Refactored some 3d-only code into a new module, to reduce the bloated size of gameloop.

This commit is contained in:
Martin Haye 2019-07-15 10:21:12 -07:00
parent 995907da95
commit 317fa2c890
4 changed files with 75 additions and 384 deletions

View File

@ -2406,7 +2406,7 @@ class A2PackPartitions
compileModule("store", "src/plasma/") compileModule("store", "src/plasma/")
compileModule("diskops", "src/plasma/") compileModule("diskops", "src/plasma/")
compileModule("godmode", "src/plasma/") compileModule("godmode", "src/plasma/")
compileModule("intimate", "src/plasma/") compileModule("util3d", "src/plasma/")
compileModule("automap", "src/plasma/") compileModule("automap", "src/plasma/")
//compileModule("sndseq", "src/plasma/") // not yet //compileModule("sndseq", "src/plasma/") // not yet
compileModule("questlog", "src/plasma/") compileModule("questlog", "src/plasma/")

View File

@ -86,7 +86,6 @@ import gamelib
predef pause(count)#1 predef pause(count)#1
predef payGold(amount)#1 predef payGold(amount)#1
predef percentToRatio(pct)#1 predef percentToRatio(pct)#1
predef plotLinePixels(page, color, len, xbyte, xbit, xinc, xdir, y, yinc, ydir)#0
predef printf1(fmt, arg1)#0 predef printf1(fmt, arg1)#0
predef printf2(fmt, arg1, arg2)#0 predef printf2(fmt, arg1, arg2)#0
predef printf3(fmt, arg1, arg2, arg3)#0 predef printf3(fmt, arg1, arg2, arg3)#0
@ -120,7 +119,6 @@ import gamelib
predef setCursor(x, y)#0 predef setCursor(x, y)#0
predef setGameFlag(flagName, val)#0 predef setGameFlag(flagName, val)#0
predef setGround(num)#0 predef setGround(num)#0
predef setIntimateMode(enable)#0
predef setMap(is3D, num, x, y, dir)#0 predef setMap(is3D, num, x, y, dir)#0
predef setRecordMode(enable)#0 predef setRecordMode(enable)#0
predef setStoryMode(enable)#0 predef setStoryMode(enable)#0
@ -167,6 +165,10 @@ import gamelib
word pGlobalTileset word pGlobalTileset
byte isFloppyVer byte isFloppyVer
byte recordMode byte recordMode
byte prevClockColor, prevClockHour, prevClockMinute
byte nextSignificantMinute
byte lampFrame
word lampDir
/////////// Shared string constants ////////////// /////////// Shared string constants //////////////
@ -179,4 +181,5 @@ import gamelib
// Next: other useful strings // Next: other useful strings
byte[] S_HIS, S_HER, S_THEIR byte[] S_HIS, S_HER, S_THEIR
end end

View File

