A few questions :)

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

elusive
Very interested
Posts: 57
Joined: Fri Jan 27, 2012 12:03 am

A few questions :)

Post by elusive » Sat Jun 11, 2016 5:03 pm

Hey everyone, I have a few questions about the Genny/MD:

Question 1: Is there an easy way to determine if a Game Genie, 32x, or Sega CD is attached to the console? What about copiers? I'd like to put in some commands or functions into SecondBASIC that would return a 1 if the above is detected, and a 0 if the peripherals aren't connected. If this is something that is pretty straight forward, any help would be greatly appreciated :)

Question 2: I'd like to make a function set do work with 4 player controls for SecondBASIC. I don't know a lick about doing this (I'm very inexperienced with ASM), and I know it's a lot to ask, but would anyone be willing to work with me to make this a reality? Since I'm using the BEX library, I was wondering if it would be possible to build off of that (if it would make things easier).

Question 3: Sega CD Mode 1 - I believe Chilli had posted the ASM source on how to do this, but again, I'd need some help implementing this in SecondBASIC.

I know questions 2 and 3 are asking a lot, so to garner some incentive for the help, I'm willing to compensate whoever helps (either in games, or money) :P

ComradeOj
Interested
Posts: 27
Joined: Sun Jun 28, 2015 4:18 pm
Contact:

Re: A few questions :)

Post by ComradeOj » Sat Jun 11, 2016 9:32 pm

The 32X is easy. Just look for the ASCII string "MARS" (4D 41 52 53) at $A130EC. If it says MARS, then a 32x is attached.
For the SEGA CD, you could try writing to the SCD's RAM, and try reading back to see if the value was stored. There is probably a better way though.
I'm not sure about Game Genie or game copiers.

I'm not sure about your other questions, although I'm also interested in SEGA CD mode 1 booting.
I was able to dig up this documentation on the SEGA multitap. Maybe it can help.
http://www.raphnet.net/divers/documenta ... ltitap.txt
Visit my web site at http://www.mode5.net/!

elusive
Very interested
Posts: 57
Joined: Fri Jan 27, 2012 12:03 am

Re: A few questions :)

Post by elusive » Sat Jun 11, 2016 9:55 pm

Thanks for the info about the 32x! I'll take a look at the link as well :) Thanks dude

BigEvilCorporation
Very interested
Posts: 209
Joined: Sat Sep 08, 2012 10:41 am
Contact:

Re: A few questions :)

Post by BigEvilCorporation » Sun Jun 12, 2016 10:09 am

For MegaCD detection, see if this has the info you need:

Code: Select all

; ************************************
; Mega-CD
; ************************************

; BIOS addresses for various MegaCD types
mcd_bios_addr_1 equ 0x00415800 ; SEGA Model 1
mcd_bios_addr_2 equ 0x00416000 ; SEGA Model 2
mcd_bios_addr_3 equ 0x00416000 ; WonderMega/X'Eye
mcd_bios_addr_4 equ 0x0041AD00 ; LaserActive

; MegaCD signatures
mcd_sig_1: dc.b 'SEGA',0
mcd_sig_2: dc.b 'SEGA',0
mcd_sig_3: dc.b 'WONDER',0
mcd_sig_4: dc.b 'SEGA',0

; Offset into BIOS to find signature
mcd_sig_offset equ 0x6D

; Checks if MegaCD is attached and returns BIOS type
; d0 - Return value: BIOS index if MCD present, 0 if not
GetMCDType:
        ; Check BIOS signature 1
        lea mcd_sig_1, a0
        lea mcd_bios_addr_1+mcd_sig_offset, a1
        jsr CompareString
        cmp.b #0x0, d0
        bne @NotType1
        move.l #0x1, d0 ; Found type 1
        rts

        @NotType1:
        lea mcd_sig_2, a0
        lea mcd_bios_addr_2+mcd_sig_offset, a1
        jsr CompareString
        cmp.b #0x0, d0
        bne @NotType2
        move.l #0x2, d0 ; Found type 2
        rts

        @NotType2:
        lea mcd_sig_3, a0
        lea mcd_bios_addr_3+mcd_sig_offset, a1
        jsr CompareString
        cmp.b #0x0, d0
        bne @NotType3
        move.l #0x3, d0 ; Found type 3
        rts

        @NotType3:
        lea mcd_sig_4, a0
        lea mcd_bios_addr_4+mcd_sig_offset, a1
        jsr CompareString
        cmp.b #0x0, d0
        bne @NotType4
        move.l #0x4, d0 ; Found type 4
        rts

        @NotType4:
        clr.l d0 ; MegaCD not found
        rts
Mileage may vary, I only wrote it for Genesis dev on a Cross Products devkit, never been tried with retail units.
A blog of my Megadrive programming adventures: http://www.bigevilcorporation.co.uk

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

Re: A few questions :)

Post by Eke » Sun Jun 12, 2016 8:37 pm

You can detect if Mega CD is connected by checking bit6 of I/O version register ($A10001): if bit6 is cleared, it means Mega CD unit is connected (and powered ON).

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: A few questions :)

Post by Sik » Mon Jun 13, 2016 6:34 am

Yeah, the F bit in $A10001 is the intended way to check for the Sega CD (don't get fooled by its name in the docs, that's because the floppy drive was originally going to be where the Sega CD ended up).

