Fixed some minor issues

Started work on Straight Stairs
This commit is contained in:
aerinon
2020-04-01 12:48:04 -06:00
parent c968621ba3
commit 01bff51707
13 changed files with 294 additions and 425 deletions

View File

@@ -15,6 +15,7 @@ incsrc drhooks.asm
;Main Code
org $278000 ;138000
incsrc normal.asm
incsrc scroll.asm
incsrc spiral.asm
incsrc gfx.asm
incsrc keydoors.asm

View File

@@ -43,7 +43,7 @@ db $00,$01,$02,$00,$03,$00,$04,$00,$00,$00,$00,$00,$00,$05,$00,$00
db $00,$06,$07,$08,$09,$0A,$0B,$00,$00,$0C,$0D,$0E,$00,$0F,$10,$11
db $12,$13,$14,$15,$16,$00,$17,$00,$00,$00,$18,$19,$00,$00,$1A,$00
db $1B,$00,$1C,$1D,$1E,$1F,$20,$21,$22,$23,$24,$25,$00,$26,$27,$00
db $00,$28,$00,$29,$2A,$2B,$2C,$00,$00,$2D,$2E,$2F,$30,$31,$32,$00
db $96,$28,$97,$29,$2A,$2B,$2C,$00,$00,$2D,$2E,$2F,$30,$31,$32,$00
db $33,$34,$35,$36,$00,$00,$37,$38,$39,$3A,$3B,$3C,$3D,$3E,$3F,$40
db $41,$42,$43,$00,$00,$00,$44,$45,$46,$00,$47,$48,$49,$4A,$4B,$00
db $00,$4C,$00,$00,$00,$4D,$4E,$00,$00,$00,$00,$4F,$50,$51,$52,$53
@@ -208,14 +208,16 @@ dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003,
dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Eastern Attic Start
dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TT Entrance Quad
dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TT SE Quad
; this should end at 27AE10 about
; some values you can hardcode
dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Aga 6F
dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Sewers Rope
; this should end at 27AE40 about (152 * 24 bytes = 3648 or E40)
; some values you can hardcode for spirals
;dw $0070, $36a0 ; ->HC Stairwell
;dw $0072, $4ff8 ; ->HC Map Room
;dw $0080, $1f50 ; ->zelda's cellblock
org $27B000
SpiralTable:
SpiralTable: ;113 4 byte entries - should end at 27B44C
dw $0203, $8080 ;null row
dw $0203, $8080 ;HC Backhallway
dw $0203, $8080 ;Sewer Pull

View File

@@ -24,12 +24,19 @@ NotLinkDoor2:
; Staircase routine
org $01c3d4 ;(PC: c3d4)
org $01c3d4 ; <- c3d4 - Bank01.asm : 9762-4 (Dungeon_DetectStaircase-> STA $A0 : LDA $063D, X)
jsl RecordStairType : nop
org $02a1e7 ;(PC: 121e7)
jsl SpiralWarp
org $029383 ; <- 11384 - Bank02.asm : 3629 (.walkingDownStaircase-> ADD $20 : STA $20)
jsl StraightStairsFix : nop
org $0293aa ; <- 113aa - Bank02.asm : 3653 (ADD $20 : STA $20)
jsl StraightStairsFix : nop
org $029396 ; <- 11384 - Bank02.asm : 3641 (LDA $01C322, X)
jsl StraightStairLayerFix
; Graphics fix
org $02895d
Splicer:

View File

