From 3bbcc7ed926e62f5c786d6d2132fbcba61b9b3b3 Mon Sep 17 00:00:00 2001 From: Martin Haye Date: Tue, 15 Jul 2014 09:52:58 -0700 Subject: [PATCH] Rearranged things a bit in preparation for segmented 2D map packing. --- .../src/org/demo/PackPartitions.groovy | 19 ++++++++++++------- Platform/Apple/virtual/src/font/fontEngine.s | 2 +- .../Apple/virtual/src/plasma/gameloop.pla | 12 ++++++++---- Platform/Apple/virtual/src/raycast/render.s | 7 ++++--- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/Platform/Apple/tools/PackPartitions/src/org/demo/PackPartitions.groovy b/Platform/Apple/tools/PackPartitions/src/org/demo/PackPartitions.groovy index 6029d745..397c3984 100644 --- a/Platform/Apple/tools/PackPartitions/src/org/demo/PackPartitions.groovy +++ b/Platform/Apple/tools/PackPartitions/src/org/demo/PackPartitions.groovy @@ -414,7 +414,7 @@ class PackPartitions javascriptOut.println("];\n") } - def write3DMap(buf, mapName, rows) // [ref BigBlue1_50] + def write3DMap(buf, mapName, rows, scriptModule) // [ref BigBlue1_50] { def width = rows[0].size() + 2 // Sentinel $FF at start and end of each row def height = rows.size() + 2 // Sentinel rows of $FF's at start and end @@ -454,6 +454,9 @@ class PackPartitions buf.put((byte)width) buf.put((byte)height) + // Followed by script module num + buf.put((byte)scriptModule) + // Followed by name writeString(buf, mapName.replaceFirst(/ ?-? ?3D/, "")) @@ -565,24 +568,26 @@ class PackPartitions def num = maps3D.size() + 1 def name = mapEl.@name ?: "map$num" println "Packing 3D map #$num named '$name'." - packScripts(mapEl, num) + def scriptModule = packScripts(mapEl, name) def rows = parseMap(mapEl, tileEls) def buf = ByteBuffer.allocate(50000) - write3DMap(buf, name, rows) + write3DMap(buf, name, rows, scriptModule) maps3D[name] = [num:num, buf:buf] } - def packScripts(mapEl, mapNum) + def packScripts(mapEl, mapName) { if (!mapEl.scripts) - return + return 0 ScriptModule module = new ScriptModule() module.packScripts(mapEl.scripts[0]) - def num = mapNum + 0x20 // to distinguish from system modules - def name = "mapScript$mapNum" + def num = modules.size() + 1 + def name = "mapScript$num" + println "Packing scripts for map $mapName, to module $num." modules[name] = [num:num, buf:wrapByteList(module.data)] bytecodes[name] = [num:num, buf:wrapByteList(module.bytecode)] fixups[name] = [num:num, buf:wrapByteList(module.fixups)] + return num } def readBinary(path) diff --git a/Platform/Apple/virtual/src/font/fontEngine.s b/Platform/Apple/virtual/src/font/fontEngine.s index f754dd51..7fa3e6bb 100644 --- a/Platform/Apple/virtual/src/font/fontEngine.s +++ b/Platform/Apple/virtual/src/font/fontEngine.s @@ -750,5 +750,5 @@ strLENGTH !fill 1 ; length of string ;--------------------------- ; End of the code... ;--------------------------- - + !align 127,0 !source "tables.i" diff --git a/Platform/Apple/virtual/src/plasma/gameloop.pla b/Platform/Apple/virtual/src/plasma/gameloop.pla index 2c9ccd38..37b2379f 100644 --- a/Platform/Apple/virtual/src/plasma/gameloop.pla +++ b/Platform/Apple/virtual/src/plasma/gameloop.pla @@ -355,6 +355,7 @@ end ; General methods def initMap() + word scriptModule ; Reset memory (our module will stay since memory manager locked it upon load) loader(RESET_MEMORY, MAIN_MEM, 0) @@ -385,9 +386,13 @@ def initMap() ; Load everything that we just queued loader(FINISH_LOAD, MAIN_MEM, 1) ; 1 = keep open - ; Load the scripts for this map - pScripts = loader(QUEUE_LOAD, MAIN_MEM, ((mapNum+$20)<<8) | RES_TYPE_MODULE) - loader(FINISH_LOAD, MAIN_MEM, 1) ; 1 = keep open + ; Load the scripts for this map, if it has any. + scriptModule = pMap->2 ; first 2 bytes are width and height, third byte is script module num + if scriptModule + pScripts = loader(QUEUE_LOAD, MAIN_MEM, (scriptModule << 8) | RES_TYPE_MODULE) + loader(FINISH_LOAD, MAIN_MEM, 1) ; 1 = keep open + *pScripts() + fin ; Start up the font engine initFontEngine(pFont) @@ -402,7 +407,6 @@ def initMap() ; Initialize the map scripts setWindow2() - *pScripts() prevX = -1 prevY = -1 diff --git a/Platform/Apple/virtual/src/raycast/render.s b/Platform/Apple/virtual/src/raycast/render.s index bae9ee18..33a6c673 100644 --- a/Platform/Apple/virtual/src/raycast/render.s +++ b/Platform/Apple/virtual/src/raycast/render.s @@ -1573,6 +1573,7 @@ loadTextures: !zone sta mapWidth ; and save it jsr .get ; get map height sta mapHeight ; and save it + jsr .get ; ignore script module num (it gets loaded by PLASMA code) lda .get+1 ; current pointer is the map name sta mapName ; save it lda .get+2 @@ -1583,9 +1584,9 @@ loadTextures: !zone inc mapNameLen cmp #0 bne .skip ; until end-of-string is reached (zero byte) - lda mapNameLen ; clamp length of map name + lda mapNameLen ; clamp length of map name cmp #MAX_NAME_LEN - bcc + + bcc .notrnc lda mapName sta .trunc+1 lda mapName+1 @@ -1594,7 +1595,7 @@ loadTextures: !zone lda #0 .trunc sta mapName,x stx mapNameLen -+ lda #0 ; now comes the list of textures. +.notrnc lda #0 ; now comes the list of textures. sta txNum .lup: jsr .get ; get texture resource number tay ; to Y for mem manager