hook vanilla HUD code

This commit is contained in:
Justin Scofield
2022-09-30 20:51:47 -05:00
parent 793c52c75c
commit 61c921a342
2 changed files with 240 additions and 223 deletions

View File

@@ -387,8 +387,6 @@ Menu_ScrollUp:
.loop .loop
DEX : DEX : STX.w MenuScrollLevelV DEX : DEX : STX.w MenuScrollLevelV
JSL Menu_UpdateHudItem
RTS RTS
} }
@@ -426,7 +424,6 @@ Menu_Exit:
.no_item .no_item
REP #$20 REP #$20
STZ $0200 STZ $0200
;;STZ $11
LDA.w $010C LDA.w $010C
STA.b $10 STA.b $10
@@ -442,81 +439,9 @@ Menu_Exit:
RTS RTS
} }
; =============================================================================
; XX MENU HIJACK HUD
HudItems:
dw BowsGFX
dw BoomsGFX
dw HookGFX
dw BombsGFX
dw DekuMaskGFX
dw BottlesGFX
dw Fire_rodGFX
dw Ice_rodGFX
dw LampGFX
dw HammerGFX
dw GoronMaskGFX
dw BottlesGFX
dw SomariaGFX
dw ByrnaGFX
dw BookGFX
dw JumpFeatherGFX
dw BunnyHoodGFX
dw BottlesGFX
dw OcarinaGFX
dw MirrorGFX
dw ShovelGFX
dw PowderGFX
dw StoneMaskGFX
dw BottlesGFX
; LDA.w $0202
; ASL : TAX
; LDY.w HudItems-2, X
Menu_UpdateHudItem:
{
PHB
PHK
PLB
; print pc
; SEP #$30
; LDA.b #$7E : STA.b $0C ; set the indirect bank
; REP #$30
; LDA.w $0202
; ASL : TAX
; LDY.w HudItems-2, X
; STY.b $00
; LDY.w $0202
; LDX.w Menu_AddressIndex-1, Y
; LDA.l $7EF300, X
; STA.w $08
; LDA.b [$08]
; ADC.b $00
; TAY
REP #$30
LDA.w $0202
ASL : TAX
LDY.w HudItems-2, X
LDA.w $0000,Y : STA.l $7EC778
LDA.w $0002,Y : STA.l $7EC77A
LDA.w $0004,Y : STA.l $7EC7B8
LDA.w $0006,Y : STA.l $7EC7BA
SEP #$30
PLB
RTL
}
; ============================================================================= ; =============================================================================
incsrc "menu_draw_bg.asm" incsrc "menu_draw_bg.asm"
incsrc "lw_map_names.asm" incsrc "lw_map_names.asm"
incsrc "menu_hud.asm"
; ============================================================================= ; =============================================================================

View File

