diff --git a/engine/events.asm b/engine/events.asm index 0e8b29afc..e7598b595 100644 --- a/engine/events.asm +++ b/engine/events.asm @@ -167,10 +167,10 @@ HandleMap: ; 96773 cp 2 ; HandleMap ret nz - call Function967d1 + call HandleMapObjects call NextOverworldFrame - call Function967e1 - call Function967f4 + call HandleMapBackground + call CheckPlayerState ret ; 96795 @@ -226,21 +226,21 @@ HandleMapTimeAndJoypad: ; 967c1 ret ; 967d1 -Function967d1: ; 967d1 +HandleMapObjects: ; 967d1 callba HandleNPCStep ; engine/map_objects.asm callba _HandlePlayerStep call _CheckObjectEnteringVisibleRange ret ; 967e1 -Function967e1: ; 967e1 +HandleMapBackground: ; 967e1 callba _UpdateSprites callba ScrollScreen callba PlaceMapNameSign ret ; 967f4 -Function967f4: ; 967f4 +CheckPlayerState: ; 967f4 ld a, [wPlayerStepFlags] bit 5, a ; in the middle of step jr z, .events diff --git a/engine/events_2.asm b/engine/events_2.asm index af0f8df17..42e3ed8e4 100644 --- a/engine/events_2.asm +++ b/engine/events_2.asm @@ -458,7 +458,7 @@ HandleQueuedCommand: ; 97e79 .okay ld e, a ld d, 0 - ld hl, .Jumptable_ba + ld hl, .Jumptable add hl, de add hl, de add hl, de @@ -472,7 +472,7 @@ HandleQueuedCommand: ; 97e79 ret ; 97e94 -.Jumptable_ba: ; 97e94 +.Jumptable: ; 97e94 dba CmdQueue_Null dba CmdQueue_Null2 dba CmdQueue_StoneTable @@ -531,9 +531,9 @@ CmdQueue_Type4: ; 97ebc ld a, [hl] dec a ld [hl], a - jr z, .asm_97eee + jr z, .finish and $1 - jr z, .asm_97ee4 + jr z, .add ld hl, 2 add hl, bc ld a, [hSCY] @@ -541,7 +541,7 @@ CmdQueue_Type4: ; 97ebc ld [hSCY], a ret -.asm_97ee4 +.add ld hl, 2 add hl, bc ld a, [hSCY] @@ -549,7 +549,7 @@ CmdQueue_Type4: ; 97ebc ld [hSCY], a ret -.asm_97eee +.finish ld hl, 4 add hl, bc ld a, [hl] diff --git a/engine/events_3.asm b/engine/events_3.asm index dfcf60e73..e3e197adf 100755 --- a/engine/events_3.asm +++ b/engine/events_3.asm @@ -276,13 +276,13 @@ CheckForHiddenItems: ; b8172 ; Checks to see if there are hidden items on the screen that have not yet been found. If it finds one, returns carry. call GetMapScriptHeaderBank ld [Buffer1], a -; Get the coordinate of the bottom right corner of the screen, and load it in wd1ec/wd1ed. +; Get the coordinate of the bottom right corner of the screen, and load it in Buffer3/Buffer4. ld a, [XCoord] add SCREEN_WIDTH / 4 - ld [wd1ed], a + ld [Buffer4], a ld a, [YCoord] add SCREEN_HEIGHT / 4 - ld [wd1ec], a + ld [Buffer3], a ; Get the pointer for the first signpost header in the map... ld hl, wCurrentMapSignpostHeaderPointer ld a, [hli] @@ -301,7 +301,7 @@ CheckForHiddenItems: ; b8172 call .GetFarByte ld e, a ; Is the Y coordinate of the signpost on the screen? If not, go to the next signpost. - ld a, [wd1ec] + ld a, [Buffer3] sub e jr c, .next cp SCREEN_HEIGHT / 2 @@ -309,7 +309,7 @@ CheckForHiddenItems: ; b8172 ; Is the X coordinate of the signpost on the screen? If not, go to the next signpost. call .GetFarByte ld d, a - ld a, [wd1ed] + ld a, [Buffer4] sub d jr c, .next cp SCREEN_WIDTH / 2 diff --git a/engine/map_setup.asm b/engine/map_setup.asm index 38aaf5fec..dc013ffdd 100644 --- a/engine/map_setup.asm +++ b/engine/map_setup.asm @@ -258,8 +258,8 @@ MapSetupCommands: ; 15440 dba LoadMapPalettes ; 11 dba LoadWildMonData ; 12 dba RefreshMapSprites ; 13 - dba RunCallback_05_03 ; 14 - dba RunCallback_03 ; 15 + dba HandleNewMap ; 14 + dba InitCommandQueue ; 15 dba LoadObjectsRunCallback_02 ; 16 dba LoadSpawnPoint ; 17 dba EnterMapConnection ; 18 diff --git a/engine/pokedex.asm b/engine/pokedex.asm index 4d8b22ef4..e61a24964 100644 --- a/engine/pokedex.asm +++ b/engine/pokedex.asm @@ -694,9 +694,9 @@ Pokedex_UpdateSearchScreen: ; 40471 (10:4471) .show_search_results ld [wDexListingEnd], a ld a, [wDexListingScrollOffset] - ld [wc7e0], a + ld [wDexListingScrollOffsetBackup], a ld a, [wDexListingCursor] - ld [wc7e1], a + ld [wDexListingCursorBackup], a ld a, [wLastDexEntry] ld [wcf65], a xor a @@ -777,9 +777,9 @@ Pokedex_UpdateSearchResultsScreen: ; 40562 (10:4562) ret .return_to_search_screen - ld a, [wc7e0] + ld a, [wDexListingScrollOffsetBackup] ld [wDexListingScrollOffset], a - ld a, [wc7e1] + ld a, [wDexListingCursorBackup] ld [wDexListingCursor], a ld a, [wcf65] ld [wLastDexEntry], a diff --git a/engine/warp_connection.asm b/engine/warp_connection.asm index 515edce40..180aada87 100755 --- a/engine/warp_connection.asm +++ b/engine/warp_connection.asm @@ -1,5 +1,5 @@ -RunCallback_05_03: ; 1045b0 +HandleNewMap: ; 1045b0 call Clearwc7e8 call ResetMapBufferEventFlags call ResetFlashIfOutOfCave @@ -7,7 +7,7 @@ RunCallback_05_03: ; 1045b0 call ResetBikeFlags ld a, MAPCALLBACK_NEWMAP call RunMapCallback -RunCallback_03: ; 1045c4 +InitCommandQueue: ; 1045c4 callba ClearCmdQueue ld a, MAPCALLBACK_CMDQUEUE call RunMapCallback @@ -20,18 +20,16 @@ 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 + jp z, .south + cp UP + jp z, .north + cp LEFT + jp z, .west + cp RIGHT + jp z, .east ret -; 1045ed - -EnterWestConnection: ; 1045ed +.west ld a, [WestConnectedMapGroup] ld [MapGroup], a ld a, [WestConnectedMapNumber] @@ -64,11 +62,9 @@ EnterWestConnection: ; 1045ed ld [wOverworldMapAnchor], a ld a, h ld [wOverworldMapAnchor + 1], a - jp EnteredConnection -; 104629 + jp .done - -EnterEastConnection: ; 104629 +.east ld a, [EastConnectedMapGroup] ld [MapGroup], a ld a, [EastConnectedMapNumber] @@ -85,27 +81,25 @@ EnterEastConnection: ; 104629 ld h, [hl] ld l, a srl c - jr z, .skip_to_load + jr z, .skip_to_load2 ld a, [EastConnectedMapWidth] add 6 ld e, a ld d, 0 -.loop +.loop2 add hl, de dec c - jr nz, .loop + jr nz, .loop2 -.skip_to_load +.skip_to_load2 ld a, l ld [wOverworldMapAnchor], a ld a, h ld [wOverworldMapAnchor + 1], a - jp EnteredConnection -; 104665 + jp .done - -EnterNorthConnection: ; 104665 +.north ld a, [NorthConnectedMapGroup] ld [MapGroup], a ld a, [NorthConnectedMapNumber] @@ -128,11 +122,9 @@ EnterNorthConnection: ; 104665 ld [wOverworldMapAnchor], a ld a, h ld [wOverworldMapAnchor + 1], a - jp EnteredConnection -; 104696 + jp .done - -EnterSouthConnection: ; 104696 +.south ld a, [SouthConnectedMapGroup] ld [MapGroup], a ld a, [SouthConnectedMapNumber] @@ -155,10 +147,7 @@ EnterSouthConnection: ; 104696 ld [wOverworldMapAnchor], a ld a, h ld [wOverworldMapAnchor + 1], a - ; fallthrough -; 1046c4 - -EnteredConnection: ; 1046c4 +.done scf ret ; 1046c6 @@ -239,11 +228,11 @@ LoadMapTimeOfDay: ; 104750 callba ReplaceTimeOfDayPals callba UpdateTimeOfDayPal call OverworldTextModeSwitch - call Function104770 - call Function1047a3 + call .ClearBGMap + call .PushAttrMap ret -Function104770: ; 104770 (41:4770) +.ClearBGMap: ; 104770 (41:4770) ld a, VBGMap0 / $100 ld [wBGMapAnchor + 1], a xor a @@ -251,23 +240,27 @@ Function104770: ; 104770 (41:4770) ld [hSCY], a ld [hSCX], a callba ApplyBGMapAnchorToObjects + ld a, [rVBK] push af ld a, $1 ld [rVBK], a + xor a ld bc, VBGMap1 - VBGMap0 hlbgcoord 0, 0 call ByteFill + pop af ld [rVBK], a + ld a, $60 ld bc, VBGMap1 - VBGMap0 hlbgcoord 0, 0 call ByteFill ret -Function1047a3: ; 1047a3 (41:47a3) +.PushAttrMap: ; 1047a3 (41:47a3) decoord 0, 0 call .copy ld a, [hCGB] diff --git a/macros.asm b/macros.asm index bfdd38505..e72d2ee66 100644 --- a/macros.asm +++ b/macros.asm @@ -257,9 +257,9 @@ debgcoord EQUS "bgcoord de," bcbgcoord EQUS "bgcoord bc," bgrows EQUS "* $20" -palred EQUS "$0400 *" +palred EQUS "$0001 *" palgreen EQUS "$0020 *" -palblue EQUS "$0001 *" +palblue EQUS "$0400 *" dsprite: MACRO ; conditional segment is there because not every instance of diff --git a/main.asm b/main.asm index a8eba9a21..8aaf58391 100644 --- a/main.asm +++ b/main.asm @@ -5129,10 +5129,10 @@ LoadPoisonBGPals: ; cbcdd ld hl, BGPals ld c, $20 .loop -; RGB 31, 21, 28 - ld a, (palred 31 + palgreen 21 + palblue 28) % $100 +; RGB 28, 21, 31 + ld a, (palred 28 + palgreen 21 + palblue 31) % $100 ld [hli], a - ld a, (palred 31 + palgreen 21 + palblue 28) / $100 + ld a, (palred 28 + palgreen 21 + palblue 31) / $100 ld [hli], a dec c jr nz, .loop @@ -5358,11 +5358,11 @@ RotateUnownFrontpic: ; e0000 ld hl, OverworldMap ld de, sScratch - ld bc, $31 tiles + ld bc, 7 * 7 tiles call CopyBytes pop hl ld de, sScratch - ld c, $31 + ld c, 7 * 7 ld a, [hROMBank] ld b, a call Get2bpp @@ -5774,7 +5774,8 @@ DrawPokedexSearchResultsWindow: ; 1de1d1 (77:61d1) .esults_D ; 1de23c ; (SEARCH R) - db "ESULTS" + db "ESULTS" + next "" ; (### FOUN) next "D!@" diff --git a/wram.asm b/wram.asm index 7c769e006..d42c9d952 100644 --- a/wram.asm +++ b/wram.asm @@ -875,8 +875,8 @@ wUnlockedUnownMode:: ds 1 wDexCurrentUnownIndex:: ds 1 wDexUnownCount:: ds 1 wDexConvertedMonType:: ds 1 ; mon type converted from dex search mon type -wc7e0:: ds 1 -wc7e1:: ds 1 +wDexListingScrollOffsetBackup:: ds 1 +wDexListingCursorBackup:: ds 1 wBackupDexListingCursor:: wc7e2:: ds 1 wBackupDexListingPage:: @@ -896,7 +896,7 @@ ENDC wMiscEnd:: -wc7e8:: ds 24 +wc7e8:: ds 24 ; ???? SECTION "Overworld Map", WRAM0 [$c800] @@ -1878,7 +1878,7 @@ UsedSpritesEnd:: wd154:: ; d154 ds 31 ; 64 -wd173:: ds 1 +wd173:: ds 1 ; related to command queue type 3 ds 13 wd181:: ds 1 wd182:: ds 1