Merge git://github.com/ekeeke/Genesis-Plus-GX

This commit is contained in:
twinaphex 2012-10-22 18:01:17 +02:00
commit 52a8cca2d4
12 changed files with 100 additions and 77 deletions

View File

@ -357,7 +357,7 @@ int cdd_load(char *filename, char *header)
if (!(memcmp(lptr, "FILE", 4))) if (!(memcmp(lptr, "FILE", 4)))
{ {
/* check supported file types */ /* check supported file types */
if (!strstr(lptr," BINARY") && !strstr(lptr," WAVE")) if (!strstr(lptr," BINARY") && !strstr(lptr," WAV"))
{ {
/* unsupported file type */ /* unsupported file type */
break; break;
@ -375,7 +375,7 @@ int cdd_load(char *filename, char *header)
if (ptr - fname) ptr++; if (ptr - fname) ptr++;
/* append filename characters after filepath */ /* append filename characters after filepath */
while ((*lptr != '\"') && memcmp(lptr, " BINARY", 7) && memcmp(lptr, " WAVE", 5)) while ((*lptr != '\"') && memcmp(lptr, " BINARY", 7) && memcmp(lptr, " WAV", 4))
{ {
*ptr++ = *lptr++; *ptr++ = *lptr++;
} }
@ -636,6 +636,9 @@ int cdd_load(char *filename, char *header)
} }
} }
/* Lead-out */
cdd.toc.tracks[cdd.toc.last].start = cdd.toc.end;
/* CD loaded */ /* CD loaded */
cdd.loaded = 1; cdd.loaded = 1;
return 1; return 1;
@ -839,6 +842,7 @@ void cdd_update(void)
} }
else else
{ {
cdd.status = CD_END;
return; return;
} }
@ -898,6 +902,10 @@ void cdd_update(void)
} }
else if (cdd.index >= cdd.toc.last) else if (cdd.index >= cdd.toc.last)
{ {
/* no AUDIO track playing */
scd.regs[0x36>>1].byte.h = 0x01;
/* end of disc */
cdd.index = cdd.toc.last; cdd.index = cdd.toc.last;
cdd.lba = cdd.toc.end; cdd.lba = cdd.toc.end;
} }
@ -905,6 +913,9 @@ void cdd_update(void)
/* seek to current block */ /* seek to current block */
if (!cdd.index) if (!cdd.index)
{ {
/* no AUDIO track playing */
scd.regs[0x36>>1].byte.h = 0x01;
fseek(cdd.toc.tracks[0].fd, cdd.lba * cdd.sectorSize, SEEK_SET); fseek(cdd.toc.tracks[0].fd, cdd.lba * cdd.sectorSize, SEEK_SET);
} }
else if (cdd.toc.tracks[cdd.index].fd) else if (cdd.toc.tracks[cdd.index].fd)
@ -961,7 +972,7 @@ void cdd_process(void)
scd.regs[0x3a>>1].w = lut_BCD_16[(lba/75)/60]; scd.regs[0x3a>>1].w = lut_BCD_16[(lba/75)/60];
scd.regs[0x3c>>1].w = lut_BCD_16[(lba/75)%60]; scd.regs[0x3c>>1].w = lut_BCD_16[(lba/75)%60];
scd.regs[0x3e>>1].w = lut_BCD_16[(lba%75)]; scd.regs[0x3e>>1].w = lut_BCD_16[(lba%75)];
scd.regs[0x40>>1].byte.h = 0x00; scd.regs[0x40>>1].byte.h = 0x00; /* TODO: check what is returned in RS8 (note: bit 1 is checked by BIOS) */
break; break;
} }
@ -972,7 +983,7 @@ void cdd_process(void)
scd.regs[0x3a>>1].w = lut_BCD_16[(lba/75)/60]; scd.regs[0x3a>>1].w = lut_BCD_16[(lba/75)/60];
scd.regs[0x3c>>1].w = lut_BCD_16[(lba/75)%60]; scd.regs[0x3c>>1].w = lut_BCD_16[(lba/75)%60];
scd.regs[0x3e>>1].w = lut_BCD_16[(lba%75)]; scd.regs[0x3e>>1].w = lut_BCD_16[(lba%75)];
scd.regs[0x40>>1].byte.h = 0x00; scd.regs[0x40>>1].byte.h = 0x00; /* TODO: check what is returned in RS8 */
break; break;
} }
@ -981,7 +992,7 @@ void cdd_process(void)
scd.regs[0x38>>1].w = (cdd.status << 8) | 0x02; scd.regs[0x38>>1].w = (cdd.status << 8) | 0x02;
scd.regs[0x3a>>1].w = (cdd.index < cdd.toc.last) ? lut_BCD_16[cdd.index + 1] : 0x0A0A; scd.regs[0x3a>>1].w = (cdd.index < cdd.toc.last) ? lut_BCD_16[cdd.index + 1] : 0x0A0A;
scd.regs[0x3c>>1].w = 0x0000; scd.regs[0x3c>>1].w = 0x0000;
scd.regs[0x3e>>1].w = 0x0000; scd.regs[0x3e>>1].w = 0x0000; /* TODO: check what is returned in RS6 */
scd.regs[0x40>>1].byte.h = 0x00; scd.regs[0x40>>1].byte.h = 0x00;
break; break;
} }
@ -1002,8 +1013,8 @@ void cdd_process(void)
scd.regs[0x38>>1].w = (cdd.status << 8) | 0x04; scd.regs[0x38>>1].w = (cdd.status << 8) | 0x04;
scd.regs[0x3a>>1].w = 0x0001; scd.regs[0x3a>>1].w = 0x0001;
scd.regs[0x3c>>1].w = lut_BCD_16[cdd.toc.last]; scd.regs[0x3c>>1].w = lut_BCD_16[cdd.toc.last];
scd.regs[0x3e>>1].w = 0x0000; scd.regs[0x3e>>1].w = 0x0000; /* TODO: check what is returned in RS6-RS7 */
scd.regs[0x40>>1].byte.h = 0x00; scd.regs[0x40>>1].byte.h = 0x00; /* TODO: check what is returned in RS8 */
break; break;
} }
@ -1018,7 +1029,7 @@ void cdd_process(void)
scd.regs[0x40>>1].byte.h = track % 10; scd.regs[0x40>>1].byte.h = track % 10;
if (track == 1) if (track == 1)
{ {
/* data track */ /* RS6 bit 3 is set for DATA track */
scd.regs[0x3e>>1].byte.h |= 0x08; scd.regs[0x3e>>1].byte.h |= 0x08;
} }
break; break;
@ -1081,7 +1092,14 @@ void cdd_process(void)
/* Some delay is also needed when playing AUDIO tracks located at the end of the disc (ex: Sonic CD intro) */ /* Some delay is also needed when playing AUDIO tracks located at the end of the disc (ex: Sonic CD intro) */
/* max. seek time = 1.5s = 1.5 x 75 = 112.5 CDD interrupts (rounded to 120) for 270000 sectors max on disc */ /* max. seek time = 1.5s = 1.5 x 75 = 112.5 CDD interrupts (rounded to 120) for 270000 sectors max on disc */
/* Note: this is only a rough approximation, on real hardware, drive seek time is much likely not linear */ /* Note: this is only a rough approximation, on real hardware, drive seek time is much likely not linear */
cdd.latency += ((abs(lba - cdd.lba) * 120) / 270000); if (lba < cdd.lba)
{
cdd.latency += (((cdd.lba - lba) * 120) / 270000);
}
else
{
cdd.latency += (((lba - cdd.lba) * 120) / 270000);
}
/* seek AUDIO track */ /* seek AUDIO track */
if (lba < cdd.toc.tracks[index].start) if (lba < cdd.toc.tracks[index].start)

