Donkey Kong Forum
General Donkey Kong Discussion => General Donkey Kong Discussion => Topic started by: JCHarrist on July 18, 2013, 09:25:16 pm
-
I know I'm not the only attract mode geek here so I decided to brush up on my assembly skills by breaking down the attract mode code. I've always been kinda fascinated by the seemingly endless number of possible outcomes.
It turns out that it is incredibly simple, with only 28 lines of code to handle Jumpmans movements. The movements are completely hardcoded with no randomness and no barrel/fireball/ladder detection. However, the barrels and fireballs behave exactly like they do in a game, so that is where the variability comes from.
It only becomes interesting if Jumpman is able to grab the hammer and actually smash something because when the screen freezes during the smashes, the script keeps running and the variable number and timing of the smashes is what makes the many different outcomes possible.
The input sequence table starts at 21D1 and only has 15 different moves. The first byte is the input. The second byte is the duration of the FOLLOWING input.
I've expanded on Jeff Willms commenting.
21D1 80 FE ; jump
21D3 01 C0 ; run right for 254 frames
21D5 04 50 ; climb ladder for 192 frames( it only takes 54 frames to climb the short ladder so he pauses at the top for 138 frames)
21D7 02 10 ; run left for 80 frames
21D9 82 60 ; jump left for 16 frames
21DB 02 10 ; run left for 96 frames
21DD 82 CA ; jump left for 16 frames
21DF 01 10 ; run right for 202 frames
21E1 81 FF ; jump right for 16 frames (grabs hammer)
21E3 02 38 ; run left for 255 frames
21E5 01 80 ; run right for 56 frames
21E7 02 FF ; run left for 128 frames
21E9 04 80 ; up for 255 frames
21EB 04 60 ; up 128 frames
21ED 80 ; jump for 96 frames
The code that calls the inputs follows directly after it. It's interesting to note that Jumpman occasionally makes it further than the 15 inputs in the table at which point the code starts using itself as input data. It will take some more experimentation to define those inputs although #16 and #17 seem to make Jumpman run right for at least 220 frames or so. :o
21EE 11D121 LD DE,#21D1 ; load DE with #21D1 (address of start of input table data)
21F1 21CC63 LD HL,#63CC ; load HL with #63CC (63CC holds the sequence # of the current input)
21F4 7E LD A,(HL) ; load A with input sequence #
21F5 07 RLCA ; multiply A X 2
21F6 83 ADD A,E ; add A to E (E = hex D1/ decimal 209)
21F7 5F LD E,A ; put A into E (this returns DE to the address of the current input )
21F8 1A LD A,(DE) ; load A from the address of the current input from table
21F9 321060 LD (#6010),A ; output A to Jumpman
21FC 2C INC L ; increment HL by 1 to 63DC (63DC holds the number of frames remaining to execute the input)
21FD 7E LD A,(HL) ; load the # of frames remaining to execute into A
21FE 35 DEC (HL) ; decrement the # of frames remaining by 1
21FF A7 AND A ; clear carry flag
2200 C0 RET NZ ; return if A is not zero
2201 1C INC E ; if A is zero increment E by 1 (advances to next input duration)
2202 1A LD A,(DE) ; load A with input duration
2203 77 LD (HL),A ; store input duration into HL (address 63DC)
2204 2D DEC L ; decrement HL to address 63CC
2205 34 INC (HL) ; increment the input sequence #
2206 C9 RET ; return
Earlier we were discussing this is in the shoutbox and Chris P was doing some experimentation using invinciblity cheat and it seems that in order for Jumpman to make it to the third girder he has to smash exactly 3 objects AND be standing at the base of a ladder when the hammer expires.
Discuss, fellow attract mode geeks! ;D
-
21E9 04 80 ; up for 255 frames
21EB 04 60 ; up 128 frames
21ED 80 ; jump for 96 frames
So, based on this (the fact that there are no potential movements to the right after climbing to the third girder), it is impossible for Jumpman to get to the 4th girder... correct?
-
21E9 04 80 ; up for 255 frames
21EB 04 60 ; up 128 frames
21ED 80 ; jump for 96 frames
So, based on this (the fact that there are no potential movements to the right after climbing to the third girder), it is impossible for Jumpman to get to the 4th girder... correct?
Well, as I stated, after the #15th input, the code "overflows" out of the table data and starts reading inputs from the program code itself. It seems that #16 and #17 make him run to the right for around 220 frames, but that's as far as I've ever seen him survive.
-
I used the invinsibility cheat along with the always climb cheat. I shut off the always climb while jumpman is half way up Pauline's ladder. He will climb to the top on his own, get to the top and stop. The rom literally stalls, it will not let you play the game. :)
-
I just realized that this is the only way to actually end the game next to Pauline
-
I used the invinsibility cheat along with the always climb cheat. I shut off the always climb while jumpman is half way up Pauline's ladder. He will climb to the top on his own, get to the top and stop. The rom literally stalls, it will not let you play the game. :)
A reliable source told me you were on 1.3M pace. Great job!
-
Using the "Always Climb" was a great idea, Corey.
Fascinating that the game stalls. Imagine if it kept going. Somebody could painstakingly put together a kill screen...
We finally got demo-Jumpman through the attract mode! Love it!
-
I used the invinsibility cheat along with the always climb cheat. I shut off the always climb while jumpman is half way up Pauline's ladder. He will climb to the top on his own, get to the top and stop. The rom literally stalls, it will not let you play the game. :)
How do we end up with 9800 on the Bonus Timer?
-
Yea 9800 bonus timer, wht da? Is that part of the invincibility cheat, it gives you extra time?
Pretty cool though.
-
The bonus timer was an additional cheat, infinite bonus timer.
-
21E9 04 80 ; up for 255 frames
21EB 04 60 ; up 128 frames
21ED 80 ; jump for 96 frames
So, based on this (the fact that there are no potential movements to the right after climbing to the third girder), it is impossible for Jumpman to get to the 4th girder... correct?
Well, as I stated, after the #15th input, the code "overflows" out of the table data and starts reading inputs from the program code itself. It seems that #16 and #17 make him run to the right for around 220 frames, but that's as far as I've ever seen him survive.
That is very interesting, at least now I can see there is no programmed input beyond climbing to the 3rd girder, the run to right is strictly an overflow error like you said, but that almost always gets to that point. Maybe the programmer was jsut OK with that happening. But, when he does climb to the 3rd girder, if he ever managers to jump over the barrels, and there is a clear path....he'll run to the right but not fall off, or who knows what the next thing will do after the 220 frames to the right you said.
Would be neat to run the invisibility cheat without "always climb" and wait for him to climb to the 3rd girder and see what happens after the run to the right? You'd have to wait for about 15-20 screens through but should be able to do the fast forward.
BTW, not sure how always climb worked on the attact screen, does he always run in the right direction after climbing?
-
Dave, I believe that Chris said he runs off the right edge of the 3rd girder; apparently most of the "invincible" attract screens end with jump man on the bottom girder, due to survival after falling off the edges...
Perhaps the always climb cheat skips the bottom hammer? Between the 13 other coded inputs and the overflow, it must've been enough
-
Would be neat to run the invisibility cheat without "always climb" and wait for him to climb to the 3rd girder and see what happens after the run to the right?
How would we know that he's climbed to the 3rd girder, if we can't see him?
Just kidding, Dave. I know what you meant. :)
-
Dave, I believe that Chris said he runs off the right edge of the 3rd girder; apparently most of the "invincible" attract screens end with jump man on the bottom girder, due to survival after falling off the edges...
Perhaps the always climb cheat skips the bottom hammer? Between the 13 other coded inputs and the overflow, it must've been enough
You can't run off the edge of the 3 girder to the right.
-
Now that I know what the numbers do, and since the barrels always do the same thing the first time through in MAME, it should be a simple matter to program Jumpman to make it to the top. 8)
-
Now that I know what the numbers do, and since the barrels always do the same thing the first time through in MAME, it should be a simple matter to program Jumpman to make it to the top. 8)
Do you mean a trial and error approach using hard coded values, as opposed to AI?
-
Dave, I believe that Chris said he runs off the right edge of the 3rd girder; apparently most of the "invincible" attract screens end with jump man on the bottom girder, due to survival after falling off the edges...
Perhaps the always climb cheat skips the bottom hammer? Between the 13 other coded inputs and the overflow, it must've been enough
You can't run off the edge of the 3 girder to the right.
Well that is true, I havent actually seen the invincible attract or tested it for that matter; perhaps he meant/said the left edge of the 3rd girder? I was just relaying the results that chris_P gave in the shoutbox. It was in response to my suggestion that we try to run an attract mode with invincibility to determine the hardcoded path.
-
Now that I know what the numbers do, and since the barrels always do the same thing the first time through in MAME, it should be a simple matter to program Jumpman to make it to the top. 8)
Do you mean a trial and error approach using hard coded values, as opposed to AI?
Yes, just a hardcoded script that will work the first time through the attract mode. The problem is getting him there in only 15 moves. Oh, and barrels do steer in attract mode.
-
Yes, just a hardcoded script that will work the first time through the attract mode. The problem is getting him there in only 15 moves. Oh, and barrels do steer in attract mode.
Yeah, that's what I mean. Using values that are hard coded, you can control Mario to precisely perform the same actions every time, thereby triggering identical barrel behavior (on that first attract mode run). An actual player would be highly unlikely to reproduce those same movements exactly; off by a frame or 2 here and there, and the remainder of the stage plays out differently.
-
Yes, just a hardcoded script that will work the first time through the attract mode. The problem is getting him there in only 15 moves. Oh, and barrels do steer in attract mode.
Yeah, that's what I mean. Using values that are hard coded, you can control Mario to precisely perform the same actions every time, thereby triggering identical barrel behavior (on that first attract mode run). An actual player would be highly unlikely to reproduce those same movements exactly; off by a frame or 2 here and there, and the remainder of the stage plays out differently.
Ok, now I'm confused.
Who said anything about a player trying to duplicate the movements?
-
Ok, now I'm confused.
Who said anything about a player trying to duplicate the movements?
I'm just comparing the hard coded values (in attract mode) to an actual player's inputs (using a save state, for example).
A human player could load a save state 100 times, attempting to play the board identically each time. The odds of performing the same exact actions, frame by frame, for any 2 trials, are close to zero. The resulting gameplay would vary greatly.
By contrast, the attract mode (initial run) should produce identical results, since the input values are precise.
-
Scott, ;)
What about the steering % for the barrels, I'd still think the odds will be no better than 1/10 (it will play a few variants until everything steers "properly"). I don't think the barrels would follow the "same" path every time, unless of course, mame's number generators always start at the same values? Every time i turn on the cab, it boots with a different attract screen, prior to any user inputs.
-
Scott, ;)
What about the steering % for the barrels, I'd still think the odds will be no better than 1/10 (it will play a few variants until everything steers "properly"). I don't think the barrels would follow the "same" path every time, unless of course, mame's number generators always start at the same values? Every time i turn on the cab, it boots with a different attract screen, prior to any user inputs.
In MAME, after a hard reboot , the barrels do the same thing every time in attract mode. Jumpman does influence them just like in a game, but they will steer the same way every time , at least in the first attract mode run.
Arcade cabinets are different in this respect. The random number generator must get seeded differently because the attract modes are not predictable.
-
Scott, ;)
What about the steering % for the barrels, I'd still think the odds will be no better than 1/10 (it will play a few variants until everything steers "properly"). I don't think the barrels would follow the "same" path every time, unless of course, mame's number generators always start at the same values? Every time i turn on the cab, it boots with a different attract screen, prior to any user inputs.
Yeah, the other parameters that determine barrel decisions (RNG values, etc.) would have to be the same. I don't know if those memory locations are initialized when attract mode is first run, or if they contain leftover values (or random garbage).
-
In MAME, after a hard reboot , the barrels do the same thing every time in attract mode. Jumpman does influence them just like in a game, but they will steer the same way every time , at least in the first attract mode run.
Arcade cabinets are different in this respect. The random number generator must get seeded differently because the attract modes are not predictable.
Ok, I seem to recall a similar discussion on DKF a few months ago.
-
Oh, and barrels do steer in attract mode.
Yes! Finally! An answer! I'd been curious about that for so long!
-
Here's as far as I can get him with 15 moves. He runs into the overflow after that last jump. :(
DK attract mode reprogrammed (http://www.youtube.com/watch?v=ohtHJEW3Duw#ws)
-
Ok, I seem to recall a similar discussion on DKF a few months ago.
I managed to locate the thread I alluded to earlier.
The relevant discussion begins here:
Elevator Stage, how do you get from safe spot to safe spot? (https://donkeykongforum.net/index.php?topic=120.msg2014#msg2014)
-
Here's as far as I can get him with 15 moves. He runs into the overflow after that last jump. :(
Just curious, did you experiment with different combinations of values for the "run left", "run right", and "climb up" moves? I'm wondering if an adjustment to the number of frames (increase/decrease by 1 or 2) might reduce the number of necessary barrel jumps (sort of like the Level 1-1 4000 Challenge).
-
Here's as far as I can get him with 15 moves. He runs into the overflow after that last jump. :(
Just curious, did you experiment with different combinations of values for the "run left", "run right", and "climb up" moves? I'm wondering if an adjustment to the number of frames (increase/decrease by 1 or 2) might reduce the number of necessary barrel jumps (sort of like the Level 1-1 4000 Challenge).
Yeah, I'm still playing around with it. I think I see a way to save one more move. That should get him up the ladder to the 6th girder. :D
-
Yeah, I'm still playing around with it. I think I see a way to save one more move. That should get him up the ladder to the 6th girder. :D
Nice! Of course, I could just tackle this myself, sparing you the annoyance of a backseat driver. ;)
-
Fkn hell. So close! I need one more jump and one more climb!
DK attract mode reprogrammed 2 (http://www.youtube.com/watch?v=P5SmxYxkEw8#ws)
-
Nice video, Jeff! Very cool stuff indeed.
-
Perhaps try using some vertical jumps (80) which seems to require only one byte instead of two, so you can use more than 15 moves.
Of course, I assume that getting to the top Will hang the program like what happened to Corey. I think the main loop of the software needs to detect a death to be able to exit out of this mode of assuming that subsequent program instructions are user inputs. So, the program will run to the end of file trying to give inputs to Jumpman and when the end of file is reached the main program loop is caught in an infinite loop, resulting in a software hang.
Still a fun exercise though...
-
Really? I post the code and the first thing you guys look at is attract mode? ::)
I think the real challenge is to see how high you can make Mario climb without any kind of ROM modification. You can use the coin-insert button to manipulate the random number generator and produce any kind of randomness you want. Depending on how Mario behaves after overflowing out of the input table, there is a small chance that it's possible to finish the first screen given the right randomness, so someone might be able to make a TAS that consists only of coin-insert button presses in which Mario finishes the first screen in attract mode. Any takers?
Edit: Ah, never mind. It seems doing a coin-insert causes it to leave attract mode. It still could be possible to finish the first screen given the right randomness but I don't think there's a good way of manipulating the RNG.
-
Fkn hell. So close! I need one more jump and one more climb!
I assume you're modifying the ROM bytes that it normally reads to have some other values, so you're limited by space?
Instead, you can probably find an unused part of the ROM with more space available, put your new values there, and then modify the code to point there instead of the original place.
Todd
-
Nice! Of course, I could just tackle this myself, sparing you the annoyance of a backseat driver. ;)
Ok, give it a shot.
This is what I have:
21D1 01 CE ; run right(no duration)
21D3 01 39 ; run right for 206 frames
21D5 04 82 ; climb ladder for 57 frames
21D7 02 55 ; run left for 130 frames
21D9 04 10 ; climb ladder for 85 frames
21DB 81 C0 ; jump right for 16 frames
21DD 04 10 ; climb ladder for 192 frames(big pause at the top)
21DF 82 38 ; jump left for 16 frames
21E1 02 4F ; run left for 56 frames
21E3 04 30 ; climb ladder for 79 frames
21E5 81 74 ; jump right for 48 frames (2 jumps over 2 barrels)
21E7 01 10 ; run right for 116 frames
21E9 81 60 ; jump right for 16 frames
21EB 04 80 ; climb ladder for 96 frames
21ED 02 ; run left for 128 frames
I think it's gonna be very tough to get him all the way to the top with the number of moves available, but it is a neat challenge.
-
Perhaps try using some vertical jumps (80) which seems to require only one byte instead of two, so you can use more than 15 moves.
Dean, the long jumps and the straight jumps both only take one byte. The 2nd byte is the duration of the next input.
-
Really? I post the code and the first thing you guys look at is attract mode? ::)
Haha! At least I'm doing SOMETHING with it. ;)
-
Fkn hell. So close! I need one more jump and one more climb!
I assume you're modifying the ROM bytes that it normally reads to have some other values, so you're limited by space?
Instead, you can probably find an unused part of the ROM with more space available, put your new values there, and then modify the code to point there instead of the original place.
Todd
Yeah, that will be plan B I guess, but let's see if anyone can fit it in the available space first. :D
Welcome to the forum! :)
-
Hmm, using your example, are you sure you can't say
21DB 80 ;
21DC . . . (Not 21DD)
I'm not really sure if that works, just throwing it out there.
-
Really? I post the code and the first thing you guys look at is attract mode? ::)
Yeah, isn't it great?
JC, Mitch and I were discussing our next assignment. We plan to replace a few sprites, so that players will have more options when entering their initials.
Vincent specifically requested an "E", with an accent grave:
XÈR
It's an exciting project! ;)
-
Hmm, using your example, are you sure you can't say
21DB 80 ;
21DC . . . (Not 21DD)
I'm not really sure if that works, just throwing it out there.
Not sure if I'm following you, but the 81 at 21DB is the right jump on the 3rd girder that clears a barrel AND puts jumpman right under the next ladder, so it's actually saving a move. The CO (decimal 192) at 21DC is the duration of the ladder climb at 21DD (04).
The way the code is written, the 2nd byte has to be used as a duration. It couldn't be used as another input.
-
Another way to have fun with this is to make the attract mode playable.
You can do this using the MAME debugger console by adding the following lines:
bp 80,1,{pc=87 ; g}
bp 1977,1,{pc=197a ; g}
You can also enable sound in attract mode with this line:
bp e9,1,{pc=eb ; g}
I will see if I can find another hack to make it so the game doesn't freak out when jumpman makes it to the top in attract mode.
edit: found it. The following hack fixes attract mode if jumpman should finish the level:
bp 746,{b@600a==16},{b@600a=5; g}
More fun with attract mode. Set the screen played:
bp 770,1,{b@6227=2 ; g}
The above code sets the screen to 2 [conveyors] during attract mode. Change the 2 to 3 for elevators, or to 4 for rivets.
Don Hodges
-
This is too much fun.
If you thought demo-Jumpman was bad on barrels, check him out on rivets.
Though he's still not as bad as D2K demo-Jumpman.
-
Thank you, Don. Those are some great suggestions! I tried them all.
-
Another way to have fun with this is to make the attract mode playable.
You can do this using the MAME debugger console by adding the following lines:
bp 80,1,{pc=87 ; g}
bp 1977,1,{pc=197a ; g}
You can also enable sound in attract mode with this line:
bp e9,1,{pc=eb ; g}
I will see if I can find another hack to make it so the game doesn't freak out when jumpman makes it to the top in attract mode.
edit: found it. The following hack fixes attract mode if jumpman should finish the level:
bp 746,{b@600a==16},{b@600a=5; g}
More fun with attract mode. Set the screen played:
bp 770,1,{b@6227=2 ; g}
The above code sets the screen to 2 [conveyors] during attract mode. Change the 2 to 3 for elevators, or to 4 for rivets.
Don Hodges
Oh man, just when I thought I was going to get some playing time in today. ;D
Thanks Don!
-
DK Attract Mode, as you've never seen it before!
Not Your Typical DK Attract Mode (https://www.twitch.tv/stella_blue/v/50173433)
The highlight video features 2 somewhat unusual examples of attract mode.
The 1st part illustrates how not to play the Pie Factory. As the bonus timer reaches 1500 (and then again at 1100), I can't even begin to guess what Mario is doing. At least he has the good sense to leech the fireball for 100 points before dying.
Ever wonder what happens if you switch screen types during attract mode? The 2nd part is an interesting hybrid of the Conveyor and Rivet stages. Again, Mario doesn't survive, but he does collect the hat and purse (a 600 point "good death").
EDIT: The video highlight, originally hosted at Justin TV, is currently 1 minute 20 seconds of a blank screen.
-
that rivet treadmill :D Blue pies FTW
-
OMG, there has GOT to be a Rivet Hack made like that for people to play!
-
DK Attract Mode, as you've never seen it before!
Not Your Typical DK Attract Mode (http://www.justin.tv/stella_blue/c/2605139)
The highlight video features 2 somewhat unusual examples of attract mode.
The 1st part illustrates how not to play the Pie Factory. As the bonus timer reaches 1500 (and then again at 1100), I can't even begin to guess what Mario is doing. At least he has the good sense to leech the fireball for 100 points before dying.
Ever wonder what happens if you switch screen types during attract mode? The 2nd part is an interesting hybrid of the Conveyor and Rivet stages. Again, Mario doesn't survive, but he does collect the hat and purse (a 600 point "good death").
That's cool. We can see what happens in the overflow much more clearly without the barrels spoiling the fun. He hits the overflow at 45 seconds in the video on the pie factory.
Also interesting that he did climb the ladder toward the end of the rivet/pie factory hybrid board. :D
-
So I gave up on trying to get him to the top on the first attract mode cycle. I decided to just put in a script that would potentially get him to the top and sit back and watch.
On the 27th cycle.... success!
DK attract mode reprogram success! (http://www.youtube.com/watch?v=j3JWqZvY71c#ws)
And it does indeed crash the game.
-
That's cool. We can see what happens in the overflow much more clearly without the barrels spoiling the fun. He hits the overflow at 45 seconds in the video on the pie factory.
There was another Pie Factory example where the fireballs left him alone, and he eventually died after the bonus timer reached 000.
The elevator stage isn't very interesting, as Mario runs past the edge of the starting platform, and dies immediately. If you make it playable instead, you'll notice that everything moves very slowly (it is Level 00, after all).
-
So I gave up on trying to get him to the top on the first attract mode cycle. I decided to just put in a script that would potentially get him to the top and sit back and watch.
On the 27th cycle.... success!
[noembed]DK attract mode reprogram success! (http://www.youtube.com/watch?v=j3JWqZvY71c#ws)[/noembed]
And it does indeed crash the game.
Outstanding! I especially enjoyed the quintuple jump on the 5th girder. 8)
-
Just a thought about the riv-pie... spoiler alert!---------------->TOTALLY OFF TOPIC
Would DK be harder easier/the same if; we removed the rivets and pies and replaced it with 1 riv-pie screen? It would essentially subtract a minimum of 19 screens from the 117, but I think that the increased difficulty of this screen might actually offset the loss of boards. Basically, i think that getting to level 22 on a game that only had 98 screens but included the riv-pie would be just as hard, if not harder, than getting to level 22 in standard DK.
What do you guys think?
-
The elevator stage isn't very interesting, as Mario runs past the edge of the starting platform, and dies immediately. If you make it playable instead, you'll notice that everything moves very slowly (it is Level 00, after all).
It seems like it would be straightforward to create an attract mode that passes an elevator screen.
-
You could never guarantee the position of the between-elevator fireball, so that would cause problems, but maybe there's a way around that?
-
http://kotaku.com/this-guy-wrote-a-program-that-teaches-itself-to-play-ne-472451152 (http://kotaku.com/this-guy-wrote-a-program-that-teaches-itself-to-play-ne-472451152)
found this made me think of you guys
-
Insane, Jeff! That's awesome to know what happens when Jumpman finishes the first screen on the attract mode. Tears to my eyes mate!
-
I just realized that this is the only way to actually end the game next to Pauline
I can't help thinking that the symbolism here has strong alchemical overtones.
The great work is complete.
-
I just realized that this is the only way to actually end the game next to Pauline
I can't help thinking that the symbolism here has strong alchemical overtones.
The great work is complete.
Perhaps the tale of the Monkey King :D
-
i finally got my first jumpman climbing up to the third girder in attract mode recorded. Lol.