fixed audio buffer allocation, added icon for SDL/win32 version

This commit is contained in:
ekeeke31 2008-08-25 19:38:03 +00:00
parent 63ca498fc9
commit 189157a408
16 changed files with 139 additions and 115 deletions

View File

@ -17,9 +17,9 @@ include $(DEVKITPPC)/gamecube_rules
#---------------------------------------------------------------------------------
TARGET := genplus_cube
BUILD := build_cube
SOURCES := source source/m68k source/cpu source/sound source/cart_hw \
SOURCES := source source/m68k source/z80 source/sound source/cart_hw \
source/cart_hw/svp source/ngc source/ngc/gui source/sound/SRC
INCLUDES := source source/m68k source/cpu source/sound source/cart_hw \
INCLUDES := source source/m68k source/z80 source/sound source/cart_hw \
source/cart_hw/svp source/ngc source/ngc/gui source/sound/SRC
#---------------------------------------------------------------------------------

View File

@ -17,9 +17,9 @@ include $(DEVKITPPC)/wii_rules
#---------------------------------------------------------------------------------
TARGET := genplus_wii
BUILD := build_wii
SOURCES := source source/m68k source/cpu source/sound source/cart_hw\
SOURCES := source source/m68k source/z80 source/sound source/cart_hw\
source/cart_hw/svp source/ngc source/ngc/gui source/sound/SRC
INCLUDES := source source/m68k source/cpu source/sound source/cart_hw\
INCLUDES := source source/m68k source/z80 source/sound source/cart_hw\
source/cart_hw/svp source/ngc source/ngc/gui source/sound/SRC
#---------------------------------------------------------------------------------

View File

@ -5,30 +5,28 @@ current:
---------
[Genesis]
(MAME YM2612) fixed LFO phase update for CH3 special mode: fix sound effects in Warlock & Aladdin (thanks to AamirM)
(MAME YM2612) fixed enveloppe attenuation level on "KEY ON": fix Ecco 2's splash sound
(MAME YM2612) minor fixes on SSG-EG emulation
(MAME YM2612) added libsamplerate (Secret Rabbit Code) support for better FM resampling (HQ mode)
(VDP) implemented cycle-accurate HINT timings: every timing sensitive games/demos are now *finally* working fine
(VDP) fixed a bug affecting CRAM/VSRAM DMA timings
(VDP) fixed Sprite Attribute Table address mask for VRAM writes
(CPU) improved accuracy of 68k access to Z80: fix music in Pacman 2 when entering PAUSE menu
(CPU) disabled "Address Error" emulation when UMK3 hack is loaded: fix game crashing after a round ends up
(CART) added support for some more unlicensed games: Pocket Monster, King of Fighter 98, Soul Blade (credits to Haze)
(IO) improved Menacer emulation: fix lightgun support in Body Count & T2: The Arcade Game
(IO) implemented Konami Justifier emulation: fix lightgun support in Lethal Enforcers 1 & 2
(IO) implemented Sega Mouse emulation (Populous 2, Body Count, Shangai 2, Fun'n Games, ...)
[Wii only]
- added lightgun & mouse support through Wiimote IR
- added DVD support thanks to libDI (no modchip required)
- YM2612(MAME): fixed LFO phase update for CH3 special mode: fix sound effects in Warlock & Aladdin (thanks to AamirM)
- YM2612(MAME): fixed EG attenuation level on "KEY ON": fix Ecco 2's splash sound
- YM2612(MAME): fixed SSG-EG emulation: fix Bubba'n Stix (Track 5) and many others
- YM2612(MAME): replaced sample interpolation with libsamplerate support, High Quality mode is now more accurate
- implemented cycle-accurate HINT timings: every timing sensitive games/demos are now *finally* working fine
- fixed a bug affecting CRAM/VSRAM DMA timings
- fixed Sprite Attribute Table address mask for VRAM writes
- improved accuracy of 68k access to Z80: fix music in Pacman 2 when entering PAUSE menu
- disabled "Address Error" emulation when UMK3 hack is loaded: fix game crashing after a round ends up
- added support for some more unlicensed games: Pocket Monster, King of Fighter 98, Soul Blade (credits to Haze)
- improved Menacer emulation: fix lightgun support in Body Count & T2: The Arcade Game
- added Konami Justifier emulation: fix lightgun support in Lethal Enforcers 1 & 2
- added Sega Mouse emulation (Populous 2, Body Count, Shangai 2, Fun'n Games, ...)
[NGC/Wii]
- added Wiimote support for Menacer/Justifier/Mouse
- added DVD support in Wii mode (no modchip required)
- added "Gun cursor" option to enable/disable gun position display
- added "Invert Mouse" option to invert Sega Mouse vertical axe (required by some games)
- improved Controller options: Wiimote/Nunchuk and Classical Controllers can now be affected separately to ANY player
- faster zipped ROM loading from SDCARD
- reduced binaries size using Dollz3
16/07/2008:

View File

@ -14,7 +14,6 @@ typedef struct
uint8 boost;
uint8 filter;
uint8 hq_fm;
uint8 filter;
uint8 fm_core;
int8 sram_auto;
int8 freeze_auto;

View File

@ -1122,6 +1122,8 @@ void MainMenu ()
case 6: /*** SD/PSO/TP Reload ***/
memfile_autosave();
system_shutdown();
audio_shutdown();
VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK);
VIDEO_Flush();
VIDEO_WaitVSync();
@ -1133,6 +1135,8 @@ void MainMenu ()
case 7: /*** Return to Wii System Menu ***/
memfile_autosave();
system_shutdown();
audio_shutdown();
VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK);
VIDEO_Flush();
VIDEO_WaitVSync();

