src/mess/osd/winui/optionsms.h
| r2243 | r2244 | |
| 41 | 41 | void SetHashDirs(const char *dir); |
| 42 | 42 | const char *GetHashDirs(void); |
| 43 | 43 | |
| 44 | | void SetSelectedSoftware(int driver_index, const mess_device_class *devclass, int device_inst, const char *software); |
| 45 | | const char *GetSelectedSoftware(int driver_index, const mess_device_class *devclass, int device_inst); |
| 44 | void SetSelectedSoftware(int driver_index, const device_config *device, const char *software); |
| 45 | const char *GetSelectedSoftware(int driver_index, const device_config *device); |
| 46 | 46 | |
| 47 | 47 | void SetExtraSoftwarePaths(int driver_index, const char *extra_paths); |
| 48 | 48 | const char *GetExtraSoftwarePaths(int driver_index); |
src/mess/osd/winui/messui.c
| r2243 | r2244 | |
| 396 | 396 | // confirm any mandatory devices are loaded |
| 397 | 397 | if (iodev->must_be_loaded) |
| 398 | 398 | { |
| 399 | | pszSoftware = GetSelectedSoftware(drvindex, &iodev->devclass, iodev->index_in_device); |
| 399 | pszSoftware = GetSelectedSoftware(drvindex, dev); |
| 400 | 400 | if (!pszSoftware || !*pszSoftware) |
| 401 | 401 | { |
| 402 | 402 | snprintf(szMessage, sizeof(szMessage) / sizeof(szMessage[0]), |
| r2243 | r2244 | |
| 424 | 424 | |
| 425 | 425 | |
| 426 | 426 | // this is a wrapper call to wrap the idiosycracies of SetSelectedSoftware() |
| 427 | | static void InternalSetSelectedSoftware(int drvindex, const mess_device_class *devclass, int device_inst, const char *pszSoftware) |
| 427 | static void InternalSetSelectedSoftware(int drvindex, const device_config *device, const char *pszSoftware) |
| 428 | 428 | { |
| 429 | 429 | if (!pszSoftware) |
| 430 | 430 | pszSoftware = ""; |
| 431 | 431 | |
| 432 | 432 | // only call SetSelectedSoftware() if this value is different |
| 433 | | if (strcmp(GetSelectedSoftware(drvindex, devclass, device_inst), pszSoftware)) |
| 433 | if (strcmp(GetSelectedSoftware(drvindex, device), pszSoftware)) |
| 434 | 434 | { |
| 435 | | SetSelectedSoftware(drvindex, devclass, device_inst, pszSoftware); |
| 435 | SetSelectedSoftware(drvindex, device, pszSoftware); |
| 436 | 436 | } |
| 437 | 437 | } |
| 438 | 438 | |
| r2243 | r2244 | |
| 465 | 465 | if (nID < 0) |
| 466 | 466 | { |
| 467 | 467 | // special case; first try to find existing image |
| 468 | | s = GetSelectedSoftware(drvindex, &iodev->devclass, iodev->index_in_device); |
| 468 | s = GetSelectedSoftware(drvindex, dev); |
| 469 | 469 | if (s && !mame_stricmp(s, pszFilename)) |
| 470 | 470 | { |
| 471 | 471 | nID = iodev->index_in_device; |
| r2243 | r2244 | |
| 475 | 475 | if (nID < 0) |
| 476 | 476 | { |
| 477 | 477 | // still not found? locate an empty slot |
| 478 | | s = GetSelectedSoftware(drvindex, &iodev->devclass, iodev->index_in_device); |
| 478 | s = GetSelectedSoftware(drvindex, dev); |
| 479 | 479 | if (!s || !*s || !mame_stricmp(s, pszFilename)) |
| 480 | 480 | { |
| 481 | 481 | nID = iodev->index_in_device; |
| r2243 | r2244 | |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | if (nID >= 0) |
| 486 | | InternalSetSelectedSoftware(drvindex, &iodev->devclass, nID, pszFilename); |
| 486 | InternalSetSelectedSoftware(drvindex, dev, pszFilename); |
| 487 | 487 | else if (LOG_SOFTWARE) |
| 488 | 488 | dprintf("MessSpecifyImage(): Failed to place image '%s'\n", pszFilename); |
| 489 | 489 | |
| r2243 | r2244 | |
| 516 | 516 | |
| 517 | 517 | if (iodev != NULL) |
| 518 | 518 | { |
| 519 | | if (!mame_stricmp(pszFilename, GetSelectedSoftware(drvindex, &iodev->devclass, iodev->index_in_device))) |
| 519 | if (!mame_stricmp(pszFilename, GetSelectedSoftware(drvindex, dev))) |
| 520 | 520 | { |
| 521 | 521 | MessSpecifyImage(drvindex, &devclass, iodev->index_in_device, NULL); |
| 522 | 522 | } |
| r2243 | r2244 | |
| 564 | 564 | { |
| 565 | 565 | iodev = mess_device_from_core_device(dev); |
| 566 | 566 | |
| 567 | | pszSoftware = GetSelectedSoftware(drvindex, &iodev->devclass, iodev->index_in_device); |
| 567 | pszSoftware = GetSelectedSoftware(drvindex, dev); |
| 568 | 568 | if (pszSoftware && *pszSoftware) |
| 569 | 569 | { |
| 570 | 570 | i = SoftwarePicker_LookupIndex(hwndSoftware, pszSoftware); |
| r2243 | r2244 | |
| 895 | 895 | { |
| 896 | 896 | LPCTSTR t_buffer = NULL; |
| 897 | 897 | TCHAR* t_s; |
| 898 | | LPCSTR s = GetSelectedSoftware(nDriverIndex, &dev->devclass, nID); |
| 898 | LPCSTR s = GetSelectedSoftware(nDriverIndex, dev->devconfig); |
| 899 | 899 | |
| 900 | 900 | t_s = tstring_from_utf8(s); |
| 901 | 901 | if( !t_s ) |
src/mess/osd/winui/optionsms.c
| r2243 | r2244 | |
| 140 | 140 | options_set_string(MameUIGlobal(), OPTION_HASHPATH, paths, OPTION_PRIORITY_CMDLINE); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | | void SetSelectedSoftware(int driver_index, const mess_device_class *devclass, int device_inst, const char *software) |
| 143 | void SetSelectedSoftware(int driver_index, const device_config *dev, const char *software) |
| 144 | 144 | { |
| 145 | | const char *opt_name = device_instancename(devclass, device_inst); |
| 145 | const struct IODevice *iodev = mess_device_from_core_device(dev); |
| 146 | const char *opt_name = device_instancename(&iodev->devclass, iodev->index_in_device); |
| 146 | 147 | core_options *o; |
| 147 | 148 | |
| 148 | 149 | if (LOG_SOFTWARE) |
| 149 | 150 | { |
| 150 | | dprintf("SetSelectedSoftware(): driver_index=%d (\'%s\') devclass=%p device_inst=%d software='%s'\n", |
| 151 | | driver_index, drivers[driver_index]->name, devclass, device_inst, software); |
| 151 | dprintf("SetSelectedSoftware(): dev=%p (\'%s\') software='%s'\n", |
| 152 | dev, drivers[driver_index]->name, software); |
| 152 | 153 | } |
| 153 | 154 | |
| 154 | 155 | o = load_options(OPTIONS_GAME, driver_index); |
| 155 | | opt_name = device_instancename(devclass, device_inst); |
| 156 | 156 | options_set_string(o, opt_name, software, OPTION_PRIORITY_CMDLINE); |
| 157 | 157 | save_options(OPTIONS_GAME, o, driver_index); |
| 158 | 158 | options_free(o); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | | const char *GetSelectedSoftware(int driver_index, const mess_device_class *devclass, int device_inst) |
| 161 | const char *GetSelectedSoftware(int driver_index, const device_config *dev) |
| 162 | 162 | { |
| 163 | | const char *opt_name = device_instancename(devclass, device_inst); |
| 163 | const struct IODevice *iodev = mess_device_from_core_device(dev); |
| 164 | const char *opt_name = device_instancename(&iodev->devclass, iodev->index_in_device); |
| 164 | 165 | const char *software; |
| 165 | 166 | core_options *o; |
| 166 | 167 | |
| 167 | 168 | o = load_options(OPTIONS_GAME, driver_index); |
| 168 | | opt_name = device_instancename(devclass, device_inst); |
| 169 | 169 | software = options_get_string(o, opt_name); |
| 170 | 170 | return software ? software : ""; |
| 171 | 171 | } |