first edge function
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
!add = "clc : adc"
|
||||
!sub = "sec : sbc"
|
||||
!bge = "bcs"
|
||||
!blt = "bcc"
|
||||
|
||||
; Free RAM notes
|
||||
; Normal doors use $FE for scrolling indicator
|
||||
@@ -17,6 +19,7 @@ incsrc spiral.asm
|
||||
incsrc gfx.asm
|
||||
incsrc keydoors.asm
|
||||
incsrc overrides.asm
|
||||
incsrc edges.asm
|
||||
warnpc $279000
|
||||
|
||||
; Data Section
|
||||
|
||||
@@ -493,21 +493,21 @@ dw $ffff ; indicates the end - we can drop this
|
||||
; Edge Transition Table
|
||||
org $27C500 ;ends around 27C5F0
|
||||
NorthOpenEdge:
|
||||
db $80,$00,$11, $80,$00,$11, $80,$00,$11, $80,$00,$11
|
||||
db $80,$00,$11, $80,$00,$11, $80,$00,$11, $80,$00,$11
|
||||
db $80,$00,$11, $80,$00,$11, $80,$00,$11
|
||||
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 $80,$00,$11, $80,$00,$11, $80,$00,$11, $80,$00,$11
|
||||
db $80,$00,$11, $80,$00,$11, $80,$00,$11, $80,$00,$11
|
||||
db $80,$00,$11, $80,$00,$11, $80,$00,$11
|
||||
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
|
||||
WestOpenEdge:
|
||||
db $80,$00,$11, $80,$00,$11, $80,$00,$11
|
||||
db $80,$00,$11, $80,$00,$11, $80,$00,$11
|
||||
db $80,$00,$11, $80,$00,$11, $80,$00,$11
|
||||
db $00,$80,$11, $00,$80,$11, $00,$80,$11
|
||||
db $00,$80,$11, $00,$80,$11, $00,$80,$11
|
||||
db $00,$80,$11, $00,$80,$11, $00,$80,$11
|
||||
EastOpenEdge:
|
||||
db $80,$00,$11, $80,$00,$11, $80,$00,$11
|
||||
db $80,$00,$11, $80,$00,$11, $80,$00,$11
|
||||
db $80,$00,$11, $80,$00,$11, $80,$00,$11
|
||||
db $00,$80,$11, $00,$80,$11, $00,$80,$11
|
||||
db $00,$80,$11, $00,$80,$11, $00,$80,$11
|
||||
db $00,$80,$11, $00,$80,$11, $00,$80,$11
|
||||
; Edge Info Table (Midpoint, Width, Min Coord)
|
||||
NorthEdgeInfo:
|
||||
db $a8,$10,$a0, $2c,$08,$28 ;HC
|
||||
|
||||
228
asm/edges.asm
228
asm/edges.asm
@@ -0,0 +1,228 @@
|
||||
HorzEdge:
|
||||
cpy #$ff : beq +
|
||||
jsr DetectWestEdge : bra ++
|
||||
+ jsr DetectEastEdge
|
||||
++ cmp #$ff : beq +
|
||||
sta $00 : asl : !add $00: tax
|
||||
cpy #$ff : beq ++
|
||||
jsr LoadWestData : bra .main
|
||||
++ jsr LoadEastData
|
||||
.main
|
||||
jsr LoadEdgeRoomHorz
|
||||
sec : rts
|
||||
+ clc : rts
|
||||
|
||||
VertEdge:
|
||||
cpy #$ff : beq +
|
||||
jsr DetectNorthEdge : bra ++
|
||||
+ jsr DetectSouthEdge
|
||||
++ cmp #$ff : beq +
|
||||
sta $00 : asl : !add $00 : tax
|
||||
cpy #$ff : beq ++
|
||||
jsr LoadNorthData : bra .main
|
||||
++ jsr LoadSouthData
|
||||
.main
|
||||
; todo: work to do
|
||||
sec : rts
|
||||
+ clc : rts
|
||||
|
||||
; todo: LoadVert
|
||||
; todo: FixAdjustTrans
|
||||
; todo: Fix ab fe swap in normal
|
||||
|
||||
LoadEdgeRoomHorz:
|
||||
lda $03 : sta $a0
|
||||
sty $09
|
||||
and.b #$0f : asl a : !sub $23 : !add $09 : sta $02
|
||||
ldy #$00 : jsr ShiftVariablesMainDir
|
||||
lda $a0 : and.b #$F0 : lsr #3 : sta $0603 : inc : sta $0607
|
||||
|
||||
|
||||
lda $04 : and #$40 : bne +
|
||||
lda $603 : sta $00 : stz $01 : bra ++
|
||||
+ lda $607 : sta $00 : lda #$02 : sta $01
|
||||
++
|
||||
lda $00 : sta $21 : sta $0601 : sta $0605
|
||||
lda $01 : sta $aa : lsr : sta $01 : stz $00
|
||||
|
||||
stz $0e
|
||||
rep #$30
|
||||
lda $e8 : sta $02
|
||||
lda $06 : and #$00ff : !add $00 : sta $00
|
||||
|
||||
cmp #$006c : !bge +
|
||||
lda #$0077 : bra ++
|
||||
+ cmp #$017c : !blt +
|
||||
lda #$0187 : bra ++
|
||||
+ !add #$000b
|
||||
++ sta $0618 : inc #2 : sta $061a
|
||||
|
||||
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 : bra .done
|
||||
+ lda $02 : !sub $00 : inc $0e
|
||||
|
||||
.done sta $ab : sep #$30
|
||||
lda $0e : asl : ora $ac : sta $ac
|
||||
lda $0601 : sta $e9
|
||||
|
||||
lda $04 : and #$80 : 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
|
||||
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
|
||||
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
|
||||
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
|
||||
rts
|
||||
|
||||
|
||||
DetectNorthEdge:
|
||||
ldx #$ff
|
||||
lda $a2
|
||||
cmp #$82 : bne +
|
||||
lda $22 : cmp #$50 : bcs ++
|
||||
ldx #$01 : bra .end
|
||||
++ ldx #$00 : bra .end
|
||||
+ cmp #$83 : bne +
|
||||
ldx #$02 : bra .end
|
||||
+ cmp #$84 : bne +
|
||||
lda $a9 : beq ++
|
||||
lda $22 : cmp #$78 : bcs +++
|
||||
ldx #$04 : bra .end
|
||||
+++ ldx #$05 : bra .end
|
||||
++ lda $22 : cmp #$78 : bcs ++
|
||||
ldx #$03 : bra .end
|
||||
++ ldx #$04 : bra .end
|
||||
+ cmp #$85 : bne +
|
||||
ldx #$06 : bra .end
|
||||
+ cmp #$db : bne +
|
||||
lda $a9 : beq ++
|
||||
lda $22 : beq ++
|
||||
ldx #$08 : bra .end
|
||||
++ ldx #$07 : bra .end
|
||||
+ cmp #$dc : bne .end
|
||||
lda $a9 : bne ++
|
||||
lda $22 : bcs #$b0 : bcs ++
|
||||
ldx #$09 : bra .end
|
||||
++ ldx #$0a
|
||||
.end txa : rts
|
||||
|
||||
DetectSouthEdge:
|
||||
ldx #$ff
|
||||
lda $a2
|
||||
cmp #$72 : bne +
|
||||
lda $22 : cmp #$50 : bcs ++
|
||||
ldx #$01 : bra .end
|
||||
++ ldx #$00 : bra .end
|
||||
+ cmp #$73 : bne +
|
||||
ldx #$02 : bra .end
|
||||
+ cmp #$74 : bne +
|
||||
lda $a9 : beq ++
|
||||
lda $22 : cmp #$78 : bcs +++
|
||||
ldx #$04 : bra .end
|
||||
+++ ldx #$05 : bra .end
|
||||
++ lda $22 : cmp #$78 : bcs ++
|
||||
ldx #$03 : bra .end
|
||||
++ ldx #$04 : bra .end
|
||||
+ cmp #$75 : bne +
|
||||
ldx #$06 : bra .end
|
||||
+ cmp #$cb : bne +
|
||||
lda $a9 : beq ++
|
||||
lda $22 : beq ++
|
||||
ldx #$08 : bra .end
|
||||
++ ldx #$07 : bra .end
|
||||
+ cmp #$cc : bne .end
|
||||
lda $a9 : bne ++
|
||||
lda $22 : bcs #$b0 : bcs ++
|
||||
ldx #$09 : bra .end
|
||||
++ ldx #$0a
|
||||
.end txa : rts
|
||||
|
||||
DetectWestEdge:
|
||||
ldx #$ff
|
||||
lda $a2
|
||||
cmp #$65 : bne +
|
||||
ldx #$00 : bra .end
|
||||
+ cmp #$74 : bne +
|
||||
ldx #$01 : bra .end
|
||||
+ cmp #$75 : bne +
|
||||
ldx #$02 : bra .end
|
||||
+ cmp #$82 : bne +
|
||||
lda $aa : beq ++
|
||||
ldx #$03 : bra .end
|
||||
++ ldx #$04 : bra .end
|
||||
+ cmp #$85 : bne +
|
||||
ldx #$05 : bra .end
|
||||
+ cmp #$cc : bne +
|
||||
lda $aa : beq ++
|
||||
ldx #$07 : bra .end
|
||||
++ ldx #$06 : bra .end
|
||||
+ cmp #$dc : bne .end
|
||||
ldx #$08
|
||||
.end txa : rts
|
||||
|
||||
DetectEastEdge:
|
||||
ldx #$ff
|
||||
lda $a2
|
||||
cmp #$64 : bne +
|
||||
ldx #$00 : bra .end
|
||||
+ cmp #$73 : bne +
|
||||
ldx #$01 : bra .end
|
||||
+ cmp #$74 : bne +
|
||||
ldx #$02 : bra .end
|
||||
+ cmp #$81 : bne +
|
||||
lda $aa : beq ++
|
||||
ldx #$04 : bra .end
|
||||
++ ldx #$03 : bra .end
|
||||
+ cmp #$84 : bne +
|
||||
ldx #$05 : bra .end
|
||||
+ cmp #$cb : bne +
|
||||
lda $aa : beq ++
|
||||
ldx #$07 : bra .end
|
||||
++ ldx #$06 : bra .end
|
||||
+ cmp #$db : bne .end
|
||||
ldx #$08
|
||||
.end txa : rts
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
WarpLeft:
|
||||
lda DRMode : beq .end
|
||||
lda $040c : cmp.b #$ff : beq .end
|
||||
lda $20 : ldx $aa
|
||||
jsr CalcIndex
|
||||
@@ -9,6 +10,7 @@ WarpLeft:
|
||||
rtl
|
||||
|
||||
WarpRight:
|
||||
lda DRMode : beq .end
|
||||
lda $040c : cmp.b #$ff : beq .end
|
||||
lda $20 : ldx $aa
|
||||
jsr CalcIndex
|
||||
@@ -19,6 +21,7 @@ WarpRight:
|
||||
rtl
|
||||
|
||||
WarpUp:
|
||||
lda DRMode : beq .end
|
||||
lda $040c : cmp.b #$ff : beq .end
|
||||
lda $22 : ldx $a9
|
||||
jsr CalcIndex
|
||||
@@ -29,6 +32,7 @@ WarpUp:
|
||||
rtl
|
||||
|
||||
WarpDown:
|
||||
lda DRMode : beq .end
|
||||
lda $040c : cmp.b #$ff : beq .end
|
||||
lda $22 : ldx $a9
|
||||
jsr CalcIndex
|
||||
@@ -39,11 +43,11 @@ WarpDown:
|
||||
rtl
|
||||
|
||||
TrapDoorFixer:
|
||||
lda $ab : and #$0038 : beq .end
|
||||
lda $fe : and #$0038 : beq .end
|
||||
xba : asl #2 : sta $00
|
||||
stz $0468 : lda $068c : ora $00 : sta $068c
|
||||
.end
|
||||
stz $ab ; clear our ab here because we don't need it anymore
|
||||
stz $fe ; clear our ab here because we don't need it anymore
|
||||
rts
|
||||
|
||||
Cleanup:
|
||||
@@ -72,7 +76,8 @@ LoadRoomHorz:
|
||||
sty $06 : sta $07 : lda $a0 : pha ; Store normal room on stack
|
||||
lda $07 : jsr LookupNewRoom ; New room is in A, Room Data is in $00
|
||||
lda $01 : and.b #$80 : cmp #$80 : bne .gtg
|
||||
pla : sta $a0 : bra .end ; Restore normal room, abort (straight staircases and open edges can get in this routine)
|
||||
jsr HorzEdge : pla : bcs .end
|
||||
sta $a0 : bra .end ; Restore normal room, abort (straight staircases and open edges can get in this routine)
|
||||
|
||||
.gtg ;Good to Go!
|
||||
pla ; Throw away normal room (don't fill up the stack)
|
||||
@@ -84,7 +89,7 @@ LoadRoomHorz:
|
||||
jsr ShiftQuad
|
||||
jsr ShiftCameraBounds
|
||||
ldy #$01 : jsr ShiftVariablesSubDir ; flip direction
|
||||
lda $01 : sta $ab : and #$04 : lsr #2
|
||||
lda $01 : sta $fe : and #$04 : lsr #2
|
||||
sta $ee
|
||||
lda $01 : and #$10 : beq .end : stz $0468
|
||||
.end
|
||||
@@ -100,8 +105,8 @@ LoadRoomVert:
|
||||
sty $06 : sta $07 : lda $a0 : pha ; Store normal room on stack
|
||||
lda $07 : jsr LookupNewRoom ; New room is in A, Room Data is in $00
|
||||
lda $01 : and.b #$80 : cmp #$80 : bne .gtg
|
||||
pla : sta $a0 : bra .end ; Restore normal room, abort (straight staircases and open edges can get in this routine)
|
||||
|
||||
jsr VertEdge : pla : bcs .end
|
||||
sta $a0 : bra .end ; Restore normal room, abort (straight staircases and open edges can get in this routine)
|
||||
.gtg ;Good to Go!
|
||||
pla ; Throw away normal room (don't fill up the stack)
|
||||
lda $a0 : and.b #$F0 : lsr #3 : !sub $21 : !add $06 : sta $02
|
||||
@@ -111,7 +116,7 @@ LoadRoomVert:
|
||||
jsr ShiftQuad
|
||||
jsr ShiftCameraBounds
|
||||
ldy #$00 : jsr ShiftVariablesSubDir ; flip direction
|
||||
lda $01 : sta $ab : and #$04 : lsr #2
|
||||
lda $01 : sta $fe : and #$04 : lsr #2
|
||||
sta $ee
|
||||
.end
|
||||
plb ; restore db register
|
||||
@@ -132,7 +137,7 @@ LookupNewRoom: ; expects data offset to be in A
|
||||
rts
|
||||
}
|
||||
|
||||
; INPUTS-- X: Direction Index , $02: Shift Value
|
||||
; INPUTS-- Y: Direction Index , $02: Shift Value
|
||||
; Sets high bytes of various registers
|
||||
ShiftVariablesMainDir:
|
||||
{
|
||||
@@ -249,7 +254,7 @@ AdjustTransition:
|
||||
lda $fe : and #$0001 : asl : tax
|
||||
lda.l OffsetTable,x : adc $00E2,y : and.w #$FFFE : sta $00E2,y : sta $00E0,y
|
||||
ply : bra .done
|
||||
.reset ; clear the 0127 variable so to not disturb intra-tile doors
|
||||
.reset ; clear the $ab variable so to not disturb intra-tile doors
|
||||
stz $fe
|
||||
.done
|
||||
rep #$20 : lda $00 : and #$01fc
|
||||
|
||||
Reference in New Issue
Block a user