diff --git a/source/gx/config.c b/source/gx/config.c index 567fd6d..ab32d91 100644 --- a/source/gx/config.c +++ b/source/gx/config.c @@ -100,8 +100,8 @@ void config_default(void) config.fm_preamp = 100; config.hq_fm = 1; config.psgBoostNoise = 1; - config.filter = 0; - config.lp_range = 60; + config.filter = 1; + config.lp_range = 0x9999; /* 0.6 in 16.16 fixed point */ config.low_freq = 880; config.high_freq = 5000; config.lg = 1.0; @@ -109,6 +109,7 @@ void config_default(void) config.hg = 1.0; config.dac_bits = 14; config.ym2413 = 2; /* AUTO */ + config.mono = 0; /* system options */ config.system = 0; /* AUTO */ @@ -131,16 +132,16 @@ void config_default(void) config.gg_extra = 0; config.ntsc = 0; config.vsync = 1; /* AUTO */ + config.bilinear = 1; + config.vfilter = 1; if (VIDEO_HaveComponentCable()) { - config.render = 2; - config.bilinear = 1; + config.render = 2; } else { - config.render = 0; - config.bilinear = 0; + config.render = 0; } switch (vmode->viTVMode >> 2) @@ -159,7 +160,7 @@ void config_default(void) } #ifdef HW_RVL - config.trap = 0; + config.trap = 0; config.gamma = VI_GM_1_0 / 10.0; #endif diff --git a/source/gx/config.h b/source/gx/config.h index d031a25..c2cd096 100644 --- a/source/gx/config.h +++ b/source/gx/config.h @@ -40,7 +40,7 @@ #ifndef _CONFIG_H_ #define _CONFIG_H_ -#define CONFIG_VERSION "GENPLUS-GX 1.7.2" +#define CONFIG_VERSION "GENPLUS-GX 1.7.4" /**************************************************************************** * Config Option @@ -54,9 +54,10 @@ typedef struct uint8 psgBoostNoise; uint8 dac_bits; uint8 ym2413; + uint8 mono; int16 psg_preamp; int16 fm_preamp; - int16 lp_range; + uint32 lp_range; int16 low_freq; int16 high_freq; int16 lg; @@ -68,7 +69,6 @@ typedef struct uint8 vdp_mode; uint8 force_dtack; uint8 addr_error; - uint8 tmss; uint8 bios; uint8 lock_on; uint8 hot_swap; @@ -81,6 +81,7 @@ typedef struct uint8 render; uint8 tv_mode; uint8 bilinear; + uint8 vfilter; uint8 aspect; int16 xshift; int16 yshift; diff --git a/source/gx/gui/filesel.c b/source/gx/gui/filesel.c index f95aa5d..1990732 100644 --- a/source/gx/gui/filesel.c +++ b/source/gx/gui/filesel.c @@ -484,7 +484,7 @@ int FileSelector(int type) if (selection < 0) { selection = maxfiles - 1; - offset = selection - 10 + 1; + offset = maxfiles - 10; } if (selection < offset) offset -= 10; @@ -559,8 +559,12 @@ int FileSelector(int type) if ((filelist[i].flags) && !strcmp(prev_folder,filelist[i].filename)) { selection = i; - offset = (i / 10) * 10; - i = maxfiles; + while (i >= (offset + 10)) + { + offset += 10; + if (offset > (maxfiles - 10)) offset = maxfiles - 10; + } + break; } } } diff --git a/source/gx/gui/menu.c b/source/gx/gui/menu.c index 9518611..6bd3718 100644 --- a/source/gx/gui/menu.c +++ b/source/gx/gui/menu.c @@ -332,7 +332,7 @@ static gui_item items_options[5] = }; /* Audio options */ -static gui_item items_audio[12] = +static gui_item items_audio[13] = { {NULL,NULL,"Master System FM: AUTO", "Enable/disable YM2413 chip", 56,132,276,48}, {NULL,NULL,"High-Quality FM: ON", "Adjust YM2612/YM2413 resampling quality", 56,132,276,48}, @@ -340,6 +340,7 @@ static gui_item items_audio[12] = {NULL,NULL,"FM Volume: 1.00", "Adjust YM2612/YM2413 output level", 56,132,276,48}, {NULL,NULL,"PSG Volume: 2.50", "Adjust SN76489 output level", 56,132,276,48}, {NULL,NULL,"PSG Noise Boost: OFF", "Boost SN76489 Noise Channel", 56,132,276,48}, + {NULL,NULL,"Audio Out: STEREO", "Select audio mixing output type", 56,132,276,48}, {NULL,NULL,"Filtering: 3-BAND EQ", "Setup Audio filtering", 56,132,276,48}, {NULL,NULL,"Low Gain: 1.00", "Adjust EQ Low Band Gain", 56,132,276,48}, {NULL,NULL,"Mid Gain: 1.00", "Adjust EQ Mid Band Gain", 56,132,276,48}, @@ -365,25 +366,26 @@ static gui_item items_system[10] = /* Video options */ #ifdef HW_RVL -static gui_item items_video[12] = +static gui_item items_video[13] = #else -static gui_item items_video[10] = +static gui_item items_video[11] = #endif { - {NULL,NULL,"Display: PROGRESSIVE", "Select video mode", 56,132,276,48}, - {NULL,NULL,"TV mode: 50/60Hz", "Select video refresh rate", 56,132,276,48}, - {NULL,NULL,"VSYNC: AUTO", "Enable/disable sync with Video Hardware", 56,132,276,48}, - {NULL,NULL,"GX Bilinear Filter: OFF", "Enable/disable texture hardware filtering", 56,132,276,48}, + {NULL,NULL,"Display: PROGRESSIVE", "Select video mode", 56,132,276,48}, + {NULL,NULL,"TV mode: 50/60Hz", "Select video refresh rate", 56,132,276,48}, + {NULL,NULL,"VSYNC: AUTO", "Enable/disable sync with Video Hardware", 56,132,276,48}, + {NULL,NULL,"GX Bilinear Filter: OFF", "Enable/disable texture hardware filtering", 56,132,276,48}, + {NULL,NULL,"GX Deflickering Filter: OFF","Enable/disable GX hardware filtering", 56,132,276,48}, #ifdef HW_RVL - {NULL,NULL,"VI Trap Filter: ON", "Enable/disable video hardware filtering", 56,132,276,48}, - {NULL,NULL,"VI Gamma Correction: 1.0","Adjust video hardware gamma correction", 56,132,276,48}, + {NULL,NULL,"VI Trap Filter: ON", "Enable/disable video hardware filtering", 56,132,276,48}, + {NULL,NULL,"VI Gamma Correction: 1.0", "Adjust video hardware gamma correction", 56,132,276,48}, #endif - {NULL,NULL,"NTSC Filter: COMPOSITE", "Enable/disable NTSC software filtering", 56,132,276,48}, - {NULL,NULL,"Borders: OFF", "Enable/disable overscan emulation", 56,132,276,48}, - {NULL,NULL,"GG screen: ORIGINAL", "Enable/disable Game Gear extended screen", 56,132,276,48}, - {NULL,NULL,"Aspect: ORIGINAL (4:3)", "Select display aspect ratio", 56,132,276,48}, - {NULL,NULL,"Screen Position (+0,+0)", "Adjust display position", 56,132,276,48}, - {NULL,NULL,"Screen Scaling (+0,+0)", "Adjust display scaling", 56,132,276,48} + {NULL,NULL,"NTSC Filter: COMPOSITE", "Enable/disable NTSC software filtering", 56,132,276,48}, + {NULL,NULL,"Borders: OFF", "Enable/disable overscan emulation", 56,132,276,48}, + {NULL,NULL,"GG screen: ORIGINAL", "Enable/disable Game Gear extended screen", 56,132,276,48}, + {NULL,NULL,"Aspect: ORIGINAL (4:3)", "Select display aspect ratio", 56,132,276,48}, + {NULL,NULL,"Screen Position (+0,+0)", "Adjust display position", 56,132,276,48}, + {NULL,NULL,"Screen Scaling (+0,+0)", "Adjust display scaling", 56,132,276,48} }; /* Menu options */ @@ -819,6 +821,7 @@ static void soundmenu () sprintf (items[3].text, "FM Volume: %1.2f", fm_volume); sprintf (items[4].text, "PSG Volume: %1.2f", psg_volume); sprintf (items[5].text, "PSG Noise Boost: %s", config.psgBoostNoise ? "ON":"OFF"); + sprintf (items[6].text, "Audio Out: %s", config.mono ? "MONO":"STEREO"); if (config.filter == 2) { @@ -826,26 +829,27 @@ static void soundmenu () float mg = (float)config.mg/100.0; float hg = (float)config.hg/100.0; - sprintf(items[6].text, "Filtering: 3-BAND EQ"); - sprintf(items[7].text, "Low Gain: %1.2f", lg); - strcpy(items[7].comment, "Adjust EQ Low Band Gain"); - sprintf(items[8].text, "Middle Gain: %1.2f", mg); - sprintf(items[9].text, "High Gain: %1.2f", hg); - sprintf(items[10].text, "Low Freq: %d", config.low_freq); - sprintf(items[11].text, "High Freq: %d", config.high_freq); - m->max_items = 12; + sprintf(items[7].text, "Filtering: 3-BAND EQ"); + sprintf(items[8].text, "Low Gain: %1.2f", lg); + strcpy(items[8].comment, "Adjust EQ Low Band Gain"); + sprintf(items[9].text, "Middle Gain: %1.2f", mg); + sprintf(items[10].text, "High Gain: %1.2f", hg); + sprintf(items[11].text, "Low Freq: %d", config.low_freq); + sprintf(items[12].text, "High Freq: %d", config.high_freq); + m->max_items = 13; } else if (config.filter == 1) { - sprintf (items[6].text, "Filtering: LOW-PASS"); - sprintf (items[7].text, "Low-Pass Rate: %d %%", config.lp_range); - strcpy (items[7].comment, "Adjust Low Pass filter"); - m->max_items = 8; + int lp_range = (config.lp_range * 100 + 0xffff) / 0x10000; + sprintf (items[7].text, "Filtering: LOW-PASS"); + sprintf (items[8].text, "Low-Pass Rate: %d %%", lp_range); + strcpy (items[9].comment, "Adjust Low Pass filter"); + m->max_items = 9; } else { - sprintf (items[6].text, "Filtering: OFF"); - m->max_items = 7; + sprintf (items[7].text, "Filtering: OFF"); + m->max_items = 8; } GUI_InitMenu(m); @@ -935,28 +939,36 @@ static void soundmenu () } case 6: + { + config.mono ^= 1; + sprintf (items[6].text, "Audio Out: %s", config.mono ? "MONO":"STEREO"); + break; + } + + case 7: { config.filter = (config.filter + 1) % 3; if (config.filter == 2) { float lg = (float)config.lg/100.0; - sprintf (items[6].text, "Filtering: 3-BAND EQ"); - sprintf (items[7].text, "Low Gain: %1.2f", lg); - strcpy (items[7].comment, "Adjust EQ Low Band Gain"); - m->max_items = 12; + sprintf (items[7].text, "Filtering: 3-BAND EQ"); + sprintf (items[8].text, "Low Gain: %1.2f", lg); + strcpy (items[8].comment, "Adjust EQ Low Band Gain"); + m->max_items = 13; audio_set_equalizer(); } else if (config.filter == 1) { - sprintf (items[6].text, "Filtering: LOW-PASS"); - sprintf (items[7].text, "Low-Pass Rate: %d %%", config.lp_range); - strcpy (items[7].comment, "Adjust Low Pass filter"); - m->max_items = 8; + int lp_range = (config.lp_range * 100 + 0xffff) / 0x10000; + sprintf (items[7].text, "Filtering: LOW-PASS"); + sprintf (items[8].text, "Low-Pass Rate: %d %%", lp_range); + strcpy (items[8].comment, "Adjust Low Pass filter"); + m->max_items = 9; } else { - sprintf (items[6].text, "Filtering: OFF"); - m->max_items = 7; + sprintf (items[7].text, "Filtering: OFF"); + m->max_items = 8; } while ((m->offset + 4) > m->max_items) @@ -967,56 +979,58 @@ static void soundmenu () break; } - case 7: + case 8: { if (config.filter == 1) { - GUI_OptionBox(m,0,"Low-Pass Rate",(void *)&config.lp_range,1,0,100,1); - sprintf (items[7].text, "Low-Pass Rate: %d %%", config.lp_range); + int lp_range = (config.lp_range * 100 + 0xffff) / 0x10000; + GUI_OptionBox(m,0,"Low-Pass Rate",(void *)&lp_range,1,0,100,1); + sprintf (items[8].text, "Low-Pass Rate: %d %%", lp_range); + config.lp_range = (lp_range * 0x10000) / 100; } else { float lg = (float)config.lg/100.0; GUI_OptionBox(m,0,"Low Gain",(void *)&lg,0.01,0.0,2.0,0); - sprintf (items[7].text, "Low Gain: %1.2f", lg); + sprintf (items[8].text, "Low Gain: %1.2f", lg); config.lg = (int)(lg * 100.0); audio_set_equalizer(); } break; } - case 8: + case 9: { float mg = (float)config.mg/100.0; GUI_OptionBox(m,0,"Middle Gain",(void *)&mg,0.01,0.0,2.0,0); - sprintf (items[8].text, "Middle Gain: %1.2f", mg); + sprintf (items[9].text, "Middle Gain: %1.2f", mg); config.mg = (int)(mg * 100.0); audio_set_equalizer(); break; } - case 9: - { - float hg = (float)config.hg/100.0; - GUI_OptionBox(m,0,"High Gain",(void *)&hg,0.01,0.0,2.0,0); - sprintf (items[9].text, "High Gain: %1.2f", hg); - config.hg = (int)(hg * 100.0); - audio_set_equalizer(); - break; - } - case 10: { - GUI_OptionBox(m,0,"Low Frequency",(void *)&config.low_freq,10,0,config.high_freq,1); - sprintf (items[10].text, "Low Freq: %d", config.low_freq); + float hg = (float)config.hg/100.0; + GUI_OptionBox(m,0,"High Gain",(void *)&hg,0.01,0.0,2.0,0); + sprintf (items[10].text, "High Gain: %1.2f", hg); + config.hg = (int)(hg * 100.0); audio_set_equalizer(); break; } case 11: + { + GUI_OptionBox(m,0,"Low Frequency",(void *)&config.low_freq,10,0,config.high_freq,1); + sprintf (items[11].text, "Low Freq: %d", config.low_freq); + audio_set_equalizer(); + break; + } + + case 12: { GUI_OptionBox(m,0,"High Frequency",(void *)&config.high_freq,100,config.low_freq,30000,1); - sprintf (items[11].text, "High Freq: %d", config.high_freq); + sprintf (items[12].text, "High Freq: %d", config.high_freq); audio_set_equalizer(); break; } @@ -1292,14 +1306,7 @@ static void systemmenu () case 6: /*** 68k Address Error ***/ { config.addr_error ^= 1; - if (((system_hw & SYSTEM_PBC) == SYSTEM_MD) && (system_hw != SYSTEM_MCD)) - { - /* reinitialize cartridge hardware (UMK3 hack support) */ - md_cart_init(); - - /* restore SRAM */ - slot_autoload(0,config.s_device); - } + m68k.aerr_enabled = config.addr_error; sprintf (items[6].text, "68k Address Error: %s", config.addr_error ? "ON" : "OFF"); break; } @@ -1439,14 +1446,14 @@ static void systemmenu () * ****************************************************************************/ #ifdef HW_RVL -#define VI_OFFSET 6 +#define VI_OFFSET 7 static void update_gamma(void) { VIDEO_SetGamma((int)(config.gamma * 10.0)); VIDEO_Flush(); } #else -#define VI_OFFSET 4 +#define VI_OFFSET 5 #endif static void videomenu () @@ -1477,10 +1484,11 @@ static void videomenu () sprintf (items[2].text, "VSYNC: OFF"); sprintf (items[3].text, "GX Bilinear Filter: %s", config.bilinear ? " ON" : "OFF"); + sprintf (items[4].text, "GX Deflickering Filter: %s", config.vfilter ? " ON" : "OFF"); #ifdef HW_RVL - sprintf (items[4].text, "VI Trap Filter: %s", config.trap ? " ON" : "OFF"); - sprintf (items[5].text, "VI Gamma Correction: %1.1f", config.gamma); + sprintf (items[5].text, "VI Trap Filter: %s", config.trap ? " ON" : "OFF"); + sprintf (items[6].text, "VI Gamma Correction: %1.1f", config.gamma); #endif if (config.ntsc == 1) @@ -1493,7 +1501,7 @@ static void videomenu () sprintf (items[VI_OFFSET].text, "NTSC Filter: OFF"); if (config.overscan == 3) - sprintf (items[VI_OFFSET+1].text, "Borders: ALL"); + sprintf (items[VI_OFFSET+1].text, "Borders: FULL"); else if (config.overscan == 2) sprintf (items[VI_OFFSET+1].text, "Borders: H ONLY"); else if (config.overscan == 1) @@ -1590,13 +1598,18 @@ static void videomenu () sprintf (items[3].text, "GX Bilinear Filter: %s", config.bilinear ? " ON" : "OFF"); break; -#ifdef HW_RVL - case 4: /*** VIDEO Trap filtering ***/ - config.trap ^= 1; - sprintf (items[4].text, "VI Trap Filter: %s", config.trap ? " ON" : "OFF"); + case 4: /*** GX Copy filtering (deflickering filter) ***/ + config.vfilter ^= 1; + sprintf (items[4].text, "GX Deflicker Filter: %s", config.vfilter ? " ON" : "OFF"); break; - case 5: /*** VIDEO Gamma correction ***/ +#ifdef HW_RVL + case 5: /*** VIDEO Trap filtering ***/ + config.trap ^= 1; + sprintf (items[5].text, "VI Trap Filter: %s", config.trap ? " ON" : "OFF"); + break; + + case 6: /*** VIDEO Gamma correction ***/ if (system_hw) { update_gamma(); @@ -1615,7 +1628,7 @@ static void videomenu () m->arrows[1]->state = state[1]; m->screenshot = 0; strcpy(m->title,"Video Settings"); - sprintf (items[5].text, "VI Gamma Correction: %1.1f", config.gamma); + sprintf (items[6].text, "VI Gamma Correction: %1.1f", config.gamma); VIDEO_SetGamma(VI_GM_1_0); VIDEO_Flush(); } @@ -1641,7 +1654,7 @@ static void videomenu () case VI_OFFSET+1: /*** overscan emulation ***/ config.overscan = (config.overscan + 1) & 3; if (config.overscan == 3) - sprintf (items[VI_OFFSET+1].text, "Borders: ALL"); + sprintf (items[VI_OFFSET+1].text, "Borders: FULL"); else if (config.overscan == 2) sprintf (items[VI_OFFSET+1].text, "Borders: H ONLY"); else if (config.overscan == 1) diff --git a/source/gx/gx_audio.c b/source/gx/gx_audio.c index dbd340e..ca24660 100644 --- a/source/gx/gx_audio.c +++ b/source/gx/gx_audio.c @@ -78,7 +78,7 @@ static void ai_callback(void) prevtime = current; #endif - audio_sync = 1; + audio_sync = 0; } /* AUDIO engine initialization */ @@ -128,7 +128,7 @@ void gx_audio_Shutdown(void) ***/ int gx_audio_Update(void) { - if (audio_sync) + if (!audio_sync) { /* Current available soundbuffer */ s16 *sb = (s16 *)(soundbuffer[mixbuffer]); @@ -151,7 +151,7 @@ int gx_audio_Update(void) DCFlushRange((void *)sb, size); AUDIO_InitDMA((u32) sb, size); mixbuffer = (mixbuffer + 1) % SOUND_BUFFER_NUM; - audio_sync = 0; + audio_sync = 1; /* Start Audio DMA */ /* this is called once to kick-off DMA from external memory to audio interface */ @@ -200,7 +200,7 @@ void gx_audio_Start(void) memset(soundbuffer, 0, 3 * SOUND_BUFFER_LEN); audioStarted = 0; mixbuffer = 0; - audio_sync = 1; + audio_sync = 0; } /*** diff --git a/source/gx/gx_video.c b/source/gx/gx_video.c index 21b9860..f0c1756 100644 --- a/source/gx/gx_video.c +++ b/source/gx/gx_video.c @@ -368,7 +368,7 @@ static void vi_callback(u32 cnt) prevtime = current; #endif - video_sync = 1; + video_sync = 0; } /* Vertex Rendering */ @@ -460,7 +460,7 @@ static void gxResetRendering(u8 type) } /* Reset GX rendering mode */ -static void gxResetMode(GXRModeObj *tvmode) +static void gxResetMode(GXRModeObj *tvmode, int vfilter_enabled) { Mtx44 p; f32 yScale = GX_GetYScaleFactor(tvmode->efbHeight, tvmode->xfbHeight); @@ -472,7 +472,7 @@ static void gxResetMode(GXRModeObj *tvmode) GX_SetScissor(0, 0, tvmode->fbWidth, tvmode->efbHeight); GX_SetDispCopySrc(0, 0, tvmode->fbWidth, tvmode->efbHeight); GX_SetDispCopyDst(xfbWidth, xfbHeight); - GX_SetCopyFilter(tvmode->aa, tvmode->sample_pattern, (tvmode->xfbMode == VI_XFBMODE_SF) ? GX_FALSE : GX_TRUE, tvmode->vfilter); + GX_SetCopyFilter(tvmode->aa, tvmode->sample_pattern, (tvmode->xfbMode == VI_XFBMODE_SF) ? GX_FALSE : vfilter_enabled, tvmode->vfilter); GX_SetFieldMode(tvmode->field_rendering, ((tvmode->viHeight == 2 * tvmode->xfbHeight) ? GX_ENABLE : GX_DISABLE)); guOrtho(p, tvmode->efbHeight/2, -(tvmode->efbHeight/2), -(tvmode->fbWidth/2), tvmode->fbWidth/2, 100, 1000); GX_LoadProjectionMtx(p, GX_ORTHOGRAPHIC); @@ -666,6 +666,9 @@ static void gxDrawCrosshair(gx_texture *texture, int x, int y) int w = (texture->width * rmode->fbWidth) / (rmode->viWidth); int h = (texture->height * rmode->efbHeight) / (rmode->viHeight); + /* Aspect correction for widescreen TV */ + if (config.aspect & 2) w = (w * 3) / 4; + /* EFB scale & shift */ int xwidth = square[3] - square[9]; int ywidth = square[4] - square[10]; @@ -718,15 +721,18 @@ static void gxDrawCdLeds(gx_texture *texture_l, gx_texture *texture_r) { /* adjust texture dimensions to XFB->VI scaling */ int w = (texture_l->width * rmode->fbWidth) / (rmode->viWidth); - int h = (texture_r->height * rmode->efbHeight) / (rmode->viHeight); + int h = (texture_l->height * rmode->efbHeight) / (rmode->viHeight); + + /* Aspect correction for widescreen TV */ + if (config.aspect & 2) w = (w * 3) / 4; /* EFB scale & shift */ int xwidth = square[3] - square[9]; int ywidth = square[4] - square[10]; /* adjust texture coordinates to EFB */ - int xl = (((bitmap.viewport.x + 4) * xwidth) / (bitmap.viewport.w + 2*bitmap.viewport.x)) + square[9]; - int xr = xwidth - xl + 2*square[9] - w; + int xl = ((bitmap.viewport.x * xwidth) / vwidth) + square[9] + 8; + int xr = (((bitmap.viewport.x + bitmap.viewport.w) * xwidth) / vwidth) + square[9] - 8 - w; int y = (((bitmap.viewport.y + bitmap.viewport.h - 4) * ywidth) / vheight) + square[10] - h; /* reset GX rendering */ @@ -1466,7 +1472,7 @@ void gx_video_Stop(void) /* GX menu rendering */ gxResetRendering(1); - gxResetMode(vmode); + gxResetMode(vmode, GX_TRUE); /* render game snapshot */ gxClearScreen((GXColor)BLACK); @@ -1625,15 +1631,16 @@ void gx_video_Start(void) gxResetRendering(0); /* resynchronize emulation with VSYNC */ + video_sync = 0; VIDEO_WaitVSync(); } /* GX render update */ int gx_video_Update(void) { - if (!video_sync && config.vsync && (gc_pal == vdp_pal)) return NO_SYNC; + if (video_sync) return NO_SYNC; - video_sync = 0; + video_sync = config.vsync && (gc_pal == vdp_pal); /* check if display has changed during frame */ if (bitmap.viewport.changed & 1) @@ -1684,7 +1691,7 @@ int gx_video_Update(void) gxResetScaler(vwidth); /* update GX rendering mode */ - gxResetMode(rmode); + gxResetMode(rmode, config.vfilter); /* update VI mode */ VIDEO_Configure(rmode); @@ -1829,7 +1836,7 @@ void gx_video_Init(void) /* Initialize GX */ gxStart(); gxResetRendering(1); - gxResetMode(vmode); + gxResetMode(vmode, GX_TRUE); /* initialize FONT */ FONT_Init(); diff --git a/source/system.c b/source/system.c index bc7b45d..fac388d 100644 --- a/source/system.c +++ b/source/system.c @@ -53,7 +53,7 @@ int16 SVP_cycles = 800; static uint8 pause_b; static EQSTATE eq; -static int32 llp,rrp; +static int16 llp,rrp; /******************************************************************************************/ /* Audio subsystem */ @@ -239,46 +239,47 @@ int audio_update(int16 *buffer) /* Audio filtering */ if (config.filter) { - int32 i, l, r; + int samples = size; + int16 *out = buffer; + int32 l, r; if (config.filter & 1) { /* single-pole low-pass filter (6 dB/octave) */ - uint32 factora = (config.lp_range << 16) / 100; + uint32 factora = config.lp_range; uint32 factorb = 0x10000 - factora; - int32 ll = llp; - int32 rr = rrp; - for (i = 0; i < size; i ++) + /* restore previous sample */ + l = llp; + r = rrp; + + do { /* apply low-pass filter */ - ll = (ll>>16)*factora + buffer[0]*factorb; - rr = (rr>>16)*factora + buffer[1]*factorb; - l = ll >> 16; - r = rr >> 16; + l = l*factora + out[0]*factorb; + r = r*factora + out[1]*factorb; - /* clipping (16-bit samples) */ - if (l > 32767) l = 32767; - else if (l < -32768) l = -32768; - if (r > 32767) r = 32767; - else if (r < -32768) r = -32768; + /* 16.16 fixed point */ + l >>= 16; + r >>= 16; /* update sound buffer */ - *buffer++ = l; - *buffer++ = r; + *out++ = l; + *out++ = r; } + while (--samples); /* save last samples for next frame */ - llp = ll; - rrp = rr; + llp = l; + rrp = r; } else if (config.filter & 2) { - for (i = 0; i < size; i ++) + do { /* 3 Band EQ */ - l = do_3band(&eq,buffer[0]); - r = do_3band(&eq,buffer[1]); + l = do_3band(&eq,out[0]); + r = do_3band(&eq,out[1]); /* clipping (16-bit samples) */ if (l > 32767) l = 32767; @@ -287,12 +288,27 @@ int audio_update(int16 *buffer) else if (r < -32768) r = -32768; /* update sound buffer */ - *buffer++ = l; - *buffer++ = r; + *out++ = l; + *out++ = r; } + while (--samples); } } + /* Mono output mixing */ + if (config.mono) + { + int16 out; + int samples = size; + do + { + out = (buffer[0] + buffer[1]) / 2; + *buffer++ = out; + *buffer++ = out; + } + while (--samples); + } + #ifdef LOGSOUND error("%d samples returned\n\n",size); #endif diff --git a/source/win/config.c b/source/win/config.c index 812dfcf..408cac5 100644 --- a/source/win/config.c +++ b/source/win/config.c @@ -13,15 +13,16 @@ void set_config_defaults(void) config.fm_preamp = 100; config.hq_fm = 1; config.psgBoostNoise = 1; - config.filter = 0; + config.filter = 1; config.low_freq = 200; config.high_freq = 8000; config.lg = 1.0; config.mg = 1.0; config.hg = 1.0; - config.lp_range = 60; + config.lp_range = 0x9999; /* 0.6 in 16.16 fixed point */ config.dac_bits = 14; config.ym2413 = 2; /* = AUTO (0 = always OFF, 1 = always ON) */ + config.mono = 0; /* system options */ config.system = 0; /* = AUTO (or SYSTEM_SG, SYSTEM_MARKIII, SYSTEM_SMS, SYSTEM_SMS2, SYSTEM_GG, SYSTEM_MD) */ diff --git a/source/win/config.h b/source/win/config.h index 22ed43c..457a46d 100644 --- a/source/win/config.h +++ b/source/win/config.h @@ -20,19 +20,19 @@ typedef struct uint8 ym2413; int16 psg_preamp; int16 fm_preamp; - int16 lp_range; + uint32 lp_range; int16 low_freq; int16 high_freq; int16 lg; int16 mg; int16 hg; + uint8 mono; uint8 system; uint8 region_detect; uint8 vdp_mode; uint8 master_clock; uint8 force_dtack; uint8 addr_error; - uint8 tmss; uint8 bios; uint8 lock_on; uint8 hot_swap;