From 2cb51c3c621ed60e192e8342fdeb4225def91bd8 Mon Sep 17 00:00:00 2001 From: notaz Date: Wed, 21 May 2008 19:08:10 +0000 Subject: [PATCH] win32 Pico mostly finished git-svn-id: file:///home/notaz/opt/svn/PicoDrive@452 be3aeb3a-fb24-0410-a615-afba39da0efa --- platform/win32/GenaDrive/Direct.cpp | 4 ++- platform/win32/GenaDrive/Emu.cpp | 4 +-- platform/win32/GenaDrive/Main.cpp | 47 ++++++++++++++++++++++------- platform/win32/GenaDrive/app.h | 2 +- 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/platform/win32/GenaDrive/Direct.cpp b/platform/win32/GenaDrive/Direct.cpp index 38c2bd8c..3c8f3769 100644 --- a/platform/win32/GenaDrive/Direct.cpp +++ b/platform/win32/GenaDrive/Direct.cpp @@ -160,7 +160,9 @@ static int DirectClearDDraw(unsigned int colour) static int DirectPresentDDraw() { - int ret = m_pddsFrontBuffer->Blt(&FrameRectMy, m_pddsBackBuffer, &EmuScreenRect, DDBLT_WAIT, NULL); + int ret = 0; + if (FrameRectMy.right - FrameRectMy.left > 0 && FrameRectMy.bottom - FrameRectMy.top > 0) + ret = m_pddsFrontBuffer->Blt(&FrameRectMy, m_pddsBackBuffer, &EmuScreenRect, DDBLT_WAIT, NULL); if (ret) { LOGFAIL(); return 1; } return 0; } diff --git a/platform/win32/GenaDrive/Emu.cpp b/platform/win32/GenaDrive/Emu.cpp index 75323533..46fa27ab 100644 --- a/platform/win32/GenaDrive/Emu.cpp +++ b/platform/win32/GenaDrive/Emu.cpp @@ -4,7 +4,7 @@ unsigned short *EmuScreen=NULL; int EmuWidth=320,EmuHeight=224; RECT EmuScreenRect = { 0, 0, 320, 224 }; -int picohw_pen_pressed = 0; +int PicoPadAdd = 0; static int EmuScan(unsigned int num); unsigned char *PicoDraw2FB = NULL; @@ -59,7 +59,7 @@ int EmuFrame() } PicoPad[0]=input; - if (picohw_pen_pressed) PicoPad[0] |= 0x20; + PicoPad[0]|=PicoPadAdd; PsndOut=(short *)DSoundNext; PicoFrame(); diff --git a/platform/win32/GenaDrive/Main.cpp b/platform/win32/GenaDrive/Main.cpp index a25d89f2..b54c8e4f 100644 --- a/platform/win32/GenaDrive/Main.cpp +++ b/platform/win32/GenaDrive/Main.cpp @@ -15,7 +15,7 @@ int MainWidth=720,MainHeight=480; static HMENU mmain = 0, mdisplay = 0, mpicohw = 0; static int rom_loaded = 0; static HBITMAP ppad_bmp = 0; -static HBITMAP ppage_bmps[6] = { 0, }; +static HBITMAP ppage_bmps[7] = { 0, }; static char rom_name[0x20*3+1]; static void UpdateRect() @@ -103,7 +103,7 @@ static void PrepareForROM(unsigned char *rom_data) PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000; - picohw_pen_pressed = 0; + PicoPadAdd = 0; ret = extract_rom_name(rom_name, rom_data + 0x150, 0x20); if (ret == 0) @@ -121,7 +121,7 @@ static void PrepareForROM(unsigned char *rom_data) ppad_bmp = png2hb(path, 0); } - for (i = 0; i < 6; i++) { + for (i = 0; i < 7; i++) { if (ppage_bmps[i] != NULL) DeleteObject(ppage_bmps[i]); sprintf(p, "pico\\%s_%i.png", rom_name, i); ppage_bmps[i] = png2hb(path, 1); @@ -267,13 +267,35 @@ static LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam) if (PtInRect(&rc, pt)) break; PicoPicohw.pen_pos[0] |= 0x8000; PicoPicohw.pen_pos[1] |= 0x8000; - picohw_pen_pressed = 0; + PicoPadAdd = 0; break; } return DefWindowProc(hwnd,msg,wparam,lparam); } +static void key_down(WPARAM key) +{ + switch (key) { + case VK_LEFT: PicoPadAdd |= 4; break; + case VK_RIGHT: PicoPadAdd |= 8; break; + case VK_UP: PicoPadAdd |= 1; break; + case VK_DOWN: PicoPadAdd |= 2; break; + case 'X': PicoPadAdd |= 0x10; break; + } +} + +static void key_up(WPARAM key) +{ + switch (key) { + case VK_LEFT: PicoPadAdd &= ~0x04; break; + case VK_RIGHT: PicoPadAdd &= ~0x08; break; + case VK_UP: PicoPadAdd &= ~0x01; break; + case VK_DOWN: PicoPadAdd &= ~0x02; break; + case 'X': PicoPadAdd &= ~0x10; break; + } +} + static LRESULT CALLBACK PicoSwWndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam) { PAINTSTRUCT ps; @@ -281,15 +303,17 @@ static LRESULT CALLBACK PicoSwWndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lp switch (msg) { - case WM_CLOSE: return 0; case WM_DESTROY: PicoSwWnd=NULL; break; - case WM_LBUTTONDOWN: picohw_pen_pressed = 1; return 0; - case WM_LBUTTONUP: picohw_pen_pressed = 0; return 0; + case WM_LBUTTONDOWN: PicoPadAdd |= 0x20; return 0; + case WM_LBUTTONUP: PicoPadAdd &= ~0x20; return 0; case WM_MOUSEMOVE: + if (HIWORD(lparam) < 0x20) break; PicoPicohw.pen_pos[0] = 0x03c + LOWORD(lparam) * 2/3; - PicoPicohw.pen_pos[1] = 0x2f8 + HIWORD(lparam); + PicoPicohw.pen_pos[1] = 0x2f8 + HIWORD(lparam) - 0x20; SetTimer(FrameWnd, 100, 1000, NULL); break; + case WM_KEYDOWN: key_down(wparam); break; + case WM_KEYUP: key_up(wparam); break; case WM_PAINT: hdc = BeginPaint(hwnd, &ps); if (ppage_bmps[PicoPicohw.page] == NULL) @@ -321,15 +345,16 @@ static LRESULT CALLBACK PicoPadWndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM l switch (msg) { - case WM_CLOSE: return 0; case WM_DESTROY: PicoPadWnd=NULL; break; - case WM_LBUTTONDOWN: picohw_pen_pressed = 1; return 0; - case WM_LBUTTONUP: picohw_pen_pressed = 0; return 0; + case WM_LBUTTONDOWN: PicoPadAdd |= 0x20; return 0; + case WM_LBUTTONUP: PicoPadAdd &= ~0x20; return 0; case WM_MOUSEMOVE: PicoPicohw.pen_pos[0] = 0x03c + LOWORD(lparam); PicoPicohw.pen_pos[1] = 0x1fc + HIWORD(lparam); SetTimer(FrameWnd, 100, 1000, NULL); break; + case WM_KEYDOWN: key_down(wparam); break; + case WM_KEYUP: key_up(wparam); break; case WM_PAINT: if (ppad_bmp == NULL) break; hdc = BeginPaint(hwnd, &ps); diff --git a/platform/win32/GenaDrive/app.h b/platform/win32/GenaDrive/app.h index 65ed5420..30d59cb7 100644 --- a/platform/win32/GenaDrive/app.h +++ b/platform/win32/GenaDrive/app.h @@ -24,7 +24,7 @@ extern unsigned short *EmuScreen; extern int EmuWidth,EmuHeight; extern RECT EmuScreenRect; -extern int picohw_pen_pressed; +extern int PicoPadAdd; int EmuInit(); void EmuExit(); int EmuRomLoad(char *name); -- 2.39.5