2 Skelton for retropc emulator
4 Author : K.Ohta <whatisthis.sowhat _at_ gmail.com>
18 void CSP_DiskParams::_open_disk(QString s) {
20 printf("Tray to open disk: %s", s.toUtf8().constData());
21 printf("Drive = %d\n", d);
22 emit do_open_disk(d, s);
24 void CSP_DiskParams::_open_cart(QString s) {
26 emit do_open_cart(d, s);
28 void CSP_DiskParams::_open_cmt(QString s) {
38 void open_cart_dialog(QWidget *hWnd, int drv)
40 CSP_DiskDialog dlg(hWnd);
42 #if defined(_GAMEGEAR)
43 QString ext = "*.rom,*.bin,*.gg,*.col";
44 QString desc = "Game Cartridge";
45 #elif defined(_MASTERSYSTEM)
46 QString ext = "*.rom,*.bin,*.sms";
47 QString desc = "Game Cartridge";
48 #elif defined(_PC6001) || defined(_PC6001MK2) || defined(_PC6001MK2SR) || defined(_PC6601) || defined(_PC6601SR)
49 QString ext = "*.rom,*.bin,*.60";
50 QString desc = "Game Cartridge";
51 #elif defined(_PCENGINE) || defined(_X1TWIN)
52 QString ext = "*.rom,*.bin,*.pce";
53 QString desc = "HuCARD";
55 QString ext = "*.rom,*.bin";
56 QString desc = "Game Cartridge";
59 desc = desc + " (" + ext + ")";
60 QStringList filter(desc);
61 if(config.initial_cart_dir != NULL) {
62 dirname = config.initial_cart_dir;
65 getcwd(app, PATH_MAX);
66 dirname = get_parent_dir(app);
68 dlg.param.setDrive(drv);
69 dlg.setDirectory(dirname);
70 dlg.setNameFilters(filter);
71 QObject::connect(&dlg, SIGNAL(fileSelected(const QString)), dlg.param, SLOT(dlg.param->_open_cart(const QString)));
78 void OnOpenQDSub(AG_Event *event)
80 AG_FileType *filetype = (AG_FileType *)AG_PTR(3);
81 char *path = AG_STRING(2);
83 AG_FileDlg *my = (AG_FileDlg *)AG_SELF();
85 if(strlen(path) <= 0) return;
86 strncpy(path_shadow, path, AG_PATHNAME_MAX);
87 UPDATE_HISTORY(path, config.recent_quickdisk_path[drv]);
88 get_parent_dir(path_shadow);
89 strcpy(config.initial_quickdisk_dir, path_shadow);
90 if(emu) emu->open_quickdisk(drv, path, 0);
94 void open_quickdisk_dialog(AG_Widget *hWnd, int drv)
96 char path_shadow[AG_PATHNAME_MAX];
97 const char *ext = "*.mzt,*.q20,*qdf";
98 char *desc = _N("Quick Disk");
102 win = AG_WindowNew(0);
104 dlg = AG_FileDlgNew(win, AG_FILEDLG_MASK_EXT | AG_FILEDLG_ASYNC | AG_FILEDLG_CLOSEWIN);
105 if(dlg == NULL) return;
107 if(config.initial_quickdisk_dir != NULL) {
108 AG_FileDlgSetDirectory(dlg, "%s", config.initial_quickdisk_dir);
112 dirname = df.currentPath();
113 strncpy(app, dirname.toUtf8().constData(), PATH_MAX);
114 dirname = get_parent_dir(app);
116 AG_FileDlgAddType(dlg, desc, ext, OnOpenQDSub, "%i", drv);
123 void open_tape_dialog(QWidget *hWnd, bool play)
125 int playf = play ? 1 : 0;
129 QStringList filter(desc);
130 if(config.initial_tape_dir != NULL) {
131 dirname = config.initial_tape_dir;
135 dirname = df.currentPath();
136 strncpy(app, dirname.toUtf8().constData(), PATH_MAX);
137 dirname = get_parent_dir(app);
139 CSP_DiskDialog dlg(hWnd);
140 dlg.param->setRecMode(play);
141 dlg.setDirectory(dirname);
142 dlg.setNameFilters(filter);
143 QObject::connect(&dlg, SIGNAL(fileSelected(QString)), dlg.param, SLOT(dlg.param->_open_cmt(QString)));
149 #ifdef USE_LASER_DISC
150 void OnOpenLaserDiscSub(AG_Event *event)
152 AG_FileType *filetype = (AG_FileType *)AG_PTR(2);
153 char *path = AG_STRING(1);
154 char path_shadow[AG_PATHNAME_MAX];
155 AG_FileDlg *my = (AG_FileDlg *)AG_SELF();
157 if(strlen(path) <= 0) return;
158 strncpy(path_shadow, path, AG_PATHNAME_MAX);
159 UPDATE_HISTORY(path, config.recent_laser_disc_path);
160 get_parent_dir(path_shadow);
161 strcpy(config.initial_laser_disc_dir, path_shadow);
162 if(emu) emu->open_laser_disc(path);
166 void open_laser_disc_dialog(AG_Widget *hWnd)
168 const char *ext = "*.avi,*.mpg,*.mpeg,*.wmv,*.ogv";
169 char *desc = "Laser Disc";
172 win = AG_WindowNew(0);
174 AG_FileDlg *dlg = AG_FileDlgNew(win, AG_FILEDLG_MASK_EXT | AG_FILEDLG_ASYNC | AG_FILEDLG_CLOSEWIN);
175 if(dlg == NULL) return;
177 if(config.initial_laser_disc_dir != NULL) {
178 AG_FileDlgSetDirectory(dlg, "%s", config.initial_laser_disc_dir);
180 _TCHAR app[AG_PATHNAME_MAX];
181 AG_GetCWD(app, AG_PATHNAME_MAX);
182 AG_FileDlgSetDirectory(dlg, "%s", get_parent_dir(app));
184 AG_FileDlgAddType(dlg, desc, ext, OnOpenLaserDiscSub, "%p", NULL);
190 #ifdef USE_BINARY_FILE1
192 void OnOpenBinarySub(AG_Event *event)
194 AG_FileType *filetype = (AG_FileType *)AG_PTR(4);
195 char *path = AG_STRING(3);
196 char path_shadow[AG_PATHNAME_MAX];
198 int load = AG_INT(2);
199 AG_FileDlg *my = (AG_FileDlg *)AG_SELF();
201 strncpy(path_shadow, path, AG_PATHNAME_MAX);
202 UPDATE_HISTORY(path, config.recent_binary_path[drv]);
203 get_parent_dir(path_shadow);
204 strcpy(config.initial_binary_dir, path_shadow);
206 emu->load_binary(drv, path);
208 emu->save_binary(drv, path);
213 void open_binary_dialog(AG_Widget *hWnd, int drv, bool load)
215 const char ext = "*.ram,*.bin";
218 int loadf = load ? 1 : 0;
219 #if defined(_PASOPIA) || defined(_PASOPIA7)
220 char *desc = "RAM Pack Cartridge";
222 char *desc = "Memory Dump";
224 win = AG_WIndowNew(0);
225 AG_FileDlg *dlg = AG_FileDlgNew(win, AG_FILEDLG_MASK_EXT | AG_FILEDLG_ASYNC | AG_FILEDLG_CLOSEWIN);
226 if(dlg == NULL) return;
228 if(config.initial_binary_dir != NULL) {
229 AG_FileDlgSetDirectory(dlg, "%s", config.initial_binary_dir);
231 _TCHAR app[AG_PATHNAME_MAX];
232 AG_GetCWD(app, AG_PATHNAME_MAX);
233 AG_FileDlgSetDirectory(dlg, "%s", get_parent_dir(app));
235 AG_FileDlgAddType(dlg, desc, ext, OnOpenBinarySub, "%i,%i", drv, loadf);
243 #ifdef SUPPORT_DRAG_DROP
244 void open_any_file(_TCHAR* path)
246 #if defined(USE_CART1)
247 if(check_file_extension(path, _T(".rom")) ||
248 check_file_extension(path, _T(".bin")) ||
249 check_file_extension(path, _T(".gg" )) ||
250 check_file_extension(path, _T(".col")) ||
251 check_file_extension(path, _T(".sms")) ||
252 check_file_extension(path, _T(".60" )) ||
253 check_file_extension(path, _T(".pce"))) {
254 UPDATE_HISTORY(path, config.recent_cart_path[0]);
255 strcpy(config.initial_cart_dir, get_parent_dir(path));
256 emu->open_cart(0, path);
261 if(check_file_extension(path, _T(".d88")) ||
262 check_file_extension(path, _T(".d77")) ||
263 check_file_extension(path, _T(".td0")) ||
264 check_file_extension(path, _T(".imd")) ||
265 check_file_extension(path, _T(".dsk")) ||
266 check_file_extension(path, _T(".fdi")) ||
267 check_file_extension(path, _T(".hdm")) ||
268 check_file_extension(path, _T(".tfd")) ||
269 check_file_extension(path, _T(".xdf")) ||
270 check_file_extension(path, _T(".2d" )) ||
271 check_file_extension(path, _T(".sf7"))) {
272 UPDATE_HISTORY(path, config.recent_disk_path[0]);
273 strcpy(config.initial_disk_dir, get_parent_dir(path));
274 open_disk(0, path, 0);
278 #if defined(USE_TAPE)
279 if(check_file_extension(path, _T(".wav")) ||
280 check_file_extension(path, _T(".cas")) ||
281 check_file_extension(path, _T(".p6" )) ||
282 check_file_extension(path, _T(".cmt")) ||
283 check_file_extension(path, _T(".n80")) ||
284 check_file_extension(path, _T(".t88")) ||
285 check_file_extension(path, _T(".mzt")) ||
286 check_file_extension(path, _T(".m12")) ||
287 check_file_extension(path, _T(".mti")) ||
288 check_file_extension(path, _T(".mtw")) ||
289 check_file_extension(path, _T(".tap"))) {
290 UPDATE_HISTORY(path, config.recent_tape_path);
291 strcpy(config.initial_tape_dir, get_parent_dir(path));
292 emu->play_tape(path);
296 #if defined(USE_BINARY_FILE1)
297 if(check_file_extension(path, _T(".ram")) ||
298 check_file_extension(path, _T(".bin"))) {
299 UPDATE_HISTORY(path, config.recent_binary_path[0]);
300 strcpy(config.initial_binary_dir, get_parent_dir(path));
301 emu->load_binary(0, path);