Implemented initial character naming, gender assignment, and XP/SP init.

This commit is contained in:
Martin Haye
2017-07-08 16:36:08 -07:00
parent bf4e3c7792
commit 30a5881f24
9 changed files with 139 additions and 66 deletions

View File

@@ -2889,9 +2889,12 @@ def makePlayer_pt2(p, health, level, aiming, handToHand, dodging)#1
p=>w_health = health p=>w_health = health
p->b_level = level p->b_level = level
p=>w_maxHealth = health p=>w_maxHealth = health
// Non-first players are NPCs
if global=>p_players; p->b_playerFlags = PLAYER_FLAG_NPC; fin
p->b_aiming = aiming p->b_aiming = aiming
p->b_handToHand = handToHand p->b_handToHand = handToHand
p->b_dodging = dodging p->b_dodging = dodging
initPlayerXP(p)
return p return p
end end
""") """)

View File

@@ -123,11 +123,8 @@ DisplayStr JMP DoParse ; API call address
;Does not do line breaking ;Does not do line breaking
CalcWidth JMP DoCWdth CalcWidth JMP DoCWdth
;Save the cursor position ;Get the cursor position
SaveCursor JMP SvCurs GetCursor JMP GtCurs
;Restore the cursor position
RestCursor JMP RsCurs
;To get a string of text up to 40 chars long using a ;To get a string of text up to 40 chars long using a
;flashing cursor use GetStr. It allows use of either ;flashing cursor use GetStr. It allows use of either
@@ -549,25 +546,22 @@ WtL_Prs LDA #0 ; if wait interrupted then do
STA ChBflip STA ChBflip
RTS RTS
;Routine: Save the cursor position. There is exactly one save slot. ;Routine: Get the cursor position (relative to the current window)
BCursColL !byte 0 ;Saved Lo-byte of 16-bit horz X-pos value GtCurs DEX
BCursColH !byte 0 ;Saved Hi-byte X-position {0..279} LDA CursColL
BCursRow !byte 0 ;Saved vertical Y-position {0..191} SEC
SvCurs LDA CursColL SBC CursXl
STA BCursColL STA evalStkL,X
LDA CursColH LDA CursColH
STA BCursColH SBC CursXh
STA evalStkH,X
DEX
LDA CursRow LDA CursRow
STA BCursRow SEC
RTS SBC CursY
STA evalStkL,X
;Routine: Restore the cursor position. There is exactly one save slot. LDA #0
RsCurs LDA BCursColL STA evalStkH,X
STA CursColL
LDA BCursColH
STA CursColH
LDA BCursRow
STA CursRow
RTS RTS
;Routine: Set window boundaries. Paramaters are pushed on the PLASMA ;Routine: Set window boundaries. Paramaters are pushed on the PLASMA

View File

@@ -40,8 +40,7 @@ CopyWindow = ClearWindow+3
DisplayChar = CopyWindow+3 DisplayChar = CopyWindow+3
DisplayStr = DisplayChar+3 DisplayStr = DisplayChar+3
CalcWidth = DisplayStr+3 CalcWidth = DisplayStr+3
SaveCursor = CalcWidth+3 GetCursor = CalcWidth+3
RestCursor = SaveCursor+3 GetStr = GetCursor+3
GetStr = RestCursor+3
GetScreenLine = GetStr+3 GetScreenLine = GetStr+3
NextScreenLine = GetScreenLine+3 NextScreenLine = GetScreenLine+3

View File

@@ -344,10 +344,11 @@ def playerCombatChoose(pl)#0
word p, pWeapon word p, pWeapon
byte nWeapons, key byte nWeapons, key
byte canShoot, canReload, canChange, canAdvance byte canShoot, canReload, canChange, canAdvance
word cursX, cursY
// Before we start, save the cursor location so we can // Before we start, save the cursor location so we can
// later restore it for the next player's choice. // later restore it for the next player's choice.
saveCursor() cursX, cursY = getCursor()
// Count all weapons and get currently equipped // Count all weapons and get currently equipped
canShoot = FALSE canShoot = FALSE
@@ -365,7 +366,7 @@ def playerCombatChoose(pl)#0
loop loop
// Let them know their options // Let them know their options
restoreCursor() setCursor(cursX, cursY)
rawDisplayf1("^D%s", pl=>s_name) rawDisplayf1("^D%s", pl=>s_name)
displayOption('M', "Melee") displayOption('M', "Melee")
if pWeapon if pWeapon