@ -19,13 +19,6 @@ const CHAR_WND_HEALTH_X = 112
const ANIM_PAUSE_MAX = 150 const ANIM_PAUSE_MAX = 150
const CLOCK_X = 119
const CLOCK_Y = 176
const CLOCK_RADIUS = 14
const LAMP_Y = 168
const LAMP_XBYTE = 10
const CLOCK_ADV_2D_HOURS = 1 const CLOCK_ADV_2D_HOURS = 1
const CLOCK_ADV_2D_MINS = 0 const CLOCK_ADV_2D_MINS = 0
const CLOCK_ADV_2D_SECS = 0 const CLOCK_ADV_2D_SECS = 0
@ -52,11 +45,11 @@ include "combat.plh"
include "party.plh" include "party.plh"
include "store.plh" include "store.plh"
include "diskops.plh" include "diskops.plh"
include "intimate.plh"
include "godmode.plh" include "godmode.plh"
include "automap.plh" include "automap.plh"
include "questlog.plh" include "questlog.plh"
include "story.plh" include "story.plh"
include "util3d.plh"
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Data structures // Data structures
@ -81,7 +74,7 @@ predef playerDeath()#0
predef startGame(firstTime, ask)#0 predef startGame(firstTime, ask)#0
predef showAnimFrame()#0 predef showAnimFrame()#0
predef showParty()#0 predef showParty()#0
predef unloadTextures()#0 predef textureControl(flg)#0
predef clearEncounterZones()#0 predef clearEncounterZones()#0
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
@ -117,11 +110,11 @@ word triggerTbl
word cmdTbl[96] // ASCII $00..$5F word cmdTbl[96] // ASCII $00..$5F
byte frameLoaded = 0 byte frameLoaded = 0
word curEngine = NULL word curEngine = NULL
word pIntimate = NULL word pModUtil3d = NULL
word util3d = NULL
export word pResourceIndex = NULL export word pResourceIndex = NULL
export word pGlobalTileset = NULL export word pGlobalTileset = NULL
export byte curMapPartition = 0 export byte curMapPartition = 0
export word pGodModule = NULL
export word typeHash = 0 export word typeHash = 0
word curHeapPct = 0 word curHeapPct = 0
byte lastMoveDir = $FF byte lastMoveDir = $FF
@ -155,13 +148,13 @@ byte animDirCt
byte anyAnims = TRUE byte anyAnims = TRUE
word animPauseCt word animPauseCt
byte showingLamp = TRUE byte showingLamp = TRUE
byte lampFrame = 0 export byte lampFrame = 0
word lampDir = 1 export word lampDir = 1
byte storyMode = FALSE byte storyMode = FALSE
// Time and clock // Time and clock
byte prevClockColor, prevClockHour, prevClockMinute export byte prevClockColor, prevClockHour, prevClockMinute
byte nextSignificantMinute export byte nextSignificantMinute
byte snoozeX0, snoozeX1, snoozeY byte snoozeX0, snoozeX1, snoozeY
word timeEventFunc word timeEventFunc
@ -193,9 +186,6 @@ export byte[] S_HIS = "his"
export byte[] S_HER = "her" export byte[] S_HER = "her"
export byte[] S_THEIR = "their" export byte[] S_THEIR = "their"
//byte[] macro = "lddddwwwwwwwwwwwwwwaaaaawwwwwdwwwwwwwwddwwwwwwwwaw",0
//word pMacro = NULL //@macro
//word startTick = 0
word lastTick = 0 word lastTick = 0
export byte recordMode = 0 export byte recordMode = 0
@ -302,7 +292,7 @@ asm render(intrOnKbd)#0
+asmPlasmNoRet 1 +asmPlasmNoRet 1
jmp $6018 jmp $6018
end end
asm texControl(doLoad)#0 asm _texControl(doLoad)#0
+asmPlasmNoRet 1 +asmPlasmNoRet 1
jmp $601B jmp $601B
end end
@ -399,123 +389,6 @@ export asm memset(pDst, val, len)#0
+ rts + rts
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Specialized line routine for drawing the clock. Plots in black or white only.
// Parameters:
// page : 0=page1, $60=page2
// color: 0=black, $7F=white
// len : number of pixels to plot
// xbyte: x/7, e.g. 0-39 byte offset within screen row
// xbit : (3<<(x%7)) & $7F
// xinc : fraction 0..$FF telling how often to advance on X axis
// xdir : 0=left, 1=right
// y : hi-res line number 0..191
// yinc : fraction 0..$FF telling how often to advance on X axis
// ydir : 0=up, 1=down
export asm plotLinePixels(page, color, len, xbyte, xbit, xinc, xdir, y, yinc, ydir)#0
!zone {
.param_page = evalStkL+9
.param_color = evalStkL+8
.param_len = evalStkL+7
.param_xbyte = evalStkL+6
.param_xbit = evalStkL+5
.param_xinc = evalStkL+4
.param_xdir = evalStkL+3
.param_y = evalStkL+2
.param_yinc = evalStkL+1
.param_ydir = evalStkL+0
.xfrac = tmp
.yfrac = tmp+1
+asmPlasmNoRet 10
lda #0
sta .xfrac
sta .yfrac
.getline
txa
pha
lda .param_y,x
jsr GetScreenLine
pla
tax
lda pTmp+1
eor .param_page,x ; $60 flips to page 2, 0 for page 1
sta pTmp+1
clc ; signal to take X path first
.pix
dec .param_len,x ; decrement count of pixels todo
bmi .done ; get out if it goes negative
ldy .param_xbyte,x ; byte number on line
lda .param_color,x ; get color mask
eor (pTmp),y ; funny logic to plot in color - part 1
and .param_xbit,x ; bit mask within byte
eor (pTmp),y ; funny logic - part 2
ora #$80 ; force hi-bit colors for entire clock face (no mixing)
sta (pTmp),y ; store the result
lda .param_xbit,x ; check bit mask:
and #$60 ; was it the rightmost pixel?
eor #$40
bne + ; if not, done w/ plotting
lda .param_color,x ; it was, so we need to plot
iny ; ...next byte's...
eor (pTmp),y
and #1 ; ...first pixel
eor (pTmp),y
ora #$80 ; force hi-bit colors for entire clock face (no mixing)
sta (pTmp),y
dey ; back to where we were
+ bcs .movey ; skip X processing if we just did it
.movex ; check and move on X axis
lda .xfrac
clc
adc .param_xinc,x ; bump the X fraction
sta .xfrac
bcc .movey ; if not a whole number bump, don't move on X
lda .param_xbit,x
ldy .param_xdir,x ; check X direction (0=left, 1=right)
bne .right
.left
lsr ; 1 bit to the left
cmp #$20
bne +
ora #$40
+ cmp #1
bne .ltrt
dec .param_xbyte,x ; finished with byte, move 1 byte left
lda #$40 ; high bit of next-to-left byte
bne .ltrt ; always taken
.right
asl ; 1 bit to right
bpl .ltrt
and #$7F
bne .ltrt
inc .param_xbyte,x ; finished with byte, move 1 byte right
lda #3 ; low bit of next-to-right byte
.ltrt
sta .param_xbit,x
sec ; signal to take the Y path next time
bcs .pix ; plot at the new position
.movey
lda .yfrac
clc
adc .param_yinc,x ; bump the Y fraction
sta .yfrac
bcc .movex ; if not a whole number bump, don't move on Y, go bump X
lda .param_ydir,x ; check Y direction (0=up, 1=down)
bne .down
.up
dec .param_y,x ; prev line (up)
bcs .getline ; always taken
.down
inc .param_y,x ; next line (down)
bcs .getline ; always taken
.done
rts
}
end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
export asm readAuxByte(ptr)#1 export asm readAuxByte(ptr)#1
+asmPlasmRet 1 +asmPlasmRet 1
@ -1595,22 +1468,6 @@ export def getUpperKey()#1
copyWindow(0) copyWindow(0)
fin fin
//if pMacro
// pMacro++
// if ^pMacro
// if ^pMacro <> 'l'
// if !startTick; startTick = getTick(); fin
// fin
// return charToUpper(^pMacro)
// else
// pMacro = NULL
// printf3("start=%d end=%d elapsed=%d\n", startTick, getTick(), tickDiff(startTick, getTick()))
// ^$C054
// ^$C051
// rdkey()
// fin
//fin
// Now wait for a key, and animate while doing so. // Now wait for a key, and animate while doing so.
while ^kbd < 128 while ^kbd < 128
if recordMode if recordMode
@ -1684,33 +1541,6 @@ export def forEach(p, do)#0
forSome(p, @trueFunc, do) forSome(p, @trueFunc, do)
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
def nextLampFrame()#0
word n, pTile
if !mapIs3D or !frameLoaded; return; fin
if showingLamp
n = lampFrame - LAMP_1
n = n + lampDir
while n < 0
n = n + (LAMP_COUNT-1) // because PLASMA's modulo operator adopts C's (IMO useless) behavior
loop
if n >= (LAMP_COUNT-1)
n = n % (LAMP_COUNT-1)
fin
n = n + LAMP_1
if (rand16() % 100) < 10
lampDir = -lampDir
fin
else
n = LAMP_0
fin
pTile = pGlobalTileset + (n << 5) + 1 // +1 to skip to the header (# of tiles)
blit(FALSE, pTile, getScreenLine(LAMP_Y)+LAMP_XBYTE, 16, 2)
blit(FALSE, pTile, getScreenLine(LAMP_Y)+LAMP_XBYTE+$2000, 16, 2)
lampFrame = n
end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Pause for a specified count period, advancing the animation periodically. Terminates early // Pause for a specified count period, advancing the animation periodically. Terminates early
// if a key is pressed. In either case, returns the number of counts waited. // if a key is pressed. In either case, returns the number of counts waited.
@ -1813,8 +1643,8 @@ export def setSky(num)#0
skyNum = num skyNum = num
setColor(0, skyNum) setColor(0, skyNum)
needRender = TRUE needRender = TRUE
showingLamp = mapIs3D and (skyNum == 0 or skyNum == 8) showingLamp = mapIs3D and texturesLoaded and (skyNum == 0 or skyNum == 8)
nextLampFrame // to update image if showingLamp and util3d; util3d=>util3d_nextLampFrame(); fin // to update image
fin fin
end end
@ -1909,7 +1739,7 @@ def resetAnimPause()#0
anyAnims = TRUE // for now; might get cleared if we discover otherwise on advance anyAnims = TRUE // for now; might get cleared if we discover otherwise on advance
animDirCt = 1 animDirCt = 1
animPauseCt = ANIM_PAUSE_MAX animPauseCt = ANIM_PAUSE_MAX
showingLamp = mapIs3D and (skyNum == 0 or skyNum == 8) showingLamp = mapIs3D and texturesLoaded and (skyNum == 0 or skyNum == 8)
lampFrame = 0 lampFrame = 0
lampDir = 1 lampDir = 1
end end
@ -1924,7 +1754,7 @@ export def loadFrameImg(img)#0
clearPortrait() clearPortrait()
// Make room in aux mem by throwing out textures // Make room in aux mem by throwing out textures
unloadTextures() textureControl(FALSE)
// Load the image data into aux mem // Load the image data into aux mem
if img if img
@ -2163,157 +1993,22 @@ export def loadMainFrameImg()#0
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
def horzSegment(color, len, x, y)#0 def loadUtil3d()#0
//params: page, color, len, xbyte, xbit, xinc, xdir, y, yinc, ydir if !pModUtil3d and mapIs3D
plotLinePixels($60, color, len, x/7, (3<<(x%7)) & $7F, $FF, 1, y, 0, 0) mmgr(START_LOAD, 1) // code is in partition 1
end pModUtil3d = mmgr(QUEUE_LOAD, MOD_UTIL3D<<8 | RES_TYPE_MODULE)
mmgr(FINISH_LOAD, 0)
/////////////////////////////////////////////////////////////////////////////////////////////////// util3d = pModUtil3d()
def putSegment(color, len, isOuter, x, y)#0
if isOuter
horzSegment(color ^ $7F, len, x, y)
else
horzSegment(color ^ $7F, 1, x, y)
horzSegment(color, len-3, x+2, y)
horzSegment(color ^ $7F, 1, x+len, y)
fin fin
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Draw a filled, outlined circle
def drawCircle(color, radius, x0, y0)#0
word x, y, dx, dy, err, r2, p
// Clear extents buffer
r2 = radius << 1
memset($280, 0, r2)
// Midpoint circle algorithm, but instead of plotting points, just record max extents
x = radius-1
y = 0
dx = 1
dy = 1
err = dx - r2
while (x >= y)
p = $280 + y
^p = max(^p, x)
p = $280 + x
^p = max(^p, y)
if err <= 0
y++
err = err + dy
dy = dy + 2
elsif err > 0
x--
dx = dx + 2
err = err + dx - r2
fin
loop
// Using the extents, draw an outline circle
for y = 0 to radius-1
x = ^($280+y)
putSegment(color, x<<1, y>=radius-2, x0-x, y0-y)
putSegment(color, x<<1, y>=radius-2, x0-x, y0+y)
next
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def drawHand(color, hour, isShort)#0
word xdir, xinc, ydir, yinc, len
ydir = (hour > 3 and hour < 9) & 1 // 3..9 = 1
xdir = (hour < 6) & 1 // 1..6 = 1
xinc = (^("123210123210"+hour) - '0') * 85
yinc = (^("210123210123"+hour) - '0') * 85
len = (hour % 3) ?? (CLOCK_RADIUS*3/2)-4 :: CLOCK_RADIUS-2
if isShort
len = len * 3 / 5
fin
//params: page, color, len, xbyte, xbit, xinc, xdir, y, yinc, ydir
plotLinePixels($60, color, len, CLOCK_X/7, (3<<(CLOCK_X%7)) & $7F, xinc, xdir, CLOCK_Y, yinc, ydir)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def drawHands(color, hour, min)#0
word n
n = min/5
drawHand(color, n ?? n :: 12, FALSE)
n = hour % 12
drawHand(color, n ?? n :: 12, TRUE)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def showClock()#0
word cursX, cursY, color
// Show page 1 while we do work on page 2
flipToPage1
// Erase old clock hands if applicable
if prevClockColor <> 99
drawHands(prevClockColor, prevClockHour, prevClockMinute)
fin
// New color
color = global->b_hour < 6 or global->b_hour >= 18 ?? 0 :: $7F
if color <> prevClockColor
// Draw entire circle in new color
drawCircle(color, CLOCK_RADIUS, CLOCK_X, CLOCK_Y)
else
// Erase old clock hands
drawHands(prevClockColor, prevClockHour, prevClockMinute)
fin
// Draw new clock hands
drawHands(color ^ $7F, global->b_hour, global->b_minute)
// Copy the image from pg 2 to pg 1
cursX, cursY = getCursor()
setWindow(CLOCK_Y-CLOCK_RADIUS, CLOCK_Y+CLOCK_RADIUS, (CLOCK_X-CLOCK_RADIUS)/7*7, (CLOCK_X+CLOCK_RADIUS+13)/7*7)
copyWindow($60) // page 2 to page 1
setWindow2()
setCursor(cursX, cursY)
// And record parameters for erasing the clock hands next time
prevClockColor = color
prevClockHour = global->b_hour
prevClockMinute = global->b_minute
nextSignificantMinute = global->b_minute - (global->b_minute % 5) + 5
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def showCompassDir(dir)#0
word cursX, cursY, str
cursX, cursY = getCursor()
setWindow(173, 182, 28, 49) // Top, Bottom, Left, Right
clearWindow()
when dir
is 15; is 0; is 1; str = "E"; break
is 2; str = "SE"; break
is 3; is 4; is 5; str = "S"; break;
is 6; str = "SW"; break;
is 7; is 8; is 9; str = "W"; break;
is 10; str = "NW"; break;
is 11; is 12; is 13; str = "N"; break;
is 14; str = "NE"; break;
wend
centerStr(str, 21)
if mapIs3D and texturesLoaded; copyWindow(0); fin
setWindow2()
setCursor(cursX, cursY)
end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Load code and data, set up everything to display a 2D or 3D map // Load code and data, set up everything to display a 2D or 3D map
def initMap(x, y, dir)#0 def initMap(x, y, dir)#0
word pDiskOps // TEMPORARY - FIXME FOO word pDiskOps // TEMPORARY - FIXME FOO
// If we have a renderer loaded, let it know to flush automap marks // If we have a renderer loaded, let it know to flush automap marks
unloadTextures() textureControl(FALSE)
// 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)
mmgr(RESET_MEMORY, 0) mmgr(RESET_MEMORY, 0)
@ -2334,6 +2029,7 @@ def initMap(x, y, dir)#0
pGlobalTileset = mmgr(QUEUE_LOAD, 1<<8 | RES_TYPE_TILESET) // even in 3d, need tiles for lamp/etc. pGlobalTileset = mmgr(QUEUE_LOAD, 1<<8 | RES_TYPE_TILESET) // even in 3d, need tiles for lamp/etc.
pDiskOps = mmgr(QUEUE_LOAD, MOD_DISKOPS<<8 | RES_TYPE_MODULE) // TEMPORARY - FIXME FOO pDiskOps = mmgr(QUEUE_LOAD, MOD_DISKOPS<<8 | RES_TYPE_MODULE) // TEMPORARY - FIXME FOO
mmgr(FINISH_LOAD, 0) mmgr(FINISH_LOAD, 0)
if mapIs3D; loadUtil3d(); fin
pDiskOps()=>diskops_checkAutomap() // TEMPORARY - FIXME FOO pDiskOps()=>diskops_checkAutomap() // TEMPORARY - FIXME FOO
mmgr(FREE_MEMORY, pDiskOps) // TEMPORARY - FIXME FOO mmgr(FREE_MEMORY, pDiskOps) // TEMPORARY - FIXME FOO
@ -2376,8 +2072,10 @@ def initMap(x, y, dir)#0
snoozeX1 = -1 snoozeX1 = -1
if timeEventFunc; timeEventFunc(global->b_hour); fin if timeEventFunc; timeEventFunc(global->b_hour); fin
if mapIs3D if mapIs3D
showCompassDir(dir) if util3d
showClock() util3d=>util3d_showCompassDir(dir)
util3d=>util3d_showClock()
fin
elsif global->b_curAvatar <> 0 elsif global->b_curAvatar <> 0
setAvatar(global->b_curAvatar) setAvatar(global->b_curAvatar)
doRender() doRender()
@ -2403,12 +2101,23 @@ export def scriptSetAvatar(avatarTileNum)#0
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
export def unloadTextures()#0 export def textureControl(flg)#0
if renderLoaded and texturesLoaded if !renderLoaded or !mapIs3D; return; fin
flipToPage1() flipToPage1
texControl(0) if flg and !texturesLoaded
texturesLoaded = FALSE _texControl(1)
loadUtil3d
showingLamp = (skyNum == 0 or skyNum == 8)
elsif !flg and texturesLoaded
_texControl(0)
if pModUtil3d
mmgr(FREE_MEMORY, pModUtil3d)
pModUtil3d = NULL
util3d = NULL
fin
showingLamp = FALSE
fin fin
texturesLoaded = flg
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
@ -2432,12 +2141,8 @@ end
// Perform rendering, copy if necessary, clear appropriate flags // Perform rendering, copy if necessary, clear appropriate flags
def doRender()#0 def doRender()#0
if curPortrait; clearPortrait(); fin if curPortrait; clearPortrait(); fin
if !texturesLoaded textureControl(TRUE)
flipToPage1() if showingLamp; util3d=>util3d_nextLampFrame(); fin
texControl(1)
texturesLoaded = TRUE
fin
if showingLamp; nextLampFrame; fin
render(0) // Don't interrupt on kbd - must finish the render render(0) // Don't interrupt on kbd - must finish the render
needRender = FALSE needRender = FALSE
end end
@ -2474,7 +2179,7 @@ def advTime(hours, mins, secs)#0
fin fin
if mapIs3D and redrawClock if mapIs3D and redrawClock
showClock() if util3d; util3d=>util3d_showClock(); fin
fin fin
if runScript and timeEventFunc if runScript and timeEventFunc
@ -2487,18 +2192,14 @@ end
// Called by scripts to display a string. We set the flag noting that something has been // Called by scripts to display a string. We set the flag noting that something has been
// displayed, then use an assembly routine to do the work. // displayed, then use an assembly routine to do the work.
export def _scriptDisplayStr(str)#0 export def _scriptDisplayStr(str)#0
if pIntimate if renderLoaded and !curPortrait and !curFullscreenImg and needRender
pIntimate=>intimate_displayStr(str) doRender()
else flipToPage1()
if renderLoaded and !curPortrait and !curFullscreenImg and needRender needRender = FALSE
doRender()
flipToPage1()
needRender = FALSE
fin
if textClearCountdown; clearTextWindow(); fin
displayStr(str)
textDrawn = TRUE
fin fin
if textClearCountdown; clearTextWindow(); fin
displayStr(str)
textDrawn = TRUE
anyInteraction = TRUE anyInteraction = TRUE
end end
@ -2632,7 +2333,7 @@ end
// Turn left (3D mode) // Turn left (3D mode)
def rotateLeft()#1 def rotateLeft()#1
needRender = TRUE needRender = TRUE
showCompassDir(adjustDir(-global->b_moveMode)) util3d=>util3d_showCompassDir(adjustDir(-global->b_moveMode))
return 0 return 0
end end
@ -2640,7 +2341,7 @@ end
// Rotate to the right (3D mode) // Rotate to the right (3D mode)
def rotateRight()#1 def rotateRight()#1
needRender = TRUE needRender = TRUE
showCompassDir(adjustDir(global->b_moveMode)) util3d=>util3d_showCompassDir(adjustDir(global->b_moveMode))
return 0 return 0
end end
@ -2884,14 +2585,14 @@ def showAnimFrame()#0
blit(1, curPortrait + 2, getScreenLine(top)+2, 128, 18) blit(1, curPortrait + 2, getScreenLine(top)+2, 128, 18)
fin fin
needRender = FALSE // suppress display of map for this frame needRender = FALSE // suppress display of map for this frame
if showingLamp; nextLampFrame(); fin if showingLamp and util3d; util3d=>util3d_nextLampFrame(); fin
elsif curFullscreenImg elsif curFullscreenImg
blit(1, curFullscreenImg + 2, getScreenLine(0), 192, 40) // the +2 is to skip anim hdr offset blit(1, curFullscreenImg + 2, getScreenLine(0), 192, 40) // the +2 is to skip anim hdr offset
needRender = FALSE // suppress display of map for this frame needRender = FALSE // suppress display of map for this frame
elsif mapIs3D elsif mapIs3D
if showingLamp; nextLampFrame(); fin if showingLamp and util3d; util3d=>util3d_nextLampFrame(); fin
render($FF) // it's only animation, so do interrupt if a key is pressed render($FF) // it's only animation, so do interrupt if a key is pressed
if showingLamp; nextLampFrame(); fin if showingLamp and util3d; util3d=>util3d_nextLampFrame(); fin
fin fin
end end
@ -2934,7 +2635,7 @@ export def setPortrait(portraitNum)#0
cursX, cursY = getCursor() cursX, cursY = getCursor()
// Make room by unloading the textures (only if renderer is loaded) // Make room by unloading the textures (only if renderer is loaded)
unloadTextures() textureControl(FALSE)
// Now clear out the map area // Now clear out the map area
useMapWindow() useMapWindow()
@ -3016,7 +2717,7 @@ def loadEngine(moduleNum)#1
if curEngine; fatal("dblEng"); fin if curEngine; fatal("dblEng"); fin
preEnginePortraitNum = curPortraitNum preEnginePortraitNum = curPortraitNum
clearPortrait() clearPortrait()
unloadTextures() textureControl(FALSE)
flipToPage1() flipToPage1()
mmgr(START_LOAD, 1) // code is in partition 1 mmgr(START_LOAD, 1) // code is in partition 1
curEngine = mmgr(QUEUE_LOAD, moduleNum<<8 | RES_TYPE_MODULE) curEngine = mmgr(QUEUE_LOAD, moduleNum<<8 | RES_TYPE_MODULE)
@ -3035,7 +2736,7 @@ def returnFromEngine(render)#0
else else
clearPortrait() clearPortrait()
fin fin
if renderLoaded; texControl(1); texturesLoaded = TRUE; fin textureControl(TRUE)
mapNameHash = 0; showMapName(global=>s_mapName) mapNameHash = 0; showMapName(global=>s_mapName)
clearTextWindow() clearTextWindow()
if render if render
@ -3044,9 +2745,11 @@ def returnFromEngine(render)#0
needRender = TRUE needRender = TRUE
fin fin
if mapIs3D if mapIs3D
showCompassDir(getDir())
prevClockColor = 99 prevClockColor = 99
showClock() if util3d
util3d=>util3d_showCompassDir(getDir())
util3d=>util3d_showClock()
fin
fin fin
showParty() showParty()
setWindow2() // in case we're mid-script setWindow2() // in case we're mid-script
@ -3275,16 +2978,13 @@ def toggleGodMode()#1
key = getUpperKey key = getUpperKey
if key == 15 // ctrl-O if key == 15 // ctrl-O
key = getUpperKey key = getUpperKey
if key == 4 or key == 18 // ctrl-D or ctrl-R if key == 4 // ctrl-D
flipToPage1() flipToPage1()
clearTextWindow() clearTextWindow()
if key == 4 // ctrl-D if key == 4 // ctrl-D
global->b_godmode = !global->b_godmode global->b_godmode = !global->b_godmode
displayf1("gm:%d\n", global->b_godmode & 1) displayf1("gm:%d\n", global->b_godmode & 1)
initCmds() // rebuild the command table with new commands initCmds() // rebuild the command table with new commands
else
setRecordMode(1 - recordMode)
displayf1("rm:%d\n", recordMode)
fin fin
textDrawn = TRUE textDrawn = TRUE
beep; beep beep; beep
@ -3301,8 +3001,8 @@ def cheatCmd()#1
key = charToUpper((^kbd) & $7F) key = charToUpper((^kbd) & $7F)
// We don't use laodEngine, since godmode may use it too, and we'd get double modules // We don't use laodEngine, since godmode may use it too, and we'd get double modules
unloadTextures() // seems to be necessary for teleport-to-3d to work right textureControl(FALSE) // seems to be necessary for teleport-to-3d to work right
flipToPage1() flipToPage1
mmgr(START_LOAD, 1) // code is in partition 1 mmgr(START_LOAD, 1) // code is in partition 1
pModule = mmgr(QUEUE_LOAD, MOD_GODMODE<<8 | RES_TYPE_MODULE) pModule = mmgr(QUEUE_LOAD, MOD_GODMODE<<8 | RES_TYPE_MODULE)
mmgr(FINISH_LOAD, 0) mmgr(FINISH_LOAD, 0)
@ -3310,7 +3010,7 @@ def cheatCmd()#1
pModule()=>godmode_cheatCmd(key) pModule()=>godmode_cheatCmd(key)
mmgr(FREE_MEMORY, pModule) mmgr(FREE_MEMORY, pModule)
if renderLoaded; texControl(1); texturesLoaded = TRUE; fin textureControl(TRUE)
return 0 return 0
end end
@ -3525,7 +3225,7 @@ export def createThing(moduleID, creationFuncNum)#1
word p_module, funcTbl, func, p_thing word p_module, funcTbl, func, p_thing
// Unload textures to make room for the module (also flips to page 1 if needed) // Unload textures to make room for the module (also flips to page 1 if needed)
unloadTextures() textureControl(FALSE)
// Load the module that is capable of creating the thing // Load the module that is capable of creating the thing
mmgr(START_LOAD, 1) // code is in partition 1 mmgr(START_LOAD, 1) // code is in partition 1
@ -3800,18 +3500,6 @@ export def getGameFlag(flagNum)#1
return global->ba_gameFlags[byteNum] & mask return global->ba_gameFlags[byteNum] & mask
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
export def setIntimateMode(enable)#0
if enable
pIntimate = loadEngine(MOD_INTIMATE)
pIntimate=>intimate_setMode(enable)
else
pIntimate=>intimate_setMode(enable)
returnFromEngine(TRUE)
pIntimate = NULL
fin
end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
export def setStoryMode(enable)#0 export def setStoryMode(enable)#0
// Story mode only exists on 800K or hard drive builds // Story mode only exists on 800K or hard drive builds

View File

@ -34,7 +34,7 @@ NOTFLG_SPRITE = $FF-$80
jmp pl_setPos ; params: x (0-255), y (0-255); return: nothing jmp pl_setPos ; params: x (0-255), y (0-255); return: nothing
jmp pl_getDir ; params: none; return: dir (0-15) jmp pl_getDir ; params: none; return: dir (0-15)
jmp pl_setDir ; params: dir (0-15); return: nothing jmp pl_setDir ; params: dir (0-15); return: nothing
jmp pl_advance ; params: none; return: 0 if same, 1 if new map tile, 2 if new and scripted jmp pl_advance ; params: nSteps; return: 0 if same, 1 if new map tile, 2 if new and scripted
jmp pl_setColor ; params: slot (0=sky/1=ground), color (0-15); return: nothing jmp pl_setColor ; params: slot (0=sky/1=ground), color (0-15); return: nothing
jmp pl_render ; params: intrOnKbd jmp pl_render ; params: intrOnKbd
jmp pl_texControl ; params: 0=unload textures, 1=load textures jmp pl_texControl ; params: 0=unload textures, 1=load textures