From d314bdb4fa6061fc8f288bae6c514df54047e79e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 29 Nov 2015 21:34:59 -0500 Subject: [PATCH] Pokedex labels --- battle/core.asm | 34 +- constants/map_setup_constants.asm | 92 +- constants/wram_constants.asm | 7 + engine/battle_start.asm | 4 +- engine/crystal_intro.asm | 20 +- engine/pokedex.asm | 910 +++++++++--------- engine/time_capsule/conversion.asm | 6 +- engine/warp_connection.asm | 440 +++++++++ event/photo.asm | 2 +- .../questionmark/front.2bpp.lz} | Bin .../pokedex.2bpp.lz} | Bin .../1ddf33.2bpp.lz => pokedex/sgb.2bpp.lz} | Bin home.asm | 4 +- home/map.asm | 4 +- main.asm | 651 +++---------- misc/fixed_words.asm | 2 +- misc/mobile_40.asm | 4 +- misc/mobile_41.asm | 2 +- misc/mobile_45.asm | 2 +- misc/mobile_46.asm | 2 +- misc/mobile_5f.asm | 4 +- wram.asm | 70 +- 22 files changed, 1150 insertions(+), 1110 deletions(-) create mode 100755 engine/warp_connection.asm rename gfx/{unknown/1de0e1.2bpp.lz => pics/questionmark/front.2bpp.lz} (100%) rename gfx/{unknown/04150e.2bpp.lz => pokedex/pokedex.2bpp.lz} (100%) rename gfx/{unknown/1ddf33.2bpp.lz => pokedex/sgb.2bpp.lz} (100%) diff --git a/battle/core.asm b/battle/core.asm index 70e9a24c9..08d3f2d3b 100644 --- a/battle/core.asm +++ b/battle/core.asm @@ -1430,8 +1430,8 @@ HandleMysteryberry: ; 3c93c ld a, [hBattleTurn] and a jr z, .wild - ld de, wc739 - ld hl, wc735 + ld de, wWildMonPP + ld hl, wWildMonMoves ld a, [wBattleMode] dec a jr z, .wild @@ -3643,13 +3643,13 @@ LoadEnemyPkmnToSwitchTo: ; 3d6ca ld a, [CurPartySpecies] cp UNOWN jr nz, .skip_unown - ld a, [wdef4] + ld a, [wFirstUnownSeen] and a jr nz, .skip_unown ld hl, EnemyMonDVs predef GetUnownLetter ld a, [UnownLetter] - ld [wdef4], a + ld [wFirstUnownSeen], a .skip_unown ld hl, EnemyMonHP @@ -6711,7 +6711,7 @@ endr ld bc, PKMN_NAME_LENGTH call CopyBytes -; Caught this mon +; Saw this mon ld a, [TempEnemyMonSpecies] dec a ld c, a @@ -8531,7 +8531,7 @@ BattleIntro: ; 3f4dd call ClearBox call ClearSprites ld a, [wBattleMode] - cp $1 + cp WILD_BATTLE call z, UpdateEnemyHUD ld a, $1 ld [hBGMapMode], a @@ -8560,9 +8560,9 @@ InitEnemy: ; 3f55e BackUpVBGMap2: ; 3f568 ld a, [rSVBK] push af - ld a, $6 ; BANK(w6_d000) + ld a, $6 ; BANK(wBackupTilemap) ld [rSVBK], a - ld hl, w6_d000 + ld hl, wBackupTilemap ld bc, $40 tiles ; VBGMap3 - VBGMap2 ld a, $2 call ByteFill @@ -8570,7 +8570,7 @@ BackUpVBGMap2: ; 3f568 push af ld a, $1 ld [rVBK], a - ld de, w6_d000 + ld de, wBackupTilemap hlbgcoord 0, 0 ; VBGMap2 lb bc, BANK(BackUpVBGMap2), $40 call Request2bpp @@ -8637,16 +8637,16 @@ InitEnemyTrainer: ; 3f594 ; 3f607 InitEnemyWildmon: ; 3f607 - ld a, $1 + ld a, WILD_BATTLE ld [wBattleMode], a callba MobileFn_10605d call LoadEnemyMon ld hl, EnemyMonMoves - ld de, wc735 + ld de, wWildMonMoves ld bc, NUM_MOVES call CopyBytes ld hl, EnemyMonPP - ld de, wc739 + ld de, wWildMonPP ld bc, NUM_MOVES call CopyBytes ld hl, EnemyMonDVs @@ -8654,11 +8654,11 @@ InitEnemyWildmon: ; 3f607 ld a, [CurPartySpecies] cp UNOWN jr nz, .skip_unown - ld a, [wdef4] + ld a, [wFirstUnownSeen] and a jr nz, .skip_unown ld a, [UnownLetter] - ld [wdef4], a + ld [wFirstUnownSeen], a .skip_unown ld de, VTiles2 predef FrontpicPredef @@ -9456,12 +9456,12 @@ InitBattleDisplay: ; 3fb6c ld a, $6 ld [rSVBK], a - ld hl, w6_d000 - ld bc, w6_d400 - w6_d000 + ld hl, wBackupTilemap + ld bc, wBackupAttrMap - wBackupTilemap ld a, " " call ByteFill - ld de, w6_d000 + ld de, wBackupTilemap hlbgcoord 0, 0 lb bc, BANK(.BlankBGMap), $40 call Request2bpp diff --git a/constants/map_setup_constants.asm b/constants/map_setup_constants.asm index 194257996..cc81a15cc 100644 --- a/constants/map_setup_constants.asm +++ b/constants/map_setup_constants.asm @@ -15,50 +15,50 @@ const_value SET $f1 ; Command descriptions from Condensation water's scripting compendium. const_def const_def - const map_lcd_on - const map_lcd_off - const map_sound_off - const map_music - const map_start_music - const map_fade_music - const map_fade - const map_bike_music - const map_music_force - const map_max_volume - const map_load_blocks - const map_connection_blocks - const map_save_screen - const map_buffer_screen - const map_load_graphics - const map_load_tileset_header - const map_time_of_day - const map_palettes - const map_wildmons - const map_sprites - const map_change_callback - const map_start_callback - const map_load_objects - const map_load_spawn - const map_load_connection - const map_load_warp - const map_attributes - const map_attributes_2 - const map_clear_bg_palettes - const map_fade_out_palettes - const map_fade_in_palettes - const map_anchor_screen - const map_warp_face - const map_face_down - const map_spawn_coord - const map_player_coord - const map_prolong_sprites - const map_delay_sprites - const map_update_roam - const map_keep_roam - const map_fade_out_music - const map_animations_on - const map_animations_off - const map_keep_palettes - const map_text_scroll_off - const map_stop_script + const map_lcd_on ; 00 + const map_lcd_off ; 01 + const map_sound_off ; 02 + const map_music ; 03 + const map_start_music ; 04 + const map_fade_music ; 05 + const map_fade ; 06 + const map_bike_music ; 07 + const map_music_force ; 08 + const map_max_volume ; 09 + const map_load_blocks ; 0a + const map_connection_blocks ; 0b + const map_save_screen ; 0c + const map_buffer_screen ; 0d + const map_load_graphics ; 0e + const map_load_tileset_header ; 0f + const map_time_of_day ; 10 + const map_palettes ; 11 + const map_wildmons ; 12 + const map_sprites ; 13 + const map_change_callback ; 14 + const map_start_callback ; 15 + const map_load_objects ; 16 + const map_load_spawn ; 17 + const map_load_connection ; 18 + const map_load_warp ; 19 + const map_attributes ; 1a + const map_attributes_2 ; 1b + const map_clear_bg_palettes ; 1c + const map_fade_out_palettes ; 1d + const map_fade_in_palettes ; 1e + const map_anchor_screen ; 1f + const map_warp_face ; 20 + const map_face_down ; 21 + const map_spawn_coord ; 22 + const map_player_coord ; 23 + const map_prolong_sprites ; 24 + const map_delay_sprites ; 25 + const map_update_roam ; 26 + const map_keep_roam ; 27 + const map_fade_out_music ; 28 + const map_animations_on ; 29 + const map_animations_off ; 2a + const map_keep_palettes ; 2b + const map_text_scroll_off ; 2c + const map_stop_script ; 2d map_end_setup_script EQU -1 diff --git a/constants/wram_constants.asm b/constants/wram_constants.asm index a8d348e6c..f7486fc83 100644 --- a/constants/wram_constants.asm +++ b/constants/wram_constants.asm @@ -96,3 +96,10 @@ PC_WITHDRAW EQU 0 PC_DEPOSIT EQU 1 DAYCARE_WITHDRAW EQU 2 DAYCARE_DEPOSIT EQU 3 + +; wCurrentDexMode + const_def + const DEXMODE_NEW + const DEXMODE_OLD + const DEXMODE_ABC + const DEXMODE_UNOWN diff --git a/engine/battle_start.asm b/engine/battle_start.asm index 845af9d2a..4ef26cae3 100644 --- a/engine/battle_start.asm +++ b/engine/battle_start.asm @@ -120,7 +120,7 @@ Function8c2cf: ; 8c2cf ld a, $6 ld [rSVBK], a push hl - ld hl, w6_d000 + ld hl, wBackupTilemap ld bc, $28 * $10 .loop @@ -132,7 +132,7 @@ Function8c2cf: ; 8c2cf jr nz, .loop pop hl - ld de, w6_d000 + ld de, wBackupTilemap ld b, BANK(Function8c2cf) ; BANK(@) ld c, $28 call Request2bpp diff --git a/engine/crystal_intro.asm b/engine/crystal_intro.asm index 3f764526d..beada9f84 100755 --- a/engine/crystal_intro.asm +++ b/engine/crystal_intro.asm @@ -79,17 +79,17 @@ Functione45e8: ; e45e8 ld [rSVBK], a ld hl, IntroLogoGFX - ld de, w6_d000 + ld de, wBackupTilemap ld a, BANK(IntroLogoGFX) call FarDecompress ld hl, VTiles0 - ld de, w6_d000 + ld de, wBackupTilemap lb bc, 1, 8 tiles call Request2bpp ld hl, VTiles1 - ld de, w6_d000 + $80 tiles + ld de, wBackupTilemap + $80 tiles lb bc, 1, 8 tiles call Request2bpp @@ -1886,7 +1886,7 @@ Functione541b: ; e541b (39:541b) push af ld a, $6 ld [rSVBK], a - ld hl, w6_d000 + ld hl, wBackupTilemap decoord 0, 0 ld b, SCREEN_HEIGHT .asm_e542a @@ -2000,10 +2000,10 @@ Functione54c2: ; e54c2 (39:54c2) ld a, $6 ld [rSVBK], a push de - ld de, w6_d000 + ld de, wBackupTilemap call Decompress pop hl - ld de, w6_d000 + ld de, wBackupTilemap ld bc, $180 call Request2bpp pop af @@ -2016,10 +2016,10 @@ Functione54de: ; e54de (39:54de) ld a, $6 ld [rSVBK], a push de - ld de, w6_d000 + ld de, wBackupTilemap call Decompress pop hl - ld de, w6_d000 + ld de, wBackupTilemap ld bc, $1ff call Request2bpp pop af @@ -2032,10 +2032,10 @@ Functione54fa: ; e54fa (39:54fa) ld a, $6 ld [rSVBK], a push de - ld de, w6_d000 + ld de, wBackupTilemap call Decompress pop hl - ld de, w6_d000 + ld de, wBackupTilemap ld bc, $140 call Request2bpp pop af diff --git a/engine/pokedex.asm b/engine/pokedex.asm index 78fe5fc45..25111dea1 100644 --- a/engine/pokedex.asm +++ b/engine/pokedex.asm @@ -31,7 +31,7 @@ Pokedex: ; 40000 ld a, [wJumptableIndex] bit 7, a jr nz, .exit - call Function4010b + call Pokedex_Main call DelayFrame jr .main @@ -40,8 +40,8 @@ Pokedex: ; 40000 call PlaySFX call WaitSFX call ClearSprites - ld a, [wc7d4] - ld [wd959], a + ld a, [wCurrentDexMode] + ld [wLastDexMode], a pop af ld [hInMenu], a @@ -63,7 +63,7 @@ InitPokedex: ; 40063 call ClearBGPalettes call ClearSprites call ClearTileMap - call Function414b7 + call Pokedex_LoadGFX ld hl, wPokedexDataStart ld bc, wPokedexDataEnd - wPokedexDataStart @@ -76,78 +76,78 @@ InitPokedex: ; 40063 ld [wcf65], a ld [wcf66], a - call Function400a2 + call Pokedex_CheckUnlockedUnownMode - ld a, [wd959] - ld [wc7d4], a + ld a, [wLastDexMode] + ld [wCurrentDexMode], a - call Function40bdc - call Function400b4 - call Function400ed + call Pokedex_ChangeMode + call Pokedex_InitCursorPosition + call Pokedex_GetLandmark callba Function1de247 - call Function41af7 + call Pokedex_ResetBGMapMode ret ; 400a2 -Function400a2: ; 400a2 +Pokedex_CheckUnlockedUnownMode: ; 400a2 ld a, [StatusFlags] bit 1, a - jr nz, .asm_400ae + jr nz, .unlocked xor a - ld [wc7dc], a + ld [wUnlockedUnownMode], a ret -.asm_400ae - ld a, 1 - ld [wc7dc], a +.unlocked + ld a, TRUE + ld [wUnlockedUnownMode], a ret ; 400b4 -Function400b4: ; 400b4 - ld hl, wc6d0 - ld a, [wc2d6] +Pokedex_InitCursorPosition: ; 400b4 + ld hl, wPokedexDataStart + ld a, [wLastDexEntry] and a - jr z, .asm_400ec - cp $fc - jr nc, .asm_400ec + jr z, .done + cp NUM_POKEMON + 1 + jr nc, .done ld b, a - ld a, [wc7d2] + ld a, [wDexListingEnd] cp $8 - jr c, .asm_400db + jr c, .only_one_page sub $7 ld c, a -.asm_400cc +.loop1 ld a, b cp [hl] - jr z, .asm_400ec + jr z, .done inc hl - ld a, [wc7d0] + ld a, [wDexListingPage] inc a - ld [wc7d0], a + ld [wDexListingPage], a dec c - jr nz, .asm_400cc + jr nz, .loop1 -.asm_400db +.only_one_page ld c, $7 -.asm_400dd +.loop2 ld a, b cp [hl] - jr z, .asm_400ec + jr z, .done inc hl - ld a, [wc7d1] + ld a, [wDexListingCursor] inc a - ld [wc7d1], a + ld [wDexListingCursor], a dec c - jr nz, .asm_400dd + jr nz, .loop2 -.asm_400ec +.done ret ; 400ed -Function400ed: ; 400ed +Pokedex_GetLandmark: ; 400ed ld a, [MapGroup] ld b, a ld a, [MapNumber] @@ -155,7 +155,7 @@ Function400ed: ; 400ed call GetWorldMapLocation cp SPECIAL_MAP - jr nz, .asm_40107 + jr nz, .load ld a, [BackupMapGroup] ld b, a @@ -163,20 +163,20 @@ Function400ed: ; 400ed ld c, a call GetWorldMapLocation -.asm_40107 - ld [wc7e4], a +.load + ld [wDexCurrentLocation], a ret ; 4010b -Function4010b: ; 4010b +Pokedex_Main: ; 4010b ld a, [wJumptableIndex] - ld hl, Jumptable_40115 - call Function41432 + ld hl, .Jumptable + call Pokedex_LoadPointer jp [hl] ; 40115 -Jumptable_40115: ; 40115 (10:4115) +.Jumptable: ; 40115 (10:4115) dw Function4013c dw Function401ae dw Function40217 @@ -188,17 +188,17 @@ Jumptable_40115: ; 40115 (10:4115) dw Function403be dw Function4050a dw Function40562 - dw Function405bd + dw Pokedex_UnownMode ; Unown Dex dw Function405df - dw Function40136 + dw Pokedex_CloseDex ; Exit -Function40131: ; 40131 (10:4131) +Pokedex_IncrementDexPointer: ; 40131 (10:4131) ld hl, wJumptableIndex inc [hl] ret -Function40136: ; 40136 (10:4136) +Pokedex_CloseDex: ; 40136 (10:4136) ld hl, wJumptableIndex set 7, [hl] ret @@ -209,45 +209,46 @@ Function4013c: ; 4013c (10:413c) call ClearSprites xor a hlcoord 0, 0, AttrMap - ld bc, $168 + ld bc, SCREEN_HEIGHT * SCREEN_WIDTH call ByteFill - callba Function1de171 + callba DrawPokedexListWindow hlcoord 0, 17 ld de, String_START_SEARCH - call Function40acd + call Pokedex_PlaceString ld a, $7 ld [wc7d3], a call Function40b0f - call Function41aeb - call Function41af7 + call Pokedex_SetBGMapMode_3ifDMG_4ifCGB + call Pokedex_ResetBGMapMode call Function4074c ld a, $5 ld [hSCX], a - ld a, [wc7d4] - cp $1 - ld a, $4a - jr z, .asm_4017b - ld a, $47 -.asm_4017b + ld a, [wCurrentDexMode] + cp DEXMODE_OLD + ld a, $4a + jr z, .okay + ld a, $47 +.okay ld [hWX], a xor a ld [hWY], a call WaitBGMap - call Function41af7 - ld a, $ff + + call Pokedex_ResetBGMapMode + ld a, -1 ld [CurPartySpecies], a ld a, $4 call Function41423 call Function41148 - callba Function1de171 + callba DrawPokedexListWindow hlcoord 0, 17 ld de, String_START_SEARCH - call Function40acd + call Pokedex_PlaceString ld a, $7 ld [wc7d3], a call Function40b0f - call Function40131 + call Pokedex_IncrementDexPointer ret Function401ae: ; 401ae (10:41ae) @@ -270,13 +271,13 @@ Function401ae: ; 401ae (10:41ae) xor a ld [hBGMapMode], a call Function40b0f - call Function41ad7 - call Function41af7 + call Pokedex_SetBGMapMode3 + call Pokedex_ResetBGMapMode ret .a - call Function40bb1 - call Function40bd0 + call Pokedex_GetMonAtCursorPosition + call Pokedex_CheckSeen ret z ld a, $2 ld [wJumptableIndex], a @@ -318,23 +319,23 @@ Function40217: ; 40217 (10:4217) xor a ld [hBGMapMode], a call ClearSprites - call Function41478 + call Pokedex_LoadCurrentFootprint call Function407fd call Function4134f - call Function40bb1 - ld [wc2d6], a + call Pokedex_GetMonAtCursorPosition + ld [wLastDexEntry], a callba DisplayDexEntry - call Function40ba0 + call Pokedex_DrawFootprint call WaitBGMap ld a, $a7 ld [hWX], a - call Function40bb1 + call Pokedex_GetMonAtCursorPosition ld [CurPartySpecies], a ld a, $4 call Function41423 ld a, [CurPartySpecies] call PlayCry - call Function40131 + call Pokedex_IncrementDexPointer ret Function40258: ; 40258 (10:4258) @@ -347,25 +348,25 @@ Function40258: ; 40258 (10:4258) ld a, [hl] and A_BUTTON jr nz, .a - call Function4066c + call Pokedex_NextOrPreviousDexEntry ret nc - call Function40131 + call Pokedex_IncrementDexPointer ret .a ld a, [wc7d8] ld hl, Jumptable_402f2 - call Function41432 + call Pokedex_LoadPointer jp [hl] .b ld a, [LastVolume] and a - jr z, .asm_40288 + jr z, .max_volume ld a, $77 ld [LastVolume], a -.asm_40288 +.max_volume call MaxVolume ld a, [wcf64] ld [wJumptableIndex], a @@ -376,8 +377,8 @@ Function40292: ; 40292 ld a, [wPokedexStatus] xor $1 ld [wPokedexStatus], a - call Function40bb1 - ld [wc2d6], a + call Pokedex_GetMonAtCursorPosition + ld [wLastDexEntry], a callba DisplayDexEntry call WaitBGMap ret @@ -391,14 +392,14 @@ Function402aa: ; 402aa (10:42aa) ld [hBGMapMode], a call Function407fd call Function4134f - call Function41478 - call Function40bb1 - ld [wc2d6], a + call Pokedex_LoadCurrentFootprint + call Pokedex_GetMonAtCursorPosition + ld [wLastDexEntry], a callba DisplayDexEntry - call Function40ba0 + call Pokedex_DrawFootprint call Function4143b call WaitBGMap - call Function40bb1 + call Pokedex_GetMonAtCursorPosition ld [CurPartySpecies], a ld a, $4 call Function41423 @@ -410,11 +411,12 @@ Function402aa: ; 402aa (10:42aa) ; 402e8 (10:42e8) Unknown_402e8: ; 402e8 - dw $0430 + db D_RIGHT | D_LEFT, 4 dwcoord 1, 17 dwcoord 6, 17 dwcoord 11, 17 dwcoord 15, 17 + ; 402f2 Jumptable_402f2: ; 402f2 @@ -433,8 +435,8 @@ Function402fa: ; 402fa ld [hWX], a ld a, $90 ld [hWY], a - call Function40bb1 - ld a, [wc7e4] + call Pokedex_GetMonAtCursorPosition + ld a, [wDexCurrentLocation] ld e, a predef Function91d11 call Function41401 @@ -449,7 +451,7 @@ Function402fa: ; 402fa call Function4038d call Function4143b call WaitBGMap - call Function40bb1 + call Pokedex_GetMonAtCursorPosition ld [CurPartySpecies], a ld a, $4 call Function41423 @@ -457,7 +459,7 @@ Function402fa: ; 402fa ; 40340 Function40340: ; 40340 - call Function40bb1 + call Pokedex_GetMonAtCursorPosition ld a, [wd265] call GetCryIndex ld e, c @@ -485,7 +487,7 @@ Function4034f: ; 4034f ld [wcf65], a call ClearBGPalettes call DisableLCD - call Function414fb + call Pokedex_LoadInvertedFont call Function4038d call EnableLCD call WaitBGMap @@ -497,9 +499,9 @@ Function4034f: ; 4034f Function4038d: ; 4038d call Function407fd - call Function40bb1 + call Pokedex_GetMonAtCursorPosition callba DisplayDexEntry - call Function40ba0 + call Pokedex_DrawFootprint ret ; 4039d @@ -509,17 +511,17 @@ Function4039d: ; 4039d (10:439d) call ClearSprites call Function4087c call Function4134f - ld a, [wc7d4] + ld a, [wCurrentDexMode] ld [wc7d8], a call Function40e5b call WaitBGMap ld a, $10 call Function41423 - call Function40131 + call Pokedex_IncrementDexPointer ret Function403be: ; 403be (10:43be) - ld a, [wc7dc] + ld a, [wUnlockedUnownMode] and a jr nz, .asm_403c9 ld de, Unknown_403f3 @@ -542,7 +544,7 @@ Function403be: ; 403be (10:43be) .asm_403e0 ld a, [wc7d8] ld hl, Jumptable_40405 - call Function41432 + call Pokedex_LoadPointer jp [hl] .asm_403ea @@ -553,17 +555,17 @@ Function403be: ; 403be (10:43be) ; 403f3 (10:43f3) Unknown_403f3: ; 403f3 - dw $03c0 - dwcoord 2, 4 - dwcoord 2, 6 - dwcoord 2, 8 + db D_UP | D_DOWN, 3 + dwcoord 2, 4 + dwcoord 2, 6 + dwcoord 2, 8 ; 403fb Unknown_403fb: ; 403fb - dw $04c0 - dwcoord 2, 4 - dwcoord 2, 6 - dwcoord 2, 8 + db D_UP | D_DOWN, 4 + dwcoord 2, 4 + dwcoord 2, 6 + dwcoord 2, 8 dwcoord 2, 10 ; 40405 @@ -585,17 +587,17 @@ Function40411: ; 40411 (10:4411) Function40415: ; 40415 (10:4415) ld b, $2 Function40417: ; 40417 (10:4417) - ld a, [wc7d4] + ld a, [wCurrentDexMode] cp b jr z, .asm_40431 ld a, b - ld [wc7d4], a - call Function40bdc + ld [wCurrentDexMode], a + call Pokedex_ChangeMode call Function40f08 xor a - ld [wc7d0], a - ld [wc7d1], a - call Function400b4 + ld [wDexListingPage], a + ld [wDexListingCursor], a + call Pokedex_InitCursorPosition .asm_40431 call Function41401 @@ -626,7 +628,7 @@ Function40443: ; 40443 (10:4443) call WaitBGMap ld a, $10 call Function41423 - call Function40131 + call Pokedex_IncrementDexPointer ret Function40471: ; 40471 (10:4471) @@ -646,7 +648,7 @@ Function40471: ; 40471 (10:4471) .asm_4048b ld a, [wc7d8] ld hl, Jumptable_404a8 - call Function41432 + call Pokedex_LoadPointer jp [hl] .asm_40495 @@ -657,7 +659,7 @@ Function40471: ; 40471 (10:4471) ; 4049e (10:449e) Unknown_4049e: ; 4049e - dw $04c0 + db D_UP | D_DOWN, 4 dwcoord 2, 4 dwcoord 2, 6 dwcoord 2, 13 @@ -683,7 +685,7 @@ Function404b7: ; 404b7 ld a, [wc7d7] and a jr nz, .asm_404dc - call Function40bdc + call Pokedex_ChangeMode call Function41107 xor a ld [hBGMapMode], a @@ -694,16 +696,16 @@ Function404b7: ; 404b7 ret .asm_404dc - ld [wc7d2], a - ld a, [wc7d0] + ld [wDexListingEnd], a + ld a, [wDexListingPage] ld [wc7e0], a - ld a, [wc7d1] + ld a, [wDexListingCursor] ld [wc7e1], a - ld a, [wc2d6] + ld a, [wLastDexEntry] ld [wcf65], a xor a - ld [wc7d0], a - ld [wc7d1], a + ld [wDexListingPage], a + ld [wDexListingCursor], a call Function41401 ld a, $9 ld [wJumptableIndex], a @@ -722,17 +724,17 @@ Function4050a: ; 4050a (10:450a) ld [hBGMapMode], a xor a hlcoord 0, 0, AttrMap - ld bc, $168 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT call ByteFill - call Function41ae1 - call Function41af7 - callba Function1de1d1 + call Pokedex_SetBGMapMode4 + call Pokedex_ResetBGMapMode + callba DrawPokedexSearchResultsWindow call Function409cf ld a, $4 ld [wc7d3], a call Function40b0f - call Function41ad7 - call Function41af7 + call Pokedex_SetBGMapMode3 + call Pokedex_ResetBGMapMode call Function40962 ld a, $5 ld [hSCX], a @@ -741,15 +743,15 @@ Function4050a: ; 4050a (10:450a) xor a ld [hWY], a call WaitBGMap - call Function41af7 - callba Function1de1d1 + call Pokedex_ResetBGMapMode + callba DrawPokedexSearchResultsWindow call Function409cf call Function41281 ld a, $ff ld [CurPartySpecies], a ld a, $4 call Function41423 - call Function40131 + call Pokedex_IncrementDexPointer ret Function40562: ; 40562 (10:4562) @@ -766,13 +768,13 @@ Function40562: ; 40562 (10:4562) xor a ld [hBGMapMode], a call Function40b0f - call Function41ad7 - call Function41af7 + call Pokedex_SetBGMapMode3 + call Pokedex_ResetBGMapMode ret .asm_40583 - call Function40bb1 - call Function40bd0 + call Pokedex_GetMonAtCursorPosition + call Pokedex_CheckSeen ret z ld a, $2 ld [wJumptableIndex], a @@ -782,14 +784,14 @@ Function40562: ; 40562 (10:4562) .asm_40595 ld a, [wc7e0] - ld [wc7d0], a + ld [wDexListingPage], a ld a, [wc7e1] - ld [wc7d1], a + ld [wDexListingCursor], a ld a, [wcf65] - ld [wc2d6], a + ld [wLastDexEntry], a call Function41401 call ClearSprites - call Function40bdc + call Pokedex_ChangeMode ld a, $5 ld [wJumptableIndex], a xor a @@ -798,45 +800,45 @@ Function40562: ; 40562 (10:4562) ld [hWX], a ret -Function405bd: ; 405bd (10:45bd) - call Function41a2c +Pokedex_UnownMode: ; 405bd (10:45bd) + call Pokedex_LoadUnownFont call Function409f1 xor a ld [wc7dd], a call Function41a58 call Function40658 - callba Functionfba2e + callba PrintUnownWord call WaitBGMap ld a, $16 call Function41423 - call Function40131 + call Pokedex_IncrementDexPointer ret Function405df: ; 405df (10:45df) ld hl, hJoyPressed ; $ffa7 ld a, [hl] and A_BUTTON | B_BUTTON - jr nz, .asm_405eb + jr nz, .a_b call Function40610 ret -.asm_405eb +.a_b call Function41401 ld a, $7 ld [wJumptableIndex], a call DelayFrame - call Function41a24 - jr nz, .asm_40603 + call Pokedex_CheckSGB + jr nz, .decompress callba Function1ddf26 - jr .asm_4060f + jr .done -.asm_40603 +.decompress ld hl, PokedexLZ ld de, VTiles2 tile $31 lb bc, BANK(PokedexLZ), $3a call DecompressRequest2bpp -.asm_4060f +.done ret Function40610: ; 40610 (10:4610) @@ -859,7 +861,7 @@ Function40610: ; 40610 (10:4610) ret nc ld a, [hl] inc [hl] - jr .asm_40635 + jr .update .left ld hl, wc7dd @@ -869,7 +871,7 @@ Function40610: ; 40610 (10:4610) ld a, [hl] dec [hl] -.asm_40635 +.update push af xor a ld [hBGMapMode], a @@ -877,7 +879,7 @@ Function40610: ; 40610 (10:4610) call Function40654 call Function41a58 call Function40658 - callba Functionfba2e + callba PrintUnownWord ld a, $1 ld [hBGMapMode], a call DelayFrame @@ -904,11 +906,11 @@ endr ld [hl], c ret -Function4066c: ; 4066c (10:466c) - ld a, [wc7d1] - ld [wc7e2], a - ld a, [wc7d0] - ld [wc7e3], a +Pokedex_NextOrPreviousDexEntry: ; 4066c (10:466c) + ld a, [wDexListingCursor] + ld [wBackupDexListingCursor], a + ld a, [wDexListingPage] + ld [wBackupDexListingPage], a ld hl, hJoyLast ld a, [hl] and D_UP @@ -922,43 +924,43 @@ Function4066c: ; 4066c (10:466c) .up ld a, [wc7d3] ld d, a - ld a, [wc7d2] + ld a, [wDexListingEnd] ld e, a call Function406ea - jr nc, .asm_406b7 - call Function40bb1 - call Function40bd0 - jr nz, .asm_406b5 + jr nc, .nope + call Pokedex_GetMonAtCursorPosition + call Pokedex_CheckSeen + jr nz, .yep jr .up .down ld a, [wc7d3] ld d, a - ld a, [wc7d2] + ld a, [wDexListingEnd] ld e, a call Function406fe - jr nc, .asm_406b7 - call Function40bb1 - call Function40bd0 - jr nz, .asm_406b5 + jr nc, .nope + call Pokedex_GetMonAtCursorPosition + call Pokedex_CheckSeen + jr nz, .yep jr .down -.asm_406b5 +.yep scf ret -.asm_406b7 - ld a, [wc7e2] - ld [wc7d1], a - ld a, [wc7e3] - ld [wc7d0], a +.nope + ld a, [wBackupDexListingCursor] + ld [wDexListingCursor], a + ld a, [wBackupDexListingPage] + ld [wDexListingPage], a and a ret Function406c5: ; 406c5 (10:46c5) ld a, [wc7d3] ld d, a - ld a, [wc7d2] + ld a, [wDexListingEnd] ld e, a ld hl, hJoyLast ld a, [hl] @@ -979,14 +981,14 @@ Function406c5: ; 406c5 (10:46c5) jr asm_4073d Function406ea: ; 406ea (10:46ea) - ld hl, wc7d1 + ld hl, wDexListingCursor ld a, [hl] and a jr z, .asm_406f4 dec [hl] jr asm_4073f .asm_406f4 - ld hl, wc7d0 + ld hl, wDexListingPage ld a, [hl] and a jr z, asm_4073d @@ -994,7 +996,7 @@ Function406ea: ; 406ea (10:46ea) jr asm_4073f Function406fe: ; 406fe (10:46fe) - ld hl, wc7d1 + ld hl, wDexListingCursor ld a, [hl] inc a cp e @@ -1004,14 +1006,14 @@ Function406fe: ; 406fe (10:46fe) inc [hl] jr asm_4073f .asm_4070c - ld hl, wc7d0 + ld hl, wDexListingPage add [hl] cp e jr nc, asm_4073d inc [hl] jr asm_4073f asm_40716: ; 40716 (10:4716) - ld hl, wc7d0 + ld hl, wDexListingPage ld a, [hl] and a jr z, asm_4073d @@ -1025,7 +1027,7 @@ asm_40716: ; 40716 (10:4716) ld [hl], a jr asm_4073f asm_40728: ; 40728 (10:4728) - ld hl, wc7d0 + ld hl, wDexListingPage ld a, d add a add [hl] @@ -1065,20 +1067,20 @@ Function40741: ; 40741 Function4074c: ; 4074c (10:474c) hlcoord 0, 17 ld de, String_START_SEARCH - call Function40acd + call Pokedex_PlaceString ld a, $32 hlcoord 0, 0 - ld bc, $168 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT call ByteFill hlcoord 0, 0 lb bc, 7, 7 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 0, 9 ld bc, $607 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 1, 11 ld de, String_SEEN - call Function40acd + call Pokedex_PlaceString ld hl, PokedexSeen ; wdeb9 (aliases: EndPokedexSeen) ld b, EndPokedexSeen - PokedexSeen call CountSetBits @@ -1088,7 +1090,7 @@ Function4074c: ; 4074c (10:474c) call PrintNum hlcoord 1, 14 ld de, String_OWN - call Function40acd + call Pokedex_PlaceString ld hl, PokedexCaught ld b, EndPokedexCaught - PokedexCaught call CountSetBits @@ -1098,7 +1100,7 @@ Function4074c: ; 4074c (10:474c) call PrintNum hlcoord 1, 17 ld de, String_SELECT_OPTION - call Function40acd + call Pokedex_PlaceString hlcoord 8, 1 ld b, $7 ld a, $5a @@ -1115,7 +1117,7 @@ Function4074c: ; 4074c (10:474c) ld [hl], $54 hlcoord 8, 16 ld [hl], $5b - call Function40ab2 + call Pokedex_PlaceFrontpicTopLeftCorner ret ; 407e1 (10:47e1) @@ -1130,10 +1132,10 @@ String_START_SEARCH: ; 407f2 ; 407fd Function407fd: ; 407fd - call Function40aa6 + call Pokedex_FillBackgroundColor2 hlcoord 0, 0 ld bc, $0f12 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 19, 0 ld [hl], $34 hlcoord 19, 1 @@ -1151,14 +1153,14 @@ Function407fd: ; 407fd call ByteFill hlcoord 9, 7 ld de, Unknown_40852 - call Function40acd + call Pokedex_PlaceString hlcoord 9, 9 ld de, Unknown_4085c - call Function40acd + call Pokedex_PlaceString hlcoord 0, 17 ld de, Unknown_40867 - call Function40acd - call Function40ab2 + call Pokedex_PlaceString + call Pokedex_PlaceFrontpicTopLeftCorner ret ; 4084f @@ -1173,20 +1175,20 @@ Unknown_40867: ; 40867 ; 4087c Function4087c: ; 4087c (10:487c) - call Function40aa6 + call Pokedex_FillBackgroundColor2 hlcoord 0, 2 lb bc, 8, 18 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 0, 12 lb bc, 4, 18 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 0, 1 ld de, Unknown_408b2 - call Function40acd + call Pokedex_PlaceString hlcoord 3, 4 ld de, String_408bd call PlaceString - ld a, [wc7dc] + ld a, [wUnlockedUnownMode] and a ret z hlcoord 3, 10 @@ -1211,19 +1213,19 @@ String_408e5: ; 408e5 ; 408f0 Function408f0: ; 408f0 (10:48f0) - call Function40aa6 + call Pokedex_FillBackgroundColor2 hlcoord 0, 2 lb bc, 14, 18 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 0, 1 ld de, Unknown_4092a - call Function40acd + call Pokedex_PlaceString hlcoord 8, 4 ld de, Unknown_40935 - call Function40acd + call Pokedex_PlaceString hlcoord 8, 6 ld de, Unknown_40935 - call Function40acd + call Pokedex_PlaceString hlcoord 3, 4 ld de, String_40940 call PlaceString @@ -1254,13 +1256,13 @@ String_4094c: ; 4094c ; 40962 Function40962: ; 40962 (10:4962) - call Function40aa6 + call Pokedex_FillBackgroundColor2 hlcoord 0, 0 lb bc, 7, 7 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 0, 11 lb bc, 5, 18 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 1, 12 ld de, String_409ae call PlaceString @@ -1280,7 +1282,7 @@ Function40962: ; 40962 (10:4962) ld [hl], $69 hlcoord 8, 10 ld [hl], $6a - call Function40ab2 + call Pokedex_PlaceFrontpicTopLeftCorner ret ; 409ae (10:49ae) @@ -1310,28 +1312,28 @@ Function409cf: ; 409cf (10:49cf) ret Function409f1: ; 409f1 (10:49f1) - call Function40aa6 + call Pokedex_FillBackgroundColor2 hlcoord 2, 1 lb bc, 10, 13 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 2, 14 lb bc, 1, 13 - call Function40ad5 + call Pokedex_PlaceBorder hlcoord 2, 15 ld [hl], $3d hlcoord 16, 15 ld [hl], $3e hlcoord 6, 5 - call Function40ab5 + call Pokedex_PlaceFrontpicAtHL ld de, 0 ld b, 0 ld c, 26 -.asm_40a1d +.loop ld hl, UnownDex add hl, de ld a, [hl] and a - jr z, .asm_40a39 + jr z, .done push af ld hl, Unknown_40a3e rept 4 @@ -1341,19 +1343,20 @@ endr ld h, [hl] ld l, a pop af - add $3f + add $40 - 1 ; Unown A ld [hl], a inc de inc b dec c - jr nz, .asm_40a1d -.asm_40a39 + jr nz, .loop +.done ld a, b ld [wc7de], a ret ; 40a3e (10:4a3e) Unknown_40a3e: ; 40a3e +; letter, cursor dwcoord 4,11, 3,11 dwcoord 4,10, 3,10 dwcoord 4, 9, 3, 9 @@ -1382,7 +1385,7 @@ Unknown_40a3e: ; 40a3e dwcoord 14,10, 15,10 ; 40aa6 -Function40aa6: ; 40aa6 +Pokedex_FillBackgroundColor2: ; 40aa6 hlcoord 0, 0 ld a, $32 ld bc, SCREEN_WIDTH * SCREEN_HEIGHT @@ -1390,113 +1393,118 @@ Function40aa6: ; 40aa6 ret ; 40ab2 -Function40ab2: ; 40ab2 +Pokedex_PlaceFrontpicTopLeftCorner: ; 40ab2 hlcoord 1, 1 -Function40ab5: ; 40ab5 +Pokedex_PlaceFrontpicAtHL: ; 40ab5 xor a ld b, $7 -.asm_40ab8 +.row ld c, $7 push af push hl -.asm_40abc +.col ld [hli], a add $7 dec c - jr nz, .asm_40abc + jr nz, .col pop hl - ld de, $0014 + ld de, SCREEN_WIDTH add hl, de pop af inc a dec b - jr nz, .asm_40ab8 + jr nz, .row ret ; 40acd -Function40acd: ; 40acd -.asm_40acd +Pokedex_PlaceString: ; 40acd +.loop ld a, [de] - cp $ff + cp -1 ret z inc de ld [hli], a - jr .asm_40acd + jr .loop ; 40ad5 -Function40ad5: ; 40ad5 +Pokedex_PlaceBorder: ; 40ad5 push hl ld a, $33 ld [hli], a ld d, $34 - call Function40b06 + call .FillRow ld a, $35 ld [hl], a pop hl - ld de, $0014 + ld de, SCREEN_WIDTH add hl, de -.asm_40ae6 +.loop push hl ld a, $36 ld [hli], a ld d, $7f - call Function40b06 + call .FillRow ld a, $37 ld [hl], a pop hl - ld de, $0014 + ld de, SCREEN_WIDTH add hl, de dec b - jr nz, .asm_40ae6 + jr nz, .loop ld a, $38 ld [hli], a ld d, $39 - call Function40b06 + call .FillRow ld a, $3a ld [hl], a ret ; 40b06 -Function40b06: ; 40b06 +.FillRow: ; 40b06 ld e, c -.asm_40b07 +.row_loop ld a, e and a ret z ld a, d ld [hli], a dec e - jr .asm_40b07 + jr .row_loop ; 40b0f Function40b0f: ; 40b0f (10:4b0f) - ld a, [wc7d4] - cp $1 - jr z, .asm_40b1a - ld c, $b - jr .asm_40b1c -.asm_40b1a - ld c, $b -.asm_40b1c +; This check is completely useless. + ld a, [wCurrentDexMode] + cp DEXMODE_OLD + jr z, .okay + ld c, 11 + jr .resume +.okay + ld c, 11 +; End useless check +.resume +; Clear (2 * [wc7d3] + 1) by 11 box starting at 0,1 hlcoord 0, 1 ld a, [wc7d3] add a inc a ld b, a - ld a, $7f - call Function413fe - ld a, [wc7d0] + ld a, " " + call Pokedex_FillBox + +; Load de with wPokedexDataStart + [wDexListingPage] + ld a, [wDexListingPage] ld e, a ld d, $0 - ld hl, wc6d0 + ld hl, wPokedexDataStart add hl, de ld e, l ld d, h hlcoord 0, 2 ld a, [wc7d3] -.asm_40b3c +.loop push af ld a, [de] ld [wd265], a @@ -1504,37 +1512,38 @@ Function40b0f: ; 40b0f (10:4b0f) push hl call Function40b55 pop hl - ld de, $28 + ld de, 2 * SCREEN_WIDTH add hl, de pop de inc de pop af dec a - jr nz, .asm_40b3c + jr nz, .loop call Function4143b ret Function40b55: ; 40b55 (10:4b55) and a ret z - call Function40b6a - call Function40b8d + call Pokedex_PrintNumberIfOldMode + call Pokedex_PlaceDefaultStringIfNotSeen ret c - call Function40b82 + call Pokedex_PlaceCaughtSymbolIfCaught push hl call GetPokemonName pop hl call PlaceString ret -Function40b6a: ; 40b6a (10:4b6a) - ld a, [wc7d4] - cp $1 - jr z, .asm_40b72 +Pokedex_PrintNumberIfOldMode: ; 40b6a (10:4b6a) + ld a, [wCurrentDexMode] + cp DEXMODE_OLD + jr z, .printnum ret -.asm_40b72 + +.printnum push hl - ld de, -20 + ld de, -SCREEN_WIDTH add hl, de ld de, wd265 lb bc, PRINTNUM_LEADINGZEROS | 1, 3 @@ -1542,31 +1551,32 @@ Function40b6a: ; 40b6a (10:4b6a) pop hl ret -Function40b82: ; 40b82 (10:4b82) - call Function40bc4 - jr nz, .asm_40b89 +Pokedex_PlaceCaughtSymbolIfCaught: ; 40b82 (10:4b82) + call Pokedex_CheckCaught + jr nz, .place_caught_symbol inc hl ret -.asm_40b89 + +.place_caught_symbol ld a, $4f ld [hli], a ret -Function40b8d: ; 40b8d (10:4b8d) - call Function40bd0 +Pokedex_PlaceDefaultStringIfNotSeen: ; 40b8d (10:4b8d) + call Pokedex_CheckSeen ret nz inc hl - ld de, String_40b9a + ld de, .NameNotSeen call PlaceString scf ret ; 40b9a (10:4b9a) -String_40b9a: ; 40b9a +.NameNotSeen: ; 40b9a db "-----@" ; 40ba0 -Function40ba0: ; 40ba0 +Pokedex_DrawFootprint: ; 40ba0 hlcoord 18, 1 ld a, $62 ld [hli], a @@ -1581,13 +1591,13 @@ Function40ba0: ; 40ba0 ; 40bb1 -Function40bb1: ; 40bb1 - ld a, [wc7d1] - ld hl, wc7d0 +Pokedex_GetMonAtCursorPosition: ; 40bb1 + ld a, [wDexListingCursor] + ld hl, wDexListingPage add [hl] ld e, a ld d, $0 - ld hl, wc6d0 + ld hl, wPokedexDataStart add hl, de ld a, [hl] ld [wd265], a @@ -1595,7 +1605,7 @@ Function40bb1: ; 40bb1 ; 40bc4 -Function40bc4: ; 40bc4 (10:4bc4) +Pokedex_CheckCaught: ; 40bc4 (10:4bc4) push de push hl ld a, [wd265] @@ -1606,7 +1616,7 @@ Function40bc4: ; 40bc4 (10:4bc4) ret -Function40bd0: ; 40bd0 +Pokedex_CheckSeen: ; 40bd0 push de push hl ld a, [wd265] @@ -1619,100 +1629,100 @@ Function40bd0: ; 40bd0 -Function40bdc: ; 40bdc - ld hl, wc6d0 - ld bc, $100 +Pokedex_ChangeMode: ; 40bdc + ld hl, wPokedexDataStart + ld bc, wPokedexMetadata - wPokedexDataStart xor a call ByteFill - ld a, [wc7d4] - ld hl, Jumptable_40bf0 - call Function41432 + ld a, [wCurrentDexMode] + ld hl, .Jumptable + call Pokedex_LoadPointer jp [hl] ; 40bf0 -Jumptable_40bf0: ; 40bf0 (10:4bf0) - dw Function40bf6 - dw Function40c08 - dw Function40c30 +.Jumptable: ; 40bf0 (10:4bf0) + dw .NewMode + dw .OldMode + dw Pokedex_ABCMode -Function40bf6: ; 40bf6 (10:4bf6) +.NewMode: ; 40bf6 (10:4bf6) ld de, NewPokedexOrder - ld hl, wc6d0 + ld hl, wPokedexDataStart ld c, NUM_POKEMON -.asm_40bfe +.loopnew ld a, [de] inc de ld [hli], a dec c - jr nz, .asm_40bfe - call Function40c18 + jr nz, .loopnew + call .FindLastSeen ret -Function40c08: ; 40c08 (10:4c08) - ld hl, wc6d0 +.OldMode: ; 40c08 (10:4c08) + ld hl, wPokedexDataStart ld a, $1 ld c, NUM_POKEMON -.asm_40c0f +.loopold ld [hli], a inc a dec c - jr nz, .asm_40c0f - call Function40c18 + jr nz, .loopold + call .FindLastSeen ret -Function40c18: ; 40c18 (10:4c18) - ld hl, wc7ca +.FindLastSeen: ; 40c18 (10:4c18) + ld hl, wPokedexDataStart + NUM_POKEMON - 1 ld d, NUM_POKEMON ld e, d -.asm_40c1e +.loopfindend ld a, [hld] ld [wd265], a - call Function40bd0 - jr nz, .asm_40c2b + call Pokedex_CheckSeen + jr nz, .foundend dec d dec e - jr nz, .asm_40c1e -.asm_40c2b + jr nz, .loopfindend +.foundend ld a, d - ld [wc7d2], a + ld [wDexListingEnd], a ret -Function40c30: ; 40c30 +Pokedex_ABCMode: ; 40c30 xor a - ld [wc7d2], a - ld hl, wc6d0 + ld [wDexListingEnd], a + ld hl, wPokedexDataStart ld de, AlphabeticalPokedexOrder ld c, NUM_POKEMON -.asm_40c3c +.loop1abc push bc ld a, [de] ld [wd265], a - call Function40bd0 - jr z, .asm_40c51 + call Pokedex_CheckSeen + jr z, .skipabc ld a, [wd265] ld [hli], a - ld a, [wc7d2] + ld a, [wDexListingEnd] inc a - ld [wc7d2], a + ld [wDexListingEnd], a -.asm_40c51 +.skipabc inc de pop bc dec c - jr nz, .asm_40c3c - ld a, [wc7d2] + jr nz, .loop1abc + ld a, [wDexListingEnd] ld c, 0 -.asm_40c5b +.loop2abc cp NUM_POKEMON - jr z, .asm_40c64 + jr z, .doneabc ld [hl], c inc hl inc a - jr .asm_40c5b + jr .loop2abc -.asm_40c64 +.doneabc ret ; 40c65 @@ -1726,11 +1736,11 @@ Function40e5b: ; 40e5b xor a ld [hBGMapMode], a hlcoord 0, 12 - ld bc, $0412 - call Function40ad5 + lb bc, 4, SCREEN_WIDTH - 2 + call Pokedex_PlaceBorder ld a, [wc7d8] ld hl, Unknown_40e7d - call Function41432 + call Pokedex_LoadPointer ld e, l ld d, h hlcoord 1, 14 @@ -1741,28 +1751,28 @@ Function40e5b: ; 40e5b ; 40e7d Unknown_40e7d: ; 40e7d - dw String_40e85 - dw String_40ea6 - dw String_40ec6 - dw String_40ee4 + dw .NewMode + dw .OldMode + dw .ABCMode + dw .UnownMode ; 40e85 -String_40e85: ; 40e85 - db $e1, $e2, " are listed by" +.NewMode: ; 40e85 + db " are listed by" next "evolution type.@" ; 40ea6 -String_40ea6: ; 40ea6 - db $e1, $e2, " are listed by" +.OldMode: ; 40ea6 + db " are listed by" next "official type.@" ; 40ec6 -String_40ec6: ; 40ec6 - db $e1, $e2, " are listed" +.ABCMode: ; 40ec6 + db " are listed" next "alphabetically.@" ; 40ee4 -String_40ee4: ; 40ee4 +.UnownMode: ; 40ee4 db "UNOWN are listed" next "in catching order.@" ; 40f08 @@ -1771,24 +1781,25 @@ Function40f08: ; 40f08 (10:4f08) xor a ld [hBGMapMode], a hlcoord 0, 12 - ld bc, $412 - call Function40ad5 - ld de, String_40f32 + lb bc, 4, SCREEN_WIDTH - 2 + call Pokedex_PlaceBorder + ld de, String_ChangingModesPleaseWait hlcoord 1, 14 call PlaceString ld a, $1 ld [hBGMapMode], a - ld c, $40 + ld c, 64 call DelayFrames ld de, SFX_CHANGE_DEX_MODE call PlaySFX - ld c, $40 + ld c, 64 call DelayFrames ret ; 40f32 (10:4f32) -String_40f32: ; 40f32 - db "Changing modes.", $4e, "Please wait.@" +String_ChangingModesPleaseWait: ; 40f32 + db "Changing modes." + next "Please wait.@" ; 40f4f Function40f4f: ; 40f4f (10:4f4f) @@ -1861,7 +1872,7 @@ Function40fa8: ; 40fa8 (10:4fa8) hlcoord 9, 3 ld bc, $408 ld a, $7f - call Function413fe + call Pokedex_FillBox ld a, [wc7d5] hlcoord 9, 4 call Function40fcd @@ -1926,8 +1937,8 @@ Function41095: ; 41095 add hl, de ld a, [hl] ld [wc7df], a - ld hl, wc6d0 - ld de, wc6d0 + ld hl, wPokedexDataStart + ld de, wPokedexDataStart ld c, NUM_POKEMON xor a ld [wc7d7], a @@ -1938,7 +1949,7 @@ Function41095: ; 41095 jr z, .asm_410e0 ld [wd265], a ld [CurSpecies], a - call Function40bc4 + call Pokedex_CheckCaught jr z, .asm_410e0 push hl push de @@ -2008,7 +2019,7 @@ Function41107: ; 41107 ld [hBGMapMode], a hlcoord 0, 12 ld bc, $0412 - call Function40ad5 + call Pokedex_PlaceBorder ld de, String_41126 hlcoord 1, 14 call PlaceString @@ -2025,7 +2036,7 @@ String_41126: ; 41126 ; 41148 Function41148: ; 41148 (10:5148) - ld a, [wc7d4] + ld a, [wCurrentDexMode] cp $1 jp z, Function41157 call Function41229 @@ -2034,7 +2045,7 @@ Function41148: ; 41148 (10:5148) Function41157: ; 41157 (10:5157) ld hl, Unknown_41167 - ld a, [wc7d1] + ld a, [wDexListingCursor] or a jr nz, .asm_41163 ld hl, Unknown_411c8 @@ -2133,7 +2144,7 @@ Unknown_41230: ; 41230 ; 41281 Function41281: ; 41281 (10:5281) - ld a, [wc7d4] + ld a, [wCurrentDexMode] cp $1 jp z, Function41157 ld hl, Unknown_41290 @@ -2176,7 +2187,7 @@ Function412f1: ; 412f1 (10:52f1) ld a, [hl] cp $ff ret z - ld a, [wc7d1] + ld a, [wDexListingCursor] and $7 swap a add [hl] @@ -2196,11 +2207,11 @@ Function412f1: ; 412f1 (10:52f1) Function4130e: ; 4130e (10:530e) push de - ld a, [wc7d2] + ld a, [wDexListingEnd] dec a ld e, a - ld a, [wc7d1] - ld hl, wc7d0 + ld a, [wDexListingCursor] + ld hl, wDexListingPage add [hl] cp e jr z, .asm_4133f @@ -2213,7 +2224,7 @@ Function4130e: ; 4130e (10:530e) ld a, d or e jr z, .asm_41341 - ld a, [wc7d2] + ld a, [wDexListingEnd] ld c, a .asm_41333 ld a, e @@ -2247,6 +2258,7 @@ Function4134f: ; 4134f (10:534f) ret Function4135a: ; 4135a (10:535a) +; bc = [de] - 1 ld a, [de] ld b, a inc de @@ -2254,74 +2266,79 @@ Function4135a: ; 4135a (10:535a) dec a ld c, a inc de - call Function413e0 + call Pokedex_BlinkInfoScreenCursor + ld hl, hJoyPressed ; $ffa7 ld a, [hl] and D_LEFT | D_UP and b - jr nz, .asm_4138f + jr nz, .MoveCursorLeft ld a, [hl] and D_RIGHT | D_DOWN and b - jr nz, .asm_413a0 + jr nz, .MoveCursorRight ld a, [hl] and SELECT and b - jr nz, .asm_413c1 - call Function413f5 - jr c, .asm_413bf + jr nz, .Select + call Pokedex_CursorFrameDelay + jr c, .NoAction ld hl, hJoyLast ld a, [hl] and D_LEFT | D_UP and b - jr nz, .asm_4138f + jr nz, .MoveCursorLeft ld a, [hl] and D_RIGHT | D_DOWN and b - jr nz, .asm_413a0 - jr .asm_413bf -.asm_4138f + jr nz, .MoveCursorRight + jr .NoAction + +.MoveCursorLeft ld a, [wc7d8] and a - jr z, .asm_413bf - call Function413d4 - ld [hl], $7f + jr z, .NoAction + call Pokedex_GetCursorPosition + ld [hl], " " ld hl, wc7d8 dec [hl] - jr .asm_413af -.asm_413a0 + jr .UpdateCursorPosition + +.MoveCursorRight ld a, [wc7d8] cp c - jr nc, .asm_413bf - call Function413d4 - ld [hl], $7f + jr nc, .NoAction + call Pokedex_GetCursorPosition + ld [hl], " " ld hl, wc7d8 inc [hl] -.asm_413af - call Function413d4 - ld [hl], $ed +.UpdateCursorPosition + call Pokedex_GetCursorPosition + ld [hl], "▶" ld a, $c ld [wc7d9], a xor a ld [wc7da], a scf ret -.asm_413bf + +.NoAction and a ret -.asm_413c1 - call Function413d4 - ld [hl], $7f + +.Select + call Pokedex_GetCursorPosition + ld [hl], " " ld a, [wc7d8] cp c - jr c, .asm_413ce + jr c, .Update ld a, $ff -.asm_413ce +.Update inc a ld [wc7d8], a - jr .asm_413af + jr .UpdateCursorPosition -Function413d4: ; 413d4 (10:53d4) +Pokedex_GetCursorPosition: ; 413d4 (10:53d4) ld a, [wc7d8] add a ld l, a @@ -2332,30 +2349,32 @@ Function413d4: ; 413d4 (10:53d4) ld l, a ret -Function413e0: ; 413e0 (10:53e0) +Pokedex_BlinkInfoScreenCursor: ; 413e0 (10:53e0) ld hl, wc7da ld a, [hl] inc [hl] and $8 - jr z, .asm_413ef - call Function413d4 - ld [hl], $7f - ret -.asm_413ef - call Function413d4 - ld [hl], $ed + jr z, .blink_on + call Pokedex_GetCursorPosition + ld [hl], " " ret -Function413f5: ; 413f5 (10:53f5) +.blink_on + call Pokedex_GetCursorPosition + ld [hl], "▶" + ret + +Pokedex_CursorFrameDelay: ; 413f5 (10:53f5) ld hl, wc7d9 ld a, [hl] and a ret z + dec [hl] scf ret -Function413fe: ; 413fe (10:53fe) +Pokedex_FillBox: ; 413fe (10:53fe) jp FillBoxWithByte Function41401: ; 41401 (10:5401) @@ -2391,7 +2410,7 @@ Function41427: ; 41427 ; 41432 -Function41432: ; 41432 +Pokedex_LoadPointer: ; 41432 ld e, a ld d, 0 rept 2 @@ -2404,10 +2423,10 @@ endr ; 4143b Function4143b: ; 4143b - call Function40bb1 - call Function40bd0 - jr z, .asm_4145b - ld a, [wdef4] + call Pokedex_GetMonAtCursorPosition + call Pokedex_CheckSeen + jr z, .QuestionMark + ld a, [wFirstUnownSeen] ld [UnownLetter], a ld a, [wd265] ld [CurPartySpecies], a @@ -2416,10 +2435,10 @@ Function4143b: ; 4143b predef GetFrontpic ret -.asm_4145b +.QuestionMark ld a, BANK(sScratch) call GetSRAMBank - callba Function1de0d7 + callba LoadQuestionMarkPic ld hl, VTiles2 ld de, sScratch ld c, 7 * 7 @@ -2431,13 +2450,13 @@ Function4143b: ; 4143b ; 41478 -Function41478: ; 41478 (10:5478) - call Function40bb1 +Pokedex_LoadCurrentFootprint: ; 41478 (10:5478) + call Pokedex_GetMonAtCursorPosition -Function4147b: ; 4147b +Pokedex_LoadAnyFootprint: ; 4147b ld a, [wd265] dec a - and $f8 + and ($ff ^ $07) ; $f8 ; $1f << 3 srl a srl a srl a @@ -2463,7 +2482,7 @@ Function4147b: ; 4147b ; Whoever was editing footprints forgot to fix their ; tile editor. Now each bottom half is 8 tiles off. - ld de, $80 + ld de, 8 tiles add hl, de ld e, l @@ -2476,28 +2495,28 @@ Function4147b: ; 4147b ; 414b7 -Function414b7: ; 414b7 +Pokedex_LoadGFX: ; 414b7 call DisableLCD ld hl, VTiles2 - ld bc, $0310 + ld bc, $31 tiles xor a call ByteFill - call Function414fb + call Pokedex_LoadInvertedFont call LoadFontsExtra ld hl, VTiles2 tile $60 - ld bc, $0200 - call Function41504 - call Function41a24 - jr nz, .asm_414e0 - callba Function1ddf1c - jr .asm_414e9 + ld bc, $20 tiles + call Pokedex_InvertTiles + call Pokedex_CheckSGB + jr nz, .LoadPokedexLZ + callba LoadSGBPokedexGFX + jr .LoadPokedexSlowpokeLZ -.asm_414e0 +.LoadPokedexLZ ld hl, PokedexLZ ld de, VTiles2 tile $31 call Decompress -.asm_414e9 +.LoadPokedexSlowpokeLZ ld hl, PokedexSlowpokeLZ ld de, VTiles0 call Decompress @@ -2506,30 +2525,31 @@ Function414b7: ; 414b7 call EnableLCD ret -Function414fb: ; 414fb +Pokedex_LoadInvertedFont: ; 414fb call LoadStandardFont ld hl, VTiles1 - ld bc, $0800 + ld bc, $80 tiles -Function41504: ; 41504 +Pokedex_InvertTiles: ; 41504 +.loop ld a, [hl] xor $ff ld [hli], a dec bc ld a, b or c - jr nz, Function41504 + jr nz, .loop ret ; 4150e PokedexLZ: ; 4150e -INCBIN "gfx/unknown/04150e.2bpp.lz" +INCBIN "gfx/pokedex/pokedex.2bpp.lz" ; 416b0 PokedexSlowpokeLZ: ; 416b0 INCBIN "gfx/pokedex/slowpoke.2bpp.lz" -Function41a24: ; 41a24 +Pokedex_CheckSGB: ; 41a24 ld a, [hCGB] or a ret nz @@ -2538,20 +2558,20 @@ Function41a24: ; 41a24 ret ; 41a2c -Function41a2c: ; 41a2c +Pokedex_LoadUnownFont: ; 41a2c ld a, BANK(sScratch) call GetSRAMBank ld hl, UnownFont ld de, sScratch + $188 - ld bc, $270 + ld bc, 39 tiles ld a, BANK(UnownFont) call FarCopyBytes ld hl, sScratch + $188 - ld bc, $1b0 - call Function41504 + ld bc, 27 tiles + call Pokedex_InvertTiles ld de, sScratch + $188 ld hl, VTiles2 tile $40 - lb bc, BANK(Function41a2c), $1b + lb bc, BANK(Pokedex_LoadUnownFont), 27 call Request2bpp call CloseSRAM ret @@ -2577,24 +2597,24 @@ Function41a58: ; 41a58 (10:5a58) ret ; 41a7f -Function41a7f: ; 41a7f +_NewPokedexEntry: ; 41a7f xor a ld [hBGMapMode], a callba Function1de247 - call Function41af7 + call Pokedex_ResetBGMapMode call DisableLCD call LoadStandardFont call LoadFontsExtra - call Function414b7 - call Function4147b + call Pokedex_LoadGFX + call Pokedex_LoadAnyFootprint ld a, [wd265] ld [CurPartySpecies], a call Function407fd - call Function40ba0 + call Pokedex_DrawFootprint hlcoord 0, 17 ld [hl], $3b inc hl - ld bc, $13 + ld bc, 19 ld a, " " call ByteFill callba DisplayDexEntry @@ -2611,31 +2631,31 @@ Function41a7f: ; 41a7f ; 41ad7 -Function41ad7: ; 41ad7 (10:5ad7) +Pokedex_SetBGMapMode3: ; 41ad7 (10:5ad7) ld a, $3 ld [hBGMapMode], a ld c, 4 call DelayFrames ret -Function41ae1: ; 41ae1 (10:5ae1) +Pokedex_SetBGMapMode4: ; 41ae1 (10:5ae1) ld a, $4 ld [hBGMapMode], a ld c, 4 call DelayFrames ret -Function41aeb: ; 41aeb (10:5aeb) +Pokedex_SetBGMapMode_3ifDMG_4ifCGB: ; 41aeb (10:5aeb) ld a, [hCGB] and a - jr z, .asm_41af3 - call Function41ae1 -.asm_41af3 - call Function41ad7 + jr z, .DMG + call Pokedex_SetBGMapMode4 +.DMG + call Pokedex_SetBGMapMode3 ret -Function41af7: ; 41af7 +Pokedex_ResetBGMapMode: ; 41af7 xor a ld [hBGMapMode], a ret diff --git a/engine/time_capsule/conversion.asm b/engine/time_capsule/conversion.asm index 50ddc23d7..cd2d68da1 100755 --- a/engine/time_capsule/conversion.asm +++ b/engine/time_capsule/conversion.asm @@ -355,7 +355,7 @@ NewPokedexEntry: ; fb877 ld [hSCX], a xor a ld [wPokedexStatus], a - callba Function41a7f + callba _NewPokedexEntry call WaitPressAorB_BlinkCursor ld a, $1 ld [wPokedexStatus], a @@ -366,7 +366,7 @@ NewPokedexEntry: ; fb877 call MaxVolume call RotateThreePalettesRight ld a, [hSCX] - add $fb + add -5 ; 251 ; NUM_POKEMON ld [hSCX], a call Functionfb8c8 pop af @@ -378,7 +378,7 @@ Functionfb8c8: ; fb8c8 call ClearTileMap call LoadFontsExtra call LoadStandardFont - callba Function40ab2 + callba Pokedex_PlaceFrontpicTopLeftCorner call Function3200 callba GetEnemyMonDVs ld a, [hli] diff --git a/engine/warp_connection.asm b/engine/warp_connection.asm new file mode 100755 index 000000000..e9a38257d --- /dev/null +++ b/engine/warp_connection.asm @@ -0,0 +1,440 @@ + +RunCallback_05_03: ; 1045b0 + call Clearwc7e8 + call ResetMapBufferEventFlags + call ResetFlashIfOutOfCave + call GetCurrentMapTrigger + call ResetBikeFlags + ld a, $5 + call RunMapCallback + +RunCallback_03: ; 1045c4 + callba ClearCmdQueue + ld a, $3 + call RunMapCallback + call GetMapHeaderTimeOfDayNybble + ld [wc2d0], a + ret + + +EnterMapConnection: ; 1045d6 +; Return carry if a connection has been entered. + ld a, [wPlayerStepDirection] + and a + jp z, EnterSouthConnection + cp 1 + jp z, EnterNorthConnection + cp 2 + jp z, EnterWestConnection + cp 3 + jp z, EnterEastConnection + ret +; 1045ed + + +EnterWestConnection: ; 1045ed + ld a, [WestConnectedMapGroup] + ld [MapGroup], a + ld a, [WestConnectedMapNumber] + ld [MapNumber], a + ld a, [WestConnectionStripXOffset] + ld [XCoord], a + ld a, [WestConnectionStripYOffset] + ld hl, YCoord + add [hl] + ld [hl], a + ld c, a + ld hl, WestConnectionWindow + ld a, [hli] + ld h, [hl] + ld l, a + srl c + jr z, .skip_to_load + ld a, [WestConnectedMapWidth] + add 6 + ld e, a + ld d, 0 + +.loop + add hl, de + dec c + jr nz, .loop + +.skip_to_load + ld a, l + ld [wd194], a + ld a, h + ld [wd194 + 1], a + jp EnteredConnection +; 104629 + + +EnterEastConnection: ; 104629 + ld a, [EastConnectedMapGroup] + ld [MapGroup], a + ld a, [EastConnectedMapNumber] + ld [MapNumber], a + ld a, [EastConnectionStripXOffset] + ld [XCoord], a + ld a, [EastConnectionStripYOffset] + ld hl, YCoord + add [hl] + ld [hl], a + ld c, a + ld hl, EastConnectionWindow + ld a, [hli] + ld h, [hl] + ld l, a + srl c + jr z, .skip_to_load + ld a, [EastConnectedMapWidth] + add 6 + ld e, a + ld d, 0 + +.loop + add hl, de + dec c + jr nz, .loop + +.skip_to_load + ld a, l + ld [wd194], a + ld a, h + ld [wd194 + 1], a + jp EnteredConnection +; 104665 + + +EnterNorthConnection: ; 104665 + ld a, [NorthConnectedMapGroup] + ld [MapGroup], a + ld a, [NorthConnectedMapNumber] + ld [MapNumber], a + ld a, [NorthConnectionStripYOffset] + ld [YCoord], a + ld a, [NorthConnectionStripXOffset] + ld hl, XCoord + add [hl] + ld [hl], a + ld c, a + ld hl, NorthConnectionWindow + ld a, [hli] + ld h, [hl] + ld l, a + ld b, 0 + srl c + add hl, bc + ld a, l + ld [wd194], a + ld a, h + ld [wd194 + 1], a + jp EnteredConnection +; 104696 + + +EnterSouthConnection: ; 104696 + ld a, [SouthConnectedMapGroup] + ld [MapGroup], a + ld a, [SouthConnectedMapNumber] + ld [MapNumber], a + ld a, [SouthConnectionStripYOffset] + ld [YCoord], a + ld a, [SouthConnectionStripXOffset] + ld hl, XCoord + add [hl] + ld [hl], a + ld c, a + ld hl, SouthConnectionWindow + ld a, [hli] + ld h, [hl] + ld l, a + ld b, 0 + srl c + add hl, bc + ld a, l + ld [wd194], a + ld a, h + ld [wd194 + 1], a + ; fallthrough +; 1046c4 + +EnteredConnection: ; 1046c4 + scf + ret +; 1046c6 + +LoadWarpData: ; 1046c6 + call .SaveDigWarp + call .SetSpawn + ld a, [wNextWarp] + ld [WarpNumber], a + ld a, [wNextMapGroup] + ld [MapGroup], a + ld a, [wNextMapNumber] + ld [MapNumber], a + ret + +.SaveDigWarp: ; 1046df (41:46df) + call GetMapPermission + call CheckOutdoorMap + ret nz + ld a, [wNextMapGroup] + ld b, a + ld a, [wNextMapNumber] + ld c, a + call GetAnyMapPermission + call CheckIndoorMap + ret nz + ld a, [wPrevMapGroup] + cp GROUP_MOUNT_MOON_SQUARE + jr nz, .not_mt_moon_or_tin_tower + ld a, [wPrevMapNumber] + cp MAP_MOUNT_MOON_SQUARE + ret z + cp MAP_TIN_TOWER_ROOF + ret z +.not_mt_moon_or_tin_tower + ld a, [wPrevWarp] + ld [wDigWarp], a + ld a, [wPrevMapGroup] + ld [wDigMapGroup], a + ld a, [wPrevMapNumber] + ld [wDigMapNumber], a + ret + +.SetSpawn: ; 104718 (41:4718) + call GetMapPermission + call CheckOutdoorMap + ret nz + ld a, [wNextMapGroup] + ld b, a + ld a, [wNextMapNumber] + ld c, a + call GetAnyMapPermission + call CheckIndoorMap + ret nz + ld a, [wNextMapGroup] + ld b, a + ld a, [wNextMapNumber] + ld c, a + call GetAnyMapTileset + ld a, c + cp TILESET_POKECENTER + jr z, .pokecenter_pokecom + cp TILESET_POKECOM_CENTER + jr z, .pokecenter_pokecom + ret +.pokecenter_pokecom + ld a, [wPrevMapGroup] + ld [wLastSpawnMapGroup], a + ld a, [wPrevMapNumber] + ld [wLastSpawnMapNumber], a + ret + +LoadMapTimeOfDay: ; 104750 + ld hl, VramState + res 6, [hl] + ld a, $1 + ld [wSpriteUpdatesEnabled], a + callba Function8c0e5 + callba Function8c001 + call OverworldTextModeSwitch + call Function104770 + call Function1047a3 + ret + +Function104770: ; 104770 (41:4770) + ld a, VBGMap0 / $100 + ld [wBGMapAnchor + 1], a + xor a + ld [wBGMapAnchor], a + ld [hSCY], a + ld [hSCX], a + callba Function5958 + ld a, [rVBK] + push af + ld a, $1 + ld [rVBK], a + xor a + lb bc, 4, 0 + hlbgcoord 0, 0 + call ByteFill + pop af + ld [rVBK], a + ld a, $60 + lb bc, 4, 0 + hlbgcoord 0, 0 + call ByteFill + ret + +Function1047a3: ; 1047a3 (41:47a3) + decoord 0, 0 + call .copy + ld a, [hCGB] + and a + ret z + + decoord 0, 0, AttrMap + ld a, $1 + ld [rVBK], a +.copy: + hlbgcoord 0, 0 + ld c, SCREEN_WIDTH + ld b, SCREEN_HEIGHT +.row + push bc +.column + ld a, [de] + inc de + ld [hli], a + dec c + jr nz, .column + ld bc, $20 - SCREEN_WIDTH + add hl, bc + pop bc + dec b + jr nz, .row + ld a, $0 + ld [rVBK], a + ret + +LoadGraphics: ; 1047cf + call LoadTilesetHeader + call LoadTileset + xor a + ld [hMapAnims], a + xor a + ld [hTileAnimFrame], a + callba RefreshSprites + call LoadFontsExtra + callba Function106594 + ret + +LoadMapPalettes: ; 1047eb + ld b, SCGB_09 + jp GetSGBLayout +; 1047f0 + +RefreshMapSprites: ; 1047f0 + call ClearSprites + callba ReturnFromMapSetupScript + call GetMovementPermissions + callba Function579d + callba CheckReplaceKrisSprite + ld hl, wPlayerSpriteSetupFlags + bit 6, [hl] + jr nz, .skip + ld hl, VramState + set 0, [hl] + call Function2e31 +.skip + ld a, [wPlayerSpriteSetupFlags] + and $1c + ld [wPlayerSpriteSetupFlags], a + ret + +CheckMovingOffEdgeOfMap:: ; 104820 (41:4820) + ld a, [wPlayerStepDirection] + cp STANDING + ret z + and a ; DOWN + jr z, .down + cp UP + jr z, .up + cp LEFT + jr z, .left + cp RIGHT + jr z, .right + and a + ret + +.down + ld a, [PlayerNextMapY] + sub 4 + ld b, a + ld a, [MapHeight] + add a + cp b + jr z, .ok + and a + ret + +.up + ld a, [PlayerNextMapY] + sub 4 + cp -1 + jr z, .ok + and a + ret + +.left + ld a, [PlayerNextMapX] + sub $4 + cp -1 + jr z, .ok + and a + ret + +.right + ld a, [PlayerNextMapX] + sub 4 + ld b, a + ld a, [MapWidth] + add a + cp b + jr z, .ok + and a + ret + +.ok + scf + ret + + +GetCoordOfUpperLeftCorner:: ; 10486d + ld hl, OverworldMap + ld a, [XCoord] + bit 0, a + jr nz, .increment_then_halve1 + srl a + add $1 + jr .resume + +.increment_then_halve1 + add $1 + srl a + +.resume + ld c, a + ld b, $0 + add hl, bc + ld a, [MapWidth] + add $6 + ld c, a + ld b, $0 + ld a, [YCoord] + bit 0, a + jr nz, .increment_then_halve2 + srl a + add $1 + jr .resume2 + +.increment_then_halve2 + add $1 + srl a + +.resume2 + call AddNTimes + ld a, l + ld [wd194], a + ld a, h + ld [wd194 + 1], a + ld a, [YCoord] + and $1 + ld [wd196], a + ld a, [XCoord] + and $1 + ld [wd197], a + ret +; 1048ba diff --git a/event/photo.asm b/event/photo.asm index 712107ed0..b35b38e04 100755 --- a/event/photo.asm +++ b/event/photo.asm @@ -162,7 +162,7 @@ Function16cff: ; 16cff ld a, BANK(sScratch) call GetSRAMBank - ld de, w6_d000 + ld de, wBackupTilemap ld hl, sScratch ld a, [hROMBank] ld b, a diff --git a/gfx/unknown/1de0e1.2bpp.lz b/gfx/pics/questionmark/front.2bpp.lz similarity index 100% rename from gfx/unknown/1de0e1.2bpp.lz rename to gfx/pics/questionmark/front.2bpp.lz diff --git a/gfx/unknown/04150e.2bpp.lz b/gfx/pokedex/pokedex.2bpp.lz similarity index 100% rename from gfx/unknown/04150e.2bpp.lz rename to gfx/pokedex/pokedex.2bpp.lz diff --git a/gfx/unknown/1ddf33.2bpp.lz b/gfx/pokedex/sgb.2bpp.lz similarity index 100% rename from gfx/unknown/1ddf33.2bpp.lz rename to gfx/pokedex/sgb.2bpp.lz diff --git a/home.asm b/home.asm index 7c7148891..8f014f26d 100644 --- a/home.asm +++ b/home.asm @@ -2192,7 +2192,7 @@ Function3f7c:: ; 3f7c ; 3f88 Function3f88:: ; 3f88 - ld hl, w6_d000 + ld hl, wBackupTilemap ld b, $0 .asm_3f8d push bc @@ -2213,7 +2213,7 @@ Function3f88:: ; 3f88 ; 3f9f Function3f9f:: ; 3f9f - ld hl, w6_d000 + ld hl, wBackupTilemap .asm_3fa2 push bc ld c, $8 diff --git a/home/map.asm b/home/map.asm index e385517a1..bd83c7069 100644 --- a/home/map.asm +++ b/home/map.asm @@ -1425,10 +1425,10 @@ LoadTileset:: ; 2821 ld [rSVBK], a ld a, e - ld de, w6_d000 + ld de, wBackupTilemap call FarDecompress - ld hl, w6_d000 + ld hl, wBackupTilemap ld de, VTiles2 ld bc, $60 tiles call CopyBytes diff --git a/main.asm b/main.asm index b31f1c95a..dac5605b3 100644 --- a/main.asm +++ b/main.asm @@ -45,9 +45,9 @@ LoadPushOAM:: ; 4031 ; 403f PushOAM: ; 403f - ld a, Sprites >> 8 + ld a, Sprites / $100 ld [rDMA], a - ld a, $28 + ld a, 40 .loop dec a jr nz, .loop @@ -149,12 +149,12 @@ Function64db: ; 64db ld [rSVBK], a ld a, $60 - ld hl, w6_d000 + ld hl, wBackupTilemap lb bc, 4, 0 call ByteFill - ld a, w6_d000 / $100 + ld a, wBackupTilemap / $100 ld [rHDMA1], a - ld a, w6_d000 % $100 + ld a, wBackupTilemap % $100 ld [rHDMA2], a ld a, (VBGMap0 % $8000) / $100 ld [rHDMA3], a @@ -3616,16 +3616,16 @@ dig_incave .CheckCanDig: ; cbb8 call GetMapPermission - cp $4 + cp CAVE jr z, .incave - cp $7 + cp DUNGEON jr z, .incave .fail ld a, $2 ret .incave - ld hl, wdca9 + ld hl, wDigWarp ld a, [hli] and a jr z, .fail @@ -3640,8 +3640,8 @@ dig_incave ; cbd8 .DoDig: ; cbd8 - ld hl, wdca9 - ld de, wd146 + ld hl, wDigWarp + ld de, wNextWarp ld bc, 3 call CopyBytes call GetPartyNick @@ -3755,9 +3755,9 @@ TeleportFunction: ; cc61 jr .nope .CheckIfSpawnPoint - ld a, [wdcb2] + ld a, [wLastSpawnMapGroup] ld d, a - ld a, [wdcb3] + ld a, [wLastSpawnMapNumber] ld e, a callba IsSpawnPoint jr nc, .nope @@ -6559,11 +6559,11 @@ AddTempmonToParty: ; da96 call AddNTimes predef GetUnownLetter callab UpdateUnownDex - ld a, [wdef4] + ld a, [wFirstUnownSeen] and a jr nz, .done ld a, [UnownLetter] - ld [wdef4], a + ld [wFirstUnownSeen], a .done and a @@ -18176,12 +18176,12 @@ Function4e906: ; 4e906 push af ld a, $6 ld [rSVBK], a - ld hl, w6_d000 - ld bc, w6_d400 - w6_d000 + ld hl, wBackupTilemap + ld bc, wBackupAttrMap - wBackupTilemap ld a, " " call ByteFill hlbgcoord 0, 0 - ld de, w6_d000 + ld de, wBackupTilemap ld b, $0 ld c, $40 call Request2bpp @@ -19615,15 +19615,15 @@ _GetFrontpic: ; 510a5 ld a, $6 ld [rSVBK], a ld a, b - ld de, w6_d000 + $800 + ld de, wBackupTilemap + $800 call FarDecompress pop bc - ld hl, w6_d000 - ld de, w6_d000 + $800 + ld hl, wBackupTilemap + ld de, wBackupTilemap + $800 call Function512ab pop hl push hl - ld de, w6_d000 + ld de, wBackupTilemap ld c, 7 * 7 ld a, [hROMBank] ld b, a @@ -19666,7 +19666,7 @@ Function51103: ; 51103 ld a, $1 ld [rVBK], a push hl - ld de, w6_d000 + ld de, wBackupTilemap ld c, 7 * 7 ld a, [hROMBank] ld b, a @@ -19697,7 +19697,7 @@ Function51103: ; 51103 call Function5114f pop bc pop hl - ld de, w6_d000 + ld de, wBackupTilemap ld a, [hROMBank] ld b, a call Get2bpp @@ -19707,7 +19707,7 @@ Function51103: ; 51103 ; 5114f Function5114f: ; 5114f - ld hl, w6_d000 + ld hl, wBackupTilemap swap c ld a, c and $f @@ -19766,14 +19766,14 @@ GetBackpic: ; 5116c inc hl ld a, d call GetFarHalfword - ld de, w6_d000 + ld de, wBackupTilemap pop af call FarDecompress - ld hl, w6_d000 + ld hl, wBackupTilemap ld c, 6 * 6 call Function5127c pop hl - ld de, w6_d000 + ld de, wBackupTilemap ld a, [hROMBank] ld b, a call Get2bpp @@ -19872,10 +19872,10 @@ GetTrainerPic: ; 5120d ld a, BANK(TrainerPicPointers) call GetFarHalfword pop af - ld de, w6_d000 + ld de, wBackupTilemap call FarDecompress pop hl - ld de, w6_d000 + ld de, wBackupTilemap ld c, 7 * 7 ld a, [hROMBank] ld b, a @@ -19901,10 +19901,10 @@ DecompressPredef: ; 5125d push de push bc ld a, b - ld de, w6_d000 + ld de, wBackupTilemap call FarDecompress pop bc - ld de, w6_d000 + ld de, wBackupTilemap pop hl ld a, [hROMBank] ld b, a @@ -22096,7 +22096,7 @@ UpdateUnownDex: ; fba18 ; fba2e -Functionfba2e: ; fba2e (3e:7a2e) +PrintUnownWord: ; fba2e (3e:7a2e) hlcoord 4, 15 ld bc, 12 ld a, " " @@ -22117,13 +22117,13 @@ endr ld e, a ld d, [hl] hlcoord 4, 15 -.asm_fba52 +.loop ld a, [de] - cp $ff + cp -1 ret z inc de ld [hli], a - jr .asm_fba52 + jr .loop ; fba5a (3e:7a5a) UnownWords: ; fba5a @@ -22220,18 +22220,18 @@ Function104000:: ; 104000 Function104006: ; 104006 decoord 0, 0, AttrMap - ld hl, w6_d400 + ld hl, wBackupAttrMap call Function104263 decoord 0, 0 - ld hl, w6_d000 + ld hl, wBackupTilemap call Function10425f ld a, $0 ld [rVBK], a - ld hl, w6_d000 + ld hl, wBackupTilemap call Function10419d ld a, $1 ld [rVBK], a - ld hl, w6_d400 + ld hl, wBackupAttrMap call Function10419d ret ; 10402d @@ -22243,11 +22243,11 @@ Function10402d:: ; 10402d Function104033: ; 104033 decoord 0, 0 - ld hl, w6_d000 + ld hl, wBackupTilemap call Function10425f ld a, $0 ld [rVBK], a - ld hl, w6_d000 + ld hl, wBackupTilemap call Function10419d ret ; 104047 @@ -22259,11 +22259,11 @@ Function104047: ; 104047 Function10404d: ; 10404d decoord 0, 0, AttrMap - ld hl, w6_d400 + ld hl, wBackupAttrMap call Function104263 ld a, $1 ld [rVBK], a - ld hl, w6_d400 + ld hl, wBackupAttrMap call Function10419d ret ; 104061 @@ -22275,10 +22275,10 @@ ReloadMapPart:: ; 104061 Function104067: ; 104067 decoord 0, 0, AttrMap - ld hl, w6_d400 + ld hl, wBackupAttrMap call Function104263 decoord 0, 0 - ld hl, w6_d000 + ld hl, wBackupTilemap call Function10425f call DelayFrame di @@ -22286,11 +22286,11 @@ Function104067: ; 104067 push af ld a, $1 ld [rVBK], a - ld hl, w6_d400 + ld hl, wBackupAttrMap call Function1041ad ld a, $0 ld [rVBK], a - ld hl, w6_d000 + ld hl, wBackupTilemap call Function1041ad pop af ld [rVBK], a @@ -22305,10 +22305,10 @@ Function104099: ; 104099 Function1040a2: ; 1040a2 decoord 0, 0, AttrMap - ld hl, w6_d400 + ld hl, wBackupAttrMap call Function104263 decoord 0, 0 - ld hl, w6_d000 + ld hl, wBackupTilemap call Function10425f call DelayFrame di @@ -22316,11 +22316,11 @@ Function1040a2: ; 1040a2 push af ld a, $1 ld [rVBK], a - ld hl, w6_d400 + ld hl, wBackupAttrMap call Function1041c1 ld a, $0 ld [rVBK], a - ld hl, w6_d000 + ld hl, wBackupTilemap call Function1041c1 pop af ld [rVBK], a @@ -22375,10 +22375,10 @@ Function104110:: ; 104110 Function104116: ; 104116 decoord 0, 0, AttrMap - ld hl, w6_d400 + ld hl, wBackupAttrMap call Function104263 decoord 0, 0 - ld hl, w6_d000 + ld hl, wBackupTilemap call Function10425f call DelayFrame di @@ -22386,11 +22386,11 @@ Function104116: ; 104116 push af ld a, $1 ld [rVBK], a - ld hl, w6_d400 + ld hl, wBackupAttrMap call Function1041b7 ld a, $0 ld [rVBK], a - ld hl, w6_d000 + ld hl, wBackupTilemap call Function1041b7 pop af ld [rVBK], a @@ -22405,19 +22405,19 @@ Function104148: ; 104148 (41:4148) Function10414e: ; 10414e decoord 0, 0, AttrMap - ld hl, w6_d400 + ld hl, wBackupAttrMap call Function104263 ld c, $ff decoord 0, 0 - ld hl, w6_d000 + ld hl, wBackupTilemap call Function104265 ld a, $1 ld [rVBK], a - ld hl, w6_d400 + ld hl, wBackupAttrMap call Function1041ad ld a, $0 ld [rVBK], a - ld hl, w6_d000 + ld hl, wBackupTilemap call Function1041ad ret ; 104177 @@ -22436,7 +22436,7 @@ Function104177: ; 104177 ld [rSVBK], a ld a, [rVBK] push af - call Function10419c + call ._hl_ pop af ld [rVBK], a pop af @@ -22448,7 +22448,7 @@ Function104177: ; 104177 ret ; 10419c -Function10419c: ; 10419c +._hl_: ; 10419c jp [hl] ; 10419d @@ -22658,7 +22658,7 @@ _Get2bpp:: ; 104284 push bc push hl - ; Copy c tiles of the 2bpp from b:de to w6_d000 + ; Copy c tiles of the 2bpp from b:de to wBackupTilemap ld a, b ; bank ld l, c ; number of tiles ld h, $0 @@ -22669,7 +22669,7 @@ endr ld c, l ld h, d ; address ld l, e - ld de, w6_d000 + ld de, wBackupTilemap call FarCopyBytes pop hl @@ -22681,7 +22681,7 @@ endr ld d, h ld e, l - ld hl, w6_d000 + ld hl, wBackupTilemap call Function104209 ; restore the previous bank @@ -22736,7 +22736,7 @@ endr ld b, h ld h, d ld l, e - ld de, w6_d000 + ld de, wBackupTilemap call FarCopyBytesDouble_DoubleBankSwitch pop hl @@ -22748,7 +22748,7 @@ endr ld d, h ld e, l - ld hl, w6_d000 + ld hl, wBackupTilemap call Function104209 pop af @@ -22762,22 +22762,22 @@ Function104303: ; 104303 ; 104309 Function104309: - ld hl, w6_d000 + ld hl, wBackupTilemap decoord 0, 0 call Function10433a - ld hl, w6_d000 + $80 + ld hl, wBackupTilemap + $80 decoord 0, 0, AttrMap call Function10433a ld a, $1 ld [rVBK], a ld c, $8 - ld hl, w6_d000 + $80 + ld hl, wBackupTilemap + $80 debgcoord 0, 0, VBGMap1 call Function104209 ld a, $0 ld [rVBK], a ld c, $8 - ld hl, w6_d000 + ld hl, wBackupTilemap debgcoord 0, 0, VBGMap1 call Function104209 ret @@ -22785,7 +22785,7 @@ Function104309: Function10433a: ; 10433a (41:433a) ld b, 4 .outer_loop - ld c, 20 + ld c, SCREEN_WIDTH .inner_loop ld a, [de] ld [hli], a @@ -22793,7 +22793,7 @@ Function10433a: ; 10433a (41:433a) dec c jr nz, .inner_loop ld a, l - add $20 - 20 + add $20 - SCREEN_WIDTH ld l, a ld a, h adc $0 @@ -22816,446 +22816,7 @@ FishingRodGFX2: INCBIN "gfx/misc/fishing2.2bpp" BoulderDustGFX: INCBIN "gfx/misc/boulderdust.2bpp" FishingRodGFX4: INCBIN "gfx/misc/fishing4.2bpp" - -RunCallback_05_03: ; 1045b0 - call Clearwc7e8 - call ResetMapBufferEventFlags - call ResetFlashIfOutOfCave - call GetCurrentMapTrigger - call ResetBikeFlags - ld a, $5 - call RunMapCallback - -RunCallback_03: ; 1045c4 - callba ClearCmdQueue - ld a, $3 - call RunMapCallback - call GetMapHeaderTimeOfDayNybble - ld [wc2d0], a - ret - - -EnterMapConnection: ; 1045d6 -; Return carry if a connection has been entered. - ld a, [wPlayerStepDirection] - and a - jp z, EnterSouthConnection - cp 1 - jp z, EnterNorthConnection - cp 2 - jp z, EnterWestConnection - cp 3 - jp z, EnterEastConnection - ret -; 1045ed - - -EnterWestConnection: ; 1045ed - ld a, [WestConnectedMapGroup] - ld [MapGroup], a - ld a, [WestConnectedMapNumber] - ld [MapNumber], a - ld a, [WestConnectionStripXOffset] - ld [XCoord], a - ld a, [WestConnectionStripYOffset] - ld hl, YCoord - add [hl] - ld [hl], a - ld c, a - ld hl, WestConnectionWindow - ld a, [hli] - ld h, [hl] - ld l, a - srl c - jr z, .skip_to_load - ld a, [WestConnectedMapWidth] - add 6 - ld e, a - ld d, 0 - -.loop - add hl, de - dec c - jr nz, .loop - -.skip_to_load - ld a, l - ld [wd194], a - ld a, h - ld [wd194 + 1], a - jp EnteredConnection -; 104629 - - -EnterEastConnection: ; 104629 - ld a, [EastConnectedMapGroup] - ld [MapGroup], a - ld a, [EastConnectedMapNumber] - ld [MapNumber], a - ld a, [EastConnectionStripXOffset] - ld [XCoord], a - ld a, [EastConnectionStripYOffset] - ld hl, YCoord - add [hl] - ld [hl], a - ld c, a - ld hl, EastConnectionWindow - ld a, [hli] - ld h, [hl] - ld l, a - srl c - jr z, .skip_to_load - ld a, [EastConnectedMapWidth] - add 6 - ld e, a - ld d, 0 - -.loop - add hl, de - dec c - jr nz, .loop - -.skip_to_load - ld a, l - ld [wd194], a - ld a, h - ld [wd194 + 1], a - jp EnteredConnection -; 104665 - - -EnterNorthConnection: ; 104665 - ld a, [NorthConnectedMapGroup] - ld [MapGroup], a - ld a, [NorthConnectedMapNumber] - ld [MapNumber], a - ld a, [NorthConnectionStripYOffset] - ld [YCoord], a - ld a, [NorthConnectionStripXOffset] - ld hl, XCoord - add [hl] - ld [hl], a - ld c, a - ld hl, NorthConnectionWindow - ld a, [hli] - ld h, [hl] - ld l, a - ld b, 0 - srl c - add hl, bc - ld a, l - ld [wd194], a - ld a, h - ld [wd194 + 1], a - jp EnteredConnection -; 104696 - - -EnterSouthConnection: ; 104696 - ld a, [SouthConnectedMapGroup] - ld [MapGroup], a - ld a, [SouthConnectedMapNumber] - ld [MapNumber], a - ld a, [SouthConnectionStripYOffset] - ld [YCoord], a - ld a, [SouthConnectionStripXOffset] - ld hl, XCoord - add [hl] - ld [hl], a - ld c, a - ld hl, SouthConnectionWindow - ld a, [hli] - ld h, [hl] - ld l, a - ld b, 0 - srl c - add hl, bc - ld a, l - ld [wd194], a - ld a, h - ld [wd194 + 1], a - ; fallthrough -; 1046c4 - -EnteredConnection: ; 1046c4 - scf - ret -; 1046c6 - -LoadWarpData: ; 1046c6 - call Function1046df - call Function104718 - ld a, [wd146] - ld [WarpNumber], a - ld a, [wd147] - ld [MapGroup], a - ld a, [wd148] - ld [MapNumber], a - ret - -Function1046df: ; 1046df (41:46df) - call GetMapPermission - call CheckOutdoorMap - ret nz - ld a, [wd147] - ld b, a - ld a, [wd148] - ld c, a - call GetAnyMapPermission - call CheckIndoorMap - ret nz - ld a, [wd14a] - cp $f - jr nz, .asm_104705 - ld a, [wd14b] - cp $a - ret z - cp $c - ret z -.asm_104705 - ld a, [wd149] - ld [wdca9], a - ld a, [wd14a] - ld [wdcaa], a - ld a, [wd14b] - ld [wdcab], a - ret - -Function104718: ; 104718 (41:4718) - call GetMapPermission - call CheckOutdoorMap - ret nz - ld a, [wd147] - ld b, a - ld a, [wd148] - ld c, a - call GetAnyMapPermission - call CheckIndoorMap - ret nz - ld a, [wd147] - ld b, a - ld a, [wd148] - ld c, a - call GetAnyMapTileset - ld a, c - cp $7 - jr z, .asm_104743 - cp $15 - jr z, .asm_104743 - ret -.asm_104743 - ld a, [wd14a] - ld [wdcb2], a - ld a, [wd14b] - ld [wdcb3], a - ret - -LoadMapTimeOfDay: ; 104750 - ld hl, VramState - res 6, [hl] - ld a, $1 - ld [wSpriteUpdatesEnabled], a - callba Function8c0e5 - callba Function8c001 - call OverworldTextModeSwitch - call Function104770 - call Function1047a3 - ret - -Function104770: ; 104770 (41:4770) - ld a, VBGMap0 / $100 - ld [wBGMapAnchor + 1], a - xor a - ld [wBGMapAnchor], a - ld [hSCY], a - ld [hSCX], a - callba Function5958 - ld a, [rVBK] - push af - ld a, $1 - ld [rVBK], a - xor a - lb bc, 4, 0 - hlbgcoord 0, 0 - call ByteFill - pop af - ld [rVBK], a - ld a, $60 - lb bc, 4, 0 - hlbgcoord 0, 0 - call ByteFill - ret - -Function1047a3: ; 1047a3 (41:47a3) - decoord 0, 0 - call .copy - ld a, [hCGB] - and a - ret z - - decoord 0, 0, AttrMap - ld a, $1 - ld [rVBK], a -.copy: - hlbgcoord 0, 0 - ld c, SCREEN_WIDTH - ld b, SCREEN_HEIGHT -.row - push bc -.column - ld a, [de] - inc de - ld [hli], a - dec c - jr nz, .column - ld bc, $20 - SCREEN_WIDTH - add hl, bc - pop bc - dec b - jr nz, .row - ld a, $0 - ld [rVBK], a - ret - -LoadGraphics: ; 1047cf - call LoadTilesetHeader - call LoadTileset - xor a - ld [hMapAnims], a - xor a - ld [hTileAnimFrame], a - callba RefreshSprites - call LoadFontsExtra - callba Function106594 - ret - -LoadMapPalettes: ; 1047eb - ld b, SCGB_09 - jp GetSGBLayout -; 1047f0 - -RefreshMapSprites: ; 1047f0 - call ClearSprites - callba ReturnFromMapSetupScript - call GetMovementPermissions - callba Function579d - callba CheckReplaceKrisSprite - ld hl, wPlayerSpriteSetupFlags - bit 6, [hl] - jr nz, .skip - ld hl, VramState - set 0, [hl] - call Function2e31 -.skip - ld a, [wPlayerSpriteSetupFlags] - and $1c - ld [wPlayerSpriteSetupFlags], a - ret - -CheckMovingOffEdgeOfMap:: ; 104820 (41:4820) - ld a, [wPlayerStepDirection] - cp STANDING - ret z - and a ; DOWN - jr z, .down - cp UP - jr z, .up - cp LEFT - jr z, .left - cp RIGHT - jr z, .right - and a - ret - -.down - ld a, [PlayerNextMapY] - sub 4 - ld b, a - ld a, [MapHeight] - add a - cp b - jr z, .ok - and a - ret - -.up - ld a, [PlayerNextMapY] - sub 4 - cp -1 - jr z, .ok - and a - ret - -.left - ld a, [PlayerNextMapX] - sub $4 - cp -1 - jr z, .ok - and a - ret - -.right - ld a, [PlayerNextMapX] - sub 4 - ld b, a - ld a, [MapWidth] - add a - cp b - jr z, .ok - and a - ret - -.ok - scf - ret - - -GetCoordOfUpperLeftCorner:: ; 10486d - ld hl, OverworldMap - ld a, [XCoord] - bit 0, a - jr nz, .increment_then_halve1 - srl a - add $1 - jr .resume - -.increment_then_halve1 - add $1 - srl a - -.resume - ld c, a - ld b, $0 - add hl, bc - ld a, [MapWidth] - add $6 - ld c, a - ld b, $0 - ld a, [YCoord] - bit 0, a - jr nz, .increment_then_halve2 - srl a - add $1 - jr .resume2 - -.increment_then_halve2 - add $1 - srl a - -.resume2 - call AddNTimes - ld a, l - ld [wd194], a - ld a, h - ld [wd194 + 1], a - ld a, [YCoord] - and $1 - ld [wd196], a - ld a, [XCoord] - and $1 - ld [wd197], a - ret -; 1048ba +INCLUDE "engine/warp_connection.asm" INCLUDE "engine/mysterygift.asm" @@ -23824,7 +23385,7 @@ String_PM: db "PM@" ; 1dd6ff INCLUDE "engine/diploma.asm" -Function1ddf1c: ; 1ddf1c +LoadSGBPokedexGFX: ; 1ddf1c ld hl, LZ_1ddf33 ld de, VTiles2 tile $31 call Decompress @@ -23840,21 +23401,21 @@ Function1ddf26: ; 1ddf26 (77:5f26) ; 1ddf33 (77:5f33) LZ_1ddf33: ; 1ddf33 -INCBIN "gfx/unknown/1ddf33.2bpp.lz" +INCBIN "gfx/pokedex/sgb.2bpp.lz" ; 1de0d7 -Function1de0d7: ; 1de0d7 - ld hl, LZ_1de0e1 +LoadQuestionMarkPic: ; 1de0d7 + ld hl, .QuestionMarkLZ ld de, sScratch call Decompress ret ; 1de0e1 -LZ_1de0e1: ; 1de0e1 -INCBIN "gfx/unknown/1de0e1.2bpp.lz" +.QuestionMarkLZ: ; 1de0e1 +INCBIN "gfx/pics/questionmark/front.2bpp.lz" ; 1de171 -Function1de171: ; 1de171 (77:6171) +DrawPokedexListWindow: ; 1de171 (77:6171) ld a, $32 hlcoord 0, 17 ld bc, 12 @@ -23864,46 +23425,49 @@ Function1de171: ; 1de171 (77:6171) call ClearBox ld a, $34 hlcoord 0, 0 - ld bc, $b + ld bc, 11 call ByteFill ld a, $39 hlcoord 0, 16 - ld bc, $b + ld bc, 11 call ByteFill hlcoord 5, 0 ld [hl], $3f hlcoord 5, 16 ld [hl], $40 - ld a, [wc7d4] - cp $1 - jr z, .asm_1de1bf + ld a, [wCurrentDexMode] + cp DEXMODE_OLD + jr z, .OldMode +; scroll bar hlcoord 11, 0 ld [hl], $50 ld a, $51 hlcoord 11, 1 ld b, SCREEN_HEIGHT - 3 - call Function1de27f + call Bank77_FillColumn ld [hl], $52 - jr .asm_1de1d0 -.asm_1de1bf + jr .Done + +.OldMode +; no scroll bar hlcoord 11, 0 ld [hl], $66 ld a, $67 hlcoord 11, 1 ld b, SCREEN_HEIGHT - 3 - call Function1de27f + call Bank77_FillColumn ld [hl], $68 -.asm_1de1d0 +.Done ret -Function1de1d1: ; 1de1d1 (77:61d1) +DrawPokedexSearchResultsWindow: ; 1de1d1 (77:61d1) ld a, $34 hlcoord 0, 0 - ld bc, $b + ld bc, 11 call ByteFill ld a, $39 hlcoord 0, 10 - ld bc, $b + ld bc, 11 call ByteFill hlcoord 5, 0 ld [hl], $3f @@ -23914,35 +23478,36 @@ Function1de1d1: ; 1de1d1 (77:61d1) ld a, $67 hlcoord 11, 1 ld b, SCREEN_HEIGHT / 2 - call Function1de27f + call Bank77_FillColumn ld [hl], $68 ld a, $34 hlcoord 0, 11 - ld bc, $b + ld bc, 11 call ByteFill ld a, $39 hlcoord 0, 17 - ld bc, $b + ld bc, 11 call ByteFill hlcoord 11, 11 ld [hl], $66 ld a, $67 hlcoord 11, 12 ld b, 5 - call Function1de27f + call Bank77_FillColumn ld [hl], $68 hlcoord 0, 12 lb bc, 5, 11 call ClearBox - ld de, String_1de23c + ld de, .esults_D hlcoord 0, 12 call PlaceString ret ; 1de23c (77:623c) -String_1de23c: ; 1de23c -; At a glance, this is less coherent in the Japanese charset. +.esults_D: ; 1de23c +; (SEARCH R) db "ESULTS" +; (### FOUN) next "D!@" ; 1de247 @@ -23961,15 +23526,15 @@ Function1de247: ; 1de247 ld [hl], $66 hlcoord 19, 1 ld a, $67 - ld b, SCREEN_HEIGHT - 3 - call Function1de27f + ld b, 15 + call Bank77_FillColumn ld [hl], $68 hlcoord 19, 17 ld [hl], $3c xor a ld b, SCREEN_HEIGHT hlcoord 19, 0, AttrMap - call Function1de27f + call Bank77_FillColumn call Function3200 pop hl ld a, l @@ -23979,7 +23544,7 @@ Function1de247: ; 1de247 ret ; 1de27f -Function1de27f: ; 1de27f +Bank77_FillColumn: ; 1de27f push de ld de, SCREEN_WIDTH .loop diff --git a/misc/fixed_words.asm b/misc/fixed_words.asm index 7bb39427e..a3d3f0389 100755 --- a/misc/fixed_words.asm +++ b/misc/fixed_words.asm @@ -308,7 +308,7 @@ Function11c1ca: ; 11c1ca callba ReloadMapPart callba Function8cf53 callba LoadPokemonData - callba Function40c30 + callba Pokedex_ABCMode ld a, [rSVBK] push af ld a, $5 diff --git a/misc/mobile_40.asm b/misc/mobile_40.asm index 5883a693e..211fabea5 100644 --- a/misc/mobile_40.asm +++ b/misc/mobile_40.asm @@ -6774,11 +6774,11 @@ Function102d48: ; 102d48 call AddNTimes predef GetUnownLetter callba UpdateUnownDex - ld a, [wdef4] + ld a, [wFirstUnownSeen] and a jr nz, .asm_102d98 ld a, [UnownLetter] - ld [wdef4], a + ld [wFirstUnownSeen], a .asm_102d98 and a diff --git a/misc/mobile_41.asm b/misc/mobile_41.asm index 69abe1cd2..79f52115e 100755 --- a/misc/mobile_41.asm +++ b/misc/mobile_41.asm @@ -1058,7 +1058,7 @@ Function1064d8: ; 1064d8 jr asm_1064ed asm_1064ed - ld de, w6_d000 + ld de, wBackupTilemap ld b, $0 ld a, [rSVBK] push af diff --git a/misc/mobile_45.asm b/misc/mobile_45.asm index 831f690e6..40e4cac16 100644 --- a/misc/mobile_45.asm +++ b/misc/mobile_45.asm @@ -5662,7 +5662,7 @@ Function1161d5: ; 1161d5 ld [rSVBK], a ld hl, Unknown_117356 - ld de, w6_d000 + ld de, wBackupTilemap ld bc, $0300 call CopyBytes diff --git a/misc/mobile_46.asm b/misc/mobile_46.asm index 44f1fc12c..8bfed5609 100755 --- a/misc/mobile_46.asm +++ b/misc/mobile_46.asm @@ -5986,7 +5986,7 @@ Function11ad1b: ; 11ad1b ld [wcd30], a ld a, $2 ld [wc7d4], a - callba Function40bdc + callba Pokedex_ChangeMode ret ; 11ad6e diff --git a/misc/mobile_5f.asm b/misc/mobile_5f.asm index e61689a9e..26bf5f28e 100644 --- a/misc/mobile_5f.asm +++ b/misc/mobile_5f.asm @@ -418,12 +418,12 @@ Function17d1f1: ; 17d1f1 call AddNTimes predef GetUnownLetter callab UpdateUnownDex - ld a, [wdef4] + ld a, [wFirstUnownSeen] and a jr nz, .asm_17d223 ld a, [UnownLetter] - ld [wdef4], a + ld [wFirstUnownSeen], a .asm_17d223 ret diff --git a/wram.asm b/wram.asm index 556e0f8c1..368fba11c 100644 --- a/wram.asm +++ b/wram.asm @@ -335,7 +335,7 @@ wc2cf:: ds 1 wc2d0:: ds 4 wc2d4:: ds 1 wc2d5:: ds 1 -wc2d6:: ds 1 +wLastDexEntry:: ds 1 wc2d7:: ds 1 wPreviousLandmark:: ds 1 wCurrentLandmark:: ds 1 @@ -762,7 +762,6 @@ wOTTrademon:: trademon wOTTrademon ds wPlayerTrademon - @ wc6d0:: -wPokedexDataStart:: PlayerSDefLevel:: ; c6d0 ds 1 wc6d1:: @@ -1003,10 +1002,20 @@ wc7b9:: ds 1 wc7ba:: ds 1 wc7bb:: ds 15 wc7ca:: ds 6 -wc7d0:: ds 1 -wc7d1:: ds 1 -wc7d2:: ds 1 -wc7d3:: ds 1 + + ds -$100 +wPokedexDataStart:: +wPokedexOrder:: ds NUM_POKEMON +- 1 +wPokedexOrderEnd:: ds 6 +wPokedexMetadata:: +wDexListingPage:: +wc7d0:: ds 1 ; Dex list page +wDexListingCursor:: +wc7d1:: ds 1 ; Dex cursor +wDexListingEnd:: +wc7d2:: ds 1 ; Last mon to display +wc7d3:: ds 1 ; Number of mons visible per dex list page +wCurrentDexMode:: ; Pokedex Mode wc7d4:: ds 1 ; Index of the topmost visible item in a scrolling menu wc7d5:: ds 1 ; Which row the cursor is at in a scrolling menu (0-6) wc7d6:: ds 1 @@ -1015,14 +1024,17 @@ wc7d8:: ds 1 wc7d9:: ds 1 wc7da:: ds 1 wDexSearchSlowpokeFrame:: ds 1 -wc7dc:: ds 1 +wUnlockedUnownMode:: ds 1 wc7dd:: ds 1 wc7de:: ds 1 wc7df:: ds 1 wc7e0:: ds 1 wc7e1:: ds 1 +wBackupDexListingCursor:: wc7e2:: ds 1 +wBackupDexListingPage:: wc7e3:: ds 1 +wDexCurrentLocation:: wc7e4:: ds 1 IF DEF(CRYSTAL11) wPokedexStatus:: @@ -1836,18 +1848,14 @@ CurPartyLevel:: ; d143 wd144:: ds 2 ; used when following a map warp -wNextWarp:: -wd146:: ds 1 -wNextMapGroup:: -wd147:: ds 1 -wNextMapNumber:: -wd148:: ds 1 -wPrevWarp:: -wd149:: ds 1 -wPrevMapGroup:: -wd14a:: ds 1 -wPrevMapNumber:: -wd14b:: ds 1 +; d146 +wNextWarp:: ds 1 +wNextMapGroup:: ds 1 +wNextMapNumber:: ds 1 +wPrevWarp:: ds 1 +wPrevMapGroup:: ds 1 +wPrevMapNumber:: ds 1 +; d14c wd14c:: ds 1 ; used in FollowNotExact wd14d:: ds 1 ; used in FollowNotExact @@ -2515,7 +2523,7 @@ PCItemsEnd:: wPokegearFlags:: ds 1 wRadioTuningKnob:: ds 1 -wd959:: ds 2 +wLastDexMode:: ds 2 WhichRegisteredItem:: ; d95b ds 1 RegisteredItem:: ; d95c @@ -2796,11 +2804,11 @@ wPlayerDataEnd:: wMapData:: VisitedSpawns:: ; dca5 - flag_array 27 + flag_array NUM_SPAWNS -wdca9:: ds 1 -wdcaa:: ds 1 -wdcab:: ds 1 +wDigWarp:: ds 1 +wDigMapGroup:: ds 1 +wDigMapNumber:: ds 1 ; used on maps like second floor pokécenter, which are reused, so we know which ; map to return to BackupWarpNumber:: ; dcac @@ -2812,10 +2820,8 @@ BackupMapNumber:: ; dcae ds 3 -wLastSpawnMapGroup:: -wdcb2:: ds 1 -wLastSpawnMapNumber:: -wdcb3:: ds 1 +wLastSpawnMapGroup:: ds 1 +wLastSpawnMapNumber:: ds 1 WarpNumber:: ; dcb4 ds 1 @@ -2876,7 +2882,7 @@ UnownDex:: ; ded9 UnlockedUnowns:: ; def3 ds 1 -wdef4:: ds 1 +wFirstUnownSeen:: ds 1 wDaycareMan:: ; def5 @@ -3099,8 +3105,10 @@ w5_dc3e:: ds $c SECTION "WRAM 6", WRAMX, BANK [6] -w6_d000:: ds $400 -w6_d400:: ds $200 +wBackupTilemap:: ds $20 * SCREEN_HEIGHT + ds $1c0 +wBackupAttrMap:: ds $20 * SCREEN_HEIGHT + ds -$40 w6_d600:: ds $200 w6_d800::