Ask anything your want about Megadrive/Genesis programming.
Moderator: BigEvilCorporation
-
KanedaFr
- Administrateur
- Posts: 1150
- Joined: Tue Aug 29, 2006 10:56 am
-
Contact:
Post
by KanedaFr » Tue Oct 26, 2010 11:33 am
Hi,
I would like to link my code at a specific address.
Ex:
Code: Select all
multipad.s
.org 0xFFB20
.globl get_multitap
get_multitap:
xxxx
When I look at the final rom.bin, the code is at 0x1030F4 (not 0xFFB20)
I also note that in the multipad.o, the code is near 0xFFB20
so, does using .org directive mean "in the objet file" ? I would like the linking process to use this directive....
does someone know how to do this ?
thanks
-
HardWareMan
- Very interested
- Posts: 749
- Joined: Sat Dec 15, 2007 7:49 am
- Location: Kazakhstan, Pavlodar
Post
by HardWareMan » Tue Oct 26, 2010 12:00 pm
Use assembler. :3
-
KanedaFr
- Administrateur
- Posts: 1150
- Joined: Tue Aug 29, 2006 10:56 am
-
Contact:
Post
by KanedaFr » Tue Oct 26, 2010 12:10 pm
I'm trying, I'm trying!
-
KanedaFr
- Administrateur
- Posts: 1150
- Joined: Tue Aug 29, 2006 10:56 am
-
Contact:
Post
by KanedaFr » Tue Oct 26, 2010 12:35 pm
Wow!
I succeed updating the ld script! (you see HardwareMan, I'm really trying hard!
)
Code: Select all
//in md.ld
.multipad 0x000FFB20:
{
multipad.o
} > rom = 0xFF
//in multipad.s
.section multipad
.globl get_multitap
get_multitap:
xxxx
is it the right way ?
-
Chilly Willy
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Post
by Chilly Willy » Tue Oct 26, 2010 5:50 pm
There's no "right" way, just ways that work.
Using a section is a decent way of doing it. You could also pad the rom.
Why do you need a specific address in the rom? Perhaps you can change the code to avoid needing a fixed address. That would be the "best" way to handle it.
-
KanedaFr
- Administrateur
- Posts: 1150
- Joined: Tue Aug 29, 2006 10:56 am
-
Contact:
Post
by KanedaFr » Wed Oct 27, 2010 7:23 am
I know if not something to do usually.
In fact, I'm trying some hacks on an existing rom so I need be sure I call the already coded functions
thanks anyway
-
HardWareMan
- Very interested
- Posts: 749
- Joined: Sat Dec 15, 2007 7:49 am
- Location: Kazakhstan, Pavlodar
Post
by HardWareMan » Wed Oct 27, 2010 7:44 am
Hmm. You need to call already coded procedure at specific address? In ASM, you just do: jsr $0FFB20. :3 Try harder to use ASM. :3
-
KanedaFr
- Administrateur
- Posts: 1150
- Joined: Tue Aug 29, 2006 10:56 am
-
Contact:
Post
by KanedaFr » Wed Oct 27, 2010 7:50 am
ah ah!
no...
I wrote a function that need to be added at a 0xFFB20 (free space in rom) and call it from an existing function (where I added the jsr $FFB20)
This function is fully written in asm... hopefully lot of you shared pure asm code I used to learn
I know functions wrote on asm are 'address dependant' (ex: thing like bra nearFunc became bra +=4 and not bra $233DD) so I prefer to code it at the correct address while testing so I could copy/paste the final binary from my test rom to hack rom
It's what I did : I successfully added 6 pad support to a 3 pad only game
more coming soon
-
GManiac
- Very interested
- Posts: 92
- Joined: Thu Jan 29, 2009 2:05 am
- Location: Russia
Post
by GManiac » Wed Oct 27, 2010 1:58 pm
You should declare you procedure in another section and then set base address of this section during linking. I don't familiar with linker options, all I know is how to assemble files with GNU toolchain. Something like this:
Code: Select all
m68k-elf-as.exe %1 -o %1.out -mcpu=68000 --register-prefix-optional
m68k-elf-ld.exe %1.out -o %1.o -e 0 -Tbss 0 -Tdata 0 -Ttext 0
m68k-elf-objcopy.exe %1.o %1.gen -O binary
Tbss, Tdata, Ttext are segments for linker.
-
powerofrecall
- Very interested
- Posts: 237
- Joined: Fri Apr 17, 2009 7:35 pm
- Location: USA
Post
by powerofrecall » Mon Dec 06, 2010 2:54 pm
KanedaFr wrote:ah ah!
no...
I wrote a function that need to be added at a 0xFFB20 (free space in rom) and call it from an existing function (where I added the jsr $FFB20)
This function is fully written in asm... hopefully lot of you shared pure asm code I used to learn
I know functions wrote on asm are 'address dependant' (ex: thing like bra nearFunc became bra +=4 and not bra $233DD) so I prefer to code it at the correct address while testing so I could copy/paste the final binary from my test rom to hack rom
It's what I did : I successfully added 6 pad support to a 3 pad only game
more coming soon
Please tell me it's Cyborg Justice
-
KanedaFr
- Administrateur
- Posts: 1150
- Joined: Tue Aug 29, 2006 10:56 am
-
Contact:
Post
by KanedaFr » Mon Dec 06, 2010 3:20 pm
sorry, it's NHL94...but I'm finishing my How to, so you'll be able to do it by yourself
-
KanedaFr
- Administrateur
- Posts: 1150
- Joined: Tue Aug 29, 2006 10:56 am
-
Contact:
Post
by KanedaFr » Mon Dec 13, 2010 10:08 pm
If you're interesting to know how I added 6 buttons support to NHL 94 (thanks to some of you!), read my
last technical doc.
I hope it will give some ideas to future Genny hackers
-
Chilly Willy
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Post
by Chilly Willy » Mon Dec 13, 2010 10:56 pm
Nice hacking tutorial. Just enough detail without getting too bogged down in code.