Revise code for starting In Single entrance caves

No longer hardcoded to only work for link's house.
This commit is contained in:
Kevin Cathcart
2018-08-19 10:41:17 -04:00
parent 5a6935ca63
commit d81bec6c88
2 changed files with 71 additions and 32 deletions

View File

@@ -39,39 +39,50 @@ JML.l Overworld_Entrance_BRANCH_RHO
AllowStartFromSingleEntranceCave:
; 16 Bit A, 16 bit XY
; do not need to preserve A or X or Y
LDA $7EF3C8 : AND.w #$00FF ; What we wrote over
BEQ +
BRL .done
+
PHA
LDA #$0016 : STA $7EC142 ; Cache the main screen designation
LDA $02DCF3 : STA $7EC144 ; Cache BG1 V scroll
LDA $02DD91 : STA $7EC146 ; Cache BG1 H scroll
LDA $02DE2F : !ADD.w #$0010 : STA $7EC148 ; Cache Link's Y coordinate
LDA $02DECD : STA $7EC14A ; Cache Link's X coordinate
LDA $02DF6B : STA $7EC150 ; Cache Camera Y coord lower bound.
LDA $02E009 : STA $7EC152 ; Cache Camera X coord lower bound.
LDA $02DC55 : STA $7EC14E ; Cache Link VRAM Location
LDA $7EF3C8 : AND.w #$00FF ; What we wrote over
PHA
TAX
; Handle the 2 "unknown" bytes, which control what area of the backgound
; relative to the camera gets loaded with new tile data as the player moves around
; (because some overworld areas like Kak are too big for a single VRAM tilemap)
LDA.l $02E06A : AND.w #$00FF
BIT.w #$0080 : BEQ + : ORA #$FF00 : + ; Sign extend
STA.l $7EC16A
LDA.l StartingAreaExitOffset, X
LDA.l $02E0B9 : AND.w #$00FF
BIT.w #$0080 : BEQ + : ORA #$FF00 : + ; Sign extend
STA.l $7EC16E
BNE +
BRL .done
+
LDA.w #$0000 : !SUB.l $7EC16A : STA $7EC16C
LDA.w #$0000 : !SUB.l $7EC16E : STA $7EC170
DEC
STA $00
LSR #2 : !ADD $00 : LSR #2 ; mult by 20
TAX
LDA $02DBC9 : AND.w #$00FF
STA $7EC14C ; Cache the overworld area number
STA $7EC140 ; Cache the aux overworld area number
PLA
.done
LDA #$0016 : STA $7EC142 ; Cache the main screen designation
LDA.l StartingAreaExitTable+$05, X : STA $7EC144 ; Cache BG1 V scroll
LDA.l StartingAreaExitTable+$07, X : STA $7EC146 ; Cache BG1 H scroll
LDA.l StartingAreaExitTable+$09, X : !ADD.w #$0010 : STA $7EC148 ; Cache Link's Y coordinate
LDA.l StartingAreaExitTable+$0B, X : STA $7EC14A ; Cache Link's X coordinate
LDA.l StartingAreaExitTable+$0D, X : STA $7EC150 ; Cache Camera Y coord lower bound.
LDA.l StartingAreaExitTable+$0F, X : STA $7EC152 ; Cache Camera X coord lower bound.
LDA.l StartingAreaExitTable+$03, X : STA $7EC14E ; Cache Link VRAM Location
; Handle the 2 "unknown" bytes, which control what area of the backgound
; relative to the camera? gets loaded with new tile data as the player moves around
; (because some overworld areas like Kak are too big for a single VRAM tilemap)
LDA.l StartingAreaExitTable+$11, X : AND.w #$00FF
BIT.w #$0080 : BEQ + : ORA #$FF00 : + ; Sign extend
STA.l $7EC16A
LDA.l StartingAreaExitTable+$12, X : AND.w #$00FF
BIT.w #$0080 : BEQ + : ORA #$FF00 : + ; Sign extend
STA.l $7EC16E
LDA.w #$0000 : !SUB.l $7EC16A : STA $7EC16C
LDA.w #$0000 : !SUB.l $7EC16E : STA $7EC170
LDA.l StartingAreaExitTable+$02, X : AND.w #$00FF
STA $7EC14C ; Cache the overworld area number
STA $7EC140 ; Cache the aux overworld area number
.done
PLA
RTL
;--------------------------------------------------------------------------------
;--------------------------------------------------------------------------------