summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPikalaxALT <PikalaxALT@gmail.com>2015-11-05 15:08:00 -0500
committerPikalaxALT <PikalaxALT@gmail.com>2015-11-05 15:08:00 -0500
commit1205fe5100c09624350b5e6822b4c063586afcaf (patch)
tree04c3034bda38e17d0f7c901ddb153610cd9483f8
parentadf2fe712d372bad8c68590ae77b1dde85290d8f (diff)
PLAYEREVENT_
-rw-r--r--constants/map_setup_constants.asm4
-rw-r--r--constants/script_constants.asm14
-rw-r--r--engine/events.asm40
-rw-r--r--engine/scripting.asm2
-rw-r--r--home.asm2
-rw-r--r--home/map.asm18
-rw-r--r--main.asm14
-rw-r--r--maps/Colosseum.asm2
-rw-r--r--maps/GoldenrodMagnetTrainStation.asm2
-rw-r--r--maps/SaffronTrainStation.asm2
-rw-r--r--maps/TimeCapsule.asm2
-rw-r--r--maps/TradeCenter.asm2
-rw-r--r--misc/mobile_40.asm2
13 files changed, 61 insertions, 45 deletions
diff --git a/constants/map_setup_constants.asm b/constants/map_setup_constants.asm
index e3088496f..89d99ba90 100644
--- a/constants/map_setup_constants.asm
+++ b/constants/map_setup_constants.asm
@@ -1,5 +1,4 @@
-const_value SET $f0
- const MAPSETUP_00
+const_value SET $f1
const MAPSETUP_WARP
const MAPSETUP_02
const MAPSETUP_RELOADMAP
@@ -11,6 +10,7 @@ const_value SET $f0
const MAPSETUP_09
const MAPSETUP_10
const MAPSETUP_BADWARP
+ const MAPSETUP_12
; Command descriptions from Condensation water's scripting compendium. const_def
const_def
diff --git a/constants/script_constants.asm b/constants/script_constants.asm
index 191a9c024..5cda66d02 100644
--- a/constants/script_constants.asm
+++ b/constants/script_constants.asm
@@ -35,3 +35,17 @@ NUM_VARS EQU const_value
RETVAR_STRBUF2 EQU (0 << 6)
RETVAR_ADDR_DE EQU (1 << 6)
RETVAR_EXECUTE EQU (2 << 6)
+
+const_value SET -1
+ const PLAYEREVENT_MAPSCRIPT
+ const PLAYEREVENT_NONE
+ const PLAYEREVENT_SEENBYTRAINER
+ const PLAYEREVENT_TALKTOTRAINER
+ const PLAYEREVENT_ITEMBALL
+ const PLAYEREVENT_4
+ const PLAYEREVENT_WARP
+ const PLAYEREVENT_FALL
+ const PLAYEREVENT_7
+ const PLAYEREVENT_HATCH
+ const PLAYEREVENT_9
+NUM_PLAYER_EVENTS EQU const_value
diff --git a/engine/events.asm b/engine/events.asm
index 20e2bc0dd..04511f776 100644
--- a/engine/events.asm
+++ b/engine/events.asm
@@ -322,9 +322,9 @@ PlayerEvents: ; 9681f
ld [ScriptRunning], a
call DoPlayerEvent
ld a, [ScriptRunning]
- cp 4
+ cp PLAYEREVENT_4
jr z, .ok2
- cp 9
+ cp PLAYEREVENT_9
jr z, .ok2
xor a
@@ -1050,14 +1050,14 @@ DoPlayerEvent: ; 96beb
ld a, [ScriptRunning]
and a
ret z
- cp -1 ; run script
+ cp PLAYEREVENT_MAPSCRIPT ; run script
ret z
- cp 10
+ cp NUM_PLAYER_EVENTS
ret nc
ld c, a
ld b, 0
- ld hl, ScriptPointers96c0c
+ ld hl, PlayerEventScriptPointers
rept 3
add hl,bc
endr
@@ -1070,18 +1070,18 @@ endr
ret
; 96c0c
-ScriptPointers96c0c: ; 96c0c
- dba Invalid_0x96c2d
- dba SeenByTrainerScript
- dba TalkToTrainerScript
- dba FindItemInBallScript
- dba UnknownScript_0x96c4d
- dba WarpToNewMapScript
- dba FallIntoMapScript
- dba UnknownScript_0x124c8
- dba HatchEggScript
- dba UnknownScript_0x96c4f
- dba Invalid_0x96c2d
+PlayerEventScriptPointers: ; 96c0c
+ dba Invalid_0x96c2d ; 0
+ dba SeenByTrainerScript ; 1
+ dba TalkToTrainerScript ; 2
+ dba FindItemInBallScript ; 3
+ dba UnknownScript_0x96c4d ; 4
+ dba WarpToNewMapScript ; 5
+ dba FallIntoMapScript ; 6
+ dba UnknownScript_0x124c8 ; 7
+ dba HatchEggScript ; 8
+ dba UnknownScript_0x96c4f ; 9
+ dba Invalid_0x96c2d ; 10
; 96c2d
Invalid_0x96c2d: ; 96c2d
@@ -1122,11 +1122,11 @@ LandAfterPitfallScript: ; 96c4a
end
; 96c4d
-UnknownScript_0x96c4d: ; 96c4d
- reloadandreturn $f7
+UnknownScript_0x96c4d: ; 4
+ reloadandreturn MAPSETUP_07
; 96c4f
-UnknownScript_0x96c4f: ; 96c4f
+UnknownScript_0x96c4f: ; 9
deactivatefacing $3
callasm SetBit4_ScriptFlags3
end
diff --git a/engine/scripting.asm b/engine/scripting.asm
index 115ed77f8..360360f79 100644
--- a/engine/scripting.asm
+++ b/engine/scripting.asm
@@ -1664,7 +1664,7 @@ endr
ret
; 0x974f3
-Function974f3:: ; 0x974f3
+CallCallback:: ; 0x974f3
ld a, [ScriptBank]
or $80
ld [ScriptBank], a
diff --git a/home.asm b/home.asm
index 7bda59055..9def17d17 100644
--- a/home.asm
+++ b/home.asm
@@ -1242,7 +1242,7 @@ Function3574:: ; 3574
ld e, l
call Function35de
jr nc, .asm_3597
- call Function2631
+ call CallMapScript
callba EnableScriptMode
scf
ret
diff --git a/home/map.asm b/home/map.asm
index cb83a689d..e33e3bab9 100644
--- a/home/map.asm
+++ b/home/map.asm
@@ -208,7 +208,7 @@ endr
; 222a
Function222a:: ; 222a
- ld a, $fa
+ ld a, MAPSETUP_10
ld [hMapEntryMethod], a
callba RunMapSetupScript
xor a
@@ -967,14 +967,15 @@ CallScript:: ; 261f
ld a, h
ld [ScriptPos + 1], a
- ld a, $ff
+ ld a, PLAYEREVENT_MAPSCRIPT
ld [ScriptRunning], a
scf
ret
; 2631
-Function2631:: ; 2631
+CallMapScript:: ; 2631
+; Call a script at hl in the current bank if there isn't already a script running
ld a, [ScriptRunning]
and a
ret nz
@@ -988,7 +989,7 @@ RunMapCallback:: ; 263b
ld a, [hROMBank]
push af
call SwitchToMapScriptHeaderBank
- call Function2653
+ call .FindCallback
jr nc, .done
call GetMapScriptHeaderBank
@@ -1003,7 +1004,7 @@ RunMapCallback:: ; 263b
ret
; 2653
-Function2653:: ; 2653
+.FindCallback: ; 2653
ld a, [wCurrMapCallbackCount]
ld c, a
and a
@@ -1018,14 +1019,14 @@ Function2653:: ; 2653
.loop
ld a, [hl]
cp b
- jr z, .done
+ jr z, .found
add hl, de
dec c
jr nz, .loop
xor a
ret
-.done
+.found
inc hl
ld a, [hli]
ld h, [hl]
@@ -1035,7 +1036,8 @@ Function2653:: ; 2653
; 2674
ExecuteCallbackScript:: ; 2674
- callba Function974f3
+; Do map callback de and return to script bank b.
+ callba CallCallback
ld a, [ScriptMode]
push af
ld hl, ScriptFlags
diff --git a/main.asm b/main.asm
index 02bf1fb29..e9723661a 100644
--- a/main.asm
+++ b/main.asm
@@ -141,7 +141,7 @@ NewGame: ; 5b6b
ld a, SPAWN_HOME
ld [wd001], a
- ld a, $f1
+ ld a, MAPSETUP_WARP
ld [hMapEntryMethod], a
jp FinishContinueFunction
; 5b8f
@@ -451,7 +451,7 @@ Continue: ; 5d65
ld a, [wSpawnAfterChampion]
cp SPAWN_LANCE
jr z, .SpawnAfterE4
- ld a, $f2
+ ld a, MAPSETUP_02
ld [hMapEntryMethod], a
jp FinishContinueFunction
@@ -473,7 +473,7 @@ SpawnAfterRed: ; 5de2
PostCreditsSpawn: ; 5de7
xor a
ld [wSpawnAfterChampion], a
- ld a, $f1
+ ld a, MAPSETUP_WARP
ld [hMapEntryMethod], a
ret
; 5df0
@@ -5248,7 +5248,7 @@ FlyFunction: ; ca3b
special WarpToSpawnPoint
callasm DelayLoadingNewSprites
writecode VAR_MOVEMENT, $0
- newloadmap -4
+ newloadmap MAPSETUP_12
callasm Function8cb33
special WaitSFX
callasm Functioncacb
@@ -5516,7 +5516,7 @@ UsedDigOrEscapeRopeScript: ; 0xcc3c
farscall UnknownScript_0x122c1
special WarpToSpawnPoint
writecode VAR_MOVEMENT, $0
- newloadmap -11
+ newloadmap MAPSETUP_05
playsound SFX_WARP_FROM
applymovement PLAYER, MovementData_0xcc5d
end
@@ -5614,7 +5614,7 @@ Script_UsedTeleport: ; 0xccbb
farscall UnknownScript_0x122c1
special WarpToSpawnPoint
writecode VAR_MOVEMENT, $0
- newloadmap -12
+ newloadmap MAPSETUP_04
playsound SFX_WARP_FROM
applymovement PLAYER, MovementData_0xcce3
end
@@ -12257,7 +12257,7 @@ UnknownScript_0x124ce: ; 0x124ce
callasm Function12527
farscall UnknownScript_0x122c1
special WarpToSpawnPoint
- newloadmap $f1
+ newloadmap MAPSETUP_WARP
resetfuncs
.script_64f2
diff --git a/maps/Colosseum.asm b/maps/Colosseum.asm
index 52feffa09..7b9c5272a 100644
--- a/maps/Colosseum.asm
+++ b/maps/Colosseum.asm
@@ -49,7 +49,7 @@ ColosseumScript_Initialize:
MapColosseumSignpost1Script:
special Special_Colosseum
- newloadmap $f8
+ newloadmap MAPSETUP_08
end
ChrisScript_0x193499:
diff --git a/maps/GoldenrodMagnetTrainStation.asm b/maps/GoldenrodMagnetTrainStation.asm
index cdf7a8c1d..a20649ae1 100644
--- a/maps/GoldenrodMagnetTrainStation.asm
+++ b/maps/GoldenrodMagnetTrainStation.asm
@@ -35,7 +35,7 @@ OfficerScript_0x550ec:
writebyte $0
special Special_MagnetTrain
warpcheck
- newloadmap $f9
+ newloadmap MAPSETUP_09
applymovement PLAYER, .MovementBoardTheTrain
wait $14
end
diff --git a/maps/SaffronTrainStation.asm b/maps/SaffronTrainStation.asm
index 70b7834b4..455618116 100644
--- a/maps/SaffronTrainStation.asm
+++ b/maps/SaffronTrainStation.asm
@@ -35,7 +35,7 @@ OfficerScript_0x18a81e:
writebyte $1
special Special_MagnetTrain
warpcheck
- newloadmap $f9
+ newloadmap MAPSETUP_09
applymovement PLAYER, .MovementBoardTheTrain
wait $14
end
diff --git a/maps/TimeCapsule.asm b/maps/TimeCapsule.asm
index 32d52bb77..59f9c36b4 100644
--- a/maps/TimeCapsule.asm
+++ b/maps/TimeCapsule.asm
@@ -39,7 +39,7 @@ TimeCapsule_Initialize:
MapTimeCapsuleSignpost1Script:
special Special_TimeCapsule
- newloadmap $f8
+ newloadmap MAPSETUP_08
end
ChrisScript_0x19351a:
diff --git a/maps/TradeCenter.asm b/maps/TradeCenter.asm
index 3fad7fb24..a53f6a319 100644
--- a/maps/TradeCenter.asm
+++ b/maps/TradeCenter.asm
@@ -39,7 +39,7 @@ TradeCenter_Initialize:
MapTradeCenterSignpost1Script:
special Special_TradeCenter
- newloadmap $f8
+ newloadmap MAPSETUP_08
end
ChrisScript_0x19340b:
diff --git a/misc/mobile_40.asm b/misc/mobile_40.asm
index 3e1635959..25a769b85 100644
--- a/misc/mobile_40.asm
+++ b/misc/mobile_40.asm
@@ -406,7 +406,7 @@ Function1002c9: ; 1002c9
; 1002dc
Function1002dc: ; 1002dc
- ld a, $f8
+ ld a, MAPSETUP_08
ld [hMapEntryMethod], a
callba RunMapSetupScript
xor a