region detection, cd states wip, fixes, stuff
[picodrive.git] / platform / gp2x / 940ctl_ym2612.c
index f1949e6..1352172 100644 (file)
@@ -27,6 +27,7 @@ static unsigned char *mp3_mem = 0;
 \r
 int crashed_940 = 0;\r
 \r
+static FILE *loaded_mp3 = 0;\r
 \r
 /***********************************************************/\r
 \r
@@ -380,6 +381,8 @@ void YM2612Init_940(int baseclock, int rate)
 \r
        internal_reset();\r
 \r
+       loaded_mp3 = 0;\r
+\r
        /* now cause 940 to init it's ym2612 stuff */\r
        shared_ctl->baseclock = baseclock;\r
        shared_ctl->rate = rate;\r
@@ -468,13 +471,12 @@ static void mix_samples(short *dest_buf, int *ym_buf, short *mp3_buf, int len, i
 \r
 // here we assume that length is different between games, but constant in one game\r
 \r
-static FILE *loaded_mp3 = 0;\r
+static int mp3_samples_ready = 0, mp3_buffer_offs = 0;\r
+static int mp3_play_bufsel = 0;\r
 \r
 void YM2612UpdateOne_940(short *buffer, int length, int stereo)\r
 {\r
        int cdda_on, *ym_buffer = shared_data->mix_buffer, mp3_job = 0;\r
-       static int mp3_samples_ready = 0, mp3_buffer_offs = 0;\r
-       static int mp3_play_bufsel = 1;\r
 \r
        //printf("YM2612UpdateOne_940()\n");\r
        if (shared_ctl->busy) wait_busy_940();\r
@@ -567,6 +569,10 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023
        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
+       // reset buffer pointers..\r
+       mp3_samples_ready = mp3_buffer_offs = mp3_play_bufsel = 0;\r
+       shared_ctl->mp3_buffsel = 1; // will change to 0 on first decode\r
 }\r
 \r
 \r