Ever since I started playing DK I've been fascinated with the elevator stage. Of all the boards, it truly is the only one on which no player should ever die. However I still find myself dying, as do even the best players. I decided to take a closer look at the stage when the code for the game was posted on the forums. What follows in this post, and probably the several after it, is a technical, code-level analysis of the springs. Since I'm not a programmer, engineer, or math expert I apologize up front for any mistakes or inconsistencies in the terminology and presentation. I encourage everyone to dig in, double-check my work, and break it down even further.
Let me also state that I don't think any of the following information will be groundbreaking or crucial for most players, especially beginners. This is just an extraction of information that lies in the code and is intended for those of us who enjoy looking under the hood.? I won't be delving too deep into actual spring strategy, but hopefully this post will get the wheels churning and someone will see something useful.
I used a variety of methods to gather this information. Starting with the DK code posted by Jeff Willms, I used WolfMAME 106, 140, and 149 and a variety of save-states to analyze the spring behavior in Donkey Kong US Set 1 and D2K: Jumpman Returns.
This post is concerned with the actual springs themselves. Hopefully further analysis on fireball movement, leeching opportunities, elevator movement, etc. will come later.
Spring BasicsRate of GenerationFirst and foremost, how often are the springs generated? Each new spring corresponds with the Bonus Timer ticks and one spring is generated for every 100 that the timer decrements.
Spring Generation:
Level 1 (Japan Set, D2K) = Every 120 frames, or 2 seconds. 3 extra at 000 Bonus. 52 total.
Level 2 = Every 100 frames or 1.667 seconds. 3 extra at 000 Bonus. 62 total.
Level 3 = Every 80 frames or 1.333 seconds.4 extra at 000 Bonus. 73 total.
Level 4+ = Every 60 frames or 1 second. 5 extra at 000 Bonus. 84 total.
Each spring has a life of 180 frames. The beginning and end of this life cycle occurs off-screen. Depending on the length and scrunchiness of the spring, it can spend anywhere from 1 to 9 frames off-screen before it makes its appearance. All springs take 25 frames (inclusive of their off-screen movement) to make their initial on-screen landing near Kong's feet. They then bounce along for another 75 frames before entering their falling state, which lasts a further 56 frames before they disappear off the bottom of the screen. At this point they still exist in the code, but only for 24 frames before their memory location is used for the next spring. This timing occurs for every spring, regardless of level. The only difference between levels is how often the springs are generated.
Spring PathFrom here on out, please note that x-values INCREASE as Jumpman moves to the right, and y-values DECREASE as Jumpman moves up.
Every spring follows the same parabolic path. The 25 y-values for this path are as follows (in hex):
50 4D 4A 47 45 43 41 3F 3E 3D 3D 3C 3C 3C 3D 3D 3E 3F 41 43 45 47 4A 4D 50
This pattern repeats until the spring falls. You'll notice that at the beginning and end of the path the spring is at y=50. This causes the spring to slide along the girder for two frames every time it lands. This has the potential to make two different springs appear to be the same, depending on when the player processes the landing animation. Springs move 2 pixels horizontally every frame during the bounce phase, and their vertical distance varies depending on where they are in their path. During the falling phase, springs drop at a rate of 3 pixels per frame.
A simple graph of this movement looks like this:
Spring LengthNow, the spring quality that most people are interested in: length. I will use the numbering system that Dean Saglio used in his pop quiz: 0 for the shortest spring and 15 for the longest.
Springs can be generated in one of 16 locations. They always start, off-screen, at y=50, but their x-value can be any of 16 points, each separated by 1 pixel. Technically, spring Types 0 through 7 are actually generated on the right side of the screen. The shortest spring, Type 0, initially bounces to the left of the elevator pulley and has an x-value (hex) of 28 when it lands. The longest spring, Type 15, has a value of 37. So, the initial landing spot (near Kong's left foot) of all 16 springs shakes out like this:
Type 0: 28
Type 1: 29
Type 2: 2A
Type 3: 2B
Type 4: 2C
Type 5: 2D
Type 6: 2E
Type 7: 2F
Type 8: 30
Type 9: 31
Type 10: 32
Type 11: 33
Type 12: 34
Type 13: 35
Type 14: 36
Type 15: 37
Here is an animated GIF that demonstrates the initial landing spots for all 16 springs.
Getting Up Pauline's LadderOnce you've traversed the lower obstacles and made it up to Kong's girder, all that remains is to navigate the springs and rescue Pauline. There are various strategies for doing this, but they all boil down to one fact: you must get close enough to the ladder on one spring so you have time to ascend the ladder before the next spring hits you. The amount of wiggle room you have varies depending on the level and the type of springs that are bouncing your way.
The following information is mostly about what is theoretically possible in a pixel-perfect, frame-by-frame world.
Safe Spots and Pauline's LadderThe two safe spots are each 13 pixels wide. These safe spots are areas where no spring will ever hit you. The edges of these safe spots are determined by the shortest and longest springs. The longest spring (15) determines the LEFT edge of the safe spots, and the shortest spring (0) determines the RIGHT edge.
The 1st safe spot extends from x=A7 to x=B4. For reference, Jumpman's position when he ascends the ladder to Kong's girder is x=B3. The edge of Kong's girder is x=BB. So, there are actually 7 pixels of danger to the right of Jumpman as he stands in the 1st safe spot...but why would you be going in that direction anyway?
The 2nd safe spot extends from x=75 to x=82. The center of Pauline's ladder is at x=93, but since the ladder is 8 pixels wide (x=90 to x=97), it is actually offset to the left.
As stated above, these two areas are permanent safe zones. However, the edges of these zones can shift as different springs enter the screen. Below is a table of how the x-value for each safe spot’s inner edge shifts for every spring.
Type 1st Safe Spot 2nd Safe Spot
Type 0 98 82
Type 1 99 83
Type 2 9A 84
Type 3 9B 85
Type 4 9C 86
Type 5 9D 87
Type 6 9E 88
Type 7 9F 89
Type 8 A0 8A
Type 9 A1 8B
Type 10 A2 8C
Type 11 A3 8D
Type 12 A4 8E
Type 13 A5 8F
Type 14 A6 90
Type 15 A7 91It's easy to see that running right up to the ladder is possible on the longest and shortest springs, depending on which safe spot you're in. As each spring shifts the safe spot, Jumpman can get a "jump" on the ladder, of varying lengths, which increase the odds of making the final run up to Pauline.
Here are some related graphics:
This graphic needs a little refining. The spring paths are basically showing the path followed by the bottom center of each spring.
There are also safe spots ON Pauline's ladder.
As most players know, certain springs reach higher than others and can collide with Jumpman even when he's almost to the top. When Jumpman is standing at the bottom of the ladder, his sprite is centered at y=50. He moves up the ladder in 2 pixel increments and when he reaches y=30 he has reached the top. However, Jumpman only needs to reach y=38 to be safe from all springs.
I advise everyone to check out Ethan Daniels' hitbox diagram in order to get an idea of how much space is needed to avoid the springs:
https://donkeykongforum.net/index.php?topic=493.msg8905Below is a table showing each spring type, the extreme x,y coordinates for Jumpman and each spring when they collide on the ladder (essentially the boundary Jumpman must cross to survive), and the y-value Jumpman must reach in order to be safe for each given spring.
Ladder Collision: Spring Landing "x" - [Spring "x,y"/Jumpman "x,y"] - Jumpman Safe "y" - Collision Direction - 1st Safe Spot - 2nd Safe Spot
Type 0 28 98,43 93,3C 3A up 98 82
Type 1 29 97,45 93,3E 3C up 99 83
Type 2 2A 98,45 93,3E 3C up 9A 84
Type 3 2B 97,47 93,40 3E up 9B 85
Type 4 2C 98,47 93,40 3E up 9C 86
Type 5 2D 97,4A 93,44 42 up 9D 87
Type 6 2E 8E,4A 93,44 42 down 9E 88
Type 7 2F 8F,4A 93,44 42 down 9F 89
Type 8 30 8E,47 93,40 3E down A0 8A
Type 9 31 8F,47 93,40 3E down A1 8B
Type 10 32 8E,45 93,3E 3C down A2 8C
Type 11 33 8F,45 93,3E 3C down A3 8D
Type 12 34 8E,43 93,3C 3A down A4 8E
Type 13 35 8F,43 93,3C 3A down A5 8F
Type 14 36 8E,41 93,3A 38 down A6 90
Type 15 37 8F,41 93,3A 38 down A7 91Jumpman's MovementAn important, albeit code-level, factor in approaching the spring stage is that when Jumpman is puttering around the board, his sprite has an internal value that is constantly changing and he actually pauses every third frame. There's more on this here:
https://donkeykongforum.net/index.php?topic=383.msg6904;topicseen#msg6904Essentially, memory address 620F is a movement indicator (this is the comment for this location in the code posted on DKF) and counts down 2-1-0, one value per frame (1/60 second), repeatedly, while running. Value 2 is when the sprite changes and Jumpman pauses, values 1 and 0 occur when Jumpman is actually moving. When climbing a ladder the same memory address counts down 4-3-2-1-0. For values 3-2-1-0 Jumpman is stationary on the ladder, and when the value reaches 4 again he moves up the ladder 2 pixels.
Why is this important? When standing and waiting to make a move on the springs, the value stored in 620F determines how soon Jumpman will move after you make a joystick or keyboard input. If the value is 2 or 1, he will move right away. If the value is 0, there will be a dead frame where the value changes to 2 and the sprite is updated before any movement occurs. More importantly, this effects the point at which Jumpman can climb the final ladder. Jumpman can NOT climb a ladder until 620F reaches 0. So, if he reaches the left edge of ladder, but 620F is at 1, it will take one extra frame to start climbing the ladder regardless of the timing of the up input. This can have huge ramifications if one does not corner up the ladder as described by Dean here:
https://donkeykongforum.net/index.php?topic=429.msg7645#msg7645What Does It All Mean? (aka TOO MANY WORDS JUST POST PICTURES JFC)To determine which spring combinations are passable, I asked myself the following questions:
1) What are the minimum frame requirements to get from each safe spot on the girder to each safe spot on Pauline's ladder?
2) How long must I wait after each spring passes over Jumpman's head, in both the 1st and 2nd safe spots, before I can make my approach to the ladder?
3) How long has the trailing spring been heading my way while I wait for my opportunity to ascend the ladder?
Let me reiterate that this is all about what is technically possible, not necessarily practical.
Due to the sprite values discussed earlier, there are 3 possible answers for every location in Question 1. For example, running from 2nd safe spot x=82 to ladder safe spot y=38 can take 76, 77, or 78 frames.
For Question 2, you must wait for the spring to pass over your head by 2 frames/4 pixels in the 2nd safe spot before you can run. So, if you're standing at x=82, you must wait for the spring to be at x=88 before you can run. In the 1st safe spot, you must wait at least 3 frames after the spring bounces in front of you before you can run. This is all assuming you've given yourself the maximum jump allowed by each spring type.
The exception to these numbers are the two longest springs, 14 and 15. Since you can wait at the left edge of the ladder for these springs to pass, you can press up as they pass you. However, cornering a ladder this way automatically warps you to the middle of the ladder. In the case of a Type 14, this is x=90 to x=93. For a Type 15, it's x=91 to x=93 (but you might as well just wait at x=90...it doesn't make a difference for a Type 15). This warp necessitates waiting an extra frame before climbing the ladder. Therefore, Types 13, 14, and 15 all have the same wiggle room when sneaking between springs from the 2nd safe spot. This extra frame of waiting also explains the D2K killscreen. A pixel-and-frame perfect run up the ladder requires 1 extra frame of waiting, and is 1 frame short of reaching safe spot on Pauline's ladder. One f***ing frame!!!
For Question 3, the trailing Level 4 spring has been headed your way 13 frames by the time you can make your move from the 2nd safe spot, and 14 frames by the time you can make your move from the 1st safe spot. On Level 3, the trailing spring has yet to be generated, still needing 7 frames or 6 frames depending on safe spot. Level 2 springs need 27 or 26, and Level 1 D2K springs need 47 or 46 frames to be generated.
For example, on Level 4 I'm waiting in 2nd the safe spot and I see a Type 12 spring. I move into the most ideal position (x=8E), and as it passes me I run for the ladder and see that a Type 4 spring has landed and is on its way. In this case, I only need 43 frames get to the safe spot on Pauline's ladder (for Type 4, y=3E). It takes a Type 4 spring 79 frames to reach Jumpman on the ladder, but since it's already been heading my way for 13 frames before I can run, it only needs 66 more frames to reach the ladder. 66 frames minus the 43 I need to reach the safe spot = 23 frames of wiggle room.
Instead of pasting my enormous collection of thousands of data points, I will try to summarize my findings below in the graphics below.
First, find the Type of spring that is the leading spring in the vertical column on the left. Then, move horizontally to find the Type of spring that is the trailing spring. Where the two rows intersect is the wiggle room, in frames, that you have to complete the run up the ladder. Cells that are colored orange are spring combinations that may or may not be possible depending on Jumpman's sprite value at 620F when you make a run for it. Referring to the example above, use the L4 chart and find "12" row in the left hand column of the "2nd safe spot" chart. Then follow it over to "4" column, and you'll see that 23 frames is the amount of wiggle room to pass a [12,4] combo.
I will end this post with these graphics because 1) my brain is full, and 2) I want to give people a chance to digest all of this and suggest corrections, additions, etc.
Other things to address:
1) Does scrunchiness matter? (no)
2) How many possible combos can you pass in order to get from the 1st safe spot to the 2nd?
3) Could jumping springs be realistically incorporated into the game?
Level 1 (Japan Set, D2K) CombosLevel 2 CombosLevel 3 CombosLevel 4 Combostl;dr. wait for a long, then go on a short.Edit: Fixed some not good grammar. Clarified a couple of paragraphs. Changed the link to Ethan's hitbox diagram.