Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace hardcoded banks & addresses in non-mobile code #460

Merged
merged 15 commits into from
Jan 22, 2018

Conversation

CuriouserThing
Copy link
Contributor

@CuriouserThing CuriouserThing commented Jan 3, 2018

Addresses #413.

"Replace" is defined here as replacing constant numbers with BANK functions (in the case of banks) or labels (in the case of addresses), except where the use of a bank or address appears unnecessary and therefore can't be clearly labeled (such cases should be explicitly commented, though).

"Non-mobile code" is defined here as all code outside mobile/*.asm, lib/mobile/main.asm , and home/mobile.asm. (There are still thousands of hardcoded banks & addresses in mobile code.)

  • Replace hardcoded ROM banks. (Possibly unneeded?)
  • Replace hardcoded SRAM banks.
  • Replace hardcoded WRAM banks.
  • Replace hardcoded ROM addresses.
  • Replace hardcoded SRAM addresses.
  • Replace hardcoded WRAM addresses.
  • Replace hardcoded VRAM banks & addresses. (This isn't advisable while VRAM is still vaguely and incompletely labeled).

(fb825a8 is irrelevant and a relic I committed before I knew the scope of this PR. But I left it in since it just makes one minor improvement to mobile code.)

@CuriouserThing CuriouserThing changed the title Remove hardcoded banks & addresses in non-mobile code [DNM] Remove hardcoded banks & addresses in non-mobile code Jan 3, 2018
home/names.asm Outdated
@@ -7,7 +7,7 @@ NamesPointers:: ; 33ab
dbw 0, PartyMonOT
dbw 0, OTPartyMonOT
dba TrainerClassNames
dbw $4, $4b52 ; within PackMenuGFX
dbw $4, PackMenuGFX + 60
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make that dba PackMenuGFX + 60 since $4 is BANK(PackMenuGFX + 60).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BANK() can't evaluate arithmetic (at least I think that's the problem). dbw BANK(PackMenuGFX), PackMenuGFX + 60 is the best that can be done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh well, dbw BANK(PackMenuGFX), PackMenuGFX + 60 is good enough.

ld a, [rSVBK]
push af
ld a, $1
ld [rSVBK], a
farcall SaveGameData_
REPT _NARG
Copy link
Member

@xCrystal xCrystal Jan 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rept, shift, and endr should be lowercase! (shift should be tabulated too).

@@ -13,7 +13,7 @@ GBCOnlyScreen: ; 4ea82
ld de, wd000
ld a, [rSVBK]
push af
ld a, 0
ld a, 0 ; this is tantamount to selecting Bank 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please clarify that this isn't a typo; writing 0 to rSVBK has the same effect as 1. (SVBK)

@xCrystal
Copy link
Member

xCrystal commented Jan 4, 2018

While at it, there may be more hardcoded WRAM banks in calls to FarCopyWRAM and GetFarWRAMByte (GetFarWRAMWord appears to be unreferenced).

@CuriouserThing CuriouserThing changed the title [DNM] Remove hardcoded banks & addresses in non-mobile code [DNM] Replace hardcoded banks & addresses in non-mobile code Jan 4, 2018
engine/menu.asm Outdated
@@ -730,15 +730,15 @@ Function24423: ; 24423
ld a, [VramState]
bit 0, a
ret z
xor a
xor a ; effectively ld a, BANK(sScratch)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other parts of the code just comment the implied zero value: xor a ; PARTYMON, xor a ; OAKS_POKEMON_TALK, xor a ; LOW(vBGMap0), etc.

@CuriouserThing
Copy link
Contributor Author

I'm currently tracing backward from MBC3RomBank and don't think there are any hardcoded ROM banks left from what I'm seeing. If anyone has any leads, please share, since I'm about done this otherwise.

@CuriouserThing CuriouserThing changed the title [DNM] Replace hardcoded banks & addresses in non-mobile code Replace hardcoded banks & addresses in non-mobile code Jan 9, 2018
roukaour added a commit to Rangi42/pokecrystal that referenced this pull request Jan 15, 2018
 (resolve PR pret#460)

# Conflicts:
#	engine/battle/core.asm
#	engine/save.asm
@yenatch yenatch merged commit 6c5cd7a into pret:master Jan 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants