Sega Genesis/Mega Drive emulation got a massive overhaul on steam

And I don’t just mean supporting ROM hacks, and mods, I mean this is what the new Genesis & Mega Drive Classics UI looks like:

SEGA themed bedroom

SEGA themed bedroom

First off as you can see, it’s a room.  The kind of place any SEGA nerd of the late 1980’s and early 1990’s would of course dream to own, with wall posters, sonic rug, eco toys, and of course a nice library of games and a tube TV set.

Instead of the old boring menu, you now get to choose titles off the shelf, and it’ll automatically drop them into the console.  Maybe we will get manuals rendered next?

Chose a game

Chose a game

While it is dark, it does offer a ‘time of day’ so you can watch the procession of the virtual sun in your bedroom.  I guess it speaks that we don’t get to go outdoors enough, but now we can be trapped into a virtual bedroom as well.  With our game selected, we can turn up the curvature of the tube, or even enable scanlines for that old feel..

Alien Storm

Alien Storm

The emulator is VERY demanding, there is no mistake about that.  While the classical interface was unique for the time, but it also had issues like making you scroll one at a time through the games.  As always you can buy this on steam.  A nice touch is the latest update adds in many controllers and pads.

So what is missing? The MegaCD.  The 32x.  Saturn, Dreamcat heck even the master system are suspiciously absent.  One day I suppose.  Will this hub turn into something that 3rd parties can release Genesis/Mega Drive titles onto?  Is this the start of the virtual console?

Or just a flashy UI.  I guess time will tell.

Ported System16 0.53 to Windows

To be honest, it was about 30 minutes worth of work to jump from Allegro 2.11 to Allegro 4.2.  I’ve never used it before, but the only ‘gotcha’ was how they handle the main to WinMain for linking.

At the end of your main procedure, you need to place the following code:

END_OF_MAIN()

And that is it! No semicolon either!

Last night I was playing with Musashi, and actually had the ‘demo’ program loading up the Altered Beast program, and running.  I just put in the memory areas to let it have read only to the ROM space, read write to the memory addresses, and write only to the IO ports.  It was enough for it to lock up in an endless loop like this:

E 3990: 4a38 f01c           : tst.b   $f01c.w
E 3994: 67fa                : beq     3990

Well some digging around and I found these vague hints:

Some special bytes:
F018: if bit5 is set 1, the screen is not updated
F01C: Timer ?
TimerA=&RAM[0xFF][0xF01C];
TimerB=&RAM[0xFF][0xF01E];

So it looks like it’s waiting for a shared memory value to be set to a ‘1’, so I setup the IRQ to include this nice hack:

offset=0x00FFf01c-0x00FF0000;
WRITE_BYTE(g_ram, offset,1);

And we were away.

So I thought I’d try to make the big step, as System16 v0.53 uses an ancient version of the UAE Amiga emulator, somewhere between 0.4 and 0.6, I think.  Anyways I was hoping to expand more and more functionality, and one thing SEGA did love to do was add more and more processors into their designs with some boards sporting up to three 68000 processors.  And Musashi can support multiple processors so, it seemed like a good fit.

So I amputated the UAE code, and tried to see how many functions System16 calls out from UAE, and it isn’t that much.  Most calls involve setting up emulation, and executing a single instruction. System16 handles all the memory access, Interrupts, and I/O.  So a few hours of bashing away I got it to link, and was greeted with a nice black screen.  I did remember that when I was first playing with the code, that even though the CPU was executing instructions nothing would be drawn without the external interrupt.  So I googled around and found another emulator, Virtual Jaguar, that also uses the Musashi 68000 CPU core.

So I could take the old UAE way of executing an interrupt from this:


