Cave state fixes

This commit is contained in:
aerinon
2023-03-06 16:10:41 -07:00
parent 72e8d73277
commit 5c213477bc
2 changed files with 20 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
WarpLeft:
lda.l DRMode : beq .end
lda $040c : cmp.b #$ff : beq .end
JSR CheckIfCave : BCS .end
lda $20 : ldx $aa
jsr CalcIndex
!add #$06 : ldy #$01 ; offsets in A, Y
@@ -11,7 +11,7 @@ WarpLeft:
WarpRight:
lda.l DRMode : beq .end
lda $040c : cmp.b #$ff : beq .end
JSR CheckIfCave : BCS .end
lda $20 : ldx $aa
jsr CalcIndex
!add #$12 : ldy #$ff ; offsets in A, Y
@@ -22,7 +22,7 @@ WarpRight:
WarpUp:
lda.l DRMode : beq .end
lda $040c : cmp.b #$ff : beq .end
JSR CheckIfCave : BCS .end
lda $22 : ldx $a9
jsr CalcIndex
ldy #$02 ; offsets in A, Y
@@ -40,7 +40,7 @@ endmacro
WarpDown:
lda.l DRMode : beq .end
lda $040c : cmp.b #$ff : beq .end
JSR CheckIfCave : BCS .end
lda $22 : ldx $a9
jsr CalcIndex
!add #$0c : ldy #$ff ; offsets in A, Y
@@ -79,6 +79,14 @@ Cleanup:
lda $ef
rts
; carry set if cave, clear otherwise
CheckIfCave:
REP #$30
LDA.b $A2 : CMP.w #$00E1 : BCS .invalid
SEP #$30 : CLC : RTS
.invalid
SEP #$30 : SEC : RTS
;A needs be to the low coordinate, x needs to be either 0 for left,upper or non-zero for right,down
; This sets A (00,02,04) and stores half that at $04 for later use, (src door)
CalcIndex: ; A->low byte of Link's Coord, X-> Link's quadrant, DoorOffset x 2 -> A, DoorOffset -> $04 (vert/horz agnostic)

View File

@@ -1,24 +1,28 @@
RecordStairType: {
pha
lda.l DRMode : beq .norm
lda $040c : cmp #$ff : beq .norm
REP #$30 : LDA.b $A2 : CMP.w #$00E1 : BCS .norm
CMP #$00DF : BEQ .norm
SEP #$30
lda $0e
cmp #$25 : bcc ++ ; don't record straight staircases
sta $045e
++ pla : bra +
.norm pla : sta $a0
.norm SEP #$30 : pla : sta $a0
+ lda $063d, x
rtl
}
SpiralWarp: {
lda.l DRMode : beq .abort ; abort if not DR
lda $040c : cmp.b #$ff : beq .abort ; abort if not in dungeon
REP #$30 : LDA.b $A2 : CMP.w #$00E1 : BCS .abort
CMP #$00DF : BEQ .abort
SEP #$30
lda $045e : cmp #$5e : beq .gtg ; abort if not spiral - intended room is in A!
cmp #$5f : beq .gtg
cmp #$26 : beq .inroom
.abort
stz $045e : lda $a2 : and #$0f : rtl ; clear,run hijacked code and get out
SEP #$30 : stz $045e : lda $a2 : and.b #$0f : rtl ; clear,run hijacked code and get out
.inroom
jsr InroomStairsWarp
lda $a2 : and #$0f ; this is the code we are hijacking