the MSB in the tablet position register denotes pen on surface.
add logic and a hotkey for handling pen not on surface. This allows
for repositioning of the pen without the storyware reacting to it.
PicoPicohw.fifo_bytes = 0;
PicoPicohw.r12 = 0;
+ PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000;
+
PicoPicoPCMIrqEn(0);
PicoPicoPCMFilter(0);
PicoPicoPCMGain(8);
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");\r
- PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000;\r
- break;\r
+ case 0: emu_status_msg("Input: Joystick"); break;\r
}\r
+ PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000;\r
}\r
if (events & PEV_PICO_PPREV) {\r
PicoPicohw.page--;\r
PicoPicohw.page = 6;\r
emu_status_msg("Page %i", PicoPicohw.page);\r
}\r
- if (events & PEV_PICO_PEN) {\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
}\r
+ if (events & PEV_PICO_PPOSV) {\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 (pico_inp_mode == 0)\r
return;\r
\r
if (pico_pen_y < PICO_PEN_ADJUST_Y)\r
pico_pen_y = PICO_PEN_ADJUST_Y;\r
- if (pico_pen_y > 224 - PICO_PEN_ADJUST_Y)\r
- pico_pen_y = 224 - 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_x < PICO_PEN_ADJUST_X)\r
pico_pen_x = PICO_PEN_ADJUST_X;\r
- if (pico_pen_x > 320 - PICO_PEN_ADJUST_X)\r
- pico_pen_x = 320 - 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
\r
- PicoPicohw.pen_pos[0] = 0x03c + pico_pen_x;\r
- PicoPicohw.pen_pos[1] = pico_inp_mode == 1 ? (0x2f8 + pico_pen_y) : (0x1fc + pico_pen_y);\r
+ PicoPicohw.pen_pos[0] &= 0x8000;\r
+ PicoPicohw.pen_pos[1] &= 0x8000;\r
+ PicoPicohw.pen_pos[0] |= 0x03c + pico_pen_x;\r
+ PicoPicohw.pen_pos[1] |= (pico_inp_mode == 1 ? 0x2f8 : 0x1fc) + pico_pen_y;\r
}\r
\r
static void do_turbo(unsigned short *pad, int acts)\r
extern int reset_timing;
extern int flip_after_sync;
-#define PICO_PEN_ADJUST_X 2
-#define PICO_PEN_ADJUST_Y 2
+#define PICO_PEN_ADJUST_X 1
+#define PICO_PEN_ADJUST_Y 1
extern int pico_pen_x, pico_pen_y;
extern int pico_inp_mode;
#define PEVB_PICO_PNEXT 21
#define PEVB_PICO_PPREV 20
#define PEVB_PICO_SWINP 19
-#define PEVB_PICO_PEN 18
-#define PEVB_RESET 17
+#define PEVB_PICO_SHPEN 18
+#define PEVB_PICO_PPOSV 17
+#define PEVB_RESET 16
#define PEV_VOL_DOWN (1 << PEVB_VOL_DOWN)
#define PEV_VOL_UP (1 << PEVB_VOL_UP)
#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_PEN (1 << PEVB_PICO_PEN)
+#define PEV_PICO_SHPEN (1 << PEVB_PICO_SHPEN)
+#define PEV_PICO_PPOSV (1 << PEVB_PICO_PPOSV)
#define PEV_RESET (1 << PEVB_RESET)
-#define PEV_MASK 0x7ffe0000
+#define PEV_MASK 0x7fff0000
#endif /* INCLUDE_c48097f3ff2a6a9af1cce8fd7a9b3f0c */
{ 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_PEN },
+ { SDLK_F9, IN_BINDTYPE_EMU, PEVB_PICO_SHPEN },
+ { SDLK_F10, IN_BINDTYPE_EMU, PEVB_PICO_PPOSV },
{ SDLK_BACKSPACE, IN_BINDTYPE_EMU, PEVB_FF },
{ 0, 0, 0 }
};
{ "Pico Next page ", PEV_PICO_PNEXT },
{ "Pico Prev page ", PEV_PICO_PPREV },
{ "Pico Switch input", PEV_PICO_SWINP },
- { "Pico Display pen ", PEV_PICO_PEN },
+ { "Pico Pen sensor ", PEV_PICO_PPOSV },
+ { "Pico Show pen ", PEV_PICO_SHPEN },
{ NULL, 0 }
};
\r
static void draw_pico_ptr(void)\r
{\r
+ int up = (PicoPicohw.pen_pos[0]|PicoPicohw.pen_pos[1]) & 0x8000;\r
int x, y, pitch = 320, offs;\r
\r
- x = ((pico_pen_x * colcount * ((1ULL<<32) / 320)) >> 32) + firstcol;\r
- y = ((pico_pen_y * linecount * ((1ULL<<32) / 224)) >> 32) + firstline;\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
\r
if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) {\r
pitch = 240;\r
\r
if (is_16bit_mode()) {\r
unsigned short *p = (unsigned short *)g_screen_ptr + offs;\r
+ int o = (up ? 0x0000 : 0xffff), _ = (up ? 0xffff : 0x0000);\r
\r
- p[0] ^= 0xffff;\r
- p[pitch-1] ^= 0xffff; p[pitch] ^= 0xffff; p[pitch+1] ^= 0xffff;\r
- p[pitch*2] ^= 0xffff;\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
} else {\r
unsigned char *p = (unsigned char *)g_screen_ptr + offs;\r
+ int o = (up ? 0xe0 : 0xf0), _ = (up ? 0xf0 : 0xe0);\r
\r
- p[-1] = 0xe0; p[0] = 0xf0; p[1] = 0xe0;\r
- p[pitch-1] = 0xf0; p[pitch] = 0xf0; p[pitch+1] = 0xf0;\r
- p[2*pitch-1] = 0xe0; p[2*pitch] = 0xf0; p[2*pitch+1] = 0xe0;\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
}\r
}\r
\r
static unsigned audio_latency = 0;
static bool update_audio_latency = false;
static uint16_t pico_events;
-int pico_inp_mode;
+int pico_inp_mode, pico_pen_visible;
int pico_pen_x = 320/2, pico_pen_y = 240/2;
static void retro_audio_buff_status_cb(
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Red Button" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Pen Button" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT,"Switch input" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Pen sensor" },
+ { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Pen visibility" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "Previous page" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Next page" },
environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, &rmsg);
}
+static void draw_pico_ptr(void)
+{
+ int up = (PicoPicohw.pen_pos[0]|PicoPicohw.pen_pos[1]) & 0x8000;
+ int x, y, pitch = vout_width, offs;
+ unsigned short *p = (unsigned short *)((char *)vout_buf + vout_offset);
+ int o = (up ? 0x0000 : 0xffff), _ = (up ? 0xffff : 0x0000);
+
+ x = ((pico_pen_x * vout_width * ((1ULL<<32) / 320 + 1)) >> 32);
+ y = ((pico_pen_y * vout_height * ((1ULL<<32) / 224 + 1)) >> 32);
+ p += x + y * pitch;
+
+ 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] ^= _;
+}
+
void run_events_pico(unsigned int events)
{
int lim_x;
switch (pico_inp_mode) {
case 2: emu_status_msg("Input: Pen on Pad"); break;
case 1: emu_status_msg("Input: Pen on Storyware"); break;
- case 0: emu_status_msg("Input: Joystick");
- PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000;
- break;
+ case 0: emu_status_msg("Input: Joystick"); break;
}
+ PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000;
}
if (events & (1 << RETRO_DEVICE_ID_JOYPAD_L)) {
PicoPicohw.page--;
PicoPicohw.page = 6;
emu_status_msg("Page %i", PicoPicohw.page);
}
+ if (events & (1 << RETRO_DEVICE_ID_JOYPAD_X)) {
+ pico_pen_visible = !pico_pen_visible;
+ emu_status_msg("%s Pen", pico_pen_visible ? "Show" : "Hide");
+ }
+ if (events & (1 << RETRO_DEVICE_ID_JOYPAD_START)) {
+ PicoPicohw.pen_pos[0] ^= 0x8000;
+ PicoPicohw.pen_pos[1] ^= 0x8000;
+ emu_status_msg("Pen %s", PicoPicohw.pen_pos[0] & 0x8000 ? "Up" : "Down");
+ }
if (pico_inp_mode == 0)
return;
if (PicoIn.pad[0] & 8) pico_pen_x++;
PicoIn.pad[0] &= ~0x0f; // release UDLR
- lim_x = (Pico.video.reg[12]&1) ? 319 : 255;
if (pico_pen_y < PICO_PEN_ADJUST_Y)
pico_pen_y = PICO_PEN_ADJUST_Y;
- if (pico_pen_y > 224 - PICO_PEN_ADJUST_Y)
- pico_pen_y = 224 - PICO_PEN_ADJUST_Y;
+ if (pico_pen_y > 224-1 - PICO_PEN_ADJUST_Y)
+ pico_pen_y = 224-1 - PICO_PEN_ADJUST_Y;
if (pico_pen_x < PICO_PEN_ADJUST_X)
pico_pen_x = PICO_PEN_ADJUST_X;
- if (pico_pen_x > lim_x - PICO_PEN_ADJUST_X)
- pico_pen_x = lim_x - PICO_PEN_ADJUST_X;
+ if (pico_pen_x > 320-1 - PICO_PEN_ADJUST_X)
+ pico_pen_x = 320-1 - PICO_PEN_ADJUST_X;
- PicoPicohw.pen_pos[0] = pico_pen_x;
- if (!(Pico.video.reg[12] & 1))
- PicoPicohw.pen_pos[0] += pico_pen_x / 4;
- PicoPicohw.pen_pos[0] += 0x3c;
- PicoPicohw.pen_pos[1] = pico_inp_mode == 1 ? (0x2f8 + pico_pen_y) : (0x1fc + pico_pen_y);
+ PicoPicohw.pen_pos[0] &= 0x8000;
+ PicoPicohw.pen_pos[1] &= 0x8000;
+ PicoPicohw.pen_pos[0] |= 0x3c + pico_pen_x;
+ PicoPicohw.pen_pos[1] |= (pico_inp_mode == 1 ? 0x2f8 : 0x1fc) + pico_pen_y;
}
void retro_run(void)
PicoIn.pad[pad] |= retro_pico_map[i];
if (PicoIn.AHW == PAHW_PICO) {
- uint16_t ev = input[0] & ((1 << RETRO_DEVICE_ID_JOYPAD_L) | (1 << RETRO_DEVICE_ID_JOYPAD_R) | (1 << RETRO_DEVICE_ID_JOYPAD_SELECT));
+ uint16_t ev = input[0] &
+ ((1 << RETRO_DEVICE_ID_JOYPAD_L) | (1 << RETRO_DEVICE_ID_JOYPAD_R) |
+ (1 << RETRO_DEVICE_ID_JOYPAD_X) | (1 << RETRO_DEVICE_ID_JOYPAD_SELECT) |
+ (1 << RETRO_DEVICE_ID_JOYPAD_START));
uint16_t new_ev = ev & ~pico_events;
pico_events = ev;
run_events_pico(new_ev);
}
}
+ if ((PicoIn.AHW & PAHW_PICO) && pico_pen_visible)
+ if (pico_inp_mode) draw_pico_ptr();
+
buff = (char*)vout_buf + vout_offset;
#endif
\r
static void draw_pico_ptr(void)\r
{\r
+ int up = (PicoPicohw.pen_pos[0]|PicoPicohw.pen_pos[1]) & 0x8000;\r
+ int o = (up ? 0x0000 : 0xffff), _ = (up ? 0xffff : 0x0000);\r
int pitch = g_screen_ppitch;\r
u16 *p = g_screen_ptr;\r
int x = pico_pen_x, y = pico_pen_y;\r
\r
- x = (x * out_w * ((1ULL<<32) / 320)) >> 32;\r
- y = (y * out_h * ((1ULL<<32) / 224)) >> 32;\r
+ x = (x * out_w * ((1ULL<<32) / 320 + 1)) >> 32;\r
+ y = (y * out_h * ((1ULL<<32) / 224 + 1)) >> 32;\r
p += (screen_y+y)*pitch + (screen_x+x);\r
\r
- p[-pitch] ^= 0xffff;\r
- p[-1] ^= 0xffff; p[0] ^= 0xffff; p[1] ^= 0xffff;\r
- p[pitch] ^= 0xffff;\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
}\r
\r
/* render/screen buffer handling:\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_PEN },\r
+ { KEY_8, IN_BINDTYPE_EMU, PEVB_PICO_SHPEN },\r
+ { KEY_9, IN_BINDTYPE_EMU, PEVB_PICO_PPOSV },\r
{ 0, 0, 0 }\r
};\r
\r
\r
static void draw_pico_ptr(void)\r
{\r
+ int up = (PicoPicohw.pen_pos[0]|PicoPicohw.pen_pos[1]) & 0x8000;\r
+ 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
\r
- x = (x * saved_col_count * ((1ULL<<32) / 320)) >> 32;\r
- y = (y * saved_line_count * ((1ULL<<32) / 224)) >> 32;\r
+ x = (x * saved_col_count * ((1ULL<<32) / 320 + 1)) >> 32;\r
+ y = (y * saved_line_count * ((1ULL<<32) / 224 + 1)) >> 32;\r
p += (saved_start_col+x) + (saved_start_line+y) * pitch;\r
\r
- p[-pitch] ^= 0xffff;\r
- p[-1] ^= 0xffff; p[0] ^= 0xffff; p[1] ^= 0xffff;\r
- p[pitch] ^= 0xffff;\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
}\r
\r
void pemu_finalize_frame(const char *fps, const char *notice)\r
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 pp = g_screen_ppitch;
+ int pitch = g_screen_ppitch;
- x = (x * out_w * ((1ULL<<32) / 320)) >> 32;
- y = (y * out_h * ((1ULL<<32) / 224)) >> 32;
+ x = (x * out_w * ((1ULL<<32) / 320 + 1)) >> 32;
+ y = (y * out_h * ((1ULL<<32) / 224 + 1)) >> 32;
- offs = g_screen_ppitch * (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 : 0x7fff), _ = (up ? 0x7fff : 0x0000);
- p[ -1] = 0x0000; p[ 0] = 0x001f; p[ 1] = 0x0000;
- p[ pp-1] = 0x001f; p[ pp] = 0x001f; p[ pp+1] = 0x001f;
- p[2*pp-1] = 0x0000; p[2*pp] = 0x001f; p[2*pp+1] = 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] ^= _;
} else {
unsigned char *p = (unsigned char *)g_screen_ptr + offs + 8;
+ int o = (up ? 0xe0 : 0xf0), _ = (up ? 0xf0 : 0xe0);
- p[ -1] = 0xe0; p[ 0] = 0xf0; p[ 1] = 0xe0;
- p[ pp-1] = 0xf0; p[ pp] = 0xf0; p[ pp+1] = 0xf0;
- p[2*pp-1] = 0xe0; p[2*pp] = 0xf0; p[2*pp+1] = 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] = _;
}
}
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;
- x = (x * out_w * ((1ULL<<32) / 320)) >> 32;
- y = (y * out_h * ((1ULL<<32) / 224)) >> 32;
+ x = (x * out_w * ((1ULL<<32) / 320 + 1)) >> 32;
+ y = (y * out_h * ((1ULL<<32) / 224 + 1)) >> 32;
offs = 512 * (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[ -1] = 0x0000; p[ 0] = 0x001f; p[ 1] = 0x0000;
- p[ 511] = 0x001f; p[ 512] = 0x001f; p[ 513] = 0x001f;
- p[1023] = 0x0000; p[1024] = 0x001f; p[1025] = 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] ^= _;
} else {
unsigned char *p = (unsigned char *)g_screen_ptr + offs + 8;
+ int o = (up ? 0xe0 : 0xf0), _ = (up ? 0xf0 : 0xe0);
- p[ -1] = 0xe0; p[ 0] = 0xf0; p[ 1] = 0xe0;
- p[ 511] = 0xf0; p[ 512] = 0xf0; p[ 513] = 0xf0;
- p[1023] = 0xe0; p[1024] = 0xf0; p[1025] = 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] = _;
}
}