platforms, display pad overlay and storyware pages for Pico
authorkub <derkub@gmail.com>
Wed, 20 Mar 2024 22:43:10 +0000 (23:43 +0100)
committerkub <derkub@gmail.com>
Mon, 25 Mar 2024 22:08:23 +0000 (23:08 +0100)
14 files changed:
Makefile
pico/pico/pico.c
platform/common/emu.c
platform/common/emu.h
platform/common/input_pico.h
platform/common/inputmap_kbd.c
platform/common/menu_pico.c
platform/gp2x/emu.c
platform/libpicofe
platform/linux/blit.c
platform/linux/emu.c
platform/pandora/plat.c
platform/ps2/emu.c
platform/psp/emu.c

index cbed790..3fe87cb 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -246,18 +246,24 @@ endif
 ifeq "$(PLATFORM)" "libretro"
 OBJS += platform/libretro/libretro.o
 ifneq ($(STATIC_LINKING), 1)
+CFLAGS += -DHAVE_ZLIB
+OBJS += platform/libretro/libretro-common/formats/png/rpng.o
+OBJS += platform/libretro/libretro-common/streams/trans_stream.o
+OBJS += platform/libretro/libretro-common/streams/trans_stream_pipe.o
+OBJS += platform/libretro/libretro-common/streams/trans_stream_zlib.o
+OBJS += platform/libretro/libretro-common/file/file_path_io.o
+OBJS += platform/libretro/libretro-common/file/file_path.o
+OBJS += platform/libretro/libretro-common/vfs/vfs_implementation.o
+OBJS += platform/libretro/libretro-common/time/rtime.o
+OBJS += platform/libretro/libretro-common/string/stdstring.o
 OBJS += platform/libretro/libretro-common/compat/compat_strcasestr.o
+OBJS += platform/libretro/libretro-common/encodings/encoding_utf.o
+OBJS += platform/libretro/libretro-common/compat/compat_strl.o
 ifeq "$(USE_LIBRETRO_VFS)" "1"
 OBJS += platform/libretro/libretro-common/compat/compat_posix_string.o
-OBJS += platform/libretro/libretro-common/compat/compat_strl.o
 OBJS += platform/libretro/libretro-common/compat/fopen_utf8.o
-OBJS += platform/libretro/libretro-common/encodings/encoding_utf.o
-OBJS += platform/libretro/libretro-common/string/stdstring.o
-OBJS += platform/libretro/libretro-common/time/rtime.o
 OBJS += platform/libretro/libretro-common/streams/file_stream.o
 OBJS += platform/libretro/libretro-common/streams/file_stream_transforms.o
-OBJS += platform/libretro/libretro-common/file/file_path.o
-OBJS += platform/libretro/libretro-common/vfs/vfs_implementation.o
 endif
 endif
 ifeq "$(USE_LIBRETRO_VFS)" "1"
index 99f21f4..94c80f2 100644 (file)
@@ -60,6 +60,5 @@ PICO_INTERNAL void PicoInitPico(void)
 
   PicoIn.AHW = PAHW_PICO;
   memset(&PicoPicohw, 0, sizeof(PicoPicohw));
-  PicoPicohw.pen_pos[0] = 0x03c + 320/2;
-  PicoPicohw.pen_pos[1] = 0x200 + 240/2;
+  PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000;
 }
index d576b43..051f8b4 100644 (file)
@@ -1,6 +1,7 @@
 /*\r
  * PicoDrive\r
  * (C) notaz, 2007-2010\r
+ * (C) irixxxx, 2019-2024\r
  *\r
  * This work is licensed under the terms of MAME license.\r
  * See COPYING file in the top-level directory.\r
@@ -19,6 +20,7 @@
 #include "../libpicofe/fonts.h"\r
 #include "../libpicofe/sndout.h"\r
 #include "../libpicofe/lprintf.h"\r
+#include "../libpicofe/readpng.h"\r
 #include "../libpicofe/plat.h"\r
 #include "emu.h"\r
 #include "input_pico.h"\r
@@ -618,7 +620,7 @@ void emu_prep_defconfig(void)
 {\r
        memset(&defaultConfig, 0, sizeof(defaultConfig));\r
        defaultConfig.EmuOpt    = EOPT_EN_SRAM | EOPT_EN_SOUND | EOPT_16BPP |\r
-                                 EOPT_EN_CD_LEDS | EOPT_GZIP_SAVES | 0x10/*?*/;\r
+                                 EOPT_EN_CD_LEDS | EOPT_GZIP_SAVES | EOPT_PICO_PEN;\r
        defaultConfig.s_PicoOpt = POPT_EN_SNDFILTER|POPT_EN_GG_LCD|POPT_EN_YM2413 |\r
                                  POPT_EN_STEREO|POPT_EN_FM|POPT_EN_PSG|POPT_EN_Z80 |\r
                                  POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_MCD_GFX |\r
@@ -1041,19 +1043,76 @@ void emu_reset_game(void)
        reset_timing = 1;\r
 }\r
 \r
