Tested a lot of north edges

This commit is contained in:
aerinon
2020-02-19 12:50:37 -07:00
parent b76a5f954d
commit 6f3040415d
5 changed files with 202 additions and 61 deletions

View File

@@ -4,8 +4,8 @@
!blt = "bcc"
; Free RAM notes
; Normal doors use $FE for scrolling indicator
; Normal doors use $AB to store the trap door indicator
; Normal doors use $AB-AC for scrolling indicator
; Normal doors use $FE to store the trap door indicator
; Spiral doors use $045e to store stair type
; Gfx uses $b1 to for sub-sub-sub-module thing
@@ -20,6 +20,7 @@ incsrc gfx.asm
incsrc keydoors.asm
incsrc overrides.asm
incsrc edges.asm
incsrc math.asm
warnpc $279000
; Data Section

View File

@@ -497,7 +497,7 @@ db $00,$80,$11, $00,$80,$11, $00,$80,$11, $00,$80,$11
db $00,$80,$11, $00,$80,$11, $00,$80,$11, $00,$80,$11
db $00,$80,$11, $00,$80,$11, $00,$80,$11
SouthOpenEdge:
db $00,$80,$11, $00,$80,$11, $00,$80,$11, $00,$80,$11
db $83,$a2,$11, $00,$80,$11, $00,$80,$11, $00,$80,$11
db $00,$80,$11, $00,$80,$11, $00,$80,$11, $00,$80,$11
db $00,$80,$11, $00,$80,$11, $00,$80,$11
WestOpenEdge:
@@ -538,4 +538,6 @@ db $40,$20,$30 ; DP North Hall
db $68,$10,$60, $84,$18,$78 ; HC Guards
db $a0,$a0,$50 ; DP Main Lobby
db $58,$50,$30, $98,$50,$70 ; TT Ambush
db $58,$50,$30 ; TT Nook
db $58,$50,$30 ; TT Nook
MultDivInfo: ; (1placeholder, 1, 2, 3, 4, 5, 6, 10, 20)
db $01, $01, $02, $03, $04, $05, $06, $0a, $14

View File