void inline Exception(int nr, CPTR oldpc)
{
MakeSR();
#ifdef DEBUG_INT
TraceOn();
printf("Exception %0x, valeur = %0x, pc = %0x\n", nr, oldpc, m68k_getpc());
printf("Valeur de r�gistre SR = 0x%0x\n", regs.sr);
#endif
if(!regs.s) {
   regs.a[7]=regs.isp;
   regs.s=1;
   }

regs.a[7] -= 4;
put_long (regs.a[7], m68k_getpc ());
regs.a[7] -= 2;
put_word (regs.a[7], regs.sr);
m68k_setpc(get_long(regs.vbr + 4*nr));

#ifdef DEBUG_INT
printf("VBR=%08x , NR=%d , I=%04x \n", regs.vbr, nr, regs.vbr+4*nr);
if (strace) printf("int jump 0x%0x\n", regs.pc);
#endif

regs.t1 = regs.t0 = regs.m = 0;
}

To this:


void inline Exception(int nr, CPTR oldpc)
{
unsigned int sr = m68ki_init_exception();
unsigned int newPC = cpu_read_long(nr<<2);

m68ki_stack_frame_3word(m68k_get_reg(0L, M68K_REG_PC),sr);
m68k_set_reg(M68K_REG_PC,newPC);
}

A quick recompile, and it was running!

Now with that in play, I went ahead and dumped all the old code, and the old Allegro, and went through re-building with Allegro 4.2 on Windows.  It didn’t take that long, I was really impressed!  At the same time I didn’t improve on anything in the slightest.

System16 v0.53 on Windows

System16 v0.53 on Windows

This is only a proof of concept, the fun hasn’t even started yet.  If you want a ‘solid’ emulator, go with MAME.  This isn’t anywhere near ready but it is interesting that it is running.  There is much more work to do with this, especially adding a Z80, and YM2151.

You can download the Win32 executable here.  You’ll need your own Altered Beast ROMs, it’s an ancient set, nothing that any recent download will map to.

More fun with the System16, kinda, sorta?

So, Ive been playing around with emulators, and for some reason I think it’d be awesome to have a real one.  So I check ebay, and yeah there is a few, Altered Beast, Shinobi, and even an Outrun, and a couple of Hang Ons!  Wow this is so cool, then I check the prices, and shipping and yeah it’s REAL expensive, REAL quick.  And even back when I did own an Altered Beast board, I never got it hooked up as it was ‘too hard’.

So, I’m about to give up on the whole thing, then I spot this Altered Beast board, for sale for a mere €50!  And the shipping isn’t too insane either!  But looking at the PCB board in the picture, and I can tell something is not quite right:

€50 board!

€50 board!

Now for those who don’t know, this clearly is not a System16 board.  However it certainly does have a 68000, and z80 processor!  Could this be some 2nd tier manufacturing job? Or perhaps it’s one of these infamous bootleg boards?

For comparison, here is a real SEGA System16 board

A real System16 board

A real System16 board

As you can see, they really look nothing alike.  Also the other give away is that the far cheaper €50 board is JAMMA compatible.  All the old SEGA boards are not.

What the heck is JAMMA anyways?  You see that edge connector?  That is where you would plug in the power, coin catchers, the player buttons, and the speakers to.  Even in the old days, recycling cabinets was a thing, and having modular boards was a ‘good thing’.  But SEGA didn’t want you to swap out their boards with anyone elses, so they used their own system.  But it’s just a wiring thing, there is nothing digitial locked down, no encryption either (look at HDMI!).  So you can use an adapter, to interface from SEGA to JAMMA.

Anyways, I went ahead and placed the order.

Now doing some more research, and the monitors used in 1980’s arcades were RGB+Sync driven.  Which are ancient, and of course, HEAVY. But a little bit of searching led me to the to the GBS 8200 v4.0.

GBS 8200 v40

GBS 8200 v4.0

AKA known as the “GBS8200 CGA/EGA/YUV/RGB To VGA Arcade Game Video Converter”.  Well this certainly looks perfect!  I mean from the description alone, it’ll do what I want.  Even better they make them a few KM from here, and I could get one for ~ $20 USD.  Perfect.

