Entrances stuff
Page 1 of 1
20151120
Entrances stuff
- Code:
; *$158B3-$15B6D LOCAL
Dungeon_LoadEntrance:
{
; Routine initializes dungeons
PHB : PHK : PLB
; Link is officially in a dungeon now.
LDA.b #$01 : STA $1B
; Did Link just die and he's being respawned in this dungeon?
LDA $010A : BEQ .notDeathReload
STZ $010A
; if Link died in this dungeon, presumably all these variables are still cached
; anyway
JMP .skipCaching
.notDeathReload
REP #$20
LDA $040A : STA $7EC140 ; Mirror the aux overworld area number
LDA $1C : STA $7EC142 ; Mirror the main screen designation
LDA $E8 : STA $7EC144 ; Mirror BG1 V scroll
LDA $E2 : STA $7EC146 ; Mirror BG1 H scroll
LDA $20 : STA $7EC148 ; Mirror Link's Y coordinate
LDA $22 : STA $7EC14A ; Mirror Link's X coordinate
LDA $0618 : STA $7EC150 ; Mirror Camera Y coord lower bound.
LDA $061C : STA $7EC152 ; Mirror Camera X coord lower bound.
LDA $8A : STA $7EC14C ; Mirror the overworld area number
LDA $84 : STA $7EC14E ; Not sure about this one.
STZ $8A
STZ $8C
LDA $0600 : STA $7EC154
LDA $0602 : STA $7EC156
LDA $0604 : STA $7EC158
LDA $0606 : STA $7EC15A
LDA $0610 : STA $7EC15C
LDA $0612 : STA $7EC15E
LDA $0614 : STA $7EC160
LDA $0616 : STA $7EC162
LDA $0624 : STA $7EC16A
LDA $0626 : STA $7EC16C
LDA $0628 : STA $7EC16E
LDA $062A : STA $7EC170
SEP #$20
; cache graphics settings
LDA $0AA0 : STA $7EC164
LDA $0AA1 : STA $7EC165
LDA $0AA2 : STA $7EC166
LDA $0AA3 : STA $7EC167
REP #$30
.skipCaching
STZ $011A : STZ $011C : STZ $010A
; Check which character is following Link. Check if it’s the old man
; Yep, must use an entrance
LDA $7EF3CC : CMP.w #$0004 : BEQ .useStartingPointEntrance
LDA $04AA : BEQ .notSaveAndContinue
.useStartingPointEntrance
; Load using an starting point entrance index instead.
JMP Dungeon_LoadStartingPoint
.notSaveAndContinue
; Use a normal entrance instead
LDA $010E : AND.w #$00FF : ASL A : TAX : ASL #2 : TAY
LDA $C813, X : STA $A0 : STA $048E
LDA $CE4F, X : STA $E8 : STA $E6 : STA $0122 : STA $0124
LDA $CD45, X : STA $E2 : STA $E0 : STA $011E : STA $0120
; Has Link woken up yet?
LDA $7EF3C5 : BEQ .beforeUncleGear
; $14F59, X THAT IS
LDA $CF59, X : STA $20
LDA $D063, X : STA $22
.beforeUncleGear
LDA $D16D, X : STA $0618 : INC #2 : STA $061A
LDA $D277, X : STA $061C : INC #2 : STA $061E
LDA.w #$01F8 : STA $EC
LDA $D724, X : STA $0696 : STZ $0698
LDA.w #$0000 : STA $0610
LDA.w #$0110 : STA $0612
LDA.w #$0000 : STA $0614
LDA.w #$0100 : STA $0616
LDA $010E : AND.w #$00FF : TAX
SEP #$20
; HM calls these scroll edges. Must investigate.
LDA $C91D, Y : STA $0601
LDA $C91E, Y : STA $0603
LDA $C91F, Y : STA $0605
LDA $C920, Y : STA $0607
LDA $C921, Y : STA $0609
LDA $C922, Y : STA $060B
LDA $C923, Y : STA $060D
LDA $C924, Y : STA $060F
STZ $0600 : STZ $0602
LDA.b #$10 : STA $0604 : STA $0606 : STA $0608 : STA $060A : STA $060C : STA $060E
; Make it so Link faces south (down) at most entrances.
LDA.b #$02
CPX.w #$0000 : BEQ .linkFacesSouth
; one special cases where Link enters from the top. potential for an edit here
CPX.w #$0043 : BEQ .linkFacesSouth
LDA.b #$00 ; Make it so Link faces north
.linkFacesSouth
STA $2F
; Main blockset value
LDA $D381, X : STA $0AA1
; Music value. Is it the beginning music?
LDA $D82E, X : STA $0132 : CMP.b #$03 : BNE .notBeginningMusic
; Check game status
; Is it less than first part?
LDA $7EF3C5 : CMP.b #$02 : BCC .haventSavedZelda
; Play the cave music if it's first or second part.
LDA.b #$12
.haventSavedZelda
STA $0132
.notBeginningMusic
LDA $D406, X : STA $A4
; Load the palace number.
LDA $D48B, X : STA $040C
; Interestingly enough, this could allow for horizontal doorways?
LDA $D510, X : STA $6C
; Set the position that Link starts at.
LDA $D595, X : LSR #4 : STA $EE
; Set Pseudo bg level
LDA $D595, X : AND.b #$0F : STA $0476
LDA $D61A, X : LSR #4 : STA $A6
LDA $D61A, X : AND.b #$0F : STA $A7
LDA $D69F, X : LSR #4 : STA $A9
LDA $D69F, X : AND.b #$0F : STA $AA
LDX $A0 : CPX.w #$0100 : BCC .notExtendedRoom
; rooms above room 255 apparently can't have multiple floors?
; probably b/c they can't utilize exits
STZ $A4
Some of the more interesting stuff:
; Interestingly enough, this could allow for horizontal doorways?
LDA $D510, X : STA $6C
; Make it so Link faces south (down) at most entrances.
LDA.b #$02
CPX.w #$0000 : BEQ .linkFacesSouth
; one special cases where Link enters from the top. potential for an edit here
CPX.w #$0043 : BEQ .linkFacesSouth
LDA.b #$00 ; Make it so Link faces north
.linkFacesSouth
STA $2F
Founder- Since : 2012-06-19
Permissions in this forum:
You cannot reply to topics in this forum