@@ -114,173 +114,6 @@ MathEnd:
sep #$30
rts
; expects target quad in $05 (either 0 or 1) and target pixel in $04, target room should be in $a0
; $06 is either $ff or $01/02
; uses $00-$03 and $0e for calculation
; also set up $ac
ScrollY: ;change the Y offset variables
lda $a0 : and.b #$f0 : lsr #3 : sta $0603 : inc : sta $0607
lda $05 : bne +
lda $603 : sta $00 : stz $01 : bra ++
+ lda $607 : sta $00 : lda #$02 : sta $01
++ ; $01 now contains 0 or 2 and $00 contains the correct lat
stz $0e
rep #$30
lda $00 : pha
lda $e8 : and #$01ff : sta $02
lda $04 : jsr LimitYCamera : sta $00
jsr CheckRoomLayoutY : bcc +
lda $00 : cmp #$0080 : !bge ++
cmp #$0010 : !blt .cmpSrll
lda #$0010 : bra .cmpSrll
++ cmp #$0100 : !bge .cmpSrll
lda #$0100
.cmpSrll sta $00
; figures out scroll amt
+ lda $00 : cmp $02 : bne +
lda #$0000 : bra .next
+ !blt +
!sub $02 : inc $0e : bra .next
+ lda $02 : !sub $00
.next
sta $ab
jsr AdjustCameraBoundsY
pla : sta $00
sep #$30
lda $04 : sta $20
lda $00 : sta $21 : sta $0601 : sta $0605
lda $01 : sta $aa
lda $0e : asl : ora $ac : sta $ac
lda $e9 : and #$01 : asl #2 : tax : lda $0603, x : sta $e9
rts
LimitYCamera:
cmp #$006c : !bge +
lda #$0000 : bra .end
+ cmp #$017d : !blt +
lda #$0110 : bra .end
+ !sub #$006c
.end rts
CheckRoomLayoutY:
jsr LoadRoomLayout ;switches to 8-bit
cmp #$00 : beq .lock
cmp #$07 : beq .free
cmp #$01 : beq .free
cmp #$04 : !bge .lock
cmp #$02 : bne +
lda $06 : cmp #$ff : beq .lock
+ cmp #$03 : bne .free
lda $06 : cmp #$ff : bne .lock
.free rep #$30 : clc : rts
.lock rep #$30 : sec : rts
LoadRoomLayout:
lda $a0 : asl : !add $a0 : tax
lda $1f8001, x : sta $b8
lda $1f8000, x : sta $b7
sep #$30
ldy #$01 : lda [$b7], y : and #$1c : lsr #2
rts
; expects target quad in $05 (either 0 or 1) and target pixel in $04, target room should be in $a0
; uses $00-$03 and $0e for calculation
; also set up $ac
ScrollX: ;change the X offset variables
lda $a0 : and.b #$0f : asl : sta $060b : inc : sta $060f
lda $05 : bne +
lda $60b : sta $00 : stz $01 : bra ++
+ lda $60f : sta $00 : lda #$01 : sta $01
++ ; $01 now contains 0 or 1 and $00 contains the correct long
stz $0e ; pos/neg indicator
rep #$30
lda $00 : pha
lda $e2 : and #$01ff : sta $02
lda $04 : jsr LimitXCamera : sta $00
jsr CheckRoomLayoutX : bcc +
lda $00 : cmp #$0080 : !bge ++
lda #$0000 : bra .cmpSrll
++ lda #$0100
.cmpSrll sta $00
;figures out scroll amt
+ lda $00 : cmp $02 : bne +
lda #$0000 : bra .next
+ !blt +
!sub $02 : inc $0e : bra .next
+ lda $02 : !sub $00
.next
sta $ab : lda $04
cmp #$0078 : !bge +
lda #$007f : bra ++
+ cmp #$0178 : !blt +
lda #$017f : bra ++
+ !add #$0007
++ sta $061c : inc #2 : sta $061e
pla : sta $00
sep #$30
lda $04 : sta $22
lda $00 : sta $23 : sta $0609 : sta $060d
lda $01 : sta $a9
lda $0e : asl : ora $ac : sta $ac
lda $e3 : and #$01 : asl #2 : tax : lda $060b, x : sta $e3
rts
LimitXCamera:
cmp #$0080 : !bge +
lda #$0000 : bra .end
+ cmp #$0181 : !blt +
lda #$0180
+ !sub #$0080
.end rts
CheckRoomLayoutX:
jsr LoadRoomLayout ;switches to 8-bit
cmp #$04 : !blt .lock
cmp #$05 : bne +
lda $06 : cmp #$ff : beq .lock
+ cmp #$06 : bne .free
lda $06 : cmp #$ff : bne .lock
.free rep #$30 : clc : rts
.lock rep #$30 : sec : rts
AdjustCameraBoundsY:
jsr CheckRoomLayoutY : bcc .free
; layouts that are camera locked (quads only)
lda $04 : and #$00ff : cmp #$007d : !blt +
lda #$0088 : bra ++
+ cmp #$006d : !bge +
lda #$0078 : bra ++
+ !add #$000b
; I think we no longer need the $02 variable
++ sta $02 : lda $04 : and #$0100 : !add $02 : bra .setBounds
; layouts where the camera is free
.free lda $04 : cmp #$006c : !bge +
lda #$0077 : bra .setBounds
+ cmp #$017c : !blt +
lda #$0187 : bra .setBounds
+ !add #$000b
.setBounds sta $0618 : inc #2 : sta $061a
rts
; don't need midpoint of edge Link is leaving (formerly in $06 - used by dir indicator)
; don't need width of edge Link is going to (currently in $0b)
LoadNorthData:

View File