View File

@ -50,6 +50,7 @@
#define CD_READY 0x04 #define CD_READY 0x04
#define CD_OPEN 0x05 #define CD_OPEN 0x05
#define CD_STOP 0x09 #define CD_STOP 0x09
#define CD_END 0x0C
/* CD blocks scanning speed */ /* CD blocks scanning speed */
#define CD_SCAN_SPEED 10 #define CD_SCAN_SPEED 10

View File

@ -64,6 +64,16 @@ void pcm_reset(void)
/* reset default bank */ /* reset default bank */
pcm.bank = pcm.ram; pcm.bank = pcm.ram;
/* reset channels stereo panning */
pcm.chan[0].pan = 0xff;
pcm.chan[1].pan = 0xff;
pcm.chan[2].pan = 0xff;
pcm.chan[3].pan = 0xff;
pcm.chan[4].pan = 0xff;
pcm.chan[5].pan = 0xff;
pcm.chan[6].pan = 0xff;
pcm.chan[7].pan = 0xff;
/* reset master clocks counter */ /* reset master clocks counter */
pcm.cycles = 0; pcm.cycles = 0;
@ -77,15 +87,15 @@ int pcm_context_save(uint8 *state)
uint8 tmp8; uint8 tmp8;
int bufferptr = 0; int bufferptr = 0;
tmp8 = (scd.pcm_hw.bank - scd.pcm_hw.ram) >> 12; tmp8 = (pcm.bank - pcm.ram) >> 12;
save_param(scd.pcm_hw.chan, sizeof(scd.pcm_hw.chan)); save_param(pcm.chan, sizeof(pcm.chan));
save_param(scd.pcm_hw.out, sizeof(scd.pcm_hw.out)); save_param(pcm.out, sizeof(pcm.out));
save_param(&tmp8, 1); save_param(&tmp8, 1);
save_param(&scd.pcm_hw.enabled, sizeof(scd.pcm_hw.enabled)); save_param(&pcm.enabled, sizeof(pcm.enabled));
save_param(&scd.pcm_hw.status, sizeof(scd.pcm_hw.status)); save_param(&pcm.status, sizeof(pcm.status));
save_param(&scd.pcm_hw.index, sizeof(scd.pcm_hw.index)); save_param(&pcm.index, sizeof(pcm.index));
save_param(scd.pcm_hw.ram, sizeof(scd.pcm_hw.ram)); save_param(pcm.ram, sizeof(pcm.ram));
return bufferptr; return bufferptr;
} }
@ -95,16 +105,16 @@ int pcm_context_load(uint8 *state)
uint8 tmp8; uint8 tmp8;
int bufferptr = 0; int bufferptr = 0;
load_param(scd.pcm_hw.chan, sizeof(scd.pcm_hw.chan)); load_param(pcm.chan, sizeof(pcm.chan));
load_param(scd.pcm_hw.out, sizeof(scd.pcm_hw.out)); load_param(pcm.out, sizeof(pcm.out));
load_param(&tmp8, 1); load_param(&tmp8, 1);
scd.pcm_hw.bank = &scd.pcm_hw.ram[(tmp8 & 0x0f) << 12]; pcm.bank = &pcm.ram[(tmp8 & 0x0f) << 12];
load_param(&scd.pcm_hw.enabled, sizeof(scd.pcm_hw.enabled)); load_param(&pcm.enabled, sizeof(pcm.enabled));
load_param(&scd.pcm_hw.status, sizeof(scd.pcm_hw.status)); load_param(&pcm.status, sizeof(pcm.status));
load_param(&scd.pcm_hw.index, sizeof(scd.pcm_hw.index)); load_param(&pcm.index, sizeof(pcm.index));
load_param(scd.pcm_hw.ram, sizeof(scd.pcm_hw.ram)); load_param(pcm.ram, sizeof(pcm.ram));
return bufferptr; return bufferptr;
} }
@ -209,7 +219,7 @@ void pcm_run(unsigned int length)
} }
} }
/* end of blib buffer frame */ /* end of blip buffer frame */
blip_end_frame(blip[0], length); blip_end_frame(blip[0], length);
blip_end_frame(blip[1], length); blip_end_frame(blip[1], length);

