From 55cd9892e3783ae6eb4a6fa702a3154d30c65433 Mon Sep 17 00:00:00 2001 From: Martin Haye Date: Thu, 31 Dec 2015 09:56:50 -0800 Subject: [PATCH] More efficient way to call global scripts. --- Platform/Apple/virtual/src/plasma/combat.pla | 3 ++ .../Apple/virtual/src/plasma/gameloop.pla | 18 ++++------ .../virtual/src/plasma/globalScripts.pla | 34 ++++++------------- .../virtual/src/plasma/globalScripts.plh | 28 +++++++-------- 4 files changed, 34 insertions(+), 49 deletions(-) diff --git a/Platform/Apple/virtual/src/plasma/combat.pla b/Platform/Apple/virtual/src/plasma/combat.pla index 29e7e87e..992cb553 100644 --- a/Platform/Apple/virtual/src/plasma/combat.pla +++ b/Platform/Apple/virtual/src/plasma/combat.pla @@ -391,6 +391,9 @@ def startCombat() // Display portrait of first group setPortrait(global=>p_enemyGroups=>p_enemies->ba_images[0]) + // If portrait was already in memory, the memory mgr load might still be open. Close it. + mmgr(FINISH_LOAD, 0) + // We're going to do all our text drawing in window 2. Also, might as well // set everything up so that the map gets redrawn when combat finishes. setWindow2() diff --git a/Platform/Apple/virtual/src/plasma/gameloop.pla b/Platform/Apple/virtual/src/plasma/gameloop.pla index b318bd0d..b1f00817 100644 --- a/Platform/Apple/virtual/src/plasma/gameloop.pla +++ b/Platform/Apple/virtual/src/plasma/gameloop.pla @@ -1851,7 +1851,7 @@ end /////////////////////////////////////////////////////////////////////////////////////////////////// def testCombat() - word globalScripts, callScript + word globalScripts word combatEngine word x, y byte dir @@ -1865,16 +1865,15 @@ def testCombat() combatEngine = mmgr(QUEUE_LOAD, MODULE_COMBAT<<8 | RES_TYPE_MODULE) globalScripts = mmgr(QUEUE_LOAD, MODULE_GLOBAL_SCRIPTS<<8 | RES_TYPE_MODULE) mmgr(FINISH_LOAD, 1) // 1 = keep open - callScript = globalScripts() // Create the enemy group(s). global=>p_enemyGroups = NULL when rand16() % 2 is 0 - addToList(@global=>p_enemyGroups, callScript(script_new_EnemyGroup_Dirt_Bags)) + addToList(@global=>p_enemyGroups, globalScripts()=>script_new_EnemyGroup_Dirt_Bags()) break otherwise - addToList(@global=>p_enemyGroups, callScript(script_new_EnemyGroup_Flesh_Feeders)) + addToList(@global=>p_enemyGroups, globalScripts()=>script_new_EnemyGroup_Flesh_Feeders()) break wend @@ -2038,16 +2037,11 @@ end /////////////////////////////////////////////////////////////////////////////////////////////////// // Create the party def initParty() - word globalScripts, callScript - + word globalScripts globalScripts = mmgr(QUEUE_LOAD, MODULE_GLOBAL_SCRIPTS<<8 | RES_TYPE_MODULE) mmgr(FINISH_LOAD, 1) // 1 = keep open - - callScript = globalScripts() - addToList(@global=>p_players, callScript(script_new_Player_Hue_Hauser)) - addToList(@global=>p_players, callScript(script_new_Player_Mokahnu)) - - // No need for the global scripts now that everything has been created + addToList(@global=>p_players, globalScripts()=>script_new_Player_Hue_Hauser()) + addToList(@global=>p_players, globalScripts()=>script_new_Player_Mokahnu()) mmgr(FREE_MEMORY, globalScripts) end diff --git a/Platform/Apple/virtual/src/plasma/globalScripts.pla b/Platform/Apple/virtual/src/plasma/globalScripts.pla index 9d8386cc..4e0cb8bd 100644 --- a/Platform/Apple/virtual/src/plasma/globalScripts.pla +++ b/Platform/Apple/virtual/src/plasma/globalScripts.pla @@ -12,6 +12,16 @@ include "gamelib.plh" include "playtype.plh" include "gen_images.plh" +predef new_Modifier, new_Armor_Chaps, new_Armor_ShamanHeaddress, new_Armor_TahnkuPants, new_Armor_TahnkuVest +predef new_Weapon_Handgun, new_Weapon_SpiritBow, new_Weapon_SpiritBlade, calcPlayerArmor, new_Player_Hue_Hauser +predef new_Player_Mokahnu, new_Enemy_Dirt_Bag, new_EnemyGroup_Dirt_Bags, new_Enemy_Flesh_Feeder +predef new_EnemyGroup_Flesh_Feeders + +word[] funcTbl = @new_Modifier, @new_Armor_Chaps, @new_Armor_ShamanHeaddress, @new_Armor_TahnkuPants, @new_Armor_TahnkuVest +word = @new_Weapon_Handgun, @new_Weapon_SpiritBow, @new_Weapon_SpiritBlade, @calcPlayerArmor, @new_Player_Hue_Hauser +word = @new_Player_Mokahnu, @new_Enemy_Dirt_Bag, @new_EnemyGroup_Dirt_Bags, @new_Enemy_Flesh_Feeder +word = @new_EnemyGroup_Flesh_Feeders + /////////////////////////////////////////////////////////////////////////////////////////////////// def new_Modifier(kind, value) word p @@ -296,27 +306,5 @@ def new_EnemyGroup_Flesh_Feeders return p end -/////////////////////////////////////////////////////////////////////////////////////////////////// -def callGlobalScript(n) - when n - is 0; return new_Modifier() - is 1; return new_Armor_Chaps() - is 2; return new_Armor_ShamanHeaddress() - is 3; return new_Armor_TahnkuPants() - is 4; return new_Armor_TahnkuVest() - is 5; return new_Weapon_Handgun() - is 6; return new_Weapon_SpiritBow() - is 7; return new_Weapon_SpiritBlade() - is 8; return calcPlayerArmor() - is 9; return new_Player_Hue_Hauser() - is 10; return new_Player_Mokahnu() - is 11; return new_Enemy_Dirt_Bag() - is 12; return new_EnemyGroup_Dirt_Bags() - is 13; return new_Enemy_Flesh_Feeder() - is 14; return new_EnemyGroup_Flesh_Feeders() - otherwise; brk() - wend -end - -return @callGlobalScript +return @funcTbl done \ No newline at end of file diff --git a/Platform/Apple/virtual/src/plasma/globalScripts.plh b/Platform/Apple/virtual/src/plasma/globalScripts.plh index e15ecfd2..08a13bcb 100644 --- a/Platform/Apple/virtual/src/plasma/globalScripts.plh +++ b/Platform/Apple/virtual/src/plasma/globalScripts.plh @@ -9,17 +9,17 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// const script_new_Modifier = 0 -const script_new_Armor_Chaps = 1 -const script_new_Armor_ShamanHeaddress = 2 -const script_new_Armor_TahnkuPants = 3 -const script_new_Armor_TahnkuVest = 4 -const script_new_Weapon_Handgun = 5 -const script_new_Weapon_SpiritBow = 6 -const script_new_Weapon_SpiritBlade = 7 -const script_calcPlayerArmor = 8 -const script_new_Player_Hue_Hauser = 9 -const script_new_Player_Mokahnu = 10 -const script_new_Enemy_Dirt_Bag = 11 -const script_new_EnemyGroup_Dirt_Bags = 12 -const script_new_Enemy_Flesh_Feeder = 13 -const script_new_EnemyGroup_Flesh_Feeders = 14 \ No newline at end of file +const script_new_Armor_Chaps = 2 +const script_new_Armor_ShamanHeaddress = 4 +const script_new_Armor_TahnkuPants = 6 +const script_new_Armor_TahnkuVest = 8 +const script_new_Weapon_Handgun = 10 +const script_new_Weapon_SpiritBow = 12 +const script_new_Weapon_SpiritBlade = 14 +const script_calcPlayerArmor = 16 +const script_new_Player_Hue_Hauser = 18 +const script_new_Player_Mokahnu = 20 +const script_new_Enemy_Dirt_Bag = 22 +const script_new_EnemyGroup_Dirt_Bags = 24 +const script_new_Enemy_Flesh_Feeder = 26 +const script_new_EnemyGroup_Flesh_Feeders = 28 \ No newline at end of file