| Collectibles | - In the first US release, each of the four kinds of animal token has its own count. A token adds 1 to its kind's count, and a count of 4 becomes 1, so the fourth token of a kind counts as the first of a new set. The new count, 1 to 3, picks one of three consecutive sounds, and at 3 the game sets two values whose effect isn't read here. Code
- In the first US release, a Rambi or Enguarde token count carries into the next game unless the console is reset (computed). Starting or loading a game sets the first two of the four animal token counts to 0 and leaves the other two as they were: by the disassembly's names, Winky's and Expresso's counts are cleared, and Rambi's and Enguarde's are not. The reset fills work RAM with zero bytes by DMA through its data port, starting at address 0. The only other writes to the four counts are the token routine's own (dkc/animal-tokens) and a copy of 280 bytes of player state that starts two bytes below the counts (280 converted from hex): at a game's start the game copies the state to both players' stores, and in two-player mode, as far as the code shows (the mode isn't read), each change of player saves the state to one store and loads it from the other. Code
|
| Color math | - In the first US release, Torchlight Trouble dims the stage with color math outside its beam (dkc-av/torchlight-beam-window). The start code of its 6 entrances loads 128 background colors into color memory with every bit inverted, sets color 0, the backdrop, to a gray of 16 of 31 in each channel (converted from hex), writes 255 to both bytes of color 17 (white, converted from hex), and fills the third background layer's map with one tile word (in the value). It puts the third layer alone on the main screen with window 1, inverted, applied to it, and the first and second layers and the sprites on the subscreen, with no color window in use. Color math subtracts the subscreen from the third layer and from the backdrop, and the cave display routine writes the same layers and color math again every frame. Where the third layer shows color 17, 31 less an inverted channel gives the channel back (computed), so the stage shows its own background colors; where the backdrop shows, 16 less the inverted channel leaves the channel 15 lower (computed). While a countdown the game keeps is above 0, each frame takes 1 off it, writes to the backdrop the color the new count picks from four (in the value, for counts 0 to 3), and turns off the main screen's layers and color math, so that frame shows the backdrop alone. Code
- In the first US release, Poison Pond lays its third background layer over the rest of the stage at half strength. The second start step of its 2 entrances (by the disassembly's names, its start and its checkpoint) puts the third layer alone on the main screen and the first and second layers and the sprites on the subscreen, and sets color math to add the subscreen at half to the third layer and the backdrop. It turns on HDMA channels 2, 5 and 6; the underwater stages' channel setup points them at tables in RAM that set the second layer's horizontal scroll, the first layer's scroll and the third's down the screen. The other 7 underwater entrances (Croctopus Chase's, Coral Capers', Clam City's and Enguarde's bonus room's) take a second step that turns on channels 2 and 5 and sets the color math's layers and operation and the fixed color from a per-entrance table: adding on the second layer and the backdrop for Croctopus Chase, Coral Capers and Enguarde's bonus room, and subtracting at half on the second layer for Clam City. Code
|
| Echo | - In the first US release, every song gets the same echo buffer and delay: when it restarts, the driver sets the sound chip's echo delay to 4, which makes an 8,192-byte buffer (computed), and its buffer to start at
$DF00, and clears the 8,192 bytes from there (computed). It also sets echo volume, feedback, and every voice's echo bit to 0, and starts the song with echo writing off. A song turns echo on with its own commands: $15 gives the feedback and the echo volume and turns writing on, $16 and $17 set echo per voice, and $18 the filter. Code
|
| Extra life | - In the first US release, 100 bananas give a life (converted from hex). The banana counter on screen counts up one at a time toward the bananas collected; when it would pass 99, the game takes 100 from the bananas collected, sets the counter back to 0, and adds a life. The life waits instead when the sprite number the life routine keeps isn't positive: the number is made negative, and a later routine adds the life and sets it back to 0. In one mode, set by a flag the code tests, the counter runs to 999 and goes back to 0 with no life (both converted from hex). Code
- In the first US release, the routine that plays the sound the disassembly names "life balloon" adds to the lives a value read from a field of the touched sprite, and adds the same value to a field of the sprite the life routine keeps, whose role isn't read. Where the value is set isn't read. Code
- In the first US release, the routine the disassembly labels KONG letters adds a life when four letter flags are all set: once a test it runs first passes (unread), it adds the sprite's own flag to the four, and when all four are set it resets them, sets two other flags whose effect isn't read, and adds a life. Code
|
| HDMA | - In the first US release, Torchlight Trouble's beam is window 1 reshaped on every line by HDMA. The second start step of 45 entrances (counted), Torchlight Trouble's among them, points HDMA channel 2 at a table in RAM of 224 one-line entries (computed), each writing window 1's left and right edges, all set to 255 and 254, and turns that channel on. Only the 6 entrances whose flag word has bit 2 set (converted from hex), which by the disassembly's names are Torchlight Trouble's start, checkpoint and bonus-room ways in and out, rewrite the table each frame, and only while the game keeps a sprite number for it. The beam starts at a point set by that sprite's position and offsets carried in its current pose, which also carries two slopes, one for the beam's upper edge and one for its lower edge, in 1/256 px a line; when bit 14 of the sprite's attribute word is set (converted from hex), both slopes and the horizontal offset are taken negated. The point's line is held between 0 and 223 (converted from hex). From it, each line up moves the edge by the upper slope and each line down by the lower: with a positive slope the window runs from the edge to 255, with a negative one from 0 to the edge, and once the edge passes the screen's side every line beyond is set back to 255 and 254. Every frame the cave display routine makes the table's first entry 1 line or 3 by the low bit of a counter, so on alternate counts the whole shape sits 2 lines lower (computed). Code
- In the first US release, the snow stages can wave their third background layer up and down, line by line, with HDMA. The second start step of 15 entrances (by the disassembly's names, Snow Barrel Blast's, Ice Age Alley's and Rambi's bonus room's) builds a table in RAM of 288 one-line entries for that layer's vertical scroll, from a table of 64 values rising from 0 to 127: down the screen the values run 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 0, 0, then the same below 0, a 32-line wave of up to 2 px either way (computed). The step points HDMA channel 2 at the table and leaves HDMA off. The snow display routine starts the channel one entry further back every 2 counts of a counter it reads, so the wave moves down a line every 2 counts and repeats every 64 (computed), and turns the channel on, with the third layer's map moved to another address in video memory, only while a weather stage the game keeps is 5. Code
|
| Lives | |
| Metasprites | - In the first US release, each sprite pose is one block in ROM: an 8-byte header, then 2 bytes per piece (its X, then its Y), then the pose's tiles, which the game sends to video memory as they stand, 32 bytes a tile (dkc-av/sprite-pose-upload). Header byte 0 counts the large pieces; bytes 1 and 3 count two groups of small pieces, and bytes 2 and 4 give each group's first tile number, counted from the sprite's own tile base. Each large piece's tile number is 2 past the last, plus 16 more on reaching a multiple of 16, so from a base that is a multiple of 16 eight large pieces fill each pair of tile rows (computed); each small piece's is 1 past the last. Large pieces get both of a sprite's two extra bits in the sprite table, the second as the size bit; small pieces get the second bit never. A piece whose Y comes out at
$F0 or more after the sprite's offset is added is left out of the frame, and the first extra bit, the ninth X bit, is kept only when X passes 255. Code - In the first US release, a sprite's tiles go to video memory only when its pose changes: the game queues one transfer of header byte 5 × 32 bytes, read straight from the pose's block in ROM after its piece list, to video memory at the sprite's own tile base, and a second of byte 7's low four bits × 32 bytes, landing byte 6 × 16 words further on, when that count isn't 0. A later routine runs the queue as DMA transfers to video memory. The queue has a limit on uploads; at or past it, nothing is queued, and poses from number 141 up are drawn as the pose last uploaded. Code
- In the first US release, each animation is a script of entries, each a length byte below 128 followed by a 2-byte pose number. Each frame the game takes the sprite's animation speed from its timer; when the timer reaches 0 or less it adds the next entry's length × 256 and shows that entry's pose, so at the speed an animation starts with a length counts frames (computed). An entry that leaves the timer still negative is passed over, so a higher speed can skip poses. A byte from 128 up is a command: the first restarts the animation from its first entry, and the second calls a routine named by a 3-byte address. Code
- In the first US release, eight looping animations of the two Kongs list these pose entries before their restart command (counted, computed). At the speed an animation starts with, the lengths add up to the frames one pass takes (computed), as long as the routines the scripts call (commands
$81, $83 and $84, unread) leave the speed and the script alone. The animations the disassembly names Donkey Kong's walk and run each step through 20 poses, one length unit apiece; the ones it names Diddy's walk and run have 16 and 13 poses, two units apiece. Code
|
| Music driver | - In the first US release, the game sends the sound driver to the audio processor once, at reset: first a small loader, then 3,454 bytes of driver to audio RAM from address 1,248 (both computed), the first 256 of them zeros, then the sound effects. To start a song it sends the song's data, each block headed by its length and its address in audio RAM, restarts the driver at its entry point, and waits for the driver to answer 255. Each byte goes over the ports with a toggling handshake that the loader echoes back. Code
- In the first US release, the song table has 27 entries, each a 3-byte pointer to a song's data, and a second table holds 28 sample lists. Starting a song through the game's music routine first loads the sample list with the song's own number, so the Samples column is each song's set beside the 29 shared ones. Lists 18 and 26 are one list; list 27 has no song of its own: when the boot screen's fanfare (song 10) starts before the shared 29 have loaded, list 27 loads in their place, and otherwise list 10 does. Code
- In the first US release, the sound driver reads each track as bytes: from
$81 up a note, followed by its length, where the note byte plus the track's transpose picks the entry in a table of 61 pitches; $80 a rest; and below $80 one of 49 commands, $00 to $30, through a jump table. A note writes the voice's volume, pitch, sample, and envelope to the sound chip and keys the voice on. The rows give each command's length in bytes, as its handler moves the track on, and what it sets; four of the commands set parameters for effects the driver runs each tick, whose use isn't read here. Code - In the first US release, sound effects play on the same eight voices as the music: the driver runs 16 tracks, the music's eight and eight for effects, and effect track 8 + n uses voice n. An effect that starts takes its voice over, turning its noise and echo bits off; while it plays, the music track for that voice keeps its place, and a music note on that voice writes nothing to it. When the effect ends the voice goes back to the music, with its echo bit set again if the music had turned echo on. Code
|
| Palette swap | - In the first US release, sprites draw from eight palette slots of 15 colors each: the game copies 30 bytes per palette to color memory at entry 129 + 16 × the slot (computed), leaving the 16-color block's first entry alone. A sprite asks for a palette by its address. A slot that holds that palette and whose use count isn't negative is shared, and its count goes up; a holder whose count is negative is passed over. Without a match, the first empty slot takes the palette and its upload joins a queue of 16, from which each call of the upload routine sends one. With neither, the sprite gets slot 0 and the request is kept with a retry value of 120 (computed), whose unit isn't read. In one mode, set by a flag the code tests, the colors come from a copy in RAM laid out like the ROM's palette area instead of from ROM. Code
- In the first US release, the two Kongs' palettes are swapped by which Kong the game has as current. When the word the disassembly names the current Kong is 1, the palette the disassembly files as Donkey Kong's active one goes to the sprite a first Kong slot names, and Diddy's inactive one to sprite 4; otherwise Diddy's active one goes to the sprite a second slot names and Donkey Kong's inactive one to sprite 2. A slot holding 0 falls back to sprite 2 or 4. Under one condition, read but not identified, all four move two palettes on, to the ones the disassembly files as the Kongs' P2 palettes. Code
|
| Sampled sound | - In the first US release, the game loads samples into audio RAM a list at a time and keeps a 255-byte map from each sample's number to its slot. It points the sound chip's sample directory at
$3200, 4 bytes a slot (the sample's start and its loop point), and puts sample data from $3300. A list of 29 samples loads once, the first time either of the two routines that ask for it runs; after it, each song's own list loads in its place, starting where the 29 end, unless the same list is already loaded. For each sample the game sends its data, then its directory entry, and writes its slot into the map, which it then copies to audio RAM at $04E0. The driver's instrument command reads that map. Code - The sample table holds 70 entries, each a 3-byte pointer into banks C7 and C8; each sample there starts with two 16-bit words, its loop offset and its length in bytes, and its data follows. The table and the rest of bank C9 are byte-identical in the first US release and Rev 2; banks C7 and C8 may differ, so the rows' lengths and loop offsets are Rev 2's. In Rev 2, 8 of the 70 samples have a loop offset other than 0, and 32 have the loop flag set in their last block, so they repeat (counted, computed). Code
|
| Screen fade | |
| Scrolling | - In the first US release, each entrance (a stage's start, its checkpoint barrel, a way into or out of a bonus room) picks the routines that run each frame while that entrance is in play from a table of 230 rows, one per entrance number. Each row is a pair of routines; each of the first routines named here writes the background layers' scroll registers (dkc-av/parallax-layers), and one caller runs the first alone while another runs the first and then the second. The frame interrupt runs the current task of a list, and the list the game sets up for play holds a loading task and then that second caller, so once the loading task moves the list on, both routines of the entrance's pair run on each frame interrupt; the interrupt that comes while a frame's work is still running only rewrites the brightness and returns. The 230 rows hold 21 different pairs (counted). By the disassembly's names for the entrance numbers, Torchlight Trouble's rows hold the pair that Reptile Rumble, Bouncy Bonanza, Manic Mincers and Elevator Antics also use, and Orang-utan Gang's start and its five returns from bonus rooms hold a pair no other entrance uses. Code
- In the first US release, the stages' display routines move the second background layer at half the first layer's horizontal speed in the jungle, Orang-utan Gang, snow and cave pairs (dkc-av/level-display-routines). Vertically the jungle pair moves it at a quarter of the first layer's speed, and Orang-utan Gang's and the snow pair at an eighth, the snow pair holding it at 31 px at most; the cave pair moves it at an eighth of the first layer's position held at 287 px or less (both converted from hex). The underwater pair holds the second layer's vertical scroll at -1 (converted from hex) and moves the third layer vertically with the first. The cave and underwater pairs move the third layer horizontally at one and a half times the first layer's speed (computed), except in Poison Pond, where HDMA rewrites the third layer's scroll down the screen (dkc-av/poison-pond-blend). Code
|