View File

@ -1045,7 +1045,7 @@ void scd_init(void)
{ {
if (i & 2) if (i & 2)
{ {
/* PRG-RAM (first 128KB bank, mirrored ?) */ /* PRG-RAM (first 128KB bank, mirrored) */
m68k.memory_map[i].base = scd.prg_ram + ((i & 1) << 16); m68k.memory_map[i].base = scd.prg_ram + ((i & 1) << 16);
m68k.memory_map[i].read8 = NULL; m68k.memory_map[i].read8 = NULL;
m68k.memory_map[i].read16 = NULL; m68k.memory_map[i].read16 = NULL;
@ -1068,7 +1068,7 @@ void scd_init(void)
} }
} }
/* $200000-$23FFFF (resp. $600000-$63FFFF): Word-RAM in 2M mode (256KB) */ /* $200000-$3FFFFF (resp. $600000-$7FFFFF): Word-RAM in 2M mode (256KB mirrored) */
for (i=base+0x20; i<base+0x24; i++) for (i=base+0x20; i<base+0x24; i++)
{ {
m68k.memory_map[i].base = scd.word_ram_2M + ((i & 3) << 16); m68k.memory_map[i].base = scd.word_ram_2M + ((i & 3) << 16);
@ -1080,18 +1080,6 @@ void scd_init(void)
zbank_memory_map[i].write = NULL; zbank_memory_map[i].write = NULL;
} }
/* $240000-$3FFFFF (resp. $400000-$7FFFFF): unused area (Word-RAM mirrored ?) */
for (i=base+0x24; i<base+0x40; i++)
{
m68k.memory_map[i].base = scd.word_ram_2M + ((i & 3) << 16);
m68k.memory_map[i].read8 = m68k_read_bus_8;
m68k.memory_map[i].read16 = m68k_read_bus_16;
m68k.memory_map[i].write8 = m68k_unused_8_w;
m68k.memory_map[i].write16 = m68k_unused_16_w;
zbank_memory_map[i].read = zbank_unused_r;
zbank_memory_map[i].write = zbank_unused_w;
}
/****************************************************************/ /****************************************************************/
/* SUB-CPU memory map ($000000-$FFFFFF) */ /* SUB-CPU memory map ($000000-$FFFFFF) */
/****************************************************************/ /****************************************************************/

