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
org $87FD66
JSL $20AF20
JSL LinkState_BunnyHoodRun
RTS
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
CMP.b #$16 : BNE end ; is it the bunny hood?
LDA.w $02B2 ; did you put it on?
BEQ end
LDA $20AF70,X ; load new speed values
CMP.b #$16 : BNE .end ; is it the bunny hood?
LDA.w !CurrentMask ; did you put it on?
BEQ .end
LDA.l BunnySpeedTable, X ; load new speed values
CLC
RTL
end: {
.end
LDA $87E227, X ; load native speed values
CLC
RTL
}
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
}
; =============================================================================
; Press R to transform into bunny form and run faster.
; =============================================================================
org $07A494
LinkItem_Ether:
{
JSR Link_CheckNewY_ButtonPress : BCC .return
LDA $3A : AND.b #$BF : STA $3A ; clear the Y button state
%CheckNewR_ButtonPress() : BEQ .return
LDA $6C : BNE .return ; in a doorway
LDA $0FFC : BNE .return ; can't open menu
LDY.b #$04 : LDA.b #$23
JSL AddTransformationCloud
LDA.b #$14 : JSR Player_DoSfx2
%PlayerTransform()
LDA $02B2 : CMP #$04 : BEQ .unequip ; is the hood already on?
JSL UpdateBunnyPalette
LDA #$37 : STA $BC ; change link's sprite
LDA #$04 : STA $02B2
BRA .return
.unequip
STZ $02B2
JSL Palette_ArmorAndGloves
LDA #$10 : STA $BC ; take the hood off
%ResetToLinkGraphics()
.return
CLC

View File

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

View File

@@ -1,5 +1,10 @@
; =============================================================================
; Change Link Sprite with $BC
; Oracle of Secrets - Mask Library
; =============================================================================
!CurrentMask = $02B2
!LinkGraphics = $BC
; =============================================================================
org $09912C
@@ -11,15 +16,37 @@ org $07B073
org $078028
Player_DoSfx2:
; =============================================================================
macro PlayerTransform()
LDY.b #$04 : LDA.b #$23
JSL AddTransformationCloud
LDA.b #$14 : JSR Player_DoSfx2
endmacro
; Link Sprite hook
org $008A01
LDA $BC
macro ResetToLinkGraphics()
STZ !CurrentMask
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
JSL StartupMasks
; Link Sprite hook before game starts
org $008A01
LDA $BC
; =============================================================================
; Change Link's palette based on $02B2 (mask value)
; =============================================================================
org $1BEDF9
JSL Palette_ArmorAndGloves ; 4bytes
RTL ; 1byte
@@ -29,6 +56,10 @@ org $1BEE1B
JSL Palette_ArmorAndGloves_part_two
RTL
; =============================================================================
; EXPANDED SPACE
; =============================================================================
org $3A8000
StartupMasks:
{
@@ -54,30 +85,31 @@ Palette_ArmorAndGloves:
JMP .original_sprite
.deku_mask
LDA.b #$35 : STA $BC ; Load Deku Mask Location
JMP .original_palette
; Load Deku Mask Location
LDA.b #$35 : STA $BC : JMP .original_palette
.zora_mask
LDA.b #$36 : STA $BC ; Load Zora Mask Location
JMP .original_palette
; Load Zora Mask Location
LDA.b #$36 : STA $BC : JMP .original_palette
.wolf_mask
LDA.b #$38 : STA $BC ; Load Wolf Mask Location
JSL $38F000
; Load Wolf Mask Location
LDA.b #$38 : STA $BC : JSL $38F000
RTL
.bunny_hood
LDA.b #$37 : STA $BC ; Load Bunny Hood Location
JSL $37F000
; Load Bunny Hood Location
LDA.b #$37 : STA $BC : JSL $37F000
RTL
.minish_form
LDA.b #$39 : STA $BC ; Load Minish Form Location
JMP .original_palette
RTL
; Load Minish Form Location
LDA.b #$39 : STA $BC : JMP .original_palette
; RTL
.original_sprite
LDA.b #$10 : STA $BC ; Load Original Sprite Location
; Load Original Sprite Location
LDA.b #$10 : STA $BC
.original_palette
REP #$21
@@ -131,9 +163,12 @@ Palette_ArmorAndGloves:
; =============================================================================
; Overworld Palette Persist
; =============================================================================
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
@@ -161,6 +196,7 @@ Overworld_CgramAuxToMain_Override:
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
TileDetection_OverworldAttributeJumpTable:
; org $07DAEB ; Tile ID 61
org $07DAF2
dw LinkState_CheckForMinishForm ; Tile ID 64
dw LinkState_CheckMinishTile ; Tile ID 65
@@ -23,31 +25,25 @@ org $07F89D
LinkState_CheckForMinishForm:
{
SEP #$30
; Check for the R button (like minish cap)
LDA.b $F6 : BIT.b #$10 : BNE .r_button_press
BRA .return
.r_button_press
%CheckNewR_ButtonPress() : BEQ .return
LDY.b #$04 : LDA.b #$23
JSL AddTransformationCloud
LDA.b #$14 : JSR Player_DoSfx2
LDA !CurrentMask
CMP.b #$05 : BEQ .already_minish ; return to human form
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.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
BRA .return
.already_minish
STZ $02B2
LDA $0AA5 : STA.l $7EF359
%PlayerTransform()
%ResetToLinkGraphics()
LDA $0AAF : STA.l $7EF35A
LDA #$10 : STA $BC
.return
REP #$30

View File

@@ -58,20 +58,20 @@ LinkItem_ShovelAndFlute:
; Bank 07 Free Space
pullpc
print pc
LinkItem_WolfMask:
{
SEP #$30
LDA $02B2 : CMP #$03 : BNE .equip
JSR LinkItem_Shovel
.equip
; 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 $0FFC : BNE .return ; can't open menu
LDY.b #$04 : LDA.b #$23
JSL AddTransformationCloud
LDA.b #$14 : JSR Player_DoSfx2
%PlayerTransform()
LDA $02B2 : CMP #$03 : BEQ .unequip ; is the wolf mask already on?
JSL UpdateWolfPalette
@@ -80,11 +80,10 @@ LinkItem_WolfMask:
BRA .return
.unequip
STZ $02B2
JSL Palette_ArmorAndGloves
LDA #$10 : STA $BC ; take the mask off
%ResetToLinkGraphics()
.return
CLC
REP #$30
RTS
}

View File

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