Implemented switchable move mode: default -> fast -> classic

This commit is contained in:
Martin Haye 2019-06-27 08:59:17 -07:00
parent 1efc0d3630
commit c93418510e
5 changed files with 79 additions and 26 deletions

View File

@ -600,6 +600,7 @@ def newGame()#0
global->b_curAvatar = BASE_AVATAR
global=>w_combatPauseCt = DEFAULT_COMBAT_PAUSE_CT
global->b_hour = 12 // start at high noon
global->b_moveMode = 1 // normal
mmgr(START_LOAD, 1) // players module and new game module both in partition 1
playersModule = mmgr(QUEUE_LOAD, MOD_GEN_PLAYERS<<8 | RES_TYPE_MODULE)
newGameModule = mmgr(QUEUE_LOAD, GS_NEW_GAME<<8 | RES_TYPE_MODULE)

View File

@ -290,8 +290,8 @@ asm setDir(dir)#0
+asmPlasmNoRet 1
jmp $600F
end
asm advance()#1 // returns: 0 if same pos, 1 if new pos, 2 if new pos and scripted
+asmPlasmRet 0
asm advance(nSteps)#1 // returns: 0 if same pos, 1 if new pos, 2 if new pos and scripted
+asmPlasmRet 1
jmp $6012
end
asm setColor(slot, color)#0 // params: slot (0=sky/1=ground), color (0-17)
@ -2536,11 +2536,11 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
def moveInternal(facingDir, moveDir, beepOK, shouldAdvTime)#1
byte val
byte val, i
word x, y
setDir(moveDir)
val = advance()
val = advance(global->b_moveMode)
lastMoveDir = moveDir
setDir(facingDir)
@ -2558,7 +2558,9 @@ def moveInternal(facingDir, moveDir, beepOK, shouldAdvTime)#1
// Advance time if requested
if shouldAdvTime
if mapIs3D
advTime(CLOCK_ADV_3D_HOURS, CLOCK_ADV_3D_MINS, CLOCK_ADV_3D_SECS)
for i = 0 to global->b_moveMode
advTime(CLOCK_ADV_3D_HOURS, CLOCK_ADV_3D_MINS, CLOCK_ADV_3D_SECS)
next
else
advTime(CLOCK_ADV_2D_HOURS, CLOCK_ADV_2D_MINS, CLOCK_ADV_2D_SECS)
fin
@ -2578,6 +2580,7 @@ def moveInternal(facingDir, moveDir, beepOK, shouldAdvTime)#1
checkEncounter(x, y, FALSE)
fin
fin
return val
end
@ -2609,7 +2612,7 @@ def moveBackward()#1
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Move backward two steps (3D mode), or one step (2D mode). This is often used when exiting a
// Move backward two quarter-steps (3D mode), or one step (2D mode). This is often used when exiting a
// building or fleeing combat, so we don't want to generate any random encounters.
export def moveWayBackward()#1
byte facingDir, moveDir
@ -2617,8 +2620,8 @@ export def moveWayBackward()#1
if lastMoveDir <> $FF
moveDir = (lastMoveDir + 8) & 15 // reverse of last move
moveInternal(facingDir, moveDir, FALSE, TRUE) // no beep, but do adv time
if mapIs3D
moveInternal(facingDir, moveDir, FALSE, FALSE) // no beep, don't adv time
if global->b_moveMode == 1
moveInternal(facingDir, moveDir, FALSE, TRUE) // no beep, but do adv time
fin
fin
lastMoveDir = $FF // avoid problems if moveWayBackward called repeatedly
@ -2629,7 +2632,7 @@ end
// Turn left (3D mode)
def rotateLeft()#1
needRender = TRUE
showCompassDir(adjustDir(-1))
showCompassDir(adjustDir(-global->b_moveMode))
return 0
end
@ -2637,7 +2640,7 @@ end
// Rotate to the right (3D mode)
def rotateRight()#1
needRender = TRUE
showCompassDir(adjustDir(1))
showCompassDir(adjustDir(global->b_moveMode))
return 0
end
@ -3331,6 +3334,47 @@ def showQuests()#1
return 0
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def showMoveMode()#0
flipToPage1()
clearTextWindow()
rawDisplayStr("Move mode:\n")
if global->b_moveMode == 1; rawDisplayStr("^I"); fin
rawDisplayStr("default^N ")
if global->b_moveMode == 2; rawDisplayStr("^I"); fin
rawDisplayStr("fast^N ")
if global->b_moveMode == 4; rawDisplayStr("^I"); fin
rawDisplayStr("classic^N\n")
textClearCountdown = 3
if mapIs3D and texturesLoaded; copyWindow(0); fin
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def switchMoveMode()#1
byte dir
word x, y
dir = getDir()
if global->b_moveMode == 1
global->b_moveMode = 2
dir = dir & ~1
elsif global->b_moveMode == 2
global->b_moveMode = 4
dir = dir & ~3
else
global->b_moveMode = 1
fin
setDir(dir)
getPos(@x, @y)
setPos(x, y) // to round it
needRender = TRUE
showMoveMode
return 0
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Set up the command table for 3D mode
def initCmds()#0
@ -3368,6 +3412,8 @@ def initCmds()#0
// Commands handled differently in 3D vs 2D
if mapIs3D
cmdTbl[3] = @switchMoveMode // ctrl-C
cmdTbl['W'] = @moveForward
cmdTbl['A'] = @rotateLeft
cmdTbl['D'] = @rotateRight

