Merged in DR v1.4.1.6
This commit is contained in:
776
newhud.asm
776
newhud.asm
@@ -1,296 +1,558 @@
|
||||
!InfiniteTile = $2431
|
||||
!BlankTile = $207F
|
||||
!SlashTile = $2830
|
||||
!PTile = $296C
|
||||
!CTile = $295F
|
||||
|
||||
NewDrawHud:
|
||||
PHB
|
||||
|
||||
SEP #$30
|
||||
;================================================================================
|
||||
; Draw bomb count
|
||||
!BOMBCOUNT_DRAW_ADDRESS = "$7EC75A"
|
||||
!INFINITE_BOMBS = "$7F50C9"
|
||||
;================================================================================
|
||||
REP #$10
|
||||
|
||||
LDA !INFINITE_BOMBS : BNE .infinite_bombs
|
||||
.finite_bombs
|
||||
LDA.l $7EF343 ; bombs
|
||||
JSR HudHexToDec2Digit ;requires 8 bit registers!
|
||||
REP #$20
|
||||
LDX.b $06 : TXA : ORA.w #$2400 : STA !BOMBCOUNT_DRAW_ADDRESS ; Draw bombs 10 digit
|
||||
LDX.b $07 : TXA : ORA.w #$2400 : STA !BOMBCOUNT_DRAW_ADDRESS+2 ; Draw bombs 1 digit
|
||||
BRA +
|
||||
|
||||
.infinite_bombs
|
||||
REP #$20
|
||||
LDA.w #$2431 : STA !BOMBCOUNT_DRAW_ADDRESS ; infinity (left half)
|
||||
INC A : STA !BOMBCOUNT_DRAW_ADDRESS+2 ; infinity (right half)
|
||||
+
|
||||
LDA.b #$7E
|
||||
PHA : PLB
|
||||
|
||||
;================================================================================
|
||||
; Draw rupee counter
|
||||
!RUPEE_DRAW_ADDRESS = "$7EC750"
|
||||
;================================================================================
|
||||
NewHUD_DrawBombs:
|
||||
LDA.l InfiniteBombs : BEQ .finite
|
||||
|
||||
LDA.l $7EF362 ; Drawing bombs (above) always ends with 16-bit A, so, no need to REP here
|
||||
JSR HudHexToDec4Digit
|
||||
LDX.b $04 : TXA : ORA.w #$2400 : STA !RUPEE_DRAW_ADDRESS ; 1000s
|
||||
LDX.b $05 : TXA : ORA.w #$2400 : STA !RUPEE_DRAW_ADDRESS+2 ; 100s
|
||||
LDX.b $06 : TXA : ORA.w #$2400 : STA !RUPEE_DRAW_ADDRESS+4 ; 10s
|
||||
LDX.b $07 : TXA : ORA.w #$2400 : STA !RUPEE_DRAW_ADDRESS+6 ; 1s
|
||||
.infinite
|
||||
LDY.w #!InfiniteTile+0
|
||||
LDX.w #!InfiniteTile+1
|
||||
BRA .draw
|
||||
|
||||
.finite
|
||||
LDA.w BombsEquipment
|
||||
JSR HUDHex2Digit
|
||||
|
||||
.draw
|
||||
STY.w HUDBombCount+0
|
||||
STX.w HUDBombCount+2
|
||||
|
||||
;================================================================================
|
||||
; Draw arrow count
|
||||
!ARROWCOUNT_DRAW_ADDRESS = "$7EC760"
|
||||
!INFINITE_ARROWS = "$7F50C8"
|
||||
;================================================================================
|
||||
NewHUD_DrawRupees:
|
||||
REP #$20
|
||||
|
||||
SEP #$20
|
||||
LDA.l ArrowMode : BNE +
|
||||
LDA !INFINITE_ARROWS : BNE .infinite_arrows
|
||||
.finite_arrows
|
||||
LDA.l $7EF377 ; arrows
|
||||
JSR HudHexToDec2Digit
|
||||
REP #$20
|
||||
LDX.b $06 : TXA : ORA.w #$2400 : STA !ARROWCOUNT_DRAW_ADDRESS ; Draw arrows 10 digit
|
||||
LDX.b $07 : TXA : ORA.w #$2400 : STA !ARROWCOUNT_DRAW_ADDRESS+2 ; Draw arrows 1 digit
|
||||
BRA +
|
||||
LDA.w DisplayRupees
|
||||
JSR HUDHex4Digit
|
||||
|
||||
.infinite_arrows
|
||||
REP #$20
|
||||
LDA.w #$2431 : STA !ARROWCOUNT_DRAW_ADDRESS ; infinity (left half)
|
||||
INC A : STA !ARROWCOUNT_DRAW_ADDRESS+2 ; infinity (right half)
|
||||
+
|
||||
;================================================================================
|
||||
; Draw Goal Item Indicator
|
||||
!GOAL_DRAW_ADDRESS = "$7EC72A"
|
||||
;================================================================================
|
||||
REP #$20
|
||||
LDA.l GoalItemRequirement : BNE + : JMP .done : + ; Star Meter
|
||||
LDA.b Scrap04 : TAX : STX.w HUDRupees+0 ; 1000s
|
||||
LDA.b Scrap05 : TAX : STX.w HUDRupees+2 ; 100s
|
||||
LDA.b Scrap06 : TAX : STX.w HUDRupees+4 ; 10s
|
||||
LDA.b Scrap07 : TAX : STX.w HUDRupees+6 ; 1s
|
||||
|
||||
;================================================================================
|
||||
NewHUD_DrawArrows:
|
||||
SEP #$20
|
||||
|
||||
LDA.l ArrowMode : BNE NewHUD_DrawGoal
|
||||
LDA.l InfiniteArrows : BEQ .finite
|
||||
|
||||
.infinite
|
||||
LDY.w #!InfiniteTile+0
|
||||
LDX.w #!InfiniteTile+1
|
||||
BRA .draw
|
||||
|
||||
.finite
|
||||
LDA.w CurrentArrows
|
||||
JSR HUDHex2Digit
|
||||
|
||||
.draw
|
||||
STY.w HUDArrowCount+0
|
||||
STX.w HUDArrowCount+2
|
||||
|
||||
;================================================================================
|
||||
NewHUD_DrawGoal:
|
||||
REP #$20
|
||||
LDA.w UpdateHUDFlag : BEQ .no_goal
|
||||
LDA.l GoalItemRequirement : BEQ .no_goal
|
||||
|
||||
LDA.l GoalItemIcon : STA.w HUDGoalIndicator
|
||||
LDA.w #!SlashTile : STA.w HUDGoalIndicator+8
|
||||
LDA.l GoalCounter
|
||||
JSR HudHexToDec4Digit
|
||||
JSR HUDHex4Digit
|
||||
|
||||
LDA.l GoalItemIcon : STA !GOAL_DRAW_ADDRESS ; draw star icon
|
||||
|
||||
LDX.b $05 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+2 ; draw 100's digit
|
||||
LDX.b $06 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+4 ; draw 10's digit
|
||||
LDX.b $07 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+6 ; draw 1's digit
|
||||
LDA.b Scrap05 : TAX : STX.w HUDGoalIndicator+2 ; draw 100's digit
|
||||
LDA.b Scrap06 : TAX : STX.w HUDGoalIndicator+4 ; draw 10's digit
|
||||
LDA.b Scrap07 : TAX : STX.w HUDGoalIndicator+6 ; draw 1's digit
|
||||
|
||||
LDA.l GoalItemRequirement : CMP.w #$FFFF : BEQ .skip
|
||||
LDA.l GoalItemRequirement
|
||||
JSR HudHexToDec4Digit
|
||||
LDA.w #$2830 : STA !GOAL_DRAW_ADDRESS+8 ; draw slash
|
||||
LDX.b $05 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+10 ; draw 100's digit
|
||||
LDX.b $06 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+12 ; draw 10's digit
|
||||
LDX.b $07 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+14 ; draw 1's digit
|
||||
BRA .done
|
||||
.skip
|
||||
LDA.w #$207F ; transparent tile
|
||||
STA !GOAL_DRAW_ADDRESS+8
|
||||
STA !GOAL_DRAW_ADDRESS+10
|
||||
STA !GOAL_DRAW_ADDRESS+12
|
||||
.done
|
||||
REP #$20
|
||||
LDX.w #!BlankTile
|
||||
LDA.w GoalCounter
|
||||
CMP.w #100 : BCS .req : STX.w HUDGoalIndicator+$02
|
||||
CMP.w #10 : BCS .req : STX.w HUDGoalIndicator+$04
|
||||
|
||||
.req
|
||||
LDA.l GoalItemRequirement : CMP.w #$FFFF : BNE .real_goal
|
||||
|
||||
STX.w HUDGoalIndicator+10
|
||||
STX.w HUDGoalIndicator+12
|
||||
STX.w HUDGoalIndicator+14
|
||||
|
||||
.no_goal
|
||||
SEP #$20
|
||||
BRA NewHUD_DrawKeys
|
||||
|
||||
.real_goal
|
||||
JSR HUDHex4Digit
|
||||
|
||||
LDA.b Scrap05 : TAX : STX.w HUDGoalIndicator+10 ; draw 100's digit
|
||||
LDA.b Scrap06 : TAX : STX.w HUDGoalIndicator+12 ; draw 10's digit
|
||||
LDA.b Scrap07 : TAX : STX.w HUDGoalIndicator+14 ; draw 1's digit
|
||||
|
||||
;================================================================================
|
||||
; Draw Dungeon Compass Counts
|
||||
NewHUD_DrawKeys:
|
||||
LDA.w CurrentSmallKeys
|
||||
CMP.b #$FF
|
||||
BNE .in_dungeon
|
||||
|
||||
LDY.w #!BlankTile
|
||||
STY.w HUDKeyIcon
|
||||
STY.w HUDKeyDigits+0
|
||||
STY.w HUDKeyDigits+2
|
||||
BRA NewHUD_DrawDungeonCounters
|
||||
|
||||
.in_dungeon
|
||||
JSR HUDHex2Digit
|
||||
CPY.w #$2490
|
||||
BNE .real_10s
|
||||
|
||||
LDY.w #!BlankTile
|
||||
|
||||
.real_10s
|
||||
STY.w HUDKeyDigits+0
|
||||
STX.w HUDKeyDigits+2
|
||||
|
||||
;================================================================================
|
||||
LDA.l CompassMode : AND #$000F : BEQ + ; skip if CompassMode is 0.
|
||||
JSL.l DrawDungeonCompassCounts ; compasses.asm
|
||||
NewHUD_DrawDungeonCounters:
|
||||
LDA.w UpdateHUDFlag : BEQ NewHUD_DrawPrizeIcon
|
||||
LDA.l CompassMode : ORA.l MapHUDMode : BIT.b #$03 : BEQ NewHUD_DrawPrizeIcon
|
||||
LDX.b IndoorsFlag : BNE +
|
||||
JMP.w NewHUD_DrawMagicMeter
|
||||
+
|
||||
SEP #$30
|
||||
; extra hard safeties for getting dungeon ID to prevent crashes
|
||||
LDA.w DungeonID
|
||||
CMP.b #$1B : BCS NewHUD_DrawPrizeIcon ; Skip if not in a valid dungeon ID
|
||||
AND.b #$FE : TAX
|
||||
LSR : TAY
|
||||
PHX : PHY
|
||||
|
||||
JSR DrawCompassCounts
|
||||
SEP #$10
|
||||
PLY : PLX
|
||||
JSR DrawMapCounts
|
||||
|
||||
;================================================================================
|
||||
NewHUD_DrawPrizeIcon:
|
||||
REP #$10
|
||||
SEP #$20
|
||||
LDA.b GameMode
|
||||
CMP.b #$12 : BEQ .no_prize
|
||||
CMP.b #$0E : BEQ +
|
||||
LDA.w UpdateHUDFlag : BEQ NewHUD_DrawItemCounter
|
||||
+
|
||||
LDA.w DungeonID
|
||||
CMP.b #$1A : BCS .no_prize
|
||||
CMP.b #$04 : BCC .no_prize
|
||||
CMP.b #$08 : BNE .dungeon
|
||||
|
||||
;================================================================================
|
||||
; Draw key count
|
||||
!KEY_DIGITS_ADDRESS = "$7EC764"
|
||||
!KEY_ICON_ADDRESS = "$7EC726"
|
||||
;================================================================================
|
||||
SEP #$20
|
||||
LDA.l CurrentSmallKeys : CMP.b #$FF : BEQ .not_in_dungeon
|
||||
.in_dungeon
|
||||
JSR HudHexToDec2Digit : REP #$20
|
||||
|
||||
; if 10s digit is 0, draw transparent tile instead of 0
|
||||
LDX.b $06 : TXA : CPX.b #$90 : BNE +
|
||||
LDA.w #$007F
|
||||
+
|
||||
ORA.w #$2400 : STA !KEY_DIGITS_ADDRESS
|
||||
|
||||
; 1s digit
|
||||
LDX.b $07 : TXA : ORA.w #$2400 : STA !KEY_DIGITS_ADDRESS+2
|
||||
BRA .done_keys
|
||||
|
||||
.not_in_dungeon
|
||||
REP #$20
|
||||
|
||||
;in the overworld, draw transparent tiles instead of key count
|
||||
LDA.w #$247F : STA !KEY_DIGITS_ADDRESS : STA !KEY_DIGITS_ADDRESS+2
|
||||
STA !KEY_ICON_ADDRESS
|
||||
|
||||
.done_keys
|
||||
|
||||
;--------------------------------------------------------------------------------
|
||||
; Draw pendant/crystal icon
|
||||
;--------------------------------------------------------------------------------
|
||||
!PRIZE_ICON = $7EC742
|
||||
!P_ICON = $296C
|
||||
!C_ICON = $295F
|
||||
|
||||
SEP #$20
|
||||
LDA.b $1B : BEQ .noprize
|
||||
|
||||
LDX.w $040C
|
||||
CPX #$1A : !BGE .noprize
|
||||
CPX #$04 : !BLT .noprize
|
||||
CPX #$08 : BEQ .noprize
|
||||
|
||||
LDA $10 : CMP #$12 : BEQ .noprize
|
||||
.no_prize
|
||||
LDY.w #!BlankTile
|
||||
BRA .draw_prize
|
||||
|
||||
.dungeon
|
||||
SEP #$30
|
||||
TAX
|
||||
LSR
|
||||
TAY
|
||||
LDA.l MapMode
|
||||
REP #$20
|
||||
BEQ .drawprize
|
||||
|
||||
LDA.l MapField
|
||||
REP #$30
|
||||
BEQ .prize
|
||||
|
||||
LDA.w MapField
|
||||
AND.l DungeonItemMasks,X
|
||||
BEQ .noprize
|
||||
BEQ .no_prize
|
||||
|
||||
.drawprize
|
||||
TXA : LSR : TAX
|
||||
LDA.l CrystalPendantFlags_2, X
|
||||
AND.w #$0040 : BNE .is_crystal
|
||||
.prize
|
||||
TYX
|
||||
LDA.l CrystalPendantFlags_2,X
|
||||
BIT.w #$0080
|
||||
BNE .no_icon
|
||||
|
||||
LDA.w #!P_ICON
|
||||
BRA .doneprize
|
||||
BIT.w #$0040
|
||||
BNE .crystal
|
||||
|
||||
.is_crystal
|
||||
LDA.w #!C_ICON
|
||||
BRA .doneprize
|
||||
LDY.w #!PTile
|
||||
BRA .draw_prize
|
||||
|
||||
.noprize
|
||||
REP #$20
|
||||
LDA.w #$207F
|
||||
.crystal
|
||||
LDY.w #!CTile
|
||||
BRA .draw_prize
|
||||
|
||||
.doneprize
|
||||
STA.l !PRIZE_ICON
|
||||
.no_icon
|
||||
LDY.w #!BlankTile
|
||||
|
||||
;--------------------------------------------------------------------------------
|
||||
; Draw Magic Meter
|
||||
!INFINITE_MAGIC = "$7F50CA"
|
||||
!DrawMagicMeter_mp_tilemap = "$0DFE0F"
|
||||
;--------------------------------------------------------------------------------
|
||||
LDA CurrentMagic : AND #$00FF ; crap we wrote over when placing the hook for OnDrawHud
|
||||
!ADD #$0007
|
||||
AND #$FFF8
|
||||
TAX ; end of crap
|
||||
|
||||
LDA !INFINITE_MAGIC : AND.w #$00FF : BNE + : JMP .green : +
|
||||
SEP #$20 : LDA.b #$80 : STA CurrentMagic : REP #$30 ; set magic to max
|
||||
LDX.w #$0080 ; load full magic meter graphics
|
||||
LDA $1A : AND.w #$000C : LSR #2
|
||||
BEQ .red
|
||||
CMP.w #0001 : BEQ .yellow
|
||||
CMP.w #0002 : BNE + : JMP .green : +
|
||||
.blue
|
||||
LDA !DrawMagicMeter_mp_tilemap+0, X : AND.w #$EFFF : STA $7EC746
|
||||
LDA !DrawMagicMeter_mp_tilemap+2, X : AND.w #$EFFF : STA $7EC786
|
||||
LDA !DrawMagicMeter_mp_tilemap+4, X : AND.w #$EFFF : STA $7EC7C6
|
||||
LDA !DrawMagicMeter_mp_tilemap+6, X : AND.w #$EFFF : STA $7EC806
|
||||
RTL
|
||||
.red
|
||||
LDA !DrawMagicMeter_mp_tilemap+0, X : AND.w #$E7FF : STA $7EC746
|
||||
LDA !DrawMagicMeter_mp_tilemap+2, X : AND.w #$E7FF : STA $7EC786
|
||||
LDA !DrawMagicMeter_mp_tilemap+4, X : AND.w #$E7FF : STA $7EC7C6
|
||||
LDA !DrawMagicMeter_mp_tilemap+6, X : AND.w #$E7FF : STA $7EC806
|
||||
RTL
|
||||
.yellow
|
||||
LDA !DrawMagicMeter_mp_tilemap+0, X : AND.w #$EBFF : STA $7EC746
|
||||
LDA !DrawMagicMeter_mp_tilemap+2, X : AND.w #$EBFF : STA $7EC786
|
||||
LDA !DrawMagicMeter_mp_tilemap+4, X : AND.w #$EBFF : STA $7EC7C6
|
||||
LDA !DrawMagicMeter_mp_tilemap+6, X : AND.w #$EBFF : STA $7EC806
|
||||
RTL
|
||||
.orange
|
||||
LDA !DrawMagicMeter_mp_tilemap+0, X : AND.w #$E3FF : STA $7EC746
|
||||
LDA !DrawMagicMeter_mp_tilemap+2, X : AND.w #$E3FF : STA $7EC786
|
||||
LDA !DrawMagicMeter_mp_tilemap+4, X : AND.w #$E3FF : STA $7EC7C6
|
||||
LDA !DrawMagicMeter_mp_tilemap+6, X : AND.w #$E3FF : STA $7EC806
|
||||
RTL
|
||||
.green
|
||||
LDA !DrawMagicMeter_mp_tilemap+0, X : STA $7EC746
|
||||
LDA !DrawMagicMeter_mp_tilemap+2, X : STA $7EC786
|
||||
LDA !DrawMagicMeter_mp_tilemap+4, X : STA $7EC7C6
|
||||
LDA !DrawMagicMeter_mp_tilemap+6, X : STA $7EC806
|
||||
.draw_prize
|
||||
STY.w HUDPrizeIcon
|
||||
|
||||
;================================================================================
|
||||
NewHUD_DrawItemCounter:
|
||||
REP #$20
|
||||
LDA.w UpdateHUDFlag : BNE .continue
|
||||
.early_exit
|
||||
JMP NewHUD_DrawMagicMeter
|
||||
.continue
|
||||
LDA.l ItemCounterHUD : AND.w #$00FF : BEQ .early_exit
|
||||
LDA.w #!SlashTile : STA.w HUDGoalIndicator+$08
|
||||
LDA.l TotalItemCount : CMP.w #1000 : BCS .item_four_digits
|
||||
LDA.w TotalItemCountTiles+$02 : STA.w HUDGoalIndicator+$0A
|
||||
LDA.w TotalItemCountTiles+$04 : STA.w HUDGoalIndicator+$0C
|
||||
LDA.w TotalItemCountTiles+$06 : STA.w HUDGoalIndicator+$0E
|
||||
|
||||
LDA.w TotalItemCounter
|
||||
JSR HUDHex4Digit
|
||||
LDA.b Scrap05 : TAX : STX.w HUDGoalIndicator+$02
|
||||
LDA.b Scrap06 : TAX : STX.w HUDGoalIndicator+$04
|
||||
LDA.b Scrap07 : TAX : STX.w HUDGoalIndicator+$06
|
||||
REP #$20 : LDA.w TotalItemCounter
|
||||
LDX.w #!BlankTile
|
||||
CMP.w #100 : BCS NewHUD_DrawMagicMeter : STX.w HUDGoalIndicator+$02
|
||||
CMP.w #10 : BCS NewHUD_DrawMagicMeter : STX.w HUDGoalIndicator+$04
|
||||
BRA NewHUD_DrawMagicMeter
|
||||
|
||||
.item_four_digits
|
||||
LDA.w TotalItemCountTiles+$00 : STA.w HUDGoalIndicator+$0A
|
||||
LDA.w TotalItemCountTiles+$02 : STA.w HUDGoalIndicator+$0C
|
||||
LDA.w TotalItemCountTiles+$04 : STA.w HUDGoalIndicator+$0E
|
||||
LDA.w TotalItemCountTiles+$06 : STA.w HUDGoalIndicator+$10
|
||||
|
||||
LDA.w TotalItemCounter
|
||||
JSR HUDHex4Digit
|
||||
LDA.b Scrap04 : TAX : STX.w HUDGoalIndicator+$00
|
||||
LDA.b Scrap05 : TAX : STX.w HUDGoalIndicator+$02
|
||||
LDA.b Scrap06 : TAX : STX.w HUDGoalIndicator+$04
|
||||
LDA.b Scrap07 : TAX : STX.w HUDGoalIndicator+$06
|
||||
REP #$20 : LDA.w TotalItemCounter
|
||||
LDX.w #!BlankTile
|
||||
CMP.w #1000 : BCS NewHUD_DrawMagicMeter : STX.w HUDGoalIndicator+$00
|
||||
CMP.w #100 : BCS NewHUD_DrawMagicMeter : STX.w HUDGoalIndicator+$02
|
||||
CMP.w #10 : BCS NewHUD_DrawMagicMeter : STX.w HUDGoalIndicator+$04
|
||||
|
||||
;================================================================================
|
||||
DrawMagicMeter_mp_tilemap = $0DFE0F
|
||||
NewHUD_DrawMagicMeter:
|
||||
SEP #$31
|
||||
LDA.l CurrentMagic
|
||||
ADC.b #$06 ; carry set by above for +1 to get +7
|
||||
AND.b #$F8
|
||||
TAY
|
||||
|
||||
LDA.l InfiniteMagic
|
||||
BEQ .set_index
|
||||
|
||||
.infinite_magic
|
||||
LDA.b #$80
|
||||
STA.w CurrentMagic
|
||||
TAY
|
||||
|
||||
LDA.b FrameCounter
|
||||
REP #$30
|
||||
AND.w #$000C
|
||||
LSR
|
||||
BRA .recolor
|
||||
|
||||
.set_index ; this branch is always 0000 when taken
|
||||
REP #$30
|
||||
TDC
|
||||
.recolor
|
||||
TAX
|
||||
LDA.l MagicMeterColorMasks,X
|
||||
|
||||
TYX
|
||||
TAY : AND.l DrawMagicMeter_mp_tilemap+0,X : STA.w HUDTileMapBuffer+$046
|
||||
TYA : AND.l DrawMagicMeter_mp_tilemap+2,X : STA.w HUDTileMapBuffer+$086
|
||||
TYA : AND.l DrawMagicMeter_mp_tilemap+4,X : STA.w HUDTileMapBuffer+$0C6
|
||||
TYA : AND.l DrawMagicMeter_mp_tilemap+6,X : STA.w HUDTileMapBuffer+$106
|
||||
|
||||
;================================================================================
|
||||
NewHUD_DoneDrawing:
|
||||
STZ.w UpdateHUDFlag
|
||||
PLB
|
||||
RTL
|
||||
|
||||
;================================================================================
|
||||
; 16-bit A, 8-bit X
|
||||
; in: A(b) - Byte to Convert
|
||||
; out: $04 - $07 (high - low)
|
||||
;================================================================================
|
||||
HudHexToDec4Digit:
|
||||
LDY.b #$90
|
||||
-
|
||||
CMP.w #1000 : !BLT +
|
||||
INY
|
||||
SBC.w #1000 : BRA -
|
||||
+
|
||||
STY $04 : LDY #$90 ; Store 1000s digit & reset Y
|
||||
-
|
||||
CMP.w #100 : !BLT +
|
||||
INY
|
||||
SBC.w #100 : BRA -
|
||||
+
|
||||
STY $05 : LDY #$90 ; Store 100s digit & reset Y
|
||||
-
|
||||
CMP.w #10 : !BLT +
|
||||
INY
|
||||
SBC.w #10 : BRA -
|
||||
+
|
||||
STY $06 : LDY #$90 ; Store 10s digit & reset Y
|
||||
CMP.w #1 : !BLT +
|
||||
-
|
||||
INY
|
||||
DEC : BNE -
|
||||
+
|
||||
STY $07 ; Store 1s digit
|
||||
RTS
|
||||
MagicMeterColorMasks:
|
||||
dw $FFFF ; green - KEEP GREEN FIRST
|
||||
dw $EFFF ; blue
|
||||
dw $E7FF ; red
|
||||
dw $EBFF ; yellow
|
||||
dw $E3FF ; orange
|
||||
|
||||
;================================================================================
|
||||
; 8-bit registers
|
||||
; in: A(b) - Byte to Convert
|
||||
; out: $05 - $07 (high - low)
|
||||
DrawCompassCounts:
|
||||
LDA.l CompassMode : AND.b #$0F : BNE .continue
|
||||
.early_exit
|
||||
JMP .done
|
||||
.continue
|
||||
|
||||
; no compass needed if this bit is set
|
||||
BIT.b #$02 : BNE .draw_compass_count
|
||||
TYX : LDA.l ExistsTransfer, X : TAX : LDA.l CompassExists, X : BEQ .draw_compass_count
|
||||
REP #$20
|
||||
LDX.w DungeonID : LDA.w CompassField : AND.l DungeonItemMasks,X : BEQ .early_exit
|
||||
|
||||
.draw_compass_count
|
||||
LDX.w DungeonID
|
||||
CPX.b #$00 : BNE .not_sewers
|
||||
INX #2
|
||||
|
||||
.not_sewers
|
||||
REP #$20
|
||||
LDA.w DungeonLocationsChecked, X
|
||||
PHA
|
||||
|
||||
LDA.w #!SlashTile : STA.w HUDTileMapBuffer+$98 ; always slash
|
||||
LDA.l CompassTotalsWRAM,X
|
||||
CMP.w #100 : BCS .three_digits
|
||||
CMP.w #10 : BCS .two_digits
|
||||
|
||||
LDA.l CompassTotalsOneDigit, X : STA.w HUDTileMapBuffer+$9A
|
||||
PLA
|
||||
JSR HUDHex2Digit
|
||||
STX.w HUDTileMapBuffer+$96
|
||||
BRA .done
|
||||
|
||||
.two_digits
|
||||
LDA.l CompassTotalsTensDigit, X : STA.w HUDTileMapBuffer+$9A
|
||||
LDA.l CompassTotalsOneDigit, X : STA.w HUDTileMapBuffer+$9C
|
||||
PLA
|
||||
JSR HUDHex2Digit
|
||||
CPY.w #$2490 : BEQ +
|
||||
STY.w HUDTileMapBuffer+$94
|
||||
+ STX.w HUDTileMapBuffer+$96
|
||||
BRA .done
|
||||
|
||||
.three_digits
|
||||
LDA.l CompassTotalsHundredsDigit, X : STA.w HUDTileMapBuffer+$9A
|
||||
LDA.l CompassTotalsTensDigit, X : STA.w HUDTileMapBuffer+$9C
|
||||
LDA.l CompassTotalsOneDigit, X : STA.w HUDTileMapBuffer+$9E
|
||||
PLA : PHA
|
||||
JSR HUDHex4Digit
|
||||
LDA.b Scrap05 : TAX : STX.w HUDTileMapBuffer+$92
|
||||
LDA.b Scrap06 : TAX : STX.w HUDTileMapBuffer+$94
|
||||
LDA.b Scrap07 : TAX : STX.w HUDTileMapBuffer+$96
|
||||
REP #$20 : PLA
|
||||
LDX.w #!BlankTile
|
||||
CMP.w #100 : BCS .done
|
||||
STX.w HUDTileMapBuffer+$92
|
||||
CMP.w #10 : BCS .done
|
||||
STX.w HUDTileMapBuffer+$94
|
||||
|
||||
.done
|
||||
SEP #$20
|
||||
RTS
|
||||
;================================================================================
|
||||
;HudHexToDec3Digit: ; this may be overkill, could have used the 4 digit one...
|
||||
; LDY.b #$90
|
||||
; -
|
||||
; CMP.b #100 : !BLT +
|
||||
; INY
|
||||
; SBC.b #100 : BRA -
|
||||
; +
|
||||
; STY $05 : LDY.b #$90 ; Store 100s digit and reset Y
|
||||
; -
|
||||
; CMP.b #10 : !BLT +
|
||||
; INY
|
||||
; SBC.b #10 : BRA -
|
||||
; +
|
||||
; STY $06 : LDY #$90 ; Store 10s digit and reset Y
|
||||
; CMP.b #1 : !BLT +
|
||||
; -
|
||||
; INY
|
||||
; DEC : BNE -
|
||||
; +
|
||||
; STY $07 ; Store 1s digit
|
||||
;RTS
|
||||
DrawMapCounts:
|
||||
LDA.l MapHUDMode : BEQ .done
|
||||
|
||||
; no map needed if this bit is set
|
||||
BIT.b #$02 : BNE .draw_map_count
|
||||
REP #$20
|
||||
LDA.w MapField : AND.l DungeonItemMasks,X : BEQ .done
|
||||
|
||||
.draw_map_count
|
||||
SEP #$20
|
||||
TYX : BNE .not_sewers
|
||||
INX
|
||||
|
||||
.not_sewers
|
||||
LDA.w DungeonCollectedKeys, X
|
||||
PHA
|
||||
|
||||
LDA.l MapTotalsWRAM,X
|
||||
|
||||
JSR HUDHex2Digit
|
||||
STX.w HUDTileMapBuffer+$A6
|
||||
|
||||
LDX.w #!SlashTile : STX.w HUDTileMapBuffer+$A4
|
||||
|
||||
PLA
|
||||
JSR HUDHex2Digit
|
||||
STX.w HUDTileMapBuffer+$A2
|
||||
|
||||
.done
|
||||
SEP #$20
|
||||
RTS
|
||||
|
||||
; maps from $040C to the odd order used in overworld map
|
||||
ExistsTransfer:
|
||||
db $0C, $0C, $00, $02, $0B, $09, $03, $07, $04, $08, $01, $06, $05, $0A
|
||||
|
||||
;================================================================================
|
||||
; 8-bit registers
|
||||
; in: A(b) - Byte to Convert
|
||||
; out: $06 - $07 (high - low)
|
||||
; Exits with:
|
||||
; X - ones place tile
|
||||
; Y - tens place tile
|
||||
;===================================================================================================
|
||||
HUDHex2Digit:
|
||||
SEP #$30 ; clear high byte of X and Y and make it so they don't get B
|
||||
ASL : TAX
|
||||
|
||||
REP #$10
|
||||
|
||||
LDA.b #$24 : XBA ; tile props in high byte
|
||||
|
||||
LDA.l FastHexTable,X : LSR #4 : ORA.b #$90
|
||||
TAY
|
||||
|
||||
LDA.l FastHexTable,X : AND.b #$0F : ORA.b #$90
|
||||
TAX
|
||||
|
||||
RTS
|
||||
|
||||
HUDHex4Digit:
|
||||
JSL HexToDec
|
||||
|
||||
REP #$30
|
||||
|
||||
LDA.l HexToDecDigit2 : ORA.w #$9090 : STA.b Scrap04
|
||||
LDA.l HexToDecDigit4 : ORA.w #$9090 : STA.b Scrap06
|
||||
|
||||
LDA.w #$2400
|
||||
|
||||
SEP #$20
|
||||
RTS
|
||||
|
||||
HUDHex2Digit_Long:
|
||||
JSR HUDHex2Digit
|
||||
REP #$20
|
||||
RTL
|
||||
|
||||
HUDHex4Digit_Long:
|
||||
JSR HUDHex4Digit
|
||||
REP #$20
|
||||
RTL
|
||||
|
||||
;================================================================================
|
||||
HudHexToDec2Digit:
|
||||
LDY.b #$90
|
||||
-
|
||||
CMP.b #10 : !BLT +
|
||||
INY
|
||||
SBC.b #10 : BRA -
|
||||
+
|
||||
STY $06 : LDY #$90 ; Store 10s digit and reset Y
|
||||
CMP.b #1 : !BLT +
|
||||
-
|
||||
INY
|
||||
DEC : BNE -
|
||||
+
|
||||
STY $07 ; Store 1s digit
|
||||
UpdateHearts:
|
||||
PHB
|
||||
REP #$20
|
||||
SEP #$10
|
||||
|
||||
LDX.b #$7E
|
||||
PHX
|
||||
PLB
|
||||
|
||||
LDA.w MaximumHealth
|
||||
LSR
|
||||
LSR
|
||||
LSR
|
||||
AND.w #$1F1F
|
||||
|
||||
|
||||
TAX
|
||||
XBA
|
||||
TAY
|
||||
|
||||
LDA.w #HUDTileMapBuffer+$068
|
||||
STA.b Scrap07
|
||||
STA.b Scrap09
|
||||
|
||||
.next_filled_heart
|
||||
CPX.b #$01
|
||||
BMI .done_hearts
|
||||
|
||||
PHX
|
||||
LDA.l HUDHeartColors_index : ASL : TAX
|
||||
LDA.l HUDHeartColors_masks_game_hud,X
|
||||
PLX
|
||||
ORA.w #$20A0
|
||||
|
||||
CPY.b #$01
|
||||
BPL .add_heart
|
||||
|
||||
INC
|
||||
INC
|
||||
|
||||
.add_heart
|
||||
STA.b ($07)
|
||||
|
||||
DEY
|
||||
DEX
|
||||
|
||||
LDA.b Scrap07
|
||||
INC
|
||||
INC
|
||||
CMP.w #HUDTileMapBuffer+$07C
|
||||
BEQ .next_row
|
||||
|
||||
CMP.w #HUDTileMapBuffer+$0BC
|
||||
BNE .fine
|
||||
|
||||
.next_row
|
||||
ADC.w #$002B
|
||||
|
||||
.fine
|
||||
STA.b Scrap07
|
||||
|
||||
CPY.b #$00
|
||||
BNE .next_filled_heart
|
||||
|
||||
STA.b Scrap09
|
||||
BRA .next_filled_heart
|
||||
|
||||
.done_hearts
|
||||
LDA.w CurrentHealth
|
||||
AND.w #$0007
|
||||
BEQ .skip_partial
|
||||
CMP.w #$0005
|
||||
BCS .more_than_half
|
||||
|
||||
LDA.l HUDHeartColors_index : ASL : TAX
|
||||
LDA.l HUDHeartColors_masks_game_hud,X
|
||||
ORA.w #$20A1
|
||||
STA.b ($09)
|
||||
BRA .skip_partial
|
||||
|
||||
.more_than_half
|
||||
LDA.l HUDHeartColors_index : ASL : TAX
|
||||
LDA.l HUDHeartColors_masks_game_hud,X
|
||||
ORA.w #$20A0
|
||||
STA.b ($09)
|
||||
|
||||
.skip_partial
|
||||
SEP #$30
|
||||
|
||||
PLB
|
||||
RTL
|
||||
|
||||
CheckHeartPaletteFileSelect:
|
||||
LDA.l HUDHeartColors_index : ASL : TAX
|
||||
LDA.l HUDHeartColors_masks_file_select,X
|
||||
ORA.w #$0200
|
||||
LDX.w #$000A
|
||||
RTL
|
||||
|
||||
CheckHeartPalette:
|
||||
PHX
|
||||
LDA.l HUDHeartColors_index : ASL : TAX
|
||||
LDA.l HUDHeartColors_masks_game_hud,X
|
||||
ORA.w #$20A0
|
||||
PLX
|
||||
RTS
|
||||
|
||||
ColorAnimatedHearts:
|
||||
PHX
|
||||
REP #$20
|
||||
LDA.l HUDHeartColors_index : ASL : TAX
|
||||
LDA.l HUDHeartColors_masks_game_hud,X
|
||||
PLX
|
||||
ORA.l HeartFramesBaseTiles,X
|
||||
STA.b [Scrap00],Y
|
||||
SEP #$20
|
||||
RTL
|
||||
|
||||
HeartFramesBaseTiles:
|
||||
dw $20A3, $20A4, $20A3, $20A0
|
||||
|
||||
Reference in New Issue
Block a user