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

0 Members and 1 Guest are viewing this topic.

Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1764
  • I'm going to jump next to your leg.
    • Donkey Blog
    • Awards
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 06, 2015, 12:09:11 am 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?
Member for 11 Years DK Masters - Rank D DKJR Killscreener IGBY 2016 DKF Team Member IGBY 2015 DKF Team Member IGBY 2014 DKF Team Member Blogger Twitch Streamer DK Killscreener CK Killscreener

Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1764
  • I'm going to jump next to your leg.
    • Donkey Blog
    • Awards
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?
Member for 11 Years DK Masters - Rank D DKJR Killscreener IGBY 2016 DKF Team Member IGBY 2015 DKF Team Member IGBY 2014 DKF Team Member Blogger Twitch Streamer DK Killscreener CK Killscreener

Offline Evunz

  • Full Member
  • *
  • Posts: 65
    • Awards
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
Member for 9 Years Blogger Twitch Streamer

Offline f_symbols

  • Spring Jumper
  • *
  • Posts: 835
  • wht u mean
    • Awards
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?
Member for 11 Years IGBY 2016 DKF Team Member Winner of a community event Former DK Remix World Record Holder DK Remix Killscreener IGBY 2015 DKF Team Member DK 1M Point Scorer IGBY 2014 DKF Team Member Blogger DK Killscreener Twitch Streamer

Offline tudose

  • Spring Jumper
  • *
  • Posts: 536
    • Awards
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
Member for 11 Years Former CK World Record Holder - MAME DKJR World Record Holder - MAME DK Masters - Rank D DKJR Killscreener DK 1.1M Point Scorer IGBY 2016 DKF Team Member IGBY 2015 DKF Team Member Blogger Winner of a community event DK Killscreener DK 1M Point Scorer CK Killscreener Twitch Streamer Former DK Level 1-1 World Record Holder

Offline marinomitch13

  • Spring Jumper
  • *
  • Posts: 1806
    • How to Play DK
    • Awards
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.
Member for 11 Years IGBY 2015 DKF Team Member DK Killscreener Blogger Twitch Streamer

jammyyy

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


Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1764
  • I'm going to jump next to your leg.
    • Donkey Blog
    • Awards
Re: HACKED ROMS: Crazy Kong 117!
« Reply #7 on: March 21, 2015, 01: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?
Member for 11 Years DK Masters - Rank D DKJR Killscreener IGBY 2016 DKF Team Member IGBY 2015 DKF Team Member IGBY 2014 DKF Team Member Blogger Twitch Streamer DK Killscreener CK Killscreener