Author Topic: Donkey Kong Program Code  (Read 54611 times)

0 Members and 1 Guest are viewing this topic.

Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1763
  • I'm going to jump next to your leg.
    • Donkey Blog
    • Awards
Donkey Kong Program Code
« on: July 08, 2013, 07:47:14 pm »
I guess it's about time that this was posted.

This will be totally unintelligible to pretty much all of us (including me), but people wanted it, so what the heck.

This is US Set 1 (TKG-4), in plain text.

I don't remember what program I used to disassemble it (it was 7 months ago and I never used it before or since), and I'm quite sure that I didn't do it "optimally." If any of these opcodes didn't get translated correctly, I would not know.

BUT it's "in order" and complete, as far as I know. This combines c_5et_g.bin, c_5ct_g.bin, c_5bt_g.bin, and c_5at_g.bin, which are the game code ROMs.

If nothing else my line numbers (in HEX) line up with the ones that Jeff Kulczycki has here, so it would appear that I did something right.

If anybody's got a better version, feel free to post it!
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 DKJR Killscreener DK Masters - Rank D Blogger Twitch Streamer DK Killscreener CK Killscreener

SQUIIDUX

  • Guest
Re: Donkey Kong Program Code
« Reply #1 on: July 08, 2013, 07:49:05 pm »
let's see what we can get going here

Offline marinomitch13

  • Spring Jumper
  • *
  • Posts: 1806
    • How to Play DK
    • Awards
Re: Donkey Kong Program Code
« Reply #2 on: July 08, 2013, 08:15:13 pm »
Excellent! Once the manual is done, I swear a solemn vow to learn assembly and read this code!!!
"Thou hast made us for Thyself, and our heart is restless until it finds its rest in Thee." -Augustine, Confessions.
Member for 11 Years DK Killscreener Blogger Twitch Streamer

Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1763
  • I'm going to jump next to your leg.
    • Donkey Blog
    • Awards
Re: Donkey Kong Program Code
« Reply #3 on: July 08, 2013, 08:19:33 pm »
3F30 through 3F9F are definitely NOT opcodes, for example.

"PROGRAM,WE WOULD TEACH YOU.*****TEL.TOKYO-JAPAN 044(244)2151    EXTENTION 304   SYSTEM DESIGN   IKEGAMI CO. LIM."

So that section is just HEX codes for ASCII text characters. (50 is HEX for "P", 52=R, 4F=O, etc.)

But the disassembler translated them in terms of the Z80 opcode instruction set, so in the disassembled file it reads as
3f30 50        LD      D,B
3f31 52        LD      D,D
3f32 4F        LD      C,A
etc.

My disassembly might be full of problems like that, or might not be, because I don't know what I'm doing, or what I'm reading. I don't know how to differentiate what's actually machine code from what's junk. Probably very little junk in here though, I would assume, since the whole program had to fit into 16K.
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 DKJR Killscreener DK Masters - Rank D Blogger Twitch Streamer DK Killscreener CK Killscreener

Offline JCHarrist

  • Spring Jumper
  • *
  • Posts: 643
    • Donkey Kong Forum
    • Awards
Re: Donkey Kong Program Code
« Reply #4 on: July 08, 2013, 08:21:56 pm »
Someone should call that number. ;D
Member for 11 Years DKF Founder Former CK World Record Holder - Arcade CK Killscreener DK Killscreener

Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1763
  • I'm going to jump next to your leg.
    • Donkey Blog
    • Awards
Re: Donkey Kong Program Code
« Reply #5 on: July 08, 2013, 08:28:07 pm »
Here it is unconverted in case somebody wants to re-disassemble it.

