const osd_directory_entry *osd_readdir(osd_directory *dir) { // if we've previously allocated a name, free it now if (dir->entry.name != NULL) { free((void *)dir->entry.name); dir->entry.name = NULL; } // if this isn't the first file, do a find next if (!dir->is_first) { if (!FindNextFile(dir->find, &dir->data)) return NULL; } // otherwise, just use the data we already had else dir->is_first = FALSE; // extract the data dir->entry.name = utf8_from_tstring(dir->data.cFileName); dir->entry.type = win_attributes_to_entry_type(dir->data.dwFileAttributes); dir->entry.size = dir->data.nFileSizeLow | ((UINT64) dir->data.nFileSizeHigh << 32); return (dir->entry.name != NULL) ? &dir->entry : NULL; }
TDevice* create_rawinput_device(running_machine &machine, PRAWINPUTDEVICELIST rawinputdevice) { TDevice* devinfo = nullptr; INT name_length = 0; // determine the length of the device name, allocate it, and fetch it if not nameless if (get_rawinput_device_info(rawinputdevice->hDevice, RIDI_DEVICENAME, NULL, &name_length) != 0) return nullptr; std::unique_ptr<TCHAR[]> tname = std::make_unique<TCHAR[]>(name_length + 1); if (name_length > 1 && get_rawinput_device_info(rawinputdevice->hDevice, RIDI_DEVICENAME, tname.get(), &name_length) == -1) return nullptr; // if this is an RDP name, skip it if (_tcsstr(tname.get(), TEXT("Root#RDP_")) != NULL) return nullptr; // improve the name and then allocate a device tname = std::unique_ptr<TCHAR[]>(rawinput_device_improve_name(tname.release())); // convert name to utf8 auto osd_deleter = [](void *ptr) { osd_free(ptr); }; auto utf8_name = std::unique_ptr<char, decltype(osd_deleter)>(utf8_from_tstring(tname.get()), osd_deleter); devinfo = devicelist()->create_device<TDevice>(machine, utf8_name.get(), *this); // Add the handle devinfo->set_handle(rawinputdevice->hDevice); return devinfo; }
static int RetrieveDirList(int nDir, int nFlagResult, void (*SetTheseDirs)(const char *s)) { int i; int nResult = 0; int nPaths; TCHAR buf[MAX_PATH * MAX_DIRS]; char* utf8_buf; if (DirInfo_Modified(g_pDirInfo, nDir)) { memset(buf, 0, sizeof(buf)); nPaths = DirInfo_NumDir(g_pDirInfo, nDir); for (i = 0; i < nPaths; i++) { _tcscat(buf, FixSlash(DirInfo_Path(g_pDirInfo, nDir, i))); if (i < nPaths - 1) _tcscat(buf, TEXT(";")); } utf8_buf = utf8_from_tstring(buf); SetTheseDirs(utf8_buf); osd_free(utf8_buf); nResult |= nFlagResult; } return nResult; }
void add_rawinput_device(running_machine& machine, RAWINPUTDEVICELIST * device) override { // make sure this is a keyboard if (device->dwType != RIM_TYPEKEYBOARD) return; // allocate and link in a new device rawinput_keyboard_device *devinfo = create_rawinput_device<rawinput_keyboard_device>(machine, device); if (devinfo == NULL) return; keyboard_trans_table &table = keyboard_trans_table::instance(); // populate it for (int keynum = 0; keynum < MAX_KEYS; keynum++) { input_item_id itemid = table.map_di_scancode_to_itemid(keynum); TCHAR keyname[100]; char *name; // generate the name if (GetKeyNameText(((keynum & 0x7f) << 16) | ((keynum & 0x80) << 17), keyname, ARRAY_LENGTH(keyname)) == 0) _sntprintf(keyname, ARRAY_LENGTH(keyname), TEXT("Scan%03d"), keynum); name = utf8_from_tstring(keyname); // add the item to the device devinfo->device()->add_item(name, itemid, generic_button_get_state, &devinfo->keyboard.state[keynum]); osd_free(name); } }
extern "C" int _tmain(int argc, TCHAR **argv) { int i = 0; char **utf8_argv = NULL; /* convert arguments to UTF-8 */ utf8_argv = (char **) malloc(argc * sizeof(*argv)); if (utf8_argv == NULL) return 999; for (i = 0; i < argc; i++) { utf8_argv[i] = utf8_from_tstring(argv[i]); if (utf8_argv[i] == NULL) { free(utf8_argv); return 999; } } /* run utf8_main */ int rc = utf8_main(argc, utf8_argv); /* free arguments */ for (i = 0; i < argc; i++) free(utf8_argv[i]); free(utf8_argv); return rc; }
static BOOL SoftwarePicker_AddEntry(HWND hwndPicker, directory_search_info *pSearchInfo) { //software_picker_info *pPickerInfo; LPSTR pszFilename; BOOL rc; char* utf8_FileName; //pPickerInfo = GetSoftwarePickerInfo(hwndPicker); utf8_FileName = utf8_from_tstring(pSearchInfo->fd.cFileName); if( !utf8_FileName ) return FALSE; if (!strcmp(utf8_FileName, ".") || !strcmp(utf8_FileName, "..")) { osd_free(utf8_FileName); return TRUE; } pszFilename = (LPSTR)alloca(strlen(pSearchInfo->directory_name) + 1 + strlen(utf8_FileName) + 1); strcpy(pszFilename, pSearchInfo->directory_name); strcat(pszFilename, "\\"); strcat(pszFilename, utf8_FileName); if (pSearchInfo->fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) rc = SoftwarePicker_AddDirectory(hwndPicker, pszFilename); else rc = SoftwarePicker_InternalAddFile(hwndPicker, pszFilename, FALSE); osd_free(utf8_FileName); return rc; }
DWORD win_get_current_directory_utf8(DWORD bufferlength, char* buffer) { DWORD result = 0; TCHAR* t_buffer = NULL; char* utf8_buffer = NULL; if( bufferlength > 0 ) { t_buffer = (TCHAR*)malloc((bufferlength * sizeof(TCHAR)) + 1); if( !t_buffer ) return result; } result = GetCurrentDirectory(bufferlength, t_buffer); if( bufferlength > 0 ) { utf8_buffer = utf8_from_tstring(t_buffer); if( !utf8_buffer ) { osd_free(t_buffer); return result; } } strncpy(buffer, utf8_buffer, bufferlength); if( utf8_buffer ) osd_free(utf8_buffer); if( t_buffer ) free(t_buffer); return result; }
BOOL CALLBACK win_monitor_info::monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data) { osd_monitor_info ***tailptr = (osd_monitor_info ***)data; osd_monitor_info *monitor; MONITORINFOEX info; BOOL result; // get the monitor info info.cbSize = sizeof(info); result = GetMonitorInfo(handle, (LPMONITORINFO)&info); assert(result); (void)result; // to silence gcc 4.6 // guess the aspect ratio assuming square pixels float aspect = (float)(info.rcMonitor.right - info.rcMonitor.left) / (float)(info.rcMonitor.bottom - info.rcMonitor.top); // allocate a new monitor info char *temp = utf8_from_tstring(info.szDevice); // copy in the data monitor = global_alloc(win_monitor_info(handle, temp, aspect)); osd_free(temp); // hook us into the list **tailptr = monitor; *tailptr = &monitor->m_next; // enumerate all the available monitors so to list their names in verbose mode return TRUE; }
//============================================================ // osd_subst_env //============================================================ void osd_subst_env(char **dst, const char *src) { TCHAR buffer[MAX_PATH]; TCHAR *t_src = tstring_from_utf8(src); ExpandEnvironmentStrings(t_src, buffer, ARRAY_LENGTH(buffer)); *dst = utf8_from_tstring(buffer); }
//============================================================ // osd_subst_env //============================================================ void osd_subst_env(std::string &dst, const std::string &src) { TCHAR buffer[MAX_PATH]; auto t_src = tstring_from_utf8(src.c_str()); ExpandEnvironmentStrings(t_src.c_str(), buffer, ARRAY_LENGTH(buffer)); utf8_from_tstring(dst, buffer); }
bool osd_font_windows::open(const char *font_path, const char *_name, int &height) { // accept qualifiers from the name astring name(_name); if (name == "default") name = "Tahoma"; bool bold = (name.replace(0, "[B]", "") + name.replace(0, "[b]", "") > 0); bool italic = (name.replace(0, "[I]", "") + name.replace(0, "[i]", "") > 0); // build a basic LOGFONT description of what we want LOGFONT logfont; logfont.lfHeight = DEFAULT_FONT_HEIGHT; logfont.lfWidth = 0; logfont.lfEscapement = 0; logfont.lfOrientation = 0; logfont.lfWeight = bold ? FW_BOLD : FW_MEDIUM; logfont.lfItalic = italic; logfont.lfUnderline = FALSE; logfont.lfStrikeOut = FALSE; logfont.lfCharSet = ANSI_CHARSET; logfont.lfOutPrecision = OUT_DEFAULT_PRECIS; logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS; logfont.lfQuality = NONANTIALIASED_QUALITY; logfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; // copy in the face name TCHAR *face = tstring_from_utf8(name); _tcsncpy(logfont.lfFaceName, face, sizeof(logfont.lfFaceName) / sizeof(TCHAR)); logfont.lfFaceName[sizeof(logfont.lfFaceName) / sizeof(TCHAR)-1] = 0; osd_free(face); // create the font height = logfont.lfHeight; m_font = CreateFontIndirect(&logfont); if (m_font == NULL) return false; // select it into a temp DC and get the real font name HDC dummyDC = CreateCompatibleDC(NULL); HGDIOBJ oldfont = SelectObject(dummyDC, m_font); TCHAR realname[100]; GetTextFace(dummyDC, ARRAY_LENGTH(realname), realname); SelectObject(dummyDC, oldfont); DeleteDC(dummyDC); // if it doesn't match our request, fail char *utf = utf8_from_tstring(realname); int result = core_stricmp(utf, name); osd_free(utf); // if we didn't match, nuke our font and fall back if (result != 0) { DeleteObject(m_font); m_font = NULL; return false; } return true; }
int _tmain(int argc, TCHAR **argv) #endif // __GNUC__ { int i, rc; char **utf8_argv; #ifdef __GNUC__ TCHAR **argv; #ifdef UNICODE // MinGW doesn't support wmain() directly, so we have to jump through some hoops extern void __wgetmainargs(int *argc, wchar_t ***wargv, wchar_t ***wenviron, int expand_wildcards, int *startupinfo); WCHAR **wenviron; int startupinfo; __wgetmainargs(&argc, &argv, &wenviron, 0, &startupinfo); #else // !UNICODE argv = a_argv; #endif // UNICODE #endif // __GNUC__ #ifdef MALLOC_DEBUG { extern int winalloc_in_main_code; winalloc_in_main_code = TRUE; #endif /* convert arguments to UTF-8 */ utf8_argv = (char **) malloc(argc * sizeof(*argv)); if (utf8_argv == NULL) return 999; for (i = 0; i < argc; i++) { utf8_argv[i] = utf8_from_tstring(argv[i]); if (utf8_argv[i] == NULL) return 999; } /* run utf8_main */ rc = utf8_main(argc, utf8_argv); /* free arguments */ for (i = 0; i < argc; i++) free(utf8_argv[i]); free(utf8_argv); #ifdef MALLOC_DEBUG { void check_unfreed_mem(void); check_unfreed_mem(); } winalloc_in_main_code = FALSE; } #endif return rc; }
static win_monitor_info *pick_monitor(core_options &options, int index) { const char *scrname, *scrname2; win_monitor_info *monitor; int moncount = 0; char option[20]; float aspect; // get the screen option scrname = options_get_string(&options, WINOPTION_SCREEN); sprintf(option, "screen%d", index); scrname2 = options_get_string(&options, option); // decide which one we want to use if (strcmp(scrname2, "auto") != 0) scrname = scrname2; // get the aspect ratio sprintf(option, "aspect%d", index); aspect = get_aspect(options, option, TRUE); // look for a match in the name first if (scrname[0] != 0) for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->next) { char *utf8_device; int rc = 1; moncount++; utf8_device = utf8_from_tstring(monitor->info.szDevice); if (utf8_device != NULL) { rc = strcmp(scrname, utf8_device); osd_free(utf8_device); } if (rc == 0) goto finishit; } // didn't find it; alternate monitors until we hit the jackpot index %= moncount; for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->next) if (index-- == 0) goto finishit; // return the primary just in case all else fails monitor = primary_monitor; finishit: if (aspect != 0) monitor->aspect = aspect; return monitor; }
DWORD win_get_module_file_name_utf8(HMODULE module, char *filename, DWORD size) { TCHAR t_filename[MAX_PATH]; char *utf8_filename; if (GetModuleFileName(module, t_filename, ARRAY_LENGTH(t_filename)) == 0) return 0; utf8_filename = utf8_from_tstring(t_filename); if (!utf8_filename) return 0; size = (DWORD) snprintf(filename, size, "%s", utf8_filename); free(utf8_filename); return size; }
static BOOL DirListReadControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name) { int directory_count; LV_ITEM lvi; TCHAR buffer[2048]; char *utf8_dir_list; int i, pos, driver_index; BOOL res; // determine the directory count; note that one item is the "< >" entry directory_count = ListView_GetItemCount(control); if (directory_count > 0) directory_count--; buffer[0] = '\0'; pos = 0; for (i = 0; i < directory_count; i++) { // append a semicolon, if we're past the first entry if (i > 0) pos += _sntprintf(&buffer[pos], ARRAY_LENGTH(buffer) - pos, TEXT(";")); // retrieve the next entry memset(&lvi, '\0', sizeof(lvi)); lvi.mask = LVIF_TEXT; lvi.iItem = i; lvi.pszText = &buffer[pos]; lvi.cchTextMax = ARRAY_LENGTH(buffer) - pos; res = ListView_GetItem(control, &lvi); // advance the position pos += _tcslen(&buffer[pos]); } utf8_dir_list = utf8_from_tstring(buffer); if (utf8_dir_list != NULL) { driver_index = PropertiesCurrentGame(dialog); SetExtraSoftwarePaths(driver_index, utf8_dir_list); osd_free(utf8_dir_list); } return TRUE; }
void win_monitor_info::refresh() { BOOL result; // fetch the latest info about the monitor m_info.cbSize = sizeof(m_info); result = GetMonitorInfo(m_handle, (LPMONITORINFO)&m_info); assert(result); char *temp = utf8_from_tstring(m_info.szDevice); if (temp) strncpy(m_name, temp, sizeof(m_name)); osd_free(temp); m_pos_size = RECT_to_osd_rect(m_info.rcMonitor); m_usuable_pos_size = RECT_to_osd_rect(m_info.rcWork); m_is_primary = ((m_info.dwFlags & MONITORINFOF_PRIMARY) != 0); (void)result; // to silence gcc 4.6 }
extern "C" int _tmain(int argc, TCHAR **argv) { int i, rc; char **utf8_argv; #ifdef MALLOC_DEBUG { extern int winalloc_in_main_code; winalloc_in_main_code = TRUE; #endif /* convert arguments to UTF-8 */ utf8_argv = (char **) malloc(argc * sizeof(*argv)); if (utf8_argv == NULL) return 999; for (i = 0; i < argc; i++) { utf8_argv[i] = utf8_from_tstring(argv[i]); if (utf8_argv[i] == NULL) return 999; } /* run utf8_main */ rc = utf8_main(argc, utf8_argv); /* free arguments */ for (i = 0; i < argc; i++) free(utf8_argv[i]); free(utf8_argv); #ifdef MALLOC_DEBUG { void check_unfreed_mem(void); check_unfreed_mem(); } winalloc_in_main_code = FALSE; } #endif return rc; }
int win_get_window_text_utf8(HWND window, char *buffer, size_t buffer_size) { int result = 0; char *utf8_buffer = NULL; TCHAR t_buffer[256]; t_buffer[0] = '\0'; // invoke the core Win32 API GetWindowText(window, t_buffer, ARRAY_LENGTH(t_buffer)); utf8_buffer = utf8_from_tstring(t_buffer); if (!utf8_buffer) goto done; result = snprintf(buffer, buffer_size, "%s", utf8_buffer); done: if (utf8_buffer) free(utf8_buffer); return result; }
osd_file::error osd_get_full_path(std::string &dst, std::string const &path) { // convert the path to TCHARs TCHAR *t_path = tstring_from_utf8(path.c_str()); osd_disposer<TCHAR> t_path_disposer(t_path); if (!t_path) return osd_file::error::OUT_OF_MEMORY; // cannonicalize the path TCHAR buffer[MAX_PATH]; if (!GetFullPathName(t_path, ARRAY_LENGTH(buffer), buffer, nullptr)) return win_error_to_file_error(GetLastError()); // convert the result back to UTF-8 char *result = utf8_from_tstring(buffer); osd_disposer<char> result_disposer(result); if (!result) return osd_file::error::OUT_OF_MEMORY; dst = result; return osd_file::error::NONE; }
static void Directories_OnOk(HWND hDlg) { int i; int nResult = 0; LPTSTR s; char* utf8_s; for (i = 0; g_directoryInfo[i].lpName; i++) { if (g_directoryInfo[i].bMulti) { nResult |= RetrieveDirList(i, g_directoryInfo[i].nDirDlgFlags, g_directoryInfo[i].pfnSetTheseDirs); } else { s = FixSlash(DirInfo_Dir(g_pDirInfo, i)); utf8_s = utf8_from_tstring(s); g_directoryInfo[i].pfnSetTheseDirs(utf8_s); osd_free(utf8_s); } } EndDialog(hDlg, nResult); }
static void init_monitors(void) { win_monitor_info **tailptr; // make a list of monitors win_monitor_list = NULL; tailptr = &win_monitor_list; EnumDisplayMonitors(NULL, NULL, monitor_enum_callback, (LPARAM)&tailptr); // if we're verbose, print the list of monitors { win_monitor_info *monitor; for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->next) { char *utf8_device = utf8_from_tstring(monitor->info.szDevice); if (utf8_device != NULL) { mame_printf_verbose("Video: Monitor %p = \"%s\" %s\n", monitor->handle, utf8_device, (monitor == primary_monitor) ? "(primary)" : ""); osd_free(utf8_device); } } } }
file_error osd_get_full_path(char **dst, const char *path) { file_error err; TCHAR *t_path; TCHAR buffer[MAX_PATH]; // convert the path to TCHARs t_path = tstring_from_utf8(path); if (t_path == NULL) { err = FILERR_OUT_OF_MEMORY; goto done; } // cannonicalize the path if (!GetFullPathName(t_path, ARRAY_LENGTH(buffer), buffer, NULL)) { err = win_error_to_mame_file_error(GetLastError()); goto done; } // convert the result back to UTF-8 *dst = utf8_from_tstring(buffer); if (!*dst) { err = FILERR_OUT_OF_MEMORY; goto done; } err = FILERR_NONE; done: if (t_path != NULL) osd_free(t_path); return err; }
bool consolewin_info::handle_command(WPARAM wparam, LPARAM lparam) { if ((HIWORD(wparam) == 0) && (LOWORD(wparam) >= ID_DEVICE_OPTIONS)) { UINT32 const devid = (LOWORD(wparam) - ID_DEVICE_OPTIONS) / DEVOPTION_MAX; image_interface_iterator iter(machine().root_device()); device_image_interface *const img = iter.byindex(devid); if (img != NULL) { switch ((LOWORD(wparam) - ID_DEVICE_OPTIONS) % DEVOPTION_MAX) { case DEVOPTION_OPEN : { astring filter; build_generic_filter(img, false, filter); LPTSTR t_filter = tstring_from_utf8(filter.c_str()); if (t_filter) { // convert a pipe-char delimited string into a NUL delimited string for (int i = 0; t_filter[i] != '\0'; i++) { if (t_filter[i] == '|') t_filter[i] = '\0'; } TCHAR selectedFilename[MAX_PATH]; selectedFilename[0] = '\0'; OPENFILENAME ofn; memset(&ofn, 0, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = NULL; ofn.lpstrFile = selectedFilename; ofn.lpstrFile[0] = '\0'; ofn.nMaxFile = MAX_PATH; ofn.lpstrFilter = t_filter; ofn.nFilterIndex = 1; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; if (GetOpenFileName(&ofn)) { char *utf8_buf = utf8_from_tstring(selectedFilename); if (utf8_buf != NULL) { img->load(utf8_buf); osd_free(utf8_buf); } } osd_free(t_filter); } } return true; //case DEVOPTION_CREATE: //return true; case DEVOPTION_CLOSE: img->unload(); return 1; } if (img->device().type() == CASSETTE) { cassette_image_device *const cassette = downcast<cassette_image_device *>(&img->device()); switch ((LOWORD(wparam) - ID_DEVICE_OPTIONS) % DEVOPTION_MAX) { case DEVOPTION_CASSETTE_STOPPAUSE: cassette->change_state(CASSETTE_STOPPED, CASSETTE_MASK_UISTATE); return true; case DEVOPTION_CASSETTE_PLAY: cassette->change_state(CASSETTE_PLAY, CASSETTE_MASK_UISTATE); return true; case DEVOPTION_CASSETTE_RECORD: cassette->change_state(CASSETTE_RECORD, CASSETTE_MASK_UISTATE); return true; case DEVOPTION_CASSETTE_REWIND: cassette->seek(-60.0, SEEK_CUR); return true; case DEVOPTION_CASSETTE_FASTFORWARD: cassette->seek(+60.0, SEEK_CUR); return true; } } } } return disasmbasewin_info::handle_command(wparam, lparam); }
static int GetCustomVideoModes(ConfigSettings *cs, ModeLine VideoMode[MAX_MODELINES]) { HKEY hKey; int dwIndex = 0, j = -1; int hactive, vactive, vfreq; LONG lRes; TCHAR dv[1024]; TCHAR *DefaultVideo = NULL; DWORD type; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("HARDWARE\\DEVICEMAP\\VIDEO"), 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS) { TCHAR *chsrc, *chdst; DefaultVideo = reg_query_string(hKey, TEXT("\\Device\\Video0")); RegCloseKey(hKey); if (DefaultVideo == NULL) { mame_printf_error("SwitchRes: Failed opening \\Device\\Video0 registry\n"); return -1; } chdst = dv; for (chsrc = DefaultVideo + 18; *chsrc != 0; chsrc++) *chdst++ = *chsrc; *chdst = 0; } else { mame_printf_error("SwitchRes: Failed opening DefaultVideo registry\n"); return -1; } if (cs->verbose) mame_printf_verbose("SwitchRes: DefaultVideo '%s'\n", utf8_from_tstring(dv)); if ((lRes = RegOpenKeyEx(HKEY_LOCAL_MACHINE, dv, 0, KEY_ALL_ACCESS, &hKey)) == ERROR_SUCCESS) { type = 0; TCHAR lpValueName[1024]; char lpData[1024]; DWORD lpcValueName = 1024; DWORD lpcData = 1024; while (RegEnumValue (hKey, dwIndex, lpValueName, &lpcValueName, NULL, &type, (LPBYTE)lpData, &lpcData) != ERROR_NO_MORE_ITEMS) { dwIndex++; if (_tcsstr(lpValueName, TEXT("DALDTMCRTBCD"))) { int hhh = 0, hhi = 0, hhf = 0, hht = 0, vvv = 0, vvi = 0, vvf = 0, vvt = 0, interlace = 0; double dotclock = 0; int checksum; int i = 0, k = 0; int active = 0; if (cs->verbose) mame_printf_verbose("SwitchRes: %s:\n ", utf8_from_tstring(lpValueName)); dotclock = (double)CustomModeDataWord(38, lpData); hhh = (int)RealRes(CustomModeDataWord(10, lpData)); hhi = (int)RealRes(CustomModeDataWord(14, lpData)); hhf = (int)RealRes(CustomModeDataWord(18, lpData)) + hhi; hht = (int)RealRes(CustomModeDataWord(6, lpData)); vvv = CustomModeDataWord(26, lpData); vvi = CustomModeDataWord(30, lpData); vvf = CustomModeDataWord(34, lpData) + vvi; vvt = CustomModeDataWord(22, lpData); interlace = (lpData[3] == 0x0e)?1:0; checksum = CustomModeDataWordBCD(66, lpData); if (cs->verbose) mame_printf_verbose("SwitchRes: (%d/%d) Modeline %.6f %d %d %d %d %d %d %d %d%s\n", checksum, (int)lpcData, (double)((double)dotclock * 10000.0)/1000000.0, (int)RealRes (hhh), (int)RealRes (hhi), (int)RealRes (hhf), (int)RealRes (hht), vvv, vvi, vvf, vvt, (interlace)?" interlace":""); if (sscanf(utf8_from_tstring(lpValueName), "DALDTMCRTBCD%dx%dx0x%d", &hactive, &vactive, &vfreq) != 3) { if (sscanf(utf8_from_tstring(lpValueName), "DALDTMCRTBCD%dX%dX0X%d", &hactive, &vactive, &vfreq) != 3) { mame_printf_info("SwitchRes: Failed getting resolution values from %s\n", utf8_from_tstring(lpValueName)); continue; } } for (k = 0; k < MAX_MODELINES; k++) { if (VideoMode[k].hactive == hactive && VideoMode[k].vactive == vactive && VideoMode[k].vfreq == vfreq) { active = 1; break; } } if (active) { sprintf(VideoMode[k].name, "%dx%d@%d", hactive, vactive, vfreq); VideoMode[k].a_width = hactive; VideoMode[k].a_height = vactive; sprintf(VideoMode[k].resolution, "%dx%d@%d", hactive, vactive, vfreq); VideoMode[k].vfreq = vfreq; VideoMode[k].a_vfreq = (double)(dotclock * 10000.0) / (vvt * hht); VideoMode[k].pclock = dotclock * 10000; VideoMode[k].hactive = hhh; VideoMode[k].hbegin = hhi; VideoMode[k].hend = hhf; VideoMode[k].htotal = hht; VideoMode[k].vactive = vvv; VideoMode[k].vbegin = vvi; VideoMode[k].vend = vvf; VideoMode[k].vtotal = vvt; VideoMode[k].interlace = interlace; VideoMode[k].doublescan = 0; VideoMode[k].custom = 1; for(i=0; i < lpcValueName; i++) { VideoMode[k].label[i] = lpValueName[i]; } VideoMode[k].regdata_size = lpcData; for(i=0; i < VideoMode[k].regdata_size; i++) { VideoMode[k].regdata[i] = lpData[i]; if (cs->verbose > 4) mame_printf_verbose("[%02X]", lpData[i]); } if (cs->verbose > 4) mame_printf_verbose("\n"); j++; } } lpcValueName = 1024; lpcData = 1024; } RegCloseKey(hKey); } else { mame_printf_error("SwitchRes: Failed opening %s registry entry with error %d\n", utf8_from_tstring(dv), (int)lRes); j = -1; } if (DefaultVideo != NULL) global_free(DefaultVideo); return j; }