fix FAKE_IN_GP2X
[libpicofe.git] / gp2x / 940ctl.c
index ee250f8..f6073d0 100644 (file)
 #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 "../../Pico/PicoInt.h"\r
-#include "../../Pico/sound/ym2612.h"\r
-#include "../../Pico/sound/mix.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
@@ -150,7 +144,7 @@ static void wait_busy_940(int job)
                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
@@ -247,7 +241,7 @@ static void internal_reset(void)
 \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
@@ -270,7 +264,7 @@ void sharedmem_init(void)
 }\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
@@ -287,8 +281,8 @@ void YM2612Init_940(int baseclock, int rate)
        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
@@ -313,7 +307,7 @@ void YM2612Init_940(int baseclock, int rate)
                fp = fopen(binpath, "rb");\r
                if(!fp)\r
                {\r
-                       memset(gp2x_screen, 0, 320*240*2);\r
+                       memset(g_screen_ptr, 0, 320*240*2);\r
                        text_out16(10, 100, "failed to open required file:");\r
                        text_out16(10, 110, CODE940_FILE);\r
                        gp2x_video_flip2();\r
@@ -348,8 +342,8 @@ void YM2612Init_940(int baseclock, int rate)
        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
@@ -508,7 +502,7 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023
                shared_ctl->mp3_len = ftell(f);\r
                loaded_mp3 = f;\r
 \r
-               if (PicoOpt&0x200) {\r
+               if (PicoOpt & POPT_EXT_FM) {\r
                        // as we are going to change 940's cacheable area, we must invalidate it's cache..\r
                        if (CHECK_BUSY(JOB940_MP3DECODE)) wait_busy_940(JOB940_MP3DECODE);\r
                        add_job_940(JOB940_INVALIDATE_DCACHE);\r
@@ -522,7 +516,7 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023
                byte_offs *= pos;\r
                byte_offs >>= 6;\r
        }\r
-       // printf("mp3 pos1024: %i, byte_offs %i/%i\n", pos, byte_offs, shared_ctl->mp3_len);\r
+       printf("  mp3 pos1024: %i, byte_offs %i/%i\n", pos, byte_offs, shared_ctl->mp3_len);\r
 \r
        shared_ctl->mp3_offs = byte_offs;\r
 \r
@@ -531,7 +525,13 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023
        mp3_job_started = 0;\r
        shared_ctl->mp3_buffsel = 1; // will change to 0 on first decode\r
 \r
-       if (!(PicoOpt&0x200)) mp3_start_local();\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
 }\r
 \r
 \r