ram.asm initial commit. Replaced all address defines with labels

Value defines styled without quotes, # moved to load/store/cmp site
Added registers.asm (copied from spannerisms JP disassembly)
Added a bunch of length annotations
Deleted old or trivial commented out code
Deleted: ganonfixes.asm, map.asm, seedtag.asm
Replaced obsolete credits.asm with creditsnew.asm
Moved scratch space at $7F5020-3F to mirrored WRAM (7E1E70-8F)
Moved clock RAM to mirrored WRAM (7E1E90-9F)
dialog.asm: FreeDungeonItemNotice preserves callee-preserved scratch RAM
Toast buffer moved to mirrored WRAM (7E1E0E-0F)
servicerequest.asm: long store to $012E converted to word length store
This commit is contained in:
cassidoxa
2022-11-05 00:50:25 -04:00
parent cafb0908a0
commit 43f753b517
72 changed files with 7706 additions and 7305 deletions

View File

@@ -1,8 +1,7 @@
NewDrawHud:
SEP #$30
SEP #$30
;================================================================================
; Draw bomb count
!BOMBCOUNT_DRAW_ADDRESS = "$7EC75A"
;================================================================================
LDA.l InfiniteBombs : BNE .infinite_bombs
@@ -10,54 +9,50 @@ SEP #$30
LDA.l BombsEquipment ; 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
LDX.b Scrap06 : TXA : ORA.w #$2400 : STA.l HUDBombCount ; Draw bombs 10 digit
LDX.b Scrap07 : TXA : ORA.w #$2400 : STA.l HUDBombCount+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.w #$2431 : STA.l HUDBombCount ; infinity (left half)
INC A : STA.l HUDBombCount+2 ; infinity (right half)
+
;================================================================================
; Draw rupee counter
!RUPEE_DRAW_ADDRESS = "$7EC750"
;================================================================================
LDA.l DisplayRupees ; 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
LDX.b Scrap04 : TXA : ORA.w #$2400 : STA.l HUDRupees ; 1000s
LDX.b Scrap05 : TXA : ORA.w #$2400 : STA.l HUDRupees+2 ; 100s
LDX.b Scrap06 : TXA : ORA.w #$2400 : STA.l HUDRupees+4 ; 10s
LDX.b Scrap07 : TXA : ORA.w #$2400 : STA.l HUDRupees+6 ; 1s
;================================================================================
; Draw arrow count
!ARROWCOUNT_DRAW_ADDRESS = "$7EC760"
!INFINITE_ARROWS = "$7F50C8"
;================================================================================
SEP #$20
LDA.l ArrowMode : BNE +
LDA !INFINITE_ARROWS : BNE .infinite_arrows
LDA.l InfiniteArrows : BNE .infinite_arrows
.finite_arrows
LDA.l CurrentArrows ; 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
LDX.b Scrap06 : TXA : ORA.w #$2400 : STA.l HUDArrowCount ; Draw arrows 10 digit
LDX.b Scrap07 : TXA : ORA.w #$2400 : STA.l HUDArrowCount+2 ; Draw arrows 1 digit
BRA +
.infinite_arrows
REP #$20
LDA.w #$2431 : STA !ARROWCOUNT_DRAW_ADDRESS ; infinity (left half)
INC A : STA !ARROWCOUNT_DRAW_ADDRESS+2 ; infinity (right half)
LDA.w #$2431 : STA.l HUDArrowCount ; infinity (left half)
INC A : STA.l HUDArrowCount+2 ; infinity (right half)
+
;================================================================================
; Draw Goal Item Indicator
!GOAL_DRAW_ADDRESS = "$7EC72A"
;================================================================================
REP #$20
@@ -66,25 +61,25 @@ SEP #$30
LDA.l GoalCounter
JSR HudHexToDec4Digit
LDA.l GoalItemIcon : STA.l !GOAL_DRAW_ADDRESS ; draw star icon
LDA.l GoalItemIcon : STA.l HUDGoalIndicator ; 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
LDX.b Scrap05 : TXA : ORA.w #$2400 : STA.l HUDGoalIndicator+2 ; draw 100's digit
LDX.b Scrap06 : TXA : ORA.w #$2400 : STA.l HUDGoalIndicator+4 ; draw 10's digit
LDX.b Scrap07 : TXA : ORA.w #$2400 : STA.l 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
LDA.w #$2830 : STA.l HUDGoalIndicator+8 ; draw slash
LDX.b Scrap05 : TXA : ORA.w #$2400 : STA.l HUDGoalIndicator+10 ; draw 100's digit
LDX.b Scrap06 : TXA : ORA.w #$2400 : STA.l HUDGoalIndicator+12 ; draw 10's digit
LDX.b Scrap07 : TXA : ORA.w #$2400 : STA.l HUDGoalIndicator+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
STA.l HUDGoalIndicator+8
STA.l HUDGoalIndicator+10
STA.l HUDGoalIndicator+12
.done
;================================================================================
@@ -96,8 +91,6 @@ SEP #$30
;================================================================================
; Draw key count
!KEY_DIGITS_ADDRESS = "$7EC764"
!KEY_ICON_ADDRESS = "$7EC726"
;================================================================================
SEP #$20
LDA.l CurrentSmallKeys : CMP.b #$FF : BEQ .not_in_dungeon
@@ -105,21 +98,21 @@ SEP #$30
JSR HudHexToDec2Digit : REP #$20
; if 10s digit is 0, draw transparent tile instead of 0
LDX.b $06 : TXA : CPX.b #$90 : BNE +
LDX.b Scrap06 : TXA : CPX.b #$90 : BNE +
LDA.w #$007F
+
ORA.w #$2400 : STA !KEY_DIGITS_ADDRESS
ORA.w #$2400 : STA.l HUDKeyDigits
; 1s digit
LDX.b $07 : TXA : ORA.w #$2400 : STA !KEY_DIGITS_ADDRESS+2
LDX.b Scrap07 : TXA : ORA.w #$2400 : STA.l HUDKeyDigits+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
LDA.w #$247F : STA.l HUDKeyDigits : STA.l HUDKeyDigits+2
STA.l HUDKeyIcon
.done_keys
@@ -129,7 +122,6 @@ SEP #$30
;--------------------------------------------------------------------------------
; Draw pendant/crystal icon
;--------------------------------------------------------------------------------
!PRIZE_ICON = $7EC742
!P_ICON = $296C
!C_ICON = $295F
@@ -141,7 +133,7 @@ SEP #$30
CPX #$04 : !BLT .noprize
CPX #$08 : BEQ .noprize
LDA $10 : CMP #$12 : BEQ .noprize
LDA.b $10 : CMP #$12 : BEQ .noprize
LDA.l MapMode
REP #$20
@@ -168,54 +160,53 @@ SEP #$30
LDA.w #$207F
.doneprize
STA.l !PRIZE_ICON
STA.l HUDPrizeIcon
;--------------------------------------------------------------------------------
; Draw Magic Meter
!INFINITE_MAGIC = "$7F50CA"
!DrawMagicMeter_mp_tilemap = "$0DFE0F"
DrawMagicMeter_mp_tilemap = $0DFE0F
;--------------------------------------------------------------------------------
LDA CurrentMagic : AND #$00FF ; crap we wrote over when placing the hook for OnDrawHud
LDA.l CurrentMagic : AND.w #$00FF ; crap we wrote over when placing the hook for OnDrawHud
!ADD #$0007
AND #$FFF8
AND.w #$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
LDA.l InfiniteMagic : AND.w #$00FF : BNE + : JMP .green : +
SEP #$20 : LDA.b #$80 : STA.l CurrentMagic : REP #$30 ; set magic to max
LDX.w #$0080 ; load full magic meter graphics
LDA $1A : AND.w #$000C : LSR #2
LDA.b $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
LDA.l DrawMagicMeter_mp_tilemap+0, X : AND.w #$EFFF : STA.l $7EC746
LDA.l DrawMagicMeter_mp_tilemap+2, X : AND.w #$EFFF : STA.l $7EC786
LDA.l DrawMagicMeter_mp_tilemap+4, X : AND.w #$EFFF : STA.l $7EC7C6
LDA.l DrawMagicMeter_mp_tilemap+6, X : AND.w #$EFFF : STA.l $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
LDA.l DrawMagicMeter_mp_tilemap+0, X : AND.w #$E7FF : STA.l $7EC746
LDA.l DrawMagicMeter_mp_tilemap+2, X : AND.w #$E7FF : STA.l $7EC786
LDA.l DrawMagicMeter_mp_tilemap+4, X : AND.w #$E7FF : STA.l $7EC7C6
LDA.l DrawMagicMeter_mp_tilemap+6, X : AND.w #$E7FF : STA.l $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
LDA.l DrawMagicMeter_mp_tilemap+0, X : AND.w #$EBFF : STA.l $7EC746
LDA.l DrawMagicMeter_mp_tilemap+2, X : AND.w #$EBFF : STA.l $7EC786
LDA.l DrawMagicMeter_mp_tilemap+4, X : AND.w #$EBFF : STA.l $7EC7C6
LDA.l DrawMagicMeter_mp_tilemap+6, X : AND.w #$EBFF : STA.l $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
LDA.l DrawMagicMeter_mp_tilemap+0, X : AND.w #$E3FF : STA.l $7EC746
LDA.l DrawMagicMeter_mp_tilemap+2, X : AND.w #$E3FF : STA.l $7EC786
LDA.l DrawMagicMeter_mp_tilemap+4, X : AND.w #$E3FF : STA.l $7EC7C6
LDA.l DrawMagicMeter_mp_tilemap+6, X : AND.w #$E3FF : STA.l $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
LDA.l DrawMagicMeter_mp_tilemap+0, X : STA.l $7EC746
LDA.l DrawMagicMeter_mp_tilemap+2, X : STA.l $7EC786
LDA.l DrawMagicMeter_mp_tilemap+4, X : STA.l $7EC7C6
LDA.l DrawMagicMeter_mp_tilemap+6, X : STA.l $7EC806
RTL
;================================================================================
@@ -230,25 +221,25 @@ HudHexToDec4Digit:
INY
SBC.w #1000 : BRA -
+
STY $04 : LDY #$90 ; Store 1000s digit & reset Y
STY.b Scrap04 : LDY.b #$90 ; Store 1000s digit & reset Y
-
CMP.w #100 : !BLT +
INY
SBC.w #100 : BRA -
+
STY $05 : LDY #$90 ; Store 100s digit & reset Y
STY.b Scrap05 : LDY.b #$90 ; Store 100s digit & reset Y
-
CMP.w #10 : !BLT +
INY
SBC.w #10 : BRA -
+
STY $06 : LDY #$90 ; Store 10s digit & reset Y
STY.b Scrap06 : LDY.b #$90 ; Store 10s digit & reset Y
CMP.w #1 : !BLT +
-
INY
DEC : BNE -
+
STY $07 ; Store 1s digit
STY.b Scrap07 ; Store 1s digit
RTS
;================================================================================
@@ -290,11 +281,11 @@ HudHexToDec2Digit:
INY
SBC.b #10 : BRA -
+
STY $06 : LDY #$90 ; Store 10s digit and reset Y
STY.b Scrap06 : LDY.b #$90 ; Store 10s digit and reset Y
CMP.b #1 : !BLT +
-
INY
DEC : BNE -
+
STY $07 ; Store 1s digit
STY.b Scrap07 ; Store 1s digit
RTS