View File

@@ -12,6 +12,7 @@ include "gamelib.plh"
include "globalDefs.plh" include "globalDefs.plh"
include "playtype.plh" include "playtype.plh"
include "diskops.plh" include "diskops.plh"
include "party.plh"
include "gen_modules.plh" include "gen_modules.plh"
include "gen_players.plh" include "gen_players.plh"
@@ -268,19 +269,45 @@ def _loadGame()#1
return 0 return 0
end end
def getCharacterName()#0
word cursX, cursY
displayStr("\nCharacter name?\n")
cursX, cursY = getCursor()
printf2("cursX=%d cursY=%d\n", cursX, cursY)
setWindow(cursY+24, cursY+24+18, cursX+154, cursX+154+62)
clearWindow()
global=>p_players=>s_name = getStringResponse()
setWindow2()
setCursor(cursX, cursY)
end
def getCharacterGender()#0
displayStr("\n\nGender? (M/F/N/...) \n")
global=>p_players->c_gender = getUpperKey()
displayChar(global=>p_players->c_gender)
end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
def newGame()#0 def newGame()#0
word playersModule, newGameModule word playersModule, newGameModule, partyModule
initHeap(0) // initially empty heap initHeap(0) // initially empty heap
global->b_curAvatar = 0 global->b_curAvatar = 0
global=>w_combatPauseCt = DEFAULT_COMBAT_PAUSE_CT global=>w_combatPauseCt = DEFAULT_COMBAT_PAUSE_CT
mmgr(START_LOAD, 1) // players module and new game module both in partition 1 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) playersModule = mmgr(QUEUE_LOAD, MOD_GEN_PLAYERS<<8 | RES_TYPE_MODULE)
newGameModule = mmgr(QUEUE_LOAD, GS_NEW_GAME<<8 | RES_TYPE_MODULE) newGameModule = mmgr(QUEUE_LOAD, GS_NEW_GAME<<8 | RES_TYPE_MODULE)
partyModule = mmgr(QUEUE_LOAD, MOD_PARTY<<8 | RES_TYPE_MODULE)
mmgr(FINISH_LOAD, 0) mmgr(FINISH_LOAD, 0)
playersModule()=>makeInitialParty() playersModule()=>makeInitialParty()
addXP(0) // to set initial skill pts loadMainFrameImg()
showMapName("New game")
setWindow2()
newGameModule()() newGameModule()()
getCharacterName()
getCharacterGender()
if global=>p_players->b_skillPoints
partyModule()=>party_showPlayerSheet(0)
fin
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -50,6 +50,7 @@ import gamelib
predef finishString(isPlural)#1 predef finishString(isPlural)#1
predef flipToPage1()#0 predef flipToPage1()#0
predef getCharResponse()#1 predef getCharResponse()#1
predef getCursor()#2
predef getDir()#1 predef getDir()#1
predef getGameFlag(flagName)#1 predef getGameFlag(flagName)#1
predef getPos(px, py)#0 predef getPos(px, py)#0
@@ -59,6 +60,7 @@ import gamelib
predef getYN()#1 predef getYN()#1
predef giveItemToPlayer(p_player, itemFuncNum)#0 predef giveItemToPlayer(p_player, itemFuncNum)#0
predef initHeap(loadedSize)#0 predef initHeap(loadedSize)#0
predef initPlayerXP(player)#0
predef loadFrameImg(img)#0 predef loadFrameImg(img)#0
predef loadMainFrameImg()#0 predef loadMainFrameImg()#0
predef makeModifier(name, value)#1 predef makeModifier(name, value)#1
@@ -92,11 +94,9 @@ import gamelib
predef readStr()#1 predef readStr()#1
predef removeFromList(pList, toRemove)#0 predef removeFromList(pList, toRemove)#0
predef removePlayerFromParty(playerName)#0 predef removePlayerFromParty(playerName)#0
predef restoreCursor()#0
predef rightJustifyNum(num, rightX)#0 predef rightJustifyNum(num, rightX)#0
predef rightJustifyStr(str, rightX)#0 predef rightJustifyStr(str, rightX)#0
predef rollDice(encoded)#1 predef rollDice(encoded)#1
predef saveCursor()#0
predef scanForNamedObj(p_obj, name)#1 predef scanForNamedObj(p_obj, name)#1
predef scriptCombat(mapCode)#1 predef scriptCombat(mapCode)#1
predef scriptDisplayStr(str)#0 predef scriptDisplayStr(str)#0
@@ -105,6 +105,7 @@ import gamelib
predef scriptSetAvatar(avatarTileNum)#0 predef scriptSetAvatar(avatarTileNum)#0
predef scriptSwapTile(fromX, fromY, toX, toY)#0 predef scriptSwapTile(fromX, fromY, toX, toY)#0
predef setCmd(key, func)#0 predef setCmd(key, func)#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 setIntimateMode(enable)#0

