mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
win32 Pico work nearly done
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@450 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
42989e7d7e
commit
8f7ed1b8e1
6 changed files with 142 additions and 16 deletions
|
@ -47,7 +47,7 @@ int DSoundInit()
|
||||||
// Make buffer for the next seg to put into the loop:
|
// Make buffer for the next seg to put into the loop:
|
||||||
DSoundNext=(short *)malloc((PsndLen<<2)+64); if (DSoundNext==NULL) return 1;
|
DSoundNext=(short *)malloc((PsndLen<<2)+64); if (DSoundNext==NULL) return 1;
|
||||||
memset(DSoundNext,0,PsndLen<<2);
|
memset(DSoundNext,0,PsndLen<<2);
|
||||||
// dprintf2("p %p\n", DSoundNext);
|
// lprintf("p %p\n", DSoundNext);
|
||||||
|
|
||||||
// Create the DirectSound interface:
|
// Create the DirectSound interface:
|
||||||
DirectSoundCreate(NULL,&DSound,NULL);
|
DirectSoundCreate(NULL,&DSound,NULL);
|
||||||
|
@ -91,14 +91,14 @@ static int WriteSeg()
|
||||||
|
|
||||||
// Lock the segment at 'LoopWrite' and copy the next segment in
|
// Lock the segment at 'LoopWrite' and copy the next segment in
|
||||||
ret = LoopBuffer->Lock(LoopWrite<<((PicoOpt&8) ? 2 : 1),PsndLen<<((PicoOpt&8) ? 2 : 1), &mema,&sizea, &memb,&sizeb, 0);
|
ret = LoopBuffer->Lock(LoopWrite<<((PicoOpt&8) ? 2 : 1),PsndLen<<((PicoOpt&8) ? 2 : 1), &mema,&sizea, &memb,&sizeb, 0);
|
||||||
if (ret) dprintf2("LoopBuffer->Lock() failed: %i\n", ret);
|
if (ret) lprintf("LoopBuffer->Lock() failed: %i\n", ret);
|
||||||
|
|
||||||
if (mema) memcpy(mema,DSoundNext,sizea);
|
if (mema) memcpy(mema,DSoundNext,sizea);
|
||||||
// if (memb) memcpy(memb,DSoundNext+sizea,sizeb);
|
// if (memb) memcpy(memb,DSoundNext+sizea,sizeb);
|
||||||
if (sizeb != 0) dprintf2("sizeb is not 0! (%i)\n", sizeb);
|
if (sizeb != 0) lprintf("sizeb is not 0! (%i)\n", sizeb);
|
||||||
|
|
||||||
ret = LoopBuffer->Unlock(mema,sizea, memb,0);
|
ret = LoopBuffer->Unlock(mema,sizea, memb,0);
|
||||||
if (ret) dprintf2("LoopBuffer->Unlock() failed: %i\n", ret);
|
if (ret) lprintf("LoopBuffer->Unlock() failed: %i\n", ret);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ static int DirectScreenDDraw()
|
||||||
ret = m_pddsBackBuffer->Lock(NULL, &sd, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WAIT|DDLOCK_WRITEONLY, NULL);
|
ret = m_pddsBackBuffer->Lock(NULL, &sd, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WAIT|DDLOCK_WRITEONLY, NULL);
|
||||||
if (ret) { LOGFAIL(); return 1; }
|
if (ret) { LOGFAIL(); return 1; }
|
||||||
|
|
||||||
//dprintf2("w: %i h: %i pi: %i pf: %i\n", sd.dwWidth, sd.dwHeight, sd.lPitch, sd.ddpfPixelFormat.dwRGBBitCount);
|
//lprintf("w: %i h: %i pi: %i pf: %i\n", sd.dwWidth, sd.dwHeight, sd.lPitch, sd.ddpfPixelFormat.dwRGBBitCount);
|
||||||
|
|
||||||
if (sd.ddpfPixelFormat.dwRGBBitCount == 32)
|
if (sd.ddpfPixelFormat.dwRGBBitCount == 32)
|
||||||
{
|
{
|
||||||
|
@ -388,7 +388,7 @@ int DirectScreen()
|
||||||
TexScreenSwizzle();
|
TexScreenSwizzle();
|
||||||
#else
|
#else
|
||||||
ret=TexScreenLinear();
|
ret=TexScreenLinear();
|
||||||
if (ret) dprintf2("TexScreenLinear failed\n");
|
if (ret) lprintf("TexScreenLinear failed\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetupMatrices();
|
SetupMatrices();
|
||||||
|
@ -397,7 +397,7 @@ int DirectScreen()
|
||||||
|
|
||||||
// Copy vertices in:
|
// Copy vertices in:
|
||||||
VertexBuffer->Lock(0,sizeof(VertexList),&lock,0);
|
VertexBuffer->Lock(0,sizeof(VertexList),&lock,0);
|
||||||
if (lock==NULL) { dprintf2("VertexBuffer->Lock failed\n"); return 1; }
|
if (lock==NULL) { lprintf("VertexBuffer->Lock failed\n"); return 1; }
|
||||||
memcpy(lock,VertexList,sizeof(VertexList));
|
memcpy(lock,VertexList,sizeof(VertexList));
|
||||||
VertexBuffer->Unlock();
|
VertexBuffer->Unlock();
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ extern "C" int dprintf(char *format, ...)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern "C" int dprintf2(char *format, ...)
|
extern "C" int lprintf(char *format, ...)
|
||||||
{
|
{
|
||||||
char str[512];
|
char str[512];
|
||||||
va_list val=NULL;
|
va_list val=NULL;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include <crtdbg.h>
|
#include <crtdbg.h>
|
||||||
#include <commdlg.h>
|
#include <commdlg.h>
|
||||||
|
#include "../../common/readpng.h"
|
||||||
|
|
||||||
char *romname=NULL;
|
char *romname=NULL;
|
||||||
HWND FrameWnd=NULL;
|
HWND FrameWnd=NULL;
|
||||||
|
@ -13,6 +14,9 @@ int MainWidth=720,MainHeight=480;
|
||||||
|
|
||||||
static HMENU mmain = 0, mdisplay = 0, mpicohw = 0;
|
static HMENU mmain = 0, mdisplay = 0, mpicohw = 0;
|
||||||
static int rom_loaded = 0;
|
static int rom_loaded = 0;
|
||||||
|
static HBITMAP ppad_bmp = 0;
|
||||||
|
static HBITMAP ppage_bmps[6] = { 0, };
|
||||||
|
static char rom_name[0x20*3+1];
|
||||||
|
|
||||||
static void UpdateRect()
|
static void UpdateRect()
|
||||||
{
|
{
|
||||||
|
@ -23,9 +27,71 @@ static void UpdateRect()
|
||||||
FrameRectMy = wi.rcClient;
|
FrameRectMy = wi.rcClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PrepareFroROM()
|
static int extract_rom_name(char *dest, const unsigned char *src, int len)
|
||||||
{
|
{
|
||||||
int show = PicoAHW & PAHW_PICO;
|
char *p = dest, s_old = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = len - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if (src[i^1] != ' ') break;
|
||||||
|
}
|
||||||
|
len = i + 1;
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
unsigned char s = src[i^1];
|
||||||
|
if (s == 0x20 && s_old == 0x20) continue;
|
||||||
|
else if (s >= 0x20 && s < 0x7f && s != '%')
|
||||||
|
{
|
||||||
|
*p++ = s;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf(p, "%%%02x", s);
|
||||||
|
p += 3;
|
||||||
|
}
|
||||||
|
s_old = s;
|
||||||
|
}
|
||||||
|
*p = 0;
|
||||||
|
|
||||||
|
return p - dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static HBITMAP png2hb(const char *fname, int is_480)
|
||||||
|
{
|
||||||
|
BITMAPINFOHEADER bih;
|
||||||
|
HBITMAP bmp;
|
||||||
|
void *bmem;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
bmem = calloc(1, is_480 ? 480*240*3 : 320*240*3);
|
||||||
|
if (bmem == NULL) return NULL;
|
||||||
|
ret = readpng(bmem, fname, is_480 ? READPNG_480_24 : READPNG_320_24);
|
||||||
|
if (ret != 0) {
|
||||||
|
free(bmem);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&bih, 0, sizeof(bih));
|
||||||
|
bih.biSize = sizeof(bih);
|
||||||
|
bih.biWidth = is_480 ? 480 : 320;
|
||||||
|
bih.biHeight = -240;
|
||||||
|
bih.biPlanes = 1;
|
||||||
|
bih.biBitCount = 24;
|
||||||
|
bih.biCompression = BI_RGB;
|
||||||
|
bmp = CreateDIBitmap(GetDC(FrameWnd), &bih, CBM_INIT, bmem, (BITMAPINFO *)&bih, 0);
|
||||||
|
if (bmp == NULL)
|
||||||
|
lprintf("CreateDIBitmap failed with %i", GetLastError());
|
||||||
|
|
||||||
|
free(bmem);
|
||||||
|
return bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PrepareForROM(unsigned char *rom_data)
|
||||||
|
{
|
||||||
|
int i, ret, show = PicoAHW & PAHW_PICO;
|
||||||
EnableMenuItem(mmain, 2, MF_BYPOSITION|(show ? MF_ENABLED : MF_GRAYED));
|
EnableMenuItem(mmain, 2, MF_BYPOSITION|(show ? MF_ENABLED : MF_GRAYED));
|
||||||
ShowWindow(PicoPadWnd, show ? SW_SHOWNA : SW_HIDE);
|
ShowWindow(PicoPadWnd, show ? SW_SHOWNA : SW_HIDE);
|
||||||
ShowWindow(PicoSwWnd, show ? SW_SHOWNA : SW_HIDE);
|
ShowWindow(PicoSwWnd, show ? SW_SHOWNA : SW_HIDE);
|
||||||
|
@ -33,10 +99,34 @@ static void PrepareFroROM()
|
||||||
CheckMenuItem(mpicohw, 1211, show ? MF_CHECKED : MF_UNCHECKED);
|
CheckMenuItem(mpicohw, 1211, show ? MF_CHECKED : MF_UNCHECKED);
|
||||||
PostMessage(FrameWnd, WM_COMMAND, 1220 + PicoPicohw.page, 0);
|
PostMessage(FrameWnd, WM_COMMAND, 1220 + PicoPicohw.page, 0);
|
||||||
DrawMenuBar(FrameWnd);
|
DrawMenuBar(FrameWnd);
|
||||||
|
InvalidateRect(PicoSwWnd, NULL, 1);
|
||||||
|
|
||||||
PicoPicohw.pen_pos[0] =
|
PicoPicohw.pen_pos[0] =
|
||||||
PicoPicohw.pen_pos[1] = 0x8000;
|
PicoPicohw.pen_pos[1] = 0x8000;
|
||||||
picohw_pen_pressed = 0;
|
picohw_pen_pressed = 0;
|
||||||
|
|
||||||
|
ret = extract_rom_name(rom_name, rom_data + 0x150, 0x20);
|
||||||
|
if (ret == 0)
|
||||||
|
extract_rom_name(rom_name, rom_data + 0x130, 0x20);
|
||||||
|
|
||||||
|
if (show)
|
||||||
|
{
|
||||||
|
char path[MAX_PATH], *p;
|
||||||
|
GetModuleFileName(NULL, path, sizeof(path) - 32);
|
||||||
|
p = strrchr(path, '\\');
|
||||||
|
if (p == NULL) p = path;
|
||||||
|
else p++;
|
||||||
|
if (ppad_bmp == NULL) {
|
||||||
|
strcpy(p, "pico\\pad.png");
|
||||||
|
ppad_bmp = png2hb(path, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < 6; 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadROM(const char *cmdpath)
|
static void LoadROM(const char *cmdpath)
|
||||||
|
@ -83,7 +173,7 @@ static void LoadROM(const char *cmdpath)
|
||||||
PicoCartUnload();
|
PicoCartUnload();
|
||||||
PicoCartInsert(rom_data_new, rom_size);
|
PicoCartInsert(rom_data_new, rom_size);
|
||||||
|
|
||||||
PrepareFroROM();
|
PrepareForROM(rom_data_new);
|
||||||
|
|
||||||
rom_loaded = 1;
|
rom_loaded = 1;
|
||||||
romname = rompath;
|
romname = rompath;
|
||||||
|
@ -152,6 +242,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
|
||||||
for (i = 0; i < 7; i++)
|
for (i = 0; i < 7; i++)
|
||||||
CheckMenuItem(mpicohw, 1220 + i, MF_UNCHECKED);
|
CheckMenuItem(mpicohw, 1220 + i, MF_UNCHECKED);
|
||||||
CheckMenuItem(mpicohw, 1220 + PicoPicohw.page, MF_CHECKED);
|
CheckMenuItem(mpicohw, 1220 + PicoPicohw.page, MF_CHECKED);
|
||||||
|
InvalidateRect(PicoSwWnd, NULL, 1);
|
||||||
return 0;
|
return 0;
|
||||||
case 1300:
|
case 1300:
|
||||||
MessageBox(FrameWnd, "PicoDrive v" VERSION " (c) notaz, 2006-2008\n"
|
MessageBox(FrameWnd, "PicoDrive v" VERSION " (c) notaz, 2006-2008\n"
|
||||||
|
@ -185,6 +276,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
|
||||||
|
|
||||||
static LRESULT CALLBACK PicoSwWndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
|
static LRESULT CALLBACK PicoSwWndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
|
||||||
{
|
{
|
||||||
|
PAINTSTRUCT ps;
|
||||||
|
HDC hdc, hdc2;
|
||||||
|
|
||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
case WM_CLOSE: return 0;
|
case WM_CLOSE: return 0;
|
||||||
|
@ -196,6 +290,25 @@ static LRESULT CALLBACK PicoSwWndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lp
|
||||||
PicoPicohw.pen_pos[1] = 0x2f8 + HIWORD(lparam);
|
PicoPicohw.pen_pos[1] = 0x2f8 + HIWORD(lparam);
|
||||||
SetTimer(FrameWnd, 100, 1000, NULL);
|
SetTimer(FrameWnd, 100, 1000, NULL);
|
||||||
break;
|
break;
|
||||||
|
case WM_PAINT:
|
||||||
|
hdc = BeginPaint(hwnd, &ps);
|
||||||
|
if (ppage_bmps[PicoPicohw.page] == NULL)
|
||||||
|
{
|
||||||
|
SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
|
||||||
|
SetTextColor(hdc, RGB(255, 255, 255));
|
||||||
|
SetBkColor(hdc, RGB(0, 0, 0));
|
||||||
|
TextOut(hdc, 2, 2, "missing PNGs for", 16);
|
||||||
|
TextOut(hdc, 2, 18, rom_name, strlen(rom_name));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hdc2 = CreateCompatibleDC(GetDC(FrameWnd));
|
||||||
|
SelectObject(hdc2, ppage_bmps[PicoPicohw.page]);
|
||||||
|
BitBlt(hdc, 0, 0, 480, 240, hdc2, 0, 0, SRCCOPY);
|
||||||
|
DeleteDC(hdc2);
|
||||||
|
}
|
||||||
|
EndPaint(hwnd, &ps);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(hwnd,msg,wparam,lparam);
|
return DefWindowProc(hwnd,msg,wparam,lparam);
|
||||||
|
@ -203,6 +316,9 @@ static LRESULT CALLBACK PicoSwWndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lp
|
||||||
|
|
||||||
static LRESULT CALLBACK PicoPadWndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
|
static LRESULT CALLBACK PicoPadWndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
|
||||||
{
|
{
|
||||||
|
PAINTSTRUCT ps;
|
||||||
|
HDC hdc, hdc2;
|
||||||
|
|
||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
case WM_CLOSE: return 0;
|
case WM_CLOSE: return 0;
|
||||||
|
@ -214,6 +330,15 @@ static LRESULT CALLBACK PicoPadWndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM l
|
||||||
PicoPicohw.pen_pos[1] = 0x1fc + HIWORD(lparam);
|
PicoPicohw.pen_pos[1] = 0x1fc + HIWORD(lparam);
|
||||||
SetTimer(FrameWnd, 100, 1000, NULL);
|
SetTimer(FrameWnd, 100, 1000, NULL);
|
||||||
break;
|
break;
|
||||||
|
case WM_PAINT:
|
||||||
|
if (ppad_bmp == NULL) break;
|
||||||
|
hdc = BeginPaint(hwnd, &ps);
|
||||||
|
hdc2 = CreateCompatibleDC(GetDC(FrameWnd));
|
||||||
|
SelectObject(hdc2, ppad_bmp);
|
||||||
|
BitBlt(hdc, 0, 0, 320, 240, hdc2, 0, 0, SRCCOPY);
|
||||||
|
EndPaint(hwnd, &ps);
|
||||||
|
DeleteDC(hdc2);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(hwnd,msg,wparam,lparam);
|
return DefWindowProc(hwnd,msg,wparam,lparam);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
R=..\..\..\
|
R=..\..\..\
|
||||||
|
|
||||||
CFLAGS=/nologo /W2 /O2 /D "_CRT_SECURE_NO_WARNINGS" -I. -I$(R)
|
CFLAGS=/nologo /W2 /O2 /D "_CRT_SECURE_NO_WARNINGS" -I. -I$(R) -I$(R)zlib\
|
||||||
|
|
||||||
LDFLAGS=/nologo /machine:I386 /opt:nowin98 /out:PicoDrive.exe
|
LDFLAGS=/nologo /machine:I386 /opt:nowin98 /out:PicoDrive.exe
|
||||||
|
|
||||||
|
@ -22,7 +22,8 @@ OBJ = Emu.obj Input.obj Main.obj Direct.obj DSound.obj Loop.obj
|
||||||
|
|
||||||
# common
|
# common
|
||||||
#OBJS += platform\common\emu.obj platform\common\menu.obj platform\common\fonts.obj
|
#OBJS += platform\common\emu.obj platform\common\menu.obj platform\common\fonts.obj
|
||||||
# platform\common\readpng.obj platform\common\mp3_helix.obj
|
# platform\common\mp3_helix.obj
|
||||||
|
OBJ = $(OBJ) $(R)platform\common\readpng.obj
|
||||||
|
|
||||||
# Pico
|
# Pico
|
||||||
OBJ = $(OBJ) $(R)Pico\Area.obj $(R)Pico\Cart.obj $(R)Pico\Memory.obj $(R)Pico\Misc.obj $(R)Pico\Pico.obj $(R)Pico\Sek.obj \
|
OBJ = $(OBJ) $(R)Pico\Area.obj $(R)Pico\Cart.obj $(R)Pico\Memory.obj $(R)Pico\Misc.obj $(R)Pico\Pico.obj $(R)Pico\Sek.obj \
|
||||||
|
@ -60,7 +61,7 @@ OBJ = $(OBJ) $(R)cpu\cz80\cz80.obj
|
||||||
ALL : PicoDrive.exe
|
ALL : PicoDrive.exe
|
||||||
|
|
||||||
PicoDrive.exe : $(OBJ)
|
PicoDrive.exe : $(OBJ)
|
||||||
link.exe $(LDFLAGS) $(OBJ) gdi32.lib user32.lib advapi32.lib dsound.lib comdlg32.lib ddraw.lib dxguid.lib
|
link.exe $(LDFLAGS) $(OBJ) libpng.lib gdi32.lib user32.lib advapi32.lib dsound.lib comdlg32.lib ddraw.lib dxguid.lib
|
||||||
|
|
||||||
# d3d8.lib d3dx8.lib
|
# d3d8.lib d3dx8.lib
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#define __FUNCTION__ ""
|
#define __FUNCTION__ ""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LOGFAIL() dprintf2("fail: %s %s:%i\n", __FUNCTION__, __FILE__, __LINE__)
|
#define LOGFAIL() lprintf("fail: %s %s:%i\n", __FUNCTION__, __FILE__, __LINE__)
|
||||||
|
|
||||||
|
|
||||||
// Emu.cpp
|
// Emu.cpp
|
||||||
|
@ -52,7 +52,7 @@ int LoopInit();
|
||||||
void LoopExit();
|
void LoopExit();
|
||||||
int LoopCode();
|
int LoopCode();
|
||||||
//extern "C" int dprintf(char *format, ...);
|
//extern "C" int dprintf(char *format, ...);
|
||||||
extern "C" int dprintf2(char *format, ...);
|
extern "C" int lprintf(char *format, ...);
|
||||||
|
|
||||||
// Main.cpp
|
// Main.cpp
|
||||||
extern char *romname;
|
extern char *romname;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue