From 4b2b67ebc7fc6205c6589243b9c9a0a172a97ebb Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 27 Jan 2008 23:57:20 +0000 Subject: [PATCH] updating win32 port git-svn-id: file:///home/notaz/opt/svn/PicoDrive@338 be3aeb3a-fb24-0410-a615-afba39da0efa --- platform/win32/GenaDrive/Direct.cpp | 6 +-- platform/win32/GenaDrive/Emu.cpp | 59 +++++++++-------------- platform/win32/GenaDrive/Input.cpp | 18 ++----- platform/win32/GenaDrive/Loop.cpp | 66 +++++++------------------- platform/win32/GenaDrive/Main.cpp | 20 ++++---- platform/win32/GenaDrive/Makefile.vc | 57 ++++++++++++++++++++++ platform/win32/GenaDrive/app.h | 7 +-- platform/win32/GenaDrive/port_config.h | 15 ++---- 8 files changed, 122 insertions(+), 126 deletions(-) create mode 100644 platform/win32/GenaDrive/Makefile.vc diff --git a/platform/win32/GenaDrive/Direct.cpp b/platform/win32/GenaDrive/Direct.cpp index 05b84de..b6f4285 100644 --- a/platform/win32/GenaDrive/Direct.cpp +++ b/platform/win32/GenaDrive/Direct.cpp @@ -75,7 +75,7 @@ int DirectInit() ret=TexScreenInit(); if (ret) return 1; - FontInit(); + //FontInit(); Device->SetRenderState(D3DRS_LIGHTING,0); // Turn off lighting @@ -87,8 +87,8 @@ int DirectInit() void DirectExit() { - FontExit(); - TexScreenExit(); + //FontExit(); + //TexScreenExit(); RELEASE(VertexBuffer) RELEASE(DirectBack) diff --git a/platform/win32/GenaDrive/Emu.cpp b/platform/win32/GenaDrive/Emu.cpp index 5294d7a..4e5bc95 100644 --- a/platform/win32/GenaDrive/Emu.cpp +++ b/platform/win32/GenaDrive/Emu.cpp @@ -1,39 +1,17 @@ #include "app.h" -extern "C" { -struct Pico -{ - unsigned char ram[0x10000]; // 0x00000 scratch ram - unsigned short vram[0x8000]; // 0x10000 - unsigned char zram[0x2000]; // 0x20000 Z80 ram - unsigned char ioports[0x10]; - unsigned int pad[0x3c]; // unused - unsigned short cram[0x40]; // 0x22100 - unsigned short vsram[0x40]; // 0x22180 - - unsigned char *rom; // 0x22200 - unsigned int romsize; // 0x22204 - -// struct PicoMisc m; -// struct PicoVideo video; -}; - extern struct Pico Pico; -} - unsigned short *EmuScreen=NULL; extern "C" unsigned short *framebuff=NULL; int EmuWidth=0,EmuHeight=0; static int frame=0; static int EmuScan(unsigned int num, void *sdata); +unsigned char *PicoDraw2FB = NULL; int EmuInit() { int len=0; -// PicoOpt=-1; -// PsndRate=44100; PsndLen=DSoundSeg; - PicoInit(); // Allocate screen: @@ -43,6 +21,8 @@ int EmuInit() framebuff=(unsigned short *)malloc((8+320)*(8+224+8)*2); memset(EmuScreen,0,len); + PicoDraw2FB = (unsigned char *)framebuff; + PicoDrawSetColorFormat(1); PicoScan=EmuScan; return 0; @@ -70,7 +50,7 @@ static int EmuScan(unsigned int num, void *sdata) pd=EmuScreen+(num<<8)+(num<<6); end=pd+320; ps=(unsigned short *)sdata; - do { *pd++=(unsigned short)PicoCram(*ps++); } while (pd 0; sram_size--) - if(SRam.data[sram_size-1]) break; - if(sram_size) { - FILE *f = fopen(romname, "wb"); - if(f) { - fwrite(SRam.data, 1, sram_size, f); - fclose(f); - } - } - - FileMenu.exit(); + //FileMenu.exit(); EmuExit(); DSoundExit(); PsndLen=0; InputExit(); @@ -113,6 +74,7 @@ static int DoGame() } // ---------------------------------------------------------------- +/* static int MenuUpdate() { int delta=0; @@ -149,6 +111,7 @@ static int MenuRender() return 0; } +*/ // ---------------------------------------------------------------- @@ -161,9 +124,9 @@ static int ModeUpdate() if (DSoundNext) memset(DSoundNext,0,PsndLen<<2); - if (LoopMode==2) { FileMenu.scan(); LoopMode++; return 0; } - if (LoopMode==3) { MenuUpdate(); return 0; } - if (LoopMode==4) { LightCalUpdate(); return 0; } +// if (LoopMode==2) { FileMenu.scan(); LoopMode++; return 0; } +// if (LoopMode==3) { MenuUpdate(); return 0; } +// if (LoopMode==4) { LightCalUpdate(); return 0; } LoopMode=2; // Unknown mode, go to rom menu return 0; @@ -173,13 +136,13 @@ static int ModeUpdate() static int ModeRender() { DirectScreen(); - if (LoopMode==3) MenuRender(); - if (LoopMode==4) LightCalRender(); +// if (LoopMode==3) MenuRender(); +// if (LoopMode==4) LightCalRender(); return 0; } -static void UpdateSound() +static void UpdateSound(int len) { if(fastForward) return; while (DSoundUpdate()) { Sleep(1); } @@ -206,6 +169,7 @@ int LoopCode() // ------------------------------------------------------------------------------------- +#if 0 extern "C" int dprintf(char *format, ...) { char *name=NULL; @@ -229,6 +193,7 @@ extern "C" int dprintf(char *format, ...) va_end(val); return 0; } +#endif extern "C" int dprintf2(char *format, ...) { @@ -242,3 +207,4 @@ extern "C" int dprintf2(char *format, ...) return 0; } + diff --git a/platform/win32/GenaDrive/Main.cpp b/platform/win32/GenaDrive/Main.cpp index edab430..a8e3362 100644 --- a/platform/win32/GenaDrive/Main.cpp +++ b/platform/win32/GenaDrive/Main.cpp @@ -113,13 +113,16 @@ int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR cmdline,int) DWORD tid=0; HANDLE thread=NULL; + FrameInit(); + ret=LoopInit(); if (ret) { LoopExit(); return 1; } + // notaz: load rom static char rompath[MAX_PATH]; rompath[0] = 0; strcpy(rompath, cmdline + (cmdline[0] == '\"' ? 1 : 0)); if(rompath[strlen(rompath)-1] == '\"') rompath[strlen(rompath)-1] = 0; - FILE *rom = 0; - if(strlen(rompath) > 4) rom = fopen(rompath, "rb"); + pm_file *rom = 0; + if(strlen(rompath) > 4) rom = pm_open(rompath); if(!rom) { OPENFILENAME of; ZeroMemory(&of, sizeof(OPENFILENAME)); of.lStructSize = sizeof(OPENFILENAME); @@ -128,7 +131,7 @@ int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR cmdline,int) of.nMaxFile = MAX_PATH; of.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY; if(!GetOpenFileName(&of)) return 1; - rom = fopen(rompath, "rb"); + rom = pm_open(rompath); if(!rom) return 1; } romname = rompath; @@ -137,17 +140,13 @@ int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR cmdline,int) //RDebug::Print(_L("PicoCartLoad() failed.")); //goto cleanup; } - - FrameInit(); - ret=LoopInit(); if (ret) { LoopExit(); return 1; } + pm_close(rom); PicoCartInsert(rom_data, rom_size); // only now we got the mode (pal/ntsc), so init sound now DSoundInit(); - preLoopInit(); - // Make another thread to run LoopCode(): LoopQuit=0; thread=CreateThread(NULL,0,ThreadCode,NULL,0,&tid); @@ -174,5 +173,10 @@ int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR cmdline,int) _CrtDumpMemoryLeaks(); return 0; } + +extern void error(char *text) +{ + MessageBox(FrameWnd, text, "Error", 0); +} #endif diff --git a/platform/win32/GenaDrive/Makefile.vc b/platform/win32/GenaDrive/Makefile.vc new file mode 100644 index 0000000..20b58e1 --- /dev/null +++ b/platform/win32/GenaDrive/Makefile.vc @@ -0,0 +1,57 @@ +# Makefile for MS Visual C + +R=..\..\..\ + +CFLAGS=/nologo /W2 /O2 /D "_CRT_SECURE_NO_WARNINGS" -I. -I$(R) + +LDFLAGS=/nologo /machine:I386 /opt:nowin98 /out:PicoDrive.exe + +CFLAGS=$(CFLAGS) /DEMU_F68K + +CFLAGS=$(CFLAGS) /D_USE_CZ80 + +# emu +OBJ = Emu.obj Input.obj Main.obj Direct.obj DSound.obj Loop.obj TexScreen.obj + +# not used: Rom.obj Font.obj FileMenu.obj LightCal.obj + +# common +#OBJS += platform\common\emu.obj platform\common\menu.obj platform\common\fonts.obj +# platform\common\readpng.obj platform\common\mp3_helix.obj + +# 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 \ + $(R)Pico\VideoPort.obj $(R)Pico\Draw2.obj $(R)Pico\Draw.obj $(R)Pico\Patch.obj +# Pico - CD +OBJ = $(OBJ) $(R)Pico\cd\Pico.obj $(R)Pico\cd\Memory.obj $(R)Pico\cd\Sek.obj $(R)Pico\cd\LC89510.obj \ + $(R)Pico\cd\cd_sys.obj $(R)Pico\cd\cd_file.obj $(R)Pico\cd\gfx_cd.obj \ + $(R)Pico\cd\Area.obj $(R)Pico\cd\Misc.obj $(R)Pico\cd\pcm.obj $(R)Pico\cd\buffering.obj +# Pico - sound +OBJ = $(OBJ) $(R)Pico\sound\sound.obj $(R)Pico\sound\sn76496.obj $(R)Pico\sound\ym2612.obj $(R)Pico\sound\mix.obj +# Pico - carthw +OBJ = $(OBJ) $(R)Pico\carthw\svp\svp.obj $(R)Pico\carthw\svp\Memory.obj $(R)Pico\carthw\svp\ssp16.obj +# zlib +OBJ = $(OBJ) $(R)zlib\gzio.obj $(R)zlib\inffast.obj $(R)zlib\inflate.obj $(R)zlib\inftrees.obj $(R)zlib\trees.obj \ + $(R)zlib\deflate.obj $(R)zlib\crc32.obj $(R)zlib\adler32.obj $(R)zlib\zutil.obj $(R)zlib\compress.obj $(R)zlib\uncompr.obj +# unzip +OBJ = $(OBJ) $(R)unzip\unzip.obj $(R)unzip\unzip_stream.obj +# CPU cores +OBJ = $(OBJ) $(R)cpu\fame\famec.obj +# z80 +OBJ = $(OBJ) $(R)cpu\cz80\cz80.obj + + +.c.obj: + cl $(CFLAGS) /c $< /Fo$@ + +.cpp.obj: + cl $(CFLAGS) /c $< /Fo$@ + + +ALL : PicoDrive.exe + +PicoDrive.exe : $(OBJ) + link.exe $(LDFLAGS) $(OBJ) gdi32.lib user32.lib advapi32.lib d3d8.lib d3dx8.lib dsound.lib comdlg32.lib + +clean: + -del $(OBJ) PicoDrive.exe diff --git a/platform/win32/GenaDrive/app.h b/platform/win32/GenaDrive/app.h index 43f756e..7467257 100644 --- a/platform/win32/GenaDrive/app.h +++ b/platform/win32/GenaDrive/app.h @@ -13,7 +13,7 @@ #include -#include "Pico.h" +#include #define PI 3.14159265f @@ -53,19 +53,20 @@ int LightCalUpdate(); int LightCalRender(); // Loop.cpp -void preLoopInit(); extern char LoopQuit; extern int LoopMode; int LoopInit(); void LoopExit(); int LoopCode(); +//extern "C" int dprintf(char *format, ...); +extern "C" int dprintf2(char *format, ...); // Main.cpp extern HWND FrameWnd; extern int MainWidth,MainHeight; extern char AppName[]; -extern "C" int dprintf(char *format, ...); +extern void error(char *text); // Rom.cpp extern unsigned char *RomData; diff --git a/platform/win32/GenaDrive/port_config.h b/platform/win32/GenaDrive/port_config.h index fbb2170..44b049a 100644 --- a/platform/win32/GenaDrive/port_config.h +++ b/platform/win32/GenaDrive/port_config.h @@ -7,19 +7,12 @@ #define START_ROW 0 // which row of tiles to start rendering at? #define END_ROW 28 // ..end +#define mix_32_to_16l_stereo_lvl mix_32_to_16l_stereo + // pico.c #define CAN_HANDLE_240_LINES 0 -#ifdef __cplusplus -extern "C" { -#endif - -// common debug -int dprintf (char *format, ...); -int dprintf2(char *format, ...); - -#ifdef __cplusplus -} // End of extern "C" -#endif +#define dprintf +#define strcasecmp stricmp #endif //PORT_CONFIG_H -- 2.39.2