From a2425e0751354f69e686258bbdbb3feeb3cf22a5 Mon Sep 17 00:00:00 2001 From: Martin Haye Date: Thu, 12 Sep 2019 07:21:09 -0700 Subject: [PATCH] Added a new 'promptAnyKey' block to save space and time. --- .../mythos/mythos-editor/html/editor.html | 1 + .../mythos-editor/js/mythos_uncompressed.js | 22 ++++++++++++++---- .../src/org/badvision/A2PackPartitions.groovy | 23 +++++++++++++++---- Platform/Apple/virtual/src/plasma/gamelib.plh | 2 +- .../Apple/virtual/src/plasma/gameloop.pla | 4 ++-- 5 files changed, 40 insertions(+), 12 deletions(-) diff --git a/OutlawEditor/src/main/resources/mythos/mythos-editor/html/editor.html b/OutlawEditor/src/main/resources/mythos/mythos-editor/html/editor.html index a6f9b7cf..895f927a 100644 --- a/OutlawEditor/src/main/resources/mythos/mythos-editor/html/editor.html +++ b/OutlawEditor/src/main/resources/mythos/mythos-editor/html/editor.html @@ -124,6 +124,7 @@ + diff --git a/OutlawEditor/src/main/resources/mythos/mythos-editor/js/mythos_uncompressed.js b/OutlawEditor/src/main/resources/mythos/mythos-editor/js/mythos_uncompressed.js index 43208759..ade7ec88 100644 --- a/OutlawEditor/src/main/resources/mythos/mythos-editor/js/mythos_uncompressed.js +++ b/OutlawEditor/src/main/resources/mythos/mythos-editor/js/mythos_uncompressed.js @@ -535,18 +535,30 @@ if (typeof Mythos === "undefined") { this.setTooltip('Get a key from the keyboard (and discard it)'); } }; - Blockly.Blocks['text_mode'] = { + Blockly.Blocks['text_getanykey'] = { init: function () { this.setHelpUrl(Mythos.helpUrl); this.setColour(54); this.setPreviousStatement(true); this.setNextStatement(true); - var textModes = new Blockly.FieldDropdown([['Normal', 0], ['Inverse', 1]]); this.appendDummyInput() - .appendField("Text Mode") - .appendField(textModes, "MODE"); + .appendField("Get any key"); this.setOutput(false); - this.setTooltip('Print text and leave cursor at end of last printed character'); + this.setTooltip('Get a key from the keyboard (and discard it)'); + } + }; + Blockly.Blocks['text_promptanykey'] = { + init: function () { + this.setHelpUrl(Mythos.helpUrl); + this.setColour(54); + this.setPreviousStatement(true); + this.setNextStatement(true); + this.appendDummyInput() + .appendField("Prompt for key") + .appendField(new Blockly.FieldDropdown([["with", "1"], ["without", "0"]]), "CLEAR") + .appendField("clear"); + this.setOutput(false); + this.setTooltip('Prompt "(press any key)", wait for key, optionally clear window after'); } }; Blockly.Blocks['text_clear_window'] = { diff --git a/Platform/Apple/tools/PackPartitions/src/org/badvision/A2PackPartitions.groovy b/Platform/Apple/tools/PackPartitions/src/org/badvision/A2PackPartitions.groovy index 0f2e2b68..2617ce98 100644 --- a/Platform/Apple/tools/PackPartitions/src/org/badvision/A2PackPartitions.groovy +++ b/Platform/Apple/tools/PackPartitions/src/org/badvision/A2PackPartitions.groovy @@ -1830,7 +1830,7 @@ class A2PackPartitions /** Iterate an array of maps, adding them one at a time until we get to one * that won't fit. The maps list is modified to remove all that were accepted. - * Returns [chunks, spaceRemaining] + * Returns [chunks, spaceUsed, spaceRemaining] */ def fillDisk(int partNum, int availBlks, ArrayList maps, Set toDupe) { @@ -1904,7 +1904,7 @@ class A2PackPartitions } reportWriter.println String.format(" %-22s: %6.1fK", "unused", (availBlks*512 - spaceUsed) / 1024.0) reportWriter.println "Total: 140K" - return [outChunks, spaceUsed] + return [outChunks, spaceUsed, availBlks*512 - spaceUsed] } def recordChunks(typeName, nameToData) { @@ -2029,7 +2029,10 @@ class A2PackPartitions def mapsToDupe = allMaps.grep{ it.name != "" && it.order < 0 }.collect{ it.name }.toSet() def mapsTodo = allMaps.collect { it.name } def partChunks = [] + def totalFloppySpace = 0 + def totalUnused = 0 for (int partNum=1; partNum<=MAX_DISKS && !mapsTodo.isEmpty(); partNum++) { + totalFloppySpace += (FLOPPY_SIZE * 512) int availBlks = FLOPPY_SIZE - DOS_OVERHEAD availBlks -= AC_KLUDGE // AppleCommander currently unable to allocate last block if (partNum == 1) { @@ -2042,10 +2045,13 @@ class A2PackPartitions availBlks -= calcSaveGameBlks() } - def (chunks, spaceUsed) = fillDisk(partNum, availBlks, mapsTodo, mapsToDupe) + def (chunks, spaceUsed, spaceUnused) = fillDisk(partNum, availBlks, mapsTodo, mapsToDupe) partChunks << [partNum:partNum, chunks:chunks, spaceUsed:spaceUsed] + totalUnused += spaceUnused } assert allMaps.isEmpty : "All data must fit within $MAX_DISKS disks." + reportWriter.println String.format("\nTotal space on floppies: %6.1fK", totalFloppySpace / 1024.0) + reportWriter.println String.format("Total unused on floppies: %6.1fK", totalUnused / 1024.0) // If any stories, add them in a special final chunk. if (stories.size() > 0) { @@ -4717,6 +4723,8 @@ end packClearWindow(blk); break case 'text_getanykey': packGetAnyKey(blk); break + case 'text_promptanykey': + packPromptAnyKey(blk); break case 'controls_if': packIfStmt(blk); break case 'flow_repeat': @@ -4853,7 +4861,7 @@ end outIndented("if isFloppyVer\n") ++indent outTextBlock(blk.value[1].block, false) - outIndented("promptAnyKeyAndClear()\n") + outIndented("promptAnyKey(TRUE)\n") // TRUE = clear after --indent // On 800k or hard drive builds, follow the intro with the full (long) text @@ -4889,6 +4897,13 @@ end outIndented("getUpperKey()\n") } + def packPromptAnyKey(blk) + { + def clrFlg = getSingle(blk.field, 'CLEAR').text() + assert clrFlg == "0" || clrFlg == "1" + outIndented("promptAnyKey($clrFlg)\n") + } + def packVarSet(blk) { def name = "v_" + humanNameToSymbol(getSingle(blk.field, 'VAR'), false) diff --git a/Platform/Apple/virtual/src/plasma/gamelib.plh b/Platform/Apple/virtual/src/plasma/gamelib.plh index d068c9f2..d3b6cbe2 100644 --- a/Platform/Apple/virtual/src/plasma/gamelib.plh +++ b/Platform/Apple/virtual/src/plasma/gamelib.plh @@ -92,7 +92,7 @@ import gamelib predef printf3(fmt, arg1, arg2, arg3)#0 predef printHex(num)#0 predef printMem()#1 - predef promptAnyKeyAndClear()#0 + predef promptAnyKey(clearAfter)#0 predef puts(str)#0 predef queue_setMap(is3D, num, x, y, dir)#0 predef queue_teleport(x, y, dir)#0 diff --git a/Platform/Apple/virtual/src/plasma/gameloop.pla b/Platform/Apple/virtual/src/plasma/gameloop.pla index 159e9d78..e375e18a 100644 --- a/Platform/Apple/virtual/src/plasma/gameloop.pla +++ b/Platform/Apple/virtual/src/plasma/gameloop.pla @@ -2218,10 +2218,10 @@ def _scriptDisplayStr(str)#0 end /////////////////////////////////////////////////////////////////////////////////////////////////// -export def promptAnyKeyAndClear()#0 +export def promptAnyKey(clearAfter)#0 scriptDisplayStr("\n(press any key)") getUpperKey - clearWindow + if clearAfter; clearWindow; fin end ///////////////////////////////////////////////////////////////////////////////////////////////////