15eb0001 |
1 | \r |
58db92b9 |
2 | // This file is part of the PicoDrive Megadrive Emulator\r |
3 | \r |
c41b9b97 |
4 | // Copyright (c) 2011 FinalDave (emudave (at) gmail.com)\r |
5 | \r |
58db92b9 |
6 | // This code is licensed under the GNU General Public License version 2.0 and the MAME License.\r |
7 | // You can choose the license that has the most advantages for you.\r |
8 | \r |
9 | // SVN repository can be found at http://code.google.com/p/cyclone68000/\r |
10 | \r |
15eb0001 |
11 | #include "stdafx.h"\r |
12 | #include <stdarg.h>\r |
13 | \r |
14 | static FILE *DebugFile=NULL;\r |
15 | int Main3800=0;\r |
16 | int WINAPI WinMain(HINSTANCE,HINSTANCE,LPTSTR,int)\r |
17 | {\r |
18 | MSG msg; int ret=0;\r |
19 | TCHAR device[260];\r |
20 | \r |
21 | memset(&msg,0,sizeof(msg));\r |
22 | memset(device,0,sizeof(device));\r |
23 | \r |
24 | // Check if this program is running already:\r |
25 | FrameWnd=FindWindow(APP_TITLE,NULL);\r |
26 | if (FrameWnd!=NULL) { SetForegroundWindow(FrameWnd); return 0; }\r |
27 | \r |
28 | DeleteFile(L"zout.txt");\r |
29 | \r |
30 | SystemParametersInfo(SPI_GETOEMINFO,sizeof(device)>>1,device,0);\r |
31 | if (_wcsicmp(device,L"compaq ipaq h3800")==0) Main3800=1;\r |
32 | \r |
33 | FrameInit();\r |
34 | \r |
35 | ConfigInit();\r |
36 | ConfigLoad();\r |
37 | \r |
38 | WaveRate=44100; WaveLen=735;\r |
39 | WaveInit();\r |
40 | \r |
41 | for(;;)\r |
42 | {\r |
43 | ret=PeekMessage(&msg,NULL,0,0,PM_REMOVE);\r |
44 | if (ret)\r |
45 | {\r |
46 | if (msg.message==WM_QUIT) break;\r |
47 | TranslateMessage(&msg);\r |
48 | DispatchMessage(&msg);\r |
49 | }\r |
50 | else\r |
51 | {\r |
52 | EmulateFrame();\r |
53 | //WaveUpdate();\r |
54 | Sleep(1);\r |
55 | }\r |
56 | }\r |
57 | \r |
58 | WaveExit();\r |
59 | EmulateExit();\r |
60 | \r |
61 | ConfigSave();\r |
62 | \r |
63 | DestroyWindow(FrameWnd);\r |
64 | \r |
65 | if (DebugFile) fclose(DebugFile);\r |
66 | DebugFile=NULL;\r |
67 | return 0;\r |
68 | }\r |
69 | \r |
70 | extern "C" int dprintf(char *Format, ...)\r |
71 | {\r |
72 | va_list VaList=NULL;\r |
73 | va_start(VaList,Format);\r |
74 | \r |
75 | if (DebugFile==NULL) DebugFile=fopen("zout.txt","wt");\r |
76 | if (DebugFile) vfprintf(DebugFile,Format,VaList);\r |
77 | \r |
78 | va_end(VaList);\r |
79 | return 0;\r |
80 | }\r |