View File

@ -144,8 +144,8 @@
#define TL_RES_LEN (256) /* 8 bits addressing (real chip) */
#define MAXOUT (+32767)
#define MINOUT (-32768)
#define MAXOUT (+16383)
#define MINOUT (-16384)
/* TL_TAB_LEN is calculated as:
@ -263,15 +263,10 @@ O(16),O(16),O(16),O(16),O(16),O(16),O(16),O(16)
#define O(a) (a*1)
static const UINT8 eg_rate_shift[32+64+32]={ /* Envelope Generator counter shifts (32 + 64 rates + 32 RKS) */
/* 32 infinite time rates */
/*O(0),O(0),O(0),O(0),O(0),O(0),O(0),O(0),
O(0),O(0),O(0),O(0),O(0),O(0),O(0),O(0),
O(0),O(0),O(0),O(0),O(0),O(0),O(0),O(0),
O(0),O(0),O(0),O(0),O(0),O(0),O(0),O(0),*/
O(11),O(11),O(11),O(11),O(11),O(11),O(11),O(11),
O(11),O(11),O(11),O(11),O(11),O(11),O(11),O(11),
O(11),O(11),O(11),O(11),O(11),O(11),O(11),O(11),
O(11),O(11),O(11),O(11),O(11),O(11),O(11),O(11),
O(0),O(0),O(0),O(0),O(0),O(0),O(0),O(0),
O(0),O(0),O(0),O(0),O(0),O(0),O(0),O(0),
/* rates 00-11 */
O(11),O(11),O(11),O(11),
@ -652,8 +647,9 @@ INLINE void set_timers(int v )
INLINE void FM_KEYON(FM_CH *CH , int s )
{
FM_SLOT *SLOT = &CH->SLOT[s];
if(SLOT->state <= EG_REL)
if( !SLOT->key )
{
SLOT->key = 1;
SLOT->phase = 0; /* restart Phase Generator */
SLOT->ssgn = (SLOT->ssg & 0x04) >> 1;
@ -664,9 +660,9 @@ INLINE void FM_KEYON(FM_CH *CH , int s )
}
else
{
/* Attack Rate is maximal: directly switch to Decay */
SLOT->state = EG_DEC;
/* directly switch to Decay */
SLOT->volume = MIN_ATT_INDEX;
SLOT->state = EG_DEC;
}
}
}
@ -674,12 +670,15 @@ INLINE void FM_KEYON(FM_CH *CH , int s )
INLINE void FM_KEYOFF(FM_CH *CH , int s )
{
FM_SLOT *SLOT = &CH->SLOT[s];
if( SLOT->key )
{
SLOT->key = 0;
if (SLOT->state>EG_REL)
{
SLOT->state = EG_REL; /* phase -> Release */
SLOT->ssgn = 0; /* reset Invert Flag (from Nemesis) */
}
}
}
/* set algorithm connection */
@ -812,7 +811,7 @@ INLINE void set_ar_ksr(FM_CH *CH,FM_SLOT *SLOT,int v)
/* set decay rate */
INLINE void set_dr(FM_SLOT *SLOT,int v)
{
SLOT->d1r = (v&0x1f) ? (32 + ((v&0x1f)<<1)) : 0;
SLOT->d1r = (v&0x1f) ? 32 + ((v&0x1f)<<1) : 0;
SLOT->eg_sh_d1r = eg_rate_shift [SLOT->d1r + SLOT->ksr];
SLOT->eg_sel_d1r= eg_rate_select[SLOT->d1r + SLOT->ksr];
@ -822,7 +821,7 @@ INLINE void set_dr(FM_SLOT *SLOT,int v)
/* set sustain rate */
INLINE void set_sr(FM_SLOT *SLOT,int v)
{
SLOT->d2r = (v&0x1f) ? (32 + ((v&0x1f)<<1)) : 0;
SLOT->d2r = (v&0x1f) ? 32 + ((v&0x1f)<<1) : 0;
SLOT->eg_sh_d2r = eg_rate_shift [SLOT->d2r + SLOT->ksr];
SLOT->eg_sel_d2r= eg_rate_select[SLOT->d2r + SLOT->ksr];
@ -1713,7 +1712,7 @@ static void OPNWriteReg(int r, int v)
int feedback = (v>>3)&7;
CH->ALGO = v&7;
CH->FB = feedback ? feedback+6 : 0;
setup_connection( CH, c );
setup_connection( CH, c );
}
break;
case 1: /* 0xb4-0xb6 : L , R , AMS , PMS (ym2612/YM2610B/YM2610/YM2608) */
@ -1895,7 +1894,7 @@ int YM2612Write(unsigned char a, unsigned char v)
{
int addr;
//v &= 0xff; /* adjust to 8 bit bus */
v &= 0xff; /* adjust to 8 bit bus */
switch( a&3 )
{

View File

@ -30,17 +30,17 @@ int (*_YM2612_Read)(void);
void (*_YM2612_Update)(int **buf, int length);
int (*_YM2612_Reset)(void);
/* cycle-accurate samples */
static double m68cycles_per_sample[2];
static double z80cycles_per_sample[2];
/* libsamplerate buffers */
static float fm_buffer_48kHz[1000*2];
static float fm_buffer_53kHz[1061*2];
static int fm_buffer[2][1061];
static SRC_DATA data;
/* libsamplerate buffers (max. is 488 cycles per line x 313 lines / 144) */
static SRC_DATA src_data;
static float src_in[1061*2];
static int src_buffer[2][1061];
/* YM2612 data */
int fm_reg[2][0x100]; /* Register arrays (2x256) */
/* YM2612 register arrays */
int fm_reg[2][0x100];
/* return the number of samples that should have been rendered so far */
static inline uint32 fm_sample_cnt(uint8 is_z80)
@ -64,8 +64,8 @@ static inline void fm_update()
if (config.hq_fm && !config.fm_core)
{
tempBuffer[0] = fm_buffer[0] + snd.fm.lastStage;
tempBuffer[1] = fm_buffer[1] + snd.fm.lastStage;
tempBuffer[0] = src_buffer[0] + snd.fm.lastStage;
tempBuffer[1] = src_buffer[1] + snd.fm.lastStage;
}
else
{
@ -101,11 +101,11 @@ void sound_init(int rate)
z80cycles_per_sample[0] = (144.0 * 7.0) / 15.0;
/* initialize samplerate converter data */
data.data_in = fm_buffer_53kHz;
data.data_out = fm_buffer_48kHz;
data.input_frames = vdp_pal ? 1061 : 888;
data.output_frames = 1000;
data.src_ratio = vdp_pal ? (960.0/1061.0) : (800.0/888.0);
src_data.data_in = src_in;
src_data.data_out = snd.fm.src_out;
src_data.input_frames = (int)(((double)m68cycles_per_line * (double)lines_per_frame / 144.0) + 0.5);
src_data.output_frames = rate / vdp_rate;
src_data.src_ratio = (double)src_data.output_frames / (double)src_data.input_frames;
}
else
{
@ -142,7 +142,7 @@ void sound_init(int rate)
void sound_update(void)
{
/* finalize sound buffers */
snd.fm.curStage = (config.hq_fm && !config.fm_core) ? data.input_frames : snd.buffer_size;
snd.fm.curStage = (config.hq_fm && !config.fm_core) ? src_data.input_frames : snd.buffer_size;
snd.psg.curStage = snd.buffer_size;
/* update last samples (if needed) */
@ -153,53 +153,42 @@ void sound_update(void)
if (config.hq_fm && !config.fm_core)
{
double scaled_value ;
int len = data.input_frames;
int len = src_data.input_frames;
/* this is basically libsamplerate "src_int_to_float_array" function, adapted to interlace samples */
while (len)
{
len -- ;
fm_buffer_53kHz [len*2] = (float) (fm_buffer[0] [len] / (8.0 * 0x10000000)) ;
fm_buffer_53kHz [len*2 + 1] = (float) (fm_buffer[1] [len] / (8.0 * 0x10000000)) ;
src_in[len*2] = (float) (src_buffer[0] [len] / (8.0 * 0x10000000));
src_in[len*2 + 1] = (float) (src_buffer[1] [len] / (8.0 * 0x10000000));
}
/* samplerate conversion */
src_simple (&data, 5 - config.hq_fm, 2);
src_simple (&src_data, SRC_LINEAR + 1 - config.hq_fm, 2);
/* this is basically libsamplerate "src_float_to_int_array" function, adapted to interlace samples */
len = vdp_pal ? 960 : 800;
len = snd.buffer_size;
while (len)
{
len -- ;
scaled_value = fm_buffer_48kHz [len*2] * (8.0 * 0x10000000);
if (scaled_value >= (1.0 * 0x7FFFFFFF))
{
snd.fm.buffer[0][len] = 0x7fffffff;
}
else if (scaled_value <= (-8.0 * 0x10000000))
{
snd.fm.buffer[0][len] = -1 - 0x7fffffff;
}
else
{
snd.fm.buffer[0][len] = (long)scaled_value;
}
scaled_value = fm_buffer_48kHz [len*2+1] * (8.0 * 0x10000000);
scaled_value = snd.fm.src_out[len*2] * (8.0 * 0x10000000);
if (scaled_value >= (1.0 * 0x7FFFFFFF))
{
snd.fm.buffer[1][len] = 0x7fffffff;
}
snd.fm.buffer[0][len] = 0x7fffffff;
else if (scaled_value <= (-8.0 * 0x10000000))
{
snd.fm.buffer[1][len] = -1 - 0x7fffffff;
}
snd.fm.buffer[0][len] = -1 - 0x7fffffff;
else
snd.fm.buffer[0][len] = (long)scaled_value;
scaled_value = snd.fm.src_out[len*2+1] * (8.0 * 0x10000000);
if (scaled_value >= (1.0 * 0x7FFFFFFF))
snd.fm.buffer[1][len] = 0x7fffffff;
else if (scaled_value <= (-8.0 * 0x10000000))
snd.fm.buffer[1][len] = -1 - 0x7fffffff;
else
{
snd.fm.buffer[1][len] = (long)scaled_value;
}
}
}
/* reset samples count */
snd.fm.curStage = 0;

View File

@ -47,9 +47,6 @@ uint8 interlaced;
uint32 frame_cnt;
uint8 system_hw;
/* Function prototypes */
static void audio_update (void);
/****************************************************************
* CPU execution managment
****************************************************************/
@ -304,23 +301,44 @@ int system_frame (int do_skip)
****************************************************************/
int audio_init (int rate)
{
/* Shutdown first */
audio_shutdown();
/* Clear the sound data context */
memset (&snd, 0, sizeof (snd));
/* Make sure the requested sample rate is valid */
if (!rate || ((rate < 8000) | (rate > 48000))) return (0);
if (!rate || ((rate < 8000) | (rate > 48000))) return (-1);
snd.sample_rate = rate;
/* Calculate the sound buffer size (for one frame) */
snd.buffer_size = (rate / vdp_rate);
/* (re)allocate sound buffers */
snd.fm.buffer[0] = realloc (snd.fm.buffer[0], snd.buffer_size * sizeof (int));
snd.fm.buffer[1] = realloc (snd.fm.buffer[1], snd.buffer_size * sizeof (int));
#ifndef NGC
/* output buffers */
snd.buffer[0] = (int16 *) malloc(SND_SIZE);
snd.buffer[1] = (int16 *) malloc(SND_SIZE);
if (!snd.buffer[0] || !snd.buffer[1]) return (-1);
memset (snd.buffer[0], 0, SND_SIZE);
memset (snd.buffer[1], 0, SND_SIZE);
#endif
/* YM2612 stream buffers */
snd.fm.buffer[0] = (int *)malloc (SND_SIZE*2);
snd.fm.buffer[1] = (int *)malloc (SND_SIZE*2);
if (!snd.fm.buffer[0] || !snd.fm.buffer[1]) return (-1);
memset (snd.fm.buffer[0], 0, SND_SIZE*2);
memset (snd.fm.buffer[1], 0, SND_SIZE*2);
snd.psg.buffer = realloc (snd.psg.buffer, SND_SIZE);
/* SRC buffers */
if (config.hq_fm && !config.fm_core)
{
snd.fm.src_out = (float *) malloc(snd.buffer_size*2*sizeof(float));
if (!snd.fm.src_out) return (-1);
}
/* SN76489 stream buffers */
snd.psg.buffer = (int16 *)malloc (SND_SIZE);
if (!snd.psg.buffer) return (-1);
memset (snd.psg.buffer, 0, SND_SIZE);
@ -333,9 +351,20 @@ int audio_init (int rate)
return (0);
}
void audio_shutdown(void)
{
/* free sound buffers */
if (snd.buffer[0]) free(snd.buffer[0]);
if (snd.buffer[1]) free(snd.buffer[1]);
if (snd.fm.buffer[0]) free(snd.fm.buffer[0]);
if (snd.fm.buffer[1]) free(snd.fm.buffer[1]);
if (snd.fm.src_out) free(snd.fm.src_out);
if (snd.psg.buffer) free(snd.psg.buffer);
}
static int ll, rr;
static void audio_update (void)
void audio_update (void)
{
int i;
int l, r;
@ -384,7 +413,7 @@ static void audio_update (void)
#ifdef NGC
*sb++ = r; // RIGHT channel comes first
*sb++ = l;
#elif DOS
#else
snd.buffer[0][i] = l;
snd.buffer[1][i] = r;
#endif

View File

@ -61,6 +61,7 @@ typedef struct
int curStage;
int lastStage;
int *buffer[2];
float *src_out; /* SRC conversion buffer */
} fm;
struct
{
@ -95,8 +96,10 @@ extern void system_init (void);
extern void system_reset (void);
extern void system_shutdown (void);
extern int system_frame(int skip);
extern void z80_run (int cyc);
extern int audio_init (int rate);
extern void audio_shutdown (void);
extern void audio_update (void);
extern void z80_run (int cyc);
#endif /* _SYSTEM_H_ */

View File

@ -3,20 +3,20 @@ Genesis Plus History
Note: All recent changes directly come from the Gamecube/Wii port, coded by Eke-Eke.
[current]
- (MAME YM2612) fixed LFO phase update for CH3 special mode: fix sound effects in Warlock & Aladdin (thanks to AamirM)
- (MAME YM2612) fixed enveloppe attenuation level on "KEY ON": fix Ecco 2's splash sound
- (MAME YM2612) minor fixes on SSG-EG emulation
- (MAME YM2612) added libsamplerate (Secret Rabbit Code) support for better FM resampling (HQ mode)
- (VDP) implemented cycle-accurate HINT timings: every timing sensitive games/demos are now *finally* working fine
- (VDP) fixed a bug affecting CRAM/VSRAM DMA timings
- (VDP) fixed Sprite Attribute Table address mask for VRAM writes
- (CPU) improved accuracy of 68k access to Z80: fix music in Pacman 2 when entering PAUSE menu
- (CPU) disabled "Address Error" emulation when UMK3 hack is loaded: fix game crashing after a round ends up
- (CART) added support for some more unlicensed games: Pocket Monster, King of Fighter 98, Soul Blade (credits to Haze)
- (IO) improved Menacer emulation: fix lightgun support in Body Count & T2: The Arcade Game
- (IO) implemented Konami Justifier emulation: fix lightgun support in Lethal Enforcers 1 & 2
- (IO) implemented Sega Mouse emulation (Populous 2, Body Count, Shangai 2, Fun'n Games, ...)
[Current] (Eke-Eke)
- YM2612(MAME): fixed LFO phase update for CH3 special mode: fix sound effects in Warlock & Aladdin (thanks to AamirM)
- YM2612(MAME): fixed EG attenuation level on "KEY ON": fix Ecco 2's splash sound
- YM2612(MAME): fixed SSG-EG emulation: fix Bubba'n Stix (Track 5) and many others
- YM2612(MAME): replaced sample interpolation with libsamplerate support, High Quality mode is now more accurate
- implemented cycle-accurate HINT timings: every timing sensitive games/demos are now *finally* working fine
- fixed a bug affecting CRAM/VSRAM DMA timings
- fixed Sprite Attribute Table address mask for VRAM writes
- improved accuracy of 68k access to Z80: fix music in Pacman 2 when entering PAUSE menu
- disabled "Address Error" emulation when UMK3 hack is loaded: fix game crashing after a round ends up
- added support for some more unlicensed games: Pocket Monster, King of Fighter 98, Soul Blade (credits to Haze)
- improved Menacer emulation: fix lightgun support in Body Count & T2: The Arcade Game
- added Konami Justifier emulation: fix lightgun support in Lethal Enforcers 1 & 2
- added Sega Mouse emulation (Populous 2, Body Count, Shangai 2, Fun'n Games, ...)
[07/16/08] (Eke-Eke)
- adjusted (again) HINT timings: fix Double Dragon 2 (game freezed), hopefully does not break anything else

View File

@ -103,17 +103,11 @@ void set_config_defaults(void)
config.fm_core = 0;
/* system options */
config.freeze_auto = -1;
config.sram_auto = -1;
config.region_detect = 0;
config.force_dtack = 0;
config.bios_enabled = 0;
/* display options */
config.xshift = 0;
config.yshift = 0;
config.xscale = 0;
config.yscale = 0;
config.aspect = 1;
config.overscan = 1;
config.render = 0;

View File

@ -11,7 +11,9 @@ struct {
void error_init(void)
{
#ifdef LOG_ERROR
error_log = fopen("error.log","w");
#endif
}
void error_shutdown(void)

View File

@ -58,6 +58,7 @@ OBJECTS += obj/main.o \
obj/fileio.o \
obj/loadrom.o
OBJECTS += obj/icon.o
all: $(NAME)
@ -97,6 +98,9 @@ obj/%.o : ../m68k/%.c ../m68k/%.h
obj/%.o : ./%.c ./%.h
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
obj/icon.o :
windres icon.rc $@
pack :
strip $(NAME)
upx -9 $(NAME)

View File

@ -15,7 +15,9 @@ struct {
void error_init(void)
{
#ifdef LOG_ERROR
error_log = fopen("error.log","w");
#endif
}
void error_shutdown(void)

View File

@ -0,0 +1 @@
MAINICON ICON "md.ico"

BIN
source/unused/win/md.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB