Identify wCrystalData's content and rename memory locations accordingly (#1191)

This commit is contained in:
Brianum
2025-06-30 17:37:37 +02:00
committed by GitHub
parent 36fdf1a1fc
commit 8f5a8c5b5b
7 changed files with 92 additions and 91 deletions

View File

@@ -1,21 +1,21 @@
InitCrystalData:
ld a, $1
ld [wd474], a
ld [wPlayerPrefecture], a
xor a
ld [wd473], a
ld [wPlayerAge], a
ld [wPlayerGender], a
ld [wd475], a
ld [wd476], a
ld [wd477], a
ld [wd478], a
ld [wPlayerPostalCode], a
ld [wPlayerPostalCode+1], a
ld [wPlayerPostalCode+2], a
ld [wPlayerPostalCode+3], a
ld [wd002], a
ld [wd003], a
ld a, [wd479]
ld a, [wCrystalFlags]
res 0, a ; ???
ld [wd479], a
ld a, [wd479]
ld [wCrystalFlags], a
ld a, [wCrystalFlags]
res 1, a ; ???
ld [wd479], a
ld [wCrystalFlags], a
ret
INCLUDE "mobile/mobile_12.asm"

View File

@@ -402,7 +402,7 @@ PostCreditsSpawn:
Continue_MobileAdapterMenu: ; unused
farcall CheckMobileAdapterStatus
ret nc
ld hl, wd479
ld hl, wCrystalFlags
bit 1, [hl]
ret nz
ld a, 5

View File

@@ -451,11 +451,11 @@ Function14d6c: ; unreferenced
ret
Function14d83: ; unreferenced
ld a, BANK(s4_a60c) ; aka BANK(s4_a60d) ; MBC30 bank used by JP Crystal; inaccessible by MBC3
ld a, BANK(s4_a60c) ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call OpenSRAM
xor a
ld [s4_a60c], a ; address of MBC30 bank
ld [s4_a60d], a ; address of MBC30 bank
ld [s4_a60c+1], a ; address of MBC30 bank
call CloseSRAM
ret
@@ -840,15 +840,15 @@ _SaveData:
call CopyBytes
; This block originally had some mobile functionality, but since we're still in
; BANK(sCrystalData), it instead overwrites the sixteen wEventFlags starting at 1:s4_a60e with
; garbage from wd479. This isn't an issue, since ErasePreviousSave is followed by a regular
; BANK(sCrystalData), it instead overwrites the sixteen wEventFlags starting at 1:sCrystalFlags with
; garbage from wCrystalFlags. This isn't an issue, since ErasePreviousSave is followed by a regular
; save that unwrites the garbage.
ld hl, wd479
ld hl, wCrystalFlags
ld a, [hli]
ld [s4_a60e + 0], a
ld [sCrystalFlags + 0], a
ld a, [hli]
ld [s4_a60e + 1], a
ld [sCrystalFlags + 1], a
jp CloseSRAM
@@ -861,12 +861,12 @@ _LoadData:
call CopyBytes
; This block originally had some mobile functionality to mirror _SaveData above, but instead it
; (harmlessly) writes the aforementioned wEventFlags to the unused wd479.
; (harmlessly) writes the aforementioned wEventFlags to the unused wCrystalFlags.
ld hl, wd479
ld a, [s4_a60e + 0]
ld hl, wCrystalFlags
ld a, [sCrystalFlags + 0]
ld [hli], a
ld a, [s4_a60e + 1]
ld a, [sCrystalFlags + 1]
ld [hli], a
jp CloseSRAM

View File

