I know that it might be considered sacrilege to defile a classic, particularly the elegant, flawless, bug-free perfection that is Crazy Kong, but I've been learning and messing around with the Z80 assembly language and the DK code quite a bit for some time and decided that it would be fun to implement one hack that I've always wanted to see: a 117-board version of CK, laid out just like US-style Donkey Kong!
In other words, a DK-type L1-L4 start, with L5+ as the barrels-conveyors-barrels-elevators-barrels-rivets sequence that we know and love.
Tonight I managed to pull that off! Awesome!
The ROM is attached and playable in MAME.
PLAYING THIS IN MAME1. If you're going to be playing in a MAME version prior to 122 (that includes you 106 users) the ROM file must be named "ckong.zip". If playing in a version after 122, the ROM file must be named "ckongpt2.zip". The ROM name must be exact. If you have the original in there, be sure to temporarily rename it to "ckong.bak" (or whatever you like) to set it aside.
2. The game will only run if you are using either 1) a front end (such as the WolfMAME 106 GUI, MAME32, etc.) OR 2) the command line. MAME will report an incorrect checksum before starting emulation, but it will work. Those are the only two options.
You cannot start the game from the "stock" front end/GUI that comes with newer MAMEs. When you select the game and try to start it, it will report that the ROMs are incorrect and won't budge from there. This is a (very annoying) quirk of the built-in GUI. Games with bad checksums can run just fine from the command line, or any other front end, but not from MAME's GUI. Go figure...
So far I have tested this up through level 6 and all seems well, and I didn't change anything else.
If any nerdlingers are interested in the technical details of how this was accomplished, read on.
NINTENDO OF AMERICA'S DK LEVEL HACKThere is a 21-byte table (physically located on the last DK ROM chip, close to the end of the 3000-3FFF program space) which dictates the layout of the board types for the first 20 boards (1-1 through the L5 rivets), with a numerical code 01 (barrels) through 04 (rivets) representing each board type. The 21st byte specifies the end of the table.
Among Nintendo of America's changes to the DK code when they brought the game to the US was to alter this table.
In the original Japanese code, the 21-byte block is just 01-02-03-04 repeated five times + the "end of table" byte. It might seem redundant at first to repeat the same four bytes five times over, but as we all know, DK has five internal difficulty settings, and each of DK Japan's first 20 boards behaves uniquely unto itself, starting at "x" difficulty and going up (or not), depending on what level you're on, as the timer goes down. Thus all 20 boards need a specific reference in the table that can be loaded into memory for difficulty-ramping.
** NEXT-DAY EDIT: Something troubled me about this and the more I thought about it, the more I realized I had to be at least partly wrong. I think I was.
Both the level number and board-type also go into memory, and those two variables SHOULD be all the program needs in order to determine the difficulty setting, so technically repeating 01-02-03-04 five times IS redundant and the table should indeed only have the four entries! In fact, the table might not even be necessary at all...
In addition, the text for "125m" and "150m" are options explicitly built-in for the "how high?" screen, and the part of the code that determines how many stacked monkeys to draw does check for 6 monkeys, which you would never see in the Japanese version since all levels top out at 100m. Why would they add 125m and 150m text blocks and a monkey-stack limit of 6 if they were never intended to be used? So I'm thinking that they actually DID code the board-slot scheme with flexibility in mind, in order to keep options open for easy tweaking later. They just never implemented a different layout for the Japanese release. It was an interesting decision. I am still a novice with this stuff, so perhaps someone better with Z80 assembly and/or the DK program in general can chime in if my thinking is wrong? **
There are, at any rate, those 20 distinct slots in the table, and NOA did indeed take advantage of this to spice up the game and give it more mystery/replay value. Change any/all of the 20 entries in the table and you change the order. NOA changed the table to:
01-04-01-03-04-01-02-03-04-01-02-01-03-04-01-02-01-03-01-04.
With that done, there was one more simple but critical change.
In two different "cleared board" subroutines further back in the program (physically they're on the first ROM chip), after clearing a board there's an instruction to increment the level layout table up by 1 and load it into memory. The instruction immediately following asks "did we hit the end-of-table byte?" If that's a no, we proceed to the next instruction. But if that's a yes, the instruction is to go back to position 17 in the table (which is 5-1 in the Japanese version, and 5-3 in the US version). Obviously we don't want to go to 5-3, so for the US version we just change the referenced byte to position 15, which is 5-1 US. The level counter increments, but as far as the layout table is concerned, we're back to slot 15.
At the end of L6, the level counter increments to 7, but now that we've completed slot 20 in the layout we run into the "end of table" 21st byte again, returning us to slot 15 in the table... and hence we have our loop.
So, change the slot from 17 to 15 in both subroutines and the patch is finished.
HACKING CRAZY KONGSo, how to get this US-style board layout change into Crazy Kong?
Luckily, CK is basically "grafted" onto DK's code, albeit with many changed bytes throughout, plus lots of new code on two additional ROM chips (to do the new attract mode, accommodate the different hardware, etc.). It all gets pretty messy because of that. If viewed in a HEX diff viewer, which I used, it's interesting to see at a glance how the CK code weaves in and out. At any rate, since CK is more of a graft than a rewrite, whatever bytes are alike will be at the same addresses in both programs. If you know where in DK to find the level layout table and the 2 instructions for the loop subroutine, then you have them in CK.
Pull the two CK chips that need modification out of the ckong.zip, open them in a HEX editor, update the subroutines and the layout table to match DK US, dump them back into the zip, and that's it. 117 boards, laid out the way we're used to!
It actually took me longer to write this out than to just do the (simple) hack, but I know some people are interested in the game code and the logic of it. Hopefully somebody will have a few minutes of fun with this. I'm curious to see what kind of start score Phil can get.
I predict a million'll happen! A million!