From ac7457e579782a4389a3ee14dd2a9fcd6fdff28b Mon Sep 17 00:00:00 2001 From: Keith McKnight Date: Tue, 21 Feb 2023 14:46:04 -0500 Subject: [PATCH 01/17] birdo attach, albatoss --- src/prg-0-1.asm | 8 +++++--- src/prg-2-3.asm | 41 +++++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/prg-0-1.asm b/src/prg-0-1.asm index 92217b9..fa34510 100644 --- a/src/prg-0-1.asm +++ b/src/prg-0-1.asm @@ -2104,11 +2104,11 @@ PlayerLiftFrames: .db $08 .db $08 -byte_BANK0_8ACE: +PlayerClimbHorizontalSpeed: .db $00 .db $10 .db $F0 -; --------------------------------------------------------------------------- + HandlePlayerState_Climbing: LDA Player1JoypadHeld @@ -2127,7 +2127,7 @@ loc_BANK0_8ADF: LDA Player1JoypadHeld AND #ControllerInput_Right | ControllerInput_Left TAY - LDA byte_BANK0_8ACE, Y + LDA PlayerClimbHorizontalSpeed, Y STA PlayerXVelocity LDA PlayerXLo CLC @@ -3575,6 +3575,7 @@ loc_BANK0_90AE: LDA PickUpToEnemyTypeTable, Y ; What sprite is spawned for you when lifting a bg object STA ObjectType, X +BombFuse: LDY #$FF ; regular bomb fuse CMP #Enemy_Bomb BEQ loc_BANK0_90C1 @@ -3582,6 +3583,7 @@ loc_BANK0_90AE: CMP #Enemy_BobOmb BNE loc_BANK0_90C5 +BobOmbFuse: LDY #$50 ; BobOmb fuse loc_BANK0_90C1: diff --git a/src/prg-2-3.asm b/src/prg-2-3.asm index cf45e46..8643919 100644 --- a/src/prg-2-3.asm +++ b/src/prg-2-3.asm @@ -3105,7 +3105,7 @@ SetHeartSprite: AND #$20 EOR #$20 ASL A - ORA #$01 + ORA #ObjAttrib_Palette1 STA SpriteDMAArea + 2, Y RenderSprite_Heart_Exit: @@ -3626,7 +3626,7 @@ TurnIntoPuffOfSmoke_Exit: RTS -byte_BANK2_91C5: +BirdoItemXVelocity: .db $F8 .db $08 @@ -3667,14 +3667,17 @@ AttachObjectToBirdo_DoAttach: LDA ObjectYLo, Y ADC #$0E STA ObjectYLo, X - JSR EnemyFindWhichSidePlayerIsOn - LDA byte_BANK2_91C5, Y + ; Determine trajectory of object after Birdo is killed + JSR EnemyFindWhichSidePlayerIsOn + LDA BirdoItemXVelocity, Y STA ObjectXVelocity, X LDA #$E0 STA ObjectYVelocity, X + PLA PLA + LDA #SpriteFlags46E_Damage | SpriteFlags46E_Unliftable | SpriteFlags46E_NoEnemyCollision STA EnemyArray_46E, X LDA #$30 @@ -3682,44 +3685,42 @@ AttachObjectToBirdo_DoAttach: JMP RenderSprite - -byte_BANK2_9212: - .db $F0 - -byte_BANK2_9213: - .db $FF +AlbatossScreenBoundaryOffsetLo: + .db $F0 ; right +AlbatossScreenBoundaryOffsetHi: + .db $FF ; left .db $00 -; --------------------------------------------------------------------------- + EnemyInit_AlbatossStartLeft: JSR EnemyInit_Basic LDA #$F0 - BNE loc_BANK2_9221 + BNE EnemyInit_Albatoss_SetXVelocity EnemyInit_AlbatossStartRight: JSR EnemyInit_Basic LDA #$10 -loc_BANK2_9221: +EnemyInit_Albatoss_SetXVelocity: STA ObjectXVelocity, X INC EnemyArray_B1, X + LDA ObjectType, X SEC - -loc_BANK2_9228: - SBC #$0B + SBC #Enemy_AlbatossStartRight TAY + LDA ScreenBoundaryLeftLo - ADC byte_BANK2_9212, Y + ADC AlbatossScreenBoundaryOffsetLo, Y STA ObjectXLo, X LDA ScreenBoundaryLeftHi - ADC byte_BANK2_9213, Y + ADC AlbatossScreenBoundaryOffsetHi, Y STA ObjectXHi, X + RTS -; --------------------------------------------------------------------------- EnemyBehavior_Albatoss: JSR RenderSprite_Albatoss @@ -12436,7 +12437,7 @@ AreaSecondaryRoutine_HealthBar_Loop: STA SpriteDMAArea + 1, Y LDA #$10 STA SpriteDMAArea + 3, Y - LDA #$01 + LDA #ObjAttrib_Palette1 STA SpriteDMAArea + 2, Y LDA byte_RAM_0 STA SpriteDMAArea, Y From 039c990815b9531743058c36a079dbf78a841893 Mon Sep 17 00:00:00 2001 From: Keith McKnight Date: Tue, 21 Feb 2023 20:31:21 -0500 Subject: [PATCH 02/17] ending --- src/prg-c-d.asm | 483 ++++++++++-------------------------------------- src/ram.asm | 10 +- 2 files changed, 107 insertions(+), 386 deletions(-) diff --git a/src/prg-c-d.asm b/src/prg-c-d.asm index 9ebe494..c3104e4 100644 --- a/src/prg-c-d.asm +++ b/src/prg-c-d.asm @@ -1562,13 +1562,13 @@ CastRoll_TheEndDelay: BPL CastRoll_TheEndDelay_Exit LDA #$00 - STA MarioSnoringCounter5 - STA MarioSnoringCounter6 - STA MarioSnoringCounter7 + STA TheEndScriptWordCopyIndex + STA TheEndScriptCounter + STA TheEndScriptWordTileIndex LDA #$05 - STA MarioSnoringTheEndFrameCounter - LDA #$14 - STA MarioSnoringCounter9 + STA TheEndScriptHoldFrameCounter + LDA #((TheEndScript_End - TheEndScript_The) / 8 - 1) + STA TheEndScriptWordFrameIndex LDA #$3F STA PPUBuffer_301 @@ -1587,93 +1587,92 @@ CastRoll_TheEndDelay_Exit: CastRoll_TheEndAnimation: - LDA MarioSnoringCounter6 +CastRoll_TheEndAnimation_The: + LDA TheEndScriptCounter AND #$80 - BNE CastRoll_TheEndAnimation_Exit + BNE CastRoll_TheEndAnimation_The_Exit - LDA MarioSnoringCounter6 - BNE loc_BANKC_8ACD + LDA TheEndScriptCounter + BNE CastRoll_TheEndAnimation_End - DEC MarioSnoringTheEndFrameCounter - BPL CastRoll_TheEndAnimation_Exit + DEC TheEndScriptHoldFrameCounter + BPL CastRoll_TheEndAnimation_The_Exit LDA #$05 - STA MarioSnoringTheEndFrameCounter + STA TheEndScriptHoldFrameCounter + LDA #$03 - STA MarioSnoringCounter7 + STA TheEndScriptWordTileIndex LDX #$00 - LDY MarioSnoringCounter5 - -loc_BANKC_8A9C: + LDY TheEndScriptWordCopyIndex +CastRoll_TheEndAnimation_The_Loop: LDA #$40 STA SpriteDMAArea, X INX - LDA byte_BANKC_92FE, Y + LDA TheEndScript_The, Y STA SpriteDMAArea, X INY INX LDA #$00 STA SpriteDMAArea, X INX - LDA byte_BANKC_92FE, Y + LDA TheEndScript_The, Y STA SpriteDMAArea, X INY INX - DEC MarioSnoringCounter7 - BPL loc_BANKC_8A9C + DEC TheEndScriptWordTileIndex + BPL CastRoll_TheEndAnimation_The_Loop - STY MarioSnoringCounter5 - DEC MarioSnoringCounter9 - BPL CastRoll_TheEndAnimation_Exit + STY TheEndScriptWordCopyIndex + DEC TheEndScriptWordFrameIndex + BPL CastRoll_TheEndAnimation_The_Exit - INC MarioSnoringCounter6 - LDA #$12 - STA MarioSnoringCounter9 + INC TheEndScriptCounter + LDA #((TheEnd_RTS - TheEndScript_End) / 8 - 1) + STA TheEndScriptWordFrameIndex LDA #$00 - STA MarioSnoringCounter5 + STA TheEndScriptWordCopyIndex -CastRoll_TheEndAnimation_Exit: +CastRoll_TheEndAnimation_The_Exit: RTS -; --------------------------------------------------------------------------- -loc_BANKC_8ACD: - DEC MarioSnoringTheEndFrameCounter - BPL locret_BANKC_8B07 +CastRoll_TheEndAnimation_End: + DEC TheEndScriptHoldFrameCounter + BPL CastRoll_TheEndAnimation_End_Exit LDA #$05 - STA MarioSnoringTheEndFrameCounter + STA TheEndScriptHoldFrameCounter LDA #$03 - STA MarioSnoringCounter7 + STA TheEndScriptWordTileIndex LDX #$00 - LDY MarioSnoringCounter5 - -loc_BANKC_8ADD: + LDY TheEndScriptWordCopyIndex +CastRoll_TheEndAnimation_End_Loop: LDA #$40 STA SpriteDMAArea + $10, X INX - LDA byte_BANKC_93A6, Y + LDA TheEndScript_End, Y STA SpriteDMAArea + $10, X INY INX LDA #$00 STA SpriteDMAArea + $10, X INX - LDA byte_BANKC_93A6, Y + LDA TheEndScript_End, Y STA SpriteDMAArea + $10, X INY INX - DEC MarioSnoringCounter7 - BPL loc_BANKC_8ADD + DEC TheEndScriptWordTileIndex + BPL CastRoll_TheEndAnimation_End_Loop - STY MarioSnoringCounter5 - DEC MarioSnoringCounter9 - BPL locret_BANKC_8B07 + STY TheEndScriptWordCopyIndex + DEC TheEndScriptWordFrameIndex + BPL CastRoll_TheEndAnimation_End_Exit LDA #$FF - STA MarioSnoringCounter6 + STA TheEndScriptCounter -locret_BANKC_8B07: +CastRoll_TheEndAnimation_End_Exit: RTS @@ -1884,17 +1883,15 @@ CastRoll_Porcupo: .db $F9, $3E, $00, $30 ; $10 .db $F9, $30, $00, $38 ; $14 .db $F9, $32, $00, $40 ; $18 - .db $F9 ; $1C -byte_BANKC_8D5F: - .db $3E, $00, $48, $F9 - .db $EE, $00, $24, $F9 ; 4 - .db $EC, $00, $2C, $F9 ; 8 - .db $F2, $00, $34, $F9 ; $C - .db $D4, $00, $3C, $F9 ; $10 - .db $F8, $00, $44, $F9 ; $14 - .db $EE, $00, $4C, $F9 ; $18 - .db $EC, $00, $54, $F9 ; $1C - .db $3E, $00, $5C ; $20 + .db $F9, $3E, $00, $48 ; $1C + .db $F9, $EE, $00, $24 ; $20 + .db $F9, $EC, $00, $2C ; $24 + .db $F9, $F2, $00, $34 ; $28 + .db $F9, $D4, $00, $3C ; $2C + .db $F9, $F8, $00, $44 ; $30 + .db $F9, $EE, $00, $4C ; $34 + .db $F9, $EC, $00, $54 ; $38 + .db $F9, $3E, $00, $5C ; $3C CastRoll_Tweeter: .db $D0, $3E, $00, $30 .db $D0, $3E, $00, $38 ; 4 @@ -2268,327 +2265,51 @@ CastRoll_Wart: .db $F9, $F6, $00, $44 ; $50 .db $F9, $C0, $00, $50 ; $54 .db $F9, $C0, $00, $58 ; $58 -byte_BANKC_92FE: - .db $10 - .db $90 - .db $7C - .db $98 - .db $7C - .db $A0 - .db $7C - .db $A8 - .db $12 - .db $90 - .db $7C - .db $98 - .db $7C - .db $A0 - .db $7C - .db $A8 - .db $14 - .db $90 - .db $7C - .db $98 - .db $7C - .db $A0 - .db $7C - .db $A8 - .db $16 - .db $90 - .db $7C - .db $98 - .db $7C - .db $A0 - .db $7C - .db $A8 - .db $16 - .db $90 - .db $18 - .db $98 - .db $7C - .db $A0 - .db $7C - .db $A8 - .db $16 - .db $90 - .db $1A - .db $98 - .db $7C - .db $A0 - .db $7C - .db $A8 - .db $16 - .db $90 - .db $1C - .db $98 - .db $7C - .db $A0 - .db $7C - .db $A8 - .db $16 - .db $90 - .db $1E - .db $98 - .db $7C - .db $A0 - .db $7C - .db $A8 - .db $20 - .db $90 - .db $1E - .db $98 - .db $7C - .db $A0 - .db $7C - .db $A8 - .db $24 - .db $90 - .db $1E - .db $98 - .db $7C - .db $A0 - .db $7C - .db $A8 - .db $24 - .db $90 - .db $28 - .db $98 - .db $7C - .db $A0 - .db $7C - .db $A8 - .db $24 - .db $90 - .db $2A - .db $98 - .db $7C - .db $A0 - .db $7C - .db $A8 - .db $24 - .db $90 - .db $2A - .db $98 - .db $2C - .db $A0 - .db $7C - .db $A8 - .db $24 - .db $90 - .db $2A - .db $98 - .db $2E - .db $A0 - .db $7C - .db $A8 - .db $24 - .db $90 - .db $30 - .db $98 - .db $32 - .db $A0 - .db $7C - .db $A8 - .db $24 - .db $90 - .db $30 - .db $98 - .db $34 - .db $A0 - .db $7C - .db $A8 - .db $24 - .db $90 - .db $30 - .db $98 - .db $36 - .db $A0 - .db $7C - .db $A8 - .db $24 - .db $90 - .db $30 - .db $98 - .db $36 - .db $A0 - .db $38 - .db $A8 - .db $24 - .db $90 - .db $30 - .db $98 - .db $3A - .db $A0 - .db $3C - .db $A8 - .db $24 - .db $90 - .db $30 - .db $98 - .db $3E - .db $A0 - .db $40 - .db $A8 - .db $24 - .db $90 - .db $30 - .db $98 - .db $3E - .db $A0 - .db $42 - .db $A8 -byte_BANKC_93A6: - .db $44 - .db $B0 - .db $46 - .db $B8 - .db $7C - .db $C0 - .db $7C - .db $C8 - .db $48 - .db $B0 - .db $4A - .db $B8 - .db $7C - .db $C0 - .db $7C - .db $C8 - .db $4C - .db $B0 - .db $4E - .db $B8 - .db $7C - .db $C0 - .db $7C - .db $C8 - .db $50 - .db $B0 - .db $52 - .db $B8 - .db $7C - .db $C0 - .db $7C - .db $C8 - .db $54 - .db $B0 - .db $56 - .db $B8 - .db $7C - .db $C0 - .db $7C - .db $C8 - .db $58 - .db $B0 - .db $5A - .db $B8 - .db $7C - .db $C0 - .db $7C - .db $C8 - .db $5C - .db $B0 - .db $5E - .db $B8 - .db $7C - .db $C0 - .db $7C - .db $C8 - .db $5C - .db $B0 - .db $60 - .db $B8 - .db $7C - .db $C0 - .db $7C - .db $C8 - .db $5C - .db $B0 - .db $62 - .db $B8 - .db $7C - .db $C0 - .db $7C - .db $C8 - .db $5C - .db $B0 - .db $64 - .db $B8 - .db $66 - .db $C0 - .db $7C - .db $C8 - .db $5C - .db $B0 - .db $64 - .db $B8 - .db $68 - .db $C0 - .db $7C - .db $C8 - .db $5C - .db $B0 - .db $64 - .db $B8 - .db $6A - .db $C0 - .db $7C - .db $C8 - .db $5C - .db $B0 - .db $64 - .db $B8 - .db $6C - .db $C0 - .db $6E - .db $C8 - .db $5C - .db $B0 - .db $64 - .db $B8 - .db $6C - .db $C0 - .db $70 - .db $C8 - .db $5C - .db $B0 - .db $64 - .db $B8 - .db $6C - .db $C0 - .db $72 - .db $C8 - .db $5C - .db $B0 - .db $64 - .db $B8 - .db $6C - .db $C0 - .db $74 - .db $C8 - .db $5C - .db $B0 - .db $64 - .db $B8 - .db $6C - .db $C0 - .db $76 - .db $C8 - .db $5C - .db $B0 - .db $64 - .db $B8 - .db $6C - .db $C0 - .db $78 - .db $C8 - .db $5C - .db $B0 - .db $64 - .db $B8 - .db $6C - .db $C0 - .db $7A - .db $C8 - .db $60 +TheEndScript_The: + .db $10, $90, $7C, $98, $7C, $A0, $7C, $A8 + .db $12, $90, $7C, $98, $7C, $A0, $7C, $A8 + .db $14, $90, $7C, $98, $7C, $A0, $7C, $A8 + .db $16, $90, $7C, $98, $7C, $A0, $7C, $A8 + .db $16, $90, $18, $98, $7C, $A0, $7C, $A8 + .db $16, $90, $1A, $98, $7C, $A0, $7C, $A8 + .db $16, $90, $1C, $98, $7C, $A0, $7C, $A8 + .db $16, $90, $1E, $98, $7C, $A0, $7C, $A8 + .db $20, $90, $1E, $98, $7C, $A0, $7C, $A8 + .db $24, $90, $1E, $98, $7C, $A0, $7C, $A8 + .db $24, $90, $28, $98, $7C, $A0, $7C, $A8 + .db $24, $90, $2A, $98, $7C, $A0, $7C, $A8 + .db $24, $90, $2A, $98, $2C, $A0, $7C, $A8 + .db $24, $90, $2A, $98, $2E, $A0, $7C, $A8 + .db $24, $90, $30, $98, $32, $A0, $7C, $A8 + .db $24, $90, $30, $98, $34, $A0, $7C, $A8 + .db $24, $90, $30, $98, $36, $A0, $7C, $A8 + .db $24, $90, $30, $98, $36, $A0, $38, $A8 + .db $24, $90, $30, $98, $3A, $A0, $3C, $A8 + .db $24, $90, $30, $98, $3E, $A0, $40, $A8 + .db $24, $90, $30, $98, $3E, $A0, $42, $A8 + +TheEndScript_End: + .db $44, $B0, $46, $B8, $7C, $C0, $7C, $C8 + .db $48, $B0, $4A, $B8, $7C, $C0, $7C, $C8 + .db $4C, $B0, $4E, $B8, $7C, $C0, $7C, $C8 + .db $50, $B0, $52, $B8, $7C, $C0, $7C, $C8 + .db $54, $B0, $56, $B8, $7C, $C0, $7C, $C8 + .db $58, $B0, $5A, $B8, $7C, $C0, $7C, $C8 + .db $5C, $B0, $5E, $B8, $7C, $C0, $7C, $C8 + .db $5C, $B0, $60, $B8, $7C, $C0, $7C, $C8 + .db $5C, $B0, $62, $B8, $7C, $C0, $7C, $C8 + .db $5C, $B0, $64, $B8, $66, $C0, $7C, $C8 + .db $5C, $B0, $64, $B8, $68, $C0, $7C, $C8 + .db $5C, $B0, $64, $B8, $6A, $C0, $7C, $C8 + .db $5C, $B0, $64, $B8, $6C, $C0, $6E, $C8 + .db $5C, $B0, $64, $B8, $6C, $C0, $70, $C8 + .db $5C, $B0, $64, $B8, $6C, $C0, $72, $C8 + .db $5C, $B0, $64, $B8, $6C, $C0, $74, $C8 + .db $5C, $B0, $64, $B8, $6C, $C0, $76, $C8 + .db $5C, $B0, $64, $B8, $6C, $C0, $78, $C8 + .db $5C, $B0, $64, $B8, $6C, $C0, $7A, $C8 + +; Not actually used +TheEnd_RTS: + RTS diff --git a/src/ram.asm b/src/ram.asm index ae55269..66d26b0 100644 --- a/src/ram.asm +++ b/src/ram.asm @@ -84,17 +84,17 @@ TitleScreenStoryNeedsClear: ; set when the text area needs to be cleared for the MarioSnoringWaveFrameCounter: ; controls waving speed TitleScreenStoryTextIndex: .dsb 1 ; 3 ; $0018 -MarioSnoringCounter5: +TheEndScriptWordCopyIndex: ; index of the script tile/position data that gets copied TitleScreenStoryDone: ; RAM $0002 check will restart title screen when set .dsb 1 ; 4 ; $0019 -MarioSnoringCounter6: +TheEndScriptCounter: ; ??? TitleScreenStoryTextLineTimer: ; used to pause between writing lines of text .dsb 1 ; 5 ; $001a -MarioSnoringCounter7: +TheEndScriptWordTileIndex: ; each word is 4 tiles wide .dsb 1 ; 6 ; $001b -MarioSnoringTheEndFrameCounter: ; controls writing speed +TheEndScriptHoldFrameCounter: ; controls writing speed .dsb 1 ; 7 ; $001c -MarioSnoringCounter9: +TheEndScriptWordFrameIndex: ; used to count down number of frames per word .dsb 1 ; 8 ; $001d PlayerYHi: From 9285ee4ad7bf8555ae49e5097a7144f61f0a0bea Mon Sep 17 00:00:00 2001 From: Keith McKnight Date: Wed, 22 Feb 2023 17:55:02 -0500 Subject: [PATCH 03/17] ending labels --- src/prg-0-1.asm | 256 +++++++++++++++++++++++++----------------------- src/prg-2-3.asm | 85 ++++++++++------ 2 files changed, 188 insertions(+), 153 deletions(-) diff --git a/src/prg-0-1.asm b/src/prg-0-1.asm index fa34510..6948e64 100644 --- a/src/prg-0-1.asm +++ b/src/prg-0-1.asm @@ -866,7 +866,7 @@ CopyBackgroundAttributesToPPUBuffer_Vertical_Loop: CopyBackgroundAttributesToPPUBuffer_Vertical_HalfRow: ; Bottom row of PPU attributes has half-sized blocks - ; Shift background palettes down one quad + ; Shift background palettes down one quad LDA ScrollingPPUAttributeUpdateBuffer, X LSR A LSR A @@ -3641,7 +3641,7 @@ loc_BANK0_90EA: TileBehavior_CheckJar: LDY HoldingItem - BNE loc_BANK0_917C + BNE TileBehavior_CheckPickUp_DoNotLift LDA PlayerDucking BEQ TileBehavior_CheckPickUp @@ -3656,7 +3656,7 @@ TileBehavior_CheckJar: CMP #BackgroundTile_JarTopNonEnterable BEQ TileBehavior_GoDownJar - BNE loc_BANK0_917C + BNE TileBehavior_CheckPickUp_DoNotLift TileBehavior_CheckJar_NotSubspace: INY @@ -3665,7 +3665,7 @@ TileBehavior_CheckJar_NotSubspace: BEQ TileBehavior_GoDownJar CMP #BackgroundTile_JarTopPointer - BNE loc_BANK0_917C + BNE TileBehavior_CheckPickUp_DoNotLift INY ; Now Y = $02 @@ -3676,7 +3676,7 @@ TileBehavior_GoDownJar: ADC #$04 AND #$0F CMP #$08 - BCS loc_BANK0_917C + BCS TileBehavior_CheckPickUp_DoNotLift ; Stop horiziontal movement LDA #$00 @@ -3712,7 +3712,7 @@ SnapPlayerToTile_Exit: TileBehavior_CheckPickUp: BIT Player1JoypadPress - BVC loc_BANK0_917C + BVC TileBehavior_CheckPickUp_DoNotLift ; B button pressed @@ -3721,34 +3721,34 @@ TileBehavior_CheckPickUp: ADC #$06 AND #$0F CMP #$0C - BCS loc_BANK0_917C + BCS TileBehavior_CheckPickUp_DoNotLift LDA byte_RAM_0 CMP #BackgroundTile_DiggableSand - BNE loc_BANK0_916E + BNE TileBehavior_CheckPickUp_ItemTile + ; It's sand! Set the enemy pickup index LDA #$0E - BNE loc_BANK0_9177 + BNE TileBehavior_CheckPickUp_SetPickUpIndex -; blocks that can be picked up -loc_BANK0_916E: +TileBehavior_CheckPickUp_ItemTile: + ; blocks that can be picked up CMP #BackgroundTile_Unused6D - BCS loc_BANK0_917C + BCS TileBehavior_CheckPickUp_DoNotLift ; convert to an index in PickUpToEnemyTypeTable SEC SBC #BackgroundTile_MushroomBlock - BCC loc_BANK0_917C + BCC TileBehavior_CheckPickUp_DoNotLift -loc_BANK0_9177: +TileBehavior_CheckPickUp_SetPickUpIndex: STA byte_RAM_9 JMP loc_BANK0_9074 -; --------------------------------------------------------------------------- -loc_BANK0_917C: +TileBehavior_CheckPickUp_DoNotLift: LDA PlayerDucking - BNE locret_BANK0_91CE + BNE TileBehavior_CheckDoorTiles_Exit LDA byte_RAM_6 SEC @@ -3761,9 +3761,9 @@ loc_BANK0_917C: STA byte_RAM_1 LDA byte_RAM_3 STA byte_RAM_2 - JSR sub_BANK0_92C1 + JSR CheckOutOfBounds_Bank0 - BCS locret_BANK0_91CE + BCS TileBehavior_CheckDoorTiles_Exit JSR SetTileOffsetAndAreaPageAddr_Bank1 @@ -3775,36 +3775,35 @@ loc_BANK0_917C: LDX ObjectBeingCarriedIndex LDY ObjectType, X CPY #Enemy_Key - BNE locret_BANK0_91CE + BNE TileBehavior_CheckDoorTiles_Exit loc_BANK0_91AE: LDX InSubspaceOrJar CPX #$02 BEQ loc_BANK0_91BF + ; check to see if the tile matches one of the door tiles LDY #$04 - -; check to see if the tile matches one of the door tiles -loc_BANK0_91B7: +TileBehavior_CheckDoorTiles_Loop: CMP DoorTiles, Y - BEQ loc_BANK0_91EB + BEQ TileBehavior_CheckDoorTiles_Index DEY - BPL loc_BANK0_91B7 + BPL TileBehavior_CheckDoorTiles_Loop loc_BANK0_91BF: BIT Player1JoypadPress - BVC locret_BANK0_91CE + BVC TileBehavior_CheckDoorTiles_Exit STA byte_RAM_0 CMP #BackgroundTile_GrassInactive - BCS locret_BANK0_91CE + BCS TileBehavior_CheckDoorTiles_Exit SEC SBC #BackgroundTile_GrassCoin BCS loc_BANK0_91CF -locret_BANK0_91CE: +TileBehavior_CheckDoorTiles_Exit: RTS ; --------------------------------------------------------------------------- @@ -3830,17 +3829,16 @@ loc_BANK0_91E3: STA byte_RAM_9 JMP loc_BANK0_9074 -; --------------------------------------------------------------------------- ; ; Checks to see if we're trying to go through the door ; ; Input ; Y = tile index in DoorTiles -loc_BANK0_91EB: +TileBehavior_CheckDoorTiles_Index: LDA Player1JoypadPress AND #ControllerInput_Up - BEQ locret_BANK0_91CE + BEQ TileBehavior_CheckDoorTiles_Exit ; player is holding up and is trying to go through this door LDA PlayerXLo @@ -3848,19 +3846,18 @@ loc_BANK0_91EB: ADC #$05 AND #$0F CMP #$0A - BCS locret_BANK0_91CE + BCS TileBehavior_CheckDoorTiles_Exit CPY #$04 ; index of BackgroundTile_LightDoorEndLevel - BNE loc_BANK0_9205 + BNE TileBehavior_CheckDoorTiles_AreaTransition ; setting GameMode to $03 to go to Bonus Chance DEY STY GameMode RTS -; --------------------------------------------------------------------------- -loc_BANK0_9205: +TileBehavior_CheckDoorTiles_AreaTransition: LDA #TransitionType_Door STA TransitionType TYA @@ -3958,6 +3955,7 @@ loc_BANK0_925E: ADC byte_RAM_0 STA byte_RAM_2 STA byte_RAM_3 + LDA IsHorizontalLevel BNE loc_BANK0_927D @@ -3980,7 +3978,7 @@ loc_BANK0_9284: ADC byte_RAM_1 STA byte_RAM_1 STA byte_RAM_4 - JSR sub_BANK0_92C1 + JSR CheckOutOfBounds_Bank0 BCC loc_BANK0_929E @@ -4000,12 +3998,23 @@ loc_BANK0_92A5: RTS -; =============== S U B R O U T I N E ======================================= - -sub_BANK0_92AA: +; +; Converts absolute vertical position to page-relative vertical position +; +; Since pages are $F0 pixels tall, this effectively adds $10 per page +; +; Input +; Y = y-position hi +; A = y-position lo +; +; Output +; Y = page +; A = y-position lo (on page) +; +AbsoluteToPageRelativeY_Bank0: STA byte_RAM_F TYA - BMI locret_BANK0_92C0 + BMI AbsoluteToPageRelativeY_Exit_Bank0 ASL A ASL A @@ -4013,49 +4022,62 @@ sub_BANK0_92AA: ASL A CLC ADC byte_RAM_F - BCS loc_BANK0_92BC + BCS AbsoluteToPageRelativeY_Overflow_Bank0 CMP #$F0 - BCC locret_BANK0_92C0 + BCC AbsoluteToPageRelativeY_Exit_Bank0 -loc_BANK0_92BC: +AbsoluteToPageRelativeY_Overflow_Bank0: CLC ADC #$10 INY -locret_BANK0_92C0: +AbsoluteToPageRelativeY_Exit_Bank0: RTS -; End of function sub_BANK0_92AA - ; ; NOTE: This is a copy of the "sub_BANK3_BC2E" routine in Bank 3 ; +; Checks if the position is out of bounds +; +; Input +; byte_RAM_1 = y-position hi +; byte_RAM_E6 = y-position lo +; byte_RAM_2 = x-position hi +; byte_RAM_E5 = x-position lo +; +; Output +; byte_RAM_E8 = out-of-bounds page number +; C = whether the position is out of bounds ; -sub_BANK0_92C1: +CheckOutOfBounds_Bank0: LDY byte_RAM_1 LDA byte_RAM_E6 - JSR sub_BANK0_92AA - + JSR AbsoluteToPageRelativeY_Bank0 STY byte_RAM_1 STA byte_RAM_E6 + LDY IsHorizontalLevel LDA byte_RAM_1, Y STA byte_RAM_E8 + + ; Is X out of bounds? LDA byte_RAM_2 - CMP byte_BANK0_92E0 + 1, Y - BCS locret_BANK0_92DF + CMP OutOfBoundsPageX_Bank0, Y + BCS CheckOutOfBounds_Exit_Bank0 + ; X position is in bounds, what about Y? LDA byte_RAM_1 - CMP byte_BANK0_92E0, Y + CMP OutOfBoundsPageY_Bank0, Y -locret_BANK0_92DF: +CheckOutOfBounds_Exit_Bank0: RTS -byte_BANK0_92E0: +OutOfBoundsPageY_Bank0: .db $0A +OutOfBoundsPageX_Bank0: .db $01 .db $0B @@ -4208,7 +4230,7 @@ ReplaceTile_StoreXHi_Bank0: LDA ObjectYHi, X ADC #$00 STA byte_RAM_1 - JSR sub_BANK0_92C1 + JSR CheckOutOfBounds_Bank0 PLA BCS locret_BANK0_934E @@ -4259,7 +4281,7 @@ loc_BANK0_937C: INY loc_BANK0_93B9: - LDA byte_BANK0_940A, Y + LDA PPUNametableTargetHi, Y CLC ADC PPUBuffer_301, X STA PPUBuffer_301, X @@ -4306,11 +4328,11 @@ loc_BANK0_93B9: ; Another byte of PPU high addresses for horiz/vert levels -byte_BANK0_940A: - .db $20 - .db $28 - .db $20 - .db $24 +PPUNametableTargetHi: + .db $20 ; vertical + .db $28 ; vertical + .db $20 ; horizontal + .db $24 ; horizontal ; @@ -6517,8 +6539,8 @@ EndingCelebrationPaletteFade3: EndingScreenUpdateIndex: .db EndingUpdateBuffer_PaletteFade1 - .db EndingUpdateBuffer_PaletteFade2 ; 1 ; @TODO This seems wrong, somehow - .db EndingUpdateBuffer_PaletteFade3 ; 2 + .db EndingUpdateBuffer_PaletteFade2 + .db EndingUpdateBuffer_PaletteFade3 ContributorSpriteZeroOAMData: .db $8C, $FC, $20, $94 @@ -6613,19 +6635,19 @@ loc_BANK1_AAD4: INC byte_RAM_10 JSR ContributorTicker - JSR loc_BANK1_ABCC + JSR ContributorPhaseAnimation LDA byte_RAM_E6 CMP #$03 - BCS loc_BANK1_AB20 + BCS ContributorScene_SubconCheer -loc_BANK1_AAE7: +ContributorScene_VBlankLoop: BIT PPUSTATUS - BVS loc_BANK1_AAE7 + BVS ContributorScene_VBlankLoop -loc_BANK1_AAEC: +ContributorScene_VBlank2Loop: BIT PPUSTATUS - BVC loc_BANK1_AAEC + BVC ContributorScene_VBlank2Loop LDX #$02 @@ -6660,9 +6682,8 @@ loc_BANK1_AAF5: loc_BANK1_AB1D: JMP loc_BANK1_AAD4 -; --------------------------------------------------------------------------- -loc_BANK1_AB20: +ContributorScene_SubconCheer: LDA #VMirror JSR ChangeNametableMirroring @@ -6684,29 +6705,27 @@ loc_BANK1_AB32: JSR ContributorCharacterAnimation -loc_BANK1_AB40: +ContributorScene_SubconCheer_VBlankLoop: BIT PPUSTATUS - BVS loc_BANK1_AB40 + BVS ContributorScene_SubconCheer_VBlankLoop -loc_BANK1_AB45: +ContributorScene_SubconCheer_VBlank2Loop: BIT PPUSTATUS - BVC loc_BANK1_AB45 + BVC ContributorScene_SubconCheer_VBlank2Loop + ; Timing for the Subcons jumping scroll position LDX #$02 - loc_BANK1_AB4C: LDY #$00 - loc_BANK1_AB4E: LDA byte_RAM_0 LDA byte_RAM_0 DEY BNE loc_BANK1_AB4E - DEX BNE loc_BANK1_AB4C - LDA #$B0 + LDA #PPUCtrl_Base2000 | PPUCtrl_WriteHorizontal | PPUCtrl_Sprite0000 | PPUCtrl_Background1000 | PPUCtrl_SpriteSize8x16 | PPUCtrl_NMIEnabled ORA byte_RAM_F2 STA PPUCtrlMirror STA PPUCTRL @@ -6764,9 +6783,7 @@ EndingSceneTransition_Exit: RTS -; --------------------------------------------------------------------------- - -loc_BANK1_ABA7: +ContributorScene_FadeIn: LDA byte_RAM_10 AND #$03 BNE EndingSceneTransition_Exit @@ -6796,19 +6813,18 @@ DisableNMI_Bank1: RTS - -loc_BANK1_ABCC: +ContributorPhaseAnimation: JSR ContributorCharacterAnimation LDA byte_RAM_E6 JSR JumpToTableAfterJump - .dw loc_BANK1_ABA7 - .dw loc_BANK1_AC0A - .dw loc_BANK1_AC87 + .dw ContributorScene_FadeIn + .dw ContributorScene_CrowdSurfing + .dw ContributorScene_Zonk -byte_BANK1_ABDA: +ZonkXVelocity: .db $C0 .db $C8 .db $B8 @@ -6816,7 +6832,7 @@ byte_BANK1_ABDA: .db $C8 .db $C0 -byte_BANK1_ABE0: +ZonkYVelocity: .db $C0 .db $08 .db $E0 @@ -6838,7 +6854,7 @@ EndingWartTiles: .db $25 .db $27 -byte_BANK1_ABF2: +EndingWartTilesX: .db $00 .db $08 .db $10 @@ -6852,7 +6868,7 @@ byte_BANK1_ABF2: .db $20 .db $28 -byte_BANK1_ABFE: +EndingWartTilesY: .db $00 .db $00 .db $00 @@ -6867,87 +6883,84 @@ byte_BANK1_ABFE: .db $10 -; --------------------------------------------------------------------------- - -loc_BANK1_AC0A: +ContributorScene_CrowdSurfing: JSR ApplyPlayerPhysicsX LDA PlayerXHi CMP #$01 - BNE loc_BANK1_AC37 + BNE ContributorScene_CrowdSurfing_PositionY LDA PlayerXLo CMP #$20 - BCC loc_BANK1_AC37 + BCC ContributorScene_CrowdSurfing_PositionY + ; Advance to next phase INC_abs byte_RAM_E6 LDA #$A0 STA byte_RAM_10 - LDX #$05 -loc_BANK1_AC22: + LDX #$05 +ContributorScene_CrowdSurfing_ZonkVelocityLoop: LDA #$20 STA ObjectXLo, X LDA #$A8 - -loc_BANK1_AC28: STA ObjectYLo, X - LDA byte_BANK1_ABDA, X + LDA ZonkXVelocity, X STA ObjectXVelocity, X - LDA byte_BANK1_ABE0, X + LDA ZonkYVelocity, X STA ObjectYVelocity, X DEX - BPL loc_BANK1_AC22 + BPL ContributorScene_CrowdSurfing_ZonkVelocityLoop -loc_BANK1_AC37: +ContributorScene_CrowdSurfing_PositionY: LDY #$A0 LDA byte_RAM_10 AND #$38 - BNE loc_BANK1_AC40 + BNE ContributorScene_CrowdSurfing_PositionY_Skip1 DEY -loc_BANK1_AC40: +ContributorScene_CrowdSurfing_PositionY_Skip1: AND #$08 - BNE loc_BANK1_AC45 + BNE ContributorScene_CrowdSurfing_PositionY_Skip2 DEY -loc_BANK1_AC45: +ContributorScene_CrowdSurfing_PositionY_Skip2: STY PlayerYLo + LDX #$0B LDY #$70 - -loc_BANK1_AC4B: +ContributorScene_CrowdSurfing_DrarWart_Loop: LDA PlayerYLo CLC - ADC byte_BANK1_ABFE, X + ADC EndingWartTilesY, X STA SpriteDMAArea, Y LDA EndingWartTiles, X STA SpriteDMAArea + 1, Y LDA #$01 STA SpriteDMAArea + 2, Y + LDA PlayerXLo CLC - ADC byte_BANK1_ABF2, X + ADC EndingWartTilesX, X STA SpriteDMAArea + 3, Y - LDA PlayerXHi -loc_BANK1_AC6A: + LDA PlayerXHi ADC #$00 - BEQ loc_BANK1_AC73 + BEQ ContributorScene_CrowdSurfing_DrarWart_Next LDA #$F0 STA SpriteDMAArea, Y -loc_BANK1_AC73: +ContributorScene_CrowdSurfing_DrarWart_Next: INY INY INY INY DEX - BPL loc_BANK1_AC4B + BPL ContributorScene_CrowdSurfing_DrarWart_Loop RTS @@ -6960,7 +6973,7 @@ ZonkTiles: .db $37 .db $39 -byte_BANK1_AC81: +ZonkPositionReset: .db $00 .db $06 .db $03 @@ -6969,11 +6982,10 @@ byte_BANK1_AC81: .db $0C -loc_BANK1_AC87: +ContributorScene_Zonk: LDA byte_RAM_10 BNE loc_BANK1_ACA4 -loc_BANK1_AC8B: STA ObjectXSubpixel + 6 STA ObjectYSubpixel + 6 STA ObjectXLo + 6 @@ -6987,10 +6999,8 @@ loc_BANK1_AC8B: INC_abs byte_RAM_E6 - loc_BANK1_ACA4: LDX #$05 - loc_BANK1_ACA6: STX byte_RAM_12 JSR ApplyObjectPhysicsX_Bank1 @@ -7002,7 +7012,7 @@ loc_BANK1_ACA6: BEQ loc_BANK1_ACC1 AND #$0F - CMP byte_BANK1_AC81, X + CMP ZonkPositionReset, X BNE loc_BANK1_ACC3 LDA #$20 diff --git a/src/prg-2-3.asm b/src/prg-2-3.asm index 8643919..11896b3 100644 --- a/src/prg-2-3.asm +++ b/src/prg-2-3.asm @@ -7739,11 +7739,10 @@ RenderSprite_Mouser_Exit: RTS -; --------------------------------------------------------------------------- -byte_BANK3_A652: +OstroRiderOffsetX: .db $FB .db $05 -; --------------------------------------------------------------------------- + RenderSprite_Ostro: JSR RenderSprite_NotRocket @@ -7761,7 +7760,7 @@ RenderSprite_Ostro: LDY EnemyMovementDirection, X LDA byte_RAM_1 CLC - ADC byte_BANK3_A652 - 1, Y + ADC OstroRiderOffsetX - 1, Y STA byte_RAM_1 JSR FindSpriteSlot @@ -11533,12 +11532,13 @@ DetermineCollisionFlags_Y: CPX #$01 BCS loc_BANK3_BAD1 + ; The player can duck, so see if we need to account for that IFNDEF PLAYER_HITBOX PHA LDY PlayerDucking PLA SEC - SBC byte_BANK3_BB2F, Y + SBC PlayerHitBoxYOffset, Y ELSE LDY PlayerHitbox SEC @@ -11615,11 +11615,10 @@ DetermineCollisionFlags_ExitY: RTS -byte_BANK3_BB2F: - .db $0B - .db $10 +PlayerHitBoxYOffset: + .db $0B ; standing + .db $10 ; ducking -; =============== S U B R O U T I N E ======================================= sub_BANK3_BB31: LDY #$00 @@ -11758,6 +11757,7 @@ loc_BANK3_BB96: ADC byte_RAM_0 STA byte_RAM_2 STA byte_RAM_3 + LDA IsHorizontalLevel BNE loc_BANK3_BBB5 @@ -11780,7 +11780,7 @@ loc_BANK3_BBBC: ADC byte_RAM_1 STA byte_RAM_1 STA byte_RAM_4 - JSR sub_BANK3_BC2E + JSR CheckOutOfBounds BCC loc_BANK3_BBD6 @@ -11888,31 +11888,45 @@ SetPlayerStateLifting: ; -; @TODO: Figure out what this does exactly +; Checks if the position is out of bounds ; -sub_BANK3_BC2E: +; Duplicate of subroutine in bank 0 +; +; Input +; byte_RAM_1 = y-position hi +; byte_RAM_E6 = y-position lo +; byte_RAM_2 = x-position hi +; byte_RAM_E5 = x-position lo +; +; Output +; byte_RAM_E8 = out-of-bounds page number +; C = whether the position is out of bounds +; +CheckOutOfBounds: LDY byte_RAM_1 LDA byte_RAM_E6 - JSR sub_BANK3_BD6B - + JSR AbsoluteToPageRelativeY STY byte_RAM_1 STA byte_RAM_E6 + LDY IsHorizontalLevel LDA byte_RAM_1, Y STA byte_RAM_E8 + LDA byte_RAM_2 - CMP byte_BANK3_BC4D + 1, Y - BCS locret_BANK3_BC4C + CMP OutOfBoundsPageX, Y + BCS CheckOutOfBounds_Exit LDA byte_RAM_1 - CMP byte_BANK3_BC4D, Y + CMP OutOfBoundsPageY, Y -locret_BANK3_BC4C: +CheckOutOfBounds_Exit: RTS -byte_BANK3_BC4D: +OutOfBoundsPageY: .db $0A +OutOfBoundsPageX: .db $01 .db $0B @@ -11952,7 +11966,7 @@ ReplaceTile_StoreXHi: LDA ObjectYHi, X ADC #$00 STA byte_RAM_1 - JSR sub_BANK3_BC2E + JSR CheckOutOfBounds PLA BCS locret_BANK3_BC1E @@ -12159,12 +12173,25 @@ SnapPlayerToTile_Exit_Bank3: RTS -; =============== S U B R O U T I N E ======================================= - -sub_BANK3_BD6B: +; +; Converts absolute vertical position to page-relative vertical position +; +; Duplicate of subroutine in bank 0 +; +; Since pages are $F0 pixels tall, this effectively adds $10 per page +; +; Input +; Y = y-position hi +; A = y-position lo +; +; Output +; Y = page +; A = y-position lo (on page) +; +AbsoluteToPageRelativeY: STA byte_RAM_F TYA - BMI locret_BANK3_BD81 + BMI AbsoluteToPageRelativeY_Exit ASL A ASL A @@ -12172,21 +12199,19 @@ sub_BANK3_BD6B: ASL A CLC ADC byte_RAM_F - BCS loc_BANK3_BD7D + BCS AbsoluteToPageRelativeY_Overflow CMP #$F0 - BCC locret_BANK3_BD81 + BCC AbsoluteToPageRelativeY_Exit -loc_BANK3_BD7D: +AbsoluteToPageRelativeY_Overflow: CLC ADC #$10 INY -locret_BANK3_BD81: +AbsoluteToPageRelativeY_Exit: RTS -; End of function sub_BANK3_BD6B - ; ; Checks collision in one dimension (wrapping) From 4568c7b4759d64510f3afeb2f4b331e2920ed101 Mon Sep 17 00:00:00 2001 From: Keith McKnight Date: Sat, 25 Feb 2023 18:35:31 -0500 Subject: [PATCH 04/17] hawkmouth boss --- src/prg-2-3.asm | 45 +++++++++++++++++++++++---------------------- src/prg-4-5.asm | 19 +++++++++---------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/prg-2-3.asm b/src/prg-2-3.asm index 11896b3..440e8be 100644 --- a/src/prg-2-3.asm +++ b/src/prg-2-3.asm @@ -8816,32 +8816,31 @@ RenderSprite_Rocket: JMP loc_BANK2_9C53 -; --------------------------------------------------------------------------- -byte_BANK3_AC25: +FryGuyOffsetX_A: .db $F0 - -byte_BANK3_AC26: +FryGuyOffsetX_B: .db $00 .db $F0 -; =============== S U B R O U T I N E ======================================= - RenderSprite_Fryguy: LDA #$00 STA byte_RAM_EE + LDA ObjectAnimationTimer, X AND #$08 LSR A LSR A LSR A STA byte_RAM_7 + LDY byte_RAM_7 LDA SpriteTempScreenX PHA CLC - ADC byte_BANK3_AC25, Y + ADC FryGuyOffsetX_A, Y STA SpriteTempScreenX + LDA #$80 LDY ObjectFlashTimer, X BEQ loc_BANK3_AC4B @@ -8857,7 +8856,7 @@ loc_BANK3_AC4B: PLA CLC LDY byte_RAM_7 - ADC byte_BANK3_AC26, Y + ADC FryGuyOffsetX_B, Y STA SpriteTempScreenX LDA #$84 LDY ObjectFlashTimer, X @@ -9566,20 +9565,23 @@ EnemyInit_HawkmouthBoss: STA EnemyHP, X RTS -; --------------------------------------------------------------------------- -byte_BANK3_AFEC: + +HawkmouthBoss_AccelerationX: .db $01 .db $FF -byte_BANK3_AFEE: + +HawkmouthBoss_MaxVelocityX: .db $28 .db $D8 -byte_BANK3_AFF0: + +HawkmouthBoss_AccelerationY: .db $01 .db $FF -byte_BANK3_AFF2: + +HawkmouthBoss_MaxVelocityY: .db $10 .db $F0 -; --------------------------------------------------------------------------- + EnemyBehavior_HawkmouthBoss: JSR RenderSprite_HawkmouthBoss @@ -9718,9 +9720,9 @@ loc_BANK3_B0BA: TAY LDA ObjectYVelocity, X CLC - ADC byte_BANK3_AFF0, Y + ADC HawkmouthBoss_AccelerationY, Y STA ObjectYVelocity, X - CMP byte_BANK3_AFF2, Y + CMP HawkmouthBoss_MaxVelocityY, Y BNE loc_BANK3_B0D3 INC EnemyVariable, X @@ -9729,22 +9731,21 @@ loc_BANK3_B0D3: JSR EnemyFindWhichSidePlayerIsOn LDA ObjectXVelocity, X - CMP byte_BANK3_AFEE, Y + CMP HawkmouthBoss_MaxVelocityX, Y BEQ loc_BANK3_B0E3 CLC - ADC byte_BANK3_AFEC, Y + ADC HawkmouthBoss_AccelerationX, Y STA ObjectXVelocity, X loc_BANK3_B0E3: JMP ApplyObjectPhysics -; --------------------------------------------------------------------------- -byte_BANK3_B0E6: + +HawkmouthBoss_BackOffset: .db $F8 .db $10 -; =============== S U B R O U T I N E ======================================= RenderSprite_HawkmouthBoss: LDA EnemyArray_480, X @@ -9765,7 +9766,7 @@ RenderSprite_HawkmouthBoss: LDX byte_RAM_2 LDA SpriteTempScreenX CLC - ADC byte_BANK3_B0E6 - 1, X + ADC HawkmouthBoss_BackOffset - 1, X PHA PHP DEX diff --git a/src/prg-4-5.asm b/src/prg-4-5.asm index 3508f67..a42051b 100644 --- a/src/prg-4-5.asm +++ b/src/prg-4-5.asm @@ -489,8 +489,9 @@ DMCFreqTable: .db $0F .db $0F .db $0F - .db $60 ; ??? +ProcessMusicQueue_Unused: + RTS ProcessMusicQueue_ThenReadNoteData: JMP ProcessMusicQueue_ReadNoteData @@ -683,11 +684,12 @@ ProcessMusicQueue_EndOfSegment: BEQ ProcessMusicQueue_ThenSetNextPart IFNDEF EXPAND_MUSIC - AND #Music1_Overworld | Music1_Inside | Music1_Subspace + AND #Music2_MushroomGetJingle | Music2_EndingAndCast | Music2_CrystalGetFanfare + BEQ StopMusic ELSE JSR CheckStopMusic + BCC StopMusic ENDIF - BEQ StopMusic LDA MusicResume1 BNE ProcessMusicQueue_ResumeMusicQueue1 @@ -1374,19 +1376,16 @@ IFDEF EXPAND_MUSIC ; A = MusicPlaying2 ; CheckStopMusic: - CMP #Music1_Overworld + CMP #Music2_MushroomGetJingle BEQ CheckStopMusic_Resume - CMP #Music1_Inside + CMP #Music2_EndingAndCast BEQ CheckStopMusic_Resume - CMP #Music1_Subspace + CMP #Music2_CrystalGetFanfare BEQ CheckStopMusic_Resume CheckStopMusic_Stop: - LDA #$00 - RTS - + CLC CheckStopMusic_Resume: - LDA #$01 RTS From 9bde93755554f60c14b9887fa38df2d255899a7b Mon Sep 17 00:00:00 2001 From: Keith McKnight Date: Mon, 27 Feb 2023 18:11:52 -0500 Subject: [PATCH 05/17] bonus chance --- src/prg-e-f.asm | 135 +++++++++++++++++++++++++----------------------- src/ram.asm | 9 ++++ 2 files changed, 78 insertions(+), 66 deletions(-) diff --git a/src/prg-e-f.asm b/src/prg-e-f.asm index 935339b..d3a5a0e 100644 --- a/src/prg-e-f.asm +++ b/src/prg-e-f.asm @@ -1575,18 +1575,18 @@ ENDIF LDA #Music2_SlotWarpFanfare STA MusicQueue2 + LDA SlotMachineCoins BNE loc_BANKF_E7F2 JMP NoCoinsForSlotMachine -; --------------------------------------------------------------------------- loc_BANKF_E7F2: LDA #$03 - STA ObjectXLo + 3 - STA ObjectXLo + 4 - STA ObjectXLo + 5 + STA SlotMachineReelTimer1 + STA SlotMachineReelTimer2 + STA SlotMachineReelTimer3 JSR WaitForNMI_TurnOnPPU loc_BANKF_E7FD: @@ -1655,35 +1655,41 @@ StartSlotMachine: JSR sub_BANKF_EA68 - LDA #$01 ; Set all reel timers - STA ObjectXLo - STA ObjectXLo + 1 - STA ObjectXLo + 2 - LSR A ; Set all reels to the first position - STA ObjectXLo + 6 - STA ObjectXLo + 7 - STA ObjectXLo + 8 + ; Set all reels to active + LDA #$01 + STA SlotMachineReelActive1 + STA SlotMachineReelActive2 + STA SlotMachineReelActive3 + + ; Set initial reel position + LSR A + STA SlotMachineReelValue1 + STA SlotMachineReelValue2 + STA SlotMachineReelValue3 DoSlotMachineSpinnyShit: JSR WaitForNMI ; $2C-$2E: Reel change timer ; $2F-$31: Current reel icon - LDA #SoundEffect2_Climbing ; Play "reel sound" sound effect + ; Play "reel sound" sound effect + LDA #SoundEffect2_Climbing STA SoundEffectQueue2 - JSR sub_BANKF_EAC2 - JSR sub_BANKF_EADC + JSR SlotMachine_CheckJoypad + + JSR SlotMachine_UpdateReel - JSR sub_BANKF_EAF6 + JSR SlotMachine_DrawReels JSR SlotMachineTextFlashIndex LDA BonusChanceUpdateBuffer_PUSH_A_BUTTON, Y STA ScreenUpdateIndex INC byte_RAM_6 - LDA ObjectXLo ; Reel 1 still active? - ORA ObjectXLo + 1 ; Reel 2 still active? - ORA ObjectXLo + 2 ; Reel 3 still active? + + LDA SlotMachineReelActive1 + ORA SlotMachineReelActive2 + ORA SlotMachineReelActive3 BNE DoSlotMachineSpinnyShit ; If any are still active, go back to waiting LDA #ScreenUpdateBuffer_RAM_ErasePushAButtonText @@ -1691,14 +1697,14 @@ DoSlotMachineSpinnyShit: JSR WaitForNMI LDY #$00 - LDX ObjectXLo + 6 ; Load reel 1 + LDX SlotMachineReelValue1 LDA SlotMachineReelOrder1RAM, X BNE CheckReel2Symbol ; Is this reel a cherry? INY ; Yes; add one life CheckReel2Symbol: - LDX ObjectXLo + 7 ; Load reel 2 + LDX SlotMachineReelValue2 CMP SlotMachineReelOrder2RAM, X BNE AddSlotMachineExtraLives ; Does this match the previous symbol? @@ -1708,7 +1714,7 @@ CheckReel2Symbol: INY ; They are both cherries, add another life or something CheckReel3Symbol: - LDX ObjectXLo + 8 ; Load reel 3 + LDX SlotMachineReelValue3 CMP SlotMachineReelOrder3RAM, X ; Does reel 3 match the previous two? BNE AddSlotMachineExtraLives ; No, fuck you @@ -2109,98 +2115,96 @@ WaitForNMILoop: RTS ; If yes, go back to what we were doing -; =============== S U B R O U T I N E ======================================= - -sub_BANKF_EAC2: +; +; Stops the next spinning reel when the A button is pressed +; +SlotMachine_CheckJoypad: LDA Player1JoypadPress - BPL locret_BANKF_EAD1 + BPL SlotMachine_CheckJoypad_Exit LDX #$00 - -loc_BANKF_EAC8: - LDA ObjectXLo, X - BNE loc_BANKF_EAD2 +SlotMachine_CheckJoypad_Loop: + LDA SlotMachineReelActive1, X + BNE SlotMachine_CheckJoypad_StopReel INX CPX #$03 - BCC loc_BANKF_EAC8 + BCC SlotMachine_CheckJoypad_Loop -locret_BANKF_EAD1: +SlotMachine_CheckJoypad_Exit: RTS -; --------------------------------------------------------------------------- -loc_BANKF_EAD2: +SlotMachine_CheckJoypad_StopReel: LDA #$00 - STA ObjectXLo, X + STA SlotMachineReelActive1, X LDA #SoundEffect1_CherryGet STA SoundEffectQueue1 RTS -; End of function sub_BANKF_EAC2 -; =============== S U B R O U T I N E ======================================= - -sub_BANKF_EADC: +; +; Counts down reek timers and updates the current reel value +; +SlotMachine_UpdateReel: LDX #$02 +SlotMachine_UpdateReel_Loop: + LDA SlotMachineReelActive1, X + BEQ SlotMachine_UpdateReel_Next -loc_BANKF_EADE: - LDA ObjectXLo, X - BEQ loc_BANKF_EAF2 - - DEC ObjectXLo + 3, X - BNE loc_BANKF_EAF2 + DEC SlotMachineReelTimer1, X + BNE SlotMachine_UpdateReel_Next LDA #$04 - STA ObjectXLo + 3, X - DEC ObjectXLo + 6, X - BPL loc_BANKF_EAF2 + STA SlotMachineReelTimer1, X + DEC SlotMachineReelValue1, X + BPL SlotMachine_UpdateReel_Next LDA #$07 - STA ObjectXLo + 6, X + STA SlotMachineReelValue1, X -loc_BANKF_EAF2: +SlotMachine_UpdateReel_Next: DEX - BPL loc_BANKF_EADE + BPL SlotMachine_UpdateReel_Loop RTS -; End of function sub_BANKF_EADC - -; =============== S U B R O U T I N E ======================================= -sub_BANKF_EAF6: +; +; Draws the reel sprites +; +SlotMachine_DrawReels: LDA #$02 STA byte_RAM_0 - -loc_BANKF_EAFA: +SlotMachine_DrawReels_Loop: LDA byte_RAM_0 TAY ASL A ASL A ASL A TAX - ADC ObjectXLo + 6, Y + ADC SlotMachineReelValue1, Y TAY LDA SlotMachineReelOrder1RAM, Y TAY + + ; Copy OAM data for the current value of the reel LDA #$07 STA byte_RAM_1 - -loc_BANKF_EB0D: +SlotMachine_DrawReels_DMALoop: LDA BonusChanceCherrySprite, Y STA SpriteDMAArea + $10, X INX INY DEC byte_RAM_1 - BPL loc_BANKF_EB0D + BPL SlotMachine_DrawReels_DMALoop DEC byte_RAM_0 - BPL loc_BANKF_EAFA + BPL SlotMachine_DrawReels_Loop + ; All the sprites were drawn in the first slot, so move them to the correct place LDX #$17 - -loc_BANKF_EB1F: +SlotMachine_DrawReels_PositionLoop: TXA AND #$18 ASL A @@ -2211,11 +2215,10 @@ loc_BANKF_EB1F: DEX DEX DEX - BPL loc_BANKF_EB1F + BPL SlotMachine_DrawReels_PositionLoop RTS -; End of function sub_BANKF_EAF6 IFNDEF BONUS_CHANCE_RAM_CLEANUP ; diff --git a/src/ram.asm b/src/ram.asm index 66d26b0..f22f80c 100644 --- a/src/ram.asm +++ b/src/ram.asm @@ -124,20 +124,29 @@ PlayerXLo: CastRollTimer: .dsb 1 ; $0028 ObjectXLo: +SlotMachineReelActive1: CastRollSequenceIndex: .dsb 1 ; $0029 +SlotMachineReelActive2: CastRollFadePaletteIndex: .dsb 1 ; 1 ; $002a +SlotMachineReelActive3: CastRollSpriteIndex: .dsb 1 ; 2 ; $002b +SlotMachineReelTimer1: .dsb 1 ; 3 ; $002c +SlotMachineReelTimer2: .dsb 1 ; 4 ; $002d +SlotMachineReelTimer3: CastRollThrottle: .dsb 1 ; 5 ; $002e +SlotMachineReelValue1: CastRollSpriteLo: .dsb 1 ; 6 ; $002f +SlotMachineReelValue2: CastRollSpriteHi: .dsb 1 ; 7 ; $0030 +SlotMachineReelValue3: .dsb 1 ; 8 ; $0031 PlayerYLo: From 6e9f1cedb577c88912fb715d8238e44c546a3e08 Mon Sep 17 00:00:00 2001 From: Keith McKnight Date: Mon, 27 Feb 2023 18:35:30 -0500 Subject: [PATCH 06/17] character select --- src/prg-e-f.asm | 74 +++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 39 deletions(-) diff --git a/src/prg-e-f.asm b/src/prg-e-f.asm index d3a5a0e..f895242 100644 --- a/src/prg-e-f.asm +++ b/src/prg-e-f.asm @@ -640,9 +640,12 @@ DoCharacterSelectMenu: JSR ResetScreenForTitleCard + ; This effectively does a redundant bank switch to A/B the first time we + ; access the character select. There doesn't seem to be a clear reason why + ; this would be necessary, so it's confusing! LDA CharacterSelectBankSwitch CMP #$A5 - BEQ loc_BANKF_E2B2 + BEQ DoCharacterSelectMenu_AfterBankSwitch LDA #PRGBank_A_B JSR ChangeMappedPRGBank @@ -650,7 +653,7 @@ DoCharacterSelectMenu: LDA #$A5 STA CharacterSelectBankSwitch -loc_BANKF_E2B2: +DoCharacterSelectMenu_AfterBankSwitch: JSR EnableNMI_PauseTitleCard JSR DisableNMI @@ -663,11 +666,11 @@ loc_BANKF_E2B2: STA PreviousWorld LDY #$3F -loc_BANKF_E2CA: +CharacterSelect_CopySpritesLoop: LDA PlayerSelectMarioSprites1, Y STA SpriteDMAArea + $10, Y DEY - BPL loc_BANKF_E2CA + BPL CharacterSelect_CopySpritesLoop JSR EnableNMI @@ -679,43 +682,41 @@ loc_BANKF_E2CA: JSR WaitForNMI - JMP loc_BANKF_E311 + JMP CharacterSelect_DrawArrow -; --------------------------------------------------------------------------- -loc_BANKF_E2E8: +CharacterSelect_CheckChangeCharacter: LDA Player1JoypadPress AND #ControllerInput_Right | ControllerInput_Left - BNE CharacterSelect_ChangeCharacter + BNE CharacterSelect_CheckChangeCharacterRight JMP CharacterSelectMenuLoop -; --------------------------------------------------------------------------- -CharacterSelect_ChangeCharacter: +CharacterSelect_CheckChangeCharacterRight: LDA Player1JoypadPress AND #ControllerInput_Right - BEQ loc_BANKF_E2FE + BEQ CharacterSelect_CheckChangeCharacterLeft DEC CurrentCharacter LDA #SoundEffect1_CherryGet STA SoundEffectQueue1 -loc_BANKF_E2FE: +CharacterSelect_CheckChangeCharacterLeft: LDA Player1JoypadPress AND #ControllerInput_Left - BEQ loc_BANKF_E30B + BEQ CharacterSelect_SetCurrentCharacter INC CurrentCharacter LDA #SoundEffect1_CherryGet STA SoundEffectQueue1 -loc_BANKF_E30B: +CharacterSelect_SetCurrentCharacter: LDA CurrentCharacter AND #$03 STA CurrentCharacter -loc_BANKF_E311: +CharacterSelect_DrawArrow: LDY #$00 LDA #$21 STA PPUBuffer_301 @@ -760,27 +761,25 @@ loc_BANKF_E311: LDX #$12 LDY #$00 - -loc_BANKF_E37D: +CharacterSelect_DarkSpritesPaletteLoop: LDA PlayerSelectSpritePalettesDark, Y STA PPUBuffer_301, Y INY DEX - BPL loc_BANKF_E37D + BPL CharacterSelect_DarkSpritesPaletteLoop LDA #$06 STA byte_RAM_A LDX CurrentCharacter LDA PlayerSelectPaletteOffsets, X TAX - -loc_BANKF_E391: +CharacterSelect_SelectedSpritePaletteLoop: LDA PlayerSelectSpritePalettes, X STA PPUBuffer_301, Y INY INX DEC byte_RAM_A - BPL loc_BANKF_E391 + BPL CharacterSelect_SelectedSpritePaletteLoop LDA #$00 STA PPUBuffer_301, Y @@ -790,13 +789,12 @@ CharacterSelectMenuLoop: LDA Player1JoypadPress AND #ControllerInput_A - BNE loc_BANKF_E3AE + BNE ConfirmCharacterSelection - JMP loc_BANKF_E2E8 + JMP CharacterSelect_CheckChangeCharacter -; --------------------------------------------------------------------------- -loc_BANKF_E3AE: +ConfirmCharacterSelection: LDA #SoundEffect1_CherryGet STA SoundEffectQueue1 LDX CurrentWorld @@ -807,41 +805,38 @@ loc_BANKF_E3AE: STA byte_RAM_10 JSR WaitForNMI - LDX #$F + LDX #$0F LDA CurrentCharacter TAY LDA PlayerSelectSpriteIndexes, Y TAY - -loc_BANKF_E3CC: +ConfirmCharacterSelection_ArmUpLoop: LDA PlayerSelectMarioSprites2, Y STA SpriteDMAArea + $10, Y INY DEX - BPL loc_BANKF_E3CC + BPL ConfirmCharacterSelection_ArmUpLoop -loc_BANKF_E3D6: +ConfirmCharacterSelection_ArmUpPauseLoop: JSR WaitForNMI DEC byte_RAM_10 - BPL loc_BANKF_E3D6 + BPL ConfirmCharacterSelection_ArmUpPauseLoop LDY #$3F - -loc_BANKF_E3DF: +ConfirmCharacterSelection_ArmDownLoop: LDA PlayerSelectMarioSprites1, Y STA SpriteDMAArea + $10, Y DEY - BPL loc_BANKF_E3DF + BPL ConfirmCharacterSelection_ArmDownLoop LDA #$40 STA byte_RAM_10 - -loc_BANKF_E3EC: +ConfirmCharacterSelection_ArmDownPauseLoop: JSR WaitForNMI DEC byte_RAM_10 - BPL loc_BANKF_E3EC + BPL ConfirmCharacterSelection_ArmDownPauseLoop LDA #Music2_StopMusic STA MusicQueue2 @@ -1201,7 +1196,8 @@ InitializeJar: STA MusicQueue1 LDA #$01 STA CurrentMusicIndex - JMP loc_BANKF_E5E1 + + JMP SubArea_SetBoundaries InitializeSubspace: @@ -1212,7 +1208,7 @@ InitializeSubspace: LDA #$04 STA CurrentMusicIndex -loc_BANKF_E5E1: +SubArea_SetBoundaries: LDA #PRGBank_0_1 JSR ChangeMappedPRGBank From 715760b0f1c7b9e568c32bd54e2b683ddd541136 Mon Sep 17 00:00:00 2001 From: Keith McKnight Date: Mon, 27 Feb 2023 18:37:22 -0500 Subject: [PATCH 07/17] number formatting --- src/prg-0-1.asm | 8 ++++---- src/prg-a-b.asm | 8 ++++---- src/ram.asm | 16 ++++++++-------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/prg-0-1.asm b/src/prg-0-1.asm index 6948e64..0682348 100644 --- a/src/prg-0-1.asm +++ b/src/prg-0-1.asm @@ -1844,7 +1844,7 @@ CopyAttributesToHorizontalBuffer_Loop: INY DEC byte_RAM_E LDA byte_RAM_E - CMP #03 + CMP #$03 BNE CopyAttributesToHorizontalBuffer_Loop RTS @@ -1856,7 +1856,7 @@ CopyAttributesToHorizontalBuffer_Loop: ; sub_BANK0_8925: STY byte_RAM_F - LDA #01 + LDA #$01 STA byte_RAM_4 LDY ReadLevelDataOffset LDX PPUAttributeUpdateCounter @@ -1997,7 +1997,7 @@ HandlePlayerState_Dying: BNE locret_BANK0_8A86 LDA PlayerScreenYHi - CMP #02 + CMP #$02 BEQ LoseALife JSR ApplyPlayerPhysicsY @@ -2016,7 +2016,7 @@ loc_BANK0_8A72: ; --------------------------------------------------------------------------- LoseALife: - LDA #02 + LDA #$02 STA PlayerAnimationFrame LDY #$01 ; Set game mode to title card DEC ExtraLives diff --git a/src/prg-a-b.asm b/src/prg-a-b.asm index 2879b62..57a0579 100644 --- a/src/prg-a-b.asm +++ b/src/prg-a-b.asm @@ -183,7 +183,7 @@ loc_BANKA_8347: ADC #$20 STA byte_RAM_1 LDA byte_RAM_0 - ADC #0 + ADC #$00 STA byte_RAM_0 JMP loc_BANKA_8338 @@ -226,10 +226,10 @@ loc_BANKA_8392: STA byte_RAM_0 LDA #$C8 STA byte_RAM_1 - LDY #0 + LDY #$00 loc_BANKA_839C: - LDX #$F + LDX #$0F LDA PPUSTATUS LDA byte_RAM_0 STA PPUADDR @@ -250,7 +250,7 @@ loc_BANKA_83AB: ADC #$20 STA byte_RAM_1 LDA byte_RAM_0 - ADC #0 + ADC #$00 STA byte_RAM_0 JMP loc_BANKA_839C diff --git a/src/ram.asm b/src/ram.asm index f22f80c..377d5f6 100644 --- a/src/ram.asm +++ b/src/ram.asm @@ -1620,14 +1620,14 @@ ENDIF CurrentMusicDPCMOffset: .dsb 1 ; $05ff -; #01 Overworld -; #02 Character Select -; #04 Inside -; #08 Boss -; #10 Invincible -; #20 Subspace -; #40 Wart -; #80 Title +; $01 Overworld +; $02 Character Select +; $04 Inside +; $08 Boss +; $10 Invincible +; $20 Subspace +; $40 Wart +; $80 Title MusicQueue1: .dsb 1 ; $0600 From c9bbbd248a0ddc43bce2e86c6878bf2459dfe70b Mon Sep 17 00:00:00 2001 From: Keith McKnight Date: Sun, 19 Mar 2023 22:10:41 -0400 Subject: [PATCH 08/17] lil tweaks --- src/prg-0-1.asm | 2 + src/prg-2-3.asm | 144 ++++++++++++++++++++++++------------------------ 2 files changed, 74 insertions(+), 72 deletions(-) diff --git a/src/prg-0-1.asm b/src/prg-0-1.asm index 0682348..4410cc9 100644 --- a/src/prg-0-1.asm +++ b/src/prg-0-1.asm @@ -2196,6 +2196,7 @@ ClimbableTiles: .db BackgroundTile_LadderStandable .db BackgroundTile_LadderStandableShadow .db BackgroundTile_ChainStandable +ClimbableTiles_End: ; @@ -3917,6 +3918,7 @@ DoorTiles: .db BackgroundTile_DarkDoor .db BackgroundTile_LightDoor .db BackgroundTile_LightDoorEndLevel +DoorTiles_End: ; diff --git a/src/prg-2-3.asm b/src/prg-2-3.asm index 440e8be..692d979 100644 --- a/src/prg-2-3.asm +++ b/src/prg-2-3.asm @@ -797,77 +797,77 @@ InitializeEnemy: JSR JumpToTableAfterJump EnemyInitializationTable: - .dw EnemyInit_Basic ; Heart - .dw EnemyInit_Basic ; ShyguyRed - .dw EnemyInit_Basic ; Tweeter - .dw EnemyInit_Basic ; ShyguyPink - .dw EnemyInit_Basic ; Porcupo - .dw EnemyInit_Basic ; SnifitRed - .dw EnemyInit_Stationary ; SnifitGray - .dw EnemyInit_Basic ; SnifitPink - .dw EnemyInit_Basic ; Ostro - .dw EnemyInit_Bobomb ; BobOmb - .dw EnemyInit_Basic ; AlbatossCarryingBobOmb - .dw EnemyInit_AlbatossStartRight ; AlbatossStartRight - .dw EnemyInit_AlbatossStartLeft ; AlbatossStartLeft - .dw EnemyInit_Basic ; NinjiRunning - .dw EnemyInit_Stationary ; NinjiJumping - .dw EnemyInit_BeezoDiving ; BeezoDiving - .dw EnemyInit_Basic ; BeezoStraight - .dw EnemyInit_Basic ; WartBubble - .dw EnemyInit_Basic ; Pidgit - .dw EnemyInit_Trouter ; Trouter - .dw EnemyInit_Basic ; Hoopstar - .dw EnemyInit_JarGenerators ; JarGeneratorShyguy - .dw EnemyInit_JarGenerators ; JarGeneratorBobOmb - .dw EnemyInit_Phanto ; Phanto - .dw EnemyInit_Cobrats ; CobratJar - .dw EnemyInit_Cobrats ; CobratSand - .dw EnemyInit_Pokey ; Pokey - .dw EnemyInit_Basic ; Bullet - .dw EnemyInit_Birdo ; Birdo - .dw EnemyInit_Mouser ; Mouser - .dw EnemyInit_Basic ; Egg - .dw EnemyInit_Tryclyde ; Tryclyde - .dw EnemyInit_Basic ; Fireball - .dw EnemyInit_Clawgrip ; Clawgrip - .dw EnemyInit_Basic ; ClawgripRock - .dw EnemyInit_Stationary ; PanserStationaryFiresAngled - .dw EnemyInit_Basic ; PanserWalking - .dw EnemyInit_Stationary ; PanserStationaryFiresUp - .dw EnemyInit_Basic ; Autobomb - .dw EnemyInit_Basic ; AutobombFire - .dw EnemyInit_WhaleSpout ; WhaleSpout - .dw EnemyInit_Basic ; Flurry - .dw EnemyInit_Fryguy ; Fryguy - .dw EnemyInit_Fryguy ; FryguySplit - .dw EnemyInit_Wart ; Wart - .dw EnemyInit_HawkmouthBoss ; HawkmouthBoss - .dw EnemyInit_Sparks ; Spark1 - .dw EnemyInit_Sparks ; Spark2 - .dw EnemyInit_Sparks ; Spark3 - .dw EnemyInit_Sparks ; Spark4 - .dw EnemyInit_Basic ; VegetableSmall - .dw EnemyInit_Basic ; VegetableLarge - .dw EnemyInit_Basic ; VegetableWart - .dw EnemyInit_Basic ; Shell - .dw EnemyInit_Basic ; Coin - .dw EnemyInit_Basic ; Bomb - .dw EnemyInit_Basic ; Rocket - .dw EnemyInit_Basic ; MushroomBlock - .dw EnemyInit_Basic ; POWBlock - .dw EnemyInit_FallingLogs ; FallingLogs - .dw EnemyInit_Basic ; SubspaceDoor - .dw EnemyInit_Key ; Key - .dw EnemyInit_Basic ; SubspacePotion - .dw EnemyInit_Stationary ; Mushroom - .dw EnemyInit_Stationary ; Mushroom1up - .dw EnemyInit_Basic ; FlyingCarpet - .dw EnemyInit_Hawkmouth ; HawkmouthRight - .dw EnemyInit_Hawkmouth ; HawkmouthLeft - .dw EnemyInit_CrystalBallStarmanStopwatch ; CrystalBall - .dw EnemyInit_CrystalBallStarmanStopwatch ; Starman - .dw EnemyInit_CrystalBallStarmanStopwatch ; Stopwatch + .dw EnemyInit_Basic ; $00 Enemy_Heart + .dw EnemyInit_Basic ; $01 Enemy_ShyguyRed + .dw EnemyInit_Basic ; $02 Enemy_Tweeter + .dw EnemyInit_Basic ; $03 Enemy_ShyguyPink + .dw EnemyInit_Basic ; $04 Enemy_Porcupo + .dw EnemyInit_Basic ; $05 Enemy_SnifitRed + .dw EnemyInit_Stationary ; $06 Enemy_SnifitGray + .dw EnemyInit_Basic ; $07 Enemy_SnifitPink + .dw EnemyInit_Basic ; $08 Enemy_Ostro + .dw EnemyInit_Bobomb ; $09 Enemy_BobOmb + .dw EnemyInit_Basic ; $0A Enemy_AlbatossCarryingBobOmb + .dw EnemyInit_AlbatossStartRight ; $0B Enemy_AlbatossStartRight + .dw EnemyInit_AlbatossStartLeft ; $0C Enemy_AlbatossStartLeft + .dw EnemyInit_Basic ; $0D Enemy_NinjiRunning + .dw EnemyInit_Stationary ; $0E Enemy_NinjiJumping + .dw EnemyInit_BeezoDiving ; $0F Enemy_BeezoDiving + .dw EnemyInit_Basic ; $10 Enemy_BeezoStraight + .dw EnemyInit_Basic ; $11 Enemy_WartBubble + .dw EnemyInit_Basic ; $12 Enemy_Pidgit + .dw EnemyInit_Trouter ; $13 Enemy_Trouter + .dw EnemyInit_Basic ; $14 Enemy_Hoopstar + .dw EnemyInit_JarGenerators ; $15 Enemy_JarGeneratorShyguy + .dw EnemyInit_JarGenerators ; $16 Enemy_JarGeneratorBobOmb + .dw EnemyInit_Phanto ; $17 Enemy_Phanto + .dw EnemyInit_Cobrats ; $18 Enemy_CobratJar + .dw EnemyInit_Cobrats ; $19 Enemy_CobratSand + .dw EnemyInit_Pokey ; $1A Enemy_Pokey + .dw EnemyInit_Basic ; $1B Enemy_Bullet + .dw EnemyInit_Birdo ; $1C Enemy_Birdo + .dw EnemyInit_Mouser ; $1D Enemy_Mouser + .dw EnemyInit_Basic ; $1E Enemy_Egg + .dw EnemyInit_Tryclyde ; $1F Enemy_Tryclyde + .dw EnemyInit_Basic ; $20 Enemy_Fireball + .dw EnemyInit_Clawgrip ; $21 Enemy_Clawgrip + .dw EnemyInit_Basic ; $22 Enemy_ClawgripRock + .dw EnemyInit_Stationary ; $23 Enemy_PanserStationaryFiresAngled + .dw EnemyInit_Basic ; $24 Enemy_PanserWalking + .dw EnemyInit_Stationary ; $25 Enemy_PanserStationaryFiresUp + .dw EnemyInit_Basic ; $26 Enemy_Autobomb + .dw EnemyInit_Basic ; $27 Enemy_AutobombFire + .dw EnemyInit_WhaleSpout ; $28 Enemy_WhaleSpout + .dw EnemyInit_Basic ; $29 Enemy_Flurry + .dw EnemyInit_Fryguy ; $2A Enemy_Fryguy + .dw EnemyInit_Fryguy ; $2B Enemy_FryguySplit + .dw EnemyInit_Wart ; $2C Enemy_Wart + .dw EnemyInit_HawkmouthBoss ; $2D Enemy_HawkmouthBoss + .dw EnemyInit_Sparks ; $2E Enemy_Spark1 + .dw EnemyInit_Sparks ; $2F Enemy_Spark2 + .dw EnemyInit_Sparks ; $30 Enemy_Spark3 + .dw EnemyInit_Sparks ; $31 Enemy_Spark4 + .dw EnemyInit_Basic ; $32 Enemy_VegetableSmall + .dw EnemyInit_Basic ; $33 Enemy_VegetableLarge + .dw EnemyInit_Basic ; $34 Enemy_VegetableWart + .dw EnemyInit_Basic ; $35 Enemy_Shell + .dw EnemyInit_Basic ; $36 Enemy_Coin + .dw EnemyInit_Basic ; $37 Enemy_Bomb + .dw EnemyInit_Basic ; $38 Enemy_Rocket + .dw EnemyInit_Basic ; $39 Enemy_MushroomBlock + .dw EnemyInit_Basic ; $3A Enemy_POWBlock + .dw EnemyInit_FallingLogs ; $3B Enemy_FallingLogs + .dw EnemyInit_Basic ; $3C Enemy_SubspaceDoor + .dw EnemyInit_Key ; $3D Enemy_Key + .dw EnemyInit_Basic ; $3E Enemy_SubspacePotion + .dw EnemyInit_Stationary ; $3F Enemy_Mushroom + .dw EnemyInit_Stationary ; $40 Enemy_Mushroom1up + .dw EnemyInit_Basic ; $41 Enemy_FlyingCarpet + .dw EnemyInit_Hawkmouth ; $42 Enemy_HawkmouthRight + .dw EnemyInit_Hawkmouth ; $43 Enemy_HawkmouthLeft + .dw EnemyInit_CrystalBallStarmanStopwatch ; $44 Enemy_CrystalBall + .dw EnemyInit_CrystalBallStarmanStopwatch ; $45 Enemy_Starman + .dw EnemyInit_CrystalBallStarmanStopwatch ; $46 Enemy_Stopwatch EnemyInitializationTable_End: @@ -6543,7 +6543,7 @@ unusedSpace $A030, $FF EnemyTilemap2: -; Pidgit + ; Pidgit .db $2D, $2F ; $00 .db $2D, $2F ; $02 ; Flying carpet From 47d7b9cd7b98785707a6f7f79e8fe132667ec95d Mon Sep 17 00:00:00 2001 From: Keith McKnight Date: Sun, 28 Dec 2025 12:08:04 -0500 Subject: [PATCH 09/17] title screen annotations --- src/prg-0-1.asm | 130 ++++++++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 60 deletions(-) diff --git a/src/prg-0-1.asm b/src/prg-0-1.asm index 4410cc9..841015a 100644 --- a/src/prg-0-1.asm +++ b/src/prg-0-1.asm @@ -5171,7 +5171,7 @@ TitleStoryTextPointersHi: .db >TitleStoryText_Line06 .db >TitleStoryText_Line07 .db >TitleStoryText_Line08 - .db >TitleStoryText_Line08 ; For some reason line 8 is referenced twice here, but not used + .db >TitleStoryText_Line08 ; Dummy reference, this index used for clearing screen .db >TitleStoryText_Line09 .db >TitleStoryText_Line10 .db >TitleStoryText_Line11 @@ -5190,7 +5190,7 @@ TitleStoryTextPointersLo: .db Date: Sun, 28 Dec 2025 16:37:03 -0500 Subject: [PATCH 10/17] more descriptive labels for banks e-f --- src/defs.asm | 7 +- src/prg-0-1.asm | 30 ++--- src/prg-2-3.asm | 4 +- src/prg-e-f.asm | 330 +++++++++++++++++++++++++----------------------- src/ram.asm | 6 + 5 files changed, 201 insertions(+), 176 deletions(-) diff --git a/src/defs.asm b/src/defs.asm index b6316f5..6457468 100644 --- a/src/defs.asm +++ b/src/defs.asm @@ -43,6 +43,10 @@ TransitionType_Rocket = $05 ; --------------------------------------------------------------------------- +CrouchJumpTimerMax = $3C + +; --------------------------------------------------------------------------- + ; enum Characters Character_Mario = $00 Character_Princess = $01 @@ -258,7 +262,8 @@ SpriteAnimation_WalkingCarrying = $01 SpriteAnimation_Standing = $02 SpriteAnimation_StandingCarrying = $03 SpriteAnimation_Ducking = $04 -SpriteAnimation_5 = $05 +SpriteAnimation_DuckingCarrying = $05 +SpriteAnimation_5 = $05 ; Ducking while carrying...? SpriteAnimation_Jumping = $06 SpriteAnimation_Dead = $07 SpriteAnimation_Pulling = $08 diff --git a/src/prg-0-1.asm b/src/prg-0-1.asm index 841015a..2350696 100644 --- a/src/prg-0-1.asm +++ b/src/prg-0-1.asm @@ -2016,7 +2016,7 @@ loc_BANK0_8A72: ; --------------------------------------------------------------------------- LoseALife: - LDA #$02 + LDA #SpriteAnimation_Standing STA PlayerAnimationFrame LDY #$01 ; Set game mode to title card DEC ExtraLives @@ -2095,14 +2095,14 @@ PlayerLiftTimer: .db $01 PlayerLiftFrames: - .db $01 - .db $02 - .db $04 - .db $04 - .db $04 - .db $04 - .db $08 - .db $08 + .db SpriteAnimation_WalkingCarrying + .db SpriteAnimation_Standing + .db SpriteAnimation_Ducking + .db SpriteAnimation_Ducking + .db SpriteAnimation_Ducking + .db SpriteAnimation_Ducking + .db SpriteAnimation_Pulling + .db SpriteAnimation_Pulling PlayerClimbHorizontalSpeed: .db $00 @@ -2411,7 +2411,7 @@ HandlePlayerState_ChangingSize_Next: loc_BANK0_8C0D: LDY PlayerAnimationFrame - CPY #$0A + CPY #SpriteAnimation_Climbing BNE loc_BANK0_8C15 LDA #PlayerState_Climbing @@ -2481,7 +2481,7 @@ ENDIF BNE ResetPartialCrouchJumpTimer LDA CrouchJumpTimer ; check if crouch jump is charged - CMP #$3C + CMP #CrouchJumpTimerMax BCS loc_BANK0_8C92 INC CrouchJumpTimer ; increment crouch jump charge @@ -2489,7 +2489,7 @@ ENDIF ResetPartialCrouchJumpTimer: ; reset crouch jump timer if it isn't full LDA CrouchJumpTimer - CMP #$3C ; max crouch jump timer + CMP #CrouchJumpTimerMax ; max crouch jump timer BCS loc_BANK0_8C6F LDA #$00 ; reset crouch jump timer to zero @@ -2571,7 +2571,7 @@ PlayerStartJump_CheckXSpeed: ; Check crouch jump timer LDY CrouchJumpTimer - CPY #$3C + CPY #CrouchJumpTimerMax BCC PlayerStartJump_SetYVelocity ; Clear Player1JoypadHeld for a crouch jump @@ -5991,8 +5991,8 @@ FreeSubconsScene: STA FreeSubconsTimer LDA #$01 STA PlayerDirection - LSR A - STA PlayerState ; A=$00 + LSR A ; A = $00 + STA PlayerState STA FreeSubconsCorkCounter STA CrouchJumpTimer STA byte_RAM_E6 diff --git a/src/prg-2-3.asm b/src/prg-2-3.asm index 692d979..5c642de 100644 --- a/src/prg-2-3.asm +++ b/src/prg-2-3.asm @@ -11215,7 +11215,7 @@ loc_BANK3_B922: ; Force the player into a ducking position LDA #$01 STA PlayerDucking - LDA #$04 + LDA #SpriteAnimation_Ducking STA PlayerAnimationFrame LDA #$10 STA PlayerStateTimer @@ -11882,7 +11882,7 @@ SetPlayerStateLifting: STA PlayerState LDA #$06 STA PlayerStateTimer - LDA #$08 + LDA #SpriteAnimation_Pulling STA PlayerAnimationFrame INC HoldingItem RTS diff --git a/src/prg-e-f.asm b/src/prg-e-f.asm index f895242..38a8963 100644 --- a/src/prg-e-f.asm +++ b/src/prg-e-f.asm @@ -1226,41 +1226,41 @@ SubArea_Loop: LDA InSubspaceOrJar CMP #$02 - BEQ loc_BANKF_E606 + BEQ SubArea_TurnOnPPU LDA #PRGBank_6_7 JSR ChangeMappedPRGBank JSR LoadCurrentPalette -loc_BANKF_E606: +SubArea_TurnOnPPU: JSR WaitForNMI_TurnOnPPU -; subspace -loc_BANKF_E609: +Subspace_MainLoop: JSR WaitForNMI JSR HideAllSprites - JSR sub_BANKF_F0F9 + JSR RunFrame_Subspace LDY GameMode - BEQ loc_BANKF_E61A + BEQ Subspace_CheckStillInSubspace JMP ResetAreaAndProcessGameMode ; --------------------------------------------------------------------------- -loc_BANKF_E61A: +Subspace_CheckStillInSubspace: LDA InSubspaceOrJar - BNE loc_BANKF_E609 + BNE Subspace_MainLoop + ; Subspace visit only "counts" if coins were collected LDA SubspaceCoins - BEQ loc_BANKF_E627 + BEQ Subspace_ExitToMainArea INC SubspaceVisits -loc_BANKF_E627: +Subspace_ExitToMainArea: LDA CurrentLevelAreaCopy STA CurrentLevelArea LDA #PRGBank_6_7 @@ -1272,15 +1272,18 @@ loc_BANKF_E627: JSR HideAllSprites + ; Restore the music index LDY CompareMusicIndex STY CurrentMusicIndex + + ; If leaving subspace while still invincible, don't reset the music LDA StarInvincibilityTimer - BNE loc_BANKF_E64C + BNE Subspace_Exit_AfterMusicRestore LDA LevelMusicIndexes, Y STA MusicQueue1 -loc_BANKF_E64C: +Subspace_Exit_AfterMusicRestore: LDA #PRGBank_0_1 JSR ChangeMappedPRGBank @@ -1378,21 +1381,22 @@ DoGameOverStuff: LDA #ScreenUpdateBuffer_Text_Game_Over STA ScreenUpdateIndex + + ; Delay before showing "CONTINUE" text LDA #$C0 STA byte_RAM_6 - -loc_BANKF_E6E6: +GameOver_DelayLoop: JSR WaitForNMI DEC byte_RAM_6 - BNE loc_BANKF_E6E6 + BNE GameOver_DelayLoop LDY #(BonusChanceUpdateBuffer_BONUS_CHANCE_Unused - PPUBuffer_Text_Continue - 1) -loc_BANKF_E6EF: +GameOver_DrawContinueText: LDA PPUBuffer_Text_Continue, Y STA PPUBuffer_ContinueRetryText, Y DEY - BPL loc_BANKF_E6EF + BPL GameOver_DrawContinueText ; Hide the bullet for RETRY LDA #$FB @@ -1406,33 +1410,36 @@ loc_BANKF_E6EF: STA byte_RAM_8 LDA #ScreenUpdateBuffer_RAM_ContinueRetryText DEC Continues - BPL loc_BANKF_E717 + BPL GameOver_SetScreenUpdateIndex + ; No continues left, default to RETRY LDA #$01 STA byte_RAM_8 LDA #ScreenUpdateBuffer_Text_Retry -loc_BANKF_E717: +GameOver_SetScreenUpdateIndex: STA ScreenUpdateIndex -loc_BANKF_E719: +GameOver_InputLoop: JSR WaitForNMI LDA Player1JoypadPress AND #ControllerInput_Select - BEQ loc_BANKF_E747 + BEQ GameOver_CheckStartButton LDA byte_RAM_8 EOR #$01 STA byte_RAM_8 + LDY Continues CPY #$FF - BNE loc_BANKF_E733 + BNE GameOver_UpdateBulletSprites + ; No continues left, force back to RETRY LDA #$01 STA byte_RAM_8 -loc_BANKF_E733: +GameOver_UpdateBulletSprites: ASL A ASL A TAY @@ -1444,10 +1451,10 @@ loc_BANKF_E733: LDA #ScreenUpdateBuffer_RAM_ContinueRetryBullets STA ScreenUpdateIndex -loc_BANKF_E747: +GameOver_CheckStartButton: LDA Player1JoypadPress AND #ControllerInput_Start - BEQ loc_BANKF_E719 + BEQ GameOver_InputLoop LDA byte_RAM_8 BNE GameOver_Retry @@ -1455,7 +1462,6 @@ loc_BANKF_E747: STA SlotMachineCoins JMP ContinueGame -; --------------------------------------------------------------------------- GameOver_Retry: JMP StartGame @@ -1497,7 +1503,7 @@ DoWorldWarp: STA ScreenUpdateIndex LDA #Music2_SlotWarpFanfare STA MusicQueue2 - JSR Delay160Frames + JSR SlotMachine_Delay160Frames JSR InitializeSomeLevelStuff @@ -1567,25 +1573,25 @@ ENDIF STA StackArea JSR DisableNMI - JSR sub_BANKF_EA33 + JSR SetupBonusChancePalette LDA #Music2_SlotWarpFanfare STA MusicQueue2 LDA SlotMachineCoins - BNE loc_BANKF_E7F2 + BNE SlotMachine_InitializeReels JMP NoCoinsForSlotMachine -loc_BANKF_E7F2: +SlotMachine_InitializeReels: LDA #$03 STA SlotMachineReelTimer1 STA SlotMachineReelTimer2 STA SlotMachineReelTimer3 JSR WaitForNMI_TurnOnPPU -loc_BANKF_E7FD: +SlotMachine_CheckCoinsLoop: LDA SlotMachineCoins BNE StartSlotMachine @@ -1649,7 +1655,7 @@ StartSlotMachine: DEC SlotMachineCoins JSR WaitForNMI - JSR sub_BANKF_EA68 + JSR SetupBonusChanceScreen ; Set all reels to active LDA #$01 @@ -1726,11 +1732,13 @@ AddSlotMachineExtraLives: TYA ; Y contains extra lives to add CLC ADC ExtraLives ; Add won extra lives to current lives - BCC loc_BANKF_E8D3 ; Check if adding extra lives has wrapped the counter - LDA #$FF ; If so, set extra lives to 255 (#$FF) + ; We don't want to overflow ExtraLives! If that happens, stop at 255 (#$FF) + BCC AddSlotMachineExtraLives_SetExtraLives + + LDA #$FF -loc_BANKF_E8D3: +AddSlotMachineExtraLives_SetExtraLives: STA ExtraLives TYA ; Did we actually win any lives? BEQ SlotMachineLoseFanfare ; No, play lose sound effect @@ -1743,9 +1751,9 @@ loc_BANKF_E8D3: STA byte_RAM_6 JSR WaitForNMI - JSR sub_BANKF_EA68 + JSR SetupBonusChanceScreen -loc_BANKF_E8ED: +SlotMachine_WinDisplayLoop: JSR WaitForNMI JSR SlotMachineTextFlashIndex @@ -1753,25 +1761,25 @@ loc_BANKF_E8ED: LDA BonusChanceUpdateBuffer_PLAYER_1UP, Y STA ScreenUpdateIndex DEC byte_RAM_6 - BNE loc_BANKF_E8ED + BNE SlotMachine_WinDisplayLoop - BEQ loc_BANKF_E90C + BEQ SlotMachine_NextRound SlotMachineLoseFanfare: LDA #Music2_DeathJingle STA MusicQueue2 JSR WaitForNMI - JSR sub_BANKF_EA68 + JSR SetupBonusChanceScreen - JSR Delay160Frames + JSR SlotMachine_Delay160Frames -loc_BANKF_E90C: +SlotMachine_NextRound: LDA #ScreenUpdateBuffer_RAM_EraseBonusMessageTextUnused STA ScreenUpdateIndex JSR WaitForNMI - JMP loc_BANKF_E7FD + JMP SlotMachine_CheckCoinsLoop ; @@ -1795,7 +1803,7 @@ SlotMachineTextFlashIndex: NoCoinsForSlotMachine: - JSR Delay80Frames + JSR SlotMachine_Delay80Frames IFDEF EXPAND_MUSIC ; Need $08 to loop correctly, but want to preserve addresses @@ -1807,7 +1815,7 @@ ELSE ENDIF STA byte_RAM_6 -loc_BANKF_E92A: +SlotMachine_NoCoins_FlashLoop: LDA byte_RAM_6 AND #$01 TAY @@ -1816,30 +1824,30 @@ loc_BANKF_E92A: LDA #$0A STA byte_RAM_7 -loc_BANKF_E938: +SlotMachine_NoCoins_DelayLoop: JSR WaitForNMI_TurnOnPPU DEC byte_RAM_7 - BNE loc_BANKF_E938 + BNE SlotMachine_NoCoins_DelayLoop DEC byte_RAM_6 - BPL loc_BANKF_E92A + BPL SlotMachine_NoCoins_FlashLoop JMP GoToNextLevel -Delay80Frames: +SlotMachine_Delay80Frames: LDA #$50 - BNE DelayFrames + BNE SlotMachine_DelayFrames -Delay160Frames: +SlotMachine_Delay160Frames: LDA #$A0 -DelayFrames: +SlotMachine_DelayFrames: STA byte_RAM_7 -DelayFrames_Loop: +SlotMachine_DelayFrames_Loop: JSR WaitForNMI_TurnOnPPU DEC byte_RAM_7 - BNE DelayFrames_Loop + BNE SlotMachine_DelayFrames_Loop RTS @@ -1990,9 +1998,7 @@ EnableNMI: RTS -; =============== S U B R O U T I N E ======================================= - -sub_BANKF_EA33: +SetupBonusChancePalette: JSR SetScrollXYTo0 LDA PPUSTATUS @@ -2001,12 +2007,12 @@ sub_BANKF_EA33: STA PPUADDR STY PPUADDR -loc_BANKF_EA43: +SetupBonusChancePalette_Loop: LDA unk_RAM_59C, Y STA PPUDATA INY CPY #$10 - BCC loc_BANKF_EA43 + BCC SetupBonusChancePalette_Loop LDY #$00 LDA PPUSTATUS @@ -2022,11 +2028,8 @@ SetBonusChancePalette: CPY #$10 BCC SetBonusChancePalette -; End of function sub_BANKF_EA33 - -; =============== S U B R O U T I N E ======================================= -sub_BANKF_EA68: +SetupBonusChanceScreen: LDY ExtraLives DEY TYA @@ -2047,8 +2050,6 @@ sub_BANKF_EA68: JMP WaitForNMI -; End of function sub_BANKF_EA68 - ; ; Converts a number to numerical tiles with space for 2 digits @@ -2482,7 +2483,6 @@ NMI_Exit: PLP RTI -; End of function NMI ; ; Sets the PPU address to `$3f00`, then immediatley to `$0000` @@ -3085,36 +3085,33 @@ LevelMusicIndexes: .db Music1_Subspace ; 4 -; =============== S U B R O U T I N E ======================================= - -sub_BANKF_F0F9: +RunFrame_Subspace: JSR NextSpriteFlickerSlot LDA PlayerInRocket - BNE loc_BANKF_F11B + BNE RunFrame_Subspace_AfterRender ; boss clear fanfare locks player movement LDA MusicPlaying2 CMP #Music2_BossClearFanfare - BEQ loc_BANKF_F115 + BEQ RunFrame_Subspace_AfterPlayerState LDA PlayerLock - BNE loc_BANKF_F115 + BNE RunFrame_Subspace_AfterPlayerState LDA #PRGBank_0_1 JSR ChangeMappedPRGBank JSR HandlePlayerState -loc_BANKF_F115: +RunFrame_Subspace_AfterPlayerState: JSR SetPlayerScreenPosition JSR RenderPlayer -loc_BANKF_F11B: +RunFrame_Subspace_AfterRender: JMP RunFrame_Common -; End of function sub_BANKF_F0F9 ; ; Does a lot of important stuff in horizontal levels @@ -3632,16 +3629,18 @@ IFDEF CONTROLLER_2_DEBUG RenderPlayer_AfterChangeCharacterPoof: ENDIF + ; Cycle the palette for changing size LDY_abs PlayerState CPY #PlayerState_ChangingSize - BEQ loc_BANKF_F337 + BEQ RenderPlayer_SetPaletteAttributes + ; Cycle the palette for star invincibility LDY StarInvincibilityTimer - BNE loc_BANKF_F337 + BNE RenderPlayer_SetPaletteAttributes - LDA DamageInvulnTime ; Determine if the player is invincible from damage, -; and if so, if they should be visible - BEQ loc_BANKF_F345 + ; Make the player sprite blink if they are invincible from taking damage + LDA DamageInvulnTime + BEQ RenderPlayer_CheckBehindBackground LSR A LSR A @@ -3650,34 +3649,36 @@ ENDIF TAY LDA DamageInvulnTime AND DamageInvulnBlinkFrames, Y - BNE loc_BANKF_F345 + BNE RenderPlayer_CheckBehindBackground + ; Bail out, which will make the player invisible RTS -; --------------------------------------------------------------------------- -loc_BANKF_F337: +RenderPlayer_SetPaletteAttributes: LDA byte_RAM_10 CPY #$18 - BCS loc_BANKF_F33F + BCS RenderPlayer_SetPaletteAttributes_Apply + ; Flash a little more slowly when the player is changing size or if the star + ; invincibility timer has almost run out LSR A LSR A -loc_BANKF_F33F: +RenderPlayer_SetPaletteAttributes_Apply: AND #ObjAttrib_Palette ORA PlayerAttributes STA PlayerAttributes -loc_BANKF_F345: +RenderPlayer_CheckBehindBackground: LDA QuicksandDepth - BEQ loc_BANKF_F350 + BEQ RenderPlayer_SetSpritePositions LDA #ObjAttrib_BehindBackground ORA PlayerAttributes STA PlayerAttributes -loc_BANKF_F350: +RenderPlayer_SetSpritePositions: LDA PlayerScreenX STA SpriteDMAArea + $23 STA SpriteDMAArea + $2B @@ -3685,76 +3686,90 @@ loc_BANKF_F350: ADC #$08 STA SpriteDMAArea + $27 STA SpriteDMAArea + $2F + + ; Visible y-position of the sprite starts with the player screen y-position + ; and is adjusted based on other factors LDA PlayerScreenYLo STA byte_RAM_0 LDA PlayerScreenYHi STA byte_RAM_1 + + ; The ducking sprite position is not adjusted between small/large size LDY PlayerAnimationFrame - CPY #$04 - BEQ loc_BANKF_F382 + CPY #SpriteAnimation_Ducking + BEQ RenderPlayer_CheckCharacter + ; Check the player size LDA PlayerCurrentSize - BEQ loc_BANKF_F382 + BEQ RenderPlayer_CheckCharacter + ; Adjust for small characters (that aren't ducking) LDA byte_RAM_0 CLC ADC #$08 STA byte_RAM_0 - BCC loc_BANKF_F382 + BCC RenderPlayer_CheckCharacter INC byte_RAM_1 -loc_BANKF_F382: +RenderPlayer_CheckCharacter: + ; Princess doesn't bob while walking LDA CurrentCharacter CMP #Character_Princess - BEQ loc_BANKF_F394 + BEQ RenderPlayer_TopHalf - CPY #$00 - BNE loc_BANKF_F394 +RenderPlayer_WalkingAdjustYPosition: + ; Y is PlayerAnimationFrame from before + CPY #SpriteAnimation_Walking + BNE RenderPlayer_TopHalf + ; Move up by one pixel while walking LDA byte_RAM_0 - BNE loc_BANKF_F392 + BNE RenderPlayer_WalkingAdjustYPosition_Lo DEC byte_RAM_1 -loc_BANKF_F392: +RenderPlayer_WalkingAdjustYPosition_Lo: DEC byte_RAM_0 -loc_BANKF_F394: +RenderPlayer_TopHalf: JSR FindSpriteSlot LDA byte_RAM_1 - BNE loc_BANKF_F3A6 + ; If the top of the character is out of bounds, skip + BNE RenderPlayer_BottomHalf LDA byte_RAM_0 - STA SpriteDMAArea, Y + STA SpriteDMAArea, Y ; eye STA SpriteDMAArea + $20 STA SpriteDMAArea + $24 -loc_BANKF_F3A6: +RenderPlayer_BottomHalf: LDA byte_RAM_0 CLC ADC #$10 STA byte_RAM_0 LDA byte_RAM_1 ADC #$00 - BNE loc_BANKF_F3BB + ; If the bottom of the character is out of bounds, do not render it + BNE RenderPlayer_CheckCrouchJump LDA byte_RAM_0 STA SpriteDMAArea + $28 STA SpriteDMAArea + $2C -loc_BANKF_F3BB: +RenderPlayer_CheckCrouchJump: LDA CrouchJumpTimer - CMP #$3C - BCC loc_BANKF_F3CA + CMP #CrouchJumpTimerMax + BCC RenderPlayer_SetSpriteAttributes + ; Rapidly flash when crouch timer is maxed out LDA byte_RAM_10 AND #ObjAttrib_Palette1 ORA PlayerAttributes STA PlayerAttributes -loc_BANKF_F3CA: +RenderPlayer_SetSpriteAttributes: LDA PlayerDirection LSR A ROR A @@ -3762,109 +3777,116 @@ loc_BANKF_F3CA: ORA PlayerAttributes AND #%11111100 ORA #ObjAttrib_Palette1 - STA SpriteDMAArea + 2, Y + STA SpriteDMAArea + 2, Y ; eye + LDX PlayerAnimationFrame - CPX #$07 - BEQ loc_BANKF_F3E2 + CPX #SpriteAnimation_Dead + BEQ RenderPlayer_SetAttributes_MirroredSprite - CPX #$04 - BNE loc_BANKF_F3EE + CPX #SpriteAnimation_Ducking + BNE RenderPlayer_SetAttributes_RegularSprite -loc_BANKF_F3E2: +RenderPlayer_SetAttributes_MirroredSprite: LDA PlayerAttributes STA SpriteDMAArea + $22 STA SpriteDMAArea + $2A ORA #$40 - BNE loc_BANKF_F3F8 + BNE RenderPlayer_SetAttributes_SecondHalf -loc_BANKF_F3EE: - AND #$FC +RenderPlayer_SetAttributes_RegularSprite: + AND #%11111100 ORA PlayerAttributes STA SpriteDMAArea + $22 STA SpriteDMAArea + $2A -loc_BANKF_F3F8: +RenderPlayer_SetAttributes_SecondHalf: STA SpriteDMAArea + $26 STA SpriteDMAArea + $2E + LDA CharacterFrameEyeTiles, X - BNE loc_BANKF_F408 + BNE RenderPlayer_SetEyeTile + ; When the table lookup is $00, use the character eye tile lookup LDX CurrentCharacter LDA CharacterEyeTiles, X -loc_BANKF_F408: - STA SpriteDMAArea + 1, Y +RenderPlayer_SetEyeTile: + STA SpriteDMAArea + 1, Y ; eye + ; Standing, walking, and ducking animations have "holding item" variants LDA PlayerAnimationFrame - CMP #$06 - BCS loc_BANKF_F413 + CMP #SpriteAnimation_Jumping + BCS RenderPlayer_PrepareCharacterTiles ORA HoldingItem -loc_BANKF_F413: +RenderPlayer_PrepareCharacterTiles: ASL A ASL A TAX LDA PlayerDirection - BNE loc_BANKF_F44A + BNE RenderPlayer_SetTiles_FacingRight +RenderPlayer_SetTiles_FacingLeft: LDA SpriteDMAArea + $23 - STA SpriteDMAArea + 3, Y + STA SpriteDMAArea + 3, Y ; eye LDA CharacterTiles_Walk1, X STA SpriteDMAArea + $21 LDA CharacterTiles_Walk1 + 1, X STA SpriteDMAArea + $25 + + ; Checks to see if we should use the special Princess bottom tiles LDA PlayerCurrentSize - BNE loc_BANKF_F43F + BNE RenderPlayer_SetTiles_FacingLeft_Bottom LDA CurrentCharacter CMP #Character_Princess - BNE loc_BANKF_F43F + BNE RenderPlayer_SetTiles_FacingLeft_Bottom LDA PlayerAnimationFrame CMP #SpriteAnimation_Jumping - BNE loc_BANKF_F43F + BNE RenderPlayer_SetTiles_FacingLeft_Bottom - LDX #$2A + LDX #(CharacterTiles_PrincessJumpBody - CharacterTiles_Walk1 - 2) ; #$2A -loc_BANKF_F43F: +RenderPlayer_SetTiles_FacingLeft_Bottom: LDA CharacterTiles_Walk1 + 2, X STA SpriteDMAArea + $29 LDA CharacterTiles_Walk1 + 3, X - BNE loc_BANKF_F478 + BNE RenderPlayer_SetTiles_BottomRight -loc_BANKF_F44A: +RenderPlayer_SetTiles_FacingRight: LDA SpriteDMAArea + $27 - STA SpriteDMAArea + 3, Y + STA SpriteDMAArea + 3, Y ; eye LDA CharacterTiles_Walk1 + 1, X STA SpriteDMAArea + $21 LDA CharacterTiles_Walk1, X STA SpriteDMAArea + $25 + + ; The next LDA PlayerCurrentSize - BNE loc_BANKF_F46F + BNE RenderPlayer_SetTiles_FacingRight_Bottom LDA CurrentCharacter CMP #Character_Princess - BNE loc_BANKF_F46F + BNE RenderPlayer_SetTiles_FacingRight_Bottom LDA PlayerAnimationFrame CMP #SpriteAnimation_Jumping - BNE loc_BANKF_F46F + BNE RenderPlayer_SetTiles_FacingRight_Bottom - LDX #$2A + LDX #(CharacterTiles_PrincessJumpBody - CharacterTiles_Walk1 - 2) ; #$2A -loc_BANKF_F46F: +RenderPlayer_SetTiles_FacingRight_Bottom: LDA CharacterTiles_Walk1 + 3, X STA SpriteDMAArea + $29 LDA CharacterTiles_Walk1 + 2, X -loc_BANKF_F478: +RenderPlayer_SetTiles_BottomRight: STA SpriteDMAArea + $2D RTS -; =============== S U B R O U T I N E ======================================= - SetAreaStartPage: LDA IsHorizontalLevel BNE SetAreaStartPage_HorizontalLevel @@ -3942,7 +3964,7 @@ DetermineVerticalScroll_Exit: GetVerticalAreaStartPage: STA byte_RAM_F TYA - BMI locret_BANKF_F4D9 + BMI GetVerticalAreaStartPage_Exit ASL A ASL A @@ -3950,21 +3972,19 @@ GetVerticalAreaStartPage: ASL A CLC ADC byte_RAM_F - BCS loc_BANKF_F4D5 + BCS GetVerticalAreaStartPage_AdjustPage CMP #$F0 - BCC locret_BANKF_F4D9 + BCC GetVerticalAreaStartPage_Exit -loc_BANKF_F4D5: +GetVerticalAreaStartPage_AdjustPage: CLC ADC #$10 INY -locret_BANKF_F4D9: +GetVerticalAreaStartPage_Exit: RTS -; End of function GetVerticalAreaStartPage - SpriteFlickerDMAOffset: .db $C0 @@ -5126,9 +5146,6 @@ DoAreaReset_EnemyLoopEnd: LDX byte_RAM_12 RTS -; End of function DoAreaReset - -; =============== S U B R O U T I N E ======================================= AreaResetEnemyDestroy: ; load raw enemy data offset so we can allow the level object to respawn @@ -5146,9 +5163,6 @@ AreaResetEnemyDestroy_AfterAllowRespawn: STA EnemyState, X RTS -; End of function AreaResetEnemyDestroy - -; =============== S U B R O U T I N E ======================================= KillPlayer: LDA #PlayerState_Dying ; Mark player as dead @@ -5166,7 +5180,7 @@ ENDIF LDA #SpriteAnimation_Dead ; Set player animation to dead? STA PlayerAnimationFrame LDA HoldingItem - BEQ loc_BANKF_F749 + BEQ PlayerDeath_SetMusic ; Probably something to throw away ; a held item on death @@ -5180,14 +5194,14 @@ ENDIF STX byte_RAM_D LDX EnemyState, Y CPX #EnemyState_Sinking - BEQ loc_BANKF_F747 + BEQ PlayerDeath_Exit STA ObjectYVelocity, Y -loc_BANKF_F747: +PlayerDeath_Exit: LDX byte_RAM_D -loc_BANKF_F749: +PlayerDeath_SetMusic: IFNDEF RESPAWN_INSTEAD_OF_DEATH ; Set music to death jingle LDA #Music2_DeathJingle diff --git a/src/ram.asm b/src/ram.asm index 377d5f6..440522f 100644 --- a/src/ram.asm +++ b/src/ram.asm @@ -1755,6 +1755,9 @@ GroundSlipperiness: .dsb 1 ; $0626 DoAreaTransition: .dsb 1 ; $0627 +; $00: Regular area +; $01: Jar +; $02: Subspace InSubspaceOrJar: .dsb 1 ; $0628 CurrentLevelRelative: @@ -2018,6 +2021,9 @@ Player1JoypadExpansionPress: .dsb 1 ; $06f4 Player2JoypadExpansionPress: .dsb 1 ; $06f5 +; Current player sprite size +; $00 = Large +; $01 = Small PlayerCurrentSize: .dsb 1 ; $06f6 BackgroundCHR1: From e071a429df947b5ed49eceb920fc4dc7e3d50140 Mon Sep 17 00:00:00 2001 From: Keith McKnight Date: Sun, 28 Dec 2025 22:38:55 -0500 Subject: [PATCH 11/17] more descriptive labels for banks a-b --- src/defs.asm | 3 +- src/prg-a-b.asm | 122 +++++++++++++++++++++++++----------------------- src/prg-e-f.asm | 35 +++++++++----- 3 files changed, 87 insertions(+), 73 deletions(-) diff --git a/src/defs.asm b/src/defs.asm index 6457468..d20052b 100644 --- a/src/defs.asm +++ b/src/defs.asm @@ -187,7 +187,7 @@ ScreenUpdateBuffer_RAM_EraseBonusMessageTextUnused = $11 ScreenUpdateBuffer_WarpToWorld = $12 ScreenUpdateBuffer_RAM_ContinueRetryBullets = $13 ScreenUpdateBuffer_RAM_EndOfLevelDoor = $14 -ScreenUpdateBuffer_TitleCardLeftover = $15 +ScreenUpdateBuffer_TitleCardCharacterSelectMask = $15 ScreenUpdateBuffer_PauseExtraLife = $16 ScreenUpdateBuffer_RAM_BonusChanceLayout = $17 @@ -316,7 +316,6 @@ Stack100_Gameplay = %11000000 ; normal gameplay ; --------------------------------------------------------------------------- ; enum PPUControl (bitfield) (width 1 byte) -PPUCtrl_BaseAddress = $03 PPUCtrl_Base2000 = $00 PPUCtrl_Base2400 = $01 PPUCtrl_Base2800 = $02 diff --git a/src/prg-a-b.asm b/src/prg-a-b.asm index 57a0579..7bf9b17 100644 --- a/src/prg-a-b.asm +++ b/src/prg-a-b.asm @@ -13,10 +13,12 @@ ; ; This title card is used for every world from 1 to 6. -; The only difference is the loaded CHR banks. +; The only difference is the loaded CHR banks, and the special logic for worlds +; 2 and 6 to redraw the last two rows offset up by 16 pixels, effectively +; overwriting the grass with sand. ; World1thru6TitleCard: - .db $FB, $FB, $B0, $B2, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB + .db $FB, $FB, $B0, $B2, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB ; $00 .db $FB, $FB, $B1, $B3, $FB, $FB, $FB, $FB, $FB, $FB, $C0, $C1, $FB, $FB, $FB, $FB ; $10 .db $FB, $FB, $B4, $B5, $FB, $FB, $FB, $FB, $B6, $B8, $BA, $B8, $BA, $BC, $FB, $FB ; $20 .db $FB, $FB, $B4, $B5, $FB, $FB, $FB, $FB, $B7, $B9, $BB, $B9, $BB, $BD, $FB, $FB ; $30 @@ -31,7 +33,7 @@ World1thru6TitleCard: ; This one is the special one used for World 7 ; World7TitleCard: - .db $FB, $FB, $B0, $B2, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB + .db $FB, $FB, $B0, $B2, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB, $FB ; $00 .db $FB, $FB, $B1, $B3, $FB, $FB, $FB, $FB, $FB, $FB, $C0, $C1, $FB, $FB, $FB, $FB ; $10 .db $FB, $FB, $B1, $B3, $FB, $FB, $FB, $FB, $B6, $B8, $BA, $B8, $BA, $BC, $FB, $FB ; $20 .db $FB, $FB, $B1, $B3, $FB, $FB, $FB, $FB, $B7, $B9, $BB, $B9, $BB, $BD, $FB, $FB ; $30 @@ -146,38 +148,36 @@ CopyBonusChanceLayoutToRAM_Loop2: RTS -; =============== S U B R O U T I N E ======================================= DrawTitleCardWorldImage: LDA CurrentWorld CMP #6 - BEQ loc_BANKA_8392 ; Special case for World 7's title card + BEQ DrawTitleCardWorld7 ; Special case for World 7's title card +DrawTitleCardWorld1thru6: LDA #$25 STA byte_RAM_0 LDA #$C8 STA byte_RAM_1 LDY #$00 -loc_BANKA_8338: +DrawTitleCardWorld1thru6_Loop: LDX #$0F LDA PPUSTATUS LDA byte_RAM_0 STA PPUADDR - -loc_BANKA_8342: LDA byte_RAM_1 STA PPUADDR -loc_BANKA_8347: +DrawTitleCardWorld1thru6_CopyTileRow: LDA World1thru6TitleCard, Y STA PPUDATA INY DEX - BPL loc_BANKA_8347 + BPL DrawTitleCardWorld1thru6_CopyTileRow CPY #$A0 - BCS loc_BANKA_8364 + BCS DrawTitleCardWorld1thru6_AfterTileRows LDA byte_RAM_1 ADC #$20 @@ -185,50 +185,57 @@ loc_BANKA_8347: LDA byte_RAM_0 ADC #$00 STA byte_RAM_0 - JMP loc_BANKA_8338 + JMP DrawTitleCardWorld1thru6_Loop -; --------------------------------------------------------------------------- -loc_BANKA_8364: +DrawTitleCardWorld1thru6_AfterTileRows: + ; Check if we're in a desert world LDA CurrentWorld CMP #1 - BEQ loc_BANKA_8371 + BEQ DrawTitleCard_Desert CMP #5 - BEQ loc_BANKA_8371 + BEQ DrawTitleCard_Desert - BNE loc_BANKA_8389 + BNE DrawTitleCard_Cleanup -loc_BANKA_8371: + ; If we're on a desert world, the grass tiles are overwritten with duplicates + ; of the sand tiles below. +DrawTitleCard_Desert: AND #$80 - BNE loc_BANKA_8389 + BNE DrawTitleCard_Cleanup + ; Point to the row of grass tiles LDA #$26 STA byte_RAM_0 LDA #$88 STA byte_RAM_1 + + ; Set the desert title card flag so we don't infinitely loop LDA CurrentWorld ORA #$80 STA CurrentWorld + + ; Reset the pointer to the bottom two rows LDY #$80 - BNE loc_BANKA_8338 + BNE DrawTitleCardWorld1thru6_Loop -loc_BANKA_8389: +DrawTitleCard_Cleanup: + ; Clear the desert title card flag LDA CurrentWorld - AND #$F + AND #$0F STA CurrentWorld RTS -; --------------------------------------------------------------------------- -loc_BANKA_8392: +DrawTitleCardWorld7: LDA #$25 STA byte_RAM_0 LDA #$C8 STA byte_RAM_1 LDY #$00 -loc_BANKA_839C: +DrawTitleCardWorld7_Loop: LDX #$0F LDA PPUSTATUS LDA byte_RAM_0 @@ -236,15 +243,15 @@ loc_BANKA_839C: LDA byte_RAM_1 STA PPUADDR -loc_BANKA_83AB: +DrawTitleCardWorld7_CopyTileRow: LDA World7TitleCard, Y STA PPUDATA INY DEX - BPL loc_BANKA_83AB + BPL DrawTitleCardWorld7_CopyTileRow CPY #$A0 - BCS locret_BANKA_83C8 + BCS DrawTitleCardWorld7_Exit LDA byte_RAM_1 ADC #$20 @@ -252,14 +259,11 @@ loc_BANKA_83AB: LDA byte_RAM_0 ADC #$00 STA byte_RAM_0 - JMP loc_BANKA_839C + JMP DrawTitleCardWorld7_Loop -; --------------------------------------------------------------------------- - -locret_BANKA_83C8: +DrawTitleCardWorld7_Exit: RTS -; End of function DrawTitleCardWorldImage StatOffsets: .db (MarioStats - CharacterStats) @@ -425,113 +429,113 @@ MysteryData14439: ; CopyCharacterStatsAndStuff: IFDEF CONTROLLER_2_DEBUG - JSR CopyCharacterStats + JSR CopyAllCharacterStats ENDIF LDX CurrentCharacter LDY StatOffsets, X LDX #$00 -loc_BANKA_8458: +CopyCharacterStats_Loop: LDA CharacterStats, Y STA CharacterStatsRAM, X INY INX CPX #$17 - BCC loc_BANKA_8458 + BCC CopyCharacterStats_Loop LDA CurrentCharacter ASL A ASL A TAY LDX #$00 -loc_BANKA_846B: +CopyCharacterPalette_Loop: LDA CharacterPalette, Y STA RestorePlayerPalette0, X INY INX CPX #$04 - BCC loc_BANKA_846B + BCC CopyCharacterPalette_Loop LDY #$4C -loc_BANKA_8479: +CopyPlayerSelectPalettes_Loop: LDA PlayerSelectPalettes, Y STA PPUBuffer_TitleCardPalette, Y DEY CPY #$FF - BNE loc_BANKA_8479 + BNE CopyPlayerSelectPalettes_Loop LDY #$B6 -loc_BANKA_8486: +CopyBonusChanceReelOrder_Loop: LDA BonusChanceReel1Order, Y STA SlotMachineReelOrder1RAM, Y DEY CPY #$FF - BNE loc_BANKA_8486 + BNE CopyBonusChanceReelOrder_Loop LDY #$63 -loc_BANKA_8493: +CopyTitleCardText_Loop: LDA TitleCardText, Y STA PPUBuffer_TitleCardText, Y DEY CPY #$FF - BNE loc_BANKA_8493 + BNE CopyTitleCardText_Loop ; This data is copied, but doesn't appear to be used. Its original purpose is not obvious. LDY #$17 -loc_BANKA_84A0: +CopyMysteryData_Loop: LDA MysteryData14439, Y STA MysteryData14439_RAM, Y DEY - BPL loc_BANKA_84A0 + BPL CopyMysteryData_Loop ; Copy object collision hitbox table ; ; The fact that it's in RAM is taken advantage of to programmatically change ; the hitbox for Hawkmouth after picking up the crystal. LDY #$4F -loc_BANKA_84AB: +CopyObjectCollisionHitbox_Loop: LDA ObjectCollisionHitboxLeft, Y STA ObjectCollisionHitboxLeft_RAM, Y DEY - BPL loc_BANKA_84AB + BPL CopyObjectCollisionHitbox_Loop ; Copy flying carpet acceleration table LDY #$03 -loc_BANKA_84B6: +CopyFlyingCarpetAcceleration_Loop: LDA FlyingCarpetAcceleration, Y STA FlyingCarpetAcceleration_RAM, Y DEY - BPL loc_BANKA_84B6 + BPL CopyFlyingCarpetAcceleration_Loop ; Copy object collision type table ; ; The fact that it's in RAM is used to toggle the Boss Hawkmouth between an ; object and an enemy. LDY #$49 -loc_BANKA_84C1: +CopyEnemyPlayerCollisionTable_Loop: LDA EnemyPlayerCollisionTable, Y STA EnemyPlayerCollisionTable_RAM, Y DEY - BPL loc_BANKA_84C1 + BPL CopyEnemyPlayerCollisionTable_Loop ; Copy end of level door PPU data to RAM ; ; The fact that it's in RAM is actually taken advantage of when defeating Clawgrip, since the ; door needs to be drawn in a slightly different spot. LDY #$20 -loc_BANKA_84CC: +CopyEndOfLevelDoor_Loop: LDA EndOfLevelDoor, Y STA PPUBuffer_EndOfLevelDoor, Y DEY - BPL loc_BANKA_84CC + BPL CopyEndOfLevelDoor_Loop ; Copy Wart's OAM address table LDY #$06 -loc_BANKA_84D7: +CopyWartOAMOffsets_Loop: LDA WartOAMOffsets, Y STA WartOAMOffsets_RAM, Y DEY - BPL loc_BANKA_84D7 + BPL CopyWartOAMOffsets_Loop RTS @@ -716,13 +720,13 @@ IFDEF CONTROLLER_2_DEBUG ; ; Copies all character stats to RAM for hot-swapping the current character ; -CopyCharacterStats: +CopyAllCharacterStats: LDX #(MysteryData14439 - StatOffsets - 1) -CopyCharacterStats_Loop: +CopyAllCharacterStats_Loop: LDA StatOffsets, X STA StatOffsetsRAM, X DEX - BPL CopyCharacterStats_Loop + BPL CopyAllCharacterStats_Loop RTS ENDIF diff --git a/src/prg-e-f.asm b/src/prg-e-f.asm index 38a8963..bfb2ee1 100644 --- a/src/prg-e-f.asm +++ b/src/prg-e-f.asm @@ -47,7 +47,7 @@ ScreenUpdateBufferPointers: .dw PPUBuffer_WarpToWorld .dw PPUBuffer_ContinueRetryBullets .dw PPUBuffer_EndOfLevelDoor - .dw PPUBuffer_TitleCardLeftover + .dw PPUBuffer_TitleCardCharacterSelectMask .dw PPUBuffer_PauseExtraLife .dw PPUBuffer_BonusChanceLayout @@ -183,9 +183,10 @@ PPUBuffer_PauseExtraLife: .db $27, $EA, $05 .db $AA, $AA, $AA, $AA, $AA -; This draws two columns of black tiles along the right side of the nametable to the left of the -; title card, which was the character/level select in Doki Doki Panic. In SMB2, it remains unused. -PPUBuffer_TitleCardLeftover: +; This draws black tiles over the diamons on the right side of the character +; select screen, which would otherwise cause a single pixel column of junk to +; be visible on the title card screen. +PPUBuffer_TitleCardCharacterSelectMask: .db $20, $1E, $9E .db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF .db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF @@ -556,12 +557,20 @@ DisplayLevelTitleCardAndMore: JSR DisableNMI - ; Set the scrolling mirror over to the right side... - ; This Isn't quiiite correct, and causes a bunch of - ; crud to show on the very left pixel -- residue - ; from the character select screen + ; Set the scrolling mirror over to the right side. + ; + ; In Doki Doki Panic, there is a horizontal scrolling transition from the + ; character select screen to the level title, since they are presented as + ; opposite pages in a storybook. + ; + ; This implementation is actually off by a pixel, since you can only scroll + ; over 255 pixels before needing to update the base nametable address. + ; + ; If the title card drawing routine didn't also erase part of the character + ; select screen below, you would see a column of junk pixels on the left! LDA #$FF STA PPUScrollXMirror + JSR ChangeTitleCardCHR LDA #PRGBank_A_B @@ -584,7 +593,8 @@ DisplayLevelTitleCardAndMore_TitleCardPaletteLoop: STA ScreenUpdateIndex JSR WaitForNMI - LDA #ScreenUpdateBuffer_TitleCardLeftover + ; Erase the right column of metatiles from the character select screen + LDA #ScreenUpdateBuffer_TitleCardCharacterSelectMask STA ScreenUpdateIndex JSR WaitForNMI @@ -614,6 +624,7 @@ PreStartLevel: LDA #PRGBank_A_B JSR ChangeMappedPRGBank + ; We probably didn't need to do this a second time... JSR CopyCharacterStatsAndStuff JSR EnableNMI @@ -1332,7 +1343,7 @@ ShowCardAfterTransition: STA TitleCard_ExtraLife_DrawAddress LDA #$48 STA TitleCard_ExtraLife_DrawAddress + 1 - LDA #ScreenUpdateBuffer_TitleCardLeftover + LDA #ScreenUpdateBuffer_TitleCardCharacterSelectMask STA CardScreenUpdateIndex JSR PauseScreen_Card @@ -2672,11 +2683,11 @@ UpdatePPUFromBufferWithOptions: PHA ; Enable NMI + Vertical increment + whatever else was already set... LDA PPUCtrlMirror - ORA #PPUCtrl_Base2000 | PPUCtrl_WriteVertical | PPUCtrl_Sprite0000 | PPUCtrl_Background0000 | PPUCtrl_SpriteSize8x8 | PPUCtrl_NMIEnabled + ORA #PPUCtrl_WriteVertical | PPUCtrl_NMIEnabled ; ...but only if $80 was set in the length byte. Otherwise, turn vertical incrementing back off. BCS UpdatePPUFBWO_EnableVerticalIncrement - AND #PPUCtrl_Base2C00 | PPUCtrl_WriteHorizontal | PPUCtrl_Sprite1000 | PPUCtrl_Background1000 | PPUCtrl_SpriteSize8x16 | PPUCtrl_NMIEnabled | $40 + AND #($FF ^ PPUCtrl_WriteVertical) UpdatePPUFBWO_EnableVerticalIncrement: STA PPUCTRL From a9cd3203d8ae9e3c2295cad94957d00bb20cd943 Mon Sep 17 00:00:00 2001 From: Keith McKnight Date: Sun, 28 Dec 2025 23:35:34 -0500 Subject: [PATCH 12/17] lifted object labels --- src/prg-0-1.asm | 83 ++++++++++++++++++++++++++++--------------------- src/prg-2-3.asm | 4 ++- 2 files changed, 50 insertions(+), 37 deletions(-) diff --git a/src/prg-0-1.asm b/src/prg-0-1.asm index 2350696..1f14dea 100644 --- a/src/prg-0-1.asm +++ b/src/prg-0-1.asm @@ -3530,22 +3530,27 @@ PickUpToEnemyTypeTable: .db Enemy_MushroomBlock ; $0E ; this one seems to be overridden for digging in sand -; find a slot for the item being lifted -loc_BANK0_9074: +; +; Tries to find a slot to create an object for the item being lifted +; +; Output +; X = slot used +; N = enabled if no empty slot was found +; +CreateLiftedObject: LDX #$06 -loc_BANK0_9076: +CreateLiftedObject_FindSlot: LDA EnemyState, X - BEQ loc_BANK0_9080 + BEQ CreateLiftedObject_FoundSlot INX CPX #$09 - BCC loc_BANK0_9076 + BCC CreateLiftedObject_FindSlot RTS -; create the sprite for the item being picked up -loc_BANK0_9080: +CreateLiftedObject_FoundSlot: LDA byte_RAM_0 STA EnemyVariable, X LDA byte_RAM_3 @@ -3564,63 +3569,66 @@ loc_BANK0_9080: LDA #EnemyState_Alive LDY byte_RAM_9 - CPY #$0E - BNE loc_BANK0_90AE + CPY #$0E ; the magic sand number + BNE CreateLiftedObject_SetEnemyState + ; It's sand!!! LDA #$20 STA ObjectTimer1, X LDA #EnemyState_Sand -loc_BANK0_90AE: +CreateLiftedObject_SetEnemyState: STA EnemyState, X LDA PickUpToEnemyTypeTable, Y ; What sprite is spawned for you when lifting a bg object STA ObjectType, X -BombFuse: +CreateLiftedObject_BombFuse: LDY #$FF ; regular bomb fuse CMP #Enemy_Bomb - BEQ loc_BANK0_90C1 + BEQ CreateLiftedObject_SetObjectTimer1 CMP #Enemy_BobOmb - BNE loc_BANK0_90C5 + BNE CreateLiftedObject_NonBomb -BobOmbFuse: +CreateLiftedObject_BobOmbFuse: LDY #$50 ; BobOmb fuse -loc_BANK0_90C1: +CreateLiftedObject_SetObjectTimer1: STY ObjectTimer1, X - BNE loc_BANK0_90EA + BNE CreateLiftedObject_Init ; unconditional branch -loc_BANK0_90C5: +CreateLiftedObject_NonBomb: CMP #Enemy_Mushroom1up - BNE loc_BANK0_90D5 + BNE CreateLiftedObject_NonMushroom1up LDA Mushroom1upPulled - BEQ loc_BANK0_90EA + BEQ CreateLiftedObject_Init + ; If we've already pulled the 1-Up, spawn a vegetable instead LDA #Enemy_VegetableSmall STA ObjectType, X - JMP loc_BANK0_90EA + JMP CreateLiftedObject_Init -loc_BANK0_90D5: +CreateLiftedObject_NonMushroom1up: CMP #Enemy_VegetableLarge - BNE loc_BANK0_90EA + BNE CreateLiftedObject_Init LDY BigVeggiesPulled INY CPY #$05 - BCC loc_BANK0_90E7 + BCC CreateLiftedObject_SetBigVeggiesPulled + ; The fifth large veggie is a stopwatch LDA #Enemy_Stopwatch STA ObjectType, X LDY #$00 -loc_BANK0_90E7: +CreateLiftedObject_SetBigVeggiesPulled: STY BigVeggiesPulled -loc_BANK0_90EA: - JSR loc_BANK1_B9EB +CreateLiftedObject_Init: + JSR EnemyInit_BasicReset_Bank1 LDA #CollisionFlags_Down STA EnemyCollision, X @@ -3728,7 +3736,7 @@ TileBehavior_CheckPickUp: CMP #BackgroundTile_DiggableSand BNE TileBehavior_CheckPickUp_ItemTile - ; It's sand! Set the enemy pickup index + ; It's sand! Set the magic sand number and create an object LDA #$0E BNE TileBehavior_CheckPickUp_SetPickUpIndex @@ -3744,7 +3752,7 @@ TileBehavior_CheckPickUp_ItemTile: TileBehavior_CheckPickUp_SetPickUpIndex: STA byte_RAM_9 - JMP loc_BANK0_9074 + JMP CreateLiftedObject TileBehavior_CheckPickUp_DoNotLift: @@ -3828,7 +3836,7 @@ loc_BANK0_91E3: CLC ADC #$04 STA byte_RAM_9 - JMP loc_BANK0_9074 + JMP CreateLiftedObject ; @@ -7542,7 +7550,7 @@ CreateStarman: LDA ScreenYHi ADC #$00 STA ObjectYHi, X - JSR loc_BANK1_BA17 + JSR EnemyInit_BasicAttributes_Bank1 LDX byte_RAM_12 @@ -7550,15 +7558,17 @@ CreateStarman_Exit: RTS -; =============== S U B R O U T I N E ======================================= - +; +; NOTE: This is more-or-less a copy of the "EnemyInit_Basic" routine in Bank 2, but +; it is used here for spawning the door animation and Starman objects. +; EnemyInit_Basic_Bank1: LDA #$00 STA ObjectTimer1, X LDA #$00 STA EnemyVariable, X -loc_BANK1_B9EB: +EnemyInit_BasicReset_Bank1: LDA #$00 STA EnemyArray_B1, X STA ObjectProjectileTimer, X @@ -7575,10 +7585,12 @@ loc_BANK1_B9EB: STA EnemyArray_480, X STA EnemyHP, X STA ObjectYVelocity, X + ; The Bank 2 equivalent doesn't set ObjectXVelocity, since the basic enemies + ; start moving toward the player by default. STA ObjectXVelocity, X ; look up object attributes -loc_BANK1_BA17: +EnemyInit_BasicAttributes_Bank1: LDY ObjectType, X LDA ObjectAttributeTable, Y AND #ObjAttrib_Palette | ObjAttrib_Horizontal | ObjAttrib_FrontFacing | ObjAttrib_Mirrored | ObjAttrib_BehindBackground | ObjAttrib_16x32 @@ -7591,8 +7603,6 @@ loc_BANK1_BA17: STA EnemyArray_492, X RTS -; End of function EnemyInit_Basic_Bank1 - ; ; Turns the key into a puff of smoke @@ -7887,6 +7897,7 @@ CreateEnemy_Bank1_FoundSlot: LDA #EnemyState_Alive STA EnemyState, Y LSR A + ; A = $00 STA EnemyArray_SpawnsDoor, Y LDA #Enemy_ShyguyRed STA ObjectType, Y diff --git a/src/prg-2-3.asm b/src/prg-2-3.asm index 5c642de..7b81e12 100644 --- a/src/prg-2-3.asm +++ b/src/prg-2-3.asm @@ -880,7 +880,7 @@ EnemyInitializationTable_End: SetEnemyAttributes: LDY ObjectType, X LDA ObjectAttributeTable, Y - AND #$7F + AND #ObjAttrib_Palette | ObjAttrib_Horizontal | ObjAttrib_FrontFacing | ObjAttrib_Mirrored | ObjAttrib_BehindBackground | ObjAttrib_16x32 STA ObjectAttributes, X LDA EnemyArray_46E_Data, Y STA EnemyArray_46E, X @@ -906,6 +906,8 @@ EnemyInit_Basic: EnemyInit_BasicWithoutTimer: LDA #$00 STA EnemyVariable, X + +EnemyInit_BasicReset: LDA #$00 ; You do realize you already LDA #$00, right??? STA EnemyArray_B1, X STA ObjectProjectileTimer, X From 1b77ed3d9a5dda43ca7c3b89211087ae6544c266 Mon Sep 17 00:00:00 2001 From: Keith McKnight Date: Mon, 29 Dec 2025 11:17:22 -0500 Subject: [PATCH 13/17] ending labels --- src/prg-c-d.asm | 380 +++++++++++++++++++++++++----------------------- 1 file changed, 195 insertions(+), 185 deletions(-) diff --git a/src/prg-c-d.asm b/src/prg-c-d.asm index c3104e4..a073dd7 100644 --- a/src/prg-c-d.asm +++ b/src/prg-c-d.asm @@ -559,11 +559,11 @@ CastRoll_ScrollSprites_AfterSpriteCounter: .dw CastRoll_CrawlDelay .dw CastRoll_CrawlStart .dw CastRoll_CrawlContinue - .dw CastRoll_QueueWart + .dw CastRoll_WartSetup + .dw CastRoll_WartScroll .dw CastRoll_WartLaugh - .dw loc_BANKC_89B6 - .dw loc_BANKC_8A04 - .dw loc_BANKC_8A37 + .dw CastRoll_DoPaletteFadeOut + .dw CastRoll_HideSprites .dw CastRoll_TheEndDelay .dw CastRoll_TheEndAnimation @@ -764,6 +764,9 @@ CastRoll_CrawlDelay_Exit: RTS +; +; Starts the cast roll crawl +; CastRoll_CrawlStart: LDA CastRollThrottle AND #$01 @@ -791,6 +794,9 @@ CastRoll_CrawlStart: STA CastRollSpriteActive4 STA CastRollSpriteActive1 +; +; Runs the cast roll crawl without the initial setup +; CastRoll_CrawlContinue: CastRollSprite1: LDA CastRollSpriteActive1 @@ -846,10 +852,10 @@ CastRollSprite2_Loop: CastRollSprite3: LDA CastRollSpriteActive3 - BNE loc_BANKC_8693 + BNE CastRoll_CrawlContinue_UpdateSprite4 LDA CastRollSpriteCounter3 - BNE loc_BANKC_8693 + BNE CastRoll_CrawlContinue_UpdateSprite4 JSR LoadCastRollSpritePointer @@ -877,111 +883,109 @@ CastRollSprite3_Loop: CastRollSprite3_SetLastRowOffset: STY CastRollSprite3C -loc_BANKC_8693: +CastRoll_CrawlContinue_UpdateSprite4: LDA CastRollSpriteActive4 - BEQ loc_BANKC_869A + BEQ CastRoll_CrawlContinue_UpdateSprite1 - JMP loc_BANKC_873A + JMP CastRoll_CrawlContinue_UpdateSprite2 -; --------------------------------------------------------------------------- -loc_BANKC_869A: +CastRoll_CrawlContinue_UpdateSprite1: LDA CastRollThrottle AND #$01 - BNE loc_BANKC_86A3 + BNE CastRoll_CrawlContinue_Sprite1Row1 - JMP loc_BANKC_873A + JMP CastRoll_CrawlContinue_UpdateSprite2 -; --------------------------------------------------------------------------- -loc_BANKC_86A3: +CastRoll_CrawlContinue_Sprite1Row1: LDA SpriteDMAArea + $40 CMP #$F8 - BEQ loc_BANKC_86C3 + BEQ CastRoll_CrawlContinue_Sprite1Row2 LDA CastRollSprite1A SEC SBC #$01 CMP #$10 - BNE loc_BANKC_86B5 + BNE CastRoll_CrawlContinue_Sprite1Row1_Update LDA #$F8 -loc_BANKC_86B5: +CastRoll_CrawlContinue_Sprite1Row1_Update: STA CastRollSprite1A STA SpriteDMAArea + $40 STA SpriteDMAArea + $44 STA SpriteDMAArea + $48 STA SpriteDMAArea + $4C -loc_BANKC_86C3: +CastRoll_CrawlContinue_Sprite1Row2: LDA SpriteDMAArea + $50 CMP #$F8 - BEQ loc_BANKC_86F2 + BEQ CastRoll_CrawlContinue_Sprite1Row3 DEC CastRollSprite1B CMP #$F9 - BNE loc_BANKC_86D6 + BNE CastRoll_CrawlContinue_Sprite1Row2_Update LDA CastRollSprite1B CMP #$D0 - BNE loc_BANKC_86F2 + BNE CastRoll_CrawlContinue_Sprite1Row3 -loc_BANKC_86D6: +CastRoll_CrawlContinue_Sprite1Row2_Update: LDA CastRollSprite1B CMP #$10 - BNE loc_BANKC_86E6 + BNE CastRoll_CrawlContinue_Sprite1Row2_Hide LDA CastRollSpriteIndex CMP #$FF - BNE loc_BANKC_86E4 + BNE CastRoll_CrawlContinue_Sprite1Row2_CheckEnd INC CastRollSequenceIndex -loc_BANKC_86E4: +CastRoll_CrawlContinue_Sprite1Row2_CheckEnd: LDA #$F8 -loc_BANKC_86E6: +CastRoll_CrawlContinue_Sprite1Row2_Hide: STA SpriteDMAArea + $50 STA SpriteDMAArea + $54 STA SpriteDMAArea + $58 STA SpriteDMAArea + $5C -loc_BANKC_86F2: +CastRoll_CrawlContinue_Sprite1Row3: LDA SpriteDMAArea + $60 CMP #$F8 - BEQ loc_BANKC_873A + BEQ CastRoll_CrawlContinue_UpdateSprite2 DEC CastRollSprite1C CMP #$F9 - BNE loc_BANKC_870C + BNE CastRoll_CrawlContinue_Sprite1Row3_Update LDA CastRollSprite1C CMP #$D0 - BNE loc_BANKC_873A + BNE CastRoll_CrawlContinue_UpdateSprite2 LDY CastRollSpriteIndex LDA CastRollSpriteOffset, Y STA CastRollSpriteCounter2 -loc_BANKC_870C: +CastRoll_CrawlContinue_Sprite1Row3_Update: LDA CastRollSprite1C CMP #$10 - BNE loc_BANKC_8722 + BNE CastRoll_CrawlContinue_Sprite1Row3_Hide LDA #$00 STA CastRollSpriteActive1 LDA CastRollSpriteIndex CMP #$FF - BNE loc_BANKC_8720 + BNE CastRoll_CrawlContinue_Sprite1Row3_Deactivate LDA #$FF STA CastRollSpriteActive1 -loc_BANKC_8720: +CastRoll_CrawlContinue_Sprite1Row3_Deactivate: LDA #$F8 -loc_BANKC_8722: +CastRoll_CrawlContinue_Sprite1Row3_Hide: STA SpriteDMAArea + $60 STA SpriteDMAArea + $64 STA SpriteDMAArea + $68 @@ -991,101 +995,95 @@ loc_BANKC_8722: STA SpriteDMAArea + $78 STA SpriteDMAArea + $7C -loc_BANKC_873A: +CastRoll_CrawlContinue_UpdateSprite2: LDA CastRollThrottle AND #$01 - BNE loc_BANKC_8743 + BNE CastRoll_CrawlContinue_Sprite2Row1 - JMP loc_BANKC_87D2 + JMP CastRoll_CrawlContinue_UpdateSprite3 -; --------------------------------------------------------------------------- -loc_BANKC_8743: +CastRoll_CrawlContinue_Sprite2Row1: LDA SpriteDMAArea + $80 CMP #$F8 - BEQ loc_BANKC_8763 + BEQ CastRoll_CrawlContinue_Sprite2Row2 LDA CastRollSprite2A - -loc_BANKC_874C: SEC SBC #$01 CMP #$10 - BNE loc_BANKC_8755 + BNE CastRoll_CrawlContinue_Sprite2Row1_Update LDA #$F8 -loc_BANKC_8755: +CastRoll_CrawlContinue_Sprite2Row1_Update: STA CastRollSprite2A STA SpriteDMAArea + $80 STA SpriteDMAArea + $84 STA SpriteDMAArea + $88 STA SpriteDMAArea + $8C -loc_BANKC_8763: +CastRoll_CrawlContinue_Sprite2Row2: LDA SpriteDMAArea + $90 CMP #$F8 - BEQ loc_BANKC_878A + BEQ CastRoll_CrawlContinue_Sprite2Row3 DEC CastRollSprite2B CMP #$F9 - BNE loc_BANKC_8776 + BNE CastRoll_CrawlContinue_Sprite2Row2_Update LDA CastRollSprite2B CMP #$D0 - BNE loc_BANKC_878A + BNE CastRoll_CrawlContinue_Sprite2Row3 -loc_BANKC_8776: +CastRoll_CrawlContinue_Sprite2Row2_Update: LDA CastRollSprite2B CMP #$10 - BNE loc_BANKC_877E + BNE CastRoll_CrawlContinue_Sprite2Row2_Hide LDA #$F8 -loc_BANKC_877E: +CastRoll_CrawlContinue_Sprite2Row2_Hide: STA SpriteDMAArea + $90 STA SpriteDMAArea + $94 - -loc_BANKC_8784: STA SpriteDMAArea + $98 STA SpriteDMAArea + $9C -loc_BANKC_878A: +CastRoll_CrawlContinue_Sprite2Row3: LDA SpriteDMAArea + $A0 CMP #$F8 - BEQ loc_BANKC_87D2 + BEQ CastRoll_CrawlContinue_UpdateSprite3 DEC CastRollSprite2C CMP #$F9 - BNE loc_BANKC_87A4 + BNE CastRoll_CrawlContinue_Sprite2Row3_Update LDA CastRollSprite2C CMP #$D0 - BNE loc_BANKC_87D2 + BNE CastRoll_CrawlContinue_UpdateSprite3 LDY CastRollSpriteIndex LDA CastRollSpriteOffset, Y STA CastRollSpriteCounter3 -loc_BANKC_87A4: +CastRoll_CrawlContinue_Sprite2Row3_Update: LDA CastRollSprite2C CMP #$10 - BNE loc_BANKC_87BA + BNE CastRoll_CrawlContinue_Sprite2Row3_Hide -loc_BANKC_87AA: LDA #$00 STA CastRollSpriteActive2 LDA CastRollSpriteIndex CMP #$FF - BNE loc_BANKC_87B8 + BNE CastRoll_CrawlContinue_Sprite2Row3_Deactivate LDA #$FF STA CastRollSpriteActive2 -loc_BANKC_87B8: +CastRoll_CrawlContinue_Sprite2Row3_Deactivate: LDA #$F8 -loc_BANKC_87BA: +CastRoll_CrawlContinue_Sprite2Row3_Hide: STA SpriteDMAArea + $A0 STA SpriteDMAArea + $A4 STA SpriteDMAArea + $A8 @@ -1095,109 +1093,108 @@ loc_BANKC_87BA: STA SpriteDMAArea + $B8 STA SpriteDMAArea + $BC -loc_BANKC_87D2: +CastRoll_CrawlContinue_UpdateSprite3: LDA CastRollThrottle AND #$01 - BNE loc_BANKC_87DB + BNE CastRoll_CrawlContinue_Sprite3Row1 - JMP locret_BANKC_8897 + JMP CastRoll_CrawlContinue_Exit -; --------------------------------------------------------------------------- -loc_BANKC_87DB: +CastRoll_CrawlContinue_Sprite3Row1: LDA SpriteDMAArea + $C0 CMP #$F8 - BEQ loc_BANKC_87FB + BEQ CastRoll_CrawlContinue_Sprite3Row2 LDA CastRollSprite3A SEC SBC #$01 CMP #$10 - BNE loc_BANKC_87ED + BNE CastRoll_CrawlContinue_Sprite3Row1_Update LDA #$F8 -loc_BANKC_87ED: +CastRoll_CrawlContinue_Sprite3Row1_Update: STA CastRollSprite3A STA SpriteDMAArea + $C0 STA SpriteDMAArea + $C4 STA SpriteDMAArea + $C8 STA SpriteDMAArea + $CC -loc_BANKC_87FB: +CastRoll_CrawlContinue_Sprite3Row2: LDA SpriteDMAArea + $D0 CMP #$F8 - BEQ loc_BANKC_8822 + BEQ CastRoll_CrawlContinue_Sprite3Row3 DEC CastRollSprite3B CMP #$F9 - BNE loc_BANKC_880E + BNE CastRoll_CrawlContinue_Sprite3Row2_Update LDA CastRollSprite3B CMP #$D0 - BNE loc_BANKC_8822 + BNE CastRoll_CrawlContinue_Sprite3Row3 -loc_BANKC_880E: +CastRoll_CrawlContinue_Sprite3Row2_Update: LDA CastRollSprite3B CMP #$10 - BNE loc_BANKC_8816 + BNE CastRoll_CrawlContinue_Sprite3Row2_Hide LDA #$F8 -loc_BANKC_8816: +CastRoll_CrawlContinue_Sprite3Row2_Hide: STA SpriteDMAArea + $D0 STA SpriteDMAArea + $D4 STA SpriteDMAArea + $D8 STA SpriteDMAArea + $DC -loc_BANKC_8822: +CastRoll_CrawlContinue_Sprite3Row3: LDA SpriteDMAArea + $E0 CMP #$F8 - BEQ locret_BANKC_8897 + BEQ CastRoll_CrawlContinue_Exit DEC CastRollSprite3C CMP #$F9 - BNE loc_BANKC_883C + BNE CastRoll_CrawlContinue_Sprite3Row3_Update LDA CastRollSprite3C CMP #$D0 - BNE locret_BANKC_8897 + BNE CastRoll_CrawlContinue_Exit LDY CastRollSpriteIndex LDA CastRollSpriteOffset, Y STA CastRollSpriteCounter1 -loc_BANKC_883C: +CastRoll_CrawlContinue_Sprite3Row3_Update: ; Is this Tryclyde? LDA CastRollSpriteIndex CMP #(CastRoll_SpritePointersLo - CastRoll_SpritePointersHi) - BNE loc_BANKC_884C + BNE CastRoll_CrawlContinue_Sprite3Row3_CheckEnd ; And is the last row at the right spot? LDA CastRollSprite3C CMP #$B8 - BNE loc_BANKC_884C + BNE CastRoll_CrawlContinue_Sprite3Row3_CheckEnd ; Add "TRICLYDE" to the crawl LDA #$01 STA CastRollLastSprite -loc_BANKC_884C: +CastRoll_CrawlContinue_Sprite3Row3_CheckEnd: LDA CastRollSprite3C CMP #$10 - BNE loc_BANKC_8862 + BNE CastRoll_CrawlContinue_Sprite3Row3_Hide LDA #$00 STA CastRollSpriteActive3 LDA CastRollSpriteIndex CMP #$FF - BNE loc_BANKC_8860 + BNE CastRoll_CrawlContinue_Sprite3Row3_Deactivate LDA #$FF STA CastRollSpriteActive3 -loc_BANKC_8860: +CastRoll_CrawlContinue_Sprite3Row3_Deactivate: LDA #$F8 -loc_BANKC_8862: +CastRoll_CrawlContinue_Sprite3Row3_Hide: STA SpriteDMAArea + $E0 STA SpriteDMAArea + $E4 STA SpriteDMAArea + $E8 @@ -1207,7 +1204,7 @@ loc_BANKC_8862: STA SpriteDMAArea + $F8 STA SpriteDMAArea + $FC LDA CastRollLastSprite - BEQ locret_BANKC_8897 + BEQ CastRoll_CrawlContinue_Exit ; Other sprites include their own text label, but since Tryclyde is taller ; than the rest, his label is drawn separately @@ -1226,12 +1223,14 @@ CastRoll_TriclydeTextLoop: LDA #$FF STA CastRollSpriteIndex -locret_BANKC_8897: +CastRoll_CrawlContinue_Exit: RTS -; --------------------------------------------------------------------------- -CastRoll_QueueWart: +; +; Loads Wart's CHR data and sets up the initial sprite positions +; +CastRoll_WartSetup: LDY #$48 STY SpriteCHR1 INY @@ -1242,25 +1241,25 @@ CastRoll_QueueWart: STY SpriteCHR4 LDY #$5B -loc_BANKC_88AB: +CastRoll_WartSetup_CopyWartSprite_Loop: LDA CastRoll_Wart, Y STA SpriteDMAArea + $40, Y DEY - BPL loc_BANKC_88AB + BPL CastRoll_WartSetup_CopyWartSprite_Loop INC CastRollSequenceIndex LDY #$00 LDX #$0F LDA #$C0 -loc_BANKC_88BC: +CastRoll_WartSetup_SetSpriteY_Loop: STA SpriteDMAArea + 1, Y INY INY INY INY DEX - BPL loc_BANKC_88BC + BPL CastRoll_WartSetup_SetSpriteY_Loop LDA #$D0 STA CastRollSprite1A @@ -1274,32 +1273,33 @@ loc_BANKC_88BC: RTS -CastRoll_WartLaugh: +; +; Scrolls Wart's sprites up the screen +; +CastRoll_WartScroll: LDA CastRollThrottle AND #$01 - BNE loc_BANKC_88E0 + BNE CastRoll_WartScroll_UpdateSprites - JMP loc_BANKC_898D + JMP CastRoll_WartScroll_Exit -; --------------------------------------------------------------------------- -loc_BANKC_88E0: +CastRoll_WartScroll_UpdateSprites: LDA SpriteDMAArea + $40 CMP #$F8 - BEQ loc_BANKC_8906 + BEQ CastRoll_WartScroll_CheckRow2 LDA CastRollSprite1A SEC SBC #$01 CMP #$50 - BNE loc_BANKC_88F5 + BNE CastRoll_WartScroll_UpdateRow1 INC CastRollSequenceIndex - JMP loc_BANKC_898D + JMP CastRoll_WartScroll_Exit -; --------------------------------------------------------------------------- -loc_BANKC_88F5: +CastRoll_WartScroll_UpdateRow1: STA CastRollSprite1A STA SpriteDMAArea + $40 STA SpriteDMAArea + $44 @@ -1307,81 +1307,81 @@ loc_BANKC_88F5: STA SpriteDMAArea + $4C STA SpriteDMAArea + $50 -loc_BANKC_8906: +CastRoll_WartScroll_CheckRow2: LDA SpriteDMAArea + $54 CMP #$F8 - BEQ loc_BANKC_8930 + BEQ CastRoll_WartScroll_CheckRow3 DEC CastRollSprite1B CMP #$F9 - BNE loc_BANKC_8919 + BNE CastRoll_WartScroll_UpdateRow2 LDA CastRollSprite1B CMP #$D0 - BNE loc_BANKC_8930 + BNE CastRoll_WartScroll_CheckRow3 -loc_BANKC_8919: +CastRoll_WartScroll_UpdateRow2: LDA CastRollSprite1B CMP #$10 - BNE loc_BANKC_8921 + BNE CastRoll_WartScroll_HideRow2 LDA #$F8 -loc_BANKC_8921: +CastRoll_WartScroll_HideRow2: STA SpriteDMAArea + $54 STA SpriteDMAArea + $58 STA SpriteDMAArea + $5C STA SpriteDMAArea + $60 STA SpriteDMAArea + $64 -loc_BANKC_8930: +CastRoll_WartScroll_CheckRow3: LDA SpriteDMAArea + $68 CMP #$F8 - BEQ loc_BANKC_895A + BEQ CastRoll_WartScroll_CheckRow4 DEC CastRollSprite1C CMP #$F9 - BNE loc_BANKC_8943 + BNE CastRoll_WartScroll_UpdateRow3 LDA CastRollSprite1C CMP #$D0 - BNE loc_BANKC_895A + BNE CastRoll_WartScroll_CheckRow4 -loc_BANKC_8943: +CastRoll_WartScroll_UpdateRow3: LDA CastRollSprite1C CMP #$10 - BNE loc_BANKC_894B + BNE CastRoll_WartScroll_HideRow3 LDA #$F8 -loc_BANKC_894B: +CastRoll_WartScroll_HideRow3: STA SpriteDMAArea + $68 STA SpriteDMAArea + $6C STA SpriteDMAArea + $70 STA SpriteDMAArea + $74 STA SpriteDMAArea + $78 -loc_BANKC_895A: +CastRoll_WartScroll_CheckRow4: LDA SpriteDMAArea + $7C CMP #$F8 - BEQ loc_BANKC_898D + BEQ CastRoll_WartScroll_Exit DEC CastRollSprite2A CMP #$F9 - BNE loc_BANKC_896D + BNE CastRoll_WartScroll_UpdateRow4 LDA CastRollSprite2A CMP #$D0 - BNE loc_BANKC_898D + BNE CastRoll_WartScroll_Exit -loc_BANKC_896D: +CastRoll_WartScroll_UpdateRow4: LDA CastRollSprite2A CMP #$10 - BNE loc_BANKC_8975 + BNE CastRoll_WartScroll_HideRow4 LDA #$F8 -loc_BANKC_8975: +CastRoll_WartScroll_HideRow4: STA SpriteDMAArea + $7C STA SpriteDMAArea + $80 STA SpriteDMAArea + $84 @@ -1391,7 +1391,7 @@ loc_BANKC_8975: STA SpriteDMAArea + $94 STA SpriteDMAArea + $98 -loc_BANKC_898D: +CastRoll_WartScroll_Exit: LDA #$00 STA CastRoll_TempA STA CastRoll_Temp9 @@ -1434,30 +1434,30 @@ WartLaugh_Frame2: .db $9C -loc_BANKC_89B6: +CastRoll_WartLaugh: DEC CastRoll_Temp9 - BPL locret_BANKC_8A00 + BPL CastRoll_WartLaugh_Exit LDA #$08 STA CastRoll_Temp9 DEC CastRoll_TempA1 - BPL loc_BANKC_89CD + BPL CastRoll_WartLaugh_CheckFrame INC CastRollSequenceIndex LDA #$00 STA CastRollTimer STA CastRollFadePaletteIndex - JMP locret_BANKC_8A00 + JMP CastRoll_WartLaugh_Exit -loc_BANKC_89CD: +CastRoll_WartLaugh_CheckFrame: LDA CastRoll_TempA AND #$01 - BNE loc_BANKC_89EB + BNE CastRoll_WartLaugh_Frame2 LDY #$00 LDX #$00 -loc_BANKC_89D7: +CastRoll_WartLaugh_Frame1_Loop: INC CastRoll_TempA LDA WartLaugh_Frame1, X STA SpriteDMAArea + $41, Y @@ -1467,18 +1467,17 @@ loc_BANKC_89D7: INY INX CPX #$0F - BNE loc_BANKC_89D7 + BNE CastRoll_WartLaugh_Frame1_Loop - JMP locret_BANKC_8A00 + JMP CastRoll_WartLaugh_Exit -; --------------------------------------------------------------------------- -loc_BANKC_89EB: +CastRoll_WartLaugh_Frame2: INC CastRoll_TempA LDX #$00 LDY #$00 -loc_BANKC_89F1: +CastRoll_WartLaugh_Frame2_Loop: LDA WartLaugh_Frame2, X STA SpriteDMAArea + $41, Y INY @@ -1487,9 +1486,9 @@ loc_BANKC_89F1: INY INX CPX #$F - BNE loc_BANKC_89F1 + BNE CastRoll_WartLaugh_Frame2_Loop -locret_BANKC_8A00: +CastRoll_WartLaugh_Exit: RTS @@ -1499,9 +1498,12 @@ CastRoll_PaletteFadeOut: .db $12 -loc_BANKC_8A04: +; +; Fades the palette to make Wart disappear +; +CastRoll_DoPaletteFadeOut: DEC CastRollTimer - BPL locret_BANKC_8A36 + BPL CastRoll_DoPaletteFadeOut_Exit LDA #$10 STA CastRollTimer @@ -1519,44 +1521,49 @@ loc_BANKC_8A04: INC CastRollFadePaletteIndex LDA CastRollFadePaletteIndex CMP #$03 - BNE locret_BANKC_8A36 + BNE CastRoll_DoPaletteFadeOut_Exit INC CastRollSequenceIndex LDA #$16 STA CastRollTimer -locret_BANKC_8A36: +CastRoll_DoPaletteFadeOut_Exit: RTS -; --------------------------------------------------------------------------- -loc_BANKC_8A37: +; +; Hides the cast roll sprites to prepare for the "The End" animation +; +CastRoll_HideSprites: DEC CastRollTimer - BPL locret_BANKC_8A51 + BPL CastRoll_HideSprites_Exit LDX #$16 LDY #$00 LDA #$F8 -loc_BANKC_8A41: +CastRoll_HideSprites_Loop: STA SpriteDMAArea + $40, Y INY INY INY INY DEX - BPL loc_BANKC_8A41 + BPL CastRoll_HideSprites_Loop LDA #$30 STA CastRollTimer -loc_BANKC_8A4F: +CastRoll_HideSprites_NextSequence: INC CastRollSequenceIndex -locret_BANKC_8A51: +CastRoll_HideSprites_Exit: RTS +; +; Pauses before starting the "The End" animation +; CastRoll_TheEndDelay: DEC CastRollTimer BPL CastRoll_TheEndDelay_Exit @@ -1586,6 +1593,9 @@ CastRoll_TheEndDelay_Exit: RTS +; +; Plays the "The End" animation +; CastRoll_TheEndAnimation: CastRoll_TheEndAnimation_The: LDA TheEndScriptCounter @@ -1740,10 +1750,10 @@ CastRoll_SpritePointersLo: CastRoll_Mario: - .db $D0, $3E, $00, $30 - .db $D0, $00, $00, $38 ; 4 - .db $D0, $02, $00, $40 ; 8 - .db $D0, $3E, $00, $48 ; $C + .db $D0, $3E, $00, $30 ; $00 + .db $D0, $00, $00, $38 ; $04 + .db $D0, $02, $00, $40 ; $08 + .db $D0, $3E, $00, $48 ; $0C .db $F9, $3E, $00, $30 ; $10 .db $F9, $04, $00, $38 ; $14 .db $F9, $06, $00, $40 ; $18 @@ -1757,10 +1767,10 @@ CastRoll_Mario: .db $F9, $3E, $00, $54 ; $38 .db $F9, $3E, $00, $5C ; $3C CastRoll_Luigi: - .db $D0, $3E, $00, $30 - .db $D0, $08, $00, $38 ; 4 - .db $D0, $0A, $00, $40 ; 8 - .db $D0, $3E, $00, $48 ; $C + .db $D0, $3E, $00, $30 ; $00 + .db $D0, $08, $00, $38 ; $04 + .db $D0, $0A, $00, $40 ; $08 + .db $D0, $3E, $00, $48 ; $0C .db $F9, $3E, $00, $30 ; $10 .db $F9, $0C, $00, $38 ; $14 .db $F9, $0E, $00, $40 ; $18 @@ -1774,10 +1784,10 @@ CastRoll_Luigi: .db $F9, $3E, $00, $54 ; $38 .db $F9, $3E, $00, $5C ; $3C CastRoll_Princess: - .db $D0, $3E, $00, $30 - .db $D0, $10, $00, $38 ; 4 - .db $D0, $12, $00, $40 ; 8 - .db $D0, $3E, $00, $48 ; $C + .db $D0, $3E, $00, $30 ; $00 + .db $D0, $10, $00, $38 ; $04 + .db $D0, $12, $00, $40 ; $08 + .db $D0, $3E, $00, $48 ; $0C .db $F9, $3E, $00, $30 ; $10 .db $F9, $14, $00, $38 ; $14 .db $F9, $16, $00, $40 ; $18 @@ -1808,10 +1818,10 @@ CastRoll_Toad: .db $F9, $3E, $00, $50 ; $38 .db $F9, $3E, $00, $58 ; $3C CastRoll_Shyguy: - .db $D0, $3E, $00, $30 - .db $D0, $3E, $00, $38 ; 4 - .db $D0, $3E, $00, $40 ; 8 - .db $D0, $3E, $00, $48 ; $C + .db $D0, $3E, $00, $30 ; $00 + .db $D0, $3E, $00, $38 ; $04 + .db $D0, $3E, $00, $40 ; $08 + .db $D0, $3E, $00, $48 ; $0C .db $F9, $3E, $00, $30 ; $10 .db $F9, $20, $00, $38 ; $14 .db $F9, $22, $00, $40 ; $18 @@ -1825,10 +1835,10 @@ CastRoll_Shyguy: .db $F9, $CC, $00, $50 ; $38 .db $F9, $3E, $00, $58 ; $3C CastRoll_Snifit: - .db $D0, $3E, $00, $30 - .db $D0, $3E, $00, $38 ; 4 - .db $D0, $3E, $00, $40 ; 8 - .db $D0, $3E, $00, $48 ; $C + .db $D0, $3E, $00, $30 ; $00 + .db $D0, $3E, $00, $38 ; $04 + .db $D0, $3E, $00, $40 ; $08 + .db $D0, $3E, $00, $48 ; $0C .db $F9, $3E, $00, $30 ; $10 .db $F9, $24, $00, $38 ; $14 .db $F9, $26, $00, $40 ; $18 @@ -1842,10 +1852,10 @@ CastRoll_Snifit: .db $F9, $F6, $00, $50 ; $38 .db $F9, $3E, $00, $58 ; $3C CastRoll_Ninji: - .db $D0, $3E, $00, $30 - .db $D0, $3E, $00, $38 ; 4 - .db $D0, $3E, $00, $40 ; 8 - .db $D0, $3E, $00, $48 ; $C + .db $D0, $3E, $00, $30 ; $00 + .db $D0, $3E, $00, $38 ; $04 + .db $D0, $3E, $00, $40 ; $08 + .db $D0, $3E, $00, $48 ; $0C .db $F9, $3E, $00, $30 ; $10 .db $F9, $28, $00, $38 ; $14 .db $F9, $2A, $00, $40 ; $18 @@ -1859,10 +1869,10 @@ CastRoll_Ninji: .db $F9, $3E, $00, $54 ; $38 .db $F9, $3E, $00, $5C ; $3C CastRoll_Beezo: - .db $D0, $3E, $00, $30 - .db $D0, $3E, $00, $38 ; 4 - .db $D0, $3E, $00, $40 ; 8 - .db $D0, $3E, $00, $48 ; $C + .db $D0, $3E, $00, $30 ; $00 + .db $D0, $3E, $00, $38 ; $04 + .db $D0, $3E, $00, $40 ; $08 + .db $D0, $3E, $00, $48 ; $0C .db $F9, $3E, $00, $30 ; $10 .db $F9, $2C, $00, $38 ; $14 .db $F9, $2E, $00, $40 ; $18 From 86fafdf30ce7c3b5c1e340c3e2dc339ba35f3569 Mon Sep 17 00:00:00 2001 From: Keith McKnight Date: Mon, 29 Dec 2025 22:54:24 -0500 Subject: [PATCH 14/17] do you even lift --- src/prg-0-1.asm | 33 +++---- src/prg-2-3.asm | 231 +++++++++++++++++++++++++++--------------------- src/ram.asm | 9 +- 3 files changed, 155 insertions(+), 118 deletions(-) diff --git a/src/prg-0-1.asm b/src/prg-0-1.asm index 1f14dea..f43e81c 100644 --- a/src/prg-0-1.asm +++ b/src/prg-0-1.asm @@ -1918,17 +1918,20 @@ IFDEF CONTROLLER_2_DEBUG JSR CheckPlayer2Joypad ENDIF - LDA PlayerState ; Handles player states? + LDA PlayerState CMP #PlayerState_Lifting - BCS loc_BANK0_8A26 ; If the player is changing size, just handle that + BCS HandlePlayerState_Route - LDA #$00 ; Check if the player needs to change size + ; State is normal or climbing. + ; Before we handle the state, first determine if the player is changing size + LDA #$00 LDY #$10 CPY PlayerHealth ROL A EOR PlayerCurrentSize - BEQ loc_BANK0_8A26 + BEQ HandlePlayerState_Route + ; Handle the grow or shrinking animation LDY PlayerCurrentSize LDA GrowShrinkSFXIndexes, Y STA SoundEffectQueue2 @@ -1937,11 +1940,12 @@ ENDIF LDA #PlayerState_ChangingSize STA PlayerState -loc_BANK0_8A26: +HandlePlayerState_Route: LDA #ObjAttrib_Palette0 STA PlayerAttributes + LDA PlayerState - JSR JumpToTableAfterJump ; Player state handling? + JSR JumpToTableAfterJump .dw HandlePlayerState_Normal ; Normal .dw HandlePlayerState_Climbing ; Climbing @@ -2031,7 +2035,6 @@ SetGameModeAfterDeath: locret_BANK0_8A86: RTS -; --------------------------------------------------------------------------- HandlePlayerState_Lifting: LDA PlayerStateTimer @@ -2040,20 +2043,21 @@ HandlePlayerState_Lifting: LDX ObjectBeingCarriedIndex LDY ObjectBeingCarriedTimer, X CPY #$02 - BCC loc_BANK0_8ABB + BCC HandlePlayerState_Lifting_ObjectIsAloft CPY #$07 - BNE loc_BANK0_8A9D + BNE HandlePlayerState_DecrementCarryTimer LDA #DPCM_ItemPull STA DPCMQueue -loc_BANK0_8A9D: +HandlePlayerState_DecrementCarryTimer: DEC ObjectBeingCarriedTimer, X LDA PlayerLiftFrames, Y STA PlayerAnimationFrame + LDA EnemyState, X - CMP #$06 + CMP #EnemyState_Sand BEQ loc_BANK0_8AB0 LDA ObjectType, X @@ -2071,13 +2075,12 @@ loc_BANK0_8AB8: STA PlayerStateTimer RTS -; --------------------------------------------------------------------------- -loc_BANK0_8ABB: + ; When the object is fully lifted, reset the player back to a normal state +HandlePlayerState_Lifting_ObjectIsAloft: + ; A = $01 from PlayerStateTimer STA PlayerState INC PlayerInAir - -loc_BANK0_8ABF: INC PlayerDucking IFDEF PLAYER_HITBOX LDA PlayerDucking diff --git a/src/prg-2-3.asm b/src/prg-2-3.asm index 7b81e12..8a44b83 100644 --- a/src/prg-2-3.asm +++ b/src/prg-2-3.asm @@ -44,7 +44,6 @@ AreaMainRoutine_NoTransition: JMP AreaMainRoutine_Gameplay -; --------------------------------------------------------------------------- AreaInitialization: INC AreaInitialized @@ -627,23 +626,29 @@ CheckObjectHorizontalSpawnBoundaries_InitializePage_CreateObject: CheckObjectVerticalSpawnBoundaries: + ; First, we need to determine which boundary to check. + ; By default, check each one on alternatiing frames. LDA byte_RAM_10 AND #$01 TAY INY + + ; But if we're already scrolling... LDA NeedsScroll - BEQ loc_BANK2_82FC + BEQ CheckObjectVerticalSpawnBoundaries_CalculateBoundary + ; ...just use that direction instead AND #$03 EOR #$03 TAY -loc_BANK2_82FC: +CheckObjectVerticalSpawnBoundaries_CalculateBoundary: LDA ScreenYLo CLC ADC SpawnBoundaryOffsets - 1, Y AND #$F0 STA byte_RAM_5 + LDA ScreenYHi ADC SpawnBoundaryOffsets + 1, Y STA byte_RAM_6 @@ -1152,16 +1157,19 @@ HandleEnemyState_BlockFizzle: LSR A AND #$01 STA EnemyMovementDirection, X + LDA #ObjAttrib_Palette1 ; also SpriteFlags46E_Damage STA ObjectAttributes, X STA EnemyArray_46E, X + + ; Choose tile baed on object timer LDA #$3C CPY #$0C - BCC loc_BANK2_85AC + BCC HandleEnemyState_BlockFizzle_DrawSprite LDA #$3E -loc_BANK2_85AC: +HandleEnemyState_BlockFizzle_DrawSprite: JMP RenderSprite_DrawObject @@ -1176,20 +1184,22 @@ HandleEnemyState_Sinking: JSR EnemyBehavior_CheckDamagedInterrupt LDA ObjectBeingCarriedTimer, X - BEQ loc_BANK2_85C1 + BEQ HandleEnemyState_Sinking_NotCarried LDA #EnemyState_Alive STA EnemyState, X RTS -loc_BANK2_85C1: +HandleEnemyState_Sinking_NotCarried: LDA ObjectTimer1, X BEQ HandleEnemyState_Exit LDA ObjectType, X CMP #Enemy_VegetableSmall - BCS loc_BANK2_85E1 + BCS HandleEnemyState_Sinking_Item + + ; If it's not an item, it will shake and struggle in panic while sinking JSR IncrementAnimationTimerBy2 @@ -1205,7 +1215,7 @@ loc_BANK2_85C1: ADC #$01 STA EnemyMovementDirection, X -loc_BANK2_85E1: +HandleEnemyState_Sinking_Item: JSR sub_BANK2_9486 JMP CheckObjectCollision @@ -1252,7 +1262,7 @@ HandleEnemyState_BombExploding: BMI HandleEnemyState_DrawExplosion TAY - JSR ExplodeNearbyBlocks + JSR ExplodeNearbyBlock HandleEnemyState_DrawExplosion: LDA #$60 @@ -1287,9 +1297,8 @@ HandleEnemyState_DrawExplosion_Loop: LDX byte_RAM_12 JMP CheckObjectCollision -; --------------------------------------------------------------------------- -ExplodeNearbyBlocks_Exit: +ExplodeNearbyBlock_Exit: RTS @@ -1342,22 +1351,27 @@ ExplosionTileLayoutHi: .db >(SubAreaTileLayout - $100) ; -; Blow up blocks near this object +; Blow up a single block near this object +; +; This is called multiple times sequence with different index offets to destroy +; multiple blocks within the blast zone ; ; Input ; X = enemy slot ; Y = index ; -ExplodeNearbyBlocks: +ExplodeNearbyBlock: LDA ObjectXLo, X CLC ADC ExplosionOffsetXLo, Y STA byte_RAM_C + LDA ObjectXHi, X ADC ExplosionOffsetXHi, Y STA byte_RAM_D + CMP #$0B - BCS ExplodeNearbyBlocks_Exit + BCS ExplodeNearbyBlock_Exit LDA ObjectYLo, X ADC ExplosionOffsetYLo, Y @@ -1368,10 +1382,10 @@ ExplodeNearbyBlocks: ADC ExplosionOffsetYHi, Y STA byte_RAM_F CMP #$0A - BCS ExplodeNearbyBlocks_Exit + BCS ExplodeNearbyBlock_Exit LDY IsHorizontalLevel - BNE loc_BANK2_86BD + BNE ExplodeNearbyBlock_ConvertHorizontalPosition ; Vertical level @@ -1388,11 +1402,11 @@ ExplodeNearbyBlocks: ; Determine vertical page LDY #$FF -ExplodeNearbyBlocks_VerticalPageLoop: +ExplodeNearbyBlock_VerticalPageLoop: SEC SBC #$0F INY - BCS ExplodeNearbyBlocks_VerticalPageLoop + BCS ExplodeNearbyBlock_VerticalPageLoop STY byte_RAM_D @@ -1404,7 +1418,7 @@ ExplodeNearbyBlocks_VerticalPageLoop: ASL A STA byte_RAM_E -loc_BANK2_86BD: +ExplodeNearbyBlock_ConvertHorizontalPosition: ; Convert horizontal pixel position to tile position LDA byte_RAM_C LSR A @@ -1421,20 +1435,20 @@ loc_BANK2_86BD: LDY #$00 LDA ScreenBoundaryLeftHi CMP #$0A - BNE loc_BANK2_86D5 + BNE ExplodeNearbyBlock_SetupTileLayoutAddress ; We're in a subarea, treat it as page 0 STY byte_RAM_D INY -loc_BANK2_86D5: +ExplodeNearbyBlock_SetupTileLayoutAddress: LDA #$10 STA byte_RAM_7 LDA ExplosionTileLayoutHi, Y STA byte_RAM_8 LDY byte_RAM_D -loc_BANK2_86E0: +ExplodeNearbyBlock_CalculateTileLayoutPage: LDA byte_RAM_7 CLC ADC #$F0 @@ -1443,23 +1457,23 @@ loc_BANK2_86E0: ADC #$00 STA byte_RAM_8 DEY - BPL loc_BANK2_86E0 + BPL ExplodeNearbyBlock_CalculateTileLayoutPage LDY byte_RAM_5 LDA (byte_RAM_7), Y CMP #BackgroundTile_BombableBrick - BEQ ExplodeNearbyBlocks_DestroyBlock + BEQ ExplodeNearbyBlock_DestroyBlock CMP #BackgroundTile_DiggableSand - BEQ ExplodeNearbyBlocks_DestroyBlock + BEQ ExplodeNearbyBlock_DestroyBlock CMP #BackgroundTile_JarSmall - BEQ ExplodeNearbyBlocks_DestroyBlock + BEQ ExplodeNearbyBlock_DestroyBlock RTS -ExplodeNearbyBlocks_DestroyBlock: +ExplodeNearbyBlock_DestroyBlock: LDA #BackgroundTile_Sky STA (byte_RAM_7), Y @@ -1469,11 +1483,11 @@ ExplodeNearbyBlocks_DestroyBlock: ASL A ASL A LDY IsHorizontalLevel - BNE ExplodeNearbyBlocks_DestroyBlock_UpdatePPU + BNE ExplodeNearbyBlock_DestroyBlock_UpdatePPU ASL A -ExplodeNearbyBlocks_DestroyBlock_UpdatePPU: +ExplodeNearbyBlock_DestroyBlock_UpdatePPU: PHA LDA byte_RAM_E STA byte_RAM_2 @@ -1525,26 +1539,26 @@ ExplodeNearbyBlocks_DestroyBlock_UpdatePPU: ; Look for a slot to create a block fizzle sprite LDX #$08 -ExplodeNearbyBlocks_FindSprite_Loop: +ExplodeNearbyBlock_FindSprite_Loop: LDA EnemyState, X - BEQ ExplodeNearbyBlocks_CreateSprite + BEQ ExplodeNearbyBlock_CreateSprite DEX - BPL ExplodeNearbyBlocks_FindSprite_Loop + BPL ExplodeNearbyBlock_FindSprite_Loop - BMI ExplodeNearbyBlocks_CreateSprite_Exit + BMI ExplodeNearbyBlock_CreateSprite_Exit -ExplodeNearbyBlocks_CreateSprite: +ExplodeNearbyBlock_CreateSprite: LDA byte_RAM_C AND #$F0 STA ObjectXLo, X LDA byte_RAM_D LDY IsHorizontalLevel - BNE ExplodeNearbyBlocks_CreateSprite_Position + BNE ExplodeNearbyBlock_CreateSprite_Position TYA -ExplodeNearbyBlocks_CreateSprite_Position: +ExplodeNearbyBlock_CreateSprite_Position: STA ObjectXHi, X LDA byte_RAM_B STA ObjectYLo, X @@ -1554,7 +1568,7 @@ ExplodeNearbyBlocks_CreateSprite_Position: JSR SetBlockFizzle -ExplodeNearbyBlocks_CreateSprite_Exit: +ExplodeNearbyBlock_CreateSprite_Exit: ; Restore next object index LDX byte_RAM_12 @@ -1575,14 +1589,14 @@ HandleEnemyState_PuffOfSmoke: LDA ObjectAttributes, X ORA #ObjAttrib_Mirrored STA ObjectAttributes, X + + ; Animate until the timer expires LDA ObjectTimer1, X - BNE loc_BANK2_87AC + BNE HandleEnemyState_PuffOfSmoke_Animate JMP HandleEnemyState_PuffOfSmoke_CheckDestroy -; --------------------------------------------------------------------------- - -loc_BANK2_87AC: +HandleEnemyState_PuffOfSmoke_Animate: LSR A LSR A LSR A @@ -1598,16 +1612,17 @@ loc_BANK2_87AC: BNE HandleEnemyState_PuffOfSmoke_Exit LDY #$22 + LDA ObjectType, X CMP #Enemy_Clawgrip - BNE loc_BANK2_87CA + BNE HandleEnemyState_PuffOfSmoke_SetDoorYPosition ; Clawgrip special hack: ; Move the "Draw the door" PPU command ; up 8 tile rows ($100) to be on the platform DEY -loc_BANK2_87CA: +HandleEnemyState_PuffOfSmoke_SetDoorYPosition: STY PPUBuffer_EndOfLevelDoor STY PPUBuffer_EndOfLevelDoor + $07 INY @@ -1615,7 +1630,7 @@ loc_BANK2_87CA: STY PPUBuffer_EndOfLevelDoor + $17 LDY #$03 -loc_BANK2_87D9: +HandleEnemyState_PuffOfSmoke_UpdateDoorPPUBuffer: ; Boss door PPU updates LDA EndOfLevelDoorPage, X AND #%00000001 @@ -1623,17 +1638,17 @@ loc_BANK2_87D9: ASL A EOR #%00000100 LDX IsHorizontalLevel - BNE loc_BANK2_87E7 + BNE HandleEnemyState_PuffOfSmoke_UpdateDoorPPUBuffer_Horizontal ASL A -loc_BANK2_87E7: +HandleEnemyState_PuffOfSmoke_UpdateDoorPPUBuffer_Horizontal: LDX EndOfLevelDoorRowOffsets, Y ORA PPUBuffer_EndOfLevelDoor, X STA PPUBuffer_EndOfLevelDoor, X LDX byte_RAM_12 DEY - BPL loc_BANK2_87D9 + BPL HandleEnemyState_PuffOfSmoke_UpdateDoorPPUBuffer LDA #$14 STA ScreenUpdateIndex @@ -1643,7 +1658,7 @@ loc_BANK2_87E7: LDA #$10 STA byte_RAM_0 -loc_BANK2_8804: +HandleEnemyState_PuffOfSmoke_CalculateDoorTileAddress: LDA byte_RAM_0 CLC ADC #$F0 @@ -1652,7 +1667,7 @@ loc_BANK2_8804: ADC #$00 STA byte_RAM_1 DEY - BPL loc_BANK2_8804 + BPL HandleEnemyState_PuffOfSmoke_CalculateDoorTileAddress LDA ObjectType, X CMP #Enemy_Clawgrip @@ -1710,7 +1725,7 @@ HandleEnemyState_Sand: LDA #$12 STA ObjectAttributes, X LDA ObjectTimer1, X - BEQ loc_BANK2_8888 + BEQ HandleEnemyState_Sand_TimerExpired LDA #$F8 STA ObjectYVelocity, X @@ -1719,7 +1734,7 @@ HandleEnemyState_Sand: LDA #$B2 LDY ObjectTimer1, X CPY #$10 - BCS loc_BANK2_8885 + BCS HandleEnemyState_Sand_DrawSprite LDA #SpriteFlags46E_MirrorAnimation STA EnemyArray_46E, X @@ -1732,19 +1747,18 @@ HandleEnemyState_Sand: LDA #$B4 -loc_BANK2_8885: +HandleEnemyState_Sand_DrawSprite: JMP RenderSprite_DrawObject -; --------------------------------------------------------------------------- -loc_BANK2_8888: +HandleEnemyState_Sand_TimerExpired: CPX ObjectBeingCarriedIndex - BNE loc_BANK2_8891 + BNE HandleEnemyState_Sand_Destroy LDA #$00 STA HoldingItem -loc_BANK2_8891: +HandleEnemyState_Sand_Destroy: JMP EnemyDestroy @@ -1991,136 +2005,154 @@ EnemyDestroy_Exit: RTS -; --------------------------------------------------------------------------- - +; +; Standard enemy behavior routine +; HandleEnemyState_Alive: LDA #$01 STA ObjectNonSticky, X + LDY ObjectProjectileTimer, X DEY CPY #$1F - BCS loc_BANK2_89C9 + BCS HandleEnemyState_Alive_AfterProjectileTimer INC ObjectProjectileTimer, X -loc_BANK2_89C9: +HandleEnemyState_Alive_AfterProjectileTimer: JSR HandleEnemyScreenBounds + ; Time-out while player is changing size LDA PlayerState CMP #PlayerState_ChangingSize - BEQ loc_BANK2_89E2 + BEQ HandleEnemyState_Alive_Pause + ; While in a screen interval scroll, render the enemy without behavior LDA NeedsScroll AND #%00000100 - BNE loc_BANK2_8A07 + BNE HandleEnemyState_Alive_RenderOnly + ; Time-out while the stopwatch is active LDA StopwatchTimer - BNE loc_BANK2_89E2 + BNE HandleEnemyState_Alive_Pause + ; Otherwise run full behavior is the object is not stunned LDA ObjectStunTimer, X - BEQ loc_BANK2_8A0A + BEQ HandleEnemyState_Alive_RunBehavior -loc_BANK2_89E2: +HandleEnemyState_Alive_Pause: + ; Some objects don't actually honor the pause LDA ObjectType, X IFDEF REV_A + ; This fix prevents mini-Fryguy enemies from falling offscreen if they happen + ; to get hit while the character is taking damage. This bug would softlock + ; the game because it wouldn't count them as being defeated. CMP #Enemy_FryguySplit - BEQ loc_BANK2_8A0A + BEQ HandleEnemyState_Alive_RunBehavior ENDIF + ; Hearts ignore the pause CMP #Enemy_Heart - BEQ loc_BANK2_8A0A + BEQ HandleEnemyState_Alive_RunBehavior + ; Flying carpet does not ignore the pause CMP #Enemy_FlyingCarpet - BEQ loc_BANK2_89F0 + BEQ HandleEnemyState_Alive_EnemyObject + ; Projectile objects ignore the pause CMP #Enemy_VegetableSmall - BCS loc_BANK2_8A0A + BCS HandleEnemyState_Alive_RunBehavior -loc_BANK2_89F0: +HandleEnemyState_Alive_EnemyObject: + ; This subroutine will exit HandleEnemyState_Alive entirely if it needs to + ; set the enemy state to "dead" JSR EnemyBehavior_CheckDamagedInterrupt + ; If that didn't kill the enemy, handle projectile behavior LDA ObjectProjectileTimer, X - BEQ loc_BANK2_89FB + BEQ HandleEnemyState_Alive_CheckCarried JSR ApplyObjectMovement -loc_BANK2_89FB: +HandleEnemyState_Alive_CheckCarried: LDA ObjectBeingCarriedTimer, X - BEQ loc_BANK2_8A04 + BEQ HandleEnemyState_Alive_CheckCollision DEC ObjectAnimationTimer, X -loc_BANK2_8A01: JMP CarryObject -; --------------------------------------------------------------------------- - -loc_BANK2_8A04: +HandleEnemyState_Alive_CheckCollision: JSR CheckObjectCollision -loc_BANK2_8A07: +HandleEnemyState_Alive_RenderOnly: JMP RenderSprite -; --------------------------------------------------------------------------- -loc_BANK2_8A0A: +HandleEnemyState_Alive_RunBehavior: LDY #$01 LDA ObjectXVelocity, X - BEQ loc_BANK2_8A15 + BEQ HandleEnemyState_Alive_SetMovementDirection - BPL loc_BANK2_8A13 + BPL HandleEnemyState_Alive_SetMovementDirection_Right INY -loc_BANK2_8A13: +HandleEnemyState_Alive_SetMovementDirection_Right: STY EnemyMovementDirection, X -loc_BANK2_8A15: +HandleEnemyState_Alive_SetMovementDirection: LDY ObjectType, X LDA ObjectAttributeTable, Y AND #ObjAttrib_Palette0 | ObjAttrib_BehindBackground - BNE loc_BANK2_8A41 + BNE HandleEnemyState_Alive_UpdateAttributes + ; Unset the behind background flag LDA ObjectAttributes, X - AND #ObjAttrib_Palette | ObjAttrib_Horizontal | ObjAttrib_FrontFacing | ObjAttrib_Mirrored | ObjAttrib_16x32 | ObjAttrib_UpsideDown + AND #($FF ^ ObjAttrib_BehindBackground) STA ObjectAttributes, X + + ; If the object is being carried, we might put it behind the background LDA ObjectBeingCarriedTimer, X CMP #$02 - BCC loc_BANK2_8A41 + BCC HandleEnemyState_Alive_UpdateAttributes + ; If it's a Bob-omb on the ground, put it behind the background + ; (if the carry timer is 2 or higher) LDA ObjectType, X CMP #Enemy_BobOmb - BNE loc_BANK2_8A36 + BNE HandleEnemyState_Alive_CheckUpsideDownFlag LDA EnemyCollision, X AND #CollisionFlags_Down - BNE loc_BANK2_8A3B + BNE HandleEnemyState_Alive_SetBehindBackground -loc_BANK2_8A36: +HandleEnemyState_Alive_CheckUpsideDownFlag: + ; If the object is upside-down, put it behind the background LDA ObjectAttributeTable, Y - BPL loc_BANK2_8A41 + BPL HandleEnemyState_Alive_UpdateAttributes -loc_BANK2_8A3B: +HandleEnemyState_Alive_SetBehindBackground: LDA ObjectAttributes, X ORA #ObjAttrib_BehindBackground STA ObjectAttributes, X -loc_BANK2_8A41: +HandleEnemyState_Alive_UpdateAttributes: JSR RunEnemyBehavior LDA ObjectYHi, X - BMI loc_BANK2_8A50 + BMI HandleEnemyState_Alive_CheckCollisionAfterBehavior LDA SpriteTempScreenY CMP #$E8 - BCC loc_BANK2_8A50 + BCC HandleEnemyState_Alive_CheckCollisionAfterBehavior RTS ; --------------------------------------------------------------------------- -loc_BANK2_8A50: +HandleEnemyState_Alive_CheckCollisionAfterBehavior: JMP CheckObjectCollision ; --------------------------------------------------------------------------- @@ -3489,6 +3521,7 @@ EnemyBehavior_CheckBombTimer: LDY ObjectBeingCarriedTimer, X BEQ EnemyBehavior_Bomb_Explode + ; A = $00 STA HoldingItem STA ObjectBeingCarriedTimer, X @@ -4192,7 +4225,6 @@ EnemyBehavior_BobOmb_CheckFuse: EnemyBehavior_BobOmb_Explode: JMP EnemyBehavior_Bomb_Explode - EnemyBehavior_BobOmb_Flash: CMP #$30 ; When to start flashing BCS EnemyBehavior_BasicWalker @@ -4206,7 +4238,6 @@ EnemyBehavior_BobOmb_Flash: AND #%11111011 STA ObjectAttributes, X - EnemyBehavior_BasicWalker: JSR ObjectTileCollision @@ -11101,6 +11132,7 @@ CheckCollisionWithPlayer_StandingOnHead: STA EnemyCollision, X STX ObjectBeingCarriedIndex STA ObjectShakeTimer, X + LDA #$07 STA ObjectBeingCarriedTimer, X JSR SetPlayerStateLifting @@ -11263,6 +11295,7 @@ loc_BANK3_B96E: LDY byte_RAM_12 STY ObjectBeingCarriedIndex + LDA #$01 STA ObjectBeingCarriedTimer, Y INC HoldingItem diff --git a/src/ram.asm b/src/ram.asm index 440522f..ff72b8c 100644 --- a/src/ram.asm +++ b/src/ram.asm @@ -362,10 +362,11 @@ ObjectAnimationTimer: .dsb 1 ; $00a6 .dsb 1 ; $00a7 -; Set to 7 when lifting, then stays at 1 -; Note that this doesn't seem to actually -; make you carry an item, it just THINKS -; it's being carried. +; Set to 7 when lifting, then decrements to 1 and stays there as long as the +; object is held. +; +; Note that this doesn't actually make you carry an item, but rather that the +; item THINKS it's being carried. ObjectBeingCarriedTimer: .dsb 1 ; $00a8 .dsb 1 ; $00a9 From 97031c6f843b418e1b583565c8094d07b902c52e Mon Sep 17 00:00:00 2001 From: Keith McKnight Date: Tue, 30 Dec 2025 17:22:10 -0500 Subject: [PATCH 15/17] update build.sh --- build.sh | 13 +++++++++++-- src/prg-2-3.asm | 6 ++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 2307b89..5240f40 100755 --- a/build.sh +++ b/build.sh @@ -6,11 +6,20 @@ SM_USA="c63bacd07cf0d2336e8a4f9b9c556d0758629f102211d989d92495e117a8b3a0" compareHash() { - echo $1 $2 | sha256sum --check > /dev/null 2>&1 + expected_hash="$1" + file="$2" + actual_hash=$(sha256sum "$file" 2>/dev/null | cut -d' ' -f1) + [ "$expected_hash" = "$actual_hash" ] } build() { - tools/asm6f smb2.asm -n -c -L bin/smb2.nes "$@" > bin/assembler.log + # Try to use asm6f from PATH first (local/macOS) + if command -v asm6f > /dev/null 2>&1 ; then + asm6f smb2.asm -n -c -L bin/smb2.nes "$@" > bin/assembler.log + # Fall back to tools/asm6f (Linux-only) + else + tools/asm6f smb2.asm -n -c -L bin/smb2.nes "$@" > bin/assembler.log + fi } diff --git a/src/prg-2-3.asm b/src/prg-2-3.asm index 8a44b83..00d1a6f 100644 --- a/src/prg-2-3.asm +++ b/src/prg-2-3.asm @@ -7533,6 +7533,7 @@ RenderSprite_Pidgit: STY_abs byte_RAM_F4 + ; Attributes for the carpet LDA #ObjAttrib_Palette1 | ObjAttrib_Horizontal | ObjAttrib_16x32 STA ObjectAttributes, X LDA ObjectXLo, X @@ -7540,10 +7541,12 @@ RenderSprite_Pidgit: SEC SBC #$08 STA ObjectXLo, X + LDA ObjectXHi, X PHA SBC #$00 STA ObjectXHi, X + JSR ScreenSpriteClipping_Horizontal PLA @@ -7554,11 +7557,14 @@ RenderSprite_Pidgit: CLC ADC #$0C STA SpriteTempScreenY + LDA SpriteTempScreenX SBC #$07 STA SpriteTempScreenX + JSR RenderSprite_FlyingCarpet + ; Attributes for actual Pidgit LDA #ObjAttrib_Palette1 | ObjAttrib_Horizontal | ObjAttrib_FrontFacing STA ObjectAttributes, X From 7ff2bd76798fc2b7c1409fdd9e3cd76b603a330b Mon Sep 17 00:00:00 2001 From: Keith McKnight Date: Tue, 30 Dec 2025 17:30:20 -0500 Subject: [PATCH 16/17] travis -> github workflow --- .github/workflows/test.yml | 15 +++++++++++++++ .travis.yml | 3 --- 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..b6b4264 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,15 @@ +name: Test Build + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Run tests + run: ./build.sh test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9fcd053..0000000 --- a/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: minimal -script: - - ./build.sh test From ccd914b263c590f88a34075c9b04cb2bc938f359 Mon Sep 17 00:00:00 2001 From: Keith McKnight Date: Tue, 30 Dec 2025 18:13:27 -0500 Subject: [PATCH 17/17] update readme --- README.md | 83 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index bfff9df..959ed91 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,27 @@ # Super Mario Bros. 2, Discombobulated + [![Logo](tools/logo.png "Logo")](https://xkeeper0.github.io/smb2)\ A disassembly of Super Mario Bros. 2. This project is intended to fully disassemble, comment, and understand -everything about the game *Super Mario Bros. 2* on the NES. In addition to the +everything about the game _Super Mario Bros. 2_ on the NES. In addition to the disassembly, there is also [documentation about the game's formats](https://xkeeper0.github.io/smb2), though those are more of a work in progress than the disassembly. As an added bonus, a fully understood disassembly will also make modifying and changing the game easier! ----- +--- ## Building This is designed for use with [asm6f](https://github.com/freem/asm6f/). -For your convenience, binaries of that have been included. (Windows/Linux) +For your convenience, Windows and Linux binaries of that have been included. -[![Build Status](https://travis-ci.com/Xkeeper0/smb2.svg?branch=asm6)](https://travis-ci.com/Xkeeper0/smb2) +[![Build Status](https://github.com/kmck/smb2/actions/workflows/test.yml/badge.svg)](https://github.com/kmck/smb2/actions/workflows/test.yml) ### Windows + Open a command prompt window and run: build (builds PRG0) @@ -31,56 +33,75 @@ It will then output the SHA-256 hashes of PRG0 and PRG1, as well as the SHA-256 hash of the assembled ROM, useful if you intend to keep a one-to-one build. ### Linux, etc + A version of `asm6f` built under Ubuntu has been included under `tools/`. To build, run the following command: - ./build.sh (builds PRG0) - ./build.sh -dREV_A (builds PRG1) - ./build.sh -dSM_USA (builds Super Mario USA) - ./build.sh test (builds both PRG0 and PRG1, verifying they match) + ./build.sh (builds PRG0) + ./build.sh -dREV_A (builds PRG1) + ./build.sh -dSM_USA (builds Super Mario USA) + ./build.sh test (builds both PRG0 and PRG1, verifying they match) The build script will also display a message if the built ROM's SHA-256 hash matches either PRG0 or PRG1. +#### macOS + +Since there is no readily-available distrubition of `asm6f`, the most +straightforward thing is is to clone the repo and build from source. + +```shell +# Get the source code +cd ~/Code # or wherever you like to organize your projects +git clone git@github.com:freem/asm6f.git +cd asm6f +# Build the binary--you might to run xcode-select --install +make +# Assuming build succeeded, symlink to a convenient spot in your PATH +ln -s ~/Code/asm6f/asm6f /usr/local/bin/asm6f +``` + ### Output + The build process will generate a few files: -* `bin/smb2.nes`, your assembled ROM. -* `bin/smb2.lst`, the assembler listing. Use this to see how the code assembled. -* `bin/assembler.txt`, the log from the assembler -* `bin/smb2.*.nl`, name-listing files for FCEUX's debugger. -* Some other cruft, probably. welp +- `bin/smb2.nes`, your assembled ROM. +- `bin/smb2.lst`, the assembler listing. Use this to see how the code assembled. +- `bin/assembler.txt`, the log from the assembler +- `bin/smb2.*.nl`, name-listing files for FCEUX's debugger. +- Some other cruft, probably. welp **By default, the build script will create a byte-for-byte copy of the game**, matching these two SHA-256 hashes: -* PRG0: `47ba60fad332fdea5ae44b7979fe1ee78de1d316ee027fea2ad5fe3c0d86f25a` -* PRG1: `6ca47e9da206914730895e45fef4f7393e59772c1c80e9b9befc1a01d7ecf724` +- PRG0: `47ba60fad332fdea5ae44b7979fe1ee78de1d316ee027fea2ad5fe3c0d86f25a` +- PRG1: `6ca47e9da206914730895e45fef4f7393e59772c1c80e9b9befc1a01d7ecf724` You can edit `config.asm` to change some build options; see that file for details. ## Assembly + The "source" lives in the `src` directory: -* `prg-x-x.asm` are the program banks. They are grouped in pairs, as that is how +- `prg-x-x.asm` are the program banks. They are grouped in pairs, as that is how SMB2 loads them. If you want to change this, you will need to split them apart again. -* `defs.asm` defines various enums and identifiers. -* `ram.asm` contains labels and definitions for RAM addresses. -* `extras/` contains some additional fun things (see `config.asm`). -* `levels/` contains level and enemy data. -* `music/` contains music and sound data. -* This list is growing as we split the disassembly into smaller parts. - +- `defs.asm` defines various enums and identifiers. +- `ram.asm` contains labels and definitions for RAM addresses. +- `extras/` contains some additional fun things (see `config.asm`). +- `levels/` contains level and enemy data. +- `music/` contains music and sound data. +- This list is growing as we split the disassembly into smaller parts. ## Contributing -* Fork the repository. -* Make changes. -* Submit a pull request! -* You are also encouraged to visit the [Discord server](https://discord.gg/TsWMMeV) - if you have any questions. +- Fork the repository. +- Make changes. +- Submit a pull request! +- You are also encouraged to visit the [Discord server](https://discord.gg/TsWMMeV) + if you have any questions. ## See Also -* [Data Crystal's SMB2 page](http://datacrystal.romhacking.net/wiki/Super_Mario_Bros._2) -* [CaptainSouthbird's SMB3 disassembly](https://github.com/Drakim/smb3) and [Drakim's asm6f version](https://github.com/Drakim/smb3) -* [Our Discord server](https://discord.gg/TsWMMeV) + +- [Data Crystal's SMB2 page](http://datacrystal.romhacking.net/wiki/Super_Mario_Bros._2) +- [CaptainSouthbird's SMB3 disassembly](https://github.com/Drakim/smb3) and [Drakim's asm6f version](https://github.com/Drakim/smb3) +- [Our Discord server](https://discord.gg/TsWMMeV)