static HMENU mmain = 0, mdisplay = 0, mpicohw = 0;\r
static int rom_loaded = 0;\r
static HBITMAP ppad_bmp = 0;\r
-static HBITMAP ppage_bmps[6] = { 0, };\r
+static HBITMAP ppage_bmps[7] = { 0, };\r
static char rom_name[0x20*3+1];\r
\r
static void UpdateRect()\r
\r
PicoPicohw.pen_pos[0] =\r
PicoPicohw.pen_pos[1] = 0x8000;\r
- picohw_pen_pressed = 0;\r
+ PicoPadAdd = 0;\r
\r
ret = extract_rom_name(rom_name, rom_data + 0x150, 0x20);\r
if (ret == 0)\r
ppad_bmp = png2hb(path, 0);\r
}\r
\r
- for (i = 0; i < 6; i++) {\r
+ for (i = 0; i < 7; i++) {\r
if (ppage_bmps[i] != NULL) DeleteObject(ppage_bmps[i]);\r
sprintf(p, "pico\\%s_%i.png", rom_name, i);\r
ppage_bmps[i] = png2hb(path, 1);\r
if (PtInRect(&rc, pt)) break;\r
PicoPicohw.pen_pos[0] |= 0x8000;\r
PicoPicohw.pen_pos[1] |= 0x8000;\r
- picohw_pen_pressed = 0;\r
+ PicoPadAdd = 0;\r
break;\r
}\r
\r
return DefWindowProc(hwnd,msg,wparam,lparam);\r
}\r
\r
+static void key_down(WPARAM key)\r
+{\r
+ switch (key) {\r
+ case VK_LEFT: PicoPadAdd |= 4; break;\r
+ case VK_RIGHT: PicoPadAdd |= 8; break;\r
+ case VK_UP: PicoPadAdd |= 1; break;\r
+ case VK_DOWN: PicoPadAdd |= 2; break;\r
+ case 'X': PicoPadAdd |= 0x10; break;\r
+ }\r
+}\r
+\r
+static void key_up(WPARAM key)\r
+{\r
+ switch (key) {\r
+ case VK_LEFT: PicoPadAdd &= ~0x04; break;\r
+ case VK_RIGHT: PicoPadAdd &= ~0x08; break;\r
+ case VK_UP: PicoPadAdd &= ~0x01; break;\r
+ case VK_DOWN: PicoPadAdd &= ~0x02; break;\r
+ case 'X': PicoPadAdd &= ~0x10; break;\r
+ }\r
+}\r
+\r
static LRESULT CALLBACK PicoSwWndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)\r
{\r
PAINTSTRUCT ps;\r
\r
switch (msg)\r
{\r
- case WM_CLOSE: return 0;\r
case WM_DESTROY: PicoSwWnd=NULL; break;\r
- case WM_LBUTTONDOWN: picohw_pen_pressed = 1; return 0;\r
- case WM_LBUTTONUP: picohw_pen_pressed = 0; return 0;\r
+ case WM_LBUTTONDOWN: PicoPadAdd |= 0x20; return 0;\r
+ case WM_LBUTTONUP: PicoPadAdd &= ~0x20; return 0;\r
case WM_MOUSEMOVE:\r
+ if (HIWORD(lparam) < 0x20) break;\r
PicoPicohw.pen_pos[0] = 0x03c + LOWORD(lparam) * 2/3;\r
- PicoPicohw.pen_pos[1] = 0x2f8 + HIWORD(lparam);\r
+ PicoPicohw.pen_pos[1] = 0x2f8 + HIWORD(lparam) - 0x20;\r
SetTimer(FrameWnd, 100, 1000, NULL);\r
break;\r
+ case WM_KEYDOWN: key_down(wparam); break;\r
+ case WM_KEYUP: key_up(wparam); break;\r
case WM_PAINT:\r
hdc = BeginPaint(hwnd, &ps);\r
if (ppage_bmps[PicoPicohw.page] == NULL)\r
\r
switch (msg)\r
{\r
- case WM_CLOSE: return 0;\r
case WM_DESTROY: PicoPadWnd=NULL; break;\r
- case WM_LBUTTONDOWN: picohw_pen_pressed = 1; return 0;\r
- case WM_LBUTTONUP: picohw_pen_pressed = 0; return 0;\r
+ case WM_LBUTTONDOWN: PicoPadAdd |= 0x20; return 0;\r
+ case WM_LBUTTONUP: PicoPadAdd &= ~0x20; return 0;\r
case WM_MOUSEMOVE:\r
PicoPicohw.pen_pos[0] = 0x03c + LOWORD(lparam);\r
PicoPicohw.pen_pos[1] = 0x1fc + HIWORD(lparam);\r
SetTimer(FrameWnd, 100, 1000, NULL);\r
break;\r
+ case WM_KEYDOWN: key_down(wparam); break;\r
+ case WM_KEYUP: key_up(wparam); break;\r
case WM_PAINT:\r
if (ppad_bmp == NULL) break;\r
hdc = BeginPaint(hwnd, &ps);\r