From 57462b76380408f95eddb02d9326dd46ac8461fa Mon Sep 17 00:00:00 2001 From: Martin Haye Date: Sun, 31 May 2015 11:19:03 -0700 Subject: [PATCH] Moved scenario script strings to aux mem. --- .../src/org/demo/PackPartitions.groovy | 39 ++++----- .../Apple/virtual/src/plasma/gameloop.pla | 83 +++++++++++++++++-- 2 files changed, 95 insertions(+), 27 deletions(-) diff --git a/Platform/Apple/tools/PackPartitions/src/org/demo/PackPartitions.groovy b/Platform/Apple/tools/PackPartitions/src/org/demo/PackPartitions.groovy index 1ac3e9a3..cd7ee78f 100644 --- a/Platform/Apple/tools/PackPartitions/src/org/demo/PackPartitions.groovy +++ b/Platform/Apple/tools/PackPartitions/src/org/demo/PackPartitions.groovy @@ -1384,26 +1384,29 @@ class PackPartitions def fixups = [] def nScripts = 0 + def nStringBytes = 0 def locationsWithTriggers = [] as Set def vec_setScriptInfo = 0x300 - def vec_displayStr = 0x303 - def vec_getYN = 0x306 - def vec_setMap = 0x309 - def vec_setSky = 0x30C - def vec_setGround = 0x30F - def vec_teleport = 0x312 - def vec_setPortrait = 0x315 - def vec_clrPortrait = 0x318 + def vec_pushAuxStr = 0x303 + def vec_displayStr = 0x306 + def vec_getYN = 0x309 + def vec_setMap = 0x30C + def vec_setSky = 0x30F + def vec_setGround = 0x312 + def vec_teleport = 0x315 + def vec_setPortrait = 0x318 + def vec_clrPortrait = 0x31B - def addString(str) + def emitAuxString(str) { + emitCodeByte(0x54) // CALL + emitCodeWord(vec_pushAuxStr) assert str.size() < 256 : "String too long, max is 255 characters: $str" - def addr = dataAddr() - emitDataByte(str.size()) - str.each { ch -> emitDataByte((byte)ch) } - return addr + emitCodeByte(str.size()) + str.each { ch -> emitCodeByte((byte)ch) } + nStringBytes += str.size() + 1 } /** @@ -1435,6 +1438,8 @@ class PackPartitions } makeInit(mapName, scripts, xRange, yRange) emitFixupByte(0xFF) + + //println " Code stats: data=${data.size}, bytecode=${bytecode.size} (str=$nStringBytes), fixups=${fixups.size}" //println "data: $data" //println "bytecode: $bytecode" //println "fixups: $fixups" @@ -1603,9 +1608,7 @@ class PackPartitions def text = fld.text() //println " text: '$text'" - emitCodeByte(0x26) // LA - def textAddr = addString(text) - emitCodeFixup(textAddr) + emitAuxString(text) emitCodeByte(0x54) // CALL emitCodeWord(vec_displayStr) emitCodeByte(0x30) // DROP @@ -1836,9 +1839,7 @@ class PackPartitions shortName = (" " * extra) + shortName // Code to register the table and map name - emitCodeByte(0x26) // LA - def textAddr = addString(shortName) - emitCodeFixup(textAddr) + emitAuxString(shortName) emitCodeByte(0x26) // LA emitCodeFixup(dataAddr()) emitCodeByte(0x54) // CALL diff --git a/Platform/Apple/virtual/src/plasma/gameloop.pla b/Platform/Apple/virtual/src/plasma/gameloop.pla index 8b68a703..5b72d864 100644 --- a/Platform/Apple/virtual/src/plasma/gameloop.pla +++ b/Platform/Apple/virtual/src/plasma/gameloop.pla @@ -171,6 +171,69 @@ asm render // no params +asmPlasm 0 jmp $6018 end +/////////////////////////////////////////////////////////////////////////////////////////////////// +asm pushAuxStr // params: none; ret: $200 (inbuf) + stx tmp ; save PLASMA's X reg eval stack index + tsx + lda $103,x ; get PLASMA's Y-reg value from its place in the stack + tay + + ; Create the following subroutine, used to copy chars from aux to main: + ;0010- 8D 03 C0 STA $C003 + ;0013- C8 INY + ;0014- D0 02 BNE $0018 + ;0016- E6 F5 INC $F5 + ;0018- B1 F4 LDA ($F4),Y + ;001A- 8D 02 C0 STA $C002 + ;001D- 60 RTS + lda #$8D + sta $10 + sta $1A + ldx #2 + stx $15 + stx $1B + inx + stx $11 + lda #$C0 + sta $12 + sta $1C + lda #$C8 + sta $13 + lda #$D0 + sta $14 + lda #$E6 + sta $16 + ldx #$F5 + stx $17 + lda #$B1 + sta $18 + dex + stx $19 + lda #$60 + sta $1D + + ; Get string length and save it + jsr $10 + sta $200 + ldx #0 + ; Copy entire string +- cpx $200 + beq + + jsr $10 + inx + sta $200,x + bne - ++ tsx + tya + sta $103,x ; modify PLASMA's Y reg so it picks up code execution just after the string + ldx tmp ; retrieve PLASMA's eval stack ptr + dex ; make room for ret value + lda #0 + sta evalStkL,x ; return value lo (<$200) + lda #2 + sta evalStkH,x ; and hi (>$200) + rts +end /////////////////////////////////////////////////////////////////////////////////////////////////// asm blitPortrait // params: srcData, dstScreenPtr @@ -1204,35 +1267,39 @@ def setCallbacks() // $303 callbacks.3 = $4c - callbacks:4 = @scriptDisplayStr + callbacks:4 = @pushAuxStr // $306 callbacks.6 = $4c - callbacks:7 = @getYN + callbacks:7 = @scriptDisplayStr // $309 callbacks.9 = $4c - callbacks:10 = @queue_setMap + callbacks:10 = @getYN // $30C callbacks.12 = $4c - callbacks:13 = @setSky + callbacks:13 = @queue_setMap // $30F callbacks.15 = $4c - callbacks:16 = @setGround + callbacks:16 = @setSky // $312 callbacks.18 = $4c - callbacks:19 = @queue_teleport + callbacks:19 = @setGround // $315 callbacks.21 = $4c - callbacks:22 = @setPortrait + callbacks:22 = @queue_teleport // $318 callbacks.24 = $4c - callbacks:25 = @clrPortrait + callbacks:25 = @setPortrait + + // $31B + callbacks.27 = $4c + callbacks:28 = @clrPortrait end ///////////////////////////////////////////////////////////////////////////////////////////////////