C programming

Ask anything your want about Mega/SegaCD programming.

Moderator: Mask of Destiny

Post Reply
Jaklub
Interested
Posts: 41
Joined: Mon Aug 24, 2009 1:36 pm

C programming

Post by Jaklub » Sat Aug 14, 2010 4:08 pm

I'm planning moving my project from Sega Genesis to Sega CD (it's easier to burn a CD than buying a flashcart, as I may be getting a Sega Mega Drive with Mega CD soon).
Is there any solution similiar to Stef's MiniDevkit? I compiled Frog Feast (http://frogfeast.rastersoft.net/SegaCDSrc.html), but I don't really understand how does it work.
Thanks in advance.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Sat Aug 14, 2010 5:04 pm

Not yet. Other than BEX, Frog Feast, and SLO, I'm not aware of anything. I'm working on a MCD base for Wolf3D for the MCD, but it won't be available for a while yet.

mic_
Very interested
Posts: 265
Joined: Tue Aug 12, 2008 12:26 pm
Location: Sweden
Contact:

Post by mic_ » Sat Aug 14, 2010 5:32 pm

it's easier to burn a CD than buying a flashcart
It's probably easier to buy a flashcart than a MegaCD unit though ;)

But maybe you were planning on using some of the extra hardware functionality available through the MegaCD?
I would imagine that you could use mostly the same tools that you use for your Genesis projects, except that you'll need to create an ISO image before burning your game to a disc (I have no idea about the image layout, but there's a tool for it at the rastersoft page apparently).

Jaklub
Interested
Posts: 41
Joined: Mon Aug 24, 2009 1:36 pm

Post by Jaklub » Sat Aug 14, 2010 6:06 pm

mic_ wrote:I would imagine that you could use mostly the same tools that you use for your Genesis projects, except that you'll need to create an ISO image before burning your game to a disc (I have no idea about the image layout, but there's a tool for it at the rastersoft page apparently).
I compared the output ASM codes of Hello World from BasiEgaXorz for Sega Genesis and Sega CD and found only (or that) one difference.

Code: Select all

__end_segacd:
	ds.b	262143-(__end_segacd-__initialize_reset_start)
	dc.b	0

	REND
before END.
So I really hope there is a way to create an ISO image. But if there is, I don't know if I'll be able to play CD tracks (that's the only Sega CD functionality I want to use now).
I'll check out what SLO is.

mic_
Very interested
Posts: 265
Joined: Tue Aug 12, 2008 12:26 pm
Location: Sweden
Contact:

Post by mic_ » Sat Aug 14, 2010 6:14 pm

Code: Select all

  ds.b   262143-(__end_segacd-__initialize_reset_start) 
  dc.b   0
That's just padding the output to 256 kB.

Jaklub
Interested
Posts: 41
Joined: Mon Aug 24, 2009 1:36 pm

Post by Jaklub » Sat Aug 14, 2010 6:19 pm

mic_ wrote:

Code: Select all

  ds.b   262143-(__end_segacd-__initialize_reset_start) 
  dc.b   0
That's just padding the output to 256 kB.
Well, I don't know a single bit of ASM. That's nice to know.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Sat Aug 14, 2010 7:19 pm

The MCD boots using the first 16 sectors (0 to 15) before the standard ISO volume info at sector 16. The MCD loads sector 0, which has the region-specific security block along with a header that tells it how much else to load from the start of the CD for the boot code. The boot sectors include an init function that is called before the vblank interrupt is enabled, a vblank interrupt handler, and an entry point for the loader. The loader must then locate and load the main code for the disc. Often, it merely reads sectors from a hardcoded location on the disc as ISO9660 format is pretty simple. It could be more complicated, including code for finding files and loading them. SLO presents a list of files and allows the user to pick one to load and run. My own boot loader has full ISO9660, Rockridge, and Joliet handling, and looks for specific files to load and run for the main 68k, the sub 68k, and the 32x.

Once the boot loader has loaded and run the main code, then it is more like regular C/C++ coding... the main code must have a crt0.s that inits things like clearing the bss and calling the ctors (if applicable) before calling main(). You really need to know how the MCD works to be able to write anything. You need to know how to call the CD BIOS to play tracks, and how to set the hardware so that the word ram is switched back and forth to the MD side so you can get video output.

Jaklub
Interested
Posts: 41
Joined: Mon Aug 24, 2009 1:36 pm

Post by Jaklub » Sat Aug 14, 2010 9:07 pm

I guess it's not as easy as it seemed to. Don't want to use loaders and I don't have much of technical knowledge. Gotta stick to the Frog Feast source code.
Thanks for your posts, but I don't mind if somebody has something to add.

Post Reply