Added support for println and clearWindow blocks. Added support for defaults in keyboard teleport. Fixed nasty page-boundary bug for strings in scripts.

This commit is contained in:
Martin Haye 2015-07-04 10:02:49 -07:00
parent 1becc7d61b
commit 195decd122
2 changed files with 72 additions and 31 deletions

View File

@ -1423,15 +1423,17 @@ class PackPartitions
def vec_setScriptInfo = 0x300 def vec_setScriptInfo = 0x300
def vec_pushAuxStr = 0x303 def vec_pushAuxStr = 0x303
def vec_displayStr = 0x306 def vec_displayStr = 0x306
def vec_getYN = 0x309 def vec_displayStrNL = 0x309
def vec_setMap = 0x30C def vec_getYN = 0x30C
def vec_setSky = 0x30F def vec_setMap = 0x30F
def vec_setGround = 0x312 def vec_setSky = 0x312
def vec_teleport = 0x315 def vec_setGround = 0x315
def vec_setPortrait = 0x318 def vec_teleport = 0x318
def vec_clrPortrait = 0x31B def vec_setPortrait = 0x31B
def vec_moveBackward = 0x31E def vec_clrPortrait = 0x31E
def vec_getCharacter = 0x321 def vec_moveBackward = 0x321
def vec_getCharacter = 0x324
def vec_clrTextWindow = 0x327
def emitAuxString(inStr) def emitAuxString(inStr)
{ {
@ -1563,6 +1565,8 @@ class PackPartitions
case 'text_print': case 'text_print':
case 'text_println': case 'text_println':
packTextPrint(blk); break packTextPrint(blk); break
case 'text_clear_window':
packClearWindow(blk); break
case 'text_getanykey': case 'text_getanykey':
packGetAnyKey(); break packGetAnyKey(); break
case 'controls_if': case 'controls_if':
@ -1665,7 +1669,17 @@ class PackPartitions
emitAuxString(text) emitAuxString(text)
emitCodeByte(0x54) // CALL emitCodeByte(0x54) // CALL
emitCodeWord(vec_displayStr) emitCodeWord(blk.@type == 'text_print' ? vec_displayStr : vec_displayStrNL)
emitCodeByte(0x30) // DROP
}
def packClearWindow(blk)
{
assert blk.value.size() == 0
//println " clearWindow"
emitCodeByte(0x54) // CALL
emitCodeWord(vec_clrTextWindow)
emitCodeByte(0x30) // DROP emitCodeByte(0x30) // DROP
} }

View File

@ -205,7 +205,9 @@ asm pushAuxStr // params: none; ret: $200 (inbuf)
; Get string length and save it ; Get string length and save it
iny ; advance to next code byte iny ; advance to next code byte
bne + bne +
inc $F4 ; next pg if necessary inc $F5 ; next pg if necessary
tsx
inc $105,x ; also PLASMA's copy of the page pointer
+ jsr $10 + jsr $10
sta $200 sta $200
ldx #0 ldx #0
@ -214,7 +216,11 @@ asm pushAuxStr // params: none; ret: $200 (inbuf)
beq ++ beq ++
iny ; advance to next code byte iny ; advance to next code byte
bne + bne +
inc $F4 ; next pg if necessary inc $F5 ; next pg if necessary
stx tmp+1
tsx
inc $105,x ; also PLASMA's copy of the page pointer
ldx tmp+1
+ jsr $10 ; now fetch the byte from aux mem + jsr $10 ; now fetch the byte from aux mem
inx inx
sta $200,x ; and stuff it in the string / input buffer sta $200,x ; and stuff it in the string / input buffer
@ -678,6 +684,14 @@ def parseDec(str)
return n return n
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
def parseDecWithDefault(str, default)
if ^str == 0
return default
fin
return parseDec(str)
end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Get a keystroke and convert it to upper case // Get a keystroke and convert it to upper case
def getUpperKey() def getUpperKey()
@ -1041,17 +1055,17 @@ def kbdTeleport()
getPos(@x, @y) getPos(@x, @y)
printf3("\nCurrent: X=%d Y=%d Facing=%d\n", x, y, getDir()) printf3("\nCurrent: X=%d Y=%d Facing=%d\n", x, y, getDir())
puts("3D : ") printf1("3D [%d]: ", mapIs3D)
d3 = parseDec(readStr()) d3 = parseDecWithDefault(readStr(), mapIs3D)
if d3 > 1; d3 = 1; fin if d3 > 1; d3 = 1; fin
puts("Map: ") printf1("Map [%d]: ", mapNum)
num = parseDec(readStr()) num = parseDecWithDefault(readStr(), mapNum)
puts("X : ") printf1("X [%d] : ", x)
x = parseDec(readStr()) x = parseDecWithDefault(readStr(), x)
puts("Y : ") printf1("Y [%d] : ", y)
y = parseDec(readStr()) y = parseDecWithDefault(readStr(), y)
puts("Facing: ") printf1("Facing [%d]: ", dir)
dir = parseDec(readStr()) dir = parseDecWithDefault(readStr(), dir)
^$c052 ^$c052
@ -1161,6 +1175,11 @@ def scriptDisplayStr(str)
displayStr(str) displayStr(str)
end end
def scriptDisplayStrNL(str)
scriptDisplayStr(str)
displayStr("\n")
end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Get a key, and don't return until it's Y or N (or lower-case of those). Returns 1 for Y. // Get a key, and don't return until it's Y or N (or lower-case of those). Returns 1 for Y.
def getYN() def getYN()
@ -1321,39 +1340,47 @@ def setCallbacks()
// $309 // $309
callbacks.9 = $4c callbacks.9 = $4c
callbacks:10 = @getYN callbacks:10 = @scriptDisplayStrNL
// $30C // $30C
callbacks.12 = $4c callbacks.12 = $4c
callbacks:13 = @queue_setMap callbacks:13 = @getYN
// $30F // $30F
callbacks.15 = $4c callbacks.15 = $4c
callbacks:16 = @setSky callbacks:16 = @queue_setMap
// $312 // $312
callbacks.18 = $4c callbacks.18 = $4c
callbacks:19 = @setGround callbacks:19 = @setSky
// $315 // $315
callbacks.21 = $4c callbacks.21 = $4c
callbacks:22 = @queue_teleport callbacks:22 = @setGround
// $318 // $318
callbacks.24 = $4c callbacks.24 = $4c
callbacks:25 = @setPortrait callbacks:25 = @queue_teleport
// $31B // $31B
callbacks.27 = $4c callbacks.27 = $4c
callbacks:28 = @clrPortrait callbacks:28 = @setPortrait
// $31E // $31E
callbacks.30 = $4c callbacks.30 = $4c
callbacks:31 = @moveBackward callbacks:31 = @clrPortrait
// $321 // $321
callbacks.33 = $4c callbacks.33 = $4c
callbacks:34 = @getUpperKey callbacks:34 = @moveBackward
// $324
callbacks.36 = $4c
callbacks:37 = @getUpperKey
// $327
callbacks.39 = $4c
callbacks:40 = @clearWindow
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////