#include <errno.h>\r
\r
#include "code940/940shared.h"\r
-#include "gp2x.h"\r
-#include "emu.h"\r
-#include "menu.h"\r
+#include "soc_mmsp2.h"\r
+#include "soc.h"\r
#include "../common/mp3.h"\r
#include "../common/arm_utils.h"\r
#include "../common/menu.h"\r
#include "../common/emu.h"\r
+#include "../common/input.h"\r
#include "../../pico/pico_int.h"\r
#include "../../pico/sound/ym2612.h"\r
#include "../../pico/sound/mix.h"\r
\r
-/* we will need some gp2x internals here */\r
-extern volatile unsigned short *gp2x_memregs; /* from minimal library rlyeh */\r
-extern volatile unsigned long *gp2x_memregl;\r
-\r
-extern int reset_timing;\r
static unsigned char *shared_mem = 0;\r
static _940_data_t *shared_data = 0;\r
_940_ctl_t *shared_ctl = 0;\r
gp2x_memregs[0x3b46>>1], gp2x_memregl[0x4500>>2], gp2x_memregl[0x4510>>2]);\r
printf("last lr: %08x, lastjob: %i\n", shared_ctl->last_lr, shared_ctl->lastjob);\r
\r
- strcpy(menuErrorMsg, "940 crashed, too much overclock?");\r
+ me_update_msg("940 crashed, too much overclock?");\r
engineState = PGS_Menu;\r
crashed_940 = 1;\r
}\r
\r
\r
/* this must be called after mmu hack, the allocated regions must not get cached */\r
-void sharedmem_init(void)\r
+void sharedmem940_init(void)\r
{\r
if (shared_mem != NULL) return;\r
\r
}\r
\r
\r
-void sharedmem_deinit(void)\r
+void sharedmem940_finish(void)\r
{\r
munmap(shared_mem, 0x210000);\r
munmap(mp3_mem, MP3_SIZE_MAX);\r
printf("YM2612Init_940()\n");\r
printf("Mem usage: shared_data: %i, shared_ctl: %i\n", sizeof(*shared_data), sizeof(*shared_ctl));\r
\r
- Reset940(1, 2);\r
- Pause940(1);\r
+ reset940(1, 2);\r
+ pause940(1);\r
\r
gp2x_memregs[0x3B40>>1] = 0; // disable DUALCPU interrupts for 920\r
gp2x_memregs[0x3B42>>1] = 1; // enable DUALCPU interrupts for 940\r
if (crashed_940)\r
{\r
unsigned char ucData[1024];\r
- int nRead, i, nLen = 0;\r
- char binpath[1024];\r
+ int nRead, nLen = 0;\r
+ char binpath[512];\r
FILE *fp;\r
\r
- strncpy(binpath, g_argv[0], 1023);\r
- binpath[1023] = 0;\r
- for (i = strlen(binpath); i > 0; i--)\r
- if (binpath[i] == '/') { binpath[i] = 0; break; }\r
- strcat(binpath, "/" CODE940_FILE);\r
-\r
+ emu_make_path(binpath, CODE940_FILE, sizeof(binpath));\r
fp = fopen(binpath, "rb");\r
if(!fp)\r
{\r
text_out16(10, 100, "failed to open required file:");\r
text_out16(10, 110, CODE940_FILE);\r
gp2x_video_flip2();\r
+ in_menu_wait(PBTN_MOK|PBTN_MBACK, 100);\r
printf("failed to open %s\n", binpath);\r
exit(1);\r
}\r
gp2x_memregl[0x4510>>2] = 0xffffffff; // clear pending IRQs in INTPND\r
\r
/* start the 940 */\r
- Reset940(0, 2);\r
- Pause940(0);\r
+ reset940(0, 2);\r
+ pause940(0);\r
\r
// YM2612ResetChip_940(); // will be done on JOB940_YM2612INIT\r
\r
}\r
\r
\r
+/***********************************************************/\r
+\r
static int mp3_samples_ready = 0, mp3_buffer_offs = 0;\r
static int mp3_play_bufsel = 0, mp3_job_started = 0;\r
\r
void mp3_update(int *buffer, int length, int stereo)\r
{\r
int length_mp3;\r
- int cdda_on;\r
-\r
- // playback was started, track not ended\r
- cdda_on = loaded_mp3 && shared_ctl->mp3_offs < shared_ctl->mp3_len;\r
-\r
- if (!cdda_on) return;\r
\r
- if (!(PicoOpt&0x200)) {\r
+ if (!(PicoOpt & POPT_EXT_FM)) {\r
mp3_update_local(buffer, length, stereo);\r
return;\r
}\r
\r
+ // check if playback was started, track not ended\r
+ if (loaded_mp3 == NULL || shared_ctl->mp3_offs >= shared_ctl->mp3_len)\r
+ return;\r
+\r
length_mp3 = length;\r
if (PsndRate == 22050) length_mp3 <<= 1; // mp3s are locked to 44100Hz stereo\r
else if (PsndRate == 11025) length_mp3 <<= 2; // so make length 44100ish\r
}\r
\r
\r
-/***********************************************************/\r
-\r
void mp3_start_play(FILE *f, int pos) // pos is 0-1023\r
{\r
int byte_offs = 0;\r
\r
- if (!(PicoOpt&0x800)) { // cdda disabled?\r
+ if (!(PicoOpt & POPT_EN_MCD_CDDA) || f == NULL)\r
+ return;\r
+\r
+ if (!(PicoOpt & POPT_EXT_FM)) {\r
+ mp3_start_play_local(f, pos);\r
return;\r
}\r
\r
mp3_job_started = 0;\r
shared_ctl->mp3_buffsel = 1; // will change to 0 on first decode\r
\r
- if (PicoOpt & POPT_EXT_FM)\r
- {\r
- add_job_940(JOB940_MP3RESET);\r
- if (CHECK_BUSY(JOB940_MP3RESET)) wait_busy_940(JOB940_MP3RESET);\r
- }\r
- else\r
- mp3_start_local();\r
+ add_job_940(JOB940_MP3RESET);\r
+ if (CHECK_BUSY(JOB940_MP3RESET)) wait_busy_940(JOB940_MP3RESET);\r
}\r
\r
-\r
-int mp3_get_offset(void)\r
-{\r
- unsigned int offs1024 = 0;\r
- int cdda_on;\r
-\r
- cdda_on = (PicoAHW & PAHW_MCD) && (PicoOpt&0x800) && !(Pico_mcd->s68k_regs[0x36] & 1) &&\r
- (Pico_mcd->scd.Status_CDC & 1) && loaded_mp3;\r
-\r
- if (cdda_on) {\r
- offs1024 = shared_ctl->mp3_offs << 7;\r
- offs1024 /= shared_ctl->mp3_len >> 3;\r
- }\r
- printf("offs1024=%u (%i/%i)\n", offs1024, shared_ctl->mp3_offs, shared_ctl->mp3_len);\r
-\r
- return offs1024;\r
-}\r
-\r
-\r