9 int MainWidth=720,MainHeight=480;
\r
11 char AppName[]="GenaDrive";
\r
14 extern "C" int SekReset();
\r
17 // ------------------------------------ XBox Main ------------------------------------------
\r
20 static int MainCode()
\r
24 ret=LoopInit(); if (ret) { LoopExit(); return 1; }
\r
26 LoopQuit=0; LoopCode();
\r
34 LD_LAUNCH_DASHBOARD launch;
\r
38 // Go back to dashboard:
\r
39 memset(&launch,0,sizeof(launch));
\r
40 launch.dwReason=XLD_LAUNCH_DASHBOARD_MAIN_MENU;
\r
41 XLaunchNewImage(NULL,(LAUNCH_DATA *)&launch);
\r
45 // ----------------------------------- Windows Main ----------------------------------------
\r
47 // Window proc for the frame window:
\r
48 static LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
\r
50 if (msg==WM_CLOSE) { PostQuitMessage(0); return 0; }
\r
51 if (msg==WM_DESTROY) FrameWnd=NULL; // Blank handle
\r
53 return DefWindowProc(hwnd,msg,wparam,lparam);
\r
56 static int FrameInit()
\r
59 RECT rect={0,0,0,0};
\r
61 int left=0,top=0,width=0,height=0;
\r
63 memset(&wc,0,sizeof(wc));
\r
65 // Register the window class:
\r
66 wc.lpfnWndProc=WndProc;
\r
67 wc.hInstance=GetModuleHandle(NULL);
\r
68 wc.hCursor=LoadCursor(NULL,IDC_ARROW);
\r
69 wc.hbrBackground=CreateSolidBrush(0);
\r
70 wc.lpszClassName="MainFrame";
\r
73 rect.right =320;//MainWidth;
\r
74 rect.bottom=224;//MainHeight;
\r
76 // Adjust size of windows based on borders:
\r
77 style=WS_OVERLAPPEDWINDOW;
\r
78 AdjustWindowRect(&rect,style,0);
\r
79 width =rect.right-rect.left;
\r
80 height=rect.bottom-rect.top;
\r
82 // Place window in the centre of the screen:
\r
83 SystemParametersInfo(SPI_GETWORKAREA,0,&rect,0);
\r
84 left=rect.left+rect.right;
\r
85 top=rect.top+rect.bottom;
\r
87 left-=width; left>>=1;
\r
88 top-=height; top>>=1;
\r
90 // Create the window:
\r
91 FrameWnd=CreateWindow(wc.lpszClassName,AppName,style|WS_VISIBLE,
\r
92 left,top,width,height,NULL,NULL,NULL,NULL);
\r
97 // --------------------
\r
99 static DWORD WINAPI ThreadCode(void *)
\r
105 // starscream needs this
\r
106 unsigned char *rom_data = 0;
\r
107 unsigned int rom_size = 0;
\r
109 int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR cmdline,int)
\r
114 HANDLE thread=NULL;
\r
117 static char rompath[MAX_PATH]; rompath[0] = 0;
\r
118 strcpy(rompath, cmdline + (cmdline[0] == '\"' ? 1 : 0));
\r
119 if(rompath[strlen(rompath)-1] == '\"') rompath[strlen(rompath)-1] = 0;
\r
122 if(strlen(rompath) > 4) rom = fopen(rompath, "rb");
\r
124 OPENFILENAME of; ZeroMemory(&of, sizeof(OPENFILENAME));
\r
125 of.lStructSize = sizeof(OPENFILENAME);
\r
126 of.lpstrFilter = "ROMs\0*.smd;*.bin;*.gen\0";
\r
127 of.lpstrFile = rompath; rompath[0] = 0;
\r
128 of.nMaxFile = MAX_PATH;
\r
129 of.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
\r
130 if(!GetOpenFileName(&of)) return 1;
\r
131 rom = fopen(rompath, "rb");
\r
136 if(PicoCartLoad(rom, &rom_data, &rom_size)) {
\r
137 //RDebug::Print(_L("PicoCartLoad() failed."));
\r
142 ret=LoopInit(); if (ret) { LoopExit(); return 1; }
\r
144 PicoCartInsert(rom_data, rom_size);
\r
146 // only now we got the mode (pal/ntsc), so init sound now
\r
151 // Make another thread to run LoopCode():
\r
153 thread=CreateThread(NULL,0,ThreadCode,NULL,0,&tid);
\r
155 // Main window loop:
\r
158 GetMessage(&msg,NULL,0,0);
\r
159 if (msg.message==WM_QUIT) break;
\r
161 TranslateMessage(&msg);
\r
162 DispatchMessage(&msg);
\r
165 // Signal thread to quit and wait for it to exit:
\r
166 LoopQuit=1; WaitForSingleObject(thread,5000);
\r
167 CloseHandle(thread); thread=NULL;
\r
170 DestroyWindow(FrameWnd);
\r
174 _CrtDumpMemoryLeaks();
\r