ref: df118afbcaef31c26df433ae52c26335796cdb40
parent: 617ba8be3d86ea7c81d4481d67d8fee67caeeee9
author: mid-kid <esteve.varela@gmail.com>
date: Mon Nov 20 14:50:54 EST 2017
Move all of constants/sram_constants.asm into sram This way we can easily use `BANK()` where appropriate, and it is more tidy.
--- a/constants.asm
+++ b/constants.asm
@@ -4,7 +4,6 @@
INCLUDE "hram.asm"
INCLUDE "constants/wram_constants.asm"
-INCLUDE "constants/sram_constants.asm"
INCLUDE "constants/pokemon_constants.asm"
INCLUDE "constants/type_constants.asm"
INCLUDE "constants/move_constants.asm"
--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -142,6 +142,7 @@
WILDMON_GRASS_STRUCTURE_LENGTH EQU 2 + 3 * (1 + 2 * NUM_WILDMONS_PER_AREA_TIME_OF_DAY)
MOBILE_EVENT_OBJECT_GS_BALL EQU $b
+MOBILE_LOGIN_PASSWORD_LENGTH EQU 17
MALE EQU 0
FEMALE EQU 1
--- a/constants/sram_constants.asm
+++ /dev/null
@@ -1,53 +1,0 @@
-; Mobile bank 5
-
-; sMobileEventIndex EQU $a000 ; moved to 1:BE3C in English
-sTrainerRankings EQU $a001
-sTrainerRankingGameTimeHOF EQU $a001
-sTrainerRankingStepCountHOF EQU $a005
-sTrainerRankingHealingsHOF EQU $a009
-sTrainerRankingBattlesHOF EQU $a00d
-sTrainerRankingStepCount EQU $a010
-sTrainerRankingBattleTowerWins EQU $a014
-sTrainerRankingTMsHMsTaught EQU $a018
-sTrainerRankingBattles EQU $a01b
-sTrainerRankingWildBattles EQU $a01e
-sTrainerRankingTrainerBattles EQU $a021
-sTrainerRankingUnused1 EQU $a024
-sTrainerRankingHOFEntries EQU $a027
-sTrainerRankingWildMonsCaught EQU $a02a
-sTrainerRankingHookedEncounters EQU $a02d
-sTrainerRankingEggsHatched EQU $a030
-sTrainerRankingMonsEvolved EQU $a033
-sTrainerRankingFruitPicked EQU $a036
-sTrainerRankingHealings EQU $a039
-sTrainerRankingMysteryGift EQU $a03c
-sTrainerRankingTrades EQU $a03f
-sTrainerRankingFly EQU $a042
-sTrainerRankingSurf EQU $a045
-sTrainerRankingWaterfall EQU $a048
-sTrainerRankingWhiteOuts EQU $a04b
-sTrainerRankingLuckyNumberShow EQU $a04e
-sTrainerRankingPhoneCalls EQU $a051
-sTrainerRankingUnused2 EQU $a054
-sTrainerRankingLinkBattles EQU $a057
-sTrainerRankingSplash EQU $a05a
-sTrainerRankingTreeEncounters EQU $a05d
-sTrainerRankingUnused3 EQU $a060
-sTrainerRankingColosseumWins EQU $a063
-sTrainerRankingColosseumLosses EQU $a066
-sTrainerRankingColosseumDraws EQU $a069
-sTrainerRankingSelfdestruct EQU $a06c
-sTrainerRankingCurrentSlotsStreak EQU $a06f
-sTrainerRankingLongestSlotsStreak EQU $a071
-sTrainerRankingTotalSlotsPayouts EQU $a073
-sTrainerRankingTotalBattlePayouts EQU $a077
-sTrainerRankingLongestMagikarp EQU $a07b
-sTrainerRankingShortestMagikarp EQU $a07d
-sTrainerRankingBugContestScore EQU $a07f
-sTrainerRankingsChecksum EQU $a081
-sTrainerRankingsEnd EQU $a083
-; sMobileEventIndexBackup EQU $a083 ; moved to 1:BE44 in English
-sTrainerRankingsBackup EQU $a084
-
-sMobileLoginPassword EQU $aa4b
-LOGIN_PASSWORD_LENGTH EQU 17
--- a/misc/mobile_41.asm
+++ b/misc/mobile_41.asm
@@ -5,7 +5,7 @@
; Copies certain values at the time the player enters the Hall of Fame.
TrainerRankings_HallOfFame2:: mobile ; 0x105ef6
- ld a, $5
+ ld a, BANK(sTrainerRankingGameTimeHOF)
call GetSRAMBank
ld hl, GameTimeHours
@@ -36,7 +36,7 @@
; 105f33
TrainerRankings_MagikarpLength: mobile ; 105f33
- ld a, $5
+ ld a, BANK(sTrainerRankingLongestMagikarp)
call GetSRAMBank
ld de, Buffer1
ld hl, sTrainerRankingLongestMagikarp
@@ -104,7 +104,7 @@
; 105f79
TrainerRankings_BugContestScore: mobile ; 105f79
- ld a, $5
+ ld a, BANK(sTrainerRankingBugContestScore)
call GetSRAMBank
ld a, [hProduct]
ld hl, sTrainerRankingBugContestScore
@@ -133,7 +133,7 @@
; 105f9f
TrainerRankings_AddToSlotsWinStreak: mobile ; 105f9f
- ld a, $5
+ ld a, BANK(sTrainerRankingCurrentSlotsStreak)
call GetSRAMBank
; Increment the current streak
@@ -173,7 +173,7 @@
; 105fd0
TrainerRankings_EndSlotsWinStreak: mobile ; 105fd0
- ld a, $5
+ ld a, BANK(sTrainerRankingCurrentSlotsStreak)
call GetSRAMBank
ld hl, sTrainerRankingCurrentSlotsStreak
xor a
@@ -185,7 +185,7 @@
; 105fe3
TrainerRankings_AddToSlotsPayouts: mobile ; 105fe3
- ld a, $5
+ ld a, BANK(sTrainerRankingTotalSlotsPayouts)
call GetSRAMBank
ld hl, sTrainerRankingTotalSlotsPayouts + 3
ld a, e
@@ -213,7 +213,7 @@
; 106008
TrainerRankings_AddToBattlePayouts: mobile ; 106008
- ld a, $5
+ ld a, BANK(sTrainerRankingTotalBattlePayouts)
call GetSRAMBank
ld hl, sTrainerRankingTotalBattlePayouts + 3
ld a, [bc]
@@ -416,7 +416,7 @@
; Increments a big-endian value of bc + 1 bytes at hl
TrainerRankings_Increment: ; 10612d
- ld a, $5
+ ld a, BANK(sTrainerRankings)
call GetSRAMBank
push hl
push de
@@ -453,7 +453,7 @@
; Used when SRAM bank 5 isn’t already loaded — what’s the point of this?
UpdateTrainerRankingsChecksum2: mobile ; 106155
- ld a, $5
+ ld a, BANK(sTrainerRankings)
call GetSRAMBank
call UpdateTrainerRankingsChecksum
call CloseSRAM
--- a/misc/mobile_45.asm
+++ b/misc/mobile_45.asm
@@ -7249,13 +7249,13 @@
call PlaceString
ld a, $1e
ld [wcd4e], a
- ld a, $5
+ ld a, BANK(sMobileLoginPassword)
call GetSRAMBank
ld a, [wcd4f]
ld [sMobileLoginPassword], a
ld hl, $c708
ld de, sMobileLoginPassword + 1
- ld bc, LOGIN_PASSWORD_LENGTH
+ ld bc, MOBILE_LOGIN_PASSWORD_LENGTH
call CopyBytes
call CloseSRAM
ld a, [wcd4f]
--- a/misc/mobile_46.asm
+++ b/misc/mobile_46.asm
@@ -4224,10 +4224,10 @@
ret
Function119ec2: ; 119ec2 (46:5ec2)
- ld a, $5
+ ld a, BANK(sMobileLoginPassword)
call GetSRAMBank
xor a
- ld [sMobileLoginPassword + LOGIN_PASSWORD_LENGTH], a
+ ld [sMobileLoginPassword + MOBILE_LOGIN_PASSWORD_LENGTH], a
ld de, sMobileLoginPassword + 1
.loop
ld a, [de]
@@ -4395,7 +4395,7 @@
; 11a00e
Function11a00e: ; 11a00e
- ld a, $5
+ ld a, BANK(sMobileLoginPassword)
call GetSRAMBank
ld a, [sMobileLoginPassword]
and a
@@ -4404,7 +4404,7 @@
call CloseSRAM
and a
ret nz
- ld a, $5
+ ld a, BANK(sMobileLoginPassword)
call GetSRAMBank
xor a
ld [sMobileLoginPassword], a
--- a/misc/mobile_5f.asm
+++ b/misc/mobile_5f.asm
@@ -4688,7 +4688,7 @@
ret nz
.asm_17f5a1
- ld a, $5
+ ld a, BANK(sMobileLoginPassword)
call GetSRAMBank
xor a
ld [sMobileLoginPassword], a
--- a/misc/mobile_menu.asm
+++ b/misc/mobile_menu.asm
@@ -441,11 +441,11 @@
ld a, [wMenuCursorY]
cp $2
jr z, .dont_delete_password
- ld a, $5
+ ld a, BANK(sMobileLoginPassword)
call GetSRAMBank
ld hl, sMobileLoginPassword
xor a
- ld bc, LOGIN_PASSWORD_LENGTH
+ ld bc, MOBILE_LOGIN_PASSWORD_LENGTH
call ByteFill
call CloseSRAM
ld hl, UnknownText_0x4a35d
--- a/pokecrystal.link
+++ b/pokecrystal.link
@@ -356,3 +356,5 @@
"Boxes 1-7"
SRAM $03
"Boxes 8-14"
+SRAM $05
+ "SRAM Mobile"
--- a/sram.asm
+++ b/sram.asm
@@ -243,3 +243,57 @@
box sBox12
box sBox13
box sBox14
+
+SECTION "SRAM Mobile", SRAM, BANK [5]
+ds 1 ; Former location for sMobileEventIndex, moved to 1:BE3C in English
+sTrainerRankings:: ; a001
+sTrainerRankingGameTimeHOF:: ds 4
+sTrainerRankingStepCountHOF:: ds 4
+sTrainerRankingHealingsHOF:: ds 4
+sTrainerRankingBattlesHOF:: ds 3
+sTrainerRankingStepCount:: ds 4
+sTrainerRankingBattleTowerWins:: ds 4
+sTrainerRankingTMsHMsTaught:: ds 3
+sTrainerRankingBattles:: ds 3
+sTrainerRankingWildBattles:: ds 3
+sTrainerRankingTrainerBattles:: ds 3
+sTrainerRankingUnused1:: ds 3
+sTrainerRankingHOFEntries:: ds 3
+sTrainerRankingWildMonsCaught:: ds 3
+sTrainerRankingHookedEncounters:: ds 3
+sTrainerRankingEggsHatched:: ds 3
+sTrainerRankingMonsEvolved:: ds 3
+sTrainerRankingFruitPicked:: ds 3
+sTrainerRankingHealings:: ds 3
+sTrainerRankingMysteryGift:: ds 3
+sTrainerRankingTrades:: ds 3
+sTrainerRankingFly:: ds 3
+sTrainerRankingSurf:: ds 3
+sTrainerRankingWaterfall:: ds 3
+sTrainerRankingWhiteOuts:: ds 3
+sTrainerRankingLuckyNumberShow:: ds 3
+sTrainerRankingPhoneCalls:: ds 3
+sTrainerRankingUnused2:: ds 3
+sTrainerRankingLinkBattles:: ds 3
+sTrainerRankingSplash:: ds 3
+sTrainerRankingTreeEncounters:: ds 3
+sTrainerRankingUnused3:: ds 3
+sTrainerRankingColosseumWins:: ds 3
+sTrainerRankingColosseumLosses:: ds 3
+sTrainerRankingColosseumDraws:: ds 3
+sTrainerRankingSelfdestruct:: ds 3
+sTrainerRankingCurrentSlotsStreak:: ds 2
+sTrainerRankingLongestSlotsStreak:: ds 2
+sTrainerRankingTotalSlotsPayouts:: ds 4
+sTrainerRankingTotalBattlePayouts:: ds 4
+sTrainerRankingLongestMagikarp:: ds 2
+sTrainerRankingShortestMagikarp:: ds 2
+sTrainerRankingBugContestScore:: ds 2
+sTrainerRankingsChecksum:: ds 2
+sTrainerRankingsEnd:: ; a083
+ds 1 ; Former location for sMobileEventIndexBackup, moved to 1:BE44 in English
+sTrainerRankingsBackup:: ds sTrainerRankingsEnd - sTrainerRankings
+
+ds $945
+; aa4b
+sMobileLoginPassword:: ds MOBILE_LOGIN_PASSWORD_LENGTH