Why would you want to check the Game Genie though? o.o

EDIT: oh also
elusive wrote:Question 3: Sega CD Mode 1 - I believe Chilli had posted the ASM source on how to do this, but again, I'd need some help implementing this in SecondBASIC.
That's not mode 1! >_>

Mode 1 is a way of getting the Sega CD firmware to boot from the cartridge instead of from the CD drive (which requires !CART_IN to be wired as if there was no cartridge, by the way), let's not spread misinformation please. The usual hack is to instead scan for the BIOS at known locations, but that's not mode 1 (can we please find a different name for this?).
Sik is pronounced as "seek", not as "sick".

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

Re: A few questions :)

Post by Eke » Mon Jun 13, 2016 7:15 am

The usual hack is to instead scan for the BIOS at known locations, but that's not mode 1 (can we please find a different name for this?).
Booting from cartridge (CART_IN low) with Sega CD BIOS located at 0x4xxxxxx is actually called "Mode 1" in official docs.
Booting from Sega CD BIOS (CART_IN high) with cartridge located at 0x4xxxxx is called "Mode 2 Type 2"
Attachments
image.jpg
image.jpg (236.52 KiB) Viewed 12118 times

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: A few questions :)

Post by Sik » Mon Jun 13, 2016 4:32 pm

WTF what page is that?

Also doesn't explain then the boot code Nemesis founds where the firmware looks for a header in the cartridge and boots from there.
Sik is pronounced as "seek", not as "sick".

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: A few questions :)

Post by Stef » Mon Jun 13, 2016 6:07 pm

This page comes from the official Mega-CD documentation, i saw it as well and there is others references to Mode 1 in MegaCD as the cartridge boot :

Image

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

Re: A few questions :)

Post by Eke » Mon Jun 13, 2016 7:23 pm

Sik wrote:WTF what page is that?
It's page 5 of the Mega CD hardware manual which has been available online for some years.
Sik wrote: Also doesn't explain then the boot code Nemesis founds where the firmware looks for a header in the cartridge and boots from there.
This was likely done for the Mega CD diagnostic cartridge which is described in the Service Manual. It's just that some BIOS were developped to run some code from the cartridge if a specific header was found, but this is described here as Mode 2 Type 2 anyway, with special function cartridge available at 0x4xxxxx and initial booting from Mega CD internal ROM.

The mode used by Pier Solar, Flux, Wonder Library and the few ROM hacks with added CDDA support, where you boot from cartridge ROM and have access to Mega CD BIOS (as well as PRG-RAM & Word-RAM) at 0x4xxxxx is somehow "officially" called Mode 1 (again Type 2).

Charles MacDonald
Very interested
Posts: 292
Joined: Sat Apr 21, 2007 1:14 am

Re: A few questions :)

Post by Charles MacDonald » Tue Jun 14, 2016 3:14 am

The Game Genie disables all the user-accessible registers when it is running a game. The only thing you could do is checksum the ROM and verify if it is bad or not, which would indicate the Genie was patching one or more locations.

I can't remember if the Genie software fully clears out RAM and VRAM before running, so maybe you could scan that for "leftovers" from when the Genie menu was running.

elusive
Very interested
Posts: 57
Joined: Fri Jan 27, 2012 12:03 am

Re: A few questions :)

Post by elusive » Tue Jun 14, 2016 2:28 pm

Thanks for all of the information everyone!

charles, thanks for that bit of info. I guess using a checksum routine would be the way to go for game genie detection :)

As for why I want to know, it's just for general information.

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: A few questions :)

Post by Sik » Tue Jun 14, 2016 6:20 pm

Why do you want to detect the Game Genie, anyway?
Sik is pronounced as "seek", not as "sick".

elusive
Very interested
Posts: 57
Joined: Fri Jan 27, 2012 12:03 am

Re: A few questions :)

Post by elusive » Wed Jun 15, 2016 2:29 am

Why not? It could be used as an easter egg :P

elusive
Very interested
Posts: 57
Joined: Fri Jan 27, 2012 12:03 am

Re: A few questions :)

Post by elusive » Sun Jul 10, 2016 12:57 pm

Hey everyone, I have a few more questions :)

First new question: Is there a way to trigger a soft reset without having to write your own "reboot" process. I know you can check in the bootup vector to see if the console had a soft reset or a hard reset, but unsure if there's a way through code to "push the reset button" for you, so to speak. I thought I found a thread on here some time ago, but I cannot find it for the life of me, so I may have been dreaming :P

Question 2: I've run into a nasty issue with SecondBASIC - when I compile past a certain length of code*, it seems the ROM becomes corrupt and when it launches in an emulator, the title is displayed as random text (like 8 'F %2C 91 A I A<) and not the title of the game. What is the cause of it appearing corrupt (ie, data isn't aligned properly, something is bloating the header, etc.). I think this might be a long shot of a question.

* I say past a certain length because it's when the issue shows up, but I know it's an issue somewhere else rather than the command that's blowing up my project. Any general information on what would cause it to mess up like that would be helpful.


I found the issue for this and it's because I wasn't aligning the music files properly :) Found the problem right after I posted this lol

Thanks!

Post Reply