Saturday 22 October 2022

A background coding 68K ASM on the Neo Geo certainly comes in handy...

I thought today I'd see if I could remember enough about Neo Geo programming to modify my old Donkey Kong source code and get something running with the Xevious tiles.

I learned a few things today; primarily that I don't comment my Neo Geo code anywhere near as comprehensively as I should. It's fine when you're in the thick of things developing, but having left it for 8 years I found myself scratching my head. Another thing is that my 68K is really rusty, but I think that'll return to me soon enough.

In the process of adapting the code for Xevious, I restructured the source tree to more closely resemble my multi-platform C transcodes. The approach I had taken with Donkey Kong was using macros to access hardware within the core code, rather than remove all host-dependent code from the core with a cleanly-architected host layer. So I fixed that.

I updated my tools to generate 68k ASM data statements for the Neo Geo palette. It occurred to me today that the rich palettes on the Neo Geo negate the need for any CLUTs (colour look-up tables); instead there is a 16-colour palette for each CLUT entry on the original hardware. I also realised that I could partition palettes between the background tiles and the sprites, but I won't get into the details now.

One thing is that each palette entry has a transparent colour (0), but the background tiles use all (4) colours and don't have transparency. The solution was to go back and modify my Neo Geo graphics tool to produce background tiles with bit 3 set, shifting them to use the top half of the palette exclusively.

I still need to organise the tiles and palettes optimally for the Neo Geo, but it's enough to get started.

With the project in place and assembling with the new source structure and a few extra files, and a few modifications to get it running again, I tried to get a single screen of background tiles to display. I dumped the memory contents from MAME and copied the background attribute and code areas into an ASM source file and set about modifying the routine that renders the Donkey Kong tilemap. In the end I scrapped it and wrote another for Xevious from scratch.

Give that I hadn't really tested the Neo Geo graphics conversion properly, or the palette/CLUT conversion at all, I was surprised when tonight I finally got to this point...

Xevious on the Neo Geo

The code is far from optimal, but not bad for one night's effort after an 8 year hiatus from Neo Geo programming (in ASM at least). It's also 4 tiles wider than what is visible on the arcade game, but I can fix that easily enough.

Next step will be to get it reading from the map ROM and then scrolling. Then add objects (sprites).

Then I really should go back and finish the RE... (but this is too much fun!)

No comments:

Post a Comment