Use constants to delineate map types, and factor out more data

This commit is contained in:
Rangi 2020-08-31 10:23:19 -04:00
parent 70eac3a1f7
commit bfd9f617c9
17 changed files with 126 additions and 135 deletions

View file

@ -1573,7 +1573,7 @@ ItemUseCardKey:
ld b, a
.loop
ld a, [hli]
cp $ff
cp -1
jp z, ItemUseNotTime
cp b
jr nz, .nextEntry1
@ -1600,46 +1600,7 @@ ItemUseCardKey:
set 7, [hl]
ret
; These tables are probably supposed to be door locations in Silph Co.,
; but they are unused.
; The reason there are 3 tables is unknown.
; Format:
; 00: Map ID
; 01: Y
; 02: X
; 03: ID?
CardKeyTable1:
db SILPH_CO_2F,$04,$04,$00
db SILPH_CO_2F,$04,$05,$01
db SILPH_CO_4F,$0C,$04,$02
db SILPH_CO_4F,$0C,$05,$03
db SILPH_CO_7F,$06,$0A,$04
db SILPH_CO_7F,$06,$0B,$05
db SILPH_CO_9F,$04,$12,$06
db SILPH_CO_9F,$04,$13,$07
db SILPH_CO_10F,$08,$0A,$08
db SILPH_CO_10F,$08,$0B,$09
db $ff
CardKeyTable2:
db SILPH_CO_3F,$08,$09,$0A
db SILPH_CO_3F,$09,$09,$0B
db SILPH_CO_5F,$04,$07,$0C
db SILPH_CO_5F,$05,$07,$0D
db SILPH_CO_6F,$0C,$05,$0E
db SILPH_CO_6F,$0D,$05,$0F
db SILPH_CO_8F,$08,$07,$10
db SILPH_CO_8F,$09,$07,$11
db SILPH_CO_9F,$08,$03,$12
db SILPH_CO_9F,$09,$03,$13
db $ff
CardKeyTable3:
db SILPH_CO_11F,$08,$09,$14
db SILPH_CO_11F,$09,$09,$15
db $ff
INCLUDE "data/events/card_key_coords.asm"
ItemUsePokedoll:
ld a, [wIsInBattle]

View file

@ -1,3 +1,5 @@
NOT_VISITED EQU $fe
DisplayTownMap:
call LoadTownMap
ld hl, wUpdateSpritesEnabled
@ -224,7 +226,7 @@ LoadTownMap_Fly::
ld a, [hl]
cp $ff
jr z, .wrapToStartOfList
cp $fe
cp NOT_VISITED
jr z, .pressedUp ; skip past unvisited towns
jp .townMapFlyLoop
.wrapToStartOfList
@ -236,11 +238,11 @@ LoadTownMap_Fly::
ld a, [hl]
cp $ff
jr z, .wrapToEndOfList
cp $fe
cp NOT_VISITED
jr z, .pressedDown ; skip past unvisited towns
jp .townMapFlyLoop
.wrapToEndOfList
ld hl, wFlyLocationsList + 11
ld hl, wFlyLocationsList + NUM_CITY_MAPS
jr .pressedDown
ToText:
@ -254,11 +256,11 @@ BuildFlyLocationsList:
ld e, a
ld a, [wTownVisitedFlag + 1]
ld d, a
ld bc, SAFFRON_CITY + 1
lb bc, 0, NUM_CITY_MAPS
.loop
srl d
rr e
ld a, $fe ; store $fe if the town hasn't been visited
ld a, NOT_VISITED
jr nc, .notVisited
ld a, b ; store the map number of the town if it has been visited
.notVisited
@ -554,7 +556,7 @@ ZeroOutDuplicatesInList:
LoadTownMapEntry:
; in: a = map number
; out: lower nybble of [de] = x, upper nybble of [de] = y, hl = address of name
cp REDS_HOUSE_1F
cp FIRST_INDOOR_MAP
jr c, .external
ld bc, 4
ld hl, InternalMapEntries