screen ptr/size unification, major cleanups
[libpicofe.git] / gp2x / 940ctl.c
index b372d92..d219d8a 100644 (file)
@@ -18,9 +18,9 @@
 #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
@@ -82,10 +82,6 @@ int YM2612Write_940(unsigned int a, unsigned int v, int scanline)
                        upd = 0;\r
                        break;\r
 \r
-               case 1: /* data port 0    */\r
-                       if (ST_address == 0x2b) upd = 0; /* DAC sel */\r
-                       break;\r
-\r
                case 2: /* address port 1 */\r
                        if (addr_A1 == 1 && ST_address == v)\r
                                return 0;\r
@@ -317,7 +313,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
@@ -403,8 +399,8 @@ int YM2612UpdateOne_940(int *buffer, int length, int stereo, int is_buf_empty)
 \r
        /* predict sample counter for next frame */\r
        if (PsndLen_exc_add) {\r
-               if (PsndLen_exc_cnt + PsndLen_exc_add >= 0x10000) length = PsndLen + 1;\r
-               else length = PsndLen;\r
+               length = PsndLen;\r
+               if (PsndLen_exc_cnt + PsndLen_exc_add >= 0x10000) length++;\r
        }\r
 \r
        /* give 940 ym job */\r
@@ -512,7 +508,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
@@ -526,7 +522,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
@@ -535,7 +531,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