@@ -9,7 +9,7 @@ InitMobileProfile:
call z, InitCrystalData
call ClearBGPalettes
call Function48d3d
ld a, [wd479]
ld a, [wCrystalFlags]
bit 1, a
jr z, .not_yet_initialized
ld a, [wd003]
@@ -94,7 +94,7 @@ InitMobileProfile:
.asm_48113
hlcoord 11, 6
call Function487ec
ld a, [wd474]
ld a, [wPlayerPrefecture]
dec a
ld hl, Prefectures
call GetNthString
@@ -132,7 +132,7 @@ asm_4815f:
ld a, [wd002]
bit 6, a
jr z, .dont_check_b_button
ld hl, wd479
ld hl, wCrystalFlags
bit 1, [hl]
jr z, .dont_check_b_button
bit B_BUTTON_F, b
@@ -149,7 +149,7 @@ asm_4815f:
ret
Function48187:
ld a, [wd479]
ld a, [wCrystalFlags]
bit 1, a
jr nz, .asm_481f1
ld a, [wd003]
@@ -190,7 +190,7 @@ Function48187:
.asm_481db
bit 3, d
jr nz, .asm_481f1
ld a, [wd479]
ld a, [wCrystalFlags]
bit 0, a
jr nz, .asm_481f8
lb bc, 1, 8
@@ -198,7 +198,7 @@ Function48187:
call ClearBox
jr .asm_48201
.asm_481f1
ld a, [wd479]
ld a, [wCrystalFlags]
bit 0, a
jr nz, .asm_48201
.asm_481f8
@@ -257,7 +257,7 @@ Function4820d:
call ClearTilemap
ld b, SCGB_DIPLOMA
call GetSGBLayout
ld hl, wd479
ld hl, wCrystalFlags
set 1, [hl]
xor a
ret
@@ -344,7 +344,7 @@ Function48304:
ld a, [wMenuScrollPosition]
ld c, a
push bc
ld a, [wd474]
ld a, [wPlayerPrefecture]
dec a
cp $29
jr c, .asm_4833f
@@ -424,7 +424,7 @@ Function483bb:
ld hl, wScrollingMenuCursorPosition
ld a, [hl]
inc a
ld [wd474], a
ld [wPlayerPrefecture], a
dec a
ld b, a
ld hl, Prefectures
@@ -689,7 +689,7 @@ Function486bf:
ld [hli], a ; init x
ld a, [wd002]
bit 6, a
jr nz, .check_wd479
jr nz, .check_flags
call Function48725
ld a, 4
jr nc, .got_num_rows_1
@@ -698,8 +698,8 @@ Function486bf:
ld [hli], a
jr .got_num_rows_2
.check_wd479
ld a, [wd479]
.check_flags
ld a, [wCrystalFlags]
bit 1, a
jr nz, .four_rows
call Function48725
@@ -827,7 +827,7 @@ Function4876f:
ld c, $8
call Function48cdc
call WaitBGMap
ld a, [wd473]
ld a, [wPlayerAge]
and a
jr z, .asm_487ab
cp $64
@@ -849,7 +849,7 @@ Function4876f:
call Function487ec
ld c, 10
call DelayFrames
ld a, [wd473]
ld a, [wPlayerAge]
push af
.asm_487c6
call JoyTextDelay
@@ -860,9 +860,9 @@ Function4876f:
pop bc
jr nz, .asm_487da
ld a, b
ld [wd473], a
ld [wPlayerAge], a
.asm_487da
ld a, [wd473]
ld a, [wPlayerAge]
call ExitMenu
hlcoord 11, 6
call Function487ec
@@ -872,7 +872,7 @@ Function4876f:
Function487ec:
push hl
ld de, wd473
ld de, wPlayerAge
call Function487ff
pop hl
rept 4
@@ -920,7 +920,7 @@ Function4880e:
and a
ret
.asm_48838
ld hl, wd473
ld hl, wPlayerAge
ld a, [hl]
and a
jr z, .asm_48840
@@ -929,7 +929,7 @@ Function4880e:
ld [hl], a
jr .asm_4886f
.asm_48843
ld hl, wd473
ld hl, wPlayerAge
ld a, [hl]
cp $64
jr nc, .asm_4884c
@@ -938,25 +938,25 @@ Function4880e:
ld [hl], a
jr .asm_4886f
.asm_4884f
ld a, [wd473]
ld a, [wPlayerAge]
cp $5b
jr c, .asm_48858
ld a, $5a
.asm_48858
add $a
ld [wd473], a
ld [wPlayerAge], a
jr .asm_4886f
.asm_4885f
ld a, [wd473]
ld a, [wPlayerAge]
cp $a
jr nc, .asm_48868
ld a, $a
.asm_48868
sub $a
ld [wd473], a
ld [wPlayerAge], a
jr .asm_4886f
.asm_4886f
ld a, [wd473]
ld a, [wPlayerAge]
and a
jr z, .asm_48887
cp $64
@@ -1026,19 +1026,19 @@ Function488d3:
ld b, $1
ld c, $8
call Function48cdc
ld a, [wd475]
ld a, [wPlayerPostalCode]
and $f
ld d, $0
hlcoord 11, 10
call Function489ea
call WaitBGMap
ld a, [wd475]
ld a, [wPlayerPostalCode]
ld b, a
ld a, [wd476]
ld a, [wPlayerPostalCode+1]
ld c, a
ld a, [wd477]
ld a, [wPlayerPostalCode+2]
ld d, a
ld a, [wd478]
ld a, [wPlayerPostalCode+3]
ld e, a
push de
push bc
@@ -1127,20 +1127,20 @@ asm_48972:
jr nz, .asm_489b1
pop bc
ld a, b
ld [wd475], a
ld [wPlayerPostalCode], a
ld a, c
ld [wd476], a
ld [wPlayerPostalCode+1], a
pop bc
ld a, b
ld [wd477], a
ld [wPlayerPostalCode+2], a
ld a, c
ld [wd478], a
ld [wPlayerPostalCode+3], a
jr .asm_489c5
.asm_489b1
push af
ld a, [wd479]
ld a, [wCrystalFlags]
set 0, a
ld [wd479], a
ld [wCrystalFlags], a
ld a, [wd003]
set 3, a
ld [wd003], a
@@ -1170,36 +1170,36 @@ asm_48972:
Function489ea:
push de
ld a, [wd475]
ld a, [wPlayerPostalCode]
and $f
call Mobile12_Bin2Dec
ld a, [wd476]
ld a, [wPlayerPostalCode+1]
and $f0
swap a
inc hl
call Mobile12_Bin2Dec
ld a, [wd476]
ld a, [wPlayerPostalCode+1]
and $f
inc hl
call Mobile12_Bin2Dec
inc hl
ld de, String_48a38
call PlaceString
ld a, [wd477]
ld a, [wPlayerPostalCode+2]
and $f0
swap a
inc hl
call Mobile12_Bin2Dec
ld a, [wd477]
ld a, [wPlayerPostalCode+2]
and $f
inc hl
call Mobile12_Bin2Dec
ld a, [wd478]
ld a, [wPlayerPostalCode+3]
and $f0
swap a
inc hl
call Mobile12_Bin2Dec
ld a, [wd478]
ld a, [wPlayerPostalCode+3]
and $f
inc hl
call Mobile12_Bin2Dec
@@ -1239,12 +1239,12 @@ Function48a3a:
ld a, [wd003]
set 3, a
ld [wd003], a
ld a, [wd479]
ld a, [wCrystalFlags]
res 0, a
ld [wd479], a
ld [wCrystalFlags], a
xor a
ld bc, $4
ld hl, wd475
ld hl, wPlayerPostalCode
call ByteFill
jr Function48a9a
.asm_48a98
@@ -1286,40 +1286,40 @@ Function48ab5:
cp $6
jr .asm_48b15
.asm_48adf
ld hl, wd475
ld hl, wPlayerPostalCode
ld a, [hl]
and $f
jr .asm_48b1d
.asm_48ae7
ld hl, wd476
ld hl, wPlayerPostalCode+1
ld a, [hl]
swap a
or $f0
jr .asm_48b1d
.asm_48af1
ld hl, wd476
ld hl, wPlayerPostalCode+1
ld a, [hl]
and $f
jr .asm_48b1d
.asm_48af9
ld hl, wd477
ld hl, wPlayerPostalCode+2
ld a, [hl]
swap a
or $f0
jr .asm_48b1d
.asm_48b03
ld hl, wd477
ld hl, wPlayerPostalCode+2
ld a, [hl]
and $f
jr .asm_48b1d
.asm_48b0b
ld hl, wd478
ld hl, wPlayerPostalCode+3
ld a, [hl]
swap a
or $f0
jr .asm_48b1d
.asm_48b15
ld hl, wd478
ld hl, wPlayerPostalCode+3
ld a, [hl]
and $f
jr .asm_48b1d
@@ -1721,16 +1721,16 @@ Function48d2a:
ret
Function48d30:
ld hl, wd475
ld hl, wPlayerPostalCode
call Function48d4a
ld hl, wd477
ld hl, wPlayerPostalCode+2
call Function48d4a
ret
Function48d3d:
ld hl, wd475
ld hl, wPlayerPostalCode
call Function48d94
ld hl, wd477
ld hl, wPlayerPostalCode+2
call Function48d94
ret

