mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-09-08 11:54:28 +00:00
Symmetric improvements to 2D API.
This commit is contained in:
parent
f0a53623b5
commit
7be0112be4
@ -1937,7 +1937,7 @@ __asmPlasm: !zone
|
|||||||
ldy evalStkH,x ; ...Y=hi
|
ldy evalStkH,x ; ...Y=hi
|
||||||
.jsr jsr $1111 ; call the routine to do work
|
.jsr jsr $1111 ; call the routine to do work
|
||||||
bit setLcRW+lcBank2 ; read from language card (where PLASMA runtime lives)
|
bit setLcRW+lcBank2 ; read from language card (where PLASMA runtime lives)
|
||||||
sta tmp ; save return value lo
|
sta tmp ; stash return value lo
|
||||||
pla
|
pla
|
||||||
tax ; restore adjusted PLASMA stack pointer
|
tax ; restore adjusted PLASMA stack pointer
|
||||||
lda tmp
|
lda tmp
|
||||||
|
@ -60,12 +60,12 @@ const FATAL_ERROR = $1F
|
|||||||
// Other constants
|
// Other constants
|
||||||
const callbacks = $300
|
const callbacks = $300
|
||||||
|
|
||||||
// 3D mode
|
// 3D map start
|
||||||
const OVERMAP_NUM = 11
|
//const OVERMAP_NUM = 11
|
||||||
const OVERMAP_IS_3D = 1
|
//const OVERMAP_IS_3D = 1
|
||||||
// 2D mode
|
// 2D map start
|
||||||
//const OVERMAP_NUM = 1
|
const OVERMAP_NUM = 1
|
||||||
//const OVERMAP_IS_3D = 0
|
const OVERMAP_IS_3D = 0
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Predefined functions, for circular calls or out-of-order calls
|
// Predefined functions, for circular calls or out-of-order calls
|
||||||
@ -807,6 +807,7 @@ def kbdTeleport()
|
|||||||
word x, y
|
word x, y
|
||||||
byte dir
|
byte dir
|
||||||
|
|
||||||
|
flipToPage1()
|
||||||
^$c053
|
^$c053
|
||||||
if ^$25 < 23; ^$25 = 23; fin
|
if ^$25 < 23; ^$25 = 23; fin
|
||||||
getPos(@x, @y)
|
getPos(@x, @y)
|
||||||
|
@ -600,6 +600,11 @@ CROSS_WEST
|
|||||||
JSR MainDraw
|
JSR MainDraw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
;----------------------------------------------------------------------
|
||||||
|
; >> pl_render
|
||||||
|
; Params: none; return: none
|
||||||
|
; Draw at the current position.
|
||||||
|
pl_render:
|
||||||
DRAW: LDA #0
|
DRAW: LDA #0
|
||||||
BEQ +
|
BEQ +
|
||||||
CALC: LDA #1
|
CALC: LDA #1
|
||||||
@ -916,7 +921,6 @@ FinishCalc
|
|||||||
; params: mapNum, pMapData, x, y, dir
|
; params: mapNum, pMapData, x, y, dir
|
||||||
pl_initMap: !zone
|
pl_initMap: !zone
|
||||||
STX PLASMA_X ; save PLASMA's eval stack pos
|
STX PLASMA_X ; save PLASMA's eval stack pos
|
||||||
BIT setROM ; switch out PLASMA while we work
|
|
||||||
|
|
||||||
; PLASMA code has already loaded the Northwest-most map section. Record its ID and address.
|
; PLASMA code has already loaded the Northwest-most map section. Record its ID and address.
|
||||||
LDA evalStkL+4,X
|
LDA evalStkL+4,X
|
||||||
@ -952,18 +956,12 @@ pl_initMap: !zone
|
|||||||
|
|
||||||
; The bullk of the work is taken care of by a helper function.
|
; The bullk of the work is taken care of by a helper function.
|
||||||
INX ; skip dir so that X/Y pos are at top of eval stack
|
INX ; skip dir so that X/Y pos are at top of eval stack
|
||||||
JSR SETPOS
|
JMP SETPOS
|
||||||
|
|
||||||
; all done
|
|
||||||
BIT setLcRW+lcBank2 ; switch PLASMA runtime back in
|
|
||||||
LDX PLASMA_X ; restore PLASMA's eval stk pos
|
|
||||||
INX
|
|
||||||
INX ; toss 4 slots (params=5, ret=1, diff=4)
|
|
||||||
INX
|
|
||||||
INX
|
|
||||||
RTS
|
|
||||||
|
|
||||||
;----------------------------------------------------------------------
|
;----------------------------------------------------------------------
|
||||||
|
; >> pl_setPos
|
||||||
|
; Params: X, Y
|
||||||
|
pl_setPos:
|
||||||
SETPOS:
|
SETPOS:
|
||||||
; Figure out which map sections we need to load.
|
; Figure out which map sections we need to load.
|
||||||
; We can temporarily use the DRAW_* variables for our work here, since
|
; We can temporarily use the DRAW_* variables for our work here, since
|
||||||
@ -1148,42 +1146,24 @@ SETPOS:
|
|||||||
; >> pl_flipToPage1
|
; >> pl_flipToPage1
|
||||||
; No-op, because in 2D we don't use hi-res page 2
|
; No-op, because in 2D we don't use hi-res page 2
|
||||||
pl_flipToPage1:
|
pl_flipToPage1:
|
||||||
dex ; no-op still needs a return slot (0 param - 1 ret = -1)
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
;----------------------------------------------------------------------
|
;----------------------------------------------------------------------
|
||||||
; >> pl_setColor
|
; >> pl_setColor
|
||||||
; No-op, because in 2D we don't have sky and ground colors
|
; No-op, because in 2D we don't have sky and ground colors
|
||||||
pl_setColor:
|
pl_setColor:
|
||||||
rts ; no need to mess with X: 1 param - 1 ret = 0
|
rts
|
||||||
|
|
||||||
;----------------------------------------------------------------------
|
|
||||||
; >> pl_setPos
|
|
||||||
; Params: X, Y
|
|
||||||
pl_setPos:
|
|
||||||
TXA
|
|
||||||
PHA ; save PLASMA eval stk pos
|
|
||||||
BIT setROM ; switch out PLASMA while we work
|
|
||||||
JSR SETPOS ; bulk of the work done by a helper function
|
|
||||||
BIT setLcRW+lcBank2 ; switch PLASMA runtime back in
|
|
||||||
PLA ; restore PLASMA's eval stk pos
|
|
||||||
TAX
|
|
||||||
INX ; toss 1 slot (params=2, ret=0, diff=2)
|
|
||||||
INX
|
|
||||||
RTS
|
|
||||||
|
|
||||||
;----------------------------------------------------------------------
|
;----------------------------------------------------------------------
|
||||||
; >> pl_getPos
|
; >> pl_getPos
|
||||||
; Params: @X, @Y
|
; Params: @X, @Y
|
||||||
pl_getPos: !zone {
|
pl_getPos: !zone {
|
||||||
!if DEBUG {
|
!if DEBUG {
|
||||||
BIT setROM
|
|
||||||
+prStr : !text "O_X=",0 : +prWord ORIGIN_X
|
+prStr : !text "O_X=",0 : +prWord ORIGIN_X
|
||||||
+prStr : !text "R_X=",0 : +prByte REL_X
|
+prStr : !text "R_X=",0 : +prByte REL_X
|
||||||
+prStr : !text "O_Y=",0 : +prWord ORIGIN_Y
|
+prStr : !text "O_Y=",0 : +prWord ORIGIN_Y
|
||||||
+prStr : !text "R_Y=",0 : +prByte REL_Y
|
+prStr : !text "R_Y=",0 : +prByte REL_Y
|
||||||
+crout
|
+crout
|
||||||
BIT setLcRW+lcBank2
|
|
||||||
}
|
}
|
||||||
LDA ORIGIN_Y
|
LDA ORIGIN_Y
|
||||||
CLC
|
CLC
|
||||||
@ -1199,7 +1179,7 @@ pl_getPos: !zone {
|
|||||||
JSR .sto
|
JSR .sto
|
||||||
LDA ORIGIN_X+1
|
LDA ORIGIN_X+1
|
||||||
ADC #0
|
ADC #0
|
||||||
JMP .sto2 ; Note: total X incr: 1 (2 parms - 1 ret = 1)
|
JMP .sto2
|
||||||
.sto LDY evalStkL,X ; lo byte of address
|
.sto LDY evalStkL,X ; lo byte of address
|
||||||
STY .sto2+1
|
STY .sto2+1
|
||||||
LDY evalStkH,X ; hi byte of address
|
LDY evalStkH,X ; hi byte of address
|
||||||
@ -1217,10 +1197,7 @@ pl_getDir:
|
|||||||
LDA AVATAR_DIR ; take our 0..3
|
LDA AVATAR_DIR ; take our 0..3
|
||||||
ASL ; and translate
|
ASL ; and translate
|
||||||
ASL ; to 0..15
|
ASL ; to 0..15
|
||||||
DEX ; make a place for it on eval stk
|
LDY #0
|
||||||
STA evalStkL,X ; and save it
|
|
||||||
LDA #0
|
|
||||||
STA evalStkH,X
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
;----------------------------------------------------------------------
|
;----------------------------------------------------------------------
|
||||||
@ -1279,7 +1256,12 @@ INNER_ADVANCE: !zone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
;----------------------------------------------------------------------
|
;----------------------------------------------------------------------
|
||||||
ADVANCE: !zone {
|
; >> pl_advance
|
||||||
|
; Params: none; return: 0 if blocked, 1 if same, 2 if new map tile, 3 if new and scripted
|
||||||
|
; Advance in the current direction
|
||||||
|
pl_advance: !zone {
|
||||||
|
STX PLASMA_X ; save PLASMA eval stk pos
|
||||||
|
|
||||||
LDA REL_X ; save X
|
LDA REL_X ; save X
|
||||||
PHA
|
PHA
|
||||||
LDA REL_Y ; and save Y
|
LDA REL_Y ; and save Y
|
||||||
@ -1311,50 +1293,13 @@ ADVANCE: !zone {
|
|||||||
EOR REL_X
|
EOR REL_X
|
||||||
.or ORA #11 ; self-modified above
|
.or ORA #11 ; self-modified above
|
||||||
BEQ .ret
|
BEQ .ret
|
||||||
INY ; moved
|
LDY #2 ; moved, so return at least 2.
|
||||||
LDA AVATAR_TILE
|
LDA AVATAR_TILE
|
||||||
AND #$40 ; check script flag
|
AND #$40 ; check script flag
|
||||||
BEQ .ret
|
BEQ .ret
|
||||||
INY ; moved and also new place is scripted
|
INY ; moved and also new place is scripted, return 3.
|
||||||
.ret RTS
|
.ret TYA
|
||||||
}
|
LDY #0 ; hi byte of return always zero
|
||||||
|
|
||||||
;----------------------------------------------------------------------
|
|
||||||
; >> pl_advance
|
|
||||||
; Params: none; return: 0 if same, 1 if new map tile, 2 if new and scripted
|
|
||||||
; Advance in the current direction
|
|
||||||
pl_advance: !zone {
|
|
||||||
STX PLASMA_X ; save PLASMA eval stk pos
|
|
||||||
BIT setROM ; switch out PLASMA while we work
|
|
||||||
|
|
||||||
JSR ADVANCE ; most of the work done by helper function
|
|
||||||
TYA
|
|
||||||
PHA
|
|
||||||
JSR DRAW
|
|
||||||
PLA
|
|
||||||
TAY
|
|
||||||
|
|
||||||
BIT setLcRW+lcBank2 ; switch PLASMA runtime back in
|
|
||||||
LDX PLASMA_X ; restore PLASMA's eval stk pos
|
|
||||||
DEX ; make room for ret val (params=0, ret=1, diff=-1)
|
|
||||||
TYA ; get ret val
|
|
||||||
STA evalStkL,X ; and save it
|
|
||||||
LDA #0 ; hi byte of ret val
|
|
||||||
STA evalStkH,X ; is always zero
|
|
||||||
RTS
|
|
||||||
}
|
|
||||||
|
|
||||||
;----------------------------------------------------------------------
|
|
||||||
; >> pl_render
|
|
||||||
; Params: none; return: none
|
|
||||||
; Draw at the current position.
|
|
||||||
pl_render: !zone {
|
|
||||||
STX PLASMA_X ; save PLASMA eval stk pos
|
|
||||||
BIT setROM ; switch out PLASMA while we work
|
|
||||||
|
|
||||||
JSR DRAW
|
|
||||||
|
|
||||||
BIT setLcRW+lcBank2 ; switch PLASMA runtime back in
|
|
||||||
RTS
|
RTS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user