@@ -106,7 +106,11 @@ LoadRoomHorz:
.normal
jsr PrepScrollToNormal
.scroll jsr ScrollY
.scroll
lda $01 : and #$40 : pha
jsr ScrollY
pla : beq .end
ldy #$06 : jsr ApplyScroll
.end
plb ; restore db register
rts
@@ -135,7 +139,11 @@ LoadRoomVert:
.normal
jsr PrepScrollToNormal
.scroll jsr ScrollX
.scroll
lda $01 : and #$40 : pha
jsr ScrollX
pla : beq .end
ldy #$00 : jsr ApplyScroll
.end
plb ; restore db register
rts
@@ -198,33 +206,16 @@ PrepScrollToNormal:
.end rts
}
AdjustTransition:
StraightStairsFix:
{
lda $ab : and #$01ff : beq .reset
phy : ldy #$06 ; operating on vertical registers during horizontal trans
cpx.b #$02 : bcs .horizontalScrolling
ldy #$00 ; operate on horizontal regs during vert trans
.horizontalScrolling
cmp #$0008 : bcs +
pha : lda $ab : and #$0200 : beq ++
pla : bra .add
++ pla : eor #$ffff : inc ; convert to negative
.add jsr AdjustCamAdd : ply : bra .reset
+ lda $ab : and #$0200 : xba : tax
lda.l OffsetTable,x : jsr AdjustCamAdd
lda $ab : !sub #$0008 : sta $ab
ply : bra .done
.reset ; clear the $ab variable so to not disturb intra-tile doors
stz $ab
.done
lda $00 : and #$01fc
rtl
lda DRMode : bne +
!add $20 : sta $20
+ rtl
}
AdjustCamAdd:
!add $00E2,y : pha
and #$01ff : cmp #$0111 : !blt +
cmp #$01f8 : !bge ++
pla : and #$ff10 : pha : bra +
++ pla : and #$ff00 : !add #$0100 : pha
+ pla : sta $00E2,y : sta $00E0,y : rts
StraightStairLayerFix:
{
lda DRMode : beq +
lda $ee : rtl
+ lda $01c322, x : rtl
}

206
asm/scroll.asm Normal file
View File

