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