add a pitch variable
[picodrive.git] / platform / common / emu.c
index b4db4c6..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
@@ -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
@@ -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