View File

@@ -66,7 +66,7 @@ predef showParty()#0
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Global variables // Global variables
export byte mapNum = -1 export byte mapNum = -1
export byte mapIs3D = -1 export byte mapIs3D = 0
word mapNameHash = 0 word mapNameHash = 0
word totalMapWidth word totalMapWidth
word totalMapHeight word totalMapHeight
@@ -804,17 +804,10 @@ export asm setWindow(top, bottom, left, right)#0
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Save the cursor position (1 save slot) // Get the cursor position - returns X, Y
export asm saveCursor()#0 export asm getCursor()#2
+asmPlasmNoRet 0 bit setLcRW+lcBank2
jmp SaveCursor jmp GetCursor
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Restore the cursor position (1 save slot)
export asm restoreCursor()#0
+asmPlasmNoRet 0
jmp RestCursor
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1184,6 +1177,12 @@ export def rawDisplayf1(str, arg1)#0; rawDisplayStr(sprintf3(str, arg1, 0, 0));
export def rawDisplayf2(str, arg1, arg2)#0; rawDisplayStr(sprintf3(str, arg1, arg2, 0)); end export def rawDisplayf2(str, arg1, arg2)#0; rawDisplayStr(sprintf3(str, arg1, arg2, 0)); end
export def rawDisplayf3(str, arg1, arg2, arg3)#0; rawDisplayStr(sprintf3(str, arg1, arg2, arg3)); end export def rawDisplayf3(str, arg1, arg2, arg3)#0; rawDisplayStr(sprintf3(str, arg1, arg2, arg3)); end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Set the cursor position in the font engine
export def setCursor(x, y)#0
rawDisplayf2("^V%D^T%D", y, x)
end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
export def parseDec(str)#1 export def parseDec(str)#1
word n word n
@@ -1404,8 +1403,8 @@ end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Window for the large upper right bar // Window for the large upper right bar
export def setWindow2()#0 export def setWindow2()#0
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
displayChar('N'-$40) // Set normal mode - clear all special modes (like underline, etc.)
end end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1471,9 +1470,9 @@ end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Display the party data on the screen // Display the party data on the screen
export def showParty()#0 export def showParty()#0
word p word p, cursX, cursY
saveCursor() cursX, cursY = getCursor()
setWindow3() setWindow3()
clearWindow() clearWindow()
@@ -1484,7 +1483,7 @@ export def showParty()#0
p = p=>p_nextObj p = p=>p_nextObj
loop loop
if p if p
rawDisplayStr("^Y^I LEVEL UP ^N\n") rawDisplayStr("^Y^I LEVEL U)P ^N\n")
else else
rawDisplayStr("^LName") rawDisplayStr("^LName")
rightJustifyStr(@S_HEALTH, CHAR_WND_HEALTH_X) // begin underline mode rightJustifyStr(@S_HEALTH, CHAR_WND_HEALTH_X) // begin underline mode
@@ -1506,7 +1505,7 @@ export def showParty()#0
copyWindow() copyWindow()
fin fin
setWindow2() setWindow2()
restoreCursor() setCursor(cursX, cursY)
needShowParty = FALSE needShowParty = FALSE
end end
@@ -1994,7 +1993,7 @@ export def scriptDisplayStr(str)#0
pIntimate=>intimate_displayStr(str) pIntimate=>intimate_displayStr(str)
else else
textDrawn = TRUE textDrawn = TRUE
flipToPage1() if renderLoaded; flipToPage1(); fin
displayStr(str) displayStr(str)
fin fin
^kbdStrobe ^kbdStrobe
@@ -2086,12 +2085,12 @@ end
// Display a portrait drawing (typically called from scripts) // Display a portrait drawing (typically called from scripts)
export def setPortrait(portraitNum)#0 export def setPortrait(portraitNum)#0
word srcData word srcData
byte part, cx, cy byte part, cx, cy, cursX, cursY
clearPortrait() clearPortrait()
// We're going to switch windows. Save the cursor pos in the text window. // We're going to switch windows. Save the cursor pos in the text window.
saveCursor() 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() unloadTextures()
@@ -2102,7 +2101,7 @@ export def setPortrait(portraitNum)#0
// Restore the cursor position // Restore the cursor position
setWindow2() setWindow2()
restoreCursor() setCursor(cursX, cursY)
// Load the portrait image and display it // Load the portrait image and display it
part = lookupResourcePart(3, portraitNum) part = lookupResourcePart(3, portraitNum)
@@ -2302,6 +2301,24 @@ def showPlayer3()#1
return showPlayerSheet(2) return showPlayerSheet(2)
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Level up the first character that's applicable
def levelUp()#1
word player
byte n
player = global=>p_players
n = 0
while player
if player->b_skillPoints
showPlayerSheet(n)
return 0
fin
player = player=>p_nextObj
loop
beep
return 0
end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
export def addEncounterZone(code, x, y, dist, chance)#0 export def addEncounterZone(code, x, y, dist, chance)#0
word p word p
@@ -2450,6 +2467,7 @@ def initCmds()#0
cmdTbl['1'] = @showPlayer1 cmdTbl['1'] = @showPlayer1
cmdTbl['2'] = @showPlayer2 cmdTbl['2'] = @showPlayer2
cmdTbl['3'] = @showPlayer3 cmdTbl['3'] = @showPlayer3
cmdTbl['U'] = @levelUp
cmdTbl[$13] = @saveGame // ctrl-S cmdTbl[$13] = @saveGame // ctrl-S
cmdTbl[$0c] = @loadGame // ctrl-L cmdTbl[$0c] = @loadGame // ctrl-L
cmdTbl['?'] = @help cmdTbl['?'] = @help
@@ -2715,14 +2733,12 @@ export def addXP(val)#1
player=>w_curXP = 29999 player=>w_curXP = 29999
fin fin
while player=>w_curXP >= player=>w_nextXP while player=>w_curXP >= player=>w_nextXP
if player=>w_curXP > 0 // Level up!
// Level up! player->b_level++
player->b_level++ player->b_skillPoints = player->b_skillPoints + callGlobalFunc(GS_LEVEL_S_P, player->b_level, 0, 0)
player->b_skillPoints = player->b_skillPoints + callGlobalFunc(GS_LEVEL_S_P, player->b_level, 0, 0) player=>w_maxHealth = player=>w_maxHealth + player->b_stamina + rollDice($2600) // stam + 2d6
player=>w_maxHealth = player=>w_maxHealth + player->b_stamina + rollDice($2600) // stam + 2d6 player=>w_health = player=>w_maxHealth // let's make leveling up an extra nice thing
player=>w_health = player=>w_maxHealth // let's make leveling up an extra nice thing needShowParty = TRUE
needShowParty = TRUE
fin
// Check XP for next level, and enforce level cap if any // Check XP for next level, and enforce level cap if any
n = callGlobalFunc(GS_LEVEL_X_P, player->b_level + 1, 0, 0) n = callGlobalFunc(GS_LEVEL_X_P, player->b_level + 1, 0, 0)
@@ -2738,6 +2754,14 @@ export def addXP(val)#1
return val return val
end end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Initialize XP (and skill pts) for newly created character
export def initPlayerXP(player)#0
player->b_skillPoints = callGlobalFunc(GS_LEVEL_S_P, player->b_level, 0, 0)
player=>w_curXP = callGlobalFunc(GS_LEVEL_X_P, player->b_level, 0, 0)
player=>w_nextXP = callGlobalFunc(GS_LEVEL_X_P, player->b_level + 1, 0, 0)
end
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
export def addPlayerToParty(playerFuncNum)#0 export def addPlayerToParty(playerFuncNum)#0
word p word p