View File

@@ -1982,11 +1982,11 @@ Function119054:
call CopyBytes
ldh a, [rWBK]
push af
ld a, BANK(wd474) ; aka BANK(wd475)
ld a, BANK(wPlayerPrefecture) ; aka BANK(wPlayerPostalCode)
ldh [rWBK], a
ld a, [wd474]
ld a, [wPlayerPrefecture]
ld [s5_b2f3], a
ld hl, wd475
ld hl, wPlayerPostalCode
ld de, s5_b2f4
ld bc, 4
call CopyBytes

View File

@@ -199,6 +199,8 @@ SECTION "Boxes 8-14", SRAM
SECTION "SRAM Mobile 1", SRAM
sCrystalDataJP::
; location of sCrystalData in the japanese version, relocated in international releases
ds $7
sEZChatMessages::
@@ -215,10 +217,9 @@ s4_a03b:: ds 37 * 40
s4_a603:: ds 8
s4_a60b:: db
s4_a60c:: db
s4_a60d:: db
s4_a60c:: dw
s4_a60e:: dw
sCrystalFlags:: ds 2
ds $1f0

View File

@@ -2868,15 +2868,15 @@ wPlayerGender::
; 0 male
; 1 female
db
wd473:: ds 1
wd474:: ds 1
wd475:: ds 1
wd476:: ds 1
wd477:: ds 1
wd478:: ds 1
; mobile profile
wPlayerAge:: ds 1
wPlayerPrefecture:: ds 1
wPlayerPostalCode:: ds 4
wCrystalDataEnd::
wd479:: ds 2
wCrystalFlags::
; flags related to mobile profile
flag_array 16
wGameData::
wPlayerData::