33e9fa25de4ce5cc332dde483a263815dda8c10e
[cyclone68000.git] / PicoDrive / File.cpp
1 \r
2 // This file is part of the PicoDrive Megadrive Emulator\r
3 \r
4 // This code is licensed under the GNU General Public License version 2.0 and the MAME License.\r
5 // You can choose the license that has the most advantages for you.\r
6 \r
7 // SVN repository can be found at http://code.google.com/p/cyclone68000/\r
8 \r
9 #include "stdafx.h"\r
10 \r
11 // Loading roms, loading and saving states etc...\r
12 \r
13 int FileLoadRom()\r
14 {\r
15   OPENFILENAME ofn;\r
16 \r
17   memset(&ofn,0,sizeof(ofn));\r
18   memset(&RomName,0,sizeof(RomName));\r
19 \r
20   ofn.lStructSize=sizeof(ofn);\r
21   ofn.hwndOwner=FrameWnd;\r
22   ofn.hInstance=GetModuleHandle(NULL);\r
23   ofn.lpstrFile=RomName;\r
24   ofn.nMaxFile=260;\r
25   ofn.lpstrDefExt=L"bin";\r
26   ofn.lpstrFilter=L"Rom Files\0*.bin;*.gen;*.smd\0\0";\r
27 \r
28   GetOpenFileName(&ofn);\r
29 \r
30   UpdateWindow(FrameWnd);\r
31 \r
32   // Open new rom:\r
33   if (RomName[0]) EmulateInit();\r
34 \r
35   return 0;\r
36 }\r
37 \r
38 int FileState(int load)\r
39 {\r
40   OPENFILENAME ofn;\r
41   WCHAR name[260]={0};\r
42 \r
43   if (load==0) wcscpy(name,L"State.mds");\r
44 \r
45   memset(&ofn,0,sizeof(ofn));\r
46   ofn.lStructSize=sizeof(ofn);\r
47   ofn.hwndOwner=FrameWnd;\r
48   ofn.hInstance=GetModuleHandle(NULL);\r
49   ofn.lpstrFile=name;\r
50   ofn.nMaxFile=sizeof(name)>>1;\r
51   ofn.lpstrDefExt=L"mds";\r
52   ofn.lpstrFilter=L"MD State Files\0*.mds\0\0";\r
53 \r
54   if (load) GetOpenFileNameW(&ofn);\r
55   else      GetSaveFileNameW(&ofn);\r
56   UpdateWindow(FrameWnd);\r
57 \r
58   if (name[0]==0) return 1;\r
59 \r
60   if (PmovFile) fclose(PmovFile);\r
61 \r
62   PmovFile=_wfopen(name,load ? L"rb":L"wb");\r
63   if (PmovFile==NULL) return 1;\r
64   \r
65   PmovAction=load?6:5;\r
66   PmovState(); // Save the state\r
67 \r
68   return 0;\r
69 }\r