SEGA CD Mode 1

Ask anything your want about Mega/SegaCD programming.

Moderator: Mask of Destiny

Posts: 1132
Joined: Tue Aug 29, 2006 10:56 am

Re: SEGA CD Mode 1

Post by KanedaFr » Fri Jul 21, 2017 2:40 pm

From what we know, a CDD access takes almost 1/75s
so every time a BIOS function called need to communicate with the CDD, it takes this time.
Add the process time, you almost have a frame (60hz/50Hz)
:arrow: you lost a frame every bios call ?!

I don't understand how Sega let this happen....
At the first scratch, the game hangs or happy lagging......
Am I too serious about this ?

On the other side, I saw some BIOS call are made in 3 steps : XXXSTART, XXXXREAD, XXXXSTOP
I assume it was to handle this kind of thing ?

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

Re: SEGA CD Mode 1

Post by Chilly Willy » Fri Jul 21, 2017 3:16 pm

Well, most of the time you don't ask for one sector at a time, you either ask for N sectors, or tell the CD to just start streaming data until you tell it to stop, so you're not constantly doing CDD commands. All the bios handling tends to take place inside CDD and CDC interrupts when they're done so that they occur immediately instead of when the chip is busy. Also, it's only the CD system where you have to watch the timing - the comm registers and asic only take a couple clock cycles to rd/wr.

If you want to see how "typical" sega cd code looks, go check out the reverse-engineered SCD Cinepak code. You'll see code like this

Code: Select all

	LINK     A6,#0x0
	;; to get here sub is ready to swap meg
	;; need to wait for main to be ready to swap meg
	MOVEA.L  #0xFF8010,A0
	TST.W    0x2(A0)
	BNE.S    SwapMegWaitForZeroCommand
	;; swap the main/sub control of the two 1Mbit areas in word RAM
	EORI.W   #0x1,(0xFF8002).L
	UNLK     A6
This is probably compiled code... I've never seen hand-written assembly use link/unlk. It also sets the address register INSIDE the loop - that's typical of unoptimized compiled code. Notice how they simply wait for one of the comm registers to be cleared and then toggle the memory bit? See any error handling or timeouts or whatnot? That's typical for code from the period.

Post Reply