-void run_events_pico(unsigned int events)\r
+static int pico_page;\r
+static int pico_w, pico_h;\r
+static u16 *pico_overlay;\r
+\r
+static u16 *load_pico_overlay(int page, int w, int h)\r
 {\r
-       if (events & PEV_PICO_SWINP) {\r
-               pico_inp_mode++;\r
-               if (pico_inp_mode > 2)\r
-                       pico_inp_mode = 0;\r
-               switch (pico_inp_mode) {\r
-                       case 2: emu_status_msg("Input: Pen on Pad"); break;\r
-                       case 1: emu_status_msg("Input: Pen on Storyware"); break;\r
-                       case 0: emu_status_msg("Input: Joystick"); break;\r
+       static const char *pic_exts[] = { "png", "PNG" };\r
+       char *ext, *fname = NULL;\r
+       int extpos, i;\r
+\r
+       if (pico_page == page && pico_w == w && pico_h == h)\r
+               return pico_overlay;\r
+       pico_page = page;\r
+       pico_w = w, pico_h = h;\r
+\r
+       ext = strrchr(rom_fname_loaded, '.');\r
+       extpos = ext ? ext-rom_fname_loaded : strlen(rom_fname_loaded);\r
+       strcpy(static_buff, rom_fname_loaded);\r
+       static_buff[extpos++] = '_';\r
+       if (page < 0) {\r
+               static_buff[extpos++] = 'p';\r
+               static_buff[extpos++] = 'a';\r
+               static_buff[extpos++] = 'd';\r
+       } else\r
+               static_buff[extpos++] = '0'+PicoPicohw.page;\r
+       static_buff[extpos++] = '.';\r
+\r
+       for (i = 0; i < ARRAY_SIZE(pic_exts); i++) {\r
+               strcpy(static_buff+extpos, pic_exts[i]);\r
+               if (access(static_buff, R_OK) == 0) {\r
+                       printf("found Pico file: %s\n", static_buff);\r
+                       fname = static_buff;\r
+                       break;\r
                }\r
-               PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000;\r
        }\r
+\r
+       pico_overlay = realloc(pico_overlay, w*h*2);\r
+       memset(pico_overlay, 0, w*h*2);\r
+       if (!fname || !pico_overlay || readpng(pico_overlay, fname, READPNG_SCALE, w, h)) {\r
+               if (pico_overlay)\r
+                       free(pico_overlay);\r
+               pico_overlay = NULL;\r
+       }\r
+\r
+       return pico_overlay;\r
+}\r
+\r
+void emu_pico_overlay(u16 *pd, int w, int h, int pitch)\r
+{\r
+       u16 *overlay = NULL;\r
+       int y, oh = h;\r
+\r
+       // get overlay\r
+       if (pico_inp_mode == 1) {\r
+               oh = (w/2 < h ? w/2 : h); // storyware has squished h\r
+               overlay = load_pico_overlay(PicoPicohw.page, w, oh);\r
+       } else if (pico_inp_mode == 2)\r
+               overlay = load_pico_overlay(-1, w, oh);\r
+\r
+       // copy overlay onto buffer\r
+       if (overlay) {\r
+               for (y = 0; y < oh; y++)\r
+                       memcpy(pd + y*pitch, overlay + y*w, w*2);\r
+               if (y < h)\r
+                       memset(pd + y*pitch, 0, w*2);\r
+       }\r
+}\r
+\r
+void run_events_pico(unsigned int events)\r
+{\r
        if (events & PEV_PICO_PPREV) {\r
                PicoPicohw.page--;\r
                if (PicoPicohw.page < 0)\r
@@ -1066,16 +1125,35 @@ void run_events_pico(unsigned int events)
                        PicoPicohw.page = 6;\r
                emu_status_msg("Page %i", PicoPicohw.page);\r
        }\r
-       if (events & PEV_PICO_SHPEN) {\r
-               currentConfig.EmuOpt ^= EOPT_PICO_PEN;\r
-               emu_status_msg("%s Pen", currentConfig.EmuOpt & EOPT_PICO_PEN ? "Show" : "Hide");\r
+       if (events & PEV_PICO_STORY) {\r
+               if (pico_inp_mode == 1) {\r
+                       pico_inp_mode = 0;\r
+                       emu_status_msg("Input: D-Pad");\r
+               } else {\r
+                       pico_inp_mode = 1;\r
+                       emu_status_msg("Input: Pen on Storyware");\r
+               }\r
+       }\r
+       if (events & PEV_PICO_PAD) {\r
+               if (pico_inp_mode == 2) {\r
+                       pico_inp_mode = 0;\r
+                       emu_status_msg("Input: D-Pad");\r
+               } else {\r
+                       pico_inp_mode = 2;\r
+                       emu_status_msg("Input: Pen on Pad");\r
+               }\r
        }\r
-       if (events & PEV_PICO_PPOSV) {\r
+       if (events & PEV_PICO_PENST) {\r
                PicoPicohw.pen_pos[0] ^= 0x8000;\r
                PicoPicohw.pen_pos[1] ^= 0x8000;\r
                emu_status_msg("Pen %s", PicoPicohw.pen_pos[0] & 0x8000 ? "Up" : "Down");\r
        }\r
 \r
+       if ((currentConfig.EmuOpt & EOPT_PICO_PEN) &&\r
+                       (PicoIn.pad[0]&0x20) && pico_inp_mode && pico_overlay) {\r
+               pico_inp_mode = 0;\r
+               emu_status_msg("Input: D-Pad");\r
+       }\r
        if (pico_inp_mode == 0)\r
                return;\r
 \r
@@ -1086,14 +1164,15 @@ void run_events_pico(unsigned int events)
        if (PicoIn.pad[0] & 8) pico_pen_x++;\r
        PicoIn.pad[0] &= ~0x0f; // release UDLR\r
 \r
+       /* cursor position, cursor drawing must not cross screen borders */\r
        if (pico_pen_y < PICO_PEN_ADJUST_Y)\r
                pico_pen_y = PICO_PEN_ADJUST_Y;\r
-       if (pico_pen_y > 224-1 - PICO_PEN_ADJUST_Y)\r
-               pico_pen_y = 224-1 - PICO_PEN_ADJUST_Y;\r
+       if (pico_pen_y > 223-1 - PICO_PEN_ADJUST_Y)\r
+               pico_pen_y = 223-1 - PICO_PEN_ADJUST_Y;\r
        if (pico_pen_x < PICO_PEN_ADJUST_X)\r
                pico_pen_x = PICO_PEN_ADJUST_X;\r
-       if (pico_pen_x > 320-1 - PICO_PEN_ADJUST_X)\r
-               pico_pen_x = 320-1 - PICO_PEN_ADJUST_X;\r
+       if (pico_pen_x > 319-1 - PICO_PEN_ADJUST_X)\r
+               pico_pen_x = 319-1 - PICO_PEN_ADJUST_X;\r
 \r
        PicoPicohw.pen_pos[0] &= 0x8000;\r
        PicoPicohw.pen_pos[1] &= 0x8000;\r
index 959ce0b..c477883 100644 (file)
@@ -160,6 +160,8 @@ void  emu_get_game_name(char *str150);
 void  emu_set_fastforward(int set_on);
 void  emu_status_msg(const char *format, ...);
 
+void  emu_pico_overlay(unsigned short *pd, int w, int h, int pitch);
+
 /* default sound code */
 void  emu_sound_start(void);
 void  emu_sound_stop(void);
index 10d6511..2f3de41 100644 (file)
@@ -27,9 +27,9 @@
 #define PEVB_FF         22
 #define PEVB_PICO_PNEXT 21
 #define PEVB_PICO_PPREV 20
-#define PEVB_PICO_SWINP 19
-#define PEVB_PICO_SHPEN 18
-#define PEVB_PICO_PPOSV 17
+#define PEVB_PICO_STORY 19
+#define PEVB_PICO_PAD   18
+#define PEVB_PICO_PENST 17
 #define PEVB_RESET      16
 
 #define PEV_VOL_DOWN    (1 << PEVB_VOL_DOWN)
@@ -43,9 +43,9 @@
 #define PEV_FF          (1 << PEVB_FF)
 #define PEV_PICO_PNEXT  (1 << PEVB_PICO_PNEXT)
 #define PEV_PICO_PPREV  (1 << PEVB_PICO_PPREV)
-#define PEV_PICO_SWINP  (1 << PEVB_PICO_SWINP)
-#define PEV_PICO_SHPEN  (1 << PEVB_PICO_SHPEN)
-#define PEV_PICO_PPOSV  (1 << PEVB_PICO_PPOSV)
+#define PEV_PICO_STORY  (1 << PEVB_PICO_STORY)
+#define PEV_PICO_PAD    (1 << PEVB_PICO_PAD)
+#define PEV_PICO_PENST  (1 << PEVB_PICO_PENST)
 #define PEV_RESET       (1 << PEVB_RESET)
 
 #define PEV_MASK 0x7fff0000
index 821a8ee..c41abbb 100644 (file)
@@ -29,9 +29,9 @@ const struct in_default_bind in_sdl_defbinds[] = {
        { SDLK_F5,     IN_BINDTYPE_EMU, PEVB_SWITCH_RND },
        { SDLK_F6,     IN_BINDTYPE_EMU, PEVB_PICO_PPREV },
        { SDLK_F7,     IN_BINDTYPE_EMU, PEVB_PICO_PNEXT },
-       { SDLK_F8,     IN_BINDTYPE_EMU, PEVB_PICO_SWINP },
-       { SDLK_F9,     IN_BINDTYPE_EMU, PEVB_PICO_SHPEN },
-       { SDLK_F10,    IN_BINDTYPE_EMU, PEVB_PICO_PPOSV },
+       { SDLK_F8,     IN_BINDTYPE_EMU, PEVB_PICO_STORY },
+       { SDLK_F9,     IN_BINDTYPE_EMU, PEVB_PICO_PAD },
+       { SDLK_F10,    IN_BINDTYPE_EMU, PEVB_PICO_PENST },
        { SDLK_BACKSPACE, IN_BINDTYPE_EMU, PEVB_FF },
        { 0, 0, 0 }
 };
index ffd9161..00f2aa6 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * PicoDrive
  * (C) notaz, 2010,2011
+ * (C) irixxxx, 2023,2024
  *
  * This work is licensed under the terms of MAME license.
  * See COPYING file in the top-level directory.
@@ -349,21 +350,21 @@ me_bind_action me_ctrl_actions[] =
 
 me_bind_action emuctrl_actions[] =
 {
-       { "Load State       ", PEV_STATE_LOAD },
-       { "Save State       ", PEV_STATE_SAVE },
-       { "Prev Save Slot   ", PEV_SSLOT_PREV },
-       { "Next Save Slot   ", PEV_SSLOT_NEXT },
-       { "Switch Renderer  ", PEV_SWITCH_RND },
-       { "Volume Down      ", PEV_VOL_DOWN },
-       { "Volume Up        ", PEV_VOL_UP },
-       { "Fast forward     ", PEV_FF },
-       { "Reset Game       ", PEV_RESET },
-       { "Enter Menu       ", PEV_MENU },
-       { "Pico Next page   ", PEV_PICO_PNEXT },
-       { "Pico Prev page   ", PEV_PICO_PPREV },
-       { "Pico Switch input", PEV_PICO_SWINP },
-       { "Pico Pen sensor  ", PEV_PICO_PPOSV },
-       { "Pico Show pen    ", PEV_PICO_SHPEN },
+       { "Load State     ", PEV_STATE_LOAD },
+       { "Save State     ", PEV_STATE_SAVE },
+       { "Prev Save Slot ", PEV_SSLOT_PREV },
+       { "Next Save Slot ", PEV_SSLOT_NEXT },
+       { "Switch Renderer", PEV_SWITCH_RND },
+       { "Volume Down    ", PEV_VOL_DOWN },
+       { "Volume Up      ", PEV_VOL_UP },
+       { "Fast forward   ", PEV_FF },
+       { "Reset Game     ", PEV_RESET },
+       { "Enter Menu     ", PEV_MENU },
+       { "Pico Next page ", PEV_PICO_PNEXT },
+       { "Pico Prev page ", PEV_PICO_PPREV },
+       { "Pico Storyware ", PEV_PICO_STORY },
+       { "Pico Pad       ", PEV_PICO_PAD },
+       { "Pico Pen state ", PEV_PICO_PENST },
        { NULL,                0 }
 };
 
@@ -463,15 +464,17 @@ static const char h_fmsound[]  = "Disabling improves performance, but breaks sou
 static const char h_dacnoise[] = "FM chips in the 1st Mega Drive model have DAC noise,\n"
                                "newer models used different chips without this";
 static const char h_fmfilter[] = "Improves sound accuracy but is noticeably slower,\n"
-                               "best´quality if native rate isn't working";
+                               "best quality if native rate isn't working";
+static const char h_picopen[]  = "Enabling resets Pico display and d-pad input back to\n"
+                               "screen if the Pico pen button is pressed";
 
 static menu_entry e_menu_md_options[] =
 {
-       mee_enum_h    ("Renderer",        MA_OPT_RENDERER, currentConfig.renderer, renderer_names, h_renderer),
-       mee_onoff_h   ("FM audio",        MA_OPT2_ENABLE_YM2612, PicoIn.opt, POPT_EN_FM, h_fmsound),
-       mee_onoff_h   ("FM filter",       MA_OPT_FM_FILTER, PicoIn.opt, POPT_EN_FM_FILTER, h_fmfilter),
-       mee_onoff_h   ("FM DAC noise",    MA_OPT2_ENABLE_YM_DAC, PicoIn.opt, POPT_EN_FM_DAC, h_dacnoise),
-       mee_onoff     ("Show Pico pen",   MA_OPT_PICO_PEN, currentConfig.EmuOpt, EOPT_PICO_PEN),
+       mee_enum_h    ("Renderer",                  MA_OPT_RENDERER, currentConfig.renderer, renderer_names, h_renderer),
+       mee_onoff_h   ("FM audio",                  MA_OPT2_ENABLE_YM2612, PicoIn.opt, POPT_EN_FM, h_fmsound),
+       mee_onoff_h   ("FM filter",                 MA_OPT_FM_FILTER, PicoIn.opt, POPT_EN_FM_FILTER, h_fmfilter),
+       mee_onoff_h   ("FM DAC noise",              MA_OPT2_ENABLE_YM_DAC, PicoIn.opt, POPT_EN_FM_DAC, h_dacnoise),
+       mee_onoff_h   ("Pen button shows screen",   MA_OPT_PICO_PEN, currentConfig.EmuOpt, EOPT_PICO_PEN, h_picopen),
        mee_end,
 };
 
@@ -1295,8 +1298,6 @@ static const char *mgn_picopage(int id, int *offs)
 
 static int mh_picopage(int id, int keys)
 {
-       int ret;
-
        if (keys & (PBTN_LEFT|PBTN_RIGHT)) { // multi choice
                PicoPicohw.page += (keys & PBTN_LEFT) ? -1 : 1;
                if (PicoPicohw.page < 0) PicoPicohw.page = 6;
index f20f29a..aae7fbd 100644 (file)
@@ -196,9 +196,12 @@ static void draw_pico_ptr(void)
 {\r
        int up = (PicoPicohw.pen_pos[0]|PicoPicohw.pen_pos[1]) & 0x8000;\r
        int x, y, pitch = 320, offs;\r
+       // storyware pages are actually squished, 2:1\r
+       int h = (pico_inp_mode == 1 ? 160 : linecount);\r
+       if (h < 224) y++;\r
 \r
        x = ((pico_pen_x * colcount  * ((1ULL<<32)/320 + 1)) >> 32) + firstcol;\r
-       y = ((pico_pen_y * linecount * ((1ULL<<32)/224 + 1)) >> 32) + firstline;\r
+       y = ((pico_pen_y * h         * ((1ULL<<32)/224 + 1)) >> 32) + firstline;\r
 \r
        if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) {\r
                pitch = 240;\r
@@ -210,16 +213,18 @@ static void draw_pico_ptr(void)
                unsigned short *p = (unsigned short *)g_screen_ptr + offs;\r
                int o = (up ? 0x0000 : 0xffff), _ = (up ? 0xffff : 0x0000);\r
 \r
-               p[-pitch-1] ^= _; p[-pitch] ^= o; p[-pitch+1] ^= _;\r
-               p[1]        ^= o; p[0]      ^= o; p[1]        ^= o;\r
-               p[pitch-1]  ^= _; p[pitch]  ^= o; p[pitch+1]  ^= _;\r
+               p[-pitch-1] ^= o; p[-pitch] ^= _; p[-pitch+1] ^= _; p[-pitch+2] ^= o;\r
+               p[-1]       ^= _; p[0]      ^= o; p[1]        ^= o; p[2]        ^= _;\r
+               p[pitch-1]  ^= _; p[pitch]  ^= o; p[pitch+1]  ^= o; p[pitch+2]  ^= _;\r
+               p[2*pitch-1]^= o; p[2*pitch]^= _; p[2*pitch+1]^= _; p[2*pitch+2]^= o;\r
        } else {\r
                unsigned char *p = (unsigned char *)g_screen_ptr + offs;\r
                int o = (up ? 0xe0 : 0xf0), _ = (up ? 0xf0 : 0xe0);\r
 \r
-               p[-pitch-1]  = _; p[-pitch]  = o; p[-pitch+1]  = _;\r
-               p[-1]        = o; p[0]       = o; p[1]         = o;\r
-               p[pitch-1]   = _; p[pitch]   = o; p[pitch+1]   = _;\r
+               p[-pitch-1] = o; p[-pitch] = _; p[-pitch+1] = _; p[-pitch+2] = o;\r
+               p[-1]       = _; p[0]      = o; p[1]        = o; p[2]        = _;\r
+               p[pitch-1]  = _; p[pitch]  = o; p[pitch+1]  = o; p[pitch+2]  = _;\r
+               p[2*pitch-1]= o; p[2*pitch]= _; p[2*pitch+1]= _; p[2*pitch+2]= o;\r
        }\r
 }\r
 \r
@@ -434,8 +439,15 @@ void pemu_finalize_frame(const char *fps, const char *notice)
                osd_text(osd_fps_x, osd_y, fps);\r
        if ((PicoIn.AHW & PAHW_MCD) && (emu_opt & EOPT_EN_CD_LEDS))\r
                draw_cd_leds();\r
-       if ((PicoIn.AHW & PAHW_PICO) && (currentConfig.EmuOpt & EOPT_PICO_PEN))\r
-               if (pico_inp_mode) draw_pico_ptr();\r
+       if (PicoIn.AHW & PAHW_PICO) {\r
+               int h = linecount, w = colcount;\r
+               u16 *pd = g_screen_ptr + firstline*g_screen_ppitch + firstcol;\r
+\r
+               if (pico_inp_mode && is_16bit_mode())\r
+                       emu_pico_overlay(pd, w, h, g_screen_ppitch);\r
+               if (pico_inp_mode /*== 2 || overlay*/)\r
+                       draw_pico_ptr();\r
+       }\r
 }\r
 \r
 void plat_video_flip(void)\r
index 82b4854..4563c13 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 82b4854771302e23201de274eee2969fc28be8be
+Subproject commit 4563c13167deb97851397789bf2fb95bb44cf1ed
index ee2b6d0..e10aa6b 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * PicoDrive
  * (C) notaz, 2006,2009
+ * (C) irixxxx, 2022
  *
  * This work is licensed under the terms of MAME license.
  * See COPYING file in the top-level directory.
index ba384ba..5d65ad5 100644 (file)
@@ -1,6 +1,7 @@
 /*\r
  * PicoDrive\r
  * (C) notaz, 2006-2010\r
+ * (C) irixxxx, 2019-2024\r
  *\r
  * This work is licensed under the terms of MAME license.\r
  * See COPYING file in the top-level directory.\r
@@ -92,14 +93,18 @@ static void draw_pico_ptr(void)
        int pitch = g_screen_ppitch;\r
        u16 *p = g_screen_ptr;\r
        int x = pico_pen_x, y = pico_pen_y;\r
+       // storyware pages are actually squished, 2:1\r
+       int h = (pico_inp_mode == 1 ? 160 : out_h);\r
+       if (h < 224) y++;\r
 \r
        x = (x * out_w * ((1ULL<<32) / 320 + 1)) >> 32;\r
-       y = (y * out_h * ((1ULL<<32) / 224 + 1)) >> 32;\r
+       y = (y *     h * ((1ULL<<32) / 224 + 1)) >> 32;\r
        p += (screen_y+y)*pitch + (screen_x+x);\r
 \r
-       p[-pitch-1] ^= _; p[-pitch] ^= o; p[-pitch+1] ^= _;\r
-       p[-1]       ^= o; p[0]      ^= o; p[1]        ^= o;\r
-       p[pitch-1]  ^= _; p[pitch]  ^= o; p[pitch+1]  ^= _;\r
+       p[-pitch-1] ^= o; p[-pitch] ^= _; p[-pitch+1] ^= _; p[-pitch+2] ^= o;\r
+       p[-1]       ^= _; p[0]      ^= o; p[1]        ^= o; p[2]        ^= _;\r
+       p[pitch-1]  ^= _; p[pitch]  ^= o; p[pitch+1]  ^= o; p[pitch+2]  ^= _;\r
+       p[2*pitch-1]^= o; p[2*pitch]^= _; p[2*pitch+1]^= _; p[2*pitch+2]^= o;\r
 }\r
 \r
 /* render/screen buffer handling:\r
@@ -194,6 +199,7 @@ void pemu_finalize_frame(const char *fps, const char *notice)
                u16 *ps = ghost_buf;\r
                int y, h = currentConfig.vscaling == EOPT_SCALE_SW ? 240:out_h;\r
                int w = currentConfig.scaling == EOPT_SCALE_SW ? 320:out_w;\r
+\r
                if (currentConfig.ghosting == 1)\r
                        for (y = 0; y < h; y++) {\r
                                v_blend((u32 *)pd, (u32 *)ps, w/2, p_075_round);\r
@@ -208,8 +214,17 @@ void pemu_finalize_frame(const char *fps, const char *notice)
                        }\r
        }\r
 \r
-       if ((PicoIn.AHW & PAHW_PICO) && (currentConfig.EmuOpt & EOPT_PICO_PEN))\r
-               if (pico_inp_mode) draw_pico_ptr();\r
+       if (PicoIn.AHW & PAHW_PICO) {\r
+               int h = currentConfig.vscaling == EOPT_SCALE_SW ? 240:out_h;\r
+               int w = currentConfig.scaling == EOPT_SCALE_SW ? 320:out_w;\r
+               u16 *pd = screen_buffer(g_screen_ptr) + out_y*g_screen_ppitch + out_x;\r
+\r
+               if (pico_inp_mode)\r
+                       emu_pico_overlay(pd, w, h, g_screen_ppitch);\r
+               if (pico_inp_mode /*== 2 || overlay*/)\r
+                       draw_pico_ptr();\r
+       }\r
+\r
        if (notice)\r
                emu_osd_text16(4, g_screen_height - 8, notice);\r
        if (currentConfig.EmuOpt & EOPT_SHOW_FPS)\r
index 32177ac..20f9ca8 100644 (file)
@@ -75,9 +75,9 @@ static struct in_default_bind in_evdev_defbinds[] =
        { KEY_4,        IN_BINDTYPE_EMU, PEVB_SSLOT_NEXT },\r
        { KEY_5,        IN_BINDTYPE_EMU, PEVB_PICO_PPREV },\r
        { KEY_6,        IN_BINDTYPE_EMU, PEVB_PICO_PNEXT },\r
-       { KEY_7,        IN_BINDTYPE_EMU, PEVB_PICO_SWINP },\r
-       { KEY_8,        IN_BINDTYPE_EMU, PEVB_PICO_SHPEN },\r
-       { KEY_9,        IN_BINDTYPE_EMU, PEVB_PICO_PPOSV },\r
+       { KEY_7,        IN_BINDTYPE_EMU, PEVB_PICO_STORY },\r
+       { KEY_8,        IN_BINDTYPE_EMU, PEVB_PICO_PAD },\r
+       { KEY_9,        IN_BINDTYPE_EMU, PEVB_PICO_PENST },\r
        { 0, 0, 0 }\r
 };\r
 \r
@@ -143,20 +143,32 @@ static void draw_pico_ptr(void)
        int o = (up ? 0x0000 : 0xffff), _ = (up ? 0xffff : 0x0000);\r
        int x = pico_pen_x, y = pico_pen_y, pitch = g_screen_ppitch;\r
        unsigned short *p = (unsigned short *)g_screen_ptr;\r
+       // storyware pages are actually squished, 2:1\r
+       int h = (pico_inp_mode == 1 ? 160 : saved_line_count);\r
+       if (h < 224) y++;\r
 \r
-       x = (x * saved_col_count  * ((1ULL<<32) / 320 + 1)) >> 32;\r
-       y = (y * saved_line_count * ((1ULL<<32) / 224 + 1)) >> 32;\r
+       x = (x * saved_col_count * ((1ULL<<32) / 320 + 1)) >> 32;\r
+       y = (y * h               * ((1ULL<<32) / 224 + 1)) >> 32;\r
        p += (saved_start_col+x) + (saved_start_line+y) * pitch;\r
 \r
-       p[-pitch-1] ^= _; p[-pitch] ^= o; p[-pitch+1] ^= _;\r
-       p[-1]       ^= o; p[0]      ^= o; p[1]        ^= o;\r
-       p[pitch-1]  ^= _; p[pitch]  ^= o; p[pitch+1]  ^= _;\r
+       p[-pitch-1] ^= o; p[-pitch] ^= _; p[-pitch+1] ^= _; p[-pitch+2] ^= o;\r
+       p[-1]       ^= _; p[0]      ^= o; p[1]        ^= o; p[2]        ^= _;\r
+       p[pitch-1]  ^= _; p[pitch]  ^= o; p[pitch+1]  ^= o; p[pitch+2]  ^= _;\r
+       p[2*pitch-1]^= o; p[2*pitch]^= _; p[2*pitch+1]^= _; p[2*pitch+2]^= o;\r
 }\r
 \r
 void pemu_finalize_frame(const char *fps, const char *notice)\r
 {\r
-       if ((PicoIn.AHW & PAHW_PICO) && (currentConfig.EmuOpt & EOPT_PICO_PEN))\r
-               if (pico_inp_mode) draw_pico_ptr();\r
+       if (PicoIn.AHW & PAHW_PICO) {\r
+               int h = saved_line_count, w = saved_col_count;\r
+               u16 *pd = g_screen_ptr + saved_start_line*g_screen_ppitch\r
+                                       + saved_start_col;\r
+\r
+               if (pico_inp_mode)\r
+                       emu_pico_overlay(pd, w, h, g_screen_ppitch);\r
+               if (pico_inp_mode /*== 2 || overlay*/)\r
+                       draw_pico_ptr();\r
+       }\r
        if (notice && notice[0])\r
                emu_osd_text16(2 + g_osd_start_x, g_osd_y, notice);\r
        if (fps && fps[0] && (currentConfig.EmuOpt & EOPT_SHOW_FPS))\r
index b15c603..35db974 100644 (file)
@@ -713,9 +713,12 @@ static void draw_pico_ptr(void)
        int up = (PicoPicohw.pen_pos[0]|PicoPicohw.pen_pos[1]) & 0x8000;
        int x = pico_pen_x, y = pico_pen_y, offs;
        int pitch = g_screen_ppitch;
+       // storyware pages are actually squished, 2:1
+       int h = (pico_inp_mode == 1 ? 160 : out_h);
+       if (h < 224) y++;
 
        x = (x * out_w * ((1ULL<<32) / 320 + 1)) >> 32;
-       y = (y * out_h * ((1ULL<<32) / 224 + 1)) >> 32;
+       y = (y *     h * ((1ULL<<32) / 224 + 1)) >> 32;
 
        offs = pitch * (out_y+y) + (out_x+x);
 
@@ -723,16 +726,18 @@ static void draw_pico_ptr(void)
                unsigned short *p = (unsigned short *)g_screen_ptr + offs;
                int o = (up ? 0x0000 : 0x7fff), _ = (up ? 0x7fff : 0x0000);
 
-               p[-pitch-1] ^= _; p[-pitch] ^= o; p[-pitch+1] ^= _;
-               p[1]        ^= o; p[0]      ^= o; p[1]        ^= o;
-               p[pitch-1]  ^= _; p[pitch]  ^= o; p[pitch+1]  ^= _;
+               p[-pitch-1] ^= o; p[-pitch] ^= _; p[-pitch+1] ^= _; p[-pitch+2] ^= o;
+               p[-1]       ^= _; p[0]      ^= o; p[1]        ^= o; p[2]        ^= _;
+               p[pitch-1]  ^= _; p[pitch]  ^= o; p[pitch+1]  ^= o; p[pitch+2]  ^= _;
+               p[2*pitch-1]^= o; p[2*pitch]^= _; p[2*pitch+1]^= _; p[2*pitch+2]^= o;
        } else {
                unsigned char *p = (unsigned char *)g_screen_ptr + offs + 8;
                int o = (up ? 0xe0 : 0xf0), _ = (up ? 0xf0 : 0xe0);
 
-               p[-pitch-1]  = _; p[-pitch]  = o; p[-pitch+1]  = _;
-               p[-1]        = o; p[0]       = o; p[1]         = o;
-               p[pitch-1]   = _; p[pitch]   = o; p[pitch+1]   = _;
+               p[-pitch-1] = o; p[-pitch] = _; p[-pitch+1] = _; p[-pitch+2] = o;
+               p[-1]       = _; p[0]      = o; p[1]        = o; p[2]        = _;
+               p[pitch-1]  = _; p[pitch]  = o; p[pitch+1]  = o; p[pitch+2]  = _;
+               p[2*pitch-1]= o; p[2*pitch]= _; p[2*pitch+1]= _; p[2*pitch+2]= o;
        }
 }
 