View File

@ -322,37 +322,40 @@ unsigned int ctrl_io_read_byte(unsigned int address)
#endif #endif
if (system_hw == SYSTEM_MCD) if (system_hw == SYSTEM_MCD)
{ {
/* register index ($A12000-A1203F mirrored up to $A120FF) */
uint8 index = address & 0x3f;
/* Memory Mode */ /* Memory Mode */
if (address == 0xa12003) if (index == 0x03)
{ {
m68k_poll_detect(0x03); m68k_poll_detect(0x03);
return scd.regs[0x03>>1].byte.l; return scd.regs[0x03>>1].byte.l;
} }
/* SUB-CPU communication flags */ /* SUB-CPU communication flags */
if (address == 0xa1200f) if (index == 0x0f)
{ {
m68k_poll_detect(0x0f); m68k_poll_detect(0x0f);
return scd.regs[0x0f>>1].byte.l; return scd.regs[0x0f>>1].byte.l;
} }
/* default registers */ /* default registers */
if (address < 0xa12030) if (index < 0x30)
{ {
/* SUB-CPU communication words */ /* SUB-CPU communication words */
if (address >= 0xa12020) if (index >= 0x20)
{ {
m68k_poll_detect((address - 0x10) & 0x1f); m68k_poll_detect(index - 0x10);
} }
/* register LSB */ /* register LSB */
if (address & 1) if (address & 1)
{ {
return scd.regs[(address >> 1) & 0xff].byte.l; return scd.regs[index >> 1].byte.l;
} }
/* register MSB */ /* register MSB */
return scd.regs[(address >> 1) & 0xff].byte.h; return scd.regs[index >> 1].byte.h;
} }
} }
@ -441,35 +444,38 @@ unsigned int ctrl_io_read_word(unsigned int address)
#endif #endif
if (system_hw == SYSTEM_MCD) if (system_hw == SYSTEM_MCD)
{ {
/* register index ($A12000-A1203F mirrored up to $A120FF) */
uint8 index = address & 0x3f;
/* Memory Mode */ /* Memory Mode */
if (address == 0xa12002) if (index == 0x02)
{ {
m68k_poll_detect(0x03); m68k_poll_detect(0x03);
return scd.regs[0x03>>1].w; return scd.regs[0x03>>1].w;
} }
/* CDC host data (word access only ?) */ /* CDC host data (word access only ?) */
if (address == 0xa12008) if (index == 0x08)
{ {
return cdc_host_r(); return cdc_host_r();
} }
/* H-INT vector (word access only ?) */ /* H-INT vector (word access only ?) */
if (address == 0xa12006) if (index == 0x06)
{ {
return *(uint16 *)(m68k.memory_map[0].base + 0x72); return *(uint16 *)(m68k.memory_map[0].base + 0x72);
} }
/* default registers */ /* default registers */
if (address < 0xa12030) if (index < 0x30)
{ {
/* SUB-CPU communication words */ /* SUB-CPU communication words */
if (address >= 0xa12020) if (index >= 0x20)
{ {
m68k_poll_detect((address - 0x10) & 0x1e); m68k_poll_detect(index - 0x10);
} }
return scd.regs[(address >> 1) & 0xff].w; return scd.regs[index >> 1].w;
} }
} }
@ -565,7 +571,8 @@ void ctrl_io_write_byte(unsigned int address, unsigned int data)
#endif #endif
if (system_hw == SYSTEM_MCD) if (system_hw == SYSTEM_MCD)
{ {
switch (address & 0xff) /* register index ($A12000-A1203F mirrored up to $A120FF) */
switch (address & 0x3f)
{ {
case 0x00: /* SUB-CPU interrupt */ case 0x00: /* SUB-CPU interrupt */
{ {
@ -795,7 +802,8 @@ void ctrl_io_write_word(unsigned int address, unsigned int data)
#endif #endif
if (system_hw == SYSTEM_MCD) if (system_hw == SYSTEM_MCD)
{ {
switch (address & 0xfe) /* register index ($A12000-A1203F mirrored up to $A120FF) */
switch (address & 0x3e)
{ {
case 0x00: /* SUB-CPU interrupt & control */ case 0x00: /* SUB-CPU interrupt & control */
{ {

View File

@ -8,8 +8,6 @@
#include "blip_buf.h" #include "blip_buf.h"
#define BLIP_ASSERT 1
#ifdef BLIP_ASSERT #ifdef BLIP_ASSERT
#include <assert.h> #include <assert.h>
#endif #endif
@ -236,11 +234,10 @@ int blip_read_samples( blip_t* m, short out [], int count)
buf_t const* in = SAMPLES( m ); buf_t const* in = SAMPLES( m );
buf_t const* end = in + count; buf_t const* end = in + count;
int sum = m->integrator; int sum = m->integrator;
int s;
do do
{ {
/* Eliminate fraction */ /* Eliminate fraction */
s = ARITH_SHIFT( sum, delta_bits ); int s = ARITH_SHIFT( sum, delta_bits );
sum += *in++; sum += *in++;
@ -275,24 +272,23 @@ int blip_mix_samples( blip_t* m, short out [], int count)
buf_t const* in = SAMPLES( m ); buf_t const* in = SAMPLES( m );
buf_t const* end = in + count; buf_t const* end = in + count;
int sum = m->integrator; int sum = m->integrator;
int s, temp;
do do
{ {
/* Eliminate fraction */ /* Eliminate fraction */
s = ARITH_SHIFT( sum, delta_bits ); int s = ARITH_SHIFT( sum, delta_bits );
sum += *in++; sum += *in++;
/* Add to current buffer */
temp = s + *out;
CLAMP( temp );
*out = temp;
out += 2;
/* High-pass filter */ /* High-pass filter */
sum -= s << (delta_bits - bass_shift); sum -= s << (delta_bits - bass_shift);
/* Add current buffer value */
s += *out;
CLAMP( s );
*out = s;
out += 2;
} }
while ( in != end ); while ( in != end );
m->integrator = sum; m->integrator = sum;

View File

@ -41,7 +41,6 @@
****************************************************************************************/ ****************************************************************************************/
#include "shared.h" #include "shared.h"
#include <windows.h>
#include <zlib.h> #include <zlib.h>
static int check_zip(char *filename); static int check_zip(char *filename);

View File

@ -1,4 +1,8 @@
#ifdef __WIN32__
#include <windows.h> #include <windows.h>
#else
#define MessageBox(owner, text, caption, type) printf("%s: %s\n", caption, text)
#endif
#include "SDL.h" #include "SDL.h"
#include "SDL_thread.h" #include "SDL_thread.h"
@ -197,7 +201,8 @@ static void sdl_video_update()
/* clear destination surface */ /* clear destination surface */
SDL_FillRect(sdl_video.surf_screen, 0, 0); SDL_FillRect(sdl_video.surf_screen, 0, 0);
/*if (config.render && (interlaced || config.ntsc)) rect.h *= 2; #if 0
if (config.render && (interlaced || config.ntsc)) rect.h *= 2;
if (config.ntsc) rect.w = (reg[12]&1) ? MD_NTSC_OUT_WIDTH(rect.w) : SMS_NTSC_OUT_WIDTH(rect.w); if (config.ntsc) rect.w = (reg[12]&1) ? MD_NTSC_OUT_WIDTH(rect.w) : SMS_NTSC_OUT_WIDTH(rect.w);
if (config.ntsc) if (config.ntsc)
{ {
@ -233,7 +238,8 @@ static void sdl_video_update()
free(md_ntsc); free(md_ntsc);
md_ntsc = NULL; md_ntsc = NULL;
} }
} */ }
#endif
} }
SDL_BlitSurface(sdl_video.surf_bitmap, &sdl_video.srect, sdl_video.surf_screen, &sdl_video.drect); SDL_BlitSurface(sdl_video.surf_bitmap, &sdl_video.srect, sdl_video.surf_screen, &sdl_video.drect);
@ -658,8 +664,6 @@ int sdl_input_update(void)
break; break;
} }
} }
free (keystate);
return 1; return 1;
} }

View File

@ -6,7 +6,6 @@
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
#include <time.h> #include <time.h>
#include <conio.h>
#include <SDL.h> #include <SDL.h>
#include <stdlib.h> #include <stdlib.h>