Next up is the power, I decided to get a “JAMMA” power supply.  A bunch of searching, and this one was the cheapest one I could find, and again shipping wasn’t too bad, but not great either.  The supply was again around $20 USD, but shipping was $15. OUCH.

MD-9916A JAMMA switching power supply

MD-9916A JAMMA switching power supply

I figured having the ability to screw in would be a ‘good thing’.

Naturally, I need the cables to wire this mess together, so I ordered a “JAMMA Cabinet Wire Wiring Harness Loom” for about $15 USD.  Naturally mine is all in Chinese since I went cheap.  But it’s OK, I have a multi meter so I can test continuity.

Finally I saw a QANBA N1 arcade style joystick in a local mall for $230 HKD.  That is less than HALF the price of the ones I see online in the USA, Europe, or Canada.  So at least that is nice.  Now with all the parts, I just have to wait for the board to arrive.  And wait, and wait.  Nothing updated on ebay, then suddenly I check a few days later, as it’s been two weeks by this point, and it turns out that it’s been sitting in the post office in Hong Kong for a week!  If only they let me know…  SF Express, and FedEx have come without issues.  Oh well, now I have the board!

I can now finally flip it over to reveal:

Graphics board

Graphics board

It’s all 74L TTL logic chips, EEPROMS, and some PALs as well.  There are NO custom SEGA chips at all.  If anything this is what is inside of the SEGA ASIC’s on the System16 board.  Whoa.

Ok, so this is certainly a bootleg board.  A quick search of MAME shows that they have a Datsu ROMset, so maybe this is one?  Nothing on the boards say Datsu, however it does say ALTER/S, and it shows being QA’d on 11/11/88.

Now it’s time to cable this thing up!

But first JAMMA boards are typically key’d so you cant put the adapter in backwards.  There is no key on this board, so I need to check the voltages to make sure I don’t flip it backwards.

JAMMA Standard Pinout

** Solder Side Parts Side **




GND A 1 GND
GND B 2 GND
+5v C 3 +5v
+5v D 4 +5v
-5v E 5 -5v
+12v F 6 +12v
Key, No Pin H 7 Key, No Pin
Coin Counter 2 J 8 Coin Counter 1
Coin Lockout K 9 Coin Lockout
Speaker (-) L 10 Speaker (+)
NC M 11 NC
Video Analog Green N 12 Video Analog Red
Video Composite Sync P 13 Video Analog Blue
Service Switch R 14 Video Ground
Tilt/Slam S 15 Test
Coin B T 16 Coin A
Player 2 Start U 17 Player 1 Start
Player 2 X-Dir Player 2 Up V 18 Player 1 Up Player 1 X-Dir
Player 2 Y-Dir Player 2 Down W 19 Player 1 Down Player 1 Y-Dir
Player 2 X-Clk Player 2 Left X 20 Player 1 Left Player 1 X-Clk
Player 2 Y-Clk Player 2 Right Y 21 Player 1 Right Player 1 Y-Clk
Player 2 Button 1 Z 22 Player 1 Button 1
Player 2 Button 2 a 23 Player 1 Button 2
Player 2 Button 3 b 24 Player 1 Button 3
1 Player 2 Button 4 NC c 25 NC Player 1 Button 4 1
1 Player 2 Button 5 NC d 26 NC Player 1 Button 5 1
2 Player 2 Button 6 GND e 27 GND Player 1 Button 6 2
GND f 28 GND

This is the standard pinnout of a JAMMA harness. Importantly you can see it’s Ground than +5v.  So looking at the 68000 processor to check it’s pinnout:

