Thursday 12 December 2013

Coins and dipswitches

Some more integration into Neo Geo, bugfixes and tidy-ups tonight.

I got curious about the soft dipswitches on the Neo Geo; now the Donkey Kong dipswitches are all implemented on the Neo Geo. I've replaced the cabinet upright/cocktail switch with a horizontal/vertical switch that controls the screen rotation.


I got thrown for a while because the game name wouldn't appear correctly on the setup screen. After scratching my head for a while before relenting and tracing through BIOS calls, I discovered that it is read from the backup RAM, not the dipswitch settings table in ROM! And because I had run Neo Kong previously with garbage in the table, it had saved a rubbish game name in the backup RAM (everything is keyed from the NGH number in the ROM header). Deleting the saveram file and running it again fixed the issue.

I also fixed the coin-up issue, which was a bug in the 68K port; comes from reading Z80 instructions which are <dest>,<src> and translating to 68K which is <src>,<dest>. Not the first time I've made that mistake, and it won't be the last. So I can coin-up and start a 1P or 2P game (which I've now hooked up to the actual START buttons on the Neo Geo)...

...which brings me to another Z80 Donkey Kong bug. The routine to detect 1P and 2P start buttons stores a mask in the B register, depending on whether there is one or more credits. Then the routine periodically prints the 'PRESS 1P or 2P START' message, depending on a timer value, before reading the hardware and testing the input against the mask. The bug is that if the messages are displayed, then the B register is not preserved, and is always set to 0. It doesn't matter, because invariably the button is detected on the next loop, and the message not displayed and it all works.

This in turn resulted in a related but different bug on the 68K port; the mask register wasn't being set to 0, but 0xff - meaning that pressing 2P start with only 1 credit was being accepted. Anyway, all fixed on the 68K port now.

Next session I can well and truly get into the game-play code. First order of business will be getting Mario to move on the 1st level. But I have a feeling that I won't get the opportunity tomorrow, so it'll have to wait a few days...

No comments:

Post a Comment