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

Update code for rgbds 0.3.3 #27

Merged
merged 3 commits into from
Sep 29, 2017
Merged

Update code for rgbds 0.3.3 #27

merged 3 commits into from
Sep 29, 2017

Conversation

Pokechu22
Copy link
Contributor

This PR updates the code for RGBDS 0.3.3. RGBDS 0.2.5 is no longer supported.

I should note that I have no idea what I'm doing. This linkerscript may not be correct (and I'm not sure if linkerscript.link is the best name - pret/pokecrystal#389 uses linkerscript.ld, but the others use linkerscript.link). I haven't removed existing bank definitions from the files themselves, and there are some section definitions that aren't in the linkerscript.

However, the rom hash matches, and the symbol list matches that from before this change. So I think everything works.

The change that I really don't know for sure, though, is my change to the stack. Originally, it looked like this (bottom of wram.asm):

wGBCBasePalPointers:: ds NUM_ACTIVE_PALS * 2 ; dee1
wGBCPal:: ds PAL_SIZE ; dee9
wLastBGP:: ds 1 ; def1
wLastOBP0:: ds 1 ; def2
wLastOBP1:: ds 1 ; def3
wdef5:: ds 1 ; def4
wBGPPalsBuffer:: ds NUM_ACTIVE_PALS * PAL_SIZE ; def5

SECTION "Stack", WRAMX[$dfff], BANK[1]
wStack:: ; dfff
	ds -$100

However, ds -$100 is no longer legal, so I tried changing it to this, based off of what is done in pokered:

wGBCBasePalPointers:: ds NUM_ACTIVE_PALS * 2 ; dee1
wGBCPal:: ds PAL_SIZE ; dee9
wLastBGP:: ds 1 ; def1
wLastOBP0:: ds 1 ; def2
wLastOBP1:: ds 1 ; def3
wdef5:: ds 1 ; def4
wBGPPalsBuffer:: ds NUM_ACTIVE_PALS * PAL_SIZE ; def5

SECTION "Stack", WRAMX[$df00], BANK[1]
	ds $ff
wStack:: ; dfff

However, that also doesn't work:

error: Unable to place 'Stack' (WRAMX section) at $DF00 in bank $201
make: *** [pokeyellow.gbc] Error 1

As far as I can tell, this is because wBGPPalsBuffer extends into $DF00 ($def5+NUM_ACTIVE_PALS * PAL_SIZE=$df15). This seems to me like a problem, but it's the way the code was written, and as far as I can tell, it's how it's actually used (but I'm not good with assembly). As far as I can tell this means that that buffer will clobber the stack.

I've changed the code to this:

wGBCBasePalPointers:: ds NUM_ACTIVE_PALS * 2 ; dee1
wGBCPal:: ds PAL_SIZE ; dee9
wLastBGP:: ds 1 ; def1
wLastOBP0:: ds 1 ; def2
wLastOBP1:: ds 1 ; def3
wdef5:: ds 1 ; def4
wBGPPalsBuffer:: ds NUM_ACTIVE_PALS * PAL_SIZE ; def5

SECTION "Stack", WRAMX[$df15], BANK[1]
	ds $ea
wStack:: ; dfff

which works fine (everything still compiles and the roms match) but I'm not entirely confident that it's correct.

See also:

The stack size also is smaller because wBGPPalsBuffer cut into it.  This seems wrong, but I don't know how to do it correctly.
@yenatch
Copy link
Collaborator

yenatch commented Sep 26, 2017

pokecrystal is using pokecrystal.ld. I think this is the best way to go for the filename. Or pokeyellow.link.

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.

None yet

3 participants