;;; CGRAM ;;; { BG palette 6: Room background BG palette 7: Kraid Sprite palette 3: Kraid rocks Sprite palette 7: Kraid } ;;; VRAM ;;; { $0000..3FFF: BG1/2 tiles { $2000..27FF: BG3 tiles $3E00..3FFF: BG1/2 tiles that need reloading after pause screen { $3F00..3FFF: Room background } } $4000..4FFF: BG2 tilemap $5000..57FF: BG1 tilemap $5800..5FFF: BG3 tilemap $6000..7FFF: Sprite tiles } ;;; WRAM ;;; { Slot ID Enemy Enemy RAM 00 E2BF Kraid 0F78..0FB7, 7800..783F 01 E2FF Kraid arm 0FB8..0FF7, 7840..787F 02 E33F Top lint 0FF8..1037, 7880..78BF 03 E37F Middle lint 1038..1077, 78C0..78FF 04 E3BF Bottom lint 1078..10B7, 7900..793F 05 E3FF Kraid foot 10B8..10F7, 7940..797F 06 E43F Good fingernail 10F8..1137, 7980..79BF (gives drops) 07 E47F Bad fingernail 1138..1177, 79C0..79FF (doesn't give drops) $0FA8: Function $0FAA: { Kraid instruction list pointer Kraid fingernail X subvelocity Kraid lint spawning X speed } $0FAC: { Kraid instruction timer Kraid fingernail X velocity Kraid lint X additional spawning velocity } $0FAE: Kraid fingernail Y subvelocity $0FB0: Kraid fingernail Y velocity. Unused triple damage flag (set when Kraid's mouth is shot, read by unused $B269) $0FB2: Function timer $0FB4: Set to 1 by fingernails, otherwise unused $0FB6: Kraid ceiling break index $7E:7800: Next function. Kraid foot thinking timer $7E:7802: Set to 2 in Kraid main loop / Kraid shot if shot with charge beam, no effect $7E:7804: Initialised to 0 if Kraid is dead, otherwise unused $7E:7806: Kraid thinking timer. Only used for transition to attacking with mouth open during first phase, and initial mouth opening during transition to second phase $7E:7808: Minimum Y position to which Kraid will eject Samus. Initialised to 144h, then set to A4h when ceiling breaks $7E:780A: Kraid mouth reopen flags { 1: Shot body with charged beam this frame 2: Shot body with charged beam (during main loop - thinking) 4: Reopen mouth. Set when shot in mouth after being shot in body with charged beam } $7E:780B: Kraid mouth reopen counter. Set to 3 when shot in body with charged beam $7E:780C: Kraid max health * 1/8 $7E:780E: Kraid max health * 2/8. Kraid fingernail orientation: 0 if diagonal, 1 if horizontal $7E:7810: Kraid max health * 3/8 $7E:7812: Kraid max health * 4/8 $7E:7814: Kraid max health * 5/8 $7E:7816: Kraid max health * 6/8 $7E:7818: Kraid max health * 7/8 $7E:781A: Kraid max health * 8/8 $7E:781E: Kraid target X position $7E:7820: Kraid max health * 1/4 $7E:7822: Kraid max health * 2/4 $7E:7824: Kraid max health * 3/4 $7E:7826: Kraid max health * 4/4 $7E:782A: Kraid hurt frame (flashes white on odd frames) $7E:782C: Kraid hurt frame timer $7E:783E: Initialised to 0, otherwise unused $7E:2000..2FFF: BG2 tilemap { $7E:2000..27FF: Kraid top half. Transferred to VRAM BG2 tilemap when unpausing $7E:2800..2DFF: Kraid bottom half $7E:2FC0..FF: Used to clear rows of Kraid's tilemap when he's dying } $7E:4000..4FFF: Decompression buffer $7E:5000..53FF: Copy of VRAM $3E00..3FFF during pause screen } ;;; Execution flow ;;; { $A959: Kraid initialisation { Unpause hook = $C24E (unpause hook - Kraid is alive) Pause hook = $C325 (pause hook - Kraid) If Kraid is dead: Kraid function = $C715 (fade in regular background) Kraid is alive: Kraid function = $C865 (restrict Samus X position to first screen) Kraid function timer = 300 Kraid next function = $C86B (raise Kraid through floor) } $AB43: Kraid's arm initialisation { If Kraid is alive: Kraid arm function = $BA2D (RTL) Kraid arm instruction list pointer = $8AA4 (rising/sinking) } $AB68/$AB9C/$ABCA: Kraid lint initialisation { If Kraid is alive: Kraid top lint function = $B831 (RTL) Kraid top lint instruction list pointer = $8AFE (initial) Kraid top lint instruction timer = 7FFFh Kraid top lint spritemap pointer = $A5DF } $ABF8: Kraid's foot initialisation { If Kraid is alive: Kraid foot function = $BA2D (RTL) Kraid foot instruction list pointer = $86E7 (initial) } $AC21: Kraid main AI { $AFAA: Kraid's mouth / projectile collision handling { If Kraid shot with fatal blow and [Kraid function] < $C360 (Kraid death): Kraid function = $C360 (Kraid death) If [Kraid instruction list pointer] < $970E (roar): Kraid instruction list pointer += $970E (dying roar) - $96D2 (roar) } $B181: Kraid body / projectile collision handling { If shot and [Kraid function] = $AEA4 (Kraid main loop - thinking): Kraid function = $B6BF (Kraid shot) } Execute Kraid function } Kraid functions: { $C715: Fade in regular background { $C715: Clear BG2 tilemap top half $C751: Clear BG2 tilemap bottom half $C777: Load standard BG3 tiles 1/4 { Unpause hook = $C1FB (unpause hook - Kraid is dead) } $C7A3: Load standard BG3 tiles 2/4 $C7C9: Load standard BG3 tiles 3/4 $C7EF: Load standard BG3 tiles 4/4 $C815: Fade in BG palette 6 { If Kraid is alive: Kraid function = $C843: Set enemy properties to dead - Kraid was alive Else: Kraid function = $C851: Set enemy properties to dead - Kraid was dead } } $C865: Restrict Samus X position to first screen (eventually goes to Kraid next function) $B965: Process Kraid instruction (eventually goes to Kraid next function) $C86B: Raise Kraid through floor { $C86B: Load tilemap top half $C89A: Load tilemap bottom half, start music and earthquake $C8E0: Spawn random earthquake projectiles every 10h frames $C902: Spawn random earthquake projectiles every 8 frames $C924: Raise Kraid { If [Kraid Y position] < 1C9h: Kraid function = $AEA4 (Kraid main loop) Kraid instruction list pointer = $96D2 + 8 (roar) Kraid foot function = $B960 (first phase - thinking) Kraid foot next function = $BF2D (first phase - prepare to lunge forward) Kraid arm instruction list pointer = $89F3 (normal) } } $AEA4: Kraid main loop { $AEA4: Thinking (can be shot to trigger mouth opening) { If Kraid thinking timer decremented to zero: Kraid instruction list pointer = $96D2 + 8 (roar) Kraid function = $BBEA (attacking with mouth open) } $BBEA: Attacking with mouth open { If finished instructions: If set to reopen mouth and [Kraid mouth reopen counter] != 0: (mouth reopen) Kraid function = $B92D (handle Kraid enemy function timer) Kraid next function = $B6BF (Kraid shot) Else: Kraid function = $AEA4 (thinking) } } $B6BF: Kraid shot { $B6BF: Initialise Kraid eye glowing { Kraid instruction list pointer = $974A + 8 (eye glowing) } $B6D7: Glow Kraid's eye $B73D: Unglow Kraid's eye { Kraid instruction list pointer = $96D2 + 8 (roar) } $AEE4: Kraid's mouth is open { If finished instructions: If set to reopen mouth and [Kraid mouth reopen counter] != 0: (mouth reopen) Kraid function = $B92D (handle Kraid enemy function timer) Kraid next function = $B6BF (Kraid shot) Else: Kraid function = $AEA4 (Kraid main loop) } } $C0A1: Kraid gets big { $C0A1: Release camera $AC4D: Break ceiling into platforms $AD3A: Set BG2 tilemap priority bits $AD61: Finish updating BG2 tilemap { Kraid foot instruction list pointer = $86ED (Kraid is big - neutral) Kraid lints instruction list pointer = $8B04 (Kraid is big) } $AD8E: Draw room background $AE23: Fade in room background { If reached target colour: Kraid instruction list pointer = $96D2 + 8 (roar) Kraid lints function = $B923 (horizontally align enemy to Kraid) Kraid lints next function = $B832 (produce lint) Kraid fingernails function = $B92D (handle Kraid enemy function timer) Kraid fingernails next function = $BD60 (initialise fingernail) Kraid foot function = $BB6E (second phase setup) Kraid foot instruction list pointer = $8887 (Kraid is big - walking backwards) } $AEC4: Thinking { If Kraid thinking timer decremented to zero: Kraid function = $AEE4 (Kraid shot - Kraid's mouth is open) Kraid instruction list pointer = $96D2 + 8 (roar) } } $C360: Kraid death { $C360: Initialise death { Kraid arm instruction list pointer = $8AF0 (dying / preparing to lunge forward) Kraid instruction list pointer = $9764 + 8 (dying) } $C3F9: Fade out background $C4A4: Update BG2 tilemap top half { Kraid lint functions = $B923 (horizontally align enemy to Kraid) } $C4C8: Update BG2 tilemap bottom half { Unpause hook = $C2A0 (unpause hook - Kraid is sinking) Kraid arm instruction list pointer = $8AA4 (rising/sinking) Kraid foot instruction list pointer = $86E7 (initial) Kraid foot function = $BA2D (RTL) } $C537: Kraid sinks through floor { If [Kraid Y position] >= 260h: Kraid function = $C715 (fade in regular background) } } } Kraid foot functions: { $B960: First phase { $B960: Thinking (eventually goes to Kraid foot next function) { If [Kraid health] < [7/8 Kraid health]: Kraid function = $B965 (process Kraid instruction) Kraid next function = $C0A1 (Kraid gets big) Kraid instruction list pointer = $96D2 + 8 (roar) + 32h/2Ah/22h/1Ah Kraid foot function = $BA2D (RTS) Kraid foot instruction list pointer = $86E7 (initial) Kraid arm instruction list pointer = $89F3 (normal) } $BF2D: Prepare to lunge forward { If [Kraid arm instruction list pointer] >= $8A37: Kraid arm instruction list pointer = $8AF0 (dying / preparing to lunge forward) Kraid foot instruction list pointer = $87BD (lunge forward) } $BF5D: Lunge forward { If [Kraid foot instruction list pointer] = $8885: If [Kraid X position] != 5Ch: Kraid foot instruction list pointer = $87BD (lunge forward) Else: Kraid foot instruction list pointer = $86ED (Kraid is big - neutral) Kraid foot function = $BFAB (retreat from lunge) } $BFAB: Retreat from lunge { If [Kraid foot instruction list pointer] >= $8939: If [Kraid X position] != B0h: Kraid foot instruction list pointer = $8887 (Kraid is big - walking backwards) Else: Kraid foot instruction list pointer = $86ED (Kraid is big - neutral) Kraid arm instruction list pointer = $89F3 (normal) Kraid foot function = $B960 (thinking) } } $BB6E: Second phase setup { $BB6E: Walk to starting spot { If [Kraid target X position] <= [Kraid X position] and [Kraid foot instruction list pointer] >= $8939: Kraid foot instruction list pointer = $86ED (Kraid is big - neutral) Kraid foot function = $B92D (decrement enemy function timer) Kraid foot next function = $BBA4 (initialise second phase) } $B92D: Decrement enemy function timer (eventually goes to next function) $BBA4: Initialise second phase { Kraid foot instruction list pointer = $8887 (Kraid is big - walking backwards) Kraid foot function = $BB45 (second phase) } } $BB45: Second phase { $BB45: Walking backwards { If [Kraid target X position] <= [Kraid X position] and [Kraid foot instruction list pointer] >= $8939: Kraid foot instruction list pointer = $86ED (Kraid is big - neutral) } $BA2E: Thinking { If Kraid thinking timer decremented to zero: Kraid foot instruction list pointer = $8887/$86F3 (Kraid is big - walking backwards/forwards) Kraid foot function = $BB45/$BBAE } $BBAE: Walking forwards { If [Kraid foot instruction list pointer] = $87BB (last frame of walking forwards animation): If [Kraid target X position] < [Kraid X position]: Kraid foot instruction list pointer = $86F3 (Kraid is big - walking forwards) Else: Kraid foot function = $BA2E (thinking) Kraid foot instruction list pointer = $86ED (Kraid is big - neutral) } } } Kraid lints functions: { $B923: Horizontally align enemy to Kraid $B832: Produce lint $B868: Charge lint $B89B: Fire lint } Kraid fingernails functions: { $B92D: Handle Kraid enemy function timer $BD60: Initialise fingernail { Enemy instruction list pointer = $8B0A (fingernail) } $B907: Wait until top lint X position >= 100h $BE8E: Fire fingernail } } ;;; Kraid instructions ;;; { Points to the *next* instruction in the instruction list, FFFFh terminated, 7FFFh will cause a crash If t & 8000h = 0: tttt TTTT pppp mmmm t: Timer T: Tilemap pointer, fixed 2C0h bytes p: Kraid projectile hitbox m: Kraid's mouth projectile hitbox If p & 8000h != 0: pppp p: If FFFFh, terminator, otherwise pointer to function } ;;; Enemy headers ;;; { ______________________________________________________________________ $E2BF: Kraid | _____________________________________________________________ $E2FF: Kraid arm | | ____________________________________________________ $E33F: Top lint | | | ___________________________________________ $E37F: Middle lint | | | | __________________________________ $E3BF: Bottom lint | | | | | _________________________ $E3FF: Kraid foot | | | | | | ________________ $E43F: Good fingernail (gives drops) | | | | | | | _______ $E47F: Bad fingernail (doesn't give drops) | | | | | | | | 1E00 1E00 1E00 1E00 1E00 1E00 1E00 1E00 ; 0: Tile data size 8687 8687 8687 8687 8687 8687 8687 8687 ; 2: Palette 03E8 03E8 03E8 03E8 03E8 03E8 000A 000A ; 4: Health 0014 0014 000A 000A 000A 0014 000A 000A ; 6: Damage 0038 0030 0018 0018 0018 0008 0008 0008 ; 8: Width 0090 0030 0008 0008 0008 0008 0008 0008 ; Ah: Height A7 A7 A7 A7 A7 A7 A7 A7 ; Ch: Bank 00 00 00 00 00 00 00 00 ; Dh: Hurt AI time 0000 0000 0000 0000 0000 0000 0000 0000 ; Eh: Cry 0003 0000 0000 0000 0000 0000 0000 0000 ; 10h: Boss value A959 AB43 AB68 AB9C ABCA ABF8 BCEF BD2D ; 12h: Initialisation AI 0001 0001 0001 0001 0001 0001 0001 0001 ; 14h: Number of parts AC21 B7BD B801 B80D B819 B9F6 BD32 BD49 ; 18h: Main AI 800F 800F 800F 800F 800F 800F 800F 800F ; 1Ah: Grapple AI 804C 804C 804C 804C 804C 804C 804C 804C ; 1Ch: Hurt AI 8041 8041 8041 8041 8041 8041 8041 8041 ; 1Eh: Frozen AI 0000 0000 0000 0000 0000 0000 0000 0000 ; 20h: X-ray AI 0000 0000 0000 0000 0000 0000 0000 0000 ; 22h: Death animation 803C 0000 0000 0000 0000 0000 0000 0000 ; 28h: Power bomb reaction 949F 9490 948F 948F 948F 948F BCCF BCDE ; 30h: Enemy touch 804C 94B5 802D 802D 802D 94B5 802D 802D ; 32h: Enemy shot ABCC00 ABCC00 ABCC00 ABCC00 ABCC00 ABCC00 ABCC00 ABCC00 ; 36h: Tile data 05 05 05 05 05 05 05 05 ; 39h: Layer F41C 0000 0000 0000 0000 F422 F422 0000 ; 3Ah: Drop chances ($B4) F15A F170 F186 F186 F186 F170 F19C F19C ; 3Ch: Vulnerabilities ($B4) 0000 0000 0000 0000 0000 0000 0000 0000 ; 3Eh: Enemy name ($B4) } ;;; Enemy vulnerabilities ;;; { ; Vulnerability format: ; v = fddddddd ; If v = FFh: ; Freeze, no damage ; Else: ; d: Damage multiplier * 2 ; f: Does not freeze ; _________________________________________________________________ 0: Power ; | ______________________________________________________________ 1: Wave ; | | ___________________________________________________________ 2: Ice ; | | | ________________________________________________________ 3: Ice + wave ; | | | | _____________________________________________________ 4: Spazer ; | | | | | __________________________________________________ 5: Spazer + wave ; | | | | | | _______________________________________________ 6: Spazer + ice ; | | | | | | | ____________________________________________ 7: Spazer + ice + wave ; | | | | | | | | _________________________________________ 8: Plasma ; | | | | | | | | | ______________________________________ 9: Plasma + wave ; | | | | | | | | | | ___________________________________ Ah: Plasma + ice ; | | | | | | | | | | | ________________________________ Bh: Plasma + ice + wave ; | | | | | | | | | | | | ; | | | | | | | | | | | | ____________________________ Ch: Missile ; | | | | | | | | | | | | | _________________________ Dh: Super missile ; | | | | | | | | | | | | | | ______________________ Eh: Bomb ; | | | | | | | | | | | | | | | ___________________ Fh: Power bomb ; | | | | | | | | | | | | | | | | ________________ 10h: Speed booster ; | | | | | | | | | | | | | | | | | _____________ 11h: Shinespark ; | | | | | | | | | | | | | | | | | | __________ 12h: Screw attack ; | | | | | | | | | | | | | | | | | | | _______ 13h: Charged beam ; | | | | | | | | | | | | | | | | | | | | ____ 14h: Pseudo screw attack ; | | | | | | | | | | | | | | | | | | | | | _ 15h: Unused ; | | | | | | | | | | | | | | | | | | | | | | $B4:F15A db 82,82,82,82,82,82,82,82,82,82,82,82, 82,82,80,80,80,80,80,02,80,80 ; Kraid $B4:F170 db 80,80,80,80,80,80,80,80,80,80,80,80, 80,80,80,80,80,80,80,00,80,80 ; Kraid limbs $B4:F186 db 80,80,80,80,80,80,80,80,80,80,80,80, 80,80,80,80,80,80,80,00,80,80 ; Kraid lint $B4:F19C db 82,82,82,82,82,82,82,82,82,82,82,82, 82,82,82,82,82,00,82,02,82,82 ; Kraid fingernails } ;;; Enemy drop chances ;;; { ; ________________ ; 0: Small health ; | _____________ ; 1: Big health ; | | __________ ; 2: Missiles ; | | | _______ ; 3: Nothing ; | | | | ____ ; 4: Super missiles ; | | | | | _ ; 5: Power bombs ; | | | | | | $B4:F41C db 32,32,32,00,32,37 ; 19.6% 19.6% 19.6% 19.6% 21.6% - Kraid $B4:F422 db 0A,23,C8,00,0A,00 ; 3.9% 13.7% 78.4% 3.9% - Kraid foot and good fingernail } ;;; Enemy population ;;; { ; ____________________________________ Enemy ID ; | _______________________________ X position ; | | __________________________ Y position ; | | | _____________________ Initialisation parameter ; | | | | ________________ Properties (8000h: hitbox solid to Samus, 4000h: respawns if killed, 2000h: process instructions, 800h: process off-screen, 400h: intangible) ; | | | | | ___________ Extra properties (4: extended spritemap format) ; | | | | | | ______ Parameter 1 ; | | | | | | | _ Parameter 2 ; | | | | | | | | $A1:9EB5 dx E2BF,0100,0218,0000,0D00,0004,0000,0000, ; Kraid E2FF,00E8,01E8,0000,2800,0004,0000,0001, ; Kraid arm E33F,00C8,0210,0000,A800,0000,0000,0000, ; Top lint E37F,00B0,0250,0000,A800,0000,0000,0001, ; Middle lint E3BF,00B2,0288,0000,A800,0000,0000,0002, ; Bottom lint E3FF,0100,0278,0000,2C00,0004,0000,0003, ; Kraid foot E43F,00E8,01E8,0000,6800,0000,0000,0000, ; Good fingernail E47F,00E8,01E8,0000,6800,0000,0000,0000, ; Bad fingernail FFFF, 00 } ;;; Library background commands ;;; { $8F:B815 dx 0008,9AB200,2000,1000, ; Standard BG3 tiles 0004,B9FA38,4000, ;\ 0002,7E4000,4000,1000, ;} Kraid top half 0004,B9FE3E,4000, ;\ 0002,7E4000,4800,1000, ;} Kraid bottom half 0000 }