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

0 Members and 1 Guest are viewing this topic.

Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1671
  • I'm going to jump next to your leg.
    • Donkey Blog
Donkey Kong Program Code
« on: July 08, 2013, 06: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?
Twitch TV  Streamer DK Killscreener Crazy Kong Killscreener DKF Blogger DK Jr. Killscreener

Offline SQUIIDUX

  • Full Member
  • *
  • Posts: 92
Re: Donkey Kong Program Code
« Reply #1 on: July 08, 2013, 06:49:05 PM »
let's see what we can get going here
Twitch TV  Streamer

Offline marinomitch13

  • Moderator
  • Spring Jumper
  • *
  • Posts: 1789
    • How to Play DK
Re: Donkey Kong Program Code
« Reply #2 on: July 08, 2013, 07: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.
Twitch TV  Streamer DKF Blogger DK Killscreener

Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1671
  • I'm going to jump next to your leg.
    • Donkey Blog
Re: Donkey Kong Program Code
« Reply #3 on: July 08, 2013, 07: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?
Twitch TV  Streamer DK Killscreener Crazy Kong Killscreener DKF Blogger DK Jr. Killscreener

Offline JCHarrist

  • Administrator
  • Spring Jumper
  • *
  • Posts: 532
    • Donkey Kong Forum
Re: Donkey Kong Program Code
« Reply #4 on: July 08, 2013, 07:21:56 PM »
Someone should call that number. ;D
Twitch TV  Streamer DK Killscreener Crazy Kong Killscreener

Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1671
  • I'm going to jump next to your leg.
    • Donkey Blog
Re: Donkey Kong Program Code
« Reply #5 on: July 08, 2013, 07: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, 08: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?
Twitch TV  Streamer DK Killscreener Crazy Kong Killscreener DKF Blogger DK Jr. Killscreener

Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1671
  • I'm going to jump next to your leg.
    • Donkey Blog
Re: Donkey Kong Program Code
« Reply #6 on: July 08, 2013, 07: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?
Twitch TV  Streamer DK Killscreener Crazy Kong Killscreener DKF Blogger DK Jr. Killscreener

Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1671
  • I'm going to jump next to your leg.
    • Donkey Blog
Re: Donkey Kong Program Code
« Reply #7 on: July 08, 2013, 07: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?
Twitch TV  Streamer DK Killscreener Crazy Kong Killscreener DKF Blogger DK Jr. Killscreener

corey.chambers

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

Offline Monstabonza

  • Senior Member
  • *
  • Posts: 241
Re: Donkey Kong Program Code
« Reply #9 on: July 08, 2013, 08: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 =
Twitch TV  Streamer DKF Blogger Crazy Kong Killscreener

Offline marinomitch13

  • Moderator
  • Spring Jumper
  • *
  • Posts: 1789
    • How to Play DK
“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 ChrisP

  • Spring Jumper
  • *
  • Posts: 1671
  • I'm going to jump next to your leg.
    • Donkey Blog
Re: Donkey Kong Program Code
« Reply #11 on: July 08, 2013, 09: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?
Twitch TV  Streamer DK Killscreener Crazy Kong Killscreener DKF Blogger DK Jr. Killscreener

Offline SQUIIDUX

  • Full Member
  • *
  • Posts: 92
Re: Donkey Kong Program Code
« Reply #12 on: July 09, 2013, 02:06:59 AM »
im working this boys!
Twitch TV  Streamer

Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1671
  • I'm going to jump next to your leg.
    • Donkey Blog
Re: Donkey Kong Program Code
« Reply #13 on: July 09, 2013, 01: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?
Twitch TV  Streamer DK Killscreener Crazy Kong Killscreener DKF Blogger DK Jr. Killscreener

Offline Jeffw

  • Full Member
  • *
  • Posts: 72
Re: Donkey Kong Program Code
« Reply #14 on: July 11, 2013, 03: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

Twitch TV  Streamer DK Killscreener Kong-Off 2 Champion DK 1 Million Point Scorer DK 1.1 Million Point Scorer Kong-Off 3 Champion