D4 1 64 D5
D3 2 63 D6
D2 3 62 D7
D1 4 61 D8
D0 5 60 D9
AS 6 59 D10
UDS 7 58 D11
LDS 8 57 D12
R/W 9 56 D13
DTACK 10 55 D14
BG 11 54 D15
BGACK 12 53 GND
BR 13 52 A23
VCC 14 51 A22
CLK 15 50 A21
GND 16 49 VCC
HALT 17 48 A20
Reset 18 47 A19
VMA 19 46 A18
E 20 45 A17
VPA 21 44 A16
BERR 22 43 A15
IPL2 23 42 A14
IPL1 24 41 A13
IPL0 25 40 A12
FC2 26 39 A11
FC1 27 38 A10
FC0 28 37 A9
A1 29 36 A8
A2 30 35 A7
A3 31 34 A6
A4 32 33 A5
 You can see it’s power input is on pin 14.  Likewise, the ground is on pin 53.  Also looking at the edge connector, you can see the two pairs of pins, which correspond to the double ground, and double +5v.
Connecting the harness

Connecting the harness

From there, it was a matter of connecting up the power supply, adding in the power to the video board, connecting the RGBS connector, and powering it up.  It was very cool to get a glimpse of Altered Beast!

Something is wrong

Something is wrong

And hello, it is a Datsu board.  I’ve tried to google about these boards, and all that I could find out is that they seemed to be popular in Italy.  They may have been made in Korea.  There was another variation called ‘Mutant Warrior/Super Warrior‘.  There was some posts about it in an Italian game forum mameitalia.net, and arcadeitalia.net . Google translate works fine enough to read, but they were in smaller places that couldn’t afford mainstream games, so enter the bootlegs.  And this makes sense, as the board I got was from rural France.

I maybe had a picture for 20 seconds, it was frozen, then the screen went black.  I power cycled, to nothing.  I tried it again to a green screen.  And again to a green screen.  At this point I think it’s died.  I let it rest for a few minutes, and try again.  Nothing.  I leave it powered up, and feel the processor, and it’s warm.  It’s doing something, so I think.  So I start to play with the video board, and as I change resolutions, I get an image!.. then it disappears.  Power cycling, and changing resolutions occasionally gives me an image.  I look more closely at the CPU board, and notice that it has 4 standoffs placed on each corner.  There is nothing in the middle, and over the past 28 years the board is sagging.

In order to fix the sag, I decouple the two boards, and spread them out.  I try it again, and it doesn’t show me anything. Eventually I play with all the video board settings, and manually set it to the RGBS input, and then the image stays!  The board is running.  I tweek some of the settings, and the pink goes away, and now it looks correct!

20160430_110924

LOGO

And even the intro animation is OK

Looks good

Looks good

OK, now it’s time to turn it off, and wire up the joystick.

The first step is to remove the joystick ball, and on the QANBA N1 you first flip it upside down, and remove the little cover.

Remove the cover

Remove the cover

to reveal the screwdriver slot to let you hold the stick in place as you unscrew the ball.

slot

slot

Now it pops off, and it’s really easy to remove the USB interface cables, and drag in the JAMMA cables.  Again use a tester to tone out what goes where. DO NOT FOLLOW MY COLORING GUIDE.  I’m pretty sure there is no colour standard, so just because mine is like this, yours will 99.9999% not be.  The only common thing is that each of these buttons needs a ground.

Joystick wired up

Joystick wired up

My harness has a common ground for P1 and P2, so I just tapped up the end and tucked it in the joystick body.  Now with wired up, I can put the joystick back together, and play!

And that is when I could finally see that something was wrong.  I was doing pretty well, then in the 2nd level I saw this weird thing:

An actual wall of text

An actual wall of text

The sprites are working fine, and the gameplay continues.  But eventually the wall of text effect went from the background to the foreground obscuring game play.

foreground tile corruption

foreground tile corruption

So no doubt something is bad on the board.  I need to get it looked at, and see about first dumping and checking the EEPROMS.  Next the RAM on the graphics board, may be suspect as well.  I think the CPU is fine since it runs OK, I’m just unable to really see pass the wall.

For the heck of it, I went and got some powered speakers, and hooked them up:

