More prototypes.

This commit is contained in:
Martin Haye 2017-06-10 07:32:31 -07:00
parent 3ac73e7165
commit eea4767a51
3 changed files with 41 additions and 30 deletions

View File

@ -3974,7 +3974,8 @@ end
def facing = blk.field[3].text().toInteger() def facing = blk.field[3].text().toInteger()
assert facing >= 0 && facing <= 15 assert facing >= 0 && facing <= 15
outIndented("return queue_setMap(${mapNum[0] == '2D' ? 0 : 1}, ${mapNum[1]}, $x, $y, $facing)\n") outIndented("queue_setMap(${mapNum[0] == '2D' ? 0 : 1}, ${mapNum[1]}, $x, $y, $facing)\n")
outIndented("return 0\n")
} }
def packSetPortrait(blk) def packSetPortrait(blk)

View File

@ -49,7 +49,7 @@ import gamelib
predef getDir() predef getDir()
predef getGameFlag predef getGameFlag
predef getPos(px, py)#0 predef getPos(px, py)#0
predef getStat predef getStat(player, statName)
predef getStringResponse predef getStringResponse
predef getUpperKey predef getUpperKey
predef getYN predef getYN
@ -110,11 +110,11 @@ import gamelib
predef setPortrait predef setPortrait
predef setScriptInfo(mapName, trigTbl, wdt, hgt)#0 predef setScriptInfo(mapName, trigTbl, wdt, hgt)#0
predef setSky(num)#0 predef setSky(num)#0
predef setStat predef setStat(player, statName, val)#0
predef setWindow predef setWindow
predef setWindow1 predef setWindow1()#0
predef setWindow2 predef setWindow2()#0
predef setWindow3 predef setWindow3()#0
predef showMapName predef showMapName
predef showParty predef showParty
predef sprintf1(fmt, arg1) predef sprintf1(fmt, arg1)
@ -124,7 +124,7 @@ import gamelib
predef strncpy predef strncpy
predef takeItemFromPlayer predef takeItemFromPlayer
predef textHome predef textHome
predef tossStrings predef tossStrings()#0
predef unbenchPlayer predef unbenchPlayer
// This pointer is the root of all heap-tracked (and garbage collected) objects. // This pointer is the root of all heap-tracked (and garbage collected) objects.

View File

