Compass Refactor

This commit is contained in:
aerinon
2020-11-03 10:12:08 -07:00
parent 0dba58c194
commit 717913b8fb
4 changed files with 31 additions and 198 deletions

View File

@@ -1,15 +1,6 @@
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
; $7F5010 - Scratch Space ; $7F5010 - Scratch Space
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
; The number of items in a dungeon never changes. use this macro instead of
; HexToDec when drawing the "??/XX" item counter
; %DrawConstantNumber(1,4) draws 14
;--------------------------------------------------------------------------------
macro DrawConstantNumber(digit1,digit2)
LDA.w #$2490+<digit1> : STA $7EC79A
LDA.w #$2490+<digit2> : STA $7EC79C
endmacro
;--------------------------------------------------------------------------------
DrawDungeonCompassCounts: DrawDungeonCompassCounts:
LDX $1B : BNE + : RTL : + ; Skip if outdoors LDX $1B : BNE + : RTL : + ; Skip if outdoors
@@ -19,13 +10,23 @@ DrawDungeonCompassCounts:
LDA $7EF364 : AND.l .item_masks, X ; Load compass values to A, mask with dungeon item masks LDA $7EF364 : AND.l .item_masks, X ; Load compass values to A, mask with dungeon item masks
BNE + : RTL : + ; skip if we don't have compass BNE + : RTL : + ; skip if we don't have compass
++ ++
JMP (CompassCountDungeonHandlers, X) : .return_spot LDA $040C : LSR : TAX
; we switch to 8-bit A in the jump before this LDA.l CompassTotal, X : AND #$00FF
SEP #$20
JSR HudHexToDec2Digit JSR HudHexToDec2Digit
REP #$20 REP #$20
PHX
LDX.b $06 : TXA : ORA #$2400 : STA $7EC79A
LDX.b $07 : TXA : ORA #$2400 : STA $7EC79C
PLX
LDA $7EF4C0, X : AND #$00FF
SEP #$20
JSR HudHexToDec2Digit
REP #$20
LDX.b $06 : TXA : ORA #$2400 : STA $7EC794 ; Draw the item count LDX.b $06 : TXA : ORA #$2400 : STA $7EC794 ; Draw the item count
LDX.b $07 : TXA : ORA #$2400 : STA $7EC796 LDX.b $07 : TXA : ORA #$2400 : STA $7EC796
@@ -37,117 +38,7 @@ RTL
.item_masks ; these are dungeon correlations to $7EF364 - $7EF369 so it knows where to store compasses, etc .item_masks ; these are dungeon correlations to $7EF364 - $7EF369 so it knows where to store compasses, etc
dw $8000, $4000, $2000, $1000, $0800, $0400, $0200, $0100 dw $8000, $4000, $2000, $1000, $0800, $0400, $0200, $0100
dw $0080, $0040, $0020, $0010, $0008, $0004 dw $0080, $0040, $0020, $0010, $0008, $0004
CompassCountDungeonHandlers: ; pointers to functions that handle dungeon-specific code
dw CompassCount_Escape, CompassCount_Escape ; (hyrule castle, sewers)
dw CompassCount_Eastern, CompassCount_Desert, CompassCount_Agah
dw CompassCount_Swamp, CompassCount_PoD, CompassCount_Mire
dw CompassCount_Skull, CompassCount_Ice, CompassCount_Hera
dw CompassCount_Thieves, CompassCount_Trock, CompassCount_Gt
}
CompassCount_Escape:
print "compass_r_addr: ", pc
%DrawConstantNumber(0,8)
SEP #$20
LDA $7EF434 : LSR #4
JMP DrawDungeonCompassCounts_return_spot
CompassCount_Eastern:
%DrawConstantNumber(0,6)
SEP #$20
LDA $7EF436 : AND.b #$07
JMP DrawDungeonCompassCounts_return_spot
CompassCount_Desert:
%DrawConstantNumber(0,6)
SEP #$20
LDA $7EF435 : LSR #5
JMP DrawDungeonCompassCounts_return_spot
CompassCount_Agah:
%DrawConstantNumber(0,2)
SEP #$20
LDA $7EF435 : AND.b #$02
JMP DrawDungeonCompassCounts_return_spot
CompassCount_Swamp:
%DrawConstantNumber(1,0)
SEP #$20
LDA $7EF439 : AND.b #$0F
JMP DrawDungeonCompassCounts_return_spot
CompassCount_PoD:
%DrawConstantNumber(1,4)
SEP #$20
LDA $7EF434 : AND.b #$0F
JMP DrawDungeonCompassCounts_return_spot
CompassCount_Mire:
%DrawConstantNumber(0,8)
SEP #$20
LDA $7EF438 : AND.b #$0F
JMP DrawDungeonCompassCounts_return_spot
CompassCount_Skull:
%DrawConstantNumber(0,8)
SEP #$20
LDA $7EF437 : LSR #4
JMP DrawDungeonCompassCounts_return_spot
CompassCount_Ice:
%DrawConstantNumber(0,8)
SEP #$20
LDA $7EF438 : LSR #4
JMP DrawDungeonCompassCounts_return_spot
CompassCount_Hera:
%DrawConstantNumber(0,6)
SEP #$20
LDA $7EF435 : AND.b #$1C : LSR #2
JMP DrawDungeonCompassCounts_return_spot
CompassCount_Thieves:
%DrawConstantNumber(0,8)
SEP #$20
LDA $7EF437 : AND.b #$0F
JMP DrawDungeonCompassCounts_return_spot
CompassCount_Trock:
%DrawConstantNumber(1,2)
SEP #$20
LDA $7EF439 : LSR #4
JMP DrawDungeonCompassCounts_return_spot
CompassCount_Gt:
%DrawConstantNumber(2,7)
SEP #$20
LDA $7EF436 : LSR #3
JMP DrawDungeonCompassCounts_return_spot
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
; $7EF434 - hhhhdddd - item locations checked ; $7EF4C0-7EF4CF - item locations checked indexed by $040C >> 1
; h - hyrule castle/sewers
; d - palace of darkness
;--------------------------------------------------------------------------------
; $7EF435 - dddhhhaa - item locations checked
; d - desert palace
; h - tower of hera
; a - agahnim's tower
;--------------------------------------------------------------------------------
; $7EF436 - gggggeee - item locations checked
; g - ganon's tower
; e - eastern palace
;--------------------------------------------------------------------------------
; $7EF437 - sssstttt - item locations checked
; s - skull woods
; t - thieves town
;--------------------------------------------------------------------------------
; $7EF438 - iiiimmmm - item locations checked
; i - ice palace
; m - misery mire
;--------------------------------------------------------------------------------
; $7EF439 - ttttssss - item locations checked
; t - turtle rock
; s - swamp palace
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------

