diff --git a/Masks/deku_mask.asm b/Masks/deku_mask.asm index a828e31..f30423c 100644 --- a/Masks/deku_mask.asm +++ b/Masks/deku_mask.asm @@ -30,6 +30,8 @@ Link_HandleDekuTransformation: RTS } +print "here", pc + org $07811A JSR Link_HandleDekuTransformation @@ -38,6 +40,9 @@ org $07811A org $07A64B ; formerly Quake LinkItem_DekuMask: { + ; Check for R button held + LDA $F2 : CMP #$10 : BNE .return + JSR Link_CheckNewY_ButtonPress : BCC .return LDA $3A : AND.b #$BF : STA $3A ; clear the Y button state @@ -50,18 +55,27 @@ LinkItem_DekuMask: LDA $02B2 : CMP #$01 : BEQ .unequip ; is the deku mask on? JSL Palette_ArmorAndGloves ; set the palette - LDA #$0A : STA $5D ; set control handler to mode "using quake" + + LDA.l $7EF359 : STA $0AA5 ; Store the current sword + LDA.l $7EF35A : STA $0AAF ; Store the current shield + LDA.b #$00 : STA $7EF359 : STA $7EF35A ; Clear the sword and shield + LDA #$02 : STA $7E03FC ; Set the override to Bow (pea shooter) + LDA #$35 : STA $BC ; put the mask on LDA #$01 : STA $02B2 - LDA #$00 : STA $03FC BRA .return .unequip JSL Palette_ArmorAndGloves STZ $5D - STZ $03FC - LDA #$10 : STA $BC : STZ $02B2 ; take the mask off + + ; Restore the sword and shield + LDA $0AA5 : STA.l $7EF359 + LDA $0AAF : STA.l $7EF35A + LDA #$00 : STA $7E03FC ; clear the override + LDA #$10 : STA $BC : STZ $02B2 ; take the mask off + .return RTS @@ -69,139 +83,104 @@ LinkItem_DekuMask: ; ============================================================================= -; LinkItem_UsingQuake is 152 (base10) bytes long -org $07A6D6 -LinkItem_UsingQuake: -{ - JSR $82DA - JSL LinkItem_UsingDekuMask +org $079CD9 + JSL LinkItem_CheckForSwordSwing_Masks - RTS - NOP #149 - - print pc -} -; end of UsingQuake is at 07A773 +org $07A013 + JSL LinkItem_SlingshotPrepare ; ============================================================================= org $318000 -LinkItem_UsingDekuMask: +LinkItem_CheckForSwordSwing_Masks: { - JSL CheckIndoorStatus_Long - LDA.b $F5 - AND.b #$80 - BEQ .dont_toggle_oob - - LDA.w $037F - EOR.b #$01 - STA.w $037F - -.dont_toggle_oob - STZ.w $02CA - - LDA $0345 : BNE .recache - LDA $4D : BEQ .recoiling - ; LDA $7EF357 : BEQ .recache - - STZ $02E0 - -; *$383C7 LONG BRANCH LOCATION LinkState_Bunny_recache -.recache - - LDA $7EF357 : BEQ .no_pearl_a - - STZ $56 - STZ $4D - -.no_pearl_a - - STZ $2E ; animation steps - STZ $02E1 ; - STZ $50 - - JSL Player_ResetSwimState - - ; Link hit a wall or an enemy hit him, making him go backwards. - LDA.b #$02 : STA $5D - - LDA $7EF357 : BEQ .no_pearl_b - - ; this resets link to default state. - LDA.b #$00 : STA $5D - - JSL LoadActualGearPalettes - -.no_pearl_b - - BRL .exit - -.recoiling - - LDA $46 : BEQ .wait_maybe_not_recoiling - ;BRL $0783A1 ; Permabunny mode. - -.wait_maybe_not_recoiling - - LDA.b #$FF : STA $24 : STA $25 : STA $29 - STZ $02C6 - - LDA $034A : BEQ .not_moving - - LDA.b #$01 : STA $0335 : STA $0337 - LDA.b #$80 : STA $0334 : STA $0336 - - ; BRL $9715 - -.not_moving - - JSL Player_ResetSwimCollision_Long - JSL Link_HandleYItems_Long ; $39B0E IN ROM - - LDA $49 : AND.b #$0F : BNE .movement - LDA $F0 : AND.b #$0F : BNE .movement - STA $30 : STA $31 : STA $67 : STA $26 - - STZ $2E - - LDA $48 : AND.b #$F6 : STA $48 - LDX.b #$20 : STX $0371 - - ; Ledge timer is reset here the same way as for normal link (unbunny). - LDX.b #$13 : STX $0375 - - BRA .finish_up - -.movement - - STA $67 : CMP $26 : BEQ .directions_match - - STZ $2A - STZ $2B - STZ $6B - STZ $4B - - LDX.b #$20 : STX $0371 - - ; Ledge timer is reset here the same way as for normal link (unbunny). - LDX.b #$13 : STX $0375 - -.directions_match - - STA $26 - -.finish_up - JSL Link_HandleDiagonalCollision_Long - JSL Link_HandleVelocity ; $3E245 IN ROM - JSL Link_HandleCardinalCollision_Long - JSL Link_HandleMovingAnimation_FullLongEntry ; $3E6A6 IN ROM - - STZ $0302 - - JSL HandleIndoorCameraAndDoors_Long ; $3E8F0 IN ROM - -.exit: + LDA $02B2 : CMP #$01 : BNE .return + LDA #$01 RTL + +.return + LDA $3B : AND.b #$10 + RTL +} + +; ============================================================================= + + +; Hooked @ [$07A013] +; $A200 +LinkItem_SlingshotPrepare: +{ + LDA #$01 : TSB $50 + LDA $7EF340 + BNE .alpha + JMP $A270 +.alpha + CMP #$01 + BNE .void ; unused afaik (RTS?) + JMP .beta + +; $A214 +.void + + +; $A270 +.beta + LDA $7F1060 + CMP #$10 + BEQ $20A27B + JMP .theta + +; $A300 +.theta + LDA $7F502E + CMP #$01 + BNE .gamma + RTL + +; $A309 +.gamma + LDA #$01 ; Load the accumulator with hex value 01 + STA $7F502E ; Store the accumulator value at memory address 7F502E + + PHB ; Push data bank register on stack + REP #$30 ; Clear 16-bit accumulator and index registers + LDX #$A500 ; Load X register with source address + LDY #$9800 ; Load Y register with destination address + LDA #$00BF ; Load the accumulator with the number of bytes to be moved + MVN $20, $7E ; Block move negative - moves 00BF bytes from $A500 to $9800 + SEP #$30 ; Set 8-bit accumulator and index registers + PLB ; Pull data bank register from stack + +.loop + LDA $4212 : AND #$80 : BNE .loop ; Wait for VBlank start (beginning of vertical blanking period) +.loop2 + LDA $4212 : AND #$80 : BEQ .loop2 ; Wait for VBlank end + + REP #$30 ; Clear 16-bit accumulator and index registers + LDA #$A700 : STA $4302 ; Set DMA source address to $A700 + LDA #$42A0 : STA $2116 ; Set VRAM (Video RAM) address to $42A0 + SEP #$30 ; Set 8-bit accumulator and index registers + + LDA #$80 : STA $2115 ; Set VRAM write increment to 2 bytes, and access mode to word access at the specified address + LDA #$18 : STA $4301 ; Set DMA destination address to $2118 (VRAM data write) + LDA #$20 : STA $4304 ; Set DMA transfer size to 32 bytes + LDA #$80 : STA $4305 ; Set DMA transfer size (high byte) + LDA #$01 : STA $4300 ; Set DMA mode to 1 (2 registers write once) + STA $420B ; Start DMA on channel 0 + + REP #$30 ; Clear 16-bit accumulator and index registers + LDA #$43A0 : STA $2116 ; Set VRAM address to $43A0 + LDA #$A800 : STA $4302 ; Set DMA source address to $A800 + SEP #$30 ; Set 8-bit accumulator and index registers + + LDA #$80 : STA $2115 ; Set VRAM write increment to 2 bytes, and access mode to word access at the specified address + LDA #$18 : STA $4301 ; Set DMA destination address to $2118 (VRAM data write) + LDA #$20 : STA $4304 ; Set DMA transfer size to 32 bytes + LDA #$80 : STA $4305 ; Set DMA transfer size (high byte) + LDA #$01 : STA $4300 ; Set DMA mode to 1 (2 registers write once) + STA $420B ; Start DMA on channel 0 + RTL ; Return from subroutine long + } \ No newline at end of file diff --git a/Masks/mask_routines.asm b/Masks/mask_routines.asm index ddf6e97..8334493 100644 --- a/Masks/mask_routines.asm +++ b/Masks/mask_routines.asm @@ -213,4 +213,33 @@ Link_HandleYItems_Long: JSR Link_HandleYItems PLB RTL -} \ No newline at end of file +} + +; ============================================================================= + +org $07FA41 +LinkState_ResetMaskAnimated: +{ + LDA $02B2 : BEQ .no_mask + CMP #$01 : BNE .transform + + ; Restore the sword, shield, and bow override + LDA $0AA5 : STA.l $7EF359 + LDA $0AAF : STA.l $7EF35A + LDA #$00 : STA $7E03FC + +.transform + LDY.b #$04 : LDA.b #$23 + JSL AddTransformationCloud + LDA.b #$14 : JSR Player_DoSfx2 + + JSL Palette_ArmorAndGloves + LDA #$10 : STA $BC : STZ $02B2 +.no_mask + RTL +} + +print "Next address for jump in bank07: ", pc + + +; ============================================================================= \ No newline at end of file diff --git a/Masks/zora_mask.asm b/Masks/zora_mask.asm index a499d40..3b0e73c 100644 --- a/Masks/zora_mask.asm +++ b/Masks/zora_mask.asm @@ -224,10 +224,6 @@ LinkState_UsingZoraMask: ; ============================================================================= - -print "Next address for jump in bank07: ", pc - - ; End of LinkState_Swimming org $079781 JSR LinkState_UsingZoraMask @@ -244,640 +240,3 @@ org $0782D2 org $07C307 JSR LinkState_UsingZoraMask_dungeon_stairs RTS - - -; ============================================================================= -; Disassembled/Debugged Code of Conn's Zora Flippers -; May God Give Me Strength - -; ============================================================================= -; 22E0E0 - -org $348000 -FairyFlippers_E0E0: -{ - LDA $1B ; 1 if the player is in indoors and 0 otherwise. - BNE .alpha ; we are outdoors - - LDA $7F500E ; are we currently underwater? - CMP #$01 - BNE .alpha ; we are not underwater - - LDA #$01 - STA $55 ; activate cape flag (invisible, invincible) - STZ $5D ; reset player to ground state - LDA #$08 - STA $5E ; set the player speed - RTL -;------- -.alpha - LDA #$01 - STA $4D - RTL -} - -; ============================================================================= -; 22E100 - -FairyFlippers_E100: -{ - LDA $2F ; The direction the player is currently facing - STA $0323 ; Mirror of $2F - JMP FairyFlippers_E5F0 ; $E5F0 - NOP - NOP - NOP - NOP - LDA $0345 ; Set to 1 when we are in deep water, 0 otherwise - CMP #$01 ; Are we in deep water? - BEQ FairyFlippers_E120 - LDA $7F500E - CMP #$01 - BEQ $22E11C - RTL -} - -; ============================================================================= -; 22E120 - -FairyFlippers_E120: -{ - LDA $F0 ; Joypad 1 Register - CMP #$40 - BEQ .alpha ; $22E12D - LDA #$00 - STA $7F500F - RTL -;------- -.alpha - LDA $7F500F - CMP #$01 - BNE $22E136 - RTL -;------- - LDA #$01 - STA $7F500F - JSR $E340 - NOP - NOP - LDA $1B - BEQ $22E17D - LDA $7F500E - CMP #$00 - BNE $22E163 - JMP $E320 -} - -; ============================================================================= -; 22E17D - -FairyFlippers_E17D: -{ - LDA $7F500E - CMP #$00 - BNE $22E1A3 - LDA $5D ; Player Handler or "State" - CMP #$04 - BEQ $22E18C - RTL -;------- - LDA #$01 - STA $7F500E - STZ $5D ; Player Handler or "State" - LDA #$01 - STA $55 ; Cape flag - STA $037B - LDA #$08 - STA $5E ; Speed setting for link - NOP - NOP - NOP - RTL -;------- - LDA #$00 - JSL $22EF80 - LDA #$04 - STA $5D ; Player Handler or "State" - STZ $55 ; Reset cape flag (invisible invincible) - STZ $5E ; Reset Speed - LDA #$01 - STA $0345 ; Set to 1 when we are in deep water. 0 otherwise - STZ $037B - RTL -} - -; ============================================================================= -; 22E1E0 -; Observed behavior: Triggers when entering and exiting water indoors only -; Returns to 3C30B below -; Noted changes added - -FairyFlippers_SetFlipperAbilities: -{ - LDA $1B ; Flag set to 1 when indoors, 0 otherwise - BNE .set_player_state - - LDA $7F500E ; - CMP #$01 - BNE .set_player_state - - LDA #$01 - STA $55 ; Set cape flag (invisible invincible) - STZ $5D ; Player Handler or "State" - LDA #$08 - STA $5E ; Set player speed - RTL -;------- -.set_player_state - LDA #$06 ; recoil mode 2 - STA $5D ; Player Handler or "State" - RTL -} - -; ============================================================================= -; *$3C2C3-$3C30B LOCAL - -Vanilla_UntitledRoutine: -{ - LDA $1B : BNE .alpha ; Set to 1 if indoors, 0 otherwise - LDX #$02 - BRA .beta - -.alpha - LDX $1D - LDA $047A : BEQ .beta - LDX #$00 ; Modified from vanilla `LDY.b #$00` - -.beta - STX $00 - LDA $C2BA, X : TAX - LDA $66 : BNE .gamma - TXA : EOR #$FF : INC : TAX - -.gamma - STX $27 - STZ $28 - LDX $00 - LDA $C2BD,X - - STA $29 ; vertical resistance - STA $02C7 ; countdown timer - STZ $24 ; z coordinate for link - STZ $25 ; ??? No idea - - LDA $C2C0,X - JSL $8EFCE0 ; Dungeon Code (Flippers?) - CMP #$02 : BEQ .delta - JSL FairyFlippers_E0E0 ; $22E0E0 - STZ $0360 - -.delta - JSL FairyFlippers_SetFlipperAbilities ; $22E1E0 - RTS -} - - -; ============================================================================= -; 22E260 - -FairyFlippers_E260: -{ - LDA $7EF33C ; fairy flippers save ram - AND #$00FF - CMP #$0001 - BEQ .has_fairy_flippers ; $22E271 - LDA $7EF357 - RTL - -; ------- -; 22E271 -.has_fairy_flippers - SEP #$30 - LDA #$3C - STA $1613 - STA $1615 - STA $1653 - STA $1655 - REP #$30 - LDA $7EF357 - RTL -} - -; ============================================================================= -; 22E2A0 -; -; Description: routine is hooked at $07:8106, right before the -; Link_ControlHandlerTable jump loop. -; -; Observed behavior of preserving the direction link was facing when diving -; E.g. face left, dive, turn right underwater, and resurface facing left - -FairyFlippers_Prepare: -{ - JSR FairyFlippers_Main ; $E530 - JSL FairyFlippers_HandleMagic ; $22E670 - LDA $7F500E : CMP #$01 ; are we currently underwater? - BEQ .underwater - JMP FairyFlippers_RestoreControlHandler ; $E2F0 - - ; if so, restore control -.underwater - LDA $F0 ; Joypad 1 Register (preserves previous press) - SEC : SBC #$0B ; up left right it seems - BCS .beta - JMP FairyFlippers_RestoreControlHandler ; $E2F0 - -.beta - LDA $F0 ; Joypad 1 Register (preserves previous press) - SEC : SBC #$4B ; probably Y - BCS .gamma - - LDA #$40 - STA $F0 - ; TODO: RESTORE ME - ; JMP $079657 ; Apart of LinkState_Swimming - -.gamma - LDA $F0 ; Joypad 1 Register (preserves previous press) - SEC : SBC #$BB - BCS $22E2D5 ; Unknown?? Possibly dead branch - - JMP FairyFlippers_RestoreControlHandler ; $E2F0 -} - - -; ============================================================================= -; 22E2F0 - -FairyFlippers_RestoreControlHandler: -{ - LDA $5D ; Player Handler or "State" - ASL - TAX - ; TODO: RESTORE ME - ; JMP $078106 ; Link_ControlHandler Jump Table Statement -} - -; ============================================================================= -; 22E300 - -FairyFlippers_E300: -{ - LDA #$00 - STA $5D ; Player Handler or "State" - STA $7F500E - STA $7F500F - STA $5E - STA $0345 - JSL $00E3FA - RTL -} - -; ============================================================================= -; 22E340 - -FairyFlippers_E340: -{ - LDA $1B ; 1 if indoors, 0 otherwise - BEQ $22E34E - LDA $0114 ; Value of the type of tile Link is standing on - BEQ $22E34E - CMP #$08 - BEQ $22E34E - RTS -;------- - LDA #$24 ; Splash sound effect - STA $012E - RTS -} - -; ============================================================================= -; 22E460 - -FairyFlippers_E460: -{ - LDA $02E4 ; If flag nonzero, Link cannot move - AND #$00FF - BNE .alpha ; $22E46E - LDA #$0009 - LDX $8C - RTL -;------- -.alpha - LDA $0202 ; currently selected item - AND #$00FF - CMP #$000F ; what item is F? - BNE $22E481 - LDA $02F0 - AND #$00FF - BEQ $22E487 - LDA #$0009 - LDX $8C - RTL -} - - -; ============================================================================= -; 22E500 - -FairyFlippers_E500: -{ - CMP #$5A - BEQ $22E507 - JMP $D00B -} - -; ============================================================================= -; 22E530 -; Seems to always run when you are in the water - -FairyFlippers_Main: -{ - LDA $7F500E ; are we currently underwater? - CMP #$01 - BEQ $22E539 - RTS -;------------- -; underwater - LDA $7F500F - CMP #$01 - BNE .alpha - - LDA $F0 : CMP #$40 ; controller again you shouldn't have - BNE .alpha - - LDA $67 : CMP #$00 ; is player facing up ? - BEQ .alpha - STZ $67 - -.alpha - LDA $1B ; Dungeon/Overworld flag - BNE $22E558 - - ; Set underwater walking speed - LDA #$08 - STA $5E ; Link Speed Setting - - RTS -} - -; ============================================================================= -; 22E5F0 - -FairyFlippers_E5F0: -{ - LDA $7EF33C - BNE $22E5F7 - RTL -;------- - LDA $4D - BEQ $22E5FC - RTL -;------- - JMP $E108 -} - -; ============================================================================= -; 22E600 -; Possibly relevant, unconfirmed - -; Referenced at: 0D:E507 - -FairyFlippers_E600: -{ - LDA $7EF34A - AND #$00FF - CMP #$0001 - BEQ $22E611 - LDA $7EF35C,X - RTL -;------- - LDA $7EF33B - AND #$00FF - CMP #$0001 - BNE $22E622 - LDA $7EF35C,X - RTL -;------- - SEP #$30 - LDA #$3C - STA $139F - STA $13A1 - STA $13DF - STA $13E1 - REP #$30 - LDA $7EF35C,X - RTL -} - -; ============================================================================= -; 22E670 - -FairyFlippers_HandleMagic: -{ - LDA $7F500E ; probably free ram - CMP #$01 - BEQ $22E679 - RTL -;------- -; Magic draining loop - LDA $7EF36E ; Load magic - BNE $22E688 ; branch if != 0 - LDA #$3C - STA $012E - ; TODO: RESTORE ME - ; JMP $22E141 - LDA $7F500D ; load timer - BNE $22E69E ; branch if != 0 - LDA #$18 - STA $7F500D ; set timer to 18 - LDA $7EF36E ; load magic - DEC ; decrease magic by 1 - STA $7EF36E ; store new magic - RTL -;------- - DEC - STA $7F500D ; decrease timer - RTL -} - -; ============================================================================= -; 22E700 - -FairyFlippers_E700: -{ - STA $F6 - STY $FA - REP #$30 - LDA $7EE000 - DEC - BNE $22E721 - LDA $7EF339 - INC - CMP #$1770 - BCC $22E71A - LDA #$0000 - STA $7EF339 - LDA #$0E10 - STA $7EE000 - SEP #$30 - RTL -} - -; ============================================================================= -; 22E760 - -FairyFlippers_E760: -{ - LDA #$0E10 - STA $7EE000 - LDY #$0000 - LDX $00 - RTL -} - -; ============================================================================= -; 22E780 -; Jesucristo... - -FairyFlippers_E780: -{ - REP #$30 - LDY #$0000 - LDA $7EF339 - CMP #$000A - BCC $22E796 - SEC - SBC #$000A - INY - INY - BRA $22E789 - STA $00 - TYA - ASL - ASL - ASL - ORA $00 - LDY #$0000 - CMP #$0060 - BCC $22E7AD - SEC - SBC #$0060 - INY - BRA $22E7A1 - LDX #$0000 - STA $00 - AND #$000F - ASL - TAX - LDA $22E860,X - STA $1376 - LDA $00 - AND #$00F0 - LSR - LSR - LSR - TAX - LDA $22E860,X - STA $1374 - TYA - LDY #$0000 - CMP #$000A - BCC $22E7DF - SEC - SBC #$000A - INY - INY - BRA $22E7D2 - STA $00 - TYA - ASL - ASL - ASL - ORA $00 - STA $00 - AND #$000F - ASL - TAX - LDA $22E860,X - STA $1370 - LDA $00 - AND #$00F0 - LSR - LSR - LSR - TAX - LDA $22E860,X - STA $136E - LDA $7E0AE0 - AND #$00FF - CMP #$00C0 - BNE $22E816 - LDA #$2CF5 - BRA $22E819 - LDA #$241D - STA $1372 - SEP #$30 - INC $0207 - LDA $F0 - RTL -} - -; ============================================================================= -; 22E830 - -FairyFlippers_E830: -{ - ADC #$0020 - STA $1CD0 - LDA $10 - AND #$00FF - CMP #$0012 - BEQ $22E841 - RTL -;------- - STZ $0223 - STZ $1CD8 - LDA $7F502E - AND #$00FF - CMP #$0000 - BNE $22E854 - RTL -} - -; ============================================================================= -; 22EF50 - -{ - LDA $7EF3CC - CMP #$0D - BEQ $22EF59 - RTL -} - -; ============================================================================= -; 22EF80 - -{ - STA $7F500E ; reset underwater variable - STZ $0372 ; link bounce flag - RTL -} - -; ============================================================================= -; 22EFA0 - -{ - LDA $5D ; Player Handler or "State" - CMP #$05 - BNE $22EFAA - STZ $0351 - RTS -;------- - LDA $4D - CMP #$01 - BNE $22EFB4 - LDA #$04 - STA $5D ; Player Handler or "State" - RTS -} \ No newline at end of file diff --git a/Menu/menu.asm b/Menu/menu.asm index d1235e4..88c57dd 100644 --- a/Menu/menu.asm +++ b/Menu/menu.asm @@ -426,6 +426,8 @@ Menu_CheckBottle: Menu_Exit: { + JSL LinkState_ResetMaskAnimated + REP #$20 ; reset submodule