Merge pull request #27 from Oggom/master

Sync with main repo
This commit is contained in:
Twinaphex 2015-06-01 06:52:19 +02:00
commit d291c543f0
14 changed files with 617 additions and 466 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 MiB

After

Width:  |  Height:  |  Size: 3.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 MiB

After

Width:  |  Height:  |  Size: 3.8 MiB

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)
{

View File

@ -2,7 +2,7 @@
* Genesis Plus
* CD data controller (LC89510 compatible)
*
* Copyright (C) 2012 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2012-2015 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
@ -376,8 +376,8 @@ void cdc_reg_w(unsigned char data)
/* start data transfer if data output is enabled */
if (cdc.ifctrl & BIT_DOUTEN)
{
/* set !DTBSY */
cdc.ifstat &= ~BIT_DTBSY;
/* set !DTBSY and !DTEN */
cdc.ifstat &= ~(BIT_DTBSY | BIT_DTEN);
/* clear DBCH bits 4-7 */
cdc.dbc.byte.h &= 0x0f;
@ -391,10 +391,7 @@ void cdc_reg_w(unsigned char data)
case 2: /* MAIN-CPU host read */
case 3: /* SUB-CPU host read */
{
/* set !DTEN */
cdc.ifstat &= ~BIT_DTEN;
/* set DSR bit (register $04) */
/* set DSR bit (SCD register $04) */
scd.regs[0x04>>1].byte.h |= 0x40;
break;
}
@ -645,7 +642,7 @@ unsigned char cdc_reg_r(void)
unsigned short cdc_host_r(void)
{
/* check if data is available */
if (!(cdc.ifstat & BIT_DTEN))
if (scd.regs[0x04>>1].byte.h & 0x40)
{
/* read data word from CDC RAM buffer */
uint16 data = *(uint16 *)(cdc.ram + (cdc.dac.w & 0x3ffe));

View File

@ -2,7 +2,7 @@
* Genesis Plus
* CD data controller (LC89510 compatible)
*
* Copyright (C) 2012 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2012-2015 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:

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

@ -475,8 +475,8 @@ static void s68k_poll_sync(unsigned int reg_mask)
static unsigned int scd_read_byte(unsigned int address)
{
/* PCM area (8K) is mirrored into $FF0000-$FF7FFF */
if (address < 0xff8000)
/* PCM area (8K) mirrored into $xF0000-$xF7FFF */
if (!(address & 0x8000))
{
/* get /LDS only */
if (address & 1)
@ -491,36 +491,39 @@ static unsigned int scd_read_byte(unsigned int address)
error("[%d][%d]read byte CD register %X (%X)\n", v_counter, s68k.cycles, address, s68k.pc);
#endif
/* only A1-A8 are used for decoding */
address &= 0x1ff;
/* Memory Mode */
if (address == 0xff8003)
if (address == 0x03)
{
s68k_poll_detect(1<<0x03);
return scd.regs[0x03>>1].byte.l;
}
/* MAIN-CPU communication flags */
if (address == 0xff800e)
if (address == 0x0e)
{
s68k_poll_detect(1<<0x0e);
return scd.regs[0x0e>>1].byte.h;
}
/* CDC transfer status */
if (address == 0xff8004)
if (address == 0x04)
{
s68k_poll_detect(1<<0x04);
return scd.regs[0x04>>1].byte.h;
}
/* GFX operation status */
if (address == 0xff8058)
if (address == 0x58)
{
s68k_poll_detect(1<<0x08);
return scd.regs[0x58>>1].byte.h;
}
/* CDC register data (controlled by BIOS, byte access only ?) */
if (address == 0xff8007)
if (address == 0x07)
{
unsigned int data = cdc_reg_r();
#ifdef LOG_CDC
@ -530,21 +533,21 @@ static unsigned int scd_read_byte(unsigned int address)
}
/* LED status */
if (address == 0xff8000)
if (address == 0x00)
{
/* register $00 is reserved for MAIN-CPU, we use $06 instead */
return scd.regs[0x06>>1].byte.h;
}
/* RESET status */
if (address == 0xff8001)
if (address == 0x01)
{
/* always return 1 */
return 0x01;
}
/* Font data */
if ((address >= 0xff8050) && (address <= 0xff8056))
if ((address >= 0x50) && (address <= 0x56))
{
/* shifted 4-bit input (xxxx00) */
uint8 bits = (scd.regs[0x4e>>1].w >> (((address & 6) ^ 6) << 1)) << 2;
@ -573,21 +576,28 @@ static unsigned int scd_read_byte(unsigned int address)
s68k_poll_detect(1 << (address & 0x1f));
}
/* Subcode buffer */
else if (address & 0x100)
{
/* 64 x 16-bit mirrored */
address &= 0x17f;
}
/* default registers */
if (address & 1)
{
/* register LSB */
return scd.regs[(address >> 1) & 0xff].byte.l;
return scd.regs[address >> 1].byte.l;
}
/* register MSB */
return scd.regs[(address >> 1) & 0xff].byte.h;
return scd.regs[address >> 1].byte.h;
}
static unsigned int scd_read_word(unsigned int address)
{
/* PCM area (8K) is mirrored into $FF0000-$FF7FFF */
if (address < 0xff8000)
/* PCM area (8K) mirrored into $xF0000-$xF7FFF */
if (!(address & 0x8000))
{
/* get /LDS only */
return pcm_read((address >> 1) & 0x1fff);
@ -597,35 +607,38 @@ static unsigned int scd_read_word(unsigned int address)
error("[%d][%d]read word CD register %X (%X)\n", v_counter, s68k.cycles, address, s68k.pc);
#endif
/* only A1-A8 are used for decoding */
address &= 0x1ff;
/* Memory Mode */
if (address == 0xff8002)
if (address == 0x02)
{
s68k_poll_detect(1<<0x03);
return scd.regs[0x03>>1].w;
}
/* CDC host data (word access only ?) */
if (address == 0xff8008)
if (address == 0x08)
{
return cdc_host_r();
}
/* LED & RESET status */
if (address == 0xff8000)
if (address == 0x00)
{
/* register $00 is reserved for MAIN-CPU, we use $06 instead */
return scd.regs[0x06>>1].w;
}
/* Stopwatch counter (word access only ?) */
if (address == 0xff800c)
if (address == 0x0c)
{
/* cycle-accurate counter value */
return (scd.regs[0x0c>>1].w + ((s68k.cycles - scd.stopwatch) / TIMERS_SCYCLES_RATIO)) & 0xfff;
}
/* Font data */
if ((address >= 0xff8050) && (address <= 0xff8056))
if ((address >= 0x50) && (address <= 0x56))
{
/* shifted 4-bit input (xxxx00) */
uint8 bits = (scd.regs[0x4e>>1].w >> (((address & 6) ^ 6) << 1)) << 2;
@ -663,8 +676,15 @@ static unsigned int scd_read_word(unsigned int address)
s68k_poll_detect(3 << (address & 0x1e));
}
/* Subcode buffer */
else if (address & 0x100)
{
/* 64 x 16-bit mirrored */
address &= 0x17f;
}
/* default registers */
return scd.regs[(address >> 1) & 0xff].w;
return scd.regs[address >> 1].w;
}
INLINE void word_ram_switch(uint8 mode)
@ -731,8 +751,8 @@ INLINE void word_ram_switch(uint8 mode)
static void scd_write_byte(unsigned int address, unsigned int data)
{
/* PCM area (8K) is mirrored into $FF0000-$FF7FFF */
if (address < 0xff8000)
/* PCM area (8K) mirrored into $xF0000-$xF7FFF */
if (!(address & 0x8000))
{
/* get /LDS only */
if (address & 1)
@ -1012,8 +1032,8 @@ static void scd_write_byte(unsigned int address, unsigned int data)
static void scd_write_word(unsigned int address, unsigned int data)
{
/* PCM area (8K) is mirrored into $FF0000-$FF7FFF */
if (address < 0xff8000)
/* PCM area (8K) mirrored into $xF0000-$xF7FFF */
if (!(address & 0x8000))
{
/* get /LDS only */
pcm_write((address >> 1) & 0x1fff, data);

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);

View File

@ -3,7 +3,7 @@
*
* Genesis Plus GX configuration file support
*
* Copyright Eke-Eke (2007-2014)
* Copyright Eke-Eke (2007-2015)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
@ -259,7 +259,10 @@ void config_default(void)
/* try to restore user config */
int loaded = config_load();
#ifndef HW_RVL
#ifdef HW_RVL
/* initialize WPAD timeout */
WPAD_SetIdleTimeout(config.autosleep ? 300 : 1800);
#else
/* check if component cable was detected */
if (VIDEO_HaveComponentCable())
{

View File

@ -3,7 +3,7 @@
*
* Genesis Plus GX configuration file support
*
* Copyright Eke-Eke (2007-2014)
* Copyright Eke-Eke (2007-2015)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:

View File

@ -1128,7 +1128,6 @@ void gx_input_Init(void)
PAD_Init();
#ifdef HW_RVL
WPAD_Init();
WPAD_SetIdleTimeout(config.autosleep ? 300 : 1800);
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
WPAD_SetVRes(WPAD_CHAN_ALL,640,480);
#endif