View File

@@ -313,63 +313,18 @@ AddInventory:
;!SHAME_CHEST = "$7EF416" ; ---s ---- ;!SHAME_CHEST = "$7EF416" ; ---s ----
;LDA !SHAME_CHEST : ORA.w #$0010 : STA !SHAME_CHEST ;LDA !SHAME_CHEST : ORA.w #$0010 : STA !SHAME_CHEST
;+ ;+
print "compass_w_addr: ", pc
SEP #$20 ; Set 8-bit Accumulator SEP #$20 ; Set 8-bit Accumulator
LDA $040C ; get dungeon id LDA $040C ; get dungeon id
CMP.b #$00 : BNE + ; Sewers (Escape) CMP.l BallNChainDungeon : BNE +
BRA ++ CPY.b #$32 : BNE +
+ CMP.b #$02 : BNE + ; Hyrule Castle (Escape)
++
CPY.b #$32 : BNE ++ : BRL .itemCounts : ++ ; Ball & Chain Guard's Big Key
%TopHalf($7EF434)
BRL .fullItemCounts BRL .fullItemCounts
+ CMP.b #$04 : BNE + ; Eastern Palace + LSR : TAX : LDA $7EF4C0, X : INC : STA $7EF4C0, X
LDA $7EF436 : INC : AND #$07 : TAX CPX.b #$0D : BNE +
LDA $7EF436 : AND #$F8 : STA $7EF436
TXA : ORA $7EF436 : STA $7EF436
BRL .fullItemCounts
+ CMP.b #$06 : BNE + ; Desert Palace
LDA $7EF435 : !ADD #$20 : STA $7EF435
BRL .fullItemCounts
+ CMP.b #$08 : BNE + ; Agahnim's Tower
LDA $7EF435 : INC : AND #$03 : TAX
LDA $7EF435 : AND #$FC : STA $7EF435
TXA : ORA $7EF435 : STA $7EF435
BRL .fullItemCounts
+ CMP.b #$0A : BNE + ; Swamp Palace
%BottomHalf($7EF439)
BRL .fullItemCounts
+ CMP.b #$0C : BNE + ; Palace of Darkness
%BottomHalf($7EF434)
BRL .fullItemCounts
+ CMP.b #$0E : BNE + ; Misery Mire
%BottomHalf($7EF438)
BRL .fullItemCounts
+ CMP.b #$10 : BNE + ; Skull Woods
%TopHalf($7EF437)
BRL .fullItemCounts
+ CMP.b #$12 : BNE + ; Ice Palace
%TopHalf($7EF438)
BRL .fullItemCounts
+ CMP.b #$14 : BNE + ; Tower of Hera
LDA $7EF435 : !ADD #$04 : AND #$1C : TAX
LDA $7EF435 : AND #$E3 : STA $7EF435
TXA : ORA $7EF435 : STA $7EF435
BRL .fullItemCounts
+ CMP.b #$16 : BNE + ; Thieves' Town
%BottomHalf($7EF437)
BRL .fullItemCounts
+ CMP.b #$18 : BNE + ; Turtle Rock
%TopHalf($7EF439)
BRL .fullItemCounts
+ CMP.b #$1A : BNE + ; Ganon's Tower
LDA $7EF436 : !ADD #$08 : STA $7EF436
LDA $7EF366 : AND #$04 : BNE ++ LDA $7EF366 : AND #$04 : BNE ++
JSR .incrementGTowerPreBigKey JSR .incrementGTowerPreBigKey
++ ++
;BRL .fullItemCounts
+ +
; == END INDOOR-ONLY SECTION ; == END INDOOR-ONLY SECTION