And it sounds so different from the SEGA version.  An inspection of the board shows that there is no YM2151, but rather a pair of YM2203’s and an OKI M5205 for the speech synths.

In retrospect, I probably should have gone with something like the arcade supergun.  I didn’t know it was a thing unfortunately.  My solution is more “traditional” , but it works.

System 16

A long long time ago, back when I got a Pentium 100 the wonderful world of emulation was really starting to be possible with such a high powered CPU.  First was the simple Game Boy emulators, then a Commodore 64 emulator, the incredible Amiga Emulator, the beginnings of SIMH (back when it was only a PDP-11 emulator), and then I found the SEGA emulator, System 16.

It was really cool being able to play 16bit arcade games on the desktop, although rather slowly.  From there everyone knows the rise of MAME.  But while looking around for a small 68000 C compiler, I came across the source code to an older version of System 16, 0.53 on archive.org.  Naturally it’s for MS-DOS, as was everything back in the day.  Also slightly interesting is the 68000 emulation, written by Bernd Schmitd of UAE fame.  So for the heck of it, I set about getting Thierry Lescot’s System 16 building again.  I’ve never used allegro before, so it was a bit of a fight to get a version of it to actually build.  It turns out that I should have been building version 2.11 with tools of that era (why on earth was I using GCC 4, and binutils 2.18?) and instead stick with GCC 2.7.2.2 and some much older binutils.  And in no time I had build the library, and it’s examples.  With that done, I was able to re-build System 16 with GCC 4.1.2 and get a binary!

Back in the day, I actually did have an Altered Beast arcade board.  Sadly it died in a move, someone near and dear just saw the PCB as “garbage” and tossed it.  Sigh, but I did have ROM dumps, as I did a refresh of it forever ago.  Anyways I still have the ROM files, so I guess that is nice.

Anyways I fired up the emulator and got what is known as the “jail bar” effect, which is from a bad ROM.

Corrupt tiles

Corrupt tiles

Notice the sprites

Notice the sprites

The System 16 splits it’s memory into a program space, a sprite memory bank, a tile memory bank, and RAM for stack and things like the palette.  As you can see the program is certainly running, and the sprites are good.  I did some poking around a bit later, and noticed that due to a logic bug, the texture ROMs are actually never loaded!

So a quick patch, and now we get Altered Beast up and running!

Altered Beast title screen

Altered Beast title screen

demo play

demo play

Well, now isn’t that great!

Not that I would imagine anyone would really care, I mean MAME is a thing, and even from the readme:

Altered Beast : No sound emulation

So it’s pretty quiet.  Additionally the source is pretty restrictive:

These sources can’t be used for commercial purpose, any new version of the
emulator done with these sources must specify my name somewhere on the screen
et docs and I must be informed about any new release of the emulator.

For anyone interested you can find the source & binaries out on sourceforge.

Merry Christmas from Japan!

So yeah, I’ve been crazy busy this holiday season, between work and vacation so updates have . well not been forth coming.

I wanted to touch on old StarWars games for the new movie, and even got to play Star Wars on a x68000!  If it were the 80’s I would super recommend one.  But in this day/age it’s plagued by poor draw distances, poor wire frame 3d, and just poor game play.  It is probably more of a fault with the arcade version that was revolutionary for it’s time, then it rotted and was ported out.  Something like Frontier puts Star Wars to shame on low grade 68000 based hardware.

But the sound, sure was awesome!

I also want to do some passable review of the retro freak!  I picked up one for about $150 USD. It is expensive, there is no doubt about that, and it is emulation.  I also picked up a NES on a chip console clone for about $13 USD.  At the same time I can score a MegaDrive for about 30-40 USD, and 25-30 for a SNES.  Which brings me to an interesting observation:

There is next to NO Mega Drive stuff.  There is far more Saturn, and very few Dreamcast, but I’s seen maybe 15 Mega Drive carts.  Meanwhile I’ve found Famicom/Super Famicom stuff almost everywhere I look.  My favorite is the local chain “Book Off” that almost always has a nice retro section, along with used PS1, PS2, PS3 and PS4 stuff.

