mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-11-13 22:35:10 +01:00
fixed sound issues in PAL mode when HQ YM2612 is enabled (modified FIR resampler ratio)
fixed video glitches in games that switch video horizontal width. fixed BIOS infinite loop on hard reset
This commit is contained in:
parent
f2e43c9f8f
commit
0d58ff65e0
@ -2209,14 +2209,14 @@ void MainMenu (void)
|
|||||||
|
|
||||||
case 2: /*** Options */
|
case 2: /*** Options */
|
||||||
GUI_DeleteMenu(m);
|
GUI_DeleteMenu(m);
|
||||||
optionmenu ();
|
optionmenu();
|
||||||
GUI_InitMenu(m);
|
GUI_InitMenu(m);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: /*** Memory Manager ***/
|
case 3: /*** Memory Manager ***/
|
||||||
if (!cart.romsize) break;
|
if (!cart.romsize) break;
|
||||||
GUI_DeleteMenu(m);
|
GUI_DeleteMenu(m);
|
||||||
quit = filemenu ();
|
quit = filemenu();
|
||||||
if (quit) break;
|
if (quit) break;
|
||||||
GUI_InitMenu(m);
|
GUI_InitMenu(m);
|
||||||
break;
|
break;
|
||||||
@ -2225,9 +2225,10 @@ void MainMenu (void)
|
|||||||
if (!cart.romsize) break;
|
if (!cart.romsize) break;
|
||||||
GUI_DrawMenuFX(m,10,1);
|
GUI_DrawMenuFX(m,10,1);
|
||||||
GUI_DeleteMenu(m);
|
GUI_DeleteMenu(m);
|
||||||
gxClearScreen ((GXColor)BLACK);
|
gxClearScreen((GXColor)BLACK);
|
||||||
gxSetScreen();
|
gxSetScreen();
|
||||||
system_reset ();
|
system_init();
|
||||||
|
system_reset();
|
||||||
quit = 1;
|
quit = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2246,7 +2247,7 @@ void MainMenu (void)
|
|||||||
case 8: /*** ROM Information ***/
|
case 8: /*** ROM Information ***/
|
||||||
if (!cart.romsize) break;
|
if (!cart.romsize) break;
|
||||||
GUI_DeleteMenu(m);
|
GUI_DeleteMenu(m);
|
||||||
showrominfo ();
|
showrominfo();
|
||||||
GUI_InitMenu(m);
|
GUI_InitMenu(m);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,8 @@ void gx_audio_Update(void)
|
|||||||
u32 size = dma_len;
|
u32 size = dma_len;
|
||||||
|
|
||||||
/* VIDEO interrupt synchronization: we approximate next DMA length (see below) */
|
/* VIDEO interrupt synchronization: we approximate next DMA length (see below) */
|
||||||
/* VSYNC period is 16715 us which is approx. 802.32 samples */
|
/* In 50Hz mode, VSYNC period is 19967 usec which is approx 958.42 samples */
|
||||||
|
/* In 60Hz mode, VSYNC period is 16715 usec which is approx. 802.32 samples */
|
||||||
/* DMA length should be a multiple of 32 bytes so we use either 800 or 808 samples */
|
/* DMA length should be a multiple of 32 bytes so we use either 800 or 808 samples */
|
||||||
if (dma_sync)
|
if (dma_sync)
|
||||||
{
|
{
|
||||||
|
@ -460,13 +460,13 @@ static void gxResetScale(u32 width, u32 height)
|
|||||||
if (config.overscan)
|
if (config.overscan)
|
||||||
{
|
{
|
||||||
/* borders are emulated */
|
/* borders are emulated */
|
||||||
xscale = 358 - gc_pal;
|
xscale = 358 + ((reg[12] & 1)*2) - gc_pal;
|
||||||
yscale = vdp_pal + ((gc_pal && !config.render) ? 143 : 120);
|
yscale = vdp_pal + ((gc_pal && !config.render) ? 143 : 120);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* borders are simulated (black) */
|
/* borders are simulated (black) */
|
||||||
xscale = 328 - gc_pal;
|
xscale = 325 + ((reg[12] & 1)*2) - gc_pal;
|
||||||
yscale = bitmap.viewport.h / 2;
|
yscale = bitmap.viewport.h / 2;
|
||||||
if (vdp_pal && (!gc_pal || config.render)) yscale = yscale * 240 / 288;
|
if (vdp_pal && (!gc_pal || config.render)) yscale = yscale * 240 / 288;
|
||||||
else if (!vdp_pal && gc_pal && !config.render) yscale = yscale * 288 / 240;
|
else if (!vdp_pal && gc_pal && !config.render) yscale = yscale * 288 / 240;
|
||||||
@ -484,7 +484,7 @@ static void gxResetScale(u32 width, u32 height)
|
|||||||
if (config.overscan)
|
if (config.overscan)
|
||||||
{
|
{
|
||||||
/* borders are emulated */
|
/* borders are emulated */
|
||||||
xscale = 348;
|
xscale = 352;
|
||||||
yscale = (gc_pal && !config.render) ? (vdp_pal ? (268*144 / bitmap.viewport.h):143) : (vdp_pal ? (224*144 / bitmap.viewport.h):120);
|
yscale = (gc_pal && !config.render) ? (vdp_pal ? (268*144 / bitmap.viewport.h):143) : (vdp_pal ? (224*144 / bitmap.viewport.h):120);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1334,7 +1334,7 @@ void gx_video_Start(void)
|
|||||||
crosshair[1] = gxTextureOpenPNG(Crosshair_p2_png,0);
|
crosshair[1] = gxTextureOpenPNG(Crosshair_p2_png,0);
|
||||||
|
|
||||||
/* apply changes on next video update */
|
/* apply changes on next video update */
|
||||||
bitmap.viewport.changed |= 1;
|
bitmap.viewport.changed = 1;
|
||||||
|
|
||||||
/* reset GX rendering */
|
/* reset GX rendering */
|
||||||
gxResetRendering(0);
|
gxResetRendering(0);
|
||||||
@ -1343,12 +1343,19 @@ void gx_video_Start(void)
|
|||||||
/* GX render update */
|
/* GX render update */
|
||||||
void gx_video_Update(void)
|
void gx_video_Update(void)
|
||||||
{
|
{
|
||||||
|
int update = bitmap.viewport.changed;
|
||||||
|
|
||||||
/* check if display has changed */
|
/* check if display has changed */
|
||||||
if (bitmap.viewport.changed & 1)
|
if (update)
|
||||||
{
|
{
|
||||||
/* update texture size */
|
/* update texture size */
|
||||||
vwidth = bitmap.viewport.w + 2 * bitmap.viewport.x;
|
int old_vwidth = vwidth;
|
||||||
vheight = bitmap.viewport.h + 2 * bitmap.viewport.y;
|
vwidth = bitmap.viewport.w + (2 * bitmap.viewport.x);
|
||||||
|
vheight = bitmap.viewport.h + (2 * bitmap.viewport.y);
|
||||||
|
|
||||||
|
/* if width has been changed, do no render this frame */
|
||||||
|
/* this fixes texture glitches when changing width middle-frame */
|
||||||
|
if (vwidth != old_vwidth) return;
|
||||||
|
|
||||||
/* special cases */
|
/* special cases */
|
||||||
if (config.render && interlaced) vheight = vheight << 1;
|
if (config.render && interlaced) vheight = vheight << 1;
|
||||||
@ -1397,9 +1404,9 @@ void gx_video_Update(void)
|
|||||||
whichfb ^= 1;
|
whichfb ^= 1;
|
||||||
|
|
||||||
/* reconfigure VI */
|
/* reconfigure VI */
|
||||||
if (bitmap.viewport.changed & 1)
|
if (update)
|
||||||
{
|
{
|
||||||
bitmap.viewport.changed &= 2;
|
bitmap.viewport.changed = 0;
|
||||||
|
|
||||||
/* change VI mode */
|
/* change VI mode */
|
||||||
VIDEO_Configure(rmode);
|
VIDEO_Configure(rmode);
|
||||||
|
@ -73,7 +73,11 @@ void sound_init(int rate)
|
|||||||
if (config.hq_fm)
|
if (config.hq_fm)
|
||||||
{
|
{
|
||||||
m68cycles_per_sample[0] = 144;
|
m68cycles_per_sample[0] = 144;
|
||||||
Fir_Resampler_time_ratio(vclk/144.0/(double)rate);
|
|
||||||
|
/* "real" ratio is (vclk/144.0)/(rate) but this causes scratchy sound in Wii/GCN 50Hz video mode */
|
||||||
|
/* since "real" framerate is lower than 50 fps whereas PAL Wii/GCN framerate is higher than 50 fps */
|
||||||
|
/* it's better to directly use the ratio between generated & expected numbers of samples per frame */
|
||||||
|
Fir_Resampler_time_ratio((double)m68cycles_per_line * (double)lines_per_frame * (double)vdp_rate / 144.0 / (double)rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize sound chips */
|
/* initialize sound chips */
|
||||||
|
@ -1917,7 +1917,10 @@ void YM2612Update(int length)
|
|||||||
|
|
||||||
/* Output samples buffers */
|
/* Output samples buffers */
|
||||||
int16 *bufFIR = Fir_Resampler_buffer();
|
int16 *bufFIR = Fir_Resampler_buffer();
|
||||||
if (bufFIR) bufFIR += snd.fm.pos*2;
|
if (bufFIR)
|
||||||
|
{
|
||||||
|
bufFIR += (snd.fm.pos << 1);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bufL = snd.fm.buffer[0] + snd.fm.pos;
|
bufL = snd.fm.buffer[0] + snd.fm.pos;
|
||||||
|
@ -79,7 +79,7 @@ void audio_update (int size)
|
|||||||
if (config.hq_fm)
|
if (config.hq_fm)
|
||||||
{
|
{
|
||||||
int len = Fir_Resampler_input_needed(size * 2);
|
int len = Fir_Resampler_input_needed(size * 2);
|
||||||
sound_update(len/2,size);
|
sound_update(len >> 1,size);
|
||||||
Fir_Resampler_write(len);
|
Fir_Resampler_write(len);
|
||||||
Fir_Resampler_read(fm,size);
|
Fir_Resampler_read(fm,size);
|
||||||
}
|
}
|
||||||
@ -201,9 +201,6 @@ void audio_shutdown(void)
|
|||||||
|
|
||||||
/* Resampling buffer */
|
/* Resampling buffer */
|
||||||
Fir_Resampler_shutdown();
|
Fir_Resampler_shutdown();
|
||||||
|
|
||||||
/* sn76489 chip (Blip Buffer allocated memory) */
|
|
||||||
SN76489_Shutdown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************
|
/****************************************************************
|
||||||
@ -282,24 +279,12 @@ int system_frame (int do_skip)
|
|||||||
interlaced = (reg[12] & 2) >> 1;
|
interlaced = (reg[12] & 2) >> 1;
|
||||||
if (old_interlaced != interlaced)
|
if (old_interlaced != interlaced)
|
||||||
{
|
{
|
||||||
bitmap.viewport.changed |= 1;
|
bitmap.viewport.changed = 1;
|
||||||
im2_flag = ((reg[12] & 6) == 6);
|
im2_flag = ((reg[12] & 6) == 6);
|
||||||
odd_frame = 1;
|
odd_frame = 1;
|
||||||
}
|
}
|
||||||
odd_frame ^= 1;
|
odd_frame ^= 1;
|
||||||
|
|
||||||
#ifdef NGC
|
|
||||||
if (bitmap.viewport.changed & 2)
|
|
||||||
{
|
|
||||||
/* Update the width of the viewport */
|
|
||||||
bitmap.viewport.w = (reg[12] & 1) ? 320 : 256;
|
|
||||||
bitmap.viewport.changed = 1;
|
|
||||||
|
|
||||||
/* Update clipping */
|
|
||||||
window_clip();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* clear VBLANK and DMA flags */
|
/* clear VBLANK and DMA flags */
|
||||||
status &= 0xFFF5;
|
status &= 0xFFF5;
|
||||||
|
|
||||||
|
30
source/vdp.c
30
source/vdp.c
@ -211,9 +211,9 @@ void vdp_reset(void)
|
|||||||
bitmap.viewport.ow = 224;
|
bitmap.viewport.ow = 224;
|
||||||
|
|
||||||
/* reset border area */
|
/* reset border area */
|
||||||
bitmap.viewport.x = config.overscan ? 14 : 0;
|
bitmap.viewport.x = (reg[12] & 1) ? 16 : 12;
|
||||||
bitmap.viewport.y = config.overscan ? (vdp_pal ? 32 : 8) : 0;
|
bitmap.viewport.y = config.overscan ? (vdp_pal ? 32 : 8) : 0;
|
||||||
bitmap.viewport.changed = 2;
|
bitmap.viewport.changed = 1;
|
||||||
|
|
||||||
/* initialize some registers (normally set by BIOS) */
|
/* initialize some registers (normally set by BIOS) */
|
||||||
if (config.bios_enabled != 3)
|
if (config.bios_enabled != 3)
|
||||||
@ -245,9 +245,9 @@ void vdp_restore(uint8 *vdp_regs)
|
|||||||
hctab = (reg[12] & 1) ? cycle2hc40 : cycle2hc32;
|
hctab = (reg[12] & 1) ? cycle2hc40 : cycle2hc32;
|
||||||
|
|
||||||
/* reinitialize overscan area */
|
/* reinitialize overscan area */
|
||||||
bitmap.viewport.x = config.overscan ? 14 : 0;
|
bitmap.viewport.x = (reg[12] & 1) ? 16 : 12;
|
||||||
bitmap.viewport.y = config.overscan ? (((reg[1] & 8) ? 0 : 8) + (vdp_pal ? 24 : 0)) : 0;
|
bitmap.viewport.y = config.overscan ? (((reg[1] & 8) ? 0 : 8) + (vdp_pal ? 24 : 0)) : 0;
|
||||||
bitmap.viewport.changed = 2;
|
bitmap.viewport.changed = 1;
|
||||||
|
|
||||||
/* restore VDP timings */
|
/* restore VDP timings */
|
||||||
fifo_latency = (reg[12] & 1) ? 27 : 30;
|
fifo_latency = (reg[12] & 1) ? 27 : 30;
|
||||||
@ -682,12 +682,13 @@ static inline void reg_w(unsigned int r, unsigned int d)
|
|||||||
/* See if the viewport height has actually been changed */
|
/* See if the viewport height has actually been changed */
|
||||||
if ((d & 8) != (reg[1] & 8))
|
if ((d & 8) != (reg[1] & 8))
|
||||||
{
|
{
|
||||||
/* update the height of the viewport */
|
/* update viewport */
|
||||||
bitmap.viewport.changed |= 1;
|
bitmap.viewport.changed = 1;
|
||||||
bitmap.viewport.h = (d & 8) ? 240 : 224;
|
bitmap.viewport.h = (d & 8) ? 240 : 224;
|
||||||
|
if (config.overscan)
|
||||||
/* update overscan height */
|
{
|
||||||
if (config.overscan) bitmap.viewport.y = ((vdp_pal ? 288 : 240) - bitmap.viewport.h) / 2;
|
bitmap.viewport.y = ((vdp_pal ? 288 : 240) - bitmap.viewport.h) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
/* update VC table */
|
/* update VC table */
|
||||||
if (vdp_pal) vctab = (d & 8) ? vc_pal_240 : vc_pal_224;
|
if (vdp_pal) vctab = (d & 8) ? vc_pal_240 : vc_pal_224;
|
||||||
@ -769,10 +770,9 @@ static inline void reg_w(unsigned int r, unsigned int d)
|
|||||||
/* Update HC table */
|
/* Update HC table */
|
||||||
hctab = cycle2hc40;
|
hctab = cycle2hc40;
|
||||||
|
|
||||||
#ifndef NGC
|
|
||||||
/* Update viewport width */
|
/* Update viewport width */
|
||||||
bitmap.viewport.w = 320;
|
bitmap.viewport.w = 320;
|
||||||
#endif
|
if (config.overscan) bitmap.viewport.x = 16;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -785,22 +785,16 @@ static inline void reg_w(unsigned int r, unsigned int d)
|
|||||||
/* Update HC table */
|
/* Update HC table */
|
||||||
hctab = cycle2hc32;
|
hctab = cycle2hc32;
|
||||||
|
|
||||||
#ifndef NGC
|
|
||||||
/* Update viewport width */
|
/* Update viewport width */
|
||||||
bitmap.viewport.w = 256;
|
bitmap.viewport.w = 256;
|
||||||
#endif
|
if (config.overscan) bitmap.viewport.x = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NGC
|
|
||||||
/* Update viewport */
|
/* Update viewport */
|
||||||
bitmap.viewport.changed = 1;
|
bitmap.viewport.changed = 1;
|
||||||
|
|
||||||
/* Update clipping */
|
/* Update clipping */
|
||||||
window_clip();
|
window_clip();
|
||||||
#else
|
|
||||||
/* Postpound update on next frame */
|
|
||||||
bitmap.viewport.changed = 2;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See if the S/TE mode bit has changed */
|
/* See if the S/TE mode bit has changed */
|
||||||
|
Loading…
Reference in New Issue
Block a user