summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/battle_start.asm16
-rw-r--r--engine/map_objects.asm208
-rw-r--r--engine/movement.asm82
-rw-r--r--engine/save.asm18
-rw-r--r--engine/scripting.asm149
5 files changed, 244 insertions, 229 deletions
diff --git a/engine/battle_start.asm b/engine/battle_start.asm
index 0897b8a4a..5bcaad99c 100644
--- a/engine/battle_start.asm
+++ b/engine/battle_start.asm
@@ -27,7 +27,7 @@ Predef_StartBattle: ; 8c20f
ld [rSVBK], a
ld hl, wMapPals
- ld bc, $0040
+ ld bc, 8 palettes
xor a
call ByteFill
@@ -308,9 +308,11 @@ StartTrainerBattle_Flash: ; 8c3ab (23:43ab)
StartTrainerBattle_SetUpForWavyOutro: ; 8c3e8 (23:43e8)
callba Function5602
- ld a, $5
+ ld a, $5 ; BANK(LYOverrides)
ld [rSVBK], a
+
call StartTrainerBattle_NextScene
+
ld a, $43
ld [hLCDStatCustom], a
xor a
@@ -342,8 +344,8 @@ StartTrainerBattle_SineWave: ; 8c408 (23:4408)
ld d, [hl]
add [hl]
ld [hl], a
- ld a, $90
- ld bc, wd100
+ ld a, LYOverridesEnd - LYOverrides
+ ld bc, LYOverrides
ld e, $0
.loop
@@ -364,7 +366,7 @@ StartTrainerBattle_SineWave: ; 8c408 (23:4408)
StartTrainerBattle_SetUpForSpinOutro: ; 8c43d (23:443d)
callba Function5602
- ld a, $5
+ ld a, $5 ; BANK(LYOverrides)
ld [rSVBK], a
call StartTrainerBattle_NextScene
xor a
@@ -507,7 +509,7 @@ endr
StartTrainerBattle_SetUpForRandomScatterOutro: ; 8c578 (23:4578)
callba Function5602
- ld a, $5
+ ld a, $5 ; BANK(LYOverrides)
ld [rSVBK], a
call StartTrainerBattle_NextScene
ld a, $10
@@ -739,10 +741,12 @@ WipeLYOverrides: ; 8c6d8
push af
ld a, $5
ld [rSVBK], a
+
ld hl, LYOverrides
call .wipe
ld hl, LYOverridesBackup
call .wipe
+
pop af
ld [rSVBK], a
ret
diff --git a/engine/map_objects.asm b/engine/map_objects.asm
index 2de4074a8..e442b7f77 100644
--- a/engine/map_objects.asm
+++ b/engine/map_objects.asm
@@ -8,44 +8,44 @@ sprite_movement_data: macro
dn \6, 0
endm
; function, facing, action, flags1, flags2, palette flags
- sprite_movement_data SPRITEMOVEFN_00, DOWN, PERSON_ACTION_01, $02, $00, %0000 ; 00
- sprite_movement_data SPRITEMOVEFN_STANDING, DOWN, PERSON_ACTION_01, $0c, $00, %0000 ; 01
- sprite_movement_data SPRITEMOVEFN_RANDOM_WALK_XY, DOWN, PERSON_ACTION_01, $00, $00, %0000 ; 02
- sprite_movement_data SPRITEMOVEFN_SLOW_RANDOM_SPIN, DOWN, PERSON_ACTION_01, $00, $00, %0000 ; 03
- sprite_movement_data SPRITEMOVEFN_RANDOM_WALK_Y, DOWN, PERSON_ACTION_01, $00, $00, %0000 ; 04
- sprite_movement_data SPRITEMOVEFN_RANDOM_WALK_X, DOWN, PERSON_ACTION_01, $00, $00, %0000 ; 05
- sprite_movement_data SPRITEMOVEFN_STANDING, DOWN, PERSON_ACTION_01, $00, $00, %0000 ; 06
- sprite_movement_data SPRITEMOVEFN_STANDING, UP, PERSON_ACTION_01, $00, $00, %0000 ; 07
- sprite_movement_data SPRITEMOVEFN_STANDING, LEFT, PERSON_ACTION_01, $00, $00, %0000 ; 08
- sprite_movement_data SPRITEMOVEFN_STANDING, RIGHT, PERSON_ACTION_01, $00, $00, %0000 ; 09
- sprite_movement_data SPRITEMOVEFN_FAST_RANDOM_SPIN, DOWN, PERSON_ACTION_01, $00, $00, %0000 ; 0a
- sprite_movement_data SPRITEMOVEFN_OBEY_DPAD, DOWN, PERSON_ACTION_01, $02, $00, %0000 ; 0b
- sprite_movement_data SPRITEMOVEFN_08, DOWN, PERSON_ACTION_01, $00, $00, %0000 ; 0c
- sprite_movement_data SPRITEMOVEFN_09, DOWN, PERSON_ACTION_01, $00, $00, %0000 ; 0d
- sprite_movement_data SPRITEMOVEFN_0A, DOWN, PERSON_ACTION_01, $00, $00, %0000 ; 0e
- sprite_movement_data SPRITEMOVEFN_0B, DOWN, PERSON_ACTION_01, $00, $00, %0000 ; 0f
- sprite_movement_data SPRITEMOVEFN_0C, DOWN, PERSON_ACTION_01, $00, $00, %0000 ; 10
- sprite_movement_data SPRITEMOVEFN_0D, DOWN, PERSON_ACTION_01, $00, $00, %0000 ; 11
- sprite_movement_data SPRITEMOVEFN_0E, DOWN, PERSON_ACTION_01, $00, $00, %0000 ; 12
- sprite_movement_data SPRITEMOVEFN_FOLLOW, DOWN, PERSON_ACTION_01, $02, $00, %0000 ; 13
- sprite_movement_data SPRITEMOVEFN_SCRIPTED, DOWN, PERSON_ACTION_01, $02, $00, %0000 ; 14
+ sprite_movement_data SPRITEMOVEFN_00, DOWN, PERSON_ACTION_STAND, $02, $00, %0000 ; 00
+ sprite_movement_data SPRITEMOVEFN_STANDING, DOWN, PERSON_ACTION_STAND, $0c, $00, %0000 ; 01
+ sprite_movement_data SPRITEMOVEFN_RANDOM_WALK_XY, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 02
+ sprite_movement_data SPRITEMOVEFN_SLOW_RANDOM_SPIN, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 03
+ sprite_movement_data SPRITEMOVEFN_RANDOM_WALK_Y, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 04
+ sprite_movement_data SPRITEMOVEFN_RANDOM_WALK_X, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 05
+ sprite_movement_data SPRITEMOVEFN_STANDING, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 06
+ sprite_movement_data SPRITEMOVEFN_STANDING, UP, PERSON_ACTION_STAND, $00, $00, %0000 ; 07
+ sprite_movement_data SPRITEMOVEFN_STANDING, LEFT, PERSON_ACTION_STAND, $00, $00, %0000 ; 08
+ sprite_movement_data SPRITEMOVEFN_STANDING, RIGHT, PERSON_ACTION_STAND, $00, $00, %0000 ; 09
+ sprite_movement_data SPRITEMOVEFN_FAST_RANDOM_SPIN, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 0a
+ sprite_movement_data SPRITEMOVEFN_OBEY_DPAD, DOWN, PERSON_ACTION_STAND, $02, $00, %0000 ; 0b
+ sprite_movement_data SPRITEMOVEFN_08, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 0c
+ sprite_movement_data SPRITEMOVEFN_09, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 0d
+ sprite_movement_data SPRITEMOVEFN_0A, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 0e
+ sprite_movement_data SPRITEMOVEFN_0B, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 0f
+ sprite_movement_data SPRITEMOVEFN_0C, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 10
+ sprite_movement_data SPRITEMOVEFN_0D, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 11
+ sprite_movement_data SPRITEMOVEFN_0E, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 12
+ sprite_movement_data SPRITEMOVEFN_FOLLOW, DOWN, PERSON_ACTION_STAND, $02, $00, %0000 ; 13
+ sprite_movement_data SPRITEMOVEFN_SCRIPTED, DOWN, PERSON_ACTION_STAND, $02, $00, %0000 ; 14
sprite_movement_data SPRITEMOVEFN_BIG_SNORLAX, DOWN, PERSON_ACTION_09, $2e, $01, %1100 ; 15
sprite_movement_data SPRITEMOVEFN_BOUNCE, DOWN, PERSON_ACTION_0A, $2e, $00, %0000 ; 16
- sprite_movement_data SPRITEMOVEFN_STANDING, DOWN, PERSON_ACTION_01, $0c, $00, %0000 ; 17
- sprite_movement_data SPRITEMOVEFN_STANDING, DOWN, PERSON_ACTION_01, $2e, $10, %0000 ; 18
- sprite_movement_data SPRITEMOVEFN_STRENGTH, DOWN, PERSON_ACTION_01, $2e, $00, %0100 ; 19
- sprite_movement_data SPRITEMOVEFN_FOLLOWNOTEXACT, DOWN, PERSON_ACTION_01, $02, $00, %0000 ; 1a
+ sprite_movement_data SPRITEMOVEFN_STANDING, DOWN, PERSON_ACTION_STAND, $0c, $00, %0000 ; 17
+ sprite_movement_data SPRITEMOVEFN_STANDING, DOWN, PERSON_ACTION_STAND, $2e, $10, %0000 ; 18
+ sprite_movement_data SPRITEMOVEFN_STRENGTH, DOWN, PERSON_ACTION_STAND, $2e, $00, %0100 ; 19
+ sprite_movement_data SPRITEMOVEFN_FOLLOWNOTEXACT, DOWN, PERSON_ACTION_STAND, $02, $00, %0000 ; 1a
sprite_movement_data SPRITEMOVEFN_SHADOW, DOWN, PERSON_ACTION_00, $8e, $01, %0000 ; 1b
- sprite_movement_data SPRITEMOVEFN_EMOTE, DOWN, PERSON_ACTION_08, $8e, $02, %0000 ; 1c
+ sprite_movement_data SPRITEMOVEFN_EMOTE, DOWN, PERSON_ACTION_EMOTE, $8e, $02, %0000 ; 1c
sprite_movement_data SPRITEMOVEFN_SCREENSHAKE, DOWN, PERSON_ACTION_00, $82, $00, %0000 ; 1d
- sprite_movement_data SPRITEMOVEFN_SPIN_COUNTERCLOCKWISE, LEFT, PERSON_ACTION_01, $00, $00, %0000 ; 1e
- sprite_movement_data SPRITEMOVEFN_SPIN_CLOCKWISE, RIGHT, PERSON_ACTION_01, $00, $00, %0000 ; 1f
+ sprite_movement_data SPRITEMOVEFN_SPIN_COUNTERCLOCKWISE, LEFT, PERSON_ACTION_STAND, $00, $00, %0000 ; 1e
+ sprite_movement_data SPRITEMOVEFN_SPIN_CLOCKWISE, RIGHT, PERSON_ACTION_STAND, $00, $00, %0000 ; 1f
sprite_movement_data SPRITEMOVEFN_STRENGTH, DOWN, PERSON_ACTION_0C, $2e, $01, %1100 ; 20
sprite_movement_data SPRITEMOVEFN_STRENGTH, DOWN, PERSON_ACTION_0D, $2e, $01, %1100 ; 21
sprite_movement_data SPRITEMOVEFN_BOULDERDUST, DOWN, PERSON_ACTION_0E, $8e, $01, %0000 ; 22
sprite_movement_data SPRITEMOVEFN_GRASS, DOWN, PERSON_ACTION_0F, $8e, $02, %0000 ; 23
- sprite_movement_data SPRITEMOVEFN_RANDOM_WALK_XY, DOWN, PERSON_ACTION_01, $00, $00, %0010 ; 24
- sprite_movement_data SPRITEMOVEFN_00, DOWN, PERSON_ACTION_01, $00, $00, %0000 ; 25
+ sprite_movement_data SPRITEMOVEFN_RANDOM_WALK_XY, DOWN, PERSON_ACTION_STAND, $00, $00, %0010 ; 24
+ sprite_movement_data SPRITEMOVEFN_00, DOWN, PERSON_ACTION_STAND, $00, $00, %0000 ; 25
; 4357
@@ -167,7 +167,7 @@ Function43f3: ; 43f3
bit 5, [hl]
jr nz, .bit5
- cp STEP_TYPE_01
+ cp STEP_TYPE_STANDING
jr z, .one
jr .ok
@@ -186,7 +186,7 @@ Function43f3: ; 43f3
ld a, [hl]
and a
ret z
- cp STEP_TYPE_01
+ cp STEP_TYPE_STANDING
ret z
.ok
@@ -246,22 +246,22 @@ endr
Pointers445f: ; 445f
dw SetFacingStanding, SetFacingStanding ; 00
- dw Function44b5, SetFacingCurrent ; 01
- dw Function44c1, SetFacingCurrent ; 02
- dw Function4508, SetFacingCurrent ; 03
- dw Function4529, SetFacingCurrent ; 04
- dw Function4539, SetFacingStanding ; 05
- dw Function456e, Function456e ; 06
- dw Function457b, SetFacingStanding ; 07
- dw Function4582, Function4582 ; 08
- dw Function4589, Function4589 ; 09
- dw Function4590, Function45a4 ; 0a
- dw Function45ab, SetFacingCurrent ; 0c
- dw Function45be, Function45be ; 0b
- dw Function45c5, Function45c5 ; 0d
- dw Function45da, SetFacingStanding ; 0e
- dw Function45ed, SetFacingStanding ; 0f
- dw Function44e4, SetFacingCurrent ; 10
+ dw Function44b5, SetFacingCurrent ; 01 standing?
+ dw Function44c1, SetFacingCurrent ; 02 walking?
+ dw Function4508, SetFacingCurrent ; 03 bumping?
+ dw Function4529, SetFacingCurrent ; 04
+ dw Function4539, SetFacingStanding ; 05
+ dw Function456e, Function456e ; 06
+ dw Function457b, SetFacingStanding ; 07
+ dw Function4582, Function4582 ; 08
+ dw Function4589, Function4589 ; 09
+ dw Function4590, Function45a4 ; 0a
+ dw Function45ab, SetFacingCurrent ; 0c
+ dw Function45be, Function45be ; 0b
+ dw Function45c5, Function45c5 ; 0d
+ dw Function45da, SetFacingStanding ; 0e
+ dw Function45ed, SetFacingStanding ; 0f
+ dw Function44e4, SetFacingCurrent ; 10
; 44a3
SetFacingStanding: ; 44a3
@@ -444,10 +444,10 @@ Function457b: ; 457b
ret
; 4582
-Function4582: ; 4582
+Function4582: ; 4582 emote
ld hl, OBJECT_FACING_STEP
add hl, bc
- ld [hl], FACING_14
+ ld [hl], FACING_EMOTE
ret
; 4589
@@ -930,7 +930,7 @@ Function47bc: ; 47bc
call Function467b
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_01
+ ld [hl], STEP_TYPE_STANDING
ret
; 47dd
@@ -1033,7 +1033,7 @@ Function47dd: ; 47dd
call Function467b
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_01
+ ld [hl], PERSON_ACTION_STAND
ld hl, OBJECT_STEP_TYPE
add hl, bc
ld [hl], STEP_TYPE_05
@@ -1206,7 +1206,7 @@ Function47dd: ; 47dd
ld [hl], STANDING
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_01
+ ld [hl], PERSON_ACTION_STAND
ret
; 4958
@@ -1258,7 +1258,7 @@ Function47dd: ; 47dd
.MovementSpinRepeat: ; 499c
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_01
+ ld [hl], PERSON_ACTION_STAND
ld hl, OBJECT_RANGE
add hl, bc
ld a, [hl]
@@ -1354,7 +1354,7 @@ Function47dd: ; 47dd
call ._MovementShadow_Grass_Emote_BoulderDust
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_08
+ ld [hl], PERSON_ACTION_EMOTE
ld hl, OBJECT_STEP_DURATION
add hl, bc
ld [hl], 0
@@ -1500,9 +1500,9 @@ endr
call Function463f
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_02
+ ld [hl], PERSON_ACTION_STEP
- ld hl, wd4cf
+ ld hl, wCenteredObject
ld a, [hMapObjectIndexBuffer]
cp [hl]
jr z, .load_6
@@ -1515,7 +1515,7 @@ endr
.load_6
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_06
+ ld [hl], STEP_TYPE_PLAYER_WALK
ret
.NewDuration: ; 4b17
@@ -1541,7 +1541,7 @@ SetRandomStepDuration: ; 4b2d
ld [hl], STANDING
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_01
+ ld [hl], PERSON_ACTION_STAND
ld hl, OBJECT_STEP_TYPE
add hl, bc
ld [hl], STEP_TYPE_03
@@ -1552,19 +1552,19 @@ Pointers4b45: ; 4b45
; These pointers use OBJECT_STEP_TYPE. See constants/sprite_constants.asm
dw Function47bc ; 00
dw Function47dd ; 01
- dw Function4e2b ; 02
+ dw Function4e2b ; 02 npc walk
dw Function4ddd ; 03
dw Function4e21 ; 04
dw Function4e0c ; 05
- dw Function4e56 ; 06
+ dw Function4e56 ; 06 player walk
dw Function4e47 ; 07
- dw Function4b86 ; 08
- dw Function4bbf ; 09
- dw Function4e83 ; 0a
+ dw Function4b86 ; 08 npc jump step
+ dw Function4bbf ; 09 player jump step
+ dw Function4e83 ; 0a half step
dw Function4dff ; 0b
- dw Function4c18 ; 0c
- dw Function4c89 ; 0d
- dw Function4d14 ; 0e
+ dw Function4c18 ; 0c teleport from
+ dw Function4c89 ; 0d teleport to
+ dw Function4d14 ; 0e skyfall
dw Function4ecd ; 0f
dw Function4d7e ; 10
dw Function4daf ; 11
@@ -1585,7 +1585,7 @@ Function4b79: ; 4b79
ret nz
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_01
+ ld [hl], STEP_TYPE_STANDING
ret
; 4b86
@@ -1622,7 +1622,7 @@ Function4ba9: ; 4ba9
call Function4600
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_01
+ ld [hl], STEP_TYPE_STANDING
ret
; 4bbf
@@ -1674,7 +1674,7 @@ Function4bfd: ; 4bfd
call Function4600
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_01
+ ld [hl], STEP_TYPE_STANDING
ret
; 4c18
@@ -1698,7 +1698,7 @@ Function4c23: ; 4c23
Function4c32: ; 4c32
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_04
+ ld [hl], PERSON_ACTION_SPIN
ld hl, OBJECT_STEP_DURATION
add hl, bc
dec [hl]
@@ -1724,7 +1724,7 @@ Function4c42: ; 4c42
Function4c5d: ; 4c5d
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_04
+ ld [hl], PERSON_ACTION_SPIN
ld hl, OBJECT_31
add hl, bc
inc [hl]
@@ -1745,7 +1745,7 @@ Function4c5d: ; 4c5d
ld [hl], 0
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_01
+ ld [hl], STEP_TYPE_STANDING
ret
; 4c89
@@ -1795,7 +1795,7 @@ Function4cb3: ; 4cb3
Function4cc9: ; 4cc9
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_04
+ ld [hl], PERSON_ACTION_SPIN
ld hl, OBJECT_31
add hl, bc
inc [hl]
@@ -1823,7 +1823,7 @@ Function4ceb: ; 4ceb
Function4cf5: ; 4cf5
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_04
+ ld [hl], PERSON_ACTION_SPIN
ld hl, OBJECT_STEP_DURATION
add hl, bc
dec [hl]
@@ -1837,7 +1837,7 @@ Function4d01: ; 4d01
ld [hl], 0
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_01
+ ld [hl], STEP_TYPE_STANDING
ret
; 4d14
@@ -1865,7 +1865,7 @@ Function4d2e: ; 4d2e
ret nz
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_02
+ ld [hl], PERSON_ACTION_STEP
ld hl, OBJECT_STEP_FRAME
add hl, bc
ld [hl], 0
@@ -1902,7 +1902,7 @@ Function4d6b: ; 4d6b
ld [hl], 0
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_01
+ ld [hl], STEP_TYPE_STANDING
ret
; 4d7e
@@ -1936,7 +1936,7 @@ Function4d94: ; 4d94
ld [hl], 0
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_01
+ ld [hl], STEP_TYPE_STANDING
ret
; 4daf
@@ -1950,7 +1950,7 @@ Function4db5: ; 4db5
add hl, bc
ld a, [hl]
and %00000001
- ld a, PERSON_ACTION_01
+ ld a, PERSON_ACTION_STAND
jr z, .yes
ld a, PERSON_ACTION_00
@@ -1966,9 +1966,9 @@ Function4dc8: ; 4dc8
add hl, bc
ld a, [hl]
and %00000001
- ld a, PERSON_ACTION_04
+ ld a, PERSON_ACTION_SPIN
jr z, .yes
- ld a, PERSON_ACTION_05
+ ld a, PERSON_ACTION_SPIN_FLICKER
.yes
ld hl, OBJECT_ACTION
@@ -1987,7 +1987,7 @@ Function4ddd: ; 4ddd
ret nz
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_01
+ ld [hl], STEP_TYPE_STANDING
ret
; 4df0
@@ -2009,7 +2009,7 @@ Function4dff: ; 4dff
ret nz
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_01
+ ld [hl], STEP_TYPE_STANDING
ret
; 4e0c
@@ -2048,7 +2048,7 @@ Function4e2b: ; 4e2b
ld [hl], STANDING
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_01
+ ld [hl], STEP_TYPE_STANDING
ret
; 4e47
@@ -2089,7 +2089,7 @@ Function4e65: ; 4e65
ld [hl], STANDING
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_01
+ ld [hl], STEP_TYPE_STANDING
ret
; 4e83
@@ -2138,7 +2138,7 @@ Function4ec0: ; 4ec0
ret nz
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_01
+ ld [hl], STEP_TYPE_STANDING
ret
; 4ecd
@@ -2170,7 +2170,7 @@ Function4ecd: ; 4ecd
ld [hl], STANDING
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_01
+ ld [hl], STEP_TYPE_STANDING
ret
; 4f04
@@ -2302,7 +2302,7 @@ Function4f99: ; 4f99
ld [hl], 0
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_01
+ ld [hl], STEP_TYPE_STANDING
ret
; 4fb2
@@ -2731,17 +2731,19 @@ Function55e0:: ; 55e0
ret
; 5602
-Function5602: ; 5602
- call Function5645
- ld a, 0
- call Function5629
+Function5602: ; 5602, called at battle start
+ call Function5645 ; clear sprites
+ ld a, PLAYER
+ call Function5629 ; respawn player
+
ld a, [wd459]
bit 7, a
jr z, .ok
+
ld a, [hLastTalked]
and a
jr z, .ok
- call Function5629
+ call Function5629 ; respawn opponent
.ok
call _UpdateSprites
@@ -2749,9 +2751,9 @@ Function5602: ; 5602
; 561d
Function561d: ; 561d
- call Function5645
- ld a, 0
- call Function5629
+ call Function5645 ; clear sprites
+ ld a, PLAYER
+ call Function5629 ; respawn player
call _UpdateSprites
ret
; 5629
@@ -2783,7 +2785,7 @@ Function5645: ; 5645
ld bc, ObjectStructs
.loop
ld [hMapObjectIndexBuffer], a
- call Function5680
+ call SetFacing_Standing
ld hl, OBJECT_STRUCT_LENGTH
add hl, bc
ld b, h
@@ -2799,9 +2801,9 @@ Function565c: ; 565c
push bc
call Function56cd
pop bc
- jr c, Function5680
+ jr c, SetFacing_Standing
call Function56a3
- jr c, Function5680
+ jr c, SetFacing_Standing
call Function5688
callba Function4440
xor a
@@ -2810,13 +2812,13 @@ Function565c: ; 565c
Function5673: ; 5673
call Function56a3
- jr c, Function5680
- callba Function4440
+ jr c, SetFacing_Standing
+ callba Function4440 ; no need to farcall
xor a
ret
; 5680
-Function5680: ; 5680
+SetFacing_Standing: ; 5680
ld hl, OBJECT_FACING_STEP
add hl, bc
ld [hl], STANDING
diff --git a/engine/movement.asm b/engine/movement.asm
index 07bdc37c7..86a2eb6fb 100644
--- a/engine/movement.asm
+++ b/engine/movement.asm
@@ -87,7 +87,7 @@ MovementPointers: ; 5075
dw Movement_step_shake ; 55
dw Movement_56 ; 56
dw Movement_rock_smash ; 57
- dw Movement_return_dig ; 58
+ dw Movement_return_dig ; 58
dw Movement_59 ; 59
; 5129
@@ -129,7 +129,7 @@ Movement_step_dig: ; 5145
ld [hl], a
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_04
+ ld [hl], PERSON_ACTION_SPIN
call GetMovementByte
ld hl, OBJECT_STEP_DURATION
add hl, bc
@@ -159,17 +159,17 @@ Movement_return_dig: ; 516a
ld [hl], STANDING
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_12
+ ld [hl], STEP_TYPE_RETURN_DIG
ret
; 5189
Movement_fish_got_bite: ; 5189
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_06
+ ld [hl], PERSON_ACTION_FISHING
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_10
+ ld [hl], STEP_TYPE_GOT_BITE
ret
; 5196
@@ -180,20 +180,20 @@ Movement_rock_smash: ; 5196
ld [hl], a
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_01
+ ld [hl], PERSON_ACTION_STAND
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_11
+ ld [hl], STEP_TYPE_ROCK_SMASH
ret
; 51ab
Movement_fish_cast_rod: ; 51ab
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_06
+ ld [hl], PERSON_ACTION_FISHING
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_01
+ ld [hl], STEP_TYPE_STANDING
ret
; 51b8
@@ -219,7 +219,7 @@ Movement_step_end: ; 51c1
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_01
+ ld [hl], STEP_TYPE_STANDING
ret
; 51db
@@ -264,7 +264,7 @@ Movement_remove_person: ; 51fd
Movement_4b: ; 5210
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_01
+ ld [hl], PERSON_ACTION_STAND
ld hl, OBJECT_STEP_TYPE
add hl, bc
@@ -325,7 +325,7 @@ Movement_step_sleep_common: ; 5247
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_01
+ ld [hl], PERSON_ACTION_STAND
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
@@ -341,11 +341,11 @@ Movement_step_bump: ; 525f
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_0B
+ ld [hl], STEP_TYPE_BUMP
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_03
+ ld [hl], PERSON_ACTION_BUMP
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
@@ -457,7 +457,7 @@ TurnHead: ; 52ee
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_01
+ ld [hl], PERSON_ACTION_STAND
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
@@ -732,11 +732,11 @@ HalfStep: ; 5400
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_02
+ ld [hl], PERSON_ACTION_STEP
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_0A
+ ld [hl], STEP_TYPE_HALF_STEP
ret
; 5412
@@ -745,7 +745,7 @@ NormalStep: ; 5412
call Function463f
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_02
+ ld [hl], PERSON_ACTION_STEP
ld hl, OBJECT_NEXT_TILE
add hl, bc
@@ -760,20 +760,20 @@ NormalStep: ; 5412
call ShakeGrass
.skip_grass
- ld hl, wd4cf
+ ld hl, wCenteredObject
ld a, [hMapObjectIndexBuffer]
cp [hl]
- jr z, .step_type_06
+ jr z, .player
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_02
+ ld [hl], STEP_TYPE_NPC_WALK
ret
-.step_type_06
+.player
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_06
+ ld [hl], STEP_TYPE_PLAYER_WALK
ret
; 5446
@@ -783,22 +783,22 @@ TurningStep: ; 5446
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_04
+ ld [hl], PERSON_ACTION_SPIN
- ld hl, wd4cf
+ ld hl, wCenteredObject
ld a, [hMapObjectIndexBuffer]
cp [hl]
- jr z, .step_type_06
+ jr z, .player
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_02
+ ld [hl], STEP_TYPE_NPC_WALK
ret
-.step_type_06
+.player
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_06
+ ld [hl], STEP_TYPE_PLAYER_WALK
ret
; 5468
@@ -809,22 +809,22 @@ SlideStep: ; 5468
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_01
+ ld [hl], PERSON_ACTION_STAND
- ld hl, wd4cf
+ ld hl, wCenteredObject
ld a, [hMapObjectIndexBuffer]
cp [hl]
- jr z, .step_type_06
+ jr z, .player
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_02
+ ld [hl], STEP_TYPE_NPC_WALK
ret
-.step_type_06
+.player
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_06
+ ld [hl], STEP_TYPE_PLAYER_WALK
ret
; 548a
@@ -841,23 +841,23 @@ JumpStep: ; 548a
ld hl, OBJECT_ACTION
add hl, bc
- ld [hl], PERSON_ACTION_02
+ ld [hl], PERSON_ACTION_STEP
call SpawnShadow
- ld hl, wd4cf
+ ld hl, wCenteredObject
ld a, [hMapObjectIndexBuffer]
cp [hl]
- jr z, .step_type_09
+ jr z, .player
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_08
+ ld [hl], STEP_TYPE_NPC_JUMP
ret
-.step_type_09
+.player
ld hl, OBJECT_STEP_TYPE
add hl, bc
- ld [hl], STEP_TYPE_09
+ ld [hl], STEP_TYPE_PLAYER_JUMP
ret
; 54b8
diff --git a/engine/save.asm b/engine/save.asm
index de11a8133..8bccd932c 100644
--- a/engine/save.asm
+++ b/engine/save.asm
@@ -496,9 +496,9 @@ Function14da0: ; 14da0
ValidateSave: ; 14da9
ld a, BANK(s1_a008)
call GetSRAMBank
- ld a, $63
+ ld a, 99
ld [s1_a008], a
- ld a, $7f
+ ld a, " "
ld [s1_ad0f], a
jp CloseSRAM
; 14dbb
@@ -564,9 +564,9 @@ Function14e13: ; 14e13
ValidateBackupSave: ; 14e2d
ld a, BANK(s0_b208)
call GetSRAMBank
- ld a, $63
+ ld a, 99
ld [s0_b208], a
- ld a, $7f
+ ld a, " "
ld [s0_bf0f], a
call CloseSRAM
ret
@@ -661,7 +661,7 @@ TryLoadSaveFile: ; 14ea5 (5:4ea5)
.corrupt
ld a, [Options]
push af
- set 4, a
+ set NO_TEXT_SCROLL, a
ld [Options], a
ld hl, UnknownText_0x1529c
call PrintText
@@ -735,10 +735,10 @@ Function14f84: ; 14f84
ld a, BANK(s1_a008)
call GetSRAMBank
ld a, [s1_a008]
- cp $63
+ cp 99
jr nz, .nope
ld a, [s1_ad0f]
- cp $7f
+ cp " "
jr nz, .nope
ld hl, sOptions
ld de, Options
@@ -757,10 +757,10 @@ Function14faf: ; 14faf
ld a, BANK(s0_b208)
call GetSRAMBank
ld a, [s0_b208]
- cp $63
+ cp 99
jr nz, .nope
ld a, [s0_bf0f]
- cp $7f
+ cp " "
jr nz, .nope
ld hl, sBackupOptions
ld de, Options
diff --git a/engine/scripting.asm b/engine/scripting.asm
index 60618abab..a0acbf75c 100644
--- a/engine/scripting.asm
+++ b/engine/scripting.asm
@@ -241,7 +241,7 @@ ENDC
dw Script_trainerclassname
dw Script_name
dw Script_wait
- dw Script_unknown0xa9
+ dw Script_check_save
; 0x96e05
StartScript: ; 0x96e05
@@ -415,10 +415,10 @@ Script_repeattext: ; 0x96ebb
call GetScriptByte
ld h, a
cp -1
- jr nz, .done ; 0x96ec5 $11
+ jr nz, .done
ld a, l
cp -1
- jr nz, .done ; 0x96eca $c
+ jr nz, .done
ld hl, wd44e
ld a, [hli]
ld b, a
@@ -456,7 +456,7 @@ Script_yesorno: ; 0x96eed
call YesNoBox
ld a, 0
- jr c, .no ; 0x96ef2 $2
+ jr c, .no
ld a, 1
.no
ld [ScriptVar], a
@@ -567,12 +567,12 @@ Script_verbosegiveitem: ; 0x96f60
; 0x96f76
-Function96f76: ; 96f76
+ret_96f76: ; 96f76
ret
; 96f77
GiveItemScript: ; 96f77
- callasm Function96f76
+ callasm ret_96f76
writetext ReceivedItemText
iffalse .Full
waitbutton
@@ -792,16 +792,16 @@ Script_askforphonenumber: ; 0x970be
; number (SingleByteParam)
call YesNoBox
- jr c, .refused ; 0x970c1 $13
+ jr c, .refused
call GetScriptByte
ld c, a
callba AddPhoneNumber
- jr c, .phonefull ; 0x970cd $3
+ jr c, .phonefull
xor a
- jr .done ; 0x970d0 $9
+ jr .done
.phonefull
ld a, 1
- jr .done ; 0x970d4 $5
+ jr .done
.refused
call GetScriptByte
ld a, 2
@@ -1196,7 +1196,7 @@ ApplyPersonFacing: ; 0x9728b
ld a, d
push de
call CheckObjectVisibility
- jr c, .not_visible ; 0x97290 $27
+ jr c, .not_visible
ld hl, OBJECT_SPRITE
add hl, bc
ld a, [hl]
@@ -1207,13 +1207,13 @@ ApplyPersonFacing: ; 0x9728b
ld hl, OBJECT_FLAGS1
add hl, bc
bit 2, [hl]
- jr nz, .not_visible ; 0x972a4 $13
+ jr nz, .not_visible
pop de
ld a, e
call SetSpriteDirection
ld hl, VramState
bit 6, [hl]
- jr nz, .text_state ; 0x972b0 $3
+ jr nz, .text_state
call .DisableTextTiles
.text_state
call UpdateSprites
@@ -1235,7 +1235,7 @@ ApplyPersonFacing: ; 0x9728b
dec bc
ld a, b
or c
- jr nz, .loop ; 0x972cb $f8
+ jr nz, .loop
ret
; 0x972ce
@@ -1299,9 +1299,9 @@ ApplyEventActionAppearDisappear: ; 0x9730b
ld d, [hl]
ld a, -1
cp e
- jr nz, .okay ; 0x9731a $5
+ jr nz, .okay
cp d
- jr nz, .okay ; 0x9731d $2
+ jr nz, .okay
xor a
ret
.okay
@@ -1391,7 +1391,7 @@ Script_loademote: ; 0x97384
call GetScriptByte
cp -1
- jr nz, .not_var_emote ; 0x97389 $3
+ jr nz, .not_var_emote
ld a, [ScriptVar]
.not_var_emote
ld c, a
@@ -1563,21 +1563,21 @@ Script_returnafterbattle: ; 0x97459
ld a, [wBattleResult]
and $3f
cp $1
- jr nz, .notblackedout ; 0x97466 $8
+ jr nz, .notblackedout
ld b, BANK(Script_BattleWhiteout)
ld hl, Script_BattleWhiteout
jp ScriptJump
.notblackedout
bit 0, d
- jr z, .was_wild ; 0x97472 $8
+ jr z, .was_wild
callba MomTriesToBuySomething
- jr .done ; 0x9747a $12
+ jr .done
.was_wild
ld a, [wBattleResult]
bit 7, a
- jr z, .done ; 0x97481 $b
+ jr z, .done
ld b, BANK(Script_SpecialBillCall)
ld de, Script_SpecialBillCall
callba LoadScriptBDE
@@ -1643,12 +1643,18 @@ Script_2ptcall: ; 0x974be
; fallthrough
ScriptCall: ; 0x974cb
+; Bug: The script stack has a capacity of 5 scripts, yet there is
+; nothing to stop you from pushing a sixth script. The high part
+; of the script address can then be overwritten by modifications
+; to ScriptDelay, causing the script to return to the rst/interrupt
+; space.
+
push de
- ld hl, wd43c
+ ld hl, wScriptStackSize
ld e, [hl]
inc [hl]
ld d, $0
- ld hl, wd43d
+ ld hl, wScriptStackBA1
rept 3
add hl, de
endr
@@ -1751,8 +1757,8 @@ Script_if_equal: ; 0x97540
call GetScriptByte
ld hl, ScriptVar
cp [hl]
- jr z, Script_2jump ; 0x97547 $b5
- jr SkipTwoScriptBytes ; 0x97549 $4b
+ jr z, Script_2jump
+ jr SkipTwoScriptBytes
; 0x9754b
Script_if_not_equal: ; 0x9754b
@@ -1764,8 +1770,8 @@ Script_if_not_equal: ; 0x9754b
call GetScriptByte
ld hl, ScriptVar
cp [hl]
- jr nz, Script_2jump ; 0x97552 $aa
- jr SkipTwoScriptBytes ; 0x97554 $40
+ jr nz, Script_2jump
+ jr SkipTwoScriptBytes
; 0x97556
Script_if_greater_than: ; 0x97556
@@ -1778,8 +1784,8 @@ Script_if_greater_than: ; 0x97556
ld b, a
call GetScriptByte
cp b
- jr c, Script_2jump ; 0x9755e $9e
- jr SkipTwoScriptBytes ; 0x97560 $34
+ jr c, Script_2jump
+ jr SkipTwoScriptBytes
; 0x97562
Script_if_less_than: ; 0x97562
@@ -1792,8 +1798,8 @@ Script_if_less_than: ; 0x97562
ld b, a
ld a, [ScriptVar]
cp b
- jr c, Script_2jump ; 0x9756a $92
- jr SkipTwoScriptBytes ; 0x9756c $28
+ jr c, Script_2jump
+ jr SkipTwoScriptBytes
; 0x9756e
Script_jumpstd: ; 0x9756e
@@ -1802,7 +1808,7 @@ Script_jumpstd: ; 0x9756e
; predefined_script (MultiByteParam)
call StdScript
- jr ScriptJump ; 0x97571 $2a
+ jr ScriptJump
; 0x97573
Script_callstd: ; 0x97573
@@ -1870,7 +1876,7 @@ Script_checktriggers: ; 0x975c2
; script command 0x13
call CheckTriggers
- jr z, .asm_975cb ; 0x975c5 $4
+ jr z, .asm_975cb
ld [ScriptVar], a
ret
.asm_975cb
@@ -1892,7 +1898,7 @@ Script_checkmaptriggers: ; 0x975d1
call GetMapTrigger
ld a, d
or e
- jr z, .asm_975e5 ; 0x975de $5
+ jr z, .asm_975e5
ld a, [de]
ld [ScriptVar], a
ret
@@ -1911,7 +1917,7 @@ Script_dotrigger: ; 0x975eb
ld b, a
ld a, [MapNumber]
ld c, a
- jr Unknown_975fd ; 0x975f3 $8
+ jr Unknown_975fd
; 0x975f5
Script_domaptrigger: ; 0x975f5
@@ -1931,7 +1937,7 @@ Unknown_975fd: ; 0x975fd
call GetMapTrigger
ld a, d
or e
- jr z, .asm_97608 ; 0x97602 $4
+ jr z, .asm_97608
call GetScriptByte
ld [de], a
.asm_97608
@@ -2012,28 +2018,31 @@ Script_random: ; 0x97640
ld [ScriptVar], a
and a
ret z
+
ld c, a
- call Function97673
+ call .Divide256byC
and a
- jr z, .asm_9765f ; 0x9764d $10
+ jr z, .no_restriction ; 256 % b == 0
ld b, a
xor a
sub b
ld b, a
-.asm_97653
+.loop
push bc
call Random
pop bc
- ld a, [$ffe1]
+ ld a, [hRandomAdd]
cp b
- jr nc, .asm_97653 ; 0x9765b $f6
- jr .asm_97666 ; 0x9765d $7
-.asm_9765f
+ jr nc, .loop
+ jr .finish
+
+.no_restriction
push bc
call Random
pop bc
- ld a, [$ffe1]
-.asm_97666
+ ld a, [hRandomAdd]
+
+.finish
push af
ld a, [ScriptVar]
ld c, a
@@ -2043,14 +2052,14 @@ Script_random: ; 0x97640
ret
; 0x97673
-Function97673: ; 0x97673
+.Divide256byC: ; 0x97673
xor a
ld b, a
sub c
-.asm_97676
+.mod_loop
inc b
sub c
- jr nc, .asm_97676 ; 0x97678 $fc
+ jr nc, .mod_loop
dec b
add c
ret
@@ -2119,7 +2128,7 @@ Script_pokenamemem: ; 0x976ae
call GetScriptByte
and a
- jr nz, .gotit ; 0x976b2 $3
+ jr nz, .gotit
ld a, [ScriptVar]
.gotit
ld [wd265], a
@@ -2149,13 +2158,13 @@ Script_itemtotext: ; 0x976d5
call GetScriptByte
and a
- jr nz, .ok ; 0x976d9 $3
+ jr nz, .ok
ld a, [ScriptVar]
.ok
ld [wd265], a
call GetItemName
ld de, StringBuffer1
- jr ConvertMemToText ; 0x976e7 $d7
+ jr ConvertMemToText
; 0x976e9
Script_mapnametotext: ; 0x976e9
@@ -2183,7 +2192,7 @@ Script_displaylocation: ; 0x97701
; memory (SingleByteParam)
call GetScriptByte
- jr ConvertLandmarkToText ; 0x97704 $ee
+ jr ConvertLandmarkToText
; 0x97706
Script_trainertotext: ; 0x97706
@@ -2198,7 +2207,7 @@ Script_trainertotext: ; 0x97706
call GetScriptByte
ld b, a
callba GetTrainerName
- jr ConvertMemToText ; 0x97714 $aa
+ jr ConvertMemToText
; 0x97716
Script_name: ; 0x97716
@@ -2227,7 +2236,7 @@ Script_trainerclassname: ; 0x9772b
ld a, TRAINER_NAME
ld [wNamedObjectTypeBuffer], a
- jr ContinueToGetName ; 0x97730 $ea
+ jr ContinueToGetName
; 0x97732
Script_readmoney: ; 0x97732
@@ -2344,7 +2353,7 @@ Script_giveitem: ; 0x977ca
call GetScriptByte
cp ITEM_FROM_MEM
- jr nz, .ok ; 0x977cf $3
+ jr nz, .ok
ld a, [ScriptVar]
.ok
ld [CurItem], a
@@ -2352,7 +2361,7 @@ Script_giveitem: ; 0x977ca
ld [wItemQuantityChangeBuffer], a
ld hl, NumItems
call ReceiveItem
- jr nc, .full ; 0x977e3 $6
+ jr nc, .full
ld a, $1
ld [ScriptVar], a
ret
@@ -2718,7 +2727,7 @@ Script_checkevent: ; 0x979a4
call EventFlagAction
ld a, c
and a
- jr z, .false ; 0x979b3 $2
+ jr z, .false
ld a, 1
.false
ld [ScriptVar], a
@@ -2766,7 +2775,7 @@ Script_checkflag: ; 0x979d7
call _EngineFlagAction
ld a, c
and a
- jr z, .false ; 0x979e6 $2
+ jr z, .false
ld a, 1
.false
ld [ScriptVar], a
@@ -2835,7 +2844,7 @@ Script_warp: ; 0x97a1d
; This seems to be some sort of error handling case.
call GetScriptByte
and a
- jr z, .not_ok ; 0x97a21 $27
+ jr z, .not_ok
ld [MapGroup], a
call GetScriptByte
ld [MapNumber], a
@@ -3080,14 +3089,14 @@ Script_pause: ; 0x97b47
call GetScriptByte
and a
- jr z, .loop ; 0x97b4b $3
+ jr z, .loop
ld [ScriptDelay], a
.loop
ld c, 2
call DelayFrames
ld hl, ScriptDelay
dec [hl]
- jr nz, .loop ; 0x97b59 $f5
+ jr nz, .loop
ret
; 0x97b5c
@@ -3098,7 +3107,7 @@ Script_deactivatefacing: ; 0x97b5c
call GetScriptByte
and a
- jr z, .no_time ; 0x97b60 $3
+ jr z, .no_time
ld [ScriptDelay], a
.no_time
ld a, SCRIPT_WAIT
@@ -3149,14 +3158,14 @@ Script_return: ; 0x97b8c
ExitScriptSubroutine: ; 0x97b9a
; Return carry if there's no parent to return to.
- ld hl, wd43c
+ ld hl, wScriptStackSize
ld a, [hl]
and a
- jr z, .done ; 0x97b9f $1d
+ jr z, .done
dec [hl]
ld e, [hl]
ld d, $0
- ld hl, wd43d
+ ld hl, wScriptStackBA1
rept 3
add hl,de
endr
@@ -3181,7 +3190,7 @@ Script_resetfuncs: ; 0x97bc0
; script command 0x93
xor a
- ld [wd43c], a
+ ld [wScriptStackSize], a
ld [ScriptRunning], a
ld a, SCRIPT_OFF
ld [ScriptMode], a
@@ -3231,22 +3240,22 @@ Script_wait: ; 0x97c05
call DelayFrames
pop af
dec a
- jr nz, .loop ; 0x97c11 $f6
+ jr nz, .loop
pop bc
ret
; 0x97c15
-Script_unknown0xa9: ; 0x97c15
+Script_check_save: ; 0x97c15
; script command 0xa9
- callba Function4cffe
+ callba CheckSave
ld a, c
ld [ScriptVar], a
ret
; 0x97c20
-Function97c20: ; 97c20 unreferenced
+; 97c20 unreferenced
ld a, [.byte]
ld [ScriptVar], a
ret