From e48a401290e794854880f06fc230a369f37e6b9b Mon Sep 17 00:00:00 2001 From: Remy Oukaour Date: Thu, 14 Dec 2017 00:36:24 -0500 Subject: Reorganize macros --- event/unown.asm | 2 -- 1 file changed, 2 deletions(-) (limited to 'event') diff --git a/event/unown.asm b/event/unown.asm index efd4c74f5..1be858bd6 100644 --- a/event/unown.asm +++ b/event/unown.asm @@ -1,5 +1,3 @@ - - SpecialHoOhChamber: ; 0x8addb ld hl, PartySpecies ld a, [hl] -- cgit v1.2.3 From 59fe4078124f0fa8d1613a3f715861d9c6f2d449 Mon Sep 17 00:00:00 2001 From: Remy Oukaour Date: Fri, 15 Dec 2017 17:22:52 -0500 Subject: Copy pokered's organization some more, with further constant and data files --- event/buena.asm | 22 ++++++++-------------- event/mom_phone.asm | 2 +- 2 files changed, 9 insertions(+), 15 deletions(-) (limited to 'event') diff --git a/event/buena.asm b/event/buena.asm index 4802943f9..fa54cc3de 100644 --- a/event/buena.asm +++ b/event/buena.asm @@ -289,8 +289,12 @@ Buena_PrizeMenu: ; 8b0e2 ; 8b129 .indices ; 8b129 - db 9 - db 1, 2, 3, 4, 5, 6, 7, 8, 9 + db NUM_BUENA_PRIZES +x = 1 +rept NUM_BUENA_PRIZES + db x +x = x + 1 +endr db -1 ; 8b134 @@ -319,7 +323,7 @@ Buena_PrizeMenu: ; 8b0e2 Buena_getprize: ; 8b154 dec a - ld hl, .prizes + ld hl, BuenaPrizeItems ld b, 0 ld c, a add hl, bc @@ -327,14 +331,4 @@ Buena_getprize: ; 8b154 ret ; 8b15e -.prizes ; 8b15e - db ULTRA_BALL, 2 - db FULL_RESTORE, 2 - db NUGGET, 3 - db RARE_CANDY, 3 - db PROTEIN, 5 - db IRON, 5 - db CARBOS, 5 - db CALCIUM, 5 - db HP_UP, 5 -; 8b170 +INCLUDE "data/items/buena_prizes.asm" diff --git a/event/mom_phone.asm b/event/mom_phone.asm index 0d7a2366f..58ecad02a 100755 --- a/event/mom_phone.asm +++ b/event/mom_phone.asm @@ -212,7 +212,7 @@ endr ret ; fd136 -INCLUDE "data/mom_phone_items.asm" +INCLUDE "data/items/mom_phone.asm" db 0, 0, 0 ; XXX -- cgit v1.2.3 From 2cf5cc1dc7f0dcc4651cdacaefb28d1b607f444c Mon Sep 17 00:00:00 2001 From: Remy Oukaour Date: Fri, 15 Dec 2017 17:50:45 -0500 Subject: Move more unknown graphics into real subfolders --- event/photo.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'event') diff --git a/event/photo.asm b/event/photo.asm index fea57a368..55ac8e7d1 100755 --- a/event/photo.asm +++ b/event/photo.asm @@ -214,9 +214,9 @@ UnownDexVacantString: ; 16d9c UnownDexATile: ; 16d9c -INCBIN "gfx/unknown/bold_a.1bpp" +INCBIN "gfx/printer/bold_a.1bpp" UnownDexBTile: ; 16da4 -INCBIN "gfx/unknown/bold_b.1bpp" +INCBIN "gfx/printer/bold_b.1bpp" ; 16dac PlaceUnownPrinterFrontpic: ; 16dac -- cgit v1.2.3 From 1038ebca5e2638ecbce1052c1dad7474372a7fd5 Mon Sep 17 00:00:00 2001 From: Remy Oukaour Date: Fri, 15 Dec 2017 20:10:54 -0500 Subject: Move more contiguous related code blocks from main.asm to engine/ and events/ --- event/bug_contest.asm | 43 ++++++++ event/bug_contest_mon_stats.asm | 107 +++++++++++++++++++ event/catch_tutorial.asm | 81 ++++++++++++++ event/catch_tutorial_input.asm | 43 ++++++++ event/hidden_items.asm | 51 +++++++++ event/lucky_number.asm | 226 ++++++++++++++++++++++++++++++++++++++++ event/move_tutor.asm | 103 ++++++++++++++++++ event/special.asm | 4 + 8 files changed, 658 insertions(+) create mode 100644 event/bug_contest.asm create mode 100644 event/bug_contest_mon_stats.asm create mode 100644 event/catch_tutorial.asm create mode 100644 event/catch_tutorial_input.asm create mode 100644 event/hidden_items.asm create mode 100644 event/lucky_number.asm create mode 100644 event/move_tutor.asm (limited to 'event') 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 -- cgit v1.2.3 From e44640b0088dad5856d7a6f60ad930779931b251 Mon Sep 17 00:00:00 2001 From: Remy Oukaour Date: Fri, 15 Dec 2017 21:22:26 -0500 Subject: Move more main.asm code into individual files --- event/buena_menu.asm | 58 ++++++ event/bug_contest.asm | 43 ---- event/bug_contest/caught_mon.asm | 38 ++++ event/bug_contest/contest.asm | 43 ++++ event/bug_contest/contest_2.asm | 133 ++++++++++++ event/bug_contest/display_stats.asm | 107 ++++++++++ event/bug_contest/judging.asm | 395 ++++++++++++++++++++++++++++++++++++ event/bug_contest_2.asm | 133 ------------ event/bug_contest_judging.asm | 395 ------------------------------------ event/bug_contest_mon_stats.asm | 107 ---------- event/heal_machine_anim.asm | 265 ++++++++++++++++++++++++ event/photo.asm | 295 --------------------------- event/poisonstep_pals.asm | 48 +++++ event/print_photo.asm | 61 ++++++ event/print_unown.asm | 233 +++++++++++++++++++++ event/print_unown_2.asm | 111 ++++++++++ 16 files changed, 1492 insertions(+), 973 deletions(-) create mode 100644 event/buena_menu.asm delete mode 100644 event/bug_contest.asm create mode 100644 event/bug_contest/caught_mon.asm create mode 100644 event/bug_contest/contest.asm create mode 100755 event/bug_contest/contest_2.asm create mode 100644 event/bug_contest/display_stats.asm create mode 100755 event/bug_contest/judging.asm delete mode 100755 event/bug_contest_2.asm delete mode 100755 event/bug_contest_judging.asm delete mode 100644 event/bug_contest_mon_stats.asm create mode 100755 event/heal_machine_anim.asm delete mode 100755 event/photo.asm create mode 100644 event/poisonstep_pals.asm create mode 100755 event/print_photo.asm create mode 100644 event/print_unown.asm create mode 100644 event/print_unown_2.asm (limited to 'event') diff --git a/event/buena_menu.asm b/event/buena_menu.asm new file mode 100644 index 000000000..b453da783 --- /dev/null +++ b/event/buena_menu.asm @@ -0,0 +1,58 @@ +AskRememberPassword: ; 4ae12 + call .DoMenu + ld a, $0 + jr c, .okay + ld a, $1 + +.okay + ld [ScriptVar], a + ret + +.DoMenu: ; 4ae1f + lb bc, 14, 7 + push bc + ld hl, YesNoMenuDataHeader + call CopyMenuDataHeader + pop bc + ld a, b + ld [wMenuBorderLeftCoord], a + add $5 + ld [wMenuBorderRightCoord], a + ld a, c + ld [wMenuBorderTopCoord], a + add $4 + ld [wMenuBorderBottomCoord], a + call PushWindow + call VerticalMenu + push af + ld c, 15 + call DelayFrames + call Buena_ExitMenu + pop af + jr c, .refused + ld a, [wMenuCursorY] + cp $2 + jr z, .refused + and a + ret + +.refused + ld a, $2 + ld [wMenuCursorY], a + scf + ret + +Buena_ExitMenu: ; 4ae5e + ld a, [hOAMUpdate] + push af + call ExitMenu + call UpdateSprites + xor a + ld [hOAMUpdate], a + call DelayFrame + ld a, $1 + ld [hOAMUpdate], a + call ApplyTilemap + pop af + ld [hOAMUpdate], a + ret diff --git a/event/bug_contest.asm b/event/bug_contest.asm deleted file mode 100644 index 2cb88ad30..000000000 --- a/event/bug_contest.asm +++ /dev/null @@ -1,43 +0,0 @@ -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/caught_mon.asm b/event/bug_contest/caught_mon.asm new file mode 100644 index 000000000..729033d8b --- /dev/null +++ b/event/bug_contest/caught_mon.asm @@ -0,0 +1,38 @@ +BugContest_SetCaughtContestMon: ; e6ce + ld a, [wContestMon] + and a + jr z, .firstcatch + ld [wd265], a + callba DisplayAlreadyCaughtText + callba DisplayCaughtContestMonStats + lb bc, 14, 7 + call PlaceYesNoBox + ret c + +.firstcatch + call .generatestats + ld a, [TempEnemyMonSpecies] + ld [wd265], a + call GetPokemonName + ld hl, .caughttext + call PrintText + ret + +.generatestats ; e6fd + ld a, [TempEnemyMonSpecies] + ld [CurSpecies], a + ld [CurPartySpecies], a + call GetBaseData + xor a + ld bc, PARTYMON_STRUCT_LENGTH + ld hl, wContestMon + call ByteFill + xor a + ld [MonType], a + ld hl, wContestMon + jp GeneratePartyMonStats + +.caughttext ; 0xe71d + ; Caught @ ! + text_jump UnknownText_0x1c10c0 + db "@" diff --git a/event/bug_contest/contest.asm b/event/bug_contest/contest.asm new file mode 100644 index 000000000..2cb88ad30 --- /dev/null +++ b/event/bug_contest/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/contest_2.asm b/event/bug_contest/contest_2.asm new file mode 100755 index 000000000..493c69d0c --- /dev/null +++ b/event/bug_contest/contest_2.asm @@ -0,0 +1,133 @@ +Special_SelectRandomBugContestContestants: ; 139a8 +; Select five random people to participate in the current contest. + +; First we have to make sure that any old data is cleared away. + ld c, 10 ; Number of people to choose from. + ld hl, BugCatchingContestantEventFlagTable +.loop1 + push bc + push hl + ld e, [hl] + inc hl + ld d, [hl] + ld b, RESET_FLAG + call EventFlagAction + pop hl + inc hl + inc hl + pop bc + dec c + jr nz, .loop1 + +; Now that that's out of the way, we can get on to the good stuff. + ld c, 5 +.loop2 + push bc +.next +; Choose a flag at uniform random to be set. + call Random + cp 250 + jr nc, .next + ld c, 25 + call SimpleDivide + ld e, b + ld d, 0 + ld hl, BugCatchingContestantEventFlagTable + add hl, de + add hl, de + ld e, [hl] + inc hl + ld d, [hl] + push de +; If we've already set it, it doesn't count. + ld b, CHECK_FLAG + call EventFlagAction + pop de + ld a, c + and a + jr nz, .next +; Set the flag. This will cause that sprite to not be visible in the contest. + ld b, SET_FLAG + call EventFlagAction + pop bc +; Check if we're done. If so, return. Otherwise, choose the next victim. + dec c + jr nz, .loop2 + ret +; 139ed + +Special_CheckBugContestContestantFlag: ; 139ed +; Checks the flag of the Bug Catching Contestant whose index is loaded in a. + +; Bug: If a >= 10 when this is called, it will read beyond the table. + + ld hl, BugCatchingContestantEventFlagTable + ld e, a + ld d, 0 + add hl, de + add hl, de + ld e, [hl] + inc hl + ld d, [hl] + ld b, CHECK_FLAG + call EventFlagAction + ret +; 139fe + +BugCatchingContestantEventFlagTable: ; 139fe + dw EVENT_BUG_CATCHING_CONTESTANT_1A + dw EVENT_BUG_CATCHING_CONTESTANT_2A + dw EVENT_BUG_CATCHING_CONTESTANT_3A + dw EVENT_BUG_CATCHING_CONTESTANT_4A + dw EVENT_BUG_CATCHING_CONTESTANT_5A + dw EVENT_BUG_CATCHING_CONTESTANT_6A + dw EVENT_BUG_CATCHING_CONTESTANT_7A + dw EVENT_BUG_CATCHING_CONTESTANT_8A + dw EVENT_BUG_CATCHING_CONTESTANT_9A + dw EVENT_BUG_CATCHING_CONTESTANT_10A +; 13a12 + +ContestDropOffMons: ; 13a12 + ld hl, PartyMon1HP + ld a, [hli] + or [hl] + jr z, .fainted +; Mask the rest of your party by setting the count to 1... + ld hl, PartyCount + ld a, 1 + ld [hli], a + inc hl +; ... backing up the second mon index somewhere... + ld a, [hl] + ld [wBugContestSecondPartySpecies], a +; ... and replacing it with the terminator byte + ld [hl], $ff + xor a + ld [ScriptVar], a + ret + +.fainted + ld a, $1 + ld [ScriptVar], a + ret +; 13a31 + +ContestReturnMons: ; 13a31 +; Restore the species of the second mon. + ld hl, PartySpecies + 1 + ld a, [wBugContestSecondPartySpecies] + ld [hl], a +; Restore the party count, which must be recomputed. + ld b, $1 +.loop + ld a, [hli] + cp -1 + jr z, .done + inc b + jr .loop + +.done + ld a, b + ld [PartyCount], a + ret +; 13a47 diff --git a/event/bug_contest/display_stats.asm b/event/bug_contest/display_stats.asm new file mode 100644 index 000000000..d6ad3997e --- /dev/null +++ b/event/bug_contest/display_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/bug_contest/judging.asm b/event/bug_contest/judging.asm new file mode 100755 index 000000000..a7a9eb022 --- /dev/null +++ b/event/bug_contest/judging.asm @@ -0,0 +1,395 @@ +_BugContestJudging: ; 1369d + call ContestScore + callba TrainerRankings_BugContestScore + call BugContest_JudgeContestants + ld a, [wBugContestThirdPlacePersonID] + call LoadContestantName + ld a, [wBugContestThirdPlaceMon] + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + ld hl, BugContest_ThirdPlaceText + call PrintText + ld a, [wBugContestSecondPlacePersonID] + call LoadContestantName + ld a, [wBugContestSecondPlaceMon] + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + ld hl, BugContest_SecondPlaceText + call PrintText + ld a, [wBugContestFirstPlacePersonID] + call LoadContestantName + ld a, [wBugContestFirstPlaceMon] + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + ld hl, BugContest_FirstPlaceText + call PrintText + jp BugContest_GetPlayersResult +; 136eb + +BugContest_FirstPlaceText: ; 0x136eb + text_jump ContestJudging_FirstPlaceText + start_asm + ld de, SFX_1ST_PLACE + call PlaySFX + call WaitSFX + ld hl, BugContest_FirstPlaceScoreText + ret +; 136fd + +BugContest_FirstPlaceScoreText: ; 0x136fd + ; The winning score was @ points! + text_jump ContestJudging_FirstPlaceScoreText + db "@" +; 0x13702 + +BugContest_SecondPlaceText: ; 0x13702 + ; Placing second was @ , who caught a @ !@ @ + text_jump ContestJudging_SecondPlaceText + start_asm + ld de, SFX_2ND_PLACE + call PlaySFX + call WaitSFX + ld hl, BugContest_SecondPlaceScoreText + ret +; 13714 + +BugContest_SecondPlaceScoreText: ; 0x13714 + ; The score was @ points! + text_jump ContestJudging_SecondPlaceScoreText + db "@" +; 0x13719 + +BugContest_ThirdPlaceText: ; 0x13719 + ; Placing third was @ , who caught a @ !@ @ + text_jump ContestJudging_ThirdPlaceText + start_asm + ld de, SFX_3RD_PLACE + call PlaySFX + call WaitSFX + ld hl, BugContest_ThirdPlaceScoreText + ret +; 1372b + +BugContest_ThirdPlaceScoreText: ; 0x1372b + ; The score was @ points! + text_jump ContestJudging_ThirdPlaceScoreText + db "@" +; 0x13730 + +LoadContestantName: ; 13730 + +; If a = 0, get your name. + dec a + jr z, .player +; Find the pointer for the trainer class of the Bug Catching Contestant whose ID is in a. + ld c, a + ld b, 0 + ld hl, BugContestantPointers + add hl, bc + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a +; Copy the Trainer Class to c. + ld a, [hli] + ld c, a +; Save hl and bc for later. + push hl + push bc +; Get the Trainer Class name and copy it into wBugContestWinnerName. + callab GetTrainerClassName + ld hl, StringBuffer1 + ld de, wBugContestWinnerName + ld bc, TRAINER_CLASS_NAME_LENGTH + call CopyBytes + ld hl, wBugContestWinnerName +; Delete the trailing terminator and replace it with a space. +.next + ld a, [hli] + cp "@" + jr nz, .next + dec hl + ld [hl], " " + inc hl + ld d, h + ld e, l +; Restore the Trainer Class ID and Trainer ID pointer. Save de for later. + pop bc + pop hl + push de +; Get the name of the trainer with class c and ID b. + ld a, [hl] + ld b, a + callab GetTrainerName +; Append the name to wBugContestWinnerName. + ld hl, StringBuffer1 + pop de + ld bc, NAME_LENGTH - 1 + jp CopyBytes + +.player + ld hl, PlayerName + ld de, wBugContestWinnerName + ld bc, NAME_LENGTH + jp CopyBytes +; 13783 + + +INCLUDE "data/bug_contest_winners.asm" +; 13807 + + +BugContest_GetPlayersResult: ; 13807 + ld hl, wBugContestThirdPlacePersonID + ld de, -4 + ld b, 3 +.loop + ld a, [hl] + cp 1 ; Player + jr z, .done + add hl, de + dec b + jr nz, .loop + +.done + ret +; 13819 + +BugContest_JudgeContestants: ; 13819 + call ClearContestResults + call ComputeAIContestantScores + ld hl, wBugContestTempPersonID + ld a, 1 ; Player + ld [hli], a + ld a, [wContestMon] + ld [hli], a + ld a, [hProduct] + ld [hli], a + ld a, [hProduct + 1] + ld [hl], a + call DetermineContestWinners + ret +; 13833 + +ClearContestResults: ; 13833 + ld hl, wBugContestResults + ld b, wBugContestWinnersEnd - wBugContestResults + xor a +.loop + ld [hli], a + dec b + jr nz, .loop + ret +; 1383e + +DetermineContestWinners: ; 1383e + ld de, wBugContestTempScore + ld hl, wBugContestFirstPlaceScore + ld c, 2 + call StringCmp + jr c, .not_first_place + ld hl, wBugContestSecondPlacePersonID + ld de, wBugContestThirdPlacePersonID + ld bc, 4 + call CopyBytes + ld hl, wBugContestFirstPlacePersonID + ld de, wBugContestSecondPlacePersonID + ld bc, 4 + call CopyBytes + ld hl, wBugContestFirstPlacePersonID + call CopyTempContestant + jr .done + +.not_first_place + ld de, wBugContestTempScore + ld hl, wBugContestSecondPlaceScore + ld c, 2 + call StringCmp + jr c, .not_second_place + ld hl, wBugContestSecondPlacePersonID + ld de, wBugContestThirdPlacePersonID + ld bc, 4 + call CopyBytes + ld hl, wBugContestSecondPlacePersonID + call CopyTempContestant + jr .done + +.not_second_place + ld de, wBugContestTempScore + ld hl, wBugContestThirdPlaceScore + ld c, 2 + call StringCmp + jr c, .done + ld hl, wBugContestThirdPlacePersonID + call CopyTempContestant + +.done + ret +; 138a0 + +CopyTempContestant: ; 138a0 +; Could've just called CopyBytes. + ld de, wBugContestTempPersonID +rept 3 + ld a, [de] + inc de + ld [hli], a +endr + ld a, [de] + inc de + ld [hl], a + ret +; 138b0 + +ComputeAIContestantScores: ; 138b0 + ld e, 0 +.loop + push de + call Special_CheckBugContestContestantFlag + pop de + jr nz, .done + ld a, e + inc a + inc a + ld [wBugContestTempPersonID], a + dec a + ld c, a + ld b, 0 + ld hl, BugContestantPointers + add hl, bc + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + inc hl + inc hl +.loop2 + call Random + and 3 + cp 3 + jr z, .loop2 + ld c, a + ld b, 0 + add hl, bc + add hl, bc + add hl, bc + ld a, [hli] + ld [wBugContestTempMon], a + ld a, [hli] + ld h, [hl] + ld l, a + call Random + and 7 + ld c, a + ld b, 0 + add hl, bc + ld a, h + ld [wBugContestTempScore], a + ld a, l + ld [wBugContestTempScore + 1], a + push de + call DetermineContestWinners + pop de + +.done + inc e + ld a, e + cp 10 + jr nz, .loop + ret +; 13900 + +ContestScore: ; 13900 +; Determine the player's score in the Bug Catching Contest. + + xor a + ld [hProduct], a + ld [hMultiplicand], a + + ld a, [wContestMonSpecies] ; Species + and a + jr z, .done + + ; Tally the following: + + ; Max HP * 4 + ld a, [wContestMonMaxHP + 1] + call .AddContestStat + ld a, [wContestMonMaxHP + 1] + call .AddContestStat + ld a, [wContestMonMaxHP + 1] + call .AddContestStat + ld a, [wContestMonMaxHP + 1] + call .AddContestStat + + ; Stats + ld a, [wContestMonAttack + 1] + call .AddContestStat + ld a, [wContestMonDefense + 1] + call .AddContestStat + ld a, [wContestMonSpeed + 1] + call .AddContestStat + ld a, [wContestMonSpclAtk + 1] + call .AddContestStat + ld a, [wContestMonSpclDef + 1] + call .AddContestStat + + ; DVs + ld a, [wContestMonDVs + 0] + ld b, a + and 2 + add a + add a + ld c, a + + swap b + ld a, b + and 2 + add a + add c + ld d, a + + ld a, [wContestMonDVs + 1] + ld b, a + and 2 + ld c, a + + swap b + ld a, b + and 2 + srl a + add c + add c + add d + add d + + call .AddContestStat + + ; Remaining HP / 8 + ld a, [wContestMonHP + 1] + srl a + srl a + srl a + call .AddContestStat + + ; Whether it's holding an item + ld a, [wContestMonItem] + and a + jr z, .done + + ld a, 1 + call .AddContestStat + +.done + ret +; 1397f + +.AddContestStat: ; 1397f + ld hl, hMultiplicand + add [hl] + ld [hl], a + ret nc + dec hl + inc [hl] + ret +; 13988 diff --git a/event/bug_contest_2.asm b/event/bug_contest_2.asm deleted file mode 100755 index 493c69d0c..000000000 --- a/event/bug_contest_2.asm +++ /dev/null @@ -1,133 +0,0 @@ -Special_SelectRandomBugContestContestants: ; 139a8 -; Select five random people to participate in the current contest. - -; First we have to make sure that any old data is cleared away. - ld c, 10 ; Number of people to choose from. - ld hl, BugCatchingContestantEventFlagTable -.loop1 - push bc - push hl - ld e, [hl] - inc hl - ld d, [hl] - ld b, RESET_FLAG - call EventFlagAction - pop hl - inc hl - inc hl - pop bc - dec c - jr nz, .loop1 - -; Now that that's out of the way, we can get on to the good stuff. - ld c, 5 -.loop2 - push bc -.next -; Choose a flag at uniform random to be set. - call Random - cp 250 - jr nc, .next - ld c, 25 - call SimpleDivide - ld e, b - ld d, 0 - ld hl, BugCatchingContestantEventFlagTable - add hl, de - add hl, de - ld e, [hl] - inc hl - ld d, [hl] - push de -; If we've already set it, it doesn't count. - ld b, CHECK_FLAG - call EventFlagAction - pop de - ld a, c - and a - jr nz, .next -; Set the flag. This will cause that sprite to not be visible in the contest. - ld b, SET_FLAG - call EventFlagAction - pop bc -; Check if we're done. If so, return. Otherwise, choose the next victim. - dec c - jr nz, .loop2 - ret -; 139ed - -Special_CheckBugContestContestantFlag: ; 139ed -; Checks the flag of the Bug Catching Contestant whose index is loaded in a. - -; Bug: If a >= 10 when this is called, it will read beyond the table. - - ld hl, BugCatchingContestantEventFlagTable - ld e, a - ld d, 0 - add hl, de - add hl, de - ld e, [hl] - inc hl - ld d, [hl] - ld b, CHECK_FLAG - call EventFlagAction - ret -; 139fe - -BugCatchingContestantEventFlagTable: ; 139fe - dw EVENT_BUG_CATCHING_CONTESTANT_1A - dw EVENT_BUG_CATCHING_CONTESTANT_2A - dw EVENT_BUG_CATCHING_CONTESTANT_3A - dw EVENT_BUG_CATCHING_CONTESTANT_4A - dw EVENT_BUG_CATCHING_CONTESTANT_5A - dw EVENT_BUG_CATCHING_CONTESTANT_6A - dw EVENT_BUG_CATCHING_CONTESTANT_7A - dw EVENT_BUG_CATCHING_CONTESTANT_8A - dw EVENT_BUG_CATCHING_CONTESTANT_9A - dw EVENT_BUG_CATCHING_CONTESTANT_10A -; 13a12 - -ContestDropOffMons: ; 13a12 - ld hl, PartyMon1HP - ld a, [hli] - or [hl] - jr z, .fainted -; Mask the rest of your party by setting the count to 1... - ld hl, PartyCount - ld a, 1 - ld [hli], a - inc hl -; ... backing up the second mon index somewhere... - ld a, [hl] - ld [wBugContestSecondPartySpecies], a -; ... and replacing it with the terminator byte - ld [hl], $ff - xor a - ld [ScriptVar], a - ret - -.fainted - ld a, $1 - ld [ScriptVar], a - ret -; 13a31 - -ContestReturnMons: ; 13a31 -; Restore the species of the second mon. - ld hl, PartySpecies + 1 - ld a, [wBugContestSecondPartySpecies] - ld [hl], a -; Restore the party count, which must be recomputed. - ld b, $1 -.loop - ld a, [hli] - cp -1 - jr z, .done - inc b - jr .loop - -.done - ld a, b - ld [PartyCount], a - ret -; 13a47 diff --git a/event/bug_contest_judging.asm b/event/bug_contest_judging.asm deleted file mode 100755 index a7a9eb022..000000000 --- a/event/bug_contest_judging.asm +++ /dev/null @@ -1,395 +0,0 @@ -_BugContestJudging: ; 1369d - call ContestScore - callba TrainerRankings_BugContestScore - call BugContest_JudgeContestants - ld a, [wBugContestThirdPlacePersonID] - call LoadContestantName - ld a, [wBugContestThirdPlaceMon] - ld [wNamedObjectIndexBuffer], a - call GetPokemonName - ld hl, BugContest_ThirdPlaceText - call PrintText - ld a, [wBugContestSecondPlacePersonID] - call LoadContestantName - ld a, [wBugContestSecondPlaceMon] - ld [wNamedObjectIndexBuffer], a - call GetPokemonName - ld hl, BugContest_SecondPlaceText - call PrintText - ld a, [wBugContestFirstPlacePersonID] - call LoadContestantName - ld a, [wBugContestFirstPlaceMon] - ld [wNamedObjectIndexBuffer], a - call GetPokemonName - ld hl, BugContest_FirstPlaceText - call PrintText - jp BugContest_GetPlayersResult -; 136eb - -BugContest_FirstPlaceText: ; 0x136eb - text_jump ContestJudging_FirstPlaceText - start_asm - ld de, SFX_1ST_PLACE - call PlaySFX - call WaitSFX - ld hl, BugContest_FirstPlaceScoreText - ret -; 136fd - -BugContest_FirstPlaceScoreText: ; 0x136fd - ; The winning score was @ points! - text_jump ContestJudging_FirstPlaceScoreText - db "@" -; 0x13702 - -BugContest_SecondPlaceText: ; 0x13702 - ; Placing second was @ , who caught a @ !@ @ - text_jump ContestJudging_SecondPlaceText - start_asm - ld de, SFX_2ND_PLACE - call PlaySFX - call WaitSFX - ld hl, BugContest_SecondPlaceScoreText - ret -; 13714 - -BugContest_SecondPlaceScoreText: ; 0x13714 - ; The score was @ points! - text_jump ContestJudging_SecondPlaceScoreText - db "@" -; 0x13719 - -BugContest_ThirdPlaceText: ; 0x13719 - ; Placing third was @ , who caught a @ !@ @ - text_jump ContestJudging_ThirdPlaceText - start_asm - ld de, SFX_3RD_PLACE - call PlaySFX - call WaitSFX - ld hl, BugContest_ThirdPlaceScoreText - ret -; 1372b - -BugContest_ThirdPlaceScoreText: ; 0x1372b - ; The score was @ points! - text_jump ContestJudging_ThirdPlaceScoreText - db "@" -; 0x13730 - -LoadContestantName: ; 13730 - -; If a = 0, get your name. - dec a - jr z, .player -; Find the pointer for the trainer class of the Bug Catching Contestant whose ID is in a. - ld c, a - ld b, 0 - ld hl, BugContestantPointers - add hl, bc - add hl, bc - ld a, [hli] - ld h, [hl] - ld l, a -; Copy the Trainer Class to c. - ld a, [hli] - ld c, a -; Save hl and bc for later. - push hl - push bc -; Get the Trainer Class name and copy it into wBugContestWinnerName. - callab GetTrainerClassName - ld hl, StringBuffer1 - ld de, wBugContestWinnerName - ld bc, TRAINER_CLASS_NAME_LENGTH - call CopyBytes - ld hl, wBugContestWinnerName -; Delete the trailing terminator and replace it with a space. -.next - ld a, [hli] - cp "@" - jr nz, .next - dec hl - ld [hl], " " - inc hl - ld d, h - ld e, l -; Restore the Trainer Class ID and Trainer ID pointer. Save de for later. - pop bc - pop hl - push de -; Get the name of the trainer with class c and ID b. - ld a, [hl] - ld b, a - callab GetTrainerName -; Append the name to wBugContestWinnerName. - ld hl, StringBuffer1 - pop de - ld bc, NAME_LENGTH - 1 - jp CopyBytes - -.player - ld hl, PlayerName - ld de, wBugContestWinnerName - ld bc, NAME_LENGTH - jp CopyBytes -; 13783 - - -INCLUDE "data/bug_contest_winners.asm" -; 13807 - - -BugContest_GetPlayersResult: ; 13807 - ld hl, wBugContestThirdPlacePersonID - ld de, -4 - ld b, 3 -.loop - ld a, [hl] - cp 1 ; Player - jr z, .done - add hl, de - dec b - jr nz, .loop - -.done - ret -; 13819 - -BugContest_JudgeContestants: ; 13819 - call ClearContestResults - call ComputeAIContestantScores - ld hl, wBugContestTempPersonID - ld a, 1 ; Player - ld [hli], a - ld a, [wContestMon] - ld [hli], a - ld a, [hProduct] - ld [hli], a - ld a, [hProduct + 1] - ld [hl], a - call DetermineContestWinners - ret -; 13833 - -ClearContestResults: ; 13833 - ld hl, wBugContestResults - ld b, wBugContestWinnersEnd - wBugContestResults - xor a -.loop - ld [hli], a - dec b - jr nz, .loop - ret -; 1383e - -DetermineContestWinners: ; 1383e - ld de, wBugContestTempScore - ld hl, wBugContestFirstPlaceScore - ld c, 2 - call StringCmp - jr c, .not_first_place - ld hl, wBugContestSecondPlacePersonID - ld de, wBugContestThirdPlacePersonID - ld bc, 4 - call CopyBytes - ld hl, wBugContestFirstPlacePersonID - ld de, wBugContestSecondPlacePersonID - ld bc, 4 - call CopyBytes - ld hl, wBugContestFirstPlacePersonID - call CopyTempContestant - jr .done - -.not_first_place - ld de, wBugContestTempScore - ld hl, wBugContestSecondPlaceScore - ld c, 2 - call StringCmp - jr c, .not_second_place - ld hl, wBugContestSecondPlacePersonID - ld de, wBugContestThirdPlacePersonID - ld bc, 4 - call CopyBytes - ld hl, wBugContestSecondPlacePersonID - call CopyTempContestant - jr .done - -.not_second_place - ld de, wBugContestTempScore - ld hl, wBugContestThirdPlaceScore - ld c, 2 - call StringCmp - jr c, .done - ld hl, wBugContestThirdPlacePersonID - call CopyTempContestant - -.done - ret -; 138a0 - -CopyTempContestant: ; 138a0 -; Could've just called CopyBytes. - ld de, wBugContestTempPersonID -rept 3 - ld a, [de] - inc de - ld [hli], a -endr - ld a, [de] - inc de - ld [hl], a - ret -; 138b0 - -ComputeAIContestantScores: ; 138b0 - ld e, 0 -.loop - push de - call Special_CheckBugContestContestantFlag - pop de - jr nz, .done - ld a, e - inc a - inc a - ld [wBugContestTempPersonID], a - dec a - ld c, a - ld b, 0 - ld hl, BugContestantPointers - add hl, bc - add hl, bc - ld a, [hli] - ld h, [hl] - ld l, a - inc hl - inc hl -.loop2 - call Random - and 3 - cp 3 - jr z, .loop2 - ld c, a - ld b, 0 - add hl, bc - add hl, bc - add hl, bc - ld a, [hli] - ld [wBugContestTempMon], a - ld a, [hli] - ld h, [hl] - ld l, a - call Random - and 7 - ld c, a - ld b, 0 - add hl, bc - ld a, h - ld [wBugContestTempScore], a - ld a, l - ld [wBugContestTempScore + 1], a - push de - call DetermineContestWinners - pop de - -.done - inc e - ld a, e - cp 10 - jr nz, .loop - ret -; 13900 - -ContestScore: ; 13900 -; Determine the player's score in the Bug Catching Contest. - - xor a - ld [hProduct], a - ld [hMultiplicand], a - - ld a, [wContestMonSpecies] ; Species - and a - jr z, .done - - ; Tally the following: - - ; Max HP * 4 - ld a, [wContestMonMaxHP + 1] - call .AddContestStat - ld a, [wContestMonMaxHP + 1] - call .AddContestStat - ld a, [wContestMonMaxHP + 1] - call .AddContestStat - ld a, [wContestMonMaxHP + 1] - call .AddContestStat - - ; Stats - ld a, [wContestMonAttack + 1] - call .AddContestStat - ld a, [wContestMonDefense + 1] - call .AddContestStat - ld a, [wContestMonSpeed + 1] - call .AddContestStat - ld a, [wContestMonSpclAtk + 1] - call .AddContestStat - ld a, [wContestMonSpclDef + 1] - call .AddContestStat - - ; DVs - ld a, [wContestMonDVs + 0] - ld b, a - and 2 - add a - add a - ld c, a - - swap b - ld a, b - and 2 - add a - add c - ld d, a - - ld a, [wContestMonDVs + 1] - ld b, a - and 2 - ld c, a - - swap b - ld a, b - and 2 - srl a - add c - add c - add d - add d - - call .AddContestStat - - ; Remaining HP / 8 - ld a, [wContestMonHP + 1] - srl a - srl a - srl a - call .AddContestStat - - ; Whether it's holding an item - ld a, [wContestMonItem] - and a - jr z, .done - - ld a, 1 - call .AddContestStat - -.done - ret -; 1397f - -.AddContestStat: ; 1397f - ld hl, hMultiplicand - add [hl] - ld [hl], a - ret nc - dec hl - inc [hl] - ret -; 13988 diff --git a/event/bug_contest_mon_stats.asm b/event/bug_contest_mon_stats.asm deleted file mode 100644 index d6ad3997e..000000000 --- a/event/bug_contest_mon_stats.asm +++ /dev/null @@ -1,107 +0,0 @@ -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/heal_machine_anim.asm b/event/heal_machine_anim.asm new file mode 100755 index 000000000..4f543c0b3 --- /dev/null +++ b/event/heal_machine_anim.asm @@ -0,0 +1,265 @@ +HealMachineAnim: ; 12324 + ; If you have no Pokemon, don't change the buffer. This can lead to some glitchy effects if you have no Pokemon. + ld a, [PartyCount] + and a + ret z + ; The location of the healing machine relative to the player is stored in ScriptVar. + ; 0: Up and left (Pokemon Center) + ; 1: Left (Elm's Lab) + ; 2: Up (Hall of Fame) + ld a, [ScriptVar] + ld [Buffer1], a + ld a, [rOBP1] + ld [Buffer2], a + call .DoJumptableFunctions + ld a, [Buffer2] + call DmgToCgbObjPal1 + ret +; 1233e + +.DoJumptableFunctions: ; 1233e + xor a + ld [Buffer3], a +.jumpable_loop + ld a, [Buffer1] + ld e, a + ld d, 0 + ld hl, .Pointers + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [Buffer3] + ld e, a + inc a + ld [Buffer3], a + add hl, de + ld a, [hl] + cp 5 + jr z, .finish + ld hl, .Jumptable + rst JumpTable + jr .jumpable_loop + +.finish + ret +; 12365 + +.Pointers: ; 12365 + dw .Pokecenter + dw .ElmLab + dw .HallOfFame +; 1236b + +.Pokecenter: ; 1236b + db 0, 1, 3, 5 +.ElmLab: ; 1236f + db 0, 1, 3, 5 +.HallOfFame: ; 12373 + db 0, 2, 4, 5 +; 12377 + +.Jumptable: ; 12377 + dw .LoadGFX + dw .PC_LoadBallsOntoMachine + dw .HOF_LoadBallsOntoMachine + dw .PlayHealMusic + dw .HOF_PlaySFX + dw .dummy_5 ; never encountered +; 12383 + +.LoadGFX: ; 12383 + call .LoadPalettes + ld de, .HealMachineGFX + ld hl, VTiles0 tile $7c + lb bc, BANK(.HealMachineGFX), $2 + call Request2bpp + ret +; 12393 + +.PC_LoadBallsOntoMachine: ; 12393 + ld hl, Sprites + $80 + ld de, .PC_ElmsLab_OAM + call .PlaceHealingMachineTile + call .PlaceHealingMachineTile + jr .LoadBallsOntoMachine + +.HOF_LoadBallsOntoMachine: ; 123a1 + ld hl, Sprites + $80 + ld de, .HOF_OAM + +.LoadBallsOntoMachine: ; 123a7 + ld a, [PartyCount] + ld b, a +.party_loop + call .PlaceHealingMachineTile + push de + ld de, SFX_SECOND_PART_OF_ITEMFINDER + call PlaySFX + pop de + ld c, 30 + call DelayFrames + dec b + jr nz, .party_loop + ret +; 123bf + +.PlayHealMusic: ; 123bf + ld de, MUSIC_HEAL + call PlayMusic + jp .FlashPalettes8Times +; 123c8 + +.HOF_PlaySFX: ; 123c8 + ld de, SFX_GAME_FREAK_LOGO_GS + call PlaySFX + call .FlashPalettes8Times + call WaitSFX + ld de, SFX_BOOT_PC + call PlaySFX + ret +; 123db + +.dummy_5 ; 123db + ret +; 123dc + +.PC_ElmsLab_OAM: ; 123dc + dsprite 4, 0, 4, 2, $7c, $16 + dsprite 4, 0, 4, 6, $7c, $16 + dsprite 4, 6, 4, 0, $7d, $16 + dsprite 4, 6, 5, 0, $7d, $36 ; xflip + dsprite 5, 3, 4, 0, $7d, $16 + dsprite 5, 3, 5, 0, $7d, $36 ; xflip + dsprite 6, 0, 4, 0, $7d, $16 + dsprite 6, 0, 5, 0, $7d, $36 ; xflip +; 123fc + +.HealMachineGFX: ; 123fc +INCBIN "gfx/overworld/heal_machine.2bpp" +; 1241c + +.HOF_OAM: ; 1241c + dsprite 7, 4, 10, 1, $7d, $16 + dsprite 7, 4, 10, 6, $7d, $16 + dsprite 7, 3, 9, 5, $7d, $16 + dsprite 7, 3, 11, 2, $7d, $16 + dsprite 7, 1, 9, 1, $7d, $16 + dsprite 7, 1, 11, 5, $7d, $16 +; 12434 + +.LoadPalettes: ; 12434 + call IsCGB + jr nz, .cgb + ld a, %11100000 + ld [rOBP1], a + ret + +.cgb + ld hl, .palettes + ld de, OBPals + 8 * 6 + ld bc, 8 + ld a, $5 + call FarCopyWRAM + ld a, $1 + ld [hCGBPalUpdate], a + ret +; 12451 + +.palettes ; 12451 + RGB 31, 31, 31 + RGB 31, 19, 10 + RGB 31, 07, 01 + RGB 00, 00, 00 +; 12459 + +.FlashPalettes8Times: ; 12459 + ld c, $8 +.palette_loop + push bc + call .FlashPalettes + ld c, 10 + call DelayFrames + pop bc + dec c + jr nz, .palette_loop + ret +; 12469 + +.FlashPalettes: ; 12469 + call IsCGB + jr nz, .go + ld a, [rOBP1] + xor %00101000 + ld [rOBP1], a + ret + +.go + ld a, [rSVBK] + push af + ld a, $5 + ld [rSVBK], a + + ld hl, OBPals + 8 * 6 + ld a, [hli] + ld e, a + ld a, [hli] + ld d, a + push de + ld c, $3 +.palette_loop_2 + ld a, [hli] + ld e, a + ld a, [hld] + ld d, a + dec hl + ld a, d + ld [hld], a + ld a, e + ld [hli], a + inc hl + inc hl + inc hl + dec c + jr nz, .palette_loop_2 + pop de + dec hl + ld a, d + ld [hld], a + ld a, e + ld [hl], a + + pop af + ld [rSVBK], a + ld a, $1 + ld [hCGBPalUpdate], a + ret +; 124a3 + +.PlaceHealingMachineTile: ; 124a3 + push bc + ld a, [Buffer1] + bcpixel 2, 4 + cp $1 ; ElmsLab + jr z, .okay + bcpixel 0, 0 + +.okay + ld a, [de] + add c + inc de + ld [hli], a + ld a, [de] + add b + inc de + ld [hli], a + ld a, [de] + inc de + ld [hli], a + ld a, [de] + inc de + ld [hli], a + pop bc + ret +; 124c1 diff --git a/event/photo.asm b/event/photo.asm deleted file mode 100755 index 55ac8e7d1..000000000 --- a/event/photo.asm +++ /dev/null @@ -1,295 +0,0 @@ -UnownPrinter: ; 16be4 - ld a, [UnownDex] - and a - ret z - - ld a, [hInMenu] - push af - ld a, $1 - ld [hInMenu], a - ld a, [Options] - push af - set NO_TEXT_SCROLL, a - ld [Options], a - call ClearBGPalettes - call ClearTileMap - - ld de, UnownDexATile - ld hl, VTiles1 tile $6f - lb bc, BANK(UnownDexBTile), 1 - call Request1bpp - - ld de, UnownDexBTile - ld hl, VTiles1 tile $75 - lb bc, BANK(UnownDexBTile), 1 - call Request1bpp - - hlcoord 0, 0 - lb bc, 3, 18 - call TextBox - - hlcoord 0, 5 - lb bc, 7, 7 - call TextBox - - hlcoord 0, 14 - lb bc, 2, 18 - call TextBox - - hlcoord 1, 2 - ld de, AlphRuinsStampString - call PlaceString - - hlcoord 1, 16 - ld de, UnownDexDoWhatString - call PlaceString - - hlcoord 10, 6 - ld de, UnownDexMenuString - call PlaceString - - xor a - ld [wJumptableIndex], a - call .UpdateUnownFrontpic - call WaitBGMap - - ld a, UNOWN - ld [CurPartySpecies], a - xor a - ld [TempMonDVs], a - ld [TempMonDVs + 1], a - - ld b, SCGB_TRAINER_OR_MON_FRONTPIC_PALS - call GetSGBLayout - call SetPalettes - -.joy_loop - call JoyTextDelay - - ld a, [hJoyPressed] - and B_BUTTON - jr nz, .pressed_b - - ld a, [hJoyPressed] - and A_BUTTON - jr nz, .pressed_a - - call .LeftRight - call DelayFrame - jr .joy_loop - -.pressed_a - ld a, [wJumptableIndex] - push af - callba PrintUnownStamp - call RestartMapMusic - pop af - ld [wJumptableIndex], a - jr .joy_loop - -.pressed_b - pop af - ld [Options], a - pop af - ld [hInMenu], a - call ReturnToMapFromSubmenu - ret -; 16ca0 - -.LeftRight: ; 16ca0 - ld a, [hJoyLast] - and D_RIGHT - jr nz, .press_right - ld a, [hJoyLast] - and D_LEFT - jr nz, .press_left - ret - -.press_left - ld hl, wJumptableIndex - ld a, [hl] - and a - jr nz, .wrap_around_left - ld [hl], 26 + 1 -.wrap_around_left - dec [hl] - jr .return - -.press_right - ld hl, wJumptableIndex - ld a, [hl] - cp 26 - jr c, .wrap_around_right - ld [hl], -1 -.wrap_around_right - inc [hl] - -.return - call .UpdateUnownFrontpic - ret -; 16cc8 - -.UpdateUnownFrontpic: ; 16cc8 - ld a, [wJumptableIndex] - cp 26 - jr z, .vacant - inc a - ld [UnownLetter], a - ld a, UNOWN - ld [CurPartySpecies], a - xor a - ld [wBoxAlignment], a - ld de, VTiles2 - predef GetFrontpic - call .Load2bppToSRAM - hlcoord 1, 6 - xor a - ld [hGraphicStartTile], a - lb bc, 7, 7 - predef PlaceGraphic - ld de, VTiles2 tile $31 - callba RotateUnownFrontpic - ret - -.Load2bppToSRAM: ; 16cff - ld a, [rSVBK] - push af - ld a, $6 - ld [rSVBK], a - - ld a, BANK(sScratch) - call GetSRAMBank - ld de, wDecompressScratch - ld hl, sScratch - ld a, [hROMBank] - ld b, a - ld c, $31 - call Get2bpp - call CloseSRAM - - pop af - ld [rSVBK], a - ret - -.vacant - hlcoord 1, 6 - lb bc, 7, 7 - call ClearBox - hlcoord 1, 9 - ld de, UnownDexVacantString - call PlaceString - xor a - call GetSRAMBank - ld hl, sScratch - ld bc, $31 tiles - xor a - call ByteFill - ld hl, VTiles2 tile $31 - ld de, sScratch - ld c, $31 - ld a, [hROMBank] - ld b, a - call Get2bpp - call CloseSRAM - ld c, 20 - call DelayFrames - ret -; 16d57 - -AlphRuinsStampString: - db " ALPH RUINS STAMP@" - -UnownDexDoWhatString: - db "Do what?@" - -UnownDexMenuString: - db "♂ PRINT" - next "♀ CANCEL" - next "← PREVIOUS" - next "→ NEXT" - db "@" - -UnownDexVacantString: - db "VACANT@" -; 16d9c - -UnownDexATile: ; 16d9c -INCBIN "gfx/printer/bold_a.1bpp" -UnownDexBTile: ; 16da4 -INCBIN "gfx/printer/bold_b.1bpp" -; 16dac - -PlaceUnownPrinterFrontpic: ; 16dac - hlcoord 0, 0 - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - ld a, " " - call ByteFill - hlcoord 7, 11 - ld a, $31 - ld [hGraphicStartTile], a - lb bc, 7, 7 - predef PlaceGraphic - ret -; 16dc7 - -PhotoStudio: ; 16dc7 - ld hl, .Text_AskWhichMon - call PrintText - callba SelectMonFromParty - jr c, .cancel - ld a, [CurPartySpecies] - cp EGG - jr z, .egg - - ld hl, .Text_HoldStill - call PrintText - call DisableSpriteUpdates - callba PrintPartymon - call ReturnToMapWithSpeechTextbox - ld a, [hPrinter] - and a - jr nz, .cancel - ld hl, .Text_Presto - jr .print_text - -.cancel - ld hl, .Text_NoPicture - jr .print_text - -.egg - ld hl, .Text_Egg - -.print_text - call PrintText - ret -; 16e04 - -.Text_AskWhichMon: ; 0x16e04 - ; Which #MON should I photo- graph? - text_jump UnknownText_0x1be024 - db "@" -; 0x16e09 - -.Text_HoldStill: ; 0x16e09 - ; All righty. Hold still for a bit. - text_jump UnknownText_0x1be047 - db "@" -; 0x16e0e - -.Text_Presto: ; 0x16e0e - ; Presto! All done. Come again, OK? - text_jump UnknownText_0x1be06a - db "@" -; 0x16e13 - -.Text_NoPicture: ; 0x16e13 - ; Oh, no picture? Come again, OK? - text_jump UnknownText_0x1c0000 - db "@" -; 0x16e18 - -.Text_Egg: ; 0x16e18 - ; An EGG? My talent is worth more… - text_jump UnknownText_0x1c0021 - db "@" -; 0x16e1d diff --git a/event/poisonstep_pals.asm b/event/poisonstep_pals.asm new file mode 100644 index 000000000..c556ba498 --- /dev/null +++ b/event/poisonstep_pals.asm @@ -0,0 +1,48 @@ +LoadPoisonBGPals: ; cbcdd + call .LoadPals + ld a, [hCGB] + and a + ret nz + ret ; ???? + +.LoadPals: ; cbce5 + ld a, [hCGB] + and a + jr nz, .cgb + ld a, [TimeOfDayPal] + and $3 + cp $3 + ld a, %00000000 + jr z, .convert_pals + ld a, %10101010 + +.convert_pals + call DmgToCgbBGPals + ld c, 4 + call DelayFrames + callba _UpdateTimePals + ret + +.cgb + ld a, [rSVBK] + push af + ld a, $5 + ld [rSVBK], a + ld hl, BGPals + ld c, $20 +.loop +; RGB 28, 21, 31 + ld a, (palred 28 + palgreen 21 + palblue 31) % $100 + ld [hli], a + ld a, (palred 28 + palgreen 21 + palblue 31) / $100 + ld [hli], a + dec c + jr nz, .loop + pop af + ld [rSVBK], a + ld a, $1 + ld [hCGBPalUpdate], a + ld c, 4 + call DelayFrames + callba _UpdateTimePals + ret diff --git a/event/print_photo.asm b/event/print_photo.asm new file mode 100755 index 000000000..448910355 --- /dev/null +++ b/event/print_photo.asm @@ -0,0 +1,61 @@ +PhotoStudio: ; 16dc7 + ld hl, .Text_AskWhichMon + call PrintText + callba SelectMonFromParty + jr c, .cancel + ld a, [CurPartySpecies] + cp EGG + jr z, .egg + + ld hl, .Text_HoldStill + call PrintText + call DisableSpriteUpdates + callba PrintPartymon + call ReturnToMapWithSpeechTextbox + ld a, [hPrinter] + and a + jr nz, .cancel + ld hl, .Text_Presto + jr .print_text + +.cancel + ld hl, .Text_NoPicture + jr .print_text + +.egg + ld hl, .Text_Egg + +.print_text + call PrintText + ret +; 16e04 + +.Text_AskWhichMon: ; 0x16e04 + ; Which #MON should I photo- graph? + text_jump UnknownText_0x1be024 + db "@" +; 0x16e09 + +.Text_HoldStill: ; 0x16e09 + ; All righty. Hold still for a bit. + text_jump UnknownText_0x1be047 + db "@" +; 0x16e0e + +.Text_Presto: ; 0x16e0e + ; Presto! All done. Come again, OK? + text_jump UnknownText_0x1be06a + db "@" +; 0x16e13 + +.Text_NoPicture: ; 0x16e13 + ; Oh, no picture? Come again, OK? + text_jump UnknownText_0x1c0000 + db "@" +; 0x16e18 + +.Text_Egg: ; 0x16e18 + ; An EGG? My talent is worth more… + text_jump UnknownText_0x1c0021 + db "@" +; 0x16e1d diff --git a/event/print_unown.asm b/event/print_unown.asm new file mode 100644 index 000000000..5e0162bad --- /dev/null +++ b/event/print_unown.asm @@ -0,0 +1,233 @@ +UnownPrinter: ; 16be4 + ld a, [UnownDex] + and a + ret z + + ld a, [hInMenu] + push af + ld a, $1 + ld [hInMenu], a + ld a, [Options] + push af + set NO_TEXT_SCROLL, a + ld [Options], a + call ClearBGPalettes + call ClearTileMap + + ld de, UnownDexATile + ld hl, VTiles1 tile $6f + lb bc, BANK(UnownDexBTile), 1 + call Request1bpp + + ld de, UnownDexBTile + ld hl, VTiles1 tile $75 + lb bc, BANK(UnownDexBTile), 1 + call Request1bpp + + hlcoord 0, 0 + lb bc, 3, 18 + call TextBox + + hlcoord 0, 5 + lb bc, 7, 7 + call TextBox + + hlcoord 0, 14 + lb bc, 2, 18 + call TextBox + + hlcoord 1, 2 + ld de, AlphRuinsStampString + call PlaceString + + hlcoord 1, 16 + ld de, UnownDexDoWhatString + call PlaceString + + hlcoord 10, 6 + ld de, UnownDexMenuString + call PlaceString + + xor a + ld [wJumptableIndex], a + call .UpdateUnownFrontpic + call WaitBGMap + + ld a, UNOWN + ld [CurPartySpecies], a + xor a + ld [TempMonDVs], a + ld [TempMonDVs + 1], a + + ld b, SCGB_TRAINER_OR_MON_FRONTPIC_PALS + call GetSGBLayout + call SetPalettes + +.joy_loop + call JoyTextDelay + + ld a, [hJoyPressed] + and B_BUTTON + jr nz, .pressed_b + + ld a, [hJoyPressed] + and A_BUTTON + jr nz, .pressed_a + + call .LeftRight + call DelayFrame + jr .joy_loop + +.pressed_a + ld a, [wJumptableIndex] + push af + callba PrintUnownStamp + call RestartMapMusic + pop af + ld [wJumptableIndex], a + jr .joy_loop + +.pressed_b + pop af + ld [Options], a + pop af + ld [hInMenu], a + call ReturnToMapFromSubmenu + ret +; 16ca0 + +.LeftRight: ; 16ca0 + ld a, [hJoyLast] + and D_RIGHT + jr nz, .press_right + ld a, [hJoyLast] + and D_LEFT + jr nz, .press_left + ret + +.press_left + ld hl, wJumptableIndex + ld a, [hl] + and a + jr nz, .wrap_around_left + ld [hl], 26 + 1 +.wrap_around_left + dec [hl] + jr .return + +.press_right + ld hl, wJumptableIndex + ld a, [hl] + cp 26 + jr c, .wrap_around_right + ld [hl], -1 +.wrap_around_right + inc [hl] + +.return + call .UpdateUnownFrontpic + ret +; 16cc8 + +.UpdateUnownFrontpic: ; 16cc8 + ld a, [wJumptableIndex] + cp 26 + jr z, .vacant + inc a + ld [UnownLetter], a + ld a, UNOWN + ld [CurPartySpecies], a + xor a + ld [wBoxAlignment], a + ld de, VTiles2 + predef GetFrontpic + call .Load2bppToSRAM + hlcoord 1, 6 + xor a + ld [hGraphicStartTile], a + lb bc, 7, 7 + predef PlaceGraphic + ld de, VTiles2 tile $31 + callba RotateUnownFrontpic + ret + +.Load2bppToSRAM: ; 16cff + ld a, [rSVBK] + push af + ld a, $6 + ld [rSVBK], a + + ld a, BANK(sScratch) + call GetSRAMBank + ld de, wDecompressScratch + ld hl, sScratch + ld a, [hROMBank] + ld b, a + ld c, $31 + call Get2bpp + call CloseSRAM + + pop af + ld [rSVBK], a + ret + +.vacant + hlcoord 1, 6 + lb bc, 7, 7 + call ClearBox + hlcoord 1, 9 + ld de, UnownDexVacantString + call PlaceString + xor a + call GetSRAMBank + ld hl, sScratch + ld bc, $31 tiles + xor a + call ByteFill + ld hl, VTiles2 tile $31 + ld de, sScratch + ld c, $31 + ld a, [hROMBank] + ld b, a + call Get2bpp + call CloseSRAM + ld c, 20 + call DelayFrames + ret +; 16d57 + +AlphRuinsStampString: + db " ALPH RUINS STAMP@" + +UnownDexDoWhatString: + db "Do what?@" + +UnownDexMenuString: + db "♂ PRINT" + next "♀ CANCEL" + next "← PREVIOUS" + next "→ NEXT" + db "@" + +UnownDexVacantString: + db "VACANT@" +; 16d9c + +UnownDexATile: ; 16d9c +INCBIN "gfx/printer/bold_a.1bpp" +UnownDexBTile: ; 16da4 +INCBIN "gfx/printer/bold_b.1bpp" +; 16dac + +PlaceUnownPrinterFrontpic: ; 16dac + hlcoord 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + ld a, " " + call ByteFill + hlcoord 7, 11 + ld a, $31 + ld [hGraphicStartTile], a + lb bc, 7, 7 + predef PlaceGraphic + ret +; 16dc7 diff --git a/event/print_unown_2.asm b/event/print_unown_2.asm new file mode 100644 index 000000000..057db5176 --- /dev/null +++ b/event/print_unown_2.asm @@ -0,0 +1,111 @@ +RotateUnownFrontpic: ; e0000 +; something to do with Unown printer + push de + xor a + call GetSRAMBank + ld hl, sScratch + ld bc, 0 +.loop + push bc + push hl + push bc + ld de, wd002 + call .Copy + call .Rotate + ld hl, UnownPrinter_OverworldMapRectangle + pop bc + add hl, bc + add hl, bc + ld a, [hli] + ld e, a + ld d, [hl] + ld hl, wd012 + call .Copy + pop hl + ld bc, $10 + add hl, bc + pop bc + inc c + ld a, c + cp 7 * 7 + jr c, .loop + + ld hl, OverworldMap + ld de, sScratch + ld bc, 7 * 7 tiles + call CopyBytes + pop hl + ld de, sScratch + ld c, 7 * 7 + ld a, [hROMBank] + ld b, a + call Get2bpp + call CloseSRAM + ret + +.Copy: ; e004e + ld c, $10 +.loop_copy + ld a, [hli] + ld [de], a + inc de + dec c + jr nz, .loop_copy + ret + +.Rotate: ; e0057 + ld hl, wd012 + ld e, %10000000 + ld d, 8 +.loop_decompress + push hl + ld hl, wd002 + call .CountSetBit + pop hl + ld a, b + ld [hli], a + push hl + ld hl, wd003 + call .CountSetBit + pop hl + ld a, b + ld [hli], a + srl e + dec d + jr nz, .loop_decompress + ret + +.CountSetBit: ; e0078 + ld b, 0 + ld c, 8 +.loop_count + ld a, [hli] + and e + jr z, .clear + scf + jr .apply + +.clear + and a + +.apply + rr b + inc hl + dec c + jr nz, .loop_count + ret + +overworldmaprect: MACRO +y = 0 +rept \1 +x = \1 * (\2 +- 1) + y +rept \2 + dw OverworldMap tile x +x = x +- \2 +endr +y = y + 1 +endr +endm + +UnownPrinter_OverworldMapRectangle: ; e008b + overworldmaprect 7, 7 -- cgit v1.2.3 From aa44ecfc4ff7e85629825c7068a014794b206463 Mon Sep 17 00:00:00 2001 From: Remy Oukaour Date: Sat, 16 Dec 2017 12:09:16 -0500 Subject: Consolidate duplicate graphics --- event/celebi.asm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'event') diff --git a/event/celebi.asm b/event/celebi.asm index c9be9cb39..ab0a333f2 100755 --- a/event/celebi.asm +++ b/event/celebi.asm @@ -124,12 +124,13 @@ CelebiEvent_SpawnLeaf: ; 49944 ; 49962 SpecialCelebiLeafGFX: ; 49962 -INCBIN "gfx/special/celebi/leaf.2bpp" +INCBIN "gfx/overworld/cut_grass.2bpp" + SpecialCelebiGFX: ; 499a2 -INCBIN "gfx/special/celebi/1.2bpp" -INCBIN "gfx/special/celebi/2.2bpp" -INCBIN "gfx/special/celebi/3.2bpp" -INCBIN "gfx/special/celebi/4.2bpp" +INCBIN "gfx/overworld/celebi/1.2bpp" +INCBIN "gfx/overworld/celebi/2.2bpp" +INCBIN "gfx/overworld/celebi/3.2bpp" +INCBIN "gfx/overworld/celebi/4.2bpp" UpdateCelebiPosition: ; 49aa2 (12:5aa2) -- cgit v1.2.3 From 25a3960646548c40af70f9f59bed544f4ce8d472 Mon Sep 17 00:00:00 2001 From: Remy Oukaour Date: Sat, 16 Dec 2017 19:00:50 -0500 Subject: Move some more main.asm routines into individual files --- event/hidden_items.asm | 51 --------------------------------------- event/itemball.asm | 54 ----------------------------------------- event/misc_scripts.asm | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ event/misc_scripts_2.asm | 51 +++++++++++++++++++++++++++++++++++++++ event/std_collision.asm | 29 ++++++++++++++++++++++ 5 files changed, 142 insertions(+), 105 deletions(-) delete mode 100644 event/hidden_items.asm delete mode 100755 event/itemball.asm create mode 100755 event/misc_scripts.asm create mode 100644 event/misc_scripts_2.asm create mode 100644 event/std_collision.asm (limited to 'event') diff --git a/event/hidden_items.asm b/event/hidden_items.asm deleted file mode 100644 index c4c51d5e6..000000000 --- a/event/hidden_items.asm +++ /dev/null @@ -1,51 +0,0 @@ -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/itemball.asm b/event/itemball.asm deleted file mode 100755 index ed0c6a9e0..000000000 --- a/event/itemball.asm +++ /dev/null @@ -1,54 +0,0 @@ -FindItemInBallScript:: ; 0x122ce - callasm .TryReceiveItem - iffalse .no_room - disappear LAST_TALKED - opentext - writetext .text_found - playsound SFX_ITEM - pause 60 - itemnotify - closetext - end -; 0x122e3 - -.no_room ; 0x122e3 - opentext - writetext .text_found - waitbutton - writetext .text_bag_full - waitbutton - closetext - end -; 0x122ee - -.text_found ; 0x122ee - ; found @ ! - text_jump UnknownText_0x1c0a1c - db "@" -; 0x122f3 - -.text_bag_full ; 0x122f3 - ; But can't carry any more items. - text_jump UnknownText_0x1c0a2c - db "@" -; 0x122f8 - -.TryReceiveItem: ; 122f8 - xor a - ld [ScriptVar], a - ld a, [EngineBuffer1] - ld [wNamedObjectIndexBuffer], a - call GetItemName - ld hl, StringBuffer3 - call CopyName2 - ld a, [EngineBuffer1] - ld [CurItem], a - ld a, [CurFruit] - ld [wItemQuantityChangeBuffer], a - ld hl, NumItems - call ReceiveItem - ret nc - ld a, $1 - ld [ScriptVar], a - ret -; 12324 diff --git a/event/misc_scripts.asm b/event/misc_scripts.asm new file mode 100755 index 000000000..97372a57a --- /dev/null +++ b/event/misc_scripts.asm @@ -0,0 +1,62 @@ +Script_AbortBugContest: ; 0x122c1 + checkflag ENGINE_BUG_CONTEST_TIMER + iffalse .finish + setflag ENGINE_DAILY_BUG_CONTEST + special ContestReturnMons +.finish + end + +FindItemInBallScript:: ; 0x122ce + callasm .TryReceiveItem + iffalse .no_room + disappear LAST_TALKED + opentext + writetext .text_found + playsound SFX_ITEM + pause 60 + itemnotify + closetext + end +; 0x122e3 + +.no_room ; 0x122e3 + opentext + writetext .text_found + waitbutton + writetext .text_bag_full + waitbutton + closetext + end +; 0x122ee + +.text_found ; 0x122ee + ; found @ ! + text_jump UnknownText_0x1c0a1c + db "@" +; 0x122f3 + +.text_bag_full ; 0x122f3 + ; But can't carry any more items. + text_jump UnknownText_0x1c0a2c + db "@" +; 0x122f8 + +.TryReceiveItem: ; 122f8 + xor a + ld [ScriptVar], a + ld a, [EngineBuffer1] + ld [wNamedObjectIndexBuffer], a + call GetItemName + ld hl, StringBuffer3 + call CopyName2 + ld a, [EngineBuffer1] + ld [CurItem], a + ld a, [CurFruit] + ld [wItemQuantityChangeBuffer], a + ld hl, NumItems + call ReceiveItem + ret nc + ld a, $1 + ld [ScriptVar], a + ret +; 12324 diff --git a/event/misc_scripts_2.asm b/event/misc_scripts_2.asm new file mode 100644 index 000000000..c4c51d5e6 --- /dev/null +++ b/event/misc_scripts_2.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/std_collision.asm b/event/std_collision.asm new file mode 100644 index 000000000..17b1e49b2 --- /dev/null +++ b/event/std_collision.asm @@ -0,0 +1,29 @@ +CheckFacingTileForStd:: ; 1365b +; Checks to see if the tile you're facing has a std script associated with it. If so, executes the script and returns carry. + ld a, c + ld de, 3 + ld hl, TileCollisionStdScripts + call IsInArray + jr nc, .notintable + + ld a, jumpstd_command + ld [wJumpStdScriptBuffer], a + inc hl + ld a, [hli] + ld [wJumpStdScriptBuffer + 1], a + ld a, [hli] + ld [wJumpStdScriptBuffer + 2], a + ld a, BANK(Script_JumpStdFromRAM) + ld hl, Script_JumpStdFromRAM + call CallScript + scf + ret + +.notintable + xor a + ret + +INCLUDE "data/collision_stdscripts.asm" + +Script_JumpStdFromRAM: ; 0x1369a + jump wJumpStdScriptBuffer -- cgit v1.2.3 From aa97752efeef1425a0e0a00059f4a44569c917fc Mon Sep 17 00:00:00 2001 From: Remy Oukaour Date: Sat, 23 Dec 2017 00:31:04 -0500 Subject: Move NUM_BUENA_PRIZES to event/buena.asm (still hard-coded) Buena_PrizeMenu has "rept NUM_BUENA_PRIZES", which needs NUM_BUENA_PRIZES to be already defined. BuenaPrizeItems and BuenaPrizeItemsEnd are needed to define NUM_BUENA_PRIZES; but BuenaPrizeItems is defined after Buena_PrizeMenu. I don't see a way to avoid hard-coding its value of 9. Contrast that with the NUM_MOM_ITEMS constants, which are not used as "rept" arguments and so can be defined within their code file. --- event/buena.asm | 2 ++ event/mom_phone.asm | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'event') diff --git a/event/buena.asm b/event/buena.asm index fa54cc3de..2cb3b5a63 100644 --- a/event/buena.asm +++ b/event/buena.asm @@ -288,6 +288,8 @@ Buena_PrizeMenu: ; 8b0e2 dba .prizepoints ; 8b129 +NUM_BUENA_PRIZES EQU 9 ; ((BuenaPrizeItemsEnd - BuenaPrizeItems) / 2) + .indices ; 8b129 db NUM_BUENA_PRIZES x = 1 diff --git a/event/mom_phone.asm b/event/mom_phone.asm index 58ecad02a..aab4abe4b 100755 --- a/event/mom_phone.asm +++ b/event/mom_phone.asm @@ -1,3 +1,6 @@ +NUM_MOM_ITEMS_1 EQUS "((MomItems_1End - MomItems_1) / 8)" +NUM_MOM_ITEMS_2 EQUS "((MomItems_2End - MomItems_2) / 8)" + const_value = 1 const MOM_ITEM const MOM_DOLL @@ -57,7 +60,7 @@ MomTriesToBuySomething:: ; fcfec CheckBalance_MomItem2: ; fd044 ld a, [wWhichMomItem] - cp 10 + cp NUM_MOM_ITEMS_2 jr nc, .nope call GetItemFromMom ld a, [hli] @@ -100,7 +103,7 @@ CheckBalance_MomItem2: ; fd044 .exact call .AddMoney - ld a, 5 + ld a, NUM_MOM_ITEMS_1 call RandomRange inc a ld [wWhichMomItemSet], a @@ -195,7 +198,7 @@ GetItemFromMom: ; fd117 .zero ld a, [wWhichMomItem] - cp 10 ; length of MomItems_2 + cp NUM_MOM_ITEMS_2 jr c, .ok xor a -- cgit v1.2.3