Testing long-range teleport.

This commit is contained in:
Martin Haye 2015-05-03 09:25:57 -07:00
parent 4f093e405f
commit be7b8a0b70
3 changed files with 87 additions and 6 deletions

View File

@ -11,6 +11,7 @@ a2l = $3E
a2h = $3F
; Other monitor locations
inbuf = $200
resetVec = $3F2
; PRODOS

View File

@ -277,6 +277,16 @@ FATAL_ERROR = $1F
;------------------------------------------------------------------------------
; Convenience for writing assembly routines in PLASMA source
; Macro param: number of parameters passed from PLASMA routine
; 1. Save PLASMA's X register index
; 2. Switch to ROM
; 3. Load the last parameter (if any) into A=lo, Y=hi
; 4. Run the calling routine (X still points into evalStk for add'l params if needed)
; 5. Switch back to LC RAM
; 6. Restore PLASMA's X register, and advance it over the parameter(s), leaving
; space for the return value.
; 7. Store A=lo/Y=hi into PLASMA return value
; 8. Return to PLASMA
!macro asmPlasm nArgs {
ldy #nArgs
jsr _asmPlasm

View File

@ -248,6 +248,26 @@ asm beep
jmp bell
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Read a string from the keyboard, turn it into a PLASMA string and return a pointer to the string.
asm getstr
+asmPlasm 0
jsr getln1
txa
pha
beq +
- lda inbuf-1,x
and #$7F
sta inbuf,x
dex
bne -
+ pla
sta inbuf,x
lda #<inbuf
ldy #>inbuf
rts
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Send a command to the memory manager
// Params: cmd, mainOrAux, amount
@ -414,11 +434,13 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Print a signed decimal word
def printDec(n)
if n < 0; printChar('-'); n = -n; fin
if n > 9999; printChar('0' + n/10000); n = n%10000; fin
if n > 999; printChar('0' + n/1000); n = n%1000; fin
if n > 99; printChar('0' + n/100); n = n%100; fin
if n > 9; printChar('0' + n/10); n = n%10; fin
word n0
if n < 0; printChar('-'); n = -n; fin
n0 = n
if n0 > 9999; printChar('0' + n/10000); n = n%10000; fin
if n0 > 999; printChar('0' + n/1000); n = n%1000; fin
if n0 > 99; printChar('0' + n/100); n = n%100; fin
if n0 > 9; printChar('0' + n/10); n = n%10; fin
printChar('0' + n)
end
@ -457,6 +479,31 @@ def printf1(str, arg1); printf4(str, arg1, 0, 0, 0); end
def printf2(str, arg1, arg2); printf4(str, arg1, arg2, 0, 0); end
def printf3(str, arg1, arg2, arg3); printf4(str, arg1, arg2, arg3, 0); end
///////////////////////////////////////////////////////////////////////////////////////////////////
def parseDec(str)
word n
word pend
word p
byte neg
neg = FALSE
n = 0
p = str + 1
pend = p + ^str
while p < pend
if p == (str+1) and ^p == '-'
neg = TRUE
elsif ^p >= '0' and ^p <= '9'
n = (n*10) + (^p - '0')
else
break
fin
p = p+1
loop
if neg; return -n; fin
return n
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Get a keystroke and convert it to upper case
def getUpperKey()
@ -738,6 +785,20 @@ def debugPos()
printf2("x=$%x y=$%x\n", x, y)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def teleport()
word x, y
^$c053
if ^$25 < 20; ^$25 = 20; crout(); fin
puts("X: ")
x = parseDec(getstr())
printf1("Got %d\n", x)
puts("Y: ")
y = parseDec(getstr())
printf1("Got %d\n", y)
setMap(mapIs3D, mapNum, x, y, 0)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Get a key and dispatch it to a command. Then do it again, forever.
def kbdLoop()
@ -815,7 +876,10 @@ def initCmds()
cmdTbl[i] = 0
next
// Handle 3D vs 2D commands separately
// Commands common to both 2D and 3D
initCmd('T', @teleport)
// Commands handled differently in 3D vs 2D
if mapIs3D
initCmd('W', @moveForward)
initCmd('A', @rotateLeft)
@ -841,6 +905,12 @@ def initCmds()
initCmd('S', @moveSouth)
initCmd('X', @moveSouth)
initCmd('A', @moveWest)
initCmd('I', @moveNorth)
initCmd('J', @moveWest)
initCmd('L', @moveEast)
initCmd('K', @moveSouth)
initCmd(',', @moveSouth)
fin
end