mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-02-28 12:29:59 +00:00
Added automap-compatible 2D tiles to 3D maps.
This commit is contained in:
parent
234e013047
commit
7b9522d6d6
@ -637,13 +637,16 @@ class A2PackPartitions
|
||||
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
|
||||
|
||||
// For automap display, we need 2D tiles as well
|
||||
def (tileSetNum, tileMap) = packTileSet(rows, 0, width-2, 0, height-2) // exclude sentinels
|
||||
|
||||
// Determine the set of all referenced textures, and assign numbers to them.
|
||||
def texMap = [:]
|
||||
def texList = []
|
||||
def texFlags = []
|
||||
def texNames = [] as Set
|
||||
rows.each { row ->
|
||||
row.each { tile ->
|
||||
rows.eachWithIndex { row,y ->
|
||||
row.eachWithIndex { tile,x ->
|
||||
def id = tile?.@id
|
||||
def name = tile?.@name
|
||||
if (name != null)
|
||||
@ -657,7 +660,7 @@ class A2PackPartitions
|
||||
flags |= 2
|
||||
if (tile?.@blocker == 'true')
|
||||
flags |= 4
|
||||
texList.add(textures[name].num)
|
||||
texList.add([tileMap[id], textures[name].num])
|
||||
texFlags.add(flags)
|
||||
texMap[id] = texList.size()
|
||||
if (tile?.@sprite == 'true')
|
||||
@ -676,11 +679,15 @@ class A2PackPartitions
|
||||
buf.put((byte)width)
|
||||
buf.put((byte)height)
|
||||
|
||||
// Followed by script module num
|
||||
// Followed by script module num and tileset num
|
||||
buf.put((byte)scriptModule)
|
||||
buf.put((byte)tileSetNum)
|
||||
|
||||
// Followed by the list of textures
|
||||
texList.each { buf.put((byte)it) }
|
||||
// Followed by the list of textures; each one has 2D tile num and 3D texture num
|
||||
texList.each { tileNum, texNum ->
|
||||
buf.put((byte)(tileNum == null ? 0xFF : tileNum+1))
|
||||
buf.put((byte)texNum)
|
||||
}
|
||||
buf.put((byte)0)
|
||||
|
||||
// Followed by the corresponding list of texture flags
|
||||
@ -898,12 +905,11 @@ class A2PackPartitions
|
||||
def tileIds = [] as Set
|
||||
(yOff ..< yOff+height).each { y ->
|
||||
def row = (y < rows.size) ? rows[y] : null
|
||||
(xOff ..< xOff+height).each { x ->
|
||||
(xOff ..< xOff+width).each { x ->
|
||||
def tile = (row && x < row.size) ? row[x] : null
|
||||
tileIds.add(tile?.@id)
|
||||
}
|
||||
}
|
||||
|
||||
assert tileIds.size() > 0
|
||||
|
||||
// See if there's a good existing tile set we can use/add to.
|
||||
@ -983,6 +989,7 @@ class A2PackPartitions
|
||||
{
|
||||
def name = mapEl.@name ?: "map$num"
|
||||
def num = mapNames[name][1]
|
||||
|
||||
//println "Packing 3D map #$num named '$name': num=$num."
|
||||
withContext("map '$name'") {
|
||||
addResourceDep("map", name, "map3D", name)
|
||||
@ -2020,6 +2027,7 @@ class A2PackPartitions
|
||||
compileModule("diskops", "src/plasma/")
|
||||
compileModule("godmode", "src/plasma/")
|
||||
compileModule("intimate", "src/plasma/")
|
||||
compileModule("automap", "src/plasma/")
|
||||
compileModule("gen_enemies", "src/plasma/")
|
||||
compileModule("gen_items", "src/plasma/")
|
||||
compileModule("gen_players", "src/plasma/")
|
||||
@ -2042,20 +2050,18 @@ class A2PackPartitions
|
||||
dataIn.map.each { map ->
|
||||
def name = map?.@name
|
||||
def shortName = name.replaceAll(/[\s-]*[23]D$/, '')
|
||||
if (map?.@name =~ /\s*2D$/) {
|
||||
mapNames[name] = ['2D', num2D+1]
|
||||
mapNames[shortName] = ['2D', num2D+1]
|
||||
def rows = parseMap(map, dataIn.tile, true) // quick mode
|
||||
def (width, height, nHorzSections, nVertSections) = calcMapExtent(rows)
|
||||
num2D += (nHorzSections * nVertSections)
|
||||
}
|
||||
else if (map?.@name =~ /\s*3D$/) {
|
||||
|
||||
mapNames[name] = ['2D', num2D+1]
|
||||
mapNames[shortName] = ['2D', num2D+1]
|
||||
def rows = parseMap(map, dataIn.tile, true) // quick mode
|
||||
def (width, height, nHorzSections, nVertSections) = calcMapExtent(rows)
|
||||
num2D += (nHorzSections * nVertSections)
|
||||
|
||||
if (map?.@name =~ /\s*3D$/) {
|
||||
mapNames[name] = ['3D', num3D+1]
|
||||
mapNames[shortName] = ['3D', num3D+1]
|
||||
++num3D
|
||||
}
|
||||
else
|
||||
printWarning "map name '${map?.@name}' should contain '2D' or '3D'. Skipping."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
printf '\33c\e[3J' # cls
|
||||
cd /Users/mhaye/plat/tools/ProRWTS && make && \
|
||||
cd /Users/mhaye/plat/tools/PLASMA/src && make vm && \
|
||||
cd /Users/mhaye/plat/tools/PackPartitions && rm -f dist/PackPartitions.jar && ant jar
|
||||
|
@ -23,9 +23,10 @@ const fontDataLen = $4FA // really only $474, but we need to fill all gaps
|
||||
const CHAR_WND_HEALTH_X = 112
|
||||
|
||||
const ANIM_PAUSE_MAX = 150
|
||||
const LAMP_PAUSE_MAX = 43
|
||||
const LAMP_PAUSE_MIN = 30
|
||||
const LAMP_PAUSE_MAX = 100
|
||||
|
||||
const CLOCK_X = 112
|
||||
const CLOCK_X = 119
|
||||
const CLOCK_Y = 176
|
||||
const CLOCK_RADIUS = 14
|
||||
|
||||
@ -56,6 +57,7 @@ include "store.plh"
|
||||
include "diskops.plh"
|
||||
include "intimate.plh"
|
||||
include "godmode.plh"
|
||||
include "automap.plh"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Data structures
|
||||
@ -1602,11 +1604,11 @@ end
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def nextLampFrame()#0
|
||||
word n, pTile
|
||||
if !mapIs3D or !frameLoaded; return; fin
|
||||
|
||||
if showingLamp
|
||||
n = ((lampFrame + lampDir) % (LAMP_COUNT-1)) + LAMP_1
|
||||
if !n
|
||||
lampDir = ((rand16() % 2) * 2) - 1 // -1 or 1, randomly
|
||||
fin
|
||||
if (rand16() % 100) < 10; lampDir = -lampDir; fin
|
||||
else
|
||||
n = LAMP_0
|
||||
fin
|
||||
@ -1631,7 +1633,7 @@ export def pause(count)#1
|
||||
lampPauseCt--
|
||||
if lampPauseCt < 0
|
||||
if mapIs3D; nextLampFrame(); fin // handles show/hide as well
|
||||
lampPauseCt = LAMP_PAUSE_MAX
|
||||
lampPauseCt = (rand16() % (LAMP_PAUSE_MAX-LAMP_PAUSE_MIN)) + LAMP_PAUSE_MIN
|
||||
fin
|
||||
next
|
||||
return i
|
||||
@ -1717,7 +1719,7 @@ export def setSky(num)#0
|
||||
skyNum = num
|
||||
setColor(0, skyNum)
|
||||
needRender = TRUE
|
||||
showingLamp = mapIs3D and skyNum == 0
|
||||
showingLamp = mapIs3D and (skyNum == 0 or skyNum == 8)
|
||||
fin
|
||||
end
|
||||
|
||||
@ -1806,8 +1808,8 @@ end
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def resetAnimPause()#0
|
||||
animPauseCt = ANIM_PAUSE_MAX
|
||||
lampPauseCt = LAMP_PAUSE_MAX
|
||||
showingLamp = mapIs3D and skyNum == 0
|
||||
lampPauseCt = (rand16() % (LAMP_PAUSE_MAX-LAMP_PAUSE_MIN)) + LAMP_PAUSE_MIN
|
||||
showingLamp = mapIs3D and (skyNum == 0 or skyNum == 8)
|
||||
lampFrame = 0
|
||||
lampDir = 1
|
||||
end
|
||||
@ -2325,12 +2327,17 @@ def doRender()#0
|
||||
if mapIs3D
|
||||
flipToPage1()
|
||||
texControl(1)
|
||||
nextLampFrame // handles hide and/or show
|
||||
lampPauseCt = LAMP_PAUSE_MAX
|
||||
if lampPauseCt < 50
|
||||
nextLampFrame
|
||||
fin
|
||||
fin
|
||||
texturesLoaded = TRUE
|
||||
fin
|
||||
render()
|
||||
if mapIs3D
|
||||
nextLampFrame // handles hide and/or show
|
||||
lampPauseCt = (rand16() % (LAMP_PAUSE_MAX-LAMP_PAUSE_MIN)) + LAMP_PAUSE_MIN
|
||||
fin
|
||||
needRender = FALSE
|
||||
end
|
||||
|
||||
@ -2933,6 +2940,14 @@ export def callGlobalFunc(moduleNum, arg1, arg2, arg3)#1
|
||||
return ret
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Load the automap engine and display the map
|
||||
def showAutomap()#1
|
||||
loadEngine(MOD_AUTOMAP)=>automap_show()
|
||||
returnFromEngine(TRUE)
|
||||
return 0
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Load the Party engine and show data for the given player
|
||||
def showPlayerSheet(num)#1
|
||||
@ -3149,6 +3164,7 @@ def initCmds()#0
|
||||
cmdTbl['?'] = @help
|
||||
cmdTbl[$07] = @toggleGodMode // ctrl-G
|
||||
cmdTbl[' '] = @snooze // "space out" (snooze)
|
||||
cmdTbl[$0d] = @showAutomap // ctrl-M = Enter/Return
|
||||
if global->b_godmode
|
||||
pGodModule=>godmode_setCheatCmds()
|
||||
fin
|
||||
|
@ -1624,11 +1624,14 @@ loadTextures: !zone
|
||||
sty .scInit+2 ; ...after it loads of course.
|
||||
stx scripts
|
||||
sty scripts+1
|
||||
jsr .get ; skip tileset number (only used by automap display logic)
|
||||
lda #0 ; now comes the list of textures.
|
||||
sta txNum
|
||||
.lup: jsr .get ; get texture resource number
|
||||
tay ; to Y for mem manager
|
||||
.lup: jsr .get ; skip tile number (only used by automap display logic)
|
||||
tay
|
||||
beq .done ; zero = end of texture list
|
||||
jsr .get ; get texture resource number
|
||||
tay ; to Y for mem manager
|
||||
lda #QUEUE_LOAD
|
||||
ldx #RES_TYPE_TEXTURE
|
||||
jsr auxLoader ; we want textures in aux mem
|
||||
|
Loading…
x
Reference in New Issue
Block a user