View File

@@ -279,6 +279,13 @@ def showSkills(player, numToBump)#1
clearLittleArea(x2, y+9) clearLittleArea(x2, y+9)
fin fin
displaySkill(player, NULL, @y, x2, 0, "Skill points", player+b_skillPoints) displaySkill(player, NULL, @y, x2, 0, "Skill points", player+b_skillPoints)
if player->c_gender > ' '
vspace()
rawDisplayf2("\n^T%D%s", x2+32, "Gender")
rightJustifyStr(sprintf1("%c", player->c_gender), x2+26)
fin
return skillNum-1 return skillNum-1
end end
@@ -471,13 +478,19 @@ end
// the item is returned; else NULL is returned. // the item is returned; else NULL is returned.
def _showPlayerSheet(player_num)#1 // funcTbl functions always have to return a value def _showPlayerSheet(player_num)#1 // funcTbl functions always have to return a value
word player, item word player, item
byte i_page, totalItems, itemsOnPage, redisplay, sel, mode byte i_page, totalItems, itemsOnPage, redisplay, sel, mode, noRepeatMenu
setBigWindow() setBigWindow()
i_page = 0 i_page = 0
redisplay = 2 redisplay = 2
mode = 'I' // 'I' for inventory, 'S' for skills noRepeatMenu = FALSE
player = numToPlayer(player_num)
if player->b_skillPoints
mode = 'S' // go straight to level up if applicable
else
mode = 'I' // otherwise default to inventory mode
fin
repeat repeat
player = numToPlayer(player_num) player = numToPlayer(player_num)
if !player; beep; return NULL; fin if !player; beep; return NULL; fin
@@ -499,11 +512,14 @@ def _showPlayerSheet(player_num)#1 // funcTbl functions always have to return a
redisplay = 0 redisplay = 0
fin fin
if mode == 'I' if !noRepeatMenu
showInvMenu(player, totalItems, i_page, itemsOnPage) if mode == 'I'
else // 'S' showInvMenu(player, totalItems, i_page, itemsOnPage)
showSkillsMenu(player, itemsOnPage) else // 'S'
showSkillsMenu(player, itemsOnPage)
fin
fin fin
noRepeatMenu = FALSE
// Get a key, do something // Get a key, do something
sel = getUpperKey() sel = getUpperKey()
@@ -585,6 +601,13 @@ def _showPlayerSheet(player_num)#1 // funcTbl functions always have to return a
sel = sel - 'A' sel = sel - 'A'
if sel >= 0 and sel < itemsOnPage and player->b_skillPoints if sel >= 0 and sel < itemsOnPage and player->b_skillPoints
showSkills(player, sel+1) showSkills(player, sel+1)
// Redisplay when last pt allocated
if !player->b_skillPoints
clearWindow()
redisplay = 1
else
noRepeatMenu = TRUE
fin
else else
beep beep
fin fin

View File

@@ -51,6 +51,7 @@ struc Player
byte t_type byte t_type
word p_nextObj word p_nextObj
word s_name word s_name
byte c_gender
byte b_combatOrder byte b_combatOrder
word p_combatNext word p_combatNext
word w_health word w_health