mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-03-04 07:29:21 +00:00
Rearranged things a bit in preparation for segmented 2D map packing.
This commit is contained in:
parent
df246c40c6
commit
3bbcc7ed92
@ -414,7 +414,7 @@ class PackPartitions
|
|||||||
javascriptOut.println("];\n")
|
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 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
|
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)width)
|
||||||
buf.put((byte)height)
|
buf.put((byte)height)
|
||||||
|
|
||||||
|
// Followed by script module num
|
||||||
|
buf.put((byte)scriptModule)
|
||||||
|
|
||||||
// Followed by name
|
// Followed by name
|
||||||
writeString(buf, mapName.replaceFirst(/ ?-? ?3D/, ""))
|
writeString(buf, mapName.replaceFirst(/ ?-? ?3D/, ""))
|
||||||
|
|
||||||
@ -565,24 +568,26 @@ class PackPartitions
|
|||||||
def num = maps3D.size() + 1
|
def num = maps3D.size() + 1
|
||||||
def name = mapEl.@name ?: "map$num"
|
def name = mapEl.@name ?: "map$num"
|
||||||
println "Packing 3D map #$num named '$name'."
|
println "Packing 3D map #$num named '$name'."
|
||||||
packScripts(mapEl, num)
|
def scriptModule = packScripts(mapEl, name)
|
||||||
def rows = parseMap(mapEl, tileEls)
|
def rows = parseMap(mapEl, tileEls)
|
||||||
def buf = ByteBuffer.allocate(50000)
|
def buf = ByteBuffer.allocate(50000)
|
||||||
write3DMap(buf, name, rows)
|
write3DMap(buf, name, rows, scriptModule)
|
||||||
maps3D[name] = [num:num, buf:buf]
|
maps3D[name] = [num:num, buf:buf]
|
||||||
}
|
}
|
||||||
|
|
||||||
def packScripts(mapEl, mapNum)
|
def packScripts(mapEl, mapName)
|
||||||
{
|
{
|
||||||
if (!mapEl.scripts)
|
if (!mapEl.scripts)
|
||||||
return
|
return 0
|
||||||
ScriptModule module = new ScriptModule()
|
ScriptModule module = new ScriptModule()
|
||||||
module.packScripts(mapEl.scripts[0])
|
module.packScripts(mapEl.scripts[0])
|
||||||
def num = mapNum + 0x20 // to distinguish from system modules
|
def num = modules.size() + 1
|
||||||
def name = "mapScript$mapNum"
|
def name = "mapScript$num"
|
||||||
|
println "Packing scripts for map $mapName, to module $num."
|
||||||
modules[name] = [num:num, buf:wrapByteList(module.data)]
|
modules[name] = [num:num, buf:wrapByteList(module.data)]
|
||||||
bytecodes[name] = [num:num, buf:wrapByteList(module.bytecode)]
|
bytecodes[name] = [num:num, buf:wrapByteList(module.bytecode)]
|
||||||
fixups[name] = [num:num, buf:wrapByteList(module.fixups)]
|
fixups[name] = [num:num, buf:wrapByteList(module.fixups)]
|
||||||
|
return num
|
||||||
}
|
}
|
||||||
|
|
||||||
def readBinary(path)
|
def readBinary(path)
|
||||||
|
@ -750,5 +750,5 @@ strLENGTH !fill 1 ; length of string
|
|||||||
;---------------------------
|
;---------------------------
|
||||||
; End of the code...
|
; End of the code...
|
||||||
;---------------------------
|
;---------------------------
|
||||||
|
!align 127,0
|
||||||
!source "tables.i"
|
!source "tables.i"
|
||||||
|
@ -355,6 +355,7 @@ end
|
|||||||
; General methods
|
; General methods
|
||||||
|
|
||||||
def initMap()
|
def initMap()
|
||||||
|
word scriptModule
|
||||||
|
|
||||||
; Reset memory (our module will stay since memory manager locked it upon load)
|
; Reset memory (our module will stay since memory manager locked it upon load)
|
||||||
loader(RESET_MEMORY, MAIN_MEM, 0)
|
loader(RESET_MEMORY, MAIN_MEM, 0)
|
||||||
@ -385,9 +386,13 @@ def initMap()
|
|||||||
; Load everything that we just queued
|
; Load everything that we just queued
|
||||||
loader(FINISH_LOAD, MAIN_MEM, 1) ; 1 = keep open
|
loader(FINISH_LOAD, MAIN_MEM, 1) ; 1 = keep open
|
||||||
|
|
||||||
; Load the scripts for this map
|
; Load the scripts for this map, if it has any.
|
||||||
pScripts = loader(QUEUE_LOAD, MAIN_MEM, ((mapNum+$20)<<8) | RES_TYPE_MODULE)
|
scriptModule = pMap->2 ; first 2 bytes are width and height, third byte is script module num
|
||||||
loader(FINISH_LOAD, MAIN_MEM, 1) ; 1 = keep open
|
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
|
; Start up the font engine
|
||||||
initFontEngine(pFont)
|
initFontEngine(pFont)
|
||||||
@ -402,7 +407,6 @@ def initMap()
|
|||||||
|
|
||||||
; Initialize the map scripts
|
; Initialize the map scripts
|
||||||
setWindow2()
|
setWindow2()
|
||||||
*pScripts()
|
|
||||||
prevX = -1
|
prevX = -1
|
||||||
prevY = -1
|
prevY = -1
|
||||||
|
|
||||||
|
@ -1573,6 +1573,7 @@ loadTextures: !zone
|
|||||||
sta mapWidth ; and save it
|
sta mapWidth ; and save it
|
||||||
jsr .get ; get map height
|
jsr .get ; get map height
|
||||||
sta mapHeight ; and save it
|
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
|
lda .get+1 ; current pointer is the map name
|
||||||
sta mapName ; save it
|
sta mapName ; save it
|
||||||
lda .get+2
|
lda .get+2
|
||||||
@ -1583,9 +1584,9 @@ loadTextures: !zone
|
|||||||
inc mapNameLen
|
inc mapNameLen
|
||||||
cmp #0
|
cmp #0
|
||||||
bne .skip ; until end-of-string is reached (zero byte)
|
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
|
cmp #MAX_NAME_LEN
|
||||||
bcc +
|
bcc .notrnc
|
||||||
lda mapName
|
lda mapName
|
||||||
sta .trunc+1
|
sta .trunc+1
|
||||||
lda mapName+1
|
lda mapName+1
|
||||||
@ -1594,7 +1595,7 @@ loadTextures: !zone
|
|||||||
lda #0
|
lda #0
|
||||||
.trunc sta mapName,x
|
.trunc sta mapName,x
|
||||||
stx mapNameLen
|
stx mapNameLen
|
||||||
+ lda #0 ; now comes the list of textures.
|
.notrnc lda #0 ; now comes the list of textures.
|
||||||
sta txNum
|
sta txNum
|
||||||
.lup: jsr .get ; get texture resource number
|
.lup: jsr .get ; get texture resource number
|
||||||
tay ; to Y for mem manager
|
tay ; to Y for mem manager
|
||||||
|
Loading…
x
Reference in New Issue
Block a user