@@ -0,0 +1,206 @@
AdjustTransition:
{
lda $ab : and #$01ff : beq .reset
phy : ldy #$06 ; operating on vertical registers during horizontal trans
cpx.b #$02 : bcs .horizontalScrolling
ldy #$00 ; operate on horizontal regs during vert trans
.horizontalScrolling
cmp #$0008 : bcs +
pha : lda $ab : and #$0200 : beq ++
pla : bra .add
++ pla : eor #$ffff : inc ; convert to negative
.add jsr AdjustCamAdd : ply : bra .reset
+ lda $ab : and #$0200 : xba : tax
lda.l OffsetTable,x : jsr AdjustCamAdd
lda $ab : !sub #$0008 : sta $ab
ply : bra .done
.reset ; clear the $ab variable so to not disturb intra-tile doors
stz $ab
.done
lda $00 : and #$01fc
rtl
}
AdjustCamAdd:
!add $00E2,y : pha
and #$01ff : cmp #$0111 : !blt +
cmp #$01f8 : !bge ++
pla : and #$ff10 : pha : bra +
++ pla : and #$ff00 : !add #$0100 : pha
+ pla : sta $00E2,y : sta $00E0,y : rts
; expects target quad in $05 (either 0 or 1) and target pixel in $04, target room should be in $a0
; $06 is either $ff or $01/02
; uses $00-$03 and $0e for calculation
; also set up $ac
ScrollY: ;change the Y offset variables
lda $a0 : and.b #$f0 : lsr #3 : sta $0603 : inc : sta $0607
lda $05 : bne +
lda $603 : sta $00 : stz $01 : bra ++
+ lda $607 : sta $00 : lda #$02 : sta $01
++ ; $01 now contains 0 or 2 and $00 contains the correct lat
stz $0e
rep #$30
lda $00 : pha
lda $e8 : and #$01ff : sta $02
lda $04 : jsr LimitYCamera : sta $00
jsr CheckRoomLayoutY : bcc +
lda $00 : cmp #$0080 : !bge ++
cmp #$0010 : !blt .cmpSrll
lda #$0010 : bra .cmpSrll
++ cmp #$0100 : !bge .cmpSrll
lda #$0100
.cmpSrll sta $00
; figures out scroll amt
+ lda $00 : cmp $02 : bne +
lda #$0000 : bra .next
+ !blt +
!sub $02 : inc $0e : bra .next
+ lda $02 : !sub $00
.next
sta $ab
jsr AdjustCameraBoundsY
pla : sta $00
sep #$30
lda $04 : sta $20
lda $00 : sta $21 : sta $0601 : sta $0605
lda $01 : sta $aa
lda $0e : asl : ora $ac : sta $ac
lda $e9 : and #$01 : asl #2 : tax : lda $0603, x : sta $e9
rts
LimitYCamera:
cmp #$006c : !bge +
lda #$0000 : bra .end
+ cmp #$017d : !blt +
lda #$0110 : bra .end
+ !sub #$006c
.end rts
CheckRoomLayoutY:
jsr LoadRoomLayout ;switches to 8-bit
cmp #$00 : beq .lock
cmp #$07 : beq .free
cmp #$01 : beq .free
cmp #$04 : !bge .lock
cmp #$02 : bne +
lda $06 : cmp #$ff : beq .lock
+ cmp #$03 : bne .free
lda $06 : cmp #$ff : bne .lock
.free rep #$30 : clc : rts
.lock rep #$30 : sec : rts
AdjustCameraBoundsY:
jsr CheckRoomLayoutY : bcc .free
; layouts that are camera locked (quads only)
lda $04 : and #$00ff : cmp #$007d : !blt +
lda #$0088 : bra ++
+ cmp #$006d : !bge +
lda #$0078 : bra ++
+ !add #$000b
; I think we no longer need the $02 variable
++ sta $02 : lda $04 : and #$0100 : !add $02 : bra .setBounds
; layouts where the camera is free
.free lda $04 : cmp #$006c : !bge +
lda #$0077 : bra .setBounds
+ cmp #$017c : !blt +
lda #$0187 : bra .setBounds
+ !add #$000b
.setBounds sta $0618 : inc #2 : sta $061a
rts
LoadRoomLayout:
lda $a0 : asl : !add $a0 : tax
lda $1f8001, x : sta $b8
lda $1f8000, x : sta $b7
sep #$30
ldy #$01 : lda [$b7], y : and #$1c : lsr #2
rts
; expects target quad in $05 (either 0 or 1) and target pixel in $04, target room should be in $a0
; uses $00-$03 and $0e for calculation
; also set up $ac
ScrollX: ;change the X offset variables
lda $a0 : and.b #$0f : asl : sta $060b : inc : sta $060f
lda $05 : bne +
lda $60b : sta $00 : stz $01 : bra ++
+ lda $60f : sta $00 : lda #$01 : sta $01
++ ; $01 now contains 0 or 1 and $00 contains the correct long
stz $0e ; pos/neg indicator
rep #$30
lda $00 : pha
lda $e2 : and #$01ff : sta $02
lda $04 : jsr LimitXCamera : sta $00
jsr CheckRoomLayoutX : bcc +
lda $00 : cmp #$0080 : !bge ++
lda #$0000 : bra .cmpSrll
++ lda #$0100
.cmpSrll sta $00
;figures out scroll amt
+ lda $00 : cmp $02 : bne +
lda #$0000 : bra .next
+ !blt +
!sub $02 : inc $0e : bra .next
+ lda $02 : !sub $00
.next
sta $ab : lda $04
cmp #$0078 : !bge +
lda #$007f : bra ++
+ cmp #$0178 : !blt +
lda #$017f : bra ++
+ !add #$0007
++ sta $061c : inc #2 : sta $061e
pla : sta $00
sep #$30
lda $04 : sta $22
lda $00 : sta $23 : sta $0609 : sta $060d
lda $01 : sta $a9
lda $0e : asl : ora $ac : sta $ac
lda $e3 : and #$01 : asl #2 : tax : lda $060b, x : sta $e3
rts
LimitXCamera:
cmp #$0080 : !bge +
lda #$0000 : bra .end
+ cmp #$0181 : !blt +
lda #$0180
+ !sub #$0080
.end rts
CheckRoomLayoutX:
jsr LoadRoomLayout ;switches to 8-bit
cmp #$04 : !blt .lock
cmp #$05 : bne +
lda $06 : cmp #$ff : beq .lock
+ cmp #$06 : bne .free
lda $06 : cmp #$ff : bne .lock
.free rep #$30 : clc : rts
.lock rep #$30 : sec : rts
ApplyScroll:
rep #$30
lda $ab : and #$01ff : sta $00
lda $ab : and #$0200 : beq +
lda $00e2, y : !add $00 : bra .end
+ lda $00e2, y : !sub $00
.end
sta $00e2, y
sta $00e0, y
stz $ab : sep #$30 : rts

View File

@@ -1,7 +1,8 @@
RecordStairType: {
sta $a0
lda $0e : sta $045e
lda $063d, x
pha : lda DRMode : beq +
lda $0e : sta $045e : pla : bra .end
+ pla : sta $a0
.end lda $063d, x
rtl
}