I've been keen on MD development for some time and have now taken the plunge and am shoulder deep in documentation and information. [And loving it, btw ].
As a bit of background, I'm fairly competent in an array of languages, I'd done some z80 programming about 10 years back, so am not entirely new to ASM. That being said, I am wanting to get a complete understanding of the MD system from the ground up.
I run a linux system, and I've been setting up my toolchain for building the ROM images. I've built the gendev/sgdk project, and that is working fine. I've compiled some code which has booted successfully on my MD system.
While the SGDK is fantastic for streamlining building projects, I would like to get a more raw taste of the intialisation and startup protocols of the MD and how the code all goes together. I'd like to have my own init code containing the ROM header and startup, and compile it manually.
I have been following the linux-specific instructions at http://darkdust.net/writings/megadrive. I didn't rebuild a whole new m68k toolchain, as I can just use the one built for gendev/SGDK. So I've just been following his code.
Now, to my possible problem. When I compile his code using his sample code , I obtain a .bin file, however it does not run on the MD [hardware and emulator]. Taking a look in a hex editor, my compiled binary is exactly the same to the included one, except it has an extra 18 bytes of zeroes at the end. To confirm, even the included 'firststeps.bin' does not boot on my MD.
The sample code is split up into init.S [the ROM header and initialisations] and firststeps.S [VDP test code]. I put the firststeps.S file into a blank SGDK project and hit make. The binary produced boots up no problem with the SGDK boot code.
Am I correct in assuming the init code on darkdust is not correct to produce a bootable ROM? Or is there something wrong with how I am building the ROM?
Here is my output when manually compiling...
Code: Select all
m68k-elf-as -m68000 init.S -o init.o
m68k-elf-as -m68000 firststeps.S -o firststeps.o
m68k-elf-ld init.o firststeps.o --oformat binary -o firststeps_2.bin
m68k-elf-ld: warning: cannot find entry symbol _start; defaulting to 0000000080000000
I have noticed that when SGDK builds, there are some scripts which run with m68k-elf-as, are these required?
Basically, what I am looking for is a way to compile small amounts of code like that seen on darkdust, to give me the opportunity to poke and prod at the MD while I'm learning. Finding example code which works on linux with the GNU toolchain is proving difficult.
Would appreciate and assistance and advice.
Thanks!