+static HMENU mdisplay = 0;\r
+static int rom_loaded = 0;\r
+\r
+static void UpdateRect()\r
+{\r
+ WINDOWINFO wi;\r
+ memset(&wi, 0, sizeof(wi));\r
+ wi.cbSize = sizeof(wi);\r
+ GetWindowInfo(FrameWnd, &wi);\r
+ FrameRectMy = wi.rcClient;\r
+}\r
+\r
+static void LoadROM(const char *cmdpath)\r
+{\r
+ static char rompath[MAX_PATH] = { 0, };\r
+ unsigned char *rom_data_new = NULL;\r
+ unsigned int rom_size = 0;\r
+ pm_file *rom = NULL;\r
+ int oldwait=LoopWait;\r
+ int i, ret;\r
+\r
+ if (cmdpath) {\r
+ strcpy(rompath, cmdpath + (cmdpath[0] == '\"' ? 1 : 0));\r
+ if (rompath[strlen(rompath)-1] == '\"') rompath[strlen(rompath)-1] = 0;\r
+ if (strlen(rompath) > 4) rom = pm_open(rompath);\r
+ }\r
+\r
+ if (!rom) {\r
+ OPENFILENAME of; ZeroMemory(&of, sizeof(OPENFILENAME));\r
+ of.lStructSize = sizeof(OPENFILENAME);\r
+ of.lpstrFilter = "ROMs\0*.smd;*.bin;*.gen;*.zip\0";\r
+ of.lpstrFile = rompath; rompath[0] = 0;\r
+ of.nMaxFile = MAX_PATH;\r
+ of.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;\r
+ of.hwndOwner = FrameWnd;\r
+ if (!GetOpenFileName(&of)) return;\r
+ rom = pm_open(rompath);\r
+ if (!rom) { error("failed to open ROM"); return; }\r
+ }\r
+\r
+ ret=PicoCartLoad(rom, &rom_data_new, &rom_size);\r
+ pm_close(rom);\r
+ if (ret) {\r
+ error("failed to load ROM");\r
+ return;\r
+ }\r
+\r
+ // halt the work thread..\r
+ // just a hack, should've used proper sync. primitives here, but who will use this emu anyway..\r
+ LoopWaiting=0;\r
+ LoopWait=1;\r
+ for (i = 0; LoopWaiting == 0 && i < 10; i++) Sleep(100);\r
+\r
+ PicoUnloadCart();\r
+ PicoCartInsert(rom_data_new, rom_size);\r
+\r
+ rom_loaded = 1;\r
+ romname = rompath;\r
+ LoopWait=0;\r
+}\r
+\r
+static int rect_widths[4] = { 320, 256, 640, 512 };\r
+static int rect_heights[4] = { 224, 224, 448, 448 };\r
+\r