@@ -3,7 +3,7 @@ HorzEdge:
jsr DetectWestEdge : bra ++
+ jsr DetectEastEdge
++ cmp #$ff : beq +
sta $00 : asl : !add $00: tax
sta $00 : asl : !add $00 : tax
cpy #$ff : beq ++
jsr LoadWestData : bra .main
++ jsr LoadEastData
@@ -22,14 +22,10 @@ VertEdge:
jsr LoadNorthData : bra .main
++ jsr LoadSouthData
.main
; todo: work to do
jsr LoadEdgeRoomVert
sec : rts
+ clc : rts
; todo: LoadVert
; todo: FixAdjustTrans
; todo: Fix ab fe swap in normal
LoadEdgeRoomHorz:
lda $03 : sta $a0
sty $09
@@ -44,11 +40,12 @@ LoadEdgeRoomHorz:
++
lda $00 : sta $21 : sta $0601 : sta $0605
lda $01 : sta $aa : lsr : sta $01 : stz $00
lda $0a : sta $20
stz $0e
rep #$30
lda $e8 : sta $02
lda $06 : and #$00ff : !add $00 : sta $00
lda $e8 : and #$01ff : sta $02
lda $0a : and #$00ff : !add $00 : sta $00
cmp #$006c : !bge +
lda #$0077 : bra ++
@@ -68,51 +65,116 @@ LoadEdgeRoomHorz:
cmp $02 : bne +
lda #$0000 : bra .done
+ !blt +
!sub $02 : bra .done
+ lda $02 : !sub $00 : inc $0e
!sub $02 : inc $0e : bra .done
+ lda $02 : !sub $00
.done sta $ab : sep #$30
lda $0e : asl : ora $ac : sta $ac
lda $0601 : sta $e9
lda $0603 : sta $e9
lda $04 : and #$80 : lsr #4 : sta $ee ; layer stuff
rts
LoadEdgeRoomVert:
lda $03 : sta $a0
sty $09
and.b #$f0 : lsr #3 : !sub $21 : !add $09 : sta $02
ldy #$01 : jsr ShiftVariablesMainDir
lda $a0 : and.b #$0f : asl : sta $060b : inc : sta $060f
lda $04 : and #$20 : bne +
lda $60b : sta $00 : stz $01 : bra ++
+ lda $60f : sta $00 : lda #$01 : sta $01
++ ; $01 now contains 0 or 1
lda $00 : sta $23 : sta $0609 : sta $060d
lda $01 : sta $a9 : stz $00 ; setup for 16 bit ops
lda $0a : sta $22
stz $0e ; pos/neg indicator
rep #$30
lda $e2 : and #$01ff : sta $02
lda $0a : and #$00ff : !add $00 : sta $00
cmp #$0078 : !bge +
lda #$007f : bra ++
+ cmp #$0178 : !blt +
lda #$017f : bra ++
+ !add #$0007
++ sta $061c : inc #2 : sta $061e
lda $00 : cmp #$0078 : !bge +
lda #$0000 : bra ++
+ cmp #$0178 : !blt +
lda #$0100 : bra ++
+ !sub #$0078
++ sta $00
; figures out scroll amt
cmp $02 : bne +
lda #$0000 : bra .done
+ !blt +
!sub $02 : inc $0e : bra .done
+ lda $02 : !sub $00
.done sta $ab : sep #$30
lda $0e : asl : ora $ac : sta $ac
lda $060b : sta $e3
lda $04 : and #$10 : lsr #4 : sta $ee ; layer stuff
rts
LoadNorthData:
lda NorthEdgeInfo x, sta $06
lda NorthEdgeInfo x+1, sta $07
lda NorthEdgeInfo x+2, sta $08
lda NorthOpenEdge x, sta $03
lda NorthOpenEdge x+1, sta $04
lda NorthOpenEdge x+2, sta $05
lda NorthEdgeInfo, x : sta $06 ; not needed I think
lda NorthOpenEdge, x : sta $03 : inx
lda NorthEdgeInfo, x : sta $07 ;probably needed for maths - unsure
lda NorthOpenEdge, x : sta $04 : inx
lda NorthEdgeInfo, x : sta $08 ; needed for maths
lda NorthOpenEdge, x : sta $05
lda $04 : and #$0f : sta $00 : asl : !add $00 : tax
lda SouthEdgeInfo, x : sta $0a : inx ; needed now, and for nrml transition
lda SouthEdgeInfo, x : sta $0b : inx ; probably not needed - unsure
lda SouthEdgeInfo, x : sta $0c ; needed for maths
rts
LoadSouthData:
lda SouthEdgeInfo x, sta $06
lda SouthEdgeInfo x+1, sta $07
lda SouthEdgeInfo x+2, sta $08
lda SouthOpenEdge x, sta $03
lda SouthOpenEdge x+1, sta $04
lda SouthOpenEdge x+2, sta $05
lda SouthEdgeInfo, x : sta $06
lda SouthOpenEdge, x : sta $03 : inx
lda SouthEdgeInfo, x : sta $07
lda SouthOpenEdge, x : sta $04 : inx
lda SouthEdgeInfo, x : sta $08
lda SouthOpenEdge, x : sta $05
lda $04 : and #$0f : sta $00 : asl : !add $00 : tax
lda NorthEdgeInfo, x : sta $0a : inx
lda NorthEdgeInfo, x : sta $0b : inx
lda NorthEdgeInfo, x : sta $0c
rts
LoadWestData:
lda WestEdgeInfo x, sta $06
lda WestEdgeInfo x+1, sta $07
lda WestEdgeInfo x+2, sta $08
lda WestOpenEdge x, sta $03
lda WestOpenEdge x+1, sta $04
lda WestOpenEdge x+2, sta $05
lda WestEdgeInfo, x : sta $06
lda WestOpenEdge, x : sta $03 : inx
lda WestEdgeInfo, x : sta $07
lda WestOpenEdge, x : sta $04 : inx
lda WestEdgeInfo, x : sta $08
lda WestOpenEdge, x : sta $05
lda $04 : and #$0f : sta $00 : asl : !add $00 : tax
lda EastEdgeInfo, x : sta $0a : inx
lda EastEdgeInfo, x : sta $0b : inx
lda EastEdgeInfo, x : sta $0c
rts
LoadEastData:
lda EastEdgeInfo x, sta $06
lda EastEdgeInfo x+1, sta $07
lda EastEdgeInfo x+2, sta $08
lda EastOpenEdge x, sta $03
lda EastOpenEdge x+1, sta $04
lda EastOpenEdge x+2, sta $05
lda EastEdgeInfo, x : sta $06
lda EastOpenEdge, x : sta $03 : inx
lda EastEdgeInfo, x : sta $07
lda EastOpenEdge, x : sta $04 : inx
lda EastEdgeInfo, x : sta $08
lda EastOpenEdge, x : sta $05
lda $04 : and #$0f : sta $00 : asl : !add $00 : tax
lda WestEdgeInfo, x : sta $0a : inx
lda WestEdgeInfo, x : sta $0b : inx
lda WestEdgeInfo, x : sta $0c
rts
@@ -142,7 +204,7 @@ DetectNorthEdge:
++ ldx #$07 : bra .end
+ cmp #$dc : bne .end
lda $a9 : bne ++
lda $22 : bcs #$b0 : bcs ++
lda $22 : cmp #$b0 : bcs ++
ldx #$09 : bra .end
++ ldx #$0a
.end txa : rts
@@ -173,7 +235,7 @@ DetectSouthEdge:
++ ldx #$07 : bra .end
+ cmp #$cc : bne .end
lda $a9 : bne ++
lda $22 : bcs #$b0 : bcs ++
lda $22 : cmp #$b0 : bcs ++
ldx #$09 : bra .end
++ ldx #$0a
.end txa : rts

