Another refactor of camera bounds logic
This commit is contained in:
@@ -335,5 +335,10 @@ CamBoundIndex: ; Horizontal 1st
|
|||||||
db 0, 4 ; Camera Bounds $0618-$61f
|
db 0, 4 ; Camera Bounds $0618-$61f
|
||||||
OppCamBoundIndex: ; Horizontal 1st
|
OppCamBoundIndex: ; Horizontal 1st
|
||||||
db 4, 0 ; Camera Bounds $0618-$61f
|
db 4, 0 ; Camera Bounds $0618-$61f
|
||||||
|
CamBoundBaseLine: ; X camera stuff is 1st column todo Y camera is not right yet
|
||||||
|
dw $007f, $0077 ; Left/Top camera bounds when at edge or layout frozen
|
||||||
|
dw $0007, $000b ; Left/Top camera bounds when not frozen + appropriate low byte $22/$20 (preadj. by #$78/#$6c)
|
||||||
|
dw $00ff, $010b ; Right/Bot camera bounds when not frozen + appropriate low byte $20/$22
|
||||||
|
dw $017f, $0187 ; Right/Bot camera bound when at edge or layout frozen
|
||||||
|
|
||||||
incsrc doortables.asm
|
incsrc doortables.asm
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
SpiralWarp:
|
SpiralWarp: {
|
||||||
{
|
|
||||||
|
|
||||||
pha : lda $040c : cmp.b #$ff : beq .abort ; abort if not in dungeon
|
pha : lda $040c : cmp.b #$ff : beq .abort ; abort if not in dungeon
|
||||||
cmp #$06 : bcs .abort ; abort if not supported yet -- todo: this needs to be altered/removed as more dungeons are implemented
|
cmp #$06 : bcs .abort ; abort if not supported yet -- todo: this needs to be altered/removed as more dungeons are implemented
|
||||||
lda $0e : cmp #$5e : beq .gtg ; abort if not spiral - intended room is in A!
|
lda $0e : cmp #$5e : beq .gtg ; abort if not spiral - intended room is in A!
|
||||||
@@ -34,7 +32,9 @@ SpiralWarp:
|
|||||||
lda $02 : sta $22
|
lda $02 : sta $22
|
||||||
lda $03 : sta $20
|
lda $03 : sta $20
|
||||||
|
|
||||||
|
lda $01 : and #$10 : sta $07 ; zeroHzCam check
|
||||||
ldy #$00 : jsr SetCamera
|
ldy #$00 : jsr SetCamera
|
||||||
|
lda $01 : and #$20 : sta $07 ; zeroVtCam check
|
||||||
ldy #$01 : jsr SetCamera
|
ldy #$01 : jsr SetCamera
|
||||||
|
|
||||||
ply : plx : plb ; pull the stuff we pushed
|
ply : plx : plb ; pull the stuff we pushed
|
||||||
@@ -47,8 +47,7 @@ SpiralWarp:
|
|||||||
}
|
}
|
||||||
|
|
||||||
;Sets the offset in A
|
;Sets the offset in A
|
||||||
LookupSpiralOffset:
|
LookupSpiralOffset: {
|
||||||
{
|
|
||||||
;where link currently is in $a2: quad in a8 & #$03
|
;where link currently is in $a2: quad in a8 & #$03
|
||||||
;count doors
|
;count doors
|
||||||
stz $00 : ldx #$00 : stz $01
|
stz $00 : ldx #$00 : stz $01
|
||||||
@@ -85,8 +84,7 @@ LookupSpiralOffset:
|
|||||||
rts
|
rts
|
||||||
}
|
}
|
||||||
|
|
||||||
ShiftQuadSimple:
|
ShiftQuadSimple: {
|
||||||
{
|
|
||||||
lda CoordIndex,y : tax
|
lda CoordIndex,y : tax
|
||||||
lda $21,x : !add $06 : sta $21,x ; coordinate update
|
lda $21,x : !add $06 : sta $21,x ; coordinate update
|
||||||
lda CamQuadIndex,y : tax
|
lda CamQuadIndex,y : tax
|
||||||
@@ -95,8 +93,7 @@ ShiftQuadSimple:
|
|||||||
rts
|
rts
|
||||||
}
|
}
|
||||||
|
|
||||||
SetCamera:
|
SetCamera: {
|
||||||
{
|
|
||||||
stz $04 : sty $05
|
stz $04 : sty $05
|
||||||
|
|
||||||
tyx : lda $a9,x : bne .nonZeroHalf
|
tyx : lda $a9,x : bne .nonZeroHalf
|
||||||
@@ -105,34 +102,51 @@ SetCamera:
|
|||||||
dec $e3,x
|
dec $e3,x
|
||||||
|
|
||||||
.noQuadAdj
|
.noQuadAdj
|
||||||
lda $01 : and #$10 : !add $05 : cmp #$10 : beq .done ; zeroHzCam check (10+0 = 10)
|
lda $07 : bne .adj0
|
||||||
lda $01 : and #$20 : !add $05 : cmp #$21 : beq .done ; zeroVtCam check (20+1 = 21)
|
|
||||||
lda CoordIndex,y : tax
|
lda CoordIndex,y : tax
|
||||||
lda $20,x : cmp #$79 : bcc .done
|
lda $20,x : cmp #$79 : bcc .adj0
|
||||||
!sub #$78 : sta $04 : bra .done
|
!sub #$78 : sta $04
|
||||||
|
tya : asl : add #$04 : tax : jsr AdjCamBounds : bra .done
|
||||||
|
.adj0
|
||||||
|
tya : asl : tax : jsr AdjCamBounds : bra .done
|
||||||
|
|
||||||
.nonZeroHalf ;meaning either right half or bottom half
|
.nonZeroHalf ;meaning either right half or bottom half
|
||||||
lda CoordIndex,y : tax
|
lda CoordIndex,y : tax
|
||||||
lda $20,x : cmp #$78 : bcs .setQuad
|
lda $20,x : cmp #$78 : bcs .setQuad
|
||||||
lda $01 : and #$10 : !add $05 : cmp #$10 : beq .done ; zeroHzCam check (10+0 = 10)
|
lda $07 : bne .adj1
|
||||||
lda $01 : and #$20 : !add $05 : cmp #$21 : beq .done ; zeroVtCam check (20+1 = 21)
|
!add #$78 : sta $04
|
||||||
!add #$78 : sta $04 : bra .done
|
tya : asl : add #$08 : tax : jsr AdjCamBounds : bra .done
|
||||||
|
|
||||||
.setQuad
|
.setQuad
|
||||||
lda CamQuadIndex,y : tax : lda $0607, x : pha
|
lda CamQuadIndex,y : tax : lda $0607, x : pha
|
||||||
lda CameraIndex,y : tax : pla : sta $e3, x
|
lda CameraIndex,y : tax : pla : sta $e3, x
|
||||||
bra .done
|
.adj1
|
||||||
|
tya : asl : add #$0c : tax : jsr AdjCamBounds : bra .done
|
||||||
|
|
||||||
.done
|
.done
|
||||||
lda CameraIndex,y : tax : lda $e2, x : phx
|
lda CameraIndex,y : tax : lda $e2, x : phx
|
||||||
jsr AdjCamBounds
|
lda $04 : sta $e2, x
|
||||||
plx : lda $e2, x : !sub $04 : sta $e2, x
|
|
||||||
rts
|
rts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; input, expects X to be an appropriate offset into the CamBoundBaseLine table
|
||||||
|
; when $04 is 0 no coordinate are added
|
||||||
|
AdjCamBounds: {
|
||||||
|
rep #$20 : lda CamBoundBaseLine, x : sta $05
|
||||||
|
lda $04 : and #$00ff : beq .common
|
||||||
|
lda CoordIndex,y : tax
|
||||||
|
lda $20, x : and #$00ff : !add $05 : sta $05
|
||||||
|
.common
|
||||||
|
lda OppCamBoundIndex,y : tax
|
||||||
|
lda $05 : sta $0618, x
|
||||||
|
inc #2 : sta $061A, x : sep #$20
|
||||||
|
rts
|
||||||
|
}
|
||||||
|
|
||||||
|
; todo - should I delete this, yet?
|
||||||
;input : A should be loaded with current camera low byte
|
;input : A should be loaded with current camera low byte
|
||||||
; $04 should be loaded with what we want the low byte to become (00-ff)
|
; $04 should be loaded with what we want the low byte to become (00-ff)
|
||||||
AdjCamBounds:
|
AdjCamBoundsOld:
|
||||||
{
|
{
|
||||||
stz $05 : rep #$30 : and #$00FF ; sanitize input for 16 bit
|
stz $05 : rep #$30 : and #$00FF ; sanitize input for 16 bit
|
||||||
!sub $04 : sta $04
|
!sub $04 : sta $04
|
||||||
|
|||||||
Reference in New Issue
Block a user