Fixed issues with dreamcast dsf playback.

CQTexperiment
vspader 2009-03-01 11:00:46 -08:00
parent a49cd40952
commit 40c723df79
5 changed files with 30 additions and 8 deletions

View File

@ -1226,6 +1226,8 @@ void *aica_start(const void *config)
void aica_stop(void) void aica_stop(void)
{ {
free(AllocedAICA->buffertmpl);
free(AllocedAICA->buffertmpr);
free(AllocedAICA); free(AllocedAICA);
} }

View File

@ -39,13 +39,13 @@ static void aica_irq(int irq)
#define MIXER(level,pan) ((level & 0xff) | ((pan & 0x03) << 8)) #define MIXER(level,pan) ((level & 0xff) | ((pan & 0x03) << 8))
#define YM3012_VOL(LVol,LPan,RVol,RPan) (MIXER(LVol,LPan)|(MIXER(RVol,RPan) << 16)) #define YM3012_VOL(LVol,LPan,RVol,RPan) (MIXER(LVol,LPan)|(MIXER(RVol,RPan) << 16))
static struct AICAinterface aica_interface = static struct AICAinterface aica_interface =
{ {
1, 1,
{ dc_ram, }, { dc_ram, },
{ YM3012_VOL(100, MIXER_PAN_LEFT, 100, MIXER_PAN_RIGHT) }, { YM3012_VOL(100, MIXER_PAN_LEFT, 100, MIXER_PAN_RIGHT) },
{ aica_irq, }, { aica_irq, },
}; };
uint8 dc_read8(int addr) uint8 dc_read8(int addr)
{ {
@ -172,3 +172,4 @@ void dc_hw_init(void)
aica_start(&aica_interface); aica_start(&aica_interface);
} }

View File

@ -33,6 +33,7 @@ static char psfby[256];
static uint32 decaybegin, decayend, total_samples; static uint32 decaybegin, decayend, total_samples;
void *aica_start(const void *config); void *aica_start(const void *config);
void aica_stop(void);
void AICA_Update(void *param, INT16 **inputs, INT16 **buf, int samples); void AICA_Update(void *param, INT16 **inputs, INT16 **buf, int samples);
int32 dsf_start(uint8 *buffer, uint32 length) int32 dsf_start(uint8 *buffer, uint32 length)
@ -88,6 +89,7 @@ int32 dsf_start(uint8 *buffer, uint32 length)
// Dispose the corlett structure for the lib - we don't use it // Dispose the corlett structure for the lib - we don't use it
free(lib); free(lib);
free(lib_decoded);
} }
} }
@ -209,6 +211,9 @@ int32 dsf_gen(int16 *buffer, uint32 samples)
int32 dsf_stop(void) int32 dsf_stop(void)
{ {
aica_stop();
free(c);
return AO_SUCCESS; return AO_SUCCESS;
} }

View File

@ -193,6 +193,7 @@ int32 qsf_start(uint8 *buffer, uint32 length)
// Dispose the corlett structure for the lib - we don't use it // Dispose the corlett structure for the lib - we don't use it
free(lib); free(lib);
free(lib_decoded);
} }
// now patch the file into RAM OVER the libraries // now patch the file into RAM OVER the libraries
@ -305,7 +306,8 @@ int32 qsf_stop(void)
{ {
free(Z80ROM); free(Z80ROM);
free(QSamples); free(QSamples);
free(c);
return AO_SUCCESS; return AO_SUCCESS;
} }

View File

@ -103,7 +103,7 @@ int ao_get_lib(char *fn, uint8 **buf, uint64 *length)
{ {
NSMutableDictionary *dict = [NSMutableDictionary dictionary]; NSMutableDictionary *dict = [NSMutableDictionary dictionary];
for (int i =0 ; i < 8; i++) { for (int i = 1 ; i < 9; i++) {
NSString *key = [[NSString alloc] initWithUTF8String:info.title[i]]; NSString *key = [[NSString alloc] initWithUTF8String:info.title[i]];
NSString *value = [[NSString alloc] initWithUTF8String:info.info[i]]; NSString *value = [[NSString alloc] initWithUTF8String:info.info[i]];
@ -137,7 +137,7 @@ int ao_get_lib(char *fn, uint8 **buf, uint64 *length)
ao_display_info info; ao_display_info info;
if ((*types[type].fillinfo)(&info) == AO_SUCCESS) if ((*types[type].fillinfo)(&info) == AO_SUCCESS)
{ {
for (int i =0 ; i < 8; i++) { for (int i = 1 ; i < 9; i++) {
NSString *key = [[NSString alloc] initWithUTF8String:info.title[i]]; NSString *key = [[NSString alloc] initWithUTF8String:info.title[i]];
NSString *value = [[NSString alloc] initWithUTF8String:info.info[i]]; NSString *value = [[NSString alloc] initWithUTF8String:info.info[i]];
@ -247,7 +247,19 @@ int ao_get_lib(char *fn, uint8 **buf, uint64 *length)
return 0; return 0;
} }
(*types[type].gen)(buf, frames); const int maxFrames = 1470; // The Dreamcast decoder starts smashing things if you try decoding more than this
int amountRead = 0;
while (amountRead < frames) {
int requestAmount = frames - amountRead;
if (requestAmount > maxFrames) {
requestAmount = maxFrames;
}
(*types[type].gen)((int16_t *)((int32_t *)buf + amountRead), requestAmount);
amountRead += requestAmount;
}
framesRead += frames; framesRead += frames;
@ -319,7 +331,7 @@ int ao_get_lib(char *fn, uint8 **buf, uint64 *length)
+ (NSArray *)fileTypes + (NSArray *)fileTypes
{ {
return [NSArray arrayWithObjects:@"psf",@"minipsf",@"psf2", @"spu", @"psf2", @"ssf", @"dsf", @"qsf", nil]; return [NSArray arrayWithObjects:@"psf",@"minipsf",@"psf2", @"spu", @"psf2", @"ssf", @"dsf", @"minidsf", @"qsf", nil];
} }
+ (NSArray *)mimeTypes + (NSArray *)mimeTypes