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

@@ -5,28 +5,28 @@
; $7EF349 bunny hood RAM slot ; $7EF349 bunny hood RAM slot
; ;
; Adjustable speed table at the end ; Adjustable speed table at the end
; db (0) $18: - Horizontal and vertical walking speed ; db (0) $18: - Horizontal and vertical walking speed
; (Default = 18) ; (Default = 18)
; db (1) $10 - Diagonal walking speed ; db (1) $10 - Diagonal walking speed
; (Default = 10) ; (Default = 10)
; db (2) $0a - Stairs walking speed ; db (2) $0a - Stairs walking speed
; (Default = 0A) ; (Default = 0A)
; db (0c) $14 - walking through heavy grass speed (also shallow water) ; db (0c) $14 - walking through heavy grass speed (also shallow water)
; (Default = 14) ; (Default = 14)
; db (0d) $0d - walking diagonally through heavy grass speed (also shallow water) ; db (0d) $0d - walking diagonally through heavy grass speed (also shallow water)
; (Default = 0D) ; (Default = 0D)
; db (10) $40 - Pegasus boots speed (Default = 40) ; db (10) $40 - Pegasus boots speed (Default = 40)
; ;
; ============================================================================= ; =============================================================================
org $378000 org $378000
incbin gfx/bunny_link.4bpp incbin gfx/bunny_link.4bpp
; ============================================================================= ; =============================================================================
UpdateBunnyPalette: UpdateBunnyPalette:
{ {
REP #$30 ; change 16bit mode REP #$30 ; change 16bit mode
LDX #$001E LDX #$001E
.loop .loop
@@ -34,8 +34,8 @@ UpdateBunnyPalette:
DEX : DEX : BPL .loop DEX : DEX : BPL .loop
SEP #$30 ; go back to 8 bit mode SEP #$30 ; go back to 8 bit mode
INC $15 ; update the palette INC $15 ; update the palette
RTL ; or RTS depending on where you need it RTL ; or RTS depending on where you need it
} }
; ============================================================================= ; =============================================================================
@@ -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:
LDA.w $0202 ; check the current item {
CMP.b #$16 : BNE end ; is it the bunny hood? CPX.b #$11 : BCS .end ; speed value upper bound check
LDA.w $02B2 ; did you put it on? LDA.w $0202 ; check the current item
BEQ end CMP.b #$16 : BNE .end ; is it the bunny hood?
LDA $20AF70,X ; load new speed values LDA.w !CurrentMask ; did you put it on?
CLC BEQ .end
RTL LDA.l BunnySpeedTable, X ; load new speed values
CLC
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 $0FFC : BNE .return ; can't open menu
LDA $6C : BNE .return ; in a doorway %PlayerTransform()
LDA $0FFC : BNE .return ; can't open menu
LDY.b #$04 : LDA.b #$23 LDA $02B2 : CMP #$04 : BEQ .unequip ; is the hood already on?
JSL AddTransformationCloud
LDA.b #$14 : JSR Player_DoSfx2
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,81 +2,45 @@
; Deku Mask ; Deku Mask
; ============================================================================= ; =============================================================================
org $358000
; =============================================================================
org $358000
incbin gfx/deku_link.bin incbin gfx/deku_link.bin
; ============================================================================= ; =============================================================================
org $07A64B ; formerly Quake 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 $6C : BNE .return ; in a doorway
LDA $3A : AND.b #$BF : STA $3A ; clear the Y button state LDA $0FFC : BNE .return ; can't open menu
LDA $6C : BNE .return ; in a doorway %PlayerTransform()
LDA $0FFC : BNE .return ; can't open menu
LDY.b #$04 : LDA.b #$23 LDA $02B2 : CMP #$01 : BEQ .unequip ; is the deku mask on?
JSL AddTransformationCloud JSL Palette_ArmorAndGloves ; set the palette
LDA.b #$14 : JSR Player_DoSfx2
LDA $02B2 : CMP #$01 : BEQ .unequip ; is the deku mask on?
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
@@ -111,47 +75,47 @@ LinkItem_SlingshotPrepare:
; $A309 ; $A309
.gamma .gamma
LDA #$01 ; Load the accumulator with hex value 01 LDA #$01 ; Load the accumulator with hex value 01
STA $7F502E ; Store the accumulator value at memory address 7F502E STA $7F502E ; Store the accumulator value at memory address 7F502E
PHB ; Push data bank register on stack PHB ; Push data bank register on stack
REP #$30 ; Clear 16-bit accumulator and index registers REP #$30 ; Clear 16-bit accumulator and index registers
LDX #$A500 ; Load X register with source address LDX #$A500 ; Load X register with source address
LDY #$9800 ; Load Y register with destination address LDY #$9800 ; Load Y register with destination address
LDA #$00BF ; Load the accumulator with the number of bytes to be moved 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 MVN $20, $7E ; Block move negative - moves 00BF bytes from $A500 to $9800
SEP #$30 ; Set 8-bit accumulator and index registers SEP #$30 ; Set 8-bit accumulator and index registers
PLB ; Pull data bank register from stack PLB ; Pull data bank register from stack
.loop .loop
LDA $4212 : AND #$80 : BNE .loop ; Wait for VBlank start (beginning of vertical blanking period) LDA $4212 : AND #$80 : BNE .loop ; Wait for VBlank start (beginning of vertical blanking period)
.loop2 .loop2
LDA $4212 : AND #$80 : BEQ .loop2 ; Wait for VBlank end LDA $4212 : AND #$80 : BEQ .loop2 ; Wait for VBlank end
REP #$30 ; Clear 16-bit accumulator and index registers REP #$30 ; Clear 16-bit accumulator and index registers
LDA #$A700 : STA $4302 ; Set DMA source address to $A700 LDA #$A700 : STA $4302 ; Set DMA source address to $A700
LDA #$42A0 : STA $2116 ; Set VRAM (Video RAM) address to $42A0 LDA #$42A0 : STA $2116 ; Set VRAM (Video RAM) address to $42A0
SEP #$30 ; Set 8-bit accumulator and index registers 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 #$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 #$18 : STA $4301 ; Set DMA destination address to $2118 (VRAM data write)
LDA #$20 : STA $4304 ; Set DMA transfer size to 32 bytes LDA #$20 : STA $4304 ; Set DMA transfer size to 32 bytes
LDA #$80 : STA $4305 ; Set DMA transfer size (high byte) LDA #$80 : STA $4305 ; Set DMA transfer size (high byte)
LDA #$01 : STA $4300 ; Set DMA mode to 1 (2 registers write once) LDA #$01 : STA $4300 ; Set DMA mode to 1 (2 registers write once)
STA $420B ; Start DMA on channel 0 STA $420B ; Start DMA on channel 0
REP #$30 ; Clear 16-bit accumulator and index registers REP #$30 ; Clear 16-bit accumulator and index registers
LDA #$43A0 : STA $2116 ; Set VRAM address to $43A0 LDA #$43A0 : STA $2116 ; Set VRAM address to $43A0
LDA #$A800 : STA $4302 ; Set DMA source address to $A800 LDA #$A800 : STA $4302 ; Set DMA source address to $A800
SEP #$30 ; Set 8-bit accumulator and index registers 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 #$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 #$18 : STA $4301 ; Set DMA destination address to $2118 (VRAM data write)
LDA #$20 : STA $4304 ; Set DMA transfer size to 32 bytes LDA #$20 : STA $4304 ; Set DMA transfer size to 32 bytes
LDA #$80 : STA $4305 ; Set DMA transfer size (high byte) LDA #$80 : STA $4305 ; Set DMA transfer size (high byte)
LDA #$01 : STA $4300 ; Set DMA mode to 1 (2 registers write once) LDA #$01 : STA $4300 ; Set DMA mode to 1 (2 registers write once)
STA $420B ; Start DMA on channel 0 STA $420B ; Start DMA on channel 0
RTL ; Return from subroutine long RTL ; Return from subroutine long
} }
@@ -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,24 +16,50 @@ 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
NOP #$01 NOP #$01
org $1BEE1B org $1BEE1B
JSL Palette_ArmorAndGloves_part_two JSL Palette_ArmorAndGloves_part_two
RTL RTL
; =============================================================================
; EXPANDED SPACE
; =============================================================================
org $3A8000 org $3A8000
StartupMasks: StartupMasks:
{ {
@@ -46,49 +77,50 @@ StartupMasks:
Palette_ArmorAndGloves: Palette_ArmorAndGloves:
{ {
LDA $02B2 : CMP #$01 : BEQ .deku_mask LDA $02B2 : CMP #$01 : BEQ .deku_mask
CMP.b #$02 : BEQ .zora_mask CMP.b #$02 : BEQ .zora_mask
CMP.b #$03 : BEQ .wolf_mask CMP.b #$03 : BEQ .wolf_mask
CMP.b #$04 : BEQ .bunny_hood CMP.b #$04 : BEQ .bunny_hood
CMP.b #$05 : BEQ .minish_form CMP.b #$05 : BEQ .minish_form
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
LDA $7EF35B ; Link's armor value LDA $7EF35B ; Link's armor value
JSL $1BEDFF ; Read Original Palette Code JSL $1BEDFF ; Read Original Palette Code
RTL RTL
.part_two .part_two
SEP #$30 SEP #$30
REP #$30 REP #$30
LDA.w #$0000 ; Ignore glove color modifier $7EF354 LDA.w #$0000 ; Ignore glove color modifier $7EF354
JSL $1BEE21 ; Read Original Palette Code JSL $1BEE21 ; Read Original Palette Code
RTL RTL
PHX : PHY : PHA PHX : PHY : PHA
@@ -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

@@ -4,14 +4,16 @@
; Reacts to Tile ID 64 to transform into Minish Link ; Reacts to Tile ID 64 to transform into Minish Link
; ============================================================================= ; =============================================================================
org $398000 org $398000
incbin gfx/minish_link.4bpp 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
@@ -58,8 +54,8 @@ LinkState_CheckForMinishForm:
LinkState_CheckMinishTile: LinkState_CheckMinishTile:
{ {
LDA $02B2 : BEQ .blocked ; no form LDA $02B2 : BEQ .blocked ; no form
CMP.b #$05 : BNE .blocked ; not minish CMP.b #$05 : BNE .blocked ; not minish
LDA $0A : TSB $0343 LDA $0A : TSB $0343
RTS RTS

View File

@@ -6,14 +6,14 @@
; ;
; ============================================================================= ; =============================================================================
org $388000 org $388000
incbin gfx/wolf_link.4bpp incbin gfx/wolf_link.4bpp
; ============================================================================= ; =============================================================================
UpdateWolfPalette: UpdateWolfPalette:
{ {
REP #$30 ; change 16bit mode REP #$30 ; change 16bit mode
LDX #$001E LDX #$001E
.loop .loop
@@ -21,8 +21,8 @@ UpdateWolfPalette:
DEX : DEX : BPL .loop DEX : DEX : BPL .loop
SEP #$30 ; go back to 8 bit mode SEP #$30 ; go back to 8 bit mode
INC $15 ; update the palette INC $15 ; update the palette
RTL ; or RTS depending on where you need it RTL ; or RTS depending on where you need it
} }
; ============================================================================= ; =============================================================================
@@ -58,33 +58,32 @@ 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
LDA #$38 : STA $BC ; change link's sprite LDA #$38 : STA $BC ; change link's sprite
LDA #$03 : STA $02B2 LDA #$03 : STA $02B2
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

@@ -16,22 +16,22 @@
; ;
; ============================================================================= ; =============================================================================
org $368000 org $368000
incbin gfx/zora_link.4bpp incbin gfx/zora_link.4bpp
; ============================================================================= ; =============================================================================
UpdateZoraPalette: UpdateZoraPalette:
{ {
REP #$30 ; change 16 bit mode REP #$30 ; change 16 bit mode
LDX #$001E LDX #$001E
.loop .loop
LDA.l zora_palette, X : STA $7EC6E0, X LDA.l zora_palette, X : STA $7EC6E0, X
DEX : DEX : BPL .loop DEX : DEX : BPL .loop
SEP #$30 ; go back to 8 bit mode SEP #$30 ; go back to 8 bit mode
INC $15 ; update the palette INC $15 ; update the palette
RTL RTL
} }
@@ -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 $6C : BNE .return ; in a doorway
LDA $3A : AND.b #$BF : STA $3A ; clear the Y button state LDA $0FFC : BNE .return ; can't open menu
LDA $6C : BNE .return ; in a doorway %PlayerTransform()
LDA $0FFC : BNE .return ; can't open menu
LDY.b #$04 : LDA.b #$23 LDA $02B2 : CMP #$02 : BEQ .unequip ; is the zora mask on?
JSL AddTransformationCloud JSL UpdateZoraPalette ; change links palette
LDA.b #$14 : JSR Player_DoSfx2 LDA #$36 : STA $BC ; change links graphics
LDA #$02 : STA $02B2 ; set the zora mask on
LDA $02B2 : CMP #$02 : BEQ .unequip ; is the zora mask on?
JSL UpdateZoraPalette
LDA #$36 : STA $BC
LDA #$02 : STA $02B2
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
@@ -138,10 +129,10 @@ LinkState_UsingZoraMask:
; Check if already underwater ; Check if already underwater
LDA $0AAB : BEQ .dive LDA $0AAB : BEQ .dive
STZ $55 ; Reset cape flag STZ $55 ; Reset cape flag
STZ $0AAB ; Reset underwater flag STZ $0AAB ; Reset underwater flag
STZ $0351 ; Reset ripple flag STZ $0351 ; Reset ripple flag
STZ $037B ; Reset invincibility flag STZ $037B ; Reset invincibility flag
LDA #$04 : STA $5D ; Put Link in Swimming State LDA #$04 : STA $5D ; Put Link in Swimming State
JMP .return JMP .return
@@ -156,7 +147,7 @@ LinkState_UsingZoraMask:
; Splash visual effect ; Splash visual effect
LDA.b #$15 : LDY.b #$00 LDA.b #$15 : LDY.b #$00
JSL AddTransitionSplash JSL AddTransitionSplash
; Stay in swimming mode ; Stay in swimming mode
LDA #$04 : STA $5D LDA #$04 : STA $5D
@@ -187,21 +178,21 @@ LinkState_UsingZoraMask:
.dive_dungeon .dive_dungeon
; Splash effect ; Splash effect
LDA.b #$15 : LDY.b #$00 LDA.b #$15 : LDY.b #$00
JSL AddTransitionSplash JSL AddTransitionSplash
STZ $5D ; reset player to ground state STZ $5D ; reset player to ground state
STZ $EE ; move link to lower level STZ $EE ; move link to lower level
LDA #$72 LDA #$72
STA $9A ; Set layer STA $9A ; Set layer
LDA #$08 LDA #$08
STA $5E ; Set the player speed STA $5E ; Set the player speed
STZ $0345 STZ $0345
LDA #$01 LDA #$01
STA $0AAB ; Set the player underwater flag STA $0AAB ; Set the player underwater flag
.return_dungeon .return_dungeon
JSR $E8F0 ; HandleIndoorCameraAndDoors JSR $E8F0 ; HandleIndoorCameraAndDoors
@@ -238,12 +229,12 @@ LinkState_UsingZoraMask:
; Remove Diving Effects ; Remove Diving Effects
LDA $67 : AND #$01 : STA $2F LDA $67 : AND #$01 : STA $2F
STZ $5E ; Reset speed to normal STZ $5E ; Reset speed to normal
STZ $0AAB ; Reset underwater flag STZ $0AAB ; Reset underwater flag
STZ $0351 ; Reset ripple flag STZ $0351 ; Reset ripple flag
STZ $24 ; Reset z coordinate for link STZ $24 ; Reset z coordinate for link
STZ $0372 ; Reset link bounce flag STZ $0372 ; Reset link bounce flag
LDA #$62 : STA $9A ; Reset dungeon layer LDA #$62 : STA $9A ; Reset dungeon layer
JMP .return_default JMP .return_default
} }
@@ -256,21 +247,18 @@ LinkState_UsingZoraMask:
.dungeon_stairs .dungeon_stairs
{ {
LDA $02B2 : CMP #$02 : BNE .return_hop LDA $02B2 : CMP #$02 : BNE .return_hop
STZ $5E ; Reset speed to normal STZ $5E ; Reset speed to normal
STZ $0AAB ; Reset underwater flag STZ $0AAB ; Reset underwater flag
LDA #$62 : STA $9A ; Reset dungeon layer LDA #$62 : STA $9A ; Reset dungeon layer
.return_hop .return_hop
LDA #$06 : STA $5D ; Set Link to Recoil State LDA #$06 : STA $5D ; Set Link to Recoil State
RTS RTS
} }
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
@@ -284,7 +272,7 @@ LinkState_ResetMaskAnimated:
.transform .transform
LDY.b #$04 : LDA.b #$23 LDY.b #$04 : LDA.b #$23
JSL AddTransformationCloud JSL AddTransformationCloud
LDA.b #$14 : JSR Player_DoSfx2 LDA.b #$14 : JSR Player_DoSfx2
STZ $02B2 STZ $02B2
@@ -294,5 +282,4 @@ LinkState_ResetMaskAnimated:
RTL RTL
} }
print "==> LinkState_ResetMaskAnimated ", pc
pushpc pushpc