@ -49,8 +49,19 @@ export word global // the global heap object, from which all live objects must
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Predefined functions, for circular calls or out-of-order calls // Predefined functions, for circular calls or out-of-order calls
predef setWindow2, initCmds, nextAnimFrame, checkEncounter, doCombat, clearPortrait, showMapName predef setWindow2()#0
predef doRender, playerDeath, startGame, showAnimFrame, finalWin, showParty predef initCmds()#0
predef nextAnimFrame()#0
predef checkEncounter(x, y, force)#0
predef doCombat(mapCode, backUpOnFlee)
predef clearPortrait()#0
predef showMapName(mapName)#0
predef doRender()#0
predef playerDeath()#0
predef startGame(ask)#0
predef showAnimFrame()#0
predef finalWin()#0
predef showParty()#0
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Global variables // Global variables
@ -163,18 +174,17 @@ end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Temporary hack: after scriptDisplayStr is called, generated code calls this to clear the PLASMA // Temporary hack: after scriptDisplayStr is called, generated code calls this to clear the PLASMA
// string pool. That way, many long strings can be used in a single function. // string pool. That way, many long strings can be used in a single function.
export asm tossStrings export asm tossStrings#0
lda framePtr lda framePtr
sta outerFramePtr sta outerFramePtr
lda framePtr+1 lda framePtr+1
sta outerFramePtr+1 sta outerFramePtr+1
dex
rts rts
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// API to call rendering engine (same API for raycaster and tile engine) // API to call rendering engine (same API for raycaster and tile engine)
asm initDisplay#0 // params: mapNum, pMapData, x, y, dir asm initDisplay(mapNum, pMapData, x, y, dir)#0
+asmPlasmNoRet 6 +asmPlasmNoRet 6
jmp $6000 jmp $6000
end end
@ -194,8 +204,8 @@ export asm getDir // no params; returns: dir (0-15)
+asmPlasmRet 0 +asmPlasmRet 0
jmp $600C jmp $600C
end end
asm setDir // params: dir (0-15) asm setDir#0 // params: dir (0-15)
+asmPlasmRet 1 +asmPlasmNoRet 1
jmp $600F jmp $600F
end end
asm advance // no params; return: 0 if same pos, 1 if new pos, 2 if new pos and scripted asm advance // no params; return: 0 if same pos, 1 if new pos, 2 if new pos and scripted
@ -1319,21 +1329,21 @@ end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Window for the map name bar // Window for the map name bar
export def setWindow1() export def setWindow1()#0
setWindow(8, 17, 35, 119) // Top, Bottom, Left, Right setWindow(8, 17, 35, 119) // Top, Bottom, Left, Right
mapNameHash = 0 // on the assumption that it's being set because somebody's going to print there mapNameHash = 0 // on the assumption that it's being set because somebody's going to print there
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Window for the large upper right bar // Window for the large upper right bar
export def setWindow2() export def setWindow2()#0
displayChar('N'-$40) // Set normal mode - clear all special modes (like underline, etc.) displayChar('N'-$40) // Set normal mode - clear all special modes (like underline, etc.)
setWindow(24, 132, 154, 267) // Top, Bottom, Left, Right setWindow(24, 132, 154, 267) // Top, Bottom, Left, Right
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Window for the mid-size lower right bar // Window for the mid-size lower right bar
export def setWindow3() export def setWindow3()#0
setWindow(144, 180, 154, 267) // Top, Bottom, Left, Right setWindow(144, 180, 154, 267) // Top, Bottom, Left, Right
end end
@ -1393,7 +1403,7 @@ end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Display the party data on the screen // Display the party data on the screen
export def showParty() export def showParty()#0
word p word p
saveCursor() saveCursor()
@ -1598,7 +1608,7 @@ end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Display a portrait drawing (typically called from scripts) // Display a portrait drawing (typically called from scripts)
export def clearPortrait() export def clearPortrait()#0
if curPortrait if curPortrait
auxMmgr(FREE_MEMORY, curPortrait) auxMmgr(FREE_MEMORY, curPortrait)
curPortrait = NULL curPortrait = NULL
@ -1614,7 +1624,7 @@ end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Perform rendering, copy if necessary, clear appropriate flags // Perform rendering, copy if necessary, clear appropriate flags
def doRender() def doRender()#0
if curPortrait; clearPortrait(); fin if curPortrait; clearPortrait(); fin
if !texturesLoaded if !texturesLoaded
if mapIs3D if mapIs3D
@ -1846,7 +1856,7 @@ def hashString(str)
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
export def showMapName(mapName) export def showMapName(mapName)#0
word newNameHash word newNameHash
newNameHash = hashString(mapName) newNameHash = hashString(mapName)
@ -1939,7 +1949,7 @@ end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Show the current animation frame // Show the current animation frame
def showAnimFrame() def showAnimFrame()#0
if curPortrait if curPortrait
// Blit portrait to the appropriate area on the screen // Blit portrait to the appropriate area on the screen
if frameLoaded == 3 // 3D-mode frame? Note: don't check mapIs3D, because we might be in an engine if frameLoaded == 3 // 3D-mode frame? Note: don't check mapIs3D, because we might be in an engine
@ -1959,7 +1969,7 @@ end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Advance to next frame of current animation, if any // Advance to next frame of current animation, if any
def nextAnimFrame() def nextAnimFrame()#0
word flags word flags
if !anyAnims; return; fin if !anyAnims; return; fin
@ -2229,7 +2239,7 @@ export def scriptCombat(mapCode)
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
def playerDeath() def playerDeath()#0
callGlobalFunc(GS_DEATH, 0, 0, 0) callGlobalFunc(GS_DEATH, 0, 0, 0)
startGame(FALSE) // don't ask, just load startGame(FALSE) // don't ask, just load
end end
@ -2244,7 +2254,7 @@ def doCombat(mapCode, backUpOnFlee)
if (result == -99) if (result == -99)
playerDeath() playerDeath()
return return 0
fin fin
returnFromEngine(TRUE) returnFromEngine(TRUE)
@ -2257,7 +2267,7 @@ end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Check for a random encounter at this position // Check for a random encounter at this position
export def checkEncounter(x, y, force) export def checkEncounter(x, y, force)#0
word p word p
word p_bestZone, bestDist word p_bestZone, bestDist
word d word d
@ -2320,7 +2330,7 @@ def enableGodMode()
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
export def finalWin() export def finalWin()#0
flipToPage1() flipToPage1()
loadFrameImg(4) // total hack loadFrameImg(4) // total hack
while 1 // 1 infinite loop while 1 // 1 infinite loop
@ -2335,7 +2345,7 @@ end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Set up the command table for 3D mode // Set up the command table for 3D mode
def initCmds() def initCmds()#0
// Clear the command table // Clear the command table
byte i byte i
@ -2669,7 +2679,7 @@ def clampByte(val)
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
export def setStat(player, statName, val) export def setStat(player, statName, val)#0
when statName when statName
is @S_INTELLIGENCE; player->b_intelligence = clampByte(val); break is @S_INTELLIGENCE; player->b_intelligence = clampByte(val); break
is @S_STRENGTH; player->b_strength = clampByte(val); break is @S_STRENGTH; player->b_strength = clampByte(val); break
@ -2753,7 +2763,7 @@ export def buySell(storeCode, profitRatio)
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
def startGame(ask) def startGame(ask)#0
word p_module word p_module
// Create a new game or load an existing one // Create a new game or load an existing one