diff --git a/Platform/Apple/tools/PLASMA/src/PLVM02#4000 b/Platform/Apple/tools/PLASMA/src/PLVM02#4000 index b9274cb2..1330adfb 100644 Binary files a/Platform/Apple/tools/PLASMA/src/PLVM02#4000 and b/Platform/Apple/tools/PLASMA/src/PLVM02#4000 differ diff --git a/Platform/Apple/virtual/src/core/mem.s b/Platform/Apple/virtual/src/core/mem.s index 42e9b10e..807d17e5 100644 --- a/Platform/Apple/virtual/src/core/mem.s +++ b/Platform/Apple/virtual/src/core/mem.s @@ -1029,7 +1029,11 @@ retPSrc: heapIntern: !zone stx pTmp sty pTmp+1 - jsr startHeapScan + tya + ora pTmp ; check for null input ptr + bne + + rts ; input null -> output null ++ jsr startHeapScan bcs .notfnd ; handle case of empty heap .blklup bvs .nxtblk ; it's a string diff --git a/Platform/Apple/virtual/src/plasma/gameloop.pla b/Platform/Apple/virtual/src/plasma/gameloop.pla index 232a5ab9..84d5bc7f 100644 --- a/Platform/Apple/virtual/src/plasma/gameloop.pla +++ b/Platform/Apple/virtual/src/plasma/gameloop.pla @@ -1489,6 +1489,7 @@ def initMap(x, y, dir) // Load the frame image, then raycaster or tile engine loadMainFrameImg() + mmgr(START_LOAD, 1) mmgr(SET_MEM_TARGET, displayEngine) if mapIs3D mmgr(QUEUE_LOAD, CODE_RENDER<<8 | RES_TYPE_CODE) @@ -2539,7 +2540,9 @@ end export def addUnique(pList, p_thing) if !scanForNamedObj(*pList, p_thing=>s_name) addToList(pList, p_thing) + return TRUE fin + return FALSE end /////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Platform/Apple/virtual/src/plasma/party.pla b/Platform/Apple/virtual/src/plasma/party.pla index c70a7d5e..e9886864 100644 --- a/Platform/Apple/virtual/src/plasma/party.pla +++ b/Platform/Apple/virtual/src/plasma/party.pla @@ -242,7 +242,7 @@ def _party_doPlayerSheet(num) // Get size of inventory pane in chars getMapWindow(@hMap, @vMap) - i_rows = vMap / 9 // our fancy font engine does 9 scanlines per char, for nice descenders + i_rows = (vMap / 9) - 3 // 9 rows per line; minus 3 lines for header/footer i_page = 0 repeat player = showPlayerSheet(num, i_page, i_rows) diff --git a/Platform/Apple/virtual/src/plasma/store.pla b/Platform/Apple/virtual/src/plasma/store.pla index 39de218f..c168865f 100644 --- a/Platform/Apple/virtual/src/plasma/store.pla +++ b/Platform/Apple/virtual/src/plasma/store.pla @@ -16,8 +16,8 @@ include "gen_items.plh" const PAGE_SIZE = 14 // (183-10)/9 lines, minus 5 lines for header/footer -const STATS_COL_1 = 60 -const STATS_COL_2 = 120 +const STATS_COL_1 = 45 +const STATS_COL_2 = 140 // Exported functions go here. First a predef for each one, then a table with function pointers // in the same order as the constants are defined in the header. @@ -28,6 +28,7 @@ word pItemsModule const MAX_PAGE_ITEMS = 20 // should be plenty word pageItems[MAX_PAGE_ITEMS] word pagePrices[MAX_PAGE_ITEMS] +word pMatchPlayer /////////////////////////////////////////////////////////////////////////////////////////////////// // Definitions used by assembly code @@ -185,7 +186,7 @@ end /////////////////////////////////////////////////////////////////////////////////////////////////// def formatStr(str) - rawDisplayf1("%s", str) + rawDisplayStr(str) end /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -232,15 +233,15 @@ end /////////////////////////////////////////////////////////////////////////////////////////////////// def displayWeaponStats(pItem1, pItem2) - displayTwoCol("Uses", pItem1, pItem2, b_maxUses, @byteField, @formatNum) - displayTwoCol("Ammo", pItem1, pItem2, s_ammoKind, @wordField, @formatStr) - displayTwoCol("Clip", pItem1, pItem2, b_clipSize, @byteField, @formatNum) - displayTwoCol("Melee", pItem1, pItem2, r_meleeDmg, @wordField, @formatDice) - displayTwoCol("Proj", pItem1, pItem2, r_projectileDmg, @wordField, @formatDice) - displayTwoCol("Attck", pItem1, pItem2, ba_attacks+0, @byteField, @formatAttack) - displayTwoCol("Att 2", pItem1, pItem2, ba_attacks+1, @byteField, @formatAttack) - displayTwoCol("Att 3", pItem1, pItem2, ba_attacks+2, @byteField, @formatAttack) - displayTwoCol("Range", pItem1, pItem2, b_weaponRange, @byteField, @formatNum) + displayTwoCol("Uses", pItem1, pItem2, b_maxUses, @byteField, @formatNum) + displayTwoCol("Ammo", pItem1, pItem2, s_ammoKind, @wordField, @formatStr) + displayTwoCol("Clip", pItem1, pItem2, b_clipSize, @byteField, @formatNum) + displayTwoCol("Melee", pItem1, pItem2, r_meleeDmg, @wordField, @formatDice) + displayTwoCol("Proj", pItem1, pItem2, r_projectileDmg, @wordField, @formatDice) + displayTwoCol("Attack", pItem1, pItem2, ba_attacks+0, @byteField, @formatAttack) + displayTwoCol("Att 2", pItem1, pItem2, ba_attacks+1, @byteField, @formatAttack) + displayTwoCol("Att 3", pItem1, pItem2, ba_attacks+2, @byteField, @formatAttack) + displayTwoCol("Range", pItem1, pItem2, b_weaponRange, @byteField, @formatNum) end /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -258,6 +259,12 @@ end def displayItemStats(pItem1, price, pItem2) word pMod1, pMod2 + clearWindow() + rawDisplayf1("^T108Browse\n\n^T%D^LMerchandise^L", STATS_COL_1) + if pItem2 + rawDisplayf2("^T%D^L%s^L", STATS_COL_2, pMatchPlayer=>s_name) + fin + // First, show the item type and name when pItem1->t_type is TYPE_ITEM; rawDisplayStr("\nItem"); break @@ -297,21 +304,27 @@ def displayItemStats(pItem1, price, pItem2) loop fin - rawDisplayf2("\n\nPrice^T%D%d", STATS_COL_1, price) + rawDisplayf2("\n\nGold^T%D%d", STATS_COL_1, price) + rawDisplayf2("^T%D%d", STATS_COL_2, global=>w_gold) end /////////////////////////////////////////////////////////////////////////////////////////////////// def matchEquipped(pMatch, nSkip) - word pPlayer, pItem, k1, k2 + word pPlayer, pItem pPlayer = global=>p_players + pMatchPlayer = NULL while pPlayer pItem = pPlayer=>p_items while pItem - printf2(" pl=$%x it=$%x\n", pPlayer, pItem) if (pItem->t_type == pMatch->t_type) and (pItem->t_type == TYPE_WEAPON or pItem->t_type == TYPE_ARMOR) - if (pItem->b_flags & ITEM_FLAG_EQUIP) and (pItem=>s_itemKind == pMatch=>s_itemKind) - if nSkip == 0; return pItem; fin - nSkip = nSkip - 1 + if (pItem->b_flags & ITEM_FLAG_EQUIP) + if pItem->t_type <> TYPE_ARMOR or (pItem=>s_itemKind == pMatch=>s_itemKind) + if nSkip == 0 + pMatchPlayer = pPlayer + return pItem + fin + nSkip = nSkip - 1 + fin fin fin pItem = pItem=>p_nextObj @@ -321,27 +334,50 @@ def matchEquipped(pMatch, nSkip) return NULL end +/////////////////////////////////////////////////////////////////////////////////////////////////// +def displayItemMenu(price, hasNextComp) + rawDisplayf1("\n\n[Esc]^T%D", STATS_COL_1) + if price <= global=>w_gold + rawDisplayStr("B)uy it") + else + rawDisplayStr("(too much)") + fin + if hasNextComp + rawDisplayf1("^T%DN)ext compare", STATS_COL_2) + fin +end + /////////////////////////////////////////////////////////////////////////////////////////////////// def browseItem(num) word pItem, price, compSkip, pComp + byte sel pItem = pageItems[num] price = pagePrices[num] compSkip = 0 - while TRUE - clearWindow() - rawDisplayStr("^T108Browse\n") - puts("match\n") - pComp = matchEquipped(compSkip) - if compSkip > 0 and !pComp - compSkip = 0; pComp = matchEquipped(compSkip) - fin - puts("disp\n") - displayItemStats(pItem, price, pComp) - if getUpperKey() == $1B // Esc + displayItemStats(pItem, price, matchEquipped(pItem, compSkip)) + displayItemMenu(price, compSkip or matchEquipped(pItem, 1+compSkip)) + sel = getUpperKey() + if sel == 'B' and global=>w_gold >= price + matchEquipped(pItem, compSkip) // to set pMatchPlayer + if !addUnique(@pMatchPlayer=>p_items, pItem) + rawDisplayStr("\n\nDuplicate item.") + beep() + pause(800) + else + global=>w_gold = global=>w_gold - price + rawDisplayStr("\n\nSold!") + pause(500) + break + fin + elsif sel == 'N' and (compSkip or matchEquipped(pItem, 1+compSkip)) + compSkip++ + if !matchEquipped(pItem, compSkip); compSkip = 0; fin + elsif sel == $1B // Esc break + else + beep() fin - compSkip++ loop end @@ -350,11 +386,11 @@ def _buyFromStore(storeCode, markupRatio) word pItemTbl, choice byte nItemsOnPage, pageNum, nPages, redisplay - setOversizeWindow() - loadItems() pItemTbl = pItemsModule()=>items_forStoreCode(storeCode) + setOversizeWindow() + nPages = (countArray(pItemTbl) + PAGE_SIZE) / PAGE_SIZE pageNum = 0