From 9f8ad1a65b3f2080ffa775de1e67630390c85133 Mon Sep 17 00:00:00 2001 From: michaelangel007 Date: Mon, 21 Jul 2014 18:21:31 -0700 Subject: [PATCH 01/10] WIP show current disk track --- source/Disk.cpp | 12 ++++++++ source/Disk.h | 1 + source/Frame.cpp | 77 ++++++++++++++++++++++++++++++++++++++---------- source/Frame.h | 2 ++ 4 files changed, 77 insertions(+), 15 deletions(-) diff --git a/source/Disk.cpp b/source/Disk.cpp index 938bdc00..56e31b2c 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -64,6 +64,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA string strFilenameInZip; // 0x00 or HIMAGE imagehandle; // Init'd by DiskInsert() -> ImageOpen() int track; + int nLastTrack; LPBYTE trackimage; int phase; int byte; @@ -82,6 +83,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA strFilenameInZip = other.strFilenameInZip; imagehandle = other.imagehandle; track = other.track; + nLastTrack = other.nLastTrack; trackimage = other.trackimage; phase = other.phase; byte = other.byte; @@ -117,6 +119,7 @@ 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; } +int DiskGetTrack( int drive ) { return g_aFloppyDisk[ drive ].track; } const string& DiskGetDiskPathFilename(const int iDrive) { @@ -784,6 +787,15 @@ static BYTE __stdcall DiskReadWrite (WORD programcounter, WORD, BYTE, BYTE, ULON if (!fptr->trackimagedata) return 0xFF; + // Bug # .. Show Track status + if( fptr->nLastTrack != fptr->track ) + { + fptr->nLastTrack = fptr->track; + + //FrameRefreshStatus(DRAW_LEDS); + DrawStatusAreaDisk( (HDC)0 ); + } + BYTE result = 0; if (!floppywritemode || !fptr->bWriteProtected) diff --git a/source/Disk.h b/source/Disk.h index 58a522ca..c38b346b 100644 --- a/source/Disk.h +++ b/source/Disk.h @@ -62,6 +62,7 @@ bool DiskGetProtect(const int iDrive); void DiskSetProtect(const int iDrive, const bool bWriteProtect); int DiskGetCurrentDrive(); int DiskGetCurrentTrack(); +int DiskGetTrack( int drive ); int DiskGetCurrentPhase(); int DiskGetCurrentOffset(); char* DiskGetCurrentState(); diff --git a/source/Frame.cpp b/source/Frame.cpp index 7ed59233..5e87c8b3 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -546,6 +546,62 @@ static void DrawFrameWindow () } +void DrawStatusAreaDisk( HDC passdc ) +{ + FrameReleaseDC(); + HDC dc = (passdc ? passdc : GetDC(g_hFrameWindow)); +// HDC dc = g_hFrameDC; + + int x = buttonx; + int y = buttony+BUTTONS*BUTTONCY+1; + + Disk_Status_e eDrive1Status = DISK_STATUS_OFF; + Disk_Status_e eDrive2Status = DISK_STATUS_OFF; + DiskGetLightStatus(&eDrive1Status, &eDrive2Status); + + int Disk1Track = DiskGetTrack(0); + int Disk2Track = DiskGetTrack(1); + + if (g_bIsFullScreen) + { +/* + SelectObject(dc,smallfont); + SetBkMode(dc,OPAQUE); + SetBkColor(dc,RGB(0,0,0)); + SetTextAlign(dc,TA_LEFT | TA_TOP); +*/ + SetTextColor(dc, g_aDiskFullScreenColorsLED[ eDrive1Status ] ); + TextOut(dc,x+ 3,y+2,TEXT("1"),1); + + SetTextColor(dc, g_aDiskFullScreenColorsLED[ eDrive2Status ] ); + TextOut(dc,x+13,y+2,TEXT("2"),1); + } + else + { + RECT rDiskLed = {0,0,8,8}; + + DrawBitmapRect(dc,x+12,y+6,&rDiskLed,g_hDiskWindowedLED[eDrive1Status]); + DrawBitmapRect(dc,x+31,y+6,&rDiskLed,g_hDiskWindowedLED[eDrive2Status]); + + // Track/Sector + SelectObject(dc,smallfont); + SetTextAlign(dc,TA_CENTER | TA_TOP); + SetTextColor(dc,RGB(0,0,0)); + SetBkMode(dc,TRANSPARENT); +// SetBkMode(dc,OPAQUE); + + char buffer[16] = ""; + sprintf_s( buffer, sizeof(buffer), "%2d ", Disk1Track ); + TextOut(dc,x+16,y+5,buffer, strlen(buffer) ); // 1 + + sprintf_s( buffer, sizeof(buffer), "%2d ", Disk2Track ); + TextOut(dc,x+35,y+5,buffer, strlen(buffer) ); + } + +// if (!passdc) +// ReleaseDC(g_hFrameWindow,dc); +} + //=========================================================================== static void DrawStatusArea (HDC passdc, int drawflags) { @@ -556,10 +612,6 @@ static void DrawStatusArea (HDC passdc, int drawflags) const bool bCaps = KeybGetCapsStatus(); //const bool bP8Caps = KeybGetP8CapsStatus(); // TODO: FIXME: Not used ?! Should show the LED status ... - Disk_Status_e eDrive1Status = DISK_STATUS_OFF; - Disk_Status_e eDrive2Status = DISK_STATUS_OFF; - DiskGetLightStatus(&eDrive1Status, &eDrive2Status); - #if HD_LED // 1.19.0.0 Hard Disk Status/Indicator Light Disk_Status_e eHardDriveStatus = DISK_STATUS_OFF; @@ -573,11 +625,7 @@ static void DrawStatusArea (HDC passdc, int drawflags) SetBkColor(dc,RGB(0,0,0)); SetTextAlign(dc,TA_LEFT | TA_TOP); - SetTextColor(dc, g_aDiskFullScreenColorsLED[ eDrive1Status ] ); - TextOut(dc,x+ 3,y+2,TEXT("1"),1); - - SetTextColor(dc, g_aDiskFullScreenColorsLED[ eDrive2Status ] ); - TextOut(dc,x+13,y+2,TEXT("2"),1); +// DrawStatusAreaDisk( passdc ); #if HD_LED SetTextColor(dc, g_aDiskFullScreenColorsLED[ eHardDriveStatus ] ); @@ -618,9 +666,8 @@ static void DrawStatusArea (HDC passdc, int drawflags) TextOut(dc,x+BUTTONCX/2,y+13,(g_nAppMode == MODE_PAUSED ? TITLE_PAUSED : TITLE_STEPPING) ,8); - } - else + else // g_bIsFullScreen { if (drawflags & DRAW_BACKGROUND) { @@ -638,12 +685,10 @@ static void DrawStatusArea (HDC passdc, int drawflags) // 1.19.0.0 Hard Disk Status/Indicator Light TextOut(dc,x+ 7,y+17,TEXT("H"),1); } + if (drawflags & DRAW_LEDS) { - RECT rDiskLed = {0,0,8,8}; - - DrawBitmapRect(dc,x+12,y+6,&rDiskLed,g_hDiskWindowedLED[eDrive1Status]); - DrawBitmapRect(dc,x+31,y+6,&rDiskLed,g_hDiskWindowedLED[eDrive2Status]); + DrawStatusAreaDisk( dc ); if (!IS_APPLE2) { @@ -662,6 +707,7 @@ static void DrawStatusArea (HDC passdc, int drawflags) #if HD_LED // 1.19.0.0 Hard Disk Status/Indicator Light + RECT rDiskLed = {0,0,8,8}; DrawBitmapRect(dc,x+12,y+18,&rDiskLed,g_hDiskWindowedLED[eHardDriveStatus]); #endif } @@ -672,6 +718,7 @@ static void DrawStatusArea (HDC passdc, int drawflags) GetAppleWindowTitle(); // SetWindowText() // WindowTitle SendMessage(g_hFrameWindow,WM_SETTEXT,0,(LPARAM)g_pAppTitle); } + if (drawflags & DRAW_BUTTON_DRIVES) { DrawButton(dc, BTN_DRIVE1); diff --git a/source/Frame.h b/source/Frame.h index 824ca907..8c882d56 100644 --- a/source/Frame.h +++ b/source/Frame.h @@ -48,6 +48,8 @@ bool GetFullScreen32Bit(void); void SetFullScreen32Bit(bool b32Bit); + void DrawStatusAreaDisk( HDC hdc ); + LRESULT CALLBACK FrameWndProc ( HWND window, UINT message, From e8fda39cae1a0ed7e11251ba3bb98a208a8d162e Mon Sep 17 00:00:00 2001 From: michaelangel007 Date: Mon, 21 Jul 2014 22:56:57 -0700 Subject: [PATCH 02/10] #201 Fix display of track status in full-screen and windowed mode ... http://imgur.com/KzKpwIv --- source/Disk.cpp | 3 ++- source/Frame.cpp | 70 +++++++++++++++++++++++++++--------------------- 2 files changed, 41 insertions(+), 32 deletions(-) diff --git a/source/Disk.cpp b/source/Disk.cpp index 56e31b2c..bf692fbf 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -787,7 +787,8 @@ static BYTE __stdcall DiskReadWrite (WORD programcounter, WORD, BYTE, BYTE, ULON if (!fptr->trackimagedata) return 0xFF; - // Bug # .. Show Track status + // Feature Request #201 Show track status + // https://github.com/AppleWin/AppleWin/issues/201 if( fptr->nLastTrack != fptr->track ) { fptr->nLastTrack = fptr->track; diff --git a/source/Frame.cpp b/source/Frame.cpp index 5e87c8b3..25a70354 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -550,7 +550,6 @@ void DrawStatusAreaDisk( HDC passdc ) { FrameReleaseDC(); HDC dc = (passdc ? passdc : GetDC(g_hFrameWindow)); -// HDC dc = g_hFrameDC; int x = buttonx; int y = buttony+BUTTONS*BUTTONCY+1; @@ -562,19 +561,29 @@ void DrawStatusAreaDisk( HDC passdc ) int Disk1Track = DiskGetTrack(0); int Disk2Track = DiskGetTrack(1); + SelectObject(dc,smallfont); + SetBkMode(dc,OPAQUE); + SetBkColor(dc,RGB(0,0,0)); + SetTextAlign(dc,TA_LEFT | TA_TOP); + + char buffer[16] = ""; + if (g_bIsFullScreen) { -/* - SelectObject(dc,smallfont); - SetBkMode(dc,OPAQUE); - SetBkColor(dc,RGB(0,0,0)); - SetTextAlign(dc,TA_LEFT | TA_TOP); -*/ +#if _DEBUG && 0 + SetBkColor(dc,RGB(255,0,255)); +#endif + // NB.The 2 extra spaces are needed since we don't erase the background to black + SetTextColor(dc, g_aDiskFullScreenColorsLED[ eDrive1Status ] ); - TextOut(dc,x+ 3,y+2,TEXT("1"),1); +// TextOut(dc,x+ 3,y+2,TEXT("1"),1); + sprintf_s( buffer, sizeof(buffer), "T%2d ", Disk1Track ); + TextOut(dc,x+3,y-12,buffer, strlen(buffer) ); // original: y+2; y-12 puts status in the Joystick Button Icon SetTextColor(dc, g_aDiskFullScreenColorsLED[ eDrive2Status ] ); - TextOut(dc,x+13,y+2,TEXT("2"),1); +// TextOut(dc,x+13,y+2,TEXT("2"),1); + sprintf_s( buffer, sizeof(buffer), "T%2d ", Disk2Track ); + TextOut(dc,x+23,y-12,buffer, strlen(buffer) ); // original: y+2; y-12 puts status in the Joystick Button Icon } else { @@ -583,23 +592,26 @@ void DrawStatusAreaDisk( HDC passdc ) DrawBitmapRect(dc,x+12,y+6,&rDiskLed,g_hDiskWindowedLED[eDrive1Status]); DrawBitmapRect(dc,x+31,y+6,&rDiskLed,g_hDiskWindowedLED[eDrive2Status]); - // Track/Sector - SelectObject(dc,smallfont); - SetTextAlign(dc,TA_CENTER | TA_TOP); + // Erase background + SelectObject(dc,GetStockObject(NULL_PEN)); +#if _DEBUG && 0 + SelectObject( dc, CreateSolidBrush( RGB(255,0,255) ) ); +#else + SelectObject(dc,btnfacebrush); +#endif + Rectangle(dc,x+4,y+32,x+BUTTONCX+1,y+44); // y+35 + SetTextColor(dc,RGB(0,0,0)); - SetBkMode(dc,TRANSPARENT); -// SetBkMode(dc,OPAQUE); + SetBkMode(dc,TRANSPARENT); - char buffer[16] = ""; - sprintf_s( buffer, sizeof(buffer), "%2d ", Disk1Track ); - TextOut(dc,x+16,y+5,buffer, strlen(buffer) ); // 1 + // Feature Request #201 Show track status + // https://github.com/AppleWin/AppleWin/issues/201 + sprintf_s( buffer, sizeof(buffer), "T%2d", Disk1Track ); + TextOut(dc,x+6,y+32,buffer, strlen(buffer) ); - sprintf_s( buffer, sizeof(buffer), "%2d ", Disk2Track ); - TextOut(dc,x+35,y+5,buffer, strlen(buffer) ); + sprintf_s( buffer, sizeof(buffer), "T%2d", Disk2Track ); + TextOut(dc,x+26,y+32,buffer, strlen(buffer) ); } - -// if (!passdc) -// ReleaseDC(g_hFrameWindow,dc); } //=========================================================================== @@ -620,12 +632,7 @@ static void DrawStatusArea (HDC passdc, int drawflags) if (g_bIsFullScreen) { - SelectObject(dc,smallfont); - SetBkMode(dc,OPAQUE); - SetBkColor(dc,RGB(0,0,0)); - SetTextAlign(dc,TA_LEFT | TA_TOP); - -// DrawStatusAreaDisk( passdc ); + DrawStatusAreaDisk( passdc ); #if HD_LED SetTextColor(dc, g_aDiskFullScreenColorsLED[ eHardDriveStatus ] ); @@ -657,7 +664,7 @@ static void DrawStatusArea (HDC passdc, int drawflags) // const int nCapsLen = sizeof(sCapsStatus) / sizeof(TCHAR); // TextOut(dc,x+BUTTONCX,y+2,"Caps",4); // sCapsStatus,nCapsLen - 1); - TextOut(dc,x+BUTTONCX,y+2,TEXT("A"),1); + TextOut(dc,x+BUTTONCX,y+2,TEXT("A"),1); // NB. Caps Lock indicator is already flush right! } SetTextAlign(dc,TA_CENTER | TA_TOP); SetTextColor(dc,(g_nAppMode == MODE_PAUSED || g_nAppMode == MODE_STEPPING @@ -673,8 +680,9 @@ static void DrawStatusArea (HDC passdc, int drawflags) { SelectObject(dc,GetStockObject(NULL_PEN)); SelectObject(dc,btnfacebrush); - Rectangle(dc,x,y,x+BUTTONCX+2,y+35); - Draw3dRect(dc,x+1,y+3,x+BUTTONCX,y+31,0); + Rectangle(dc,x,y,x+BUTTONCX+2,y+48); // y+35 + Draw3dRect(dc,x+1,y+3,x+BUTTONCX,y+44,0); // y+31 + SelectObject(dc,smallfont); SetTextAlign(dc,TA_CENTER | TA_TOP); SetTextColor(dc,RGB(0,0,0)); From d914526c273a3732a801d2390bb0f583ea0ad662 Mon Sep 17 00:00:00 2001 From: michaelangel007 Date: Mon, 21 Jul 2014 23:28:12 -0700 Subject: [PATCH 03/10] Updated "In Development" note about track display status --- bin/History.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/History.txt b/bin/History.txt index e12d4128..fbca8a84 100644 --- a/bin/History.txt +++ b/bin/History.txt @@ -31,6 +31,10 @@ Changes: (current memory address low byte) -memclear 7 Initialize memory to page address (current memory address high byte) +. [Feature #201] Added display of current track for the floppy drives. + Note: There are NO plans to display the sector number due to sectors being + a high level structure defined by the underlying OS -- it would take some + memory probing to display the accurate sector number. Fixed: . [Bug #206] Pooyan freezes due to RNDL/RNDH not initialized to non-zero values From f5be097177e4e5cc9d483b6febf932cbc0861c0a Mon Sep 17 00:00:00 2001 From: michaelangel007 Date: Tue, 22 Jul 2014 00:08:18 -0700 Subject: [PATCH 04/10] #201 Show Track/Sector -- preliminary support for showing DOS3.3 --- source/Frame.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/source/Frame.cpp b/source/Frame.cpp index 25a70354..dc7d7b98 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -599,7 +599,7 @@ void DrawStatusAreaDisk( HDC passdc ) #else SelectObject(dc,btnfacebrush); #endif - Rectangle(dc,x+4,y+32,x+BUTTONCX+1,y+44); // y+35 + Rectangle(dc,x+4,y+32,x+BUTTONCX+1,y+56); // y+35 -> 44 -> 56 SetTextColor(dc,RGB(0,0,0)); SetBkMode(dc,TRANSPARENT); @@ -611,6 +611,30 @@ void DrawStatusAreaDisk( HDC passdc ) sprintf_s( buffer, sizeof(buffer), "T%2d", Disk2Track ); TextOut(dc,x+26,y+32,buffer, strlen(buffer) ); + + // Try DOS3.3 Sector + static char sectord1[ 8 ] = ""; + static char sectord2[ 8 ] = ""; + + int DOS33drive = mem[ 0xB7EA ]; + int DOS33track = mem[ 0xB7EC ]; + int DOS33sector = mem[ 0xB7ED ]; + if (DOS33sector >= 0 && DOS33sector < 16 ) + { + if (DOS33track == Disk1Track && DOS33drive == 1) + sprintf_s( sectord1, sizeof(sectord1), "S%2d", DOS33sector ); + + if (DOS33track == Disk2Track && DOS33drive == 2) + sprintf_s( sectord2, sizeof(sectord2), "S%2d", DOS33sector ); + } + else + { + sprintf_s( sectord1, sizeof(sectord1), "S??" ); + sprintf_s( sectord2, sizeof(sectord2), "S??" ); + } + + TextOut(dc,x+ 6,y+42, sectord1, strlen(sectord1) ); + TextOut(dc,x+26,y+42, sectord2, strlen(sectord2) ); } } @@ -680,8 +704,8 @@ static void DrawStatusArea (HDC passdc, int drawflags) { SelectObject(dc,GetStockObject(NULL_PEN)); SelectObject(dc,btnfacebrush); - Rectangle(dc,x,y,x+BUTTONCX+2,y+48); // y+35 - Draw3dRect(dc,x+1,y+3,x+BUTTONCX,y+44,0); // y+31 + Rectangle(dc,x,y,x+BUTTONCX+2,y+60); // y+35 --> 48 --> 60 + Draw3dRect(dc,x+1,y+3,x+BUTTONCX,y+56,0); // y+31 --> 44 --> 56 SelectObject(dc,smallfont); SetTextAlign(dc,TA_CENTER | TA_TOP); From 6ad02871c1e5c35f9a84fa1ef003a3a726c608f9 Mon Sep 17 00:00:00 2001 From: michaelangel007 Date: Wed, 23 Jul 2014 18:08:52 -0700 Subject: [PATCH 05/10] #201 Fixed Track/Sector display to be responsive --- source/Disk.cpp | 43 ++++++---- source/Frame.cpp | 209 +++++++++++++++++++++++++++++++++++------------ source/Frame.h | 3 +- 3 files changed, 187 insertions(+), 68 deletions(-) diff --git a/source/Disk.cpp b/source/Disk.cpp index bf692fbf..377dd57b 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -64,7 +64,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA string strFilenameInZip; // 0x00 or HIMAGE imagehandle; // Init'd by DiskInsert() -> ImageOpen() int track; - int nLastTrack; LPBYTE trackimage; int phase; int byte; @@ -83,7 +82,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA strFilenameInZip = other.strFilenameInZip; imagehandle = other.imagehandle; track = other.track; - nLastTrack = other.nLastTrack; trackimage = other.trackimage; phase = other.phase; byte = other.byte; @@ -212,7 +210,8 @@ static void CheckSpinning(void) if (floppymotoron) g_aFloppyDisk[currdrive].spinning = 20000; if (modechange) - FrameRefreshStatus(DRAW_LEDS); + //FrameRefreshStatus(DRAW_LEDS); + FrameDrawDiskLEDS( (HDC)0 ); } //=========================================================================== @@ -464,6 +463,10 @@ static BYTE __stdcall DiskControlStepper(WORD, WORD address, BYTE, BYTE, ULONG) fptr->track = newtrack; fptr->trackimagedata = 0; } + + // Feature Request #201 Show track status + // https://github.com/AppleWin/AppleWin/issues/201 + FrameDrawDiskStatus( (HDC)0 ); } #else // Old 1.13.1 code for Chessmaster 2000 to work! (see bug#18109) const int nNumTracksInImage = ImageGetNumTracks(fptr->imagehandle); @@ -787,16 +790,6 @@ static BYTE __stdcall DiskReadWrite (WORD programcounter, WORD, BYTE, BYTE, ULON if (!fptr->trackimagedata) return 0xFF; - // Feature Request #201 Show track status - // https://github.com/AppleWin/AppleWin/issues/201 - if( fptr->nLastTrack != fptr->track ) - { - fptr->nLastTrack = fptr->track; - - //FrameRefreshStatus(DRAW_LEDS); - DrawStatusAreaDisk( (HDC)0 ); - } - BYTE result = 0; if (!floppywritemode || !fptr->bWriteProtected) @@ -825,6 +818,12 @@ static BYTE __stdcall DiskReadWrite (WORD programcounter, WORD, BYTE, BYTE, ULON if (++fptr->byte >= fptr->nibbles) fptr->byte = 0; + // Feature Request #201 Show track status + // https://github.com/AppleWin/AppleWin/issues/201 + // NB. Prevent flooding of forcing UI to redraw!!! + if( ((fptr->byte) & 0xFF) == 0 ) + FrameDrawDiskStatus( (HDC)0 ); + return result; } @@ -917,7 +916,10 @@ static BYTE __stdcall DiskSetWriteMode(WORD, WORD, BYTE, BYTE, ULONG) BOOL modechange = !g_aFloppyDisk[currdrive].writelight; g_aFloppyDisk[currdrive].writelight = 20000; if (modechange) - FrameRefreshStatus(DRAW_LEDS); + { + //FrameRefreshStatus(DRAW_LEDS); + FrameDrawDiskLEDS( (HDC)0 ); + } return MemReturnRandomData(1); } @@ -932,7 +934,11 @@ void DiskUpdatePosition(DWORD cycles) if (fptr->spinning && !floppymotoron) { if (!(fptr->spinning -= MIN(fptr->spinning, (cycles >> 6)))) - FrameRefreshStatus(DRAW_LEDS); + { + // FrameRefreshStatus(DRAW_LEDS); + FrameDrawDiskLEDS( (HDC)0 ); + FrameDrawDiskStatus( (HDC)0 ); + } } if (floppywritemode && (currdrive == loop) && fptr->spinning) @@ -942,7 +948,11 @@ void DiskUpdatePosition(DWORD cycles) else if (fptr->writelight) { if (!(fptr->writelight -= MIN(fptr->writelight, (cycles >> 6)))) - FrameRefreshStatus(DRAW_LEDS); + { + //FrameRefreshStatus(DRAW_LEDS); + FrameDrawDiskLEDS( (HDC)0 ); + FrameDrawDiskStatus( (HDC)0 ); + } } if ((!enhancedisk) && (!diskaccessed) && fptr->spinning) @@ -973,6 +983,7 @@ bool DiskDriveSwap(void) Disk_SaveLastDiskImage(DRIVE_2); FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); + FrameDrawDiskLEDS( (HDC)0 ); return true; } diff --git a/source/Frame.cpp b/source/Frame.cpp index dc7d7b98..7a0e2dd1 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -72,6 +72,16 @@ static int g_nMaxViewportScale = kDEFAULT_VIEWPORT_SCALE; static HBITMAP g_hDiskWindowedLED[ NUM_DISK_STATUS ]; //static HBITMAP g_hDiskFullScreenLED[ NUM_DISK_STATUS ]; +static int g_nTrackDrive1 = -1; +static int g_nTrackDrive2 = -1; +static int g_nSectorDrive1 = -1; +static int g_nSectorDrive2 = -1; +static TCHAR g_sTrackDrive1 [8] = TEXT("??"); +static TCHAR g_sTrackDrive2 [8] = TEXT("??"); +static TCHAR g_sSectorDrive1[8] = TEXT("??"); +static TCHAR g_sSectorDrive2[8] = TEXT("??"); +Disk_Status_e g_eStatusDrive1 = DISK_STATUS_OFF; +Disk_Status_e g_eStatusDrive2 = DISK_STATUS_OFF; // Must keep in sync with Disk_Status_e g_aDiskFullScreenColors static DWORD g_aDiskFullScreenColorsLED[ NUM_DISK_STATUS ] = @@ -546,51 +556,167 @@ static void DrawFrameWindow () } -void DrawStatusAreaDisk( HDC passdc ) +//=========================================================================== +void FrameDrawDiskLEDS( HDC passdc ) { + static Disk_Status_e eDrive1Status = DISK_STATUS_OFF; + static Disk_Status_e eDrive2Status = DISK_STATUS_OFF; + DiskGetLightStatus(&eDrive1Status, &eDrive2Status); + + g_eStatusDrive1 = eDrive1Status; + g_eStatusDrive2 = eDrive2Status; + + // Draw Track/Sector FrameReleaseDC(); HDC dc = (passdc ? passdc : GetDC(g_hFrameWindow)); int x = buttonx; int y = buttony+BUTTONS*BUTTONCY+1; - Disk_Status_e eDrive1Status = DISK_STATUS_OFF; - Disk_Status_e eDrive2Status = DISK_STATUS_OFF; + if (g_bIsFullScreen) + { + SelectObject(dc,smallfont); + SetBkMode(dc,OPAQUE); + SetBkColor(dc,RGB(0,0,0)); + SetTextAlign(dc,TA_LEFT | TA_TOP); + + SetTextColor(dc, g_aDiskFullScreenColorsLED[ eDrive1Status ] ); + TextOut(dc,x+ 3,y+2,TEXT("1"),1); + + SetTextColor(dc, g_aDiskFullScreenColorsLED[ eDrive2Status ] ); + TextOut(dc,x+13,y+2,TEXT("2"),1); + } + else + { + RECT rDiskLed = {0,0,8,8}; + DrawBitmapRect(dc,x+12,y+6,&rDiskLed,g_hDiskWindowedLED[eDrive1Status]); + DrawBitmapRect(dc,x+31,y+6,&rDiskLed,g_hDiskWindowedLED[eDrive2Status]); + } +} + +// Feature Request #201 Show track status +// https://github.com/AppleWin/AppleWin/issues/201 +//=========================================================================== +void FrameDrawDiskStatus( HDC passdc ) +{ + int nActiveFloppy = DiskGetCurrentDrive(); + + static Disk_Status_e eDrive1Status = DISK_STATUS_OFF; + static Disk_Status_e eDrive2Status = DISK_STATUS_OFF; DiskGetLightStatus(&eDrive1Status, &eDrive2Status); - int Disk1Track = DiskGetTrack(0); - int Disk2Track = DiskGetTrack(1); + static int nDisk1Track = DiskGetTrack(0); + static int nDisk2Track = DiskGetTrack(1); + + static int nDisk1Sector = 0; + static int nDisk2Sector = 0; + + // Probe known OS's for Track/Sector + int DOS33sector = mem[ 0xB7ED ]; + int isProDOS = mem[ 0xBF00 ] == 0x4C; + + // Try DOS3.3 Sector + if (DOS33sector >= 0 && DOS33sector < 16 ) + { + int DOS33drive = mem[ 0xB7EA ]; + int DOS33track = mem[ 0xB7EC ]; + if( DOS33drive == 1 ) + { + #if _DEBUG && 0 + if(DOS33track != nDisk1Track) // POHO + { + char text[128]; + sprintf( text, "\n\n\nWARNING: DOS33Track: %d (%02X) != nDisk1Track: %d (%02X)\n\n\n", DOS33track, DOS33track, nDisk1Track, nDisk1Track ); + OutputDebugString( text ); + } + #endif // _DEBUG + + sprintf_s( g_sTrackDrive1 , sizeof(g_sTrackDrive1), "%2d", g_nTrackDrive1 ); + sprintf_s( g_sSectorDrive1, sizeof(g_sSectorDrive1), "%2d", DOS33sector ); + nDisk1Track = g_nTrackDrive1 = DOS33track; + g_nSectorDrive1 = DOS33sector; + } + else +// if (DOS33track == nDisk2Track && DOS33drive == 2) + if( DOS33drive == 2 ) + { + sprintf_s( g_sTrackDrive2 , sizeof(g_sTrackDrive2 ), "%2d", g_nTrackDrive2 ); + sprintf_s( g_sSectorDrive2, sizeof(g_sSectorDrive2), "%2d", DOS33sector ); + nDisk2Track = g_nTrackDrive2 = DOS33track; + g_nSectorDrive2 = DOS33sector; + } + } + else + if( isProDOS ) + { + int ProDOSdrive = mem[ 0xBE3D ]; + int ProDOStrack = mem[ 0xD356 ]; + int ProDOSsector = mem[ 0xD357 ]; + if (ProDOSdrive == 1) sprintf_s( g_sSectorDrive1, sizeof(g_sSectorDrive1), "B??" ); + if (ProDOSdrive == 2) sprintf_s( g_sSectorDrive2, sizeof(g_sSectorDrive2), "B??" ); + } + else + { +// nDisk1Sector = -1; +// nDisk2Sector = -1; + if( nActiveFloppy == 0 ) { g_nTrackDrive1 = 0; nDisk1Sector = -1; sprintf_s( g_sSectorDrive1, sizeof(g_sSectorDrive1), "??" ); } + else { g_nTrackDrive2 = 0; nDisk2Sector = -1; sprintf_s( g_sSectorDrive2, sizeof(g_sSectorDrive2), "??" ); } + } + + // NB.The 2 extra spaces are needed since we don't erase the background to black +// sprintf_s( g_sTrackDrive1, sizeof(g_sTrackDrive1), "%2d", g_nTrackDrive1 ); +// sprintf_s( g_sTrackDrive2, sizeof(g_sTrackDrive2), "%2d", g_nTrackDrive2 ); + + g_nTrackDrive1 = nDisk1Track ; + g_nTrackDrive2 = nDisk2Track ; + g_nSectorDrive1 = nDisk1Sector ; + g_nSectorDrive2 = nDisk2Sector ; + + // Draw Track/Sector + FrameReleaseDC(); + HDC dc = (passdc ? passdc : GetDC(g_hFrameWindow)); + + int x = buttonx; + int y = buttony+BUTTONS*BUTTONCY+1; SelectObject(dc,smallfont); SetBkMode(dc,OPAQUE); SetBkColor(dc,RGB(0,0,0)); SetTextAlign(dc,TA_LEFT | TA_TOP); - char buffer[16] = ""; + char text[ 16 ]; if (g_bIsFullScreen) { #if _DEBUG && 0 SetBkColor(dc,RGB(255,0,255)); #endif - // NB.The 2 extra spaces are needed since we don't erase the background to black - SetTextColor(dc, g_aDiskFullScreenColorsLED[ eDrive1Status ] ); -// TextOut(dc,x+ 3,y+2,TEXT("1"),1); - sprintf_s( buffer, sizeof(buffer), "T%2d ", Disk1Track ); - TextOut(dc,x+3,y-12,buffer, strlen(buffer) ); // original: y+2; y-12 puts status in the Joystick Button Icon + TextOut(dc,x+ 3,y+2,TEXT("1"),1); SetTextColor(dc, g_aDiskFullScreenColorsLED[ eDrive2Status ] ); -// TextOut(dc,x+13,y+2,TEXT("2"),1); - sprintf_s( buffer, sizeof(buffer), "T%2d ", Disk2Track ); - TextOut(dc,x+23,y-12,buffer, strlen(buffer) ); // original: y+2; y-12 puts status in the Joystick Button Icon + TextOut(dc,x+13,y+2,TEXT("2"),1); + + int dx = 0; + if( nActiveFloppy == 0 ) + { + //dx = 3; + sprintf( text, "%s/%s ", g_sTrackDrive1, g_sSectorDrive1 ); + } + else + { + //dx = 23; + sprintf( text, "%s/%s ", g_sTrackDrive2, g_sSectorDrive2 ); + } + + SetTextColor(dc, g_aDiskFullScreenColorsLED[ DISK_STATUS_READ ] ); + TextOut(dc,x+dx,y-12,text, strlen(text) ); // original: y+2; y-12 puts status in the Configuration Button Icon } else { - RECT rDiskLed = {0,0,8,8}; - - DrawBitmapRect(dc,x+12,y+6,&rDiskLed,g_hDiskWindowedLED[eDrive1Status]); - DrawBitmapRect(dc,x+31,y+6,&rDiskLed,g_hDiskWindowedLED[eDrive2Status]); + // NB. Only draw Track/Sector if 2x windowed + if (g_nOldViewportScale == 1) + return; // Erase background SelectObject(dc,GetStockObject(NULL_PEN)); @@ -604,37 +730,18 @@ void DrawStatusAreaDisk( HDC passdc ) SetTextColor(dc,RGB(0,0,0)); SetBkMode(dc,TRANSPARENT); - // Feature Request #201 Show track status - // https://github.com/AppleWin/AppleWin/issues/201 - sprintf_s( buffer, sizeof(buffer), "T%2d", Disk1Track ); - TextOut(dc,x+6,y+32,buffer, strlen(buffer) ); - - sprintf_s( buffer, sizeof(buffer), "T%2d", Disk2Track ); - TextOut(dc,x+26,y+32,buffer, strlen(buffer) ); - - // Try DOS3.3 Sector - static char sectord1[ 8 ] = ""; - static char sectord2[ 8 ] = ""; - - int DOS33drive = mem[ 0xB7EA ]; - int DOS33track = mem[ 0xB7EC ]; - int DOS33sector = mem[ 0xB7ED ]; - if (DOS33sector >= 0 && DOS33sector < 16 ) - { - if (DOS33track == Disk1Track && DOS33drive == 1) - sprintf_s( sectord1, sizeof(sectord1), "S%2d", DOS33sector ); - - if (DOS33track == Disk2Track && DOS33drive == 2) - sprintf_s( sectord2, sizeof(sectord2), "S%2d", DOS33sector ); - } - else - { - sprintf_s( sectord1, sizeof(sectord1), "S??" ); - sprintf_s( sectord2, sizeof(sectord2), "S??" ); - } - - TextOut(dc,x+ 6,y+42, sectord1, strlen(sectord1) ); - TextOut(dc,x+26,y+42, sectord2, strlen(sectord2) ); +// if( nActiveFloppy == 0 ) + { + sprintf( text, "T%s", g_sTrackDrive1 ); + TextOut(dc,x+6 ,y+32,text, strlen(text) ); + sprintf( text, "S%s", g_sSectorDrive1 ); + TextOut(dc,x+ 6,y+42, text, strlen(text) ); +// } else { + sprintf( text, "T%s", g_sTrackDrive2 ); + TextOut(dc,x+26,y+32,text, strlen(text) ); + sprintf( text, "S%s", g_sSectorDrive2 ); + TextOut(dc,x+26,y+42, text, strlen(text) ); + } } } @@ -656,7 +763,7 @@ static void DrawStatusArea (HDC passdc, int drawflags) if (g_bIsFullScreen) { - DrawStatusAreaDisk( passdc ); + SelectObject(dc,smallfont); #if HD_LED SetTextColor(dc, g_aDiskFullScreenColorsLED[ eHardDriveStatus ] ); @@ -720,7 +827,7 @@ static void DrawStatusArea (HDC passdc, int drawflags) if (drawflags & DRAW_LEDS) { - DrawStatusAreaDisk( dc ); + FrameDrawDiskLEDS( dc ); if (!IS_APPLE2) { diff --git a/source/Frame.h b/source/Frame.h index 8c882d56..af22106a 100644 --- a/source/Frame.h +++ b/source/Frame.h @@ -48,7 +48,8 @@ bool GetFullScreen32Bit(void); void SetFullScreen32Bit(bool b32Bit); - void DrawStatusAreaDisk( HDC hdc ); + void FrameDrawDiskLEDS( HDC hdc ); + void FrameDrawDiskStatus( HDC hdc ); LRESULT CALLBACK FrameWndProc ( HWND window, From 099bdbe5eec747856b5b9071f1685ece9c7ceb15 Mon Sep 17 00:00:00 2001 From: michaelangel007 Date: Wed, 23 Jul 2014 22:40:35 -0700 Subject: [PATCH 06/10] Fix ProDOS track & sector display to be more accurate --- source/Frame.cpp | 75 ++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/source/Frame.cpp b/source/Frame.cpp index 7a0e2dd1..c3cb2c5a 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -612,38 +612,41 @@ void FrameDrawDiskStatus( HDC passdc ) static int nDisk2Sector = 0; // Probe known OS's for Track/Sector - int DOS33sector = mem[ 0xB7ED ]; int isProDOS = mem[ 0xBF00 ] == 0x4C; // Try DOS3.3 Sector - if (DOS33sector >= 0 && DOS33sector < 16 ) + if( !isProDOS ) { + int DOS33sector = mem[ 0xB7ED ]; int DOS33drive = mem[ 0xB7EA ]; int DOS33track = mem[ 0xB7EC ]; - if( DOS33drive == 1 ) - { - #if _DEBUG && 0 - if(DOS33track != nDisk1Track) // POHO - { - char text[128]; - sprintf( text, "\n\n\nWARNING: DOS33Track: %d (%02X) != nDisk1Track: %d (%02X)\n\n\n", DOS33track, DOS33track, nDisk1Track, nDisk1Track ); - OutputDebugString( text ); - } - #endif // _DEBUG - sprintf_s( g_sTrackDrive1 , sizeof(g_sTrackDrive1), "%2d", g_nTrackDrive1 ); - sprintf_s( g_sSectorDrive1, sizeof(g_sSectorDrive1), "%2d", DOS33sector ); - nDisk1Track = g_nTrackDrive1 = DOS33track; - g_nSectorDrive1 = DOS33sector; - } - else -// if (DOS33track == nDisk2Track && DOS33drive == 2) - if( DOS33drive == 2 ) + if (DOS33sector >= 0 && DOS33sector < 16 ) { - sprintf_s( g_sTrackDrive2 , sizeof(g_sTrackDrive2 ), "%2d", g_nTrackDrive2 ); - sprintf_s( g_sSectorDrive2, sizeof(g_sSectorDrive2), "%2d", DOS33sector ); - nDisk2Track = g_nTrackDrive2 = DOS33track; - g_nSectorDrive2 = DOS33sector; + if( DOS33drive == 1 ) + { + #if _DEBUG && 0 + if(DOS33track != nDisk1Track) + { + char text[128]; + sprintf( text, "\n\n\nWARNING: DOS33Track: %d (%02X) != nDisk1Track: %d (%02X)\n\n\n", DOS33track, DOS33track, nDisk1Track, nDisk1Track ); + OutputDebugString( text ); + } + #endif // _DEBUG + + sprintf_s( g_sTrackDrive1 , sizeof(g_sTrackDrive1), "%2d", g_nTrackDrive1 ); + sprintf_s( g_sSectorDrive1, sizeof(g_sSectorDrive1), "%2d", DOS33sector ); + nDisk1Track = g_nTrackDrive1 = DOS33track; + g_nSectorDrive1 = DOS33sector; + } + else + if( DOS33drive == 2 ) + { + sprintf_s( g_sTrackDrive2 , sizeof(g_sTrackDrive2 ), "%2d", g_nTrackDrive2 ); + sprintf_s( g_sSectorDrive2, sizeof(g_sSectorDrive2), "%2d", DOS33sector ); + nDisk2Track = g_nTrackDrive2 = DOS33track; + g_nSectorDrive2 = DOS33sector; + } } } else @@ -652,21 +655,23 @@ void FrameDrawDiskStatus( HDC passdc ) int ProDOSdrive = mem[ 0xBE3D ]; int ProDOStrack = mem[ 0xD356 ]; int ProDOSsector = mem[ 0xD357 ]; - if (ProDOSdrive == 1) sprintf_s( g_sSectorDrive1, sizeof(g_sSectorDrive1), "B??" ); - if (ProDOSdrive == 2) sprintf_s( g_sSectorDrive2, sizeof(g_sSectorDrive2), "B??" ); + if( ProDOSsector >= 0 && ProDOSsector <= 16) + { + if (ProDOSdrive == 1) sprintf_s( g_sSectorDrive1, sizeof(g_sSectorDrive1), "%d", ProDOSsector ); + if (ProDOSdrive == 2) sprintf_s( g_sSectorDrive2, sizeof(g_sSectorDrive2), "%d", ProDOSsector ); + } + else + { + if (ProDOSdrive == 1) sprintf_s( g_sSectorDrive1, sizeof(g_sSectorDrive1), "??" ); + if (ProDOSdrive == 2) sprintf_s( g_sSectorDrive2, sizeof(g_sSectorDrive2), "??" ); + } } else { -// nDisk1Sector = -1; -// nDisk2Sector = -1; if( nActiveFloppy == 0 ) { g_nTrackDrive1 = 0; nDisk1Sector = -1; sprintf_s( g_sSectorDrive1, sizeof(g_sSectorDrive1), "??" ); } else { g_nTrackDrive2 = 0; nDisk2Sector = -1; sprintf_s( g_sSectorDrive2, sizeof(g_sSectorDrive2), "??" ); } } - // NB.The 2 extra spaces are needed since we don't erase the background to black -// sprintf_s( g_sTrackDrive1, sizeof(g_sTrackDrive1), "%2d", g_nTrackDrive1 ); -// sprintf_s( g_sTrackDrive2, sizeof(g_sTrackDrive2), "%2d", g_nTrackDrive2 ); - g_nTrackDrive1 = nDisk1Track ; g_nTrackDrive2 = nDisk2Track ; g_nSectorDrive1 = nDisk1Sector ; @@ -699,15 +704,9 @@ void FrameDrawDiskStatus( HDC passdc ) int dx = 0; if( nActiveFloppy == 0 ) - { - //dx = 3; sprintf( text, "%s/%s ", g_sTrackDrive1, g_sSectorDrive1 ); - } else - { - //dx = 23; sprintf( text, "%s/%s ", g_sTrackDrive2, g_sSectorDrive2 ); - } SetTextColor(dc, g_aDiskFullScreenColorsLED[ DISK_STATUS_READ ] ); TextOut(dc,x+dx,y-12,text, strlen(text) ); // original: y+2; y-12 puts status in the Configuration Button Icon From 825aba0fdae7cececa19436fe5136b716563cac6 Mon Sep 17 00:00:00 2001 From: michaelangel007 Date: Wed, 23 Jul 2014 22:58:23 -0700 Subject: [PATCH 07/10] Use active track for ProDOS --- source/Frame.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/Frame.cpp b/source/Frame.cpp index c3cb2c5a..1a0bea6c 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -617,7 +617,7 @@ void FrameDrawDiskStatus( HDC passdc ) // Try DOS3.3 Sector if( !isProDOS ) { - int DOS33sector = mem[ 0xB7ED ]; + int DOS33sector = mem[ 0xB7ED ]; int DOS33drive = mem[ 0xB7EA ]; int DOS33track = mem[ 0xB7EC ]; @@ -657,8 +657,8 @@ void FrameDrawDiskStatus( HDC passdc ) int ProDOSsector = mem[ 0xD357 ]; if( ProDOSsector >= 0 && ProDOSsector <= 16) { - if (ProDOSdrive == 1) sprintf_s( g_sSectorDrive1, sizeof(g_sSectorDrive1), "%d", ProDOSsector ); - if (ProDOSdrive == 2) sprintf_s( g_sSectorDrive2, sizeof(g_sSectorDrive2), "%d", ProDOSsector ); + if (ProDOSdrive == 1) { g_nTrackDrive1 = ProDOStrack; sprintf_s( g_sTrackDrive1 , sizeof(g_sTrackDrive1), "%2d", g_nTrackDrive1 ); sprintf_s( g_sSectorDrive1, sizeof(g_sSectorDrive1), "%d", ProDOSsector ); } + if (ProDOSdrive == 2) { g_nTrackDrive2 = ProDOStrack; sprintf_s( g_sTrackDrive2 , sizeof(g_sTrackDrive1), "%2d", g_nTrackDrive1 ); sprintf_s( g_sSectorDrive2, sizeof(g_sSectorDrive2), "%d", ProDOSsector ); } } else { @@ -668,8 +668,8 @@ void FrameDrawDiskStatus( HDC passdc ) } else { - if( nActiveFloppy == 0 ) { g_nTrackDrive1 = 0; nDisk1Sector = -1; sprintf_s( g_sSectorDrive1, sizeof(g_sSectorDrive1), "??" ); } - else { g_nTrackDrive2 = 0; nDisk2Sector = -1; sprintf_s( g_sSectorDrive2, sizeof(g_sSectorDrive2), "??" ); } + if( nActiveFloppy == 0 ) { g_nTrackDrive1 = nDisk1Track; nDisk1Sector = -1; sprintf_s( g_sSectorDrive1, sizeof(g_sSectorDrive1), "??" ); } + else { g_nTrackDrive2 = nDisk2Track; nDisk2Sector = -1; sprintf_s( g_sSectorDrive2, sizeof(g_sSectorDrive2), "??" ); } } g_nTrackDrive1 = nDisk1Track ; From f5617a396d756acde30567ce4c3f7581ea97c8c5 Mon Sep 17 00:00:00 2001 From: michaelangel007 Date: Thu, 24 Jul 2014 21:58:19 -0700 Subject: [PATCH 08/10] Final cleanup on Track/Sector --- source/Frame.cpp | 114 ++++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 61 deletions(-) diff --git a/source/Frame.cpp b/source/Frame.cpp index 1a0bea6c..164088bd 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -72,14 +72,14 @@ static int g_nMaxViewportScale = kDEFAULT_VIEWPORT_SCALE; static HBITMAP g_hDiskWindowedLED[ NUM_DISK_STATUS ]; //static HBITMAP g_hDiskFullScreenLED[ NUM_DISK_STATUS ]; -static int g_nTrackDrive1 = -1; -static int g_nTrackDrive2 = -1; -static int g_nSectorDrive1 = -1; -static int g_nSectorDrive2 = -1; -static TCHAR g_sTrackDrive1 [8] = TEXT("??"); -static TCHAR g_sTrackDrive2 [8] = TEXT("??"); -static TCHAR g_sSectorDrive1[8] = TEXT("??"); -static TCHAR g_sSectorDrive2[8] = TEXT("??"); +static int g_nTrackDrive1 = -1; +static int g_nTrackDrive2 = -1; +static int g_nSectorDrive1 = -1; +static int g_nSectorDrive2 = -1; +static TCHAR g_sTrackDrive1 [8] = TEXT("??"); +static TCHAR g_sTrackDrive2 [8] = TEXT("??"); +static TCHAR g_sSectorDrive1[8] = TEXT("??"); +static TCHAR g_sSectorDrive2[8] = TEXT("??"); Disk_Status_e g_eStatusDrive1 = DISK_STATUS_OFF; Disk_Status_e g_eStatusDrive2 = DISK_STATUS_OFF; @@ -601,53 +601,38 @@ void FrameDrawDiskStatus( HDC passdc ) { int nActiveFloppy = DiskGetCurrentDrive(); - static Disk_Status_e eDrive1Status = DISK_STATUS_OFF; - static Disk_Status_e eDrive2Status = DISK_STATUS_OFF; - DiskGetLightStatus(&eDrive1Status, &eDrive2Status); - - static int nDisk1Track = DiskGetTrack(0); - static int nDisk2Track = DiskGetTrack(1); + int nDisk1Track = DiskGetTrack(0); + int nDisk2Track = DiskGetTrack(1); - static int nDisk1Sector = 0; - static int nDisk2Sector = 0; - // Probe known OS's for Track/Sector - int isProDOS = mem[ 0xBF00 ] == 0x4C; + int isProDOS = mem[ 0xBF00 ] == 0x4C; + bool isValid = true; // Try DOS3.3 Sector if( !isProDOS ) { - int DOS33sector = mem[ 0xB7ED ]; int DOS33drive = mem[ 0xB7EA ]; + int DOS33sector = mem[ 0xB7ED ]; int DOS33track = mem[ 0xB7EC ]; - if (DOS33sector >= 0 && DOS33sector < 16 ) + if ((DOS33drive >= 0 && DOS33drive < 2) + && (DOS33track >= 0 && DOS33track < 40) + && (DOS33sector >= 0 && DOS33sector < 16)) { - if( DOS33drive == 1 ) - { - #if _DEBUG && 0 - if(DOS33track != nDisk1Track) - { - char text[128]; - sprintf( text, "\n\n\nWARNING: DOS33Track: %d (%02X) != nDisk1Track: %d (%02X)\n\n\n", DOS33track, DOS33track, nDisk1Track, nDisk1Track ); - OutputDebugString( text ); - } - #endif // _DEBUG + #if _DEBUG && 0 + if(DOS33track != nDisk1Track) + { + char text[128]; + sprintf( text, "\n\n\nWARNING: DOS33Track: %d (%02X) != nDisk1Track: %d (%02X)\n\n\n", DOS33track, DOS33track, nDisk1Track, nDisk1Track ); + OutputDebugString( text ); + } + #endif // _DEBUG - sprintf_s( g_sTrackDrive1 , sizeof(g_sTrackDrive1), "%2d", g_nTrackDrive1 ); - sprintf_s( g_sSectorDrive1, sizeof(g_sSectorDrive1), "%2d", DOS33sector ); - nDisk1Track = g_nTrackDrive1 = DOS33track; - g_nSectorDrive1 = DOS33sector; - } - else - if( DOS33drive == 2 ) - { - sprintf_s( g_sTrackDrive2 , sizeof(g_sTrackDrive2 ), "%2d", g_nTrackDrive2 ); - sprintf_s( g_sSectorDrive2, sizeof(g_sSectorDrive2), "%2d", DOS33sector ); - nDisk2Track = g_nTrackDrive2 = DOS33track; - g_nSectorDrive2 = DOS33sector; - } + /**/ if( DOS33drive == 1 ) g_nSectorDrive1 = DOS33sector; + else if( DOS33drive == 2 ) g_nSectorDrive2 = DOS33sector; } + else + isValid = false; } else if( isProDOS ) @@ -655,27 +640,34 @@ void FrameDrawDiskStatus( HDC passdc ) int ProDOSdrive = mem[ 0xBE3D ]; int ProDOStrack = mem[ 0xD356 ]; int ProDOSsector = mem[ 0xD357 ]; - if( ProDOSsector >= 0 && ProDOSsector <= 16) + + if ((ProDOSdrive >= 0 && ProDOSdrive < 2) + && (ProDOStrack >= 0 && ProDOStrack < 40) + && (ProDOSsector >= 0 && ProDOSsector < 16)) { - if (ProDOSdrive == 1) { g_nTrackDrive1 = ProDOStrack; sprintf_s( g_sTrackDrive1 , sizeof(g_sTrackDrive1), "%2d", g_nTrackDrive1 ); sprintf_s( g_sSectorDrive1, sizeof(g_sSectorDrive1), "%d", ProDOSsector ); } - if (ProDOSdrive == 2) { g_nTrackDrive2 = ProDOStrack; sprintf_s( g_sTrackDrive2 , sizeof(g_sTrackDrive1), "%2d", g_nTrackDrive1 ); sprintf_s( g_sSectorDrive2, sizeof(g_sSectorDrive2), "%d", ProDOSsector ); } + /**/ if (ProDOSdrive == 1) g_nSectorDrive1 = ProDOSsector; + else if (ProDOSdrive == 2) g_nSectorDrive2 = ProDOSsector; } else - { - if (ProDOSdrive == 1) sprintf_s( g_sSectorDrive1, sizeof(g_sSectorDrive1), "??" ); - if (ProDOSdrive == 2) sprintf_s( g_sSectorDrive2, sizeof(g_sSectorDrive2), "??" ); - } - } - else - { - if( nActiveFloppy == 0 ) { g_nTrackDrive1 = nDisk1Track; nDisk1Sector = -1; sprintf_s( g_sSectorDrive1, sizeof(g_sSectorDrive1), "??" ); } - else { g_nTrackDrive2 = nDisk2Track; nDisk2Sector = -1; sprintf_s( g_sSectorDrive2, sizeof(g_sSectorDrive2), "??" ); } + isValid = false; } - g_nTrackDrive1 = nDisk1Track ; - g_nTrackDrive2 = nDisk2Track ; - g_nSectorDrive1 = nDisk1Sector ; - g_nSectorDrive2 = nDisk2Sector ; + g_nTrackDrive1 = nDisk1Track; + g_nTrackDrive2 = nDisk2Track; + + if( !isValid ) + { + if (nActiveFloppy == 0) g_nSectorDrive1 = -1; + else g_nSectorDrive2 = -1; + } + + sprintf_s( g_sTrackDrive1 , sizeof(g_sTrackDrive1 ), "%2d", g_nTrackDrive1 ); + if (g_nSectorDrive1 < 0) sprintf_s( g_sSectorDrive1, sizeof(g_sSectorDrive1), "??" , g_nSectorDrive1 ); + else sprintf_s( g_sSectorDrive1, sizeof(g_sSectorDrive1), "%2d", g_nSectorDrive1 ); + + sprintf_s( g_sTrackDrive2 , sizeof(g_sTrackDrive2), "%2d", g_nTrackDrive2 ); + if (g_nSectorDrive2 < 0) sprintf_s( g_sSectorDrive2, sizeof(g_sSectorDrive2), "??" , g_nSectorDrive2 ); + else sprintf_s( g_sSectorDrive2, sizeof(g_sSectorDrive2), "%2d", g_nSectorDrive2 ); // Draw Track/Sector FrameReleaseDC(); @@ -696,10 +688,10 @@ void FrameDrawDiskStatus( HDC passdc ) #if _DEBUG && 0 SetBkColor(dc,RGB(255,0,255)); #endif - SetTextColor(dc, g_aDiskFullScreenColorsLED[ eDrive1Status ] ); + SetTextColor(dc, g_aDiskFullScreenColorsLED[ g_eStatusDrive1 ] ); TextOut(dc,x+ 3,y+2,TEXT("1"),1); - SetTextColor(dc, g_aDiskFullScreenColorsLED[ eDrive2Status ] ); + SetTextColor(dc, g_aDiskFullScreenColorsLED[ g_eStatusDrive2 ] ); TextOut(dc,x+13,y+2,TEXT("2"),1); int dx = 0; From f0ca2282ed6d6b434cef3d6a972aa1ec2ef60b88 Mon Sep 17 00:00:00 2001 From: michaelangel007 Date: Thu, 24 Jul 2014 22:10:08 -0700 Subject: [PATCH 09/10] #201 Updated history "In Development" for Track/Sector and Pooyan fix description --- bin/History.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/History.txt b/bin/History.txt index fbca8a84..59e460ee 100644 --- a/bin/History.txt +++ b/bin/History.txt @@ -31,12 +31,15 @@ Changes: (current memory address low byte) -memclear 7 Initialize memory to page address (current memory address high byte) -. [Feature #201] Added display of current track for the floppy drives. - Note: There are NO plans to display the sector number due to sectors being - a high level structure defined by the underlying OS -- it would take some - memory probing to display the accurate sector number. -Fixed: -. [Bug #206] Pooyan freezes due to RNDL/RNDH not initialized to non-zero values +. [Feature #201] Added display of current Track/Sector for the floppy drives. + - In 2x window mode the status is displayed below the drive LEDs. + - In full screen mode the status is displayed above the drive LEDS. The track/sector + is shown only for the last drive accessed. + Note: DOS3.3 Track/Sector status should be accurate. + ProDOS support is preliminary -- the track/sector may show zero after an operation. +Fixes: +. [Bug #206] Pooyan would freeze due to RNDL/RNDH not initialized to non-zero values on + a cold boot. Latest: From 9cb6626fc32a104dfbe56359f65499b62f6d8f04 Mon Sep 17 00:00:00 2001 From: michaelangel007 Date: Sat, 26 Jul 2014 09:36:29 -0700 Subject: [PATCH 10/10] #201 Fix ProDOS track/sector to be more accurate. Always use the actual floppy drive instead of probing ProDOS --- source/Frame.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/Frame.cpp b/source/Frame.cpp index 164088bd..4e320205 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -635,11 +635,15 @@ void FrameDrawDiskStatus( HDC passdc ) isValid = false; } else - if( isProDOS ) + if( isProDOS ) // & regs.pc > 0xD000 ) // RWTS @ $D300 { - int ProDOSdrive = mem[ 0xBE3D ]; - int ProDOStrack = mem[ 0xD356 ]; - int ProDOSsector = mem[ 0xD357 ]; + // we can't just read from mem[ 0xD357 ] since it might be bank-switched from ROM + // and we need the Language Card RAM + // memrom[ 0xD350 ] = " ERROR\x07\x00" + // T S + int ProDOSdrive = nActiveFloppy + 1; // mem[ 0xBE3D ]; + int ProDOStrack = *MemGetMainPtr( 0xC356 ); // LC1 $D356 + int ProDOSsector = *MemGetMainPtr( 0xC357 ); // LC1 $D357 if ((ProDOSdrive >= 0 && ProDOSdrive < 2) && (ProDOStrack >= 0 && ProDOStrack < 40)