[Core/CD] added CD-AUDIO & CD+G support

This commit is contained in:
EkeEke 2015-05-31 18:21:35 +02:00
parent 1ee664873e
commit a07f7a3d24
6 changed files with 564 additions and 420 deletions

View File

@ -514,7 +514,7 @@ void sms_cart_init(void)
if (config.bios & 1)
{
/* load BIOS file */
int bios_size = load_bios();
int bios_size = load_bios(system_hw);
if (bios_size > 0xC000)
{

File diff suppressed because it is too large Load Diff

View File

@ -58,9 +58,6 @@
#define CD_STOP 0x09
#define CD_END 0x0C
/* CD blocks scanning speed */
#define CD_SCAN_SPEED 30
#define CD_MAX_TRACKS 100
/* CD track */
@ -73,6 +70,7 @@ typedef struct
int offset;
int start;
int end;
int type;
} track_t;
/* CD TOC */
@ -81,6 +79,7 @@ typedef struct
int end;
int last;
track_t tracks[CD_MAX_TRACKS];
FILE *sub;
} toc_t;
/* CDD hardware */

View File

@ -573,6 +573,13 @@ static unsigned int scd_read_byte(unsigned int address)
s68k_poll_detect(1 << (address & 0x1f));
}
/* Subcode buffer */
else if (address >= 0xff8100)
{
/* 64 x 16-bit mirrored */
address &= 0x17f;
}
/* default registers */
if (address & 1)
{
@ -663,6 +670,13 @@ static unsigned int scd_read_word(unsigned int address)
s68k_poll_detect(3 << (address & 0x1e));
}
/* Subcode buffer */
else if (address >= 0xff8100)
{
/* 64 x 16-bit mirrored */
address &= 0x17f;
}
/* default registers */
return scd.regs[(address >> 1) & 0xff].w;
}

View File

