Notes for inverted mode
KevinCathcart opened this issue · 0 comments
This "issue" exits to provide Karkat with notes about spawning in a single entrance cave (specifally c-shaped house) for inverted mode. Please read this carefully.
Doing this in the approach we discussed consists of the randomizer front end writing out one row to the starting point table, (to specify the new starting point), and one row to the exit table (to update the Houlihan exit). Due to the column-major table design writing out one row to each of those tables consist of a bunch of really small writes, but it is still conceptually one record.
While the front end would be responsible for filling values into the two table rows mentioned, you will obviously want to have a local copy of the values to be set for testing purposes. You will want to stick the below in a file like sandbox.asm
. Fully commented version is available
;----------------------------------
; Start at C-Shaped house
;----------------------------------
org $02D8D2 : dw $11c
org $02D8E0 : db $23, $22, $23, $23, $19, $19, $19, $19
org $02D918 : dw $1900
org $02D926 : dw $2300
org $02D934 : dw $233e
org $02D942 : dw $1940
org $02D950 : dw $0177
org $02D95E : dw $017F
org $02D96C : db $03
org $02D973 : db $00
org $02D97A : db $FF
org $02D981 : db $00
org $02D988 : db $00
org $02D98F : db $02
org $02D996 : dw $0DE8
org $02D9A4 : dw $0054
org $02D9B2 : db $07
;--------------------------------------------------------------
; Make Houlihan exit at C-Shaped House
;--------------------------------------------------------------
org $02DB68 : dw $0003
org $02DBC9 : db $58
org $02DC55 : dw $09d8
org $02DCF3 : dw $0744
org $02DD91 : dw $02ce
org $02DE2F : dw $0797
org $02DECD : dw $0348
org $02DF6B : dw $07b3
org $02E009 : dw $0353
org $02E06A : db $0a
org $02E0B9 : db $f6
org $02E145 : dw $0DE8
org $02E1E3 : dw $0000
In addition to that, it is neccesary to add a hook that triggers when loading the link's house staring point, that will load up the values needed to allow leaving the starting area without crashing. In order to make it generic I've designed the hook to simply load values for the houlihan exit.
org $02D9B9 ; <- 159B9 - Bank02.asm:11089 (LDA $7EF3C8)
JSL AllowStartFromSingleEntranceCave
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
; 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 $02E0B9 : 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 $02DBC9 : AND.w #$00FF
STA $7EC14C ; Cache the overworld area number
STA $7EC140 ; Cache the aux overworld area number
PLA
.done
RTL
That hook is safe to run unconditionally, because multi-entrance caves ignore all those values, and they will all be overwritten the next time the player enters any overworld->underworld door.