From 7232ebe52396f2c0dc94ad3a5ea9761f3c781c3f Mon Sep 17 00:00:00 2001 From: tomch Date: Sat, 2 Nov 2013 21:24:45 +0000 Subject: [PATCH] Applied Nick's patch for 'disk info' cmd --- AppleWin/docs/History.txt | 3 +- AppleWin/source/Debugger/Debug.cpp | 25 +++++++++++++- .../source/Debugger/Debugger_Commands.cpp | 1 + AppleWin/source/Debugger/Debugger_Types.h | 1 + AppleWin/source/Disk.cpp | 34 ++++++++++++++++++- AppleWin/source/Disk.h | 5 +++ 6 files changed, 66 insertions(+), 3 deletions(-) diff --git a/AppleWin/docs/History.txt b/AppleWin/docs/History.txt index ce735d7b..96387e55 100644 --- a/AppleWin/docs/History.txt +++ b/AppleWin/docs/History.txt @@ -15,7 +15,8 @@ tomch at users.berlios.de Latest: ------- - +Changes: +. Debugger: Added "disk info" command Fixes: . [ Bug #19154 ] ProDOS Order 2IMG crashing diff --git a/AppleWin/source/Debugger/Debug.cpp b/AppleWin/source/Debugger/Debug.cpp index 3815ce3f..8ea5081d 100644 --- a/AppleWin/source/Debugger/Debug.cpp +++ b/AppleWin/source/Debugger/Debug.cpp @@ -3620,9 +3620,32 @@ Update_t CmdDisk ( int nArgs) if (! nArgs) goto _Help; + // check for info command + int iParam = 0; + int nInfoFound = FindParam( g_aArgs[ 1 ].sArg, MATCH_EXACT, iParam, _PARAM_DISK_BEGIN, _PARAM_DISK_END ); + if (iParam == PARAM_DISK_INFO) + { + if (nArgs > 2) + goto _Help; + + int drive = DiskGetCurrentDrive() + 1; + char buffer[200] = ""; + sprintf(buffer, "D%d at T$%X (%d), phase $%X, offset $%X, %s", + drive, + DiskGetCurrentTrack(), + DiskGetCurrentTrack(), + DiskGetCurrentPhase(), + DiskGetCurrentOffset(), + DiskGetCurrentState()); + + ConsoleBufferPush(buffer); + return ConsoleUpdate(); + } + if (nArgs < 2) goto _Help; + // first param should be drive int iDrive = g_aArgs[ 1 ].nValue; if ((iDrive < 1) || (iDrive > 2)) @@ -3630,7 +3653,7 @@ Update_t CmdDisk ( int nArgs) iDrive--; - int iParam = 0; + // second param is command int nFound = FindParam( g_aArgs[ 2 ].sArg, MATCH_EXACT, iParam, _PARAM_DISK_BEGIN, _PARAM_DISK_END ); if (! nFound) diff --git a/AppleWin/source/Debugger/Debugger_Commands.cpp b/AppleWin/source/Debugger/Debugger_Commands.cpp index 8ad5894f..fc5fd10f 100644 --- a/AppleWin/source/Debugger/Debugger_Commands.cpp +++ b/AppleWin/source/Debugger/Debugger_Commands.cpp @@ -418,6 +418,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {TEXT("TARGET") , NULL, PARAM_CONFIG_TARGET }, // Disk {TEXT("EJECT") , NULL, PARAM_DISK_EJECT }, + {TEXT("INFO") , NULL, PARAM_DISK_INFO }, {TEXT("PROTECT") , NULL, PARAM_DISK_PROTECT }, {TEXT("READ") , NULL, PARAM_DISK_READ }, // Font (Config) diff --git a/AppleWin/source/Debugger/Debugger_Types.h b/AppleWin/source/Debugger/Debugger_Types.h index d3eb3f8a..f0140e6a 100644 --- a/AppleWin/source/Debugger/Debugger_Types.h +++ b/AppleWin/source/Debugger/Debugger_Types.h @@ -1315,6 +1315,7 @@ const DisasmData_t* pDisasmData; // Disk , _PARAM_DISK_BEGIN = _PARAM_CONFIG_END // Daisy Chain , PARAM_DISK_EJECT = _PARAM_DISK_BEGIN // DISK 1 EJECT + , PARAM_DISK_INFO // DISK 1 INFO , PARAM_DISK_PROTECT // DISK 1 PROTECT , PARAM_DISK_READ // DISK 1 READ Track Sector NumSectors MemAddress , _PARAM_DISK_END diff --git a/AppleWin/source/Disk.cpp b/AppleWin/source/Disk.cpp index b1474be7..0fb0b528 100644 --- a/AppleWin/source/Disk.cpp +++ b/AppleWin/source/Disk.cpp @@ -93,7 +93,39 @@ static void WriteTrack (int drive); //=========================================================================== -void Disk_LoadLastDiskImage(const int iDrive) +int DiskGetCurrentDrive(void) { return currdrive; } +int DiskGetCurrentTrack(void) { return g_aFloppyDisk[currdrive].track; } +int DiskGetCurrentPhase(void) { return g_aFloppyDisk[currdrive].phase; } +int DiskGetCurrentOffset(void) { return g_aFloppyDisk[currdrive].byte; } + +char* DiskGetCurrentState(void) +{ + if (g_aFloppyDisk[currdrive].imagehandle == NULL) + return "Empty"; + + if (!floppymotoron) + { + if (g_aFloppyDisk[currdrive].spinning > 0) + return "Off (spinning)"; + else + return "Off"; + } + else if (floppywritemode) + { + if (g_aFloppyDisk[currdrive].bWriteProtected) + return "Writing"; + else + return "Writing (write protected)"; + } + else + { + return "Reading"; + } +} + +//=========================================================================== + + void Disk_LoadLastDiskImage(const int iDrive) { char sFilePath[ MAX_PATH + 1]; sFilePath[0] = 0; diff --git a/AppleWin/source/Disk.h b/AppleWin/source/Disk.h index 903b5d12..5bf4a850 100644 --- a/AppleWin/source/Disk.h +++ b/AppleWin/source/Disk.h @@ -60,6 +60,11 @@ void DiskNotifyInvalidImage(const int iDrive, LPCTSTR pszImageFilename, const void DiskReset(void); bool DiskGetProtect(const int iDrive); void DiskSetProtect(const int iDrive, const bool bWriteProtect); +int DiskGetCurrentDrive(); +int DiskGetCurrentTrack(); +int DiskGetCurrentPhase(); +int DiskGetCurrentOffset(); +char* DiskGetCurrentState(); void DiskSelect(const int iDrive); void DiskUpdatePosition(DWORD); bool DiskDriveSwap(void);