summaryrefslogtreecommitdiff
path: root/event
diff options
context:
space:
mode:
authorRemy Oukaour <remy.oukaour@gmail.com>2017-12-15 20:10:54 -0500
committerRemy Oukaour <remy.oukaour@gmail.com>2017-12-15 20:10:54 -0500
commit1038ebca5e2638ecbce1052c1dad7474372a7fd5 (patch)
tree7bc9722faff9aa68ab1e5dc0960f9ce35da6bbec /event
parent606817f18b67a7d033adad31cbbea19d2e05e98e (diff)
Move more contiguous related code blocks from main.asm to engine/ and events/
Diffstat (limited to 'event')
-rw-r--r--event/bug_contest.asm43
-rw-r--r--event/bug_contest_mon_stats.asm107
-rw-r--r--event/catch_tutorial.asm81
-rw-r--r--event/catch_tutorial_input.asm43
-rw-r--r--event/hidden_items.asm51
-rw-r--r--event/lucky_number.asm226
-rw-r--r--event/move_tutor.asm103
-rwxr-xr-xevent/special.asm4
8 files changed, 658 insertions, 0 deletions
diff --git a/event/bug_contest.asm b/event/bug_contest.asm
new file mode 100644
index 000000000..2cb88ad30
--- /dev/null
+++ b/event/bug_contest.asm
@@ -0,0 +1,43 @@
+Special_GiveParkBalls: ; 135db
+ xor a
+ ld [wContestMon], a
+ ld a, 20
+ ld [wParkBallsRemaining], a
+ callba StartBugContestTimer
+ ret
+
+BugCatchingContestBattleScript:: ; 0x135eb
+ writecode VAR_BATTLETYPE, BATTLETYPE_CONTEST
+ randomwildmon
+ startbattle
+ reloadmapafterbattle
+ copybytetovar wParkBallsRemaining
+ iffalse BugCatchingContestOutOfBallsScript
+ end
+
+BugCatchingContestOverScript:: ; 0x135f8
+ playsound SFX_ELEVATOR_END
+ opentext
+ writetext BugCatchingContestText_BeeepTimesUp
+ waitbutton
+ jump BugCatchingContestReturnToGateScript
+
+BugCatchingContestOutOfBallsScript: ; 0x13603
+ playsound SFX_ELEVATOR_END
+ opentext
+ writetext BugCatchingContestText_ContestIsOver
+ waitbutton
+
+BugCatchingContestReturnToGateScript: ; 0x1360b
+ closetext
+ jumpstd bugcontestresultswarp
+
+BugCatchingContestText_BeeepTimesUp: ; 0x1360f
+ ; ANNOUNCER: BEEEP! Time's up!
+ text_jump UnknownText_0x1bd2ca
+ db "@"
+
+BugCatchingContestText_ContestIsOver: ; 0x13614
+ ; ANNOUNCER: The Contest is over!
+ text_jump UnknownText_0x1bd2e7
+ db "@"
diff --git a/event/bug_contest_mon_stats.asm b/event/bug_contest_mon_stats.asm
new file mode 100644
index 000000000..d6ad3997e
--- /dev/null
+++ b/event/bug_contest_mon_stats.asm
@@ -0,0 +1,107 @@
+DisplayCaughtContestMonStats: ; cc000
+ call ClearBGPalettes
+ call ClearTileMap
+ call ClearSprites
+ call LoadFontsBattleExtra
+
+ ld hl, Options
+ ld a, [hl]
+ push af
+ set 4, [hl]
+
+ hlcoord 0, 0
+ ld b, 4
+ ld c, 13
+ call TextBox
+
+ hlcoord 0, 6
+ ld b, 4
+ ld c, 13
+ call TextBox
+
+ hlcoord 2, 0
+ ld de, .Stock
+ call PlaceString
+
+ hlcoord 2, 6
+ ld de, .This
+ call PlaceString
+
+ hlcoord 5, 4
+ ld de, .Health
+ call PlaceString
+
+ hlcoord 5, 10
+ ld de, .Health
+ call PlaceString
+
+ ld a, [wContestMon]
+ ld [wd265], a
+ call GetPokemonName
+ ld de, StringBuffer1
+ hlcoord 1, 2
+ call PlaceString
+
+ ld h, b
+ ld l, c
+ ld a, [wContestMonLevel]
+ ld [TempMonLevel], a
+ call PrintLevel
+
+ ld de, EnemyMonNick
+ hlcoord 1, 8
+ call PlaceString
+
+ ld h, b
+ ld l, c
+ ld a, [EnemyMonLevel]
+ ld [TempMonLevel], a
+ call PrintLevel
+
+ hlcoord 11, 4
+ ld de, wContestMonMaxHP
+ lb bc, 2, 3
+ call PrintNum
+
+ hlcoord 11, 10
+ ld de, EnemyMonMaxHP
+ call PrintNum
+
+ ld hl, SwitchMonText
+ call PrintText
+
+ pop af
+ ld [Options], a
+
+ call WaitBGMap
+ ld b, SCGB_DIPLOMA
+ call GetSGBLayout
+ call SetPalettes
+ ret
+
+.Health:
+ db "HEALTH@"
+.Stock:
+ db " STOCK ", $4a, " @"
+.This:
+ db " THIS ", $4a, " @"
+
+SwitchMonText: ; cc0c2
+ ; Switch #MON?
+ text_jump UnknownText_0x1c10cf
+ db "@"
+
+DisplayAlreadyCaughtText: ; cc0c7
+ call GetPokemonName
+ ld hl, .AlreadyCaughtText
+ jp PrintText
+
+.AlreadyCaughtText: ; 0xcc0d0
+ ; You already caught a @ .
+ text_jump UnknownText_0x1c10dd
+ db "@"
+
+Predef2F:
+Predef38:
+Predef39: ; cc0d5
+ ret
diff --git a/event/catch_tutorial.asm b/event/catch_tutorial.asm
new file mode 100644
index 000000000..8340d8c13
--- /dev/null
+++ b/event/catch_tutorial.asm
@@ -0,0 +1,81 @@
+CatchTutorial:: ; 4e554
+ ld a, [BattleType]
+ dec a
+ ld c, a
+ ld hl, .dw
+ ld b, 0
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
+
+.dw ; 4e564 (13:6564)
+ dw .DudeTutorial
+ dw .DudeTutorial
+ dw .DudeTutorial
+
+.DudeTutorial: ; 4e56a (13:656a)
+; Back up your name to your Mom's name.
+ ld hl, PlayerName
+ ld de, MomsName
+ ld bc, NAME_LENGTH
+ call CopyBytes
+; Copy Dude's name to your name
+ ld hl, .Dude
+ ld de, PlayerName
+ ld bc, NAME_LENGTH
+ call CopyBytes
+
+ call .LoadDudeData
+
+ xor a
+ ld [hJoyDown], a
+ ld [hJoyPressed], a
+ ld a, [Options]
+ push af
+ and $f8
+ add $3
+ ld [Options], a
+ ld hl, .AutoInput
+ ld a, BANK(.AutoInput)
+ call StartAutoInput
+ callab StartBattle
+ call StopAutoInput
+ pop af
+
+ ld [Options], a
+ ld hl, MomsName
+ ld de, PlayerName
+ ld bc, NAME_LENGTH
+ call CopyBytes
+ ret
+
+.LoadDudeData: ; 4e5b7 (13:65b7)
+ ld hl, wDudeNumItems
+ ld [hl], 1
+ inc hl
+ ld [hl], POTION
+ inc hl
+ ld [hl], 1
+ inc hl
+ ld [hl], -1
+ ld hl, wDudeNumKeyItems
+ ld [hl], 0
+ inc hl
+ ld [hl], -1
+ ld hl, wDudeNumBalls
+ ld a, 1
+ ld [hli], a
+ ld a, POKE_BALL ; 5
+ ld [hli], a
+ ld [hli], a
+ ld [hl], -1
+ ret
+
+.Dude: ; 4e5da
+ db "DUDE@"
+
+.AutoInput: ; 4e5df
+ db NO_INPUT, $ff ; end
diff --git a/event/catch_tutorial_input.asm b/event/catch_tutorial_input.asm
new file mode 100644
index 000000000..9d2a03db2
--- /dev/null
+++ b/event/catch_tutorial_input.asm
@@ -0,0 +1,43 @@
+_DudeAutoInput_A:: ; 1de28a
+ ld hl, DudeAutoInput_A
+ jr _DudeAutoInput
+
+_DudeAutoInput_RightA: ; 1de28f
+ ld hl, DudeAutoInput_RightA
+ jr _DudeAutoInput
+
+_DudeAutoInput_DownA: ; 1de294
+ ld hl, DudeAutoInput_DownA
+ jr _DudeAutoInput
+
+_DudeAutoInput: ; 1de299
+ ld a, BANK(DudeAutoInputs)
+ call StartAutoInput
+ ret
+
+DudeAutoInputs:
+
+DudeAutoInput_A: ; 1de29f
+ db NO_INPUT, $50
+ db A_BUTTON, $00
+ db NO_INPUT, $ff ; end
+
+DudeAutoInput_RightA: ; 1de2a5
+ db NO_INPUT, $08
+ db D_RIGHT, $00
+ db NO_INPUT, $08
+ db A_BUTTON, $00
+ db NO_INPUT, $ff ; end
+
+DudeAutoInput_DownA: ; 1de2af
+ db NO_INPUT, $fe
+ db NO_INPUT, $fe
+ db NO_INPUT, $fe
+ db NO_INPUT, $fe
+ db D_DOWN, $00
+ db NO_INPUT, $fe
+ db NO_INPUT, $fe
+ db NO_INPUT, $fe
+ db NO_INPUT, $fe
+ db A_BUTTON, $00
+ db NO_INPUT, $ff ; end
diff --git a/event/hidden_items.asm b/event/hidden_items.asm
new file mode 100644
index 000000000..c4c51d5e6
--- /dev/null
+++ b/event/hidden_items.asm
@@ -0,0 +1,51 @@
+RepelWoreOffScript:: ; 0x13619
+ opentext
+ writetext .text
+ waitbutton
+ closetext
+ end
+
+.text ; 0x13620
+ ; REPEL's effect wore off.
+ text_jump UnknownText_0x1bd308
+ db "@"
+
+HiddenItemScript:: ; 0x13625
+ opentext
+ copybytetovar EngineBuffer3
+ itemtotext 0, 0
+ writetext .found_text
+ giveitem ITEM_FROM_MEM
+ iffalse .bag_full
+ callasm SetMemEvent
+ specialsound
+ itemnotify
+ jump .finish
+
+.bag_full ; 0x1363e
+ buttonsound
+ writetext .no_room_text
+ waitbutton
+
+.finish ; 13643
+ closetext
+ end
+
+.found_text ; 0x13645
+ ; found @ !
+ text_jump UnknownText_0x1bd321
+ db "@"
+
+.no_room_text ; 0x1364a
+ ; But has no space left…
+ text_jump UnknownText_0x1bd331
+ db "@"
+
+SetMemEvent: ; 1364f
+ ld hl, EngineBuffer1
+ ld a, [hli]
+ ld d, [hl]
+ ld e, a
+ ld b, SET_FLAG
+ call EventFlagAction
+ ret
diff --git a/event/lucky_number.asm b/event/lucky_number.asm
new file mode 100644
index 000000000..8cec7599d
--- /dev/null
+++ b/event/lucky_number.asm
@@ -0,0 +1,226 @@
+Special_CheckForLuckyNumberWinners: ; 4d87a
+ xor a
+ ld [ScriptVar], a
+ ld [wFoundMatchingIDInParty], a
+ ld a, [PartyCount]
+ and a
+ ret z
+ ld d, a
+ ld hl, PartyMon1ID
+ ld bc, PartySpecies
+.PartyLoop:
+ ld a, [bc]
+ inc bc
+ cp EGG
+ call nz, .CompareLuckyNumberToMonID
+ push bc
+ ld bc, PARTYMON_STRUCT_LENGTH
+ add hl, bc
+ pop bc
+ dec d
+ jr nz, .PartyLoop
+ ld a, BANK(sBox)
+ call GetSRAMBank
+ ld a, [sBoxCount]
+ and a
+ jr z, .SkipOpenBox
+ ld d, a
+ ld hl, sBoxMon1ID
+ ld bc, sBoxSpecies
+.OpenBoxLoop:
+ ld a, [bc]
+ inc bc
+ cp EGG
+ jr z, .SkipOpenBoxMon
+ call .CompareLuckyNumberToMonID
+ jr nc, .SkipOpenBoxMon
+ ld a, 1
+ ld [wFoundMatchingIDInParty], a
+
+.SkipOpenBoxMon:
+ push bc
+ ld bc, BOXMON_STRUCT_LENGTH
+ add hl, bc
+ pop bc
+ dec d
+ jr nz, .OpenBoxLoop
+
+.SkipOpenBox:
+ call CloseSRAM
+ ld c, $0
+.BoxesLoop:
+ ld a, [wCurBox]
+ and $f
+ cp c
+ jr z, .SkipBox
+ ld hl, .BoxBankAddresses
+ ld b, 0
+ add hl, bc
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ call GetSRAMBank
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a ; hl now contains the address of the loaded box in SRAM
+ ld a, [hl]
+ and a
+ jr z, .SkipBox ; no mons in this box
+ push bc
+ ld b, h
+ ld c, l
+ inc bc
+ ld de, sBoxMon1ID - sBox
+ add hl, de
+ ld d, a
+.BoxNLoop:
+ ld a, [bc]
+ inc bc
+ cp EGG
+ jr z, .SkipBoxMon
+
+ call .CompareLuckyNumberToMonID ; sets ScriptVar and CurPartySpecies appropriately
+ jr nc, .SkipBoxMon
+ ld a, 1
+ ld [wFoundMatchingIDInParty], a
+
+.SkipBoxMon:
+ push bc
+ ld bc, BOXMON_STRUCT_LENGTH
+ add hl, bc
+ pop bc
+ dec d
+ jr nz, .BoxNLoop
+ pop bc
+
+.SkipBox:
+ inc c
+ ld a, c
+ cp NUM_BOXES
+ jr c, .BoxesLoop
+
+ call CloseSRAM
+ ld a, [ScriptVar]
+ and a
+ ret z ; found nothing
+ callba TrainerRankings_LuckyNumberShow
+ ld a, [wFoundMatchingIDInParty]
+ and a
+ push af
+ ld a, [CurPartySpecies]
+ ld [wNamedObjectIndexBuffer], a
+ call GetPokemonName
+ ld hl, .FoundPartymonText
+ pop af
+ jr z, .print
+ ld hl, .FoundBoxmonText
+
+.print
+ jp PrintText
+
+.CompareLuckyNumberToMonID: ; 4d939
+ push bc
+ push de
+ push hl
+ ld d, h
+ ld e, l
+ ld hl, Buffer1
+ lb bc, PRINTNUM_LEADINGZEROS | 2, 5
+ call PrintNum
+ ld hl, LuckyNumberDigit1Buffer
+ ld de, wLuckyIDNumber
+ lb bc, PRINTNUM_LEADINGZEROS | 2, 5
+ call PrintNum
+ ld b, 5
+ ld c, 0
+ ld hl, LuckyNumberDigit5Buffer
+ ld de, Buffer5
+.loop
+ ld a, [de]
+ cp [hl]
+ jr nz, .done
+ dec de
+ dec hl
+ inc c
+ dec b
+ jr nz, .loop
+
+.done
+ pop hl
+ push hl
+ ld de, -6
+ add hl, de
+ ld a, [hl]
+ pop hl
+ pop de
+ push af
+ ld a, c
+ ld b, 1
+ cp 5
+ jr z, .okay
+ ld b, 2
+ cp 3
+ jr nc, .okay
+ ld b, 3
+ cp 2
+ jr nz, .nomatch
+
+.okay
+ inc b
+ ld a, [ScriptVar]
+ and a
+ jr z, .bettermatch
+ cp b
+ jr c, .nomatch
+
+.bettermatch
+ dec b
+ ld a, b
+ ld [ScriptVar], a
+ pop bc
+ ld a, b
+ ld [CurPartySpecies], a
+ pop bc
+ scf
+ ret
+
+.nomatch
+ pop bc
+ pop bc
+ and a
+ ret
+
+.BoxBankAddresses: ; 4d99f
+ dba sBox1
+ dba sBox2
+ dba sBox3
+ dba sBox4
+ dba sBox5
+ dba sBox6
+ dba sBox7
+ dba sBox8
+ dba sBox9
+ dba sBox10
+ dba sBox11
+ dba sBox12
+ dba sBox13
+ dba sBox14
+
+.FoundPartymonText: ; 0x4d9c9
+ ; Congratulations! We have a match with the ID number of @ in your party.
+ text_jump UnknownText_0x1c1261
+ db "@"
+
+.FoundBoxmonText: ; 0x4d9ce
+ ; Congratulations! We have a match with the ID number of @ in your PC BOX.
+ text_jump UnknownText_0x1c12ae
+ db "@"
+
+Special_PrintTodaysLuckyNumber: ; 4d9d3
+ ld hl, StringBuffer3
+ ld de, wLuckyIDNumber
+ lb bc, PRINTNUM_LEADINGZEROS | 2, 5
+ call PrintNum
+ ld a, "@"
+ ld [StringBuffer3 + 5], a
+ ret
diff --git a/event/move_tutor.asm b/event/move_tutor.asm
new file mode 100644
index 000000000..b26114dd0
--- /dev/null
+++ b/event/move_tutor.asm
@@ -0,0 +1,103 @@
+Special_MoveTutor: ; 4925b
+ call FadeToMenu
+ call ClearBGPalettes
+ call ClearScreen
+ call DelayFrame
+ ld b, SCGB_PACKPALS
+ call GetSGBLayout
+ xor a
+ ld [wItemAttributeParamBuffer], a
+ call .GetMoveTutorMove
+ ld [wd265], a
+ ld [wPutativeTMHMMove], a
+ call GetMoveName
+ call CopyName1
+ callba ChooseMonToLearnTMHM
+ jr c, .cancel
+ jr .enter_loop
+
+.loop
+ callba ChooseMonToLearnTMHM_NoRefresh
+ jr c, .cancel
+.enter_loop
+ call CheckCanLearnMoveTutorMove
+ jr nc, .loop
+ xor a
+ ld [ScriptVar], a
+ jr .quit
+
+.cancel
+ ld a, -1
+ ld [ScriptVar], a
+.quit
+ call CloseSubmenu
+ ret
+
+.GetMoveTutorMove: ; 492a5
+ ld a, [ScriptVar]
+ cp 1
+ jr z, .flamethrower
+ cp 2
+ jr z, .thunderbolt
+ ld a, ICE_BEAM
+ ret
+
+.flamethrower
+ ld a, FLAMETHROWER
+ ret
+
+.thunderbolt
+ ld a, THUNDERBOLT
+ ret
+
+CheckCanLearnMoveTutorMove: ; 492b9
+ ld hl, .MenuDataHeader
+ call LoadMenuDataHeader
+
+ predef CanLearnTMHMMove
+
+ push bc
+ ld a, [CurPartyMon]
+ ld hl, PartyMonNicknames
+ call GetNick
+ pop bc
+
+ ld a, c
+ and a
+ jr nz, .can_learn
+ push de
+ ld de, SFX_WRONG
+ call PlaySFX
+ pop de
+ ld a, BANK(Text_TMHMNotCompatible)
+ ld hl, Text_TMHMNotCompatible
+ call FarPrintText
+ jr .didnt_learn
+
+.can_learn
+ callab KnowsMove
+ jr c, .didnt_learn
+
+ predef LearnMove
+ ld a, b
+ and a
+ jr z, .didnt_learn
+
+ ld c, HAPPINESS_LEARNMOVE
+ callab ChangeHappiness
+ jr .learned
+
+.didnt_learn
+ call ExitMenu
+ and a
+ ret
+
+.learned
+ call ExitMenu
+ scf
+ ret
+
+.MenuDataHeader: ; 0x4930a
+ db $40 ; flags
+ db 12, 00 ; start coords
+ db 17, 19 ; end coords
diff --git a/event/special.asm b/event/special.asm
index f1228abc6..71323499e 100755
--- a/event/special.asm
+++ b/event/special.asm
@@ -229,3 +229,7 @@ CopyPokemonName_Buffer1_Buffer3: ; 746e
ld de, StringBuffer3
ld bc, PKMN_NAME_LENGTH
jp CopyBytes
+
+Predef1: ; 747a
+; not used
+ ret