@@ -2,159 +2,164 @@ org $0DFB91
JSL NewMenuUpdate JSL NewMenuUpdate
RTS RTS
org $3D8000 newIgnoreItemBox:
JSL NewMenuUpdate_ignoreItemBox
RTS
org $0DDD21
JSR newIgnoreItemBox
org $268000
NewMenuUpdate: NewMenuUpdate:
{ {
PHB : PHK : PLB
JSR Hud_UpdateItemBox JSR Hud_UpdateItemBox
; ; *$6FB94 ALTERNATE ENTRY POINT ; *$6FB94 ALTERNATE ENTRY POINT
; .ignoreItemBox .ignoreItemBox
; SEP #$30 SEP #$30
; ; the hook for optimization was placed here... ; the hook for optimization was placed here...
; ; need to draw partial heart still though. update: optimization complete with great results ; need to draw partial heart still though. update: optimization complete with great results
; LDA.b #$FD : STA $0A LDA.b #$FD : STA $0A
; LDA.b #$F9 : STA $0B LDA.b #$F9 : STA $0B
; LDA.b #$0D : STA $0C LDA.b #$0D : STA $0C
; LDA.b #$68 : STA $07 LDA.b #$68 : STA $07
; LDA.b #$C7 : STA $08 LDA.b #$C7 : STA $08
; LDA.b #$7E : STA $09 LDA.b #$7E : STA $09
; REP #$30 REP #$30
; ; Load Capacity health. ; Load Capacity health.
; LDA $7EF36C : AND.w #$00FF : STA $00 : STA $02 : STA $04 LDA $7EF36C : AND.w #$00FF : STA $00 : STA $02 : STA $04
; ; First, just draw all the empty hearts (capacity health) ; First, just draw all the empty hearts (capacity health)
; JSR HUD_UpdateHearts JSR HUD_UpdateHearts
; SEP #$30 SEP #$30
; LDA.b #$03 : STA $0A LDA.b #$03 : STA $0A
; LDA.b #$FA : STA $0B LDA.b #$FA : STA $0B
; LDA.b #$0D : STA $0C LDA.b #$0D : STA $0C
; LDA.b #$68 : STA $07 LDA.b #$68 : STA $07
; LDA.b #$C7 : STA $08 LDA.b #$C7 : STA $08
; LDA.b #$7E : STA $09 LDA.b #$7E : STA $09
; ; Branch if at full health ; Branch if at full health
; LDA $7EF36C : CMP $7EF36D : BEQ .healthUpdated LDA $7EF36C : CMP $7EF36D : BEQ .healthUpdated
; ; Seems absurd to have a branch of zero bytes, right? ; Seems absurd to have a branch of zero bytes, right?
; SBC #$04 : CMP $7EF36D : BCS .healthUpdated SBC #$04 : CMP $7EF36D : BCS .healthUpdated
; .healthUpdated .healthUpdated
; ; A = actual health + 0x03; ; A = actual health + 0x03;
; LDA $7EF36D : ADC #$03 LDA $7EF36D : ADC.b #$03
; REP #$30 REP #$30
; AND.w #$00FC : STA $00 : STA $04 AND.w #$00FC : STA $00 : STA $04
; LDA $7EF36C : AND.w #$00FF : STA $02 LDA $7EF36C : AND.w #$00FF : STA $02
; ; this time we're filling in the full and partially filled hearts (actual health) ; this time we're filling in the full and partially filled hearts (actual health)
; JSR HUD_UpdateHearts JSR HUD_UpdateHearts
; ; *$6FC09 ALTERNATE ENTRY POINT ; reentry hook ; *$6FC09 ALTERNATE ENTRY POINT ; reentry hook
; .ignoreHealth .ignoreHealth
; REP #$30 REP #$30
; ; Magic amount indicator (normal, 1/2, or 1/4) ; Magic amount indicator (normal, 1/2, or 1/4)
; LDA $7EF37B : AND.w #$00FF : CMP.w #$0001 : BCC .normalMagicMeter LDA $7EF37B : AND.w #$00FF : CMP.w #$0001 : BCC .normalMagicMeter
; ; draws a 1/2 magic meter (note, we could add in the 1/4 magic meter here if ; draws a 1/2 magic meter (note, we could add in the 1/4 magic meter here if
; ; we really cared about that >_> ; we really cared about that >_>
; LDA.w #$28F7 : STA $7EC704 LDA.w #$28F7 : STA $7EC704
; LDA.w #$2851 : STA $7EC706 LDA.w #$2851 : STA $7EC706
; LDA.w #$28FA : STA $7EC708 LDA.w #$28FA : STA $7EC708
; .normalMagicMeter .normalMagicMeter
; ; check how much magic power the player has at the moment (ranges from 0 to 0x7F) ; check how much magic power the player has at the moment (ranges from 0 to 0x7F)
; ; X = ((MP & 0xFF)) + 7) & 0xFFF8) ; X = ((MP & 0xFF)) + 7) & 0xFFF8)
; LDA $7EF36E : AND.w #$00FF : ADC #$0007 : AND.w #$FFF8 : TAX LDA $7EF36E : AND.w #$00FF : ADC.w #$0007 : AND.w #$FFF8 : TAX
; ; these four writes draw the magic power bar based on how much MP you have ; these four writes draw the magic power bar based on how much MP you have
; LDA MagicTilemap+0, X : STA $7EC746 LDA MagicTilemap+0, X : STA $7EC746
; LDA MagicTilemap+2, X : STA $7EC786 LDA MagicTilemap+2, X : STA $7EC786
; LDA MagicTilemap+4, X : STA $7EC7C6 LDA MagicTilemap+4, X : STA $7EC7C6
; LDA MagicTilemap+6, X : STA $7EC806 LDA MagicTilemap+6, X : STA $7EC806
; ; Load how many rupees the player has ; Load how many rupees the player has
; LDA $7EF362 LDA $7EF362
; JSR HexToDecimal JSR HexToDecimal
; REP #$30 REP #$30
; ; The tile index for the first rupee digit ; The tile index for the first rupee digit
; LDA $03 : AND.w #$00FF : ORA.w #$2400 : STA $7EC750 LDA $03 : AND.w #$00FF : ORA.w #$2400 : STA $7EC750
; ; The tile index for the second rupee digit ; The tile index for the second rupee digit
; LDA $04 : AND.w #$00FF : ORA.w #$2400 : STA $7EC752 LDA $04 : AND.w #$00FF : ORA.w #$2400 : STA $7EC752
; ; The tile index for the third rupee digit ; The tile index for the third rupee digit
; LDA $05 : AND.w #$00FF : ORA.w #$2400 : STA $7EC754 LDA $05 : AND.w #$00FF : ORA.w #$2400 : STA $7EC754
; ; Number of bombs Link has. ; Number of bombs Link has.
; LDA $7EF343 : AND.w #$00FF LDA $7EF343 : AND.w #$00FF
; JSR HexToDecimal JSR HexToDecimal
; REP #$30 REP #$30
; ; The tile index for the first bomb digit ; The tile index for the first bomb digit
; LDA $04 : AND.w #$00FF : ORA.w #$2400 : STA $7EC758 LDA $04 : AND.w #$00FF : ORA.w #$2400 : STA $7EC758
; ; The tile index for the second bomb digit ; The tile index for the second bomb digit
; LDA $05 : AND.w #$00FF : ORA.w #$2400 : STA $7EC75A LDA $05 : AND.w #$00FF : ORA.w #$2400 : STA $7EC75A
; ; Number of Arrows Link has. ; Number of Arrows Link has.
; LDA $7EF377 : AND.w #$00FF LDA $7EF377 : AND.w #$00FF
; ; converts hex to up to 3 decimal digits ; converts hex to up to 3 decimal digits
; JSR HexToDecimal JSR HexToDecimal
; REP #$30 REP #$30
; ; ; The tile index for the first arrow digit ; The tile index for the first arrow digit
; ; LDA $04 : AND.w #$00FF : ORA.w #$2400 : STA $7EC75E LDA $04 : AND.w #$00FF : ORA.w #$2400 : STA $7EC75E
; ; ; The tile index for the second arrow digit ; The tile index for the second arrow digit
; ; LDA $05 : AND.w #$00FF : ORA.w #$2400 : STA $7EC760 LDA $05 : AND.w #$00FF : ORA.w #$2400 : STA $7EC760
; ; LDA.w #$007F : STA $05 LDA.w #$007F : STA $05
; ; Load number of Keys Link has ; Load number of Keys Link has
; LDA $7EF36F : AND.w #$00FF : CMP.w #$00FF : BEQ .noKeys LDA $7EF36F : AND.w #$00FF : CMP.w #$00FF : BEQ .noKeys
; JSR HexToDecimal JSR HexToDecimal
; .noKeys .noKeys
; REP #$30 REP #$30
; ; The key digit, which is optionally drawn. ; The key digit, which is optionally drawn.
; ; Also check to see if the key spot is blank ; Also check to see if the key spot is blank
; LDA $05 : AND.w #$00FF : ORA.w #$2400 : STA $7EC764 LDA $05 : AND.w #$00FF : ORA.w #$2400 : STA $7EC764
; CMP.w #$247F : BNE .dontBlankKeyIcon CMP.w #$247F : BNE .dontBlankKeyIcon
; ; If the key digit is blank, also blank out the key icon. ; If the key digit is blank, also blank out the key icon.
; STA $7EC724 STA $7EC724
; .dontBlankKeyIcon .dontBlankKeyIcon
; SEP #$30 SEP #$30
PLB
RTL RTL
} }
@@ -189,6 +194,7 @@ HudItems:
Hud_UpdateItemBox: Hud_UpdateItemBox:
{ {
REP #$30
LDA.w $0202 LDA.w $0202
ASL : TAX ASL : TAX
LDY.w HudItems-2, X LDY.w HudItems-2, X
@@ -197,13 +203,95 @@ Hud_UpdateItemBox:
LDA.w $0002,Y : STA.l $7EC77A LDA.w $0002,Y : STA.l $7EC77A
LDA.w $0004,Y : STA.l $7EC7B8 LDA.w $0004,Y : STA.l $7EC7B8
LDA.w $0006,Y : STA.l $7EC7BA LDA.w $0006,Y : STA.l $7EC7BA
SEP #$30
RTS
}
Vanilla_UpdateItemBox:
{
SEP #$30
; Dost thou haveth the the bow?
LDA $7EF340 : BEQ .havethNoBow
; Dost thou haveth the silver arrows?
; (okay I'll stop soon)
CMP.b #$03 : BCC .havethNoSilverArrows
; Draw the arrow guage icon as silver rather than normal wood arrows.
LDA.b #$86 : STA $7EC71E
LDA.b #$24 : STA $7EC71F
LDA.b #$87 : STA $7EC720
LDA.b #$24 : STA $7EC721
LDX.b #$04
; check how many arrows the player has
LDA $7EF377 : BNE .drawBowItemIcon
LDX.b #$03
BRA .drawBowItemIcon
.havethNoSilverArrows
LDX.b #$02
LDA $7EF377 : BNE .drawBowItemIcon
LDX.b #$01
.drawBowItemIcon
; values of X correspond to how the icon will end up drawn:
; 0x01 - normal bow with no arrows
; 0x02 - normal bow with arrows
; 0x03 - silver bow with no silver arrows
; 0x04 - silver bow with silver arrows
TXA : STA $7EF340
.havethNoBow
REP #$30
LDX $0202 : BEQ .noEquippedItem
LDA $7EF33F, X : AND.w #$00FF
CPX.w #$0004 : BNE .bombsNotEquipped
LDA.w #$0001
.bombsNotEquipped
CPX.w #$0010 : BNE .bottleNotEquipped
TXY : TAX : LDA $7EF35B, X : AND.w #$00FF : TYX
.bottleNotEquipped
STA $02
TXA : DEC A : ASL A : TAX
LDA $FA93, X : STA $04
LDA $02 : ASL #3 : TAY
; These addresses form the item box graphics.
LDA ($04), Y : STA $7EC74A : INY #2
LDA ($04), Y : STA $7EC74C : INY #2
LDA ($04), Y : STA $7EC78A : INY #2
LDA ($04), Y : STA $7EC78C : INY #2
.noEquippedItem
RTS RTS
} }
; ============================================================================== ; ==============================================================================
HUD_UpdateHearts: HUD_UpdateHearts:
{ {
; Draws hearts in a painfully slow loop ; Draws hearts in a painfully slow loop
@@ -255,7 +343,7 @@ HUD_UpdateHearts:
; if not, we have to move down one tile in the tilemap ; if not, we have to move down one tile in the tilemap
LDX.w #$0000 LDX.w #$0000
LDA $07 : ADC #$0040 : STA $07 LDA $07 : ADC.w #$0040 : STA $07
.noLineChange .noLineChange
@@ -264,6 +352,8 @@ HUD_UpdateHearts:
RTS RTS
} }
; ==============================================================================
MagicTilemap: MagicTilemap:
dw $3CF5, $3CF5, $3CF5, $3CF5 dw $3CF5, $3CF5, $3CF5, $3CF5
dw $3CF5, $3CF5, $3CF5, $3C5F dw $3CF5, $3CF5, $3CF5, $3C5F
@@ -283,6 +373,8 @@ MagicTilemap:
dw $3C4D, $3C5E, $3C5E, $3C5E dw $3C4D, $3C5E, $3C5E, $3C5E
dw $3C4E, $3C5E, $3C5E, $3C5E dw $3C4E, $3C5E, $3C5E, $3C5E
; ==============================================================================
HexToDecimal: HexToDecimal:
{ {
; This apparently is a hex to decimal converter for use with displaying numbers ; This apparently is a hex to decimal converter for use with displaying numbers