61
asm/math.asm Normal file
View File

@@ -0,0 +1,61 @@
;divide by 2 example
; 0 1 2 3 4 5 6 7 8 9 a b c d e f 10--Offset Ruler
;v 00 01 01 02 02 03 03 04 04 04 05 05 06 06 07 07 08
;divide by 3 example
; 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13 14 15 16 17 18
;00 00 01 01 01 02 02 02 03 03 03 04 04 04 05 05 05 06 06 06 07 07 07 08 08
MultiplyByY:
.loop cpy #$0001 : beq .done
cpy #$0003 : bne ++
jsr MultiBy3 : bra .done
++ cpy #$0005 : bne ++
jsr MultiBy5 : bra .done
++ asl : sta $00 : tya : lsr : tay : lda $00 : bra .loop
.done rts
;todo -- width in X?
DivideByY:
.loop cpy #$0001 : beq .done
cpy #$0003 : bne ++
jsr DivideBy3 : bra .done
++ cpy #$0005 : bne ++
jsr DivideBy5 : bra .done
; todo -- alter - width
++ tyx : jsr DivideBy2 : sta $00 : tya : lsr : tay : lda $00 : bra .loop
.done rts
MultiBy3:
sta $00 : asl : !add $00
rts
MultiBy5:
sta $00 : asl #2 : !add $00
rts
;width of divison in x
DivideBy2:
sta $00
lsr : bcc .done
sta $02 : txa : lsr : cmp $00 : !bge .done
lda $02 : inc
.done rts
DivideBy3:
sta $00
ldx #$0000
lda #$0002
.loop cmp $00 : !bge .store
inx : !add #$0003 : bra .loop
.store txa
rts
DivideBy5:
sta $00
ldx #$0000
lda #$0003
.loop cmp $00 : !bge .store
inx : !add #$0005 : bra .loop
.store txa
rts

View File

