X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2F940ctl.c;h=76986a5df10124022e67ae46518a183b533e19ee;hb=69dfeea15942d588fe0e4b18b51cf54cfde5b272;hp=921922c90365355cb42ec3853ba9f6dbad522952;hpb=45deb4099e6d20780376e6425d43107120a10bc6;p=libpicofe.git diff --git a/gp2x/940ctl.c b/gp2x/940ctl.c index 921922c..76986a5 100644 --- a/gp2x/940ctl.c +++ b/gp2x/940ctl.c @@ -17,6 +17,7 @@ #include "../common/arm_utils.h" #include "../common/menu.h" #include "../common/emu.h" +#include "../common/input.h" #include "../../pico/pico_int.h" #include "../../pico/sound/ym2612.h" #include "../../pico/sound/mix.h" @@ -294,7 +295,7 @@ void YM2612Init_940(int baseclock, int rate) if (crashed_940) { unsigned char ucData[1024]; - int nRead, i, nLen = 0; + int nRead, nLen = 0; char binpath[512]; FILE *fp; @@ -306,6 +307,7 @@ void YM2612Init_940(int baseclock, int rate) text_out16(10, 100, "failed to open required file:"); text_out16(10, 110, CODE940_FILE); gp2x_video_flip2(); + in_menu_wait(PBTN_MOK|PBTN_MBACK, 100); printf("failed to open %s\n", binpath); exit(1); } @@ -403,24 +405,24 @@ int YM2612UpdateOne_940(int *buffer, int length, int stereo, int is_buf_empty) } +/***********************************************************/ + static int mp3_samples_ready = 0, mp3_buffer_offs = 0; static int mp3_play_bufsel = 0, mp3_job_started = 0; void mp3_update(int *buffer, int length, int stereo) { int length_mp3; - int cdda_on; - - // playback was started, track not ended - cdda_on = loaded_mp3 && shared_ctl->mp3_offs < shared_ctl->mp3_len; - if (!cdda_on) return; - - if (!(PicoOpt&0x200)) { + if (!(PicoOpt & POPT_EXT_FM)) { mp3_update_local(buffer, length, stereo); return; } + // check if playback was started, track not ended + if (loaded_mp3 == NULL || shared_ctl->mp3_offs >= shared_ctl->mp3_len) + return; + length_mp3 = length; if (PsndRate == 22050) length_mp3 <<= 1; // mp3s are locked to 44100Hz stereo else if (PsndRate == 11025) length_mp3 <<= 2; // so make length 44100ish @@ -473,13 +475,16 @@ void mp3_update(int *buffer, int length, int stereo) } -/***********************************************************/ - -void mp3_start_play(FILE *f, int pos) // pos is 0-1023 +void mp3_start_play(void *f_, int pos) // pos is 0-1023 { int byte_offs = 0; + FILE *f = f_; - if (!(PicoOpt&0x800)) { // cdda disabled? + if (!(PicoOpt & POPT_EN_MCD_CDDA) || f == NULL) + return; + + if (!(PicoOpt & POPT_EXT_FM)) { + mp3_start_play_local(f, pos); return; } @@ -520,31 +525,7 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023 mp3_job_started = 0; shared_ctl->mp3_buffsel = 1; // will change to 0 on first decode - if (PicoOpt & POPT_EXT_FM) - { - add_job_940(JOB940_MP3RESET); - if (CHECK_BUSY(JOB940_MP3RESET)) wait_busy_940(JOB940_MP3RESET); - } - else - mp3_start_local(); -} - - -int mp3_get_offset(void) -{ - unsigned int offs1024 = 0; - int cdda_on; - - cdda_on = (PicoAHW & PAHW_MCD) && (PicoOpt&0x800) && !(Pico_mcd->s68k_regs[0x36] & 1) && - (Pico_mcd->scd.Status_CDC & 1) && loaded_mp3; - - if (cdda_on) { - offs1024 = shared_ctl->mp3_offs << 7; - offs1024 /= shared_ctl->mp3_len >> 3; - } - printf("offs1024=%u (%i/%i)\n", offs1024, shared_ctl->mp3_offs, shared_ctl->mp3_len); - - return offs1024; + add_job_940(JOB940_MP3RESET); + if (CHECK_BUSY(JOB940_MP3RESET)) wait_busy_940(JOB940_MP3RESET); } -