mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-09-09 02:54:37 +00:00
More refactoring.
This commit is contained in:
parent
03e27aaa76
commit
efe2415098
@ -6,10 +6,9 @@ const NULL = 0
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Fixed memory locations
|
// Fixed memory locations
|
||||||
const raycaster = $6000 // main mem
|
const displayEngine = $6000 // main mem (raycaster and tile engine at same location)
|
||||||
const tileEngine = $6000 // main mem
|
const expandVec = $2000 // aux mem (only for raycaster)
|
||||||
const expandVec = $2000 // aux mem
|
const fontEngine = $BA00 // main mem
|
||||||
const fontEngine = $BA00 // main mem
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Resource numbers
|
// Resource numbers
|
||||||
@ -102,6 +101,15 @@ byte textDrawn = FALSE
|
|||||||
word skyNum = 9
|
word skyNum = 9
|
||||||
word groundNum = 10
|
word groundNum = 10
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// API to call rendering engine (same API for raycaster and tile engine)
|
||||||
|
const initDisplay = displayEngine + 0 // params: pMapData, x, y, dir; return: map name (as C str)
|
||||||
|
const flipToPage1 = displayEngine + 3 // params: none; return: nothing
|
||||||
|
const getPos = displayEngine + 6 // params: @x, @y, @dir; return: nothing
|
||||||
|
const setPos = displayEngine + 9 // params: x (0-255), y (0-255), dir (0-15); return: nothing
|
||||||
|
const advance = displayEngine + 12 // params: none; return: 1 if new pos *and* scripted
|
||||||
|
const setColor = displayEngine + 15 // params: slot (0=sky/1=ground), color (0-15); return: nothing
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Definitions used by assembly code
|
// Definitions used by assembly code
|
||||||
asm __defs
|
asm __defs
|
||||||
@ -252,7 +260,7 @@ asm goMon
|
|||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Jump straight to the system monitor
|
// Execute a monitor breakpoint
|
||||||
// Params: None
|
// Params: None
|
||||||
asm brk
|
asm brk
|
||||||
bit setROM
|
bit setROM
|
||||||
@ -461,15 +469,6 @@ def debugMem(bank)
|
|||||||
^$c050
|
^$c050
|
||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Clear the command table
|
|
||||||
def resetCmds()
|
|
||||||
byte i
|
|
||||||
for i = 0 to 63
|
|
||||||
cmdTbl[i] = 0
|
|
||||||
next
|
|
||||||
end
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Establish a keystroke -> command association in the command table
|
// Establish a keystroke -> command association in the command table
|
||||||
def initCmd(key, func)
|
def initCmd(key, func)
|
||||||
@ -495,7 +494,7 @@ end
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Load code and data, set up everything to display a 3D map
|
// Load code and data, set up everything to display a 3D map
|
||||||
def initMap3D(x, y, dir)
|
def initMap(x, y, dir)
|
||||||
word scriptModule
|
word scriptModule
|
||||||
|
|
||||||
// Set up the command table
|
// Set up the command table
|
||||||
@ -504,24 +503,22 @@ def initMap3D(x, y, dir)
|
|||||||
// Reset memory (our module will stay since memory manager locked it upon load)
|
// Reset memory (our module will stay since memory manager locked it upon load)
|
||||||
loader(RESET_MEMORY, MAIN_MEM, 0)
|
loader(RESET_MEMORY, MAIN_MEM, 0)
|
||||||
|
|
||||||
// Load the font engine
|
// Load the font engine and its font
|
||||||
loader(SET_MEM_TARGET, MAIN_MEM, fontEngine)
|
loader(SET_MEM_TARGET, MAIN_MEM, fontEngine)
|
||||||
loader(QUEUE_LOAD, MAIN_MEM, RES_NUM_FONT_ENGINE<<8 | RES_TYPE_CODE)
|
loader(QUEUE_LOAD, MAIN_MEM, RES_NUM_FONT_ENGINE<<8 | RES_TYPE_CODE)
|
||||||
|
|
||||||
// Load the font for the font engine
|
|
||||||
loader(SET_MEM_TARGET, MAIN_MEM, $9000)
|
loader(SET_MEM_TARGET, MAIN_MEM, $9000)
|
||||||
pFont = loader(QUEUE_LOAD, MAIN_MEM, 1<<8 | RES_TYPE_FONT)
|
pFont = loader(QUEUE_LOAD, MAIN_MEM, 1<<8 | RES_TYPE_FONT)
|
||||||
|
|
||||||
// Load the raycaster
|
// Queue loading of the raycaster or tile engine and the map data
|
||||||
loader(SET_MEM_TARGET, MAIN_MEM, raycaster)
|
loader(SET_MEM_TARGET, MAIN_MEM, displayEngine)
|
||||||
loader(QUEUE_LOAD, MAIN_MEM, RES_NUM_RAYCASTER<<8 | RES_TYPE_CODE)
|
if mapIs3D
|
||||||
|
loader(QUEUE_LOAD, MAIN_MEM, RES_NUM_RAYCASTER<<8 | RES_TYPE_CODE)
|
||||||
// Load the texture expansion code
|
pMap = loader(QUEUE_LOAD, MAIN_MEM, mapNum<<8 | RES_TYPE_3D_MAP)
|
||||||
loader(SET_MEM_TARGET, AUX_MEM, expandVec)
|
else
|
||||||
loader(QUEUE_LOAD, AUX_MEM, RES_NUM_EXPAND_VEC<<8 | RES_TYPE_CODE)
|
loader(QUEUE_LOAD, MAIN_MEM, RES_NUM_TILE_ENGINE<<8 | RES_TYPE_CODE)
|
||||||
|
pMap = loader(QUEUE_LOAD, MAIN_MEM, mapNum<<8 | RES_TYPE_2D_MAP)
|
||||||
// Load the map
|
fin
|
||||||
pMap = loader(QUEUE_LOAD, MAIN_MEM, mapNum<<8 | RES_TYPE_3D_MAP)
|
|
||||||
|
|
||||||
// Load everything that we just queued
|
// Load everything that we just queued
|
||||||
loader(FINISH_LOAD, MAIN_MEM, 1) // 1 = keep open
|
loader(FINISH_LOAD, MAIN_MEM, 1) // 1 = keep open
|
||||||
@ -539,13 +536,8 @@ def initMap3D(x, y, dir)
|
|||||||
// Start up the font engine
|
// Start up the font engine
|
||||||
initFontEngine(pFont)
|
initFontEngine(pFont)
|
||||||
|
|
||||||
// Start up the raycaster
|
// Start up the display engine with map data and starting position
|
||||||
initDisplayEngine(pMap)
|
cMapName = initDisplay(pMap, x, y, dir)
|
||||||
|
|
||||||
// Set initial player position in case the init script doesn't do it
|
|
||||||
^playerDir = 1
|
|
||||||
*playerX = $280
|
|
||||||
*playerY = $380
|
|
||||||
|
|
||||||
// Initialize the map scripts
|
// Initialize the map scripts
|
||||||
setWindow2()
|
setWindow2()
|
||||||
@ -558,66 +550,6 @@ def initMap3D(x, y, dir)
|
|||||||
if pScripts
|
if pScripts
|
||||||
*pScripts()
|
*pScripts()
|
||||||
fin
|
fin
|
||||||
|
|
||||||
// Draw the first frame
|
|
||||||
renderFrame()
|
|
||||||
redraw = FALSE
|
|
||||||
end
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Load code and data, set up everything to display a 2D map
|
|
||||||
def initMap2D()
|
|
||||||
|
|
||||||
// Set up the command table
|
|
||||||
initCmds2D()
|
|
||||||
|
|
||||||
// Reset memory (our module will stay since memory manager locked it upon load)
|
|
||||||
loader(RESET_MEMORY, MAIN_MEM, 0)
|
|
||||||
|
|
||||||
// Load the font engine
|
|
||||||
loader(SET_MEM_TARGET, MAIN_MEM, fontEngine)
|
|
||||||
loader(QUEUE_LOAD, MAIN_MEM, RES_NUM_FONT_ENGINE<<8 | RES_TYPE_CODE)
|
|
||||||
|
|
||||||
// Load the font for the font engine
|
|
||||||
loader(SET_MEM_TARGET, MAIN_MEM, $9000)
|
|
||||||
pFont = loader(QUEUE_LOAD, MAIN_MEM, 1<<8 | RES_TYPE_FONT)
|
|
||||||
|
|
||||||
// Load the tile engine
|
|
||||||
loader(SET_MEM_TARGET, MAIN_MEM, tileEngine)
|
|
||||||
loader(QUEUE_LOAD, MAIN_MEM, RES_NUM_TILE_ENGINE<<8 | RES_TYPE_CODE)
|
|
||||||
|
|
||||||
// Load everything that we just queued
|
|
||||||
loader(FINISH_LOAD, MAIN_MEM, 1) // 1 = keep open
|
|
||||||
|
|
||||||
// Load the frame image (and lock it there)
|
|
||||||
loadFrameImg()
|
|
||||||
|
|
||||||
// Start up the font engine
|
|
||||||
initFontEngine(pFont)
|
|
||||||
|
|
||||||
// For now
|
|
||||||
prevX = -1
|
|
||||||
prevY = -1
|
|
||||||
triggerTbl = NULL
|
|
||||||
|
|
||||||
// Start up the tile engine
|
|
||||||
initDisplayEngine(mapNum)
|
|
||||||
|
|
||||||
// And do the first draw.
|
|
||||||
renderFrame()
|
|
||||||
redraw = FALSE
|
|
||||||
end
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Set up mapNum (2D or 3D depending on state of is3DMap)
|
|
||||||
def initMap(x, y, dir)
|
|
||||||
if mapIs3D
|
|
||||||
initMap3D(x, y, dir)
|
|
||||||
else
|
|
||||||
initMap2D(x, y, dir)
|
|
||||||
fin
|
|
||||||
prevMapNum = mapNum
|
|
||||||
prevMapIs3D = mapIs3D
|
|
||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -653,16 +585,6 @@ def setWindow3()
|
|||||||
^cursh = ^wndleft
|
^cursh = ^wndleft
|
||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Make sure page 1 of hi-res is displayed. Do this before doing memory manager operations, since
|
|
||||||
// they overwrite page 2.
|
|
||||||
def flipToFirstPage
|
|
||||||
if ^frontBuf == 1
|
|
||||||
renderFrame()
|
|
||||||
redraw = FALSE
|
|
||||||
fin
|
|
||||||
end
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
def callScripts(x, y)
|
def callScripts(x, y)
|
||||||
word p
|
word p
|
||||||
@ -712,7 +634,7 @@ def checkScripts()
|
|||||||
if isScripted()
|
if isScripted()
|
||||||
callScripts(x, y)
|
callScripts(x, y)
|
||||||
if (mapNum <> prevMapNum) or (mapIs3D <> prevMapIs3D)
|
if (mapNum <> prevMapNum) or (mapIs3D <> prevMapIs3D)
|
||||||
flipToFirstPage()
|
flipToPage1()
|
||||||
initMap()
|
initMap()
|
||||||
fin
|
fin
|
||||||
fin
|
fin
|
||||||
@ -871,38 +793,40 @@ end
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Set up the command table for 3D mode
|
// Set up the command table for 3D mode
|
||||||
def initCmds3D()
|
def initCmds3D()
|
||||||
resetCmds()
|
|
||||||
|
|
||||||
initCmd('W', @moveForward)
|
// Clear the command table
|
||||||
initCmd('A', @rotateLeft)
|
byte i
|
||||||
initCmd('D', @rotateRight)
|
for i = 0 to 63
|
||||||
initCmd('S', @moveBackward)
|
cmdTbl[i] = 0
|
||||||
initCmd('X', @moveBackward)
|
next
|
||||||
initCmd('Z', @strafeLeft)
|
|
||||||
initCmd('C', @strafeRight)
|
|
||||||
|
|
||||||
initCmd('I', @moveForward)
|
// Handle 3D vs 2D commands separately
|
||||||
initCmd('J', @rotateLeft)
|
if mapIs3D
|
||||||
initCmd('L', @rotateRight)
|
initCmd('W', @moveForward)
|
||||||
initCmd('K', @moveBackward)
|
initCmd('A', @rotateLeft)
|
||||||
initCmd(',', @moveBackward)
|
initCmd('D', @rotateRight)
|
||||||
initCmd('M', @strafeLeft)
|
initCmd('S', @moveBackward)
|
||||||
initCmd('.', @strafeRight)
|
initCmd('X', @moveBackward)
|
||||||
|
initCmd('Z', @strafeLeft)
|
||||||
|
initCmd('C', @strafeRight)
|
||||||
|
|
||||||
initCmd('Y', @nextSky)
|
initCmd('I', @moveForward)
|
||||||
initCmd('G', @nextGround)
|
initCmd('J', @rotateLeft)
|
||||||
end
|
initCmd('L', @rotateRight)
|
||||||
|
initCmd('K', @moveBackward)
|
||||||
|
initCmd(',', @moveBackward)
|
||||||
|
initCmd('M', @strafeLeft)
|
||||||
|
initCmd('.', @strafeRight)
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
initCmd('Y', @nextSky)
|
||||||
// Set up the command table for 2D mode
|
initCmd('G', @nextGround)
|
||||||
def initCmds2D()
|
else
|
||||||
resetCmds()
|
initCmd('W', @moveNorth)
|
||||||
|
initCmd('D', @moveEast)
|
||||||
initCmd('W', @moveNorth)
|
initCmd('S', @moveSouth)
|
||||||
initCmd('D', @moveEast)
|
initCmd('X', @moveSouth)
|
||||||
initCmd('S', @moveSouth)
|
initCmd('A', @moveWest)
|
||||||
initCmd('X', @moveSouth)
|
end
|
||||||
initCmd('A', @moveWest)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1986,6 +1986,18 @@ pl_setColor: !zone
|
|||||||
inx ; toss unused stack slot (parms=2, ret=1, diff=1)
|
inx ; toss unused stack slot (parms=2, ret=1, diff=1)
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
;-------------------------------------------------------------------------------
|
||||||
|
; Load texture expansion code into aux mem
|
||||||
|
loadExpand: !zone
|
||||||
|
lda #SET_MEM_TARGET
|
||||||
|
ldx #<expandVec
|
||||||
|
ldy #>expandVec
|
||||||
|
jsr auxLoader
|
||||||
|
lda #QUEUE_LOAD
|
||||||
|
ldx #RES_TYPE_TEXTURE
|
||||||
|
ldy #RES_NUM_EXPAND_VEC
|
||||||
|
jmp auxLoader
|
||||||
|
|
||||||
;-------------------------------------------------------------------------------
|
;-------------------------------------------------------------------------------
|
||||||
; The real action
|
; The real action
|
||||||
pl_initMap: !zone
|
pl_initMap: !zone
|
||||||
@ -2000,6 +2012,7 @@ pl_initMap: !zone
|
|||||||
jsr pl_setPos
|
jsr pl_setPos
|
||||||
; Proceed with loading
|
; Proceed with loading
|
||||||
bit setROM ; switch out PLASMA while we work
|
bit setROM ; switch out PLASMA while we work
|
||||||
|
jsr loadExpand
|
||||||
jsr loadTextures
|
jsr loadTextures
|
||||||
jsr copyScreen
|
jsr copyScreen
|
||||||
lda tablesInitted
|
lda tablesInitted
|
||||||
|
Loading…
Reference in New Issue
Block a user