View File

@@ -55,30 +55,7 @@
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
; $7EF433 - locations before mirror ; $7EF433 - locations before mirror
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
; $7EF434 - hhhhdddd - item locations checked ; $7EF434-7EF439 - free space
; h - hyrule castle
; d - palace of darkness
;--------------------------------------------------------------------------------
; $7EF435 - dddhhhaa - item locations checked
; d - desert palace
; h - tower of hera
; a - agahnim's tower
;--------------------------------------------------------------------------------
; $7EF436 - gggggeee - item locations checked
; g - ganon's tower
; e - eastern palace
;--------------------------------------------------------------------------------
; $7EF437 - sssstttt - item locations checked
; s - skull woods
; t - thieves town
;--------------------------------------------------------------------------------
; $7EF438 - iiiimmmm - item locations checked
; i - ice palace
; m - misery mire
;--------------------------------------------------------------------------------
; $7EF439 - ttttssss - item locations checked
; t - turtle rock
; s - swamp palace
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
; $7EF43A - times mirrored outdoors ; $7EF43A - times mirrored outdoors
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
@@ -137,6 +114,8 @@
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
; $7EF466w[2] - mirror timestamp (high) ; $7EF466w[2] - mirror timestamp (high)
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
; $7EF4C0 - 7EF4CF - locations checked, indexed by 040C >> 1
;--------------------------------------------------------------------------------
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
!LOCK_STATS = "$7EF443" !LOCK_STATS = "$7EF443"

View File

@@ -1831,3 +1831,11 @@ db #$01
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
; 0x186380 - 187FFF (unused) ; 0x186380 - 187FFF (unused)
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
org $30EFFF ; PC 0x186FFF
BallNChainDungeon:
db #$02
org $30F000 ; PC 0x187000-0x18700F
CompassTotal:
db $08, $08, $06, $06, $02, $0A, $0E, $08, $08, $08, $06, $08, $0C, $1B, $00, $00