From 2c50d19c48ad074d641a66de0e21bf621a758a74 Mon Sep 17 00:00:00 2001 From: Martin Haye Date: Fri, 2 Jun 2017 08:25:29 -0700 Subject: [PATCH] Outlaw-configurable combat and enemy intro text now working. --- .../src/org/badvision/A2PackPartitions.groovy | 21 +++++++++----- Platform/Apple/virtual/src/plasma/combat.pla | 28 ++++--------------- Platform/Apple/virtual/src/plasma/diskops.pla | 2 +- .../Apple/virtual/src/plasma/gameloop.pla | 17 +++++++++-- 4 files changed, 36 insertions(+), 32 deletions(-) diff --git a/Platform/Apple/tools/PackPartitions/src/org/badvision/A2PackPartitions.groovy b/Platform/Apple/tools/PackPartitions/src/org/badvision/A2PackPartitions.groovy index a8138474..c8e719a2 100644 --- a/Platform/Apple/tools/PackPartitions/src/org/badvision/A2PackPartitions.groovy +++ b/Platform/Apple/tools/PackPartitions/src/org/badvision/A2PackPartitions.groovy @@ -82,7 +82,7 @@ class A2PackPartitions def itemNameToFunc = [:] def playerNameToFunc = [:] - def requiredGlobalScripts = ["New Game", "Help", "Combat win", "Combat intro", "Enemy intro", "Death"] + def requiredGlobalScripts = ["New Game", "Help", "Combat win", "Combat intro", "Combat prompt", "Enemy intro", "Death"] def globalScripts = [:] def lastSysModule @@ -2295,7 +2295,7 @@ class A2PackPartitions } } def result = buf.toString() - if (result.length() > 15) + if (result.length() > 16) { // PLASMA's compiler has a silent limit on the number of significant // characters in a symbol. To make the symbol short enough but still @@ -3011,7 +3011,10 @@ end } out.println "" modules.each { k, v -> - out.println "const MOD_${humanNameToSymbol(k, true)} = ${v.num}" + if (humanNameToSymbol(k, true).startsWith("GS_")) + out.println "const ${humanNameToSymbol(k, true)} = ${v.num}" + else + out.println "const MOD_${humanNameToSymbol(k, true)} = ${v.num}" } } replaceIfDiff("build/src/plasma/gen_modules.plh") @@ -3419,7 +3422,7 @@ end assert proc.value[0].@name == "RETURN" assert proc.value[0].block.size() == 1 outIndented("return ") - packExpr(proc.value[0].block[0]) + packExpr(proc.value[0].block[0], true) out << "\n" } @@ -3585,7 +3588,7 @@ end def name = "v_" + humanNameToSymbol(getSingle(blk.field, 'VAR'), false) variables << name outIndented("$name = ") - packExpr(getSingle(getSingle(blk.value).block)) + packExpr(getSingle(getSingle(blk.value).block), true) // true to intern any strings out << "\n" } @@ -3728,7 +3731,7 @@ end } // Now generate the code. Pad with zeros to make exactly 3 args - outIndented("callGlobalFunc(MOD_GS_${humanNameToSymbol(funcName, true)}") + outIndented("callGlobalFunc(GS_${humanNameToSymbol(funcName, true)}") (0..<3).each { idx -> out << ", " if (idx < blk.value.size()) { @@ -3853,7 +3856,7 @@ end out << "partyHasPlayer(${escapeString(name)})" } - def packExpr(blk) + def packExpr(blk, internString = false) { switch (blk.@type) { case 'math_number': @@ -3881,7 +3884,11 @@ end packVarGet(blk) break case 'text': + if (internString) + out << "mmgr(HEAP_INTERN, " out << escapeString(getSingle(blk.field, 'TEXT').text()) + if (internString) + out << ")" break case 'interaction_has_item': packHasItem(blk) diff --git a/Platform/Apple/virtual/src/plasma/combat.pla b/Platform/Apple/virtual/src/plasma/combat.pla index 2b1a7d31..a393479b 100644 --- a/Platform/Apple/virtual/src/plasma/combat.pla +++ b/Platform/Apple/virtual/src/plasma/combat.pla @@ -212,19 +212,7 @@ def playerCombatChoose(pl) // Let them know their options displayStr("\n") - when rand16() % 5 - is 0 - displayStr("Think fast!"); break - is 1 - displayStr("Do you:"); break - is 2 - displayStr("Suck it up:"); break - is 3 - displayStr("Options:"); break - otherwise - displayStr("Decisions, decisions..."); break - wend - + callGlobalFunc(GS_COMBAT_PROMPT, 0, 0, 0) displayOption('M', "Melee") if pWeapon if pWeapon->b_clipCurrent @@ -477,23 +465,19 @@ def startCombat(mapCode) clearWindow() // General intro to the combat situation - callGlobalFunc(MOD_GS_COMBAT_INTRO, 0, 0, 0) + callGlobalFunc(GS_COMBAT_INTRO, 0, 0, 0) // Say who we're fighting - - displayStr(s) p = global=>p_enemyGroups while p n = countList(p=>p_enemies) setPlural(n <> 1) - puts("Calling enemy intro\n") - s = callGlobalFunc(MOD_GS_ENEMY_INTRO, 0, 0, 0) - printf1("Intro: %s\n", s) + s = callGlobalFunc(GS_ENEMY_INTRO, 0, 0, 0) displayf2(s, n, p=>p_enemies=>s_name) p = p=>p_nextObj loop - rawDisplayStr("\nDo you:\n") + rawDisplayStr("\n\nDo you:\n") displayOption('B', "Battle") displayOption('F', "Flee") while TRUE @@ -563,10 +547,10 @@ def _combat_zoneEncounter(s_encZone) p = global=>p_combatFirst while p if !nPlayersFighting - callGlobalFunc(MOD_GS_DEATH, 0, 0, 0) + callGlobalFunc(GS_DEATH, 0, 0, 0) return -99 // special code for death elsif !nEnemiesFighting - callGlobalFunc(MOD_GS_COMBAT_WIN, 0, 0, 0) + callGlobalFunc(GS_COMBAT_WIN, 0, 0, 0) // Grab the loot displayf1("You find %d gold pieces!", addGold(collectLoot())) getUpperKey() diff --git a/Platform/Apple/virtual/src/plasma/diskops.pla b/Platform/Apple/virtual/src/plasma/diskops.pla index e8465315..8a369fc9 100644 --- a/Platform/Apple/virtual/src/plasma/diskops.pla +++ b/Platform/Apple/virtual/src/plasma/diskops.pla @@ -268,7 +268,7 @@ def newGame() global->b_curAvatar = 0 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, MOD_GS_NEW_GAME<<8 | RES_TYPE_MODULE) + newGameModule = mmgr(QUEUE_LOAD, GS_NEW_GAME<<8 | RES_TYPE_MODULE) mmgr(FINISH_LOAD, 0) playersModule()=>makeInitialParty() newGameModule()() diff --git a/Platform/Apple/virtual/src/plasma/gameloop.pla b/Platform/Apple/virtual/src/plasma/gameloop.pla index 04b98f38..f1701d80 100644 --- a/Platform/Apple/virtual/src/plasma/gameloop.pla +++ b/Platform/Apple/virtual/src/plasma/gameloop.pla @@ -611,13 +611,16 @@ end export asm puts +asmPlasm 1 sta pTmp + lda #'!' + ldx #1 sty pTmp+1 + beq + ; safety: print '!' instead of null string ldy #0 lda (pTmp),y tax iny - lda (pTmp),y - ora #$80 ++ ora #$80 +safeCout iny dex @@ -1070,6 +1073,10 @@ export def printf3(str, arg1, arg2, arg3) word pos word curArg word p + if !str + printChar('!') // Safety valve for NULL string pointer + return + fin pos = 0 curArg = @arg1 while TRUE @@ -2123,6 +2130,12 @@ def loadEngine(moduleNum) flipToPage1() mmgr(START_LOAD, 1) // code is in partition 1 curEngine = mmgr(QUEUE_LOAD, moduleNum<<8 | RES_TYPE_MODULE) + // For combat module, pre-load some global funcs + if moduleNum == MOD_COMBAT + mmgr(QUEUE_LOAD, GS_COMBAT_INTRO<<8 | RES_TYPE_MODULE) + mmgr(QUEUE_LOAD, GS_COMBAT_PROMPT<<8 | RES_TYPE_MODULE) + mmgr(QUEUE_LOAD, GS_ENEMY_INTRO<<8 | RES_TYPE_MODULE) + fin mmgr(FINISH_LOAD, 0) return curEngine() // return function table end @@ -2289,7 +2302,7 @@ end def help flipToPage1() setMapWindow(); clearWindow() - loadEngine(MOD_GS_HELP)() + loadEngine(GS_HELP)() returnFromEngine(TRUE) end