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
;--------------------------------------------------------------------------------
;--------------------------------------------------------------------------------

View File

@@ -905,8 +905,36 @@ db $00, $01, $02, $03, $04
; $308220 (0x180220) - $30823F (0x18023F)
; Plandomizer Author Name (ASCII) - Leave unused chars as 0
org $308220 ; PC 0x180220
;================================================================================
; $308240 (0x180420) - $308246 (0x180246)
; For starting areas in single entrance caves, we specify which row in the StartingAreaExitTable
; to use for exit information. Values are 1 based indexes, with 0 representing a multi-entrance cave
; start position.
; Position 0: Link's House
; Position 1: sanctuary
; Position 2: Zelda's cell
; Position 3: Wounded Uncle
; Position 4: Mantle
; Position 5: Middle of Old Man Cave
; Position 6: Old Man's House
org $308240 ; PC 0x180240
StartingAreaExitOffset:
db $00, $00, $00, $00, $00, $00, $00
;--------------------------------------------------------------------------------
; 0x180240 - 0x1814FF (unused)
; 0x180246 - 0x18024F (unused)
;-------------------------------------------------------------------------------
; $308250 (0x180250) - $30829F (0x18029F)
org $308250 ; PC 0x180250
StartingAreaExitTable:
; This has the same format as the main Exit table, except
; is stored row major instead of column major
; it lacks the last two columns and has 1 padding byte per row (the last byte)
dw $0112 : db $53 : dw $001e, $0400, $06e2, $0446, $0758, $046d, $075f : db $00, $00, $00
dw $0000 : db $00 : dw $0000, $0000, $0000, $0000, $0000, $0000, $0000 : db $00, $00, $00
dw $0000 : db $00 : dw $0000, $0000, $0000, $0000, $0000, $0000, $0000 : db $00, $00, $00
dw $0000 : db $00 : dw $0000, $0000, $0000, $0000, $0000, $0000, $0000 : db $00, $00, $00
;================================================================================
; 0x1802A0 - 0x1814FF (unused)
;================================================================================
; $309500 (0x181500) - $309FFF (0x181FFF) original 0x39C bytes
; Replacement Ending Sequence Text Data