@@ -748,8 +753,15 @@ void pemu_finalize_frame(const char *fps, const char *notice)
 {
        int emu_opt = currentConfig.EmuOpt;
 
-       if ((PicoIn.AHW & PAHW_PICO) && (currentConfig.EmuOpt & EOPT_PICO_PEN))
-               if (pico_inp_mode) draw_pico_ptr();
+       if (PicoIn.AHW & PAHW_PICO) {
+               int h = out_h, w = out_w;
+               u16 *pd = g_screen_ptr + out_y*g_screen_ppitch + out_x;
+
+               if (pico_inp_mode && is_16bit_mode())
+                       emu_pico_overlay(pd, w, h, g_screen_ppitch);
+               if (pico_inp_mode /*== 2 || overlay*/)
+                       draw_pico_ptr();
+       }
 
        osd_buf_cnt = 0;
        if (notice)      osd_text(4, notice);
index 624d02a..948102b 100644 (file)
@@ -373,26 +373,31 @@ static void draw_pico_ptr(void)
        int up = (PicoPicohw.pen_pos[0]|PicoPicohw.pen_pos[1]) & 0x8000;
        int x = pico_pen_x, y = pico_pen_y, offs;
        int pitch = g_screen_ppitch;
+       // storyware pages are actually squished, 2:1
+       int h = (pico_inp_mode == 1 ? 160 : out_h);
+       if (h < 224) y++;
 
        x = (x * out_w * ((1ULL<<32) / 320 + 1)) >> 32;
-       y = (y * out_h * ((1ULL<<32) / 224 + 1)) >> 32;
+       y = (y *     h * ((1ULL<<32) / 224 + 1)) >> 32;
 
-       offs = 512 * (out_y+y) + (out_x+x);
+       offs = pitch * (out_y+y) + (out_x+x);
 
        if (is_16bit_mode()) {
                unsigned short *p = (unsigned short *)g_screen_ptr + offs;
                int o = (up ? 0x0000 : 0xffff), _ = (up ? 0xffff : 0x0000);
 
-               p[-pitch-1] ^= _; p[-pitch] ^= o; p[-pitch+1] ^= _;
-               p[1]        ^= o; p[0]      ^= o; p[1]        ^= o;
-               p[pitch-1]  ^= _; p[pitch]  ^= o; p[pitch+1]  ^= _;
+               p[-pitch-1] ^= o; p[-pitch] ^= _; p[-pitch+1] ^= _; p[-pitch+2] ^= o;
+               p[-1]       ^= _; p[0]      ^= o; p[1]        ^= o; p[2]        ^= _;
+               p[pitch-1]  ^= _; p[pitch]  ^= o; p[pitch+1]  ^= o; p[pitch+2]  ^= _;
+               p[2*pitch-1]^= o; p[2*pitch]^= _; p[2*pitch+1]^= _; p[2*pitch+2]^= o;
        } else {
                unsigned char *p = (unsigned char *)g_screen_ptr + offs + 8;
                int o = (up ? 0xe0 : 0xf0), _ = (up ? 0xf0 : 0xe0);
 
-               p[-pitch-1]  = _; p[-pitch]  = o; p[-pitch+1]  = _;
-               p[-1]        = o; p[0]       = o; p[1]         = o;
-               p[pitch-1]   = _; p[pitch]   = o; p[pitch+1]   = _;
+               p[-pitch-1] = o; p[-pitch] = _; p[-pitch+1] = _; p[-pitch+2] = o;
+               p[-1]       = _; p[0]      = o; p[1]        = o; p[2]        = _;
+               p[pitch-1]  = _; p[pitch]  = o; p[pitch+1]  = o; p[pitch+2]  = _;
+               p[2*pitch-1]= o; p[2*pitch]= _; p[2*pitch+1]= _; p[2*pitch+2]= o;
        }
 }
 
@@ -697,8 +702,15 @@ void pemu_finalize_frame(const char *fps, const char *notice)
 {
        int emu_opt = currentConfig.EmuOpt;
 
-       if ((PicoIn.AHW & PAHW_PICO) && (currentConfig.EmuOpt & EOPT_PICO_PEN))
-               if (pico_inp_mode) draw_pico_ptr();
+       if (PicoIn.AHW & PAHW_PICO) {
+               int h = out_h, w = out_w;
+               u16 *pd = g_screen_ptr + out_y*g_screen_ppitch + out_x;
+
+               if (pico_inp_mode && is_16bit_mode())
+                       emu_pico_overlay(pd, w, h, g_screen_ppitch);
+               if (pico_inp_mode /*== 2 || overlay*/)
+                       draw_pico_ptr();
+       }
 
        osd_buf_cnt = 0;
        if (notice)