mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-12-31 21:51:50 +01:00
fixed an error with Z80 reset from previous changes
This commit is contained in:
parent
3434f89e3b
commit
84a395dbf3
@ -258,18 +258,19 @@ unsigned int gen_bankswitch_r(void)
|
|||||||
-----------------------------------------------------------------------*/
|
-----------------------------------------------------------------------*/
|
||||||
void gen_zbusreq_w(unsigned int state, unsigned int cycles)
|
void gen_zbusreq_w(unsigned int state, unsigned int cycles)
|
||||||
{
|
{
|
||||||
if (state) /* Z80 Bus Requested */
|
if (state) /* !ZBUSREQ asserted */
|
||||||
{
|
{
|
||||||
/* if z80 was running, resynchronize with 68k */
|
/* if z80 was running, resynchronize with 68k */
|
||||||
if (zstate == 1)
|
if (zstate == 1)
|
||||||
z80_run(cycles);
|
z80_run(cycles);
|
||||||
|
|
||||||
/* request Z80 bus */
|
/* update Z80 bus status */
|
||||||
zstate |= 2;
|
zstate |= 2;
|
||||||
|
|
||||||
/* enable 68k access */
|
/* check if Z80 reset is released */
|
||||||
if (zstate & 1)
|
if (zstate & 1)
|
||||||
{
|
{
|
||||||
|
/* enable 68k access to Z80 bus */
|
||||||
_m68k_memory_map *base = &m68k_memory_map[0xa0];
|
_m68k_memory_map *base = &m68k_memory_map[0xa0];
|
||||||
base->read8 = z80_read_byte;
|
base->read8 = z80_read_byte;
|
||||||
base->read16 = z80_read_word;
|
base->read16 = z80_read_word;
|
||||||
@ -277,13 +278,13 @@ void gen_zbusreq_w(unsigned int state, unsigned int cycles)
|
|||||||
base->write16 = z80_write_word;
|
base->write16 = z80_write_word;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else /* Z80 Bus Released */
|
else /* !ZBUSREQ released */
|
||||||
{
|
{
|
||||||
/* if z80 is restarted, resynchronize with 68k */
|
/* if z80 is restarted, resynchronize with 68k */
|
||||||
if (zstate == 3)
|
if (zstate == 3)
|
||||||
mcycles_z80 = cycles;
|
mcycles_z80 = cycles;
|
||||||
|
|
||||||
/* release Z80 bus */
|
/* update Z80 bus status */
|
||||||
zstate &= 1;
|
zstate &= 1;
|
||||||
|
|
||||||
/* disable 68k access */
|
/* disable 68k access */
|
||||||
@ -301,21 +302,19 @@ void gen_zreset_w(unsigned int state, unsigned int cycles)
|
|||||||
if (state == (zstate & 1))
|
if (state == (zstate & 1))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (state) /* !ZRESET inactive */
|
if (state) /* !ZRESET released */
|
||||||
{
|
{
|
||||||
/* if z80 is restarted, resynchronize with 68k */
|
/* if z80 is restarted, resynchronize with 68k */
|
||||||
if (zstate == 0)
|
if (!zstate)
|
||||||
mcycles_z80 = cycles;
|
mcycles_z80 = cycles;
|
||||||
|
|
||||||
/* reset Z80 */
|
/* update Z80 bus status */
|
||||||
z80_reset();
|
|
||||||
|
|
||||||
/* negate Z80 reset */
|
|
||||||
zstate |= 1;
|
zstate |= 1;
|
||||||
|
|
||||||
/* enable 68k access */
|
/* check if Z80 bus has been requested */
|
||||||
if (zstate & 1)
|
if (zstate & 2)
|
||||||
{
|
{
|
||||||
|
/* enable 68k access to Z80 bus */
|
||||||
_m68k_memory_map *base = &m68k_memory_map[0xa0];
|
_m68k_memory_map *base = &m68k_memory_map[0xa0];
|
||||||
base->read8 = z80_read_byte;
|
base->read8 = z80_read_byte;
|
||||||
base->read16 = z80_read_word;
|
base->read16 = z80_read_word;
|
||||||
@ -323,13 +322,17 @@ void gen_zreset_w(unsigned int state, unsigned int cycles)
|
|||||||
base->write16 = z80_write_word;
|
base->write16 = z80_write_word;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else /* !ZRESET active */
|
else /* !ZRESET asserted */
|
||||||
{
|
{
|
||||||
/* if z80 was running, resynchronize with 68k */
|
/* if z80 was running, resynchronize with 68k */
|
||||||
if (zstate == 1)
|
if (zstate == 1)
|
||||||
z80_run(cycles);
|
z80_run(cycles);
|
||||||
|
|
||||||
/* assert Z80 reset */
|
/* reset Z80 & YM2612 */
|
||||||
|
z80_reset();
|
||||||
|
fm_reset(cycles);
|
||||||
|
|
||||||
|
/* update Z80 bus status */
|
||||||
zstate &= 2;
|
zstate &= 2;
|
||||||
|
|
||||||
/* disable 68k access */
|
/* disable 68k access */
|
||||||
@ -340,8 +343,6 @@ void gen_zreset_w(unsigned int state, unsigned int cycles)
|
|||||||
base->write16 = m68k_unused_16_w;
|
base->write16 = m68k_unused_16_w;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset YM2612 */
|
|
||||||
fm_reset(cycles);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gen_zbank_w (unsigned int state)
|
void gen_zbank_w (unsigned int state)
|
||||||
|
@ -42,10 +42,10 @@ static inline void fm_update(unsigned int cycles)
|
|||||||
fm_cycles_count += cycles;
|
fm_cycles_count += cycles;
|
||||||
|
|
||||||
/* number of samples during period */
|
/* number of samples during period */
|
||||||
uint32 cnt = cycles / fm_cycles_ratio;
|
unsigned int cnt = cycles / fm_cycles_ratio;
|
||||||
|
|
||||||
/* remaining cycles */
|
/* remaining cycles */
|
||||||
uint32 remain = cycles % fm_cycles_ratio;
|
unsigned int remain = cycles % fm_cycles_ratio;
|
||||||
if (remain)
|
if (remain)
|
||||||
{
|
{
|
||||||
/* one sample ahead */
|
/* one sample ahead */
|
||||||
@ -82,10 +82,10 @@ static inline void psg_update(unsigned int cycles)
|
|||||||
psg_cycles_count += cycles;
|
psg_cycles_count += cycles;
|
||||||
|
|
||||||
/* number of samples during period */
|
/* number of samples during period */
|
||||||
uint32 cnt = cycles / psg_cycles_ratio;
|
unsigned int cnt = cycles / psg_cycles_ratio;
|
||||||
|
|
||||||
/* remaining cycles */
|
/* remaining cycles */
|
||||||
uint32 remain = cycles % psg_cycles_ratio;
|
unsigned int remain = cycles % psg_cycles_ratio;
|
||||||
if (remain)
|
if (remain)
|
||||||
{
|
{
|
||||||
/* one sample ahead */
|
/* one sample ahead */
|
||||||
|
@ -89,7 +89,7 @@ int audio_update (void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* adjust remaining samples in FM output buffer*/
|
/* adjust remaining samples in FM output buffer*/
|
||||||
snd.fm.pos -= (size << 1);
|
snd.fm.pos -= (size * 2);
|
||||||
|
|
||||||
#ifdef LOGSOUND
|
#ifdef LOGSOUND
|
||||||
error("%d FM samples remaining\n",(snd.fm.pos - snd.fm.buffer)>>1);
|
error("%d FM samples remaining\n",(snd.fm.pos - snd.fm.buffer)>>1);
|
||||||
@ -154,8 +154,8 @@ int audio_update (void)
|
|||||||
rrp = rr;
|
rrp = rr;
|
||||||
|
|
||||||
/* keep remaining samples for next frame */
|
/* keep remaining samples for next frame */
|
||||||
memcpy(snd.fm.buffer, fm, (snd.fm.pos - snd.fm.buffer) << 2);
|
memcpy(snd.fm.buffer, fm, (snd.fm.pos - snd.fm.buffer) * 4);
|
||||||
memcpy(snd.psg.buffer, psg, (snd.psg.pos - snd.psg.buffer) << 1);
|
memcpy(snd.psg.buffer, psg, (snd.psg.pos - snd.psg.buffer) * 2);
|
||||||
|
|
||||||
#ifdef LOGSOUND
|
#ifdef LOGSOUND
|
||||||
error("%d samples returned\n\n",size);
|
error("%d samples returned\n\n",size);
|
||||||
@ -191,20 +191,12 @@ int audio_init (int samplerate, float framerate)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* SN76489 stream buffers */
|
/* SN76489 stream buffers */
|
||||||
#ifndef NGC
|
|
||||||
snd.psg.buffer = (int16 *) malloc(snd.buffer_size * sizeof(int16));
|
snd.psg.buffer = (int16 *) malloc(snd.buffer_size * sizeof(int16));
|
||||||
#else
|
|
||||||
snd.psg.buffer = (int16 *) memalign(32, snd.buffer_size * sizeof(int16));
|
|
||||||
#endif
|
|
||||||
if (!snd.psg.buffer)
|
if (!snd.psg.buffer)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
/* YM2612 stream buffers */
|
/* YM2612 stream buffers */
|
||||||
#ifndef NGC
|
|
||||||
snd.fm.buffer = (int32 *) malloc(snd.buffer_size * sizeof(int32) * 2);
|
snd.fm.buffer = (int32 *) malloc(snd.buffer_size * sizeof(int32) * 2);
|
||||||
#else
|
|
||||||
snd.fm.buffer = (int32 *) memalign(32,snd.buffer_size * sizeof(int32) * 2);
|
|
||||||
#endif
|
|
||||||
if (!snd.fm.buffer)
|
if (!snd.fm.buffer)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user