.include "symbols.inc" .include "locals.inc" .segment "PRG" ;=============================================================================== ; Reset ; ; Global: ; Initializes the NES hardware and game RAM, validates the warm-start ; signature, initializes game-specific state, and transfers control to the ; remainder of the reset path at CPU $C07F. ; ; Parameters: ; None. ; ; Returns: ; Does not return. Execution continues in the preserved PRG region. ; ; PRG offsets: $0000-$007E ; CPU range: $C000-$C07E ; Size: $007F bytes ;=============================================================================== Reset: lda #$00 ; $0000: A9 00 sta PPUCTRL ; $0002: 8D 00 20 sta PPUMASK ; $0005: 8D 01 20 WaitForVBlankSet: lda PPUSTATUS ; $0008: AD 02 20 bpl WaitForVBlankSet ; $000B: 10 FB WaitForVBlankClear: lda PPUSTATUS ; $000D: AD 02 20 bmi WaitForVBlankClear ; $0010: 30 FB WaitForSecondVBlank: lda PPUSTATUS ; $0012: AD 02 20 bpl WaitForSecondVBlank ; $0015: 10 FB sei ; $0017: 78 cld ; $0018: D8 ldx #$FF ; $0019: A2 FF txs ; $001B: 9A ldx #$12 ; $001C: A2 12 lda #$00 ; $001E: A9 00 ClearZeroPage: sta $00,x ; $0020: 95 00 inx ; $0022: E8 bne ClearZeroPage ; $0023: D0 FB ldx #$02 ; $0025: A2 02 CheckSavedSignature: lda $07FA,x ; $0027: BD FA 07 cmp $C082,x ; $002A: DD 82 C0 bne InitializeMemory ; $002D: D0 05 dex ; $002F: CA bpl CheckSavedSignature ; $0030: 10 F5 bmi SavedSignatureValid ; $0032: 30 43 InitializeMemory: ldx #$00 ; $0034: A2 00 txa ; $0036: 8A ClearZeroPageAndStackPage: sta $00,x ; $0037: 95 00 sta $0700,x ; $0039: 9D 00 07 inx ; $003C: E8 bne ClearZeroPageAndStackPage ; $003D: D0 F8 lda #$32 ; $003F: A9 32 sta $15 ; $0041: 85 15 InitializeBlockLoop: lda #$32 ; $0043: A9 32 jsr $D6DE ; $0045: 20 DE D6 lda #$00 ; $0048: A9 00 sta $46 ; $004A: 85 46 jsr $C579 ; $004C: 20 79 C5 dec $15 ; $004F: C6 15 bne InitializeBlockLoop ; $0051: D0 F0 ldx #$0E ; $0053: A2 0E CopyInitializationData: lda $C085,x ; $0055: BD 85 C0 sta $0629,x ; $0058: 9D 29 06 dex ; $005B: CA bpl CopyInitializationData ; $005C: 10 F7 ldx #$04 ; $005E: A2 04 ClearLocalVariables: lda #$00 ; $0060: A9 00 sta $03,x ; $0062: 95 03 dex ; $0064: CA bpl ClearLocalVariables ; $0065: 10 F9 lda #$00 ; $0067: A9 00 jsr $D6DE ; $0069: 20 DE D6 ldx #$02 ; $006C: A2 02 CopySavedSignature: lda $C082,x ; $006E: BD 82 C0 sta $07FA,x ; $0071: 9D FA 07 dex ; $0074: CA bpl CopySavedSignature ; $0075: 10 F7 SavedSignatureValid: lda #$1E ; $0077: A9 1E sta $01 ; $0079: 85 01 lda #$90 ; $007B: A9 90 sta $00 ; $007D: 85 00 ; Decoded PRG block $007F-$046A. EnterMainInitialization: jmp MainInitialization ; $007F: 4C D4 F1 WarmStartSignature: .byte "HAL" ; $0082: 48 41 4C ResetInitializationData: .byte $00, $00, $00, $01, $00, $00, $00, $00 ; $0085: 00 00 00 01 00 00 00 00 .byte $01, $00, $00, $00, $05, $02, $00 ; $008D: 01 00 00 00 05 02 00 ;=============================================================================== ; NmiHandler ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C094; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $0094 ; CPU address: $C094 ;=============================================================================== NmiHandler: pha ; $0094: 48 txa ; $0095: 8A pha ; $0096: 48 tya ; $0097: 98 pha ; $0098: 48 lda #$00 ; $0099: A9 00 sta $2003 ; $009B: 8D 03 20 lda #$02 ; $009E: A9 02 sta $4014 ; $00A0: 8D 14 40 lda PpuBufferReadOffset ; $00A3: A5 52 cmp PpuBufferWriteOffset ; $00A5: C5 53 beq Label_C0AC ; $00A7: F0 03 jsr FlushPpuCommandPreserved ; $00A9: 20 7C C1 Label_C0AC: jsr UpdatePpuTransferSources ; $00AC: 20 0D D6 jsr BuildFrameOam ; $00AF: 20 98 D7 inc FrameCounter ; $00B2: E6 19 lda #$20 ; $00B4: A9 20 sta $2006 ; $00B6: 8D 06 20 lda #$00 ; $00B9: A9 00 sta $2006 ; $00BB: 8D 06 20 lda #$00 ; $00BE: A9 00 sta $2005 ; $00C0: 8D 05 20 sta $2005 ; $00C3: 8D 05 20 jsr UpdateAudioFrame ; $00C6: 20 F7 FF lda #$01 ; $00C9: A9 01 sta NmiCompletedFlag ; $00CB: 85 02 lda RenderingDisabledFlag ; $00CD: A5 16 beq Label_C0F1 ; $00CF: F0 20 Label_C0D1: lda $2002 ; $00D1: AD 02 20 bmi Label_C0D1 ; $00D4: 30 FB ldx #$04 ; $00D6: A2 04 ldy #$C6 ; $00D8: A0 C6 Label_C0DA: dey ; $00DA: 88 bne Label_C0DA ; $00DB: D0 FD dex ; $00DD: CA bne Label_C0DA ; $00DE: D0 FA lda PpuControlBase ; $00E0: A5 18 ora PpuControlShadow ; $00E2: 05 00 sta $2000 ; $00E4: 8D 00 20 lda PpuScrollX ; $00E7: A5 17 sta $2005 ; $00E9: 8D 05 20 lda #$00 ; $00EC: A9 00 sta $2005 ; $00EE: 8D 05 20 Label_C0F1: pla ; $00F1: 68 tay ; $00F2: A8 pla ; $00F3: 68 tax ; $00F4: AA pla ; $00F5: 68 rti ; $00F6: 40 ;=============================================================================== ; IrqHandler ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C0F7; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $00F7 ; CPU address: $C0F7 ;=============================================================================== IrqHandler: jmp IrqHandler ; $00F7: 4C F7 C0 ;=============================================================================== ; DisableNmi ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C0FA; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $00FA ; CPU address: $C0FA ;=============================================================================== DisableNmi: lda PpuControlShadow ; $00FA: A5 00 and #$7F ; $00FC: 29 7F Label_C0FE: sta $2000 ; $00FE: 8D 00 20 sta PpuControlShadow ; $0101: 85 00 rts ; $0103: 60 ;=============================================================================== ; EnableNmi ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C104; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $0104 ; CPU address: $C104 ;=============================================================================== EnableNmi: lda PpuControlShadow ; $0104: A5 00 ora #$80 ; $0106: 09 80 bne Label_C0FE ; $0108: D0 F4 ;=============================================================================== ; SetPpuControl ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C10A; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $010A ; CPU address: $C10A ;=============================================================================== SetPpuControl: lda #$00 ; $010A: A9 00 Label_C10C: pha ; $010C: 48 jsr WaitForFrame ; $010D: 20 65 F4 pla ; $0110: 68 sta $2001 ; $0111: 8D 01 20 rts ; $0114: 60 ;=============================================================================== ; SetPpuMask ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C115; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $0115 ; CPU address: $C115 ;=============================================================================== SetPpuMask: lda PpuMaskShadow ; $0115: A5 01 bne Label_C10C ; $0117: D0 F3 ;=============================================================================== ; WaitForFrameAndSetPpuMask ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C119; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $0119 ; CPU address: $C119 ;=============================================================================== WaitForFrameAndSetPpuMask: jsr BuildPpuCommand ; $0119: 20 54 C1 ldy #$00 ; $011C: A0 00 Label_C11E: lda $0057,y ; $011E: B9 57 00 sta $0300,x ; $0121: 9D 00 03 inx ; $0124: E8 iny ; $0125: C8 cpy PpuCommandLength ; $0126: C4 56 bne Label_C11E ; $0128: D0 F4 stx PpuBufferWriteOffset ; $012A: 86 53 rts ; $012C: 60 ;=============================================================================== ; CopyBytesToPpuBuffer ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C12D; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $012D ; CPU address: $C12D ;=============================================================================== CopyBytesToPpuBuffer: lda #$57 ; $012D: A9 57 ldy #$00 ; $012F: A0 00 ;=============================================================================== ; AppendBytesToPpuBuffer ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C131; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $0131 ; CPU address: $C131 ;=============================================================================== AppendBytesToPpuBuffer: sta PpuSourcePtrLo ; $0131: 85 21 sty PpuSourcePtrHi ; $0133: 84 22 txa ; $0135: 8A pha ; $0136: 48 ldy #$02 ; $0137: A0 02 ;=============================================================================== ; AppendLengthPrefixedPpuData ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C139; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $0139 ; CPU address: $C139 ;=============================================================================== AppendLengthPrefixedPpuData: lda (PpuSourcePtrLo),y ; $0139: B1 21 clc ; $013B: 18 adc #$03 ; $013C: 69 03 sta Temp12 ; $013E: 85 12 ldx PpuBufferWriteOffset ; $0140: A6 53 ldy #$00 ; $0142: A0 00 Label_C144: lda (PpuSourcePtrLo),y ; $0144: B1 21 sta $0300,x ; $0146: 9D 00 03 inx ; $0149: E8 iny ; $014A: C8 cpy Temp12 ; $014B: C4 12 bne Label_C144 ; $014D: D0 F5 stx PpuBufferWriteOffset ; $014F: 86 53 pla ; $0151: 68 tax ; $0152: AA rts ; $0153: 60 ;=============================================================================== ; BuildPpuCommand ; ; Global: ; Builds a PPU command-buffer entry from the pending command address/length. ; ; Local: ; Formats the PPU command (address high byte with $20 prefix, address low ; byte, length) and writes it into the command buffer at $0300. ; ; Parameters: ; PpuCommandAddressLo/Hi ($55/$54), PpuCommandLength ($56), ; PpuBufferWriteOffset ($53). ; ; Returns: ; PpuBufferWriteOffset advanced; command bytes appended to $0300 buffer. ; ; PRG offset: $0154 ; CPU address: $C154 ;=============================================================================== BuildPpuCommand: ldx PpuBufferWriteOffset ; $0154: A6 53 lda #$00 ; $0156: A9 00 sta Temp12 ; $0158: 85 12 lda PpuCommandAddressLo ; $015A: A5 55 asl a ; $015C: 0A asl a ; $015D: 0A asl a ; $015E: 0A asl a ; $015F: 0A rol Temp12 ; $0160: 26 12 asl a ; $0162: 0A ;=============================================================================== ; AppendPpuAddressAndLength ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C163; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $0163 ; CPU address: $C163 ;=============================================================================== AppendPpuAddressAndLength: rol Temp12 ; $0163: 26 12 ora PpuCommandAddressHi ; $0165: 05 54 pha ; $0167: 48 lda Temp12 ; $0168: A5 12 ora #$20 ; $016A: 09 20 sta $0300,x ; $016C: 9D 00 03 inx ; $016F: E8 pla ; $0170: 68 sta $0300,x ; $0171: 9D 00 03 inx ; $0174: E8 lda PpuCommandLength ; $0175: A5 56 sta $0300,x ; $0177: 9D 00 03 inx ; $017A: E8 rts ; $017B: 60 ;=============================================================================== ; FlushPpuCommandPreserved ; ; Global: ; Flushes the PPU command buffer while preserving the X and Y registers. ; ; Local: ; Saves X/Y, calls PreserveXYAndFinalizePpuCommand to walk the $0300 command ; buffer and write pending PPU updates, then restores X/Y. ; ; Parameters: ; PpuBufferReadOffset/WriteOffset ($52/$53). ; ; Returns: ; X and Y preserved; PPU command buffer drained. ; ; PRG offset: $017C ; CPU address: $C17C ;=============================================================================== FlushPpuCommandPreserved: tya ; $017C: 98 pha ; $017D: 48 txa ; $017E: 8A pha ; $017F: 48 jsr PreserveXYAndFinalizePpuCommand; $0180: 20 88 C1 pla ; $0183: 68 tax ; $0184: AA pla ; $0185: 68 tay ; $0186: A8 rts ; $0187: 60 ;=============================================================================== ; PreserveXYAndFinalizePpuCommand ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C188; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $0188 ; CPU address: $C188 ;=============================================================================== PreserveXYAndFinalizePpuCommand: ldx PpuBufferReadOffset ; $0188: A6 52 lda $0300,x ; $018A: BD 00 03 inx ; $018D: E8 sta PpuDestinationHi ; $018E: 85 50 sta $2006 ; $0190: 8D 06 20 ;=============================================================================== ; FlushPpuCommandBuffer ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C193; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $0193 ; CPU address: $C193 ;=============================================================================== FlushPpuCommandBuffer: lda $0300,x ; $0193: BD 00 03 inx ; $0196: E8 sta $2006 ; $0197: 8D 06 20 ldy $0300,x ; $019A: BC 00 03 inx ; $019D: E8 Label_C19E: lda $0300,x ; $019E: BD 00 03 inx ; $01A1: E8 sta $2007 ; $01A2: 8D 07 20 dey ; $01A5: 88 bne Label_C19E ; $01A6: D0 F6 lda PpuDestinationHi ; $01A8: A5 50 cmp #$3F ; $01AA: C9 3F bne Label_C1BE ; $01AC: D0 10 lda #$3F ; $01AE: A9 3F sta $2006 ; $01B0: 8D 06 20 lda #$00 ; $01B3: A9 00 sta $2006 ; $01B5: 8D 06 20 sta $2006 ; $01B8: 8D 06 20 sta $2006 ; $01BB: 8D 06 20 Label_C1BE: stx PpuBufferReadOffset ; $01BE: 86 52 cpx PpuBufferWriteOffset ; $01C0: E4 53 bne PreserveXYAndFinalizePpuCommand; $01C2: D0 C4 rts ; $01C4: 60 Label_C1C5: lda #$20 ; $01C5: A9 20 sta $F2 ; $01C7: 85 F2 jsr $C527 ; $01C9: 20 27 C5 jsr $C539 ; $01CC: 20 39 C5 lda #$FF ; $01CF: A9 FF sta $CD ; $01D1: 85 CD lda #$AD ; $01D3: A9 AD sta SpawnCommandPointerLo ; $01D5: 85 23 lda #$C4 ; $01D7: A9 C4 sta SpawnCommandPointerHi ; $01D9: 85 24 lda #$80 ; $01DB: A9 80 sta $91 ; $01DD: 85 91 sta $0488 ; $01DF: 8D 88 04 lda #$70 ; $01E2: A9 70 sta $9A ; $01E4: 85 9A jsr InitializeParticleSlots ; $01E6: 20 4A CD lda #$00 ; $01E9: A9 00 sta $41 ; $01EB: 85 41 sta $C9 ; $01ED: 85 C9 sta $CA ; $01EF: 85 CA sta $BA ; $01F1: 85 BA sta $C5 ; $01F3: 85 C5 sta $C8 ; $01F5: 85 C8 jsr InitializeAudio ; $01F7: 20 A5 F4 ldx #$13 ; $01FA: A2 13 Label_C1FC: lda #$FF ; $01FC: A9 FF sta $0530,x ; $01FE: 9D 30 05 lda #$F0 ; $0201: A9 F0 sta $04A4,x ; $0203: 9D A4 04 dex ; $0206: CA bpl Label_C1FC ; $0207: 10 F3 Label_C209: jsr $F470 ; $0209: 20 70 F4 jsr UpdateGameplayObjects ; $020C: 20 91 E6 lda $C5 ; $020F: A5 C5 bne Label_C216 ; $0211: D0 03 jsr UpdateSpecialObjectSystem ; $0213: 20 F9 C6 Label_C216: lda FrameCounter ; $0216: A5 19 lsr a ; $0218: 4A bcs Label_C21E ; $0219: B0 03 jmp Label_C2D0 ; $021B: 4C D0 C2 Label_C21E: lda $C5 ; $021E: A5 C5 beq RunGameplayFrame ; $0220: F0 05 dec $C5 ; $0222: C6 C5 jmp Label_C2D0 ; $0224: 4C D0 C2 ;=============================================================================== ; RunGameplayFrame ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C227; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $0227 ; CPU address: $C227 ;=============================================================================== RunGameplayFrame: lda PpuScrollX ; $0227: A5 17 bne Label_C231 ; $0229: D0 06 lda PpuControlBase ; $022B: A5 18 eor #$01 ; $022D: 49 01 sta PpuControlBase ; $022F: 85 18 Label_C231: dec PpuScrollX ; $0231: C6 17 lda $0488 ; $0233: AD 88 04 beq Label_C24D ; $0236: F0 15 inc $0488 ; $0238: EE 88 04 lda $0488 ; $023B: AD 88 04 cmp #$F0 ; $023E: C9 F0 bcc Label_C247 ; $0240: 90 05 lda #$00 ; $0242: A9 00 sta $0488 ; $0244: 8D 88 04 Label_C247: lda $BD ; $0247: A5 BD beq Label_C24D ; $0249: F0 02 inc $91 ; $024B: E6 91 Label_C24D: ldx #$07 ; $024D: A2 07 Label_C24F: lda $055D,x ; $024F: BD 5D 05 bmi Label_C26D ; $0252: 30 19 inc $0567,x ; $0254: FE 67 05 lda $0567,x ; $0257: BD 67 05 cmp #$F8 ; $025A: C9 F8 bne Label_C26D ; $025C: D0 0F lda #$FF ; $025E: A9 FF sta $055D,x ; $0260: 9D 5D 05 lda #$F0 ; $0263: A9 F0 sta $057B,x ; $0265: 9D 7B 05 lda #$00 ; $0268: A9 00 sta $05CE ; $026A: 8D CE 05 Label_C26D: dex ; $026D: CA bpl Label_C24F ; $026E: 10 DF ldx #$13 ; $0270: A2 13 Label_C272: lda $0530,x ; $0272: BD 30 05 bmi Label_C289 ; $0275: 30 12 inc $0490,x ; $0277: FE 90 04 lda $0490,x ; $027A: BD 90 04 cmp #$F8 ; $027D: C9 F8 bcc Label_C289 ; $027F: 90 08 lda #$F0 ; $0281: A9 F0 sta $04A4,x ; $0283: 9D A4 04 sta $0530,x ; $0286: 9D 30 05 Label_C289: dex ; $0289: CA bpl Label_C272 ; $028A: 10 E6 lda PpuScrollX ; $028C: A5 17 and #$07 ; $028E: 29 07 bne Label_C2D0 ; $0290: D0 3E ldx $88 ; $0292: A6 88 dex ; $0294: CA bmi Label_C2D0 ; $0295: 30 39 lda #$00 ; $0297: A9 00 sta $3E ; $0299: 85 3E lda #$01 ; $029B: A9 01 jsr InitializeOrQueueObject ; $029D: 20 DE D6 inc $C9 ; $02A0: E6 C9 lda $C9 ; $02A2: A5 C9 and #$1F ; $02A4: 29 1F bne Label_C2BC ; $02A6: D0 14 inc $CA ; $02A8: E6 CA lda $CA ; $02AA: A5 CA cmp #$0A ; $02AC: C9 0A bne Label_C2BC ; $02AE: D0 0C lda #$02 ; $02B0: A9 02 sta $CA ; $02B2: 85 CA ldy $BA ; $02B4: A4 BA iny ; $02B6: C8 tya ; $02B7: 98 and #$03 ; $02B8: 29 03 sta $BA ; $02BA: 85 BA Label_C2BC: ldx $CA ; $02BC: A6 CA lda SpawnPatternIndexTable,x ; $02BE: BD BF C3 asl a ; $02C1: 0A tay ; $02C2: A8 lda SpawnPatternHandlerTable,y; $02C3: B9 B5 C3 sta DispatchPointerLo ; $02C6: 85 25 lda $C3B6,y ; $02C8: B9 B6 C3 sta DispatchPointerHi ; $02CB: 85 26 jsr DispatchSpawnPattern ; $02CD: 20 B2 C3 Label_C2D0: ldx #$07 ; $02D0: A2 07 Label_C2D2: lda $055D,x ; $02D2: BD 5D 05 bmi Label_C2EF ; $02D5: 30 18 jsr $CECE ; $02D7: 20 CE CE lda $05CD ; $02DA: AD CD 05 beq Label_C2EF ; $02DD: F0 10 dec $05CD ; $02DF: CE CD 05 inc $05CE ; $02E2: EE CE 05 txa ; $02E5: 8A pha ; $02E6: 48 lda $0559 ; $02E7: AD 59 05 jsr InitializeOrQueueObject ; $02EA: 20 DE D6 pla ; $02ED: 68 tax ; $02EE: AA Label_C2EF: jsr $CE2F ; $02EF: 20 2F CE dex ; $02F2: CA bpl Label_C2D2 ; $02F3: 10 DD ldx #$13 ; $02F5: A2 13 Label_C2F7: lda $0530,x ; $02F7: BD 30 05 bmi Label_C317 ; $02FA: 30 1B lda $C5 ; $02FC: A5 C5 bne Label_C314 ; $02FE: D0 14 jsr $C9B6 ; $0300: 20 B6 C9 lda $04A4,x ; $0303: BD A4 04 cmp #$02 ; $0306: C9 02 bcs Label_C30D ; $0308: B0 03 jsr ReflectObjectYVelocity ; $030A: 20 4F CA Label_C30D: cmp #$D8 ; $030D: C9 D8 bcc Label_C314 ; $030F: 90 03 jsr ReflectObjectYVelocity ; $0311: 20 4F CA Label_C314: jsr $CB1C ; $0314: 20 1C CB Label_C317: lda FrameCounter ; $0317: A5 19 and #$07 ; $0319: 29 07 lsr a ; $031B: 4A tay ; $031C: A8 lda $C9DD,y ; $031D: B9 DD C9 pha ; $0320: 48 lda FrameCounter ; $0321: A5 19 lsr a ; $0323: 4A txa ; $0324: 8A bcc Label_C32D ; $0325: 90 06 sta Temp12 ; $0327: 85 12 lda #$13 ; $0329: A9 13 sbc Temp12 ; $032B: E5 12 Label_C32D: asl a ; $032D: 0A asl a ; $032E: 0A tay ; $032F: A8 pla ; $0330: 68 sta $02B1,y ; $0331: 99 B1 02 lda $04A4,x ; $0334: BD A4 04 sta $02B0,y ; $0337: 99 B0 02 lda $0490,x ; $033A: BD 90 04 sta $02B3,y ; $033D: 99 B3 02 lda #$00 ; $0340: A9 00 sta $02B2,y ; $0342: 99 B2 02 dex ; $0345: CA bpl Label_C2F7 ; $0346: 10 AF lda $05CE ; $0348: AD CE 05 cmp #$14 ; $034B: C9 14 bcc Label_C36F ; $034D: 90 20 inc $47 ; $034F: E6 47 lda #$00 ; $0351: A9 00 jsr InitializeOrQueueObject ; $0353: 20 DE D6 dec $47 ; $0356: C6 47 lda #$10 ; $0358: A9 10 sta $F2 ; $035A: 85 F2 inc $C8 ; $035C: E6 C8 jsr $D3ED ; $035E: 20 ED D3 jsr $C527 ; $0361: 20 27 C5 dec $C8 ; $0364: C6 C8 ldx #$64 ; $0366: A2 64 jsr $F45E ; $0368: 20 5E F4 lda #$20 ; $036B: A9 20 sta $F2 ; $036D: 85 F2 Label_C36F: ldx #$F0 ; $036F: A2 F0 lda $0488 ; $0371: AD 88 04 beq Label_C378 ; $0374: F0 02 ldx #$88 ; $0376: A2 88 Label_C378: stx $0200 ; $0378: 8E 00 02 stx $0204 ; $037B: 8E 04 02 sta $0203 ; $037E: 8D 03 02 clc ; $0381: 18 adc #$08 ; $0382: 69 08 sta $0207 ; $0384: 8D 07 02 lda FrameCounter ; $0387: A5 19 and #$03 ; $0389: 29 03 sta $0202 ; $038B: 8D 02 02 sta $0206 ; $038E: 8D 06 02 ldx #$E3 ; $0391: A2 E3 stx $0201 ; $0393: 8E 01 02 inx ; $0396: E8 stx $0205 ; $0397: 8E 05 02 lda $88 ; $039A: A5 88 bmi Label_C3A1 ; $039C: 30 03 jmp Label_C209 ; $039E: 4C 09 C2 Label_C3A1: jsr SortOrInitializeRecords ; $03A1: 20 79 C5 lda #$01 ; $03A4: A9 01 sta $F0 ; $03A6: 85 F0 jsr WaitForFrame ; $03A8: 20 65 F4 lda #$02 ; $03AB: A9 02 sta $F2 ; $03AD: 85 F2 jmp $F36A ; $03AF: 4C 6A F3 ;=============================================================================== ; DispatchSpawnPattern ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C3B2; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $03B2 ; CPU address: $C3B2 ;=============================================================================== DispatchSpawnPattern: jmp ($0025) ; $03B2: 6C 25 00 SpawnPatternHandlerTable: .word SpawnFromCommandStream ; $03B5: C9 C3 .word SpawnAtRandomPosition ; $03B7: F7 C3 .word SpawnPatternNone ; $03B9: 3E C4 .word InitializeSpecialObject ; $03BB: 5F C4 .word SpawnPatternNoneAlt ; $03BD: 5E C4 SpawnPatternIndexTable: .byte $00, $00, $02, $02, $02, $02, $02, $04, $03, $01 ; $03BF: 00 00 02 02 02 02 02 04 03 01 ;=============================================================================== ; SpawnFromCommandStream ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C3C9; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $03C9 ; CPU address: $C3C9 ;=============================================================================== SpawnFromCommandStream: ldy #$00 ; $03C9: A0 00 lda (SpawnCommandPointerLo),y ; $03CB: B1 23 inc SpawnCommandPointerLo ; $03CD: E6 23 bne Label_C3D3 ; $03CF: D0 02 inc SpawnCommandPointerHi ; $03D1: E6 24 Label_C3D3: tax ; $03D3: AA beq Label_C3F6 ; $03D4: F0 20 asl a ; $03D6: 0A asl a ; $03D7: 0A asl a ; $03D8: 0A sta SpawnPixelPosition ; $03D9: 85 15 lda #$00 ; $03DB: A9 00 sta SpawnParameter ; $03DD: 85 14 txa ; $03DF: 8A and #$C0 ; $03E0: 29 C0 cmp #$80 ; $03E2: C9 80 bne Label_C3EC ; $03E4: D0 06 jsr AllocateEffectObject ; $03E6: 20 6B C4 jmp SpawnFromCommandStream ; $03E9: 4C C9 C3 Label_C3EC: cmp #$00 ; $03EC: C9 00 bne Label_C3F6 ; $03EE: D0 06 jsr $C486 ; $03F0: 20 86 C4 jmp SpawnFromCommandStream ; $03F3: 4C C9 C3 Label_C3F6: rts ; $03F6: 60 ;=============================================================================== ; SpawnAtRandomPosition ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C3F7; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $03F7 ; CPU address: $C3F7 ;=============================================================================== SpawnAtRandomPosition: jsr GetRandomValue ; $03F7: 20 B3 F1 and #$7F ; $03FA: 29 7F cmp #$04 ; $03FC: C9 04 bcc SpawnRandomObject ; $03FE: 90 0C cmp #$18 ; $0400: C9 18 bcs SpawnRandomObject ; $0402: B0 08 asl a ; $0404: 0A asl a ; $0405: 0A asl a ; $0406: 0A sta SpawnPixelPosition ; $0407: 85 15 jsr AllocateEffectObject ; $0409: 20 6B C4 ;=============================================================================== ; SpawnRandomObject ; ; Global: ; Spawns a gameplay object at a randomized screen position. ; ; Local: ; Picks a random Y position in the valid band, snaps it to a 32-pixel grid, ; derives a spawn parameter from random state and the spawn selector table, ; allocates a gameplay-object slot, then retries (optionally reflecting Y ; velocity) until the object is placed or the slot pool is exhausted. ; ; Parameters: ; RandomState ($1B), SpawnSelector ($BA), SpawnSelectorAdjustmentTable. ; ; Returns: ; A gameplay object allocated and initialized; X = slot ($00-$13) or $FF if ; the pool is full. ; ; PRG offset: $040C ; CPU address: $C40C ;=============================================================================== SpawnRandomObject: jsr GetRandomValue ; $040C: 20 B3 F1 and #$3F ; $040F: 29 3F cmp #$02 ; $0411: C9 02 bcc Label_C439 ; $0413: 90 24 cmp #$18 ; $0415: C9 18 bcs Label_C439 ; $0417: B0 20 asl a ; $0419: 0A asl a ; $041A: 0A asl a ; $041B: 0A sta SpawnPixelPosition ; $041C: 85 15 jsr GetRandomValue ; $041E: 20 B3 F1 and #$3F ; $0421: 29 3F ldx $BA ; $0423: A6 BA adc SpawnSelectorAdjustmentTable,x; $0425: 7D 3A C4 sta SpawnParameter ; $0428: 85 14 jsr $C486 ; $042A: 20 86 C4 jsr GetRandomValue ; $042D: 20 B3 F1 lsr a ; $0430: 4A bcc SpawnRandomObject ; $0431: 90 D9 jsr ReflectObjectYVelocity ; $0433: 20 4F CA jmp SpawnRandomObject ; $0436: 4C 0C C4 Label_C439: rts ; $0439: 60 SpawnSelectorAdjustmentTable: .byte $20, $30, $40, $60 ; $043A: 20 30 40 60 ;=============================================================================== ; SpawnPatternNone ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C43E; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $043E ; CPU address: $C43E ;=============================================================================== SpawnPatternNone: jsr GetRandomValue ; $043E: 20 B3 F1 and #$CF ; $0441: 29 CF bne SpawnAtRandomPosition ; $0443: D0 B2 ldy $89 ; $0445: A4 89 iny ; $0447: C8 bne SpawnAtRandomPosition ; $0448: D0 AD lda #$E6 ; $044A: A9 E6 sta $9B ; $044C: 85 9B lda RandomState ; $044E: A5 1B and #$7F ; $0450: 29 7F adc #$40 ; $0452: 69 40 sta $92 ; $0454: 85 92 lda #$80 ; $0456: A9 80 sta $89 ; $0458: 85 89 lda #$00 ; $045A: A9 00 sta $80 ; $045C: 85 80 ;=============================================================================== ; SpawnPatternNoneAlt ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C45E; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $045E ; CPU address: $C45E ;=============================================================================== SpawnPatternNoneAlt: rts ; $045E: 60 ;=============================================================================== ; InitializeSpecialObject ; ; Global: ; Reachable game-engine routine identified during recursive Pass-1 tracing. ; ; Local: ; Performs the control flow beginning at CPU $C45F; detailed semantics are ; refined as its RAM and table dependencies are traced. ; ; Parameters: ; Caller-defined register and global RAM state. ; ; Returns: ; Routine-specific result; register preservation remains provisional. ; ; PRG offset: $045F ; CPU address: $C45F ;=============================================================================== InitializeSpecialObject: jsr SpawnRandomObject ; $045F: 20 0C C4 jsr GetRandomValue ; $0462: 20 B3 F1 and #$7F ; $0465: 29 7F sta $0508,x ; $0467: 9D 08 05 rts ; $046A: 60 ;=============================================================================== ; AllocateEffectObject ; ; Global: ; Allocates and initializes an entry in the eight-slot effect-object pool. ; ; Local: ; Searches slots 7 through 0 for a negative state byte. If a free slot is ; found, marks it active, clears its X position, and applies the requested ; spawn position to its Y-position field. ; ; Parameters: ; SpawnPixelPosition ($15) = initial effect-object position. ; ; Returns: ; X = allocated slot, $00-$07. If the pool is full, X returns as $FF and no ; pool fields are changed. ; ; Clobbers: ; A and X. ; ; PRG offsets: $046B-$0485 ; CPU range: $C46B-$C485 ;=============================================================================== AllocateEffectObject: ldx #$07 ; $046B: A2 07 @FindFreeSlot: lda EffectObjectState,x ; $046D: BD 5D 05 bmi @InitializeSlot ; $0470: 30 04 dex ; $0472: CA bpl @FindFreeSlot ; $0473: 10 F8 rts ; $0475: 60 @InitializeSlot: lda #$01 ; $0476: A9 01 sta EffectObjectState,x ; $0478: 9D 5D 05 lda #$00 ; $047B: A9 00 sta EffectObjectPosX,x ; $047D: 9D 67 05 lda SpawnPixelPosition ; $0480: A5 15 sta EffectObjectPosY,x ; $0482: 9D 7B 05 rts ; $0485: 60 ;=============================================================================== ; AllocateGameplayObject ; ; Global: ; Allocates and initializes an entry in the twenty-slot gameplay-object pool. ; ; Local: ; Searches slots 19 through 0 for a negative lifecycle-state byte. On ; success, initializes the slot state and clears its movement/parameter ; fields before copying the requested spawn parameters into the position ; fields. ; ; Parameters: ; SpawnParameter ($14) = high X-position or horizontal spawn parameter. ; SpawnPixelPosition ($15) = initial Y-position in pixel units. ; ; Returns: ; X = allocated slot, $00-$13. If the pool is full, X returns as $FF and no ; pool fields are changed. ; ; Clobbers: ; A and X. ; ; PRG offsets: $0486-$04AC ; CPU range: $C486-$C4AC ;=============================================================================== AllocateGameplayObject: ldx #$13 ; $0486: A2 13 @FindFreeSlot: lda GameplayObjectState,x ; $0488: BD 30 05 bmi @InitializeSlot ; $048B: 30 04 dex ; $048D: CA bpl @FindFreeSlot ; $048E: 10 F8 rts ; $0490: 60 @InitializeSlot: lda #$00 ; $0491: A9 00 sta GameplayObjectState,x ; $0493: 9D 30 05 sta GameplayObjectPosX,x ; $0496: 9D 90 04 sta GameplayObjectVelocityX,x ; $0499: 9D F4 04 sta GameplayObjectParameter,x ; $049C: 9D 08 05 sta GameplayObjectVelocityY,x ; $049F: 9D E0 04 lda SpawnParameter ; $04A2: A5 14 sta GameplayObjectPosXHi,x ; $04A4: 9D 1C 05 lda SpawnPixelPosition ; $04A7: A5 15 sta GameplayObjectPosY,x ; $04A9: 9D A4 04 rts ; $04AC: 60 ; Round spawn command stream ; ; Command data consumed by SpawnFromCommandStream ($C3C9) to initialize ; round objects. Each command byte: top 3 bits give the spawn Y position, ; bits 7-6 select object type (%10 = effect object via AllocateEffectObject, ; %00 = gameplay object via AllocateGameplayObject), and any other value ; terminates the stream. ; ; PRG offsets: $04AD-$0526 ; CPU range: $C4AD-$C526 ;=============================================================================== RoundSpawnCommandStream: .byte $00, $00, $09, $00, $08, $8C, $00, $07; $04AD: 00 00 09 00 08 8C 00 07 .byte $18, $00, $18, $00, $19, $00, $1A, $00; $04B5: 18 00 18 00 19 00 1A 00 .byte $84, $94, $1A, $00, $1A, $00, $1A, $00; $04BD: 84 94 1A 00 1A 00 1A 00 .byte $0B, $12, $00, $0C, $13, $00, $0D, $14; $04C5: 0B 12 00 0C 13 00 0D 14 .byte $00, $14, $00, $00, $90, $00, $07, $00; $04CD: 00 14 00 00 90 00 07 00 .byte $07, $8C, $96, $00, $08, $00, $09, $00; $04D5: 07 8C 96 00 08 00 09 00 .byte $00, $18, $00, $17, $00, $16, $00, $00; $04DD: 00 18 00 17 00 16 00 00 .byte $00, $00, $00, $00, $8A, $90, $00, $00; $04E5: 00 00 00 00 8A 90 00 00 .byte $00, $08, $00, $09, $98, $00, $0A, $00; $04ED: 00 08 00 09 98 00 0A 00 .byte $00, $00, $86, $8A, $15, $00, $14, $00; $04F5: 00 00 86 8A 15 00 14 00 .byte $8E, $13, $00, $00, $03, $0D, $00, $0D; $04FD: 8E 13 00 00 03 0D 00 0D .byte $0E, $00, $0C, $0D, $00, $0D, $19, $00; $0505: 0E 00 0C 0D 00 0D 19 00 .byte $86, $92, $00, $00, $98, $00, $00, $0A; $050D: 86 92 00 00 98 00 00 0A .byte $12, $00, $09, $13, $00, $08, $14, $00; $0515: 12 00 09 13 00 08 14 00 .byte $07, $15, $00, $07, $16, $00, $07, $00; $051D: 07 15 00 07 16 00 07 00 .byte $00, $00 ; $0525: 00 00 ;=============================================================================== ; AdvanceRoundSeed ; ; Global: ; Advances the RAM value at RoundSeedValue using a deterministic multiply step. ; ; Local: ; Refreshes the source value, doubles it in memory, then forms ten times the refreshed value modulo 256. ; ; Parameters: ; Round seed/source state in RoundSeedValue. ; ; Returns: ; RoundSeedValue contains the advanced byte value. ; ; PRG offsets: $0527-$0538 ; CPU range: $C527-$C538 ;=============================================================================== AdvanceRoundSeed: jsr UpdateRoundSeedSource ; $0527: 20 E2 D0 asl RoundSeedValue ; $052A: 0E 59 05 lda RoundSeedValue ; $052D: AD 59 05 asl a ; $0530: 0A asl a ; $0531: 0A adc RoundSeedValue ; $0532: 6D 59 05 sta RoundSeedValue ; $0535: 8D 59 05 rts ; $0538: 60 ;=============================================================================== ; FindSortedRecordPosition ; ; Global: ; Finds the insertion position for the current five-byte record. ; ; Local: ; Walks up to 50 five-byte records at SortedRecordTable, comparing bytes from high to low against the current record at $0003-$0007. ; ; Parameters: ; Current five-byte record at $0003-$0007. ; ; Returns: ; A and RecordIndex identify the selected position; $43/$49/$4A receive derived values. ; ; PRG offsets: $0539-$0578 ; CPU range: $C539-$C578 ;=============================================================================== FindSortedRecordPosition: lda #$00 ; $0539: A9 00 sta RecordIndex ; $053B: 85 12 Label_C53D: lda RecordIndex ; $053D: A5 12 asl a ; $053F: 0A asl a ; $0540: 0A adc RecordIndex ; $0541: 65 12 sta RecordPtrLo ; $0543: 85 1D lda #$07 ; $0545: A9 07 sta RecordPtrHi ; $0547: 85 1E ldy #$04 ; $0549: A0 04 Label_C54B: lda (RecordPtrLo),y ; $054B: B1 1D cmp CurrentRecord,y ; $054D: D9 03 00 bcc Label_C563 ; $0550: 90 11 bne Label_C559 ; $0552: D0 05 dey ; $0554: 88 bpl Label_C54B ; $0555: 10 F4 bmi Label_C563 ; $0557: 30 0A Label_C559: inc RecordIndex ; $0559: E6 12 lda RecordIndex ; $055B: A5 12 cmp #$32 ; $055D: C9 32 bne Label_C53D ; $055F: D0 DC dec RecordIndex ; $0561: C6 12 Label_C563: inc RecordIndex ; $0563: E6 12 lda RecordIndex ; $0565: A5 12 pha ; $0567: 48 sta SelectedRecordIndex ; $0568: 85 43 ldy #$0A ; $056A: A0 0A jsr DivideOrScaleRecordValue ; $056C: 20 7C D7 sta ScaledRecordValue ; $056F: 85 4A lda SelectedRecordIndex ; $0571: A5 43 sta SelectedRecordIndexCopy ; $0573: 85 49 pla ; $0575: 68 sta RecordIndex ; $0576: 85 12 rts ; $0578: 60 ;=============================================================================== ; InsertRecordIntoSortedTable ; ; Global: ; Inserts the current five-byte record into the sorted 50-record table. ; ; Local: ; Finds the insertion index, shifts later five-byte records toward the end, and copies the current record into the selected slot. ; ; Parameters: ; Current five-byte record at $0003-$0007. ; ; Returns: ; The table at SortedRecordTable-$07F9 is updated in place. ; ; PRG offsets: $0579-$05B6 ; CPU range: $C579-$C5B6 ;=============================================================================== InsertRecordIntoSortedTable: jsr FindSortedRecordPosition ; $0579: 20 39 C5 dec RecordIndex ; $057C: C6 12 lda #$31 ; $057E: A9 31 sec ; $0580: 38 sbc RecordIndex ; $0581: E5 12 sta ReverseRecordIndex ; $0583: 85 13 asl a ; $0585: 0A asl a ; $0586: 0A adc ReverseRecordIndex ; $0587: 65 13 tay ; $0589: A8 lda RecordIndex ; $058A: A5 12 asl a ; $058C: 0A asl a ; $058D: 0A adc RecordIndex ; $058E: 65 12 sta RecordPtrLo ; $0590: 85 1D clc ; $0592: 18 adc #$05 ; $0593: 69 05 sta DestinationPtrLo ; $0595: 85 1F lda #$07 ; $0597: A9 07 sta RecordPtrHi ; $0599: 85 1E sta DestinationPtrHi ; $059B: 85 20 tya ; $059D: 98 beq Label_C5AC ; $059E: F0 0C dey ; $05A0: 88 Label_C5A1: lda (RecordPtrLo),y ; $05A1: B1 1D sta (DestinationPtrLo),y ; $05A3: 91 1F dey ; $05A5: 88 bne Label_C5A1 ; $05A6: D0 F9 lda (RecordPtrLo),y ; $05A8: B1 1D sta (DestinationPtrLo),y ; $05AA: 91 1F Label_C5AC: ldy #$04 ; $05AC: A0 04 Label_C5AE: lda CurrentRecord,y ; $05AE: B9 03 00 sta (RecordPtrLo),y ; $05B1: 91 1D dey ; $05B3: 88 bpl Label_C5AE ; $05B4: 10 F8 rts ; $05B6: 60 ; Carrier display-selection tables ;=============================================================================== NormalDisplayModeTable: .byte $01, $02, $03, $03 ; $05B7: 01 02 03 03 AlternateDisplayModeTable: .byte $02, $01, $FF, $03, $04, $05, $06, $FF ; $05BB: 02 01 FF 03 04 05 06 FF ;=============================================================================== ; UpdateCarrierObjectDisplay ; ; Global: ; Builds the display state for a carrier/rescue-sequence object and places the selected player relative to it. ; ; Local: ; Selects a display mode from one of two tables, builds an eight-part metasprite, and updates the targeted player position while the sequence is active. ; ; Parameters: ; Carrier sequence state at $048A-$048D and player arrays indexed through $048B. ; ; Returns: ; Carrier metasprite and target-player coordinates updated. ; ; PRG offsets: $05C3-$0613 ; CPU range: $C5C3-$C613 ;=============================================================================== UpdateCarrierObjectDisplay: lda CarrierSequenceTimer ; $05C3: AD 8D 04 lsr a ; $05C6: 4A lsr a ; $05C7: 4A lsr a ; $05C8: 4A tax ; $05C9: AA lda CarrierMode ; $05CA: AD 8A 04 bne Label_C5D5 ; $05CD: D0 06 lda NormalDisplayModeTable,x ; $05CF: BD B7 C5 jmp Label_C5D8 ; $05D2: 4C D8 C5 Label_C5D5: lda AlternateDisplayModeTable,x ; $05D5: BD BB C5 Label_C5D8: sta CarrierDisplayMode ; $05D8: 85 87 ldx #$08 ; $05DA: A2 08 jsr BuildObjectMetasprite ; $05DC: 20 A4 E3 lda CarrierDropPending ; $05DF: AD 8C 04 beq Label_C613 ; $05E2: F0 2F ldx CarrierTargetPlayer ; $05E4: AE 8B 04 lda CarrierSequenceTimer ; $05E7: AD 8D 04 cmp #$20 ; $05EA: C9 20 bne Label_C5F4 ; $05EC: D0 06 lda #$FF ; $05EE: A9 FF sta PlayerSlotState,x ; $05F0: 95 88 bmi Label_C610 ; $05F2: 30 1C Label_C5F4: bcs Label_C613 ; $05F4: B0 1D lda CarrierSavedValue ; $05F6: AD 50 04 bne Label_C602 ; $05F9: D0 07 lda CarrierTargetX ; $05FB: A5 99 clc ; $05FD: 18 adc #$04 ; $05FE: 69 04 bne Label_C607 ; $0600: D0 05 Label_C602: lda CarrierTargetX ; $0602: A5 99 sec ; $0604: 38 sbc #$04 ; $0605: E9 04 Label_C607: sta PlayerPosX,x ; $0607: 95 91 lda CarrierPosY ; $0609: A5 A2 sec ; $060B: 38 sbc #$0A ; $060C: E9 0A sta PlayerPosY,x ; $060E: 95 9A Label_C610: jsr BuildObjectMetasprite ; $0610: 20 A4 E3 Label_C613: rts ; $0613: 60 ;=============================================================================== ; FindEligiblePlayerForCarrier ; ; Global: ; Selects a player slot eligible for the carrier/rescue sequence. ; ; Local: ; Scans player slots 7 through 0, excluding inactive entries and rejecting a slot at the lower screen boundary unless its X position matches the carrier target. ; ; Parameters: ; Player state and position arrays; CarrierTargetX. ; ; Returns: ; CarrierTargetPlayer is set when an eligible player is found; $FF indicates none. ; ; PRG offsets: $0614-$064A ; CPU range: $C614-$C64A ;=============================================================================== FindEligiblePlayerForCarrier: lda #$FF ; $0614: A9 FF sta CarrierTargetPlayer ; $0616: 8D 8B 04 ldx #$07 ; $0619: A2 07 Label_C61B: lda PlayerSlotState,x ; $061B: B5 88 bmi Label_C62B ; $061D: 30 0C lda PlayerPosY,x ; $061F: B5 9A cmp #$B4 ; $0621: C9 B4 bcc Label_C62B ; $0623: 90 06 lda PlayerPosX,x ; $0625: B5 91 cmp CarrierTargetX ; $0627: C5 99 beq Label_C62F ; $0629: F0 04 Label_C62B: dex ; $062B: CA bpl Label_C61B ; $062C: 10 ED rts ; $062E: 60 Label_C62F: stx CarrierTargetPlayer ; $062F: 8E 8B 04 lda PlayerVariantTable,x ; $0632: BD 48 04 sta CarrierSavedValue ; $0635: 8D 50 04 lda #$00 ; $0638: A9 00 sta CarrierMode ; $063A: 8D 8A 04 sta CarrierSequenceTimer ; $063D: 8D 8D 04 sta CarrierDropPending ; $0640: 8D 8C 04 sta CarrierSequenceActive ; $0643: 8D 89 04 lda #$DC ; $0646: A9 DC sta CarrierPosY ; $0648: 85 A2 rts ; $064A: 60 ;=============================================================================== ; AdvanceCarrierTargetX ; ; Global: ; Advances and wraps the carrier horizontal target position. ; ; Local: ; Increments CarrierTargetX and wraps values at $B1 or above back to $40. ; ; Parameters: ; CarrierTargetX. ; ; Returns: ; CarrierTargetX updated. ; ; PRG offsets: $064B-$0657 ; CPU range: $C64B-$C657 ;=============================================================================== AdvanceCarrierTargetX: inc CarrierTargetX ; $064B: E6 99 lda CarrierTargetX ; $064D: A5 99 cmp #$B1 ; $064F: C9 B1 bcc Label_C657 ; $0651: 90 04 lda #$40 ; $0653: A9 40 sta CarrierTargetX ; $0655: 85 99 Label_C657: rts ; $0657: 60 ;=============================================================================== ; UpdateCarrierArrivalSequence ; ; Global: ; Advances the carrier vertical movement and resolves its arrival at the selected player. ; ; Local: ; Moves the carrier toward its target, advances sequence timers, changes player animation/state when contact is reached, and queues a sound request. ; ; Parameters: ; Carrier and player sequence state in zero page and $0489-$048D. ; ; Returns: ; Carrier sequence state, player state, and sound request flags updated. ; ; PRG offsets: $0658-$06B7 ; CPU range: $C658-$C6B7 ;=============================================================================== UpdateCarrierArrivalSequence: lda CarrierSequenceActive ; $0658: AD 89 04 bne Label_C66F ; $065B: D0 12 dec CarrierPosY ; $065D: C6 A2 lda CarrierPosY ; $065F: A5 A2 cmp #$C4 ; $0661: C9 C4 bcs Label_C671 ; $0663: B0 0C inc CarrierPosY ; $0665: E6 A2 inc CarrierMode ; $0667: EE 8A 04 inc CarrierSequenceActive ; $066A: EE 89 04 bne Label_C671 ; $066D: D0 02 Label_C66F: inc CarrierPosY ; $066F: E6 A2 Label_C671: inc CarrierSequenceTimer ; $0671: EE 8D 04 lda CarrierSequenceTimer ; $0674: AD 8D 04 cmp #$18 ; $0677: C9 18 bne Label_C6A3 ; $0679: D0 28 ldx CarrierTargetPlayer ; $067B: AE 8B 04 lda PlayerSlotState,x ; $067E: B5 88 bmi Label_C6A3 ; $0680: 30 21 lda PlayerPosY,x ; $0682: B5 9A clc ; $0684: 18 adc #$10 ; $0685: 69 10 cmp CarrierPosY ; $0687: C5 A2 bcc Label_C6A3 ; $0689: 90 18 ldy PlayerAnimationState,x ; $068B: BC 51 04 lda CarrierAnimationSequenceTable,y ; $068E: B9 B8 C6 sta PlayerAnimationState,x ; $0691: 9D 51 04 lda #$00 ; $0694: A9 00 sta PlayerLifecycleState,x ; $0696: 95 7F sta PlayerSlotState,x ; $0698: 95 88 lda SoundRequestFlags2 ; $069A: A5 F2 ora #$40 ; $069C: 09 40 sta SoundRequestFlags2 ; $069E: 85 F2 inc CarrierDropPending ; $06A0: EE 8C 04 Label_C6A3: lda CarrierMode ; $06A3: AD 8A 04 beq Label_C6B7 ; $06A6: F0 0F lda CarrierSequenceTimer ; $06A8: AD 8D 04 cmp #$28 ; $06AB: C9 28 beq Label_C6B3 ; $06AD: F0 04 cmp #$30 ; $06AF: C9 30 bne Label_C6B7 ; $06B1: D0 04 Label_C6B3: lda #$CC ; $06B3: A9 CC sta CarrierPosY ; $06B5: 85 A2 Label_C6B7: rts ; $06B7: 60 ; Carrier animation remap table ; Maps player animation states to the carrier-sequence animation states. ;=============================================================================== CarrierAnimationSequenceTable: .byte $08, $09, $0A, $0B ; $06B8: 08 09 0A 0B .byte $08, $09, $0A, $0B ; $06BC: 08 09 0A 0B .byte $08, $09, $0A, $0B ; $06C0: 08 09 0A 0B ;=============================================================================== ; BeginCarrierTargetSequence ; ; Global: ; Starts the carrier sequence for the currently selected player when conditions allow. ; ; Local: ; Rejects an already-active sequence or an invalid target, captures player state, resets sequence fields, and initializes the carrier vertical position. ; ; Parameters: ; CarrierTargetPlayer and player arrays. ; ; Returns: ; Carrier sequence activated when a valid target exists. ; ; PRG offsets: $06C4-$06F8 ; CPU range: $C6C4-$C6F8 ;=============================================================================== BeginCarrierTargetSequence: lda CarrierSequenceActive ; $06C4: AD 89 04 bne Label_C6F8 ; $06C7: D0 2F ldx CarrierTargetPlayer ; $06C9: AE 8B 04 lda PlayerSlotState,x ; $06CC: B5 88 bmi Label_C6E0 ; $06CE: 30 10 lda PlayerPosY,x ; $06D0: B5 9A cmp #$B4 ; $06D2: C9 B4 bcc Label_C6E0 ; $06D4: 90 0A lda PlayerPosX,x ; $06D6: B5 91 cmp #$40 ; $06D8: C9 40 bcc Label_C6E0 ; $06DA: 90 04 cmp #$B1 ; $06DC: C9 B1 bcc Label_C6EE ; $06DE: 90 0E Label_C6E0: lda #$30 ; $06E0: A9 30 sec ; $06E2: 38 sbc CarrierSequenceTimer ; $06E3: ED 8D 04 sta CarrierSequenceTimer ; $06E6: 8D 8D 04 inc CarrierSequenceActive ; $06E9: EE 89 04 bne Label_C6F8 ; $06EC: D0 0A Label_C6EE: lda PlayerPosX,x ; $06EE: B5 91 sta $99 ; $06F0: 85 99 lda $0448,x ; $06F2: BD 48 04 sta $0450 ; $06F5: 8D 50 04 Label_C6F8: rts ; $06F8: 60 ;=============================================================================== ; UpdateCarrierSequence ; ; Global: ; Coordinates the carrier target search, movement, arrival, and display update. ; ; Local: ; Advances the target X position while idle; otherwise updates arrival state, acquires a target, starts the sequence, and tail-calls the display updater. ; ; Parameters: ; Carrier sequence state and player arrays. ; ; Returns: ; Carrier and player state updated for the frame. ; ; PRG offsets: $06F9-$0715 ; CPU range: $C6F9-$C715 ;=============================================================================== UpdateCarrierSequence: lda CarrierDisplayMode ; $06F9: A5 87 bpl Label_C70D ; $06FB: 10 10 jsr AdvanceCarrierTargetX ; $06FD: 20 4B C6 jsr FindEligiblePlayerForCarrier ; $0700: 20 14 C6 lda CarrierTargetPlayer ; $0703: AD 8B 04 bpl Label_C709 ; $0706: 10 01 rts ; $0708: 60 Label_C709: lda #$40 ; $0709: A9 40 sta SoundRequestFlags3 ; $070B: 85 F3 Label_C70D: jsr BeginCarrierTargetSequence ; $070D: 20 C4 C6 jsr UpdateCarrierArrivalSequence ; $0710: 20 58 C6 jmp UpdateCarrierObjectDisplay ; $0713: 4C C3 C5 ;=============================================================================== ; InitializeRoundObjectPools ; ; Global: ; Clears the first two gameplay-object slots and starts round object spawning. ; ; Local: ; Marks two gameplay slots unused, clears their auxiliary state, then calls the round-spawn routine. ; ; Parameters: ; Global round state. ; ; Returns: ; Object pools initialized and spawn processing started. ; ; PRG offsets: $0716-$0725 ; CPU range: $C716-$C725 ;=============================================================================== InitializeRoundObjectPools: ldx #$01 ; $0716: A2 01 Label_C718: lda #$FF ; $0718: A9 FF sta GameplayObjectState,x ; $071A: 9D 30 05 sta GameplayObjectAuxState,x ; $071D: 9D 44 05 dex ; $0720: CA bpl Label_C718 ; $0721: 10 F5 jsr SpawnRoundObjects ; $0723: 20 7A C7 ;=============================================================================== ; InitializeRoundPresentation ; ; Global: ; Initializes round-dependent object counts, delays, and hidden OAM entries. ; ; Local: ; Clears pool state, clamps the round index for lookup tables, loads round parameters, hides three OAM entries, and tail-calls presentation setup. ; ; Parameters: ; RoundIndex. ; ; Returns: ; RoundSpawnDelay, SpawnSelector, OAM, and presentation state initialized. ; ; PRG offsets: $0726-$0747 ; CPU range: $C726-$C747 ;=============================================================================== InitializeRoundPresentation: ldx RoundIndex ; $0726: A6 3C cpx #$18 ; $0728: E0 18 bcc Label_C72E ; $072A: 90 02 ldx #$18 ; $072C: A2 18 Label_C72E: lda RoundObjectCountTable,x ; $072E: BD 48 C7 sta SpawnSelector ; $0731: 85 BA lda RoundDelayTable,x ; $0733: BD 61 C7 sta RoundSpawnDelay ; $0736: 85 B8 lda #$F0 ; $0738: A9 F0 sta OamEntryE0Y ; $073A: 8D E0 02 sta OamEntryE4Y ; $073D: 8D E4 02 sta OamEntryE8Y ; $0740: 8D E8 02 lda #$03 ; $0743: A9 03 jmp ConfigureRoundPresentation ; $0745: 4C 56 C8 ; Round spawn lookup tables ;=============================================================================== RoundObjectCountTable: .byte $00, $00, $00, $00, $00, $00, $00, $00 ; $0748: 00 00 00 00 00 00 00 00 .byte $00, $00, $01, $01, $01, $01, $01, $01 ; $0750: 00 00 01 01 01 01 01 01 .byte $02, $01, $01, $01, $01, $01, $01, $01 ; $0758: 02 01 01 01 01 01 01 01 .byte $01 ; $0760: 01 RoundDelayTable: .byte $0F, $0F, $0C, $0C, $0C, $0C, $0A, $0A ; $0761: 0F 0F 0C 0C 0C 0C 0A 0A .byte $0A, $0A, $0C, $0C, $0A, $0A, $0A, $08 ; $0769: 0A 0A 0C 0C 0A 0A 0A 08 .byte $0A, $0A, $08, $08, $08, $08, $08, $08 ; $0771: 0A 0A 08 08 08 08 08 08 .byte $05 ; $0779: 05 ;=============================================================================== ; ChooseRoundSpawnIndex ; ; Global: ; Chooses a randomized spawn index below the current round limit. ; ; Local: ; Copies a negative cached index when available; otherwise repeatedly samples the random generator until the result is below RoundSpawnRandomLimit and nonzero. ; ; Parameters: ; RoundSpawnRandomLimit and cached index $A4. ; ; Returns: ; A contains the selected nonzero index and SelectedSpawnIndex is updated when needed. ; ; PRG offsets: $077A-$078F ; CPU range: $C77A-$C78F ;=============================================================================== ChooseRoundSpawnIndex: lda RoundSpawnRandomLimit ; $077A: A5 A3 bpl Label_C781 ; $077C: 10 03 Label_C77E: sta SelectedSpawnIndex ; $077E: 85 A4 rts ; $0780: 60 Label_C781: jsr GetRandomValue ; $0781: 20 B3 F1 Label_C784: cmp RoundSpawnRandomLimit ; $0784: C5 A3 bcc Label_C77E ; $0786: 90 F6 beq Label_C77E ; $0788: F0 F4 clc ; $078A: 18 sbc RoundSpawnRandomLimit ; $078B: E5 A3 jmp Label_C784 ; $078D: 4C 84 C7 ;=============================================================================== ; UpdateRoundSpawner ; ; Global: ; Runs the timed round-object spawning process. ; ; Local: ; Uses FrameCounter as a divider, counts down RoundSpawnDelay, finds two free gameplay-object slots, initializes a new object from round/spawn tables, and repeats until the round quota is exhausted. ; ; Parameters: ; Round spawn state, gameplay-object arrays, and SpawnSelector. ; ; Returns: ; A gameplay object may be initialized; round counters and sound requests are updated. ; ; PRG offsets: $0790-$0830 ; CPU range: $C790-$C830 ;=============================================================================== UpdateRoundSpawner: lda FrameCounter ; $0790: A5 19 and #$7F ; $0792: 29 7F beq Label_C797 ; $0794: F0 01 Label_C796: rts ; $0796: 60 Label_C797: dec RoundSpawnDelay ; $0797: C6 B8 bne Label_C796 ; $0799: D0 FB ldx #$00 ; $079B: A2 00 lda GameplayObjectState,x ; $079D: BD 30 05 bmi Label_C7AD ; $07A0: 30 0B inx ; $07A2: E8 lda GameplayObjectState,x ; $07A3: BD 30 05 bmi Label_C7AD ; $07A6: 30 05 lda #$01 ; $07A8: A9 01 sta RoundSpawnDelay ; $07AA: 85 B8 rts ; $07AC: 60 Label_C7AD: ldy SelectedSpawnIndex ; $07AD: A4 A4 sty SelectedSpawnIndexCopy ; $07AF: 84 A5 bpl Label_C7B4 ; $07B1: 10 01 rts ; $07B3: 60 Label_C7B4: lda #$80 ; $07B4: A9 80 sta GameplayObjectVelocityFracY,x ; $07B6: 9D B8 04 sta GameplayObjectVelocityIntY,x ; $07B9: 9D CC 04 lda #$00 ; $07BC: A9 00 sta GameplayObjectState,x ; $07BE: 9D 30 05 lda $00B2,y ; $07C1: B9 B2 00 sta GameplayObjectPosX,x ; $07C4: 9D 90 04 lda $00B5,y ; $07C7: B9 B5 00 sta GameplayObjectPosY,x ; $07CA: 9D A4 04 ldy SpawnSelector ; $07CD: A4 BA jsr GetRandomValue ; $07CF: 20 B3 F1 and #$1F ; $07D2: 29 1F adc SpawnParameterTable,y ; $07D4: 79 9F C8 sta GameplayObjectParameter,x ; $07D7: 9D 08 05 lda SpawnPositionHiTable,y ; $07DA: B9 AB C8 sta GameplayObjectPosXHi,x ; $07DD: 9D 1C 05 lda SpawnVelocityYTable,y ; $07E0: B9 A5 C8 sta GameplayObjectVelocityY,x ; $07E3: 9D E0 04 lda SpawnVelocityXTable,y ; $07E6: B9 B1 C8 sta GameplayObjectVelocityX,x ; $07E9: 9D F4 04 jsr GetRandomValue ; $07EC: 20 B3 F1 and #$03 ; $07EF: 29 03 sta GameplayObjectAuxState,x ; $07F1: 9D 44 05 tay ; $07F4: A8 lda SpawnXOffsetTable,y ; $07F5: B9 97 C8 clc ; $07F8: 18 adc GameplayObjectPosX,x ; $07F9: 7D 90 04 sta GameplayObjectPosX,x ; $07FC: 9D 90 04 lda SpawnYOffsetTable,y ; $07FF: B9 9B C8 clc ; $0802: 18 adc GameplayObjectPosY,x ; $0803: 7D A4 04 sta GameplayObjectPosY,x ; $0806: 9D A4 04 lda SpawnFlipYTable,y ; $0809: B9 8F C8 beq Label_C811 ; $080C: F0 03 jsr NegateGameplayObjectVelocityY ; $080E: 20 3D CA Label_C811: lda SpawnFlipXTable,y ; $0811: B9 93 C8 beq Label_C819 ; $0814: F0 03 jsr NegateGameplayObjectVelocityX ; $0816: 20 55 CA Label_C819: lda SpawnSelector ; $0819: A5 BA cmp #$05 ; $081B: C9 05 bcs Label_C821 ; $081D: B0 02 inc SpawnSelector ; $081F: E6 BA Label_C821: lda #$06 ; $0821: A9 06 sec ; $0823: 38 sbc SpawnSelector ; $0824: E5 BA sta RoundSpawnDelay ; $0826: 85 B8 lda SoundRequestFlags0 ; $0828: A5 F0 ora #$04 ; $082A: 09 04 sta SoundRequestFlags0 ; $082C: 85 F0 jmp ChooseRoundSpawnIndex ; $082E: 4C 7A C7 ;=============================================================================== ; UpdateRoundHud ; ; Global: ; Updates the round HUD when the spawn countdown reaches its display phase. ; ; Local: ; Waits for the appropriate frame count, requests a sound at the transition, selects a HUD tile, and appends four values from zero-page arrays to the PPU command buffer. ; ; Parameters: ; RoundSpawnDelay, FrameCounter, and zero-page HUD values. ; ; Returns: ; PPU command buffer receives the updated HUD values. ; ; PRG offsets: $0831-$0855 ; CPU range: $C831-$C855 ;=============================================================================== UpdateRoundHud: lda RoundSpawnDelay ; $0831: A5 B8 cmp #$01 ; $0833: C9 01 bne Label_C88A ; $0835: D0 53 lda GameplayObjectState ; $0837: AD 30 05 bmi Label_C846 ; $083A: 30 0A lda $0531 ; $083C: AD 31 05 bmi Label_C846 ; $083F: 30 05 lda #$02 ; $0841: A9 02 sta RoundSpawnDelay ; $0843: 85 B8 rts ; $0845: 60 Label_C846: lda FrameCounter ; $0846: A5 19 and #$7F ; $0848: 29 7F cmp #$40 ; $084A: C9 40 bcc Label_C88A ; $084C: 90 3C bne ConfigureRoundPresentation ; $084E: D0 06 lda SoundRequestFlags1 ; $0850: A5 F1 ora #$08 ; $0852: 09 08 sta SoundRequestFlags1 ; $0854: 85 F1 ;=============================================================================== ; ConfigureRoundPresentation ; ; Global: ; Configures round presentation state and writes HUD values. ; ; Local: ; Selects a HUD tile from the mode table, iterates active HUD values, and appends them as PPU commands before tail-calling the common buffer append routine. ; ; Parameters: ; A = presentation mode; SelectedSpawnIndex and zero-page HUD values. ; ; Returns: ; PPU command buffer updated. ; ; PRG offsets: $0856-$0882 ; CPU range: $C856-$C882 ;=============================================================================== ConfigureRoundPresentation: and #$03 ; $0856: 29 03 tax ; $0858: AA lda RoundHudTileTable,x ; $0859: BD 8B C8 sta RoundHudTile ; $085C: 85 5A ldx SelectedSpawnIndex ; $085E: A6 A4 bmi Label_C88A ; $0860: 30 28 lda #$23 ; $0862: A9 23 sta RoundHudCommandAddressHi ; $0864: 85 57 lda $A6,x ; $0866: B5 A6 sta RoundHudCommandAddressLo ; $0868: 85 58 lda #$01 ; $086A: A9 01 sta RoundHudCommandLength ; $086C: 85 59 jsr AppendRoundHudValue ; $086E: 20 83 C8 lda $A9,x ; $0871: B5 A9 sta RoundHudCommandAddressLo ; $0873: 85 58 jsr AppendRoundHudValue ; $0875: 20 83 C8 lda $AC,x ; $0878: B5 AC sta RoundHudCommandAddressLo ; $087A: 85 58 jsr AppendRoundHudValue ; $087C: 20 83 C8 lda $AF,x ; $087F: B5 AF sta RoundHudCommandAddressLo ; $0881: 85 58 ;=============================================================================== ; AppendRoundHudValue ; ; Global: ; Appends one HUD value to the PPU command buffer. ; ; Local: ; Stores the current value as a one-byte command payload and invokes the common PPU-buffer append routine. ; ; Parameters: ; A = HUD value; $57-$59 describe the command. ; ; Returns: ; One HUD update command appended. ; ; PRG offsets: $0883-$088A ; CPU range: $C883-$C88A ;=============================================================================== AppendRoundHudValue: lda #$57 ; $0883: A9 57 ldy #$00 ; $0885: A0 00 jmp AppendBytesToPpuBuffer ; $0887: 4C 31 C1 Label_C88A: rts ; $088A: 60 ; Round spawner and sprite lookup tables ;=============================================================================== RoundHudTileTable: .byte $55, $FF, $00, $FF ; $088B: 55 FF 00 FF SpawnFlipYTable: .byte $00, $00, $FF, $FF ; $088F: 00 00 FF FF SpawnFlipXTable: .byte $FF, $00, $00, $FF ; $0893: FF 00 00 FF SpawnXOffsetTable: .byte $10, $10, $F0, $F0 ; $0897: 10 10 F0 F0 SpawnYOffsetTable: .byte $DE, $22, $22, $DE ; $089B: DE 22 22 DE SpawnParameterTable: .byte $60, $70, $80, $90, $A0, $B0 ; $089F: 60 70 80 90 A0 B0 SpawnVelocityYTable: .byte $00, $00, $00, $00, $00, $00 ; $08A5: 00 00 00 00 00 00 SpawnPositionHiTable: .byte $C0, $F0, $20, $50, $80, $B0 ; $08AB: C0 F0 20 50 80 B0 SpawnVelocityXTable: .byte $00, $00, $01, $01, $01, $01 ; $08B1: 00 00 01 01 01 01 ;=============================================================================== ; UpdateRoundObjectSpritesAndPhysics ; ; Global: ; Updates both round-spawned gameplay objects, constructs their three-sprite OAM entries, and advances their state and movement. ; ; Local: ; Walks slots 1 through 0, skips inactive entries, derives OAM coordinates and tiles from lookup tables, advances animation state, performs bounds handling, integrates movement, resolves interactions, and writes OAM. ; ; Parameters: ; Gameplay-object arrays, FrameCounter, and round-spawn lookup tables. ; ; Returns: ; Object state, positions, animation, and OAM entries are updated. ; ; PRG offsets: $08B7-$09B5 ; CPU range: $C8B7-$C9B5 ;=============================================================================== UpdateRoundObjectSpritesAndPhysics: ldx #$01 ; $08B7: A2 01 Label_C8B9: lda GameplayObjectState,x ; $08B9: BD 30 05 bpl Label_C8C1 ; $08BC: 10 03 jmp Label_C9AF ; $08BE: 4C AF C9 Label_C8C1: lda GameplayObjectAuxState,x ; $08C1: BD 44 05 bmi Label_C941 ; $08C4: 30 7B tay ; $08C6: A8 txa ; $08C7: 8A pha ; $08C8: 48 ldx SelectedSpawnIndexCopy ; $08C9: A6 A5 lda RoundSpawnBaseX,x ; $08CB: B5 B2 adc RoundObjectXOffsetTable,y ; $08CD: 79 E5 C9 sta $02E3 ; $08D0: 8D E3 02 sta $02E7 ; $08D3: 8D E7 02 sta $02EB ; $08D6: 8D EB 02 lda RoundSpawnBaseY,x ; $08D9: B5 B5 adc RoundObjectYOffsetTable,y ; $08DB: 79 F5 C9 sta $02E0 ; $08DE: 8D E0 02 adc RoundObjectVerticalSpacingTable,y ; $08E1: 79 05 CA sta $02E4 ; $08E4: 8D E4 02 adc RoundObjectVerticalSpacingTable,y ; $08E7: 79 05 CA sta $02E8 ; $08EA: 8D E8 02 tya ; $08ED: 98 and #$03 ; $08EE: 29 03 tax ; $08F0: AA tya ; $08F1: 98 lsr a ; $08F2: 4A lsr a ; $08F3: 4A tay ; $08F4: A8 lda FrameCounter ; $08F5: A5 19 lsr a ; $08F7: 4A lsr a ; $08F8: 4A bcs Label_C8FF ; $08F9: B0 04 tya ; $08FB: 98 adc #$05 ; $08FC: 69 05 tay ; $08FE: A8 Label_C8FF: lda RoundObjectTileTopTable,y ; $08FF: B9 15 CA sta $02E1 ; $0902: 8D E1 02 lda RoundObjectTileMiddleTable,y ; $0905: B9 1F CA sta $02E5 ; $0908: 8D E5 02 lda RoundObjectTileBottomTable,y ; $090B: B9 29 CA sta $02E9 ; $090E: 8D E9 02 lda RoundObjectAttributeTable,x ; $0911: BD 33 CA sta $02E2 ; $0914: 8D E2 02 sta $02E6 ; $0917: 8D E6 02 sta $02EA ; $091A: 8D EA 02 pla ; $091D: 68 tax ; $091E: AA lda FrameCounter ; $091F: A5 19 and #$07 ; $0921: 29 07 bne Label_C937 ; $0923: D0 12 lda GameplayObjectAuxState,x ; $0925: BD 44 05 clc ; $0928: 18 adc #$04 ; $0929: 69 04 sta GameplayObjectAuxState,x ; $092B: 9D 44 05 cmp #$14 ; $092E: C9 14 bcc Label_C937 ; $0930: 90 05 lda #$FF ; $0932: A9 FF sta GameplayObjectAuxState,x ; $0934: 9D 44 05 Label_C937: lda GameplayObjectAuxState,x ; $0937: BD 44 05 cmp #$10 ; $093A: C9 10 bcs Label_C941 ; $093C: B0 03 jmp Label_C9AF ; $093E: 4C AF C9 Label_C941: jsr IntegrateGameplayObjectPosition ; $0941: 20 B6 C9 lda GameplayObjectPosX,x ; $0944: BD 90 04 cmp #$02 ; $0947: C9 02 bcs Label_C94E ; $0949: B0 03 jsr BounceGameplayObjectY ; $094B: 20 37 CA Label_C94E: lda GameplayObjectPosX,x ; $094E: BD 90 04 cmp #$F7 ; $0951: C9 F7 bcc Label_C958 ; $0953: 90 03 jsr BounceGameplayObjectY ; $0955: 20 37 CA Label_C958: lda GameplayObjectPosY,x ; $0958: BD A4 04 cmp #$02 ; $095B: C9 02 bcs Label_C962 ; $095D: B0 03 jsr BounceGameplayObjectX ; $095F: 20 4F CA Label_C962: lda GameplayObjectPosY,x ; $0962: BD A4 04 cmp #$E0 ; $0965: C9 E0 bcc Label_C976 ; $0967: 90 0D lda #$FF ; $0969: A9 FF sta GameplayObjectState,x ; $096B: 9D 30 05 lda #$F0 ; $096E: A9 F0 sta GameplayObjectPosY,x ; $0970: 9D A4 04 jmp Label_C9AF ; $0973: 4C AF C9 Label_C976: jsr TestGameplayObjectAgainstBounds ; $0976: 20 67 CA jsr ResolveGameplayObjectInteraction ; $0979: 20 1C CB ldy GameplayObjectState,x ; $097C: BC 30 05 iny ; $097F: C8 tya ; $0980: 98 and #$07 ; $0981: 29 07 sta GameplayObjectState,x ; $0983: 9D 30 05 ldy GameplayObjectState,x ; $0986: BC 30 05 lda RoundObjectTileTable,y ; $0989: B9 DD C9 sta CurrentRoundObjectTile ; $098C: 85 12 txa ; $098E: 8A asl a ; $098F: 0A asl a ; $0990: 0A clc ; $0991: 18 tay ; $0992: A8 lda GameplayObjectPosY,x ; $0993: BD A4 04 cmp #$D0 ; $0996: C9 D0 sta OamBuffer,y ; $0998: 99 00 02 lda GameplayObjectPosX,x ; $099B: BD 90 04 sta $0203,y ; $099E: 99 03 02 lda CurrentRoundObjectTile ; $09A1: A5 12 sta $0201,y ; $09A3: 99 01 02 lda #$00 ; $09A6: A9 00 bcc Label_C9AC ; $09A8: 90 02 lda #$20 ; $09AA: A9 20 Label_C9AC: sta $0202,y ; $09AC: 99 02 02 Label_C9AF: dex ; $09AF: CA bmi Label_C9B5 ; $09B0: 30 03 jmp Label_C8B9 ; $09B2: 4C B9 C8 Label_C9B5: rts ; $09B5: 60 ;=============================================================================== ; IntegrateGameplayObjectPosition ; ; Global: ; Applies the gameplay object velocity components to its fixed-point position fields. ; ; Local: ; Adds the fractional and integer components of both axes into the corresponding parallel position arrays. ; ; Parameters: ; X = gameplay-object slot. ; ; Returns: ; Gameplay object X/Y fixed-point positions updated. ; ; PRG offsets: $09B6-$09DC ; CPU range: $C9B6-$C9DC ;=============================================================================== IntegrateGameplayObjectPosition: lda GameplayObjectParameter,x ; $09B6: BD 08 05 clc ; $09B9: 18 adc GameplayObjectVelocityFracY,x ; $09BA: 7D B8 04 sta GameplayObjectVelocityFracY,x ; $09BD: 9D B8 04 lda GameplayObjectVelocityY,x ; $09C0: BD E0 04 adc GameplayObjectPosX,x ; $09C3: 7D 90 04 sta GameplayObjectPosX,x ; $09C6: 9D 90 04 lda GameplayObjectPosXHi,x ; $09C9: BD 1C 05 clc ; $09CC: 18 adc GameplayObjectVelocityIntY,x ; $09CD: 7D CC 04 sta GameplayObjectVelocityIntY,x ; $09D0: 9D CC 04 lda GameplayObjectVelocityX,x ; $09D3: BD F4 04 adc GameplayObjectPosY,x ; $09D6: 7D A4 04 sta GameplayObjectPosY,x ; $09D9: 9D A4 04 rts ; $09DC: 60 ; Round-object sprite tables ;=============================================================================== RoundObjectTileTable: .byte $9D, $9E, $9F, $9E, $9D, $A0, $A1, $A0 ; $09DD: 9D 9E 9F 9E 9D A0 A1 A0 RoundObjectXOffsetTable: .byte $08, $08, $F0, $F0, $08, $08, $F0, $F0 ; $09E5: 08 08 F0 F0 08 08 F0 F0 .byte $08, $08, $F0, $F0, $08, $08, $F0, $F0 ; $09ED: 08 08 F0 F0 08 08 F0 F0 RoundObjectYOffsetTable: .byte $EE, $0A, $0A, $EE, $EE, $0A, $0A, $EE ; $09F5: EE 0A 0A EE EE 0A 0A EE .byte $EE, $0A, $0A, $EE, $EE, $0A, $0A, $EE ; $09FD: EE 0A 0A EE EE 0A 0A EE RoundObjectVerticalSpacingTable: .byte $F8, $08, $08, $F8, $F8, $08, $08, $F8 ; $0A05: F8 08 08 F8 F8 08 08 F8 .byte $F8, $08, $08, $F8, $F8, $08, $08, $F8 ; $0A0D: F8 08 08 F8 F8 08 08 F8 RoundObjectTileTopTable: .byte $91, $93, $97, $97, $FC, $92, $95, $9A ; $0A15: 91 93 97 97 FC 92 95 9A .byte $9A, $FC ; $0A1D: 9A FC RoundObjectTileMiddleTable: .byte $FC, $94, $98, $98, $FC, $FC, $96, $9B ; $0A1F: FC 94 98 98 FC FC 96 9B .byte $9B, $FC ; $0A27: 9B FC RoundObjectTileBottomTable: .byte $FC, $FC, $99, $99, $FC, $FC, $FC, $9C ; $0A29: FC FC 99 99 FC FC FC 9C .byte $9C, $FC ; $0A31: 9C FC RoundObjectAttributeTable: .byte $C0, $40, $00, $80 ; $0A33: C0 40 00 80 ;=============================================================================== ; NegateGameplayObjectVelocityY ; ; Global: ; Sets the sound/event request flag and negates one fixed-point gameplay-object velocity pair. ; ; Local: ; Sets bit $80 in SoundRequestFlags3, then two’s-complements GameplayObjectParameter and GameplayObjectVelocityY. ; ; Parameters: ; X = gameplay-object slot. ; ; Returns: ; The selected velocity pair is negated. ; ; PRG offsets: $0A37-$0A4E ; CPU range: $CA37-$CA4E ;=============================================================================== BounceGameplayObjectY: lda SoundRequestFlags3 ; $0A37: A5 F3 ora #$80 ; $0A39: 09 80 sta SoundRequestFlags3 ; $0A3B: 85 F3 NegateGameplayObjectVelocityY: lda #$00 ; $0A3D: A9 00 sec ; $0A3F: 38 sbc GameplayObjectParameter,x ; $0A40: FD 08 05 sta GameplayObjectParameter,x ; $0A43: 9D 08 05 lda #$00 ; $0A46: A9 00 sbc GameplayObjectVelocityY,x ; $0A48: FD E0 04 sta GameplayObjectVelocityY,x ; $0A4B: 9D E0 04 rts ; $0A4E: 60 ;=============================================================================== ; NegateGameplayObjectVelocityX ; ; Global: ; Sets the sound/event request flag and negates the other fixed-point gameplay-object velocity pair. ; ; Local: ; Sets bit $80 in SoundRequestFlags3, then two’s-complements GameplayObjectPosXHi and GameplayObjectVelocityX. ; ; Parameters: ; X = gameplay-object slot. ; ; Returns: ; The selected velocity pair is negated. ; ; PRG offsets: $0A4F-$0A66 ; CPU range: $CA4F-$CA66 ;=============================================================================== BounceGameplayObjectX: lda SoundRequestFlags3 ; $0A4F: A5 F3 ora #$80 ; $0A51: 09 80 sta SoundRequestFlags3 ; $0A53: 85 F3 NegateGameplayObjectVelocityX: lda #$00 ; $0A55: A9 00 sec ; $0A57: 38 sbc GameplayObjectPosXHi,x ; $0A58: FD 1C 05 sta GameplayObjectPosXHi,x ; $0A5B: 9D 1C 05 lda #$00 ; $0A5E: A9 00 sbc GameplayObjectVelocityX,x ; $0A60: FD F4 04 sta GameplayObjectVelocityX,x ; $0A63: 9D F4 04 rts ; $0A66: 60 ;=============================================================================== ; TestGameplayObjectAgainstBounds ; ; Global: ; Tests one gameplay object against a table-driven set of rectangular boundaries. ; ; Local: ; Walks boundary candidate records through four zero-page pointers, accumulates directional overlap flags, and reflects velocity components according to the collision side. ; ; Parameters: ; X = gameplay-object slot; BoundsCandidateIndex and four boundary-table pointers. ; ; Returns: ; GameplayObjectCollisionFlags contains overlap sides; velocity components may be negated. ; ; PRG offsets: $0A67-$0B1A ; CPU range: $CA67-$CB1A ;=============================================================================== TestGameplayObjectAgainstBounds: ldy BoundsCandidateIndex ; $0A67: A4 CD Label_CA69: lda #$00 ; $0A69: A9 00 sta GameplayObjectCollisionFlags ; $0A6B: 85 CC lda (BoundsTopPtrLo),y ; $0A6D: B1 27 sec ; $0A6F: 38 sbc #$08 ; $0A70: E9 08 cmp GameplayObjectPosY,x ; $0A72: DD A4 04 bcs Label_CADD ; $0A75: B0 66 adc #$03 ; $0A77: 69 03 cmp GameplayObjectPosY,x ; $0A79: DD A4 04 bcc Label_CA82 ; $0A7C: 90 04 lda #$01 ; $0A7E: A9 01 bne Label_CA92 ; $0A80: D0 10 Label_CA82: lda (BoundsBottomPtrLo),y ; $0A82: B1 29 cmp GameplayObjectPosY,x ; $0A84: DD A4 04 bcc Label_CADD ; $0A87: 90 54 sbc #$03 ; $0A89: E9 03 cmp GameplayObjectPosY,x ; $0A8B: DD A4 04 bcs Label_CAAD ; $0A8E: B0 1D lda #$02 ; $0A90: A9 02 Label_CA92: sta GameplayObjectCollisionFlags ; $0A92: 85 CC lda (BoundsLeftPtrLo),y ; $0A94: B1 23 cmp #$10 ; $0A96: C9 10 beq Label_CAA2 ; $0A98: F0 08 sec ; $0A9A: 38 sbc #$04 ; $0A9B: E9 04 cmp GameplayObjectPosX,x ; $0A9D: DD 90 04 bcs Label_CAA9 ; $0AA0: B0 07 Label_CAA2: lda (BoundsRightPtrLo),y ; $0AA2: B1 25 cmp GameplayObjectPosX,x ; $0AA4: DD 90 04 bcs Label_CAAD ; $0AA7: B0 04 Label_CAA9: lda #$00 ; $0AA9: A9 00 sta GameplayObjectCollisionFlags ; $0AAB: 85 CC Label_CAAD: lda (BoundsLeftPtrLo),y ; $0AAD: B1 23 cmp #$10 ; $0AAF: C9 10 beq Label_CAC8 ; $0AB1: F0 15 sec ; $0AB3: 38 sbc #$08 ; $0AB4: E9 08 cmp GameplayObjectPosX,x ; $0AB6: DD 90 04 bcs Label_CADD ; $0AB9: B0 22 adc #$03 ; $0ABB: 69 03 cmp GameplayObjectPosX,x ; $0ABD: DD 90 04 bcc Label_CAC8 ; $0AC0: 90 06 lda GameplayObjectCollisionFlags ; $0AC2: A5 CC ora #$04 ; $0AC4: 09 04 bne Label_CADB ; $0AC6: D0 13 Label_CAC8: lda (BoundsRightPtrLo),y ; $0AC8: B1 25 cmp #$FF ; $0ACA: C9 FF beq Label_CADD ; $0ACC: F0 0F cmp GameplayObjectPosX,x ; $0ACE: DD 90 04 bcc Label_CADD ; $0AD1: 90 0A sbc #$03 ; $0AD3: E9 03 bcs Label_CADD ; $0AD5: B0 06 lda GameplayObjectCollisionFlags ; $0AD7: A5 CC ora #$08 ; $0AD9: 09 08 Label_CADB: sta GameplayObjectCollisionFlags ; $0ADB: 85 CC Label_CADD: lda GameplayObjectCollisionFlags ; $0ADD: A5 CC bne Label_CAE8 ; $0ADF: D0 07 Label_CAE1: dey ; $0AE1: 88 bmi Label_CAE7 ; $0AE2: 30 03 jmp Label_CA69 ; $0AE4: 4C 69 CA Label_CAE7: rts ; $0AE7: 60 Label_CAE8: lsr GameplayObjectCollisionFlags ; $0AE8: 46 CC bcc Label_CAF4 ; $0AEA: 90 08 lda GameplayObjectVelocityX,x ; $0AEC: BD F4 04 bmi Label_CAF4 ; $0AEF: 30 03 jsr BounceGameplayObjectX ; $0AF1: 20 4F CA Label_CAF4: lsr GameplayObjectCollisionFlags ; $0AF4: 46 CC bcc Label_CB00 ; $0AF6: 90 08 lda GameplayObjectVelocityX,x ; $0AF8: BD F4 04 bpl Label_CB00 ; $0AFB: 10 03 jsr BounceGameplayObjectX ; $0AFD: 20 4F CA Label_CB00: lsr GameplayObjectCollisionFlags ; $0B00: 46 CC bcc Label_CB0C ; $0B02: 90 08 lda GameplayObjectVelocityY,x ; $0B04: BD E0 04 bmi Label_CB0C ; $0B07: 30 03 jsr BounceGameplayObjectY ; $0B09: 20 37 CA Label_CB0C: lsr GameplayObjectCollisionFlags ; $0B0C: 46 CC bcc Label_CB18 ; $0B0E: 90 08 lda GameplayObjectVelocityY,x ; $0B10: BD E0 04 bpl Label_CB18 ; $0B13: 10 03 jsr BounceGameplayObjectY ; $0B15: 20 37 CA Label_CB18: jmp Label_CAE1 ; $0B18: 4C E1 CA ; $0B1B: RTS terminating TestGameplayObjectAgainstBounds. rts ; $0B1B: 60 ;=============================================================================== ; ResolveGameplayObjectInteraction ; ; Global: ; Tests the current gameplay object against active player slots and handles a successful hit. ; ; Local: ; Compares object and player coordinates, transitions the player into a hit state, updates animation/timers and sound flags, then removes the gameplay object. ; ; Parameters: ; X = gameplay-object slot. ; ; Returns: ; Player and gameplay-object state may be changed. ; ; PRG offsets: $0B1C-$0B73 ; CPU range: $CB1C-$CB73 ;=============================================================================== ResolveGameplayObjectInteraction: ldy #$01 ; $0B1C: A0 01 Label_CB1E: lda $0088,y ; $0B1E: B9 88 00 bmi Label_CB70 ; $0B21: 30 4D beq Label_CB70 ; $0B23: F0 4B lda $00BD,y ; $0B25: B9 BD 00 bne Label_CB70 ; $0B28: D0 46 lda GameplayObjectPosX,x ; $0B2A: BD 90 04 sec ; $0B2D: 38 sbc $0091,y ; $0B2E: F9 91 00 jsr AbsoluteDifference ; $0B31: 20 8E F0 cmp #$08 ; $0B34: C9 08 bcs Label_CB70 ; $0B36: B0 38 lda GameplayObjectPosY,x ; $0B38: BD A4 04 sec ; $0B3B: 38 sbc $009A,y ; $0B3C: F9 9A 00 sec ; $0B3F: 38 sbc #$08 ; $0B40: E9 08 jsr AbsoluteDifference ; $0B42: 20 8E F0 cmp #$0C ; $0B45: C9 0C bcs Label_CB70 ; $0B47: B0 27 lda #$00 ; $0B49: A9 00 sta $0088,y ; $0B4B: 99 88 00 lda #$01 ; $0B4E: A9 01 sta $007F,y ; $0B50: 99 7F 00 sta $00C1,y ; $0B53: 99 C1 00 lda #$0B ; $0B56: A9 0B sta PlayerAnimationState,y ; $0B58: 99 51 04 lda #$20 ; $0B5B: A9 20 sta PlayerStateTimer,y ; $0B5D: 99 5A 04 lda SoundRequestFlags0 ; $0B60: A5 F0 ora #$80 ; $0B62: 09 80 sta SoundRequestFlags0 ; $0B64: 85 F0 lda #$F0 ; $0B66: A9 F0 sta GameplayObjectPosY,x ; $0B68: 9D A4 04 lda #$FF ; $0B6B: A9 FF sta GameplayObjectState,x ; $0B6D: 9D 30 05 Label_CB70: dey ; $0B70: 88 bpl Label_CB1E ; $0B71: 10 AB rts ; $0B73: 60 ;=============================================================================== ; UpdateBonusObjectSystem ; ; Global: ; Advances the active bonus-object subsystem. ; ; Local: ; Finds the active object, performs frame-gated phase/timer updates, tests player overlap, and advances object phases. ; ; Parameters: ; Bonus object arrays and FrameCounter. ; ; Returns: ; Bonus object state and player effects may be updated. ; ; PRG offsets: $0B74-$0BA7 ; CPU range: $CB74-$CBA7 ;=============================================================================== UpdateBonusObjectSystem: ldx ActiveBonusObjectIndex ; $0B74: AE D1 05 bmi Label_CBA7 ; $0B77: 30 2E Label_CB79: jsr FindActiveBonusObject ; $0B79: 20 A8 CB lda BonusObjectTimer,x ; $0B7C: BD 04 06 beq Label_CBA4 ; $0B7F: F0 23 txa ; $0B81: 8A eor FrameCounter ; $0B82: 45 19 and #$01 ; $0B84: 29 01 bne Label_CBA4 ; $0B86: D0 1C ldy BonusObjectPhase,x ; $0B88: BC FA 05 iny ; $0B8B: C8 tya ; $0B8C: 98 and #$03 ; $0B8D: 29 03 sta BonusObjectPhase,x ; $0B8F: 9D FA 05 jsr DrawBonusObjectHud ; $0B92: 20 CB CC lda BonusObjectPhase,x ; $0B95: BD FA 05 cmp #$01 ; $0B98: C9 01 bne Label_CBA4 ; $0B9A: D0 08 dec BonusObjectPhaseTimer,x ; $0B9C: DE 0E 06 bne Label_CBA4 ; $0B9F: D0 03 dec BonusObjectTimer,x ; $0BA1: DE 04 06 Label_CBA4: dex ; $0BA4: CA bpl Label_CB79 ; $0BA5: 10 D2 Label_CBA7: rts ; $0BA7: 60 ;=============================================================================== ; FindActiveBonusObject ; ; Global: ; Returns whether the selected bonus-object slot is active. ; ; Local: ; Loads the slot timer/state and returns through the caller path. ; ; Parameters: ; X = bonus-object slot. ; ; Returns: ; Condition codes and A reflect slot activity. ; ; PRG offsets: $0BA8-$0BB1 ; CPU range: $CBA8-$CBB1 ;=============================================================================== FindActiveBonusObject: ldy #$07 ; $0BA8: A0 07 lda BonusObjectTimer,x ; $0BAA: BD 04 06 bne TestBonusObjectPlayerOverlap ; $0BAD: D0 03 jmp TestBonusObjectCollection ; $0BAF: 4C 3A CC ;=============================================================================== ; TestBonusObjectPlayerOverlap ; ; Global: ; Tests a bonus object against each active player and applies directional impulses. ; ; Local: ; Computes absolute X/Y deltas, checks overlap thresholds, sets player impulse fields, requests sound, and continues through all players. ; ; Parameters: ; X = bonus-object slot; Y iterates player slots. ; ; Returns: ; Player motion state and sound flags may be updated. ; ; PRG offsets: $0BB2-$0C32 ; CPU range: $CBB2-$CC32 ;=============================================================================== TestBonusObjectPlayerOverlap: lda $0088,y ; $0BB2: B9 88 00 bmi Label_CC2F ; $0BB5: 30 78 beq Label_CC2F ; $0BB7: F0 76 cpy #$02 ; $0BB9: C0 02 bcc Label_CBC1 ; $0BBB: 90 04 cmp #$01 ; $0BBD: C9 01 beq Label_CC2F ; $0BBF: F0 6E Label_CBC1: lda $0091,y ; $0BC1: B9 91 00 clc ; $0BC4: 18 adc #$08 ; $0BC5: 69 08 sec ; $0BC7: 38 sbc BonusObjectPosX,x ; $0BC8: FD D2 05 sta CollisionDeltaX ; $0BCB: 85 12 jsr AbsoluteDifference ; $0BCD: 20 8E F0 cmp #$12 ; $0BD0: C9 12 bcs Label_CC2F ; $0BD2: B0 5B lda $009A,y ; $0BD4: B9 9A 00 clc ; $0BD7: 18 adc #$0C ; $0BD8: 69 0C sec ; $0BDA: 38 sbc BonusObjectPosY,x ; $0BDB: FD DC 05 sta CollisionDeltaY ; $0BDE: 85 13 jsr AbsoluteDifference ; $0BE0: 20 8E F0 cmp #$12 ; $0BE3: C9 12 bcs Label_CC2F ; $0BE5: B0 48 lda CollisionDeltaX ; $0BE7: A5 12 bmi Label_CBFC ; $0BE9: 30 11 cmp #$03 ; $0BEB: C9 03 bcc Label_CC0B ; $0BED: 90 1C lda #$02 ; $0BEF: A9 02 sta PlayerHorizontalImpulse,y ; $0BF1: 99 1B 04 jsr RequestCollisionSound ; $0BF4: 20 33 CC jsr AdjustPlayerVerticalState ; $0BF7: 20 BB EB bne Label_CC0B ; $0BFA: D0 0F Label_CBFC: cmp #$FD ; $0BFC: C9 FD bcs Label_CC0B ; $0BFE: B0 0B lda #$FE ; $0C00: A9 FE sta PlayerHorizontalImpulse,y ; $0C02: 99 1B 04 jsr AdjustPlayerVerticalState ; $0C05: 20 BB EB jsr RequestCollisionSound ; $0C08: 20 33 CC Label_CC0B: lda CollisionDeltaY ; $0C0B: A5 13 bmi Label_CC20 ; $0C0D: 30 11 cmp #$03 ; $0C0F: C9 03 bcc Label_CC2F ; $0C11: 90 1C lda #$02 ; $0C13: A9 02 sta PlayerVerticalImpulse,y ; $0C15: 99 2D 04 jsr AdjustPlayerHorizontalState ; $0C18: 20 B2 EB jsr RequestCollisionSound ; $0C1B: 20 33 CC bne Label_CC2F ; $0C1E: D0 0F Label_CC20: cmp #$FD ; $0C20: C9 FD bcs Label_CC2F ; $0C22: B0 0B lda #$FE ; $0C24: A9 FE sta PlayerVerticalImpulse,y ; $0C26: 99 2D 04 jsr AdjustPlayerHorizontalState ; $0C29: 20 B2 EB jsr RequestCollisionSound ; $0C2C: 20 33 CC Label_CC2F: dey ; $0C2F: 88 bpl TestBonusObjectPlayerOverlap ; $0C30: 10 80 rts ; $0C32: 60 ;=============================================================================== ; RequestCollisionSound ; ; Global: ; Queues the collision sound effect. ; ; Local: ; Sets bit $02 in SoundRequestFlags1. ; ; Parameters: ; None. ; ; Returns: ; Sound request flag updated. ; ; PRG offsets: $0C33-$0C39 ; CPU range: $CC33-$CC39 ;=============================================================================== RequestCollisionSound: lda SoundRequestFlags1 ; $0C33: A5 F1 ora #$02 ; $0C35: 09 02 sta SoundRequestFlags1 ; $0C37: 85 F1 rts ; $0C39: 60 ;=============================================================================== ; TestBonusObjectCollection ; ; Global: ; Tests a bonus object against players for collection or activation. ; ; Local: ; Checks phase-dependent rectangular overlap and starts the bonus-object timer when collected. ; ; Parameters: ; X = bonus-object slot; Y iterates players. ; ; Returns: ; Bonus object phase/timer may be changed. ; ; PRG offsets: $0C3A-$0CBE ; CPU range: $CC3A-$CCBE ;=============================================================================== TestBonusObjectCollection: lda $0088,y ; $0C3A: B9 88 00 bmi Label_CCB8 ; $0C3D: 30 79 beq Label_CCB8 ; $0C3F: F0 77 cpy #$02 ; $0C41: C0 02 bcc Label_CC73 ; $0C43: 90 2E lda BonusObjectPhase,x ; $0C45: BD FA 05 cmp #$03 ; $0C48: C9 03 bne Label_CC73 ; $0C4A: D0 27 lda BonusObjectPosX,x ; $0C4C: BD D2 05 sec ; $0C4F: 38 sbc #$0A ; $0C50: E9 0A cmp $0091,y ; $0C52: D9 91 00 bcs Label_CC73 ; $0C55: B0 1C adc #$04 ; $0C57: 69 04 cmp $0091,y ; $0C59: D9 91 00 bcc Label_CC73 ; $0C5C: 90 15 lda BonusObjectPosY,x ; $0C5E: BD DC 05 sec ; $0C61: 38 sbc #$1C ; $0C62: E9 1C cmp $009A,y ; $0C64: D9 9A 00 bcs Label_CC73 ; $0C67: B0 0A adc #$04 ; $0C69: 69 04 cmp $009A,y ; $0C6B: D9 9A 00 bcc Label_CC73 ; $0C6E: 90 03 jsr TriggerBonusObjectEffect ; $0C70: 20 BF CC Label_CC73: lda $0091,y ; $0C73: B9 91 00 clc ; $0C76: 18 adc #$08 ; $0C77: 69 08 sec ; $0C79: 38 sbc BonusObjectPosX,x ; $0C7A: FD D2 05 jsr AbsoluteDifference ; $0C7D: 20 8E F0 sta CollisionDeltaX ; $0C80: 85 12 lda $009A,y ; $0C82: B9 9A 00 clc ; $0C85: 18 adc #$0C ; $0C86: 69 0C sec ; $0C88: 38 sbc BonusObjectPosY,x ; $0C89: FD DC 05 jsr AbsoluteDifference ; $0C8C: 20 8E F0 sta CollisionDeltaY ; $0C8F: 85 13 lda BonusObjectPhase,x ; $0C91: BD FA 05 cmp #$03 ; $0C94: C9 03 beq Label_CCA2 ; $0C96: F0 0A lda CollisionDeltaX ; $0C98: A5 12 pha ; $0C9A: 48 lda CollisionDeltaY ; $0C9B: A5 13 sta CollisionDeltaX ; $0C9D: 85 12 pla ; $0C9F: 68 sta CollisionDeltaY ; $0CA0: 85 13 Label_CCA2: lda CollisionDeltaX ; $0CA2: A5 12 cmp #$14 ; $0CA4: C9 14 bcs Label_CCB8 ; $0CA6: B0 10 lda CollisionDeltaY ; $0CA8: A5 13 cmp #$0B ; $0CAA: C9 0B bcs Label_CCB8 ; $0CAC: B0 0A lda #$01 ; $0CAE: A9 01 sta BonusObjectTimer,x ; $0CB0: 9D 04 06 lda #$32 ; $0CB3: A9 32 sta BonusObjectPhaseTimer,x ; $0CB5: 9D 0E 06 Label_CCB8: dey ; $0CB8: 88 bmi Label_CCBE ; $0CB9: 30 03 jmp TestBonusObjectCollection ; $0CBB: 4C 3A CC Label_CCBE: rts ; $0CBE: 60 ;=============================================================================== ; TriggerBonusObjectEffect ; ; Global: ; Invokes the bonus effect using the collecting player as context. ; ; Local: ; Preserves the bonus slot, moves the player index into X, increments the effect count, and calls the effect routine. ; ; Parameters: ; X = bonus-object slot; Y = player slot. ; ; Returns: ; Bonus effect counter and player state updated. ; ; PRG offsets: $0CBF-$0CCA ; CPU range: $CCBF-$CCCA ;=============================================================================== TriggerBonusObjectEffect: txa ; $0CBF: 8A pha ; $0CC0: 48 tya ; $0CC1: 98 tax ; $0CC2: AA inc BonusEffectCounter ; $0CC3: E6 CB jsr ApplyBonusEffect ; $0CC5: 20 83 E9 pla ; $0CC8: 68 tax ; $0CC9: AA rts ; $0CCA: 60 ;=============================================================================== ; DrawBonusObjectHud ; ; Global: ; Builds three HUD tile commands for the active bonus object. ; ; Local: ; Loads command address bytes, selects three triplets of tiles from phase tables, appends each command, and advances the PPU destination. ; ; Parameters: ; X = bonus-object slot. ; ; Returns: ; Three HUD command groups appended. ; ; PRG offsets: $0CCB-$0D0E ; CPU range: $CCCB-$CD0E ;=============================================================================== DrawBonusObjectHud: lda BonusHudAddressHi,x ; $0CCB: BD F0 05 sta HudCommandAddressHi ; $0CCE: 85 57 lda BonusHudAddressLo,x ; $0CD0: BD E6 05 sta HudCommandAddressLo ; $0CD3: 85 58 lda #$03 ; $0CD5: A9 03 sta HudCommandLength ; $0CD7: 85 59 ldy BonusObjectPhase,x ; $0CD9: BC FA 05 lda BonusHudRow0Tile0Table,y ; $0CDC: B9 26 CD sta HudCommandTile0 ; $0CDF: 85 5A lda BonusHudRow0Tile1Table,y ; $0CE1: B9 2A CD sta HudCommandTile1 ; $0CE4: 85 5B lda BonusHudRow0Tile2Table,y ; $0CE6: B9 2E CD sta HudCommandTile2 ; $0CE9: 85 5C jsr AdvanceHudCommandAddress ; $0CEB: 20 0F CD lda BonusHudRow1Tile0Table,y ; $0CEE: B9 32 CD sta HudCommandTile0 ; $0CF1: 85 5A lda BonusHudRow1Tile1Table,y ; $0CF3: B9 36 CD sta HudCommandTile1 ; $0CF6: 85 5B lda BonusHudRow1Tile2Table,y ; $0CF8: B9 3A CD sta HudCommandTile2 ; $0CFB: 85 5C jsr AdvanceHudCommandAddress ; $0CFD: 20 0F CD lda BonusHudRow2Tile0Table,y ; $0D00: B9 3E CD sta HudCommandTile0 ; $0D03: 85 5A lda BonusHudRow2Tile1Table,y ; $0D05: B9 42 CD sta HudCommandTile1 ; $0D08: 85 5B lda BonusHudRow2Tile2Table,y ; $0D0A: B9 46 CD sta HudCommandTile2 ; $0D0D: 85 5C ;=============================================================================== ; AdvanceHudCommandAddress ; ; Global: ; Appends one three-byte HUD tile group and advances the destination by $20. ; ; Local: ; Preserves Y, appends the command block at $57, advances the low address byte, and carries into the high byte. ; ; Parameters: ; Y = phase/table index; $57-$5C = command. ; ; Returns: ; HUD command appended and destination advanced. ; ; PRG offsets: $0D0F-$0D25 ; CPU range: $CD0F-$CD25 ;=============================================================================== AdvanceHudCommandAddress: tya ; $0D0F: 98 pha ; $0D10: 48 lda #$57 ; $0D11: A9 57 ldy #$00 ; $0D13: A0 00 jsr $C131 ; $0D15: 20 31 C1 pla ; $0D18: 68 tay ; $0D19: A8 lda HudCommandAddressLo ; $0D1A: A5 58 clc ; $0D1C: 18 adc #$20 ; $0D1D: 69 20 sta HudCommandAddressLo ; $0D1F: 85 58 bcc Label_CD25 ; $0D21: 90 02 inc HudCommandAddressHi ; $0D23: E6 57 Label_CD25: rts ; $0D25: 60 ; Bonus-object HUD tile triplets ; ; Each four-byte table is indexed by BonusObjectPhase ($00-$03). The three ; tables in each group supply HudCommandTile0, HudCommandTile1, and ; HudCommandTile2 for one of the three vertically separated HUD commands. ; ; PRG offsets: $0D26-$0D49 ; CPU range: $CD26-$CD49 ;=============================================================================== BonusHudRow0Tile0Table: .byte $A1, $24, $24, $24 ; $0D26: A1 24 24 24 BonusHudRow0Tile1Table: .byte $A2, $9E, $AB, $24 ; $0D2A: A2 9E AB 24 BonusHudRow0Tile2Table: .byte $24, $24, $AC, $24 ; $0D2E: 24 24 AC 24 BonusHudRow1Tile0Table: .byte $A3, $24, $AD, $A8 ; $0D32: A3 24 AD A8 BonusHudRow1Tile1Table: .byte $A4, $9F, $AE, $A9 ; $0D36: A4 9F AE A9 BonusHudRow1Tile2Table: .byte $A5, $24, $AF, $AA ; $0D3A: A5 24 AF AA BonusHudRow2Tile0Table: .byte $24, $24, $B0, $24 ; $0D3E: 24 24 B0 24 BonusHudRow2Tile1Table: .byte $A6, $A0, $B1, $24 ; $0D42: A6 A0 B1 24 BonusHudRow2Tile2Table: .byte $A7, $24, $24, $24 ; $0D46: A7 24 24 24 ;=============================================================================== ; InitializeParticleSlots ; ; Global: ; Initializes the ten-slot particle/effect pool. ; ; Local: ; Marks each slot inactive and places its Y coordinate offscreen. ; ; Parameters: ; None. ; ; Returns: ; Particle slots 0-9 are inactive and hidden. ; ; PRG offsets: $0D4A-$0D59 ; CPU range: $CD4A-$CD59 ;=============================================================================== InitializeParticleSlots: ldx #$09 ; $0D4A: A2 09 Label_CD4C: lda #$FF ; $0D4C: A9 FF sta ParticleState,x ; $0D4E: 9D 5D 05 lda #$F0 ; $0D51: A9 F0 sta ParticlePosY,x ; $0D53: 9D 7B 05 dex ; $0D56: CA bpl Label_CD4C ; $0D57: 10 F3 rts ; $0D59: 60 ;=============================================================================== ; SpawnTimedParticle ; ; Global: ; Counts down the shared spawn timer and initializes one free particle slot when it expires. ; ; Local: ; Reloads the timer from pseudo-random state, finds a free slot, clears motion accumulators, assigns initial position and velocity, and decrements the remaining spawn count. ; ; Parameters: ; ParticleSpawnCountdown and remaining count at $05CB. ; ; Returns: ; One particle may be activated; spawn counters are updated. ; ; PRG offsets: $0D5A-$0DA9 ; CPU range: $CD5A-$CDA9 ;=============================================================================== SpawnTimedParticle: dec ParticleSpawnCountdown ; $0D5A: CE CC 05 beq Label_CD60 ; $0D5D: F0 01 rts ; $0D5F: 60 Label_CD60: lda RandomState ; $0D60: A5 1B and #$3F ; $0D62: 29 3F adc #$28 ; $0D64: 69 28 sta ParticleSpawnCountdown ; $0D66: 8D CC 05 ldx #$09 ; $0D69: A2 09 Label_CD6B: lda ParticleState,x ; $0D6B: BD 5D 05 bmi Label_CD74 ; $0D6E: 30 04 dex ; $0D70: CA bpl Label_CD6B ; $0D71: 10 F8 rts ; $0D73: 60 Label_CD74: lda #$00 ; $0D74: A9 00 sta ParticleState,x ; $0D76: 9D 5D 05 sta ParticleVelocityXLo,x ; $0D79: 9D 99 05 sta ParticleVelocityXHi,x ; $0D7C: 9D 8F 05 lda #$80 ; $0D7F: A9 80 sta ParticlePosXFrac,x ; $0D81: 9D 71 05 sta ParticlePosYFrac,x ; $0D84: 9D 85 05 lda #$D0 ; $0D87: A9 D0 sta ParticlePosY,x ; $0D89: 9D 7B 05 jsr GetRandomValue ; $0D8C: 20 B3 F1 and #$03 ; $0D8F: 29 03 tay ; $0D91: A8 lda ParticleInitialVelocityTable,y ; $0D92: B9 AE CE sta ParticlePosX,x ; $0D95: 9D 67 05 ldy #$00 ; $0D98: A0 00 lda RandomState ; $0D9A: A5 1B sta ParticleVelocityYLo,x ; $0D9C: 9D B7 05 bpl Label_CDA2 ; $0D9F: 10 01 dey ; $0DA1: 88 Label_CDA2: tya ; $0DA2: 98 sta ParticleVelocityYHi,x ; $0DA3: 9D C1 05 dec ParticleSpawnRemaining ; $0DA6: CE CB 05 rts ; $0DA9: 60 ;=============================================================================== ; UpdateParticleSystem ; ; Global: ; Updates all ten particle slots for the current frame. ; ; Local: ; For each active slot, integrates signed X/Y motion, applies scrolling, retires particles outside the visible range, draws sprites, and tests player overlap. ; ; Parameters: ; Particle arrays, ParticleScrollDelta, and FrameCounter. ; ; Returns: ; Particle positions, states, OAM, and player interactions are updated. ; ; PRG offsets: $0DAA-$0E2E ; CPU range: $CDAA-$CE2E ;=============================================================================== UpdateParticleSystem: ldx #$09 ; $0DAA: A2 09 Label_CDAC: lda ParticleState,x ; $0DAC: BD 5D 05 bmi Label_CE22 ; $0DAF: 30 71 beq Label_CDFC ; $0DB1: F0 49 lda ParticleVelocityXLo,x ; $0DB3: BD 99 05 sta MotionDeltaLo ; $0DB6: 85 12 lda ParticleVelocityXHi,x ; $0DB8: BD 8F 05 sta MotionDeltaHi ; $0DBB: 85 13 jsr UpdateSignedMotionAccumulator ; $0DBD: 20 A6 F1 lda ParticleVelocityYLo,x ; $0DC0: BD B7 05 clc ; $0DC3: 18 adc MotionDeltaLo ; $0DC4: 65 12 sta ParticleVelocityYLo,x ; $0DC6: 9D B7 05 sta MotionDeltaLo ; $0DC9: 85 12 lda ParticleVelocityYHi,x ; $0DCB: BD C1 05 adc MotionDeltaHi ; $0DCE: 65 13 sta ParticleVelocityYHi,x ; $0DD0: 9D C1 05 sta MotionDeltaHi ; $0DD3: 85 13 jsr UpdateSignedMotionAccumulator ; $0DD5: 20 A6 F1 lda ParticleVelocityXLo,x ; $0DD8: BD 99 05 sec ; $0DDB: 38 sbc MotionDeltaLo ; $0DDC: E5 12 sta ParticleVelocityXLo,x ; $0DDE: 9D 99 05 lda ParticleVelocityXHi,x ; $0DE1: BD 8F 05 sbc MotionDeltaHi ; $0DE4: E5 13 sta ParticleVelocityXHi,x ; $0DE6: 9D 8F 05 lda ParticlePosXFrac,x ; $0DE9: BD 71 05 clc ; $0DEC: 18 adc ParticleVelocityXLo,x ; $0DED: 7D 99 05 sta ParticlePosXFrac,x ; $0DF0: 9D 71 05 lda ParticlePosX,x ; $0DF3: BD 67 05 adc ParticleVelocityXHi,x ; $0DF6: 7D 8F 05 sta ParticlePosX,x ; $0DF9: 9D 67 05 Label_CDFC: lda ParticlePosYFrac,x ; $0DFC: BD 85 05 sec ; $0DFF: 38 sbc ParticleScrollDelta ; $0E00: ED 5A 05 sta ParticlePosYFrac,x ; $0E03: 9D 85 05 bcs Label_CE0B ; $0E06: B0 03 dec ParticlePosY,x ; $0E08: DE 7B 05 Label_CE0B: lda ParticlePosY,x ; $0E0B: BD 7B 05 cmp #$F0 ; $0E0E: C9 F0 beq Label_CE1D ; $0E10: F0 0B cmp #$A8 ; $0E12: C9 A8 bcs Label_CE22 ; $0E14: B0 0C lda #$01 ; $0E16: A9 01 sta ParticleState,x ; $0E18: 9D 5D 05 bne Label_CE22 ; $0E1B: D0 05 Label_CE1D: lda #$FF ; $0E1D: A9 FF sta ParticleState,x ; $0E1F: 9D 5D 05 Label_CE22: jsr DrawParticleSprites ; $0E22: 20 2F CE jsr TestParticlePlayerOverlap ; $0E25: 20 CE CE dex ; $0E28: CA bmi Label_CE2E ; $0E29: 30 03 jmp Label_CDAC ; $0E2B: 4C AC CD Label_CE2E: rts ; $0E2E: 60 ;=============================================================================== ; DrawParticleSprites ; ; Global: ; Builds the three-sprite OAM representation for one particle slot. ; ; Local: ; Selects the attribute and animation frame from state/timing tables, writes three adjacent sprites, and hides inactive particles. ; ; Parameters: ; X = particle slot. ; ; Returns: ; OAM entries for the selected particle are written. ; ; PRG offsets: $0E2F-$0EAD ; CPU range: $CE2F-$CEAD ;=============================================================================== DrawParticleSprites: ldy ParticleState,x ; $0E2F: BC 5D 05 iny ; $0E32: C8 lda ParticleAttributeTable,y ; $0E33: B9 B2 CE sta MotionDeltaHi ; $0E36: 85 13 txa ; $0E38: 8A sta MotionDeltaLo ; $0E39: 85 12 asl a ; $0E3B: 0A adc MotionDeltaLo ; $0E3C: 65 12 asl a ; $0E3E: 0A asl a ; $0E3F: 0A tay ; $0E40: A8 lda ParticlePosY,x ; $0E41: BD 7B 05 sta ParticleOamBase,y ; $0E44: 99 50 02 sta $0254,y ; $0E47: 99 54 02 clc ; $0E4A: 18 adc #$08 ; $0E4B: 69 08 sta $0258,y ; $0E4D: 99 58 02 lda ParticlePosX,x ; $0E50: BD 67 05 sta $0253,y ; $0E53: 99 53 02 clc ; $0E56: 18 adc #$04 ; $0E57: 69 04 sta $025B,y ; $0E59: 99 5B 02 clc ; $0E5C: 18 adc #$04 ; $0E5D: 69 04 sta $0257,y ; $0E5F: 99 57 02 lda MotionDeltaHi ; $0E62: A5 13 sta $0252,y ; $0E64: 99 52 02 sta $0256,y ; $0E67: 99 56 02 sta $025A,y ; $0E6A: 99 5A 02 lda ParticleState,x ; $0E6D: BD 5D 05 bmi Label_CE99 ; $0E70: 30 27 lda #$A8 ; $0E72: A9 A8 sta $0251,y ; $0E74: 99 51 02 lda #$A9 ; $0E77: A9 A9 sta $0255,y ; $0E79: 99 55 02 lda FrameCounter ; $0E7C: A5 19 lsr a ; $0E7E: 4A lsr a ; $0E7F: 4A lsr a ; $0E80: 4A lsr a ; $0E81: 4A and #$07 ; $0E82: 29 07 stx MotionDeltaHi ; $0E84: 86 13 tax ; $0E86: AA lda ParticleAnimationTileTable,x ; $0E87: BD B5 CE sta $0259,y ; $0E8A: 99 59 02 lda $025A,y ; $0E8D: B9 5A 02 eor ParticleAnimationAttributeMaskTable,x; $0E90: 5D BD CE sta $025A,y ; $0E93: 99 5A 02 ldx MotionDeltaHi ; $0E96: A6 13 rts ; $0E98: 60 Label_CE99: lda #$F0 ; $0E99: A9 F0 sta ParticlePosY,x ; $0E9B: 9D 7B 05 lda #$AC ; $0E9E: A9 AC sta $0251,y ; $0EA0: 99 51 02 lda #$AD ; $0EA3: A9 AD sta $0255,y ; $0EA5: 99 55 02 lda #$FC ; $0EA8: A9 FC sta $0259,y ; $0EAA: 99 59 02 rts ; $0EAD: 60 ; Particle rendering tables ;=============================================================================== ParticleInitialVelocityTable: .byte $20, $50, $A0, $D0 ; $0EAE: 20 50 A0 D0 ParticleAttributeTable: .byte $02, $22, $02 ; $0EB2: 02 22 02 ParticleAnimationTileTable: .byte $AA, $AB, $AB, $AA, $AA, $AB, $AB, $AA ; $0EB5: AA AB AB AA AA AB AB AA ParticleAnimationAttributeMaskTable: .byte $00, $00, $40, $40, $40, $40, $00, $00 ; $0EBD: 00 00 40 40 40 40 00 00 .byte $FC, $FC, $DF, $FC, $FC, $E0, $E2, $E1 ; $0EC5: FC FC DF FC FC E0 E2 E1 .byte $FC ; $0ECD: FC ;=============================================================================== ; TestParticlePlayerOverlap ; ; Global: ; Tests an active particle against both players and records a hit. ; ; Local: ; Rejects inactive players and particles, checks X/Y distances, retires the particle, increments the player hit counter, and requests a sound. ; ; Parameters: ; X = particle slot. ; ; Returns: ; Particle and player hit state may be updated. ; ; PRG offsets: $0ECE-$0F12 ; CPU range: $CECE-$CF12 ;=============================================================================== TestParticlePlayerOverlap: ldy #$01 ; $0ECE: A0 01 Label_CED0: lda $0088,y ; $0ED0: B9 88 00 bmi Label_CF0F ; $0ED3: 30 3A beq Label_CF0F ; $0ED5: F0 38 lda ParticleState,x ; $0ED7: BD 5D 05 bmi Label_CF12 ; $0EDA: 30 36 lda $009A,y ; $0EDC: B9 9A 00 cmp #$C0 ; $0EDF: C9 C0 bcs Label_CF0F ; $0EE1: B0 2C sec ; $0EE3: 38 sbc ParticlePosY,x ; $0EE4: FD 7B 05 jsr AbsoluteDifference ; $0EE7: 20 8E F0 cmp #$18 ; $0EEA: C9 18 bcs Label_CF0F ; $0EEC: B0 21 lda $0091,y ; $0EEE: B9 91 00 sec ; $0EF1: 38 sbc ParticlePosX,x ; $0EF2: FD 67 05 jsr AbsoluteDifference ; $0EF5: 20 8E F0 cmp #$10 ; $0EF8: C9 10 bcs Label_CF0F ; $0EFA: B0 13 lda #$FF ; $0EFC: A9 FF sta ParticleState,x ; $0EFE: 9D 5D 05 lda PlayerParticleHitCount,y ; $0F01: B9 CD 05 clc ; $0F04: 18 adc #$01 ; $0F05: 69 01 sta PlayerParticleHitCount,y ; $0F07: 99 CD 05 lda #$02 ; $0F0A: A9 02 sta SoundRequestFlags0 ; $0F0C: 85 F0 rts ; $0F0E: 60 Label_CF0F: dey ; $0F0F: 88 bpl Label_CED0 ; $0F10: 10 BE Label_CF12: rts ; $0F12: 60 ;=============================================================================== ; RunParticleBonusSequence ; ; Global: ; Runs the complete particle bonus/transition sequence. ; ; Local: ; Initializes systems, spawns and updates particles until exhausted, presents result screens, positions players, and advances several timed PPU/audio phases. ; ; Parameters: ; Global game and player state. ; ; Returns: ; Sequence completes and returns to the main state flow. ; ; PRG offsets: $0F13-$10E1 ; CPU range: $CF13-$D0E1 ;=============================================================================== RunParticleBonusSequence: lda #$20 ; $0F13: A9 20 sta SoundRequestFlags2 ; $0F15: 85 F2 jsr LoadParticleSequenceData ; $0F17: 20 E2 D0 jsr InitializeParticleSlots ; $0F1A: 20 4A CD ldx PlayerCountMinusOne ; $0F1D: A6 40 Label_CF1F: lda PlayerActiveFlags,x ; $0F1F: B5 41 bmi Label_CF26 ; $0F21: 30 03 jsr $F3B0 ; $0F23: 20 B0 F3 Label_CF26: dex ; $0F26: CA bpl Label_CF1F ; $0F27: 10 F6 ldx #$00 ; $0F29: A2 00 stx PlayerCollisionDisable ; $0F2B: 86 BD stx SequenceState ; $0F2D: 86 BE lda #$14 ; $0F2F: A9 14 sta $05CB ; $0F31: 8D CB 05 Label_CF34: jsr $F470 ; $0F34: 20 70 F4 inc $4C ; $0F37: E6 4C jsr $D8DD ; $0F39: 20 DD D8 jsr $E691 ; $0F3C: 20 91 E6 lda $05CB ; $0F3F: AD CB 05 beq Label_CF47 ; $0F42: F0 03 jsr SpawnTimedParticle ; $0F44: 20 5A CD Label_CF47: jsr UpdateParticleSystem ; $0F47: 20 AA CD lda $05CB ; $0F4A: AD CB 05 bne Label_CF34 ; $0F4D: D0 E5 ldx #$09 ; $0F4F: A2 09 Label_CF51: lda ParticleState,x ; $0F51: BD 5D 05 bpl Label_CF34 ; $0F54: 10 DE dex ; $0F56: CA bpl Label_CF51 ; $0F57: 10 F8 lda FrameCounter ; $0F59: A5 19 bne Label_CF34 ; $0F5B: D0 D7 jsr $D246 ; $0F5D: 20 46 D2 ldx #$02 ; $0F60: A2 02 stx SequenceStep ; $0F62: 86 46 jsr $F45E ; $0F64: 20 5E F4 lda #$2B ; $0F67: A9 2B ldy #$D1 ; $0F69: A0 D1 jsr $C131 ; $0F6B: 20 31 C1 lda #$5A ; $0F6E: A9 5A ldy #$D1 ; $0F70: A0 D1 jsr $C131 ; $0F72: 20 31 C1 lda #$65 ; $0F75: A9 65 ldy #$D1 ; $0F77: A0 D1 jsr $C131 ; $0F79: 20 31 C1 ldx PlayerCountMinusOne ; $0F7C: A6 40 Label_CF7E: lda #$20 ; $0F7E: A9 20 sta PlayerPosX,x ; $0F80: 95 91 lda $D19E,x ; $0F82: BD 9E D1 sta PlayerPosY,x ; $0F85: 95 9A lda #$03 ; $0F87: A9 03 sta $7F,x ; $0F89: 95 7F lda #$01 ; $0F8B: A9 01 sta $0448,x ; $0F8D: 9D 48 04 jsr $F3B0 ; $0F90: 20 B0 F3 jsr $E3A4 ; $0F93: 20 A4 E3 dex ; $0F96: CA bpl Label_CF7E ; $0F97: 10 E5 lda #$44 ; $0F99: A9 44 sta ParticlePosX ; $0F9B: 8D 67 05 sta $0568 ; $0F9E: 8D 68 05 lda #$54 ; $0FA1: A9 54 sta ParticlePosY ; $0FA3: 8D 7B 05 lda #$74 ; $0FA6: A9 74 sta $057C ; $0FA8: 8D 7C 05 lda #$01 ; $0FAB: A9 01 sta ParticleState ; $0FAD: 8D 5D 05 sta $055E ; $0FB0: 8D 5E 05 ldx PlayerCountMinusOne ; $0FB3: A6 40 Label_CFB5: jsr DrawParticleSprites ; $0FB5: 20 2F CE dex ; $0FB8: CA bpl Label_CFB5 ; $0FB9: 10 FA jsr $F45C ; $0FBB: 20 5C F4 lda #$2B ; $0FBE: A9 2B sta PpuCommandData0 ; $0FC0: 85 57 lda #$24 ; $0FC2: A9 24 sta PpuCommandData1 ; $0FC4: 85 58 sta PpuCommandData2 ; $0FC6: 85 59 lda #$0C ; $0FC8: A9 0C sta PpuCommandAddressHi ; $0FCA: 85 54 lda #$0B ; $0FCC: A9 0B sta PpuCommandAddressLo ; $0FCE: 85 55 lda #$05 ; $0FD0: A9 05 sta PpuCommandLength ; $0FD2: 85 56 lda PlayerParticleHitCount ; $0FD4: AD CD 05 jsr $D1C9 ; $0FD7: 20 C9 D1 lda PlayerCountMinusOne ; $0FDA: A5 40 beq Label_CFE8 ; $0FDC: F0 0A lda #$0F ; $0FDE: A9 0F sta PpuCommandAddressLo ; $0FE0: 85 55 lda PlayerParticleHitCount2 ; $0FE2: AD CE 05 jsr $D1C9 ; $0FE5: 20 C9 D1 Label_CFE8: jsr $F45C ; $0FE8: 20 5C F4 lda ParticleSequenceValue ; $0FEB: AD 59 05 sta PpuCommandData0 ; $0FEE: 85 57 lda #$00 ; $0FF0: A9 00 sta PpuCommandData1 ; $0FF2: 85 58 sta PpuCommandData2 ; $0FF4: 85 59 lda #$08 ; $0FF6: A9 08 sta PpuCommandAddressHi ; $0FF8: 85 54 lda #$0B ; $0FFA: A9 0B sta PpuCommandAddressLo ; $0FFC: 85 55 lda #$03 ; $0FFE: A9 03 sta PpuCommandLength ; $1000: 85 56 lda ParticleSequenceValue ; $1002: AD 59 05 jsr $C119 ; $1005: 20 19 C1 lda PlayerCountMinusOne ; $1008: A5 40 beq Label_D013 ; $100A: F0 07 lda #$0F ; $100C: A9 0F sta PpuCommandAddressLo ; $100E: 85 55 jsr $C119 ; $1010: 20 19 C1 Label_D013: lda #$FF ; $1013: A9 FF sta ParticleState ; $1015: 8D 5D 05 sta $055E ; $1018: 8D 5E 05 ldx PlayerCountMinusOne ; $101B: A6 40 Label_D01D: jsr DrawParticleSprites ; $101D: 20 2F CE dex ; $1020: CA bpl Label_D01D ; $1021: 10 FA lda #$02 ; $1023: A9 02 sta SoundRequestFlags0 ; $1025: 85 F0 ldx #$02 ; $1027: A2 02 jsr $F45E ; $1029: 20 5E F4 ldx PlayerCountMinusOne ; $102C: A6 40 Label_D02E: jsr DrawParticleSprites ; $102E: 20 2F CE dex ; $1031: CA bpl Label_D02E ; $1032: 10 FA jsr $D1A0 ; $1034: 20 A0 D1 jsr $F45C ; $1037: 20 5C F4 lda #$01 ; $103A: A9 01 sta SoundRequestFlags0 ; $103C: 85 F0 jsr $D121 ; $103E: 20 21 D1 bne Label_D068 ; $1041: D0 25 lda #$70 ; $1043: A9 70 ldy #$D1 ; $1045: A0 D1 jsr $C131 ; $1047: 20 31 C1 jsr $F465 ; $104A: 20 65 F4 ldx #$1A ; $104D: A2 1A Label_D04F: lda $D184,x ; $104F: BD 84 D1 sta PpuCommandData0,x ; $1052: 95 57 dex ; $1054: CA bpl Label_D04F ; $1055: 10 F8 lda SequenceDataLo ; $1057: AD 5B 05 sta SequencePointerLo ; $105A: 85 68 lda SequenceDataHi ; $105C: AD 5C 05 sta SequencePointerHi ; $105F: 85 69 jsr $C12D ; $1061: 20 2D C1 lda #$10 ; $1064: A9 10 sta SoundRequestFlags2 ; $1066: 85 F2 Label_D068: ldx #$78 ; $1068: A2 78 jsr $F45E ; $106A: 20 5E F4 jsr $D1A0 ; $106D: 20 A0 D1 Label_D070: lda #$00 ; $1070: A9 00 sta SequencePlayerIndex ; $1072: 85 3E ldx #$04 ; $1074: A2 04 jsr $D213 ; $1076: 20 13 D2 jsr $C12D ; $1079: 20 2D C1 lda PlayerCountMinusOne ; $107C: A5 40 beq Label_D08E ; $107E: F0 0E inc SequencePlayerIndex ; $1080: E6 3E ldx #$12 ; $1082: A2 12 jsr $D213 ; $1084: 20 13 D2 lda #$65 ; $1087: A9 65 ldy #$00 ; $1089: A0 00 jsr $C131 ; $108B: 20 31 C1 Label_D08E: lda #$01 ; $108E: A9 01 sta SoundRequestFlags1 ; $1090: 85 F1 ldx #$02 ; $1092: A2 02 jsr $F45E ; $1094: 20 5E F4 lda PpuBufferHead ; $1097: A5 5D cmp #$24 ; $1099: C9 24 bne Label_D070 ; $109B: D0 D3 lda PlayerCountMinusOne ; $109D: A5 40 beq Label_D0A8 ; $109F: F0 07 lda a:$006B ; $10A1: AD 6B 00 cmp #$24 ; $10A4: C9 24 bne Label_D070 ; $10A6: D0 C8 Label_D0A8: ldx #$0A ; $10A8: A2 0A jsr $F45E ; $10AA: 20 5E F4 jsr $D121 ; $10AD: 20 21 D1 bne Label_D0CE ; $10B0: D0 1C lda SequenceDataLo ; $10B2: AD 5B 05 sta SequenceValueLo ; $10B5: 85 47 lda SequenceDataHi ; $10B7: AD 5C 05 sta SequenceValueHi ; $10BA: 85 48 lda PlayerCountMinusOne ; $10BC: A5 40 sta SequencePlayerIndex ; $10BE: 85 3E Label_D0C0: jsr $D6DC ; $10C0: 20 DC D6 dec SequencePlayerIndex ; $10C3: C6 3E bpl Label_D0C0 ; $10C5: 10 F9 lda #$01 ; $10C7: A9 01 sta SoundRequestFlags1 ; $10C9: 85 F1 jsr $F45C ; $10CB: 20 5C F4 Label_D0CE: lda #$00 ; $10CE: A9 00 sta SequenceValueLo ; $10D0: 85 47 sta SequenceValueHi ; $10D2: 85 48 ldx #$01 ; $10D4: A2 01 Label_D0D6: lda PlayerActiveFlags,x ; $10D6: B5 41 bpl Label_D0DC ; $10D8: 10 02 sta PlayerSlotState,x ; $10DA: 95 88 Label_D0DC: dex ; $10DC: CA bpl Label_D0D6 ; $10DD: 10 F7 jmp $F353 ; $10DF: 4C 53 F3 ;=============================================================================== ; LoadParticleSequenceData ; ; Global: ; Loads the next particle-sequence data set and clears player hit totals. ; ; Local: ; Indexes four parameter tables, advances the index while in range, and clears both result counters. ; ; Parameters: ; ParticleSequenceIndex. ; ; Returns: ; Sequence parameters loaded and result counters cleared. ; ; PRG offsets: $10E2-$110C ; CPU range: $D0E2-$D10C ;=============================================================================== LoadParticleSequenceData: ldx ParticleSequenceIndex ; $10E2: AE 58 05 lda ParticleSequenceIndexTable,x ; $10E5: BD 0D D1 sta ParticleSequenceValue ; $10E8: 8D 59 05 lda ParticleSequenceValueTableA,x ; $10EB: BD 12 D1 sta $055A ; $10EE: 8D 5A 05 lda ParticleSequenceValueTableB,x ; $10F1: BD 17 D1 sta SequenceDataLo ; $10F4: 8D 5B 05 lda ParticleSequenceValueTableC,x ; $10F7: BD 1C D1 sta SequenceDataHi ; $10FA: 8D 5C 05 cpx #$04 ; $10FD: E0 04 bcs Label_D104 ; $10FF: B0 03 inc ParticleSequenceIndex ; $1101: EE 58 05 Label_D104: lda #$00 ; $1104: A9 00 sta PlayerParticleHitCount ; $1106: 8D CD 05 sta PlayerParticleHitCount2 ; $1109: 8D CE 05 rts ; $110C: 60 ; Sequence parameter tables ParticleSequenceIndexTable: .byte $03, $05, $07, $07, $07 ; $110D: 03 05 07 07 07 ParticleSequenceValueTableA: .byte $80, $90, $98, $A0, $A8 ; $1112: 80 90 98 A0 A8 ParticleSequenceValueTableB: .byte $01, $01, $02, $02, $03 ; $1117: 01 01 02 02 03 ParticleSequenceValueTableC: .byte $00, $05, $00, $05, $00 ; $111C: 00 05 00 05 00 ; Sum player particle-hit totals SumParticleHitCounts: lda $05CD ; $1121: AD CD 05 clc ; $1124: 18 adc $05CE ; $1125: 6D CE 05 cmp #$14 ; $1128: C9 14 rts ; $112A: 60 ; Embedded PPU templates, strings, and position tables ($D12B-$D19F) ParticleResultsData: .byte $3F, $00, $10, $0F, $30, $30, $30, $0F ; $112B: 3F 00 10 0F 30 30 30 0F .byte $30, $27, $15, $0F, $30, $02, $21, $0F ; $1133: 30 27 15 0F 30 02 21 0F .byte $16, $16, $16 ; $113B: 16 16 16 ParticleResultsPpuTemplate: .byte $21, $73, $0B, $29, $00 ; $113E: 21 73 0B 29 00 .byte $00, $00, $00, $00, $24, $19, $1D, $1C ; $1143: 00 00 00 00 24 19 1D 1C .byte $26, $21, $F3, $0B, $29, $00, $00, $00 ; $114B: 26 21 F3 0B 29 00 00 00 .byte $00, $00, $24, $19, $1D, $1C, $26, $23 ; $1153: 00 00 24 19 1D 1C 26 23 .byte $E8, $08, $FF, $FF, $FF, $FF, $FF, $FF ; $115B: E8 08 FF FF FF FF FF FF .byte $FF, $FF, $23, $C0, $08, $40, $50, $50 ; $1163: FF FF 23 C0 08 40 50 50 .byte $50, $50, $90, $A0, $A0, $22, $88, $11 ; $116B: 50 50 90 A0 A0 22 88 11 .byte $19, $24, $0E, $24, $1B, $24, $0F, $24 ; $1173: 19 24 0E 24 1B 24 0F 24 .byte $0E, $24, $0C, $24, $1D, $24, $2C, $2C ; $117B: 0E 24 0C 24 1D 24 2C 2C .byte $2C ; $1183: 2C PlayerStartYTable: .byte $22, $C6, $17, $1C, $1E, $19, $0E ; $1184: 22 C6 17 1C 1E 19 0E .byte $1B, $24, $0B, $18, $17, $1E, $1C, $24 ; $118B: 1B 24 0B 18 17 1E 1C 24 .byte $24, $24, $01, $00, $00, $00, $00, $19 ; $1193: 24 24 01 00 00 00 00 19 .byte $1D, $1C, $2C ; $119B: 1D 1C 2C PlayerStartXTable: .byte $50, $70 ; $119E: 50 70 DrawParticleBonusResults: ldx #$1C ; $11A0: A2 1C Label_D1A2: lda ParticleResultsPpuTemplate,x ; $11A2: BD 3E D1 sta $57,x ; $11A5: 95 57 dex ; $11A7: CA bpl Label_D1A2 ; $11A8: 10 F8 ldx #$04 ; $11AA: A2 04 ldy $05CD ; $11AC: AC CD 05 jsr AddParticleResultDigits ; $11AF: 20 DC D1 ldx #$12 ; $11B2: A2 12 ldy $05CE ; $11B4: AC CE 05 jsr AddParticleResultDigits ; $11B7: 20 DC D1 jsr $C12D ; $11BA: 20 2D C1 lda $40 ; $11BD: A5 40 bne Label_D1C2 ; $11BF: D0 01 rts ; $11C1: 60 Label_D1C2: lda #$65 ; $11C2: A9 65 ldy #$00 ; $11C4: A0 00 jmp $C131 ; $11C6: 4C 31 C1 ConvertValueToDecimalDigits: ldy #$00 ; $11C9: A0 00 Label_D1CB: cmp #$0A ; $11CB: C9 0A bcc Label_D1D5 ; $11CD: 90 06 iny ; $11CF: C8 sbc #$0A ; $11D0: E9 0A jmp Label_D1CB ; $11D2: 4C CB D1 Label_D1D5: sty $5A ; $11D5: 84 5A sta $5B ; $11D7: 85 5B jmp $C119 ; $11D9: 4C 19 C1 AddParticleResultDigits: dey ; $11DC: 88 bmi Label_D1FE ; $11DD: 30 1F lda $0559 ; $11DF: AD 59 05 clc ; $11E2: 18 adc $59,x ; $11E3: 75 59 cmp #$0A ; $11E5: C9 0A bcc Label_D1ED ; $11E7: 90 04 sbc #$0A ; $11E9: E9 0A inc $58,x ; $11EB: F6 58 Label_D1ED: sta $59,x ; $11ED: 95 59 lda $58,x ; $11EF: B5 58 cmp #$0A ; $11F1: C9 0A bcc Label_D1FB ; $11F3: 90 06 sbc #$0A ; $11F5: E9 0A inc $57,x ; $11F7: F6 57 sta $58,x ; $11F9: 95 58 Label_D1FB: jmp AddParticleResultDigits ; $11FB: 4C DC D1 Label_D1FE: ldy #$00 ; $11FE: A0 00 Label_D200: lda $57,x ; $1200: B5 57 beq Label_D208 ; $1202: F0 04 cmp #$24 ; $1204: C9 24 bne Label_D212 ; $1206: D0 0A Label_D208: lda #$24 ; $1208: A9 24 sta $57,x ; $120A: 95 57 inx ; $120C: E8 iny ; $120D: C8 cpy #$04 ; $120E: C0 04 bne Label_D200 ; $1210: D0 EE Label_D212: rts ; $1212: 60 DecrementDecimalDigits: lda $59,x ; $1213: B5 59 cmp #$24 ; $1215: C9 24 beq Label_D243 ; $1217: F0 2A tay ; $1219: A8 bne Label_D238 ; $121A: D0 1C lda $58,x ; $121C: B5 58 cmp #$24 ; $121E: C9 24 beq Label_D243 ; $1220: F0 21 lda $58,x ; $1222: B5 58 bne Label_D232 ; $1224: D0 0C lda $57,x ; $1226: B5 57 cmp #$24 ; $1228: C9 24 beq Label_D243 ; $122A: F0 17 lda #$0A ; $122C: A9 0A sta $58,x ; $122E: 95 58 dec $57,x ; $1230: D6 57 Label_D232: lda #$0A ; $1232: A9 0A sta $59,x ; $1234: 95 59 dec $58,x ; $1236: D6 58 Label_D238: dec $59,x ; $1238: D6 59 txa ; $123A: 8A pha ; $123B: 48 lda #$0A ; $123C: A9 0A jsr $D6DE ; $123E: 20 DE D6 pla ; $1241: 68 tax ; $1242: AA Label_D243: jmp Label_D1FE ; $1243: 4C FE D1 ClearPpuAndOamBuffers: jsr $C10A ; $1246: 20 0A C1 jsr $C0FA ; $1249: 20 FA C0 lda #$20 ; $124C: A9 20 sta $2006 ; $124E: 8D 06 20 lda #$00 ; $1251: A9 00 sta $2006 ; $1253: 8D 06 20 jsr ClearNametable ; $1256: 20 75 D2 jsr ClearNametable ; $1259: 20 75 D2 jsr $C104 ; $125C: 20 04 C1 jsr $C115 ; $125F: 20 15 C1 ldx #$3F ; $1262: A2 3F ldy #$00 ; $1264: A0 00 sty $4C ; $1266: 84 4C Label_D268: lda #$F0 ; $1268: A9 F0 sta $0200,y ; $126A: 99 00 02 iny ; $126D: C8 iny ; $126E: C8 iny ; $126F: C8 iny ; $1270: C8 dex ; $1271: CA bpl Label_D268 ; $1272: 10 F4 rts ; $1274: 60 ClearNametable: ldx #$F0 ; $1275: A2 F0 lda #$24 ; $1277: A9 24 Label_D279: sta $2007 ; $1279: 8D 07 20 sta $2007 ; $127C: 8D 07 20 sta $2007 ; $127F: 8D 07 20 sta $2007 ; $1282: 8D 07 20 dex ; $1285: CA bne Label_D279 ; $1286: D0 F1 ldx #$40 ; $1288: A2 40 lda #$00 ; $128A: A9 00 Label_D28C: sta $2007 ; $128C: 8D 07 20 dex ; $128F: CA bne Label_D28C ; $1290: D0 FA rts ; $1292: 60 LoadStageObjectData: jsr $C10A ; $1293: 20 0A C1 jsr $C0FA ; $1296: 20 FA C0 lda $16 ; $1299: A5 16 beq Label_D2A0 ; $129B: F0 03 jmp $D572 ; $129D: 4C 72 D5 Label_D2A0: ldy $3B ; $12A0: A4 3B lda StageStreamPointerLoTable,y ; $12A2: B9 2A DB sta $1D ; $12A5: 85 1D lda StageStreamPointerHiTable,y ; $12A7: B9 3A DB sta $1E ; $12AA: 85 1E jsr $D497 ; $12AC: 20 97 D4 ldx #$00 ; $12AF: A2 00 Label_D2B1: jsr $D4E5 ; $12B1: 20 E5 D4 cmp #$FF ; $12B4: C9 FF beq Label_D322 ; $12B6: F0 6A sta $54 ; $12B8: 85 54 jsr $D4E5 ; $12BA: 20 E5 D4 sta $55 ; $12BD: 85 55 ldy #$03 ; $12BF: A0 03 Label_D2C1: jsr $D4FB ; $12C1: 20 FB D4 lda #$04 ; $12C4: A9 04 sta $12 ; $12C6: 85 12 lda $D493,y ; $12C8: B9 93 D4 Label_D2CB: sta $2007 ; $12CB: 8D 07 20 clc ; $12CE: 18 adc #$04 ; $12CF: 69 04 dec $12 ; $12D1: C6 12 bne Label_D2CB ; $12D3: D0 F6 inc $55 ; $12D5: E6 55 dey ; $12D7: 88 bpl Label_D2C1 ; $12D8: 10 E7 lda $55 ; $12DA: A5 55 sec ; $12DC: 38 sbc #$04 ; $12DD: E9 04 sta $55 ; $12DF: 85 55 jsr $D51C ; $12E1: 20 1C D5 sta $A6,x ; $12E4: 95 A6 inc $54 ; $12E6: E6 54 inc $54 ; $12E8: E6 54 jsr $D51C ; $12EA: 20 1C D5 sta $A9,x ; $12ED: 95 A9 inc $55 ; $12EF: E6 55 inc $55 ; $12F1: E6 55 jsr $D51C ; $12F3: 20 1C D5 sta $AF,x ; $12F6: 95 AF dec $54 ; $12F8: C6 54 dec $54 ; $12FA: C6 54 jsr $D51C ; $12FC: 20 1C D5 sta $AC,x ; $12FF: 95 AC stx $A4 ; $1301: 86 A4 lda #$03 ; $1303: A9 03 jsr $C856 ; $1305: 20 56 C8 jsr $C17C ; $1308: 20 7C C1 ldx $A4 ; $130B: A6 A4 lda $54 ; $130D: A5 54 asl a ; $130F: 0A asl a ; $1310: 0A asl a ; $1311: 0A clc ; $1312: 18 adc #$10 ; $1313: 69 10 sta $B2,x ; $1315: 95 B2 lda $55 ; $1317: A5 55 asl a ; $1319: 0A asl a ; $131A: 0A asl a ; $131B: 0A sta $B5,x ; $131C: 95 B5 inx ; $131E: E8 jmp Label_D2B1 ; $131F: 4C B1 D2 Label_D322: dex ; $1322: CA stx $A3 ; $1323: 86 A3 ldx #$00 ; $1325: A2 00 Label_D327: jsr $D4E5 ; $1327: 20 E5 D4 cmp #$FF ; $132A: C9 FF beq Label_D37E ; $132C: F0 50 sta $54 ; $132E: 85 54 jsr $D4E5 ; $1330: 20 E5 D4 sta $55 ; $1333: 85 55 jsr $D4E5 ; $1335: 20 E5 D4 sta $05FA,x ; $1338: 9D FA 05 lda $54 ; $133B: A5 54 asl a ; $133D: 0A asl a ; $133E: 0A asl a ; $133F: 0A adc #$0C ; $1340: 69 0C sta $05D2,x ; $1342: 9D D2 05 lda $55 ; $1345: A5 55 asl a ; $1347: 0A asl a ; $1348: 0A asl a ; $1349: 0A adc #$0C ; $134A: 69 0C sta $05DC,x ; $134C: 9D DC 05 lda #$00 ; $134F: A9 00 sta $0604,x ; $1351: 9D 04 06 jsr $D4FB ; $1354: 20 FB D4 sta $05E6,x ; $1357: 9D E6 05 lda $13 ; $135A: A5 13 sta $05F0,x ; $135C: 9D F0 05 jsr $D56C ; $135F: 20 6C D5 jsr $D53C ; $1362: 20 3C D5 inc $54 ; $1365: E6 54 inc $54 ; $1367: E6 54 jsr $D53C ; $1369: 20 3C D5 inc $55 ; $136C: E6 55 inc $55 ; $136E: E6 55 jsr $D53C ; $1370: 20 3C D5 dec $54 ; $1373: C6 54 dec $54 ; $1375: C6 54 jsr $D53C ; $1377: 20 3C D5 inx ; $137A: E8 jmp Label_D327 ; $137B: 4C 27 D3 Label_D37E: dex ; $137E: CA stx $05D1 ; $137F: 8E D1 05 jsr $D4E5 ; $1382: 20 E5 D4 sta $1F ; $1385: 85 1F jsr $D4E5 ; $1387: 20 E5 D4 sta $20 ; $138A: 85 20 ldy #$00 ; $138C: A0 00 lda ($1F),y ; $138E: B1 1F tax ; $1390: AA dex ; $1391: CA bpl Label_D399 ; $1392: 10 05 inc $C8 ; $1394: E6 C8 jmp Label_D3BA ; $1396: 4C BA D3 Label_D399: iny ; $1399: C8 Label_D39A: lda ($1F),y ; $139A: B1 1F iny ; $139C: C8 sta $93,x ; $139D: 95 93 lda ($1F),y ; $139F: B1 1F iny ; $13A1: C8 sta $9C,x ; $13A2: 95 9C lda ($1F),y ; $13A4: B1 1F iny ; $13A6: C8 sta $0453,x ; $13A7: 9D 53 04 lda #$02 ; $13AA: A9 02 sta $81,x ; $13AC: 95 81 lda #$01 ; $13AE: A9 01 sta $8A,x ; $13B0: 95 8A lda $C6 ; $13B2: A5 C6 sta $0441,x ; $13B4: 9D 41 04 dex ; $13B7: CA bpl Label_D39A ; $13B8: 10 E0 Label_D3BA: jsr $D4E5 ; $13BA: 20 E5 D4 sta $CD ; $13BD: 85 CD jsr $D4E5 ; $13BF: 20 E5 D4 sta $23 ; $13C2: 85 23 jsr $D4E5 ; $13C4: 20 E5 D4 tay ; $13C7: A8 sta $24 ; $13C8: 85 24 lda $23 ; $13CA: A5 23 jsr $D48C ; $13CC: 20 8C D4 sta $25 ; $13CF: 85 25 sty $26 ; $13D1: 84 26 jsr $D48C ; $13D3: 20 8C D4 sta $27 ; $13D6: 85 27 sty $28 ; $13D8: 84 28 jsr $D48C ; $13DA: 20 8C D4 sta $29 ; $13DD: 85 29 sty $2A ; $13DF: 84 2A jsr $D5D9 ; $13E1: 20 D9 D5 jsr BuildStagePpuCommands ; $13E4: 20 ED D3 jsr $C104 ; $13E7: 20 04 C1 jmp $C115 ; $13EA: 4C 15 C1 BuildStagePpuCommands: ldx #$22 ; $13ED: A2 22 Label_D3EF: lda StagePaletteAndTileData,x ; $13EF: BD 37 D4 sta $57,x ; $13F2: 95 57 dex ; $13F4: CA bpl Label_D3EF ; $13F5: 10 F8 lda $C8 ; $13F7: A5 C8 bne Label_D410 ; $13F9: D0 15 lda $3B ; $13FB: A5 3B and #$0C ; $13FD: 29 0C ora #$03 ; $13FF: 09 03 tay ; $1401: A8 ldx #$03 ; $1402: A2 03 Label_D404: lda $D45A,y ; $1404: B9 5A D4 sta $5A,x ; $1407: 95 5A dey ; $1409: 88 dex ; $140A: CA bpl Label_D404 ; $140B: 10 F7 Label_D40D: jmp $C12D ; $140D: 4C 2D C1 Label_D410: ldx $0558 ; $1410: AE 58 05 lda $D46A,x ; $1413: BD 6A D4 sta $1D ; $1416: 85 1D lda $D46F,x ; $1418: BD 6F D4 sta $1E ; $141B: 85 1E ldx #$03 ; $141D: A2 03 ldy #$07 ; $141F: A0 07 Label_D421: lda ($1D),y ; $1421: B1 1D sta $72,x ; $1423: 95 72 dey ; $1425: 88 dex ; $1426: CA bpl Label_D421 ; $1427: 10 F8 lda $16 ; $1429: A5 16 bne Label_D40D ; $142B: D0 E0 Label_D42D: lda ($1D),y ; $142D: B1 1D sta a:$005A,y ; $142F: 99 5A 00 dey ; $1432: 88 bpl Label_D42D ; $1433: 10 F8 bmi Label_D40D ; $1435: 30 D6 StagePaletteAndTileData: .byte $3F, $00, $20, $0F, $2A, $09, $07, $0F ; $1437: 3F 00 20 0F 2A 09 07 0F .byte $30, $27, $15, $0F, $30, $02, $21, $0F ; $143F: 30 27 15 0F 30 02 21 0F .byte $30, $00, $10, $0F, $16, $12, $37, $0F ; $1447: 30 00 10 0F 16 12 37 0F .byte $12, $16, $37, $0F, $17, $11, $35, $0F ; $144F: 12 16 37 0F 17 11 35 0F .byte $17, $11, $2B, $0F, $2A, $09, $07, $0F ; $1457: 17 11 2B 0F 2A 09 07 0F .byte $26, $06, $07, $0F, $1B, $0C, $07, $0F ; $145F: 26 06 07 0F 1B 0C 07 0F .byte $2C, $01, $06, $74, $7C, $84, $84, $84 ; $1467: 2C 01 06 74 7C 84 84 84 .byte $D4, $D4, $D4, $D4, $D4, $0F, $02, $08 ; $146F: D4 D4 D4 D4 D4 0F 02 08 .byte $06, $0F, $2B, $30, $12, $0F, $07, $0A ; $1477: 06 0F 2B 30 12 0F 07 0A .byte $19, $0F, $26, $30, $2B, $0F, $07, $0C ; $147F: 19 0F 26 30 2B 0F 07 0C .byte $1C, $0F, $15, $30, $26 ; $1487: 1C 0F 15 30 26 AddOffsetToStreamPointer: sec ; $148C: 38 adc $CD ; $148D: 65 CD bcc Label_D492 ; $148F: 90 01 iny ; $1491: C8 Label_D492: rts ; $1492: 60 StreamPointerAdjustmentTable: .byte $7F, $7E, $7D, $7C ; $1493: 7F 7E 7D 7C DecodePpuCommandStream: jsr ReadStageStreamByte ; $1497: 20 E5 D4 sta $1F ; $149A: 85 1F jsr ReadStageStreamByte ; $149C: 20 E5 D4 sta $20 ; $149F: 85 20 tax ; $14A1: AA beq Label_D4E4 ; $14A2: F0 40 Label_D4A4: jsr ReadPpuStreamByte ; $14A4: 20 F0 D4 tax ; $14A7: AA beq DecodePpuCommandStream ; $14A8: F0 ED and #$7F ; $14AA: 29 7F sta $2006 ; $14AC: 8D 06 20 jsr ReadPpuStreamByte ; $14AF: 20 F0 D4 sta $2006 ; $14B2: 8D 06 20 jsr ReadPpuStreamByte ; $14B5: 20 F0 D4 sta $12 ; $14B8: 85 12 txa ; $14BA: 8A and #$80 ; $14BB: 29 80 lsr a ; $14BD: 4A lsr a ; $14BE: 4A lsr a ; $14BF: 4A lsr a ; $14C0: 4A lsr a ; $14C1: 4A ora $00 ; $14C2: 05 00 sta $2000 ; $14C4: 8D 00 20 txa ; $14C7: 8A and #$40 ; $14C8: 29 40 bne Label_D4D8 ; $14CA: D0 0C Label_D4CC: jsr ReadPpuStreamByte ; $14CC: 20 F0 D4 sta $2007 ; $14CF: 8D 07 20 dec $12 ; $14D2: C6 12 bne Label_D4CC ; $14D4: D0 F6 beq Label_D4A4 ; $14D6: F0 CC Label_D4D8: jsr ReadPpuStreamByte ; $14D8: 20 F0 D4 Label_D4DB: sta $2007 ; $14DB: 8D 07 20 dec $12 ; $14DE: C6 12 bne Label_D4DB ; $14E0: D0 F9 beq Label_D4A4 ; $14E2: F0 C0 Label_D4E4: rts ; $14E4: 60 ReadStageStreamByte: ldy #$00 ; $14E5: A0 00 lda ($1D),y ; $14E7: B1 1D inc $1D ; $14E9: E6 1D bne Label_D4EF ; $14EB: D0 02 inc $1E ; $14ED: E6 1E Label_D4EF: rts ; $14EF: 60 ReadPpuStreamByte: ldy #$00 ; $14F0: A0 00 lda ($1F),y ; $14F2: B1 1F inc $1F ; $14F4: E6 1F bne Label_D4FA ; $14F6: D0 02 inc $20 ; $14F8: E6 20 Label_D4FA: rts ; $14FA: 60 Label_D4FB: lda $55 ; $14FB: A5 55 sta $12 ; $14FD: 85 12 lda #$00 ; $14FF: A9 00 asl $12 ; $1501: 06 12 asl $12 ; $1503: 06 12 asl $12 ; $1505: 06 12 asl $12 ; $1507: 06 12 rol a ; $1509: 2A asl $12 ; $150A: 06 12 rol a ; $150C: 2A ora #$20 ; $150D: 09 20 sta $2006 ; $150F: 8D 06 20 sta $13 ; $1512: 85 13 lda $12 ; $1514: A5 12 ora $54 ; $1516: 05 54 sta $2006 ; $1518: 8D 06 20 rts ; $151B: 60 SetTileAddressFromCoordinates: lda $55 ; $151C: A5 55 and #$FC ; $151E: 29 FC asl a ; $1520: 0A sta $12 ; $1521: 85 12 lda $54 ; $1523: A5 54 lsr a ; $1525: 4A lsr a ; $1526: 4A ora $12 ; $1527: 05 12 ora #$C0 ; $1529: 09 C0 pha ; $152B: 48 lda $55 ; $152C: A5 55 and #$02 ; $152E: 29 02 sta $12 ; $1530: 85 12 lda $54 ; $1532: A5 54 and #$02 ; $1534: 29 02 lsr a ; $1536: 4A ora $12 ; $1537: 05 12 tay ; $1539: A8 pla ; $153A: 68 rts ; $153B: 60 ReadModifyAttributeByte: lda #$23 ; $153C: A9 23 sta $2006 ; $153E: 8D 06 20 jsr SetTileAddressFromCoordinates ; $1541: 20 1C D5 sta $2006 ; $1544: 8D 06 20 lda $2007 ; $1547: AD 07 20 lda $2007 ; $154A: AD 07 20 and AttributeClearMaskTable,y ; $154D: 39 64 D5 ora AttributeSetMaskTable,y ; $1550: 19 68 D5 pha ; $1553: 48 lda #$23 ; $1554: A9 23 sta $2006 ; $1556: 8D 06 20 jsr SetTileAddressFromCoordinates ; $1559: 20 1C D5 sta $2006 ; $155C: 8D 06 20 pla ; $155F: 68 sta $2007 ; $1560: 8D 07 20 rts ; $1563: 60 AttributeClearMaskTable: .byte $FC, $F3, $CF, $3F ; $1564: FC F3 CF 3F AttributeSetMaskTable: .byte $01, $04, $10, $40 ; $1568: 01 04 10 40 InitializeNametablePatterns: jsr $CCCB ; $156C: 20 CB CC jmp $C17C ; $156F: 4C 7C C1 Label_D572: lda #$C0 ; $1572: A9 C0 ldy #$23 ; $1574: A0 23 jsr WriteNametableHeaderPattern ; $1576: 20 93 D5 lda #$C0 ; $1579: A9 C0 ldy #$27 ; $157B: A0 27 jsr WriteNametableHeaderPattern ; $157D: 20 93 D5 ldy #$23 ; $1580: A0 23 lda #$60 ; $1582: A9 60 jsr WriteNametableAttributePattern ; $1584: 20 B8 D5 ldy #$27 ; $1587: A0 27 lda #$60 ; $1589: A9 60 jsr WriteNametableAttributePattern ; $158B: 20 B8 D5 inc $C8 ; $158E: E6 C8 jmp $D3E1 ; $1590: 4C E1 D3 WriteNametableHeaderPattern: sty $2006 ; $1593: 8C 06 20 sta $2006 ; $1596: 8D 06 20 ldx #$00 ; $1599: A2 00 Label_D59B: lda $DCAE,x ; $159B: BD AE DC sta $2007 ; $159E: 8D 07 20 inx ; $15A1: E8 cpx #$08 ; $15A2: E0 08 bne Label_D59B ; $15A4: D0 F5 lda #$00 ; $15A6: A9 00 ldx #$28 ; $15A8: A2 28 jsr FillPpuBytes ; $15AA: 20 B1 D5 lda #$AA ; $15AD: A9 AA ldx #$10 ; $15AF: A2 10 FillPpuBytes: sta $2007 ; $15B1: 8D 07 20 dex ; $15B4: CA bne FillPpuBytes ; $15B5: D0 FA rts ; $15B7: 60 WriteNametableAttributePattern: sty $2006 ; $15B8: 8C 06 20 sta $2006 ; $15BB: 8D 06 20 ldx #$20 ; $15BE: A2 20 lda #$58 ; $15C0: A9 58 jsr WriteAttributeQuadrants ; $15C2: 20 C9 D5 ldx #$40 ; $15C5: A2 40 lda #$5C ; $15C7: A9 5C WriteAttributeQuadrants: sta $12 ; $15C9: 85 12 Label_D5CB: txa ; $15CB: 8A and #$03 ; $15CC: 29 03 eor #$03 ; $15CE: 49 03 ora $12 ; $15D0: 05 12 sta $2007 ; $15D2: 8D 07 20 dex ; $15D5: CA bne Label_D5CB ; $15D6: D0 F3 rts ; $15D8: 60 ScanNametableTiles: ldx #$00 ; $15D9: A2 00 Label_D5DB: jsr GetNametableAddressForIndex ; $15DB: 20 51 D6 jsr ClassifyNametableTile ; $15DE: 20 F1 D5 lda $51 ; $15E1: A5 51 ora #$04 ; $15E3: 09 04 sta $51 ; $15E5: 85 51 jsr ClassifyNametableTile ; $15E7: 20 F1 D5 inx ; $15EA: E8 inx ; $15EB: E8 cpx #$80 ; $15EC: E0 80 bne Label_D5DB ; $15EE: D0 EB rts ; $15F0: 60 ClassifyNametableTile: lda $51 ; $15F1: A5 51 sta $2006 ; $15F3: 8D 06 20 lda $50 ; $15F6: A5 50 sta $2006 ; $15F8: 8D 06 20 lda $2007 ; $15FB: AD 07 20 lda $2007 ; $15FE: AD 07 20 cmp #$24 ; $1601: C9 24 bne Label_D60C ; $1603: D0 07 txa ; $1605: 8A and #$03 ; $1606: 29 03 tay ; $1608: A8 jmp Label_D63B ; $1609: 4C 3B D6 Label_D60C: rts ; $160C: 60 Label_D60D: lda $4C ; $160D: A5 4C beq Label_D63A ; $160F: F0 29 dec $4C ; $1611: C6 4C lda $4F ; $1613: A5 4F clc ; $1615: 18 adc #$02 ; $1616: 69 02 and #$3F ; $1618: 29 3F sta $4F ; $161A: 85 4F tax ; $161C: AA jsr GetNametableAddressForIndex ; $161D: 20 51 D6 lda $51 ; $1620: A5 51 sta $2006 ; $1622: 8D 06 20 lda $50 ; $1625: A5 50 sta $2006 ; $1627: 8D 06 20 lda $2007 ; $162A: AD 07 20 lda $2007 ; $162D: AD 07 20 ldy #$03 ; $1630: A0 03 Label_D632: cmp NametableTileClassTable,y ; $1632: D9 4C D6 beq Label_D63B ; $1635: F0 04 dey ; $1637: 88 bpl Label_D632 ; $1638: 10 F8 Label_D63A: rts ; $163A: 60 Label_D63B: lda $51 ; $163B: A5 51 sta $2006 ; $163D: 8D 06 20 lda $50 ; $1640: A5 50 sta $2006 ; $1642: 8D 06 20 lda $D64D,y ; $1645: B9 4D D6 sta $2007 ; $1648: 8D 07 20 rts ; $164B: 60 NametableTileClassTable: .byte $24, $ED, $EE, $EF, $24 ; $164C: 24 ED EE EF 24 GetNametableAddressForIndex: lda NametableAddressPairTable,x ; $1651: BD 5C D6 sta $50 ; $1654: 85 50 lda NametableAddressPairTable+1,x ; $1656: BD 5D D6 sta $51 ; $1659: 85 51 rts ; $165B: 60 NametableAddressPairTable: .byte $63, $21, $A5, $21, $CB, $20, $B7, $20 ; $165C: 63 21 A5 21 CB 20 B7 20 .byte $7D, $21, $9B, $22, $F2, $20, $49, $22 ; $1664: 7D 21 9B 22 F2 20 49 22 .byte $6D, $21, $0B, $22, $92, $22, $95, $21 ; $166C: 6D 21 0B 22 92 22 95 21 .byte $1C, $21, $48, $21, $E0, $20, $0B, $23 ; $1674: 1C 21 48 21 E0 20 0B 23 .byte $CE, $20, $D0, $21, $06, $21, $19, $21 ; $167C: CE 20 D0 21 06 21 19 21 .byte $30, $22, $8A, $22, $88, $22, $A4, $20 ; $1684: 30 22 8A 22 88 22 A4 20 .byte $42, $22, $68, $21, $3C, $22, $36, $21 ; $168C: 42 22 68 21 3C 22 36 21 .byte $CA, $21, $BC, $20, $96, $21, $4C, $21 ; $1694: CA 21 BC 20 96 21 4C 21 .byte $35, $22, $EF, $20, $68, $22, $A6, $20 ; $169C: 35 22 EF 20 68 22 A6 20 .byte $BB, $21, $7A, $21, $EA, $20, $F1, $21 ; $16A4: BB 21 7A 21 EA 20 F1 21 .byte $C2, $20, $77, $21, $54, $21, $BA, $20 ; $16AC: C2 20 77 21 54 21 BA 20 .byte $C5, $22, $BE, $20, $FA, $20, $AE, $21 ; $16B4: C5 22 BE 20 FA 20 AE 21 .byte $46, $21, $9A, $21, $D2, $20, $3D, $21 ; $16BC: 46 21 9A 21 D2 20 3D 21 .byte $2B, $22, $B0, $20, $B6, $21, $AC, $20 ; $16C4: 2B 22 B0 20 B6 21 AC 20 .byte $B3, $20, $DB, $20, $F6, $20, $2C, $21 ; $16CC: B3 20 DB 20 F6 20 2C 21 .byte $E7, $20, $62, $21, $E4, $21, $4E, $21 ; $16D4: E7 20 62 21 E4 21 4E 21 UpdateBonusScoreTotals: lda #$00 ; $16DC: A9 00 AccumulatePlayerBonusScore: sta $43 ; $16DE: 85 43 lda $3A ; $16E0: A5 3A beq Label_D6E5 ; $16E2: F0 01 Label_D6E4: rts ; $16E4: 60 Label_D6E5: ldx $3E ; $16E5: A6 3E cpx #$02 ; $16E7: E0 02 bcs Label_D6E4 ; $16E9: B0 F9 lda $41,x ; $16EB: B5 41 bmi Label_D6E4 ; $16ED: 30 F5 ldy #$64 ; $16EF: A0 64 jsr DivideBonusValue ; $16F1: 20 7C D7 clc ; $16F4: 18 adc $48 ; $16F5: 65 48 sta $45 ; $16F7: 85 45 ldy #$0A ; $16F9: A0 0A jsr DivideBonusValue ; $16FB: 20 7C D7 sta $44 ; $16FE: 85 44 ldx $3F ; $1700: A6 3F lda BonusScoreWeightTable,x ; $1702: BD 79 D7 sta $21 ; $1705: 85 21 lda #$06 ; $1707: A9 06 sta $22 ; $1709: 85 22 lda $3E ; $170B: A5 3E asl a ; $170D: 0A asl a ; $170E: 0A ora $3E ; $170F: 05 3E tax ; $1711: AA clc ; $1712: 18 lda $03,x ; $1713: B5 03 adc $43 ; $1715: 65 43 jsr ClampDecimalDigit ; $1717: 20 8F D7 sta $03,x ; $171A: 95 03 lda $04,x ; $171C: B5 04 adc $44 ; $171E: 65 44 jsr ClampDecimalDigit ; $1720: 20 8F D7 sta $04,x ; $1723: 95 04 lda $05,x ; $1725: B5 05 adc $45 ; $1727: 65 45 jsr ClampDecimalDigit ; $1729: 20 8F D7 sta $05,x ; $172C: 95 05 lda $06,x ; $172E: B5 06 adc $47 ; $1730: 65 47 jsr ClampDecimalDigit ; $1732: 20 8F D7 sta $06,x ; $1735: 95 06 lda $07,x ; $1737: B5 07 adc #$00 ; $1739: 69 00 jsr ClampDecimalDigit ; $173B: 20 8F D7 sta $07,x ; $173E: 95 07 inx ; $1740: E8 inx ; $1741: E8 inx ; $1742: E8 inx ; $1743: E8 ldy #$04 ; $1744: A0 04 Label_D746: lda $03,x ; $1746: B5 03 cmp ($21),y ; $1748: D1 21 bcc Label_D765 ; $174A: 90 19 bne Label_D752 ; $174C: D0 04 dex ; $174E: CA dey ; $174F: 88 bpl Label_D746 ; $1750: 10 F4 Label_D752: ldy #$00 ; $1752: A0 00 lda $3E ; $1754: A5 3E asl a ; $1756: 0A asl a ; $1757: 0A ora $3E ; $1758: 05 3E tax ; $175A: AA Label_D75B: lda $03,x ; $175B: B5 03 sta ($21),y ; $175D: 91 21 inx ; $175F: E8 iny ; $1760: C8 cpy #$05 ; $1761: C0 05 bne Label_D75B ; $1763: D0 F6 Label_D765: ldy #$04 ; $1765: A0 04 Label_D767: lda ($21),y ; $1767: B1 21 sta a:$000D,y ; $1769: 99 0D 00 dey ; $176C: 88 bpl Label_D767 ; $176D: 10 F8 inc $46 ; $176F: E6 46 lda $16 ; $1771: A5 16 beq Label_D778 ; $1773: F0 03 jsr $C539 ; $1775: 20 39 C5 Label_D778: rts ; $1778: 60 BonusScoreWeightTable: .byte $29, $2E, $33 ; $1779: 29 2E 33 DivideBonusValue: sty $12 ; $177C: 84 12 ldx #$FF ; $177E: A2 FF lda $43 ; $1780: A5 43 Label_D782: sec ; $1782: 38 sbc $12 ; $1783: E5 12 inx ; $1785: E8 bcs Label_D782 ; $1786: B0 FA clc ; $1788: 18 adc $12 ; $1789: 65 12 sta $43 ; $178B: 85 43 txa ; $178D: 8A rts ; $178E: 60 ClampDecimalDigit: cmp #$0A ; $178F: C9 0A bcs Label_D794 ; $1791: B0 01 rts ; $1793: 60 Label_D794: sec ; $1794: 38 sbc #$0A ; $1795: E9 0A rts ; $1797: 60 DrawBonusResultScreen: ldy $46 ; $1798: A4 46 dey ; $179A: 88 beq Label_D7A0 ; $179B: F0 03 bpl Label_D805 ; $179D: 10 66 rts ; $179F: 60 Label_D7A0: lda #$20 ; $17A0: A9 20 sta $2006 ; $17A2: 8D 06 20 lda #$43 ; $17A5: A9 43 sta $2006 ; $17A7: 8D 06 20 lda #$8E ; $17AA: A9 8E sta $2007 ; $17AC: 8D 07 20 ldx #$04 ; $17AF: A2 04 Label_D7B1: lda $03,x ; $17B1: B5 03 sta $2007 ; $17B3: 8D 07 20 dex ; $17B6: CA bpl Label_D7B1 ; $17B7: 10 F8 lda #$00 ; $17B9: A9 00 sta $2007 ; $17BB: 8D 07 20 lda #$24 ; $17BE: A9 24 sta $2007 ; $17C0: 8D 07 20 sta $2007 ; $17C3: 8D 07 20 ldx #$8C ; $17C6: A2 8C stx $2007 ; $17C8: 8E 07 20 inx ; $17CB: E8 stx $2007 ; $17CC: 8E 07 20 ldx #$04 ; $17CF: A2 04 Label_D7D1: lda $0D,x ; $17D1: B5 0D sta $2007 ; $17D3: 8D 07 20 dex ; $17D6: CA bpl Label_D7D1 ; $17D7: 10 F8 lda #$00 ; $17D9: A9 00 sta $2007 ; $17DB: 8D 07 20 lda #$24 ; $17DE: A9 24 sta $2007 ; $17E0: 8D 07 20 sta $2007 ; $17E3: 8D 07 20 lda $16 ; $17E6: A5 16 bne DrawBonusValueDigits ; $17E8: D0 6A lda $40 ; $17EA: A5 40 beq Label_D802 ; $17EC: F0 14 lda #$8F ; $17EE: A9 8F sta $2007 ; $17F0: 8D 07 20 ldx #$04 ; $17F3: A2 04 Label_D7F5: lda $08,x ; $17F5: B5 08 sta $2007 ; $17F7: 8D 07 20 dex ; $17FA: CA bpl Label_D7F5 ; $17FB: 10 F8 lda #$00 ; $17FD: A9 00 sta $2007 ; $17FF: 8D 07 20 Label_D802: dec $46 ; $1802: C6 46 rts ; $1804: 60 Label_D805: dec $46 ; $1805: C6 46 lda #$20 ; $1807: A9 20 sta $2006 ; $1809: 8D 06 20 lda #$62 ; $180C: A9 62 sta $2006 ; $180E: 8D 06 20 lda $41 ; $1811: A5 41 jsr DrawBonusMeter ; $1813: 20 26 D8 lda $40 ; $1816: A5 40 beq Label_D83A ; $1818: F0 20 lda #$20 ; $181A: A9 20 sta $2006 ; $181C: 8D 06 20 lda #$75 ; $181F: A9 75 sta $2006 ; $1821: 8D 06 20 lda $42 ; $1824: A5 42 DrawBonusMeter: bmi Label_D83B ; $1826: 30 13 Label_D828: sta $50 ; $1828: 85 50 ldx #$06 ; $182A: A2 06 Label_D82C: lda #$24 ; $182C: A9 24 cpx $50 ; $182E: E4 50 bcs Label_D834 ; $1830: B0 02 lda #$2A ; $1832: A9 2A Label_D834: sta $2007 ; $1834: 8D 07 20 dex ; $1837: CA bpl Label_D82C ; $1838: 10 F2 Label_D83A: rts ; $183A: 60 Label_D83B: lda $40 ; $183B: A5 40 beq Label_D828 ; $183D: F0 E9 ldx #$08 ; $183F: A2 08 Label_D841: lda BonusLabelTiles,x ; $1841: BD 4B D8 sta $2007 ; $1844: 8D 07 20 dex ; $1847: CA bpl Label_D841 ; $1848: 10 F7 rts ; $184A: 60 BonusLabelTiles: .byte $1B, $0E, $1F, $18, $24, $0E, $16, $0A ; $184B: 1B 0E 1F 18 24 0E 16 0A .byte $10 ; $1853: 10 DrawBonusValueDigits: ldy #$04 ; $1854: A0 04 Label_D856: lda BonusDigitOffsetTable,y ; $1856: B9 6C D8 sta $2007 ; $1859: 8D 07 20 dey ; $185C: 88 bpl Label_D856 ; $185D: 10 F7 lda $4A ; $185F: A5 4A sta $2007 ; $1861: 8D 07 20 lda $49 ; $1864: A5 49 sta $2007 ; $1866: 8D 07 20 dec $46 ; $1869: C6 46 rts ; $186B: 60 BonusDigitOffsetTable: .byte $FB, $FA, $F9, $F8, $F7 ; $186C: FB FA F9 F8 F7 CreateBonusResultSprites: sta $12 ; $1871: 85 12 stx $13 ; $1873: 86 13 sty $14 ; $1875: 84 14 ldx #$01 ; $1877: A2 01 Label_D879: lda $061A,x ; $1879: BD 1A 06 bmi Label_D88C ; $187C: 30 0E dex ; $187E: CA bpl Label_D879 ; $187F: 10 F8 ldx #$01 ; $1881: A2 01 lda $0619 ; $1883: AD 19 06 cmp $0618 ; $1886: CD 18 06 bcc Label_D88C ; $1889: 90 01 dex ; $188B: CA Label_D88C: lda #$64 ; $188C: A9 64 sta $0618,x ; $188E: 9D 18 06 lda $12 ; $1891: A5 12 sta $061A,x ; $1893: 9D 1A 06 tay ; $1896: A8 txa ; $1897: 8A asl a ; $1898: 0A asl a ; $1899: 0A asl a ; $189A: 0A tax ; $189B: AA lda BonusSpriteTileTableA,y ; $189C: B9 D1 D8 sta $02F1,x ; $189F: 9D F1 02 lda BonusSpriteTileTableB,y ; $18A2: B9 D7 D8 sta $02F5,x ; $18A5: 9D F5 02 ldy $13 ; $18A8: A4 13 lda a:$009A,y ; $18AA: B9 9A 00 sec ; $18AD: 38 sbc #$08 ; $18AE: E9 08 sta $02F0,x ; $18B0: 9D F0 02 sta $02F4,x ; $18B3: 9D F4 02 lda a:$0091,y ; $18B6: B9 91 00 sta $02F3,x ; $18B9: 9D F3 02 clc ; $18BC: 18 adc #$08 ; $18BD: 69 08 sta $02F7,x ; $18BF: 9D F7 02 lda $3E ; $18C2: A5 3E sta $02F2,x ; $18C4: 9D F2 02 sta $02F6,x ; $18C7: 9D F6 02 ldy $14 ; $18CA: A4 14 ldx $13 ; $18CC: A6 13 lda $12 ; $18CE: A5 12 rts ; $18D0: 60 BonusSpriteTileTableA: .byte $F4, $F5, $F6, $F7, $F8, $F9 ; $18D1: F4 F5 F6 F7 F8 F9 BonusSpriteTileTableB: .byte $FB, $FB, $FA, $FB, $FB, $FB ; $18D7: FB FB FA FB FB FB UpdateBonusResultSprites: ldx #$01 ; $18DD: A2 01 Label_D8DF: lda $061A,x ; $18DF: BD 1A 06 bmi Label_D8FB ; $18E2: 30 17 dec $0618,x ; $18E4: DE 18 06 bne Label_D8FB ; $18E7: D0 12 lda #$FF ; $18E9: A9 FF sta $061A,x ; $18EB: 9D 1A 06 txa ; $18EE: 8A asl a ; $18EF: 0A asl a ; $18F0: 0A asl a ; $18F1: 0A tay ; $18F2: A8 lda #$F0 ; $18F3: A9 F0 sta $02F0,y ; $18F5: 99 F0 02 sta $02F4,y ; $18F8: 99 F4 02 Label_D8FB: dex ; $18FB: CA bpl Label_D8DF ; $18FC: 10 E1 rts ; $18FE: 60 ClearBonusResultSprites: ldx #$01 ; $18FF: A2 01 Label_D901: lda #$00 ; $1901: A9 00 sta $0618,x ; $1903: 9D 18 06 lda #$FF ; $1906: A9 FF sta $061A,x ; $1908: 9D 1A 06 dex ; $190B: CA bpl Label_D901 ; $190C: 10 F3 rts ; $190E: 60 Label_D90F: jsr $D246 ; $190F: 20 46 D2 jsr $C10A ; $1912: 20 0A C1 jsr $F465 ; $1915: 20 65 F4 jsr $C0FA ; $1918: 20 FA C0 lda #$2C ; $191B: A9 2C sta $1D ; $191D: 85 1D lda #$D9 ; $191F: A9 D9 sta $1E ; $1921: 85 1E jsr $D497 ; $1923: 20 97 D4 jsr $C104 ; $1926: 20 04 C1 jmp $C115 ; $1929: 4C 15 C1 ; Title/menu PPU command streams and tile data TitleScreenPpuData: .byte $30, $D9, $00, $00, $3F, $00, $04, $0F ; $192C: 30 D9 00 00 3F 00 04 0F .byte $30, $27, $2A, $3F, $18, $04, $0F, $16 ; $1934: 30 27 2A 3F 18 04 0F 16 .byte $30, $21, $20, $7C, $21, $F0, $F1, $24 ; $193C: 30 21 20 7C 21 F0 F1 24 .byte $24, $24, $24, $E0, $E1, $E1, $E2, $E0 ; $1944: 24 24 24 E0 E1 E1 E2 E0 .byte $E1, $E1, $E2, $E0, $E2, $24, $E0, $E2 ; $194C: E1 E1 E2 E0 E2 24 E0 E2 .byte $24, $E0, $E1, $E1, $E2, $E0, $E1, $E1 ; $1954: 24 E0 E1 E1 E2 E0 E1 E1 .byte $E2, $E0, $EC, $24, $E0, $E2, $20, $A2 ; $195C: E2 E0 EC 24 E0 E2 20 A2 .byte $1B, $E3, $E3, $E3, $E5, $E3, $E3, $E3 ; $1964: 1B E3 E3 E3 E5 E3 E3 E3 .byte $E5, $E3, $E5, $24, $E3, $E5, $24, $E3 ; $196C: E5 E3 E5 24 E3 E5 24 E3 .byte $E3, $E3, $E5, $E3, $E3, $E3, $E5, $E3 ; $1974: E3 E3 E5 E3 E3 E3 E5 E3 .byte $E3, $F3, $E3, $E5, $20, $C2, $1B, $E3 ; $197C: E3 F3 E3 E5 20 C2 1B E3 .byte $E4, $E3, $E7, $E3, $E4, $E3, $E5, $E3 ; $1984: E4 E3 E7 E3 E4 E3 E5 E3 .byte $E5, $24, $E3, $E5, $24, $E3, $E4, $E3 ; $198C: E5 24 E3 E5 24 E3 E4 E3 .byte $E5, $E3, $E4, $E3, $E5, $E3, $E3, $E3 ; $1994: E5 E3 E4 E3 E5 E3 E3 E3 .byte $E3, $E5, $20, $E2, $1B, $E3, $E3, $E3 ; $199C: E3 E5 20 E2 1B E3 E3 E3 .byte $E2, $E3, $E3, $E3, $E5, $E3, $E5, $24 ; $19A4: E2 E3 E3 E3 E5 E3 E5 24 .byte $E3, $E5, $24, $E3, $E3, $E3, $E5, $E3 ; $19AC: E3 E5 24 E3 E3 E3 E5 E3 .byte $E3, $E3, $E5, $E3, $E3, $E3, $E3, $E5 ; $19B4: E3 E3 E5 E3 E3 E3 E3 E5 .byte $21, $02, $1B, $E3, $E4, $E3, $E5, $E3 ; $19BC: 21 02 1B E3 E4 E3 E5 E3 .byte $F2, $E3, $E5, $E3, $E3, $E2, $E3, $E3 ; $19C4: F2 E3 E5 E3 E3 E2 E3 E3 .byte $E2, $E3, $E3, $E3, $E5, $E3, $E3, $E3 ; $19CC: E2 E3 E3 E3 E5 E3 E3 E3 .byte $E5, $E3, $F2, $E3, $E3, $E5, $21, $22 ; $19D4: E5 E3 F2 E3 E3 E5 21 22 .byte $1B, $E6, $E3, $E3, $E7, $EB, $24, $E6 ; $19DC: 1B E6 E3 E3 E7 EB 24 E6 .byte $E7, $E6, $E3, $E7, $E6, $E3, $E7, $E6 ; $19E4: E7 E6 E3 E7 E6 E3 E7 E6 .byte $E3, $E3, $E7, $E6, $E3, $E3, $E7, $EB ; $19EC: E3 E3 E7 E6 E3 E3 E7 EB .byte $24, $E6, $E3, $E7, $21, $4C, $12, $E0 ; $19F4: 24 E6 E3 E7 21 4C 12 E0 .byte $E1, $E1, $E2, $E0, $E2, $E0, $E1, $E1 ; $19FC: E1 E1 E2 E0 E2 E0 E1 E1 .byte $E2, $E8, $24, $E0, $E2, $E0, $E1, $E1 ; $1A04: E2 E8 24 E0 E2 E0 E1 E1 .byte $E2, $21, $6C, $12, $E3, $E3, $E3, $E7 ; $1A0C: E2 21 6C 12 E3 E3 E3 E7 .byte $E3, $E5, $E3, $F5, $F6, $E7, $E3, $F3 ; $1A14: E3 E5 E3 F5 F6 E7 E3 F3 .byte $E3, $E5, $E6, $E3, $E3, $E7, $21, $8C ; $1A1C: E3 E5 E6 E3 E3 E7 21 8C .byte $12, $E3, $E3, $EF, $24, $E3, $E5, $E3 ; $1A24: 12 E3 E3 EF 24 E3 E5 E3 .byte $24, $24, $24, $E3, $E3, $E3, $E5, $24 ; $1A2C: 24 24 24 E3 E3 E3 E5 24 .byte $E3, $E5, $24, $21, $AC, $12, $E3, $E3 ; $1A34: E3 E5 24 21 AC 12 E3 E3 .byte $E1, $EA, $E3, $E5, $E3, $E9, $E3, $E2 ; $1A3C: E1 EA E3 E5 E3 E9 E3 E2 .byte $E3, $E3, $E3, $E5, $24, $E3, $E5, $24 ; $1A44: E3 E3 E3 E5 24 E3 E5 24 .byte $21, $CC, $12, $E3, $E3, $EF, $24, $E3 ; $1A4C: 21 CC 12 E3 E3 EF 24 E3 .byte $E5, $E3, $F3, $E3, $E5, $E3, $F2, $E3 ; $1A54: E5 E3 F3 E3 E5 E3 F2 E3 .byte $E5, $24, $E3, $E5, $24, $21, $EC, $12 ; $1A5C: E5 24 E3 E5 24 21 EC 12 .byte $E6, $E7, $24, $24, $E6, $E7, $E6, $E7 ; $1A64: E6 E7 24 24 E6 E7 E6 E7 .byte $E6, $E7, $EB, $24, $E6, $E7, $24, $E6 ; $1A6C: E6 E7 EB 24 E6 E7 24 E6 .byte $E7, $24, $22, $48, $10, $0A, $24, $24 ; $1A74: E7 24 22 48 10 0A 24 24 .byte $01, $25, $19, $15, $0A, $22, $0E, $1B ; $1A7C: 01 25 19 15 0A 22 0E 1B .byte $24, $10, $0A, $16, $0E, $22, $88, $10 ; $1A84: 24 10 0A 16 0E 22 88 10 .byte $0B, $24, $24, $02, $25, $19, $15, $0A ; $1A8C: 0B 24 24 02 25 19 15 0A .byte $22, $0E, $1B, $24, $10, $0A, $16, $0E ; $1A94: 22 0E 1B 24 10 0A 16 0E .byte $22, $C8, $10, $0C, $24, $24, $0B, $0A ; $1A9C: 22 C8 10 0C 24 24 0B 0A .byte $15, $15, $18, $18, $17, $24, $24, $1D ; $1AA4: 15 15 18 18 17 24 24 1D .byte $1B, $12, $19, $23, $49, $0E, $F4, $01 ; $1AAC: 1B 12 19 23 49 0E F4 01 .byte $09, $08, $04, $24, $17, $12, $17, $1D ; $1AB4: 09 08 04 24 17 12 17 1D .byte $0E, $17, $0D, $18, $00 ; $1ABC: 0E 17 0D 18 00 RunTitleMenuLoop: jsr $C104 ; $1AC1: 20 04 C1 jsr $D90F ; $1AC4: 20 0F D9 lda #$00 ; $1AC7: A9 00 sta $19 ; $1AC9: 85 19 Label_DACB: jsr $F465 ; $1ACB: 20 65 F4 lda $19 ; $1ACE: A5 19 beq Label_DAF1 ; $1AD0: F0 1F jsr ApplySelectedGameMode ; $1AD2: 20 08 DB jsr $E768 ; $1AD5: 20 68 E7 tax ; $1AD8: AA and #$10 ; $1AD9: 29 10 bne Label_DAF0 ; $1ADB: D0 13 txa ; $1ADD: 8A and #$20 ; $1ADE: 29 20 beq Label_DAED ; $1AE0: F0 0B lda #$00 ; $1AE2: A9 00 sta $19 ; $1AE4: 85 19 ldx $3F ; $1AE6: A6 3F lda GameModePlayerCountTable,x ; $1AE8: BD 05 DB sta $3F ; $1AEB: 85 3F Label_DAED: jmp Label_DACB ; $1AED: 4C CB DA Label_DAF0: rts ; $1AF0: 60 Label_DAF1: inc $3A ; $1AF1: E6 3A inc $40 ; $1AF3: E6 40 lda #$00 ; $1AF5: A9 00 sta $4015 ; $1AF7: 8D 15 40 sta $16 ; $1AFA: 85 16 jsr $F1F2 ; $1AFC: 20 F2 F1 lda #$00 ; $1AFF: A9 00 sta $3A ; $1B01: 85 3A beq RunTitleMenuLoop ; $1B03: F0 BC GameModePlayerCountTable: ora ($02,x) ; $1B05: 01 02 brk ; $1B07: 00 ApplySelectedGameMode: lda $3F ; $1B08: A5 3F lsr a ; $1B0A: 4A sta $16 ; $1B0B: 85 16 lda $3F ; $1B0D: A5 3F tax ; $1B0F: AA and #$01 ; $1B10: 29 01 sta $40 ; $1B12: 85 40 lda StageDataPointerTableLo,x ; $1B14: BD 27 DB sta $057B ; $1B17: 8D 7B 05 lda #$2C ; $1B1A: A9 2C sta $0567 ; $1B1C: 8D 67 05 ldx #$00 ; $1B1F: A2 00 stx $055D ; $1B21: 8E 5D 05 jmp $CE2F ; $1B24: 4C 2F CE ;=============================================================================== ; Stage data tables ; CPU $DB27-$E3A3 / PRG $1B27-$23A3 ; Mode selection, stage stream pointers, PPU command streams, object placement, ; boundary data, and stage setup pointer tables. ;=============================================================================== StageDataPointerTableLo: GameModeInitialStageTable: .byte $8C, $9C, $AC ; $1B27: 8C 9C AC StageStreamPointerLoTable: .byte $4A, $59, $F2, $6C, $77, $88, $E1, $6C ; $1B2A: 4A 59 F2 6C 77 88 E1 6C .byte $99, $03, $CA, $6C, $AD, $17, $E1, $6C ; $1B32: 99 03 CA 6C AD 17 E1 6C StageStreamPointerHiTable: .byte $DB, $DB, $DB, $DB, $DB, $DB, $DB, $DB ; $1B3A: DB DB DB DB DB DB DB DB .byte $DB, $DC, $DB, $DB, $DB, $DC, $DB, $DB ; $1B42: DB DC DB DB DB DC DB DB StageStream_00: StageStream_00_Target: .byte $2B, $DC, $39, $DD, $00, $00, $10, $06 ; $1B4A: 2B DC 39 DD 00 00 10 06 .byte $FF, $FF, $96, $DF, $02, $7A, $DE ; $1B52: FF FF 96 DF 02 7A DE StageStream_01: StageStream_01_Target: .byte $2B, $DC, $39, $DD, $4B, $DD, $00, $00 ; $1B59: 2B DC 39 DD 4B DD 00 00 .byte $18, $0C, $04, $0E, $FF, $FF, $A0, $DF ; $1B61: 18 0C 04 0E FF FF A0 DF .byte $04, $86, $DE ; $1B69: 04 86 DE StageStream_02: StageStream_03_Target: StageStream_07_Target: StageStream_0B_Target: StageStream_0F_Target: .byte $CA, $DC, $00, $00, $FF, $FF, $B0, $DF ; $1B6C: CA DC 00 00 FF FF B0 DF .byte $00, $9A, $DE ; $1B74: 00 9A DE StageStream_03: StageStream_04_Target: .byte $2B, $DC, $5E, $DD, $00, $00, $08, $06 ; $1B77: 2B DC 5E DD 00 00 08 06 .byte $18, $0A, $FF, $FF, $B1, $DF, $06, $9E ; $1B7F: 18 0A FF FF B1 DF 06 9E .byte $DE ; $1B87: DE StageStream_05_Target: .byte $2B, $DC, $7D ; $1B88: 2B DC 7D StageStream_04: .byte $DD, $00, $00, $04, $06, $12, $08, $FF ; $1B8B: DD 00 00 04 06 12 08 FF .byte $FF, $C1, $DF, $07, $BA, $DE ; $1B93: FF C1 DF 07 BA DE StageStream_08_Target: .byte $2B, $DC, $A3, $DD ; $1B99: 2B DC A3 DD StageStream_05: .byte $00, $00, $06, $06, $14, $10, $FF, $0F ; $1B9D: 00 00 06 06 14 10 FF 0F .byte $0D, $01, $FF, $D4, $DF, $09, $DA, $DE ; $1BA5: 0D 01 FF D4 DF 09 DA DE StageStream_0C_Target: .byte $2B ; $1BAD: 2B StageStream_06: .byte $DC, $CE, $DD, $00, $00, $04, $06, $10 ; $1BAE: DC CE DD 00 00 04 06 10 .byte $0E, $FF, $08, $0E, $03, $0D, $09, $03 ; $1BB6: 0E FF 08 0E 03 0D 09 03 .byte $12, $08, $03, $17, $0D, $03, $FF, $E7 ; $1BBE: 12 08 03 17 0D 03 FF E7 .byte $DF, $03, $02, $DF ; $1BC6: DF 03 02 DF StageStream_07: StageStream_0A_Target: .byte $2B, $DC, $5E, $DD, $00, $00, $10, $06 ; $1BCA: 2B DC 5E DD 00 00 10 06 .byte $1A, $0C, $FF, $08, $08, $01, $18, $04 ; $1BD2: 1A 0C FF 08 08 01 18 04 .byte $01, $FF, $B1, $DF, $06 ; $1BDA: 01 FF B1 DF 06 StageStream_08: .byte $9E, $DE ; $1BDF: 9E DE StageStream_06_Target: StageStream_0E_Target: .byte $2B, $DC, $DB, $DD, $00, $00, $0E, $06 ; $1BE1: 2B DC DB DD 00 00 0E 06 .byte $0C, $14, $FF, $FF, $F7 ; $1BE9: 0C 14 FF FF F7 StageStream_09: .byte $DF, $06, $12, $DF ; $1BEE: DF 06 12 DF StageStream_02_Target: .byte $2B, $DC, $01, $DE, $00, $00, $04, $08 ; $1BF2: 2B DC 01 DE 00 00 04 08 .byte $16, $10, $FF, $FF, $07, $E0, $09 ; $1BFA: 16 10 FF FF 07 E0 09 StageStream_0A: .byte $2E, $DF ; $1C01: 2E DF StageStream_09_Target: .byte $2B, $DC, $32, $DE, $00, $00, $04, $10 ; $1C03: 2B DC 32 DE 00 00 04 10 .byte $18, $10, $FF, $0E, $06, $01, $FF, $17 ; $1C0B: 18 10 FF 0E 06 01 FF 17 .byte $E0, $07, $56, $DF ; $1C13: E0 07 56 DF StageStream_0B: StageStream_0D_Target: .byte $2B, $DC, $5B, $DE, $00, $00, $04, $08 ; $1C17: 2B DC 5B DE 00 00 04 08 .byte $0E, $10, $FF, $10, $07, $01, $FF, $2A ; $1C1F: 0E 10 FF 10 07 01 FF 2A .byte $E0, $07, $76, $DF ; $1C27: E0 07 76 DF StagePpuData_Common: .byte $23, $40, $88, $39, $38, $39, $38, $39 ; $1C2B: 23 40 88 39 38 39 38 39 .byte $38, $39, $33, $24, $24, $24, $24, $24 ; $1C33: 38 39 33 24 24 24 24 24 .byte $24, $24, $24, $24, $24, $24, $24, $24 ; $1C3B: 24 24 24 24 24 24 24 24 .byte $24, $24, $24, $30, $38, $39, $38, $39 ; $1C43: 24 24 24 30 38 39 38 39 .byte $38, $39, $38, $3C, $3B, $3C, $3B, $3C ; $1C4B: 38 39 38 3C 3B 3C 3B 3C .byte $3B, $3C, $3D, $58, $59, $5A, $5B, $58 ; $1C53: 3B 3C 3D 58 59 5A 5B 58 .byte $59, $5A, $5B, $58, $59, $5A, $5B, $58 ; $1C5B: 59 5A 5B 58 59 5A 5B 58 .byte $59, $5A, $5B, $3A, $3B, $3C, $3B, $3C ; $1C63: 59 5A 5B 3A 3B 3C 3B 3C .byte $3B, $3C, $3B, $60, $61, $62, $63, $60 ; $1C6B: 3B 3C 3B 60 61 62 63 60 .byte $61, $62, $63, $5C, $5D, $5E, $5F, $5C ; $1C73: 61 62 63 5C 5D 5E 5F 5C .byte $5D, $5E, $5F, $5C, $5D, $5E, $5F, $5C ; $1C7B: 5D 5E 5F 5C 5D 5E 5F 5C .byte $5D, $5E, $5F, $60, $61, $62, $63, $60 ; $1C83: 5D 5E 5F 60 61 62 63 60 .byte $61, $62, $63, $5C, $5D, $5E, $5F, $5C ; $1C8B: 61 62 63 5C 5D 5E 5F 5C .byte $5D, $5E, $5F, $5C, $5D, $5E, $5F, $5C ; $1C93: 5D 5E 5F 5C 5D 5E 5F 5C .byte $5D, $5E, $5F, $5C, $5D, $5E, $5F, $5C ; $1C9B: 5D 5E 5F 5C 5D 5E 5F 5C .byte $5D, $5E, $5F, $5C, $5D, $5E, $5F, $5C ; $1CA3: 5D 5E 5F 5C 5D 5E 5F 5C .byte $5D, $5E, $5F ; $1CAB: 5D 5E 5F NametableHeaderPatternData: .byte $40, $50, $50, $50, $50, $90, $A0, $A0 ; $1CAE: 40 50 50 50 50 90 A0 A0 .byte $23, $F0, $10, $00, $00, $A0, $A0, $A0 ; $1CB6: 23 F0 10 00 00 A0 A0 A0 .byte $A0, $00, $00, $0A, $0A, $0A, $0A, $0A ; $1CBE: A0 00 00 0A 0A 0A 0A 0A .byte $0A, $0A, $0A, $00, $A3, $04, $04, $93 ; $1CC6: 0A 0A 0A 00 A3 04 04 93 .byte $94, $94, $94, $A3, $05, $04, $95, $96 ; $1CCE: 94 94 94 A3 05 04 95 96 .byte $96, $96, $A2, $EA, $05, $93, $94, $94 ; $1CD6: 96 96 A2 EA 05 93 94 94 .byte $94, $94, $A2, $EB, $05, $95, $96, $96 ; $1CDE: 94 94 A2 EB 05 95 96 96 .byte $96, $96, $A3, $34, $03, $93, $94, $94 ; $1CE6: 96 96 A3 34 03 93 94 94 .byte $A3, $35, $03, $95, $96, $96, $A3, $1A ; $1CEE: A3 35 03 95 96 96 A3 1A .byte $04, $93, $94, $94, $94, $A3, $1B, $04 ; $1CF6: 04 93 94 94 94 A3 1B 04 .byte $95, $96, $96, $96, $63, $80, $20, $97 ; $1CFE: 95 96 96 96 63 80 20 97 .byte $23, $A0, $20, $98, $99, $98, $99, $98 ; $1D06: 23 A0 20 98 99 98 99 98 .byte $99, $98, $99, $98, $99, $98, $99, $98 ; $1D0E: 99 98 99 98 99 98 99 98 .byte $99, $98, $99, $98, $99, $98, $99, $98 ; $1D16: 99 98 99 98 99 98 99 98 .byte $99, $98, $99, $98, $99, $98, $99, $98 ; $1D1E: 99 98 99 98 99 98 99 98 .byte $99, $98, $99, $23, $C0, $08, $40, $50 ; $1D26: 99 98 99 23 C0 08 40 50 .byte $50, $50, $50, $90, $A0, $A0, $63, $E8 ; $1D2E: 50 50 50 90 A0 A0 63 E8 .byte $10, $FF, $00 ; $1D36: 10 FF 00 StagePpuLayoutData: .byte $22, $49, $0E, $30, $31, $32, $31, $32 ; $1D39: 22 49 0E 30 31 32 31 32 .byte $31, $32, $31, $32, $31, $32, $31, $32 ; $1D41: 31 32 31 32 31 32 31 32 .byte $33, $00, $21, $57, $06, $30, $31, $32 ; $1D49: 33 00 21 57 06 30 31 32 .byte $31, $32, $33, $21, $65, $06, $30, $31 ; $1D51: 31 32 33 21 65 06 30 31 .byte $32, $31, $32, $33, $00, $21, $90, $03 ; $1D59: 32 31 32 33 00 21 90 03 .byte $30, $31, $33, $22, $26, $03, $30, $31 ; $1D61: 30 31 33 22 26 03 30 31 .byte $33, $22, $57, $03, $30, $31, $33, $22 ; $1D69: 33 22 57 03 30 31 33 22 .byte $6C, $03, $30, $31, $33, $22, $F2, $03 ; $1D71: 6C 03 30 31 33 22 F2 03 .byte $30, $31, $33, $00, $20, $CB, $03, $30 ; $1D79: 30 31 33 00 20 CB 03 30 .byte $31, $33, $A1, $6D, $03, $3E, $3F, $40 ; $1D81: 31 33 A1 6D 03 3E 3F 40 .byte $A1, $59, $04, $3E, $3F, $3F, $40, $A1 ; $1D89: A1 59 04 3E 3F 3F 40 A1 .byte $A5, $03, $3E, $3F, $40, $22, $AA, $03 ; $1D91: A5 03 3E 3F 40 22 AA 03 .byte $30, $31, $33, $22, $B3, $03, $30, $31 ; $1D99: 30 31 33 22 B3 03 30 31 .byte $33, $00, $20, $E2, $02, $30, $33, $20 ; $1DA1: 33 00 20 E2 02 30 33 20 .byte $FB, $02, $30, $33, $21, $57, $02, $30 ; $1DA9: FB 02 30 33 21 57 02 30 .byte $33, $21, $93, $02, $30, $33, $22, $0B ; $1DB1: 33 21 93 02 30 33 22 0B .byte $02, $30, $33, $22, $47, $02, $30, $33 ; $1DB9: 02 30 33 22 47 02 30 33 .byte $22, $83, $02, $30, $33, $22, $CF, $04 ; $1DC1: 22 83 02 30 33 22 CF 04 .byte $30, $31, $32, $33, $00, $22, $CA, $03 ; $1DC9: 30 31 32 33 00 22 CA 03 .byte $30, $31, $33, $22, $D2, $03, $30, $31 ; $1DD1: 30 31 33 22 D2 03 30 31 .byte $33, $00, $21, $08, $04, $30, $31, $32 ; $1DD9: 33 00 21 08 04 30 31 32 .byte $33, $21, $14, $04, $30, $31, $32, $33 ; $1DE1: 33 21 14 04 30 31 32 33 .byte $A1, $A5, $04, $3E, $3F, $3F, $40, $A1 ; $1DE9: A1 A5 04 3E 3F 3F 40 A1 .byte $BA, $04, $3E, $3F, $3F, $40, $22, $6C ; $1DF1: BA 04 3E 3F 3F 40 22 6C .byte $06, $30, $31, $32, $31, $32, $33, $00 ; $1DF9: 06 30 31 32 31 32 33 00 .byte $22, $EE, $04, $30, $31, $32, $33, $20 ; $1E01: 22 EE 04 30 31 32 33 20 .byte $F9, $03, $30, $31, $33, $A1, $1A, $03 ; $1E09: F9 03 30 31 33 A1 1A 03 .byte $3F, $3F, $40, $21, $90, $03, $30, $31 ; $1E11: 3F 3F 40 21 90 03 30 31 .byte $33, $A1, $B1, $03, $3F, $3F, $40, $22 ; $1E19: 33 A1 B1 03 3F 3F 40 22 .byte $28, $03, $30, $31, $33, $A2, $49, $03 ; $1E21: 28 03 30 31 33 A2 49 03 .byte $3F, $3F, $40, $20, $EA, $02, $30, $33 ; $1E29: 3F 3F 40 20 EA 02 30 33 .byte $00, $A2, $6C, $03, $3E, $3F, $40, $A2 ; $1E31: 00 A2 6C 03 3E 3F 40 A2 .byte $73, $03, $3E, $3F, $40, $20, $E4, $04 ; $1E39: 73 03 3E 3F 40 20 E4 04 .byte $30, $31, $32, $33, $20, $F8, $04, $30 ; $1E41: 30 31 32 33 20 F8 04 30 .byte $31, $32, $33, $21, $A8, $04, $30, $31 ; $1E49: 31 32 33 21 A8 04 30 31 .byte $32, $33, $21, $B5, $04, $30, $31, $32 ; $1E51: 32 33 21 B5 04 30 31 32 .byte $33, $00, $22, $64, $02, $30, $33, $22 ; $1E59: 33 00 22 64 02 30 33 22 .byte $08, $02, $30, $33, $21, $AC, $02, $30 ; $1E61: 08 02 30 33 21 AC 02 30 .byte $33, $21, $B4, $02, $30, $33, $22, $18 ; $1E69: 33 21 B4 02 30 33 22 18 .byte $02, $30, $33, $22, $7C, $02, $30, $33 ; $1E71: 02 30 33 22 7C 02 30 33 .byte $00, $10, $C8, $48, $38, $FF, $B8, $CF ; $1E79: 00 10 C8 48 38 FF B8 CF .byte $CF, $8F, $E0, $E0, $98, $10, $C4, $48 ; $1E81: CF 8F E0 E0 98 10 C4 48 .byte $B8, $28, $3C, $FF, $B8, $E8, $58, $CF ; $1E89: B8 28 3C FF B8 E8 58 CF .byte $CF, $8F, $4F, $57, $E0, $E0, $98, $58 ; $1E91: CF 8F 4F 57 E0 E0 98 58 .byte $60, $10, $FF, $DF, $EC, $10, $C8, $80 ; $1E99: 60 10 FF DF EC 10 C8 80 .byte $30, $B8, $60, $90, $38, $FF, $98, $48 ; $1EA1: 30 B8 60 90 38 FF 98 48 .byte $D0, $78, $A8, $CF, $CF, $5F, $87, $8F ; $1EA9: D0 78 A8 CF CF 5F 87 8F .byte $97, $B7, $E0, $E0, $68, $90, $98, $A0 ; $1EB1: 97 B7 E0 E0 68 90 98 A0 .byte $C0, $10, $C8, $58, $68, $C8, $28, $50 ; $1EB9: C0 10 C8 58 68 C8 28 50 .byte $98, $38, $FF, $70, $78, $D0, $30, $68 ; $1EC1: 98 38 FF 70 78 D0 30 68 .byte $B0, $CF, $CF, $2F, $57, $4F, $67, $A7 ; $1EC9: B0 CF CF 2F 57 4F 67 A7 .byte $A7, $E0, $E0, $38, $6C, $6C, $7C, $B0 ; $1ED1: A7 E0 E0 38 6C 6C 7C B0 .byte $B0, $10, $C8, $12, $DA, $BA, $9A, $5A ; $1ED9: B0 10 C8 12 DA BA 9A 5A .byte $3A, $1A, $7A, $38, $FF, $1E, $E6, $C6 ; $1EE1: 3A 1A 7A 38 FF 1E E6 C6 .byte $A6, $66, $46, $26, $96, $CF, $CF, $37 ; $1EE9: A6 66 46 26 96 CF CF 37 .byte $37, $4F, $5F, $7F, $8F, $9F, $AF, $E0 ; $1EF1: 37 4F 5F 7F 8F 9F AF E0 .byte $E0, $40, $40, $58, $68, $88, $98, $A8 ; $1EF9: E0 40 40 58 68 88 98 A8 .byte $B8, $10, $C8, $52, $92, $38, $FF, $66 ; $1F01: B8 10 C8 52 92 38 FF 66 .byte $A6, $CF, $CF, $AF, $AF, $E0, $E0, $B8 ; $1F09: A6 CF CF AF AF E0 E0 B8 .byte $B8, $10, $C8, $40, $A0, $28, $D0, $60 ; $1F11: B8 10 C8 40 A0 28 D0 60 .byte $38, $FF, $60, $C0, $30, $D8, $90, $CF ; $1F19: 38 FF 60 C0 30 D8 90 CF .byte $CF, $3F, $3F, $67, $67, $97, $E0, $E0 ; $1F21: CF 3F 3F 67 67 97 E0 E0 .byte $48, $48, $88, $88, $A0, $10, $C8, $50 ; $1F29: 48 48 88 88 A0 10 C8 50 .byte $C8, $88, $40, $70, $D0, $88, $48, $38 ; $1F31: C8 88 40 70 D0 88 48 38 .byte $FF, $60, $E0, $98, $58, $90, $D8, $90 ; $1F39: FF 60 E0 98 58 90 D8 90 .byte $50, $CF, $CF, $37, $37, $5F, $87, $B7 ; $1F41: 50 CF CF 37 37 5F 87 B7 .byte $3C, $64, $8C, $E0, $E0, $40, $40, $68 ; $1F49: 3C 64 8C E0 E0 40 40 68 .byte $90, $C0, $60, $80, $A8, $10, $C8, $20 ; $1F51: 90 C0 60 80 A8 10 C8 20 .byte $C0, $40, $A8, $60, $98, $38, $FF, $40 ; $1F59: C0 40 A8 60 98 38 FF 40 .byte $E0, $60, $C8, $68, $A0, $CF, $CF, $37 ; $1F61: E0 60 C8 68 A0 CF CF 37 .byte $37, $67, $67, $97, $97, $E0, $E0, $40 ; $1F69: 37 67 67 97 97 E0 E0 40 .byte $40, $70, $70, $B0, $B0, $10, $C8, $20 ; $1F71: 40 70 70 B0 B0 10 C8 20 .byte $40, $60, $A0, $C0, $E0, $38, $FF, $30 ; $1F79: 40 60 A0 C0 E0 38 FF 30 .byte $50, $70, $B0, $D0, $F0, $CF, $CF, $97 ; $1F81: 50 70 B0 D0 F0 CF CF 97 .byte $7F, $67, $67, $7F, $97, $E0, $E0, $A0 ; $1F89: 7F 67 67 7F 97 E0 E0 A0 .byte $88, $70, $70, $88, $A0, $03, $58, $78 ; $1F91: 88 70 70 88 A0 03 58 78 .byte $04, $78, $78, $04, $98, $78, $04, $05 ; $1F99: 04 78 78 04 98 78 04 05 .byte $C8, $38, $05, $38, $40, $05, $58, $78 ; $1FA1: C8 38 05 38 40 05 58 78 .byte $04, $78, $78, $04, $98, $78, $04, $00 ; $1FA9: 04 78 78 04 98 78 04 00 .byte $05, $94, $A0, $06, $84, $48, $05, $34 ; $1FB1: 05 94 A0 06 84 48 05 34 .byte $70, $04, $64, $80, $04, $BC, $78, $04 ; $1FB9: 70 04 64 80 04 BC 78 04 .byte $06, $5C, $18, $06, $24, $50, $05, $64 ; $1FC1: 06 5C 18 06 24 50 05 64 .byte $40, $05, $C4, $38, $05, $54, $90, $04 ; $1FC9: 40 05 C4 38 05 54 90 04 .byte $9C, $90, $04, $06, $10, $20, $06, $D8 ; $1FD1: 9C 90 04 06 10 20 06 D8 .byte $20, $06, $B8, $38, $05, $98, $48, $05 ; $1FD9: 20 06 B8 38 05 98 48 05 .byte $58, $68, $05, $38, $78, $04, $05, $54 ; $1FE1: 58 68 05 38 78 04 05 54 .byte $98, $05, $94, $98, $05, $6C, $39, $06 ; $1FE9: 98 05 94 98 05 6C 39 06 .byte $94, $31, $06, $BC, $59, $06, $05, $50 ; $1FF1: 94 31 06 BC 59 06 05 50 .byte $28, $06, $A8, $28, $06, $24, $50, $06 ; $1FF9: 28 06 A8 28 06 24 50 06 .byte $CC, $50, $06, $70, $80, $04, $05, $50 ; $2001: CC 50 06 70 80 04 05 50 .byte $20, $06, $C8, $20, $06, $84, $48, $05 ; $2009: 20 06 C8 20 06 84 48 05 .byte $44, $70, $05, $78, $A0, $04, $06, $28 ; $2011: 44 70 05 78 A0 04 06 28 .byte $20, $06, $C8, $20, $06, $48, $50, $05 ; $2019: 20 06 C8 20 06 48 50 05 .byte $B0, $50, $05, $5C, $80, $04, $94, $80 ; $2021: B0 50 05 5C 80 04 94 80 .byte $04, $06, $20, $80, $04, $40, $68, $05 ; $2029: 04 06 20 80 04 40 68 05 .byte $60, $50, $06, $A0, $50, $06, $C0, $68 ; $2031: 60 50 06 A0 50 06 C0 68 .byte $05, $E0, $80, $04 ; $2039: 05 E0 80 04 StageObjectPointerData: .byte $08, $08, $F0, $08, $08, $00, $00, $00 ; $203D: 08 08 F0 08 08 00 00 00 .byte $00, $08, $08, $08, $00, $00, $01, $08 ; $2045: 00 08 08 08 00 00 01 08 .byte $08, $09, $00, $00, $FF, $08, $08, $07 ; $204D: 08 09 00 00 FF 08 08 07 .byte $FE, $00, $00, $06, $08, $08, $02, $00 ; $2055: FE 00 00 06 08 08 02 00 .byte $00, $0A, $08, $08, $02, $00, $01, $0A ; $205D: 00 0A 08 08 02 00 01 0A .byte $08, $09, $04, $00, $00, $0C, $08, $08 ; $2065: 08 09 04 00 00 0C 08 08 .byte $00, $00, $FE, $08, $08, $06, $FD, $FD ; $206D: 00 00 FE 08 08 06 FD FD .byte $FD, $05, $05, $05, $08, $08, $08, $00 ; $2075: FD 05 05 05 08 08 08 00 .byte $00, $00, $08, $08, $07, $00, $00, $FF ; $207D: 00 00 08 08 07 00 00 FF .byte $08, $08, $09, $00, $00, $01, $0A, $08 ; $2085: 08 08 09 00 00 01 0A 08 .byte $08, $02, $00, $00, $06, $08, $08, $FE ; $208D: 08 02 00 00 06 08 08 FE .byte $00, $00, $06, $08, $07, $FE, $00, $FF ; $2095: 00 00 06 08 07 FE 00 FF .byte $04, $08, $08, $FC, $00, $00, $08, $08 ; $209D: 04 08 08 FC 00 00 08 08 .byte $0A, $00, $00, $02, $0B, $0B, $0B, $03 ; $20A5: 0A 00 00 02 0B 0B 0B 03 .byte $03, $03, $00, $00, $01, $02, $03, $04 ; $20AD: 03 03 00 00 01 02 03 04 .byte $05, $00, $00, $01, $02, $03, $06, $07 ; $20B5: 05 00 00 01 02 03 06 07 .byte $00, $00, $01, $02, $03, $06, $08, $00 ; $20BD: 00 00 01 02 03 06 08 00 .byte $09, $0A, $02, $0B, $0C, $05, $00, $00 ; $20C5: 09 0A 02 0B 0C 05 00 00 .byte $01, $02, $03, $04, $05, $00, $00, $01 ; $20CD: 01 02 03 04 05 00 00 01 .byte $02, $0D, $0E, $05, $00, $1A, $1B, $1C ; $20D5: 02 0D 0E 05 00 1A 1B 1C .byte $1D, $1E, $1F, $01, $1A, $1B, $20, $1D ; $20DD: 1D 1E 1F 01 1A 1B 20 1D .byte $1E, $FC, $00, $1A, $21, $22, $1D, $23 ; $20E5: 1E FC 00 1A 21 22 1D 23 .byte $24, $00, $00, $38, $35, $0D, $39, $37 ; $20ED: 24 00 00 38 35 0D 39 37 .byte $00, $00, $34, $35, $03, $36, $37, $00 ; $20F5: 00 00 34 35 03 36 37 00 .byte $09, $3A, $35, $0B, $3B, $37, $00, $CE ; $20FD: 09 3A 35 0B 3B 37 00 CE .byte $CF, $D0, $D1, $D2, $D3, $00, $25, $26 ; $2105: CF D0 D1 D2 D3 00 25 26 .byte $27, $28, $29, $2A, $01, $28, $29, $2C ; $210D: 27 28 29 2A 01 28 29 2C .byte $25, $26, $2B, $00, $4C, $CC, $02, $4D ; $2115: 25 26 2B 00 4C CC 02 4D .byte $CD, $05, $00, $4C, $2F, $22, $4D, $30 ; $211D: CD 05 00 4C 2F 22 4D 30 .byte $24, $07, $4C, $2F, $35, $4D, $30, $37 ; $2125: 24 07 4C 2F 35 4D 30 37 .byte $02, $4C, $2F, $27, $4D, $30, $2A, $07 ; $212D: 02 4C 2F 27 4D 30 2A 07 .byte $4C, $2F, $2B, $4D, $30, $2C, $00, $0F ; $2135: 4C 2F 2B 4D 30 2C 00 0F .byte $10, $02, $11, $12, $05, $00, $0F, $10 ; $213D: 10 02 11 12 05 00 0F 10 .byte $02, $11, $19, $07, $00, $0F, $10, $02 ; $2145: 02 11 19 07 00 0F 10 02 .byte $11, $19, $08, $00, $13, $14, $02, $15 ; $214D: 11 19 08 00 13 14 02 15 .byte $16, $05, $00, $0F, $10, $02, $11, $12 ; $2155: 16 05 00 0F 10 02 11 12 .byte $05, $03, $13, $17, $02, $15, $18, $05 ; $215D: 05 03 13 17 02 15 18 05 .byte $04, $13, $2D, $1C, $15, $2E, $1F, $05 ; $2165: 04 13 2D 1C 15 2E 1F 05 .byte $13, $2D, $20, $15, $2E, $FC, $04, $13 ; $216D: 13 2D 20 15 2E FC 04 13 .byte $2F, $22, $15, $30, $24, $00, $13, $3C ; $2175: 2F 22 15 30 24 00 13 3C .byte $35, $15, $3D, $37, $00, $0F, $40, $35 ; $217D: 35 15 3D 37 00 0F 40 35 .byte $11, $41, $37, $03, $13, $3E, $35, $15 ; $2185: 11 41 37 03 13 3E 35 15 .byte $3F, $37, $00, $D4, $D5, $D0, $D6, $D7 ; $218D: 3F 37 00 D4 D5 D0 D6 D7 .byte $D3, $00, $25, $31, $27, $32, $33, $2A ; $2195: D3 00 25 31 27 32 33 2A .byte $02, $25, $31, $27, $32, $33, $2A, $00 ; $219D: 02 25 31 27 32 33 2A 00 .byte $FC, $48, $42, $FC, $49, $43, $00, $FC ; $21A5: FC 48 42 FC 49 43 00 FC .byte $48, $44, $FC, $49, $45, $00, $FC, $4A ; $21AD: 48 44 FC 49 45 00 FC 4A .byte $46, $FC, $4B, $47, $00, $FC, $A4, $A5 ; $21B5: 46 FC 4B 47 00 FC A4 A5 .byte $FC, $A6, $A7, $08, $FC, $71, $FC, $FC ; $21BD: FC A6 A7 08 FC 71 FC FC .byte $72, $73, $08, $FC, $74, $FC, $FC, $75 ; $21C5: 72 73 08 FC 74 FC FC 75 .byte $76, $08, $FC, $71, $77, $FC, $72, $73 ; $21CD: 76 08 FC 71 77 FC 72 73 .byte $08, $FC, $74, $77, $FC, $75, $76, $08 ; $21D5: 08 FC 74 77 FC 75 76 08 .byte $FC, $71, $78, $FC, $72, $73, $08, $FC ; $21DD: FC 71 78 FC 72 73 08 FC .byte $74, $78, $FC, $75, $76, $08, $FC, $71 ; $21E5: 74 78 FC 75 76 08 FC 71 .byte $79, $FC, $72, $73, $08, $FC, $74, $79 ; $21ED: 79 FC 72 73 08 FC 74 79 .byte $FC, $75, $76, $00, $4E, $4F, $50, $51 ; $21F5: FC 75 76 00 4E 4F 50 51 .byte $52, $53, $00, $4E, $4F, $50, $51, $5E ; $21FD: 52 53 00 4E 4F 50 51 5E .byte $58, $00, $4E, $4F, $50, $51, $5E, $5D ; $2205: 58 00 4E 4F 50 51 5E 5D .byte $00, $54, $55, $50, $56, $57, $53, $00 ; $220D: 00 54 55 50 56 57 53 00 .byte $4E, $4F, $50, $51, $52, $53, $00, $59 ; $2215: 4E 4F 50 51 52 53 00 59 .byte $5A, $50, $5B, $5C, $53, $00, $FC, $5F ; $221D: 5A 50 5B 5C 53 00 FC 5F .byte $60, $FC, $61, $62, $06, $63, $64, $60 ; $2225: 60 FC 61 62 06 63 64 60 .byte $FC, $65, $62, $00, $66, $67, $60, $68 ; $222D: FC 65 62 00 66 67 60 68 .byte $69, $62, $00, $6A, $67, $60, $6B, $69 ; $2235: 69 62 00 6A 67 60 6B 69 .byte $62, $00, $FC, $6C, $6D, $FC, $6E, $6F ; $223D: 62 00 FC 6C 6D FC 6E 6F .byte $00, $FC, $6C, $6D, $FC, $6E, $70 ; $2245: 00 FC 6C 6D FC 6E 70 StageBoundaryDataA: .byte $AF, $B6, $BD, $B6, $C4, $CB, $D2, $CB ; $224C: AF B6 BD B6 C4 CB D2 CB .byte $D9, $E0, $E7, $E0, $EE, $F5, $FC, $F5 ; $2254: D9 E0 E7 E0 EE F5 FC F5 .byte $0A, $0A, $0A, $0A, $11, $11, $11, $11 ; $225C: 0A 0A 0A 0A 11 11 11 11 .byte $18, $18, $18, $18, $1F, $1F, $1F, $1F ; $2264: 18 18 18 18 1F 1F 1F 1F .byte $26, $26, $26, $26, $2D, $2D, $2D, $2D ; $226C: 26 26 26 26 2D 2D 2D 2D .byte $34, $34, $34, $34, $3B, $42, $49, $42 ; $2274: 34 34 34 34 3B 42 49 42 .byte $50, $57, $5E, $57, $65, $6C, $73, $6C ; $227C: 50 57 5E 57 65 6C 73 6C .byte $7A, $81, $88, $81, $96, $96, $96, $96 ; $2284: 7A 81 88 81 96 96 96 96 .byte $9D, $9D, $9D, $9D, $A4, $AB, $B2, $AB ; $228C: 9D 9D 9D 9D A4 AB B2 AB .byte $B9, $A4, $B9, $A4 ; $2294: B9 A4 B9 A4 StageBoundaryDataB: .byte $E0, $E0, $E0, $E0, $E0, $E0, $E0, $E0 ; $2298: E0 E0 E0 E0 E0 E0 E0 E0 .byte $E0, $E0, $E0, $E0, $E0, $E0, $E0, $E0 ; $22A0: E0 E0 E0 E0 E0 E0 E0 E0 .byte $E1, $E1, $E1, $E1, $E1, $E1, $E1, $E1 ; $22A8: E1 E1 E1 E1 E1 E1 E1 E1 .byte $E1, $E1, $E1, $E1, $E1, $E1, $E1, $E1 ; $22B0: E1 E1 E1 E1 E1 E1 E1 E1 .byte $E1, $E1, $E1, $E1, $E1, $E1, $E1, $E1 ; $22B8: E1 E1 E1 E1 E1 E1 E1 E1 .byte $E1, $E1, $E1, $E1, $E1, $E1, $E1, $E1 ; $22C0: E1 E1 E1 E1 E1 E1 E1 E1 .byte $E1, $E1, $E1, $E1, $E1, $E1, $E1, $E1 ; $22C8: E1 E1 E1 E1 E1 E1 E1 E1 .byte $E1, $E1, $E1, $E1, $E1, $E1, $E1, $E1 ; $22D0: E1 E1 E1 E1 E1 E1 E1 E1 .byte $E1, $E1, $E1, $E1, $E1, $E1, $E1, $E1 ; $22D8: E1 E1 E1 E1 E1 E1 E1 E1 .byte $E1, $E1, $E1, $E1 ; $22E0: E1 E1 E1 E1 StageObjectTypeData: .byte $81, $81, $8F, $81, $F5, $F5, $03, $F5 ; $22E4: 81 81 8F 81 F5 F5 03 F5 StageObjectXData: .byte $E1, $E1, $E1, $E1, $E0, $E0, $E1, $E0 ; $22EC: E1 E1 E1 E1 E0 E0 E1 E0 StageObjectYData: .byte $F8, $FF, $06, $FF, $0D, $14, $1B, $14 ; $22F4: F8 FF 06 FF 0D 14 1B 14 .byte $3E, $3E, $22, $29, $30, $30, $30, $30 ; $22FC: 3E 3E 22 29 30 30 30 30 .byte $C0, $C0, $C0, $C0, $C0, $C7, $C0, $C7 ; $2304: C0 C0 C0 C0 C0 C7 C0 C7 .byte $CE, $D5, $CE, $D5, $DC, $E3, $DC, $E3 ; $230C: CE D5 CE D5 DC E3 DC E3 .byte $EA, $F1, $EA, $F1, $3E, $45, $3E, $45 ; $2314: EA F1 EA F1 3E 45 3E 45 .byte $37, $37, $37, $37 ; $231C: 37 37 37 37 StageObjectAttributeData: .byte $E1, $E1, $E2, $E1, $E2, $E2, $E2, $E2 ; $2320: E1 E1 E2 E1 E2 E2 E2 E2 .byte $E2, $E2, $E2, $E2, $E2, $E2, $E2, $E2 ; $2328: E2 E2 E2 E2 E2 E2 E2 E2 .byte $E1, $E1, $E1, $E1, $E1, $E1, $E1, $E1 ; $2330: E1 E1 E1 E1 E1 E1 E1 E1 .byte $E1, $E1, $E1, $E1, $E1, $E1, $E1, $E1 ; $2338: E1 E1 E1 E1 E1 E1 E1 E1 .byte $E1, $E1, $E1, $E1, $E2, $E2, $E2, $E2 ; $2340: E1 E1 E1 E1 E2 E2 E2 E2 .byte $E2, $E2, $E2, $E2 ; $2348: E2 E2 E2 E2 StageObjectDataTableA: .byte $44, $2C, $00 ; $234C: 44 2C 00 StageObjectDataTableB: .byte $00, $00, $04 ; $234F: 00 00 04 StageObjectDataTableC: .byte $24, $08, $00, $00, $FC, $FC, $FE, $FC ; $2352: 24 08 00 00 FC FC FE FC .byte $00, $7B, $FC, $FC, $7C, $FC, $FC, $00 ; $235A: 00 7B FC FC 7C FC FC 00 .byte $7D, $7E, $FC, $7F, $80, $FC, $00, $81 ; $2362: 7D 7E FC 7F 80 FC 00 81 .byte $82, $83, $84, $85, $86, $00, $87, $88 ; $236A: 82 83 84 85 86 00 87 88 .byte $FC, $89, $8A, $FC, $00, $8B, $8C, $FC ; $2372: FC 89 8A FC 00 8B 8C FC .byte $8D, $8E, $FC, $00, $8F, $90, $FC, $FC ; $237A: 8D 8E FC 00 8F 90 FC FC .byte $FC, $FC ; $2382: FC FC StageObjectDataTableD: .byte $55, $5A, $61, $68, $6F, $76, $7D ; $2384: 55 5A 61 68 6F 76 7D StageObjectDataTableE: .byte $E3, $E3, $E3, $E3, $E3, $E3, $E3 ; $238B: E3 E3 E3 E3 E3 E3 E3 StageSetupPointerLoTable: .byte $20, $38, $50, $68, $80, $98, $B0, $C8 ; $2392: 20 38 50 68 80 98 B0 C8 .byte $08 ; $239A: 08 StageSetupPointerHiTable: .byte $20, $38, $C8, $B0, $98, $80, $68, $50 ; $239B: 20 38 C8 B0 98 80 68 50 .byte $08 ; $23A3: 08 ; RenderObjectSprites ; Purpose: select object animation streams and emit six OAM sprite records. ; Inputs: X = object slot; object state arrays and frame counter in RAM. ; Returns: selected OAM buffer updated; A/Y modified; X restored. RenderObjectSprites: lda StageSetupPointerLoTable,x ; $23A4: BD 92 E3 sta $1F ; $23A7: 85 1F lda $19 ; $23A9: A5 19 lsr a ; $23AB: 4A bcc Label_E3B3 ; $23AC: 90 05 lda StageSetupPointerHiTable,x ; $23AE: BD 9B E3 sta $1F ; $23B1: 85 1F Label_E3B3: lda #$02 ; $23B3: A9 02 sta $20 ; $23B5: 85 20 lda $88,x ; $23B7: B5 88 bpl Label_E3CF ; $23B9: 10 14 cmp #$FF ; $23BB: C9 FF beq Label_E3C2 ; $23BD: F0 03 jmp RenderLargeObjectSprites ; $23BF: 4C D5 E4 Label_E3C2: ldy #$14 ; $23C2: A0 14 Label_E3C4: lda #$F0 ; $23C4: A9 F0 sta ($1F),y ; $23C6: 91 1F dey ; $23C8: 88 dey ; $23C9: 88 dey ; $23CA: 88 dey ; $23CB: 88 bpl Label_E3C4 ; $23CC: 10 F6 rts ; $23CE: 60 Label_E3CF: cpx #$08 ; $23CF: E0 08 beq Label_E41B ; $23D1: F0 48 lda $7F,x ; $23D3: B5 7F asl a ; $23D5: 0A asl a ; $23D6: 0A adc $0436,x ; $23D7: 7D 36 04 cpx #$02 ; $23DA: E0 02 bcs Label_E408 ; $23DC: B0 2A ldy $88,x ; $23DE: B4 88 adc $E34C,y ; $23E0: 79 4C E3 tay ; $23E3: A8 lda $E24C,y ; $23E4: B9 4C E2 sta $1D ; $23E7: 85 1D lda $E298,y ; $23E9: B9 98 E2 sta $1E ; $23EC: 85 1E lda $BD,x ; $23EE: B5 BD beq Label_E429 ; $23F0: F0 37 ldy $88,x ; $23F2: B4 88 lda $E34F,y ; $23F4: B9 4F E3 adc $0436,x ; $23F7: 7D 36 04 tay ; $23FA: A8 lda $E2E4,y ; $23FB: B9 E4 E2 sta $1D ; $23FE: 85 1D lda $E2EC,y ; $2400: B9 EC E2 sta $1E ; $2403: 85 1E jmp Label_E429 ; $2405: 4C 29 E4 Label_E408: ldy $88,x ; $2408: B4 88 clc ; $240A: 18 adc $E352,y ; $240B: 79 52 E3 tay ; $240E: A8 lda $E2F4,y ; $240F: B9 F4 E2 sta $1D ; $2412: 85 1D lda $E320,y ; $2414: B9 20 E3 sta $1E ; $2417: 85 1E bne Label_E429 ; $2419: D0 0E Label_E41B: ldy $7F,x ; $241B: B4 7F bmi Label_E3C2 ; $241D: 30 A3 lda $E384,y ; $241F: B9 84 E3 sta $1D ; $2422: 85 1D lda $E38B,y ; $2424: B9 8B E3 sta $1E ; $2427: 85 1E Label_E429: lda $91,x ; $2429: B5 91 sta $15 ; $242B: 85 15 lda $9A,x ; $242D: B5 9A sta $12 ; $242F: 85 12 txa ; $2431: 8A beq Label_E444 ; $2432: F0 10 cpx #$01 ; $2434: E0 01 bne Label_E43C ; $2436: D0 04 lda #$01 ; $2438: A9 01 bne Label_E444 ; $243A: D0 08 Label_E43C: lda $0451,x ; $243C: BD 51 04 clc ; $243F: 18 adc #$02 ; $2440: 69 02 and #$03 ; $2442: 29 03 Label_E444: ldy $0448,x ; $2444: BC 48 04 beq Label_E44B ; $2447: F0 02 ora #$40 ; $2449: 09 40 Label_E44B: ldy $88,x ; $244B: B4 88 cpy #$02 ; $244D: C0 02 bne Label_E459 ; $244F: D0 08 ldy $7F,x ; $2451: B4 7F cpy #$05 ; $2453: C0 05 bne Label_E459 ; $2455: D0 02 eor #$40 ; $2457: 49 40 Label_E459: ldy $9A,x ; $2459: B4 9A cpy #$C9 ; $245B: C0 C9 bcs Label_E463 ; $245D: B0 04 cpx #$09 ; $245F: E0 09 bne Label_E465 ; $2461: D0 02 Label_E463: ora #$20 ; $2463: 09 20 Label_E465: sta $14 ; $2465: 85 14 lda #$43 ; $2467: A9 43 sta $21 ; $2469: 85 21 lda #$E0 ; $246B: A9 E0 sta $22 ; $246D: 85 22 lda $0448,x ; $246F: BD 48 04 beq Label_E47C ; $2472: F0 08 lda #$79 ; $2474: A9 79 sta $21 ; $2476: 85 21 lda #$E0 ; $2478: A9 E0 sta $22 ; $247A: 85 22 Label_E47C: ldy #$00 ; $247C: A0 00 lda ($1D),y ; $247E: B1 1D inc $1D ; $2480: E6 1D bne Label_E486 ; $2482: D0 02 inc $1E ; $2484: E6 1E Label_E486: asl a ; $2486: 0A sta $13 ; $2487: 85 13 asl a ; $2489: 0A adc $13 ; $248A: 65 13 adc $21 ; $248C: 65 21 sta $21 ; $248E: 85 21 bcc Label_E494 ; $2490: 90 02 inc $22 ; $2492: E6 22 Label_E494: txa ; $2494: 8A pha ; $2495: 48 ldx #$05 ; $2496: A2 05 ldy #$00 ; $2498: A0 00 Label_E49A: lda $12 ; $249A: A5 12 clc ; $249C: 18 adc $E03D,x ; $249D: 7D 3D E0 sta ($1F),y ; $24A0: 91 1F sta $12 ; $24A2: 85 12 iny ; $24A4: C8 sty $13 ; $24A5: 84 13 ldy #$00 ; $24A7: A0 00 lda ($1D),y ; $24A9: B1 1D inc $1D ; $24AB: E6 1D bne Label_E4B1 ; $24AD: D0 02 inc $1E ; $24AF: E6 1E Label_E4B1: ldy $13 ; $24B1: A4 13 sta ($1F),y ; $24B3: 91 1F iny ; $24B5: C8 lda $14 ; $24B6: A5 14 sta ($1F),y ; $24B8: 91 1F iny ; $24BA: C8 sty $13 ; $24BB: 84 13 ldy #$00 ; $24BD: A0 00 lda $15 ; $24BF: A5 15 clc ; $24C1: 18 adc ($21),y ; $24C2: 71 21 inc $21 ; $24C4: E6 21 bne Label_E4CA ; $24C6: D0 02 inc $22 ; $24C8: E6 22 Label_E4CA: ldy $13 ; $24CA: A4 13 sta ($1F),y ; $24CC: 91 1F iny ; $24CE: C8 dex ; $24CF: CA bpl Label_E49A ; $24D0: 10 C8 pla ; $24D2: 68 tax ; $24D3: AA rts ; $24D4: 60 ; RenderLargeObjectSprites ; Purpose: emit a fixed multi-sprite object and update animation/expiry state. ; Inputs: X = object slot; $1F selects the OAM destination. ; Returns: OAM entries updated; X restored; expired objects disabled. RenderLargeObjectSprites: txa ; $24D5: 8A pha ; $24D6: 48 ldy $1F ; $24D7: A4 1F lda $9A,x ; $24D9: B5 9A sta $0200,y ; $24DB: 99 00 02 sta $0204,y ; $24DE: 99 04 02 clc ; $24E1: 18 adc #$08 ; $24E2: 69 08 sta $0208,y ; $24E4: 99 08 02 sta $020C,y ; $24E7: 99 0C 02 lda #$F0 ; $24EA: A9 F0 sta $0210,y ; $24EC: 99 10 02 sta $0214,y ; $24EF: 99 14 02 lda $91,x ; $24F2: B5 91 sta $0203,y ; $24F4: 99 03 02 sta $020B,y ; $24F7: 99 0B 02 clc ; $24FA: 18 adc #$08 ; $24FB: 69 08 sta $0207,y ; $24FD: 99 07 02 sta $020F,y ; $2500: 99 0F 02 lda $9A,x ; $2503: B5 9A cmp #$D0 ; $2505: C9 D0 lda #$03 ; $2507: A9 03 bcc Label_E50D ; $2509: 90 02 lda #$23 ; $250B: A9 23 Label_E50D: sta $0202,y ; $250D: 99 02 02 lda $7F,x ; $2510: B5 7F bne Label_E553 ; $2512: D0 3F lda $0202,y ; $2514: B9 02 02 sta $0206,y ; $2517: 99 06 02 sta $020A,y ; $251A: 99 0A 02 sta $020E,y ; $251D: 99 0E 02 lda #$DA ; $2520: A9 DA sta $0201,y ; $2522: 99 01 02 lda #$DB ; $2525: A9 DB sta $0205,y ; $2527: 99 05 02 lda #$DC ; $252A: A9 DC sta $0209,y ; $252C: 99 09 02 lda #$DD ; $252F: A9 DD sta $020D,y ; $2531: 99 0D 02 ldx $1F ; $2534: A6 1F lda $19 ; $2536: A5 19 and #$20 ; $2538: 29 20 beq Label_E550 ; $253A: F0 14 lda $19 ; $253C: A5 19 and #$40 ; $253E: 29 40 bne Label_E54A ; $2540: D0 08 inc $0200,x ; $2542: FE 00 02 inc $0204,x ; $2545: FE 04 02 bne Label_E550 ; $2548: D0 06 Label_E54A: inc $0203,x ; $254A: FE 03 02 inc $020B,x ; $254D: FE 0B 02 Label_E550: pla ; $2550: 68 tax ; $2551: AA rts ; $2552: 60 Label_E553: lda $0202,y ; $2553: B9 02 02 ora #$40 ; $2556: 09 40 sta $0206,y ; $2558: 99 06 02 ora #$80 ; $255B: 09 80 sta $020E,y ; $255D: 99 0E 02 and #$BF ; $2560: 29 BF sta $020A,y ; $2562: 99 0A 02 lda #$DE ; $2565: A9 DE sta $0201,y ; $2567: 99 01 02 sta $0205,y ; $256A: 99 05 02 sta $0209,y ; $256D: 99 09 02 sta $020D,y ; $2570: 99 0D 02 dec $045A,x ; $2573: DE 5A 04 bpl Label_E584 ; $2576: 10 0C lda #$FF ; $2578: A9 FF sta $88,x ; $257A: 95 88 lda #$F0 ; $257C: A9 F0 sta $9A,x ; $257E: 95 9A lda #$04 ; $2580: A9 04 sta $F1 ; $2582: 85 F1 Label_E584: pla ; $2584: 68 tax ; $2585: AA rts ; $2586: 60 ; CopyOverlaySpriteStream ; Purpose: copy a selected 16-byte overlay sprite stream into OAM and apply Y offset. ; Inputs: $BB = stream index, $BC = vertical offset. ; Returns: overlay OAM region updated; may decrement $BB. CopyOverlaySpriteStream: ldx $BB ; $2587: A6 BB bmi Label_E5C4 ; $2589: 30 39 lda OverlaySpriteStreamLoTable,x ; $258B: BD C5 E5 sta $1D ; $258E: 85 1D lda OverlaySpriteStreamHiTable,x ; $2590: BD CA E5 sta $1E ; $2593: 85 1E ldy #$00 ; $2595: A0 00 ldx #$00 ; $2597: A2 00 Label_E599: lda ($1D),y ; $2599: B1 1D sta $02E0,x ; $259B: 9D E0 02 iny ; $259E: C8 inx ; $259F: E8 cmp #$F0 ; $25A0: C9 F0 bne Label_E5A7 ; $25A2: D0 03 inx ; $25A4: E8 inx ; $25A5: E8 inx ; $25A6: E8 Label_E5A7: cpx #$10 ; $25A7: E0 10 bne Label_E599 ; $25A9: D0 EE ldy #$0F ; $25AB: A0 0F Label_E5AD: lda $02E0,y ; $25AD: B9 E0 02 clc ; $25B0: 18 adc $BC ; $25B1: 65 BC sta $02E0,y ; $25B3: 99 E0 02 dey ; $25B6: 88 dey ; $25B7: 88 dey ; $25B8: 88 dey ; $25B9: 88 bpl Label_E5AD ; $25BA: 10 F1 lda $19 ; $25BC: A5 19 and #$03 ; $25BE: 29 03 bne Label_E5C4 ; $25C0: D0 02 dec $BB ; $25C2: C6 BB Label_E5C4: rts ; $25C4: 60 ; Rendering streams and object motion/physics lookup data OverlaySpriteStreamLoTable: .byte $FD, $ED, $E0, $D6, $CF ; $25C5: FD ED E0 D6 CF OverlaySpriteStreamHiTable: .byte $E5, $E5, $E5, $E5, $E5, $D0, $AE, $03 ; $25CA: E5 E5 E5 E5 E5 D0 AE 03 .byte $04, $F0, $F0, $F0, $C8, $AF, $03, $04 ; $25D2: 04 F0 F0 F0 C8 AF 03 04 .byte $D0, $B0, $03, $04, $F0, $F0, $C8, $B1 ; $25DA: D0 B0 03 04 F0 F0 C8 B1 .byte $03, $FC, $C8, $B2, $03, $04, $D0, $B3 ; $25E2: 03 FC C8 B2 03 04 D0 B3 .byte $03, $04, $F0, $C8, $B4, $03, $00, $C8 ; $25EA: 03 04 F0 C8 B4 03 00 C8 .byte $B4, $43, $08, $D0, $B5, $03, $00, $D0 ; $25F2: B4 43 08 D0 B5 03 00 D0 .byte $B5, $43, $08, $F0, $F0, $F0, $F0 ; $25FA: B5 43 08 F0 F0 F0 F0 ObjectAccelerationTableA: .byte $04, $04, $05, $06, $03, $03, $03, $06 ; $2601: 04 04 05 06 03 03 03 06 .byte $0A, $0A, $0A, $0A ; $2609: 0A 0A 0A 0A ObjectAccelerationTableB: .byte $28, $32, $46, $78, $00, $00, $00, $64 ; $260D: 28 32 46 78 00 00 00 64 .byte $00, $00, $00, $00 ; $2615: 00 00 00 00 ObjectVelocityTableA: .byte $0A, $1E, $32, $70, $00, $00, $00, $70 ; $2619: 0A 1E 32 70 00 00 00 70 .byte $00, $00, $00, $00 ; $2621: 00 00 00 00 ObjectVelocityTableB: .byte $14, $3C, $64, $A0, $00, $00, $00, $A0 ; $2625: 14 3C 64 A0 00 00 00 A0 .byte $00, $00, $00, $00 ; $262D: 00 00 00 00 ObjectVelocityTableC: .byte $70, $B0, $E0, $40, $80, $80, $80, $40 ; $2631: 70 B0 E0 40 80 80 80 40 .byte $00, $00, $00, $00 ; $2639: 00 00 00 00 ObjectVelocityTableD: .byte $00, $00, $00, $01, $00, $00, $00, $01 ; $263D: 00 00 00 01 00 00 00 01 .byte $00, $00, $00, $00 ; $2645: 00 00 00 00 ObjectVelocityTableE: .byte $90, $50, $20, $C0, $80, $80, $80, $C0 ; $2649: 90 50 20 C0 80 80 80 C0 .byte $00, $00, $00, $00 ; $2651: 00 00 00 00 ObjectVelocityTableF: .byte $FF, $FF, $FF, $FE, $FF, $FF, $FF, $FE ; $2655: FF FF FF FE FF FF FF FE .byte $00, $00, $00, $00 ; $265D: 00 00 00 00 ObjectMotionTableA: .byte $50, $90, $C0, $40, $40, $40, $40, $40 ; $2661: 50 90 C0 40 40 40 40 40 .byte $00, $00, $00, $00 ; $2669: 00 00 00 00 ObjectMotionTableB: .byte $00, $00, $00, $01, $00, $00, $00, $01 ; $266D: 00 00 00 01 00 00 00 01 .byte $02, $02, $02, $02 ; $2675: 02 02 02 02 ObjectMotionTableC: .byte $B0, $70, $40, $C0, $C0, $C0, $C0, $C0 ; $2679: B0 70 40 C0 C0 C0 C0 C0 .byte $C0, $C0, $C0, $C0 ; $2681: C0 C0 C0 C0 ObjectMotionTableD: .byte $FF, $FF, $FF, $FE, $FF, $FF, $FF, $FE ; $2685: FF FF FF FE FF FF FF FE .byte $FE, $01, $FE, $FE ; $268D: FE 01 FE FE ; UpdateAllObjects ; Purpose: update active object slots, physics, interactions, and sprite rendering. ; Inputs: global object arrays; no explicit register parameters. ; Returns: all active objects processed; X exhausted to $FF. UpdateAllObjects: jsr $EE25 ; $2691: 20 25 EE ldx #$07 ; $2694: A2 07 Label_E696: lda $88,x ; $2696: B5 88 bpl Label_E6A4 ; $2698: 10 0A cmp #$FF ; $269A: C9 FF beq Label_E6E2 ; $269C: F0 44 jsr $ECBA ; $269E: 20 BA EC jmp Label_E6E2 ; $26A1: 4C E2 E6 Label_E6A4: cpx #$02 ; $26A4: E0 02 bcc Label_E6B8 ; $26A6: 90 10 cmp #$01 ; $26A8: C9 01 bne Label_E6B8 ; $26AA: D0 0C lda $7F,x ; $26AC: B5 7F cmp #$02 ; $26AE: C9 02 bcs Label_E6B8 ; $26B0: B0 06 lda $F1 ; $26B2: A5 F1 ora #$20 ; $26B4: 09 20 sta $F1 ; $26B6: 85 F1 Label_E6B8: dec $043F,x ; $26B8: DE 3F 04 bne Label_E6D9 ; $26BB: D0 1C lda #$03 ; $26BD: A9 03 sta $043F,x ; $26BF: 9D 3F 04 cpx #$02 ; $26C2: E0 02 bcs Label_E6CE ; $26C4: B0 08 dec $BF,x ; $26C6: D6 BF bne Label_E6CE ; $26C8: D0 04 lda #$00 ; $26CA: A9 00 sta $BD,x ; $26CC: 95 BD Label_E6CE: jsr $EA18 ; $26CE: 20 18 EA stx $3E ; $26D1: 86 3E jsr $EBC4 ; $26D3: 20 C4 EB jsr $E796 ; $26D6: 20 96 E7 Label_E6D9: jsr $EA58 ; $26D9: 20 58 EA jsr $ED28 ; $26DC: 20 28 ED jsr $E983 ; $26DF: 20 83 E9 Label_E6E2: jsr $E3A4 ; $26E2: 20 A4 E3 dex ; $26E5: CA bpl Label_E696 ; $26E6: 10 AE rts ; $26E8: 60 ; UpdatePlayerInputState ; Purpose: update per-player directional input and animation timing state. ; Inputs: X = player object slot. ; Returns: direction/state byte $31,X updated. UpdatePlayerInputState: cpx #$02 ; $26E9: E0 02 bcs Label_E705 ; $26EB: B0 18 lda $19 ; $26ED: A5 19 and #$0F ; $26EF: 29 0F bne Label_E6F8 ; $26F1: D0 05 jsr $F1B3 ; $26F3: 20 B3 F1 sta $31,x ; $26F6: 95 31 Label_E6F8: lda $3A ; $26F8: A5 3A bne Label_E705 ; $26FA: D0 09 jsr $E76A ; $26FC: 20 6A E7 lda $061C,x ; $26FF: BD 1C 06 sta $31,x ; $2702: 95 31 Label_E704: rts ; $2704: 60 Label_E705: lda $9A,x ; $2705: B5 9A cmp #$A0 ; $2707: C9 A0 bcc Label_E712 ; $2709: 90 07 lda $31,x ; $270B: B5 31 ora #$40 ; $270D: 09 40 sta $31,x ; $270F: 95 31 rts ; $2711: 60 Label_E712: dec $045A,x ; $2712: DE 5A 04 bne Label_E704 ; $2715: D0 ED jsr $F1B3 ; $2717: 20 B3 F1 ldy $0451,x ; $271A: BC 51 04 and ObjectAnimationPeriodTable,y ; $271D: 39 62 E7 adc ControllerBitMaskTable,y ; $2720: 79 65 E7 sta $045A,x ; $2723: 9D 5A 04 stx $12 ; $2726: 86 12 lda $19 ; $2728: A5 19 rol a ; $272A: 2A rol a ; $272B: 2A eor $12 ; $272C: 45 12 and #$01 ; $272E: 29 01 tay ; $2730: A8 lda a:$0088,y ; $2731: B9 88 00 bmi Label_E749 ; $2734: 30 13 lda a:$00BD,y ; $2736: B9 BD 00 bne Label_E749 ; $2739: D0 0E lda #$00 ; $273B: A9 00 sta $31,x ; $273D: 95 31 lda a:$009A,y ; $273F: B9 9A 00 sec ; $2742: 38 sbc #$04 ; $2743: E9 04 cmp $9A,x ; $2745: D5 9A bcs Label_E74D ; $2747: B0 04 Label_E749: lda #$40 ; $2749: A9 40 sta $31,x ; $274B: 95 31 Label_E74D: lda $91,x ; $274D: B5 91 cmp a:$0091,y ; $274F: D9 91 00 bcs Label_E75B ; $2752: B0 07 lda $31,x ; $2754: B5 31 ora #$01 ; $2756: 09 01 sta $31,x ; $2758: 95 31 rts ; $275A: 60 Label_E75B: lda $31,x ; $275B: B5 31 ora #$02 ; $275D: 09 02 sta $31,x ; $275F: 95 31 rts ; $2761: 60 ; Per-object animation timer masks selected by object type/state. ObjectAnimationPeriodTable: .byte $1F, $0F, $07 ; $2762: 1F 0F 07 ; Base timer periods paired with ObjectAnimationPeriodTable. ObjectAnimationBasePeriodTable: ControllerBitMaskTable: .byte $20, $10, $08 ; $2765: 20 10 08 ; PollControllers ; Purpose: strobe both NES controller ports and update current/pressed input bytes. ; Inputs: none. ; Returns: controller history at $061C-$061F updated; A/X/Y modified. PollControllers: ldx #$00 ; $2768: A2 00 ReadControllerPort: lda #$01 ; $276A: A9 01 sta $4016 ; $276C: 8D 16 40 lda #$00 ; $276F: A9 00 sta $4016 ; $2771: 8D 16 40 ldy #$07 ; $2774: A0 07 Label_E776: lda $4016,x ; $2776: BD 16 40 sta $12 ; $2779: 85 12 lsr a ; $277B: 4A ora $12 ; $277C: 05 12 lsr a ; $277E: 4A rol $061C,x ; $277F: 3E 1C 06 dey ; $2782: 88 bpl Label_E776 ; $2783: 10 F1 ldy $061E,x ; $2785: BC 1E 06 lda $061C,x ; $2788: BD 1C 06 sta $061E,x ; $278B: 9D 1E 06 tya ; $278E: 98 eor $061C,x ; $278F: 5D 1C 06 and $061C,x ; $2792: 3D 1C 06 rts ; $2795: 60 ; UpdateObjectMotionState ; Purpose: clear motion accumulators for inactive objects and integrate active-object velocity. ; Inputs: X = object slot. ; Returns: per-object fixed-point motion values updated. UpdateObjectMotionState: lda $88,x ; $2796: B5 88 bne Label_E7A3 ; $2798: D0 09 Label_E79A: lda #$00 ; $279A: A9 00 sta $0424,x ; $279C: 9D 24 04 sta $042D,x ; $279F: 9D 2D 04 rts ; $27A2: 60 Label_E7A3: cmp #$02 ; $27A3: C9 02 beq Label_E7E8 ; $27A5: F0 41 cpx #$02 ; $27A7: E0 02 bcc Label_E7E8 ; $27A9: 90 3D lda $7F,x ; $27AB: B5 7F cmp #$02 ; $27AD: C9 02 bcs Label_E79A ; $27AF: B0 E9 ; UpdateObjectVelocity ; Purpose: select movement state and adjust horizontal velocity from directional state. ; Inputs: X = object slot. ; Returns: state $7F,X, facing $0448,X, and velocity $0424/$042D updated. UpdateObjectVelocity: lda $0424,x ; $27B1: BD 24 04 sta $12 ; $27B4: 85 12 lda $042D,x ; $27B6: BD 2D 04 sta $13 ; $27B9: 85 13 jsr $F1A6 ; $27BB: 20 A6 F1 lda $0463,x ; $27BE: BD 63 04 clc ; $27C1: 18 adc $12 ; $27C2: 65 12 sta $0463,x ; $27C4: 9D 63 04 sta $12 ; $27C7: 85 12 lda $046C,x ; $27C9: BD 6C 04 adc $13 ; $27CC: 65 13 sta $046C,x ; $27CE: 9D 6C 04 sta $13 ; $27D1: 85 13 jsr $F1A6 ; $27D3: 20 A6 F1 lda $0424,x ; $27D6: BD 24 04 sec ; $27D9: 38 sbc $12 ; $27DA: E5 12 sta $0424,x ; $27DC: 9D 24 04 lda $042D,x ; $27DF: BD 2D 04 sbc $13 ; $27E2: E5 13 sta $042D,x ; $27E4: 9D 2D 04 rts ; $27E7: 60 Label_E7E8: lda $7F,x ; $27E8: B5 7F cmp #$06 ; $27EA: C9 06 bcc Label_E7EF ; $27EC: 90 01 rts ; $27EE: 60 Label_E7EF: lda $7F,x ; $27EF: B5 7F cmp #$04 ; $27F1: C9 04 bne Label_E811 ; $27F3: D0 1C lda $31,x ; $27F5: B5 31 and #$02 ; $27F7: 29 02 beq Label_E802 ; $27F9: F0 07 lda $0448,x ; $27FB: BD 48 04 beq Label_E811 ; $27FE: F0 11 bne Label_E80D ; $2800: D0 0B Label_E802: lda $31,x ; $2802: B5 31 and #$01 ; $2804: 29 01 beq Label_E811 ; $2806: F0 09 lda $0448,x ; $2808: BD 48 04 bne Label_E811 ; $280B: D0 04 Label_E80D: lda #$05 ; $280D: A9 05 sta $7F,x ; $280F: 95 7F Label_E811: lda $7F,x ; $2811: B5 7F cmp #$02 ; $2813: C9 02 bne Label_E832 ; $2815: D0 1B lda $31,x ; $2817: B5 31 and #$02 ; $2819: 29 02 beq Label_E821 ; $281B: F0 04 lda #$00 ; $281D: A9 00 beq Label_E829 ; $281F: F0 08 Label_E821: lda $31,x ; $2821: B5 31 and #$01 ; $2823: 29 01 beq Label_E82E ; $2825: F0 07 lda #$01 ; $2827: A9 01 Label_E829: cmp $0448,x ; $2829: DD 48 04 beq Label_E832 ; $282C: F0 04 Label_E82E: lda #$04 ; $282E: A9 04 sta $7F,x ; $2830: 95 7F Label_E832: lda $7F,x ; $2832: B5 7F cmp #$04 ; $2834: C9 04 bcc Label_E854 ; $2836: 90 1C lda $31,x ; $2838: B5 31 and #$02 ; $283A: 29 02 beq Label_E845 ; $283C: F0 07 lda $0448,x ; $283E: BD 48 04 bne Label_E854 ; $2841: D0 11 beq Label_E850 ; $2843: F0 0B Label_E845: lda $31,x ; $2845: B5 31 and #$01 ; $2847: 29 01 beq Label_E854 ; $2849: F0 09 lda $0448,x ; $284B: BD 48 04 beq Label_E854 ; $284E: F0 04 Label_E850: lda #$02 ; $2850: A9 02 sta $7F,x ; $2852: 95 7F Label_E854: lda $7F,x ; $2854: B5 7F cmp #$03 ; $2856: C9 03 bne Label_E864 ; $2858: D0 0A lda $31,x ; $285A: B5 31 and #$03 ; $285C: 29 03 beq Label_E864 ; $285E: F0 04 lda #$02 ; $2860: A9 02 sta $7F,x ; $2862: 95 7F Label_E864: lda $7F,x ; $2864: B5 7F cmp #$04 ; $2866: C9 04 bcs Label_E87F ; $2868: B0 15 lda $31,x ; $286A: B5 31 and #$02 ; $286C: 29 02 beq Label_E874 ; $286E: F0 04 lda #$00 ; $2870: A9 00 beq Label_E87C ; $2872: F0 08 Label_E874: lda $31,x ; $2874: B5 31 and #$01 ; $2876: 29 01 beq Label_E87F ; $2878: F0 05 lda #$01 ; $287A: A9 01 Label_E87C: sta $0448,x ; $287C: 9D 48 04 Label_E87F: lda $7F,x ; $287F: B5 7F cmp #$04 ; $2881: C9 04 bcc Label_E8B8 ; $2883: 90 33 lda $0436,x ; $2885: BD 36 04 cmp #$01 ; $2888: C9 01 bne Label_E8B8 ; $288A: D0 2C ldy $0451,x ; $288C: BC 51 04 lda $0448,x ; $288F: BD 48 04 beq Label_E8A6 ; $2892: F0 12 lda $0424,x ; $2894: BD 24 04 sec ; $2897: 38 sbc $E625,y ; $2898: F9 25 E6 sta $0424,x ; $289B: 9D 24 04 lda $042D,x ; $289E: BD 2D 04 sbc #$00 ; $28A1: E9 00 jmp Label_E901 ; $28A3: 4C 01 E9 Label_E8A6: lda $0424,x ; $28A6: BD 24 04 clc ; $28A9: 18 adc $E625,y ; $28AA: 79 25 E6 sta $0424,x ; $28AD: 9D 24 04 lda $042D,x ; $28B0: BD 2D 04 adc #$00 ; $28B3: 69 00 jmp Label_E901 ; $28B5: 4C 01 E9 Label_E8B8: lda $7F,x ; $28B8: B5 7F beq Label_E8C7 ; $28BA: F0 0B cmp #$02 ; $28BC: C9 02 beq Label_E907 ; $28BE: F0 47 cmp #$03 ; $28C0: C9 03 beq Label_E8C7 ; $28C2: F0 03 jmp Label_E951 ; $28C4: 4C 51 E9 Label_E8C7: lda $0436,x ; $28C7: BD 36 04 cmp #$01 ; $28CA: C9 01 beq Label_E8D1 ; $28CC: F0 03 jmp Label_E951 ; $28CE: 4C 51 E9 Label_E8D1: ldy $0451,x ; $28D1: BC 51 04 lda $31,x ; $28D4: B5 31 and #$02 ; $28D6: 29 02 beq Label_E8EC ; $28D8: F0 12 lda $0424,x ; $28DA: BD 24 04 sec ; $28DD: 38 sbc $E619,y ; $28DE: F9 19 E6 sta $0424,x ; $28E1: 9D 24 04 lda $042D,x ; $28E4: BD 2D 04 sbc #$00 ; $28E7: E9 00 jmp Label_E901 ; $28E9: 4C 01 E9 Label_E8EC: lda $31,x ; $28EC: B5 31 and #$01 ; $28EE: 29 01 beq Label_E951 ; $28F0: F0 5F lda $0424,x ; $28F2: BD 24 04 clc ; $28F5: 18 adc $E619,y ; $28F6: 79 19 E6 sta $0424,x ; $28F9: 9D 24 04 lda $042D,x ; $28FC: BD 2D 04 adc #$00 ; $28FF: 69 00 Label_E901: sta $042D,x ; $2901: 9D 2D 04 jmp Label_E951 ; $2904: 4C 51 E9 Label_E907: lda $0436,x ; $2907: BD 36 04 cmp #$01 ; $290A: C9 01 bne Label_E951 ; $290C: D0 43 ldy $0451,x ; $290E: BC 51 04 lda $31,x ; $2911: B5 31 and #$02 ; $2913: 29 02 beq Label_E929 ; $2915: F0 12 lda $0424,x ; $2917: BD 24 04 sec ; $291A: 38 sbc $E625,y ; $291B: F9 25 E6 sta $0424,x ; $291E: 9D 24 04 lda $042D,x ; $2921: BD 2D 04 sbc #$00 ; $2924: E9 00 jmp Label_E93E ; $2926: 4C 3E E9 Label_E929: lda $31,x ; $2929: B5 31 and #$01 ; $292B: 29 01 beq Label_E951 ; $292D: F0 22 lda $0424,x ; $292F: BD 24 04 clc ; $2932: 18 adc $E625,y ; $2933: 79 25 E6 sta $0424,x ; $2936: 9D 24 04 lda $042D,x ; $2939: BD 2D 04 adc #$00 ; $293C: 69 00 Label_E93E: sta $042D,x ; $293E: 9D 2D 04 lda $31,x ; $2941: B5 31 and #$03 ; $2943: 29 03 beq Label_E951 ; $2945: F0 0A cpx #$02 ; $2947: E0 02 bcs Label_E951 ; $2949: B0 06 lda $F0 ; $294B: A5 F0 ora #$08 ; $294D: 09 08 sta $F0 ; $294F: 85 F0 Label_E951: lda $7F,x ; $2951: B5 7F cmp #$04 ; $2953: C9 04 bcc Label_E982 ; $2955: 90 2B lda $0448,x ; $2957: BD 48 04 bne Label_E963 ; $295A: D0 07 lda $042D,x ; $295C: BD 2D 04 bmi Label_E982 ; $295F: 30 21 bpl Label_E968 ; $2961: 10 05 Label_E963: lda $042D,x ; $2963: BD 2D 04 bpl Label_E982 ; $2966: 10 1A Label_E968: lda $7F,x ; $2968: B5 7F cmp #$05 ; $296A: C9 05 bne Label_E976 ; $296C: D0 08 lda $0448,x ; $296E: BD 48 04 eor #$01 ; $2971: 49 01 sta $0448,x ; $2973: 9D 48 04 Label_E976: lda #$03 ; $2976: A9 03 sta $7F,x ; $2978: 95 7F lda #$00 ; $297A: A9 00 sta $0424,x ; $297C: 9D 24 04 sta $042D,x ; $297F: 9D 2D 04 Label_E982: rts ; $2982: 60 ; UpdateObjectFacingAndState ; Purpose: normalize movement/facing state using controller direction and object mode. ; Inputs: X = object slot. ; Returns: object state and facing fields updated. UpdateObjectFacingAndState: lda $CB ; $2983: A5 CB bne Label_E9B6 ; $2985: D0 2F lda $BD,x ; $2987: B5 BD beq Label_E99A ; $2989: F0 0F lda $0488 ; $298B: AD 88 04 beq Label_E99A ; $298E: F0 0A sec ; $2990: 38 sbc $91,x ; $2991: F5 91 jsr $F08E ; $2993: 20 8E F0 cmp #$05 ; $2996: C9 05 bcc Label_E9B6 ; $2998: 90 1C Label_E99A: cpx #$02 ; $299A: E0 02 bcc Label_E9A4 ; $299C: 90 06 lda $88,x ; $299E: B5 88 cmp #$02 ; $29A0: C9 02 bne Label_E9F2 ; $29A2: D0 4E Label_E9A4: lda $7F,x ; $29A4: B5 7F cmp #$02 ; $29A6: C9 02 bcc Label_E9F2 ; $29A8: 90 48 cmp #$06 ; $29AA: C9 06 bcs Label_E9F2 ; $29AC: B0 44 lda #$01 ; $29AE: A9 01 sta $7F,x ; $29B0: 95 7F sta $045A,x ; $29B2: 9D 5A 04 rts ; $29B5: 60 Label_E9B6: lda #$00 ; $29B6: A9 00 sta $0412,x ; $29B8: 9D 12 04 sta $041B,x ; $29BB: 9D 1B 04 sta $0409,x ; $29BE: 9D 09 04 sta $CB ; $29C1: 85 CB cpx #$02 ; $29C3: E0 02 bcc Label_E9FD ; $29C5: 90 36 lda $88,x ; $29C7: B5 88 cmp #$02 ; $29C9: C9 02 beq Label_E9F3 ; $29CB: F0 26 cmp #$01 ; $29CD: C9 01 bne Label_E9F2 ; $29CF: D0 21 lda $7F,x ; $29D1: B5 7F cmp #$02 ; $29D3: C9 02 bcs Label_E9F2 ; $29D5: B0 1B lda #$02 ; $29D7: A9 02 sta $7F,x ; $29D9: 95 7F lda $C6 ; $29DB: A5 C6 sta $043F,x ; $29DD: 9D 3F 04 lda #$00 ; $29E0: A9 00 sta $0424,x ; $29E2: 9D 24 04 sta $042D,x ; $29E5: 9D 2D 04 sta $0463,x ; $29E8: 9D 63 04 sta $046C,x ; $29EB: 9D 6C 04 lda #$40 ; $29EE: A9 40 sta $F1 ; $29F0: 85 F1 Label_E9F2: rts ; $29F2: 60 Label_E9F3: lda #$00 ; $29F3: A9 00 sta $7F,x ; $29F5: 95 7F lda #$01 ; $29F7: A9 01 sta $045A,x ; $29F9: 9D 5A 04 rts ; $29FC: 60 Label_E9FD: lda $7F,x ; $29FD: B5 7F cmp #$01 ; $29FF: C9 01 bne Label_EA17 ; $2A01: D0 14 cmp #$06 ; $2A03: C9 06 bcs Label_EA17 ; $2A05: B0 10 lda $0424,x ; $2A07: BD 24 04 ora $042D,x ; $2A0A: 1D 2D 04 bne Label_EA13 ; $2A0D: D0 04 lda #$03 ; $2A0F: A9 03 bne Label_EA15 ; $2A11: D0 02 Label_EA13: lda #$02 ; $2A13: A9 02 Label_EA15: sta $7F,x ; $2A15: 95 7F Label_EA17: rts ; $2A17: 60 ; ApplyObjectHorizontalMotion ; Purpose: clamp and integrate horizontal fixed-point velocity. ; Inputs: X = object slot. ; Returns: horizontal position/velocity updated; may deactivate escaped objects. ApplyObjectHorizontalMotion: cpx #$02 ; $2A18: E0 02 bcs Label_EA2C ; $2A1A: B0 10 lda $BD,x ; $2A1C: B5 BD bne Label_EA44 ; $2A1E: D0 24 lda $7F,x ; $2A20: B5 7F cmp #$01 ; $2A22: C9 01 beq Label_EA3E ; $2A24: F0 18 cmp #$03 ; $2A26: C9 03 bne Label_EA44 ; $2A28: D0 1A beq Label_EA3E ; $2A2A: F0 12 Label_EA2C: lda $7F,x ; $2A2C: B5 7F cmp #$01 ; $2A2E: C9 01 beq Label_EA3E ; $2A30: F0 0C cmp #$03 ; $2A32: C9 03 bcc Label_EA44 ; $2A34: 90 0E lda $19 ; $2A36: A5 19 and #$03 ; $2A38: 29 03 bne Label_EA47 ; $2A3A: D0 0B beq Label_EA44 ; $2A3C: F0 06 Label_EA3E: lda $19 ; $2A3E: A5 19 and #$07 ; $2A40: 29 07 bne Label_EA47 ; $2A42: D0 03 Label_EA44: inc $0436,x ; $2A44: FE 36 04 Label_EA47: lda $0436,x ; $2A47: BD 36 04 and #$03 ; $2A4A: 29 03 sta $0436,x ; $2A4C: 9D 36 04 bne Label_EA57 ; $2A4F: D0 06 lda $7F,x ; $2A51: B5 7F bne Label_EA57 ; $2A53: D0 02 inc $7F,x ; $2A55: F6 7F Label_EA57: rts ; $2A57: 60 ; ApplyObjectVerticalMotion ; Purpose: clamp and integrate vertical fixed-point velocity. ; Inputs: X = object slot. ; Returns: vertical position/velocity updated; may trigger object removal. ApplyObjectVerticalMotion: lda $0475,x ; $2A58: BD 75 04 beq Label_EA60 ; $2A5B: F0 03 dec $0475,x ; $2A5D: DE 75 04 Label_EA60: cpx #$02 ; $2A60: E0 02 bcs Label_EA8C ; $2A62: B0 28 lda $C1,x ; $2A64: B5 C1 beq Label_EA8C ; $2A66: F0 24 lda $19 ; $2A68: A5 19 lsr a ; $2A6A: 4A bcc Label_EA8B ; $2A6B: 90 1E inc $0436,x ; $2A6D: FE 36 04 lda $0436,x ; $2A70: BD 36 04 and #$03 ; $2A73: 29 03 sta $0436,x ; $2A75: 9D 36 04 lda #$01 ; $2A78: A9 01 sta $7F,x ; $2A7A: 95 7F dec $045A,x ; $2A7C: DE 5A 04 bne Label_EA8B ; $2A7F: D0 0A lda #$00 ; $2A81: A9 00 sta $C1,x ; $2A83: 95 C1 sta $7F,x ; $2A85: 95 7F lda #$20 ; $2A87: A9 20 sta $F0 ; $2A89: 85 F0 Label_EA8B: rts ; $2A8B: 60 Label_EA8C: lda $0412,x ; $2A8C: BD 12 04 clc ; $2A8F: 18 ldy $0451,x ; $2A90: BC 51 04 adc $E601,y ; $2A93: 79 01 E6 sta $0412,x ; $2A96: 9D 12 04 bcc Label_EA9E ; $2A99: 90 03 inc $041B,x ; $2A9B: FE 1B 04 Label_EA9E: lda $041B,x ; $2A9E: BD 1B 04 bmi Label_EAC1 ; $2AA1: 30 1E cmp $E66D,y ; $2AA3: D9 6D E6 bcc Label_EADC ; $2AA6: 90 34 bne Label_EAB2 ; $2AA8: D0 08 lda $0412,x ; $2AAA: BD 12 04 cmp $E661,y ; $2AAD: D9 61 E6 bcc Label_EADC ; $2AB0: 90 2A Label_EAB2: lda $E661,y ; $2AB2: B9 61 E6 sta $0412,x ; $2AB5: 9D 12 04 lda $E66D,y ; $2AB8: B9 6D E6 sta $041B,x ; $2ABB: 9D 1B 04 jmp Label_EADC ; $2ABE: 4C DC EA Label_EAC1: cmp $E685,y ; $2AC1: D9 85 E6 bcc Label_EAD0 ; $2AC4: 90 0A bne Label_EADC ; $2AC6: D0 14 lda $0412,x ; $2AC8: BD 12 04 cmp $E679,y ; $2ACB: D9 79 E6 bcs Label_EADC ; $2ACE: B0 0C Label_EAD0: lda $E679,y ; $2AD0: B9 79 E6 sta $0412,x ; $2AD3: 9D 12 04 lda $E685,y ; $2AD6: B9 85 E6 sta $041B,x ; $2AD9: 9D 1B 04 Label_EADC: jsr IntegrateVerticalPosition ; $2ADC: 20 A0 EB cmp #$F8 ; $2ADF: C9 F8 bcs Label_EB0D ; $2AE1: B0 2A cmp #$E8 ; $2AE3: C9 E8 bcc Label_EB0D ; $2AE5: 90 26 lda #$FF ; $2AE7: A9 FF sta $88,x ; $2AE9: 95 88 lda #$04 ; $2AEB: A9 04 sta $BB ; $2AED: 85 BB lda $91,x ; $2AEF: B5 91 sta $BC ; $2AF1: 85 BC cpx #$02 ; $2AF3: E0 02 bcc Label_EB05 ; $2AF5: 90 0E lda #$80 ; $2AF7: A9 80 sta $88,x ; $2AF9: 95 88 lda #$00 ; $2AFB: A9 00 sta $7F,x ; $2AFD: 95 7F lda #$01 ; $2AFF: A9 01 sta $F3 ; $2B01: 85 F3 bne Label_EB0D ; $2B03: D0 08 Label_EB05: lda $C8 ; $2B05: A5 C8 bne Label_EB0D ; $2B07: D0 04 lda #$40 ; $2B09: A9 40 sta $F0 ; $2B0B: 85 F0 Label_EB0D: lda $042D,x ; $2B0D: BD 2D 04 bmi Label_EB30 ; $2B10: 30 1E cmp $E63D,y ; $2B12: D9 3D E6 bcc Label_EB4B ; $2B15: 90 34 bne Label_EB21 ; $2B17: D0 08 lda $0424,x ; $2B19: BD 24 04 cmp $E631,y ; $2B1C: D9 31 E6 bcc Label_EB4B ; $2B1F: 90 2A Label_EB21: lda $E631,y ; $2B21: B9 31 E6 sta $0424,x ; $2B24: 9D 24 04 lda $E63D,y ; $2B27: B9 3D E6 sta $042D,x ; $2B2A: 9D 2D 04 jmp Label_EB4B ; $2B2D: 4C 4B EB Label_EB30: cmp $E655,y ; $2B30: D9 55 E6 bcc Label_EB3F ; $2B33: 90 0A bne Label_EB4B ; $2B35: D0 14 lda $0424,x ; $2B37: BD 24 04 cmp $E649,y ; $2B3A: D9 49 E6 bcs Label_EB4B ; $2B3D: B0 0C Label_EB3F: lda $E649,y ; $2B3F: B9 49 E6 sta $0424,x ; $2B42: 9D 24 04 lda $E655,y ; $2B45: B9 55 E6 sta $042D,x ; $2B48: 9D 2D 04 Label_EB4B: jsr IntegrateHorizontalPosition ; $2B4B: 20 8E EB lda $16 ; $2B4E: A5 16 beq Label_EB62 ; $2B50: F0 10 lda $91,x ; $2B52: B5 91 cmp #$10 ; $2B54: C9 10 bcs Label_EB5A ; $2B56: B0 02 lda #$10 ; $2B58: A9 10 Label_EB5A: cmp #$E0 ; $2B5A: C9 E0 bcc Label_EB60 ; $2B5C: 90 02 lda #$E0 ; $2B5E: A9 E0 Label_EB60: sta $91,x ; $2B60: 95 91 Label_EB62: lda $C8 ; $2B62: A5 C8 beq Label_EB8D ; $2B64: F0 27 lda $88,x ; $2B66: B5 88 bne Label_EB8D ; $2B68: D0 23 lda $9A,x ; $2B6A: B5 9A cmp #$C8 ; $2B6C: C9 C8 bcc Label_EB8D ; $2B6E: 90 1D lda #$C7 ; $2B70: A9 C7 sta $9A,x ; $2B72: 95 9A lda $0451,x ; $2B74: BD 51 04 cmp #$0B ; $2B77: C9 0B bne Label_EB84 ; $2B79: D0 09 dec $0451,x ; $2B7B: DE 51 04 jsr $F107 ; $2B7E: 20 07 F1 jmp $F18C ; $2B81: 4C 8C F1 Label_EB84: lda #$02 ; $2B84: A9 02 sta $88,x ; $2B86: 95 88 lda #$03 ; $2B88: A9 03 sta $0451,x ; $2B8A: 9D 51 04 Label_EB8D: rts ; $2B8D: 60 ; IntegrateHorizontalPosition ; Purpose: add horizontal velocity to fixed-point X position. ; Inputs: X = object slot. ; Returns: $0400,X and $91,X updated. IntegrateHorizontalPosition: lda $0400,x ; $2B8E: BD 00 04 clc ; $2B91: 18 adc $0424,x ; $2B92: 7D 24 04 sta $0400,x ; $2B95: 9D 00 04 lda $91,x ; $2B98: B5 91 adc $042D,x ; $2B9A: 7D 2D 04 sta $91,x ; $2B9D: 95 91 rts ; $2B9F: 60 ; IntegrateVerticalPosition ; Purpose: add vertical velocity to fixed-point Y position. ; Inputs: X = object slot. ; Returns: $0409,X and $9A,X updated. IntegrateVerticalPosition: lda $0409,x ; $2BA0: BD 09 04 clc ; $2BA3: 18 adc $0412,x ; $2BA4: 7D 12 04 sta $0409,x ; $2BA7: 9D 09 04 lda $9A,x ; $2BAA: B5 9A adc $041B,x ; $2BAC: 7D 1B 04 sta $9A,x ; $2BAF: 95 9A rts ; $2BB1: 60 ; ApplyHorizontalCollisionResponse ; Purpose: run collision handling around horizontal integration. ; Inputs: X = object slot. ; Returns: collision response and position updated. ApplyHorizontalCollisionResponse: jsr $F0B4 ; $2BB2: 20 B4 F0 jsr IntegrateHorizontalPosition ; $2BB5: 20 8E EB jmp $F0B4 ; $2BB8: 4C B4 F0 ; ApplyVerticalCollisionResponse ; Purpose: run collision handling around vertical integration. ; Inputs: X = object slot. ; Returns: collision response and position updated. ApplyVerticalCollisionResponse: jsr $F0B4 ; $2BBB: 20 B4 F0 jsr IntegrateVerticalPosition ; $2BBE: 20 A0 EB jmp $F0B4 ; $2BC1: 4C B4 F0 ; UpdateObjectEnvironmentState ; Purpose: update environment-dependent object motion and collision flags. ; Inputs: X = object slot. ; Returns: movement flags and velocities adjusted. UpdateObjectEnvironmentState: cpx #$02 ; $2BC4: E0 02 bcs Label_EBE3 ; $2BC6: B0 1B lda $88,x ; $2BC8: B5 88 bne Label_EBD6 ; $2BCA: D0 0A lda $0436,x ; $2BCC: BD 36 04 bne Label_EBD6 ; $2BCF: D0 05 lda #$00 ; $2BD1: A9 00 sta $7F,x ; $2BD3: 95 7F rts ; $2BD5: 60 Label_EBD6: lda $7F,x ; $2BD6: B5 7F cmp #$06 ; $2BD8: C9 06 bcc Label_EC38 ; $2BDA: 90 5C lda #$01 ; $2BDC: A9 01 sta $7F,x ; $2BDE: 95 7F dec $88,x ; $2BE0: D6 88 rts ; $2BE2: 60 Label_EBE3: lda $88,x ; $2BE3: B5 88 cmp #$02 ; $2BE5: C9 02 beq Label_EC38 ; $2BE7: F0 4F lda $0436,x ; $2BE9: BD 36 04 bne Label_EBFD ; $2BEC: D0 0F lda $88,x ; $2BEE: B5 88 bne Label_EBF7 ; $2BF0: D0 05 lda #$00 ; $2BF2: A9 00 sta $7F,x ; $2BF4: 95 7F rts ; $2BF6: 60 Label_EBF7: lda $7F,x ; $2BF7: B5 7F bne Label_EBFE ; $2BF9: D0 03 inc $7F,x ; $2BFB: F6 7F Label_EBFD: rts ; $2BFD: 60 Label_EBFE: cmp #$02 ; $2BFE: C9 02 bcc Label_EBFD ; $2C00: 90 FB dec $045A,x ; $2C02: DE 5A 04 bne Label_EC37 ; $2C05: D0 30 lda $C7 ; $2C07: A5 C7 sta $045A,x ; $2C09: 9D 5A 04 inc $7F,x ; $2C0C: F6 7F lda $7F,x ; $2C0E: B5 7F cmp #$07 ; $2C10: C9 07 bcc Label_EC37 ; $2C12: 90 23 lda #$02 ; $2C14: A9 02 sta $88,x ; $2C16: 95 88 lda #$00 ; $2C18: A9 00 sta $7F,x ; $2C1A: 95 7F ldy $0451,x ; $2C1C: BC 51 04 lda EnvironmentStateTable,y ; $2C1F: B9 AE EC ldy $047E,x ; $2C22: BC 7E 04 bne Label_EC2F ; $2C25: D0 08 dec $047E,x ; $2C27: DE 7E 04 lda $0451,x ; $2C2A: BD 51 04 and #$03 ; $2C2D: 29 03 Label_EC2F: sta $0451,x ; $2C2F: 9D 51 04 lda #$FE ; $2C32: A9 FE sta $041B,x ; $2C34: 9D 1B 04 Label_EC37: rts ; $2C37: 60 Label_EC38: jsr $E6E9 ; $2C38: 20 E9 E6 lda $31,x ; $2C3B: B5 31 and #$C3 ; $2C3D: 29 C3 beq Label_EC49 ; $2C3F: F0 08 cpx #$02 ; $2C41: E0 02 bcs Label_EC49 ; $2C43: B0 04 lda #$00 ; $2C45: A9 00 sta $BD,x ; $2C47: 95 BD Label_EC49: lda $31,x ; $2C49: B5 31 and #$40 ; $2C4B: 29 40 bne Label_EC61 ; $2C4D: D0 12 lda $31,x ; $2C4F: B5 31 and #$80 ; $2C51: 29 80 bne Label_EC5C ; $2C53: D0 07 lda #$00 ; $2C55: A9 00 sta $0620,x ; $2C57: 9D 20 06 beq Label_ECAD ; $2C5A: F0 51 Label_EC5C: lda $0620,x ; $2C5C: BD 20 06 bne Label_ECAD ; $2C5F: D0 4C Label_EC61: lda $7F,x ; $2C61: B5 7F cmp #$02 ; $2C63: C9 02 bcc Label_EC75 ; $2C65: 90 0E dec $9A,x ; $2C67: D6 9A dec $9A,x ; $2C69: D6 9A lda #$00 ; $2C6B: A9 00 sta $0412,x ; $2C6D: 9D 12 04 sta $041B,x ; $2C70: 9D 1B 04 beq Label_EC7E ; $2C73: F0 09 Label_EC75: cmp #$01 ; $2C75: C9 01 beq Label_EC7E ; $2C77: F0 05 lda $0436,x ; $2C79: BD 36 04 bne Label_ECAD ; $2C7C: D0 2F Label_EC7E: lda #$00 ; $2C7E: A9 00 sta $7F,x ; $2C80: 95 7F lda #$01 ; $2C82: A9 01 sta $0436,x ; $2C84: 9D 36 04 lda #$01 ; $2C87: A9 01 sta $0620,x ; $2C89: 9D 20 06 ldy #$00 ; $2C8C: A0 00 cpx #$02 ; $2C8E: E0 02 bcc Label_EC93 ; $2C90: 90 01 iny ; $2C92: C8 Label_EC93: lda a:$00F0,y ; $2C93: B9 F0 00 ora #$10 ; $2C96: 09 10 sta a:$00F0,y ; $2C98: 99 F0 00 lda $0412,x ; $2C9B: BD 12 04 sec ; $2C9E: 38 ldy $0451,x ; $2C9F: BC 51 04 sbc $E60D,y ; $2CA2: F9 0D E6 sta $0412,x ; $2CA5: 9D 12 04 bcs Label_ECAD ; $2CA8: B0 03 dec $041B,x ; $2CAA: DE 1B 04 Label_ECAD: rts ; $2CAD: 60 ; Environment response pattern used by UpdateObjectEnvironmentState. EnvironmentStateTable: .byte $01, $02, $02, $03, $01, $02, $02, $03 ; $2CAE: 01 02 02 03 01 02 02 03 .byte $01, $02, $02, $03 ; $2CB6: 01 02 02 03 ; UpdateSpecialObjectState ; Purpose: update special/falling object states and test contact with active players. ; Inputs: X = object slot. ; Returns: position/state/event fields updated; X restored. UpdateSpecialObjectState: lda $7F,x ; $2CBA: B5 7F bne Label_ED27 ; $2CBC: D0 69 jsr $E7B1 ; $2CBE: 20 B1 E7 jsr $EB8E ; $2CC1: 20 8E EB lda $0409,x ; $2CC4: BD 09 04 sec ; $2CC7: 38 sbc #$60 ; $2CC8: E9 60 sta $0409,x ; $2CCA: 9D 09 04 lda $9A,x ; $2CCD: B5 9A sbc #$00 ; $2CCF: E9 00 sta $9A,x ; $2CD1: 95 9A cmp #$F1 ; $2CD3: C9 F1 bcc Label_ECDB ; $2CD5: 90 04 lda #$FF ; $2CD7: A9 FF sta $88,x ; $2CD9: 95 88 Label_ECDB: txa ; $2CDB: 8A pha ; $2CDC: 48 ldy #$01 ; $2CDD: A0 01 Label_ECDF: lda a:$0088,y ; $2CDF: B9 88 00 beq Label_ED22 ; $2CE2: F0 3E bmi Label_ED22 ; $2CE4: 30 3C lda $9A,x ; $2CE6: B5 9A sec ; $2CE8: 38 sbc a:$009A,y ; $2CE9: F9 9A 00 jsr $F08E ; $2CEC: 20 8E F0 cmp #$18 ; $2CEF: C9 18 bcs Label_ED22 ; $2CF1: B0 2F lda $91,x ; $2CF3: B5 91 sec ; $2CF5: 38 sbc a:$0091,y ; $2CF6: F9 91 00 jsr $F08E ; $2CF9: 20 8E F0 cmp #$10 ; $2CFC: C9 10 bcs Label_ED22 ; $2CFE: B0 22 lda #$FF ; $2D00: A9 FF sta $7F,x ; $2D02: 95 7F lda #$03 ; $2D04: A9 03 sta $045A,x ; $2D06: 9D 5A 04 lda #$78 ; $2D09: A9 78 sta $C5 ; $2D0B: 85 C5 lda #$02 ; $2D0D: A9 02 sta $F0 ; $2D0F: 85 F0 lda #$32 ; $2D11: A9 32 sty $3E ; $2D13: 84 3E jsr $D6DE ; $2D15: 20 DE D6 lda #$01 ; $2D18: A9 01 ldx $3E ; $2D1A: A6 3E jsr $D871 ; $2D1C: 20 71 D8 pla ; $2D1F: 68 tax ; $2D20: AA rts ; $2D21: 60 Label_ED22: dey ; $2D22: 88 bpl Label_ECDF ; $2D23: 10 BA pla ; $2D25: 68 tax ; $2D26: AA Label_ED27: rts ; $2D27: 60 ; ResolveStageCollision ; Purpose: test an object against stage collision boundaries and classify contact side. ; Inputs: X = object slot; stage collision pointers in zero page. ; Returns: collision mask in $CC and response fields updated. ResolveStageCollision: ldy $88,x ; $2D28: B4 88 dey ; $2D2A: 88 bpl Label_ED2E ; $2D2B: 10 01 Label_ED2D: rts ; $2D2D: 60 Label_ED2E: lda $9A,x ; $2D2E: B5 9A cmp #$F9 ; $2D30: C9 F9 bcc Label_ED40 ; $2D32: 90 0C lda $041B,x ; $2D34: BD 1B 04 bpl Label_ED2D ; $2D37: 10 F4 lda #$00 ; $2D39: A9 00 sta $CC ; $2D3B: 85 CC jmp Label_EDE1 ; $2D3D: 4C E1 ED Label_ED40: ldy $CD ; $2D40: A4 CD bmi Label_ED27 ; $2D42: 30 E3 Label_ED44: lda #$00 ; $2D44: A9 00 sta $CC ; $2D46: 85 CC lda ($27),y ; $2D48: B1 27 sec ; $2D4A: 38 sbc #$18 ; $2D4B: E9 18 cmp $9A,x ; $2D4D: D5 9A bcs Label_EDB6 ; $2D4F: B0 65 adc #$03 ; $2D51: 69 03 cmp $9A,x ; $2D53: D5 9A bcc Label_ED5B ; $2D55: 90 04 lda #$01 ; $2D57: A9 01 bne Label_ED69 ; $2D59: D0 0E Label_ED5B: lda ($29),y ; $2D5B: B1 29 cmp $9A,x ; $2D5D: D5 9A bcc Label_EDB6 ; $2D5F: 90 55 sbc #$03 ; $2D61: E9 03 cmp $9A,x ; $2D63: D5 9A bcs Label_ED89 ; $2D65: B0 22 lda #$02 ; $2D67: A9 02 Label_ED69: sta $CC ; $2D69: 85 CC lda ($23),y ; $2D6B: B1 23 cmp #$10 ; $2D6D: C9 10 beq Label_ED78 ; $2D6F: F0 07 sec ; $2D71: 38 sbc #$0C ; $2D72: E9 0C cmp $91,x ; $2D74: D5 91 bcs Label_ED85 ; $2D76: B0 0D Label_ED78: lda ($25),y ; $2D78: B1 25 cmp #$FF ; $2D7A: C9 FF beq Label_ED89 ; $2D7C: F0 0B sec ; $2D7E: 38 sbc #$04 ; $2D7F: E9 04 cmp $91,x ; $2D81: D5 91 bcs Label_ED89 ; $2D83: B0 04 Label_ED85: lda #$00 ; $2D85: A9 00 sta $CC ; $2D87: 85 CC Label_ED89: lda ($23),y ; $2D89: B1 23 sec ; $2D8B: 38 sbc #$10 ; $2D8C: E9 10 beq Label_EDA0 ; $2D8E: F0 10 cmp $91,x ; $2D90: D5 91 bcs Label_EDB6 ; $2D92: B0 22 adc #$04 ; $2D94: 69 04 cmp $91,x ; $2D96: D5 91 bcc Label_EDA0 ; $2D98: 90 06 lda $CC ; $2D9A: A5 CC ora #$04 ; $2D9C: 09 04 bne Label_EDB4 ; $2D9E: D0 14 Label_EDA0: lda ($25),y ; $2DA0: B1 25 cmp #$FF ; $2DA2: C9 FF beq Label_EDB6 ; $2DA4: F0 10 cmp $91,x ; $2DA6: D5 91 bcc Label_EDB6 ; $2DA8: 90 0C sbc #$04 ; $2DAA: E9 04 cmp $91,x ; $2DAC: D5 91 bcs Label_EDB6 ; $2DAE: B0 06 lda $CC ; $2DB0: A5 CC ora #$08 ; $2DB2: 09 08 Label_EDB4: sta $CC ; $2DB4: 85 CC Label_EDB6: lda $CC ; $2DB6: A5 CC bne Label_EDC1 ; $2DB8: D0 07 dey ; $2DBA: 88 bmi Label_EDC0 ; $2DBB: 30 03 jmp Label_ED44 ; $2DBD: 4C 44 ED Label_EDC0: rts ; $2DC0: 60 Label_EDC1: lsr $CC ; $2DC1: 46 CC bcc Label_EDD6 ; $2DC3: 90 11 lda $041B,x ; $2DC5: BD 1B 04 bmi Label_EDD6 ; $2DC8: 30 0C lda ($27),y ; $2DCA: B1 27 sbc #$18 ; $2DCC: E9 18 sta $9A,x ; $2DCE: 95 9A inc $9A,x ; $2DD0: F6 9A lda #$01 ; $2DD2: A9 01 sta $CB ; $2DD4: 85 CB Label_EDD6: lsr $CC ; $2DD6: 46 CC bcc Label_EDF4 ; $2DD8: 90 1A lda $041B,x ; $2DDA: BD 1B 04 bpl Label_EDF4 ; $2DDD: 10 15 lda ($29),y ; $2DDF: B1 29 Label_EDE1: sta $9A,x ; $2DE1: 95 9A jsr $F107 ; $2DE3: 20 07 F1 jsr $F18C ; $2DE6: 20 8C F1 cpx #$02 ; $2DE9: E0 02 bcs Label_EDF0 ; $2DEB: B0 03 jsr $CC33 ; $2DED: 20 33 CC Label_EDF0: lda $CB ; $2DF0: A5 CB bne Label_EE24 ; $2DF2: D0 30 Label_EDF4: lsr $CC ; $2DF4: 46 CC bcc Label_EDFF ; $2DF6: 90 07 lda $042D,x ; $2DF8: BD 2D 04 bmi Label_EDFF ; $2DFB: 30 02 bpl Label_EE08 ; $2DFD: 10 09 Label_EDFF: lsr $CC ; $2DFF: 46 CC bcc Label_EE24 ; $2E01: 90 21 lda $042D,x ; $2E03: BD 2D 04 bpl Label_EE24 ; $2E06: 10 1C Label_EE08: jsr $F0DE ; $2E08: 20 DE F0 jsr $F172 ; $2E0B: 20 72 F1 lda $042D,x ; $2E0E: BD 2D 04 ora $0424,x ; $2E11: 1D 24 04 beq Label_EE24 ; $2E14: F0 0E lda $0448,x ; $2E16: BD 48 04 eor #$01 ; $2E19: 49 01 sta $0448,x ; $2E1B: 9D 48 04 lda $F1 ; $2E1E: A5 F1 ora #$02 ; $2E20: 09 02 sta $F1 ; $2E22: 85 F1 Label_EE24: rts ; $2E24: 60 ; CheckObjectInteractions ; Purpose: compare active object pairs and dispatch overlap resolution. ; Inputs: active object arrays. ; Returns: collisions resolved; event and score state may be updated. CheckObjectInteractions: ldx #$07 ; $2E25: A2 07 Label_EE27: stx $12 ; $2E27: 86 12 ldy $12 ; $2E29: A4 12 dey ; $2E2B: 88 bpl Label_EE31 ; $2E2C: 10 03 Label_EE2E: jmp Label_EF2A ; $2E2E: 4C 2A EF Label_EE31: lda $88,x ; $2E31: B5 88 bmi Label_EE2E ; $2E33: 30 F9 beq Label_EE2E ; $2E35: F0 F7 lda a:$0088,y ; $2E37: B9 88 00 bmi Label_EE2E ; $2E3A: 30 F2 beq Label_EE2E ; $2E3C: F0 F0 lda #$00 ; $2E3E: A9 00 sta $CC ; $2E40: 85 CC lda a:$009A,y ; $2E42: B9 9A 00 sec ; $2E45: 38 sbc $9A,x ; $2E46: F5 9A jsr $F08E ; $2E48: 20 8E F0 cmp #$18 ; $2E4B: C9 18 bcs Label_EEC0 ; $2E4D: B0 71 lda $9A,x ; $2E4F: B5 9A clc ; $2E51: 18 adc #$18 ; $2E52: 69 18 sta $12 ; $2E54: 85 12 lda a:$009A,y ; $2E56: B9 9A 00 clc ; $2E59: 18 adc #$07 ; $2E5A: 69 07 sec ; $2E5C: 38 sbc $12 ; $2E5D: E5 12 jsr $F08E ; $2E5F: 20 8E F0 cmp #$04 ; $2E62: C9 04 bcs Label_EE6A ; $2E64: B0 04 lda #$01 ; $2E66: A9 01 bne Label_EE7C ; $2E68: D0 12 Label_EE6A: lda a:$009A,y ; $2E6A: B9 9A 00 clc ; $2E6D: 18 adc #$11 ; $2E6E: 69 11 sec ; $2E70: 38 sbc $9A,x ; $2E71: F5 9A jsr $F08E ; $2E73: 20 8E F0 cmp #$04 ; $2E76: C9 04 bcs Label_EE8F ; $2E78: B0 15 lda #$02 ; $2E7A: A9 02 Label_EE7C: sta $CC ; $2E7C: 85 CC lda a:$0091,y ; $2E7E: B9 91 00 sec ; $2E81: 38 sbc $91,x ; $2E82: F5 91 jsr $F08E ; $2E84: 20 8E F0 cmp #$10 ; $2E87: C9 10 bcc Label_EE8F ; $2E89: 90 04 lda #$00 ; $2E8B: A9 00 sta $CC ; $2E8D: 85 CC Label_EE8F: lda $91,x ; $2E8F: B5 91 clc ; $2E91: 18 adc #$10 ; $2E92: 69 10 sta $12 ; $2E94: 85 12 lda a:$0091,y ; $2E96: B9 91 00 clc ; $2E99: 18 adc #$07 ; $2E9A: 69 07 sec ; $2E9C: 38 sbc $12 ; $2E9D: E5 12 jsr $F08E ; $2E9F: 20 8E F0 cmp #$04 ; $2EA2: C9 04 bcs Label_EEAA ; $2EA4: B0 04 lda #$04 ; $2EA6: A9 04 bne Label_EEBC ; $2EA8: D0 12 Label_EEAA: lda a:$0091,y ; $2EAA: B9 91 00 clc ; $2EAD: 18 adc #$09 ; $2EAE: 69 09 sec ; $2EB0: 38 sbc $91,x ; $2EB1: F5 91 jsr $F08E ; $2EB3: 20 8E F0 cmp #$04 ; $2EB6: C9 04 bcs Label_EEC0 ; $2EB8: B0 06 lda #$08 ; $2EBA: A9 08 Label_EEBC: ora $CC ; $2EBC: 05 CC sta $CC ; $2EBE: 85 CC Label_EEC0: lda #$00 ; $2EC0: A9 00 sta $4B ; $2EC2: 85 4B lsr $CC ; $2EC4: 46 CC bcc Label_EECD ; $2EC6: 90 05 jsr $F0A6 ; $2EC8: 20 A6 F0 bmi Label_EED6 ; $2ECB: 30 09 Label_EECD: lsr $CC ; $2ECD: 46 CC bcc Label_EEF1 ; $2ECF: 90 20 jsr $F0A6 ; $2ED1: 20 A6 F0 bmi Label_EEF1 ; $2ED4: 30 1B Label_EED6: jsr $F0BD ; $2ED6: 20 BD F0 bcs Label_EEED ; $2ED9: B0 12 jsr $F107 ; $2EDB: 20 07 F1 jsr $F18C ; $2EDE: 20 8C F1 jsr $F0B4 ; $2EE1: 20 B4 F0 jsr $F107 ; $2EE4: 20 07 F1 jsr $F18C ; $2EE7: 20 8C F1 jsr $F0B4 ; $2EEA: 20 B4 F0 Label_EEED: lda #$01 ; $2EED: A9 01 sta $4B ; $2EEF: 85 4B Label_EEF1: lsr $CC ; $2EF1: 46 CC bcc Label_EEFA ; $2EF3: 90 05 jsr $F098 ; $2EF5: 20 98 F0 bmi Label_EF03 ; $2EF8: 30 09 Label_EEFA: lsr $CC ; $2EFA: 46 CC bcc Label_EF1E ; $2EFC: 90 20 jsr $F098 ; $2EFE: 20 98 F0 bmi Label_EF1E ; $2F01: 30 1B Label_EF03: jsr $F0BD ; $2F03: 20 BD F0 bcs Label_EF1A ; $2F06: B0 12 jsr $F0DE ; $2F08: 20 DE F0 jsr $F172 ; $2F0B: 20 72 F1 jsr $F0B4 ; $2F0E: 20 B4 F0 jsr $F0DE ; $2F11: 20 DE F0 jsr $F172 ; $2F14: 20 72 F1 jsr $F0B4 ; $2F17: 20 B4 F0 Label_EF1A: lda #$01 ; $2F1A: A9 01 sta $4B ; $2F1C: 85 4B Label_EF1E: jsr ResolveObjectCollisionPair ; $2F1E: 20 37 EF jsr $F0B4 ; $2F21: 20 B4 F0 jsr ResolveObjectCollisionPair ; $2F24: 20 37 EF jsr $F0B4 ; $2F27: 20 B4 F0 Label_EF2A: dey ; $2F2A: 88 bmi Label_EF30 ; $2F2B: 30 03 jmp Label_EE31 ; $2F2D: 4C 31 EE Label_EF30: dex ; $2F30: CA bmi Label_EF36 ; $2F31: 30 03 jmp Label_EE27 ; $2F33: 4C 27 EE Label_EF36: rts ; $2F36: 60 ; ResolveObjectCollisionPair ; Purpose: resolve one overlapping pair and apply state, score, sound, and knockback effects. ; Inputs: X/Y = object pair. ; Returns: both object records and global event flags may change. ResolveObjectCollisionPair: cpx #$02 ; $2F37: E0 02 bcc Label_EF42 ; $2F39: 90 07 cpy #$02 ; $2F3B: C0 02 bcc Label_EF42 ; $2F3D: 90 03 jmp Label_F043 ; $2F3F: 4C 43 F0 Label_EF42: lda #$00 ; $2F42: A9 00 sta $0487 ; $2F44: 8D 87 04 lda $0475,x ; $2F47: BD 75 04 beq Label_EF4F ; $2F4A: F0 03 jmp Label_F043 ; $2F4C: 4C 43 F0 Label_EF4F: lda $4B ; $2F4F: A5 4B bne Label_EF56 ; $2F51: D0 03 jmp Label_F043 ; $2F53: 4C 43 F0 Label_EF56: cpx #$02 ; $2F56: E0 02 bcs Label_EF61 ; $2F58: B0 07 lda $BD,x ; $2F5A: B5 BD beq Label_EF72 ; $2F5C: F0 14 jmp Label_F043 ; $2F5E: 4C 43 F0 Label_EF61: lda $88,x ; $2F61: B5 88 cmp #$01 ; $2F63: C9 01 bne Label_EF72 ; $2F65: D0 0B lda $7F,x ; $2F67: B5 7F cmp #$02 ; $2F69: C9 02 bcs Label_EF7F ; $2F6B: B0 12 lda #$01 ; $2F6D: A9 01 sta $0487 ; $2F6F: 8D 87 04 Label_EF72: lda a:$009A,y ; $2F72: B9 9A 00 clc ; $2F75: 18 adc #$04 ; $2F76: 69 04 cmp $9A,x ; $2F78: D5 9A bcc Label_EF7F ; $2F7A: 90 03 jmp Label_F043 ; $2F7C: 4C 43 F0 Label_EF7F: lda #$14 ; $2F7F: A9 14 sta $0475,x ; $2F81: 9D 75 04 lda #$00 ; $2F84: A9 00 sta $0436,x ; $2F86: 9D 36 04 cpy #$02 ; $2F89: C0 02 bcc Label_EF97 ; $2F8B: 90 0A lda a:$0088,y ; $2F8D: B9 88 00 cmp #$02 ; $2F90: C9 02 beq Label_EF97 ; $2F92: F0 03 jmp Label_F043 ; $2F94: 4C 43 F0 Label_EF97: lda $F0 ; $2F97: A5 F0 ora #$02 ; $2F99: 09 02 sta $F0 ; $2F9B: 85 F0 lda $88,x ; $2F9D: B5 88 cmp #$02 ; $2F9F: C9 02 bne Label_EFC0 ; $2FA1: D0 1D cpx #$02 ; $2FA3: E0 02 bcs Label_EFC0 ; $2FA5: B0 19 sty $12 ; $2FA7: 84 12 ldy $7F,x ; $2FA9: B4 7F lda CollisionResultStateTable,y ; $2FAB: B9 53 F0 ldy $12 ; $2FAE: A4 12 pha ; $2FB0: 48 pla ; $2FB1: 68 bne Label_EFB7 ; $2FB2: D0 03 jmp Label_F043 ; $2FB4: 4C 43 F0 Label_EFB7: sta $7F,x ; $2FB7: 95 7F lda #$00 ; $2FB9: A9 00 sta $0436,x ; $2FBB: 9D 36 04 beq Label_EFEA ; $2FBE: F0 2A Label_EFC0: dec $88,x ; $2FC0: D6 88 bne Label_EFCE ; $2FC2: D0 0A lda #$FF ; $2FC4: A9 FF sta $041B,x ; $2FC6: 9D 1B 04 lda #$00 ; $2FC9: A9 00 sta $0412,x ; $2FCB: 9D 12 04 Label_EFCE: lda #$00 ; $2FCE: A9 00 sta $7F,x ; $2FD0: 95 7F sta $0424,x ; $2FD2: 9D 24 04 sta $042D,x ; $2FD5: 9D 2D 04 lda $91,x ; $2FD8: B5 91 bmi Label_EFE0 ; $2FDA: 30 04 lda #$FF ; $2FDC: A9 FF bne Label_EFE2 ; $2FDE: D0 02 Label_EFE0: lda #$00 ; $2FE0: A9 00 Label_EFE2: sta $046C,x ; $2FE2: 9D 6C 04 lda #$80 ; $2FE5: A9 80 sta $0463,x ; $2FE7: 9D 63 04 Label_EFEA: sty $12 ; $2FEA: 84 12 ldy $0451,x ; $2FEC: BC 51 04 lda ObjectStateTransitionTable,y ; $2FEF: B9 5E F0 sta $0451,x ; $2FF2: 9D 51 04 lda #$01 ; $2FF5: A9 01 sta $047E,x ; $2FF7: 9D 7E 04 ldy $12 ; $2FFA: A4 12 cpy #$02 ; $2FFC: C0 02 bcs Label_F043 ; $2FFE: B0 43 lda $0451,x ; $3000: BD 51 04 cmp #$07 ; $3003: C9 07 beq Label_F011 ; $3005: F0 0A cmp #$08 ; $3007: C9 08 bcc Label_F011 ; $3009: 90 06 lda $F1 ; $300B: A5 F1 ora #$80 ; $300D: 09 80 sta $F1 ; $300F: 85 F1 Label_F011: ldy $0451,x ; $3011: BC 51 04 lda CollisionSoundTable,y ; $3014: B9 6A F0 sta $13 ; $3017: 85 13 lda $0487 ; $3019: AD 87 04 beq Label_F023 ; $301C: F0 05 lda CollisionScoreTable,y ; $301E: B9 76 F0 sta $13 ; $3021: 85 13 Label_F023: lda CollisionEventTable,y ; $3023: B9 82 F0 clc ; $3026: 18 adc $0487 ; $3027: 6D 87 04 sta $14 ; $302A: 85 14 lda $12 ; $302C: A5 12 sta $3E ; $302E: 85 3E pha ; $3030: 48 txa ; $3031: 8A pha ; $3032: 48 lda $13 ; $3033: A5 13 pha ; $3035: 48 lda $14 ; $3036: A5 14 jsr $D871 ; $3038: 20 71 D8 pla ; $303B: 68 jsr $D6DE ; $303C: 20 DE D6 pla ; $303F: 68 tax ; $3040: AA pla ; $3041: 68 tay ; $3042: A8 Label_F043: lda $0451,x ; $3043: BD 51 04 cmp #$0B ; $3046: C9 0B bne Label_F052 ; $3048: D0 08 lda $C8 ; $304A: A5 C8 bne Label_F052 ; $304C: D0 04 lda #$20 ; $304E: A9 20 sta $F0 ; $3050: 85 F0 Label_F052: rts ; $3052: 60 ; Collision outcome state values indexed by collision class. CollisionResultStateTable: .byte $06, $06, $07, $08, $09, $0A, $00, $00, $00, $00, $00 ; $3053: 06 06 07 08 09 0A 00 00 00 00 00 ; Post-collision object-state transitions. ObjectStateTransitionTable: .byte $04, $05, $06, $07, $08, $09, $0A, $0B, $08, $09, $0A, $0B ; $305E: 04 05 06 07 08 09 0A 0B 08 09 0A 0B ; Collision sound/event magnitude values. CollisionSoundTable: .byte $00, $00, $00, $00, $32, $4B, $64, $64, $4B, $64, $96, $64 ; $306A: 00 00 00 00 32 4B 64 64 4B 64 96 64 ; Collision score/reward values. CollisionScoreTable: .byte $00, $00, $00, $00, $32, $4B, $64, $64, $64, $96, $C8, $64 ; $3076: 00 00 00 00 32 4B 64 64 64 96 C8 64 ; Collision event identifiers. CollisionEventTable: .byte $00, $00, $00, $00, $01, $02, $03, $03, $02, $03, $04, $03 ; $3082: 00 00 00 00 01 02 03 03 02 03 04 03 ; AbsoluteDifferenceA ; Purpose: return the absolute value of signed accumulator A. ; Inputs: A = signed delta. ; Returns: A = absolute magnitude. AbsoluteDifferenceA: pha ; $308E: 48 pla ; $308F: 68 bpl Label_F097 ; $3090: 10 05 eor #$FF ; $3092: 49 FF clc ; $3094: 18 adc #$01 ; $3095: 69 01 Label_F097: rts ; $3097: 60 ; SubtractHorizontalVelocityPair ; Purpose: calculate Y-object minus X-object horizontal velocity. ; Inputs: X/Y = object indexes. ; Returns: A/high arithmetic state from $0424/$042D difference. SubtractHorizontalVelocityPair: lda $0424,y ; $3098: B9 24 04 sec ; $309B: 38 sbc $0424,x ; $309C: FD 24 04 lda $042D,y ; $309F: B9 2D 04 sbc $042D,x ; $30A2: FD 2D 04 rts ; $30A5: 60 ; SubtractVerticalVelocityPair ; Purpose: calculate Y-object minus X-object vertical velocity. ; Inputs: X/Y = object indexes. ; Returns: A/high arithmetic state from $0412/$041B difference. SubtractVerticalVelocityPair: lda $0412,y ; $30A6: B9 12 04 sec ; $30A9: 38 sbc $0412,x ; $30AA: FD 12 04 lda $041B,y ; $30AD: B9 1B 04 sbc $041B,x ; $30B0: FD 1B 04 rts ; $30B3: 60 ; SwapObjectIndexes ; Purpose: exchange X and Y through scratch bytes. ; Inputs: X/Y = object indexes. ; Returns: X/Y swapped. SwapObjectIndexes: stx $12 ; $30B4: 86 12 sty $13 ; $30B6: 84 13 ldx $13 ; $30B8: A6 13 ldy $12 ; $30BA: A4 12 rts ; $30BC: 60 ; TestPairCollisionEligibility ; Purpose: test whether an object pair can participate in collision response. ; Inputs: X/Y = object indexes. ; Returns: A = zero if rejected, nonzero if eligible. TestPairCollisionEligibility: cpx #$02 ; $30BD: E0 02 bcc Label_F0DD ; $30BF: 90 1C lda $7F,x ; $30C1: B5 7F cmp #$02 ; $30C3: C9 02 bcc Label_F0DD ; $30C5: 90 16 lda #$01 ; $30C7: A9 01 cmp $88,x ; $30C9: D5 88 bcs Label_F0DD ; $30CB: B0 10 cpy #$02 ; $30CD: C0 02 bcc Label_F0DD ; $30CF: 90 0C lda a:$007F,y ; $30D1: B9 7F 00 cmp #$02 ; $30D4: C9 02 bcc Label_F0DD ; $30D6: 90 05 lda #$01 ; $30D8: A9 01 cmp a:$0088,y ; $30DA: D9 88 00 Label_F0DD: rts ; $30DD: 60 ; NegateHorizontalMotion ; Purpose: negate an object horizontal velocity and acceleration pair. ; Inputs: X = object slot. ; Returns: horizontal motion fields negated; direction flag normalized. NegateHorizontalMotion: lda #$00 ; $30DE: A9 00 sec ; $30E0: 38 sbc $0424,x ; $30E1: FD 24 04 sta $0424,x ; $30E4: 9D 24 04 lda #$00 ; $30E7: A9 00 sbc $042D,x ; $30E9: FD 2D 04 sta $042D,x ; $30EC: 9D 2D 04 lda #$00 ; $30EF: A9 00 sec ; $30F1: 38 sbc $0463,x ; $30F2: FD 63 04 sta $0463,x ; $30F5: 9D 63 04 lda #$00 ; $30F8: A9 00 sbc $046C,x ; $30FA: FD 6C 04 sta $046C,x ; $30FD: 9D 6C 04 lda $31,x ; $3100: B5 31 and #$40 ; $3102: 29 40 sta $31,x ; $3104: 95 31 rts ; $3106: 60 ; NegateVerticalMotion ; Purpose: negate an object vertical velocity pair. ; Inputs: X = object slot. ; Returns: vertical motion fields negated. NegateVerticalMotion: lda #$00 ; $3107: A9 00 sec ; $3109: 38 sbc $0412,x ; $310A: FD 12 04 sta $0412,x ; $310D: 9D 12 04 lda #$00 ; $3110: A9 00 sbc $041B,x ; $3112: FD 1B 04 sta $041B,x ; $3115: 9D 1B 04 rts ; $3118: 60 ; MultiplySignedValue ; Purpose: multiply a signed 16-bit value by an 8-bit factor. ; Inputs: signed value in $2B/$2C, multiplier in A. ; Returns: signed product in $2E-$30. MultiplySignedValue: sta $2D ; $3119: 85 2D lda $2C ; $311B: A5 2C bpl MultiplyUnsigned16By8 ; $311D: 10 24 lda #$00 ; $311F: A9 00 sec ; $3121: 38 sbc $2B ; $3122: E5 2B sta $2B ; $3124: 85 2B lda #$00 ; $3126: A9 00 sbc $2C ; $3128: E5 2C sta $2C ; $312A: 85 2C jsr MultiplyUnsigned16By8 ; $312C: 20 43 F1 lda #$00 ; $312F: A9 00 sec ; $3131: 38 sbc $2E ; $3132: E5 2E sta $2E ; $3134: 85 2E lda #$00 ; $3136: A9 00 sbc $2F ; $3138: E5 2F sta $2F ; $313A: 85 2F lda #$00 ; $313C: A9 00 sbc $30 ; $313E: E5 30 sta $30 ; $3140: 85 30 rts ; $3142: 60 ; MultiplyUnsigned16By8 ; Purpose: perform the unsigned shift-add multiply core. ; Inputs: $2B/$2C multiplicand, $2D multiplier. ; Returns: 24-bit product in $2E-$30. MultiplyUnsigned16By8: txa ; $3143: 8A pha ; $3144: 48 lda #$00 ; $3145: A9 00 sta $2E ; $3147: 85 2E sta $2F ; $3149: 85 2F sta $30 ; $314B: 85 30 ldx #$08 ; $314D: A2 08 Label_F14F: asl $2E ; $314F: 06 2E rol $2F ; $3151: 26 2F rol $30 ; $3153: 26 30 asl $2D ; $3155: 06 2D bcc Label_F16C ; $3157: 90 13 clc ; $3159: 18 lda $2B ; $315A: A5 2B adc $2E ; $315C: 65 2E sta $2E ; $315E: 85 2E lda $2C ; $3160: A5 2C adc $2F ; $3162: 65 2F sta $2F ; $3164: 85 2F lda #$00 ; $3166: A9 00 adc $30 ; $3168: 65 30 sta $30 ; $316A: 85 30 Label_F16C: dex ; $316C: CA bne Label_F14F ; $316D: D0 E0 pla ; $316F: 68 tax ; $3170: AA rts ; $3171: 60 ; ScaleHorizontalVelocity ; Purpose: scale horizontal velocity by the fixed collision factor. ; Inputs: X = object slot. ; Returns: $0424/$042D scaled. ScaleHorizontalVelocity: lda $0424,x ; $3172: BD 24 04 sta $2B ; $3175: 85 2B lda $042D,x ; $3177: BD 2D 04 sta $2C ; $317A: 85 2C lda #$CD ; $317C: A9 CD jsr MultiplySignedValue ; $317E: 20 19 F1 lda $2F ; $3181: A5 2F sta $0424,x ; $3183: 9D 24 04 lda $30 ; $3186: A5 30 sta $042D,x ; $3188: 9D 2D 04 rts ; $318B: 60 ; ScaleVerticalVelocity ; Purpose: scale vertical velocity by the fixed collision factor. ; Inputs: X = object slot. ; Returns: $0412/$041B scaled. ScaleVerticalVelocity: lda $0412,x ; $318C: BD 12 04 sta $2B ; $318F: 85 2B lda $041B,x ; $3191: BD 1B 04 sta $2C ; $3194: 85 2C lda #$CD ; $3196: A9 CD jsr MultiplySignedValue ; $3198: 20 19 F1 lda $2F ; $319B: A5 2F sta $0412,x ; $319D: 9D 12 04 lda $30 ; $31A0: A5 30 sta $041B,x ; $31A2: 9D 1B 04 rts ; $31A5: 60 ; ShiftInputVectorRight4 ; Purpose: arithmetic-shift the two-byte input vector right four places. ; Inputs: vector in $12/$13. ; Returns: scaled vector in $12/$13. ShiftInputVectorRight4: ldy #$04 ; $31A6: A0 04 Label_F1A8: lda $13 ; $31A8: A5 13 asl a ; $31AA: 0A ror $13 ; $31AB: 66 13 ror $12 ; $31AD: 66 12 dey ; $31AF: 88 bne Label_F1A8 ; $31B0: D0 F6 rts ; $31B2: 60 ; NextRandomByte ; Purpose: advance the game pseudo-random shift register. ; Inputs: random state in $1B/$1C. ; Returns: A and $1B contain the next random byte. NextRandomByte: txa ; $31B3: 8A pha ; $31B4: 48 ldx #$0B ; $31B5: A2 0B Label_F1B7: asl $1B ; $31B7: 06 1B rol $1C ; $31B9: 26 1C rol a ; $31BB: 2A rol a ; $31BC: 2A eor $1B ; $31BD: 45 1B rol a ; $31BF: 2A eor $1B ; $31C0: 45 1B lsr a ; $31C2: 4A lsr a ; $31C3: 4A eor #$FF ; $31C4: 49 FF and #$01 ; $31C6: 29 01 ora $1B ; $31C8: 05 1B sta $1B ; $31CA: 85 1B dex ; $31CC: CA bne Label_F1B7 ; $31CD: D0 E8 pla ; $31CF: 68 tax ; $31D0: AA lda $1B ; $31D1: A5 1B rts ; $31D3: 60 Label_F1D4: jsr $DAC1 ; $31D4: 20 C1 DA ldx #$09 ; $31D7: A2 09 Label_F1D9: lda #$00 ; $31D9: A9 00 sta $03,x ; $31DB: 95 03 dex ; $31DD: CA bpl Label_F1D9 ; $31DE: 10 F9 sta $3E ; $31E0: 85 3E inc $41 ; $31E2: E6 41 jsr $D6DE ; $31E4: 20 DE D6 lda #$0F ; $31E7: A9 0F sta $4015 ; $31E9: 8D 15 40 lda #$01 ; $31EC: A9 01 sta $F0 ; $31EE: 85 F0 lda #$02 ; $31F0: A9 02 ; InitializeRoundObjects ; Purpose: initialize object slots and round-specific gameplay state. ; Inputs: round/stage globals. ; Returns: object arrays, sound state, and counters initialized. InitializeRoundObjects: sta $41 ; $31F2: 85 41 ldy $40 ; $31F4: A4 40 bne Label_F1FA ; $31F6: D0 02 lda #$FF ; $31F8: A9 FF Label_F1FA: sta $42 ; $31FA: 85 42 ldx #$00 ; $31FC: A2 00 stx $0488 ; $31FE: 8E 88 04 stx $3B ; $3201: 86 3B stx $3C ; $3203: 86 3C stx $0558 ; $3205: 8E 58 05 dex ; $3208: CA stx $89 ; $3209: 86 89 ldx $40 ; $320B: A6 40 Label_F20D: jsr $F3B0 ; $320D: 20 B0 F3 dex ; $3210: CA bpl Label_F20D ; $3211: 10 FA Label_F213: lda #$00 ; $3213: A9 00 sta $C8 ; $3215: 85 C8 lda $3C ; $3217: A5 3C lsr a ; $3219: 4A lsr a ; $321A: 4A cmp #$08 ; $321B: C9 08 bcc Label_F221 ; $321D: 90 02 lda #$08 ; $321F: A9 08 Label_F221: tax ; $3221: AA lda RoundObjectTypeTable,x ; $3222: BD BA F3 sta $C6 ; $3225: 85 C6 lda RoundObjectPositionTable,x ; $3227: BD C3 F3 sta $C7 ; $322A: 85 C7 lda $3C ; $322C: A5 3C cmp #$02 ; $322E: C9 02 bcs Label_F238 ; $3230: B0 06 lda #$03 ; $3232: A9 03 sta $C6 ; $3234: 85 C6 sta $C7 ; $3236: 85 C7 Label_F238: ldx #$07 ; $3238: A2 07 Label_F23A: lda #$00 ; $323A: A9 00 sta $0448,x ; $323C: 9D 48 04 sta $0475,x ; $323F: 9D 75 04 sta $047E,x ; $3242: 9D 7E 04 sta $0424,x ; $3245: 9D 24 04 sta $042D,x ; $3248: 9D 2D 04 sta $0412,x ; $324B: 9D 12 04 sta $041B,x ; $324E: 9D 1B 04 sta $0463,x ; $3251: 9D 63 04 sta $046C,x ; $3254: 9D 6C 04 sta $0400,x ; $3257: 9D 00 04 sta $0409,x ; $325A: 9D 09 04 lda #$01 ; $325D: A9 01 sta $043F,x ; $325F: 9D 3F 04 sta $045A,x ; $3262: 9D 5A 04 lda #$03 ; $3265: A9 03 sta $0436,x ; $3267: 9D 36 04 dex ; $326A: CA bpl Label_F23A ; $326B: 10 CD ldx #$05 ; $326D: A2 05 Label_F26F: lda #$FF ; $326F: A9 FF sta $8A,x ; $3271: 95 8A dex ; $3273: CA bpl Label_F26F ; $3274: 10 F9 ldx $40 ; $3276: A6 40 Label_F278: jsr ResetObjectMotion ; $3278: 20 86 F3 dex ; $327B: CA bpl Label_F278 ; $327C: 10 FA jsr $D246 ; $327E: 20 46 D2 jsr $D293 ; $3281: 20 93 D2 lda $C6 ; $3284: A5 C6 cmp #$10 ; $3286: C9 10 bcs Label_F28E ; $3288: B0 04 lda #$58 ; $328A: A9 58 sta $C6 ; $328C: 85 C6 Label_F28E: jsr $F4A5 ; $328E: 20 A5 F4 jsr $D8FF ; $3291: 20 FF D8 lda $16 ; $3294: A5 16 beq Label_F29B ; $3296: F0 03 jmp $C1C5 ; $3298: 4C C5 C1 Label_F29B: lda $C8 ; $329B: A5 C8 beq Label_F2A2 ; $329D: F0 03 jmp $CF13 ; $329F: 4C 13 CF Label_F2A2: jsr $C716 ; $32A2: 20 16 C7 lda $3B ; $32A5: A5 3B and #$03 ; $32A7: 29 03 bne Label_F2B3 ; $32A9: D0 08 lda #$08 ; $32AB: A9 08 sta $F2 ; $32AD: 85 F2 ldx $3A ; $32AF: A6 3A bne Label_F2B9 ; $32B1: D0 06 Label_F2B3: lda #$FF ; $32B3: A9 FF sta $3D ; $32B5: 85 3D inc $3C ; $32B7: E6 3C Label_F2B9: jsr $F470 ; $32B9: 20 70 F4 lda $3D ; $32BC: A5 3D beq Label_F2C5 ; $32BE: F0 05 dec $3D ; $32C0: C6 3D jsr $F3CC ; $32C2: 20 CC F3 Label_F2C5: jsr NextRandomByte ; $32C5: 20 B3 F1 jsr $E691 ; $32C8: 20 91 E6 jsr $C6F9 ; $32CB: 20 F9 C6 jsr $C790 ; $32CE: 20 90 C7 jsr $C831 ; $32D1: 20 31 C8 jsr $C8B7 ; $32D4: 20 B7 C8 jsr $D8DD ; $32D7: 20 DD D8 jsr $E587 ; $32DA: 20 87 E5 jsr $CB74 ; $32DD: 20 74 CB inc $4C ; $32E0: E6 4C ldx $40 ; $32E2: A6 40 Label_F2E4: lda $88,x ; $32E4: B5 88 bpl Label_F30D ; $32E6: 10 25 lda $3A ; $32E8: A5 3A bne Label_F326 ; $32EA: D0 3A lda $41,x ; $32EC: B5 41 bmi Label_F30D ; $32EE: 30 1D dec $C3,x ; $32F0: D6 C3 bne Label_F327 ; $32F2: D0 33 txa ; $32F4: 8A pha ; $32F5: 48 jsr $C726 ; $32F6: 20 26 C7 pla ; $32F9: 68 tax ; $32FA: AA ldy #$02 ; $32FB: A0 02 dec $41,x ; $32FD: D6 41 sty $46 ; $32FF: 84 46 bmi Label_F30D ; $3301: 30 0A jsr ResetObjectMotion ; $3303: 20 86 F3 jsr $F3B0 ; $3306: 20 B0 F3 lda #$80 ; $3309: A9 80 sta $F2 ; $330B: 85 F2 Label_F30D: dex ; $330D: CA bpl Label_F2E4 ; $330E: 10 D4 lda $41 ; $3310: A5 41 bpl Label_F318 ; $3312: 10 04 lda $42 ; $3314: A5 42 bmi Label_F366 ; $3316: 30 4E Label_F318: lda $3A ; $3318: A5 3A beq Label_F327 ; $331A: F0 0B jsr $E768 ; $331C: 20 68 E7 lda $061C ; $331F: AD 1C 06 and #$30 ; $3322: 29 30 beq Label_F2B9 ; $3324: F0 93 Label_F326: rts ; $3326: 60 Label_F327: ldx #$05 ; $3327: A2 05 Label_F329: lda $8A,x ; $3329: B5 8A beq Label_F32F ; $332B: F0 02 bpl Label_F2B9 ; $332D: 10 8A Label_F32F: dex ; $332F: CA bpl Label_F329 ; $3330: 10 F7 lda $BB ; $3332: A5 BB bpl Label_F2B9 ; $3334: 10 83 ldx $40 ; $3336: A6 40 Label_F338: ldy $88,x ; $3338: B4 88 dey ; $333A: 88 bpl Label_F34C ; $333B: 10 0F lda $41,x ; $333D: B5 41 bmi Label_F34C ; $333F: 30 0B lda #$FF ; $3341: A9 FF sta $88,x ; $3343: 95 88 lda #$01 ; $3345: A9 01 sta $C3,x ; $3347: 95 C3 jmp Label_F2B9 ; $3349: 4C B9 F2 Label_F34C: dex ; $334C: CA bpl Label_F338 ; $334D: 10 E9 lda #$02 ; $334F: A9 02 sta $F2 ; $3351: 85 F2 ldx #$96 ; $3353: A2 96 jsr $F45E ; $3355: 20 5E F4 ldx $3B ; $3358: A6 3B inx ; $335A: E8 cpx #$10 ; $335B: E0 10 bne Label_F361 ; $335D: D0 02 ldx #$04 ; $335F: A2 04 Label_F361: stx $3B ; $3361: 86 3B jmp Label_F213 ; $3363: 4C 13 F2 Label_F366: lda #$01 ; $3366: A9 01 sta $F2 ; $3368: 85 F2 lda #$00 ; $336A: A9 00 sta $17 ; $336C: 85 17 sta $18 ; $336E: 85 18 sta $15 ; $3370: 85 15 jsr $F40B ; $3372: 20 0B F4 Label_F375: jsr $F465 ; $3375: 20 65 F4 jsr $E768 ; $3378: 20 68 E7 and #$30 ; $337B: 29 30 bne Label_F383 ; $337D: D0 04 dec $15 ; $337F: C6 15 bne Label_F375 ; $3381: D0 F2 Label_F383: jmp Label_F1D4 ; $3383: 4C D4 F1 ; ResetObjectMotion ; Purpose: clear an object motion/state record. ; Inputs: X = object slot. ; Returns: motion fields cleared and default state restored. ResetObjectMotion: lda $41,x ; $3386: B5 41 bmi Label_F3AD ; $3388: 30 23 lda ObjectSpawnStateTable,x ; $338A: BD AE F3 sta $91,x ; $338D: 95 91 lda #$B8 ; $338F: A9 B8 sta $9A,x ; $3391: 95 9A sta $BD,x ; $3393: 95 BD lda #$C8 ; $3395: A9 C8 sta $BF,x ; $3397: 95 BF lda #$5A ; $3399: A9 5A ldy $41,x ; $339B: B4 41 bpl Label_F3A1 ; $339D: 10 02 lda #$01 ; $339F: A9 01 Label_F3A1: sta $C3,x ; $33A1: 95 C3 lda #$00 ; $33A3: A9 00 sta $C1,x ; $33A5: 95 C1 sta $042D,x ; $33A7: 9D 2D 04 sta $0424,x ; $33AA: 9D 24 04 Label_F3AD: rts ; $33AD: 60 ObjectSpawnStateTable: .byte $20, $D0 ; $33AE: 20 D0 ; ActivateSpawnedObject ; Purpose: finalize a newly spawned object record. ; Inputs: X = object slot. ; Returns: object type/state initialized and slot activated. ActivateSpawnedObject: lda #$03 ; $33B0: A9 03 sta $0451,x ; $33B2: 9D 51 04 lda #$02 ; $33B5: A9 02 sta $88,x ; $33B7: 95 88 rts ; $33B9: 60 RoundObjectTypeTable: .byte $58, $50, $58, $50, $50, $40, $38, $30 ; $33BA: 58 50 58 50 50 40 38 30 .byte $28 ; $33C2: 28 RoundObjectPositionTable: .byte $04, $04, $03, $03, $02, $02, $02, $02 ; $33C3: 04 04 03 03 02 02 02 02 .byte $02 ; $33CB: 02 ; LoadRoundScreenData ; Purpose: select and queue round-specific screen/status data. ; Inputs: round and mode globals. ; Returns: display data pointers and buffers initialized. LoadRoundScreenData: lda $3D ; $33CC: A5 3D and #$20 ; $33CE: 29 20 beq Label_F3EE ; $33D0: F0 1C ldx #$0A ; $33D2: A2 0A Label_F3D4: lda $F3F5,x ; $33D4: BD F5 F3 sta $57,x ; $33D7: 95 57 dex ; $33D9: CA bpl Label_F3D4 ; $33DA: 10 F8 ldy #$0A ; $33DC: A0 0A lda $3C ; $33DE: A5 3C sta $43 ; $33E0: 85 43 jsr $D77C ; $33E2: 20 7C D7 sta $60 ; $33E5: 85 60 lda $43 ; $33E7: A5 43 sta $61 ; $33E9: 85 61 jmp $C12D ; $33EB: 4C 2D C1 Label_F3EE: lda #$00 ; $33EE: A9 00 ldy #$F4 ; $33F0: A0 F4 jmp $C131 ; $33F2: 4C 31 C1 RoundInitAttributeTable: .byte $20, $6C, $08, $19, $11, $0A, $1C, $0E ; $33F5: 20 6C 08 19 11 0A 1C 0E .byte $25, $00, $00, $20, $6C, $08, $24, $24 ; $33FD: 25 00 00 20 6C 08 24 24 .byte $24, $24, $24, $24, $24, $24 ; $3405: 24 24 24 24 24 24 ; DrawRoundStatusPanel ; Purpose: write fixed round-status tile rows and numeric fields. ; Inputs: round status globals. ; Returns: status-panel buffer populated. DrawRoundStatusPanel: jsr WaitOneFrame ; $340B: 20 65 F4 ldx #$01 ; $340E: A2 01 Label_F410: lda $F43B,x ; $3410: BD 3B F4 ldy $F43D,x ; $3413: BC 3D F4 jsr $C131 ; $3416: 20 31 C1 dex ; $3419: CA bpl Label_F410 ; $341A: 10 F4 ldx #$0F ; $341C: A2 0F Label_F41E: lda #$24 ; $341E: A9 24 sta $5A,x ; $3420: 95 5A dex ; $3422: CA bpl Label_F41E ; $3423: 10 F9 lda #$10 ; $3425: A9 10 sta $59 ; $3427: 85 59 lda #$21 ; $3429: A9 21 sta $57 ; $342B: 85 57 ldx #$02 ; $342D: A2 02 Label_F42F: lda $F43F,x ; $342F: BD 3F F4 sta $58 ; $3432: 85 58 jsr $C12D ; $3434: 20 2D C1 dex ; $3437: CA bpl Label_F42F ; $3438: 10 F5 rts ; $343A: 60 StatusPanelAddressLoTable: .byte $42, $55 ; $343B: 42 55 StatusPanelAddressHiTable: .byte $F4, $F4 ; $343D: F4 F4 StatusPanelTileData: .byte $88, $A8, $E8, $21, $C8, $10, $24, $24 ; $343F: 88 A8 E8 21 C8 10 24 24 .byte $24, $10, $0A, $16, $0E, $24, $24, $18 ; $3447: 24 10 0A 16 0E 24 24 18 .byte $1F, $0E, $1B, $24, $24, $24, $23, $DA ; $344F: 1F 0E 1B 24 24 24 23 DA .byte $04, $AA, $AA, $AA, $AA ; $3457: 04 AA AA AA AA ; DelayFrames ; Purpose: wait for a fixed number of frame ticks. ; Inputs: A = frame count. ; Returns: after A frame-counter transitions. DelayFrames: ldx #$14 ; $345C: A2 14 DelayFramesLoop: jsr WaitOneFrame ; $345E: 20 65 F4 dex ; $3461: CA bne DelayFramesLoop ; $3462: D0 FA rts ; $3464: 60 ; WaitOneFrame ; Purpose: block until the NMI/frame counter changes. ; Inputs: none. ; Returns: one frame elapsed. WaitOneFrame: lda #$00 ; $3465: A9 00 sta $02 ; $3467: 85 02 WaitForFrameCounter: lda $02 ; $3469: A5 02 beq WaitForFrameCounter ; $346B: F0 FC dec $02 ; $346D: C6 02 Label_F46F: rts ; $346F: 60 ; WaitForStartPress ; Purpose: wait for Start while maintaining frame and PPU state. ; Inputs: global controller/game state. ; Returns: Start detected; transition-delay fields updated. WaitForStartPress: jsr WaitForFrameCounter ; $3470: 20 69 F4 lda $3A ; $3473: A5 3A bne Label_F46F ; $3475: D0 F8 jsr $E768 ; $3477: 20 68 E7 and #$10 ; $347A: 29 10 beq Label_F46F ; $347C: F0 F1 lda #$04 ; $347E: A9 04 sta $F2 ; $3480: 85 F2 lda $01 ; $3482: A5 01 and #$EF ; $3484: 29 EF sta $2001 ; $3486: 8D 01 20 Label_F489: jsr WaitOneFrame ; $3489: 20 65 F4 jsr $E768 ; $348C: 20 68 E7 and #$10 ; $348F: 29 10 beq Label_F489 ; $3491: F0 F6 lda $01 ; $3493: A5 01 sta $2001 ; $3495: 8D 01 20 ldy #$04 ; $3498: A0 04 lda $C8 ; $349A: A5 C8 ora $16 ; $349C: 05 16 beq Label_F4A2 ; $349E: F0 02 ldy #$20 ; $34A0: A0 20 Label_F4A2: sty $F2 ; $34A2: 84 F2 rts ; $34A4: 60 ; InitializeGameplayGlobals ; Purpose: initialize common gameplay flags, counters, and player defaults. ; Inputs: none. ; Returns: core gameplay globals reset. InitializeGameplayGlobals: lda #$01 ; $34A5: A9 01 sta $048E ; $34A7: 8D 8E 04 sta $048F ; $34AA: 8D 8F 04 lda #$FF ; $34AD: A9 FF sta $BB ; $34AF: 85 BB sta $87 ; $34B1: 85 87 sta $048C ; $34B3: 8D 8C 04 ldx #$01 ; $34B6: A2 01 stx $0459 ; $34B8: 8E 59 04 stx $90 ; $34BB: 86 90 inx ; $34BD: E8 stx $46 ; $34BE: 86 46 lda #$40 ; $34C0: A9 40 sta $99 ; $34C2: 85 99 rts ; $34C4: 60 .incbin "prg.bin", $34C5, $003B ; UpdateSoundEngine ; Purpose: invoke the sound-effect/music sequencer for the current frame. ; Inputs: sound state and stream pointers in zero page. ; Returns: APU registers and per-channel sequencer state updated. UpdateSoundEngine: jsr $F78F ; $3500: 20 8F F7 Label_F503: rts ; $3503: 60 ; ProcessSoundChannels ; Purpose: interpret active sound streams for pulse, triangle, and noise channels. ; Inputs: sound pointers, timers, envelopes, and channel flags in $D0-$FF. ; Returns: APU channel registers and stream cursors updated. ProcessSoundChannels: lda #$00 ; $3504: A9 00 tax ; $3506: AA sta $FD ; $3507: 85 FD beq Label_F51B ; $3509: F0 10 Label_F50B: txa ; $350B: 8A lsr a ; $350C: 4A tax ; $350D: AA Label_F50E: inx ; $350E: E8 txa ; $350F: 8A cmp #$04 ; $3510: C9 04 beq Label_F503 ; $3512: F0 EF lda $FD ; $3514: A5 FD clc ; $3516: 18 adc #$04 ; $3517: 69 04 sta $FD ; $3519: 85 FD Label_F51B: txa ; $351B: 8A asl a ; $351C: 0A tax ; $351D: AA lda $E0,x ; $351E: B5 E0 sta $FE ; $3520: 85 FE lda $E1,x ; $3522: B5 E1 sta $FF ; $3524: 85 FF lda $E1,x ; $3526: B5 E1 beq Label_F50B ; $3528: F0 E1 txa ; $352A: 8A lsr a ; $352B: 4A tax ; $352C: AA dec $D0,x ; $352D: D6 D0 bne Label_F50E ; $352F: D0 DD Label_F531: ldy $E8,x ; $3531: B4 E8 inc $E8,x ; $3533: F6 E8 lda ($FE),y ; $3535: B1 FE beq UpdateSoundEngine ; $3537: F0 C7 tay ; $3539: A8 cmp #$FF ; $353A: C9 FF beq Label_F547 ; $353C: F0 09 and #$C0 ; $353E: 29 C0 cmp #$C0 ; $3540: C9 C0 beq Label_F553 ; $3542: F0 0F jmp Label_F561 ; $3544: 4C 61 F5 Label_F547: lda $D8,x ; $3547: B5 D8 beq Label_F55E ; $3549: F0 13 dec $D8,x ; $354B: D6 D8 lda $EC,x ; $354D: B5 EC sta $E8,x ; $354F: 95 E8 bne Label_F55E ; $3551: D0 0B Label_F553: tya ; $3553: 98 and #$3F ; $3554: 29 3F sta $D8,x ; $3556: 95 D8 dec $D8,x ; $3558: D6 D8 lda $E8,x ; $355A: B5 E8 sta $EC,x ; $355C: 95 EC Label_F55E: jmp Label_F531 ; $355E: 4C 31 F5 Label_F561: tya ; $3561: 98 bpl Label_F57B ; $3562: 10 17 and #$0F ; $3564: 29 0F clc ; $3566: 18 adc $DF ; $3567: 65 DF tay ; $3569: A8 lda SoundCommandMaskTable,y ; $356A: B9 60 F6 sta $D4,x ; $356D: 95 D4 tay ; $356F: A8 txa ; $3570: 8A cmp #$02 ; $3571: C9 02 beq Label_F5C4 ; $3573: F0 4F Label_F575: ldy $E8,x ; $3575: B4 E8 inc $E8,x ; $3577: F6 E8 lda ($FE),y ; $3579: B1 FE Label_F57B: tay ; $357B: A8 txa ; $357C: 8A cmp #$03 ; $357D: C9 03 beq Label_F5E1 ; $357F: F0 60 pha ; $3581: 48 tax ; $3582: AA cmp #$01 ; $3583: C9 01 beq Label_F5B9 ; $3585: F0 32 Label_F587: ldx $FD ; $3587: A6 FD lda ApuPeriodLowTable,y ; $3589: B9 01 F6 beq Label_F599 ; $358C: F0 0B sta $4002,x ; $358E: 9D 02 40 lda ApuPeriodHighTable,y ; $3591: B9 00 F6 ora #$08 ; $3594: 09 08 sta $4003,x ; $3596: 9D 03 40 Label_F599: tay ; $3599: A8 pla ; $359A: 68 tax ; $359B: AA tya ; $359C: 98 bne Label_F5AA ; $359D: D0 0B ldy #$00 ; $359F: A0 00 txa ; $35A1: 8A cmp #$02 ; $35A2: C9 02 beq Label_F5AC ; $35A4: F0 06 ldy #$10 ; $35A6: A0 10 bne Label_F5AC ; $35A8: D0 02 Label_F5AA: ldy $DC,x ; $35AA: B4 DC Label_F5AC: tya ; $35AC: 98 ldy $FD ; $35AD: A4 FD sta $4000,y ; $35AF: 99 00 40 Label_F5B2: lda $D4,x ; $35B2: B5 D4 sta $D0,x ; $35B4: 95 D0 jmp Label_F50E ; $35B6: 4C 0E F5 Label_F5B9: lda $F5 ; $35B9: A5 F5 and #$02 ; $35BB: 29 02 beq Label_F587 ; $35BD: F0 C8 pla ; $35BF: 68 tax ; $35C0: AA jmp Label_F5B2 ; $35C1: 4C B2 F5 Label_F5C4: tya ; $35C4: 98 ldy $07F0 ; $35C5: AC F0 07 beq Label_F5CE ; $35C8: F0 04 lda #$FF ; $35CA: A9 FF bne Label_F5D9 ; $35CC: D0 0B Label_F5CE: clc ; $35CE: 18 adc #$FE ; $35CF: 69 FE asl a ; $35D1: 0A asl a ; $35D2: 0A cmp #$3C ; $35D3: C9 3C bcc Label_F5D9 ; $35D5: 90 02 lda #$3C ; $35D7: A9 3C Label_F5D9: sta $4008 ; $35D9: 8D 08 40 sta $DE ; $35DC: 85 DE jmp Label_F575 ; $35DE: 4C 75 F5 Label_F5E1: lda $F4 ; $35E1: A5 F4 cmp #$02 ; $35E3: C9 02 beq Label_F5F9 ; $35E5: F0 12 lda $F700,y ; $35E7: B9 00 F7 sta $400C ; $35EA: 8D 0C 40 lda $F701,y ; $35ED: B9 01 F7 sta $400E ; $35F0: 8D 0E 40 lda $F702,y ; $35F3: B9 02 F7 sta $400F ; $35F6: 8D 0F 40 Label_F5F9: jmp Label_F5B2 ; $35F9: 4C B2 F5 .incbin "prg.bin", $35FC, $0004 ; Interleaved APU timer high/low bytes; aliases below preserve the original odd/even indexed accesses. ApuPeriodTable: .byte $07, $F0, $00, $00, $00, $D4, $00, $C8 ; $3600: 07 F0 00 00 00 D4 00 C8 .byte $00, $BD, $00, $B2, $00, $A8, $00, $9F ; $3608: 00 BD 00 B2 00 A8 00 9F .byte $00, $96, $00, $8D, $00, $85, $00, $7E ; $3610: 00 96 00 8D 00 85 00 7E .byte $00, $76, $00, $70, $01, $AB, $01, $93 ; $3618: 00 76 00 70 01 AB 01 93 .byte $01, $7C, $01, $67, $01, $52, $01, $3F ; $3620: 01 7C 01 67 01 52 01 3F .byte $01, $2D, $01, $1C, $01, $0C, $00, $FD ; $3628: 01 2D 01 1C 01 0C 00 FD .byte $00, $EE, $00, $E1, $03, $57, $03, $27 ; $3630: 00 EE 00 E1 03 57 03 27 .byte $02, $F9, $02, $CF, $02, $A6, $02, $80 ; $3638: 02 F9 02 CF 02 A6 02 80 .byte $02, $5C, $02, $3A, $02, $1A, $01, $FC ; $3640: 02 5C 02 3A 02 1A 01 FC .byte $01, $DF, $01, $C4, $03, $F8, $00, $69 ; $3648: 01 DF 01 C4 03 F8 00 69 .byte $00, $63, $00, $5E, $00, $58, $00, $53 ; $3650: 00 63 00 5E 00 58 00 53 .byte $00, $4F, $00, $4A, $00, $46, $00, $42 ; $3658: 00 4F 00 4A 00 46 00 42 ApuPeriodHighTable = ApuPeriodTable ApuPeriodLowTable = ApuPeriodTable + 1 ; Sound command masks, duration patterns, and channel-selection values. SoundCommandMaskTable: .byte $03, $06, $0C, $18, $30, $12, $24, $09 ; $3660: 03 06 0C 18 30 12 24 09 .byte $08, $04, $07, $01, $04, $08, $10, $20 ; $3668: 08 04 07 01 04 08 10 20 .byte $40, $18, $30, $0C, $01, $06, $0C, $18 ; $3670: 40 18 30 0C 01 06 0C 18 .byte $30, $60, $24, $48, $12, $10, $08, $0E ; $3678: 30 60 24 48 12 10 08 0E .byte $02, $03, $04 ; $3680: 02 03 04 ; SelectSoundChannelOffset ; Purpose: select the pulse 1 APU register shadow offset. ; Inputs: none. ; Returns: A = $00 and control flows into the common selector. SelectSoundChannelOffset: lda #$00 ; $3683: A9 00 beq Label_F691 ; $3685: F0 0A ; SelectPulse2Offset ; Purpose: select the pulse 2 APU register shadow offset. ; Inputs: none. ; Returns: A = $08 and control flows into the common selector. SelectPulse2Offset: lda #$08 ; $3687: A9 08 bne Label_F691 ; $3689: D0 06 ; SelectTriangleOffset ; Purpose: select the triangle/noise APU shadow offset. ; Inputs: none. ; Returns: A = $0C or $04 through the common selector. SelectTriangleOffset: lda #$0C ; $368B: A9 0C bne Label_F691 ; $368D: D0 02 ; CopyFourBytesToApuShadow ; Purpose: copy four bytes from a source pointer to the selected APU shadow/register block. ; Inputs: X/Y form source pointer; selector entry determines destination offset. ; Returns: four bytes copied; source pointer retained in $FB/$FC. CopyFourBytesToApuShadow: lda #$04 ; $368F: A9 04 Label_F691: sta $F9 ; $3691: 85 F9 lda #$40 ; $3693: A9 40 sta $FA ; $3695: 85 FA stx $FB ; $3697: 86 FB sty $FC ; $3699: 84 FC ldy #$00 ; $369B: A0 00 Label_F69D: lda ($FB),y ; $369D: B1 FB sta ($F9),y ; $369F: 91 F9 iny ; $36A1: C8 tya ; $36A2: 98 cmp #$04 ; $36A3: C9 04 bne Label_F69D ; $36A5: D0 F6 rts ; $36A7: 60 ; InitializeSoundSequence ; Purpose: resolve a sound sequence, load its initial state, and reset channel cursors. ; Inputs: A = sound request/sequence selector. ; Returns: stream state $DF-$EB and sound flags initialized. InitializeSoundSequence: tax ; $36A8: AA jsr $F798 ; $36A9: 20 98 F7 stx $F6 ; $36AC: 86 F6 lda $07F5 ; $36AE: AD F5 07 beq Label_F6BE ; $36B1: F0 0B cmp #$02 ; $36B3: C9 02 bne Label_F6BE ; $36B5: D0 07 sta $F0 ; $36B7: 85 F0 lda #$00 ; $36B9: A9 00 sta $07F5 ; $36BB: 8D F5 07 Label_F6BE: lda SoundSequencePointerTable,y ; $36BE: B9 CA FB tay ; $36C1: A8 ldx #$00 ; $36C2: A2 00 Label_F6C4: lda SoundSequencePointerTable,y ; $36C4: B9 CA FB sta $DF,x ; $36C7: 95 DF iny ; $36C9: C8 inx ; $36CA: E8 txa ; $36CB: 8A cmp #$09 ; $36CC: C9 09 bne Label_F6C4 ; $36CE: D0 F4 lda #$01 ; $36D0: A9 01 sta $D0 ; $36D2: 85 D0 sta $D1 ; $36D4: 85 D1 sta $D2 ; $36D6: 85 D2 sta $D3 ; $36D8: 85 D3 lda #$00 ; $36DA: A9 00 sta $E8 ; $36DC: 85 E8 sta $E9 ; $36DE: 85 E9 sta $EA ; $36E0: 85 EA sta $EB ; $36E2: 85 EB rts ; $36E4: 60 ; Preserved sound data / unused bytes Data_F6E5: .byte $94, $AB, $FD, $58, $00, $7F, $04, $18 ; $36E5: 94 AB FD 58 00 7F 04 18 .byte $3F, $7F, $00, $00, $06, $7F, $0A, $C0 ; $36ED: 3F 7F 00 00 06 7F 0A C0 .byte $08, $7F, $05, $C0, $C1, $89, $02, $0F ; $36F5: 08 7F 05 C0 C1 89 02 0F .byte $FF, $FF, $FF, $10, $00, $18, $10, $01 ; $36FD: FF FF FF 10 00 18 10 01 .byte $18, $00, $01, $88, $02, $02, $40, $03 ; $3705: 18 00 01 88 02 02 40 03 .byte $05, $40, $04, $07, $40 ; $370D: 05 40 04 07 40 ; SilencePulseChannels ; Purpose: sound-driver routine identified from call flow and register/state access. ; Inputs: sound request, channel, and stream state in zero page/global RAM as used locally. ; Returns: corresponding APU or sequencer state updated. SilencePulseChannels: lda #$7F ; $3712: A9 7F sta $4001 ; $3714: 8D 01 40 sta $4005 ; $3717: 8D 05 40 ; InitializeApuChannelState ; Purpose: sound-driver routine identified from call flow and register/state access. ; Inputs: sound request, channel, and stream state in zero page/global RAM as used locally. ; Returns: corresponding APU or sequencer state updated. InitializeApuChannelState: stx $DC ; $371A: 86 DC sty $DD ; $371C: 84 DD rts ; $371E: 60 Sound_F71F: ldx #$E5 ; $371F: A2 E5 ldy #$F6 ; $3721: A0 F6 bne Sound_F745 ; $3723: D0 20 ; UpdateMusicTempo ; Purpose: sound-driver routine identified from call flow and register/state access. ; Inputs: sound request, channel, and stream state in zero page/global RAM as used locally. ; Returns: corresponding APU or sequencer state updated. UpdateMusicTempo: lda $F3 ; $3725: A5 F3 lsr a ; $3727: 4A bcs Sound_F736 ; $3728: B0 0C lda $F7 ; $372A: A5 F7 lsr a ; $372C: 4A bcs Sound_F749 ; $372D: B0 1A lda $F0 ; $372F: A5 F0 and #$10 ; $3731: 29 10 bne Sound_F71F ; $3733: D0 EA rts ; $3735: 60 Sound_F736: lda $F7 ; $3736: A5 F7 ora #$01 ; $3738: 09 01 sta $F7 ; $373A: 85 F7 lda #$00 ; $373C: A9 00 sta $07E4 ; $373E: 8D E4 07 ldx #$FC ; $3741: A2 FC ldy #$F5 ; $3743: A0 F5 Sound_F745: jsr $F683 ; $3745: 20 83 F6 rts ; $3748: 60 Sound_F749: inc $07E4 ; $3749: EE E4 07 lda $07E4 ; $374C: AD E4 07 cmp #$58 ; $374F: C9 58 bne Sound_F77B ; $3751: D0 28 lda #$00 ; $3753: A9 00 sta $F7 ; $3755: 85 F7 rts ; $3757: 60 Sound_F758: lda #$C0 ; $3758: A9 C0 sta $4017 ; $375A: 8D 17 40 jsr UpdateSoundPriority ; $375D: 20 25 FB jsr ProcessMusicRequest ; $3760: 20 0A F9 jsr UpdatePulseEffects ; $3763: 20 38 FA jsr UpdateNoiseEffects ; $3766: 20 AC FA jsr ProcessSoundEffectRequests ; $3769: 20 24 F8 lda $F1 ; $376C: A5 F1 sta $07E9 ; $376E: 8D E9 07 lda #$00 ; $3771: A9 00 sta $F0 ; $3773: 85 F0 sta $F1 ; $3775: 85 F1 sta $F2 ; $3777: 85 F2 sta $F3 ; $3779: 85 F3 Sound_F77B: rts ; $377B: 60 Sound_F77C: lda $F4 ; $377C: A5 F4 and #$06 ; $377E: 29 06 bne Sound_F77B ; $3780: D0 F9 lda $F4 ; $3782: A5 F4 and #$F0 ; $3784: 29 F0 sta $F4 ; $3786: 85 F4 ldx #$E9 ; $3788: A2 E9 ldy #$F6 ; $378A: A0 F6 jmp Sound_F879 ; $378C: 4C 79 F8 ; UpdateSoundRequests ; Purpose: sound-driver routine identified from call flow and register/state access. ; Inputs: sound request, channel, and stream state in zero page/global RAM as used locally. ; Returns: corresponding APU or sequencer state updated. UpdateSoundRequests: lda $F6 ; $378F: A5 F6 cmp #$20 ; $3791: C9 20 bne Sound_F79F ; $3793: D0 0A inc $07E8 ; $3795: EE E8 07 ; InitializeSoundDataPointers ; Purpose: sound-driver routine identified from call flow and register/state access. ; Inputs: sound request, channel, and stream state in zero page/global RAM as used locally. ; Returns: corresponding APU or sequencer state updated. InitializeSoundDataPointers: and #$0F ; $3798: 29 0F cmp #$0F ; $379A: C9 0F bne ResetAllSoundState ; $379C: D0 07 txa ; $379E: 8A Sound_F79F: lda $F4 ; $379F: A5 F4 and #$20 ; $37A1: 29 20 bne Sound_F7C7 ; $37A3: D0 22 ; ResetAllSoundState ; Purpose: sound-driver routine identified from call flow and register/state access. ; Inputs: sound request, channel, and stream state in zero page/global RAM as used locally. ; Returns: corresponding APU or sequencer state updated. ResetAllSoundState: lda #$10 ; $37A5: A9 10 sta $400C ; $37A7: 8D 0C 40 sta $4000 ; $37AA: 8D 00 40 sta $4004 ; $37AD: 8D 04 40 lda #$00 ; $37B0: A9 00 sta $F4 ; $37B2: 85 F4 Sound_F7B4: sta $F5 ; $37B4: 85 F5 sta $F6 ; $37B6: 85 F6 sta $07FA ; $37B8: 8D FA 07 sta $F7 ; $37BB: 85 F7 sta $4008 ; $37BD: 8D 08 40 sta $4011 ; $37C0: 8D 11 40 sta $07F0 ; $37C3: 8D F0 07 rts ; $37C6: 60 Sound_F7C7: lda #$10 ; $37C7: A9 10 sta $4004 ; $37C9: 8D 04 40 sta $400C ; $37CC: 8D 0C 40 lda #$00 ; $37CF: A9 00 beq Sound_F7B4 ; $37D1: F0 E1 Sound_F7D3: lda #$00 ; $37D3: A9 00 sta $07FA ; $37D5: 8D FA 07 rts ; $37D8: 60 Sound_F7D9: ldx #$F5 ; $37D9: A2 F5 ldy #$F6 ; $37DB: A0 F6 jmp Sound_F879 ; $37DD: 4C 79 F8 Sound_F7E0: inc $07FB ; $37E0: EE FB 07 lda $07FB ; $37E3: AD FB 07 cmp #$10 ; $37E6: C9 10 beq Sound_F7D9 ; $37E8: F0 EF cmp #$20 ; $37EA: C9 20 beq Sound_F7D3 ; $37EC: F0 E5 rts ; $37EE: 60 Sound_F7EF: lda #$00 ; $37EF: A9 00 sta $07FB ; $37F1: 8D FB 07 lda #$F0 ; $37F4: A9 F0 sta $07FA ; $37F6: 8D FA 07 ldx #$F1 ; $37F9: A2 F1 ldy #$F6 ; $37FB: A0 F6 jmp Sound_F879 ; $37FD: 4C 79 F8 Sound_F800: lda $F4 ; $3800: A5 F4 and #$F0 ; $3802: 29 F0 ora #$02 ; $3804: 09 02 sta $F4 ; $3806: 85 F4 lda #$00 ; $3808: A9 00 sta $07F7 ; $380A: 8D F7 07 ldx #$F1 ; $380D: A2 F1 ldy #$F6 ; $380F: A0 F6 jmp Sound_F879 ; $3811: 4C 79 F8 Sound_F814: inc $07F7 ; $3814: EE F7 07 lda $07F7 ; $3817: AD F7 07 cmp #$10 ; $381A: C9 10 bne Sound_F85B ; $381C: D0 3D jmp Sound_F89B ; $381E: 4C 9B F8 Sound_F821: jmp ResetAllSoundState ; $3821: 4C A5 F7 ; ProcessSoundEffectRequests ; Purpose: sound-driver routine identified from call flow and register/state access. ; Inputs: sound request, channel, and stream state in zero page/global RAM as used locally. ; Returns: corresponding APU or sequencer state updated. ProcessSoundEffectRequests: lda $F0 ; $3824: A5 F0 lsr a ; $3826: 4A bcs Sound_F821 ; $3827: B0 F8 lda $F6 ; $3829: A5 F6 cmp #$DF ; $382B: C9 DF beq Sound_F83B ; $382D: F0 0C cmp #$7F ; $382F: C9 7F beq Sound_F83B ; $3831: F0 08 cmp #$20 ; $3833: C9 20 beq Sound_F83B ; $3835: F0 04 lda $F6 ; $3837: A5 F6 bne Sound_F85B ; $3839: D0 20 Sound_F83B: lda $07FA ; $383B: AD FA 07 cmp #$0F ; $383E: C9 0F beq Sound_F7EF ; $3840: F0 AD cmp #$F0 ; $3842: C9 F0 beq Sound_F7E0 ; $3844: F0 9A lda $F0 ; $3846: A5 F0 lsr a ; $3848: 4A lsr a ; $3849: 4A bcs Sound_F800 ; $384A: B0 B4 lsr a ; $384C: 4A bcs Sound_F85F ; $384D: B0 10 lsr a ; $384F: 4A bcs Sound_F85C ; $3850: B0 0A lda $F4 ; $3852: A5 F4 lsr a ; $3854: 4A lsr a ; $3855: 4A bcs Sound_F814 ; $3856: B0 BC lsr a ; $3858: 4A bcs Sound_F87D ; $3859: B0 22 Sound_F85B: rts ; $385B: 60 Sound_F85C: jmp Sound_F77C ; $385C: 4C 7C F7 Sound_F85F: lda $F4 ; $385F: A5 F4 and #$80 ; $3861: 29 80 bne Sound_F85B ; $3863: D0 F6 lda $F4 ; $3865: A5 F4 and #$F0 ; $3867: 29 F0 ora #$04 ; $3869: 09 04 sta $F4 ; $386B: 85 F4 lda #$00 ; $386D: A9 00 sta $07F3 ; $386F: 8D F3 07 sta $07F1 ; $3872: 8D F1 07 ldx #$ED ; $3875: A2 ED ldy #$F6 ; $3877: A0 F6 Sound_F879: jsr $F68B ; $3879: 20 8B F6 rts ; $387C: 60 Sound_F87D: inc $07F3 ; $387D: EE F3 07 lda $07F3 ; $3880: AD F3 07 cmp #$03 ; $3883: C9 03 bne Sound_F8A1 ; $3885: D0 1A lda #$00 ; $3887: A9 00 sta $07F3 ; $3889: 8D F3 07 inc $07F1 ; $388C: EE F1 07 lda $07F1 ; $388F: AD F1 07 cmp #$10 ; $3892: C9 10 bne Sound_F8A2 ; $3894: D0 0C lda #$10 ; $3896: A9 10 sta $400C ; $3898: 8D 0C 40 Sound_F89B: lda $F4 ; $389B: A5 F4 and #$F0 ; $389D: 29 F0 sta $F4 ; $389F: 85 F4 Sound_F8A1: rts ; $38A1: 60 Sound_F8A2: sta $400E ; $38A2: 8D 0E 40 rts ; $38A5: 60 Sound_F8A6: lda #$00 ; $38A6: A9 00 sta $07E0 ; $38A8: 8D E0 07 clc ; $38AB: 18 lda $1B ; $38AC: A5 1B and #$07 ; $38AE: 29 07 adc #$02 ; $38B0: 69 02 sta $07E1 ; $38B2: 8D E1 07 lda $F7 ; $38B5: A5 F7 and #$00 ; $38B7: 29 00 ora #$80 ; $38B9: 09 80 sta $F7 ; $38BB: 85 F7 bne Sound_F8E8 ; $38BD: D0 29 Sound_F8BF: inc $07E0 ; $38BF: EE E0 07 lda $07E0 ; $38C2: AD E0 07 cmp $07E1 ; $38C5: CD E1 07 bne Sound_F8E8 ; $38C8: D0 1E Sound_F8CA: lda #$10 ; $38CA: A9 10 sta $4000 ; $38CC: 8D 00 40 sta $4004 ; $38CF: 8D 04 40 lda #$00 ; $38D2: A9 00 sta $F7 ; $38D4: 85 F7 lda $F4 ; $38D6: A5 F4 and #$0F ; $38D8: 29 0F sta $F4 ; $38DA: 85 F4 rts ; $38DC: 60 Sound_F8DD: jsr ResetAllSoundState ; $38DD: 20 A5 F7 lda #$80 ; $38E0: A9 80 sta $F4 ; $38E2: 85 F4 lda #$02 ; $38E4: A9 02 sta $F0 ; $38E6: 85 F0 Sound_F8E8: ldx #$F9 ; $38E8: A2 F9 ldy #$F6 ; $38EA: A0 F6 jsr $F683 ; $38EC: 20 83 F6 lda $1B ; $38EF: A5 1B and #$0F ; $38F1: 29 0F sta $4002 ; $38F3: 8D 02 40 ldx #$F9 ; $38F6: A2 F9 ldy #$F6 ; $38F8: A0 F6 jsr $F68F ; $38FA: 20 8F F6 lda $1B ; $38FD: A5 1B lsr a ; $38FF: 4A lsr a ; $3900: 4A and #$0F ; $3901: 29 0F sta $4006 ; $3903: 8D 06 40 rts ; $3906: 60 Sound_F907: jmp Sound_F8A6 ; $3907: 4C A6 F8 ; ProcessMusicRequest ; Purpose: sound-driver routine identified from call flow and register/state access. ; Inputs: sound request, channel, and stream state in zero page/global RAM as used locally. ; Returns: corresponding APU or sequencer state updated. ProcessMusicRequest: lda $F6 ; $390A: A5 F6 beq Sound_F91B ; $390C: F0 0D cmp #$DF ; $390E: C9 DF beq Sound_F91B ; $3910: F0 09 lda $F0 ; $3912: A5 F0 and #$E0 ; $3914: 29 E0 beq Sound_F94E ; $3916: F0 36 jsr ResetAllSoundState ; $3918: 20 A5 F7 Sound_F91B: lda $F0 ; $391B: A5 F0 asl a ; $391D: 0A bcs Sound_F8DD ; $391E: B0 BD asl a ; $3920: 0A bcs Sound_F952 ; $3921: B0 2F asl a ; $3923: 0A bcs Sound_F965 ; $3924: B0 3F lda $F4 ; $3926: A5 F4 asl a ; $3928: 0A bcs Sound_F8E8 ; $3929: B0 BD lda $F4 ; $392B: A5 F4 and #$E0 ; $392D: 29 E0 bne Sound_F94E ; $392F: D0 1D lda $F6 ; $3931: A5 F6 cmp #$DF ; $3933: C9 DF beq Sound_F94B ; $3935: F0 14 lda $F6 ; $3937: A5 F6 bne Sound_F94E ; $3939: D0 13 lda $F3 ; $393B: A5 F3 asl a ; $393D: 0A bcs Sound_F907 ; $393E: B0 C7 asl a ; $3940: 0A bcs Sound_F977 ; $3941: B0 34 lda $F7 ; $3943: A5 F7 asl a ; $3945: 0A bcs Sound_F94F ; $3946: B0 07 asl a ; $3948: 0A bcs Sound_F993 ; $3949: B0 48 Sound_F94B: jsr UpdateMusicTempo ; $394B: 20 25 F7 Sound_F94E: rts ; $394E: 60 Sound_F94F: jmp Sound_F8BF ; $394F: 4C BF F8 Sound_F952: lda #$0F ; $3952: A9 0F sta $07FA ; $3954: 8D FA 07 lda $F4 ; $3957: A5 F4 and #$0F ; $3959: 29 0F ora #$40 ; $395B: 09 40 sta $F4 ; $395D: 85 F4 ldx #$D1 ; $395F: A2 D1 ldy #$F9 ; $3961: A0 F9 bne Sound_F98F ; $3963: D0 2A Sound_F965: lda #$02 ; $3965: A9 02 sta $F0 ; $3967: 85 F0 lda $F4 ; $3969: A5 F4 and #$0F ; $396B: 29 0F ora #$20 ; $396D: 09 20 sta $F4 ; $396F: 85 F4 ldx #$CD ; $3971: A2 CD ldy #$F9 ; $3973: A0 F9 bne Sound_F98F ; $3975: D0 18 Sound_F977: lda #$00 ; $3977: A9 00 sta $07FC ; $3979: 8D FC 07 lda $F7 ; $397C: A5 F7 and #$00 ; $397E: 29 00 ora #$40 ; $3980: 09 40 sta $F7 ; $3982: 85 F7 ldx #$D5 ; $3984: A2 D5 ldy #$F9 ; $3986: A0 F9 jsr $F68F ; $3988: 20 8F F6 ldx #$D9 ; $398B: A2 D9 ldy #$F9 ; $398D: A0 F9 Sound_F98F: jsr $F683 ; $398F: 20 83 F6 rts ; $3992: 60 Sound_F993: inc $07FC ; $3993: EE FC 07 lda $07FC ; $3996: AD FC 07 cmp #$12 ; $3999: C9 12 beq Sound_F9CA ; $399B: F0 2D cmp #$06 ; $399D: C9 06 bcc Sound_F9B1 ; $399F: 90 10 lda $1B ; $39A1: A5 1B ora #$10 ; $39A3: 09 10 and #$7F ; $39A5: 29 7F sta $07FE ; $39A7: 8D FE 07 rol a ; $39AA: 2A sta $07FD ; $39AB: 8D FD 07 jmp Sound_F9BD ; $39AE: 4C BD F9 Sound_F9B1: inc $07FD ; $39B1: EE FD 07 inc $07FD ; $39B4: EE FD 07 inc $07FE ; $39B7: EE FE 07 inc $07FE ; $39BA: EE FE 07 Sound_F9BD: lda $07FD ; $39BD: AD FD 07 sta $4006 ; $39C0: 8D 06 40 lda $07FE ; $39C3: AD FE 07 sta $4002 ; $39C6: 8D 02 40 rts ; $39C9: 60 Sound_F9CA: jmp Sound_F8CA ; $39CA: 4C CA F8 ; Preserved sound data / unused bytes Data_F9CD: .byte $B8, $D5, $20, $00, $9F, $93, $80, $22 ; $39CD: B8 D5 20 00 9F 93 80 22 .byte $3F, $BA, $E0, $06, $3F, $BB, $CE, $06 ; $39D5: 3F BA E0 06 3F BB CE 06 .byte $B8, $93, $50, $02, $80, $7F, $60, $68 ; $39DD: B8 93 50 02 80 7F 60 68 .byte $80, $7F, $62, $68 ; $39E5: 80 7F 62 68 ; UpdateSoundEnvelopes ; Purpose: sound-driver routine identified from call flow and register/state access. ; Inputs: sound request, channel, and stream state in zero page/global RAM as used locally. ; Returns: corresponding APU or sequencer state updated. UpdateSoundEnvelopes: lda $F5 ; $39E9: A5 F5 and #$02 ; $39EB: 29 02 bne Sound_FA26 ; $39ED: D0 37 lda $F6 ; $39EF: A5 F6 cmp #$DF ; $39F1: C9 DF beq Sound_F9F9 ; $39F3: F0 04 lda $F6 ; $39F5: A5 F6 bne Sound_FA26 ; $39F7: D0 2D Sound_F9F9: lda #$00 ; $39F9: A9 00 sta $07F9 ; $39FB: 8D F9 07 lda $F5 ; $39FE: A5 F5 and #$E0 ; $3A00: 29 E0 ora #$02 ; $3A02: 09 02 sta $F5 ; $3A04: 85 F5 ldx #$DD ; $3A06: A2 DD ldy #$F9 ; $3A08: A0 F9 bne Sound_FA7F ; $3A0A: D0 73 Sound_FA0C: inc $07F9 ; $3A0C: EE F9 07 lda $07F9 ; $3A0F: AD F9 07 cmp #$07 ; $3A12: C9 07 bne Sound_FA26 ; $3A14: D0 10 lda #$7F ; $3A16: A9 7F sta $4005 ; $3A18: 8D 05 40 lda #$10 ; $3A1B: A9 10 sta $4004 ; $3A1D: 8D 04 40 lda $F5 ; $3A20: A5 F5 and #$E0 ; $3A22: 29 E0 sta $F5 ; $3A24: 85 F5 Sound_FA26: rts ; $3A26: 60 Sound_FA27: jsr ResetAllSoundState ; $3A27: 20 A5 F7 ldx #$E1 ; $3A2A: A2 E1 ldy #$F9 ; $3A2C: A0 F9 jsr $F683 ; $3A2E: 20 83 F6 ldx #$E5 ; $3A31: A2 E5 ldy #$F9 ; $3A33: A0 F9 jmp Sound_FA7F ; $3A35: 4C 7F FA ; UpdatePulseEffects ; Purpose: sound-driver routine identified from call flow and register/state access. ; Inputs: sound request, channel, and stream state in zero page/global RAM as used locally. ; Returns: corresponding APU or sequencer state updated. UpdatePulseEffects: lda $F6 ; $3A38: A5 F6 beq Sound_FA42 ; $3A3A: F0 06 and #$0F ; $3A3C: 29 0F cmp #$0F ; $3A3E: C9 0F bne Sound_FA63 ; $3A40: D0 21 Sound_FA42: lda $F4 ; $3A42: A5 F4 and #$80 ; $3A44: 29 80 bne Sound_FA63 ; $3A46: D0 1B lda $F7 ; $3A48: A5 F7 and #$C0 ; $3A4A: 29 C0 bne Sound_FA63 ; $3A4C: D0 15 lda $F1 ; $3A4E: A5 F1 lsr a ; $3A50: 4A bcs Sound_FA27 ; $3A51: B0 D4 lsr a ; $3A53: 4A bcs UpdateSoundEnvelopes ; $3A54: B0 93 lsr a ; $3A56: 4A bcs Sound_FA83 ; $3A57: B0 2A lsr a ; $3A59: 4A lsr a ; $3A5A: 4A bcs Sound_FA64 ; $3A5B: B0 07 lda $F5 ; $3A5D: A5 F5 lsr a ; $3A5F: 4A lsr a ; $3A60: 4A bcs Sound_FA0C ; $3A61: B0 A9 Sound_FA63: rts ; $3A63: 60 Sound_FA64: lda $F6 ; $3A64: A5 F6 bne Sound_FA63 ; $3A66: D0 FB lda $F5 ; $3A68: A5 F5 and #$02 ; $3A6A: 29 02 bne Sound_FA63 ; $3A6C: D0 F5 ldx #$8A ; $3A6E: A2 8A ldy #$FA ; $3A70: A0 FA jsr $F68F ; $3A72: 20 8F F6 lda $1B ; $3A75: A5 1B and #$3F ; $3A77: 29 3F ora #$10 ; $3A79: 09 10 sta $4006 ; $3A7B: 8D 06 40 rts ; $3A7E: 60 Sound_FA7F: jsr $F68F ; $3A7F: 20 8F F6 rts ; $3A82: 60 Sound_FA83: ldy #$0A ; $3A83: A0 0A lda #$EF ; $3A85: A9 EF jmp Sound_FBA5 ; $3A87: 4C A5 FB ; Preserved sound data / unused bytes Data_FA8A: .byte $D9, $86, $A8, $48, $08, $7F, $40, $28 ; $3A8A: D9 86 A8 48 08 7F 40 28 .byte $08, $7F, $45, $28 ; $3A92: 08 7F 45 28 ; UpdateTriangleEffects ; Purpose: sound-driver routine identified from call flow and register/state access. ; Inputs: sound request, channel, and stream state in zero page/global RAM as used locally. ; Returns: corresponding APU or sequencer state updated. UpdateTriangleEffects: inc $07F6 ; $3A96: EE F6 07 lda $07F6 ; $3A99: AD F6 07 cmp #$04 ; $3A9C: C9 04 bne Sound_FAD8 ; $3A9E: D0 38 lda $F5 ; $3AA0: A5 F5 and #$1F ; $3AA2: 29 1F sta $F5 ; $3AA4: 85 F5 ldx #$92 ; $3AA6: A2 92 ldy #$FA ; $3AA8: A0 FA bne Sound_FB00 ; $3AAA: D0 54 ; UpdateNoiseEffects ; Purpose: sound-driver routine identified from call flow and register/state access. ; Inputs: sound request, channel, and stream state in zero page/global RAM as used locally. ; Returns: corresponding APU or sequencer state updated. UpdateNoiseEffects: lda $F6 ; $3AAC: A5 F6 beq Sound_FABA ; $3AAE: F0 0A cmp #$08 ; $3AB0: C9 08 beq Sound_FABA ; $3AB2: F0 06 and #$0F ; $3AB4: 29 0F cmp #$0F ; $3AB6: C9 0F bne Sound_FAD8 ; $3AB8: D0 1E Sound_FABA: lda $F4 ; $3ABA: A5 F4 and #$80 ; $3ABC: 29 80 bne Sound_FAD8 ; $3ABE: D0 18 lda $F1 ; $3AC0: A5 F1 asl a ; $3AC2: 0A bcs Sound_FB17 ; $3AC3: B0 52 asl a ; $3AC5: 0A bcs Sound_FAE2 ; $3AC6: B0 1A lda $F5 ; $3AC8: A5 F5 asl a ; $3ACA: 0A asl a ; $3ACB: 0A bcs UpdateTriangleEffects ; $3ACC: B0 C8 lda $F1 ; $3ACE: A5 F1 and #$20 ; $3AD0: 29 20 beq Sound_FAD9 ; $3AD2: F0 05 lda $F6 ; $3AD4: A5 F6 beq Sound_FB04 ; $3AD6: F0 2C Sound_FAD8: rts ; $3AD8: 60 Sound_FAD9: lda $F6 ; $3AD9: A5 F6 cmp #$DF ; $3ADB: C9 DF bne Sound_FAD8 ; $3ADD: D0 F9 jmp Sound_F79F ; $3ADF: 4C 9F F7 Sound_FAE2: lda $F5 ; $3AE2: A5 F5 and #$1F ; $3AE4: 29 1F ora #$40 ; $3AE6: 09 40 sta $F5 ; $3AE8: 85 F5 lda #$00 ; $3AEA: A9 00 sta $4008 ; $3AEC: 8D 08 40 sta $F6 ; $3AEF: 85 F6 sta $07F6 ; $3AF1: 8D F6 07 lda #$10 ; $3AF4: A9 10 sta $4004 ; $3AF6: 8D 04 40 sta $400C ; $3AF9: 8D 0C 40 ldx #$8E ; $3AFC: A2 8E ldy #$FA ; $3AFE: A0 FA Sound_FB00: jsr $F687 ; $3B00: 20 87 F6 rts ; $3B03: 60 Sound_FB04: lda $07E9 ; $3B04: AD E9 07 and #$20 ; $3B07: 29 20 bne Sound_FB10 ; $3B09: D0 05 lda #$02 ; $3B0B: A9 02 sta $07F5 ; $3B0D: 8D F5 07 Sound_FB10: ldy #$08 ; $3B10: A0 08 lda #$DF ; $3B12: A9 DF jmp Sound_FBA5 ; $3B14: 4C A5 FB Sound_FB17: ldy #$04 ; $3B17: A0 04 lda #$7F ; $3B19: A9 7F jmp Sound_FBA5 ; $3B1B: 4C A5 FB Sound_FB1E: ldy #$00 ; $3B1E: A0 00 lda #$02 ; $3B20: A9 02 jmp Sound_FBC1 ; $3B22: 4C C1 FB ; UpdateSoundPriority ; Purpose: sound-driver routine identified from call flow and register/state access. ; Inputs: sound request, channel, and stream state in zero page/global RAM as used locally. ; Returns: corresponding APU or sequencer state updated. UpdateSoundPriority: lda $07E8 ; $3B25: AD E8 07 bne Sound_FB5E ; $3B28: D0 34 lda $F2 ; $3B2A: A5 F2 lsr a ; $3B2C: 4A bcs Sound_FB82 ; $3B2D: B0 53 lsr a ; $3B2F: 4A bcs Sound_FB1E ; $3B30: B0 EC lsr a ; $3B32: 4A bcs Sound_FB4C ; $3B33: B0 17 lsr a ; $3B35: 4A bcs Sound_FB7C ; $3B36: B0 44 lsr a ; $3B38: 4A bcs Sound_FB69 ; $3B39: B0 2E lsr a ; $3B3B: 4A bcs Sound_FB5E ; $3B3C: B0 20 lsr a ; $3B3E: 4A bcs Sound_FB58 ; $3B3F: B0 17 lsr a ; $3B41: 4A bcs Sound_FB52 ; $3B42: B0 0E lda $F6 ; $3B44: A5 F6 bne Sound_FB49 ; $3B46: D0 01 rts ; $3B48: 60 Sound_FB49: jmp $F504 ; $3B49: 4C 04 F5 Sound_FB4C: ldy #$02 ; $3B4C: A0 02 lda #$04 ; $3B4E: A9 04 bne Sound_FBA5 ; $3B50: D0 53 Sound_FB52: ldy #$09 ; $3B52: A0 09 lda #$80 ; $3B54: A9 80 bne Sound_FB6D ; $3B56: D0 15 Sound_FB58: ldy #$07 ; $3B58: A0 07 lda #$40 ; $3B5A: A9 40 bne Sound_FB6D ; $3B5C: D0 0F Sound_FB5E: lda #$00 ; $3B5E: A9 00 sta $07E8 ; $3B60: 8D E8 07 ldy #$06 ; $3B63: A0 06 lda #$20 ; $3B65: A9 20 bne Sound_FBC1 ; $3B67: D0 58 Sound_FB69: ldy #$05 ; $3B69: A0 05 lda #$10 ; $3B6B: A9 10 Sound_FB6D: jsr $F6A8 ; $3B6D: 20 A8 F6 ldx #$FC ; $3B70: A2 FC ldy #$FC ; $3B72: A0 FC jsr SilencePulseChannels ; $3B74: 20 12 F7 inc $07F0 ; $3B77: EE F0 07 bne Sound_FB49 ; $3B7A: D0 CD Sound_FB7C: ldy #$03 ; $3B7C: A0 03 lda #$08 ; $3B7E: A9 08 bne Sound_FB86 ; $3B80: D0 04 Sound_FB82: ldy #$01 ; $3B82: A0 01 lda #$01 ; $3B84: A9 01 Sound_FB86: jsr $F6A8 ; $3B86: 20 A8 F6 ldx #$80 ; $3B89: A2 80 ldy #$80 ; $3B8B: A0 80 Sound_FB8D: jsr InitializeApuChannelState ; $3B8D: 20 1A F7 lda #$83 ; $3B90: A9 83 sta $4001 ; $3B92: 8D 01 40 lda #$7F ; $3B95: A9 7F sta $4005 ; $3B97: 8D 05 40 bne Sound_FBAF ; $3B9A: D0 13 jsr $F6A8 ; $3B9C: 20 A8 F6 ldx #$04 ; $3B9F: A2 04 ldy #$04 ; $3BA1: A0 04 bne Sound_FBAC ; $3BA3: D0 07 Sound_FBA5: jsr $F6A8 ; $3BA5: 20 A8 F6 ldx #$80 ; $3BA8: A2 80 ldy #$80 ; $3BAA: A0 80 Sound_FBAC: jsr SilencePulseChannels ; $3BAC: 20 12 F7 Sound_FBAF: lda #$00 ; $3BAF: A9 00 sta $07F0 ; $3BB1: 8D F0 07 lda $F4 ; $3BB4: A5 F4 and #$20 ; $3BB6: 29 20 beq Sound_FB49 ; $3BB8: F0 8F lda #$D5 ; $3BBA: A9 D5 sta $4001 ; $3BBC: 8D 01 40 bne Sound_FB49 ; $3BBF: D0 88 Sound_FBC1: jsr $F6A8 ; $3BC1: 20 A8 F6 ldx #$80 ; $3BC4: A2 80 ldy #$BA ; $3BC6: A0 BA bne Sound_FB8D ; $3BC8: D0 C3 ; Sound sequence pointer/index table and encoded sequence data. SoundSequencePointerTable: .byte $0B, $14, $1D, $26, $2F, $38, $41, $4A ; $3BCA: 0B 14 1D 26 2F 38 41 4A .byte $53, $5C, $65, $0C, $02, $FF, $0B, $FF ; $3BD2: 53 5C 65 0C 02 FF 0B FF .byte $1E, $FF, $31, $FF, $15, $18, $FE, $2A ; $3BDA: 1E FF 31 FF 15 18 FE 2A .byte $FE, $65, $FE, $86, $FE, $0C, $0D, $FE ; $3BE2: FE 65 FE 86 FE 0C 0D FE .byte $00, $00, $13, $FE, $00, $00, $15, $38 ; $3BEA: 00 00 13 FE 00 00 15 38 .byte $FF, $5A, $FF, $79, $FF, $94, $FF, $00 ; $3BF2: FF 5A FF 79 FF 94 FF 00 .byte $00, $00, $D7, $FE, $ED, $FE, $00, $00 ; $3BFA: 00 00 D7 FE ED FE 00 00 .byte $00, $B3, $FF, $C9, $FF, $DA, $FF, $EF ; $3C02: 00 B3 FF C9 FF DA FF EF .byte $FF, $15, $A5, $FC, $0A, $FD, $98, $FD ; $3C0A: FF 15 A5 FC 0A FD 98 FD .byte $E0, $FD, $15, $B2, $FE, $00, $00, $C5 ; $3C12: E0 FD 15 B2 FE 00 00 C5 .byte $FE, $00, $00, $15, $00, $00, $92, $FE ; $3C1A: FE 00 00 15 00 00 92 FE .byte $A1, $FE, $00, $00, $0C, $59, $FC, $72 ; $3C22: A1 FE 00 00 0C 59 FC 72 .byte $FC, $8C, $FC, $00, $00, $00, $00, $00 ; $3C2A: FC 8C FC 00 00 00 00 00 .byte $38, $FC, $49, $FC, $00, $00, $82, $02 ; $3C32: 38 FC 49 FC 00 00 82 02 .byte $8B, $02, $80, $08, $02, $10, $02, $16 ; $3C3A: 8B 02 80 08 02 10 02 16 .byte $02, $52, $02, $02, $02, $1A, $00, $82 ; $3C42: 02 52 02 02 02 1A 00 82 .byte $02, $80, $10, $02, $16, $02, $52, $02 ; $3C4A: 02 80 10 02 16 02 52 02 .byte $5A, $02, $02, $02, $56, $81, $02, $80 ; $3C52: 5A 02 02 02 56 81 02 80 .byte $12, $02, $0C, $02, $04, $02, $0C, $02 ; $3C5A: 12 02 0C 02 04 02 0C 02 .byte $04, $02, $2A, $02, $81, $04, $02, $80 ; $3C62: 04 02 2A 02 81 04 02 80 .byte $04, $02, $81, $04, $88, $02, $02, $00 ; $3C6A: 04 02 81 04 88 02 02 00 .byte $88, $02, $02, $80, $04, $02, $2A, $02 ; $3C72: 88 02 02 80 04 02 2A 02 .byte $24, $02, $2A, $02, $24, $02, $1C, $02 ; $3C7A: 24 02 2A 02 24 02 1C 02 .byte $81, $22, $02, $80, $22, $02, $81, $24 ; $3C82: 81 22 02 80 22 02 81 24 .byte $88, $02, $88, $02, $80, $56, $02, $4E ; $3C8A: 88 02 88 02 80 56 02 4E .byte $02, $12, $02, $4E, $02, $12, $02, $0C ; $3C92: 02 12 02 4E 02 12 02 0C .byte $02, $81, $10, $02, $80, $10, $02, $81 ; $3C9A: 02 81 10 02 80 10 02 81 .byte $12, $88, $02, $C3, $81, $02, $02, $1C ; $3CA2: 12 88 02 C3 81 02 02 1C .byte $02, $02, $02, $1C, $1C, $FF, $C6, $88 ; $3CAA: 02 02 02 1C 1C FF C6 88 .byte $1C, $FF, $C7, $82, $4C, $4C, $2A, $4C ; $3CB2: 1C FF C7 82 4C 4C 2A 4C .byte $FF, $C6, $88, $1C, $FF, $C4, $81, $46 ; $3CBA: FF C6 88 1C FF C4 81 46 .byte $02, $46, $02, $32, $02, $46, $80, $2E ; $3CC2: 02 46 02 32 02 46 80 2E .byte $2E, $FF, $C3, $82, $46, $46, $81, $32 ; $3CCA: 2E FF C3 82 46 46 81 32 .byte $32, $46, $2E, $FF, $80, $0C, $0C, $81 ; $3CD2: 32 46 2E FF 80 0C 0C 81 .byte $46, $46, $46, $80, $04, $04, $81, $46 ; $3CDA: 46 46 46 80 04 04 81 46 .byte $46, $02, $C8, $82, $4C, $4C, $2A, $4C ; $3CE2: 46 02 C8 82 4C 4C 2A 4C .byte $FF, $C2, $81, $46, $80, $32, $32, $82 ; $3CEA: FF C2 81 46 80 32 32 82 .byte $46, $04, $81, $46, $2A, $FF, $C2, $81 ; $3CF2: 46 04 81 46 2A FF C2 81 .byte $0C, $0C, $80, $04, $04, $81, $04, $80 ; $3CFA: 0C 0C 80 04 04 81 04 80 .byte $2E, $2E, $81, $2E, $82, $24, $FF, $00 ; $3D02: 2E 2E 81 2E 82 24 FF 00 .byte $81, $32, $02, $02, $06, $0C, $32, $02 ; $3D0A: 81 32 02 02 06 0C 32 02 .byte $02, $8A, $2E, $8B, $02, $8A, $2E, $8B ; $3D12: 02 8A 2E 8B 02 8A 2E 8B .byte $02, $8A, $2E, $8B, $02, $88, $2E, $32 ; $3D1A: 02 8A 2E 8B 02 88 2E 32 .byte $2E, $D0, $8C, $2C, $24, $FF, $D0, $2E ; $3D22: 2E D0 8C 2C 24 FF D0 2E .byte $20, $FF, $C3, $80, $28, $02, $82, $02 ; $3D2A: 20 FF C3 80 28 02 82 02 .byte $80, $2C, $02, $32, $02, $24, $02, $82 ; $3D32: 80 2C 02 32 02 24 02 82 .byte $02, $81, $02, $80, $28, $02, $06, $02 ; $3D3A: 02 81 02 80 28 02 06 02 .byte $28, $02, $81, $02, $80, $24, $02, $32 ; $3D42: 28 02 81 02 80 24 02 32 .byte $02, $24, $02, $FF, $80, $28, $02, $82 ; $3D4A: 02 24 02 FF 80 28 02 82 .byte $02, $80, $2C, $02, $32, $02, $24, $02 ; $3D52: 02 80 2C 02 32 02 24 02 .byte $82, $02, $89, $0C, $0A, $08, $06, $32 ; $3D5A: 82 02 89 0C 0A 08 06 32 .byte $30, $2E, $2C, $2A, $28, $26, $24, $02 ; $3D62: 30 2E 2C 2A 28 26 24 02 .byte $02, $02, $86, $02, $C7, $84, $02, $FF ; $3D6A: 02 02 86 02 C7 84 02 FF .byte $C4, $80, $28, $02, $82, $02, $80, $2C ; $3D72: C4 80 28 02 82 02 80 2C .byte $02, $32, $02, $24, $02, $82, $02, $81 ; $3D7A: 02 32 02 24 02 82 02 81 .byte $02, $80, $28, $02, $06, $02, $28, $02 ; $3D82: 02 80 28 02 06 02 28 02 .byte $81, $02, $80, $24, $02, $32, $02, $24 ; $3D8A: 81 02 80 24 02 32 02 24 .byte $02, $FF, $C8, $84, $02, $FF, $81, $14 ; $3D92: 02 FF C8 84 02 FF 81 14 .byte $02, $02, $14, $1A, $14, $02, $02, $88 ; $3D9A: 02 02 14 1A 14 02 02 88 .byte $10, $10, $10, $10, $14, $10, $85, $3C ; $3DA2: 10 10 10 10 14 10 85 3C .byte $81, $44, $85, $4A, $81, $44, $88, $28 ; $3DAA: 81 44 85 4A 81 44 88 28 .byte $24, $20, $46, $42, $40, $C6, $81, $3C ; $3DB2: 24 20 46 42 40 C6 81 3C .byte $02, $02, $44, $02, $02, $02, $4A, $02 ; $3DBA: 02 02 44 02 02 02 4A 02 .byte $46, $36, $36, $38, $38, $02, $3A, $02 ; $3DC2: 46 36 36 38 38 02 3A 02 .byte $80, $3C, $3C, $81, $02, $24, $02, $02 ; $3DCA: 80 3C 3C 81 02 24 02 02 .byte $2C, $24, $88, $24, $1E, $46, $36, $38 ; $3DD2: 2C 24 88 24 1E 46 36 38 .byte $3A, $FF, $C4, $84, $02, $FF, $D8, $81 ; $3DDA: 3A FF C4 84 02 FF D8 81 .byte $06, $FF, $C6, $88, $06, $FF, $C7, $81 ; $3DE2: 06 FF C6 88 06 FF C7 81 .byte $06, $06, $80, $06, $06, $81, $06, $06 ; $3DEA: 06 06 80 06 06 81 06 06 .byte $80, $06, $06, $81, $06, $06, $FF, $C6 ; $3DF2: 80 06 06 81 06 06 FF C6 .byte $88, $06, $FF, $E0, $81, $06, $06, $FF ; $3DFA: 88 06 FF E0 81 06 06 FF .byte $82, $0F, $81, $06, $06, $EA, $06, $06 ; $3E02: 82 0F 81 06 06 EA 06 06 .byte $06, $06, $FF, $C5, $80, $0E, $58, $FF ; $3E0A: 06 06 FF C5 80 0E 58 FF .byte $00, $C5, $80, $0E, $58, $FF, $82, $1C ; $3E12: 00 C5 80 0E 58 FF 82 1C .byte $1C, $C3, $82, $1C, $1C, $81, $1C, $1C ; $3E1A: 1C C3 82 1C 1C 81 1C 1C .byte $1C, $02, $FF, $C7, $88, $1C, $FF, $00 ; $3E22: 1C 02 FF C7 88 1C FF 00 .byte $83, $02, $80, $0E, $02, $0E, $02, $0C ; $3E2A: 83 02 80 0E 02 0E 02 0C .byte $02, $0E, $02, $4E, $02, $02, $02, $0E ; $3E32: 02 0E 02 4E 02 02 02 0E .byte $02, $0C, $02, $02, $02, $0E, $02, $0C ; $3E3A: 02 0C 02 02 02 0E 02 0C .byte $02, $0E, $02, $4E, $02, $02, $02, $0E ; $3E42: 02 0E 02 4E 02 02 02 0E .byte $02, $0C, $02, $0E, $02, $0E, $02, $0C ; $3E4A: 02 0C 02 0E 02 0E 02 0C .byte $02, $0E, $02, $4E, $02, $02, $02, $0E ; $3E52: 02 0E 02 4E 02 02 02 0E .byte $02, $0C, $02, $88, $4E, $18, $16, $12 ; $3E5A: 02 0C 02 88 4E 18 16 12 .byte $0E, $0C, $0E, $83, $02, $81, $3E, $3E ; $3E62: 0E 0C 0E 83 02 81 3E 3E .byte $82, $46, $1C, $46, $81, $02, $38, $3E ; $3E6A: 82 46 1C 46 81 02 38 3E .byte $02, $82, $46, $1C, $82, $48, $48, $81 ; $3E72: 02 82 46 1C 82 48 48 81 .byte $3E, $3E, $82, $38, $88, $24, $20, $1C ; $3E7A: 3E 3E 82 38 88 24 20 1C .byte $48, $46, $42, $3E, $82, $09, $09, $C6 ; $3E82: 48 46 42 3E 82 09 09 C6 .byte $82, $03, $0C, $FF, $C6, $88, $06, $FF ; $3E8A: 82 03 0C FF C6 88 06 FF .byte $ED, $89, $2A, $02, $04, $0C, $02, $04 ; $3E92: ED 89 2A 02 04 0C 02 04 .byte $08, $02, $30, $26, $02, $30, $FF, $80 ; $3E9A: 08 02 30 26 02 30 FF 80 .byte $02, $ED, $89, $0C, $02, $12, $4E, $02 ; $3EA2: 02 ED 89 0C 02 12 4E 02 .byte $12, $18, $02, $0E, $08, $02, $0E, $FF ; $3EAA: 12 18 02 0E 08 02 0E FF .byte $80, $42, $02, $48, $02, $1E, $02, $24 ; $3EB2: 80 42 02 48 02 1E 02 24 .byte $02, $02, $02, $2A, $02, $C6, $8C, $30 ; $3EBA: 02 02 02 2A 02 C6 8C 30 .byte $2A, $FF, $00, $80, $24, $02, $2A, $02 ; $3EC2: 2A FF 00 80 24 02 2A 02 .byte $30, $02, $06, $02, $02, $02, $0C, $02 ; $3ECA: 30 02 06 02 02 02 0C 02 .byte $C6, $8C, $12, $18, $FF, $80, $56, $54 ; $3ED2: C6 8C 12 18 FF 80 56 54 .byte $52, $50, $81, $02, $80, $5E, $5A, $54 ; $3EDA: 52 50 81 02 80 5E 5A 54 .byte $50, $18, $14, $10, $0A, $06, $30, $2C ; $3EE2: 50 18 14 10 0A 06 30 2C .byte $28, $02, $00, $80, $1A, $18, $16, $14 ; $3EEA: 28 02 00 80 1A 18 16 14 .byte $81, $02, $80, $02, $5E, $5A, $54, $50 ; $3EF2: 81 02 80 02 5E 5A 54 50 .byte $18, $14, $10, $0A, $06, $30, $2C, $28 ; $3EFA: 18 14 10 0A 06 30 2C 28 .byte $82, $1C, $02, $1C, $02, $02, $1C, $1C ; $3F02: 82 1C 02 1C 02 02 1C 1C .byte $00, $81, $10, $0A, $32, $28, $80, $32 ; $3F0A: 00 81 10 0A 32 28 80 32 .byte $02, $32, $02, $82, $32, $81, $06, $02 ; $3F12: 02 32 02 82 32 81 06 02 .byte $06, $02, $82, $32, $81, $54, $1A, $10 ; $3F1A: 06 02 82 32 81 54 1A 10 .byte $0A, $80, $10, $02, $10, $02, $82, $10 ; $3F22: 0A 80 10 02 10 02 82 10 .byte $81, $16, $02, $16, $02, $82, $0A, $83 ; $3F2A: 81 16 02 16 02 82 0A 83 .byte $03, $0C, $82, $03, $0C, $0C, $C2, $88 ; $3F32: 03 0C 82 03 0C 0C C2 88 .byte $1C, $1C, $1C, $1C, $1C, $1C, $83, $1C ; $3F3A: 1C 1C 1C 1C 1C 1C 83 1C .byte $80, $04, $04, $2A, $02, $82, $1C, $FF ; $3F42: 80 04 04 2A 02 82 1C FF .byte $81, $4C, $02, $4C, $02, $2A, $02, $4C ; $3F4A: 81 4C 02 4C 02 2A 02 4C .byte $1C, $81, $4C, $02, $4C, $02, $4C, $00 ; $3F52: 1C 81 4C 02 4C 02 4C 00 .byte $88, $2E, $2E, $2E, $30, $04, $30, $C4 ; $3F5A: 88 2E 2E 2E 30 04 30 C4 .byte $80, $2E, $04, $FF, $83, $02, $88, $2E ; $3F62: 80 2E 04 FF 83 02 88 2E .byte $2E, $2E, $30, $04, $30, $C4, $80, $2E ; $3F6A: 2E 2E 30 04 30 C4 80 2E .byte $04, $FF, $83, $02, $84, $02, $02, $C2 ; $3F72: 04 FF 83 02 84 02 02 C2 .byte $88, $3E, $3E, $3E, $42, $46, $42, $84 ; $3F7A: 88 3E 3E 3E 42 46 42 84 .byte $3E, $FF, $85, $3E, $81, $3E, $88, $1C ; $3F82: 3E FF 85 3E 81 3E 88 1C .byte $46, $1C, $81, $02, $3E, $3E, $3E, $82 ; $3F8A: 46 1C 81 02 3E 3E 3E 82 .byte $34, $02, $C2, $88, $06, $06, $06, $06 ; $3F92: 34 02 C2 88 06 06 06 06 .byte $06, $06, $82, $06, $06, $06, $06, $FF ; $3F9A: 06 06 82 06 06 06 06 FF .byte $C2, $81, $06, $06, $80, $06, $06, $81 ; $3FA2: C2 81 06 06 80 06 06 81 .byte $06, $06, $06, $06, $80, $06, $06, $FF ; $3FAA: 06 06 06 06 80 06 06 FF .byte $09, $80, $10, $02, $10, $02, $10, $02 ; $3FB2: 09 80 10 02 10 02 10 02 .byte $0C, $0C, $0C, $02, $0C, $02, $14, $14 ; $3FBA: 0C 0C 0C 02 0C 02 14 14 .byte $14, $02, $14, $02, $85, $10, $00, $80 ; $3FC2: 14 02 14 02 85 10 00 80 .byte $32, $02, $32, $02, $32, $02, $C2, $32 ; $3FCA: 32 02 32 02 32 02 C2 32 .byte $32, $32, $02, $32, $02, $FF, $85, $32 ; $3FD2: 32 32 02 32 02 FF 85 32 .byte $80, $54, $02, $54, $02, $54, $02, $50 ; $3FDA: 80 54 02 54 02 54 02 50 .byte $50, $50, $02, $50, $02, $56, $56, $56 ; $3FE2: 50 50 02 50 02 56 56 56 .byte $02, $56, $02, $85, $54, $C4, $85, $0C ; $3FEA: 02 56 02 85 54 C4 85 0C .byte $FF, $FF, $FF, $FF, $FF ; $3FF2: FF FF FF FF FF ; UpdateAudioFrame ; Purpose: sound-driver routine identified from call flow and register/state access. ; Inputs: sound request, channel, and stream state in zero page/global RAM as used locally. ; Returns: corresponding APU or sequencer state updated. UpdateAudioFrame: jmp Sound_F758 ; $3FF7: 4C 58 F7 ; NES interrupt vectors InterruptVectors: .word $C094, $C000, $C0F7 ; $3FFA: 94 C0 00 C0 F7 C0