Sega CD Mode 1 support functions for SGDK

For anything related to sound (YM2612, PSG, Z80, PCM...)

Moderator: BigEvilCorporation

DarkKobold
Newbie
Posts: 4
Joined: Thu May 21, 2020 10:50 pm

Re: Sega CD Mode 1 support functions for SGDK

Post by DarkKobold » Thu Jun 04, 2020 3:42 am

As I mentioned, I'm probably far too unskilled to make that level of change. I really just changed how it handled registers. I'm super curious how he got it working, since there are so many issues with this code. Is there any way I could get help on this?

Manveru
Very interested
Posts: 80
Joined: Wed Sep 05, 2012 3:30 pm

Re: Sega CD Mode 1 support functions for SGDK

Post by Manveru » Thu Jun 04, 2020 4:16 pm

Now i see this thread up, i wonder if there is any tutorial or else to make "Mode 1" (sorry Sik) work in emulators. I tried with Kega but it has some glitches that does not draw the graphics after loading the CD. It is suppose to work with Genesis plus gx, but i can not find any guide for that, so any help is welcome.

EDIT: ok, i knew Kega DMA stuff stop working when you load a CD in Mode 1, but i forgot i was using DMA for some stuff and that was the reason it was not working for me. So no DMA, no problem using Kega for that.
The man who moves a mountain begins by carrying away small stones. Confucius, 551-479 BC

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

Re: Sega CD Mode 1 support functions for SGDK

Post by Chilly Willy » Thu Jun 04, 2020 7:08 pm

Emulators generally don't handle things like Mode 1 since it wasn't used by anything commercial, so it was of no interest to emulator authors. It's like CD32X emulation - not something emulations handle. This is more a real hardware thing.

Manveru
Very interested
Posts: 80
Joined: Wed Sep 05, 2012 3:30 pm

Re: Sega CD Mode 1 support functions for SGDK

Post by Manveru » Thu Jun 04, 2020 11:08 pm

Chilly Willy wrote:
Thu Jun 04, 2020 7:08 pm
Emulators generally don't handle things like Mode 1 since it wasn't used by anything commercial, so it was of no interest to emulator authors. It's like CD32X emulation - not something emulations handle. This is more a real hardware thing.
Yeah, but finally Kega can be used for testing if you do not use DMA.

By the way i can see when i try your mode 1 rom in Kega and Console and you open the MegaCD but you close it with no disc, it seems to detect a disc somehow, and some time later the screen changes with a "no disc" message. The problem is the red led that keeps blinking forever. Maybe you need to do some extra test for empty cd slot?

Thanks

EDIT: well, i realize MegaCD led keeps blinking when it is switched on and no cd. It is a bad thing having a MD game with Mode 1 feature, but if you do not put a disc on the CD unit you will have a led blinking for hours... Is there a way to say to the Mega CD to stop detecting CD, or switch off the CD or whatever?
The man who moves a mountain begins by carrying away small stones. Confucius, 551-479 BC

DarkKobold
Newbie
Posts: 4
Joined: Thu May 21, 2020 10:50 pm

Re: Sega CD Mode 1 support functions for SGDK

Post by DarkKobold » Fri Jun 05, 2020 5:44 pm

I think there might be an issue with the KOS decompile.

I had to change

Code: Select all

 bra.b   Kos_Decomp_Loop
to

Code: Select all

 bra.w   Kos_Decomp_Loop
This suggests that the kos decomp asm isn't compiling the same, which doesn't make a ton of sense.

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

Re: Sega CD Mode 1 support functions for SGDK

Post by Chilly Willy » Fri Jun 05, 2020 7:27 pm

Manveru wrote:
Thu Jun 04, 2020 11:08 pm
EDIT: well, i realize MegaCD led keeps blinking when it is switched on and no cd. It is a bad thing having a MD game with Mode 1 feature, but if you do not put a disc on the CD unit you will have a led blinking for hours... Is there a way to say to the Mega CD to stop detecting CD, or switch off the CD or whatever?
I suppose that after a certain amount of time, or if the user selects something from the menu to disable the cd, you could reset the asic and the sub cpu. That should do it.

Code: Select all

    /*
	 * Reset the Gate Array - this specific sequence of writes is recognized by
	 * the gate array as a reset sequence, clearing the entire internal state -
	 * this is needed for the LaserActive
	 */
	write_word(0xA12002, 0xFF00);
	write_byte(0xA12001, 0x03);
	write_byte(0xA12001, 0x02);
	write_byte(0xA12001, 0x00);

    /*
     * Reset the Sub-CPU, request the bus
     */
    write_byte(0xA12001, 0x02);
    while (!(read_byte(0xA12001) & 2)) write_byte(0xA12001, 0x02); // wait on bus acknowledge
You could also have another menu option to re-init the CD if the user decided later to actually use it.

Manveru
Very interested
Posts: 80
Joined: Wed Sep 05, 2012 3:30 pm

Re: Sega CD Mode 1 support functions for SGDK

Post by Manveru » Sat Jun 06, 2020 2:43 pm

Chilly Willy wrote:
Fri Jun 05, 2020 7:27 pm
I suppose that after a certain amount of time, or if the user selects something from the menu to disable the cd, you could reset the asic and the sub cpu. That should do it.

Code: Select all

    /*
	 * Reset the Gate Array - this specific sequence of writes is recognized by
	 * the gate array as a reset sequence, clearing the entire internal state -
	 * this is needed for the LaserActive
	 */
	write_word(0xA12002, 0xFF00);
	write_byte(0xA12001, 0x03);
	write_byte(0xA12001, 0x02);
	write_byte(0xA12001, 0x00);

    /*
     * Reset the Sub-CPU, request the bus
     */
    write_byte(0xA12001, 0x02);
    while (!(read_byte(0xA12001) & 2)) write_byte(0xA12001, 0x02); // wait on bus acknowledge
You could also have another menu option to re-init the CD if the user decided later to actually use it.
Thanks Chilly Willy, it works perfectly. May the videogames gods bless you.
The man who moves a mountain begins by carrying away small stones. Confucius, 551-479 BC

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

Re: Sega CD Mode 1 support functions for SGDK

Post by Chilly Willy » Sun Jun 07, 2020 12:49 pm

Good to hear. I'll have to remember to make that change in my own stuff. That was a good point - while leaving the CD constantly checking probably doesn't hurt anything, it's better to just shut things down after a while. A menu option in case the user changes their mind later is probably also a good idea.

Eke
Very interested
Posts: 864
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Re: Sega CD Mode 1 support functions for SGDK

Post by Eke » Thu Jul 23, 2020 8:18 pm

Manveru wrote:
Thu Jun 04, 2020 4:16 pm
It is suppose to work with Genesis plus gx, but i can not find any guide for that, so any help is welcome
Sorry, I didn't see this post earlier but it's indeed not well documented. It's quite simple to activate Mega CD mode 1 though (I call it "cartridge boot" mode): just put the cue file and associated CD image file(s) in same directory as the ROM file, using same basename for the cue file and the ROM file ("game.md" and "game.cue" for example) then load the ROM file. You will also need a CD BIOS file with correct name for each region as required by the emulator for Mega CD emulation (BIOS_CD_U.bin, etc).

Post Reply