From bcd833e7582e14f17b52225314b6b790c1109fcc Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 22 Nov 2013 04:51:47 -0500 Subject: [PATCH] version checks for event script commands and move in related asm --- engine/scripting.asm | 94 +++++++++++++++++++++++++++++++++++++++++++- main.asm | 78 ------------------------------------ 2 files changed, 92 insertions(+), 80 deletions(-) diff --git a/engine/scripting.asm b/engine/scripting.asm index 0885266fd..4fabec928 100644 --- a/engine/scripting.asm +++ b/engine/scripting.asm @@ -1,3 +1,75 @@ +; Event scripting commands. + + +Function96c56: ; 96c56 + push af + ld a, 1 + ld [ScriptMode], a + pop af + ret +; 96c5e + + +ScriptEvents: ; 96c5e + call StartScript +.loop + ld a, [ScriptMode] + ld hl, .modes + rst JumpTable + call CheckScript + jr nz, .loop + ret +; 96c6e + +.modes ; 96c6e + dw EndScript + dw RunScriptCommand + dw WaitScriptMovement + dw WaitScript + +EndScript: ; 96c76 + call StopScript + ret +; 96c7a + +WaitScript: ; 96c7a + call StopScript + + ld hl, ScriptDelay + dec [hl] + ret nz + + callba Function58b9 + + ld a, SCRIPT_READ + ld [ScriptMode], a + call StartScript + ret +; 96c91 + +WaitScriptMovement: ; 96c91 + call StopScript + + ld hl, VramState + bit 7, [hl] + ret nz + + callba Function58b9 + + ld a, SCRIPT_READ + ld [ScriptMode], a + call StartScript + ret +; 96ca9 + +RunScriptCommand: ; 96ca9 + call GetScriptByte + ld hl, ScriptCommandTable + rst JumpTable + ret +; 96cb1 + + ScriptCommandTable: ; 0x96cb1 dw Script_2call dw Script_3call @@ -81,7 +153,9 @@ ScriptCommandTable: ; 0x96cb1 dw Script_loadmenudata dw Script_writebackup dw Script_jumptextfaceplayer +IF _CRYSTAL dw Script_3jumptext +ENDC dw Script_jumptext dw Script_closetext dw Script_keeptextopen @@ -279,6 +353,9 @@ JumpTextScript: ; 0x96e7a end ; 0x96e81 + +IF _CRYSTAL + Script_3jumptext: ; 0x96e81 ; script command 0x52 ; parameters: @@ -295,6 +372,9 @@ Script_3jumptext: ; 0x96e81 jp ScriptJump ; 0x96e9b +ENDC + + Script_2writetext: ; 0x96e9b ; script command 0x4c ; parameters: @@ -2018,7 +2098,7 @@ Script_checkver: ; 0x976a6 ; 0x976ad Version: ; 976ad - db 0 ; VERSION + db VERSION ; 976ae Script_pokenamemem: ; 0x976ae @@ -3117,7 +3197,7 @@ DisplayCredits: call Function261b call StopScript ret -; 0x97c05 +; 0x97c051 Script_wait: ; 0x97c05 ; script command 0xa8 @@ -3146,3 +3226,13 @@ Script_unknown0xa9: ; 0x97c15 ret ; 0x97c20 + +Function97c20: ; 97c20 + ld a, [.byte] + ld [ScriptVar], a + ret + +.byte + db 0 +; 97c28 + diff --git a/main.asm b/main.asm index 777320965..127f9b0ec 100644 --- a/main.asm +++ b/main.asm @@ -86686,87 +86686,9 @@ UnknownScript_0x96c4f: ; 96c4f ; 96c56 -Function96c56: ; 96c56 - push af - ld a, 1 - ld [ScriptMode], a - pop af - ret -; 96c5e - - -ScriptEvents: ; 96c5e - call StartScript -.loop - ld a, [ScriptMode] - ld hl, .modes - rst JumpTable - call CheckScript - jr nz, .loop - ret -; 96c6e - -.modes ; 96c6e - dw EndScript - dw RunScriptCommand - dw WaitScriptMovement - dw WaitScript - -EndScript: ; 96c76 - call StopScript - ret -; 96c7a - -WaitScript: ; 96c7a - call StopScript - - ld hl, ScriptDelay - dec [hl] - ret nz - - callba Function58b9 - - ld a, SCRIPT_READ - ld [ScriptMode], a - call StartScript - ret -; 96c91 - -WaitScriptMovement: ; 96c91 - call StopScript - - ld hl, VramState - bit 7, [hl] - ret nz - - callba Function58b9 - - ld a, SCRIPT_READ - ld [ScriptMode], a - call StartScript - ret -; 96ca9 - -RunScriptCommand: ; 96ca9 - call GetScriptByte - ld hl, ScriptCommandTable - rst JumpTable - ret -; 96cb1 - - INCLUDE "engine/scripting.asm" -Function97c20: ; 97c20 - ld a, [.byte] - ld [ScriptVar], a - ret - -.byte - db 0 -; 97c28 - Function97c28: ; 97c28 ld hl, StatusFlags2 res 1, [hl]