drc: support ms ABI
[picodrive.git] / platform / common / emu.c
index 407ed59..0a9f089 100644 (file)
@@ -42,6 +42,7 @@ void *g_screen_ptr;
 \r
 int g_screen_width  = 320;\r
 int g_screen_height = 240;\r
+int g_screen_ppitch = 320; // pitch in pixels\r
 \r
 const char *PicoConfigFile = "config2.cfg";\r
 currentConfig_t currentConfig, defaultConfig;\r
@@ -604,7 +605,7 @@ void emu_set_defconfig(void)
 {\r
        memcpy(&currentConfig, &defaultConfig, sizeof(currentConfig));\r
        PicoIn.opt = currentConfig.s_PicoOpt;\r
-       PsndRate = currentConfig.s_PsndRate;\r
+       PicoIn.sndRate = currentConfig.s_PsndRate;\r
        PicoIn.regionOverride = currentConfig.s_PicoRegion;\r
        PicoIn.autoRgnOrder = currentConfig.s_PicoAutoRgnOrder;\r
 }\r
@@ -730,12 +731,12 @@ void name(int x, int y, const char *text)                         \
        }                                                               \\r
 }\r
 \r
-mk_text_out(emu_text_out8,      unsigned char,    0xf0, g_screen_ptr, 1, g_screen_width)\r
-mk_text_out(emu_text_out16,     unsigned short, 0xffff, g_screen_ptr, 1, g_screen_width)\r
+mk_text_out(emu_text_out8,      unsigned char,    0xf0, g_screen_ptr, 1, g_screen_ppitch)\r
+mk_text_out(emu_text_out16,     unsigned short, 0xffff, g_screen_ptr, 1, g_screen_ppitch)\r
 mk_text_out(emu_text_out8_rot,  unsigned char,    0xf0,\r
-       (char *)g_screen_ptr  + (g_screen_width - 1) * g_screen_height, -g_screen_height, 1)\r
+       (char *)g_screen_ptr  + (g_screen_ppitch - 1) * g_screen_height, -g_screen_height, 1)\r
 mk_text_out(emu_text_out16_rot, unsigned short, 0xffff,\r
-       (short *)g_screen_ptr + (g_screen_width - 1) * g_screen_height, -g_screen_height, 1)\r
+       (short *)g_screen_ptr + (g_screen_ppitch - 1) * g_screen_height, -g_screen_height, 1)\r
 \r
 #undef mk_text_out\r
 \r
@@ -751,7 +752,7 @@ void emu_osd_text16(int x, int y, const char *text)
        for (h = 0; h < 8; h++) {\r
                unsigned short *p;\r
                p = (unsigned short *)g_screen_ptr\r
-                       + x + g_screen_width * (y + h);\r
+                       + x + g_screen_ppitch * (y + h);\r
                for (i = len; i > 0; i--, p++)\r
                        *p = (*p >> 2) & 0x39e7;\r
        }\r
@@ -958,10 +959,10 @@ void emu_set_fastforward(int set_on)
        static int set_Frameskip, set_EmuOpt, is_on = 0;\r
 \r
        if (set_on && !is_on) {\r
-               set_PsndOut = PsndOut;\r
+               set_PsndOut = PicoIn.sndOut;\r
                set_Frameskip = currentConfig.Frameskip;\r
                set_EmuOpt = currentConfig.EmuOpt;\r
-               PsndOut = NULL;\r
+               PicoIn.sndOut = NULL;\r
                currentConfig.Frameskip = 8;\r
                currentConfig.EmuOpt &= ~4;\r
                currentConfig.EmuOpt |= 0x40000;\r
@@ -969,7 +970,7 @@ void emu_set_fastforward(int set_on)
                emu_status_msg("FAST FORWARD");\r
        }\r
        else if (!set_on && is_on) {\r
-               PsndOut = set_PsndOut;\r
+               PicoIn.sndOut = set_PsndOut;\r
                currentConfig.Frameskip = set_Frameskip;\r
                currentConfig.EmuOpt = set_EmuOpt;\r
                PsndRerate(1);\r
@@ -1204,8 +1205,11 @@ static void mkdir_path(char *path_with_reserve, int pos, const char *name)
 void emu_cmn_forced_frame(int no_scale, int do_emu)\r
 {\r
        int po_old = PicoIn.opt;\r
+       int y;\r
 \r
-       memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4);\r
+       for (y = 0; y < g_screen_height; y++)\r
+               memset32((short *)g_screen_ptr + g_screen_ppitch * y, 0,\r
+                        g_screen_width * 2 / 4);\r
 \r
        PicoIn.opt &= ~POPT_ALT_RENDERER;\r
        PicoIn.opt |= POPT_ACC_SPRITES;\r
@@ -1253,9 +1257,9 @@ void emu_init(void)
        config_readlrom(path);\r
 \r
        PicoInit();\r
-       PicoMessage = plat_status_msg_busy_next;\r
-       PicoMCDopenTray = emu_tray_open;\r
-       PicoMCDcloseTray = emu_tray_close;\r
+       PicoIn.osdMessage = plat_status_msg_busy_next;\r
+       PicoIn.mcdTrayOpen = emu_tray_open;\r
+       PicoIn.mcdTrayClose = emu_tray_close;\r
 \r
        sndout_init();\r
 }\r
@@ -1285,12 +1289,12 @@ void emu_finish(void)
 \r
 static void snd_write_nonblocking(int len)\r
 {\r
-       sndout_write_nb(PsndOut, len);\r
+       sndout_write_nb(PicoIn.sndOut, len);\r
 }\r
 \r
 void emu_sound_start(void)\r
 {\r
-       PsndOut = NULL;\r
+       PicoIn.sndOut = NULL;\r
 \r
        if (currentConfig.EmuOpt & EOPT_EN_SOUND)\r
        {\r
@@ -1299,12 +1303,12 @@ void emu_sound_start(void)
                PsndRerate(Pico.m.frame_count ? 1 : 0);\r
 \r
                printf("starting audio: %i len: %i stereo: %i, pal: %i\n",\r
-                       PsndRate, PsndLen, is_stereo, Pico.m.pal);\r
-               sndout_start(PsndRate, is_stereo);\r
-               PicoWriteSound = snd_write_nonblocking;\r
+                       PicoIn.sndRate, Pico.snd.len, is_stereo, Pico.m.pal);\r
+               sndout_start(PicoIn.sndRate, is_stereo);\r
+               PicoIn.writeSound = snd_write_nonblocking;\r
                plat_update_volume(0, 0);\r
                memset(sndBuffer, 0, sizeof(sndBuffer));\r
-               PsndOut = sndBuffer;\r
+               PicoIn.sndOut = sndBuffer;\r
        }\r
 }\r
 \r