Transformation mask refactor, CheckForSwordSwing

This commit is contained in:
scawful
2023-08-14 09:06:37 -04:00
parent b5c055cb54
commit 41b2b52750
6 changed files with 244 additions and 238 deletions

View File

@@ -54,52 +54,54 @@ JSR $FD66
CLC CLC
org $87FD66 org $87FD66
JSL $20AF20 JSL LinkState_BunnyHoodRun
RTS RTS
org $20AF20 org $20AF20
CPX.b #$11 : BCS end ; speed value upper bound check LinkState_BunnyHoodRun:
{
CPX.b #$11 : BCS .end ; speed value upper bound check
LDA.w $0202 ; check the current item LDA.w $0202 ; check the current item
CMP.b #$16 : BNE end ; is it the bunny hood? CMP.b #$16 : BNE .end ; is it the bunny hood?
LDA.w $02B2 ; did you put it on? LDA.w !CurrentMask ; did you put it on?
BEQ end BEQ .end
LDA $20AF70,X ; load new speed values LDA.l BunnySpeedTable, X ; load new speed values
CLC CLC
RTL RTL
end: { .end
LDA $87E227, X ; load native speed values LDA $87E227, X ; load native speed values
CLC CLC
RTL RTL
} }
org $20AF70 ; this selects the new speed values org $20AF70 ; this selects the new speed values
BunnySpeedTable:
{
db $20, $12, $0a, $18, $10, $08, $08, $04, $0c, $10, $09, $19, $14, $0d, $10, $08, $40 db $20, $12, $0a, $18, $10, $08, $08, $04, $0c, $10, $09, $19, $14, $0d, $10, $08, $40
}
; =============================================================================
; Press R to transform into bunny form and run faster.
; ============================================================================= ; =============================================================================
org $07A494 org $07A494
LinkItem_Ether: LinkItem_Ether:
{ {
JSR Link_CheckNewY_ButtonPress : BCC .return %CheckNewR_ButtonPress() : BEQ .return
LDA $3A : AND.b #$BF : STA $3A ; clear the Y button state
LDA $6C : BNE .return ; in a doorway LDA $6C : BNE .return ; in a doorway
LDA $0FFC : BNE .return ; can't open menu LDA $0FFC : BNE .return ; can't open menu
LDY.b #$04 : LDA.b #$23 %PlayerTransform()
JSL AddTransformationCloud
LDA.b #$14 : JSR Player_DoSfx2
LDA $02B2 : CMP #$04 : BEQ .unequip ; is the hood already on? LDA $02B2 : CMP #$04 : BEQ .unequip ; is the hood already on?
JSL UpdateBunnyPalette JSL UpdateBunnyPalette
LDA #$37 : STA $BC ; change link's sprite LDA #$37 : STA $BC ; change link's sprite
LDA #$04 : STA $02B2 LDA #$04 : STA $02B2
BRA .return BRA .return
.unequip .unequip
STZ $02B2 %ResetToLinkGraphics()
JSL Palette_ArmorAndGloves
LDA #$10 : STA $BC ; take the hood off
.return .return
CLC CLC

View File

@@ -2,9 +2,6 @@
; Deku Mask ; Deku Mask
; ============================================================================= ; =============================================================================
; =============================================================================
org $358000 org $358000
incbin gfx/deku_link.bin incbin gfx/deku_link.bin
@@ -14,69 +11,36 @@ org $07A64B ; formerly Quake
LinkItem_DekuMask: LinkItem_DekuMask:
{ {
; Check for R button held ; Check for R button held
LDA $F2 : CMP #$10 : BNE .return %CheckNewR_ButtonPress() : BEQ .return
JSR Link_CheckNewY_ButtonPress : BCC .return
LDA $3A : AND.b #$BF : STA $3A ; clear the Y button state
LDA $6C : BNE .return ; in a doorway LDA $6C : BNE .return ; in a doorway
LDA $0FFC : BNE .return ; can't open menu LDA $0FFC : BNE .return ; can't open menu
LDY.b #$04 : LDA.b #$23 %PlayerTransform()
JSL AddTransformationCloud
LDA.b #$14 : JSR Player_DoSfx2
LDA $02B2 : CMP #$01 : BEQ .unequip ; is the deku mask on? LDA $02B2 : CMP #$01 : BEQ .unequip ; is the deku mask on?
JSL Palette_ArmorAndGloves ; set the palette JSL Palette_ArmorAndGloves ; set the palette
LDA.l $7EF359 : STA $0AA5 ; Store the current sword
LDA.l $7EF35A : STA $0AAF ; Store the current shield LDA.l $7EF35A : STA $0AAF ; Store the current shield
LDA.b #$00 : STA $7EF359 : STA $7EF35A ; Clear the sword and shield LDA.b #$00 : STA $7EF35A ; Clear the shield
LDA #$02 : STA $7E03FC ; Set the override to Bow (pea shooter)
LDA #$35 : STA $BC ; put the mask on LDA #$35 : STA $BC ; put the mask on
LDA #$01 : STA $02B2 LDA #$01 : STA $02B2 ; set the deku mask flag
BRA .return BRA .return
.unequip .unequip
JSL Palette_ArmorAndGloves
STZ $5D STZ $5D
; Restore the shield
; Restore the sword and shield
LDA $0AA5 : STA.l $7EF359
LDA $0AAF : STA.l $7EF35A LDA $0AAF : STA.l $7EF35A
LDA #$00 : STA $7E03FC ; clear the override
LDA #$10 : STA $BC : STZ $02B2 ; take the mask off
%ResetToLinkGraphics()
.return .return
RTS RTS
} }
; =============================================================================
org $079CD9
JSL LinkItem_CheckForSwordSwing_Masks
; =============================================================================
org $318000 org $318000
LinkItem_CheckForSwordSwing_Masks:
{
LDA $02B2 : CMP #$01 : BNE .return
LDA #$01
RTL
.return
LDA $3B : AND.b #$10
RTL
}
; =============================================================================
; org $07A013 ; org $07A013
; JSL LinkItem_SlingshotPrepare ; JSL LinkItem_SlingshotPrepare
@@ -161,11 +125,10 @@ LinkItem_SlingshotPrepare:
org $07811A org $07811A
JSR Link_HandleDekuTransformation JSR Link_HandleDekuTransformation
; Bank 07 Free Space pullpc ; Bank 07 Free Space from minish_form
; TODO: CHECK IF THIS ACTUALLY EXECUTES CAUSE I'M NOT SURE IT DOES Link_HandleDekuTransformation: ; Link_HandleBunnyTransformation
pullpc
Link_HandleDekuTransformation:
{ {
; Check if using Quake Medallion
LDA $5D : CMP.b #$0A : BEQ .continue LDA $5D : CMP.b #$0A : BEQ .continue
JSR $82DA JSR $82DA

View File

@@ -1,5 +1,10 @@
; ============================================================================= ; =============================================================================
; Change Link Sprite with $BC ; Oracle of Secrets - Mask Library
; =============================================================================
!CurrentMask = $02B2
!LinkGraphics = $BC
; ============================================================================= ; =============================================================================
org $09912C org $09912C
@@ -11,15 +16,37 @@ org $07B073
org $078028 org $078028
Player_DoSfx2: Player_DoSfx2:
; ============================================================================= macro PlayerTransform()
LDY.b #$04 : LDA.b #$23
JSL AddTransformationCloud
LDA.b #$14 : JSR Player_DoSfx2
endmacro
; Link Sprite hook macro ResetToLinkGraphics()
org $008A01 STZ !CurrentMask
LDA $BC JSL Palette_ArmorAndGloves
LDA.b #$10 : STA !LinkGraphics
endmacro
macro CheckNewR_ButtonPress()
LDA.b $F6 : BIT.b #$10
endmacro
; =============================================================================
; Change Link's sprite by setting $BC to the bank containing a spritesheet.
; =============================================================================
org $008827 org $008827
JSL StartupMasks JSL StartupMasks
; Link Sprite hook before game starts
org $008A01
LDA $BC
; =============================================================================
; Change Link's palette based on $02B2 (mask value)
; =============================================================================
org $1BEDF9 org $1BEDF9
JSL Palette_ArmorAndGloves ; 4bytes JSL Palette_ArmorAndGloves ; 4bytes
RTL ; 1byte RTL ; 1byte
@@ -29,6 +56,10 @@ org $1BEE1B
JSL Palette_ArmorAndGloves_part_two JSL Palette_ArmorAndGloves_part_two
RTL RTL
; =============================================================================
; EXPANDED SPACE
; =============================================================================
org $3A8000 org $3A8000
StartupMasks: StartupMasks:
{ {
@@ -54,30 +85,31 @@ Palette_ArmorAndGloves:
JMP .original_sprite JMP .original_sprite
.deku_mask .deku_mask
LDA.b #$35 : STA $BC ; Load Deku Mask Location ; Load Deku Mask Location
JMP .original_palette LDA.b #$35 : STA $BC : JMP .original_palette
.zora_mask .zora_mask
LDA.b #$36 : STA $BC ; Load Zora Mask Location ; Load Zora Mask Location
JMP .original_palette LDA.b #$36 : STA $BC : JMP .original_palette
.wolf_mask .wolf_mask
LDA.b #$38 : STA $BC ; Load Wolf Mask Location ; Load Wolf Mask Location
JSL $38F000 LDA.b #$38 : STA $BC : JSL $38F000
RTL RTL
.bunny_hood .bunny_hood
LDA.b #$37 : STA $BC ; Load Bunny Hood Location ; Load Bunny Hood Location
JSL $37F000 LDA.b #$37 : STA $BC : JSL $37F000
RTL RTL
.minish_form .minish_form
LDA.b #$39 : STA $BC ; Load Minish Form Location ; Load Minish Form Location
JMP .original_palette LDA.b #$39 : STA $BC : JMP .original_palette
RTL ; RTL
.original_sprite .original_sprite
LDA.b #$10 : STA $BC ; Load Original Sprite Location ; Load Original Sprite Location
LDA.b #$10 : STA $BC
.original_palette .original_palette
REP #$21 REP #$21
@@ -131,9 +163,12 @@ Palette_ArmorAndGloves:
; ============================================================================= ; =============================================================================
; Overworld Palette Persist ; Overworld Palette Persist
; =============================================================================
Overworld_CgramAuxToMain_Override: Overworld_CgramAuxToMain_Override:
{ {
; copies the auxiliary CGRAM buffer to the main one and causes NMI to reupload the palette. ; Copies the auxiliary CGRAM buffer to the main one
; Causes NMI to reupload the palette.
REP #$20 REP #$20
@@ -161,6 +196,7 @@ Overworld_CgramAuxToMain_Override:
RTL RTL
} }
pushpc
; ============================================================================= ; =============================================================================
@@ -172,3 +208,26 @@ Overworld_CgramAuxToMain:
} }
; ============================================================================= ; =============================================================================
; Change which mask forms have access to the sword.
; =============================================================================
org $079CD9
JSL LinkItem_CheckForSwordSwing_Masks
; =============================================================================
pullpc
LinkItem_CheckForSwordSwing_Masks:
{
LDA $02B2 : BEQ .return
CMP.b #$02 : BEQ .return ; zora mask can use sword
LDA #$01
RTL
.return
LDA $3B : AND.b #$10
RTL
}
; =============================================================================

View File

@@ -12,6 +12,8 @@ incbin gfx/minish_link.4bpp
org $07DA2A org $07DA2A
TileDetection_OverworldAttributeJumpTable: TileDetection_OverworldAttributeJumpTable:
; org $07DAEB ; Tile ID 61
org $07DAF2 org $07DAF2
dw LinkState_CheckForMinishForm ; Tile ID 64 dw LinkState_CheckForMinishForm ; Tile ID 64
dw LinkState_CheckMinishTile ; Tile ID 65 dw LinkState_CheckMinishTile ; Tile ID 65
@@ -23,31 +25,25 @@ org $07F89D
LinkState_CheckForMinishForm: LinkState_CheckForMinishForm:
{ {
SEP #$30 SEP #$30
; Check for the R button (like minish cap) ; Check for the R button (like minish cap)
LDA.b $F6 : BIT.b #$10 : BNE .r_button_press %CheckNewR_ButtonPress() : BEQ .return
BRA .return
.r_button_press
LDY.b #$04 : LDA.b #$23 LDA !CurrentMask
JSL AddTransformationCloud CMP.b #$05 : BEQ .already_minish ; return to human form
LDA.b #$14 : JSR Player_DoSfx2 CMP.b #$00 : BNE .return ; don't transform if not human
%PlayerTransform()
LDA $02B2 : CMP.b #$05 : BEQ .already_minish
LDA.l $7EF359 : STA $0AA5 ; Store the current sword
LDA.l $7EF35A : STA $0AAF ; Store the current shield LDA.l $7EF35A : STA $0AAF ; Store the current shield
LDA.b #$00 : STA $7EF359 : STA $7EF35A ; Clear the sword and shield LDA.b #$00 : STA $7EF35A ; Clear the shield
LDA #$39 : STA $BC ; change link's sprite LDA #$39 : STA $BC ; Change link's sprite
LDA #$05 : STA $02B2 ; Set the current mask form LDA #$05 : STA $02B2 ; Set the current mask form
BRA .return BRA .return
.already_minish .already_minish
STZ $02B2 %PlayerTransform()
LDA $0AA5 : STA.l $7EF359 %ResetToLinkGraphics()
LDA $0AAF : STA.l $7EF35A LDA $0AAF : STA.l $7EF35A
LDA #$10 : STA $BC
.return .return
REP #$30 REP #$30

View File

@@ -58,20 +58,20 @@ LinkItem_ShovelAndFlute:
; Bank 07 Free Space ; Bank 07 Free Space
pullpc pullpc
print pc
LinkItem_WolfMask: LinkItem_WolfMask:
{ {
SEP #$30
LDA $02B2 : CMP #$03 : BNE .equip LDA $02B2 : CMP #$03 : BNE .equip
JSR LinkItem_Shovel JSR LinkItem_Shovel
.equip .equip
; Check for R button press ; Check for R button press
LDA.b $F6 : BIT.b #$10 : BEQ .return %CheckNewR_ButtonPress() : BEQ .return
LDA $6C : BNE .return ; in a doorway LDA $6C : BNE .return ; in a doorway
LDA $0FFC : BNE .return ; can't open menu LDA $0FFC : BNE .return ; can't open menu
LDY.b #$04 : LDA.b #$23 %PlayerTransform()
JSL AddTransformationCloud
LDA.b #$14 : JSR Player_DoSfx2
LDA $02B2 : CMP #$03 : BEQ .unequip ; is the wolf mask already on? LDA $02B2 : CMP #$03 : BEQ .unequip ; is the wolf mask already on?
JSL UpdateWolfPalette JSL UpdateWolfPalette
@@ -80,11 +80,10 @@ LinkItem_WolfMask:
BRA .return BRA .return
.unequip .unequip
STZ $02B2 %ResetToLinkGraphics()
JSL Palette_ArmorAndGloves
LDA #$10 : STA $BC ; take the mask off
.return .return
CLC REP #$30
RTS RTS
} }

View File

@@ -55,26 +55,21 @@ org $07A569
LinkItem_ZoraMask: LinkItem_ZoraMask:
{ {
; Check for R button held ; Check for R button held
LDA $F2 : CMP #$10 : BNE .return %CheckNewR_ButtonPress() : BEQ .return
JSR Link_CheckNewY_ButtonPress : BCC .return
LDA $3A : AND.b #$BF : STA $3A ; clear the Y button state
LDA $6C : BNE .return ; in a doorway LDA $6C : BNE .return ; in a doorway
LDA $0FFC : BNE .return ; can't open menu LDA $0FFC : BNE .return ; can't open menu
LDY.b #$04 : LDA.b #$23 %PlayerTransform()
JSL AddTransformationCloud
LDA.b #$14 : JSR Player_DoSfx2
LDA $02B2 : CMP #$02 : BEQ .unequip ; is the zora mask on? LDA $02B2 : CMP #$02 : BEQ .unequip ; is the zora mask on?
JSL UpdateZoraPalette JSL UpdateZoraPalette ; change links palette
LDA #$36 : STA $BC LDA #$36 : STA $BC ; change links graphics
LDA #$02 : STA $02B2 LDA #$02 : STA $02B2 ; set the zora mask on
BRA .return BRA .return
.unequip .unequip
JSL Palette_ArmorAndGloves %ResetToLinkGraphics()
LDA #$10 : STA $BC : STZ $02B2 ; take the mask off
.return .return
CLC CLC
@@ -102,11 +97,7 @@ org $07C307
; ============================================================================= ; =============================================================================
pullpc ; Bank07 Free Space from Deku Mask
; Bank07 Free Space
; Predecessor: Wolf Mask I think
; org $07F95D
pullpc
LinkState_UsingZoraMask: LinkState_UsingZoraMask:
{ {
; Check if the mask is equipped ; Check if the mask is equipped
@@ -265,12 +256,9 @@ LinkState_UsingZoraMask:
} }
print "==> LinkState_UsingZoraMask ", pc print "==> LinkState_UsingZoraMask ", pc
; =============================================================================
; TODO: Make this so it does not cancel if $0202 is still the same mask ; TODO: Make this so it does not cancel if $0202 is still the same mask
; corresponding to the form the player is in. ; corresponding to the form the player is in.
; Also, prevent this from canceling minish form. ; Also, prevent this from canceling minish form.
; org $07FA55
LinkState_ResetMaskAnimated: LinkState_ResetMaskAnimated:
{ {
LDA $02B2 : BEQ .no_mask LDA $02B2 : BEQ .no_mask
@@ -294,5 +282,4 @@ LinkState_ResetMaskAnimated:
RTL RTL
} }
print "==> LinkState_ResetMaskAnimated ", pc
pushpc pushpc