View File

@ -46,6 +46,9 @@ struc TGlobal
byte b_hour
byte b_minute
byte b_second
// move mode (1=normal, 2=fast, 4=classic)
byte b_moveMode
end
const PLAYER_FLAG_NPC = $01

View File

@ -39,7 +39,7 @@ NOTFLG_SPRITE = $FF-$80
jmp pl_render ; params: intrOnKbd
jmp pl_texControl ; params: 0=unload textures, 1=load textures
jmp pl_getScripts ; params: none
jmp pl_setAvatar ; params: A=tile number
jmp pl_setAvatar ; params: tile number
jmp pl_copyTile ; params: fromX, fromY, toX, toY
; Conditional assembly flags
@ -1826,37 +1826,39 @@ calcMapOriginX:
;-------------------------------------------------------------------------------
; Advance in current direction if not blocked.
; Params: none
; Params: # of steps
; Return: 0 if blocked;
; 1 if advanced but still within same map tile;
; 2 if pos is on a new map tile
pl_advance: !zone
sta .stepCt
; Save current coords on the stack for later compare or restore
ldx #0
- lda playerX,x
pha
inx
cpx #4
bne -
; Advance the coordinates based on the direction.
lda playerDir
asl
asl ; shift twice: each dir is 4 bytes in table
tax
; Advance the coordinates based on the direction.
; Along the way, we save each one on the stack for later compare or restore
lda playerX
pha
.step lda playerX
clc
adc walkDirs,x
sta playerX
lda playerX+1
pha
adc walkDirs+1,x
sta playerX+1
jsr .chk
sta .ora+1
lda playerY
pha
clc
adc walkDirs+2,x
sta playerY
lda playerY+1
pha
adc walkDirs+3,x
sta playerY+1
jsr .chk
@ -1870,7 +1872,9 @@ pl_advance: !zone
bpl -
ldy #0
beq .done
.ok ; Not blocked. See if we're in a new map tile.
.ok dec .stepCt
bne .step
.finish ; Not blocked. See if we're in a new map tile.
pla
eor playerY+1
sta tmp
@ -1902,6 +1906,7 @@ pl_advance: !zone
.rstx ldx #11 ; self-modified above
cmp #0
rts
.stepCt !byte 0
;-------------------------------------------------------------------------------
; Copy a tile (destructively) from one position to another

View File

@ -114,7 +114,7 @@ next_zp = $AD
JMP pl_setPos ; params: x (0-255), y (0-255); return: nothing
JMP pl_getDir ; params: none; return: dir (0-15)
JMP pl_setDir ; params: dir (0-15); return: nothing
JMP pl_advance ; params: none; return: 0 if blocked, 1 if same, 2 if new map tile
JMP pl_advance ; params: nSteps; return: 0 if blocked, 1 if same, 2 if new map tile
JMP pl_setColor ; params: slot (0=sky/1=ground), color (0-15); return: nothing
JMP pl_render ; params: intrOnKbd
JMP pl_texControl ; params: 1=load, 0=unload
@ -1253,9 +1253,6 @@ SETPOS:
; >> pl_flipToPage1
; No-op, because in 2D we don't use hi-res page 2
pl_flipToPage1:
rts
;----------------------------------------------------------------------
; >> pl_setColor
; No-op, because in 2D we don't have sky and ground colors
pl_setColor:
@ -1401,7 +1398,8 @@ INNER_ADVANCE: !zone {
;----------------------------------------------------------------------
; >> pl_advance
; Params: none; return: 0 if blocked, 1 if same, 2 if new map tile, 3 if new and scripted
; Params: nSteps (ignored -- in 2D we always advance exactly 1 step)
; return: 0 if blocked, 1 if same, 2 if new map tile, 3 if new and scripted
; Advance in the current direction
pl_advance: !zone {
STX PLASMA_X ; save PLASMA eval stk pos