@ -2,7 +2,7 @@
* Genesis Plus
* ROM Loading Support
*
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
* Copyright (C) 1998-2003 Charles Mac Donald (original code)
* Copyright (C) 2007-2015 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
@ -389,11 +389,11 @@ void getrominfo(char *romheader)
* Return loaded size (-1 if already loaded)
*
***************************************************************************/
int load_bios(void)
int load_bios(int system)
{
int size = 0;
switch (system_hw)
switch (system)
{
case SYSTEM_MCD:
{
@ -532,10 +532,11 @@ int load_rom(char *filename)
int i, size;
#ifdef USE_DYNAMIC_ALLOC
/* allocate memory for Cartridge /CD hardware buffer if required */
if (ext == NULL)
if (!ext)
{
/* allocate memory for Cartridge / CD hardware if required */
ext = (external_t *)malloc(sizeof(external_t));
if (!ext) return (0);
}
#endif
@ -550,30 +551,28 @@ int load_rom(char *filename)
cdd.loaded = 0;
}
/* auto-detect CD image files */
/* auto-detect CD image file */
size = cdd_load(filename, (char *)(cart.rom));
if (size < 0)
{
/* error opening file */
return 0;
return (0);
}
if (size > 0)
/* CD image file ? */
if (size)
{
/* CD image file loaded */
/* enable CD hardware */
system_hw = SYSTEM_MCD;
/* boot from CD hardware */
scd.cartridge.boot = 0x00;
}
else
{
/* load file into ROM buffer */
char extension[4];
size = load_archive(filename, cart.rom, sizeof(cart.rom), extension);
if (!size)
{
/* mark all BOOTROM as unloaded since they could have been overwritten */
system_bios &= ~(0x10 | SYSTEM_SMS | SYSTEM_GG);
return 0;
}
size = load_archive(filename, cart.rom, cdd.loaded ? 0x800000 : MAXROMSIZE, extension);
/* mark BOOTROM as unloaded if they have been overwritten by cartridge ROM */
if (size > 0x800000)
@ -586,8 +585,16 @@ int load_rom(char *filename)
/* Master System or Game Gear BIOS ROM are loaded within $400000-$4FFFFF area */
system_bios &= ~(SYSTEM_SMS | SYSTEM_GG);
}
else if (size <= 0)
{
/* mark all BOOTROM as unloaded since they could have been overwritten */
system_bios &= ~(0x10 | SYSTEM_SMS | SYSTEM_GG);
/* error loading file */
return 0;
}
/* convert lower case to upper case */
/* convert lower case file extension to upper case */
*(uint32 *)(extension) &= 0xdfdfdfdf;
/* auto-detect system hardware from ROM file extension */
@ -608,7 +615,7 @@ int load_rom(char *filename)
}
else
{
/* Mega Drive hardware (Genesis mode) */
/* default is Mega Drive / Genesis hardware (16-bit mode) */
system_hw = SYSTEM_MD;
/* decode .MDX format */
@ -641,7 +648,7 @@ int load_rom(char *filename)
size -= 512;
memcpy (cart.rom, cart.rom + 512, size);
/* assume interleaved Genesis ROM format (.smd) */
/* assume interleaved Mega Drive / Genesis ROM format (.smd) */
if (system_hw == SYSTEM_MD)
{
for (i = 0; i < (size / 0x4000); i++)
@ -661,26 +668,9 @@ int load_rom(char *filename)
/* set console region */
get_region((char *)(cart.rom));
/* CD image file */
if (system_hw == SYSTEM_MCD)
{
/* load CD BOOT ROM */
if (!load_bios())
{
/* unmount CD image */
cdd_unload();
/* error loading CD BOOT ROM */
return (0);
}
/* boot from CD */
scd.cartridge.boot = 0x00;
}
#ifdef LSB_FIRST
/* 16-bit ROM specific */
else if (system_hw == SYSTEM_MD)
if (system_hw == SYSTEM_MD)
{
/* Byteswap ROM to optimize 16-bit access */
for (i = 0; i < cart.romsize; i += 2)
@ -701,14 +691,28 @@ int load_rom(char *filename)
/* Save auto-detected system hardware */
romtype = system_hw;
/* CD image file */
if (system_hw == SYSTEM_MCD)
{
/* try to load CD BOOTROM for selected region */
if (!load_bios(SYSTEM_MCD))
{
/* unmount CD image */
cdd_unload();
/* error booting from CD */
return (0);
}
}
/* CD BOOTROM */
if (strstr(rominfo.ROMType, "BR") != NULL)
else if (strstr(rominfo.ROMType, "BR") != NULL)
{
/* enable CD hardware */
system_hw = SYSTEM_MCD;
/* boot from CD */
/* boot from CD hardware */
scd.cartridge.boot = 0x00;
/* copy ROM to BOOTROM area */
@ -721,7 +725,26 @@ int load_rom(char *filename)
system_bios = (system_bios & 0xf0) | (region_code >> 4);
}
/* ROM cartridges with CD support */
/* ROM cartridge with CD loaded */
else if (cdd.loaded)
{
/* try to load CD BOOTROM */
if (load_bios(SYSTEM_MCD))
{
/* enable CD hardware */
system_hw = SYSTEM_MCD;
/* boot from cartridge */
scd.cartridge.boot = 0x40;
}
else
{
/* unmount CD image */
cdd_unload();
}
}
/* ROM cartridge with CD support */
else if ((strstr(rominfo.domestic,"FLUX") != NULL) ||
(strstr(rominfo.domestic,"WONDER LIBRARY") != NULL) ||
(strstr(rominfo.product,"T-5740") != NULL))
@ -729,33 +752,23 @@ int load_rom(char *filename)
/* check if console hardware is set to AUTO */
if (!config.system)
{
/* auto-enable CD hardware */
system_hw = SYSTEM_MCD;
/* try to load CD BOOTROM */
if (load_bios())
if (load_bios(SYSTEM_MCD))
{
char fname[256];
int len = strlen(filename);
/* automatically try to load associated .iso file */
while ((len && (filename[len] != '.')) || (len > 251)) len--;
strncpy(fname, filename, len);
strcpy(&fname[len], ".iso");
cdd_load(fname, (char *)cdc.ram);
/* enable CD hardware */
system_hw = SYSTEM_MCD;
/* boot from cartridge */
scd.cartridge.boot = 0x40;
/* change ROM filename extension to .iso */
while (len && (filename[len-1] != '.')) len--;
if (len < 253)
{
strncpy(fname, filename, len);
strcpy(&fname[len], "iso");
}
/* automatically load associated .iso image */
cdd_load(fname, (char *)cdc.ram);
}
else
{
/* if not found, disable CD hardware */
system_hw = SYSTEM_MD;
}
}
}
@ -980,19 +993,19 @@ void get_region(char *romheader)
if (system_hw == SYSTEM_MCD)
{
/* security code */
switch (romheader[0x20b])
switch ((unsigned char)romheader[0x20b])
{
case 0x7a:
region_code = REGION_USA;
break;
case 0x64:
region_code = REGION_EUROPE;
break;
default:
case 0xa1:
region_code = REGION_JAPAN_NTSC;
break;
default:
region_code = REGION_USA;
break;
}
}

View File

@ -2,7 +2,7 @@
* Genesis Plus
* ROM Loading Support
*
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
* Copyright (C) 1998-2003 Charles Mac Donald (original code)
* Copyright (C) 2007-2015 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
@ -64,7 +64,7 @@ extern ROMINFO rominfo;
extern uint8 romtype;
/* Function prototypes */
extern int load_bios(void);
extern int load_bios(int system);
extern int load_rom(char *filename);
extern void get_region(char *romheader);
extern char *get_company(void);