@@ -89,6 +89,7 @@ LoadRoomHorz:
jsr ShiftQuad
jsr ShiftCameraBounds
ldy #$01 : jsr ShiftVariablesSubDir ; flip direction
jsr SetupScrollIndicator
lda $01 : sta $fe : and #$04 : lsr #2
sta $ee
lda $01 : and #$10 : beq .end : stz $0468
@@ -116,6 +117,7 @@ LoadRoomVert:
jsr ShiftQuad
jsr ShiftCameraBounds
ldy #$00 : jsr ShiftVariablesSubDir ; flip direction
jsr SetupScrollIndicator
lda $01 : sta $fe : and #$04 : lsr #2
sta $ee
.end
@@ -123,6 +125,12 @@ LoadRoomVert:
rts
}
SetupScrollIndicator:
lda $ab : and #$01 : asl : sta $ac
lda $ab : and #$40 : clc : rol #3 : ora $ac : sta $ac
lda $ab : and #$20 : asl #2 : sta $ab
rts
LookupNewRoom: ; expects data offset to be in A
{
rep #$30 : and #$00FF ;sanitize A reg (who knows what is in the high byte)
@@ -157,7 +165,7 @@ ShiftLowCoord:
{
lda $01 : and.b #$03 ; high byte index
jsr CalcOpposingShift
lda $fe : and.b #$f0 : cmp.b #$20 : bne .lowDone
lda $ab : and.b #$f0 : cmp.b #$20 : bne .lowDone
lda OppCoordIndex,y : tax
lda #$80 : !add $20,x : sta $20,x
.lowDone
@@ -165,13 +173,13 @@ ShiftLowCoord:
}
; expects A to be (0,1,2) (dest number) and (0,1,2) (src door number) to be stored in $04
; $0127 will be set to a bitmask aaaa qxxf
; $ab will be set to a bitmask aaaa qxxf
; a - amount of adjust
; f - flag, if set, then amount is pos, otherwise neg.
; q - quadrant, if set, then quadrant needs to be modified
CalcOpposingShift:
{
stz $fe ; set up (can you zero out 127 alone?)
stz $ab : stz $ac ; set up
cmp.b $04 : beq .noOffset ; (equal, no shifts to do)
phy : tay ; reserve these
lda $04 : tax : tya : !sub $04 : sta $04 : cmp.b #$00 : bpl .shiftPos
@@ -179,8 +187,8 @@ CalcOpposingShift:
cpx.b #$01 : beq .skipNegQuad
ora #$08
.skipNegQuad
sta $fe : lda $04 : cmp.b #$FE : beq .done ;already set $0127
lda $fe : eor #$60
sta $ab : lda $04 : cmp.b #$FE : beq .done ;already set $ab
lda $ab : eor #$60
bra .setDone
.shiftPos
@@ -188,10 +196,10 @@ CalcOpposingShift:
cpy.b #$01 : beq .skipPosQuad
ora #$08
.skipPosQuad
sta $fe : lda $04 : cmp.b #$02 : bcs .done ;already set $0127
lda $fe : eor #$60
sta $ab : lda $04 : cmp.b #$02 : bcs .done ;already set $ab
lda $ab : eor #$60
.setDone sta $fe
.setDone sta $ab
.done ply
.noOffset rts
}
@@ -199,9 +207,9 @@ CalcOpposingShift:
ShiftQuad:
{
lda $fe : and #$08 : cmp.b #$00 : beq .quadDone
lda $ab : and #$08 : beq .quadDone
lda ShiftQuadIndex,y : tax ; X should be set to either 1 (vertical) or 2 (horizontal) (for a9,aa quadrant)
lda $fe : and #$01 : cmp.b #$00 : beq .decQuad
lda $ab : and #$01 : beq .decQuad
inc $02
txa : sta $a8, x ; alter a9/aa
bra .quadDone
@@ -229,8 +237,8 @@ ShiftCameraBounds:
{
lda CamBoundIndex,y : tax ; should be 0 for horz travel (vert bounds) or 4 for vert travel (horz bounds)
rep #$30
lda $fe : and #$00f0 : asl #2 : sta $06
lda $fe : and #$0001 : cmp #$0000 : beq .subIt
lda $ab : and #$00f0 : asl #2 : sta $06
lda $ab : and #$0001 : cmp #$0000 : beq .subIt
lda $0618, x : !add $06 : sta $0618, x
lda $061A, x : !add $06 : sta $061A, x
sep #$30
@@ -244,19 +252,26 @@ ShiftCameraBounds:
AdjustTransition:
{
lda $fe : and #$00f0 : lsr
sep #$20 : cmp $0126 : bcc .reset
rep #$20
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
lda $fe : and #$0001 : asl : tax
lda.l OffsetTable,x : adc $00E2,y : and.w #$FFFE : sta $00E2,y : sta $00E0,y
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 $fe
stz $ab
.done
rep #$20 : lda $00 : and #$01fc
lda $00 : and #$01fc
rtl
}
}
AdjustCamAdd:
!add $00E2,y : sta $00E2,y : sta $00E0,y : rts