The secret message (or, at least, the part of it that didn't get overwritten by the U.S. code changes) is at the bottom.

« Last Edit: July 08, 2013, 09:59:00 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?
Member for 11 Years DKJR Killscreener DK Masters - Rank D Blogger Twitch Streamer DK Killscreener CK Killscreener

Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1763
  • I'm going to jump next to your leg.
    • Donkey Blog
    • Awards
Re: Donkey Kong Program Code
« Reply #6 on: July 08, 2013, 08:43:11 pm »
Oh yeah, it was dz80 that I used.

And as Jeff says:
"dZ80 won't tell you when you've hit data instead of code.  You'll just have to be on your toes and notice when the code stops making sense and starts looking like random garbage."

(Which is what causes the problem of dz80 trying to translate that text as machine codes)

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 DKJR Killscreener DK Masters - Rank D Blogger Twitch Streamer DK Killscreener CK Killscreener

Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1763
  • I'm going to jump next to your leg.
    • Donkey Blog
    • Awards
Re: Donkey Kong Program Code
« Reply #7 on: July 08, 2013, 08:50:48 pm »
Oh yer.

In the code I posted the "$"s came out as "H"s, but it's all the same stuff...

Now we just need somebody to figure all this out!

Allen?
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 DKJR Killscreener DK Masters - Rank D Blogger Twitch Streamer DK Killscreener CK Killscreener

corey.chambers

  • Guest
Re: Donkey Kong Program Code
« Reply #8 on: July 08, 2013, 08:52:30 pm »
Who volunteers to create the Program Code Training Video?  :P

Offline Monstabonza

  • Senior Member
  • *
  • Posts: 237
    • Awards
Re: Donkey Kong Program Code
« Reply #9 on: July 08, 2013, 09:07:06 pm »
That would be you Corey the resident video editing guru ;)
Dk PB 391800
Dk jr PB 42000
CK 481400 lvl 19-1
CK On CC 567100 KS

Twitch =
Member for 11 Years CK Killscreener Blogger Twitch Streamer

Offline marinomitch13

  • Spring Jumper
  • *
  • Posts: 1806
    • How to Play DK
    • Awards
"Thou hast made us for Thyself, and our heart is restless until it finds its rest in Thee." -Augustine, Confessions.
Member for 11 Years DK Killscreener Blogger Twitch Streamer

Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1763
  • I'm going to jump next to your leg.
    • Donkey Blog
    • Awards
Re: Donkey Kong Program Code
« Reply #11 on: July 08, 2013, 10:08:20 pm »
I added another .txt version to the post above which includes the line numbers, the HEX codes, and the ASCII equivalent. Looks nicer than the other .txt, though it isn't the "true" 16KB version.

We are analyzing difficult this program.
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 DKJR Killscreener DK Masters - Rank D Blogger Twitch Streamer DK Killscreener CK Killscreener

SQUIIDUX

  • Guest
Re: Donkey Kong Program Code
« Reply #12 on: July 09, 2013, 03:06:59 am »
im working this boys!

Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1763
  • I'm going to jump next to your leg.
    • Donkey Blog
    • Awards
Re: Donkey Kong Program Code
« Reply #13 on: July 09, 2013, 02:20:34 pm »
This is the mother of all "wht da?"s
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 DKJR Killscreener DK Masters - Rank D Blogger Twitch Streamer DK Killscreener CK Killscreener

Jeffw

  • Guest
Re: Donkey Kong Program Code
« Reply #14 on: July 11, 2013, 04:59:46 pm »
I've attached a commented disassembly of a Donkey Kong rom. Most of the comments in this file are from a commenter who wishes to remain anonymous, but some of the comments are my own.

There are improvements that can be made to this file. The list of RAM values at the top is incomplete, certain comments are not very detailed, and I know for a fact that there are some errors in these comments, because looking through it just now I realized that I did not correct all the errors I encountered when I originally was reading through this. I think I will probably go through this file and add more detailed comments and explanations (and fix the errors) for the parts that I have read through myself. If anyone else is considering making modifications to this file as well it might be worthwhile to use something like etherpad, which provides the ability to collaboratively edit text files in real-time.

The parts that I have looked at are:
- The barrel deployment routine, specifically the timing of barrel releases and the cause of "pauses" from DK and their length
- Wild barrel behaviour on all internal difficulties including the cause of bombs and those that start as bombs but transition to normal wild barrels part-way down
- The entire fireball movement algorithm including both freezers and normal fireballs
- Conveyor directions on pie factory and pie deployment