summaryrefslogtreecommitdiff
path: root/engine/events.asm
diff options
context:
space:
mode:
Diffstat (limited to 'engine/events.asm')
-rw-r--r--engine/events.asm156
1 files changed, 83 insertions, 73 deletions
diff --git a/engine/events.asm b/engine/events.asm
index e0770b7a0..0740da545 100644
--- a/engine/events.asm
+++ b/engine/events.asm
@@ -123,7 +123,7 @@ StartMap: ; 96724
ld hl, MapStatus
ld bc, $3e ; 62
call ByteFill
- callba Function113e5
+ callba InitCallReceiveDelay
call ClearJoypad
; fallthrough
; 9673e
@@ -138,19 +138,19 @@ EnterMap: ; 9673e
call ClearAllScriptFlags3
ld a, [hMapEntryMethod]
- cp $f7
+ cp MAPSETUP_07
jr nz, .dontset
call SetAll_ScriptFlags3
.dontset
ld a, [hMapEntryMethod]
- cp $f3
+ cp MAPSETUP_RELOADMAP
jr nz, .dontresetpoison
xor a
ld [PoisonStepCount], a
.dontresetpoison
- xor a
+ xor a ; end map entry
ld [hMapEntryMethod], a
ld a, 2 ; HandleMap
ld [MapStatus], a
@@ -285,12 +285,12 @@ Function96812: ; 96812
PlayerEvents: ; 9681f
xor a
-
+; If there's already a player event, don't interrupt it.
ld a, [ScriptRunning]
and a
ret nz
- call Function968e4
+ call Dummy_CheckScriptFlags3Bit5 ; This is a waste of time
call CheckTrainerBattle3
jr c, .ok
@@ -298,13 +298,13 @@ PlayerEvents: ; 9681f
call CheckTileEvent
jr c, .ok
- call Function97c30
+ call RunMemScript
jr c, .ok
- call Function968ec
+ call DoMapTrigger
jr c, .ok
- call Function9693a
+ call CheckTimeEvents
jr c, .ok
call OWPlayerInput
@@ -320,7 +320,7 @@ PlayerEvents: ; 9681f
pop af
ld [ScriptRunning], a
- call Function96beb
+ call DoPlayerEvent
ld a, [ScriptRunning]
cp 4
jr z, .ok2
@@ -361,7 +361,7 @@ CheckTileEvent: ; 96874
callba CheckMovingOffEdgeOfMap
jr c, .return4
- call Function2238
+ call CheckWarpTile
jr c, .return6
.bit2
@@ -436,11 +436,11 @@ SetUpFiveStepWildEncounterCooldown: ; 968d1
ret
; 968d7
-Function968d7: ; 968d7
+ret_968d7: ; 968d7
ret
-; 968d8
+;968d8
-Function968d8: ; 968d8
+SetMinTwoStepWildEncounterCooldown: ; 968d8
ld a, [wWildEncounterCooldown]
cp 2
ret nc
@@ -449,15 +449,15 @@ Function968d8: ; 968d8
ret
; 968e4
-Function968e4: ; 968e4
+Dummy_CheckScriptFlags3Bit5: ; 968e4
call CheckBit5_ScriptFlags3
ret z
- call Function2f3e
+ call ret_2f3e
ret
; 968ec
-Function968ec: ; 968ec
- ld a, [wdc07]
+DoMapTrigger: ; 968ec
+ ld a, [wCurrMapTriggerCount]
and a
jr z, .nope
@@ -468,7 +468,7 @@ Function968ec: ; 968ec
ld e, a
ld d, 0
- ld hl, wdc07 + 1
+ ld hl, wCurrMapTriggerHeaderPointer
ld a, [hli]
ld h, [hl]
ld l, a
@@ -505,23 +505,23 @@ endr
ret
; 9693a
-Function9693a: ; 9693a
- ld a, [InLinkBattle]
+CheckTimeEvents: ; 9693a
+ ld a, [wLinkMode]
and a
jr nz, .nothing
ld hl, StatusFlags2
bit 2, [hl]
- jr z, .asm_96951
+ jr z, .do_daily
- callba Function114a4
- jr c, .elevator
+ callba CheckBugContestTimer
+ jr c, .end_bug_contest
xor a
ret
-.asm_96951
- callba Function11452
- callba Function114e7
+.do_daily
+ callba CheckDailyResetTimer
+ callba CheckPokerusTrick
callba CheckPhoneCall
ret c
@@ -529,7 +529,7 @@ Function9693a: ; 9693a
xor a
ret
-.elevator
+.end_bug_contest
ld a, BANK(BugCatchingContestOverScript)
ld hl, BugCatchingContestOverScript
call CallScript
@@ -537,7 +537,7 @@ Function9693a: ; 9693a
ret
; 96970
-Function96970: ; 96970
+.unused ; 96970
ld a, 8
scf
ret
@@ -856,7 +856,7 @@ PlayerMovement: ; 96af0
; 96b10
.seven ; 96b10
- call Function968d7 ; empty
+ call ret_968d7 ; mobile
xor a
ld c, a
ret
@@ -898,7 +898,7 @@ PlayerMovement: ; 96af0
CheckMenuOW: ; 96b30
xor a
- ld [$ffa0], a
+ ld [hMenuReturn], a
ld [$ffa1], a
ld a, [hJoyPressed]
@@ -940,9 +940,9 @@ SelectMenuScript: ; 96b5f
StartMenuCallback:
SelectMenuCallback: ; 96b66
- copybytetovar $ffa0
- if_equal %10000000, .Script
- if_equal -1, .Asm
+ copybytetovar hMenuReturn
+ if_equal HMENURETURN_SCRIPT, .Script
+ if_equal HMENURETURN_ASM, .Asm
end
; 96b72
@@ -957,76 +957,86 @@ SelectMenuCallback: ; 96b66
CountStep: ; 96b79
- ld a, [InLinkBattle]
+ ; Don't count steps in link communication rooms.
+ ld a, [wLinkMode]
and a
jr nz, .done
- callba Function90136
- jr c, .setminus1
+ ; If there is a special phone call, don't count the step.
+ callba CheckSpecialPhoneCall
+ jr c, .doscript
- call Function96bd7
- jr c, .setminus1
+ ; If Repel wore off, don't count the step.
+ call DoRepelStep
+ jr c, .doscript
+ ; Count the step for poison and total steps
ld hl, PoisonStepCount
inc [hl]
ld hl, StepCount
inc [hl]
- jr nz, .asm_96b9c
+ ; Every 256 steps, increase the happiness of all your Pokemon.
+ jr nz, .skip_happiness
callba StepHappiness
-.asm_96b9c
+.skip_happiness
+ ; Every 256 steps, offset from the happiness incrementor by 128 steps,
+ ; decrease the hatch counter of all your eggs until you reach the first
+ ; one that is ready to hatch.
ld a, [StepCount]
cp $80
- jr nz, .asm_96bab
+ jr nz, .skip_egg
- callba Function16f3e
- jr nz, .set8
+ callba DoEggStep
+ jr nz, .hatch
-.asm_96bab
+.skip_egg
+ ; Increase the EXP of (both) DayCare Pokemon by 1.
callba DaycareStep
+ ; Every four steps, deal damage to all Poisoned Pokemon
ld hl, PoisonStepCount
ld a, [hl]
cp 4
- jr c, .poisoned
+ jr c, .skip_poison
ld [hl], 0
- callba Function505da
- jr c, .setminus1
+ callba DoPoisonStep
+ jr c, .doscript
-.poisoned
- callba Function97db3
+.skip_poison
+ callba DoBikeStep
.done
xor a
ret
-.setminus1
+.doscript
ld a, -1
scf
ret
-.set8
+.hatch
ld a, 8
scf
ret
; 96bd3
-Function96bd3: ; 96bd3
+.unreferenced: ; 96bd3
ld a, 7
scf
ret
; 96bd7
-Function96bd7: ; 96bd7
- ld a, [RepelStepsLeft]
+DoRepelStep: ; 96bd7
+ ld a, [wRepelEffect]
and a
ret z
dec a
- ld [RepelStepsLeft], a
+ ld [wRepelEffect], a
ret nz
ld a, BANK(RepelWoreOffScript)
@@ -1036,11 +1046,11 @@ Function96bd7: ; 96bd7
ret
; 96beb
-Function96beb: ; 96beb
+DoPlayerEvent: ; 96beb
ld a, [ScriptRunning]
and a
ret z
- cp -1
+ cp -1 ; run script
ret z
cp 10
ret nc
@@ -1061,17 +1071,17 @@ endr
; 96c0c
ScriptPointers96c0c: ; 96c0c
- dbw BANK(Invalid_0x96c2d), Invalid_0x96c2d
- dbw BANK(SeenByTrainerScript), SeenByTrainerScript
- dbw BANK(TalkToTrainerScript), TalkToTrainerScript
- dbw BANK(FindItemInBallScript), FindItemInBallScript
- dbw BANK(UnknownScript_0x96c4d), UnknownScript_0x96c4d
- dbw BANK(WarpToNewMapScript), WarpToNewMapScript
- dbw BANK(FallIntoMapScript), FallIntoMapScript
- dbw BANK(UnknownScript_0x124c8), UnknownScript_0x124c8
- dbw BANK(HatchEggScript), HatchEggScript
- dbw BANK(UnknownScript_0x96c4f), UnknownScript_0x96c4f
- dbw BANK(Invalid_0x96c2d), Invalid_0x96c2d
+ 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
; 96c2d
Invalid_0x96c2d: ; 96c2d
@@ -1089,16 +1099,16 @@ HatchEggScript: ; 96c2f
WarpToNewMapScript: ; 96c34
warpsound
- newloadmap $f5
+ newloadmap MAPSETUP_05
end
; 96c38
FallIntoMapScript: ; 96c38
- newloadmap $f6
+ newloadmap MAPSETUP_06
playsound SFX_KINESIS
applymovement PLAYER, MovementData_0x96c48
playsound SFX_STRENGTH
- scall UnknownScript_0x96c4a
+ scall LandAfterPitfallScript
end
; 96c48
@@ -1107,7 +1117,7 @@ MovementData_0x96c48: ; 96c48
step_end
; 96c4a
-UnknownScript_0x96c4a: ; 96c4a
+LandAfterPitfallScript: ; 96c4a
earthquake 16
end
; 96c4d