diff options
Diffstat (limited to 'engine/town_map.asm')
-rwxr-xr-x | engine/town_map.asm | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/engine/town_map.asm b/engine/town_map.asm index c58b9fd8..a92f49e4 100755 --- a/engine/town_map.asm +++ b/engine/town_map.asm @@ -25,9 +25,10 @@ DisplayTownMap: ; 70e3e (1c:4e3e) xor a ld [wWhichTownMapLocation], a pop af - jr .next -.changeSelectedLocation - ld hl, wTileMap + jr .enterLoop + +.townMapLoop + hlCoord 0, 0 ld bc, $114 call ClearScreenArea ld hl, TownMapOrder @@ -36,7 +37,7 @@ DisplayTownMap: ; 70e3e (1c:4e3e) ld b, 0 add hl, bc ld a, [hl] -.next +.enterLoop ld de, wTownMapCoords call LoadTownMapEntry ld a, [de] @@ -66,7 +67,7 @@ DisplayTownMap: ; 70e3e (1c:4e3e) call JoypadLowSensitivity ld a, [hJoy5] ld b, a - and D_UP | D_DOWN | A_BUTTON | B_BUTTON + and A_BUTTON | B_BUTTON | D_UP | D_DOWN jr z, .inputLoop ld a, (SFX_02_3c - SFX_Headers_02) / 3 call PlaySound @@ -78,7 +79,7 @@ DisplayTownMap: ; 70e3e (1c:4e3e) ld [wTownMapSpriteBlinkingEnabled], a ld [hJoy7], a ld [wAnimCounter], a - call TownMapCleanUp + call ExitTownMap pop hl pop af ld [hl], a @@ -86,21 +87,21 @@ DisplayTownMap: ; 70e3e (1c:4e3e) .pressedUp ld a, [wWhichTownMapLocation] inc a - cp NUM_TOWN_MAP_LOCATIONS - jr nz, .skipWrapping1 - xor a ; wrap to 0 -.skipWrapping1 + cp TownMapOrderEnd - TownMapOrder ; number of list items + 1 + jr nz, .noOverflow + xor a +.noOverflow ld [wWhichTownMapLocation], a - jp .changeSelectedLocation + jp .townMapLoop .pressedDown ld a, [wWhichTownMapLocation] dec a cp -1 - jr nz, .skipWrapping2 - ld a, NUM_TOWN_MAP_LOCATIONS - 1 ; wrap to last location -.skipWrapping2 + jr nz, .noUnderflow + ld a, TownMapOrderEnd - TownMapOrder - 1 ; number of list items +.noUnderflow ld [wWhichTownMapLocation], a - jp .changeSelectedLocation + jp .townMapLoop INCLUDE "data/town_map_order.asm" @@ -114,7 +115,7 @@ LoadTownMap_Nest: ; 70f60 (1c:4f60) push af ld [hl], $ff push hl - call Func_711ef + call DisplayWildLocations call GetMonName hlCoord 1, 0 call PlaceString @@ -123,7 +124,7 @@ LoadTownMap_Nest: ; 70f60 (1c:4f60) ld de, MonsNestText call PlaceString call WaitForTextScrollButtonPress - call TownMapCleanUp + call ExitTownMap pop hl pop af ld [hl], a @@ -151,7 +152,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90) push af ld [hl], $ff push hl - ld hl, wTileMap + hlCoord 0, 0 ld de, ToText call PlaceString ld a, [W_CURMAP] @@ -188,7 +189,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90) ld a, [hJoy5] ld b, a pop hl - and D_UP | D_DOWN | A_BUTTON | B_BUTTON + and A_BUTTON | B_BUTTON | D_UP | D_DOWN jr z, .inputLoop bit 0, b jr nz, .pressedA @@ -252,14 +253,14 @@ BuildFlyLocationsList: ; 71070 (1c:5070) ld e, a ld a, [W_TOWNVISITEDFLAG + 1] ld d, a - ld bc, 11 ; number of towns + ld bc, SAFFRON_CITY + 1 .loop srl d rr e ld a, $fe ; store $fe if the town hasn't been visited - jr nc, .next + jr nc, .notVisited ld a, b ; store the map number of the town if it has been visited -.next +.notVisited ld [hl], a inc hl inc b @@ -275,7 +276,7 @@ LoadTownMap: ; 7109b (1c:509b) call GBPalWhiteOutWithDelay3 call ClearScreen call UpdateSprites - ld hl, wTileMap + hlCoord 0, 0 ld b, $12 ld c, $12 call TextBoxBorder @@ -290,9 +291,9 @@ LoadTownMap: ; 7109b (1c:509b) ld bc, $8 ld a, BANK(MonNestIcon) call FarCopyDataDouble - ld hl, wTileMap + hlCoord 0, 0 ld de, CompressedMap -.loop +.nextTile ld a, [de] and a jr z, .done @@ -303,12 +304,12 @@ LoadTownMap: ; 7109b (1c:509b) swap a and $f add $60 -.writeRunLoop ; write one run of the RLE data +.writeRunLoop ld [hli], a dec c jr nz, .writeRunLoop inc de - jr .loop + jr .nextTile .done call EnableLCD ld b, $2 @@ -325,7 +326,7 @@ CompressedMap: ; 71100 (1c:5100) ; you can decompress this file with the redrle program in the extras/ dir INCBIN "gfx/town_map.rle" -TownMapCleanUp: ; 711ab (1c:51ab) +ExitTownMap: ; 711ab (1c:51ab) ; clear town map graphics data and load usual graphics data xor a ld [wTownMapSpriteBlinkingEnabled], a @@ -363,7 +364,7 @@ DrawPlayerOrBirdSprite: ; 711c4 (1c:51c4) ld bc, $a0 jp CopyData -Func_711ef: ; 711ef (1c:51ef) +DisplayWildLocations: ; 711ef (1c:51ef) callba FindWildLocationsOfMon call ZeroOutDuplicatesInList ld hl, wOAMBuffer @@ -371,7 +372,7 @@ Func_711ef: ; 711ef (1c:51ef) .loop ld a, [de] cp $ff - jr z, .loopDone + jr z, .exitLoop and a jr z, .nextEntry push hl @@ -381,14 +382,14 @@ Func_711ef: ; 711ef (1c:51ef) cp $19 ; Cerulean Cave's coordinates jr z, .nextEntry ; skip Cerulean Cave call TownMapCoordsToOAMCoords - ld a, $4 + ld a, $4 ; nest icon tile no. ld [hli], a xor a ld [hli], a .nextEntry inc de jr .loop -.loopDone +.exitLoop ld a, l and a ; were any OAM entries written? jr nz, .drawPlayerSprite |