X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2F940ctl.c;h=4bfd043c73b2dd907f14cb896b07ed632b5b5cd1;hb=ca69c3e5a0ecf407c02dc85c6f3282ebb1efc5a2;hp=083036e8df110f5581585a0966e333019a56c650;hpb=d572cbad9886a04f8c51edb825dc6aaec9b02e23;p=libpicofe.git diff --git a/gp2x/940ctl.c b/gp2x/940ctl.c index 083036e..4bfd043 100644 --- a/gp2x/940ctl.c +++ b/gp2x/940ctl.c @@ -13,16 +13,15 @@ #include "code940/940shared.h" #include "soc_mmsp2.h" #include "soc.h" -#include "emu.h" #include "../common/mp3.h" #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" -extern int reset_timing; static unsigned char *shared_mem = 0; static _940_data_t *shared_data = 0; _940_ctl_t *shared_ctl = 0; @@ -243,7 +242,7 @@ static void internal_reset(void) /* this must be called after mmu hack, the allocated regions must not get cached */ -void sharedmem_init(void) +void sharedmem940_init(void) { if (shared_mem != NULL) return; @@ -266,7 +265,7 @@ void sharedmem_init(void) } -void sharedmem_deinit(void) +void sharedmem940_finish(void) { munmap(shared_mem, 0x210000); munmap(mp3_mem, MP3_SIZE_MAX); @@ -276,8 +275,6 @@ void sharedmem_deinit(void) } -extern char **g_argv; - void YM2612Init_940(int baseclock, int rate) { printf("YM2612Init_940()\n"); @@ -296,16 +293,11 @@ void YM2612Init_940(int baseclock, int rate) if (crashed_940) { unsigned char ucData[1024]; - int nRead, i, nLen = 0; - char binpath[1024]; + int nRead, nLen = 0; + char binpath[512]; FILE *fp; - strncpy(binpath, g_argv[0], 1023); - binpath[1023] = 0; - for (i = strlen(binpath); i > 0; i--) - if (binpath[i] == '/') { binpath[i] = 0; break; } - strcat(binpath, "/" CODE940_FILE); - + emu_make_path(binpath, CODE940_FILE, sizeof(binpath)); fp = fopen(binpath, "rb"); if(!fp) { @@ -313,6 +305,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); } @@ -410,24 +403,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 @@ -480,13 +473,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 & POPT_EN_MCD_CDDA) || f == NULL) + return; - if (!(PicoOpt&0x800)) { // cdda disabled? + if (!(PicoOpt & POPT_EXT_FM)) { + mp3_start_play_local(f, pos); return; } @@ -527,31 +523,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(); + add_job_940(JOB940_MP3RESET); + if (CHECK_BUSY(JOB940_MP3RESET)) wait_busy_940(JOB940_MP3RESET); } - -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; -} - -