There’s a problem with my current series on mahjong games– when I say “mahjong”, people in my home country of the United States of America probably don’t think of the 2-4 player competitive game. They think of the single-player tile-matching game, Mahjong Solitaire, also known as Shanghai, beloved of office-workers and casual gamers everywhere. And that’s popular in Japan too; popular enough to get arcade releases. How did Sunsoft bring Shanghai to arcades? Why is that even a question worth asking?

Born on the PC

The exact origins of the tile-matching game using mahjong tiles are unclear, but making it a video game is usually attributed to Brodie Lockard, who discovered the tile-matching game as he dealt with recovery from an injury that had left him paralyzed, porting it to the PLATO system. But it was the Activision-published 1986 release across computers that really made it a mainstream hit.

Shanghai on the Apple II, the dragon

Shanghai presents you with an arrangement of mahjong tiles arranged in a multi-level structure. You can remove tiles from the structure, but you have to follow certain rules when doing so: to be removed, they must have an empty space on one side, and nothing on top of them. This is a nice brain teaser, and honestly I’m completely addicted to it.

Shanghai on the Apple II gameplay. Tiles are stacked

Take a look at the 1986 Apple ][ version above. This uses the Apple’s “HIRES” directly-addressable pixel graphics mode; and while that’s normal for games on this platform, Shanghai pretty much necessitates using the directly-addressable pixel graphics modes whenever possible. Because the problem is that any tile could be on top of any other tile, and they can be on different levels. There’s no tile grid.

Shanghai on NES. The colors are different, rather than having visually different levels

And that’s what makes this game so interesting as a use case for comparing ports. Because while computers of this period generally have directly-addressable graphics modes, game-centric hardware usually did not, and that made this game hard to port. The Famicom port above is particularly pathetic; it uses colors to simulate the layers and tiles are limited to 16x16. It’s actually extremely playable and has catchy music, but it’s highly compromised visually. (Oddly, the CGA IBM PC release also used colors instead of levels)

a shanghai game on master system. The tiles are big but the player is stuck

The Sega Master System version is far superior, with big tiles taking up almost the entire screen. This is because the Master System, while not having directly-addressable pixel modes (other than the legacy mode, used in F-16 Fighting Falcon for exactly this purpose, but thank goodness they didn’t use that), does have video RAM. But it doesn’t actually have enough video ram to tile this whole area. So how’s it doing this? Take a look at the tiles in an emulator like Emulicious.

list of the tiles. a few are flickering

Certain tiles from the top row of tiles are being redrawn mid-frame so they can fulfill double-duty as also covering the bottom row. You can also see how this game uses the majority of the sprite table in VRAM to act as additional tiles instead; the only sprites used are those that make up the cursor. It seems like such a simple screen, but they’re actually pushing the console here! This port was developed in-house at Sega, usually attributed to the famous Mark Cerny.

It’s not just graphical issues. Look at the video of Shanghai on Famicom below. Notice how long it takes for the game to figure out how many moves the player has remaining. Sure, it’s not more than a few seconds, but that’s a lot of frames. Therefore, this version of Shanghai can’t end your game automatically when you have no moves left. I’ve often complimented the Famicom’s plucky little 1.7MHz almost-6502, but this is a complex combinatorial problem. (It’s a faster CPU than the Apple ][!)

It’s worth noting, though, that Shanghai II on the same platform does detect this automatically (though it still takes a few frames to notice), so it’s likely that the original game could’ve done this. This is all just context to let you know that Shanghai is more complex to support than it looks at first glance. We’ve looked at a lot of arcade game hardware here, and it’s almost all tile-based. Tiles are great for video games! But this game required another approach.

The game warns that the player can not call ron, due to the rule of furiten

You might wonder if this is another case where a blitter, like Nichibutsu used on almost all their mahjong titles, would be a good fit. After all, it’s very clearly shown that those can copy large mahjong tiles around. Well, maybe it would’ve been. But for their 1988 arcade release, Sunsoft did something else.

Advances in PC

The PCB is large but spacious, festooned with both Sunsoft’s logo and the logo of their parent company, the Sun Corporation of Japan, a Japanese conglomerate that still exists today, owning businesses ranging from the recent Sunsoft revival to, uh, an Israeli phone-hacking firm? Okay then…

The PCB of Shanghai

In any case, the first interesting thing about this board is the CPU. It’s an 8MHz NEC V30; this is an upgraded version of the Intel 8086, which means it’s a 16-bit CPU with a 16-bit data bus and a 20-bit address bus.

NEC V30 chip

Certainly x86 processors are less common than Motorola 68000s in arcade boards of this time, but they’re not unheard of either. In terms of arcade boards that have shown up on this blog, Panic Road used an NEC V30 clone made by Sony. And of course, this also would’ve been a decent CPU for a home computer of the time, though the high-end was leaving it behind by 1988. Pairing it with 16kiB of RAM, though? Extremely stingy. (Yes, yes, code executes from ROM)

Panic Road title screen, with a Seibu Kaihatsu copyright

I’m not certain, but I suspect that Seibu Kaihatsu, who developed Panic Road, may have been involved in the hardware side of things for Shanghai. Admittedly, this is mostly just the use of the V30 CPU, and the fact that Success’ Kyuukyoku no Othello used similar hardware, but paired with a Seibu Kaihatsu sound setup, and Seibu Kaihatsu appears to have very frequently did this kind of contract hardware work. (The software is all Sunsoft, as far as I can tell)

YM2203 on the PCB

That being said, Shanghai does not use a Seibu Kaihatsu sound system; it hooks up a Yamaha YM2203 FM synthesizer right up to the V30’s IO ports. The four-operator three-voice YM2203 was a constant companion of Japanese arcade games in the 1980’s; we’ve seen it most recently in my post on Taito’s Kiki KaiKai, and it was a popular sound expansion option for NEC’s PC98 computer series.

The large many-pinned HD63484

The graphics is where this gets particularly interesting. This is the Hitachi HD63484; their answer to the NEC APC’s μPD7220 (which shared a team with the μPD777 we saw in the past with Epoch’s machines). IEEE Computer World notes that in 1988 24% of the PC graphics cards targeting computer-assisted design (CAD) used it.

It was noted for its elegant command-based interface and very high resolution graphics capability; 4096x4096, for a chip released in 1984! (Though at that high resolution, you’re limited to monochrome) Of course, Shanghai is designed for JAMMA, which is limited to “standard definition” video, so you’d never reach that. That mode also required 2MiB of RAM, apparently; here, it’s paired with 256kiB of RAM; this is also the slower 8MHz version.

Indeed, overall the low RAM (and the 15kHz output) is really the main thing separating this from a PC of the time; otherwise, this is a “professional-grade” video setup and CPU. And for what?

Shanghai

Shanghai title screen, showing two Chinese men looking at the tile structure

The title screen of Shanghai is the same image that Activision used on the box art for most releases in this time, and was also used in the Famicom support, though this is much higher resolution and pretty good quality. (The kanji characters, 上海, mean “above the sea”, but in this case are likely used because this is the Chinese character rendering of the name of the city of Shanghai)

Before we dig into the gameplay, let’s talk about the video a bit more. I used the Framemeister for this capture, and got some stats from it.

Input RGB, Dot 720x279p, V: 53.44Hz, Color: RGB Analog

You might notice the screen looks slightly cut-off; this makes sense when you notice the Framemeister identifies this as actually running at 53.44Hz and 279p, a very odd video resolution. Weird frequencies like this were more common in the PC space, but weren’t unheard of in the arcade space either. Generally you’d tune your monitor once for a particular board, and that board would stay in place for awhile, so being off was fine. It’s mostly an issue for those of us who want to switch out boards at random and use upscalers; that was never the target market.

Shanghai running on a CRT

My little 9” Trinitron does sync otot the image, but you can see even more of the top of the image was cropped, and my phone completely failed to sync properly to take a good image. Still, in practice I don’t think this is a bit problem. Let’s shift gears from the video signal to talking about something else that is a prediliction of this blog: talking about the difference between arcade games and home computer games!

Translating Shanghainese

Shanghai, as a game, falls into the same category of “patience” games like the classic card game Klondike Solitaire. It’s a single-player game where the main point is just to complete the challenge by moving things about. There isn’t really a loss condition, other than the game becoming impossible. Indeed, Activision’s game usually provides options for reversing moves and finding new moves. (Peeking, on the other hand, usually ends your game) These features are why it’s so much nicer to play Shanghai on a computer rather than building a tower on your table.

Shanghai on Famicom, options menu: BACKUP, RETRY, FIND, PEEK

Naturally, this is a great way to sabotage the productivity of office workers. But it’s not a great way to make money in an arcade; obviously, if you could just put in one quarter and play for hours, arcade operators would go and buy someone else’s game instead. It’s a business.

Shanghai gameplay

So Sunsoft made some changes. Notice the timer at the bottom of the screen; if you make a pair, the timer replenishes a bit. Being able to “find” is limited to three times; this is what the three sticks labeled “HELP!” are for. Being able to back up is gone entirely. On the other hand, since this was a fairly new game, Japanese text explaining how to play is also added.

Shanghai death screen

If you run out of possible moves, the game kills you, but gives you the option to restart with the same board. You start from the beginning, though, so I hope your memory’s good. The lack of any sort of single-step backup is I think a weakness of this game. The later Sunsoft arcade title Shanghai: The Great Wall (Shanghai Triple Threat), which used the Sega ST-V hardware, allows both a selection of three helps and three backups. Otherwise, it follows the basic pattern of this timer-based gameplay very closely, because it actually works pretty well.

Shanghai on STV, showing the backs

There’s another thing that’s kind of odd. In all the versions of Shanghai I’ve discussed here except the arcade one, the mouse cursor moves freely. This is because it’s a mouse cursor, and that’s what they usually do; even when they’re being moved by a controller or something else that isn’t technically a mouse.

Shanghai on arcade

But for this arcade game, your cursor is snapped; it always moves to be on top of something you can click on. Moving left doesn’t move it left by a small amount, it moves it to the next leftmost element that you can click on (presumably a tile). It’s fine, and maybe was done to speed up play, but I can see why the ST-V sequel does away with it.

I’ve never even been to China

This might sound like I’m being harsh on Shanghai. And maybe I am, so let’s be clear: this is a very fun game, and there’s a reason it kicked off a whole series of Sunsoft arcade games. The timer adds an element of urgency that’s lacking in the original. It’s hardly the first game’s fault Sunsoft refined the formula later on.

Screen clear! in ST-V Shanghai

In fact, I always like to go back to the original Shanghai for the simplicity of design; something about just having a single possible layout and a basic set of controls is appealing. And Shanghai for arcade provides that much. The fact that it does so while also being basically a contemporary PC workstation someone stole all the RAM from? That’s just icing on the cake.

Arcade Shanghai with the top tile selected