void Disk_LoadLastDiskImage(const int iDrive) { _ASSERT(iDrive == DRIVE_1 || iDrive == DRIVE_2); char sFilePath[ MAX_PATH + 1]; sFilePath[0] = 0; char *pRegKey = (iDrive == DRIVE_1) ? REGVALUE_PREF_LAST_DISK_1 : REGVALUE_PREF_LAST_DISK_2; if (RegLoadString(TEXT(REG_PREFS),pRegKey,1,sFilePath,MAX_PATH)) { sFilePath[ MAX_PATH ] = 0; DiskSetDiskPathFilename(iDrive, sFilePath); #if _DEBUG // MessageBox(g_hFrameWindow,pFileName,pRegKey,MB_OK); #endif // _tcscat(imagefilename,TEXT("MASTER.DSK")); // TODO: Should remember last disk by user g_bSaveDiskImage = false; // Pass in ptr to local copy of filepath, since RemoveDisk() sets DiskPathFilename = "" DiskInsert(iDrive, sFilePath, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); g_bSaveDiskImage = true; } //else MessageBox(g_hFrameWindow,"Reg Key/Value not found",pRegKey,MB_OK); }
// Looks like a (bad) C&P from SaveStateSelectImage() // - eg. see "RAPCS" tags below... // Used by: // . CPageDisk: IDC_CIDERPRESS_BROWSE // . CPageAdvanced: IDC_PRINTER_DUMP_FILENAME_BROWSE string CPropertySheetHelper::BrowseToFile(HWND hWindow, TCHAR* pszTitle, TCHAR* REGVALUE, TCHAR* FILEMASKS) { static char PathToFile[MAX_PATH] = {0}; //This is a really awkward way to prevent mixing CiderPress and SaveStated values (RAPCS), but it seem the quickest. Here is its Line 1. strcpy(PathToFile, Snapshot_GetFilename()); //RAPCS, line 2. TCHAR szDirectory[MAX_PATH] = TEXT(""); TCHAR szFilename[MAX_PATH]; strcpy(szFilename, ""); RegLoadString(TEXT("Configuration"), REGVALUE, 1, szFilename ,MAX_PATH); string PathName = szFilename; OPENFILENAME ofn; ZeroMemory(&ofn,sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hWindow; ofn.hInstance = g_hInstance; ofn.lpstrFilter = FILEMASKS; /*ofn.lpstrFilter = TEXT("Applications (*.exe)\0*.exe\0") TEXT("Text files (*.txt)\0*.txt\0") TEXT("All Files\0*.*\0");*/ ofn.lpstrFile = szFilename; ofn.nMaxFile = MAX_PATH; ofn.lpstrInitialDir = szDirectory; ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrTitle = pszTitle; int nRes = GetOpenFileName(&ofn); if(nRes) // Okay is pressed { strcpy(m_szNewFilename, &szFilename[ofn.nFileOffset]); // TODO:TC: m_szNewFilename not used! (Was g_szNewFilename) szFilename[ofn.nFileOffset] = 0; if (_tcsicmp(szDirectory, szFilename)) strcpy(m_szSSNewDirectory, szFilename); // TODO:TC: m_szSSNewDirectory looks dodgy! (Was g_szSSNewDirectory) PathName = szFilename; PathName.append (m_szNewFilename); } else // Cancel is pressed { RegLoadString(TEXT("Configuration"), REGVALUE, 1, szFilename,MAX_PATH); PathName = szFilename; } strcpy(m_szNewFilename, PathToFile); //RAPCS, line 3 (last). return PathName; }
//=========================================================================== BOOL RegLoadValue (LPCTSTR section, LPCTSTR key, BOOL peruser, DWORD *value) { if (!value) return 0; TCHAR buffer[32] = TEXT(""); if (!RegLoadString(section,key,peruser,buffer,32)) return 0; buffer[31] = 0; *value = (DWORD)_ttoi(buffer); return 1; }
// pszFilename is not qualified with path BOOL HD_InsertDisk2(int nDrive, LPCTSTR pszFilename) { if (*pszFilename == 0x00) return false; char szFullFilename[MAX_PATH]; RegLoadString(TEXT("Preferences"),TEXT("HDV Starting Directory"), 1, szFullFilename, MAX_PATH); strcat(szFullFilename, pszFilename); return HD_InsertDisk(nDrive, szFullFilename); }
void HD_Select(int nDrive) { TCHAR directory[MAX_PATH] = TEXT(""); TCHAR filename[MAX_PATH] = TEXT(""); TCHAR title[40]; RegLoadString(TEXT("Preferences"),TEXT("HDV Starting Directory"),1,directory,MAX_PATH); _tcscpy(title,TEXT("Select HDV Image For HDD ")); _tcscat(title,nDrive ? TEXT("2") : TEXT("1")); OPENFILENAME ofn; ZeroMemory(&ofn,sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = g_hFrameWindow; ofn.hInstance = g_hInstance; ofn.lpstrFilter = TEXT("Hard Disk Images (*.hdv,*.po)\0*.hdv;*.po\0") TEXT("All Files\0*.*\0"); ofn.lpstrFile = filename; ofn.nMaxFile = MAX_PATH; ofn.lpstrInitialDir = directory; ofn.Flags = OFN_CREATEPROMPT | OFN_HIDEREADONLY; ofn.lpstrTitle = title; ofn.lpTemplateName = TEXT("INSERT_DIALOG"); if (GetOpenFileName(&ofn)) { if ((!ofn.nFileExtension) || !filename[ofn.nFileExtension]) _tcscat(filename,TEXT(".hdv")); if (HD_InsertDisk(nDrive, filename)) { filename[ofn.nFileOffset] = 0; if (_tcsicmp(directory,filename)) RegSaveString(TEXT("Preferences"),TEXT("HDV Starting Directory"),1,filename); } else { NotifyInvalidImage(filename); } } }
void Disk2InterfaceCard::LoadLastDiskImage(const int drive) { _ASSERT(drive == DRIVE_1 || drive == DRIVE_2); char sFilePath[ MAX_PATH + 1]; sFilePath[0] = 0; const char *pRegKey = (drive == DRIVE_1) ? REGVALUE_PREF_LAST_DISK_1 : REGVALUE_PREF_LAST_DISK_2; if (RegLoadString(TEXT(REG_PREFS), pRegKey, 1, sFilePath, MAX_PATH)) { sFilePath[ MAX_PATH ] = 0; m_saveDiskImage = false; // Pass in ptr to local copy of filepath, since RemoveDisk() sets DiskPathFilename = "" InsertDisk(drive, sFilePath, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); m_saveDiskImage = true; } }
void HD_Select(const int iDrive) { TCHAR directory[MAX_PATH] = TEXT(""); TCHAR filename[MAX_PATH] = TEXT(""); TCHAR title[40]; RegLoadString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_HDV_START_DIR), 1, directory, MAX_PATH); _tcscpy(title, TEXT("Select HDV Image For HDD ")); _tcscat(title, iDrive ? TEXT("2") : TEXT("1")); OPENFILENAME ofn; ZeroMemory(&ofn,sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = g_hFrameWindow; ofn.hInstance = g_hInstance; ofn.lpstrFilter = TEXT("Hard Disk Images (*.hdv,*.po,*.2mg,*.2img,*.gz,*.zip)\0*.hdv;*.po;*.2mg;*.2img;*.gz;*.zip\0") TEXT("All Files\0*.*\0"); ofn.lpstrFile = filename; ofn.nMaxFile = MAX_PATH; ofn.lpstrInitialDir = directory; ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; // Don't allow creation & hide the read-only checkbox ofn.lpstrTitle = title; if (GetOpenFileName(&ofn)) { if ((!ofn.nFileExtension) || !filename[ofn.nFileExtension]) _tcscat(filename,TEXT(".hdv")); if (HD_InsertDisk(iDrive, filename)) { filename[ofn.nFileOffset] = 0; if (_tcsicmp(directory, filename)) RegSaveString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_HDV_START_DIR), 1, filename); } else { NotifyInvalidImage(filename); } } }
//=========================================================================== void TapeSelect() { char directory[MAX_PATH] = ""; char filename[MAX_PATH] = ""; char title[40]; OPENFILENAME ofn; RegLoadString(PREFERENCIAS, DIRINIC, 1, directory, MAX_PATH); strcpy(title,"Selecione a imagem do tape"); ZeroMemory(&ofn,sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = framewindow; ofn.hInstance = instance; ofn.lpstrFilter = "Imagens de Tape (*.ct2)\0*.ct2\0"; ofn.lpstrFile = filename; ofn.nMaxFile = MAX_PATH; ofn.lpstrInitialDir = directory; ofn.Flags = OFN_PATHMUSTEXIST; ofn.lpstrTitle = title; if (GetOpenFileName(&ofn)) { int error; if ((!ofn.nFileExtension) || !filename[ofn.nFileExtension]) strcat(filename,".ct2"); error = TapeInsere(filename, ofn.Flags & OFN_READONLY, 1); if (!error) { //strcpy(NomeTitulo, filename + ofn.nFileOffset); TapePegaTitulo(filename + ofn.nFileOffset); filename[ofn.nFileOffset] = 0; if (stricmp(directory, filename)) RegSaveString(PREFERENCIAS, DIRINIC, 1, filename); FrameRefreshStatus(DRAW_BACKGROUND | DRAW_LEDS); } else TapeNotifyInvalidImage(filename, error); } }
/* load a string from subkey */ bool CReg::LoadString (LPCTSTR pszSubKey, LPCTSTR pszValName, CString &sString) { return RegLoadString (hKey, pszSubKey, pszValName, sString); }
/* load a string from subkey */ bool CReg::LoadString (LPCTSTR pszSubKey, LPCTSTR pszValName, LPTSTR pszString, DWORD dwLength) { return RegLoadString (hKey, pszSubKey, pszValName, pszString, dwLength); }
BOOL CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam) { switch (message) { case WM_NOTIFY: { // Property Sheet notifications switch (((LPPSHNOTIFY)lparam)->hdr.code) { case PSN_SETACTIVE: // About to become the active page m_PropertySheetHelper.SetLastPage(m_Page); InitOptions(hWnd); break; case PSN_KILLACTIVE: SetWindowLong(hWnd, DWL_MSGRESULT, FALSE); // Changes are valid break; case PSN_APPLY: DlgOK(hWnd); SetWindowLong(hWnd, DWL_MSGRESULT, PSNRET_NOERROR); // Changes are valid break; case PSN_QUERYCANCEL: // Can use this to ask user to confirm cancel break; case PSN_RESET: DlgCANCEL(hWnd); break; } } break; case WM_COMMAND: switch (LOWORD(wparam)) { case IDC_COMBO_DISK1: if (HIWORD(wparam) == CBN_SELCHANGE) { HandleDiskCombo(hWnd, DRIVE_1, LOWORD(wparam)); FrameRefreshStatus(DRAW_BUTTON_DRIVES); } break; case IDC_COMBO_DISK2: if (HIWORD(wparam) == CBN_SELCHANGE) { HandleDiskCombo(hWnd, DRIVE_2, LOWORD(wparam)); FrameRefreshStatus(DRAW_BUTTON_DRIVES); } break; case IDC_COMBO_HDD1: if (HIWORD(wparam) == CBN_SELCHANGE) { HandleHDDCombo(hWnd, HARDDISK_1, LOWORD(wparam)); } break; case IDC_COMBO_HDD2: if (HIWORD(wparam) == CBN_SELCHANGE) { HandleHDDCombo(hWnd, HARDDISK_2, LOWORD(wparam)); } break; case IDC_HDD_ENABLE: EnableHDD(hWnd, IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE)); break; case IDC_HDD_SWAP: HandleHDDSwap(hWnd); break; case IDC_CIDERPRESS_BROWSE: { std::string CiderPressLoc = m_PropertySheetHelper.BrowseToFile(hWnd, TEXT("Select path to CiderPress"), REGVALUE_CIDERPRESSLOC, TEXT("Applications (*.exe)\0*.exe\0") TEXT("All Files\0*.*\0") ); RegSaveString(TEXT(REG_CONFIG), REGVALUE_CIDERPRESSLOC, 1, CiderPressLoc.c_str()); SendDlgItemMessage(hWnd, IDC_CIDERPRESS_FILENAME, WM_SETTEXT, 0, (LPARAM) CiderPressLoc.c_str()); } break; } break; case WM_INITDIALOG: { m_PropertySheetHelper.FillComboBox(hWnd, IDC_DISKTYPE, m_discchoices, sg_Disk2Card.GetEnhanceDisk() ? 1 : 0); m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK1, m_defaultDiskOptions, -1); m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK2, m_defaultDiskOptions, -1); if (strlen(sg_Disk2Card.GetFullName(DRIVE_1)) > 0) { SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_INSERTSTRING, 0, (LPARAM)sg_Disk2Card.GetFullName(DRIVE_1)); SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_SETCURSEL, 0, 0); } if (strlen(sg_Disk2Card.GetFullName(DRIVE_2)) > 0) { SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_INSERTSTRING, 0, (LPARAM)sg_Disk2Card.GetFullName(DRIVE_2)); SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_SETCURSEL, 0, 0); } InitComboHDD(hWnd); TCHAR PathToCiderPress[MAX_PATH] = ""; RegLoadString(TEXT(REG_CONFIG), REGVALUE_CIDERPRESSLOC, 1, PathToCiderPress,MAX_PATH); SendDlgItemMessage(hWnd, IDC_CIDERPRESS_FILENAME ,WM_SETTEXT, 0, (LPARAM)PathToCiderPress); CheckDlgButton(hWnd, IDC_HDD_ENABLE, HD_CardIsEnabled() ? BST_CHECKED : BST_UNCHECKED); EnableHDD(hWnd, IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE)); InitOptions(hWnd); break; } } return FALSE; }
/* load a string */ bool CReg::LoadString (LPCTSTR pszValName, CString &sString) { return RegLoadString (hKey, nullptr, pszValName, sString); }
//Reads configuration from the registry entries void LoadConfiguration(void) { DWORD dwComputerType; if (REGLOAD(TEXT(REGVALUE_APPLE2_TYPE), &dwComputerType)) { if ((dwComputerType >= A2TYPE_MAX) || (dwComputerType >= A2TYPE_UNDEFINED && dwComputerType < A2TYPE_CLONE)) dwComputerType = A2TYPE_APPLE2EENHANCED; g_Apple2Type = (eApple2Type) dwComputerType; } else // Support older AppleWin registry entries { REGLOAD(TEXT(REGVALUE_OLD_APPLE2_TYPE), &dwComputerType); switch (dwComputerType) { // NB. No A2TYPE_APPLE2E (this is correct) case 0: g_Apple2Type = A2TYPE_APPLE2; case 1: g_Apple2Type = A2TYPE_APPLE2PLUS; case 2: g_Apple2Type = A2TYPE_APPLE2EENHANCED; default: g_Apple2Type = A2TYPE_APPLE2EENHANCED; } } switch (g_Apple2Type) //Sets the character set for the Apple model/clone { case A2TYPE_APPLE2: g_nCharsetType = 0; break; case A2TYPE_APPLE2PLUS: g_nCharsetType = 0; break; case A2TYPE_APPLE2E: g_nCharsetType = 0; break; case A2TYPE_APPLE2EENHANCED:g_nCharsetType = 0; break; case A2TYPE_PRAVETS82: g_nCharsetType = 1; break; case A2TYPE_PRAVETS8A: g_nCharsetType = 2; break; case A2TYPE_PRAVETS8M: g_nCharsetType = 3; break; //This charset has a very small difference with the PRAVETS82 one an probably has some misplaced characters. Still the Pravets82 charset is used, because setting charset to 3 results in some problems. } // if (!REGLOAD(TEXT(REGVALUE_JOYSTICK0_EMU_TYPE), &joytype[JN_JOYSTICK0])) LoadConfigOldJoystick(JN_JOYSTICK0); if (!REGLOAD(TEXT(REGVALUE_JOYSTICK1_EMU_TYPE), &joytype[JN_JOYSTICK1])) LoadConfigOldJoystick(JN_JOYSTICK1); REGLOAD(TEXT("Sound Emulation") ,&soundtype); char aySerialPortName[ CSuperSerialCard::SIZEOF_SERIALCHOICE_ITEM ]; if (RegLoadString( TEXT("Configuration"), TEXT(REGVALUE_SERIAL_PORT_NAME), TRUE, aySerialPortName, sizeof(aySerialPortName) ) ) { sg_SSC.SetSerialPortName(aySerialPortName); } REGLOAD(TEXT(REGVALUE_EMULATION_SPEED) ,&g_dwSpeed); REGLOAD(TEXT(REGVALUE_ENHANCE_DISK_SPEED),(DWORD *)&enhancedisk); Config_Load_Video(); REGLOAD(TEXT("Uthernet Active") ,(DWORD *)&tfe_enabled); SetCurrentCLK6502(); // DWORD dwTmp; if(REGLOAD(TEXT(REGVALUE_THE_FREEZES_F8_ROM), &dwTmp)) sg_PropertySheet.SetTheFreezesF8Rom(dwTmp); if(REGLOAD(TEXT(REGVALUE_SPKR_VOLUME), &dwTmp)) SpkrSetVolume(dwTmp, sg_PropertySheet.GetVolumeMax()); if(REGLOAD(TEXT(REGVALUE_MB_VOLUME), &dwTmp)) MB_SetVolume(dwTmp, sg_PropertySheet.GetVolumeMax()); if(REGLOAD(TEXT(REGVALUE_SAVE_STATE_ON_EXIT), &dwTmp)) g_bSaveStateOnExit = dwTmp ? true : false; if(REGLOAD(TEXT(REGVALUE_DUMP_TO_PRINTER), &dwTmp)) g_bDumpToPrinter = dwTmp ? true : false; if(REGLOAD(TEXT(REGVALUE_CONVERT_ENCODING), &dwTmp)) g_bConvertEncoding = dwTmp ? true : false; if(REGLOAD(TEXT(REGVALUE_FILTER_UNPRINTABLE), &dwTmp)) g_bFilterUnprintable = dwTmp ? true : false; if(REGLOAD(TEXT(REGVALUE_PRINTER_APPEND), &dwTmp)) g_bPrinterAppend = dwTmp ? true : false; if(REGLOAD(TEXT(REGVALUE_HDD_ENABLED), &dwTmp)) HD_SetEnabled(dwTmp ? true : false); char szHDVPathname[MAX_PATH] = {0}; if(RegLoadString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_LAST_HARDDISK_1), 1, szHDVPathname, sizeof(szHDVPathname))) HD_InsertDisk(HARDDISK_1, szHDVPathname); if(RegLoadString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_LAST_HARDDISK_2), 1, szHDVPathname, sizeof(szHDVPathname))) HD_InsertDisk(HARDDISK_2, szHDVPathname); if(REGLOAD(TEXT(REGVALUE_PDL_XTRIM), &dwTmp)) JoySetTrim((short)dwTmp, true); if(REGLOAD(TEXT(REGVALUE_PDL_YTRIM), &dwTmp)) JoySetTrim((short)dwTmp, false); if(REGLOAD(TEXT(REGVALUE_SCROLLLOCK_TOGGLE), &dwTmp)) sg_PropertySheet.SetScrollLockToggle(dwTmp); if(REGLOAD(TEXT(REGVALUE_CURSOR_CONTROL), &dwTmp)) sg_PropertySheet.SetJoystickCursorControl(dwTmp); if(REGLOAD(TEXT(REGVALUE_AUTOFIRE), &dwTmp)) sg_PropertySheet.SetAutofire(dwTmp); if(REGLOAD(TEXT(REGVALUE_CENTERING_CONTROL), &dwTmp)) sg_PropertySheet.SetJoystickCenteringControl(dwTmp); if(REGLOAD(TEXT(REGVALUE_MOUSE_CROSSHAIR), &dwTmp)) sg_PropertySheet.SetMouseShowCrosshair(dwTmp); if(REGLOAD(TEXT(REGVALUE_MOUSE_RESTRICT_TO_WINDOW), &dwTmp)) sg_PropertySheet.SetMouseRestrictToWindow(dwTmp); if(REGLOAD(TEXT(REGVALUE_SLOT4), &dwTmp)) g_Slot4 = (SS_CARDTYPE) dwTmp; if(REGLOAD(TEXT(REGVALUE_SLOT5), &dwTmp)) g_Slot5 = (SS_CARDTYPE) dwTmp; if (g_Slot4 == CT_MockingboardC || g_Slot4 == CT_Phasor) MB_SetSoundcardType(g_Slot4); else MB_SetSoundcardType(CT_Empty); // char szFilename[MAX_PATH] = {0}; // Current/Starting Dir is the "root" of where the user keeps his disk images RegLoadString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_START_DIR), 1, szFilename, MAX_PATH); if (szFilename[0] == 0) GetCurrentDirectory(sizeof(szFilename), szFilename); SetCurrentImageDir(szFilename); Disk_LoadLastDiskImage(DRIVE_1); Disk_LoadLastDiskImage(DRIVE_2); // szFilename[0] = 0; RegLoadString(TEXT(REG_CONFIG),TEXT(REGVALUE_SAVESTATE_FILENAME),1,szFilename,sizeof(szFilename)); Snapshot_SetFilename(szFilename); // If not in Registry than default will be used (ie. g_sCurrentDir + default filename) szFilename[0] = 0; RegLoadString(TEXT(REG_CONFIG),TEXT(REGVALUE_PRINTER_FILENAME),1,szFilename,sizeof(szFilename)); Printer_SetFilename(szFilename); // If not in Registry than default will be used dwTmp = 10; REGLOAD(TEXT(REGVALUE_PRINTER_IDLE_LIMIT), &dwTmp); Printer_SetIdleLimit(dwTmp); char szUthernetInt[MAX_PATH] = {0}; RegLoadString(TEXT(REG_CONFIG),TEXT("Uthernet Interface"),1,szUthernetInt,MAX_PATH); update_tfe_interface(szUthernetInt,NULL); if (REGLOAD(TEXT(REGVALUE_WINDOW_SCALE), &dwTmp)) SetViewportScale(dwTmp); if (REGLOAD(TEXT(REGVALUE_CONFIRM_REBOOT), &dwTmp)) g_bConfirmReboot = dwTmp; }