mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-09-30 03:56:59 +00:00
Excellent progress on displaying map special icons.
This commit is contained in:
parent
7ffc63db8e
commit
ba748eed52
@ -1077,24 +1077,26 @@ class A2PackPartitions
|
||||
def setName = "tileSet_automap"
|
||||
def tileIds = [] as Set
|
||||
def tileMap = [:]
|
||||
def buf = ByteBuffer.allocate(50000)
|
||||
def mainBuf = ByteBuffer.allocate(50000)
|
||||
def smBuf = ByteBuffer.allocate(20000)
|
||||
|
||||
// Add each automap tile to the set
|
||||
dataIn.tile.sort{(it.@category + it.@name).toLowerCase()}.each { tile ->
|
||||
def name = tile.@name
|
||||
def id = tile.@id
|
||||
def data = tiles[id]
|
||||
def cat = tile.@category.toLowerCase().trim()
|
||||
if (cat == "automap") {
|
||||
def num = tileMap.size()
|
||||
tileIds.add(id)
|
||||
tileMap[id] = num
|
||||
data.flip() // crazy stuff to append one buffer to another
|
||||
buf.put(data)
|
||||
tiles[id].flip() // crazy stuff to append one buffer to another
|
||||
mainBuf.put(tiles[id])
|
||||
smTiles[id].flip()
|
||||
smBuf.put(smTiles[id])
|
||||
}
|
||||
}
|
||||
|
||||
tileSets[setName] = [num:setNum, mainBuf:buf, smBuf:ByteBuffer.allocate(1), tileMap:tileMap, tileIds:tileIds]
|
||||
tileSets[setName] = [num:setNum, mainBuf:mainBuf, smBuf:smBuf, tileMap:tileMap, tileIds:tileIds]
|
||||
addResourceDep("map", "<root>", "tileSet", "tileSet_automap")
|
||||
return [setNum, tileMap]
|
||||
}
|
||||
@ -2369,6 +2371,7 @@ class A2PackPartitions
|
||||
{
|
||||
def num2D = 0
|
||||
def num3D = 0
|
||||
def width, height, nHorzSections, nVertSections
|
||||
dataIn.map.each { map ->
|
||||
def name = map?.@name
|
||||
def shortName = name.replaceAll(/[\s-]*[23]D$/, '')
|
||||
@ -2378,7 +2381,7 @@ class A2PackPartitions
|
||||
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)
|
||||
(width, height, nHorzSections, nVertSections) = calcMapExtent(rows)
|
||||
(1..(nHorzSections * nVertSections)).each {
|
||||
int rowBytes = (TILES_PER_ROW+7)/8
|
||||
mapSizes << ['2D', it+num2D, 2 + (rowBytes * ROWS_PER_SECTION)]
|
||||
@ -2402,7 +2405,7 @@ class A2PackPartitions
|
||||
if (baseMapNum > 0 && automapPat) {
|
||||
map.scripts.script.each { script ->
|
||||
String scriptName = script?.@name.trim().toLowerCase()
|
||||
if (automapPat.matcher(scriptName).matches()) {
|
||||
if (automapPat.matcher(scriptName).find()) {
|
||||
def tile
|
||||
automapTiles.each { tileName, tileNum ->
|
||||
if (scriptName.contains(tileName))
|
||||
@ -2415,7 +2418,14 @@ class A2PackPartitions
|
||||
int y = trig.@y.toInteger()
|
||||
assert x >= 0 && x < 255 : "map too wide"
|
||||
assert y >= 0 && y < 255 : "map too high"
|
||||
automapSpecials << [baseMapNum, y, x, tile]
|
||||
if (map?.@name =~ /\s*2D$/) {
|
||||
int hsect = x / TILES_PER_ROW
|
||||
int vsect = y / ROWS_PER_SECTION
|
||||
int mapNum = baseMapNum + (vsect * nHorzSections) + hsect
|
||||
automapSpecials << [mapNum, y % ROWS_PER_SECTION, x % TILES_PER_ROW, tile]
|
||||
}
|
||||
else
|
||||
automapSpecials << [baseMapNum, y, x, tile]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2114,7 +2114,7 @@ disk_queueLoad: !zone
|
||||
lda (pTmp),y ; and hi byte
|
||||
+ stx reqLen ; save the uncompressed length
|
||||
sta reqLen+1 ; both bytes
|
||||
!if DEBUG { +prStr : !text "ucLen=",0 : +prWord reqLen : +crout }
|
||||
!if DEBUG >= 2 { +prStr : !text "ucLen=",0 : +prWord reqLen : +crout }
|
||||
; Load the bytecode of the gamelib (first) bytecode module at the highest possible point
|
||||
; (to reduce fragmentation of the rest of aux mem)
|
||||
lda resType
|
||||
|
@ -24,6 +24,7 @@ const SECTION_HEIGHT_2D = 23
|
||||
|
||||
const specPtr = $BC // must match asm definition below for pSpecials
|
||||
const specScanFor = $BE // must match asm definition below for scanFor
|
||||
const specGodMask = $BF // must match asm definition below for godMask
|
||||
|
||||
struc TMapSection
|
||||
byte bm_mapNum
|
||||
@ -63,7 +64,7 @@ word pAllMarks
|
||||
word pSpecialsBuf
|
||||
word pSpecialTiles
|
||||
word scanSpecials = $100 // placed at $100 so it can easily access aux mem
|
||||
word pSpecTiles
|
||||
word specTileset
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Definitions used by assembly code
|
||||
@ -90,6 +91,7 @@ pSrc = $B8 ; length 2
|
||||
pDst = $BA ; length 2
|
||||
pSpecials = $BC ; length 2
|
||||
scanFor = $BE ; length 1
|
||||
godMask = $BF ; length 1
|
||||
|
||||
HB = evalStkH-evalStkL ; offset to get from lo byte to hi byte on eval stack
|
||||
|
||||
@ -308,18 +310,27 @@ asm fillRow(mapRowData, mask, tileTrans, pSmallTiles, pSpecialTiles, blankTile,
|
||||
.loop
|
||||
ldy .srcOff
|
||||
lda (pSrc),y ; get raw data
|
||||
iny
|
||||
sty .srcOff
|
||||
ora godMask ; mask in show-all mode
|
||||
asl
|
||||
bpl .blank ; skip unless $40 bit is set denoting this space has been seen
|
||||
lsr
|
||||
pha
|
||||
lda pSpecials+1
|
||||
pha
|
||||
lda pSpecials
|
||||
pha
|
||||
jsr $100 ; scan for automap specials override
|
||||
sta .special
|
||||
beq +
|
||||
dex ; to use pSpecialTiles instead of pSmallTiles
|
||||
bpl .got ; always taken
|
||||
+ pla ; normal processing (no special override)
|
||||
tay
|
||||
pla
|
||||
sta pSpecials
|
||||
pla
|
||||
sta pSpecials+1
|
||||
pla
|
||||
dex ; index pSpecialTiles instead of pSmallTiles
|
||||
cpy #0
|
||||
bne .notrans ; ... if it's a special tile
|
||||
inx ; otherwise, normal processing (no special override)
|
||||
and .param_mask,x ; mask to get just tile number
|
||||
beq .blank
|
||||
tay
|
||||
@ -330,14 +341,13 @@ asm fillRow(mapRowData, mask, tileTrans, pSmallTiles, pSpecialTiles, blankTile,
|
||||
asl
|
||||
tay
|
||||
lda (pTmp),y
|
||||
.got
|
||||
tay
|
||||
.notrans
|
||||
dey ; tileNum - 1
|
||||
dey ; tileNum - 1
|
||||
lda #0
|
||||
sta tmp+1
|
||||
sty tmp
|
||||
tya ; multiply by 9 bytes per reduced tile in the tileset
|
||||
tya ; multiply by 9 bytes per reduced tile in the tileset
|
||||
asl
|
||||
rol tmp+1
|
||||
asl
|
||||
@ -347,15 +357,15 @@ asm fillRow(mapRowData, mask, tileTrans, pSmallTiles, pSpecialTiles, blankTile,
|
||||
adc tmp
|
||||
bcc +
|
||||
inc tmp+1
|
||||
+ clc
|
||||
adc .param_pSmallTiles,x ; X may have been adjusted to address pSpecialTiles instead
|
||||
+ clc ; X may have been adjusted to address pSpecialTiles instead
|
||||
adc .param_pSmallTiles,x
|
||||
pha
|
||||
lda tmp+1
|
||||
adc .param_pSmallTiles+HB,x
|
||||
ldy .special
|
||||
beq +
|
||||
inx ; back to using normal pSmallTiles
|
||||
+ bcc .store ; always taken
|
||||
inx ; back to using normal pSmallTiles
|
||||
+ bcc .store ; always taken
|
||||
.blank
|
||||
lda .param_blankTile,x
|
||||
pha
|
||||
@ -370,6 +380,7 @@ asm fillRow(mapRowData, mask, tileTrans, pSmallTiles, pSpecialTiles, blankTile,
|
||||
iny
|
||||
iny
|
||||
sty .dstOff
|
||||
inc .srcOff
|
||||
dec .param_width,x
|
||||
bne .loop
|
||||
rts
|
||||
@ -508,11 +519,6 @@ asm _scanSpecials_start()#0
|
||||
!zone {
|
||||
; This gets copied to and run from $100 so it can easily access aux mem
|
||||
sta setAuxRd
|
||||
|
||||
lda #$60
|
||||
sta 0
|
||||
jsr 0 ; FOO
|
||||
|
||||
.loop
|
||||
ldy #0
|
||||
lda (pSpecials),y
|
||||
@ -550,7 +556,7 @@ def loadMarks()#0
|
||||
pSpecialsBuf = auxMmgr(QUEUE_LOAD, CODE_GEN_MAP_SPECIALS<<8 | RES_TYPE_CODE)
|
||||
|
||||
// While we're at it, load the automap special tiles.
|
||||
pSpecTiles = mmgr(QUEUE_LOAD, 2<<8 | RES_TYPE_TILESET) // always tileset 2 (just after global tiles)
|
||||
specTileset = mmgr(QUEUE_LOAD, 2<<8 | RES_TYPE_TILESET) // always tileset 2 (just after global tiles)
|
||||
mmgr(FINISH_LOAD, 0)
|
||||
|
||||
// Call the automark write routine. This has not only the effect of flushing the marks
|
||||
@ -563,7 +569,7 @@ def loadMarks()#0
|
||||
memcpy($4002, pAllMarks, len, 1)
|
||||
|
||||
// Figure out where the small versions of the special tiles reside (at the end of the full size tiles)
|
||||
pSpecialTiles = pSpecialsBuf + 1 + ((^pSpecialsBuf) << 5)
|
||||
pSpecialTiles = specTileset + 1 + ((^specTileset) << 5)
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -737,7 +743,7 @@ def displaySection3D(pSection, pSmallTiles)#0
|
||||
// Display each visible row
|
||||
for y = 1 to pSection->bm_ch // offset is 1 to skip over sentinel row
|
||||
*specPtr = specBlk
|
||||
^specScanFor = y + pSection->wm_y0
|
||||
^specScanFor = y + pSection->bm_oy - 1
|
||||
scanSpecials()#0
|
||||
displayRow3D(getScreenLine(line) + lx, rowData, tileTrans, pSmallTiles, pSpecialTiles, pSection->bm_cw)
|
||||
rowData = rowData + rowSize
|
||||
@ -747,7 +753,7 @@ end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
def displaySection2D(pSection, pSmallTiles)#0
|
||||
word rowData
|
||||
word rowData, specBlk
|
||||
byte y, line, lx
|
||||
|
||||
// Merge automap marks into the data if not done yet
|
||||
@ -767,9 +773,13 @@ def displaySection2D(pSection, pSmallTiles)#0
|
||||
*specPtr = pSpecialsBuf
|
||||
^specScanFor = pSection->bm_mapNum
|
||||
scanSpecials()#0
|
||||
specBlk = *specPtr
|
||||
|
||||
// Display each visible row
|
||||
for y = 1 to pSection->bm_ch
|
||||
*specPtr = specBlk
|
||||
^specScanFor = y + pSection->bm_oy - 1
|
||||
scanSpecials()#0
|
||||
displayRow2D(getScreenLine(line) + lx, rowData, pSmallTiles, pSpecialTiles, pSection->bm_cw)
|
||||
rowData = rowData + SECTION_WIDTH_2D
|
||||
line = line + 8
|
||||
@ -969,6 +979,7 @@ def _automap_show()#1
|
||||
centerScreen
|
||||
loadMarks
|
||||
prepSections(0,0)
|
||||
^specGodMask = 0
|
||||
displaySections
|
||||
|
||||
// Now allow the player to scroll the map
|
||||
@ -1003,12 +1014,27 @@ def _automap_show()#1
|
||||
scrollRight(8)
|
||||
fin
|
||||
break
|
||||
is '*'
|
||||
if global->b_godmode
|
||||
^specGodMask = ^specGodMask ^ $40 // toggle display-all
|
||||
prepSections(0,0)
|
||||
displaySections
|
||||
fin
|
||||
break
|
||||
wend
|
||||
until key == 27 or key == 'Q' or key == '-' // esc or Q or - to exit
|
||||
|
||||
// Free up stuff we allocated or loaded
|
||||
auxMmgr(FREE_MEMORY, pAllMarks)
|
||||
auxMmgr(FREE_MEMORY, pSpecialsBuf)
|
||||
mmgr(FREE_MEMORY, pSpecTiles)
|
||||
mmgr(FREE_MEMORY, specTileset)
|
||||
|
||||
// Ensure the global tileset is reloaded (otherwise tile eng will try to load it from wrong partition)
|
||||
mmgr(START_LOAD, 1)
|
||||
pGlobalTileset = mmgr(QUEUE_LOAD, 1<<8 | RES_TYPE_TILESET)
|
||||
mmgr(FINISH_LOAD, 0)
|
||||
|
||||
// All done.
|
||||
return 0
|
||||
end
|
||||
|
||||
|
@ -158,6 +158,7 @@ import gamelib
|
||||
word pCurMap
|
||||
byte curMapPartition
|
||||
word pResourceIndex
|
||||
word pGlobalTileset
|
||||
|
||||
/////////// Shared string constants //////////////
|
||||
|
||||
|
@ -115,7 +115,7 @@ byte allowZoneInit = FALSE
|
||||
word curEngine = NULL
|
||||
word pIntimate = NULL
|
||||
export word pResourceIndex = NULL
|
||||
word pGlobalTileset = NULL
|
||||
export word pGlobalTileset = NULL
|
||||
export byte curMapPartition = 0
|
||||
export word pGodModule = NULL
|
||||
export word typeHash = 0
|
||||
|
Loading…
Reference in New Issue
Block a user