platform ps2, handle audio similar to psp
[picodrive.git] / platform / gp2x / 940ctl.c
index 99c25d6..b173002 100644 (file)
@@ -22,9 +22,9 @@
 #include "../common/arm_utils.h"\r
 #include "../common/menu_pico.h"\r
 #include "../common/emu.h"\r
-#include "../../pico/pico_int.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
 #include "code940/940shared.h"\r
 #include "plat.h"\r
 #include "940ctl.h"\r
@@ -100,10 +100,10 @@ int YM2612Write_940(unsigned int a, unsigned int v, int scanline)
                UINT16 *writebuff = shared_ctl->writebuffsel ? shared_ctl->writebuff0 : shared_ctl->writebuff1;\r
 \r
                /* detect rapid ym updates */\r
-               if (upd && !(writebuff_ptr & 0x80000000) && scanline < 224)\r
+               if (upd && !(writebuff_ptr & 0x80000000))\r
                {\r
-                       int mid = Pico.m.pal ? 68 : 93;\r
-                       if (scanline > mid) {\r
+                       int mid = (Pico.m.pal ? 313 : 262) / 2;\r
+                       if (scanline >= mid) {\r
                                //printf("%05i:%03i: rapid ym\n", Pico.m.frame_count, scanline);\r
                                writebuff[writebuff_ptr++ & 0xffff] = 0xfffe;\r
                                writebuff_ptr |= 0x80000000;\r
@@ -282,7 +282,7 @@ void sharedmem940_finish(void)
 }\r
 \r
 \r
-void YM2612Init_940(int baseclock, int rate)\r
+void YM2612Init_940(int baseclock, int rate, int ssg)\r
 {\r
        static int oldrate;\r
 \r
@@ -339,7 +339,7 @@ void YM2612Init_940(int baseclock, int rate)
        memset(shared_ctl,  0, sizeof(*shared_ctl));\r
 \r
        /* cause local ym2612 to init REGS */\r
-       YM2612Init_(baseclock, rate);\r
+       YM2612Init_(baseclock, rate, ssg);\r
 \r
        internal_reset();\r
 \r
@@ -402,9 +402,9 @@ int YM2612UpdateOne_940(int *buffer, int length, int stereo, int is_buf_empty)
        writebuff_ptr = 0;\r
 \r
        /* predict sample counter for next frame */\r
-       if (PsndLen_exc_add) {\r
-               length = PsndLen;\r
-               if (PsndLen_exc_cnt + PsndLen_exc_add >= 0x10000) length++;\r
+       if (Pico.snd.len_e_add) {\r
+               length = Pico.snd.len;\r
+               if (Pico.snd.len_e_cnt + Pico.snd.len_e_add >= 0x10000) length++;\r
        }\r
 \r
        /* give 940 ym job */\r
@@ -425,8 +425,7 @@ int YM2612UpdateOne_940(int *buffer, int length, int stereo, int is_buf_empty)
 int mp3dec_decode(FILE *f, int *file_pos, int file_len)\r
 {\r
        if (!(PicoIn.opt & POPT_EXT_FM)) {\r
-               //mp3_update_local(buffer, length, stereo);\r
-               return 0;\r
+               return _mp3dec_decode(f, file_pos, file_len);\r
        }\r
 \r
        // check if playback was started, track not ended\r
@@ -457,17 +456,16 @@ int mp3dec_decode(FILE *f, int *file_pos, int file_len)
 int mp3dec_start(FILE *f, int fpos_start)\r
 {\r
        if (!(PicoIn.opt & POPT_EXT_FM)) {\r
-               //mp3_start_play_local(f, pos);\r
-               return -1;\r
+               return _mp3dec_start(f, fpos_start);\r
        }\r
 \r
        if (loaded_mp3 != f)\r
        {\r
-               if (PicoMessage != NULL)\r
+               if (PicoIn.osdMessage != NULL)\r
                {\r
                        fseek(f, 0, SEEK_END);\r
                        if (ftell(f) > 2*1024*1024)\r
-                               PicoMessage("Loading MP3...");\r
+                               PicoIn.osdMessage("Loading MP3...");\r
                }\r
                fseek(f, 0, SEEK_SET);\r
                fread(mp3_mem, 1, MP3_SIZE_MAX, f);\r