Author Topic: HACKED ROMS: Crazy Kong 117!  (Read 3621 times)

0 Members and 1 Guest are viewing this topic.

Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1648
  • I'm going to jump next to your leg.
    • Donkey Blog
HACKED ROMS: Crazy Kong 117!
« on: February 22, 2015, 03:15:29 AM »
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 MAME

1. 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 HACK

There 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. ;D 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 KONG

So, 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! <Tim>
« Last Edit: May 05, 2015, 11:09:11 PM by ChrisP »
http://donkeykongblog.blogspot.com

4 Quarters :-* - 800K Avg. Per Qtr. :o - No Restarts 8) - No Proof :'(

7/26/2013   Coin 35,946   710,800   18-1
7/28/2013   Coin 35,947   903,700   22-1
8/16/2013   Coin 35,948   694,100   17-6
8/17/2013   Coin 35,949   893,100   22-1

3,201,700: the $1 World Record?
Twitch TV  Streamer DK Killscreener Crazy Kong Killscreener DKF Blogger

Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1648
  • I'm going to jump next to your leg.
    • Donkey Blog
Re: HACKED ROMS: Crazy Kong 117!
« Reply #1 on: February 22, 2015, 03:55:26 AM »
At this point I know enough that I could also patch the ladder cheat, add jump-steering, and patch the floor glitch if anybody thinks it's a good idea! I dunno though, then it starts to not feel like Crazy Kong anymore.
http://donkeykongblog.blogspot.com

4 Quarters :-* - 800K Avg. Per Qtr. :o - No Restarts 8) - No Proof :'(

7/26/2013   Coin 35,946   710,800   18-1
7/28/2013   Coin 35,947   903,700   22-1
8/16/2013   Coin 35,948   694,100   17-6
8/17/2013   Coin 35,949   893,100   22-1

3,201,700: the $1 World Record?
Twitch TV  Streamer DK Killscreener Crazy Kong Killscreener DKF Blogger

Offline Evunz

  • Full Member
  • *
  • Posts: 63
Re: HACKED ROMS: Crazy Kong 117!
« Reply #2 on: February 22, 2015, 05:31:58 AM »
Good job Chris, this is very interesting !
« Last Edit: February 22, 2015, 05:33:29 AM by Evunz »
I'm a french player http://www.twitch.tv/evunz
DKF Blogger Twitch TV  Streamer

Offline f_symbols

  • Spring Jumper
  • *
  • Posts: 742
  • wht u mean
Re: HACKED ROMS: Crazy Kong 117!
« Reply #3 on: February 22, 2015, 11:06:01 AM »
Kreygasm Kreygasm Kreygasm Kreygasm Kreygasm Kreygasm Kreygasm Kreygasm                                                      Kreygasm Kreygasm Kreygasm Kreygasm                        <Pigger>                      Kreygasm Kreygasm Kreygasm Kreygasm Kreygasm
This is so hot, one could reckon the Tudose will love it as much as the ladies love the Tudose.  I also agree (as a non-player of CK FailFish) that if you start changing things too much, it will just become dk w/ CK sprites.  Kudos Chrispy, your skills never cease to amaze

 <Tim>  Did you have enough bits?
DK Remix Killscreener Twitch TV  Streamer DK Killscreener DKF Blogger DK 1 Million Point Scorer

Offline p2dose

  • Elite Member
  • *
  • Posts: 472
Re: HACKED ROMS: Crazy Kong 117!
« Reply #4 on: February 22, 2015, 12:03:25 PM »
great work, chris! this is pretty fkn sweet. lol ethan <Tim>

i reckon ill fire this one up next week at some point love it

Offline marinomitch13

  • Strategy Moderator
  • Spring Jumper
  • *
  • Posts: 1745
    • How to Play DK
Re: HACKED ROMS: Crazy Kong 117!
« Reply #5 on: February 22, 2015, 02:11:13 PM »
Oh my! Did Chris just figure out a round-about way to get Phil to play something that is ever-so-slightly-more-like DK? I think so.  Kreygasm  Kappa
“Thou hast made us for Thyself, and our heart is restless until it finds its rest in Thee.” -Augustine, Confessions.
Twitch TV  Streamer DKF Blogger DK Killscreener

Offline jammyyy

  • Full Member
  • *
  • Posts: 72
Re: HACKED ROMS: Crazy Kong 117!
« Reply #6 on: March 18, 2015, 06:40:17 PM »
Hay Chirs can you upload your hack to FB THE MAME EVENT! Classic Gaming's Weekend Warriors file section ?  ::)

Twitch TV  Streamer

Offline dkshawn

  • Senior Member
  • *
  • Posts: 123
Re: HACKED ROMS: Crazy Kong 117!
« Reply #7 on: March 20, 2015, 01:29:22 PM »
I have also been studying z80 assembly and the DK code listing. This week, for the first time, I was actually able to modify mario's sprite graphics in Turaco and get the moded rom to play in mame. I just changed mario to be a fireball and ran around as a fireball. It was quite a thrilling moment when it worked because it took a lot of trial and error to get that to work. I'm a programmer so the whole hacking game code thing is interesting to me. I havn't tweaked any code yet because I don't really have any simple ideas. A while back I thought I wanted to fix the kill screen but that has already been done. Wild barrell hack - done. I did find a web page that showed all sort of DK moded graphics was interesting. The Pink Floyd DK. The Bill Clinton DK. The Pac Man DK. I have some related ideas. I'm not sure it will ever happen, but I think creating another DK2 Jumpman Returns type of game would been a worthwhile effort. I have some ideas but easier said than done! Still just reading/reviewing code for fun. But it's nice to see other people with the same coding interests.
DK Cabinet 1,022,700 KS (1/24/2015)
DK Killscreener Twitch TV  Streamer DKF Blogger DK 1 Million Point Scorer

Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1648
  • I'm going to jump next to your leg.
    • Donkey Blog
Re: HACKED ROMS: Crazy Kong 117!
« Reply #8 on: March 21, 2015, 12:34:12 AM »
Whoah Shawn, Jumpman as a fireball, I want it!

You should attach that ROM if you can.
http://donkeykongblog.blogspot.com

4 Quarters :-* - 800K Avg. Per Qtr. :o - No Restarts 8) - No Proof :'(

7/26/2013   Coin 35,946   710,800   18-1
7/28/2013   Coin 35,947   903,700   22-1
8/16/2013   Coin 35,948   694,100   17-6
8/17/2013   Coin 35,949   893,100   22-1

3,201,700: the $1 World Record?
Twitch TV  Streamer DK Killscreener Crazy Kong Killscreener DKF Blogger

Offline dkshawn

  • Senior Member
  • *
  • Posts: 123
Re: HACKED ROMS: Crazy Kong 117!
« Reply #9 on: March 25, 2015, 01:56:04 PM »
Ok, I attached it. I kinda didn't want to put it out there cause it's just a quick tweak of the graphics and I actually don't find it fun to play except for the novelty of running around as a firefox this time but I guess you might have fun for a few minutes too.
DK Cabinet 1,022,700 KS (1/24/2015)
DK Killscreener Twitch TV  Streamer DKF Blogger DK 1 Million Point Scorer