Clipping is actually working now (for 3D maps at least).

This commit is contained in:
Martin Haye 2018-03-11 15:21:00 -07:00
parent ae7d885a9e
commit 2151819d95

View File

@ -11,11 +11,11 @@
include "gamelib.plh" include "gamelib.plh"
include "globalDefs.plh" include "globalDefs.plh"
const MAP_TOP = 8 // lines const MAP_TOP = 11 // lines
const MAP_LEFT = 2 // bytes const MAP_LEFT = 2 // bytes
const SCREEN_ROWS = 22 const SCREEN_ROWS = 21
const SCREEN_COLS = 38 const SCREEN_COLS = 36
struc MapSection struc MapSection
byte b_mapNum byte b_mapNum
@ -268,11 +268,11 @@ def displaySection3D(pSection)#0
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
// Display each visible row // Display each visible row
for y = 0 to pSection->b_ch - 1 for y = 1 to pSection->b_ch // offset is 1 to skip over sentinel row
// 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 = mapData + ((y + pSection->b_oy + 1) * rowSize) + pSection->b_ox + 1 rowData = mapData + ((y + pSection->b_oy) * 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-8)) + MAP_LEFT + pSection->b_sx
displayRow(pScreen, rowData, tileTrans, pSmallTiles, pSection->b_cw) displayRow(pScreen, rowData, tileTrans, pSmallTiles, pSection->b_cw)
next next
end end
@ -294,8 +294,7 @@ end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
def _automap_show()#1 def _automap_show()#1
setBigWindow byte key
clearWindow
// Clear out the blank tile buffer // Clear out the blank tile buffer
memset(@blankTile, 0, 9) memset(@blankTile, 0, 9)
@ -309,7 +308,13 @@ def _automap_show()#1
screenX1 = SCREEN_COLS screenX1 = SCREEN_COLS
screenY1 = SCREEN_ROWS screenY1 = SCREEN_ROWS
repeat
setBigWindow
clearWindow
// Calculate visiblity and load maps+tilesets // Calculate visiblity and load maps+tilesets
printf2("Screen: %d/%d - ", screenX0, screenY0)
printf2("%d/%d\n", screenX1, screenY1)
prepSections prepSections
// Display everything visible // Display everything visible
@ -319,7 +324,27 @@ def _automap_show()#1
freeSections freeSections
// All done. // All done.
getUpperKey key = getUpperKey
when key
// Equip/unequip player with weapon/armor
is 'I'
screenY0++
screenY1++
break
is 'J'
screenX0++
screenX1++
break
is 'K'
screenX0--
screenX1--
break
is 'M'
screenY0--
screenY1--
break
wend
until key == 27 // esc
return 0 return 0
end end