diff --git a/AppleWin/docs/History.txt b/AppleWin/docs/History.txt index 96387e55..4d60f3c9 100644 --- a/AppleWin/docs/History.txt +++ b/AppleWin/docs/History.txt @@ -15,10 +15,18 @@ tomch at users.berlios.de Latest: ------- + + +1.23.3 - 6 Dec 2013 +------------------- Changes: +. Support cursor keys (in addition to numpad) when using keyboard as joystick emulation +. Support auto-fire for all 3 joystick buttons (via Config->Input) . Debugger: Added "disk info" command +. Added confirmation message box for reboot (F2) Fixes: -. [ Bug #19154 ] ProDOS Order 2IMG crashing +. [Bug #19154] ProDOS Order 2IMG crashing +. [Support #103098] Sometimes swapping disk could cause INIT to fail with ERROR #8 1.23.2 - 14 Sep 2013 diff --git a/AppleWin/resource/Applewin.rc b/AppleWin/resource/Applewin.rc index be227717..1efc821e 100644 --- a/AppleWin/resource/Applewin.rc +++ b/AppleWin/resource/Applewin.rc @@ -110,12 +110,12 @@ BEGIN PUSHBUTTON "&Benchmark Emulator",IDC_BENCHMARK,15,179,85,15 END -IDD_PROPPAGE_INPUT DIALOGEX 0, 0, 210, 182 +IDD_PROPPAGE_INPUT DIALOGEX 0, 0, 210, 215 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_CAPTION | WS_SYSMENU CAPTION "Input" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - GROUPBOX "Joystick Control",IDC_STATIC,5,7,200,66 + GROUPBOX "Joystick Control",IDC_STATIC,5,7,200,101 LTEXT "Joystick &1:",IDC_STATIC,12,20,40,8 COMBOBOX IDC_JOYSTICK0,52,18,100,100,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Joystick &2:",IDC_STATIC,12,35,40,8 @@ -126,17 +126,20 @@ BEGIN LTEXT "&Y-trim:",IDC_STATIC,115,56,28,8 CTEXT "0",IDC_STATIC,137,49,24,20,SS_CENTERIMAGE CONTROL "Spin1",IDC_SPIN_YTRIM,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY,161,53,10,14 + CONTROL "Allow cursor keys to be read from keyboard ",IDC_CURSORCONTROL, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,75,155,10 + CONTROL "Auto-fire (all 3 buttons)",IDC_AUTOFIRE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,90,155,10 CONTROL "&Scroll Lock acts as toggle for full-speed CPU",IDC_SCROLLLOCK_TOGGLE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,81,166,10 - CONTROL "&Mouse interface in slot 4",IDC_MOUSE_IN_SLOT4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,95,106,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,113,166,10 + CONTROL "&Mouse interface in slot 4",IDC_MOUSE_IN_SLOT4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,127,106,10 CONTROL "Show &crosshairs in window's frame",IDC_MOUSE_CROSSHAIR, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,109,159,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,141,159,10 CONTROL "&Restrict mouse to Apple window",IDC_MOUSE_RESTRICT_TO_WINDOW, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,123,121,10 - LTEXT "Microsoft CP/M SoftCard:",IDC_STATIC,5,138,122,10 - COMBOBOX IDC_CPM_CONFIG,90,136,55,60,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Paste &From Clipboard",IDC_PASTE_FROM_CLIPBOARD,5,160,81,14 - LTEXT "(Shift+Insert during emulation)",IDC_STATIC,90,163,111,8 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,155,121,10 + LTEXT "Microsoft CP/M SoftCard:",IDC_STATIC,8,170,122,10 + COMBOBOX IDC_CPM_CONFIG,93,168,55,60,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Paste &From Clipboard",IDC_PASTE_FROM_CLIPBOARD,8,192,81,14 + LTEXT "(Shift+Insert during emulation)",IDC_STATIC,93,195,111,8 END IDD_PROPPAGE_SOUND DIALOGEX 0, 0, 210, 191 @@ -246,8 +249,8 @@ DISK_ICON ICON "DISK.ICO" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,23,2,0 - PRODUCTVERSION 1,23,2,0 + FILEVERSION 1,23,3,0 + PRODUCTVERSION 1,23,3,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -265,12 +268,12 @@ BEGIN VALUE "Comments", "http://applewin.berlios.de" VALUE "CompanyName", "AppleWin" VALUE "FileDescription", "Apple //e Emulator for Windows" - VALUE "FileVersion", "1, 23, 2, 0" + VALUE "FileVersion", "1, 23, 3, 0" VALUE "InternalName", "APPLEWIN" VALUE "LegalCopyright", " 1994-2013 Michael O'Brien, Oliver Schmidt, Tom Charlesworth, Michael Pohoreski, Nick Westgate, Linards Ticmanis" VALUE "OriginalFilename", "APPLEWIN.EXE" VALUE "ProductName", "Apple //e Emulator" - VALUE "ProductVersion", "1, 23, 2, 0" + VALUE "ProductVersion", "1, 23, 3, 0" END END BLOCK "VarFileInfo" @@ -360,6 +363,22 @@ BEGIN END +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_PROPPAGE_INPUT, DIALOG + BEGIN + BOTTOMMARGIN, 182 + END +END +#endif // APSTUDIO_INVOKED + + ///////////////////////////////////////////////////////////////////////////// // // String Table diff --git a/AppleWin/resource/resource.h b/AppleWin/resource/resource.h index 39bd347c..7d0ef83d 100644 --- a/AppleWin/resource/resource.h +++ b/AppleWin/resource/resource.h @@ -101,6 +101,8 @@ #define IDC_GPL_BORDER 1063 #define IDC_APPLEWIN_VERSION 1064 #define IDC_APPLEWIN_ICON 1065 +#define IDC_CURSORCONTROL 1066 +#define IDC_AUTOFIRE 1067 #define IDM_EXIT 40001 #define IDM_HELP 40002 #define IDM_ABOUT 40003 @@ -120,7 +122,7 @@ #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 146 #define _APS_NEXT_COMMAND_VALUE 40012 -#define _APS_NEXT_CONTROL_VALUE 1066 +#define _APS_NEXT_CONTROL_VALUE 1068 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/AppleWin/source/Applewin.cpp b/AppleWin/source/Applewin.cpp index 4e6d408c..0fd0f73e 100644 --- a/AppleWin/source/Applewin.cpp +++ b/AppleWin/source/Applewin.cpp @@ -526,6 +526,11 @@ void LoadConfiguration(void) if(REGLOAD(TEXT(REGVALUE_SCROLLLOCK_TOGGLE), &dwTmp)) sg_PropertySheet.SetScrollLockToggle(dwTmp); + if(REGLOAD(TEXT(REGVALUE_CURSOR_CONTROL), &dwTmp)) + sg_PropertySheet.SetCursorControl(dwTmp); + if(REGLOAD(TEXT(REGVALUE_AUTOFIRE), &dwTmp)) + sg_PropertySheet.SetAutofire(dwTmp); + if(REGLOAD(TEXT(REGVALUE_MOUSE_CROSSHAIR), &dwTmp)) sg_PropertySheet.SetMouseShowCrosshair(dwTmp); if(REGLOAD(TEXT(REGVALUE_MOUSE_RESTRICT_TO_WINDOW), &dwTmp)) diff --git a/AppleWin/source/Common.h b/AppleWin/source/Common.h index bfaa7ab0..2849bc2f 100644 --- a/AppleWin/source/Common.h +++ b/AppleWin/source/Common.h @@ -81,6 +81,8 @@ enum AppMode_e #define REGVALUE_PDL_XTRIM "PDL X-Trim" #define REGVALUE_PDL_YTRIM "PDL Y-Trim" #define REGVALUE_SCROLLLOCK_TOGGLE "ScrollLock Toggle" +#define REGVALUE_CURSOR_CONTROL "Cursor Control" +#define REGVALUE_AUTOFIRE "Autofire" #define REGVALUE_MOUSE_CROSSHAIR "Mouse crosshair" #define REGVALUE_MOUSE_RESTRICT_TO_WINDOW "Mouse restrict to window" #define REGVALUE_THE_FREEZES_F8_ROM "The Freeze's F8 Rom" diff --git a/AppleWin/source/Configuration/IPropertySheet.h b/AppleWin/source/Configuration/IPropertySheet.h index 25544598..b526c469 100644 --- a/AppleWin/source/Configuration/IPropertySheet.h +++ b/AppleWin/source/Configuration/IPropertySheet.h @@ -8,6 +8,10 @@ __interface IPropertySheet UINT GetScrollLockToggle(void); void SetScrollLockToggle(UINT uValue); + UINT GetCursorControl(void); + void SetCursorControl(UINT uValue); + UINT GetAutofire(UINT uButton); + void SetAutofire(UINT uValue); UINT GetMouseShowCrosshair(void); void SetMouseShowCrosshair(UINT uValue); UINT GetMouseRestrictToWindow(void); diff --git a/AppleWin/source/Configuration/PageInput.cpp b/AppleWin/source/Configuration/PageInput.cpp index fbbafc83..accd6fb4 100644 --- a/AppleWin/source/Configuration/PageInput.cpp +++ b/AppleWin/source/Configuration/PageInput.cpp @@ -164,6 +164,8 @@ BOOL CPageInput::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM SendDlgItemMessage(hWnd, IDC_SPIN_XTRIM, UDM_SETPOS, 0, MAKELONG(JoyGetTrim(true),0)); SendDlgItemMessage(hWnd, IDC_SPIN_YTRIM, UDM_SETPOS, 0, MAKELONG(JoyGetTrim(false),0)); + CheckDlgButton(hWnd, IDC_CURSORCONTROL, m_uCursorControl ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_AUTOFIRE, m_bmAutofire ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_SCROLLLOCK_TOGGLE, m_uScrollLockToggle ? BST_CHECKED : BST_UNCHECKED); InitOptions(hWnd); @@ -194,12 +196,16 @@ void CPageInput::DlgOK(HWND hWnd) JoySetTrim((short)SendDlgItemMessage(hWnd, IDC_SPIN_XTRIM, UDM_GETPOS, 0, 0), true); JoySetTrim((short)SendDlgItemMessage(hWnd, IDC_SPIN_YTRIM, UDM_GETPOS, 0, 0), false); + m_uCursorControl = IsDlgButtonChecked(hWnd, IDC_CURSORCONTROL) ? 1 : 0; + m_bmAutofire = IsDlgButtonChecked(hWnd, IDC_AUTOFIRE) ? 7 : 0; // bitmap of 3 bits m_uMouseShowCrosshair = IsDlgButtonChecked(hWnd, IDC_MOUSE_CROSSHAIR) ? 1 : 0; m_uMouseRestrictToWindow = IsDlgButtonChecked(hWnd, IDC_MOUSE_RESTRICT_TO_WINDOW) ? 1 : 0; REGSAVE(TEXT(REGVALUE_PDL_XTRIM), JoyGetTrim(true)); REGSAVE(TEXT(REGVALUE_PDL_YTRIM), JoyGetTrim(false)); REGSAVE(TEXT(REGVALUE_SCROLLLOCK_TOGGLE), m_uScrollLockToggle); + REGSAVE(TEXT(REGVALUE_CURSOR_CONTROL), m_uCursorControl); + REGSAVE(TEXT(REGVALUE_AUTOFIRE), m_bmAutofire); REGSAVE(TEXT(REGVALUE_MOUSE_CROSSHAIR), m_uMouseShowCrosshair); REGSAVE(TEXT(REGVALUE_MOUSE_RESTRICT_TO_WINDOW), m_uMouseRestrictToWindow); @@ -308,6 +314,8 @@ void CPageInput::InitSlotOptions(HWND hWnd) InitJoystickChoices(hWnd, JN_JOYSTICK0, IDC_JOYSTICK0); InitJoystickChoices(hWnd, JN_JOYSTICK1, IDC_JOYSTICK1); + + EnableWindow(GetDlgItem(hWnd, IDC_CURSORCONTROL), JoyUsingKeyboard() ? TRUE : FALSE); } void CPageInput::InitCPMChoices(HWND hWnd) diff --git a/AppleWin/source/Configuration/PageInput.h b/AppleWin/source/Configuration/PageInput.h index dd0da748..74c8ecc8 100644 --- a/AppleWin/source/Configuration/PageInput.h +++ b/AppleWin/source/Configuration/PageInput.h @@ -12,6 +12,8 @@ public: m_Page(PG_INPUT), m_PropertySheetHelper(PropertySheetHelper), m_uScrollLockToggle(0), + m_uCursorControl(1), + m_bmAutofire(0), m_uMouseShowCrosshair(0), m_uMouseRestrictToWindow(0), m_CPMChoice(CPM_UNPLUGGED) @@ -24,6 +26,10 @@ public: UINT GetScrollLockToggle(void){ return m_uScrollLockToggle; } void SetScrollLockToggle(UINT uValue){ m_uScrollLockToggle = uValue; } + UINT GetCursorControl(void){ return m_uCursorControl; } + void SetCursorControl(UINT uValue){ m_uCursorControl = uValue; } + UINT GetAutofire(UINT uButton) { return (m_bmAutofire >> uButton) & 1; } // Get a specific button + void SetAutofire(UINT uValue) { m_bmAutofire = uValue; } // Set all buttons UINT GetMouseShowCrosshair(void){ return m_uMouseShowCrosshair; } void SetMouseShowCrosshair(UINT uValue){ m_uMouseShowCrosshair = uValue; } UINT GetMouseRestrictToWindow(void){ return m_uMouseRestrictToWindow; } @@ -69,6 +75,8 @@ private: CPropertySheetHelper& m_PropertySheetHelper; UINT m_uScrollLockToggle; + UINT m_uCursorControl; // 1 = Allow AppleII to read cursor keys from $C000 (when using keyboard as a joystick) + UINT m_bmAutofire; // bitmask b2:0 UINT m_uMouseShowCrosshair; UINT m_uMouseRestrictToWindow; diff --git a/AppleWin/source/Configuration/PropertySheet.h b/AppleWin/source/Configuration/PropertySheet.h index c7bfa5c7..eb852b0e 100644 --- a/AppleWin/source/Configuration/PropertySheet.h +++ b/AppleWin/source/Configuration/PropertySheet.h @@ -27,6 +27,10 @@ public: virtual UINT GetScrollLockToggle(void){ return m_PageInput.GetScrollLockToggle(); } virtual void SetScrollLockToggle(UINT uValue){ m_PageInput.SetScrollLockToggle(uValue); } + virtual UINT GetCursorControl(void){ return m_PageInput.GetCursorControl(); } + virtual void SetCursorControl(UINT uValue){ m_PageInput.SetCursorControl(uValue); } + virtual UINT GetAutofire(UINT uButton) { return m_PageInput.GetAutofire(uButton); } + virtual void SetAutofire(UINT uValue) { m_PageInput.SetAutofire(uValue); } virtual UINT GetMouseShowCrosshair(void){ return m_PageInput.GetMouseShowCrosshair(); } virtual void SetMouseShowCrosshair(UINT uValue){ m_PageInput.SetMouseShowCrosshair(uValue); } virtual UINT GetMouseRestrictToWindow(void){ return m_PageInput.GetMouseRestrictToWindow(); } diff --git a/AppleWin/source/Debugger/Debugger_Display.cpp b/AppleWin/source/Debugger/Debugger_Display.cpp index 8f3093e5..745eeed3 100644 --- a/AppleWin/source/Debugger/Debugger_Display.cpp +++ b/AppleWin/source/Debugger/Debugger_Display.cpp @@ -762,7 +762,7 @@ int PrintText ( const char * pText, RECT & rRect ) { #if _DEBUG if (! pText) - MessageBox( NULL, "pText = NULL!", "DrawText()", MB_OK ); + MessageBox( g_hFrameWindow, "pText = NULL!", "DrawText()", MB_OK ); #endif int nLen = strlen( pText ); diff --git a/AppleWin/source/Disk.cpp b/AppleWin/source/Disk.cpp index 0fb0b528..075860a6 100644 --- a/AppleWin/source/Disk.cpp +++ b/AppleWin/source/Disk.cpp @@ -50,7 +50,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Public _________________________________________________________________________________________ BOOL enhancedisk = 1; // TODO: Make static & add accessor funcs - string DiskPathFilename[NUM_DRIVES]; // TODO: Move this into Disk_t & add accessor funcs // Private ________________________________________________________________________________________ @@ -61,6 +60,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA { TCHAR imagename[ MAX_DISK_IMAGE_NAME + 1 ]; // (ie. no extension) TCHAR fullname [ MAX_DISK_FULL_NAME + 1 ]; // or : This is persisted to the snapshot file + string strDiskPathFilename; string strFilenameInZip; // 0x00 or HIMAGE imagehandle; // Init'd by DiskInsert() -> ImageOpen() int track; @@ -73,6 +73,26 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA DWORD spinning; DWORD writelight; int nibbles; // Init'd by ReadTrack() -> ImageReadTrack() + + const Disk_t& operator= (const Disk_t& other) + { + memcpy(imagename, other.imagename, sizeof(imagename)); + memcpy(fullname , other.fullname, sizeof(fullname)); + strDiskPathFilename = other.strDiskPathFilename; + strFilenameInZip = other.strFilenameInZip; + imagehandle = other.imagehandle; + track = other.track; + trackimage = other.trackimage; + phase = other.phase; + byte = other.byte; + bWriteProtected = other.bWriteProtected; + trackimagedata = other.trackimagedata; + trackimagedirty = other.trackimagedirty; + spinning = other.spinning; + writelight = other.writelight; + nibbles = other.nibbles; + return *this; + } }; static WORD currdrive = 0; @@ -98,6 +118,16 @@ int DiskGetCurrentTrack(void) { return g_aFloppyDisk[currdrive].track; } int DiskGetCurrentPhase(void) { return g_aFloppyDisk[currdrive].phase; } int DiskGetCurrentOffset(void) { return g_aFloppyDisk[currdrive].byte; } +const string& DiskGetDiskPathFilename(const int iDrive) +{ + return g_aFloppyDisk[iDrive].strDiskPathFilename; +} + +static void DiskSetDiskPathFilename(const int iDrive, const string strPathName) +{ + g_aFloppyDisk[iDrive].strDiskPathFilename = strPathName; +} + char* DiskGetCurrentState(void) { if (g_aFloppyDisk[currdrive].imagehandle == NULL) @@ -127,6 +157,8 @@ char* DiskGetCurrentState(void) void Disk_LoadLastDiskImage(const int iDrive) { + _ASSERT(iDrive == DRIVE_1 || iDrive == DRIVE_2); + char sFilePath[ MAX_PATH + 1]; sFilePath[0] = 0; @@ -137,10 +169,10 @@ char* DiskGetCurrentState(void) if (RegLoadString(TEXT(REG_PREFS),pRegKey,1,sFilePath,MAX_PATH)) { sFilePath[ MAX_PATH ] = 0; - DiskPathFilename[ iDrive ] = sFilePath; + DiskSetDiskPathFilename(iDrive, sFilePath); #if _DEBUG -// MessageBox(NULL,pFileName,pRegKey,MB_OK); +// MessageBox(g_hFrameWindow,pFileName,pRegKey,MB_OK); #endif // _tcscat(imagefilename,TEXT("MASTER.DSK")); // TODO: Should remember last disk by user @@ -149,22 +181,24 @@ char* DiskGetCurrentState(void) DiskInsert(iDrive, sFilePath, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); g_bSaveDiskImage = true; } - //else MessageBox(NULL,"Reg Key/Value not found",pRegKey,MB_OK); + //else MessageBox(g_hFrameWindow,"Reg Key/Value not found",pRegKey,MB_OK); } //=========================================================================== void Disk_SaveLastDiskImage(const int iDrive) { - const char *pFileName = DiskPathFilename[iDrive].c_str(); + _ASSERT(iDrive == DRIVE_1 || iDrive == DRIVE_2); - if (g_bSaveDiskImage) - { - if (iDrive == DRIVE_1) - RegSaveString(TEXT(REG_PREFS),REGVALUE_PREF_LAST_DISK_1,1,pFileName); - else - RegSaveString(TEXT(REG_PREFS),REGVALUE_PREF_LAST_DISK_2,1,pFileName); - } + if (!g_bSaveDiskImage) + return; + + const char *pFileName = DiskGetDiskPathFilename(iDrive).c_str(); + + if (iDrive == DRIVE_1) + RegSaveString(TEXT(REG_PREFS), REGVALUE_PREF_LAST_DISK_1, TRUE, pFileName); + else + RegSaveString(TEXT(REG_PREFS), REGVALUE_PREF_LAST_DISK_2, TRUE, pFileName); } //=========================================================================== @@ -324,7 +358,7 @@ static void RemoveDisk(const int iDrive) memset( pFloppy->imagename, 0, MAX_DISK_IMAGE_NAME+1 ); memset( pFloppy->fullname , 0, MAX_DISK_FULL_NAME +1 ); pFloppy->strFilenameInZip = ""; - DiskPathFilename[iDrive] = ""; + DiskSetDiskPathFilename(iDrive, ""); Disk_SaveLastDiskImage( iDrive ); Video_ResetScreenshotCounter( NULL ); @@ -584,9 +618,9 @@ ImageError_e DiskInsert(const int iDrive, LPCTSTR pszImageFilename, const bool b { GetImageTitle(pszImageFilename, fptr); - DiskPathFilename[iDrive] = pszImageFilename; + DiskSetDiskPathFilename(iDrive, pszImageFilename); - //MessageBox( NULL, imagefilename, fptr->imagename, MB_OK ); + //MessageBox( g_hFrameWindow, imagefilename, fptr->imagename, MB_OK ); Video_ResetScreenshotCounter( fptr->imagename ); } else @@ -827,7 +861,7 @@ void DiskSelectImage(const int iDrive, LPSTR pszFilename) ImageError_e Error = DiskInsert(iDrive, filename, ofn.Flags & OFN_READONLY, IMAGE_CREATE); if (Error == eIMAGE_ERROR_NONE) { - DiskPathFilename[iDrive] = filename; + DiskSetDiskPathFilename(iDrive, filename); filename[ofn.nFileOffset] = 0; if (_tcsicmp(directory, filename)) RegSaveString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_START_DIR), 1, filename); @@ -919,13 +953,12 @@ bool DiskDriveSwap(void) return false; // Swap disks between drives - Disk_t temp; + // . NB. We swap trackimage ptrs (so don't need to swap the buffers' data) + // . TODO: Consider array of Pointers: Disk_t* g_aDrive[] + swap(g_aFloppyDisk[0], g_aFloppyDisk[1]); - // Swap trackimage ptrs (so don't need to swap the buffers' data) - // TODO: Array of Pointers: Disk_t* g_aDrive[] - memcpy(&temp , &g_aFloppyDisk[0], sizeof(Disk_t )); - memcpy(&g_aFloppyDisk[0], &g_aFloppyDisk[1], sizeof(Disk_t )); - memcpy(&g_aFloppyDisk[1], &temp , sizeof(Disk_t )); + Disk_SaveLastDiskImage(DRIVE_1); + Disk_SaveLastDiskImage(DRIVE_2); FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); @@ -1109,8 +1142,9 @@ DWORD DiskSetSnapshot(SS_CARD_DISK2* pSS, DWORD /*dwSlot*/) bImageError = true; // DiskInsert() sets up: - // . fullname // . imagename + // . fullname + // . strDiskPathFilename // . writeprotected } diff --git a/AppleWin/source/Disk.h b/AppleWin/source/Disk.h index 5bf4a850..58a522ca 100644 --- a/AppleWin/source/Disk.h +++ b/AppleWin/source/Disk.h @@ -40,7 +40,7 @@ const bool IMAGE_DONT_CREATE = false; const bool IMAGE_CREATE = true; extern BOOL enhancedisk; -extern string DiskPathFilename[NUM_DRIVES]; +const string& DiskGetDiskPathFilename(const int iDrive); void DiskInitialize(void); // DiskIIManagerStartup() void DiskDestroy(void); // no, doesn't "destroy" the disk image. DiskIIManagerShutdown() diff --git a/AppleWin/source/Frame.cpp b/AppleWin/source/Frame.cpp index 6d6d5fc8..bdeb3a31 100644 --- a/AppleWin/source/Frame.cpp +++ b/AppleWin/source/Frame.cpp @@ -122,7 +122,7 @@ static bool g_bShowingCursor = true; static bool g_bLastCursorInAppleViewport = false; void DrawStatusArea (HDC passdc, BOOL drawflags); -void ProcessButtonClick (int button); +static void ProcessButtonClick (int button, bool bFromButtonUI=false); void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive); void RelayEvent (UINT message, WPARAM wparam, LPARAM lparam); void ResetMachineState (); @@ -792,7 +792,7 @@ LRESULT CALLBACK FrameWndProc ( case WM_DDE_EXECUTE: { LogFileOutput("WM_DDE_EXECUTE\n"); LPTSTR filename = (LPTSTR)GlobalLock((HGLOBAL)lparam); -//MessageBox( NULL, filename, "DDE Exec", MB_OK ); +//MessageBox( g_hFrameWindow, filename, "DDE Exec", MB_OK ); ImageError_e Error = DiskInsert(DRIVE_1, filename, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); if (Error == eIMAGE_ERROR_NONE) { @@ -881,7 +881,7 @@ LRESULT CALLBACK FrameWndProc ( if (wparam == VK_SNAPSHOT_560) { #if _DEBUG -// MessageBox( NULL, "Double 580x384 size!", "PrintScreen", MB_OK ); +// MessageBox( g_hFrameWindow, "Double 580x384 size!", "PrintScreen", MB_OK ); #endif Video_TakeScreenShot( SCREENSHOT_560x384 ); } @@ -891,7 +891,7 @@ LRESULT CALLBACK FrameWndProc ( if( lparam & MOD_SHIFT) { #if _DEBUG -// MessageBox( NULL, "Normal 280x192 size!", "PrintScreen", MB_OK ); +// MessageBox( g_hFrameWindow, "Normal 280x192 size!", "PrintScreen", MB_OK ); #endif } Video_TakeScreenShot( SCREENSHOT_280x192 ); @@ -1051,7 +1051,7 @@ LRESULT CALLBACK FrameWndProc ( EraseButton(wparam-VK_F1); else DrawButton((HDC)0,wparam-VK_F1); - ProcessButtonClick(wparam-VK_F1); + ProcessButtonClick(wparam-VK_F1, true); } else { @@ -1130,7 +1130,7 @@ LRESULT CALLBACK FrameWndProc ( EraseButton(buttonactive); else DrawButton((HDC)0,buttonactive); - ProcessButtonClick(buttonactive); + ProcessButtonClick(buttonactive, true); } buttonactive = -1; } @@ -1496,7 +1496,16 @@ static void ScreenWindowResize(const bool bCtrlKey) } } -void ProcessButtonClick (int button) +static bool ConfirmReboot(bool bFromButtonUI) +{ + if (!bFromButtonUI) + return true; + + int res = MessageBox(g_hFrameWindow, "Are you sure you want to reboot?\n(All data will be lost!)", "Reboot", MB_ICONWARNING|MB_YESNO); + return res == IDYES; +} + +static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) { SoundCore_SetFade(FADE_OUT); @@ -1531,19 +1540,24 @@ void ProcessButtonClick (int button) DiskBoot(); g_nAppMode = MODE_RUNNING; } - else - if (g_nAppMode == MODE_RUNNING) + else if (g_nAppMode == MODE_RUNNING) { - ResetMachineState(); - g_nAppMode = MODE_RUNNING; + if (ConfirmReboot(bFromButtonUI)) + { + ResetMachineState(); + g_nAppMode = MODE_RUNNING; + } } - if ((g_nAppMode == MODE_DEBUG) || (g_nAppMode == MODE_STEPPING)) // exit debugger + else if ((g_nAppMode == MODE_DEBUG) || (g_nAppMode == MODE_STEPPING)) // exit debugger { - // If any breakpoints active and ! we are not running at normal speed - if (g_nBreakpoints && !g_bDebugNormalSpeedBreakpoints) - CmdGo( 0 ); // 6502 runs at full speed, switch to MODE_STEPPNIG - else - DebugEnd(); // 6502 runs at normal speed, switch to MODE_RUNNING + if (ConfirmReboot(bFromButtonUI)) + { + // If any breakpoints active and we are not running at normal speed + if (g_nBreakpoints && !g_bDebugNormalSpeedBreakpoints) + CmdGo(0); // 6502 runs at full speed, switch to MODE_STEPPING + else + DebugEnd(); // 6502 runs at normal speed, switch to MODE_RUNNING + } } DrawStatusArea((HDC)0,DRAW_TITLE); VideoRedrawScreen(); @@ -1626,10 +1640,10 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) //TODO: A directory is open if an empty path to CiderPress is set. This has to be fixed. string filename1= "\""; - filename1.append (DiskPathFilename[iDrive]); - filename1.append ("\""); + filename1.append( DiskGetDiskPathFilename(iDrive) ); + filename1.append("\""); string sFileNameEmpty = "\""; - sFileNameEmpty.append ("\""); + sFileNameEmpty.append("\""); // Load the menu template containing the shortcut menu from the // application's resources. @@ -1691,7 +1705,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) //if(!filename1.compare("\"\"") == false) //Do not use this, for some reason it does not work!!! if(!filename1.compare(sFileNameEmpty) ) { - int MB_Result = MessageBox( NULL, "No disk image loaded. Do you want to run CiderPress anyway?" ,"No disk image.", MB_ICONINFORMATION|MB_YESNO ); + int MB_Result = MessageBox(g_hFrameWindow, "No disk image loaded. Do you want to run CiderPress anyway?" ,"No disk image.", MB_ICONINFORMATION|MB_YESNO); if (MB_Result == IDYES) { if (FileExists (PathToCiderPress )) @@ -1700,7 +1714,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) } else { - MessageBox(NULL, szCiderpressNotFoundText, szCiderpressNotFoundCaption, MB_ICONINFORMATION|MB_OK); + MessageBox(g_hFrameWindow, szCiderpressNotFoundText, szCiderpressNotFoundCaption, MB_ICONINFORMATION|MB_OK); } } } @@ -1712,7 +1726,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) } else { - MessageBox(NULL, szCiderpressNotFoundText, szCiderpressNotFoundCaption, MB_ICONINFORMATION|MB_OK); + MessageBox(g_hFrameWindow, szCiderpressNotFoundText, szCiderpressNotFoundCaption, MB_ICONINFORMATION|MB_OK); } } } diff --git a/AppleWin/source/Joystick.cpp b/AppleWin/source/Joystick.cpp index 05d8d32f..0ec70ad8 100644 --- a/AppleWin/source/Joystick.cpp +++ b/AppleWin/source/Joystick.cpp @@ -39,6 +39,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "StdAfx.h" #include "MouseInterface.h" +#include "Configuration\PropertySheet.h" #define BUTTONTIME 5000 @@ -249,8 +250,7 @@ void JoyInitialize() //=========================================================================== -// TODO: Need some UI config support for cursor keys & selecting whether the key press is also made available to the Apple II (like Jace) -//#define SUPPORT_CURSOR_KEYS +#define SUPPORT_CURSOR_KEYS BOOL JoyProcessKey(int virtkey, BOOL extended, BOOL down, BOOL autorep) { @@ -277,6 +277,7 @@ BOOL JoyProcessKey(int virtkey, BOOL extended, BOOL down, BOOL autorep) // BOOL keychange = 0; + bool bIsCursorKey = false; if (virtkey == VK_MENU) // VK_MENU == ALT Key (Button #0 or #1) { @@ -316,6 +317,8 @@ BOOL JoyProcessKey(int virtkey, BOOL extended, BOOL down, BOOL autorep) if (virtkey == VK_LEFT || virtkey == VK_UP || virtkey == VK_RIGHT || virtkey == VK_DOWN) { keychange = 1; // This prevents cursors keys being available to the Apple II (eg. Lode Runner uses cursor left/right for game speed) + bIsCursorKey = true; + switch (virtkey) { case VK_LEFT: CursorKeys.Left = down; break; @@ -407,53 +410,76 @@ BOOL JoyProcessKey(int virtkey, BOOL extended, BOOL down, BOOL autorep) ypos[nJoyNum] = PDL_CENTRAL + g_nPdlTrimY; } + if (bIsCursorKey && sg_PropertySheet.GetCursorControl()) + { + // Allow AppleII keyboard to see this cursor keypress too + return 0; + } + return 1; } //=========================================================================== +static void DoAutofire(UINT uButton, BOOL& pressed) +{ + static BOOL toggle[3] = {0}; + static BOOL lastPressed[3] = {0}; + + BOOL nowPressed = pressed; + if (sg_PropertySheet.GetAutofire(uButton) && pressed) + { + toggle[uButton] = (!lastPressed[uButton]) ? TRUE : toggle[uButton] = !toggle[uButton]; + pressed = pressed && toggle[uButton]; + } + lastPressed[uButton] = nowPressed; +} + BYTE __stdcall JoyReadButton(WORD, WORD address, BYTE, BYTE, ULONG nCyclesLeft) { - address &= 0xFF; + address &= 0xFF; - if(joyinfo[joytype[0]].device == DEVICE_JOYSTICK) - CheckJoystick0(); - if(joyinfo[joytype[1]].device == DEVICE_JOYSTICK) - CheckJoystick1(); + if(joyinfo[joytype[0]].device == DEVICE_JOYSTICK) + CheckJoystick0(); + if(joyinfo[joytype[1]].device == DEVICE_JOYSTICK) + CheckJoystick1(); - BOOL pressed = 0; - switch (address) { + BOOL pressed = 0; + switch (address) + { + case 0x61: + pressed = (buttonlatch[0] || joybutton[0] || setbutton[0] || keydown[JK_OPENAPPLE]); + if(joyinfo[joytype[1]].device != DEVICE_KEYBOARD) + pressed = (pressed || keydown[JK_BUTTON0]); + buttonlatch[0] = 0; + DoAutofire(0, pressed); + break; - case 0x61: - pressed = (buttonlatch[0] || joybutton[0] || setbutton[0] || keydown[JK_OPENAPPLE]); - if(joyinfo[joytype[1]].device != DEVICE_KEYBOARD) - pressed = (pressed || keydown[JK_BUTTON0]); - buttonlatch[0] = 0; - break; + case 0x62: + pressed = (buttonlatch[1] || joybutton[1] || setbutton[1] || keydown[JK_CLOSEDAPPLE]); + if(joyinfo[joytype[1]].device != DEVICE_KEYBOARD) + pressed = (pressed || keydown[JK_BUTTON1]); + buttonlatch[1] = 0; + DoAutofire(1, pressed); + break; - case 0x62: - pressed = (buttonlatch[1] || joybutton[1] || setbutton[1] || keydown[JK_CLOSEDAPPLE]); - if(joyinfo[joytype[1]].device != DEVICE_KEYBOARD) - pressed = (pressed || keydown[JK_BUTTON1]); - buttonlatch[1] = 0; - break; + case 0x63: + if (IS_APPLE2 && (joyinfo[joytype[1]].device == DEVICE_NONE)) + { + // Apple II/II+ with no joystick has the "SHIFT key mod" + // See Sather's Understanding The Apple II p7-36 + pressed = !(GetKeyState(VK_SHIFT) < 0); + } + else + { + pressed = (buttonlatch[2] || joybutton[2] || setbutton[2]); + DoAutofire(2, pressed); + } + buttonlatch[2] = 0; + break; + } - case 0x63: - if (IS_APPLE2 && (joyinfo[joytype[1]].device == DEVICE_NONE)) - { - // Apple II/II+ with no joystick has the "SHIFT key mod" - // See Sather's Understanding The Apple II p7-36 - pressed = !(GetKeyState(VK_SHIFT) < 0); - } - else - { - pressed = (buttonlatch[2] || joybutton[2] || setbutton[2]); - } - buttonlatch[2] = 0; - break; - - } - return MemReadFloatingBus(pressed, nCyclesLeft); + return MemReadFloatingBus(pressed, nCyclesLeft); } //=========================================================================== @@ -611,11 +637,16 @@ void JoyUpdatePosition() } //=========================================================================== + BOOL JoyUsingMouse() { - return (joyinfo[joytype[0]].device == DEVICE_MOUSE) || (joyinfo[joytype[1]].device == DEVICE_MOUSE); + return (joyinfo[joytype[0]].device == DEVICE_MOUSE) || (joyinfo[joytype[1]].device == DEVICE_MOUSE); } +BOOL JoyUsingKeyboard() +{ + return (joyinfo[joytype[0]].device == DEVICE_KEYBOARD) || (joyinfo[joytype[1]].device == DEVICE_KEYBOARD); +} //=========================================================================== void JoyDisableUsingMouse() diff --git a/AppleWin/source/Joystick.h b/AppleWin/source/Joystick.h index d2fab41b..d9901952 100644 --- a/AppleWin/source/Joystick.h +++ b/AppleWin/source/Joystick.h @@ -12,6 +12,7 @@ BOOL JoySetEmulationType(HWND,DWORD,int, const bool bMousecardActive); void JoySetPosition(int,int,int,int); void JoyUpdatePosition(); BOOL JoyUsingMouse(); +BOOL JoyUsingKeyboard(); void JoyDisableUsingMouse(); void JoySetTrim(short nValue, bool bAxisX); short JoyGetTrim(bool bAxisX); diff --git a/AppleWin/source/Video.cpp b/AppleWin/source/Video.cpp index eec385bf..83e52f18 100644 --- a/AppleWin/source/Video.cpp +++ b/AppleWin/source/Video.cpp @@ -3910,7 +3910,7 @@ void Video_TakeScreenShot( int iScreenShotType ) if (g_nLastScreenShot > nMaxScreenShot) // Holy Crap! User has maxed the number of screenshots!? { sprintf( sScreenShotFileName, "You have more then %d screenshot filenames! They will no longer be saved.\n\nEither move some of your screenshots or increase the maximum in video.cpp\n", nMaxScreenShot ); - MessageBox( NULL, sScreenShotFileName, "Warning", MB_OK ); + MessageBox( g_hFrameWindow, sScreenShotFileName, "Warning", MB_OK ); g_nLastScreenShot = 0; return; } @@ -4031,9 +4031,9 @@ void Video_MakeScreenShot(FILE *pFile) // char sText[256]; // sprintf( sText, "sizeof: BITMAPFILEHEADER = %d\n", sizeof(BITMAPFILEHEADER) ); // = 14 -// MessageBox( NULL, sText, "Info 1", MB_OK ); +// MessageBox( g_hFrameWindow, sText, "Info 1", MB_OK ); // sprintf( sText, "sizeof: BITMAPINFOHEADER = %d\n", sizeof(BITMAPINFOHEADER) ); // = 40 -// MessageBox( NULL, sText, "Info 2", MB_OK ); +// MessageBox( g_hFrameWindow, sText, "Info 2", MB_OK ); char sIfSizeZeroOrUnknown_BadWinBmpHeaderPackingSize[ sizeof( WinBmpHeader_t ) == (14 + 40) ]; sIfSizeZeroOrUnknown_BadWinBmpHeaderPackingSize; @@ -4106,7 +4106,7 @@ void Video_SaveScreenShot( const char *pScreenShotFileName ) if( g_bDisplayPrintScreenFileName ) { - MessageBox( NULL, pScreenShotFileName, "Screen Captured", MB_OK ); + MessageBox( g_hFrameWindow, pScreenShotFileName, "Screen Captured", MB_OK ); } }