Debugging new refactored automap.

This commit is contained in:
Martin Haye 2018-03-11 12:26:12 -07:00
parent a82cef30cc
commit d5ce5197e7

View File

@ -23,11 +23,16 @@ struc MapSection
byte b_tilesetNum byte b_tilesetNum
word p_tileset word p_tileset
byte b_visible byte b_visible
word w_x0, w_y0 // upper-left coord of map in global space word w_x0 // upper-left coord of map in global space
word w_x1, w_y1 // bottom-right coord of map (exclusive) in global space word w_y0
byte b_sx, b_sy // clipped screen coordinate word w_x1 // bottom-right coord of map (exclusive) in global space
byte b_ox, b_oy // clipped offset within map to display word w_y1
byte b_cw, b_ch // clipped size within map to display byte b_sx // clipped screen coordinate
byte b_sy
byte b_ox // clipped offset within map to display
byte b_oy
byte b_cw // clipped size within map to display
byte b_ch
end end
const MAX_SECT = 40 const MAX_SECT = 40
@ -44,7 +49,7 @@ byte blankTile[9]
word screenX0, screenY0, screenX1, screenY1 word screenX0, screenY0, screenX1, screenY1
byte nSections byte nSections
byte sectionBuf[MAX_SECT_BUF] byte sectionBuf[SECT_BUF_SIZE]
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Definitions used by assembly code // Definitions used by assembly code
@ -151,7 +156,7 @@ asm drawSlice(pBlank, pScreen, nTiles, tilePtrs)#0
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
def displayRow(rowNum, mapRowData, tileTrans, pSmallTiles, width)#0 def displayRow(pScreen, mapRowData, tileTrans, pSmallTiles, width)#0
byte x, mapRaw, tileNum byte x, mapRaw, tileNum
for x = 0 to width-1 for x = 0 to width-1
mapRaw = ^(mapRowData + x) & $1F mapRaw = ^(mapRowData + x) & $1F
@ -162,13 +167,13 @@ def displayRow(rowNum, mapRowData, tileTrans, pSmallTiles, width)#0
tilePtrs[x] = @blankTile tilePtrs[x] = @blankTile
fin fin
next next
drawSlice(@blankTile, getScreenLine((rowNum+2)<<3) + 2, width, @tilePtrs) drawSlice(@blankTile, pScreen, width, @tilePtrs)
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
def make3DSection(pSection)#0 def make3DSection(pSection)#0
// Record the map data (it's already loaded for 3D display) // Record the map data (it's already loaded for 3D display)
pSection->b_mapNum = curMapNum pSection->b_mapNum = mapNum
pSection=>p_map = pCurMap pSection=>p_map = pCurMap
// Record the tile set number // Record the tile set number
@ -182,6 +187,20 @@ def make3DSection(pSection)#0
pSection=>w_y1 = totalMapHeight pSection=>w_y1 = totalMapHeight
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
def printSection(pSection)#0
printf1("Sect %d: ", (pSection - @sectionBuf) / MapSection)
printf2("%d/%d - ", pSection=>w_x0, pSection=>w_y0)
printf2("%d/%d; ", pSection=>w_x1, pSection=>w_y1)
printf1("vis=%d ", pSection->b_visible)
if pSection->b_visible
printf2("scrn=%d/%d ", pSection->b_sx, pSection->b_sy)
printf2("off=%d/%d ", pSection->b_ox, pSection->b_oy)
printf2("clip=%dw/%dh", pSection->b_cw, pSection->b_ch)
fin
puts(".\n")
end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
def prepSections#0 def prepSections#0
byte i byte i
@ -234,16 +253,16 @@ def freeSections#0
pSection=>p_tileset = NULL pSection=>p_tileset = NULL
fin fin
pSection = pSection + MapSection pSection = pSection + MapSection
end next
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
def displaySection3D(pSection)#0 def displaySection3D(pSection)#0
word pSmallTiles, tileTrans, mapData word pSmallTiles, tileTrans, mapData, rowData, pScreen
byte nTextures, y, rowSize, rowData, pScreen byte nTextures, y, rowSize
// Figure out where the small tiles reside (at the end of the full size tiles) // Figure out where the small tiles reside (at the end of the full size tiles)
pSmallTiles = pSection=>p_tileset + 1 + ((^(pSection=>pTileset)) << 5) pSmallTiles = pSection=>p_tileset + 1 + ((^(pSection=>p_tileset)) << 5)
// Extract significant pointers from the map blob // Extract significant pointers from the map blob
rowSize = ^(pSection=>p_map) rowSize = ^(pSection=>p_map)
@ -253,12 +272,11 @@ def displaySection3D(pSection)#0
nTextures++ nTextures++
loop loop
mapData = tileTrans + (nTextures*3) + 2 // *2 for tilenum+texnum, *1 for texture flags, 2 for zero-terms mapData = tileTrans + (nTextures*3) + 2 // *2 for tilenum+texnum, *1 for texture flags, 2 for zero-terms
printf2("mapData=$%x, rowSize=%d\n", mapData, rowSize) // FOO
// Display each visible row // Display each visible row
for y = 0 to pSection->b_ch - 1 for y = 0 to pSection->b_ch - 1
// The +1's below are to skip over the sentinel row and column that 3D maps have // The +1's below are to skip over the sentinel row and column that 3D maps have
rowData = ((y + pSection->b_oy + 1) * rowSize) + pSection->b_ox + 1 rowData = mapData + ((y + pSection->b_oy + 1) * rowSize) + pSection->b_ox + 1
// The << 3 below is because each row is 8 screen lines // The << 3 below is because each row is 8 screen lines
pScreen = getScreenLine(((y + pSection->b_sy) << 3) + MAP_TOP) + MAP_LEFT + pSection->b_sx pScreen = getScreenLine(((y + pSection->b_sy) << 3) + MAP_TOP) + MAP_LEFT + pSection->b_sx
displayRow(pScreen, rowData, tileTrans, pSmallTiles, pSection->b_cw) displayRow(pScreen, rowData, tileTrans, pSmallTiles, pSection->b_cw)
@ -272,6 +290,7 @@ def displaySections#0
pSection = @sectionBuf pSection = @sectionBuf
for i = 0 to nSections-1 for i = 0 to nSections-1
printSection(pSection)
if pSection->b_visible if pSection->b_visible
if mapIs3D if mapIs3D
displaySection3D(pSection) displaySection3D(pSection)
@ -280,7 +299,7 @@ def displaySections#0
fin fin
fin fin
pSection = pSection + MapSection pSection = pSection + MapSection
end next
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////