From 41ffdefb1db0f6939f83aac048ad9752cd96815b Mon Sep 17 00:00:00 2001 From: ekeeke31 Date: Sun, 12 Oct 2008 19:56:35 +0000 Subject: [PATCH] various modifications --- history.txt | 14 ++++++++++---- source/ngc/config.c | 6 ++++-- source/ngc/config.h | 1 + source/ngc/gui/menu.c | 9 ++++++--- source/ngc/history.c | 2 ++ source/ngc/memfile.c | 2 ++ source/ngc/ngc.c | 3 ++- source/render.c | 8 ++++---- source/sound/sound.c | 9 ++++++--- source/system.c | 25 ++++++++++++------------- source/system.h | 7 ++++--- source/vdp.c | 4 ++-- 12 files changed, 55 insertions(+), 35 deletions(-) diff --git a/history.txt b/history.txt index 2f5e0bc..d916abf 100644 --- a/history.txt +++ b/history.txt @@ -10,18 +10,24 @@ CURRENT: - YM2612(MAME): improved Detune overflow accuracy, fix very high frequency sounds in many games - YM2612(MAME): fixed registers 0x20-0x26 Reset state, fix intro music in "B.O.B" - YM2612(MAME): removed previous fix with KEY ON, fix "Flamethrower" sound effect in "Alien 3" -- adjusted HCounter values, fix line flickering in "Sonic 3D" bonus stage -- re-enabled Z80 banked access to WRAM, fix hang-up in "Mamono Hunter Youko" -- modified JCART emulation, fix corrupted tracks logo in "Micro Machines 2" +- adjusted HCounter values, fixes line flickering in "Sonic 3D" bonus stage +- adjusted VINT timing, fixes hang-up in "V.R Troopers" +- improved HBLANK flag accuracy, fixes line flickering in "Gouketsuji Ichizoku" +- re-enabled Z80 banked access to WRAM, fixes hang-up in "Mamono Hunter Youko" +- modified JCART emulation, fixes corrupted tracks logo in "Micro Machines 2" [NGC/Wii] -- now use fixed libsamplerate setting in "HQ YM2612" mode +- remove unused libsamplerate settings in "HQ YM2612" mode - implemented menu fast scrolling with the Wiimote D-PAD - fixed config file incompatibilities between Gamecube and Wii versions - re-enabled texture filtering in H40 original mode when overscan is emulated: fix screen scroll tearing - added Shay Green's NTSC Filters support + +[NGC] - added proper 480p menu detection for NTSC Gamecube users +- now prevents FAT automatic operations if no SDCARD is inserted + 26/08/2008: diff --git a/source/ngc/config.c b/source/ngc/config.c index f9b60db..3bc161a 100644 --- a/source/ngc/config.c +++ b/source/ngc/config.c @@ -7,9 +7,12 @@ #define CONFIG_VERSION "GENPLUS 1.2.6 " t_config config; +bool use_FAT; void config_save() { + if (!use_FAT) return; + /* first check if directory exist */ DIR_ITER *dir = diropen("/genplus"); if (dir == NULL) mkdir("/genplus",S_IRWXU); @@ -27,13 +30,12 @@ void config_save() void config_load() { - char version[15]; - /* open file for writing */ FILE *fp = fopen("/genplus/genplus.ini", "rb"); if (fp == NULL) return; /* read version */ + char version[15]; fread(version, 15, 1, fp); fclose(fp); if (strcmp(version,CONFIG_VERSION)) return; diff --git a/source/ngc/config.h b/source/ngc/config.h index d1edac5..cdf8a36 100644 --- a/source/ngc/config.h +++ b/source/ngc/config.h @@ -41,6 +41,7 @@ extern t_config config; extern void config_save(); extern void config_load(); extern void set_config_defaults(void); +extern bool use_FAT; #endif /* _CONFIG_H_ */ diff --git a/source/ngc/gui/menu.c b/source/ngc/gui/menu.c index 570e15e..82e938f 100644 --- a/source/ngc/gui/menu.c +++ b/source/ngc/gui/menu.c @@ -146,7 +146,9 @@ void soundmenu () sprintf (items[1], "FM Volume: %1.2f", config.fm_preamp); sprintf (items[2], "Volume Boost: %dX", config.boost); sprintf (items[3], "LowPass Filter: %s", config.filter ? " ON":"OFF"); - sprintf (items[4], "HQ YM2612: %s", config.hq_fm ? " ON":"OFF"); + if (config.hq_fm == 0) sprintf (items[4], "HQ YM2612: OFF"); + else if ((config.hq_fm == 1) || config.fm_core) sprintf (items[4], "HQ YM2612: LINEAR"); + else sprintf (items[4], "HQ YM2612: SINC"); sprintf (items[5], "FM core: %s", config.fm_core ? "GENS" : "MAME"); ret = domenu (&items[0], count, 1); @@ -178,7 +180,8 @@ void soundmenu () break; case 4: - config.hq_fm ^= 1; + config.hq_fm ++; + if ((config.hq_fm>2)||(config.fm_core && (config.hq_fm>1))) config.hq_fm = 0; if (genromsize) { audio_init(48000); @@ -328,7 +331,7 @@ void dispmenu () if (config.tv_mode == 0) sprintf (items[2], "TV Mode: 60HZ"); else if (config.tv_mode == 1) sprintf (items[2], "TV Mode: 50HZ"); else sprintf (items[2], "TV Mode: 50/60HZ"); - sprintf (items[3], "Texture Filter: %s", config.filtering ? " ON" : "OFF"); + sprintf (items[3], "GX Filter: %s", config.filtering ? " ON" : "OFF"); if (config.ntsc == 1) sprintf (items[4], "NTSC Filter: COMPOSITE"); else if (config.ntsc == 2) sprintf (items[4], "NTSC Filter: S-VIDEO"); else if (config.ntsc == 3) sprintf (items[4], "NTSC Filter: RGB"); diff --git a/source/ngc/history.c b/source/ngc/history.c index bb5739e..5a54f32 100644 --- a/source/ngc/history.c +++ b/source/ngc/history.c @@ -15,6 +15,8 @@ t_history history; void history_save() { + if (!use_FAT) return; + /* first check if directory exist */ DIR_ITER *dir = diropen("/genplus"); if (dir == NULL) mkdir("/genplus",S_IRWXU); diff --git a/source/ngc/memfile.c b/source/ngc/memfile.c index 8cdc0c2..c547577 100644 --- a/source/ngc/memfile.c +++ b/source/ngc/memfile.c @@ -85,6 +85,8 @@ static int SD_ManageFile(char *filename, int direction, int filetype) int done = 0; int filesize; + if (!use_FAT) return 0; + /* first check if directory exist */ DIR_ITER *dir = diropen("/genplus/saves"); if (dir == NULL) mkdir("/genplus/saves",S_IRWXU); diff --git a/source/ngc/ngc.c b/source/ngc/ngc.c index 543d4bc..a8f51f9 100644 --- a/source/ngc/ngc.c +++ b/source/ngc/ngc.c @@ -125,7 +125,8 @@ int main (int argc, char *argv[]) #endif /* Initialize SDCARD Interface (LibFAT) */ - fatInitDefault(); + use_FAT = 0; + if (fatInitDefault() == true) use_FAT = 1; /* Restore User Configuration */ set_config_defaults(); diff --git a/source/render.c b/source/render.c index 4e37171..c4816f9 100644 --- a/source/render.c +++ b/source/render.c @@ -647,7 +647,7 @@ void render_line(int line, uint8 odd_frame) /* vertical borders or display OFF */ if ((line >= bitmap.viewport.h) || (!(reg[1] & 0x40))) { - memset(&lb[0x20], 0x40 | border, width); + memset(&lb[0x20], 0x40, width); } else { @@ -693,14 +693,14 @@ void render_line(int line, uint8 odd_frame) } /* Mode 4 feature only (unemulated, no games rely on this) */ - /*if(!(reg[1] & 0x04) && (reg[0] & 0x20)) memset(&lb[0x20], 0x40 | border, 0x08);*/ + /*if(!(reg[1] & 0x04) && (reg[0] & 0x20)) memset(&lb[0x20], 0x40, 0x08);*/ } /* horizontal borders */ if (config.overscan) { - memset(&lb[0x20 - bitmap.viewport.x], 0x40 | border, bitmap.viewport.x); - memset(&lb[0x20 + bitmap.viewport.w], 0x40 | border, bitmap.viewport.x); + memset(&lb[0x20 - bitmap.viewport.x], 0x40, bitmap.viewport.x); + memset(&lb[0x20 + bitmap.viewport.w], 0x40, bitmap.viewport.x); width += 2 * bitmap.viewport.x; } diff --git a/source/sound/sound.c b/source/sound/sound.c index 3e7e709..b6a219c 100644 --- a/source/sound/sound.c +++ b/source/sound/sound.c @@ -24,6 +24,9 @@ #include "shared.h" #include "samplerate.h" +#define CLOCK_NTSC 53693175 +#define CLOCK_PAL 53203424 + /* generic functions */ int (*_YM2612_Write)(unsigned char adr, unsigned char data); int (*_YM2612_Read)(void); @@ -91,8 +94,8 @@ static inline void psg_update() void sound_init(int rate) { - double vclk = Master_Clock / 7.0; /* 68000 and YM2612 clock */ - double zclk = Master_Clock / 15.0; /* Z80 and SN76489 clock */ + double vclk = (vdp_pal ? (double)CLOCK_PAL : (double)CLOCK_NTSC) / 7.0; /* 68000 and YM2612 clock */ + double zclk = (vdp_pal ? (double)CLOCK_PAL : (double)CLOCK_NTSC) / 15.0; /* Z80 and SN76489 clock */ /* cycle-accurate FM samples */ if (config.hq_fm && !config.fm_core) @@ -164,7 +167,7 @@ void sound_update(void) } /* samplerate conversion */ - src_simple (&src_data, svp ? SRC_LINEAR : SRC_SINC_FASTEST, 2); + src_simple (&src_data, (config.hq_fm&1) ? SRC_LINEAR : SRC_SINC_FASTEST, 2); /* this is basically libsamplerate "src_float_to_int_array" function, adapted to interlace samples */ len = snd.buffer_size; diff --git a/source/system.c b/source/system.c index a46d0b4..717d644 100644 --- a/source/system.c +++ b/source/system.c @@ -33,8 +33,6 @@ t_snd snd; uint8 vdp_rate; uint16 lines_per_frame; double Master_Clock; -uint32 m68cycles_per_line; -uint32 z80cycles_per_line; uint32 aim_m68k; uint32 count_m68k; uint32 line_m68k; @@ -61,16 +59,21 @@ static inline void update_interrupts(void) uint8 latency = hvint_updated; hvint_updated = -1; + /* VDP hardware latency */ + if (latency) count_m68k += m68k_execute(latency); + + /* Level 6 interrupt */ if (vint_pending && (reg[1] & 0x20)) { vint_triggered = 1; - if (latency) count_m68k += m68k_execute(latency); m68k_set_irq(6); } + /* Level 4 interrupt */ else if (hint_pending && (reg[0] & 0x10)) { m68k_set_irq(4); } + /* Clear all interrupts */ else { m68k_set_irq(0); @@ -105,10 +108,6 @@ void system_init (void) lines_per_frame = vdp_pal ? 313 : 262; Master_Clock = vdp_pal ? (double)CLOCK_PAL : (double)CLOCK_NTSC; - /* CPU cycles increments */ - z80cycles_per_line = 228; - m68cycles_per_line = 488; - gen_init (); vdp_init (); render_init (); @@ -260,22 +259,22 @@ int system_frame (int do_skip) /* update inputs */ update_input(); - /* set VBLANK flag */ + /* set VBLANK flag (Dracula) */ status |= 0x08; /* Z80 interrupt is 16ms period (one frame) and 64us length (one scanline) */ zirq = 1; z80_set_irq_line(0, ASSERT_LINE); - /* delay between HINT, VBLANK and VINT (approx. 14.7 us) */ - m68k_run(line_m68k + 84); /* need to take upcoming latency in account (Hurricanes, Outrunners) */ - if (zreset && !zbusreq) z80_run(line_z80 + 40); - else count_z80 = line_z80 + 40; + /* delay between HINT, VBLANK and VINT (OutRunners, VR Troopers) */ + m68k_run(line_m68k + 84); + if (zreset && !zbusreq) z80_run(line_z80 + 39); + else count_z80 = line_z80 + 39; /* Vertical Interrupt */ status |= 0x80; vint_pending = 1; - hvint_updated = 30; /* Tyrants, Mega-Lo-Mania & Ex Mutant need some cycles to read VINT flag */ + hvint_updated = 36; /* Tyrants, Mega-Lo-Mania & Ex Mutant need some cycles to read VINT flag */ } else if (zirq) { diff --git a/source/system.h b/source/system.h index f937533..3276dab 100644 --- a/source/system.h +++ b/source/system.h @@ -28,6 +28,10 @@ #define SYSTEM_MEGADRIVE 1 #define SYSTEM_PICO 2 +/* CPU cycles increments */ +#define z80cycles_per_line 228 +#define m68cycles_per_line 488 + typedef struct { uint8 *data; /* Bitmap data */ @@ -75,10 +79,7 @@ typedef struct extern t_bitmap bitmap; extern t_snd snd; extern uint16 lines_per_frame; -extern double Master_Clock; extern uint8 vdp_rate; -extern uint32 m68cycles_per_line; -extern uint32 z80cycles_per_line; extern uint32 aim_m68k; extern uint32 count_m68k; extern uint32 line_m68k; diff --git a/source/vdp.c b/source/vdp.c index 4de7717..2f378e8 100644 --- a/source/vdp.c +++ b/source/vdp.c @@ -604,7 +604,7 @@ unsigned int vdp_ctrl_r(void) if (!(reg[1] & 0x40)) temp |= 0x8; /* HBLANK flag (Sonic 3 and Sonic 2 "VS Modes", Lemmings 2) */ - if (count_m68k <= line_m68k + 84) temp |= 0x4; + if ((count_m68k <= (line_m68k + 84)) || (count_m68k > (line_m68k + 488))) temp |= 0x4; /* clear pending flag */ pending = 0; @@ -766,7 +766,7 @@ void vdp_reg_w(unsigned int r, unsigned int d) color_update(0x00, *(uint16 *)&cram[(border << 1)]); /* background color modified during HBLANK */ - if ((v_counter < bitmap.viewport.h) && (count_m68k <= (line_m68k + 84))) + if (count_m68k <= (line_m68k + 84)) { /* remap current line (see Road Rash I,II,III) */ reg[7] = d;