Otherwise, I have horrible to non existent internet in the house I rented (it is like the yacht in Hong Kong from a few years back), so I’ve been forced to spend my time in internet cafes for 12+ hours a day.

Oh yeah, Tokyo is just like London.  After 6pm, everyone goes home, the stores close, and there is nothing open.  After 10 the trains stop and that is that.

While I’m on the subject of living in the future, and working physically wherever, the Microsoft Surface is a HORRIBLE HORRIBLE thing.  Granted I didn’t pay for this one, but it’s wifi chip is utter crap, it is prone to locking hard, and the kickstand and detachable keyboard is a JOKE.  I know Balmer wanted in on the iPad action, and then the Surface RT, eventually became just another PC, but damn a laptop this is not.  The only nice thing I can say is that it boots fast.  Which is something you’ll be doing lots of.  The fan is noisy and distracting, the display is OK, but nothing fancy in this modern age.

I currently had to go out and buy 2 USB Ethernet adapters and bridge the cafe’s internet so I could connect this POS.  I give the Microsoft Surface Pro v3 a 1/5*.  AVOID DO NOT BUY.

Merry Christmas!

Merry Christmas!

In the “neato” section, I did find an eval copy of Citrix.  And a NIB quality box of Postal 2!  I didn’t know there was any updates so that was a surprise.  But now I see it is on sale over on Steam, for $7.50 Hong Kong Dollars.  I would do some give away but I also found out that my account got converted. YAY.

steam is now in HKD

Steam is now priced in Hong Kong Dollars!

Which means I cannot give anything away as apparently I now live in a poorer area and get subsidized games. I guess that is to make up for censored and restricted catalogs.

So yeah, I am alive.

And MERRY CHRISTMAS!!!!!!

Crazy to think that 2016 is literally around the corner!

SEGA exits the console market

And if that isn’t crazy enough, they rebranded themselves as SEGA Games.

No, really.

SEGA used to stand for SErvice, GAmes, so now they’ve just re-named themselves Service Games Games.  I guess it hails back to Windows 2000 being built on Windows New Technology, Technology.

But consoles are in decline, mobile phones and PC is where the market is, so it’s no surprise.  The only other question is how many more times am I going to end up paying for Altered Beast, Phantasy Star II, and various genesis games.

CannonBall!

CannonBall!

CannonBall!

So while indulging my SEGA kick, I came across something super cool, a blog dedicated to reverse engineering and porting outrun to C++, Reassembler!

Now this is pretty awesome in that not only does it work (and boy does it!), his Outrun! project, CannonBall runs on OS X, Windows, Linux, and can you believe it, javascript. (you need an OutrunB ROM for this, as it loads all it’s sound, music, graphics and map resources from an Outrun rom set).   You can read about his javascript porting adventure here, the TL;DR version is that he used emscripten to  convert clang’s LLVM bytecode into javascript.  Boy does this seem to open up quite a few possibilities as javascript compilers seem to get better and better on the browser side.  I happily get 60fps on my MacBook Air with Chrome.

Even better he’s got another project, LayOut, which lets you build your own maps for CannonBall!

For fun, be sure to check out his Easter Eggs section, there is quite a bit of stuff hiding in these old ROMs.  Not to mention there is enough other gamestuff in them, that SEGA didn’t build each game for their boards in a vacuum.

All and all, I’d say it’s a good read!

Revenge of Shinobi now available on steam!

I remember paying well over $100 CDN for this back when it came out… But now its on sale for $2.99 … lol wow the times have changed!  And of course this is where the whole ‘neozeed’ thing came from, nothing to do with the matrix.

I wonder how long until they start releasing SegaCD & 32x stuff?

Looks like instead of drinking too many dos equis, I’ll be trying to remember how to do that double jump throw thing.