summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile11
-rw-r--r--asm/macros/event.inc124
-rw-r--r--common_syms/link.txt16
-rw-r--r--data/maps/BattleFrontier_BattleDomeBattleRoom/scripts.inc2
-rw-r--r--data/maps/BattleFrontier_BattleTowerBattleRoom/scripts.inc4
-rw-r--r--data/maps/BattleFrontier_BattleTowerLobby/scripts.inc34
-rw-r--r--data/maps/BattleFrontier_BattleTowerMultiBattleRoom/scripts.inc4
-rw-r--r--data/maps/EverGrandeCity_DrakesRoom/scripts.inc2
-rw-r--r--data/maps/LilycoveCity_ContestLobby/scripts.inc38
-rw-r--r--data/maps/LilycoveCity_LilycoveMuseum_2F/scripts.inc10
-rw-r--r--data/maps/UnionRoom/scripts.inc22
-rw-r--r--data/scripts/berry_blender.inc22
-rw-r--r--data/scripts/cable_club.inc96
-rw-r--r--data/specials.inc10
-rw-r--r--gflib/text.h266
-rw-r--r--graphics/contest/results_screen.bin (renamed from graphics/contest/clink_tilemap11.bin)bin24 -> 24 bytes
-rw-r--r--graphics/contest/results_screen.pal (renamed from graphics/contest/misc_2.pal)0
-rw-r--r--graphics/contest/results_screen.png (renamed from graphics/contest/misc_2.png)bin1775 -> 1775 bytes
-rw-r--r--graphics/contest/results_screen_beauty.bin (renamed from graphics/contest/clink_tilemap7.bin)0
-rw-r--r--graphics/contest/results_screen_cool.bin (renamed from graphics/contest/clink_tilemap6.bin)bin20 -> 20 bytes
-rw-r--r--graphics/contest/results_screen_cute.bin (renamed from graphics/contest/clink_tilemap8.bin)0
-rw-r--r--graphics/contest/results_screen_hyper.bin (renamed from graphics/contest/clink_tilemap3.bin)bin40 -> 40 bytes
-rw-r--r--graphics/contest/results_screen_link.bin (renamed from graphics/contest/clink_tilemap5.bin)bin20 -> 20 bytes
-rw-r--r--graphics/contest/results_screen_master.bin (renamed from graphics/contest/clink_tilemap4.bin)bin40 -> 40 bytes
-rw-r--r--graphics/contest/results_screen_normal.bin (renamed from graphics/contest/clink_tilemap1.bin)bin40 -> 40 bytes
-rw-r--r--graphics/contest/results_screen_smart.bin (renamed from graphics/contest/clink_tilemap9.bin)0
-rw-r--r--graphics/contest/results_screen_super.bin (renamed from graphics/contest/clink_tilemap2.bin)bin40 -> 40 bytes
-rw-r--r--graphics/contest/results_screen_tough.bin (renamed from graphics/contest/clink_tilemap10.bin)0
-rw-r--r--graphics/union_room_chat/background.bin (renamed from graphics/link/misc.bin)bin1280 -> 1280 bytes
-rw-r--r--graphics/union_room_chat/background.png (renamed from graphics/link/misc.png)bin513 -> 513 bytes
-rw-r--r--graphics/union_room_chat/border.bin (renamed from graphics/link/link_winedge.bin)bin1280 -> 1280 bytes
-rw-r--r--graphics/union_room_chat/border.png (renamed from graphics/link/link_winedge.png)bin189 -> 189 bytes
-rw-r--r--graphics/union_room_chat/interface.pal (renamed from graphics/interface/unk_palette3.pal)0
-rw-r--r--graphics/union_room_chat/keyboard_cursor.png (renamed from graphics/interface/unk_cursor.png)bin307 -> 307 bytes
-rw-r--r--graphics/union_room_chat/r_button.png (renamed from graphics/interface/unk_rbutton.png)bin188 -> 188 bytes
-rw-r--r--graphics/union_room_chat/r_button_labels.png (renamed from graphics/interface/unk_change_case.png)bin247 -> 247 bytes
-rw-r--r--graphics/union_room_chat/text_entry_arrow.png (renamed from graphics/interface/unk_cursor_arrow.png)bin157 -> 157 bytes
-rw-r--r--graphics/union_room_chat/text_entry_cursor.png (renamed from graphics/interface/unk_dash.png)bin146 -> 146 bytes
-rw-r--r--graphics/union_room_chat/unk_palette1.pal (renamed from graphics/interface/unk_palette1.pal)0
-rw-r--r--graphics/union_room_chat/unk_palette2.pal (renamed from graphics/interface/unk_palette2.pal)0
-rw-r--r--graphics/union_room_chat/window_1.pal (renamed from graphics/link/link1.pal)0
-rw-r--r--graphics/union_room_chat/window_2.pal (renamed from graphics/link/link2.pal)0
-rwxr-xr-xinclude/berry_crush.h2
-rw-r--r--include/cable_club.h16
-rw-r--r--include/confetti_util.h33
-rw-r--r--include/config.h8
-rw-r--r--include/constants/cable_club.h16
-rw-r--r--include/constants/contest.h17
-rw-r--r--include/constants/field_specials.h5
-rw-r--r--include/constants/global.h2
-rw-r--r--include/constants/trainers.h2
-rw-r--r--include/constants/union_room.h78
-rw-r--r--include/contest.h5
-rw-r--r--include/contest_link.h (renamed from include/contest_link_80FC4F4.h)6
-rw-r--r--include/contest_util.h (renamed from include/contest_link_80F57C4.h)10
-rw-r--r--include/dodrio_berry_picking.h2
-rw-r--r--include/event_object_lock.h2
-rw-r--r--include/event_object_movement.h18
-rw-r--r--include/fieldmap.h2
-rw-r--r--include/gba/types.h3
-rw-r--r--include/global.h4
-rw-r--r--include/global.tv.h7
-rw-r--r--include/graphics.h48
-rw-r--r--include/hall_of_fame.h1
-rw-r--r--include/item_menu.h5
-rw-r--r--include/link.h47
-rw-r--r--include/link_rfu.h367
-rw-r--r--include/menu.h2
-rwxr-xr-xinclude/mevent.h4
-rw-r--r--include/mevent2.h2
-rw-r--r--include/mystery_gift.h2
-rw-r--r--include/pokemon.h4
-rw-r--r--include/pokemon_jump.h2
-rw-r--r--include/rom_81520A8.h33
-rw-r--r--include/save.h2
-rw-r--r--include/start_menu.h4
-rw-r--r--include/strings.h12
-rw-r--r--include/union_room.h145
-rw-r--r--include/union_room_battle.h3
-rwxr-xr-xinclude/union_room_chat.h15
-rw-r--r--include/union_room_player_avatar.h18
-rw-r--r--ld_script.txt14
-rw-r--r--sound/direct_sound_data.inc776
-rw-r--r--sound/direct_sound_samples/cries/abra.aif (renamed from sound/direct_sound_samples/cry_abra.aif)bin11660 -> 11660 bytes
-rw-r--r--sound/direct_sound_samples/cries/absol.aif (renamed from sound/direct_sound_samples/cry_absol.aif)bin5256 -> 5256 bytes
-rw-r--r--sound/direct_sound_samples/cries/aerodactyl.aif (renamed from sound/direct_sound_samples/cry_aerodactyl.aif)bin12142 -> 12142 bytes
-rw-r--r--sound/direct_sound_samples/cries/aggron.aif (renamed from sound/direct_sound_samples/cry_aggron.aif)bin12776 -> 12776 bytes
-rw-r--r--sound/direct_sound_samples/cries/aipom.aif (renamed from sound/direct_sound_samples/cry_aipom.aif)bin7058 -> 7058 bytes
-rw-r--r--sound/direct_sound_samples/cries/alakazam.aif (renamed from sound/direct_sound_samples/cry_alakazam.aif)bin15740 -> 15740 bytes
-rw-r--r--sound/direct_sound_samples/cries/altaria.aif (renamed from sound/direct_sound_samples/cry_altaria.aif)bin5564 -> 5564 bytes
-rw-r--r--sound/direct_sound_samples/cries/ampharos.aif (renamed from sound/direct_sound_samples/cry_ampharos.aif)bin8242 -> 8242 bytes
-rw-r--r--sound/direct_sound_samples/cries/anorith.aif (renamed from sound/direct_sound_samples/cry_anorith.aif)bin5862 -> 5862 bytes
-rw-r--r--sound/direct_sound_samples/cries/arbok.aif (renamed from sound/direct_sound_samples/cry_arbok.aif)bin9648 -> 9648 bytes
-rw-r--r--sound/direct_sound_samples/cries/arcanine.aif (renamed from sound/direct_sound_samples/cry_arcanine.aif)bin8602 -> 8602 bytes
-rw-r--r--sound/direct_sound_samples/cries/ariados.aif (renamed from sound/direct_sound_samples/cry_ariados.aif)bin6170 -> 6170 bytes
-rw-r--r--sound/direct_sound_samples/cries/armaldo.aif (renamed from sound/direct_sound_samples/cry_armaldo.aif)bin11380 -> 11380 bytes
-rw-r--r--sound/direct_sound_samples/cries/aron.aif (renamed from sound/direct_sound_samples/cry_aron.aif)bin4600 -> 4600 bytes
-rw-r--r--sound/direct_sound_samples/cries/articuno.aif (renamed from sound/direct_sound_samples/cry_articuno.aif)bin11792 -> 11792 bytes
-rw-r--r--sound/direct_sound_samples/cries/azumarill.aif (renamed from sound/direct_sound_samples/cry_azumarill.aif)bin8452 -> 8452 bytes
-rw-r--r--sound/direct_sound_samples/cries/azurill.aif (renamed from sound/direct_sound_samples/cry_azurill.aif)bin5212 -> 5212 bytes
-rw-r--r--sound/direct_sound_samples/cries/bagon.aif (renamed from sound/direct_sound_samples/cry_bagon.aif)bin3934 -> 3934 bytes
-rw-r--r--sound/direct_sound_samples/cries/baltoy.aif (renamed from sound/direct_sound_samples/cry_baltoy.aif)bin6264 -> 6264 bytes
-rw-r--r--sound/direct_sound_samples/cries/banette.aif (renamed from sound/direct_sound_samples/cry_banette.aif)bin6334 -> 6334 bytes
-rw-r--r--sound/direct_sound_samples/cries/barboach.aif (renamed from sound/direct_sound_samples/cry_barboach.aif)bin4632 -> 4632 bytes
-rw-r--r--sound/direct_sound_samples/cries/bayleef.aif (renamed from sound/direct_sound_samples/cry_bayleef.aif)bin4414 -> 4414 bytes
-rw-r--r--sound/direct_sound_samples/cries/beautifly.aif (renamed from sound/direct_sound_samples/cry_beautifly.aif)bin4128 -> 4128 bytes
-rw-r--r--sound/direct_sound_samples/cries/beedrill.aif (renamed from sound/direct_sound_samples/cry_beedrill.aif)bin9656 -> 9656 bytes
-rw-r--r--sound/direct_sound_samples/cries/beldum.aif (renamed from sound/direct_sound_samples/cry_beldum.aif)bin4828 -> 4828 bytes
-rw-r--r--sound/direct_sound_samples/cries/bellossom.aif (renamed from sound/direct_sound_samples/cry_bellossom.aif)bin7042 -> 7042 bytes
-rw-r--r--sound/direct_sound_samples/cries/bellsprout.aif (renamed from sound/direct_sound_samples/cry_bellsprout.aif)bin3792 -> 3792 bytes
-rw-r--r--sound/direct_sound_samples/cries/blastoise.aif (renamed from sound/direct_sound_samples/cry_blastoise.aif)bin9622 -> 9622 bytes
-rw-r--r--sound/direct_sound_samples/cries/blaziken.aif (renamed from sound/direct_sound_samples/cry_blaziken.aif)bin15690 -> 15690 bytes
-rw-r--r--sound/direct_sound_samples/cries/blissey.aif (renamed from sound/direct_sound_samples/cry_blissey.aif)bin8278 -> 8278 bytes
-rw-r--r--sound/direct_sound_samples/cries/breloom.aif (renamed from sound/direct_sound_samples/cry_breloom.aif)bin6376 -> 6376 bytes
-rw-r--r--sound/direct_sound_samples/cries/bulbasaur.aif (renamed from sound/direct_sound_samples/cry_bulbasaur.aif)bin8266 -> 8266 bytes
-rw-r--r--sound/direct_sound_samples/cries/butterfree.aif (renamed from sound/direct_sound_samples/cry_butterfree.aif)bin5026 -> 5026 bytes
-rw-r--r--sound/direct_sound_samples/cries/cacnea.aif (renamed from sound/direct_sound_samples/cry_cacnea.aif)bin4488 -> 4488 bytes
-rw-r--r--sound/direct_sound_samples/cries/cacturne.aif (renamed from sound/direct_sound_samples/cry_cacturne.aif)bin11310 -> 11310 bytes
-rw-r--r--sound/direct_sound_samples/cries/camerupt.aif (renamed from sound/direct_sound_samples/cry_camerupt.aif)bin11526 -> 11526 bytes
-rw-r--r--sound/direct_sound_samples/cries/carvanha.aif (renamed from sound/direct_sound_samples/cry_carvanha.aif)bin5048 -> 5048 bytes
-rw-r--r--sound/direct_sound_samples/cries/cascoon.aif (renamed from sound/direct_sound_samples/cry_cascoon.aif)bin8126 -> 8126 bytes
-rw-r--r--sound/direct_sound_samples/cries/castform.aif (renamed from sound/direct_sound_samples/cry_castform.aif)bin6302 -> 6302 bytes
-rw-r--r--sound/direct_sound_samples/cries/caterpie.aif (renamed from sound/direct_sound_samples/cry_caterpie.aif)bin4192 -> 4192 bytes
-rw-r--r--sound/direct_sound_samples/cries/celebi.aif (renamed from sound/direct_sound_samples/cry_celebi.aif)bin7230 -> 7230 bytes
-rw-r--r--sound/direct_sound_samples/cries/chansey.aif (renamed from sound/direct_sound_samples/cry_chansey.aif)bin7390 -> 7390 bytes
-rw-r--r--sound/direct_sound_samples/cries/charizard.aif (renamed from sound/direct_sound_samples/cry_charizard.aif)bin9622 -> 9622 bytes
-rw-r--r--sound/direct_sound_samples/cries/charmander.aif (renamed from sound/direct_sound_samples/cry_charmander.aif)bin7216 -> 7216 bytes
-rw-r--r--sound/direct_sound_samples/cries/charmeleon.aif (renamed from sound/direct_sound_samples/cry_charmeleon.aif)bin7248 -> 7248 bytes
-rw-r--r--sound/direct_sound_samples/cries/chikorita.aif (renamed from sound/direct_sound_samples/cry_chikorita.aif)bin2654 -> 2654 bytes
-rw-r--r--sound/direct_sound_samples/cries/chimecho.aif (renamed from sound/direct_sound_samples/cry_chimecho.aif)bin5040 -> 5040 bytes
-rw-r--r--sound/direct_sound_samples/cries/chinchou.aif (renamed from sound/direct_sound_samples/cry_chinchou.aif)bin6346 -> 6346 bytes
-rw-r--r--sound/direct_sound_samples/cries/clamperl.aif (renamed from sound/direct_sound_samples/cry_clamperl.aif)bin9142 -> 9142 bytes
-rw-r--r--sound/direct_sound_samples/cries/claydol.aif (renamed from sound/direct_sound_samples/cry_claydol.aif)bin9668 -> 9668 bytes
-rw-r--r--sound/direct_sound_samples/cries/clefable.aif (renamed from sound/direct_sound_samples/cry_clefable.aif)bin5294 -> 5294 bytes
-rw-r--r--sound/direct_sound_samples/cries/clefairy.aif (renamed from sound/direct_sound_samples/cry_clefairy.aif)bin4234 -> 4234 bytes
-rw-r--r--sound/direct_sound_samples/cries/cleffa.aif (renamed from sound/direct_sound_samples/cry_cleffa.aif)bin2992 -> 2992 bytes
-rw-r--r--sound/direct_sound_samples/cries/cloyster.aif (renamed from sound/direct_sound_samples/cry_cloyster.aif)bin10354 -> 10354 bytes
-rw-r--r--sound/direct_sound_samples/cries/combusken.aif (renamed from sound/direct_sound_samples/cry_combusken.aif)bin14360 -> 14360 bytes
-rw-r--r--sound/direct_sound_samples/cries/corphish.aif (renamed from sound/direct_sound_samples/cry_corphish.aif)bin6010 -> 6010 bytes
-rw-r--r--sound/direct_sound_samples/cries/corsola.aif (renamed from sound/direct_sound_samples/cry_corsola.aif)bin6440 -> 6440 bytes
-rw-r--r--sound/direct_sound_samples/cries/cradily.aif (renamed from sound/direct_sound_samples/cry_cradily.aif)bin14542 -> 14542 bytes
-rw-r--r--sound/direct_sound_samples/cries/crawdaunt.aif (renamed from sound/direct_sound_samples/cry_crawdaunt.aif)bin12316 -> 12316 bytes
-rw-r--r--sound/direct_sound_samples/cries/crobat.aif (renamed from sound/direct_sound_samples/cry_crobat.aif)bin11562 -> 11562 bytes
-rw-r--r--sound/direct_sound_samples/cries/croconaw.aif (renamed from sound/direct_sound_samples/cry_croconaw.aif)bin10096 -> 10096 bytes
-rw-r--r--sound/direct_sound_samples/cries/cubone.aif (renamed from sound/direct_sound_samples/cry_cubone.aif)bin7558 -> 7558 bytes
-rw-r--r--sound/direct_sound_samples/cries/cyndaquil.aif (renamed from sound/direct_sound_samples/cry_cyndaquil.aif)bin3528 -> 3528 bytes
-rw-r--r--sound/direct_sound_samples/cries/delcatty.aif (renamed from sound/direct_sound_samples/cry_delcatty.aif)bin10518 -> 10518 bytes
-rw-r--r--sound/direct_sound_samples/cries/delibird.aif (renamed from sound/direct_sound_samples/cry_delibird.aif)bin8094 -> 8094 bytes
-rw-r--r--sound/direct_sound_samples/cries/deoxys.aif (renamed from sound/direct_sound_samples/cry_deoxys.aif)bin10388 -> 10388 bytes
-rw-r--r--sound/direct_sound_samples/cries/dewgong.aif (renamed from sound/direct_sound_samples/cry_dewgong.aif)bin10546 -> 10546 bytes
-rw-r--r--sound/direct_sound_samples/cries/diglett.aif (renamed from sound/direct_sound_samples/cry_diglett.aif)bin9698 -> 9698 bytes
-rw-r--r--sound/direct_sound_samples/cries/ditto.aif (renamed from sound/direct_sound_samples/cry_ditto.aif)bin5566 -> 5566 bytes
-rw-r--r--sound/direct_sound_samples/cries/dodrio.aif (renamed from sound/direct_sound_samples/cry_dodrio.aif)bin9712 -> 9712 bytes
-rw-r--r--sound/direct_sound_samples/cries/doduo.aif (renamed from sound/direct_sound_samples/cry_doduo.aif)bin9616 -> 9616 bytes
-rw-r--r--sound/direct_sound_samples/cries/donphan.aif (renamed from sound/direct_sound_samples/cry_donphan.aif)bin8554 -> 8554 bytes
-rw-r--r--sound/direct_sound_samples/cries/dragonair.aif (renamed from sound/direct_sound_samples/cry_dragonair.aif)bin8318 -> 8318 bytes
-rw-r--r--sound/direct_sound_samples/cries/dragonite.aif (renamed from sound/direct_sound_samples/cry_dragonite.aif)bin9502 -> 9502 bytes
-rw-r--r--sound/direct_sound_samples/cries/dratini.aif (renamed from sound/direct_sound_samples/cry_dratini.aif)bin5812 -> 5812 bytes
-rw-r--r--sound/direct_sound_samples/cries/drowzee.aif (renamed from sound/direct_sound_samples/cry_drowzee.aif)bin14494 -> 14494 bytes
-rw-r--r--sound/direct_sound_samples/cries/dugtrio.aif (renamed from sound/direct_sound_samples/cry_dugtrio.aif)bin9686 -> 9686 bytes
-rw-r--r--sound/direct_sound_samples/cries/dunsparce.aif (renamed from sound/direct_sound_samples/cry_dunsparce.aif)bin7926 -> 7926 bytes
-rw-r--r--sound/direct_sound_samples/cries/dusclops.aif (renamed from sound/direct_sound_samples/cry_dusclops.aif)bin6858 -> 6858 bytes
-rw-r--r--sound/direct_sound_samples/cries/duskull.aif (renamed from sound/direct_sound_samples/cry_duskull.aif)bin5310 -> 5310 bytes
-rw-r--r--sound/direct_sound_samples/cries/dustox.aif (renamed from sound/direct_sound_samples/cry_dustox.aif)bin6338 -> 6338 bytes
-rw-r--r--sound/direct_sound_samples/cries/eevee.aif (renamed from sound/direct_sound_samples/cry_eevee.aif)bin7104 -> 7104 bytes
-rw-r--r--sound/direct_sound_samples/cries/ekans.aif (renamed from sound/direct_sound_samples/cry_ekans.aif)bin9626 -> 9626 bytes
-rw-r--r--sound/direct_sound_samples/cries/electabuzz.aif (renamed from sound/direct_sound_samples/cry_electabuzz.aif)bin15380 -> 15380 bytes
-rw-r--r--sound/direct_sound_samples/cries/electrike.aif (renamed from sound/direct_sound_samples/cry_electrike.aif)bin6186 -> 6186 bytes
-rw-r--r--sound/direct_sound_samples/cries/electrode.aif (renamed from sound/direct_sound_samples/cry_electrode.aif)bin12564 -> 12564 bytes
-rw-r--r--sound/direct_sound_samples/cries/elekid.aif (renamed from sound/direct_sound_samples/cry_elekid.aif)bin5284 -> 5284 bytes
-rw-r--r--sound/direct_sound_samples/cries/entei.aif (renamed from sound/direct_sound_samples/cry_entei.aif)bin10198 -> 10198 bytes
-rw-r--r--sound/direct_sound_samples/cries/espeon.aif (renamed from sound/direct_sound_samples/cry_espeon.aif)bin9828 -> 9828 bytes
-rw-r--r--sound/direct_sound_samples/cries/exeggcute.aif (renamed from sound/direct_sound_samples/cry_exeggcute.aif)bin9416 -> 9416 bytes
-rw-r--r--sound/direct_sound_samples/cries/exeggutor.aif (renamed from sound/direct_sound_samples/cry_exeggutor.aif)bin15880 -> 15880 bytes
-rw-r--r--sound/direct_sound_samples/cries/exploud.aif (renamed from sound/direct_sound_samples/cry_exploud.aif)bin14086 -> 14086 bytes
-rw-r--r--sound/direct_sound_samples/cries/farfetchd.aif (renamed from sound/direct_sound_samples/cry_farfetchd.aif)bin3766 -> 3766 bytes
-rw-r--r--sound/direct_sound_samples/cries/fearow.aif (renamed from sound/direct_sound_samples/cry_fearow.aif)bin8602 -> 8602 bytes
-rw-r--r--sound/direct_sound_samples/cries/feebas.aif (renamed from sound/direct_sound_samples/cry_feebas.aif)bin3932 -> 3932 bytes
-rw-r--r--sound/direct_sound_samples/cries/feraligatr.aif (renamed from sound/direct_sound_samples/cry_feraligatr.aif)bin12712 -> 12712 bytes
-rw-r--r--sound/direct_sound_samples/cries/flaaffy.aif (renamed from sound/direct_sound_samples/cry_flaaffy.aif)bin6854 -> 6854 bytes
-rw-r--r--sound/direct_sound_samples/cries/flareon.aif (renamed from sound/direct_sound_samples/cry_flareon.aif)bin7748 -> 7748 bytes
-rw-r--r--sound/direct_sound_samples/cries/flygon.aif (renamed from sound/direct_sound_samples/cry_flygon.aif)bin12974 -> 12974 bytes
-rw-r--r--sound/direct_sound_samples/cries/forretress.aif (renamed from sound/direct_sound_samples/cry_forretress.aif)bin9990 -> 9990 bytes
-rw-r--r--sound/direct_sound_samples/cries/furret.aif (renamed from sound/direct_sound_samples/cry_furret.aif)bin3168 -> 3168 bytes
-rw-r--r--sound/direct_sound_samples/cries/gardevoir.aif (renamed from sound/direct_sound_samples/cry_gardevoir.aif)bin12154 -> 12154 bytes
-rw-r--r--sound/direct_sound_samples/cries/gastly.aif (renamed from sound/direct_sound_samples/cry_gastly.aif)bin11620 -> 11620 bytes
-rw-r--r--sound/direct_sound_samples/cries/gengar.aif (renamed from sound/direct_sound_samples/cry_gengar.aif)bin7372 -> 7372 bytes
-rw-r--r--sound/direct_sound_samples/cries/geodude.aif (renamed from sound/direct_sound_samples/cry_geodude.aif)bin11816 -> 11816 bytes
-rw-r--r--sound/direct_sound_samples/cries/girafarig.aif (renamed from sound/direct_sound_samples/cry_girafarig.aif)bin7346 -> 7346 bytes
-rw-r--r--sound/direct_sound_samples/cries/glalie.aif (renamed from sound/direct_sound_samples/cry_glalie.aif)bin10420 -> 10420 bytes
-rw-r--r--sound/direct_sound_samples/cries/gligar.aif (renamed from sound/direct_sound_samples/cry_gligar.aif)bin6068 -> 6068 bytes
-rw-r--r--sound/direct_sound_samples/cries/gloom.aif (renamed from sound/direct_sound_samples/cry_gloom.aif)bin6246 -> 6246 bytes
-rw-r--r--sound/direct_sound_samples/cries/golbat.aif (renamed from sound/direct_sound_samples/cry_golbat.aif)bin9674 -> 9674 bytes
-rw-r--r--sound/direct_sound_samples/cries/goldeen.aif (renamed from sound/direct_sound_samples/cry_goldeen.aif)bin4936 -> 4936 bytes
-rw-r--r--sound/direct_sound_samples/cries/golduck.aif (renamed from sound/direct_sound_samples/cry_golduck.aif)bin5646 -> 5646 bytes
-rw-r--r--sound/direct_sound_samples/cries/golem.aif (renamed from sound/direct_sound_samples/cry_golem.aif)bin7080 -> 7080 bytes
-rw-r--r--sound/direct_sound_samples/cries/gorebyss.aif (renamed from sound/direct_sound_samples/cry_gorebyss.aif)bin11176 -> 11176 bytes
-rw-r--r--sound/direct_sound_samples/cries/granbull.aif (renamed from sound/direct_sound_samples/cry_granbull.aif)bin11782 -> 11782 bytes
-rw-r--r--sound/direct_sound_samples/cries/graveler.aif (renamed from sound/direct_sound_samples/cry_graveler.aif)bin13900 -> 13900 bytes
-rw-r--r--sound/direct_sound_samples/cries/grimer.aif (renamed from sound/direct_sound_samples/cry_grimer.aif)bin5274 -> 5274 bytes
-rw-r--r--sound/direct_sound_samples/cries/groudon.aif (renamed from sound/direct_sound_samples/cry_groudon.aif)bin18438 -> 18438 bytes
-rw-r--r--sound/direct_sound_samples/cries/grovyle.aif (renamed from sound/direct_sound_samples/cry_grovyle.aif)bin10198 -> 10198 bytes
-rw-r--r--sound/direct_sound_samples/cries/growlithe.aif (renamed from sound/direct_sound_samples/cry_growlithe.aif)bin6696 -> 6696 bytes
-rw-r--r--sound/direct_sound_samples/cries/grumpig.aif (renamed from sound/direct_sound_samples/cry_grumpig.aif)bin6318 -> 6318 bytes
-rw-r--r--sound/direct_sound_samples/cries/gulpin.aif (renamed from sound/direct_sound_samples/cry_gulpin.aif)bin4028 -> 4028 bytes
-rw-r--r--sound/direct_sound_samples/cries/gyarados.aif (renamed from sound/direct_sound_samples/cry_gyarados.aif)bin10078 -> 10078 bytes
-rw-r--r--sound/direct_sound_samples/cries/hariyama.aif (renamed from sound/direct_sound_samples/cry_hariyama.aif)bin8348 -> 8348 bytes
-rw-r--r--sound/direct_sound_samples/cries/haunter.aif (renamed from sound/direct_sound_samples/cry_haunter.aif)bin11714 -> 11714 bytes
-rw-r--r--sound/direct_sound_samples/cries/heracross.aif (renamed from sound/direct_sound_samples/cry_heracross.aif)bin9144 -> 9144 bytes
-rw-r--r--sound/direct_sound_samples/cries/hitmonchan.aif (renamed from sound/direct_sound_samples/cry_hitmonchan.aif)bin8906 -> 8906 bytes
-rw-r--r--sound/direct_sound_samples/cries/hitmonlee.aif (renamed from sound/direct_sound_samples/cry_hitmonlee.aif)bin9318 -> 9318 bytes
-rw-r--r--sound/direct_sound_samples/cries/hitmontop.aif (renamed from sound/direct_sound_samples/cry_hitmontop.aif)bin6936 -> 6936 bytes
-rw-r--r--sound/direct_sound_samples/cries/ho_oh.aif (renamed from sound/direct_sound_samples/cry_ho_oh.aif)bin11260 -> 11260 bytes
-rw-r--r--sound/direct_sound_samples/cries/hoothoot.aif (renamed from sound/direct_sound_samples/cry_hoothoot.aif)bin5458 -> 5458 bytes
-rw-r--r--sound/direct_sound_samples/cries/hoppip.aif (renamed from sound/direct_sound_samples/cry_hoppip.aif)bin4226 -> 4226 bytes
-rw-r--r--sound/direct_sound_samples/cries/horsea.aif (renamed from sound/direct_sound_samples/cry_horsea.aif)bin4754 -> 4754 bytes
-rw-r--r--sound/direct_sound_samples/cries/houndoom.aif (renamed from sound/direct_sound_samples/cry_houndoom.aif)bin9820 -> 9820 bytes
-rw-r--r--sound/direct_sound_samples/cries/houndour.aif (renamed from sound/direct_sound_samples/cry_houndour.aif)bin6332 -> 6332 bytes
-rw-r--r--sound/direct_sound_samples/cries/huntail.aif (renamed from sound/direct_sound_samples/cry_huntail.aif)bin7944 -> 7944 bytes
-rw-r--r--sound/direct_sound_samples/cries/hypno.aif (renamed from sound/direct_sound_samples/cry_hypno.aif)bin14450 -> 14450 bytes
-rw-r--r--sound/direct_sound_samples/cries/igglybuff.aif (renamed from sound/direct_sound_samples/cry_igglybuff.aif)bin3518 -> 3518 bytes
-rw-r--r--sound/direct_sound_samples/cries/illumise.aif (renamed from sound/direct_sound_samples/cry_illumise.aif)bin8536 -> 8536 bytes
-rw-r--r--sound/direct_sound_samples/cries/ivysaur.aif (renamed from sound/direct_sound_samples/cry_ivysaur.aif)bin8270 -> 8270 bytes
-rw-r--r--sound/direct_sound_samples/cries/jigglypuff.aif (renamed from sound/direct_sound_samples/cry_jigglypuff.aif)bin2720 -> 2720 bytes
-rw-r--r--sound/direct_sound_samples/cries/jirachi.aif (renamed from sound/direct_sound_samples/cry_jirachi.aif)bin6758 -> 6758 bytes
-rw-r--r--sound/direct_sound_samples/cries/jolteon.aif (renamed from sound/direct_sound_samples/cry_jolteon.aif)bin7904 -> 7904 bytes
-rw-r--r--sound/direct_sound_samples/cries/jumpluff.aif (renamed from sound/direct_sound_samples/cry_jumpluff.aif)bin8106 -> 8106 bytes
-rw-r--r--sound/direct_sound_samples/cries/jynx.aif (renamed from sound/direct_sound_samples/cry_jynx.aif)bin23606 -> 23606 bytes
-rw-r--r--sound/direct_sound_samples/cries/kabuto.aif (renamed from sound/direct_sound_samples/cry_kabuto.aif)bin6170 -> 6170 bytes
-rw-r--r--sound/direct_sound_samples/cries/kabutops.aif (renamed from sound/direct_sound_samples/cry_kabutops.aif)bin6867 -> 6867 bytes
-rw-r--r--sound/direct_sound_samples/cries/kadabra.aif (renamed from sound/direct_sound_samples/cry_kadabra.aif)bin13408 -> 13408 bytes
-rw-r--r--sound/direct_sound_samples/cries/kakuna.aif (renamed from sound/direct_sound_samples/cry_kakuna.aif)bin9104 -> 9104 bytes
-rw-r--r--sound/direct_sound_samples/cries/kangaskhan.aif (renamed from sound/direct_sound_samples/cry_kangaskhan.aif)bin9334 -> 9334 bytes
-rw-r--r--sound/direct_sound_samples/cries/kecleon.aif (renamed from sound/direct_sound_samples/cry_kecleon.aif)bin4202 -> 4202 bytes
-rw-r--r--sound/direct_sound_samples/cries/kingdra.aif (renamed from sound/direct_sound_samples/cry_kingdra.aif)bin6922 -> 6922 bytes
-rw-r--r--sound/direct_sound_samples/cries/kingler.aif (renamed from sound/direct_sound_samples/cry_kingler.aif)bin12132 -> 12132 bytes
-rw-r--r--sound/direct_sound_samples/cries/kirlia.aif (renamed from sound/direct_sound_samples/cry_kirlia.aif)bin6100 -> 6100 bytes
-rw-r--r--sound/direct_sound_samples/cries/koffing.aif (renamed from sound/direct_sound_samples/cry_koffing.aif)bin10154 -> 10154 bytes
-rw-r--r--sound/direct_sound_samples/cries/krabby.aif (renamed from sound/direct_sound_samples/cry_krabby.aif)bin12112 -> 12112 bytes
-rw-r--r--sound/direct_sound_samples/cries/kyogre.aif (renamed from sound/direct_sound_samples/cry_kyogre.aif)bin17782 -> 17782 bytes
-rw-r--r--sound/direct_sound_samples/cries/lairon.aif (renamed from sound/direct_sound_samples/cry_lairon.aif)bin10392 -> 10392 bytes
-rw-r--r--sound/direct_sound_samples/cries/lanturn.aif (renamed from sound/direct_sound_samples/cry_lanturn.aif)bin5282 -> 5282 bytes
-rw-r--r--sound/direct_sound_samples/cries/lapras.aif (renamed from sound/direct_sound_samples/cry_lapras.aif)bin7408 -> 7408 bytes
-rw-r--r--sound/direct_sound_samples/cries/larvitar.aif (renamed from sound/direct_sound_samples/cry_larvitar.aif)bin6350 -> 6350 bytes
-rw-r--r--sound/direct_sound_samples/cries/latias.aif (renamed from sound/direct_sound_samples/cry_latias.aif)bin6098 -> 6098 bytes
-rw-r--r--sound/direct_sound_samples/cries/latios.aif (renamed from sound/direct_sound_samples/cry_latios.aif)bin10958 -> 10958 bytes
-rw-r--r--sound/direct_sound_samples/cries/ledian.aif (renamed from sound/direct_sound_samples/cry_ledian.aif)bin4214 -> 4214 bytes
-rw-r--r--sound/direct_sound_samples/cries/ledyba.aif (renamed from sound/direct_sound_samples/cry_ledyba.aif)bin3506 -> 3506 bytes
-rw-r--r--sound/direct_sound_samples/cries/lickitung.aif (renamed from sound/direct_sound_samples/cry_lickitung.aif)bin7571 -> 7571 bytes
-rw-r--r--sound/direct_sound_samples/cries/lileep.aif (renamed from sound/direct_sound_samples/cry_lileep.aif)bin4838 -> 4838 bytes
-rw-r--r--sound/direct_sound_samples/cries/linoone.aif (renamed from sound/direct_sound_samples/cry_linoone.aif)bin15248 -> 15248 bytes
-rw-r--r--sound/direct_sound_samples/cries/lombre.aif (renamed from sound/direct_sound_samples/cry_lombre.aif)bin7282 -> 7282 bytes
-rw-r--r--sound/direct_sound_samples/cries/lotad.aif (renamed from sound/direct_sound_samples/cry_lotad.aif)bin2232 -> 2232 bytes
-rw-r--r--sound/direct_sound_samples/cries/loudred.aif (renamed from sound/direct_sound_samples/cry_loudred.aif)bin6582 -> 6582 bytes
-rw-r--r--sound/direct_sound_samples/cries/ludicolo.aif (renamed from sound/direct_sound_samples/cry_ludicolo.aif)bin8398 -> 8398 bytes
-rw-r--r--sound/direct_sound_samples/cries/lugia.aif (renamed from sound/direct_sound_samples/cry_lugia.aif)bin18900 -> 18900 bytes
-rw-r--r--sound/direct_sound_samples/cries/lunatone.aif (renamed from sound/direct_sound_samples/cry_lunatone.aif)bin11956 -> 11956 bytes
-rw-r--r--sound/direct_sound_samples/cries/luvdisc.aif (renamed from sound/direct_sound_samples/cry_luvdisc.aif)bin2456 -> 2456 bytes
-rw-r--r--sound/direct_sound_samples/cries/machamp.aif (renamed from sound/direct_sound_samples/cry_machamp.aif)bin8256 -> 8256 bytes
-rw-r--r--sound/direct_sound_samples/cries/machoke.aif (renamed from sound/direct_sound_samples/cry_machoke.aif)bin6782 -> 6782 bytes
-rw-r--r--sound/direct_sound_samples/cries/machop.aif (renamed from sound/direct_sound_samples/cry_machop.aif)bin6696 -> 6696 bytes
-rw-r--r--sound/direct_sound_samples/cries/magby.aif (renamed from sound/direct_sound_samples/cry_magby.aif)bin7218 -> 7218 bytes
-rw-r--r--sound/direct_sound_samples/cries/magcargo.aif (renamed from sound/direct_sound_samples/cry_magcargo.aif)bin10486 -> 10486 bytes
-rw-r--r--sound/direct_sound_samples/cries/magikarp.aif (renamed from sound/direct_sound_samples/cry_magikarp.aif)bin9492 -> 9492 bytes
-rw-r--r--sound/direct_sound_samples/cries/magmar.aif (renamed from sound/direct_sound_samples/cry_magmar.aif)bin7738 -> 7738 bytes
-rw-r--r--sound/direct_sound_samples/cries/magnemite.aif (renamed from sound/direct_sound_samples/cry_magnemite.aif)bin9610 -> 9610 bytes
-rw-r--r--sound/direct_sound_samples/cries/magneton.aif (renamed from sound/direct_sound_samples/cry_magneton.aif)bin11914 -> 11914 bytes
-rw-r--r--sound/direct_sound_samples/cries/makuhita.aif (renamed from sound/direct_sound_samples/cry_makuhita.aif)bin3704 -> 3704 bytes
-rw-r--r--sound/direct_sound_samples/cries/manectric.aif (renamed from sound/direct_sound_samples/cry_manectric.aif)bin10492 -> 10492 bytes
-rw-r--r--sound/direct_sound_samples/cries/mankey.aif (renamed from sound/direct_sound_samples/cry_mankey.aif)bin8178 -> 8178 bytes
-rw-r--r--sound/direct_sound_samples/cries/mantine.aif (renamed from sound/direct_sound_samples/cry_mantine.aif)bin7884 -> 7884 bytes
-rw-r--r--sound/direct_sound_samples/cries/mareep.aif (renamed from sound/direct_sound_samples/cry_mareep.aif)bin3694 -> 3694 bytes
-rw-r--r--sound/direct_sound_samples/cries/marill.aif (renamed from sound/direct_sound_samples/cry_marill.aif)bin6538 -> 6538 bytes
-rw-r--r--sound/direct_sound_samples/cries/marowak.aif (renamed from sound/direct_sound_samples/cry_marowak.aif)bin7216 -> 7216 bytes
-rw-r--r--sound/direct_sound_samples/cries/marshtomp.aif (renamed from sound/direct_sound_samples/cry_marshtomp.aif)bin8498 -> 8498 bytes
-rw-r--r--sound/direct_sound_samples/cries/masquerain.aif (renamed from sound/direct_sound_samples/cry_masquerain.aif)bin9830 -> 9830 bytes
-rw-r--r--sound/direct_sound_samples/cries/mawile.aif (renamed from sound/direct_sound_samples/cry_mawile.aif)bin5756 -> 5756 bytes
-rw-r--r--sound/direct_sound_samples/cries/medicham.aif (renamed from sound/direct_sound_samples/cry_medicham.aif)bin8246 -> 8246 bytes
-rw-r--r--sound/direct_sound_samples/cries/meditite.aif (renamed from sound/direct_sound_samples/cry_meditite.aif)bin4078 -> 4078 bytes
-rw-r--r--sound/direct_sound_samples/cries/meganium.aif (renamed from sound/direct_sound_samples/cry_meganium.aif)bin8100 -> 8100 bytes
-rw-r--r--sound/direct_sound_samples/cries/meowth.aif (renamed from sound/direct_sound_samples/cry_meowth.aif)bin4796 -> 4796 bytes
-rw-r--r--sound/direct_sound_samples/cries/metagross.aif (renamed from sound/direct_sound_samples/cry_metagross.aif)bin19644 -> 19644 bytes
-rw-r--r--sound/direct_sound_samples/cries/metang.aif (renamed from sound/direct_sound_samples/cry_metang.aif)bin9398 -> 9398 bytes
-rw-r--r--sound/direct_sound_samples/cries/metapod.aif (renamed from sound/direct_sound_samples/cry_metapod.aif)bin11622 -> 11622 bytes
-rw-r--r--sound/direct_sound_samples/cries/mew.aif (renamed from sound/direct_sound_samples/cry_mew.aif)bin15146 -> 15146 bytes
-rw-r--r--sound/direct_sound_samples/cries/mewtwo.aif (renamed from sound/direct_sound_samples/cry_mewtwo.aif)bin15144 -> 15144 bytes
-rw-r--r--sound/direct_sound_samples/cries/mightyena.aif (renamed from sound/direct_sound_samples/cry_mightyena.aif)bin9748 -> 9748 bytes
-rw-r--r--sound/direct_sound_samples/cries/milotic.aif (renamed from sound/direct_sound_samples/cry_milotic.aif)bin19542 -> 19542 bytes
-rw-r--r--sound/direct_sound_samples/cries/miltank.aif (renamed from sound/direct_sound_samples/cry_miltank.aif)bin7424 -> 7424 bytes
-rw-r--r--sound/direct_sound_samples/cries/minun.aif (renamed from sound/direct_sound_samples/cry_minun.aif)bin8004 -> 8004 bytes
-rw-r--r--sound/direct_sound_samples/cries/misdreavus.aif (renamed from sound/direct_sound_samples/cry_misdreavus.aif)bin5816 -> 5816 bytes
-rw-r--r--sound/direct_sound_samples/cries/moltres.aif (renamed from sound/direct_sound_samples/cry_moltres.aif)bin11796 -> 11796 bytes
-rw-r--r--sound/direct_sound_samples/cries/mr_mime.aif (renamed from sound/direct_sound_samples/cry_mr_mime.aif)bin9446 -> 9446 bytes
-rw-r--r--sound/direct_sound_samples/cries/mudkip.aif (renamed from sound/direct_sound_samples/cry_mudkip.aif)bin3776 -> 3776 bytes
-rw-r--r--sound/direct_sound_samples/cries/muk.aif (renamed from sound/direct_sound_samples/cry_muk.aif)bin7374 -> 7374 bytes
-rw-r--r--sound/direct_sound_samples/cries/murkrow.aif (renamed from sound/direct_sound_samples/cry_murkrow.aif)bin8370 -> 8370 bytes
-rw-r--r--sound/direct_sound_samples/cries/natu.aif (renamed from sound/direct_sound_samples/cry_natu.aif)bin5294 -> 5294 bytes
-rw-r--r--sound/direct_sound_samples/cries/nidoking.aif (renamed from sound/direct_sound_samples/cry_nidoking.aif)bin12176 -> 12176 bytes
-rw-r--r--sound/direct_sound_samples/cries/nidoqueen.aif (renamed from sound/direct_sound_samples/cry_nidoqueen.aif)bin8424 -> 8424 bytes
-rw-r--r--sound/direct_sound_samples/cries/nidoran_f.aif (renamed from sound/direct_sound_samples/cry_nidoran_f.aif)bin4858 -> 4858 bytes
-rw-r--r--sound/direct_sound_samples/cries/nidoran_m.aif (renamed from sound/direct_sound_samples/cry_nidoran_m.aif)bin5216 -> 5216 bytes
-rw-r--r--sound/direct_sound_samples/cries/nidorina.aif (renamed from sound/direct_sound_samples/cry_nidorina.aif)bin6394 -> 6394 bytes
-rw-r--r--sound/direct_sound_samples/cries/nidorino.aif (renamed from sound/direct_sound_samples/cry_nidorino.aif)bin6042 -> 6042 bytes
-rw-r--r--sound/direct_sound_samples/cries/nincada.aif (renamed from sound/direct_sound_samples/cry_nincada.aif)bin3244 -> 3244 bytes
-rw-r--r--sound/direct_sound_samples/cries/ninetales.aif (renamed from sound/direct_sound_samples/cry_ninetales.aif)bin12174 -> 12174 bytes
-rw-r--r--sound/direct_sound_samples/cries/ninjask.aif (renamed from sound/direct_sound_samples/cry_ninjask.aif)bin6084 -> 6084 bytes
-rw-r--r--sound/direct_sound_samples/cries/noctowl.aif (renamed from sound/direct_sound_samples/cry_noctowl.aif)bin10564 -> 10564 bytes
-rw-r--r--sound/direct_sound_samples/cries/nosepass.aif (renamed from sound/direct_sound_samples/cry_nosepass.aif)bin6696 -> 6696 bytes
-rw-r--r--sound/direct_sound_samples/cries/numel.aif (renamed from sound/direct_sound_samples/cry_numel.aif)bin4664 -> 4664 bytes
-rw-r--r--sound/direct_sound_samples/cries/nuzleaf.aif (renamed from sound/direct_sound_samples/cry_nuzleaf.aif)bin5712 -> 5712 bytes
-rw-r--r--sound/direct_sound_samples/cries/octillery.aif (renamed from sound/direct_sound_samples/cry_octillery.aif)bin13084 -> 13084 bytes
-rw-r--r--sound/direct_sound_samples/cries/oddish.aif (renamed from sound/direct_sound_samples/cry_oddish.aif)bin7298 -> 7298 bytes
-rw-r--r--sound/direct_sound_samples/cries/omanyte.aif (renamed from sound/direct_sound_samples/cry_omanyte.aif)bin6672 -> 6672 bytes
-rw-r--r--sound/direct_sound_samples/cries/omastar.aif (renamed from sound/direct_sound_samples/cry_omastar.aif)bin6666 -> 6666 bytes
-rw-r--r--sound/direct_sound_samples/cries/onix.aif (renamed from sound/direct_sound_samples/cry_onix.aif)bin12340 -> 12340 bytes
-rw-r--r--sound/direct_sound_samples/cries/paras.aif (renamed from sound/direct_sound_samples/cry_paras.aif)bin13924 -> 13924 bytes
-rw-r--r--sound/direct_sound_samples/cries/parasect.aif (renamed from sound/direct_sound_samples/cry_parasect.aif)bin15140 -> 15140 bytes
-rw-r--r--sound/direct_sound_samples/cries/pelipper.aif (renamed from sound/direct_sound_samples/cry_pelipper.aif)bin5894 -> 5894 bytes
-rw-r--r--sound/direct_sound_samples/cries/persian.aif (renamed from sound/direct_sound_samples/cry_persian.aif)bin9412 -> 9412 bytes
-rw-r--r--sound/direct_sound_samples/cries/phanpy.aif (renamed from sound/direct_sound_samples/cry_phanpy.aif)bin5664 -> 5664 bytes
-rw-r--r--sound/direct_sound_samples/cries/pichu.aif (renamed from sound/direct_sound_samples/cry_pichu.aif)bin3684 -> 3684 bytes
-rw-r--r--sound/direct_sound_samples/cries/pidgeot.aif (renamed from sound/direct_sound_samples/cry_pidgeot.aif)bin8590 -> 8590 bytes
-rw-r--r--sound/direct_sound_samples/cries/pidgeotto.aif (renamed from sound/direct_sound_samples/cry_pidgeotto.aif)bin7512 -> 7512 bytes
-rw-r--r--sound/direct_sound_samples/cries/pidgey.aif (renamed from sound/direct_sound_samples/cry_pidgey.aif)bin1984 -> 1984 bytes
-rw-r--r--sound/direct_sound_samples/cries/pikachu.aif (renamed from sound/direct_sound_samples/cry_pikachu.aif)bin8316 -> 8316 bytes
-rw-r--r--sound/direct_sound_samples/cries/piloswine.aif (renamed from sound/direct_sound_samples/cry_piloswine.aif)bin6480 -> 6480 bytes
-rw-r--r--sound/direct_sound_samples/cries/pineco.aif (renamed from sound/direct_sound_samples/cry_pineco.aif)bin6690 -> 6690 bytes
-rw-r--r--sound/direct_sound_samples/cries/pinsir.aif (renamed from sound/direct_sound_samples/cry_pinsir.aif)bin6186 -> 6186 bytes
-rw-r--r--sound/direct_sound_samples/cries/plusle.aif (renamed from sound/direct_sound_samples/cry_plusle.aif)bin4504 -> 4504 bytes
-rw-r--r--sound/direct_sound_samples/cries/politoed.aif (renamed from sound/direct_sound_samples/cry_politoed.aif)bin9114 -> 9114 bytes
-rw-r--r--sound/direct_sound_samples/cries/poliwag.aif (renamed from sound/direct_sound_samples/cry_poliwag.aif)bin5562 -> 5562 bytes
-rw-r--r--sound/direct_sound_samples/cries/poliwhirl.aif (renamed from sound/direct_sound_samples/cry_poliwhirl.aif)bin3354 -> 3354 bytes
-rw-r--r--sound/direct_sound_samples/cries/poliwrath.aif (renamed from sound/direct_sound_samples/cry_poliwrath.aif)bin5582 -> 5582 bytes
-rw-r--r--sound/direct_sound_samples/cries/ponyta.aif (renamed from sound/direct_sound_samples/cry_ponyta.aif)bin7524 -> 7524 bytes
-rw-r--r--sound/direct_sound_samples/cries/poochyena.aif (renamed from sound/direct_sound_samples/cry_poochyena.aif)bin4656 -> 4656 bytes
-rw-r--r--sound/direct_sound_samples/cries/porygon.aif (renamed from sound/direct_sound_samples/cry_porygon.aif)bin10002 -> 10002 bytes
-rw-r--r--sound/direct_sound_samples/cries/porygon2.aif (renamed from sound/direct_sound_samples/cry_porygon2.aif)bin7854 -> 7854 bytes
-rw-r--r--sound/direct_sound_samples/cries/primeape.aif (renamed from sound/direct_sound_samples/cry_primeape.aif)bin8086 -> 8086 bytes
-rw-r--r--sound/direct_sound_samples/cries/psyduck.aif (renamed from sound/direct_sound_samples/cry_psyduck.aif)bin6578 -> 6578 bytes
-rw-r--r--sound/direct_sound_samples/cries/pupitar.aif (renamed from sound/direct_sound_samples/cry_pupitar.aif)bin4234 -> 4234 bytes
-rw-r--r--sound/direct_sound_samples/cries/quagsire.aif (renamed from sound/direct_sound_samples/cry_quagsire.aif)bin6684 -> 6684 bytes
-rw-r--r--sound/direct_sound_samples/cries/quilava.aif (renamed from sound/direct_sound_samples/cry_quilava.aif)bin5962 -> 5962 bytes
-rw-r--r--sound/direct_sound_samples/cries/qwilfish.aif (renamed from sound/direct_sound_samples/cry_qwilfish.aif)bin5808 -> 5808 bytes
-rw-r--r--sound/direct_sound_samples/cries/raichu.aif (renamed from sound/direct_sound_samples/cry_raichu.aif)bin11842 -> 11842 bytes
-rw-r--r--sound/direct_sound_samples/cries/raikou.aif (renamed from sound/direct_sound_samples/cry_raikou.aif)bin8704 -> 8704 bytes
-rw-r--r--sound/direct_sound_samples/cries/ralts.aif (renamed from sound/direct_sound_samples/cry_ralts.aif)bin5066 -> 5066 bytes
-rw-r--r--sound/direct_sound_samples/cries/rapidash.aif (renamed from sound/direct_sound_samples/cry_rapidash.aif)bin9292 -> 9292 bytes
-rw-r--r--sound/direct_sound_samples/cries/raticate.aif (renamed from sound/direct_sound_samples/cry_raticate.aif)bin4770 -> 4770 bytes
-rw-r--r--sound/direct_sound_samples/cries/rattata.aif (renamed from sound/direct_sound_samples/cry_rattata.aif)bin3956 -> 3956 bytes
-rw-r--r--sound/direct_sound_samples/cries/rayquaza.aif (renamed from sound/direct_sound_samples/cry_rayquaza.aif)bin14532 -> 14532 bytes
-rw-r--r--sound/direct_sound_samples/cries/regice.aif (renamed from sound/direct_sound_samples/cry_regice.aif)bin15936 -> 15936 bytes
-rw-r--r--sound/direct_sound_samples/cries/regirock.aif (renamed from sound/direct_sound_samples/cry_regirock.aif)bin15862 -> 15862 bytes
-rw-r--r--sound/direct_sound_samples/cries/registeel.aif (renamed from sound/direct_sound_samples/cry_registeel.aif)bin11476 -> 11476 bytes
-rw-r--r--sound/direct_sound_samples/cries/relicanth.aif (renamed from sound/direct_sound_samples/cry_relicanth.aif)bin10072 -> 10072 bytes
-rw-r--r--sound/direct_sound_samples/cries/remoraid.aif (renamed from sound/direct_sound_samples/cry_remoraid.aif)bin5290 -> 5290 bytes
-rw-r--r--sound/direct_sound_samples/cries/rhydon.aif (renamed from sound/direct_sound_samples/cry_rhydon.aif)bin10186 -> 10186 bytes
-rw-r--r--sound/direct_sound_samples/cries/rhyhorn.aif (renamed from sound/direct_sound_samples/cry_rhyhorn.aif)bin9686 -> 9686 bytes
-rw-r--r--sound/direct_sound_samples/cries/roselia.aif (renamed from sound/direct_sound_samples/cry_roselia.aif)bin5382 -> 5382 bytes
-rw-r--r--sound/direct_sound_samples/cries/sableye.aif (renamed from sound/direct_sound_samples/cry_sableye.aif)bin5826 -> 5826 bytes
-rw-r--r--sound/direct_sound_samples/cries/salamence.aif (renamed from sound/direct_sound_samples/cry_salamence.aif)bin12514 -> 12514 bytes
-rw-r--r--sound/direct_sound_samples/cries/sandshrew.aif (renamed from sound/direct_sound_samples/cry_sandshrew.aif)bin4678 -> 4678 bytes
-rw-r--r--sound/direct_sound_samples/cries/sandslash.aif (renamed from sound/direct_sound_samples/cry_sandslash.aif)bin6784 -> 6784 bytes
-rw-r--r--sound/direct_sound_samples/cries/sceptile.aif (renamed from sound/direct_sound_samples/cry_sceptile.aif)bin13012 -> 13012 bytes
-rw-r--r--sound/direct_sound_samples/cries/scizor.aif (renamed from sound/direct_sound_samples/cry_scizor.aif)bin11462 -> 11462 bytes
-rw-r--r--sound/direct_sound_samples/cries/scyther.aif (renamed from sound/direct_sound_samples/cry_scyther.aif)bin6676 -> 6676 bytes
-rw-r--r--sound/direct_sound_samples/cries/seadra.aif (renamed from sound/direct_sound_samples/cry_seadra.aif)bin4228 -> 4228 bytes
-rw-r--r--sound/direct_sound_samples/cries/seaking.aif (renamed from sound/direct_sound_samples/cry_seaking.aif)bin9654 -> 9654 bytes
-rw-r--r--sound/direct_sound_samples/cries/sealeo.aif (renamed from sound/direct_sound_samples/cry_sealeo.aif)bin5928 -> 5928 bytes
-rw-r--r--sound/direct_sound_samples/cries/seedot.aif (renamed from sound/direct_sound_samples/cry_seedot.aif)bin4106 -> 4106 bytes
-rw-r--r--sound/direct_sound_samples/cries/seel.aif (renamed from sound/direct_sound_samples/cry_seel.aif)bin8954 -> 8954 bytes
-rw-r--r--sound/direct_sound_samples/cries/sentret.aif (renamed from sound/direct_sound_samples/cry_sentret.aif)bin2108 -> 2108 bytes
-rw-r--r--sound/direct_sound_samples/cries/seviper.aif (renamed from sound/direct_sound_samples/cry_seviper.aif)bin5820 -> 5820 bytes
-rw-r--r--sound/direct_sound_samples/cries/sharpedo.aif (renamed from sound/direct_sound_samples/cry_sharpedo.aif)bin11488 -> 11488 bytes
-rw-r--r--sound/direct_sound_samples/cries/shedinja.aif (renamed from sound/direct_sound_samples/cry_shedinja.aif)bin3876 -> 3876 bytes
-rw-r--r--sound/direct_sound_samples/cries/shelgon.aif (renamed from sound/direct_sound_samples/cry_shelgon.aif)bin9992 -> 9992 bytes
-rw-r--r--sound/direct_sound_samples/cries/shellder.aif (renamed from sound/direct_sound_samples/cry_shellder.aif)bin7718 -> 7718 bytes
-rw-r--r--sound/direct_sound_samples/cries/shiftry.aif (renamed from sound/direct_sound_samples/cry_shiftry.aif)bin9860 -> 9860 bytes
-rw-r--r--sound/direct_sound_samples/cries/shroomish.aif (renamed from sound/direct_sound_samples/cry_shroomish.aif)bin4436 -> 4436 bytes
-rw-r--r--sound/direct_sound_samples/cries/shuckle.aif (renamed from sound/direct_sound_samples/cry_shuckle.aif)bin5110 -> 5110 bytes
-rw-r--r--sound/direct_sound_samples/cries/shuppet.aif (renamed from sound/direct_sound_samples/cry_shuppet.aif)bin4144 -> 4144 bytes
-rw-r--r--sound/direct_sound_samples/cries/silcoon.aif (renamed from sound/direct_sound_samples/cry_silcoon.aif)bin8074 -> 8074 bytes
-rw-r--r--sound/direct_sound_samples/cries/skarmory.aif (renamed from sound/direct_sound_samples/cry_skarmory.aif)bin11982 -> 11982 bytes
-rw-r--r--sound/direct_sound_samples/cries/skiploom.aif (renamed from sound/direct_sound_samples/cry_skiploom.aif)bin6516 -> 6516 bytes
-rw-r--r--sound/direct_sound_samples/cries/skitty.aif (renamed from sound/direct_sound_samples/cry_skitty.aif)bin3560 -> 3560 bytes
-rw-r--r--sound/direct_sound_samples/cries/slaking.aif (renamed from sound/direct_sound_samples/cry_slaking.aif)bin4970 -> 4970 bytes
-rw-r--r--sound/direct_sound_samples/cries/slakoth.aif (renamed from sound/direct_sound_samples/cry_slakoth.aif)bin4272 -> 4272 bytes
-rw-r--r--sound/direct_sound_samples/cries/slowbro.aif (renamed from sound/direct_sound_samples/cry_slowbro.aif)bin6720 -> 6720 bytes
-rw-r--r--sound/direct_sound_samples/cries/slowking.aif (renamed from sound/direct_sound_samples/cry_slowking.aif)bin11908 -> 11908 bytes
-rw-r--r--sound/direct_sound_samples/cries/slowpoke.aif (renamed from sound/direct_sound_samples/cry_slowpoke.aif)bin3724 -> 3724 bytes
-rw-r--r--sound/direct_sound_samples/cries/slugma.aif (renamed from sound/direct_sound_samples/cry_slugma.aif)bin8536 -> 8536 bytes
-rw-r--r--sound/direct_sound_samples/cries/smeargle.aif (renamed from sound/direct_sound_samples/cry_smeargle.aif)bin5114 -> 5114 bytes
-rw-r--r--sound/direct_sound_samples/cries/smoochum.aif (renamed from sound/direct_sound_samples/cry_smoochum.aif)bin5860 -> 5860 bytes
-rw-r--r--sound/direct_sound_samples/cries/sneasel.aif (renamed from sound/direct_sound_samples/cry_sneasel.aif)bin4586 -> 4586 bytes
-rw-r--r--sound/direct_sound_samples/cries/snorlax.aif (renamed from sound/direct_sound_samples/cry_snorlax.aif)bin2648 -> 2648 bytes
-rw-r--r--sound/direct_sound_samples/cries/snorunt.aif (renamed from sound/direct_sound_samples/cry_snorunt.aif)bin8500 -> 8500 bytes
-rw-r--r--sound/direct_sound_samples/cries/snubbull.aif (renamed from sound/direct_sound_samples/cry_snubbull.aif)bin7220 -> 7220 bytes
-rw-r--r--sound/direct_sound_samples/cries/solrock.aif (renamed from sound/direct_sound_samples/cry_solrock.aif)bin8080 -> 8080 bytes
-rw-r--r--sound/direct_sound_samples/cries/spearow.aif (renamed from sound/direct_sound_samples/cry_spearow.aif)bin8806 -> 8806 bytes
-rw-r--r--sound/direct_sound_samples/cries/spheal.aif (renamed from sound/direct_sound_samples/cry_spheal.aif)bin2880 -> 2880 bytes
-rw-r--r--sound/direct_sound_samples/cries/spinarak.aif (renamed from sound/direct_sound_samples/cry_spinarak.aif)bin6696 -> 6696 bytes
-rw-r--r--sound/direct_sound_samples/cries/spinda.aif (renamed from sound/direct_sound_samples/cry_spinda.aif)bin6216 -> 6216 bytes
-rw-r--r--sound/direct_sound_samples/cries/spoink.aif (renamed from sound/direct_sound_samples/cry_spoink.aif)bin3648 -> 3648 bytes
-rw-r--r--sound/direct_sound_samples/cries/squirtle.aif (renamed from sound/direct_sound_samples/cry_squirtle.aif)bin7222 -> 7222 bytes
-rw-r--r--sound/direct_sound_samples/cries/stantler.aif (renamed from sound/direct_sound_samples/cry_stantler.aif)bin11208 -> 11208 bytes
-rw-r--r--sound/direct_sound_samples/cries/starmie.aif (renamed from sound/direct_sound_samples/cry_starmie.aif)bin10402 -> 10402 bytes
-rw-r--r--sound/direct_sound_samples/cries/staryu.aif (renamed from sound/direct_sound_samples/cry_staryu.aif)bin9934 -> 9934 bytes
-rw-r--r--sound/direct_sound_samples/cries/steelix.aif (renamed from sound/direct_sound_samples/cry_steelix.aif)bin18988 -> 18988 bytes
-rw-r--r--sound/direct_sound_samples/cries/sudowoodo.aif (renamed from sound/direct_sound_samples/cry_sudowoodo.aif)bin8084 -> 8084 bytes
-rw-r--r--sound/direct_sound_samples/cries/suicune.aif (renamed from sound/direct_sound_samples/cry_suicune.aif)bin9126 -> 9126 bytes
-rw-r--r--sound/direct_sound_samples/cries/sunflora.aif (renamed from sound/direct_sound_samples/cry_sunflora.aif)bin7928 -> 7928 bytes
-rw-r--r--sound/direct_sound_samples/cries/sunkern.aif (renamed from sound/direct_sound_samples/cry_sunkern.aif)bin4056 -> 4056 bytes
-rw-r--r--sound/direct_sound_samples/cries/surskit.aif (renamed from sound/direct_sound_samples/cry_surskit.aif)bin5258 -> 5258 bytes
-rw-r--r--sound/direct_sound_samples/cries/swablu.aif (renamed from sound/direct_sound_samples/cry_swablu.aif)bin2824 -> 2824 bytes
-rw-r--r--sound/direct_sound_samples/cries/swalot.aif (renamed from sound/direct_sound_samples/cry_swalot.aif)bin8676 -> 8676 bytes
-rw-r--r--sound/direct_sound_samples/cries/swampert.aif (renamed from sound/direct_sound_samples/cry_swampert.aif)bin11220 -> 11220 bytes
-rw-r--r--sound/direct_sound_samples/cries/swellow.aif (renamed from sound/direct_sound_samples/cry_swellow.aif)bin4524 -> 4524 bytes
-rw-r--r--sound/direct_sound_samples/cries/swinub.aif (renamed from sound/direct_sound_samples/cry_swinub.aif)bin6328 -> 6328 bytes
-rw-r--r--sound/direct_sound_samples/cries/taillow.aif (renamed from sound/direct_sound_samples/cry_taillow.aif)bin3024 -> 3024 bytes
-rw-r--r--sound/direct_sound_samples/cries/tangela.aif (renamed from sound/direct_sound_samples/cry_tangela.aif)bin7550 -> 7550 bytes
-rw-r--r--sound/direct_sound_samples/cries/tauros.aif (renamed from sound/direct_sound_samples/cry_tauros.aif)bin9150 -> 9150 bytes
-rw-r--r--sound/direct_sound_samples/cries/teddiursa.aif (renamed from sound/direct_sound_samples/cry_teddiursa.aif)bin8266 -> 8266 bytes
-rw-r--r--sound/direct_sound_samples/cries/tentacool.aif (renamed from sound/direct_sound_samples/cry_tentacool.aif)bin7960 -> 7960 bytes
-rw-r--r--sound/direct_sound_samples/cries/tentacruel.aif (renamed from sound/direct_sound_samples/cry_tentacruel.aif)bin11458 -> 11458 bytes
-rw-r--r--sound/direct_sound_samples/cries/togepi.aif (renamed from sound/direct_sound_samples/cry_togepi.aif)bin5460 -> 5460 bytes
-rw-r--r--sound/direct_sound_samples/cries/togetic.aif (renamed from sound/direct_sound_samples/cry_togetic.aif)bin3526 -> 3526 bytes
-rw-r--r--sound/direct_sound_samples/cries/torchic.aif (renamed from sound/direct_sound_samples/cry_torchic.aif)bin4840 -> 4840 bytes
-rw-r--r--sound/direct_sound_samples/cries/torkoal.aif (renamed from sound/direct_sound_samples/cry_torkoal.aif)bin4662 -> 4662 bytes
-rw-r--r--sound/direct_sound_samples/cries/totodile.aif (renamed from sound/direct_sound_samples/cry_totodile.aif)bin9152 -> 9152 bytes
-rw-r--r--sound/direct_sound_samples/cries/trapinch.aif (renamed from sound/direct_sound_samples/cry_trapinch.aif)bin5080 -> 5080 bytes
-rw-r--r--sound/direct_sound_samples/cries/treecko.aif (renamed from sound/direct_sound_samples/cry_treecko.aif)bin5836 -> 5836 bytes
-rw-r--r--sound/direct_sound_samples/cries/tropius.aif (renamed from sound/direct_sound_samples/cry_tropius.aif)bin16318 -> 16318 bytes
-rw-r--r--sound/direct_sound_samples/cries/typhlosion.aif (renamed from sound/direct_sound_samples/cry_typhlosion.aif)bin18944 -> 18944 bytes
-rw-r--r--sound/direct_sound_samples/cries/tyranitar.aif (renamed from sound/direct_sound_samples/cry_tyranitar.aif)bin11656 -> 11656 bytes
-rw-r--r--sound/direct_sound_samples/cries/tyrogue.aif (renamed from sound/direct_sound_samples/cry_tyrogue.aif)bin8072 -> 8072 bytes
-rw-r--r--sound/direct_sound_samples/cries/umbreon.aif (renamed from sound/direct_sound_samples/cry_umbreon.aif)bin7746 -> 7746 bytes
-rw-r--r--sound/direct_sound_samples/cries/unown.aif (renamed from sound/direct_sound_samples/cry_unown.aif)bin6576 -> 6576 bytes
-rw-r--r--sound/direct_sound_samples/cries/unused_265.aif (renamed from sound/direct_sound_samples/cry_unused_265.aif)bin4676 -> 4676 bytes
-rw-r--r--sound/direct_sound_samples/cries/unused_268.aif (renamed from sound/direct_sound_samples/cry_unused_268.aif)bin8828 -> 8828 bytes
-rw-r--r--sound/direct_sound_samples/cries/ursaring.aif (renamed from sound/direct_sound_samples/cry_ursaring.aif)bin14862 -> 14862 bytes
-rw-r--r--sound/direct_sound_samples/cries/vaporeon.aif (renamed from sound/direct_sound_samples/cry_vaporeon.aif)bin11018 -> 11018 bytes
-rw-r--r--sound/direct_sound_samples/cries/venomoth.aif (renamed from sound/direct_sound_samples/cry_venomoth.aif)bin8002 -> 8002 bytes
-rw-r--r--sound/direct_sound_samples/cries/venonat.aif (renamed from sound/direct_sound_samples/cry_venonat.aif)bin7746 -> 7746 bytes
-rw-r--r--sound/direct_sound_samples/cries/venusaur.aif (renamed from sound/direct_sound_samples/cry_venusaur.aif)bin9648 -> 9648 bytes
-rw-r--r--sound/direct_sound_samples/cries/vibrava.aif (renamed from sound/direct_sound_samples/cry_vibrava.aif)bin7002 -> 7002 bytes
-rw-r--r--sound/direct_sound_samples/cries/victreebel.aif (renamed from sound/direct_sound_samples/cry_victreebel.aif)bin9630 -> 9630 bytes
-rw-r--r--sound/direct_sound_samples/cries/vigoroth.aif (renamed from sound/direct_sound_samples/cry_vigoroth.aif)bin7168 -> 7168 bytes
-rw-r--r--sound/direct_sound_samples/cries/vileplume.aif (renamed from sound/direct_sound_samples/cry_vileplume.aif)bin12760 -> 12760 bytes
-rw-r--r--sound/direct_sound_samples/cries/volbeat.aif (renamed from sound/direct_sound_samples/cry_volbeat.aif)bin5772 -> 5772 bytes
-rw-r--r--sound/direct_sound_samples/cries/voltorb.aif (renamed from sound/direct_sound_samples/cry_voltorb.aif)bin12346 -> 12346 bytes
-rw-r--r--sound/direct_sound_samples/cries/vulpix.aif (renamed from sound/direct_sound_samples/cry_vulpix.aif)bin11870 -> 11870 bytes
-rw-r--r--sound/direct_sound_samples/cries/wailmer.aif (renamed from sound/direct_sound_samples/cry_wailmer.aif)bin14134 -> 14134 bytes
-rw-r--r--sound/direct_sound_samples/cries/wailord.aif (renamed from sound/direct_sound_samples/cry_wailord.aif)bin20928 -> 20928 bytes
-rw-r--r--sound/direct_sound_samples/cries/walrein.aif (renamed from sound/direct_sound_samples/cry_walrein.aif)bin18067 -> 18067 bytes
-rw-r--r--sound/direct_sound_samples/cries/wartortle.aif (renamed from sound/direct_sound_samples/cry_wartortle.aif)bin8614 -> 8614 bytes
-rw-r--r--sound/direct_sound_samples/cries/weedle.aif (renamed from sound/direct_sound_samples/cry_weedle.aif)bin8124 -> 8124 bytes
-rw-r--r--sound/direct_sound_samples/cries/weepinbell.aif (renamed from sound/direct_sound_samples/cry_weepinbell.aif)bin7310 -> 7310 bytes
-rw-r--r--sound/direct_sound_samples/cries/weezing.aif (renamed from sound/direct_sound_samples/cry_weezing.aif)bin10806 -> 10806 bytes
-rw-r--r--sound/direct_sound_samples/cries/whiscash.aif (renamed from sound/direct_sound_samples/cry_whiscash.aif)bin8478 -> 8478 bytes
-rw-r--r--sound/direct_sound_samples/cries/whismur.aif (renamed from sound/direct_sound_samples/cry_whismur.aif)bin4092 -> 4092 bytes
-rw-r--r--sound/direct_sound_samples/cries/wigglytuff.aif (renamed from sound/direct_sound_samples/cry_wigglytuff.aif)bin3412 -> 3412 bytes
-rw-r--r--sound/direct_sound_samples/cries/wingull.aif (renamed from sound/direct_sound_samples/cry_wingull.aif)bin6132 -> 6132 bytes
-rw-r--r--sound/direct_sound_samples/cries/wobbuffet.aif (renamed from sound/direct_sound_samples/cry_wobbuffet.aif)bin10276 -> 10276 bytes
-rw-r--r--sound/direct_sound_samples/cries/wooper.aif (renamed from sound/direct_sound_samples/cry_wooper.aif)bin3710 -> 3710 bytes
-rw-r--r--sound/direct_sound_samples/cries/wurmple.aif (renamed from sound/direct_sound_samples/cry_wurmple.aif)bin4412 -> 4412 bytes
-rw-r--r--sound/direct_sound_samples/cries/wynaut.aif (renamed from sound/direct_sound_samples/cry_wynaut.aif)bin6932 -> 6932 bytes
-rw-r--r--sound/direct_sound_samples/cries/xatu.aif (renamed from sound/direct_sound_samples/cry_xatu.aif)bin7392 -> 7392 bytes
-rw-r--r--sound/direct_sound_samples/cries/yanma.aif (renamed from sound/direct_sound_samples/cry_yanma.aif)bin8506 -> 8506 bytes
-rw-r--r--sound/direct_sound_samples/cries/zangoose.aif (renamed from sound/direct_sound_samples/cry_zangoose.aif)bin4778 -> 4778 bytes
-rw-r--r--sound/direct_sound_samples/cries/zapdos.aif (renamed from sound/direct_sound_samples/cry_zapdos.aif)bin7724 -> 7724 bytes
-rw-r--r--sound/direct_sound_samples/cries/zigzagoon.aif (renamed from sound/direct_sound_samples/cry_zigzagoon.aif)bin5786 -> 5786 bytes
-rw-r--r--sound/direct_sound_samples/cries/zubat.aif (renamed from sound/direct_sound_samples/cry_zubat.aif)bin9688 -> 9688 bytes
-rw-r--r--src/battle_controller_link_opponent.c4
-rw-r--r--src/battle_controller_recorded_opponent.c4
-rw-r--r--src/battle_controllers.c7
-rw-r--r--src/battle_main.c2
-rw-r--r--src/battle_message.c14
-rw-r--r--src/berry.c16
-rw-r--r--src/berry_blender.c11
-rwxr-xr-xsrc/berry_crush.c17
-rw-r--r--src/cable_club.c772
-rw-r--r--src/confetti_util.c218
-rw-r--r--src/contest.c70
-rw-r--r--src/contest_link.c (renamed from src/contest_link_80FC4F4.c)11
-rw-r--r--src/contest_link_util.c (renamed from src/contest_link_81D9DE4.c)0
-rw-r--r--src/contest_painting.c18
-rw-r--r--src/contest_util.c (renamed from src/contest_link_80F57C4.c)1258
-rw-r--r--src/data/union_room.h472
-rw-r--r--src/dodrio_berry_picking.c12
-rw-r--r--src/easy_chat.c5
-rwxr-xr-xsrc/ereader_screen.c12
-rw-r--r--src/event_object_lock.c2
-rw-r--r--src/event_object_movement.c143
-rwxr-xr-xsrc/faraway_island.c2
-rw-r--r--src/field_effect.c4
-rwxr-xr-xsrc/field_effect_helpers.c38
-rw-r--r--src/field_screen_effect.c8
-rw-r--r--src/field_specials.c10
-rw-r--r--src/fieldmap.c11
-rw-r--r--src/fldeff_misc.c2
-rw-r--r--src/graphics.c56
-rw-r--r--src/hall_of_fame.c340
-rw-r--r--src/image_processing_effects.c44
-rwxr-xr-xsrc/item_menu.c10
-rw-r--r--src/librfu_rfu.c4
-rw-r--r--src/link.c346
-rw-r--r--src/link_rfu_2.c2294
-rw-r--r--src/link_rfu_3.c754
-rw-r--r--src/main.c4
-rw-r--r--src/menu.c2
-rwxr-xr-xsrc/mevent2.c6
-rw-r--r--src/mystery_event_menu.c4
-rw-r--r--src/mystery_gift.c17
-rw-r--r--src/new_game.c2
-rw-r--r--src/overworld.c2
-rwxr-xr-xsrc/party_menu.c4
-rw-r--r--src/pokedex.c12
-rw-r--r--src/pokemon.c8
-rwxr-xr-xsrc/pokemon_jump.c16
-rw-r--r--src/record_mixing.c15
-rw-r--r--src/rom_81520A8.c218
-rw-r--r--src/save.c50
-rw-r--r--src/scrcmd.c18
-rwxr-xr-xsrc/script_pokemon_util_80F87D8.c6
-rw-r--r--src/secret_base.c3
-rw-r--r--src/slot_machine.c23
-rw-r--r--src/start_menu.c78
-rw-r--r--src/strings.c12
-rw-r--r--src/trade.c21
-rw-r--r--src/tv.c16
-rw-r--r--src/union_room.c3666
-rw-r--r--src/union_room_battle.c473
-rwxr-xr-xsrc/union_room_chat.c2588
-rw-r--r--src/union_room_player_avatar.c493
-rw-r--r--src/wireless_communication_status_screen.c432
-rw-r--r--sym_bss.txt1
-rw-r--r--sym_ewram.txt5
536 files changed, 9368 insertions, 8223 deletions
diff --git a/Makefile b/Makefile
index 27d77754c..99a93718b 100644
--- a/Makefile
+++ b/Makefile
@@ -49,6 +49,8 @@ DATA_SRC_SUBDIR = src/data
DATA_ASM_SUBDIR = data
SONG_SUBDIR = sound/songs
MID_SUBDIR = sound/songs/midi
+SAMPLE_SUBDIR = sound/direct_sound_samples
+CRY_SUBDIR = sound/direct_sound_samples/cries
C_BUILDDIR = $(OBJ_DIR)/$(C_SUBDIR)
GFLIB_BUILDDIR = $(OBJ_DIR)/$(GFLIB_SUBDIR)
@@ -67,7 +69,7 @@ OBJ_DIR := build/emerald
LIBPATH := -L ../../tools/agbcc/lib
else
CC1 = $(shell $(CC) --print-prog-name=cc1) -quiet
-override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -fno-aggressive-loop-optimizations -Wno-pointer-to-int-cast
+override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast
ROM := pokeemerald_modern.gba
OBJ_DIR := build/modern
LIBPATH := -L "$(dir $(shell $(CC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(CC) -mthumb -print-file-name=libc.a))"
@@ -173,7 +175,8 @@ clean-tools:
@$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);)
mostlyclean: tidy
- rm -f sound/direct_sound_samples/*.bin
+ rm -f $(SAMPLE_SUBDIR)/*.bin
+ rm -f $(CRY_SUBDIR)/*.bin
rm -f $(MID_SUBDIR)/*.s
find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' -o -iname '*.latfont' -o -iname '*.hwjpnfont' -o -iname '*.fwjpnfont' \) -exec rm {} +
rm -f $(DATA_ASM_SUBDIR)/layouts/layouts.inc $(DATA_ASM_SUBDIR)/layouts/layouts_table.inc
@@ -212,7 +215,7 @@ include songs.mk
%.gbapal: %.png ; $(GFX) $< $@
%.lz: % ; $(GFX) $< $@
%.rl: % ; $(GFX) $< $@
-sound/direct_sound_samples/cry_%.bin: sound/direct_sound_samples/cry_%.aif ; $(AIF) $< $@ --compress
+$(CRY_SUBDIR)/%.bin: $(CRY_SUBDIR)/%.aif ; $(AIF) $< $@ --compress
sound/%.bin: sound/%.aif ; $(AIF) $< $@
@@ -232,7 +235,7 @@ $(C_BUILDDIR)/record_mixing.o: CFLAGS += -ffreestanding
$(C_BUILDDIR)/librfu_intr.o: CC1 := tools/agbcc/bin/agbcc_arm
$(C_BUILDDIR)/librfu_intr.o: CFLAGS := -O2 -mthumb-interwork -quiet
else
-$(C_BUILDDIR)/librfu_intr.o: CFLAGS := -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -fno-aggressive-loop-optimizations -Wno-pointer-to-int-cast
+$(C_BUILDDIR)/librfu_intr.o: CFLAGS := -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast
endif
ifeq ($(NODEP),1)
diff --git a/asm/macros/event.inc b/asm/macros/event.inc
index a4beb3527..5e5a2758d 100644
--- a/asm/macros/event.inc
+++ b/asm/macros/event.inc
@@ -274,15 +274,17 @@
.2byte \functionId
.endm
- @ Blocks script execution until a command or ASM code manually unblocks it. Generally used with specific commands and specials. If this command runs, and a subsequent command or piece of ASM does not unblock state, the script will remain blocked indefinitely (essentially a hang).
+ @ Blocks script execution until a command or ASM code manually unblocks it. Generally used with specific
+ @ commands and specials. If this command runs, and a subsequent command or piece of ASM does not unblock
+ @ state, the script will remain blocked indefinitely (essentially a hang).
.macro waitstate
.byte 0x27
.endm
- @ Blocks script execution for time (frames? milliseconds?).
- .macro delay time:req
+ @ Blocks script execution for frames. (Pokemon Emerald runs at just shy of 60 frames per second.)
+ .macro delay frames:req
.byte 0x28
- .2byte \time
+ .2byte \frames
.endm
@ Sets a to 1.
@@ -315,7 +317,8 @@
.byte 0x2d
.endm
- @ Sets the values of variables 0x8000, 0x8001, and 0x8002 to the current hour, minute, and second. In FRLG, this command sets those variables to zero.
+ @ Sets the values of variables 0x8000, 0x8001, and 0x8002 to the current hour, minute, and second. In FRLG,
+ @ this command sets those variables to zero.
.macro gettime
.byte 0x2e
.endm
@@ -378,7 +381,8 @@
.byte \speed
.endm
- @ Sends the player to Warp warp on Map bank.map. If the specified warp is 0xFF, then the player will instead be sent to (X, Y) on the map.
+ @ Sends the player to Warp warp on Map bank.map. If the specified warp is 0xFF,
+ @ then the player will instead be sent to (X, Y) on the map.
.macro warp map:req, warp:req, X:req, Y:req
.byte 0x39
map \map
@@ -429,7 +433,8 @@
.2byte \Y
.endm
- @ Sets the warp destination that a warp to Warp 127 on Map 127.127 will connect to. Useful when a map has warps that need to go to script-controlled locations (i.e. elevators).
+ @ Sets the warp destination that a warp to Warp 127 on Map 127.127 will connect to.
+ @ Useful when a map has warps that need to go to script-controlled locations (i.e. elevators).
.macro setdynamicwarp map:req, warp:req, X:req, Y:req
.byte 0x3f
map \map
@@ -468,7 +473,8 @@
.byte 0x43
.endm
- @ Attempts to add quantity of item index to the player's Bag. If the player has enough room, the item will be added and VAR_RESULT will be set to TRUE; otherwise, VAR_RESULT is set to FALSE.
+ @ Attempts to add quantity of item index to the player's Bag. If the player has enough room, the item will be added and
+ @ VAR_RESULT will be set to TRUE; otherwise, VAR_RESULT is set to FALSE.
.macro additem index:req, quantity=1
.byte 0x44
.2byte \index
@@ -482,21 +488,24 @@
.2byte \quantity
.endm
- @ Checks if the player has enough space in their Bag to hold quantity more of item index. Sets VAR_RESULT to TRUE if there is room, or FALSE is there is no room.
+ @ Checks if the player has enough space in their Bag to hold quantity more of item index. Sets VAR_RESULT to
+ @ TRUE if there is room, or FALSE is there is no room.
.macro checkitemspace index:req, quantity:req
.byte 0x46
.2byte \index
.2byte \quantity
.endm
- @ Checks if the player has quantity or more of item index in their Bag. Sets VAR_RESULT to TRUE if the player has enough of the item, or FALSE if they have fewer than quantity of the item.
+ @ Checks if the player has quantity or more of item index in their Bag. Sets VAR_RESULT to TRUE if the player has
+ @ enough of the item, or FALSE if they have fewer than quantity of the item.
.macro checkitem index:req, quantity:req
.byte 0x47
.2byte \index
.2byte \quantity
.endm
- @ Checks which Bag pocket the specified item belongs in, and writes the pocket value (POCKET_*) to VAR_RESULT. This script is used to show the name of the proper Bag pocket when the player receives an item via callstd (simplified to giveitem in XSE).
+ @ Checks which Bag pocket the specified item belongs in, and writes the pocket value (POCKET_*) to VAR_RESULT.
+ @ This script is used to show the name of the proper Bag pocket when the player receives an item via callstd (simplified to giveitem in XSE).
.macro checkitemtype index:req
.byte 0x48
.2byte \index
@@ -534,7 +543,8 @@
.2byte \decoration
.endm
- @ Checks if the player has enough space in their PC to hold decoration. Sets VAR_RESULT to TRUE if there is room, or FALSE is there is no room. In FireRed, this command is a nop. (The argument is read, but not used for anything.)
+ @ Checks if the player has enough space in their PC to hold decoration. Sets VAR_RESULT to TRUE if there is room, or
+ @ FALSE is there is no room. In FireRed, this command is a nop. (The argument is read, but not used for anything.)
.macro checkdecorspace decoration:req
.byte 0x4e
.2byte \decoration
@@ -556,7 +566,10 @@
.endif
.endm
- @ Blocks script execution until the movements being applied to the specified (index) Object finish. If the specified Object is 0x0000, then the command will block script execution until all Objects affected by applymovement finish their movements. If the specified Object is not currently being manipulated with applymovement, then this command does nothing.
+ @ Blocks script execution until the movements being applied to the specified (index) Object finish.
+ @ If the specified Object is 0x0000, then the command will block script execution until all Objects
+ @ affected by applymovement finish their movements. If the specified Object is not currently being
+ @ manipulated with applymovement, then this command does nothing.
@ If no map is specified, then the current map is used.
.macro waitmovement index:req, map
.ifb \map
@@ -569,7 +582,9 @@
.endif
.endm
- @ Attempts to hide the specified (index) Object on the specified (map_group, map_num) map, by setting its visibility flag if it has a valid one. If the Object does not have a valid visibility flag, this command does nothing.
+ @ Attempts to hide the specified (index) Object on the specified (map_group, map_num) map,
+ @ by setting its visibility flag if it has a valid one. If the Object does not have a valid
+ @ visibility flag, this command does nothing.
@ If no map is specified, then the current map is used.
.macro removeobject index:req, map
.ifb \map
@@ -582,7 +597,8 @@
.endif
.endm
- @ Unsets the specified (index) Object's visibility flag on the specified (map_group, map_num) map if it has a valid one. If the Object does not have a valid visibility flag, this command does nothing.
+ @ Unsets the specified (index) Object's visibility flag on the specified (map_group, map_num) map if it has a valid one.
+ @ If the Object does not have a valid visibility flag, this command does nothing.
@ If no map is specified, then the current map is used.
.macro addobject index:req, map
.ifb \map
@@ -723,7 +739,8 @@
.endm
- @ Starts a trainer battle using the battle information stored in RAM (usually by trainerbattle, which actually calls this command behind-the-scenes), and blocks script execution until the battle finishes.
+ @ Starts a trainer battle using the battle information stored in RAM (usually by trainerbattle, which actually calls this
+ @ command behind-the-scenes), and blocks script execution until the battle finishes.
.macro trainerbattlebegin
.byte 0x5d
.endm
@@ -763,7 +780,8 @@
.2byte \y
.endm
- @ Copies a live object event's xy position to its template, so that if the sprite goes off screen, it'll still be there when it comes back on screen.
+ @ Copies a live object event's xy position to its template, so that if the sprite goes off screen,
+ @ it'll still be there when it comes back on screen.
.macro copyobjectxytoperm index:req
.byte 0x64
.2byte \index
@@ -775,12 +793,15 @@
.byte \byte
.endm
- @ If a standard message box (or its text) is being drawn on-screen, this command blocks script execution until the box and its text have been fully drawn.
+ @ If a standard message box (or its text) is being drawn on-screen, this command blocks script execution until the
+ @ box and its text have been fully drawn.
.macro waitmessage
.byte 0x66
.endm
- @ Starts displaying a standard message box containing the specified text. If text is a pointer, then the string at that offset will be loaded and used. If text is script bank 0, then the value of script bank 0 will be treated as a pointer to the text. (You can use loadpointer to place a string pointer in a script bank.)
+ @ Starts displaying a standard message box containing the specified text. If text is a pointer, then the string at
+ @ that offset will be loaded and used. If text is script bank 0, then the value of script bank 0 will be treated as
+ @ a pointer to the text. (You can use loadpointer to place a string pointer in a script bank.)
.macro message text:req
.byte 0x67
.4byte \text
@@ -816,14 +837,16 @@
.byte 0x6d
.endm
- @ Displays a YES/NO multichoice box at the specified coordinates, and blocks script execution until the user makes a selection. Their selection is stored in VAR_RESULT as NO (0) or YES (1). Pressing B is equivalent to answering NO
+ @ Displays a YES/NO multichoice box at the specified coordinates, and blocks script execution until the user makes a selection.
+ @ Their selection is stored in VAR_RESULT as NO (0) or YES (1). Pressing B is equivalent to answering NO
.macro yesnobox x:req, y:req
.byte 0x6e
.byte \x
.byte \y
.endm
- @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. Lists of options are predefined (sMultichoiceLists) and the one to be used is specified with list. If b is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button.
+ @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made.
+ @ Lists of options are predefined (sMultichoiceLists) and the one to be used is specified with list. If b is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button.
.macro multichoice x:req, y:req, list:req, b:req
.byte 0x6f
.byte \x
@@ -832,7 +855,10 @@
.byte \b
.endm
- @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. Lists of options are predefined (sMultichoiceLists) and the one to be used is specified with list. The default argument determines the initial position of the cursor when the box is first opened; it is zero-indexed, and if it is too large, it is treated as 0x00. If b is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button.
+ @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made.
+ @ Lists of options are predefined (sMultichoiceLists) and the one to be used is specified with list. The default argument determines
+ @ the initial position of the cursor when the box is first opened; it is zero-indexed, and if it is too large, it is treated as 0x00.
+ @ If b is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button.
.macro multichoicedefault x:req, y:req, list:req, default:req, b:req
.byte 0x70
.byte \x
@@ -842,7 +868,9 @@
.byte \b
.endm
- @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. Lists of options are predefined (sMultichoiceLists) and the one to be used is specified with list. The per_row argument determines how many list items will be shown on a single row of the box.
+ @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made.
+ @ Lists of options are predefined (sMultichoiceLists) and the one to be used is specified with list.
+ @ The per_row argument determines how many list items will be shown on a single row of the box.
.macro multichoicegrid x:req, y:req, list:req, per_row:req, B:req
.byte 0x71
.byte \x
@@ -894,7 +922,9 @@
.byte \a
.endm
- @ Displays the string at pointer as braille text in a standard message box. The string must be formatted to use braille characters and needs to provide six extra starting characters that are skipped (in RS, these characters determined the box's size and position, but in Emerald these are calculated automatically).
+ @ Displays the string at pointer as braille text in a standard message box. The string must be formatted to use braille
+ @ characters and needs to provide six extra starting characters that are skipped (in RS, these characters determined the
+ @ box's size and position, but in Emerald these are calculated automatically).
.macro braillemessage text:req
.byte 0x78
.4byte \text
@@ -923,7 +953,9 @@
.2byte \move
.endm
- @ Checks if at least one Pokemon in the player's party knows the specified (index) attack. If so, VAR_RESULT is set to the (zero-indexed) slot number of the first Pokemon that knows the move. If not, VAR_RESULT is set to PARTY_SIZE. VAR_0x8004 is also set to this Pokemon's species.
+ @ Checks if at least one Pokemon in the player's party knows the specified (index) attack. If so, VAR_RESULT is set to the
+ @ (zero-indexed) slot number of the first Pokemon that knows the move. If not, VAR_RESULT is set to PARTY_SIZE.
+ @ VAR_0x8004 is also set to this Pokemon's species.
.macro checkpartymove index:req
.byte 0x7c
.2byte \index
@@ -942,14 +974,16 @@
.byte \out
.endm
- @ Writes the nickname of the Pokemon in slot slot (zero-indexed) of the player's party to the specified buffer. If an empty or invalid slot is specified, ten spaces ("") are written to the buffer.
+ @ Writes the nickname of the Pokemon in slot slot (zero-indexed) of the player's party to the specified buffer.
+ @ If an empty or invalid slot is specified, ten spaces ("") are written to the buffer.
.macro bufferpartymonnick out:req, slot:req
.byte 0x7f
.byte \out
.2byte \slot
.endm
- @ Writes the name of the item at index item to the specified buffer. If the specified index is larger than the number of items in the game (0x176), the name of item 0 ("????????") is buffered instead.
+ @ Writes the name of the item at index item to the specified buffer. If the specified index is larger than
+ @ the number of items in the game (0x176), the name of item 0 ("????????") is buffered instead.
.macro bufferitemname out:req, item:req
.byte 0x80
.byte \out
@@ -977,7 +1011,8 @@
.2byte \input
.endm
- @ Writes the standard string identified by index to the specified buffer. This command has no protections in place at all, so specifying an invalid standard string (e.x. 0x2B) can and usually will cause data corruption.
+ @ Writes the standard string identified by index to the specified buffer. This command has no protections in place at all,
+ @ so specifying an invalid standard string (e.x. 0x2B) can and usually will cause crashes or garbage characters.
.macro bufferstdstring out:req, index:req
.byte 0x84
.byte \out
@@ -1063,7 +1098,8 @@
.byte \check
.endm
- @ If check is 0x00, this command will check if the player has money >= value; VAR_RESULT is set to TRUE if the player has enough money, or FALSE if they do not.
+ @ If check is 0x00, this command will check if the player has money >= value; VAR_RESULT is set to TRUE if the player
+ @ has enough money, or FALSE if they do not.
.macro checkmoney value:req, check:req
.byte 0x92
.4byte \value
@@ -1291,7 +1327,8 @@
.2byte \count
.endm
- @ Prepares to start a wild battle against a species at Level level holding item. Running this command will not affect normal wild battles. You start the prepared battle with dowildbattle.
+ @ Prepares to start a wild battle against a species at Level level holding item. Running this command will not affect
+ @ normal wild battles. You start the prepared battle with dowildbattle.
.macro setwildbattle species:req, level:req, item:req
.byte 0xb6
.2byte \species
@@ -1395,19 +1432,22 @@
.2byte \box
.endm
- @ Sets the color of the text in standard message boxes. 0x00 produces blue (male) text, 0x01 produces red (female) text, 0xFF resets the color to the default for the current OW's gender, and all other values produce black text.
+ @ Sets the color of the text in standard message boxes. 0x00 produces blue (male) text, 0x01 produces red (female) text,
+ @ 0xFF resets the color to the default for the current OW's gender, and all other values produce black text.
.macro textcolor color:req
.byte 0xc7
.byte \color
.endm
- @ The exact purpose of this command is unknown, but it is related to the blue help-text box that appears on the bottom of the screen when the Main Menu is opened.
+ @ The exact purpose of this command is unknown, but it is related to the blue help-text box that appears on the bottom
+ @ of the screen when the Main Menu is opened.
.macro loadhelp pointer:req
.byte 0xc8
.4byte \pointer
.endm
- @ The exact purpose of this command is unknown, but it is related to the blue help-text box that appears on the bottom of the screen when the Main Menu is opened.
+ @ The exact purpose of this command is unknown, but it is related to the blue help-text box that appears on the bottom of
+ @ the screen when the Main Menu is opened.
.macro unloadhelp
.byte 0xc9
.endm
@@ -1435,13 +1475,15 @@
.2byte \slot
.endm
- @ Checks if the Pokemon in the specified slot of the player's party is obedient. If the Pokemon is disobedient, VAR_RESULT is TRUE. If the Pokemon is obedient (or if the specified slot is empty or invalid), VAR_RESULT is FALSE.
+ @ Checks if the Pokemon in the specified slot of the player's party is obedient. If the Pokemon is disobedient,
+ @ VAR_RESULT is TRUE. If the Pokemon is obedient (or if the specified slot is empty or invalid), VAR_RESULT is FALSE.
.macro checkmonobedience slot:req
.byte 0xce
.2byte \slot
.endm
- @ Depending on factors I haven't managed to understand yet, this command may cause script execution to jump to the offset specified by the pointer at 0x020375C0.
+ @ Depending on factors I haven't managed to understand yet, this command may cause script execution to jump to the
+ @ offset specified by the pointer at 0x020375C0.
.macro gotoram
.byte 0xcf
.endm
@@ -1468,7 +1510,8 @@
.byte \location
.endm
- @ For the rotating tile puzzles in Mossdeep Gym/Trick House Room 7. Moves the objects on the colored puzzle specified by puzzleNumber one rotation
+ @ For the rotating tile puzzles in Mossdeep Gym/Trick House Room 7. Moves the objects on the colored puzzle
+ @ specified by puzzleNumber one rotation
.macro moverotatingtileobjects puzzleNumber:req
.byte 0xd3
.2byte \puzzleNumber
@@ -1479,7 +1522,9 @@
.byte 0xd4
.endm
- @ For the rotating tile puzzles in Mossdeep Gym/Trick House Room 7. Allocates memory for the puzzle objects. isTrickHouse is needed to determine which of the two maps the puzzle is on, in order to know where in the tileset the puzzle tiles start. In FireRed, this command is a nop.
+ @ For the rotating tile puzzles in Mossdeep Gym/Trick House Room 7. Allocates memory for the puzzle objects.
+ @ isTrickHouse is needed to determine which of the two maps the puzzle is on, in order to know where in the tileset
+ @ the puzzle tiles start. In FireRed, this command is a nop.
.macro initrotatingtilepuzzle isTrickHouse:req
.byte 0xd5
.2byte \isTrickHouse
@@ -1551,7 +1596,10 @@
.2byte \word
.endm
- @ Writes the name of the specified (item) item to the specified buffer. If the specified item is a Berry (0x85 - 0xAE) or Poke Ball (0x4) and if the quantity is 2 or more, the buffered string will be pluralized ("IES" or "S" appended). If the specified item is the Enigma Berry, I have no idea what this command does (but testing showed no pluralization). If the specified index is larger than the number of items in the game (0x176), the name of item 0 ("????????") is buffered instead.
+ @ Writes the name of the specified (item) item to the specified buffer. If the specified item is a Berry (0x85 - 0xAE) or
+ @ Poke Ball (0x4) and if the quantity is 2 or more, the buffered string will be pluralized ("IES" or "S" appended).
+ @ If the specified item is the Enigma Berry, I have no idea what this command does (but testing showed no pluralization).
+ @ If the specified index is larger than the number of items in the game (0x176), the name of item 0 ("????????") is buffered instead.
.macro bufferitemnameplural out:req, item:req, quantity:req
.byte 0xe2
.byte \out
diff --git a/common_syms/link.txt b/common_syms/link.txt
index a6d096116..37c16a557 100644
--- a/common_syms/link.txt
+++ b/common_syms/link.txt
@@ -3,15 +3,15 @@ gLinkDebugSeed
gLocalLinkPlayerBlock
gLinkErrorOccurred
gLinkDebugFlags
-gFiller_03003074
+gLinkFiller1
gRemoteLinkPlayersNotReceived
gBlockReceivedStatus
-gFiller_03003080
+gLinkFiller2
gLinkHeldKeys
gRecvCmds
gLinkStatus
-gUnknown_030030E4
-gUnknown_030030E8
+gLinkDummy1
+gLinkDummy2
gUnknown_030030EC
gUnknown_030030F0
gUnknown_030030F4
@@ -26,12 +26,10 @@ gLinkCallback
gShouldAdvanceLinkState
gLinkTestBlockChecksums
gBlockRequestType
-gFiller_03003154
-gFiller_03003158
-gFiller_0300315c
+gLinkFiller3
+gLinkFiller4
+gLinkFiller5
gLastSendQueueCount
gLink
gLastRecvQueueCount
gLinkSavedIme
-gFiller_03004138
-gFiller_0300413C
diff --git a/data/maps/BattleFrontier_BattleDomeBattleRoom/scripts.inc b/data/maps/BattleFrontier_BattleDomeBattleRoom/scripts.inc
index 25522f0c0..048c4fc80 100644
--- a/data/maps/BattleFrontier_BattleDomeBattleRoom/scripts.inc
+++ b/data/maps/BattleFrontier_BattleDomeBattleRoom/scripts.inc
@@ -172,7 +172,7 @@ BattleFrontier_BattleDomeBattleRoom_EventScript_WonTourney:: @ 824BF62
BattleFrontier_BattleDomeBattleRoom_EventScript_WonLvOpenTourney:: @ 824BF96
msgbox BattleFrontier_BattleDomeBattleRoom_Text_PlayerIsLvOpenChamp, MSGBOX_DEFAULT
BattleFrontier_BattleDomeBattleRoom_EventScript_CelebrateWin:: @ 824BF9E
- special DoConfettiEffect
+ special DoDomeConfetti
playse SE_W227B
call BattleFrontier_BattleDomeBattleRoom_EventScript_AudienceLookAround
delay 60
diff --git a/data/maps/BattleFrontier_BattleTowerBattleRoom/scripts.inc b/data/maps/BattleFrontier_BattleTowerBattleRoom/scripts.inc
index 029009294..89eaeda50 100644
--- a/data/maps/BattleFrontier_BattleTowerBattleRoom/scripts.inc
+++ b/data/maps/BattleFrontier_BattleTowerBattleRoom/scripts.inc
@@ -45,7 +45,7 @@ BattleFrontier_BattleTowerBattleRoom_EventScript_OpponentEnter:: @ 8241BC3
BattleFrontier_BattleTower_EventScript_WarpToLobbyLost:: @ 8241C03
frontier_set FRONTIER_DATA_CHALLENGE_STATUS, CHALLENGE_STATUS_LOST
tower_set TOWER_DATA_LVL_MODE
- setvar VAR_0x8004, 3
+ setvar VAR_0x8004, FANCOUNTER_USED_BATTLE_TOWER
special Script_TryGainNewFanFromCounter
goto BattleFrontier_BattleTowerBattleRoom_EventScript_WarpToLobby
@@ -134,7 +134,7 @@ BattleFrontier_BattleTowerBattleRoom_EventScript_ContinueChallenge:: @ 8241DDC
BattleFrontier_BattleTowerBattleRoom_EventScript_WarpToLobbyWon:: @ 8241DF6
frontier_set FRONTIER_DATA_CHALLENGE_STATUS, CHALLENGE_STATUS_WON
tower_set TOWER_DATA_LVL_MODE
- setvar VAR_0x8004, 3
+ setvar VAR_0x8004, FANCOUNTER_USED_BATTLE_TOWER
special Script_TryGainNewFanFromCounter
goto BattleFrontier_BattleTowerBattleRoom_EventScript_WarpToLobby
diff --git a/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc b/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc
index 843cacef4..14e5afb11 100644
--- a/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc
+++ b/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc
@@ -786,19 +786,19 @@ BattleFrontier_BattleTowerLobby_EventScript_TryCableLink:: @ 823F2C5
setvar VAR_0x8005, 0
special TryBattleLinkup
waitstate
- compare VAR_RESULT, 1
+ compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq BattleFrontier_BattleTowerLobby_EventScript_CableLinkSuccessful
- compare VAR_RESULT, 2
+ compare VAR_RESULT, LINKUP_SOMEONE_NOT_READY
goto_if_eq CableClub_EventScript_AbortLinkSomeoneNotReady
- compare VAR_RESULT, 3
+ compare VAR_RESULT, LINKUP_DIFF_SELECTIONS
goto_if_eq BattleFrontier_BattleTowerLobby_EventScript_AbortLinkDifferentSelections
- compare VAR_RESULT, 4
+ compare VAR_RESULT, LINKUP_WRONG_NUM_PLAYERS
goto_if_eq BattleFrontier_BattleTowerLobby_EventScript_AbortLinkIncorrectNumberOfPlayers
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq BattleFrontier_BattleTowerLobby_EventScript_CancelChallenge
- compare VAR_RESULT, 6
+ compare VAR_RESULT, LINKUP_CONNECTION_ERROR
goto_if_eq CableClub_EventScript_AbortLinkConnectionError
- compare VAR_RESULT, 11
+ compare VAR_RESULT, LINKUP_FAILED_BATTLE_TOWER
goto_if_eq BattleFrontier_BattleTowerLobby_EventScript_AbortLink
end
@@ -853,7 +853,7 @@ BattleFrontier_BattleTowerLobby_EventScript_CableLinkSuccessful:: @ 823F3AF
message BattleFrontier_BattleTowerLobby_Text_SaveGameBeforeShowingIn
waitmessage
tower_save CHALLENGE_STATUS_SAVING
- special sub_80A08CC
+ special SaveForBattleTowerLink
waitstate
playse SE_SAVE
waitse
@@ -884,26 +884,26 @@ BattleFrontier_BattleTowerLobby_EventScript_ChooseLeader:: @ 823F3F3
BattleFrontier_BattleTowerLobby_EventScript_TryBecomeLeader:: @ 823F430
call CableClub_EventScript_TryBecomeLinkLeader
- compare VAR_RESULT, 1
+ compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq BattleFrontier_BattleTowerLobby_EventScript_WirelessLinkSuccessful
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq BattleFrontier_BattleTowerLobby_EventScript_ChooseLeader
- compare VAR_RESULT, 8
+ compare VAR_RESULT, LINKUP_RETRY_ROLE_ASSIGN
goto_if_eq BattleFrontier_BattleTowerLobby_EventScript_TryBecomeLeader
- compare VAR_RESULT, 11
+ compare VAR_RESULT, LINKUP_FAILED_BATTLE_TOWER
goto_if_eq BattleFrontier_BattleTowerLobby_EventScript_AbortLink
release
return
BattleFrontier_BattleTowerLobby_EventScript_TryJoinGroup:: @ 823F463
call CableClub_EventScript_TryJoinLinkGroup
- compare VAR_RESULT, 1
+ compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq BattleFrontier_BattleTowerLobby_EventScript_WirelessLinkSuccessful
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq BattleFrontier_BattleTowerLobby_EventScript_ChooseLeader
- compare VAR_RESULT, 8
+ compare VAR_RESULT, LINKUP_RETRY_ROLE_ASSIGN
goto_if_eq BattleFrontier_BattleTowerLobby_EventScript_TryJoinGroup
- compare VAR_RESULT, 11
+ compare VAR_RESULT, LINKUP_FAILED_BATTLE_TOWER
goto_if_eq BattleFrontier_BattleTowerLobby_EventScript_AbortLink
release
return
@@ -914,7 +914,7 @@ BattleFrontier_BattleTowerLobby_EventScript_WirelessLinkSuccessful:: @ 823F496
message BattleFrontier_BattleTowerLobby_Text_SaveGameBeforeShowingIn
waitmessage
tower_save CHALLENGE_STATUS_SAVING
- special sub_80A08CC
+ special SaveForBattleTowerLink
waitstate
playse SE_SAVE
waitse
diff --git a/data/maps/BattleFrontier_BattleTowerMultiBattleRoom/scripts.inc b/data/maps/BattleFrontier_BattleTowerMultiBattleRoom/scripts.inc
index 3c549a919..754384136 100644
--- a/data/maps/BattleFrontier_BattleTowerMultiBattleRoom/scripts.inc
+++ b/data/maps/BattleFrontier_BattleTowerMultiBattleRoom/scripts.inc
@@ -103,7 +103,7 @@ BattleFrontier_BattleTowerMultiBattleRoom_EventScript_DoTowerBattle:: @ 8249069
BattleFrontier_BattleTowerMultiBattleRoom_EventScript_WarpToLobbyLost:: @ 824907E
frontier_set FRONTIER_DATA_CHALLENGE_STATUS, CHALLENGE_STATUS_LOST
tower_set TOWER_DATA_LVL_MODE
- setvar VAR_0x8004, 3
+ setvar VAR_0x8004, FANCOUNTER_USED_BATTLE_TOWER
special Script_TryGainNewFanFromCounter
goto BattleFrontier_BattleTowerBattleRoom_EventScript_WarpToLobby
@@ -208,7 +208,7 @@ BattleFrontier_BattleTowerMultiBattleRoom_EventScript_ContinueChallenge:: @ 8249
BattleFrontier_BattleTowerMultiBattleRoom_EventScript_WarpToLobbyWon:: @ 82492AF
frontier_set FRONTIER_DATA_CHALLENGE_STATUS, CHALLENGE_STATUS_WON
tower_set TOWER_DATA_LVL_MODE
- setvar VAR_0x8004, 3
+ setvar VAR_0x8004, FANCOUNTER_USED_BATTLE_TOWER
special Script_TryGainNewFanFromCounter
goto BattleFrontier_BattleTowerBattleRoom_EventScript_WarpToLobby
diff --git a/data/maps/EverGrandeCity_DrakesRoom/scripts.inc b/data/maps/EverGrandeCity_DrakesRoom/scripts.inc
index 2ae78caad..b9debf676 100644
--- a/data/maps/EverGrandeCity_DrakesRoom/scripts.inc
+++ b/data/maps/EverGrandeCity_DrakesRoom/scripts.inc
@@ -54,7 +54,7 @@ EverGrandeCity_DrakesRoom_EventScript_PostBattleSpeech:: @ 822871A
end
EverGrandeCity_DrakesRoom_EventScript_Defeated:: @ 8228724
- setvar VAR_0x8004, 0
+ setvar VAR_0x8004, FANCOUNTER_DEFEATED_DRAKE
special Script_TryGainNewFanFromCounter
setflag FLAG_DEFEATED_ELITE_4_DRAKE
call PokemonLeague_EliteFour_SetAdvanceToNextRoomMetatiles
diff --git a/data/maps/LilycoveCity_ContestLobby/scripts.inc b/data/maps/LilycoveCity_ContestLobby/scripts.inc
index 12b598346..a3d232346 100644
--- a/data/maps/LilycoveCity_ContestLobby/scripts.inc
+++ b/data/maps/LilycoveCity_ContestLobby/scripts.inc
@@ -43,7 +43,7 @@ LilycoveCity_ContestLobby_EventScript_ContestArtist:: @ 821A264
msgbox LilycoveCity_ContestLobby_Text_YourPokemonSpurredMeToPaint, MSGBOX_DEFAULT
lockall
fadescreen FADE_TO_BLACK
- showcontestwinner 0
+ showcontestwinner CONTEST_WINNER_ARTIST
lockall
msgbox LilycoveCity_ContestLobby_Text_ShouldITakePaintingToMuseum, MSGBOX_YESNO
compare VAR_RESULT, YES
@@ -217,7 +217,7 @@ LilycoveCity_ContestLobby_EventScript_LinkContestArtist:: @ 821A436
msgbox LilycoveCity_ContestLobby_Text_YourPokemonSpurredMeToPaint, MSGBOX_DEFAULT
lockall
fadescreen FADE_TO_BLACK
- showcontestwinner 0
+ showcontestwinner CONTEST_WINNER_ARTIST
msgbox LilycoveCity_ContestLobby_Text_ShouldITakePaintingToMuseum, MSGBOX_YESNO
compare VAR_RESULT, YES
goto_if_eq LilycoveCity_ContestLobby_EventScript_TakePaintingToMuseumLink
@@ -505,42 +505,42 @@ LilycoveCity_ContestLobby_EventScript_NinjaBoy:: @ 821A735
LilycoveCity_ContestLobby_EventScript_ContestWinner1:: @ 821A73E
lockall
fadescreen FADE_TO_BLACK
- showcontestwinner 1
+ showcontestwinner CONTEST_WINNER_HALL_1
releaseall
end
LilycoveCity_ContestLobby_EventScript_ContestWinner2:: @ 821A745
lockall
fadescreen FADE_TO_BLACK
- showcontestwinner 2
+ showcontestwinner CONTEST_WINNER_HALL_2
releaseall
end
LilycoveCity_ContestLobby_EventScript_ContestWinner3:: @ 821A74C
lockall
fadescreen FADE_TO_BLACK
- showcontestwinner 3
+ showcontestwinner CONTEST_WINNER_HALL_3
releaseall
end
LilycoveCity_ContestLobby_EventScript_ContestWinner4:: @ 821A753
lockall
fadescreen FADE_TO_BLACK
- showcontestwinner 4
+ showcontestwinner CONTEST_WINNER_HALL_4
releaseall
end
LilycoveCity_ContestLobby_EventScript_ContestWinner5:: @ 821A75A
lockall
fadescreen FADE_TO_BLACK
- showcontestwinner 5
+ showcontestwinner CONTEST_WINNER_HALL_5
releaseall
end
LilycoveCity_ContestLobby_EventScript_ContestWinner6:: @ 821A761
lockall
fadescreen FADE_TO_BLACK
- showcontestwinner 6
+ showcontestwinner CONTEST_WINNER_HALL_6
releaseall
end
@@ -767,15 +767,15 @@ LilycoveCity_ContestLobby_EventScript_TrySetUpLinkContest:: @ 821AA15
call_if_eq LilycoveCity_ContestLobby_EventScript_TryLinkGMode
compare VAR_TEMP_C, 2
goto_if_ge LilycoveCity_ContestLobby_EventScript_CancelLinkContest
- compare VAR_RESULT, 4
+ compare VAR_RESULT, LINKUP_WRONG_NUM_PLAYERS
goto_if_eq LilycoveCity_ContestLobby_EventScript_CancelLinkDifferentChoices
- compare VAR_RESULT, 3
+ compare VAR_RESULT, LINKUP_DIFF_SELECTIONS
goto_if_eq LilycoveCity_ContestLobby_EventScript_CancelLinkDifferentChoices
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq LilycoveCity_ContestLobby_EventScript_CancelLinkContest
- compare VAR_RESULT, 6
+ compare VAR_RESULT, LINKUP_CONNECTION_ERROR
goto_if_eq LilycoveCity_ContestLobby_EventScript_CancelLinkError
- compare VAR_RESULT, 10
+ compare VAR_RESULT, LINKUP_FAILED_CONTEST_GMODE
goto_if_eq LilycoveCity_ContestLobby_EventScript_CancelLinkModeDifference
message3 LilycoveCity_ContestLobby_Text_Transmitting
contestlinktransfer
@@ -889,22 +889,22 @@ LilycoveCity_ContestLobby_EventScript_DecideLinkLeader:: @ 821ABA6
LilycoveCity_ContestLobby_EventScript_TryLeadGroup:: @ 821ABE3
call LilycoveCity_ContestLobby_EventScript_TryBecomeLinkLeader
- compare VAR_RESULT, 1
+ compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq LilycoveCity_ContestLobby_EventScript_LinkLeaderDecided
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq LilycoveCity_ContestLobby_EventScript_DecideLinkLeader
- compare VAR_RESULT, 8
+ compare VAR_RESULT, LINKUP_RETRY_ROLE_ASSIGN
goto_if_eq LilycoveCity_ContestLobby_EventScript_TryLeadGroup
release
end
LilycoveCity_ContestLobby_EventScript_TryJoinGroup:: @ 821AC0B
call LilycoveCity_ContestLobby_EventScript_TryJoinLinkGroup
- compare VAR_RESULT, 1
+ compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq LilycoveCity_ContestLobby_EventScript_LinkLeaderDecided
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq LilycoveCity_ContestLobby_EventScript_DecideLinkLeader
- compare VAR_RESULT, 8
+ compare VAR_RESULT, LINKUP_RETRY_ROLE_ASSIGN
goto_if_eq LilycoveCity_ContestLobby_EventScript_TryJoinGroup
release
end
diff --git a/data/maps/LilycoveCity_LilycoveMuseum_2F/scripts.inc b/data/maps/LilycoveCity_LilycoveMuseum_2F/scripts.inc
index 5d45ed144..257bdd086 100644
--- a/data/maps/LilycoveCity_LilycoveMuseum_2F/scripts.inc
+++ b/data/maps/LilycoveCity_LilycoveMuseum_2F/scripts.inc
@@ -183,35 +183,35 @@ LilycoveCity_LilycoveMuseum_2F_EventScript_RichBoy:: @ 821999C
LilycoveCity_LilycoveMuseum_2F_EventScript_ShowCoolPainting:: @ 82199A5
msgbox LilycoveCity_LilycoveMuseum_2F_Text_ItsPaintingOfPokemon, MSGBOX_SIGN
fadescreen FADE_TO_BLACK
- showcontestwinner 9
+ showcontestwinner CONTEST_WINNER_MUSEUM_COOL
releaseall
end
LilycoveCity_LilycoveMuseum_2F_EventScript_ShowBeautyPainting:: @ 82199B3
msgbox LilycoveCity_LilycoveMuseum_2F_Text_ItsPaintingOfPokemon, MSGBOX_SIGN
fadescreen FADE_TO_BLACK
- showcontestwinner 10
+ showcontestwinner CONTEST_WINNER_MUSEUM_BEAUTY
releaseall
end
LilycoveCity_LilycoveMuseum_2F_EventScript_ShowCutePainting:: @ 82199C1
msgbox LilycoveCity_LilycoveMuseum_2F_Text_ItsPaintingOfPokemon, MSGBOX_SIGN
fadescreen FADE_TO_BLACK
- showcontestwinner 11
+ showcontestwinner CONTEST_WINNER_MUSEUM_CUTE
releaseall
end
LilycoveCity_LilycoveMuseum_2F_EventScript_ShowSmartPainting:: @ 82199CF
msgbox LilycoveCity_LilycoveMuseum_2F_Text_ItsPaintingOfPokemon, MSGBOX_SIGN
fadescreen FADE_TO_BLACK
- showcontestwinner 12
+ showcontestwinner CONTEST_WINNER_MUSEUM_SMART
releaseall
end
LilycoveCity_LilycoveMuseum_2F_EventScript_ShowToughPainting:: @ 82199DD
msgbox LilycoveCity_LilycoveMuseum_2F_Text_ItsPaintingOfPokemon, MSGBOX_SIGN
fadescreen FADE_TO_BLACK
- showcontestwinner 13
+ showcontestwinner CONTEST_WINNER_MUSEUM_TOUGH
releaseall
end
diff --git a/data/maps/UnionRoom/scripts.inc b/data/maps/UnionRoom/scripts.inc
index eac27fb5c..5a478970d 100644
--- a/data/maps/UnionRoom/scripts.inc
+++ b/data/maps/UnionRoom/scripts.inc
@@ -20,7 +20,7 @@ UnionRoom_OnResume: @ 823D1B1
removeobject 5
removeobject 4
removeobject 3
- special UnionRoomSpecial
+ special RunUnionRoom
end
UnionRoom_OnTransition: @ 823D1E5
@@ -29,7 +29,7 @@ UnionRoom_OnTransition: @ 823D1E5
UnionRoom_EventScript_Player1:: @ 823D1E6
lock
faceplayer
- setvar VAR_RESULT, 1
+ setvar VAR_RESULT, UR_INTERACT_PLAYER_1
waitstate
release
end
@@ -37,7 +37,7 @@ UnionRoom_EventScript_Player1:: @ 823D1E6
UnionRoom_EventScript_Player2:: @ 823D1F0
lock
faceplayer
- setvar VAR_RESULT, 2
+ setvar VAR_RESULT, UR_INTERACT_PLAYER_2
waitstate
release
end
@@ -45,7 +45,7 @@ UnionRoom_EventScript_Player2:: @ 823D1F0
UnionRoom_EventScript_Player3:: @ 823D1FA
lock
faceplayer
- setvar VAR_RESULT, 3
+ setvar VAR_RESULT, UR_INTERACT_PLAYER_3
waitstate
release
end
@@ -53,7 +53,7 @@ UnionRoom_EventScript_Player3:: @ 823D1FA
UnionRoom_EventScript_Player4:: @ 823D204
lock
faceplayer
- setvar VAR_RESULT, 4
+ setvar VAR_RESULT, UR_INTERACT_PLAYER_4
waitstate
release
end
@@ -61,7 +61,7 @@ UnionRoom_EventScript_Player4:: @ 823D204
UnionRoom_EventScript_Player5:: @ 823D20E
lock
faceplayer
- setvar VAR_RESULT, 5
+ setvar VAR_RESULT, UR_INTERACT_PLAYER_5
waitstate
release
end
@@ -69,7 +69,7 @@ UnionRoom_EventScript_Player5:: @ 823D20E
UnionRoom_EventScript_Player6:: @ 823D218
lock
faceplayer
- setvar VAR_RESULT, 6
+ setvar VAR_RESULT, UR_INTERACT_PLAYER_6
waitstate
release
end
@@ -77,7 +77,7 @@ UnionRoom_EventScript_Player6:: @ 823D218
UnionRoom_EventScript_Player7:: @ 823D222
lock
faceplayer
- setvar VAR_RESULT, 7
+ setvar VAR_RESULT, UR_INTERACT_PLAYER_7
waitstate
release
end
@@ -85,7 +85,7 @@ UnionRoom_EventScript_Player7:: @ 823D222
UnionRoom_EventScript_Player8:: @ 823D22C
lock
faceplayer
- setvar VAR_RESULT, 8
+ setvar VAR_RESULT, UR_INTERACT_PLAYER_8
waitstate
release
end
@@ -93,14 +93,14 @@ UnionRoom_EventScript_Player8:: @ 823D22C
UnionRoom_EventScript_Attendant:: @ 823D236
lock
faceplayer
- setvar VAR_RESULT, 9
+ setvar VAR_RESULT, UR_INTERACT_ATTENDANT
waitstate
release
end
UnionRoom_EventScript_Unused:: @ 823D240
lockall
- setvar VAR_RESULT, 10
+ setvar VAR_RESULT, UR_INTERACT_UNUSED
waitstate
releaseall
end
diff --git a/data/scripts/berry_blender.inc b/data/scripts/berry_blender.inc
index 975408daf..28c3d6de7 100644
--- a/data/scripts/berry_blender.inc
+++ b/data/scripts/berry_blender.inc
@@ -600,15 +600,15 @@ BerryBlender_EventScript_TryDoLinkBlender: @ 82940BB
waitmessage
special TryBerryBlenderLinkup
waitstate
- compare VAR_RESULT, 1
+ compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq BerryBlender_EventScript_SpawnLinkPartners
- compare VAR_RESULT, 2
+ compare VAR_RESULT, LINKUP_SOMEONE_NOT_READY
goto_if_eq BerryBlender_EventScript_CloseLinkNotReady
- compare VAR_RESULT, 3
+ compare VAR_RESULT, LINKUP_DIFF_SELECTIONS
goto_if_eq BerryBlender_EventScript_CloseLinkDifferentSelections
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq BerryBlender_EventScript_CloseLink
- compare VAR_RESULT, 6
+ compare VAR_RESULT, LINKUP_CONNECTION_ERROR
goto_if_eq BerryBlender_EventScript_LinkError
end
@@ -712,22 +712,22 @@ BerryBlender_EventScript_DecideLinkLeader: @ 82941F8
BerryBlender_EventScript_TryLeadGroup: @ 8294235
call BerryBlender_EventScript_TryBecomeLinkLeader
- compare VAR_RESULT, 1
+ compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq BerryBlender_EventScript_LinkLeaderDecided
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq BerryBlender_EventScript_DecideLinkLeader
- compare VAR_RESULT, 8
+ compare VAR_RESULT, LINKUP_RETRY_ROLE_ASSIGN
goto_if_eq BerryBlender_EventScript_TryLeadGroup
release
end
BerryBlender_EventScript_TryJoinGroup: @ 829425D
call BerryBlender_EventScript_TryJoinLinkGroup
- compare VAR_RESULT, 1
+ compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq BerryBlender_EventScript_LinkLeaderDecided
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq BerryBlender_EventScript_DecideLinkLeader
- compare VAR_RESULT, 8
+ compare VAR_RESULT, LINKUP_RETRY_ROLE_ASSIGN
goto_if_eq BerryBlender_EventScript_TryJoinGroup
release
end
diff --git a/data/scripts/cable_club.inc b/data/scripts/cable_club.inc
index 6d5702f74..66cf74f0a 100644
--- a/data/scripts/cable_club.inc
+++ b/data/scripts/cable_club.inc
@@ -349,17 +349,17 @@ CableClub_EventScript_TryEnterColosseum:: @ 8276F60
waitmessage
special TryBattleLinkup
waitstate
- compare VAR_RESULT, 1
+ compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq CableClub_EventScript_EnterColosseum
- compare VAR_RESULT, 2
+ compare VAR_RESULT, LINKUP_SOMEONE_NOT_READY
goto_if_eq CableClub_EventScript_AbortLinkSomeoneNotReady
- compare VAR_RESULT, 3
+ compare VAR_RESULT, LINKUP_DIFF_SELECTIONS
goto_if_eq CableClub_EventScript_AbortLinkDifferentSelections
- compare VAR_RESULT, 4
+ compare VAR_RESULT, LINKUP_WRONG_NUM_PLAYERS
goto_if_eq CableClub_EventScript_AbortLinkIncorrectNumberOfBattlers
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq CableClub_EventScript_AbortLink
- compare VAR_RESULT, 6
+ compare VAR_RESULT, LINKUP_CONNECTION_ERROR
goto_if_eq CableClub_EventScript_AbortLinkConnectionError
end
@@ -452,21 +452,21 @@ CableClub_EventScript_TradeCenter:: @ 82770B2
waitmessage
special TryTradeLinkup
waitstate
- compare VAR_RESULT, 1
+ compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq CableClub_EventScript_EnterTradeCenter
- compare VAR_RESULT, 2
+ compare VAR_RESULT, LINKUP_SOMEONE_NOT_READY
goto_if_eq CableClub_EventScript_AbortLinkSomeoneNotReady
- compare VAR_RESULT, 3
+ compare VAR_RESULT, LINKUP_DIFF_SELECTIONS
goto_if_eq CableClub_EventScript_AbortLinkDifferentSelections
- compare VAR_RESULT, 4
+ compare VAR_RESULT, LINKUP_WRONG_NUM_PLAYERS
goto_if_eq CableClub_EventScript_AbortLinkIncorrectNumberOfParticipants
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq CableClub_EventScript_AbortLink
- compare VAR_RESULT, 6
+ compare VAR_RESULT, LINKUP_CONNECTION_ERROR
goto_if_eq CableClub_EventScript_AbortLinkConnectionError
- compare VAR_RESULT, 7
+ compare VAR_RESULT, LINKUP_PLAYER_NOT_READY
goto_if_eq CableClub_EventScript_AbortLinkPlayerNotReady
- compare VAR_RESULT, 9
+ compare VAR_RESULT, LINKUP_PARTNER_NOT_READY
goto_if_eq CableClub_EventScript_AbortLinkOtherTrainerNotReady
end
@@ -527,21 +527,21 @@ CableClub_EventScript_RecordCorner:: @ 82771DB
waitmessage
special TryRecordMixLinkup
waitstate
- special sub_80B2EA8
+ special ValidateMixingGameLanguage
waitstate
- compare VAR_RESULT, 12
+ compare VAR_RESULT, LINKUP_FOREIGN_GAME
goto_if_eq CableClub_EventScript_AbortLinkForeignGame
- compare VAR_RESULT, 1
+ compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq CableClub_EventScript_EnterRecordCorner
- compare VAR_RESULT, 2
+ compare VAR_RESULT, LINKUP_SOMEONE_NOT_READY
goto_if_eq CableClub_EventScript_AbortLinkSomeoneNotReady
- compare VAR_RESULT, 3
+ compare VAR_RESULT, LINKUP_DIFF_SELECTIONS
goto_if_eq CableClub_EventScript_AbortLinkDifferentSelections
- compare VAR_RESULT, 4
+ compare VAR_RESULT, LINKUP_WRONG_NUM_PLAYERS
goto_if_eq CableClub_EventScript_AbortLinkIncorrectNumberOfParticipants
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq CableClub_EventScript_AbortLink
- compare VAR_RESULT, 6
+ compare VAR_RESULT, LINKUP_CONNECTION_ERROR
goto_if_eq CableClub_EventScript_AbortLinkConnectionError
end
@@ -972,7 +972,7 @@ CableClub_EventScript_EnterUnionRoom:: @ 827759F
special SetCableClubWarp
warpteleport2 MAP_UNION_ROOM, 255, 7, 11
waitstate
- special UnionRoomSpecial
+ special RunUnionRoom
waitstate
end
@@ -1181,22 +1181,22 @@ CableClub_EventScript_ChooseLinkLeaderFrom2:: @ 8277989
CableClub_EventScript_TryLeadGroup2Players:: @ 82779C6
call CableClub_EventScript_TryBecomeLinkLeader
- compare VAR_RESULT, 1
+ compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq CableClub_EventScript_EnterWirelessLinkRoom
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq CableClub_EventScript_ChooseLinkLeaderFrom2
- compare VAR_RESULT, 8
+ compare VAR_RESULT, LINKUP_RETRY_ROLE_ASSIGN
goto_if_eq CableClub_EventScript_TryLeadGroup2Players
release
return
CableClub_EventScript_TryJoinGroup2Players:: @ 82779EE
call CableClub_EventScript_TryJoinLinkGroup
- compare VAR_RESULT, 1
+ compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq CableClub_EventScript_EnterWirelessLinkRoom
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq CableClub_EventScript_ChooseLinkLeaderFrom2
- compare VAR_RESULT, 8
+ compare VAR_RESULT, LINKUP_RETRY_ROLE_ASSIGN
goto_if_eq CableClub_EventScript_TryJoinGroup2Players
release
return
@@ -1214,22 +1214,22 @@ CableClub_EventScript_ChooseLinkLeaderFrom4:: @ 8277A16
CableClub_EventScript_TryLeadGroup4Players:: @ 8277A53
call CableClub_EventScript_TryBecomeLinkLeader
- compare VAR_RESULT, 1
+ compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq CableClub_EventScript_EnterWirelessLinkRoom
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq CableClub_EventScript_ChooseLinkLeaderFrom4
- compare VAR_RESULT, 8
+ compare VAR_RESULT, LINKUP_RETRY_ROLE_ASSIGN
goto_if_eq CableClub_EventScript_TryLeadGroup4Players
release
return
CableClub_EventScript_TryJoinGroup4Players:: @ 8277A7B
call CableClub_EventScript_TryJoinLinkGroup
- compare VAR_RESULT, 1
+ compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq CableClub_EventScript_EnterWirelessLinkRoom
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq CableClub_EventScript_ChooseLinkLeaderFrom4
- compare VAR_RESULT, 8
+ compare VAR_RESULT, LINKUP_RETRY_ROLE_ASSIGN
goto_if_eq CableClub_EventScript_TryJoinGroup4Players
release
return
@@ -1247,22 +1247,22 @@ CableClub_EventScript_ChooseLinkLeader:: @ 8277AA3
CableClub_EventScript_TryLeadGroupXPlayers:: @ 8277AE0
call CableClub_EventScript_TryBecomeLinkLeader
- compare VAR_RESULT, 1
+ compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq CableClub_EventScript_EnterWirelessLinkRoom
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq CableClub_EventScript_ChooseLinkLeader
- compare VAR_RESULT, 8
+ compare VAR_RESULT, LINKUP_RETRY_ROLE_ASSIGN
goto_if_eq CableClub_EventScript_TryLeadGroupXPlayers
release
return
CableClub_EventScript_TryJoinGroupXPlayers:: @ 8277B08
call CableClub_EventScript_TryJoinLinkGroup
- compare VAR_RESULT, 1
+ compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq CableClub_EventScript_EnterWirelessLinkRoom
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq CableClub_EventScript_ChooseLinkLeader
- compare VAR_RESULT, 8
+ compare VAR_RESULT, LINKUP_RETRY_ROLE_ASSIGN
goto_if_eq CableClub_EventScript_TryJoinGroupXPlayers
release
return
@@ -1310,7 +1310,7 @@ EventScript_WirelessBoxResults:: @ 8277B8A
compare VAR_RESULT, FALSE
goto_if_eq CableClub_EventScript_AdapterNotConnected
fadescreen FADE_TO_BLACK
- special sub_801A42C
+ special ShowWirelessCommunicationScreen
waitstate
msgbox CableClub_Text_ParticipantsStepUpToCounter, MSGBOX_DEFAULT
releaseall
@@ -1453,22 +1453,22 @@ MossdeepCity_GameCorner_1F_EventScript_ChooseLinkLeader:: @ 8277D81
MossdeepCity_GameCorner_1F_EventScript_TryBecomeLinkLeader:: @ 8277DBE
call CableClub_EventScript_TryBecomeLinkLeader
- compare VAR_RESULT, 1
+ compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq MossdeepCity_GameCorner_1F_EventScript_EnterMinigameRoom
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq MossdeepCity_GameCorner_1F_EventScript_ChooseLinkLeader
- compare VAR_RESULT, 8
+ compare VAR_RESULT, LINKUP_RETRY_ROLE_ASSIGN
goto_if_eq MossdeepCity_GameCorner_1F_EventScript_TryBecomeLinkLeader
release
return
MossdeepCity_GameCorner_1F_EventScript_TryJoinLinkGroup:: @ 8277DE6
call CableClub_EventScript_TryJoinLinkGroup
- compare VAR_RESULT, 1
+ compare VAR_RESULT, LINKUP_SUCCESS
goto_if_eq MossdeepCity_GameCorner_1F_EventScript_EnterMinigameRoom
- compare VAR_RESULT, 5
+ compare VAR_RESULT, LINKUP_FAILED
goto_if_eq MossdeepCity_GameCorner_1F_EventScript_ChooseLinkLeader
- compare VAR_RESULT, 8
+ compare VAR_RESULT, LINKUP_RETRY_ROLE_ASSIGN
goto_if_eq MossdeepCity_GameCorner_1F_EventScript_TryJoinLinkGroup
release
return
diff --git a/data/specials.inc b/data/specials.inc
index 97cc3c782..0f78f981f 100644
--- a/data/specials.inc
+++ b/data/specials.inc
@@ -39,7 +39,7 @@ gSpecials:: @ 81DBA64
def_special TryBattleLinkup
def_special TryTradeLinkup
def_special TryRecordMixLinkup
- def_special sub_80B2EA8
+ def_special ValidateMixingGameLanguage
def_special CloseLink
def_special ColosseumPlayerSpotTriggered
def_special PlayerEnteredTradeSeat
@@ -426,8 +426,8 @@ gSpecials:: @ 81DBA64
def_special IsWirelessAdapterConnected
def_special TryBecomeLinkLeader
def_special TryJoinLinkGroup
- def_special UnionRoomSpecial
- def_special sub_801A42C
+ def_special RunUnionRoom
+ def_special ShowWirelessCommunicationScreen
def_special InitUnionRoom
def_special BufferUnionRoomPlayerName
def_special sub_801DC20
@@ -498,11 +498,11 @@ gSpecials:: @ 81DBA64
def_special GetPCBoxToSendMon
def_special ShouldShowBoxWasFullMessage
def_special SetMatchCallRegisteredFlag
- def_special DoConfettiEffect
+ def_special DoDomeConfetti
def_special CreateAbnormalWeatherEvent
def_special GetAbnormalWeatherMapNameAndType
def_special GetMartEmployeeObjectEventId
- def_special sub_80A08CC
+ def_special SaveForBattleTowerLink
def_special Unused_SetWeatherSunny
def_special SetUnlockedPokedexFlags
def_special IsTrainerRegistered
diff --git a/gflib/text.h b/gflib/text.h
index 4819eb37b..5b317600e 100644
--- a/gflib/text.h
+++ b/gflib/text.h
@@ -1,95 +1,183 @@
#ifndef GUARD_TEXT_H
#define GUARD_TEXT_H
-#define CHAR_SPACE 0x00
-#define CHAR_PLUS 0x2E
-#define CHAR_0 0xA1
-#define CHAR_1 0xA2
-#define CHAR_2 0xA3
-#define CHAR_3 0xA4
-#define CHAR_4 0xA5
-#define CHAR_5 0xA6
-#define CHAR_6 0xA7
-#define CHAR_7 0xA8
-#define CHAR_8 0xA9
-#define CHAR_9 0xAA
-#define CHAR_EXCL_MARK 0xAB
-#define CHAR_QUESTION_MARK 0xAC
-#define CHAR_PERIOD 0xAD
-#define CHAR_HYPHEN 0xAE
-#define CHAR_ELLIPSIS 0xB0
-#define CHAR_DBL_QUOT_LEFT 0xB1
-#define CHAR_DBL_QUOT_RIGHT 0xB2
-#define CHAR_SGL_QUOT_LEFT 0xB3
-#define CHAR_SGL_QUOT_RIGHT 0xB4
-#define CHAR_MALE 0xB5
-#define CHAR_FEMALE 0xB6
-#define CHAR_CURRENCY 0xB7
-#define CHAR_COMMA 0xB8
-#define CHAR_MULT_SIGN 0xB9
-#define CHAR_SLASH 0xBA
-#define CHAR_A 0xBB
-#define CHAR_B 0xBC
-#define CHAR_C 0xBD
-#define CHAR_D 0xBE
-#define CHAR_E 0xBF
-#define CHAR_F 0xC0
-#define CHAR_G 0xC1
-#define CHAR_H 0xC2
-#define CHAR_I 0xC3
-#define CHAR_J 0xC4
-#define CHAR_K 0xC5
-#define CHAR_L 0xC6
-#define CHAR_M 0xC7
-#define CHAR_N 0xC8
-#define CHAR_O 0xC9
-#define CHAR_P 0xCA
-#define CHAR_Q 0xCB
-#define CHAR_R 0xCC
-#define CHAR_S 0xCD
-#define CHAR_T 0xCE
-#define CHAR_U 0xCF
-#define CHAR_V 0xD0
-#define CHAR_W 0xD1
-#define CHAR_X 0xD2
-#define CHAR_Y 0xD3
-#define CHAR_Z 0xD4
-#define CHAR_a 0xD5
-#define CHAR_b 0xD6
-#define CHAR_c 0xD7
-#define CHAR_d 0xD8
-#define CHAR_e 0xD9
-#define CHAR_f 0xDA
-#define CHAR_g 0xDB
-#define CHAR_h 0xDC
-#define CHAR_i 0xDD
-#define CHAR_j 0xDE
-#define CHAR_k 0xDF
-#define CHAR_l 0xE0
-#define CHAR_m 0xE1
-#define CHAR_n 0xE2
-#define CHAR_o 0xE3
-#define CHAR_p 0xE4
-#define CHAR_q 0xE5
-#define CHAR_r 0xE6
-#define CHAR_s 0xE7
-#define CHAR_t 0xE8
-#define CHAR_u 0xE9
-#define CHAR_v 0xEA
-#define CHAR_w 0xEB
-#define CHAR_x 0xEC
-#define CHAR_y 0xED
-#define CHAR_z 0xEE
-#define CHAR_SPECIAL_F7 0xF7
-#define CHAR_SPECIAL_F8 0xF8
-#define CHAR_SPECIAL_F9 0xF9
-#define CHAR_COLON 0xF0
-#define CHAR_PROMPT_SCROLL 0xFA // waits for button press and scrolls dialog
-#define CHAR_PROMPT_CLEAR 0xFB // waits for button press and clears dialog
-#define EXT_CTRL_CODE_BEGIN 0xFC // extended control code
-#define PLACEHOLDER_BEGIN 0xFD // string placeholder
-#define CHAR_NEWLINE 0xFE
-#define EOS 0xFF // end of string
+#define CHAR_SPACE 0x00
+#define CHAR_A_GRAVE 0x01
+#define CHAR_A_ACUTE 0x02
+#define CHAR_A_CIRCUMFLEX 0x03
+#define CHAR_C_CEDILLA 0x04
+#define CHAR_E_GRAVE 0x05
+#define CHAR_E_ACUTE 0x06
+#define CHAR_E_CIRCUMFLEX 0x07
+#define CHAR_E_DIAERESIS 0x08
+#define CHAR_I_GRAVE 0x09
+//#define CHAR_I_ACUTE 0x0A // Is 0x5A instead
+#define CHAR_I_CIRCUMFLEX 0x0B
+#define CHAR_I_DIAERESIS 0x0C
+#define CHAR_O_GRAVE 0x0D
+#define CHAR_O_ACUTE 0x0E
+#define CHAR_O_CIRCUMFLEX 0x0F
+#define CHAR_OE 0x10
+#define CHAR_U_GRAVE 0x11
+#define CHAR_U_ACUTE 0x12
+#define CHAR_U_CIRCUMFLEX 0x13
+#define CHAR_N_TILDE 0x14
+#define CHAR_ESZETT 0x15
+#define CHAR_a_GRAVE 0x16
+#define CHAR_a_ACUTE 0x17
+//#define CHAR_a_CIRCUMFLEX 0x18 // Is 0x68 instead
+#define CHAR_c_CEDILLA 0x19
+#define CHAR_e_GRAVE 0x1A
+#define CHAR_e_ACUTE 0x1B
+#define CHAR_e_CIRCUMFLEX 0x1C
+#define CHAR_e_DIAERESIS 0x1D
+#define CHAR_i_GRAVE 0x1E
+//#define CHAR_i_ACUTE 0x1F // Is 0x6F instead
+#define CHAR_i_CIRCUMFLEX 0x20
+#define CHAR_i_DIAERESIS 0x21
+#define CHAR_o_GRAVE 0x22
+#define CHAR_o_ACUTE 0x23
+#define CHAR_o_CIRCUMFLEX 0x24
+#define CHAR_oe 0x25
+#define CHAR_u_GRAVE 0x26
+#define CHAR_u_ACUTE 0x27
+#define CHAR_u_CIRCUMFLEX 0x28
+#define CHAR_n_TILDE 0x29
+#define CHAR_MASCULINE_ORDINAL 0x2A
+#define CHAR_FEMININE_ORDINAL 0x2B
+#define CHAR_SUPER_ER 0x2C
+#define CHAR_AMPERSAND 0x2D
+#define CHAR_PLUS 0x2E
+//
+#define CHAR_LV 0x34
+#define CHAR_EQUALS 0x35
+#define CHAR_SEMICOLON 0x36
+//
+#define CHAR_INV_QUESTION_MARK 0x51
+#define CHAR_INV_EXCL_MARK 0x52
+#define CHAR_PK 0x53
+#define CHAR_MN 0x54
+#define CHAR_PO 0x55
+#define CHAR_KE 0x56
+#define CHAR_BLOCK_1 0x57 // Each of these 3
+#define CHAR_BLOCK_2 0x58 // chars contains 1/3
+#define CHAR_BLOCK_3 0x59 // of the word BLOCK
+#define CHAR_I_ACUTE 0x5A
+#define CHAR_PERCENT 0x5B
+#define CHAR_LEFT_PAREN 0x5C
+#define CHAR_RIGHT_PAREN 0x5D
+//
+#define CHAR_a_CIRCUMFLEX 0x68
+//
+#define CHAR_i_ACUTE 0x6F
+//
+#define CHAR_UNK_SPACER 0x77
+//
+#define CHAR_UP_ARROW 0x79
+#define CHAR_DOWN_ARROW 0x7A
+#define CHAR_LEFT_ARROW 0x7B
+#define CHAR_RIGHT_ARROW 0x7C
+//
+#define CHAR_SUPER_E 0x84
+#define CHAR_LESS_THAN 0x85
+#define CHAR_GREATER_THAN 0x86
+//
+#define CHAR_SUPER_RE 0xA0
+#define CHAR_0 0xA1
+#define CHAR_1 0xA2
+#define CHAR_2 0xA3
+#define CHAR_3 0xA4
+#define CHAR_4 0xA5
+#define CHAR_5 0xA6
+#define CHAR_6 0xA7
+#define CHAR_7 0xA8
+#define CHAR_8 0xA9
+#define CHAR_9 0xAA
+#define CHAR_EXCL_MARK 0xAB
+#define CHAR_QUESTION_MARK 0xAC
+#define CHAR_PERIOD 0xAD
+#define CHAR_HYPHEN 0xAE
+#define CHAR_BULLET 0xAF
+#define CHAR_ELLIPSIS 0xB0
+#define CHAR_DBL_QUOT_LEFT 0xB1
+#define CHAR_DBL_QUOT_RIGHT 0xB2
+#define CHAR_SGL_QUOT_LEFT 0xB3
+#define CHAR_SGL_QUOT_RIGHT 0xB4
+#define CHAR_MALE 0xB5
+#define CHAR_FEMALE 0xB6
+#define CHAR_CURRENCY 0xB7
+#define CHAR_COMMA 0xB8
+#define CHAR_MULT_SIGN 0xB9
+#define CHAR_SLASH 0xBA
+#define CHAR_A 0xBB
+#define CHAR_B 0xBC
+#define CHAR_C 0xBD
+#define CHAR_D 0xBE
+#define CHAR_E 0xBF
+#define CHAR_F 0xC0
+#define CHAR_G 0xC1
+#define CHAR_H 0xC2
+#define CHAR_I 0xC3
+#define CHAR_J 0xC4
+#define CHAR_K 0xC5
+#define CHAR_L 0xC6
+#define CHAR_M 0xC7
+#define CHAR_N 0xC8
+#define CHAR_O 0xC9
+#define CHAR_P 0xCA
+#define CHAR_Q 0xCB
+#define CHAR_R 0xCC
+#define CHAR_S 0xCD
+#define CHAR_T 0xCE
+#define CHAR_U 0xCF
+#define CHAR_V 0xD0
+#define CHAR_W 0xD1
+#define CHAR_X 0xD2
+#define CHAR_Y 0xD3
+#define CHAR_Z 0xD4
+#define CHAR_a 0xD5
+#define CHAR_b 0xD6
+#define CHAR_c 0xD7
+#define CHAR_d 0xD8
+#define CHAR_e 0xD9
+#define CHAR_f 0xDA
+#define CHAR_g 0xDB
+#define CHAR_h 0xDC
+#define CHAR_i 0xDD
+#define CHAR_j 0xDE
+#define CHAR_k 0xDF
+#define CHAR_l 0xE0
+#define CHAR_m 0xE1
+#define CHAR_n 0xE2
+#define CHAR_o 0xE3
+#define CHAR_p 0xE4
+#define CHAR_q 0xE5
+#define CHAR_r 0xE6
+#define CHAR_s 0xE7
+#define CHAR_t 0xE8
+#define CHAR_u 0xE9
+#define CHAR_v 0xEA
+#define CHAR_w 0xEB
+#define CHAR_x 0xEC
+#define CHAR_y 0xED
+#define CHAR_z 0xEE
+#define CHAR_BLACK_TRIANGLE 0xEF
+#define CHAR_COLON 0xF0
+#define CHAR_A_DIAERESIS 0xF1
+#define CHAR_O_DIAERESIS 0xF2
+#define CHAR_U_DIAERESIS 0xF3
+#define CHAR_a_DIAERESIS 0xF4
+#define CHAR_o_DIAERESIS 0xF5
+#define CHAR_u_DIAERESIS 0xF6
+#define CHAR_SPECIAL_F7 0xF7
+#define CHAR_SPECIAL_F8 0xF8
+#define CHAR_SPECIAL_F9 0xF9
+#define CHAR_PROMPT_SCROLL 0xFA // waits for button press and scrolls dialog
+#define CHAR_PROMPT_CLEAR 0xFB // waits for button press and clears dialog
+#define EXT_CTRL_CODE_BEGIN 0xFC // extended control code
+#define PLACEHOLDER_BEGIN 0xFD // string placeholder
+#define CHAR_NEWLINE 0xFE
+#define EOS 0xFF // end of string
// Special F9 chars
#define CHAR_UP_ARROW_2 0x00
diff --git a/graphics/contest/clink_tilemap11.bin b/graphics/contest/results_screen.bin
index 3b46e00b8..3b46e00b8 100644
--- a/graphics/contest/clink_tilemap11.bin
+++ b/graphics/contest/results_screen.bin
Binary files differ
diff --git a/graphics/contest/misc_2.pal b/graphics/contest/results_screen.pal
index 869aef9e1..869aef9e1 100644
--- a/graphics/contest/misc_2.pal
+++ b/graphics/contest/results_screen.pal
diff --git a/graphics/contest/misc_2.png b/graphics/contest/results_screen.png
index 106b975cf..106b975cf 100644
--- a/graphics/contest/misc_2.png
+++ b/graphics/contest/results_screen.png
Binary files differ
diff --git a/graphics/contest/clink_tilemap7.bin b/graphics/contest/results_screen_beauty.bin
index fe02ec0b5..fe02ec0b5 100644
--- a/graphics/contest/clink_tilemap7.bin
+++ b/graphics/contest/results_screen_beauty.bin
diff --git a/graphics/contest/clink_tilemap6.bin b/graphics/contest/results_screen_cool.bin
index f3939831e..f3939831e 100644
--- a/graphics/contest/clink_tilemap6.bin
+++ b/graphics/contest/results_screen_cool.bin
Binary files differ
diff --git a/graphics/contest/clink_tilemap8.bin b/graphics/contest/results_screen_cute.bin
index d37d6df3c..d37d6df3c 100644
--- a/graphics/contest/clink_tilemap8.bin
+++ b/graphics/contest/results_screen_cute.bin
diff --git a/graphics/contest/clink_tilemap3.bin b/graphics/contest/results_screen_hyper.bin
index d4bb7bae7..d4bb7bae7 100644
--- a/graphics/contest/clink_tilemap3.bin
+++ b/graphics/contest/results_screen_hyper.bin
Binary files differ
diff --git a/graphics/contest/clink_tilemap5.bin b/graphics/contest/results_screen_link.bin
index cc07b0f1a..cc07b0f1a 100644
--- a/graphics/contest/clink_tilemap5.bin
+++ b/graphics/contest/results_screen_link.bin
Binary files differ
diff --git a/graphics/contest/clink_tilemap4.bin b/graphics/contest/results_screen_master.bin
index 32f24abd6..32f24abd6 100644
--- a/graphics/contest/clink_tilemap4.bin
+++ b/graphics/contest/results_screen_master.bin
Binary files differ
diff --git a/graphics/contest/clink_tilemap1.bin b/graphics/contest/results_screen_normal.bin
index e22f21839..e22f21839 100644
--- a/graphics/contest/clink_tilemap1.bin
+++ b/graphics/contest/results_screen_normal.bin
Binary files differ
diff --git a/graphics/contest/clink_tilemap9.bin b/graphics/contest/results_screen_smart.bin
index 79d2e3fbb..79d2e3fbb 100644
--- a/graphics/contest/clink_tilemap9.bin
+++ b/graphics/contest/results_screen_smart.bin
diff --git a/graphics/contest/clink_tilemap2.bin b/graphics/contest/results_screen_super.bin
index 21c804d12..21c804d12 100644
--- a/graphics/contest/clink_tilemap2.bin
+++ b/graphics/contest/results_screen_super.bin
Binary files differ
diff --git a/graphics/contest/clink_tilemap10.bin b/graphics/contest/results_screen_tough.bin
index 2a91bb78d..2a91bb78d 100644
--- a/graphics/contest/clink_tilemap10.bin
+++ b/graphics/contest/results_screen_tough.bin
diff --git a/graphics/link/misc.bin b/graphics/union_room_chat/background.bin
index e91b50c8d..e91b50c8d 100644
--- a/graphics/link/misc.bin
+++ b/graphics/union_room_chat/background.bin
Binary files differ
diff --git a/graphics/link/misc.png b/graphics/union_room_chat/background.png
index ae6ba4d02..ae6ba4d02 100644
--- a/graphics/link/misc.png
+++ b/graphics/union_room_chat/background.png
Binary files differ
diff --git a/graphics/link/link_winedge.bin b/graphics/union_room_chat/border.bin
index f3e264d05..f3e264d05 100644
--- a/graphics/link/link_winedge.bin
+++ b/graphics/union_room_chat/border.bin
Binary files differ
diff --git a/graphics/link/link_winedge.png b/graphics/union_room_chat/border.png
index 86ddacc03..86ddacc03 100644
--- a/graphics/link/link_winedge.png
+++ b/graphics/union_room_chat/border.png
Binary files differ
diff --git a/graphics/interface/unk_palette3.pal b/graphics/union_room_chat/interface.pal
index 071f73b42..071f73b42 100644
--- a/graphics/interface/unk_palette3.pal
+++ b/graphics/union_room_chat/interface.pal
diff --git a/graphics/interface/unk_cursor.png b/graphics/union_room_chat/keyboard_cursor.png
index fac4e0a93..fac4e0a93 100644
--- a/graphics/interface/unk_cursor.png
+++ b/graphics/union_room_chat/keyboard_cursor.png
Binary files differ
diff --git a/graphics/interface/unk_rbutton.png b/graphics/union_room_chat/r_button.png
index 168a293f3..168a293f3 100644
--- a/graphics/interface/unk_rbutton.png
+++ b/graphics/union_room_chat/r_button.png
Binary files differ
diff --git a/graphics/interface/unk_change_case.png b/graphics/union_room_chat/r_button_labels.png
index 185c4abf5..185c4abf5 100644
--- a/graphics/interface/unk_change_case.png
+++ b/graphics/union_room_chat/r_button_labels.png
Binary files differ
diff --git a/graphics/interface/unk_cursor_arrow.png b/graphics/union_room_chat/text_entry_arrow.png
index 574758cdf..574758cdf 100644
--- a/graphics/interface/unk_cursor_arrow.png
+++ b/graphics/union_room_chat/text_entry_arrow.png
Binary files differ
diff --git a/graphics/interface/unk_dash.png b/graphics/union_room_chat/text_entry_cursor.png
index 34c3709cf..34c3709cf 100644
--- a/graphics/interface/unk_dash.png
+++ b/graphics/union_room_chat/text_entry_cursor.png
Binary files differ
diff --git a/graphics/interface/unk_palette1.pal b/graphics/union_room_chat/unk_palette1.pal
index 12bc76261..12bc76261 100644
--- a/graphics/interface/unk_palette1.pal
+++ b/graphics/union_room_chat/unk_palette1.pal
diff --git a/graphics/interface/unk_palette2.pal b/graphics/union_room_chat/unk_palette2.pal
index d2a55fec6..d2a55fec6 100644
--- a/graphics/interface/unk_palette2.pal
+++ b/graphics/union_room_chat/unk_palette2.pal
diff --git a/graphics/link/link1.pal b/graphics/union_room_chat/window_1.pal
index a86815b0e..a86815b0e 100644
--- a/graphics/link/link1.pal
+++ b/graphics/union_room_chat/window_1.pal
diff --git a/graphics/link/link2.pal b/graphics/union_room_chat/window_2.pal
index a8c95a3c0..a8c95a3c0 100644
--- a/graphics/link/link2.pal
+++ b/graphics/union_room_chat/window_2.pal
diff --git a/include/berry_crush.h b/include/berry_crush.h
index 8909ae821..a08f1f699 100755
--- a/include/berry_crush.h
+++ b/include/berry_crush.h
@@ -3,6 +3,6 @@
#include "main.h"
-void sub_8020C70(MainCallback callback);
+void StartBerryCrush(MainCallback callback);
#endif // GUARD_BERRY_CRUSH_H
diff --git a/include/cable_club.h b/include/cable_club.h
index c2849ca3e..7340742ea 100644
--- a/include/cable_club.h
+++ b/include/cable_club.h
@@ -3,18 +3,12 @@
#include "task.h"
-// Exported type declarations
-
-// Exported RAM declarations
-
-// Exported ROM declarations
-
-void sub_80B37D4(TaskFunc taskFunc);
-u8 sub_80B3050(void);
-void sub_80B360C(void);
-bool32 sub_80B2AF4(u16 *arg0, u16 *arg1);
+void CreateTask_EnterCableClubSeat(TaskFunc taskFunc);
+u8 CreateTask_ReestablishCableClubLink(void);
+void CB2_ReturnFromCableClubBattle(void);
+bool32 AreBattleTowerLinkSpeciesSame(u16 *speciesList1, u16 *speciesList2);
void sub_80B3AF8(u8 taskId);
-void task00_08081A90(u8 taskId);
+void Task_WaitForLinkPlayerConnection(u8 taskId);
bool32 GetLinkTrainerCardColor(u8 linkPlayerIndex);
#endif //GUARD_CABLE_CLUB_H
diff --git a/include/confetti_util.h b/include/confetti_util.h
new file mode 100644
index 000000000..ecc05a220
--- /dev/null
+++ b/include/confetti_util.h
@@ -0,0 +1,33 @@
+#ifndef GUARD_CONFETTI_UTIL_H
+#define GUARD_CONFETTI_UTIL_H
+
+struct ConfettiUtil
+{
+ struct OamData oam;
+ s16 x;
+ s16 y;
+ s16 xDelta;
+ s16 yDelta;
+ u16 tileTag;
+ u16 palTag;
+ u16 tileNum;
+ u8 id;
+ u8 filler;
+ u8 animNum;
+ u8 active:1;
+ u8 allowUpdates:1;
+ u8 dummied:1;
+ u8 priority:2;
+ s16 data[8];
+ void (*callback)(struct ConfettiUtil *);
+};
+
+bool32 ConfettiUtil_Init(u8 count);
+bool32 ConfettiUtil_Free(void);
+bool32 ConfettiUtil_Update(void);
+u8 ConfettiUtil_SetCallback(u8 id, void (*func)(struct ConfettiUtil *));
+u8 ConfettiUtil_SetData(u8 id, u8 dataArrayId, s16 dataValue);
+u8 ConfettiUtil_AddNew(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16 y, u8 animNum, u8 priority);
+u8 ConfettiUtil_Remove(u8 id);
+
+#endif // GUARD_CONFETTI_UTIL_H
diff --git a/include/config.h b/include/config.h
index 318ed39d8..4f97a12a3 100644
--- a/include/config.h
+++ b/include/config.h
@@ -26,4 +26,12 @@
#define UNITS_METRIC
#endif
+// Various undefined behavior bugs may or may not prevent compilation with
+// newer compilers. So always fix them when using a modern compiler.
+#if MODERN
+#ifndef UBFIX
+#define UBFIX
+#endif
+#endif
+
#endif // GUARD_CONFIG_H
diff --git a/include/constants/cable_club.h b/include/constants/cable_club.h
index f2aa4120c..cbdd049db 100644
--- a/include/constants/cable_club.h
+++ b/include/constants/cable_club.h
@@ -12,4 +12,20 @@
#define USING_MINIGAME 8
#define USING_BATTLE_TOWER 9
+// Return states for the group of specials that use CreateLinkupTask
+// A few also used by TryBecomeLinkLeader and TryJoinLinkGroup
+#define LINKUP_ONGOING 0
+#define LINKUP_SUCCESS 1
+#define LINKUP_SOMEONE_NOT_READY 2
+#define LINKUP_DIFF_SELECTIONS 3
+#define LINKUP_WRONG_NUM_PLAYERS 4
+#define LINKUP_FAILED 5
+#define LINKUP_CONNECTION_ERROR 6
+#define LINKUP_PLAYER_NOT_READY 7
+#define LINKUP_RETRY_ROLE_ASSIGN 8
+#define LINKUP_PARTNER_NOT_READY 9
+#define LINKUP_FAILED_CONTEST_GMODE 10
+#define LINKUP_FAILED_BATTLE_TOWER 11
+#define LINKUP_FOREIGN_GAME 12
+
#endif //GUARD_CONSTANTS_CABLE_CLUB_H
diff --git a/include/constants/contest.h b/include/constants/contest.h
index 186c56e2b..2de2866a3 100644
--- a/include/constants/contest.h
+++ b/include/constants/contest.h
@@ -29,6 +29,23 @@
#define CONTEST_CATEGORY_TOUGH 4
#define CONTEST_CATEGORIES_COUNT 5
+#define CONTEST_WINNER_ARTIST 0 // Winner shown by the artist, painting not necessarily saved
+#define CONTEST_WINNER_HALL_1 1
+#define CONTEST_WINNER_HALL_2 2
+#define CONTEST_WINNER_HALL_3 3
+#define CONTEST_WINNER_HALL_4 4
+#define CONTEST_WINNER_HALL_5 5
+#define CONTEST_WINNER_HALL_6 6
+#define NUM_CONTEST_HALL_WINNERS 6
+#define CONTEST_WINNER_7 7
+#define CONTEST_WINNER_8 8
+#define CONTEST_WINNER_MUSEUM_COOL 9
+#define CONTEST_WINNER_MUSEUM_BEAUTY 10
+#define CONTEST_WINNER_MUSEUM_CUTE 11
+#define CONTEST_WINNER_MUSEUM_SMART 12
+#define CONTEST_WINNER_MUSEUM_TOUGH 13
+// NUM_CONTEST_WINNERS in constants/global.h
+
#define CANT_ENTER_CONTEST 0
#define CAN_ENTER_CONTEST_EQUAL_RANK 1
#define CAN_ENTER_CONTEST_HIGH_RANK 2
diff --git a/include/constants/field_specials.h b/include/constants/field_specials.h
index a2dc117e4..a01151378 100644
--- a/include/constants/field_specials.h
+++ b/include/constants/field_specials.h
@@ -75,4 +75,9 @@
#define FANCLUB_MEMBER7 14
#define FANCLUB_MEMBER8 15
+#define FANCOUNTER_DEFEATED_DRAKE 0
+#define FANCOUNTER_BATTLED_AT_BASE 1
+#define FANCOUNTER_FINISHED_CONTEST 2
+#define FANCOUNTER_USED_BATTLE_TOWER 3
+
#endif // GUARD_CONSTANTS_FIELD_SPECIALS_H
diff --git a/include/constants/global.h b/include/constants/global.h
index c7063d71c..956f86a05 100644
--- a/include/constants/global.h
+++ b/include/constants/global.h
@@ -52,6 +52,8 @@
#define APPRENTICE_COUNT 4
#define APPRENTICE_MAX_QUESTIONS 9
#define MAX_REMATCH_ENTRIES 100 // only REMATCH_TABLE_ENTRIES (78) are used
+#define NUM_CONTEST_WINNERS 13
+#define UNION_ROOM_KB_ROW_COUNT 10
#define PYRAMID_BAG_ITEMS_COUNT 10
#define HALL_FACILITIES_COUNT 9 // 7 facilities for single mode + tower double mode + tower multi mode.
diff --git a/include/constants/trainers.h b/include/constants/trainers.h
index 541b131ca..3f22c7cef 100644
--- a/include/constants/trainers.h
+++ b/include/constants/trainers.h
@@ -13,7 +13,7 @@
#define TRAINER_PLAYER 1023
#define TRAINER_SECRET_BASE 1024
#define TRAINER_LINK_OPPONENT 2048
-#define TRAINER_OPPONENT_C00 3072
+#define TRAINER_UNION_ROOM 3072
#define TRAINER_STEVEN_PARTNER 3075
#define TRAINER_PIC_HIKER 0
diff --git a/include/constants/union_room.h b/include/constants/union_room.h
index 2314f85a0..d867fb340 100644
--- a/include/constants/union_room.h
+++ b/include/constants/union_room.h
@@ -1,6 +1,60 @@
#ifndef GUARD_CONSTANTS_UNION_ROOM_H
#define GUARD_CONSTANTS_UNION_ROOM_H
+#define MAX_UNION_ROOM_PLAYERS 8
+
+#define UNION_ROOM_SPAWN_NONE 0
+#define UNION_ROOM_SPAWN_IN 1
+#define UNION_ROOM_SPAWN_OUT 2
+
+#define ACTIVITY_NONE 0
+#define ACTIVITY_BATTLE_SINGLE 1
+#define ACTIVITY_BATTLE_DOUBLE 2
+#define ACTIVITY_BATTLE_MULTI 3
+#define ACTIVITY_TRADE 4
+#define ACTIVITY_CHAT 5
+#define ACTIVITY_WONDER_CARD 6
+#define ACTIVITY_WONDER_NEWS 7
+#define ACTIVITY_CARD 8
+#define ACTIVITY_POKEMON_JUMP 9
+#define ACTIVITY_BERRY_CRUSH 10
+#define ACTIVITY_BERRY_PICK 11
+#define ACTIVITY_SEARCH 12
+#define ACTIVITY_SPIN_TRADE 13
+#define ACTIVITY_BATTLE_TOWER_OPEN 14
+#define ACTIVITY_RECORD_CORNER 15
+#define ACTIVITY_BERRY_BLENDER 16
+
+// Player response
+#define ACTIVITY_ACCEPT 17
+#define ACTIVITY_DECLINE 18
+
+#define ACTIVITY_NPCTALK 19
+#define ACTIVITY_PLYRTALK 20
+
+// Duplicate IDs?
+#define ACTIVITY_WONDER_CARD2 21
+#define ACTIVITY_WONDER_NEWS2 22
+
+#define ACTIVITY_CONTEST_COOL 23
+#define ACTIVITY_CONTEST_BEAUTY 24
+#define ACTIVITY_CONTEST_CUTE 25
+#define ACTIVITY_CONTEST_SMART 26
+#define ACTIVITY_CONTEST_TOUGH 27
+#define ACTIVITY_BATTLE_TOWER 28
+#define ACTIVITY_29 29
+
+#define IN_UNION_ROOM (1 << 6)
+
+// Used in UR_AddTextPrinterParameterized
+#define UR_COLOR_DKE_WHT_LTE 0
+#define UR_COLOR_RED_WHT_LTR 1
+#define UR_COLOR_GRN_WHT_LTG 2
+#define UR_COLOR_WHT_WHT_LTE 3
+#define UR_COLOR_WHT_DKE_LTE 4
+#define UR_COLOR_GRN_DN6_LTB 5
+#define UR_COLOR_DN5_DN6_LTB 6
+
#define LINK_GROUP_SINGLE_BATTLE 0
#define LINK_GROUP_DOUBLE_BATTLE 1
#define LINK_GROUP_MULTI_BATTLE 2
@@ -10,8 +64,8 @@
#define LINK_GROUP_BERRY_PICKING 6
#define LINK_GROUP_WONDER_CARD 7
#define LINK_GROUP_WONDER_NEWS 8
-#define LINK_GROUP_UNK_9 9
-#define LINK_GROUP_UNK_10 10
+#define LINK_GROUP_UNION_ROOM_RESUME 9
+#define LINK_GROUP_UNION_ROOM_INIT 10
#define LINK_GROUP_UNK_11 11
#define LINK_GROUP_RECORD_CORNER 12
#define LINK_GROUP_BERRY_BLENDER 13
@@ -25,4 +79,24 @@
#define LINK_GROUP_BATTLE_TOWER_OPEN 21
#define NUM_LINK_GROUP_TYPES 22
+#define UR_TRADE_MATCH 0
+#define UR_TRADE_NOTYPE 1
+#define UR_TRADE_NOEGG 2
+
+#define UR_TRADE_READY 0
+#define UR_TRADE_PLAYER_NOT_READY 1
+#define UR_TRADE_PARTNER_NOT_READY 2
+
+#define UR_INTERACT_PLAYER_1 1
+#define UR_INTERACT_PLAYER_2 2
+#define UR_INTERACT_PLAYER_3 3
+#define UR_INTERACT_PLAYER_4 4
+#define UR_INTERACT_PLAYER_5 5
+#define UR_INTERACT_PLAYER_6 6
+#define UR_INTERACT_PLAYER_7 7
+#define UR_INTERACT_PLAYER_8 8
+#define UR_INTERACT_ATTENDANT 9
+#define UR_INTERACT_UNUSED 10
+#define UR_INTERACT_START_MENU 11
+
#endif //GUARD_CONSTANTS_UNION_ROOM_H
diff --git a/include/contest.h b/include/contest.h
index 00c3191eb..a9b1db9ee 100644
--- a/include/contest.h
+++ b/include/contest.h
@@ -430,9 +430,9 @@ struct ContestResources
extern struct ContestPokemon gContestMons[CONTESTANT_COUNT];
extern s16 gContestMonConditions[CONTESTANT_COUNT];
-extern s16 gUnknown_02039F08[CONTESTANT_COUNT];
+extern s16 gContestMonTotalPoints[CONTESTANT_COUNT];
extern s16 gUnknown_02039F10[CONTESTANT_COUNT];
-extern s16 gUnknown_02039F18[CONTESTANT_COUNT];
+extern s16 gContestMonRound2Points[CONTESTANT_COUNT];
extern u8 gContestFinalStandings[CONTESTANT_COUNT];
extern u8 gContestMonPartyIndex;
extern u8 gContestPlayerMonIndex;
@@ -448,7 +448,6 @@ extern u8 sContestBgCopyFlags;
extern struct ContestWinner gCurContestWinner;
extern u8 gUnknown_02039F5C;
extern u8 gUnknown_02039F5D;
-
extern u32 gContestRngValue;
// contest.c
diff --git a/include/contest_link_80FC4F4.h b/include/contest_link.h
index a3f118798..4344d55ad 100644
--- a/include/contest_link_80FC4F4.h
+++ b/include/contest_link.h
@@ -1,5 +1,5 @@
-#ifndef GUARD_CONTEST_LINK_80FC4F4_H
-#define GUARD_CONTEST_LINK_80FC4F4_H
+#ifndef GUARD_CONTEST_LINK_H
+#define GUARD_CONTEST_LINK_H
void sub_80FCC88(u8);
void sub_80FCC88(u8);
@@ -10,4 +10,4 @@ void sub_80FC804(u8);
void sub_80FCE48(u8);
void sub_80FC894(u8);
-#endif //GUARD_CONTEST_LINK_80FC4F4_H
+#endif //GUARD_CONTEST_LINK_H
diff --git a/include/contest_link_80F57C4.h b/include/contest_util.h
index add3ae62f..c0d8df031 100644
--- a/include/contest_link_80F57C4.h
+++ b/include/contest_util.h
@@ -1,12 +1,12 @@
-#ifndef GUARD_CONTEST_LINK_80F57C4_H
-#define GUARD_CONTEST_LINK_80F57C4_H
+#ifndef GUARD_CONTEST_UTIL_H
+#define GUARD_CONTEST_UTIL_H
void BufferContestantTrainerName(void);
void BufferContestantMonNickname(void);
void StartContest(void);
void BufferContestantMonSpecies(void);
-void sub_80F8484(void);
-void sub_80F84C4(u8);
+void ShowContestResults(void);
+void ContestLinkTransfer(u8);
void sub_80FC998(u8 taskId);
-#endif // GUARD_CONTEST_LINK_80F57C4_H
+#endif // GUARD_CONTEST_UTIL_H
diff --git a/include/dodrio_berry_picking.h b/include/dodrio_berry_picking.h
index 9995decc2..5decbeccb 100644
--- a/include/dodrio_berry_picking.h
+++ b/include/dodrio_berry_picking.h
@@ -1,7 +1,7 @@
#ifndef GUARD_DODRIO_BERRY_PICKING_H
#define GUARD_DODRIO_BERRY_PICKING_H
-void sub_802493C(u16 a0, void (*callback)(void));
+void StartDodrioBerryPicking(u16 a0, void (*callback)(void));
void IsDodrioInParty(void);
void ShowDodrioBerryPickingRecords(void);
diff --git a/include/event_object_lock.h b/include/event_object_lock.h
index a3b350019..0226eb632 100644
--- a/include/event_object_lock.h
+++ b/include/event_object_lock.h
@@ -8,6 +8,6 @@ void LockSelectedObjectEvent(void);
void sub_8098630(void);
bool8 sub_8098734(void);
void ScriptUnfreezeObjectEvents(void);
-void sub_8098524(void);
+void UnionRoom_UnlockPlayerAndChatPartner(void);
#endif // GUARD_EVENT_OBJECT_LOCK_H
diff --git a/include/event_object_movement.h b/include/event_object_movement.h
index f0caa38aa..6ccd4759e 100644
--- a/include/event_object_movement.h
+++ b/include/event_object_movement.h
@@ -81,11 +81,11 @@ void sub_808E16C(s16, s16);
void OverrideSecretBaseDecorationSpriteScript(u8 localId, u8 mapNum, u8 mapGroup, u8 decorCat);
void sub_8092FF0(s16, s16, s16 *, s16 *);
u8 GetFaceDirectionAnimNum(u8);
-void sub_80930E0(s16 *, s16 *, s16, s16);
+void SetSpritePosToOffsetMapCoords(s16 *, s16 *, s16, s16);
void ObjectEventClearHeldMovement(struct ObjectEvent *);
void ObjectEventClearHeldMovementIfActive(struct ObjectEvent *);
void TrySpawnObjectEvents(s16, s16);
-u8 sprite_new(u8 graphicsId, u8 a1, s16 x, s16 y, u8 z, u8 direction);
+u8 CreateObjectSprite(u8 graphicsId, u8 a1, s16 x, s16 y, u8 z, u8 direction);
u8 AddPseudoObjectEvent(u16, void (*)(struct Sprite *), s16 x, s16 y, u8 subpriority);
u8 TrySpawnObjectEvent(u8, u8, u8);
u8 SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8 localId, s16 x, s16 y, u8 z);
@@ -180,7 +180,7 @@ void CreateLevitateMovementTask(struct ObjectEvent *);
void DestroyExtraMovementTask(u8);
void UnfreezeObjectEvents(void);
void FreezeObjectEventsExceptOne(u8 objectEventId);
-void sub_8097B78(u8, u8);
+void TurnObjectEventSprite(u8, u8);
void sub_8098074(u8 var1, u8 var2);
void FreezeObjectEvents(void);
bool8 FreezeObjectEvent(struct ObjectEvent *objectEvent);
@@ -194,7 +194,7 @@ void UpdateObjectEventSpriteVisibility(struct Sprite *sprite, bool8 invisible);
s16 sub_809773C(s16 a1);
s16 sub_8097728(s16 a1);
void CameraObjectReset2(void);
-u8 ObjectEventGetBerryTreeId(u8 objectEventId);
+u8 GetObjectEventBerryTreeId(u8 objectEventId);
void sub_8092EF0(u8 mapId, u8 mapNumber, u8 mapGroup);
bool8 IsBerryTreeSparkling(u8, u8, u8);
@@ -414,10 +414,10 @@ u8 MovementType_RunInPlace_Step0(struct ObjectEvent *, struct Sprite *);
u8 MovementType_Invisible_Step0(struct ObjectEvent *, struct Sprite *);
u8 MovementType_Invisible_Step1(struct ObjectEvent *, struct Sprite *);
u8 MovementType_Invisible_Step2(struct ObjectEvent *, struct Sprite *);
-void sub_8097C44(u8 var, bool32 var2);
-bool32 sub_8097C8C(u8 var);
-void sub_8097BB4(u8 var1, u8 graphicsId);
-void sub_8097CC4(u8 var1, u8 var2);
-bool32 sub_8097D9C(u8 var);
+void SetObjectEventSpriteInvisibility(u8 var, bool32 var2);
+bool32 IsObjectEventSpriteInvisible(u8 var);
+void SetObjectEventSpriteGraphics(u8 var1, u8 graphicsId);
+void SetObjectEventSpriteAnim(u8 var1, u8 var2);
+bool32 IsObjectEventSpriteAnimating(u8 var);
#endif //GUARD_EVENT_OBJECT_MOVEMENT_H
diff --git a/include/fieldmap.h b/include/fieldmap.h
index dc81d1766..aff458eb1 100644
--- a/include/fieldmap.h
+++ b/include/fieldmap.h
@@ -43,6 +43,7 @@ void copy_map_tileset1_to_vram(const struct MapLayout *);
void copy_map_tileset2_to_vram(const struct MapLayout *);
struct MapHeader const *const mapconnection_get_mapheader(struct MapConnection *connection);
struct MapConnection *GetConnectionAtCoords(s16 x, s16 y);
+void MapGridSetMetatileImpassabilityAt(int x, int y, bool32 impassable);
void SpriteCB_PokeballGlow(struct Sprite *);
void SpriteCB_PokecenterMonitor(struct Sprite *);
@@ -50,6 +51,5 @@ void SpriteCB_HallOfFameMonitor(struct Sprite *);
// field_region_map.c
void FieldInitRegionMap(MainCallback callback);
-void sub_8088B94(int x, int y, int a2);
#endif //GUARD_FIELDMAP_H
diff --git a/include/gba/types.h b/include/gba/types.h
index 7163f925f..35d02e263 100644
--- a/include/gba/types.h
+++ b/include/gba/types.h
@@ -27,6 +27,9 @@ typedef double f64;
typedef u8 bool8;
typedef u16 bool16;
typedef u32 bool32;
+typedef vu8 vbool8;
+typedef vu16 vbool16;
+typedef vu32 vbool32;
struct BgCnt
{
diff --git a/include/global.h b/include/global.h
index 2b03ebbe1..abcf1d545 100644
--- a/include/global.h
+++ b/include/global.h
@@ -960,7 +960,7 @@ struct SaveBlock1
/*0x2E20*/ u8 additionalPhrases[8]; // bitfield for 33 additional phrases in easy chat system
/*0x2E28*/ OldMan oldMan;
/*0x2e64*/ struct EasyChatPair easyChatPairs[5]; //Dewford trend [0] and some other stuff
- /*0x2e90*/ struct ContestWinner contestWinners[13]; // 0 - 5 used in contest hall, 6 - 7 unused?, 8 - 12 museum
+ /*0x2e90*/ struct ContestWinner contestWinners[NUM_CONTEST_WINNERS]; // see CONTEST_WINNER_*
/*0x3030*/ struct DayCare daycare;
/*0x3150*/ struct LinkBattleRecords linkBattleRecords;
/*0x31A8*/ u8 giftRibbons[52];
@@ -974,7 +974,7 @@ struct SaveBlock1
/*0x3B24*/ u8 seen2[DEX_FLAGS_NO];
/*0x3B58*/ LilycoveLady lilycoveLady;
/*0x3B98*/ struct TrainerNameRecord trainerNameRecords[20];
- /*0x3C88*/ u8 unk3C88[10][21];
+ /*0x3C88*/ u8 registeredTexts[UNION_ROOM_KB_ROW_COUNT][21];
/*0x3D5A*/ u8 filler3D5A[0xA];
/*0x3D64*/ struct SaveTrainerHill trainerHill;
/*0x3D70*/ struct WaldaPhrase waldaPhrase;
diff --git a/include/global.tv.h b/include/global.tv.h
index 34791d43c..ba1c3c37e 100644
--- a/include/global.tv.h
+++ b/include/global.tv.h
@@ -18,6 +18,13 @@ typedef union // size = 0x24
/*0x23*/ u8 trainerIdHi;
} common;
+ // Common init (used for initialization loop)
+ struct {
+ /*0x00*/ u8 kind;
+ /*0x01*/ bool8 active;
+ /*0x02*/ u8 pad02[34];
+ } commonInit;
+
// Local shows
// TVSHOW_FAN_CLUB_LETTER
struct {
diff --git a/include/graphics.h b/include/graphics.h
index b41a43095..8514d49bd 100644
--- a/include/graphics.h
+++ b/include/graphics.h
@@ -4082,8 +4082,8 @@ extern const u8 gNamingScreenUnderscoreTiles[];
extern const u32 gUnknown_08D9BA44[];
-extern const u32 gContestConfetti_Gfx[];
-extern const u32 gContestConfetti_Pal[];
+extern const u32 gConfetti_Gfx[];
+extern const u32 gConfetti_Pal[];
extern const u32 gUnknown_08C093F0[];
extern const u32 gSubstituteDollTilemap[];
@@ -4927,23 +4927,23 @@ extern const u32 gRouletteCreditTiles[];
extern const u32 gRouletteNumbersTiles[];
extern const u32 gRouletteMultiplierTiles[];
-// Contest Link
-extern const u32 gUnknown_08C19588[];
+// Contest util
+extern const u32 gContestResults_Gfx[];
extern const u32 gUnknown_08C19EEC[];
extern const u32 gUnknown_08C1A000[];
extern const u32 gUnknown_08C1A12C[];
-extern const u32 gUnknown_08C1A2B4[];
-extern const u16 gUnknown_08DC6498[];
-extern const u16 gUnknown_08DC63F8[];
-extern const u16 gUnknown_08DC6420[];
-extern const u16 gUnknown_08DC6448[];
-extern const u16 gUnknown_08DC6470[];
-extern const u16 gUnknown_08DC64AC[];
-extern const u16 gUnknown_08DC64C0[];
-extern const u16 gUnknown_08DC64D4[];
-extern const u16 gUnknown_08DC64E8[];
-extern const u16 gUnknown_08DC64FC[];
-extern const u16 gUnknown_08DC6510[];
+extern const u32 gContestResults_Pal[];
+extern const u16 gLinkContestResults_Tilemap[];
+extern const u16 gNormalContestResults_Tilemap[];
+extern const u16 gSuperContestResults_Tilemap[];
+extern const u16 gHyperContestResults_Tilemap[];
+extern const u16 gMasterContestResults_Tilemap[];
+extern const u16 gCoolContestResults_Tilemap[];
+extern const u16 gBeautyContestResults_Tilemap[];
+extern const u16 gCuteContestResults_Tilemap[];
+extern const u16 gSmartContestResults_Tilemap[];
+extern const u16 gToughContestResults_Tilemap[];
+extern const u16 gContestResults_Tilemap[];
// Trainer Card.
extern const u16 gHoennTrainerCard0Star_Pal[];
@@ -4986,14 +4986,14 @@ extern const u16 gEasyChatRightWindow_Pal[];
extern const u32 gUsePokeblockCondition_Gfx[];
// Union Room Chat
-extern const u16 gUnknown_08DD4BB0[];
-extern const u16 gUnknown_08DD4BD0[];
-extern const u32 gUnknown_08DD4BF0[];
-extern const u32 gUnknown_08DD4C4C[];
-extern const u32 gUnknown_08DD4CF8[];
-extern const u16 gLinkMiscMenu_Pal[];
-extern const u32 gLinkMiscMenu_Gfx[];
-extern const u32 gLinkMiscMenu_Tilemap[];
+extern const u16 gUnionRoomChat_Background_Pal[];
+extern const u32 gUnionRoomChat_Background_Gfx[];
+extern const u32 gUnionRoomChat_Background_Tilemap[];
+extern const u16 gUnionRoomChat_Window_Pal1[];
+extern const u16 gUnionRoomChat_Window_Pal2[];
+extern const u32 gUnionRoomChat_Border_Gfx[];
+extern const u32 gUnionRoomChat_Border_Tilemap[];
+extern const u32 gUnionRoomChat_RButtonLabels[];
// Use Pokeblock
extern const u8 gPokenavConditionCancel_Gfx[];
diff --git a/include/hall_of_fame.h b/include/hall_of_fame.h
index a83fad2fc..f1f456713 100644
--- a/include/hall_of_fame.h
+++ b/include/hall_of_fame.h
@@ -4,7 +4,6 @@
void CB2_DoHallOfFameScreen(void);
void CB2_DoHallOfFameScreenDontSaveData(void);
void CB2_DoHallOfFamePC(void);
-void DoConfettiEffect(void);
// hof_pc.c
void ReturnFromHallOfFamePC(void);
diff --git a/include/item_menu.h b/include/item_menu.h
index 9930ccd4f..edfb986f7 100644
--- a/include/item_menu.h
+++ b/include/item_menu.h
@@ -52,10 +52,7 @@ struct BagMenuStruct
void (*exitCallback)(void);
u8 tilemapBuffer[0x800];
u8 spriteId[12];
- u8 windowPointers[7];
- u8 unk817;
- u8 unk818;
- u8 unk819;
+ u8 windowPointers[10];
u8 itemOriginalLocation;
u8 pocketSwitchDisabled:4;
u8 itemIconSlot:2;
diff --git a/include/link.h b/include/link.h
index f41161d23..25e62ff1e 100644
--- a/include/link.h
+++ b/include/link.h
@@ -73,10 +73,10 @@
#define LINKCMD_CANCEL_TRADE 0xEEBB
#define LINKCMD_0xEECC 0xEECC
-#define LINKTYPE_0x1111 0x1111 // trade
-#define LINKTYPE_0x1122 0x1122 // trade
-#define LINKTYPE_0x1133 0x1133 // trade
-#define LINKTYPE_0x1144 0x1144 // trade
+#define LINKTYPE_TRADE 0x1111
+#define LINKTYPE_TRADE_CONNECTING 0x1122
+#define LINKTYPE_TRADE_SETUP 0x1133
+#define LINKTYPE_TRADE_DISCONNECTED 0x1144
#define LINKTYPE_BATTLE 0x2211
#define LINKTYPE_0x2222 0x2222 // unused battle?
#define LINKTYPE_SINGLE_BATTLE 0x2233
@@ -85,13 +85,13 @@
#define LINKTYPE_BATTLE_TOWER_50 0x2266
#define LINKTYPE_BATTLE_TOWER_OPEN 0x2277
#define LINKTYPE_BATTLE_TOWER 0x2288
-#define LINKTYPE_0x3311 0x3311
-#define LINKTYPE_0x3322 0x3322
+#define LINKTYPE_RECORD_MIX_BEFORE 0x3311
+#define LINKTYPE_RECORD_MIX_AFTER 0x3322
#define LINKTYPE_BERRY_BLENDER_SETUP 0x4411
#define LINKTYPE_BERRY_BLENDER 0x4422
-#define LINKTYPE_0x5501 0x5501 // mystery event
+#define LINKTYPE_MYSTERY_EVENT 0x5501
#define LINKTYPE_0x5502 0x5502 // unused?
-#define LINKTYPE_0x5503 0x5503 // eReader
+#define LINKTYPE_EREADER 0x5503
#define LINKTYPE_CONTEST_GMODE 0x6601
#define LINKTYPE_CONTEST_EMODE 0x6602
@@ -126,10 +126,10 @@ enum
EXCHANGE_NOT_STARTED,
EXCHANGE_COMPLETE,
EXCHANGE_TIMED_OUT,
- EXCHANGE_IN_PROGRESS,
+ EXCHANGE_DIFF_SELECTIONS,
EXCHANGE_PLAYER_NOT_READY,
EXCHANGE_PARTNER_NOT_READY,
- EXCHANGE_STAT_6,
+ EXCHANGE_WRONG_NUM_PLAYERS,
EXCHANGE_STAT_7
};
@@ -274,9 +274,8 @@ void LoadWirelessStatusIndicatorSpriteGfx(void);
bool8 IsLinkTaskFinished(void);
void CreateWirelessStatusIndicatorSprite(u8, u8);
void sub_800ADF8(void);
-void sub_800B488(void);
+void SetWirelessCommType1(void);
void CheckShouldAdvanceLinkState(void);
-void sub_8011BD0(void);
u8 IsLinkMaster(void);
void sub_800AC34(void);
bool8 HandleLinkConnection(void);
@@ -285,14 +284,14 @@ void sub_800A418(void);
void SetSuppressLinkErrorMessage(bool8 flag);
void sub_800B524(struct LinkPlayer *linkPlayer);
u8 GetSioMultiSI(void);
-void sub_800AAF4(void);
-void sub_800AF18(u32 status, u8 lastSendQueueCount, u8 lastRecvQueueCount, u8 unk_06);
+void ClearSavedLinkPlayers(void);
+void BufferLinkErrorInfo(u32 status, u8 lastSendQueueCount, u8 lastRecvQueueCount, u8 unk_06);
void sub_800B348(void);
-void sub_800B3A4(u32 who);
-bool32 sub_800A07C(void);
+void LinkPlayerFromBlock(u32 who);
+bool32 Link_AnyPartnersPlayingFRLG_JP(void);
void ResetLinkPlayerCount(void);
-void sub_800AA04(u8 a0);
-void sub_800B4C0(void);
+void SaveLinkPlayers(u8 a0);
+void SetWirelessCommType0(void);
bool32 sub_800B504(void);
extern u16 gLinkPartnersHeldKeys[6];
@@ -331,18 +330,18 @@ extern u32 gFiller_03003080;
extern struct LinkPlayer gLocalLinkPlayer;
bool32 Link_AnyPartnersPlayingRubyOrSapphire(void);
-bool32 sub_800A03C(void);
+bool32 LinkDummy_Return2(void);
void SetLocalLinkPlayerId(u8);
u8 GetSavedPlayerCount(void);
void sub_8009FAC(void);
bool8 sub_800A4D8(u8 a0);
-u8 sub_800A9D8(void);
+u8 GetLinkPlayerCountAsBitFlags(void);
u8 sub_800A0C8(s32, s32);
-u8 sub_800A9A8(void);
+u8 GetSavedLinkPlayerCountAsBitFlags(void);
void sub_800AD10(void);
-void sub_800AB18(void);
-void sub_8009F18(void);
-bool8 sub_800AA60(void);
+void CheckLinkPlayersMatchSaved(void);
+void StartSendingKeysToLink(void);
+bool8 DoesLinkPlayerCountMatchSaved(void);
void sub_800ABF4(u16 a0);
bool32 IsSendingKeysToLink(void);
u32 GetLinkRecvQueueLength(void);
diff --git a/include/link_rfu.h b/include/link_rfu.h
index 2d74e686a..eede41d60 100644
--- a/include/link_rfu.h
+++ b/include/link_rfu.h
@@ -5,7 +5,43 @@
#include "link.h"
#include "AgbRfu_LinkManager.h"
-// Exported type declarations
+#define RFU_COMMAND_0x4400 0x4400
+#define RFU_COMMAND_0x8800 0x8800
+#define RFU_COMMAND_0x8900 0x8900
+#define RFU_COMMAND_0xA100 0xA100
+#define RFU_COMMAND_0x7700 0x7700
+#define RFU_COMMAND_0x7800 0x7800
+#define RFU_COMMAND_0x6600 0x6600
+#define RFU_COMMAND_0x5F00 0x5F00
+#define RFU_COMMAND_0x2F00 0x2F00
+#define RFU_COMMAND_0xBE00 0xBE00
+#define RFU_COMMAND_0xEE00 0xEE00
+#define RFU_COMMAND_0xED00 0xED00
+
+#define RFU_SERIAL_7F7D 0x7F7D
+
+#define RECV_QUEUE_NUM_SLOTS 32
+#define RECV_QUEUE_SLOT_LENGTH (14 * MAX_RFU_PLAYERS)
+
+#define SEND_QUEUE_NUM_SLOTS 40
+#define SEND_QUEUE_SLOT_LENGTH 14
+
+#define BACKUP_QUEUE_NUM_SLOTS 2
+#define BACKUP_QUEUE_SLOT_LENGTH 14
+
+#define RFU_STATUS_OK 0
+#define RFU_STATUS_FATAL_ERROR 1
+#define RFU_STATUS_CONNECTION_ERROR 2
+#define RFU_STATUS_CHILD_SEND_COMPLETE 3
+#define RFU_STATUS_NEW_CHILD_DETECTED 4
+#define RFU_STATUS_JOIN_GROUP_OK 5
+#define RFU_STATUS_JOIN_GROUP_NO 6
+#define RFU_STATUS_WAIT_ACK_JOIN_GROUP 7
+#define RFU_STATUS_LEAVE_GROUP_NOTICE 8
+#define RFU_STATUS_LEAVE_GROUP 9
+#define RFU_STATUS_10 10
+#define RFU_STATUS_11 11
+#define RFU_STATUS_ACK_JOIN_GROUP 12
// RfuTgtData.gname is read as these structs.
struct GFtgtGnameSub
@@ -13,12 +49,11 @@ struct GFtgtGnameSub
u16 language:4;
u16 hasNews:1;
u16 hasCard:1;
- u16 unk_00_6:1;
+ u16 unknown:1; // Never read
u16 isChampion:1;
u16 hasNationalDex:1;
u16 gameClear:1;
u16 version:4;
- u16 unk_01_6:2;
u8 playerTrainerId[2];
};
@@ -38,111 +73,73 @@ struct __attribute__((packed, aligned(2))) GFtgtGname
u8 padding;
}; // size: RFU_GNAME_SIZE
-struct UnkLinkRfuStruct_02022B2C
-{
- u8 unk_00;
- u8 unk_01;
- u16 unk_02;
- u8 unk_04;
- u16 unk_06;
- struct GFtgtGname *unk_08;
- u8 *unk_0c;
- u8 unk_10;
- u8 unk_11;
- u16 unk_12;
- u16 unk_14;
-};
-
-struct UnkLinkRfuStruct_02022B44
-{
- u8 fill_00[6];
- u16 unk_06;
- u8 fill_08[6];
- vu8 unk_0e;
- u8 unk_0f;
- u8 fill_10[0x54];
- u16 unk_64;
- u8 fill_66[0x1d];
- u8 unk_83;
- u8 fill_84[0x58];
-};
-
-struct UnkRfuStruct_2_Sub_6c
+struct RfuBlockSend
{
- /* 0x00 */ u16 unk_00;
- /* 0x02 */ u16 unk_02;
- /* 0x04 */ const u8 *unk_04;
- /* 0x08 */ u32 unk_08;
- /* 0x0c */ u32 unk_0c;
- /* 0x10 */ u8 unk_10;
- /* 0x11 */ u8 unk_11;
- /* 0x12 */ u8 unk_12;
+ /* 0x00 */ u16 next;
+ /* 0x02 */ u16 count;
+ /* 0x04 */ const u8 *payload;
+ /* 0x08 */ u32 receivedFlags;
+ /* 0x0c */ u32 failedFlags;
+ /* 0x10 */ bool8 sending;
+ /* 0x11 */ u8 owner;
+ /* 0x12 */ u8 receiving;
};
-struct UnkRfuStruct_2_Sub_124
+struct RfuRecvQueue
{
- /* 0x000 */ u8 unk_00[32][70];
- /* 0x8c0 */ vu8 unk_8c0;
- /* 0x8c1 */ vu8 unk_8c1;
- /* 0x8c2 */ vu8 unk_8c2;
- /* 0x8c3 */ vu8 unk_8c3;
+ /* 0x000 */ u8 slots[RECV_QUEUE_NUM_SLOTS][RECV_QUEUE_SLOT_LENGTH];
+ /* 0x8c0 */ vu8 recvSlot;
+ /* 0x8c1 */ vu8 sendSlot;
+ /* 0x8c2 */ vu8 count;
+ /* 0x8c3 */ vu8 full;
};
-struct UnkRfuStruct_2_Sub_9e8
+struct RfuSendQueue
{
- /* 0x000 */ u8 unk_00[40][14];
- /* 0x230 */ vu8 unk_230;
- /* 0x231 */ vu8 unk_231;
- /* 0x232 */ vu8 unk_232;
- /* 0x233 */ vu8 unk_233;
+ /* 0x000 */ u8 slots[SEND_QUEUE_NUM_SLOTS][SEND_QUEUE_SLOT_LENGTH];
+ /* 0x230 */ vu8 recvSlot;
+ /* 0x231 */ vu8 sendSlot;
+ /* 0x232 */ vu8 count;
+ /* 0x233 */ vu8 full;
};
-struct UnkRfuStruct_2_Sub_c1c
+struct RfuBackupQueue
{
- /* 0x00 */ u8 unk_00[2][14];
- /* 0x1c */ vu8 unk_1c;
- /* 0x1d */ vu8 unk_1d;
- /* 0x1e */ vu8 unk_1e;
+ /* 0x00 */ u8 slots[BACKUP_QUEUE_NUM_SLOTS][BACKUP_QUEUE_SLOT_LENGTH];
+ /* 0x1c */ vu8 recvSlot;
+ /* 0x1d */ vu8 sendSlot;
+ /* 0x1e */ vu8 count;
};
-struct UnkRfuStruct_Sub_Unused
+struct GFRfuManager
{
- /* 0x000 */ u8 unk_00[2][256];
- /* 0x200 */ vu8 unk_200;
- /* 0x201 */ vu8 unk_201;
- /* 0x202 */ vu8 unk_202;
- /* 0x203 */ vu8 unk_203;
-};
-
-struct UnkRfuStruct_2
-{
- /* 0x000 */ void (*linkRfuCallback)(void);
- /* 0x004 */ u16 unk_04;
+ /* 0x000 */ void (*callback)(void);
+ /* 0x004 */ u16 state;
/* 0x006 */ u8 filler_06[4];
- /* 0x00a */ u16 unk_0a;
- /* 0x00c */ u8 unk_0c;
+ /* 0x00a */ u16 linkmanMsg;
+ /* 0x00c */ u8 parentChild;
/* 0x00d */ u8 playerCount;
- /* 0x00e */ u8 unk_0e;
+ /* 0x00e */ bool8 unk_0e;
/* 0x00f */ u8 unk_0f;
/* 0x010 */ u16 unk_10;
/* 0x012 */ u16 unk_12;
- /* 0x014 */ u8 unk_14[4][14];
+ /* 0x014 */ u8 unk_14[RFU_CHILD_MAX][14];
/* 0x04c */ u8 unk_4c[14];
/* 0x05a */ u8 unk_5a;
/* 0x05b */ u8 unk_5b;
- /* 0x05c */ u8 unk_5c[5];
- /* 0x061 */ u8 unk_61[5];
- /* 0x066 */ u8 unk_66;
- /* 0x067 */ u8 unk_67;
+ /* 0x05c */ bool8 blockReceived[MAX_RFU_PLAYERS];
+ /* 0x061 */ bool8 numBlocksReceived[MAX_RFU_PLAYERS];
+ /* 0x066 */ u8 idleTaskId;
+ /* 0x067 */ u8 searchTaskId;
/* 0x068 */ u8 filler_68[4];
- /* 0x06c */ struct UnkRfuStruct_2_Sub_6c unk_6c;
- /* 0x080 */ struct UnkRfuStruct_2_Sub_6c unk_80[5];
+ /* 0x06c */ struct RfuBlockSend sendBlock;
+ /* 0x080 */ struct RfuBlockSend recvBlock[MAX_RFU_PLAYERS];
/* 0x0e4 */ u8 unk_e4[5];
/* 0x0e9 */ u8 unk_e9[5];
- /* 0x0ee */ vu8 unk_ee;
- /* 0x0ef */ u8 unk_ef;
- /* 0x0f0 */ u8 unk_f0;
- /* 0x0f1 */ u8 unk_f1;
+ /* 0x0ee */ vu8 errorState;
+ /* 0x0ef */ bool8 isShuttingDown;
+ /* 0x0f0 */ u8 linkLossRecoveryState;
+ /* 0x0f1 */ u8 status;
/* 0x0f2 */ u16 unk_f2[6];
/* 0x0fe */ u16 unk_fe;
/* 0x100 */ u16 unk_100;
@@ -151,193 +148,137 @@ struct UnkRfuStruct_2
/* 0x10A */ struct GFtgtGname unk_10A;
u8 filler_;
u8 playerName[PLAYER_NAME_LENGTH + 1];
- /* 0x124 */ struct UnkRfuStruct_2_Sub_124 unk_124;
- /* 0x9e8 */ struct UnkRfuStruct_2_Sub_9e8 unk_9e8;
- /* 0xc1c */ struct UnkRfuStruct_2_Sub_c1c unk_c1c;
- /* 0xc3c */ vu8 unk_c3c;
+ /* 0x124 */ struct RfuRecvQueue recvQueue;
+ /* 0x9e8 */ struct RfuSendQueue sendQueue;
+ /* 0xc1c */ struct RfuBackupQueue backupQueue;
+ /* 0xc3c */ vu8 linkRecovered;
/* 0xc3d */ u8 unk_c3d;
- /* 0xc3e */ vu8 unk_c3e;
+ /* 0xc3e */ vu8 childSlot;
/* 0xc3f */ u8 unk_c3f[70];
/* 0xc85 */ u8 unk_c85;
- /* 0xc86 */ u8 unk_c86;
- /* 0xc87 */ u8 unk_c87[5][7][2];
- /* 0xccd */ u8 unk_ccd;
- /* 0xcce */ u8 unk_cce;
+ /* 0xc86 */ u8 recvStatus;
+ /* 0xc87 */ u8 recvCmds[5][7][2];
+ /* 0xccd */ u8 parentId;
+ /* 0xcce */ u8 multiplayerId;
/* 0xccf */ u8 unk_ccf;
/* 0xcd0 */ vu8 unk_cd0;
- /* 0xcd1 */ u8 unk_cd1[4];
- /* 0xcd5 */ u8 unk_cd5[4];
+ /* 0xcd1 */ u8 partnerSendStatuses[RFU_CHILD_MAX];
+ /* 0xcd5 */ u8 partnerRecvStatuses[RFU_CHILD_MAX];
/* 0xcd9 */ u8 unk_cd9;
/* 0xcda */ u8 unk_cda;
- /* 0xcdb */ vu8 unk_cdb;
- /* 0xcdc */ vu8 unk_cdc;
+ /* 0xcdb */ vbool8 unk_cdb;
+ /* 0xcdc */ vbool8 unk_cdc;
/* 0xcdd */ u8 unk_cdd;
- /* 0xcde */ u8 unk_cde[4];
+ /* 0xcde */ u8 linkPlayerIdx[RFU_CHILD_MAX];
/* 0xce2 */ u8 unk_ce2;
/* 0xce2 */ u8 unk_ce3;
/* 0xce4 */ u8 unk_ce4;
/* 0xce5 */ u8 unk_ce5;
/* 0xce5 */ u8 unk_ce6;
- /* 0xce7 */ u8 unk_ce7;
+ /* 0xce7 */ u8 acceptSlot_flag;
/* 0xce8 */ u8 unk_ce8;
/* 0xce9 */ u8 unk_ce9;
/* 0xcea */ u8 unk_cea[4];
/* 0xcee */ u8 unk_cee[4];
}; // size = 0xcf4
-struct UnkRfuStruct_8010A14
-{
- char unk_00[15];
- u8 unk_0f;
- u8 unk_10[4];
- struct LinkPlayer unk_14[5];
- u8 fill_a0[0x5c];
-};
-
// Exported RAM declarations
-extern struct GFtgtGname gUnknown_02022B14;
-extern u8 gUnknown_02022B22[];
-extern struct UnkRfuStruct_2 Rfu;
+extern struct GFtgtGname gHostRFUtgtGnameBuffer;
+extern u8 gHostRFUtgtUnameBuffer[];
+extern struct GFRfuManager Rfu;
extern u8 gWirelessStatusIndicatorSpriteId;
// Exported ROM declarations
void WipeTrainerNameRecords(void);
-void sub_800E700(void);
-void sub_800EDD4(void);
-void sub_800F6FC(u8 who);
-void sub_800F728(u8 who);
+void InitRFUAPI(void);
+void LinkRfu_Shutdown(void);
+void Rfu_SetBlockReceivedFlag(u8 who);
+void Rfu_ResetBlockReceivedFlag(u8 who);
bool32 IsSendingKeysToRfu(void);
-void sub_800F804(void);
+void StartSendingKeysToRfu(void);
void sub_800F850(void);
-u8 sub_800FCD8(void);
-bool32 sub_800FE84(const u8 *src, size_t size);
+u8 Rfu_GetBlockReceivedStatus(void);
+bool32 Rfu_InitBlockSend(const u8 *src, size_t size);
void ClearLinkRfuCallback(void);
-u8 sub_80104F4(void);
-u8 rfu_get_multiplayer_id(void);
+u8 Rfu_GetLinkPlayerCount(void);
+u8 Rfu_GetMultiplayerId(void);
bool8 sub_8010100(u8 a0);
bool8 IsLinkRfuTaskFinished(void);
bool8 Rfu_IsMaster(void);
void task_add_05_task_del_08FA224_when_no_RfuFunc(void);
void sub_8010434(void);
-void sub_800E604(void);
-void sub_800E174(void);
-void sub_800E6D0(void);
+void ResetLinkRfuGFLayer(void);
+void UpdateWirelessStatusIndicatorSprite(void);
+void InitRFU(void);
bool32 sub_8010EC0(void);
bool32 sub_8010F1C(void);
-bool32 sub_8011A80(void);
+bool32 RfuHasErrored(void);
bool32 IsRfuRecvQueueEmpty(void);
u32 GetRfuRecvQueueLength(void);
void RfuVSync(void);
void sub_80111B0(bool32 a0);
-u8 sub_8011A74(void);
-struct GFtgtGname *sub_800F7DC(void);
-void sub_8011068(u8 a0);
-void sub_8011170(u32 a0);
-void sub_8011A64(u8 a0, u16 a1);
+u8 RfuGetStatus(void);
+struct GFtgtGname *GetHostRFUtgtGname(void);
+void UpdateGameData_GroupLockedIn(u8 a0);
+void GetLinkmanErrorParams(u32 a0);
+void RfuSetStatus(u8 a0, u16 a1);
u8 sub_801048C(bool32 a0);
-void sub_800DF90(struct GFtgtGname *buff1, u8 *buff2);
-void sub_8010F84(u8 a0, u32 a1, u32 a2);
-void sub_8011C10(u32 a0);
+void LinkRfu3_SetGnameUnameFromStaticBuffers(struct GFtgtGname *buff1, u8 *buff2);
+void SetHostRFUtgtGname(u8 activity, u32 child_sprite_genders, bool32 started);
+void InitializeRfuLinkManager_LinkLeader(u32 a0);
bool32 sub_8012240(void);
-void sub_800EF38(void);
+void LinkRfu_StopManagerAndFinalizeSlots(void);
bool32 sub_80105EC(void);
-bool32 sub_801064C(u16 a0, const u8 *a1);
-void sub_8010688(u8 a0, u16 a1, const u8 *a2);
-u32 sub_8010714(u16 a0, const u8 *a1);
-void sub_8011DC0(const u8 *a0, u16 a1);
-bool8 sub_800EF1C(void);
-bool32 sub_800EF58(bool32 a0);
-void DestroyWirelessStatusIndicatorSprite(void);
+bool32 HasTrainerLeftPartnersList(u16 trainerId, const u8 *name);
+void SendRfuStatusToPartner(u8 status, u16 trainerId, const u8 *name);
+u32 WaitSendRfuStatusToPartner(u16 trainerId, const u8 *name);
+void RequestDisconnectSlotByTrainerNameAndId(const u8 *a0, u16 a1);
+bool8 LmanAcceptSlotFlagIsNotZero(void);
+bool32 WaitRfuState(bool32 a0);
void sub_801103C(void);
-void sub_8011C5C(void);
-void sub_80106D4(void);
+void InitializeRfuLinkManager_JoinGroup(void);
+void SendLeaveGroupNotice(void);
void RecordMixTrainerNames(void);
-void sub_800ED10(void);
-void sub_800ED28(void);
-void sub_8011090(u8 a0, u32 a1, u32 a2);
-void sub_8011FC8(const u8 *src, u16 trainerId);
-void sub_8010FA0(bool32 a0, bool32 a1);
-void sub_8010F60(void);
-void sub_8010FCC(u32 a0, u32 a1, u32 a2);
-void sub_8011C84(void);
+void LinkRfu_CreateConnectionAsParent(void);
+void LinkRfu_StopManagerBeforeEnteringChat(void);
+void UpdateGameData_SetActivity(u8 activity, u32 flags, bool32 started);
+void CreateTask_RfuReconnectWithParent(const u8 *src, u16 trainerId);
+void SetGnameBufferWonderFlags(bool32 a0, bool32 a1);
+void ClearAndInitHostRFUtgtGname(void);
+void SetTradeBoardRegisteredMonInfo(u32 type, u32 species, u32 level);
+void InitializeRfuLinkManager_EnterUnionRoom(void);
void sub_8012188(const u8 *name, struct GFtgtGname *structPtr, u8 a2);
-bool32 sub_8011B90(void);
+bool32 IsUnionRoomListenTaskActive(void);
void sub_800FE50(void *a0);
-bool32 sub_800E540(u16 id, u8 *name);
+bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name);
void sub_8011DE0(u32 arg0);
u8 sub_801100C(s32 a0);
void sub_800EF7C(void);
-bool8 sub_800DE7C(struct GFtgtGname *buff1, u8 *buff2, u8 idx);
-bool8 sub_800DF34(struct GFtgtGname *buff1, u8 *buff2, u8 idx);
+bool8 LinkRfu_GetNameIfCompatible(struct GFtgtGname *buff1, u8 *buff2, u8 idx);
+bool8 LinkRfu_GetNameIfSerial7F7D(struct GFtgtGname *buff1, u8 *buff2, u8 idx);
s32 sub_800E87C(u8 idx);
-void sub_8011BA4(void);
-void sub_8010198(void);
+void CreateTask_RfuIdle(void);
+void DestroyTask_RfuIdle(void);
void sub_8011AC8(void);
void LinkRfu_FatalError(void);
bool32 sub_8011A9C(void);
void sub_80104B0(void);
void sub_8011A50(void);
void sub_80110B8(u32 a0);
-bool8 sub_800DAC8(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2);
-void sub_800EAB4(void);
-void sub_800EAFC(void);
-void sub_800ED34(u16 unused);
-void sub_800EDBC(u16 unused);
-void sub_800F048(void);
-void sub_800F86C(u8 unused);
-void sub_800FCC4(struct UnkRfuStruct_2_Sub_6c *data);
-void sub_800FD14(u16 command);
-void rfufunc_80F9F44(void);
-void sub_800FFB0(void);
-void rfufunc_80FA020(void);
-bool32 sub_8010454(u32 a0);
-void sub_8010528(void);
-void sub_8010750(void);
-s32 sub_80107A0(void);
-void sub_801084C(u8 taskId);
-void sub_80109E8(u16 a0);
-void sub_8010A70(void *a0);
-void sub_8010AAC(u8 taskId);
-void sub_8010D0C(u8 taskId);
-void sub_80115EC(s32 a0);
-u8 sub_8011CE4(const u8 *a0, u16 a1);
-void sub_8011D6C(u32 a0);
-void sub_8011E94(u32 a0, u32 a1);
-bool8 sub_8012224(void);
-void sub_801227C(void);
-void sub_801209C(u8 taskId);
-void sub_8011BF8(void);
-void sub_8011BA4(void);
-void sub_800D6C8(struct UnkRfuStruct_2_Sub_124 *ptr);
-void sub_800D724(struct UnkRfuStruct_2_Sub_9e8 *ptr);
-void sub_800D780(struct UnkRfuStruct_Sub_Unused *ptr);
-void sub_800D7D8(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2);
-void sub_800D888(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2);
-bool8 sub_800D934(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2);
-bool8 sub_800D9DC(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2);
-void sub_800DA68(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2);
-bool8 sub_800DAC8(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2);
-void sub_800DB18(struct UnkRfuStruct_Sub_Unused *q1, u8 *q2);
-bool8 sub_800DB84(struct UnkRfuStruct_Sub_Unused *q1, u8 *q2);
-void sub_800DBF8(u8 *q1, u8 mode);
-void PkmnStrToASCII(u8 *q1, const u8 *q2);
-void ASCIIToPkmnStr(u8 *q1, const u8 *q2);
-u8 sub_800DD1C(u8 maxFlags);
-void sub_800DD94(struct GFtgtGname *data, u8 r9, bool32 r2, s32 r3);
-bool8 sub_800DE7C(struct GFtgtGname *buff1, u8 *buff2, u8 idx);
-bool8 sub_800DF34(struct GFtgtGname *buff1, u8 *buff2, u8 idx);
-void sub_800DF90(struct GFtgtGname *buff1, u8 *buff2);
+bool32 IsRfuSerialNumberValid(u32 serialNo);
+bool8 IsRfuRecoveringFromLinkLoss(void);
+void RfuRecvQueue_Reset(struct RfuRecvQueue *queue);
+void RfuSendQueue_Reset(struct RfuSendQueue *queue);
+void RfuRecvQueue_Enqueue(struct RfuRecvQueue *queue, u8 *data);
+void RfuSendQueue_Enqueue(struct RfuSendQueue *queue, u8 *data);
+bool8 RfuRecvQueue_Dequeue(struct RfuRecvQueue *queue, u8 *dest);
+bool8 RfuSendQueue_Dequeue(struct RfuSendQueue *queue, u8 *dest);
+void RfuBackupQueue_Enqueue(struct RfuBackupQueue *queue, const u8 *q2);
+bool8 RfuBackupQueue_Dequeue(struct RfuBackupQueue *queue, u8 *q2);
+void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 started, s32 child_sprite_genders);
void CreateWirelessStatusIndicatorSprite(u8 x, u8 y);
void DestroyWirelessStatusIndicatorSprite(void);
void LoadWirelessStatusIndicatorSpriteGfx(void);
-u8 sub_800E124(void);
-void sub_800E15C(struct Sprite *sprite, s32 signalStrengthAnimNum);
-void sub_800E174(void);
-void CopyTrainerRecord(struct TrainerNameRecord *dest, u32 trainerId, const u8 *name);
-bool32 NameIsNotEmpty(const u8 *name);
-void RecordMixTrainerNames(void);
-bool32 sub_800E540(u16 id, u8 *name);
-void WipeTrainerNameRecords(void);
#endif //GUARD_LINK_RFU_H
diff --git a/include/menu.h b/include/menu.h
index 1f4d63284..20eda0fce 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -79,7 +79,7 @@ void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u
u8 sub_8199944(u8 windowId, u8 optionWidth, u8 columns, u8 rows, u8 initialCursorPos);
u8 sub_8199134(s8, s8);
u8 GetStartMenuWindowId(void);
-void sub_819A2BC(u8, u8);
+void ListMenuLoadStdPalAt(u8, u8);
u8 Menu_MoveCursor(s8 cursorDelta);
u8 Menu_MoveCursorNoWrapAround(s8 cursorDelta);
void DrawStdWindowFrame(u8 windowId, bool8 CopyToVram);
diff --git a/include/mevent.h b/include/mevent.h
index a34ca355c..8c0ebbad7 100755
--- a/include/mevent.h
+++ b/include/mevent.h
@@ -57,7 +57,7 @@ u32 sub_801B708(const u16 *a0, const struct MEventStruct_Unk1442CC *a1, const vo
bool32 MEventStruct_Unk1442CC_CompareField_unk_16(const struct MEventStruct_Unk1442CC *a0, const u16 *a1);
u16 MEventStruct_Unk1442CC_GetValueNFrom_unk_20(const struct MEventStruct_Unk1442CC *a0, u32 command);
u16 mevent_081445C0(u32 command);
-void sub_801B940(void);
-bool32 sub_801B94C(u16 a0);
+void ResetReceivedWonderCardFlag(void);
+bool32 MEventHandleReceivedWonderCard(u16 a0);
#endif //GUARD_MEVENT_H
diff --git a/include/mevent2.h b/include/mevent2.h
index 80b1fd51b..316a9e6de 100644
--- a/include/mevent2.h
+++ b/include/mevent2.h
@@ -1,6 +1,6 @@
#ifndef GUARD_MEVENT2_H
#define GUARD_MEVENT2_H
-void sub_801B990(u32, u32);
+void RecordIdOfWonderCardSenderByEventType(u32, u32);
#endif //GUARD_MEVENT2_H
diff --git a/include/mystery_gift.h b/include/mystery_gift.h
index 243895a67..fb0414ee0 100644
--- a/include/mystery_gift.h
+++ b/include/mystery_gift.h
@@ -12,5 +12,7 @@ bool32 MG_PrintTextOnWindow1AndWaitButton(u8 *textState, const u8 *str);
void AddTextPrinterToWindow1(const u8 *src);
void c2_ereader(void);
void c2_mystery_gift(void);
+void MG_DrawTextBorder(u8 windowId);
+s8 mevent_message_print_and_prompt_yes_no(u8 *textState, u16 *windowId, bool8 yesNoBoxPlacement, const u8 *str);
#endif //GUARD_MYSTERY_GIFT_H
diff --git a/include/pokemon.h b/include/pokemon.h
index 7ac65d36b..69ef7a142 100644
--- a/include/pokemon.h
+++ b/include/pokemon.h
@@ -279,8 +279,8 @@ void sub_80686FC(struct Pokemon *mon, struct BattleTowerPokemon *dest);
void CreateObedientMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId);
bool8 sub_80688F8(u8 caseId, u8 battlerId);
void SetDeoxysStats(void);
-u16 sub_8068B48(void);
-u16 sub_8068BB0(void);
+u16 GetUnionRoomTrainerPic(void);
+u16 GetUnionRoomTrainerClass(void);
void CreateObedientEnemyMon(void);
void CalculateMonStats(struct Pokemon *mon);
void BoxMonToMon(const struct BoxPokemon *src, struct Pokemon *dest);
diff --git a/include/pokemon_jump.h b/include/pokemon_jump.h
index 9cf65212f..91733b385 100644
--- a/include/pokemon_jump.h
+++ b/include/pokemon_jump.h
@@ -3,7 +3,7 @@
#include "main.h"
-void sub_802A9A8(u16 monId, MainCallback callback);
+void StartPokemonJump(u16 monId, MainCallback callback);
bool32 IsSpeciesAllowedInPokemonJump(u16 species);
void IsPokemonJumpSpeciesInParty(void);
void ResetPokeJumpResults(void);
diff --git a/include/rom_81520A8.h b/include/rom_81520A8.h
deleted file mode 100644
index 2be12200f..000000000
--- a/include/rom_81520A8.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef GUARD_ROM_81520A8_H
-#define GUARD_ROM_81520A8_H
-
-struct UnkStruct_81520A8
-{
- struct OamData oam;
- s16 x;
- s16 y;
- s16 xDelta;
- s16 yDelta;
- u16 tileTag;
- u16 palTag;
- u16 tileNum;
- u8 id;
- u8 filler17; // Unused.
- u8 unk18;
- u8 unk19_0:1;
- u8 unk19_1:1;
- u8 unk19_2:1;
- u8 priority:2;
- s16 data[8];
- void (*callback)(struct UnkStruct_81520A8 *);
-};
-
-bool32 sub_81521C0(u8 count);
-bool32 sub_8152254(void);
-bool32 sub_81522D4(void);
-u8 sub_8152438(u8 id, void (*func)(struct UnkStruct_81520A8 *));
-u8 sub_8152474(u8 id, u8 dataArrayId, s16 dataValue);
-u8 sub_81524C4(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16 y, u8 arg5, u8 priority);
-u8 sub_81525D0(u8 id);
-
-#endif // GUARD_ROM_81520A8_H
diff --git a/include/save.h b/include/save.h
index 225b2b62c..18b57502b 100644
--- a/include/save.h
+++ b/include/save.h
@@ -102,7 +102,7 @@ u8 Save_LoadGameData(u8 saveType);
u16 sub_815355C(void);
u32 TryReadSpecialSaveSection(u8 sector, u8* dst);
u32 TryWriteSpecialSaveSection(u8 sector, u8* src);
-void sub_8153688(u8 taskId);
+void Task_LinkSave(u8 taskId);
// save_failed_screen.c
void DoSaveFailedScreen(u8 saveType);
diff --git a/include/start_menu.h b/include/start_menu.h
index df2a290a2..1ddd82066 100644
--- a/include/start_menu.h
+++ b/include/start_menu.h
@@ -8,8 +8,8 @@ void Task_ShowStartMenu(u8 taskId);
void ShowStartMenu(void);
void ShowBattlePyramidStartMenu(void);
void SaveGame(void);
-void sub_80A0514(void);
-void sub_80A08CC(void);
+void CB2_SetUpSaveAfterLinkBattle(void);
+void SaveForBattleTowerLink(void);
void HideStartMenu(void);
void AppendToList(u8* list, u8* pos, u8 newEntry);
diff --git a/include/strings.h b/include/strings.h
index 5720598ad..67b238422 100644
--- a/include/strings.h
+++ b/include/strings.h
@@ -962,7 +962,7 @@ extern const u8 gText_TwoDashes[];
extern const u8 *const gReturnToXStringsTable2[];
-extern const u8 gText_XPLink[];
+extern const u8 gText_NumPlayerLink[];
extern const u8 gText_ConfirmLinkWhenPlayersReady[];
extern const u8 gText_ConfirmStartLinkWithXPlayers[];
extern const u8 gText_AwaitingLinkup[];
@@ -2494,7 +2494,7 @@ extern const u8 gText_CommunicationStandby[];
extern const u8 gText_AnnouncingResults[];
extern const u8 gText_PreliminaryResults[];
extern const u8 gText_Round2Results[];
-extern const u8 gText_Var1sVar2Won[];
+extern const u8 gText_ContestantsMonWon[];
// Trainer Card
extern const u8 gText_LinkCableBattles[];
@@ -2815,10 +2815,10 @@ extern const u8 gText_RegisterTextHere[];
extern const u8 gText_InputText[];
extern const u8 gText_ExitingChat[];
extern const u8 gText_LeaderLeftEndingChat[];
-extern const u8 gText_RegisteredTextChanged[];
-extern const u8 gText_AlreadySavedFile_Unused[];
-extern const u8 gText_SavingDontTurnOff_Unused[];
-extern const u8 gText_PlayerSavedGame_Unused[];
+extern const u8 gText_RegisteredTextChangedOKToSave[];
+extern const u8 gText_AlreadySavedFile_Chat[];
+extern const u8 gText_SavingDontTurnOff_Chat[];
+extern const u8 gText_PlayerSavedGame_Chat[];
extern const u8 gText_IfLeaderLeavesChatEnds[];
extern const u8 gText_Upper[];
extern const u8 gText_Lower[];
diff --git a/include/union_room.h b/include/union_room.h
index 4c4cb5a62..563a048d3 100644
--- a/include/union_room.h
+++ b/include/union_room.h
@@ -2,71 +2,70 @@
#define GUARD_UNION_ROOM_H
#include "link_rfu.h"
+#include "link.h"
+#include "constants/union_room.h"
// Exported type declarations
-struct UnkStruct_Shared
+struct WirelessGnameUnamePair
{
- struct GFtgtGname field_0;
+ struct GFtgtGname gname;
u8 ALIGNED(4) playerName[PLAYER_NAME_LENGTH + 1];
};
struct UnkStruct_x1C
{
- struct UnkStruct_Shared unk0;
- u8 unk18:1;
+ struct WirelessGnameUnamePair gname_uname;
+ u8 active:1;
};
struct UnkStruct_x20
{
- struct UnkStruct_Shared unk;
- u16 field_18;
- u8 field_1A_0:2;
- u8 field_1A_1:1;
+ struct WirelessGnameUnamePair gname_uname;
+ u16 timeoutCounter;
+ u8 groupScheduledAnim:2;
+ bool8 useRedText:1; // Never set
u8 field_1B;
- u8 field_1D;
- u8 field_1E;
- u8 field_1F;
+ u8 filler[3];
};
struct UnkStruct_Main0
{
- struct UnkStruct_x20 arr[8];
+ struct UnkStruct_x20 arr[MAX_UNION_ROOM_PLAYERS];
};
struct UnkStruct_Main4
{
- struct UnkStruct_x1C arr[5];
+ struct UnkStruct_x1C arr[MAX_RFU_PLAYERS];
};
struct UnkStruct_Main8
{
- struct UnkStruct_x20 arr[5];
+ struct UnkStruct_x20 arr[MAX_RFU_PLAYERS];
};
-struct UnkStruct_Leader
+struct WirelessLink_Leader
{
struct UnkStruct_Main0 *field_0;
struct UnkStruct_Main4 *field_4;
struct UnkStruct_Main8 *field_8;
u8 state;
u8 textState;
- u8 field_E;
+ u8 delayTimerAfterOk;
u8 listWindowId;
- u8 field_10;
- u8 field_11;
+ u8 bButtonCancelWindowId;
+ u8 nPlayerModeWindowId;
u8 listTaskId;
- u8 field_13;
- u8 field_14;
- u8 field_15;
+ u8 playerCount;
+ u16 field_14;
u8 field_16;
- u8 field_17;
- u8 field_18;
- u8 field_19;
- u16 field_1A;
+ u8 listenTaskId;
+ u8 activity;
+ u8 joinRequestAnswer;
+ u16 memberConfirmTimeout;
};
-struct UnkStruct_Group
+struct WirelessLink_Group
{
struct UnkStruct_Main0 *field_0;
struct UnkStruct_Main4 *field_4;
@@ -74,98 +73,96 @@ struct UnkStruct_Group
u8 textState;
u8 field_A;
u8 listWindowId;
- u8 field_C;
- u8 field_D;
+ u8 bButtonCancelWindowId;
+ u8 playerNameAndIdWindowId;
u8 listTaskId;
- u8 field_F;
+ u8 leaderId;
u8 field_10;
- u8 field_11;
- u8 field_12;
+ u8 listenTaskId;
+ u8 isWonderNews;
u8 field_13;
- u8 field_14;
- u8 field_15;
+ u8 refreshTimer;
+ u8 delayBeforePrint;
};
-struct UnkStruct_8019BA8
+struct UnionRoomObject
{
- u8 field_0;
- u8 field_1;
- s8 field_2;
- u8 field_3;
+ u8 state;
+ u8 gfxId;
+ s8 animState;
+ u8 schedAnim;
};
-struct UnkStruct_URoom
+struct WirelessLink_URoom
{
struct UnkStruct_Main0 *field_0;
struct UnkStruct_Main4 *field_4;
struct UnkStruct_Main0 *field_8;
struct UnkStruct_Main4 *field_C;
- u16 field_10;
+ u16 unknown; // Never read
u16 field_12;
u8 state;
u8 stateAfterPrint;
u8 textState;
- u8 field_17;
- u8 field_18;
- u8 field_19;
- u8 field_1A;
- u8 field_1B;
- u8 field_1C;
- u8 field_1D;
- u8 field_1E;
- u8 field_1F;
- u8 field_20;
+ u8 filler[4];
+ u8 topListMenuWindowId;
+ u8 topListMenuId;
+ u8 tradeBoardSelectWindowId;
+ u8 tradeBoardDetailsWindowId;
+ u8 unused1;
+ u8 searchTaskId;
u8 spriteIds[40];
- u8 field_49;
- u8 field_4A;
- u16 field_4C[6];
- u8 field_58[0x98 - 0x58];
- u16 field_98;
- u16 field_9A[3];
- struct UnkStruct_8019BA8 field_A0[8];
- u8 field_C0[12][15];
- u8 field_174[48];
- u8 field_1A4[200];
+ u8 unused2;
+ u8 tradeBoardListMenuId;
+ u16 playerSendBuffer[6];
+ u8 activityRequestStrbufs[4][16];
+ u16 partnerYesNoResponse;
+ u16 recvActivityRequest[3];
+ struct UnionRoomObject objects[MAX_UNION_ROOM_PLAYERS];
+ u8 trainerCardStrBuffer[12][15];
+ u8 trainerCardColorStrBuffer[48];
+ u8 trainerCardMsgStrBuffer[200];
};
-union UnkUnion_Main
+union WirelessLink_Main
{
- struct UnkStruct_Leader *leader;
- struct UnkStruct_Group *group;
- struct UnkStruct_URoom *uRoom;
+ struct WirelessLink_Leader *leader;
+ struct WirelessLink_Group *group;
+ struct WirelessLink_URoom *uRoom;
};
struct UnionRoomTrade
{
- u16 field_0;
+ u16 state;
u16 type;
u32 playerPersonality;
- u8 field_8;
- u8 field_9;
+ u8 offerPlayerId;
+ u8 filler1;
u16 playerSpecies;
u16 playerLevel;
u16 species;
u16 level;
- u16 field_12;
+ u16 filler2;
u32 personality;
};
// Exported RAM declarations
-extern u8 gUnknown_02022C2C;
-extern union UnkUnion_Main gUnknown_02022C30;
-extern struct GFtgtGnameSub gUnknown_02022C38;
+extern u8 gPlayerCurrActivity;
+extern union WirelessLink_Main gUnknown_02022C30;
+extern struct GFtgtGnameSub gPartnerTgtGnameSub;
extern u16 gUnionRoomOfferedSpecies;
extern u8 gUnionRoomRequestedMonType;
// Exported ROM declarations
-u8 sub_8013F78(void);
-void nullsub_89(u8 taskId);
-void var_800D_set_xB(void);
+u8 CreateTask_CreateTradeMenu(void);
+void SetUsingUnionRoomStartMenu(void);
void MEvent_CreateTask_CardOrNewsWithFriend(u32 arg0);
void MEvent_CreateTask_CardOrNewsOverWireless(u32 arg0);
void MEvent_CreateTask_Leader(u32 arg0);
+u8 CreateTask_ListenToWireless(void);
+void StartUnionRoomBattle(u16 battleFlags);
#endif //GUARD_UNION_ROOM_H
diff --git a/include/union_room_battle.h b/include/union_room_battle.h
index 2f5086008..ffccf197f 100644
--- a/include/union_room_battle.h
+++ b/include/union_room_battle.h
@@ -1,7 +1,6 @@
#ifndef GUARD_UNION_ROOM_BATTLE_H
#define GUARD_UNION_ROOM_BATTLE_H
-u8 sub_8013C40(void);
-void sub_8014210(u16 battleFlags);
+void CB2_UnionRoomBattle(void);
#endif //GUARD_UNION_ROOM_BATTLE_H
diff --git a/include/union_room_chat.h b/include/union_room_chat.h
index e7ca9d46e..dbd45c543 100755
--- a/include/union_room_chat.h
+++ b/include/union_room_chat.h
@@ -1,18 +1,7 @@
#ifndef GUARD_UNION_ROOM_CHAT_H
#define GUARD_UNION_ROOM_CHAT_H
-enum
-{
- UNION_ROOM_KB_PAGE_UPPER,
- UNION_ROOM_KB_PAGE_LOWER,
- UNION_ROOM_KB_PAGE_EMOJI,
- UNION_ROOM_KB_PAGE_COUNT
-};
-
-#define UNION_ROOM_KB_ROW_COUNT 10
-
-
-void sub_801DD98(void);
-void copy_strings_to_sav1(void);
+void EnterUnionRoomChat(void);
+void InitUnionRoomChatRegisteredTexts(void);
#endif // GUARD_UNION_ROOM_CHAT_H
diff --git a/include/union_room_player_avatar.h b/include/union_room_player_avatar.h
index 9870d0981..c7add758a 100644
--- a/include/union_room_player_avatar.h
+++ b/include/union_room_player_avatar.h
@@ -1,14 +1,14 @@
#ifndef GUARD_UNION_ROOM_PLAYER_AVATAR_H
#define GUARD_UNION_ROOM_PLAYER_AVATAR_H
-u8 sub_8019BA8(struct UnkStruct_8019BA8 * ptr);
-void sub_8019E3C(void);
-void sub_8019E70(u8 *arg0, s32 arg1);
-void sub_8019F04(u8 *spriteIds);
-void sub_8019F2C(void);
-void sub_801A274(struct UnkStruct_URoom *arg0);
-void sub_801A284(struct UnkStruct_URoom *arg0);
-bool32 sub_801A2A8(struct UnkStruct_Main0 *arg0, s16 *arg1, s16 *arg2, u8 *arg3);
-void sub_801A3D0(u32 arg0, u32 arg1, struct UnkStruct_Main0 *arg2);
+u8 InitUnionRoomPlayerObjects(struct UnionRoomObject *players);
+void DestroyUnionRoomPlayerObjects(void);
+void CreateGroupMemberSpritesInvisible(u8 *spriteIds, s32 playerIdx);
+void DestroyGroupMemberSprites(u8 *spriteIds);
+void SetTilesAroundUnionRoomPlayersPassable(void);
+void ScheduleUnionRoomPlayerRefresh(struct WirelessLink_URoom *uroom);
+void HandleUnionRoomPlayerRefresh(struct WirelessLink_URoom *uroom);
+bool32 TryInteractWithUnionRoomMember(struct UnkStruct_Main0 *main0, s16 *directionPtr, s16 *playerIdxPtr, u8 *spriteIds);
+void UpdateUnionRoomMemberFacing(u32 currDirection, u32 playerIdx, struct UnkStruct_Main0 *main0);
#endif //GUARD_UNION_ROOM_PLAYER_AVATAR_H
diff --git a/ld_script.txt b/ld_script.txt
index 74d9f6ae6..0e7e2f234 100644
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -65,6 +65,7 @@ SECTIONS {
src/union_room.o(.text);
src/mystery_gift.o(.text);
src/union_room_player_avatar.o(.text);
+ src/wireless_communication_status_screen.o(.text);
src/union_room_battle.o(.text);
src/mevent2.o(.text);
src/mevent_801BAAC.o(.text);
@@ -168,7 +169,7 @@ SECTIONS {
src/record_mixing.o(.text);
src/secret_base.o(.text);
src/tv.o(.text);
- src/contest_link_80F57C4.o(.text);
+ src/contest_util.o(.text);
src/script_pokemon_util_80F87D8.o(.text);
src/field_poison.o(.text);
src/pokemon_size_record.o(.text);
@@ -176,7 +177,7 @@ SECTIONS {
src/field_special_scene.o(.text);
src/rotating_gate.o(.text);
src/safari_zone.o(.text);
- src/contest_link_80FC4F4.o(.text);
+ src/contest_link.o(.text);
src/item_use.o(.text);
src/battle_anim_effects_1.o(.text);
src/battle_anim_effects_2.o(.text);
@@ -237,7 +238,7 @@ SECTIONS {
src/cable_car.o(.text);
src/math_util.o(.text);
src/roulette_util.o(.text);
- src/rom_81520A8.o(.text);
+ src/confetti_util.o(.text);
src/save.o(.text);
src/mystery_event_script.o(.text);
src/field_effect_helpers.o(.text);
@@ -328,7 +329,7 @@ SECTIONS {
src/trainer_hill.o(.text);
src/rayquaza_scene.o(.text);
src/walda_phrase.o(.text);
- src/contest_link_81D9DE4.o(.text);
+ src/contest_link_util.o(.text);
src/gym_leader_rematch.o(.text);
src/unk_transition.o(.text);
src/international_string_util.o(.text);
@@ -450,6 +451,7 @@ SECTIONS {
src/union_room.o(.rodata);
src/mystery_gift.o(.rodata);
src/union_room_player_avatar.o(.rodata);
+ src/wireless_communication_status_screen.o(.rodata);
src/union_room_battle.o(.rodata);
src/mevent2.o(.rodata);
src/mevent_801BAAC.o(.rodata);
@@ -542,13 +544,13 @@ SECTIONS {
src/record_mixing.o(.rodata);
src/secret_base.o(.rodata);
src/tv.o(.rodata);
- src/contest_link_80F57C4.o(.rodata);
+ src/contest_util.o(.rodata);
src/script_pokemon_util_80F87D8.o(.rodata);
src/pokemon_size_record.o(.rodata)
src/fldeff_misc.o(.rodata);
src/field_special_scene.o(.rodata);
src/rotating_gate.o(.rodata);
- src/contest_link_80FC4F4.o(.rodata);
+ src/contest_link.o(.rodata);
src/item_use.o(.rodata);
src/battle_anim_effects_1.o(.rodata);
src/battle_anim_effects_2.o(.rodata);
diff --git a/sound/direct_sound_data.inc b/sound/direct_sound_data.inc
index 80f91a01d..4a3a3b6d3 100644
--- a/sound/direct_sound_data.inc
+++ b/sound/direct_sound_data.inc
@@ -388,1555 +388,1555 @@ DirectSoundWaveData_8745A7C::
.align 2
Cry_Bulbasaur::
- .incbin "sound/direct_sound_samples/cry_bulbasaur.bin"
+ .incbin "sound/direct_sound_samples/cries/bulbasaur.bin"
.align 2
Cry_Ivysaur::
- .incbin "sound/direct_sound_samples/cry_ivysaur.bin"
+ .incbin "sound/direct_sound_samples/cries/ivysaur.bin"
.align 2
Cry_Venusaur::
- .incbin "sound/direct_sound_samples/cry_venusaur.bin"
+ .incbin "sound/direct_sound_samples/cries/venusaur.bin"
.align 2
Cry_Charmander::
- .incbin "sound/direct_sound_samples/cry_charmander.bin"
+ .incbin "sound/direct_sound_samples/cries/charmander.bin"
.align 2
Cry_Charmeleon::
- .incbin "sound/direct_sound_samples/cry_charmeleon.bin"
+ .incbin "sound/direct_sound_samples/cries/charmeleon.bin"
.align 2
Cry_Charizard::
- .incbin "sound/direct_sound_samples/cry_charizard.bin"
+ .incbin "sound/direct_sound_samples/cries/charizard.bin"
.align 2
Cry_Squirtle::
- .incbin "sound/direct_sound_samples/cry_squirtle.bin"
+ .incbin "sound/direct_sound_samples/cries/squirtle.bin"
.align 2
Cry_Wartortle::
- .incbin "sound/direct_sound_samples/cry_wartortle.bin"
+ .incbin "sound/direct_sound_samples/cries/wartortle.bin"
.align 2
Cry_Blastoise::
- .incbin "sound/direct_sound_samples/cry_blastoise.bin"
+ .incbin "sound/direct_sound_samples/cries/blastoise.bin"
.align 2
Cry_Caterpie::
- .incbin "sound/direct_sound_samples/cry_caterpie.bin"
+ .incbin "sound/direct_sound_samples/cries/caterpie.bin"
.align 2
Cry_Metapod::
- .incbin "sound/direct_sound_samples/cry_metapod.bin"
+ .incbin "sound/direct_sound_samples/cries/metapod.bin"
.align 2
Cry_Butterfree::
- .incbin "sound/direct_sound_samples/cry_butterfree.bin"
+ .incbin "sound/direct_sound_samples/cries/butterfree.bin"
.align 2
Cry_Weedle::
- .incbin "sound/direct_sound_samples/cry_weedle.bin"
+ .incbin "sound/direct_sound_samples/cries/weedle.bin"
.align 2
Cry_Kakuna::
- .incbin "sound/direct_sound_samples/cry_kakuna.bin"
+ .incbin "sound/direct_sound_samples/cries/kakuna.bin"
.align 2
Cry_Beedrill::
- .incbin "sound/direct_sound_samples/cry_beedrill.bin"
+ .incbin "sound/direct_sound_samples/cries/beedrill.bin"
.align 2
Cry_Pidgey::
- .incbin "sound/direct_sound_samples/cry_pidgey.bin"
+ .incbin "sound/direct_sound_samples/cries/pidgey.bin"
.align 2
Cry_Pidgeotto::
- .incbin "sound/direct_sound_samples/cry_pidgeotto.bin"
+ .incbin "sound/direct_sound_samples/cries/pidgeotto.bin"
.align 2
Cry_Pidgeot::
- .incbin "sound/direct_sound_samples/cry_pidgeot.bin"
+ .incbin "sound/direct_sound_samples/cries/pidgeot.bin"
.align 2
Cry_Rattata::
- .incbin "sound/direct_sound_samples/cry_rattata.bin"
+ .incbin "sound/direct_sound_samples/cries/rattata.bin"
.align 2
Cry_Raticate::
- .incbin "sound/direct_sound_samples/cry_raticate.bin"
+ .incbin "sound/direct_sound_samples/cries/raticate.bin"
.align 2
Cry_Spearow::
- .incbin "sound/direct_sound_samples/cry_spearow.bin"
+ .incbin "sound/direct_sound_samples/cries/spearow.bin"
.align 2
Cry_Fearow::
- .incbin "sound/direct_sound_samples/cry_fearow.bin"
+ .incbin "sound/direct_sound_samples/cries/fearow.bin"
.align 2
Cry_Ekans::
- .incbin "sound/direct_sound_samples/cry_ekans.bin"
+ .incbin "sound/direct_sound_samples/cries/ekans.bin"
.align 2
Cry_Arbok::
- .incbin "sound/direct_sound_samples/cry_arbok.bin"
+ .incbin "sound/direct_sound_samples/cries/arbok.bin"
.align 2
Cry_Pikachu::
- .incbin "sound/direct_sound_samples/cry_pikachu.bin"
+ .incbin "sound/direct_sound_samples/cries/pikachu.bin"
.align 2
Cry_Raichu::
- .incbin "sound/direct_sound_samples/cry_raichu.bin"
+ .incbin "sound/direct_sound_samples/cries/raichu.bin"
.align 2
Cry_Sandshrew::
- .incbin "sound/direct_sound_samples/cry_sandshrew.bin"
+ .incbin "sound/direct_sound_samples/cries/sandshrew.bin"
.align 2
Cry_Sandslash::
- .incbin "sound/direct_sound_samples/cry_sandslash.bin"
+ .incbin "sound/direct_sound_samples/cries/sandslash.bin"
.align 2
Cry_NidoranF::
- .incbin "sound/direct_sound_samples/cry_nidoran_f.bin"
+ .incbin "sound/direct_sound_samples/cries/nidoran_f.bin"
.align 2
Cry_Nidorina::
- .incbin "sound/direct_sound_samples/cry_nidorina.bin"
+ .incbin "sound/direct_sound_samples/cries/nidorina.bin"
.align 2
Cry_Nidoqueen::
- .incbin "sound/direct_sound_samples/cry_nidoqueen.bin"
+ .incbin "sound/direct_sound_samples/cries/nidoqueen.bin"
.align 2
Cry_NidoranM::
- .incbin "sound/direct_sound_samples/cry_nidoran_m.bin"
+ .incbin "sound/direct_sound_samples/cries/nidoran_m.bin"
.align 2
Cry_Nidorino::
- .incbin "sound/direct_sound_samples/cry_nidorino.bin"
+ .incbin "sound/direct_sound_samples/cries/nidorino.bin"
.align 2
Cry_Nidoking::
- .incbin "sound/direct_sound_samples/cry_nidoking.bin"
+ .incbin "sound/direct_sound_samples/cries/nidoking.bin"
.align 2
Cry_Clefairy::
- .incbin "sound/direct_sound_samples/cry_clefairy.bin"
+ .incbin "sound/direct_sound_samples/cries/clefairy.bin"
.align 2
Cry_Clefable::
- .incbin "sound/direct_sound_samples/cry_clefable.bin"
+ .incbin "sound/direct_sound_samples/cries/clefable.bin"
.align 2
Cry_Vulpix::
- .incbin "sound/direct_sound_samples/cry_vulpix.bin"
+ .incbin "sound/direct_sound_samples/cries/vulpix.bin"
.align 2
Cry_Ninetales::
- .incbin "sound/direct_sound_samples/cry_ninetales.bin"
+ .incbin "sound/direct_sound_samples/cries/ninetales.bin"
.align 2
Cry_Jigglypuff::
- .incbin "sound/direct_sound_samples/cry_jigglypuff.bin"
+ .incbin "sound/direct_sound_samples/cries/jigglypuff.bin"
.align 2
Cry_Wigglytuff::
- .incbin "sound/direct_sound_samples/cry_wigglytuff.bin"
+ .incbin "sound/direct_sound_samples/cries/wigglytuff.bin"
.align 2
Cry_Zubat::
- .incbin "sound/direct_sound_samples/cry_zubat.bin"
+ .incbin "sound/direct_sound_samples/cries/zubat.bin"
.align 2
Cry_Golbat::
- .incbin "sound/direct_sound_samples/cry_golbat.bin"
+ .incbin "sound/direct_sound_samples/cries/golbat.bin"
.align 2
Cry_Oddish::
- .incbin "sound/direct_sound_samples/cry_oddish.bin"
+ .incbin "sound/direct_sound_samples/cries/oddish.bin"
.align 2
Cry_Gloom::
- .incbin "sound/direct_sound_samples/cry_gloom.bin"
+ .incbin "sound/direct_sound_samples/cries/gloom.bin"
.align 2
Cry_Vileplume::
- .incbin "sound/direct_sound_samples/cry_vileplume.bin"
+ .incbin "sound/direct_sound_samples/cries/vileplume.bin"
.align 2
Cry_Paras::
- .incbin "sound/direct_sound_samples/cry_paras.bin"
+ .incbin "sound/direct_sound_samples/cries/paras.bin"
.align 2
Cry_Parasect::
- .incbin "sound/direct_sound_samples/cry_parasect.bin"
+ .incbin "sound/direct_sound_samples/cries/parasect.bin"
.align 2
Cry_Venonat::
- .incbin "sound/direct_sound_samples/cry_venonat.bin"
+ .incbin "sound/direct_sound_samples/cries/venonat.bin"
.align 2
Cry_Venomoth::
- .incbin "sound/direct_sound_samples/cry_venomoth.bin"
+ .incbin "sound/direct_sound_samples/cries/venomoth.bin"
.align 2
Cry_Diglett::
- .incbin "sound/direct_sound_samples/cry_diglett.bin"
+ .incbin "sound/direct_sound_samples/cries/diglett.bin"
.align 2
Cry_Dugtrio::
- .incbin "sound/direct_sound_samples/cry_dugtrio.bin"
+ .incbin "sound/direct_sound_samples/cries/dugtrio.bin"
.align 2
Cry_Meowth::
- .incbin "sound/direct_sound_samples/cry_meowth.bin"
+ .incbin "sound/direct_sound_samples/cries/meowth.bin"
.align 2
Cry_Persian::
- .incbin "sound/direct_sound_samples/cry_persian.bin"
+ .incbin "sound/direct_sound_samples/cries/persian.bin"
.align 2
Cry_Psyduck::
- .incbin "sound/direct_sound_samples/cry_psyduck.bin"
+ .incbin "sound/direct_sound_samples/cries/psyduck.bin"
.align 2
Cry_Golduck::
- .incbin "sound/direct_sound_samples/cry_golduck.bin"
+ .incbin "sound/direct_sound_samples/cries/golduck.bin"
.align 2
Cry_Mankey::
- .incbin "sound/direct_sound_samples/cry_mankey.bin"
+ .incbin "sound/direct_sound_samples/cries/mankey.bin"
.align 2
Cry_Primeape::
- .incbin "sound/direct_sound_samples/cry_primeape.bin"
+ .incbin "sound/direct_sound_samples/cries/primeape.bin"
.align 2
Cry_Growlithe::
- .incbin "sound/direct_sound_samples/cry_growlithe.bin"
+ .incbin "sound/direct_sound_samples/cries/growlithe.bin"
.align 2
Cry_Arcanine::
- .incbin "sound/direct_sound_samples/cry_arcanine.bin"
+ .incbin "sound/direct_sound_samples/cries/arcanine.bin"
.align 2
Cry_Poliwag::
- .incbin "sound/direct_sound_samples/cry_poliwag.bin"
+ .incbin "sound/direct_sound_samples/cries/poliwag.bin"
.align 2
Cry_Poliwhirl::
- .incbin "sound/direct_sound_samples/cry_poliwhirl.bin"
+ .incbin "sound/direct_sound_samples/cries/poliwhirl.bin"
.align 2
Cry_Poliwrath::
- .incbin "sound/direct_sound_samples/cry_poliwrath.bin"
+ .incbin "sound/direct_sound_samples/cries/poliwrath.bin"
.align 2
Cry_Abra::
- .incbin "sound/direct_sound_samples/cry_abra.bin"
+ .incbin "sound/direct_sound_samples/cries/abra.bin"
.align 2
Cry_Kadabra::
- .incbin "sound/direct_sound_samples/cry_kadabra.bin"
+ .incbin "sound/direct_sound_samples/cries/kadabra.bin"
.align 2
Cry_Alakazam::
- .incbin "sound/direct_sound_samples/cry_alakazam.bin"
+ .incbin "sound/direct_sound_samples/cries/alakazam.bin"
.align 2
Cry_Machop::
- .incbin "sound/direct_sound_samples/cry_machop.bin"
+ .incbin "sound/direct_sound_samples/cries/machop.bin"
.align 2
Cry_Machoke::
- .incbin "sound/direct_sound_samples/cry_machoke.bin"
+ .incbin "sound/direct_sound_samples/cries/machoke.bin"
.align 2
Cry_Machamp::
- .incbin "sound/direct_sound_samples/cry_machamp.bin"
+ .incbin "sound/direct_sound_samples/cries/machamp.bin"
.align 2
Cry_Bellsprout::
- .incbin "sound/direct_sound_samples/cry_bellsprout.bin"
+ .incbin "sound/direct_sound_samples/cries/bellsprout.bin"
.align 2
Cry_Weepinbell::
- .incbin "sound/direct_sound_samples/cry_weepinbell.bin"
+ .incbin "sound/direct_sound_samples/cries/weepinbell.bin"
.align 2
Cry_Victreebel::
- .incbin "sound/direct_sound_samples/cry_victreebel.bin"
+ .incbin "sound/direct_sound_samples/cries/victreebel.bin"
.align 2
Cry_Tentacool::
- .incbin "sound/direct_sound_samples/cry_tentacool.bin"
+ .incbin "sound/direct_sound_samples/cries/tentacool.bin"
.align 2
Cry_Tentacruel::
- .incbin "sound/direct_sound_samples/cry_tentacruel.bin"
+ .incbin "sound/direct_sound_samples/cries/tentacruel.bin"
.align 2
Cry_Geodude::
- .incbin "sound/direct_sound_samples/cry_geodude.bin"
+ .incbin "sound/direct_sound_samples/cries/geodude.bin"
.align 2
Cry_Graveler::
- .incbin "sound/direct_sound_samples/cry_graveler.bin"
+ .incbin "sound/direct_sound_samples/cries/graveler.bin"
.align 2
Cry_Golem::
- .incbin "sound/direct_sound_samples/cry_golem.bin"
+ .incbin "sound/direct_sound_samples/cries/golem.bin"
.align 2
Cry_Ponyta::
- .incbin "sound/direct_sound_samples/cry_ponyta.bin"
+ .incbin "sound/direct_sound_samples/cries/ponyta.bin"
.align 2
Cry_Rapidash::
- .incbin "sound/direct_sound_samples/cry_rapidash.bin"
+ .incbin "sound/direct_sound_samples/cries/rapidash.bin"
.align 2
Cry_Slowpoke::
- .incbin "sound/direct_sound_samples/cry_slowpoke.bin"
+ .incbin "sound/direct_sound_samples/cries/slowpoke.bin"
.align 2
Cry_Slowbro::
- .incbin "sound/direct_sound_samples/cry_slowbro.bin"
+ .incbin "sound/direct_sound_samples/cries/slowbro.bin"
.align 2
Cry_Magnemite::
- .incbin "sound/direct_sound_samples/cry_magnemite.bin"
+ .incbin "sound/direct_sound_samples/cries/magnemite.bin"
.align 2
Cry_Magneton::
- .incbin "sound/direct_sound_samples/cry_magneton.bin"
+ .incbin "sound/direct_sound_samples/cries/magneton.bin"
.align 2
Cry_Farfetchd::
- .incbin "sound/direct_sound_samples/cry_farfetchd.bin"
+ .incbin "sound/direct_sound_samples/cries/farfetchd.bin"
.align 2
Cry_Doduo::
- .incbin "sound/direct_sound_samples/cry_doduo.bin"
+ .incbin "sound/direct_sound_samples/cries/doduo.bin"
.align 2
Cry_Dodrio::
- .incbin "sound/direct_sound_samples/cry_dodrio.bin"
+ .incbin "sound/direct_sound_samples/cries/dodrio.bin"
.align 2
Cry_Seel::
- .incbin "sound/direct_sound_samples/cry_seel.bin"
+ .incbin "sound/direct_sound_samples/cries/seel.bin"
.align 2
Cry_Dewgong::
- .incbin "sound/direct_sound_samples/cry_dewgong.bin"
+ .incbin "sound/direct_sound_samples/cries/dewgong.bin"
.align 2
Cry_Grimer::
- .incbin "sound/direct_sound_samples/cry_grimer.bin"
+ .incbin "sound/direct_sound_samples/cries/grimer.bin"
.align 2
Cry_Muk::
- .incbin "sound/direct_sound_samples/cry_muk.bin"
+ .incbin "sound/direct_sound_samples/cries/muk.bin"
.align 2
Cry_Shellder::
- .incbin "sound/direct_sound_samples/cry_shellder.bin"
+ .incbin "sound/direct_sound_samples/cries/shellder.bin"
.align 2
Cry_Cloyster::
- .incbin "sound/direct_sound_samples/cry_cloyster.bin"
+ .incbin "sound/direct_sound_samples/cries/cloyster.bin"
.align 2
Cry_Gastly::
- .incbin "sound/direct_sound_samples/cry_gastly.bin"
+ .incbin "sound/direct_sound_samples/cries/gastly.bin"
.align 2
Cry_Haunter::
- .incbin "sound/direct_sound_samples/cry_haunter.bin"
+ .incbin "sound/direct_sound_samples/cries/haunter.bin"
.align 2
Cry_Gengar::
- .incbin "sound/direct_sound_samples/cry_gengar.bin"
+ .incbin "sound/direct_sound_samples/cries/gengar.bin"
.align 2
Cry_Onix::
- .incbin "sound/direct_sound_samples/cry_onix.bin"
+ .incbin "sound/direct_sound_samples/cries/onix.bin"
.align 2
Cry_Drowzee::
- .incbin "sound/direct_sound_samples/cry_drowzee.bin"
+ .incbin "sound/direct_sound_samples/cries/drowzee.bin"
.align 2
Cry_Hypno::
- .incbin "sound/direct_sound_samples/cry_hypno.bin"
+ .incbin "sound/direct_sound_samples/cries/hypno.bin"
.align 2
Cry_Krabby::
- .incbin "sound/direct_sound_samples/cry_krabby.bin"
+ .incbin "sound/direct_sound_samples/cries/krabby.bin"
.align 2
Cry_Kingler::
- .incbin "sound/direct_sound_samples/cry_kingler.bin"
+ .incbin "sound/direct_sound_samples/cries/kingler.bin"
.align 2
Cry_Voltorb::
- .incbin "sound/direct_sound_samples/cry_voltorb.bin"
+ .incbin "sound/direct_sound_samples/cries/voltorb.bin"
.align 2
Cry_Electrode::
- .incbin "sound/direct_sound_samples/cry_electrode.bin"
+ .incbin "sound/direct_sound_samples/cries/electrode.bin"
.align 2
Cry_Exeggcute::
- .incbin "sound/direct_sound_samples/cry_exeggcute.bin"
+ .incbin "sound/direct_sound_samples/cries/exeggcute.bin"
.align 2
Cry_Exeggutor::
- .incbin "sound/direct_sound_samples/cry_exeggutor.bin"
+ .incbin "sound/direct_sound_samples/cries/exeggutor.bin"
.align 2
Cry_Cubone::
- .incbin "sound/direct_sound_samples/cry_cubone.bin"
+ .incbin "sound/direct_sound_samples/cries/cubone.bin"
.align 2
Cry_Marowak::
- .incbin "sound/direct_sound_samples/cry_marowak.bin"
+ .incbin "sound/direct_sound_samples/cries/marowak.bin"
.align 2
Cry_Hitmonlee::
- .incbin "sound/direct_sound_samples/cry_hitmonlee.bin"
+ .incbin "sound/direct_sound_samples/cries/hitmonlee.bin"
.align 2
Cry_Hitmonchan::
- .incbin "sound/direct_sound_samples/cry_hitmonchan.bin"
+ .incbin "sound/direct_sound_samples/cries/hitmonchan.bin"
.align 2
Cry_Lickitung::
- .incbin "sound/direct_sound_samples/cry_lickitung.bin"
+ .incbin "sound/direct_sound_samples/cries/lickitung.bin"
.align 2
Cry_Koffing::
- .incbin "sound/direct_sound_samples/cry_koffing.bin"
+ .incbin "sound/direct_sound_samples/cries/koffing.bin"
.align 2
Cry_Weezing::
- .incbin "sound/direct_sound_samples/cry_weezing.bin"
+ .incbin "sound/direct_sound_samples/cries/weezing.bin"
.align 2
Cry_Rhyhorn::
- .incbin "sound/direct_sound_samples/cry_rhyhorn.bin"
+ .incbin "sound/direct_sound_samples/cries/rhyhorn.bin"
.align 2
Cry_Rhydon::
- .incbin "sound/direct_sound_samples/cry_rhydon.bin"
+ .incbin "sound/direct_sound_samples/cries/rhydon.bin"
.align 2
Cry_Chansey::
- .incbin "sound/direct_sound_samples/cry_chansey.bin"
+ .incbin "sound/direct_sound_samples/cries/chansey.bin"
.align 2
Cry_Tangela::
- .incbin "sound/direct_sound_samples/cry_tangela.bin"
+ .incbin "sound/direct_sound_samples/cries/tangela.bin"
.align 2
Cry_Kangaskhan::
- .incbin "sound/direct_sound_samples/cry_kangaskhan.bin"
+ .incbin "sound/direct_sound_samples/cries/kangaskhan.bin"
.align 2
Cry_Horsea::
- .incbin "sound/direct_sound_samples/cry_horsea.bin"
+ .incbin "sound/direct_sound_samples/cries/horsea.bin"
.align 2
Cry_Seadra::
- .incbin "sound/direct_sound_samples/cry_seadra.bin"
+ .incbin "sound/direct_sound_samples/cries/seadra.bin"
.align 2
Cry_Goldeen::
- .incbin "sound/direct_sound_samples/cry_goldeen.bin"
+ .incbin "sound/direct_sound_samples/cries/goldeen.bin"
.align 2
Cry_Seaking::
- .incbin "sound/direct_sound_samples/cry_seaking.bin"
+ .incbin "sound/direct_sound_samples/cries/seaking.bin"
.align 2
Cry_Staryu::
- .incbin "sound/direct_sound_samples/cry_staryu.bin"
+ .incbin "sound/direct_sound_samples/cries/staryu.bin"
.align 2
Cry_Starmie::
- .incbin "sound/direct_sound_samples/cry_starmie.bin"
+ .incbin "sound/direct_sound_samples/cries/starmie.bin"
.align 2
Cry_MrMime::
- .incbin "sound/direct_sound_samples/cry_mr_mime.bin"
+ .incbin "sound/direct_sound_samples/cries/mr_mime.bin"
.align 2
Cry_Scyther::
- .incbin "sound/direct_sound_samples/cry_scyther.bin"
+ .incbin "sound/direct_sound_samples/cries/scyther.bin"
.align 2
Cry_Jynx::
- .incbin "sound/direct_sound_samples/cry_jynx.bin"
+ .incbin "sound/direct_sound_samples/cries/jynx.bin"
.align 2
Cry_Electabuzz::
- .incbin "sound/direct_sound_samples/cry_electabuzz.bin"
+ .incbin "sound/direct_sound_samples/cries/electabuzz.bin"
.align 2
Cry_Magmar::
- .incbin "sound/direct_sound_samples/cry_magmar.bin"
+ .incbin "sound/direct_sound_samples/cries/magmar.bin"
.align 2
Cry_Pinsir::
- .incbin "sound/direct_sound_samples/cry_pinsir.bin"
+ .incbin "sound/direct_sound_samples/cries/pinsir.bin"
.align 2
Cry_Tauros::
- .incbin "sound/direct_sound_samples/cry_tauros.bin"
+ .incbin "sound/direct_sound_samples/cries/tauros.bin"
.align 2
Cry_Magikarp::
- .incbin "sound/direct_sound_samples/cry_magikarp.bin"
+ .incbin "sound/direct_sound_samples/cries/magikarp.bin"
.align 2
Cry_Gyarados::
- .incbin "sound/direct_sound_samples/cry_gyarados.bin"
+ .incbin "sound/direct_sound_samples/cries/gyarados.bin"
.align 2
Cry_Lapras::
- .incbin "sound/direct_sound_samples/cry_lapras.bin"
+ .incbin "sound/direct_sound_samples/cries/lapras.bin"
.align 2
Cry_Ditto::
- .incbin "sound/direct_sound_samples/cry_ditto.bin"
+ .incbin "sound/direct_sound_samples/cries/ditto.bin"
.align 2
Cry_Eevee::
- .incbin "sound/direct_sound_samples/cry_eevee.bin"
+ .incbin "sound/direct_sound_samples/cries/eevee.bin"
.align 2
Cry_Vaporeon::
- .incbin "sound/direct_sound_samples/cry_vaporeon.bin"
+ .incbin "sound/direct_sound_samples/cries/vaporeon.bin"
.align 2
Cry_Jolteon::
- .incbin "sound/direct_sound_samples/cry_jolteon.bin"
+ .incbin "sound/direct_sound_samples/cries/jolteon.bin"
.align 2
Cry_Flareon::
- .incbin "sound/direct_sound_samples/cry_flareon.bin"
+ .incbin "sound/direct_sound_samples/cries/flareon.bin"
.align 2
Cry_Porygon::
- .incbin "sound/direct_sound_samples/cry_porygon.bin"
+ .incbin "sound/direct_sound_samples/cries/porygon.bin"
.align 2
Cry_Omanyte::
- .incbin "sound/direct_sound_samples/cry_omanyte.bin"
+ .incbin "sound/direct_sound_samples/cries/omanyte.bin"
.align 2
Cry_Omastar::
- .incbin "sound/direct_sound_samples/cry_omastar.bin"
+ .incbin "sound/direct_sound_samples/cries/omastar.bin"
.align 2
Cry_Kabuto::
- .incbin "sound/direct_sound_samples/cry_kabuto.bin"
+ .incbin "sound/direct_sound_samples/cries/kabuto.bin"
.align 2
Cry_Kabutops::
- .incbin "sound/direct_sound_samples/cry_kabutops.bin"
+ .incbin "sound/direct_sound_samples/cries/kabutops.bin"
.align 2
Cry_Aerodactyl::
- .incbin "sound/direct_sound_samples/cry_aerodactyl.bin"
+ .incbin "sound/direct_sound_samples/cries/aerodactyl.bin"
.align 2
Cry_Snorlax::
- .incbin "sound/direct_sound_samples/cry_snorlax.bin"
+ .incbin "sound/direct_sound_samples/cries/snorlax.bin"
.align 2
Cry_Articuno::
- .incbin "sound/direct_sound_samples/cry_articuno.bin"
+ .incbin "sound/direct_sound_samples/cries/articuno.bin"
.align 2
Cry_Zapdos::
- .incbin "sound/direct_sound_samples/cry_zapdos.bin"
+ .incbin "sound/direct_sound_samples/cries/zapdos.bin"
.align 2
Cry_Moltres::
- .incbin "sound/direct_sound_samples/cry_moltres.bin"
+ .incbin "sound/direct_sound_samples/cries/moltres.bin"
.align 2
Cry_Dratini::
- .incbin "sound/direct_sound_samples/cry_dratini.bin"
+ .incbin "sound/direct_sound_samples/cries/dratini.bin"
.align 2
Cry_Dragonair::
- .incbin "sound/direct_sound_samples/cry_dragonair.bin"
+ .incbin "sound/direct_sound_samples/cries/dragonair.bin"
.align 2
Cry_Dragonite::
- .incbin "sound/direct_sound_samples/cry_dragonite.bin"
+ .incbin "sound/direct_sound_samples/cries/dragonite.bin"
.align 2
Cry_Mewtwo::
- .incbin "sound/direct_sound_samples/cry_mewtwo.bin"
+ .incbin "sound/direct_sound_samples/cries/mewtwo.bin"
.align 2
Cry_Mew::
- .incbin "sound/direct_sound_samples/cry_mew.bin"
+ .incbin "sound/direct_sound_samples/cries/mew.bin"
.align 2
Cry_Chikorita::
- .incbin "sound/direct_sound_samples/cry_chikorita.bin"
+ .incbin "sound/direct_sound_samples/cries/chikorita.bin"
.align 2
Cry_Bayleef::
- .incbin "sound/direct_sound_samples/cry_bayleef.bin"
+ .incbin "sound/direct_sound_samples/cries/bayleef.bin"
.align 2
Cry_Meganium::
- .incbin "sound/direct_sound_samples/cry_meganium.bin"
+ .incbin "sound/direct_sound_samples/cries/meganium.bin"
.align 2
Cry_Cyndaquil::
- .incbin "sound/direct_sound_samples/cry_cyndaquil.bin"
+ .incbin "sound/direct_sound_samples/cries/cyndaquil.bin"
.align 2
Cry_Quilava::
- .incbin "sound/direct_sound_samples/cry_quilava.bin"
+ .incbin "sound/direct_sound_samples/cries/quilava.bin"
.align 2
Cry_Typhlosion::
- .incbin "sound/direct_sound_samples/cry_typhlosion.bin"
+ .incbin "sound/direct_sound_samples/cries/typhlosion.bin"
.align 2
Cry_Totodile::
- .incbin "sound/direct_sound_samples/cry_totodile.bin"
+ .incbin "sound/direct_sound_samples/cries/totodile.bin"
.align 2
Cry_Croconaw::
- .incbin "sound/direct_sound_samples/cry_croconaw.bin"
+ .incbin "sound/direct_sound_samples/cries/croconaw.bin"
.align 2
Cry_Feraligatr::
- .incbin "sound/direct_sound_samples/cry_feraligatr.bin"
+ .incbin "sound/direct_sound_samples/cries/feraligatr.bin"
.align 2
Cry_Sentret::
- .incbin "sound/direct_sound_samples/cry_sentret.bin"
+ .incbin "sound/direct_sound_samples/cries/sentret.bin"
.align 2
Cry_Furret::
- .incbin "sound/direct_sound_samples/cry_furret.bin"
+ .incbin "sound/direct_sound_samples/cries/furret.bin"
.align 2
Cry_Hoothoot::
- .incbin "sound/direct_sound_samples/cry_hoothoot.bin"
+ .incbin "sound/direct_sound_samples/cries/hoothoot.bin"
.align 2
Cry_Noctowl::
- .incbin "sound/direct_sound_samples/cry_noctowl.bin"
+ .incbin "sound/direct_sound_samples/cries/noctowl.bin"
.align 2
Cry_Ledyba::
- .incbin "sound/direct_sound_samples/cry_ledyba.bin"
+ .incbin "sound/direct_sound_samples/cries/ledyba.bin"
.align 2
Cry_Ledian::
- .incbin "sound/direct_sound_samples/cry_ledian.bin"
+ .incbin "sound/direct_sound_samples/cries/ledian.bin"
.align 2
Cry_Spinarak::
- .incbin "sound/direct_sound_samples/cry_spinarak.bin"
+ .incbin "sound/direct_sound_samples/cries/spinarak.bin"
.align 2
Cry_Ariados::
- .incbin "sound/direct_sound_samples/cry_ariados.bin"
+ .incbin "sound/direct_sound_samples/cries/ariados.bin"
.align 2
Cry_Crobat::
- .incbin "sound/direct_sound_samples/cry_crobat.bin"
+ .incbin "sound/direct_sound_samples/cries/crobat.bin"
.align 2
Cry_Chinchou::
- .incbin "sound/direct_sound_samples/cry_chinchou.bin"
+ .incbin "sound/direct_sound_samples/cries/chinchou.bin"
.align 2
Cry_Lanturn::
- .incbin "sound/direct_sound_samples/cry_lanturn.bin"
+ .incbin "sound/direct_sound_samples/cries/lanturn.bin"
.align 2
Cry_Pichu::
- .incbin "sound/direct_sound_samples/cry_pichu.bin"
+ .incbin "sound/direct_sound_samples/cries/pichu.bin"
.align 2
Cry_Cleffa::
- .incbin "sound/direct_sound_samples/cry_cleffa.bin"
+ .incbin "sound/direct_sound_samples/cries/cleffa.bin"
.align 2
Cry_Igglybuff::
- .incbin "sound/direct_sound_samples/cry_igglybuff.bin"
+ .incbin "sound/direct_sound_samples/cries/igglybuff.bin"
.align 2
Cry_Togepi::
- .incbin "sound/direct_sound_samples/cry_togepi.bin"
+ .incbin "sound/direct_sound_samples/cries/togepi.bin"
.align 2
Cry_Togetic::
- .incbin "sound/direct_sound_samples/cry_togetic.bin"
+ .incbin "sound/direct_sound_samples/cries/togetic.bin"
.align 2
Cry_Natu::
- .incbin "sound/direct_sound_samples/cry_natu.bin"
+ .incbin "sound/direct_sound_samples/cries/natu.bin"
.align 2
Cry_Xatu::
- .incbin "sound/direct_sound_samples/cry_xatu.bin"
+ .incbin "sound/direct_sound_samples/cries/xatu.bin"
.align 2
Cry_Mareep::
- .incbin "sound/direct_sound_samples/cry_mareep.bin"
+ .incbin "sound/direct_sound_samples/cries/mareep.bin"
.align 2
Cry_Flaaffy::
- .incbin "sound/direct_sound_samples/cry_flaaffy.bin"
+ .incbin "sound/direct_sound_samples/cries/flaaffy.bin"
.align 2
Cry_Ampharos::
- .incbin "sound/direct_sound_samples/cry_ampharos.bin"
+ .incbin "sound/direct_sound_samples/cries/ampharos.bin"
.align 2
Cry_Bellossom::
- .incbin "sound/direct_sound_samples/cry_bellossom.bin"
+ .incbin "sound/direct_sound_samples/cries/bellossom.bin"
.align 2
Cry_Marill::
- .incbin "sound/direct_sound_samples/cry_marill.bin"
+ .incbin "sound/direct_sound_samples/cries/marill.bin"
.align 2
Cry_Azumarill::
- .incbin "sound/direct_sound_samples/cry_azumarill.bin"
+ .incbin "sound/direct_sound_samples/cries/azumarill.bin"
.align 2
Cry_Sudowoodo::
- .incbin "sound/direct_sound_samples/cry_sudowoodo.bin"
+ .incbin "sound/direct_sound_samples/cries/sudowoodo.bin"
.align 2
Cry_Politoed::
- .incbin "sound/direct_sound_samples/cry_politoed.bin"
+ .incbin "sound/direct_sound_samples/cries/politoed.bin"
.align 2
Cry_Hoppip::
- .incbin "sound/direct_sound_samples/cry_hoppip.bin"
+ .incbin "sound/direct_sound_samples/cries/hoppip.bin"
.align 2
Cry_Skiploom::
- .incbin "sound/direct_sound_samples/cry_skiploom.bin"
+ .incbin "sound/direct_sound_samples/cries/skiploom.bin"
.align 2
Cry_Jumpluff::
- .incbin "sound/direct_sound_samples/cry_jumpluff.bin"
+ .incbin "sound/direct_sound_samples/cries/jumpluff.bin"
.align 2
Cry_Aipom::
- .incbin "sound/direct_sound_samples/cry_aipom.bin"
+ .incbin "sound/direct_sound_samples/cries/aipom.bin"
.align 2
Cry_Sunkern::
- .incbin "sound/direct_sound_samples/cry_sunkern.bin"
+ .incbin "sound/direct_sound_samples/cries/sunkern.bin"
.align 2
Cry_Sunflora::
- .incbin "sound/direct_sound_samples/cry_sunflora.bin"
+ .incbin "sound/direct_sound_samples/cries/sunflora.bin"
.align 2
Cry_Yanma::
- .incbin "sound/direct_sound_samples/cry_yanma.bin"
+ .incbin "sound/direct_sound_samples/cries/yanma.bin"
.align 2
Cry_Wooper::
- .incbin "sound/direct_sound_samples/cry_wooper.bin"
+ .incbin "sound/direct_sound_samples/cries/wooper.bin"
.align 2
Cry_Quagsire::
- .incbin "sound/direct_sound_samples/cry_quagsire.bin"
+ .incbin "sound/direct_sound_samples/cries/quagsire.bin"
.align 2
Cry_Espeon::
- .incbin "sound/direct_sound_samples/cry_espeon.bin"
+ .incbin "sound/direct_sound_samples/cries/espeon.bin"
.align 2
Cry_Umbreon::
- .incbin "sound/direct_sound_samples/cry_umbreon.bin"
+ .incbin "sound/direct_sound_samples/cries/umbreon.bin"
.align 2
Cry_Murkrow::
- .incbin "sound/direct_sound_samples/cry_murkrow.bin"
+ .incbin "sound/direct_sound_samples/cries/murkrow.bin"
.align 2
Cry_Slowking::
- .incbin "sound/direct_sound_samples/cry_slowking.bin"
+ .incbin "sound/direct_sound_samples/cries/slowking.bin"
.align 2
Cry_Misdreavus::
- .incbin "sound/direct_sound_samples/cry_misdreavus.bin"
+ .incbin "sound/direct_sound_samples/cries/misdreavus.bin"
.align 2
Cry_Unown::
- .incbin "sound/direct_sound_samples/cry_unown.bin"
+ .incbin "sound/direct_sound_samples/cries/unown.bin"
.align 2
Cry_Wobbuffet::
- .incbin "sound/direct_sound_samples/cry_wobbuffet.bin"
+ .incbin "sound/direct_sound_samples/cries/wobbuffet.bin"
.align 2
Cry_Girafarig::
- .incbin "sound/direct_sound_samples/cry_girafarig.bin"
+ .incbin "sound/direct_sound_samples/cries/girafarig.bin"
.align 2
Cry_Pineco::
- .incbin "sound/direct_sound_samples/cry_pineco.bin"
+ .incbin "sound/direct_sound_samples/cries/pineco.bin"
.align 2
Cry_Forretress::
- .incbin "sound/direct_sound_samples/cry_forretress.bin"
+ .incbin "sound/direct_sound_samples/cries/forretress.bin"
.align 2
Cry_Dunsparce::
- .incbin "sound/direct_sound_samples/cry_dunsparce.bin"
+ .incbin "sound/direct_sound_samples/cries/dunsparce.bin"
.align 2
Cry_Gligar::
- .incbin "sound/direct_sound_samples/cry_gligar.bin"
+ .incbin "sound/direct_sound_samples/cries/gligar.bin"
.align 2
Cry_Steelix::
- .incbin "sound/direct_sound_samples/cry_steelix.bin"
+ .incbin "sound/direct_sound_samples/cries/steelix.bin"
.align 2
Cry_Snubbull::
- .incbin "sound/direct_sound_samples/cry_snubbull.bin"
+ .incbin "sound/direct_sound_samples/cries/snubbull.bin"
.align 2
Cry_Granbull::
- .incbin "sound/direct_sound_samples/cry_granbull.bin"
+ .incbin "sound/direct_sound_samples/cries/granbull.bin"
.align 2
Cry_Qwilfish::
- .incbin "sound/direct_sound_samples/cry_qwilfish.bin"
+ .incbin "sound/direct_sound_samples/cries/qwilfish.bin"
.align 2
Cry_Scizor::
- .incbin "sound/direct_sound_samples/cry_scizor.bin"
+ .incbin "sound/direct_sound_samples/cries/scizor.bin"
.align 2
Cry_Shuckle::
- .incbin "sound/direct_sound_samples/cry_shuckle.bin"
+ .incbin "sound/direct_sound_samples/cries/shuckle.bin"
.align 2
Cry_Heracross::
- .incbin "sound/direct_sound_samples/cry_heracross.bin"
+ .incbin "sound/direct_sound_samples/cries/heracross.bin"
.align 2
Cry_Sneasel::
- .incbin "sound/direct_sound_samples/cry_sneasel.bin"
+ .incbin "sound/direct_sound_samples/cries/sneasel.bin"
.align 2
Cry_Teddiursa::
- .incbin "sound/direct_sound_samples/cry_teddiursa.bin"
+ .incbin "sound/direct_sound_samples/cries/teddiursa.bin"
.align 2
Cry_Ursaring::
- .incbin "sound/direct_sound_samples/cry_ursaring.bin"
+ .incbin "sound/direct_sound_samples/cries/ursaring.bin"
.align 2
Cry_Slugma::
- .incbin "sound/direct_sound_samples/cry_slugma.bin"
+ .incbin "sound/direct_sound_samples/cries/slugma.bin"
.align 2
Cry_Magcargo::
- .incbin "sound/direct_sound_samples/cry_magcargo.bin"
+ .incbin "sound/direct_sound_samples/cries/magcargo.bin"
.align 2
Cry_Swinub::
- .incbin "sound/direct_sound_samples/cry_swinub.bin"
+ .incbin "sound/direct_sound_samples/cries/swinub.bin"
.align 2
Cry_Piloswine::
- .incbin "sound/direct_sound_samples/cry_piloswine.bin"
+ .incbin "sound/direct_sound_samples/cries/piloswine.bin"
.align 2
Cry_Corsola::
- .incbin "sound/direct_sound_samples/cry_corsola.bin"
+ .incbin "sound/direct_sound_samples/cries/corsola.bin"
.align 2
Cry_Remoraid::
- .incbin "sound/direct_sound_samples/cry_remoraid.bin"
+ .incbin "sound/direct_sound_samples/cries/remoraid.bin"
.align 2
Cry_Octillery::
- .incbin "sound/direct_sound_samples/cry_octillery.bin"
+ .incbin "sound/direct_sound_samples/cries/octillery.bin"
.align 2
Cry_Delibird::
- .incbin "sound/direct_sound_samples/cry_delibird.bin"
+ .incbin "sound/direct_sound_samples/cries/delibird.bin"
.align 2
Cry_Mantine::
- .incbin "sound/direct_sound_samples/cry_mantine.bin"
+ .incbin "sound/direct_sound_samples/cries/mantine.bin"
.align 2
Cry_Skarmory::
- .incbin "sound/direct_sound_samples/cry_skarmory.bin"
+ .incbin "sound/direct_sound_samples/cries/skarmory.bin"
.align 2
Cry_Houndour::
- .incbin "sound/direct_sound_samples/cry_houndour.bin"
+ .incbin "sound/direct_sound_samples/cries/houndour.bin"
.align 2
Cry_Houndoom::
- .incbin "sound/direct_sound_samples/cry_houndoom.bin"
+ .incbin "sound/direct_sound_samples/cries/houndoom.bin"
.align 2
Cry_Kingdra::
- .incbin "sound/direct_sound_samples/cry_kingdra.bin"
+ .incbin "sound/direct_sound_samples/cries/kingdra.bin"
.align 2
Cry_Phanpy::
- .incbin "sound/direct_sound_samples/cry_phanpy.bin"
+ .incbin "sound/direct_sound_samples/cries/phanpy.bin"
.align 2
Cry_Donphan::
- .incbin "sound/direct_sound_samples/cry_donphan.bin"
+ .incbin "sound/direct_sound_samples/cries/donphan.bin"
.align 2
Cry_Porygon2::
- .incbin "sound/direct_sound_samples/cry_porygon2.bin"
+ .incbin "sound/direct_sound_samples/cries/porygon2.bin"
.align 2
Cry_Stantler::
- .incbin "sound/direct_sound_samples/cry_stantler.bin"
+ .incbin "sound/direct_sound_samples/cries/stantler.bin"
.align 2
Cry_Smeargle::
- .incbin "sound/direct_sound_samples/cry_smeargle.bin"
+ .incbin "sound/direct_sound_samples/cries/smeargle.bin"
.align 2
Cry_Tyrogue::
- .incbin "sound/direct_sound_samples/cry_tyrogue.bin"
+ .incbin "sound/direct_sound_samples/cries/tyrogue.bin"
.align 2
Cry_Hitmontop::
- .incbin "sound/direct_sound_samples/cry_hitmontop.bin"
+ .incbin "sound/direct_sound_samples/cries/hitmontop.bin"
.align 2
Cry_Smoochum::
- .incbin "sound/direct_sound_samples/cry_smoochum.bin"
+ .incbin "sound/direct_sound_samples/cries/smoochum.bin"
.align 2
Cry_Elekid::
- .incbin "sound/direct_sound_samples/cry_elekid.bin"
+ .incbin "sound/direct_sound_samples/cries/elekid.bin"
.align 2
Cry_Magby::
- .incbin "sound/direct_sound_samples/cry_magby.bin"
+ .incbin "sound/direct_sound_samples/cries/magby.bin"
.align 2
Cry_Miltank::
- .incbin "sound/direct_sound_samples/cry_miltank.bin"
+ .incbin "sound/direct_sound_samples/cries/miltank.bin"
.align 2
Cry_Blissey::
- .incbin "sound/direct_sound_samples/cry_blissey.bin"
+ .incbin "sound/direct_sound_samples/cries/blissey.bin"
.align 2
Cry_Raikou::
- .incbin "sound/direct_sound_samples/cry_raikou.bin"
+ .incbin "sound/direct_sound_samples/cries/raikou.bin"
.align 2
Cry_Entei::
- .incbin "sound/direct_sound_samples/cry_entei.bin"
+ .incbin "sound/direct_sound_samples/cries/entei.bin"
.align 2
Cry_Suicune::
- .incbin "sound/direct_sound_samples/cry_suicune.bin"
+ .incbin "sound/direct_sound_samples/cries/suicune.bin"
.align 2
Cry_Larvitar::
- .incbin "sound/direct_sound_samples/cry_larvitar.bin"
+ .incbin "sound/direct_sound_samples/cries/larvitar.bin"
.align 2
Cry_Pupitar::
- .incbin "sound/direct_sound_samples/cry_pupitar.bin"
+ .incbin "sound/direct_sound_samples/cries/pupitar.bin"
.align 2
Cry_Tyranitar::
- .incbin "sound/direct_sound_samples/cry_tyranitar.bin"
+ .incbin "sound/direct_sound_samples/cries/tyranitar.bin"
.align 2
Cry_Lugia::
- .incbin "sound/direct_sound_samples/cry_lugia.bin"
+ .incbin "sound/direct_sound_samples/cries/lugia.bin"
.align 2
Cry_HoOh::
- .incbin "sound/direct_sound_samples/cry_ho_oh.bin"
+ .incbin "sound/direct_sound_samples/cries/ho_oh.bin"
.align 2
Cry_Celebi::
- .incbin "sound/direct_sound_samples/cry_celebi.bin"
+ .incbin "sound/direct_sound_samples/cries/celebi.bin"
.align 2
Cry_Kecleon::
- .incbin "sound/direct_sound_samples/cry_kecleon.bin"
+ .incbin "sound/direct_sound_samples/cries/kecleon.bin"
.align 2
Cry_Roselia::
- .incbin "sound/direct_sound_samples/cry_roselia.bin"
+ .incbin "sound/direct_sound_samples/cries/roselia.bin"
.align 2
Cry_Torkoal::
- .incbin "sound/direct_sound_samples/cry_torkoal.bin"
+ .incbin "sound/direct_sound_samples/cries/torkoal.bin"
.align 2
Cry_Electrike::
- .incbin "sound/direct_sound_samples/cry_electrike.bin"
+ .incbin "sound/direct_sound_samples/cries/electrike.bin"
.align 2
Cry_Manectric::
- .incbin "sound/direct_sound_samples/cry_manectric.bin"
+ .incbin "sound/direct_sound_samples/cries/manectric.bin"
.align 2
Cry_Duskull::
- .incbin "sound/direct_sound_samples/cry_duskull.bin"
+ .incbin "sound/direct_sound_samples/cries/duskull.bin"
.align 2
Cry_Latias::
- .incbin "sound/direct_sound_samples/cry_latias.bin"
+ .incbin "sound/direct_sound_samples/cries/latias.bin"
.align 2
Cry_Wynaut::
- .incbin "sound/direct_sound_samples/cry_wynaut.bin"
+ .incbin "sound/direct_sound_samples/cries/wynaut.bin"
.align 2
Cry_Seviper::
- .incbin "sound/direct_sound_samples/cry_seviper.bin"
+ .incbin "sound/direct_sound_samples/cries/seviper.bin"
.align 2
Cry_Sharpedo::
- .incbin "sound/direct_sound_samples/cry_sharpedo.bin"
+ .incbin "sound/direct_sound_samples/cries/sharpedo.bin"
.align 2
Cry_Zangoose::
- .incbin "sound/direct_sound_samples/cry_zangoose.bin"
+ .incbin "sound/direct_sound_samples/cries/zangoose.bin"
.align 2
Cry_Azurill::
- .incbin "sound/direct_sound_samples/cry_azurill.bin"
+ .incbin "sound/direct_sound_samples/cries/azurill.bin"
.align 2
Cry_Swablu::
- .incbin "sound/direct_sound_samples/cry_swablu.bin"
+ .incbin "sound/direct_sound_samples/cries/swablu.bin"
.align 2
Cry_Altaria::
- .incbin "sound/direct_sound_samples/cry_altaria.bin"
+ .incbin "sound/direct_sound_samples/cries/altaria.bin"
.align 2
Cry_Unused265::
- .incbin "sound/direct_sound_samples/cry_unused_265.bin"
+ .incbin "sound/direct_sound_samples/cries/unused_265.bin"
.align 2
Cry_Taillow::
- .incbin "sound/direct_sound_samples/cry_taillow.bin"
+ .incbin "sound/direct_sound_samples/cries/taillow.bin"
.align 2
Cry_Swellow::
- .incbin "sound/direct_sound_samples/cry_swellow.bin"
+ .incbin "sound/direct_sound_samples/cries/swellow.bin"
.align 2
Cry_Unused268::
- .incbin "sound/direct_sound_samples/cry_unused_268.bin"
+ .incbin "sound/direct_sound_samples/cries/unused_268.bin"
.align 2
Cry_Spinda::
- .incbin "sound/direct_sound_samples/cry_spinda.bin"
+ .incbin "sound/direct_sound_samples/cries/spinda.bin"
.align 2
Cry_Torchic::
- .incbin "sound/direct_sound_samples/cry_torchic.bin"
+ .incbin "sound/direct_sound_samples/cries/torchic.bin"
.align 2
Cry_Combusken::
- .incbin "sound/direct_sound_samples/cry_combusken.bin"
+ .incbin "sound/direct_sound_samples/cries/combusken.bin"
.align 2
Cry_Blaziken::
- .incbin "sound/direct_sound_samples/cry_blaziken.bin"
+ .incbin "sound/direct_sound_samples/cries/blaziken.bin"
.align 2
Cry_Treecko::
- .incbin "sound/direct_sound_samples/cry_treecko.bin"
+ .incbin "sound/direct_sound_samples/cries/treecko.bin"
.align 2
Cry_Grovyle::
- .incbin "sound/direct_sound_samples/cry_grovyle.bin"
+ .incbin "sound/direct_sound_samples/cries/grovyle.bin"
.align 2
Cry_Sceptile::
- .incbin "sound/direct_sound_samples/cry_sceptile.bin"
+ .incbin "sound/direct_sound_samples/cries/sceptile.bin"
.align 2
Cry_Mudkip::
- .incbin "sound/direct_sound_samples/cry_mudkip.bin"
+ .incbin "sound/direct_sound_samples/cries/mudkip.bin"
.align 2
Cry_Marshtomp::
- .incbin "sound/direct_sound_samples/cry_marshtomp.bin"
+ .incbin "sound/direct_sound_samples/cries/marshtomp.bin"
.align 2
Cry_Swampert::
- .incbin "sound/direct_sound_samples/cry_swampert.bin"
+ .incbin "sound/direct_sound_samples/cries/swampert.bin"
.align 2
Cry_Pelipper::
- .incbin "sound/direct_sound_samples/cry_pelipper.bin"
+ .incbin "sound/direct_sound_samples/cries/pelipper.bin"
.align 2
Cry_Wingull::
- .incbin "sound/direct_sound_samples/cry_wingull.bin"
+ .incbin "sound/direct_sound_samples/cries/wingull.bin"
.align 2
Cry_Banette::
- .incbin "sound/direct_sound_samples/cry_banette.bin"
+ .incbin "sound/direct_sound_samples/cries/banette.bin"
.align 2
Cry_Shuppet::
- .incbin "sound/direct_sound_samples/cry_shuppet.bin"
+ .incbin "sound/direct_sound_samples/cries/shuppet.bin"
.align 2
Cry_Lotad::
- .incbin "sound/direct_sound_samples/cry_lotad.bin"
+ .incbin "sound/direct_sound_samples/cries/lotad.bin"
.align 2
Cry_Lombre::
- .incbin "sound/direct_sound_samples/cry_lombre.bin"
+ .incbin "sound/direct_sound_samples/cries/lombre.bin"
.align 2
Cry_Ludicolo::
- .incbin "sound/direct_sound_samples/cry_ludicolo.bin"
+ .incbin "sound/direct_sound_samples/cries/ludicolo.bin"
.align 2
Cry_Seedot::
- .incbin "sound/direct_sound_samples/cry_seedot.bin"
+ .incbin "sound/direct_sound_samples/cries/seedot.bin"
.align 2
Cry_Nuzleaf::
- .incbin "sound/direct_sound_samples/cry_nuzleaf.bin"
+ .incbin "sound/direct_sound_samples/cries/nuzleaf.bin"
.align 2
Cry_Shiftry::
- .incbin "sound/direct_sound_samples/cry_shiftry.bin"
+ .incbin "sound/direct_sound_samples/cries/shiftry.bin"
.align 2
Cry_Carvanha::
- .incbin "sound/direct_sound_samples/cry_carvanha.bin"
+ .incbin "sound/direct_sound_samples/cries/carvanha.bin"
.align 2
Cry_Wurmple::
- .incbin "sound/direct_sound_samples/cry_wurmple.bin"
+ .incbin "sound/direct_sound_samples/cries/wurmple.bin"
.align 2
Cry_Silcoon::
- .incbin "sound/direct_sound_samples/cry_silcoon.bin"
+ .incbin "sound/direct_sound_samples/cries/silcoon.bin"
.align 2
Cry_Beautifly::
- .incbin "sound/direct_sound_samples/cry_beautifly.bin"
+ .incbin "sound/direct_sound_samples/cries/beautifly.bin"
.align 2
Cry_Cascoon::
- .incbin "sound/direct_sound_samples/cry_cascoon.bin"
+ .incbin "sound/direct_sound_samples/cries/cascoon.bin"
.align 2
Cry_Dustox::
- .incbin "sound/direct_sound_samples/cry_dustox.bin"
+ .incbin "sound/direct_sound_samples/cries/dustox.bin"
.align 2
Cry_Ralts::
- .incbin "sound/direct_sound_samples/cry_ralts.bin"
+ .incbin "sound/direct_sound_samples/cries/ralts.bin"
.align 2
Cry_Kirlia::
- .incbin "sound/direct_sound_samples/cry_kirlia.bin"
+ .incbin "sound/direct_sound_samples/cries/kirlia.bin"
.align 2
Cry_Gardevoir::
- .incbin "sound/direct_sound_samples/cry_gardevoir.bin"
+ .incbin "sound/direct_sound_samples/cries/gardevoir.bin"
.align 2
Cry_Slakoth::
- .incbin "sound/direct_sound_samples/cry_slakoth.bin"
+ .incbin "sound/direct_sound_samples/cries/slakoth.bin"
.align 2
Cry_Vigoroth::
- .incbin "sound/direct_sound_samples/cry_vigoroth.bin"
+ .incbin "sound/direct_sound_samples/cries/vigoroth.bin"
.align 2
Cry_Slaking::
- .incbin "sound/direct_sound_samples/cry_slaking.bin"
+ .incbin "sound/direct_sound_samples/cries/slaking.bin"
.align 2
Cry_Nincada::
- .incbin "sound/direct_sound_samples/cry_nincada.bin"
+ .incbin "sound/direct_sound_samples/cries/nincada.bin"
.align 2
Cry_Ninjask::
- .incbin "sound/direct_sound_samples/cry_ninjask.bin"
+ .incbin "sound/direct_sound_samples/cries/ninjask.bin"
.align 2
Cry_Shedinja::
- .incbin "sound/direct_sound_samples/cry_shedinja.bin"
+ .incbin "sound/direct_sound_samples/cries/shedinja.bin"
.align 2
Cry_Makuhita::
- .incbin "sound/direct_sound_samples/cry_makuhita.bin"
+ .incbin "sound/direct_sound_samples/cries/makuhita.bin"
.align 2
Cry_Hariyama::
- .incbin "sound/direct_sound_samples/cry_hariyama.bin"
+ .incbin "sound/direct_sound_samples/cries/hariyama.bin"
.align 2
Cry_Nosepass::
- .incbin "sound/direct_sound_samples/cry_nosepass.bin"
+ .incbin "sound/direct_sound_samples/cries/nosepass.bin"
.align 2
Cry_Glalie::
- .incbin "sound/direct_sound_samples/cry_glalie.bin"
+ .incbin "sound/direct_sound_samples/cries/glalie.bin"
.align 2
Cry_Plusle::
- .incbin "sound/direct_sound_samples/cry_plusle.bin"
+ .incbin "sound/direct_sound_samples/cries/plusle.bin"
.align 2
Cry_Minun::
- .incbin "sound/direct_sound_samples/cry_minun.bin"
+ .incbin "sound/direct_sound_samples/cries/minun.bin"
.align 2
Cry_Surskit::
- .incbin "sound/direct_sound_samples/cry_surskit.bin"
+ .incbin "sound/direct_sound_samples/cries/surskit.bin"
.align 2
Cry_Masquerain::
- .incbin "sound/direct_sound_samples/cry_masquerain.bin"
+ .incbin "sound/direct_sound_samples/cries/masquerain.bin"
.align 2
Cry_Skitty::
- .incbin "sound/direct_sound_samples/cry_skitty.bin"
+ .incbin "sound/direct_sound_samples/cries/skitty.bin"
.align 2
Cry_Delcatty::
- .incbin "sound/direct_sound_samples/cry_delcatty.bin"
+ .incbin "sound/direct_sound_samples/cries/delcatty.bin"
.align 2
Cry_Gulpin::
- .incbin "sound/direct_sound_samples/cry_gulpin.bin"
+ .incbin "sound/direct_sound_samples/cries/gulpin.bin"
.align 2
Cry_Swalot::
- .incbin "sound/direct_sound_samples/cry_swalot.bin"
+ .incbin "sound/direct_sound_samples/cries/swalot.bin"
.align 2
Cry_Numel::
- .incbin "sound/direct_sound_samples/cry_numel.bin"
+ .incbin "sound/direct_sound_samples/cries/numel.bin"
.align 2
Cry_Camerupt::
- .incbin "sound/direct_sound_samples/cry_camerupt.bin"
+ .incbin "sound/direct_sound_samples/cries/camerupt.bin"
.align 2
Cry_Barboach::
- .incbin "sound/direct_sound_samples/cry_barboach.bin"
+ .incbin "sound/direct_sound_samples/cries/barboach.bin"
.align 2
Cry_Whiscash::
- .incbin "sound/direct_sound_samples/cry_whiscash.bin"
+ .incbin "sound/direct_sound_samples/cries/whiscash.bin"
.align 2
Cry_Corphish::
- .incbin "sound/direct_sound_samples/cry_corphish.bin"
+ .incbin "sound/direct_sound_samples/cries/corphish.bin"
.align 2
Cry_Crawdaunt::
- .incbin "sound/direct_sound_samples/cry_crawdaunt.bin"
+ .incbin "sound/direct_sound_samples/cries/crawdaunt.bin"
.align 2
Cry_Spoink::
- .incbin "sound/direct_sound_samples/cry_spoink.bin"
+ .incbin "sound/direct_sound_samples/cries/spoink.bin"
.align 2
Cry_Grumpig::
- .incbin "sound/direct_sound_samples/cry_grumpig.bin"
+ .incbin "sound/direct_sound_samples/cries/grumpig.bin"
.align 2
Cry_Trapinch::
- .incbin "sound/direct_sound_samples/cry_trapinch.bin"
+ .incbin "sound/direct_sound_samples/cries/trapinch.bin"
.align 2
Cry_Vibrava::
- .incbin "sound/direct_sound_samples/cry_vibrava.bin"
+ .incbin "sound/direct_sound_samples/cries/vibrava.bin"
.align 2
Cry_Flygon::
- .incbin "sound/direct_sound_samples/cry_flygon.bin"
+ .incbin "sound/direct_sound_samples/cries/flygon.bin"
.align 2
Cry_Cacnea::
- .incbin "sound/direct_sound_samples/cry_cacnea.bin"
+ .incbin "sound/direct_sound_samples/cries/cacnea.bin"
.align 2
Cry_Cacturne::
- .incbin "sound/direct_sound_samples/cry_cacturne.bin"
+ .incbin "sound/direct_sound_samples/cries/cacturne.bin"
.align 2
Cry_Baltoy::
- .incbin "sound/direct_sound_samples/cry_baltoy.bin"
+ .incbin "sound/direct_sound_samples/cries/baltoy.bin"
.align 2
Cry_Claydol::
- .incbin "sound/direct_sound_samples/cry_claydol.bin"
+ .incbin "sound/direct_sound_samples/cries/claydol.bin"
.align 2
Cry_Lunatone::
- .incbin "sound/direct_sound_samples/cry_lunatone.bin"
+ .incbin "sound/direct_sound_samples/cries/lunatone.bin"
.align 2
Cry_Solrock::
- .incbin "sound/direct_sound_samples/cry_solrock.bin"
+ .incbin "sound/direct_sound_samples/cries/solrock.bin"
.align 2
Cry_Feebas::
- .incbin "sound/direct_sound_samples/cry_feebas.bin"
+ .incbin "sound/direct_sound_samples/cries/feebas.bin"
.align 2
Cry_Milotic::
- .incbin "sound/direct_sound_samples/cry_milotic.bin"
+ .incbin "sound/direct_sound_samples/cries/milotic.bin"
.align 2
Cry_Absol::
- .incbin "sound/direct_sound_samples/cry_absol.bin"
+ .incbin "sound/direct_sound_samples/cries/absol.bin"
.align 2
Cry_Meditite::
- .incbin "sound/direct_sound_samples/cry_meditite.bin"
+ .incbin "sound/direct_sound_samples/cries/meditite.bin"
.align 2
Cry_Medicham::
- .incbin "sound/direct_sound_samples/cry_medicham.bin"
+ .incbin "sound/direct_sound_samples/cries/medicham.bin"
.align 2
Cry_Spheal::
- .incbin "sound/direct_sound_samples/cry_spheal.bin"
+ .incbin "sound/direct_sound_samples/cries/spheal.bin"
.align 2
Cry_Sealeo::
- .incbin "sound/direct_sound_samples/cry_sealeo.bin"
+ .incbin "sound/direct_sound_samples/cries/sealeo.bin"
.align 2
Cry_Walrein::
- .incbin "sound/direct_sound_samples/cry_walrein.bin"
+ .incbin "sound/direct_sound_samples/cries/walrein.bin"
.align 2
Cry_Clamperl::
- .incbin "sound/direct_sound_samples/cry_clamperl.bin"
+ .incbin "sound/direct_sound_samples/cries/clamperl.bin"
.align 2
Cry_Huntail::
- .incbin "sound/direct_sound_samples/cry_huntail.bin"
+ .incbin "sound/direct_sound_samples/cries/huntail.bin"
.align 2
Cry_Gorebyss::
- .incbin "sound/direct_sound_samples/cry_gorebyss.bin"
+ .incbin "sound/direct_sound_samples/cries/gorebyss.bin"
.align 2
Cry_Lileep::
- .incbin "sound/direct_sound_samples/cry_lileep.bin"
+ .incbin "sound/direct_sound_samples/cries/lileep.bin"
.align 2
Cry_Cradily::
- .incbin "sound/direct_sound_samples/cry_cradily.bin"
+ .incbin "sound/direct_sound_samples/cries/cradily.bin"
.align 2
Cry_Anorith::
- .incbin "sound/direct_sound_samples/cry_anorith.bin"
+ .incbin "sound/direct_sound_samples/cries/anorith.bin"
.align 2
Cry_Armaldo::
- .incbin "sound/direct_sound_samples/cry_armaldo.bin"
+ .incbin "sound/direct_sound_samples/cries/armaldo.bin"
.align 2
Cry_Beldum::
- .incbin "sound/direct_sound_samples/cry_beldum.bin"
+ .incbin "sound/direct_sound_samples/cries/beldum.bin"
.align 2
Cry_Metang::
- .incbin "sound/direct_sound_samples/cry_metang.bin"
+ .incbin "sound/direct_sound_samples/cries/metang.bin"
.align 2
Cry_Metagross::
- .incbin "sound/direct_sound_samples/cry_metagross.bin"
+ .incbin "sound/direct_sound_samples/cries/metagross.bin"
.align 2
Cry_Bagon::
- .incbin "sound/direct_sound_samples/cry_bagon.bin"
+ .incbin "sound/direct_sound_samples/cries/bagon.bin"
.align 2
Cry_Shelgon::
- .incbin "sound/direct_sound_samples/cry_shelgon.bin"
+ .incbin "sound/direct_sound_samples/cries/shelgon.bin"
.align 2
Cry_Regirock::
- .incbin "sound/direct_sound_samples/cry_regirock.bin"
+ .incbin "sound/direct_sound_samples/cries/regirock.bin"
.align 2
Cry_Regice::
- .incbin "sound/direct_sound_samples/cry_regice.bin"
+ .incbin "sound/direct_sound_samples/cries/regice.bin"
.align 2
Cry_Registeel::
- .incbin "sound/direct_sound_samples/cry_registeel.bin"
+ .incbin "sound/direct_sound_samples/cries/registeel.bin"
.align 2
Cry_Castform::
- .incbin "sound/direct_sound_samples/cry_castform.bin"
+ .incbin "sound/direct_sound_samples/cries/castform.bin"
.align 2
Cry_Volbeat::
- .incbin "sound/direct_sound_samples/cry_volbeat.bin"
+ .incbin "sound/direct_sound_samples/cries/volbeat.bin"
.align 2
Cry_Illumise::
- .incbin "sound/direct_sound_samples/cry_illumise.bin"
+ .incbin "sound/direct_sound_samples/cries/illumise.bin"
.align 2
Cry_Poochyena::
- .incbin "sound/direct_sound_samples/cry_poochyena.bin"
+ .incbin "sound/direct_sound_samples/cries/poochyena.bin"
.align 2
Cry_Mightyena::
- .incbin "sound/direct_sound_samples/cry_mightyena.bin"
+ .incbin "sound/direct_sound_samples/cries/mightyena.bin"
.align 2
Cry_Dusclops::
- .incbin "sound/direct_sound_samples/cry_dusclops.bin"
+ .incbin "sound/direct_sound_samples/cries/dusclops.bin"
.align 2
Cry_Sableye::
- .incbin "sound/direct_sound_samples/cry_sableye.bin"
+ .incbin "sound/direct_sound_samples/cries/sableye.bin"
.align 2
Cry_Mawile::
- .incbin "sound/direct_sound_samples/cry_mawile.bin"
+ .incbin "sound/direct_sound_samples/cries/mawile.bin"
.align 2
Cry_Aron::
- .incbin "sound/direct_sound_samples/cry_aron.bin"
+ .incbin "sound/direct_sound_samples/cries/aron.bin"
.align 2
Cry_Lairon::
- .incbin "sound/direct_sound_samples/cry_lairon.bin"
+ .incbin "sound/direct_sound_samples/cries/lairon.bin"
.align 2
Cry_Aggron::
- .incbin "sound/direct_sound_samples/cry_aggron.bin"
+ .incbin "sound/direct_sound_samples/cries/aggron.bin"
.align 2
Cry_Relicanth::
- .incbin "sound/direct_sound_samples/cry_relicanth.bin"
+ .incbin "sound/direct_sound_samples/cries/relicanth.bin"
.align 2
Cry_Luvdisc::
- .incbin "sound/direct_sound_samples/cry_luvdisc.bin"
+ .incbin "sound/direct_sound_samples/cries/luvdisc.bin"
.align 2
Cry_Groudon::
- .incbin "sound/direct_sound_samples/cry_groudon.bin"
+ .incbin "sound/direct_sound_samples/cries/groudon.bin"
.align 2
Cry_Kyogre::
- .incbin "sound/direct_sound_samples/cry_kyogre.bin"
+ .incbin "sound/direct_sound_samples/cries/kyogre.bin"
.align 2
Cry_Rayquaza::
- .incbin "sound/direct_sound_samples/cry_rayquaza.bin"
+ .incbin "sound/direct_sound_samples/cries/rayquaza.bin"
.align 2
Cry_Salamence::
- .incbin "sound/direct_sound_samples/cry_salamence.bin"
+ .incbin "sound/direct_sound_samples/cries/salamence.bin"
.align 2
Cry_Breloom::
- .incbin "sound/direct_sound_samples/cry_breloom.bin"
+ .incbin "sound/direct_sound_samples/cries/breloom.bin"
.align 2
Cry_Shroomish::
- .incbin "sound/direct_sound_samples/cry_shroomish.bin"
+ .incbin "sound/direct_sound_samples/cries/shroomish.bin"
.align 2
Cry_Linoone::
- .incbin "sound/direct_sound_samples/cry_linoone.bin"
+ .incbin "sound/direct_sound_samples/cries/linoone.bin"
.align 2
Cry_Tropius::
- .incbin "sound/direct_sound_samples/cry_tropius.bin"
+ .incbin "sound/direct_sound_samples/cries/tropius.bin"
.align 2
Cry_Wailmer::
- .incbin "sound/direct_sound_samples/cry_wailmer.bin"
+ .incbin "sound/direct_sound_samples/cries/wailmer.bin"
.align 2
Cry_Zigzagoon::
- .incbin "sound/direct_sound_samples/cry_zigzagoon.bin"
+ .incbin "sound/direct_sound_samples/cries/zigzagoon.bin"
.align 2
Cry_Exploud::
- .incbin "sound/direct_sound_samples/cry_exploud.bin"
+ .incbin "sound/direct_sound_samples/cries/exploud.bin"
.align 2
Cry_Loudred::
- .incbin "sound/direct_sound_samples/cry_loudred.bin"
+ .incbin "sound/direct_sound_samples/cries/loudred.bin"
.align 2
Cry_Wailord::
- .incbin "sound/direct_sound_samples/cry_wailord.bin"
+ .incbin "sound/direct_sound_samples/cries/wailord.bin"
.align 2
Cry_Whismur::
- .incbin "sound/direct_sound_samples/cry_whismur.bin"
+ .incbin "sound/direct_sound_samples/cries/whismur.bin"
.align 2
Cry_Snorunt::
- .incbin "sound/direct_sound_samples/cry_snorunt.bin"
+ .incbin "sound/direct_sound_samples/cries/snorunt.bin"
.align 2
Cry_Latios::
- .incbin "sound/direct_sound_samples/cry_latios.bin"
+ .incbin "sound/direct_sound_samples/cries/latios.bin"
.align 2
Cry_Jirachi::
- .incbin "sound/direct_sound_samples/cry_jirachi.bin"
+ .incbin "sound/direct_sound_samples/cries/jirachi.bin"
.align 2
Cry_Deoxys::
- .incbin "sound/direct_sound_samples/cry_deoxys.bin"
+ .incbin "sound/direct_sound_samples/cries/deoxys.bin"
.align 2
Cry_Chimecho::
- .incbin "sound/direct_sound_samples/cry_chimecho.bin"
+ .incbin "sound/direct_sound_samples/cries/chimecho.bin"
.align 2
DirectSoundWaveData_register_noise::
diff --git a/sound/direct_sound_samples/cry_abra.aif b/sound/direct_sound_samples/cries/abra.aif
index 7df4446db..7df4446db 100644
--- a/sound/direct_sound_samples/cry_abra.aif
+++ b/sound/direct_sound_samples/cries/abra.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_absol.aif b/sound/direct_sound_samples/cries/absol.aif
index 884ab22b3..884ab22b3 100644
--- a/sound/direct_sound_samples/cry_absol.aif
+++ b/sound/direct_sound_samples/cries/absol.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_aerodactyl.aif b/sound/direct_sound_samples/cries/aerodactyl.aif
index c0e40f6d1..c0e40f6d1 100644
--- a/sound/direct_sound_samples/cry_aerodactyl.aif
+++ b/sound/direct_sound_samples/cries/aerodactyl.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_aggron.aif b/sound/direct_sound_samples/cries/aggron.aif
index b89ea1222..b89ea1222 100644
--- a/sound/direct_sound_samples/cry_aggron.aif
+++ b/sound/direct_sound_samples/cries/aggron.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_aipom.aif b/sound/direct_sound_samples/cries/aipom.aif
index 5ca276de2..5ca276de2 100644
--- a/sound/direct_sound_samples/cry_aipom.aif
+++ b/sound/direct_sound_samples/cries/aipom.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_alakazam.aif b/sound/direct_sound_samples/cries/alakazam.aif
index 920e2ff94..920e2ff94 100644
--- a/sound/direct_sound_samples/cry_alakazam.aif
+++ b/sound/direct_sound_samples/cries/alakazam.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_altaria.aif b/sound/direct_sound_samples/cries/altaria.aif
index 3e8e35e8e..3e8e35e8e 100644
--- a/sound/direct_sound_samples/cry_altaria.aif
+++ b/sound/direct_sound_samples/cries/altaria.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_ampharos.aif b/sound/direct_sound_samples/cries/ampharos.aif
index 4f6e255a0..4f6e255a0 100644
--- a/sound/direct_sound_samples/cry_ampharos.aif
+++ b/sound/direct_sound_samples/cries/ampharos.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_anorith.aif b/sound/direct_sound_samples/cries/anorith.aif
index 96e87e919..96e87e919 100644
--- a/sound/direct_sound_samples/cry_anorith.aif
+++ b/sound/direct_sound_samples/cries/anorith.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_arbok.aif b/sound/direct_sound_samples/cries/arbok.aif
index 6ccace9f9..6ccace9f9 100644
--- a/sound/direct_sound_samples/cry_arbok.aif
+++ b/sound/direct_sound_samples/cries/arbok.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_arcanine.aif b/sound/direct_sound_samples/cries/arcanine.aif
index 61d802153..61d802153 100644
--- a/sound/direct_sound_samples/cry_arcanine.aif
+++ b/sound/direct_sound_samples/cries/arcanine.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_ariados.aif b/sound/direct_sound_samples/cries/ariados.aif
index 1748624fb..1748624fb 100644
--- a/sound/direct_sound_samples/cry_ariados.aif
+++ b/sound/direct_sound_samples/cries/ariados.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_armaldo.aif b/sound/direct_sound_samples/cries/armaldo.aif
index 756bf0842..756bf0842 100644
--- a/sound/direct_sound_samples/cry_armaldo.aif
+++ b/sound/direct_sound_samples/cries/armaldo.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_aron.aif b/sound/direct_sound_samples/cries/aron.aif
index cce70b73b..cce70b73b 100644
--- a/sound/direct_sound_samples/cry_aron.aif
+++ b/sound/direct_sound_samples/cries/aron.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_articuno.aif b/sound/direct_sound_samples/cries/articuno.aif
index 4f237dd0f..4f237dd0f 100644
--- a/sound/direct_sound_samples/cry_articuno.aif
+++ b/sound/direct_sound_samples/cries/articuno.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_azumarill.aif b/sound/direct_sound_samples/cries/azumarill.aif
index 18411f93c..18411f93c 100644
--- a/sound/direct_sound_samples/cry_azumarill.aif
+++ b/sound/direct_sound_samples/cries/azumarill.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_azurill.aif b/sound/direct_sound_samples/cries/azurill.aif
index 7f651c3d3..7f651c3d3 100644
--- a/sound/direct_sound_samples/cry_azurill.aif
+++ b/sound/direct_sound_samples/cries/azurill.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_bagon.aif b/sound/direct_sound_samples/cries/bagon.aif
index 3843fb9f4..3843fb9f4 100644
--- a/sound/direct_sound_samples/cry_bagon.aif
+++ b/sound/direct_sound_samples/cries/bagon.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_baltoy.aif b/sound/direct_sound_samples/cries/baltoy.aif
index 25e1a708a..25e1a708a 100644
--- a/sound/direct_sound_samples/cry_baltoy.aif
+++ b/sound/direct_sound_samples/cries/baltoy.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_banette.aif b/sound/direct_sound_samples/cries/banette.aif
index 23713f1b5..23713f1b5 100644
--- a/sound/direct_sound_samples/cry_banette.aif
+++ b/sound/direct_sound_samples/cries/banette.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_barboach.aif b/sound/direct_sound_samples/cries/barboach.aif
index 4b9228259..4b9228259 100644
--- a/sound/direct_sound_samples/cry_barboach.aif
+++ b/sound/direct_sound_samples/cries/barboach.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_bayleef.aif b/sound/direct_sound_samples/cries/bayleef.aif
index 8cef22df3..8cef22df3 100644
--- a/sound/direct_sound_samples/cry_bayleef.aif
+++ b/sound/direct_sound_samples/cries/bayleef.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_beautifly.aif b/sound/direct_sound_samples/cries/beautifly.aif
index 0924b6c55..0924b6c55 100644
--- a/sound/direct_sound_samples/cry_beautifly.aif
+++ b/sound/direct_sound_samples/cries/beautifly.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_beedrill.aif b/sound/direct_sound_samples/cries/beedrill.aif
index 00d0bc96c..00d0bc96c 100644
--- a/sound/direct_sound_samples/cry_beedrill.aif
+++ b/sound/direct_sound_samples/cries/beedrill.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_beldum.aif b/sound/direct_sound_samples/cries/beldum.aif
index 76435a6a8..76435a6a8 100644
--- a/sound/direct_sound_samples/cry_beldum.aif
+++ b/sound/direct_sound_samples/cries/beldum.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_bellossom.aif b/sound/direct_sound_samples/cries/bellossom.aif
index 86580df65..86580df65 100644
--- a/sound/direct_sound_samples/cry_bellossom.aif
+++ b/sound/direct_sound_samples/cries/bellossom.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_bellsprout.aif b/sound/direct_sound_samples/cries/bellsprout.aif
index cfdd7aed2..cfdd7aed2 100644
--- a/sound/direct_sound_samples/cry_bellsprout.aif
+++ b/sound/direct_sound_samples/cries/bellsprout.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_blastoise.aif b/sound/direct_sound_samples/cries/blastoise.aif
index 76dac2bcc..76dac2bcc 100644
--- a/sound/direct_sound_samples/cry_blastoise.aif
+++ b/sound/direct_sound_samples/cries/blastoise.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_blaziken.aif b/sound/direct_sound_samples/cries/blaziken.aif
index 83e5ccf23..83e5ccf23 100644
--- a/sound/direct_sound_samples/cry_blaziken.aif
+++ b/sound/direct_sound_samples/cries/blaziken.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_blissey.aif b/sound/direct_sound_samples/cries/blissey.aif
index 897eb3d69..897eb3d69 100644
--- a/sound/direct_sound_samples/cry_blissey.aif
+++ b/sound/direct_sound_samples/cries/blissey.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_breloom.aif b/sound/direct_sound_samples/cries/breloom.aif
index ea3f1bb66..ea3f1bb66 100644
--- a/sound/direct_sound_samples/cry_breloom.aif
+++ b/sound/direct_sound_samples/cries/breloom.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_bulbasaur.aif b/sound/direct_sound_samples/cries/bulbasaur.aif
index 040fb1df7..040fb1df7 100644
--- a/sound/direct_sound_samples/cry_bulbasaur.aif
+++ b/sound/direct_sound_samples/cries/bulbasaur.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_butterfree.aif b/sound/direct_sound_samples/cries/butterfree.aif
index f27616395..f27616395 100644
--- a/sound/direct_sound_samples/cry_butterfree.aif
+++ b/sound/direct_sound_samples/cries/butterfree.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_cacnea.aif b/sound/direct_sound_samples/cries/cacnea.aif
index 4fd5acd36..4fd5acd36 100644
--- a/sound/direct_sound_samples/cry_cacnea.aif
+++ b/sound/direct_sound_samples/cries/cacnea.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_cacturne.aif b/sound/direct_sound_samples/cries/cacturne.aif
index d9fb8fda8..d9fb8fda8 100644
--- a/sound/direct_sound_samples/cry_cacturne.aif
+++ b/sound/direct_sound_samples/cries/cacturne.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_camerupt.aif b/sound/direct_sound_samples/cries/camerupt.aif
index 325df1220..325df1220 100644
--- a/sound/direct_sound_samples/cry_camerupt.aif
+++ b/sound/direct_sound_samples/cries/camerupt.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_carvanha.aif b/sound/direct_sound_samples/cries/carvanha.aif
index c7cdedf91..c7cdedf91 100644
--- a/sound/direct_sound_samples/cry_carvanha.aif
+++ b/sound/direct_sound_samples/cries/carvanha.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_cascoon.aif b/sound/direct_sound_samples/cries/cascoon.aif
index 17eef0ee9..17eef0ee9 100644
--- a/sound/direct_sound_samples/cry_cascoon.aif
+++ b/sound/direct_sound_samples/cries/cascoon.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_castform.aif b/sound/direct_sound_samples/cries/castform.aif
index c10745640..c10745640 100644
--- a/sound/direct_sound_samples/cry_castform.aif
+++ b/sound/direct_sound_samples/cries/castform.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_caterpie.aif b/sound/direct_sound_samples/cries/caterpie.aif
index b0b246b4f..b0b246b4f 100644
--- a/sound/direct_sound_samples/cry_caterpie.aif
+++ b/sound/direct_sound_samples/cries/caterpie.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_celebi.aif b/sound/direct_sound_samples/cries/celebi.aif
index 9f9f3ea39..9f9f3ea39 100644
--- a/sound/direct_sound_samples/cry_celebi.aif
+++ b/sound/direct_sound_samples/cries/celebi.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_chansey.aif b/sound/direct_sound_samples/cries/chansey.aif
index d764c86ce..d764c86ce 100644
--- a/sound/direct_sound_samples/cry_chansey.aif
+++ b/sound/direct_sound_samples/cries/chansey.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_charizard.aif b/sound/direct_sound_samples/cries/charizard.aif
index 48321b792..48321b792 100644
--- a/sound/direct_sound_samples/cry_charizard.aif
+++ b/sound/direct_sound_samples/cries/charizard.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_charmander.aif b/sound/direct_sound_samples/cries/charmander.aif
index d72c0f9e0..d72c0f9e0 100644
--- a/sound/direct_sound_samples/cry_charmander.aif
+++ b/sound/direct_sound_samples/cries/charmander.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_charmeleon.aif b/sound/direct_sound_samples/cries/charmeleon.aif
index 8e84af0d8..8e84af0d8 100644
--- a/sound/direct_sound_samples/cry_charmeleon.aif
+++ b/sound/direct_sound_samples/cries/charmeleon.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_chikorita.aif b/sound/direct_sound_samples/cries/chikorita.aif
index 67ceafdc3..67ceafdc3 100644
--- a/sound/direct_sound_samples/cry_chikorita.aif
+++ b/sound/direct_sound_samples/cries/chikorita.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_chimecho.aif b/sound/direct_sound_samples/cries/chimecho.aif
index 87ee2faee..87ee2faee 100644
--- a/sound/direct_sound_samples/cry_chimecho.aif
+++ b/sound/direct_sound_samples/cries/chimecho.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_chinchou.aif b/sound/direct_sound_samples/cries/chinchou.aif
index 356475678..356475678 100644
--- a/sound/direct_sound_samples/cry_chinchou.aif
+++ b/sound/direct_sound_samples/cries/chinchou.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_clamperl.aif b/sound/direct_sound_samples/cries/clamperl.aif
index 7250bd703..7250bd703 100644
--- a/sound/direct_sound_samples/cry_clamperl.aif
+++ b/sound/direct_sound_samples/cries/clamperl.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_claydol.aif b/sound/direct_sound_samples/cries/claydol.aif
index b89772021..b89772021 100644
--- a/sound/direct_sound_samples/cry_claydol.aif
+++ b/sound/direct_sound_samples/cries/claydol.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_clefable.aif b/sound/direct_sound_samples/cries/clefable.aif
index 9c2d8c664..9c2d8c664 100644
--- a/sound/direct_sound_samples/cry_clefable.aif
+++ b/sound/direct_sound_samples/cries/clefable.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_clefairy.aif b/sound/direct_sound_samples/cries/clefairy.aif
index c370c4a9b..c370c4a9b 100644
--- a/sound/direct_sound_samples/cry_clefairy.aif
+++ b/sound/direct_sound_samples/cries/clefairy.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_cleffa.aif b/sound/direct_sound_samples/cries/cleffa.aif
index b27cdeca9..b27cdeca9 100644
--- a/sound/direct_sound_samples/cry_cleffa.aif
+++ b/sound/direct_sound_samples/cries/cleffa.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_cloyster.aif b/sound/direct_sound_samples/cries/cloyster.aif
index b406deab0..b406deab0 100644
--- a/sound/direct_sound_samples/cry_cloyster.aif
+++ b/sound/direct_sound_samples/cries/cloyster.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_combusken.aif b/sound/direct_sound_samples/cries/combusken.aif
index 7d4b0d4cc..7d4b0d4cc 100644
--- a/sound/direct_sound_samples/cry_combusken.aif
+++ b/sound/direct_sound_samples/cries/combusken.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_corphish.aif b/sound/direct_sound_samples/cries/corphish.aif
index f0f5ca01e..f0f5ca01e 100644
--- a/sound/direct_sound_samples/cry_corphish.aif
+++ b/sound/direct_sound_samples/cries/corphish.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_corsola.aif b/sound/direct_sound_samples/cries/corsola.aif
index 68e743bfd..68e743bfd 100644
--- a/sound/direct_sound_samples/cry_corsola.aif
+++ b/sound/direct_sound_samples/cries/corsola.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_cradily.aif b/sound/direct_sound_samples/cries/cradily.aif
index 197dc8d92..197dc8d92 100644
--- a/sound/direct_sound_samples/cry_cradily.aif
+++ b/sound/direct_sound_samples/cries/cradily.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_crawdaunt.aif b/sound/direct_sound_samples/cries/crawdaunt.aif
index a203ce2fb..a203ce2fb 100644
--- a/sound/direct_sound_samples/cry_crawdaunt.aif
+++ b/sound/direct_sound_samples/cries/crawdaunt.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_crobat.aif b/sound/direct_sound_samples/cries/crobat.aif
index 75d039bd8..75d039bd8 100644
--- a/sound/direct_sound_samples/cry_crobat.aif
+++ b/sound/direct_sound_samples/cries/crobat.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_croconaw.aif b/sound/direct_sound_samples/cries/croconaw.aif
index afb7f3fdc..afb7f3fdc 100644
--- a/sound/direct_sound_samples/cry_croconaw.aif
+++ b/sound/direct_sound_samples/cries/croconaw.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_cubone.aif b/sound/direct_sound_samples/cries/cubone.aif
index 170745da1..170745da1 100644
--- a/sound/direct_sound_samples/cry_cubone.aif
+++ b/sound/direct_sound_samples/cries/cubone.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_cyndaquil.aif b/sound/direct_sound_samples/cries/cyndaquil.aif
index 4aa580199..4aa580199 100644
--- a/sound/direct_sound_samples/cry_cyndaquil.aif
+++ b/sound/direct_sound_samples/cries/cyndaquil.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_delcatty.aif b/sound/direct_sound_samples/cries/delcatty.aif
index dd665b110..dd665b110 100644
--- a/sound/direct_sound_samples/cry_delcatty.aif
+++ b/sound/direct_sound_samples/cries/delcatty.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_delibird.aif b/sound/direct_sound_samples/cries/delibird.aif
index dbedc42d4..dbedc42d4 100644
--- a/sound/direct_sound_samples/cry_delibird.aif
+++ b/sound/direct_sound_samples/cries/delibird.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_deoxys.aif b/sound/direct_sound_samples/cries/deoxys.aif
index b9623b337..b9623b337 100644
--- a/sound/direct_sound_samples/cry_deoxys.aif
+++ b/sound/direct_sound_samples/cries/deoxys.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_dewgong.aif b/sound/direct_sound_samples/cries/dewgong.aif
index 72d69b773..72d69b773 100644
--- a/sound/direct_sound_samples/cry_dewgong.aif
+++ b/sound/direct_sound_samples/cries/dewgong.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_diglett.aif b/sound/direct_sound_samples/cries/diglett.aif
index b116af7f2..b116af7f2 100644
--- a/sound/direct_sound_samples/cry_diglett.aif
+++ b/sound/direct_sound_samples/cries/diglett.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_ditto.aif b/sound/direct_sound_samples/cries/ditto.aif
index 2c797f4c4..2c797f4c4 100644
--- a/sound/direct_sound_samples/cry_ditto.aif
+++ b/sound/direct_sound_samples/cries/ditto.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_dodrio.aif b/sound/direct_sound_samples/cries/dodrio.aif
index 111d8bf3e..111d8bf3e 100644
--- a/sound/direct_sound_samples/cry_dodrio.aif
+++ b/sound/direct_sound_samples/cries/dodrio.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_doduo.aif b/sound/direct_sound_samples/cries/doduo.aif
index 5700b91d9..5700b91d9 100644
--- a/sound/direct_sound_samples/cry_doduo.aif
+++ b/sound/direct_sound_samples/cries/doduo.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_donphan.aif b/sound/direct_sound_samples/cries/donphan.aif
index a41c124b1..a41c124b1 100644
--- a/sound/direct_sound_samples/cry_donphan.aif
+++ b/sound/direct_sound_samples/cries/donphan.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_dragonair.aif b/sound/direct_sound_samples/cries/dragonair.aif
index 38c3955ef..38c3955ef 100644
--- a/sound/direct_sound_samples/cry_dragonair.aif
+++ b/sound/direct_sound_samples/cries/dragonair.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_dragonite.aif b/sound/direct_sound_samples/cries/dragonite.aif
index d1e7b11cf..d1e7b11cf 100644
--- a/sound/direct_sound_samples/cry_dragonite.aif
+++ b/sound/direct_sound_samples/cries/dragonite.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_dratini.aif b/sound/direct_sound_samples/cries/dratini.aif
index 298497480..298497480 100644
--- a/sound/direct_sound_samples/cry_dratini.aif
+++ b/sound/direct_sound_samples/cries/dratini.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_drowzee.aif b/sound/direct_sound_samples/cries/drowzee.aif
index 0d53eb2ff..0d53eb2ff 100644
--- a/sound/direct_sound_samples/cry_drowzee.aif
+++ b/sound/direct_sound_samples/cries/drowzee.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_dugtrio.aif b/sound/direct_sound_samples/cries/dugtrio.aif
index dff573dfe..dff573dfe 100644
--- a/sound/direct_sound_samples/cry_dugtrio.aif
+++ b/sound/direct_sound_samples/cries/dugtrio.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_dunsparce.aif b/sound/direct_sound_samples/cries/dunsparce.aif
index 454617c05..454617c05 100644
--- a/sound/direct_sound_samples/cry_dunsparce.aif
+++ b/sound/direct_sound_samples/cries/dunsparce.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_dusclops.aif b/sound/direct_sound_samples/cries/dusclops.aif
index de9657e4f..de9657e4f 100644
--- a/sound/direct_sound_samples/cry_dusclops.aif
+++ b/sound/direct_sound_samples/cries/dusclops.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_duskull.aif b/sound/direct_sound_samples/cries/duskull.aif
index d84ea274e..d84ea274e 100644
--- a/sound/direct_sound_samples/cry_duskull.aif
+++ b/sound/direct_sound_samples/cries/duskull.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_dustox.aif b/sound/direct_sound_samples/cries/dustox.aif
index 56d8eb336..56d8eb336 100644
--- a/sound/direct_sound_samples/cry_dustox.aif
+++ b/sound/direct_sound_samples/cries/dustox.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_eevee.aif b/sound/direct_sound_samples/cries/eevee.aif
index 8711a1470..8711a1470 100644
--- a/sound/direct_sound_samples/cry_eevee.aif
+++ b/sound/direct_sound_samples/cries/eevee.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_ekans.aif b/sound/direct_sound_samples/cries/ekans.aif
index 9eb396735..9eb396735 100644
--- a/sound/direct_sound_samples/cry_ekans.aif
+++ b/sound/direct_sound_samples/cries/ekans.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_electabuzz.aif b/sound/direct_sound_samples/cries/electabuzz.aif
index 5abdb49b7..5abdb49b7 100644
--- a/sound/direct_sound_samples/cry_electabuzz.aif
+++ b/sound/direct_sound_samples/cries/electabuzz.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_electrike.aif b/sound/direct_sound_samples/cries/electrike.aif
index 56c9666df..56c9666df 100644
--- a/sound/direct_sound_samples/cry_electrike.aif
+++ b/sound/direct_sound_samples/cries/electrike.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_electrode.aif b/sound/direct_sound_samples/cries/electrode.aif
index cbd7f0971..cbd7f0971 100644
--- a/sound/direct_sound_samples/cry_electrode.aif
+++ b/sound/direct_sound_samples/cries/electrode.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_elekid.aif b/sound/direct_sound_samples/cries/elekid.aif
index 839bdee17..839bdee17 100644
--- a/sound/direct_sound_samples/cry_elekid.aif
+++ b/sound/direct_sound_samples/cries/elekid.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_entei.aif b/sound/direct_sound_samples/cries/entei.aif
index 56a740207..56a740207 100644
--- a/sound/direct_sound_samples/cry_entei.aif
+++ b/sound/direct_sound_samples/cries/entei.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_espeon.aif b/sound/direct_sound_samples/cries/espeon.aif
index 53dc62f4d..53dc62f4d 100644
--- a/sound/direct_sound_samples/cry_espeon.aif
+++ b/sound/direct_sound_samples/cries/espeon.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_exeggcute.aif b/sound/direct_sound_samples/cries/exeggcute.aif
index 147912c2f..147912c2f 100644
--- a/sound/direct_sound_samples/cry_exeggcute.aif
+++ b/sound/direct_sound_samples/cries/exeggcute.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_exeggutor.aif b/sound/direct_sound_samples/cries/exeggutor.aif
index c0b9177bf..c0b9177bf 100644
--- a/sound/direct_sound_samples/cry_exeggutor.aif
+++ b/sound/direct_sound_samples/cries/exeggutor.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_exploud.aif b/sound/direct_sound_samples/cries/exploud.aif
index 5b80870cc..5b80870cc 100644
--- a/sound/direct_sound_samples/cry_exploud.aif
+++ b/sound/direct_sound_samples/cries/exploud.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_farfetchd.aif b/sound/direct_sound_samples/cries/farfetchd.aif
index f1db556dc..f1db556dc 100644
--- a/sound/direct_sound_samples/cry_farfetchd.aif
+++ b/sound/direct_sound_samples/cries/farfetchd.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_fearow.aif b/sound/direct_sound_samples/cries/fearow.aif
index 74a76f6d4..74a76f6d4 100644
--- a/sound/direct_sound_samples/cry_fearow.aif
+++ b/sound/direct_sound_samples/cries/fearow.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_feebas.aif b/sound/direct_sound_samples/cries/feebas.aif
index c386522f1..c386522f1 100644
--- a/sound/direct_sound_samples/cry_feebas.aif
+++ b/sound/direct_sound_samples/cries/feebas.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_feraligatr.aif b/sound/direct_sound_samples/cries/feraligatr.aif
index 9fcd93cff..9fcd93cff 100644
--- a/sound/direct_sound_samples/cry_feraligatr.aif
+++ b/sound/direct_sound_samples/cries/feraligatr.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_flaaffy.aif b/sound/direct_sound_samples/cries/flaaffy.aif
index 93dfacfaf..93dfacfaf 100644
--- a/sound/direct_sound_samples/cry_flaaffy.aif
+++ b/sound/direct_sound_samples/cries/flaaffy.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_flareon.aif b/sound/direct_sound_samples/cries/flareon.aif
index 58d28e60a..58d28e60a 100644
--- a/sound/direct_sound_samples/cry_flareon.aif
+++ b/sound/direct_sound_samples/cries/flareon.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_flygon.aif b/sound/direct_sound_samples/cries/flygon.aif
index c8c377016..c8c377016 100644
--- a/sound/direct_sound_samples/cry_flygon.aif
+++ b/sound/direct_sound_samples/cries/flygon.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_forretress.aif b/sound/direct_sound_samples/cries/forretress.aif
index 288dacbea..288dacbea 100644
--- a/sound/direct_sound_samples/cry_forretress.aif
+++ b/sound/direct_sound_samples/cries/forretress.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_furret.aif b/sound/direct_sound_samples/cries/furret.aif
index 6b4e9ce11..6b4e9ce11 100644
--- a/sound/direct_sound_samples/cry_furret.aif
+++ b/sound/direct_sound_samples/cries/furret.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_gardevoir.aif b/sound/direct_sound_samples/cries/gardevoir.aif
index a14780990..a14780990 100644
--- a/sound/direct_sound_samples/cry_gardevoir.aif
+++ b/sound/direct_sound_samples/cries/gardevoir.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_gastly.aif b/sound/direct_sound_samples/cries/gastly.aif
index 93cef851d..93cef851d 100644
--- a/sound/direct_sound_samples/cry_gastly.aif
+++ b/sound/direct_sound_samples/cries/gastly.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_gengar.aif b/sound/direct_sound_samples/cries/gengar.aif
index 379b5d37e..379b5d37e 100644
--- a/sound/direct_sound_samples/cry_gengar.aif
+++ b/sound/direct_sound_samples/cries/gengar.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_geodude.aif b/sound/direct_sound_samples/cries/geodude.aif
index 143b9031c..143b9031c 100644
--- a/sound/direct_sound_samples/cry_geodude.aif
+++ b/sound/direct_sound_samples/cries/geodude.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_girafarig.aif b/sound/direct_sound_samples/cries/girafarig.aif
index 1dd5f93e2..1dd5f93e2 100644
--- a/sound/direct_sound_samples/cry_girafarig.aif
+++ b/sound/direct_sound_samples/cries/girafarig.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_glalie.aif b/sound/direct_sound_samples/cries/glalie.aif
index e4e896547..e4e896547 100644
--- a/sound/direct_sound_samples/cry_glalie.aif
+++ b/sound/direct_sound_samples/cries/glalie.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_gligar.aif b/sound/direct_sound_samples/cries/gligar.aif
index 4050f08b0..4050f08b0 100644
--- a/sound/direct_sound_samples/cry_gligar.aif
+++ b/sound/direct_sound_samples/cries/gligar.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_gloom.aif b/sound/direct_sound_samples/cries/gloom.aif
index e930328ac..e930328ac 100644
--- a/sound/direct_sound_samples/cry_gloom.aif
+++ b/sound/direct_sound_samples/cries/gloom.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_golbat.aif b/sound/direct_sound_samples/cries/golbat.aif
index 11413df3a..11413df3a 100644
--- a/sound/direct_sound_samples/cry_golbat.aif
+++ b/sound/direct_sound_samples/cries/golbat.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_goldeen.aif b/sound/direct_sound_samples/cries/goldeen.aif
index 81fd1ecdf..81fd1ecdf 100644
--- a/sound/direct_sound_samples/cry_goldeen.aif
+++ b/sound/direct_sound_samples/cries/goldeen.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_golduck.aif b/sound/direct_sound_samples/cries/golduck.aif
index b6b71a7a4..b6b71a7a4 100644
--- a/sound/direct_sound_samples/cry_golduck.aif
+++ b/sound/direct_sound_samples/cries/golduck.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_golem.aif b/sound/direct_sound_samples/cries/golem.aif
index 0d2c4515e..0d2c4515e 100644
--- a/sound/direct_sound_samples/cry_golem.aif
+++ b/sound/direct_sound_samples/cries/golem.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_gorebyss.aif b/sound/direct_sound_samples/cries/gorebyss.aif
index b7605062c..b7605062c 100644
--- a/sound/direct_sound_samples/cry_gorebyss.aif
+++ b/sound/direct_sound_samples/cries/gorebyss.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_granbull.aif b/sound/direct_sound_samples/cries/granbull.aif
index 146b3bd0c..146b3bd0c 100644
--- a/sound/direct_sound_samples/cry_granbull.aif
+++ b/sound/direct_sound_samples/cries/granbull.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_graveler.aif b/sound/direct_sound_samples/cries/graveler.aif
index 773994228..773994228 100644
--- a/sound/direct_sound_samples/cry_graveler.aif
+++ b/sound/direct_sound_samples/cries/graveler.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_grimer.aif b/sound/direct_sound_samples/cries/grimer.aif
index 95eed1061..95eed1061 100644
--- a/sound/direct_sound_samples/cry_grimer.aif
+++ b/sound/direct_sound_samples/cries/grimer.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_groudon.aif b/sound/direct_sound_samples/cries/groudon.aif
index 62452b4d9..62452b4d9 100644
--- a/sound/direct_sound_samples/cry_groudon.aif
+++ b/sound/direct_sound_samples/cries/groudon.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_grovyle.aif b/sound/direct_sound_samples/cries/grovyle.aif
index 983bcfff3..983bcfff3 100644
--- a/sound/direct_sound_samples/cry_grovyle.aif
+++ b/sound/direct_sound_samples/cries/grovyle.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_growlithe.aif b/sound/direct_sound_samples/cries/growlithe.aif
index 134e29834..134e29834 100644
--- a/sound/direct_sound_samples/cry_growlithe.aif
+++ b/sound/direct_sound_samples/cries/growlithe.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_grumpig.aif b/sound/direct_sound_samples/cries/grumpig.aif
index 97c372076..97c372076 100644
--- a/sound/direct_sound_samples/cry_grumpig.aif
+++ b/sound/direct_sound_samples/cries/grumpig.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_gulpin.aif b/sound/direct_sound_samples/cries/gulpin.aif
index f3043b422..f3043b422 100644
--- a/sound/direct_sound_samples/cry_gulpin.aif
+++ b/sound/direct_sound_samples/cries/gulpin.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_gyarados.aif b/sound/direct_sound_samples/cries/gyarados.aif
index 238b6d721..238b6d721 100644
--- a/sound/direct_sound_samples/cry_gyarados.aif
+++ b/sound/direct_sound_samples/cries/gyarados.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_hariyama.aif b/sound/direct_sound_samples/cries/hariyama.aif
index 1ac1f3f7e..1ac1f3f7e 100644
--- a/sound/direct_sound_samples/cry_hariyama.aif
+++ b/sound/direct_sound_samples/cries/hariyama.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_haunter.aif b/sound/direct_sound_samples/cries/haunter.aif
index 60ec72171..60ec72171 100644
--- a/sound/direct_sound_samples/cry_haunter.aif
+++ b/sound/direct_sound_samples/cries/haunter.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_heracross.aif b/sound/direct_sound_samples/cries/heracross.aif
index a0734748f..a0734748f 100644
--- a/sound/direct_sound_samples/cry_heracross.aif
+++ b/sound/direct_sound_samples/cries/heracross.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_hitmonchan.aif b/sound/direct_sound_samples/cries/hitmonchan.aif
index 40479452c..40479452c 100644
--- a/sound/direct_sound_samples/cry_hitmonchan.aif
+++ b/sound/direct_sound_samples/cries/hitmonchan.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_hitmonlee.aif b/sound/direct_sound_samples/cries/hitmonlee.aif
index 3a4bcddca..3a4bcddca 100644
--- a/sound/direct_sound_samples/cry_hitmonlee.aif
+++ b/sound/direct_sound_samples/cries/hitmonlee.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_hitmontop.aif b/sound/direct_sound_samples/cries/hitmontop.aif
index 3fbee8041..3fbee8041 100644
--- a/sound/direct_sound_samples/cry_hitmontop.aif
+++ b/sound/direct_sound_samples/cries/hitmontop.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_ho_oh.aif b/sound/direct_sound_samples/cries/ho_oh.aif
index 52f8dd307..52f8dd307 100644
--- a/sound/direct_sound_samples/cry_ho_oh.aif
+++ b/sound/direct_sound_samples/cries/ho_oh.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_hoothoot.aif b/sound/direct_sound_samples/cries/hoothoot.aif
index 59e685dcc..59e685dcc 100644
--- a/sound/direct_sound_samples/cry_hoothoot.aif
+++ b/sound/direct_sound_samples/cries/hoothoot.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_hoppip.aif b/sound/direct_sound_samples/cries/hoppip.aif
index ea47877d0..ea47877d0 100644
--- a/sound/direct_sound_samples/cry_hoppip.aif
+++ b/sound/direct_sound_samples/cries/hoppip.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_horsea.aif b/sound/direct_sound_samples/cries/horsea.aif
index e41eff4b1..e41eff4b1 100644
--- a/sound/direct_sound_samples/cry_horsea.aif
+++ b/sound/direct_sound_samples/cries/horsea.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_houndoom.aif b/sound/direct_sound_samples/cries/houndoom.aif
index 6fec16d39..6fec16d39 100644
--- a/sound/direct_sound_samples/cry_houndoom.aif
+++ b/sound/direct_sound_samples/cries/houndoom.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_houndour.aif b/sound/direct_sound_samples/cries/houndour.aif
index 7431bbf29..7431bbf29 100644
--- a/sound/direct_sound_samples/cry_houndour.aif
+++ b/sound/direct_sound_samples/cries/houndour.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_huntail.aif b/sound/direct_sound_samples/cries/huntail.aif
index f1d3b29d9..f1d3b29d9 100644
--- a/sound/direct_sound_samples/cry_huntail.aif
+++ b/sound/direct_sound_samples/cries/huntail.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_hypno.aif b/sound/direct_sound_samples/cries/hypno.aif
index 32672a3c3..32672a3c3 100644
--- a/sound/direct_sound_samples/cry_hypno.aif
+++ b/sound/direct_sound_samples/cries/hypno.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_igglybuff.aif b/sound/direct_sound_samples/cries/igglybuff.aif
index 8de8394d5..8de8394d5 100644
--- a/sound/direct_sound_samples/cry_igglybuff.aif
+++ b/sound/direct_sound_samples/cries/igglybuff.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_illumise.aif b/sound/direct_sound_samples/cries/illumise.aif
index 75e03efc8..75e03efc8 100644
--- a/sound/direct_sound_samples/cry_illumise.aif
+++ b/sound/direct_sound_samples/cries/illumise.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_ivysaur.aif b/sound/direct_sound_samples/cries/ivysaur.aif
index ea474ff88..ea474ff88 100644
--- a/sound/direct_sound_samples/cry_ivysaur.aif
+++ b/sound/direct_sound_samples/cries/ivysaur.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_jigglypuff.aif b/sound/direct_sound_samples/cries/jigglypuff.aif
index 780424b4f..780424b4f 100644
--- a/sound/direct_sound_samples/cry_jigglypuff.aif
+++ b/sound/direct_sound_samples/cries/jigglypuff.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_jirachi.aif b/sound/direct_sound_samples/cries/jirachi.aif
index ea8a5c8ad..ea8a5c8ad 100644
--- a/sound/direct_sound_samples/cry_jirachi.aif
+++ b/sound/direct_sound_samples/cries/jirachi.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_jolteon.aif b/sound/direct_sound_samples/cries/jolteon.aif
index 013369158..013369158 100644
--- a/sound/direct_sound_samples/cry_jolteon.aif
+++ b/sound/direct_sound_samples/cries/jolteon.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_jumpluff.aif b/sound/direct_sound_samples/cries/jumpluff.aif
index 13b0fd315..13b0fd315 100644
--- a/sound/direct_sound_samples/cry_jumpluff.aif
+++ b/sound/direct_sound_samples/cries/jumpluff.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_jynx.aif b/sound/direct_sound_samples/cries/jynx.aif
index 7394a48a2..7394a48a2 100644
--- a/sound/direct_sound_samples/cry_jynx.aif
+++ b/sound/direct_sound_samples/cries/jynx.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_kabuto.aif b/sound/direct_sound_samples/cries/kabuto.aif
index 6ae9801b5..6ae9801b5 100644
--- a/sound/direct_sound_samples/cry_kabuto.aif
+++ b/sound/direct_sound_samples/cries/kabuto.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_kabutops.aif b/sound/direct_sound_samples/cries/kabutops.aif
index cb888bff9..cb888bff9 100644
--- a/sound/direct_sound_samples/cry_kabutops.aif
+++ b/sound/direct_sound_samples/cries/kabutops.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_kadabra.aif b/sound/direct_sound_samples/cries/kadabra.aif
index bfcc18031..bfcc18031 100644
--- a/sound/direct_sound_samples/cry_kadabra.aif
+++ b/sound/direct_sound_samples/cries/kadabra.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_kakuna.aif b/sound/direct_sound_samples/cries/kakuna.aif
index 7c4e9d7a8..7c4e9d7a8 100644
--- a/sound/direct_sound_samples/cry_kakuna.aif
+++ b/sound/direct_sound_samples/cries/kakuna.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_kangaskhan.aif b/sound/direct_sound_samples/cries/kangaskhan.aif
index 643e81eb7..643e81eb7 100644
--- a/sound/direct_sound_samples/cry_kangaskhan.aif
+++ b/sound/direct_sound_samples/cries/kangaskhan.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_kecleon.aif b/sound/direct_sound_samples/cries/kecleon.aif
index f27ae1832..f27ae1832 100644
--- a/sound/direct_sound_samples/cry_kecleon.aif
+++ b/sound/direct_sound_samples/cries/kecleon.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_kingdra.aif b/sound/direct_sound_samples/cries/kingdra.aif
index ade230c82..ade230c82 100644
--- a/sound/direct_sound_samples/cry_kingdra.aif
+++ b/sound/direct_sound_samples/cries/kingdra.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_kingler.aif b/sound/direct_sound_samples/cries/kingler.aif
index a1d845f45..a1d845f45 100644
--- a/sound/direct_sound_samples/cry_kingler.aif
+++ b/sound/direct_sound_samples/cries/kingler.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_kirlia.aif b/sound/direct_sound_samples/cries/kirlia.aif
index 692e03e5f..692e03e5f 100644
--- a/sound/direct_sound_samples/cry_kirlia.aif
+++ b/sound/direct_sound_samples/cries/kirlia.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_koffing.aif b/sound/direct_sound_samples/cries/koffing.aif
index 7ca9de088..7ca9de088 100644
--- a/sound/direct_sound_samples/cry_koffing.aif
+++ b/sound/direct_sound_samples/cries/koffing.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_krabby.aif b/sound/direct_sound_samples/cries/krabby.aif
index 6b7692f21..6b7692f21 100644
--- a/sound/direct_sound_samples/cry_krabby.aif
+++ b/sound/direct_sound_samples/cries/krabby.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_kyogre.aif b/sound/direct_sound_samples/cries/kyogre.aif
index 290948319..290948319 100644
--- a/sound/direct_sound_samples/cry_kyogre.aif
+++ b/sound/direct_sound_samples/cries/kyogre.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_lairon.aif b/sound/direct_sound_samples/cries/lairon.aif
index b487165bf..b487165bf 100644
--- a/sound/direct_sound_samples/cry_lairon.aif
+++ b/sound/direct_sound_samples/cries/lairon.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_lanturn.aif b/sound/direct_sound_samples/cries/lanturn.aif
index dfeac1fbd..dfeac1fbd 100644
--- a/sound/direct_sound_samples/cry_lanturn.aif
+++ b/sound/direct_sound_samples/cries/lanturn.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_lapras.aif b/sound/direct_sound_samples/cries/lapras.aif
index 61de32408..61de32408 100644
--- a/sound/direct_sound_samples/cry_lapras.aif
+++ b/sound/direct_sound_samples/cries/lapras.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_larvitar.aif b/sound/direct_sound_samples/cries/larvitar.aif
index 1ab0e1d5f..1ab0e1d5f 100644
--- a/sound/direct_sound_samples/cry_larvitar.aif
+++ b/sound/direct_sound_samples/cries/larvitar.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_latias.aif b/sound/direct_sound_samples/cries/latias.aif
index 46f7235f3..46f7235f3 100644
--- a/sound/direct_sound_samples/cry_latias.aif
+++ b/sound/direct_sound_samples/cries/latias.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_latios.aif b/sound/direct_sound_samples/cries/latios.aif
index b8ace2a30..b8ace2a30 100644
--- a/sound/direct_sound_samples/cry_latios.aif
+++ b/sound/direct_sound_samples/cries/latios.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_ledian.aif b/sound/direct_sound_samples/cries/ledian.aif
index baefb5fa3..baefb5fa3 100644
--- a/sound/direct_sound_samples/cry_ledian.aif
+++ b/sound/direct_sound_samples/cries/ledian.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_ledyba.aif b/sound/direct_sound_samples/cries/ledyba.aif
index 4f26859a7..4f26859a7 100644
--- a/sound/direct_sound_samples/cry_ledyba.aif
+++ b/sound/direct_sound_samples/cries/ledyba.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_lickitung.aif b/sound/direct_sound_samples/cries/lickitung.aif
index e469450a1..e469450a1 100644
--- a/sound/direct_sound_samples/cry_lickitung.aif
+++ b/sound/direct_sound_samples/cries/lickitung.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_lileep.aif b/sound/direct_sound_samples/cries/lileep.aif
index ed8258eb7..ed8258eb7 100644
--- a/sound/direct_sound_samples/cry_lileep.aif
+++ b/sound/direct_sound_samples/cries/lileep.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_linoone.aif b/sound/direct_sound_samples/cries/linoone.aif
index 4e5e7d3b5..4e5e7d3b5 100644
--- a/sound/direct_sound_samples/cry_linoone.aif
+++ b/sound/direct_sound_samples/cries/linoone.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_lombre.aif b/sound/direct_sound_samples/cries/lombre.aif
index abafe4321..abafe4321 100644
--- a/sound/direct_sound_samples/cry_lombre.aif
+++ b/sound/direct_sound_samples/cries/lombre.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_lotad.aif b/sound/direct_sound_samples/cries/lotad.aif
index 2596f4390..2596f4390 100644
--- a/sound/direct_sound_samples/cry_lotad.aif
+++ b/sound/direct_sound_samples/cries/lotad.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_loudred.aif b/sound/direct_sound_samples/cries/loudred.aif
index fed7ebec8..fed7ebec8 100644
--- a/sound/direct_sound_samples/cry_loudred.aif
+++ b/sound/direct_sound_samples/cries/loudred.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_ludicolo.aif b/sound/direct_sound_samples/cries/ludicolo.aif
index 7cf670f38..7cf670f38 100644
--- a/sound/direct_sound_samples/cry_ludicolo.aif
+++ b/sound/direct_sound_samples/cries/ludicolo.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_lugia.aif b/sound/direct_sound_samples/cries/lugia.aif
index 45890a2fc..45890a2fc 100644
--- a/sound/direct_sound_samples/cry_lugia.aif
+++ b/sound/direct_sound_samples/cries/lugia.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_lunatone.aif b/sound/direct_sound_samples/cries/lunatone.aif
index 42cbc5e3c..42cbc5e3c 100644
--- a/sound/direct_sound_samples/cry_lunatone.aif
+++ b/sound/direct_sound_samples/cries/lunatone.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_luvdisc.aif b/sound/direct_sound_samples/cries/luvdisc.aif
index 3cc0cc744..3cc0cc744 100644
--- a/sound/direct_sound_samples/cry_luvdisc.aif
+++ b/sound/direct_sound_samples/cries/luvdisc.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_machamp.aif b/sound/direct_sound_samples/cries/machamp.aif
index ddeaf22c8..ddeaf22c8 100644
--- a/sound/direct_sound_samples/cry_machamp.aif
+++ b/sound/direct_sound_samples/cries/machamp.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_machoke.aif b/sound/direct_sound_samples/cries/machoke.aif
index 97065ee09..97065ee09 100644
--- a/sound/direct_sound_samples/cry_machoke.aif
+++ b/sound/direct_sound_samples/cries/machoke.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_machop.aif b/sound/direct_sound_samples/cries/machop.aif
index d92419e84..d92419e84 100644
--- a/sound/direct_sound_samples/cry_machop.aif
+++ b/sound/direct_sound_samples/cries/machop.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_magby.aif b/sound/direct_sound_samples/cries/magby.aif
index 12f3dc889..12f3dc889 100644
--- a/sound/direct_sound_samples/cry_magby.aif
+++ b/sound/direct_sound_samples/cries/magby.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_magcargo.aif b/sound/direct_sound_samples/cries/magcargo.aif
index bef0351c0..bef0351c0 100644
--- a/sound/direct_sound_samples/cry_magcargo.aif
+++ b/sound/direct_sound_samples/cries/magcargo.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_magikarp.aif b/sound/direct_sound_samples/cries/magikarp.aif
index f4f9219c5..f4f9219c5 100644
--- a/sound/direct_sound_samples/cry_magikarp.aif
+++ b/sound/direct_sound_samples/cries/magikarp.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_magmar.aif b/sound/direct_sound_samples/cries/magmar.aif
index b79c8b9a1..b79c8b9a1 100644
--- a/sound/direct_sound_samples/cry_magmar.aif
+++ b/sound/direct_sound_samples/cries/magmar.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_magnemite.aif b/sound/direct_sound_samples/cries/magnemite.aif
index ebb9103d9..ebb9103d9 100644
--- a/sound/direct_sound_samples/cry_magnemite.aif
+++ b/sound/direct_sound_samples/cries/magnemite.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_magneton.aif b/sound/direct_sound_samples/cries/magneton.aif
index 53083ac62..53083ac62 100644
--- a/sound/direct_sound_samples/cry_magneton.aif
+++ b/sound/direct_sound_samples/cries/magneton.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_makuhita.aif b/sound/direct_sound_samples/cries/makuhita.aif
index 38d7f4b44..38d7f4b44 100644
--- a/sound/direct_sound_samples/cry_makuhita.aif
+++ b/sound/direct_sound_samples/cries/makuhita.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_manectric.aif b/sound/direct_sound_samples/cries/manectric.aif
index 18a8f4666..18a8f4666 100644
--- a/sound/direct_sound_samples/cry_manectric.aif
+++ b/sound/direct_sound_samples/cries/manectric.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_mankey.aif b/sound/direct_sound_samples/cries/mankey.aif
index dda929d4c..dda929d4c 100644
--- a/sound/direct_sound_samples/cry_mankey.aif
+++ b/sound/direct_sound_samples/cries/mankey.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_mantine.aif b/sound/direct_sound_samples/cries/mantine.aif
index d1840aafa..d1840aafa 100644
--- a/sound/direct_sound_samples/cry_mantine.aif
+++ b/sound/direct_sound_samples/cries/mantine.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_mareep.aif b/sound/direct_sound_samples/cries/mareep.aif
index 2615b9def..2615b9def 100644
--- a/sound/direct_sound_samples/cry_mareep.aif
+++ b/sound/direct_sound_samples/cries/mareep.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_marill.aif b/sound/direct_sound_samples/cries/marill.aif
index 48d936e7d..48d936e7d 100644
--- a/sound/direct_sound_samples/cry_marill.aif
+++ b/sound/direct_sound_samples/cries/marill.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_marowak.aif b/sound/direct_sound_samples/cries/marowak.aif
index 279381bb5..279381bb5 100644
--- a/sound/direct_sound_samples/cry_marowak.aif
+++ b/sound/direct_sound_samples/cries/marowak.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_marshtomp.aif b/sound/direct_sound_samples/cries/marshtomp.aif
index c0106ff6c..c0106ff6c 100644
--- a/sound/direct_sound_samples/cry_marshtomp.aif
+++ b/sound/direct_sound_samples/cries/marshtomp.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_masquerain.aif b/sound/direct_sound_samples/cries/masquerain.aif
index 107bed2f7..107bed2f7 100644
--- a/sound/direct_sound_samples/cry_masquerain.aif
+++ b/sound/direct_sound_samples/cries/masquerain.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_mawile.aif b/sound/direct_sound_samples/cries/mawile.aif
index 81b252b57..81b252b57 100644
--- a/sound/direct_sound_samples/cry_mawile.aif
+++ b/sound/direct_sound_samples/cries/mawile.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_medicham.aif b/sound/direct_sound_samples/cries/medicham.aif
index dc85dd3b5..dc85dd3b5 100644
--- a/sound/direct_sound_samples/cry_medicham.aif
+++ b/sound/direct_sound_samples/cries/medicham.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_meditite.aif b/sound/direct_sound_samples/cries/meditite.aif
index 8ac680f79..8ac680f79 100644
--- a/sound/direct_sound_samples/cry_meditite.aif
+++ b/sound/direct_sound_samples/cries/meditite.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_meganium.aif b/sound/direct_sound_samples/cries/meganium.aif
index ea1e1aa51..ea1e1aa51 100644
--- a/sound/direct_sound_samples/cry_meganium.aif
+++ b/sound/direct_sound_samples/cries/meganium.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_meowth.aif b/sound/direct_sound_samples/cries/meowth.aif
index aaf3825d5..aaf3825d5 100644
--- a/sound/direct_sound_samples/cry_meowth.aif
+++ b/sound/direct_sound_samples/cries/meowth.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_metagross.aif b/sound/direct_sound_samples/cries/metagross.aif
index b96e6647c..b96e6647c 100644
--- a/sound/direct_sound_samples/cry_metagross.aif
+++ b/sound/direct_sound_samples/cries/metagross.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_metang.aif b/sound/direct_sound_samples/cries/metang.aif
index da544ce4d..da544ce4d 100644
--- a/sound/direct_sound_samples/cry_metang.aif
+++ b/sound/direct_sound_samples/cries/metang.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_metapod.aif b/sound/direct_sound_samples/cries/metapod.aif
index ddba3ed44..ddba3ed44 100644
--- a/sound/direct_sound_samples/cry_metapod.aif
+++ b/sound/direct_sound_samples/cries/metapod.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_mew.aif b/sound/direct_sound_samples/cries/mew.aif
index 2651b96ca..2651b96ca 100644
--- a/sound/direct_sound_samples/cry_mew.aif
+++ b/sound/direct_sound_samples/cries/mew.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_mewtwo.aif b/sound/direct_sound_samples/cries/mewtwo.aif
index 8e1e6c7f1..8e1e6c7f1 100644
--- a/sound/direct_sound_samples/cry_mewtwo.aif
+++ b/sound/direct_sound_samples/cries/mewtwo.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_mightyena.aif b/sound/direct_sound_samples/cries/mightyena.aif
index 53a645edc..53a645edc 100644
--- a/sound/direct_sound_samples/cry_mightyena.aif
+++ b/sound/direct_sound_samples/cries/mightyena.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_milotic.aif b/sound/direct_sound_samples/cries/milotic.aif
index 93a14161b..93a14161b 100644
--- a/sound/direct_sound_samples/cry_milotic.aif
+++ b/sound/direct_sound_samples/cries/milotic.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_miltank.aif b/sound/direct_sound_samples/cries/miltank.aif
index ad8a41a45..ad8a41a45 100644
--- a/sound/direct_sound_samples/cry_miltank.aif
+++ b/sound/direct_sound_samples/cries/miltank.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_minun.aif b/sound/direct_sound_samples/cries/minun.aif
index a55aa5631..a55aa5631 100644
--- a/sound/direct_sound_samples/cry_minun.aif
+++ b/sound/direct_sound_samples/cries/minun.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_misdreavus.aif b/sound/direct_sound_samples/cries/misdreavus.aif
index 39a09f4d0..39a09f4d0 100644
--- a/sound/direct_sound_samples/cry_misdreavus.aif
+++ b/sound/direct_sound_samples/cries/misdreavus.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_moltres.aif b/sound/direct_sound_samples/cries/moltres.aif
index 2e038a3d7..2e038a3d7 100644
--- a/sound/direct_sound_samples/cry_moltres.aif
+++ b/sound/direct_sound_samples/cries/moltres.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_mr_mime.aif b/sound/direct_sound_samples/cries/mr_mime.aif
index ff870dbc4..ff870dbc4 100644
--- a/sound/direct_sound_samples/cry_mr_mime.aif
+++ b/sound/direct_sound_samples/cries/mr_mime.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_mudkip.aif b/sound/direct_sound_samples/cries/mudkip.aif
index e8fa5c212..e8fa5c212 100644
--- a/sound/direct_sound_samples/cry_mudkip.aif
+++ b/sound/direct_sound_samples/cries/mudkip.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_muk.aif b/sound/direct_sound_samples/cries/muk.aif
index f61ff4075..f61ff4075 100644
--- a/sound/direct_sound_samples/cry_muk.aif
+++ b/sound/direct_sound_samples/cries/muk.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_murkrow.aif b/sound/direct_sound_samples/cries/murkrow.aif
index 4beddff1e..4beddff1e 100644
--- a/sound/direct_sound_samples/cry_murkrow.aif
+++ b/sound/direct_sound_samples/cries/murkrow.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_natu.aif b/sound/direct_sound_samples/cries/natu.aif
index e6e38d5cc..e6e38d5cc 100644
--- a/sound/direct_sound_samples/cry_natu.aif
+++ b/sound/direct_sound_samples/cries/natu.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_nidoking.aif b/sound/direct_sound_samples/cries/nidoking.aif
index a0c86f9ab..a0c86f9ab 100644
--- a/sound/direct_sound_samples/cry_nidoking.aif
+++ b/sound/direct_sound_samples/cries/nidoking.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_nidoqueen.aif b/sound/direct_sound_samples/cries/nidoqueen.aif
index 6c8f5254b..6c8f5254b 100644
--- a/sound/direct_sound_samples/cry_nidoqueen.aif
+++ b/sound/direct_sound_samples/cries/nidoqueen.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_nidoran_f.aif b/sound/direct_sound_samples/cries/nidoran_f.aif
index b7c8a5317..b7c8a5317 100644
--- a/sound/direct_sound_samples/cry_nidoran_f.aif
+++ b/sound/direct_sound_samples/cries/nidoran_f.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_nidoran_m.aif b/sound/direct_sound_samples/cries/nidoran_m.aif
index 08fc81c8b..08fc81c8b 100644
--- a/sound/direct_sound_samples/cry_nidoran_m.aif
+++ b/sound/direct_sound_samples/cries/nidoran_m.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_nidorina.aif b/sound/direct_sound_samples/cries/nidorina.aif
index 91e293a50..91e293a50 100644
--- a/sound/direct_sound_samples/cry_nidorina.aif
+++ b/sound/direct_sound_samples/cries/nidorina.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_nidorino.aif b/sound/direct_sound_samples/cries/nidorino.aif
index 959351363..959351363 100644
--- a/sound/direct_sound_samples/cry_nidorino.aif
+++ b/sound/direct_sound_samples/cries/nidorino.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_nincada.aif b/sound/direct_sound_samples/cries/nincada.aif
index 5f96bda50..5f96bda50 100644
--- a/sound/direct_sound_samples/cry_nincada.aif
+++ b/sound/direct_sound_samples/cries/nincada.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_ninetales.aif b/sound/direct_sound_samples/cries/ninetales.aif
index 70c8cf528..70c8cf528 100644
--- a/sound/direct_sound_samples/cry_ninetales.aif
+++ b/sound/direct_sound_samples/cries/ninetales.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_ninjask.aif b/sound/direct_sound_samples/cries/ninjask.aif
index a6f07e8d3..a6f07e8d3 100644
--- a/sound/direct_sound_samples/cry_ninjask.aif
+++ b/sound/direct_sound_samples/cries/ninjask.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_noctowl.aif b/sound/direct_sound_samples/cries/noctowl.aif
index fe2e63d45..fe2e63d45 100644
--- a/sound/direct_sound_samples/cry_noctowl.aif
+++ b/sound/direct_sound_samples/cries/noctowl.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_nosepass.aif b/sound/direct_sound_samples/cries/nosepass.aif
index be65ba082..be65ba082 100644
--- a/sound/direct_sound_samples/cry_nosepass.aif
+++ b/sound/direct_sound_samples/cries/nosepass.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_numel.aif b/sound/direct_sound_samples/cries/numel.aif
index 55cce5f2c..55cce5f2c 100644
--- a/sound/direct_sound_samples/cry_numel.aif
+++ b/sound/direct_sound_samples/cries/numel.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_nuzleaf.aif b/sound/direct_sound_samples/cries/nuzleaf.aif
index d668f3fd3..d668f3fd3 100644
--- a/sound/direct_sound_samples/cry_nuzleaf.aif
+++ b/sound/direct_sound_samples/cries/nuzleaf.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_octillery.aif b/sound/direct_sound_samples/cries/octillery.aif
index 75ee28ceb..75ee28ceb 100644
--- a/sound/direct_sound_samples/cry_octillery.aif
+++ b/sound/direct_sound_samples/cries/octillery.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_oddish.aif b/sound/direct_sound_samples/cries/oddish.aif
index 6909a8dad..6909a8dad 100644
--- a/sound/direct_sound_samples/cry_oddish.aif
+++ b/sound/direct_sound_samples/cries/oddish.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_omanyte.aif b/sound/direct_sound_samples/cries/omanyte.aif
index 15ec2d1ef..15ec2d1ef 100644
--- a/sound/direct_sound_samples/cry_omanyte.aif
+++ b/sound/direct_sound_samples/cries/omanyte.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_omastar.aif b/sound/direct_sound_samples/cries/omastar.aif
index e67d5d7fc..e67d5d7fc 100644
--- a/sound/direct_sound_samples/cry_omastar.aif
+++ b/sound/direct_sound_samples/cries/omastar.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_onix.aif b/sound/direct_sound_samples/cries/onix.aif
index aa8a16505..aa8a16505 100644
--- a/sound/direct_sound_samples/cry_onix.aif
+++ b/sound/direct_sound_samples/cries/onix.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_paras.aif b/sound/direct_sound_samples/cries/paras.aif
index f9d69c21c..f9d69c21c 100644
--- a/sound/direct_sound_samples/cry_paras.aif
+++ b/sound/direct_sound_samples/cries/paras.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_parasect.aif b/sound/direct_sound_samples/cries/parasect.aif
index d6d9433e9..d6d9433e9 100644
--- a/sound/direct_sound_samples/cry_parasect.aif
+++ b/sound/direct_sound_samples/cries/parasect.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_pelipper.aif b/sound/direct_sound_samples/cries/pelipper.aif
index 26718f848..26718f848 100644
--- a/sound/direct_sound_samples/cry_pelipper.aif
+++ b/sound/direct_sound_samples/cries/pelipper.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_persian.aif b/sound/direct_sound_samples/cries/persian.aif
index 40b3a2c56..40b3a2c56 100644
--- a/sound/direct_sound_samples/cry_persian.aif
+++ b/sound/direct_sound_samples/cries/persian.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_phanpy.aif b/sound/direct_sound_samples/cries/phanpy.aif
index 2fcab3c82..2fcab3c82 100644
--- a/sound/direct_sound_samples/cry_phanpy.aif
+++ b/sound/direct_sound_samples/cries/phanpy.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_pichu.aif b/sound/direct_sound_samples/cries/pichu.aif
index de47bbab8..de47bbab8 100644
--- a/sound/direct_sound_samples/cry_pichu.aif
+++ b/sound/direct_sound_samples/cries/pichu.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_pidgeot.aif b/sound/direct_sound_samples/cries/pidgeot.aif
index af400cdc6..af400cdc6 100644
--- a/sound/direct_sound_samples/cry_pidgeot.aif
+++ b/sound/direct_sound_samples/cries/pidgeot.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_pidgeotto.aif b/sound/direct_sound_samples/cries/pidgeotto.aif
index 7c71c8f3e..7c71c8f3e 100644
--- a/sound/direct_sound_samples/cry_pidgeotto.aif
+++ b/sound/direct_sound_samples/cries/pidgeotto.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_pidgey.aif b/sound/direct_sound_samples/cries/pidgey.aif
index b9c3a5d2a..b9c3a5d2a 100644
--- a/sound/direct_sound_samples/cry_pidgey.aif
+++ b/sound/direct_sound_samples/cries/pidgey.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_pikachu.aif b/sound/direct_sound_samples/cries/pikachu.aif
index 690bf5e1d..690bf5e1d 100644
--- a/sound/direct_sound_samples/cry_pikachu.aif
+++ b/sound/direct_sound_samples/cries/pikachu.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_piloswine.aif b/sound/direct_sound_samples/cries/piloswine.aif
index b1f34d3b5..b1f34d3b5 100644
--- a/sound/direct_sound_samples/cry_piloswine.aif
+++ b/sound/direct_sound_samples/cries/piloswine.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_pineco.aif b/sound/direct_sound_samples/cries/pineco.aif
index 80292bda0..80292bda0 100644
--- a/sound/direct_sound_samples/cry_pineco.aif
+++ b/sound/direct_sound_samples/cries/pineco.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_pinsir.aif b/sound/direct_sound_samples/cries/pinsir.aif
index cf27a11de..cf27a11de 100644
--- a/sound/direct_sound_samples/cry_pinsir.aif
+++ b/sound/direct_sound_samples/cries/pinsir.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_plusle.aif b/sound/direct_sound_samples/cries/plusle.aif
index d68984263..d68984263 100644
--- a/sound/direct_sound_samples/cry_plusle.aif
+++ b/sound/direct_sound_samples/cries/plusle.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_politoed.aif b/sound/direct_sound_samples/cries/politoed.aif
index 38b1883b4..38b1883b4 100644
--- a/sound/direct_sound_samples/cry_politoed.aif
+++ b/sound/direct_sound_samples/cries/politoed.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_poliwag.aif b/sound/direct_sound_samples/cries/poliwag.aif
index 8467f0540..8467f0540 100644
--- a/sound/direct_sound_samples/cry_poliwag.aif
+++ b/sound/direct_sound_samples/cries/poliwag.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_poliwhirl.aif b/sound/direct_sound_samples/cries/poliwhirl.aif
index f0851c693..f0851c693 100644
--- a/sound/direct_sound_samples/cry_poliwhirl.aif
+++ b/sound/direct_sound_samples/cries/poliwhirl.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_poliwrath.aif b/sound/direct_sound_samples/cries/poliwrath.aif
index 8d19f1d86..8d19f1d86 100644
--- a/sound/direct_sound_samples/cry_poliwrath.aif
+++ b/sound/direct_sound_samples/cries/poliwrath.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_ponyta.aif b/sound/direct_sound_samples/cries/ponyta.aif
index 46feb123d..46feb123d 100644
--- a/sound/direct_sound_samples/cry_ponyta.aif
+++ b/sound/direct_sound_samples/cries/ponyta.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_poochyena.aif b/sound/direct_sound_samples/cries/poochyena.aif
index 3b464ce13..3b464ce13 100644
--- a/sound/direct_sound_samples/cry_poochyena.aif
+++ b/sound/direct_sound_samples/cries/poochyena.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_porygon.aif b/sound/direct_sound_samples/cries/porygon.aif
index ced70b379..ced70b379 100644
--- a/sound/direct_sound_samples/cry_porygon.aif
+++ b/sound/direct_sound_samples/cries/porygon.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_porygon2.aif b/sound/direct_sound_samples/cries/porygon2.aif
index c08a3caaf..c08a3caaf 100644
--- a/sound/direct_sound_samples/cry_porygon2.aif
+++ b/sound/direct_sound_samples/cries/porygon2.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_primeape.aif b/sound/direct_sound_samples/cries/primeape.aif
index a868b3120..a868b3120 100644
--- a/sound/direct_sound_samples/cry_primeape.aif
+++ b/sound/direct_sound_samples/cries/primeape.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_psyduck.aif b/sound/direct_sound_samples/cries/psyduck.aif
index d2d0612f2..d2d0612f2 100644
--- a/sound/direct_sound_samples/cry_psyduck.aif
+++ b/sound/direct_sound_samples/cries/psyduck.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_pupitar.aif b/sound/direct_sound_samples/cries/pupitar.aif
index 7386636ce..7386636ce 100644
--- a/sound/direct_sound_samples/cry_pupitar.aif
+++ b/sound/direct_sound_samples/cries/pupitar.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_quagsire.aif b/sound/direct_sound_samples/cries/quagsire.aif
index 1953d0e42..1953d0e42 100644
--- a/sound/direct_sound_samples/cry_quagsire.aif
+++ b/sound/direct_sound_samples/cries/quagsire.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_quilava.aif b/sound/direct_sound_samples/cries/quilava.aif
index efe873229..efe873229 100644
--- a/sound/direct_sound_samples/cry_quilava.aif
+++ b/sound/direct_sound_samples/cries/quilava.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_qwilfish.aif b/sound/direct_sound_samples/cries/qwilfish.aif
index 268c5c89d..268c5c89d 100644
--- a/sound/direct_sound_samples/cry_qwilfish.aif
+++ b/sound/direct_sound_samples/cries/qwilfish.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_raichu.aif b/sound/direct_sound_samples/cries/raichu.aif
index e59ffbad4..e59ffbad4 100644
--- a/sound/direct_sound_samples/cry_raichu.aif
+++ b/sound/direct_sound_samples/cries/raichu.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_raikou.aif b/sound/direct_sound_samples/cries/raikou.aif
index a57a2365c..a57a2365c 100644
--- a/sound/direct_sound_samples/cry_raikou.aif
+++ b/sound/direct_sound_samples/cries/raikou.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_ralts.aif b/sound/direct_sound_samples/cries/ralts.aif
index 0baef5760..0baef5760 100644
--- a/sound/direct_sound_samples/cry_ralts.aif
+++ b/sound/direct_sound_samples/cries/ralts.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_rapidash.aif b/sound/direct_sound_samples/cries/rapidash.aif
index 920f510e4..920f510e4 100644
--- a/sound/direct_sound_samples/cry_rapidash.aif
+++ b/sound/direct_sound_samples/cries/rapidash.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_raticate.aif b/sound/direct_sound_samples/cries/raticate.aif
index 01601cab5..01601cab5 100644
--- a/sound/direct_sound_samples/cry_raticate.aif
+++ b/sound/direct_sound_samples/cries/raticate.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_rattata.aif b/sound/direct_sound_samples/cries/rattata.aif
index cb0e1f422..cb0e1f422 100644
--- a/sound/direct_sound_samples/cry_rattata.aif
+++ b/sound/direct_sound_samples/cries/rattata.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_rayquaza.aif b/sound/direct_sound_samples/cries/rayquaza.aif
index 6115e11d8..6115e11d8 100644
--- a/sound/direct_sound_samples/cry_rayquaza.aif
+++ b/sound/direct_sound_samples/cries/rayquaza.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_regice.aif b/sound/direct_sound_samples/cries/regice.aif
index 6fa23dd73..6fa23dd73 100644
--- a/sound/direct_sound_samples/cry_regice.aif
+++ b/sound/direct_sound_samples/cries/regice.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_regirock.aif b/sound/direct_sound_samples/cries/regirock.aif
index ab2a47eb8..ab2a47eb8 100644
--- a/sound/direct_sound_samples/cry_regirock.aif
+++ b/sound/direct_sound_samples/cries/regirock.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_registeel.aif b/sound/direct_sound_samples/cries/registeel.aif
index f5374e5f0..f5374e5f0 100644
--- a/sound/direct_sound_samples/cry_registeel.aif
+++ b/sound/direct_sound_samples/cries/registeel.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_relicanth.aif b/sound/direct_sound_samples/cries/relicanth.aif
index 60af9cf4e..60af9cf4e 100644
--- a/sound/direct_sound_samples/cry_relicanth.aif
+++ b/sound/direct_sound_samples/cries/relicanth.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_remoraid.aif b/sound/direct_sound_samples/cries/remoraid.aif
index 16d3f1d65..16d3f1d65 100644
--- a/sound/direct_sound_samples/cry_remoraid.aif
+++ b/sound/direct_sound_samples/cries/remoraid.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_rhydon.aif b/sound/direct_sound_samples/cries/rhydon.aif
index cfa709ee9..cfa709ee9 100644
--- a/sound/direct_sound_samples/cry_rhydon.aif
+++ b/sound/direct_sound_samples/cries/rhydon.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_rhyhorn.aif b/sound/direct_sound_samples/cries/rhyhorn.aif
index 47f344ba2..47f344ba2 100644
--- a/sound/direct_sound_samples/cry_rhyhorn.aif
+++ b/sound/direct_sound_samples/cries/rhyhorn.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_roselia.aif b/sound/direct_sound_samples/cries/roselia.aif
index 50b60b77b..50b60b77b 100644
--- a/sound/direct_sound_samples/cry_roselia.aif
+++ b/sound/direct_sound_samples/cries/roselia.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_sableye.aif b/sound/direct_sound_samples/cries/sableye.aif
index 1b3a9be30..1b3a9be30 100644
--- a/sound/direct_sound_samples/cry_sableye.aif
+++ b/sound/direct_sound_samples/cries/sableye.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_salamence.aif b/sound/direct_sound_samples/cries/salamence.aif
index d2957809c..d2957809c 100644
--- a/sound/direct_sound_samples/cry_salamence.aif
+++ b/sound/direct_sound_samples/cries/salamence.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_sandshrew.aif b/sound/direct_sound_samples/cries/sandshrew.aif
index 6879be11d..6879be11d 100644
--- a/sound/direct_sound_samples/cry_sandshrew.aif
+++ b/sound/direct_sound_samples/cries/sandshrew.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_sandslash.aif b/sound/direct_sound_samples/cries/sandslash.aif
index ee4a458ed..ee4a458ed 100644
--- a/sound/direct_sound_samples/cry_sandslash.aif
+++ b/sound/direct_sound_samples/cries/sandslash.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_sceptile.aif b/sound/direct_sound_samples/cries/sceptile.aif
index 7252cb85f..7252cb85f 100644
--- a/sound/direct_sound_samples/cry_sceptile.aif
+++ b/sound/direct_sound_samples/cries/sceptile.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_scizor.aif b/sound/direct_sound_samples/cries/scizor.aif
index f1f7832ce..f1f7832ce 100644
--- a/sound/direct_sound_samples/cry_scizor.aif
+++ b/sound/direct_sound_samples/cries/scizor.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_scyther.aif b/sound/direct_sound_samples/cries/scyther.aif
index 2b8cbc104..2b8cbc104 100644
--- a/sound/direct_sound_samples/cry_scyther.aif
+++ b/sound/direct_sound_samples/cries/scyther.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_seadra.aif b/sound/direct_sound_samples/cries/seadra.aif
index 2f60cce4a..2f60cce4a 100644
--- a/sound/direct_sound_samples/cry_seadra.aif
+++ b/sound/direct_sound_samples/cries/seadra.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_seaking.aif b/sound/direct_sound_samples/cries/seaking.aif
index e4fc7e70d..e4fc7e70d 100644
--- a/sound/direct_sound_samples/cry_seaking.aif
+++ b/sound/direct_sound_samples/cries/seaking.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_sealeo.aif b/sound/direct_sound_samples/cries/sealeo.aif
index d9ea50026..d9ea50026 100644
--- a/sound/direct_sound_samples/cry_sealeo.aif
+++ b/sound/direct_sound_samples/cries/sealeo.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_seedot.aif b/sound/direct_sound_samples/cries/seedot.aif
index c37b769f8..c37b769f8 100644
--- a/sound/direct_sound_samples/cry_seedot.aif
+++ b/sound/direct_sound_samples/cries/seedot.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_seel.aif b/sound/direct_sound_samples/cries/seel.aif
index 84c4a0a94..84c4a0a94 100644
--- a/sound/direct_sound_samples/cry_seel.aif
+++ b/sound/direct_sound_samples/cries/seel.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_sentret.aif b/sound/direct_sound_samples/cries/sentret.aif
index 4aed7cd70..4aed7cd70 100644
--- a/sound/direct_sound_samples/cry_sentret.aif
+++ b/sound/direct_sound_samples/cries/sentret.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_seviper.aif b/sound/direct_sound_samples/cries/seviper.aif
index 6a15dd6e2..6a15dd6e2 100644
--- a/sound/direct_sound_samples/cry_seviper.aif
+++ b/sound/direct_sound_samples/cries/seviper.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_sharpedo.aif b/sound/direct_sound_samples/cries/sharpedo.aif
index 1b02b56ce..1b02b56ce 100644
--- a/sound/direct_sound_samples/cry_sharpedo.aif
+++ b/sound/direct_sound_samples/cries/sharpedo.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_shedinja.aif b/sound/direct_sound_samples/cries/shedinja.aif
index 6d1d565f3..6d1d565f3 100644
--- a/sound/direct_sound_samples/cry_shedinja.aif
+++ b/sound/direct_sound_samples/cries/shedinja.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_shelgon.aif b/sound/direct_sound_samples/cries/shelgon.aif
index 24f234ffe..24f234ffe 100644
--- a/sound/direct_sound_samples/cry_shelgon.aif
+++ b/sound/direct_sound_samples/cries/shelgon.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_shellder.aif b/sound/direct_sound_samples/cries/shellder.aif
index b2ea85228..b2ea85228 100644
--- a/sound/direct_sound_samples/cry_shellder.aif
+++ b/sound/direct_sound_samples/cries/shellder.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_shiftry.aif b/sound/direct_sound_samples/cries/shiftry.aif
index c91ece114..c91ece114 100644
--- a/sound/direct_sound_samples/cry_shiftry.aif
+++ b/sound/direct_sound_samples/cries/shiftry.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_shroomish.aif b/sound/direct_sound_samples/cries/shroomish.aif
index 9e944ca20..9e944ca20 100644
--- a/sound/direct_sound_samples/cry_shroomish.aif
+++ b/sound/direct_sound_samples/cries/shroomish.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_shuckle.aif b/sound/direct_sound_samples/cries/shuckle.aif
index d835d2de6..d835d2de6 100644
--- a/sound/direct_sound_samples/cry_shuckle.aif
+++ b/sound/direct_sound_samples/cries/shuckle.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_shuppet.aif b/sound/direct_sound_samples/cries/shuppet.aif
index 1cd9a2f14..1cd9a2f14 100644
--- a/sound/direct_sound_samples/cry_shuppet.aif
+++ b/sound/direct_sound_samples/cries/shuppet.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_silcoon.aif b/sound/direct_sound_samples/cries/silcoon.aif
index ff48950ad..ff48950ad 100644
--- a/sound/direct_sound_samples/cry_silcoon.aif
+++ b/sound/direct_sound_samples/cries/silcoon.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_skarmory.aif b/sound/direct_sound_samples/cries/skarmory.aif
index 88d3985a3..88d3985a3 100644
--- a/sound/direct_sound_samples/cry_skarmory.aif
+++ b/sound/direct_sound_samples/cries/skarmory.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_skiploom.aif b/sound/direct_sound_samples/cries/skiploom.aif
index 201744d12..201744d12 100644
--- a/sound/direct_sound_samples/cry_skiploom.aif
+++ b/sound/direct_sound_samples/cries/skiploom.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_skitty.aif b/sound/direct_sound_samples/cries/skitty.aif
index 7dc4578f4..7dc4578f4 100644
--- a/sound/direct_sound_samples/cry_skitty.aif
+++ b/sound/direct_sound_samples/cries/skitty.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_slaking.aif b/sound/direct_sound_samples/cries/slaking.aif
index b6a4160f3..b6a4160f3 100644
--- a/sound/direct_sound_samples/cry_slaking.aif
+++ b/sound/direct_sound_samples/cries/slaking.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_slakoth.aif b/sound/direct_sound_samples/cries/slakoth.aif
index 0e4bbc3c3..0e4bbc3c3 100644
--- a/sound/direct_sound_samples/cry_slakoth.aif
+++ b/sound/direct_sound_samples/cries/slakoth.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_slowbro.aif b/sound/direct_sound_samples/cries/slowbro.aif
index f74b753d2..f74b753d2 100644
--- a/sound/direct_sound_samples/cry_slowbro.aif
+++ b/sound/direct_sound_samples/cries/slowbro.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_slowking.aif b/sound/direct_sound_samples/cries/slowking.aif
index 245a42023..245a42023 100644
--- a/sound/direct_sound_samples/cry_slowking.aif
+++ b/sound/direct_sound_samples/cries/slowking.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_slowpoke.aif b/sound/direct_sound_samples/cries/slowpoke.aif
index 82b05a9a7..82b05a9a7 100644
--- a/sound/direct_sound_samples/cry_slowpoke.aif
+++ b/sound/direct_sound_samples/cries/slowpoke.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_slugma.aif b/sound/direct_sound_samples/cries/slugma.aif
index fed42817c..fed42817c 100644
--- a/sound/direct_sound_samples/cry_slugma.aif
+++ b/sound/direct_sound_samples/cries/slugma.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_smeargle.aif b/sound/direct_sound_samples/cries/smeargle.aif
index 00dbedead..00dbedead 100644
--- a/sound/direct_sound_samples/cry_smeargle.aif
+++ b/sound/direct_sound_samples/cries/smeargle.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_smoochum.aif b/sound/direct_sound_samples/cries/smoochum.aif
index 4005b4ad4..4005b4ad4 100644
--- a/sound/direct_sound_samples/cry_smoochum.aif
+++ b/sound/direct_sound_samples/cries/smoochum.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_sneasel.aif b/sound/direct_sound_samples/cries/sneasel.aif
index 54242a23f..54242a23f 100644
--- a/sound/direct_sound_samples/cry_sneasel.aif
+++ b/sound/direct_sound_samples/cries/sneasel.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_snorlax.aif b/sound/direct_sound_samples/cries/snorlax.aif
index f95128e3a..f95128e3a 100644
--- a/sound/direct_sound_samples/cry_snorlax.aif
+++ b/sound/direct_sound_samples/cries/snorlax.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_snorunt.aif b/sound/direct_sound_samples/cries/snorunt.aif
index 53b05b229..53b05b229 100644
--- a/sound/direct_sound_samples/cry_snorunt.aif
+++ b/sound/direct_sound_samples/cries/snorunt.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_snubbull.aif b/sound/direct_sound_samples/cries/snubbull.aif
index bbba023fd..bbba023fd 100644
--- a/sound/direct_sound_samples/cry_snubbull.aif
+++ b/sound/direct_sound_samples/cries/snubbull.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_solrock.aif b/sound/direct_sound_samples/cries/solrock.aif
index 64c71f289..64c71f289 100644
--- a/sound/direct_sound_samples/cry_solrock.aif
+++ b/sound/direct_sound_samples/cries/solrock.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_spearow.aif b/sound/direct_sound_samples/cries/spearow.aif
index 7ce86ae29..7ce86ae29 100644
--- a/sound/direct_sound_samples/cry_spearow.aif
+++ b/sound/direct_sound_samples/cries/spearow.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_spheal.aif b/sound/direct_sound_samples/cries/spheal.aif
index fb6470210..fb6470210 100644
--- a/sound/direct_sound_samples/cry_spheal.aif
+++ b/sound/direct_sound_samples/cries/spheal.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_spinarak.aif b/sound/direct_sound_samples/cries/spinarak.aif
index 3c4c1eff1..3c4c1eff1 100644
--- a/sound/direct_sound_samples/cry_spinarak.aif
+++ b/sound/direct_sound_samples/cries/spinarak.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_spinda.aif b/sound/direct_sound_samples/cries/spinda.aif
index 0217573c7..0217573c7 100644
--- a/sound/direct_sound_samples/cry_spinda.aif
+++ b/sound/direct_sound_samples/cries/spinda.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_spoink.aif b/sound/direct_sound_samples/cries/spoink.aif
index 6cc9bf546..6cc9bf546 100644
--- a/sound/direct_sound_samples/cry_spoink.aif
+++ b/sound/direct_sound_samples/cries/spoink.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_squirtle.aif b/sound/direct_sound_samples/cries/squirtle.aif
index 43a98a53d..43a98a53d 100644
--- a/sound/direct_sound_samples/cry_squirtle.aif
+++ b/sound/direct_sound_samples/cries/squirtle.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_stantler.aif b/sound/direct_sound_samples/cries/stantler.aif
index 36ba54658..36ba54658 100644
--- a/sound/direct_sound_samples/cry_stantler.aif
+++ b/sound/direct_sound_samples/cries/stantler.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_starmie.aif b/sound/direct_sound_samples/cries/starmie.aif
index 7452a78f9..7452a78f9 100644
--- a/sound/direct_sound_samples/cry_starmie.aif
+++ b/sound/direct_sound_samples/cries/starmie.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_staryu.aif b/sound/direct_sound_samples/cries/staryu.aif
index 6ab5584bf..6ab5584bf 100644
--- a/sound/direct_sound_samples/cry_staryu.aif
+++ b/sound/direct_sound_samples/cries/staryu.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_steelix.aif b/sound/direct_sound_samples/cries/steelix.aif
index aa05e2d4c..aa05e2d4c 100644
--- a/sound/direct_sound_samples/cry_steelix.aif
+++ b/sound/direct_sound_samples/cries/steelix.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_sudowoodo.aif b/sound/direct_sound_samples/cries/sudowoodo.aif
index 1af7e18eb..1af7e18eb 100644
--- a/sound/direct_sound_samples/cry_sudowoodo.aif
+++ b/sound/direct_sound_samples/cries/sudowoodo.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_suicune.aif b/sound/direct_sound_samples/cries/suicune.aif
index 697732d68..697732d68 100644
--- a/sound/direct_sound_samples/cry_suicune.aif
+++ b/sound/direct_sound_samples/cries/suicune.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_sunflora.aif b/sound/direct_sound_samples/cries/sunflora.aif
index 126931adc..126931adc 100644
--- a/sound/direct_sound_samples/cry_sunflora.aif
+++ b/sound/direct_sound_samples/cries/sunflora.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_sunkern.aif b/sound/direct_sound_samples/cries/sunkern.aif
index bede3bf95..bede3bf95 100644
--- a/sound/direct_sound_samples/cry_sunkern.aif
+++ b/sound/direct_sound_samples/cries/sunkern.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_surskit.aif b/sound/direct_sound_samples/cries/surskit.aif
index 438b5b67a..438b5b67a 100644
--- a/sound/direct_sound_samples/cry_surskit.aif
+++ b/sound/direct_sound_samples/cries/surskit.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_swablu.aif b/sound/direct_sound_samples/cries/swablu.aif
index 066095f55..066095f55 100644
--- a/sound/direct_sound_samples/cry_swablu.aif
+++ b/sound/direct_sound_samples/cries/swablu.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_swalot.aif b/sound/direct_sound_samples/cries/swalot.aif
index 518a9bf5a..518a9bf5a 100644
--- a/sound/direct_sound_samples/cry_swalot.aif
+++ b/sound/direct_sound_samples/cries/swalot.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_swampert.aif b/sound/direct_sound_samples/cries/swampert.aif
index 56bd26405..56bd26405 100644
--- a/sound/direct_sound_samples/cry_swampert.aif
+++ b/sound/direct_sound_samples/cries/swampert.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_swellow.aif b/sound/direct_sound_samples/cries/swellow.aif
index 2b94eb432..2b94eb432 100644
--- a/sound/direct_sound_samples/cry_swellow.aif
+++ b/sound/direct_sound_samples/cries/swellow.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_swinub.aif b/sound/direct_sound_samples/cries/swinub.aif
index dc68d62d8..dc68d62d8 100644
--- a/sound/direct_sound_samples/cry_swinub.aif
+++ b/sound/direct_sound_samples/cries/swinub.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_taillow.aif b/sound/direct_sound_samples/cries/taillow.aif
index 8322a3224..8322a3224 100644
--- a/sound/direct_sound_samples/cry_taillow.aif
+++ b/sound/direct_sound_samples/cries/taillow.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_tangela.aif b/sound/direct_sound_samples/cries/tangela.aif
index c900b426d..c900b426d 100644
--- a/sound/direct_sound_samples/cry_tangela.aif
+++ b/sound/direct_sound_samples/cries/tangela.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_tauros.aif b/sound/direct_sound_samples/cries/tauros.aif
index 84fa9b317..84fa9b317 100644
--- a/sound/direct_sound_samples/cry_tauros.aif
+++ b/sound/direct_sound_samples/cries/tauros.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_teddiursa.aif b/sound/direct_sound_samples/cries/teddiursa.aif
index ba5cb5bc3..ba5cb5bc3 100644
--- a/sound/direct_sound_samples/cry_teddiursa.aif
+++ b/sound/direct_sound_samples/cries/teddiursa.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_tentacool.aif b/sound/direct_sound_samples/cries/tentacool.aif
index 332bec4b2..332bec4b2 100644
--- a/sound/direct_sound_samples/cry_tentacool.aif
+++ b/sound/direct_sound_samples/cries/tentacool.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_tentacruel.aif b/sound/direct_sound_samples/cries/tentacruel.aif
index e8ec1b14c..e8ec1b14c 100644
--- a/sound/direct_sound_samples/cry_tentacruel.aif
+++ b/sound/direct_sound_samples/cries/tentacruel.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_togepi.aif b/sound/direct_sound_samples/cries/togepi.aif
index 87ef6ef2d..87ef6ef2d 100644
--- a/sound/direct_sound_samples/cry_togepi.aif
+++ b/sound/direct_sound_samples/cries/togepi.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_togetic.aif b/sound/direct_sound_samples/cries/togetic.aif
index 8aa18ac41..8aa18ac41 100644
--- a/sound/direct_sound_samples/cry_togetic.aif
+++ b/sound/direct_sound_samples/cries/togetic.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_torchic.aif b/sound/direct_sound_samples/cries/torchic.aif
index 185a79499..185a79499 100644
--- a/sound/direct_sound_samples/cry_torchic.aif
+++ b/sound/direct_sound_samples/cries/torchic.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_torkoal.aif b/sound/direct_sound_samples/cries/torkoal.aif
index 9e56d3810..9e56d3810 100644
--- a/sound/direct_sound_samples/cry_torkoal.aif
+++ b/sound/direct_sound_samples/cries/torkoal.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_totodile.aif b/sound/direct_sound_samples/cries/totodile.aif
index dbf2179a7..dbf2179a7 100644
--- a/sound/direct_sound_samples/cry_totodile.aif
+++ b/sound/direct_sound_samples/cries/totodile.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_trapinch.aif b/sound/direct_sound_samples/cries/trapinch.aif
index 01664b72e..01664b72e 100644
--- a/sound/direct_sound_samples/cry_trapinch.aif
+++ b/sound/direct_sound_samples/cries/trapinch.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_treecko.aif b/sound/direct_sound_samples/cries/treecko.aif
index a7416e8da..a7416e8da 100644
--- a/sound/direct_sound_samples/cry_treecko.aif
+++ b/sound/direct_sound_samples/cries/treecko.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_tropius.aif b/sound/direct_sound_samples/cries/tropius.aif
index bbb52787b..bbb52787b 100644
--- a/sound/direct_sound_samples/cry_tropius.aif
+++ b/sound/direct_sound_samples/cries/tropius.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_typhlosion.aif b/sound/direct_sound_samples/cries/typhlosion.aif
index f0238d066..f0238d066 100644
--- a/sound/direct_sound_samples/cry_typhlosion.aif
+++ b/sound/direct_sound_samples/cries/typhlosion.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_tyranitar.aif b/sound/direct_sound_samples/cries/tyranitar.aif
index 557f61769..557f61769 100644
--- a/sound/direct_sound_samples/cry_tyranitar.aif
+++ b/sound/direct_sound_samples/cries/tyranitar.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_tyrogue.aif b/sound/direct_sound_samples/cries/tyrogue.aif
index e5065f58b..e5065f58b 100644
--- a/sound/direct_sound_samples/cry_tyrogue.aif
+++ b/sound/direct_sound_samples/cries/tyrogue.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_umbreon.aif b/sound/direct_sound_samples/cries/umbreon.aif
index 38129b1a7..38129b1a7 100644
--- a/sound/direct_sound_samples/cry_umbreon.aif
+++ b/sound/direct_sound_samples/cries/umbreon.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_unown.aif b/sound/direct_sound_samples/cries/unown.aif
index 8339ccb6b..8339ccb6b 100644
--- a/sound/direct_sound_samples/cry_unown.aif
+++ b/sound/direct_sound_samples/cries/unown.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_unused_265.aif b/sound/direct_sound_samples/cries/unused_265.aif
index 7f5965f06..7f5965f06 100644
--- a/sound/direct_sound_samples/cry_unused_265.aif
+++ b/sound/direct_sound_samples/cries/unused_265.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_unused_268.aif b/sound/direct_sound_samples/cries/unused_268.aif
index 5cae364c3..5cae364c3 100644
--- a/sound/direct_sound_samples/cry_unused_268.aif
+++ b/sound/direct_sound_samples/cries/unused_268.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_ursaring.aif b/sound/direct_sound_samples/cries/ursaring.aif
index fcc748bd1..fcc748bd1 100644
--- a/sound/direct_sound_samples/cry_ursaring.aif
+++ b/sound/direct_sound_samples/cries/ursaring.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_vaporeon.aif b/sound/direct_sound_samples/cries/vaporeon.aif
index 4967cfdeb..4967cfdeb 100644
--- a/sound/direct_sound_samples/cry_vaporeon.aif
+++ b/sound/direct_sound_samples/cries/vaporeon.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_venomoth.aif b/sound/direct_sound_samples/cries/venomoth.aif
index bc291ec33..bc291ec33 100644
--- a/sound/direct_sound_samples/cry_venomoth.aif
+++ b/sound/direct_sound_samples/cries/venomoth.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_venonat.aif b/sound/direct_sound_samples/cries/venonat.aif
index e89d87fa8..e89d87fa8 100644
--- a/sound/direct_sound_samples/cry_venonat.aif
+++ b/sound/direct_sound_samples/cries/venonat.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_venusaur.aif b/sound/direct_sound_samples/cries/venusaur.aif
index 8a1f69e6e..8a1f69e6e 100644
--- a/sound/direct_sound_samples/cry_venusaur.aif
+++ b/sound/direct_sound_samples/cries/venusaur.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_vibrava.aif b/sound/direct_sound_samples/cries/vibrava.aif
index 3e3180219..3e3180219 100644
--- a/sound/direct_sound_samples/cry_vibrava.aif
+++ b/sound/direct_sound_samples/cries/vibrava.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_victreebel.aif b/sound/direct_sound_samples/cries/victreebel.aif
index d6e6a4fe9..d6e6a4fe9 100644
--- a/sound/direct_sound_samples/cry_victreebel.aif
+++ b/sound/direct_sound_samples/cries/victreebel.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_vigoroth.aif b/sound/direct_sound_samples/cries/vigoroth.aif
index fc414f33d..fc414f33d 100644
--- a/sound/direct_sound_samples/cry_vigoroth.aif
+++ b/sound/direct_sound_samples/cries/vigoroth.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_vileplume.aif b/sound/direct_sound_samples/cries/vileplume.aif
index 723eec697..723eec697 100644
--- a/sound/direct_sound_samples/cry_vileplume.aif
+++ b/sound/direct_sound_samples/cries/vileplume.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_volbeat.aif b/sound/direct_sound_samples/cries/volbeat.aif
index 6f765081e..6f765081e 100644
--- a/sound/direct_sound_samples/cry_volbeat.aif
+++ b/sound/direct_sound_samples/cries/volbeat.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_voltorb.aif b/sound/direct_sound_samples/cries/voltorb.aif
index 96e3bff31..96e3bff31 100644
--- a/sound/direct_sound_samples/cry_voltorb.aif
+++ b/sound/direct_sound_samples/cries/voltorb.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_vulpix.aif b/sound/direct_sound_samples/cries/vulpix.aif
index 20da23fb4..20da23fb4 100644
--- a/sound/direct_sound_samples/cry_vulpix.aif
+++ b/sound/direct_sound_samples/cries/vulpix.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_wailmer.aif b/sound/direct_sound_samples/cries/wailmer.aif
index e8de91333..e8de91333 100644
--- a/sound/direct_sound_samples/cry_wailmer.aif
+++ b/sound/direct_sound_samples/cries/wailmer.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_wailord.aif b/sound/direct_sound_samples/cries/wailord.aif
index 2c0468010..2c0468010 100644
--- a/sound/direct_sound_samples/cry_wailord.aif
+++ b/sound/direct_sound_samples/cries/wailord.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_walrein.aif b/sound/direct_sound_samples/cries/walrein.aif
index 91d93f3fb..91d93f3fb 100644
--- a/sound/direct_sound_samples/cry_walrein.aif
+++ b/sound/direct_sound_samples/cries/walrein.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_wartortle.aif b/sound/direct_sound_samples/cries/wartortle.aif
index 5dab7fd93..5dab7fd93 100644
--- a/sound/direct_sound_samples/cry_wartortle.aif
+++ b/sound/direct_sound_samples/cries/wartortle.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_weedle.aif b/sound/direct_sound_samples/cries/weedle.aif
index 773c2c8ae..773c2c8ae 100644
--- a/sound/direct_sound_samples/cry_weedle.aif
+++ b/sound/direct_sound_samples/cries/weedle.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_weepinbell.aif b/sound/direct_sound_samples/cries/weepinbell.aif
index cdd61380a..cdd61380a 100644
--- a/sound/direct_sound_samples/cry_weepinbell.aif
+++ b/sound/direct_sound_samples/cries/weepinbell.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_weezing.aif b/sound/direct_sound_samples/cries/weezing.aif
index 2e4a7fe13..2e4a7fe13 100644
--- a/sound/direct_sound_samples/cry_weezing.aif
+++ b/sound/direct_sound_samples/cries/weezing.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_whiscash.aif b/sound/direct_sound_samples/cries/whiscash.aif
index 219737f32..219737f32 100644
--- a/sound/direct_sound_samples/cry_whiscash.aif
+++ b/sound/direct_sound_samples/cries/whiscash.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_whismur.aif b/sound/direct_sound_samples/cries/whismur.aif
index 4da92ca6a..4da92ca6a 100644
--- a/sound/direct_sound_samples/cry_whismur.aif
+++ b/sound/direct_sound_samples/cries/whismur.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_wigglytuff.aif b/sound/direct_sound_samples/cries/wigglytuff.aif
index 90aa90a23..90aa90a23 100644
--- a/sound/direct_sound_samples/cry_wigglytuff.aif
+++ b/sound/direct_sound_samples/cries/wigglytuff.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_wingull.aif b/sound/direct_sound_samples/cries/wingull.aif
index 182ef18e6..182ef18e6 100644
--- a/sound/direct_sound_samples/cry_wingull.aif
+++ b/sound/direct_sound_samples/cries/wingull.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_wobbuffet.aif b/sound/direct_sound_samples/cries/wobbuffet.aif
index 70ee1f704..70ee1f704 100644
--- a/sound/direct_sound_samples/cry_wobbuffet.aif
+++ b/sound/direct_sound_samples/cries/wobbuffet.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_wooper.aif b/sound/direct_sound_samples/cries/wooper.aif
index 51a6b627e..51a6b627e 100644
--- a/sound/direct_sound_samples/cry_wooper.aif
+++ b/sound/direct_sound_samples/cries/wooper.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_wurmple.aif b/sound/direct_sound_samples/cries/wurmple.aif
index 6442a4063..6442a4063 100644
--- a/sound/direct_sound_samples/cry_wurmple.aif
+++ b/sound/direct_sound_samples/cries/wurmple.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_wynaut.aif b/sound/direct_sound_samples/cries/wynaut.aif
index 798732c74..798732c74 100644
--- a/sound/direct_sound_samples/cry_wynaut.aif
+++ b/sound/direct_sound_samples/cries/wynaut.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_xatu.aif b/sound/direct_sound_samples/cries/xatu.aif
index ac758fdbf..ac758fdbf 100644
--- a/sound/direct_sound_samples/cry_xatu.aif
+++ b/sound/direct_sound_samples/cries/xatu.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_yanma.aif b/sound/direct_sound_samples/cries/yanma.aif
index df76534c5..df76534c5 100644
--- a/sound/direct_sound_samples/cry_yanma.aif
+++ b/sound/direct_sound_samples/cries/yanma.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_zangoose.aif b/sound/direct_sound_samples/cries/zangoose.aif
index 3c206532f..3c206532f 100644
--- a/sound/direct_sound_samples/cry_zangoose.aif
+++ b/sound/direct_sound_samples/cries/zangoose.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_zapdos.aif b/sound/direct_sound_samples/cries/zapdos.aif
index a8d914d14..a8d914d14 100644
--- a/sound/direct_sound_samples/cry_zapdos.aif
+++ b/sound/direct_sound_samples/cries/zapdos.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_zigzagoon.aif b/sound/direct_sound_samples/cries/zigzagoon.aif
index 52b9bb4f4..52b9bb4f4 100644
--- a/sound/direct_sound_samples/cry_zigzagoon.aif
+++ b/sound/direct_sound_samples/cries/zigzagoon.aif
Binary files differ
diff --git a/sound/direct_sound_samples/cry_zubat.aif b/sound/direct_sound_samples/cries/zubat.aif
index 45036d072..45036d072 100644
--- a/sound/direct_sound_samples/cry_zubat.aif
+++ b/sound/direct_sound_samples/cries/zubat.aif
Binary files differ
diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c
index 6604fa142..ce22c605f 100644
--- a/src/battle_controller_link_opponent.c
+++ b/src/battle_controller_link_opponent.c
@@ -1267,9 +1267,9 @@ static void LinkOpponentHandleDrawTrainerPic(void)
else
{
xPos = 176;
- if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_C00)
+ if (gTrainerBattleOpponent_A == TRAINER_UNION_ROOM)
{
- trainerPicId = sub_8068B48();
+ trainerPicId = GetUnionRoomTrainerPic();
}
else if ((gLinkPlayers[GetMultiplayerId() ^ BIT_SIDE].version & 0xFF) == VERSION_FIRE_RED
|| (gLinkPlayers[GetMultiplayerId() ^ BIT_SIDE].version & 0xFF) == VERSION_LEAF_GREEN)
diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c
index 7c1bff64a..35383611b 100644
--- a/src/battle_controller_recorded_opponent.c
+++ b/src/battle_controller_recorded_opponent.c
@@ -1229,9 +1229,9 @@ static void RecordedOpponentHandleDrawTrainerPic(void)
else
{
xPos = 176;
- if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_C00)
+ if (gTrainerBattleOpponent_A == TRAINER_UNION_ROOM)
{
- trainerPicId = sub_8068B48();
+ trainerPicId = GetUnionRoomTrainerPic();
}
else
{
diff --git a/src/battle_controllers.c b/src/battle_controllers.c
index b411c12f6..7f78c1ac9 100644
--- a/src/battle_controllers.c
+++ b/src/battle_controllers.c
@@ -6,6 +6,7 @@
#include "battle_message.h"
#include "cable_club.h"
#include "link.h"
+#include "link_rfu.h"
#include "party_menu.h"
#include "pokemon.h"
#include "recorded_battle.h"
@@ -33,10 +34,10 @@ void HandleLinkBattleSetup(void)
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
if (gWirelessCommType)
- sub_800B488();
+ SetWirelessCommType1();
if (!gReceivedRemoteLinkPlayers)
OpenLink();
- CreateTask(task00_08081A90, 0);
+ CreateTask(Task_WaitForLinkPlayerConnection, 0);
CreateTasksForSendRecvLinkBuffers();
}
}
@@ -827,7 +828,7 @@ void sub_8033648(void)
if (gReceivedRemoteLinkPlayers != 0 && (gBattleTypeFlags & BATTLE_TYPE_20))
{
- sub_8011BD0();
+ DestroyTask_RfuIdle();
for (i = 0; i < GetLinkPlayerCount(); i++)
{
if (GetBlockReceivedStatus() & gBitTable[i])
diff --git a/src/battle_main.c b/src/battle_main.c
index d6e3d5845..3a78da695 100644
--- a/src/battle_main.c
+++ b/src/battle_main.c
@@ -995,7 +995,7 @@ static void CB2_HandleStartBattle(void)
sub_8036A5C();
SetPlayerBerryDataInBattleStruct();
- if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_C00)
+ if (gTrainerBattleOpponent_A == TRAINER_UNION_ROOM)
{
gLinkPlayers[0].id = 0;
gLinkPlayers[1].id = 1;
diff --git a/src/battle_message.c b/src/battle_message.c
index efa4500c8..693058e2f 100644
--- a/src/battle_message.c
+++ b/src/battle_message.c
@@ -1981,7 +1981,7 @@ void BufferStringBattle(u16 stringID)
}
else
{
- if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_C00)
+ if (gTrainerBattleOpponent_A == TRAINER_UNION_ROOM)
stringPtr = sText_Trainer1WantsToBattle;
else if (gBattleTypeFlags & BATTLE_TYPE_RECORDED)
stringPtr = sText_LinkTrainerWantsToBattlePause;
@@ -2049,7 +2049,7 @@ void BufferStringBattle(u16 stringID)
{
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)))
stringPtr = sText_Trainer1SentOutPkmn;
- else if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_C00)
+ else if (gTrainerBattleOpponent_A == TRAINER_UNION_ROOM)
stringPtr = sText_Trainer1SentOutPkmn;
else
stringPtr = sText_LinkTrainerSentOutPkmn;
@@ -2110,7 +2110,7 @@ void BufferStringBattle(u16 stringID)
{
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
stringPtr = sText_LinkTrainerMultiSentOutPkmn;
- else if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_C00)
+ else if (gTrainerBattleOpponent_A == TRAINER_UNION_ROOM)
stringPtr = sText_Trainer1SentOutPkmn2;
else
stringPtr = sText_LinkTrainerSentOutPkmn2;
@@ -2180,7 +2180,7 @@ void BufferStringBattle(u16 stringID)
break;
}
}
- else if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_C00)
+ else if (gTrainerBattleOpponent_A == TRAINER_UNION_ROOM)
{
switch (gBattleTextBuff1[0])
{
@@ -2495,8 +2495,8 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst)
case B_TXT_TRAINER1_CLASS: // trainer class name
if (gBattleTypeFlags & BATTLE_TYPE_SECRET_BASE)
toCpy = gTrainerClassNames[GetSecretBaseTrainerClass()];
- else if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_C00)
- toCpy = gTrainerClassNames[sub_8068BB0()];
+ else if (gTrainerBattleOpponent_A == TRAINER_UNION_ROOM)
+ toCpy = gTrainerClassNames[GetUnionRoomTrainerClass()];
else if (gTrainerBattleOpponent_A == TRAINER_FRONTIER_BRAIN)
toCpy = gTrainerClassNames[GetFrontierBrainTrainerClass()];
else if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER)
@@ -2517,7 +2517,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst)
ConvertInternationalString(text, gBattleResources->secretBase->language);
toCpy = text;
}
- else if (gTrainerBattleOpponent_A == TRAINER_OPPONENT_C00)
+ else if (gTrainerBattleOpponent_A == TRAINER_UNION_ROOM)
{
toCpy = gLinkPlayers[multiplayerId ^ BIT_SIDE].name;
}
diff --git a/src/berry.c b/src/berry.c
index fe4a66af6..98264f37b 100644
--- a/src/berry.c
+++ b/src/berry.c
@@ -997,7 +997,7 @@ struct BerryTree *GetBerryTreeInfo(u8 id)
bool32 ObjectEventInteractionWaterBerryTree(void)
{
- struct BerryTree *tree = GetBerryTreeInfo(ObjectEventGetBerryTreeId(gSelectedObjectEvent));
+ struct BerryTree *tree = GetBerryTreeInfo(GetObjectEventBerryTreeId(gSelectedObjectEvent));
switch (tree->stage)
{
@@ -1022,7 +1022,7 @@ bool32 ObjectEventInteractionWaterBerryTree(void)
bool8 IsPlayerFacingEmptyBerryTreePatch(void)
{
if (GetObjectEventScriptPointerPlayerFacing() == BerryTreeScript
- && GetStageByBerryTreeId(ObjectEventGetBerryTreeId(gSelectedObjectEvent)) == BERRY_STAGE_NO_BERRY)
+ && GetStageByBerryTreeId(GetObjectEventBerryTreeId(gSelectedObjectEvent)) == BERRY_STAGE_NO_BERRY)
return TRUE;
else
return FALSE;
@@ -1260,7 +1260,7 @@ void ObjectEventInteractionGetBerryTreeData(void)
u8 group;
u8 num;
- id = ObjectEventGetBerryTreeId(gSelectedObjectEvent);
+ id = GetObjectEventBerryTreeId(gSelectedObjectEvent);
berry = GetBerryTypeByBerryTreeId(id);
ResetBerryTreeSparkleFlag(id);
localId = gSpecialVar_LastTalked;
@@ -1277,13 +1277,13 @@ void ObjectEventInteractionGetBerryTreeData(void)
void ObjectEventInteractionGetBerryName(void)
{
- u8 berryType = GetBerryTypeByBerryTreeId(ObjectEventGetBerryTreeId(gSelectedObjectEvent));
+ u8 berryType = GetBerryTypeByBerryTreeId(GetObjectEventBerryTreeId(gSelectedObjectEvent));
GetBerryNameByBerryType(berryType, gStringVar1);
}
void ObjectEventInteractionGetBerryCountString(void)
{
- u8 treeId = ObjectEventGetBerryTreeId(gSelectedObjectEvent);
+ u8 treeId = GetObjectEventBerryTreeId(gSelectedObjectEvent);
u8 berry = GetBerryTypeByBerryTreeId(treeId);
u8 count = GetBerryCountByBerryTreeId(treeId);
GetBerryCountStringByBerryType(berry, gStringVar1, count);
@@ -1298,13 +1298,13 @@ void ObjectEventInteractionPlantBerryTree(void)
{
u8 berry = ItemIdToBerryType(gSpecialVar_ItemId);
- PlantBerryTree(ObjectEventGetBerryTreeId(gSelectedObjectEvent), berry, 1, TRUE);
+ PlantBerryTree(GetObjectEventBerryTreeId(gSelectedObjectEvent), berry, 1, TRUE);
ObjectEventInteractionGetBerryTreeData();
}
void ObjectEventInteractionPickBerryTree(void)
{
- u8 id = ObjectEventGetBerryTreeId(gSelectedObjectEvent);
+ u8 id = GetObjectEventBerryTreeId(gSelectedObjectEvent);
u8 berry = GetBerryTypeByBerryTreeId(id);
gSpecialVar_0x8004 = AddBagItem(BerryTypeToItemId(berry), GetBerryCountByBerryTreeId(id));
@@ -1312,7 +1312,7 @@ void ObjectEventInteractionPickBerryTree(void)
void ObjectEventInteractionRemoveBerryTree(void)
{
- RemoveBerryTree(ObjectEventGetBerryTreeId(gSelectedObjectEvent));
+ RemoveBerryTree(GetObjectEventBerryTreeId(gSelectedObjectEvent));
sub_8092EF0(gSpecialVar_LastTalked, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
}
diff --git a/src/berry_blender.c b/src/berry_blender.c
index 2a122541d..a2a96c089 100644
--- a/src/berry_blender.c
+++ b/src/berry_blender.c
@@ -1246,7 +1246,7 @@ static void sub_8080018(void)
if (++sBerryBlenderData->framesToWait > 20)
{
ClearDialogWindowAndFrameToTransparent(4, TRUE);
- if (GetBlockReceivedStatus() == sub_800A9D8())
+ if (GetBlockReceivedStatus() == GetLinkPlayerCountAsBitFlags())
{
for (i = 0; i < GetLinkPlayerCount(); i++)
{
@@ -1500,7 +1500,7 @@ static void sub_80808D4(void)
switch (sBerryBlenderData->mainState)
{
case 0:
- sub_800B4C0();
+ SetWirelessCommType0();
sub_8080588();
Blender_SetParticipantBerryData(0, gSpecialVar_ItemId);
Blender_CopyBerryData(&sBerryBlenderData->blendedBerries[0], gSpecialVar_ItemId);
@@ -1664,7 +1664,7 @@ static void sub_80808D4(void)
static void sub_8080DF8(void)
{
s32 i;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < CMD_LENGTH / 2; i++)
{
gSendCmd[0] = 0;
gSendCmd[2] = 0;
@@ -2202,6 +2202,11 @@ static s16 sub_8081BD4(void)
return sUnknown_03000E06;
}
+#if MODERN
+// TODO remove this as soon as the code below is understood
+// add a UBFIX if required (code buggy?)
+__attribute__((optimize("no-aggressive-loop-optimizations")))
+#endif
static void Blender_CalculatePokeblock(struct BlenderBerry *berries, struct Pokeblock *pokeblock, u8 playersNo, u8 *flavors, u16 maxRPM)
{
s32 i, j;
diff --git a/src/berry_crush.c b/src/berry_crush.c
index 48e4ac4c3..90a299a74 100755
--- a/src/berry_crush.c
+++ b/src/berry_crush.c
@@ -832,7 +832,7 @@ u32 sub_8020C0C(MainCallback callback)
return 0;
}
-void sub_8020C70(MainCallback callback)
+void StartBerryCrush(MainCallback callback)
{
u8 playerCount = 0;
u8 multiplayerId;
@@ -842,7 +842,7 @@ void sub_8020C70(MainCallback callback)
SetMainCallback2(callback);
Rfu.unk_10 = 0;
Rfu.unk_12 = 0;
- Rfu.unk_ee = 1;
+ Rfu.errorState = 1;
return;
}
@@ -853,7 +853,7 @@ void sub_8020C70(MainCallback callback)
SetMainCallback2(callback);
Rfu.unk_10 = 0;
Rfu.unk_12 = 0;
- Rfu.unk_ee = 1;
+ Rfu.errorState = 1;
return;
}
@@ -863,7 +863,7 @@ void sub_8020C70(MainCallback callback)
SetMainCallback2(callback);
Rfu.unk_10 = 0;
Rfu.unk_12 = 0;
- Rfu.unk_ee = 1;
+ Rfu.errorState = 1;
return;
}
@@ -3013,10 +3013,10 @@ static u32 sub_8024134(struct BerryCrushGame *r5, u8 *r4)
DrawDialogueFrame(0, 0);
AddTextPrinterParameterized2(0, 1, gText_SavingDontTurnOffPower, 0, 0, 2, 1, 3);
CopyWindowToVram(0, 3);
- CreateTask(sub_8153688, 0);
+ CreateTask(Task_LinkSave, 0);
break;
case 3:
- if (FuncIsActiveTask(sub_8153688))
+ if (FuncIsActiveTask(Task_LinkSave))
return 0;
break;
case 4:
@@ -3209,6 +3209,11 @@ static u32 sub_8024568(__attribute__((unused)) struct BerryCrushGame *r0, __attr
return 0;
}
+#if MODERN
+// TODO remove this as soon as the code below is understood
+// add a UBFIX if required (code buggy?)
+__attribute__((optimize("no-aggressive-loop-optimizations")))
+#endif
void sub_8024578(struct BerryCrushGame *r4)
{
u8 r5 = 0;
diff --git a/src/cable_club.c b/src/cable_club.c
index b9c948a9c..15e468390 100644
--- a/src/cable_club.c
+++ b/src/cable_club.c
@@ -33,8 +33,9 @@
#include "constants/battle_frontier.h"
#include "constants/cable_club.h"
#include "constants/songs.h"
+#include "constants/trainers.h"
-static const struct WindowTemplate gUnknown_08550594 = {
+static const struct WindowTemplate sWindowTemplate_LinkPlayerCount = {
.bg = 0,
.tilemapLeft = 16,
.tilemapTop = 11,
@@ -43,57 +44,67 @@ static const struct WindowTemplate gUnknown_08550594 = {
.paletteNum = 15,
.baseBlock = 0x0125,
};
-static const u8 *const gTrainerCardColorNames[] = {
+
+static const u8 *const sTrainerCardColorNames[] = {
gText_BronzeCard,
gText_CopperCard,
gText_SilverCard,
gText_GoldCard
};
-static void sub_80B2634(u8 taskId);
-static void sub_80B2688(u8 taskId);
-static void sub_80B270C(u8 taskId);
-static void sub_80B275C(u8 taskId);
-static void sub_80B2804(u8 taskId);
-static void sub_80B28A8(u8 taskId);
-static void sub_80B2918(u8 taskId);
-static void sub_80B2A08(u8 taskId);
-static void sub_80B2C30(u8 taskId);
-static void sub_80B2CB0(u8 taskId);
-static void sub_80B2CEC(u8 taskId);
-static void sub_80B2D2C(u8 taskId);
-static bool8 sub_80B2D6C(u8 taskId);
-static void sub_80B2EE4(u8 taskId);
-static void sub_80B3144(u8 taskId);
-static void sub_80B3194(u8 taskId);
-static void sub_80B31E8(u8 taskId);
-static void sub_80B3220(u8 taskId);
-
-static void sub_80B236C(u8 arg0, u8 arg1)
+static void Task_LinkupStart(u8 taskId);
+static void Task_LinkupAwaitConnection(u8 taskId);
+static void Task_LinkupConfirmWhenReady(u8 taskId);
+static void Task_LinkupAwaitConfirmation(u8 taskId);
+static void Task_LinkupTryConfirmation(u8 taskId);
+static void Task_LinkupConfirm(u8 taskId);
+static void Task_LinkupExchangeDataWithLeader(u8 taskId);
+static void Task_LinkupCheckStatusAfterConfirm(u8 taskId);
+static void Task_LinkupAwaitTrainerCardData(u8 taskId);
+static void Task_StopLinkup(u8 taskId);
+static void Task_LinkupFailed(u8 taskId);
+static void Task_LinkupConnectionError(u8 taskId);
+static bool8 TryLinkTimeout(u8 taskId);
+static void Task_ValidateMixingGameLanguage(u8 taskId);
+static void Task_ReestablishLink(u8 taskId);
+static void Task_ReestablishLinkAwaitConnection(u8 taskId);
+static void Task_ReestablishLinkLeader(u8 taskId);
+static void Task_ReestablishLinkAwaitConfirmation(u8 taskId);
+
+#define tState data[0]
+
+
+#define tMinPlayers data[1]
+#define tMaxPlayers data[2]
+#define tNumPlayers data[3]
+#define tTimer data[4]
+#define tWindowId data[5]
+
+static void CreateLinkupTask(u8 minPlayers, u8 maxPlayers)
{
- if (FindTaskIdByFunc(sub_80B2634) == 0xFF)
+ if (FindTaskIdByFunc(Task_LinkupStart) == 0xFF)
{
u8 taskId1;
- taskId1 = CreateTask(sub_80B2634, 80);
- gTasks[taskId1].data[1] = arg0;
- gTasks[taskId1].data[2] = arg1;
+ taskId1 = CreateTask(Task_LinkupStart, 80);
+ gTasks[taskId1].tMinPlayers = minPlayers;
+ gTasks[taskId1].tMaxPlayers = maxPlayers;
}
}
-static void sub_80B23B0(u16 windowId, u32 value)
+static void PrintNumPlayersInLink(u16 windowId, u32 numPlayers)
{
u8 xPos;
- ConvertIntToDecimalStringN(gStringVar1, value, STR_CONV_MODE_LEFT_ALIGN, 1);
+ ConvertIntToDecimalStringN(gStringVar1, numPlayers, STR_CONV_MODE_LEFT_ALIGN, 1);
SetStandardWindowBorderStyle(windowId, 0);
- StringExpandPlaceholders(gStringVar4, gText_XPLink);
+ StringExpandPlaceholders(gStringVar4, gText_NumPlayerLink);
xPos = GetStringCenterAlignXOffset(1, gStringVar4, 88);
AddTextPrinterParameterized(windowId, 1, gStringVar4, xPos, 1, 0xFF, NULL);
CopyWindowToVram(windowId, 3);
}
-static void sub_80B241C(u16 windowId)
+static void ClearLinkPlayerCountWindow(u16 windowId)
{
// Following this call with a copy-to-vram with mode 3 is identical to
// calling ClearStdWindowAndFrame(windowId, TRUE).
@@ -101,68 +112,68 @@ static void sub_80B241C(u16 windowId)
CopyWindowToVram(windowId, 3);
}
-static void sub_80B243C(u8 taskId, u8 arg1)
+static void UpdateLinkPlayerCountDisplay(u8 taskId, u8 numPlayers)
{
s16 *data = gTasks[taskId].data;
- if (arg1 != data[3])
+ if (numPlayers != tNumPlayers)
{
- if (arg1 <= 1)
- sub_80B241C(data[5]);
+ if (numPlayers <= 1)
+ ClearLinkPlayerCountWindow(tWindowId);
else
- sub_80B23B0(data[5], arg1);
- data[3] = arg1;
+ PrintNumPlayersInLink(tWindowId, numPlayers);
+ tNumPlayers = numPlayers;
}
}
-static u32 sub_80B2478(u8 lower, u8 upper)
+static u32 ExchangeDataAndGetLinkupStatus(u8 minPlayers, u8 maxPlayers)
{
int playerCount;
- switch (GetLinkPlayerDataExchangeStatusTimed(lower, upper))
+ switch (GetLinkPlayerDataExchangeStatusTimed(minPlayers, maxPlayers))
{
case EXCHANGE_COMPLETE:
- return 1;
- case EXCHANGE_IN_PROGRESS:
- return 3;
+ return LINKUP_SUCCESS;
+ case EXCHANGE_DIFF_SELECTIONS:
+ return LINKUP_DIFF_SELECTIONS;
case EXCHANGE_PLAYER_NOT_READY:
- return 7;
+ return LINKUP_PLAYER_NOT_READY;
case EXCHANGE_PARTNER_NOT_READY:
- return 9;
- case EXCHANGE_STAT_6:
+ return LINKUP_PARTNER_NOT_READY;
+ case EXCHANGE_WRONG_NUM_PLAYERS:
ConvertIntToDecimalStringN(gStringVar1, GetLinkPlayerCount_2(), STR_CONV_MODE_LEFT_ALIGN, 1);
- return 4;
+ return LINKUP_WRONG_NUM_PLAYERS;
case EXCHANGE_STAT_7:
- return 10;
+ return LINKUP_FAILED_CONTEST_GMODE;
case EXCHANGE_TIMED_OUT:
default:
- return 0;
+ return LINKUP_ONGOING;
}
}
-static bool32 sub_80B24F8(u8 taskId)
+static bool32 CheckLinkErrored(u8 taskId)
{
if (HasLinkErrorOccurred() == TRUE)
{
- gTasks[taskId].func = sub_80B2D2C;
+ gTasks[taskId].func = Task_LinkupConnectionError;
return TRUE;
}
return FALSE;
}
-static bool32 sub_80B252C(u8 taskId)
+static bool32 CheckLinkCanceledBeforeConnection(u8 taskId)
{
if ((gMain.newKeys & B_BUTTON)
&& IsLinkConnectionEstablished() == FALSE)
{
gLinkType = 0;
- gTasks[taskId].func = sub_80B2CEC;
+ gTasks[taskId].func = Task_LinkupFailed;
return TRUE;
}
return FALSE;
}
-static bool32 sub_80B2578(u8 taskId)
+static bool32 CheckLinkCanceled(u8 taskId)
{
if (IsLinkConnectionEstablished())
SetSuppressLinkErrorMessage(TRUE);
@@ -170,7 +181,7 @@ static bool32 sub_80B2578(u8 taskId)
if (gMain.newKeys & B_BUTTON)
{
gLinkType = 0;
- gTasks[taskId].func = sub_80B2CEC;
+ gTasks[taskId].func = Task_LinkupFailed;
return TRUE;
}
return FALSE;
@@ -180,12 +191,13 @@ static bool32 sub_80B25CC(u8 taskId)
{
if (GetSioMultiSI() == 1)
{
- gTasks[taskId].func = sub_80B2D2C;
+ gTasks[taskId].func = Task_LinkupConnectionError;
return TRUE;
}
return FALSE;
}
+// Unused
static void sub_80B2600(u8 taskId)
{
gTasks[taskId].data[0]++;
@@ -196,7 +208,7 @@ static void sub_80B2600(u8 taskId)
}
}
-static void sub_80B2634(u8 taskId)
+static void Task_LinkupStart(u8 taskId)
{
s16 *data = gTasks[taskId].data;
@@ -205,21 +217,21 @@ static void sub_80B2634(u8 taskId)
OpenLinkTimed();
ResetLinkPlayerCount();
ResetLinkPlayers();
- data[5] = AddWindow(&gUnknown_08550594);
+ tWindowId = AddWindow(&sWindowTemplate_LinkPlayerCount);
}
else if (data[0] > 9)
{
- gTasks[taskId].func = sub_80B2688;
+ gTasks[taskId].func = Task_LinkupAwaitConnection;
}
data[0]++;
}
-static void sub_80B2688(u8 taskId)
+static void Task_LinkupAwaitConnection(u8 taskId)
{
u32 playerCount = GetLinkPlayerCount_2();
- if (sub_80B252C(taskId) == TRUE
- || sub_80B2578(taskId) == TRUE
+ if (CheckLinkCanceledBeforeConnection(taskId) == TRUE
+ || CheckLinkCanceled(taskId) == TRUE
|| playerCount < 2)
return;
@@ -229,60 +241,60 @@ static void sub_80B2688(u8 taskId)
{
PlaySE(SE_PIN);
ShowFieldAutoScrollMessage(gText_ConfirmLinkWhenPlayersReady);
- gTasks[taskId].func = sub_80B270C;
+ gTasks[taskId].func = Task_LinkupConfirmWhenReady;
}
else
{
PlaySE(SE_BOO);
ShowFieldAutoScrollMessage(gText_AwaitingLinkup);
- gTasks[taskId].func = sub_80B2918;
+ gTasks[taskId].func = Task_LinkupExchangeDataWithLeader;
}
}
-static void sub_80B270C(u8 taskId)
+static void Task_LinkupConfirmWhenReady(u8 taskId)
{
- if (sub_80B252C(taskId) == TRUE
+ if (CheckLinkCanceledBeforeConnection(taskId) == TRUE
|| sub_80B25CC(taskId) == TRUE
- || sub_80B24F8(taskId) == TRUE)
+ || CheckLinkErrored(taskId) == TRUE)
return;
if (GetFieldMessageBoxMode() == FIELD_MESSAGE_BOX_HIDDEN)
{
- gTasks[taskId].data[3] = 0;
- gTasks[taskId].func = sub_80B275C;
+ gTasks[taskId].tNumPlayers = 0;
+ gTasks[taskId].func = Task_LinkupAwaitConfirmation;
}
}
-static void sub_80B275C(u8 taskId)
+static void Task_LinkupAwaitConfirmation(u8 taskId)
{
s16 *data = gTasks[taskId].data;
s32 linkPlayerCount = GetLinkPlayerCount_2();
- if (sub_80B252C(taskId) == TRUE
+ if (CheckLinkCanceledBeforeConnection(taskId) == TRUE
|| sub_80B25CC(taskId) == TRUE
- || sub_80B24F8(taskId) == TRUE)
+ || CheckLinkErrored(taskId) == TRUE)
return;
- sub_80B243C(taskId, linkPlayerCount);
+ UpdateLinkPlayerCountDisplay(taskId, linkPlayerCount);
if (!(gMain.newKeys & A_BUTTON))
return;
- if (linkPlayerCount < data[1])
+ if (linkPlayerCount < tMinPlayers)
return;
- sub_800AA04(linkPlayerCount);
- sub_80B241C(data[5]);
+ SaveLinkPlayers(linkPlayerCount);
+ ClearLinkPlayerCountWindow(tWindowId);
ConvertIntToDecimalStringN(gStringVar1, linkPlayerCount, STR_CONV_MODE_LEFT_ALIGN, 1);
ShowFieldAutoScrollMessage(gText_ConfirmStartLinkWithXPlayers);
- gTasks[taskId].func = sub_80B2804;
+ gTasks[taskId].func = Task_LinkupTryConfirmation;
}
-static void sub_80B2804(u8 taskId)
+static void Task_LinkupTryConfirmation(u8 taskId)
{
- if (sub_80B252C(taskId) == TRUE
+ if (CheckLinkCanceledBeforeConnection(taskId) == TRUE
|| sub_80B25CC(taskId) == TRUE
- || sub_80B24F8(taskId) == TRUE)
+ || CheckLinkErrored(taskId) == TRUE)
return;
if (GetFieldMessageBoxMode() == FIELD_MESSAGE_BOX_HIDDEN)
@@ -290,213 +302,221 @@ static void sub_80B2804(u8 taskId)
if (GetSavedPlayerCount() != GetLinkPlayerCount_2())
{
ShowFieldAutoScrollMessage(gText_ConfirmLinkWhenPlayersReady);
- gTasks[taskId].func = sub_80B270C;
+ gTasks[taskId].func = Task_LinkupConfirmWhenReady;
}
else if (gMain.heldKeys & B_BUTTON)
{
ShowFieldAutoScrollMessage(gText_ConfirmLinkWhenPlayersReady);
- gTasks[taskId].func = sub_80B270C;
+ gTasks[taskId].func = Task_LinkupConfirmWhenReady;
}
else if (gMain.heldKeys & A_BUTTON)
{
PlaySE(SE_SELECT);
CheckShouldAdvanceLinkState();
- gTasks[taskId].func = sub_80B28A8;
+ gTasks[taskId].func = Task_LinkupConfirm;
}
}
}
-static void sub_80B28A8(u8 taskId)
+static void Task_LinkupConfirm(u8 taskId)
{
- u8 local1 = gTasks[taskId].data[1];
- u8 local2 = gTasks[taskId].data[2];
+ u8 minPlayers = gTasks[taskId].tMinPlayers;
+ u8 maxPlayers = gTasks[taskId].tMaxPlayers;
- if (sub_80B24F8(taskId) == TRUE
- || sub_80B2D6C(taskId) == TRUE)
+ if (CheckLinkErrored(taskId) == TRUE
+ || TryLinkTimeout(taskId) == TRUE)
return;
if (GetLinkPlayerCount_2() != GetSavedPlayerCount())
{
- gTasks[taskId].func = sub_80B2D2C;
+ gTasks[taskId].func = Task_LinkupConnectionError;
}
else
{
- gSpecialVar_Result = sub_80B2478(local1, local2);
- if (gSpecialVar_Result != 0)
- gTasks[taskId].func = sub_80B2A08;
+ gSpecialVar_Result = ExchangeDataAndGetLinkupStatus(minPlayers, maxPlayers);
+ if (gSpecialVar_Result != LINKUP_ONGOING)
+ gTasks[taskId].func = Task_LinkupCheckStatusAfterConfirm;
}
}
-static void sub_80B2918(u8 taskId)
+static void Task_LinkupExchangeDataWithLeader(u8 taskId)
{
- u8 local1, local2;
+ u8 minPlayers, maxPlayers;
struct TrainerCard *card;
- local1 = gTasks[taskId].data[1];
- local2 = gTasks[taskId].data[2];
+ minPlayers = gTasks[taskId].tMinPlayers;
+ maxPlayers = gTasks[taskId].tMaxPlayers;
- if (sub_80B252C(taskId) == TRUE
- || sub_80B24F8(taskId) == TRUE)
+ if (CheckLinkCanceledBeforeConnection(taskId) == TRUE
+ || CheckLinkErrored(taskId) == TRUE)
return;
- gSpecialVar_Result = sub_80B2478(local1, local2);
- if (gSpecialVar_Result == 0)
+ gSpecialVar_Result = ExchangeDataAndGetLinkupStatus(minPlayers, maxPlayers);
+ if (gSpecialVar_Result == LINKUP_ONGOING)
return;
- if (gSpecialVar_Result == 3 || gSpecialVar_Result == 4)
+ if (gSpecialVar_Result == LINKUP_DIFF_SELECTIONS
+ || gSpecialVar_Result == LINKUP_WRONG_NUM_PLAYERS)
{
sub_800AC34();
HideFieldMessageBox();
- gTasks[taskId].func = sub_80B2CB0;
+ gTasks[taskId].func = Task_StopLinkup;
}
- else if (gSpecialVar_Result == 7 || gSpecialVar_Result == 9)
+ else if (gSpecialVar_Result == LINKUP_PLAYER_NOT_READY
+ || gSpecialVar_Result == LINKUP_PARTNER_NOT_READY)
{
CloseLink();
HideFieldMessageBox();
- gTasks[taskId].func = sub_80B2CB0;
+ gTasks[taskId].func = Task_StopLinkup;
}
else
{
gFieldLinkPlayerCount = GetLinkPlayerCount_2();
gLocalLinkPlayerId = GetMultiplayerId();
- sub_800AA04(gFieldLinkPlayerCount);
+ SaveLinkPlayers(gFieldLinkPlayerCount);
card = (struct TrainerCard *)gBlockSendBuffer;
TrainerCard_GenerateCardForPlayer(card);
card->monSpecies[0] = GetMonData(&gPlayerParty[gSelectedOrderFromParty[0] - 1], MON_DATA_SPECIES, NULL);
card->monSpecies[1] = GetMonData(&gPlayerParty[gSelectedOrderFromParty[1] - 1], MON_DATA_SPECIES, NULL);
- gTasks[taskId].func = sub_80B2C30;
+ gTasks[taskId].func = Task_LinkupAwaitTrainerCardData;
}
}
-static void sub_80B2A08(u8 taskId)
+static void Task_LinkupCheckStatusAfterConfirm(u8 taskId)
{
struct TrainerCard *card;
- if (sub_80B24F8(taskId) == TRUE)
+ if (CheckLinkErrored(taskId) == TRUE)
return;
- if (gSpecialVar_Result == 4)
+ if (gSpecialVar_Result == LINKUP_WRONG_NUM_PLAYERS)
{
if (!Link_AnyPartnersPlayingRubyOrSapphire())
{
sub_800AC34();
HideFieldMessageBox();
- gTasks[taskId].func = sub_80B2CB0;
+ gTasks[taskId].func = Task_StopLinkup;
}
else
{
CloseLink();
HideFieldMessageBox();
- gTasks[taskId].func = sub_80B2CB0;
+ gTasks[taskId].func = Task_StopLinkup;
}
}
- else if (gSpecialVar_Result == 3)
+ else if (gSpecialVar_Result == LINKUP_DIFF_SELECTIONS)
{
sub_800AC34();
HideFieldMessageBox();
- gTasks[taskId].func = sub_80B2CB0;
+ gTasks[taskId].func = Task_StopLinkup;
}
- else if (gSpecialVar_Result == 7 || gSpecialVar_Result == 9)
+ else if (gSpecialVar_Result == LINKUP_PLAYER_NOT_READY
+ || gSpecialVar_Result == LINKUP_PARTNER_NOT_READY)
{
CloseLink();
HideFieldMessageBox();
- gTasks[taskId].func = sub_80B2CB0;
+ gTasks[taskId].func = Task_StopLinkup;
}
else
{
gFieldLinkPlayerCount = GetLinkPlayerCount_2();
gLocalLinkPlayerId = GetMultiplayerId();
- sub_800AA04(gFieldLinkPlayerCount);
+ SaveLinkPlayers(gFieldLinkPlayerCount);
card = (struct TrainerCard *)gBlockSendBuffer;
TrainerCard_GenerateCardForPlayer(card);
card->monSpecies[0] = GetMonData(&gPlayerParty[gSelectedOrderFromParty[0] - 1], MON_DATA_SPECIES, NULL);
card->monSpecies[1] = GetMonData(&gPlayerParty[gSelectedOrderFromParty[1] - 1], MON_DATA_SPECIES, NULL);
- gTasks[taskId].func = sub_80B2C30;
+ gTasks[taskId].func = Task_LinkupAwaitTrainerCardData;
sub_800A4D8(2);
}
}
-bool32 sub_80B2AF4(u16 *arg0, u16 *arg1)
+bool32 AreBattleTowerLinkSpeciesSame(u16 *speciesList1, u16 *speciesList2)
{
int i;
int j;
- bool32 result = FALSE;
- int k = 0;
+ bool32 haveSameSpecies = FALSE;
+ int numSameSpecies = 0;
gStringVar1[0] = EOS;
gStringVar2[0] = EOS;
- for (i = 0; i < 2; i++)
+ for (i = 0; i < FRONTIER_MULTI_PARTY_SIZE; i++)
{
- for (j = 0; j < 2; j++)
+ for (j = 0; j < FRONTIER_MULTI_PARTY_SIZE; j++)
{
- if (arg0[i] == arg1[j])
+ if (speciesList1[i] == speciesList2[j])
{
- if (k == 0)
+ if (numSameSpecies == 0)
{
- StringCopy(gStringVar1, gSpeciesNames[arg0[i]]);
- result = TRUE;
+ StringCopy(gStringVar1, gSpeciesNames[speciesList1[i]]);
+ haveSameSpecies = TRUE;
}
- if (k == 1)
+ if (numSameSpecies == 1)
{
- StringCopy(gStringVar2, gSpeciesNames[arg0[i]]);
- result = TRUE;
+ StringCopy(gStringVar2, gSpeciesNames[speciesList1[i]]);
+ haveSameSpecies = TRUE;
}
- k++;
+ numSameSpecies++;
}
}
}
- gSpecialVar_0x8005 = k;
+ // var below is read by BattleFrontier_BattleTowerLobby_EventScript_AbortLink
+ gSpecialVar_0x8005 = numSameSpecies;
- return result;
+ return haveSameSpecies;
}
-static void task_map_chg_seq_0807EC34(u16 *a0, u32 taskId)
+static void FinishLinkup(u16 *linkupStatus, u32 taskId)
{
struct TrainerCard *trainerCards = gTrainerCards;
- if (*a0 == 1)
+ if (*linkupStatus == LINKUP_SUCCESS)
{
if (gLinkType == LINKTYPE_BATTLE_TOWER_50 || gLinkType == LINKTYPE_BATTLE_TOWER_OPEN)
{
- if (sub_80B2AF4(trainerCards[0].monSpecies, trainerCards[1].monSpecies))
+ if (AreBattleTowerLinkSpeciesSame(trainerCards[0].monSpecies, trainerCards[1].monSpecies))
{
- *a0 = 11;
+ // Unsuccessful battle tower linkup
+ *linkupStatus = LINKUP_FAILED_BATTLE_TOWER;
sub_800AC34();
- gTasks[taskId].func = sub_80B2CB0;
+ gTasks[taskId].func = Task_StopLinkup;
}
else
{
- sub_80B241C(gTasks[taskId].data[5]);
+ // Successful battle tower linkup
+ ClearLinkPlayerCountWindow(gTasks[taskId].tWindowId);
EnableBothScriptContexts();
DestroyTask(taskId);
}
}
else
{
- sub_80B241C(gTasks[taskId].data[5]);
+ // Successful linkup
+ ClearLinkPlayerCountWindow(gTasks[taskId].tWindowId);
EnableBothScriptContexts();
DestroyTask(taskId);
}
}
else
{
+ // Unsuccessful linkup
sub_800AC34();
- gTasks[taskId].func = sub_80B2CB0;
+ gTasks[taskId].func = Task_StopLinkup;
}
}
-static void sub_80B2C30(u8 taskId)
+static void Task_LinkupAwaitTrainerCardData(u8 taskId)
{
u8 index;
struct TrainerCard *trainerCards;
- if (sub_80B24F8(taskId) == TRUE)
+ if (CheckLinkErrored(taskId) == TRUE)
return;
- if (GetBlockReceivedStatus() != sub_800A9A8())
+ if (GetBlockReceivedStatus() != GetSavedLinkPlayerCountAsBitFlags())
return;
for (index = 0; index < GetLinkPlayerCount(); index++)
@@ -506,74 +526,74 @@ static void sub_80B2C30(u8 taskId)
SetSuppressLinkErrorMessage(FALSE);
ResetBlockReceivedFlags();
- task_map_chg_seq_0807EC34(&gSpecialVar_Result, taskId);
+ FinishLinkup(&gSpecialVar_Result, taskId);
}
-static void sub_80B2CB0(u8 taskId)
+static void Task_StopLinkup(u8 taskId)
{
- if (gReceivedRemoteLinkPlayers == FALSE)
+ if (!gReceivedRemoteLinkPlayers)
{
- sub_80B241C(gTasks[taskId].data[5]);
+ ClearLinkPlayerCountWindow(gTasks[taskId].tWindowId);
EnableBothScriptContexts();
- RemoveWindow(gTasks[taskId].data[5]);
+ RemoveWindow(gTasks[taskId].tWindowId);
DestroyTask(taskId);
}
}
-static void sub_80B2CEC(u8 taskId)
+static void Task_LinkupFailed(u8 taskId)
{
- gSpecialVar_Result = 5;
- sub_80B241C(gTasks[taskId].data[5]);
+ gSpecialVar_Result = LINKUP_FAILED;
+ ClearLinkPlayerCountWindow(gTasks[taskId].tWindowId);
StopFieldMessage();
- RemoveWindow(gTasks[taskId].data[5]);
+ RemoveWindow(gTasks[taskId].tWindowId);
EnableBothScriptContexts();
DestroyTask(taskId);
}
-static void sub_80B2D2C(u8 taskId)
+static void Task_LinkupConnectionError(u8 taskId)
{
- gSpecialVar_Result = 6;
- sub_80B241C(gTasks[taskId].data[5]);
- RemoveWindow(gTasks[taskId].data[5]);
+ gSpecialVar_Result = LINKUP_CONNECTION_ERROR;
+ ClearLinkPlayerCountWindow(gTasks[taskId].tWindowId);
+ RemoveWindow(gTasks[taskId].tWindowId);
HideFieldMessageBox();
EnableBothScriptContexts();
DestroyTask(taskId);
}
-static bool8 sub_80B2D6C(u8 taskId)
+static bool8 TryLinkTimeout(u8 taskId)
{
- gTasks[taskId].data[4]++;
- if (gTasks[taskId].data[4] > 600)
+ gTasks[taskId].tTimer++;
+ if (gTasks[taskId].tTimer > 600)
{
- gTasks[taskId].func = sub_80B2D2C;
+ gTasks[taskId].func = Task_LinkupConnectionError;
return TRUE;
}
return FALSE;
}
-void TryBattleLinkup(u8 arg0)
+void TryBattleLinkup(void)
{
- u8 r3 = 2;
- u8 r2 = 2;
+ u8 minPlayers = 2;
+ u8 maxPlayers = 2;
switch (gSpecialVar_0x8004)
{
case USING_SINGLE_BATTLE:
- r3 = 2;
+ minPlayers = 2;
gLinkType = LINKTYPE_SINGLE_BATTLE;
break;
case USING_DOUBLE_BATTLE:
- r3 = 2;
+ minPlayers = 2;
gLinkType = LINKTYPE_DOUBLE_BATTLE;
break;
case USING_MULTI_BATTLE:
- r3 = 4;
- r2 = 4;
+ minPlayers = 4;
+ maxPlayers = 4;
gLinkType = LINKTYPE_MULTI_BATTLE;
break;
case USING_BATTLE_TOWER:
- r3 = 2;
+ minPlayers = 2;
if (gSaveBlock2Ptr->frontier.lvlMode == FRONTIER_LVL_50)
gLinkType = LINKTYPE_BATTLE_TOWER_50;
else
@@ -582,46 +602,52 @@ void TryBattleLinkup(u8 arg0)
break;
}
- sub_80B236C(r3, r2);
+ CreateLinkupTask(minPlayers, maxPlayers);
}
+#undef tMinPlayers
+#undef tMaxPlayers
+#undef tNumPlayers
+#undef tTimer
+#undef tWindowId
+
void TryTradeLinkup(void)
{
- gLinkType = LINKTYPE_0x1133;
+ gLinkType = LINKTYPE_TRADE_SETUP;
gBattleTypeFlags = 0;
- sub_80B236C(2, 2);
+ CreateLinkupTask(2, 2);
}
void TryRecordMixLinkup(void)
{
- gSpecialVar_Result = 0;
- gLinkType = LINKTYPE_0x3311;
+ gSpecialVar_Result = LINKUP_ONGOING;
+ gLinkType = LINKTYPE_RECORD_MIX_BEFORE;
gBattleTypeFlags = 0;
- sub_80B236C(2, 4);
+ CreateLinkupTask(2, 4);
}
-void sub_80B2EA8(void)
+void ValidateMixingGameLanguage(void)
{
- u32 taskId = FindTaskIdByFunc(sub_80B2EE4);
+ u32 taskId = FindTaskIdByFunc(Task_ValidateMixingGameLanguage);
if (taskId == 0xFF)
{
- taskId = CreateTask(sub_80B2EE4, 80);
- gTasks[taskId].data[0] = 0;
+ taskId = CreateTask(Task_ValidateMixingGameLanguage, 80);
+ gTasks[taskId].tState = 0;
}
}
-static void sub_80B2EE4(u8 taskId)
+static void Task_ValidateMixingGameLanguage(u8 taskId)
{
int playerCount;
int i;
- switch (gTasks[taskId].data[0])
+ switch (gTasks[taskId].tState)
{
case 0:
- if (gSpecialVar_Result == 1)
+ if (gSpecialVar_Result == LINKUP_SUCCESS)
{
- bool32 unk = FALSE;
+ bool32 mixingForeignGames = FALSE;
bool32 isEnglishRSLinked = FALSE;
bool32 isJapaneseEmeraldLinked = FALSE;
@@ -635,7 +661,7 @@ static void sub_80B2EE4(u8 taskId)
{
if (language == LANGUAGE_JAPANESE)
{
- unk = TRUE;
+ mixingForeignGames = TRUE;
break;
}
else
@@ -654,14 +680,14 @@ static void sub_80B2EE4(u8 taskId)
if (isEnglishRSLinked && isJapaneseEmeraldLinked)
{
- unk = TRUE;
+ mixingForeignGames = TRUE;
}
- if (unk)
+ if (mixingForeignGames)
{
- gSpecialVar_Result = 12;
+ gSpecialVar_Result = LINKUP_FOREIGN_GAME;
sub_800AD10();
- gTasks[taskId].data[0] = 1;
+ gTasks[taskId].tState = 1;
return;
}
}
@@ -669,7 +695,7 @@ static void sub_80B2EE4(u8 taskId)
DestroyTask(taskId);
break;
case 1:
- if (gReceivedRemoteLinkPlayers == FALSE)
+ if (!gReceivedRemoteLinkPlayers)
{
EnableBothScriptContexts();
DestroyTask(taskId);
@@ -682,26 +708,26 @@ void TryBerryBlenderLinkup(void)
{
gLinkType = LINKTYPE_BERRY_BLENDER_SETUP;
gBattleTypeFlags = 0;
- sub_80B236C(2, 4);
+ CreateLinkupTask(2, 4);
}
void TryContestGModeLinkup(void)
{
gLinkType = LINKTYPE_CONTEST_GMODE;
gBattleTypeFlags = 0;
- sub_80B236C(4, 4);
+ CreateLinkupTask(4, 4);
}
void TryContestEModeLinkup(void)
{
gLinkType = LINKTYPE_CONTEST_EMODE;
gBattleTypeFlags = 0;
- sub_80B236C(2, 4);
+ CreateLinkupTask(2, 4);
}
-u8 sub_80B3050(void)
+u8 CreateTask_ReestablishCableClubLink(void)
{
- if (FuncIsActiveTask(sub_80B3144) != FALSE)
+ if (FuncIsActiveTask(Task_ReestablishLink) != FALSE)
return 0xFF;
switch (gSpecialVar_0x8004)
@@ -717,26 +743,22 @@ u8 sub_80B3050(void)
break;
case USING_BATTLE_TOWER:
if (gSaveBlock2Ptr->frontier.lvlMode == FRONTIER_LVL_50)
- {
gLinkType = LINKTYPE_BATTLE_TOWER_50;
- }
else
- {
gLinkType = LINKTYPE_BATTLE_TOWER_OPEN;
- }
break;
case USING_TRADE_CENTER:
- gLinkType = LINKTYPE_0x1111;
+ gLinkType = LINKTYPE_TRADE;
break;
case USING_RECORD_CORNER:
- gLinkType = LINKTYPE_0x3322;
+ gLinkType = LINKTYPE_RECORD_MIX_AFTER;
break;
}
- return CreateTask(sub_80B3144, 80);
+ return CreateTask(Task_ReestablishLink, 80);
}
-static void sub_80B3144(u8 taskId)
+static void Task_ReestablishLink(u8 taskId)
{
s16 *data = gTasks[taskId].data;
@@ -744,42 +766,42 @@ static void sub_80B3144(u8 taskId)
{
OpenLink();
ResetLinkPlayers();
- CreateTask(task00_08081A90, 80);
+ CreateTask(Task_WaitForLinkPlayerConnection, 80);
}
else if (data[0] >= 10)
{
- gTasks[taskId].func = sub_80B3194;
+ gTasks[taskId].func = Task_ReestablishLinkAwaitConnection;
}
data[0]++;
}
-static void sub_80B3194(u8 taskId)
+static void Task_ReestablishLinkAwaitConnection(u8 taskId)
{
if (GetLinkPlayerCount_2() >= 2)
{
if (IsLinkMaster() == TRUE)
- gTasks[taskId].func = sub_80B31E8;
+ gTasks[taskId].func = Task_ReestablishLinkLeader;
else
- gTasks[taskId].func = sub_80B3220;
+ gTasks[taskId].func = Task_ReestablishLinkAwaitConfirmation;
}
}
-static void sub_80B31E8(u8 taskId)
+static void Task_ReestablishLinkLeader(u8 taskId)
{
if (GetSavedPlayerCount() == GetLinkPlayerCount_2())
{
CheckShouldAdvanceLinkState();
- gTasks[taskId].func = sub_80B3220;
+ gTasks[taskId].func = Task_ReestablishLinkAwaitConfirmation;
}
}
-static void sub_80B3220(u8 taskId)
+static void Task_ReestablishLinkAwaitConfirmation(u8 taskId)
{
if (gReceivedRemoteLinkPlayers == TRUE
&& IsLinkPlayerDataExchangeComplete() == TRUE)
{
- sub_800AB18();
- sub_8009F18();
+ CheckLinkPlayersMatchSaved();
+ StartSendingKeysToLink();
DestroyTask(taskId);
}
}
@@ -794,50 +816,52 @@ static void SetLinkBattleTypeFlags(int linkService)
{
switch (linkService)
{
- case USING_SINGLE_BATTLE:
- gBattleTypeFlags = BATTLE_TYPE_LINK | BATTLE_TYPE_TRAINER;
- break;
- case USING_DOUBLE_BATTLE:
- gBattleTypeFlags = BATTLE_TYPE_DOUBLE | BATTLE_TYPE_LINK | BATTLE_TYPE_TRAINER;
- break;
- case USING_MULTI_BATTLE:
- ReducePlayerPartyToSelectedMons();
- gBattleTypeFlags = BATTLE_TYPE_DOUBLE | BATTLE_TYPE_LINK | BATTLE_TYPE_TRAINER | BATTLE_TYPE_MULTI;
- break;
- case USING_BATTLE_TOWER:
- gBattleTypeFlags = BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOUBLE | BATTLE_TYPE_LINK | BATTLE_TYPE_TRAINER | BATTLE_TYPE_MULTI;
- break;
+ case USING_SINGLE_BATTLE:
+ gBattleTypeFlags = BATTLE_TYPE_LINK | BATTLE_TYPE_TRAINER;
+ break;
+ case USING_DOUBLE_BATTLE:
+ gBattleTypeFlags = BATTLE_TYPE_DOUBLE | BATTLE_TYPE_LINK | BATTLE_TYPE_TRAINER;
+ break;
+ case USING_MULTI_BATTLE:
+ ReducePlayerPartyToSelectedMons();
+ gBattleTypeFlags = BATTLE_TYPE_DOUBLE | BATTLE_TYPE_LINK | BATTLE_TYPE_TRAINER | BATTLE_TYPE_MULTI;
+ break;
+ case USING_BATTLE_TOWER:
+ gBattleTypeFlags = BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOUBLE | BATTLE_TYPE_LINK | BATTLE_TYPE_TRAINER | BATTLE_TYPE_MULTI;
+ break;
}
}
-static void sub_80B32B4(u8 taskId)
+#define tTimer data[1]
+
+static void Task_StartWiredCableClubBattle(u8 taskId)
{
struct Task* task = &gTasks[taskId];
- switch (task->data[0])
+ switch (task->tState)
{
case 0:
FadeScreen(FADE_TO_BLACK, 0);
gLinkType = LINKTYPE_BATTLE;
ClearLinkCallback_2();
- task->data[0]++;
+ task->tState++;
break;
case 1:
if (!gPaletteFade.active)
- task->data[0]++;
+ task->tState++;
break;
case 2:
- task->data[1]++;
- if (task->data[1] > 20)
- task->data[0]++;
+ task->tTimer++;
+ if (task->tTimer > 20)
+ task->tState++;
break;
case 3:
sub_800AC34();
- task->data[0]++;
+ task->tState++;
break;
case 4:
if (!gReceivedRemoteLinkPlayers)
- task->data[0]++;
+ task->tState++;
break;
case 5:
if (gLinkPlayers[0].trainerId & 1)
@@ -847,37 +871,37 @@ static void sub_80B32B4(u8 taskId)
SetLinkBattleTypeFlags(gSpecialVar_0x8004);
CleanupOverworldWindowsAndTilemaps();
- gTrainerBattleOpponent_A = 0x800;
+ gTrainerBattleOpponent_A = TRAINER_LINK_OPPONENT;
SetMainCallback2(CB2_InitBattle);
- gMain.savedCallback = sub_80B360C;
+ gMain.savedCallback = CB2_ReturnFromCableClubBattle;
DestroyTask(taskId);
break;
}
}
-static void sub_80B33BC(u8 taskId)
+static void Task_StartWirelessCableClubBattle(u8 taskId)
{
int i;
s16* data = gTasks[taskId].data;
- switch (data[0])
+ switch (tState)
{
case 0:
FadeScreen(FADE_TO_BLACK, 0);
gLinkType = LINKTYPE_BATTLE;
ClearLinkCallback_2();
- data[0] = 1;
+ tState = 1;
break;
case 1:
if (!gPaletteFade.active)
- data[0] = 2;
+ tState = 2;
break;
case 2:
SendBlock(0, &gLocalLinkPlayer, sizeof(gLocalLinkPlayer));
- data[0] = 3;
+ tState = 3;
break;
case 3:
- if (GetBlockReceivedStatus() == sub_800A9D8())
+ if (GetBlockReceivedStatus() == GetLinkPlayerCountAsBitFlags())
{
for (i = 0; i < GetLinkPlayerCount(); i++)
{
@@ -886,22 +910,22 @@ static void sub_80B33BC(u8 taskId)
sub_800B524(&gLinkPlayers[i]);
ResetBlockReceivedFlag(i);
}
- data[0] = 4;
+ tState = 4;
}
break;
case 4:
- data[1]++;
- if (data[1] > 20)
- data[0] = 5;
+ tTimer++;
+ if (tTimer > 20)
+ tState = 5;
break;
case 5:
sub_800ADF8();
- data[0] = 6;
+ tState = 6;
break;
case 6:
if (IsLinkTaskFinished())
{
- data[0] = 7;
+ tState = 7;
}
break;
case 7:
@@ -913,59 +937,61 @@ static void sub_80B33BC(u8 taskId)
gLinkPlayers[0].linkType = LINKTYPE_BATTLE;
SetLinkBattleTypeFlags(gSpecialVar_0x8004);
CleanupOverworldWindowsAndTilemaps();
- gTrainerBattleOpponent_A = 0x800;
+ gTrainerBattleOpponent_A = TRAINER_LINK_OPPONENT;
SetMainCallback2(CB2_InitBattle);
- gMain.savedCallback = sub_80B360C;
+ gMain.savedCallback = CB2_ReturnFromCableClubBattle;
DestroyTask(taskId);
break;
}
}
-static void sub_80B3554(void)
+#undef tTimer
+
+static void CB2_ReturnFromUnionRoomBattle(void)
{
u8 playerCount;
int i;
- bool32 r4;
+ bool32 linkedWithFRLG;
switch (gMain.state)
{
- case 0:
- playerCount = GetLinkPlayerCount();
- r4 = FALSE;
- for (i = 0; i < playerCount; i++)
+ case 0:
+ playerCount = GetLinkPlayerCount();
+ linkedWithFRLG = FALSE;
+ for (i = 0; i < playerCount; i++)
+ {
+ u32 version = (u8)gLinkPlayers[i].version;
+ if (version == VERSION_FIRE_RED || version == VERSION_LEAF_GREEN)
{
- u32 version = (u8)gLinkPlayers[i].version;
- if (version == VERSION_FIRE_RED || version == VERSION_LEAF_GREEN)
- {
- r4 = TRUE;
- break;
- }
+ linkedWithFRLG = TRUE;
+ break;
}
+ }
- if (r4)
- {
- gMain.state = 2;
- }
- else
- {
- sub_800AC34();
- gMain.state = 1;
- }
- break;
- case 1:
- if (gReceivedRemoteLinkPlayers == FALSE)
- {
- SetMainCallback2(CB2_ReturnToField);
- }
- break;
- case 2:
+ if (linkedWithFRLG)
+ {
+ gMain.state = 2;
+ }
+ else
+ {
+ sub_800AC34();
+ gMain.state = 1;
+ }
+ break;
+ case 1:
+ if (!gReceivedRemoteLinkPlayers)
+ {
SetMainCallback2(CB2_ReturnToField);
- break;
+ }
+ break;
+ case 2:
+ SetMainCallback2(CB2_ReturnToField);
+ break;
}
RunTasks();
}
-void sub_80B360C(void)
+void CB2_ReturnFromCableClubBattle(void)
{
gBattleTypeFlags &= ~BATTLE_TYPE_20;
Overworld_ResetMapMusic();
@@ -980,26 +1006,22 @@ void sub_80B360C(void)
{
switch (gBattleOutcome)
{
- case B_OUTCOME_WON:
- sub_801B990(0, gLinkPlayers[GetMultiplayerId() ^ 1].trainerId);
- break;
- case B_OUTCOME_LOST:
- sub_801B990(1, gLinkPlayers[GetMultiplayerId() ^ 1].trainerId);
- break;
+ case B_OUTCOME_WON:
+ RecordIdOfWonderCardSenderByEventType(0, gLinkPlayers[GetMultiplayerId() ^ 1].trainerId);
+ break;
+ case B_OUTCOME_LOST:
+ RecordIdOfWonderCardSenderByEventType(1, gLinkPlayers[GetMultiplayerId() ^ 1].trainerId);
+ break;
}
}
}
if (InUnionRoom() == TRUE)
- {
- gMain.savedCallback = sub_80B3554;
- }
+ gMain.savedCallback = CB2_ReturnFromUnionRoomBattle;
else
- {
gMain.savedCallback = CB2_ReturnToFieldFromMultiplayer;
- }
- SetMainCallback2(sub_80A0514);
+ SetMainCallback2(CB2_SetUpSaveAfterLinkBattle);
}
void CleanupLinkRoomState(void)
@@ -1020,22 +1042,23 @@ void ExitLinkRoom(void)
QueueExitLinkRoomKey();
}
-static void sub_80B3728(u8 taskId)
+// Note: gSpecialVar_0x8005 contains the id of the seat the player entered
+static void Task_EnterCableClubSeat(u8 taskId)
{
struct Task* task = &gTasks[taskId];
- switch (task->data[0])
+ switch (task->tState)
{
case 0:
ShowFieldMessage(gText_PleaseWaitForLink);
- task->data[0] = 1;
+ task->tState = 1;
break;
case 1:
if (IsFieldMessageBoxHidden())
{
sub_8087288();
SetLocalLinkPlayerId(gSpecialVar_0x8005);
- task->data[0] = 2;
+ task->tState = 2;
}
break;
case 2:
@@ -1045,12 +1068,12 @@ static void sub_80B3728(u8 taskId)
break;
case 1:
HideFieldMessageBox();
- task->data[0] = 0;
+ task->tState = 0;
sub_80872C4();
SwitchTaskToFollowupFunc(taskId);
break;
case 2:
- task->data[0] = 3;
+ task->tState = 3;
break;
}
break;
@@ -1063,35 +1086,35 @@ static void sub_80B3728(u8 taskId)
}
}
-void sub_80B37D4(TaskFunc followupFunc)
+void CreateTask_EnterCableClubSeat(TaskFunc followupFunc)
{
- u8 taskId = CreateTask(sub_80B3728, 80);
- SetTaskFuncWithFollowupFunc(taskId, sub_80B3728, followupFunc);
+ u8 taskId = CreateTask(Task_EnterCableClubSeat, 80);
+ SetTaskFuncWithFollowupFunc(taskId, Task_EnterCableClubSeat, followupFunc);
ScriptContext1_Stop();
}
-static void sub_80B37FC(u8 taskId)
+static void Task_StartWiredTrade(u8 taskId)
{
struct Task *task = &gTasks[taskId];
- switch (task->data[0])
+ switch (task->tState)
{
case 0:
ScriptContext2_Enable();
FadeScreen(FADE_TO_BLACK, 0);
ClearLinkCallback_2();
- task->data[0]++;
+ task->tState++;
break;
case 1:
if (!gPaletteFade.active)
- task->data[0]++;
+ task->tState++;
break;
case 2:
gSelectedTradeMonPositions[TRADE_PLAYER] = 0;
gSelectedTradeMonPositions[TRADE_PARTNER] = 0;
m4aMPlayAllStop();
sub_800AC34();
- task->data[0]++;
+ task->tState++;
break;
case 3:
if (!gReceivedRemoteLinkPlayers)
@@ -1103,55 +1126,51 @@ static void sub_80B37FC(u8 taskId)
}
}
-static void sub_80B3894(u8 taskId)
+static void Task_StartWirelessTrade(u8 taskId)
{
s16 *data = gTasks[taskId].data;
- switch (data[0])
+ switch (tState)
{
case 0:
ScriptContext2_Enable();
FadeScreen(FADE_TO_BLACK, 0);
ClearLinkRfuCallback();
- data[0]++;
+ tState++;
break;
case 1:
if (!gPaletteFade.active)
- data[0]++;
+ tState++;
break;
case 2:
gSelectedTradeMonPositions[TRADE_PLAYER] = 0;
gSelectedTradeMonPositions[TRADE_PARTNER] = 0;
m4aMPlayAllStop();
sub_800ADF8();
- data[0]++;
+ tState++;
break;
case 3:
if (IsLinkTaskFinished())
{
- sub_8013F78();
+ CreateTask_CreateTradeMenu();
DestroyTask(taskId);
}
break;
}
}
-// Note: VAR_0x8005 is set to the ID of the trade seat.
void PlayerEnteredTradeSeat(void)
{
if (gWirelessCommType != 0)
- {
- sub_80B37D4(sub_80B3894);
- }
+ CreateTask_EnterCableClubSeat(Task_StartWirelessTrade);
else
- {
- sub_80B37D4(sub_80B37FC);
- }
+ CreateTask_EnterCableClubSeat(Task_StartWiredTrade);
}
-static void sub_80B3950(void)
+// Unused
+static void CreateTask_StartWiredTrade(void)
{
- CreateTask(sub_80B37FC, 80);
+ CreateTask(Task_StartWiredTrade, 80);
}
void nullsub_37(void)
@@ -1159,25 +1178,20 @@ void nullsub_37(void)
}
-// Note: VAR_0x8005 is set to the ID of the player spot.
void ColosseumPlayerSpotTriggered(void)
{
gLinkType = LINKTYPE_BATTLE;
- if (gWirelessCommType != 0)
- {
- sub_80B37D4(sub_80B33BC);
- }
+ if (gWirelessCommType)
+ CreateTask_EnterCableClubSeat(Task_StartWirelessCableClubBattle);
else
- {
- sub_80B37D4(sub_80B32B4);
- }
+ CreateTask_EnterCableClubSeat(Task_StartWiredCableClubBattle);
}
-// This function is never called.
-static void sub_80B39A4(void)
+// Unused
+static void CreateTask_EnterCableClubSeatNoFollowup(void)
{
- u8 taskId = CreateTask(sub_80B3728, 80);
+ u8 taskId = CreateTask(Task_EnterCableClubSeat, 80);
ScriptContext1_Stop();
}
@@ -1199,16 +1213,18 @@ bool32 GetLinkTrainerCardColor(u8 linkPlayerIndex)
if (numStars == 0)
return FALSE;
- StringCopy(gStringVar2, gTrainerCardColorNames[numStars - 1]);
+ StringCopy(gStringVar2, sTrainerCardColorNames[numStars - 1]);
return TRUE;
}
-void task00_08081A90(u8 taskId)
+#define tTimer data[0]
+
+void Task_WaitForLinkPlayerConnection(u8 taskId)
{
struct Task *task = &gTasks[taskId];
- task->data[0]++;
- if (task->data[0] > 300)
+ task->tTimer++;
+ if (task->tTimer > 300)
{
CloseLink();
SetMainCallback2(CB2_LinkError);
@@ -1217,9 +1233,10 @@ void task00_08081A90(u8 taskId)
if (gReceivedRemoteLinkPlayers)
{
+ // Players connected, destroy task
if (gWirelessCommType == 0)
{
- if (!sub_800AA60())
+ if (!DoesLinkPlayerCountMatchSaved())
{
CloseLink();
SetMainCallback2(CB2_LinkError);
@@ -1233,6 +1250,8 @@ void task00_08081A90(u8 taskId)
}
}
+#undef tTimer
+
static void sub_80B3AAC(u8 taskId)
{
if (!gReceivedRemoteLinkPlayers)
@@ -1242,67 +1261,72 @@ static void sub_80B3AAC(u8 taskId)
}
}
+// Unused
static void sub_80B3AD0(u8 taskId)
{
sub_800AC34();
gTasks[taskId].func = sub_80B3AAC;
}
+#define tTimer data[1]
+
void sub_80B3AF8(u8 taskId)
{
s16 *data = gTasks[taskId].data;
- switch (data[0])
+ switch (tState)
{
- case 0:
- if (gWirelessCommType != 0)
- {
- DestroyTask(taskId);
- }
- else
- {
- OpenLink();
- CreateTask(task00_08081A90, 1);
- data[0]++;
- }
- break;
- case 1:
- if (++data[1] > 11)
- {
- data[1] = 0;
- data[0]++;
- }
- break;
- case 2:
- if (GetLinkPlayerCount_2() >= GetSavedPlayerCount())
+ case 0:
+ if (gWirelessCommType != 0)
+ {
+ DestroyTask(taskId);
+ }
+ else
+ {
+ OpenLink();
+ CreateTask(Task_WaitForLinkPlayerConnection, 1);
+ tState++;
+ }
+ break;
+ case 1:
+ if (++tTimer > 11)
+ {
+ tTimer = 0;
+ tState++;
+ }
+ break;
+ case 2:
+ if (GetLinkPlayerCount_2() >= GetSavedPlayerCount())
+ {
+ if (IsLinkMaster())
{
- if (IsLinkMaster())
- {
- if (++data[1] > 30)
- {
- CheckShouldAdvanceLinkState();
- data[0]++;
- }
- }
- else
+ if (++tTimer > 30)
{
- data[0]++;
+ CheckShouldAdvanceLinkState();
+ tState++;
}
}
- break;
- case 3:
- if (gReceivedRemoteLinkPlayers == TRUE && IsLinkPlayerDataExchangeComplete() == TRUE)
+ else
{
- DestroyTask(taskId);
+ tState++;
}
- break;
+ }
+ break;
+ case 3:
+ if (gReceivedRemoteLinkPlayers == TRUE && IsLinkPlayerDataExchangeComplete() == TRUE)
+ {
+ DestroyTask(taskId);
+ }
+ break;
}
}
+#undef tTimer
+
void TrySetBattleTowerLinkType(void)
{
if (gWirelessCommType == 0)
- {
gLinkType = LINKTYPE_BATTLE_TOWER;
- }
}
+
+#undef tState
diff --git a/src/confetti_util.c b/src/confetti_util.c
new file mode 100644
index 000000000..3bda3ab53
--- /dev/null
+++ b/src/confetti_util.c
@@ -0,0 +1,218 @@
+#include "global.h"
+#include "confetti_util.h"
+#include "malloc.h"
+#include "main.h"
+#include "digit_obj_util.h"
+
+static EWRAM_DATA struct
+{
+ u8 count;
+ struct ConfettiUtil *array;
+} *sWork = NULL;
+
+static void sub_81520A8(void *dest, u16 value, u8 left, u8 top, u8 width, u8 height) // Unused.
+{
+ u8 i;
+ u8 j;
+ u8 x;
+ u8 y;
+
+ for (i = 0, y = top; i < height; i++)
+ {
+ for (x = left, j = 0; j < width; j++)
+ {
+ *(u16 *)((dest) + (y * 64 + x * 2)) = value;
+ x = (x + 1) % 32;
+ }
+ y = (y + 1) % 32;
+ }
+}
+
+static void sub_8152134(void *dest, const u16 *src, u8 left, u8 top, u8 width, u8 height) // Unused.
+{
+ u8 i;
+ u8 j;
+ u8 x;
+ u8 y;
+ const u16 *_src;
+
+ for (i = 0, _src = src, y = top; i < height; i++)
+ {
+ for (x = left, j = 0; j < width; j++)
+ {
+ *(u16 *)((dest) + (y * 64 + x * 2)) = *(_src++);
+ x = (x + 1) % 32;
+ }
+ y = (y + 1) % 32;
+ }
+}
+
+bool32 ConfettiUtil_Init(u8 count)
+{
+ u8 i = 0;
+
+ if (count == 0)
+ return FALSE;
+ if (count > 64)
+ count = 64;
+
+ sWork = AllocZeroed(sizeof(*sWork));
+ if (sWork == NULL)
+ return FALSE;
+ sWork->array = AllocZeroed(count * sizeof(struct ConfettiUtil));
+ if (sWork->array == NULL)
+ {
+ FREE_AND_SET_NULL(sWork);
+ return FALSE;
+ }
+
+ sWork->count = count;
+ for (i = 0; i < count; i++)
+ {
+ memcpy(&sWork->array[i].oam, &gDummyOamData, sizeof(struct OamData));
+ sWork->array[i].dummied = TRUE;
+ }
+
+ return TRUE;
+}
+
+bool32 ConfettiUtil_Free(void)
+{
+ u8 i = 0;
+
+ if (sWork == NULL)
+ return FALSE;
+
+ for (i = 0; i < sWork->count; i++)
+ memcpy(&gMain.oamBuffer[i + 64], &gDummyOamData, sizeof(struct OamData));
+
+ memset(sWork->array, 0, sWork->count * sizeof(struct ConfettiUtil));
+ FREE_AND_SET_NULL(sWork->array);
+ memset(sWork, 0, sizeof(*sWork));
+ FREE_AND_SET_NULL(sWork);
+
+ return TRUE;
+}
+
+bool32 ConfettiUtil_Update(void)
+{
+ u8 i = 0;
+
+ if (sWork == NULL || sWork->array == NULL)
+ return FALSE;
+
+ for (i = 0; i < sWork->count; i++)
+ {
+ if (sWork->array[i].active && sWork->array[i].allowUpdates)
+ {
+ if (sWork->array[i].callback != NULL)
+ sWork->array[i].callback(&sWork->array[i]);
+
+ if (sWork->array[i].dummied)
+ {
+ memcpy(&gMain.oamBuffer[i + 64], &gDummyOamData, sizeof(struct OamData));
+ }
+ else
+ {
+ sWork->array[i].oam.y = sWork->array[i].y + sWork->array[i].yDelta;
+ sWork->array[i].oam.x = sWork->array[i].x + sWork->array[i].xDelta;
+ sWork->array[i].oam.priority = sWork->array[i].priority;
+ sWork->array[i].oam.tileNum = sWork->array[i].tileNum;
+ memcpy(&gMain.oamBuffer[i + 64], &sWork->array[i], sizeof(struct OamData));
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+static bool32 SetAnimAndTileNum(struct ConfettiUtil *structPtr, u8 animNum)
+{
+ u16 tileStart;
+
+ if (structPtr == NULL)
+ return FALSE;
+
+ tileStart = GetSpriteTileStartByTag(structPtr->tileTag);
+ if (tileStart == 0xFFFF)
+ return FALSE;
+
+ structPtr->animNum = animNum;
+ structPtr->tileNum = (GetTilesPerImage(structPtr->oam.shape, structPtr->oam.size) * animNum) + tileStart;
+ return TRUE;
+}
+
+u8 ConfettiUtil_SetCallback(u8 id, void (*func)(struct ConfettiUtil *))
+{
+ if (sWork == NULL || id >= sWork->count)
+ return 0xFF;
+ else if (!sWork->array[id].active)
+ return 0xFF;
+
+ sWork->array[id].callback = func;
+ return id;
+}
+
+u8 ConfettiUtil_SetData(u8 id, u8 dataArrayId, s16 dataValue)
+{
+ if (sWork == NULL || id >= sWork->count)
+ return 0xFF;
+ else if (!sWork->array[id].active || dataArrayId > ARRAY_COUNT(sWork->array[id].data) - 1) // - 1 b/c last slot is reserved for taskId
+ return 0xFF;
+
+ sWork->array[id].data[dataArrayId] = dataValue;
+ return id;
+}
+
+u8 ConfettiUtil_AddNew(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16 y, u8 animNum, u8 priority)
+{
+ struct ConfettiUtil *structPtr = NULL;
+ u8 i;
+
+ if (sWork == NULL || oam == NULL)
+ return 0xFF;
+
+ for (i = 0; i < sWork->count; i++)
+ {
+ if (!sWork->array[i].active)
+ {
+ structPtr = &sWork->array[i];
+ memset(structPtr, 0, sizeof(*structPtr));
+ structPtr->id = i;
+ structPtr->active = TRUE;
+ structPtr->allowUpdates = TRUE;
+ break;
+ }
+ }
+
+ if (structPtr == NULL)
+ return 0xFF;
+
+ memcpy(&structPtr->oam, oam, sizeof(*oam));
+ structPtr->tileTag = tileTag;
+ structPtr->palTag = palTag;
+ structPtr->x = x;
+ structPtr->y = y;
+ structPtr->oam.paletteNum = IndexOfSpritePaletteTag(palTag);
+ if (priority < 4)
+ {
+ structPtr->priority = priority;
+ structPtr->oam.priority = priority;
+ }
+ SetAnimAndTileNum(structPtr, animNum);
+
+ return structPtr->id;
+}
+
+u8 ConfettiUtil_Remove(u8 id)
+{
+ if (sWork == NULL || !sWork->array[id].active)
+ return 0xFF;
+
+ memset(&sWork->array[id], 0, sizeof(struct ConfettiUtil));
+ sWork->array[id].oam.y = 160;
+ sWork->array[id].oam.x = 240;
+ sWork->array[id].dummied = TRUE;
+ memcpy(&gMain.oamBuffer[id + 64], &gDummyOamData, sizeof(struct OamData));
+ return id;
+}
diff --git a/src/contest.c b/src/contest.c
index 58628e35d..314ebb381 100644
--- a/src/contest.c
+++ b/src/contest.c
@@ -31,14 +31,14 @@
#include "tv.h"
#include "scanline_effect.h"
#include "util.h"
-#include "contest_link_80F57C4.h"
+#include "contest_util.h"
#include "dma3.h"
#include "battle_message.h"
#include "event_scripts.h"
#include "event_data.h"
#include "strings.h"
#include "contest_effect.h"
-#include "contest_link_80FC4F4.h"
+#include "contest_link.h"
#include "script_pokemon_util_80F87D8.h"
#include "international_string_util.h"
#include "data.h"
@@ -155,7 +155,7 @@ static void Contest_StartTextPrinter(const u8 *, u32);
static void ContestBG_FillBoxWithIncrementingTile(u8, u16, u8, u8, u8, u8, u8, s16);
static bool32 Contest_RunTextPrinters(void);
static void Contest_SetBgCopyFlags(u32 flagIndex);
-static void sub_80DBD18(void);
+static void CalculateFinalScores(void);
static void sub_80DD080(u8);
static void sub_80DE9DC(u8);
static void sub_80DCBE8(u8, u8);
@@ -184,7 +184,7 @@ static void sub_80DC3AC(void);
static bool8 sub_80DC3C4(void);
static void ContestBG_FillBoxWithTile(u8, u16, u8, u8, u8, u8, u8);
static void Contest_PrintTextToBg0WindowStd(u32, const u8 *);
-static s16 sub_80DBD34(u8);
+static s16 GetContestantRound2Points(u8);
static void DetermineFinalStandings(void);
static bool8 sub_80DBF30(s32, s32, struct UnknownContestStruct6 *);
static void sub_80DC0F4(u8);
@@ -221,9 +221,9 @@ static void SwapMoveDescAndContestTilemaps(void);
// EWRAM vars.
EWRAM_DATA struct ContestPokemon gContestMons[CONTESTANT_COUNT] = {0};
EWRAM_DATA s16 gContestMonConditions[CONTESTANT_COUNT] = {0};
-EWRAM_DATA s16 gUnknown_02039F08[CONTESTANT_COUNT] = {0};
+EWRAM_DATA s16 gContestMonTotalPoints[CONTESTANT_COUNT] = {0};
EWRAM_DATA s16 gUnknown_02039F10[CONTESTANT_COUNT] = {0};
-EWRAM_DATA s16 gUnknown_02039F18[CONTESTANT_COUNT] = {0};
+EWRAM_DATA s16 gContestMonRound2Points[CONTESTANT_COUNT] = {0};
EWRAM_DATA u8 gContestFinalStandings[CONTESTANT_COUNT] = {0};
EWRAM_DATA u8 gContestMonPartyIndex = 0;
EWRAM_DATA u8 gContestPlayerMonIndex = 0;
@@ -239,7 +239,7 @@ EWRAM_DATA u8 gHighestRibbonRank = 0;
EWRAM_DATA struct ContestResources *gContestResources = NULL;
EWRAM_DATA u8 sContestBgCopyFlags = 0;
EWRAM_DATA struct ContestWinner gCurContestWinner = {0};
-EWRAM_DATA u8 gUnknown_02039F5C = 0;
+EWRAM_DATA bool8 gUnknown_02039F5C = 0;
EWRAM_DATA u8 gUnknown_02039F5D = 0;
// IWRAM common vars.
@@ -2490,7 +2490,7 @@ static void sub_80DA5E8(u8 taskId)
gBattle_BG2_Y = 0;
for (i = 0; i < CONTESTANT_COUNT; i++)
gUnknown_02039F10[i] = eContestantStatus[i].pointTotal;
- sub_80DBD18();
+ CalculateFinalScores();
ContestClearGeneralTextWindow();
if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK))
BravoTrainerPokemonProfile_BeforeInterview1(eContestantStatus[gContestPlayerMonIndex].prevMove);
@@ -3367,22 +3367,22 @@ bool8 Contest_IsMonsTurnDisabled(u8 a)
return FALSE;
}
-static void sub_80DBCE0(u8 contestant)
+static void CalculateTotalPointsForContestant(u8 contestant)
{
- gUnknown_02039F18[contestant] = sub_80DBD34(contestant);
- gUnknown_02039F08[contestant] = gContestMonConditions[contestant] + gUnknown_02039F18[contestant];
+ gContestMonRound2Points[contestant] = GetContestantRound2Points(contestant);
+ gContestMonTotalPoints[contestant] = gContestMonConditions[contestant] + gContestMonRound2Points[contestant];
}
-static void sub_80DBD18(void)
+static void CalculateFinalScores(void)
{
s32 i;
for (i = 0; i < CONTESTANT_COUNT; i++)
- sub_80DBCE0(i);
+ CalculateTotalPointsForContestant(i);
DetermineFinalStandings();
}
-static s16 sub_80DBD34(u8 contestant)
+static s16 GetContestantRound2Points(u8 contestant)
{
return gUnknown_02039F10[contestant] * 2;
}
@@ -3411,7 +3411,7 @@ static void DetermineFinalStandings(void)
for (i = 0; i < CONTESTANT_COUNT; i++)
{
- sp8[i].unk0 = gUnknown_02039F08[i];
+ sp8[i].unk0 = gContestMonTotalPoints[i];
sp8[i].unk4 = gContestMonConditions[i];
sp8[i].unk8 = randomOrdering[i];
sp8[i].unkC = i;
@@ -5313,22 +5313,22 @@ bool8 sub_80DEDA8(u8 rank)
}
if (rank != 0xFE)
{
- u8 r4 = sub_80DEFA8(rank, 1);
+ u8 id = sub_80DEFA8(rank, 1);
- gSaveBlock1Ptr->contestWinners[r4].personality = gContestMons[i].personality;
- gSaveBlock1Ptr->contestWinners[r4].species = gContestMons[i].species;
- gSaveBlock1Ptr->contestWinners[r4].trainerId = gContestMons[i].otId;
- StringCopy(gSaveBlock1Ptr->contestWinners[r4].monName, gContestMons[i].nickname);
- StringCopy(gSaveBlock1Ptr->contestWinners[r4].trainerName, gContestMons[i].trainerName);
+ gSaveBlock1Ptr->contestWinners[id].personality = gContestMons[i].personality;
+ gSaveBlock1Ptr->contestWinners[id].species = gContestMons[i].species;
+ gSaveBlock1Ptr->contestWinners[id].trainerId = gContestMons[i].otId;
+ StringCopy(gSaveBlock1Ptr->contestWinners[id].monName, gContestMons[i].nickname);
+ StringCopy(gSaveBlock1Ptr->contestWinners[id].trainerName, gContestMons[i].trainerName);
if(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)
- gSaveBlock1Ptr->contestWinners[r4].contestRank = CONTEST_RANK_LINK;
+ gSaveBlock1Ptr->contestWinners[id].contestRank = CONTEST_RANK_LINK;
else
- gSaveBlock1Ptr->contestWinners[r4].contestRank = gSpecialVar_ContestRank;
+ gSaveBlock1Ptr->contestWinners[id].contestRank = gSpecialVar_ContestRank;
if (rank != 0xFF)
- gSaveBlock1Ptr->contestWinners[r4].contestCategory = gSpecialVar_ContestCategory;
+ gSaveBlock1Ptr->contestWinners[id].contestCategory = gSpecialVar_ContestCategory;
else
- gSaveBlock1Ptr->contestWinners[r4].contestCategory = r7;
+ gSaveBlock1Ptr->contestWinners[id].contestCategory = r7;
}
else
{
@@ -5354,24 +5354,24 @@ u8 sub_80DEFA8(u8 rank, u8 b)
case CONTEST_RANK_MASTER:
if (b != 0)
{
- for (i = 5; i >= 1; i--)
+ for (i = NUM_CONTEST_HALL_WINNERS - 1; i >= 1; i--)
memcpy(&gSaveBlock1Ptr->contestWinners[i], &gSaveBlock1Ptr->contestWinners[i - 1], sizeof(struct ContestWinner));
}
return 0;
- default: // CONTEST_RANK_LINK
+ default:
switch (gSpecialVar_ContestCategory)
{
case CONTEST_CATEGORY_COOL:
- return 8;
+ return CONTEST_WINNER_MUSEUM_COOL - 1;
case CONTEST_CATEGORY_BEAUTY:
- return 9;
+ return CONTEST_WINNER_MUSEUM_BEAUTY - 1;
case CONTEST_CATEGORY_CUTE:
- return 10;
+ return CONTEST_WINNER_MUSEUM_CUTE - 1;
case CONTEST_CATEGORY_SMART:
- return 11;
+ return CONTEST_WINNER_MUSEUM_SMART - 1;
case CONTEST_CATEGORY_TOUGH:
default:
- return 12;
+ return CONTEST_WINNER_MUSEUM_TOUGH - 1;
}
}
}
@@ -5471,7 +5471,7 @@ static void sub_80DF250(void)
gContestResources->field_1c[r1].unkD |= 1;
for (i = 0; i < CONTESTANT_COUNT; i++)
{
- if (i != var_38 && gUnknown_02039F08[var_38] - gUnknown_02039F08[i] <= 50)
+ if (i != var_38 && gContestMonTotalPoints[var_38] - gContestMonTotalPoints[i] <= 50)
gContestResources->field_1c[i].unkD |= 4;
if (!gContestResources->field_1c[i].unkE_2)
@@ -5491,7 +5491,7 @@ static void sub_80DF250(void)
{
if (gContestMonConditions[i] > gContestMonConditions[j])
r12 = TRUE;
- if (gUnknown_02039F18[i] > gUnknown_02039F18[j])
+ if (gContestMonRound2Points[i] > gContestMonRound2Points[j])
r8 = TRUE;
}
if (!r12 && !r8)
@@ -5582,7 +5582,7 @@ static void sub_80DF4F8(void)
{
if (gContestMonConditions[r7] < gContestMonConditions[i])
r9++;
- if (gUnknown_02039F18[r7] < gUnknown_02039F18[i])
+ if (gContestMonRound2Points[r7] < gContestMonRound2Points[i])
r10++;
}
diff --git a/src/contest_link_80FC4F4.c b/src/contest_link.c
index d6cfea638..eb688f55e 100644
--- a/src/contest_link_80FC4F4.c
+++ b/src/contest_link.c
@@ -6,6 +6,7 @@
#include "pokemon.h"
#include "random.h"
#include "task.h"
+#include "contest_link.h"
#include "constants/flags.h"
static void sub_80FC5C0(u8);
@@ -36,7 +37,7 @@ bool8 sub_80FC530(u8 arg0)
bool8 sub_80FC55C(void)
{
- if (GetBlockReceivedStatus() == sub_800A9D8())
+ if (GetBlockReceivedStatus() == GetLinkPlayerCountAsBitFlags())
{
ResetBlockReceivedFlags();
return TRUE;
@@ -296,14 +297,14 @@ void sub_80FCACC(u8 taskId)
case 0:
if (IsLinkTaskFinished())
{
- if (sub_80FC4F4(gUnknown_02039F08, sizeof(gUnknown_02039F08)) == 1)
+ if (sub_80FC4F4(gContestMonTotalPoints, sizeof(gContestMonTotalPoints)) == 1)
gTasks[taskId].data[0]++;
}
break;
case 1:
if (sub_80FC55C())
{
- memcpy(gUnknown_02039F08, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(gUnknown_02039F08));
+ memcpy(gContestMonTotalPoints, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(gContestMonTotalPoints));
gTasks[taskId].data[0]++;
}
break;
@@ -334,14 +335,14 @@ void sub_80FCACC(u8 taskId)
case 6:
if (IsLinkTaskFinished())
{
- if (sub_80FC4F4(gUnknown_02039F18, sizeof(gUnknown_02039F18)) == 1)
+ if (sub_80FC4F4(gContestMonRound2Points, sizeof(gContestMonRound2Points)) == 1)
gTasks[taskId].data[0]++;
}
break;
case 7:
if (sub_80FC55C())
{
- memcpy(gUnknown_02039F18, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(gUnknown_02039F18));
+ memcpy(gContestMonRound2Points, gBlockRecvBuffer[gUnknown_02039F2B], sizeof(gContestMonRound2Points));
gTasks[taskId].data[0]++;
}
break;
diff --git a/src/contest_link_81D9DE4.c b/src/contest_link_util.c
index 8060b6cdc..8060b6cdc 100644
--- a/src/contest_link_81D9DE4.c
+++ b/src/contest_link_util.c
diff --git a/src/contest_painting.c b/src/contest_painting.c
index 7f33cac09..5dd4a70a5 100644
--- a/src/contest_painting.c
+++ b/src/contest_painting.c
@@ -170,7 +170,7 @@ void SetContestWinnerForPainting(int contestWinnerId)
u8 *ptr2 = &gUnknown_02039F5C;
gCurContestWinner = gSaveBlock1Ptr->contestWinners[contestWinnerId - 1];
*ptr1 = contestWinnerId - 1;
- *ptr2 = 0;
+ *ptr2 = FALSE;
}
void CB2_ContestPainting(void)
@@ -281,7 +281,7 @@ static void InitContestPaintingWindow(void)
ShowBg(1);
}
-static void PrintContestPaintingCaption(u8 contestType, u8 arg1)
+static void PrintContestPaintingCaption(u8 contestType, bool8 arg1)
{
int x;
u8 category;
@@ -519,12 +519,14 @@ _081303F8:\n\
}
#endif
-static void LoadContestPaintingFrame(u8 contestWinnerId, u8 arg1)
+#define VRAM_PICTURE_DATA(x, y) (((u16 *)(BG_SCREEN_ADDR(12)))[(y) * 32 + (x)])
+
+static void LoadContestPaintingFrame(u8 contestWinnerId, bool8 arg1)
{
u8 x, y;
LoadPalette(gPictureFramePalettes, 0, 0x100);
- if (arg1 == 1)
+ if (arg1 == TRUE)
{
switch (gContestPaintingWinner->contestCategory / 3)
{
@@ -550,8 +552,6 @@ static void LoadContestPaintingFrame(u8 contestWinnerId, u8 arg1)
break;
}
-#define VRAM_PICTURE_DATA(x, y) (((u16 *)(BG_SCREEN_ADDR(12)))[(y) * 32 + (x)])
-
// Set the background
for (y = 0; y < 20; y++)
{
@@ -569,8 +569,6 @@ static void LoadContestPaintingFrame(u8 contestWinnerId, u8 arg1)
// Re-set the entire top row to the first top frame part
for (x = 0; x < 16; x++)
VRAM_PICTURE_DATA(x + 7, 2) = (*gContestMonPixels)[2][7];
-
-#undef VRAM_PICTURE_DATA
}
else if (contestWinnerId < 8)
{
@@ -605,6 +603,8 @@ static void LoadContestPaintingFrame(u8 contestWinnerId, u8 arg1)
}
}
+#undef VRAM_PICTURE_DATA
+
static void InitPaintingMonOamData(u8 contestWinnerId)
{
//Some hacks just to get the asm to match
@@ -692,7 +692,7 @@ static void DoContestPaintingImageProcessing(u8 imageEffect)
LoadPalette(gContestPaintingMonPalette, 0x100, 0x200);
}
-static void CreateContestPaintingPicture(u8 contestWinnerId, u8 arg1)
+static void CreateContestPaintingPicture(u8 contestWinnerId, bool8 arg1)
{
AllocPaintingResources();
InitContestMonPixels(gContestPaintingWinner->species, 0);
diff --git a/src/contest_link_80F57C4.c b/src/contest_util.c
index 0cecaed07..22074e1a1 100644
--- a/src/contest_link_80F57C4.c
+++ b/src/contest_util.c
@@ -4,8 +4,8 @@
#include "battle_gfx_sfx_util.h"
#include "bg.h"
#include "contest.h"
-#include "contest_link_80F57C4.h"
-#include "contest_link_80FC4F4.h"
+#include "contest_util.h"
+#include "contest_link.h"
#include "data.h"
#include "decompress.h"
#include "dma3.h"
@@ -36,6 +36,7 @@
#include "tv.h"
#include "util.h"
#include "window.h"
+#include "constants/field_specials.h"
#include "constants/game_stat.h"
#include "constants/rgb.h"
#include "constants/songs.h"
@@ -43,94 +44,113 @@
#include "constants/vars.h"
#include "contest.h"
-struct ContestLinkUnk0
+enum {
+ SLIDING_TEXT_OFFSCREEN,
+ SLIDING_TEXT_ENTERING,
+ SLIDING_TEXT_ARRIVED,
+ SLIDING_TEXT_EXITING,
+};
+
+enum {
+ SLIDING_MON_ENTERED = 1,
+ SLIDING_MON_EXITED,
+};
+
+#define GET_CONTEST_WINNER_ID(i) { for ((i) = 0; (i) < CONTESTANT_COUNT && gContestFinalStandings[(i)] != 0; (i)++); }
+
+#define TAG_CONFETTI 3017
+
+#define MAX_BAR_LENGTH 87
+
+struct ContestResultsInternal
{
- u8 unk0;
- u8 unk1;
- u8 taskId;
- u8 unk3;
- u8 unk4;
- u8 unk5;
- u8 unk6;
- u8 unk7;
- u8 spriteId;
- u8 unk9;
- u8 unkA;
- s16 unkC[4];
- u8 unk14;
- u8 filler15[0x3];
+ u8 slidingTextBoxSpriteId;
+ u8 linkTextBoxSpriteId;
+ u8 showResultsTaskId;
+ u8 highlightWinnerTaskId;
+ u8 slidingTextBoxState;
+ u8 numStandingsPrinted;
+ u8 winnerMonSlidingState;
+ u8 confettiCount;
+ u8 winnerMonSpriteId;
+ bool8 destroyConfetti;
+ bool8 pointsFlashing;
+ s16 unkC[CONTESTANT_COUNT];
+ u8 numBarsUpdating;
};
-struct ContestLinkUnk14
+struct ContestMonResults
{
- int unk0;
- int unk4;
- u32 unk8;
- u32 unkC;
- u8 unk10;
- u8 unk11;
- u8 unk12;
+ int relativePreliminaryPoints;
+ int relativeRound2Points;
+ u32 barLengthPreliminary;
+ u32 barLengthRound2;
+ bool8 lostPoints;
+ u8 numStars;
+ u8 numHearts;
};
-struct ContestLink80F57C4
+struct ContestResults
{
- struct ContestLinkUnk0 *unk0;
- struct ContestLinkUnk14 (*unk4)[4];
- u8 *unk8;
- u8 *unkC[4];
- u8 *unk1C;
+ struct ContestResultsInternal *data;
+ struct ContestMonResults (*monResults)[CONTESTANT_COUNT];
+ u8 *unusedBg; // Allocated/freed, never used
+ u8 *tilemapBuffers[4];
+ u8 *unused; // Allocated/freed, never used
};
-EWRAM_DATA struct ContestLink80F57C4 *gUnknown_0203A034 = NULL;
+static EWRAM_DATA struct ContestResults *sContestResults = NULL;
-static void sub_80F6A9C(void);
-static void sub_80F71C8(void);
-u8 sub_80F7310(u8, u8);
-s8 sub_80F7364(u8, u8);
-static void sub_80F7ED0(int, u8 *, int);
-static void sub_80F7DF4(void);
+static void LoadAllContestMonIconPalettes(void);
+static void LoadContestResultsTilemaps(void);
+static u8 GetNumPreliminaryPoints(u8, bool8);
+static s8 GetNumRound2Points(u8, bool8);
+static void AddContestTextPrinter(int, u8 *, int);
+static void AllocContestResults(void);
+static void FreeContestResults(void);
static void LoadAllContestMonIcons(u8, u8);
-static void sub_80F6DC0(void);
-static void sub_80F6AE8(void);
-static void sub_80F5CE4(u8);
-static void sub_80F5C00(void);
-static void sub_80F68B4(u8);
-static void sub_80F7880(void);
-static void sub_80F5C24(void);
-static void sub_80F707C(const u8 *);
-static void sub_80F5ED8(u8);
+static void LoadContestResultSprites(void);
+static void TryCreateWirelessSprites(void);
+static void Task_StartShowContestResults(u8 taskId);
+static void CB2_StartShowContestResults(void);
+static void Task_ShowContestResults(u8);
+static void CB2_ShowContestResults(void);
+static void VBlankCB_ShowContestResults(void);
+static void Task_SlideContestResultsBg(u8);
+static void Task_WaitForLinkPartnersBeforeResults(u8);
static void sub_80F5F14(u8);
static void sub_80F5F30(u8);
-static void sub_80F5F74(u8);
-static void sub_80F7144(void);
-static void sub_80F68F0(u8);
-s32 sub_80F6B78(const u8 *, u8);
-static void sub_80F6E9C(s16, u16, u16, u16);
-static void sub_80F6058(u8);
-static void sub_80F7A80(u8, u8);
-void sub_80F7CA8(u8);
-static void sub_80F6EF4(u16);
-static void sub_80F60F0(u8);
-static void sub_80F616C(u8);
-static void sub_80F6204(u8);
-static void sub_80F73DC(u8);
-static void sub_80F74BC(u8);
-static void sub_80F753C(u8);
-static void sub_80F77E0(u8, u8);
-static void sub_80F7824(u8);
-static void sub_80F6404(u8);
-static void sub_80F75A8(struct Sprite *);
-static void sub_80F7670(u8);
-static void sub_80F7620(struct Sprite *);
-static void sub_80F66B4(u8);
-static void sub_80F671C(u8);
-static void sub_80F677C(u8);
-static void sub_80F67C4(u8);
-static void sub_80F6820(u8);
-static void sub_80F7E64(void);
-static void sub_80F6F68(struct Sprite *);
-static void sub_80F7014(struct Sprite *);
-static void sub_80F6FDC(struct Sprite *);
+static void Task_AnnouncePreliminaryResults(u8);
+static void Task_FlashStarsAndHearts(u8);
+static void Task_ShowPreliminaryResults(u8);
+static void Task_AnnounceRound2Results(u8);
+static void Task_ShowRound2Results(u8);
+static void Task_AnnounceWinner(u8);
+static void Task_DrawFinalStandingNumber(u8);
+static void Task_StartHighlightWinnersBox(u8);
+static void Task_HighlightWinnersBox(u8);
+static void Task_ShowWinnerMonBanner(u8);
+static void Task_SetSeenWinnerMon(u8);
+static void Task_TryDisconnectLinkPartners(u8);
+static void Task_WaitForLinkPartnersDisconnect(u8);
+static void Task_TrySetContestInterviewData(u8);
+static void Task_EndShowContestResults(u8);
+static void CalculateContestantsResultData(void);
+static void ShowLinkResultsTextBox(const u8 *);
+static void HideLinkResultsTextBox(void);
+static s32 DrawResultsTextWindow(const u8 *, u8);
+static void StartTextBoxSlideIn(s16, u16, u16, u16);
+static void UpdateContestResultBars(bool8, u8);
+static void Task_UpdateContestResultBar(u8);
+static void StartTextBoxSlideOut(u16);
+static void BounceMonIconInBox(u8, u8);
+static void Task_BounceMonIconInBox(u8);
+static void SpriteCB_WinnerMonSlideIn(struct Sprite *);
+static void SpriteCB_WinnerMonSlideOut(struct Sprite *);
+static void Task_CreateConfetti(u8);
+static void SpriteCB_TextBoxSlideIn(struct Sprite *);
+static void SpriteCB_TextBoxSlideOut(struct Sprite *);
+static void SpriteCB_EndTextBoxSlideIn(struct Sprite *);
static void sub_80F8508(u8);
static void sub_80F8568(u8);
static void sub_80F8584(u8);
@@ -139,7 +159,7 @@ static void sub_80F85BC(u8);
static void sub_80F86B8(u8);
static void sub_80F878C(u8);
static void sub_80F87B4(u8);
-static void sub_80F7768(struct Sprite *sprite);
+static void SpriteCB_Confetti(struct Sprite *sprite);
static const u16 sUnknown_0858D6B0[] = INCBIN_U16("graphics/unknown/unknown_58D6B0.gbapal");
static const u8 sUnknown_0858D6D0[] = INCBIN_U8("graphics/unknown/unknown_58D6D0.4bpp");
@@ -191,7 +211,7 @@ static const struct SpritePalette sUnknown_0858D850 =
.tag = 3009,
};
-static const struct OamData sOamData_858D858 =
+static const struct OamData sOamData_Confetti =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
@@ -208,32 +228,32 @@ static const struct OamData sOamData_858D858 =
.affineParam = 0,
};
-static const struct SpriteTemplate sSpriteTemplate_858D860 =
+static const struct SpriteTemplate sSpriteTemplate_Confetti =
{
- .tileTag = 3017,
- .paletteTag = 3017,
- .oam = &sOamData_858D858,
+ .tileTag = TAG_CONFETTI,
+ .paletteTag = TAG_CONFETTI,
+ .oam = &sOamData_Confetti,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
- .callback = sub_80F7768
+ .callback = SpriteCB_Confetti
};
-static const struct CompressedSpriteSheet sUnknown_0858D878 =
+static const struct CompressedSpriteSheet sSpriteSheet_Confetti =
{
- .data = gContestConfetti_Gfx,
+ .data = gConfetti_Gfx,
.size = 0x220,
- .tag = 3017
+ .tag = TAG_CONFETTI
};
-static const struct CompressedSpritePalette sUnknown_0858D880 =
+static const struct CompressedSpritePalette sSpritePalette_Confetti =
{
- .data = gContestConfetti_Pal,
- .tag = 3017
+ .data = gConfetti_Pal,
+ .tag = TAG_CONFETTI
};
-static const struct BgTemplate sUnknown_0858D888[] =
+static const struct BgTemplate sBgTemplates[] =
{
{
.bg = 0,
@@ -273,7 +293,7 @@ static const struct BgTemplate sUnknown_0858D888[] =
}
};
-static const struct WindowTemplate sUnknown_0858D898[] =
+static const struct WindowTemplate sWindowTemplates[] =
{
{
.bg = 1,
@@ -353,17 +373,17 @@ static const struct SpriteSheet sUnknown_0858D8E0 =
static const u8 sContestLinkTextColors[4] = {TEXT_COLOR_WHITE, TEXT_DYNAMIC_COLOR_6, TEXT_DYNAMIC_COLOR_5};
-void sub_80F57C4(void)
+static void InitContestResultsDisplay(void)
{
int i;
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP);
ResetBgsAndClearDma3BusyFlags(0);
- InitBgsFromTemplates(0, sUnknown_0858D888, ARRAY_COUNT(sUnknown_0858D888));
- for (i = 0; i < 4; i++)
- SetBgTilemapBuffer(i, gUnknown_0203A034->unkC[i]);
+ InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates));
+ for (i = 0; i < (int)ARRAY_COUNT(sContestResults->tilemapBuffers); i++)
+ SetBgTilemapBuffer(i, sContestResults->tilemapBuffers[i]);
- InitWindows(sUnknown_0858D898);
+ InitWindows(sWindowTemplates);
DeactivateAllTextPrinters();
SetGpuReg(REG_OFFSET_MOSAIC, 0);
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR);
@@ -398,34 +418,35 @@ void sub_80F57C4(void)
gBattle_WIN1V = 0;
}
-void sub_80F591C(void)
+static void LoadContestResultsBgGfx(void)
{
int i, j;
- s8 var0, var1;
+ s8 numStars, round2Points;
u16 tile1, tile2;
- LZDecompressVram(gUnknown_08C19588, (void *)BG_CHAR_ADDR(0));
+ LZDecompressVram(gContestResults_Gfx, (void *)BG_CHAR_ADDR(0));
CopyToBgTilemapBuffer(3, gUnknown_08C1A12C, 0, 0);
CopyToBgTilemapBuffer(2, gUnknown_08C1A000, 0, 0);
CopyToBgTilemapBuffer(0, gUnknown_08C19EEC, 0, 0);
- sub_80F71C8();
- LoadCompressedPalette(gUnknown_08C1A2B4, 0, 0x200);
+ LoadContestResultsTilemaps();
+ LoadCompressedPalette(gContestResults_Pal, 0, 0x200);
LoadPalette(sUnknown_0858D6B0, 0xF0, 0x20);
- for (i = 0; i < 4; i++)
+ for (i = 0; i < CONTESTANT_COUNT; i++)
{
- var0 = sub_80F7310(i, 1);
- var1 = sub_80F7364(i, 1);
+ numStars = GetNumPreliminaryPoints(i, TRUE);
+ round2Points = GetNumRound2Points(i, TRUE);
for (j = 0; j < 10; j++)
{
tile1 = 0x60B2;
- if (j < var0)
+ if (j < numStars)
tile1 += 2;
- if (j < abs(var1))
+ // Abs of round2Points is number of hearts
+ if (j < abs(round2Points))
{
tile2 = 0x60A4;
- if (var1 < 0)
+ if (round2Points < 0)
tile2 += 2;
}
else
@@ -448,7 +469,7 @@ void sub_80F591C(void)
ShowBg(3);
}
-static void sub_80F5A74(u8 monIndex)
+static void LoadContestMonName(u8 monIndex)
{
struct ContestPokemon *mon = &gContestMons[monIndex];
u8 *str = gDisplayedStringBattle;
@@ -456,58 +477,58 @@ static void sub_80F5A74(u8 monIndex)
str = StringCopy(gDisplayedStringBattle, gText_ColorDarkGrey);
StringCopy(str, mon->nickname);
- sub_80F7ED0(monIndex, gDisplayedStringBattle, 0);
+ AddContestTextPrinter(monIndex, gDisplayedStringBattle, 0);
StringCopy(str, gText_Slash);
StringAppend(str, mon->trainerName);
- sub_80F7ED0(monIndex, gDisplayedStringBattle, 50);
+ AddContestTextPrinter(monIndex, gDisplayedStringBattle, 50);
}
-void sub_80F5AE0(void)
+static void LoadAllContestMonNames(void)
{
int i;
for (i = 0; i < CONTESTANT_COUNT; i++)
- sub_80F5A74(i);
+ LoadContestMonName(i);
CopyBgTilemapBufferToVram(1);
}
-void sub_80F5B00(void)
+static void CB2_StartShowContestResults(void)
{
- gPaletteFade.bufferTransferDisabled = 1;
+ gPaletteFade.bufferTransferDisabled = TRUE;
SetVBlankCallback(NULL);
- sub_80F7DF4();
- sub_80F57C4();
+ AllocContestResults();
+ InitContestResultsDisplay();
ScanlineEffect_Clear();
ResetPaletteFade();
ResetSpriteData();
ResetTasks();
FreeAllSpritePalettes();
- sub_80F591C();
- sub_80F6A9C();
- LoadAllContestMonIcons(0, 1);
- sub_80F5AE0();
- memset(gUnknown_0203A034->unk0, 0, sizeof(*gUnknown_0203A034->unk0));
- memset(gUnknown_0203A034->unk4, 0, sizeof(*gUnknown_0203A034->unk4));
- sub_80F6DC0();
- sub_80F6AE8();
+ LoadContestResultsBgGfx();
+ LoadAllContestMonIconPalettes();
+ LoadAllContestMonIcons(0, TRUE);
+ LoadAllContestMonNames();
+ memset(sContestResults->data, 0, sizeof(*sContestResults->data));
+ memset(sContestResults->monResults, 0, sizeof(*sContestResults->monResults));
+ LoadContestResultSprites();
+ TryCreateWirelessSprites();
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK);
- gPaletteFade.bufferTransferDisabled = 0;
- gUnknown_0203A034->unk0->taskId = CreateTask(sub_80F5CE4, 5);
- SetMainCallback2(sub_80F5C00);
+ gPaletteFade.bufferTransferDisabled = FALSE;
+ sContestResults->data->showResultsTaskId = CreateTask(Task_ShowContestResults, 5);
+ SetMainCallback2(CB2_ShowContestResults);
gBattle_WIN1H = 0x00F0;
gBattle_WIN1V = 0x80A0;
- CreateTask(sub_80F68B4, 20);
- sub_80F7880();
+ CreateTask(Task_SlideContestResultsBg, 20);
+ CalculateContestantsResultData();
if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS)
- gPaletteFade.bufferTransferDisabled = 1;
+ gPaletteFade.bufferTransferDisabled = TRUE;
else
PlayBGM(MUS_CON_K);
- SetVBlankCallback(sub_80F5C24);
+ SetVBlankCallback(VBlankCB_ShowContestResults);
}
-static void sub_80F5C00(void)
+static void CB2_ShowContestResults(void)
{
AnimateSprites();
BuildOamBuffer();
@@ -517,7 +538,7 @@ static void sub_80F5C00(void)
CopyBgTilemapBufferToVram(2);
}
-static void sub_80F5C24(void)
+static void VBlankCB_ShowContestResults(void)
{
SetGpuReg(REG_OFFSET_BG0HOFS, gBattle_BG0_X);
SetGpuReg(REG_OFFSET_BG0VOFS, gBattle_BG0_Y);
@@ -537,29 +558,33 @@ static void sub_80F5C24(void)
ScanlineEffect_InitHBlankDmaTransfer();
}
-static void sub_80F5CE4(u8 taskId)
+#define tState data[0]
+#define tTimer data[1]
+#define tCounter data[2]
+
+static void Task_ShowContestResults(u8 taskId)
{
u16 var;
if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)
{
- switch (gTasks[taskId].data[0])
+ switch (gTasks[taskId].tState)
{
case 0:
SaveLinkContestResults();
if (gContestFinalStandings[gContestPlayerMonIndex] == 0)
{
IncrementGameStat(GAME_STAT_WON_LINK_CONTEST);
- gSpecialVar_0x8005 = 8;
+ gSpecialVar_0x8005 = TVSHOW_CONTEST_LIVE_UPDATES;
InterviewBefore();
- if (gSpecialVar_Result != 1)
+ if (gSpecialVar_Result != TRUE)
InterviewAfter();
}
- TryGainNewFanFromCounter(2);
+ TryGainNewFanFromCounter(FANCOUNTER_FINISHED_CONTEST);
sub_80DEDA8(gSpecialVar_ContestRank);
sub_80DEDA8(0xFE);
- gUnknown_02039F5C = 1;
+ gUnknown_02039F5C = TRUE;
gUnknown_02039F5D = sub_80DEFA8(0xFE, 0);
var = VarGet(VAR_CONTEST_HALL_STATE);
VarSet(VAR_CONTEST_HALL_STATE, 0);
@@ -567,26 +592,26 @@ static void sub_80F5CE4(u8 taskId)
TrySavingData(SAVE_LINK);
ClearContinueGameWarpStatus2();
VarSet(VAR_CONTEST_HALL_STATE, var);
- gTasks[taskId].data[0]++;
+ gTasks[taskId].tState++;
break;
case 1:
- gTasks[taskId].data[0]++;
+ gTasks[taskId].tState++;
if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS))
- gTasks[taskId].data[0] = 100;
+ gTasks[taskId].tState = 100;
break;
case 2:
if (IsLinkTaskFinished())
{
sub_800ADF8();
- gTasks[taskId].data[0]++;
+ gTasks[taskId].tState++;
}
return;
case 3:
if (IsLinkTaskFinished() == TRUE)
{
PlayBGM(MUS_CON_K);
- gPaletteFade.bufferTransferDisabled = 0;
- gTasks[taskId].data[0]++;
+ gPaletteFade.bufferTransferDisabled = FALSE;
+ gTasks[taskId].tState++;
break;
}
return;
@@ -595,11 +620,11 @@ static void sub_80F5CE4(u8 taskId)
if (!gPaletteFade.active)
{
- gTasks[taskId].data[0] = 0;
+ gTasks[taskId].tState = 0;
if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)
{
- sub_80F707C(gText_CommunicationStandby);
- gTasks[taskId].func = sub_80F5ED8;
+ ShowLinkResultsTextBox(gText_CommunicationStandby);
+ gTasks[taskId].func = Task_WaitForLinkPartnersBeforeResults;
}
else
{
@@ -609,15 +634,15 @@ static void sub_80F5CE4(u8 taskId)
sub_80DEDA8(gSpecialVar_ContestRank);
sub_80DEDA8(0xFE);
- gUnknown_02039F5C = 1;
+ gUnknown_02039F5C = TRUE;
gUnknown_02039F5D = sub_80DEFA8(0xFE, 0);
- TryGainNewFanFromCounter(2);
- gTasks[taskId].func = sub_80F5F74;
+ TryGainNewFanFromCounter(FANCOUNTER_FINISHED_CONTEST);
+ gTasks[taskId].func = Task_AnnouncePreliminaryResults;
}
}
}
-static void sub_80F5ED8(u8 taskId)
+static void Task_WaitForLinkPartnersBeforeResults(u8 taskId)
{
if (gReceivedRemoteLinkPlayers)
{
@@ -636,194 +661,193 @@ static void sub_80F5F30(u8 taskId)
if (IsLinkTaskFinished())
{
DestroyTask(taskId);
- gTasks[gUnknown_0203A034->unk0->taskId].func = sub_80F5F74;
- sub_80F7144();
+ gTasks[sContestResults->data->showResultsTaskId].func = Task_AnnouncePreliminaryResults;
+ HideLinkResultsTextBox();
}
}
-static void sub_80F5F74(u8 taskId)
+static void Task_AnnouncePreliminaryResults(u8 taskId)
{
- s16 var0;
+ s16 x;
- if (gTasks[taskId].data[0] == 0)
+ if (gTasks[taskId].tState == 0)
{
- CreateTask(sub_80F68F0, 20);
- var0 = sub_80F6B78(gText_AnnouncingResults, gUnknown_0203A034->unk0->unk0);
- sub_80F6E9C(var0, 144, 120, 1088);
- gTasks[taskId].data[0]++;
+ CreateTask(Task_FlashStarsAndHearts, 20);
+ x = DrawResultsTextWindow(gText_AnnouncingResults, sContestResults->data->slidingTextBoxSpriteId);
+ StartTextBoxSlideIn(x, 144, 120, 1088);
+ gTasks[taskId].tState++;
}
- else if (gTasks[taskId].data[0] == 1)
+ else if (gTasks[taskId].tState == 1)
{
- if (gUnknown_0203A034->unk0->unk4 == 0)
+ // Wait for "Announcing Results" text to leave
+ if (sContestResults->data->slidingTextBoxState == SLIDING_TEXT_OFFSCREEN)
{
- gTasks[taskId].data[1] = 0;
- gTasks[taskId].data[0]++;
+ gTasks[taskId].tTimer = 0;
+ gTasks[taskId].tState++;
}
}
- else if (gTasks[taskId].data[0] == 2)
+ else if (gTasks[taskId].tState == 2)
{
- if (++gTasks[taskId].data[1] == 21)
+ if (++gTasks[taskId].tTimer == 21)
{
- gTasks[taskId].data[1] = 0;
- gTasks[taskId].data[0]++;
+ gTasks[taskId].tTimer = 0;
+ gTasks[taskId].tState++;
}
}
- else if (gTasks[taskId].data[0] == 3)
+ else if (gTasks[taskId].tState == 3)
{
- var0 = sub_80F6B78(gText_PreliminaryResults, gUnknown_0203A034->unk0->unk0);
- sub_80F6E9C(var0, 144, -1, 1088);
- gTasks[taskId].data[0]++;
+ x = DrawResultsTextWindow(gText_PreliminaryResults, sContestResults->data->slidingTextBoxSpriteId);
+ StartTextBoxSlideIn(x, 144, -1, 1088);
+ gTasks[taskId].tState++;
}
- else if (gTasks[taskId].data[0] == 4)
+ else if (gTasks[taskId].tState == 4)
{
- if (gUnknown_0203A034->unk0->unk4 == 2)
+ if (sContestResults->data->slidingTextBoxState == SLIDING_TEXT_ARRIVED)
{
- gTasks[taskId].data[0] = 0;
- gTasks[taskId].func = sub_80F6058;
+ gTasks[taskId].tState = 0;
+ gTasks[taskId].func = Task_ShowPreliminaryResults;
}
}
}
-static void sub_80F6058(u8 taskId)
+static void Task_ShowPreliminaryResults(u8 taskId)
{
- switch (gTasks[taskId].data[0])
+ switch (gTasks[taskId].tState)
{
case 0:
- if (!gUnknown_0203A034->unk0->unkA)
+ if (!sContestResults->data->pointsFlashing)
{
- sub_80F7A80(0, gTasks[taskId].data[2]++);
- if (!gUnknown_0203A034->unk0->unk14)
- gTasks[taskId].data[0] = 2;
+ UpdateContestResultBars(FALSE, gTasks[taskId].tCounter++);
+ if (sContestResults->data->numBarsUpdating == 0)
+ gTasks[taskId].tState = 2;
else
- gTasks[taskId].data[0]++;
+ gTasks[taskId].tState++;
}
break;
case 1:
- if (!gUnknown_0203A034->unk0->unk14)
- gTasks[taskId].data[0] = 0;
+ if (sContestResults->data->numBarsUpdating == 0)
+ gTasks[taskId].tState = 0;
break;
case 2:
- sub_80F6EF4(1088);
- gTasks[taskId].data[0] = 0;
- gTasks[taskId].data[2] = 0;
- gTasks[taskId].func = sub_80F60F0;
+ StartTextBoxSlideOut(1088);
+ gTasks[taskId].tState = 0;
+ gTasks[taskId].tCounter = 0;
+ gTasks[taskId].func = Task_AnnounceRound2Results;
break;
}
}
-static void sub_80F60F0(u8 taskId)
+static void Task_AnnounceRound2Results(u8 taskId)
{
- s16 var0;
+ s16 x;
- if (gUnknown_0203A034->unk0->unk4 == 0)
+ if (sContestResults->data->slidingTextBoxState == SLIDING_TEXT_OFFSCREEN)
{
- if (++gTasks[taskId].data[1] == 21)
+ if (++gTasks[taskId].tTimer == 21)
{
- gTasks[taskId].data[1] = 0;
- var0 = sub_80F6B78(gText_Round2Results, gUnknown_0203A034->unk0->unk0);
- sub_80F6E9C(var0, 144, -1, 1088);
+ gTasks[taskId].tTimer = 0;
+ x = DrawResultsTextWindow(gText_Round2Results, sContestResults->data->slidingTextBoxSpriteId);
+ StartTextBoxSlideIn(x, 144, -1, 1088);
}
}
- else if (gUnknown_0203A034->unk0->unk4 == 2)
+ else if (sContestResults->data->slidingTextBoxState == SLIDING_TEXT_ARRIVED)
{
- gTasks[taskId].func = sub_80F616C;
+ gTasks[taskId].func = Task_ShowRound2Results;
}
}
-static void sub_80F616C(u8 taskId)
+static void Task_ShowRound2Results(u8 taskId)
{
- switch (gTasks[taskId].data[0])
+ switch (gTasks[taskId].tState)
{
case 0:
- if (!gUnknown_0203A034->unk0->unkA)
+ if (!sContestResults->data->pointsFlashing)
{
- sub_80F7A80(1, gTasks[taskId].data[2]++);
- if (!gUnknown_0203A034->unk0->unk14)
- gTasks[taskId].data[0] = 2;
+ UpdateContestResultBars(TRUE, gTasks[taskId].tCounter++);
+ if (sContestResults->data->numBarsUpdating == 0)
+ gTasks[taskId].tState = 2;
else
- gTasks[taskId].data[0]++;
+ gTasks[taskId].tState++;
}
break;
case 1:
- if (!gUnknown_0203A034->unk0->unk14)
- gTasks[taskId].data[0] = 0;
+ if (sContestResults->data->numBarsUpdating == 0)
+ gTasks[taskId].tState = 0;
break;
case 2:
- sub_80F6EF4(1088);
- gTasks[taskId].data[0] = 0;
- gTasks[taskId].func = sub_80F6204;
+ StartTextBoxSlideOut(1088);
+ gTasks[taskId].tState = 0;
+ gTasks[taskId].func = Task_AnnounceWinner;
break;
}
}
-static void sub_80F6204(u8 taskId)
+// Task data for Task_DrawFinalStandingNumber
+#define tFinalStanding data[0]
+#define tMonIndex data[1]
+
+static void Task_AnnounceWinner(u8 taskId)
{
int i;
- u8 newTaskId;
- u8 buffer[100];
- s16 var0;
-
- switch (gTasks[taskId].data[0])
+ switch (gTasks[taskId].tState)
{
case 0:
- if (!gUnknown_0203A034->unk0->unk4)
- gTasks[taskId].data[0]++;
+ if (sContestResults->data->slidingTextBoxState == SLIDING_TEXT_OFFSCREEN)
+ gTasks[taskId].tState++;
break;
case 1:
- if (++gTasks[taskId].data[1] == 31)
+ if (++gTasks[taskId].tTimer == 31)
{
- gTasks[taskId].data[1] = 0;
- gTasks[taskId].data[0]++;
+ gTasks[taskId].tTimer = 0;
+ gTasks[taskId].tState++;
}
break;
case 2:
for (i = 0; i < CONTESTANT_COUNT; i++)
{
- newTaskId = CreateTask(sub_80F73DC, 10);
- gTasks[newTaskId].data[0] = gContestFinalStandings[i];
- gTasks[newTaskId].data[1] = i;
+ u8 newTaskId = CreateTask(Task_DrawFinalStandingNumber, 10);
+ gTasks[newTaskId].tFinalStanding = gContestFinalStandings[i];
+ gTasks[newTaskId].tMonIndex = i;
}
- gTasks[taskId].data[0]++;
+ gTasks[taskId].tState++;
break;
case 3:
- if (gUnknown_0203A034->unk0->unk5 == 4)
+ if (sContestResults->data->numStandingsPrinted == CONTESTANT_COUNT)
{
- if (++gTasks[taskId].data[1] == 31)
+ if (++gTasks[taskId].tTimer == 31)
{
- gTasks[taskId].data[1] = 0;
- CreateTask(sub_80F74BC, 10);
- gTasks[taskId].data[0]++;
- for (i = 0; i < CONTESTANT_COUNT && gContestFinalStandings[i] != 0; i++)
- ;
-
- sub_80F77E0(i, 14);
+ gTasks[taskId].tTimer = 0;
+ CreateTask(Task_StartHighlightWinnersBox, 10);
+ gTasks[taskId].tState++;
+ GET_CONTEST_WINNER_ID(i);
+ BounceMonIconInBox(i, 14);
}
}
break;
case 4:
- if (++gTasks[taskId].data[1] == 21)
+ if (++gTasks[taskId].tTimer == 21)
{
- gTasks[taskId].data[1] = 0;
- for (i = 0; i < CONTESTANT_COUNT && gContestFinalStandings[i] != 0; i++)
- ;
-
+ u8 winnerTextBuffer[100];
+ s16 x;
+ gTasks[taskId].tTimer = 0;
+ GET_CONTEST_WINNER_ID(i);
StringCopy(gStringVar1, gContestMons[i].trainerName);
sub_81DB5AC(gStringVar1);
StringCopy(gStringVar2, gContestMons[i].nickname);
- StringExpandPlaceholders(buffer, gText_Var1sVar2Won);
- var0 = sub_80F6B78(buffer, gUnknown_0203A034->unk0->unk0);
- sub_80F6E9C(var0, 144, -1, 1088);
- gTasks[taskId].data[0]++;
+ StringExpandPlaceholders(winnerTextBuffer, gText_ContestantsMonWon);
+ x = DrawResultsTextWindow(winnerTextBuffer, sContestResults->data->slidingTextBoxSpriteId);
+ StartTextBoxSlideIn(x, 144, -1, 1088);
+ gTasks[taskId].tState++;
}
break;
case 5:
- gTasks[taskId].data[0] = 0;
- gTasks[taskId].func = sub_80F6404;
+ gTasks[taskId].tState = 0;
+ gTasks[taskId].func = Task_ShowWinnerMonBanner;
break;
}
}
-static void sub_80F6404(u8 taskId)
+static void Task_ShowWinnerMonBanner(u8 taskId)
{
int i;
u8 spriteId;
@@ -832,14 +856,13 @@ static void sub_80F6404(u8 taskId)
u32 personality;
const struct CompressedSpritePalette *pokePal;
- switch (gTasks[taskId].data[0])
+ switch (gTasks[taskId].tState)
{
case 0:
gBattle_WIN0H = 0x00F0;
gBattle_WIN0V = 0x5050;
- for (i = 0; i < CONTESTANT_COUNT && gContestFinalStandings[i] != 0; i++)
- ;
+ GET_CONTEST_WINNER_ID(i);
species = gContestMons[i].species;
personality = gContestMons[i].personality;
otId = gContestMons[i].otId;
@@ -867,42 +890,42 @@ static void sub_80F6404(u8 taskId)
spriteId = CreateSprite(&gMultiuseSpriteTemplate, 272, 80, 10);
gSprites[spriteId].data[1] = species;
gSprites[spriteId].oam.priority = 0;
- gSprites[spriteId].callback = sub_80F75A8;
- gUnknown_0203A034->unk0->spriteId = spriteId;
- LoadCompressedSpriteSheet(&sUnknown_0858D878);
- LoadCompressedSpritePalette(&sUnknown_0858D880);
- CreateTask(sub_80F7670, 10);
- gTasks[taskId].data[0]++;
+ gSprites[spriteId].callback = SpriteCB_WinnerMonSlideIn;
+ sContestResults->data->winnerMonSpriteId = spriteId;
+ LoadCompressedSpriteSheet(&sSpriteSheet_Confetti);
+ LoadCompressedSpritePalette(&sSpritePalette_Confetti);
+ CreateTask(Task_CreateConfetti, 10);
+ gTasks[taskId].tState++;
break;
case 1:
if (++gTasks[taskId].data[3] == 1)
{
u8 counter;
gTasks[taskId].data[3] = 0;
- gTasks[taskId].data[2] += 2;
- if (gTasks[taskId].data[2] > 32)
- gTasks[taskId].data[2] = 32;
+ gTasks[taskId].tCounter += 2;
+ if (gTasks[taskId].tCounter > 32)
+ gTasks[taskId].tCounter = 32;
- counter = gTasks[taskId].data[2];
+ counter = gTasks[taskId].tCounter;
gBattle_WIN0V = ((80 - counter) << 8) | (80 + counter);
if (counter == 32)
- gTasks[taskId].data[0]++;
+ gTasks[taskId].tState++;
}
break;
case 2:
- if (gUnknown_0203A034->unk0->unk6 == 1)
- gTasks[taskId].data[0]++;
+ if (sContestResults->data->winnerMonSlidingState == SLIDING_MON_ENTERED)
+ gTasks[taskId].tState++;
break;
case 3:
- if (++gTasks[taskId].data[1] == 121)
+ if (++gTasks[taskId].tTimer == 121)
{
- gTasks[taskId].data[1] = 0;
- gSprites[gUnknown_0203A034->unk0->spriteId].callback = sub_80F7620;
- gTasks[taskId].data[0]++;
+ gTasks[taskId].tTimer = 0;
+ gSprites[sContestResults->data->winnerMonSpriteId].callback = SpriteCB_WinnerMonSlideOut;
+ gTasks[taskId].tState++;
}
break;
case 4:
- if (gUnknown_0203A034->unk0->unk6 == 2)
+ if (sContestResults->data->winnerMonSlidingState == SLIDING_MON_EXITED)
{
u8 top = (gBattle_WIN0V >> 8);
top += 2;
@@ -911,25 +934,25 @@ static void sub_80F6404(u8 taskId)
gBattle_WIN0V = (top << 8) | (160 - top);
if (top == 80)
- gTasks[taskId].data[0]++;
+ gTasks[taskId].tState++;
}
break;
case 5:
- if (gUnknown_0203A034->unk0->unk6 == 2)
+ if (sContestResults->data->winnerMonSlidingState == SLIDING_MON_EXITED)
{
- gUnknown_0203A034->unk0->unk9 = 1;
- gTasks[taskId].data[0] = 0;
- gTasks[taskId].func = sub_80F66B4;
+ sContestResults->data->destroyConfetti = TRUE;
+ gTasks[taskId].tState = 0;
+ gTasks[taskId].func = Task_SetSeenWinnerMon;
}
break;
}
}
-static void sub_80F66B4(u8 taskId)
+static void Task_SetSeenWinnerMon(u8 taskId)
{
int i, nationalDexNum;
- if (gMain.newKeys & A_BUTTON)
+ if (JOY_NEW(A_BUTTON))
{
if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK))
{
@@ -941,62 +964,62 @@ static void sub_80F66B4(u8 taskId)
}
gTasks[taskId].data[10] = 0;
- gTasks[taskId].func = sub_80F671C;
+ gTasks[taskId].func = Task_TryDisconnectLinkPartners;
}
}
-static void sub_80F671C(u8 taskId)
+static void Task_TryDisconnectLinkPartners(u8 taskId)
{
if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)
{
if (!gTasks[taskId].data[10])
{
- sub_80F707C(gText_CommunicationStandby);
+ ShowLinkResultsTextBox(gText_CommunicationStandby);
sub_800AC34();
- gTasks[taskId].func = sub_80F677C;
+ gTasks[taskId].func = Task_WaitForLinkPartnersDisconnect;
}
}
else
{
- gTasks[taskId].func = sub_80F67C4;
+ gTasks[taskId].func = Task_TrySetContestInterviewData;
}
}
-static void sub_80F677C(u8 taskId)
+static void Task_WaitForLinkPartnersDisconnect(u8 taskId)
{
if (!gReceivedRemoteLinkPlayers)
{
if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS)
DestroyWirelessStatusIndicatorSprite();
- sub_80F7144();
- gTasks[taskId].func = sub_80F67C4;
+ HideLinkResultsTextBox();
+ gTasks[taskId].func = Task_TrySetContestInterviewData;
}
}
-static void sub_80F67C4(u8 taskId)
+static void Task_TrySetContestInterviewData(u8 taskId)
{
if (!(gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK))
BravoTrainerPokemonProfile_BeforeInterview2(gContestFinalStandings[gContestPlayerMonIndex]);
BeginHardwarePaletteFade(0xFF, 0, 0, 16, 0);
- gTasks[taskId].func = sub_80F6820;
+ gTasks[taskId].func = Task_EndShowContestResults;
}
-static void sub_80F6820(u8 taskId)
+static void Task_EndShowContestResults(u8 taskId)
{
if (!gPaletteFade.active)
{
- if (gTasks[taskId].data[1] == 0)
+ if (gTasks[taskId].tTimer == 0)
{
- DestroyTask(gUnknown_0203A034->unk0->unk3);
+ DestroyTask(sContestResults->data->highlightWinnerTaskId);
BlendPalettes(0x0000FFFF, 16, RGB_BLACK);
- gTasks[taskId].data[1]++;
+ gTasks[taskId].tTimer++;
}
- else if (gTasks[taskId].data[1] == 1)
+ else if (gTasks[taskId].tTimer == 1)
{
BlendPalettes(0xFFFF0000, 16, RGB_BLACK);
- gTasks[taskId].data[1]++;
+ gTasks[taskId].tTimer++;
}
else
{
@@ -1005,12 +1028,16 @@ static void sub_80F6820(u8 taskId)
DestroyTask(taskId);
FreeAllWindowBuffers();
SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
- sub_80F7E64();
+ FreeContestResults();
}
}
}
-static void sub_80F68B4(u8 taskId)
+#undef tState
+#undef tTimer
+#undef tCounter
+
+static void Task_SlideContestResultsBg(u8 taskId)
{
gBattle_BG3_X += 2;
gBattle_BG3_Y += 1;
@@ -1020,33 +1047,37 @@ static void sub_80F68B4(u8 taskId)
gBattle_BG3_Y -= 255;
}
-static void sub_80F68F0(u8 taskId)
+#define tDelay data[0]
+#define tCoeff data[1]
+#define tDecreasing data[2]
+
+static void Task_FlashStarsAndHearts(u8 taskId)
{
- if (++gTasks[taskId].data[0] == 2)
+ if (++gTasks[taskId].tDelay == 2)
{
- gTasks[taskId].data[0] = 0;
- if (gTasks[taskId].data[2] == 0)
- gTasks[taskId].data[1]++;
+ gTasks[taskId].tDelay = 0;
+ if (!gTasks[taskId].tDecreasing)
+ gTasks[taskId].tCoeff++;
else
- gTasks[taskId].data[1]--;
+ gTasks[taskId].tCoeff--;
- if (gTasks[taskId].data[1] == 16)
- gTasks[taskId].data[2] = 1;
- else if (gTasks[taskId].data[1] == 0)
- gTasks[taskId].data[2] = 0;
+ if (gTasks[taskId].tCoeff == 16)
+ gTasks[taskId].tDecreasing = TRUE;
+ else if (gTasks[taskId].tCoeff == 0)
+ gTasks[taskId].tDecreasing = FALSE;
- BlendPalette(0x6B, 1, gTasks[taskId].data[1], RGB(30, 22, 11));
- BlendPalette(0x68, 1, gTasks[taskId].data[1], RGB_WHITE);
- BlendPalette(0x6E, 1, gTasks[taskId].data[1], RGB(30, 29, 29));
+ BlendPalette(0x6B, 1, gTasks[taskId].tCoeff, RGB(30, 22, 11));
+ BlendPalette(0x68, 1, gTasks[taskId].tCoeff, RGB_WHITE);
+ BlendPalette(0x6E, 1, gTasks[taskId].tCoeff, RGB(30, 29, 29));
}
- if (gTasks[taskId].data[1] == 0)
- gUnknown_0203A034->unk0->unkA = 0;
+ if (gTasks[taskId].tCoeff == 0)
+ sContestResults->data->pointsFlashing = FALSE;
else
- gUnknown_0203A034->unk0->unkA = 1;
+ sContestResults->data->pointsFlashing = TRUE;
}
-void sub_80F69B8(u16 species, u8 monIndex, u8 srcOffset, u8 useDmaNow, u32 personality)
+static void LoadContestMonIcon(u16 species, u8 monIndex, u8 srcOffset, u8 useDmaNow, u32 personality)
{
const u8 *iconPtr;
u16 var0, var1, frameNum;
@@ -1071,15 +1102,15 @@ void sub_80F69B8(u16 species, u8 monIndex, u8 srcOffset, u8 useDmaNow, u32 perso
}
}
-static void LoadAllContestMonIcons(u8 srcOffset, u8 useDmaNow)
+static void LoadAllContestMonIcons(u8 srcOffset, bool8 useDmaNow)
{
int i;
for (i = 0; i < CONTESTANT_COUNT; i++)
- sub_80F69B8(gContestMons[i].species, i, srcOffset, useDmaNow, gContestMons[i].personality);
+ LoadContestMonIcon(gContestMons[i].species, i, srcOffset, useDmaNow, gContestMons[i].personality);
}
-static void sub_80F6A9C(void)
+static void LoadAllContestMonIconPalettes(void)
{
int i, species;
@@ -1090,7 +1121,7 @@ static void sub_80F6A9C(void)
}
}
-static void sub_80F6AE8(void)
+static void TryCreateWirelessSprites(void)
{
u16 sheet;
u8 spriteId;
@@ -1111,7 +1142,7 @@ static void sub_80F6AE8(void)
// src are placed on different stack positions.
#ifdef NONMATCHING
-s32 sub_80F6B78(const u8 *text, u8 spriteId)
+static s32 DrawResultsTextWindow(const u8 *text, u8 spriteId)
{
u8 *windowTilesPtr;
u16 windowId;
@@ -1176,7 +1207,7 @@ s32 sub_80F6B78(const u8 *text, u8 spriteId)
#else
NAKED
-s32 sub_80F6B78(const u8 *text, u8 spriteId)
+static s32 DrawResultsTextWindow(const u8 *text, u8 spriteId)
{
asm_unified("\n\
push {r4-r7,lr}\n\
@@ -1451,18 +1482,18 @@ _080F6D3E:\n\
}
#endif // NONMATCHING
-static void sub_80F6DC0(void)
+static void LoadContestResultSprites(void)
{
int i;
struct SpriteTemplate template;
- u8 spriteIds[8];
+ u8 spriteIds[ARRAY_COUNT(sUnknown_0858D810)];
template = sSpriteTemplate_858D7F8;
for (i = 0; i < (int)ARRAY_COUNT(sUnknown_0858D810); i++)
LoadSpriteSheet(&sUnknown_0858D810[i]);
LoadSpritePalette(&sUnknown_0858D850);
- for (i = 0; i < 8; i++)
+ for (i = 0; i < (int)ARRAY_COUNT(sUnknown_0858D810); i++)
{
spriteIds[i] = CreateSprite(&template, 272, 144, 10);
template.tileTag++;
@@ -1476,60 +1507,68 @@ static void sub_80F6DC0(void)
gSprites[spriteIds[4]].data[1] = spriteIds[6];
gSprites[spriteIds[4]].data[2] = spriteIds[7];
- gUnknown_0203A034->unk0->unk0 = spriteIds[0];
- gUnknown_0203A034->unk0->unk4 = 0;
- gUnknown_0203A034->unk0->unk1 = spriteIds[4];
- sub_80F7144();
+ sContestResults->data->slidingTextBoxSpriteId = spriteIds[0];
+ sContestResults->data->slidingTextBoxState = SLIDING_TEXT_OFFSCREEN;
+ sContestResults->data->linkTextBoxSpriteId = spriteIds[4];
+ HideLinkResultsTextBox();
}
-static void sub_80F6E9C(s16 arg0, u16 y, u16 arg2, u16 arg3)
+#define sTargetX data[4]
+#define sSlideOutTimer data[5]
+#define sSlideIncrement data[6]
+#define sDistance data[7]
+
+// If slideOutTimer is -1, it will not automatically slide out
+static void StartTextBoxSlideIn(s16 x, u16 y, u16 slideOutTimer, u16 slideIncrement)
{
- struct Sprite *sprite = &gSprites[gUnknown_0203A034->unk0->unk0];
+ struct Sprite *sprite = &gSprites[sContestResults->data->slidingTextBoxSpriteId];
sprite->pos1.x = 272;
sprite->pos1.y = y;
sprite->pos2.x = 0;
sprite->pos2.y = 0;
- sprite->data[4] = arg0 + 32;
- sprite->data[5] = arg2;
- sprite->data[6] = arg3;
- sprite->data[7] = 0;
- sprite->callback = sub_80F6F68;
- gUnknown_0203A034->unk0->unk4 = 1;
+ sprite->sTargetX = x + 32;
+ sprite->sSlideOutTimer = slideOutTimer;
+ sprite->sSlideIncrement = slideIncrement;
+ sprite->sDistance = 0;
+ sprite->callback = SpriteCB_TextBoxSlideIn;
+ sContestResults->data->slidingTextBoxState = SLIDING_TEXT_ENTERING;
}
-static void sub_80F6EF4(u16 arg0)
+static void StartTextBoxSlideOut(u16 slideIncrement)
{
- struct Sprite *sprite = &gSprites[gUnknown_0203A034->unk0->unk0];
+ struct Sprite *sprite = &gSprites[sContestResults->data->slidingTextBoxSpriteId];
sprite->pos1.x += sprite->pos2.x;
sprite->pos1.y += sprite->pos2.y;
sprite->pos2.y = 0;
sprite->pos2.x = 0;
- sprite->data[6] = arg0;
- sprite->data[7] = 0;
- sprite->callback = sub_80F7014;
- gUnknown_0203A034->unk0->unk4 = 3;
+ sprite->sSlideIncrement = slideIncrement;
+ sprite->sDistance = 0;
+ sprite->callback = SpriteCB_TextBoxSlideOut;
+ sContestResults->data->slidingTextBoxState = SLIDING_TEXT_EXITING;
}
-static void sub_80F6F40(struct Sprite *sprite)
+static void EndTextBoxSlideOut(struct Sprite *sprite)
{
sprite->pos1.x = 272;
sprite->pos1.y = 144;
sprite->pos2.y = 0;
sprite->pos2.x = 0;
sprite->callback = SpriteCallbackDummy;
- gUnknown_0203A034->unk0->unk4 = 0;
+ sContestResults->data->slidingTextBoxState = SLIDING_TEXT_OFFSCREEN;
}
-static void sub_80F6F68(struct Sprite *sprite)
+static void SpriteCB_TextBoxSlideIn(struct Sprite *sprite)
{
int i;
- s16 delta = sprite->data[7] + sprite->data[6];
+ s16 delta = sprite->sDistance + sprite->sSlideIncrement;
sprite->pos1.x -= delta >> 8;
- sprite->data[7] += sprite->data[6];
- sprite->data[7] &= 0xFF;
- if (sprite->pos1.x < sprite->data[4])
- sprite->pos1.x = sprite->data[4];
+ sprite->sDistance += sprite->sSlideIncrement;
+ sprite->sDistance &= 0xFF;
+
+ // Prevent overshooting target
+ if (sprite->pos1.x < sprite->sTargetX)
+ sprite->pos1.x = sprite->sTargetX;
for (i = 0; i < 3; i++)
{
@@ -1537,29 +1576,29 @@ static void sub_80F6F68(struct Sprite *sprite)
sprite2->pos1.x = sprite->pos1.x + sprite->pos2.x + (i + 1) * 64;
}
- if (sprite->pos1.x == sprite->data[4])
- sprite->callback = sub_80F6FDC;
+ if (sprite->pos1.x == sprite->sTargetX)
+ sprite->callback = SpriteCB_EndTextBoxSlideIn;
}
-static void sub_80F6FDC(struct Sprite *sprite)
+static void SpriteCB_EndTextBoxSlideIn(struct Sprite *sprite)
{
- gUnknown_0203A034->unk0->unk4 = 2;
- if ((u16)sprite->data[5] != 0xFFFF)
+ sContestResults->data->slidingTextBoxState = SLIDING_TEXT_ARRIVED;
+ if ((u16)sprite->sSlideOutTimer != 0xFFFF)
{
- if (--sprite->data[5] == -1)
- sub_80F6EF4(sprite->data[6]);
+ if (--sprite->sSlideOutTimer == -1)
+ StartTextBoxSlideOut(sprite->sSlideIncrement);
}
}
-static void sub_80F7014(struct Sprite *sprite)
+static void SpriteCB_TextBoxSlideOut(struct Sprite *sprite)
{
int i;
s16 delta;
- delta = sprite->data[7] + sprite->data[6];
+ delta = sprite->sDistance + sprite->sSlideIncrement;
sprite->pos1.x -= delta >> 8;
- sprite->data[7] += sprite->data[6];
- sprite->data[7] &= 0xFF;
+ sprite->sDistance += sprite->sSlideIncrement;
+ sprite->sDistance &= 0xFF;
for (i = 0; i < 3; i++)
{
struct Sprite *sprite2 = &gSprites[sprite->data[i]];
@@ -1567,25 +1606,25 @@ static void sub_80F7014(struct Sprite *sprite)
}
if (sprite->pos1.x + sprite->pos2.x < -224)
- sub_80F6F40(sprite);
+ EndTextBoxSlideOut(sprite);
}
-static void sub_80F707C(const u8 *text)
+static void ShowLinkResultsTextBox(const u8 *text)
{
int i;
u16 x;
struct Sprite *sprite;
- x = sub_80F6B78(text, gUnknown_0203A034->unk0->unk1);
- sprite = &gSprites[gUnknown_0203A034->unk0->unk1];
+ x = DrawResultsTextWindow(text, sContestResults->data->linkTextBoxSpriteId);
+ sprite = &gSprites[sContestResults->data->linkTextBoxSpriteId];
sprite->pos1.x = x + 32;
sprite->pos1.y = 80;
- sprite->invisible = 0;
+ sprite->invisible = FALSE;
for (i = 0; i < 3; i++)
{
gSprites[sprite->data[i]].pos1.x = sprite->pos1.x + sprite->pos2.x + (i + 1) * 64;
gSprites[sprite->data[i]].pos1.y = sprite->pos1.y;
- gSprites[sprite->data[i]].invisible = 0;
+ gSprites[sprite->data[i]].invisible = FALSE;
}
gBattle_WIN0H = 0x00F0;
@@ -1594,15 +1633,15 @@ static void sub_80F707C(const u8 *text)
| WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR);
}
-static void sub_80F7144(void)
+static void HideLinkResultsTextBox(void)
{
int i;
struct Sprite *sprite;
- sprite = &gSprites[gUnknown_0203A034->unk0->unk1];
- sprite->invisible = 1;
+ sprite = &gSprites[sContestResults->data->linkTextBoxSpriteId];
+ sprite->invisible = TRUE;
for (i = 0; i < 3; i++)
- gSprites[sprite->data[i]].invisible = 1;
+ gSprites[sprite->data[i]].invisible = TRUE;
gBattle_WIN0H = 0;
gBattle_WIN0V = 0;
@@ -1612,7 +1651,7 @@ static void sub_80F7144(void)
| WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR);
}
-static void sub_80F71C8(void)
+static void LoadContestResultsTilemaps(void)
{
u8 palette;
int x, y;
@@ -1621,147 +1660,153 @@ static void sub_80F71C8(void)
y = 1;
if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK)
{
- CopyToBgTilemapBufferRect(2, gUnknown_08DC6498, 5, 1, 5, 2);
+ CopyToBgTilemapBufferRect(2, gLinkContestResults_Tilemap, 5, 1, 5, 2);
x = 10;
}
else if (gSpecialVar_ContestRank == CONTEST_RANK_NORMAL)
{
- CopyToBgTilemapBufferRect(2, gUnknown_08DC63F8, 5, 1, 10, 2);
+ CopyToBgTilemapBufferRect(2, gNormalContestResults_Tilemap, 5, 1, 10, 2);
x = 15;
}
else if (gSpecialVar_ContestRank == CONTEST_RANK_SUPER)
{
- CopyToBgTilemapBufferRect(2, gUnknown_08DC6420, 5, 1, 10, 2);
+ CopyToBgTilemapBufferRect(2, gSuperContestResults_Tilemap, 5, 1, 10, 2);
x = 15;
}
else if (gSpecialVar_ContestRank == CONTEST_RANK_HYPER)
{
- CopyToBgTilemapBufferRect(2, gUnknown_08DC6448, 5, 1, 10, 2);
+ CopyToBgTilemapBufferRect(2, gHyperContestResults_Tilemap, 5, 1, 10, 2);
x = 15;
}
else // CONTEST_RANK_MASTER
{
- CopyToBgTilemapBufferRect(2, gUnknown_08DC6470, 5, 1, 10, 2);
+ CopyToBgTilemapBufferRect(2, gMasterContestResults_Tilemap, 5, 1, 10, 2);
x = 15;
}
if (gSpecialVar_ContestCategory == CONTEST_CATEGORY_COOL)
{
palette = 0;
- CopyToBgTilemapBufferRect(2, gUnknown_08DC64AC, x, y, 5, 2);
+ CopyToBgTilemapBufferRect(2, gCoolContestResults_Tilemap, x, y, 5, 2);
}
else if (gSpecialVar_ContestCategory == CONTEST_CATEGORY_BEAUTY)
{
palette = 1;
- CopyToBgTilemapBufferRect(2, gUnknown_08DC64C0, x, y, 5, 2);
+ CopyToBgTilemapBufferRect(2, gBeautyContestResults_Tilemap, x, y, 5, 2);
}
else if (gSpecialVar_ContestCategory == CONTEST_CATEGORY_CUTE)
{
palette = 2;
- CopyToBgTilemapBufferRect(2, gUnknown_08DC64D4, x, y, 5, 2);
+ CopyToBgTilemapBufferRect(2, gCuteContestResults_Tilemap, x, y, 5, 2);
}
else if (gSpecialVar_ContestCategory == CONTEST_CATEGORY_SMART)
{
palette = 3;
- CopyToBgTilemapBufferRect(2, gUnknown_08DC64E8, x, y, 5, 2);
+ CopyToBgTilemapBufferRect(2, gSmartContestResults_Tilemap, x, y, 5, 2);
}
else // CONTEST_CATEGORY_TOUGH
{
palette = 4;
- CopyToBgTilemapBufferRect(2, gUnknown_08DC64FC, x, y, 5, 2);
+ CopyToBgTilemapBufferRect(2, gToughContestResults_Tilemap, x, y, 5, 2);
}
x += 5;
- CopyToBgTilemapBufferRect(2, gUnknown_08DC6510, x, y, 6, 2);
- CopyToBgTilemapBufferRect_ChangePalette(2, gUnknown_0203A034->unkC[2], 0, 0, 32, 4, palette);
+ CopyToBgTilemapBufferRect(2, gContestResults_Tilemap, x, y, 6, 2);
+ CopyToBgTilemapBufferRect_ChangePalette(2, sContestResults->tilemapBuffers[2], 0, 0, 32, 4, palette);
}
-u8 sub_80F7310(u8 monIndex, u8 arg1)
+// Represented on results board as stars
+static u8 GetNumPreliminaryPoints(u8 monIndex, bool8 capPoints)
{
- u32 var0 = gContestMonConditions[monIndex] << 16;
- u32 var1 = var0 / 0x3F;
+ u32 condition = gContestMonConditions[monIndex] << 16;
+ u32 numStars = condition / 0x3F;
- if (var1 & 0xFFFF)
- var1 += 0x10000;
+ if (numStars & 0xFFFF)
+ numStars += 0x10000;
- var1 >>= 16;
- if (var1 == 0 && var0)
- var1 = 1;
+ numStars >>= 16;
+ if (numStars == 0 && condition)
+ numStars = 1;
- if (arg1 && var1 > 10)
- var1 = 10;
+ if (capPoints && numStars > 10)
+ numStars = 10;
- return var1;
+ return numStars;
}
-s8 sub_80F7364(u8 arg0, u8 arg1)
+// Represented on results board as hearts
+static s8 GetNumRound2Points(u8 monIndex, bool8 capPoints)
{
- u32 r4, r2;
- s16 val;
- s8 ret;
+ u32 r4, numHearts;
+ s16 results;
+ s8 points;
- val = gUnknown_02039F18[arg0];
- if (val < 0)
- r4 = -val << 16;
+ results = gContestMonRound2Points[monIndex];
+ if (results < 0)
+ r4 = -results << 16;
else
- r4 = val << 16;
+ r4 = results << 16;
- r2 = r4 / 80;
- if (r2 & 0xFFFF)
- r2 += 0x10000;
+ numHearts = r4 / 80;
+ if (numHearts & 0xFFFF)
+ numHearts += 0x10000;
- r2 >>= 16;
- if (r2 == 0 && r4 != 0)
- r2 = 1;
+ numHearts >>= 16;
+ if (numHearts == 0 && r4 != 0)
+ numHearts = 1;
- if (arg1 != 0 && r2 > 10)
- r2 = 10;
+ if (capPoints && numHearts > 10)
+ numHearts = 10;
- if (gUnknown_02039F18[arg0] < 0)
- ret = -r2;
+ if (gContestMonRound2Points[monIndex] < 0)
+ points = -numHearts;
else
- ret = r2;
+ points = numHearts;
- return ret;
+ return points;
}
-static void sub_80F73DC(u8 taskId)
+#define tState data[10]
+
+static void Task_DrawFinalStandingNumber(u8 taskId)
{
u16 firstTileNum;
- if (gTasks[taskId].data[10] == 0)
+ if (gTasks[taskId].tState == 0)
{
- gTasks[taskId].data[11] = (3 - gTasks[taskId].data[0]) * 40;
- gTasks[taskId].data[10]++;
+ gTasks[taskId].data[11] = (3 - gTasks[taskId].tFinalStanding) * 40;
+ gTasks[taskId].tState++;
}
- else if (gTasks[taskId].data[10] == 1)
+ else if (gTasks[taskId].tState == 1)
{
if (--gTasks[taskId].data[11] == -1)
{
- firstTileNum = gTasks[taskId].data[0] * 2 + 0x5043;
- WriteSequenceToBgTilemapBuffer(2, firstTileNum, 1, gTasks[taskId].data[1] * 3 + 5, 2, 1, 17, 1);
- WriteSequenceToBgTilemapBuffer(2, firstTileNum + 0x10, 1, gTasks[taskId].data[1] * 3 + 6, 2, 1, 17, 1);
- gUnknown_0203A034->unk0->unk5++;
+ firstTileNum = gTasks[taskId].tFinalStanding * 2 + 0x5043;
+ WriteSequenceToBgTilemapBuffer(2, firstTileNum, 1, gTasks[taskId].tMonIndex * 3 + 5, 2, 1, 17, 1);
+ WriteSequenceToBgTilemapBuffer(2, firstTileNum + 0x10, 1, gTasks[taskId].tMonIndex * 3 + 6, 2, 1, 17, 1);
+ sContestResults->data->numStandingsPrinted++;
DestroyTask(taskId);
PlaySE(SE_JYUNI);
}
}
}
-static void sub_80F74BC(u8 taskId)
+#undef tFinalStanding
+#undef tMonIndex
+#undef tState
+
+static void Task_StartHighlightWinnersBox(u8 taskId)
{
int i;
- for (i = 0; i < CONTESTANT_COUNT && gContestFinalStandings[i] != 0; i++)
- ;
-
- CopyToBgTilemapBufferRect_ChangePalette(2, i * 0xC0 + 0x100 + gUnknown_0203A034->unkC[2], 0, i * 3 + 4, 32, 3, 9);
+ GET_CONTEST_WINNER_ID(i);
+ CopyToBgTilemapBufferRect_ChangePalette(2, i * 0xC0 + 0x100 + sContestResults->tilemapBuffers[2], 0, i * 3 + 4, 32, 3, 9);
gTasks[taskId].data[10] = i;
gTasks[taskId].data[12] = 1;
- gTasks[taskId].func = sub_80F753C;
- gUnknown_0203A034->unk0->unk3 = taskId;
+ gTasks[taskId].func = Task_HighlightWinnersBox;
+ sContestResults->data->highlightWinnerTaskId = taskId;
}
-static void sub_80F753C(u8 taskId)
+static void Task_HighlightWinnersBox(u8 taskId)
{
if (++gTasks[taskId].data[11] == 1)
{
@@ -1780,7 +1825,7 @@ static void sub_80F753C(u8 taskId)
}
}
-static void sub_80F75A8(struct Sprite *sprite)
+static void SpriteCB_WinnerMonSlideIn(struct Sprite *sprite)
{
if (sprite->data[0] < 10)
{
@@ -1803,12 +1848,12 @@ static void sub_80F75A8(struct Sprite *sprite)
{
sprite->callback = SpriteCallbackDummy;
sprite->data[1] = 0;
- gUnknown_0203A034->unk0->unk6 = 1;
+ sContestResults->data->winnerMonSlidingState = SLIDING_MON_ENTERED;
}
}
}
-static void sub_80F7620(struct Sprite *sprite)
+static void SpriteCB_WinnerMonSlideOut(struct Sprite *sprite)
{
s16 delta = sprite->data[1] + 0x600;
sprite->pos1.x -= delta >> 8;
@@ -1817,32 +1862,32 @@ static void sub_80F7620(struct Sprite *sprite)
if (sprite->pos1.x < -32)
{
sprite->callback = SpriteCallbackDummy;
- sprite->invisible = 1;
- gUnknown_0203A034->unk0->unk6 = 2;
+ sprite->invisible = TRUE;
+ sContestResults->data->winnerMonSlidingState = SLIDING_MON_EXITED;
}
}
-static void sub_80F7670(u8 taskId)
+static void Task_CreateConfetti(u8 taskId)
{
if (++gTasks[taskId].data[0] == 5)
{
gTasks[taskId].data[0] = 0;
- if (gUnknown_0203A034->unk0->unk7 < 40)
+ if (sContestResults->data->confettiCount < 40)
{
- u8 spriteId = CreateSprite(&sSpriteTemplate_858D860, (Random() % 240) - 20, 44, 5);
+ u8 spriteId = CreateSprite(&sSpriteTemplate_Confetti, (Random() % 240) - 20, 44, 5);
gSprites[spriteId].data[0] = Random() % 512;
gSprites[spriteId].data[1] = (Random() % 24) + 16;
gSprites[spriteId].data[2] = (Random() % 256) + 48;
gSprites[spriteId].oam.tileNum += Random() % 17;
- gUnknown_0203A034->unk0->unk7++;
+ sContestResults->data->confettiCount++;
}
}
- if (gUnknown_0203A034->unk0->unk9)
+ if (sContestResults->data->destroyConfetti)
DestroyTask(taskId);
}
-static void sub_80F7768(struct Sprite *sprite)
+static void SpriteCB_Confetti(struct Sprite *sprite)
{
s16 delta;
@@ -1854,219 +1899,235 @@ static void sub_80F7768(struct Sprite *sprite)
sprite->data[4] &= 0xff;
sprite->pos1.y++;
- if (gUnknown_0203A034->unk0->unk9)
- sprite->invisible = 1;
+ if (sContestResults->data->destroyConfetti)
+ sprite->invisible = TRUE;
if (sprite->pos1.x > 248 || sprite->pos1.y > 116)
{
DestroySprite(sprite);
- gUnknown_0203A034->unk0->unk7--;
+ sContestResults->data->confettiCount--;
}
}
-static void sub_80F77E0(u8 monIndex, u8 numFrames)
+#define tMonIndex data[0]
+#define tNumFrames data[1]
+#define tSpecies data[2]
+#define tTimer data[10]
+#define tBounced data[11]
+
+static void BounceMonIconInBox(u8 monIndex, u8 numFrames)
{
- u8 taskId = CreateTask(sub_80F7824, 8);
- gTasks[taskId].data[0] = monIndex;
- gTasks[taskId].data[1] = numFrames;
- gTasks[taskId].data[2] = gContestMons[monIndex].species;
+ u8 taskId = CreateTask(Task_BounceMonIconInBox, 8);
+ gTasks[taskId].tMonIndex = monIndex;
+ gTasks[taskId].tNumFrames = numFrames;
+ gTasks[taskId].tSpecies = gContestMons[monIndex].species;
}
-static void sub_80F7824(u8 taskId)
+static void Task_BounceMonIconInBox(u8 taskId)
{
- u8 monIndex = gTasks[taskId].data[0];
- if (gTasks[taskId].data[10]++ == gTasks[taskId].data[1])
+ u8 monIndex = gTasks[taskId].tMonIndex;
+ if (gTasks[taskId].tTimer++ == gTasks[taskId].tNumFrames)
{
- gTasks[taskId].data[10] = 0;
- sub_80F69B8(gTasks[taskId].data[2], monIndex, gTasks[taskId].data[11], FALSE, gContestMons[monIndex].personality);
- gTasks[taskId].data[11] ^= 1;
+ gTasks[taskId].tTimer = 0;
+ LoadContestMonIcon(gTasks[taskId].tSpecies, monIndex, gTasks[taskId].tBounced, FALSE, gContestMons[monIndex].personality);
+ gTasks[taskId].tBounced ^= 1;
}
}
-static void sub_80F7880(void)
+#undef tMonIndex
+#undef tNumFrames
+#undef tSpecies
+#undef tTimer
+#undef tBounced
+
+static void CalculateContestantsResultData(void)
{
- int i, r4;
- u32 r1;
- s16 r2;
- s8 var;
+ int i, relativePoints;
+ u32 barLength;
+ s16 highestPoints;
+ s8 round2Points;
- r2 = gUnknown_02039F08[0];
- for (i = 1; i < 4; i++)
+ highestPoints = gContestMonTotalPoints[0];
+ for (i = 1; i < CONTESTANT_COUNT; i++)
{
- if (r2 < gUnknown_02039F08[i])
- r2 = gUnknown_02039F08[i];
+ if (highestPoints < gContestMonTotalPoints[i])
+ highestPoints = gContestMonTotalPoints[i];
}
- if (r2 < 0)
+ if (highestPoints < 0)
{
- r2 = gUnknown_02039F08[0];
- for (i = 1; i < 4; i++)
+ highestPoints = gContestMonTotalPoints[0];
+ for (i = 1; i < CONTESTANT_COUNT; i++)
{
- if (r2 > gUnknown_02039F08[i])
- r2 = gUnknown_02039F08[i];
+ if (highestPoints > gContestMonTotalPoints[i])
+ highestPoints = gContestMonTotalPoints[i];
}
}
for (i = 0; i < CONTESTANT_COUNT; i++)
{
- r4 = (gContestMonConditions[i] * 1000) / abs(r2);
- if (r4 % 10 > 4)
- r4 += 10;
- (*gUnknown_0203A034->unk4)[i].unk0 = r4 / 10;
+ relativePoints = (gContestMonConditions[i] * 1000) / abs(highestPoints);
+ if (relativePoints % 10 > 4)
+ relativePoints += 10;
+ (*sContestResults->monResults)[i].relativePreliminaryPoints = relativePoints / 10;
- r4 = (abs(gUnknown_02039F18[i]) * 1000) / abs(r2);
- if (r4 % 10 > 4)
- r4 += 10;
- (*gUnknown_0203A034->unk4)[i].unk4 = r4 / 10;
+ relativePoints = (abs(gContestMonRound2Points[i]) * 1000) / abs(highestPoints);
+ if (relativePoints % 10 > 4)
+ relativePoints += 10;
+ (*sContestResults->monResults)[i].relativeRound2Points = relativePoints / 10;
- if (gUnknown_02039F18[i] < 0)
- (*gUnknown_0203A034->unk4)[i].unk10 = 1;
+ if (gContestMonRound2Points[i] < 0)
+ (*sContestResults->monResults)[i].lostPoints = TRUE;
- r1 = ((*gUnknown_0203A034->unk4)[i].unk0 * 22528) / 100;
- if ((r1 & 0xFF) > 0x7F)
- r1 += 0x100;
- (*gUnknown_0203A034->unk4)[i].unk8 = r1 >> 8;
+ barLength = ((*sContestResults->monResults)[i].relativePreliminaryPoints * 0x5800) / 100;
+ if ((barLength & 0xFF) > 0x7F)
+ barLength += 0x100;
+ (*sContestResults->monResults)[i].barLengthPreliminary = barLength >> 8;
- r1 = ((*gUnknown_0203A034->unk4)[i].unk4 * 22528) / 100;
- if ((r1 & 0xFF) > 0x7F)
- r1 += 0x100;
- (*gUnknown_0203A034->unk4)[i].unkC = r1 >> 8;
+ barLength = ((*sContestResults->monResults)[i].relativeRound2Points * 0x5800) / 100;
+ if ((barLength & 0xFF) > 0x7F)
+ barLength += 0x100;
+ (*sContestResults->monResults)[i].barLengthRound2 = barLength >> 8;
- (*gUnknown_0203A034->unk4)[i].unk11 = sub_80F7310(i, 1);
- var = sub_80F7364(i, 1);
- (*gUnknown_0203A034->unk4)[i].unk12 = abs(var);
+ (*sContestResults->monResults)[i].numStars = GetNumPreliminaryPoints(i, TRUE);
+ round2Points = GetNumRound2Points(i, TRUE);
+ (*sContestResults->monResults)[i].numHearts = abs(round2Points);
if (gContestFinalStandings[i])
{
- s16 var1 = (*gUnknown_0203A034->unk4)[i].unk8;
- s16 var2 = (*gUnknown_0203A034->unk4)[i].unkC;
+ s16 barLengthPreliminary = (*sContestResults->monResults)[i].barLengthPreliminary;
+ s16 barLengthRound2 = (*sContestResults->monResults)[i].barLengthRound2;
- if ((*gUnknown_0203A034->unk4)[i].unk10)
- var2 *= -1;
+ if ((*sContestResults->monResults)[i].lostPoints)
+ barLengthRound2 *= -1;
- if (var1 + var2 == 88)
+ if (barLengthPreliminary + barLengthRound2 == MAX_BAR_LENGTH + 1)
{
- if (var2 > 0)
- (*gUnknown_0203A034->unk4)[i].unkC--;
- else if (var1 > 0)
- (*gUnknown_0203A034->unk4)[i].unk8--;
+ if (barLengthRound2 > 0)
+ (*sContestResults->monResults)[i].barLengthRound2--;
+ else if (barLengthPreliminary > 0)
+ (*sContestResults->monResults)[i].barLengthPreliminary--;
}
}
}
}
-static void sub_80F7A80(u8 arg0, u8 arg1)
+#define tMonId data[0]
+#define tTarget data[1]
+#define tDecreasing data[2]
+
+static void UpdateContestResultBars(bool8 isRound2, u8 numUpdates)
{
int i, taskId;
- u32 var0;
- u8 sp8 = 0, spC = 0;
+ u32 target;
+ u8 numIncreasing = 0, numDecreasing = 0;
- if (!arg0)
+ if (!isRound2)
{
- for (i = 0; i < 4; i++)
+ for (i = 0; i < CONTESTANT_COUNT; i++)
{
- u8 unk = (*gUnknown_0203A034->unk4)[i].unk11;
- if (arg1 < unk)
+ u8 numStars = (*sContestResults->monResults)[i].numStars;
+ if (numUpdates < numStars)
{
- FillBgTilemapBufferRect_Palette0(1, 0x60B3, ((19 + unk) - arg1) - 1, i * 3 + 5, 1, 1);
- taskId = CreateTask(sub_80F7CA8, 10);
+ FillBgTilemapBufferRect_Palette0(1, 0x60B3, ((19 + numStars) - numUpdates) - 1, i * 3 + 5, 1, 1);
+ taskId = CreateTask(Task_UpdateContestResultBar, 10);
- var0 = (((*gUnknown_0203A034->unk4)[i].unk8 << 16) / (*gUnknown_0203A034->unk4)[i].unk11) * (arg1 + 1);
- if ((var0 & 0xFFFF) > 0x7FFF)
- var0 += 0x10000;
+ target = (((*sContestResults->monResults)[i].barLengthPreliminary << 16) / (*sContestResults->monResults)[i].numStars) * (numUpdates + 1);
+ if ((target & 0xFFFF) > 0x7FFF)
+ target += 0x10000;
- gTasks[taskId].data[0] = i;
- gTasks[taskId].data[1] = var0 >> 16;
- gUnknown_0203A034->unk0->unk14++;
- sp8++;
+ gTasks[taskId].tMonId = i;
+ gTasks[taskId].tTarget = target >> 16;
+ sContestResults->data->numBarsUpdating++;
+ numIncreasing++;
}
}
}
else
{
- for (i = 0; i < 4; i++)
+ for (i = 0; i < CONTESTANT_COUNT; i++)
{
- s8 unk = (*gUnknown_0203A034->unk4)[i].unk12;
- u32 tile = (*gUnknown_0203A034->unk4)[i].unk10 ? 0x60A5 : 0x60A3;
- if (arg1 < unk)
+ s8 numHearts = (*sContestResults->monResults)[i].numHearts;
+ u32 tile = (*sContestResults->monResults)[i].lostPoints ? 0x60A5 : 0x60A3;
+ if (numUpdates < numHearts)
{
- FillBgTilemapBufferRect_Palette0(1, tile, ((19 + unk) - arg1) - 1, i * 3 + 6, 1, 1);
- taskId = CreateTask(sub_80F7CA8, 10);
+ FillBgTilemapBufferRect_Palette0(1, tile, ((19 + numHearts) - numUpdates) - 1, i * 3 + 6, 1, 1);
+ taskId = CreateTask(Task_UpdateContestResultBar, 10);
- var0 = (((*gUnknown_0203A034->unk4)[i].unkC << 16) / (*gUnknown_0203A034->unk4)[i].unk12) * (arg1 + 1);
- if ((var0 & 0xFFFF) > 0x7FFF)
- var0 += 0x10000;
+ target = (((*sContestResults->monResults)[i].barLengthRound2 << 16) / (*sContestResults->monResults)[i].numHearts) * (numUpdates + 1);
+ if ((target & 0xFFFF) > 0x7FFF)
+ target += 0x10000;
- gTasks[taskId].data[0] = i;
- if ((*gUnknown_0203A034->unk4)[i].unk10)
+ gTasks[taskId].tMonId = i;
+ if ((*sContestResults->monResults)[i].lostPoints)
{
- gTasks[taskId].data[2] = 1;
- spC++;
+ gTasks[taskId].tDecreasing = TRUE;
+ numDecreasing++;
}
else
{
- sp8++;
+ numIncreasing++;
}
- if ((*gUnknown_0203A034->unk4)[i].unk10)
- gTasks[taskId].data[1] = -(var0 >> 16) + (*gUnknown_0203A034->unk4)[i].unk8 ;
+ if ((*sContestResults->monResults)[i].lostPoints)
+ gTasks[taskId].tTarget = -(target >> 16) + (*sContestResults->monResults)[i].barLengthPreliminary;
else
- gTasks[taskId].data[1] = (var0 >> 16) + (*gUnknown_0203A034->unk4)[i].unk8;
+ gTasks[taskId].tTarget = (target >> 16) + (*sContestResults->monResults)[i].barLengthPreliminary;
- gUnknown_0203A034->unk0->unk14++;
+ sContestResults->data->numBarsUpdating++;
}
}
}
- if (spC)
+ if (numDecreasing)
PlaySE(SE_BOO);
- if (sp8)
+ if (numIncreasing)
PlaySE(SE_PIN);
}
-void sub_80F7CA8(u8 taskId)
+static void Task_UpdateContestResultBar(u8 taskId)
{
int i;
- u8 var0;
- u16 tileNum;
- bool32 r4 = FALSE;
- bool32 endTask = FALSE;
- u8 r6 = gTasks[taskId].data[0];
- s16 r7 = gTasks[taskId].data[1];
- s16 r12 = gTasks[taskId].data[2];
+ bool32 minMaxReached = FALSE;
+ bool32 targetReached = FALSE;
+ u8 monId = gTasks[taskId].tMonId;
+ s16 target = gTasks[taskId].tTarget;
+ s16 decreasing = gTasks[taskId].tDecreasing;
- if (r12)
+ if (decreasing)
{
- if (gUnknown_0203A034->unk0->unkC[r6] <= 0)
- r4 = TRUE;
+ if (sContestResults->data->unkC[monId] <= 0)
+ minMaxReached = TRUE;
}
else
{
- if (gUnknown_0203A034->unk0->unkC[r6] > 87)
- r4 = TRUE;
+ if (sContestResults->data->unkC[monId] > MAX_BAR_LENGTH)
+ minMaxReached = TRUE;
}
- if (gUnknown_0203A034->unk0->unkC[r6] == r7)
- endTask = TRUE;
+ if (sContestResults->data->unkC[monId] == target)
+ targetReached = TRUE;
- if (!endTask)
+ if (!targetReached)
{
- if (r4)
- gUnknown_0203A034->unk0->unkC[r6] = r7;
- else if (r12)
- gUnknown_0203A034->unk0->unkC[r6] = gUnknown_0203A034->unk0->unkC[r6] - 1;
+ if (minMaxReached)
+ sContestResults->data->unkC[monId] = target;
+ else if (decreasing)
+ sContestResults->data->unkC[monId] = sContestResults->data->unkC[monId] - 1;
else
- gUnknown_0203A034->unk0->unkC[r6] = gUnknown_0203A034->unk0->unkC[r6] + 1;
+ sContestResults->data->unkC[monId] = sContestResults->data->unkC[monId] + 1;
}
- if (!r4 && !endTask)
+ if (!minMaxReached && !targetReached)
{
+ u8 var0;
+ u16 tileNum;
for (i = 0; i < 11; i++)
{
- if (gUnknown_0203A034->unk0->unkC[r6] >= (i + 1) * 8)
+ if (sContestResults->data->unkC[monId] >= (i + 1) * 8)
var0 = 8;
- else if (gUnknown_0203A034->unk0->unkC[r6] >= i * 8)
- var0 = gUnknown_0203A034->unk0->unkC[r6] % 8;
+ else if (sContestResults->data->unkC[monId] >= i * 8)
+ var0 = sContestResults->data->unkC[monId] % 8;
else
var0 = 0;
@@ -2075,54 +2136,58 @@ void sub_80F7CA8(u8 taskId)
else
tileNum = 0x5057 + var0;
- FillBgTilemapBufferRect_Palette0(2, tileNum, i + 7, r6 * 3 + 6, 1, 1);
+ FillBgTilemapBufferRect_Palette0(2, tileNum, i + 7, monId * 3 + 6, 1, 1);
}
}
- if (endTask)
+ if (targetReached)
{
- gUnknown_0203A034->unk0->unk14--;
+ sContestResults->data->numBarsUpdating--;
DestroyTask(taskId);
}
}
-static void sub_80F7DF4(void)
+#undef tMonId
+#undef tTarget
+#undef tDecreasing
+
+static void AllocContestResults(void)
{
- gUnknown_0203A034 = AllocZeroed(sizeof(*gUnknown_0203A034));
- gUnknown_0203A034->unk0 = AllocZeroed(sizeof(*gUnknown_0203A034->unk0));
- gUnknown_0203A034->unk4 = AllocZeroed(sizeof(*gUnknown_0203A034->unk4));
- gUnknown_0203A034->unk8 = AllocZeroed(BG_SCREEN_SIZE);
- gUnknown_0203A034->unkC[0] = AllocZeroed(BG_SCREEN_SIZE);
- gUnknown_0203A034->unkC[1] = AllocZeroed(BG_SCREEN_SIZE);
- gUnknown_0203A034->unkC[2] = AllocZeroed(BG_SCREEN_SIZE);
- gUnknown_0203A034->unkC[3] = AllocZeroed(BG_SCREEN_SIZE);
- gUnknown_0203A034->unk1C = AllocZeroed(0x1000);
+ sContestResults = AllocZeroed(sizeof(*sContestResults));
+ sContestResults->data = AllocZeroed(sizeof(*sContestResults->data));
+ sContestResults->monResults = AllocZeroed(sizeof(*sContestResults->monResults));
+ sContestResults->unusedBg = AllocZeroed(BG_SCREEN_SIZE);
+ sContestResults->tilemapBuffers[0] = AllocZeroed(BG_SCREEN_SIZE);
+ sContestResults->tilemapBuffers[1] = AllocZeroed(BG_SCREEN_SIZE);
+ sContestResults->tilemapBuffers[2] = AllocZeroed(BG_SCREEN_SIZE);
+ sContestResults->tilemapBuffers[3] = AllocZeroed(BG_SCREEN_SIZE);
+ sContestResults->unused = AllocZeroed(0x1000);
AllocateMonSpritesGfx();
}
-static void sub_80F7E64(void)
+static void FreeContestResults(void)
{
- FREE_AND_SET_NULL(gUnknown_0203A034->unk0);
- FREE_AND_SET_NULL(gUnknown_0203A034->unk4);
- FREE_AND_SET_NULL(gUnknown_0203A034->unk8);
- FREE_AND_SET_NULL(gUnknown_0203A034->unkC[0]);
- FREE_AND_SET_NULL(gUnknown_0203A034->unkC[1]);
- FREE_AND_SET_NULL(gUnknown_0203A034->unkC[2]);
- FREE_AND_SET_NULL(gUnknown_0203A034->unkC[3]);
- FREE_AND_SET_NULL(gUnknown_0203A034->unk1C);
- FREE_AND_SET_NULL(gUnknown_0203A034);
+ FREE_AND_SET_NULL(sContestResults->data);
+ FREE_AND_SET_NULL(sContestResults->monResults);
+ FREE_AND_SET_NULL(sContestResults->unusedBg);
+ FREE_AND_SET_NULL(sContestResults->tilemapBuffers[0]);
+ FREE_AND_SET_NULL(sContestResults->tilemapBuffers[1]);
+ FREE_AND_SET_NULL(sContestResults->tilemapBuffers[2]);
+ FREE_AND_SET_NULL(sContestResults->tilemapBuffers[3]);
+ FREE_AND_SET_NULL(sContestResults->unused);
+ FREE_AND_SET_NULL(sContestResults);
FreeMonSpritesGfx();
}
-static void sub_80F7ED0(int windowId, u8 *str, int arg2)
+static void AddContestTextPrinter(int windowId, u8 *str, int x)
{
struct TextPrinterTemplate textPrinter;
textPrinter.currentChar = str;
textPrinter.windowId = windowId;
textPrinter.fontId = 7;
- textPrinter.x = arg2;
+ textPrinter.x = x;
textPrinter.y = 2;
- textPrinter.currentX = arg2;
+ textPrinter.currentX = x;
textPrinter.currentY = 2;
textPrinter.letterSpacing = 0;
textPrinter.lineSpacing = 0;
@@ -2274,20 +2339,14 @@ void GetContestMonCondition(void)
void GetContestWinnerId(void)
{
u8 i;
-
- for (i = 0; i < CONTESTANT_COUNT && gContestFinalStandings[i] != 0; i++)
- ;
-
+ GET_CONTEST_WINNER_ID(i);
gSpecialVar_0x8005 = i;
}
void BufferContestWinnerTrainerName(void)
{
u8 i;
-
- for (i = 0; i < CONTESTANT_COUNT && gContestFinalStandings[i] != 0; i++)
- ;
-
+ GET_CONTEST_WINNER_ID(i);
StringCopy(gStringVar3, gContestMons[i].trainerName);
sub_81DB5AC(gStringVar3);
}
@@ -2295,10 +2354,7 @@ void BufferContestWinnerTrainerName(void)
void BufferContestWinnerMonName(void)
{
u8 i;
-
- for (i = 0; i < CONTESTANT_COUNT && gContestFinalStandings[i] != 0; i++)
- ;
-
+ GET_CONTEST_WINNER_ID(i);
StringCopy(gStringVar1, gContestMons[i].nickname);
}
@@ -2328,19 +2384,19 @@ void BufferContestantMonSpecies(void)
gSpecialVar_0x8004 = gContestMons[gSpecialVar_0x8006].species;
}
-static void sub_80F8458(u8 taskId)
+static void Task_StartShowContestResults(u8 taskId)
{
if (!gPaletteFade.active)
{
DestroyTask(taskId);
- SetMainCallback2(sub_80F5B00);
+ SetMainCallback2(CB2_StartShowContestResults);
}
}
-void sub_80F8484(void)
+void ShowContestResults(void)
{
ScriptContext2_Enable();
- CreateTask(sub_80F8458, 10);
+ CreateTask(Task_StartShowContestResults, 10);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
}
@@ -2349,7 +2405,7 @@ void GetContestPlayerId(void)
gSpecialVar_0x8004 = gContestPlayerMonIndex;
}
-void sub_80F84C4(u8 taskId)
+void ContestLinkTransfer(u8 taskId)
{
u8 newTaskId;
ScriptContext2_Enable();
diff --git a/src/data/union_room.h b/src/data/union_room.h
index 8cb0bc8aa..704978766 100644
--- a/src/data/union_room.h
+++ b/src/data/union_room.h
@@ -50,27 +50,36 @@ const u8 sText_4PlayerMode[] = _("4-PLAYER\nMODE");
const u8 sText_5PlayerMode[] = _("5-PLAYER\nMODE");
static const u8 *const sPlayersNeededOrModeTexts[][5] = {
+ // 2 players required
{
sText_1PlayerNeeded,
sText_2PlayerMode
- }, {
+ },
+ // 4 players required
+ {
sText_3PlayersNeeded,
sText_2PlayersNeeded,
sText_1PlayerNeeded,
sText_4PlayerMode
- }, {
+ },
+ // 2-5 players required
+ {
sText_1PlayerNeeded,
sText_2PlayerMode,
sText_3PlayerMode,
sText_4PlayerMode,
sText_5PlayerMode
- }, {
+ },
+ // 3-5 players required
+ {
sText_2PlayersNeeded,
sText_1PlayerNeeded,
sText_3PlayerMode,
sText_4PlayerMode,
sText_5PlayerMode
- }, {
+ },
+ // 2-4 players required
+ {
sText_1PlayerNeeded,
sText_2PlayerMode,
sText_3PlayerMode,
@@ -90,15 +99,15 @@ ALIGNED(4) const u8 sText_OtherTrainerUnavailableNow[] = _("The other TRAINER do
ALIGNED(4) const u8 sText_CantTransmitTrainerTooFar[] = _("You can't transmit with a TRAINER\nwho is too far away.\p");
ALIGNED(4) const u8 sText_TrainersNotReadyYet[] = _("The other TRAINER(S) is/are not\nready yet.\p");
-const u8 *const sCantTransmitToTrainerTexts[] = {
- sText_CantTransmitTrainerTooFar,
- sText_TrainersNotReadyYet
+static const u8 *const sCantTransmitToTrainerTexts[] = {
+ [UR_TRADE_PLAYER_NOT_READY - 1] = sText_CantTransmitTrainerTooFar,
+ [UR_TRADE_PARTNER_NOT_READY - 1] = sText_TrainersNotReadyYet
};
ALIGNED(4) const u8 sText_ModeWithTheseMembersWillBeCanceled[] = _("The {STR_VAR_1} MODE with\nthese members will be canceled.{PAUSE 60}");
ALIGNED(4) const u8 sText_MemberNoLongerAvailable[] = _("There is a member who can no\nlonger remain available.\p");
-const u8 *const sPlayerUnavailableTexts[] = {
+static const u8 *const sPlayerUnavailableTexts[] = {
sText_OtherTrainerUnavailableNow,
sText_MemberNoLongerAvailable
};
@@ -111,17 +120,17 @@ ALIGNED(4) const u8 sText_AwaitingOtherMembers[] = _("{STR_VAR_1}!\nAwaiting oth
ALIGNED(4) const u8 sText_QuitBeingMember[] = _("Quit being a member?");
ALIGNED(4) const u8 sText_StoppedBeingMember[] = _("You stopped being a member.\p");
-const u8 *const sPlayerDisconnectedTexts[] = {
- NULL,
- sText_MemberNoLongerAvailable,
- sText_TrainerAppearsUnavailable,
- NULL,
- NULL,
- NULL,
- sText_PlayerRepliedNo,
- NULL,
- NULL,
- sText_StoppedBeingMember
+static const u8 *const sPlayerDisconnectedTexts[] = {
+ [RFU_STATUS_OK] = NULL,
+ [RFU_STATUS_FATAL_ERROR] = sText_MemberNoLongerAvailable,
+ [RFU_STATUS_CONNECTION_ERROR] = sText_TrainerAppearsUnavailable,
+ [RFU_STATUS_CHILD_SEND_COMPLETE] = NULL,
+ [RFU_STATUS_NEW_CHILD_DETECTED] = NULL,
+ [RFU_STATUS_JOIN_GROUP_OK] = NULL,
+ [RFU_STATUS_JOIN_GROUP_NO] = sText_PlayerRepliedNo,
+ [RFU_STATUS_WAIT_ACK_JOIN_GROUP] = NULL,
+ [RFU_STATUS_LEAVE_GROUP_NOTICE] = NULL,
+ [RFU_STATUS_LEAVE_GROUP] = sText_StoppedBeingMember
};
ALIGNED(4) const u8 sText_WirelessLinkEstablished[] = _("The WIRELESS COMMUNICATION\nSYSTEM link has been established.");
@@ -130,16 +139,16 @@ ALIGNED(4) const u8 sText_LinkWithFriendDropped[] = _("The link with your friend
ALIGNED(4) const u8 sText_PlayerRepliedNo2[] = _("{STR_VAR_1} replied, “No…”");
const u8 *const sLinkDroppedTexts[] = {
- NULL,
- sText_LinkWithFriendDropped,
- sText_LinkWithFriendDropped,
- NULL,
- NULL,
- NULL,
- sText_PlayerRepliedNo2,
- NULL,
- NULL,
- NULL
+ [RFU_STATUS_OK] = NULL,
+ [RFU_STATUS_FATAL_ERROR] = sText_LinkWithFriendDropped,
+ [RFU_STATUS_CONNECTION_ERROR] = sText_LinkWithFriendDropped,
+ [RFU_STATUS_CHILD_SEND_COMPLETE] = NULL,
+ [RFU_STATUS_NEW_CHILD_DETECTED] = NULL,
+ [RFU_STATUS_JOIN_GROUP_OK] = NULL,
+ [RFU_STATUS_JOIN_GROUP_NO] = sText_PlayerRepliedNo2,
+ [RFU_STATUS_WAIT_ACK_JOIN_GROUP] = NULL,
+ [RFU_STATUS_LEAVE_GROUP_NOTICE] = NULL,
+ [RFU_STATUS_LEAVE_GROUP] = NULL
};
ALIGNED(4) const u8 sText_DoYouWantXMode[] = _("Do you want the {STR_VAR_2}\nMODE?");
@@ -251,7 +260,7 @@ ALIGNED(4) const u8 sText_WaitForBattleFemale[] = _("A battle? Of course, but I
ALIGNED(4) const u8 sText_WaitForChatFemale[] = _("Did you want to chat?\nOkay, but please wait a moment.");
ALIGNED(4) const u8 sText_ShowTrainerCardFemale[] = _("As my introduction, I'll show you\nmy TRAINER CARD.");
-const u8 *const sText_WaitOrShowCardTexts[GENDER_COUNT][4] = {
+static const u8 *const sText_WaitOrShowCardTexts[GENDER_COUNT][4] = {
{
sText_WaitForBattleMale,
sText_WaitForChatMale,
@@ -274,7 +283,7 @@ ALIGNED(4) const u8 sText_TradeWillBeStarted[] = _("The trade will be started.{P
ALIGNED(4) const u8 sText_BattleWillBeStarted[] = _("The battle will be started.{PAUSE 60}");
ALIGNED(4) const u8 sText_EnteringChat[] = _("Entering the chat…{PAUSE 60}");
-const u8 *const sStartActivityTexts[][GENDER_COUNT][3] = {
+static const u8 *const sStartActivityTexts[][GENDER_COUNT][3] = {
{
{
sText_BattleWillBeStarted,
@@ -325,18 +334,21 @@ const u8 *const sIfYouWantToDoSomethingTexts[GENDER_COUNT] = {
ALIGNED(4) const u8 sText_TrainerBattleBusy[] = _("Whoops! Sorry, but I have to do\nsomething else.\lAnother time, okay?\p");
ALIGNED(4) const u8 sText_NeedTwoMonsOfLevel30OrLower1[] = _("If you want to battle, you need\ntwo POKéMON that are below\lLv. 30.\p");
ALIGNED(4) const u8 sText_NeedTwoMonsOfLevel30OrLower2[] = _("For a battle, you need two\nPOKéMON that are below Lv. 30.\p");
-ALIGNED(4) const u8 sText_DeclineBattleMale[] = _("Oh, all right.\nCome see me anytime, okay?\p");
-ALIGNED(4) const u8 stext_DeclineBattleFemale[] = _("Oh…\nPlease come by anytime.\p");
-static const u8 *const sDeclineBattleTexts[GENDER_COUNT] = {
- sText_DeclineBattleMale,
- stext_DeclineBattleFemale
+ALIGNED(4) const u8 sText_DeclineChatMale[] = _("Oh, all right.\nCome see me anytime, okay?\p");
+ALIGNED(4) const u8 stext_DeclineChatFemale[] = _("Oh…\nPlease come by anytime.\p");
+
+// Response from partner when player declines chat
+static const u8 *const sDeclineChatTexts[GENDER_COUNT] = {
+ sText_DeclineChatMale,
+ stext_DeclineChatFemale
};
ALIGNED(4) const u8 sText_ChatDeclinedMale[] = _("Oh, sorry!\nI just can't right this instant.\lLet's chat another time.\p");
ALIGNED(4) const u8 sText_ChatDeclinedFemale[] = _("Oh, I'm sorry.\nI have too much to do right now.\lLet's chat some other time.\p");
-const u8 *const sChatDeclinedTexts[GENDER_COUNT] = {
+// Response from partner when they decline chat
+static const u8 *const sChatDeclinedTexts[GENDER_COUNT] = {
sText_ChatDeclinedMale,
sText_ChatDeclinedFemale
};
@@ -484,8 +496,8 @@ static const u8 *const sChooseTrainerTexts[NUM_LINK_GROUP_TYPES] =
[LINK_GROUP_BERRY_PICKING] = sText_ChooseLeaderBerryPicking,
[LINK_GROUP_WONDER_CARD] = sText_ChooseTrainerToShareWonderCards,
[LINK_GROUP_WONDER_NEWS] = sText_ChooseTrainerToShareWonderNews,
- [LINK_GROUP_UNK_9] = NULL,
- [LINK_GROUP_UNK_10] = NULL,
+ [LINK_GROUP_UNION_ROOM_RESUME] = NULL,
+ [LINK_GROUP_UNION_ROOM_INIT] = NULL,
[LINK_GROUP_UNK_11] = NULL,
[LINK_GROUP_RECORD_CORNER] = sText_ChooseLeaderRecordCorner,
[LINK_GROUP_BERRY_BLENDER] = sText_ChooseLeaderBerryBlender,
@@ -567,39 +579,39 @@ const u8 *const sGladToMeetYouTexts[GENDER_COUNT] = {
ALIGNED(4) const u8 sText_FinishedCheckingPlayersTrainerCard[] = _("Finished checking {SPECIAL_F7 0x01}'s\nTRAINER CARD.{PAUSE 60}");
-const u8 *const sLinkGroupActivityTexts[] = {
- sText_EmptyString,
- sText_SingleBattle,
- sText_DoubleBattle,
- sText_MultiBattle,
- sText_PokemonTrades,
- sText_Chat,
- sText_WonderCards,
- sText_WonderNews,
- sText_Cards,
- sText_PokemonJump,
- sText_BerryCrush,
- sText_BerryPicking,
- sText_Search,
- sText_EmptyString,
- sText_BattleTowerOpenLv,
- sText_RecordCorner,
- sText_BerryBlender,
- sText_EmptyString,
- sText_EmptyString,
- sText_EmptyString,
- sText_EmptyString,
- sText_WonderCards,
- sText_WonderNews,
- sText_CoolContest,
- sText_BeautyContest,
- sText_CuteContest,
- sText_SmartContest,
- sText_ToughContest,
- sText_BattleTowerLv50
+static const u8 *const sLinkGroupActivityNameTexts[] = {
+ [ACTIVITY_NONE] = sText_EmptyString,
+ [ACTIVITY_BATTLE_SINGLE] = sText_SingleBattle,
+ [ACTIVITY_BATTLE_DOUBLE] = sText_DoubleBattle,
+ [ACTIVITY_BATTLE_MULTI] = sText_MultiBattle,
+ [ACTIVITY_TRADE] = sText_PokemonTrades,
+ [ACTIVITY_CHAT] = sText_Chat,
+ [ACTIVITY_WONDER_CARD] = sText_WonderCards,
+ [ACTIVITY_WONDER_NEWS] = sText_WonderNews,
+ [ACTIVITY_CARD] = sText_Cards,
+ [ACTIVITY_POKEMON_JUMP] = sText_PokemonJump,
+ [ACTIVITY_BERRY_CRUSH] = sText_BerryCrush,
+ [ACTIVITY_BERRY_PICK] = sText_BerryPicking,
+ [ACTIVITY_SEARCH] = sText_Search,
+ [ACTIVITY_SPIN_TRADE] = sText_EmptyString,
+ [ACTIVITY_BATTLE_TOWER_OPEN] = sText_BattleTowerOpenLv,
+ [ACTIVITY_RECORD_CORNER] = sText_RecordCorner,
+ [ACTIVITY_BERRY_BLENDER] = sText_BerryBlender,
+ [ACTIVITY_ACCEPT] = sText_EmptyString,
+ [ACTIVITY_DECLINE] = sText_EmptyString,
+ [ACTIVITY_NPCTALK] = sText_EmptyString,
+ [ACTIVITY_PLYRTALK] = sText_EmptyString,
+ [ACTIVITY_WONDER_CARD2] = sText_WonderCards,
+ [ACTIVITY_WONDER_NEWS2] = sText_WonderNews,
+ [ACTIVITY_CONTEST_COOL] = sText_CoolContest,
+ [ACTIVITY_CONTEST_BEAUTY] = sText_BeautyContest,
+ [ACTIVITY_CONTEST_CUTE] = sText_CuteContest,
+ [ACTIVITY_CONTEST_SMART] = sText_SmartContest,
+ [ACTIVITY_CONTEST_TOUGH] = sText_ToughContest,
+ [ACTIVITY_BATTLE_TOWER] = sText_BattleTowerLv50
};
-const struct WindowTemplate gUnknown_082F00BC = {
+static const struct WindowTemplate sWindowTemplate_BButtonCancel = {
.bg = 0x00,
.tilemapLeft = 0x00,
.tilemapTop = 0x00,
@@ -609,62 +621,69 @@ const struct WindowTemplate gUnknown_082F00BC = {
.baseBlock = 0x0008
};
-const u32 gUnknown_082F00C4[NUM_LINK_GROUP_TYPES] = {
- 0x0201,
- 0x0202,
- 0x0403,
- 0x0204,
- 0x2509,
- 0x250a,
- 0x350b,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x240f,
- 0x2410,
- 0x0000,
- 0x2417,
- 0x2418,
- 0x2419,
- 0x241a,
- 0x241b,
- 0x021c,
- 0x020e
+// Minimum and maximum number of players for a link group
+// A minimum of 0 means the min and max are equal
+#define LINK_GROUP_CAPACITY(min, max)(((min) << 12) | ((max) << 8))
+#define GROUP_MAX(capacity)(capacity & 0x0F)
+#define GROUP_MIN(capacity)(capacity >> 4)
+#define GROUP_MIN2(capacity)(capacity & 0xF0) // Unnecessary to have both, but needed to match
+
+static const u32 sLinkGroupToActivityAndCapacity[NUM_LINK_GROUP_TYPES] = {
+ [LINK_GROUP_SINGLE_BATTLE] = ACTIVITY_BATTLE_SINGLE | LINK_GROUP_CAPACITY(0, 2),
+ [LINK_GROUP_DOUBLE_BATTLE] = ACTIVITY_BATTLE_DOUBLE | LINK_GROUP_CAPACITY(0, 2),
+ [LINK_GROUP_MULTI_BATTLE] = ACTIVITY_BATTLE_MULTI | LINK_GROUP_CAPACITY(0, 4),
+ [LINK_GROUP_TRADE] = ACTIVITY_TRADE | LINK_GROUP_CAPACITY(0, 2),
+ [LINK_GROUP_POKEMON_JUMP] = ACTIVITY_POKEMON_JUMP | LINK_GROUP_CAPACITY(2, 5),
+ [LINK_GROUP_BERRY_CRUSH] = ACTIVITY_BERRY_CRUSH | LINK_GROUP_CAPACITY(2, 5),
+ [LINK_GROUP_BERRY_PICKING] = ACTIVITY_BERRY_PICK | LINK_GROUP_CAPACITY(3, 5),
+ [LINK_GROUP_WONDER_CARD] = ACTIVITY_NONE | LINK_GROUP_CAPACITY(0, 0),
+ [LINK_GROUP_WONDER_NEWS] = ACTIVITY_NONE | LINK_GROUP_CAPACITY(0, 0),
+ [LINK_GROUP_UNION_ROOM_RESUME] = ACTIVITY_NONE | LINK_GROUP_CAPACITY(0, 0),
+ [LINK_GROUP_UNION_ROOM_INIT] = ACTIVITY_NONE | LINK_GROUP_CAPACITY(0, 0),
+ [LINK_GROUP_UNK_11] = ACTIVITY_NONE | LINK_GROUP_CAPACITY(0, 0),
+ [LINK_GROUP_RECORD_CORNER] = ACTIVITY_RECORD_CORNER | LINK_GROUP_CAPACITY(2, 4),
+ [LINK_GROUP_BERRY_BLENDER] = ACTIVITY_BERRY_BLENDER | LINK_GROUP_CAPACITY(2, 4),
+ [LINK_GROUP_UNK_14] = ACTIVITY_NONE | LINK_GROUP_CAPACITY(0, 0),
+ [LINK_GROUP_COOL_CONTEST] = ACTIVITY_CONTEST_COOL | LINK_GROUP_CAPACITY(2, 4),
+ [LINK_GROUP_BEAUTY_CONTEST] = ACTIVITY_CONTEST_BEAUTY | LINK_GROUP_CAPACITY(2, 4),
+ [LINK_GROUP_CUTE_CONTEST] = ACTIVITY_CONTEST_CUTE | LINK_GROUP_CAPACITY(2, 4),
+ [LINK_GROUP_SMART_CONTEST] = ACTIVITY_CONTEST_SMART | LINK_GROUP_CAPACITY(2, 4),
+ [LINK_GROUP_TOUGH_CONTEST] = ACTIVITY_CONTEST_TOUGH | LINK_GROUP_CAPACITY(2, 4),
+ [LINK_GROUP_BATTLE_TOWER] = ACTIVITY_BATTLE_TOWER | LINK_GROUP_CAPACITY(0, 2),
+ [LINK_GROUP_BATTLE_TOWER_OPEN] = ACTIVITY_BATTLE_TOWER_OPEN | LINK_GROUP_CAPACITY(0, 2)
};
-const struct WindowTemplate gUnknown_082F011C = {
- .bg = 0x00,
- .tilemapLeft = 0x01,
- .tilemapTop = 0x03,
- .width = 0x0d,
- .height = 0x08,
- .paletteNum = 0x0f,
+static const struct WindowTemplate sWindowTemplate_PlayerList = {
+ .bg = 0,
+ .tilemapLeft = 1,
+ .tilemapTop = 3,
+ .width = 13,
+ .height = 8,
+ .paletteNum = 15,
.baseBlock = 0x0044
};
-const struct WindowTemplate gUnknown_082F0124 = {
- .bg = 0x00,
- .tilemapLeft = 0x01,
- .tilemapTop = 0x03,
- .width = 0x0d,
- .height = 0x0a,
- .paletteNum = 0x0f,
+static const struct WindowTemplate sWindowTemplate_5PlayerList = {
+ .bg = 0,
+ .tilemapLeft = 1,
+ .tilemapTop = 3,
+ .width = 13,
+ .height = 10,
+ .paletteNum = 15,
.baseBlock = 0x0044
};
-const struct WindowTemplate gUnknown_082F012C = {
- .bg = 0x00,
- .tilemapLeft = 0x10,
- .tilemapTop = 0x03,
- .width = 0x07,
- .height = 0x04,
- .paletteNum = 0x0f,
+static const struct WindowTemplate sWindowTemplate_NumPlayerMode = {
+ .bg = 0,
+ .tilemapLeft = 16,
+ .tilemapTop = 3,
+ .width = 7,
+ .height = 4,
+ .paletteNum = 15,
.baseBlock = 0x00c6
};
-const struct ListMenuItem gUnknown_082F0134[] = {
+static const struct ListMenuItem sPossibleGroupMembersListMenuItems[] = {
{ sText_EmptyString, 0 },
{ sText_EmptyString, 1 },
{ sText_EmptyString, 2 },
@@ -672,11 +691,11 @@ const struct ListMenuItem gUnknown_082F0134[] = {
{ sText_EmptyString, 4 }
};
-const struct ListMenuTemplate gUnknown_082F015C = {
- .items = gUnknown_082F0134,
+static const struct ListMenuTemplate sListMenuTemplate_PossibleGroupMembers = {
+ .items = sPossibleGroupMembersListMenuItems,
.moveCursorFunc = NULL,
- .itemPrintFunc = sub_8013278,
- .totalItems = 5,
+ .itemPrintFunc = ItemPrintFunc_PossibleGroupMembers,
+ .totalItems = ARRAY_COUNT(sPossibleGroupMembersListMenuItems),
.maxShowed = 5,
.windowId = 0,
.header_X = 0,
@@ -732,11 +751,11 @@ const struct ListMenuItem gUnknown_082F0184[] = {
{ sText_EmptyString, 15 }
};
-const struct ListMenuTemplate gUnknown_082F0204 = {
+static const struct ListMenuTemplate sListMenuTemplate_UnionRoomGroups = {
.items = gUnknown_082F0184,
.moveCursorFunc = ListMenuDefaultCursorMoveFunc,
- .itemPrintFunc = sub_8013DF4,
- .totalItems = 16,
+ .itemPrintFunc = ListMenuItemPrintFunc_UnionRoomGroups,
+ .totalItems = ARRAY_COUNT(gUnknown_082F0184),
.maxShowed = 5,
.windowId = 0,
.header_X = 0,
@@ -753,7 +772,7 @@ const struct ListMenuTemplate gUnknown_082F0204 = {
.cursorKind = 0
};
-const struct WindowTemplate gUnknown_082F021C = {
+static const struct WindowTemplate sWindowTemplate_InviteToActivity = {
.bg = 0x00,
.tilemapLeft = 0x14,
.tilemapTop = 0x05,
@@ -770,11 +789,11 @@ const struct ListMenuItem gUnknown_082F0224[] = {
{ sText_Exit, 0x040 }
};
-const struct ListMenuTemplate gUnknown_082F0244 = {
+static const struct ListMenuTemplate sListMenuTemplate_InviteToActivity = {
.items = gUnknown_082F0224,
.moveCursorFunc = ListMenuDefaultCursorMoveFunc,
.itemPrintFunc = NULL,
- .totalItems = 4,
+ .totalItems = ARRAY_COUNT(gUnknown_082F0224),
.maxShowed = 4,
.windowId = 0,
.header_X = 0,
@@ -791,7 +810,7 @@ const struct ListMenuTemplate gUnknown_082F0244 = {
.cursorKind = 0
};
-const struct WindowTemplate gUnknown_082F025C = {
+static const struct WindowTemplate sWindowTemplate_RegisterForTrade = {
.bg = 0x00,
.tilemapLeft = 0x12,
.tilemapTop = 0x07,
@@ -801,17 +820,17 @@ const struct WindowTemplate gUnknown_082F025C = {
.baseBlock = 0x0001
};
-const struct ListMenuItem gUnknown_082F0264[] = {
+static const struct ListMenuItem sRegisterForTradeListMenuItems[] = {
{ gText_Register, 1 },
{ sText_Info, 2 },
{ sText_Exit, 3 }
};
-const struct ListMenuTemplate gUnknown_082F027C = {
- .items = gUnknown_082F0264,
+static const struct ListMenuTemplate sListMenuTemplate_RegisterForTrade = {
+ .items = sRegisterForTradeListMenuItems,
.moveCursorFunc = ListMenuDefaultCursorMoveFunc,
.itemPrintFunc = NULL,
- .totalItems = 3,
+ .totalItems = ARRAY_COUNT(sRegisterForTradeListMenuItems),
.maxShowed = 3,
.windowId = 0,
.header_X = 0,
@@ -838,7 +857,7 @@ const struct WindowTemplate gUnknown_082F0294 = {
.baseBlock = 0x0001
};
-static const struct ListMenuItem sTradingBoardTypes[] = {
+static const struct ListMenuItem sTradingBoardTypes[NUMBER_OF_MON_TYPES] = {
{ gTypeNames[TYPE_NORMAL], TYPE_NORMAL },
{ gTypeNames[TYPE_FIRE], TYPE_FIRE },
{ gTypeNames[TYPE_WATER], TYPE_WATER },
@@ -856,14 +875,14 @@ static const struct ListMenuItem sTradingBoardTypes[] = {
{ gTypeNames[TYPE_DRAGON], TYPE_DRAGON },
{ gTypeNames[TYPE_STEEL], TYPE_STEEL },
{ gTypeNames[TYPE_DARK], TYPE_DARK },
- { sText_Exit, NUMBER_OF_MON_TYPES }
+ { sText_Exit, NUMBER_OF_MON_TYPES }
};
-const struct ListMenuTemplate sMenuTemplate_TradingBoardRequestType = {
+static const struct ListMenuTemplate sMenuTemplate_TradingBoardRequestType = {
.items = sTradingBoardTypes,
.moveCursorFunc = ListMenuDefaultCursorMoveFunc,
.itemPrintFunc = NULL,
- .totalItems = NUMBER_OF_MON_TYPES,
+ .totalItems = ARRAY_COUNT(sTradingBoardTypes),
.maxShowed = 6,
.windowId = 0,
.header_X = 0,
@@ -880,7 +899,7 @@ const struct ListMenuTemplate sMenuTemplate_TradingBoardRequestType = {
.cursorKind = 0
};
-const struct WindowTemplate gUnknown_082F0344 = {
+static const struct WindowTemplate sWindowTemplate_TradingBoard = {
.bg = 0x00,
.tilemapLeft = 0x01,
.tilemapTop = 0x01,
@@ -900,7 +919,7 @@ const struct WindowTemplate gUnknown_082F034C = {
.baseBlock = 0x0039
};
-const struct ListMenuItem gUnknown_082F0354[] = {
+static const struct ListMenuItem sTradeBoardListMenuItems[] = {
{ sText_EmptyString, -3 },
{ sText_EmptyString, 0 },
{ sText_EmptyString, 1 },
@@ -913,11 +932,11 @@ const struct ListMenuItem gUnknown_082F0354[] = {
{ sText_Exit2, 8 }
};
-const struct ListMenuTemplate gUnknown_082F03A4 = {
- .items = gUnknown_082F0354,
+static const struct ListMenuTemplate sTradeBoardListMenuTemplate = {
+ .items = sTradeBoardListMenuItems,
.moveCursorFunc = ListMenuDefaultCursorMoveFunc,
- .itemPrintFunc = sub_8017BE8,
- .totalItems = 10,
+ .itemPrintFunc = TradeBoardListMenuItemPrintFunc,
+ .totalItems = ARRAY_COUNT(sTradeBoardListMenuItems),
.maxShowed = 6,
.windowId = 0,
.header_X = 0,
@@ -944,7 +963,7 @@ const struct WindowTemplate UnrefWindowTemplate_082F03B4 = {
.baseBlock = 0x0039
};
-const struct ListMenuItem gUnknown_082F03C4[] = {
+static const struct ListMenuItem sEmptyListMenuItems[] = {
{ sText_EmptyString, 0 },
{ sText_EmptyString, 1 },
{ sText_EmptyString, 2 },
@@ -963,11 +982,12 @@ const struct ListMenuItem gUnknown_082F03C4[] = {
{ sText_EmptyString, 15 }
};
-const struct ListMenuTemplate UnrefListMenuTemplate_082F0444 = {
- .items = gUnknown_082F03C4,
+// Unused
+static const struct ListMenuTemplate sUnknownListMenuTemplate = {
+ .items = sEmptyListMenuItems,
.moveCursorFunc = ListMenuDefaultCursorMoveFunc,
.itemPrintFunc = nullsub_14,
- .totalItems = 16,
+ .totalItems = ARRAY_COUNT(sEmptyListMenuItems),
.maxShowed = 4,
.windowId = 0,
.header_X = 0,
@@ -984,78 +1004,100 @@ const struct ListMenuTemplate UnrefListMenuTemplate_082F0444 = {
.cursorKind = 0
};
-const struct UnkStruct_Shared gUnknown_082F045C = {0};
-
-ALIGNED(4) const u8 gUnknown_082F0474[] = {0x01, 0xff};
-ALIGNED(4) const u8 gUnknown_082F0478[] = {0x02, 0xff};
-ALIGNED(4) const u8 gUnknown_082F047C[] = {0x03, 0xff};
-ALIGNED(4) const u8 gUnknown_082F0480[] = {0x04, 0xff};
-ALIGNED(4) const u8 gUnknown_082F0484[] = {0x09, 0xff};
-ALIGNED(4) const u8 gUnknown_082F0488[] = {0x0a, 0xff};
-ALIGNED(4) const u8 gUnknown_082F048C[] = {0x0b, 0xff};
-ALIGNED(4) const u8 gUnknown_082F0490[] = {0x15, 0xff};
-ALIGNED(4) const u8 gUnknown_082F0494[] = {0x16, 0xff};
-ALIGNED(4) const u8 gUnknown_082F0498[] = {0x40, 0x41, 0x44, 0x45, 0x48, 0x51, 0x52, 0x53, 0x54, 0xff};
-ALIGNED(4) const u8 gUnknown_082F04A4[] = {0x0c, 0xff};
-ALIGNED(4) const u8 gUnknown_082F04A8[] = {0x01, 0x02, 0x03, 0x04, 0x09, 0x0a, 0x0b, 0x15, 0x16, 0x0d, 0xff};
-ALIGNED(4) const u8 gUnknown_082F04B4[] = {0x0f, 0xff};
-ALIGNED(4) const u8 gUnknown_082F04B8[] = {0x10, 0xff};
-ALIGNED(4) const u8 gUnknown_082F04BC[] = {0x17, 0xff};
-ALIGNED(4) const u8 gUnknown_082F04C0[] = {0x18, 0xff};
-ALIGNED(4) const u8 gUnknown_082F04C4[] = {0x19, 0xff};
-ALIGNED(4) const u8 gUnknown_082F04C8[] = {0x1a, 0xff};
-ALIGNED(4) const u8 gUnknown_082F04CC[] = {0x1b, 0xff};
-ALIGNED(4) const u8 gUnknown_082F04D0[] = {0x1c, 0xff};
-ALIGNED(4) const u8 gUnknown_082F04D4[] = {0x0e, 0xff};
-
-const u8 *const gUnknown_082F04D8[NUM_LINK_GROUP_TYPES] = {
- gUnknown_082F0474,
- gUnknown_082F0478,
- gUnknown_082F047C,
- gUnknown_082F0480,
- gUnknown_082F0484,
- gUnknown_082F0488,
- gUnknown_082F048C,
- gUnknown_082F0490,
- gUnknown_082F0494,
- gUnknown_082F0498,
- gUnknown_082F04A4,
- gUnknown_082F04A8,
- gUnknown_082F04B4,
- gUnknown_082F04B8,
- NULL,
- gUnknown_082F04BC,
- gUnknown_082F04C0,
- gUnknown_082F04C4,
- gUnknown_082F04C8,
- gUnknown_082F04CC,
- gUnknown_082F04D0,
- gUnknown_082F04D4
+const struct WirelessGnameUnamePair sWirelessGnameUnamePair_Dummy = {0};
+
+ALIGNED(4) const u8 sAcceptedActivityIds_SingleBattle[] = {ACTIVITY_BATTLE_SINGLE, 0xff};
+ALIGNED(4) const u8 sAcceptedActivityIds_DoubleBattle[] = {ACTIVITY_BATTLE_DOUBLE, 0xff};
+ALIGNED(4) const u8 sAcceptedActivityIds_MultiBattle[] = {ACTIVITY_BATTLE_MULTI, 0xff};
+ALIGNED(4) const u8 sAcceptedActivityIds_Trade[] = {ACTIVITY_TRADE, 0xff};
+ALIGNED(4) const u8 sAcceptedActivityIds_PokemonJump[] = {ACTIVITY_POKEMON_JUMP, 0xff};
+ALIGNED(4) const u8 sAcceptedActivityIds_BerryCrush[] = {ACTIVITY_BERRY_CRUSH, 0xff};
+ALIGNED(4) const u8 sAcceptedActivityIds_BerryPicking[] = {ACTIVITY_BERRY_PICK, 0xff};
+ALIGNED(4) const u8 sAcceptedActivityIds_WonderCard[] = {ACTIVITY_WONDER_CARD2, 0xff};
+ALIGNED(4) const u8 sAcceptedActivityIds_WonderNews[] = {ACTIVITY_WONDER_NEWS2, 0xff};
+ALIGNED(4) const u8 sAcceptedActivityIds_Resume[] = {
+ IN_UNION_ROOM | ACTIVITY_NONE,
+ IN_UNION_ROOM | ACTIVITY_BATTLE_SINGLE,
+ IN_UNION_ROOM | ACTIVITY_TRADE,
+ IN_UNION_ROOM | ACTIVITY_CHAT,
+ IN_UNION_ROOM | ACTIVITY_CARD,
+ IN_UNION_ROOM | ACTIVITY_ACCEPT,
+ IN_UNION_ROOM | ACTIVITY_DECLINE,
+ IN_UNION_ROOM | ACTIVITY_NPCTALK,
+ IN_UNION_ROOM | ACTIVITY_PLYRTALK,
+ 0xff
+};
+ALIGNED(4) const u8 sAcceptedActivityIds_Init[] = {ACTIVITY_SEARCH, 0xff};
+ALIGNED(4) const u8 sAcceptedActivityIds_Unk11[] = {
+ ACTIVITY_BATTLE_SINGLE,
+ ACTIVITY_BATTLE_DOUBLE,
+ ACTIVITY_BATTLE_MULTI,
+ ACTIVITY_TRADE,
+ ACTIVITY_POKEMON_JUMP,
+ ACTIVITY_BERRY_CRUSH,
+ ACTIVITY_BERRY_PICK,
+ ACTIVITY_WONDER_CARD2,
+ ACTIVITY_WONDER_NEWS2,
+ ACTIVITY_SPIN_TRADE,
+ 0xff
+};
+ALIGNED(4) const u8 sAcceptedActivityIds_RecordCorner[] = {ACTIVITY_RECORD_CORNER, 0xff};
+ALIGNED(4) const u8 sAcceptedActivityIds_BerryBlender[] = {ACTIVITY_BERRY_BLENDER, 0xff};
+ALIGNED(4) const u8 sAcceptedActivityIds_CoolContest[] = {ACTIVITY_CONTEST_COOL, 0xff};
+ALIGNED(4) const u8 sAcceptedActivityIds_BeautyContest[] = {ACTIVITY_CONTEST_BEAUTY, 0xff};
+ALIGNED(4) const u8 sAcceptedActivityIds_CuteContest[] = {ACTIVITY_CONTEST_CUTE, 0xff};
+ALIGNED(4) const u8 sAcceptedActivityIds_SmartContest[] = {ACTIVITY_CONTEST_SMART, 0xff};
+ALIGNED(4) const u8 sAcceptedActivityIds_ToughContest[] = {ACTIVITY_CONTEST_TOUGH, 0xff};
+ALIGNED(4) const u8 sAcceptedActivityIds_BattleTower[] = {ACTIVITY_BATTLE_TOWER, 0xff};
+ALIGNED(4) const u8 sAcceptedActivityIds_BattleTowerOpen[] = {ACTIVITY_BATTLE_TOWER_OPEN, 0xff};
+
+const u8 *const sAcceptedActivityIds[NUM_LINK_GROUP_TYPES] = {
+ [LINK_GROUP_SINGLE_BATTLE] = sAcceptedActivityIds_SingleBattle,
+ [LINK_GROUP_DOUBLE_BATTLE] = sAcceptedActivityIds_DoubleBattle,
+ [LINK_GROUP_MULTI_BATTLE] = sAcceptedActivityIds_MultiBattle,
+ [LINK_GROUP_TRADE] = sAcceptedActivityIds_Trade,
+ [LINK_GROUP_POKEMON_JUMP] = sAcceptedActivityIds_PokemonJump,
+ [LINK_GROUP_BERRY_CRUSH] = sAcceptedActivityIds_BerryCrush,
+ [LINK_GROUP_BERRY_PICKING] = sAcceptedActivityIds_BerryPicking,
+ [LINK_GROUP_WONDER_CARD] = sAcceptedActivityIds_WonderCard,
+ [LINK_GROUP_WONDER_NEWS] = sAcceptedActivityIds_WonderNews,
+ [LINK_GROUP_UNION_ROOM_RESUME] = sAcceptedActivityIds_Resume,
+ [LINK_GROUP_UNION_ROOM_INIT] = sAcceptedActivityIds_Init,
+ [LINK_GROUP_UNK_11] = sAcceptedActivityIds_Unk11,
+ [LINK_GROUP_RECORD_CORNER] = sAcceptedActivityIds_RecordCorner,
+ [LINK_GROUP_BERRY_BLENDER] = sAcceptedActivityIds_BerryBlender,
+ [LINK_GROUP_UNK_14] = NULL,
+ [LINK_GROUP_COOL_CONTEST] = sAcceptedActivityIds_CoolContest,
+ [LINK_GROUP_BEAUTY_CONTEST] = sAcceptedActivityIds_BeautyContest,
+ [LINK_GROUP_CUTE_CONTEST] = sAcceptedActivityIds_CuteContest,
+ [LINK_GROUP_SMART_CONTEST] = sAcceptedActivityIds_SmartContest,
+ [LINK_GROUP_TOUGH_CONTEST] = sAcceptedActivityIds_ToughContest,
+ [LINK_GROUP_BATTLE_TOWER] = sAcceptedActivityIds_BattleTower,
+ [LINK_GROUP_BATTLE_TOWER_OPEN] = sAcceptedActivityIds_BattleTowerOpen
};
-// Link group type to ID for gUnknown_02022C2C
-const u8 gUnknown_082F0530[NUM_LINK_GROUP_TYPES + 2] =
+static const u8 sLinkGroupToURoomActivity[NUM_LINK_GROUP_TYPES + 2] =
{
- 0x01,
- 0x02,
- 0x03,
- 0x04,
- 0x09,
- 0x0a,
- 0x0b,
- 0x15,
- 0x16,
- 0x00,
- 0x00,
- 0x00,
- 0x0f,
- 0x10,
- 0x00,
- 0x17,
- 0x18,
- 0x19,
- 0x1a,
- 0x1b,
- 0x1c,
- 0x0e
+ [LINK_GROUP_SINGLE_BATTLE] = ACTIVITY_BATTLE_SINGLE,
+ [LINK_GROUP_DOUBLE_BATTLE] = ACTIVITY_BATTLE_DOUBLE,
+ [LINK_GROUP_MULTI_BATTLE] = ACTIVITY_BATTLE_MULTI,
+ [LINK_GROUP_TRADE] = ACTIVITY_TRADE,
+ [LINK_GROUP_POKEMON_JUMP] = ACTIVITY_POKEMON_JUMP,
+ [LINK_GROUP_BERRY_CRUSH] = ACTIVITY_BERRY_CRUSH,
+ [LINK_GROUP_BERRY_PICKING] = ACTIVITY_BERRY_PICK,
+ [LINK_GROUP_WONDER_CARD] = ACTIVITY_WONDER_CARD2,
+ [LINK_GROUP_WONDER_NEWS] = ACTIVITY_WONDER_NEWS2,
+ [LINK_GROUP_UNION_ROOM_RESUME] = ACTIVITY_NONE,
+ [LINK_GROUP_UNION_ROOM_INIT] = ACTIVITY_NONE,
+ [LINK_GROUP_UNK_11] = ACTIVITY_NONE,
+ [LINK_GROUP_RECORD_CORNER] = ACTIVITY_RECORD_CORNER,
+ [LINK_GROUP_BERRY_BLENDER] = ACTIVITY_BERRY_BLENDER,
+ [LINK_GROUP_UNK_14] = ACTIVITY_NONE,
+ [LINK_GROUP_COOL_CONTEST] = ACTIVITY_CONTEST_COOL,
+ [LINK_GROUP_BEAUTY_CONTEST] = ACTIVITY_CONTEST_BEAUTY,
+ [LINK_GROUP_CUTE_CONTEST] = ACTIVITY_CONTEST_CUTE,
+ [LINK_GROUP_SMART_CONTEST] = ACTIVITY_CONTEST_SMART,
+ [LINK_GROUP_TOUGH_CONTEST] = ACTIVITY_CONTEST_TOUGH,
+ [LINK_GROUP_BATTLE_TOWER] = ACTIVITY_BATTLE_TOWER,
+ [LINK_GROUP_BATTLE_TOWER_OPEN] = ACTIVITY_BATTLE_TOWER_OPEN
};
diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c
index 262b7d111..3ca7a1cf7 100644
--- a/src/dodrio_berry_picking.c
+++ b/src/dodrio_berry_picking.c
@@ -450,7 +450,7 @@ static void (*const gUnknown_082F7AF4[])(void) =
};
// code
-void sub_802493C(u16 a0, void (*callback)(void))
+void StartDodrioBerryPicking(u16 a0, void (*callback)(void))
{
gUnknown_03000DB0 = FALSE;
@@ -832,9 +832,9 @@ static void sub_8025158(void)
static bool32 sub_8025170(void)
{
- u8 r4 = GetBlockReceivedStatus();
- u8 r0 = sub_800A9D8();
- if (r4 == r0)
+ u8 recvStatus = GetBlockReceivedStatus();
+ u8 playerFlags = GetLinkPlayerCountAsBitFlags();
+ if (recvStatus == playerFlags)
{
ResetBlockReceivedFlags();
return TRUE;
@@ -4483,12 +4483,12 @@ static void sub_802A380(void)
case 2:
if (!IsDma3ManagerBusyWithBgCopy())
{
- CreateTask(sub_8153688, 0);
+ CreateTask(Task_LinkSave, 0);
gUnknown_02022CF8->state++;
}
break;
case 3:
- if (!FuncIsActiveTask(sub_8153688))
+ if (!FuncIsActiveTask(Task_LinkSave))
gUnknown_02022CF8->state++;
break;
default:
diff --git a/src/easy_chat.c b/src/easy_chat.c
index 1bdb3fdc0..2a4c49213 100644
--- a/src/easy_chat.c
+++ b/src/easy_chat.c
@@ -5273,12 +5273,17 @@ void InitEasyChatPhrases(void)
gSaveBlock1Ptr->mail[i].words[j] = 0xFFFF;
}
+#ifndef UBFIX
// BUG: This is supposed to clear 64 bits, but this loop is clearing 64 bytes.
// However, this bug has no resulting effect on gameplay because only the
// Mauville old man data is corrupted, which is initialized directly after
// this function is called when starting a new game.
for (i = 0; i < 64; i++)
gSaveBlock1Ptr->additionalPhrases[i] = 0;
+#else
+ for (i = 0; i < ARRAY_COUNT(gSaveBlock1Ptr->additionalPhrases); i++)
+ gSaveBlock1Ptr->additionalPhrases[i] = 0;
+#endif
}
static bool8 sub_811F28C(void)
diff --git a/src/ereader_screen.c b/src/ereader_screen.c
index 754bbe445..26f7eb679 100755
--- a/src/ereader_screen.c
+++ b/src/ereader_screen.c
@@ -85,10 +85,10 @@ static u8 sub_81D4DE8(struct Unk03006370 *arg0)
return var0;
}
-static void sub_81D4E30(void)
+static void OpenEReaderLink(void)
{
memset(gDecompressionBuffer, 0, 0x2000);
- gLinkType = LINKTYPE_0x5503;
+ gLinkType = LINKTYPE_EREADER;
OpenLink();
SetSuppressLinkErrorMessage(TRUE);
}
@@ -255,7 +255,7 @@ static void sub_81D5084(u8 taskId)
data->unk8 = 1;
break;
case 1:
- sub_81D4E30();
+ OpenEReaderLink();
sub_81D505C(&data->unk0);
data->unk8 = 2;
break;
@@ -285,7 +285,7 @@ static void sub_81D5084(u8 taskId)
case 5:
if (sub_81D5064(&data->unk0, 90))
{
- sub_81D4E30();
+ OpenEReaderLink();
data->unk8 = 6;
}
else if (gMain.newKeys & B_BUTTON)
@@ -319,7 +319,7 @@ static void sub_81D5084(u8 taskId)
else if (sub_81D5064(&data->unk0, 10))
{
CloseLink();
- sub_81D4E30();
+ OpenEReaderLink();
sub_81D505C(&data->unk0);
}
break;
@@ -360,7 +360,7 @@ static void sub_81D5084(u8 taskId)
data->unk8 = 12;
break;
case 12:
- sub_81D4E30();
+ OpenEReaderLink();
AddTextPrinterToWindow1(gJPText_AllowEReaderToLoadCard);
data->unk8 = 13;
break;
diff --git a/src/event_object_lock.c b/src/event_object_lock.c
index b728f7774..67652a99b 100644
--- a/src/event_object_lock.c
+++ b/src/event_object_lock.c
@@ -96,7 +96,7 @@ void ScriptUnfreezeObjectEvents(void)
UnfreezeObjectEvents();
}
-void sub_8098524(void)
+void UnionRoom_UnlockPlayerAndChatPartner(void)
{
u8 playerObjectId;
diff --git a/src/event_object_movement.c b/src/event_object_movement.c
index d6a2fe2ec..ad839e006 100644
--- a/src/event_object_movement.c
+++ b/src/event_object_movement.c
@@ -28,6 +28,7 @@
#include "constants/items.h"
#include "constants/mauville_old_man.h"
#include "constants/trainer_types.h"
+#include "constants/union_room.h"
// this file was known as evobjmv.c in Game Freak's original source
@@ -97,7 +98,7 @@ static void DoRippleFieldEffect(struct ObjectEvent*, struct Sprite*);
static void DoGroundEffects_OnSpawn(struct ObjectEvent*, struct Sprite*);
static void DoGroundEffects_OnBeginStep(struct ObjectEvent*, struct Sprite*);
static void DoGroundEffects_OnFinishStep(struct ObjectEvent*, struct Sprite*);
-static void sub_8097D68(struct Sprite*);
+static void UpdateObjectEventSpritePosition(struct Sprite*);
static void ApplyLevitateMovement(u8);
static bool8 MovementType_Disguise_Callback(struct ObjectEvent *, struct Sprite *);
static bool8 MovementType_Hidden_Callback(struct ObjectEvent *, struct Sprite *);
@@ -129,7 +130,7 @@ static struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8 localId,
static void ClearObjectEventMovement(struct ObjectEvent *, struct Sprite *);
static void ObjectEventSetSingleMovement(struct ObjectEvent *, struct Sprite *, u8);
static void oamt_npc_ministep_reset(struct Sprite *, u8, u8);
-static void UpdateObjectEventSpriteSubpriorityAndVisibility(struct Sprite *);
+static void UpdateObjectEventSprite(struct Sprite *);
const u8 gReflectionEffectPaletteMap[] = {1, 1, 6, 7, 8, 9, 6, 7, 8, 9, 11, 11, 0, 0, 0, 0};
@@ -1522,7 +1523,9 @@ u8 AddPseudoObjectEvent(u16 graphicsId, void (*callback)(struct Sprite *), s16 x
return spriteId;
}
-u8 sprite_new(u8 graphicsId, u8 a1, s16 x, s16 y, u8 z, u8 direction)
+// Used to create sprite object events instead of a full object event
+// Used when resources are limiting, e.g. for the audience in contests or group members in Union Room
+u8 CreateObjectSprite(u8 graphicsId, u8 a1, s16 x, s16 y, u8 z, u8 direction)
{
u8 spriteId;
struct Sprite *sprite;
@@ -1531,11 +1534,11 @@ u8 sprite_new(u8 graphicsId, u8 a1, s16 x, s16 y, u8 z, u8 direction)
const struct ObjectEventGraphicsInfo *graphicsInfo;
graphicsInfo = GetObjectEventGraphicsInfo(graphicsId);
- MakeObjectTemplateFromObjectEventGraphicsInfo(graphicsId, UpdateObjectEventSpriteSubpriorityAndVisibility, &spriteTemplate, &subspriteTables);
+ MakeObjectTemplateFromObjectEventGraphicsInfo(graphicsId, UpdateObjectEventSprite, &spriteTemplate, &subspriteTables);
*(u16 *)&spriteTemplate.paletteTag = 0xFFFF;
x += 7;
y += 7;
- sub_80930E0(&x, &y, 8, 16);
+ SetSpritePosToOffsetMapCoords(&x, &y, 8, 16);
spriteId = CreateSpriteAtEnd(&spriteTemplate, x, y, 0);
if (spriteId != MAX_SPRITES)
{
@@ -2363,7 +2366,8 @@ static u8 GetObjectTrainerTypeByObjectEventId(u8 objectEventId)
return gObjectEvents[objectEventId].trainerType;
}
-u8 sub_808F0D4(u8 localId, u8 mapNum, u8 mapGroup)
+// Unused
+u8 GetObjectEventBerryTreeIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup)
{
u8 objectEventId;
@@ -2374,7 +2378,7 @@ u8 sub_808F0D4(u8 localId, u8 mapNum, u8 mapGroup)
return gObjectEvents[objectEventId].trainerRange_berryTreeId;
}
-u8 ObjectEventGetBerryTreeId(u8 objectEventId)
+u8 GetObjectEventBerryTreeId(u8 objectEventId)
{
return gObjectEvents[objectEventId].trainerRange_berryTreeId;
}
@@ -4864,22 +4868,22 @@ void SetSpritePosToMapCoords(s16 mapX, s16 mapY, s16 *destX, s16 *destY)
s16 dx = -gTotalCameraPixelOffsetX - gFieldCamera.x;
s16 dy = -gTotalCameraPixelOffsetY - gFieldCamera.y;
if (gFieldCamera.x > 0)
- dx += 1 << 4;
+ dx += 16;
if (gFieldCamera.x < 0)
- dx -= 1 << 4;
+ dx -= 16;
if (gFieldCamera.y > 0)
- dy += 1 << 4;
+ dy += 16;
if (gFieldCamera.y < 0)
- dy -= 1 << 4;
+ dy -= 16;
*destX = ((mapX - gSaveBlock1Ptr->pos.x) << 4) + dx;
*destY = ((mapY - gSaveBlock1Ptr->pos.y) << 4) + dy;
}
-void sub_80930E0(s16 *x, s16 *y, s16 dx, s16 dy)
+void SetSpritePosToOffsetMapCoords(s16 *x, s16 *y, s16 dx, s16 dy)
{
SetSpritePosToMapCoords(*x, *y, x, y);
*x += dx;
@@ -8630,51 +8634,56 @@ void UpdateObjectEventSpriteVisibility(struct Sprite *sprite, bool8 invisible)
sprite->invisible = TRUE;
}
-static void UpdateObjectEventSpriteSubpriorityAndVisibility(struct Sprite *sprite)
+#define tInvisible data[2]
+#define tAnimNum data[3]
+#define tAnimState data[4]
+
+static void UpdateObjectEventSprite(struct Sprite *sprite)
{
- sub_8097D68(sprite);
+ UpdateObjectEventSpritePosition(sprite);
SetObjectSubpriorityByZCoord(sprite->data[1], sprite, 1);
- UpdateObjectEventSpriteVisibility(sprite, sprite->data[2]);
+ UpdateObjectEventSpriteVisibility(sprite, sprite->tInvisible);
}
-void sub_8097AF0(void)
+// Unused
+static void DestroyObjectEventSprites(void)
{
int i;
- for(i = 0; i < MAX_SPRITES; i++)
+ for (i = 0; i < MAX_SPRITES; i++)
{
struct Sprite *sprite = &gSprites[i];
- if(sprite->inUse && sprite->callback == UpdateObjectEventSpriteSubpriorityAndVisibility)
+ if(sprite->inUse && sprite->callback == UpdateObjectEventSprite)
DestroySprite(sprite);
}
}
-int sub_8097B2C(u8 var) // this should return a u8, because all that call this shifts to u8, but it wont match because it doesnt shift u8 at the end.
+static int GetObjectEventSpriteId(u8 var) // this should return a u8, because all that call this shifts to u8, but it wont match because it doesnt shift u8 at the end.
{
int i;
- for(i = 0; i < MAX_SPRITES; i++)
+ for (i = 0; i < MAX_SPRITES; i++)
{
struct Sprite *sprite = &gSprites[i];
- if(sprite->inUse && sprite->callback == UpdateObjectEventSpriteSubpriorityAndVisibility && (u8)sprite->data[0] == var)
+ if(sprite->inUse && sprite->callback == UpdateObjectEventSprite && (u8)sprite->data[0] == var)
return i;
}
return MAX_SPRITES;
}
-void sub_8097B78(u8 var1, u8 var2)
+void TurnObjectEventSprite(u8 objectEventId, u8 direction)
{
- u8 spriteId = sub_8097B2C(var1);
+ u8 spriteId = GetObjectEventSpriteId(objectEventId);
- if(spriteId != MAX_SPRITES)
- StartSpriteAnim(&gSprites[spriteId], GetFaceDirectionAnimNum(var2));
+ if (spriteId != MAX_SPRITES)
+ StartSpriteAnim(&gSprites[spriteId], GetFaceDirectionAnimNum(direction));
}
-void sub_8097BB4(u8 var1, u8 graphicsId)
+void SetObjectEventSpriteGraphics(u8 objectEventId, u8 graphicsId)
{
- int spriteId = sub_8097B2C(var1);
+ int spriteId = GetObjectEventSpriteId(objectEventId);
- if(spriteId != MAX_SPRITES)
+ if (spriteId != MAX_SPRITES)
{
struct Sprite *sprite = &gSprites[spriteId];
const struct ObjectEventGraphicsInfo *graphicsInfo = GetObjectEventGraphicsInfo(graphicsId);
@@ -8685,7 +8694,7 @@ void sub_8097BB4(u8 var1, u8 graphicsId)
sprite->oam.paletteNum = graphicsInfo->paletteSlot;
sprite->images = graphicsInfo->images;
- if(graphicsInfo->subspriteTables == NULL)
+ if (graphicsInfo->subspriteTables == NULL)
{
sprite->subspriteTables = NULL;
sprite->subspriteTableNum = 0;
@@ -8700,102 +8709,102 @@ void sub_8097BB4(u8 var1, u8 graphicsId)
}
}
-void sub_8097C44(u8 var, bool32 var2)
+void SetObjectEventSpriteInvisibility(u8 objectEventId, bool32 invisible)
{
- u8 spriteId = sub_8097B2C(var);
+ u8 spriteId = GetObjectEventSpriteId(objectEventId);
- if(spriteId == MAX_SPRITES)
+ if (spriteId == MAX_SPRITES)
return;
- if(var2)
- gSprites[spriteId].data[2] = 1;
+ if (invisible)
+ gSprites[spriteId].tInvisible = TRUE;
else
- gSprites[spriteId].data[2] = 0;
+ gSprites[spriteId].tInvisible = FALSE;
}
-bool32 sub_8097C8C(u8 var)
+bool32 IsObjectEventSpriteInvisible(u8 objectEventId)
{
- u8 spriteId = sub_8097B2C(var);
+ u8 spriteId = GetObjectEventSpriteId(objectEventId);
- if(spriteId == MAX_SPRITES)
+ if (spriteId == MAX_SPRITES)
return FALSE;
- return (gSprites[spriteId].data[2] == TRUE);
+ return (gSprites[spriteId].tInvisible == TRUE);
}
-void sub_8097CC4(u8 var1, u8 var2)
+void SetObjectEventSpriteAnim(u8 objectEventId, u8 animNum)
{
- u8 spriteId = sub_8097B2C(var1);
+ u8 spriteId = GetObjectEventSpriteId(objectEventId);
- if(spriteId != MAX_SPRITES)
+ if (spriteId != MAX_SPRITES)
{
- gSprites[spriteId].data[3] = var2;
- gSprites[spriteId].data[4] = 0;
+ gSprites[spriteId].tAnimNum = animNum;
+ gSprites[spriteId].tAnimState = 0;
}
}
-void sub_8097CF4(struct Sprite *sprite)
+static void MoveUnionRoomObjectUp(struct Sprite *sprite)
{
- switch(sprite->data[4])
+ switch(sprite->tAnimState)
{
case 0:
sprite->pos2.y = 0;
- sprite->data[4]++;
+ sprite->tAnimState++;
case 1:
sprite->pos2.y -= 8;
- if(sprite->pos2.y == -160)
+ if (sprite->pos2.y == -160)
{
sprite->pos2.y = 0;
- sprite->data[2] = 1;
- sprite->data[3] = 0;
- sprite->data[4] = 0;
+ sprite->tInvisible = TRUE;
+ sprite->tAnimNum = 0;
+ sprite->tAnimState = 0;
}
}
}
-void sub_8097D30(struct Sprite *sprite)
+static void MoveUnionRoomObjectDown(struct Sprite *sprite)
{
- switch(sprite->data[4])
+ switch(sprite->tAnimState)
{
case 0:
sprite->pos2.y = -160;
- sprite->data[4]++;
+ sprite->tAnimState++;
case 1:
sprite->pos2.y += 8;
if(sprite->pos2.y == 0)
{
- sprite->data[3] = 0;
- sprite->data[4] = 0;
+ sprite->tAnimNum = 0;
+ sprite->tAnimState = 0;
}
}
}
-static void sub_8097D68(struct Sprite *sprite)
+static void UpdateObjectEventSpritePosition(struct Sprite *sprite)
{
- switch(sprite->data[3])
+ switch(sprite->tAnimNum)
{
- case 1:
- sub_8097D30(sprite);
+ case UNION_ROOM_SPAWN_IN:
+ MoveUnionRoomObjectDown(sprite);
break;
- case 2:
- sub_8097CF4(sprite);
+ case UNION_ROOM_SPAWN_OUT:
+ MoveUnionRoomObjectUp(sprite);
break;
case 0:
break;
default:
- sprite->data[3] = 0;
+ sprite->tAnimNum = 0;
break;
}
}
-bool32 sub_8097D9C(u8 var)
+bool32 IsObjectEventSpriteAnimating(u8 var)
{
- u8 spriteId = sub_8097B2C(var);
+ u8 spriteId = GetObjectEventSpriteId(var);
- if(spriteId == MAX_SPRITES)
+ if (spriteId == MAX_SPRITES)
return FALSE;
- if(gSprites[spriteId].data[3] != FALSE)
+ if (gSprites[spriteId].tAnimNum != 0)
return TRUE;
return FALSE;
diff --git a/src/faraway_island.c b/src/faraway_island.c
index f8e3eac14..2ac9d5c1f 100755
--- a/src/faraway_island.c
+++ b/src/faraway_island.c
@@ -378,7 +378,7 @@ void sub_81D4A90(void)
x = mew->currentCoords.x;
y = mew->currentCoords.y;
- sub_80930E0(&x, &y, 8, 8);
+ SetSpritePosToOffsetMapCoords(&x, &y, 8, 8);
sUnknown_0203CF50 = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[15], x, y, gSprites[mew->spriteId].subpriority - 1);
if (sUnknown_0203CF50 != MAX_SPRITES)
{
diff --git a/src/field_effect.c b/src/field_effect.c
index c4e9fc40a..07579f55d 100644
--- a/src/field_effect.c
+++ b/src/field_effect.c
@@ -2043,7 +2043,7 @@ static bool8 LavaridgeGymB1FWarpExitEffect_4(struct Task *task, struct ObjectEve
u8 FldEff_LavaridgeGymWarp(void)
{
u8 spriteId;
- sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
+ SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[33], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
gSprites[spriteId].oam.priority = gFieldEffectArguments[3];
gSprites[spriteId].coordOffsetEnabled = 1;
@@ -2136,7 +2136,7 @@ static bool8 LavaridgeGym1FWarpEffect_5(struct Task *task, struct ObjectEvent *o
u8 FldEff_PopOutOfAsh(void)
{
u8 spriteId;
- sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
+ SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[32], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
gSprites[spriteId].oam.priority = gFieldEffectArguments[3];
gSprites[spriteId].coordOffsetEnabled = 1;
diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c
index 52c30ab0f..e02de959b 100755
--- a/src/field_effect_helpers.c
+++ b/src/field_effect_helpers.c
@@ -274,7 +274,7 @@ u32 FldEff_TallGrass(void)
x = gFieldEffectArguments[0];
y = gFieldEffectArguments[1];
- sub_80930E0(&x, &y, 8, 8);
+ SetSpritePosToOffsetMapCoords(&x, &y, 8, 8);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[4], x, y, 0);
if (spriteId != MAX_SPRITES)
{
@@ -340,7 +340,7 @@ u32 FldEff_JumpTallGrass(void)
u8 spriteId;
struct Sprite *sprite;
- sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 12);
+ SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 12);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[10], gFieldEffectArguments[0], gFieldEffectArguments[1], 0);
if (spriteId != MAX_SPRITES)
{
@@ -380,7 +380,7 @@ u32 FldEff_LongGrass(void)
x = gFieldEffectArguments[0];
y = gFieldEffectArguments[1];
- sub_80930E0(&x, &y, 8, 8);
+ SetSpritePosToOffsetMapCoords(&x, &y, 8, 8);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[15], x, y, 0);
if (spriteId != MAX_SPRITES)
{
@@ -443,7 +443,7 @@ u32 FldEff_JumpLongGrass(void)
u8 spriteId;
struct Sprite *sprite;
- sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
+ SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[16], gFieldEffectArguments[0], gFieldEffectArguments[1], 0);
if (spriteId != MAX_SPRITES)
{
@@ -521,7 +521,7 @@ u32 FldEff_SandFootprints(void)
u8 spriteId;
struct Sprite *sprite;
- sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
+ SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[11], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
if (spriteId != MAX_SPRITES)
{
@@ -539,7 +539,7 @@ u32 FldEff_DeepSandFootprints(void)
u8 spriteId;
struct Sprite *sprite;
- sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
+ SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[23], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
if (spriteId != MAX_SPRITES)
{
@@ -557,7 +557,7 @@ u32 FldEff_BikeTireTracks(void)
u8 spriteId;
struct Sprite *sprite;
- sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
+ SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[27], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
if (spriteId != MAX_SPRITES)
{
@@ -649,7 +649,7 @@ u32 FldEff_JumpSmallSplash(void)
u8 spriteId;
struct Sprite *sprite;
- sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 12);
+ SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 12);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[14], gFieldEffectArguments[0], gFieldEffectArguments[1], 0);
if (spriteId != MAX_SPRITES)
{
@@ -667,7 +667,7 @@ u32 FldEff_JumpBigSplash(void)
u8 spriteId;
struct Sprite *sprite;
- sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
+ SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[12], gFieldEffectArguments[0], gFieldEffectArguments[1], 0);
if (spriteId != MAX_SPRITES)
{
@@ -805,7 +805,7 @@ u32 FldEff_Unknown19(void)
u8 spriteId;
struct Sprite *sprite;
- sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
+ SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[17], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
if (spriteId != MAX_SPRITES)
{
@@ -822,7 +822,7 @@ u32 FldEff_Unknown20(void)
u8 spriteId;
struct Sprite *sprite;
- sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
+ SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[18], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
if (spriteId != MAX_SPRITES)
{
@@ -839,7 +839,7 @@ u32 FldEff_Unknown21(void)
u8 spriteId;
struct Sprite *sprite;
- sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
+ SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[19], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
if (spriteId != MAX_SPRITES)
{
@@ -856,7 +856,7 @@ u32 FldEff_Unknown22(void)
u8 spriteId;
struct Sprite *sprite;
- sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
+ SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[20], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
if (spriteId != MAX_SPRITES)
{
@@ -888,7 +888,7 @@ u32 FldEff_Ash(void)
x = gFieldEffectArguments[0];
y = gFieldEffectArguments[1];
- sub_80930E0(&x, &y, 8, 8);
+ SetSpritePosToOffsetMapCoords(&x, &y, 8, 8);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[6], x, y, gFieldEffectArguments[2]);
if (spriteId != MAX_SPRITES)
{
@@ -944,7 +944,7 @@ u32 FldEff_SurfBlob(void)
u8 spriteId;
struct Sprite *sprite;
- sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
+ SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[7], gFieldEffectArguments[0], gFieldEffectArguments[1], 0x96);
if (spriteId !=MAX_SPRITES)
{
@@ -1106,7 +1106,7 @@ u32 FldEff_Dust(void)
u8 spriteId;
struct Sprite *sprite;
- sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 12);
+ SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 12);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[9], gFieldEffectArguments[0], gFieldEffectArguments[1], 0);
if (spriteId != MAX_SPRITES)
{
@@ -1182,7 +1182,7 @@ u32 FldEff_Bubbles(void)
u8 spriteId;
struct Sprite *sprite;
- sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 0);
+ SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 0);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[34], gFieldEffectArguments[0], gFieldEffectArguments[1], 0x52);
if (spriteId != MAX_SPRITES)
{
@@ -1210,7 +1210,7 @@ u32 FldEff_BerryTreeGrowthSparkle(void)
u8 spriteId;
struct Sprite *sprite;
- sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 4);
+ SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 4);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[22], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
if (spriteId != MAX_SPRITES)
{
@@ -1330,7 +1330,7 @@ u32 FldEff_Sparkle(void)
gFieldEffectArguments[0] += 7;
gFieldEffectArguments[1] += 7;
- sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
+ SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[35], gFieldEffectArguments[0], gFieldEffectArguments[1], 0x52);
if (spriteId != MAX_SPRITES)
{
diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c
index 51f719fc9..53057fc31 100644
--- a/src/field_screen_effect.c
+++ b/src/field_screen_effect.c
@@ -162,7 +162,7 @@ static void Task_ReturnToFieldCableLink(u8 taskId)
switch (task->data[0])
{
case 0:
- task->data[1] = sub_80B3050();
+ task->data[1] = CreateTask_ReestablishCableClubLink();
task->data[0]++;
break;
case 1:
@@ -204,7 +204,7 @@ static void Task_ReturnToFieldWirelessLink(u8 taskId)
if (!IsLinkTaskFinished())
{
if (++task->data[1] > 1800)
- sub_8011170(0x6000);
+ GetLinkmanErrorParams(0x6000);
}
else
{
@@ -215,7 +215,7 @@ static void Task_ReturnToFieldWirelessLink(u8 taskId)
case 2:
if (WaitForWeatherFadeIn() == TRUE)
{
- sub_8009F18();
+ StartSendingKeysToLink();
ScriptContext2_Disable();
DestroyTask(taskId);
}
@@ -240,7 +240,7 @@ void Task_ReturnToFieldRecordMixing(u8 taskId)
}
break;
case 2:
- sub_8009F18();
+ StartSendingKeysToLink();
ResetAllMultiplayerState();
ScriptContext2_Disable();
DestroyTask(taskId);
diff --git a/src/field_specials.c b/src/field_specials.c
index 818cd70db..e806440f7 100644
--- a/src/field_specials.c
+++ b/src/field_specials.c
@@ -4095,11 +4095,17 @@ void UpdateTrainerFanClubGameClear(void)
}
// If the player has < 3 fans, gain a new fan whenever the counter reaches 20+
-// Defeating Drake or participating in a Link Contest increments the counter by 2
+// Defeating Drake or participating in a Contest increments the counter by 2
// Participating at Battle Tower or in a Secret Base battle increments the counter by 1
u8 TryGainNewFanFromCounter(u8 incrementId)
{
- static const u8 sCounterIncrements[] = { 2, 1, 2, 1 };
+ static const u8 sCounterIncrements[] =
+ {
+ [FANCOUNTER_DEFEATED_DRAKE] = 2,
+ [FANCOUNTER_BATTLED_AT_BASE] = 1,
+ [FANCOUNTER_FINISHED_CONTEST] = 2,
+ [FANCOUNTER_USED_BATTLE_TOWER] = 1
+ };
if (VarGet(VAR_LILYCOVE_FAN_CLUB_STATE) == 2)
{
diff --git a/src/fieldmap.c b/src/fieldmap.c
index e953e0f93..cfc7018bd 100644
--- a/src/fieldmap.c
+++ b/src/fieldmap.c
@@ -533,9 +533,16 @@ static bool32 SavedMapViewIsEmpty(void)
u16 i;
u32 marker = 0;
+#ifndef UBFIX
// BUG: This loop extends past the bounds of the mapView array. Its size is only 0x100.
for (i = 0; i < 0x200; i++)
marker |= gSaveBlock1Ptr->mapView[i];
+#else
+ // UBFIX: Only iterate over 0x100
+ for (i = 0; i < ARRAY_COUNT(gSaveBlock1Ptr->mapView); i++)
+ marker |= gSaveBlock1Ptr->mapView[i];
+#endif
+
if (marker == 0)
return TRUE;
@@ -917,11 +924,11 @@ void GetCameraCoords(u16 *x, u16 *y)
*y = gSaveBlock1Ptr->pos.y;
}
-void sub_8088B94(int x, int y, int a2)
+void MapGridSetMetatileImpassabilityAt(int x, int y, bool32 impassable)
{
if (x >= 0 && x < gBackupMapLayout.width && y >= 0 && y < gBackupMapLayout.height)
{
- if (a2 != 0)
+ if (impassable)
gBackupMapLayout.map[x + gBackupMapLayout.width * y] |= METATILE_COLLISION_MASK;
else
gBackupMapLayout.map[x + gBackupMapLayout.width * y] &= ~METATILE_COLLISION_MASK;
diff --git a/src/fldeff_misc.c b/src/fldeff_misc.c
index 9574ac563..ab04e47ff 100644
--- a/src/fldeff_misc.c
+++ b/src/fldeff_misc.c
@@ -1008,7 +1008,7 @@ void DoSecretBaseGlitterMatSparkle(void)
s16 y = gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.y;
u8 spriteId;
- sub_80930E0(&x, &y, 8, 4);
+ SetSpritePosToOffsetMapCoords(&x, &y, 8, 4);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[22], x, y, 0);
if (spriteId != MAX_SPRITES)
diff --git a/src/graphics.c b/src/graphics.c
index 7a3a225c2..b774c5ad2 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -471,13 +471,11 @@ const u8 gTiles_8C19450[] = INCBIN_U8("graphics/contest/heart.4bpp");
const u32 gUnknownGfx_C19470[] = INCBIN_U32("graphics/unknown/unknown_C19470.4bpp.lz");
const u32 gUnknownPal_C19470[] = INCBIN_U32("graphics/unknown/unknown_C19470.gbapal.lz");
-const u32 gUnknown_08C19588[] = INCBIN_U32("graphics/contest/misc_2.4bpp.lz");
-
+const u32 gContestResults_Gfx[] = INCBIN_U32("graphics/contest/results_screen.4bpp.lz");
const u32 gUnknown_08C19EEC[] = INCBIN_U32("graphics/contest/misc_2_tilemap_1.bin.lz");
const u32 gUnknown_08C1A000[] = INCBIN_U32("graphics/contest/misc_2_tilemap_2.bin.lz");
const u32 gUnknown_08C1A12C[] = INCBIN_U32("graphics/contest/misc_2_tilemap_3.bin.lz");
-
-const u32 gUnknown_08C1A2B4[] = INCBIN_U32("graphics/contest/misc_2.gbapal.lz");
+const u32 gContestResults_Pal[] = INCBIN_U32("graphics/contest/results_screen.gbapal.lz");
const u32 gBattleAnimSpriteGfx_Impact[] = INCBIN_U32("graphics/battle_anims/sprites/impact.4bpp.lz");
const u32 gBattleAnimSpritePal_Impact[] = INCBIN_U32("graphics/battle_anims/sprites/impact.gbapal.lz");
@@ -875,8 +873,8 @@ const u32 gSubstituteDollTilemap[] = INCBIN_U32("graphics/battle_anims/sprites/s
const u32 gBattleAnimSpriteGfx_GreenStar[] = INCBIN_U32("graphics/battle_anims/sprites/green_star.4bpp.lz");
const u32 gBattleAnimSpritePal_GreenStar[] = INCBIN_U32("graphics/battle_anims/sprites/green_star.gbapal.lz");
-const u32 gContestConfetti_Gfx[] = INCBIN_U32("graphics/misc/confetti.4bpp.lz");
-const u32 gContestConfetti_Pal[] = INCBIN_U32("graphics/misc/confetti.gbapal.lz");
+const u32 gConfetti_Gfx[] = INCBIN_U32("graphics/misc/confetti.4bpp.lz");
+const u32 gConfetti_Pal[] = INCBIN_U32("graphics/misc/confetti.gbapal.lz");
const u32 gBattleAnimSpriteGfx_PinkCloud[] = INCBIN_U32("graphics/battle_anims/sprites/pink_cloud.4bpp.lz");
const u32 gBattleAnimSpritePal_PinkCloud[] = INCBIN_U32("graphics/battle_anims/sprites/pink_cloud.gbapal.lz");
@@ -1298,19 +1296,19 @@ const u8 gFireRedMenuElements_Gfx[] = INCBIN_U8("graphics/interface_fr/menu.4bpp
const u8 gBagMenuHMIcon_Gfx[] = INCBIN_U8("graphics/interface/hm.4bpp");
-// contest link stuff, appears to be a set of tilemaps
+// contest results screen
-const u16 gUnknown_08DC63F8[] = INCBIN_U16("graphics/contest/clink_tilemap1.bin");
-const u16 gUnknown_08DC6420[] = INCBIN_U16("graphics/contest/clink_tilemap2.bin");
-const u16 gUnknown_08DC6448[] = INCBIN_U16("graphics/contest/clink_tilemap3.bin");
-const u16 gUnknown_08DC6470[] = INCBIN_U16("graphics/contest/clink_tilemap4.bin");
-const u16 gUnknown_08DC6498[] = INCBIN_U16("graphics/contest/clink_tilemap5.bin");
-const u16 gUnknown_08DC64AC[] = INCBIN_U16("graphics/contest/clink_tilemap6.bin");
-const u16 gUnknown_08DC64C0[] = INCBIN_U16("graphics/contest/clink_tilemap7.bin");
-const u16 gUnknown_08DC64D4[] = INCBIN_U16("graphics/contest/clink_tilemap8.bin");
-const u16 gUnknown_08DC64E8[] = INCBIN_U16("graphics/contest/clink_tilemap9.bin");
-const u16 gUnknown_08DC64FC[] = INCBIN_U16("graphics/contest/clink_tilemap10.bin");
-const u16 gUnknown_08DC6510[] = INCBIN_U16("graphics/contest/clink_tilemap11.bin");
+const u16 gNormalContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_normal.bin");
+const u16 gSuperContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_super.bin");
+const u16 gHyperContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_hyper.bin");
+const u16 gMasterContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_master.bin");
+const u16 gLinkContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_link.bin");
+const u16 gCoolContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_cool.bin");
+const u16 gBeautyContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_beauty.bin");
+const u16 gCuteContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_cute.bin");
+const u16 gSmartContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_smart.bin");
+const u16 gToughContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_tough.bin");
+const u16 gContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen.bin");
// pokenav
@@ -1447,19 +1445,15 @@ const u32 gUnknown_08DD4620[] = INCBIN_U32("graphics/unknown/unknown_DD4620.bin.
const u32 gUnknown_08DD46E0[] = INCBIN_U32("graphics/unknown/unknown_DD46E0.bin.lz");
const u32 gUnknown_08DD47A0[] = INCBIN_U32("graphics/unknown/unknown_DD47A0.bin.lz");
-// link
-
-const u16 gLinkMiscMenu_Pal[] = INCBIN_U16("graphics/link/misc.gbapal");
-const u32 gLinkMiscMenu_Gfx[] = INCBIN_U32("graphics/link/misc.4bpp.lz");
-const u32 gLinkMiscMenu_Tilemap[] = INCBIN_U32("graphics/link/misc.bin.lz");
-
-const u16 gUnknown_08DD4BB0[] = INCBIN_U16("graphics/link/link1.gbapal");
-const u16 gUnknown_08DD4BD0[] = INCBIN_U16("graphics/link/link2.gbapal");
-
-const u32 gUnknown_08DD4BF0[] = INCBIN_U32("graphics/link/link_winedge.4bpp.lz");
-const u32 gUnknown_08DD4C4C[] = INCBIN_U32("graphics/link/link_winedge.bin.lz");
-
-const u32 gUnknown_08DD4CF8[] = INCBIN_U32("graphics/interface/unk_change_case.4bpp.lz");
+// union room chat
+const u16 gUnionRoomChat_Background_Pal[] = INCBIN_U16("graphics/union_room_chat/background.gbapal");
+const u32 gUnionRoomChat_Background_Gfx[] = INCBIN_U32("graphics/union_room_chat/background.4bpp.lz");
+const u32 gUnionRoomChat_Background_Tilemap[] = INCBIN_U32("graphics/union_room_chat/background.bin.lz");
+const u16 gUnionRoomChat_Window_Pal1[] = INCBIN_U16("graphics/union_room_chat/window_1.gbapal");
+const u16 gUnionRoomChat_Window_Pal2[] = INCBIN_U16("graphics/union_room_chat/window_2.gbapal");
+const u32 gUnionRoomChat_Border_Gfx[] = INCBIN_U32("graphics/union_room_chat/border.4bpp.lz");
+const u32 gUnionRoomChat_Border_Tilemap[] = INCBIN_U32("graphics/union_room_chat/border.bin.lz");
+const u32 gUnionRoomChat_RButtonLabels[] = INCBIN_U32("graphics/union_room_chat/r_button_labels.4bpp.lz");
const u16 gTilesetPalettes_General[][16] =
{
diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c
index 1606c2de5..bf9850dec 100644
--- a/src/hall_of_fame.c
+++ b/src/hall_of_fame.c
@@ -33,9 +33,12 @@
#include "fldeff_misc.h"
#include "trainer_pokemon_sprites.h"
#include "data.h"
-#include "rom_81520A8.h"
+#include "confetti_util.h"
#include "constants/rgb.h"
+#define HALL_OF_FAME_MAX_TEAMS 50
+#define TAG_CONFETTI 1001
+
struct HallofFameMon
{
u32 tid;
@@ -58,33 +61,31 @@ struct HofGfx
u8 tilemap2[0x1000];
};
-static EWRAM_DATA u32 sUnknown_0203BCD4 = 0;
+static EWRAM_DATA u32 sHofFadePalettes = 0;
static EWRAM_DATA struct HallofFameTeam *sHofMonPtr = NULL;
static EWRAM_DATA struct HofGfx *sHofGfxPtr = NULL;
extern struct MusicPlayerInfo gMPlayInfo_BGM;
-#define HALL_OF_FAME_MAX_TEAMS 50
-
// this file's functions
static void ClearVramOamPltt_LoadHofPal(void);
-static void sub_8174F70(void);
-static void sub_8174FAC(void);
-static bool8 sub_81751FC(void);
+static void LoadHofGfx(void);
+static void InitHofBgs(void);
+static bool8 CreateHofConfettiSprite(void);
static void SetCallback2AfterHallOfFameDisplay(void);
static bool8 sub_8175024(void);
static void Task_Hof_InitMonData(u8 taskId);
static void Task_Hof_InitTeamSaveData(u8 taskId);
static void Task_Hof_SetMonDisplayTask(u8 taskId);
static void Task_Hof_TrySaveData(u8 taskId);
-static void Task_Hof_WaitForFrames(u8 taskId);
+static void Task_Hof_WaitToDisplayMon(u8 taskId);
static void Task_Hof_DisplayMon(u8 taskId);
static void Task_Hof_PrintMonInfoAfterAnimating(u8 taskId);
static void Task_Hof_TryDisplayAnotherMon(u8 taskId);
static void Task_Hof_PaletteFadeAndPrintWelcomeText(u8 taskId);
-static void sub_8173DC0(u8 taskId);
-static void sub_8173EA4(u8 taskId);
-static void sub_8173EE4(u8 taskId);
+static void Task_Hof_DoConfetti(u8 taskId);
+static void Task_Hof_WaitToDisplayPlayer(u8 taskId);
+static void Task_Hof_DisplayPlayer(u8 taskId);
static void Task_Hof_WaitAndPrintPlayerInfo(u8 taskId);
static void Task_Hof_ExitOnKeyPressed(u8 taskId);
static void Task_Hof_HandlePaletteOnExit(u8 taskId);
@@ -101,8 +102,8 @@ static void SpriteCB_GetOnScreenAndAnimate(struct Sprite *sprite);
static void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 unused1, u8 unused2);
static void HallOfFame_PrintWelcomeText(u8 unusedPossiblyWindowId, u8 unused2);
static void HallOfFame_PrintPlayerInfo(u8 unused1, u8 unused2);
-static void Task_DoConfettiEffect(u8 taskId);
-static void sub_81751A4(struct Sprite* sprite);
+static void Task_DoDomeConfetti(u8 taskId);
+static void SpriteCB_HofConfetti(struct Sprite* sprite);
// const rom data
static const struct BgTemplate sHof_BgTemplates[] =
@@ -143,15 +144,15 @@ static const u8 sPlayerInfoTextColors[4] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_D
static const u8 sUnused_085E538C[] = {4, 5, 0, 0};
-static const struct CompressedSpriteSheet sHallOfFame_ConfettiSpriteSheet[] =
+static const struct CompressedSpriteSheet sSpriteSheet_Confetti[] =
{
- {gContestConfetti_Gfx, 0x220, 1001},
+ {.data = gConfetti_Gfx, .size = 0x220, .tag = TAG_CONFETTI},
{},
};
-static const struct CompressedSpritePalette sHallOfFame_ConfettiSpritePalette[] =
+static const struct CompressedSpritePalette sSpritePalette_Confetti[] =
{
- {gContestConfetti_Pal, 1001},
+ {.data = gConfetti_Pal, .tag = TAG_CONFETTI},
{},
};
@@ -172,7 +173,7 @@ static const s16 sHallOfFame_MonHalfTeamPositions[PARTY_SIZE / 2][4] =
{-86, 244, 184, 64}
};
-static const struct OamData sOamData_85E53FC =
+static const struct OamData sOamData_Confetti =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
@@ -189,126 +190,138 @@ static const struct OamData sOamData_85E53FC =
.affineParam = 0,
};
-static const union AnimCmd sSpriteAnim_85E5404[] =
+static const union AnimCmd sAnim_PinkConfettiA[] =
{
ANIMCMD_FRAME(0, 30),
ANIMCMD_END
};
-static const union AnimCmd sSpriteAnim_85E540C[] =
+static const union AnimCmd sAnim_RedConfettiA[] =
{
ANIMCMD_FRAME(1, 30),
ANIMCMD_END
};
-static const union AnimCmd sSpriteAnim_85E5414[] =
+static const union AnimCmd sAnim_BlueConfettiA[] =
{
ANIMCMD_FRAME(2, 30),
ANIMCMD_END
};
-static const union AnimCmd sSpriteAnim_85E541C[] =
+static const union AnimCmd sAnim_RedConfettiB[] =
{
ANIMCMD_FRAME(3, 30),
ANIMCMD_END
};
-static const union AnimCmd sSpriteAnim_85E5424[] =
+static const union AnimCmd sAnim_BlueConfettiB[] =
{
ANIMCMD_FRAME(4, 30),
ANIMCMD_END
};
-static const union AnimCmd sSpriteAnim_85E542C[] =
+static const union AnimCmd sAnim_YellowConfettiA[] =
{
ANIMCMD_FRAME(5, 30),
ANIMCMD_END
};
-static const union AnimCmd sSpriteAnim_85E5434[] =
+static const union AnimCmd sAnim_WhiteConfettiA[] =
{
ANIMCMD_FRAME(6, 30),
ANIMCMD_END
};
-static const union AnimCmd sSpriteAnim_85E543C[] =
+static const union AnimCmd sAnim_GreenConfettiA[] =
{
ANIMCMD_FRAME(7, 30),
ANIMCMD_END
};
-static const union AnimCmd sSpriteAnim_85E5444[] =
+static const union AnimCmd sAnim_PinkConfettiB[] =
{
ANIMCMD_FRAME(8, 30),
ANIMCMD_END
};
-static const union AnimCmd sSpriteAnim_85E544C[] =
+static const union AnimCmd sAnim_BlueConfettiC[] =
{
ANIMCMD_FRAME(9, 30),
ANIMCMD_END
};
-static const union AnimCmd sSpriteAnim_85E5454[] =
+static const union AnimCmd sAnim_YellowConfettiB[] =
{
ANIMCMD_FRAME(10, 30),
ANIMCMD_END
};
-static const union AnimCmd sSpriteAnim_85E545C[] =
+static const union AnimCmd sAnim_WhiteConfettiB[] =
{
ANIMCMD_FRAME(11, 30),
ANIMCMD_END
};
-static const union AnimCmd sSpriteAnim_85E5464[] =
+static const union AnimCmd sAnim_GreenConfettiB[] =
{
ANIMCMD_FRAME(12, 30),
ANIMCMD_END
};
-static const union AnimCmd sSpriteAnim_85E546C[] =
+static const union AnimCmd sAnim_PinkConfettiC[] =
{
ANIMCMD_FRAME(13, 30),
ANIMCMD_END
};
-static const union AnimCmd sSpriteAnim_85E5474[] =
+static const union AnimCmd sAnim_RedConfettiC[] =
{
ANIMCMD_FRAME(14, 30),
ANIMCMD_END
};
-static const union AnimCmd sSpriteAnim_85E547C[] =
+static const union AnimCmd sAnim_YellowConfettiC[] =
{
ANIMCMD_FRAME(15, 30),
ANIMCMD_END
};
-static const union AnimCmd sSpriteAnim_85E5484[] =
+static const union AnimCmd sAnim_WhiteConfettiC[] =
{
ANIMCMD_FRAME(16, 30),
ANIMCMD_END
};
-static const union AnimCmd * const sSpriteAnimTable_85E548C[] =
-{
- sSpriteAnim_85E5404, sSpriteAnim_85E540C, sSpriteAnim_85E5414, sSpriteAnim_85E541C,
- sSpriteAnim_85E5424, sSpriteAnim_85E542C, sSpriteAnim_85E5434, sSpriteAnim_85E543C,
- sSpriteAnim_85E5444, sSpriteAnim_85E544C, sSpriteAnim_85E5454, sSpriteAnim_85E545C,
- sSpriteAnim_85E5464, sSpriteAnim_85E546C, sSpriteAnim_85E5474, sSpriteAnim_85E547C,
- sSpriteAnim_85E5484
+static const union AnimCmd * const sAnims_Confetti[] =
+{
+ sAnim_PinkConfettiA,
+ sAnim_RedConfettiA,
+ sAnim_BlueConfettiA,
+ sAnim_RedConfettiB,
+ sAnim_BlueConfettiB,
+ sAnim_YellowConfettiA,
+ sAnim_WhiteConfettiA,
+ sAnim_GreenConfettiA,
+ sAnim_PinkConfettiB,
+ sAnim_BlueConfettiC,
+ sAnim_YellowConfettiB,
+ sAnim_WhiteConfettiB,
+ sAnim_GreenConfettiB,
+ sAnim_PinkConfettiC,
+ sAnim_RedConfettiC,
+ sAnim_YellowConfettiC,
+ sAnim_WhiteConfettiC
};
-static const struct SpriteTemplate sSpriteTemplate_85E54D0 =
+static const struct SpriteTemplate sSpriteTemplate_HofConfetti =
{
- .tileTag = 1001,
- .paletteTag = 1001,
- .oam = &sOamData_85E53FC,
- .anims = sSpriteAnimTable_85E548C,
+ .tileTag = TAG_CONFETTI,
+ .paletteTag = TAG_CONFETTI,
+ .oam = &sOamData_Confetti,
+ .anims = sAnims_Confetti,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
- .callback = sub_81751A4
+ .callback = SpriteCB_HofConfetti
};
static const u16 sHallOfFame_Pal[] = INCBIN_U16("graphics/misc/japanese_hof.gbapal");
@@ -317,10 +330,19 @@ static const u32 sHallOfFame_Gfx[] = INCBIN_U32("graphics/misc/japanese_hof.4bpp
static const struct HallofFameMon sDummyFameMon =
{
- 0x3EA03EA, 0, 0, 0, {0}
+ .tid = 0x3EA03EA,
+ .personality = 0,
+ .species = SPECIES_NONE,
+ .lvl = 0,
+ .nick = {0}
};
-static const u8 sUnused2[] = {2, 1, 3, 6, 4, 5, 0, 0};
+// Unused, order of party slots on Hall of Fame screen
+static const u8 sHallOfFame_SlotOrder[] = {
+ 2, 1, 3,
+ 6, 4, 5,
+ 0, 0
+};
// code
static void VBlankCB_HallOfFame(void)
@@ -350,14 +372,14 @@ static bool8 InitHallOfFameScreen(void)
gMain.state = 1;
break;
case 1:
- sub_8174F70();
+ LoadHofGfx();
gMain.state++;
break;
case 2:
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 7));
SetGpuReg(REG_OFFSET_BLDY, 0);
- sub_8174FAC();
+ InitHofBgs();
sHofGfxPtr->state = 0;
gMain.state++;
break;
@@ -433,7 +455,7 @@ static void Task_Hof_InitMonData(u8 taskId)
}
else
{
- sHofMonPtr->mon[i].species = 0;
+ sHofMonPtr->mon[i].species = SPECIES_NONE;
sHofMonPtr->mon[i].tid = 0;
sHofMonPtr->mon[i].personality = 0;
sHofMonPtr->mon[i].lvl = 0;
@@ -441,7 +463,7 @@ static void Task_Hof_InitMonData(u8 taskId)
}
}
- sUnknown_0203BCD4 = 0;
+ sHofFadePalettes = 0;
gTasks[taskId].tDisplayedMonId = 0;
gTasks[taskId].tPlayerSpriteID = 0xFF;
@@ -514,12 +536,12 @@ static void Task_Hof_TrySaveData(u8 taskId)
else
{
PlaySE(SE_SAVE);
- gTasks[taskId].func = Task_Hof_WaitForFrames;
+ gTasks[taskId].func = Task_Hof_WaitToDisplayMon;
gTasks[taskId].tFrameCount = 32;
}
}
-static void Task_Hof_WaitForFrames(u8 taskId)
+static void Task_Hof_WaitToDisplayMon(u8 taskId)
{
if (gTasks[taskId].tFrameCount)
gTasks[taskId].tFrameCount--;
@@ -539,32 +561,32 @@ static void Task_Hof_SetMonDisplayTask(u8 taskId)
static void Task_Hof_DisplayMon(u8 taskId)
{
u8 spriteId;
- s16 xPos, yPos, field4, field6;
+ s16 startX, startY, destX, destY;
u16 currMonId = gTasks[taskId].tDisplayedMonId;
struct HallofFameMon* currMon = &sHofMonPtr->mon[currMonId];
if (gTasks[taskId].tMonNumber > PARTY_SIZE / 2)
{
- xPos = sHallOfFame_MonFullTeamPositions[currMonId][0];
- yPos = sHallOfFame_MonFullTeamPositions[currMonId][1];
- field4 = sHallOfFame_MonFullTeamPositions[currMonId][2];
- field6 = sHallOfFame_MonFullTeamPositions[currMonId][3];
+ startX = sHallOfFame_MonFullTeamPositions[currMonId][0];
+ startY = sHallOfFame_MonFullTeamPositions[currMonId][1];
+ destX = sHallOfFame_MonFullTeamPositions[currMonId][2];
+ destY = sHallOfFame_MonFullTeamPositions[currMonId][3];
}
else
{
- xPos = sHallOfFame_MonHalfTeamPositions[currMonId][0];
- yPos = sHallOfFame_MonHalfTeamPositions[currMonId][1];
- field4 = sHallOfFame_MonHalfTeamPositions[currMonId][2];
- field6 = sHallOfFame_MonHalfTeamPositions[currMonId][3];
+ startX = sHallOfFame_MonHalfTeamPositions[currMonId][0];
+ startY = sHallOfFame_MonHalfTeamPositions[currMonId][1];
+ destX = sHallOfFame_MonHalfTeamPositions[currMonId][2];
+ destY = sHallOfFame_MonHalfTeamPositions[currMonId][3];
}
if (currMon->species == SPECIES_EGG)
- field6 += 10;
+ destY += 10;
- spriteId = CreatePicSprite2(currMon->species, currMon->tid, currMon->personality, 1, xPos, yPos, currMonId, 0xFFFF);
- gSprites[spriteId].tDestinationX = field4;
- gSprites[spriteId].tDestinationY = field6;
+ spriteId = CreatePicSprite2(currMon->species, currMon->tid, currMon->personality, 1, startX, startY, currMonId, 0xFFFF);
+ gSprites[spriteId].tDestinationX = destX;
+ gSprites[spriteId].tDestinationY = destY;
gSprites[spriteId].data[0] = 0;
gSprites[spriteId].tSpecies = currMon->species;
gSprites[spriteId].callback = SpriteCB_GetOnScreenAndAnimate;
@@ -599,11 +621,11 @@ static void Task_Hof_TryDisplayAnotherMon(u8 taskId)
}
else
{
- sUnknown_0203BCD4 |= (0x10000 << gSprites[gTasks[taskId].tMonSpriteId(currPokeID)].oam.paletteNum);
- if (gTasks[taskId].tDisplayedMonId <= 4 && currMon[1].species != SPECIES_NONE) // there is another pokemon to display
+ sHofFadePalettes |= (0x10000 << gSprites[gTasks[taskId].tMonSpriteId(currPokeID)].oam.paletteNum);
+ if (gTasks[taskId].tDisplayedMonId < PARTY_SIZE - 1 && currMon[1].species != SPECIES_NONE) // there is another pokemon to display
{
gTasks[taskId].tDisplayedMonId++;
- BeginNormalPaletteFade(sUnknown_0203BCD4, 0, 12, 12, RGB(16, 29, 24));
+ BeginNormalPaletteFade(sHofFadePalettes, 0, 12, 12, RGB(16, 29, 24));
gSprites[gTasks[taskId].tMonSpriteId(currPokeID)].oam.priority = 1;
gTasks[taskId].func = Task_Hof_DisplayMon;
}
@@ -628,16 +650,19 @@ static void Task_Hof_PaletteFadeAndPrintWelcomeText(u8 taskId)
HallOfFame_PrintWelcomeText(0, 15);
PlaySE(SE_DENDOU);
gTasks[taskId].tFrameCount = 400;
- gTasks[taskId].func = sub_8173DC0;
+ gTasks[taskId].func = Task_Hof_DoConfetti;
}
-static void sub_8173DC0(u8 taskId)
+static void Task_Hof_DoConfetti(u8 taskId)
{
if (gTasks[taskId].tFrameCount != 0)
{
gTasks[taskId].tFrameCount--;
+
+ // Create new confetti every 4th frame for the first 290 frames
+ // For the last 110 frames wait for the existing confetti to fall offscreen
if ((gTasks[taskId].tFrameCount & 3) == 0 && gTasks[taskId].tFrameCount > 110)
- sub_81751FC();
+ CreateHofConfettiSprite();
}
else
{
@@ -647,19 +672,19 @@ static void sub_8173DC0(u8 taskId)
if (gTasks[taskId].tMonSpriteId(i) != 0xFF)
gSprites[gTasks[taskId].tMonSpriteId(i)].oam.priority = 1;
}
- BeginNormalPaletteFade(sUnknown_0203BCD4, 0, 12, 12, RGB(16, 29, 24));
+ BeginNormalPaletteFade(sHofFadePalettes, 0, 12, 12, RGB(16, 29, 24));
FillWindowPixelBuffer(0, PIXEL_FILL(0));
CopyWindowToVram(0, 3);
gTasks[taskId].tFrameCount = 7;
- gTasks[taskId].func = sub_8173EA4;
+ gTasks[taskId].func = Task_Hof_WaitToDisplayPlayer;
}
}
-static void sub_8173EA4(u8 taskId)
+static void Task_Hof_WaitToDisplayPlayer(u8 taskId)
{
if (gTasks[taskId].tFrameCount >= 16)
{
- gTasks[taskId].func = sub_8173EE4;
+ gTasks[taskId].func = Task_Hof_DisplayPlayer;
}
else
{
@@ -668,7 +693,7 @@ static void sub_8173EA4(u8 taskId)
}
}
-static void sub_8173EE4(u8 taskId)
+static void Task_Hof_DisplayPlayer(u8 taskId)
{
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
ShowBg(0);
@@ -784,14 +809,14 @@ void CB2_DoHallOfFamePC(void)
gMain.state = 1;
break;
case 1:
- sub_8174F70();
+ LoadHofGfx();
gMain.state++;
break;
case 2:
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 0);
- sub_8174FAC();
+ InitHofBgs();
gMain.state++;
break;
case 3:
@@ -874,7 +899,7 @@ static void Task_HofPC_DrawSpritesPrintText(u8 taskId)
savedTeams++;
currMon = &savedTeams->mon[0];
- sUnknown_0203BCD4 = 0;
+ sHofFadePalettes = 0;
gTasks[taskId].tCurrMonId = 0;
gTasks[taskId].tMonNo = 0;
@@ -949,8 +974,8 @@ static void Task_HofPC_PrintMonInfo(u8 taskId)
currMonID = gTasks[taskId].tMonSpriteId(gTasks[taskId].tCurrMonId);
gSprites[currMonID].oam.priority = 0;
- sUnknown_0203BCD4 = (0x10000 << gSprites[currMonID].oam.paletteNum) ^ 0xFFFF0000;
- BlendPalettesUnfaded(sUnknown_0203BCD4, 0xC, RGB(16, 29, 24));
+ sHofFadePalettes = (0x10000 << gSprites[currMonID].oam.paletteNum) ^ 0xFFFF0000;
+ BlendPalettesUnfaded(sHofFadePalettes, 0xC, RGB(16, 29, 24));
currMon = &savedTeams->mon[gTasks[taskId].tCurrMonId];
if (currMon->species != SPECIES_EGG)
@@ -972,7 +997,7 @@ static void Task_HofPC_HandleInput(u8 taskId)
if (gTasks[taskId].tCurrTeamNo != 0) // prepare another team to view
{
gTasks[taskId].tCurrTeamNo--;
- for (i = 0; i < 6; i++)
+ for (i = 0; i < PARTY_SIZE; i++)
{
u8 spriteId = gTasks[taskId].tMonSpriteId(i);
if (spriteId != 0xFF)
@@ -1250,7 +1275,7 @@ static void ClearVramOamPltt_LoadHofPal(void)
LoadPalette(sHallOfFame_Pal, 0, 0x20);
}
-static void sub_8174F70(void)
+static void LoadHofGfx(void)
{
ScanlineEffect_Stop();
ResetTasks();
@@ -1259,11 +1284,11 @@ static void sub_8174F70(void)
ResetAllPicSprites();
FreeAllSpritePalettes();
gReservedSpritePaletteCount = 8;
- LoadCompressedSpriteSheet(sHallOfFame_ConfettiSpriteSheet);
- LoadCompressedSpritePalette(sHallOfFame_ConfettiSpritePalette);
+ LoadCompressedSpriteSheet(sSpriteSheet_Confetti);
+ LoadCompressedSpritePalette(sSpritePalette_Confetti);
}
-static void sub_8174FAC(void)
+static void InitHofBgs(void)
{
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sHof_BgTemplates, ARRAY_COUNT(sHof_BgTemplates));
@@ -1344,7 +1369,10 @@ static void SpriteCB_GetOnScreenAndAnimate(struct Sprite *sprite)
#undef tDestinationY
#undef tSpecies
-static void sub_81751A4(struct Sprite* sprite)
+#define sSineIdx data[0]
+#define sExtraY data[1]
+
+static void SpriteCB_HofConfetti(struct Sprite* sprite)
{
if (sprite->pos2.y > 120)
{
@@ -1353,20 +1381,20 @@ static void sub_81751A4(struct Sprite* sprite)
else
{
u16 rand;
- u8 tableID;
+ u8 sineIdx;
sprite->pos2.y++;
- sprite->pos2.y += sprite->data[1];
+ sprite->pos2.y += sprite->sExtraY;
- tableID = sprite->data[0];
+ sineIdx = sprite->sSineIdx;
rand = (Random() % 4) + 8;
- sprite->pos2.x = rand * gSineTable[tableID] / 256;
+ sprite->pos2.x = rand * gSineTable[sineIdx] / 256;
- sprite->data[0] += 4;
+ sprite->sSineIdx += 4;
}
}
-static bool8 sub_81751FC(void)
+static bool8 CreateHofConfettiSprite(void)
{
u8 spriteID;
struct Sprite* sprite;
@@ -1374,110 +1402,136 @@ static bool8 sub_81751FC(void)
s16 posX = Random() % 240;
s16 posY = -(Random() % 8);
- spriteID = CreateSprite(&sSpriteTemplate_85E54D0, posX, posY, 0);
+ spriteID = CreateSprite(&sSpriteTemplate_HofConfetti, posX, posY, 0);
sprite = &gSprites[spriteID];
- StartSpriteAnim(sprite, Random() % 17);
+ StartSpriteAnim(sprite, Random() % ARRAY_COUNT(sAnims_Confetti));
+ // 1/4 confetti sprites move an extra Y coord each frame
if (Random() & 3)
- sprite->data[1] = 0;
+ sprite->sExtraY = 0;
else
- sprite->data[1] = 1;
+ sprite->sExtraY = 1;
return FALSE;
}
-// Used when a Battle Dome tourney is won
-void DoConfettiEffect(void)
+// The below confetti functions are used when a Battle Dome tourney is won
+// For the Hall of Fame confetti see Task_Hof_DoConfetti
+// The end result is essentially the same, just a very different way of handling it
+#define tState data[0]
+#define tTimer data[1]
+#define tConfettiCount data[15]
+
+// Indexes into the data array of the struct ConfettiUtil
+#define CONFETTI_SINE_IDX 0
+#define CONFETTI_EXTRA_Y 1
+#define CONFETTI_TASK_ID 7
+
+void DoDomeConfetti(void)
{
u8 taskId;
gSpecialVar_0x8004 = 180;
- taskId = CreateTask(Task_DoConfettiEffect, 0);
+ taskId = CreateTask(Task_DoDomeConfetti, 0);
if (taskId != 0xFF)
{
- gTasks[taskId].data[1] = gSpecialVar_0x8004;
+ gTasks[taskId].tTimer = gSpecialVar_0x8004;
gSpecialVar_0x8005 = taskId;
}
}
-static void StopConfettiEffect(void)
+static void StopDomeConfetti(void)
{
u8 taskId;
- if ((taskId = FindTaskIdByFunc(Task_DoConfettiEffect)) != 0xFF)
+ if ((taskId = FindTaskIdByFunc(Task_DoDomeConfetti)) != 0xFF)
DestroyTask(taskId);
- sub_8152254();
- FreeSpriteTilesByTag(0x3E9);
- FreeSpritePaletteByTag(0x3E9);
+ ConfettiUtil_Free();
+ FreeSpriteTilesByTag(TAG_CONFETTI);
+ FreeSpritePaletteByTag(TAG_CONFETTI);
}
-static void sub_81752F4(struct UnkStruct_81520A8 *structPtr)
+static void UpdateDomeConfetti(struct ConfettiUtil *util)
{
- if (structPtr->yDelta > 110)
+ if (util->yDelta > 110)
{
- gTasks[structPtr->data[7]].data[15]--;
- sub_81525D0(structPtr->id);
+ // Destroy confetti after it falls far enough
+ gTasks[util->data[CONFETTI_TASK_ID]].tConfettiCount--;
+ ConfettiUtil_Remove(util->id);
}
else
{
- u8 var;
+ // Move confetti down
+ u8 sineIdx;
s32 rand;
- structPtr->yDelta++;
- structPtr->yDelta += structPtr->data[1];
+ util->yDelta++;
+ util->yDelta += util->data[CONFETTI_EXTRA_Y];
- var = structPtr->data[0];
+ sineIdx = util->data[CONFETTI_SINE_IDX];
rand = Random();
rand &= 3;
rand += 8;
- structPtr->xDelta = (rand) * ((gSineTable[var])) / 256;
+ util->xDelta = (rand) * ((gSineTable[sineIdx])) / 256;
- structPtr->data[0] += 4;
+ util->data[CONFETTI_SINE_IDX] += 4;
}
}
-static void Task_DoConfettiEffect(u8 taskId)
+static void Task_DoDomeConfetti(u8 taskId)
{
- u32 var = 0;
+ u32 id = 0;
u16 *data = gTasks[taskId].data;
- switch (data[0])
+ switch (tState)
{
case 0:
- if (!sub_81521C0(0x40))
+ if (!ConfettiUtil_Init(64))
{
+ // Init failed
DestroyTask(taskId);
- gSpecialVar_0x8004 = var;
+ gSpecialVar_0x8004 = 0;
gSpecialVar_0x8005 = 0xFFFF;
}
- LoadCompressedSpriteSheet(sHallOfFame_ConfettiSpriteSheet);
- LoadCompressedSpritePalette(sHallOfFame_ConfettiSpritePalette);
- data[0]++;
+ LoadCompressedSpriteSheet(sSpriteSheet_Confetti);
+ LoadCompressedSpritePalette(sSpritePalette_Confetti);
+ tState++;
break;
case 1:
- if (data[1] != 0 && data[1] % 3 == 0)
+ if (tTimer != 0 && tTimer % 3 == 0)
{
- var = sub_81524C4(&sOamData_85E53FC, 0x3E9, 0x3E9, Random() % 240, -(Random() % 8), Random() % 0x11, var);
- if (var != 0xFF)
+ // Create new confetti every 3 frames
+ id = ConfettiUtil_AddNew(&sOamData_Confetti,
+ TAG_CONFETTI,
+ TAG_CONFETTI,
+ Random() % 240,
+ -(Random() % 8),
+ Random() % ARRAY_COUNT(sAnims_Confetti),
+ id);
+ if (id != 0xFF)
{
- sub_8152438(var, sub_81752F4);
- if ((Random() & 3) == 0)
- sub_8152474(var, 1, 1);
- sub_8152474(var, 7, taskId);
- data[15]++;
+ ConfettiUtil_SetCallback(id, UpdateDomeConfetti);
+
+ // 1/4 of the confetti move an extra y coord every frame
+ if ((Random() % 4) == 0)
+ ConfettiUtil_SetData(id, CONFETTI_EXTRA_Y, 1);
+
+ ConfettiUtil_SetData(id, CONFETTI_TASK_ID, taskId);
+ tConfettiCount++;
}
}
- sub_81522D4();
- if (data[1] != 0)
- data[1]--;
- else if (data[15] == 0)
- data[0] = 0xFF;
+
+ ConfettiUtil_Update();
+ if (tTimer != 0)
+ tTimer--;
+ else if (tConfettiCount == 0)
+ tState = 0xFF;
break;
case 0xFF:
- StopConfettiEffect();
- gSpecialVar_0x8004 = var;
+ StopDomeConfetti();
+ gSpecialVar_0x8004 = 0;
gSpecialVar_0x8005 = 0xFFFF;
break;
}
diff --git a/src/image_processing_effects.c b/src/image_processing_effects.c
index 13794faf0..cbd8b9b37 100644
--- a/src/image_processing_effects.c
+++ b/src/image_processing_effects.c
@@ -5,7 +5,7 @@
// IWRAM common
u8 gCanvasColumnStart;
-u16 (*gCanvasPixels)[][32];
+u16 *gCanvasPixels;
u8 gCanvasRowEnd;
u8 gCanvasHeight;
u8 gCanvasColumnEnd;
@@ -125,7 +125,7 @@ static void ApplyImageEffect_RedChannelGrayscale(u8 delta)
for (j = 0; j < gCanvasRowEnd; j++)
{
- u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth];
+ u16 *pixelRow = &gCanvasPixels[(gCanvasRowStart + j) * gCanvasWidth];
u16 *pixel = &pixelRow[gCanvasColumnStart];
for (i = 0; i < gCanvasColumnEnd; i++, pixel++)
{
@@ -150,7 +150,7 @@ static void ApplyImageEffect_RedChannelGrayscaleHighlight(u8 highlight)
for (j = 0; j < gCanvasRowEnd; j++)
{
- u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth];
+ u16 *pixelRow = &gCanvasPixels[(gCanvasRowStart + j) * gCanvasWidth];
u16 *pixel = &pixelRow[gCanvasColumnStart];
for (i = 0; i < gCanvasColumnEnd; i++, pixel++)
{
@@ -179,7 +179,7 @@ static void ApplyImageEffect_Grayscale(void)
for (j = 0; j < gCanvasRowEnd; j++)
{
- u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth];
+ u16 *pixelRow = &gCanvasPixels[(gCanvasRowStart + j) * gCanvasWidth];
u16 *pixel = &pixelRow[gCanvasColumnStart];
for (i = 0; i < gCanvasColumnEnd; i++, pixel++)
{
@@ -195,7 +195,7 @@ static void ApplyImageEffect_Blur(void)
for (i = 0; i < gCanvasColumnEnd; i++)
{
- u16 *pixelRow = &(*gCanvasPixels)[0][gCanvasRowStart * gCanvasWidth];
+ u16 *pixelRow = &gCanvasPixels[gCanvasRowStart * gCanvasWidth];
u16 *pixel = &pixelRow[gCanvasColumnStart + i];
u16 prevPixel = *pixel;
@@ -221,7 +221,7 @@ static void ApplyImageEffect_PersonalityColor(u8 personality)
for (j = 0; j < gCanvasRowEnd; j++)
{
- u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth];
+ u16 *pixelRow = &gCanvasPixels[(gCanvasRowStart + j) * gCanvasWidth];
u16 *pixel = &pixelRow[gCanvasColumnStart];
for (i = 0; i < gCanvasColumnEnd; i++, pixel++)
{
@@ -237,7 +237,7 @@ static void ApplyImageEffect_BlackAndWhite(void)
for (j = 0; j < gCanvasRowEnd; j++)
{
- u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth];
+ u16 *pixelRow = &gCanvasPixels[(gCanvasRowStart + j) * gCanvasWidth];
u16 *pixel = &pixelRow[gCanvasColumnStart];
for (i = 0; i < gCanvasColumnEnd; i++, pixel++)
{
@@ -255,7 +255,7 @@ static void ApplyImageEffect_BlackOutline(void)
// Handle top row of pixels first.
for (j = 0; j < gCanvasRowEnd; j++)
{
- u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth];
+ u16 *pixelRow = &gCanvasPixels[(gCanvasRowStart + j) * gCanvasWidth];
pixel = &pixelRow[gCanvasColumnStart];
*pixel = QuantizePixel_BlackOutline(pixel, pixel + 1);
for (i = 1, pixel++; i < gCanvasColumnEnd - 1; i++, pixel++)
@@ -270,7 +270,7 @@ static void ApplyImageEffect_BlackOutline(void)
// Handle each column from left to right.
for (i = 0; i < gCanvasColumnEnd; i++)
{
- u16 *pixelRow = &(*gCanvasPixels)[0][gCanvasRowStart * gCanvasWidth];
+ u16 *pixelRow = &gCanvasPixels[gCanvasRowStart * gCanvasWidth];
pixel = &pixelRow[gCanvasColumnStart + i];
*pixel = QuantizePixel_BlackOutline(pixel, pixel + gCanvasWidth);
for (j = 1, pixel += gCanvasWidth; j < gCanvasRowEnd - 1; j++, pixel += gCanvasWidth)
@@ -289,7 +289,7 @@ static void ApplyImageEffect_Invert(void)
for (j = 0; j < gCanvasRowEnd; j++)
{
- u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth];
+ u16 *pixelRow = &gCanvasPixels[(gCanvasRowStart + j) * gCanvasWidth];
u16 *pixel = &pixelRow[gCanvasColumnStart];
for (i = 0; i < gCanvasColumnEnd; i++, pixel++)
{
@@ -306,7 +306,7 @@ static void ApplyImageEffect_Shimmer(void)
u16 prevPixel;
// First, invert all of the colors.
- pixel = (*gCanvasPixels)[0];
+ pixel = gCanvasPixels;
for (i = 0; i < 64; i++)
{
for (j = 0; j < 64; j++, pixel++)
@@ -319,7 +319,7 @@ static void ApplyImageEffect_Shimmer(void)
// Blur the pixels twice.
for (j = 0; j < 64; j++)
{
- pixel = &(*gCanvasPixels)[0][j];
+ pixel = &gCanvasPixels[j];
prevPixel = *pixel;
*pixel = 0x8000;
for (i = 1, pixel += 64; i < 63; i++, pixel += 64)
@@ -332,7 +332,7 @@ static void ApplyImageEffect_Shimmer(void)
}
*pixel = 0x8000;
- pixel = &(*gCanvasPixels)[0][j];
+ pixel = &gCanvasPixels[j];
prevPixel = *pixel;
*pixel = 0x8000;
for (i = 1, pixel += 64; i < 63; i++, pixel += 64)
@@ -350,7 +350,7 @@ static void ApplyImageEffect_Shimmer(void)
// Finally, invert colors back to the original color space.
// The above blur causes the outline areas to darken, which makes
// this inversion give the effect of light outlines.
- pixel = (*gCanvasPixels)[0];
+ pixel = gCanvasPixels;
for (i = 0; i < 64; i++)
{
for (j = 0; j < 64; j++, pixel++)
@@ -367,7 +367,7 @@ static void ApplyImageEffect_BlurRight(void)
for (j = 0; j < gCanvasRowEnd; j++)
{
- u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth];
+ u16 *pixelRow = &gCanvasPixels[(gCanvasRowStart + j) * gCanvasWidth];
u16 *pixel = &pixelRow[gCanvasColumnStart];
u16 prevPixel = *pixel;
for (i = 1, pixel++; i < gCanvasColumnEnd - 1; i++, pixel++)
@@ -387,7 +387,7 @@ static void ApplyImageEffect_BlurDown(void)
for (i = 0; i < gCanvasColumnEnd; i++)
{
- u16 *pixelRow = &(*gCanvasPixels)[0][gCanvasRowStart * gCanvasWidth];
+ u16 *pixelRow = &gCanvasPixels[gCanvasRowStart * gCanvasWidth];
u16 *pixel = &pixelRow[gCanvasColumnStart + i];
u16 prevPixel = *pixel;
for (j = 1, pixel += gCanvasWidth; j < gCanvasRowEnd - 1; j++, pixel += gCanvasWidth)
@@ -445,7 +445,7 @@ static void AddPointillismPoints(u16 arg0)
for (i = 0; i < points[0].delta; i++)
{
- u16 *pixel = &(*gCanvasPixels)[points[i].row * 2][points[i].column];
+ u16 *pixel = &gCanvasPixels[points[i].row * 64] + points[i].column;
if (!(0x8000 & *pixel))
{
@@ -910,7 +910,7 @@ static void QuantizePalette_Standard(bool8 useLimitedPalette)
gCanvasPalette[maxIndex] = RGB2(15, 15, 15);
for (j = 0; j < gCanvasRowEnd; j++)
{
- u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth];
+ u16 *pixelRow = &gCanvasPixels[(gCanvasRowStart + j) * gCanvasWidth];
u16 *pixel = &pixelRow[gCanvasColumnStart];
for (i = 0; i < gCanvasColumnEnd; i++, pixel++)
{
@@ -978,7 +978,7 @@ static void QuantizePalette_BlackAndWhite(void)
for (j = 0; j < gCanvasRowEnd; j++)
{
- u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth];
+ u16 *pixelRow = &gCanvasPixels[(gCanvasRowStart + j) * gCanvasWidth];
u16 *pixel = &pixelRow[gCanvasColumnStart];
for (i = 0; i < gCanvasColumnEnd; i++, pixel++)
{
@@ -1009,7 +1009,7 @@ static void QuantizePalette_GrayscaleSmall(void)
for (j = 0; j < gCanvasRowEnd; j++)
{
- u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth];
+ u16 *pixelRow = &gCanvasPixels[(gCanvasRowStart + j) * gCanvasWidth];
u16 *pixel = &pixelRow[gCanvasColumnStart];
for (i = 0; i < gCanvasColumnEnd; i++, pixel++)
{
@@ -1027,7 +1027,7 @@ static void QuantizePalette_Grayscale(void)
for (j = 0; j < gCanvasRowEnd; j++)
{
- u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth];
+ u16 *pixelRow = &gCanvasPixels[(gCanvasRowStart + j) * gCanvasWidth];
u16 *pixel = &pixelRow[gCanvasColumnStart];
for (i = 0; i < gCanvasColumnEnd; i++, pixel++)
{
@@ -1045,7 +1045,7 @@ static void QuantizePalette_PrimaryColors(void)
for (j = 0; j < gCanvasRowEnd; j++)
{
- u16 *pixelRow = &(*gCanvasPixels)[0][(gCanvasRowStart + j) * gCanvasWidth];
+ u16 *pixelRow = &gCanvasPixels[(gCanvasRowStart + j) * gCanvasWidth];
u16 *pixel = &pixelRow[gCanvasColumnStart];
for (i = 0; i < gCanvasColumnEnd; i++, pixel++)
{
diff --git a/src/item_menu.c b/src/item_menu.c
index 43e657328..591ebe018 100755
--- a/src/item_menu.c
+++ b/src/item_menu.c
@@ -1776,7 +1776,7 @@ void Task_ChooseHowManyToToss(u8 taskId)
if (AdjustQuantityAccordingToDPadInput(&tItemCount, data[2]) == TRUE)
{
- PrintItemDepositAmount(gBagMenu->unk817, tItemCount);
+ PrintItemDepositAmount(gBagMenu->windowPointers[7], tItemCount);
}
else if (gMain.newKeys & A_BUTTON)
{
@@ -2050,7 +2050,7 @@ void Task_BuyHowManyDialogueHandleInput(u8 taskId)
if (AdjustQuantityAccordingToDPadInput(&tItemCount, data[2]) == TRUE)
{
- PrintItemSoldAmount(gBagMenu->unk818, tItemCount, (ItemId_GetPrice(gSpecialVar_ItemId) / 2) * tItemCount);
+ PrintItemSoldAmount(gBagMenu->windowPointers[8], tItemCount, (ItemId_GetPrice(gSpecialVar_ItemId) / 2) * tItemCount);
}
else if (gMain.newKeys & A_BUTTON)
{
@@ -2094,7 +2094,7 @@ void sub_81AD8C8(u8 taskId)
LoadBagItemListBuffers(gBagPositionStruct.pocket);
data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos);
BagMenu_PrintCursor_(data[0], 2);
- PrintMoneyAmountInMoneyBox(gBagMenu->unk819, GetMoney(&gSaveBlock1Ptr->money), 0);
+ PrintMoneyAmountInMoneyBox(gBagMenu->windowPointers[9], GetMoney(&gSaveBlock1Ptr->money), 0);
gTasks[taskId].func = sub_81AD9C0;
}
@@ -2134,7 +2134,7 @@ void sub_81ADA7C(u8 taskId)
if (AdjustQuantityAccordingToDPadInput(&tItemCount, data[2]) == TRUE)
{
- PrintItemDepositAmount(gBagMenu->unk817, tItemCount);
+ PrintItemDepositAmount(gBagMenu->windowPointers[7], tItemCount);
}
else if (gMain.newKeys & A_BUTTON)
{
@@ -2359,7 +2359,7 @@ void SetupBagMenu_Textboxes(void)
DeactivateAllTextPrinters();
LoadUserWindowBorderGfx(0, 1, 0xE0);
LoadMessageBoxGfx(0, 10, 0xD0);
- sub_819A2BC(0xC0, 1);
+ ListMenuLoadStdPalAt(0xC0, 1);
LoadPalette(&gUnknown_0860F074, 0xF0, 0x20);
for (i = 0; i < 3; i++)
{
diff --git a/src/librfu_rfu.c b/src/librfu_rfu.c
index 3f5bd8b69..fe1d10834 100644
--- a/src/librfu_rfu.c
+++ b/src/librfu_rfu.c
@@ -488,7 +488,7 @@ static void rfu_CB_configGameData(u8 reqCommand, u16 reqResult)
for (i = 0; i < RFU_GAME_NAME_LENGTH; ++i)
gRfuLinkStatus->my.gname[i] = *gname_uname_p++;
++gname_uname_p;
- for (i = 0; i < RFU_USER_NAME_LENGTH; ++i)
+ for (i = 0; i < PLAYER_NAME_LENGTH + 1; ++i)
gRfuLinkStatus->my.uname[i] = *gname_uname_p++;
}
rfu_STC_REQ_callback(reqCommand, reqResult);
@@ -718,7 +718,7 @@ static void rfu_STC_readParentCandidateList(void)
for (j = 0; j < RFU_GAME_NAME_LENGTH; ++j)
target->gname[j] = *packet_p++;
++packet_p;
- for (j = 0; j < RFU_USER_NAME_LENGTH; ++j)
+ for (j = 0; j < PLAYER_NAME_LENGTH + 1; ++j)
target->uname[j] = *packet_p++;
++gRfuLinkStatus->findParentCount;
}
diff --git a/src/link.c b/src/link.c
index aed1afe30..e04e5e29d 100644
--- a/src/link.c
+++ b/src/link.c
@@ -1,5 +1,3 @@
-
-// Includes
#include "global.h"
#include "m4a.h"
#include "malloc.h"
@@ -30,10 +28,6 @@
#include "constants/rgb.h"
#include "constants/trade.h"
-extern u16 gHeldKeyCodeToSend;
-
-// Static type declarations
-
struct BlockTransfer
{
u16 pos;
@@ -51,15 +45,13 @@ struct LinkTestBGInfo
u32 dummy_C;
};
-// Static RAM declarations
-
static struct BlockTransfer sBlockSend;
static struct BlockTransfer sBlockRecv[MAX_LINK_PLAYERS];
static u32 sBlockSendDelayCounter;
-static u32 gUnknown_03000D54;
-static u8 gUnknown_03000D58;
+static bool32 sDummy1; // Never read
+static bool8 sDummy2; // Never assigned, read in unused function
static u32 sPlayerDataExchangeStatus;
-static u32 gUnknown_03000D60;
+static bool32 sDummy3; // Never read
static u8 sLinkTestLastBlockSendPos;
static u8 sLinkTestLastBlockRecvPos[MAX_LINK_PLAYERS];
static u8 sNumVBlanksWithoutSerialIntr;
@@ -74,15 +66,15 @@ u32 gLinkDebugSeed;
struct LinkPlayerBlock gLocalLinkPlayerBlock;
bool8 gLinkErrorOccurred;
u32 gLinkDebugFlags;
-u32 gFiller_03003074;
+u32 gLinkFiller1;
bool8 gRemoteLinkPlayersNotReceived[MAX_LINK_PLAYERS];
u8 gBlockReceivedStatus[MAX_LINK_PLAYERS];
-u32 gFiller_03003080;
+u32 gLinkFiller2;
u16 gLinkHeldKeys;
u16 gRecvCmds[MAX_RFU_PLAYERS][CMD_LENGTH];
u32 gLinkStatus;
-bool8 gUnknown_030030E4;
-bool8 gUnknown_030030E8;
+bool8 gLinkDummy1; // Never read
+bool8 gLinkDummy2; // Never read
bool8 gUnknown_030030EC[MAX_LINK_PLAYERS];
bool8 gUnknown_030030F0[MAX_LINK_PLAYERS];
u16 gUnknown_030030F4;
@@ -97,15 +89,13 @@ void (*gLinkCallback)(void);
u8 gShouldAdvanceLinkState;
u16 gLinkTestBlockChecksums[MAX_LINK_PLAYERS];
u8 gBlockRequestType;
-u32 gFiller_03003154;
-u32 gFiller_03003158;
-u32 gFiller_0300315c;
+u32 gLinkFiller3;
+u32 gLinkFiller4;
+u32 gLinkFiller5;
u8 gLastSendQueueCount;
struct Link gLink;
u8 gLastRecvQueueCount;
u16 gLinkSavedIme;
-u32 gFiller_03004138;
-u32 gFiller_0300413C;
EWRAM_DATA u8 gLinkTestDebugValuesEnabled = 0;
EWRAM_DATA u8 gUnknown_020223BD = 0;
@@ -124,16 +114,16 @@ EWRAM_DATA struct {
u8 lastSendQueueCount;
u8 unk_06;
} sLinkErrorBuffer = {};
-EWRAM_DATA u16 gUnknown_02022B08 = 0;
-EWRAM_DATA void *gUnknown_02022B0C = NULL;
+static EWRAM_DATA u16 sUnknown_02022B08 = 0;
+static EWRAM_DATA void *sLinkErrorBgTilemapBuffer = NULL;
// Static ROM declarations
static void InitLocalLinkPlayer(void);
-static void sub_80096BC(void);
+static void VBlankCB_LinkError(void);
static void CB2_LinkTest(void);
static void ProcessRecvCmds(u8 unused);
-static void sub_8009F70(void);
+static void LinkCB_SendHeldKeys(void);
static void ResetBlockSend(void);
static bool32 InitBlockSend(const void *src, size_t size);
static void LinkCB_BlockSendBegin(void);
@@ -155,7 +145,7 @@ static void sub_800AE5C(void);
static void CheckErrorStatus(void);
static void CB2_PrintErrorMessage(void);
static bool8 IsSioMultiMaster(void);
-static void sub_800B4A4(void);
+static void SetWirelessCommType0_Internal(void);
static void DisableSerial(void);
static void EnableSerial(void);
static void CheckMasterOrSlave(void);
@@ -172,29 +162,29 @@ static void SendRecvDone(void);
// .rodata
-ALIGNED(4) const u16 gWirelessLinkDisplayPal[] = INCBIN_U16("graphics/interface/wireless_link_display.gbapal");
-const u32 gWirelessLinkDisplayGfx[] = INCBIN_U32("graphics/interface/wireless_link_display.4bpp.lz");
-const u32 gWirelessLinkDisplayTilemap[] = INCBIN_U32("graphics/interface/wireless_link_display.bin.lz");
-const u16 gLinkTestDigitsPal[] = INCBIN_U16("graphics/interface/link_test_digits.gbapal");
-const u16 gLinkTestDigitsGfx[] = INCBIN_U16("graphics/interface/link_test_digits.4bpp");
-const u8 unkstring_82ed160[] = _("{HIGHLIGHT TRANSPARENT}{COLOR WHITE}");
-const u16 g2BlankTilesGfx[] = INCBIN_U16("graphics/interface/blank_1x2.4bpp");
-const struct BlockRequest gUnknown_082ED1A8[] = {
+static const u16 sWirelessLinkDisplayPal[] = INCBIN_U16("graphics/interface/wireless_link_display.gbapal");
+static const u32 sWirelessLinkDisplayGfx[] = INCBIN_U32("graphics/interface/wireless_link_display.4bpp.lz");
+static const u32 sWirelessLinkDisplayTilemap[] = INCBIN_U32("graphics/interface/wireless_link_display.bin.lz");
+static const u16 sLinkTestDigitsPal[] = INCBIN_U16("graphics/interface/link_test_digits.gbapal");
+static const u16 sLinkTestDigitsGfx[] = INCBIN_U16("graphics/interface/link_test_digits.4bpp");
+static const u8 sUnusedTransparentWhite[] = _("{HIGHLIGHT TRANSPARENT}{COLOR WHITE}");
+static const u16 s2BlankTilesGfx[] = INCBIN_U16("graphics/interface/blank_1x2.4bpp");
+static const struct BlockRequest sBlockRequests[] = {
{gBlockSendBuffer, 200},
{gBlockSendBuffer, 200},
{gBlockSendBuffer, 100},
{gBlockSendBuffer, 220},
{gBlockSendBuffer, 40}
};
-const u8 gBGControlRegs[] = {
+static const u8 sBGControlRegs[] = {
REG_OFFSET_BG0CNT,
REG_OFFSET_BG1CNT,
REG_OFFSET_BG2CNT,
REG_OFFSET_BG3CNT
};
-const char gASCIIGameFreakInc[] = "GameFreak inc.";
-const char gASCIITestPrint[] = "TEST PRINT\nP0\nP1\nP2\nP3";
-const struct BgTemplate gUnknown_082ED1FC[] = {
+static const char sASCIIGameFreakInc[] = "GameFreak inc.";
+static const char sASCIITestPrint[] = "TEST PRINT\nP0\nP1\nP2\nP3";
+static const struct BgTemplate sLinkErrorBgTemplates[] = {
{
.bg = 0,
.charBaseIndex = 2,
@@ -207,29 +197,50 @@ const struct BgTemplate gUnknown_082ED1FC[] = {
.priority = 1
}
};
-const struct WindowTemplate gUnknown_082ED204[] = {
- {0x00, 0x00, 0x00, 0x1E, 0x05, 0x0F, 0x0002},
- {0x00, 0x00, 0x06, 0x1E, 0x07, 0x0F, 0x0098},
- {0x00, 0x00, 0x0D, 0x1E, 0x07, 0x0F, 0x016A},
- DUMMY_WIN_TEMPLATE
+static const struct WindowTemplate sLinkErrorWindowTemplates[] = {
+ {
+ .bg = 0,
+ .tilemapLeft = 0,
+ .tilemapTop = 0,
+ .width = 30,
+ .height = 5,
+ .paletteNum = 15,
+ .baseBlock = 0x002
+ }, {
+ .bg = 0,
+ .tilemapLeft = 0,
+ .tilemapTop = 6,
+ .width = 30,
+ .height = 7,
+ .paletteNum = 15,
+ .baseBlock = 0x098
+ }, {
+ .bg = 0,
+ .tilemapLeft = 0,
+ .tilemapTop = 13,
+ .width = 30,
+ .height = 7,
+ .paletteNum = 15,
+ .baseBlock = 0x16A
+ }, DUMMY_WIN_TEMPLATE
};
static const u8 sTextColors[] = { TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY };
-static const u8 sUnused_082ED224[] = {0x00, 0xff, 0xfe, 0xff, 0x00};
+static const u8 sUnused_082ED224[] = {0x00, 0xFF, 0xFE, 0xFF, 0x00};
// .text
bool8 IsWirelessAdapterConnected(void)
{
- sub_800B488();
- sub_800E700();
+ SetWirelessCommType1();
+ InitRFUAPI();
if (rfu_LMAN_REQBN_softReset_and_checkID() == 0x8001)
{
rfu_REQ_stopMode();
rfu_waitREQComplete();
return TRUE;
}
- sub_800B4A4();
+ SetWirelessCommType0_Internal();
CloseLink();
RestoreSerialTimer3IntrHandlers();
return FALSE;
@@ -242,8 +253,8 @@ void Task_DestroySelf(u8 taskId)
static void InitLinkTestBG(u8 paletteNum, u8 bgNum, u8 screenBaseBlock, u8 charBaseBlock, u16 a4)
{
- LoadPalette(gLinkTestDigitsPal, paletteNum * 16, 0x20);
- DmaCopy16(3, gLinkTestDigitsGfx, (u16 *)BG_CHAR_ADDR(charBaseBlock) + (16 * a4), sizeof gLinkTestDigitsGfx);
+ LoadPalette(sLinkTestDigitsPal, paletteNum * 16, 0x20);
+ DmaCopy16(3, sLinkTestDigitsGfx, (u16 *)BG_CHAR_ADDR(charBaseBlock) + (16 * a4), sizeof sLinkTestDigitsGfx);
gLinkTestBGInfo.screenBaseBlock = screenBaseBlock;
gLinkTestBGInfo.paletteNum = paletteNum;
gLinkTestBGInfo.dummy_8 = a4;
@@ -265,12 +276,12 @@ static void InitLinkTestBG(u8 paletteNum, u8 bgNum, u8 screenBaseBlock, u8 charB
void sub_80094EC(u8 paletteNum, u8 bgNum, u8 screenBaseBlock, u8 charBaseBlock)
{
- LoadPalette(gLinkTestDigitsPal, paletteNum * 16, 0x20);
- DmaCopy16(3, gLinkTestDigitsGfx, (u16 *)BG_CHAR_ADDR(charBaseBlock), sizeof gLinkTestDigitsGfx);
+ LoadPalette(sLinkTestDigitsPal, paletteNum * 16, 0x20);
+ DmaCopy16(3, sLinkTestDigitsGfx, (u16 *)BG_CHAR_ADDR(charBaseBlock), sizeof sLinkTestDigitsGfx);
gLinkTestBGInfo.screenBaseBlock = screenBaseBlock;
gLinkTestBGInfo.paletteNum = paletteNum;
gLinkTestBGInfo.dummy_8 = 0;
- SetGpuReg(gBGControlRegs[bgNum], BGCNT_SCREENBASE(screenBaseBlock) | BGCNT_CHARBASE(charBaseBlock));
+ SetGpuReg(sBGControlRegs[bgNum], BGCNT_SCREENBASE(screenBaseBlock) | BGCNT_CHARBASE(charBaseBlock));
}
void LinkTestScreen(void)
@@ -280,9 +291,9 @@ void LinkTestScreen(void)
ResetSpriteData();
FreeAllSpritePalettes();
ResetTasks();
- SetVBlankCallback(sub_80096BC);
+ SetVBlankCallback(VBlankCB_LinkError);
ResetBlockSend();
- gLinkType = LINKTYPE_0x1111;
+ gLinkType = LINKTYPE_TRADE;
OpenLink();
SeedRng(gMain.vblankCounter2);
for (i = 0; i < MAX_LINK_PLAYERS; i++)
@@ -296,7 +307,7 @@ void LinkTestScreen(void)
AnimateSprites();
BuildOamBuffer();
UpdatePaletteFade();
- gUnknown_03000D60 = 0;
+ sDummy3 = FALSE;
InitLocalLinkPlayer();
CreateTask(Task_PrintTestData, 0);
SetMainCallback2(CB2_LinkTest);
@@ -323,7 +334,7 @@ static void InitLocalLinkPlayer(void)
}
}
-static void sub_80096BC(void)
+static void VBlankCB_LinkError(void)
{
LoadOam();
ProcessSpriteCopyRequests();
@@ -334,9 +345,9 @@ static void InitLink(void)
{
int i;
- for (i = 0; i < 8; i++)
+ for (i = 0; i < CMD_LENGTH; i++)
{
- gSendCmd[i] = 0xefff;
+ gSendCmd[i] = 0xEfff;
}
gLinkOpen = TRUE;
EnableSerial();
@@ -365,15 +376,15 @@ void OpenLink(void)
gSuppressLinkErrorMessage = FALSE;
ResetBlockReceivedFlags();
ResetBlockSend();
- gUnknown_03000D54 = 0;
- gUnknown_030030E8 = FALSE;
- gUnknown_030030E4 = FALSE;
+ sDummy1 = FALSE;
+ gLinkDummy2 = FALSE;
+ gLinkDummy1 = FALSE;
gUnknown_030030F4 = 0;
CreateTask(Task_TriggerHandshake, 2);
}
else
{
- sub_800E700();
+ InitRFUAPI();
}
gReceivedRemoteLinkPlayers = 0;
for (i = 0; i < MAX_LINK_PLAYERS; i++)
@@ -389,7 +400,7 @@ void CloseLink(void)
gReceivedRemoteLinkPlayers = FALSE;
if (gWirelessCommType)
{
- sub_800EDD4();
+ LinkRfu_Shutdown();
}
gLinkOpen = FALSE;
DisableSerial();
@@ -482,7 +493,7 @@ u16 LinkMain2(const u16 *heldKeys)
{
return 0;
}
- for (i = 0; i < 8; i++)
+ for (i = 0; i < CMD_LENGTH; i++)
{
gSendCmd[i] = 0;
}
@@ -536,8 +547,8 @@ static void ProcessRecvCmds(u8 unused)
InitLocalLinkPlayer();
block = &gLocalLinkPlayerBlock;
block->linkPlayer = gLocalLinkPlayer;
- memcpy(block->magic1, gASCIIGameFreakInc, sizeof(block->magic1) - 1);
- memcpy(block->magic2, gASCIIGameFreakInc, sizeof(block->magic2) - 1);
+ memcpy(block->magic1, sASCIIGameFreakInc, sizeof(block->magic1) - 1);
+ memcpy(block->magic2, sASCIIGameFreakInc, sizeof(block->magic2) - 1);
InitBlockSend(block, sizeof(*block));
break;
}
@@ -545,10 +556,10 @@ static void ProcessRecvCmds(u8 unused)
gLinkPartnersHeldKeys[i] = gRecvCmds[i][1];
break;
case LINKCMD_0x5555:
- gUnknown_030030E8 = TRUE;
+ gLinkDummy2 = TRUE;
break;
case LINKCMD_0x5566:
- gUnknown_030030E8 = TRUE;
+ gLinkDummy2 = TRUE;
break;
case LINKCMD_INIT_BLOCK:
{
@@ -602,8 +613,8 @@ static void ProcessRecvCmds(u8 unused)
linkPlayer->progressFlags = 0;
}
sub_800B524(linkPlayer);
- if (strcmp(block->magic1, gASCIIGameFreakInc) != 0
- || strcmp(block->magic2, gASCIIGameFreakInc) != 0)
+ if (strcmp(block->magic1, sASCIIGameFreakInc) != 0
+ || strcmp(block->magic2, sASCIIGameFreakInc) != 0)
{
SetMainCallback2(CB2_LinkError);
}
@@ -629,7 +640,7 @@ static void ProcessRecvCmds(u8 unused)
sub_800A418();
break;
case LINKCMD_0xCCCC:
- SendBlock(0, gUnknown_082ED1A8[gRecvCmds[i][1]].address, gUnknown_082ED1A8[gRecvCmds[i][1]].size);
+ SendBlock(0, sBlockRequests[gRecvCmds[i][1]].address, sBlockRequests[gRecvCmds[i][1]].size);
break;
case LINKCMD_SEND_HELD_KEYS_2:
gLinkPartnersHeldKeys[i] = gRecvCmds[i][1];
@@ -705,70 +716,56 @@ static void BuildSendCmd(u16 command)
}
}
-void sub_8009F18(void)
+void StartSendingKeysToLink(void)
{
if (gWirelessCommType)
- {
- sub_800F804();
- }
- gLinkCallback = sub_8009F70;
+ StartSendingKeysToRfu();
+
+ gLinkCallback = LinkCB_SendHeldKeys;
}
bool32 IsSendingKeysToLink(void)
{
if (gWirelessCommType)
- {
return IsSendingKeysToRfu();
- }
- if (gLinkCallback == sub_8009F70)
- {
+
+ if (gLinkCallback == LinkCB_SendHeldKeys)
return TRUE;
- }
+
return FALSE;
}
-static void sub_8009F70(void)
+static void LinkCB_SendHeldKeys(void)
{
if (gReceivedRemoteLinkPlayers == TRUE)
- {
BuildSendCmd(LINKCMD_SEND_HELD_KEYS_2);
- }
}
void ClearLinkCallback(void)
{
if (gWirelessCommType)
- {
ClearLinkRfuCallback();
- }
else
- {
gLinkCallback = NULL;
- }
}
void ClearLinkCallback_2(void)
{
if (gWirelessCommType)
- {
ClearLinkRfuCallback();
- }
else
- {
gLinkCallback = NULL;
- }
}
u8 GetLinkPlayerCount(void)
{
if (gWirelessCommType)
- {
- return sub_80104F4();
- }
+ return Rfu_GetLinkPlayerCount();
+
return EXTRACT_PLAYER_COUNT(gLinkStatus);
}
-static int sub_8009FF8(u32 version1, u32 version2)
+static int AreAnyLinkPlayersUsingVersions(u32 version1, u32 version2)
{
int i;
u8 nPlayers;
@@ -776,22 +773,22 @@ static int sub_8009FF8(u32 version1, u32 version2)
nPlayers = GetLinkPlayerCount();
for (i = 0; i < nPlayers; i++)
{
- if ((gLinkPlayers[i].version & 0xFF) == version1 || (gLinkPlayers[i].version & 0xFF) == version2)
- {
+ if ((gLinkPlayers[i].version & 0xFF) == version1
+ || (gLinkPlayers[i].version & 0xFF) == version2)
return 1;
- }
}
return -1;
}
-u32 sub_800A03C(void)
+u32 LinkDummy_Return2(void)
{
return 2;
}
-bool32 sub_800A040(void)
+// Unused
+static bool32 IsFullLinkGroupWithNoRS(void)
{
- if (GetLinkPlayerCount() != 4 || sub_8009FF8(VERSION_RUBY, VERSION_SAPPHIRE) < 0)
+ if (GetLinkPlayerCount() != MAX_LINK_PLAYERS || AreAnyLinkPlayersUsingVersions(VERSION_RUBY, VERSION_SAPPHIRE) < 0)
{
return FALSE;
}
@@ -800,18 +797,18 @@ bool32 sub_800A040(void)
bool32 Link_AnyPartnersPlayingRubyOrSapphire(void)
{
- if (sub_8009FF8(VERSION_RUBY, VERSION_SAPPHIRE) >= 0)
+ if (AreAnyLinkPlayersUsingVersions(VERSION_RUBY, VERSION_SAPPHIRE) >= 0)
{
return TRUE;
}
return FALSE;
}
-bool32 sub_800A07C(void)
+bool32 Link_AnyPartnersPlayingFRLG_JP(void)
{
int i;
- i = sub_8009FF8(VERSION_FIRE_RED, VERSION_LEAF_GREEN);
+ i = AreAnyLinkPlayersUsingVersions(VERSION_FIRE_RED, VERSION_LEAF_GREEN);
if (i >= 0 && gLinkPlayers[i].language == LANGUAGE_JAPANESE)
{
return TRUE;
@@ -826,23 +823,23 @@ void OpenLinkTimed(void)
OpenLink();
}
-u8 GetLinkPlayerDataExchangeStatusTimed(int lower, int upper)
+u8 GetLinkPlayerDataExchangeStatusTimed(int minPlayers, int maxPlayers)
{
int i;
int count;
u32 index;
- u8 cmpVal;
+ u8 numPlayers;
u32 linkType1;
u32 linkType2;
count = 0;
if (gReceivedRemoteLinkPlayers == TRUE)
{
- cmpVal = GetLinkPlayerCount_2();
- if (lower > cmpVal || cmpVal > upper)
+ numPlayers = GetLinkPlayerCount_2();
+ if (minPlayers > numPlayers || numPlayers > maxPlayers)
{
- sPlayerDataExchangeStatus = EXCHANGE_STAT_6;
- return 6;
+ sPlayerDataExchangeStatus = EXCHANGE_WRONG_NUM_PLAYERS;
+ return sPlayerDataExchangeStatus;
}
else
{
@@ -860,19 +857,19 @@ u8 GetLinkPlayerDataExchangeStatusTimed(int lower, int upper)
}
if (count == GetLinkPlayerCount())
{
- if (gLinkPlayers[0].linkType == 0x1133)
+ if (gLinkPlayers[0].linkType == LINKTYPE_TRADE_SETUP)
{
switch (GetGameProgressForLinkTrade())
{
- case TRADE_PLAYER_NOT_READY:
- sPlayerDataExchangeStatus = EXCHANGE_PLAYER_NOT_READY;
- break;
- case TRADE_PARTNER_NOT_READY:
- sPlayerDataExchangeStatus = EXCHANGE_PARTNER_NOT_READY;
- break;
- case TRADE_BOTH_PLAYERS_READY:
- sPlayerDataExchangeStatus = EXCHANGE_COMPLETE;
- break;
+ case TRADE_PLAYER_NOT_READY:
+ sPlayerDataExchangeStatus = EXCHANGE_PLAYER_NOT_READY;
+ break;
+ case TRADE_PARTNER_NOT_READY:
+ sPlayerDataExchangeStatus = EXCHANGE_PARTNER_NOT_READY;
+ break;
+ case TRADE_BOTH_PLAYERS_READY:
+ sPlayerDataExchangeStatus = EXCHANGE_COMPLETE;
+ break;
}
}
else
@@ -882,11 +879,14 @@ u8 GetLinkPlayerDataExchangeStatusTimed(int lower, int upper)
}
else
{
- sPlayerDataExchangeStatus = EXCHANGE_IN_PROGRESS;
+ sPlayerDataExchangeStatus = EXCHANGE_DIFF_SELECTIONS;
linkType1 = gLinkPlayers[GetMultiplayerId()].linkType;
linkType2 = gLinkPlayers[GetMultiplayerId() ^ 1].linkType;
- if ((linkType1 == 0x2266 && linkType2 == 0x2277) || (linkType1 == 0x2277 && linkType2 == 0x2266))
+ if ((linkType1 == LINKTYPE_BATTLE_TOWER_50 && linkType2 == LINKTYPE_BATTLE_TOWER_OPEN)
+ || (linkType1 == LINKTYPE_BATTLE_TOWER_OPEN && linkType2 == LINKTYPE_BATTLE_TOWER_50))
{
+ // 3 below indicates partner made different level mode selection
+ // See BattleFrontier_BattleTowerLobby_EventScript_AbortLinkDifferentSelections
gSpecialVar_0x8005 = 3;
}
}
@@ -921,7 +921,7 @@ bool8 IsLinkPlayerDataExchangeComplete(void)
else
{
retval = FALSE;
- sPlayerDataExchangeStatus = EXCHANGE_IN_PROGRESS;
+ sPlayerDataExchangeStatus = EXCHANGE_DIFF_SELECTIONS;
}
return retval;
}
@@ -959,7 +959,7 @@ static bool32 InitBlockSend(const void *src, size_t size)
sBlockSend.active = TRUE;
sBlockSend.size = size;
sBlockSend.pos = 0;
- if (size > 0x100)
+ if (size > BLOCK_BUFFER_SIZE)
{
sBlockSend.src = src;
}
@@ -992,7 +992,7 @@ static void LinkCB_BlockSend(void)
src = sBlockSend.src;
gSendCmd[0] = LINKCMD_CONT_BLOCK;
- for (i = 0; i < 7; i++)
+ for (i = 0; i < CMD_LENGTH - 1; i++)
{
gSendCmd[i + 1] = (src[sBlockSend.pos + i * 2 + 1] << 8) | src[sBlockSend.pos + i * 2];
}
@@ -1043,7 +1043,7 @@ u8 GetMultiplayerId(void)
{
if (gWirelessCommType == TRUE)
{
- return rfu_get_multiplayer_id();
+ return Rfu_GetMultiplayerId();
}
return SIO_MULTI_CNT->id;
}
@@ -1060,7 +1060,7 @@ bool8 SendBlock(u8 unused, const void *src, u16 size)
{
if (gWirelessCommType == TRUE)
{
- return sub_800FE84(src, size);
+ return Rfu_InitBlockSend(src, size);
}
return InitBlockSend(src, size);
}
@@ -1093,7 +1093,7 @@ u8 GetBlockReceivedStatus(void)
{
if (gWirelessCommType == TRUE)
{
- return sub_800FCD8();
+ return Rfu_GetBlockReceivedStatus();
}
return (gBlockReceivedStatus[3] << 3) | (gBlockReceivedStatus[2] << 2) | (gBlockReceivedStatus[1] << 1) | (gBlockReceivedStatus[0] << 0);
}
@@ -1102,7 +1102,7 @@ static void SetBlockReceivedFlag(u8 who)
{
if (gWirelessCommType == TRUE)
{
- sub_800F6FC(who);
+ Rfu_SetBlockReceivedFlag(who);
}
else
{
@@ -1118,7 +1118,7 @@ void ResetBlockReceivedFlags(void)
{
for (i = 0; i < MAX_RFU_PLAYERS; i++)
{
- sub_800F728(i);
+ Rfu_ResetBlockReceivedFlag(i);
}
}
else
@@ -1134,7 +1134,7 @@ void ResetBlockReceivedFlag(u8 who)
{
if (gWirelessCommType == TRUE)
{
- sub_800F728(who);
+ Rfu_ResetBlockReceivedFlag(who);
}
else if (gBlockReceivedStatus[who])
{
@@ -1261,7 +1261,7 @@ static void Task_PrintTestData(u8 taskId)
char sp[32];
int i;
- strcpy(sp, gASCIITestPrint);
+ strcpy(sp, sASCIITestPrint);
LinkTest_prntstr(sp, 5, 2);
LinkTest_prnthex(gShouldAdvanceLinkState, 2, 1, 2);
LinkTest_prnthex(gLinkStatus, 15, 1, 8);
@@ -1289,7 +1289,7 @@ void SetLinkDebugValues(u32 seed, u32 flags)
gLinkDebugFlags = flags;
}
-u8 sub_800A9A8(void)
+u8 GetSavedLinkPlayerCountAsBitFlags(void)
{
int i;
u8 flags;
@@ -1302,7 +1302,7 @@ u8 sub_800A9A8(void)
return flags;
}
-u8 sub_800A9D8(void)
+u8 GetLinkPlayerCountAsBitFlags(void)
{
int i;
u8 flags;
@@ -1315,11 +1315,11 @@ u8 sub_800A9D8(void)
return flags;
}
-void sub_800AA04(u8 a0)
+void SaveLinkPlayers(u8 playerCount)
{
int i;
- gSavedLinkPlayerCount = a0;
+ gSavedLinkPlayerCount = playerCount;
gSavedMultiplayerId = GetMultiplayerId();
for (i = 0; i < MAX_RFU_PLAYERS; i++)
{
@@ -1334,17 +1334,17 @@ u8 GetSavedPlayerCount(void)
return gSavedLinkPlayerCount;
}
-u8 sub_800AA54(void)
+// Unused
+static u8 GetSavedMultiplayerId(void)
{
return gSavedMultiplayerId;
}
-bool8 sub_800AA60(void)
+bool8 DoesLinkPlayerCountMatchSaved(void)
{
int i;
- unsigned count;
+ u32 count = 0;
- count = 0;
for (i = 0; i < gSavedLinkPlayerCount; i++)
{
if (gLinkPlayers[i].trainerId == gSavedLinkPlayers[i].trainerId)
@@ -1352,9 +1352,7 @@ bool8 sub_800AA60(void)
if (gLinkType == LINKTYPE_BATTLE_TOWER)
{
if (gLinkType == gLinkPlayers[i].linkType)
- {
count++;
- }
}
else
{
@@ -1372,7 +1370,7 @@ bool8 sub_800AA60(void)
return FALSE;
}
-void sub_800AAF4(void)
+void ClearSavedLinkPlayers(void)
{
int i;
@@ -1383,13 +1381,14 @@ void sub_800AAF4(void)
}
}
-void sub_800AB18(void)
+void CheckLinkPlayersMatchSaved(void)
{
u8 i;
for (i = 0; i < gSavedLinkPlayerCount; i++)
{
- if (gSavedLinkPlayers[i].trainerId != gLinkPlayers[i].trainerId || StringCompare(gSavedLinkPlayers[i].name, gLinkPlayers[i].name) != 0)
+ if (gSavedLinkPlayers[i].trainerId != gLinkPlayers[i].trainerId
+ || StringCompare(gSavedLinkPlayers[i].name, gLinkPlayers[i].name) != 0)
{
gLinkErrorOccurred = TRUE;
CloseLink();
@@ -1418,9 +1417,10 @@ bool8 IsLinkMaster(void)
return EXTRACT_MASTER(gLinkStatus);
}
-u8 sub_800ABE8(void)
+// Unused
+static u8 GetDummy2(void)
{
- return gUnknown_03000D58;
+ return sDummy2;
}
void sub_800ABF4(u16 a0)
@@ -1434,7 +1434,7 @@ void sub_800ABF4(u16 a0)
if (gLinkCallback == NULL)
{
gLinkCallback = sub_800AC80;
- gUnknown_030030E4 = FALSE;
+ gLinkDummy1 = FALSE;
gUnknown_030030F4 = a0;
}
}
@@ -1450,12 +1450,12 @@ void sub_800AC34(void)
{
if (gLinkCallback != NULL)
{
- gUnknown_02022B08++;
+ sUnknown_02022B08++;
}
else
{
gLinkCallback = sub_800AC80;
- gUnknown_030030E4 = FALSE;
+ gLinkDummy1 = FALSE;
gUnknown_030030F4 = 0;
}
}
@@ -1491,7 +1491,7 @@ static void sub_800ACAC(void)
gLinkVSyncDisabled = TRUE;
CloseLink();
gLinkCallback = NULL;
- gUnknown_030030E4 = TRUE;
+ gLinkDummy1 = TRUE;
}
}
@@ -1505,12 +1505,12 @@ void sub_800AD10(void)
{
if (gLinkCallback != NULL)
{
- gUnknown_02022B08++;
+ sUnknown_02022B08++;
}
else
{
gLinkCallback = sub_800AD5C;
- gUnknown_030030E4 = FALSE;
+ gLinkDummy1 = FALSE;
gUnknown_030030F4 = 0;
}
}
@@ -1550,7 +1550,7 @@ static void sub_800AD88(void)
gLinkVSyncDisabled = TRUE;
CloseLink();
gLinkCallback = NULL;
- gUnknown_030030E4 = TRUE;
+ gLinkDummy1 = TRUE;
}
}
@@ -1566,7 +1566,7 @@ void sub_800ADF8(void)
{
gLinkCallback = sub_800AE30;
}
- gUnknown_030030E4 = FALSE;
+ gLinkDummy1 = FALSE;
}
}
@@ -1618,7 +1618,7 @@ static void CheckErrorStatus(void)
}
}
-void sub_800AF18(u32 status, u8 lastSendQueueCount, u8 lastRecvQueueCount, u8 unk_06)
+void BufferLinkErrorInfo(u32 status, u8 lastSendQueueCount, u8 lastRecvQueueCount, bool8 unk_06)
{
sLinkErrorBuffer.status = status;
sLinkErrorBuffer.lastSendQueueCount = lastSendQueueCount;
@@ -1647,14 +1647,14 @@ void CB2_LinkError(void)
{
gWirelessCommType = 3;
}
- sub_800E604();
+ ResetLinkRfuGFLayer();
}
- SetVBlankCallback(sub_80096BC);
+ SetVBlankCallback(VBlankCB_LinkError);
ResetBgsAndClearDma3BusyFlags(0);
- InitBgsFromTemplates(0, gUnknown_082ED1FC, 2);
- gUnknown_02022B0C = tilemapBuffer = malloc(0x800);
+ InitBgsFromTemplates(0, sLinkErrorBgTemplates, ARRAY_COUNT(sLinkErrorBgTemplates));
+ sLinkErrorBgTilemapBuffer = tilemapBuffer = malloc(0x800);
SetBgTilemapBuffer(1, tilemapBuffer);
- if (InitWindows(gUnknown_082ED204))
+ if (InitWindows(sLinkErrorWindowTemplates))
{
DeactivateAllTextPrinters();
ResetTempTileDataBuffers();
@@ -1680,11 +1680,11 @@ void CB2_LinkError(void)
static void sub_800B080(void)
{
- LoadBgTiles(0, g2BlankTilesGfx, 0x20, 0);
- DecompressAndLoadBgGfxUsingHeap(1, gWirelessLinkDisplayGfx, FALSE, 0, 0);
- CopyToBgTilemapBuffer(1, gWirelessLinkDisplayTilemap, 0, 0);
+ LoadBgTiles(0, s2BlankTilesGfx, 0x20, 0);
+ DecompressAndLoadBgGfxUsingHeap(1, sWirelessLinkDisplayGfx, FALSE, 0, 0);
+ CopyToBgTilemapBuffer(1, sWirelessLinkDisplayTilemap, 0, 0);
CopyBgTilemapBufferToVram(1);
- LoadPalette(gWirelessLinkDisplayPal, 0, 0x20);
+ LoadPalette(sWirelessLinkDisplayPal, 0, 0x20);
FillWindowPixelBuffer(0, PIXEL_FILL(0));
FillWindowPixelBuffer(2, PIXEL_FILL(0));
AddTextPrinterParameterized3(0, 3, 2, 6, sTextColors, 0, gText_CommErrorEllipsis);
@@ -1697,7 +1697,7 @@ static void sub_800B080(void)
static void sub_800B138(void)
{
- LoadBgTiles(0, g2BlankTilesGfx, 0x20, 0);
+ LoadBgTiles(0, s2BlankTilesGfx, 0x20, 0);
FillWindowPixelBuffer(1, PIXEL_FILL(0));
FillWindowPixelBuffer(2, PIXEL_FILL(0));
AddTextPrinterParameterized3(1, 3, 2, 0, sTextColors, 0, gText_CommErrorCheckConnections);
@@ -1810,12 +1810,12 @@ void sub_800B348(void)
InitLocalLinkPlayer();
block = &gLocalLinkPlayerBlock;
block->linkPlayer = gLocalLinkPlayer;
- memcpy(block->magic1, gASCIIGameFreakInc, sizeof(block->magic1) - 1);
- memcpy(block->magic2, gASCIIGameFreakInc, sizeof(block->magic2) - 1);
+ memcpy(block->magic1, sASCIIGameFreakInc, sizeof(block->magic1) - 1);
+ memcpy(block->magic2, sASCIIGameFreakInc, sizeof(block->magic2) - 1);
memcpy(gBlockSendBuffer, block, sizeof(*block));
}
-void sub_800B3A4(u32 who)
+void LinkPlayerFromBlock(u32 who)
{
u8 who_ = who;
struct LinkPlayerBlock *block;
@@ -1825,7 +1825,7 @@ void sub_800B3A4(u32 who)
player = &gLinkPlayers[who_];
*player = block->linkPlayer;
sub_800B524(player);
- if (strcmp(block->magic1, gASCIIGameFreakInc) != 0 || strcmp(block->magic2, gASCIIGameFreakInc) != 0)
+ if (strcmp(block->magic1, sASCIIGameFreakInc) != 0 || strcmp(block->magic2, sASCIIGameFreakInc) != 0)
{
SetMainCallback2(CB2_LinkError);
}
@@ -1860,7 +1860,7 @@ bool8 HandleLinkConnection(void)
return FALSE;
}
-void sub_800B488(void)
+void SetWirelessCommType1(void)
{
if (gReceivedRemoteLinkPlayers == 0)
{
@@ -1868,7 +1868,7 @@ void sub_800B488(void)
}
}
-static void sub_800B4A4(void)
+static void SetWirelessCommType0_Internal(void)
{
if (gReceivedRemoteLinkPlayers == 0)
{
@@ -1876,7 +1876,7 @@ static void sub_800B4A4(void)
}
}
-void sub_800B4C0(void)
+void SetWirelessCommType0(void)
{
if (gReceivedRemoteLinkPlayers == 0)
{
diff --git a/src/link_rfu_2.c b/src/link_rfu_2.c
index 3ee193ec6..34e9f719b 100644
--- a/src/link_rfu_2.c
+++ b/src/link_rfu_2.c
@@ -19,34 +19,91 @@
#include "save.h"
#include "mystery_gift.h"
-extern u16 gHeldKeyCodeToSend;
-
-u32 gf_rfu_REQ_api[RFU_API_BUFF_SIZE_RAM / 4];
-struct UnkRfuStruct_2 Rfu;
-
-BSS_DATA u8 gUnknown_03000D78[8];
-BSS_DATA u8 gUnknown_03000D80[16];
-BSS_DATA u16 gUnknown_03000D90[8];
-
-EWRAM_DATA struct GFtgtGname gUnknown_02022B14 = {};
-EWRAM_DATA ALIGNED(2) u8 gUnknown_02022B22[RFU_USER_NAME_LENGTH] = {};
-EWRAM_DATA INIT_PARAM gUnknown_02022B2C = {};
-EWRAM_DATA struct UnkLinkRfuStruct_02022B44 gUnknown_02022B44 = {};
-
-// Static ROM declarations
+struct SioInfo
+{
+ char magic[15]; // PokemonSioInfo
+ u8 playerCount;
+ u8 linkPlayerIdx[RFU_CHILD_MAX];
+ struct LinkPlayer linkPlayers[MAX_RFU_PLAYERS];
+ u8 filler[92];
+};
-// .rodata
+struct RfuDebug
+{
+ u8 filler0[6];
+ u16 unk_06;
+ u8 filler1[6];
+ vu8 unk_0e;
+ u8 unk_0f;
+ u8 filler2[84];
+ u16 unk_64;
+ u8 filler3[29];
+ u8 unk_83;
+ u8 filler4[88];
+};
-const INIT_PARAM gUnknown_082ED608 = {
- 0x04, 0x20, 0x00, 0x00, 0x02,
- (u8 *)&gUnknown_02022B14,
- gUnknown_02022B22,
- 0x01, 0x00, 0x258, 0x12c
+u32 gf_rfu_REQ_api[RFU_API_BUFF_SIZE_RAM / 4];
+struct GFRfuManager Rfu;
+
+static u8 sHeldKeyCount;
+static u8 sResendBlock8[16];
+static u16 sResendBlock16[8];
+
+EWRAM_DATA struct GFtgtGname gHostRFUtgtGnameBuffer = {};
+EWRAM_DATA u8 gHostRFUtgtUnameBuffer[PLAYER_NAME_LENGTH + 1] = {};
+static EWRAM_DATA INIT_PARAM sRfuReqConfig = {};
+static EWRAM_DATA struct RfuDebug sRfuDebug = {};
+
+static void ResetSendDataManager(struct RfuBlockSend *);
+static void sub_800EAB4(void);
+static void sub_800EAFC(void);
+static void sub_800ED34(u16);
+static void sub_800EDBC(u16);
+static void UpdateBackupQueue(void);
+static void Task_ExchangeLinkPlayers(u8);
+static void RfuHandleReceiveCommand(u8);
+static void CallRfuFunc(void);
+static void RfuPrepareSendBuffer(u16);
+static void HandleBlockSend(void);
+static void SendNextBlock(void);
+static void SendLastBlock(void);
+static u8 GetPartnerIndexByNameAndTrainerID(const u8 *, u16);
+static void UpdateChildStatuses(void);
+static s32 sub_80107A0(void);
+static void sub_801084C(u8);
+static void ClearSelectedLinkPlayerIds(u16);
+static void ValidateAndReceivePokemonSioInfo(void *);
+static void sub_8010D0C(u8);
+static void sub_80115EC(s32);
+static void sub_8011BF8(void);
+static void RfuReqDisconnectSlot(u32);
+static void sub_8011E94(u32, u32);
+static void sub_801209C(u8);
+static void Debug_PrintEmpty(void);
+static void Task_Idle(u8);
+
+static const INIT_PARAM sRfuReqConfigTemplate = {
+ .maxMFrame = 4,
+ .MC_TimerCount = 32,
+ .availSlot_flag = 0,
+ .mboot_flag = 0,
+ .serialNo = 2,
+ .gameName = (void *)&gHostRFUtgtGnameBuffer,
+ .userName = gHostRFUtgtUnameBuffer,
+ .fastSearchParent_flag = TRUE,
+ .linkRecovery_enable = FALSE,
+ .linkRecovery_period = 600,
+ .NI_failCounter_limit = 0x12c
};
-const u8 gUnknown_082ED620[] = {
- 0, 3, 2, 1, 0
+
+static const u8 sAvailSlots[] = {
+ [1] = AVAIL_SLOT1,
+ [2] = AVAIL_SLOT2,
+ [3] = AVAIL_SLOT3,
+ [4] = AVAIL_SLOT4
};
-const u32 gUnknown_082ED628[] = {
+
+static const u32 sAllBlocksReceived[] = {
0x000000,
0x000001,
0x000003,
@@ -73,35 +130,43 @@ const u32 gUnknown_082ED628[] = {
0x7fffff,
0xffffff
};
-const u8 gUnknown_082ED68C[] = {
+
+static const u8 sUnknown_082ED68C[] = {
0, 0, 1,
1, 2, 2,
2, 2, 3
};
-const u8 gUnknown_082ED695[] = {
+
+static const u8 sUnknown_082ED695[] = {
0, 1, 1, 2,
1, 2, 2, 3,
1, 2, 2, 3,
2, 3, 3, 4
};
-const u8 gUnknown_082ED6A5[] = {
+
+static const u8 sUnknown_082ED6A5[] = {
0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
};
-const struct {
+
+static const struct {
u8 *buffer;
u32 size;
-} gUnknown_082ED6B8[] = {
+} sUnknown_082ED6B8[] = {
{ gBlockSendBuffer, 200 },
{ gBlockSendBuffer, 200 },
{ gBlockSendBuffer, 100 },
{ gBlockSendBuffer, 220 },
{ gBlockSendBuffer, 40 }
};
-const u16 gUnknown_082ED6E0[] = {
- 0x0002, 0x7f7d, 0x0000, 0xFFFF
+
+static const u16 sAcceptedSerialNos[] = {
+ 0x0002,
+ RFU_SERIAL_7F7D,
+ 0x0000,
+ 0xFFFF
};
-const char sUnref_082ED6E8[][15] = {
+static const char sASCII_RfuCmds[][15] = {
"RFU WAIT",
"RFU BOOT",
"RFU ERROR",
@@ -114,79 +179,83 @@ const char sUnref_082ED6E8[][15] = {
"RFU SEND ERR",
"RFU CP POLL"
};
-const char sUnref_082ED6E9[][16] = {
+
+static const char sASCII_RecoverCmds[][16] = {
" ",
"RECOVER START ",
"DISSCONECT ",
"RECOVER SUUSES",
"RECOVER FAILED"
};
-const TaskFunc gUnknown_082ED7E0[] = {
+
+static const TaskFunc sUnknown_082ED7E0[] = {
sub_801084C,
- sub_8010AAC,
+ Task_ExchangeLinkPlayers,
sub_8010D0C
};
-const char gUnknown_082ED7EC[] = "PokemonSioInfo";
-const char gUnknown_082ED7FC[] = "LINK LOSS DISCONNECT!";
-const char gUnknown_082ED814[] = "LINK LOSS RECOVERY NOW";
-
-ALIGNED(4) const char gUnknown_082ED82C[31] = {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',0x00};
-const char gUnknown_082ED84B[16] = {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',0x00};
-const char gUnknown_082ED85B[9] = {' ',' ',' ',' ',' ',' ',' ',' ',0x00};
-ALIGNED(4) const char gUnknown_082ED864[2] = {' ',0x00};
-const char gUnknown_082ED866[2] = {'*',0x00};
-const char gUnknown_082ED868[8] = "NOWSLOT";
-const char gUnknown_082ED870[12] = " ";
-const char gUnknown_082ED87C[12] = "CLOCK DRIFT";
-const char gUnknown_082ED888[12] = "BUSY SEND ";
-const char gUnknown_082ED894[12] = "CMD REJECT ";
-const char gUnknown_082ED8A0[12] = "CLOCK SLAVE";
-const char gUnknown_082ED8A8[3][8] = {
+
+static const char sASCII_PokemonSioInfo[] = "PokemonSioInfo";
+static const char sASCII_LinkLossDisconnect[] = "LINK LOSS DISCONNECT!";
+static const char sASCII_LinkLossRecoveryNow[] = "LINK LOSS RECOVERY NOW";
+ALIGNED(4) static const char sASCII_30Commas[31] = {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','\0'};
+static const char sASCII_15Commas[16] = {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','\0'};
+static const char sASCII_8Commas[9] = {' ',' ',' ',' ',' ',' ',' ',' ','\0'};
+ALIGNED(4) static const char sASCII_Space[2] = {' ','\0'};
+static const char sASCII_Asterisk[2] = {'*','\0'};
+static const char sASCII_NowSlot[8] = "NOWSLOT";
+
+static const char sASCII_ClockCmds[][12] = {
+ " ",
+ "CLOCK DRIFT",
+ "BUSY SEND ",
+ "CMD REJECT ",
+ "CLOCK SLAVE"
+};
+
+static const char sASCII_ChildParentSearch[3][8] = {
"CHILD ",
"PARENT",
"SEARCH"
};
-// .text
-
-void nullsub_5(const void *unused_0, u8 unused_1, u8 unused_2)
+static void Debug_PrintString(const void *str, u8 x, u8 y)
{
- // debug?
+
}
-void nullsub_13(u16 unused_0, u8 unused_1, u8 unused_2, u8 unused_3)
+static void Debug_PrintNum(u16 num, u8 x, u8 y, u8 numDigits)
{
}
-void sub_800E604(void)
+void ResetLinkRfuGFLayer(void)
{
s32 i;
- u8 unk_ee_bak = Rfu.unk_ee;
+ u8 errorState = Rfu.errorState;
CpuFill16(0, &Rfu, sizeof Rfu);
- Rfu.unk_ee = unk_ee_bak;
- Rfu.unk_0c = 0xFF;
- if (Rfu.unk_ee != 4)
+ Rfu.errorState = errorState;
+ Rfu.parentChild = 0xFF;
+ if (Rfu.errorState != 4)
{
- Rfu.unk_ee = 0;
+ Rfu.errorState = 0;
}
- for (i = 0; i < 5; i++)
+ for (i = 0; i < MAX_RFU_PLAYERS; i++)
{
- sub_800FCC4(Rfu.unk_80 + i);
+ ResetSendDataManager(&Rfu.recvBlock[i]);
}
- sub_800FCC4(&Rfu.unk_6c);
- sub_800D6C8(&Rfu.unk_124);
- sub_800D724(&Rfu.unk_9e8);
+ ResetSendDataManager(&Rfu.sendBlock);
+ RfuRecvQueue_Reset(&Rfu.recvQueue);
+ RfuSendQueue_Reset(&Rfu.sendQueue);
CpuFill16(0, gSendCmd, sizeof gSendCmd);
CpuFill16(0, gRecvCmds, sizeof gRecvCmds);
CpuFill16(0, gLinkPlayers, sizeof gLinkPlayers);
}
-void sub_800E6D0(void)
+void InitRFU(void)
{
IntrFunc serialIntr = gIntrTable[1];
IntrFunc timerIntr = gIntrTable[2];
- sub_800E700();
+ InitRFUAPI();
rfu_REQ_stopMode();
rfu_waitREQComplete();
REG_IME = 0;
@@ -195,59 +264,59 @@ void sub_800E6D0(void)
REG_IME = INTR_FLAG_VBLANK;
}
-void sub_800E700(void)
+void InitRFUAPI(void)
{
if (!rfu_initializeAPI((void *)gf_rfu_REQ_api, sizeof gf_rfu_REQ_api, gIntrTable + 1, TRUE))
{
gLinkType = 0;
- sub_800AAF4();
- sub_80111B0(0);
- sub_800E604();
+ ClearSavedLinkPlayers();
+ sub_80111B0(FALSE);
+ ResetLinkRfuGFLayer();
rfu_setTimerInterrupt(3, gIntrTable + 2);
}
}
-void sub_800E748(u8 taskId)
+static void Task_LinkLeaderSearchForChildren(u8 taskId)
{
- sub_8010750();
- switch (Rfu.unk_04)
+ UpdateChildStatuses();
+ switch (Rfu.state)
{
- case 0:
- rfu_LMAN_initializeRFU(&gUnknown_02022B2C);
- Rfu.unk_04 = 1;
- gTasks[taskId].data[1] = 1;
- break;
- case 1:
- break;
- case 2:
- rfu_LMAN_establishConnection(Rfu.unk_0c, 0, 240, (u16 *)gUnknown_082ED6E0);
- Rfu.unk_04 = 3;
- gTasks[taskId].data[1] = 6;
- break;
- case 3:
- break;
- case 4:
- rfu_LMAN_stopManager(FALSE);
- Rfu.unk_04 = 5;
- break;
- case 5:
- break;
- case 18:
- Rfu.unk_cdb = 0;
- rfu_LMAN_setMSCCallback(sub_800EDBC);
- sub_800EAB4();
- sub_800EAFC();
- Rfu.unk_04 = 20;
- gTasks[taskId].data[1] = 8;
- CreateTask(sub_801084C, 5);
- DestroyTask(taskId);
- break;
+ case 0:
+ rfu_LMAN_initializeRFU(&sRfuReqConfig);
+ Rfu.state = 1;
+ gTasks[taskId].data[1] = 1;
+ break;
+ case 1:
+ break;
+ case 2:
+ rfu_LMAN_establishConnection(Rfu.parentChild, 0, 240, (u16 *)sAcceptedSerialNos);
+ Rfu.state = 3;
+ gTasks[taskId].data[1] = 6;
+ break;
+ case 3:
+ break;
+ case 4:
+ rfu_LMAN_stopManager(FALSE);
+ Rfu.state = 5;
+ break;
+ case 5:
+ break;
+ case 18:
+ Rfu.unk_cdb = FALSE;
+ rfu_LMAN_setMSCCallback(sub_800EDBC);
+ sub_800EAB4();
+ sub_800EAFC();
+ Rfu.state = 20;
+ gTasks[taskId].data[1] = 8;
+ CreateTask(sub_801084C, 5);
+ DestroyTask(taskId);
+ break;
}
}
s32 sub_800E87C(u8 idx)
{
- return gUnknown_082ED6A5[idx];
+ return sUnknown_082ED6A5[idx];
}
void sub_800E88C(s32 r2, s32 r5)
@@ -258,287 +327,287 @@ void sub_800E88C(s32 r2, s32 r5)
s32 r6 = 0;
if (r5 == -1)
{
- for (i = 0; i < 4; r2 >>= 1, i++)
+ for (i = 0; i < RFU_CHILD_MAX; r2 >>= 1, i++)
{
if (r2 & 1)
{
- Rfu.unk_cde[i] = r4;
+ Rfu.linkPlayerIdx[i] = r4;
r4++;
}
}
}
else
{
- for (i = 0; i < 4; r1 >>= 1, i++)
+ for (i = 0; i < RFU_CHILD_MAX; r1 >>= 1, i++)
{
if (!(r1 & 1))
{
- Rfu.unk_cde[i] = 0;
+ Rfu.linkPlayerIdx[i] = 0;
}
}
- for (r4 = 4; r4 != 0; r4--)
+ for (r4 = RFU_CHILD_MAX; r4 != 0; r4--)
{
- for (i = 0; i < 4 && Rfu.unk_cde[i] != r4; i++);
- if (i == 4)
+ for (i = 0; i < RFU_CHILD_MAX && Rfu.linkPlayerIdx[i] != r4; i++);
+ if (i == RFU_CHILD_MAX)
{
r6 = r4;
}
}
- for (r5 &= ~r2, i = 0; i < 4; r5 >>= 1, i++)
+ for (r5 &= ~r2, i = 0; i < RFU_CHILD_MAX; r5 >>= 1, i++)
{
if (r5 & 1)
{
- Rfu.unk_cde[i] = r6++;
+ Rfu.linkPlayerIdx[i] = r6++;
}
}
}
}
-void sub_800E94C(u8 taskId)
+static void Task_JoinGroupSearchForParent(u8 taskId)
{
- switch (Rfu.unk_04)
+ switch (Rfu.state)
{
- case 0:
- rfu_LMAN_initializeRFU((INIT_PARAM *)&gUnknown_082ED608);
- Rfu.unk_04 = 1;
- gTasks[taskId].data[1] = 1;
- break;
- case 1:
- break;
- case 6:
- rfu_LMAN_establishConnection(Rfu.unk_0c, 0, 0xf0, (u16 *)gUnknown_082ED6E0);
- Rfu.unk_04 = 7;
- gTasks[taskId].data[1] = 7;
- break;
- case 7:
- break;
- case 9:
- gTasks[taskId].data[1] = 10;
- break;
- case 11:
- switch (sub_80107A0())
- {
- case 5:
- Rfu.unk_04 = 12;
- break;
- case 6:
- case 9:
- rfu_LMAN_requestChangeAgbClockMaster();
- Rfu.unk_ce4 = 2;
- DestroyTask(taskId);
- break;
- }
- break;
- case 12:
+ case 0:
+ rfu_LMAN_initializeRFU((INIT_PARAM *)&sRfuReqConfigTemplate);
+ Rfu.state = 1;
+ gTasks[taskId].data[1] = 1;
+ break;
+ case 1:
+ break;
+ case 6:
+ rfu_LMAN_establishConnection(Rfu.parentChild, 0, 240, (u16 *)sAcceptedSerialNos);
+ Rfu.state = 7;
+ gTasks[taskId].data[1] = 7;
+ break;
+ case 7:
+ break;
+ case 9:
+ gTasks[taskId].data[1] = 10;
+ break;
+ case 11:
+ switch (sub_80107A0())
{
- u8 r5 = 1 << Rfu.unk_c3e;
- rfu_clearSlot(12, Rfu.unk_c3e);
- rfu_setRecvBuffer(16, Rfu.unk_c3e, Rfu.unk_c3f, 70);
- rfu_UNI_setSendData(r5, Rfu.unk_4c, 14);
- gTasks[taskId].data[1] = 8;
+ case RFU_STATUS_JOIN_GROUP_OK:
+ Rfu.state = 12;
+ break;
+ case RFU_STATUS_JOIN_GROUP_NO:
+ case RFU_STATUS_LEAVE_GROUP:
+ rfu_LMAN_requestChangeAgbClockMaster();
+ Rfu.unk_ce4 = 2;
DestroyTask(taskId);
- if (gUnknown_02022B44.unk_0f == 0)
- {
- sub_801227C();
- gUnknown_02022B44.unk_0f++;
- }
- CreateTask(sub_801084C, 5);
break;
}
+ break;
+ case 12:
+ {
+ u8 bmChildSlot = 1 << Rfu.childSlot;
+ rfu_clearSlot(TYPE_NI_SEND | TYPE_NI_RECV, Rfu.childSlot);
+ rfu_setRecvBuffer(TYPE_UNI, Rfu.childSlot, Rfu.unk_c3f, 70);
+ rfu_UNI_setSendData(bmChildSlot, Rfu.unk_4c, sizeof(Rfu.unk_4c));
+ gTasks[taskId].data[1] = 8;
+ DestroyTask(taskId);
+ if (sRfuDebug.unk_0f == 0)
+ {
+ Debug_PrintEmpty();
+ sRfuDebug.unk_0f++;
+ }
+ CreateTask(sub_801084C, 5);
+ break;
+ }
}
}
-void sub_800EAB4(void)
+static void sub_800EAB4(void)
{
u8 i;
- u8 r5 = lman.acceptSlot_flag;
- for (i = 0; i < 4; i++)
+ u8 acceptSlot = lman.acceptSlot_flag;
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- if (r5 & 1)
+ if (acceptSlot & 1)
{
- rfu_setRecvBuffer(16, i, Rfu.unk_14[i], 14);
- rfu_clearSlot(3, i);
+ rfu_setRecvBuffer(TYPE_UNI, i, Rfu.unk_14[i], 14);
+ rfu_clearSlot(TYPE_UNI_SEND | TYPE_UNI_RECV, i);
}
- r5 >>= 1;
+ acceptSlot >>= 1;
}
}
-void sub_800EAFC(void)
+static void sub_800EAFC(void)
{
- u8 r5 = lman.acceptSlot_flag;
- rfu_UNI_setSendData(r5, Rfu.unk_c87, 70);
- Rfu.unk_cda = sub_800E87C(r5);
- Rfu.unk_ce2 = r5;
- sub_800E88C(r5, -1);
- Rfu.unk_0c = 1;
+ u8 acceptSlot = lman.acceptSlot_flag;
+ rfu_UNI_setSendData(acceptSlot, Rfu.recvCmds, 70);
+ Rfu.unk_cda = sub_800E87C(acceptSlot);
+ Rfu.unk_ce2 = acceptSlot;
+ sub_800E88C(acceptSlot, -1);
+ Rfu.parentChild = MODE_PARENT;
}
-void sub_800EB44(u8 taskId)
+static void Task_LinkRfu_UnionRoomListen(u8 taskId)
{
- if (sub_800F7DC()->activity == 0x54 && sub_8011A74() == 4)
+ if (GetHostRFUtgtGname()->activity == (ACTIVITY_PLYRTALK | IN_UNION_ROOM) && RfuGetStatus() == RFU_STATUS_NEW_CHILD_DETECTED)
{
rfu_REQ_disconnect(lman.acceptSlot_flag);
rfu_waitREQComplete();
- sub_8011A64(0, 0);
+ RfuSetStatus(RFU_STATUS_OK, 0);
}
- switch (Rfu.unk_04)
+ switch (Rfu.state)
{
- case 0:
- rfu_LMAN_initializeRFU(&gUnknown_02022B2C);
- Rfu.unk_04 = 1;
- gTasks[taskId].data[1] = 1;
- break;
- case 1:
- break;
- case 17:
- rfu_LMAN_establishConnection(2, 0, 240, (u16 *)gUnknown_082ED6E0);
- rfu_LMAN_setMSCCallback(sub_800ED34);
- Rfu.unk_04 = 18;
- break;
- case 18:
- break;
- case 13:
- if (rfu_UNI_setSendData(1 << Rfu.unk_c3e, Rfu.unk_4c, 14) == 0)
+ case 0:
+ rfu_LMAN_initializeRFU(&sRfuReqConfig);
+ Rfu.state = 1;
+ gTasks[taskId].data[1] = 1;
+ break;
+ case 1:
+ break;
+ case 17:
+ rfu_LMAN_establishConnection(2, 0, 240, (u16 *)sAcceptedSerialNos);
+ rfu_LMAN_setMSCCallback(sub_800ED34);
+ Rfu.state = 18;
+ break;
+ case 18:
+ break;
+ case 13:
+ if (rfu_UNI_setSendData(1 << Rfu.childSlot, Rfu.unk_4c, sizeof(Rfu.unk_4c)) == 0)
+ {
+ Rfu.parentChild = MODE_CHILD;
+ DestroyTask(taskId);
+ if (gTasks[taskId].data[7])
{
- Rfu.unk_0c = 0;
- DestroyTask(taskId);
- if (gTasks[taskId].data[7])
- {
- CreateTask(sub_8010D0C, 1);
- }
- else
- {
- CreateTask(sub_801084C, 5);
- }
+ CreateTask(sub_8010D0C, 1);
}
- break;
- case 14:
- rfu_LMAN_stopManager(0);
- Rfu.unk_04 = 15;
- break;
- case 15:
- break;
- case 16:
- Rfu.unk_cdb = 0;
- rfu_LMAN_setMSCCallback(sub_800EDBC);
- sub_8011068(1);
- sub_800EAB4();
- sub_800EAFC();
- Rfu.unk_04 = 20;
- gTasks[taskId].data[1] = 8;
- Rfu.unk_0c = 1;
- CreateTask(sub_801084C, 5);
- Rfu.unk_ce8 = 1;
- DestroyTask(taskId);
- break;
+ else
+ {
+ CreateTask(sub_801084C, 5);
+ }
+ }
+ break;
+ case 14:
+ rfu_LMAN_stopManager(0);
+ Rfu.state = 15;
+ break;
+ case 15:
+ break;
+ case 16:
+ Rfu.unk_cdb = FALSE;
+ rfu_LMAN_setMSCCallback(sub_800EDBC);
+ UpdateGameData_GroupLockedIn(TRUE);
+ sub_800EAB4();
+ sub_800EAFC();
+ Rfu.state = 20;
+ gTasks[taskId].data[1] = 8;
+ Rfu.parentChild = MODE_PARENT;
+ CreateTask(sub_801084C, 5);
+ Rfu.unk_ce8 = TRUE;
+ DestroyTask(taskId);
+ break;
}
}
-void sub_800ED10(void)
+void LinkRfu_CreateConnectionAsParent(void)
{
- rfu_LMAN_establishConnection(1, 0, 240, (u16 *)gUnknown_082ED6E0);
+ rfu_LMAN_establishConnection(MODE_PARENT, 0, 240, (u16 *)sAcceptedSerialNos);
}
-void sub_800ED28(void)
+void LinkRfu_StopManagerBeforeEnteringChat(void)
{
rfu_LMAN_stopManager(FALSE);
}
-void sub_800ED34(u16 unused)
+static void sub_800ED34(u16 unused)
{
s32 i;
- for (i = 0; i < 14; i++)
+ for (i = 0; i < (int)ARRAY_COUNT(Rfu.unk_4c); i++)
{
Rfu.unk_4c[i] = 0;
}
rfu_REQ_recvData();
rfu_waitREQComplete();
- if (gRfuSlotStatusUNI[Rfu.unk_c3e]->recv.newDataFlag)
+ if (gRfuSlotStatusUNI[Rfu.childSlot]->recv.newDataFlag)
{
Rfu.unk_cd0++;
- sub_800D7D8(&Rfu.unk_124, Rfu.unk_c3f);
- gUnknown_02022B44.unk_06++;
- sub_800F048();
- rfu_UNI_readySendData(Rfu.unk_c3e);
- rfu_UNI_clearRecvNewDataFlag(Rfu.unk_c3e);
+ RfuRecvQueue_Enqueue(&Rfu.recvQueue, Rfu.unk_c3f);
+ sRfuDebug.unk_06++;
+ UpdateBackupQueue();
+ rfu_UNI_readySendData(Rfu.childSlot);
+ rfu_UNI_clearRecvNewDataFlag(Rfu.childSlot);
}
- rfu_LMAN_REQ_sendData(1);
+ rfu_LMAN_REQ_sendData(TRUE);
}
-void sub_800EDBC(u16 unused)
+static void sub_800EDBC(u16 unused)
{
- Rfu.unk_cdb = 1;
+ Rfu.unk_cdb = TRUE;
}
-void sub_800EDD4(void)
+void LinkRfu_Shutdown(void)
{
u8 i;
rfu_LMAN_powerDownRFU();
- if (Rfu.unk_0c == 1)
+ if (Rfu.parentChild == MODE_PARENT)
{
- if (FuncIsActiveTask(sub_800E748) == TRUE)
+ if (FuncIsActiveTask(Task_LinkLeaderSearchForChildren) == TRUE)
{
- DestroyTask(Rfu.unk_67);
- sub_800E604();
+ DestroyTask(Rfu.searchTaskId);
+ ResetLinkRfuGFLayer();
}
}
- else if (Rfu.unk_0c == 0)
+ else if (Rfu.parentChild == MODE_CHILD)
{
- if (FuncIsActiveTask(sub_800E94C) == TRUE)
+ if (FuncIsActiveTask(Task_JoinGroupSearchForParent) == TRUE)
{
- DestroyTask(Rfu.unk_67);
- sub_800E604();
+ DestroyTask(Rfu.searchTaskId);
+ ResetLinkRfuGFLayer();
}
}
- else if (Rfu.unk_0c == 2)
+ else if (Rfu.parentChild == 2)
{
- if (FuncIsActiveTask(sub_800EB44) == TRUE)
+ if (FuncIsActiveTask(Task_LinkRfu_UnionRoomListen) == TRUE)
{
- DestroyTask(Rfu.unk_67);
- sub_800E604();
+ DestroyTask(Rfu.searchTaskId);
+ ResetLinkRfuGFLayer();
}
}
- for (i = 0; i < 3; i++)
+ for (i = 0; i < ARRAY_COUNT(sUnknown_082ED7E0); i++)
{
- if (FuncIsActiveTask(gUnknown_082ED7E0[i]) == TRUE)
+ if (FuncIsActiveTask(sUnknown_082ED7E0[i]) == TRUE)
{
- DestroyTask(FindTaskIdByFunc(gUnknown_082ED7E0[i]));
+ DestroyTask(FindTaskIdByFunc(sUnknown_082ED7E0[i]));
}
}
}
-void sub_800EE78(void)
+static void CreateTask_LinkLeaderSearchForChildren(void)
{
- Rfu.unk_67 = CreateTask(sub_800E748, 1);
+ Rfu.searchTaskId = CreateTask(Task_LinkLeaderSearchForChildren, 1);
}
-bool8 sub_800EE94(void)
+static bool8 sub_800EE94(void)
{
- if (Rfu.unk_04 == 7 && Rfu.unk_ccd)
+ if (Rfu.state == 7 && Rfu.parentId)
{
return TRUE;
}
return FALSE;
}
-bool32 sub_800EEBC(void)
+static bool32 IsParentSuccessfullyReconnected(void)
{
- if (Rfu.unk_04 == 7 && !rfu_LMAN_CHILD_connectParent(gRfuLinkStatus->partner[Rfu.unk_c3d].id, 240))
+ if (Rfu.state == 7 && !rfu_LMAN_CHILD_connectParent(gRfuLinkStatus->partner[Rfu.unk_c3d].id, 240))
{
- Rfu.unk_04 = 9;
+ Rfu.state = 9;
return TRUE;
}
return FALSE;
}
-void sub_800EF00(void)
+static void CreateTask_JoinGroupSearchForParent(void)
{
- Rfu.unk_67 = CreateTask(sub_800E94C, 1);
+ Rfu.searchTaskId = CreateTask(Task_JoinGroupSearchForParent, 1);
}
-bool8 sub_800EF1C(void)
+bool8 LmanAcceptSlotFlagIsNotZero(void)
{
if (lman.acceptSlot_flag)
{
@@ -547,17 +616,17 @@ bool8 sub_800EF1C(void)
return FALSE;
}
-void sub_800EF38(void)
+void LinkRfu_StopManagerAndFinalizeSlots(void)
{
- Rfu.unk_04 = 4;
- Rfu.unk_ce7 = lman.acceptSlot_flag;
+ Rfu.state = 4;
+ Rfu.acceptSlot_flag = lman.acceptSlot_flag;
}
-bool32 sub_800EF58(bool32 a0)
+bool32 WaitRfuState(bool32 force)
{
- if (Rfu.unk_04 == 17 || a0)
+ if (Rfu.state == 17 || force)
{
- Rfu.unk_04 = 18;
+ Rfu.state = 18;
return TRUE;
}
return FALSE;
@@ -565,14 +634,14 @@ bool32 sub_800EF58(bool32 a0)
void sub_800EF7C(void)
{
- Rfu.unk_04 = 14;
+ Rfu.state = 14;
}
-void sub_800EF88(u8 a0)
+static void sub_800EF88(u8 a0)
{
u8 i;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
if (a0 & 1)
{
@@ -583,53 +652,51 @@ void sub_800EF88(u8 a0)
}
}
-void sub_800EFB0(void)
+static void sub_800EFB0(void)
{
s32 i, j;
for (i = 0; i < 5; i++)
{
- struct UnkRfuStruct_2 *ptr = &Rfu;
+ struct GFRfuManager *ptr = &Rfu;
for (j = 0; j < 7; j++)
{
- ptr->unk_c87[i][j][1] = gRecvCmds[i][j] >> 8;
- ptr->unk_c87[i][j][0] = gRecvCmds[i][j];
+ ptr->recvCmds[i][j][1] = gRecvCmds[i][j] >> 8;
+ ptr->recvCmds[i][j][0] = gRecvCmds[i][j];
}
}
CpuFill16(0, gRecvCmds, sizeof gRecvCmds);
}
-void sub_800F014(void)
+static void sub_800F014(void)
{
s32 i;
- for (i = 0; i < 7; i++)
+ for (i = 0; i < CMD_LENGTH - 1; i++)
{
gRecvCmds[0][i] = gSendCmd[i];
}
- for (i = 0; i < 7; i++)
+ for (i = 0; i < CMD_LENGTH - 1; i++)
{
gSendCmd[i] = 0;
}
}
-void sub_800F048(void)
+static void UpdateBackupQueue(void)
{
- if (Rfu.unk_c3c)
+ if (Rfu.linkRecovered)
{
- u8 r2 = sub_800DAC8(&Rfu.unk_c1c, Rfu.unk_4c);
- if (Rfu.unk_c1c.unk_1e == 0)
- {
- Rfu.unk_c3c = 0;
- }
- if (r2)
- {
+ bool8 backupEmpty = RfuBackupQueue_Dequeue(&Rfu.backupQueue, Rfu.unk_4c);
+
+ if (Rfu.backupQueue.count == 0)
+ Rfu.linkRecovered = FALSE;
+
+ if (backupEmpty)
return;
- }
}
- if (Rfu.unk_c3c == 0)
+ if (!Rfu.linkRecovered)
{
- sub_800D9DC(&Rfu.unk_9e8, Rfu.unk_4c);
- sub_800DA68(&Rfu.unk_c1c, Rfu.unk_4c);
+ RfuSendQueue_Dequeue(&Rfu.sendQueue, Rfu.unk_4c);
+ RfuBackupQueue_Enqueue(&Rfu.backupQueue, Rfu.unk_4c);
}
}
@@ -642,9 +709,9 @@ bool32 IsRfuRecvQueueEmpty(void)
{
return FALSE;
}
- for (i = 0; i < 5; i++)
+ for (i = 0; i < MAX_RFU_PLAYERS; i++)
{
- for (j = 0; j < 7; j++)
+ for (j = 0; j < CMD_LENGTH - 1; j++)
{
if (gRecvCmds[i][j] != 0)
{
@@ -655,53 +722,53 @@ bool32 IsRfuRecvQueueEmpty(void)
return TRUE;
}
-bool32 sub_800F0F8(void)
+static bool32 sub_800F0F8(void)
{
- if (Rfu.unk_04 < 20)
+ if (Rfu.state < 20)
{
rfu_REQ_recvData();
rfu_waitREQComplete();
- rfu_LMAN_REQ_sendData(0);
+ rfu_LMAN_REQ_sendData(FALSE);
}
else
{
- Rfu.unk_cdb = 0;
+ Rfu.unk_cdb = FALSE;
if ((Rfu.unk_ce2 & gRfuLinkStatus->connSlotFlag) == Rfu.unk_ce2 && (Rfu.unk_ce2 & gRfuLinkStatus->connSlotFlag))
{
if (!Rfu.unk_cdc)
{
if (Rfu.unk_ce3)
{
- sub_8011D6C(Rfu.unk_ce3);
+ RfuReqDisconnectSlot(Rfu.unk_ce3);
Rfu.unk_ce3 = 0;
if (Rfu.unk_ce4 == 1)
{
- sub_8011A64(2, 0x8000);
- sub_8011170(0x8000);
+ RfuSetStatus(RFU_STATUS_CONNECTION_ERROR, 0x8000);
+ GetLinkmanErrorParams(0x8000);
return FALSE;
}
if (!lman.acceptSlot_flag)
{
- sub_800EDD4();
+ LinkRfu_Shutdown();
gReceivedRemoteLinkPlayers = 0;
return FALSE;
}
}
sub_800EFB0();
rfu_UNI_readySendData(Rfu.unk_cda);
- rfu_LMAN_REQ_sendData(1);
+ rfu_LMAN_REQ_sendData(TRUE);
}
else
{
rfu_REQ_PARENT_resumeRetransmitAndChange();
}
- Rfu.unk_0e = 1;
+ Rfu.unk_0e = TRUE;
}
}
return FALSE;
}
-bool32 sub_800F1E0(void)
+static bool32 sub_800F1E0(void)
{
u16 i;
u16 flags;
@@ -709,12 +776,12 @@ bool32 sub_800F1E0(void)
u16 j;
u8 retval;
- if (Rfu.unk_04 >= 20 && Rfu.unk_0e == 1)
+ if (Rfu.state >= 20 && Rfu.unk_0e == TRUE)
{
rfu_waitREQComplete();
- while (Rfu.unk_cdb == 0)
+ while (Rfu.unk_cdb == FALSE)
{
- if (Rfu.unk_ee != 0)
+ if (Rfu.errorState != 0)
{
return FALSE;
}
@@ -723,10 +790,10 @@ bool32 sub_800F1E0(void)
rfu_waitREQComplete();
if ((lman.parentAck_flag & Rfu.unk_ce2) == Rfu.unk_ce2)
{
- Rfu.unk_cdc = 0;
- gUnknown_02022B44.unk_06++;
+ Rfu.unk_cdc = FALSE;
+ sRfuDebug.unk_06++;
flags = lman.acceptSlot_flag;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
if (flags & 1)
{
@@ -735,14 +802,14 @@ bool32 sub_800F1E0(void)
if (Rfu.unk_cee[i] != 0xFF && (Rfu.unk_14[i][0] >> 5) != ((Rfu.unk_cee[i] + 1) & 7))
{
if (++Rfu.unk_cea[i] > 4)
- sub_8011170(0x8100);
+ GetLinkmanErrorParams(0x8100);
}
else
{
Rfu.unk_cee[i] = Rfu.unk_14[i][0] / 32;
Rfu.unk_cea[i] = 0;
Rfu.unk_14[i][0] &= 0x1f;
- r0 = Rfu.unk_cde[i];
+ r0 = Rfu.linkPlayerIdx[i];
for (j = 0; j < 7; j++)
{
gRecvCmds[r0][j] = (Rfu.unk_14[i][(j << 1) + 1] << 8) | Rfu.unk_14[i][(j << 1) + 0];
@@ -756,40 +823,40 @@ bool32 sub_800F1E0(void)
flags >>= 1;
}
sub_800F014();
- sub_800F86C(0);
- sub_8010528();
+ RfuHandleReceiveCommand(0);
+ CallRfuFunc();
if (Rfu.unk_ce5 && !Rfu.unk_cd9)
{
- gUnknown_02022B44.unk_0e = 0;
- rfu_clearSlot(3, Rfu.unk_cda);
- for (i = 0; i < 4; i++)
+ sRfuDebug.unk_0e = FALSE;
+ rfu_clearSlot(TYPE_UNI_SEND | TYPE_UNI_RECV, Rfu.unk_cda);
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
if ((Rfu.unk_ce5 >> i) & 1)
{
- rfu_setRecvBuffer(0x10, i, Rfu.unk_14[i], 14);
+ rfu_setRecvBuffer(TYPE_UNI, i, Rfu.unk_14[i], 14);
}
}
sub_800E88C(Rfu.unk_ce2, Rfu.unk_ce2 | Rfu.unk_ce5);
Rfu.unk_ce9 = Rfu.unk_ce5;
Rfu.unk_ce2 |= Rfu.unk_ce5;
Rfu.unk_ce5 = 0;
- rfu_UNI_setSendData(Rfu.unk_ce2, Rfu.unk_c87, 70);
+ rfu_UNI_setSendData(Rfu.unk_ce2, Rfu.recvCmds, 70);
Rfu.unk_cda = sub_800E87C(Rfu.unk_ce2);
- CreateTask(sub_8010AAC, 0);
+ CreateTask(Task_ExchangeLinkPlayers, 0);
}
}
else
{
- Rfu.unk_cdc = 1;
- Rfu.unk_0e = 0;
+ Rfu.unk_cdc = TRUE;
+ Rfu.unk_0e = FALSE;
}
- Rfu.unk_0e = 0;
+ Rfu.unk_0e = FALSE;
}
retval = Rfu.unk_cdc;
return gRfuLinkStatus->sendSlotUNIFlag ? retval & 1 : FALSE;
}
-void sub_800F498(u16 *a0, u8 *a1)
+static void sub_800F498(u16 *a0, u8 *a1)
{
s32 i;
@@ -810,15 +877,15 @@ void sub_800F498(u16 *a0, u8 *a1)
}
}
-bool32 sub_800F4F0(void)
+static bool32 RfuProcessEnqueuedRecvBlock(void)
{
u8 i;
u8 j;
u8 sp00[MAX_RFU_PLAYERS * (2 * (CMD_LENGTH - 1))];
u8 sp48[2 * (CMD_LENGTH - 1)];
- u8 switchval;
+ u8 status;
- sub_800D934(&Rfu.unk_124, sp00);
+ RfuRecvQueue_Dequeue(&Rfu.recvQueue, sp00);
for (i = 0; i < MAX_RFU_PLAYERS; i++)
{
for (j = 0; j < CMD_LENGTH - 1; j++)
@@ -826,21 +893,21 @@ bool32 sub_800F4F0(void)
gRecvCmds[i][j] = (sp00[i * 14 + (j << 1) + 1] << 8) | sp00[i * 14 + (j << 1) + 0];
}
}
- sub_800F86C(0);
+ RfuHandleReceiveCommand(0);
if (lman.childClockSlave_flag == 0 && Rfu.unk_ce4)
{
rfu_REQ_disconnect(gRfuLinkStatus->connSlotFlag | gRfuLinkStatus->linkLossSlotFlag);
rfu_waitREQComplete();
- switchval = sub_8011A74();
- if (switchval != 1 && switchval != 6 && switchval != 9)
- sub_8011A64(2, 0x9000);
+ status = RfuGetStatus();
+ if (status != RFU_STATUS_FATAL_ERROR && status != RFU_STATUS_JOIN_GROUP_NO && status != RFU_STATUS_LEAVE_GROUP)
+ RfuSetStatus(RFU_STATUS_CONNECTION_ERROR, 0x9000);
rfu_clearAllSlot();
gReceivedRemoteLinkPlayers = FALSE;
- Rfu.linkRfuCallback = NULL;
+ Rfu.callback = NULL;
if (Rfu.unk_ce4 == 1)
{
- sub_8011A64(2, 0x9000);
- sub_8011170(0x9000);
+ RfuSetStatus(RFU_STATUS_CONNECTION_ERROR, 0x9000);
+ GetLinkmanErrorParams(0x9000);
}
lman.state = lman.next_state = 0;
Rfu.unk_ce4 = 0;
@@ -848,105 +915,105 @@ bool32 sub_800F4F0(void)
if (Rfu.unk_cd0)
{
Rfu.unk_cd0--;
- sub_8010528();
+ CallRfuFunc();
sub_800F498(gSendCmd, sp48);
- sub_800D888(&Rfu.unk_9e8, sp48);
+ RfuSendQueue_Enqueue(&Rfu.sendQueue, sp48);
for (i = 0; i < CMD_LENGTH - 1; i++)
gSendCmd[i] = 0;
}
return IsRfuRecvQueueEmpty();
}
-void sub_800F638(u8 unused, u32 flags)
+static void HandleSendFailure(u8 unused, u32 flags)
{
s32 i, j;
- const u8 *r10 = Rfu.unk_6c.unk_04;
- for (i = 0; i < Rfu.unk_6c.unk_02; i++)
+ const u8 *r10 = Rfu.sendBlock.payload;
+ for (i = 0; i < Rfu.sendBlock.count; i++)
{
if (!(flags & 1))
{
- gUnknown_03000D90[0] = (~0x76ff) | i;
+ sResendBlock16[0] = RFU_COMMAND_0x8900 | i;
for (j = 0; j < 7; j++)
{
- gUnknown_03000D90[j + 1] = (r10[12 * i + (j << 1) + 1] << 8) | r10[12 * i + (j << 1) + 0];
+ sResendBlock16[j + 1] = (r10[12 * i + (j << 1) + 1] << 8) | r10[12 * i + (j << 1) + 0];
}
for (j = 0; j < 7; j++)
{
- gUnknown_03000D80[2 * j + 1] = gUnknown_03000D90[j] >> 8;
- gUnknown_03000D80[2 * j + 0] = gUnknown_03000D90[j];
+ sResendBlock8[2 * j + 1] = sResendBlock16[j] >> 8;
+ sResendBlock8[2 * j + 0] = sResendBlock16[j];
j++;j--; // Needed to match;
}
- sub_800D888(&Rfu.unk_9e8, gUnknown_03000D80);
- Rfu.unk_6c.unk_0c |= (1 << i);
+ RfuSendQueue_Enqueue(&Rfu.sendQueue, sResendBlock8);
+ Rfu.sendBlock.failedFlags |= (1 << i);
}
flags >>= 1;
}
}
-void sub_800F6FC(u8 a0)
+void Rfu_SetBlockReceivedFlag(u8 linkPlayerId)
{
- if (Rfu.unk_0c == 1 && a0)
- Rfu.unk_61[a0] = 1;
+ if (Rfu.parentChild == MODE_PARENT && linkPlayerId)
+ Rfu.numBlocksReceived[linkPlayerId] = 1;
else
- Rfu.unk_5c[a0] = 1;
+ Rfu.blockReceived[linkPlayerId] = TRUE;
}
-void sub_800F728(u8 a0)
+void Rfu_ResetBlockReceivedFlag(u8 linkPlayerId)
{
- Rfu.unk_5c[a0] = 0;
- Rfu.unk_80[a0].unk_12 = 0;
+ Rfu.blockReceived[linkPlayerId] = FALSE;
+ Rfu.recvBlock[linkPlayerId].receiving = 0;
}
-u8 sub_800F74C(const u8 *a0)
+static u8 sub_800F74C(const u8 *a0)
{
u8 i;
- if (Rfu.unk_0c == 1)
+ if (Rfu.parentChild == MODE_PARENT)
return FALSE;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- Rfu.unk_cde[i] = a0[i];
+ Rfu.linkPlayerIdx[i] = a0[i];
}
- return a0[Rfu.unk_c3e];
+ return a0[Rfu.childSlot];
}
-void rfu_func_080F97B8(void)
+static void RfuFunc_SendKeysToRfu(void)
{
if (gReceivedRemoteLinkPlayers
&& gHeldKeyCodeToSend != LINK_KEY_CODE_NULL
&& gLinkTransferringData != TRUE)
{
- gUnknown_03000D78[0]++;
- gHeldKeyCodeToSend |= (gUnknown_03000D78[0] << 8);
- sub_800FD14(0xbe00);
+ sHeldKeyCount++;
+ gHeldKeyCodeToSend |= (sHeldKeyCount << 8);
+ RfuPrepareSendBuffer(RFU_COMMAND_0xBE00);
}
}
-struct GFtgtGname *sub_800F7DC(void)
+struct GFtgtGname *GetHostRFUtgtGname(void)
{
- return &gUnknown_02022B14;
+ return &gHostRFUtgtGnameBuffer;
}
bool32 IsSendingKeysToRfu(void)
{
- return Rfu.linkRfuCallback == rfu_func_080F97B8;
+ return Rfu.callback == RfuFunc_SendKeysToRfu;
}
-void sub_800F804(void)
+void StartSendingKeysToRfu(void)
{
- Rfu.linkRfuCallback = rfu_func_080F97B8;
+ Rfu.callback = RfuFunc_SendKeysToRfu;
}
void ClearLinkRfuCallback(void)
{
- Rfu.linkRfuCallback = NULL;
+ Rfu.callback = NULL;
}
void sub_800F820(void)
{
- sub_800FD14(0x4400);
+ RfuPrepareSendBuffer(RFU_COMMAND_0x4400);
if (GetMultiplayerId() == 0)
gSendCmd[6] = GetBlenderArrowPosition();
gUnknown_020223C0++;
@@ -954,11 +1021,11 @@ void sub_800F820(void)
void sub_800F850(void)
{
- if (Rfu.linkRfuCallback == NULL)
- Rfu.linkRfuCallback = sub_800F820;
+ if (Rfu.callback == NULL)
+ Rfu.callback = sub_800F820;
}
-void sub_800F86C(u8 unused)
+static void RfuHandleReceiveCommand(u8 unused)
{
u16 i;
u16 j;
@@ -967,58 +1034,58 @@ void sub_800F86C(u8 unused)
{
switch (gRecvCmds[i][0] & 0xff00)
{
- case 0x7800:
- if (Rfu.unk_0c == 0 && gReceivedRemoteLinkPlayers != 0)
+ case RFU_COMMAND_0x7800:
+ if (Rfu.parentChild == MODE_CHILD && gReceivedRemoteLinkPlayers)
return;
// fallthrough
- case 0x7700:
- if (gRfuLinkStatus->parentChild == 0)
+ case RFU_COMMAND_0x7700:
+ if (gRfuLinkStatus->parentChild == MODE_CHILD)
{
Rfu.playerCount = gRecvCmds[i][1];
- Rfu.unk_cce = sub_800F74C((u8 *)(gRecvCmds[i] + 2));
+ Rfu.multiplayerId = sub_800F74C((u8 *)(gRecvCmds[i] + 2));
}
break;
- case 0x8800:
- if (Rfu.unk_80[i].unk_12 == 0)
+ case RFU_COMMAND_0x8800:
+ if (Rfu.recvBlock[i].receiving == 0)
{
- Rfu.unk_80[i].unk_00 = 0;
- Rfu.unk_80[i].unk_02 = gRecvCmds[i][1];
- Rfu.unk_80[i].unk_11 = gRecvCmds[i][2];
- Rfu.unk_80[i].unk_08 = 0;
- Rfu.unk_80[i].unk_12 = 1;
- Rfu.unk_5c[i] = 0;
+ Rfu.recvBlock[i].next = 0;
+ Rfu.recvBlock[i].count = gRecvCmds[i][1];
+ Rfu.recvBlock[i].owner = gRecvCmds[i][2];
+ Rfu.recvBlock[i].receivedFlags = 0;
+ Rfu.recvBlock[i].receiving = 1;
+ Rfu.blockReceived[i] = FALSE;
}
break;
- case 0x8900:
- if (Rfu.unk_80[i].unk_12 == 1)
+ case RFU_COMMAND_0x8900:
+ if (Rfu.recvBlock[i].receiving == 1)
{
- Rfu.unk_80[i].unk_00 = gRecvCmds[i][0] & 0xff;
- Rfu.unk_80[i].unk_08 |= (1 << Rfu.unk_80[i].unk_00);
+ Rfu.recvBlock[i].next = gRecvCmds[i][0] & 0xff;
+ Rfu.recvBlock[i].receivedFlags |= (1 << Rfu.recvBlock[i].next);
for (j = 0; j < 6; j++)
- gBlockRecvBuffer[i][Rfu.unk_80[i].unk_00 * 6 + j] = gRecvCmds[i][j + 1];
- if (Rfu.unk_80[i].unk_08 == gUnknown_082ED628[Rfu.unk_80[i].unk_02])
+ gBlockRecvBuffer[i][Rfu.recvBlock[i].next * 6 + j] = gRecvCmds[i][j + 1];
+ if (Rfu.recvBlock[i].receivedFlags == sAllBlocksReceived[Rfu.recvBlock[i].count])
{
- Rfu.unk_80[i].unk_12 = 2;
- sub_800F6FC(i);
- if (sub_800F7DC()->activity == 0x45 && gReceivedRemoteLinkPlayers != 0 && Rfu.unk_0c == 0)
- sub_8010A70(gBlockRecvBuffer);
+ Rfu.recvBlock[i].receiving = 2;
+ Rfu_SetBlockReceivedFlag(i);
+ if (GetHostRFUtgtGname()->activity == (ACTIVITY_CHAT | IN_UNION_ROOM) && gReceivedRemoteLinkPlayers != 0 && Rfu.parentChild == MODE_CHILD)
+ ValidateAndReceivePokemonSioInfo(gBlockRecvBuffer);
}
}
break;
- case 0xa100:
- sub_800FE84(gUnknown_082ED6B8[gRecvCmds[i][1]].buffer, (u16)gUnknown_082ED6B8[gRecvCmds[i][1]].size);
+ case RFU_COMMAND_0xA100:
+ Rfu_InitBlockSend(sUnknown_082ED6B8[gRecvCmds[i][1]].buffer, (u16)sUnknown_082ED6B8[gRecvCmds[i][1]].size);
break;
- case 0x5f00:
+ case RFU_COMMAND_0x5F00:
Rfu.unk_e4[i] = 1;
break;
- case 0x6600:
+ case RFU_COMMAND_0x6600:
if (Rfu.unk_100 == gRecvCmds[i][1])
Rfu.unk_e9[i] = 1;
break;
- case 0xed00:
- if (Rfu.unk_0c == 0)
+ case RFU_COMMAND_0xED00:
+ if (Rfu.parentChild == MODE_CHILD)
{
- if (gReceivedRemoteLinkPlayers != 0)
+ if (gReceivedRemoteLinkPlayers)
{
if (gRecvCmds[i][1] & gRfuLinkStatus->connSlotFlag)
{
@@ -1027,86 +1094,86 @@ void sub_800F86C(u8 unused)
Rfu.unk_ce4 = gRecvCmds[i][2];
}
Rfu.playerCount = gRecvCmds[i][3];
- sub_80109E8(gRecvCmds[i][1]);
+ ClearSelectedLinkPlayerIds(gRecvCmds[i][1]);
}
}
else
{
- sub_800FD14(0xee00);
+ RfuPrepareSendBuffer(RFU_COMMAND_0xEE00);
gSendCmd[1] = gRecvCmds[i][1];
gSendCmd[2] = gRecvCmds[i][2];
gSendCmd[3] = gRecvCmds[i][3];
}
break;
- case 0xee00:
- if (Rfu.unk_0c == 1)
+ case RFU_COMMAND_0xEE00:
+ if (Rfu.parentChild == MODE_PARENT)
{
Rfu.unk_ce3 |= gRecvCmds[i][1];
Rfu.unk_ce4 = gRecvCmds[i][2];
- sub_80109E8(gRecvCmds[i][1]);
+ ClearSelectedLinkPlayerIds(gRecvCmds[i][1]);
}
break;
- case 0x4400:
- case 0xbe00:
+ case RFU_COMMAND_0x4400:
+ case RFU_COMMAND_0xBE00:
gLinkPartnersHeldKeys[i] = gRecvCmds[i][1];
break;
}
- if (Rfu.unk_0c == 1 && Rfu.unk_61[i])
+ if (Rfu.parentChild == MODE_PARENT && Rfu.numBlocksReceived[i])
{
- if (Rfu.unk_61[i] == 4)
+ if (Rfu.numBlocksReceived[i] == 4)
{
- Rfu.unk_5c[i] = 1;
- Rfu.unk_61[i] = 0;
+ Rfu.blockReceived[i] = TRUE;
+ Rfu.numBlocksReceived[i] = 0;
}
else
- Rfu.unk_61[i]++;
+ Rfu.numBlocksReceived[i]++;
}
}
}
-bool8 sub_800FC60(void)
+static bool8 AreNoPlayersReceiving(void)
{
s32 i;
- for (i = 0; i < 5; i++)
+ for (i = 0; i < MAX_RFU_PLAYERS; i++)
{
- if (Rfu.unk_80[i].unk_12)
+ if (Rfu.recvBlock[i].receiving)
return FALSE;
}
return TRUE;
}
-bool8 sub_800FC88(void)
+static bool8 sub_800FC88(void)
{
s32 i;
for (i = 0; i < Rfu.playerCount; i++)
{
- if (Rfu.unk_80[i].unk_12 != 2 || Rfu.unk_5c[i] != 1)
+ if (Rfu.recvBlock[i].receiving != 2 || Rfu.blockReceived[i] != TRUE)
return FALSE;
}
return TRUE;
}
-void sub_800FCC4(struct UnkRfuStruct_2_Sub_6c *data)
+static void ResetSendDataManager(struct RfuBlockSend *data)
{
- data->unk_00 = 0;
- data->unk_02 = 0;
- data->unk_04 = NULL;
- data->unk_08 = 0;
- data->unk_10 = 0;
- data->unk_11 = 0;
- data->unk_12 = 0;
+ data->next = 0;
+ data->count = 0;
+ data->payload = NULL;
+ data->receivedFlags = 0;
+ data->sending = FALSE;
+ data->owner = 0;
+ data->receiving = 0;
}
-u8 sub_800FCD8(void)
+u8 Rfu_GetBlockReceivedStatus(void)
{
u8 flags = 0;
s32 i;
- for (i = 0; i < 5; i++)
+ for (i = 0; i < MAX_RFU_PLAYERS; i++)
{
- if (Rfu.unk_80[i].unk_12 == 2 && Rfu.unk_5c[i] == 1)
+ if (Rfu.recvBlock[i].receiving == 2 && Rfu.blockReceived[i] == TRUE)
{
flags |= (1 << i);
}
@@ -1114,7 +1181,7 @@ u8 sub_800FCD8(void)
return flags;
}
-void sub_800FD14(u16 command)
+static void RfuPrepareSendBuffer(u16 command)
{
u8 i;
u8 *buff;
@@ -1123,175 +1190,175 @@ void sub_800FD14(u16 command)
gSendCmd[0] = command;
switch (command)
{
- case 0x8800:
- gSendCmd[1] = Rfu.unk_6c.unk_02;
- gSendCmd[2] = Rfu.unk_6c.unk_11 + 0x80;
+ case RFU_COMMAND_0x8800:
+ gSendCmd[1] = Rfu.sendBlock.count;
+ gSendCmd[2] = Rfu.sendBlock.owner + 0x80;
break;
- case 0xa100:
- if (sub_800FC60())
+ case RFU_COMMAND_0xA100:
+ if (AreNoPlayersReceiving())
gSendCmd[1] = Rfu.unk_5a;
break;
- case 0x7700:
- case 0x7800:
+ case RFU_COMMAND_0x7700:
+ case RFU_COMMAND_0x7800:
tmp = Rfu.unk_ce2 ^ Rfu.unk_ce3;
- Rfu.playerCount = gUnknown_082ED695[tmp] + 1;
+ Rfu.playerCount = sUnknown_082ED695[tmp] + 1;
gSendCmd[1] = Rfu.playerCount;
buff = (u8 *)(gSendCmd + 2);
- for (i = 0; i < 4; i++)
- buff[i] = Rfu.unk_cde[i];
+ for (i = 0; i < RFU_CHILD_MAX; i++)
+ buff[i] = Rfu.linkPlayerIdx[i];
break;
- case 0x6600:
- case 0x5f00:
+ case RFU_COMMAND_0x6600:
+ case RFU_COMMAND_0x5F00:
gSendCmd[1] = Rfu.unk_100;
break;
- case 0x4400:
+ case RFU_COMMAND_0x4400:
gSendCmd[0] = command;
gSendCmd[1] = gMain.heldKeys;
break;
- case 0x2f00:
+ case RFU_COMMAND_0x2F00:
for (i = 0; i < 6; i++)
gSendCmd[1 + i] = Rfu.unk_f2[i];
break;
- case 0xbe00:
+ case RFU_COMMAND_0xBE00:
gSendCmd[1] = gHeldKeyCodeToSend;
break;
- case 0xee00:
+ case RFU_COMMAND_0xEE00:
break;
- case 0xed00:
+ case RFU_COMMAND_0xED00:
break;
}
}
void sub_800FE50(void *a0)
{
- if (gSendCmd[0] == 0 && !sub_8011A80())
+ if (gSendCmd[0] == 0 && !RfuHasErrored())
{
memcpy(Rfu.unk_f2, a0, sizeof(Rfu.unk_f2));
- sub_800FD14(0x2f00);
+ RfuPrepareSendBuffer(RFU_COMMAND_0x2F00);
}
}
-bool32 sub_800FE84(const u8 *src, size_t size)
+bool32 Rfu_InitBlockSend(const u8 *src, size_t size)
{
bool8 r4;
- if (Rfu.linkRfuCallback != NULL)
+ if (Rfu.callback != NULL)
return FALSE;
if (gSendCmd[0] != 0)
return FALSE;
- if (Rfu.unk_6c.unk_10 != 0)
+ if (Rfu.sendBlock.sending)
{
- gUnknown_02022B44.unk_83++;
+ sRfuDebug.unk_83++;
return FALSE;
}
r4 = (size % 12) != 0;
- Rfu.unk_6c.unk_11 = GetMultiplayerId();
- Rfu.unk_6c.unk_10 = 1;
- Rfu.unk_6c.unk_02 = (size / 12) + r4;
- Rfu.unk_6c.unk_00 = 0;
+ Rfu.sendBlock.owner = GetMultiplayerId();
+ Rfu.sendBlock.sending = TRUE;
+ Rfu.sendBlock.count = (size / 12) + r4;
+ Rfu.sendBlock.next = 0;
if (size > 0x100)
- Rfu.unk_6c.unk_04 = src;
+ Rfu.sendBlock.payload = src;
else
{
if (src != gBlockSendBuffer)
memcpy(gBlockSendBuffer, src, size);
- Rfu.unk_6c.unk_04 = gBlockSendBuffer;
+ Rfu.sendBlock.payload = gBlockSendBuffer;
}
- sub_800FD14(0x8800);
- Rfu.linkRfuCallback = rfufunc_80F9F44;
+ RfuPrepareSendBuffer(RFU_COMMAND_0x8800);
+ Rfu.callback = HandleBlockSend;
Rfu.unk_5b = 0;
return TRUE;
}
-void rfufunc_80F9F44(void)
+static void HandleBlockSend(void)
{
if (gSendCmd[0] == 0)
{
- sub_800FD14(0x8800);
- if (Rfu.unk_0c == 1)
+ RfuPrepareSendBuffer(RFU_COMMAND_0x8800);
+ if (Rfu.parentChild == MODE_PARENT)
{
if (++Rfu.unk_5b > 2)
- Rfu.linkRfuCallback = sub_800FFB0;
+ Rfu.callback = SendNextBlock;
}
else
{
- if ((gRecvCmds[GetMultiplayerId()][0] & 0xff00) == 0x8800)
- Rfu.linkRfuCallback = sub_800FFB0;
+ if ((gRecvCmds[GetMultiplayerId()][0] & 0xff00) == RFU_COMMAND_0x8800)
+ Rfu.callback = SendNextBlock;
}
}
}
-void sub_800FFB0(void)
+static void SendNextBlock(void)
{
s32 i;
- const u8 *src = Rfu.unk_6c.unk_04;
- gSendCmd[0] = 0x8900 | Rfu.unk_6c.unk_00;
- for (i = 0; i < 7; i++)
- gSendCmd[i + 1] = (src[(i << 1) + Rfu.unk_6c.unk_00 * 12 + 1] << 8) | src[(i << 1) + Rfu.unk_6c.unk_00 * 12 + 0];
- Rfu.unk_6c.unk_00++;
- if (Rfu.unk_6c.unk_02 <= Rfu.unk_6c.unk_00)
+ const u8 *src = Rfu.sendBlock.payload;
+ gSendCmd[0] = RFU_COMMAND_0x8900 | Rfu.sendBlock.next;
+ for (i = 0; i < CMD_LENGTH - 1; i++)
+ gSendCmd[i + 1] = (src[(i << 1) + Rfu.sendBlock.next * 12 + 1] << 8) | src[(i << 1) + Rfu.sendBlock.next * 12 + 0];
+ Rfu.sendBlock.next++;
+ if (Rfu.sendBlock.count <= Rfu.sendBlock.next)
{
- Rfu.unk_6c.unk_10 = 0;
- Rfu.linkRfuCallback = rfufunc_80FA020;
+ Rfu.sendBlock.sending = FALSE;
+ Rfu.callback = SendLastBlock;
}
}
-void rfufunc_80FA020(void)
+static void SendLastBlock(void)
{
- const u8 *src = Rfu.unk_6c.unk_04;
+ const u8 *src = Rfu.sendBlock.payload;
u8 mpId = GetMultiplayerId();
s32 i;
- if (Rfu.unk_0c == 0)
+ if (Rfu.parentChild == MODE_CHILD)
{
- gSendCmd[0] = (~0x76ff) | (Rfu.unk_6c.unk_02 - 1);
- for (i = 0; i < 7; i++)
- gSendCmd[i + 1] = (src[(i << 1) + (Rfu.unk_6c.unk_02 - 1) * 12 + 1] << 8) | src[(i << 1) + (Rfu.unk_6c.unk_02 - 1) * 12 + 0];
- if ((u8)gRecvCmds[mpId][0] == Rfu.unk_6c.unk_02 - 1)
+ gSendCmd[0] = RFU_COMMAND_0x8900 | (Rfu.sendBlock.count - 1);
+ for (i = 0; i < CMD_LENGTH - 1; i++)
+ gSendCmd[i + 1] = (src[(i << 1) + (Rfu.sendBlock.count - 1) * 12 + 1] << 8) | src[(i << 1) + (Rfu.sendBlock.count - 1) * 12 + 0];
+ if ((u8)gRecvCmds[mpId][0] == Rfu.sendBlock.count - 1)
{
- if (Rfu.unk_80[mpId].unk_08 != gUnknown_082ED628[Rfu.unk_80[mpId].unk_02])
+ if (Rfu.recvBlock[mpId].receivedFlags != sAllBlocksReceived[Rfu.recvBlock[mpId].count])
{
- sub_800F638(mpId, Rfu.unk_80[mpId].unk_08);
- gUnknown_02022B44.unk_64++;
+ HandleSendFailure(mpId, Rfu.recvBlock[mpId].receivedFlags);
+ sRfuDebug.unk_64++;
}
else
- Rfu.linkRfuCallback = NULL;
+ Rfu.callback = NULL;
}
}
else
- Rfu.linkRfuCallback = NULL;
+ Rfu.callback = NULL;
}
-bool8 sub_8010100(u8 a0)
+bool8 sub_8010100(u8 blockRequestType)
{
- Rfu.unk_5a = a0;
- sub_800FD14(0xa100);
+ Rfu.unk_5a = blockRequestType;
+ RfuPrepareSendBuffer(RFU_COMMAND_0xA100);
return TRUE;
}
-void sub_801011C(void)
+static void sub_801011C(void)
{
rfu_clearAllSlot();
rfu_LMAN_powerDownRFU();
gReceivedRemoteLinkPlayers = 0;
- Rfu.unk_ef = 1;
- Rfu.linkRfuCallback = NULL;
+ Rfu.isShuttingDown = TRUE;
+ Rfu.callback = NULL;
}
-void sub_8010148(void)
+static void sub_8010148(void)
{
rfu_REQ_disconnect(gRfuLinkStatus->connSlotFlag | gRfuLinkStatus->linkLossSlotFlag);
rfu_waitREQComplete();
sub_801011C();
}
-void sub_8010168(void)
+static void sub_8010168(void)
{
- if (Rfu.unk_0c == 0)
+ if (Rfu.parentChild == MODE_CHILD)
{
rfu_LMAN_requestChangeAgbClockMaster();
Rfu.unk_ce4 = 2;
}
else
- Rfu.linkRfuCallback = sub_8010148;
+ Rfu.callback = sub_8010148;
}
void LinkRfu_FatalError(void)
@@ -1301,7 +1368,7 @@ void LinkRfu_FatalError(void)
Rfu.unk_ce3 = gRfuLinkStatus->connSlotFlag | gRfuLinkStatus->linkLossSlotFlag;
}
-void sub_80101CC(void)
+static void sub_80101CC(void)
{
s32 i;
u8 playerCount = Rfu.playerCount;
@@ -1315,31 +1382,31 @@ void sub_80101CC(void)
if (count == playerCount)
{
gBattleTypeFlags &= ~BATTLE_TYPE_20;
- if (Rfu.unk_0c == 0)
+ if (Rfu.parentChild == MODE_CHILD)
{
- Rfu.unk_ee = 3;
+ Rfu.errorState = 3;
sub_8010168();
}
else
- Rfu.linkRfuCallback = sub_8010168;
+ Rfu.callback = sub_8010168;
}
}
-void sub_801022C(void)
+static void sub_801022C(void)
{
if (gSendCmd[0] == 0 && Rfu.unk_ce8 == 0)
{
- sub_800FD14(0x5f00);
- Rfu.linkRfuCallback = sub_80101CC;
+ RfuPrepareSendBuffer(RFU_COMMAND_0x5F00);
+ Rfu.callback = sub_80101CC;
}
}
-void sub_8010264(u8 taskId)
+static void sub_8010264(u8 taskId)
{
- if (Rfu.linkRfuCallback == NULL)
+ if (Rfu.callback == NULL)
{
Rfu.unk_cd9 = 1;
- Rfu.linkRfuCallback = sub_801022C;
+ Rfu.callback = sub_801022C;
DestroyTask(taskId);
}
}
@@ -1350,18 +1417,17 @@ void task_add_05_task_del_08FA224_when_no_RfuFunc(void)
CreateTask(sub_8010264, 5);
}
-void sub_80102B8(void)
+static void sub_80102B8(void)
{
u8 playerCount;
u8 i;
if (GetMultiplayerId() != 0)
{
- u8 r4 = Rfu.unk_124.unk_8c2;
- if (r4 == 0 && Rfu.unk_fe > 0x3c)
+ if (Rfu.recvQueue.count == 0 && Rfu.unk_fe > 60)
{
- sub_800FD14(0x6600);
- Rfu.unk_fe = r4;
+ RfuPrepareSendBuffer(RFU_COMMAND_0x6600);
+ Rfu.unk_fe = 0;
}
}
playerCount = GetLinkPlayerCount();
@@ -1375,31 +1441,31 @@ void sub_80102B8(void)
for (i = 0; i < MAX_RFU_PLAYERS; i++)
Rfu.unk_e9[i] = 0;
Rfu.unk_100++;
- Rfu.linkRfuCallback = NULL;
+ Rfu.callback = NULL;
}
Rfu.unk_fe++;
}
-void sub_8010358(void)
+static void sub_8010358(void)
{
- if (Rfu.unk_124.unk_8c2 == 0 && gSendCmd[0] == 0)
+ if (Rfu.recvQueue.count == 0 && gSendCmd[0] == 0)
{
- sub_800FD14(0x6600);
- Rfu.linkRfuCallback = sub_80102B8;
+ RfuPrepareSendBuffer(RFU_COMMAND_0x6600);
+ Rfu.callback = sub_80102B8;
}
}
-void sub_8010390(void)
+static void sub_8010390(void)
{
u8 i;
u8 playerCount;
if (GetMultiplayerId() != 0)
{
- if (Rfu.unk_124.unk_8c2 == 0 && gSendCmd[0] == 0)
+ if (Rfu.recvQueue.count == 0 && gSendCmd[0] == 0)
{
- sub_800FD14(0x6600);
- Rfu.linkRfuCallback = sub_80102B8;
+ RfuPrepareSendBuffer(RFU_COMMAND_0x6600);
+ Rfu.callback = sub_80102B8;
}
}
else
@@ -1412,10 +1478,10 @@ void sub_8010390(void)
}
if (i == playerCount)
{
- if (Rfu.unk_124.unk_8c2 == 0 && gSendCmd[0] == 0)
+ if (Rfu.recvQueue.count == 0 && gSendCmd[0] == 0)
{
- sub_800FD14(0x6600);
- Rfu.linkRfuCallback = sub_8010358;
+ RfuPrepareSendBuffer(RFU_COMMAND_0x6600);
+ Rfu.callback = sub_8010358;
}
}
}
@@ -1423,19 +1489,19 @@ void sub_8010390(void)
void sub_8010434(void)
{
- if (Rfu.linkRfuCallback == NULL)
+ if (Rfu.callback == NULL)
{
- Rfu.linkRfuCallback = sub_8010390;
+ Rfu.callback = sub_8010390;
Rfu.unk_fe = 0;
}
}
-bool32 sub_8010454(u32 a0)
+bool32 IsRfuSerialNumberValid(u32 serialNo)
{
s32 i;
- for (i = 0; gUnknown_082ED6E0[i] != a0; i++)
+ for (i = 0; sAcceptedSerialNos[i] != serialNo; i++)
{
- if (gUnknown_082ED6E0[i] == 0xFFFF)
+ if (sAcceptedSerialNos[i] == 0xFFFF)
return FALSE;
}
return TRUE;
@@ -1445,7 +1511,7 @@ u8 sub_801048C(bool32 a0)
{
if (a0 == FALSE)
return rfu_LMAN_setLinkRecovery(0, 0);
- rfu_LMAN_setLinkRecovery(1, 0x258);
+ rfu_LMAN_setLinkRecovery(1, 600);
return 0;
}
@@ -1455,71 +1521,73 @@ void sub_80104B0(void)
rfu_LMAN_stopManager(FALSE);
}
-u8 rfu_get_multiplayer_id(void)
+u8 Rfu_GetMultiplayerId(void)
{
- if (Rfu.unk_0c == 1)
+ if (Rfu.parentChild == MODE_PARENT)
return 0;
- return Rfu.unk_cce;
+ return Rfu.multiplayerId;
}
-u8 sub_80104F4(void)
+u8 Rfu_GetLinkPlayerCount(void)
{
return Rfu.playerCount;
}
bool8 IsLinkRfuTaskFinished(void)
{
- if (Rfu.unk_f1 == 2)
+ if (Rfu.status == RFU_STATUS_CONNECTION_ERROR)
return FALSE;
- return Rfu.linkRfuCallback ? FALSE : TRUE;
+ return Rfu.callback ? FALSE : TRUE;
}
-void sub_8010528(void)
+static void CallRfuFunc(void)
{
- if (Rfu.linkRfuCallback)
- Rfu.linkRfuCallback();
+ if (Rfu.callback)
+ Rfu.callback();
}
-bool8 sub_8010540(void)
+static bool8 CheckForLeavingGroupMembers(void)
{
s32 i;
- bool8 retval = FALSE;
- for (i = 0; i < 4; i++)
+ bool8 memberLeft = FALSE;
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- if (Rfu.unk_cd1[i] < 5 || Rfu.unk_cd1[i] > 6)
+ if (Rfu.partnerSendStatuses[i] < RFU_STATUS_JOIN_GROUP_OK
+ || Rfu.partnerSendStatuses[i] > RFU_STATUS_JOIN_GROUP_NO)
{
- if (gRfuSlotStatusNI[i]->recv.state == 0x46 || gRfuSlotStatusNI[i]->recv.state == 0x48)
+ if (gRfuSlotStatusNI[i]->recv.state == SLOT_STATE_RECV_SUCCESS
+ || gRfuSlotStatusNI[i]->recv.state == SLOT_STATE_RECV_SUCCESS_AND_SENDSIDE_UNKNOWN)
{
- if (Rfu.unk_cd5[i] == 8)
+ if (Rfu.partnerRecvStatuses[i] == RFU_STATUS_LEAVE_GROUP_NOTICE)
{
- Rfu.unk_cd1[i] = 9;
- Rfu.unk_cd5[i] = 10;
- rfu_clearSlot(8, i);
- rfu_NI_setSendData(1 << i, 8, Rfu.unk_cd1 + i, 1);
- retval = TRUE;
+ Rfu.partnerSendStatuses[i] = RFU_STATUS_LEAVE_GROUP;
+ Rfu.partnerRecvStatuses[i] = RFU_STATUS_10;
+ rfu_clearSlot(TYPE_NI_RECV, i);
+ rfu_NI_setSendData(1 << i, 8, &Rfu.partnerSendStatuses[i], 1);
+ memberLeft = TRUE;
}
}
- else if (gRfuSlotStatusNI[Rfu.unk_c3e]->recv.state == 0x47)
- rfu_clearSlot(8, i);
+ else if (gRfuSlotStatusNI[Rfu.childSlot]->recv.state == SLOT_STATE_RECV_FAILED)
+ rfu_clearSlot(TYPE_NI_RECV, i);
{
}
}
}
- return retval;
+ return memberLeft;
}
bool32 sub_80105EC(void)
{
u8 flags = 0;
s32 i;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- if (Rfu.unk_cd5[i] == 11)
+ if (Rfu.partnerRecvStatuses[i] == RFU_STATUS_11)
{
flags |= (1 << i);
- Rfu.unk_cd5[i] = 0;
+ Rfu.partnerRecvStatuses[i] = RFU_STATUS_OK;
}
}
if (flags)
@@ -1527,335 +1595,339 @@ bool32 sub_80105EC(void)
rfu_REQ_disconnect(flags);
rfu_waitREQComplete();
}
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- if (Rfu.unk_cd5[i] == 10 || Rfu.unk_cd5[i] == 11)
+ if (Rfu.partnerRecvStatuses[i] == RFU_STATUS_10
+ || Rfu.partnerRecvStatuses[i] == RFU_STATUS_11)
return TRUE;
}
return FALSE;
}
-bool32 sub_801064C(u16 a0, const u8 *a1)
+bool32 HasTrainerLeftPartnersList(u16 trainerId, const u8 *name)
{
- u8 r1 = sub_8011CE4(a1, a0);
- if (r1 == 0xFF)
+ u8 idx = GetPartnerIndexByNameAndTrainerID(name, trainerId);
+ if (idx == 0xFF)
return TRUE;
- if (Rfu.unk_cd1[r1] == 9)
+ if (Rfu.partnerSendStatuses[idx] == RFU_STATUS_LEAVE_GROUP)
return TRUE;
return FALSE;
}
-void sub_8010688(u8 a0, u16 a1, const u8 *a2)
+void SendRfuStatusToPartner(u8 status, u16 trainerId, const u8 *name)
{
- u8 r4 = sub_8011CE4(a2, a1);
- Rfu.unk_cd1[r4] = a0;
- rfu_clearSlot(4, r4);
- rfu_NI_setSendData(1 << r4, 8, Rfu.unk_cd1 + r4, 1);
+ u8 idx = GetPartnerIndexByNameAndTrainerID(name, trainerId);
+ Rfu.partnerSendStatuses[idx] = status;
+ rfu_clearSlot(TYPE_NI_SEND, idx);
+ rfu_NI_setSendData(1 << idx, 8, &Rfu.partnerSendStatuses[idx], 1);
}
-void sub_80106D4(void)
+void SendLeaveGroupNotice(void)
{
- Rfu.unk_c85 = 8;
- rfu_clearSlot(4, Rfu.unk_c3e);
- rfu_NI_setSendData(1 << Rfu.unk_c3e, 8, &Rfu.unk_c85, 1);
+ Rfu.unk_c85 = RFU_STATUS_LEAVE_GROUP_NOTICE;
+ rfu_clearSlot(TYPE_NI_SEND, Rfu.childSlot);
+ rfu_NI_setSendData(1 << Rfu.childSlot, 8, &Rfu.unk_c85, 1);
}
-u32 sub_8010714(u16 a0, const u8 *a1)
+u32 WaitSendRfuStatusToPartner(u16 trainerId, const u8 *name)
{
- u8 r0 = sub_8011CE4(a1, a0);
- if (r0 == 0xFF)
+ u8 idx = GetPartnerIndexByNameAndTrainerID(name, trainerId);
+ if (idx == 0xFF)
return 2;
- if (gRfuSlotStatusNI[r0]->send.state == 0)
+ if (gRfuSlotStatusNI[idx]->send.state == 0)
return 1;
return 0;
}
-void sub_8010750(void)
+static void UpdateChildStatuses(void)
{
s32 i;
- sub_8010540();
- for (i = 0; i < 4; i++)
+ CheckForLeavingGroupMembers();
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- if (gRfuSlotStatusNI[i]->send.state == 0x26 || gRfuSlotStatusNI[i]->send.state == 0x27)
+ if (gRfuSlotStatusNI[i]->send.state == SLOT_STATE_SEND_SUCCESS
+ || gRfuSlotStatusNI[i]->send.state == SLOT_STATE_SEND_FAILED)
{
- if (Rfu.unk_cd5[i] == 10)
- Rfu.unk_cd5[i] = 11;
- rfu_clearSlot(4, i);
+ if (Rfu.partnerRecvStatuses[i] == RFU_STATUS_10)
+ Rfu.partnerRecvStatuses[i] = RFU_STATUS_11;
+ rfu_clearSlot(TYPE_NI_SEND, i);
}
}
}
-s32 sub_80107A0(void)
+static s32 sub_80107A0(void)
{
- s32 retval = 0;
+ s32 status = RFU_STATUS_OK;
if (Rfu.unk_c85 == 8)
{
- if (gRfuSlotStatusNI[Rfu.unk_c3e]->send.state == 0x26 || gRfuSlotStatusNI[Rfu.unk_c3e]->send.state == 0x27)
- rfu_clearSlot(4, Rfu.unk_c3e);
+ if (gRfuSlotStatusNI[Rfu.childSlot]->send.state == SLOT_STATE_SEND_SUCCESS
+ || gRfuSlotStatusNI[Rfu.childSlot]->send.state == SLOT_STATE_SEND_FAILED)
+ rfu_clearSlot(TYPE_NI_SEND, Rfu.childSlot);
}
- if (gRfuSlotStatusNI[Rfu.unk_c3e]->recv.state == 0x46 || gRfuSlotStatusNI[Rfu.unk_c3e]->recv.state == 0x48)
+ if (gRfuSlotStatusNI[Rfu.childSlot]->recv.state == SLOT_STATE_RECV_SUCCESS
+ || gRfuSlotStatusNI[Rfu.childSlot]->recv.state == SLOT_STATE_RECV_SUCCESS_AND_SENDSIDE_UNKNOWN)
{
- rfu_clearSlot(8, Rfu.unk_c3e);
- sub_8011A64(Rfu.unk_c86, 0);
- retval = Rfu.unk_c86;
+ rfu_clearSlot(TYPE_NI_RECV, Rfu.childSlot);
+ RfuSetStatus(Rfu.recvStatus, 0);
+ status = Rfu.recvStatus;
}
- else if (gRfuSlotStatusNI[Rfu.unk_c3e]->recv.state == 0x47)
+ else if (gRfuSlotStatusNI[Rfu.childSlot]->recv.state == SLOT_STATE_RECV_FAILED)
{
- rfu_clearSlot(8, Rfu.unk_c3e);
- retval = 6;
+ rfu_clearSlot(TYPE_NI_RECV, Rfu.childSlot);
+ status = RFU_STATUS_JOIN_GROUP_NO;
}
- return retval;
+ return status;
}
-void sub_801084C(u8 taskId)
+static void sub_801084C(u8 taskId)
{
s32 i;
- if (Rfu.unk_f1 == 1 || Rfu.unk_f1 == 2)
+ if (Rfu.status == RFU_STATUS_FATAL_ERROR || Rfu.status == RFU_STATUS_CONNECTION_ERROR)
{
Rfu.unk_ce8 = 0;
DestroyTask(taskId);
}
switch (gTasks[taskId].data[0])
{
- case 0:
- if (sub_800FC60())
- {
- ResetBlockReceivedFlags();
- sub_800B348();
- gTasks[taskId].data[0]++;
- }
- break;
- case 1:
- if (Rfu.unk_0c == 1)
- {
- if (gReceivedRemoteLinkPlayers)
- sub_800FD14(0x7800);
- else
- sub_800FD14(0x7700);
- gTasks[taskId].data[0] = 101;
- }
+ case 0:
+ if (AreNoPlayersReceiving())
+ {
+ ResetBlockReceivedFlags();
+ sub_800B348();
+ gTasks[taskId].data[0]++;
+ }
+ break;
+ case 1:
+ if (Rfu.parentChild == MODE_PARENT)
+ {
+ if (gReceivedRemoteLinkPlayers)
+ RfuPrepareSendBuffer(RFU_COMMAND_0x7800);
else
- gTasks[taskId].data[0] = 2;
- break;
- case 101:
- if (gSendCmd[0] == 0)
- gTasks[taskId].data[0] = 2;
- break;
- case 2:
- if (Rfu.playerCount)
- gTasks[taskId].data[0]++;
- break;
- case 3:
- if (Rfu.unk_0c == 1)
+ RfuPrepareSendBuffer(RFU_COMMAND_0x7700);
+ gTasks[taskId].data[0] = 101;
+ }
+ else
+ gTasks[taskId].data[0] = 2;
+ break;
+ case 101:
+ if (gSendCmd[0] == 0)
+ gTasks[taskId].data[0] = 2;
+ break;
+ case 2:
+ if (Rfu.playerCount)
+ gTasks[taskId].data[0]++;
+ break;
+ case 3:
+ if (Rfu.parentChild == MODE_PARENT)
+ {
+ if (AreNoPlayersReceiving())
{
- if (sub_800FC60())
- {
- Rfu.unk_5a = 0;
- sub_800FD14(0xa100);
- gTasks[taskId].data[0]++;
- }
- }
- else
+ Rfu.unk_5a = 0;
+ RfuPrepareSendBuffer(RFU_COMMAND_0xA100);
gTasks[taskId].data[0]++;
- break;
- case 4:
- if (sub_800FC88())
- gTasks[taskId].data[0]++;
- break;
- case 5:
- for (i = 0; i < Rfu.playerCount; i++)
- {
- sub_800B3A4(i);
- sub_800F728(i);
}
+ }
+ else
gTasks[taskId].data[0]++;
- break;
- case 6:
- DestroyTask(taskId);
- gReceivedRemoteLinkPlayers = 1;
- Rfu.unk_ce8 = 0;
- rfu_LMAN_setLinkRecovery(1, 0x258);
- if (Rfu.unk_ce6)
+ break;
+ case 4:
+ if (sub_800FC88())
+ gTasks[taskId].data[0]++;
+ break;
+ case 5:
+ for (i = 0; i < Rfu.playerCount; i++)
+ {
+ LinkPlayerFromBlock(i);
+ Rfu_ResetBlockReceivedFlag(i);
+ }
+ gTasks[taskId].data[0]++;
+ break;
+ case 6:
+ DestroyTask(taskId);
+ gReceivedRemoteLinkPlayers = TRUE;
+ Rfu.unk_ce8 = FALSE;
+ rfu_LMAN_setLinkRecovery(1, 600);
+ if (Rfu.unk_ce6)
+ {
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- for (i = 0; i < 4; i++)
+ if ((Rfu.unk_ce6 >> i) & 1)
{
- if ((Rfu.unk_ce6 >> i) & 1)
- {
- Rfu.unk_ce5 = 1 << i;
- Rfu.unk_ce6 ^= (1 << i);
- }
+ Rfu.unk_ce5 = 1 << i;
+ Rfu.unk_ce6 ^= (1 << i);
}
}
- break;
+ }
+ break;
}
}
-void sub_80109E8(u16 a0)
+static void ClearSelectedLinkPlayerIds(u16 selected)
{
s32 i;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- if ((a0 >> i) & 1)
- Rfu.unk_cde[i] = 0;
+ if ((selected >> i) & 1)
+ Rfu.linkPlayerIdx[i] = 0;
}
}
-void sub_8010A14(const struct UnkRfuStruct_8010A14 *a0)
+static void ReceiveRfuLinkPlayers(const struct SioInfo *sioInfo)
{
s32 i;
- Rfu.playerCount = a0->unk_0f;
- for (i = 0; i < 4; i++)
- Rfu.unk_cde[i] = a0->unk_10[i];
+ Rfu.playerCount = sioInfo->playerCount;
+ for (i = 0; i < RFU_CHILD_MAX; i++)
+ Rfu.linkPlayerIdx[i] = sioInfo->linkPlayerIdx[i];
for (i = 0; i < MAX_RFU_PLAYERS; i++)
{
- gLinkPlayers[i] = a0->unk_14[i];
+ gLinkPlayers[i] = sioInfo->linkPlayers[i];
sub_800B524(gLinkPlayers + i);
}
}
-void sub_8010A70(void *a0)
+static void ValidateAndReceivePokemonSioInfo(void *recvBuffer)
{
- if (strcmp(gUnknown_082ED7EC, a0) == 0)
+ if (strcmp(sASCII_PokemonSioInfo, recvBuffer) == 0)
{
- sub_8010A14(a0);
- CpuFill16(0, a0, sizeof(struct UnkRfuStruct_8010A14));
+ ReceiveRfuLinkPlayers(recvBuffer);
+ CpuFill16(0, recvBuffer, sizeof(struct SioInfo));
ResetBlockReceivedFlag(0);
}
}
-void sub_8010AAC(u8 taskId)
+static void Task_ExchangeLinkPlayers(u8 taskId)
{
s32 i;
struct LinkPlayerBlock *r2;
- struct UnkRfuStruct_8010A14 *r5;
- u8 r4 = Rfu.unk_cde[gUnknown_082ED68C[Rfu.unk_ce9]];
- if (Rfu.unk_f1 == 1 || Rfu.unk_f1 == 2)
+ struct SioInfo *r5;
+ u8 r4 = Rfu.linkPlayerIdx[sUnknown_082ED68C[Rfu.unk_ce9]];
+ if (Rfu.status == RFU_STATUS_FATAL_ERROR || Rfu.status == RFU_STATUS_CONNECTION_ERROR)
{
Rfu.unk_ce8 = 0;
DestroyTask(taskId);
}
switch (gTasks[taskId].data[0])
{
- case 0:
- if (gSendCmd[0] == 0)
- {
- ResetBlockReceivedFlag(r4);
- sub_800FD14(0x7800);
- gTasks[taskId].data[0]++;
- }
- break;
- case 1:
- if (gSendCmd[0] == 0)
- gTasks[taskId].data[0]++;
- break;
- case 2:
- if ((GetBlockReceivedStatus() >> r4) & 1)
- {
- ResetBlockReceivedFlag(r4);
- r2 = (struct LinkPlayerBlock *)gBlockRecvBuffer[r4];
- gLinkPlayers[r4] = r2->linkPlayer;
- sub_800B524(gLinkPlayers + r4);
- gTasks[taskId].data[0]++;
- }
- break;
- case 3:
- r5 = (struct UnkRfuStruct_8010A14 *)gBlockSendBuffer;
- memcpy(r5->unk_00, gUnknown_082ED7EC, sizeof gUnknown_082ED7EC);
- r5->unk_0f = Rfu.playerCount;
- for (i = 0; i < 4; i++)
- r5->unk_10[i] = Rfu.unk_cde[i];
- memcpy(r5->unk_14, gLinkPlayers, sizeof gLinkPlayers);
+ case 0:
+ if (gSendCmd[0] == 0)
+ {
+ ResetBlockReceivedFlag(r4);
+ RfuPrepareSendBuffer(RFU_COMMAND_0x7800);
gTasks[taskId].data[0]++;
- // fallthrough
- case 4:
- r5 = (struct UnkRfuStruct_8010A14 *)gBlockSendBuffer;
- r5->unk_0f = Rfu.playerCount;
- for (i = 0; i < 4; i++)
- r5->unk_10[i] = Rfu.unk_cde[i];
- memcpy(r5->unk_14, gLinkPlayers, sizeof gLinkPlayers);
- if (SendBlock(0, gBlockSendBuffer, 0xa0))
- gTasks[taskId].data[0]++;
- break;
- case 5:
- if (IsLinkTaskFinished() && GetBlockReceivedStatus() & 1)
+ }
+ break;
+ case 1:
+ if (gSendCmd[0] == 0)
+ gTasks[taskId].data[0]++;
+ break;
+ case 2:
+ if ((GetBlockReceivedStatus() >> r4) & 1)
+ {
+ ResetBlockReceivedFlag(r4);
+ r2 = (struct LinkPlayerBlock *)gBlockRecvBuffer[r4];
+ gLinkPlayers[r4] = r2->linkPlayer;
+ sub_800B524(gLinkPlayers + r4);
+ gTasks[taskId].data[0]++;
+ }
+ break;
+ case 3:
+ r5 = (struct SioInfo *)gBlockSendBuffer;
+ memcpy(r5->magic, sASCII_PokemonSioInfo, sizeof sASCII_PokemonSioInfo);
+ r5->playerCount = Rfu.playerCount;
+ for (i = 0; i < RFU_CHILD_MAX; i++)
+ r5->linkPlayerIdx[i] = Rfu.linkPlayerIdx[i];
+ memcpy(r5->linkPlayers, gLinkPlayers, sizeof gLinkPlayers);
+ gTasks[taskId].data[0]++;
+ // fallthrough
+ case 4:
+ r5 = (struct SioInfo *)gBlockSendBuffer;
+ r5->playerCount = Rfu.playerCount;
+ for (i = 0; i < RFU_CHILD_MAX; i++)
+ r5->linkPlayerIdx[i] = Rfu.linkPlayerIdx[i];
+ memcpy(r5->linkPlayers, gLinkPlayers, sizeof gLinkPlayers);
+ if (SendBlock(0, gBlockSendBuffer, 0xa0))
+ gTasks[taskId].data[0]++;
+ break;
+ case 5:
+ if (IsLinkTaskFinished() && GetBlockReceivedStatus() & 1)
+ {
+ CpuFill16(0, gBlockRecvBuffer, sizeof(struct SioInfo));
+ ResetBlockReceivedFlag(0);
+ Rfu.unk_ce8 = 0;
+ if (Rfu.unk_ce6)
{
- CpuFill16(0, gBlockRecvBuffer, sizeof(struct UnkRfuStruct_8010A14));
- ResetBlockReceivedFlag(0);
- Rfu.unk_ce8 = 0;
- if (Rfu.unk_ce6)
+ for (i = 0; i < 4; i++)
{
- for (i = 0; i < 4; i++)
+ if ((Rfu.unk_ce6 >> i) & 1)
{
- if ((Rfu.unk_ce6 >> i) & 1)
- {
- Rfu.unk_ce5 = 1 << i;
- Rfu.unk_ce6 ^= (1 << i);
- Rfu.unk_ce8 = 1;
- break;
- }
+ Rfu.unk_ce5 = 1 << i;
+ Rfu.unk_ce6 ^= (1 << i);
+ Rfu.unk_ce8 = 1;
+ break;
}
}
- DestroyTask(taskId);
}
- break;
+ DestroyTask(taskId);
+ }
+ break;
}
}
-void sub_8010D0C(u8 taskId)
+static void sub_8010D0C(u8 taskId)
{
- if (Rfu.unk_f1 == 1 || Rfu.unk_f1 == 2)
+ if (Rfu.status == RFU_STATUS_FATAL_ERROR || Rfu.status == RFU_STATUS_CONNECTION_ERROR)
DestroyTask(taskId);
switch (gTasks[taskId].data[0])
{
- case 0:
- if (Rfu.playerCount)
- {
- sub_800B348();
- SendBlock(0, gBlockSendBuffer, sizeof(struct LinkPlayerBlock));
- gTasks[taskId].data[0]++;
- }
- break;
- case 1:
- if (IsLinkTaskFinished())
- gTasks[taskId].data[0]++;
- break;
- case 2:
- if (GetBlockReceivedStatus() & 1)
- {
- sub_8010A14((const struct UnkRfuStruct_8010A14 *)gBlockRecvBuffer);
- ResetBlockReceivedFlag(0);
- gReceivedRemoteLinkPlayers = 1;
- DestroyTask(taskId);
- }
- break;
+ case 0:
+ if (Rfu.playerCount)
+ {
+ sub_800B348();
+ SendBlock(0, gBlockSendBuffer, sizeof(struct LinkPlayerBlock));
+ gTasks[taskId].data[0]++;
+ }
+ break;
+ case 1:
+ if (IsLinkTaskFinished())
+ gTasks[taskId].data[0]++;
+ break;
+ case 2:
+ if (GetBlockReceivedStatus() & 1)
+ {
+ ReceiveRfuLinkPlayers((const struct SioInfo *)gBlockRecvBuffer);
+ ResetBlockReceivedFlag(0);
+ gReceivedRemoteLinkPlayers = 1;
+ DestroyTask(taskId);
+ }
+ break;
}
}
-void sub_8010DB4(void)
+static void RfuCheckErrorStatus(void)
{
- if (Rfu.unk_ee == 1 && lman.childClockSlave_flag == 0)
+ if (Rfu.errorState == 1 && lman.childClockSlave_flag == 0)
{
if (gMain.callback2 == c2_mystery_gift_e_reader_run || lman.init_param->mboot_flag)
gWirelessCommType = 2;
SetMainCallback2(CB2_LinkError);
gMain.savedCallback = CB2_LinkError;
- sub_800AF18((Rfu.unk_0a << 16) | (Rfu.unk_10 << 8) | Rfu.unk_12, Rfu.unk_124.unk_8c2, Rfu.unk_9e8.unk_232, sub_8011A74() == 2);
- Rfu.unk_ee = 2;
+ BufferLinkErrorInfo((Rfu.linkmanMsg << 16) | (Rfu.unk_10 << 8) | Rfu.unk_12, Rfu.recvQueue.count, Rfu.sendQueue.count, RfuGetStatus() == RFU_STATUS_CONNECTION_ERROR);
+ Rfu.errorState = 2;
CloseLink();
}
- else if (Rfu.unk_9e8.unk_233 == 1 || Rfu.unk_124.unk_8c3 == 1)
+ else if (Rfu.sendQueue.full == TRUE || Rfu.recvQueue.full == TRUE)
{
if (lman.childClockSlave_flag)
rfu_LMAN_requestChangeAgbClockMaster();
- sub_8011A64(1, 0x7000);
- sub_8011170(0x7000);
+ RfuSetStatus(RFU_STATUS_FATAL_ERROR, 0x7000);
+ GetLinkmanErrorParams(0x7000);
}
}
-void rfu_REQ_recvData_then_sendData(void)
+static void rfu_REQ_recvData_then_sendData(void)
{
if (lman.parent_child == 1)
{
@@ -1868,21 +1940,21 @@ void rfu_REQ_recvData_then_sendData(void)
bool32 sub_8010EC0(void)
{
bool32 retval = FALSE;
- Rfu.unk_ccd = 0;
+ Rfu.parentId = 0;
rfu_LMAN_manager_entity(Random2());
- if (Rfu.unk_ef == 0)
+ if (!Rfu.isShuttingDown)
{
- switch (Rfu.unk_0c)
+ switch (Rfu.parentChild)
{
- case 1:
- sub_800F0F8();
- break;
- case 0:
- retval = sub_800F4F0();
- break;
- case 2:
- rfu_REQ_recvData_then_sendData();
- break;
+ case MODE_PARENT:
+ sub_800F0F8();
+ break;
+ case MODE_CHILD:
+ retval = RfuProcessEnqueuedRecvBlock();
+ break;
+ case 2:
+ rfu_REQ_recvData_then_sendData();
+ break;
}
}
return retval;
@@ -1891,42 +1963,42 @@ bool32 sub_8010EC0(void)
bool32 sub_8010F1C(void)
{
bool32 retval = FALSE;
- if (Rfu.unk_ef == 0)
+ if (!Rfu.isShuttingDown)
{
- if (Rfu.unk_0c == 1)
+ if (Rfu.parentChild == MODE_PARENT)
retval = sub_800F1E0();
- sub_8010DB4();
+ RfuCheckErrorStatus();
}
return retval;
}
-void sub_8010F48(void)
+static void CopyPlayerNameToUnameBuffer(void)
{
- StringCopy(gUnknown_02022B22, gSaveBlock2Ptr->playerName);
+ StringCopy(gHostRFUtgtUnameBuffer, gSaveBlock2Ptr->playerName);
}
-void sub_8010F60(void)
+void ClearAndInitHostRFUtgtGname(void)
{
- memset(&gUnknown_02022B14, 0, 0xD);
- sub_800DD94(&gUnknown_02022B14, 0, 0, 0);
+ memset(&gHostRFUtgtGnameBuffer, 0, RFU_GAME_NAME_LENGTH);
+ InitHostRFUtgtGname(&gHostRFUtgtGnameBuffer, ACTIVITY_NONE, FALSE, 0);
}
-void sub_8010F84(u8 a0, u32 a1, u32 a2)
+void SetHostRFUtgtGname(u8 activity, u32 child_sprite_genders, bool32 started)
{
- sub_800DD94(&gUnknown_02022B14, a0, a2, a1);
+ InitHostRFUtgtGname(&gHostRFUtgtGnameBuffer, activity, started, child_sprite_genders);
}
-void sub_8010FA0(bool32 a0, bool32 a1)
+void SetGnameBufferWonderFlags(bool32 hasNews, bool32 hasCard)
{
- gUnknown_02022B14.unk_00.hasNews = a0;
- gUnknown_02022B14.unk_00.hasCard = a1;
+ gHostRFUtgtGnameBuffer.unk_00.hasNews = hasNews;
+ gHostRFUtgtGnameBuffer.unk_00.hasCard = hasCard;
}
-void sub_8010FCC(u32 type, u32 species, u32 level)
+void SetTradeBoardRegisteredMonInfo(u32 type, u32 species, u32 level)
{
- gUnknown_02022B14.type = type;
- gUnknown_02022B14.species = species;
- gUnknown_02022B14.level = level;
+ gHostRFUtgtGnameBuffer.type = type;
+ gHostRFUtgtGnameBuffer.species = species;
+ gHostRFUtgtGnameBuffer.level = level;
}
u8 sub_801100C(s32 a0)
@@ -1939,244 +2011,252 @@ u8 sub_801100C(s32 a0)
void sub_801103C(void)
{
- struct GFtgtGname *r5 = &gUnknown_02022B14;
+ struct GFtgtGname *r5 = &gHostRFUtgtGnameBuffer;
s32 i;
for (i = 1; i < GetLinkPlayerCount(); i++)
r5->child_sprite_gender[i - 1] = sub_801100C(i);
}
-void sub_8011068(u8 a0)
+void UpdateGameData_GroupLockedIn(bool8 started)
{
- gUnknown_02022B14.started = a0;
- rfu_REQ_configGameData(0, 2, (const u8 *)&gUnknown_02022B14, gUnknown_02022B22);
+ gHostRFUtgtGnameBuffer.started = started;
+ rfu_REQ_configGameData(0, 2, (void *)&gHostRFUtgtGnameBuffer, gHostRFUtgtUnameBuffer);
}
-void sub_8011090(u8 a0, u32 a1, u32 a2)
+void UpdateGameData_SetActivity(u8 activity, u32 flags, bool32 started)
{
- if (a0)
- sub_8010F84(a0, a1, a2);
- rfu_REQ_configGameData(0, 2, (const u8 *)&gUnknown_02022B14, gUnknown_02022B22);
+ if (activity != ACTIVITY_NONE)
+ SetHostRFUtgtGname(activity, flags, started);
+ rfu_REQ_configGameData(0, 2, (void *)&gHostRFUtgtGnameBuffer, gHostRFUtgtUnameBuffer);
}
void sub_80110B8(u32 a0)
{
s32 i;
- u32 r5;
- u32 r7;
+ u32 numConnectedChildren;
+ u32 child_sprite_genders;
s32 r8;
- if (sub_800F7DC()->activity == 0x45)
+ if (GetHostRFUtgtGname()->activity == (ACTIVITY_CHAT | IN_UNION_ROOM))
{
- r5 = 0;
- r7 = 0;
+ numConnectedChildren = 0;
+ child_sprite_genders = 0;
r8 = Rfu.unk_ce2 ^ Rfu.unk_ce3;
for (i = 0; i < 4; i++)
{
if ((r8 >> i) & 1)
{
- r7 |= ((0x80 | ((gLinkPlayers[Rfu.unk_cde[i]].gender & 1) << 3) | (gLinkPlayers[Rfu.unk_cde[i]].trainerId & 7)) << (r5 << 3));
- r5++;
- if (r5 == a0 - 1)
+ child_sprite_genders |= ((0x80 | ((gLinkPlayers[Rfu.linkPlayerIdx[i]].gender & 1) << 3) | (gLinkPlayers[Rfu.linkPlayerIdx[i]].trainerId & 7)) << (numConnectedChildren << 3));
+ numConnectedChildren++;
+ if (numConnectedChildren == a0 - 1)
break;
}
}
- sub_8011090(0x45, r7, 0);
+ UpdateGameData_SetActivity((ACTIVITY_CHAT | IN_UNION_ROOM), child_sprite_genders, FALSE);
}
}
-void sub_8011170(u32 a0)
+void GetLinkmanErrorParams(u32 msg)
{
- if (Rfu.unk_ee == 0)
+ if (Rfu.errorState == 0)
{
Rfu.unk_10 = lman.param[0];
Rfu.unk_12 = lman.param[1];
- Rfu.unk_0a = a0;
- Rfu.unk_ee = 1;
+ Rfu.linkmanMsg = msg;
+ Rfu.errorState = 1;
}
}
-void sub_80111A0(void)
+static void ResetErrorState(void)
{
- Rfu.unk_ee = 0;
+ Rfu.errorState = 0;
}
void sub_80111B0(bool32 a0)
{
if (!a0)
- Rfu.unk_ee = 0;
+ Rfu.errorState = 0;
else
- Rfu.unk_ee = 4;
+ Rfu.errorState = 4;
}
-void sub_80111DC(void)
+static void sub_80111DC(void)
{
sub_8011E94(lman.acceptSlot_flag, 1);
- Rfu.linkRfuCallback = NULL;
+ Rfu.callback = NULL;
}
-void sub_80111FC(void)
+static void sub_80111FC(void)
{
- Rfu.linkRfuCallback = sub_80111DC;
+ Rfu.callback = sub_80111DC;
}
-void sub_801120C(u8 a0, u8 unused1)
+static void sub_801120C(u8 msg, u8 paramCount)
{
u8 i;
- u8 r6 = 0;
- switch (a0)
+ u8 disconnectFlag = 0;
+ switch (msg)
{
- case 0x00:
- Rfu.unk_04 = 2;
+ case LMAN_MSG_INITIALIZE_COMPLETED:
+ Rfu.state = 2;
break;
- case 0x10:
+ case LMAN_MSG_NEW_CHILD_CONNECT_DETECTED:
break;
- case 0x11:
+ case LMAN_MSG_NEW_CHILD_CONNECT_ACCEPTED:
sub_80115EC(lman.param[0]);
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
if ((lman.param[0] >> i) & 1)
{
struct GFtgtGname *structPtr = (void *)gRfuLinkStatus->partner[i].gname;
- if (structPtr->activity == sub_800F7DC()->activity)
+ if (structPtr->activity == GetHostRFUtgtGname()->activity)
{
- Rfu.unk_cd1[i] = 0;
- Rfu.unk_cd5[i] = 0;
- rfu_setRecvBuffer(0x20, i, Rfu.unk_cd5 + i, 1);
+ Rfu.partnerSendStatuses[i] = RFU_STATUS_OK;
+ Rfu.partnerRecvStatuses[i] = RFU_STATUS_OK;
+ rfu_setRecvBuffer(TYPE_NI, i, &Rfu.partnerRecvStatuses[i], 1);
}
else
{
- r6 |= (1 << i);
+ disconnectFlag |= (1 << i);
}
}
}
- if (r6)
+ if (disconnectFlag)
{
- rfu_REQ_disconnect(r6);
+ rfu_REQ_disconnect(disconnectFlag);
rfu_waitREQComplete();
}
break;
- case 0x12:
+ case LMAN_MSG_NEW_CHILD_CONNECT_REJECTED:
break;
- case 0x13:
+ case LMAN_MSG_SEARCH_CHILD_PERIOD_EXPIRED:
break;
- case 0x14:
- if (Rfu.unk_ce7 != lman.acceptSlot_flag)
+ case LMAN_MSG_END_WAIT_CHILD_NAME:
+ if (Rfu.acceptSlot_flag != lman.acceptSlot_flag)
{
- rfu_REQ_disconnect(Rfu.unk_ce7 ^ lman.acceptSlot_flag);
+ rfu_REQ_disconnect(Rfu.acceptSlot_flag ^ lman.acceptSlot_flag);
rfu_waitREQComplete();
}
- Rfu.unk_04 = 0x11;
+ Rfu.state = 17;
break;
- case 0x31:
- Rfu.unk_f0 = 1;
+ case LMAN_MSG_LINK_LOSS_DETECTED_AND_START_RECOVERY:
+ Rfu.linkLossRecoveryState = 1;
break;
- case 0x32:
- Rfu.unk_f0 = 3;
+ case LMAN_MSG_LINK_RECOVERY_SUCCESSED:
+ Rfu.linkLossRecoveryState = 3;
break;
- case 0x30:
- case 0x33:
- Rfu.unk_f0 = 4;
+ case LMAN_MSG_LINK_LOSS_DETECTED_AND_DISCONNECTED:
+ case LMAN_MSG_LINK_RECOVERY_FAILED_AND_DISCONNECTED:
+ Rfu.linkLossRecoveryState = 4;
Rfu.unk_ce2 &= ~lman.param[0];
if (gReceivedRemoteLinkPlayers == 1)
{
if (Rfu.unk_ce2 == 0)
- sub_8011170(a0);
+ GetLinkmanErrorParams(msg);
else
sub_80111FC();
}
- sub_8011A64(2, a0);
+ RfuSetStatus(RFU_STATUS_CONNECTION_ERROR, msg);
break;
case 0x34:
break;
- case 0x42 ... 0x44:
+ case LMAN_MSG_RFU_POWER_DOWN:
+ case LMAN_MSG_MANAGER_STOPPED:
+ case LMAN_MSG_MANAGER_FORCED_STOPPED_AND_RFU_RESET:
break;
- case 0xf3:
- sub_8011A64(1, a0);
- sub_8011170(a0);
- Rfu.unk_ef = 1;
+ case LMAN_MSG_LMAN_API_ERROR_RETURN:
+ RfuSetStatus(RFU_STATUS_FATAL_ERROR, msg);
+ GetLinkmanErrorParams(msg);
+ Rfu.isShuttingDown = TRUE;
break;
- case 0xf0 ... 0xf2:
- case 0xff:
- sub_8011170(a0);
- sub_8011A64(1, a0);
- Rfu.unk_cdb = 1;
+ case LMAN_MSG_REQ_API_ERROR:
+ case LMAN_MSG_WATCH_DOG_TIMER_ERROR:
+ case LMAN_MSG_CLOCK_SLAVE_MS_CHANGE_ERROR_BY_DMA:
+ case LMAN_MSG_RFU_FATAL_ERROR:
+ GetLinkmanErrorParams(msg);
+ RfuSetStatus(RFU_STATUS_FATAL_ERROR, msg);
+ Rfu.unk_cdb = TRUE;
break;
}
}
-void sub_8011404(u8 a0, u8 unused1)
+void sub_8011404(u8 msg, u8 unused1)
{
- switch (a0)
+ switch (msg)
{
- case 0x00:
- Rfu.unk_04 = 6;
+ case LMAN_MSG_INITIALIZE_COMPLETED:
+ Rfu.state = 6;
break;
- case 0x20:
- Rfu.unk_ccd = lman.param[0];
+ case LMAN_MSG_PARENT_FOUND:
+ Rfu.parentId = lman.param[0];
break;
- case 0x21:
+ case LMAN_MSG_SEARCH_PARENT_PERIOD_EXPIRED:
break;
- case 0x22:
- Rfu.unk_c3e = lman.param[0];
+ case LMAN_MSG_CONNECT_PARENT_SUCCESSED:
+ Rfu.childSlot = lman.param[0];
break;
- case 0x23:
- sub_8011A64(2, a0);
+ case LMAN_MSG_CONNECT_PARENT_FAILED:
+ RfuSetStatus(RFU_STATUS_CONNECTION_ERROR, msg);
break;
- case 0x24:
- Rfu.unk_04 = 11;
+ case LMAN_MSG_CHILD_NAME_SEND_COMPLETED:
+ Rfu.state = 11;
Rfu.unk_c85 = 0;
- Rfu.unk_c86 = 0;
- rfu_setRecvBuffer(0x20, Rfu.unk_c3e, &Rfu.unk_c86, 1);
- rfu_setRecvBuffer(0x10, Rfu.unk_c3e, Rfu.unk_c3f, 70);
+ Rfu.recvStatus = RFU_STATUS_OK;
+ rfu_setRecvBuffer(TYPE_NI, Rfu.childSlot, &Rfu.recvStatus, 1);
+ rfu_setRecvBuffer(TYPE_UNI, Rfu.childSlot, Rfu.unk_c3f, 70);
break;
- case 0x25:
- sub_8011A64(2, 0x25);
+ case LMAN_MSG_CHILD_NAME_SEND_FAILED_AND_DISCONNECTED:
+ RfuSetStatus(RFU_STATUS_CONNECTION_ERROR, msg);
break;
- case 0x30:
- Rfu.unk_f0 = 2;
- if (Rfu.unk_c86 == 6)
+ case LMAN_MSG_LINK_LOSS_DETECTED_AND_DISCONNECTED:
+ Rfu.linkLossRecoveryState = 2;
+ if (Rfu.recvStatus == RFU_STATUS_JOIN_GROUP_NO)
break;
- case 0x33:
- if (Rfu.unk_f0 != 2)
- Rfu.unk_f0 = 4;
- if (Rfu.unk_c86 != 9)
- sub_8011A64(2, a0);
- nullsub_5(gUnknown_082ED7FC, 5, 5);
+ case LMAN_MSG_LINK_RECOVERY_FAILED_AND_DISCONNECTED:
+ if (Rfu.linkLossRecoveryState != 2)
+ Rfu.linkLossRecoveryState = 4;
+ if (Rfu.recvStatus != RFU_STATUS_LEAVE_GROUP)
+ RfuSetStatus(RFU_STATUS_CONNECTION_ERROR, msg);
+ Debug_PrintString(sASCII_LinkLossDisconnect, 5, 5);
if (gReceivedRemoteLinkPlayers == 1)
- sub_8011170(a0);
+ GetLinkmanErrorParams(msg);
break;
- case 0x31:
- Rfu.unk_f0 = 1;
- nullsub_5(gUnknown_082ED814, 5, 5);
+ case LMAN_MSG_LINK_LOSS_DETECTED_AND_START_RECOVERY:
+ Rfu.linkLossRecoveryState = 1;
+ Debug_PrintString(sASCII_LinkLossRecoveryNow, 5, 5);
break;
- case 0x32:
- Rfu.unk_f0 = 3;
- Rfu.unk_c3c = 1;
+ case LMAN_MSG_LINK_RECOVERY_SUCCESSED:
+ Rfu.linkLossRecoveryState = 3;
+ Rfu.linkRecovered = TRUE;
break;
case 0x34:
break;
- case 0x42 ... 0x44:
+ case LMAN_MSG_RFU_POWER_DOWN:
+ case LMAN_MSG_MANAGER_STOPPED:
+ case LMAN_MSG_MANAGER_FORCED_STOPPED_AND_RFU_RESET:
break;
- case 0xF3:
- sub_8011A64(1, a0);
- sub_8011170(a0);
- Rfu.unk_ef = 1;
+ case LMAN_MSG_LMAN_API_ERROR_RETURN:
+ RfuSetStatus(RFU_STATUS_FATAL_ERROR, msg);
+ GetLinkmanErrorParams(msg);
+ Rfu.isShuttingDown = TRUE;
break;
- case 0xF0 ... 0xF2:
- case 0xFF:
- sub_8011A64(1, a0);
- sub_8011170(a0);
- Rfu.unk_cdb = 1;
+ case LMAN_MSG_REQ_API_ERROR:
+ case LMAN_MSG_WATCH_DOG_TIMER_ERROR:
+ case LMAN_MSG_CLOCK_SLAVE_MS_CHANGE_ERROR_BY_DMA:
+ case LMAN_MSG_RFU_FATAL_ERROR:
+ RfuSetStatus(RFU_STATUS_FATAL_ERROR, msg);
+ GetLinkmanErrorParams(msg);
+ Rfu.unk_cdb = TRUE;
break;
}
}
-void sub_80115EC(s32 a0)
+static void sub_80115EC(s32 a0)
{
s32 i;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
if ((a0 >> i) & 1)
{
@@ -2186,17 +2266,17 @@ void sub_80115EC(s32 a0)
}
}
-u8 sub_8011628(s32 a0)
+static u8 GetNewChildrenInUnionRoomChat(s32 a0)
{
u8 ret = 0;
u8 i;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
if ((a0 >> i) & 1)
{
struct GFtgtGname *structPtr = (void *)gRfuLinkStatus->partner[i].gname;
- if (structPtr->activity == 0x45)
+ if (structPtr->activity == (ACTIVITY_CHAT | IN_UNION_ROOM))
ret |= (1 << i);
}
}
@@ -2204,22 +2284,22 @@ u8 sub_8011628(s32 a0)
return ret;
}
-void sub_8011674(u8 a0, u8 unused1)
+static void sub_8011674(u8 msg, u8 paramCount)
{
u8 r1;
- switch (a0)
+ switch (msg)
{
- case 0x00:
- Rfu.unk_04 = 0x11;
+ case LMAN_MSG_INITIALIZE_COMPLETED:
+ Rfu.state = 17;
break;
- case 0x10:
- sub_8011A64(4, 0);
+ case LMAN_MSG_NEW_CHILD_CONNECT_DETECTED:
+ RfuSetStatus(RFU_STATUS_NEW_CHILD_DETECTED, 0);
break;
- case 0x11:
- if (sub_800F7DC()->activity == 0x45 && Rfu.unk_cd9 == 0)
+ case LMAN_MSG_NEW_CHILD_CONNECT_ACCEPTED:
+ if (GetHostRFUtgtGname()->activity == (ACTIVITY_CHAT | IN_UNION_ROOM) && Rfu.unk_cd9 == 0)
{
- u8 idx = sub_8011628(lman.param[0]);
+ u8 idx = GetNewChildrenInUnionRoomChat(lman.param[0]);
if (idx != 0)
{
r1 = 1 << sub_800E87C(idx);
@@ -2227,7 +2307,7 @@ void sub_8011674(u8 a0, u8 unused1)
{
Rfu.unk_ce5 = r1;
Rfu.unk_ce6 |= (r1 ^ idx);
- Rfu.unk_ce8 = 1;
+ Rfu.unk_ce8 = TRUE;
}
else
{
@@ -2240,38 +2320,38 @@ void sub_8011674(u8 a0, u8 unused1)
Rfu.unk_ce4 = 2;
}
}
- else if (sub_800F7DC()->activity == 0x54)
+ else if (GetHostRFUtgtGname()->activity == (ACTIVITY_PLYRTALK | IN_UNION_ROOM))
{
rfu_REQ_disconnect(lman.acceptSlot_flag);
rfu_waitREQComplete();
}
sub_80115EC(lman.param[0]);
break;
- case 0x12:
+ case LMAN_MSG_NEW_CHILD_CONNECT_REJECTED:
break;
- case 0x13:
+ case LMAN_MSG_SEARCH_CHILD_PERIOD_EXPIRED:
break;
- case 0x14:
- if (sub_800F7DC()->activity != 0x45 && lman.acceptCount > 1)
+ case LMAN_MSG_END_WAIT_CHILD_NAME:
+ if (GetHostRFUtgtGname()->activity != (ACTIVITY_CHAT | IN_UNION_ROOM) && lman.acceptCount > 1)
{
r1 = 1 << sub_800E87C(lman.param[0]);
rfu_REQ_disconnect(lman.acceptSlot_flag ^ r1);
rfu_waitREQComplete();
}
- if (Rfu.unk_04 == 0xF)
- Rfu.unk_04 = 0x10;
+ if (Rfu.state == 15)
+ Rfu.state = 16;
break;
break;
- case 0x20:
- Rfu.unk_ccd = lman.param[0];
+ case LMAN_MSG_PARENT_FOUND:
+ Rfu.parentId = lman.param[0];
break;
- case 0x21:
+ case LMAN_MSG_SEARCH_PARENT_PERIOD_EXPIRED:
break;
- case 0x22:
- Rfu.unk_c3e = lman.param[0];
+ case LMAN_MSG_CONNECT_PARENT_SUCCESSED:
+ Rfu.childSlot = lman.param[0];
break;
- case 0x23:
- Rfu.unk_04 = 0x12;
+ case LMAN_MSG_CONNECT_PARENT_FAILED:
+ Rfu.state = 18;
if (Rfu.unk_ccf < 2)
{
Rfu.unk_ccf++;
@@ -2279,68 +2359,72 @@ void sub_8011674(u8 a0, u8 unused1)
}
else
{
- sub_8011A64(2, a0);
+ RfuSetStatus(RFU_STATUS_CONNECTION_ERROR, msg);
}
break;
- case 0x24:
- Rfu.unk_04 = 0xD;
- sub_8011A64(3, 0);
- rfu_setRecvBuffer(0x10, Rfu.unk_c3e, Rfu.unk_c3f, 70);
+ case LMAN_MSG_CHILD_NAME_SEND_COMPLETED:
+ Rfu.state = 13;
+ RfuSetStatus(RFU_STATUS_CHILD_SEND_COMPLETE, 0);
+ rfu_setRecvBuffer(TYPE_UNI, Rfu.childSlot, Rfu.unk_c3f, 70);
break;
- case 0x25:
- sub_8011A64(2, a0);
+ case LMAN_MSG_CHILD_NAME_SEND_FAILED_AND_DISCONNECTED:
+ RfuSetStatus(RFU_STATUS_CONNECTION_ERROR, msg);
break;
- case 0x31:
+ case LMAN_MSG_LINK_LOSS_DETECTED_AND_START_RECOVERY:
if (lman.acceptSlot_flag & lman.param[0])
- Rfu.unk_f0 = 1;
+ Rfu.linkLossRecoveryState = 1;
break;
- case 0x32:
- Rfu.unk_f0 = 3;
- if (gRfuLinkStatus->parentChild == 0)
- Rfu.unk_c3c = 1;
+ case LMAN_MSG_LINK_RECOVERY_SUCCESSED:
+ Rfu.linkLossRecoveryState = 3;
+ if (gRfuLinkStatus->parentChild == MODE_CHILD)
+ Rfu.linkRecovered = TRUE;
break;
- case 0x30:
- Rfu.unk_f0 = 2;
- case 0x33:
- if (Rfu.unk_f0 != 2)
- Rfu.unk_f0 = 4;
- if (Rfu.unk_0c == 1)
+ case LMAN_MSG_LINK_LOSS_DETECTED_AND_DISCONNECTED:
+ Rfu.linkLossRecoveryState = 2;
+ case LMAN_MSG_LINK_RECOVERY_FAILED_AND_DISCONNECTED:
+ if (Rfu.linkLossRecoveryState != 2)
+ Rfu.linkLossRecoveryState = 4;
+ if (Rfu.parentChild == MODE_PARENT)
{
if (gReceivedRemoteLinkPlayers == 1)
{
Rfu.unk_ce2 &= ~(lman.param[0]);
if (Rfu.unk_ce2 == 0)
- sub_8011170(a0);
+ GetLinkmanErrorParams(msg);
else
sub_80111FC();
}
}
else if (Rfu.unk_ce4 != 2 && gReceivedRemoteLinkPlayers == 1)
{
- sub_8011170(a0);
+ GetLinkmanErrorParams(msg);
rfu_LMAN_stopManager(0);
}
- if (gRfuLinkStatus->parentChild == 0xFF && lman.pcswitch_flag == 0 && FuncIsActiveTask(sub_800EB44) == TRUE)
- Rfu.unk_04 = 0x11;
+ if (gRfuLinkStatus->parentChild == MODE_NEUTRAL && lman.pcswitch_flag == 0 && FuncIsActiveTask(Task_LinkRfu_UnionRoomListen) == TRUE)
+ Rfu.state = 17;
- sub_8011A64(2, a0);
+ RfuSetStatus(RFU_STATUS_CONNECTION_ERROR, msg);
break;
- case 0x40:
+ case LMAN_MSG_LINK_DISCONNECTED_BY_USER:
Rfu.unk_ce3 = 0;
break;
- case 0x42 ... 0x44:
+ case LMAN_MSG_RFU_POWER_DOWN:
+ case LMAN_MSG_MANAGER_STOPPED:
+ case LMAN_MSG_MANAGER_FORCED_STOPPED_AND_RFU_RESET:
break;
- case 0xF3:
- sub_8011A64(1, a0);
- sub_8011170(a0);
- Rfu.unk_ef = 1;
+ case LMAN_MSG_LMAN_API_ERROR_RETURN:
+ RfuSetStatus(RFU_STATUS_FATAL_ERROR, msg);
+ GetLinkmanErrorParams(msg);
+ Rfu.isShuttingDown = TRUE;
break;
- case 0xF0 ... 0xF2:
- case 0xFF:
- sub_8011170(a0);
- sub_8011A64(1, a0);
- Rfu.unk_cdb = 0;
+ case LMAN_MSG_REQ_API_ERROR:
+ case LMAN_MSG_WATCH_DOG_TIMER_ERROR:
+ case LMAN_MSG_CLOCK_SLAVE_MS_CHANGE_ERROR_BY_DMA:
+ case LMAN_MSG_RFU_FATAL_ERROR:
+ GetLinkmanErrorParams(msg);
+ RfuSetStatus(RFU_STATUS_FATAL_ERROR, msg);
+ Rfu.unk_cdb = FALSE;
break;
}
}
@@ -2350,21 +2434,22 @@ void sub_8011A50(void)
Rfu.unk_ce4 = 2;
}
-void sub_8011A64(u8 a0, u16 a1)
+void RfuSetStatus(u8 status, u16 msg)
{
- Rfu.unk_f1 = a0;
- Rfu.unk_0a = a1;
+ Rfu.status = status;
+ Rfu.linkmanMsg = msg;
}
-u8 sub_8011A74(void)
+u8 RfuGetStatus(void)
{
- return Rfu.unk_f1;
+ return Rfu.status;
}
-bool32 sub_8011A80(void)
+bool32 RfuHasErrored(void)
{
- u32 var = sub_8011A74() - 1;
- if (var < 2)
+ // RFU_STATUS_OK will underflow here intentionally
+ u32 var = RfuGetStatus() - 1;
+ if (var < RFU_STATUS_CONNECTION_ERROR)
return TRUE;
else
return FALSE;
@@ -2377,7 +2462,7 @@ bool32 sub_8011A9C(void)
bool8 Rfu_IsMaster(void)
{
- return Rfu.unk_0c;
+ return Rfu.parentChild;
}
void RfuVSync(void)
@@ -2390,14 +2475,14 @@ void sub_8011AC8(void)
CpuFill32(0, gRecvCmds, sizeof(gRecvCmds));
}
-void sub_8011AE8(void)
+static void sub_8011AE8(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
-void sub_8011AFC(void)
+static void sub_8011AFC(void)
{
s32 i;
@@ -2408,8 +2493,8 @@ void sub_8011AFC(void)
SetVBlankCallback(sub_8011AE8);
if (IsWirelessAdapterConnected())
{
- gLinkType = LINKTYPE_0x1111;
- sub_800B488();
+ gLinkType = LINKTYPE_TRADE;
+ SetWirelessCommType1();
OpenLink();
SeedRng(gMain.vblankCounter2);
for (i = 0; i < 4; i++)
@@ -2420,29 +2505,29 @@ void sub_8011AFC(void)
AnimateSprites();
BuildOamBuffer();
UpdatePaletteFade();
- sub_8011BA4();
+ CreateTask_RfuIdle();
SetMainCallback2(sub_8011BF8);
}
}
-bool32 sub_8011B90(void)
+bool32 IsUnionRoomListenTaskActive(void)
{
- return FuncIsActiveTask(sub_800EB44);
+ return FuncIsActiveTask(Task_LinkRfu_UnionRoomListen);
}
-void sub_8011BA4(void)
+void CreateTask_RfuIdle(void)
{
- if (!FuncIsActiveTask(nullsub_89))
- Rfu.unk_66 = CreateTask(nullsub_89, 0);
+ if (!FuncIsActiveTask(Task_Idle))
+ Rfu.idleTaskId = CreateTask(Task_Idle, 0);
}
-void sub_8011BD0(void)
+void DestroyTask_RfuIdle(void)
{
- if (FuncIsActiveTask(nullsub_89) == TRUE)
- DestroyTask(Rfu.unk_66);
+ if (FuncIsActiveTask(Task_Idle) == TRUE)
+ DestroyTask(Rfu.idleTaskId);
}
-void sub_8011BF8(void)
+static void sub_8011BF8(void)
{
RunTasks();
AnimateSprites();
@@ -2450,77 +2535,77 @@ void sub_8011BF8(void)
UpdatePaletteFade();
}
-void sub_8011C10(u32 a0)
+void InitializeRfuLinkManager_LinkLeader(u32 a0)
{
- Rfu.unk_0c = 1;
- sub_8010F48();
+ Rfu.parentChild = MODE_PARENT;
+ CopyPlayerNameToUnameBuffer();
rfu_LMAN_initializeManager(sub_801120C, NULL);
- gUnknown_02022B2C = gUnknown_082ED608;
- gUnknown_02022B2C.availSlot_flag = gUnknown_082ED620[a0 - 1];
- sub_800EE78();
+ sRfuReqConfig = sRfuReqConfigTemplate;
+ sRfuReqConfig.availSlot_flag = sAvailSlots[a0 - 1];
+ CreateTask_LinkLeaderSearchForChildren();
}
-void sub_8011C5C(void)
+void InitializeRfuLinkManager_JoinGroup(void)
{
- Rfu.unk_0c = 0;
- sub_8010F48();
+ Rfu.parentChild = MODE_CHILD;
+ CopyPlayerNameToUnameBuffer();
rfu_LMAN_initializeManager(sub_8011404, sub_800ED34);
- sub_800EF00();
+ CreateTask_JoinGroupSearchForParent();
}
-void sub_8011C84(void)
+void InitializeRfuLinkManager_EnterUnionRoom(void)
{
- Rfu.unk_0c = 2;
- sub_8010F48();
+ Rfu.parentChild = 2;
+ CopyPlayerNameToUnameBuffer();
rfu_LMAN_initializeManager(sub_8011674, NULL);
- gUnknown_02022B2C = gUnknown_082ED608;
- gUnknown_02022B2C.linkRecovery_enable = 0;
- gUnknown_02022B2C.linkRecovery_period = 0x258;
- Rfu.unk_67 = CreateTask(sub_800EB44, 1);
+ sRfuReqConfig = sRfuReqConfigTemplate;
+ sRfuReqConfig.linkRecovery_enable = 0;
+ sRfuReqConfig.linkRecovery_period = 600;
+ Rfu.searchTaskId = CreateTask(Task_LinkRfu_UnionRoomListen, 1);
}
-u16 ReadU16(const void *ptr)
+static u16 ReadU16(const void *ptr)
{
const u8 *ptr_ = ptr;
return (ptr_[1] << 8) | (ptr_[0]);
}
-u8 sub_8011CE4(const u8 *a0, u16 a1)
+static u8 GetPartnerIndexByNameAndTrainerID(const u8 *name, u16 id)
{
u8 i;
- u8 ret = 0xFF;
+ u8 idx = 0xFF;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
u16 trainerId = ReadU16(gRfuLinkStatus->partner[i].gname + 2);
- if (sub_8010454(gRfuLinkStatus->partner[i].serialNo)
- && !StringCompare(a0, gRfuLinkStatus->partner[i].uname)
- && a1 == trainerId)
+ if (IsRfuSerialNumberValid(gRfuLinkStatus->partner[i].serialNo)
+ && !StringCompare(name, gRfuLinkStatus->partner[i].uname)
+ && id == trainerId)
{
- ret = i;
+ idx = i;
if (gRfuLinkStatus->partner[i].slot != 0xFF)
break;
}
}
- return ret;
+ return idx;
}
-void sub_8011D6C(u32 a0)
+static void RfuReqDisconnectSlot(u32 slot)
{
- rfu_REQ_disconnect(a0);
+ rfu_REQ_disconnect(slot);
rfu_waitREQComplete();
- Rfu.unk_ce2 &= ~(a0);
+ Rfu.unk_ce2 &= ~(slot);
rfu_clearSlot(1, Rfu.unk_cda);
- rfu_UNI_setSendData(Rfu.unk_ce2, Rfu.unk_c87, 70);
+ rfu_UNI_setSendData(Rfu.unk_ce2, Rfu.recvCmds, 70);
Rfu.unk_cda = sub_800E87C(Rfu.unk_ce2);
}
-void sub_8011DC0(const u8 *ptr, u16 a1)
+void RequestDisconnectSlotByTrainerNameAndId(const u8 *name, u16 id)
{
- u8 var = sub_8011CE4(ptr, a1);
+ u8 var = GetPartnerIndexByNameAndTrainerID(name, id);
if (var != 0xFF)
- sub_8011D6C(1 << var);
+ RfuReqDisconnectSlot(1 << var);
}
void sub_8011DE0(u32 a0)
@@ -2530,9 +2615,9 @@ void sub_8011DE0(u32 a0)
s32 i;
u8 var = 0;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- if (Rfu.unk_cde[i] == a0 && (Rfu.unk_ce2 >> i) & 1)
+ if (Rfu.linkPlayerIdx[i] == a0 && (Rfu.unk_ce2 >> i) & 1)
var |= 1 << i;
}
if (var)
@@ -2540,20 +2625,20 @@ void sub_8011DE0(u32 a0)
}
}
-void sub_8011E2C(u8 taskId)
+static void sub_8011E2C(u8 taskId)
{
if (gSendCmd[0] == 0 && Rfu.unk_ce8 == 0)
{
- sub_800FD14(0xED00);
+ RfuPrepareSendBuffer(RFU_COMMAND_0xED00);
gSendCmd[1] = gTasks[taskId].data[0];
gSendCmd[2] = gTasks[taskId].data[1];
- Rfu.playerCount -= gUnknown_082ED695[gTasks[taskId].data[0]];
+ Rfu.playerCount -= sUnknown_082ED695[gTasks[taskId].data[0]];
gSendCmd[3] = Rfu.playerCount;
DestroyTask(taskId);
}
}
-void sub_8011E94(u32 a0, u32 a1)
+static void sub_8011E94(u32 a0, u32 a1)
{
u8 taskId = FindTaskIdByFunc(sub_8011E2C);
if (taskId == 0xFF)
@@ -2569,28 +2654,29 @@ void sub_8011E94(u32 a0, u32 a1)
gTasks[taskId].data[1] = a1;
}
-void sub_8011EF4(u8 taskId)
+static void Task_RfuReconnectWithParent(u8 taskId)
{
s16 *data = gTasks[taskId].data;
if (sub_800EE94())
{
- u8 id = sub_8011CE4((u8*)data, ReadU16(&data[8]));
+ u8 id = GetPartnerIndexByNameAndTrainerID((u8*)data, ReadU16(&data[8]));
if (id != 0xFF)
{
if (gRfuLinkStatus->partner[id].slot != 0xFF)
{
Rfu.unk_c3d = id;
- if (sub_800EEBC())
+ if (IsParentSuccessfullyReconnected())
DestroyTask(taskId);
}
- else if (sub_800F7DC()->activity == 0x15 || sub_800F7DC()->activity == 0x16)
+ else if (GetHostRFUtgtGname()->activity == ACTIVITY_WONDER_CARD2
+ || GetHostRFUtgtGname()->activity == ACTIVITY_WONDER_NEWS2)
{
data[15]++;
}
else
{
- sub_8011A64(2, 0x7000);
+ RfuSetStatus(RFU_STATUS_CONNECTION_ERROR, 0x7000);
DestroyTask(taskId);
}
}
@@ -2607,47 +2693,47 @@ void sub_8011EF4(u8 taskId)
if (data[15] > 240)
{
- sub_8011A64(2, 0x7000);
+ RfuSetStatus(RFU_STATUS_CONNECTION_ERROR, 0x7000);
DestroyTask(taskId);
}
}
-void sub_8011FC8(const u8 *src, u16 trainerId)
+void CreateTask_RfuReconnectWithParent(const u8 *name, u16 trainerId)
{
u8 taskId;
s16 *data;
- Rfu.unk_f1 = 0;
- taskId = CreateTask(sub_8011EF4, 3);
+ Rfu.status = RFU_STATUS_OK;
+ taskId = CreateTask(Task_RfuReconnectWithParent, 3);
data = gTasks[taskId].data;
- StringCopy((u8*)(data), src);
+ StringCopy((u8*)(data), name);
data[8] = trainerId;
}
-bool32 sub_801200C(s16 a1, struct GFtgtGname *structPtr)
+static bool32 ShouldRejectPartnerConnectionBasedOnActivity(s16 activity, struct GFtgtGname *partnerGname)
{
- if (sub_800F7DC()->activity == 0x45)
+ if (GetHostRFUtgtGname()->activity == (ACTIVITY_CHAT | IN_UNION_ROOM))
{
- if (structPtr->activity != 0x45)
+ if (partnerGname->activity != (ACTIVITY_CHAT | IN_UNION_ROOM))
return TRUE;
}
- else if (structPtr->activity != 0x40)
+ else if (partnerGname->activity != IN_UNION_ROOM)
{
return TRUE;
}
- else if (a1 == 0x44)
+ else if (activity == (ACTIVITY_TRADE | IN_UNION_ROOM))
{
- struct GFtgtGname *structPtr2 = &Rfu.unk_10A;
- if (structPtr2->species == SPECIES_EGG)
+ struct GFtgtGname *tradeGname = &Rfu.unk_10A;
+ if (tradeGname->species == SPECIES_EGG)
{
- if (structPtr->species == structPtr2->species)
+ if (partnerGname->species == tradeGname->species)
return FALSE;
else
return TRUE;
}
- else if (structPtr->species != structPtr2->species
- || structPtr->level != structPtr2->level
- || structPtr->type != structPtr2->type)
+ else if (partnerGname->species != tradeGname->species
+ || partnerGname->level != tradeGname->level
+ || partnerGname->type != tradeGname->type)
{
return TRUE;
}
@@ -2656,53 +2742,53 @@ bool32 sub_801200C(s16 a1, struct GFtgtGname *structPtr)
return FALSE;
}
-void sub_801209C(u8 taskId)
+static void sub_801209C(u8 taskId)
{
- if (Rfu.unk_f1 == 4)
+ if (Rfu.status == RFU_STATUS_NEW_CHILD_DETECTED)
DestroyTask(taskId);
if (++gTasks[taskId].data[0] > 300)
{
- sub_8011A64(2, 0x7000);
+ RfuSetStatus(RFU_STATUS_CONNECTION_ERROR, 0x7000);
DestroyTask(taskId);
}
- if (Rfu.unk_ccd != 0 && lman.parent_child == 0)
+ if (Rfu.parentId != 0 && lman.parent_child == 0)
{
u16 trainerId = ReadU16(Rfu.unk_10A.unk_00.playerTrainerId);
- u8 id = sub_8011CE4(Rfu.playerName, trainerId);
+ u8 id = GetPartnerIndexByNameAndTrainerID(Rfu.playerName, trainerId);
if (id != 0xFF)
{
- if (!sub_801200C(gTasks[taskId].data[1], (void *)gRfuLinkStatus->partner[id].gname))
+ if (!ShouldRejectPartnerConnectionBasedOnActivity(gTasks[taskId].data[1], (void *)gRfuLinkStatus->partner[id].gname))
{
if (gRfuLinkStatus->partner[id].slot != 0xFF && !rfu_LMAN_CHILD_connectParent(gRfuLinkStatus->partner[id].id, 0x5A))
{
- Rfu.unk_04 = 0xA;
+ Rfu.state = 0xA;
DestroyTask(taskId);
}
}
else
{
- sub_8011A64(2, 0x7000);
+ RfuSetStatus(RFU_STATUS_CONNECTION_ERROR, 0x7000);
DestroyTask(taskId);
}
}
}
}
-void sub_8012188(const u8 *name, struct GFtgtGname *structPtr, u8 a2)
+void sub_8012188(const u8 *name, struct GFtgtGname *structPtr, u8 activity)
{
u8 taskId, taskId2;
Rfu.unk_ccf = 0;
- Rfu.unk_f1 = 0;
+ Rfu.status = RFU_STATUS_OK;
StringCopy(Rfu.playerName, name);
- memcpy(&Rfu.unk_10A, structPtr, 0xD);
+ memcpy(&Rfu.unk_10A, structPtr, RFU_GAME_NAME_LENGTH);
rfu_LMAN_forceChangeSP();
taskId = CreateTask(sub_801209C, 2);
- gTasks[taskId].data[1] = a2;
- taskId2 = FindTaskIdByFunc(sub_800EB44);
- if (a2 == 0x45)
+ gTasks[taskId].data[1] = activity;
+ taskId2 = FindTaskIdByFunc(Task_LinkRfu_UnionRoomListen);
+ if (activity == (ACTIVITY_CHAT | IN_UNION_ROOM))
{
if (taskId2 != 0xFF)
gTasks[taskId2].data[7] = 1;
@@ -2714,9 +2800,9 @@ void sub_8012188(const u8 *name, struct GFtgtGname *structPtr, u8 a2)
}
}
-bool8 sub_8012224(void)
+bool8 IsRfuRecoveringFromLinkLoss(void)
{
- if (Rfu.unk_f0 == 1)
+ if (Rfu.linkLossRecoveryState == 1)
return TRUE;
else
return FALSE;
@@ -2726,61 +2812,61 @@ bool32 sub_8012240(void)
{
s32 i;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- if ((lman.acceptSlot_flag >> i) & 1 && Rfu.unk_cd1[i] == 0)
+ if ((lman.acceptSlot_flag >> i) & 1 && Rfu.partnerSendStatuses[i] == RFU_STATUS_OK)
return FALSE;
}
return TRUE;
}
-void sub_801227C(void)
+static void Debug_PrintEmpty(void)
{
s32 i;
for (i = 0; i < 20; i++)
- nullsub_5(gUnknown_082ED82C, 0, i);
+ Debug_PrintString(sASCII_30Commas, 0, i);
}
-void sub_801229C(void)
+static void Debug_PrintStatus(void)
{
s32 i, j;
- nullsub_13(GetBlockReceivedStatus(), 0x1C, 0x13, 2);
- nullsub_13(gRfuLinkStatus->connSlotFlag, 0x14, 1, 1);
- nullsub_13(gRfuLinkStatus->linkLossSlotFlag, 0x17, 1, 1);
- if (Rfu.unk_0c == 1)
+ Debug_PrintNum(GetBlockReceivedStatus(), 0x1C, 0x13, 2);
+ Debug_PrintNum(gRfuLinkStatus->connSlotFlag, 0x14, 1, 1);
+ Debug_PrintNum(gRfuLinkStatus->linkLossSlotFlag, 0x17, 1, 1);
+ if (Rfu.parentChild == MODE_PARENT)
{
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
if ((gRfuLinkStatus->getNameFlag >> i) & 1)
{
- nullsub_13(gRfuLinkStatus->partner[i].serialNo, 1, i + 3, 4);
- nullsub_5((void*)gRfuLinkStatus->partner[i].gname, 6, i + 3);
- nullsub_5(gRfuLinkStatus->partner[i].uname, 0x16, i + 3);
+ Debug_PrintNum(gRfuLinkStatus->partner[i].serialNo, 1, i + 3, 4);
+ Debug_PrintString((void*)gRfuLinkStatus->partner[i].gname, 6, i + 3);
+ Debug_PrintString(gRfuLinkStatus->partner[i].uname, 0x16, i + 3);
}
}
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- for (j = 0; j < 14; j++)
+ for (j = 0; j < (int)ARRAY_COUNT(Rfu.unk_14[0]); j++)
{
- nullsub_13(Rfu.unk_14[i][j], j * 2, i + 11, 2);
+ Debug_PrintNum(Rfu.unk_14[i][j], j * 2, i + 11, 2);
}
}
- nullsub_5(gUnknown_082ED868, 1, 0xF);
+ Debug_PrintString(sASCII_NowSlot, 1, 0xF);
}
else if (gRfuLinkStatus->connSlotFlag != 0 && gRfuLinkStatus->getNameFlag != 0)
{
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- nullsub_13(0, 1, i + 3, 4);
- nullsub_5(gUnknown_082ED84B, 6, i + 3);
- nullsub_5(gUnknown_082ED85B, 0x16, i + 3);
+ Debug_PrintNum(0, 1, i + 3, 4);
+ Debug_PrintString(sASCII_15Commas, 6, i + 3);
+ Debug_PrintString(sASCII_8Commas, 0x16, i + 3);
}
- nullsub_13(gRfuLinkStatus->partner[Rfu.unk_c3e].serialNo, 1, 3, 4);
- nullsub_5((void*)gRfuLinkStatus->partner[Rfu.unk_c3e].gname, 6, 3);
- nullsub_5(gRfuLinkStatus->partner[Rfu.unk_c3e].uname, 0x16, 3);
+ Debug_PrintNum(gRfuLinkStatus->partner[Rfu.childSlot].serialNo, 1, 3, 4);
+ Debug_PrintString((void*)gRfuLinkStatus->partner[Rfu.childSlot].gname, 6, 3);
+ Debug_PrintString(gRfuLinkStatus->partner[Rfu.childSlot].uname, 0x16, 3);
}
else
{
@@ -2788,31 +2874,31 @@ void sub_801229C(void)
{
if (gRfuLinkStatus->partner[i].slot != 0xFF)
{
- nullsub_13(gRfuLinkStatus->partner[i].serialNo, 1, i + 3, 4);
- nullsub_13(gRfuLinkStatus->partner[i].id, 6, i + 3, 4);
- nullsub_5(gRfuLinkStatus->partner[i].uname, 0x16, i + 3);
+ Debug_PrintNum(gRfuLinkStatus->partner[i].serialNo, 1, i + 3, 4);
+ Debug_PrintNum(gRfuLinkStatus->partner[i].id, 6, i + 3, 4);
+ Debug_PrintString(gRfuLinkStatus->partner[i].uname, 0x16, i + 3);
}
}
- for (; i < 4; i++)
+ for (; i < RFU_CHILD_MAX; i++)
{
- nullsub_13(0, 1, i + 3, 4);
- nullsub_5(gUnknown_082ED84B, 6, i + 3);
- nullsub_5(gUnknown_082ED85B, 0x16, i + 3);
+ Debug_PrintNum(0, 1, i + 3, 4);
+ Debug_PrintString(sASCII_15Commas, 6, i + 3);
+ Debug_PrintString(sASCII_8Commas, 0x16, i + 3);
}
}
}
-u32 sub_80124C0(void)
+static u32 GetRfuSendQueueLength(void)
{
- return Rfu.unk_9e8.unk_232;
+ return Rfu.sendQueue.count;
}
u32 GetRfuRecvQueueLength(void)
{
- return Rfu.unk_124.unk_8c2;
+ return Rfu.recvQueue.count;
}
-void nullsub_89(u8 taskId)
+static void Task_Idle(u8 taskId)
{
}
diff --git a/src/link_rfu_3.c b/src/link_rfu_3.c
index 535deeca6..c53e1c59e 100644
--- a/src/link_rfu_3.c
+++ b/src/link_rfu_3.c
@@ -7,30 +7,112 @@
#include "text.h"
#include "event_data.h"
+enum {
+ WIRELESS_STATUS_ANIM_3_BARS,
+ WIRELESS_STATUS_ANIM_2_BARS,
+ WIRELESS_STATUS_ANIM_1_BAR,
+ WIRELESS_STATUS_ANIM_SEARCHING,
+ WIRELESS_STATUS_ANIM_ERROR,
+};
+
+#define UNUSED_QUEUE_NUM_SLOTS 2
+#define UNUSED_QUEUE_SLOT_LENGTH 256
+
+struct RfuUnusedQueue
+{
+ u8 slots[UNUSED_QUEUE_NUM_SLOTS][UNUSED_QUEUE_SLOT_LENGTH];
+ vu8 recvSlot;
+ vu8 sendSlot;
+ vu8 count;
+ vu8 full;
+};
+
EWRAM_DATA u8 gWirelessStatusIndicatorSpriteId = 0;
-static u8 gUnknown_03000D74;
+static u8 sUnknown_03000D74;
-const u16 gWirelessLinkIconPalette[] = INCBIN_U16("graphics/interface/wireless_link_icon.gbapal");
-const u32 gWirelessLinkIconPic[] = INCBIN_U32("graphics/interface/wireless_link_icon.4bpp.lz");
+static const u16 sWirelessLinkIconPalette[] = INCBIN_U16("graphics/interface/wireless_link_icon.gbapal");
+static const u32 sWirelessLinkIconPic[] = INCBIN_U32("graphics/interface/wireless_link_icon.4bpp.lz");
-const u8 sWireless_ASCIItoRSETable[] = {
- 0xff, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x37,
+// Most of the below two tables won't make sense with ASCII encoding.
+static const u8 sWireless_ASCIItoRSETable[256] = {
+ EOS,
+ 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x37,
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
- 0x00, 0xab, 0xb5, 0xb6, 0xb1, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xb2, 0xf1, 0x00, 0xae, 0xad, 0xba,
- 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8,
- 0xa9, 0xaa, 0x00, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
- 0x00, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1,
- 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9,
- 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1,
- 0xd2, 0xd3, 0xd4, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6,
- 0x00, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb,
- 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3,
- 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb,
- 0xec, 0xed, 0xee, 0x2d, 0x2f, 0x30, 0x31, 0x32,
+ [' '] = CHAR_SPACE,
+ ['!'] = CHAR_EXCL_MARK,
+ 0xb5, 0xb6, 0xb1, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xb2, 0xf1, 0x00,
+ ['-'] = CHAR_HYPHEN,
+ ['.'] = CHAR_PERIOD,
+ ['/'] = CHAR_SLASH,
+ ['0'] = CHAR_0,
+ ['1'] = CHAR_1,
+ ['2'] = CHAR_2,
+ ['3'] = CHAR_3,
+ ['4'] = CHAR_4,
+ ['5'] = CHAR_5,
+ ['6'] = CHAR_6,
+ ['7'] = CHAR_7,
+ ['8'] = CHAR_8,
+ ['9'] = CHAR_9,
+ 0x00, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0x00,
+ ['A'] = CHAR_A,
+ ['B'] = CHAR_B,
+ ['C'] = CHAR_C,
+ ['D'] = CHAR_D,
+ ['E'] = CHAR_E,
+ ['F'] = CHAR_F,
+ ['G'] = CHAR_G,
+ ['H'] = CHAR_H,
+ ['I'] = CHAR_I,
+ ['J'] = CHAR_J,
+ ['K'] = CHAR_K,
+ ['L'] = CHAR_L,
+ ['M'] = CHAR_M,
+ ['N'] = CHAR_N,
+ ['O'] = CHAR_O,
+ ['P'] = CHAR_P,
+ ['Q'] = CHAR_Q,
+ ['R'] = CHAR_R,
+ ['S'] = CHAR_S,
+ ['T'] = CHAR_T,
+ ['U'] = CHAR_U,
+ ['V'] = CHAR_V,
+ ['W'] = CHAR_W,
+ ['X'] = CHAR_X,
+ ['Y'] = CHAR_Y,
+ ['Z'] = CHAR_Z,
+ 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0x00,
+ ['a'] = CHAR_a,
+ ['b'] = CHAR_b,
+ ['c'] = CHAR_c,
+ ['d'] = CHAR_d,
+ ['e'] = CHAR_e,
+ ['f'] = CHAR_f,
+ ['g'] = CHAR_g,
+ ['h'] = CHAR_h,
+ ['i'] = CHAR_i,
+ ['j'] = CHAR_j,
+ ['k'] = CHAR_k,
+ ['l'] = CHAR_l,
+ ['m'] = CHAR_m,
+ ['n'] = CHAR_n,
+ ['o'] = CHAR_o,
+ ['p'] = CHAR_p,
+ ['q'] = CHAR_q,
+ ['r'] = CHAR_r,
+ ['s'] = CHAR_s,
+ ['t'] = CHAR_t,
+ ['u'] = CHAR_u,
+ ['v'] = CHAR_v,
+ ['w'] = CHAR_w,
+ ['x'] = CHAR_x,
+ ['y'] = CHAR_y,
+ ['z'] = CHAR_z,
+ 0x2d, 0x2f, 0x30, 0x31, 0x32,
0x33, 0x34, 0x35, 0x36, 0x50, 0x00, 0x01, 0x02,
0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12,
@@ -49,42 +131,107 @@ const u8 sWireless_ASCIItoRSETable[] = {
0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94
};
-const u8 sWireless_RSEtoASCIITable[] = {
- 0x20, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c,
- 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94,
- 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c,
- 0x9d, 0x9e, 0x9f, 0xa0, 0xe0, 0xe1, 0xe2, 0xe3,
- 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb,
- 0xec, 0xed, 0xee, 0xef, 0xf0, 0x7b, 0xf1, 0x7c,
- 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
- 0x84, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
- 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
- 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
- 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
- 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
- 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xa6, 0xdd, 0xa7,
- 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xf2,
- 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa,
- 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0x01, 0x02, 0x03,
- 0x04, 0x05, 0x06, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
- 0xaf, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,
- 0x37, 0x38, 0x39, 0x21, 0xdf, 0xa1, 0xb0, 0xa5,
- 0xde, 0x24, 0x2a, 0xa2, 0xa3, 0x22, 0x23, 0x20,
- 0xa4, 0x20, 0x2f, 0x41, 0x42, 0x43, 0x44, 0x45,
- 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d,
- 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55,
- 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63,
- 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
- 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73,
- 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x20,
- 0x20, 0x2b, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00
+static const u8 sWireless_RSEtoASCIITable[256] = {
+ [CHAR_SPACE] = ' ',
+ 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d,
+ 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95,
+ 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d,
+ 0x9e, 0x9f, 0xa0, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4,
+ 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec,
+ 0xed, 0xee, 0xef, 0xf0, 0x7b, 0xf1, 0x7c, 0x7d,
+ 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x07, 0x08,
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+ 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
+ 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x84,
+ 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8,
+ 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0,
+ 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8,
+ 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0,
+ 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
+ 0xd9, 0xda, 0xdb, 0xdc, 0xa6, 0xdd, 0xa7, 0xa8,
+ 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xf2, 0xf3,
+ 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb,
+ 0xfc, 0xfd, 0xfe, 0xff, 0x01, 0x02, 0x03, 0x04,
+ 0x05, 0x06, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0xaf,
+ [CHAR_0] = '0',
+ [CHAR_1] = '1',
+ [CHAR_2] = '2',
+ [CHAR_3] = '3',
+ [CHAR_4] = '4',
+ [CHAR_5] = '5',
+ [CHAR_6] = '6',
+ [CHAR_7] = '7',
+ [CHAR_8] = '8',
+ [CHAR_9] = '9',
+ [CHAR_EXCL_MARK] = '!',
+ 0xdf, 0xa1, 0xb0, 0xa5, 0xde, 0x24, 0x2a,
+ 0xa2, 0xa3, 0x22, 0x23, 0x20, 0xa4, 0x20,
+ [CHAR_SLASH] = '/',
+ [CHAR_A] = 'A',
+ [CHAR_B] = 'B',
+ [CHAR_C] = 'C',
+ [CHAR_D] = 'D',
+ [CHAR_E] = 'E',
+ [CHAR_F] = 'F',
+ [CHAR_G] = 'G',
+ [CHAR_H] = 'H',
+ [CHAR_I] = 'I',
+ [CHAR_J] = 'J',
+ [CHAR_K] = 'K',
+ [CHAR_L] = 'L',
+ [CHAR_M] = 'M',
+ [CHAR_N] = 'N',
+ [CHAR_O] = 'O',
+ [CHAR_P] = 'P',
+ [CHAR_Q] = 'Q',
+ [CHAR_R] = 'R',
+ [CHAR_S] = 'S',
+ [CHAR_T] = 'T',
+ [CHAR_U] = 'U',
+ [CHAR_V] = 'V',
+ [CHAR_W] = 'W',
+ [CHAR_X] = 'X',
+ [CHAR_Y] = 'Y',
+ [CHAR_Z] = 'Z',
+ [CHAR_a] = 'a',
+ [CHAR_b] = 'b',
+ [CHAR_c] = 'c',
+ [CHAR_d] = 'd',
+ [CHAR_e] = 'e',
+ [CHAR_f] = 'f',
+ [CHAR_g] = 'g',
+ [CHAR_h] = 'h',
+ [CHAR_i] = 'i',
+ [CHAR_j] = 'j',
+ [CHAR_k] = 'k',
+ [CHAR_l] = 'l',
+ [CHAR_m] = 'm',
+ [CHAR_n] = 'n',
+ [CHAR_o] = 'o',
+ [CHAR_p] = 'p',
+ [CHAR_q] = 'q',
+ [CHAR_r] = 'r',
+ [CHAR_s] = 's',
+ [CHAR_t] = 't',
+ [CHAR_u] = 'u',
+ [CHAR_v] = 'v',
+ [CHAR_w] = 'w',
+ [CHAR_x] = 'x',
+ [CHAR_y] = 'y',
+ [CHAR_z] = 'z',
+ 0x20, 0x20, 0x2b, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+ [CHAR_SPECIAL_F7] = ' ',
+ [CHAR_SPECIAL_F8] = ' ',
+ [CHAR_SPECIAL_F9] = ' ',
+ [CHAR_PROMPT_SCROLL] = ' ',
+ [CHAR_PROMPT_CLEAR] = ' ',
+ [EXT_CTRL_CODE_BEGIN] = ' ',
+ [PLACEHOLDER_BEGIN] = ' ',
+ [CHAR_NEWLINE] = ' ',
+ [EOS] = 0
};
-const struct OamData sWirelessStatusIndicatorOamData =
+static const struct OamData sWirelessStatusIndicatorOamData =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
@@ -98,8 +245,7 @@ const struct OamData sWirelessStatusIndicatorOamData =
.paletteNum = 0,
};
-const union AnimCmd sWirelessStatusIndicatorAnim0[] = {
- // 3 bars
+static const union AnimCmd sWirelessStatusIndicator_3Bars[] = {
ANIMCMD_FRAME( 4, 5),
ANIMCMD_FRAME( 8, 5),
ANIMCMD_FRAME(12, 5),
@@ -109,8 +255,7 @@ const union AnimCmd sWirelessStatusIndicatorAnim0[] = {
ANIMCMD_JUMP(0)
};
-const union AnimCmd sWirelessStatusIndicatorAnim1[] = {
- // 2 bars
+static const union AnimCmd sWirelessStatusIndicator_2Bars[] = {
ANIMCMD_FRAME( 4, 5),
ANIMCMD_FRAME( 8, 5),
ANIMCMD_FRAME(12, 10),
@@ -118,321 +263,299 @@ const union AnimCmd sWirelessStatusIndicatorAnim1[] = {
ANIMCMD_JUMP(0)
};
-const union AnimCmd sWirelessStatusIndicatorAnim2[] = {
- // 1 bar
+static const union AnimCmd sWirelessStatusIndicator_1Bar[] = {
ANIMCMD_FRAME(4, 5),
ANIMCMD_FRAME(8, 5),
ANIMCMD_JUMP(0)
};
-const union AnimCmd sWirelessStatusIndicatorAnim3[] = {
- // searching
+static const union AnimCmd sWirelessStatusIndicator_Searching[] = {
ANIMCMD_FRAME( 4, 10),
ANIMCMD_FRAME(20, 10),
ANIMCMD_JUMP(0)
};
-const union AnimCmd sWirelessStatusIndicatorAnim4[] = {
- // error
+static const union AnimCmd sWirelessStatusIndicator_Error[] = {
ANIMCMD_FRAME(24, 10),
ANIMCMD_FRAME( 4, 10),
ANIMCMD_JUMP(0)
};
-const union AnimCmd *const sWirelessStatusIndicatorAnims[] = {
- sWirelessStatusIndicatorAnim0,
- sWirelessStatusIndicatorAnim1,
- sWirelessStatusIndicatorAnim2,
- sWirelessStatusIndicatorAnim3,
- sWirelessStatusIndicatorAnim4
+static const union AnimCmd *const sWirelessStatusIndicatorAnims[] = {
+ [WIRELESS_STATUS_ANIM_3_BARS] = sWirelessStatusIndicator_3Bars,
+ [WIRELESS_STATUS_ANIM_2_BARS] = sWirelessStatusIndicator_2Bars,
+ [WIRELESS_STATUS_ANIM_1_BAR] = sWirelessStatusIndicator_1Bar,
+ [WIRELESS_STATUS_ANIM_SEARCHING] = sWirelessStatusIndicator_Searching,
+ [WIRELESS_STATUS_ANIM_ERROR] = sWirelessStatusIndicator_Error
};
-const struct CompressedSpriteSheet sWirelessStatusIndicatorSpriteSheet = {
- gWirelessLinkIconPic, 0x0380, 0xD431
+static const struct CompressedSpriteSheet sWirelessStatusIndicatorSpriteSheet = {
+ sWirelessLinkIconPic, 0x0380, 0xD431
};
-const struct SpritePalette sWirelessStatusIndicatorSpritePalette = {
- gWirelessLinkIconPalette, 0xD432
+static const struct SpritePalette sWirelessStatusIndicatorSpritePalette = {
+ sWirelessLinkIconPalette, 0xD432
};
-const struct SpriteTemplate sWirelessStatusIndicatorSpriteTemplate = {
- 0xD431,
- 0xD432,
- &sWirelessStatusIndicatorOamData,
- sWirelessStatusIndicatorAnims,
- NULL,
- gDummySpriteAffineAnimTable,
- SpriteCallbackDummy
+static const struct SpriteTemplate sWirelessStatusIndicatorSpriteTemplate = {
+ .tileTag = 0xD431,
+ .paletteTag = 0xD432,
+ .oam = &sWirelessStatusIndicatorOamData,
+ .anims = sWirelessStatusIndicatorAnims,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = SpriteCallbackDummy
};
-void sub_800D6C8(struct UnkRfuStruct_2_Sub_124 *ptr)
+void RfuRecvQueue_Reset(struct RfuRecvQueue *queue)
{
s32 i;
s32 j;
- for (i = 0; i < 32; i++)
+ for (i = 0; i < RECV_QUEUE_NUM_SLOTS; i++)
{
- for (j = 0; j < 70; j++)
+ for (j = 0; j < RECV_QUEUE_SLOT_LENGTH; j++)
{
- ptr->unk_00[i][j] = 0;
+ queue->slots[i][j] = 0;
}
}
- ptr->unk_8c1 = 0;
- ptr->unk_8c0 = 0;
- ptr->unk_8c2 = 0;
- ptr->unk_8c3 = 0;
+ queue->sendSlot = 0;
+ queue->recvSlot = 0;
+ queue->count = 0;
+ queue->full = FALSE;
}
-void sub_800D724(struct UnkRfuStruct_2_Sub_9e8 *ptr)
+void RfuSendQueue_Reset(struct RfuSendQueue *queue)
{
s32 i;
s32 j;
- for (i = 0; i < 40; i++)
+ for (i = 0; i < SEND_QUEUE_NUM_SLOTS; i++)
{
- for (j = 0; j < 14; j++)
+ for (j = 0; j < SEND_QUEUE_SLOT_LENGTH; j++)
{
- ptr->unk_00[i][j] = 0;
+ queue->slots[i][j] = 0;
}
}
- ptr->unk_231 = 0;
- ptr->unk_230 = 0;
- ptr->unk_232 = 0;
- ptr->unk_233 = 0;
+ queue->sendSlot = 0;
+ queue->recvSlot = 0;
+ queue->count = 0;
+ queue->full = FALSE;
}
-void sub_800D780(struct UnkRfuStruct_Sub_Unused *ptr)
+static void RfuUnusedQueue_Reset(struct RfuUnusedQueue *queue)
{
s32 i;
s32 j;
- for (i = 0; i < 2; i++)
+ for (i = 0; i < UNUSED_QUEUE_NUM_SLOTS; i++)
{
- for (j = 0; j < 256; j++)
+ for (j = 0; j < UNUSED_QUEUE_SLOT_LENGTH; j++)
{
- ptr->unk_00[i][j] = 0;
+ queue->slots[i][j] = 0;
}
}
- ptr->unk_201 = 0;
- ptr->unk_200 = 0;
- ptr->unk_202 = 0;
- ptr->unk_203 = 0;
+ queue->sendSlot = 0;
+ queue->recvSlot = 0;
+ queue->count = 0;
+ queue->full = FALSE;
}
-void sub_800D7D8(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2)
+void RfuRecvQueue_Enqueue(struct RfuRecvQueue *queue, u8 *data)
{
s32 i;
u16 imeBak;
u8 count;
- if (q1->unk_8c2 < 32)
+ if (queue->count < RECV_QUEUE_NUM_SLOTS)
{
imeBak = REG_IME;
REG_IME = 0;
count = 0;
- for (i = 0; i < 70; i += 14)
+ for (i = 0; i < RECV_QUEUE_SLOT_LENGTH; i += RECV_QUEUE_SLOT_LENGTH / MAX_RFU_PLAYERS)
{
- if (q2[i] == 0 && q2[i + 1] == 0)
- {
+ if (data[i] == 0 && data[i + 1] == 0)
count++;
- }
}
- if (count != 5)
+ if (count != MAX_RFU_PLAYERS)
{
- for (i = 0; i < 70; i++)
- {
- q1->unk_00[q1->unk_8c0][i] = q2[i];
- }
- q1->unk_8c0++;
- q1->unk_8c0 %= 32;
- q1->unk_8c2++;
- for (i = 0; i < 70; i++)
- {
- q2[i] = 0;
- }
+ for (i = 0; i < RECV_QUEUE_SLOT_LENGTH; i++)
+ queue->slots[queue->recvSlot][i] = data[i];
+
+ queue->recvSlot++;
+ queue->recvSlot %= RECV_QUEUE_NUM_SLOTS;
+ queue->count++;
+
+ for (i = 0; i < RECV_QUEUE_SLOT_LENGTH; i++)
+ data[i] = 0;
}
REG_IME = imeBak;
}
else
{
- q1->unk_8c3 = 1;
+ queue->full = TRUE;
}
}
-void sub_800D888(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2)
+void RfuSendQueue_Enqueue(struct RfuSendQueue *queue, u8 *data)
{
s32 i;
u16 imeBak;
- if (q1->unk_232 < 40)
+ if (queue->count < SEND_QUEUE_NUM_SLOTS)
{
imeBak = REG_IME;
REG_IME = 0;
- for (i = 0; i < 14; i++)
+ for (i = 0; i < SEND_QUEUE_SLOT_LENGTH; i++)
{
- if (q2[i] != 0)
- {
+ if (data[i] != 0)
break;
- }
}
- if (i != 14)
+ if (i != SEND_QUEUE_SLOT_LENGTH)
{
- for (i = 0; i < 14; i++)
- {
- q1->unk_00[q1->unk_230][i] = q2[i];
- }
- q1->unk_230++;
- q1->unk_230 %= 40;
- q1->unk_232++;
- for (i = 0; i < 14; i++)
+ for (i = 0; i < SEND_QUEUE_SLOT_LENGTH; i++)
{
- q2[i] = 0;
+ queue->slots[queue->recvSlot][i] = data[i];
}
+ queue->recvSlot++;
+ queue->recvSlot %= SEND_QUEUE_NUM_SLOTS;
+ queue->count++;
+
+ for (i = 0; i < SEND_QUEUE_SLOT_LENGTH; i++)
+ data[i] = 0;
}
REG_IME = imeBak;
}
else
{
- q1->unk_233 = 1;
+ queue->full = TRUE;
}
}
-bool8 sub_800D934(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2)
+bool8 RfuRecvQueue_Dequeue(struct RfuRecvQueue *queue, u8 *src)
{
u16 imeBak;
s32 i;
imeBak = REG_IME;
REG_IME = 0;
- if (q1->unk_8c0 == q1->unk_8c1 || q1->unk_8c3 != 0)
+ if (queue->recvSlot == queue->sendSlot || queue->full)
{
- for (i = 0; i < 70; i++)
- {
- q2[i] = 0;
- }
+ for (i = 0; i < RECV_QUEUE_SLOT_LENGTH; i++)
+ src[i] = 0;
+
REG_IME = imeBak;
return FALSE;
}
- for (i = 0; i < 70; i++)
+ for (i = 0; i < RECV_QUEUE_SLOT_LENGTH; i++)
{
- q2[i] = q1->unk_00[q1->unk_8c1][i];
+ src[i] = queue->slots[queue->sendSlot][i];
}
- q1->unk_8c1++;
- q1->unk_8c1 %= 32;
- q1->unk_8c2--;
+ queue->sendSlot++;
+ queue->sendSlot %= RECV_QUEUE_NUM_SLOTS;
+ queue->count--;
REG_IME = imeBak;
return TRUE;
}
-bool8 sub_800D9DC(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2)
+bool8 RfuSendQueue_Dequeue(struct RfuSendQueue *queue, u8 *src)
{
s32 i;
u16 imeBak;
- if (q1->unk_230 == q1->unk_231 || q1->unk_233 != 0)
- {
+ if (queue->recvSlot == queue->sendSlot || queue->full)
return FALSE;
- }
+
imeBak = REG_IME;
REG_IME = 0;
- for (i = 0; i < 14; i++)
- {
- q2[i] = q1->unk_00[q1->unk_231][i];
- }
- q1->unk_231++;
- q1->unk_231 %= 40;
- q1->unk_232--;
+ for (i = 0; i < SEND_QUEUE_SLOT_LENGTH; i++)
+ src[i] = queue->slots[queue->sendSlot][i];
+
+ queue->sendSlot++;
+ queue->sendSlot %= SEND_QUEUE_NUM_SLOTS;
+ queue->count--;
REG_IME = imeBak;
return TRUE;
}
-void sub_800DA68(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2)
+void RfuBackupQueue_Enqueue(struct RfuBackupQueue *queue, const u8 *data)
{
s32 i;
- if (q2[1] == 0)
+ if (data[1] == 0)
{
- sub_800DAC8(q1, NULL);
+ RfuBackupQueue_Dequeue(queue, NULL);
}
else
{
- for (i = 0; i < 14; i++)
- {
- q1->unk_00[q1->unk_1c][i] = q2[i];
- }
- q1->unk_1c++;
- q1->unk_1c %= 2;
- if (q1->unk_1e < 2)
- {
- q1->unk_1e++;
- }
+ for (i = 0; i < BACKUP_QUEUE_SLOT_LENGTH; i++)
+ queue->slots[queue->recvSlot][i] = data[i];
+
+ queue->recvSlot++;
+ queue->recvSlot %= BACKUP_QUEUE_NUM_SLOTS;
+
+ if (queue->count < BACKUP_QUEUE_NUM_SLOTS)
+ queue->count++;
else
- {
- q1->unk_1d = q1->unk_1c;
- }
+ queue->sendSlot = queue->recvSlot;
}
}
-bool8 sub_800DAC8(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2)
+bool8 RfuBackupQueue_Dequeue(struct RfuBackupQueue *queue, u8 *src)
{
s32 i;
- if (q1->unk_1e == 0)
- {
+ if (queue->count == 0)
return FALSE;
- }
- if (q2 != NULL)
+
+ if (src != NULL)
{
- for (i = 0; i < 14; i++)
- {
- q2[i] = q1->unk_00[q1->unk_1d][i];
- }
+ for (i = 0; i < BACKUP_QUEUE_SLOT_LENGTH; i++)
+ src[i] = queue->slots[queue->sendSlot][i];
}
- q1->unk_1d++;
- q1->unk_1d %= 2;
- q1->unk_1e--;
+ queue->sendSlot++;
+ queue->sendSlot %= BACKUP_QUEUE_NUM_SLOTS;
+ queue->count--;
return TRUE;
}
-void sub_800DB18(struct UnkRfuStruct_Sub_Unused *q1, u8 *q2)
+static void RfuUnusedQueue_Enqueue(struct RfuUnusedQueue *queue, u8 *data)
{
s32 i;
- if (q1->unk_202 < 2)
+ if (queue->count < UNUSED_QUEUE_NUM_SLOTS)
{
- for (i = 0; i < 256; i++)
- {
- q1->unk_00[q1->unk_200][i] = q2[i];
- }
- q1->unk_200++;
- q1->unk_200 %= 2;
- q1->unk_202++;
+ for (i = 0; i < UNUSED_QUEUE_SLOT_LENGTH; i++)
+ queue->slots[queue->recvSlot][i] = data[i];
+
+ queue->recvSlot++;
+ queue->recvSlot %= UNUSED_QUEUE_NUM_SLOTS;
+ queue->count++;
}
else
{
- q1->unk_203 = 1;
+ queue->full = TRUE;
}
}
-bool8 sub_800DB84(struct UnkRfuStruct_Sub_Unused *q1, u8 *q2)
+static bool8 RfuUnusedQueue_Dequeue(struct RfuUnusedQueue *queue, u8 *dest)
{
s32 i;
- if (q1->unk_200 == q1->unk_201 || q1->unk_203)
- {
+ if (queue->recvSlot == queue->sendSlot || queue->full)
return FALSE;
- }
- for (i = 0; i < 256; i++)
- {
- q2[i] = q1->unk_00[q1->unk_201][i];
- }
- q1->unk_201++;
- q1->unk_201 %= 2;
- q1->unk_202--;
+
+ for (i = 0; i < UNUSED_QUEUE_SLOT_LENGTH; i++)
+ dest[i] = queue->slots[queue->sendSlot][i];
+
+ queue->sendSlot++;
+ queue->sendSlot %= UNUSED_QUEUE_NUM_SLOTS;
+ queue->count--;
return TRUE;
}
-void sub_800DBF8(u8 *q1, u8 mode)
+// Unused
+static void sub_800DBF8(u8 *q1, u8 mode)
{
s32 i;
u8 rval;
@@ -467,47 +590,47 @@ void sub_800DBF8(u8 *q1, u8 mode)
case 3:
for (i = 0; i < 200; i++)
{
- q1[i] = i + 1 + gUnknown_03000D74;
- r5 += (i + 1 + gUnknown_03000D74) & 0xFF;
+ q1[i] = i + 1 + sUnknown_03000D74;
+ r5 += (i + 1 + sUnknown_03000D74) & 0xFF;
}
*((u16 *)(q1 + i)) = r5;
- gUnknown_03000D74++;
+ sUnknown_03000D74++;
break;
}
}
// File boundary here maybe?
-void PkmnStrToASCII(u8 *q1, const u8 *q2)
+static void PkmnStrToASCII(u8 *asciiStr, const u8 *pkmnStr)
{
s32 i;
- for (i = 0; q2[i] != EOS; i++)
+ for (i = 0; pkmnStr[i] != EOS; i++)
{
- q1[i] = sWireless_RSEtoASCIITable[q2[i]];
+ asciiStr[i] = sWireless_RSEtoASCIITable[pkmnStr[i]];
}
- q1[i] = 0;
+ asciiStr[i] = 0;
}
-void ASCIIToPkmnStr(u8 *q1, const u8 *q2)
+static void ASCIIToPkmnStr(u8 *pkmnStr, const u8 *asciiStr)
{
s32 i;
- for (i = 0; q2[i] != 0; i++)
+ for (i = 0; asciiStr[i] != 0; i++)
{
- q1[i] = sWireless_ASCIItoRSETable[q2[i]];
+ pkmnStr[i] = sWireless_ASCIItoRSETable[asciiStr[i]];
}
- q1[i] = EOS;
+ pkmnStr[i] = EOS;
}
#ifdef NONMATCHING
-u8 sub_800DD1C(u8 maxFlags)
+static u8 GetConnectedChildStrength(u8 maxFlags)
{
u8 flagCount = 0;
u32 flags = gRfuLinkStatus->connSlotFlag;
u8 i;
- if (gRfuLinkStatus->parentChild == 1)
+ if (gRfuLinkStatus->parentChild == MODE_PARENT)
{
for (i = 0; i < 4; flags >>= 1, i++)
{
@@ -530,7 +653,8 @@ u8 sub_800DD1C(u8 maxFlags)
return 0;
}
#else
-NAKED u8 sub_800DD1C(u8 maxFlags)
+NAKED
+static u8 GetConnectedChildStrength(u8 maxFlags)
{
asm_unified("\tpush {r4-r7,lr}\n"
"\tlsls r0, 24\n"
@@ -599,7 +723,7 @@ NAKED u8 sub_800DD1C(u8 maxFlags)
}
#endif
-void sub_800DD94(struct GFtgtGname *data, u8 r9, bool32 r2, s32 r3)
+void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 started, s32 child_sprite_genders)
{
s32 i;
@@ -607,82 +731,91 @@ void sub_800DD94(struct GFtgtGname *data, u8 r9, bool32 r2, s32 r3)
{
data->unk_00.playerTrainerId[i] = gSaveBlock2Ptr->playerTrainerId[i];
}
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- data->child_sprite_gender[i] = r3;
- r3 >>= 8;
+ data->child_sprite_gender[i] = child_sprite_genders;
+ child_sprite_genders >>= 8;
}
data->playerGender = gSaveBlock2Ptr->playerGender;
- data->activity = r9;
- data->started = r2;
+ data->activity = activity;
+ data->started = started;
data->unk_00.language = GAME_LANGUAGE;
data->unk_00.version = GAME_VERSION;
- data->unk_00.hasNews = 0;
- data->unk_00.hasCard = 0;
- data->unk_00.unk_00_6 = 0;
+ data->unk_00.hasNews = FALSE;
+ data->unk_00.hasCard = FALSE;
+ data->unk_00.unknown = FALSE;
data->unk_00.isChampion = FlagGet(FLAG_IS_CHAMPION);
data->unk_00.hasNationalDex = IsNationalPokedexEnabled();
data->unk_00.gameClear = FlagGet(FLAG_SYS_GAME_CLEAR);
}
-bool8 sub_800DE7C(struct GFtgtGname *buff1, u8 *buff2, u8 idx)
+bool8 LinkRfu_GetNameIfCompatible(struct GFtgtGname *buff1, u8 *buff2, u8 idx)
{
bool8 retVal;
- if (lman.parent_child == 1)
+ if (lman.parent_child == MODE_PARENT)
{
retVal = TRUE;
- if (sub_8010454(gRfuLinkStatus->partner[idx].serialNo) && ((gRfuLinkStatus->getNameFlag >> idx) & 1))
+ if (IsRfuSerialNumberValid(gRfuLinkStatus->partner[idx].serialNo) && ((gRfuLinkStatus->getNameFlag >> idx) & 1))
{
- memcpy(buff1, gRfuLinkStatus->partner[idx].gname, 0xD);
+ memcpy(buff1, gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
memcpy(buff2, gRfuLinkStatus->partner[idx].uname, PLAYER_NAME_LENGTH + 1);
}
else
{
- memset(buff1, 0, 0xD);
+ memset(buff1, 0, RFU_GAME_NAME_LENGTH);
memset(buff2, 0, PLAYER_NAME_LENGTH + 1);
}
}
else
{
retVal = FALSE;
- if (sub_8010454(gRfuLinkStatus->partner[idx].serialNo))
+ if (IsRfuSerialNumberValid(gRfuLinkStatus->partner[idx].serialNo))
{
- memcpy(buff1, gRfuLinkStatus->partner[idx].gname, 0xD);
+ memcpy(buff1, gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
memcpy(buff2, gRfuLinkStatus->partner[idx].uname, PLAYER_NAME_LENGTH + 1);
}
else
{
- memset(buff1, 0, 0xD);
+ memset(buff1, 0, RFU_GAME_NAME_LENGTH);
memset(buff2, 0, PLAYER_NAME_LENGTH + 1);
}
}
return retVal;
}
-bool8 sub_800DF34(struct GFtgtGname *buff1, u8 *buff2, u8 idx)
+bool8 LinkRfu_GetNameIfSerial7F7D(struct GFtgtGname *buff1, u8 *buff2, u8 idx)
{
bool8 retVal = FALSE;
- if (gRfuLinkStatus->partner[idx].serialNo == 0x7F7D)
+ if (gRfuLinkStatus->partner[idx].serialNo == RFU_SERIAL_7F7D)
{
- memcpy(buff1, gRfuLinkStatus->partner[idx].gname, 0xD);
- memcpy(buff2, gRfuLinkStatus->partner[idx].uname, 8);
+ memcpy(buff1, gRfuLinkStatus->partner[idx].gname, RFU_GAME_NAME_LENGTH);
+ memcpy(buff2, gRfuLinkStatus->partner[idx].uname, PLAYER_NAME_LENGTH + 1);
retVal = TRUE;
}
else
{
- memset(buff1, 0, 0xD);
- memset(buff2, 0, 8);
+ memset(buff1, 0, RFU_GAME_NAME_LENGTH);
+ memset(buff2, 0, PLAYER_NAME_LENGTH + 1);
}
return retVal;
}
-void sub_800DF90(struct GFtgtGname *buff1, u8 *buff2)
+void LinkRfu3_SetGnameUnameFromStaticBuffers(struct GFtgtGname *buff1, u8 *buff2)
{
- memcpy(buff1, &gUnknown_02022B14, 0xD);
- memcpy(buff2, gUnknown_02022B22, 8);
+ memcpy(buff1, &gHostRFUtgtGnameBuffer, RFU_GAME_NAME_LENGTH);
+ memcpy(buff2, gHostRFUtgtUnameBuffer, PLAYER_NAME_LENGTH + 1);
}
+#define sNextAnimNum data[0]
+#define sSavedAnimNum data[1]
+#define sCurrAnimNum data[2]
+#define sFrameDelay data[3]
+#define sFrameIdx data[4]
+#define sTileStart data[6]
+#define sValidator data[7]
+#define STATUS_INDICATOR_ACTIVE 0x1234 // Used to validate active indicator
+
void CreateWirelessStatusIndicatorSprite(u8 x, u8 y)
{
u8 sprId;
@@ -692,28 +825,28 @@ void CreateWirelessStatusIndicatorSprite(u8 x, u8 y)
x = 0xE7;
y = 0x08;
}
- if (gRfuLinkStatus->parentChild == 1)
+ if (gRfuLinkStatus->parentChild == MODE_PARENT)
{
sprId = CreateSprite(&sWirelessStatusIndicatorSpriteTemplate, x, y, 0);
- gSprites[sprId].data[7] = 0x1234;
- gSprites[sprId].data[6] = GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag);
+ gSprites[sprId].sValidator = STATUS_INDICATOR_ACTIVE;
+ gSprites[sprId].sTileStart = GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag);
gSprites[sprId].invisible = TRUE;
gWirelessStatusIndicatorSpriteId = sprId;
}
else
{
gWirelessStatusIndicatorSpriteId = CreateSprite(&sWirelessStatusIndicatorSpriteTemplate, x, y, 0);
- gSprites[gWirelessStatusIndicatorSpriteId].data[7] = 0x1234;
- gSprites[gWirelessStatusIndicatorSpriteId].data[6] = GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag);
+ gSprites[gWirelessStatusIndicatorSpriteId].sValidator = STATUS_INDICATOR_ACTIVE;
+ gSprites[gWirelessStatusIndicatorSpriteId].sTileStart = GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag);
gSprites[gWirelessStatusIndicatorSpriteId].invisible = TRUE;
}
}
void DestroyWirelessStatusIndicatorSprite(void)
{
- if (gSprites[gWirelessStatusIndicatorSpriteId].data[7] == 0x1234)
+ if (gSprites[gWirelessStatusIndicatorSpriteId].sValidator == STATUS_INDICATOR_ACTIVE)
{
- gSprites[gWirelessStatusIndicatorSpriteId].data[7] = 0;
+ gSprites[gWirelessStatusIndicatorSpriteId].sValidator = 0;
DestroySprite(&gSprites[gWirelessStatusIndicatorSpriteId]);
gMain.oamBuffer[125] = gDummyOamData;
CpuCopy16(&gDummyOamData, (struct OamData *)OAM + 125, sizeof(struct OamData));
@@ -730,11 +863,11 @@ void LoadWirelessStatusIndicatorSpriteGfx(void)
gWirelessStatusIndicatorSpriteId = 0xFF;
}
-u8 sub_800E124(void)
+static u8 GetParentSignalStrength(void)
{
u8 i;
u8 flags = gRfuLinkStatus->connSlotFlag;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
if (flags & 1)
{
@@ -745,104 +878,110 @@ u8 sub_800E124(void)
return 0;
}
-void sub_800E15C(struct Sprite *sprite, s32 signalStrengthAnimNum)
+static void SetWirelessStatusIndicatorAnim(struct Sprite *sprite, s32 animNum)
{
- if (sprite->data[2] != signalStrengthAnimNum)
+ if (sprite->sCurrAnimNum != animNum)
{
- sprite->data[2] = signalStrengthAnimNum;
- sprite->data[3] = 0;
- sprite->data[4] = 0;
+ sprite->sCurrAnimNum = animNum;
+ sprite->sFrameDelay = 0;
+ sprite->sFrameIdx = 0;
}
}
-void sub_800E174(void)
+void UpdateWirelessStatusIndicatorSprite(void)
{
- if (gWirelessStatusIndicatorSpriteId != 0xFF && gSprites[gWirelessStatusIndicatorSpriteId].data[7] == 0x1234)
+ if (gWirelessStatusIndicatorSpriteId != 0xFF && gSprites[gWirelessStatusIndicatorSpriteId].sValidator == STATUS_INDICATOR_ACTIVE)
{
struct Sprite *sprite = &gSprites[gWirelessStatusIndicatorSpriteId];
- u8 signalStrength = 255;
+ u8 signalStrength = RFU_LINK_ICON_LEVEL4_MAX;
u8 i = 0;
- if (gRfuLinkStatus->parentChild == 1)
+ if (gRfuLinkStatus->parentChild == MODE_PARENT)
{
for (i = 0; i < GetLinkPlayerCount() - 1; i++)
{
- if (signalStrength >= sub_800DD1C(i + 1))
+ if (signalStrength >= GetConnectedChildStrength(i + 1))
{
- signalStrength = sub_800DD1C(i + 1);
+ signalStrength = GetConnectedChildStrength(i + 1);
}
}
}
else
{
- signalStrength = sub_800E124();
+ signalStrength = GetParentSignalStrength();
}
- if (sub_8012224() == TRUE)
+ if (IsRfuRecoveringFromLinkLoss() == TRUE)
{
- sprite->data[0] = 4;
+ sprite->sNextAnimNum = WIRELESS_STATUS_ANIM_ERROR;
}
- else if (signalStrength < 25)
+ else if (signalStrength <= RFU_LINK_ICON_LEVEL1_MAX)
{
- sprite->data[0] = 3;
+ sprite->sNextAnimNum = WIRELESS_STATUS_ANIM_SEARCHING;
}
- else if (signalStrength >= 25 && signalStrength < 127)
+ else if (signalStrength >= RFU_LINK_ICON_LEVEL2_MIN && signalStrength <= RFU_LINK_ICON_LEVEL2_MAX)
{
- sprite->data[0] = 2;
+ sprite->sNextAnimNum = WIRELESS_STATUS_ANIM_1_BAR;
}
- else if (signalStrength >= 127 && signalStrength < 229)
+ else if (signalStrength >= RFU_LINK_ICON_LEVEL3_MIN && signalStrength <= RFU_LINK_ICON_LEVEL3_MAX)
{
- sprite->data[0] = 1;
+ sprite->sNextAnimNum = WIRELESS_STATUS_ANIM_2_BARS;
}
- else if (signalStrength >= 229)
+ else if (signalStrength >= RFU_LINK_ICON_LEVEL4_MIN)
{
- sprite->data[0] = 0;
+ sprite->sNextAnimNum = WIRELESS_STATUS_ANIM_3_BARS;
}
- if (sprite->data[0] != sprite->data[1])
+ if (sprite->sNextAnimNum != sprite->sSavedAnimNum)
{
- sub_800E15C(sprite, sprite->data[0]);
- sprite->data[1] = sprite->data[0];
+ SetWirelessStatusIndicatorAnim(sprite, sprite->sNextAnimNum);
+ sprite->sSavedAnimNum = sprite->sNextAnimNum;
}
- if (sprite->anims[sprite->data[2]][sprite->data[4]].frame.duration < sprite->data[3])
+ if (sprite->anims[sprite->sCurrAnimNum][sprite->sFrameIdx].frame.duration < sprite->sFrameDelay)
{
- sprite->data[4]++;
- sprite->data[3] = 0;
- if (sprite->anims[sprite->data[2]][sprite->data[4]].type == -2)
+ sprite->sFrameIdx++;
+ sprite->sFrameDelay = 0;
+ if (sprite->anims[sprite->sCurrAnimNum][sprite->sFrameIdx].type == -2)
{
- sprite->data[4] = 0;
+ sprite->sFrameIdx = 0;
}
}
else
{
- sprite->data[3]++;
+ sprite->sFrameDelay++;
}
gMain.oamBuffer[125] = sWirelessStatusIndicatorOamData;
gMain.oamBuffer[125].x = sprite->pos1.x + sprite->centerToCornerVecX;
gMain.oamBuffer[125].y = sprite->pos1.y + sprite->centerToCornerVecY;
gMain.oamBuffer[125].paletteNum = sprite->oam.paletteNum;
- gMain.oamBuffer[125].tileNum = sprite->data[6] + sprite->anims[sprite->data[2]][sprite->data[4]].frame.imageValue;
+ gMain.oamBuffer[125].tileNum = sprite->sTileStart + sprite->anims[sprite->sCurrAnimNum][sprite->sFrameIdx].frame.imageValue;
CpuCopy16(gMain.oamBuffer + 125, (struct OamData *)OAM + 125, sizeof(struct OamData));
- if (sub_8011A74() == 1)
+ if (RfuGetStatus() == RFU_STATUS_FATAL_ERROR)
{
DestroyWirelessStatusIndicatorSprite();
}
}
}
-void CopyTrainerRecord(struct TrainerNameRecord *dest, u32 trainerId, const u8 *name)
+#undef sNextAnimNum
+#undef sSavedAnimNum
+#undef sCurrAnimNum
+#undef sFrameDelay
+#undef sFrameIdx
+#undef sTileStart
+#undef sValidator
+
+static void CopyTrainerRecord(struct TrainerNameRecord *dest, u32 trainerId, const u8 *name)
{
dest->trainerId = trainerId;
StringCopy(dest->trainerName, name);
}
-bool32 NameIsNotEmpty(const u8 *name)
+static bool32 NameIsNotEmpty(const u8 *name)
{
s32 i;
for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++)
{
if (name[i] != 0)
- {
return TRUE;
- }
}
return FALSE;
}
@@ -856,13 +995,13 @@ void RecordMixTrainerNames(void)
s32 j;
s32 nextSpace;
s32 connectedTrainerRecordIndices[5];
- struct TrainerNameRecord *newRecords = calloc(20, sizeof(struct TrainerNameRecord));
+ struct TrainerNameRecord *newRecords = calloc(ARRAY_COUNT(gSaveBlock1Ptr->trainerNameRecords), sizeof(struct TrainerNameRecord));
// Check if we already have a record saved for connected trainers.
for (i = 0; i < GetLinkPlayerCount(); i++)
{
connectedTrainerRecordIndices[i] = -1;
- for (j = 0; j < 20; j++)
+ for (j = 0; j < (int)ARRAY_COUNT(gSaveBlock1Ptr->trainerNameRecords); j++)
{
if ((u16)gLinkPlayers[i].trainerId == gSaveBlock1Ptr->trainerNameRecords[j].trainerId && StringCompare(gLinkPlayers[i].name, gSaveBlock1Ptr->trainerNameRecords[j].trainerName) == 0)
{
@@ -890,12 +1029,12 @@ void RecordMixTrainerNames(void)
// Copy all non-empty records to the new list, in the order they appear on the old list. If the list is full,
// the last (oldest) records will be dropped.
- for (i = 0; i < 20; i++)
+ for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock1Ptr->trainerNameRecords); i++)
{
if (NameIsNotEmpty(gSaveBlock1Ptr->trainerNameRecords[i].trainerName))
{
CopyTrainerRecord(&newRecords[nextSpace], gSaveBlock1Ptr->trainerNameRecords[i].trainerId, gSaveBlock1Ptr->trainerNameRecords[i].trainerName);
- if (++nextSpace >= 20)
+ if (++nextSpace >= (int)ARRAY_COUNT(gSaveBlock1Ptr->trainerNameRecords))
{
break;
}
@@ -903,25 +1042,22 @@ void RecordMixTrainerNames(void)
}
// Finalize the new list, and clean up.
- memcpy(gSaveBlock1Ptr->trainerNameRecords, newRecords, 20 * sizeof(struct TrainerNameRecord));
+ memcpy(gSaveBlock1Ptr->trainerNameRecords, newRecords, sizeof(gSaveBlock1Ptr->trainerNameRecords));
free(newRecords);
}
}
-bool32 sub_800E540(u16 id, u8 *name)
+bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name)
{
s32 i;
- for (i = 0; i < 20; i++)
+ for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock1Ptr->trainerNameRecords); i++)
{
if (StringCompare(gSaveBlock1Ptr->trainerNameRecords[i].trainerName, name) == 0 && gSaveBlock1Ptr->trainerNameRecords[i].trainerId == id)
- {
return TRUE;
- }
+
if (!NameIsNotEmpty(gSaveBlock1Ptr->trainerNameRecords[i].trainerName))
- {
return FALSE;
- }
}
return FALSE;
}
@@ -930,7 +1066,7 @@ void WipeTrainerNameRecords(void)
{
s32 i;
- for (i = 0; i < 20; i++)
+ for (i = 0; i < (int)ARRAY_COUNT(gSaveBlock1Ptr->trainerNameRecords); i++)
{
gSaveBlock1Ptr->trainerNameRecords[i].trainerId = 0;
CpuFill16(0, gSaveBlock1Ptr->trainerNameRecords[i].trainerName, 8);
diff --git a/src/main.c b/src/main.c
index cf19f39b3..5249d11fa 100644
--- a/src/main.c
+++ b/src/main.c
@@ -113,7 +113,7 @@ void AgbMain()
InitIntrHandlers();
m4aSoundInit();
EnableVCountIntrAtLine150();
- sub_800E6D0();
+ InitRFU();
RtcInit();
CheckForFlashMemory();
InitMainCallbacks();
@@ -367,7 +367,7 @@ static void VBlankIntr(void)
if (!gMain.inBattle || !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_RECORDED)))
Random();
- sub_800E174();
+ UpdateWirelessStatusIndicatorSprite();
INTR_CHECK |= INTR_FLAG_VBLANK;
gMain.intrCheck |= INTR_FLAG_VBLANK;
diff --git a/src/menu.c b/src/menu.c
index 738c904ce..7d5f02b60 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -2107,7 +2107,7 @@ void sub_819A27C(u8 windowId, u16 speciesId, u32 personality, u16 x, u16 y)
BlitBitmapToWindow(windowId, GetMonIconPtr(speciesId, personality, 1), x, y, 32, 32);
}
-void sub_819A2BC(u8 palOffset, u8 palId)
+void ListMenuLoadStdPalAt(u8 palOffset, u8 palId)
{
const u16 *palette;
diff --git a/src/mevent2.c b/src/mevent2.c
index 2991ac27c..7a2edc7f5 100755
--- a/src/mevent2.c
+++ b/src/mevent2.c
@@ -548,12 +548,12 @@ u16 mevent_081445C0(u32 command)
return 0;
}
-void sub_801B940(void)
+void ResetReceivedWonderCardFlag(void)
{
gUnknown_02022C70 = FALSE;
}
-bool32 sub_801B94C(u16 a0)
+bool32 MEventHandleReceivedWonderCard(u16 a0)
{
gUnknown_02022C70 = FALSE;
if (a0 == 0)
@@ -569,7 +569,7 @@ bool32 sub_801B94C(u16 a0)
return TRUE;
}
-void sub_801B990(u32 a0, u32 a1)
+void RecordIdOfWonderCardSenderByEventType(u32 a0, u32 a1)
{
if (gUnknown_02022C70)
{
diff --git a/src/mystery_event_menu.c b/src/mystery_event_menu.c
index 14c00fd96..04902dee8 100644
--- a/src/mystery_event_menu.c
+++ b/src/mystery_event_menu.c
@@ -152,7 +152,7 @@ static void CB2_MysteryEventMenu(void)
if (!IsTextPrinterActive(0))
{
gMain.state++;
- gLinkType = LINKTYPE_0x5501;
+ gLinkType = LINKTYPE_MYSTERY_EVENT;
OpenLink();
}
break;
@@ -206,7 +206,7 @@ static void CB2_MysteryEventMenu(void)
{
if (gReceivedRemoteLinkPlayers != 0)
{
- if (GetLinkPlayerDataExchangeStatusTimed(2, 2) == 3)
+ if (GetLinkPlayerDataExchangeStatusTimed(2, 2) == EXCHANGE_DIFF_SELECTIONS)
{
sub_800AC34();
GetEventLoadMessage(gStringVar4, 1);
diff --git a/src/mystery_gift.c b/src/mystery_gift.c
index 06427d2dd..9672fe0ec 100644
--- a/src/mystery_gift.c
+++ b/src/mystery_gift.c
@@ -30,6 +30,7 @@
#include "link_rfu.h"
#include "mevent_news.h"
#include "mevent_server.h"
+#include "constants/cable_club.h"
void bgid_upload_textbox_1(u8 bgId);
void task_add_00_mystery_gift(void);
@@ -1242,21 +1243,21 @@ void task00_mystery_gift(u8 taskId)
case 0:
if (data->source == 1)
{
- MEvent_CreateTask_CardOrNewsWithFriend(0x15);
+ MEvent_CreateTask_CardOrNewsWithFriend(ACTIVITY_WONDER_CARD2);
}
else if (data->source == 0)
{
- MEvent_CreateTask_CardOrNewsOverWireless(0x15);
+ MEvent_CreateTask_CardOrNewsOverWireless(ACTIVITY_WONDER_CARD2);
}
break;
case 1:
if (data->source == 1)
{
- MEvent_CreateTask_CardOrNewsWithFriend(0x16);
+ MEvent_CreateTask_CardOrNewsWithFriend(ACTIVITY_WONDER_NEWS2);
}
else if (data->source == 0)
{
- MEvent_CreateTask_CardOrNewsOverWireless(0x16);
+ MEvent_CreateTask_CardOrNewsOverWireless(ACTIVITY_WONDER_NEWS2);
}
break;
}
@@ -1269,7 +1270,7 @@ void task00_mystery_gift(u8 taskId)
data->state = 7;
mevent_client_do_init(data->IsCardOrNews);
}
- else if (gSpecialVar_Result == 5)
+ else if (gSpecialVar_Result == LINKUP_FAILED)
{
ClearScreenInBg0(TRUE);
data->state = 3;
@@ -1599,10 +1600,10 @@ void task00_mystery_gift(u8 taskId)
switch (data->IsCardOrNews)
{
case 0:
- MEvent_CreateTask_Leader(21);
+ MEvent_CreateTask_Leader(ACTIVITY_WONDER_CARD2);
break;
case 1:
- MEvent_CreateTask_Leader(22);
+ MEvent_CreateTask_Leader(ACTIVITY_WONDER_NEWS2);
break;
}
data->source = 1;
@@ -1615,7 +1616,7 @@ void task00_mystery_gift(u8 taskId)
ClearScreenInBg0(1);
data->state = 31;
}
- else if (gSpecialVar_Result == 5)
+ else if (gSpecialVar_Result == LINKUP_FAILED)
{
ClearScreenInBg0(1);
data->state = 18;
diff --git a/src/new_game.c b/src/new_game.c
index 290c0c2bb..55a568132 100644
--- a/src/new_game.c
+++ b/src/new_game.c
@@ -197,7 +197,7 @@ void NewGameInitData(void)
WarpToTruck();
ScriptContext2_RunNewScript(EventScript_ResetAllMapFlags);
ResetMiniGamesResults();
- copy_strings_to_sav1();
+ InitUnionRoomChatRegisteredTexts();
InitLilycoveLady();
ResetAllApprenticeData();
ClearRankingHallRecords();
diff --git a/src/overworld.c b/src/overworld.c
index 8937af8f1..ea0d633bc 100644
--- a/src/overworld.c
+++ b/src/overworld.c
@@ -2913,7 +2913,7 @@ bool32 sub_808766C(void)
static u32 GetLinkSendQueueLength(void)
{
if (gWirelessCommType != 0)
- return Rfu.unk_9e8.unk_232;
+ return Rfu.sendQueue.count;
else
return gLink.sendQueue.count;
}
diff --git a/src/party_menu.c b/src/party_menu.c
index c4497e824..e9cbfc2ad 100755
--- a/src/party_menu.c
+++ b/src/party_menu.c
@@ -3527,7 +3527,7 @@ static void CursorCb_Register(u8 taskId)
u16 species = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES);
u8 obedience = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_OBEDIENCE);
- switch (CanRegisterMonForTradingBoard(*(struct GFtgtGnameSub *)sub_800F7DC(), species2, species, obedience))
+ switch (CanRegisterMonForTradingBoard(*(struct GFtgtGnameSub *)GetHostRFUtgtGname(), species2, species, obedience))
{
case CANT_REGISTER_MON:
StringExpandPlaceholders(gStringVar4, gText_PkmnCantBeTradedNow);
@@ -3553,7 +3553,7 @@ static void CursorCb_Trade1(u8 taskId)
u16 species2 = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES2);
u16 species = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES);
u8 obedience = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_OBEDIENCE);
- u32 stringId = GetUnionRoomTradeMessageId(*(struct GFtgtGnameSub *)sub_800F7DC(), gUnknown_02022C38, species2, gUnionRoomOfferedSpecies, gUnionRoomRequestedMonType, species, obedience);
+ u32 stringId = GetUnionRoomTradeMessageId(*(struct GFtgtGnameSub *)GetHostRFUtgtGname(), gPartnerTgtGnameSub, species2, gUnionRoomOfferedSpecies, gUnionRoomRequestedMonType, species, obedience);
if (stringId != UR_TRADE_MSG_NONE)
{
diff --git a/src/pokedex.c b/src/pokedex.c
index c3d38681c..0541f3f2e 100644
--- a/src/pokedex.c
+++ b/src/pokedex.c
@@ -2218,18 +2218,14 @@ static void CreatePokedexList(u8 dexMode, u8 order)
}
else
{
- bool32 r10;
- s16 r5;
-
- r10 = r5 = i = 0;
- for (i = 0; i < temp_dexCount; i++)
+ s16 r5, r10;
+ for (i = 0, r5 = 0, r10 = 0; i < temp_dexCount; i++)
{
temp_dexNum = i + 1;
if (GetSetPokedexFlag(temp_dexNum, FLAG_GET_SEEN))
r10 = 1;
if (r10)
{
- asm(""); //Needed to match for some reason
sPokedexView->pokedexList[r5].dexNum = temp_dexNum;
sPokedexView->pokedexList[r5].seen = GetSetPokedexFlag(temp_dexNum, FLAG_GET_SEEN);
sPokedexView->pokedexList[r5].owned = GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT);
@@ -4525,7 +4521,11 @@ static void UnusedPrintMonName(u8 windowId, const u8* name, u8 left, u8 top)
;
for (i = 0; i < nameLength; i++)
str[ARRAY_COUNT(str) - nameLength + i] = name[i];
+#ifdef UBFIX
+ str[ARRAY_COUNT(str) - 1] = EOS;
+#else
str[ARRAY_COUNT(str)] = EOS;
+#endif
PrintInfoSubMenuText(windowId, str, left, top);
}
diff --git a/src/pokemon.c b/src/pokemon.c
index 87ea2551f..329240f99 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -2725,7 +2725,7 @@ void SetDeoxysStats(void)
}
}
-u16 sub_8068B48(void)
+u16 GetUnionRoomTrainerPic(void)
{
u8 linkId;
u32 arrId;
@@ -2740,7 +2740,7 @@ u16 sub_8068B48(void)
return FacilityClassToPicIndex(gLinkPlayerFacilityClasses[arrId]);
}
-u16 sub_8068BB0(void)
+u16 GetUnionRoomTrainerClass(void)
{
u8 linkId;
u32 arrId;
@@ -3234,7 +3234,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de
damage /= 2;
}
- if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gBattleMoves[move].target == 8 && CountAliveMonsInBattle(BATTLE_ALIVE_DEF_SIDE) == 2)
+ if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gBattleMoves[move].target == MOVE_TARGET_BOTH && CountAliveMonsInBattle(BATTLE_ALIVE_DEF_SIDE) == 2)
damage /= 2;
// moves always do at least 1 damage.
@@ -3281,7 +3281,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de
damage /= 2;
}
- if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gBattleMoves[move].target == 8 && CountAliveMonsInBattle(BATTLE_ALIVE_DEF_SIDE) == 2)
+ if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gBattleMoves[move].target == MOVE_TARGET_BOTH && CountAliveMonsInBattle(BATTLE_ALIVE_DEF_SIDE) == 2)
damage /= 2;
// are effects of weather negated with cloud nine or air lock
diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c
index e755b6ca8..33ddee1b5 100755
--- a/src/pokemon_jump.c
+++ b/src/pokemon_jump.c
@@ -216,7 +216,7 @@ static bool32 sub_802C618(void);
static bool32 sub_802C650(void);
static void sub_802C688(int);
static int sub_802C6B0(void);
-static bool32 sub_802C70C(void);
+static bool32 AreLinkQueuesEmpty(void);
static int sub_802C73C(u8 *);
static void sub_802C780(void);
static int sub_802C790(int);
@@ -400,7 +400,7 @@ static const struct PokemonJumpMons gPkmnJumpSpecies[] =
{ .species = SPECIES_BAGON, .unk2 = 1, },
};
-void sub_802A9A8(u16 partyIndex, MainCallback callback)
+void StartPokemonJump(u16 partyIndex, MainCallback callback)
{
u8 taskId;
@@ -876,7 +876,7 @@ static bool32 sub_802B31C(void)
gUnknown_02022CFC->unk8++;
// fall through
case 1:
- if (sub_802C70C())
+ if (AreLinkQueuesEmpty())
return FALSE;
break;
}
@@ -1146,14 +1146,14 @@ static bool32 sub_802B720(void)
}
break;
case 2:
- if (sub_802C70C())
+ if (AreLinkQueuesEmpty())
{
- CreateTask(sub_8153688, 6);
+ CreateTask(Task_LinkSave, 6);
gUnknown_02022CFC->unk8++;
}
break;
case 3:
- if (!FuncIsActiveTask(sub_8153688))
+ if (!FuncIsActiveTask(Task_LinkSave))
{
sub_802DA14();
gUnknown_02022CFC->unk8++;
@@ -2025,9 +2025,9 @@ static int sub_802C6B0(void)
return count;
}
-static bool32 sub_802C70C(void)
+static bool32 AreLinkQueuesEmpty(void)
{
- return !Rfu.unk_124.unk_8c2 && !Rfu.unk_9e8.unk_232;
+ return !Rfu.recvQueue.count && !Rfu.sendQueue.count;
}
static int sub_802C73C(u8 *arg0)
diff --git a/src/record_mixing.c b/src/record_mixing.c
index 3a93d72f8..075bc6aee 100644
--- a/src/record_mixing.c
+++ b/src/record_mixing.c
@@ -169,10 +169,9 @@ static const u8 gUnknown_0858CFBE[3][4] =
#define BUFFER_CHUNK_SIZE 200
-// Note: VAR_0x8005 contains the spotId.
void RecordMixingPlayerSpotTriggered(void)
{
- sub_80B37D4(Task_RecordMixing_Main);
+ CreateTask_EnterCableClubSeat(Task_RecordMixing_Main);
}
// these variables were const in R/S, but had to become changeable because of saveblocks changing RAM position
@@ -232,7 +231,7 @@ static void PrepareExchangePacket(void)
if (Link_AnyPartnersPlayingRubyOrSapphire())
{
- if (sub_800A03C() == 0)
+ if (LinkDummy_Return2() == 0)
PrepareUnknownExchangePacket(&sSentRecord->ruby);
else
PrepareExchangePacketForRubySapphire(&sSentRecord->ruby);
@@ -351,7 +350,7 @@ static void Task_RecordMixing_Main(u8 taskId)
{
tState = 4;
if (gWirelessCommType == 0)
- data[10] = sub_80B3050();
+ data[10] = CreateTask_ReestablishCableClubLink();
PrintTextOnRecordMixing(gText_RecordMixingComplete);
data[8] = 0;
@@ -527,7 +526,7 @@ static void Task_CopyReceiveBuffer(u8 taskId)
u8 status = GetBlockReceivedStatus();
u8 handledPlayers = 0;
- if (status == sub_800A9D8())
+ if (status == GetLinkPlayerCountAsBitFlags())
{
u8 i;
@@ -987,12 +986,12 @@ static void Task_DoRecordMixing(u8 taskId)
case 6:
if (!sub_801048C(FALSE))
{
- CreateTask(sub_8153688, 5);
+ CreateTask(Task_LinkSave, 5);
task->data[0] ++;
}
break;
- case 7: // wait for sub_8153688 to finish.
- if (!FuncIsActiveTask(sub_8153688))
+ case 7: // wait for Task_LinkSave to finish.
+ if (!FuncIsActiveTask(Task_LinkSave))
{
if (gWirelessCommType)
{
diff --git a/src/rom_81520A8.c b/src/rom_81520A8.c
deleted file mode 100644
index 8b10d44d0..000000000
--- a/src/rom_81520A8.c
+++ /dev/null
@@ -1,218 +0,0 @@
-#include "global.h"
-#include "rom_81520A8.h"
-#include "malloc.h"
-#include "main.h"
-#include "digit_obj_util.h"
-
-static EWRAM_DATA struct
-{
- u8 count;
- struct UnkStruct_81520A8 *unk4;
-} *sUnknown_0203ABB8 = NULL;
-
-void sub_81520A8(void *dest, u16 value, u8 left, u8 top, u8 width, u8 height) // Unused.
-{
- u8 i;
- u8 j;
- u8 x;
- u8 y;
-
- for (i = 0, y = top; i < height; i++)
- {
- for (x = left, j = 0; j < width; j++)
- {
- *(u16 *)((dest) + (y * 64 + x * 2)) = value;
- x = (x + 1) % 32;
- }
- y = (y + 1) % 32;
- }
-}
-
-void sub_8152134(void *dest, const u16 *src, u8 left, u8 top, u8 width, u8 height) // Unused.
-{
- u8 i;
- u8 j;
- u8 x;
- u8 y;
- const u16 *_src;
-
- for (i = 0, _src = src, y = top; i < height; i++)
- {
- for (x = left, j = 0; j < width; j++)
- {
- *(u16 *)((dest) + (y * 64 + x * 2)) = *(_src++);
- x = (x + 1) % 32;
- }
- y = (y + 1) % 32;
- }
-}
-
-bool32 sub_81521C0(u8 count)
-{
- u8 i = 0;
-
- if (count == 0)
- return FALSE;
- if (count > 64)
- count = 64;
-
- sUnknown_0203ABB8 = AllocZeroed(sizeof(*sUnknown_0203ABB8));
- if (sUnknown_0203ABB8 == NULL)
- return FALSE;
- sUnknown_0203ABB8->unk4 = AllocZeroed(count * sizeof(struct UnkStruct_81520A8));
- if (sUnknown_0203ABB8->unk4 == NULL)
- {
- FREE_AND_SET_NULL(sUnknown_0203ABB8);
- return FALSE;
- }
-
- sUnknown_0203ABB8->count = count;
- for (i = 0; i < count; i++)
- {
- memcpy(&sUnknown_0203ABB8->unk4[i].oam, &gDummyOamData, sizeof(struct OamData));
- sUnknown_0203ABB8->unk4[i].unk19_2 = TRUE;
- }
-
- return TRUE;
-}
-
-bool32 sub_8152254(void)
-{
- u8 i = 0;
-
- if (sUnknown_0203ABB8 == NULL)
- return FALSE;
-
- for (i = 0; i < sUnknown_0203ABB8->count; i++)
- memcpy(&gMain.oamBuffer[i + 64], &gDummyOamData, sizeof(struct OamData));
-
- memset(sUnknown_0203ABB8->unk4, 0, sUnknown_0203ABB8->count * sizeof(struct UnkStruct_81520A8));
- FREE_AND_SET_NULL(sUnknown_0203ABB8->unk4);
- memset(sUnknown_0203ABB8, 0, sizeof(*sUnknown_0203ABB8));
- FREE_AND_SET_NULL(sUnknown_0203ABB8);
-
- return TRUE;
-}
-
-bool32 sub_81522D4(void)
-{
- u8 i = 0;
-
- if (sUnknown_0203ABB8 == NULL || sUnknown_0203ABB8->unk4 == NULL)
- return FALSE;
-
- for (i = 0; i < sUnknown_0203ABB8->count; i++)
- {
- if (sUnknown_0203ABB8->unk4[i].unk19_0 && sUnknown_0203ABB8->unk4[i].unk19_1)
- {
- if (sUnknown_0203ABB8->unk4[i].callback != NULL)
- sUnknown_0203ABB8->unk4[i].callback(&sUnknown_0203ABB8->unk4[i]);
-
- if (sUnknown_0203ABB8->unk4[i].unk19_2)
- {
- memcpy(&gMain.oamBuffer[i + 64], &gDummyOamData, sizeof(struct OamData));
- }
- else
- {
- sUnknown_0203ABB8->unk4[i].oam.y = sUnknown_0203ABB8->unk4[i].y + sUnknown_0203ABB8->unk4[i].yDelta;
- sUnknown_0203ABB8->unk4[i].oam.x = sUnknown_0203ABB8->unk4[i].x + sUnknown_0203ABB8->unk4[i].xDelta;
- sUnknown_0203ABB8->unk4[i].oam.priority = sUnknown_0203ABB8->unk4[i].priority;
- sUnknown_0203ABB8->unk4[i].oam.tileNum = sUnknown_0203ABB8->unk4[i].tileNum;
- memcpy(&gMain.oamBuffer[i + 64], &sUnknown_0203ABB8->unk4[i], sizeof(struct OamData));
- }
- }
- }
-
- return TRUE;
-}
-
-static bool32 sub_81523F4(struct UnkStruct_81520A8 *structPtr, u8 arg1)
-{
- u16 tileStart;
-
- if (structPtr == NULL)
- return FALSE;
-
- tileStart = GetSpriteTileStartByTag(structPtr->tileTag);
- if (tileStart == 0xFFFF)
- return FALSE;
-
- structPtr->unk18 = arg1;
- structPtr->tileNum = (GetTilesPerImage(structPtr->oam.shape, structPtr->oam.size) * arg1) + tileStart;
- return TRUE;
-}
-
-u8 sub_8152438(u8 id, void (*func)(struct UnkStruct_81520A8 *))
-{
- if (sUnknown_0203ABB8 == NULL || id >= sUnknown_0203ABB8->count)
- return 0xFF;
- else if (!sUnknown_0203ABB8->unk4[id].unk19_0)
- return 0xFF;
-
- sUnknown_0203ABB8->unk4[id].callback = func;
- return id;
-}
-
-u8 sub_8152474(u8 id, u8 dataArrayId, s16 dataValue)
-{
- if (sUnknown_0203ABB8 == NULL || id >= sUnknown_0203ABB8->count)
- return 0xFF;
- else if (!sUnknown_0203ABB8->unk4[id].unk19_0 || dataArrayId >= ARRAY_COUNT(sUnknown_0203ABB8->unk4[id].data))
- return 0xFF;
-
- sUnknown_0203ABB8->unk4[id].data[dataArrayId] = dataValue;
- return id;
-}
-
-u8 sub_81524C4(const struct OamData *oam, u16 tileTag, u16 palTag, s16 x, s16 y, u8 arg5, u8 priority)
-{
- struct UnkStruct_81520A8 *structPtr = NULL;
- u8 i;
-
- if (sUnknown_0203ABB8 == NULL || oam == NULL)
- return 0xFF;
-
- for (i = 0; i < sUnknown_0203ABB8->count; i++)
- {
- if (!sUnknown_0203ABB8->unk4[i].unk19_0)
- {
- structPtr = &sUnknown_0203ABB8->unk4[i];
- memset(structPtr, 0, sizeof(*structPtr));
- structPtr->id = i;
- structPtr->unk19_0 = TRUE;
- structPtr->unk19_1 = TRUE;
- break;
- }
- }
-
- if (structPtr == NULL)
- return 0xFF;
-
- memcpy(&structPtr->oam, oam, sizeof(*oam));
- structPtr->tileTag = tileTag;
- structPtr->palTag = palTag;
- structPtr->x = x;
- structPtr->y = y;
- structPtr->oam.paletteNum = IndexOfSpritePaletteTag(palTag);
- if (priority < 4)
- {
- structPtr->priority = priority;
- structPtr->oam.priority = priority;
- }
- sub_81523F4(structPtr, arg5);
-
- return structPtr->id;
-}
-
-u8 sub_81525D0(u8 id)
-{
- if (sUnknown_0203ABB8 == NULL || !sUnknown_0203ABB8->unk4[id].unk19_0)
- return 0xFF;
-
- memset(&sUnknown_0203ABB8->unk4[id], 0, sizeof(struct UnkStruct_81520A8));
- sUnknown_0203ABB8->unk4[id].oam.y = 160;
- sUnknown_0203ABB8->unk4[id].oam.x = 240;
- sUnknown_0203ABB8->unk4[id].unk19_2 = TRUE;
- memcpy(&gMain.oamBuffer[id + 64], &gDummyOamData, sizeof(struct OamData));
- return id;
-}
diff --git a/src/save.c b/src/save.c
index c19aff4d8..09e1b7aae 100644
--- a/src/save.c
+++ b/src/save.c
@@ -897,74 +897,78 @@ u32 TryWriteSpecialSaveSection(u8 sector, u8* src)
return SAVE_STATUS_OK;
}
-void sub_8153688(u8 taskId)
+#define tState data[0]
+#define tTimer data[1]
+#define tPartialSave data[2]
+
+void Task_LinkSave(u8 taskId)
{
- s16* taskData = gTasks[taskId].data;
+ s16* data = gTasks[taskId].data;
- switch (taskData[0])
+ switch (tState)
{
case 0:
gSoftResetDisabled = TRUE;
- taskData[0] = 1;
+ tState = 1;
break;
case 1:
sub_800ADF8();
- taskData[0] = 2;
+ tState = 2;
break;
case 2:
if (IsLinkTaskFinished())
{
- if (taskData[2] == 0)
+ if (!tPartialSave)
save_serialize_map();
- taskData[0] = 3;
+ tState = 3;
}
break;
case 3:
- if (taskData[2] == 0)
+ if (!tPartialSave)
SetContinueGameWarpStatusToDynamicWarp();
sub_8153380();
- taskData[0] = 4;
+ tState = 4;
break;
case 4:
- if (++taskData[1] == 5)
+ if (++tTimer == 5)
{
- taskData[1] = 0;
- taskData[0] = 5;
+ tTimer = 0;
+ tState = 5;
}
break;
case 5:
if (sub_81533AC())
- taskData[0] = 6;
+ tState = 6;
else
- taskData[0] = 4;
+ tState = 4;
break;
case 6:
sub_81533E0();
- taskData[0] = 7;
+ tState = 7;
break;
case 7:
- if (taskData[2] == 0)
+ if (!tPartialSave)
ClearContinueGameWarpStatus2();
sub_800ADF8();
- taskData[0] = 8;
+ tState = 8;
break;
case 8:
if (IsLinkTaskFinished())
{
sub_8153408();
- taskData[0] = 9;
+ tState = 9;
}
break;
case 9:
sub_800ADF8();
- taskData[0] = 10;
+ tState = 10;
break;
case 10:
if (IsLinkTaskFinished())
- taskData[0]++;
+ tState++;
break;
case 11:
- if (++taskData[1] > 5)
+ if (++tTimer > 5)
{
gSoftResetDisabled = FALSE;
DestroyTask(taskId);
@@ -972,3 +976,7 @@ void sub_8153688(u8 taskId)
break;
}
}
+
+#undef tState
+#undef tTimer
+#undef tPartialSave
diff --git a/src/scrcmd.c b/src/scrcmd.c
index 9e62c45c5..4a7f4ea73 100644
--- a/src/scrcmd.c
+++ b/src/scrcmd.c
@@ -5,7 +5,7 @@
#include "clock.h"
#include "coins.h"
#include "contest.h"
-#include "contest_link_80F57C4.h"
+#include "contest_util.h"
#include "contest_painting.h"
#include "data.h"
#include "decoration.h"
@@ -1185,22 +1185,22 @@ bool8 ScrCmd_setobjectmovementtype(struct ScriptContext *ctx)
bool8 ScrCmd_createvobject(struct ScriptContext *ctx)
{
u8 graphicsId = ScriptReadByte(ctx);
- u8 v2 = ScriptReadByte(ctx);
+ u8 objectEventId = ScriptReadByte(ctx);
u16 x = VarGet(ScriptReadHalfword(ctx));
u32 y = VarGet(ScriptReadHalfword(ctx));
u8 elevation = ScriptReadByte(ctx);
u8 direction = ScriptReadByte(ctx);
- sprite_new(graphicsId, v2, x, y, elevation, direction);
+ CreateObjectSprite(graphicsId, objectEventId, x, y, elevation, direction);
return FALSE;
}
bool8 ScrCmd_turnvobject(struct ScriptContext *ctx)
{
- u8 v1 = ScriptReadByte(ctx);
+ u8 objectEventId = ScriptReadByte(ctx);
u8 direction = ScriptReadByte(ctx);
- sub_8097B78(v1, direction);
+ TurnObjectEventSprite(objectEventId, direction);
return FALSE;
}
@@ -1469,7 +1469,9 @@ bool8 ScrCmd_hidemonpic(struct ScriptContext *ctx)
bool8 ScrCmd_showcontestwinner(struct ScriptContext *ctx)
{
u8 contestWinnerId = ScriptReadByte(ctx);
- if (contestWinnerId)
+
+ // Don't save artist's painting yet
+ if (contestWinnerId != CONTEST_WINNER_ARTIST)
SetContestWinnerForPainting(contestWinnerId);
ShowContestWinner();
@@ -1953,14 +1955,14 @@ bool8 ScrCmd_startcontest(struct ScriptContext *ctx)
bool8 ScrCmd_showcontestresults(struct ScriptContext *ctx)
{
- sub_80F8484();
+ ShowContestResults();
ScriptContext1_Stop();
return TRUE;
}
bool8 ScrCmd_contestlinktransfer(struct ScriptContext *ctx)
{
- sub_80F84C4(gSpecialVar_ContestCategory);
+ ContestLinkTransfer(gSpecialVar_ContestCategory);
ScriptContext1_Stop();
return TRUE;
}
diff --git a/src/script_pokemon_util_80F87D8.c b/src/script_pokemon_util_80F87D8.c
index 134004fd0..a6ab1693b 100755
--- a/src/script_pokemon_util_80F87D8.c
+++ b/src/script_pokemon_util_80F87D8.c
@@ -3,7 +3,7 @@
#include "battle_gfx_sfx_util.h"
#include "berry.h"
#include "contest.h"
-#include "contest_link_80F57C4.h"
+#include "contest_util.h"
#include "contest_painting.h"
#include "data.h"
#include "daycare.h"
@@ -122,7 +122,7 @@ void ShouldReadyContestArtist(void)
{
if (gContestFinalStandings[gContestPlayerMonIndex] == 0
&& gSpecialVar_ContestRank == CONTEST_RANK_MASTER
- && gUnknown_02039F08[gContestPlayerMonIndex] >= 800)
+ && gContestMonTotalPoints[gContestPlayerMonIndex] >= 800)
{
gSpecialVar_0x8004 = TRUE;
}
@@ -304,7 +304,7 @@ u8 GiveMonArtistRibbon(void)
if (!hasArtistRibbon
&& gContestFinalStandings[gContestPlayerMonIndex] == 0
&& gSpecialVar_ContestRank == CONTEST_RANK_MASTER
- && gUnknown_02039F08[gContestPlayerMonIndex] >= 800)
+ && gContestMonTotalPoints[gContestPlayerMonIndex] >= 800)
{
hasArtistRibbon = 1;
SetMonData(&gPlayerParty[gContestMonPartyIndex], MON_DATA_ARTIST_RIBBON, &hasArtistRibbon);
diff --git a/src/secret_base.c b/src/secret_base.c
index 172568db6..83626710f 100644
--- a/src/secret_base.c
+++ b/src/secret_base.c
@@ -37,6 +37,7 @@
#include "constants/event_bg.h"
#include "constants/decorations.h"
#include "constants/event_objects.h"
+#include "constants/field_specials.h"
#include "constants/items.h"
#include "constants/maps.h"
#include "constants/map_types.h"
@@ -1120,7 +1121,7 @@ const u8 *GetSecretBaseTrainerLoseText(void)
void PrepSecretBaseBattleFlags(void)
{
- TryGainNewFanFromCounter(1);
+ TryGainNewFanFromCounter(FANCOUNTER_BATTLED_AT_BASE);
gTrainerBattleOpponent_A = TRAINER_SECRET_BASE;
gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_SECRET_BASE;
}
diff --git a/src/slot_machine.c b/src/slot_machine.c
index 9e94d11f0..d1cb05b18 100644
--- a/src/slot_machine.c
+++ b/src/slot_machine.c
@@ -384,7 +384,7 @@ static const u16 gSlotPayouts[];
static const u8 *const gUnknown_083EDCE4;
static const u8 *const gUnknown_083EDCDC;
static const u32 gReelTimeGfx[];
-static const struct SpriteSheet gSlotMachineSpriteSheets[];
+static const struct SpriteSheet gSlotMachineSpriteSheets[22];
static const struct SpritePalette gSlotMachineSpritePalettes[];
static const u16 *const gUnknown_083EDE20;
static const s16 gInitialReelPositions[][2];
@@ -4171,8 +4171,8 @@ static void sub_81063C0(void)
LZDecompressWram(gSlotMachineReelTime_Gfx, sUnknown_0203AAD4);
sUnknown_0203AAD8 = Alloc(0x3600);
LZDecompressWram(gReelTimeGfx, sUnknown_0203AAD8);
- sUnknown_0203AB30 = AllocZeroed(sizeof(struct SpriteSheet) * 22);
- for (i = 0; i < 22; i++)
+ sUnknown_0203AB30 = AllocZeroed(sizeof(struct SpriteSheet) * ARRAY_COUNT(gSlotMachineSpriteSheets));
+ for (i = 0; i < ARRAY_COUNT(gSlotMachineSpriteSheets); i++)
{
sUnknown_0203AB30[i].data = gSlotMachineSpriteSheets[i].data;
sUnknown_0203AB30[i].size = gSlotMachineSpriteSheets[i].size;
@@ -6708,7 +6708,7 @@ static const struct SubspriteTable *const gUnknown_083EDBC4[] =
NULL
};
-static const struct SpriteSheet gSlotMachineSpriteSheets[] =
+static const struct SpriteSheet gSlotMachineSpriteSheets[22] =
{
{ .data = gSlotMachineReelSymbol1Tiles, .size = 0x200, .tag = 0 },
{ .data = gSlotMachineReelSymbol2Tiles, .size = 0x200, .tag = 1 },
@@ -6727,15 +6727,12 @@ static const struct SpriteSheet gSlotMachineSpriteSheets[] =
{ .data = gSlotMachineNumber7Tiles, .size = 0x40, .tag = 14 },
{ .data = gSlotMachineNumber8Tiles, .size = 0x40, .tag = 15 },
{ .data = gSlotMachineNumber9Tiles, .size = 0x40, .tag = 16 },
-};
-
-static const u8 sUnused1[][8] =
-{
- {0, 0, 0, 0, 0, 2, 18},
- {0, 0, 0, 0, 0, 2, 19},
- {0, 0, 0, 0, 0, 3, 20},
- {0, 0, 0, 0, 0, 3, 21},
- {0, 0, 0, 0, 0, 0, 0}
+ // the data for these sheets is determined at runtime
+ { .data = NULL, .size = 0x200, .tag = 18 },
+ { .data = NULL, .size = 0x200, .tag = 19 },
+ { .data = NULL, .size = 0x300, .tag = 20 },
+ { .data = NULL, .size = 0x300, .tag = 21 },
+ {},
};
static const u8 *const gUnknown_083EDCDC = gUnknown_08DD19F8;
diff --git a/src/start_menu.c b/src/start_menu.c
index 4b6fce57b..88ad364c7 100644
--- a/src/start_menu.c
+++ b/src/start_menu.c
@@ -133,8 +133,8 @@ static u8 BattlePyramidRetireInputCallback(void);
// Task callbacks
static void StartMenuTask(u8 taskId);
static void SaveGameTask(u8 taskId);
-static void sub_80A0550(u8 taskId);
-static void sub_80A08A4(u8 taskId);
+static void Task_SaveAfterLinkBattle(u8 taskId);
+static void Task_WaitForBattleTowerLinkSave(u8 taskId);
static bool8 FieldCB_ReturnToFieldStartMenu(void);
static const struct WindowTemplate sSafariBallsWindowTemplate = {0, 1, 1, 9, 4, 0xF, 8};
@@ -219,8 +219,8 @@ static bool8 SaveSuccesTimer(void);
static bool8 SaveErrorTimer(void);
static void InitBattlePyramidRetire(void);
static void sub_80A03D8(void);
-static bool32 sub_80A03E4(u8 *par1);
-static void sub_80A0540(void);
+static bool32 InitSaveWindowAfterLinkBattle(u8 *par1);
+static void CB2_SaveAfterLinkBattle(void);
static void ShowSaveInfoWindow(void);
static void RemoveSaveInfoWindow(void);
static void HideStartMenuWindow(void);
@@ -525,7 +525,7 @@ void Task_ShowStartMenu(u8 taskId)
{
case 0:
if (InUnionRoom() == TRUE)
- var_800D_set_xB();
+ SetUsingUnionRoomStartMenu();
gMenuCallback = HandleStartMenuInput;
task->data[0]++;
@@ -1159,9 +1159,9 @@ static void sub_80A03D8(void)
TransferPlttBuffer();
}
-static bool32 sub_80A03E4(u8 *par1)
+static bool32 InitSaveWindowAfterLinkBattle(u8 *state)
{
- switch (*par1)
+ switch (*state)
{
case 0:
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0);
@@ -1193,43 +1193,43 @@ static bool32 sub_80A03E4(u8 *par1)
return TRUE;
}
- (*par1)++;
+ (*state)++;
return FALSE;
}
-void sub_80A0514(void)
+void CB2_SetUpSaveAfterLinkBattle(void)
{
- if (sub_80A03E4(&gMain.state))
+ if (InitSaveWindowAfterLinkBattle(&gMain.state))
{
- CreateTask(sub_80A0550, 0x50);
- SetMainCallback2(sub_80A0540);
+ CreateTask(Task_SaveAfterLinkBattle, 0x50);
+ SetMainCallback2(CB2_SaveAfterLinkBattle);
}
}
-static void sub_80A0540(void)
+static void CB2_SaveAfterLinkBattle(void)
{
RunTasks();
UpdatePaletteFade();
}
-static void sub_80A0550(u8 taskId)
+static void Task_SaveAfterLinkBattle(u8 taskId)
{
- s16 *step = gTasks[taskId].data;
+ s16 *state = gTasks[taskId].data;
if (!gPaletteFade.active)
{
- switch (*step)
+ switch (*state)
{
case 0:
FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0,
1,
gText_SavingDontTurnOffPower,
- 255,
+ TEXT_SPEED_FF,
NULL,
- 2,
- 1,
- 3);
+ TEXT_COLOR_DARK_GREY,
+ TEXT_COLOR_WHITE,
+ TEXT_COLOR_LIGHT_GREY);
DrawTextBorderOuter(0, 8, 14);
PutWindowTilemap(0);
CopyWindowToVram(0, 3);
@@ -1237,37 +1237,37 @@ static void sub_80A0550(u8 taskId)
if (gWirelessCommType != 0 && InUnionRoom())
{
- if (sub_800A07C())
+ if (Link_AnyPartnersPlayingFRLG_JP())
{
- *step = 1;
+ *state = 1;
}
else
{
- *step = 5;
+ *state = 5;
}
}
else
{
gSoftResetDisabled = 1;
- *step = 1;
+ *state = 1;
}
break;
case 1:
SetContinueGameWarpStatusToDynamicWarp();
FullSaveGame();
- *step = 2;
+ *state = 2;
break;
case 2:
if (CheckSaveFile())
{
ClearContinueGameWarpStatus2();
- *step = 3;
+ *state = 3;
gSoftResetDisabled = 0;
}
break;
case 3:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
- *step = 4;
+ *state = 4;
break;
case 4:
FreeAllWindowBuffers();
@@ -1275,13 +1275,13 @@ static void sub_80A0550(u8 taskId)
DestroyTask(taskId);
break;
case 5:
- CreateTask(sub_8153688, 0x5);
- *step = 6;
+ CreateTask(Task_LinkSave, 5);
+ *state = 6;
break;
case 6:
- if (!FuncIsActiveTask(sub_8153688))
+ if (!FuncIsActiveTask(Task_LinkSave))
{
- *step = 3;
+ *state = 3;
}
break;
}
@@ -1357,22 +1357,26 @@ static void RemoveSaveInfoWindow(void)
RemoveWindow(sSaveInfoWindowId);
}
-static void sub_80A08A4(u8 taskId)
+static void Task_WaitForBattleTowerLinkSave(u8 taskId)
{
- if (!FuncIsActiveTask(sub_8153688))
+ if (!FuncIsActiveTask(Task_LinkSave))
{
DestroyTask(taskId);
EnableBothScriptContexts();
}
}
-void sub_80A08CC(void)
+#define tPartialSave data[2]
+
+void SaveForBattleTowerLink(void)
{
- u8 taskId = CreateTask(sub_8153688, 0x5);
- gTasks[taskId].data[2] = 1;
- gTasks[CreateTask(sub_80A08A4, 0x6)].data[1] = taskId;
+ u8 taskId = CreateTask(Task_LinkSave, 5);
+ gTasks[taskId].tPartialSave = TRUE;
+ gTasks[CreateTask(Task_WaitForBattleTowerLinkSave, 6)].data[1] = taskId;
}
+#undef tPartialSave
+
static void HideStartMenuWindow(void)
{
ClearStdWindowAndFrame(GetStartMenuWindowId(), TRUE);
diff --git a/src/strings.c b/src/strings.c
index 3ca7f693f..324e6098a 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -1236,7 +1236,7 @@ const u8 gText_BDot[] = _("B.");
const u8 gText_AnnouncingResults[] = _("Announcing the results!");
const u8 gText_PreliminaryResults[] = _("The preliminary results!");
const u8 gText_Round2Results[] = _("Round 2 results!");
-const u8 gText_Var1sVar2Won[] = _("{STR_VAR_1}'s {STR_VAR_2} won!");
+const u8 gText_ContestantsMonWon[] = _("{STR_VAR_1}'s {STR_VAR_2} won!");
const u8 gText_CommunicationStandby[] = _("Communication standby…");
const u8 gText_ColorDarkGrey[] = _("{COLOR DARK_GREY}");
const u8 gText_ColorDynamic6WhiteDynamic5[] = _("{COLOR_HIGHLIGHT_SHADOW DYNAMIC_COLOR6 WHITE DYNAMIC_COLOR5}"); // Unused
@@ -1261,10 +1261,10 @@ const u8 gJPText_PlayersXPokemon[] = _("{SPECIAL_F7 0x00}の{SPECIAL_F7 0x01}ひ
const u8 gJPText_PlayersXPokmonDoesNotExist[] = _("{SPECIAL_F7 0x00}の{SPECIAL_F7 0x01}ひきめは いません"); // Unused
const u8 gText_ExitingChat[] = _("Exiting the chat…");
const u8 gText_LeaderLeftEndingChat[] = _("The LEADER, {SPECIAL_F7 0x00}, has\nleft, ending the chat.");
-const u8 gText_RegisteredTextChanged[] = _("The registered text has been changed.\nIs it okay to save the game?");
-const u8 gText_AlreadySavedFile_Unused[] = _("There is already a saved file.\nIs it okay to overwrite it?");
-const u8 gText_SavingDontTurnOff_Unused[] = _("SAVING…\nDON'T TURN OFF THE POWER.");
-const u8 gText_PlayerSavedGame_Unused[] = _("{SPECIAL_F7 0x00} saved the game.");
+const u8 gText_RegisteredTextChangedOKToSave[] = _("The registered text has been changed.\nIs it okay to save the game?");
+const u8 gText_AlreadySavedFile_Chat[] = _("There is already a saved file.\nIs it okay to overwrite it?");
+const u8 gText_SavingDontTurnOff_Chat[] = _("SAVING…\nDON'T TURN OFF THE POWER.");
+const u8 gText_PlayerSavedGame_Chat[] = _("{SPECIAL_F7 0x00} saved the game.");
const u8 gText_IfLeaderLeavesChatEnds[] = _("If the LEADER leaves, the chat\nwill end. Is that okay?");
const u8 gText_Hello[] = _("HELLO");
const u8 gText_Pokemon2[] = _("POKéMON");
@@ -1492,7 +1492,7 @@ const u8 gText_FrameTypeNumber[] = _("{COLOR GREEN}{SHADOW LIGHT_GREEN}");
const u8 gText_ButtonTypeNormal[] = _("{COLOR GREEN}{SHADOW LIGHT_GREEN}NORMAL");
const u8 gText_ButtonTypeLR[] = _("{COLOR GREEN}{SHADOW LIGHT_GREEN}LR");
const u8 gText_ButtonTypeLEqualsA[] = _("{COLOR GREEN}{SHADOW LIGHT_GREEN}L=A");
-const u8 gText_XPLink[] = _("{STR_VAR_1}P LINK");
+const u8 gText_NumPlayerLink[] = _("{STR_VAR_1}P LINK");
const u8 gText_BronzeCard[] = _("BRONZE");
const u8 gText_CopperCard[] = _("COPPER");
const u8 gText_SilverCard[] = _("SILVER");
diff --git a/src/trade.c b/src/trade.c
index e22180ae9..3a0f07ac6 100644
--- a/src/trade.c
+++ b/src/trade.c
@@ -52,6 +52,7 @@
#include "constants/rgb.h"
#include "constants/species.h"
#include "constants/songs.h"
+#include "constants/union_room.h"
#define Trade_SendData(ptr) (SendBlock(bitmask_all_link_players_but_self(), ptr->linkData, 20))
@@ -234,7 +235,7 @@ static void CB2_SaveAndEndWirelessTrade(void);
static bool8 SendLinkData(const void *linkData, u32 size)
{
- if (gUnknown_02022C2C == 29)
+ if (gPlayerCurrActivity == ACTIVITY_29)
{
rfu_NI_setSendData(lman.acceptSlot_flag, 84, linkData, size);
return TRUE;
@@ -252,7 +253,7 @@ static void sub_80771AC(u8 a0)
static bool32 sub_80771BC(void)
{
- if (gUnknown_02022C2C == 29)
+ if (gPlayerCurrActivity == ACTIVITY_29)
{
if (gRfuSlotStatusNI[sub_800E87C(lman.acceptSlot_flag)]->send.state == 0)
return TRUE;
@@ -288,7 +289,7 @@ static void TradeResetReceivedFlag(u32 who)
static bool32 IsWirelessTrade(void)
{
- if (gWirelessCommType && gUnknown_02022C2C == 29)
+ if (gWirelessCommType && gPlayerCurrActivity == ACTIVITY_29)
return TRUE;
else
return FALSE;
@@ -388,20 +389,20 @@ static void CB2_CreateTradeMenu(void)
if (!gReceivedRemoteLinkPlayers)
{
- gLinkType = LINKTYPE_0x1122;
+ gLinkType = LINKTYPE_TRADE_CONNECTING;
sTradeMenuData->timer = 0;
if (gWirelessCommType)
{
- sub_800B488();
+ SetWirelessCommType1();
OpenLink();
- sub_8011BA4();
+ CreateTask_RfuIdle();
}
else
{
OpenLink();
gMain.state++;
- CreateTask(task00_08081A90, 1);
+ CreateTask(Task_WaitForLinkPlayerConnection, 1);
}
}
else
@@ -437,7 +438,7 @@ static void CB2_CreateTradeMenu(void)
case 4:
if (gReceivedRemoteLinkPlayers == TRUE && IsLinkPlayerDataExchangeComplete() == TRUE)
{
- sub_8011BD0();
+ DestroyTask_RfuIdle();
CalculatePlayerPartyCount();
gMain.state++;
sTradeMenuData->timer = 0;
@@ -2749,7 +2750,7 @@ void CB2_LinkTrade(void)
case 0:
if (!gReceivedRemoteLinkPlayers)
{
- gLinkType = LINKTYPE_0x1144;
+ gLinkType = LINKTYPE_TRADE_DISCONNECTED;
CloseLink();
}
sTradeData = AllocZeroed(sizeof(*sTradeData));
@@ -4596,7 +4597,7 @@ static void CB2_SaveAndEndTrade(void)
IncrementGameStat(GAME_STAT_POKEMON_TRADES);
if (gWirelessCommType)
{
- sub_801B990(2, gLinkPlayers[GetMultiplayerId() ^ 1].trainerId);
+ RecordIdOfWonderCardSenderByEventType(2, gLinkPlayers[GetMultiplayerId() ^ 1].trainerId);
}
SetContinueGameWarpStatusToDynamicWarp();
sub_8153380();
diff --git a/src/tv.c b/src/tv.c
index eaf30f82b..b3722e87a 100644
--- a/src/tv.c
+++ b/src/tv.c
@@ -764,11 +764,11 @@ void ClearTVShowData(void)
for (i = 0; i < ARRAY_COUNT(gSaveBlock1Ptr->tvShows); i ++)
{
- gSaveBlock1Ptr->tvShows[i].common.kind = 0;
- gSaveBlock1Ptr->tvShows[i].common.active = 0;
- for (j = 0; j < sizeof(TVShow) - 2; j ++)
+ gSaveBlock1Ptr->tvShows[i].commonInit.kind = 0;
+ gSaveBlock1Ptr->tvShows[i].commonInit.active = 0;
+ for (j = 0; j < ARRAY_COUNT(gSaveBlock1Ptr->tvShows[i].commonInit.pad02); j ++)
{
- gSaveBlock1Ptr->tvShows[i].common.pad02[j] = 0;
+ gSaveBlock1Ptr->tvShows[i].commonInit.pad02[j] = 0;
}
}
ClearPokemonNews();
@@ -3167,11 +3167,11 @@ void DeleteTVShowInArrayByIdx(TVShow *shows, u8 idx)
{
u8 i;
- shows[idx].common.kind = TVSHOW_OFF_AIR;
- shows[idx].common.active = FALSE;
- for (i = 0; i < 34; i ++)
+ shows[idx].commonInit.kind = TVSHOW_OFF_AIR;
+ shows[idx].commonInit.active = FALSE;
+ for (i = 0; i < ARRAY_COUNT(shows[idx].commonInit.pad02); i++)
{
- shows[idx].common.pad02[i] = 0;
+ shows[idx].commonInit.pad02[i] = 0;
}
}
diff --git a/src/union_room.c b/src/union_room.c
index cd45907f5..1ef8cd4cb 100644
--- a/src/union_room.c
+++ b/src/union_room.c
@@ -41,6 +41,7 @@
#include "trade.h"
#include "trainer_card.h"
#include "union_room.h"
+#include "union_room_battle.h"
#include "union_room_chat.h"
#include "union_room_player_avatar.h"
#include "window.h"
@@ -52,158 +53,293 @@
#include "constants/rgb.h"
#include "constants/songs.h"
#include "constants/species.h"
-#include "constants/union_room.h"
-
-EWRAM_DATA u8 sUnionRoomPlayerName[12] = {};
-EWRAM_DATA u8 gUnknown_02022C2C = 0;
-EWRAM_DATA u8 gUnknown_02022C2D = 0;
-EWRAM_DATA union UnkUnion_Main gUnknown_02022C30 = {};
-EWRAM_DATA u32 gFiller_02022C34 = 0;
-EWRAM_DATA struct GFtgtGnameSub gUnknown_02022C38 = {};
+
+// States for Task_RunUnionRoom
+enum {
+ UR_STATE_INIT,
+ UR_STATE_INIT_OBJECTS,
+ UR_STATE_INIT_LINK,
+ UR_STATE_CHECK_SELECTING_MON,
+ UR_STATE_MAIN,
+ UR_STATE_DO_SOMETHING_PROMPT,
+ UR_STATE_HANDLE_DO_SOMETHING_PROMPT_INPUT,
+ UR_STATE_DO_SOMETHING_PROMPT_2,
+ UR_STATE_PRINT_MSG,
+ UR_STATE_HANDLE_ACTIVITY_REQUEST,
+ UR_STATE_DECLINE_ACTIVITY_REQUEST,
+ UR_STATE_PLAYER_CONTACTED_YOU,
+ UR_STATE_RECV_CONTACT_DATA,
+ UR_STATE_PRINT_START_ACTIVITY_MSG,
+ UR_STATE_START_ACTIVITY_LINK,
+ UR_STATE_START_ACTIVITY_WAIT_FOR_LINK,
+ UR_STATE_START_ACTIVITY_FREE_UROOM,
+ UR_STATE_START_ACTIVITY_FADE,
+ UR_STATE_START_ACTIVITY,
+ UR_STATE_RECV_JOIN_CHAT_REQUEST,
+ UR_STATE_TRY_ACCEPT_CHAT_REQUEST_DELAY,
+ UR_STATE_TRY_ACCEPT_CHAT_REQUEST,
+ UR_STATE_ACCEPT_CHAT_REQUEST,
+ UR_STATE_WAIT_FOR_START_MENU,
+ UR_STATE_INTERACT_WITH_PLAYER,
+ UR_STATE_TRY_COMMUNICATING,
+ UR_STATE_PRINT_AND_EXIT,
+ UR_STATE_SEND_ACTIVITY_REQUEST,
+ UR_STATE_TRAINER_APPEARS_BUSY,
+ UR_STATE_WAIT_FOR_RESPONSE_TO_REQUEST,
+ UR_STATE_CANCEL_ACTIVITY_LINK_ERROR,
+ UR_STATE_SEND_TRADE_REQUST,
+ UR_STATE_REQUEST_DECLINED,
+ UR_STATE_PRINT_CONTACT_MSG,
+ UR_STATE_HANDLE_CONTACT_DATA,
+ UR_STATE_RECV_ACTIVITY_REQUEST,
+ UR_STATE_CANCEL_REQUEST_PRINT_MSG,
+ UR_STATE_CANCEL_REQUEST_RESTART_LINK,
+ UR_STATE_COMMUNICATING_WAIT_FOR_DATA,
+ UR_STATE_WAIT_FOR_CONTACT_DATA,
+ UR_STATE_PRINT_CARD_INFO,
+ UR_STATE_WAIT_FINISH_READING_CARD,
+ UR_STATE_INTERACT_WITH_ATTENDANT,
+ UR_STATE_REGISTER_PROMPT,
+ UR_STATE_CANCEL_REGISTRATION_PROMPT,
+ UR_STATE_CHECK_TRADING_BOARD,
+ UR_STATE_TRADING_BOARD_LOAD,
+ UR_STATE_REGISTER_PROMPT_HANDLE_INPUT,
+ UR_STATE_TRADING_BOARD_HANDLE_INPUT,
+ UR_STATE_TRADE_PROMPT,
+ UR_STATE_TRADE_SELECT_MON,
+ UR_STATE_TRADE_OFFER_MON,
+ UR_STATE_REGISTER_REQUEST_TYPE,
+ UR_STATE_REGISTER_SELECT_MON_FADE,
+ UR_STATE_REGISTER_SELECT_MON,
+ UR_STATE_REGISTER_COMPLETE,
+ UR_STATE_CANCEL_REGISTRATION,
+};
+
+// States for sUnionRoomTrade.state
+enum {
+ URTRADE_STATE_NONE,
+ URTRADE_STATE_REGISTERING,
+ URTRADE_STATE_OFFERING,
+};
+
+// States for Task_TryBecomeLinkLeader
+enum {
+ LL_STATE_INIT,
+ LL_STATE_INIT2 = 3,
+ LL_STATE_GET_AWAITING_PLAYERS_TEXT,
+ LL_STATE_PRINT_AWAITING_PLAYERS,
+ LL_STATE_AWAIT_PLAYERS,
+ LL_STATE_ACCEPT_NEW_MEMBER_PROMPT,
+ LL_STATE_9 = 9,
+ LL_STATE_MEMBER_LEFT,
+ LL_STATE_ACCEPT_NEW_MEMBER_PROMPT_HANDLE_INPUT,
+ LL_STATE_UPDATE_AFTER_JOIN_REQUEST,
+ LL_STATE_ACCEPTED_FINAL_MEMBER,
+ LL_STATE_WAIT_AND_CONFIRM_MEMBERS,
+ LL_STATE_MEMBERS_OK_PROMPT,
+ LL_STATE_MEMBERS_OK_PROMPT_HANDLE_INPUT,
+ LL_STATE_CONFIRMED_MEMBERS,
+ LL_STATE_FINAL_MEMBER_CHECK,
+ LL_STATE_CANCEL_PROMPT,
+ LL_STATE_CANCEL_PROMPT_HANDLE_INPUT,
+ LL_STATE_SHUTDOWN_AND_RETRY,
+ LL_STATE_RETRY,
+ LL_STATE_SHUTDOWN_AND_FAIL,
+ LL_STATE_FAILED,
+ LL_STATE_TRY_START_ACTIVITY = 26,
+ LL_STATE_MEMBER_DISCONNECTED = 29,
+ LL_STATE_CANCEL_WITH_MSG
+};
+
+// States for Task_TryJoinLinkGroup
+enum {
+ LG_STATE_INIT,
+ LG_STATE_CHOOSE_LEADER_MSG,
+ LG_STATE_INIT_WINDOWS,
+ LG_STATE_CHOOSE_LEADER_HANDLE_INPUT,
+ LG_STATE_ASK_JOIN_GROUP = 5,
+ LG_STATE_MAIN,
+ LG_STATE_ASK_LEAVE_GROUP,
+ LG_STATE_ASK_LEAVE_GROUP_HANDLE_INPUT,
+ LG_STATE_WAIT_LEAVE_GROUP,
+ LG_STATE_CANCEL_CHOOSE_LEADER,
+ LG_STATE_CANCELED,
+ LG_STATE_RFU_ERROR,
+ LG_STATE_RFU_ERROR_SHUTDOWN,
+ LG_STATE_DISCONNECTED,
+ LG_STATE_RETRY_CONNECTION,
+ LG_STATE_TRADE_NOT_READY = 18,
+ LG_STATE_TRADE_NOT_READY_RETRY,
+ LG_STATE_READY_START_ACTIVITY,
+ LG_STATE_START_ACTIVITY,
+ LG_STATE_SHUTDOWN = 23,
+};
+
+static EWRAM_DATA u8 sUnionRoomPlayerName[12] = {};
+EWRAM_DATA u8 gPlayerCurrActivity = 0;
+static EWRAM_DATA u8 sPlayerActivityGroupSize = 0;
+static EWRAM_DATA union WirelessLink_Main sWirelessLinkMain = {};
+static EWRAM_DATA u32 sUnused = 0;
+EWRAM_DATA struct GFtgtGnameSub gPartnerTgtGnameSub = {};
EWRAM_DATA u16 gUnionRoomOfferedSpecies = 0;
EWRAM_DATA u8 gUnionRoomRequestedMonType = 0;
static EWRAM_DATA struct UnionRoomTrade sUnionRoomTrade = {};
// IWRAM vars
-static struct UnkStruct_Leader *gUnknown_03000DA0;
-static struct UnkStruct_Group *gUnknown_03000DA4;
-static struct UnkStruct_URoom *gUnknown_03000DA8;
+static struct WirelessLink_Leader *sLeader;
+static struct WirelessLink_Group *sGroup;
+static struct WirelessLink_URoom *sURoom;
// this file's functions
-void sub_80173E0(u8 windowId, u8 arg1, const u8 *str, u8 arg3, u8 arg4, u8 arg5);
-u16 ReadAsU16(const u8 *ptr);
-void sub_8012780(u8 taskId);
-void sub_80134E8(u8 taskId);
-void sub_8013C7C(u8 taskId);
-void sub_8014A40(u8 taskId);
-void sub_8014F48(u8 taskId);
-void sub_80152F4(u8 taskId);
-void sub_80156E0(u8 taskId);
-void sub_80175EC(struct UnkStruct_Main4 *arg0, u8 count);
-void sub_8017580(struct UnkStruct_x20 *arg0, u8 count);
-u8 sub_8016FC0(struct UnkStruct_Main4 *arg0, u32 arg1);
-u8 sub_8016FF0(struct UnkStruct_Main4 *arg0, u32 arg1);
-bool8 PrintOnTextbox(u8 *textState, const u8 *str);
-bool8 sub_801320C(struct UnkStruct_Leader *data, u32 arg1, u32 arg2);
-u8 sub_8013398(struct UnkStruct_Main0 *arg0);
-s8 sub_80170B8(u8 *arg0, bool32 arg1);
-void sub_8018404(u8 *dest, struct UnkStruct_x20 *arg1);
-void sub_8012F64(struct UnkStruct_Leader *data);
-void sub_80149C4(void);
-u8 sub_80132D4(struct UnkStruct_Main0 *arg0);
-void sub_80178A0(u8 arg0, u8 arg1, u8 arg2, struct UnkStruct_x20 *arg3, u8 arg4, u8 id);
-u32 sub_80176E4(struct UnkStruct_x20 *arg0, struct UnkStruct_x1C *arg1);
-u8 sub_8017734(struct UnkStruct_x20 *arg0, struct UnkStruct_x1C *arg1, u8 arg2);
-u8 sub_8013E44(void);
-u32 sub_8013B8C(struct UnkStruct_Group *arg0, s32 id);
-void sub_8013BD8(struct UnkStruct_Group *arg0, s32 id);
-void sub_80173D4(void);
-void sub_80177B8(u8 arg0, u8 arg1, u8 arg2, struct UnkStruct_x20 *arg3, u8 arg4, u8 id);
-bool32 sub_8017678(struct UnkStruct_Shared *arg0, struct UnkStruct_Shared *arg1);
-static u32 GetPartyPositionOfRegisteredMon(struct UnionRoomTrade *arg0, u8 multiplayerId);
-static void ResetUnionRoomTrade(struct UnionRoomTrade *arg0);
-void sub_801AC54(void);
-void sub_80149D8(void);
-void MG_DrawTextBorder(u8 windowId);
-s8 mevent_message_print_and_prompt_yes_no(u8 *textState, u8 *arg1, u8 arg2, const u8 *str);
-bool32 sub_8016F1C(struct GFtgtGname *arg0, s16 arg1);
-u8 sub_8016DF0(struct UnkStruct_Main4 *arg0, struct UnkStruct_Main4 *arg1, u32 arg2);
-void sub_8019F2C(void);
-static bool32 RegisterTradeMonAndGetIsEgg(u32 monId, struct UnionRoomTrade *trade);
-static void RegisterTradeMon(u32 monId, struct UnionRoomTrade *arg1);
-void sub_80181CC(void);
-bool32 sub_8017940(void);
-u8 sub_8016B00(void);
-void sub_801A274(struct UnkStruct_URoom *arg0);
-bool32 sub_8017FD8(struct UnkStruct_URoom *arg0);
-void sub_801689C(struct UnkStruct_URoom *arg0);
-u8 sub_80181DC(struct UnkStruct_URoom *arg0);
-bool32 sub_80168DC(struct UnkStruct_URoom *arg0);
-bool32 sub_801704C(void);
-s32 sub_8017CF8(s32 arg1, struct UnkStruct_Main0 *arg0);
-s32 sub_80179D4(struct UnkStruct_Main0 *arg0, u8 arg1, u8 arg2, u32 playerGender);
-void sub_801818C(bool32 arg0);
-s32 sub_8017178(u8 *arg0, u8 *arg1, u8 *arg2, const struct WindowTemplate *winTemplate, const struct ListMenuTemplate *menuTemplate);
-s32 sub_80172A0(u8 *arg0, u8 *arg1, u8 *arg2, u8 *arg3, const struct WindowTemplate *winTemplate, const struct ListMenuTemplate *menuTemplate, struct UnkStruct_Main0 *arg6);
-s32 sub_8017CB0(struct UnkStruct_x20 * arg, s32 arg1);
-bool32 HasAtLeastTwoMonsOfLevel30OrLower(void);
-u32 sub_8017984(s32 arg0);
-void sub_8018220(u8 *unused, struct UnkStruct_URoom *arg1, bool8 arg2);
-void sub_8017D9C(u8 *dst, s32 arg1, u32 playerGender);
-u32 sub_80179AC(struct UnkStruct_x20 *arg0);
-void sub_8017E00(u8 *dst, u8 arg1);
-void sub_80173B0(void);
-s32 sub_8017D04(u32 type, u32 species);
-bool32 sub_8017020(const u8 *src);
-u8 sub_8019BA8(struct UnkStruct_8019BA8 * );
-s32 sub_8017EA0(u8 *dst, u32 gender, u16 *arg2, struct UnkStruct_URoom *arg3);
-void sub_801697C(u8 taskId);
-bool8 sub_8017630(struct UnkStruct_Shared* arg0, const struct UnkStruct_Shared* arg1);
-void sub_8013278(u8 windowId, s32 itemId, u8 y);
-void sub_8013DF4(u8 windowId, s32 itemId, u8 y);
-void sub_8017BE8(u8 windowId, s32 itemId, u8 y);
-void nullsub_14(u8 windowId, s32 itemId, u8 y);
+static void UR_AddTextPrinterParameterized(u8, u8, const u8 *, u8, u8, u8);
+static u16 ReadAsU16(const u8 *);
+static void Task_TryBecomeLinkLeader(u8);
+static void Task_TryJoinLinkGroup(u8);
+static void Task_ListenToWireless(u8);
+static void Task_MEvent_Leader(u8);
+static void Task_CardOrNewsWithFriend(u8);
+static void Task_CardOrNewsOverWireless(u8);
+static void Task_RunUnionRoom(u8);
+static void ClearUnkStruct_x1CArray(struct UnkStruct_Main4 *, u8);
+static void ClearUnkStruct_x20Array(struct UnkStruct_x20 *, u8);
+static u8 CreateTask_ListenForPartnersWithCompatibleSerialNos(struct UnkStruct_Main4 *, u32);
+static u8 CreateTask_ListenForPartnersWithSerial7F7D(struct UnkStruct_Main4 *, u32 );
+static bool8 PrintOnTextbox(u8 *, const u8 *);
+static bool8 Leader_SetStateIfMemberListChanged(struct WirelessLink_Leader *, u32, u32);
+static u8 sub_8013398(struct UnkStruct_Main0 *);
+static s8 UnionRoomHandleYesNo(u8 *, bool32);
+static void IntlConvPartnerUname7(u8 *, struct UnkStruct_x20 *);
+static void Leader_DestroyResources(struct WirelessLink_Leader *);
+static void CreateTask_RunScriptAndFadeToActivity(void);
+static u8 LeaderUpdateGroupMembership(struct UnkStruct_Main0 *);
+static void PrintGroupMemberCandidateOnWindowWithColor(u8, u8, u8, struct UnkStruct_x20 *, u8, u8 );
+static u32 Findx20Inx1CArray(struct UnkStruct_x20 *, struct UnkStruct_x1C *);
+static u8 Appendx1Ctox20(struct UnkStruct_x20 *, struct UnkStruct_x1C *, u8);
+static u8 GetNewLeaderCandidate(void);
+static u32 IsTryingToTradeAcrossVersionTooSoon(struct WirelessLink_Group *, s32);
+static void AskToJoinRfuGroup(struct WirelessLink_Group *, s32);
+static void JoinGroup_EnableScriptContexts(void);
+static void PrintUnionRoomGroupOnWindow(u8, u8, u8, struct UnkStruct_x20 *, u8, u8);
+static bool32 AreUnionRoomPlayerGnamesDifferent(struct WirelessGnameUnamePair *, struct WirelessGnameUnamePair *);
+static u32 GetPartyPositionOfRegisteredMon(struct UnionRoomTrade *, u8);
+static void ResetUnionRoomTrade(struct UnionRoomTrade *);
+static void CreateTask_StartActivity(void);
+static bool32 HasWonderCardOrNewsByLinkGroup(struct GFtgtGname *, s16);
+static u8 CreateTask_SearchForChildOrParent(struct UnkStruct_Main4 *, struct UnkStruct_Main4 *, u32);
+static bool32 RegisterTradeMonAndGetIsEgg(u32, struct UnionRoomTrade *);
+static void RegisterTradeMon(u32, struct UnionRoomTrade *);
+static void UR_EnableScriptContext2AndFreezeObjectEvents(void);
+static bool32 IsPlayerFacingTradingBoard(void);
+static u8 HandlePlayerListUpdate(void);
+static bool32 PollPartnerYesNoResponse(struct WirelessLink_URoom *);
+static void ReceiveUnionRoomActivityPacket(struct WirelessLink_URoom *);
+static u8 GetActivePartnerSpriteGenderParam(struct WirelessLink_URoom *);
+static bool32 UnionRoom_HandleContactFromOtherPlayer(struct WirelessLink_URoom *);
+static bool32 UR_RunTextPrinters_CheckPrinter0Active(void);
+static s32 GetUnionRoomPlayerGender(s32, struct UnkStruct_Main0 *);
+static s32 UnionRoomGetPlayerInteractionResponse(struct UnkStruct_Main0 *, u8, u8, u32);
+static void HandleCancelActivity(bool32);
+static s32 ListMenuHandler_AllItemsAvailable(u8 *, u8 *, u8 *, const struct WindowTemplate *, const struct ListMenuTemplate *);
+static s32 TradeBoardMenuHandler(u8 *, u8 *, u8 *, u8 *, const struct WindowTemplate *, const struct ListMenuTemplate *, struct UnkStruct_Main0 *);
+static s32 GetIndexOfNthTradeBoardOffer(struct UnkStruct_x20 *, s32);
+static bool32 HasAtLeastTwoMonsOfLevel30OrLower(void);
+static u32 GetResponseIdx_InviteToURoomActivity(s32);
+static void ViewURoomPartnerTrainerCard(u8 *, struct WirelessLink_URoom *, bool8);
+static void GetURoomActivityRejectMsg(u8 *, s32, u32);
+static u32 ConvPartnerUnameAndGetWhetherMetAlready(struct UnkStruct_x20 *);
+static void GetURoomActivityStartMsg(u8 *, u8);
+static void UR_ClearBg0(void);
+static s32 IsRequestedTypeOrEggInPlayerParty(u32, u32);
+static bool32 UR_PrintFieldMessage(const u8 *);
+static s32 GetChatLeaderActionRequestMessage(u8 *, u32, u16 *, struct WirelessLink_URoom *);
+static void Task_InitUnionRoom(u8 taskId);
+static bool8 AreGnameUnameDifferent(struct WirelessGnameUnamePair*, const struct WirelessGnameUnamePair*);
+static void ItemPrintFunc_PossibleGroupMembers(u8, s32, u8);
+static void ListMenuItemPrintFunc_UnionRoomGroups(u8, s32, u8);
+static void TradeBoardListMenuItemPrintFunc(u8, s32, u8);
+static void nullsub_14(u8, s32, u8);
#include "data/union_room.h"
// code
-void sub_80124EC(u8 windowId, u8 arg1, u8 stringId)
+static void PrintNumPlayersWaitingForMsg(u8 windowId, u8 capacityCode, u8 stringId)
{
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
- switch (arg1 << 8)
+ switch (capacityCode << 8)
{
- case 0x200:
- sub_80173E0(windowId, 1, sPlayersNeededOrModeTexts[0][stringId - 1], 0, 1, 0);
+ case LINK_GROUP_CAPACITY(0, 2):
+ UR_AddTextPrinterParameterized(windowId, 1, sPlayersNeededOrModeTexts[0][stringId - 1], 0, 1, UR_COLOR_DKE_WHT_LTE);
break;
- case 0x400:
- sub_80173E0(windowId, 1, sPlayersNeededOrModeTexts[1][stringId - 1], 0, 1, 0);
+ case LINK_GROUP_CAPACITY(0, 4):
+ UR_AddTextPrinterParameterized(windowId, 1, sPlayersNeededOrModeTexts[1][stringId - 1], 0, 1, UR_COLOR_DKE_WHT_LTE);
break;
- case 0x2500:
- sub_80173E0(windowId, 1, sPlayersNeededOrModeTexts[2][stringId - 1], 0, 1, 0);
+ case LINK_GROUP_CAPACITY(2, 5):
+ UR_AddTextPrinterParameterized(windowId, 1, sPlayersNeededOrModeTexts[2][stringId - 1], 0, 1, UR_COLOR_DKE_WHT_LTE);
break;
- case 0x3500:
- sub_80173E0(windowId, 1, sPlayersNeededOrModeTexts[3][stringId - 1], 0, 1, 0);
+ case LINK_GROUP_CAPACITY(3, 5):
+ UR_AddTextPrinterParameterized(windowId, 1, sPlayersNeededOrModeTexts[3][stringId - 1], 0, 1, UR_COLOR_DKE_WHT_LTE);
break;
- case 0x2400:
- sub_80173E0(windowId, 1, sPlayersNeededOrModeTexts[4][stringId - 1], 0, 1, 0);
+ case LINK_GROUP_CAPACITY(2, 4):
+ UR_AddTextPrinterParameterized(windowId, 1, sPlayersNeededOrModeTexts[4][stringId - 1], 0, 1, UR_COLOR_DKE_WHT_LTE);
break;
}
CopyWindowToVram(windowId, 2);
}
-void sub_80125BC(u8 windowId)
+static void PrintPlayerNameAndIdOnWindow(u8 windowId)
{
u8 text[30];
u8 *txtPtr;
- sub_80173E0(windowId, 1, gSaveBlock2Ptr->playerName, 0, 1, 0);
+ UR_AddTextPrinterParameterized(windowId, 1, gSaveBlock2Ptr->playerName, 0, 1, UR_COLOR_DKE_WHT_LTE);
txtPtr = StringCopy(text, sText_ID);
ConvertIntToDecimalStringN(txtPtr, ReadAsU16(gSaveBlock2Ptr->playerTrainerId), STR_CONV_MODE_LEADING_ZEROS, 5);
- sub_80173E0(windowId, 1, text, 0, 0x11, 0);
+ UR_AddTextPrinterParameterized(windowId, 1, text, 0, 0x11, UR_COLOR_DKE_WHT_LTE);
}
-void sub_801262C(u8 *dst, u8 caseId)
+static void StringExpandPlaceholders_AwaitingCommFromAnother(u8 *dst, u8 caseId)
{
switch (caseId)
{
- case 1 ... 4:
- case 9 ... 11:
- case 14 ... 16:
- case 21 ... 28:
+ case ACTIVITY_BATTLE_SINGLE:
+ case ACTIVITY_BATTLE_DOUBLE:
+ case ACTIVITY_BATTLE_MULTI:
+ case ACTIVITY_TRADE:
+ case ACTIVITY_POKEMON_JUMP:
+ case ACTIVITY_BERRY_CRUSH:
+ case ACTIVITY_BERRY_PICK:
+ case ACTIVITY_BATTLE_TOWER:
+ case ACTIVITY_BATTLE_TOWER_OPEN:
+ case ACTIVITY_RECORD_CORNER:
+ case ACTIVITY_BERRY_BLENDER:
+ case ACTIVITY_WONDER_CARD2:
+ case ACTIVITY_WONDER_NEWS2:
+ case ACTIVITY_CONTEST_COOL:
+ case ACTIVITY_CONTEST_BEAUTY:
+ case ACTIVITY_CONTEST_CUTE:
+ case ACTIVITY_CONTEST_SMART:
+ case ACTIVITY_CONTEST_TOUGH:
// UB: argument *dst isn't used, instead it always prints to gStringVar4
StringExpandPlaceholders(gStringVar4, sText_AwaitingCommunication);
break;
}
}
-bool32 sub_80126CC(u32 caseId)
+static bool32 IsActivityWithVariableGroupSize(u32 caseId)
{
switch (caseId)
{
- case 9 ... 11:
- case 15 ... 16:
- case 23 ... 27:
+ case ACTIVITY_POKEMON_JUMP:
+ case ACTIVITY_BERRY_CRUSH:
+ case ACTIVITY_BERRY_PICK:
+ case ACTIVITY_RECORD_CORNER:
+ case ACTIVITY_BERRY_BLENDER:
+ case ACTIVITY_CONTEST_COOL:
+ case ACTIVITY_CONTEST_BEAUTY:
+ case ACTIVITY_CONTEST_CUTE:
+ case ACTIVITY_CONTEST_SMART:
+ case ACTIVITY_CONTEST_TOUGH:
return TRUE;
default:
return FALSE;
@@ -213,331 +349,334 @@ bool32 sub_80126CC(u32 caseId)
void TryBecomeLinkLeader(void)
{
u8 taskId;
- struct UnkStruct_Leader *dataPtr;
+ struct WirelessLink_Leader *data;
- taskId = CreateTask(sub_8012780, 0);
- gUnknown_02022C30.leader = dataPtr = (void*)(gTasks[taskId].data);
- gUnknown_03000DA0 = dataPtr;
+ taskId = CreateTask(Task_TryBecomeLinkLeader, 0);
+ sWirelessLinkMain.leader = data = (void*)(gTasks[taskId].data);
+ sLeader = data;
- dataPtr->state = 0;
- dataPtr->textState = 0;
- gSpecialVar_Result = 0;
+ data->state = LL_STATE_INIT;
+ data->textState = 0;
+ gSpecialVar_Result = LINKUP_ONGOING;
}
-void sub_8012780(u8 taskId)
+static void Task_TryBecomeLinkLeader(u8 taskId)
{
u32 id, val;
- struct UnkStruct_Leader *data = gUnknown_02022C30.leader;
+ struct WirelessLink_Leader *data = sWirelessLinkMain.leader;
switch (data->state)
{
- case 0:
+ case LL_STATE_INIT:
if (gSpecialVar_0x8004 == LINK_GROUP_BATTLE_TOWER && gSaveBlock2Ptr->frontier.lvlMode == FRONTIER_LVL_OPEN)
gSpecialVar_0x8004++;
- gUnknown_02022C2C = gUnknown_082F00C4[gSpecialVar_0x8004];
- gUnknown_02022C2D = gUnknown_082F00C4[gSpecialVar_0x8004] >> 8;
- sub_8010F84(gUnknown_02022C2C, 0, 0);
- sub_800B488();
+ gPlayerCurrActivity = sLinkGroupToActivityAndCapacity[gSpecialVar_0x8004];
+ sPlayerActivityGroupSize = sLinkGroupToActivityAndCapacity[gSpecialVar_0x8004] >> 8;
+ SetHostRFUtgtGname(gPlayerCurrActivity, 0, 0);
+ SetWirelessCommType1();
OpenLink();
- sub_8011C10(gUnknown_02022C2D & 0xF);
- data->state = 3;
- break;
- case 3:
- data->field_4 = AllocZeroed(0x70);
- data->field_0 = AllocZeroed(0xA0);
- data->field_8 = AllocZeroed(0xA0);
- sub_80175EC(data->field_4, 4);
- sub_8017580(data->field_0->arr, 5);
- sub_800DF90(&data->field_0->arr[0].unk.field_0, data->field_0->arr[0].unk.playerName);
- data->field_0->arr[0].field_18 = 0;
- data->field_0->arr[0].field_1A_0 = 1;
- data->field_0->arr[0].field_1A_1 = 0;
+ InitializeRfuLinkManager_LinkLeader(GROUP_MAX(sPlayerActivityGroupSize));
+ data->state = LL_STATE_INIT2;
+ break;
+ case LL_STATE_INIT2:
+ data->field_4 = AllocZeroed(4 * sizeof(struct UnkStruct_x1C));
+ data->field_0 = AllocZeroed(5 * sizeof(struct UnkStruct_x20));
+ data->field_8 = AllocZeroed(5 * sizeof(struct UnkStruct_x20));
+ ClearUnkStruct_x1CArray(data->field_4, 4);
+ ClearUnkStruct_x20Array(data->field_0->arr, 5);
+ LinkRfu3_SetGnameUnameFromStaticBuffers(&data->field_0->arr[0].gname_uname.gname, data->field_0->arr[0].gname_uname.playerName);
+ data->field_0->arr[0].timeoutCounter = 0;
+ data->field_0->arr[0].groupScheduledAnim = UNION_ROOM_SPAWN_IN;
+ data->field_0->arr[0].useRedText = FALSE;
data->field_0->arr[0].field_1B = 0;
- data->field_17 = sub_8016FC0(data->field_4, 0xFF);
- data->field_10 = AddWindow(&gUnknown_082F00BC);
- switch (gUnknown_02022C2D & 0xF)
+ data->listenTaskId = CreateTask_ListenForPartnersWithCompatibleSerialNos(data->field_4, 0xFF);
+ data->bButtonCancelWindowId = AddWindow(&sWindowTemplate_BButtonCancel);
+ switch (GROUP_MAX(sPlayerActivityGroupSize))
{
case 2:
case 3:
case 4:
- data->listWindowId = AddWindow(&gUnknown_082F011C);
+ data->listWindowId = AddWindow(&sWindowTemplate_PlayerList);
break;
case 5:
- data->listWindowId = AddWindow(&gUnknown_082F0124);
+ data->listWindowId = AddWindow(&sWindowTemplate_5PlayerList);
break;
}
- data->field_11 = AddWindow(&gUnknown_082F012C);
+ data->nPlayerModeWindowId = AddWindow(&sWindowTemplate_NumPlayerMode);
- FillWindowPixelBuffer(data->field_10, PIXEL_FILL(2));
- sub_80173E0(data->field_10, 0, sText_BButtonCancel, 8, 1, 4);
- PutWindowTilemap(data->field_10);
- CopyWindowToVram(data->field_10, 2);
+ FillWindowPixelBuffer(data->bButtonCancelWindowId, PIXEL_FILL(2));
+ UR_AddTextPrinterParameterized(data->bButtonCancelWindowId, 0, sText_BButtonCancel, 8, 1, 4);
+ PutWindowTilemap(data->bButtonCancelWindowId);
+ CopyWindowToVram(data->bButtonCancelWindowId, 2);
DrawStdWindowFrame(data->listWindowId, FALSE);
- gMultiuseListMenuTemplate = gUnknown_082F015C;
+ gMultiuseListMenuTemplate = sListMenuTemplate_PossibleGroupMembers;
gMultiuseListMenuTemplate.windowId = data->listWindowId;
data->listTaskId = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0);
- DrawStdWindowFrame(data->field_11, FALSE);
- PutWindowTilemap(data->field_11);
- CopyWindowToVram(data->field_11, 2);
+ DrawStdWindowFrame(data->nPlayerModeWindowId, FALSE);
+ PutWindowTilemap(data->nPlayerModeWindowId);
+ CopyWindowToVram(data->nPlayerModeWindowId, 2);
CopyBgTilemapBufferToVram(0);
- data->field_13 = 1;
- data->state = 4;
+ data->playerCount = 1;
+ data->state = LL_STATE_GET_AWAITING_PLAYERS_TEXT;
break;
- case 4:
- StringCopy(gStringVar1, sLinkGroupActivityTexts[gUnknown_02022C2C]);
- if ((gUnknown_02022C2D >> 4) != 0)
+ case LL_STATE_GET_AWAITING_PLAYERS_TEXT:
+ StringCopy(gStringVar1, sLinkGroupActivityNameTexts[gPlayerCurrActivity]);
+ if (GROUP_MIN(sPlayerActivityGroupSize) != 0)
{
- if (data->field_13 > (gUnknown_02022C2D >> 4) - 1 && (gUnknown_02022C2D & 0xF) != 0)
+ if (data->playerCount > GROUP_MIN(sPlayerActivityGroupSize) - 1 && GROUP_MAX(sPlayerActivityGroupSize) != 0)
StringExpandPlaceholders(gStringVar4, sText_AwaitingLinkPressStart);
else
StringExpandPlaceholders(gStringVar4, sText_AwaitingCommunication);
}
else
{
- sub_801262C(gStringVar4, gUnknown_02022C2C);
+ StringExpandPlaceholders_AwaitingCommFromAnother(gStringVar4, gPlayerCurrActivity);
}
- sub_80124EC(data->field_11, gUnknown_02022C2D, data->field_13);
- data->state = 5;
+ PrintNumPlayersWaitingForMsg(data->nPlayerModeWindowId, sPlayerActivityGroupSize, data->playerCount);
+ data->state = LL_STATE_PRINT_AWAITING_PLAYERS;
break;
- case 5:
+ case LL_STATE_PRINT_AWAITING_PLAYERS:
if (PrintOnTextbox(&data->textState, gStringVar4))
- data->state = 6;
+ data->state = LL_STATE_AWAIT_PLAYERS;
break;
- case 6:
- sub_801320C(data, 7, 10);
+ case LL_STATE_AWAIT_PLAYERS:
+ Leader_SetStateIfMemberListChanged(data, LL_STATE_ACCEPT_NEW_MEMBER_PROMPT, LL_STATE_MEMBER_LEFT);
if (gMain.newKeys & B_BUTTON)
{
- if (data->field_13 == 1)
- data->state = 23;
- else if ((gUnknown_02022C2D & 0xF0) != 0)
- data->state = 30;
+ if (data->playerCount == 1)
+ data->state = LL_STATE_SHUTDOWN_AND_FAIL;
+ else if (GROUP_MIN2(sPlayerActivityGroupSize) != 0)
+ data->state = LL_STATE_CANCEL_WITH_MSG;
else
- data->state = 19;
+ data->state = LL_STATE_CANCEL_PROMPT;
}
- if ((gUnknown_02022C2D >> 4) != 0
- && data->field_13 > (gUnknown_02022C2D >> 4) - 1
- && (gUnknown_02022C2D & 0xF) != 0
+ if (GROUP_MIN(sPlayerActivityGroupSize) != 0
+ && data->playerCount > GROUP_MIN(sPlayerActivityGroupSize) - 1
+ && GROUP_MAX(sPlayerActivityGroupSize) != 0
&& sub_8012240()
&& gMain.newKeys & START_BUTTON)
{
- data->state = 15;
- sub_800EF38();
+ data->state = LL_STATE_MEMBERS_OK_PROMPT;
+ LinkRfu_StopManagerAndFinalizeSlots();
}
- if (data->state == 6 && sub_80105EC())
+ if (data->state == LL_STATE_AWAIT_PLAYERS && sub_80105EC())
{
- data->state = 9;
+ data->state = LL_STATE_9;
}
break;
- case 9:
+ case LL_STATE_9:
if (!sub_80105EC())
{
- data->state = 6;
- data->field_13 = sub_8013398(data->field_0);
+ data->state = LL_STATE_AWAIT_PLAYERS;
+ data->playerCount = sub_8013398(data->field_0);
}
break;
- case 10:
- id = ((gUnknown_02022C2C & 0xF) == 2) ? 1 : 0;
+ case LL_STATE_MEMBER_LEFT:
+ // BUG: sPlayerActivityGroupSize was meant below, not gPlayerCurrActivity
+ // This will be false for all but ACTIVITY_BATTLE_DOUBLE and ACTIVITY_DECLINE
+ // All this changes is which of two texts gets printed
+ id = (GROUP_MAX(gPlayerCurrActivity) == 2) ? 1 : 0;
if (PrintOnTextbox(&data->textState, sPlayerUnavailableTexts[id]))
{
- data->field_13 = sub_8013398(data->field_0);
+ data->playerCount = sub_8013398(data->field_0);
RedrawListMenu(data->listTaskId);
- data->state = 4;
+ data->state = LL_STATE_GET_AWAITING_PLAYERS_TEXT;
}
break;
- case 29:
- id = ((gUnknown_02022C2D & 0xF) == 2) ? 0 : 1;
+ case LL_STATE_MEMBER_DISCONNECTED:
+ id = (GROUP_MAX(sPlayerActivityGroupSize) == 2) ? 0 : 1;
if (PrintOnTextbox(&data->textState, sPlayerUnavailableTexts[id]))
{
- data->state = 21;
+ data->state = LL_STATE_SHUTDOWN_AND_RETRY;
}
break;
- case 7:
+ case LL_STATE_ACCEPT_NEW_MEMBER_PROMPT:
if (PrintOnTextbox(&data->textState, gStringVar4))
{
- data->state = 11;
+ data->state = LL_STATE_ACCEPT_NEW_MEMBER_PROMPT_HANDLE_INPUT;
}
break;
- case 11:
- switch (sub_80170B8(&data->textState, sub_801064C(ReadAsU16(data->field_0->arr[data->field_13].unk.field_0.unk_00.playerTrainerId), data->field_0->arr[data->field_13].unk.playerName)))
+ case LL_STATE_ACCEPT_NEW_MEMBER_PROMPT_HANDLE_INPUT:
+ switch (UnionRoomHandleYesNo(&data->textState, HasTrainerLeftPartnersList(ReadAsU16(data->field_0->arr[data->playerCount].gname_uname.gname.unk_00.playerTrainerId), data->field_0->arr[data->playerCount].gname_uname.playerName)))
{
- case 0:
+ case 0: // YES
LoadWirelessStatusIndicatorSpriteGfx();
CreateWirelessStatusIndicatorSprite(0, 0);
- data->field_19 = 5;
- sub_8010688(5, ReadAsU16(data->field_0->arr[data->field_13].unk.field_0.unk_00.playerTrainerId), data->field_0->arr[data->field_13].unk.playerName);
- data->state = 12;
+ data->joinRequestAnswer = RFU_STATUS_JOIN_GROUP_OK;
+ SendRfuStatusToPartner(data->joinRequestAnswer, ReadAsU16(data->field_0->arr[data->playerCount].gname_uname.gname.unk_00.playerTrainerId), data->field_0->arr[data->playerCount].gname_uname.playerName);
+ data->state = LL_STATE_UPDATE_AFTER_JOIN_REQUEST;
break;
- case 1:
+ case 1: // NO
case -1:
- data->field_19 = 6;
- sub_8010688(6, ReadAsU16(data->field_0->arr[data->field_13].unk.field_0.unk_00.playerTrainerId), data->field_0->arr[data->field_13].unk.playerName);
- data->state = 12;
+ data->joinRequestAnswer = RFU_STATUS_JOIN_GROUP_NO;
+ SendRfuStatusToPartner(data->joinRequestAnswer, ReadAsU16(data->field_0->arr[data->playerCount].gname_uname.gname.unk_00.playerTrainerId), data->field_0->arr[data->playerCount].gname_uname.playerName);
+ data->state = LL_STATE_UPDATE_AFTER_JOIN_REQUEST;
break;
case -3:
- data->state = 9;
+ data->state = LL_STATE_9;
break;
}
break;
- case 12:
- val = sub_8010714(ReadAsU16(data->field_0->arr[data->field_13].unk.field_0.unk_00.playerTrainerId), data->field_0->arr[data->field_13].unk.playerName);
- if (val == 1)
+ case LL_STATE_UPDATE_AFTER_JOIN_REQUEST:
+ val = WaitSendRfuStatusToPartner(ReadAsU16(data->field_0->arr[data->playerCount].gname_uname.gname.unk_00.playerTrainerId), data->field_0->arr[data->playerCount].gname_uname.playerName);
+ if (val == 1) // Send complete
{
- if (data->field_19 == 5)
+ if (data->joinRequestAnswer == RFU_STATUS_JOIN_GROUP_OK)
{
- data->field_0->arr[data->field_13].field_1B = 0;
+ data->field_0->arr[data->playerCount].field_1B = 0;
RedrawListMenu(data->listTaskId);
- data->field_13++;
- if (data->field_13 == (gUnknown_02022C2D & 0xF))
+ data->playerCount++;
+ if (data->playerCount == GROUP_MAX(sPlayerActivityGroupSize))
{
- if ((gUnknown_02022C2D & 0xF0) != 0 || data->field_13 == 4)
+ if (GROUP_MIN2(sPlayerActivityGroupSize) != 0 || data->playerCount == 4)
{
- data->state = 15;
+ data->state = LL_STATE_MEMBERS_OK_PROMPT;
}
else
{
- sub_8018404(gStringVar1, &data->field_0->arr[data->field_13 - 1]);
+ IntlConvPartnerUname7(gStringVar1, &data->field_0->arr[data->playerCount - 1]);
StringExpandPlaceholders(gStringVar4, sText_AnOKWasSentToPlayer);
- data->state = 13;
+ data->state = LL_STATE_ACCEPTED_FINAL_MEMBER;
}
- sub_800EF38();
- sub_80124EC(data->field_11, gUnknown_02022C2D, data->field_13);
+ LinkRfu_StopManagerAndFinalizeSlots();
+ PrintNumPlayersWaitingForMsg(data->nPlayerModeWindowId, sPlayerActivityGroupSize, data->playerCount);
}
else
{
- data->state = 4;
+ data->state = LL_STATE_GET_AWAITING_PLAYERS_TEXT;
}
}
- else
+ else // Member disconnected
{
- sub_8011DC0(data->field_0->arr[data->field_13].unk.playerName, ReadAsU16(data->field_0->arr[data->field_13].unk.field_0.unk_00.playerTrainerId));
- data->field_0->arr[data->field_13].field_1A_0 = 0;
+ RequestDisconnectSlotByTrainerNameAndId(data->field_0->arr[data->playerCount].gname_uname.playerName, ReadAsU16(data->field_0->arr[data->playerCount].gname_uname.gname.unk_00.playerTrainerId));
+ data->field_0->arr[data->playerCount].groupScheduledAnim = UNION_ROOM_SPAWN_NONE;
sub_8013398(data->field_0);
RedrawListMenu(data->listTaskId);
- data->state = 4;
+ data->state = LL_STATE_GET_AWAITING_PLAYERS_TEXT;
}
- data->field_19 = 0;
+ data->joinRequestAnswer = 0;
}
else if (val == 2)
{
- sub_8011A64(0, 0);
- data->state = 4;
+ RfuSetStatus(RFU_STATUS_OK, 0);
+ data->state = LL_STATE_GET_AWAITING_PLAYERS_TEXT;
}
break;
- case 13:
+ case LL_STATE_ACCEPTED_FINAL_MEMBER:
if (PrintOnTextbox(&data->textState, gStringVar4))
- data->state = 14;
+ data->state = LL_STATE_WAIT_AND_CONFIRM_MEMBERS;
break;
- case 14:
- if (++data->field_E > 120)
- data->state = 17;
+ case LL_STATE_WAIT_AND_CONFIRM_MEMBERS:
+ if (++data->delayTimerAfterOk > 120)
+ data->state = LL_STATE_CONFIRMED_MEMBERS;
break;
- case 15:
+ case LL_STATE_MEMBERS_OK_PROMPT:
if (PrintOnTextbox(&data->textState, sText_AreTheseMembersOK))
- data->state = 16;
+ data->state = LL_STATE_MEMBERS_OK_PROMPT_HANDLE_INPUT;
break;
- case 16:
- switch (sub_80170B8(&data->textState, FALSE))
+ case LL_STATE_MEMBERS_OK_PROMPT_HANDLE_INPUT:
+ switch (UnionRoomHandleYesNo(&data->textState, FALSE))
{
- case 0:
- data->state = 17;
+ case 0: // YES
+ data->state = LL_STATE_CONFIRMED_MEMBERS;
break;
- case 1:
+ case 1: // NO
case -1:
- if ((gUnknown_02022C2D & 0xF0) != 0)
- data->state = 30;
+ if (GROUP_MIN2(sPlayerActivityGroupSize) != 0)
+ data->state = LL_STATE_CANCEL_WITH_MSG;
else
- data->state = 19;
+ data->state = LL_STATE_CANCEL_PROMPT;
break;
}
break;
- case 19:
+ case LL_STATE_CANCEL_PROMPT:
if (PrintOnTextbox(&data->textState, sText_CancelModeWithTheseMembers))
- data->state = 20;
+ data->state = LL_STATE_CANCEL_PROMPT_HANDLE_INPUT;
break;
- case 20:
- switch (sub_80170B8(&data->textState, FALSE))
+ case LL_STATE_CANCEL_PROMPT_HANDLE_INPUT:
+ switch (UnionRoomHandleYesNo(&data->textState, FALSE))
{
- case 0:
- data->state = 23;
+ case 0: // YES
+ data->state = LL_STATE_SHUTDOWN_AND_FAIL;
break;
- case 1:
+ case 1: // NO
case -1:
- if ((gUnknown_02022C2D & 0xF0) != 0)
- data->state = 15;
- else if (data->field_13 == (gUnknown_02022C2D & 0xF))
- data->state = 15;
+ if (GROUP_MIN2(sPlayerActivityGroupSize) != 0)
+ data->state = LL_STATE_MEMBERS_OK_PROMPT;
+ else if (data->playerCount == GROUP_MAX(sPlayerActivityGroupSize))
+ data->state = LL_STATE_MEMBERS_OK_PROMPT;
else
- data->state = 4;
+ data->state = LL_STATE_GET_AWAITING_PLAYERS_TEXT;
break;
}
break;
- case 17:
- if (!sub_801320C(data, 7, 29))
- data->state = 18;
+ case LL_STATE_CONFIRMED_MEMBERS:
+ if (!Leader_SetStateIfMemberListChanged(data, LL_STATE_ACCEPT_NEW_MEMBER_PROMPT, LL_STATE_MEMBER_DISCONNECTED))
+ data->state = LL_STATE_FINAL_MEMBER_CHECK;
break;
- case 18:
- if (sub_800EF1C())
+ case LL_STATE_FINAL_MEMBER_CHECK:
+ if (LmanAcceptSlotFlagIsNotZero())
{
- if (sub_800EF58(FALSE))
+ if (WaitRfuState(FALSE))
{
- data->state = 26;
+ data->state = LL_STATE_TRY_START_ACTIVITY;
}
else
{
- if (++data->field_1A > 300)
+ if (++data->memberConfirmTimeout > 300)
{
- data->state = 29;
+ data->state = LL_STATE_MEMBER_DISCONNECTED;
data->textState = 0;
}
}
}
else
{
- data->state = 29;
+ data->state = LL_STATE_MEMBER_DISCONNECTED;
data->textState = 0;
}
break;
- case 30:
+ case LL_STATE_CANCEL_WITH_MSG:
if (PrintOnTextbox(&data->textState, sText_ModeWithTheseMembersWillBeCanceled))
- data->state = 23;
+ data->state = LL_STATE_SHUTDOWN_AND_FAIL;
break;
- case 21:
- case 23:
+ case LL_STATE_SHUTDOWN_AND_RETRY:
+ case LL_STATE_SHUTDOWN_AND_FAIL:
DestroyWirelessStatusIndicatorSprite();
- sub_800EDD4();
- sub_8012F64(data);
- data->state++;
+ LinkRfu_Shutdown();
+ Leader_DestroyResources(data);
+ data->state++; // LL_STATE_RETRY or LL_STATE_FAILED
break;
- case 24:
+ case LL_STATE_FAILED:
EnableBothScriptContexts();
DestroyTask(taskId);
- gSpecialVar_Result = 5;
+ gSpecialVar_Result = LINKUP_FAILED;
break;
- case 22:
+ case LL_STATE_RETRY:
EnableBothScriptContexts();
DestroyTask(taskId);
- gSpecialVar_Result = 8;
+ gSpecialVar_Result = LINKUP_RETRY_ROLE_ASSIGN;
break;
- case 26:
- if (sub_8011A80())
+ case LL_STATE_TRY_START_ACTIVITY:
+ if (RfuHasErrored())
{
- data->state = 29;
+ data->state = LL_STATE_MEMBER_DISCONNECTED;
}
else
{
if (gReceivedRemoteLinkPlayers != 0)
{
- if (sub_80126CC(gUnknown_02022C2C))
+ if (IsActivityWithVariableGroupSize(gPlayerCurrActivity))
sub_801103C();
- sub_8011068(1);
- sub_80149C4();
- sub_8012F64(data);
+ UpdateGameData_GroupLockedIn(TRUE);
+ CreateTask_RunScriptAndFadeToActivity();
+ Leader_DestroyResources(data);
DestroyTask(taskId);
}
}
@@ -545,319 +684,319 @@ void sub_8012780(u8 taskId)
}
}
-void sub_8012F64(struct UnkStruct_Leader *data)
+static void Leader_DestroyResources(struct WirelessLink_Leader *data)
{
- ClearWindowTilemap(data->field_11);
- ClearStdWindowAndFrame(data->field_11, FALSE);
+ ClearWindowTilemap(data->nPlayerModeWindowId);
+ ClearStdWindowAndFrame(data->nPlayerModeWindowId, FALSE);
DestroyListMenuTask(data->listTaskId, 0, 0);
- ClearWindowTilemap(data->field_10);
+ ClearWindowTilemap(data->bButtonCancelWindowId);
ClearStdWindowAndFrame(data->listWindowId, FALSE);
CopyBgTilemapBufferToVram(0);
- RemoveWindow(data->field_11);
+ RemoveWindow(data->nPlayerModeWindowId);
RemoveWindow(data->listWindowId);
- RemoveWindow(data->field_10);
- DestroyTask(data->field_17);
+ RemoveWindow(data->bButtonCancelWindowId);
+ DestroyTask(data->listenTaskId);
Free(data->field_8);
Free(data->field_0);
Free(data->field_4);
}
-void sub_8012FC4(u8 *dst, u8 caseId)
+static void Leader_GetAcceptNewMemberPrompt(u8 *dst, u8 caseId)
{
switch (caseId)
{
- case 1:
- case 2:
- case 4:
- case 14:
- case 28:
+ case ACTIVITY_BATTLE_SINGLE:
+ case ACTIVITY_BATTLE_DOUBLE:
+ case ACTIVITY_TRADE:
+ case ACTIVITY_BATTLE_TOWER_OPEN:
+ case ACTIVITY_BATTLE_TOWER:
StringExpandPlaceholders(dst, sText_PlayerContactedYouForXAccept);
break;
- case 21:
- case 22:
+ case ACTIVITY_WONDER_CARD2:
+ case ACTIVITY_WONDER_NEWS2:
StringExpandPlaceholders(dst, sText_PlayerContactedYouShareX);
break;
- case 3:
- case 9:
- case 10:
- case 11:
- case 15:
- case 16:
- case 23:
- case 24:
- case 25:
- case 26:
- case 27:
+ case ACTIVITY_BATTLE_MULTI:
+ case ACTIVITY_POKEMON_JUMP:
+ case ACTIVITY_BERRY_CRUSH:
+ case ACTIVITY_BERRY_PICK:
+ case ACTIVITY_RECORD_CORNER:
+ case ACTIVITY_BERRY_BLENDER:
+ case ACTIVITY_CONTEST_COOL:
+ case ACTIVITY_CONTEST_BEAUTY:
+ case ACTIVITY_CONTEST_CUTE:
+ case ACTIVITY_CONTEST_SMART:
+ case ACTIVITY_CONTEST_TOUGH:
StringExpandPlaceholders(dst, sText_PlayerContactedYouAddToMembers);
break;
}
}
-void sub_8013078(u8 *dst, u8 caseId)
+static void GetYouDeclinedTheOfferMessage(u8 *dst, u8 caseId)
{
switch (caseId)
{
- case 65:
- case 68:
+ case ACTIVITY_BATTLE_SINGLE | IN_UNION_ROOM:
+ case ACTIVITY_TRADE | IN_UNION_ROOM:
StringExpandPlaceholders(dst, sText_OfferDeclined1);
break;
- case 69:
- case 72:
+ case ACTIVITY_CHAT | IN_UNION_ROOM:
+ case ACTIVITY_CARD | IN_UNION_ROOM:
StringExpandPlaceholders(dst, sText_OfferDeclined2);
break;
}
}
-void sub_80130B4(u8 *dst, u8 caseId)
+static void GetYouAskedToJoinGroupPleaseWaitMessage(u8 *dst, u8 caseId)
{
switch (caseId)
{
- case 1:
- case 2:
- case 4:
- case 14:
- case 21:
- case 22:
- case 28:
+ case ACTIVITY_BATTLE_SINGLE:
+ case ACTIVITY_BATTLE_DOUBLE:
+ case ACTIVITY_TRADE:
+ case ACTIVITY_BATTLE_TOWER:
+ case ACTIVITY_BATTLE_TOWER_OPEN:
+ case ACTIVITY_WONDER_CARD2:
+ case ACTIVITY_WONDER_NEWS2:
StringExpandPlaceholders(dst, sText_AwaitingPlayersResponse);
break;
- case 3:
- case 9:
- case 10:
- case 11:
- case 15:
- case 16:
- case 23:
- case 24:
- case 25:
- case 26:
- case 27:
+ case ACTIVITY_BATTLE_MULTI:
+ case ACTIVITY_POKEMON_JUMP:
+ case ACTIVITY_BERRY_CRUSH:
+ case ACTIVITY_BERRY_PICK:
+ case ACTIVITY_RECORD_CORNER:
+ case ACTIVITY_BERRY_BLENDER:
+ case ACTIVITY_CONTEST_COOL:
+ case ACTIVITY_CONTEST_BEAUTY:
+ case ACTIVITY_CONTEST_CUTE:
+ case ACTIVITY_CONTEST_SMART:
+ case ACTIVITY_CONTEST_TOUGH:
StringExpandPlaceholders(dst, sText_PlayerHasBeenAskedToRegisterYouPleaseWait);
break;
}
}
-void sub_8013160(u8 *dst, u8 caseId)
+static void GetGroupLeaderSentAnOKMessage(u8 *dst, u8 caseId)
{
switch (caseId)
{
- case 1:
- case 2:
- case 4:
- case 14:
- case 21:
- case 22:
- case 28:
+ case ACTIVITY_BATTLE_SINGLE:
+ case ACTIVITY_BATTLE_DOUBLE:
+ case ACTIVITY_TRADE:
+ case ACTIVITY_BATTLE_TOWER:
+ case ACTIVITY_BATTLE_TOWER_OPEN:
+ case ACTIVITY_WONDER_CARD2:
+ case ACTIVITY_WONDER_NEWS2:
StringExpandPlaceholders(dst, sText_PlayerSentBackOK);
break;
- case 3:
- case 9:
- case 10:
- case 11:
- case 15:
- case 16:
- case 23:
- case 24:
- case 25:
- case 26:
- case 27:
+ case ACTIVITY_BATTLE_MULTI:
+ case ACTIVITY_POKEMON_JUMP:
+ case ACTIVITY_BERRY_CRUSH:
+ case ACTIVITY_BERRY_PICK:
+ case ACTIVITY_RECORD_CORNER:
+ case ACTIVITY_BERRY_BLENDER:
+ case ACTIVITY_CONTEST_COOL:
+ case ACTIVITY_CONTEST_BEAUTY:
+ case ACTIVITY_CONTEST_CUTE:
+ case ACTIVITY_CONTEST_SMART:
+ case ACTIVITY_CONTEST_TOUGH:
StringExpandPlaceholders(dst, sText_PlayerOKdRegistration);
break;
}
}
-bool8 sub_801320C(struct UnkStruct_Leader *data, u32 arg1, u32 arg2)
+static bool8 Leader_SetStateIfMemberListChanged(struct WirelessLink_Leader *data, u32 joinedState, u32 droppedState)
{
- switch (sub_80132D4(data->field_0))
+ switch (LeaderUpdateGroupMembership(data->field_0))
{
- case 1:
+ case UNION_ROOM_SPAWN_IN:
PlaySE(SE_PC_LOGIN);
RedrawListMenu(data->listTaskId);
- sub_8018404(gStringVar2, &data->field_0->arr[data->field_13]);
- sub_8012FC4(gStringVar4, gUnknown_02022C2C);
- data->state = arg1;
+ IntlConvPartnerUname7(gStringVar2, &data->field_0->arr[data->playerCount]);
+ Leader_GetAcceptNewMemberPrompt(gStringVar4, gPlayerCurrActivity);
+ data->state = joinedState;
break;
- case 2:
- sub_8011A64(0, 0);
+ case UNION_ROOM_SPAWN_OUT:
+ RfuSetStatus(RFU_STATUS_OK, 0);
RedrawListMenu(data->listTaskId);
- data->state = arg2;
+ data->state = droppedState;
return TRUE;
}
return FALSE;
}
-void sub_8013278(u8 arg0, s32 id, u8 arg2)
+static void ItemPrintFunc_PossibleGroupMembers(u8 windowId, s32 id, u8 y)
{
- struct UnkStruct_Leader *data = gUnknown_02022C30.leader;
- u8 var = 0;
+ struct WirelessLink_Leader *data = sWirelessLinkMain.leader;
+ u8 colorIdx = UR_COLOR_DKE_WHT_LTE;
- switch (data->field_0->arr[id].field_1A_0)
+ switch (data->field_0->arr[id].groupScheduledAnim)
{
- case 1:
+ case UNION_ROOM_SPAWN_IN:
if (data->field_0->arr[id].field_1B != 0)
- var = 2;
+ colorIdx = UR_COLOR_GRN_WHT_LTG;
break;
- case 2:
- var = 1;
+ case UNION_ROOM_SPAWN_OUT:
+ colorIdx = UR_COLOR_RED_WHT_LTR;
break;
}
- sub_80178A0(arg0, 0, arg2, &data->field_0->arr[id], var, id);
+ PrintGroupMemberCandidateOnWindowWithColor(windowId, 0, y, &data->field_0->arr[id], colorIdx, id);
}
-u8 sub_80132D4(struct UnkStruct_Main0 *arg0)
+static u8 LeaderUpdateGroupMembership(struct UnkStruct_Main0 *arg0)
{
- struct UnkStruct_Leader *data = gUnknown_02022C30.leader;
- u8 ret = 0;
+ struct WirelessLink_Leader *data = sWirelessLinkMain.leader;
+ u8 ret = UNION_ROOM_SPAWN_NONE;
u8 i;
s32 id;
- for (i = 1; i < 5; i++)
+ for (i = 1; i < MAX_RFU_PLAYERS; i++)
{
- u16 var = data->field_0->arr[i].field_1A_0;
- if (var == 1)
+ u16 var = data->field_0->arr[i].groupScheduledAnim;
+ if (var == UNION_ROOM_SPAWN_IN)
{
- id = sub_80176E4(&data->field_0->arr[i], data->field_4->arr);
+ id = Findx20Inx1CArray(&data->field_0->arr[i], data->field_4->arr);
if (id != 0xFF)
{
- data->field_0->arr[i].unk = data->field_4->arr[id].unk0;
- data->field_0->arr[i].field_18 = var;
+ data->field_0->arr[i].gname_uname = data->field_4->arr[id].gname_uname;
+ data->field_0->arr[i].timeoutCounter = 1;
}
else
{
- data->field_0->arr[i].field_1A_0 = 2;
- ret = 2;
+ data->field_0->arr[i].groupScheduledAnim = UNION_ROOM_SPAWN_OUT;
+ ret = UNION_ROOM_SPAWN_OUT;
}
}
}
- for (id = 0; id < 4; id++)
- sub_8017734(data->field_0->arr, &data->field_4->arr[id], 5);
+ for (id = 0; id < RFU_CHILD_MAX; id++)
+ Appendx1Ctox20(data->field_0->arr, &data->field_4->arr[id], MAX_RFU_PLAYERS);
- if (ret != 2)
+ if (ret != UNION_ROOM_SPAWN_OUT)
{
- for (id = 0; id < 5; id++)
+ for (id = 0; id < MAX_RFU_PLAYERS; id++)
{
if (data->field_0->arr[id].field_1B != 0)
- ret = 1;
+ ret = UNION_ROOM_SPAWN_IN;
}
}
return ret;
}
-u8 sub_8013398(struct UnkStruct_Main0 *arg0)
+static u8 sub_8013398(struct UnkStruct_Main0 *arg0)
{
- struct UnkStruct_Leader *data = gUnknown_02022C30.leader;
+ struct WirelessLink_Leader *data = sWirelessLinkMain.leader;
u8 copiedCount;
s32 i;
- u8 ret;
+ u8 playerCount;
- for (i = 0; i < 5; i++)
+ for (i = 0; i < MAX_RFU_PLAYERS; i++)
data->field_8->arr[i] = data->field_0->arr[i];
copiedCount = 0;
- for (i = 0; i < 5; i++)
+ for (i = 0; i < MAX_RFU_PLAYERS; i++)
{
- if (data->field_8->arr[i].field_1A_0 == 1)
+ if (data->field_8->arr[i].groupScheduledAnim == UNION_ROOM_SPAWN_IN)
{
data->field_0->arr[copiedCount] = data->field_8->arr[i];
copiedCount++;
}
}
- ret = copiedCount;
- for (; copiedCount < 5; copiedCount++)
+ playerCount = copiedCount;
+ for (; copiedCount < MAX_RFU_PLAYERS; copiedCount++)
{
- data->field_0->arr[copiedCount].unk = gUnknown_082F045C;
- data->field_0->arr[copiedCount].field_18 = 0;
- data->field_0->arr[copiedCount].field_1A_0 = 0;
- data->field_0->arr[copiedCount].field_1A_1 = 0;
+ data->field_0->arr[copiedCount].gname_uname = sWirelessGnameUnamePair_Dummy;
+ data->field_0->arr[copiedCount].timeoutCounter = 0;
+ data->field_0->arr[copiedCount].groupScheduledAnim = UNION_ROOM_SPAWN_NONE;
+ data->field_0->arr[copiedCount].useRedText = FALSE;
data->field_0->arr[copiedCount].field_1B = 0;
}
- for (i = 0; i < 5; i++)
+ for (i = 0; i < MAX_RFU_PLAYERS; i++)
{
- if (data->field_0->arr[i].field_1A_0 != 1)
+ if (data->field_0->arr[i].groupScheduledAnim != UNION_ROOM_SPAWN_IN)
continue;
- if (data->field_0->arr[i].field_1B != 0x40)
+ if (data->field_0->arr[i].field_1B != 64)
continue;
- ret = i;
+ playerCount = i;
break;
}
- return ret;
+ return playerCount;
}
void TryJoinLinkGroup(void)
{
u8 taskId;
- struct UnkStruct_Group *dataPtr;
+ struct WirelessLink_Group *data;
- taskId = CreateTask(sub_80134E8, 0);
- gUnknown_02022C30.group = dataPtr = (void*)(gTasks[taskId].data);
- gUnknown_03000DA4 = dataPtr;
+ taskId = CreateTask(Task_TryJoinLinkGroup, 0);
+ sWirelessLinkMain.group = data = (void*)(gTasks[taskId].data);
+ sGroup = data;
- dataPtr->state = 0;
- dataPtr->textState = 0;
- gSpecialVar_Result = 0;
+ data->state = LG_STATE_INIT;
+ data->textState = 0;
+ gSpecialVar_Result = LINKUP_ONGOING;
}
-void sub_80134E8(u8 taskId)
+static void Task_TryJoinLinkGroup(u8 taskId)
{
s32 id;
- struct UnkStruct_Group *data = gUnknown_02022C30.group;
+ struct WirelessLink_Group *data = sWirelessLinkMain.group;
switch (data->state)
{
- case 0:
+ case LG_STATE_INIT:
if (gSpecialVar_0x8004 == LINK_GROUP_BATTLE_TOWER && gSaveBlock2Ptr->frontier.lvlMode == FRONTIER_LVL_OPEN)
gSpecialVar_0x8004++;
- gUnknown_02022C2C = gUnknown_082F0530[gSpecialVar_0x8004];
- sub_8010F84(gUnknown_02022C2C, 0, 0);
- sub_800B488();
+ gPlayerCurrActivity = sLinkGroupToURoomActivity[gSpecialVar_0x8004];
+ SetHostRFUtgtGname(gPlayerCurrActivity, 0, 0);
+ SetWirelessCommType1();
OpenLink();
- sub_8011C5C();
- data->field_4 = AllocZeroed(0x70);
- data->field_0 = AllocZeroed(0x200);
- data->state = 1;
+ InitializeRfuLinkManager_JoinGroup();
+ data->field_4 = AllocZeroed(4 * sizeof(struct UnkStruct_x1C));
+ data->field_0 = AllocZeroed(16 * sizeof(struct UnkStruct_x20));
+ data->state = LG_STATE_CHOOSE_LEADER_MSG;
break;
- case 1:
+ case LG_STATE_CHOOSE_LEADER_MSG:
if (PrintOnTextbox(&data->textState, sChooseTrainerTexts[gSpecialVar_0x8004]))
- data->state = 2;
+ data->state = LG_STATE_INIT_WINDOWS;
break;
- case 2:
- sub_80175EC(data->field_4, 4);
- sub_8017580(data->field_0->arr, 16);
- data->field_11 = sub_8016FC0(data->field_4, gSpecialVar_0x8004);
- data->field_C = AddWindow(&gUnknown_082F00BC);
+ case LG_STATE_INIT_WINDOWS:
+ ClearUnkStruct_x1CArray(data->field_4, 4);
+ ClearUnkStruct_x20Array(data->field_0->arr, 16);
+ data->listenTaskId = CreateTask_ListenForPartnersWithCompatibleSerialNos(data->field_4, gSpecialVar_0x8004);
+ data->bButtonCancelWindowId = AddWindow(&sWindowTemplate_BButtonCancel);
data->listWindowId = AddWindow(&gUnknown_082F0174);
- data->field_D = AddWindow(&gUnknown_082F017C);
+ data->playerNameAndIdWindowId = AddWindow(&gUnknown_082F017C);
- FillWindowPixelBuffer(data->field_C, PIXEL_FILL(2));
- sub_80173E0(data->field_C, 0, sText_ChooseJoinCancel, 8, 1, 4);
- PutWindowTilemap(data->field_C);
- CopyWindowToVram(data->field_C, 2);
+ FillWindowPixelBuffer(data->bButtonCancelWindowId, PIXEL_FILL(2));
+ UR_AddTextPrinterParameterized(data->bButtonCancelWindowId, 0, sText_ChooseJoinCancel, 8, 1, 4);
+ PutWindowTilemap(data->bButtonCancelWindowId);
+ CopyWindowToVram(data->bButtonCancelWindowId, 2);
DrawStdWindowFrame(data->listWindowId, FALSE);
- gMultiuseListMenuTemplate = gUnknown_082F0204;
+ gMultiuseListMenuTemplate = sListMenuTemplate_UnionRoomGroups;
gMultiuseListMenuTemplate.windowId = data->listWindowId;
data->listTaskId = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0);
- DrawStdWindowFrame(data->field_D, FALSE);
- PutWindowTilemap(data->field_D);
- sub_80125BC(data->field_D);
- CopyWindowToVram(data->field_D, 2);
+ DrawStdWindowFrame(data->playerNameAndIdWindowId, FALSE);
+ PutWindowTilemap(data->playerNameAndIdWindowId);
+ PrintPlayerNameAndIdOnWindow(data->playerNameAndIdWindowId);
+ CopyWindowToVram(data->playerNameAndIdWindowId, 2);
CopyBgTilemapBufferToVram(0);
- data->field_F = 0;
- data->state = 3;
+ data->leaderId = 0;
+ data->state = LG_STATE_CHOOSE_LEADER_HANDLE_INPUT;
break;
- case 3:
- id = sub_8013E44();
+ case LG_STATE_CHOOSE_LEADER_HANDLE_INPUT:
+ id = GetNewLeaderCandidate();
switch (id)
{
case 1:
@@ -869,22 +1008,22 @@ void sub_80134E8(u8 taskId)
if (gMain.newKeys & A_BUTTON && id != -1)
{
// this unused variable along with the assignment is needed to match
- u32 unusedVar;
- unusedVar = data->field_0->arr[id].unk.field_0.activity;
+ u32 activity = data->field_0->arr[id].gname_uname.gname.activity;
- if (data->field_0->arr[id].field_1A_0 == 1 && !data->field_0->arr[id].unk.field_0.started)
+ if (data->field_0->arr[id].groupScheduledAnim == UNION_ROOM_SPAWN_IN && !data->field_0->arr[id].gname_uname.gname.started)
{
- u32 var = sub_8013B8C(data, id);
- if (var == 0)
+ u32 readyStatus = IsTryingToTradeAcrossVersionTooSoon(data, id);
+ if (readyStatus == UR_TRADE_READY)
{
- sub_8013BD8(data, id);
- data->state = 5;
+ // Trading is allowed, or not trading at all
+ AskToJoinRfuGroup(data, id);
+ data->state = LG_STATE_ASK_JOIN_GROUP;
PlaySE(SE_PN_ON);
}
else
{
- StringCopy(gStringVar4, sCantTransmitToTrainerTexts[var - 1]);
- data->state = 18;
+ StringCopy(gStringVar4, sCantTransmitToTrainerTexts[readyStatus - 1]);
+ data->state = LG_STATE_TRADE_NOT_READY;
PlaySE(SE_PN_ON);
}
}
@@ -895,7 +1034,7 @@ void sub_80134E8(u8 taskId)
}
else if (gMain.newKeys & B_BUTTON)
{
- data->state = 10;
+ data->state = LG_STATE_CANCEL_CHOOSE_LEADER;
}
break;
default:
@@ -903,273 +1042,292 @@ void sub_80134E8(u8 taskId)
break;
}
break;
- case 5:
- sub_80130B4(gStringVar4, gUnknown_02022C2C);
+ case LG_STATE_ASK_JOIN_GROUP:
+ GetYouAskedToJoinGroupPleaseWaitMessage(gStringVar4, gPlayerCurrActivity);
if (PrintOnTextbox(&data->textState, gStringVar4))
{
- sub_8018404(gStringVar1, &data->field_0->arr[data->field_F]);
- data->state = 6;
+ IntlConvPartnerUname7(gStringVar1, &data->field_0->arr[data->leaderId]);
+ data->state = LG_STATE_MAIN;
}
break;
- case 6:
- if (gReceivedRemoteLinkPlayers != 0)
+ case LG_STATE_MAIN:
+ if (gReceivedRemoteLinkPlayers)
{
- gUnknown_02022C2C = data->field_0->arr[data->field_F].unk.field_0.activity;
- sub_8011A64(0, 0);
- switch (gUnknown_02022C2C)
+ gPlayerCurrActivity = data->field_0->arr[data->leaderId].gname_uname.gname.activity;
+ RfuSetStatus(RFU_STATUS_OK, 0);
+ switch (gPlayerCurrActivity)
{
- case 1 ... 5:
- case 9 ... 11:
- case 13 ... 16:
- case 21 ... 28:
- data->state = 20;
+ case ACTIVITY_BATTLE_SINGLE:
+ case ACTIVITY_BATTLE_DOUBLE:
+ case ACTIVITY_BATTLE_MULTI:
+ case ACTIVITY_TRADE:
+ case ACTIVITY_CHAT:
+ case ACTIVITY_POKEMON_JUMP:
+ case ACTIVITY_BERRY_CRUSH:
+ case ACTIVITY_BERRY_PICK:
+ case ACTIVITY_SPIN_TRADE:
+ case ACTIVITY_BATTLE_TOWER:
+ case ACTIVITY_BATTLE_TOWER_OPEN:
+ case ACTIVITY_RECORD_CORNER:
+ case ACTIVITY_BERRY_BLENDER:
+ case ACTIVITY_WONDER_CARD2:
+ case ACTIVITY_WONDER_NEWS2:
+ case ACTIVITY_CONTEST_COOL:
+ case ACTIVITY_CONTEST_BEAUTY:
+ case ACTIVITY_CONTEST_CUTE:
+ case ACTIVITY_CONTEST_SMART:
+ case ACTIVITY_CONTEST_TOUGH:
+ data->state = LG_STATE_READY_START_ACTIVITY;
return;
}
}
- switch (sub_8011A74())
+ switch (RfuGetStatus())
{
- case 1:
- data->state = 12;
+ case RFU_STATUS_FATAL_ERROR:
+ data->state = LG_STATE_RFU_ERROR;
break;
- case 2:
- case 6:
- case 9:
- data->state = 14;
+ case RFU_STATUS_CONNECTION_ERROR:
+ case RFU_STATUS_JOIN_GROUP_NO:
+ case RFU_STATUS_LEAVE_GROUP:
+ data->state = LG_STATE_DISCONNECTED;
break;
- case 5:
- sub_8013160(gStringVar4, gUnknown_02022C2C);
+ case RFU_STATUS_JOIN_GROUP_OK:
+ GetGroupLeaderSentAnOKMessage(gStringVar4, gPlayerCurrActivity);
if (PrintOnTextbox(&data->textState, gStringVar4))
{
- if (gUnknown_02022C2C == 28 || gUnknown_02022C2C == 14)
+ if (gPlayerCurrActivity == ACTIVITY_BATTLE_TOWER || gPlayerCurrActivity == ACTIVITY_BATTLE_TOWER_OPEN)
{
- sub_8011A64(12, 0);
+ RfuSetStatus(RFU_STATUS_ACK_JOIN_GROUP, 0);
}
else
{
- sub_8011A64(7, 0);
- StringCopy(gStringVar1, sLinkGroupActivityTexts[gUnknown_02022C2C]);
+ RfuSetStatus(RFU_STATUS_WAIT_ACK_JOIN_GROUP, 0);
+ StringCopy(gStringVar1, sLinkGroupActivityNameTexts[gPlayerCurrActivity]);
StringExpandPlaceholders(gStringVar4, sText_AwaitingOtherMembers);
}
}
break;
- case 7:
- if (data->field_15 > 0xF0)
+ case RFU_STATUS_WAIT_ACK_JOIN_GROUP:
+ if (data->delayBeforePrint > 240)
{
if (PrintOnTextbox(&data->textState, gStringVar4))
{
- sub_8011A64(12, 0);
- data->field_15 = 0;
+ RfuSetStatus(RFU_STATUS_ACK_JOIN_GROUP, 0);
+ data->delayBeforePrint = 0;
}
}
else
{
- switch (gUnknown_02022C2C)
+ switch (gPlayerCurrActivity)
{
- case 1:
- case 2:
- case 4:
- case 14:
- case 28:
+ case ACTIVITY_BATTLE_SINGLE:
+ case ACTIVITY_BATTLE_DOUBLE:
+ case ACTIVITY_TRADE:
+ case ACTIVITY_BATTLE_TOWER:
+ case ACTIVITY_BATTLE_TOWER_OPEN:
break;
default:
- data->field_15++;
+ data->delayBeforePrint++;
break;
}
}
break;
}
- if (!sub_8011A74() && gMain.newKeys & B_BUTTON)
- data->state = 7;
+ if (RfuGetStatus() == RFU_STATUS_OK && gMain.newKeys & B_BUTTON)
+ data->state = LG_STATE_ASK_LEAVE_GROUP;
break;
- case 7:
+ case LG_STATE_ASK_LEAVE_GROUP:
if (PrintOnTextbox(&data->textState, sText_QuitBeingMember))
- data->state = 8;
+ data->state = LG_STATE_ASK_LEAVE_GROUP_HANDLE_INPUT;
break;
- case 8:
- switch (sub_80170B8(&data->textState, sub_8011A74()))
+ case LG_STATE_ASK_LEAVE_GROUP_HANDLE_INPUT:
+ switch (UnionRoomHandleYesNo(&data->textState, RfuGetStatus()))
{
- case 0:
- sub_80106D4();
- data->state = 9;
+ case 0: // YES
+ SendLeaveGroupNotice();
+ data->state = LG_STATE_WAIT_LEAVE_GROUP;
RedrawListMenu(data->listTaskId);
break;
- case 1:
+ case 1: // NO
case -1:
- data->state = 5;
+ data->state = LG_STATE_ASK_JOIN_GROUP;
RedrawListMenu(data->listTaskId);
break;
case -3:
- data->state = 6;
+ data->state = LG_STATE_MAIN;
RedrawListMenu(data->listTaskId);
break;
}
break;
- case 9:
- if (sub_8011A74())
- data->state = 6;
+ case LG_STATE_WAIT_LEAVE_GROUP:
+ if (RfuGetStatus())
+ data->state = LG_STATE_MAIN;
break;
- case 10:
- case 12:
- case 14:
- case 18:
- case 20:
- ClearWindowTilemap(data->field_D);
- ClearStdWindowAndFrame(data->field_D, FALSE);
+ case LG_STATE_CANCEL_CHOOSE_LEADER: // next: LG_STATE_CANCELED
+ case LG_STATE_RFU_ERROR: // next: LG_STATE_RFU_ERROR_SHUTDOWN
+ case LG_STATE_DISCONNECTED: // next: LG_STATE_RETRY_CONNECTION
+ case LG_STATE_TRADE_NOT_READY: // next: LG_STATE_TRADE_NOT_READY_RETRY
+ case LG_STATE_READY_START_ACTIVITY: // next: LG_STATE_START_ACTIVITY
+ ClearWindowTilemap(data->playerNameAndIdWindowId);
+ ClearStdWindowAndFrame(data->playerNameAndIdWindowId, FALSE);
DestroyListMenuTask(data->listTaskId, 0, 0);
- ClearWindowTilemap(data->field_C);
+ ClearWindowTilemap(data->bButtonCancelWindowId);
ClearStdWindowAndFrame(data->listWindowId, FALSE);
CopyBgTilemapBufferToVram(0);
- RemoveWindow(data->field_D);
+ RemoveWindow(data->playerNameAndIdWindowId);
RemoveWindow(data->listWindowId);
- RemoveWindow(data->field_C);
- DestroyTask(data->field_11);
+ RemoveWindow(data->bButtonCancelWindowId);
+ DestroyTask(data->listenTaskId);
Free(data->field_0);
Free(data->field_4);
data->state++;
break;
- case 13:
+ case LG_STATE_RFU_ERROR_SHUTDOWN:
DestroyWirelessStatusIndicatorSprite();
- if (PrintOnTextbox(&data->textState, sPlayerDisconnectedTexts[sub_8011A74()]))
+ if (PrintOnTextbox(&data->textState, sPlayerDisconnectedTexts[RfuGetStatus()]))
{
- gSpecialVar_Result = 6;
- data->state = 23;
+ gSpecialVar_Result = LINKUP_CONNECTION_ERROR;
+ data->state = LG_STATE_SHUTDOWN;
}
break;
- case 11:
+ case LG_STATE_CANCELED:
DestroyWirelessStatusIndicatorSprite();
- gSpecialVar_Result = 5;
- data->state = 23;
+ gSpecialVar_Result = LINKUP_FAILED;
+ data->state = LG_STATE_SHUTDOWN;
break;
- case 15:
+ case LG_STATE_RETRY_CONNECTION:
+ // Failure from disconnection
+ // Happens if player or required member(s) leave group
+ // or if player is rejected from joining group
DestroyWirelessStatusIndicatorSprite();
- if (PrintOnTextbox(&data->textState, sPlayerDisconnectedTexts[sub_8011A74()]))
+ if (PrintOnTextbox(&data->textState, sPlayerDisconnectedTexts[RfuGetStatus()]))
{
- gSpecialVar_Result = 8;
- data->state = 23;
+ gSpecialVar_Result = LINKUP_RETRY_ROLE_ASSIGN;
+ data->state = LG_STATE_SHUTDOWN;
}
break;
- case 19:
+ case LG_STATE_TRADE_NOT_READY_RETRY:
if (PrintOnTextbox(&data->textState, gStringVar4))
{
- gSpecialVar_Result = 8;
- data->state = 23;
+ gSpecialVar_Result = LINKUP_RETRY_ROLE_ASSIGN;
+ data->state = LG_STATE_SHUTDOWN;
}
break;
- case 23:
+ case LG_STATE_SHUTDOWN:
DestroyTask(taskId);
- sub_80173D4();
- sub_800EDD4();
+ JoinGroup_EnableScriptContexts();
+ LinkRfu_Shutdown();
break;
- case 21:
- sub_80149C4();
+ case LG_STATE_START_ACTIVITY:
+ CreateTask_RunScriptAndFadeToActivity();
DestroyTask(taskId);
break;
}
}
-u32 sub_8013B8C(struct UnkStruct_Group *arg0, s32 id)
+static u32 IsTryingToTradeAcrossVersionTooSoon(struct WirelessLink_Group *data, s32 id)
{
- struct UnkStruct_x20 *structPtr = &arg0->field_0->arr[id];
+ struct UnkStruct_x20 *structPtr = &data->field_0->arr[id];
- if (gUnknown_02022C2C == 4 && structPtr->unk.field_0.unk_00.version != VERSION_EMERALD)
+ if (gPlayerCurrActivity == ACTIVITY_TRADE && structPtr->gname_uname.gname.unk_00.version != VERSION_EMERALD)
{
if (!(gSaveBlock2Ptr->specialSaveWarpFlags & CHAMPION_SAVEWARP))
- return 1;
- else if (structPtr->unk.field_0.unk_00.isChampion)
- return 0;
+ return UR_TRADE_PLAYER_NOT_READY;
+ else if (structPtr->gname_uname.gname.unk_00.isChampion)
+ return UR_TRADE_READY;
}
else
{
- return 0;
+ return UR_TRADE_READY;
}
- return 2;
+ return UR_TRADE_PARTNER_NOT_READY;
}
-void sub_8013BD8(struct UnkStruct_Group *data, s32 id)
+static void AskToJoinRfuGroup(struct WirelessLink_Group *data, s32 id)
{
- data->field_F = id;
+ data->leaderId = id;
LoadWirelessStatusIndicatorSpriteGfx();
CreateWirelessStatusIndicatorSprite(0, 0);
RedrawListMenu(data->listTaskId);
- sub_8018404(gStringVar1, &data->field_0->arr[data->field_F]);
- sub_8011090(gUnknown_082F0530[gSpecialVar_0x8004], 0, 1);
- sub_8011FC8(data->field_0->arr[data->field_F].unk.playerName, ReadAsU16(data->field_0->arr[data->field_F].unk.field_0.unk_00.playerTrainerId));
+ IntlConvPartnerUname7(gStringVar1, &data->field_0->arr[data->leaderId]);
+ UpdateGameData_SetActivity(sLinkGroupToURoomActivity[gSpecialVar_0x8004], 0, TRUE);
+ CreateTask_RfuReconnectWithParent(data->field_0->arr[data->leaderId].gname_uname.playerName, ReadAsU16(data->field_0->arr[data->leaderId].gname_uname.gname.unk_00.playerTrainerId));
}
-u8 sub_8013C40(void)
+u8 CreateTask_ListenToWireless(void)
{
u8 taskId;
- struct UnkStruct_Group *dataPtr;
+ struct WirelessLink_Group *data;
- taskId = CreateTask(sub_8013C7C, 0);
- gUnknown_02022C30.group = dataPtr = (void*)(gTasks[taskId].data);
+ taskId = CreateTask(Task_ListenToWireless, 0);
+ sWirelessLinkMain.group = data = (void*)(gTasks[taskId].data);
- dataPtr->state = 0;
- dataPtr->textState = 0;
+ data->state = 0;
+ data->textState = 0;
- gUnknown_03000DA4 = dataPtr;
+ sGroup = data;
return taskId;
}
-void sub_8013C7C(u8 taskId)
+static void Task_ListenToWireless(u8 taskId)
{
- struct UnkStruct_Group *data = gUnknown_02022C30.group;
+ struct WirelessLink_Group *data = sWirelessLinkMain.group;
switch (data->state)
{
case 0:
- sub_8010F84(0, 0, 0);
- sub_800B488();
+ SetHostRFUtgtGname(0, 0, 0);
+ SetWirelessCommType1();
OpenLink();
- sub_8011C5C();
+ InitializeRfuLinkManager_JoinGroup();
sub_80111B0(TRUE);
- data->field_4 = AllocZeroed(0x70);
- data->field_0 = AllocZeroed(0x200);
+ data->field_4 = AllocZeroed(4 * sizeof(struct UnkStruct_x1C));
+ data->field_0 = AllocZeroed(16 * sizeof(struct UnkStruct_x20));
data->state = 2;
break;
case 2:
- sub_80175EC(data->field_4, 4);
- sub_8017580(data->field_0->arr, 16);
- data->field_11 = sub_8016FC0(data->field_4, 0xFF);
- data->field_F = 0;
+ ClearUnkStruct_x1CArray(data->field_4, 4);
+ ClearUnkStruct_x20Array(data->field_0->arr, 16);
+ data->listenTaskId = CreateTask_ListenForPartnersWithCompatibleSerialNos(data->field_4, 0xFF);
+ data->leaderId = 0;
data->state = 3;
break;
case 3:
- if (sub_8013E44() == 1)
+ if (GetNewLeaderCandidate() == 1)
PlaySE(SE_PC_LOGIN);
if (gTasks[taskId].data[15] == 0xFF)
data->state = 10;
break;
case 10:
- DestroyTask(data->field_11);
+ DestroyTask(data->listenTaskId);
Free(data->field_0);
Free(data->field_4);
- sub_800EDD4();
+ LinkRfu_Shutdown();
data->state++;
break;
case 11:
- sub_800EDD4();
+ LinkRfu_Shutdown();
DestroyTask(taskId);
break;
}
}
-bool32 sub_8013D88(u32 arg0, u32 id)
+static bool32 IsPartnerActivityAcceptable(u32 activity, u32 linkGroup)
{
- if (id == 0xFF)
+ if (linkGroup == 0xFF)
return TRUE;
- if (id <= ARRAY_COUNT(gUnknown_082F04D8)) // UB: <= may access data outside the array
+ if (linkGroup <= ARRAY_COUNT(sAcceptedActivityIds)) // UB: <= may access data outside the array
{
- const u8 *bytes = gUnknown_082F04D8[id];
+ const u8 *bytes = sAcceptedActivityIds[linkGroup];
while ((*(bytes) != 0xFF))
{
- if ((*bytes) == arg0)
+ if ((*bytes) == activity)
return TRUE;
bytes++;
}
@@ -1178,49 +1336,49 @@ bool32 sub_8013D88(u32 arg0, u32 id)
return FALSE;
}
-u8 sub_8013DBC(struct UnkStruct_Group *data, u32 id)
+static u8 URoomGroupListGetTextColor(struct WirelessLink_Group *data, u32 id)
{
- if (data->field_0->arr[id].field_1A_0 == 1)
+ if (data->field_0->arr[id].groupScheduledAnim == UNION_ROOM_SPAWN_IN)
{
- if (data->field_0->arr[id].unk.field_0.started)
- return 3;
- else if (data->field_0->arr[id].field_1A_1 != 0)
- return 1;
+ if (data->field_0->arr[id].gname_uname.gname.started)
+ return UR_COLOR_WHT_WHT_LTE;
+ else if (data->field_0->arr[id].useRedText)
+ return UR_COLOR_RED_WHT_LTR;
else if (data->field_0->arr[id].field_1B != 0)
- return 2;
+ return UR_COLOR_GRN_WHT_LTG;
}
- return 0;
+ return UR_COLOR_DKE_WHT_LTE;
}
-void sub_8013DF4(u8 arg0, s32 id, u8 arg2)
+static void ListMenuItemPrintFunc_UnionRoomGroups(u8 windowId, s32 id, u8 y)
{
- struct UnkStruct_Group *data = gUnknown_02022C30.group;
- u8 var = sub_8013DBC(data, id);
+ struct WirelessLink_Group *data = sWirelessLinkMain.group;
+ u8 colorId = URoomGroupListGetTextColor(data, id);
- sub_80177B8(arg0, 8, arg2, &data->field_0->arr[id], var, id);
+ PrintUnionRoomGroupOnWindow(windowId, 8, y, &data->field_0->arr[id], colorId, id);
}
-u8 sub_8013E44(void)
+static u8 GetNewLeaderCandidate(void)
{
- struct UnkStruct_Group *data = gUnknown_02022C30.group;
+ struct WirelessLink_Group *data = sWirelessLinkMain.group;
u8 ret = 0;
u8 i;
s32 id;
for (i = 0; i < 16; i++)
{
- if (data->field_0->arr[i].field_1A_0 != 0)
+ if (data->field_0->arr[i].groupScheduledAnim != UNION_ROOM_SPAWN_NONE)
{
- id = sub_80176E4(&data->field_0->arr[i], data->field_4->arr);
+ id = Findx20Inx1CArray(&data->field_0->arr[i], data->field_4->arr);
if (id != 0xFF)
{
- if (data->field_0->arr[i].field_1A_0 == 1)
+ if (data->field_0->arr[i].groupScheduledAnim == UNION_ROOM_SPAWN_IN)
{
- if (sub_8017678(&data->field_0->arr[i].unk, &data->field_4->arr[id].unk0))
+ if (AreUnionRoomPlayerGnamesDifferent(&data->field_0->arr[i].gname_uname, &data->field_4->arr[id].gname_uname))
{
- data->field_0->arr[i].unk = data->field_4->arr[id].unk0;
- data->field_0->arr[i].field_1B = 0x40;
+ data->field_0->arr[i].gname_uname = data->field_4->arr[id].gname_uname;
+ data->field_0->arr[i].field_1B = 64;
ret = 1;
}
else
@@ -1235,21 +1393,21 @@ u8 sub_8013E44(void)
}
else
{
- data->field_0->arr[i].field_1A_0 = 1;
- data->field_0->arr[i].field_1B = 0x40;
+ data->field_0->arr[i].groupScheduledAnim = UNION_ROOM_SPAWN_IN;
+ data->field_0->arr[i].field_1B = 64;
ret = 1;
}
- data->field_0->arr[i].field_18 = 0;
+ data->field_0->arr[i].timeoutCounter = 0;
}
else
{
- if (data->field_0->arr[i].field_1A_0 != 2)
+ if (data->field_0->arr[i].groupScheduledAnim != UNION_ROOM_SPAWN_OUT)
{
- data->field_0->arr[i].field_18++;
- if (data->field_0->arr[i].field_18 >= 300)
+ data->field_0->arr[i].timeoutCounter++;
+ if (data->field_0->arr[i].timeoutCounter >= 300)
{
- data->field_0->arr[i].field_1A_0 = 2;
+ data->field_0->arr[i].groupScheduledAnim = UNION_ROOM_SPAWN_OUT;
ret = 2;
}
}
@@ -1257,9 +1415,9 @@ u8 sub_8013E44(void)
}
}
- for (id = 0; id < 4; id++)
+ for (id = 0; id < RFU_CHILD_MAX; id++)
{
- if (sub_8017734(data->field_0->arr, &data->field_4->arr[id], 16) != 0xFF)
+ if (Appendx1Ctox20(data->field_0->arr, &data->field_4->arr[id], 16) != 0xFF)
ret = 1;
}
@@ -1272,14 +1430,14 @@ static void Task_CreateTradeMenu(u8 taskId)
DestroyTask(taskId);
}
-u8 sub_8013F78(void)
+u8 CreateTask_CreateTradeMenu(void)
{
u8 taskId = CreateTask(Task_CreateTradeMenu, 0);
return taskId;
}
-void sub_8013F90(u8 taskId)
+static void Task_StartUnionRoomTrade(u8 taskId)
{
u32 monId = GetPartyPositionOfRegisteredMon(&sUnionRoomTrade, GetMultiplayerId());
@@ -1319,7 +1477,7 @@ void sub_8013F90(u8 taskId)
}
}
-void sub_80140E0(u8 taskId)
+static void Task_ExchangeCards(u8 taskId)
{
switch (gTasks[taskId].data[0])
{
@@ -1329,7 +1487,7 @@ void sub_80140E0(u8 taskId)
gTasks[taskId].data[0]++;
break;
case 1:
- if (GetBlockReceivedStatus() == sub_800A9D8())
+ if (GetBlockReceivedStatus() == GetLinkPlayerCountAsBitFlags())
{
s32 i;
u16 *recvBuff;
@@ -1343,11 +1501,11 @@ void sub_80140E0(u8 taskId)
if (GetLinkPlayerCount() == 2)
{
recvBuff = gBlockRecvBuffer[GetMultiplayerId() ^ 1];
- sub_801B94C(recvBuff[48]);
+ MEventHandleReceivedWonderCard(recvBuff[48]);
}
else
{
- sub_801B940();
+ ResetReceivedWonderCardFlag();
}
ResetBlockReceivedFlags();
@@ -1357,16 +1515,16 @@ void sub_80140E0(u8 taskId)
}
}
-void sub_80141A4(void)
+static void CB2_ShowCard(void)
{
switch (gMain.state)
{
case 0:
- CreateTask(sub_80140E0, 5);
+ CreateTask(Task_ExchangeCards, 5);
gMain.state++;
break;
case 1:
- if (!FuncIsActiveTask(sub_80140E0))
+ if (!FuncIsActiveTask(Task_ExchangeCards))
ShowTrainerCardInLink(GetMultiplayerId() ^ 1, CB2_ReturnToField);
break;
}
@@ -1377,7 +1535,7 @@ void sub_80141A4(void)
BuildOamBuffer();
}
-void sub_8014210(u16 battleFlags)
+void StartUnionRoomBattle(u16 battleFlags)
{
HealPlayerParty();
SavePlayerParty();
@@ -1385,12 +1543,12 @@ void sub_8014210(u16 battleFlags)
gLinkPlayers[0].linkType = LINKTYPE_BATTLE;
gLinkPlayers[GetMultiplayerId()].id = GetMultiplayerId();
gLinkPlayers[GetMultiplayerId() ^ 1].id = GetMultiplayerId() ^ 1;
- gMain.savedCallback = sub_80B360C;
+ gMain.savedCallback = CB2_ReturnFromCableClubBattle;
gBattleTypeFlags = battleFlags;
PlayBattleBGM();
}
-static void sub_8014290(u16 linkService, u16 x, u16 y)
+static void WarpForWirelessMinigame(u16 linkService, u16 x, u16 y)
{
VarSet(VAR_CABLE_CLUB_STATE, linkService);
SetWarpDestination(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, x, y);
@@ -1398,7 +1556,7 @@ static void sub_8014290(u16 linkService, u16 x, u16 y)
WarpIntoMap();
}
-void sub_8014304(s8 mapGroup, s8 mapNum, s32 x, s32 y, u16 linkService)
+static void WarpForCableClubActivity(s8 mapGroup, s8 mapNum, s32 x, s32 y, u16 linkService)
{
gSpecialVar_0x8004 = linkService;
VarSet(VAR_CABLE_CLUB_STATE, linkService);
@@ -1409,16 +1567,16 @@ void sub_8014304(s8 mapGroup, s8 mapNum, s32 x, s32 y, u16 linkService)
WarpIntoMap();
}
-void sub_8014384(void)
+static void CB2_TransitionToCableClub(void)
{
switch (gMain.state)
{
case 0:
- CreateTask(sub_80140E0, 5);
+ CreateTask(Task_ExchangeCards, 5);
gMain.state++;
break;
case 1:
- if (!FuncIsActiveTask(sub_80140E0))
+ if (!FuncIsActiveTask(Task_ExchangeCards))
SetMainCallback2(CB2_ReturnToFieldCableClub);
break;
}
@@ -1429,120 +1587,125 @@ void sub_8014384(void)
BuildOamBuffer();
}
-void sub_80143E4(void *arg0, bool32 arg1)
+static void CreateTrainerCardInBuffer(void *dest, bool32 setWonderCard)
{
- u16 *argAsU16Ptr = arg0;
+ u16 *argAsU16Ptr = dest;
TrainerCard_GenerateCardForPlayer((struct TrainerCard *)argAsU16Ptr);
- if (arg1)
+ if (setWonderCard)
argAsU16Ptr[48] = GetWonderCardFlagID();
else
argAsU16Ptr[48] = 0;
}
-void sub_801440C(u8 taskId)
+static void Task_StartActivity(u8 taskId)
{
- sub_801B940();
- switch (gUnknown_02022C2C)
+ ResetReceivedWonderCardFlag();
+ switch (gPlayerCurrActivity)
{
- case 1 ... 4:
- case 9 ... 11:
- case 13:
- case 15:
+ case ACTIVITY_BATTLE_SINGLE:
+ case ACTIVITY_BATTLE_DOUBLE:
+ case ACTIVITY_BATTLE_MULTI:
+ case ACTIVITY_TRADE:
+ case ACTIVITY_POKEMON_JUMP:
+ case ACTIVITY_BERRY_CRUSH:
+ case ACTIVITY_BERRY_PICK:
+ case ACTIVITY_SPIN_TRADE:
+ case ACTIVITY_RECORD_CORNER:
RecordMixTrainerNames();
break;
}
- switch (gUnknown_02022C2C)
+ switch (gPlayerCurrActivity)
{
- case 65:
- case 81:
+ case ACTIVITY_BATTLE_SINGLE | IN_UNION_ROOM:
+ case ACTIVITY_ACCEPT | IN_UNION_ROOM:
CleanupOverworldWindowsAndTilemaps();
- gMain.savedCallback = sub_801AC54;
+ gMain.savedCallback = CB2_UnionRoomBattle;
InitChooseHalfPartyForBattle(3);
break;
- case 1:
+ case ACTIVITY_BATTLE_SINGLE:
CleanupOverworldWindowsAndTilemaps();
- sub_80143E4(gBlockSendBuffer, TRUE);
+ CreateTrainerCardInBuffer(gBlockSendBuffer, TRUE);
HealPlayerParty();
SavePlayerParty();
LoadPlayerBag();
- sub_8014304(MAP_GROUP(BATTLE_COLOSSEUM_2P), MAP_NUM(BATTLE_COLOSSEUM_2P), 6, 8, USING_SINGLE_BATTLE);
- SetMainCallback2(sub_8014384);
+ WarpForCableClubActivity(MAP_GROUP(BATTLE_COLOSSEUM_2P), MAP_NUM(BATTLE_COLOSSEUM_2P), 6, 8, USING_SINGLE_BATTLE);
+ SetMainCallback2(CB2_TransitionToCableClub);
break;
- case 2:
+ case ACTIVITY_BATTLE_DOUBLE:
CleanupOverworldWindowsAndTilemaps();
HealPlayerParty();
SavePlayerParty();
LoadPlayerBag();
- sub_80143E4(gBlockSendBuffer, TRUE);
- sub_8014304(MAP_GROUP(BATTLE_COLOSSEUM_2P), MAP_NUM(BATTLE_COLOSSEUM_2P), 6, 8, USING_DOUBLE_BATTLE);
- SetMainCallback2(sub_8014384);
+ CreateTrainerCardInBuffer(gBlockSendBuffer, TRUE);
+ WarpForCableClubActivity(MAP_GROUP(BATTLE_COLOSSEUM_2P), MAP_NUM(BATTLE_COLOSSEUM_2P), 6, 8, USING_DOUBLE_BATTLE);
+ SetMainCallback2(CB2_TransitionToCableClub);
break;
- case 3:
+ case ACTIVITY_BATTLE_MULTI:
CleanupOverworldWindowsAndTilemaps();
HealPlayerParty();
SavePlayerParty();
LoadPlayerBag();
- sub_80143E4(gBlockSendBuffer, TRUE);
- sub_8014304(MAP_GROUP(BATTLE_COLOSSEUM_4P), MAP_NUM(BATTLE_COLOSSEUM_4P), 5, 8, USING_MULTI_BATTLE);
- SetMainCallback2(sub_8014384);
+ CreateTrainerCardInBuffer(gBlockSendBuffer, TRUE);
+ WarpForCableClubActivity(MAP_GROUP(BATTLE_COLOSSEUM_4P), MAP_NUM(BATTLE_COLOSSEUM_4P), 5, 8, USING_MULTI_BATTLE);
+ SetMainCallback2(CB2_TransitionToCableClub);
break;
- case 4:
- sub_80143E4(gBlockSendBuffer, TRUE);
+ case ACTIVITY_TRADE:
+ CreateTrainerCardInBuffer(gBlockSendBuffer, TRUE);
CleanupOverworldWindowsAndTilemaps();
- sub_8014304(MAP_GROUP(TRADE_CENTER), MAP_NUM(TRADE_CENTER), 5, 8, USING_TRADE_CENTER);
- SetMainCallback2(sub_8014384);
+ WarpForCableClubActivity(MAP_GROUP(TRADE_CENTER), MAP_NUM(TRADE_CENTER), 5, 8, USING_TRADE_CENTER);
+ SetMainCallback2(CB2_TransitionToCableClub);
break;
- case 15:
- sub_80143E4(gBlockSendBuffer, TRUE);
+ case ACTIVITY_RECORD_CORNER:
+ CreateTrainerCardInBuffer(gBlockSendBuffer, TRUE);
CleanupOverworldWindowsAndTilemaps();
- sub_8014304(MAP_GROUP(RECORD_CORNER), MAP_NUM(RECORD_CORNER), 8, 9, USING_RECORD_CORNER);
- SetMainCallback2(sub_8014384);
+ WarpForCableClubActivity(MAP_GROUP(RECORD_CORNER), MAP_NUM(RECORD_CORNER), 8, 9, USING_RECORD_CORNER);
+ SetMainCallback2(CB2_TransitionToCableClub);
break;
- case 68:
+ case ACTIVITY_TRADE | IN_UNION_ROOM:
CleanupOverworldWindowsAndTilemaps();
- CreateTask(sub_8013F90, 0);
+ CreateTask(Task_StartUnionRoomTrade, 0);
break;
- case 5:
- case 69:
+ case ACTIVITY_CHAT:
+ case ACTIVITY_CHAT | IN_UNION_ROOM:
if (GetMultiplayerId() == 0)
{
- sub_800ED10();
+ LinkRfu_CreateConnectionAsParent();
}
else
{
- sub_800ED28();
- sub_8010F84(69, 0, 1);
+ LinkRfu_StopManagerBeforeEnteringChat();
+ SetHostRFUtgtGname(69, 0, 1);
}
- sub_801DD98();
+ EnterUnionRoomChat();
break;
- case 8:
- case 72:
- sub_80143E4(gBlockSendBuffer, FALSE);
- SetMainCallback2(sub_80141A4);
+ case ACTIVITY_CARD:
+ case ACTIVITY_CARD | IN_UNION_ROOM:
+ CreateTrainerCardInBuffer(gBlockSendBuffer, FALSE);
+ SetMainCallback2(CB2_ShowCard);
break;
- case 9:
- sub_8014290(USING_MINIGAME, 5, 1);
- sub_802A9A8(GetCursorSelectionMonId(), CB2_LoadMap);
+ case ACTIVITY_POKEMON_JUMP:
+ WarpForWirelessMinigame(USING_MINIGAME, 5, 1);
+ StartPokemonJump(GetCursorSelectionMonId(), CB2_LoadMap);
break;
- case 10:
- sub_8014290(USING_BERRY_CRUSH, 9, 1);
- sub_8020C70(CB2_LoadMap);
+ case ACTIVITY_BERRY_CRUSH:
+ WarpForWirelessMinigame(USING_BERRY_CRUSH, 9, 1);
+ StartBerryCrush(CB2_LoadMap);
break;
- case 11:
- sub_8014290(USING_MINIGAME, 5, 1);
- sub_802493C(GetCursorSelectionMonId(), CB2_LoadMap);
+ case ACTIVITY_BERRY_PICK:
+ WarpForWirelessMinigame(USING_MINIGAME, 5, 1);
+ StartDodrioBerryPicking(GetCursorSelectionMonId(), CB2_LoadMap);
break;
}
DestroyTask(taskId);
- gSpecialVar_Result = 1;
- if (gUnknown_02022C2C != 68)
+ gSpecialVar_Result = LINKUP_SUCCESS;
+ if (gPlayerCurrActivity != (ACTIVITY_TRADE | IN_UNION_ROOM))
ScriptContext2_Disable();
}
-void sub_8014790(u8 taskId)
+static void Task_RunScriptAndFadeToActivity(u8 taskId)
{
s16 *data = gTasks[taskId].data;
u16 *sendBuff = (u16*)(gBlockSendBuffer);
@@ -1550,11 +1713,11 @@ void sub_8014790(u8 taskId)
switch (data[0])
{
case 0:
- gSpecialVar_Result = 1;
- switch (gUnknown_02022C2C)
+ gSpecialVar_Result = LINKUP_SUCCESS;
+ switch (gPlayerCurrActivity)
{
- case 14:
- case 28:
+ case ACTIVITY_BATTLE_TOWER:
+ case ACTIVITY_BATTLE_TOWER_OPEN:
gLinkPlayers[0].linkType = LINKTYPE_BATTLE;
gLinkPlayers[0].id = 0;
gLinkPlayers[1].id = 2;
@@ -1565,8 +1728,12 @@ void sub_8014790(u8 taskId)
RecordMixTrainerNames();
ResetBlockReceivedFlags();
break;
- case 16:
- case 23 ... 27:
+ case ACTIVITY_BERRY_BLENDER:
+ case ACTIVITY_CONTEST_COOL:
+ case ACTIVITY_CONTEST_BEAUTY:
+ case ACTIVITY_CONTEST_CUTE:
+ case ACTIVITY_CONTEST_SMART:
+ case ACTIVITY_CONTEST_TOUGH:
RecordMixTrainerNames();
DestroyTask(taskId);
default:
@@ -1585,7 +1752,7 @@ void sub_8014790(u8 taskId)
case 2:
if (!gPaletteFade.active)
{
- if (gUnknown_02022C2C == 29)
+ if (gPlayerCurrActivity == ACTIVITY_29)
{
DestroyTask(taskId);
SetMainCallback2(CB2_StartCreateTradeMenu);
@@ -1601,7 +1768,7 @@ void sub_8014790(u8 taskId)
if (IsLinkTaskFinished())
{
DestroyTask(taskId);
- sub_80149D8();
+ CreateTask_StartActivity();
}
break;
case 4:
@@ -1612,9 +1779,9 @@ void sub_8014790(u8 taskId)
if (GetBlockReceivedStatus() == 3)
{
ResetBlockReceivedFlags();
- if (sub_80B2AF4(gBlockRecvBuffer[0], gBlockRecvBuffer[1]))
+ if (AreBattleTowerLinkSpeciesSame(gBlockRecvBuffer[0], gBlockRecvBuffer[1]))
{
- gSpecialVar_Result = 11;
+ gSpecialVar_Result = LINKUP_FAILED_BATTLE_TOWER;
data[0] = 7;
}
else
@@ -1642,78 +1809,78 @@ void sub_8014790(u8 taskId)
}
}
-void sub_80149C4(void)
+static void CreateTask_RunScriptAndFadeToActivity(void)
{
- CreateTask(sub_8014790, 0);
+ CreateTask(Task_RunScriptAndFadeToActivity, 0);
}
-void sub_80149D8(void)
+static void CreateTask_StartActivity(void)
{
- u8 taskId = CreateTask(sub_801440C, 0);
+ u8 taskId = CreateTask(Task_StartActivity, 0);
gTasks[taskId].data[0] = 0;
}
-void MEvent_CreateTask_Leader(u32 arg0)
+void MEvent_CreateTask_Leader(u32 activity)
{
u8 taskId;
- struct UnkStruct_Leader *dataPtr;
+ struct WirelessLink_Leader *data;
- taskId = CreateTask(sub_8014A40, 0);
- gUnknown_02022C30.leader = dataPtr = (void*)(gTasks[taskId].data);
+ taskId = CreateTask(Task_MEvent_Leader, 0);
+ sWirelessLinkMain.leader = data = (void*)(gTasks[taskId].data);
- dataPtr->state = 0;
- dataPtr->textState = 0;
- dataPtr->field_18 = arg0;
- gSpecialVar_Result = 0;
+ data->state = 0;
+ data->textState = 0;
+ data->activity = activity;
+ gSpecialVar_Result = LINKUP_ONGOING;
}
-void sub_8014A40(u8 taskId)
+static void Task_MEvent_Leader(u8 taskId)
{
- struct UnkStruct_Leader *data = gUnknown_02022C30.leader;
+ struct WirelessLink_Leader *data = sWirelessLinkMain.leader;
struct WindowTemplate winTemplate;
s32 val;
switch (data->state)
{
case 0:
- gUnknown_02022C2C = data->field_18;
- gUnknown_02022C2D = 2;
- sub_8010F84(data->field_18, 0, 0);
- sub_8010FA0(FALSE, FALSE);
- sub_800B488();
+ gPlayerCurrActivity = data->activity;
+ sPlayerActivityGroupSize = 2;
+ SetHostRFUtgtGname(data->activity, 0, 0);
+ SetGnameBufferWonderFlags(FALSE, FALSE);
+ SetWirelessCommType1();
OpenLink();
- sub_8011C10(2);
+ InitializeRfuLinkManager_LinkLeader(2);
data->state = 1;
break;
case 1:
- data->field_4 = AllocZeroed(0x70);
- data->field_0 = AllocZeroed(0xA0);
- data->field_8 = AllocZeroed(0xA0);
- sub_80175EC(data->field_4, 4);
- sub_8017580(data->field_0->arr, 5);
- sub_800DF90(&data->field_0->arr[0].unk.field_0, data->field_0->arr[0].unk.playerName);
- data->field_0->arr[0].field_18 = 0;
- data->field_0->arr[0].field_1A_0 = 1;
- data->field_0->arr[0].field_1A_1 = 0;
+ data->field_4 = AllocZeroed(4 * sizeof(struct UnkStruct_x1C));
+ data->field_0 = AllocZeroed(5 * sizeof(struct UnkStruct_x20));
+ data->field_8 = AllocZeroed(5 * sizeof(struct UnkStruct_x20));
+ ClearUnkStruct_x1CArray(data->field_4, 4);
+ ClearUnkStruct_x20Array(data->field_0->arr, 5);
+ LinkRfu3_SetGnameUnameFromStaticBuffers(&data->field_0->arr[0].gname_uname.gname, data->field_0->arr[0].gname_uname.playerName);
+ data->field_0->arr[0].timeoutCounter = 0;
+ data->field_0->arr[0].groupScheduledAnim = UNION_ROOM_SPAWN_IN;
+ data->field_0->arr[0].useRedText = FALSE;
data->field_0->arr[0].field_1B = 0;
- data->field_17 = sub_8016FC0(data->field_4, 0xFF);
+ data->listenTaskId = CreateTask_ListenForPartnersWithCompatibleSerialNos(data->field_4, 0xFF);
- winTemplate = gUnknown_082F011C;
+ winTemplate = sWindowTemplate_PlayerList;
winTemplate.baseBlock = GetMysteryGiftBaseBlock();
winTemplate.paletteNum = 0xC;
data->listWindowId = AddWindow(&winTemplate);
MG_DrawTextBorder(data->listWindowId);
- gMultiuseListMenuTemplate = gUnknown_082F015C;
+ gMultiuseListMenuTemplate = sListMenuTemplate_PossibleGroupMembers;
gMultiuseListMenuTemplate.windowId = data->listWindowId;
data->listTaskId = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0);
CopyBgTilemapBufferToVram(0);
- data->field_13 = 1;
+ data->playerCount = 1;
data->state = 2;
break;
case 2:
- StringCopy(gStringVar1, sLinkGroupActivityTexts[gUnknown_02022C2C]);
- sub_801262C(gStringVar4, gUnknown_02022C2C);
+ StringCopy(gStringVar1, sLinkGroupActivityNameTexts[gPlayerCurrActivity]);
+ StringExpandPlaceholders_AwaitingCommFromAnother(gStringVar4, gPlayerCurrActivity);
data->state = 3;
break;
case 3:
@@ -1721,7 +1888,7 @@ void sub_8014A40(u8 taskId)
data->state = 4;
break;
case 4:
- sub_801320C(data, 5, 6);
+ Leader_SetStateIfMemberListChanged(data, 5, 6);
if (gMain.newKeys & B_BUTTON)
{
data->state = 13;
@@ -1731,7 +1898,7 @@ void sub_8014A40(u8 taskId)
case 6:
if (MG_PrintTextOnWindow1AndWaitButton(&data->textState, sText_LinkWithFriendDropped))
{
- data->field_13 = sub_8013398(data->field_0);
+ data->playerCount = sub_8013398(data->field_0);
RedrawListMenu(data->listTaskId);
data->state = 2;
}
@@ -1745,48 +1912,48 @@ void sub_8014A40(u8 taskId)
case 0:
LoadWirelessStatusIndicatorSpriteGfx();
CreateWirelessStatusIndicatorSprite(0, 0);
- data->field_0->arr[data->field_13].field_1B = 0;
+ data->field_0->arr[data->playerCount].field_1B = 0;
RedrawListMenu(data->listTaskId);
- data->field_19 = 5;
- sub_8010688(5, ReadAsU16(data->field_0->arr[data->field_13].unk.field_0.unk_00.playerTrainerId), data->field_0->arr[data->field_13].unk.playerName);
+ data->joinRequestAnswer = RFU_STATUS_JOIN_GROUP_OK;
+ SendRfuStatusToPartner(data->joinRequestAnswer, ReadAsU16(data->field_0->arr[data->playerCount].gname_uname.gname.unk_00.playerTrainerId), data->field_0->arr[data->playerCount].gname_uname.playerName);
data->state = 8;
break;
case 1:
case -1:
- data->field_19 = 6;
- sub_8010688(6, ReadAsU16(data->field_0->arr[data->field_13].unk.field_0.unk_00.playerTrainerId), data->field_0->arr[data->field_13].unk.playerName);
+ data->joinRequestAnswer = RFU_STATUS_JOIN_GROUP_NO;
+ SendRfuStatusToPartner(data->joinRequestAnswer, ReadAsU16(data->field_0->arr[data->playerCount].gname_uname.gname.unk_00.playerTrainerId), data->field_0->arr[data->playerCount].gname_uname.playerName);
data->state = 8;
break;
}
break;
case 8:
- val = sub_8010714(ReadAsU16(data->field_0->arr[data->field_13].unk.field_0.unk_00.playerTrainerId), data->field_0->arr[data->field_13].unk.playerName);
- if (val == 1)
+ val = WaitSendRfuStatusToPartner(ReadAsU16(data->field_0->arr[data->playerCount].gname_uname.gname.unk_00.playerTrainerId), data->field_0->arr[data->playerCount].gname_uname.playerName);
+ if (val == 1) // Send complete
{
- if (data->field_19 == 5)
+ if (data->joinRequestAnswer == RFU_STATUS_JOIN_GROUP_OK)
{
- data->field_0->arr[data->field_13].field_1B = 0;
+ data->field_0->arr[data->playerCount].field_1B = 0;
RedrawListMenu(data->listTaskId);
- data->field_13++;
- sub_8018404(gStringVar1, &data->field_0->arr[data->field_13 - 1]);
+ data->playerCount++;
+ IntlConvPartnerUname7(gStringVar1, &data->field_0->arr[data->playerCount - 1]);
StringExpandPlaceholders(gStringVar4, sText_AnOKWasSentToPlayer);
data->state = 9;
- sub_800EF38();
+ LinkRfu_StopManagerAndFinalizeSlots();
}
else
{
- sub_8011DC0(data->field_0->arr[data->field_13].unk.playerName, ReadAsU16(data->field_0->arr[data->field_13].unk.field_0.unk_00.playerTrainerId));
- data->field_0->arr[data->field_13].field_1A_0 = 0;
+ RequestDisconnectSlotByTrainerNameAndId(data->field_0->arr[data->playerCount].gname_uname.playerName, ReadAsU16(data->field_0->arr[data->playerCount].gname_uname.gname.unk_00.playerTrainerId));
+ data->field_0->arr[data->playerCount].groupScheduledAnim = UNION_ROOM_SPAWN_NONE;
sub_8013398(data->field_0);
RedrawListMenu(data->listTaskId);
data->state = 2;
}
- data->field_19 = 0;
+ data->joinRequestAnswer = 0;
}
- else if (val == 2)
+ else if (val == 2) // Member disconnected
{
- sub_8011A64(0, 0);
+ RfuSetStatus(RFU_STATUS_OK, 0);
data->state = 2;
}
break;
@@ -1795,17 +1962,17 @@ void sub_8014A40(u8 taskId)
data->state = 10;
break;
case 10:
- if (++data->field_E > 120)
+ if (++data->delayTimerAfterOk > 120)
data->state = 11;
break;
case 11:
- if (!sub_801320C(data, 5, 6))
+ if (!Leader_SetStateIfMemberListChanged(data, 5, 6))
data->state = 12;
break;
case 12:
- if (sub_800EF1C())
+ if (LmanAcceptSlotFlagIsNotZero())
{
- sub_800EF58(FALSE);
+ WaitRfuState(FALSE);
data->state = 15;
}
else
@@ -1815,11 +1982,11 @@ void sub_8014A40(u8 taskId)
break;
case 13:
DestroyWirelessStatusIndicatorSprite();
- sub_800EDD4();
+ LinkRfu_Shutdown();
DestroyListMenuTask(data->listTaskId, 0, 0);
CopyBgTilemapBufferToVram(0);
RemoveWindow(data->listWindowId);
- DestroyTask(data->field_17);
+ DestroyTask(data->listenTaskId);
Free(data->field_8);
Free(data->field_0);
Free(data->field_4);
@@ -1829,17 +1996,17 @@ void sub_8014A40(u8 taskId)
if (MG_PrintTextOnWindow1AndWaitButton(&data->textState, sText_PleaseStartOver))
{
DestroyTask(taskId);
- gSpecialVar_Result = 5;
+ gSpecialVar_Result = LINKUP_FAILED;
}
break;
case 15:
- if (sub_8011A74() == 1 || sub_8011A74() == 2)
+ if (RfuGetStatus() == RFU_STATUS_FATAL_ERROR || RfuGetStatus() == RFU_STATUS_CONNECTION_ERROR)
{
data->state = 13;
}
else if (gReceivedRemoteLinkPlayers != 0)
{
- sub_8011068(1);
+ UpdateGameData_GroupLockedIn(TRUE);
data->state++;
}
break;
@@ -1847,7 +2014,7 @@ void sub_8014A40(u8 taskId)
DestroyListMenuTask(data->listTaskId, 0, 0);
CopyBgTilemapBufferToVram(0);
RemoveWindow(data->listWindowId);
- DestroyTask(data->field_17);
+ DestroyTask(data->listenTaskId);
Free(data->field_8);
Free(data->field_0);
Free(data->field_4);
@@ -1861,36 +2028,36 @@ void sub_8014A40(u8 taskId)
}
}
-void MEvent_CreateTask_CardOrNewsWithFriend(u32 arg0)
+void MEvent_CreateTask_CardOrNewsWithFriend(u32 activity)
{
u8 taskId;
- struct UnkStruct_Group *dataPtr;
+ struct WirelessLink_Group *data;
- taskId = CreateTask(sub_8014F48, 0);
- gUnknown_02022C30.group = dataPtr = (void*)(gTasks[taskId].data);
- gUnknown_03000DA4 = dataPtr;
+ taskId = CreateTask(Task_CardOrNewsWithFriend, 0);
+ sWirelessLinkMain.group = data = (void*)(gTasks[taskId].data);
+ sGroup = data;
- dataPtr->state = 0;
- dataPtr->textState = 0;
- dataPtr->field_12 = arg0 - 21;
- gSpecialVar_Result = 0;
+ data->state = 0;
+ data->textState = 0;
+ data->isWonderNews = activity - ACTIVITY_WONDER_CARD2;
+ gSpecialVar_Result = LINKUP_ONGOING;
}
-void sub_8014F48(u8 taskId)
+static void Task_CardOrNewsWithFriend(u8 taskId)
{
s32 id;
struct WindowTemplate winTemplate1, winTemplate2;
- struct UnkStruct_Group *data = gUnknown_02022C30.group;
+ struct WirelessLink_Group *data = sWirelessLinkMain.group;
switch (data->state)
{
case 0:
- sub_8010F84(data->field_12 + 21, 0, 0);
- sub_800B488();
+ SetHostRFUtgtGname(data->isWonderNews + ACTIVITY_WONDER_CARD2, 0, 0);
+ SetWirelessCommType1();
OpenLink();
- sub_8011C5C();
- data->field_4 = AllocZeroed(0x70);
- data->field_0 = AllocZeroed(0x200);
+ InitializeRfuLinkManager_JoinGroup();
+ data->field_4 = AllocZeroed(4 * sizeof(struct UnkStruct_x1C));
+ data->field_0 = AllocZeroed(16 * sizeof(struct UnkStruct_x20));
data->state = 1;
break;
case 1:
@@ -1898,9 +2065,9 @@ void sub_8014F48(u8 taskId)
data->state = 2;
break;
case 2:
- sub_80175EC(data->field_4, 4);
- sub_8017580(data->field_0->arr, 16);
- data->field_11 = sub_8016FC0(data->field_4, data->field_12 + 7);
+ ClearUnkStruct_x1CArray(data->field_4, 4);
+ ClearUnkStruct_x20Array(data->field_0->arr, 16);
+ data->listenTaskId = CreateTask_ListenForPartnersWithCompatibleSerialNos(data->field_4, data->isWonderNews + LINK_GROUP_WONDER_CARD);
winTemplate1 = gUnknown_082F0174;
winTemplate1.baseBlock = GetMysteryGiftBaseBlock();
@@ -1909,25 +2076,25 @@ void sub_8014F48(u8 taskId)
winTemplate2 = gUnknown_082F017C;
winTemplate2.paletteNum = 0xC;
- data->field_D = AddWindow(&winTemplate2);
+ data->playerNameAndIdWindowId = AddWindow(&winTemplate2);
MG_DrawTextBorder(data->listWindowId);
- gMultiuseListMenuTemplate = gUnknown_082F0204;
+ gMultiuseListMenuTemplate = sListMenuTemplate_UnionRoomGroups;
gMultiuseListMenuTemplate.windowId = data->listWindowId;
data->listTaskId = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0);
- MG_DrawTextBorder(data->field_D);
- FillWindowPixelBuffer(data->field_D, PIXEL_FILL(1));
- PutWindowTilemap(data->field_D);
- sub_80125BC(data->field_D);
- CopyWindowToVram(data->field_D, 2);
+ MG_DrawTextBorder(data->playerNameAndIdWindowId);
+ FillWindowPixelBuffer(data->playerNameAndIdWindowId, PIXEL_FILL(1));
+ PutWindowTilemap(data->playerNameAndIdWindowId);
+ PrintPlayerNameAndIdOnWindow(data->playerNameAndIdWindowId);
+ CopyWindowToVram(data->playerNameAndIdWindowId, 2);
CopyBgTilemapBufferToVram(0);
- data->field_F = 0;
+ data->leaderId = 0;
data->state = 3;
break;
case 3:
- id = sub_8013E44();
+ id = GetNewLeaderCandidate();
switch (id)
{
case 1:
@@ -1941,16 +2108,16 @@ void sub_8014F48(u8 taskId)
{
// this unused variable along with the assignment is needed to match
u32 unusedVar;
- unusedVar = data->field_0->arr[id].unk.field_0.activity;
+ unusedVar = data->field_0->arr[id].gname_uname.gname.activity;
- if (data->field_0->arr[id].field_1A_0 == 1 && !data->field_0->arr[id].unk.field_0.started)
+ if (data->field_0->arr[id].groupScheduledAnim == UNION_ROOM_SPAWN_IN && !data->field_0->arr[id].gname_uname.gname.started)
{
- data->field_F = id;
+ data->leaderId = id;
LoadWirelessStatusIndicatorSpriteGfx();
CreateWirelessStatusIndicatorSprite(0, 0);
RedrawListMenu(data->listTaskId);
- sub_8018404(gStringVar1, &data->field_0->arr[data->field_F]);
- sub_8011FC8(data->field_0->arr[data->field_F].unk.playerName, ReadAsU16(data->field_0->arr[data->field_F].unk.field_0.unk_00.playerTrainerId));
+ IntlConvPartnerUname7(gStringVar1, &data->field_0->arr[data->leaderId]);
+ CreateTask_RfuReconnectWithParent(data->field_0->arr[data->leaderId].gname_uname.playerName, ReadAsU16(data->field_0->arr[data->leaderId].gname_uname.gname.unk_00.playerTrainerId));
PlaySE(SE_PN_ON);
data->state = 4;
}
@@ -1968,26 +2135,26 @@ void sub_8014F48(u8 taskId)
break;
case 4:
AddTextPrinterToWindow1(sText_AwaitingPlayersResponse);
- sub_8018404(gStringVar1, &data->field_0->arr[data->field_F]);
+ IntlConvPartnerUname7(gStringVar1, &data->field_0->arr[data->leaderId]);
data->state = 5;
break;
case 5:
- if (gReceivedRemoteLinkPlayers != 0)
+ if (gReceivedRemoteLinkPlayers)
{
- gUnknown_02022C2C = data->field_0->arr[data->field_F].unk.field_0.activity;
+ gPlayerCurrActivity = data->field_0->arr[data->leaderId].gname_uname.gname.activity;
data->state = 10;
}
- switch (sub_8011A74())
+ switch (RfuGetStatus())
{
- case 1:
- case 2:
- case 6:
+ case RFU_STATUS_FATAL_ERROR:
+ case RFU_STATUS_CONNECTION_ERROR:
+ case RFU_STATUS_JOIN_GROUP_NO:
data->state = 8;
break;
- case 5:
+ case RFU_STATUS_JOIN_GROUP_OK:
AddTextPrinterToWindow1(sText_PlayerSentBackOK);
- sub_8011A64(0, 0);
+ RfuSetStatus(RFU_STATUS_OK, 0);
break;
}
break;
@@ -1996,28 +2163,28 @@ void sub_8014F48(u8 taskId)
case 10:
DestroyListMenuTask(data->listTaskId, 0, 0);
CopyBgTilemapBufferToVram(0);
- RemoveWindow(data->field_D);
+ RemoveWindow(data->playerNameAndIdWindowId);
RemoveWindow(data->listWindowId);
- DestroyTask(data->field_11);
+ DestroyTask(data->listenTaskId);
Free(data->field_0);
Free(data->field_4);
data->state++;
break;
case 9:
- if (MG_PrintTextOnWindow1AndWaitButton(&data->textState, sLinkDroppedTexts[sub_8011A74()]))
+ if (MG_PrintTextOnWindow1AndWaitButton(&data->textState, sLinkDroppedTexts[RfuGetStatus()]))
{
DestroyWirelessStatusIndicatorSprite();
DestroyTask(taskId);
- sub_800EDD4();
- gSpecialVar_Result = 5;
+ LinkRfu_Shutdown();
+ gSpecialVar_Result = LINKUP_FAILED;
}
break;
case 7:
DestroyWirelessStatusIndicatorSprite();
AddTextPrinterToWindow1(sText_PleaseStartOver);
DestroyTask(taskId);
- sub_800EDD4();
- gSpecialVar_Result = 5;
+ LinkRfu_Shutdown();
+ gSpecialVar_Result = LINKUP_FAILED;
break;
case 11:
data->state++;
@@ -2030,36 +2197,36 @@ void sub_8014F48(u8 taskId)
}
}
-void MEvent_CreateTask_CardOrNewsOverWireless(u32 arg0)
+void MEvent_CreateTask_CardOrNewsOverWireless(u32 activity)
{
u8 taskId;
- struct UnkStruct_Group *dataPtr;
+ struct WirelessLink_Group *data;
- taskId = CreateTask(sub_80152F4, 0);
- gUnknown_02022C30.group = dataPtr = (void*)(gTasks[taskId].data);
- gUnknown_03000DA4 = dataPtr;
+ taskId = CreateTask(Task_CardOrNewsOverWireless, 0);
+ sWirelessLinkMain.group = data = (void*)(gTasks[taskId].data);
+ sGroup = data;
- dataPtr->state = 0;
- dataPtr->textState = 0;
- dataPtr->field_12 = arg0 - 21;
- gSpecialVar_Result = 0;
+ data->state = 0;
+ data->textState = 0;
+ data->isWonderNews = activity - ACTIVITY_WONDER_CARD2;
+ gSpecialVar_Result = LINKUP_ONGOING;
}
-void sub_80152F4(u8 taskId)
+static void Task_CardOrNewsOverWireless(u8 taskId)
{
s32 id;
struct WindowTemplate winTemplate;
- struct UnkStruct_Group *data = gUnknown_02022C30.group;
+ struct WirelessLink_Group *data = sWirelessLinkMain.group;
switch (data->state)
{
case 0:
- sub_8010F84(0, 0, 0);
- sub_800B488();
+ SetHostRFUtgtGname(0, 0, 0);
+ SetWirelessCommType1();
OpenLink();
- sub_8011C5C();
- data->field_4 = AllocZeroed(0x70);
- data->field_0 = AllocZeroed(0x200);
+ InitializeRfuLinkManager_JoinGroup();
+ data->field_4 = AllocZeroed(4 * sizeof(struct UnkStruct_x1C));
+ data->field_0 = AllocZeroed(16 * sizeof(struct UnkStruct_x20));
data->state = 1;
break;
case 1:
@@ -2067,9 +2234,9 @@ void sub_80152F4(u8 taskId)
data->state = 2;
break;
case 2:
- sub_80175EC(data->field_4, 4);
- sub_8017580(data->field_0->arr, 16);
- data->field_11 = sub_8016FF0(data->field_4, data->field_12 + 7);
+ ClearUnkStruct_x1CArray(data->field_4, 4);
+ ClearUnkStruct_x20Array(data->field_0->arr, 16);
+ data->listenTaskId = CreateTask_ListenForPartnersWithSerial7F7D(data->field_4, data->isWonderNews + LINK_GROUP_WONDER_CARD);
if (data->field_13 != 0)
{
@@ -2078,18 +2245,18 @@ void sub_80152F4(u8 taskId)
data->listWindowId = AddWindow(&winTemplate);
MG_DrawTextBorder(data->listWindowId);
- gMultiuseListMenuTemplate = gUnknown_082F0204;
+ gMultiuseListMenuTemplate = sListMenuTemplate_UnionRoomGroups;
gMultiuseListMenuTemplate.windowId = data->listWindowId;
data->listTaskId = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0);
CopyBgTilemapBufferToVram(0);
}
- data->field_F = 0;
+ data->leaderId = 0;
data->state = 3;
break;
case 3:
- id = sub_8013E44();
+ id = GetNewLeaderCandidate();
switch (id)
{
case 1:
@@ -2101,17 +2268,17 @@ void sub_80152F4(u8 taskId)
case 0:
if (data->field_13 != 0)
id = ListMenu_ProcessInput(data->listTaskId);
- if (data->field_14 > 120)
+ if (data->refreshTimer > 120)
{
- if (data->field_0->arr[0].field_1A_0 == 1 && !data->field_0->arr[0].unk.field_0.started)
+ if (data->field_0->arr[0].groupScheduledAnim == UNION_ROOM_SPAWN_IN && !data->field_0->arr[0].gname_uname.gname.started)
{
- if (sub_8016F1C(&data->field_0->arr[0].unk.field_0, data->field_12 + 7))
+ if (HasWonderCardOrNewsByLinkGroup(&data->field_0->arr[0].gname_uname.gname, data->isWonderNews + LINK_GROUP_WONDER_CARD))
{
- data->field_F = 0;
- data->field_14 = 0;
+ data->leaderId = 0;
+ data->refreshTimer = 0;
LoadWirelessStatusIndicatorSpriteGfx();
CreateWirelessStatusIndicatorSprite(0, 0);
- sub_8011FC8(data->field_0->arr[0].unk.playerName, ReadAsU16(data->field_0->arr[0].unk.field_0.unk_00.playerTrainerId));
+ CreateTask_RfuReconnectWithParent(data->field_0->arr[0].gname_uname.playerName, ReadAsU16(data->field_0->arr[0].gname_uname.gname.unk_00.playerTrainerId));
PlaySE(SE_PN_ON);
data->state = 4;
}
@@ -2125,34 +2292,34 @@ void sub_80152F4(u8 taskId)
else if (gMain.newKeys & B_BUTTON)
{
data->state = 6;
- data->field_14 = 0;
+ data->refreshTimer = 0;
}
- data->field_14++;
+ data->refreshTimer++;
break;
}
break;
case 4:
AddTextPrinterToWindow1(sText_AwaitingResponseFromWirelessSystem);
- sub_8018404(gStringVar1, &data->field_0->arr[data->field_F]);
+ IntlConvPartnerUname7(gStringVar1, &data->field_0->arr[data->leaderId]);
data->state = 5;
break;
case 5:
- if (gReceivedRemoteLinkPlayers != 0)
+ if (gReceivedRemoteLinkPlayers)
{
- gUnknown_02022C2C = data->field_0->arr[data->field_F].unk.field_0.activity;
+ gPlayerCurrActivity = data->field_0->arr[data->leaderId].gname_uname.gname.activity;
data->state = 12;
}
- switch (sub_8011A74())
+ switch (RfuGetStatus())
{
- case 1:
- case 2:
- case 6:
+ case RFU_STATUS_FATAL_ERROR:
+ case RFU_STATUS_CONNECTION_ERROR:
+ case RFU_STATUS_JOIN_GROUP_NO:
data->state = 8;
break;
- case 5:
+ case RFU_STATUS_JOIN_GROUP_OK:
AddTextPrinterToWindow1(sText_WirelessLinkEstablished);
- sub_8011A64(0, 0);
+ RfuSetStatus(RFU_STATUS_OK, 0);
break;
}
break;
@@ -2166,7 +2333,7 @@ void sub_80152F4(u8 taskId)
CopyBgTilemapBufferToVram(0);
RemoveWindow(data->listWindowId);
}
- DestroyTask(data->field_11);
+ DestroyTask(data->listenTaskId);
Free(data->field_0);
Free(data->field_4);
data->state++;
@@ -2176,8 +2343,8 @@ void sub_80152F4(u8 taskId)
{
DestroyWirelessStatusIndicatorSprite();
DestroyTask(taskId);
- sub_800EDD4();
- gSpecialVar_Result = 5;
+ LinkRfu_Shutdown();
+ gSpecialVar_Result = LINKUP_FAILED;
}
break;
case 7:
@@ -2185,17 +2352,17 @@ void sub_80152F4(u8 taskId)
{
DestroyWirelessStatusIndicatorSprite();
DestroyTask(taskId);
- sub_800EDD4();
- gSpecialVar_Result = 5;
+ LinkRfu_Shutdown();
+ gSpecialVar_Result = LINKUP_FAILED;
}
break;
case 11:
- if (MG_PrintTextOnWindow1AndWaitButton(&data->textState, sNoWonderSharedTexts[data->field_12]))
+ if (MG_PrintTextOnWindow1AndWaitButton(&data->textState, sNoWonderSharedTexts[data->isWonderNews]))
{
DestroyWirelessStatusIndicatorSprite();
DestroyTask(taskId);
- sub_800EDD4();
- gSpecialVar_Result = 5;
+ LinkRfu_Shutdown();
+ gSpecialVar_Result = LINKUP_FAILED;
}
break;
case 13:
@@ -2209,172 +2376,172 @@ void sub_80152F4(u8 taskId)
}
}
-void UnionRoomSpecial(void)
+void RunUnionRoom(void)
{
- struct UnkStruct_URoom *dataPtr;
+ struct WirelessLink_URoom *uroom;
- sub_8010F60();
- CreateTask(sub_80156E0, 10);
+ ClearAndInitHostRFUtgtGname();
+ CreateTask(Task_RunUnionRoom, 10);
// dumb line needed to match
- gUnknown_02022C30.uRoom = gUnknown_02022C30.uRoom;
+ sWirelessLinkMain.uRoom = sWirelessLinkMain.uRoom;
- dataPtr = AllocZeroed(sizeof(*gUnknown_02022C30.uRoom));
- gUnknown_02022C30.uRoom = dataPtr;
- gUnknown_03000DA8 = dataPtr;
+ uroom = AllocZeroed(sizeof(*sWirelessLinkMain.uRoom));
+ sWirelessLinkMain.uRoom = uroom;
+ sURoom = uroom;
- dataPtr->state = 0;
- dataPtr->textState = 0;
- dataPtr->field_10 = 0;
- dataPtr->field_12 = 0;
+ uroom->state = UR_STATE_INIT;
+ uroom->textState = 0;
+ uroom->unknown = 0;
+ uroom->field_12 = 0;
gSpecialVar_Result = 0;
- sub_819A2BC(0xD0, 1);
+ ListMenuLoadStdPalAt(0xD0, 1);
}
-u16 ReadAsU16(const u8 *ptr)
+static u16 ReadAsU16(const u8 *ptr)
{
return (ptr[1] << 8) | (ptr[0]);
}
-void sub_8015664(u32 nextState, const u8 *src)
+static void ScheduleFieldMessageWithFollowupState(u32 nextState, const u8 *src)
{
- struct UnkStruct_URoom *data = gUnknown_02022C30.uRoom;
+ struct WirelessLink_URoom *uroom = sWirelessLinkMain.uRoom;
- data->state = 8;
- data->stateAfterPrint = nextState;
+ uroom->state = UR_STATE_PRINT_MSG;
+ uroom->stateAfterPrint = nextState;
if (src != gStringVar4)
StringExpandPlaceholders(gStringVar4, src);
}
-void sub_801568C(const u8 *src)
+static void ScheduleFieldMessageAndExit(const u8 *src)
{
- struct UnkStruct_URoom *data = gUnknown_02022C30.uRoom;
+ struct WirelessLink_URoom *uroom = sWirelessLinkMain.uRoom;
- data->state = 26;
+ uroom->state = UR_STATE_PRINT_AND_EXIT;
if (src != gStringVar4)
StringExpandPlaceholders(gStringVar4, src);
}
-void sub_80156B0(struct UnkStruct_URoom *data)
+static void sub_80156B0(struct WirelessLink_URoom *uroom)
{
- memcpy(&gDecompressionBuffer[0x3F00], data->field_0, 0x100);
+ memcpy(&gDecompressionBuffer[0x3F00], uroom->field_0, 0x100);
}
-void sub_80156C8(struct UnkStruct_URoom *data)
+static void sub_80156C8(struct WirelessLink_URoom *uroom)
{
- memcpy(data->field_0, &gDecompressionBuffer[0x3F00], 0x100);
+ memcpy(uroom->field_0, &gDecompressionBuffer[0x3F00], 0x100);
}
-void sub_80156E0(u8 taskId)
+static void Task_RunUnionRoom(u8 taskId)
{
u32 id = 0;
- s32 var5 = 0;
- s32 playerGender = 0;
- struct UnkStruct_URoom *data = gUnknown_02022C30.uRoom;
+ s32 input = 0;
+ s32 playerGender = MALE;
+ struct WirelessLink_URoom *uroom = sWirelessLinkMain.uRoom;
s16 *taskData = gTasks[taskId].data;
- switch (data->state)
+ switch (uroom->state)
{
- case 0:
- data->field_4 = AllocZeroed(0x70);
- data->field_C = AllocZeroed(0x70);
- data->field_0 = AllocZeroed(0x100);
- data->field_8 = AllocZeroed(0x20);
- sub_8017580(data->field_0->arr, 8);
- gUnknown_02022C2C = 0x40;
- data->field_20 = sub_8016DF0(data->field_C, data->field_4, 9);
- sub_8019BA8(data->field_A0);
- sub_8019F2C();
- data->state = 1;
- break;
- case 1:
- sub_8019E70(data->spriteIds, taskData[0]);
+ case UR_STATE_INIT:
+ uroom->field_4 = AllocZeroed(RFU_CHILD_MAX * sizeof(struct UnkStruct_x1C));
+ uroom->field_C = AllocZeroed(RFU_CHILD_MAX * sizeof(struct UnkStruct_x1C));
+ uroom->field_0 = AllocZeroed(8 * sizeof(struct UnkStruct_x20));
+ uroom->field_8 = AllocZeroed(sizeof(struct UnkStruct_x20));
+ ClearUnkStruct_x20Array(uroom->field_0->arr, ARRAY_COUNT(uroom->field_0->arr));
+ gPlayerCurrActivity = IN_UNION_ROOM;
+ uroom->searchTaskId = CreateTask_SearchForChildOrParent(uroom->field_C, uroom->field_4, LINK_GROUP_UNION_ROOM_RESUME);
+ InitUnionRoomPlayerObjects(uroom->objects);
+ SetTilesAroundUnionRoomPlayersPassable();
+ uroom->state = UR_STATE_INIT_OBJECTS;
+ break;
+ case UR_STATE_INIT_OBJECTS:
+ CreateGroupMemberSpritesInvisible(uroom->spriteIds, taskData[0]);
if (++taskData[0] == 8)
- data->state = 2;
+ uroom->state = UR_STATE_INIT_LINK;
break;
- case 2:
- sub_8010F84(0x40, 0, 0);
- sub_8010FCC(sUnionRoomTrade.type, sUnionRoomTrade.playerSpecies, sUnionRoomTrade.playerLevel);
- sub_800B488();
+ case UR_STATE_INIT_LINK:
+ SetHostRFUtgtGname(IN_UNION_ROOM, 0, 0);
+ SetTradeBoardRegisteredMonInfo(sUnionRoomTrade.type, sUnionRoomTrade.playerSpecies, sUnionRoomTrade.playerLevel);
+ SetWirelessCommType1();
OpenLink();
- sub_8011C84();
- sub_8017580(&data->field_8->arr[0], 1);
- sub_80175EC(data->field_4, 4);
- sub_80175EC(data->field_C, 4);
+ InitializeRfuLinkManager_EnterUnionRoom();
+ ClearUnkStruct_x20Array(&uroom->field_8->arr[0], 1);
+ ClearUnkStruct_x1CArray(uroom->field_4, 4);
+ ClearUnkStruct_x1CArray(uroom->field_C, 4);
gSpecialVar_Result = 0;
- data->state = 3;
+ uroom->state = UR_STATE_CHECK_SELECTING_MON;
break;
- case 3:
+ case UR_STATE_CHECK_SELECTING_MON:
if ((GetPartyMenuType() == PARTY_MENU_TYPE_UNION_ROOM_REGISTER
- || GetPartyMenuType() == PARTY_MENU_TYPE_UNION_ROOM_TRADE)
- && sUnionRoomTrade.field_0 != 0)
+ || GetPartyMenuType() == PARTY_MENU_TYPE_UNION_ROOM_TRADE)
+ && sUnionRoomTrade.state != URTRADE_STATE_NONE)
{
id = GetCursorSelectionMonId();
- switch (sUnionRoomTrade.field_0)
+ switch (sUnionRoomTrade.state)
{
- case 1:
- sub_8011090(0x54, 0, 1);
+ case URTRADE_STATE_REGISTERING:
+ UpdateGameData_SetActivity(ACTIVITY_PLYRTALK | IN_UNION_ROOM, 0, TRUE);
if (id >= PARTY_SIZE)
{
ResetUnionRoomTrade(&sUnionRoomTrade);
- sub_8010FCC(0, 0, 0);
- sub_801568C(sText_RegistrationCanceled);
+ SetTradeBoardRegisteredMonInfo(TYPE_NORMAL, SPECIES_NONE, 0);
+ ScheduleFieldMessageAndExit(sText_RegistrationCanceled);
}
else if (!RegisterTradeMonAndGetIsEgg(GetCursorSelectionMonId(), &sUnionRoomTrade))
{
- sub_8015664(0x34, sText_ChooseRequestedMonType);
+ ScheduleFieldMessageWithFollowupState(UR_STATE_REGISTER_REQUEST_TYPE, sText_ChooseRequestedMonType);
}
else
{
- data->state = 55;
+ uroom->state = UR_STATE_REGISTER_COMPLETE;
}
break;
- case 2:
- sub_80156C8(data);
- taskData[1] = sUnionRoomTrade.field_8;
+ case URTRADE_STATE_OFFERING:
+ sub_80156C8(uroom);
+ taskData[1] = sUnionRoomTrade.offerPlayerId;
if (id >= PARTY_SIZE)
{
- sub_801568C(sText_TradeCanceled);
+ ScheduleFieldMessageAndExit(sText_TradeCanceled);
}
else
{
- sub_8011090(0x54, 0, 1);
- gUnknown_02022C2C = 0x44;
+ UpdateGameData_SetActivity(ACTIVITY_PLYRTALK | IN_UNION_ROOM, 0, TRUE);
+ gPlayerCurrActivity = ACTIVITY_TRADE | IN_UNION_ROOM;
RegisterTradeMon(GetCursorSelectionMonId(), &sUnionRoomTrade);
- data->state = 51;
+ uroom->state = UR_STATE_TRADE_OFFER_MON;
}
break;
}
- sUnionRoomTrade.field_0 = 0;
+ sUnionRoomTrade.state = URTRADE_STATE_NONE;
}
else
{
- data->state = 4;
+ uroom->state = UR_STATE_MAIN;
}
break;
- case 4:
+ case UR_STATE_MAIN:
if (gSpecialVar_Result != 0)
{
- if (gSpecialVar_Result == 9)
+ if (gSpecialVar_Result == UR_INTERACT_ATTENDANT)
{
- sub_8011090(0x54, 0, 1);
+ UpdateGameData_SetActivity(ACTIVITY_PLYRTALK | IN_UNION_ROOM, 0, TRUE);
PlaySE(SE_PC_LOGIN);
StringCopy(gStringVar1, gSaveBlock2Ptr->playerName);
- data->state = 42;
+ uroom->state = UR_STATE_INTERACT_WITH_ATTENDANT;
gSpecialVar_Result = 0;
}
- else if (gSpecialVar_Result == 11)
+ else if (gSpecialVar_Result == UR_INTERACT_START_MENU)
{
- sub_8011090(0x54, 0, 1);
- data->state = 23;
+ UpdateGameData_SetActivity(ACTIVITY_PLYRTALK | IN_UNION_ROOM, 0, TRUE);
+ uroom->state = UR_STATE_WAIT_FOR_START_MENU;
gSpecialVar_Result = 0;
}
- else
+ else // UR_INTERACT_PLAYER_# (1-8)
{
taskData[0] = 0;
taskData[1] = gSpecialVar_Result - 1;
- data->state = 24;
+ uroom->state = UR_STATE_INTERACT_WITH_PLAYER;
gSpecialVar_Result = 0;
}
}
@@ -2382,676 +2549,688 @@ void sub_80156E0(u8 taskId)
{
if (gMain.newKeys & A_BUTTON)
{
- if (sub_801A2A8(data->field_0, &taskData[0], &taskData[1], data->spriteIds))
+ if (TryInteractWithUnionRoomMember(uroom->field_0, &taskData[0], &taskData[1], uroom->spriteIds))
{
PlaySE(SE_SELECT);
- sub_80181CC();
- data->state = 24;
+ UR_EnableScriptContext2AndFreezeObjectEvents();
+ uroom->state = UR_STATE_INTERACT_WITH_PLAYER;
break;
}
- else if (sub_8017940())
+ else if (IsPlayerFacingTradingBoard())
{
- sub_8011090(0x54, 0, 1);
+ UpdateGameData_SetActivity(ACTIVITY_PLYRTALK | IN_UNION_ROOM, 0, TRUE);
PlaySE(SE_PC_LOGIN);
- sub_80181CC();
+ UR_EnableScriptContext2AndFreezeObjectEvents();
StringCopy(gStringVar1, gSaveBlock2Ptr->playerName);
- data->state = 45;
+ uroom->state = UR_STATE_CHECK_TRADING_BOARD;
break;
}
}
- switch (sub_8016B00())
+ switch (HandlePlayerListUpdate())
{
case 1:
PlaySE(SE_PC_LOGIN);
case 2:
- sub_801A274(data);
+ ScheduleUnionRoomPlayerRefresh(uroom);
break;
case 4:
- data->state = 11;
- sub_80181CC();
- sub_8010FCC(0, 0, 0);
- sub_8011090(0x53, sub_80181DC(data), 0);
+ uroom->state = UR_STATE_PLAYER_CONTACTED_YOU;
+ UR_EnableScriptContext2AndFreezeObjectEvents();
+ SetTradeBoardRegisteredMonInfo(TYPE_NORMAL, SPECIES_NONE, 0);
+ UpdateGameData_SetActivity(ACTIVITY_NPCTALK | IN_UNION_ROOM, GetActivePartnerSpriteGenderParam(uroom), FALSE);
break;
}
- sub_801A284(data);
+ HandleUnionRoomPlayerRefresh(uroom);
}
break;
- case 23:
+ case UR_STATE_WAIT_FOR_START_MENU:
if (!FuncIsActiveTask(Task_ShowStartMenu))
{
- sub_8011090(0x40, 0, 0);
- data->state = 4;
+ UpdateGameData_SetActivity(ACTIVITY_NONE | IN_UNION_ROOM, 0, FALSE);
+ uroom->state = UR_STATE_MAIN;
}
break;
- case 24:
- sub_801704C();
- playerGender = sub_8017CF8(taskData[1], data->field_0);
- sub_8011090(0x54, 0, 1);
- switch (sub_80179D4(data->field_0, taskData[0], taskData[1], playerGender))
+ case UR_STATE_INTERACT_WITH_PLAYER:
+ UR_RunTextPrinters_CheckPrinter0Active();
+ playerGender = GetUnionRoomPlayerGender(taskData[1], uroom->field_0);
+ UpdateGameData_SetActivity(ACTIVITY_PLYRTALK | IN_UNION_ROOM, 0, TRUE);
+ switch (UnionRoomGetPlayerInteractionResponse(uroom->field_0, taskData[0], taskData[1], playerGender))
{
- case 0:
- data->state = 26;
+ case 0: // Player is or was just doing an activity
+ uroom->state = UR_STATE_PRINT_AND_EXIT;
break;
- case 1:
- sub_8012188(data->field_0->arr[taskData[1]].unk.playerName, &data->field_0->arr[taskData[1]].unk.field_0, gUnknown_02022C2C);
- data->field_12 = id; // Should be just 0, but won't match any other way.
- data->state = 25;
+ case 1: // Link communicating
+ sub_8012188(uroom->field_0->arr[taskData[1]].gname_uname.playerName, &uroom->field_0->arr[taskData[1]].gname_uname.gname, gPlayerCurrActivity);
+ uroom->field_12 = id; // Should be just 0, but won't match any other way.
+ uroom->state = UR_STATE_TRY_COMMUNICATING;
break;
- case 2:
- sub_8015664(0x13, gStringVar4);
+ case 2: // Ask to join chat
+ ScheduleFieldMessageWithFollowupState(UR_STATE_RECV_JOIN_CHAT_REQUEST, gStringVar4);
break;
}
break;
- case 25:
- sub_801704C();
- switch (sub_8011A74())
+ case UR_STATE_TRY_COMMUNICATING:
+ UR_RunTextPrinters_CheckPrinter0Active();
+ switch (RfuGetStatus())
{
- case 4:
- sub_801818C(TRUE);
- data->state = 4;
+ case RFU_STATUS_NEW_CHILD_DETECTED:
+ HandleCancelActivity(TRUE);
+ uroom->state = UR_STATE_MAIN;
break;
- case 1:
- case 2:
- if (sub_8011B90() == TRUE)
- sub_801568C(sText_TrainerAppearsBusy);
+ case RFU_STATUS_FATAL_ERROR:
+ case RFU_STATUS_CONNECTION_ERROR:
+ if (IsUnionRoomListenTaskActive() == TRUE)
+ ScheduleFieldMessageAndExit(sText_TrainerAppearsBusy);
else
- sub_8015664(30, sText_TrainerAppearsBusy);
+ ScheduleFieldMessageWithFollowupState(UR_STATE_CANCEL_ACTIVITY_LINK_ERROR, sText_TrainerAppearsBusy);
- gUnknown_02022C2C = 0x40;
+ gPlayerCurrActivity = IN_UNION_ROOM;
break;
}
- if (gReceivedRemoteLinkPlayers != 0)
+ if (gReceivedRemoteLinkPlayers)
{
- sub_80143E4(gBlockSendBuffer, TRUE);
- CreateTask(sub_80140E0, 5);
- data->state = 38;
+ CreateTrainerCardInBuffer(gBlockSendBuffer, TRUE);
+ CreateTask(Task_ExchangeCards, 5);
+ uroom->state = UR_STATE_COMMUNICATING_WAIT_FOR_DATA;
}
break;
- case 38:
- if (!FuncIsActiveTask(sub_80140E0))
+ case UR_STATE_COMMUNICATING_WAIT_FOR_DATA:
+ if (!FuncIsActiveTask(Task_ExchangeCards))
{
- if (gUnknown_02022C2C == 0x44)
- sub_8015664(31, sText_AwaitingPlayersResponseAboutTrade);
+ if (gPlayerCurrActivity == (ACTIVITY_TRADE | IN_UNION_ROOM))
+ ScheduleFieldMessageWithFollowupState(UR_STATE_SEND_TRADE_REQUST, sText_AwaitingPlayersResponseAboutTrade);
else
- data->state = 5;
+ uroom->state = UR_STATE_DO_SOMETHING_PROMPT;
}
break;
- case 30:
- if (gReceivedRemoteLinkPlayers == 0)
+ case UR_STATE_CANCEL_ACTIVITY_LINK_ERROR:
+ if (!gReceivedRemoteLinkPlayers)
{
- sub_801818C(FALSE);
- sub_801A3D0(taskData[0], taskData[1], data->field_0);
- data->state = 2;
+ HandleCancelActivity(FALSE);
+ UpdateUnionRoomMemberFacing(taskData[0], taskData[1], uroom->field_0);
+ uroom->state = UR_STATE_INIT_LINK;
}
break;
- case 5:
- id = sub_80179AC(&data->field_0->arr[taskData[1]]);
- playerGender = sub_8017CF8(taskData[1], data->field_0);
- sub_8015664(6, sHiDoSomethingTexts[id][playerGender]);
+ case UR_STATE_DO_SOMETHING_PROMPT:
+ id = ConvPartnerUnameAndGetWhetherMetAlready(&uroom->field_0->arr[taskData[1]]);
+ playerGender = GetUnionRoomPlayerGender(taskData[1], uroom->field_0);
+ ScheduleFieldMessageWithFollowupState(UR_STATE_HANDLE_DO_SOMETHING_PROMPT_INPUT, sHiDoSomethingTexts[id][playerGender]);
break;
- case 6:
- var5 = sub_8017178(&data->textState, &data->field_1B, &data->field_1C, &gUnknown_082F021C, &gUnknown_082F0244);
- if (var5 != -1)
+ case UR_STATE_HANDLE_DO_SOMETHING_PROMPT_INPUT:
+ input = ListMenuHandler_AllItemsAvailable(&uroom->textState,
+ &uroom->topListMenuWindowId,
+ &uroom->topListMenuId,
+ &sWindowTemplate_InviteToActivity,
+ &sListMenuTemplate_InviteToActivity);
+ if (input != -1)
{
- if (gReceivedRemoteLinkPlayers == 0)
+ if (!gReceivedRemoteLinkPlayers)
{
- data->state = 28;
+ uroom->state = UR_STATE_TRAINER_APPEARS_BUSY;
}
else
{
- data->field_98 = 0;
- playerGender = sub_8017CF8(taskData[1], data->field_0);
- if (var5 == -2 || var5 == 0x40)
+ uroom->partnerYesNoResponse = 0;
+ playerGender = GetUnionRoomPlayerGender(taskData[1], uroom->field_0);
+ if (input == -2 || input == IN_UNION_ROOM)
{
- data->field_4C[0] = 0x40;
- sub_800FE50(data->field_4C);
+ uroom->playerSendBuffer[0] = IN_UNION_ROOM;
+ sub_800FE50(uroom->playerSendBuffer);
StringCopy(gStringVar4, sIfYouWantToDoSomethingTexts[gLinkPlayers[0].gender]);
- data->state = 32;
+ uroom->state = UR_STATE_REQUEST_DECLINED;
}
else
{
- gUnknown_02022C2C = var5;
- gUnknown_02022C2D = (u32)(var5) >> 8;
- if (gUnknown_02022C2C == 0x41 && !HasAtLeastTwoMonsOfLevel30OrLower())
+ gPlayerCurrActivity = input;
+ sPlayerActivityGroupSize = (u32)(input) >> 8;
+ if (gPlayerCurrActivity == (ACTIVITY_BATTLE_SINGLE | IN_UNION_ROOM) && !HasAtLeastTwoMonsOfLevel30OrLower())
{
- sub_8015664(5, sText_NeedTwoMonsOfLevel30OrLower1);
+ ScheduleFieldMessageWithFollowupState(UR_STATE_DO_SOMETHING_PROMPT, sText_NeedTwoMonsOfLevel30OrLower1);
}
else
{
- data->field_4C[0] = gUnknown_02022C2C | 0x40;
- sub_800FE50(data->field_4C);
- data->state = 27;
+ uroom->playerSendBuffer[0] = gPlayerCurrActivity | IN_UNION_ROOM;
+ sub_800FE50(uroom->playerSendBuffer);
+ uroom->state = UR_STATE_SEND_ACTIVITY_REQUEST;
}
}
}
}
break;
- case 28:
+ case UR_STATE_TRAINER_APPEARS_BUSY:
StringCopy(gStringVar4, sText_TrainerBattleBusy);
- data->state = 36;
+ uroom->state = UR_STATE_CANCEL_REQUEST_PRINT_MSG;
break;
- case 27:
- sub_8017FD8(data);
- playerGender = sub_8017CF8(taskData[1], data->field_0);
- id = sub_8017984(data->field_4C[0] & 0x3F);
- if (PrintOnTextbox(&data->textState, sText_WaitOrShowCardTexts[playerGender][id]))
+ case UR_STATE_SEND_ACTIVITY_REQUEST:
+ PollPartnerYesNoResponse(uroom);
+ playerGender = GetUnionRoomPlayerGender(taskData[1], uroom->field_0);
+ id = GetResponseIdx_InviteToURoomActivity(uroom->playerSendBuffer[0] & 0x3F);
+ if (PrintOnTextbox(&uroom->textState, sText_WaitOrShowCardTexts[playerGender][id]))
{
taskData[3] = 0;
- data->state = 29;
+ uroom->state = UR_STATE_WAIT_FOR_RESPONSE_TO_REQUEST;
}
break;
- case 32:
+ case UR_STATE_REQUEST_DECLINED:
sub_800AC34();
- data->state = 36;
+ uroom->state = UR_STATE_CANCEL_REQUEST_PRINT_MSG;
break;
- case 31:
- data->field_4C[0] = 0x44;
- data->field_4C[1] = sUnionRoomTrade.species;
- data->field_4C[2] = sUnionRoomTrade.level;
- sub_800FE50(data->field_4C);
- data->state = 29;
+ case UR_STATE_SEND_TRADE_REQUST:
+ uroom->playerSendBuffer[0] = ACTIVITY_TRADE | IN_UNION_ROOM;
+ uroom->playerSendBuffer[1] = sUnionRoomTrade.species;
+ uroom->playerSendBuffer[2] = sUnionRoomTrade.level;
+ sub_800FE50(uroom->playerSendBuffer);
+ uroom->state = UR_STATE_WAIT_FOR_RESPONSE_TO_REQUEST;
break;
- case 29:
- if (gReceivedRemoteLinkPlayers == 0)
+ case UR_STATE_WAIT_FOR_RESPONSE_TO_REQUEST:
+ if (!gReceivedRemoteLinkPlayers)
{
- StringCopy(gStringVar4, sText_TrainerBattleBusy);
- data->state = 28;
+ StringCopy(gStringVar4, sText_TrainerBattleBusy); // Redundant, will be copied again in next state
+ uroom->state = UR_STATE_TRAINER_APPEARS_BUSY;
}
else
{
- sub_8017FD8(data);
- if (data->field_98 == 0x51)
+ PollPartnerYesNoResponse(uroom);
+ if (uroom->partnerYesNoResponse == (ACTIVITY_ACCEPT | IN_UNION_ROOM))
{
- if (gUnknown_02022C2C == 8)
+ if (gPlayerCurrActivity == ACTIVITY_CARD)
{
- sub_8018220(gStringVar4, data, FALSE);
- data->state = 40;
+ ViewURoomPartnerTrainerCard(gStringVar4, uroom, FALSE);
+ uroom->state = UR_STATE_PRINT_CARD_INFO;
}
else
{
- data->state = 13;
+ uroom->state = UR_STATE_PRINT_START_ACTIVITY_MSG;
}
}
- else if (data->field_98 == 0x52)
+ else if (uroom->partnerYesNoResponse == (ACTIVITY_DECLINE | IN_UNION_ROOM))
{
- data->state = 32;
- sub_8017D9C(gStringVar4, gUnknown_02022C2C | 0x40, gLinkPlayers[0].gender);
- gUnknown_02022C2C = 0;
+ uroom->state = UR_STATE_REQUEST_DECLINED;
+ GetURoomActivityRejectMsg(gStringVar4, gPlayerCurrActivity | IN_UNION_ROOM, gLinkPlayers[0].gender);
+ gPlayerCurrActivity = ACTIVITY_NONE;
}
}
break;
- case 7:
- id = sub_80179AC(&data->field_0->arr[taskData[1]]);
- playerGender = sub_8017CF8(taskData[1], data->field_0);
- sub_8015664(6, sHiDoSomethingTexts[id][playerGender]);
+ case UR_STATE_DO_SOMETHING_PROMPT_2: // Identical to UR_STATE_DO_SOMETHING_PROMPT
+ id = ConvPartnerUnameAndGetWhetherMetAlready(&uroom->field_0->arr[taskData[1]]);
+ playerGender = GetUnionRoomPlayerGender(taskData[1], uroom->field_0);
+ ScheduleFieldMessageWithFollowupState(UR_STATE_HANDLE_DO_SOMETHING_PROMPT_INPUT, sHiDoSomethingTexts[id][playerGender]);
break;
- case 40:
- if (PrintOnTextbox(&data->textState, gStringVar4))
+ case UR_STATE_PRINT_CARD_INFO:
+ if (PrintOnTextbox(&uroom->textState, gStringVar4))
{
- data->state = 41;
+ uroom->state = UR_STATE_WAIT_FINISH_READING_CARD;
sub_800ADF8();
- data->field_98 = 0;
- data->field_9A[0] = 0;
+ uroom->partnerYesNoResponse = 0;
+ uroom->recvActivityRequest[0] = 0;
}
break;
- case 41:
+ case UR_STATE_WAIT_FINISH_READING_CARD:
if (IsLinkTaskFinished())
{
if (GetMultiplayerId() == 0)
{
StringCopy(gStringVar1, gLinkPlayers[GetMultiplayerId() ^ 1].name);
- id = sub_800E540(gLinkPlayers[1].trainerId, gLinkPlayers[1].name);
+ id = PlayerHasMetTrainerBefore(gLinkPlayers[1].trainerId, gLinkPlayers[1].name);
StringExpandPlaceholders(gStringVar4, sAwaitingResponseTexts[id]);
- data->state = 33;
+ uroom->state = UR_STATE_PRINT_CONTACT_MSG;
}
else
{
- data->state = 7;
+ uroom->state = UR_STATE_DO_SOMETHING_PROMPT_2;
}
}
break;
- case 19:
- switch (sub_80170B8(&data->textState, FALSE))
+ case UR_STATE_RECV_JOIN_CHAT_REQUEST:
+ switch (UnionRoomHandleYesNo(&uroom->textState, FALSE))
{
- case 0:
+ case 0: // YES
CopyBgTilemapBufferToVram(0);
- gUnknown_02022C2C = 0x45;
- sub_8011090(0x45, 0, 1);
- sub_8012188(data->field_0->arr[taskData[1]].unk.playerName, &data->field_0->arr[taskData[1]].unk.field_0, gUnknown_02022C2C);
- data->field_12 = taskData[1];
- data->state = 20;
+ gPlayerCurrActivity = ACTIVITY_CHAT | IN_UNION_ROOM;
+ UpdateGameData_SetActivity(ACTIVITY_CHAT | IN_UNION_ROOM, 0, TRUE);
+ sub_8012188(uroom->field_0->arr[taskData[1]].gname_uname.playerName, &uroom->field_0->arr[taskData[1]].gname_uname.gname, gPlayerCurrActivity);
+ uroom->field_12 = taskData[1];
+ uroom->state = UR_STATE_TRY_ACCEPT_CHAT_REQUEST_DELAY;
taskData[3] = 0;
break;
- case 1:
+ case 1: // NO
case -1:
- playerGender = sub_8017CF8(taskData[1], data->field_0);
- sub_801568C(sDeclineBattleTexts[playerGender]);
+ playerGender = GetUnionRoomPlayerGender(taskData[1], uroom->field_0);
+ ScheduleFieldMessageAndExit(sDeclineChatTexts[playerGender]);
break;
}
break;
- case 20:
+ case UR_STATE_TRY_ACCEPT_CHAT_REQUEST_DELAY:
if (++taskData[2] > 60)
{
- data->state = 21;
+ uroom->state = UR_STATE_TRY_ACCEPT_CHAT_REQUEST;
taskData[2] = 0;
}
break;
- case 21:
- switch (sub_8011A74())
+ case UR_STATE_TRY_ACCEPT_CHAT_REQUEST:
+ switch (RfuGetStatus())
{
- case 4:
- sub_801818C(TRUE);
- data->state = 4;
+ case RFU_STATUS_NEW_CHILD_DETECTED:
+ HandleCancelActivity(TRUE);
+ uroom->state = UR_STATE_MAIN;
break;
- case 1:
- case 2:
- playerGender = sub_8017CF8(taskData[1], data->field_0);
- sub_8011090(0x54, 0, 1);
- if (sub_8011B90() == TRUE)
- sub_801568C(sChatDeclinedTexts[playerGender]);
+ case RFU_STATUS_FATAL_ERROR:
+ case RFU_STATUS_CONNECTION_ERROR:
+ playerGender = GetUnionRoomPlayerGender(taskData[1], uroom->field_0);
+ UpdateGameData_SetActivity(ACTIVITY_PLYRTALK | IN_UNION_ROOM, 0, TRUE);
+ if (IsUnionRoomListenTaskActive() == TRUE)
+ ScheduleFieldMessageAndExit(sChatDeclinedTexts[playerGender]);
else
- sub_8015664(30, sChatDeclinedTexts[playerGender]);
+ ScheduleFieldMessageWithFollowupState(UR_STATE_CANCEL_ACTIVITY_LINK_ERROR, sChatDeclinedTexts[playerGender]);
break;
- case 3:
- data->state = 22;
+ case RFU_STATUS_CHILD_SEND_COMPLETE:
+ uroom->state = UR_STATE_ACCEPT_CHAT_REQUEST;
break;
}
taskData[3]++;
break;
- case 22:
- if (sub_8011A80())
+ case UR_STATE_ACCEPT_CHAT_REQUEST:
+ if (RfuHasErrored())
{
- playerGender = sub_8017CF8(taskData[1], data->field_0);
- sub_8011090(0x54, 0, 1);
- if (sub_8011B90() == TRUE)
- sub_801568C(sChatDeclinedTexts[playerGender]);
+ playerGender = GetUnionRoomPlayerGender(taskData[1], uroom->field_0);
+ UpdateGameData_SetActivity(ACTIVITY_PLYRTALK | IN_UNION_ROOM, 0, TRUE);
+ if (IsUnionRoomListenTaskActive() == TRUE)
+ ScheduleFieldMessageAndExit(sChatDeclinedTexts[playerGender]);
else
- sub_8015664(30, sChatDeclinedTexts[playerGender]);
+ ScheduleFieldMessageWithFollowupState(UR_STATE_CANCEL_ACTIVITY_LINK_ERROR, sChatDeclinedTexts[playerGender]);
}
- if (gReceivedRemoteLinkPlayers != 0)
- data->state = 16;
+ if (gReceivedRemoteLinkPlayers)
+ uroom->state = UR_STATE_START_ACTIVITY_FREE_UROOM;
break;
- case 11:
+ case UR_STATE_PLAYER_CONTACTED_YOU:
PlaySE(SE_PINPON);
sub_800EF7C();
- data->state = 12;
- data->field_9A[0] = 0;
+ uroom->state = UR_STATE_RECV_CONTACT_DATA;
+ uroom->recvActivityRequest[0] = 0;
break;
- case 12:
- if (sub_8011A80())
+ case UR_STATE_RECV_CONTACT_DATA:
+ if (RfuHasErrored())
{
- sub_801818C(FALSE);
- data->state = 2;
+ HandleCancelActivity(FALSE);
+ uroom->state = UR_STATE_INIT_LINK;
}
- else if (gReceivedRemoteLinkPlayers != 0)
+ else if (gReceivedRemoteLinkPlayers)
{
- sub_80143E4(gBlockSendBuffer, TRUE);
- CreateTask(sub_80140E0, 5);
- data->state = 39;
+ CreateTrainerCardInBuffer(gBlockSendBuffer, TRUE);
+ CreateTask(Task_ExchangeCards, 5);
+ uroom->state = UR_STATE_WAIT_FOR_CONTACT_DATA;
}
break;
- case 39:
- sub_801689C(data);
- if (!FuncIsActiveTask(sub_80140E0))
+ case UR_STATE_WAIT_FOR_CONTACT_DATA:
+ ReceiveUnionRoomActivityPacket(uroom);
+ if (!FuncIsActiveTask(Task_ExchangeCards))
{
- data->state = 33;
+ uroom->state = UR_STATE_PRINT_CONTACT_MSG;
StringCopy(gStringVar1, gLinkPlayers[1].name);
- id = sub_800E540(gLinkPlayers[1].trainerId, gLinkPlayers[1].name);
+ id = PlayerHasMetTrainerBefore(gLinkPlayers[1].trainerId, gLinkPlayers[1].name);
StringExpandPlaceholders(gStringVar4, sPlayerContactedYouTexts[id]);
}
break;
- case 33:
- sub_801689C(data);
- if (PrintOnTextbox(&data->textState, gStringVar4))
- data->state = 34;
+ case UR_STATE_PRINT_CONTACT_MSG:
+ ReceiveUnionRoomActivityPacket(uroom);
+ if (PrintOnTextbox(&uroom->textState, gStringVar4))
+ uroom->state = UR_STATE_HANDLE_CONTACT_DATA;
break;
- case 34:
- sub_801689C(data);
- if (sub_80168DC(data) && gMain.newKeys & B_BUTTON)
+ case UR_STATE_HANDLE_CONTACT_DATA:
+ ReceiveUnionRoomActivityPacket(uroom);
+ if (UnionRoom_HandleContactFromOtherPlayer(uroom) && gMain.newKeys & B_BUTTON)
{
sub_8011DE0(1);
StringCopy(gStringVar4, sText_ChatEnded);
- data->state = 36;
+ uroom->state = UR_STATE_CANCEL_REQUEST_PRINT_MSG;
}
break;
- case 35:
- sub_8015664(9, gStringVar4);
+ case UR_STATE_RECV_ACTIVITY_REQUEST:
+ ScheduleFieldMessageWithFollowupState(UR_STATE_HANDLE_ACTIVITY_REQUEST, gStringVar4);
break;
- case 9:
- switch (sub_80170B8(&data->textState, FALSE))
+ case UR_STATE_HANDLE_ACTIVITY_REQUEST:
+ switch (UnionRoomHandleYesNo(&uroom->textState, FALSE))
{
- case 0:
- data->field_4C[0] = 0x51;
- if (gUnknown_02022C2C == 0x45)
- sub_8011090(gUnknown_02022C2C | 0x40, sub_801100C(1), 0);
+ case 0: // ACCEPT
+ uroom->playerSendBuffer[0] = ACTIVITY_ACCEPT | IN_UNION_ROOM;
+ if (gPlayerCurrActivity == (ACTIVITY_CHAT | IN_UNION_ROOM))
+ UpdateGameData_SetActivity(gPlayerCurrActivity | IN_UNION_ROOM, sub_801100C(1), FALSE);
else
- sub_8011090(gUnknown_02022C2C | 0x40, sub_801100C(1), 1);
+ UpdateGameData_SetActivity(gPlayerCurrActivity | IN_UNION_ROOM, sub_801100C(1), TRUE);
- data->field_8->arr[0].field_1B = 0;
+ uroom->field_8->arr[0].field_1B = 0;
taskData[3] = 0;
- if (gUnknown_02022C2C == 0x41)
+ if (gPlayerCurrActivity == (ACTIVITY_BATTLE_SINGLE | IN_UNION_ROOM))
{
if (!HasAtLeastTwoMonsOfLevel30OrLower())
{
- data->field_4C[0] = 0x52;
- sub_800FE50(data->field_4C);
- data->state = 10;
+ uroom->playerSendBuffer[0] = ACTIVITY_DECLINE | IN_UNION_ROOM;
+ sub_800FE50(uroom->playerSendBuffer);
+ uroom->state = UR_STATE_DECLINE_ACTIVITY_REQUEST;
StringCopy(gStringVar4, sText_NeedTwoMonsOfLevel30OrLower2);
}
else
{
- sub_800FE50(data->field_4C);
- data->state = 13;
+ sub_800FE50(uroom->playerSendBuffer);
+ uroom->state = UR_STATE_PRINT_START_ACTIVITY_MSG;
}
}
- else if (gUnknown_02022C2C == 0x48)
+ else if (gPlayerCurrActivity == (ACTIVITY_CARD | IN_UNION_ROOM))
{
- sub_800FE50(data->field_4C);
- sub_8018220(gStringVar4, data, 1);
- data->state = 40;
+ sub_800FE50(uroom->playerSendBuffer);
+ ViewURoomPartnerTrainerCard(gStringVar4, uroom, TRUE);
+ uroom->state = UR_STATE_PRINT_CARD_INFO;
}
else
{
- sub_800FE50(data->field_4C);
- data->state = 13;
+ sub_800FE50(uroom->playerSendBuffer);
+ uroom->state = UR_STATE_PRINT_START_ACTIVITY_MSG;
}
break;
- case 1:
+ case 1: // DECLINE
case -1:
- data->field_4C[0] = 0x52;
- sub_800FE50(data->field_4C);
- data->state = 10;
- sub_8013078(gStringVar4, gUnknown_02022C2C);
+ uroom->playerSendBuffer[0] = ACTIVITY_DECLINE | IN_UNION_ROOM;
+ sub_800FE50(uroom->playerSendBuffer);
+ uroom->state = UR_STATE_DECLINE_ACTIVITY_REQUEST;
+ GetYouDeclinedTheOfferMessage(gStringVar4, gPlayerCurrActivity);
break;
}
break;
- case 10:
+ case UR_STATE_DECLINE_ACTIVITY_REQUEST:
sub_800AC34();
- data->state = 36;
+ uroom->state = UR_STATE_CANCEL_REQUEST_PRINT_MSG;
break;
- case 36:
- if (gReceivedRemoteLinkPlayers == 0)
+ case UR_STATE_CANCEL_REQUEST_PRINT_MSG:
+ if (!gReceivedRemoteLinkPlayers)
{
- gUnknown_02022C2C = 0x40;
- sub_8015664(0x25, gStringVar4);
- memset(data->field_4C, 0, sizeof(data->field_4C));
- data->field_9A[0] = 0;
- data->field_98 = 0;
+ gPlayerCurrActivity = IN_UNION_ROOM;
+ ScheduleFieldMessageWithFollowupState(UR_STATE_CANCEL_REQUEST_RESTART_LINK, gStringVar4);
+ memset(uroom->playerSendBuffer, 0, sizeof(uroom->playerSendBuffer));
+ uroom->recvActivityRequest[0] = 0;
+ uroom->partnerYesNoResponse = 0;
}
break;
- case 37:
- data->state = 2;
- sub_801818C(FALSE);
+ case UR_STATE_CANCEL_REQUEST_RESTART_LINK:
+ uroom->state = UR_STATE_INIT_LINK;
+ HandleCancelActivity(FALSE);
break;
- case 13:
- sub_8017E00(gStringVar4, gUnknown_02022C2C | 0x40);
- sub_8015664(14, gStringVar4);
+ case UR_STATE_PRINT_START_ACTIVITY_MSG:
+ GetURoomActivityStartMsg(gStringVar4, gPlayerCurrActivity | IN_UNION_ROOM);
+ ScheduleFieldMessageWithFollowupState(UR_STATE_START_ACTIVITY_LINK, gStringVar4);
break;
- case 14:
+ case UR_STATE_START_ACTIVITY_LINK:
sub_800ADF8();
- data->state = 15;
+ uroom->state = UR_STATE_START_ACTIVITY_WAIT_FOR_LINK;
break;
- case 15:
+ case UR_STATE_START_ACTIVITY_WAIT_FOR_LINK:
if (IsLinkTaskFinished())
- data->state = 16;
- break;
- case 16:
- Free(data->field_8);
- Free(data->field_0);
- Free(data->field_C);
- Free(data->field_4);
- DestroyTask(data->field_20);
- sub_8019F04(data->spriteIds);
- data->state = 17;
- break;
- case 17:
+ uroom->state = UR_STATE_START_ACTIVITY_FREE_UROOM;
+ break;
+ case UR_STATE_START_ACTIVITY_FREE_UROOM:
+ Free(uroom->field_8);
+ Free(uroom->field_0);
+ Free(uroom->field_C);
+ Free(uroom->field_4);
+ DestroyTask(uroom->searchTaskId);
+ DestroyGroupMemberSprites(uroom->spriteIds);
+ uroom->state = UR_STATE_START_ACTIVITY_FADE;
+ break;
+ case UR_STATE_START_ACTIVITY_FADE:
BeginNormalPaletteFade(-1, 0, 0, 0x10, RGB_BLACK);
- data->state = 18;
+ uroom->state = UR_STATE_START_ACTIVITY;
break;
- case 18:
+ case UR_STATE_START_ACTIVITY:
if (!UpdatePaletteFade())
{
- sub_8019E3C();
+ DestroyUnionRoomPlayerObjects();
DestroyTask(taskId);
- Free(gUnknown_02022C30.uRoom);
- sub_80149D8();
+ Free(sWirelessLinkMain.uRoom);
+ CreateTask_StartActivity();
}
break;
- case 42:
- if (sub_800F7DC()->species == SPECIES_NONE)
+ case UR_STATE_INTERACT_WITH_ATTENDANT:
+ if (GetHostRFUtgtGname()->species == SPECIES_NONE)
{
- data->state = 43;
+ uroom->state = UR_STATE_REGISTER_PROMPT;
}
else
{
- if (sub_800F7DC()->species == SPECIES_EGG)
+ if (GetHostRFUtgtGname()->species == SPECIES_EGG)
{
StringCopy(gStringVar4, sText_CancelRegistrationOfEgg);
}
else
{
- StringCopy(gStringVar1, gSpeciesNames[sub_800F7DC()->species]);
- ConvertIntToDecimalStringN(gStringVar2, sub_800F7DC()->level, STR_CONV_MODE_LEFT_ALIGN, 3);
+ StringCopy(gStringVar1, gSpeciesNames[GetHostRFUtgtGname()->species]);
+ ConvertIntToDecimalStringN(gStringVar2, GetHostRFUtgtGname()->level, STR_CONV_MODE_LEFT_ALIGN, 3);
StringExpandPlaceholders(gStringVar4, sText_CancelRegistrationOfMon);
}
- sub_8015664(44, gStringVar4);
+ ScheduleFieldMessageWithFollowupState(UR_STATE_CANCEL_REGISTRATION_PROMPT, gStringVar4);
}
break;
- case 43:
- if (PrintOnTextbox(&data->textState, sText_RegisterMonAtTradingBoard))
- data->state = 47;
+ case UR_STATE_REGISTER_PROMPT:
+ if (PrintOnTextbox(&uroom->textState, sText_RegisterMonAtTradingBoard))
+ uroom->state = UR_STATE_REGISTER_PROMPT_HANDLE_INPUT;
break;
- case 47:
- var5 = sub_8017178(&data->textState, &data->field_1D, &data->field_1E, &gUnknown_082F025C, &gUnknown_082F027C);
- if (var5 != -1)
+ case UR_STATE_REGISTER_PROMPT_HANDLE_INPUT:
+ input = ListMenuHandler_AllItemsAvailable(&uroom->textState,
+ &uroom->tradeBoardSelectWindowId,
+ &uroom->tradeBoardDetailsWindowId,
+ &sWindowTemplate_RegisterForTrade,
+ &sListMenuTemplate_RegisterForTrade);
+ if (input != -1)
{
- if (var5 == -2 || var5 == 3)
+ if (input == -2 || input == 3)
{
- data->state = 4;
- sub_801818C(TRUE);
+ uroom->state = UR_STATE_MAIN;
+ HandleCancelActivity(TRUE);
}
else
{
- switch (var5)
+ switch (input)
{
case 1: // REGISTER
- sub_8015664(53, sText_WhichMonWillYouOffer);
+ ScheduleFieldMessageWithFollowupState(UR_STATE_REGISTER_SELECT_MON_FADE, sText_WhichMonWillYouOffer);
break;
case 2: // INFO
- sub_8015664(47, sText_TradingBoardInfo);
+ ScheduleFieldMessageWithFollowupState(UR_STATE_REGISTER_PROMPT_HANDLE_INPUT, sText_TradingBoardInfo);
break;
}
}
}
break;
- case 53:
+ case UR_STATE_REGISTER_SELECT_MON_FADE:
BeginNormalPaletteFade(-1, 0, 0, 0x10, RGB_BLACK);
- data->state = 54;
+ uroom->state = UR_STATE_REGISTER_SELECT_MON;
break;
- case 54:
+ case UR_STATE_REGISTER_SELECT_MON:
if (!gPaletteFade.active)
{
- sUnionRoomTrade.field_0 = 1;
+ sUnionRoomTrade.state = URTRADE_STATE_REGISTERING;
gFieldCallback = FieldCB_ContinueScriptUnionRoom;
ChooseMonForTradingBoard(PARTY_MENU_TYPE_UNION_ROOM_REGISTER, CB2_ReturnToField);
}
break;
- case 52:
- var5 = sub_8017178(&data->textState, &data->field_1D, &data->field_1E, &gUnknown_082F0294, &sMenuTemplate_TradingBoardRequestType);
- if (var5 != -1)
+ case UR_STATE_REGISTER_REQUEST_TYPE:
+ input = ListMenuHandler_AllItemsAvailable(&uroom->textState,
+ &uroom->tradeBoardSelectWindowId,
+ &uroom->tradeBoardDetailsWindowId,
+ &gUnknown_082F0294,
+ &sMenuTemplate_TradingBoardRequestType);
+ if (input != -1)
{
- switch (var5)
+ switch (input)
{
case -2:
- case 18:
+ case NUMBER_OF_MON_TYPES: // Exit
ResetUnionRoomTrade(&sUnionRoomTrade);
- sub_8010FCC(0, 0, 0);
- sub_801568C(sText_RegistrationCanceled);
+ SetTradeBoardRegisteredMonInfo(TYPE_NORMAL, SPECIES_NONE, 0);
+ ScheduleFieldMessageAndExit(sText_RegistrationCanceled);
break;
default:
- sUnionRoomTrade.type = var5;
- data->state = 55;
+ sUnionRoomTrade.type = input;
+ uroom->state = UR_STATE_REGISTER_COMPLETE;
break;
}
}
break;
- case 55:
- sub_8010FCC(sUnionRoomTrade.type, sUnionRoomTrade.playerSpecies, sUnionRoomTrade.playerLevel);
- sub_801568C(sText_RegistraionCompleted);
+ case UR_STATE_REGISTER_COMPLETE:
+ SetTradeBoardRegisteredMonInfo(sUnionRoomTrade.type, sUnionRoomTrade.playerSpecies, sUnionRoomTrade.playerLevel);
+ ScheduleFieldMessageAndExit(sText_RegistraionCompleted);
break;
- case 44:
- switch (sub_80170B8(&data->textState, FALSE))
+ case UR_STATE_CANCEL_REGISTRATION_PROMPT:
+ switch (UnionRoomHandleYesNo(&uroom->textState, FALSE))
{
- case 0:
- data->state = 56;
+ case 0: // YES
+ uroom->state = UR_STATE_CANCEL_REGISTRATION;
break;
- case 1:
+ case 1: // NO
case -1:
- sub_801818C(TRUE);
- data->state = 4;
+ HandleCancelActivity(TRUE);
+ uroom->state = UR_STATE_MAIN;
break;
}
break;
- case 56:
- if (PrintOnTextbox(&data->textState, sText_RegistrationCanceled2))
+ case UR_STATE_CANCEL_REGISTRATION:
+ if (PrintOnTextbox(&uroom->textState, sText_RegistrationCanceled2))
{
- sub_8010FCC(0, 0, 0);
+ SetTradeBoardRegisteredMonInfo(TYPE_NORMAL, SPECIES_NONE, 0);
ResetUnionRoomTrade(&sUnionRoomTrade);
- sub_801818C(TRUE);
- data->state = 4;
+ HandleCancelActivity(TRUE);
+ uroom->state = UR_STATE_MAIN;
}
break;
- case 45:
- if (PrintOnTextbox(&data->textState, sText_XCheckedTradingBoard))
- data->state = 46;
+ case UR_STATE_CHECK_TRADING_BOARD:
+ if (PrintOnTextbox(&uroom->textState, sText_XCheckedTradingBoard))
+ uroom->state = UR_STATE_TRADING_BOARD_LOAD;
break;
- case 46:
- sub_80173B0();
- data->state = 48;
+ case UR_STATE_TRADING_BOARD_LOAD:
+ UR_ClearBg0();
+ uroom->state = UR_STATE_TRADING_BOARD_HANDLE_INPUT;
break;
- case 48:
- var5 = sub_80172A0(&data->textState, &data->field_1D, &data->field_4A, &data->field_1E, &gUnknown_082F034C, &gUnknown_082F03A4, data->field_0);
- if (var5 != -1)
+ case UR_STATE_TRADING_BOARD_HANDLE_INPUT:
+ input = TradeBoardMenuHandler(&uroom->textState, &uroom->tradeBoardSelectWindowId, &uroom->tradeBoardListMenuId, &uroom->tradeBoardDetailsWindowId, &gUnknown_082F034C, &sTradeBoardListMenuTemplate, uroom->field_0);
+ if (input != -1)
{
- switch (var5)
+ switch (input)
{
case -2:
- case 8:
- sub_801818C(TRUE);
- data->state = 4;
+ case 8: // EXIT
+ HandleCancelActivity(TRUE);
+ uroom->state = UR_STATE_MAIN;
break;
default:
- sub_80173B0();
- switch (sub_8017D04(data->field_0->arr[var5].unk.field_0.type, data->field_0->arr[var5].unk.field_0.species))
+ UR_ClearBg0();
+ switch (IsRequestedTypeOrEggInPlayerParty(uroom->field_0->arr[input].gname_uname.gname.type, uroom->field_0->arr[input].gname_uname.gname.species))
{
- case 0:
- sub_8018404(gStringVar1, &data->field_0->arr[var5]);
- sub_8015664(49, sText_AskTrainerToMakeTrade);
- taskData[1] = var5;
+ case UR_TRADE_MATCH:
+ IntlConvPartnerUname7(gStringVar1, &uroom->field_0->arr[input]);
+ ScheduleFieldMessageWithFollowupState(UR_STATE_TRADE_PROMPT, sText_AskTrainerToMakeTrade);
+ taskData[1] = input;
break;
- case 1:
- sub_8018404(gStringVar1, &data->field_0->arr[var5]);
- StringCopy(gStringVar2, gTypeNames[data->field_0->arr[var5].unk.field_0.type]);
- sub_8015664(46, sText_DontHaveTypeTrainerWants);
+ case UR_TRADE_NOTYPE:
+ IntlConvPartnerUname7(gStringVar1, &uroom->field_0->arr[input]);
+ StringCopy(gStringVar2, gTypeNames[uroom->field_0->arr[input].gname_uname.gname.type]);
+ ScheduleFieldMessageWithFollowupState(UR_STATE_TRADING_BOARD_LOAD, sText_DontHaveTypeTrainerWants);
break;
- case 2:
- sub_8018404(gStringVar1, &data->field_0->arr[var5]);
- StringCopy(gStringVar2, gTypeNames[data->field_0->arr[var5].unk.field_0.type]);
- sub_8015664(46, sText_DontHaveEggTrainerWants);
+ case UR_TRADE_NOEGG:
+ IntlConvPartnerUname7(gStringVar1, &uroom->field_0->arr[input]);
+ StringCopy(gStringVar2, gTypeNames[uroom->field_0->arr[input].gname_uname.gname.type]);
+ ScheduleFieldMessageWithFollowupState(UR_STATE_TRADING_BOARD_LOAD, sText_DontHaveEggTrainerWants);
break;
}
break;
}
}
break;
- case 49:
- switch (sub_80170B8(&data->textState, FALSE))
+ case UR_STATE_TRADE_PROMPT:
+ switch (UnionRoomHandleYesNo(&uroom->textState, FALSE))
{
- case 0:
- data->state = 50;
+ case 0: // YES
+ uroom->state = UR_STATE_TRADE_SELECT_MON;
break;
- case -1:
+ case -1: // NO
case 1:
- sub_801818C(TRUE);
- data->state = 4;
+ HandleCancelActivity(TRUE);
+ uroom->state = UR_STATE_MAIN;
break;
}
break;
- case 50:
- if (PrintOnTextbox(&data->textState, sText_WhichMonWillYouOffer))
+ case UR_STATE_TRADE_SELECT_MON:
+ if (PrintOnTextbox(&uroom->textState, sText_WhichMonWillYouOffer))
{
- sUnionRoomTrade.field_0 = 2;
- memcpy(&gUnknown_02022C38, &data->field_0->arr[taskData[1]].unk.field_0.unk_00, sizeof(gUnknown_02022C38));
- gUnionRoomRequestedMonType = data->field_0->arr[taskData[1]].unk.field_0.type;
- gUnionRoomOfferedSpecies = data->field_0->arr[taskData[1]].unk.field_0.species;
+ sUnionRoomTrade.state = URTRADE_STATE_OFFERING;
+ memcpy(&gPartnerTgtGnameSub, &uroom->field_0->arr[taskData[1]].gname_uname.gname.unk_00, sizeof(gPartnerTgtGnameSub));
+ gUnionRoomRequestedMonType = uroom->field_0->arr[taskData[1]].gname_uname.gname.type;
+ gUnionRoomOfferedSpecies = uroom->field_0->arr[taskData[1]].gname_uname.gname.species;
gFieldCallback = FieldCB_ContinueScriptUnionRoom;
ChooseMonForTradingBoard(PARTY_MENU_TYPE_UNION_ROOM_TRADE, CB2_ReturnToField);
- sub_80156B0(data);
- sUnionRoomTrade.field_8 = taskData[1];
+ sub_80156B0(uroom);
+ sUnionRoomTrade.offerPlayerId = taskData[1];
}
break;
- case 51:
- gUnknown_02022C2C = 0x44;
- sub_8012188(data->field_0->arr[taskData[1]].unk.playerName, &data->field_0->arr[taskData[1]].unk.field_0, 0x44);
- sub_8018404(gStringVar1, &data->field_0->arr[taskData[1]]);
- sub_8017020(sCommunicatingWaitTexts[2]);
- data->state = 25;
+ case UR_STATE_TRADE_OFFER_MON:
+ gPlayerCurrActivity = ACTIVITY_TRADE | IN_UNION_ROOM;
+ sub_8012188(uroom->field_0->arr[taskData[1]].gname_uname.playerName, &uroom->field_0->arr[taskData[1]].gname_uname.gname, gPlayerCurrActivity);
+ IntlConvPartnerUname7(gStringVar1, &uroom->field_0->arr[taskData[1]]);
+ UR_PrintFieldMessage(sCommunicatingWaitTexts[2]);
+ uroom->state = UR_STATE_TRY_COMMUNICATING;
break;
- case 26:
- if (PrintOnTextbox(&data->textState, gStringVar4))
+ case UR_STATE_PRINT_AND_EXIT:
+ if (PrintOnTextbox(&uroom->textState, gStringVar4))
{
- sub_801818C(TRUE);
- sub_801A3D0(taskData[0], taskData[1], data->field_0);
- data->state = 4;
+ HandleCancelActivity(TRUE);
+ UpdateUnionRoomMemberFacing(taskData[0], taskData[1], uroom->field_0);
+ uroom->state = UR_STATE_MAIN;
}
break;
- case 8:
- if (PrintOnTextbox(&data->textState, gStringVar4))
- data->state = data->stateAfterPrint;
+ case UR_STATE_PRINT_MSG:
+ if (PrintOnTextbox(&uroom->textState, gStringVar4))
+ uroom->state = uroom->stateAfterPrint;
break;
}
}
-void var_800D_set_xB(void)
+void SetUsingUnionRoomStartMenu(void)
{
if (InUnionRoom() == TRUE)
- gSpecialVar_Result = 11;
+ gSpecialVar_Result = UR_INTERACT_START_MENU;
}
-void sub_801689C(struct UnkStruct_URoom *arg0)
+static void ReceiveUnionRoomActivityPacket(struct WirelessLink_URoom *data)
{
if (gRecvCmds[1][1] != 0 && (gRecvCmds[1][0] & 0xFF00) == 0x2F00)
{
- arg0->field_9A[0] = gRecvCmds[1][1];
- if (gRecvCmds[1][1] == 0x44)
+ data->recvActivityRequest[0] = gRecvCmds[1][1];
+ if (gRecvCmds[1][1] == (ACTIVITY_TRADE | IN_UNION_ROOM))
{
- arg0->field_9A[1] = gRecvCmds[1][2];
- arg0->field_9A[2] = gRecvCmds[1][3];
+ data->recvActivityRequest[1] = gRecvCmds[1][2];
+ data->recvActivityRequest[2] = gRecvCmds[1][3];
}
}
}
-bool32 sub_80168DC(struct UnkStruct_URoom *arg0)
+static bool32 UnionRoom_HandleContactFromOtherPlayer(struct WirelessLink_URoom *uroom)
{
- if (arg0->field_9A[0] != 0)
+ if (uroom->recvActivityRequest[0] != 0)
{
- s32 var = sub_8017EA0(gStringVar4, gLinkPlayers[1].gender, &arg0->field_9A[0], arg0);
- if (var == 0)
+ s32 id = GetChatLeaderActionRequestMessage(gStringVar4, gLinkPlayers[1].gender, &uroom->recvActivityRequest[0], uroom);
+ if (id == 0) // Error
{
return TRUE;
}
- else if (var == 1)
+ else if (id == 1) // Recieve activity request
{
- arg0->state = 35;
- gUnknown_02022C2C = arg0->field_9A[0];
+ uroom->state = UR_STATE_RECV_ACTIVITY_REQUEST;
+ gPlayerCurrActivity = uroom->recvActivityRequest[0];
return FALSE;
}
- else if (var == 2)
+ else if (id == 2) // No activity
{
- arg0->state = 36;
+ uroom->state = UR_STATE_CANCEL_REQUEST_PRINT_MSG;
sub_800AC34();
return FALSE;
}
@@ -3062,53 +3241,53 @@ bool32 sub_80168DC(struct UnkStruct_URoom *arg0)
void InitUnionRoom(void)
{
- struct UnkStruct_URoom *ptr;
+ struct WirelessLink_URoom *data;
sUnionRoomPlayerName[0] = EOS;
- CreateTask(sub_801697C, 0);
- gUnknown_02022C30.uRoom = gUnknown_02022C30.uRoom; // Needed to match.
- gUnknown_02022C30.uRoom = ptr = AllocZeroed(sizeof(struct UnkStruct_URoom));
- gUnknown_03000DA8 = gUnknown_02022C30.uRoom;
- ptr->state = 0;
- ptr->textState = 0;
- ptr->field_10 = 0;
- ptr->field_12 = 0;
+ CreateTask(Task_InitUnionRoom, 0);
+ sWirelessLinkMain.uRoom = sWirelessLinkMain.uRoom; // Needed to match.
+ sWirelessLinkMain.uRoom = data = AllocZeroed(sizeof(struct WirelessLink_URoom));
+ sURoom = sWirelessLinkMain.uRoom;
+ data->state = 0;
+ data->textState = 0;
+ data->unknown = 0;
+ data->field_12 = 0;
sUnionRoomPlayerName[0] = EOS;
}
-void sub_801697C(u8 taskId)
+static void Task_InitUnionRoom(u8 taskId)
{
s32 i;
u8 text[32];
- struct UnkStruct_URoom *structPtr = gUnknown_02022C30.uRoom;
+ struct WirelessLink_URoom *data = sWirelessLinkMain.uRoom;
- switch (structPtr->state)
+ switch (data->state)
{
case 0:
- structPtr->state = 1;
+ data->state = 1;
break;
case 1:
- sub_8010F84(0xC, 0, 0);
- sub_800B488();
+ SetHostRFUtgtGname(ACTIVITY_SEARCH, 0, 0);
+ SetWirelessCommType1();
OpenLink();
- sub_8011C84();
- sub_80111B0(1);
- structPtr->state = 2;
+ InitializeRfuLinkManager_EnterUnionRoom();
+ sub_80111B0(TRUE);
+ data->state = 2;
break;
case 2:
- structPtr->field_4 = AllocZeroed(0x70);
- sub_80175EC(structPtr->field_4, 4);
- structPtr->field_C = AllocZeroed(0x70);
- sub_80175EC(structPtr->field_C, 4);
- structPtr->field_0 = AllocZeroed(0x100);
- sub_8017580(structPtr->field_0->arr, 8);
- structPtr->field_8 = AllocZeroed(0x20);
- sub_8017580(&structPtr->field_8->arr[0], 1);
- structPtr->field_20 = sub_8016DF0(structPtr->field_C, structPtr->field_4, 10);
- structPtr->state = 3;
+ data->field_4 = AllocZeroed(4 * sizeof(struct UnkStruct_x1C));
+ ClearUnkStruct_x1CArray(data->field_4, 4);
+ data->field_C = AllocZeroed(4 * sizeof(struct UnkStruct_x1C));
+ ClearUnkStruct_x1CArray(data->field_C, 4);
+ data->field_0 = AllocZeroed(8 * sizeof(struct UnkStruct_x20));
+ ClearUnkStruct_x20Array(data->field_0->arr, 8);
+ data->field_8 = AllocZeroed(sizeof(struct UnkStruct_x20));
+ ClearUnkStruct_x20Array(&data->field_8->arr[0], 1);
+ data->searchTaskId = CreateTask_SearchForChildOrParent(data->field_C, data->field_4, 10);
+ data->state = 3;
break;
case 3:
- switch (sub_8016B00())
+ switch (HandlePlayerListUpdate())
{
case 1:
case 2:
@@ -3116,10 +3295,10 @@ void sub_801697C(u8 taskId)
{
for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++)
{
- if (structPtr->field_0->arr[i].field_1A_0 == 1)
+ if (data->field_0->arr[i].groupScheduledAnim == UNION_ROOM_SPAWN_IN)
{
- sub_8018404(text, &structPtr->field_0->arr[i]);
- if (sub_800E540(ReadAsU16(structPtr->field_0->arr[i].unk.field_0.unk_00.playerTrainerId), text))
+ IntlConvPartnerUname7(text, &data->field_0->arr[i]);
+ if (PlayerHasMetTrainerBefore(ReadAsU16(data->field_0->arr[i].gname_uname.gname.unk_00.playerTrainerId), text))
{
StringCopy(sUnionRoomPlayerName, text);
break;
@@ -3133,13 +3312,13 @@ void sub_801697C(u8 taskId)
}
break;
case 4:
- free(structPtr->field_8);
- free(structPtr->field_0);
- free(structPtr->field_C);
- free(structPtr->field_4);
- DestroyTask(structPtr->field_20);
- free(gUnknown_02022C30.uRoom);
- sub_800EDD4();
+ free(data->field_8);
+ free(data->field_0);
+ free(data->field_C);
+ free(data->field_4);
+ DestroyTask(data->searchTaskId);
+ free(sWirelessLinkMain.uRoom);
+ LinkRfu_Shutdown();
DestroyTask(taskId);
break;
}
@@ -3159,176 +3338,168 @@ bool16 BufferUnionRoomPlayerName(void)
}
}
-u8 sub_8016B00(void)
+static u8 HandlePlayerListUpdate(void)
{
s32 i;
u8 j;
- struct UnkStruct_URoom *structPtr = gUnknown_02022C30.uRoom;
+ struct WirelessLink_URoom *data = sWirelessLinkMain.uRoom;
s32 r7 = 0;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- if (sub_8017630(&structPtr->field_C->arr[i].unk0, &gUnknown_082F045C) == TRUE)
+ if (AreGnameUnameDifferent(&data->field_C->arr[i].gname_uname, &sWirelessGnameUnamePair_Dummy) == TRUE)
{
- structPtr->field_8->arr[0].unk = structPtr->field_C->arr[i].unk0;
- structPtr->field_8->arr[0].field_18 = 0;
- structPtr->field_8->arr[0].field_1A_0 = 1;
- structPtr->field_8->arr[0].field_1B = 1;
+ data->field_8->arr[0].gname_uname = data->field_C->arr[i].gname_uname;
+ data->field_8->arr[0].timeoutCounter = 0;
+ data->field_8->arr[0].groupScheduledAnim = UNION_ROOM_SPAWN_IN;
+ data->field_8->arr[0].field_1B = 1;
return 4;
}
}
- for (j = 0; j < 8; j++)
+ for (j = 0; j < ARRAY_COUNT(data->field_0->arr); j++)
{
- if (structPtr->field_0->arr[j].field_1A_0 != 0)
+ if (data->field_0->arr[j].groupScheduledAnim != UNION_ROOM_SPAWN_NONE)
{
- i = sub_80176E4(&structPtr->field_0->arr[j], &structPtr->field_4->arr[0]);
+ i = Findx20Inx1CArray(&data->field_0->arr[j], &data->field_4->arr[0]);
if (i != 0xFF)
{
- if (structPtr->field_0->arr[j].field_1A_0 == 1)
+ if (data->field_0->arr[j].groupScheduledAnim == UNION_ROOM_SPAWN_IN)
{
- if (sub_8017678(&structPtr->field_0->arr[j].unk, &structPtr->field_4->arr[i].unk0))
+ if (AreUnionRoomPlayerGnamesDifferent(&data->field_0->arr[j].gname_uname, &data->field_4->arr[i].gname_uname))
{
- structPtr->field_0->arr[j].unk = structPtr->field_4->arr[i].unk0;
- structPtr->field_0->arr[j].field_1B = 0x40;
+ data->field_0->arr[j].gname_uname = data->field_4->arr[i].gname_uname;
+ data->field_0->arr[j].field_1B = 64;
r7 = 1;
}
- else if (structPtr->field_0->arr[j].field_1B != 0)
+ else if (data->field_0->arr[j].field_1B != 0)
{
- structPtr->field_0->arr[j].field_1B--;
- if (structPtr->field_0->arr[j].field_1B == 0)
+ data->field_0->arr[j].field_1B--;
+ if (data->field_0->arr[j].field_1B == 0)
r7 = 2;
}
}
else
{
- structPtr->field_0->arr[j].field_1A_0 = 1;
- structPtr->field_0->arr[j].field_1B = 0;
+ data->field_0->arr[j].groupScheduledAnim = UNION_ROOM_SPAWN_IN;
+ data->field_0->arr[j].field_1B = 0;
r7 = 2;
}
- structPtr->field_0->arr[j].field_18 = 0;
+ data->field_0->arr[j].timeoutCounter = 0;
}
- else if (structPtr->field_0->arr[j].field_1A_0 != 2)
+ else if (data->field_0->arr[j].groupScheduledAnim != UNION_ROOM_SPAWN_OUT)
{
- structPtr->field_0->arr[j].field_18++;
- if (structPtr->field_0->arr[j].field_18 >= 600)
+ data->field_0->arr[j].timeoutCounter++;
+ if (data->field_0->arr[j].timeoutCounter >= 600)
{
- structPtr->field_0->arr[j].field_1A_0 = 2;
+ data->field_0->arr[j].groupScheduledAnim = UNION_ROOM_SPAWN_OUT;
r7 = 2;
}
}
- else if (structPtr->field_0->arr[j].field_1A_0 == 2)
+ else if (data->field_0->arr[j].groupScheduledAnim == UNION_ROOM_SPAWN_OUT)
{
- structPtr->field_0->arr[j].field_18++;
- if (structPtr->field_0->arr[j].field_18 >= 900)
+ data->field_0->arr[j].timeoutCounter++;
+ if (data->field_0->arr[j].timeoutCounter >= 900)
{
- sub_8017580(&structPtr->field_0->arr[j], 1);
+ ClearUnkStruct_x20Array(&data->field_0->arr[j], 1);
}
}
}
}
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- if (sub_8017734(&structPtr->field_0->arr[0], &structPtr->field_4->arr[i], 8) != 0xFF)
+ if (Appendx1Ctox20(&data->field_0->arr[0], &data->field_4->arr[i], MAX_UNION_ROOM_PLAYERS) != 0xFF)
r7 = 1;
}
return r7;
}
-void sub_8016CA0(u8 taskId)
+static void Task_SearchForChildOrParent(u8 taskId)
{
s32 i, j;
- struct UnkStruct_Shared sp0;
+ struct WirelessGnameUnamePair gname_uname;
struct UnkStruct_Main4 **ptr = (void*) gTasks[taskId].data;
- bool8 r4;
+ bool8 isParent;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- r4 = sub_800DE7C(&sp0.field_0, sp0.playerName, i);
- if (!sub_8013D88(sp0.field_0.activity, gTasks[taskId].data[4]))
+ isParent = LinkRfu_GetNameIfCompatible(&gname_uname.gname, gname_uname.playerName, i);
+ if (!IsPartnerActivityAcceptable(gname_uname.gname.activity, gTasks[taskId].data[4]))
{
- sp0 = gUnknown_082F045C;
+ gname_uname = sWirelessGnameUnamePair_Dummy;
}
- if (sp0.field_0.unk_00.language == 1)
+ if (gname_uname.gname.unk_00.language == LANGUAGE_JAPANESE)
{
- sp0 = gUnknown_082F045C;
+ gname_uname = sWirelessGnameUnamePair_Dummy;
}
- if (!r4)
+ if (!isParent)
{
for (j = 0; j < i; j++)
{
- if (!sub_8017630(&ptr[1]->arr[j].unk0, &sp0))
+ if (!AreGnameUnameDifferent(&ptr[1]->arr[j].gname_uname, &gname_uname))
{
- sp0 = gUnknown_082F045C;
+ gname_uname = sWirelessGnameUnamePair_Dummy;
}
}
- ptr[1]->arr[i].unk0 = sp0;
- ptr[1]->arr[i].unk18 = sub_8017630(&ptr[1]->arr[i].unk0, &gUnknown_082F045C);
+ ptr[1]->arr[i].gname_uname = gname_uname;
+ ptr[1]->arr[i].active = AreGnameUnameDifferent(&ptr[1]->arr[i].gname_uname, &sWirelessGnameUnamePair_Dummy);
}
else
{
- ptr[0]->arr[i].unk0 = sp0;
- ptr[0]->arr[i].unk18 = sub_8017630(&ptr[0]->arr[i].unk0, &gUnknown_082F045C);
+ ptr[0]->arr[i].gname_uname = gname_uname;
+ ptr[0]->arr[i].active = AreGnameUnameDifferent(&ptr[0]->arr[i].gname_uname, &sWirelessGnameUnamePair_Dummy);
}
}
}
-u8 sub_8016DF0(struct UnkStruct_Main4 * a0, struct UnkStruct_Main4 * a1, u32 a2)
+static u8 CreateTask_SearchForChildOrParent(struct UnkStruct_Main4 * main4_parent, struct UnkStruct_Main4 * main4_child, u32 linkGroup)
{
- u8 taskId = CreateTask(sub_8016CA0, 0);
+ u8 taskId = CreateTask(Task_SearchForChildOrParent, 0);
struct UnkStruct_Main4 ** data = (void *)gTasks[taskId].data;
- data[0] = a0;
- data[1] = a1;
- gTasks[taskId].data[4] = a2;
+ data[0] = main4_parent;
+ data[1] = main4_child;
+ gTasks[taskId].data[4] = linkGroup;
return taskId;
}
-void sub_8016E24(u8 taskId)
+static void Task_ListenForPartnersWithCompatibleSerialNos(u8 taskId)
{
s32 i, j;
struct UnkStruct_Main4 **ptr = (void*) gTasks[taskId].data;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- sub_800DE7C(&ptr[0]->arr[i].unk0.field_0, ptr[0]->arr[i].unk0.playerName, i);
- if (!sub_8013D88(ptr[0]->arr[i].unk0.field_0.activity, gTasks[taskId].data[2]))
+ LinkRfu_GetNameIfCompatible(&ptr[0]->arr[i].gname_uname.gname, ptr[0]->arr[i].gname_uname.playerName, i);
+ if (!IsPartnerActivityAcceptable(ptr[0]->arr[i].gname_uname.gname.activity, gTasks[taskId].data[2]))
{
- ptr[0]->arr[i].unk0 = gUnknown_082F045C;
+ ptr[0]->arr[i].gname_uname = sWirelessGnameUnamePair_Dummy;
}
for (j = 0; j < i; j++)
{
- if (!sub_8017630(&ptr[0]->arr[j].unk0, &ptr[0]->arr[i].unk0))
+ if (!AreGnameUnameDifferent(&ptr[0]->arr[j].gname_uname, &ptr[0]->arr[i].gname_uname))
{
- ptr[0]->arr[i].unk0 = gUnknown_082F045C;
+ ptr[0]->arr[i].gname_uname = sWirelessGnameUnamePair_Dummy;
}
}
- ptr[0]->arr[i].unk18 = sub_8017630(&ptr[0]->arr[i].unk0, &gUnknown_082F045C);
+ ptr[0]->arr[i].active = AreGnameUnameDifferent(&ptr[0]->arr[i].gname_uname, &sWirelessGnameUnamePair_Dummy);
}
}
-bool32 sub_8016F1C(struct GFtgtGname *arg0, s16 arg1)
+static bool32 HasWonderCardOrNewsByLinkGroup(struct GFtgtGname *gname, s16 linkGroup)
{
- if (arg1 == 7)
+ if (linkGroup == LINK_GROUP_WONDER_CARD)
{
- if (!arg0->unk_00.hasCard)
- {
+ if (!gname->unk_00.hasCard)
return FALSE;
- }
else
- {
return TRUE;
- }
}
- else if (arg1 == 8)
+ else if (linkGroup == LINK_GROUP_WONDER_NEWS)
{
- if (!arg0->unk_00.hasNews)
- {
+ if (!gname->unk_00.hasNews)
return FALSE;
- }
else
- {
return TRUE;
- }
}
else
{
@@ -3336,40 +3507,40 @@ bool32 sub_8016F1C(struct GFtgtGname *arg0, s16 arg1)
}
}
-void sub_8016F44(u8 taskId)
+static void Task_ListenForPartnersWithSerial7F7D(u8 taskId)
{
s32 i;
struct UnkStruct_Main4 **ptr = (void*) gTasks[taskId].data;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- if (sub_800DF34(&ptr[0]->arr[i].unk0.field_0, ptr[0]->arr[i].unk0.playerName, i))
+ if (LinkRfu_GetNameIfSerial7F7D(&ptr[0]->arr[i].gname_uname.gname, ptr[0]->arr[i].gname_uname.playerName, i))
{
- sub_8016F1C(&ptr[0]->arr[i].unk0.field_0, gTasks[taskId].data[2]);
+ HasWonderCardOrNewsByLinkGroup(&ptr[0]->arr[i].gname_uname.gname, gTasks[taskId].data[2]);
}
- ptr[0]->arr[i].unk18 = sub_8017630(&ptr[0]->arr[i].unk0, &gUnknown_082F045C);
+ ptr[0]->arr[i].active = AreGnameUnameDifferent(&ptr[0]->arr[i].gname_uname, &sWirelessGnameUnamePair_Dummy);
}
}
-u8 sub_8016FC0(struct UnkStruct_Main4 * a0, u32 a1)
+static u8 CreateTask_ListenForPartnersWithCompatibleSerialNos(struct UnkStruct_Main4 * main4, u32 linkGroup)
{
- u8 taskId = CreateTask(sub_8016E24, 0);
+ u8 taskId = CreateTask(Task_ListenForPartnersWithCompatibleSerialNos, 0);
struct UnkStruct_Main4 **ptr = (void*) gTasks[taskId].data;
- ptr[0] = a0;
- gTasks[taskId].data[2] = a1;
+ ptr[0] = main4;
+ gTasks[taskId].data[2] = linkGroup;
return taskId;
}
-u8 sub_8016FF0(struct UnkStruct_Main4 * a0, u32 a1)
+static u8 CreateTask_ListenForPartnersWithSerial7F7D(struct UnkStruct_Main4 * main4, u32 linkGroup)
{
- u8 taskId = CreateTask(sub_8016F44, 0);
+ u8 taskId = CreateTask(Task_ListenForPartnersWithSerial7F7D, 0);
struct UnkStruct_Main4 **ptr = (void*) gTasks[taskId].data;
- ptr[0] = a0;
- gTasks[taskId].data[2] = a1;
+ ptr[0] = main4;
+ gTasks[taskId].data[2] = linkGroup;
return taskId;
}
-bool32 sub_8017020(const u8 *src)
+static bool32 UR_PrintFieldMessage(const u8 *src)
{
LoadMessageBoxAndBorderGfx();
DrawDialogueFrame(0, 1);
@@ -3378,19 +3549,15 @@ bool32 sub_8017020(const u8 *src)
return FALSE;
}
-bool32 sub_801704C(void)
+static bool32 UR_RunTextPrinters_CheckPrinter0Active(void)
{
if (!RunTextPrintersAndIsPrinter0Active())
- {
return TRUE;
- }
else
- {
return FALSE;
- }
}
-bool8 PrintOnTextbox(u8 *textState, const u8 *str)
+static bool8 PrintOnTextbox(u8 *textState, const u8 *str)
{
switch (*textState)
{
@@ -3412,96 +3579,96 @@ bool8 PrintOnTextbox(u8 *textState, const u8 *str)
return FALSE;
}
-s8 sub_80170B8(u8 *arg0, bool32 arg1)
+static s8 UnionRoomHandleYesNo(u8 *state, bool32 noDraw)
{
- s8 r1;
+ s8 input;
- switch (*arg0)
+ switch (*state)
{
case 0:
- if (arg1)
+ if (noDraw)
{
return -3;
}
DisplayYesNoMenuDefaultYes();
- (*arg0)++;
+ (*state)++;
break;
case 1:
- if (arg1)
+ if (noDraw)
{
sub_8198C78();
- *arg0 = 0;
+ *state = 0;
return -3;
}
- r1 = Menu_ProcessInputNoWrapClearOnChoose();
- if (r1 == -1 || r1 == 0 || r1 == 1)
+ input = Menu_ProcessInputNoWrapClearOnChoose();
+ if (input == -1 || input == 0 || input == 1)
{
- *arg0 = 0;
- return r1;
+ *state = 0;
+ return input;
}
break;
}
return -2;
}
-u8 sub_8017118(const struct WindowTemplate * template)
+static u8 CreateTradeBoardWindow(const struct WindowTemplate * template)
{
u8 windowId = AddWindow(template);
DrawStdWindowFrame(windowId, FALSE);
- FillWindowPixelBuffer(windowId, 0xFF);
- sub_80173E0(windowId, 1, sText_NameWantedOfferLv, 8, 1, 6);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(15));
+ UR_AddTextPrinterParameterized(windowId, 1, sText_NameWantedOfferLv, 8, 1, 6);
CopyWindowToVram(windowId, 2);
PutWindowTilemap(windowId);
return windowId;
}
-void sub_8017168(u8 windowId)
+static void DeleteTradeBoardWindow(u8 windowId)
{
RemoveWindow(windowId);
}
-s32 sub_8017178(u8 *arg0, u8 *arg1, u8 *arg2, const struct WindowTemplate *winTemplate, const struct ListMenuTemplate *menuTemplate)
+static s32 ListMenuHandler_AllItemsAvailable(u8 *state, u8 *windowId, u8 *listMenuId, const struct WindowTemplate *winTemplate, const struct ListMenuTemplate *menuTemplate)
{
- s32 r1, r8;
+ s32 maxWidth, input;
struct WindowTemplate winTemplateCopy;
- switch (*arg0)
+ switch (*state)
{
case 0:
winTemplateCopy = *winTemplate;
- r1 = Intl_GetListMenuWidth(menuTemplate);
- if (winTemplateCopy.width > r1)
+ maxWidth = Intl_GetListMenuWidth(menuTemplate);
+ if (winTemplateCopy.width > maxWidth)
{
- winTemplateCopy.width = r1;
+ winTemplateCopy.width = maxWidth;
}
if (winTemplateCopy.tilemapLeft + winTemplateCopy.width > 29)
{
winTemplateCopy.tilemapLeft = max(29 - winTemplateCopy.width, 0);
}
- *arg1 = AddWindow(&winTemplateCopy);
- DrawStdWindowFrame(*arg1, FALSE);
+ *windowId = AddWindow(&winTemplateCopy);
+ DrawStdWindowFrame(*windowId, FALSE);
gMultiuseListMenuTemplate = *menuTemplate;
- gMultiuseListMenuTemplate.windowId = *arg1;
- *arg2 = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0);
- CopyWindowToVram(*arg1, TRUE);
- (*arg0)++;
+ gMultiuseListMenuTemplate.windowId = *windowId;
+ *listMenuId = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0);
+ CopyWindowToVram(*windowId, TRUE);
+ (*state)++;
break;
case 1:
- r8 = ListMenu_ProcessInput(*arg2);
- if (({gMain.newKeys & A_BUTTON;}))
+ input = ListMenu_ProcessInput(*listMenuId);
+ if (JOY_NEW(A_BUTTON))
{
- DestroyListMenuTask(*arg2, NULL, NULL);
- ClearStdWindowAndFrame(*arg1, TRUE);
- RemoveWindow(*arg1);
- *arg0 = 0;
- return r8;
+ DestroyListMenuTask(*listMenuId, NULL, NULL);
+ ClearStdWindowAndFrame(*windowId, TRUE);
+ RemoveWindow(*windowId);
+ *state = 0;
+ return input;
}
- else if (({gMain.newKeys & B_BUTTON;}))
+ else if (JOY_NEW(B_BUTTON))
{
- DestroyListMenuTask(*arg2, NULL, NULL);
- ClearStdWindowAndFrame(*arg1, TRUE);
- RemoveWindow(*arg1);
- *arg0 = 0;
+ DestroyListMenuTask(*listMenuId, NULL, NULL);
+ ClearStdWindowAndFrame(*windowId, TRUE);
+ RemoveWindow(*windowId);
+ *state = 0;
return -2;
}
break;
@@ -3510,49 +3677,48 @@ s32 sub_8017178(u8 *arg0, u8 *arg1, u8 *arg2, const struct WindowTemplate *winTe
return -1;
}
-s32 sub_80172A0(u8 *arg0, u8 *arg1, u8 *arg2, u8 *arg3, const struct WindowTemplate *winTemplate, const struct ListMenuTemplate *menuTemplate, struct UnkStruct_Main0 *arg6)
+static s32 TradeBoardMenuHandler(u8 *state, u8 *windowId, u8 *listMenuId, u8 *tradeBoardWindowId, const struct WindowTemplate *winTemplate, const struct ListMenuTemplate *menuTemplate, struct UnkStruct_Main0 *traders)
{
s32 input;
- s32 r4;
+ s32 idx;
- switch (*arg0)
+ switch (*state)
{
case 0:
- *arg3 = sub_8017118(&gUnknown_082F0344);
- *arg1 = AddWindow(winTemplate);
- DrawStdWindowFrame(*arg1, FALSE);
+ *tradeBoardWindowId = CreateTradeBoardWindow(&sWindowTemplate_TradingBoard);
+ *windowId = AddWindow(winTemplate);
+ DrawStdWindowFrame(*windowId, FALSE);
gMultiuseListMenuTemplate = *menuTemplate;
- gMultiuseListMenuTemplate.windowId = *arg1;
- *arg2 = ListMenuInit(&gMultiuseListMenuTemplate, 0, 1);
- (*arg0)++;
+ gMultiuseListMenuTemplate.windowId = *windowId;
+ *listMenuId = ListMenuInit(&gMultiuseListMenuTemplate, 0, 1);
+ (*state)++;
break;
case 1:
- CopyWindowToVram(*arg1, TRUE);
- (*arg0)++;
+ CopyWindowToVram(*windowId, TRUE);
+ (*state)++;
break;
case 2:
- // Register swap r1 <---> r2
- input = ListMenu_ProcessInput(*arg2);
- if (({gMain.newKeys & (A_BUTTON | B_BUTTON);}))
+ input = ListMenu_ProcessInput(*listMenuId);
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
{
- if (input == 8 || ({gMain.newKeys & B_BUTTON;}))
+ if (input == 8 || JOY_NEW(B_BUTTON))
{
- DestroyListMenuTask(*arg2, NULL, NULL);
- RemoveWindow(*arg1);
- sub_8017168(*arg3);
- *arg0 = 0;
+ DestroyListMenuTask(*listMenuId, NULL, NULL);
+ RemoveWindow(*windowId);
+ DeleteTradeBoardWindow(*tradeBoardWindowId);
+ *state = 0;
return -2;
}
else
{
- r4 = sub_8017CB0(arg6->arr, input);
- if (r4 >= 0)
+ idx = GetIndexOfNthTradeBoardOffer(traders->arr, input);
+ if (idx >= 0)
{
- DestroyListMenuTask(*arg2, NULL, NULL);
- RemoveWindow(*arg1);
- sub_8017168(*arg3);
- *arg0 = 0;
- return r4;
+ DestroyListMenuTask(*listMenuId, NULL, NULL);
+ RemoveWindow(*windowId);
+ DeleteTradeBoardWindow(*tradeBoardWindowId);
+ *state = 0;
+ return idx;
}
else
{
@@ -3565,127 +3731,128 @@ s32 sub_80172A0(u8 *arg0, u8 *arg1, u8 *arg2, u8 *arg3, const struct WindowTempl
return -1;
}
-void sub_80173B0(void)
+
+static void UR_ClearBg0(void)
{
FillBgTilemapBufferRect(0, 0, 0, 0, 32, 32, 0);
CopyBgTilemapBufferToVram(0);
}
-void sub_80173D4(void)
+static void JoinGroup_EnableScriptContexts(void)
{
EnableBothScriptContexts();
}
-void sub_80173E0(u8 windowId, u8 arg1, const u8 *str, u8 arg3, u8 arg4, u8 arg5)
+static void UR_AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 colorIdx)
{
- struct TextPrinterTemplate sp0;
+ struct TextPrinterTemplate printerTemplate;
- sp0.currentChar = str;
- sp0.windowId = windowId;
- sp0.fontId = arg1;
- sp0.x = arg3;
- sp0.y = arg4;
- sp0.currentX = arg3;
- sp0.currentY = arg4;
- sp0.unk = 0;
+ printerTemplate.currentChar = str;
+ printerTemplate.windowId = windowId;
+ printerTemplate.fontId = fontId;
+ printerTemplate.x = x;
+ printerTemplate.y = y;
+ printerTemplate.currentX = x;
+ printerTemplate.currentY = y;
+ printerTemplate.unk = 0;
gTextFlags.useAlternateDownArrow = FALSE;
- switch (arg5)
+ switch (colorIdx)
{
- case 0:
- sp0.letterSpacing = 0;
- sp0.lineSpacing = 0;
- sp0.fgColor = 2;
- sp0.bgColor = 1;
- sp0.shadowColor = 3;
- break;
- case 1:
- sp0.letterSpacing = 0;
- sp0.lineSpacing = 0;
- sp0.fgColor = 4;
- sp0.bgColor = 1;
- sp0.shadowColor = 5;
- break;
- case 2:
- sp0.letterSpacing = 0;
- sp0.lineSpacing = 0;
- sp0.fgColor = 6;
- sp0.bgColor = 1;
- sp0.shadowColor = 7;
- break;
- case 3:
- sp0.letterSpacing = 0;
- sp0.lineSpacing = 0;
- sp0.fgColor = 1;
- sp0.bgColor = 1;
- sp0.shadowColor = 3;
- break;
- case 4:
- sp0.letterSpacing = 0;
- sp0.lineSpacing = 0;
- sp0.fgColor = 1;
- sp0.bgColor = 2;
- sp0.shadowColor = 3;
- break;
- case 5:
- sp0.letterSpacing = 0;
- sp0.lineSpacing = 0;
- sp0.fgColor = 7;
- sp0.bgColor = 15;
- sp0.shadowColor = 9;
- break;
- case 6:
- sp0.letterSpacing = 0;
- sp0.lineSpacing = 0;
- sp0.fgColor = 14;
- sp0.bgColor = 15;
- sp0.shadowColor = 9;
+ case UR_COLOR_DKE_WHT_LTE:
+ printerTemplate.letterSpacing = 0;
+ printerTemplate.lineSpacing = 0;
+ printerTemplate.fgColor = TEXT_COLOR_DARK_GREY;
+ printerTemplate.bgColor = TEXT_COLOR_WHITE;
+ printerTemplate.shadowColor = TEXT_COLOR_LIGHT_GREY;
+ break;
+ case UR_COLOR_RED_WHT_LTR:
+ printerTemplate.letterSpacing = 0;
+ printerTemplate.lineSpacing = 0;
+ printerTemplate.fgColor = TEXT_COLOR_RED;
+ printerTemplate.bgColor = TEXT_COLOR_WHITE;
+ printerTemplate.shadowColor = TEXT_COLOR_LIGHT_RED;
+ break;
+ case UR_COLOR_GRN_WHT_LTG:
+ printerTemplate.letterSpacing = 0;
+ printerTemplate.lineSpacing = 0;
+ printerTemplate.fgColor = TEXT_COLOR_GREEN;
+ printerTemplate.bgColor = TEXT_COLOR_WHITE;
+ printerTemplate.shadowColor = TEXT_COLOR_LIGHT_GREEN;
+ break;
+ case UR_COLOR_WHT_WHT_LTE:
+ printerTemplate.letterSpacing = 0;
+ printerTemplate.lineSpacing = 0;
+ printerTemplate.fgColor = TEXT_COLOR_WHITE;
+ printerTemplate.bgColor = TEXT_COLOR_WHITE;
+ printerTemplate.shadowColor = TEXT_COLOR_LIGHT_GREY;
+ break;
+ case UR_COLOR_WHT_DKE_LTE:
+ printerTemplate.letterSpacing = 0;
+ printerTemplate.lineSpacing = 0;
+ printerTemplate.fgColor = TEXT_COLOR_WHITE;
+ printerTemplate.bgColor = TEXT_COLOR_DARK_GREY;
+ printerTemplate.shadowColor = TEXT_COLOR_LIGHT_GREY;
+ break;
+ case UR_COLOR_GRN_DN6_LTB:
+ printerTemplate.letterSpacing = 0;
+ printerTemplate.lineSpacing = 0;
+ printerTemplate.fgColor = TEXT_COLOR_LIGHT_GREEN;
+ printerTemplate.bgColor = TEXT_DYNAMIC_COLOR_6;
+ printerTemplate.shadowColor = TEXT_COLOR_LIGHT_BLUE;
+ break;
+ case UR_COLOR_DN5_DN6_LTB:
+ printerTemplate.letterSpacing = 0;
+ printerTemplate.lineSpacing = 0;
+ printerTemplate.fgColor = TEXT_DYNAMIC_COLOR_5;
+ printerTemplate.bgColor = TEXT_DYNAMIC_COLOR_6;
+ printerTemplate.shadowColor = TEXT_COLOR_LIGHT_BLUE;
break;
}
- AddTextPrinter(&sp0, 0xFF, NULL);
+ AddTextPrinter(&printerTemplate, 0xFF, NULL);
}
-void sub_8017580(struct UnkStruct_x20 *arg0, u8 count)
+static void ClearUnkStruct_x20Array(struct UnkStruct_x20 *arr, u8 count)
{
s32 i;
for (i = 0; i < count; i++)
{
- arg0[i].unk = gUnknown_082F045C;
- arg0[i].field_18 = 0xFF;
- arg0[i].field_1A_0 = 0;
- arg0[i].field_1A_1 = 0;
- arg0[i].field_1B = 0;
+ arr[i].gname_uname = sWirelessGnameUnamePair_Dummy;
+ arr[i].timeoutCounter = 255;
+ arr[i].groupScheduledAnim = UNION_ROOM_SPAWN_NONE;
+ arr[i].useRedText = FALSE;
+ arr[i].field_1B = 0;
}
}
-void sub_80175EC(struct UnkStruct_Main4 *arg0, u8 count)
+static void ClearUnkStruct_x1CArray(struct UnkStruct_Main4 *main4, u8 count)
{
s32 i;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- arg0->arr[i].unk0 = gUnknown_082F045C;
- arg0->arr[i].unk18 = 0;
+ main4->arr[i].gname_uname = sWirelessGnameUnamePair_Dummy;
+ main4->arr[i].active = FALSE;
}
}
-bool8 sub_8017630(struct UnkStruct_Shared* arg0, const struct UnkStruct_Shared* arg1)
+static bool8 AreGnameUnameDifferent(struct WirelessGnameUnamePair* pair1, const struct WirelessGnameUnamePair* pair2)
{
s32 i;
for (i = 0; i < 2; i++)
{
- if (arg0->field_0.unk_00.playerTrainerId[i] != arg1->field_0.unk_00.playerTrainerId[i])
+ if (pair1->gname.unk_00.playerTrainerId[i] != pair2->gname.unk_00.playerTrainerId[i])
{
return TRUE;
}
}
- for (i = 0; i < 8; i++)
+ for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++)
{
- if (arg0->playerName[i] != arg1->playerName[i])
+ if (pair1->playerName[i] != pair2->playerName[i])
{
return TRUE;
}
@@ -3694,34 +3861,34 @@ bool8 sub_8017630(struct UnkStruct_Shared* arg0, const struct UnkStruct_Shared*
return FALSE;
}
-bool32 sub_8017678(struct UnkStruct_Shared *arg0, struct UnkStruct_Shared *arg1)
+static bool32 AreUnionRoomPlayerGnamesDifferent(struct WirelessGnameUnamePair *pair1, struct WirelessGnameUnamePair *pair2)
{
s32 i;
- if (arg0->field_0.activity != arg1->field_0.activity)
+ if (pair1->gname.activity != pair2->gname.activity)
{
return TRUE;
}
- if (arg0->field_0.started != arg1->field_0.started)
+ if (pair1->gname.started != pair2->gname.started)
{
return TRUE;
}
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- if (arg0->field_0.child_sprite_gender[i] != arg1->field_0.child_sprite_gender[i])
+ if (pair1->gname.child_sprite_gender[i] != pair2->gname.child_sprite_gender[i])
{
return TRUE;
}
}
- if (arg0->field_0.species != arg1->field_0.species)
+ if (pair1->gname.species != pair2->gname.species)
{
return TRUE;
}
- if (arg0->field_0.type != arg1->field_0.type)
+ if (pair1->gname.type != pair2->gname.type)
{
return TRUE;
}
@@ -3729,38 +3896,38 @@ bool32 sub_8017678(struct UnkStruct_Shared *arg0, struct UnkStruct_Shared *arg1)
return FALSE;
}
-u32 sub_80176E4(struct UnkStruct_x20 *arg0, struct UnkStruct_x1C *arg1)
+static u32 Findx20Inx1CArray(struct UnkStruct_x20 *arg0, struct UnkStruct_x1C *arg1)
{
u8 result = 0xFF;
s32 i;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- if (arg1[i].unk18 && !sub_8017630(&arg0->unk, &arg1[i].unk0))
+ if (arg1[i].active && !AreGnameUnameDifferent(&arg0->gname_uname, &arg1[i].gname_uname))
{
result = i;
- arg1[i].unk18 = FALSE;
+ arg1[i].active = FALSE;
}
}
return result;
}
-u8 sub_8017734(struct UnkStruct_x20 *arg0, struct UnkStruct_x1C *arg1, u8 arg2)
+static u8 Appendx1Ctox20(struct UnkStruct_x20 *arg0, struct UnkStruct_x1C *arg1, u8 max)
{
s32 i;
- if (arg1->unk18)
+ if (arg1->active)
{
- for (i = 0; i < arg2; i++)
+ for (i = 0; i < max; i++)
{
- if (arg0[i].field_1A_0 == 0)
+ if (arg0[i].groupScheduledAnim == UNION_ROOM_SPAWN_NONE)
{
- arg0[i].unk = arg1->unk0;
- arg0[i].field_18 = 0;
- arg0[i].field_1A_0 = 1;
+ arg0[i].gname_uname = arg1->gname_uname;
+ arg0[i].timeoutCounter = 0;
+ arg0[i].groupScheduledAnim = UNION_ROOM_SPAWN_IN;
arg0[i].field_1B = 64;
- arg1->unk18 = FALSE;
+ arg1->active = FALSE;
return i;
}
}
@@ -3769,126 +3936,123 @@ u8 sub_8017734(struct UnkStruct_x20 *arg0, struct UnkStruct_x1C *arg1, u8 arg2)
return 0xFF;
}
-void sub_80177B8(u8 arg0, u8 arg1, u8 arg2, struct UnkStruct_x20 *arg3, u8 arg4, u8 id)
+static void PrintUnionRoomGroupOnWindow(u8 windowId, u8 x, u8 y, struct UnkStruct_x20 *group, u8 colorIdx, u8 id)
{
- u8 r2;
- u8 sp0[6];
+ u8 activity;
+ u8 trainerId[6];
ConvertIntToDecimalStringN(gStringVar4, id + 1, STR_CONV_MODE_LEADING_ZEROS, 2);
StringAppend(gStringVar4, sText_Colon);
- sub_80173E0(arg0, 1, gStringVar4, arg1, arg2, 0);
- arg1 += 18;
- r2 = arg3->unk.field_0.activity;
- if (arg3->field_1A_0 == 1 && !(r2 & 0x40))
+ UR_AddTextPrinterParameterized(windowId, 1, gStringVar4, x, y, 0);
+ x += 18;
+ activity = group->gname_uname.gname.activity;
+ if (group->groupScheduledAnim == UNION_ROOM_SPAWN_IN && !(activity & IN_UNION_ROOM))
{
- sub_8018404(gStringVar4, arg3);
- sub_80173E0(arg0, 1, gStringVar4, arg1, arg2, arg4);
- ConvertIntToDecimalStringN(sp0, arg3->unk.field_0.unk_00.playerTrainerId[0] | (arg3->unk.field_0.unk_00.playerTrainerId[1] << 8), STR_CONV_MODE_LEADING_ZEROS, 5);
+ IntlConvPartnerUname7(gStringVar4, group);
+ UR_AddTextPrinterParameterized(windowId, 1, gStringVar4, x, y, colorIdx);
+ ConvertIntToDecimalStringN(trainerId, group->gname_uname.gname.unk_00.playerTrainerId[0] | (group->gname_uname.gname.unk_00.playerTrainerId[1] << 8), STR_CONV_MODE_LEADING_ZEROS, 5);
StringCopy(gStringVar4, sText_ID);
- StringAppend(gStringVar4, sp0);
- sub_80173E0(arg0, 1, gStringVar4, GetStringRightAlignXOffset(1, gStringVar4, 0x88), arg2, arg4);
+ StringAppend(gStringVar4, trainerId);
+ UR_AddTextPrinterParameterized(windowId, 1, gStringVar4, GetStringRightAlignXOffset(1, gStringVar4, 0x88), y, colorIdx);
}
}
-void sub_80178A0(u8 arg0, u8 arg1, u8 arg2, struct UnkStruct_x20 *arg3, u8 arg4, u8 id)
+static void PrintGroupMemberCandidateOnWindowWithColor(u8 windowId, u8 x, u8 y, struct UnkStruct_x20 *group, u8 colorIdx, u8 id)
{
- u8 sp0[6];
+ u8 trainerId[6];
- if (arg3->field_1A_0 == 1)
+ if (group->groupScheduledAnim == UNION_ROOM_SPAWN_IN)
{
- sub_8018404(gStringVar4, arg3);
- sub_80173E0(arg0, 1, gStringVar4, arg1, arg2, arg4);
- ConvertIntToDecimalStringN(sp0, arg3->unk.field_0.unk_00.playerTrainerId[0] | (arg3->unk.field_0.unk_00.playerTrainerId[1] << 8), STR_CONV_MODE_LEADING_ZEROS, 5);
+ IntlConvPartnerUname7(gStringVar4, group);
+ UR_AddTextPrinterParameterized(windowId, 1, gStringVar4, x, y, colorIdx);
+ ConvertIntToDecimalStringN(trainerId, group->gname_uname.gname.unk_00.playerTrainerId[0] | (group->gname_uname.gname.unk_00.playerTrainerId[1] << 8), STR_CONV_MODE_LEADING_ZEROS, 5);
StringCopy(gStringVar4, sText_ID);
- StringAppend(gStringVar4, sp0);
- sub_80173E0(arg0, 1, gStringVar4, GetStringRightAlignXOffset(1, gStringVar4, 0x68), arg2, arg4);
+ StringAppend(gStringVar4, trainerId);
+ UR_AddTextPrinterParameterized(windowId, 1, gStringVar4, GetStringRightAlignXOffset(1, gStringVar4, 0x68), y, colorIdx);
}
}
-bool32 sub_8017940(void)
+static bool32 IsPlayerFacingTradingBoard(void)
{
s16 x, y;
GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
- if (x != 9)
- {
+
+ if (x != 2 + 7)
return FALSE;
- }
- if (y != 8)
- {
+
+ if (y != 1 + 7)
return FALSE;
- }
- if (gPlayerAvatar.tileTransitionState == 2 || gPlayerAvatar.tileTransitionState == 0)
- {
+
+ if (gPlayerAvatar.tileTransitionState == T_TILE_CENTER || gPlayerAvatar.tileTransitionState == T_NOT_MOVING)
return TRUE;
- }
return FALSE;
}
-u32 sub_8017984(s32 arg0)
+static u32 GetResponseIdx_InviteToURoomActivity(s32 activity)
{
- switch (arg0)
+ switch (activity)
{
- case 5:
+ case ACTIVITY_CHAT:
return 1;
- case 4:
+ case ACTIVITY_TRADE:
return 2;
- case 8:
+ case ACTIVITY_CARD:
return 3;
- case 3:
+ case ACTIVITY_BATTLE_MULTI:
default:
return 0;
}
}
-u32 sub_80179AC(struct UnkStruct_x20 *arg0)
+static u32 ConvPartnerUnameAndGetWhetherMetAlready(struct UnkStruct_x20 *arg0)
{
- u8 sp0[30];
- sub_8018404(sp0, arg0);
- return sub_800E540(ReadAsU16(arg0->unk.field_0.unk_00.playerTrainerId), sp0);
+ u8 name[30];
+ IntlConvPartnerUname7(name, arg0);
+ return PlayerHasMetTrainerBefore(ReadAsU16(arg0->gname_uname.gname.unk_00.playerTrainerId), name);
}
-s32 sub_80179D4(struct UnkStruct_Main0 *arg0, u8 arg1, u8 arg2, u32 playerGender)
+static s32 UnionRoomGetPlayerInteractionResponse(struct UnkStruct_Main0 *main0, bool8 overrideGender, u8 playerIdx, u32 playerGender)
{
- bool32 r2;
+ bool32 metBefore;
- struct UnkStruct_x20 * r5 = &arg0->arr[arg2];
+ struct UnkStruct_x20 * r5 = &main0->arr[playerIdx];
- if (!r5->unk.field_0.started && arg1 == 0)
+ if (!r5->gname_uname.gname.started && !overrideGender)
{
- sub_8018404(gStringVar1, r5);
- r2 = sub_800E540(ReadAsU16(r5->unk.field_0.unk_00.playerTrainerId), gStringVar1);
- if (r5->unk.field_0.activity == 0x45)
+ IntlConvPartnerUname7(gStringVar1, r5);
+ metBefore = PlayerHasMetTrainerBefore(ReadAsU16(r5->gname_uname.gname.unk_00.playerTrainerId), gStringVar1);
+ if (r5->gname_uname.gname.activity == (ACTIVITY_CHAT | IN_UNION_ROOM))
{
- StringExpandPlaceholders(gStringVar4, sJoinChatTexts[r2][playerGender]);
+ StringExpandPlaceholders(gStringVar4, sJoinChatTexts[metBefore][playerGender]);
return 2;
}
else
{
- sub_8017020(sCommunicatingWaitTexts[r2]);
+ UR_PrintFieldMessage(sCommunicatingWaitTexts[metBefore]);
return 1;
}
}
else
{
- sub_8018404(gStringVar1, r5);
- if (arg1 != 0)
+ IntlConvPartnerUname7(gStringVar1, r5);
+ if (overrideGender)
{
- playerGender = (r5->unk.field_0.unk_00.playerTrainerId[arg1 + 1] >> 3) & 1;
+ playerGender = (r5->gname_uname.gname.unk_00.playerTrainerId[overrideGender + 1] >> 3) & 1;
}
- switch (r5->unk.field_0.activity & 0x3F)
+ switch (r5->gname_uname.gname.activity & 0x3F)
{
- case 1:
- StringExpandPlaceholders(gStringVar4, sBattleReactionTexts[playerGender][Random() % 4]);
+ case ACTIVITY_BATTLE_SINGLE:
+ StringExpandPlaceholders(gStringVar4, sBattleReactionTexts[playerGender][Random() % ARRAY_COUNT(sBattleReactionTexts[0])]);
break;
- case 4:
+ case ACTIVITY_TRADE:
StringExpandPlaceholders(gStringVar4, sTradeReactionTexts[playerGender][Random() % 2]);
break;
- case 5:
- StringExpandPlaceholders(gStringVar4, sChatReactionTexts[playerGender][Random() % 4]);
+ case ACTIVITY_CHAT:
+ StringExpandPlaceholders(gStringVar4, sChatReactionTexts[playerGender][Random() % ARRAY_COUNT(sChatReactionTexts[0])]);
break;
- case 8:
- StringExpandPlaceholders(gStringVar4, sTrainerCardReactionTexts[playerGender][Random() % 2]);
+ case ACTIVITY_CARD:
+ StringExpandPlaceholders(gStringVar4, sTrainerCardReactionTexts[playerGender][Random() % ARRAY_COUNT(sTrainerCardReactionTexts[0])]);
break;
default:
StringExpandPlaceholders(gStringVar4, sText_TrainerAppearsBusy);
@@ -3903,73 +4067,73 @@ void nullsub_14(u8 windowId, s32 itemId, u8 y)
}
-void sub_8017B3C(u8 arg0, u8 arg1, struct GFtgtGname * arg2, const u8 * str, u8 arg4)
+static void TradeBoardPrintItemInfo(u8 windowId, u8 y, struct GFtgtGname * gname, const u8 * uname, u8 colorIdx)
{
- u8 sp8[4];
- u16 r8 = arg2->species;
- u8 r7 = arg2->type;
- u8 r9 = arg2->level;
+ u8 levelStr[4];
+ u16 species = gname->species;
+ u8 type = gname->type;
+ u8 level = gname->level;
- sub_80173E0(arg0, 1, str, 8, arg1, arg4);
- if (r8 == SPECIES_EGG)
+ UR_AddTextPrinterParameterized(windowId, 1, uname, 8, y, colorIdx);
+ if (species == SPECIES_EGG)
{
- sub_80173E0(arg0, 1, sText_EggTrade, 0x44, arg1, arg4);
+ UR_AddTextPrinterParameterized(windowId, 1, sText_EggTrade, 0x44, y, colorIdx);
}
else
{
- blit_move_info_icon(arg0, r7 + 1, 0x44, arg1);
- sub_80173E0(arg0, 1, gSpeciesNames[r8], 0x76, arg1, arg4);
- ConvertIntToDecimalStringN(sp8, r9, STR_CONV_MODE_RIGHT_ALIGN, 3);
- sub_80173E0(arg0, 1, sp8, 0xC6, arg1, arg4);
+ blit_move_info_icon(windowId, type + 1, 0x44, y);
+ UR_AddTextPrinterParameterized(windowId, 1, gSpeciesNames[species], 0x76, y, colorIdx);
+ ConvertIntToDecimalStringN(levelStr, level, STR_CONV_MODE_RIGHT_ALIGN, 3);
+ UR_AddTextPrinterParameterized(windowId, 1, levelStr, 0xC6, y, colorIdx);
}
}
-void sub_8017BE8(u8 windowId, s32 itemId, u8 y)
+static void TradeBoardListMenuItemPrintFunc(u8 windowId, s32 itemId, u8 y)
{
- struct UnkStruct_Leader *leader = gUnknown_02022C30.leader;
+ struct WirelessLink_Leader *data = sWirelessLinkMain.leader;
struct GFtgtGname *rfu;
s32 i, j;
- u8 sp4[11];
+ u8 playerName[11];
- if (itemId == -3 && y == gUnknown_082F03A4.upText_Y)
+ if (itemId == -3 && y == sTradeBoardListMenuTemplate.upText_Y)
{
- rfu = sub_800F7DC();
+ rfu = GetHostRFUtgtGname();
if (rfu->species != SPECIES_NONE)
{
- sub_8017B3C(windowId, y, rfu, gSaveBlock2Ptr->playerName, 5);
+ TradeBoardPrintItemInfo(windowId, y, rfu, gSaveBlock2Ptr->playerName, 5);
}
}
else
{
j = 0;
- for (i = 0; i < 8; i++)
+ for (i = 0; i < (int)ARRAY_COUNT(data->field_0->arr); i++)
{
- if (leader->field_0->arr[i].field_1A_0 == 1 && leader->field_0->arr[i].unk.field_0.species != SPECIES_NONE)
+ if (data->field_0->arr[i].groupScheduledAnim == UNION_ROOM_SPAWN_IN && data->field_0->arr[i].gname_uname.gname.species != SPECIES_NONE)
{
j++;
}
if (j == itemId + 1)
{
- sub_8018404(sp4, &leader->field_0->arr[i]);
- sub_8017B3C(windowId, y, &leader->field_0->arr[i].unk.field_0, sp4, 6);
+ IntlConvPartnerUname7(playerName, &data->field_0->arr[i]);
+ TradeBoardPrintItemInfo(windowId, y, &data->field_0->arr[i].gname_uname.gname, playerName, 6);
break;
}
}
}
}
-s32 sub_8017CB0(struct UnkStruct_x20 * arg, s32 arg1)
+static s32 GetIndexOfNthTradeBoardOffer(struct UnkStruct_x20 * arg, s32 n)
{
s32 i;
s32 j = 0;
for (i = 0; i < 8; i++)
{
- if (arg[i].field_1A_0 == 1 && arg[i].unk.field_0.species != SPECIES_NONE)
+ if (arg[i].groupScheduledAnim == UNION_ROOM_SPAWN_IN && arg[i].gname_uname.gname.species != SPECIES_NONE)
{
j++;
}
- if (j == arg1 + 1)
+ if (j == n + 1)
{
return i;
}
@@ -3978,12 +4142,12 @@ s32 sub_8017CB0(struct UnkStruct_x20 * arg, s32 arg1)
return -1;
}
-s32 sub_8017CF8(s32 arg1, struct UnkStruct_Main0 *arg0)
+static s32 GetUnionRoomPlayerGender(s32 playerIdx, struct UnkStruct_Main0 *main0)
{
- return arg0->arr[arg1].unk.field_0.playerGender;
+ return main0->arr[playerIdx].gname_uname.gname.playerGender;
}
-s32 sub_8017D04(u32 type, u32 species)
+static s32 IsRequestedTypeOrEggInPlayerParty(u32 type, u32 species)
{
s32 i;
@@ -3994,10 +4158,10 @@ s32 sub_8017D04(u32 type, u32 species)
species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2);
if (species == SPECIES_EGG)
{
- return 0;
+ return UR_TRADE_MATCH;
}
}
- return 2;
+ return UR_TRADE_NOEGG;
}
else
{
@@ -4006,77 +4170,77 @@ s32 sub_8017D04(u32 type, u32 species)
species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2);
if (gBaseStats[species].type1 == type || gBaseStats[species].type2 == type)
{
- return 0;
+ return UR_TRADE_MATCH;
}
}
- return 1;
+ return UR_TRADE_NOTYPE;
}
}
-void sub_8017D9C(u8 *dst, s32 arg1, u32 playerGender)
+static void GetURoomActivityRejectMsg(u8 *dst, s32 acitivty, u32 playerGender)
{
- switch (arg1)
+ switch (acitivty)
{
- case 0x41:
+ case ACTIVITY_BATTLE_SINGLE | IN_UNION_ROOM:
StringExpandPlaceholders(dst, sBattleDeclinedTexts[playerGender]);
break;
- case 0x45:
+ case ACTIVITY_CHAT | IN_UNION_ROOM:
StringExpandPlaceholders(dst, sChatDeclinedTexts[playerGender]);
break;
- case 0x44:
+ case ACTIVITY_TRADE | IN_UNION_ROOM:
StringExpandPlaceholders(dst, sText_TradeOfferRejected);
break;
- case 0x48:
+ case ACTIVITY_CARD | IN_UNION_ROOM:
StringExpandPlaceholders(dst, sShowTrainerCardDeclinedTexts[playerGender]);
break;
}
}
-void sub_8017E00(u8 *dst, u8 arg1)
+static void GetURoomActivityStartMsg(u8 *dst, u8 acitivty)
{
u8 mpId = GetMultiplayerId();
u8 gender = gLinkPlayers[mpId ^ 1].gender;
- switch (arg1)
+ switch (acitivty)
{
- case 0x41:
+ case ACTIVITY_BATTLE_SINGLE | IN_UNION_ROOM:
StringCopy(dst, sStartActivityTexts[mpId][gender][0]);
break;
- case 0x44:
+ case ACTIVITY_TRADE | IN_UNION_ROOM:
StringCopy(dst, sStartActivityTexts[mpId][gender][2]);
break;
- case 0x45:
+ case ACTIVITY_CHAT | IN_UNION_ROOM:
StringCopy(dst, sStartActivityTexts[mpId][gender][1]);
break;
}
}
-s32 sub_8017EA0(u8 *dst, u32 gender, u16 *arg2, struct UnkStruct_URoom *arg3)
+static s32 GetChatLeaderActionRequestMessage(u8 *dst, u32 gender, u16 *activityData, struct WirelessLink_URoom *uroom)
{
s32 result = 0;
u16 species = SPECIES_NONE;
s32 i;
- switch (arg2[0])
+ switch (activityData[0])
{
- case 0x41:
+ case ACTIVITY_BATTLE_SINGLE | IN_UNION_ROOM:
StringExpandPlaceholders(dst, sText_BattleChallenge);
result = 1;
break;
- case 0x45:
+ case ACTIVITY_CHAT | IN_UNION_ROOM:
StringExpandPlaceholders(dst, sText_ChatInvitation);
result = 1;
break;
- case 0x44:
- ConvertIntToDecimalStringN(arg3->field_58 + 0x00, sUnionRoomTrade.playerLevel, STR_CONV_MODE_LEFT_ALIGN, 3);
- StringCopy(arg3->field_58 + 0x10, gSpeciesNames[sUnionRoomTrade.playerSpecies]);
- for (i = 0; i < 4; i++)
+ case ACTIVITY_TRADE | IN_UNION_ROOM:
+ ConvertIntToDecimalStringN(uroom->activityRequestStrbufs[0], sUnionRoomTrade.playerLevel, STR_CONV_MODE_LEFT_ALIGN, 3);
+ StringCopy(uroom->activityRequestStrbufs[1], gSpeciesNames[sUnionRoomTrade.playerSpecies]);
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
if (gRfuLinkStatus->partner[i].serialNo == 2)
{
- ConvertIntToDecimalStringN(arg3->field_58 + 0x20, arg2[2], STR_CONV_MODE_LEFT_ALIGN, 3);
- StringCopy(arg3->field_58 + 0x30, gSpeciesNames[arg2[1]]);
- species = arg2[1];
+ ConvertIntToDecimalStringN(uroom->activityRequestStrbufs[2], activityData[2], STR_CONV_MODE_LEFT_ALIGN, 3);
+ StringCopy(uroom->activityRequestStrbufs[3], gSpeciesNames[activityData[1]]);
+ species = activityData[1];
break;
}
}
@@ -4086,19 +4250,19 @@ s32 sub_8017EA0(u8 *dst, u32 gender, u16 *arg2, struct UnkStruct_URoom *arg3)
}
else
{
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(i, arg3->field_58 + 0x10 * i);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(i, uroom->activityRequestStrbufs[i]);
}
DynamicPlaceholderTextUtil_ExpandPlaceholders(dst, sText_OfferToTradeMon);
}
result = 1;
break;
- case 0x48:
+ case ACTIVITY_CARD | IN_UNION_ROOM:
StringExpandPlaceholders(dst, sText_ShowTrainerCard);
result = 1;
break;
- case 0x40:
+ case ACTIVITY_NONE | IN_UNION_ROOM:
StringExpandPlaceholders(dst, sText_ChatDropped);
result = 2;
break;
@@ -4107,18 +4271,18 @@ s32 sub_8017EA0(u8 *dst, u32 gender, u16 *arg2, struct UnkStruct_URoom *arg3)
return result;
}
-bool32 sub_8017FD8(struct UnkStruct_URoom *arg0)
+static bool32 PollPartnerYesNoResponse(struct WirelessLink_URoom *data)
{
if (gRecvCmds[0][1] != 0)
{
- if (gRecvCmds[0][1] == 0x51)
+ if (gRecvCmds[0][1] == (ACTIVITY_ACCEPT | IN_UNION_ROOM))
{
- arg0->field_98 = 0x51;
+ data->partnerYesNoResponse = ACTIVITY_ACCEPT | IN_UNION_ROOM;
return TRUE;
}
- else if (gRecvCmds[0][1] == 0x52)
+ else if (gRecvCmds[0][1] == (ACTIVITY_DECLINE | IN_UNION_ROOM))
{
- arg0->field_98 = 0x52;
+ data->partnerYesNoResponse = ACTIVITY_DECLINE | IN_UNION_ROOM;
return TRUE;
}
}
@@ -4132,7 +4296,7 @@ bool32 InUnionRoom(void)
? TRUE : FALSE;
}
-bool32 HasAtLeastTwoMonsOfLevel30OrLower(void)
+static bool32 HasAtLeastTwoMonsOfLevel30OrLower(void)
{
s32 i;
s32 count = 0;
@@ -4152,16 +4316,16 @@ bool32 HasAtLeastTwoMonsOfLevel30OrLower(void)
return FALSE;
}
-static void ResetUnionRoomTrade(struct UnionRoomTrade *arg0)
+static void ResetUnionRoomTrade(struct UnionRoomTrade *uroomTrade)
{
- arg0->field_0 = 0;
- arg0->type = 0;
- arg0->playerPersonality = 0;
- arg0->playerSpecies = 0;
- arg0->playerLevel = 0;
- arg0->species = 0;
- arg0->level = 0;
- arg0->personality = 0;
+ uroomTrade->state = URTRADE_STATE_NONE;
+ uroomTrade->type = 0;
+ uroomTrade->playerPersonality = 0;
+ uroomTrade->playerSpecies = 0;
+ uroomTrade->playerLevel = 0;
+ uroomTrade->species = 0;
+ uroomTrade->level = 0;
+ uroomTrade->personality = 0;
}
void Script_ResetUnionRoomTrade(void)
@@ -4228,36 +4392,36 @@ static u32 GetPartyPositionOfRegisteredMon(struct UnionRoomTrade *trade, u8 mult
return response;
}
-void sub_801818C(bool32 arg0)
+static void HandleCancelActivity(bool32 setData)
{
- sub_80173B0();
+ UR_ClearBg0();
ScriptContext2_Disable();
- sub_8098524();
- gUnknown_02022C2C = 0;
- if (arg0)
+ UnionRoom_UnlockPlayerAndChatPartner();
+ gPlayerCurrActivity = ACTIVITY_NONE;
+ if (setData)
{
- sub_8010FCC(sUnionRoomTrade.type, sUnionRoomTrade.playerSpecies, sUnionRoomTrade.playerLevel);
- sub_8011090(0x40, 0, 0);
+ SetTradeBoardRegisteredMonInfo(sUnionRoomTrade.type, sUnionRoomTrade.playerSpecies, sUnionRoomTrade.playerLevel);
+ UpdateGameData_SetActivity(ACTIVITY_NONE | IN_UNION_ROOM, 0, FALSE);
}
}
-void sub_80181CC(void)
+static void UR_EnableScriptContext2AndFreezeObjectEvents(void)
{
ScriptContext2_Enable();
ScriptFreezeObjectEvents();
}
-u8 sub_80181DC(struct UnkStruct_URoom *arg0)
+static u8 GetActivePartnerSpriteGenderParam(struct WirelessLink_URoom *data)
{
u8 retVal = 0x80;
u8 i;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < RFU_CHILD_MAX; i++)
{
- if (arg0->field_C->arr[i].unk18)
+ if (data->field_C->arr[i].active)
{
- retVal |= arg0->field_C->arr[i].unk0.field_0.playerGender << 3;
- retVal |= arg0->field_C->arr[i].unk0.field_0.unk_00.playerTrainerId[0] & 7;
+ retVal |= data->field_C->arr[i].gname_uname.gname.playerGender << 3;
+ retVal |= data->field_C->arr[i].gname_uname.gname.unk_00.playerTrainerId[0] & 7;
break;
}
}
@@ -4265,7 +4429,7 @@ u8 sub_80181DC(struct UnkStruct_URoom *arg0)
return retVal;
}
-void sub_8018220(u8 *unused, struct UnkStruct_URoom *arg1, bool8 arg2)
+static void ViewURoomPartnerTrainerCard(u8 *unused, struct WirelessLink_URoom *data, bool8 isParent)
{
struct TrainerCard *trainerCard = &gTrainerCards[GetMultiplayerId() ^ 1];
s32 i;
@@ -4273,67 +4437,67 @@ void sub_8018220(u8 *unused, struct UnkStruct_URoom *arg1, bool8 arg2)
DynamicPlaceholderTextUtil_Reset();
- StringCopy(arg1->field_C0[0], gTrainerClassNames[sub_8068BB0()]);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, arg1->field_C0[0]);
+ StringCopy(data->trainerCardStrBuffer[0], gTrainerClassNames[GetUnionRoomTrainerClass()]);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, data->trainerCardStrBuffer[0]);
DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, trainerCard->playerName);
- StringCopy(arg1->field_174, sCardColorTexts[trainerCard->stars]);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, arg1->field_174);
+ StringCopy(data->trainerCardColorStrBuffer, sCardColorTexts[trainerCard->stars]);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, data->trainerCardColorStrBuffer);
- ConvertIntToDecimalStringN(arg1->field_C0[2], trainerCard->caughtMonsCount, STR_CONV_MODE_LEFT_ALIGN, 3);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(3, arg1->field_C0[2]);
+ ConvertIntToDecimalStringN(data->trainerCardStrBuffer[2], trainerCard->caughtMonsCount, STR_CONV_MODE_LEFT_ALIGN, 3);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(3, data->trainerCardStrBuffer[2]);
- ConvertIntToDecimalStringN(arg1->field_C0[3], trainerCard->playTimeHours, STR_CONV_MODE_LEFT_ALIGN, 3);
- ConvertIntToDecimalStringN(arg1->field_C0[4], trainerCard->playTimeMinutes, STR_CONV_MODE_LEADING_ZEROS, 2);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(4, arg1->field_C0[3]);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(5, arg1->field_C0[4]);
+ ConvertIntToDecimalStringN(data->trainerCardStrBuffer[3], trainerCard->playTimeHours, STR_CONV_MODE_LEFT_ALIGN, 3);
+ ConvertIntToDecimalStringN(data->trainerCardStrBuffer[4], trainerCard->playTimeMinutes, STR_CONV_MODE_LEADING_ZEROS, 2);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(4, data->trainerCardStrBuffer[3]);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(5, data->trainerCardStrBuffer[4]);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(arg1->field_1A4, sText_TrainerCardInfoPage1);
- StringCopy(gStringVar4, arg1->field_1A4);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(data->trainerCardMsgStrBuffer, sText_TrainerCardInfoPage1);
+ StringCopy(gStringVar4, data->trainerCardMsgStrBuffer);
n = trainerCard->linkBattleWins;
if (n > 9999)
{
n = 9999;
}
- ConvertIntToDecimalStringN(arg1->field_C0[0], n, STR_CONV_MODE_LEFT_ALIGN, 4);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, arg1->field_C0[0]);
+ ConvertIntToDecimalStringN(data->trainerCardStrBuffer[0], n, STR_CONV_MODE_LEFT_ALIGN, 4);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, data->trainerCardStrBuffer[0]);
n = trainerCard->linkBattleLosses;
if (n > 9999)
{
n = 9999;
}
- ConvertIntToDecimalStringN(arg1->field_C0[1], n, STR_CONV_MODE_LEFT_ALIGN, 4);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, arg1->field_C0[1]);
+ ConvertIntToDecimalStringN(data->trainerCardStrBuffer[1], n, STR_CONV_MODE_LEFT_ALIGN, 4);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(2, data->trainerCardStrBuffer[1]);
- ConvertIntToDecimalStringN(arg1->field_C0[2], trainerCard->pokemonTrades, STR_CONV_MODE_LEFT_ALIGN, 5);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(3, arg1->field_C0[2]);
+ ConvertIntToDecimalStringN(data->trainerCardStrBuffer[2], trainerCard->pokemonTrades, STR_CONV_MODE_LEFT_ALIGN, 5);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(3, data->trainerCardStrBuffer[2]);
for (i = 0; i < TRAINER_CARD_PROFILE_LENGTH; i++)
{
- CopyEasyChatWord(arg1->field_C0[i + 3], trainerCard->easyChatProfile[i]);
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(i + 4, arg1->field_C0[i + 3]);
+ CopyEasyChatWord(data->trainerCardStrBuffer[i + 3], trainerCard->easyChatProfile[i]);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(i + 4, data->trainerCardStrBuffer[i + 3]);
}
- DynamicPlaceholderTextUtil_ExpandPlaceholders(arg1->field_1A4, sText_TrainerCardInfoPage2);
- StringAppend(gStringVar4, arg1->field_1A4);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(data->trainerCardMsgStrBuffer, sText_TrainerCardInfoPage2);
+ StringAppend(gStringVar4, data->trainerCardMsgStrBuffer);
- if (arg2 == TRUE)
+ if (isParent == TRUE)
{
- DynamicPlaceholderTextUtil_ExpandPlaceholders(arg1->field_1A4, sText_FinishedCheckingPlayersTrainerCard);
- StringAppend(gStringVar4, arg1->field_1A4);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(data->trainerCardMsgStrBuffer, sText_FinishedCheckingPlayersTrainerCard);
+ StringAppend(gStringVar4, data->trainerCardMsgStrBuffer);
}
- else if (arg2 == FALSE)
+ else if (isParent == FALSE)
{
- DynamicPlaceholderTextUtil_ExpandPlaceholders(arg1->field_1A4, sGladToMeetYouTexts[trainerCard->gender]);
- StringAppend(gStringVar4, arg1->field_1A4);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(data->trainerCardMsgStrBuffer, sGladToMeetYouTexts[trainerCard->gender]);
+ StringAppend(gStringVar4, data->trainerCardMsgStrBuffer);
}
}
-void sub_8018404(u8 *dest, struct UnkStruct_x20 *arg1)
+static void IntlConvPartnerUname7(u8 *dest, struct UnkStruct_x20 *arg1)
{
- StringCopy7(dest, arg1->unk.playerName);
- ConvertInternationalString(dest, arg1->unk.field_0.unk_00.language);
+ StringCopy7(dest, arg1->gname_uname.playerName);
+ ConvertInternationalString(dest, arg1->gname_uname.gname.unk_00.language);
}
diff --git a/src/union_room_battle.c b/src/union_room_battle.c
index d2c3a5cd0..4b2aa0bb1 100644
--- a/src/union_room_battle.c
+++ b/src/union_room_battle.c
@@ -11,134 +11,24 @@
#include "window.h"
#include "text_window.h"
#include "scanline_effect.h"
-#include "m4a.h"
-#include "dynamic_placeholder_text_util.h"
#include "overworld.h"
#include "strings.h"
-#include "string_util.h"
-#include "international_string_util.h"
-#include "sound.h"
-#include "constants/songs.h"
#include "party_menu.h"
#include "battle_setup.h"
#include "link.h"
#include "union_room.h"
#include "union_room_battle.h"
+#include "constants/rgb.h"
+#include "constants/trainers.h"
-struct UnkStruct_3000DAC
+struct UnionRoomBattle
{
- /*0x00*/ u32 unk00[4];
- /*0x10*/ u32 unk10[4];
- /*0x20*/ u32 unk20[16];
- /*0x60*/ u8 taskId;
- /*0x61*/ u8 unk61;
- /*0x62*/ u8 filler_62[10];
+ s16 textState;
};
-struct UnkStruct_2022C6C
-{
- s16 a0;
-};
-
-static struct UnkStruct_3000DAC * gUnknown_03000DAC;
-
-EWRAM_DATA struct UnkStruct_2022C6C * gUnknown_02022C6C = NULL;
-
-void sub_801A43C(void);
-void sub_801A6C0(u8 taskId);
-static void sub_801A8B0(u8 windowId, u8 fontId, const u8 * str, u8 x, u8 y, u8 mode);
-bool32 sub_801AA30(u32 * a0, u32 * a1, u32 * a2, u8 taskId);
-
-const u16 gWirelessInfoScreenPal[] = INCBIN_U16("graphics/interface/wireless_info_screen.gbapal");
-const u32 gWirelessInfoScreenGfx[] = INCBIN_U32("graphics/interface/wireless_info_screen.4bpp.lz");
-const u32 gWirelessInfoScreenTilemap[] = INCBIN_U32("graphics/interface/wireless_info_screen.bin.lz");
-
-const struct BgTemplate gUnknown_082F0D34[] = {
- {
- .bg = 0,
- .charBaseIndex = 2,
- .mapBaseIndex = 0x1F,
- .priority = 0
- }, {
- .bg = 1,
- .charBaseIndex = 0,
- .mapBaseIndex = 0x08,
- .priority = 1
- }
-};
-
-const struct WindowTemplate gUnknown_082F0D3C[] = {
- {
- .bg = 0x00,
- .tilemapLeft = 0x03,
- .tilemapTop = 0x00,
- .width = 0x18,
- .height = 0x03,
- .paletteNum = 0x0f,
- .baseBlock = 0x0001
- }, {
- .bg = 0x00,
- .tilemapLeft = 0x03,
- .tilemapTop = 0x04,
- .width = 0x15,
- .height = 0x0f,
- .paletteNum = 0x0f,
- .baseBlock = 0x0049
- }, {
- .bg = 0x00,
- .tilemapLeft = 0x18,
- .tilemapTop = 0x04,
- .width = 0x03,
- .height = 0x0f,
- .paletteNum = 0x0f,
- .baseBlock = 0x0184
- },
- { 0xFF }
-};
+static EWRAM_DATA struct UnionRoomBattle * sBattle = NULL;
-const u8 *const gUnknown_082F0D5C[] = {
- gText_WirelessCommStatus,
- gText_PeopleTrading,
- gText_PeopleBattling,
- gText_PeopleInUnionRoom,
- gText_PeopleCommunicating
-};
-
-const u8 gUnknown_082F0D70[][3] = {
- {0x01, 0x01, 0x02},
- {0x02, 0x01, 0x02},
- {0x03, 0x01, 0x04},
- {0x04, 0x00, 0x02},
- {0x06, 0x03, 0x02},
- {0x07, 0x03, 0x02},
- {0x09, 0x03, 0x00},
- {0x0a, 0x03, 0x00},
- {0x0b, 0x03, 0x00},
- {0x0c, 0xff, 0x00},
- {0x0d, 0x00, 0x00},
- {0x10, 0x03, 0x00},
- {0x0f, 0x03, 0x00},
- {0x40, 0x02, 0x01},
- {0x41, 0x02, 0x02},
- {0x44, 0x02, 0x02},
- {0x45, 0x02, 0x00},
- {0x48, 0x02, 0x02},
- {0x54, 0x02, 0x01},
- {0x53, 0x02, 0x02},
- {0x51, 0x02, 0x01},
- {0x52, 0x02, 0x01},
- {0x15, 0x03, 0x02},
- {0x16, 0x03, 0x02},
- {0x17, 0x03, 0x00},
- {0x18, 0x03, 0x00},
- {0x19, 0x03, 0x00},
- {0x1a, 0x03, 0x00},
- {0x1b, 0x03, 0x00},
- {0x1c, 0x01, 0x02},
- {0x0e, 0x01, 0x02}
-};
-
-const struct BgTemplate gUnknown_082F0DD0[] = {
+static const struct BgTemplate sBgTemplates[] = {
{
.bg = 0,
.charBaseIndex = 3,
@@ -146,7 +36,7 @@ const struct BgTemplate gUnknown_082F0DD0[] = {
}
};
-const struct WindowTemplate gUnknown_082F0DD4[] = {
+static const struct WindowTemplate sWindowTemplates[] = {
{
.bg = 0,
.tilemapLeft = 3,
@@ -156,301 +46,15 @@ const struct WindowTemplate gUnknown_082F0DD4[] = {
.paletteNum = 0xE,
.baseBlock = 0x014
},
- { 0xFF }
+ DUMMY_WIN_TEMPLATE
};
-const u8 gUnknown_082F0DE4[] = { 1, 2, 3 };
-
-void sub_801A3F4(void)
-{
- if (!IsDma3ManagerBusyWithBgCopy())
- {
- RunTasks();
- RunTextPrinters();
- AnimateSprites();
- BuildOamBuffer();
- UpdatePaletteFade();
- }
-}
-
-void sub_801A418(void)
-{
- LoadOam();
- ProcessSpriteCopyRequests();
- TransferPlttBuffer();
-}
-
-void sub_801A42C(void)
-{
- SetMainCallback2(sub_801A43C);
-}
-
-void sub_801A43C(void)
-{
- SetGpuReg(REG_OFFSET_DISPCNT, 0x0000);
- gUnknown_03000DAC = AllocZeroed(sizeof(struct UnkStruct_3000DAC));
- SetVBlankCallback(NULL);
- ResetBgsAndClearDma3BusyFlags(0);
- InitBgsFromTemplates(0, gUnknown_082F0D34, ARRAY_COUNT(gUnknown_082F0D34));
- SetBgTilemapBuffer(1, Alloc(0x800));
- SetBgTilemapBuffer(0, Alloc(0x800));
- DecompressAndLoadBgGfxUsingHeap(1, gWirelessInfoScreenGfx, 0, 0, 0);
- CopyToBgTilemapBuffer(1, gWirelessInfoScreenTilemap, 0, 0);
- InitWindows(gUnknown_082F0D3C);
- DeactivateAllTextPrinters();
- ResetPaletteFade();
- ResetSpriteData();
- ResetTasks();
- ScanlineEffect_Stop();
- m4aSoundVSyncOn();
- SetVBlankCallback(sub_801A418);
- gUnknown_03000DAC->taskId = CreateTask(sub_801A6C0, 0);
- gUnknown_03000DAC->unk61 = sub_8013C40();
- gUnknown_03000DAC->unk10[3] = 1;
- ChangeBgX(0, 0, 0);
- ChangeBgY(0, 0, 0);
- ChangeBgX(1, 0, 0);
- ChangeBgY(1, 0, 0);
- LoadPalette(gWirelessInfoScreenPal, 0x00, 0x20);
- Menu_LoadStdPalAt(0xF0);
- DynamicPlaceholderTextUtil_Reset();
- FillBgTilemapBufferRect(0, 0, 0, 0, 32, 32, 0x0F);
- CopyBgTilemapBufferToVram(1);
- SetMainCallback2(sub_801A3F4);
- RunTasks();
- RunTextPrinters();
- AnimateSprites();
- BuildOamBuffer();
- UpdatePaletteFade();
-}
-
-void sub_801A584(void)
-{
- s32 i;
- FreeAllWindowBuffers();
- for (i = 0; i < 2; i++)
- {
- Free(GetBgTilemapBuffer(i));
- }
- Free(gUnknown_03000DAC);
- SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
-}
-
-void sub_801A5BC(s16 * a0, s16 * a1)
-{
- if (++(*a0) > 5)
- {
- if (++(*a1) == 14)
- {
- *a1 = 0;
- }
- *a0 = 0;
- }
- LoadPalette(gWirelessInfoScreenPal + 16 * (*a1 + 2), 0, 0x10);
-}
+static const u8 sTextColors[] = { TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY, TEXT_COLOR_LIGHT_GREY };
-void sub_801A600(void)
+static void CB2_SetUpPartiesAndStartBattle(void)
{
s32 i;
- FillWindowPixelBuffer(0, 0);
- FillWindowPixelBuffer(1, 0);
- FillWindowPixelBuffer(2, 0);
- sub_801A8B0(0, 1, gUnknown_082F0D5C[0], GetStringCenterAlignXOffset(1, gUnknown_082F0D5C[0], 0xC0), 6, 3);
- for (i = 0; i < 3; i++)
- {
- sub_801A8B0(1, 1, gUnknown_082F0D5C[i + 1], 0, 30 * i + 8, 1);
- }
- sub_801A8B0(1, 1, gUnknown_082F0D5C[i + 1], 0, 30 * i + 8, 2);
- PutWindowTilemap(0);
- CopyWindowToVram(0, 2);
- PutWindowTilemap(1);
- CopyWindowToVram(1, 2);
-}
-
-void sub_801A6C0(u8 taskId)
-{
- s32 i;
- switch (gTasks[taskId].data[0])
- {
- case 0:
- sub_801A600();
- gTasks[taskId].data[0]++;
- break;
- case 1:
- BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0);
- ShowBg(1);
- CopyBgTilemapBufferToVram(0);
- ShowBg(0);
- gTasks[taskId].data[0]++;
- break;
- case 2:
- if (!gPaletteFade.active)
- {
- gTasks[taskId].data[0]++;
- }
- break;
- case 3:
- if (sub_801AA30(gUnknown_03000DAC->unk00, gUnknown_03000DAC->unk10, gUnknown_03000DAC->unk20, gUnknown_03000DAC->unk61))
- {
- FillWindowPixelBuffer(2, 0);
- for (i = 0; i < 4; i++)
- {
- ConvertIntToDecimalStringN(gStringVar4, gUnknown_03000DAC->unk00[i], STR_CONV_MODE_RIGHT_ALIGN, 2);
- if (i != 3)
- {
- sub_801A8B0(2, 1, gStringVar4, 12, 30 * i + 8, 1);
- }
- else
- {
- sub_801A8B0(2, 1, gStringVar4, 12, 98, 2);
- }
- }
- PutWindowTilemap(2);
- CopyWindowToVram(2, 3);
- }
- if (({gMain.newKeys & A_BUTTON;}) || ({gMain.newKeys & B_BUTTON;}))
- {
- PlaySE(SE_SELECT);
- gTasks[gUnknown_03000DAC->unk61].data[15] = 0xFF;
- gTasks[taskId].data[0]++;
- }
- sub_801A5BC(&gTasks[taskId].data[7], &gTasks[taskId].data[8]);
- break;
- case 4:
- BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0);
- gTasks[taskId].data[0]++;
- break;
- case 5:
- if (!gPaletteFade.active)
- {
- SetMainCallback2(sub_801A584);
- DestroyTask(taskId);
- }
- break;
- }
-}
-
-static void sub_801A8B0(u8 windowId, u8 fontId, const u8 * str, u8 x, u8 y, u8 mode)
-{
- u8 color[3];
-
- switch (mode)
- {
- case 0:
- color[0] = 0;
- color[1] = 2;
- color[2] = 3;
- break;
- case 1:
- color[0] = 0;
- color[1] = 1;
- color[2] = 3;
- break;
- case 2:
- color[0] = 0;
- color[1] = 4;
- color[2] = 5;
- break;
- case 3:
- color[0] = 0;
- color[1] = 7;
- color[2] = 6;
- break;
- case 4:
- color[0] = 0;
- color[1] = 1;
- color[2] = 2;
- break;
- }
-
- AddTextPrinterParameterized4(windowId, fontId, x, y, 0, 0, color, -1, str);
-}
-
-u32 sub_801A960(struct UnkStruct_x20 * a0, u32 * a1)
-{
- s32 i, j, r2;
- u32 result = a0->unk.field_0.activity;
-
- for (i = 0; i < (unsigned)ARRAY_COUNT(gUnknown_082F0D70); i++)
- {
- if (result != gUnknown_082F0D70[i][0])
- {
- continue;
- }
- if (a0->field_1A_0 != 1)
- {
- continue;
- }
- if (gUnknown_082F0D70[i][2] == 0)
- {
- r2 = 0;
- for (j = 0; j < 4; j++)
- {
- if (a0->unk.field_0.child_sprite_gender[j] != 0)
- {
- r2++;
- }
- }
- r2++;
- a1[gUnknown_082F0D70[i][1]] += r2;
- }
- else
- {
- a1[gUnknown_082F0D70[i][1]] += gUnknown_082F0D70[i][2];
- }
- }
- return result;
-}
-
-bool32 sub_801AA08(u32 * a0, u32 * a1)
-{
- s32 i;
- for (i = 0; i < 4; i++)
- {
- if (a0[i] != a1[i])
- {
- return TRUE;
- }
- }
- return FALSE;
-}
-
-bool32 sub_801AA30(u32 * a0, u32 * a1, u32 * a2, u8 taskId)
-{
- bool32 r8 = FALSE;
- u32 sp0[4] = {0, 0, 0, 0};
- struct UnkStruct_x20 ** data = (void *)gTasks[taskId].data;
- s32 i;
-
- for (i = 0; i < 16; i++)
- {
- u32 r1 = sub_801A960(&(*data)[i], sp0);
- if (r1 != a2[i])
- {
- a2[i] = r1;
- r8 = TRUE;
- }
- }
- if (sub_801AA08(sp0, a1) == 0)
- {
- if (r8 != TRUE)
- {
- return FALSE;
- }
- }
- else
- {
- memcpy(a0, sp0, sizeof(sp0));
- memcpy(a1, sp0, sizeof(sp0));
- a0[3] = a0[0] + a0[1] + a0[2] + a0[3];
- }
- return TRUE;
-}
-
-void sub_801AAD4(void)
-{
- s32 i;
- sub_8014210(10);
+ StartUnionRoomBattle(BATTLE_TYPE_LINK | BATTLE_TYPE_TRAINER);
for (i = 0; i < UNION_ROOM_PARTY_SIZE; i++)
{
gEnemyParty[i] = gPlayerParty[gSelectedOrderFromParty[i] - 1];
@@ -465,25 +69,25 @@ void sub_801AAD4(void)
}
IncrementGameStat(GAME_STAT_NUM_UNION_ROOM_BATTLES);
CalculatePlayerPartyCount();
- gTrainerBattleOpponent_A = 0xC00;
+ gTrainerBattleOpponent_A = TRAINER_UNION_ROOM;
SetMainCallback2(CB2_InitBattle);
}
-void sub_801AB68(u8 windowId, const u8 * str, u8 x, u8 y, s32 speed)
+static void AddTextPrinterForUnionRoomBattle(u8 windowId, const u8 * str, u8 x, u8 y, s32 speed)
{
s32 letterSpacing = 0;
s32 lineSpacing = 1;
- FillWindowPixelBuffer(windowId, (gUnknown_082F0DE4[0] << 4) | gUnknown_082F0DE4[0]);
- AddTextPrinterParameterized4(windowId, 1, x, y, letterSpacing, lineSpacing, gUnknown_082F0DE4, speed, str);
+ FillWindowPixelBuffer(windowId, (sTextColors[0] << 4) | sTextColors[0]);
+ AddTextPrinterParameterized4(windowId, 1, x, y, letterSpacing, lineSpacing, sTextColors, speed, str);
}
-bool32 sub_801ABDC(s16 * state, const u8 * str, s32 speed)
+static bool32 PrintUnionRoomBattleMessage(s16 * state, const u8 * str, s32 speed)
{
switch (*state)
{
case 0:
DrawTextBorderOuter(0, 0x001, 0xD);
- sub_801AB68(0, str, 0, 1, speed);
+ AddTextPrinterForUnionRoomBattle(0, str, 0, 1, speed);
PutWindowTilemap(0);
CopyWindowToVram(0, 3);
(*state)++;
@@ -499,49 +103,47 @@ bool32 sub_801ABDC(s16 * state, const u8 * str, s32 speed)
return FALSE;
}
-void sub_801AC40(void)
+static void VBlankCB_UnionRoomBattle(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
-void sub_801AC54(void)
+void CB2_UnionRoomBattle(void)
{
switch (gMain.state)
{
case 0:
SetGpuReg(REG_OFFSET_DISPCNT, 0x0000);
- gUnknown_02022C6C = AllocZeroed(4);
+ sBattle = AllocZeroed(sizeof(struct UnionRoomBattle));
ResetSpriteData();
FreeAllSpritePalettes();
ResetTasks();
ResetBgsAndClearDma3BusyFlags(0);
- InitBgsFromTemplates(0, gUnknown_082F0DD0, 1);
+ InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates));
ResetTempTileDataBuffers();
- if (!InitWindows(gUnknown_082F0DD4))
- {
+ if (!InitWindows(sWindowTemplates))
return;
- }
DeactivateAllTextPrinters();
ClearWindowTilemap(0);
- FillWindowPixelBuffer(0, 0x00);
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
FillBgTilemapBufferRect(0, 0, 0, 0, 30, 20, 0xF);
LoadUserWindowBorderGfx(0, 1, 0xD0);
LoadUserWindowBorderGfx_(0, 1, 0xD0);
sub_819789C();
- SetVBlankCallback(sub_801AC40);
+ SetVBlankCallback(VBlankCB_UnionRoomBattle);
gMain.state++;
break;
case 1:
- if (sub_801ABDC(&gUnknown_02022C6C->a0, gText_CommStandbyAwaitingOtherPlayer, 0))
+ if (PrintUnionRoomBattleMessage(&sBattle->textState, gText_CommStandbyAwaitingOtherPlayer, 0))
{
gMain.state++;
}
break;
case 2:
- BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0);
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK);
ShowBg(0);
gMain.state++;
break;
@@ -551,11 +153,11 @@ void sub_801AC54(void)
memset(gBlockSendBuffer, 0, 0x20);
if (gSelectedOrderFromParty[0] == -gSelectedOrderFromParty[1])
{
- gBlockSendBuffer[0] = 0x52;
+ gBlockSendBuffer[0] = ACTIVITY_DECLINE | IN_UNION_ROOM;
}
else
{
- gBlockSendBuffer[0] = 0x51;
+ gBlockSendBuffer[0] = ACTIVITY_ACCEPT | IN_UNION_ROOM;
}
SendBlock(0, gBlockSendBuffer, 0x20);
gMain.state++;
@@ -564,15 +166,16 @@ void sub_801AC54(void)
case 4:
if (GetBlockReceivedStatus() == 3)
{
- if (gBlockRecvBuffer[0][0] == 0x51 && gBlockRecvBuffer[1][0] == 0x51)
+ if (gBlockRecvBuffer[0][0] == (ACTIVITY_ACCEPT | IN_UNION_ROOM)
+ && gBlockRecvBuffer[1][0] == (ACTIVITY_ACCEPT | IN_UNION_ROOM))
{
- BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0);
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
gMain.state = 50;
}
else
{
sub_800AC34();
- if (gBlockRecvBuffer[GetMultiplayerId()][0] == 0x52)
+ if (gBlockRecvBuffer[GetMultiplayerId()][0] == (ACTIVITY_DECLINE | IN_UNION_ROOM))
{
gMain.state = 6;
}
@@ -594,29 +197,29 @@ void sub_801AC54(void)
case 51:
if (IsLinkTaskFinished())
{
- SetMainCallback2(sub_801AAD4);
+ SetMainCallback2(CB2_SetUpPartiesAndStartBattle);
}
break;
case 6:
- if (gReceivedRemoteLinkPlayers == 0)
+ if (!gReceivedRemoteLinkPlayers)
{
gMain.state++;
}
break;
case 7:
- if (sub_801ABDC(&gUnknown_02022C6C->a0, gText_RefusedBattle, 1))
+ if (PrintUnionRoomBattleMessage(&sBattle->textState, gText_RefusedBattle, 1))
{
SetMainCallback2(CB2_ReturnToField);
}
break;
case 8:
- if (gReceivedRemoteLinkPlayers == 0)
+ if (!gReceivedRemoteLinkPlayers)
{
gMain.state++;
}
break;
case 9:
- if (sub_801ABDC(&gUnknown_02022C6C->a0, gText_BattleWasRefused, 1))
+ if (PrintUnionRoomBattleMessage(&sBattle->textState, gText_BattleWasRefused, 1))
{
SetMainCallback2(CB2_ReturnToField);
}
diff --git a/src/union_room_chat.c b/src/union_room_chat.c
index 16d05d0ef..fefb285a8 100755
--- a/src/union_room_chat.c
+++ b/src/union_room_chat.c
@@ -27,256 +27,446 @@
#include "constants/rgb.h"
#include "constants/songs.h"
+enum
+{
+ UNION_ROOM_KB_PAGE_UPPER,
+ UNION_ROOM_KB_PAGE_LOWER,
+ UNION_ROOM_KB_PAGE_EMOJI,
+ UNION_ROOM_KB_PAGE_REGISTER,
+ UNION_ROOM_KB_PAGE_COUNT,
+};
+
+#define MAX_MESSAGE_LENGTH 15
+
+enum {
+ CHAT_MESSAGE_NONE,
+ CHAT_MESSAGE_CHAT,
+ CHAT_MESSAGE_JOIN,
+ CHAT_MESSAGE_LEAVE,
+ CHAT_MESSAGE_DROP,
+ CHAT_MESSAGE_DISBAND,
+};
+
+enum {
+ STDMESSAGE_QUIT_CHATTING,
+ STDMESSAGE_REGISTER_WHERE,
+ STDMESSAGE_REGISTER_HERE,
+ STDMESSAGE_INPUT_TEXT,
+ STDMESSAGE_EXITING_CHAT,
+ STDMESSAGE_LEADER_LEFT,
+ STDMESSAGE_ASK_SAVE,
+ STDMESSAGE_ASK_OVERWRITE,
+ STDMESSAGE_SAVING_NO_OFF,
+ STDMESSAGE_SAVED_THE_GAME,
+ STDMESSAGE_WARN_LEADER_LEAVE,
+};
+
+enum {
+ CHAT_FUNC_JOIN,
+ CHAT_FUNC_HANDLE_INPUT,
+ CHAT_FUNC_SWITCH,
+ CHAT_FUNC_ASK_QUIT,
+ CHAT_FUNC_SEND,
+ CHAT_FUNC_REGISTER,
+ CHAT_FUNC_EXIT,
+ CHAT_FUNC_DROP,
+ CHAT_FUNC_DISBANDED,
+ CHAT_FUNC_SAVE_AND_EXIT,
+};
+
+enum {
+ CHATDISPLAY_FUNC_LOAD_GFX,
+ CHATDISPLAY_FUNC_MOVE_KB_CURSOR,
+ CHATDISPLAY_FUNC_CURSOR_BLINK,
+ CHATDISPLAY_FUNC_SHOW_KB_SWAP_MENU,
+ CHATDISPLAY_FUNC_HIDE_KB_SWAP_MENU,
+ CHATDISPLAY_FUNC_SWITCH_PAGES,
+ CHATDISPLAY_FUNC_ASK_QUIT_CHATTING,
+ CHATDISPLAY_FUNC_DESTROY_YESNO,
+ CHATDISPLAY_FUNC_UPDATE_MSG,
+ CHATDISPLAY_FUNC_ASK_REGISTER_TEXT,
+ CHATDISPLAY_FUNC_CANCEL_REGISTER,
+ CHATDISPLAY_FUNC_RETURN_TO_KB,
+ CHATDISPLAY_FUNC_SCROLL_CHAT,
+ CHATDISPLAY_FUNC_PRINT_INPUT_TEXT,
+ CHATDISPLAY_FUNC_ASK_SAVE,
+ CHATDISPLAY_FUNC_ASK_OVERWRITE_SAVE,
+ CHATDISPLAY_FUNC_PRINT_SAVING,
+ CHATDISPLAY_FUNC_PRINT_SAVED_GAME,
+ CHATDISPLAY_FUNC_PRINT_EXITING_CHAT,
+ CHATDISPLAY_FUNC_PRINT_LEADER_LEFT,
+ CHATDISPLAY_FUNC_ASK_CONFIRM_LEADER_LEAVE,
+};
+
+enum {
+ CHAT_EXIT_NONE,
+ CHAT_EXIT_ONLY_LEADER,
+ CHAT_EXIT_DROPPED,
+ CHAT_EXIT_DISBANDED,
+};
+
struct UnionRoomChat
{
- u8 filler0[0x4];
- u16 unk4;
- u16 unk6;
- u8 filler8[0x2];
- u16 unkA;
- u8 fillerC[0x1];
- u8 unkD;
- u8 unkE;
- u8 unkF;
+ u32 filler1;
+ u16 funcId;
+ u16 funcState;
+ u16 filler2;
+ u16 exitDelayTimer;
+ u8 filler3;
+ u8 linkPlayerCount;
+ u8 handleInputTask;
+ u8 receiveMessagesTask;
u8 currentPage;
- u8 unk11;
+ u8 currentCol;
u8 currentRow;
- u8 unk13;
- u8 unk14;
- u8 unk15;
- u8 unk16;
- u8 unk17;
- u8 unk18;
- u8 unk19;
- u8 unk1A[0x1F];
- u8 unk39[0x40];
- u8 unk79[0x40];
- u8 unkB9[UNION_ROOM_KB_ROW_COUNT][21];
- u8 filler18B[0x5];
- u8 unk190[0x28];
- u16 unk1B8;
+ u8 multiplayerId;
+ u8 lastBufferCursorPos;
+ u8 bufferCursorPos;
+ u8 receivedPlayerIndex;
+ u8 exitType;
+ bool8 changedRegisteredTexts;
+ u8 afterSaveTimer;
+ u8 messageEntryBuffer[2 * MAX_MESSAGE_LENGTH + 1];
+ u8 receivedMessage[64];
+ u8 hostName[64];
+ u8 registeredTexts[UNION_ROOM_KB_ROW_COUNT][21];
+ u8 filler4[5];
+ u8 sendMessageBuffer[40];
+ u16 tryQuitAgainTimer;
};
-struct UnionRoomChat2_Unk0
+struct UnionRoomChatDisplay_Subtask
{
- bool32 (* unk0)(u8 *);
- u8 unk4;
- u8 unk5;
+ bool32 (* callback)(u8 *);
+ bool8 active;
+ u8 state;
};
-struct UnionRoomChat2
-{
- struct UnionRoomChat2_Unk0 unk0[3];
- u16 unk18;
- u16 unk1A;
- u16 unk1C;
- u16 unk1E;
- s16 unk20;
- u8 unk22[0x106];
- u8 unk128[BG_SCREEN_SIZE];
- u8 unk928[BG_SCREEN_SIZE];
- u8 unk1128[BG_SCREEN_SIZE];
- u8 unk1928[BG_SCREEN_SIZE];
+struct UnionRoomChatDisplay
+{
+ struct UnionRoomChatDisplay_Subtask subtasks[3];
+ u16 yesNoMenuWindowId;
+ u16 currLine;
+ u16 scrollCount;
+ u16 messageWindowId;
+ s16 bg1hofs;
+ u8 expandedPlaceholdersBuffer[0x106];
+ u8 bg0Buffer[BG_SCREEN_SIZE];
+ u8 bg1Buffer[BG_SCREEN_SIZE];
+ u8 bg3Buffer[BG_SCREEN_SIZE];
+ u8 bg2Buffer[BG_SCREEN_SIZE];
u8 unk2128[0x20];
u8 unk2148[0x20];
};
-struct UnionRoomChat3
+struct UnionRoomChatSprites
{
- struct Sprite *unk0;
- struct Sprite *unk4;
- struct Sprite *unk8;
- struct Sprite *unkC;
- struct Sprite *unk10;
- u16 unk14;
+ struct Sprite *keyboardCursor;
+ struct Sprite *textEntryArrow;
+ struct Sprite *textEntryCursor;
+ struct Sprite *rButtonIcon;
+ struct Sprite *rButtonLabel;
+ u16 cursorBlinkTimer;
};
-struct Unk82F2C98
+struct SubtaskInfo
{
- u16 unk0;
- bool32 (* unk4)(u8 *);
+ u16 idx;
+ bool32 (* callback)(u8 *);
};
-struct Unk82F2D40
+struct MessageWindowInfo
{
- const u8 *unk0;
- u8 unk4;
- u8 unk5;
- u8 unk6;
- u8 unk7;
- u8 unk8;
- u8 unk9;
- u8 unkA;
+ const u8 *text;
+ u8 boxType;
+ u8 x;
+ u8 y;
+ u8 letterSpacing;
+ u8 lineSpacing;
+ bool8 hasPlaceholders;
+ bool8 useWiderBox;
};
-static void sub_801DDD0(struct UnionRoomChat *);
-static void c2_081284E0(void);
-static void sub_801DF20(void);
-static void sub_801DF38(void);
-static void sub_801DF54(u8 taskId);
-static void sub_801DFAC(void);
-static void sub_801E030(void);
-static void sub_801E120(void);
-static void sub_801E240(void);
-static void sub_801E460(void);
-static void sub_801E5C4(void);
-static void sub_801E668(void);
-static void sub_801E764(void);
-static void sub_801E838(void);
-static void sub_801E978(void);
-static void sub_801EBD4(u16);
-static bool32 sub_801EBE4(void);
-static void sub_801EC94(void);
-static void sub_801ED68(void);
-static void sub_801ED94(void);
-static bool32 sub_801EDC4(void);
-static void sub_801EDE0(void);
-static void sub_801EE10(void);
-static void sub_801EE2C(void);
-static u8 *sub_801EE84(void);
-static u8 *sub_801EEA8(void);
-static void sub_801EF1C(u8 *);
-static void sub_801EF24(u8 *);
-static void sub_801EF4C(u8 *);
-static void sub_801EF7C(u8 *);
-static void sub_801EFA8(u8 *);
-static void sub_801EFD0(u8 *);
-static u8 *sub_801F114(void);
-static void sub_801F2B4(u8 taskId);
-static bool8 sub_801F4D0(void);
-static bool32 sub_801F534(void);
-static void sub_801F544(void);
-static void sub_801F5B8(void);
-static void sub_801F5EC(u16, u8);
-static bool8 sub_801F644(u8);
-static s8 sub_801FF08(void);
-static bool32 sub_8020890(void);
-static void sub_8020770(void);
-static void sub_801F574(struct UnionRoomChat2 *);
-static void sub_801F580(void);
-static void sub_80208D0(void);
-static bool32 sub_801FDD8(u8 *);
-static void sub_8020480(void);
-static void sub_8020538(void);
-static void sub_8020584(void);
-static void sub_80205B4(void);
-static void sub_8020604(void);
+static void InitUnionRoomChat(struct UnionRoomChat *);
+static void CB2_LoadInterface(void);
+static void VBlankCB_UnionRoomChatMain(void);
+static void CB2_UnionRoomChatMain(void);
+static void Task_HandlePlayerInput(u8 taskId);
+static void Chat_Join(void);
+static void Chat_HandleInput(void);
+static void Chat_Switch(void);
+static void Chat_AskQuitChatting(void);
+static void Chat_Exit(void);
+static void Chat_Drop(void);
+static void Chat_Disbanded(void);
+static void Chat_SendMessage(void);
+static void Chat_Register(void);
+static void Chat_SaveAndExit(void);
+static void SetChatFunction(u16);
+static bool32 HandleDPadInput(void);
+static void AppendTextToMessage(void);
+static void DeleteLastMessageCharacter(void);
+static void SwitchCaseOfLastMessageCharacter(void);
+static bool32 ChatMessageIsNotEmpty(void);
+static void RegisterTextAtRow(void);
+static void ResetMessageEntryBuffer(void);
+static void SaveRegisteredTexts(void);
+static u8 *GetEndOfMessagePtr(void);
+static u8 *GetLastCharOfMessagePtr(void);
+static void PrepareSendBuffer_Null(u8 *);
+static void PrepareSendBuffer_Join(u8 *);
+static void PrepareSendBuffer_Chat(u8 *);
+static void PrepareSendBuffer_Leave(u8 *);
+static void PrepareSendBuffer_Drop(u8 *);
+static void PrepareSendBuffer_Disband(u8 *);
+static u8 *GetLimitedMessageStartPtr(void);
+static void Task_ReceiveChatMessage(u8 taskId);
+static bool8 TryAllocDisplay(void);
+static bool32 IsDisplaySubtask0Active(void);
+static void FreeDisplay(void);
+static void RunDisplaySubtasks(void);
+static void StartDisplaySubtask(u16, u8);
+static bool8 IsDisplaySubtaskActive(u8);
+static s8 ProcessMenuInput(void);
+static bool32 TryAllocSprites(void);
+static void InitScanlineEffect(void);
+static void InitDisplay(struct UnionRoomChatDisplay *);
+static void ResetDisplaySubtasks(void);
+static void FreeSprites(void);
+static void ResetGpuBgState(void);
+static void SetBgTilemapBuffers(void);
+static void ClearBg0(void);
+static void LoadChatWindowBorderGfx(void);
+static void LoadChatWindowGfx(void);
static void sub_8020680(void);
-static void sub_80206A4(void);
-static void sub_80206D0(void);
-static void sub_8020740(void);
-static void sub_80206E8(void);
-static void sub_80208E8(void);
-static void sub_8020A68(void);
-static void sub_8020B20(void);
-static void sub_80203B0(void);
-static void sub_802040C(void);
-static void sub_802091C(bool32);
+static void LoadChatMessagesWindow(void);
+static void LoadKeyboardWindow(void);
+static void LoadKeyboardSwapWindow(void);
+static void LoadTextEntryWindow(void);
+static void CreateKeyboardCursorSprite(void);
+static void CreateTextEntrySprites(void);
+static void CreateRButtonSprites(void);
+static void ShowKeyboardSwapMenu(void);
+static void HideKeyboardSwapMenu(void);
+static void SetKeyboardCursorInvisibility(bool32);
static bool32 sub_8020320(void);
-static void sub_80201A4(void);
+static void PrintCurrentKeyboardPage(void);
static bool32 sub_8020368(void);
-static void sub_802093C(void);
-static void sub_8020B80(void);
-static void sub_801FF18(int, u16);
-static void sub_801FDDC(u8, u8, u8);
-static void sub_8020094(void);
-static void sub_801FEBC(void);
-static void sub_80200C8(void);
-static void sub_801FEE4(void);
-static void sub_80200EC(u16, u16, u8);
-static void sub_8020118(u16, u8 *, u8, u8, u8);
-static void sub_80209AC(int);
-static void sub_8020420(u16, u8 *, u8);
-static void sub_80209E0(void);
-static bool32 sub_8020A1C(void);
+static void MoveKeyboardCursor(void);
+static void UpdateRButtonLabel(void);
+static void AddStdMessageWindow(int, u16);
+static void AddYesNoMenuAt(u8, u8, u8);
+static void HideStdMessageWindow(void);
+static void HideYesNoMenuWindow(void);
+static void DestroyStdMessageWindow(void);
+static void DestroyYesNoMenuWindow(void);
+static void FillTextEntryWindow(u16, u16, u8);
+static void DrawTextEntryMessage(u16, u8 *, u8, u8, u8);
+static void SetRegisteredTextPalette(bool32);
+static void PrintChatMessage(u16, u8 *, u8);
+static void StartKeyboardCursorAnim(void);
+static bool32 TryKeyboardCursorReopen(void);
static void sub_80207C0(s16);
static void sub_8020818(s16);
-static bool32 sub_801F658(u8 *state);
-static bool32 sub_801F6F8(u8 *state);
-static bool32 sub_801F730(u8 *state);
-static bool32 sub_801F768(u8 *state);
-static bool32 sub_801F7D4(u8 *state);
-static bool32 sub_801F7E0(u8 *state);
-static bool32 sub_801F82C(u8 *state);
-static bool32 sub_801F870(u8 *state);
-static bool32 sub_801F8DC(u8 *state);
-static bool32 sub_801F984(u8 *state);
-static bool32 sub_801FA2C(u8 *state);
-static bool32 sub_801FA68(u8 *state);
-static bool32 sub_801FB44(u8 *state);
-static bool32 sub_801FB70(u8 *state);
-static bool32 sub_801FBB4(u8 *state);
-static bool32 sub_801FBF8(u8 *state);
-static bool32 sub_801FC4C(u8 *state);
-static bool32 sub_801FC9C(u8 *state);
-static bool32 sub_801FCEC(u8 *state);
-static bool32 sub_801FD30(u8 *state);
-static bool32 sub_801FD88(u8 *state);
-static void sub_8020ABC(struct Sprite *sprite);
-static void sub_8020AF4(struct Sprite *sprite);
-
-EWRAM_DATA struct UnionRoomChat *gUnknown_02022C84 = NULL;
-EWRAM_DATA struct UnionRoomChat2 *gUnknown_02022C88 = NULL;
-EWRAM_DATA struct UnionRoomChat3 *gUnknown_02022C8C = NULL;
-
-void (*const gUnknown_082F2A7C[])(void) =
- {
- sub_801DFAC,
- sub_801E030,
- sub_801E120,
- sub_801E240,
- sub_801E764,
- sub_801E838,
- sub_801E460,
- sub_801E5C4,
- sub_801E668,
- sub_801E978,
- };
-
-static const u8 sKeyboardPageMaxRow[] =
-{
- [UNION_ROOM_KB_PAGE_UPPER] = 9,
- [UNION_ROOM_KB_PAGE_LOWER] = 9,
- [UNION_ROOM_KB_PAGE_EMOJI] = 9,
- 9
+static bool32 Display_Dummy(u8 *);
+static bool32 Display_LoadGfx(u8 *state);
+static bool32 Display_ShowKeyboardSwapMenu(u8 *state);
+static bool32 Display_HideKeyboardSwapMenu(u8 *state);
+static bool32 Display_SwitchPages(u8 *state);
+static bool32 Display_MoveKeyboardCursor(u8 *state);
+static bool32 Display_AskQuitChatting(u8 *state);
+static bool32 Display_DestroyYesNoDialog(u8 *state);
+static bool32 Display_UpdateMessageBuffer(u8 *state);
+static bool32 Display_AskRegisterText(u8 *state);
+static bool32 Display_CancelRegister(u8 *state);
+static bool32 Display_ReturnToKeyboard(u8 *state);
+static bool32 Display_ScrollChat(u8 *state);
+static bool32 Display_AnimateKeyboardCursor(u8 *state);
+static bool32 Display_PrintInputText(u8 *state);
+static bool32 Display_PrintExitingChat(u8 *state);
+static bool32 Display_PrintLeaderLeft(u8 *state);
+static bool32 Display_AskSave(u8 *state);
+static bool32 Display_AskOverwriteSave(u8 *state);
+static bool32 Display_PrintSavingDontTurnOff(u8 *state);
+static bool32 Display_PrintSavedTheGame(u8 *state);
+static bool32 Display_AskConfirmLeaderLeave(u8 *state);
+static void SpriteCB_TextEntryCursor(struct Sprite *sprite);
+static void SpriteCB_TextEntryArrow(struct Sprite *sprite);
+
+static EWRAM_DATA struct UnionRoomChat *sChat = NULL;
+static EWRAM_DATA struct UnionRoomChatDisplay *sDisplay = NULL;
+static EWRAM_DATA struct UnionRoomChatSprites *sSprites = NULL;
+
+static void (*const sChatMainFunctions[])(void) = {
+ [CHAT_FUNC_JOIN] = Chat_Join,
+ [CHAT_FUNC_HANDLE_INPUT] = Chat_HandleInput,
+ [CHAT_FUNC_SWITCH] = Chat_Switch,
+ [CHAT_FUNC_ASK_QUIT] = Chat_AskQuitChatting,
+ [CHAT_FUNC_SEND] = Chat_SendMessage,
+ [CHAT_FUNC_REGISTER] = Chat_Register,
+ [CHAT_FUNC_EXIT] = Chat_Exit,
+ [CHAT_FUNC_DROP] = Chat_Drop,
+ [CHAT_FUNC_DISBANDED] = Chat_Disbanded,
+ [CHAT_FUNC_SAVE_AND_EXIT] = Chat_SaveAndExit
+};
+
+static const u8 sKeyboardPageMaxRow[UNION_ROOM_KB_PAGE_COUNT] =
+{
+ [UNION_ROOM_KB_PAGE_UPPER] = 9,
+ [UNION_ROOM_KB_PAGE_LOWER] = 9,
+ [UNION_ROOM_KB_PAGE_EMOJI] = 9,
+ [UNION_ROOM_KB_PAGE_REGISTER] = 9
};
-static const u8 gUnknown_082F2AA8[] = {
- CHAR_SPACE, 0x16, 0x17, 0x68, 0x19, 0x1A, 0x1B, 0x1C,
- 0x1D, 0x1E, CHAR_SPACE, 0x20, 0x21, 0x22, 0x23, 0x24,
- 0x25, 0x26, 0x27, 0x28, 0x29, 0x15, 0x01, 0x02,
- CHAR_SPACE, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, CHAR_SPACE,
- 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12,
- 0x13, 0x14, 0x2A, 0x2B, 0x2C, 0x2D, CHAR_SPACE, CHAR_SPACE,
- CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, 0x35, 0x36, CHAR_SPACE,
- CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE,
- CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE,
- CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE,
- CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, 0x53, 0x54, 0x55, 0x56, CHAR_SPACE,
- CHAR_SPACE, CHAR_SPACE, 0x6F, 0x5B, 0x5C, 0x5D, CHAR_SPACE, CHAR_SPACE,
- CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE,
- 0x03, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, 0x5A,
- CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE,
- CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE,
- CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, 0x84, 0x85, 0x86, CHAR_SPACE,
- CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE,
- CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE,
- CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE,
- 0xA0, CHAR_0, CHAR_1, CHAR_2, CHAR_3, CHAR_4, CHAR_5, CHAR_6,
- CHAR_7, CHAR_8, CHAR_9, CHAR_EXCL_MARK, CHAR_QUESTION_MARK, CHAR_PERIOD, CHAR_HYPHEN, 0xAF,
- CHAR_ELLIPSIS, CHAR_DBL_QUOT_LEFT, CHAR_DBL_QUOT_RIGHT, CHAR_SGL_QUOT_LEFT, CHAR_SGL_QUOT_RIGHT, CHAR_MALE, CHAR_FEMALE, CHAR_CURRENCY,
- CHAR_COMMA, CHAR_MULT_SIGN, CHAR_SLASH, CHAR_a, CHAR_b, CHAR_c, CHAR_d, CHAR_e,
- CHAR_f, CHAR_g, CHAR_h, CHAR_i, CHAR_j, CHAR_k, CHAR_l, CHAR_m,
- CHAR_n, CHAR_o, CHAR_p, CHAR_q, CHAR_r, CHAR_s, CHAR_t, CHAR_u,
- CHAR_v, CHAR_w, CHAR_x, CHAR_y, CHAR_z, CHAR_A, CHAR_B, CHAR_C,
- CHAR_D, CHAR_E, CHAR_F, CHAR_G, CHAR_H, CHAR_I, CHAR_J, CHAR_K,
- CHAR_L, CHAR_M, CHAR_N, CHAR_O, CHAR_P, CHAR_Q, CHAR_R, CHAR_S,
- CHAR_T, CHAR_U, CHAR_V, CHAR_W, CHAR_X, CHAR_Y, CHAR_Z, 0xEF,
- CHAR_COLON, 0xF4, 0xF5, 0xF6, 0xF1, 0xF2, 0xF3, CHAR_SPACE,
- CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE
+static const u8 sCaseToggleTable[256] = {
+ [CHAR_A] = CHAR_a,
+ [CHAR_B] = CHAR_b,
+ [CHAR_C] = CHAR_c,
+ [CHAR_D] = CHAR_d,
+ [CHAR_E] = CHAR_e,
+ [CHAR_F] = CHAR_f,
+ [CHAR_G] = CHAR_g,
+ [CHAR_H] = CHAR_h,
+ [CHAR_I] = CHAR_i,
+ [CHAR_J] = CHAR_j,
+ [CHAR_K] = CHAR_k,
+ [CHAR_L] = CHAR_l,
+ [CHAR_M] = CHAR_m,
+ [CHAR_N] = CHAR_n,
+ [CHAR_O] = CHAR_o,
+ [CHAR_P] = CHAR_p,
+ [CHAR_Q] = CHAR_q,
+ [CHAR_R] = CHAR_r,
+ [CHAR_S] = CHAR_s,
+ [CHAR_T] = CHAR_t,
+ [CHAR_U] = CHAR_u,
+ [CHAR_V] = CHAR_v,
+ [CHAR_W] = CHAR_w,
+ [CHAR_X] = CHAR_x,
+ [CHAR_Y] = CHAR_y,
+ [CHAR_Z] = CHAR_z,
+ [CHAR_a] = CHAR_A,
+ [CHAR_b] = CHAR_B,
+ [CHAR_c] = CHAR_C,
+ [CHAR_d] = CHAR_D,
+ [CHAR_e] = CHAR_E,
+ [CHAR_f] = CHAR_F,
+ [CHAR_g] = CHAR_G,
+ [CHAR_h] = CHAR_H,
+ [CHAR_i] = CHAR_I,
+ [CHAR_j] = CHAR_J,
+ [CHAR_k] = CHAR_K,
+ [CHAR_l] = CHAR_L,
+ [CHAR_m] = CHAR_M,
+ [CHAR_n] = CHAR_N,
+ [CHAR_o] = CHAR_O,
+ [CHAR_p] = CHAR_P,
+ [CHAR_q] = CHAR_Q,
+ [CHAR_r] = CHAR_R,
+ [CHAR_s] = CHAR_S,
+ [CHAR_t] = CHAR_T,
+ [CHAR_u] = CHAR_U,
+ [CHAR_v] = CHAR_V,
+ [CHAR_w] = CHAR_W,
+ [CHAR_x] = CHAR_X,
+ [CHAR_y] = CHAR_Y,
+ [CHAR_z] = CHAR_Z,
+ [CHAR_A_GRAVE] = CHAR_a_GRAVE,
+ [CHAR_A_ACUTE] = CHAR_a_ACUTE,
+ [CHAR_A_CIRCUMFLEX] = CHAR_a_CIRCUMFLEX,
+ [CHAR_A_DIAERESIS] = CHAR_a_DIAERESIS,
+ [CHAR_C_CEDILLA] = CHAR_c_CEDILLA,
+ [CHAR_E_GRAVE] = CHAR_e_GRAVE,
+ [CHAR_E_ACUTE] = CHAR_e_ACUTE,
+ [CHAR_E_CIRCUMFLEX] = CHAR_e_CIRCUMFLEX,
+ [CHAR_E_DIAERESIS] = CHAR_e_DIAERESIS,
+ [CHAR_I_GRAVE] = CHAR_i_GRAVE,
+ [CHAR_I_ACUTE] = CHAR_i_ACUTE,
+ [CHAR_I_CIRCUMFLEX] = CHAR_i_CIRCUMFLEX,
+ [CHAR_I_DIAERESIS] = CHAR_i_DIAERESIS,
+ [CHAR_O_GRAVE] = CHAR_o_GRAVE,
+ [CHAR_O_ACUTE] = CHAR_o_ACUTE,
+ [CHAR_O_CIRCUMFLEX] = CHAR_o_CIRCUMFLEX,
+ [CHAR_O_DIAERESIS] = CHAR_o_DIAERESIS,
+ [CHAR_OE] = CHAR_oe,
+ [CHAR_U_GRAVE] = CHAR_u_GRAVE,
+ [CHAR_U_ACUTE] = CHAR_u_ACUTE,
+ [CHAR_U_CIRCUMFLEX] = CHAR_u_CIRCUMFLEX,
+ [CHAR_U_DIAERESIS] = CHAR_u_DIAERESIS,
+ [CHAR_N_TILDE] = CHAR_n_TILDE,
+ [CHAR_ESZETT] = CHAR_ESZETT,
+ [CHAR_a_GRAVE] = CHAR_A_GRAVE,
+ [CHAR_a_ACUTE] = CHAR_A_ACUTE,
+ [CHAR_a_CIRCUMFLEX] = CHAR_A_CIRCUMFLEX,
+ [CHAR_a_DIAERESIS] = CHAR_A_DIAERESIS,
+ [CHAR_c_CEDILLA] = CHAR_C_CEDILLA,
+ [CHAR_e_GRAVE] = CHAR_E_GRAVE,
+ [CHAR_e_ACUTE] = CHAR_E_ACUTE,
+ [CHAR_e_CIRCUMFLEX] = CHAR_E_CIRCUMFLEX,
+ [CHAR_e_DIAERESIS] = CHAR_E_DIAERESIS,
+ [CHAR_i_GRAVE] = CHAR_I_GRAVE,
+ [CHAR_i_ACUTE] = CHAR_I_ACUTE,
+ [CHAR_i_CIRCUMFLEX] = CHAR_I_CIRCUMFLEX,
+ [CHAR_i_DIAERESIS] = CHAR_I_DIAERESIS,
+ [CHAR_o_GRAVE] = CHAR_O_GRAVE,
+ [CHAR_o_ACUTE] = CHAR_O_ACUTE,
+ [CHAR_o_CIRCUMFLEX] = CHAR_O_CIRCUMFLEX,
+ [CHAR_o_DIAERESIS] = CHAR_O_DIAERESIS,
+ [CHAR_oe] = CHAR_OE,
+ [CHAR_u_GRAVE] = CHAR_U_GRAVE,
+ [CHAR_u_ACUTE] = CHAR_U_ACUTE,
+ [CHAR_u_CIRCUMFLEX] = CHAR_U_CIRCUMFLEX,
+ [CHAR_u_DIAERESIS] = CHAR_U_DIAERESIS,
+ [CHAR_n_TILDE] = CHAR_N_TILDE,
+ [CHAR_0] = CHAR_0,
+ [CHAR_1] = CHAR_1,
+ [CHAR_2] = CHAR_2,
+ [CHAR_3] = CHAR_3,
+ [CHAR_4] = CHAR_4,
+ [CHAR_5] = CHAR_5,
+ [CHAR_6] = CHAR_6,
+ [CHAR_7] = CHAR_7,
+ [CHAR_8] = CHAR_8,
+ [CHAR_9] = CHAR_9,
+ [CHAR_PK] = CHAR_PK,
+ [CHAR_MN] = CHAR_MN,
+ [CHAR_PO] = CHAR_PO,
+ [CHAR_KE] = CHAR_KE,
+ [CHAR_SUPER_E] = CHAR_SUPER_E,
+ [CHAR_SUPER_ER] = CHAR_SUPER_ER,
+ [CHAR_SUPER_RE] = CHAR_SUPER_RE,
+ [CHAR_PERIOD] = CHAR_PERIOD,
+ [CHAR_COMMA] = CHAR_COMMA,
+ [CHAR_COLON] = CHAR_COLON,
+ [CHAR_SEMICOLON] = CHAR_SEMICOLON,
+ [CHAR_EXCL_MARK] = CHAR_EXCL_MARK,
+ [CHAR_QUESTION_MARK] = CHAR_QUESTION_MARK,
+ [CHAR_HYPHEN] = CHAR_HYPHEN,
+ [CHAR_SLASH] = CHAR_SLASH,
+ [CHAR_ELLIPSIS] = CHAR_ELLIPSIS,
+ [CHAR_LEFT_PAREN] = CHAR_LEFT_PAREN,
+ [CHAR_RIGHT_PAREN] = CHAR_RIGHT_PAREN,
+ [CHAR_AMPERSAND] = CHAR_AMPERSAND,
+ [CHAR_DBL_QUOT_LEFT] = CHAR_DBL_QUOT_LEFT,
+ [CHAR_DBL_QUOT_RIGHT] = CHAR_DBL_QUOT_RIGHT,
+ [CHAR_SGL_QUOT_LEFT] = CHAR_SGL_QUOT_LEFT,
+ [CHAR_SGL_QUOT_RIGHT] = CHAR_SGL_QUOT_RIGHT,
+ [CHAR_MASCULINE_ORDINAL] = CHAR_MASCULINE_ORDINAL,
+ [CHAR_FEMININE_ORDINAL] = CHAR_FEMININE_ORDINAL,
+ [CHAR_BULLET] = CHAR_BULLET,
+ [CHAR_EQUALS] = CHAR_EQUALS,
+ [CHAR_MULT_SIGN] = CHAR_MULT_SIGN,
+ [CHAR_PERCENT] = CHAR_PERCENT,
+ [CHAR_LESS_THAN] = CHAR_LESS_THAN,
+ [CHAR_GREATER_THAN] = CHAR_GREATER_THAN,
+ [CHAR_MALE] = CHAR_MALE,
+ [CHAR_FEMALE] = CHAR_FEMALE,
+ [CHAR_CURRENCY] = CHAR_CURRENCY,
+ [CHAR_BLACK_TRIANGLE] = CHAR_BLACK_TRIANGLE,
};
-static const u8 *const sUnionRoomKeyboardText[UNION_ROOM_KB_PAGE_COUNT][UNION_ROOM_KB_ROW_COUNT] =
+// Excludes UNION_ROOM_KB_PAGE_REGISTER, the text for which is chosen by the player
+static const u8 *const sUnionRoomKeyboardText[UNION_ROOM_KB_PAGE_COUNT - 1][UNION_ROOM_KB_ROW_COUNT] =
{
[UNION_ROOM_KB_PAGE_UPPER] =
{
@@ -319,10 +509,10 @@ static const u8 *const sUnionRoomKeyboardText[UNION_ROOM_KB_PAGE_COUNT][UNION_RO
}
};
-const u16 gUnknown_082F2C20[] = INCBIN_U16("graphics/interface/unk_palette1.gbapal");
-const u16 gUnknown_082F2C40[] = INCBIN_U16("graphics/interface/unk_palette2.gbapal");
+static const u16 sUnk_Palette1[] = INCBIN_U16("graphics/union_room_chat/unk_palette1.gbapal");
+static const u16 sUnk_Palette2[] = INCBIN_U16("graphics/union_room_chat/unk_palette2.gbapal");
-const struct BgTemplate gUnknown_082F2C60[] = {
+static const struct BgTemplate sBgTemplates[] = {
{
.bg = 0,
.charBaseIndex = 0,
@@ -358,7 +548,7 @@ const struct BgTemplate gUnknown_082F2C60[] = {
}
};
-const struct WindowTemplate gUnknown_082F2C70[] = {
+static const struct WindowTemplate sWinTemplates[] = {
{
.bg = 0x03,
.tilemapLeft = 0x08,
@@ -391,242 +581,341 @@ const struct WindowTemplate gUnknown_082F2C70[] = {
.height = 0x09,
.paletteNum = 0x0e,
.baseBlock = 0x0013,
- }, { 0xFF }
+ }, DUMMY_WIN_TEMPLATE
};
-const struct Unk82F2C98 gUnknown_082F2C98[] = {
- {0x00000000, sub_801F658},
- {0x00000003, sub_801F6F8},
- {0x00000004, sub_801F730},
- {0x00000005, sub_801F768},
- {0x00000001, sub_801F7D4},
- {0x00000006, sub_801F7E0},
- {0x00000007, sub_801F82C},
- {0x00000008, sub_801F870},
- {0x00000009, sub_801F8DC},
- {0x0000000a, sub_801F984},
- {0x0000000b, sub_801FA2C},
- {0x0000000c, sub_801FA68},
- {0x00000002, sub_801FB44},
- {0x0000000d, sub_801FB70},
- {0x00000012, sub_801FBB4},
- {0x00000013, sub_801FBF8},
- {0x0000000e, sub_801FC4C},
- {0x0000000f, sub_801FC9C},
- {0x00000010, sub_801FCEC},
- {0x00000011, sub_801FD30},
- {0x00000014, sub_801FD88}
+static const struct SubtaskInfo sDisplaySubtasks[] = {
+ {CHATDISPLAY_FUNC_LOAD_GFX, Display_LoadGfx},
+ {CHATDISPLAY_FUNC_SHOW_KB_SWAP_MENU, Display_ShowKeyboardSwapMenu},
+ {CHATDISPLAY_FUNC_HIDE_KB_SWAP_MENU, Display_HideKeyboardSwapMenu},
+ {CHATDISPLAY_FUNC_SWITCH_PAGES, Display_SwitchPages},
+ {CHATDISPLAY_FUNC_MOVE_KB_CURSOR, Display_MoveKeyboardCursor},
+ {CHATDISPLAY_FUNC_ASK_QUIT_CHATTING, Display_AskQuitChatting},
+ {CHATDISPLAY_FUNC_DESTROY_YESNO, Display_DestroyYesNoDialog},
+ {CHATDISPLAY_FUNC_UPDATE_MSG, Display_UpdateMessageBuffer},
+ {CHATDISPLAY_FUNC_ASK_REGISTER_TEXT, Display_AskRegisterText},
+ {CHATDISPLAY_FUNC_CANCEL_REGISTER, Display_CancelRegister},
+ {CHATDISPLAY_FUNC_RETURN_TO_KB, Display_ReturnToKeyboard},
+ {CHATDISPLAY_FUNC_SCROLL_CHAT, Display_ScrollChat},
+ {CHATDISPLAY_FUNC_CURSOR_BLINK, Display_AnimateKeyboardCursor},
+ {CHATDISPLAY_FUNC_PRINT_INPUT_TEXT, Display_PrintInputText},
+ {CHATDISPLAY_FUNC_PRINT_EXITING_CHAT, Display_PrintExitingChat},
+ {CHATDISPLAY_FUNC_PRINT_LEADER_LEFT, Display_PrintLeaderLeft},
+ {CHATDISPLAY_FUNC_ASK_SAVE, Display_AskSave},
+ {CHATDISPLAY_FUNC_ASK_OVERWRITE_SAVE, Display_AskOverwriteSave},
+ {CHATDISPLAY_FUNC_PRINT_SAVING, Display_PrintSavingDontTurnOff},
+ {CHATDISPLAY_FUNC_PRINT_SAVED_GAME, Display_PrintSavedTheGame},
+ {CHATDISPLAY_FUNC_ASK_CONFIRM_LEADER_LEAVE, Display_AskConfirmLeaderLeave}
};
-const struct Unk82F2D40 gUnknown_082F2D40[] = {
- {gText_QuitChatting, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00},
- {gText_RegisterTextWhere, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00},
- {gText_RegisterTextHere, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00},
- {gText_InputText, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00},
- {gText_ExitingChat, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00},
- {gText_LeaderLeftEndingChat, 0x02, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00},
- {gText_RegisteredTextChanged, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01},
- {gText_AlreadySavedFile_Unused, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01},
- {gText_SavingDontTurnOff_Unused, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01},
- {gText_PlayerSavedGame_Unused, 0x02, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01},
- {gText_IfLeaderLeavesChatEnds, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01}
+static const struct MessageWindowInfo sDisplayStdMessages[] = {
+ [STDMESSAGE_QUIT_CHATTING] = {
+ .text = gText_QuitChatting,
+ .boxType = 1,
+ .x = 0,
+ .y = 1,
+ .letterSpacing = 0,
+ .lineSpacing = 0,
+ .hasPlaceholders = FALSE,
+ .useWiderBox = FALSE
+ },
+ [STDMESSAGE_REGISTER_WHERE] = {
+ .text = gText_RegisterTextWhere,
+ .boxType = 1,
+ .x = 0,
+ .y = 1,
+ .letterSpacing = 0,
+ .lineSpacing = 0,
+ .hasPlaceholders = FALSE,
+ .useWiderBox = FALSE
+ },
+ [STDMESSAGE_REGISTER_HERE] = {
+ .text = gText_RegisterTextHere,
+ .boxType = 1,
+ .x = 0,
+ .y = 1,
+ .letterSpacing = 0,
+ .lineSpacing = 0,
+ .hasPlaceholders = FALSE,
+ .useWiderBox = FALSE
+ },
+ [STDMESSAGE_INPUT_TEXT] = {
+ .text = gText_InputText,
+ .boxType = 1,
+ .x = 0,
+ .y = 1,
+ .letterSpacing = 0,
+ .lineSpacing = 0,
+ .hasPlaceholders = FALSE,
+ .useWiderBox = FALSE
+ },
+ [STDMESSAGE_EXITING_CHAT] = {
+ .text = gText_ExitingChat,
+ .boxType = 2,
+ .x = 0,
+ .y = 1,
+ .letterSpacing = 0,
+ .lineSpacing = 0,
+ .hasPlaceholders = FALSE,
+ .useWiderBox = FALSE
+ },
+ [STDMESSAGE_LEADER_LEFT] = {
+ .text = gText_LeaderLeftEndingChat,
+ .boxType = 2,
+ .x = 0,
+ .y = 1,
+ .letterSpacing = 0,
+ .lineSpacing = 0,
+ .hasPlaceholders = TRUE,
+ .useWiderBox = FALSE
+ },
+ [STDMESSAGE_ASK_SAVE] = {
+ .text = gText_RegisteredTextChangedOKToSave,
+ .boxType = 2,
+ .x = 0,
+ .y = 1,
+ .letterSpacing = 0,
+ .lineSpacing = 0,
+ .hasPlaceholders = FALSE,
+ .useWiderBox = TRUE
+ },
+ [STDMESSAGE_ASK_OVERWRITE] = {
+ .text = gText_AlreadySavedFile_Chat,
+ .boxType = 2,
+ .x = 0,
+ .y = 1,
+ .letterSpacing = 0,
+ .lineSpacing = 0,
+ .hasPlaceholders = FALSE,
+ .useWiderBox = TRUE
+ },
+ [STDMESSAGE_SAVING_NO_OFF] = {
+ .text = gText_SavingDontTurnOff_Chat,
+ .boxType = 2,
+ .x = 0,
+ .y = 1,
+ .letterSpacing = 0,
+ .lineSpacing = 0,
+ .hasPlaceholders = FALSE,
+ .useWiderBox = TRUE
+ },
+ [STDMESSAGE_SAVED_THE_GAME] = {
+ .text = gText_PlayerSavedGame_Chat,
+ .boxType = 2,
+ .x = 0,
+ .y = 1,
+ .letterSpacing = 0,
+ .lineSpacing = 0,
+ .hasPlaceholders = TRUE,
+ .useWiderBox = TRUE
+ },
+ [STDMESSAGE_WARN_LEADER_LEAVE] = {
+ .text = gText_IfLeaderLeavesChatEnds,
+ .boxType = 2,
+ .x = 0,
+ .y = 1,
+ .letterSpacing = 0,
+ .lineSpacing = 0,
+ .hasPlaceholders = FALSE,
+ .useWiderBox = TRUE
+ }
};
-const u8 gText_Ellipsis[] = _("…");
+static const u8 sText_Ellipsis[] = _("…");
-const struct MenuAction gUnknown_082F2DC8[] = {
- {gText_Upper, NULL},
- {gText_Lower, NULL},
- {gText_Symbols, NULL},
- {gText_Register2, NULL},
- {gText_Exit2, NULL},
+static const struct MenuAction sKeyboardPageTitleTexts[UNION_ROOM_KB_PAGE_COUNT + 1] = {
+ [UNION_ROOM_KB_PAGE_UPPER] = {gText_Upper, NULL},
+ [UNION_ROOM_KB_PAGE_LOWER] = {gText_Lower, NULL},
+ [UNION_ROOM_KB_PAGE_EMOJI] = {gText_Symbols, NULL},
+ [UNION_ROOM_KB_PAGE_REGISTER] = {gText_Register2, NULL},
+ [UNION_ROOM_KB_PAGE_COUNT] = {gText_Exit2, NULL},
};
-const u16 gUnknown_082F2DF0[] = INCBIN_U16("graphics/interface/unk_palette3.gbapal");
-const u32 gUnknown_082F2E10[] = INCBIN_U32("graphics/interface/unk_cursor.4bpp.lz");
-const u32 gUnknown_082F3094[] = INCBIN_U32("graphics/interface/unk_dash.4bpp.lz");
-const u32 gUnknown_082F30B4[] = INCBIN_U32("graphics/interface/unk_cursor_arrow.4bpp.lz");
-const u32 gUnknown_082F30E0[] = INCBIN_U32("graphics/interface/unk_rbutton.4bpp.lz");
-
-const struct CompressedSpriteSheet gUnknown_082F3134[] = {
- {gUnknown_082F2E10, 0x1000, 0x0000},
- {gUnknown_082F30B4, 0x0040, 0x0001},
- {gUnknown_082F3094, 0x0040, 0x0002},
- {gUnknown_082F30E0, 0x0080, 0x0003},
- {gUnknown_08DD4CF8, 0x0400, 0x0004}
+static const u16 sUnionRoomChatInterfacePal[] = INCBIN_U16("graphics/union_room_chat/interface.gbapal");
+static const u32 sKeyboardCursorTiles[] = INCBIN_U32("graphics/union_room_chat/keyboard_cursor.4bpp.lz");
+static const u32 sTextEntryCursorTiles[] = INCBIN_U32("graphics/union_room_chat/text_entry_cursor.4bpp.lz");
+static const u32 sTextEntryArrowTiles[] = INCBIN_U32("graphics/union_room_chat/text_entry_arrow.4bpp.lz");
+static const u32 sRButtonGfxTiles[] = INCBIN_U32("graphics/union_room_chat/r_button.4bpp.lz");
+
+static const struct CompressedSpriteSheet sSpriteSheets[] = {
+ {sKeyboardCursorTiles, 0x1000, 0},
+ {sTextEntryArrowTiles, 0x0040, 1},
+ {sTextEntryCursorTiles, 0x0040, 2},
+ {sRButtonGfxTiles, 0x0080, 3},
+ {gUnionRoomChat_RButtonLabels, 0x0400, 4}
};
-const struct SpritePalette gUnknown_082F315C = {
- gUnknown_082F2DF0, 0x0000
+static const struct SpritePalette sSpritePalette = {
+ sUnionRoomChatInterfacePal, 0
};
-const struct OamData gUnknown_082F3164 = {
+static const struct OamData sOam_KeyboardCursor = {
.shape = SPRITE_SHAPE(64x32),
.size = SPRITE_SIZE(64x32),
.priority = 1
};
-const union AnimCmd gUnknown_082F316C[] = {
+static const union AnimCmd sAnim_KeyboardCursor_Open[] = {
ANIMCMD_FRAME(0x00, 30),
ANIMCMD_END
};
-const union AnimCmd gUnknown_082F3174[] = {
+static const union AnimCmd sAnim_KeyboardCursor_Closed[] = {
ANIMCMD_FRAME(0x20, 30),
ANIMCMD_END
};
-const union AnimCmd gUnknown_082F317C[] = {
+static const union AnimCmd sAnim_KeyboardCursorWide_Open[] = {
ANIMCMD_FRAME(0x40, 30),
ANIMCMD_END
};
-const union AnimCmd gUnknown_082F3184[] = {
+static const union AnimCmd sAnim_KeyboardCursorWide_Closed[] = {
ANIMCMD_FRAME(0x60, 30),
ANIMCMD_END
};
-const union AnimCmd *const gUnknown_082F318C[] = {
- gUnknown_082F316C,
- gUnknown_082F3174,
- gUnknown_082F317C,
- gUnknown_082F3184
+static const union AnimCmd *const sAnims_KeyboardCursor[] = {
+ sAnim_KeyboardCursor_Open,
+ sAnim_KeyboardCursor_Closed,
+ sAnim_KeyboardCursorWide_Open,
+ sAnim_KeyboardCursorWide_Closed
};
-const struct SpriteTemplate gUnknown_082F319C = {
+static const struct SpriteTemplate sSpriteTemplate_KeyboardCursor = {
.tileTag = 0x0000,
.paletteTag = 0x0000,
- .oam = &gUnknown_082F3164,
- .anims = gUnknown_082F318C,
+ .oam = &sOam_KeyboardCursor,
+ .anims = sAnims_KeyboardCursor,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
-const struct OamData gUnknown_082F31B4 = {
+static const struct OamData sOam_TextEntrySprite = {
.shape = SPRITE_SHAPE(8x16),
.size = SPRITE_SIZE(8x16),
.priority = 2
};
-const struct SpriteTemplate gUnknown_082F31BC = {
+static const struct SpriteTemplate sSpriteTemplate_TextEntryCursor = {
.tileTag = 0x0002,
.paletteTag = 0x0000,
- .oam = &gUnknown_082F31B4,
+ .oam = &sOam_TextEntrySprite,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
- .callback = sub_8020ABC
+ .callback = SpriteCB_TextEntryCursor
};
-const struct SpriteTemplate gUnknown_082F31D4 = {
+static const struct SpriteTemplate sSpriteTemplate_TextEntryArrow = {
.tileTag = 0x0001,
.paletteTag = 0x0000,
- .oam = &gUnknown_082F31B4,
+ .oam = &sOam_TextEntrySprite,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
- .callback = sub_8020AF4
+ .callback = SpriteCB_TextEntryArrow
};
-const struct OamData gUnknown_082F31EC = {
+static const struct OamData sOam_RButtonIcon = {
.shape = SPRITE_SHAPE(16x16),
.size = SPRITE_SIZE(16x16),
.priority = 2
};
-const struct OamData gUnknown_082F31F4 = {
+static const struct OamData sOam_RButtonLabel = {
.shape = SPRITE_SHAPE(32x16),
.size = SPRITE_SIZE(32x16),
.priority = 2
};
-const union AnimCmd gUnknown_082F31FC[] = {
+static const union AnimCmd sAnim_ToggleCaseIcon[] = {
ANIMCMD_FRAME(0x00, 2),
ANIMCMD_END
};
-const union AnimCmd gUnknown_082F3204[] = {
+static const union AnimCmd sAnim_ToggleCaseIcon_Duplicate1[] = {
ANIMCMD_FRAME(0x08, 2),
ANIMCMD_END
};
-const union AnimCmd gUnknown_082F320C[] = {
+static const union AnimCmd sAnim_ToggleCaseIcon_Duplicate2[] = {
ANIMCMD_FRAME(0x10, 2),
ANIMCMD_END
};
-const union AnimCmd gUnknown_082F3214[] = {
+static const union AnimCmd sAnim_RegisterIcon[] = {
ANIMCMD_FRAME(0x18, 2),
ANIMCMD_END
};
-const union AnimCmd *const gUnknown_082F321C[] = {
- gUnknown_082F31FC,
- gUnknown_082F3204,
- gUnknown_082F320C,
- gUnknown_082F3214
+static const union AnimCmd *const sAnims_RButtonLabels[] = {
+ sAnim_ToggleCaseIcon,
+ sAnim_ToggleCaseIcon_Duplicate1,
+ sAnim_ToggleCaseIcon_Duplicate2,
+ sAnim_RegisterIcon
};
-const struct SpriteTemplate gUnknown_082F322C = {
+static const struct SpriteTemplate sSpriteTemplate_RButtonIcon = {
.tileTag = 0x0003,
.paletteTag = 0x0000,
- .oam = &gUnknown_082F31EC,
+ .oam = &sOam_RButtonIcon,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
-const struct SpriteTemplate gUnknown_082F3244 = {
+static const struct SpriteTemplate sSpriteTemplate_RButtonLabels = {
.tileTag = 0x0004,
.paletteTag = 0x0000,
- .oam = &gUnknown_082F31F4,
- .anims = gUnknown_082F321C,
+ .oam = &sOam_RButtonLabel,
+ .anims = sAnims_RButtonLabels,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
-void sub_801DD98(void)
+void EnterUnionRoomChat(void)
{
- gUnknown_02022C84 = Alloc(sizeof(*gUnknown_02022C84));
- sub_801DDD0(gUnknown_02022C84);
+ sChat = Alloc(sizeof(struct UnionRoomChat));
+ InitUnionRoomChat(sChat);
gKeyRepeatStartDelay = 20;
SetVBlankCallback(NULL);
- SetMainCallback2(c2_081284E0);
+ SetMainCallback2(CB2_LoadInterface);
}
-static void sub_801DDD0(struct UnionRoomChat *unionRoomChat)
+static void InitUnionRoomChat(struct UnionRoomChat *chat)
{
int i;
- unionRoomChat->unk4 = 0;
- unionRoomChat->unk6 = 0;
- unionRoomChat->currentPage = 0;
- unionRoomChat->unk11 = 0;
- unionRoomChat->currentRow = 0;
- unionRoomChat->unk14 = 0;
- unionRoomChat->unk15 = 0;
- unionRoomChat->unk16 = 0;
- unionRoomChat->unk1A[0] = EOS;
- unionRoomChat->unkD = GetLinkPlayerCount();
- unionRoomChat->unk13 = GetMultiplayerId();
- unionRoomChat->unk17 = 0;
- unionRoomChat->unk18 = 0;
- sub_801EF1C(unionRoomChat->unk190);
+ chat->funcId = 0;
+ chat->funcState = 0;
+ chat->currentPage = 0;
+ chat->currentCol = 0;
+ chat->currentRow = 0;
+ chat->lastBufferCursorPos = 0;
+ chat->bufferCursorPos = 0;
+ chat->receivedPlayerIndex = 0;
+ chat->messageEntryBuffer[0] = EOS;
+ chat->linkPlayerCount = GetLinkPlayerCount();
+ chat->multiplayerId = GetMultiplayerId();
+ chat->exitType = 0;
+ chat->changedRegisteredTexts = FALSE;
+ PrepareSendBuffer_Null(chat->sendMessageBuffer);
for (i = 0; i < UNION_ROOM_KB_ROW_COUNT; i++)
- StringCopy(unionRoomChat->unkB9[i], gSaveBlock1Ptr->unk3C88[i]);
+ StringCopy(chat->registeredTexts[i], gSaveBlock1Ptr->registeredTexts[i]);
}
-void sub_801DE30(void)
+static void FreeUnionRoomChat(void)
{
- DestroyTask(gUnknown_02022C84->unkE);
- DestroyTask(gUnknown_02022C84->unkF);
- Free(gUnknown_02022C84);
+ DestroyTask(sChat->handleInputTask);
+ DestroyTask(sChat->receiveMessagesTask);
+ Free(sChat);
}
-static void c2_081284E0(void)
+static void CB2_LoadInterface(void)
{
switch (gMain.state)
{
@@ -634,16 +923,16 @@ static void c2_081284E0(void)
ResetTasks();
ResetSpriteData();
FreeAllSpritePalettes();
- sub_801F4D0();
+ TryAllocDisplay();
gMain.state++;
break;
case 1:
- sub_801F5B8();
- if (!sub_801F534())
+ RunDisplaySubtasks();
+ if (!IsDisplaySubtask0Active())
{
BlendPalettes(0xFFFFFFFF, 16, RGB_BLACK);
BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK);
- SetVBlankCallback(sub_801DF20);
+ SetVBlankCallback(VBlankCB_UnionRoomChatMain);
gMain.state++;
}
break;
@@ -651,9 +940,9 @@ static void c2_081284E0(void)
UpdatePaletteFade();
if (!gPaletteFade.active)
{
- SetMainCallback2(sub_801DF38);
- gUnknown_02022C84->unkE = CreateTask(sub_801DF54, 8);
- gUnknown_02022C84->unkF = CreateTask(sub_801F2B4, 7);
+ SetMainCallback2(CB2_UnionRoomChatMain);
+ sChat->handleInputTask = CreateTask(Task_HandlePlayerInput, 8);
+ sChat->receiveMessagesTask = CreateTask(Task_ReceiveChatMessage, 7);
LoadWirelessStatusIndicatorSpriteGfx();
CreateWirelessStatusIndicatorSprite(232, 150);
}
@@ -661,7 +950,7 @@ static void c2_081284E0(void)
}
}
-static void sub_801DF20(void)
+static void VBlankCB_UnionRoomChatMain(void)
{
TransferPlttBuffer();
LoadOam();
@@ -669,146 +958,146 @@ static void sub_801DF20(void)
ScanlineEffect_InitHBlankDmaTransfer();
}
-static void sub_801DF38(void)
+static void CB2_UnionRoomChatMain(void)
{
RunTasks();
- sub_801F5B8();
+ RunDisplaySubtasks();
AnimateSprites();
BuildOamBuffer();
UpdatePaletteFade();
}
-static void sub_801DF54(u8 taskId)
+static void Task_HandlePlayerInput(u8 taskId)
{
- switch (gUnknown_02022C84->unk17)
+ switch (sChat->exitType)
{
- case 1:
- sub_801EBD4(6);
- gUnknown_02022C84->unk17 = 0;
+ case CHAT_EXIT_ONLY_LEADER:
+ SetChatFunction(CHAT_FUNC_EXIT);
+ sChat->exitType = CHAT_EXIT_NONE;
break;
- case 2:
- sub_801EBD4(7);
- gUnknown_02022C84->unk17 = 0;
+ case CHAT_EXIT_DROPPED:
+ SetChatFunction(CHAT_FUNC_DROP);
+ sChat->exitType = CHAT_EXIT_NONE;
break;
- case 3:
- sub_801EBD4(8);
- gUnknown_02022C84->unk17 = 0;
+ case CHAT_EXIT_DISBANDED:
+ SetChatFunction(CHAT_FUNC_DISBANDED);
+ sChat->exitType = CHAT_EXIT_NONE;
break;
}
- gUnknown_082F2A7C[gUnknown_02022C84->unk4]();
+ sChatMainFunctions[sChat->funcId]();
}
-static void sub_801DFAC(void)
+static void Chat_Join(void)
{
- switch (gUnknown_02022C84->unk6)
+ switch (sChat->funcState)
{
case 0:
- sub_801EF24(gUnknown_02022C84->unk190);
- gUnknown_02022C84->unk6++;
+ PrepareSendBuffer_Join(sChat->sendMessageBuffer);
+ sChat->funcState++;
// fall through
case 1:
if (IsLinkTaskFinished() && !sub_8011A9C())
{
- if (SendBlock(0, gUnknown_02022C84->unk190, sizeof(gUnknown_02022C84->unk190)))
- gUnknown_02022C84->unk6++;
+ if (SendBlock(0, sChat->sendMessageBuffer, sizeof(sChat->sendMessageBuffer)))
+ sChat->funcState++;
}
break;
case 2:
if (IsLinkTaskFinished())
- sub_801EBD4(1);
+ SetChatFunction(CHAT_FUNC_HANDLE_INPUT);
break;
}
}
-static void sub_801E030(void)
+static void Chat_HandleInput(void)
{
- bool8 var0, var1;
+ bool8 updateMsgActive, cursorBlinkActive;
- switch (gUnknown_02022C84->unk6)
+ switch (sChat->funcState)
{
case 0:
if (gMain.newKeys & START_BUTTON)
{
- if (gUnknown_02022C84->unk15)
- sub_801EBD4(4);
+ if (sChat->bufferCursorPos)
+ SetChatFunction(CHAT_FUNC_SEND);
}
else if (gMain.newKeys & SELECT_BUTTON)
{
- sub_801EBD4(2);
+ SetChatFunction(CHAT_FUNC_SWITCH);
}
else if (gMain.newAndRepeatedKeys & B_BUTTON)
{
- if (gUnknown_02022C84->unk15)
+ if (sChat->bufferCursorPos)
{
- sub_801ED68();
- sub_801F5EC(8, 0);
- gUnknown_02022C84->unk6 = 1;
+ DeleteLastMessageCharacter();
+ StartDisplaySubtask(CHATDISPLAY_FUNC_UPDATE_MSG, 0);
+ sChat->funcState = 1;
}
else
{
- sub_801EBD4(3);
+ SetChatFunction(CHAT_FUNC_ASK_QUIT);
}
}
else if (gMain.newKeys & A_BUTTON)
{
- sub_801EC94();
- sub_801F5EC(8, 0);
- sub_801F5EC(2, 1);
- gUnknown_02022C84->unk6 = 1;
+ AppendTextToMessage();
+ StartDisplaySubtask(CHATDISPLAY_FUNC_UPDATE_MSG, 0);
+ StartDisplaySubtask(CHATDISPLAY_FUNC_CURSOR_BLINK, 1);
+ sChat->funcState = 1;
}
else if (gMain.newKeys & R_BUTTON)
{
- if (gUnknown_02022C84->currentPage != UNION_ROOM_KB_PAGE_COUNT)
+ if (sChat->currentPage != UNION_ROOM_KB_PAGE_REGISTER)
{
- sub_801ED94();
- sub_801F5EC(8, 0);
- gUnknown_02022C84->unk6 = 1;
+ SwitchCaseOfLastMessageCharacter();
+ StartDisplaySubtask(CHATDISPLAY_FUNC_UPDATE_MSG, 0);
+ sChat->funcState = 1;
}
else
{
- sub_801EBD4(5);
+ SetChatFunction(5);
}
}
- else if (sub_801EBE4())
+ else if (HandleDPadInput())
{
- sub_801F5EC(1, 0);
- gUnknown_02022C84->unk6 = 1;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_MOVE_KB_CURSOR, 0);
+ sChat->funcState = 1;
}
break;
case 1:
- var0 = sub_801F644(0);
- var1 = sub_801F644(1);
- if (!var0 && !var1)
- gUnknown_02022C84->unk6 = 0;
+ updateMsgActive = IsDisplaySubtaskActive(0);
+ cursorBlinkActive = IsDisplaySubtaskActive(1);
+ if (!updateMsgActive && !cursorBlinkActive)
+ sChat->funcState = 0;
break;
}
}
-static void sub_801E120(void)
+static void Chat_Switch(void)
{
s16 input;
- int var0;
+ bool32 shouldSwitchPages;
- switch (gUnknown_02022C84->unk6)
+ switch (sChat->funcState)
{
case 0:
- sub_801F5EC(3, 0);
- gUnknown_02022C84->unk6++;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_SHOW_KB_SWAP_MENU, 0);
+ sChat->funcState++;
break;
case 1:
- if (!sub_801F644(0))
- gUnknown_02022C84->unk6++;
+ if (!IsDisplaySubtaskActive(0))
+ sChat->funcState++;
break;
case 2:
input = Menu_ProcessInput();
switch (input)
{
default:
- sub_801F5EC(4, 0);
- var0 = 1;
- if (gUnknown_02022C84->currentPage == input || input > UNION_ROOM_KB_PAGE_COUNT)
- var0 = 0;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_HIDE_KB_SWAP_MENU, 0);
+ shouldSwitchPages = TRUE;
+ if (sChat->currentPage == input || input > UNION_ROOM_KB_PAGE_REGISTER)
+ shouldSwitchPages = FALSE;
break;
case MENU_NOTHING_CHOSEN:
if (gMain.newKeys & SELECT_BUTTON)
@@ -818,538 +1107,532 @@ static void sub_801E120(void)
}
return;
case MENU_B_PRESSED:
- sub_801F5EC(4, 0);
- gUnknown_02022C84->unk6 = 3;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_HIDE_KB_SWAP_MENU, 0);
+ sChat->funcState = 3;
return;
}
- if (!var0)
+ if (!shouldSwitchPages)
{
- gUnknown_02022C84->unk6 = 3;
+ sChat->funcState = 3;
return;
}
- gUnknown_02022C84->unk11 = 0;
- gUnknown_02022C84->currentRow = 0;
- sub_801F5EC(5, 1);
- gUnknown_02022C84->currentPage = input;
- gUnknown_02022C84->unk6 = 4;
+ sChat->currentCol = 0;
+ sChat->currentRow = 0;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_SWITCH_PAGES, 1);
+ sChat->currentPage = input;
+ sChat->funcState = 4;
break;
case 3:
- if (!sub_801F644(0))
- sub_801EBD4(1);
+ if (!IsDisplaySubtaskActive(0))
+ SetChatFunction(CHAT_FUNC_HANDLE_INPUT);
break;
case 4:
- if (!sub_801F644(0) && !sub_801F644(1))
- sub_801EBD4(1);
+ if (!IsDisplaySubtaskActive(0) && !IsDisplaySubtaskActive(1))
+ SetChatFunction(CHAT_FUNC_HANDLE_INPUT);
break;
}
}
-static void sub_801E240(void)
+static void Chat_AskQuitChatting(void)
{
s8 input;
- switch (gUnknown_02022C84->unk6)
+ switch (sChat->funcState)
{
case 0:
- sub_801F5EC(6, 0);
- gUnknown_02022C84->unk6 = 1;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_ASK_QUIT_CHATTING, 0);
+ sChat->funcState = 1;
break;
case 1:
- if (!sub_801F644(0))
- gUnknown_02022C84->unk6 = 2;
+ if (!IsDisplaySubtaskActive(0))
+ sChat->funcState = 2;
break;
case 2:
- input = sub_801FF08();
+ input = ProcessMenuInput();
switch (input)
{
case -1:
case 1:
- sub_801F5EC(7, 0);
- gUnknown_02022C84->unk6 = 3;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_DESTROY_YESNO, 0);
+ sChat->funcState = 3;
break;
case 0:
- if (gUnknown_02022C84->unk13 == 0)
+ if (sChat->multiplayerId == 0)
{
- sub_801EFD0(gUnknown_02022C84->unk190);
- sub_801F5EC(7, 0);
- gUnknown_02022C84->unk6 = 9;
+ PrepareSendBuffer_Disband(sChat->sendMessageBuffer);
+ StartDisplaySubtask(CHATDISPLAY_FUNC_DESTROY_YESNO, 0);
+ sChat->funcState = 9;
}
else
{
- sub_801EF7C(gUnknown_02022C84->unk190);
- gUnknown_02022C84->unk6 = 4;
+ PrepareSendBuffer_Leave(sChat->sendMessageBuffer);
+ sChat->funcState = 4;
}
break;
}
break;
case 3:
- if (!sub_801F644(0))
- sub_801EBD4(1);
+ if (!IsDisplaySubtaskActive(0))
+ SetChatFunction(CHAT_FUNC_HANDLE_INPUT);
break;
case 9:
- if (!sub_801F644(0))
+ if (!IsDisplaySubtaskActive(0))
{
- sub_801F5EC(20, 0);
- gUnknown_02022C84->unk6 = 10;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_ASK_CONFIRM_LEADER_LEAVE, 0);
+ sChat->funcState = 10;
}
break;
case 10:
- if (!sub_801F644(0))
- gUnknown_02022C84->unk6 = 8;
+ if (!IsDisplaySubtaskActive(0))
+ sChat->funcState = 8;
break;
case 8:
- input = sub_801FF08();
+ input = ProcessMenuInput();
switch (input)
{
case -1:
case 1:
- sub_801F5EC(7, 0);
- gUnknown_02022C84->unk6 = 3;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_DESTROY_YESNO, 0);
+ sChat->funcState = 3;
break;
case 0:
sub_80104B0();
- sub_801EFD0(gUnknown_02022C84->unk190);
- gUnknown_02022C84->unk6 = 4;
- gUnknown_02022C84->unk1B8 = 0;
+ PrepareSendBuffer_Disband(sChat->sendMessageBuffer);
+ sChat->funcState = 4;
+ sChat->tryQuitAgainTimer = 0;
break;
}
break;
case 4:
- if (IsLinkTaskFinished() && !sub_8011A9C() && SendBlock(0, gUnknown_02022C84->unk190, sizeof(gUnknown_02022C84->unk190)))
+ if (IsLinkTaskFinished() && !sub_8011A9C() && SendBlock(0, sChat->sendMessageBuffer, sizeof(sChat->sendMessageBuffer)))
{
- if (!gUnknown_02022C84->unk13)
- gUnknown_02022C84->unk6 = 6;
+ if (!sChat->multiplayerId)
+ sChat->funcState = 6;
else
- gUnknown_02022C84->unk6 = 5;
+ sChat->funcState = 5;
}
if (!gReceivedRemoteLinkPlayers)
- sub_801EBD4(9);
+ SetChatFunction(CHAT_FUNC_SAVE_AND_EXIT);
break;
case 5:
if (!gReceivedRemoteLinkPlayers)
{
- sub_801EBD4(9);
+ SetChatFunction(CHAT_FUNC_SAVE_AND_EXIT);
}
- else if (++gUnknown_02022C84->unk1B8 > 300)
+ else if (++sChat->tryQuitAgainTimer > 300)
{
- gUnknown_02022C84->unk1B8 = 0;
- gUnknown_02022C84->unk6 = 4;
+ sChat->tryQuitAgainTimer = 0;
+ sChat->funcState = 4;
}
break;
}
}
-static void sub_801E460(void)
+static void Chat_Exit(void)
{
- switch (gUnknown_02022C84->unk6)
+ switch (sChat->funcState)
{
case 0:
- if (!FuncIsActiveTask(sub_801F2B4))
+ if (!FuncIsActiveTask(Task_ReceiveChatMessage))
{
- sub_801F5EC(7, 0);
- gUnknown_02022C84->unk6++;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_DESTROY_YESNO, 0);
+ sChat->funcState++;
}
break;
case 1:
- if (!sub_801F644(0))
+ if (!IsDisplaySubtaskActive(0))
{
- sub_801F5EC(18, 0);
- gUnknown_02022C84->unk6++;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_PRINT_EXITING_CHAT, 0);
+ sChat->funcState++;
}
break;
case 2:
- if (!sub_801F644(0))
+ if (!IsDisplaySubtaskActive(0))
{
- sub_801EFA8(gUnknown_02022C84->unk190);
- gUnknown_02022C84->unk6++;
+ PrepareSendBuffer_Drop(sChat->sendMessageBuffer);
+ sChat->funcState++;
}
break;
case 3:
- if (IsLinkTaskFinished() && !sub_8011A9C() && SendBlock(0, gUnknown_02022C84->unk190, sizeof(gUnknown_02022C84->unk190)))
- gUnknown_02022C84->unk6++;
+ if (IsLinkTaskFinished() && !sub_8011A9C() && SendBlock(0, sChat->sendMessageBuffer, sizeof(sChat->sendMessageBuffer)))
+ sChat->funcState++;
break;
case 4:
if ((GetBlockReceivedStatus() & 1) && !sub_8011A9C())
- gUnknown_02022C84->unk6++;
+ sChat->funcState++;
break;
case 5:
if (IsLinkTaskFinished() && !sub_8011A9C())
{
sub_800AC34();
- gUnknown_02022C84->unkA = 0;
- gUnknown_02022C84->unk6++;
+ sChat->exitDelayTimer = 0;
+ sChat->funcState++;
}
break;
case 6:
- if (gUnknown_02022C84->unkA < 150)
- gUnknown_02022C84->unkA++;
+ if (sChat->exitDelayTimer < 150)
+ sChat->exitDelayTimer++;
if (!gReceivedRemoteLinkPlayers)
- gUnknown_02022C84->unk6++;
+ sChat->funcState++;
break;
case 7:
- if (gUnknown_02022C84->unkA >= 150)
- sub_801EBD4(9);
+ if (sChat->exitDelayTimer >= 150)
+ SetChatFunction(CHAT_FUNC_SAVE_AND_EXIT);
else
- gUnknown_02022C84->unkA++;
+ sChat->exitDelayTimer++;
break;
}
}
-static void sub_801E5C4(void)
+static void Chat_Drop(void)
{
- switch (gUnknown_02022C84->unk6)
+ switch (sChat->funcState)
{
case 0:
- if (!FuncIsActiveTask(sub_801F2B4))
+ if (!FuncIsActiveTask(Task_ReceiveChatMessage))
{
- sub_801F5EC(7, 0);
- gUnknown_02022C84->unk6++;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_DESTROY_YESNO, 0);
+ sChat->funcState++;
}
break;
case 1:
- if (!sub_801F644(0) && IsLinkTaskFinished() && !sub_8011A9C())
+ if (!IsDisplaySubtaskActive(0) && IsLinkTaskFinished() && !sub_8011A9C())
{
sub_800AC34();
- gUnknown_02022C84->unkA = 0;
- gUnknown_02022C84->unk6++;
+ sChat->exitDelayTimer = 0;
+ sChat->funcState++;
}
break;
case 2:
- if (gUnknown_02022C84->unkA < 150)
- gUnknown_02022C84->unkA++;
+ if (sChat->exitDelayTimer < 150)
+ sChat->exitDelayTimer++;
if (!gReceivedRemoteLinkPlayers)
- gUnknown_02022C84->unk6++;
+ sChat->funcState++;
break;
case 3:
- if (gUnknown_02022C84->unkA >= 150)
- sub_801EBD4(9);
+ if (sChat->exitDelayTimer >= 150)
+ SetChatFunction(CHAT_FUNC_SAVE_AND_EXIT);
else
- gUnknown_02022C84->unkA++;
+ sChat->exitDelayTimer++;
break;
}
}
-static void sub_801E668(void)
+static void Chat_Disbanded(void)
{
- switch (gUnknown_02022C84->unk6)
+ switch (sChat->funcState)
{
case 0:
- if (!FuncIsActiveTask(sub_801F2B4))
+ if (!FuncIsActiveTask(Task_ReceiveChatMessage))
{
- if (gUnknown_02022C84->unk13)
- sub_801F5EC(7, 0);
+ if (sChat->multiplayerId)
+ StartDisplaySubtask(CHATDISPLAY_FUNC_DESTROY_YESNO, 0);
- gUnknown_02022C84->unk6++;
+ sChat->funcState++;
}
break;
case 1:
- if (!sub_801F644(0))
+ if (!IsDisplaySubtaskActive(0))
{
- if (gUnknown_02022C84->unk13)
- sub_801F5EC(19, 0);
+ if (sChat->multiplayerId)
+ StartDisplaySubtask(CHATDISPLAY_FUNC_PRINT_LEADER_LEFT, 0);
- gUnknown_02022C84->unk6++;
+ sChat->funcState++;
}
break;
case 2:
- if (sub_801F644(0) != TRUE && IsLinkTaskFinished() && !sub_8011A9C())
+ if (IsDisplaySubtaskActive(0) != TRUE && IsLinkTaskFinished() && !sub_8011A9C())
{
sub_800AC34();
- gUnknown_02022C84->unkA = 0;
- gUnknown_02022C84->unk6++;
+ sChat->exitDelayTimer = 0;
+ sChat->funcState++;
}
break;
case 3:
- if (gUnknown_02022C84->unkA < 150)
- gUnknown_02022C84->unkA++;
+ if (sChat->exitDelayTimer < 150)
+ sChat->exitDelayTimer++;
if (!gReceivedRemoteLinkPlayers)
- gUnknown_02022C84->unk6++;
+ sChat->funcState++;
break;
case 4:
- if (gUnknown_02022C84->unkA >= 150)
- sub_801EBD4(9);
+ if (sChat->exitDelayTimer >= 150)
+ SetChatFunction(CHAT_FUNC_SAVE_AND_EXIT);
else
- gUnknown_02022C84->unkA++;
+ sChat->exitDelayTimer++;
break;
}
}
-static void sub_801E764(void)
+static void Chat_SendMessage(void)
{
- switch (gUnknown_02022C84->unk6)
+ switch (sChat->funcState)
{
case 0:
if (!gReceivedRemoteLinkPlayers)
{
- sub_801EBD4(1);
+ SetChatFunction(CHAT_FUNC_HANDLE_INPUT);
break;
}
- sub_801EF4C(gUnknown_02022C84->unk190);
- gUnknown_02022C84->unk6++;
+ PrepareSendBuffer_Chat(sChat->sendMessageBuffer);
+ sChat->funcState++;
// fall through
case 1:
- if (IsLinkTaskFinished() == TRUE && !sub_8011A9C() && SendBlock(0, gUnknown_02022C84->unk190, sizeof(gUnknown_02022C84->unk190)))
- gUnknown_02022C84->unk6++;
+ if (IsLinkTaskFinished() == TRUE && !sub_8011A9C() && SendBlock(0, sChat->sendMessageBuffer, sizeof(sChat->sendMessageBuffer)))
+ sChat->funcState++;
break;
case 2:
- sub_801EE10();
- sub_801F5EC(8, 0);
- gUnknown_02022C84->unk6++;
+ ResetMessageEntryBuffer();
+ StartDisplaySubtask(CHATDISPLAY_FUNC_UPDATE_MSG, 0);
+ sChat->funcState++;
break;
case 3:
- if (!sub_801F644(0))
- gUnknown_02022C84->unk6++;
+ if (!IsDisplaySubtaskActive(0))
+ sChat->funcState++;
break;
case 4:
if (IsLinkTaskFinished())
- sub_801EBD4(1);
+ SetChatFunction(CHAT_FUNC_HANDLE_INPUT);
break;
}
}
-static void sub_801E838(void)
+static void Chat_Register(void)
{
- switch (gUnknown_02022C84->unk6)
+ switch (sChat->funcState)
{
case 0:
- if (sub_801EDC4())
+ if (ChatMessageIsNotEmpty())
{
- sub_801F5EC(9, 0);
- gUnknown_02022C84->unk6 = 2;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_ASK_REGISTER_TEXT, 0);
+ sChat->funcState = 2;
}
else
{
- sub_801F5EC(13, 0);
- gUnknown_02022C84->unk6 = 5;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_PRINT_INPUT_TEXT, 0);
+ sChat->funcState = 5;
}
break;
case 1:
if (gMain.newKeys & A_BUTTON)
{
- sub_801EDE0();
- sub_801F5EC(11, 0);
- gUnknown_02022C84->unk6 = 3;
+ RegisterTextAtRow();
+ StartDisplaySubtask(CHATDISPLAY_FUNC_RETURN_TO_KB, 0);
+ sChat->funcState = 3;
}
else if (gMain.newKeys & B_BUTTON)
{
- sub_801F5EC(10, 0);
- gUnknown_02022C84->unk6 = 4;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_CANCEL_REGISTER, 0);
+ sChat->funcState = 4;
}
- else if (sub_801EBE4())
+ else if (HandleDPadInput())
{
- sub_801F5EC(1, 0);
- gUnknown_02022C84->unk6 = 2;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_MOVE_KB_CURSOR, 0);
+ sChat->funcState = 2;
}
break;
case 2:
- if (!sub_801F644(0))
- gUnknown_02022C84->unk6 = 1;
+ if (!IsDisplaySubtaskActive(0))
+ sChat->funcState = 1;
break;
case 3:
- if (!sub_801F644(0))
+ if (!IsDisplaySubtaskActive(0))
{
- sub_801F5EC(10, 0);
- gUnknown_02022C84->unk6 = 4;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_CANCEL_REGISTER, 0);
+ sChat->funcState = 4;
}
break;
case 4:
- if (!sub_801F644(0))
- sub_801EBD4(1);
+ if (!IsDisplaySubtaskActive(0))
+ SetChatFunction(CHAT_FUNC_HANDLE_INPUT);
break;
case 5:
- if (!sub_801F644(0))
- gUnknown_02022C84->unk6 = 6;
+ if (!IsDisplaySubtaskActive(0))
+ sChat->funcState = 6;
break;
case 6:
if (gMain.newKeys & (A_BUTTON | B_BUTTON))
{
- sub_801F5EC(7, 0);
- gUnknown_02022C84->unk6 = 4;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_DESTROY_YESNO, 0);
+ sChat->funcState = 4;
}
break;
}
}
-static void sub_801E978(void)
+static void Chat_SaveAndExit(void)
{
s8 input;
- switch (gUnknown_02022C84->unk6)
+ switch (sChat->funcState)
{
case 0:
- if (!gUnknown_02022C84->unk18)
+ if (!sChat->changedRegisteredTexts)
{
- gUnknown_02022C84->unk6 = 12;
+ sChat->funcState = 12;
}
else
{
- sub_801F5EC(7, 0);
- gUnknown_02022C84->unk6 = 1;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_DESTROY_YESNO, 0);
+ sChat->funcState = 1;
}
break;
case 1:
- if (!sub_801F644(0))
+ if (!IsDisplaySubtaskActive(0))
{
- sub_801F5EC(14, 0);
- gUnknown_02022C84->unk6 = 2;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_ASK_SAVE, 0);
+ sChat->funcState = 2;
}
break;
case 2:
- input = sub_801FF08();
+ input = ProcessMenuInput();
switch (input)
{
case -1:
case 1:
- gUnknown_02022C84->unk6 = 12;
+ sChat->funcState = 12;
break;
case 0:
- sub_801F5EC(7, 0);
- gUnknown_02022C84->unk6 = 3;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_DESTROY_YESNO, 0);
+ sChat->funcState = 3;
break;
}
break;
case 3:
- if (!sub_801F644(0))
+ if (!IsDisplaySubtaskActive(0))
{
- sub_801F5EC(15, 0);
- gUnknown_02022C84->unk6 = 4;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_ASK_OVERWRITE_SAVE, 0);
+ sChat->funcState = 4;
}
break;
case 4:
- if (!sub_801F644(0))
- gUnknown_02022C84->unk6 = 5;
+ if (!IsDisplaySubtaskActive(0))
+ sChat->funcState = 5;
break;
case 5:
- input = sub_801FF08();
+ input = ProcessMenuInput();
switch (input)
{
case -1:
case 1:
- gUnknown_02022C84->unk6 = 12;
+ sChat->funcState = 12;
break;
case 0:
- sub_801F5EC(7, 0);
- gUnknown_02022C84->unk6 = 6;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_DESTROY_YESNO, 0);
+ sChat->funcState = 6;
break;
}
break;
case 6:
- if (!sub_801F644(0))
+ if (!IsDisplaySubtaskActive(0))
{
- sub_801F5EC(16, 0);
- sub_801EE2C();
- gUnknown_02022C84->unk6 = 7;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_PRINT_SAVING, 0);
+ SaveRegisteredTexts();
+ sChat->funcState = 7;
}
break;
case 7:
- if (!sub_801F644(0))
+ if (!IsDisplaySubtaskActive(0))
{
SetContinueGameWarpStatusToDynamicWarp();
TrySavingData(SAVE_NORMAL);
- gUnknown_02022C84->unk6 = 8;
+ sChat->funcState = 8;
}
break;
case 8:
- sub_801F5EC(17, 0);
- gUnknown_02022C84->unk6 = 9;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_PRINT_SAVED_GAME, 0);
+ sChat->funcState = 9;
break;
case 9:
- if (!sub_801F644(0))
+ if (!IsDisplaySubtaskActive(0))
{
PlaySE(SE_SAVE);
ClearContinueGameWarpStatus2();
- gUnknown_02022C84->unk6 = 10;
+ sChat->funcState = 10;
}
break;
case 10:
- gUnknown_02022C84->unk19 = 0;
- gUnknown_02022C84->unk6 = 11;
+ sChat->afterSaveTimer = 0;
+ sChat->funcState = 11;
break;
case 11:
- gUnknown_02022C84->unk19++;
- if (gUnknown_02022C84->unk19 > 120)
- gUnknown_02022C84->unk6 = 12;
+ sChat->afterSaveTimer++;
+ if (sChat->afterSaveTimer > 120)
+ sChat->funcState = 12;
break;
case 12:
BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK);
- gUnknown_02022C84->unk6 = 13;
+ sChat->funcState = 13;
break;
case 13:
if (!gPaletteFade.active)
{
- sub_801F544();
- sub_801DE30();
+ FreeDisplay();
+ FreeUnionRoomChat();
SetMainCallback2(CB2_ReturnToField);
}
break;
}
}
-static void sub_801EBD4(u16 arg0)
+static void SetChatFunction(u16 funcId)
{
- gUnknown_02022C84->unk4 = arg0;
- gUnknown_02022C84->unk6 = 0;
+ sChat->funcId = funcId;
+ sChat->funcState = 0;
}
-static bool32 sub_801EBE4(void)
+static bool32 HandleDPadInput(void)
{
- if (!(gMain.newAndRepeatedKeys & DPAD_UP))
+ do
{
+ if (gMain.newAndRepeatedKeys & DPAD_UP)
+ {
+ if (sChat->currentRow > 0)
+ sChat->currentRow--;
+ else
+ sChat->currentRow = sKeyboardPageMaxRow[sChat->currentPage];
+ break;
+ }
if (gMain.newAndRepeatedKeys & DPAD_DOWN)
{
- if (gUnknown_02022C84->currentRow < sKeyboardPageMaxRow[gUnknown_02022C84->currentPage])
- gUnknown_02022C84->currentRow++;
+ if (sChat->currentRow < sKeyboardPageMaxRow[sChat->currentPage])
+ sChat->currentRow++;
else
- gUnknown_02022C84->currentRow = 0;
-
- return TRUE;
+ sChat->currentRow = 0;
+ break;
}
-
- if (gUnknown_02022C84->currentPage != UNION_ROOM_KB_PAGE_COUNT)
+ if (sChat->currentPage != UNION_ROOM_KB_PAGE_REGISTER)
{
if (gMain.newAndRepeatedKeys & DPAD_LEFT)
{
- if (gUnknown_02022C84->unk11)
- gUnknown_02022C84->unk11--;
+ if (sChat->currentCol > 0)
+ sChat->currentCol--;
else
- gUnknown_02022C84->unk11 = 4;
+ sChat->currentCol = 4;
+ break;
}
else if (gMain.newAndRepeatedKeys & DPAD_RIGHT)
{
- if (gUnknown_02022C84->unk11 > 3)
- gUnknown_02022C84->unk11 = 0;
+ if (sChat->currentCol < 4)
+ sChat->currentCol++;
else
- gUnknown_02022C84->unk11++;
+ sChat->currentCol = 0;
+ break;
}
- else
- {
- return FALSE;
- }
-
- return TRUE;
}
-
return FALSE;
- }
- else
- {
- if (gUnknown_02022C84->currentRow)
- gUnknown_02022C84->currentRow--;
- else
- gUnknown_02022C84->currentRow = sKeyboardPageMaxRow[gUnknown_02022C84->currentPage];
+ } while (0);
- return TRUE;
- }
+ return TRUE;
}
-static void sub_801EC94(void)
+static void AppendTextToMessage(void)
{
int i;
const u8 *charsStr;
@@ -1357,10 +1640,11 @@ static void sub_801EC94(void)
u8 *str;
u8 buffer[21];
- if (gUnknown_02022C84->currentPage != UNION_ROOM_KB_PAGE_COUNT)
+ if (sChat->currentPage != UNION_ROOM_KB_PAGE_REGISTER)
{
- charsStr = sUnionRoomKeyboardText[gUnknown_02022C84->currentPage][gUnknown_02022C84->currentRow];
- for (i = 0; i < gUnknown_02022C84->unk11; i++)
+ // Going to append a single character
+ charsStr = sUnionRoomKeyboardText[sChat->currentPage][sChat->currentRow];
+ for (i = 0; i < sChat->currentCol; i++)
{
if (*charsStr == CHAR_SPECIAL_F9)
charsStr++;
@@ -1371,19 +1655,20 @@ static void sub_801EC94(void)
}
else
{
- u8 *tempStr = StringCopy(buffer, gUnknown_02022C84->unkB9[gUnknown_02022C84->currentRow]);
+ // Going to append registered text string
+ u8 *tempStr = StringCopy(buffer, sChat->registeredTexts[sChat->currentRow]);
tempStr[0] = CHAR_SPACE;
tempStr[1] = EOS;
charsStr = buffer;
strLength = StringLength_Multibyte(buffer);
}
- gUnknown_02022C84->unk14 = gUnknown_02022C84->unk15;
+ sChat->lastBufferCursorPos = sChat->bufferCursorPos;
if (!charsStr)
return;
- str = sub_801EE84();
- while (--strLength != -1 && gUnknown_02022C84->unk15 < 15)
+ str = GetEndOfMessagePtr();
+ while (--strLength != -1 && sChat->bufferCursorPos < MAX_MESSAGE_LENGTH)
{
if (*charsStr == CHAR_SPECIAL_F9)
{
@@ -1396,103 +1681,103 @@ static void sub_801EC94(void)
charsStr++;
str++;
- gUnknown_02022C84->unk15++;
+ sChat->bufferCursorPos++;
}
*str = EOS;
}
-static void sub_801ED68(void)
+static void DeleteLastMessageCharacter(void)
{
- gUnknown_02022C84->unk14 = gUnknown_02022C84->unk15;
- if (gUnknown_02022C84->unk15)
+ sChat->lastBufferCursorPos = sChat->bufferCursorPos;
+ if (sChat->bufferCursorPos)
{
- u8 *str = sub_801EEA8();
+ u8 *str = GetLastCharOfMessagePtr();
*str = EOS;
- gUnknown_02022C84->unk15--;
+ sChat->bufferCursorPos--;
}
}
-static void sub_801ED94(void)
+static void SwitchCaseOfLastMessageCharacter(void)
{
u8 *str;
u8 character;
- gUnknown_02022C84->unk14 = gUnknown_02022C84->unk15 - 1;
- str = sub_801EEA8();
+ sChat->lastBufferCursorPos = sChat->bufferCursorPos - 1;
+ str = GetLastCharOfMessagePtr();
if (*str != CHAR_SPECIAL_F9)
{
- character = gUnknown_082F2AA8[*str];
+ character = sCaseToggleTable[*str];
if (character)
*str = character;
}
}
-static bool32 sub_801EDC4(void)
+static bool32 ChatMessageIsNotEmpty(void)
{
- if (gUnknown_02022C84->unk15)
+ if (sChat->bufferCursorPos)
return TRUE;
else
return FALSE;
}
-static void sub_801EDE0(void)
+static void RegisterTextAtRow(void)
{
- u8 *src = sub_801F114();
- StringCopy(gUnknown_02022C84->unkB9[gUnknown_02022C84->currentRow], src);
- gUnknown_02022C84->unk18 = 1;
+ u8 *src = GetLimitedMessageStartPtr();
+ StringCopy(sChat->registeredTexts[sChat->currentRow], src);
+ sChat->changedRegisteredTexts = TRUE;
}
-static void sub_801EE10(void)
+static void ResetMessageEntryBuffer(void)
{
- gUnknown_02022C84->unk1A[0] = EOS;
- gUnknown_02022C84->unk14 = 15;
- gUnknown_02022C84->unk15 = 0;
+ sChat->messageEntryBuffer[0] = EOS;
+ sChat->lastBufferCursorPos = 15;
+ sChat->bufferCursorPos = 0;
}
-static void sub_801EE2C(void)
+static void SaveRegisteredTexts(void)
{
int i;
for (i = 0; i < UNION_ROOM_KB_ROW_COUNT; i++)
- StringCopy(gSaveBlock1Ptr->unk3C88[i], gUnknown_02022C84->unkB9[i]);
+ StringCopy(gSaveBlock1Ptr->registeredTexts[i], sChat->registeredTexts[i]);
}
-static u8 *sub_801EE6C(int arg0)
+static u8 *GetRegisteredTextByRow(int row)
{
- return gUnknown_02022C84->unkB9[arg0];
+ return sChat->registeredTexts[row];
}
-static u8 *sub_801EE84(void)
+static u8 *GetEndOfMessagePtr(void)
{
- u8 *str = gUnknown_02022C84->unk1A;
+ u8 *str = sChat->messageEntryBuffer;
while (*str != EOS)
str++;
return str;
}
-static u8 *sub_801EEA8(void)
+static u8 *GetLastCharOfMessagePtr(void)
{
- u8 *str = gUnknown_02022C84->unk1A;
- u8 *str2 = str;
- while (*str != EOS)
+ u8 *currChar = sChat->messageEntryBuffer;
+ u8 *lastChar = currChar;
+ while (*currChar != EOS)
{
- str2 = str;
- if (*str == CHAR_SPECIAL_F9)
- str++;
- str++;
+ lastChar = currChar;
+ if (*currChar == CHAR_SPECIAL_F9)
+ currChar++;
+ currChar++;
}
- return str2;
+ return lastChar;
}
-static u16 sub_801EED8(void)
+static u16 GetNumOverflowCharsInMessage(void)
{
u8 *str;
u32 i, numChars, strLength;
- strLength = StringLength_Multibyte(gUnknown_02022C84->unk1A);
- str = gUnknown_02022C84->unk1A;
+ strLength = StringLength_Multibyte(sChat->messageEntryBuffer);
+ str = sChat->messageEntryBuffer;
numChars = 0;
if (strLength > 10)
{
@@ -1510,83 +1795,83 @@ static u16 sub_801EED8(void)
return numChars;
}
-static void sub_801EF1C(u8 *arg0)
+static void PrepareSendBuffer_Null(u8 *buffer)
{
- arg0[0] = CHAR_SPACE;
+ buffer[0] = CHAT_MESSAGE_NONE;
}
-static void sub_801EF24(u8 *arg0)
+static void PrepareSendBuffer_Join(u8 *buffer)
{
- arg0[0] = 2;
- StringCopy(&arg0[1], gSaveBlock2Ptr->playerName);
- arg0[1 + (PLAYER_NAME_LENGTH + 1)] = gUnknown_02022C84->unk13;
+ buffer[0] = CHAT_MESSAGE_JOIN;
+ StringCopy(&buffer[1], gSaveBlock2Ptr->playerName);
+ buffer[1 + (PLAYER_NAME_LENGTH + 1)] = sChat->multiplayerId;
}
-static void sub_801EF4C(u8 *arg0)
+static void PrepareSendBuffer_Chat(u8 *buffer)
{
- arg0[0] = 1;
- StringCopy(&arg0[1], gSaveBlock2Ptr->playerName);
- StringCopy(&arg0[1 + (PLAYER_NAME_LENGTH + 1)], gUnknown_02022C84->unk1A);
+ buffer[0] = CHAT_MESSAGE_CHAT;
+ StringCopy(&buffer[1], gSaveBlock2Ptr->playerName);
+ StringCopy(&buffer[1 + (PLAYER_NAME_LENGTH + 1)], sChat->messageEntryBuffer);
}
-static void sub_801EF7C(u8 *arg0)
+static void PrepareSendBuffer_Leave(u8 *buffer)
{
- arg0[0] = 3;
- StringCopy(&arg0[1], gSaveBlock2Ptr->playerName);
- arg0[1 + (PLAYER_NAME_LENGTH + 1)] = gUnknown_02022C84->unk13;
+ buffer[0] = CHAT_MESSAGE_LEAVE;
+ StringCopy(&buffer[1], gSaveBlock2Ptr->playerName);
+ buffer[1 + (PLAYER_NAME_LENGTH + 1)] = sChat->multiplayerId;
sub_8011A50();
}
-static void sub_801EFA8(u8 *arg0)
+static void PrepareSendBuffer_Drop(u8 *buffer)
{
- arg0[0] = 4;
- StringCopy(&arg0[1], gSaveBlock2Ptr->playerName);
- arg0[1 + (PLAYER_NAME_LENGTH + 1)] = gUnknown_02022C84->unk13;
+ buffer[0] = CHAT_MESSAGE_DROP;
+ StringCopy(&buffer[1], gSaveBlock2Ptr->playerName);
+ buffer[1 + (PLAYER_NAME_LENGTH + 1)] = sChat->multiplayerId;
}
-static void sub_801EFD0(u8 *arg0)
+static void PrepareSendBuffer_Disband(u8 *buffer)
{
- arg0[0] = 5;
- StringCopy(&arg0[1], gSaveBlock2Ptr->playerName);
- arg0[1 + (PLAYER_NAME_LENGTH + 1)] = gUnknown_02022C84->unk13;
+ buffer[0] = CHAT_MESSAGE_DISBAND;
+ StringCopy(&buffer[1], gSaveBlock2Ptr->playerName);
+ buffer[1 + (PLAYER_NAME_LENGTH + 1)] = sChat->multiplayerId;
}
-static bool32 sub_801EFF8(u8 *arg0, u8 *arg1)
+static bool32 ProcessReceivedChatMessage(u8 *dest, u8 *recvMessage)
{
u8 *tempStr;
- u8 var0 = *arg1;
- u8 *str = arg1 + 1;
- arg1 = str;
- arg1 += 8;
+ u8 cmd = *recvMessage;
+ u8 *name = recvMessage + 1;
+ recvMessage = name;
+ recvMessage += PLAYER_NAME_LENGTH + 1;
- switch (var0)
+ switch (cmd)
{
- case 2:
- if (gUnknown_02022C84->unk13 != str[8])
+ case CHAT_MESSAGE_JOIN:
+ if (sChat->multiplayerId != name[PLAYER_NAME_LENGTH + 1])
{
DynamicPlaceholderTextUtil_Reset();
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, str);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(arg0, gText_F700JoinedChat);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, name);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(dest, gText_F700JoinedChat);
return TRUE;
}
break;
- case 1:
- tempStr = StringCopy(arg0, str);
+ case CHAT_MESSAGE_CHAT:
+ tempStr = StringCopy(dest, name);
*(tempStr++) = EXT_CTRL_CODE_BEGIN;
*(tempStr++) = EXT_CTRL_CODE_CLEAR_TO;
*(tempStr++) = 42;
*(tempStr++) = CHAR_COLON;
- StringCopy(tempStr, arg1);
+ StringCopy(tempStr, recvMessage);
return TRUE;
- case 5:
- StringCopy(gUnknown_02022C84->unk79, str);
+ case CHAT_MESSAGE_DISBAND:
+ StringCopy(sChat->hostName, name);
// fall through
- case 3:
- if (gUnknown_02022C84->unk13 != *arg1)
+ case CHAT_MESSAGE_LEAVE:
+ if (sChat->multiplayerId != *recvMessage)
{
DynamicPlaceholderTextUtil_Reset();
- DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, str);
- DynamicPlaceholderTextUtil_ExpandPlaceholders(arg0, gText_F700LeftChat);
+ DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, name);
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(dest, gText_F700LeftChat);
return TRUE;
}
break;
@@ -1597,47 +1882,47 @@ static bool32 sub_801EFF8(u8 *arg0, u8 *arg1)
static u8 GetCurrentKeyboardPage(void)
{
- return gUnknown_02022C84->currentPage;
+ return sChat->currentPage;
}
-static void sub_801F0BC(u8 *arg0, u8 *arg1)
+static void GetCurrentKeyboardColAndRow(u8 *col, u8 *row)
{
- *arg0 = gUnknown_02022C84->unk11;
- *arg1 = gUnknown_02022C84->currentRow;
+ *col = sChat->currentCol;
+ *row = sChat->currentRow;
}
-static u8 *sub_801F0D0(void)
+static u8 *GetMessageEntryBuffer(void)
{
- return gUnknown_02022C84->unk1A;
+ return sChat->messageEntryBuffer;
}
-static int sub_801F0DC(void)
+static int GetLengthOfMessageEntry(void)
{
- u8 *str = sub_801F0D0();
+ u8 *str = GetMessageEntryBuffer();
return StringLength_Multibyte(str);
}
-static void sub_801F0EC(u32 *arg0, u32 *arg1)
+static void GetBufferSelectionRegion(u32 *x, u32 *width)
{
- int diff = gUnknown_02022C84->unk15 - gUnknown_02022C84->unk14;
+ int diff = sChat->bufferCursorPos - sChat->lastBufferCursorPos;
if (diff < 0)
{
diff *= -1;
- *arg0 = gUnknown_02022C84->unk15;
+ *x = sChat->bufferCursorPos;
}
else
{
- *arg0 = gUnknown_02022C84->unk14;
+ *x = sChat->lastBufferCursorPos;
}
- *arg1 = diff;
+ *width = diff;
}
-static u8 *sub_801F114(void)
+static u8 *GetLimitedMessageStartPtr(void)
{
int i;
- u16 numChars = sub_801EED8();
- u8 *str = gUnknown_02022C84->unk1A;
+ u16 numChars = GetNumOverflowCharsInMessage();
+ u8 *str = sChat->messageEntryBuffer;
for (i = 0; i < numChars; i++)
{
if (*str == CHAR_SPECIAL_F9)
@@ -1649,12 +1934,12 @@ static u8 *sub_801F114(void)
return str;
}
-static u16 sub_801F144(void)
+static u16 GetLimitedMessageStartPos(void)
{
u16 count;
u32 i;
- u16 numChars = sub_801EED8();
- u8 *str = gUnknown_02022C84->unk1A;
+ u16 numChars = GetNumOverflowCharsInMessage();
+ u8 *str = sChat->messageEntryBuffer;
for (count = 0, i = 0; i < numChars; count++, i++)
{
if (*str == CHAR_SPECIAL_F9)
@@ -1666,56 +1951,63 @@ static u16 sub_801F144(void)
return count;
}
-static u8 *sub_801F180(void)
+static u8 *GetLastReceivedMessage(void)
{
- return gUnknown_02022C84->unk39;
+ return sChat->receivedMessage;
}
-static u8 sub_801F18C(void)
+static u8 GetReceivedPlayerIndex(void)
{
- return gUnknown_02022C84->unk16;
+ return sChat->receivedPlayerIndex;
}
-static int sub_801F198(void)
+static int GetTextEntryCursorPosition(void)
{
- return gUnknown_02022C84->unk15;
+ return sChat->bufferCursorPos;
}
-static int sub_801F1A4(void)
+static int GetShouldShowCaseToggleIcon(void)
{
- u8 *str = sub_801EEA8();
+ u8 *str = GetLastCharOfMessagePtr();
u32 character = *str;
- if (character > 0xFF || gUnknown_082F2AA8[character] == character || gUnknown_082F2AA8[character] == 0)
+ if (character > 0xFF || sCaseToggleTable[character] == character || sCaseToggleTable[character] == 0)
return 3;
else
return 0;
}
-static u8 *sub_801F1D0(void)
+static u8 *GetChatHostName(void)
{
- return gUnknown_02022C84->unk79;
+ return sChat->hostName;
}
-void copy_strings_to_sav1(void)
+void InitUnionRoomChatRegisteredTexts(void)
{
- StringCopy(gSaveBlock1Ptr->unk3C88[0], gText_Hello);
- StringCopy(gSaveBlock1Ptr->unk3C88[1], gText_Pokemon2);
- StringCopy(gSaveBlock1Ptr->unk3C88[2], gText_Trade);
- StringCopy(gSaveBlock1Ptr->unk3C88[3], gText_Battle);
- StringCopy(gSaveBlock1Ptr->unk3C88[4], gText_Lets);
- StringCopy(gSaveBlock1Ptr->unk3C88[5], gText_Ok);
- StringCopy(gSaveBlock1Ptr->unk3C88[6], gText_Sorry);
- StringCopy(gSaveBlock1Ptr->unk3C88[7], gText_YaySmileEmoji);
- StringCopy(gSaveBlock1Ptr->unk3C88[8], gText_ThankYou);
- StringCopy(gSaveBlock1Ptr->unk3C88[9], gText_ByeBye);
+ StringCopy(gSaveBlock1Ptr->registeredTexts[0], gText_Hello);
+ StringCopy(gSaveBlock1Ptr->registeredTexts[1], gText_Pokemon2);
+ StringCopy(gSaveBlock1Ptr->registeredTexts[2], gText_Trade);
+ StringCopy(gSaveBlock1Ptr->registeredTexts[3], gText_Battle);
+ StringCopy(gSaveBlock1Ptr->registeredTexts[4], gText_Lets);
+ StringCopy(gSaveBlock1Ptr->registeredTexts[5], gText_Ok);
+ StringCopy(gSaveBlock1Ptr->registeredTexts[6], gText_Sorry);
+ StringCopy(gSaveBlock1Ptr->registeredTexts[7], gText_YaySmileEmoji);
+ StringCopy(gSaveBlock1Ptr->registeredTexts[8], gText_ThankYou);
+ StringCopy(gSaveBlock1Ptr->registeredTexts[9], gText_ByeBye);
}
-static void sub_801F2B4(u8 taskId)
+#define tState data[0]
+#define tI data[1]
+#define tCurrLinkPlayer data[2]
+#define tBlockReceivedStatus data[3]
+#define tLinkPlayerCount data[4]
+#define tNextState data[5]
+
+static void Task_ReceiveChatMessage(u8 taskId)
{
u8 *buffer;
s16 *data = gTasks[taskId].data;
- switch (data[0])
+ switch (tState)
{
case 0:
if (!gReceivedRemoteLinkPlayers)
@@ -1724,115 +2016,122 @@ static void sub_801F2B4(u8 taskId)
return;
}
- data[0] = 1;
+ tState = 1;
// fall through
case 1:
- data[4] = GetLinkPlayerCount();
- if (gUnknown_02022C84->unkD != data[4])
+ tLinkPlayerCount = GetLinkPlayerCount();
+ if (sChat->linkPlayerCount != tLinkPlayerCount)
{
- data[0] = 2;
- gUnknown_02022C84->unkD = data[4];
+ tState = 2;
+ sChat->linkPlayerCount = tLinkPlayerCount;
return;
}
- data[3] = GetBlockReceivedStatus();
- if (!data[3] && sub_8011A9C())
+ tBlockReceivedStatus = GetBlockReceivedStatus();
+ if (!tBlockReceivedStatus && sub_8011A9C())
return;
- data[1] = 0;
- data[0] = 3;
+ tI = 0;
+ tState = 3;
// fall through
case 3:
- for (; data[1] < 5 && ((data[3] >> data[1]) & 1) == 0; data[1]++)
+ for (; tI < 5 && ((tBlockReceivedStatus >> tI) & 1) == 0; tI++)
;
- if (data[1] == 5)
+ if (tI == 5)
{
- data[0] = 1;
+ tState = 1;
return;
}
- data[2] = data[1];
- ResetBlockReceivedFlag(data[2]);
- buffer = (u8 *)gBlockRecvBuffer[data[1]];
+ tCurrLinkPlayer = tI;
+ ResetBlockReceivedFlag(tCurrLinkPlayer);
+ buffer = (u8 *)gBlockRecvBuffer[tI];
switch (buffer[0])
{
default:
- case 1: data[5] = 3; break;
- case 2: data[5] = 3; break;
- case 3: data[5] = 4; break;
- case 4: data[5] = 5; break;
- case 5: data[5] = 6; break;
+ case CHAT_MESSAGE_CHAT: tNextState = 3; break;
+ case CHAT_MESSAGE_JOIN: tNextState = 3; break;
+ case CHAT_MESSAGE_LEAVE: tNextState = 4; break;
+ case CHAT_MESSAGE_DROP: tNextState = 5; break;
+ case CHAT_MESSAGE_DISBAND: tNextState = 6; break;
}
- if (sub_801EFF8(gUnknown_02022C84->unk39, (u8 *)gBlockRecvBuffer[data[1]]))
+ if (ProcessReceivedChatMessage(sChat->receivedMessage, (u8 *)gBlockRecvBuffer[tI]))
{
- gUnknown_02022C84->unk16 = data[1];
- sub_801F5EC(12, 2);
- data[0] = 7;
+ sChat->receivedPlayerIndex = tI;
+ StartDisplaySubtask(CHATDISPLAY_FUNC_SCROLL_CHAT, 2);
+ tState = 7;
}
else
{
- data[0] = data[5];
+ tState = tNextState;
}
- data[1]++;
+ tI++;
break;
case 7:
- if (!sub_801F644(2))
- data[0] = data[5];
+ if (!IsDisplaySubtaskActive(2))
+ tState = tNextState;
break;
case 4:
- if (!gUnknown_02022C84->unk13 && data[2])
+ if (!sChat->multiplayerId && tCurrLinkPlayer)
{
if (GetLinkPlayerCount() == 2)
{
sub_80104B0();
- gUnknown_02022C84->unk17 = 1;
+ sChat->exitType = 1;
DestroyTask(taskId);
return;
}
- sub_8011DE0(data[2]);
+ sub_8011DE0(tCurrLinkPlayer);
}
- data[0] = 3;
+ tState = 3;
break;
case 5:
- if (gUnknown_02022C84->unk13)
- gUnknown_02022C84->unk17 = 2;
+ if (sChat->multiplayerId)
+ sChat->exitType = 2;
DestroyTask(taskId);
break;
case 6:
- gUnknown_02022C84->unk17 = 3;
+ sChat->exitType = 3;
DestroyTask(taskId);
break;
case 2:
if (!sub_8011A9C())
{
- if (!gUnknown_02022C84->unk13)
- sub_80110B8(gUnknown_02022C84->unkD);
+ if (!sChat->multiplayerId)
+ sub_80110B8(sChat->linkPlayerCount);
- data[0] = 1;
+ tState = 1;
}
break;
}
}
-static bool8 sub_801F4D0(void)
+#undef tNextState
+#undef tLinkPlayerCount
+#undef tBlockReceivedStatus
+#undef tCurrLinkPlayer
+#undef tI
+#undef tState
+
+static bool8 TryAllocDisplay(void)
{
- gUnknown_02022C88 = Alloc(sizeof(*gUnknown_02022C88));
- if (gUnknown_02022C88 && sub_8020890())
+ sDisplay = Alloc(sizeof(*sDisplay));
+ if (sDisplay && TryAllocSprites())
{
ResetBgsAndClearDma3BusyFlags(0);
- InitBgsFromTemplates(0, gUnknown_082F2C60, ARRAY_COUNT(gUnknown_082F2C60));
- InitWindows(gUnknown_082F2C70);
+ InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates));
+ InitWindows(sWinTemplates);
ResetTempTileDataBuffers();
- sub_8020770();
- sub_801F574(gUnknown_02022C88);
- sub_801F580();
- sub_801F5EC(0, 0);
+ InitScanlineEffect();
+ InitDisplay(sDisplay);
+ ResetDisplaySubtasks();
+ StartDisplaySubtask(CHATDISPLAY_FUNC_LOAD_GFX, 0);
return TRUE;
}
else
@@ -1841,80 +2140,80 @@ static bool8 sub_801F4D0(void)
}
}
-static bool32 sub_801F534(void)
+static bool32 IsDisplaySubtask0Active(void)
{
- return sub_801F644(0);
+ return IsDisplaySubtaskActive(0);
}
-static void sub_801F544(void)
+static void FreeDisplay(void)
{
- sub_80208D0();
- if (gUnknown_02022C88)
- FREE_AND_SET_NULL(gUnknown_02022C88);
+ FreeSprites();
+ if (sDisplay)
+ FREE_AND_SET_NULL(sDisplay);
FreeAllWindowBuffers();
gScanlineEffect.state = 3;
}
-static void sub_801F574(struct UnionRoomChat2 *arg0)
+static void InitDisplay(struct UnionRoomChatDisplay *display)
{
- arg0->unk18 = 0xFF;
- arg0->unk1E = 0xFF;
- arg0->unk1A = 0;
+ display->yesNoMenuWindowId = 0xFF;
+ display->messageWindowId = 0xFF;
+ display->currLine = 0;
}
-static void sub_801F580(void)
+static void ResetDisplaySubtasks(void)
{
int i;
- if (!gUnknown_02022C88)
+ if (!sDisplay)
return;
- for (i = 0; i < 3; i++)
+ for (i = 0; i < (int)ARRAY_COUNT(sDisplay->subtasks); i++)
{
- gUnknown_02022C88->unk0[i].unk0 = sub_801FDD8;
- gUnknown_02022C88->unk0[i].unk4 = 0;
- gUnknown_02022C88->unk0[i].unk5 = 0;
+ sDisplay->subtasks[i].callback = Display_Dummy;
+ sDisplay->subtasks[i].active = FALSE;
+ sDisplay->subtasks[i].state = 0;
}
}
-static void sub_801F5B8(void)
+static void RunDisplaySubtasks(void)
{
int i;
- if (!gUnknown_02022C88)
+ if (!sDisplay)
return;
- for (i = 0; i < 3; i++)
+ for (i = 0; i < (int)ARRAY_COUNT(sDisplay->subtasks); i++)
{
- gUnknown_02022C88->unk0[i].unk4 =
- gUnknown_02022C88->unk0[i].unk0(&gUnknown_02022C88->unk0[i].unk5);
+ sDisplay->subtasks[i].active =
+ sDisplay->subtasks[i].callback(&sDisplay->subtasks[i].state);
}
}
-static void sub_801F5EC(u16 arg0, u8 arg1)
+static void StartDisplaySubtask(u16 subtaskId, u8 assignId)
{
u32 i;
- gUnknown_02022C88->unk0[arg1].unk0 = sub_801FDD8;
- for (i = 0; i < 21; i++)
+ sDisplay->subtasks[assignId].callback = Display_Dummy;
+ for (i = 0; i < ARRAY_COUNT(sDisplaySubtasks); i++)
{
- if (gUnknown_082F2C98[i].unk0 == arg0)
+ if (sDisplaySubtasks[i].idx == subtaskId)
{
- gUnknown_02022C88->unk0[arg1].unk0 = gUnknown_082F2C98[i].unk4;
- gUnknown_02022C88->unk0[arg1].unk4 = 1;
- gUnknown_02022C88->unk0[arg1].unk5 = 0;
+ sDisplay->subtasks[assignId].callback = sDisplaySubtasks[i].callback;
+ sDisplay->subtasks[assignId].active = TRUE;
+ sDisplay->subtasks[assignId].state = 0;
break;
}
}
}
-static bool8 sub_801F644(u8 arg0)
+static bool8 IsDisplaySubtaskActive(u8 id)
{
- return gUnknown_02022C88->unk0[arg0].unk4;
+ return sDisplay->subtasks[id].active;
}
-bool32 sub_801F658(u8 *state)
+static bool32 Display_LoadGfx(u8 *state)
{
if (FreeTempTileDataBuffersIfPossible() == TRUE)
return TRUE;
@@ -1922,33 +2221,33 @@ bool32 sub_801F658(u8 *state)
switch (*state)
{
case 0:
- sub_8020480();
- sub_8020538();
+ ResetGpuBgState();
+ SetBgTilemapBuffers();
break;
case 1:
- sub_8020584();
+ ClearBg0();
break;
case 2:
- sub_80205B4();
+ LoadChatWindowBorderGfx();
break;
case 3:
- sub_8020604();
+ LoadChatWindowGfx();
break;
case 4:
sub_8020680();
break;
case 5:
- sub_80206A4();
- sub_80206D0();
- sub_8020740();
- sub_80206E8();
+ LoadChatMessagesWindow();
+ LoadKeyboardWindow();
+ LoadKeyboardSwapWindow();
+ LoadTextEntryWindow();
break;
case 6:
if (!IsDma3ManagerBusyWithBgCopy())
{
- sub_80208E8();
- sub_8020A68();
- sub_8020B20();
+ CreateKeyboardCursorSprite();
+ CreateTextEntrySprites();
+ CreateRButtonSprites();
}
break;
default:
@@ -1959,12 +2258,12 @@ bool32 sub_801F658(u8 *state)
return TRUE;
}
-bool32 sub_801F6F8(u8 *state)
+static bool32 Display_ShowKeyboardSwapMenu(u8 *state)
{
switch (*state)
{
case 0:
- sub_80203B0();
+ ShowKeyboardSwapMenu();
CopyWindowToVram(3, 3);
break;
case 1:
@@ -1975,12 +2274,12 @@ bool32 sub_801F6F8(u8 *state)
return TRUE;
}
-bool32 sub_801F730(u8 *state)
+static bool32 Display_HideKeyboardSwapMenu(u8 *state)
{
switch (*state)
{
case 0:
- sub_802040C();
+ HideKeyboardSwapMenu();
CopyWindowToVram(3, 3);
break;
case 1:
@@ -1991,16 +2290,16 @@ bool32 sub_801F730(u8 *state)
return TRUE;
}
-bool32 sub_801F768(u8 *state)
+static bool32 Display_SwitchPages(u8 *state)
{
switch (*state)
{
case 0:
- sub_802091C(TRUE);
+ SetKeyboardCursorInvisibility(TRUE);
if (sub_8020320())
return TRUE;
- sub_80201A4();
+ PrintCurrentKeyboardPage();
CopyWindowToVram(2, 2);
break;
case 1:
@@ -2011,9 +2310,9 @@ bool32 sub_801F768(u8 *state)
if (sub_8020368())
return TRUE;
- sub_802093C();
- sub_802091C(FALSE);
- sub_8020B80();
+ MoveKeyboardCursor();
+ SetKeyboardCursorInvisibility(FALSE);
+ UpdateRButtonLabel();
return FALSE;
}
@@ -2021,20 +2320,20 @@ bool32 sub_801F768(u8 *state)
return TRUE;
}
-bool32 sub_801F7D4(u8 *state)
+static bool32 Display_MoveKeyboardCursor(u8 *state)
{
- sub_802093C();
+ MoveKeyboardCursor();
return FALSE;
}
-bool32 sub_801F7E0(u8 *state)
+static bool32 Display_AskQuitChatting(u8 *state)
{
switch (*state)
{
case 0:
- sub_801FF18(0, 0);
- sub_801FDDC(23, 11, 1);
- CopyWindowToVram(gUnknown_02022C88->unk1E, 3);
+ AddStdMessageWindow(STDMESSAGE_QUIT_CHATTING, 0);
+ AddYesNoMenuAt(23, 11, 1);
+ CopyWindowToVram(sDisplay->messageWindowId, 3);
break;
case 1:
return IsDma3ManagerBusyWithBgCopy();
@@ -2044,21 +2343,21 @@ bool32 sub_801F7E0(u8 *state)
return TRUE;
}
-bool32 sub_801F82C(u8 *state)
+static bool32 Display_DestroyYesNoDialog(u8 *state)
{
switch (*state)
{
case 0:
- sub_8020094();
- sub_801FEBC();
+ HideStdMessageWindow();
+ HideYesNoMenuWindow();
CopyBgTilemapBufferToVram(0);
break;
case 1:
if (IsDma3ManagerBusyWithBgCopy())
return TRUE;
- sub_80200C8();
- sub_801FEE4();
+ DestroyStdMessageWindow();
+ DestroyYesNoMenuWindow();
return FALSE;
}
@@ -2066,24 +2365,24 @@ bool32 sub_801F82C(u8 *state)
return TRUE;
}
-bool32 sub_801F870(u8 *state)
+static bool32 Display_UpdateMessageBuffer(u8 *state)
{
- u32 var0, var1;
+ u32 x, width;
u8 *str;
switch (*state)
{
case 0:
- sub_801F0EC(&var0, &var1);
- sub_80200EC(var0, var1, 0);
- str = sub_801F0D0();
- sub_8020118(0, str, 3, 1, 2);
+ GetBufferSelectionRegion(&x, &width);
+ FillTextEntryWindow(x, width, 0);
+ str = GetMessageEntryBuffer();
+ DrawTextEntryMessage(0, str, 3, 1, 2);
CopyWindowToVram(1, 2);
break;
case 1:
if (!IsDma3ManagerBusyWithBgCopy())
{
- sub_8020B80();
+ UpdateRButtonLabel();
return FALSE;
}
return TRUE;
@@ -2093,27 +2392,27 @@ bool32 sub_801F870(u8 *state)
return TRUE;
}
-bool32 sub_801F8DC(u8 *state)
+static bool32 Display_AskRegisterText(u8 *state)
{
- u16 var0;
+ u16 x;
u8 *str;
u16 length;
switch (*state)
{
case 0:
- var0 = sub_801F144();
- str = sub_801F114();
+ x = GetLimitedMessageStartPos();
+ str = GetLimitedMessageStartPtr();
length = StringLength_Multibyte(str);
- sub_80200EC(var0, length, PIXEL_FILL(6));
- sub_8020118(var0, str, 0, 4, 5);
+ FillTextEntryWindow(x, length, PIXEL_FILL(6));
+ DrawTextEntryMessage(x, str, 0, 4, 5);
CopyWindowToVram(1, 2);
break;
case 1:
if (!IsDma3ManagerBusyWithBgCopy())
{
- sub_801FF18(1, 16);
- CopyWindowToVram(gUnknown_02022C88->unk1E, 3);
+ AddStdMessageWindow(STDMESSAGE_REGISTER_WHERE, 16);
+ CopyWindowToVram(sDisplay->messageWindowId, 3);
}
else
{
@@ -2122,7 +2421,7 @@ bool32 sub_801F8DC(u8 *state)
break;
case 2:
if (!IsDma3ManagerBusyWithBgCopy())
- sub_80209AC(1);
+ SetRegisteredTextPalette(TRUE);
else
return TRUE;
break;
@@ -2134,27 +2433,27 @@ bool32 sub_801F8DC(u8 *state)
return TRUE;
}
-bool32 sub_801F984(u8 *state)
+static bool32 Display_CancelRegister(u8 *state)
{
- u16 var0;
+ u16 x;
u8 *str;
u16 length;
switch (*state)
{
case 0:
- var0 = sub_801F144();
- str = sub_801F114();
+ x = GetLimitedMessageStartPos();
+ str = GetLimitedMessageStartPtr();
length = StringLength_Multibyte(str);
- sub_80200EC(var0, length, PIXEL_FILL(0));
- sub_8020118(var0, str, 3, 1, 2);
+ FillTextEntryWindow(x, length, PIXEL_FILL(0));
+ DrawTextEntryMessage(x, str, 3, 1, 2);
CopyWindowToVram(1, 2);
break;
case 1:
if (!IsDma3ManagerBusyWithBgCopy())
{
- sub_8020094();
- CopyWindowToVram(gUnknown_02022C88->unk1E, 3);
+ HideStdMessageWindow();
+ CopyWindowToVram(sDisplay->messageWindowId, 3);
}
else
{
@@ -2164,8 +2463,8 @@ bool32 sub_801F984(u8 *state)
case 2:
if (!IsDma3ManagerBusyWithBgCopy())
{
- sub_80209AC(0);
- sub_80200C8();
+ SetRegisteredTextPalette(FALSE);
+ DestroyStdMessageWindow();
}
else
{
@@ -2180,12 +2479,12 @@ bool32 sub_801F984(u8 *state)
return TRUE;
}
-bool32 sub_801FA2C(u8 *state)
+static bool32 Display_ReturnToKeyboard(u8 *state)
{
switch (*state)
{
case 0:
- sub_80201A4();
+ PrintCurrentKeyboardPage();
CopyWindowToVram(2, 2);
(*state)++;
break;
@@ -2199,48 +2498,48 @@ bool32 sub_801FA2C(u8 *state)
return TRUE;
}
-bool32 sub_801FA68(u8 *state)
+static bool32 Display_ScrollChat(u8 *state)
{
- u16 var0;
+ u16 row;
u8 *str;
- u8 var1;
+ u8 colorIdx;
switch (*state)
{
case 0:
- var0 = gUnknown_02022C88->unk1A;
- str = sub_801F180();
- var1 = sub_801F18C();
- sub_8020420(var0, str, var1);
+ row = sDisplay->currLine;
+ str = GetLastReceivedMessage();
+ colorIdx = GetReceivedPlayerIndex();
+ PrintChatMessage(row, str, colorIdx);
CopyWindowToVram(0, 2);
break;
case 1:
if (IsDma3ManagerBusyWithBgCopy())
return TRUE;
- if (gUnknown_02022C88->unk1A < 9)
+ if (sDisplay->currLine < 9)
{
- gUnknown_02022C88->unk1A++;
+ sDisplay->currLine++;
*state = 4;
return FALSE;
}
else
{
- gUnknown_02022C88->unk1C = 0;
+ sDisplay->scrollCount = 0;
(*state)++;
}
// fall through
case 2:
ScrollWindow(0, 0, 5, PIXEL_FILL(1));
CopyWindowToVram(0, 2);
- gUnknown_02022C88->unk1C++;
+ sDisplay->scrollCount++;
(*state)++;
// fall through
case 3:
if (IsDma3ManagerBusyWithBgCopy())
return TRUE;
- if (gUnknown_02022C88->unk1C < 3)
+ if (sDisplay->scrollCount < 3)
{
(*state)--;
return TRUE;
@@ -2256,28 +2555,28 @@ bool32 sub_801FA68(u8 *state)
return TRUE;
}
-bool32 sub_801FB44(u8 *state)
+static bool32 Display_AnimateKeyboardCursor(u8 *state)
{
switch (*state)
{
case 0:
- sub_80209E0();
+ StartKeyboardCursorAnim();
(*state)++;
break;
case 1:
- return sub_8020A1C();
+ return TryKeyboardCursorReopen();
}
return TRUE;
}
-bool32 sub_801FB70(u8 *state)
+static bool32 Display_PrintInputText(u8 *state)
{
switch (*state)
{
case 0:
- sub_801FF18(3, 16);
- CopyWindowToVram(gUnknown_02022C88->unk1E, 3);
+ AddStdMessageWindow(STDMESSAGE_INPUT_TEXT, 16);
+ CopyWindowToVram(sDisplay->messageWindowId, 3);
(*state)++;
break;
case 1:
@@ -2287,13 +2586,13 @@ bool32 sub_801FB70(u8 *state)
return TRUE;
}
-bool32 sub_801FBB4(u8 *state)
+static bool32 Display_PrintExitingChat(u8 *state)
{
switch (*state)
{
case 0:
- sub_801FF18(4, 0);
- CopyWindowToVram(gUnknown_02022C88->unk1E, 3);
+ AddStdMessageWindow(STDMESSAGE_EXITING_CHAT, 0);
+ CopyWindowToVram(sDisplay->messageWindowId, 3);
(*state)++;
break;
case 1:
@@ -2303,7 +2602,7 @@ bool32 sub_801FBB4(u8 *state)
return TRUE;
}
-bool32 sub_801FBF8(u8 *state)
+static bool32 Display_PrintLeaderLeft(u8 *state)
{
u8 *str;
@@ -2311,10 +2610,10 @@ bool32 sub_801FBF8(u8 *state)
{
case 0:
DynamicPlaceholderTextUtil_Reset();
- str = sub_801F1D0();
+ str = GetChatHostName();
DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, str);
- sub_801FF18(5, 0);
- CopyWindowToVram(gUnknown_02022C88->unk1E, 3);
+ AddStdMessageWindow(STDMESSAGE_LEADER_LEFT, 0);
+ CopyWindowToVram(sDisplay->messageWindowId, 3);
(*state)++;
break;
case 1:
@@ -2324,14 +2623,14 @@ bool32 sub_801FBF8(u8 *state)
return TRUE;
}
-bool32 sub_801FC4C(u8 *state)
+static bool32 Display_AskSave(u8 *state)
{
switch (*state)
{
case 0:
- sub_801FF18(6, 0);
- sub_801FDDC(23, 10, 1);
- CopyWindowToVram(gUnknown_02022C88->unk1E, 3);
+ AddStdMessageWindow(STDMESSAGE_ASK_SAVE, 0);
+ AddYesNoMenuAt(23, 10, 1);
+ CopyWindowToVram(sDisplay->messageWindowId, 3);
(*state)++;
break;
case 1:
@@ -2341,14 +2640,14 @@ bool32 sub_801FC4C(u8 *state)
return TRUE;
}
-bool32 sub_801FC9C(u8 *state)
+static bool32 Display_AskOverwriteSave(u8 *state)
{
switch (*state)
{
case 0:
- sub_801FF18(7, 0);
- sub_801FDDC(23, 10, 1);
- CopyWindowToVram(gUnknown_02022C88->unk1E, 3);
+ AddStdMessageWindow(STDMESSAGE_ASK_OVERWRITE, 0);
+ AddYesNoMenuAt(23, 10, 1);
+ CopyWindowToVram(sDisplay->messageWindowId, 3);
(*state)++;
break;
case 1:
@@ -2358,13 +2657,13 @@ bool32 sub_801FC9C(u8 *state)
return TRUE;
}
-bool32 sub_801FCEC(u8 *state)
+static bool32 Display_PrintSavingDontTurnOff(u8 *state)
{
switch (*state)
{
case 0:
- sub_801FF18(8, 0);
- CopyWindowToVram(gUnknown_02022C88->unk1E, 3);
+ AddStdMessageWindow(STDMESSAGE_SAVING_NO_OFF, 0);
+ CopyWindowToVram(sDisplay->messageWindowId, 3);
(*state)++;
break;
case 1:
@@ -2374,15 +2673,15 @@ bool32 sub_801FCEC(u8 *state)
return TRUE;
}
-bool32 sub_801FD30(u8 *state)
+static bool32 Display_PrintSavedTheGame(u8 *state)
{
switch (*state)
{
case 0:
DynamicPlaceholderTextUtil_Reset();
DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gSaveBlock2Ptr->playerName);
- sub_801FF18(9, 0);
- CopyWindowToVram(gUnknown_02022C88->unk1E, 3);
+ AddStdMessageWindow(STDMESSAGE_SAVED_THE_GAME, 0);
+ CopyWindowToVram(sDisplay->messageWindowId, 3);
(*state)++;
break;
case 1:
@@ -2392,14 +2691,14 @@ bool32 sub_801FD30(u8 *state)
return TRUE;
}
-bool32 sub_801FD88(u8 *state)
+static bool32 Display_AskConfirmLeaderLeave(u8 *state)
{
switch (*state)
{
case 0:
- sub_801FF18(10, 0);
- sub_801FDDC(23, 10, 1);
- CopyWindowToVram(gUnknown_02022C88->unk1E, 3);
+ AddStdMessageWindow(STDMESSAGE_WARN_LEADER_LEAVE, 0);
+ AddYesNoMenuAt(23, 10, 1);
+ CopyWindowToVram(sDisplay->messageWindowId, 3);
(*state)++;
break;
case 1:
@@ -2409,12 +2708,12 @@ bool32 sub_801FD88(u8 *state)
return TRUE;
}
-static bool32 sub_801FDD8(u8 *arg0)
+static bool32 Display_Dummy(u8 *state)
{
return FALSE;
}
-static void sub_801FDDC(u8 left, u8 top, u8 initialCursorPos)
+static void AddYesNoMenuAt(u8 left, u8 top, u8 initialCursorPos)
{
struct WindowTemplate template;
template.bg = 0;
@@ -2424,42 +2723,42 @@ static void sub_801FDDC(u8 left, u8 top, u8 initialCursorPos)
template.height = 4;
template.paletteNum = 14;
template.baseBlock = 0x52;
- gUnknown_02022C88->unk18 = AddWindow(&template);
- if (gUnknown_02022C88->unk18 != 0xFF)
+ sDisplay->yesNoMenuWindowId = AddWindow(&template);
+ if (sDisplay->yesNoMenuWindowId != 0xFF)
{
- FillWindowPixelBuffer(gUnknown_02022C88->unk18, PIXEL_FILL(1));
- PutWindowTilemap(gUnknown_02022C88->unk18);
- AddTextPrinterParameterized(gUnknown_02022C88->unk18, 1, gText_Yes, 8, 1, TEXT_SPEED_FF, NULL);
- AddTextPrinterParameterized(gUnknown_02022C88->unk18, 1, gText_No, 8, 17, TEXT_SPEED_FF, NULL);
- DrawTextBorderOuter(gUnknown_02022C88->unk18, 1, 13);
- InitMenuInUpperLeftCornerPlaySoundWhenAPressed(gUnknown_02022C88->unk18, 2, initialCursorPos);
+ FillWindowPixelBuffer(sDisplay->yesNoMenuWindowId, PIXEL_FILL(1));
+ PutWindowTilemap(sDisplay->yesNoMenuWindowId);
+ AddTextPrinterParameterized(sDisplay->yesNoMenuWindowId, 1, gText_Yes, 8, 1, TEXT_SPEED_FF, NULL);
+ AddTextPrinterParameterized(sDisplay->yesNoMenuWindowId, 1, gText_No, 8, 17, TEXT_SPEED_FF, NULL);
+ DrawTextBorderOuter(sDisplay->yesNoMenuWindowId, 1, 13);
+ InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sDisplay->yesNoMenuWindowId, 2, initialCursorPos);
}
}
-static void sub_801FEBC(void)
+static void HideYesNoMenuWindow(void)
{
- if (gUnknown_02022C88->unk18 != 0xFF)
+ if (sDisplay->yesNoMenuWindowId != 0xFF)
{
- ClearStdWindowAndFrameToTransparent(gUnknown_02022C88->unk18, FALSE);
- ClearWindowTilemap(gUnknown_02022C88->unk18);
+ ClearStdWindowAndFrameToTransparent(sDisplay->yesNoMenuWindowId, FALSE);
+ ClearWindowTilemap(sDisplay->yesNoMenuWindowId);
}
}
-static void sub_801FEE4(void)
+static void DestroyYesNoMenuWindow(void)
{
- if (gUnknown_02022C88->unk18 != 0xFF)
+ if (sDisplay->yesNoMenuWindowId != 0xFF)
{
- RemoveWindow(gUnknown_02022C88->unk18);
- gUnknown_02022C88->unk18 = 0xFF;
+ RemoveWindow(sDisplay->yesNoMenuWindowId);
+ sDisplay->yesNoMenuWindowId = 0xFF;
}
}
-static s8 sub_801FF08(void)
+static s8 ProcessMenuInput(void)
{
return Menu_ProcessInput();
}
-static void sub_801FF18(int arg0, u16 arg1)
+static void AddStdMessageWindow(int msgId, u16 bg0vofs)
{
const u8 *str;
int windowId;
@@ -2471,43 +2770,43 @@ static void sub_801FF18(int arg0, u16 arg1)
template.height = 4;
template.paletteNum = 14;
template.baseBlock = 0x6A;
- if (gUnknown_082F2D40[arg0].unkA)
+ if (sDisplayStdMessages[msgId].useWiderBox)
{
template.tilemapLeft -= 7;
template.width += 7;
}
- gUnknown_02022C88->unk1E = AddWindow(&template);
- windowId = gUnknown_02022C88->unk1E;
- if (gUnknown_02022C88->unk1E == 0xFF)
+ sDisplay->messageWindowId = AddWindow(&template);
+ windowId = sDisplay->messageWindowId;
+ if (sDisplay->messageWindowId == 0xFF)
return;
- if (gUnknown_082F2D40[arg0].unk9)
+ if (sDisplayStdMessages[msgId].hasPlaceholders)
{
- DynamicPlaceholderTextUtil_ExpandPlaceholders(gUnknown_02022C88->unk22, gUnknown_082F2D40[arg0].unk0);
- str = gUnknown_02022C88->unk22;
+ DynamicPlaceholderTextUtil_ExpandPlaceholders(sDisplay->expandedPlaceholdersBuffer, sDisplayStdMessages[msgId].text);
+ str = sDisplay->expandedPlaceholdersBuffer;
}
else
{
- str = gUnknown_082F2D40[arg0].unk0;
+ str = sDisplayStdMessages[msgId].text;
}
- ChangeBgY(0, arg1 * 256, 0);
+ ChangeBgY(0, bg0vofs * 256, 0);
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
PutWindowTilemap(windowId);
- if (gUnknown_082F2D40[arg0].unk4 == 1)
+ if (sDisplayStdMessages[msgId].boxType == 1)
{
DrawTextBorderInner(windowId, 0xA, 2);
AddTextPrinterParameterized5(
windowId,
1,
str,
- gUnknown_082F2D40[arg0].unk5 + 8,
- gUnknown_082F2D40[arg0].unk6 + 8,
+ sDisplayStdMessages[msgId].x + 8,
+ sDisplayStdMessages[msgId].y + 8,
TEXT_SPEED_FF,
NULL,
- gUnknown_082F2D40[arg0].unk7,
- gUnknown_082F2D40[arg0].unk8);
+ sDisplayStdMessages[msgId].letterSpacing,
+ sDisplayStdMessages[msgId].lineSpacing);
}
else
{
@@ -2516,105 +2815,103 @@ static void sub_801FF18(int arg0, u16 arg1)
windowId,
1,
str,
- gUnknown_082F2D40[arg0].unk5,
- gUnknown_082F2D40[arg0].unk6,
+ sDisplayStdMessages[msgId].x,
+ sDisplayStdMessages[msgId].y,
TEXT_SPEED_FF,
NULL,
- gUnknown_082F2D40[arg0].unk7,
- gUnknown_082F2D40[arg0].unk8);
+ sDisplayStdMessages[msgId].letterSpacing,
+ sDisplayStdMessages[msgId].lineSpacing);
}
- gUnknown_02022C88->unk1E = windowId;
+ sDisplay->messageWindowId = windowId;
}
-static void sub_8020094(void)
+static void HideStdMessageWindow(void)
{
- if (gUnknown_02022C88->unk1E != 0xFF)
+ if (sDisplay->messageWindowId != 0xFF)
{
- ClearStdWindowAndFrameToTransparent(gUnknown_02022C88->unk1E, FALSE);
- ClearWindowTilemap(gUnknown_02022C88->unk1E);
+ ClearStdWindowAndFrameToTransparent(sDisplay->messageWindowId, FALSE);
+ ClearWindowTilemap(sDisplay->messageWindowId);
}
ChangeBgY(0, 0, 0);
}
-static void sub_80200C8(void)
+static void DestroyStdMessageWindow(void)
{
- if (gUnknown_02022C88->unk1E != 0xFF)
+ if (sDisplay->messageWindowId != 0xFF)
{
- RemoveWindow(gUnknown_02022C88->unk1E);
- gUnknown_02022C88->unk1E = 0xFF;
+ RemoveWindow(sDisplay->messageWindowId);
+ sDisplay->messageWindowId = 0xFF;
}
}
-static void sub_80200EC(u16 x, u16 width, u8 fillValue)
+static void FillTextEntryWindow(u16 x, u16 width, u8 fillValue)
{
FillWindowPixelRect(1, fillValue, x * 8, 1, width * 8, 14);
}
-static void sub_8020118(u16 x, u8 *str, u8 fillValue, u8 arg3, u8 arg4)
+static void DrawTextEntryMessage(u16 x, u8 *str, u8 bgColor, u8 fgColor, u8 shadowColor)
{
- u8 *str2;
- u8 sp[38];
- if (fillValue)
- sub_80200EC(x, sub_801F198() - x, fillValue);
+ u8 color[3];
+ u8 strBuffer[35];
+ if (bgColor != TEXT_COLOR_TRANSPARENT)
+ FillTextEntryWindow(x, GetTextEntryCursorPosition() - x, bgColor);
- sp[0] = fillValue;
- sp[1] = arg3;
- sp[2] = arg4;
- str2 = &sp[4];
- str2[0] = EXT_CTRL_CODE_BEGIN;
- str2[1] = EXT_CTRL_CODE_MIN_LETTER_SPACING;
- str2[2] = 8;
- StringCopy(&str2[3], str);
- AddTextPrinterParameterized3(1, 2, x * 8, 1, sp, TEXT_SPEED_FF, str2);
+ color[0] = bgColor;
+ color[1] = fgColor;
+ color[2] = shadowColor;
+ strBuffer[0] = EXT_CTRL_CODE_BEGIN;
+ strBuffer[1] = EXT_CTRL_CODE_MIN_LETTER_SPACING;
+ strBuffer[2] = 8;
+ StringCopy(&strBuffer[3], str);
+ AddTextPrinterParameterized3(1, 2, x * 8, 1, color, TEXT_SPEED_FF, strBuffer);
}
-static void sub_80201A4(void)
+static void PrintCurrentKeyboardPage(void)
{
u8 page;
int i;
- int var1;
u16 left;
u16 top;
- u8 sp[52];
- u8 *str;
+ u8 color[3];
+ u8 str[45];
u8 *str2;
FillWindowPixelBuffer(2, PIXEL_FILL(15));
page = GetCurrentKeyboardPage();
- sp[0] = TEXT_COLOR_TRANSPARENT;
- sp[1] = TEXT_DYNAMIC_COLOR_5;
- sp[2] = TEXT_DYNAMIC_COLOR_4;
- if (page != UNION_ROOM_KB_PAGE_COUNT)
+ color[0] = TEXT_COLOR_TRANSPARENT;
+ color[1] = TEXT_DYNAMIC_COLOR_5;
+ color[2] = TEXT_DYNAMIC_COLOR_4;
+ if (page != UNION_ROOM_KB_PAGE_REGISTER)
{
- str = &sp[4];
str[0] = EXT_CTRL_CODE_BEGIN;
str[1] = EXT_CTRL_CODE_MIN_LETTER_SPACING;
- var1 = 8;
- str[2] = var1;
- left = var1;
+ str[2] = 8;
+
if (page == UNION_ROOM_KB_PAGE_EMOJI)
left = 6;
+ else
+ left = 8;
for (i = 0, top = 0; i < UNION_ROOM_KB_ROW_COUNT; i++, top += 12)
{
if (!sUnionRoomKeyboardText[page][i])
return;
- StringCopy(&sp[7], sUnionRoomKeyboardText[page][i]);
- AddTextPrinterParameterized3(2, 0, left, top, sp, TEXT_SPEED_FF, &sp[4]);
+ StringCopy(&str[3], sUnionRoomKeyboardText[page][i]);
+ AddTextPrinterParameterized3(2, 0, left, top, color, TEXT_SPEED_FF, str);
}
}
else
{
left = 4;
- for (i = 0, top = 0; i < 10; i++, top += 12)
+ for (i = 0, top = 0; i < UNION_ROOM_KB_ROW_COUNT; i++, top += 12)
{
- str2 = sub_801EE6C(i);
+ str2 = GetRegisteredTextByRow(i);
if (GetStringWidth(0, str2, 0) <= 40)
{
- AddTextPrinterParameterized3(2, 0, left, top, sp, TEXT_SPEED_FF, str2);
+ AddTextPrinterParameterized3(2, 0, left, top, color, TEXT_SPEED_FF, str2);
}
else
{
@@ -2622,11 +2919,11 @@ static void sub_80201A4(void)
do
{
length--;
- StringCopyN_Multibyte(&sp[4], str2, length);
- } while (GetStringWidth(0, &sp[4], 0) > 35);
+ StringCopyN_Multibyte(str, str2, length);
+ } while (GetStringWidth(0, str, 0) > 35);
- AddTextPrinterParameterized3(2, 0, left, top, sp, TEXT_SPEED_FF, &sp[4]);
- AddTextPrinterParameterized3(2, 0, left + 35, top, sp, TEXT_SPEED_FF, gText_Ellipsis);
+ AddTextPrinterParameterized3(2, 0, left, top, color, TEXT_SPEED_FF, str);
+ AddTextPrinterParameterized3(2, 0, left + 35, top, color, TEXT_SPEED_FF, sText_Ellipsis);
}
}
}
@@ -2634,68 +2931,69 @@ static void sub_80201A4(void)
static bool32 sub_8020320(void)
{
- if (gUnknown_02022C88->unk20 < 56)
+ if (sDisplay->bg1hofs < 56)
{
- gUnknown_02022C88->unk20 += 12;
- if (gUnknown_02022C88->unk20 >= 56)
- gUnknown_02022C88->unk20 = 56;
+ sDisplay->bg1hofs += 12;
+ if (sDisplay->bg1hofs >= 56)
+ sDisplay->bg1hofs = 56;
- if (gUnknown_02022C88->unk20 < 56)
+ if (sDisplay->bg1hofs < 56)
{
- sub_80207C0(gUnknown_02022C88->unk20);
+ sub_80207C0(sDisplay->bg1hofs);
return TRUE;
}
}
- sub_8020818(gUnknown_02022C88->unk20);
+ sub_8020818(sDisplay->bg1hofs);
return FALSE;
}
static bool32 sub_8020368(void)
{
- if (gUnknown_02022C88->unk20 > 0)
+ if (sDisplay->bg1hofs > 0)
{
- gUnknown_02022C88->unk20 -= 12;
- if (gUnknown_02022C88->unk20 <= 0)
- gUnknown_02022C88->unk20 = 0;
+ sDisplay->bg1hofs -= 12;
+ if (sDisplay->bg1hofs <= 0)
+ sDisplay->bg1hofs = 0;
- if (gUnknown_02022C88->unk20 > 0)
+ if (sDisplay->bg1hofs > 0)
{
- sub_80207C0(gUnknown_02022C88->unk20);
+ sub_80207C0(sDisplay->bg1hofs);
return TRUE;
}
}
- sub_8020818(gUnknown_02022C88->unk20);
+ sub_8020818(sDisplay->bg1hofs);
return FALSE;
}
-static void sub_80203B0(void)
+static void ShowKeyboardSwapMenu(void)
{
FillWindowPixelBuffer(3, PIXEL_FILL(1));
DrawTextBorderOuter(3, 1, 13);
- PrintTextArray(3, 2, 8, 1, 14, 5, gUnknown_082F2DC8);
+ PrintTextArray(3, 2, 8, 1, 14, 5, sKeyboardPageTitleTexts);
sub_81983AC(3, 2, 0, 1, 14, 5, GetCurrentKeyboardPage());
PutWindowTilemap(3);
}
-static void sub_802040C(void)
+static void HideKeyboardSwapMenu(void)
{
ClearStdWindowAndFrameToTransparent(3, FALSE);
ClearWindowTilemap(3);
}
-static void sub_8020420(u16 row, u8 *str, u8 arg2)
+static void PrintChatMessage(u16 row, u8 *str, u8 colorIdx)
{
+ // colorIdx: 0 = grey, 1 = red, 2 = green, 3 = blue
u8 color[3];
color[0] = TEXT_COLOR_WHITE;
- color[1] = arg2 * 2 + 2;
- color[2] = arg2 * 2 + 3;
+ color[1] = colorIdx * 2 + 2;
+ color[2] = colorIdx * 2 + 3;
FillWindowPixelRect(0, PIXEL_FILL(1), 0, row * 15, 168, 15);
AddTextPrinterParameterized3(0, 2, 0, row * 15 + 1, color, TEXT_SPEED_FF, str);
}
-static void sub_8020480(void)
+static void ResetGpuBgState(void)
{
ChangeBgX(0, 0, 0);
ChangeBgY(0, 0, 0);
@@ -2720,83 +3018,83 @@ static void sub_8020480(void)
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR);
}
-static void sub_8020538(void)
+static void SetBgTilemapBuffers(void)
{
- SetBgTilemapBuffer(0, gUnknown_02022C88->unk128);
- SetBgTilemapBuffer(1, gUnknown_02022C88->unk928);
- SetBgTilemapBuffer(3, gUnknown_02022C88->unk1128);
- SetBgTilemapBuffer(2, gUnknown_02022C88->unk1928);
+ SetBgTilemapBuffer(0, sDisplay->bg0Buffer);
+ SetBgTilemapBuffer(1, sDisplay->bg1Buffer);
+ SetBgTilemapBuffer(3, sDisplay->bg3Buffer);
+ SetBgTilemapBuffer(2, sDisplay->bg2Buffer);
}
-static void sub_8020584(void)
+static void ClearBg0(void)
{
RequestDma3Fill(0, (void *)BG_CHAR_ADDR(0), 0x20, 1);
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32);
CopyBgTilemapBufferToVram(0);
}
-static void sub_80205B4(void)
+static void LoadChatWindowBorderGfx(void)
{
- LoadPalette(gUnknown_08DD4BD0, 0x70, 0x20);
- LoadPalette(gUnknown_08DD4BB0, 0xC0, 0x20);
- DecompressAndCopyTileDataToVram(1, gUnknown_08DD4BF0, 0, 0, 0);
- CopyToBgTilemapBuffer(1, gUnknown_08DD4C4C, 0, 0);
+ LoadPalette(gUnionRoomChat_Window_Pal2, 0x70, 0x20);
+ LoadPalette(gUnionRoomChat_Window_Pal1, 0xC0, 0x20);
+ DecompressAndCopyTileDataToVram(1, gUnionRoomChat_Border_Gfx, 0, 0, 0);
+ CopyToBgTilemapBuffer(1, gUnionRoomChat_Border_Tilemap, 0, 0);
CopyBgTilemapBufferToVram(1);
}
-static void sub_8020604(void)
+static void LoadChatWindowGfx(void)
{
u8 *ptr;
- LoadPalette(gLinkMiscMenu_Pal, 0, 0x20);
- ptr = DecompressAndCopyTileDataToVram(2, gLinkMiscMenu_Gfx, 0, 0, 0);
+ LoadPalette(gUnionRoomChat_Background_Pal, 0, 0x20);
+ ptr = DecompressAndCopyTileDataToVram(2, gUnionRoomChat_Background_Gfx, 0, 0, 0);
if (ptr)
{
- CpuFastCopy(&ptr[0x220], gUnknown_02022C88->unk2128, 0x20);
- CpuFastCopy(&ptr[0x420], gUnknown_02022C88->unk2148, 0x20);
+ CpuFastCopy(&ptr[0x220], sDisplay->unk2128, 0x20);
+ CpuFastCopy(&ptr[0x420], sDisplay->unk2148, 0x20);
}
- CopyToBgTilemapBuffer(2, gLinkMiscMenu_Tilemap, 0, 0);
+ CopyToBgTilemapBuffer(2, gUnionRoomChat_Background_Tilemap, 0, 0);
CopyBgTilemapBufferToVram(2);
}
static void sub_8020680(void)
{
- LoadPalette(gUnknown_082F2C20, 0x80, 0x20);
+ LoadPalette(sUnk_Palette1, 0x80, 0x20);
RequestDma3Fill(0, (void *)BG_CHAR_ADDR(1) + 0x20, 0x20, 1);
}
-static void sub_80206A4(void)
+static void LoadChatMessagesWindow(void)
{
- LoadPalette(gUnknown_082F2C40, 0xF0, 0x20);
+ LoadPalette(sUnk_Palette2, 0xF0, 0x20);
PutWindowTilemap(0);
FillWindowPixelBuffer(0, PIXEL_FILL(1));
CopyWindowToVram(0, 3);
}
-static void sub_80206D0(void)
+static void LoadKeyboardWindow(void)
{
PutWindowTilemap(2);
- sub_80201A4();
+ PrintCurrentKeyboardPage();
CopyWindowToVram(2, 3);
}
-static void sub_80206E8(void)
+static void LoadTextEntryWindow(void)
{
int i;
- u8 var0[2];
- var0[0] = 0;
- var0[1] = 0xFF;
+ u8 unused[2];
+ unused[0] = 0;
+ unused[1] = 0xFF;
- for (i = 0; i < 15; i++)
- BlitBitmapToWindow(1, gUnknown_02022C88->unk2128, i * 8, 0, 8, 16);
+ for (i = 0; i < MAX_MESSAGE_LENGTH; i++)
+ BlitBitmapToWindow(1, sDisplay->unk2128, i * 8, 0, 8, 16);
FillWindowPixelBuffer(1, PIXEL_FILL(0));
PutWindowTilemap(1);
CopyWindowToVram(1, 3);
}
-static void sub_8020740(void)
+static void LoadKeyboardSwapWindow(void)
{
FillWindowPixelBuffer(3, PIXEL_FILL(1));
LoadUserWindowBorderGfx(3, 1, 0xD0);
@@ -2804,110 +3102,110 @@ static void sub_8020740(void)
LoadPalette(gUnknown_0860F074, 0xE0, 0x20);
}
-static void sub_8020770(void)
+static void InitScanlineEffect(void)
{
struct ScanlineEffectParams params;
params.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT;
params.dmaDest = &REG_BG1HOFS;
params.initState = 1;
params.unused9 = 0;
- gUnknown_02022C88->unk20 = 0;
+ sDisplay->bg1hofs = 0;
CpuFastFill(0, gScanlineEffectRegBuffers, sizeof(gScanlineEffectRegBuffers));
ScanlineEffect_SetParams(params);
}
-static void sub_80207C0(s16 arg0)
+static void sub_80207C0(s16 bg1hofs)
{
- CpuFill16(arg0, gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], 0x120);
- CpuFill16(0, gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer] + 0x90, 0x20);
+ CpuFill16(bg1hofs, gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], 0x120);
+ CpuFill16(0, gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer] + 0x90, 0x20);
}
-static void sub_8020818(s16 arg0)
+static void sub_8020818(s16 bg1hofs)
{
- CpuFill16(arg0, gScanlineEffectRegBuffers[0], 0x120);
- CpuFill16(0, gScanlineEffectRegBuffers[0] + 0x90, 0x20);
- CpuFill16(arg0, gScanlineEffectRegBuffers[0] + 0x3C0, 0x120);
- CpuFill16(0, gScanlineEffectRegBuffers[0] + 0x450, 0x20);
+ CpuFill16(bg1hofs, gScanlineEffectRegBuffers[0], 0x120);
+ CpuFill16(0, gScanlineEffectRegBuffers[0] + 0x90, 0x20);
+ CpuFill16(bg1hofs, gScanlineEffectRegBuffers[0] + 0x3C0, 0x120);
+ CpuFill16(0, gScanlineEffectRegBuffers[0] + 0x450, 0x20);
}
-static bool32 sub_8020890(void)
+static bool32 TryAllocSprites(void)
{
u32 i;
- for (i = 0; i < 5; i++)
- LoadCompressedSpriteSheet(&gUnknown_082F3134[i]);
+ for (i = 0; i < ARRAY_COUNT(sSpriteSheets); i++)
+ LoadCompressedSpriteSheet(&sSpriteSheets[i]);
- LoadSpritePalette(&gUnknown_082F315C);
- gUnknown_02022C8C = Alloc(0x18);
- if (!gUnknown_02022C8C)
+ LoadSpritePalette(&sSpritePalette);
+ sSprites = Alloc(sizeof(struct UnionRoomChatSprites));
+ if (!sSprites)
return FALSE;
return TRUE;
}
-static void sub_80208D0(void)
+static void FreeSprites(void)
{
- if (gUnknown_02022C8C)
- Free(gUnknown_02022C8C);
+ if (sSprites)
+ Free(sSprites);
}
-static void sub_80208E8(void)
+static void CreateKeyboardCursorSprite(void)
{
- u8 spriteId = CreateSprite(&gUnknown_082F319C, 10, 24, 0);
- gUnknown_02022C8C->unk0 = &gSprites[spriteId];
+ u8 spriteId = CreateSprite(&sSpriteTemplate_KeyboardCursor, 10, 24, 0);
+ sSprites->keyboardCursor = &gSprites[spriteId];
}
-static void sub_802091C(bool32 invisible)
+static void SetKeyboardCursorInvisibility(bool32 invisible)
{
- gUnknown_02022C8C->unk0->invisible = invisible;
+ sSprites->keyboardCursor->invisible = invisible;
}
-static void sub_802093C(void)
+static void MoveKeyboardCursor(void)
{
u8 x, y;
u8 page = GetCurrentKeyboardPage();
- sub_801F0BC(&x, &y);
- if (page != UNION_ROOM_KB_PAGE_COUNT)
+ GetCurrentKeyboardColAndRow(&x, &y);
+ if (page != UNION_ROOM_KB_PAGE_REGISTER)
{
- StartSpriteAnim(gUnknown_02022C8C->unk0, 0);
- gUnknown_02022C8C->unk0->pos1.x = x * 8 + 10;
- gUnknown_02022C8C->unk0->pos1.y = y * 12 + 24;
+ StartSpriteAnim(sSprites->keyboardCursor, 0);
+ sSprites->keyboardCursor->pos1.x = x * 8 + 10;
+ sSprites->keyboardCursor->pos1.y = y * 12 + 24;
}
else
{
- StartSpriteAnim(gUnknown_02022C8C->unk0, 2);
- gUnknown_02022C8C->unk0->pos1.x = 24;
- gUnknown_02022C8C->unk0->pos1.y = y * 12 + 24;
+ StartSpriteAnim(sSprites->keyboardCursor, 2);
+ sSprites->keyboardCursor->pos1.x = 24;
+ sSprites->keyboardCursor->pos1.y = y * 12 + 24;
}
}
-static void sub_80209AC(int arg0)
+static void SetRegisteredTextPalette(bool32 registering)
{
- const u16 *palette = &gUnknown_082F2DF0[arg0 * 2 + 1];
+ const u16 *palette = &sUnionRoomChatInterfacePal[registering * 2 + 1];
u8 index = IndexOfSpritePaletteTag(0);
LoadPalette(palette, index * 16 + 0x101, 4);
}
-static void sub_80209E0(void)
+static void StartKeyboardCursorAnim(void)
{
- if (GetCurrentKeyboardPage() != UNION_ROOM_KB_PAGE_COUNT)
- StartSpriteAnim(gUnknown_02022C8C->unk0, 1);
+ if (GetCurrentKeyboardPage() != UNION_ROOM_KB_PAGE_REGISTER)
+ StartSpriteAnim(sSprites->keyboardCursor, 1);
else
- StartSpriteAnim(gUnknown_02022C8C->unk0, 3);
+ StartSpriteAnim(sSprites->keyboardCursor, 3);
- gUnknown_02022C8C->unk14 = 0;
+ sSprites->cursorBlinkTimer = 0;
}
-static bool32 sub_8020A1C(void)
+static bool32 TryKeyboardCursorReopen(void)
{
- if (gUnknown_02022C8C->unk14 > 3)
+ if (sSprites->cursorBlinkTimer > 3)
return FALSE;
- if (++gUnknown_02022C8C->unk14 > 3)
+ if (++sSprites->cursorBlinkTimer > 3)
{
- if (GetCurrentKeyboardPage() != UNION_ROOM_KB_PAGE_COUNT)
- StartSpriteAnim(gUnknown_02022C8C->unk0, 0);
+ if (GetCurrentKeyboardPage() != UNION_ROOM_KB_PAGE_REGISTER)
+ StartSpriteAnim(sSprites->keyboardCursor, 0);
else
- StartSpriteAnim(gUnknown_02022C8C->unk0, 2);
+ StartSpriteAnim(sSprites->keyboardCursor, 2);
return FALSE;
}
@@ -2915,29 +3213,29 @@ static bool32 sub_8020A1C(void)
return TRUE;
}
-static void sub_8020A68(void)
+static void CreateTextEntrySprites(void)
{
- u8 spriteId = CreateSprite(&gUnknown_082F31BC, 76, 152, 2);
- gUnknown_02022C8C->unk8 = &gSprites[spriteId];
- spriteId = CreateSprite(&gUnknown_082F31D4, 64, 152, 1);
- gUnknown_02022C8C->unk4 = &gSprites[spriteId];
+ u8 spriteId = CreateSprite(&sSpriteTemplate_TextEntryCursor, 76, 152, 2);
+ sSprites->textEntryCursor = &gSprites[spriteId];
+ spriteId = CreateSprite(&sSpriteTemplate_TextEntryArrow, 64, 152, 1);
+ sSprites->textEntryArrow = &gSprites[spriteId];
}
-static void sub_8020ABC(struct Sprite *sprite)
+static void SpriteCB_TextEntryCursor(struct Sprite *sprite)
{
- int var0 = sub_801F198();
- if (var0 == 15)
+ int pos = GetTextEntryCursorPosition();
+ if (pos == MAX_MESSAGE_LENGTH)
{
- sprite->invisible = 1;
+ sprite->invisible = TRUE;
}
else
{
- sprite->invisible = 0;
- sprite->pos1.x = var0 * 8 + 76;
+ sprite->invisible = FALSE;
+ sprite->pos1.x = pos * 8 + 76;
}
}
-static void sub_8020AF4(struct Sprite *sprite)
+static void SpriteCB_TextEntryArrow(struct Sprite *sprite)
{
if (++sprite->data[0] > 4)
{
@@ -2947,40 +3245,42 @@ static void sub_8020AF4(struct Sprite *sprite)
}
}
-static void sub_8020B20(void)
+static void CreateRButtonSprites(void)
{
- u8 spriteId = CreateSprite(&gUnknown_082F322C, 8, 152, 3);
- gUnknown_02022C8C->unkC = &gSprites[spriteId];
- spriteId = CreateSprite(&gUnknown_082F3244, 32, 152, 4);
- gUnknown_02022C8C->unk10 = &gSprites[spriteId];
- gUnknown_02022C8C->unk10->invisible = 1;
+ u8 spriteId = CreateSprite(&sSpriteTemplate_RButtonIcon, 8, 152, 3);
+ sSprites->rButtonIcon = &gSprites[spriteId];
+ spriteId = CreateSprite(&sSpriteTemplate_RButtonLabels, 32, 152, 4);
+ sSprites->rButtonLabel = &gSprites[spriteId];
+ sSprites->rButtonLabel->invisible = TRUE;
}
-static void sub_8020B80(void)
+static void UpdateRButtonLabel(void)
{
- if (GetCurrentKeyboardPage() == UNION_ROOM_KB_PAGE_COUNT)
+ if (GetCurrentKeyboardPage() == UNION_ROOM_KB_PAGE_REGISTER)
{
- if (sub_801F0DC() != 0)
+ if (GetLengthOfMessageEntry() != 0)
{
- gUnknown_02022C8C->unk10->invisible = 0;
- StartSpriteAnim(gUnknown_02022C8C->unk10, 3);
+ // REGISTER
+ sSprites->rButtonLabel->invisible = FALSE;
+ StartSpriteAnim(sSprites->rButtonLabel, 3);
}
else
{
- gUnknown_02022C8C->unk10->invisible = 1;
+ sSprites->rButtonLabel->invisible = TRUE;
}
}
else
{
- int anim = sub_801F1A4();
+ int anim = GetShouldShowCaseToggleIcon();
if (anim == 3)
{
- gUnknown_02022C8C->unk10->invisible = 1;
+ sSprites->rButtonLabel->invisible = TRUE;
}
else
{
- gUnknown_02022C8C->unk10->invisible = 0;
- StartSpriteAnim(gUnknown_02022C8C->unk10, anim);
+ // A <--> a (toggle case)
+ sSprites->rButtonLabel->invisible = FALSE;
+ StartSpriteAnim(sSprites->rButtonLabel, anim);
}
}
diff --git a/src/union_room_player_avatar.c b/src/union_room_player_avatar.c
index 8a09306c0..cac789685 100644
--- a/src/union_room_player_avatar.c
+++ b/src/union_room_player_avatar.c
@@ -10,98 +10,124 @@
#include "constants/event_object_movement.h"
#include "constants/flags.h"
-EWRAM_DATA struct UnkStruct_8019BA8 * gUnknown_02022C64 = NULL;
-EWRAM_DATA u32 gUnknown_02022C68 = 0;
-
-static u8 sub_8019DF4(void);
-static u32 sub_8019F8C(u32 playerIdx, u32 arg1);
-static void sub_801A3B0(s32 arg0, s32 arg1, u8 arg2);
-
-ALIGNED(4) const u8 gUnknown_082F072C[][10] = {
- {0x21, 0x2c, 0x1f, 0x23, 0x25, 0x24, 0x41, 0x42},
- {0x22, 0x28, 0x20, 0x2f, 0x2f, 0x0e, 0x14, 0x2d}
+#define UR_SPRITE_START_ID (MAX_SPRITES - MAX_UNION_ROOM_PLAYERS)
+#define UR_PLAYER_SPRITE_ID(playerIdx, facingDir)(5 * playerIdx + facingDir)
+
+static EWRAM_DATA struct UnionRoomObject * sUnionObjWork = NULL;
+static EWRAM_DATA u32 sUnionObjRefreshTimer = 0;
+
+static u8 CreateTask_AnimateUnionRoomPlayers(void);
+static u32 IsUnionRoomPlayerInvisible(u32, u32);
+static void SetUnionRoomObjectFacingDirection(s32, s32, u8);
+
+static const u8 sUnionRoomObjGfxIds[GENDER_COUNT][MAX_UNION_ROOM_PLAYERS + 2] = {
+ [MALE] = {
+ OBJ_EVENT_GFX_MAN_3,
+ OBJ_EVENT_GFX_BLACK_BELT,
+ OBJ_EVENT_GFX_CAMPER,
+ OBJ_EVENT_GFX_YOUNGSTER,
+ OBJ_EVENT_GFX_PSYCHIC_M,
+ OBJ_EVENT_GFX_BUG_CATCHER,
+ OBJ_EVENT_GFX_MAN_4,
+ OBJ_EVENT_GFX_MAN_5
+ },
+ [FEMALE] = {
+ OBJ_EVENT_GFX_WOMAN_5,
+ OBJ_EVENT_GFX_HEX_MANIAC,
+ OBJ_EVENT_GFX_PICNICKER,
+ OBJ_EVENT_GFX_LASS,
+ OBJ_EVENT_GFX_LASS,
+ OBJ_EVENT_GFX_GIRL_3,
+ OBJ_EVENT_GFX_WOMAN_2,
+ OBJ_EVENT_GFX_BEAUTY
+ }
};
-static const s16 gUnknown_082F0740[][2] = {
- {0x4, 0x6},
- {0xd, 0x8},
- {0xa, 0x6},
- {0x1, 0x8},
- {0xd, 0x4},
- {0x7, 0x4},
- {0x1, 0x4},
- {0x7, 0x8}
+static const s16 sUnionRoomPlayerCoords[MAX_UNION_ROOM_PLAYERS][2] = {
+ { 4, 6},
+ {13, 8},
+ {10, 6},
+ { 1, 8},
+ {13, 4},
+ { 7, 4},
+ { 1, 4},
+ { 7, 8}
};
-static const s8 gUnknown_082F0760[][2] = {
- { 0, 0},
- { 1, 0},
- { 0, -1},
- {-1, 0},
- { 0, 1}
+static const s8 sFacingDirectionOffsets[][2] = {
+ [DIR_NONE] = { 0, 0},
+ [DIR_SOUTH] = { 1, 0},
+ [DIR_NORTH] = { 0, -1},
+ [DIR_WEST] = {-1, 0},
+ [DIR_EAST] = { 0, 1}
};
-static const u8 gUnknown_082F076A[] = {
- 0x00, 0x02, 0x01, 0x04, 0x03
+static const u8 sOppositeFacingDirection[] = {
+ [DIR_NONE] = DIR_NONE,
+ [DIR_SOUTH] = DIR_NORTH,
+ [DIR_NORTH] = DIR_SOUTH,
+ [DIR_WEST] = DIR_EAST,
+ [DIR_EAST] = DIR_WEST
};
-static const u8 gUnknown_082F076F[] = {
- 0x01, 0x03, 0x01, 0x04, 0x02
+static const u8 sNextFacingDirection[] = {
+ [DIR_NONE] = DIR_SOUTH,
+ [DIR_SOUTH] = DIR_WEST,
+ [DIR_NORTH] = DIR_SOUTH,
+ [DIR_WEST] = DIR_EAST,
+ [DIR_EAST] = DIR_NORTH
};
-static const u8 gUnknown_082F0774[] = {
- 0x09, 0x08, 0x07, 0x02, 0x06, 0x05, 0x04, 0x03,
- 0xbf, 0x02, 0xc0, 0x02, 0xc1, 0x02, 0xc2, 0x02,
- 0xc3, 0x02, 0xc4, 0x02, 0xc5, 0x02, 0xc6, 0x02
+// Local id 1 is the Nurse/Attendant, 2-9 are link players
+static const u8 sUnionRoomLocalIds[] = { 9, 8, 7, 2, 6, 5, 4, 3 };
+
+static const u16 sUnknown[] = {
+ 0x2BF,
+ 0x2C0,
+ 0x2C1,
+ 0x2C2,
+ 0x2C3,
+ 0x2C4,
+ 0x2C5,
+ 0x2C6
};
-static const u8 gUnknown_082F078C[2] = {
+static const u8 sMovement_UnionPlayerExit[2] = {
MOVEMENT_ACTION_FLY_UP,
MOVEMENT_ACTION_STEP_END
};
-static const u8 gUnknown_082F078E[2] = {
+static const u8 sMovement_UnionPlayerEnter[2] = {
MOVEMENT_ACTION_FLY_DOWN,
MOVEMENT_ACTION_STEP_END
};
-static bool32 is_walking_or_running(void)
+static bool32 IsPlayerStandingStill(void)
{
- if (gPlayerAvatar.tileTransitionState == 2 || gPlayerAvatar.tileTransitionState == 0)
- {
+ if (gPlayerAvatar.tileTransitionState == T_TILE_CENTER || gPlayerAvatar.tileTransitionState == T_NOT_MOVING)
return TRUE;
- }
else
- {
return FALSE;
- }
}
-static u8 sub_8019978(u32 a0, u32 a1)
+static u8 GetUnionRoomPlayerGraphicsId(u32 gender, u32 id)
{
- return gUnknown_082F072C[a0][a1 % 8];
+ return sUnionRoomObjGfxIds[gender][id % MAX_UNION_ROOM_PLAYERS];
}
-static void sub_8019990(u32 a0, u32 a1, s32 * a2, s32 * a3)
+static void GetUnionRoomPlayerFacingCoords(u32 playerIdx, u32 direction, s32 * x, s32 * y)
{
- *a2 = gUnknown_082F0740[a0][0] + gUnknown_082F0760[a1][0] + 7;
- *a3 = gUnknown_082F0740[a0][1] + gUnknown_082F0760[a1][1] + 7;
+ *x = sUnionRoomPlayerCoords[playerIdx][0] + sFacingDirectionOffsets[direction][0] + 7;
+ *y = sUnionRoomPlayerCoords[playerIdx][1] + sFacingDirectionOffsets[direction][1] + 7;
}
-static bool32 sub_80199E0(u32 a0, u32 a1, s32 a2, s32 a3)
+static bool32 IsUnionRoomPlayerFacingTileAt(u32 playerIdx, u32 direction, s32 x, s32 y)
{
- if (gUnknown_082F0740[a0][0] + gUnknown_082F0760[a1][0] + 7 != a2)
- {
- return FALSE;
- }
- else if (gUnknown_082F0740[a0][1] + gUnknown_082F0760[a1][1] + 7 != a3)
- {
- return FALSE;
- }
- else
- {
+ if ((sUnionRoomPlayerCoords[playerIdx][0] + sFacingDirectionOffsets[direction][0] + 7 == x)
+ && (sUnionRoomPlayerCoords[playerIdx][1] + sFacingDirectionOffsets[direction][1] + 7 == y))
return TRUE;
- }
+ else
+ return FALSE;
}
static bool32 IsUnionRoomPlayerHidden(u32 player_idx)
@@ -126,19 +152,19 @@ static void SetUnionRoomPlayerGfx(u32 playerIdx, u32 gfxId)
static void CreateUnionRoomPlayerObjectEvent(u32 playerIdx)
{
- TrySpawnObjectEvent(gUnknown_082F0774[playerIdx], gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
+ TrySpawnObjectEvent(sUnionRoomLocalIds[playerIdx], gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
}
static void RemoveUnionRoomPlayerObjectEvent(u32 playerIdx)
{
- RemoveObjectEventByLocalIdAndMap(gUnknown_082F0774[playerIdx], gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
+ RemoveObjectEventByLocalIdAndMap(sUnionRoomLocalIds[playerIdx], gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
}
static bool32 SetUnionRoomPlayerEnterExitMovement(u32 playerIdx, const u8 * movement)
{
u8 objectId;
struct ObjectEvent * object;
- if (TryGetObjectEventIdByLocalIdAndMap(gUnknown_082F0774[playerIdx], gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objectId))
+ if (TryGetObjectEventIdByLocalIdAndMap(sUnionRoomLocalIds[playerIdx], gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objectId))
{
return FALSE;
}
@@ -154,11 +180,11 @@ static bool32 SetUnionRoomPlayerEnterExitMovement(u32 playerIdx, const u8 * move
return TRUE;
}
-static bool32 sub_8019B3C(u32 playerIdx)
+static bool32 TryReleaseUnionRoomPlayerObjectEvent(u32 playerIdx)
{
u8 objectId;
struct ObjectEvent * object;
- if (TryGetObjectEventIdByLocalIdAndMap(gUnknown_082F0774[playerIdx], gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objectId))
+ if (TryGetObjectEventIdByLocalIdAndMap(sUnionRoomLocalIds[playerIdx], gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objectId))
{
return TRUE;
}
@@ -178,39 +204,39 @@ static bool32 sub_8019B3C(u32 playerIdx)
return TRUE;
}
-u8 sub_8019BA8(struct UnkStruct_8019BA8 * ptr)
+u8 InitUnionRoomPlayerObjects(struct UnionRoomObject * players)
{
s32 i;
- gUnknown_02022C68 = 0;
- gUnknown_02022C64 = ptr;
- for (i = 0; i < 8; i++)
+ sUnionObjRefreshTimer = 0;
+ sUnionObjWork = players;
+ for (i = 0; i < MAX_UNION_ROOM_PLAYERS; i++)
{
- ptr[i].field_0 = 0;
- ptr[i].field_1 = 0;
- ptr[i].field_2 = 0;
- ptr[i].field_3 = 0;
+ players[i].state = 0;
+ players[i].gfxId = 0;
+ players[i].animState = 0;
+ players[i].schedAnim = UNION_ROOM_SPAWN_NONE;
}
- return sub_8019DF4();
+ return CreateTask_AnimateUnionRoomPlayers();
}
-static bool32 sub_8019BDC(s8 * a0, u32 playerIdx, struct UnkStruct_8019BA8 * ptr)
+static bool32 AnimateUnionRoomPlayerDespawn(s8 * state, u32 playerIdx, struct UnionRoomObject * ptr)
{
- switch (*a0)
+ switch (*state)
{
case 0:
- if (SetUnionRoomPlayerEnterExitMovement(playerIdx, gUnknown_082F078C) == TRUE)
+ if (SetUnionRoomPlayerEnterExitMovement(playerIdx, sMovement_UnionPlayerExit) == TRUE)
{
HideUnionRoomPlayer(playerIdx);
- (*a0)++;
+ (*state)++;
}
break;
case 1:
- if (sub_8019B3C(playerIdx))
+ if (TryReleaseUnionRoomPlayerObjectEvent(playerIdx))
{
RemoveUnionRoomPlayerObjectEvent(playerIdx);
HideUnionRoomPlayer(playerIdx);
- *a0 = 0;
+ *state = 0;
return TRUE;
}
break;
@@ -218,42 +244,42 @@ static bool32 sub_8019BDC(s8 * a0, u32 playerIdx, struct UnkStruct_8019BA8 * ptr
return FALSE;
}
-static bool32 sub_8019C38(s8 * a0, u32 playerIdx, struct UnkStruct_8019BA8 * ptr)
+static bool32 AnimateUnionRoomPlayerSpawn(s8 * state, u32 playerIdx, struct UnionRoomObject * ptr)
{
s16 x, y;
- switch (*a0)
+ switch (*state)
{
case 0:
- if (!is_walking_or_running())
+ if (!IsPlayerStandingStill())
{
break;
}
PlayerGetDestCoords(&x, &y);
- if (sub_80199E0(playerIdx, 0, x, y) == 1)
+ if (IsUnionRoomPlayerFacingTileAt(playerIdx, 0, x, y) == TRUE)
{
break;
}
player_get_pos_including_state_based_drift(&x, &y);
- if (sub_80199E0(playerIdx, 0, x, y) == 1)
+ if (IsUnionRoomPlayerFacingTileAt(playerIdx, 0, x, y) == TRUE)
{
break;
}
- SetUnionRoomPlayerGfx(playerIdx, ptr->field_1);
+ SetUnionRoomPlayerGfx(playerIdx, ptr->gfxId);
CreateUnionRoomPlayerObjectEvent(playerIdx);
ShowUnionRoomPlayer(playerIdx);
- (*a0)++;
+ (*state)++;
// fallthrough
case 3: // incorrect?
- if (SetUnionRoomPlayerEnterExitMovement(playerIdx, gUnknown_082F078E) == 1)
+ if (SetUnionRoomPlayerEnterExitMovement(playerIdx, sMovement_UnionPlayerEnter) == TRUE)
{
- (*a0)++;
+ (*state)++;
}
break;
case 2:
- if (sub_8019B3C(playerIdx))
+ if (TryReleaseUnionRoomPlayerObjectEvent(playerIdx))
{
- *a0 = 0;
+ *state = 0;
return TRUE;
}
break;
@@ -261,44 +287,38 @@ static bool32 sub_8019C38(s8 * a0, u32 playerIdx, struct UnkStruct_8019BA8 * ptr
return FALSE;
}
-static bool32 sub_8019CF0(u32 playerIdx, u32 a1, u32 a2)
+static bool32 SpawnGroupLeader(u32 playerIdx, u32 gender, u32 id)
{
- struct UnkStruct_8019BA8 * ptr = &gUnknown_02022C64[playerIdx];
- ptr->field_3 = 1;
- ptr->field_1 = sub_8019978(a1, a2);
- if (ptr->field_0 == 0)
- {
+ struct UnionRoomObject * ptr = &sUnionObjWork[playerIdx];
+ ptr->schedAnim = UNION_ROOM_SPAWN_IN;
+ ptr->gfxId = GetUnionRoomPlayerGraphicsId(gender, id);
+
+ if (ptr->state == 0)
return TRUE;
- }
else
- {
return FALSE;
- }
}
-static bool32 sub_8019D20(u32 playerIdx)
+static bool32 DespawnGroupLeader(u32 playerIdx)
{
- struct UnkStruct_8019BA8 * ptr = &gUnknown_02022C64[playerIdx];
- ptr->field_3 = 2;
- if (ptr->field_0 == 1)
- {
+ struct UnionRoomObject * ptr = &sUnionObjWork[playerIdx];
+ ptr->schedAnim = UNION_ROOM_SPAWN_OUT;
+
+ if (ptr->state == 1)
return TRUE;
- }
else
- {
return FALSE;
- }
}
-static void sub_8019D44(u32 playerIdx, struct UnkStruct_8019BA8 * ptr)
+static void AnimateUnionRoomPlayer(u32 playerIdx, struct UnionRoomObject * ptr)
{
- switch (ptr->field_0)
+ switch (ptr->state)
{
case 0:
- if (ptr->field_3 == 1)
+ if (ptr->schedAnim == UNION_ROOM_SPAWN_IN)
{
- ptr->field_0 = 2;
- ptr->field_2 = 0;
+ ptr->state = 2;
+ ptr->animState = 0;
}
else
{
@@ -306,23 +326,23 @@ static void sub_8019D44(u32 playerIdx, struct UnkStruct_8019BA8 * ptr)
}
// fallthrough
case 2:
- if (!sub_8019F8C(playerIdx, 0) && ptr->field_3 == 2)
+ if (!IsUnionRoomPlayerInvisible(playerIdx, 0) && ptr->schedAnim == UNION_ROOM_SPAWN_OUT)
{
- ptr->field_0 = 0;
- ptr->field_2 = 0;
+ ptr->state = 0;
+ ptr->animState = 0;
RemoveUnionRoomPlayerObjectEvent(playerIdx);
HideUnionRoomPlayer(playerIdx);
}
- else if (sub_8019C38(&ptr->field_2, playerIdx, ptr) == 1)
+ else if (AnimateUnionRoomPlayerSpawn(&ptr->animState, playerIdx, ptr) == TRUE)
{
- ptr->field_0 = 1;
+ ptr->state = 1;
}
break;
case 1:
- if (ptr->field_3 == 2)
+ if (ptr->schedAnim == UNION_ROOM_SPAWN_OUT)
{
- ptr->field_0 = 3;
- ptr->field_2 = 0;
+ ptr->state = 3;
+ ptr->animState = 0;
}
else
{
@@ -330,49 +350,43 @@ static void sub_8019D44(u32 playerIdx, struct UnkStruct_8019BA8 * ptr)
}
// fallthrough
case 3:
- if (sub_8019BDC(&ptr->field_2, playerIdx, ptr) == 1)
+ if (AnimateUnionRoomPlayerDespawn(&ptr->animState, playerIdx, ptr) == 1)
{
- ptr->field_0 = 0;
+ ptr->state = 0;
}
break;
}
- ptr->field_3 = 0;
+ ptr->schedAnim = UNION_ROOM_SPAWN_NONE;
}
-static void sub_8019DD0(u8 taskId)
+static void Task_AnimateUnionRoomPlayers(u8 taskId)
{
s32 i;
- for (i = 0; i < 8; i++)
- {
- sub_8019D44(i, &gUnknown_02022C64[i]);
- }
+ for (i = 0; i < MAX_UNION_ROOM_PLAYERS; i++)
+ AnimateUnionRoomPlayer(i, &sUnionObjWork[i]);
}
-static u8 sub_8019DF4(void)
+static u8 CreateTask_AnimateUnionRoomPlayers(void)
{
- if (FuncIsActiveTask(sub_8019DD0) == 1)
- {
+ if (FuncIsActiveTask(Task_AnimateUnionRoomPlayers) == TRUE)
return NUM_TASKS;
- }
else
- {
- return CreateTask(sub_8019DD0, 5);
- }
+ return CreateTask(Task_AnimateUnionRoomPlayers, 5);
}
-static void sub_8019E20(void)
+static void DestroyTask_AnimateUnionRoomPlayers(void)
{
- u8 taskId = FindTaskIdByFunc(sub_8019DD0);
+ u8 taskId = FindTaskIdByFunc(Task_AnimateUnionRoomPlayers);
if (taskId < NUM_TASKS)
{
DestroyTask(taskId);
}
}
-void sub_8019E3C(void)
+void DestroyUnionRoomPlayerObjects(void)
{
s32 i;
- for (i = 0; i < 8; i++)
+ for (i = 0; i < MAX_UNION_ROOM_PLAYERS; i++)
{
if (!IsUnionRoomPlayerHidden(i))
{
@@ -380,233 +394,232 @@ void sub_8019E3C(void)
HideUnionRoomPlayer(i);
}
}
- gUnknown_02022C64 = NULL;
- sub_8019E20();
+ sUnionObjWork = NULL;
+ DestroyTask_AnimateUnionRoomPlayers();
}
-void sub_8019E70(u8 * sp8, s32 r9)
+void CreateGroupMemberSpritesInvisible(u8 * spriteIds, s32 playerIdx)
{
- s32 r7;
+ s32 direction;
- for (r7 = 0; r7 < 5; r7++)
+ for (direction = DIR_NONE; direction <= DIR_EAST; direction++)
{
- s32 r5 = 5 * r9 + r7;
- sp8[r5] = sprite_new(OBJ_EVENT_GFX_MAN_4, r5 - 0x38, gUnknown_082F0740[r9][0] + gUnknown_082F0760[r7][0], gUnknown_082F0740[r9][1] + gUnknown_082F0760[r7][1], 3, 1);
- sub_8097C44(r5 - 0x38, TRUE);
+ s32 id = UR_PLAYER_SPRITE_ID(playerIdx, direction);
+ spriteIds[id] = CreateObjectSprite(OBJ_EVENT_GFX_MAN_4,
+ id - UR_SPRITE_START_ID,
+ sUnionRoomPlayerCoords[playerIdx][0] + sFacingDirectionOffsets[direction][0],
+ sUnionRoomPlayerCoords[playerIdx][1] + sFacingDirectionOffsets[direction][1],
+ 3, 1);
+ SetObjectEventSpriteInvisibility(id - UR_SPRITE_START_ID, TRUE);
}
}
-void sub_8019F04(u8 * r5)
+void DestroyGroupMemberSprites(u8 * spriteIds)
{
s32 i;
- for (i = 0; i < 40; i++)
- {
- DestroySprite(&gSprites[r5[i]]);
- }
+ for (i = 0; i < UR_PLAYER_SPRITE_ID(MAX_UNION_ROOM_PLAYERS, 0); i++)
+ DestroySprite(&gSprites[spriteIds[i]]);
}
-void sub_8019F2C(void)
+void SetTilesAroundUnionRoomPlayersPassable(void)
{
- s32 i, j, x, y;
- for (i = 0; i < 8; i++)
+ s32 i, direction, x, y;
+ for (i = 0; i < MAX_UNION_ROOM_PLAYERS; i++)
{
- for (j = 0; j < 5; j++)
+ for (direction = DIR_NONE; direction <= DIR_EAST; direction++)
{
- sub_8019990(i, j, &x, &y);
- sub_8088B94(x, y, 0);
+ GetUnionRoomPlayerFacingCoords(i, direction, &x, &y);
+ MapGridSetMetatileImpassabilityAt(x, y, FALSE);
}
}
}
-static u8 sub_8019F64(u32 r1, u32 unused, struct GFtgtGname * r2)
+static u8 GetNewFacingDirectionForUnionRoomPlayer(u32 direction, u32 playerIdx, struct GFtgtGname * gname)
{
- if (r1 != 0)
- {
- return gUnknown_082F076F[r1];
- }
- else if (r2->activity == 0x45)
- {
- return 1;
- }
+ if (direction != DIR_NONE)
+ return sNextFacingDirection[direction];
+ else if (gname->activity == (ACTIVITY_CHAT | IN_UNION_ROOM))
+ return DIR_SOUTH;
else
- {
- return 4;
- }
+ return DIR_EAST;
}
-static u32 sub_8019F8C(u32 a0, u32 a1)
+static bool32 IsUnionRoomPlayerInvisible(u32 playerIdx, u32 direction)
{
- return sub_8097C8C(5 * a0 + a1 - 0x38);
+ return IsObjectEventSpriteInvisible(UR_PLAYER_SPRITE_ID(playerIdx, direction) - UR_SPRITE_START_ID);
}
-static void sub_8019FA4(u32 r5, u32 r6, u8 r8, struct GFtgtGname * r9)
+static void SpawnGroupMember(u32 playerIdx, u32 direction, u8 graphicsId, struct GFtgtGname * gname)
{
s32 x, y;
- s32 r7 = 5 * r5 + r6;
- if (sub_8019F8C(r5, r6) == 1)
+ s32 id = UR_PLAYER_SPRITE_ID(playerIdx, direction);
+ if (IsUnionRoomPlayerInvisible(playerIdx, direction) == TRUE)
{
- sub_8097C44(r7 - 0x38, FALSE);
- sub_8097CC4(r7 - 0x38, 1);
+ SetObjectEventSpriteInvisibility(id - UR_SPRITE_START_ID, FALSE);
+ SetObjectEventSpriteAnim(id - UR_SPRITE_START_ID, UNION_ROOM_SPAWN_IN);
}
- sub_8097BB4(r7 - 0x38, r8);
- sub_801A3B0(r6, r5, sub_8019F64(r6, r5, r9));
- sub_8019990(r5, r6, &x, &y);
- sub_8088B94(x, y, 1);
+ SetObjectEventSpriteGraphics(id - UR_SPRITE_START_ID, graphicsId);
+ SetUnionRoomObjectFacingDirection(direction, playerIdx, GetNewFacingDirectionForUnionRoomPlayer(direction, playerIdx, gname));
+ GetUnionRoomPlayerFacingCoords(playerIdx, direction, &x, &y);
+ MapGridSetMetatileImpassabilityAt(x, y, TRUE);
}
-static void sub_801A02C(u32 a0, u32 a1)
+static void DespawnGroupMember(u32 playerIdx, u32 direction)
{
s32 x, y;
- sub_8097CC4(5 * a0 + a1 - 0x38, 2);
- sub_8019990(a0, a1, &x, &y);
- sub_8088B94(x, y, 0);
+ SetObjectEventSpriteAnim(UR_PLAYER_SPRITE_ID(playerIdx, direction) - UR_SPRITE_START_ID, UNION_ROOM_SPAWN_OUT);
+ GetUnionRoomPlayerFacingCoords(playerIdx, direction, &x, &y);
+ MapGridSetMetatileImpassabilityAt(x, y, FALSE);
}
-static void sub_801A064(u32 r7, struct GFtgtGname * r8)
+static void AssembleGroup(u32 playerIdx, struct GFtgtGname * gname)
{
s16 x, y, x2, y2;
s32 i;
PlayerGetDestCoords(&x, &y);
player_get_pos_including_state_based_drift(&x2, &y2);
- if (sub_8097C8C(5 * r7 - 0x38) == 1)
+ if (IsObjectEventSpriteInvisible(UR_PLAYER_SPRITE_ID(playerIdx, 0) - UR_SPRITE_START_ID) == TRUE)
{
- if (sub_80199E0(r7, 0, x, y) == 1 || sub_80199E0(r7, 0, x2, y2) == 1)
+ if (IsUnionRoomPlayerFacingTileAt(playerIdx, 0, x, y) == TRUE || IsUnionRoomPlayerFacingTileAt(playerIdx, 0, x2, y2) == TRUE)
{
return;
}
- sub_8019FA4(r7, 0, sub_8019978(r8->playerGender, r8->unk_00.playerTrainerId[0]), r8);
+ SpawnGroupMember(playerIdx, 0, GetUnionRoomPlayerGraphicsId(gname->playerGender, gname->unk_00.playerTrainerId[0]), gname);
}
for (i = 1; i < 5; i++)
{
- if (r8->child_sprite_gender[i - 1] == 0)
+ if (gname->child_sprite_gender[i - 1] == 0)
{
- sub_801A02C(r7, i);
+ DespawnGroupMember(playerIdx, i);
}
- else if (sub_80199E0(r7, i, x, y) == 0 && sub_80199E0(r7, i, x2, y2) == 0)
+ else if (IsUnionRoomPlayerFacingTileAt(playerIdx, i, x, y) == FALSE && IsUnionRoomPlayerFacingTileAt(playerIdx, i, x2, y2) == FALSE)
{
- sub_8019FA4(r7, i, sub_8019978((r8->child_sprite_gender[i - 1] >> 3) & 1, r8->child_sprite_gender[i - 1] & 7), r8);
+ SpawnGroupMember(playerIdx, i, GetUnionRoomPlayerGraphicsId((gname->child_sprite_gender[i - 1] >> 3) & 1, gname->child_sprite_gender[i - 1] & 7), gname);
}
}
}
-static void sub_801A16C(u32 r5, struct GFtgtGname * r4)
+static void SpawnGroupLeaderAndMembers(u32 playerIdx, struct GFtgtGname * gname)
{
u32 i;
- switch (r4->activity)
+ switch (gname->activity)
{
- case 0x40:
- case 0x54:
- sub_8019CF0(r5, r4->playerGender, r4->unk_00.playerTrainerId[0]);
+ case ACTIVITY_NONE | IN_UNION_ROOM:
+ case ACTIVITY_PLYRTALK | IN_UNION_ROOM:
+ SpawnGroupLeader(playerIdx, gname->playerGender, gname->unk_00.playerTrainerId[0]);
for (i = 0; i < 5; i++)
{
- sub_801A02C(r5, i);
+ DespawnGroupMember(playerIdx, i);
}
break;
- case 0x41:
- case 0x44:
- case 0x45:
- case 0x48:
- case 0x51:
- case 0x52:
- case 0x53:
- sub_8019D20(r5);
- sub_801A064(r5, r4);
+ case ACTIVITY_BATTLE_SINGLE | IN_UNION_ROOM:
+ case ACTIVITY_TRADE | IN_UNION_ROOM:
+ case ACTIVITY_CHAT | IN_UNION_ROOM:
+ case ACTIVITY_CARD | IN_UNION_ROOM:
+ case ACTIVITY_ACCEPT | IN_UNION_ROOM:
+ case ACTIVITY_DECLINE | IN_UNION_ROOM:
+ case ACTIVITY_NPCTALK | IN_UNION_ROOM:
+ DespawnGroupLeader(playerIdx);
+ AssembleGroup(playerIdx, gname);
break;
}
}
-static void sub_801A214(u32 r5, struct GFtgtGname * unused)
+static void DespawnGroupLeaderAndMembers(u32 r5, struct GFtgtGname *gname)
{
s32 i;
- sub_8019D20(r5);
+ DespawnGroupLeader(r5);
for (i = 0; i < 5; i++)
{
- sub_801A02C(r5, i);
+ DespawnGroupMember(r5, i);
}
}
-static void sub_801A234(struct UnkStruct_URoom *r0)
+static void UpdateUnionRoomPlayerSprites(struct WirelessLink_URoom *uroom)
{
s32 i;
struct UnkStruct_x20 * r4;
- gUnknown_02022C68 = 0;
- for (i = 0, r4 = r0->field_0->arr; i < 8; i++)
+ sUnionObjRefreshTimer = 0;
+ for (i = 0, r4 = uroom->field_0->arr; i < MAX_UNION_ROOM_PLAYERS; i++)
{
- if (r4[i].field_1A_0 == 1)
+ if (r4[i].groupScheduledAnim == UNION_ROOM_SPAWN_IN)
{
- sub_801A16C(i, &r4[i].unk.field_0);
+ SpawnGroupLeaderAndMembers(i, &r4[i].gname_uname.gname);
}
- else if (r4[i].field_1A_0 == 2)
+ else if (r4[i].groupScheduledAnim == UNION_ROOM_SPAWN_OUT)
{
- sub_801A214(i, &r4[i].unk.field_0);
+ DespawnGroupLeaderAndMembers(i, &r4[i].gname_uname.gname);
}
}
}
-void sub_801A274(struct UnkStruct_URoom *unused)
+void ScheduleUnionRoomPlayerRefresh(struct WirelessLink_URoom *uroom)
{
- gUnknown_02022C68 = 300;
+ sUnionObjRefreshTimer = 300;
}
-void sub_801A284(struct UnkStruct_URoom *r2)
+void HandleUnionRoomPlayerRefresh(struct WirelessLink_URoom *uroom)
{
- if (++gUnknown_02022C68 > 300)
+ if (++sUnionObjRefreshTimer > 300)
{
- sub_801A234(r2);
+ UpdateUnionRoomPlayerSprites(uroom);
}
}
-bool32 sub_801A2A8(struct UnkStruct_Main0 *arg0, s16 *arg1, s16 *arg2, u8 *arg3)
+bool32 TryInteractWithUnionRoomMember(struct UnkStruct_Main0 *main0, s16 *directionPtr, s16 *playerIdxPtr, u8 *spriteIds)
{
s16 x, y;
- s32 i, j;
+ s32 i, direction;
struct UnkStruct_x20 * r4;
- if (!is_walking_or_running())
+ if (!IsPlayerStandingStill())
{
return FALSE;
}
GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
- for (i = 0, r4 = arg0->arr; i < 8; i++)
+ for (i = 0, r4 = main0->arr; i < MAX_UNION_ROOM_PLAYERS; i++)
{
- for (j = 0; j < 5; j++)
+ for (direction = DIR_NONE; direction <= DIR_EAST; direction++)
{
- s32 r3 = 5 * i + j;
- if (x != gUnknown_082F0740[i][0] + gUnknown_082F0760[j][0] + 7)
+ s32 id = UR_PLAYER_SPRITE_ID(i, direction);
+ if (x != sUnionRoomPlayerCoords[i][0] + sFacingDirectionOffsets[direction][0] + 7)
{
continue;
}
- if (y != gUnknown_082F0740[i][1] + gUnknown_082F0760[j][1] + 7)
+ if (y != sUnionRoomPlayerCoords[i][1] + sFacingDirectionOffsets[direction][1] + 7)
{
continue;
}
- if (sub_8097C8C(r3 - 0x38) != 0)
+ if (IsObjectEventSpriteInvisible(id - UR_SPRITE_START_ID))
{
continue;
}
- if (sub_8097D9C(r3 - 0x38) != 0)
+ if (IsObjectEventSpriteAnimating(id - UR_SPRITE_START_ID))
{
continue;
}
- if (r4[i].field_1A_0 != 1)
+ if (r4[i].groupScheduledAnim != UNION_ROOM_SPAWN_IN)
{
continue;
}
- sub_801A3B0(j, i, gUnknown_082F076A[GetPlayerFacingDirection()]);
- *arg1 = j;
- *arg2 = i;
+ // Face player
+ SetUnionRoomObjectFacingDirection(direction, i, sOppositeFacingDirection[GetPlayerFacingDirection()]);
+ *directionPtr = direction;
+ *playerIdxPtr = i;
return TRUE;
}
}
return FALSE;
}
-static void sub_801A3B0(s32 arg0, s32 arg1, u8 arg2)
+static void SetUnionRoomObjectFacingDirection(s32 currDirection, s32 playerIdx, u8 newDirection)
{
- sub_8097B78(5 * arg1 - 0x38 + arg0, arg2);
+ TurnObjectEventSprite(5 * playerIdx - UR_SPRITE_START_ID + currDirection, newDirection);
+ // should be line below, but order is swapped here
+ // TurnObjectEventSprite(UR_PLAYER_SPRITE_ID(playerIdx, currDirection) - UR_SPRITE_START_ID, newDirection);
}
-void sub_801A3D0(u32 arg0, u32 arg1, struct UnkStruct_Main0 *arg2)
+void UpdateUnionRoomMemberFacing(u32 currDirection, u32 playerIdx, struct UnkStruct_Main0 *main0)
{
- return sub_801A3B0(arg0, arg1, sub_8019F64(arg0, arg1, &arg2->arr[arg1].unk.field_0));
+ return SetUnionRoomObjectFacingDirection(currDirection, playerIdx, GetNewFacingDirectionForUnionRoomPlayer(currDirection, playerIdx, &main0->arr[playerIdx].gname_uname.gname));
}
diff --git a/src/wireless_communication_status_screen.c b/src/wireless_communication_status_screen.c
new file mode 100644
index 000000000..87b200f14
--- /dev/null
+++ b/src/wireless_communication_status_screen.c
@@ -0,0 +1,432 @@
+#include "global.h"
+#include "task.h"
+#include "bg.h"
+#include "palette.h"
+#include "gpu_regs.h"
+#include "malloc.h"
+#include "scanline_effect.h"
+#include "m4a.h"
+#include "dynamic_placeholder_text_util.h"
+#include "overworld.h"
+#include "strings.h"
+#include "string_util.h"
+#include "international_string_util.h"
+#include "sound.h"
+#include "menu.h"
+#include "librfu.h"
+#include "link_rfu.h"
+#include "union_room.h"
+#include "constants/songs.h"
+#include "constants/union_room.h"
+
+enum {
+ COLORMODE_NORMAL,
+ COLORMODE_WHITE_LGRAY,
+ COLORMODE_RED,
+ COLORMODE_GREEN,
+ COLORMODE_WHITE_DGRAY,
+};
+
+#define GROUPTYPE_TRADE 0
+#define GROUPTYPE_BATTLE 1
+#define GROUPTYPE_UNION 2
+#define GROUPTYPE_TOTAL 3
+#define GROUPTYPE_NONE -1
+#define NUM_GROUPTYPES 4
+
+struct WirelessCommunicationStatusScreen
+{
+ u32 groupCounts[NUM_GROUPTYPES];
+ u32 prevGroupCounts[NUM_GROUPTYPES];
+ u32 activities[NUM_TASK_DATA];
+ u8 taskId;
+ u8 rfuTaskId;
+ u8 filler[10];
+};
+
+static struct WirelessCommunicationStatusScreen * sStatusScreen;
+
+static void CB2_InitWirelessCommunicationScreen(void);
+static void Task_WirelessCommunicationScreen(u8);
+static void WCSS_AddTextPrinterParameterized(u8, u8, const u8 *, u8, u8, u8);
+static bool32 UpdateCommunicationCounts(u32 *, u32 *, u32 *, u8);
+
+static const u16 sBgTiles_Pal[] = INCBIN_U16("graphics/interface/wireless_info_screen.gbapal");
+static const u32 sBgTiles_Gfx[] = INCBIN_U32("graphics/interface/wireless_info_screen.4bpp.lz");
+static const u32 sBgTiles_Tilemap[] = INCBIN_U32("graphics/interface/wireless_info_screen.bin.lz");
+
+static const struct BgTemplate sBgTemplates[] = {
+ {
+ .bg = 0,
+ .charBaseIndex = 2,
+ .mapBaseIndex = 31,
+ .priority = 0
+ }, {
+ .bg = 1,
+ .charBaseIndex = 0,
+ .mapBaseIndex = 8,
+ .priority = 1
+ }
+};
+
+static const struct WindowTemplate sWindowTemplates[] = {
+ {
+ .bg = 0,
+ .tilemapLeft = 3,
+ .tilemapTop = 0,
+ .width = 24,
+ .height = 3,
+ .paletteNum = 15,
+ .baseBlock = 0x0001
+ }, {
+ .bg = 0,
+ .tilemapLeft = 3,
+ .tilemapTop = 4,
+ .width = 21,
+ .height = 15,
+ .paletteNum = 15,
+ .baseBlock = 0x0049
+ }, {
+ .bg = 0,
+ .tilemapLeft = 24,
+ .tilemapTop = 4,
+ .width = 3,
+ .height = 15,
+ .paletteNum = 15,
+ .baseBlock = 0x0184
+ }, DUMMY_WIN_TEMPLATE
+};
+
+static const u8 *const sHeaderTexts[NUM_GROUPTYPES + 1] = {
+ [0] = gText_WirelessCommStatus,
+ [GROUPTYPE_TRADE + 1] = gText_PeopleTrading,
+ [GROUPTYPE_BATTLE + 1] = gText_PeopleBattling,
+ [GROUPTYPE_UNION + 1] = gText_PeopleInUnionRoom,
+ [GROUPTYPE_TOTAL + 1] = gText_PeopleCommunicating
+};
+
+// Activity, group type, number of players
+// 0 players means the number of players can change and should be counted dynamically
+// GROUPTYPE_TOTAL have no unique group and are simply counted in the total of "people communicating"
+// UB: GROUPTYPE_NONE (-1) can potentially be used as an index into a u8[4] in CountPlayersInGroupAndGetActivity
+static const u8 sActivityGroupInfo[][3] = {
+ {ACTIVITY_BATTLE_SINGLE, GROUPTYPE_BATTLE, 2},
+ {ACTIVITY_BATTLE_DOUBLE, GROUPTYPE_BATTLE, 2},
+ {ACTIVITY_BATTLE_MULTI, GROUPTYPE_BATTLE, 4},
+ {ACTIVITY_TRADE, GROUPTYPE_TRADE, 2},
+ {ACTIVITY_WONDER_CARD, GROUPTYPE_TOTAL, 2},
+ {ACTIVITY_WONDER_NEWS, GROUPTYPE_TOTAL, 2},
+ {ACTIVITY_POKEMON_JUMP, GROUPTYPE_TOTAL, 0},
+ {ACTIVITY_BERRY_CRUSH, GROUPTYPE_TOTAL, 0},
+ {ACTIVITY_BERRY_PICK, GROUPTYPE_TOTAL, 0},
+ {ACTIVITY_SEARCH, GROUPTYPE_NONE, 0},
+ {ACTIVITY_SPIN_TRADE, GROUPTYPE_TRADE, 0},
+ {ACTIVITY_BERRY_BLENDER, GROUPTYPE_TOTAL, 0},
+ {ACTIVITY_RECORD_CORNER, GROUPTYPE_TOTAL, 0},
+ {ACTIVITY_NONE | IN_UNION_ROOM, GROUPTYPE_UNION, 1},
+ {ACTIVITY_BATTLE_SINGLE | IN_UNION_ROOM, GROUPTYPE_UNION, 2},
+ {ACTIVITY_TRADE | IN_UNION_ROOM, GROUPTYPE_UNION, 2},
+ {ACTIVITY_CHAT | IN_UNION_ROOM, GROUPTYPE_UNION, 0},
+ {ACTIVITY_CARD | IN_UNION_ROOM, GROUPTYPE_UNION, 2},
+ {ACTIVITY_PLYRTALK | IN_UNION_ROOM, GROUPTYPE_UNION, 1},
+ {ACTIVITY_NPCTALK | IN_UNION_ROOM, GROUPTYPE_UNION, 2},
+ {ACTIVITY_ACCEPT | IN_UNION_ROOM, GROUPTYPE_UNION, 1},
+ {ACTIVITY_DECLINE | IN_UNION_ROOM, GROUPTYPE_UNION, 1},
+ {ACTIVITY_WONDER_CARD2, GROUPTYPE_TOTAL, 2},
+ {ACTIVITY_WONDER_NEWS2, GROUPTYPE_TOTAL, 2},
+ {ACTIVITY_CONTEST_COOL, GROUPTYPE_TOTAL, 0},
+ {ACTIVITY_CONTEST_BEAUTY, GROUPTYPE_TOTAL, 0},
+ {ACTIVITY_CONTEST_CUTE, GROUPTYPE_TOTAL, 0},
+ {ACTIVITY_CONTEST_SMART, GROUPTYPE_TOTAL, 0},
+ {ACTIVITY_CONTEST_TOUGH, GROUPTYPE_TOTAL, 0},
+ {ACTIVITY_BATTLE_TOWER, GROUPTYPE_BATTLE, 2},
+ {ACTIVITY_BATTLE_TOWER_OPEN, GROUPTYPE_BATTLE, 2}
+};
+
+static void CB2_RunWirelessCommunicationScreen(void)
+{
+ if (!IsDma3ManagerBusyWithBgCopy())
+ {
+ RunTasks();
+ RunTextPrinters();
+ AnimateSprites();
+ BuildOamBuffer();
+ UpdatePaletteFade();
+ }
+}
+
+static void VBlankCB_WirelessCommunicationScreen(void)
+{
+ LoadOam();
+ ProcessSpriteCopyRequests();
+ TransferPlttBuffer();
+}
+
+void ShowWirelessCommunicationScreen(void)
+{
+ SetMainCallback2(CB2_InitWirelessCommunicationScreen);
+}
+
+static void CB2_InitWirelessCommunicationScreen(void)
+{
+ SetGpuReg(REG_OFFSET_DISPCNT, 0);
+ sStatusScreen = AllocZeroed(sizeof(struct WirelessCommunicationStatusScreen));
+ SetVBlankCallback(NULL);
+ ResetBgsAndClearDma3BusyFlags(0);
+ InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates));
+ SetBgTilemapBuffer(1, Alloc(0x800));
+ SetBgTilemapBuffer(0, Alloc(0x800));
+ DecompressAndLoadBgGfxUsingHeap(1, sBgTiles_Gfx, 0, 0, 0);
+ CopyToBgTilemapBuffer(1, sBgTiles_Tilemap, 0, 0);
+ InitWindows(sWindowTemplates);
+ DeactivateAllTextPrinters();
+ ResetPaletteFade();
+ ResetSpriteData();
+ ResetTasks();
+ ScanlineEffect_Stop();
+ m4aSoundVSyncOn();
+ SetVBlankCallback(VBlankCB_WirelessCommunicationScreen);
+ sStatusScreen->taskId = CreateTask(Task_WirelessCommunicationScreen, 0);
+ sStatusScreen->rfuTaskId = CreateTask_ListenToWireless();
+ sStatusScreen->prevGroupCounts[GROUPTYPE_TOTAL] = 1;
+ ChangeBgX(0, 0, 0);
+ ChangeBgY(0, 0, 0);
+ ChangeBgX(1, 0, 0);
+ ChangeBgY(1, 0, 0);
+ LoadPalette(sBgTiles_Pal, 0x00, 0x20);
+ Menu_LoadStdPalAt(0xF0);
+ DynamicPlaceholderTextUtil_Reset();
+ FillBgTilemapBufferRect(0, 0, 0, 0, 32, 32, 0x0F);
+ CopyBgTilemapBufferToVram(1);
+ SetMainCallback2(CB2_RunWirelessCommunicationScreen);
+ RunTasks();
+ RunTextPrinters();
+ AnimateSprites();
+ BuildOamBuffer();
+ UpdatePaletteFade();
+}
+
+static void CB2_ExitWirelessCommunicationStatusScreen(void)
+{
+ s32 i;
+ FreeAllWindowBuffers();
+ for (i = 0; i < (int)ARRAY_COUNT(sBgTemplates); i++)
+ {
+ Free(GetBgTilemapBuffer(i));
+ }
+ Free(sStatusScreen);
+ SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
+}
+
+static void WCSS_CyclePalette(s16 * counter, s16 * palIdx)
+{
+ if (++(*counter) > 5)
+ {
+ if (++(*palIdx) == 14)
+ *palIdx = 0;
+
+ *counter = 0;
+ }
+ LoadPalette(sBgTiles_Pal + 16 * (*palIdx + 2), 0, 0x10);
+}
+
+static void PrintHeaderTexts(void)
+{
+ s32 i;
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
+ FillWindowPixelBuffer(2, PIXEL_FILL(0));
+ WCSS_AddTextPrinterParameterized(0, 1, sHeaderTexts[0], GetStringCenterAlignXOffset(1, sHeaderTexts[0], 0xC0), 6, COLORMODE_GREEN);
+ for (i = 0; i < (int)ARRAY_COUNT(*sHeaderTexts) - 1; i++)
+ {
+ WCSS_AddTextPrinterParameterized(1, 1, sHeaderTexts[i + 1], 0, 30 * i + 8, COLORMODE_WHITE_LGRAY);
+ }
+ WCSS_AddTextPrinterParameterized(1, 1, sHeaderTexts[i + 1], 0, 30 * i + 8, COLORMODE_RED);
+ PutWindowTilemap(0);
+ CopyWindowToVram(0, 2);
+ PutWindowTilemap(1);
+ CopyWindowToVram(1, 2);
+}
+
+#define tState data[0]
+
+static void Task_WirelessCommunicationScreen(u8 taskId)
+{
+ s32 i;
+ switch (gTasks[taskId].tState)
+ {
+ case 0:
+ PrintHeaderTexts();
+ gTasks[taskId].tState++;
+ break;
+ case 1:
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0);
+ ShowBg(1);
+ CopyBgTilemapBufferToVram(0);
+ ShowBg(0);
+ gTasks[taskId].tState++;
+ break;
+ case 2:
+ if (!gPaletteFade.active)
+ {
+ gTasks[taskId].tState++;
+ }
+ break;
+ case 3:
+ if (UpdateCommunicationCounts(sStatusScreen->groupCounts, sStatusScreen->prevGroupCounts, sStatusScreen->activities, sStatusScreen->rfuTaskId))
+ {
+ FillWindowPixelBuffer(2, PIXEL_FILL(0));
+ for (i = 0; i < NUM_GROUPTYPES; i++)
+ {
+ ConvertIntToDecimalStringN(gStringVar4, sStatusScreen->groupCounts[i], STR_CONV_MODE_RIGHT_ALIGN, 2);
+ if (i != GROUPTYPE_TOTAL)
+ WCSS_AddTextPrinterParameterized(2, 1, gStringVar4, 12, 30 * i + 8, COLORMODE_WHITE_LGRAY);
+ else
+ WCSS_AddTextPrinterParameterized(2, 1, gStringVar4, 12, 98, COLORMODE_RED);
+ }
+ PutWindowTilemap(2);
+ CopyWindowToVram(2, 3);
+ }
+ if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON))
+ {
+ PlaySE(SE_SELECT);
+ gTasks[sStatusScreen->rfuTaskId].data[15] = 0xFF;
+ gTasks[taskId].tState++;
+ }
+ WCSS_CyclePalette(&gTasks[taskId].data[7], &gTasks[taskId].data[8]);
+ break;
+ case 4:
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0);
+ gTasks[taskId].tState++;
+ break;
+ case 5:
+ if (!gPaletteFade.active)
+ {
+ SetMainCallback2(CB2_ExitWirelessCommunicationStatusScreen);
+ DestroyTask(taskId);
+ }
+ break;
+ }
+}
+
+#undef tState
+
+static void WCSS_AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 * str, u8 x, u8 y, u8 mode)
+{
+ u8 color[3];
+
+ switch (mode)
+ {
+ case COLORMODE_NORMAL:
+ color[0] = TEXT_COLOR_TRANSPARENT;
+ color[1] = TEXT_COLOR_DARK_GREY;
+ color[2] = TEXT_COLOR_LIGHT_GREY;
+ break;
+ case COLORMODE_WHITE_LGRAY:
+ color[0] = TEXT_COLOR_TRANSPARENT;
+ color[1] = TEXT_COLOR_WHITE;
+ color[2] = TEXT_COLOR_LIGHT_GREY;
+ break;
+ case COLORMODE_RED:
+ color[0] = TEXT_COLOR_TRANSPARENT;
+ color[1] = TEXT_COLOR_RED;
+ color[2] = TEXT_COLOR_LIGHT_RED;
+ break;
+ case COLORMODE_GREEN:
+ color[0] = TEXT_COLOR_TRANSPARENT;
+ color[1] = TEXT_COLOR_LIGHT_GREEN;
+ color[2] = TEXT_COLOR_GREEN;
+ break;
+ case COLORMODE_WHITE_DGRAY:
+ color[0] = TEXT_COLOR_TRANSPARENT;
+ color[1] = TEXT_COLOR_WHITE;
+ color[2] = TEXT_COLOR_DARK_GREY;
+ break;
+ }
+
+ AddTextPrinterParameterized4(windowId, fontId, x, y, 0, 0, color, -1, str);
+}
+
+static u32 CountPlayersInGroupAndGetActivity(struct UnkStruct_x20 * unk20, u32 * groupCounts)
+{
+ int i, j, k;
+ u32 activity = unk20->gname_uname.gname.activity;
+
+ #define group_activity(i) (sActivityGroupInfo[(i)][0])
+ #define group_type(i) (sActivityGroupInfo[(i)][1])
+ #define group_players(i) (sActivityGroupInfo[(i)][2])
+
+ for (i = 0; i < ARRAY_COUNT(sActivityGroupInfo); i++)
+ {
+ if (activity == group_activity(i) && unk20->groupScheduledAnim == UNION_ROOM_SPAWN_IN)
+ {
+ if (group_players(i) == 0)
+ {
+ k = 0;
+ for (j = 0; j < RFU_CHILD_MAX; j++)
+ {
+ if (unk20->gname_uname.gname.child_sprite_gender[j] != 0) k++;
+ }
+ k++;
+ groupCounts[group_type(i)] += k;
+ }
+ else
+ {
+ groupCounts[group_type(i)] += group_players(i);
+ }
+ }
+ }
+ return activity;
+
+ #undef group_activity
+ #undef group_type
+ #undef group_players
+}
+
+static bool32 HaveCountsChanged(u32 * currCounts, u32 * prevCounts)
+{
+ s32 i;
+ for (i = 0; i < NUM_GROUPTYPES; i++)
+ {
+ if (currCounts[i] != prevCounts[i])
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static bool32 UpdateCommunicationCounts(u32 * groupCounts, u32 * prevGroupCounts, u32 * activities, u8 taskId)
+{
+ bool32 activitiesChanged = FALSE;
+ u32 groupCountBuffer[NUM_GROUPTYPES] = {0, 0, 0, 0};
+ struct UnkStruct_x20 ** data = (void *)gTasks[taskId].data;
+ s32 i;
+
+ for (i = 0; i < NUM_TASK_DATA; i++)
+ {
+ u32 activity = CountPlayersInGroupAndGetActivity(&(*data)[i], groupCountBuffer);
+ if (activity != activities[i])
+ {
+ activities[i] = activity;
+ activitiesChanged = TRUE;
+ }
+ }
+
+ if (!HaveCountsChanged(groupCountBuffer, prevGroupCounts))
+ {
+ if (activitiesChanged == TRUE)
+ return TRUE;
+ else
+ return FALSE;
+ }
+ else
+ {
+ memcpy(groupCounts, groupCountBuffer, sizeof(groupCountBuffer));
+ memcpy(prevGroupCounts, groupCountBuffer, sizeof(groupCountBuffer));
+
+ groupCounts[GROUPTYPE_TOTAL] = groupCounts[GROUPTYPE_TRADE]
+ + groupCounts[GROUPTYPE_BATTLE]
+ + groupCounts[GROUPTYPE_UNION]
+ + groupCounts[GROUPTYPE_TOTAL];
+ return TRUE;
+ }
+}
diff --git a/sym_bss.txt b/sym_bss.txt
index aad8c8f14..3166aee45 100644
--- a/sym_bss.txt
+++ b/sym_bss.txt
@@ -10,6 +10,7 @@
.include "src/link_rfu_3.o"
.include "src/link_rfu_2.o"
.include "src/union_room.o"
+ .include "src/wireless_communication_status_screen.o"
.include "src/union_room_battle.o"
.include "src/dodrio_berry_picking.o"
.include "src/rtc.o"
diff --git a/sym_ewram.txt b/sym_ewram.txt
index d00f7953c..88c4461cb 100644
--- a/sym_ewram.txt
+++ b/sym_ewram.txt
@@ -11,6 +11,7 @@
.include "src/union_room.o"
.include "src/mystery_gift.o"
.include "src/union_room_player_avatar.o"
+ .include "src/wireless_communication_status_screen.o"
.include "src/union_room_battle.o"
.include "src/mevent2.o"
.include "src/mevent_801BAAC.o"
@@ -74,7 +75,7 @@
.include "src/record_mixing.o"
.include "src/secret_base.o"
.include "src/tv.o"
- .include "src/contest_link_80F57C4.o"
+ .include "src/contest_util.o"
.include "src/rotating_gate.o"
.include "src/safari_zone.o"
.include "src/item_use.o"
@@ -103,7 +104,7 @@
.include "src/battle_transition.o"
.include "src/battle_message.o"
.include "src/cable_car.o"
- .include "src/rom_81520A8.o"
+ .include "src/confetti_util.o"
.include "src/save.o"
.include "src/mystery_event_script.o"
.include "src/move_relearner.o"