Added 0.030 of PicoDrive and moved license files into root
[cyclone68000.git] / PicoDrive / WinMain.cpp
1 \r
2 #include "stdafx.h"\r
3 #include <stdarg.h>\r
4 \r
5 static FILE *DebugFile=NULL;\r
6 int Main3800=0;\r
7 int WINAPI WinMain(HINSTANCE,HINSTANCE,LPTSTR,int)\r
8 {\r
9   MSG msg; int ret=0;\r
10   TCHAR device[260];\r
11 \r
12   memset(&msg,0,sizeof(msg));\r
13   memset(device,0,sizeof(device));\r
14 \r
15   // Check if this program is running already:\r
16   FrameWnd=FindWindow(APP_TITLE,NULL);\r
17   if (FrameWnd!=NULL) { SetForegroundWindow(FrameWnd); return 0; }\r
18 \r
19   DeleteFile(L"zout.txt");\r
20 \r
21   SystemParametersInfo(SPI_GETOEMINFO,sizeof(device)>>1,device,0);\r
22   if (_wcsicmp(device,L"compaq ipaq h3800")==0) Main3800=1;\r
23 \r
24   FrameInit();\r
25 \r
26   ConfigInit();\r
27   ConfigLoad();\r
28 \r
29   WaveRate=44100; WaveLen=735;\r
30   WaveInit();\r
31 \r
32   for(;;)\r
33   {\r
34     ret=PeekMessage(&msg,NULL,0,0,PM_REMOVE);\r
35     if (ret)\r
36     {\r
37       if (msg.message==WM_QUIT) break;\r
38       TranslateMessage(&msg);\r
39       DispatchMessage(&msg);\r
40     }\r
41     else\r
42     {\r
43       EmulateFrame();\r
44       //WaveUpdate();\r
45       Sleep(1);\r
46     }\r
47   }\r
48 \r
49   WaveExit();\r
50   EmulateExit();\r
51 \r
52   ConfigSave();\r
53 \r
54   DestroyWindow(FrameWnd);\r
55 \r
56   if (DebugFile) fclose(DebugFile);\r
57   DebugFile=NULL;\r
58   return 0;\r
59 }\r
60 \r
61 extern "C" int dprintf(char *Format, ...)\r
62 {\r
63   va_list VaList=NULL;\r
64   va_start(VaList,Format);\r
65 \r
66   if (DebugFile==NULL) DebugFile=fopen("zout.txt","wt");\r
67   if (DebugFile) vfprintf(DebugFile,Format,VaList);\r
68 \r
69   va_end(VaList);\r
70   return 0;\r
71 }\r