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

Add a section to the readme on how to recompile #5

Open
sudo-sandwich opened this issue Nov 22, 2021 · 1 comment
Open

Add a section to the readme on how to recompile #5

sudo-sandwich opened this issue Nov 22, 2021 · 1 comment

Comments

@sudo-sandwich
Copy link

I am unable to recompile identically to the original rom using devkitARM.

arm-none-eabi-gcc -o rom.elf -specs=gba.specs rom.s

Gives the following output:

rom.s: Assembler messages:
rom.s:42584: use of r13 is deprecated
rom.s:42608: use of r13 is deprecated
rom.s:42623: use of r13 is deprecated
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/11.1.0/../../../../arm-none-eabi/bin/ld.exe: c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/11.1.0/../../../../arm-none-eabi/lib/gba_crt0.o: in function `CIDExit':
(.crt0+0x20c): undefined reference to `main'
collect2.exe: error: ld returned 1 exit status
@JustinJayL
Copy link

I'm still figuring this out myself, but I'll share what I have so far:

#command to compile assembly into object file
arm-none-eabi-as -mcpu=arm7tdmi -mthumb-interwork rom.s -o rom.o

#command to link object file (WIP)
arm-none-eabi-ld rom.o rom.elf

#command to format GBA Header portions inside ELF file. (Maybe not necessary for my setup?)
tools/gbafix/gbafix hmfmt.elf -t"HARVESTMOGBA" -c"A4NE" -m"E9" -r"0" --silent
#-r"0"
#-t[<title>] Patch title. Stripped filename if none given.
#-c<game_code> Patch game code (four characters)
#-m<maker_code> Patch maker code (two characters)
#-r Patch game version (number)
#I found a tool called gbata to get me these values from the original rom.

#Command to pull binary out of elf and into a rom file, then pad out the length I'm guessing?
#to find the --pad-to value, I opened up the original rom in HxD and found the last row, then rounded it up.
arm-none-eabi-objcopy -O binary --gap-fill 0xFF --pad-to 0x800000 rom.elf rom.gba

This gets me a correctly sized, validly formatted .gba file. It only has about 10 bytes different from the original rom file. It won't run in an emulator, because of an error that execution jumped to an invalid address.

If you figure it out further from here, let me know.

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

No branches or pull requests

2 participants