DiskIIInterfaceCard add in private variables

This commit is contained in:
tomcw 2019-04-07 15:32:24 +01:00
parent e7d6eac04d
commit bbe0e67584
4 changed files with 114 additions and 101 deletions

View File

@ -35,8 +35,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Applewin.h" #include "Applewin.h"
#include "CPU.h" #include "CPU.h"
#include "Disk.h" #include "Disk.h"
#include "DiskLog.h"
#include "DiskFormatTrack.h"
#include "DiskImage.h" #include "DiskImage.h"
#include "Frame.h" #include "Frame.h"
#include "Log.h" #include "Log.h"
@ -47,57 +45,29 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../resource/resource.h" #include "../resource/resource.h"
#if LOG_DISK_NIBBLES_USE_RUNTIME_VAR DiskIIInterfaceCard::DiskIIInterfaceCard(void)
static bool g_bLogDisk_NibblesRW = false; // From VS Debugger, change this to true/false during runtime for precise nibble logging
#endif
// Private ________________________________________________________________________________________
struct Drive_t
{ {
int phase; currdrive = 0;
int track; floppylatch = 0;
DWORD spinning; floppymotoron = 0;
DWORD writelight; floppyloadmode = 0;
Disk_t disk; floppywritemode = 0;
phases = 0;
g_bSaveDiskImage = true; // Save the DiskImage name to Registry
g_uSlot = 0;
g_uDiskLastCycle = 0;
g_uDiskLastReadLatchCycle = 0;
enhancedisk = true;
Drive_t() // Debug:
{ #if LOG_DISK_NIBBLES_USE_RUNTIME_VAR
clear(); g_bLogDisk_NibblesRW = false;
} #endif
#if LOG_DISK_NIBBLES_WRITE
void clear() g_uWriteLastCycle = 0;
{ g_uSyncFFCount = 0;
phase = 0; #endif
track = 0; }
spinning = 0;
writelight = 0;
disk.clear();
}
};
static WORD currdrive = 0;
static Drive_t g_aFloppyDrive[NUM_DRIVES];
static BYTE floppylatch = 0;
static BOOL floppymotoron = 0;
static BOOL floppyloadmode = 0; // for efficiency this is not used; it's extremely unlikely to affect emulation (nickw)
static BOOL floppywritemode = 0;
static WORD phases = 0; // state bits for stepper magnet phases 0 - 3
static bool g_bSaveDiskImage = true; // Save the DiskImage name to Registry
static UINT g_uSlot = 0;
static unsigned __int64 g_uDiskLastCycle = 0;
static unsigned __int64 g_uDiskLastReadLatchCycle = 0;
static FormatTrack g_formatTrack;
static bool IsDriveValid( const int iDrive );
static LPCTSTR DiskGetFullPathName(const int iDrive);
#define SPINNING_CYCLES (20000*64) // 1280000 cycles = 1.25s
#define WRITELIGHT_CYCLES (20000*64) // 1280000 cycles = 1.25s
static bool enhancedisk = true;
//===========================================================================
bool DiskIIInterfaceCard::Disk_GetEnhanceDisk(void) { return enhancedisk; } bool DiskIIInterfaceCard::Disk_GetEnhanceDisk(void) { return enhancedisk; }
void DiskIIInterfaceCard::Disk_SetEnhanceDisk(bool bEnhanceDisk) { enhancedisk = bEnhanceDisk; } void DiskIIInterfaceCard::Disk_SetEnhanceDisk(bool bEnhanceDisk) { enhancedisk = bEnhanceDisk; }
@ -766,7 +736,6 @@ void DiskIIInterfaceCard::DiskNotifyInvalidImage(const int iDrive, LPCTSTR pszIm
MB_ICONEXCLAMATION | MB_SETFOREGROUND); MB_ICONEXCLAMATION | MB_SETFOREGROUND);
} }
//=========================================================================== //===========================================================================
bool DiskIIInterfaceCard::DiskGetProtect(const int iDrive) bool DiskIIInterfaceCard::DiskGetProtect(const int iDrive)
@ -780,7 +749,6 @@ bool DiskIIInterfaceCard::DiskGetProtect(const int iDrive)
return false; return false;
} }
//=========================================================================== //===========================================================================
void DiskIIInterfaceCard::DiskSetProtect(const int iDrive, const bool bWriteProtect) void DiskIIInterfaceCard::DiskSetProtect(const int iDrive, const bool bWriteProtect)
@ -791,7 +759,6 @@ void DiskIIInterfaceCard::DiskSetProtect(const int iDrive, const bool bWriteProt
} }
} }
//=========================================================================== //===========================================================================
bool DiskIIInterfaceCard::Disk_ImageIsWriteProtected(const int iDrive) bool DiskIIInterfaceCard::Disk_ImageIsWriteProtected(const int iDrive)
@ -815,9 +782,6 @@ bool DiskIIInterfaceCard::Disk_IsDriveEmpty(const int iDrive)
//=========================================================================== //===========================================================================
#if LOG_DISK_NIBBLES_WRITE #if LOG_DISK_NIBBLES_WRITE
static UINT64 g_uWriteLastCycle = 0;
static UINT g_uSyncFFCount = 0;
bool DiskIIInterfaceCard::LogWriteCheckSyncFF(ULONG& uCycleDelta) bool DiskIIInterfaceCard::LogWriteCheckSyncFF(ULONG& uCycleDelta)
{ {
bool bIsSyncFF = false; bool bIsSyncFF = false;
@ -1261,7 +1225,7 @@ BYTE __stdcall DiskIIInterfaceCard::Disk_IORead(WORD pc, WORD addr, BYTE bWrite,
// only even addresses return the latch (UTAIIe Table 9.1) // only even addresses return the latch (UTAIIe Table 9.1)
if (!(addr & 1)) if (!(addr & 1))
return floppylatch; return pCard->floppylatch;
else else
return MemReadFloatingBus(nExecutedCycles); return MemReadFloatingBus(nExecutedCycles);
} }
@ -1292,9 +1256,9 @@ BYTE __stdcall DiskIIInterfaceCard::Disk_IOWrite(WORD pc, WORD addr, BYTE bWrite
} }
// any address writes the latch via sequencer LD command (74LS323 datasheet) // any address writes the latch via sequencer LD command (74LS323 datasheet)
if (floppywritemode /* && floppyloadmode */) if (pCard->floppywritemode /* && floppyloadmode */)
{ {
floppylatch = d; pCard->floppylatch = d;
} }
return 0; return 0;
} }

View File

@ -23,6 +23,8 @@ along with AppleWin; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "DiskLog.h"
#include "DiskFormatTrack.h"
#include "DiskImage.h" #include "DiskImage.h"
extern class DiskIIInterfaceCard sg_DiskIICard; extern class DiskIIInterfaceCard sg_DiskIICard;
@ -41,10 +43,68 @@ const bool IMAGE_FORCE_WRITE_PROTECTED = true;
const bool IMAGE_DONT_CREATE = false; const bool IMAGE_DONT_CREATE = false;
const bool IMAGE_CREATE = true; const bool IMAGE_CREATE = true;
struct Disk_t
{
TCHAR imagename[ MAX_DISK_IMAGE_NAME + 1 ]; // <FILENAME> (ie. no extension)
TCHAR fullname [ MAX_DISK_FULL_NAME + 1 ]; // <FILENAME.EXT> or <FILENAME.zip> : This is persisted to the snapshot file
std::string strFilenameInZip; // "" or <FILENAME.EXT>
ImageInfo* imagehandle; // Init'd by DiskInsert() -> ImageOpen()
bool bWriteProtected;
//
int byte;
int nibbles; // Init'd by ReadTrack() -> ImageReadTrack()
LPBYTE trackimage;
bool trackimagedata;
bool trackimagedirty;
Disk_t()
{
clear();
}
void clear()
{
ZeroMemory(imagename, sizeof(imagename));
ZeroMemory(fullname, sizeof(fullname));
strFilenameInZip.clear();
imagehandle = NULL;
bWriteProtected = false;
//
byte = 0;
nibbles = 0;
trackimage = NULL;
trackimagedata = false;
trackimagedirty = false;
}
};
struct Drive_t
{
int phase;
int track;
DWORD spinning;
DWORD writelight;
Disk_t disk;
Drive_t()
{
clear();
}
void clear()
{
phase = 0;
track = 0;
spinning = 0;
writelight = 0;
disk.clear();
}
};
class DiskIIInterfaceCard class DiskIIInterfaceCard
{ {
public: public:
DiskIIInterfaceCard(void){}; DiskIIInterfaceCard(void);
virtual ~DiskIIInterfaceCard(void){}; virtual ~DiskIIInterfaceCard(void){};
const char* DiskGetDiskPathFilename(const int iDrive); const char* DiskGetDiskPathFilename(const int iDrive);
@ -117,44 +177,35 @@ private:
void __stdcall DiskIIInterfaceCard::DiskSetReadMode(WORD, WORD, BYTE, BYTE, ULONG); void __stdcall DiskIIInterfaceCard::DiskSetReadMode(WORD, WORD, BYTE, BYTE, ULONG);
void __stdcall DiskIIInterfaceCard::DiskSetWriteMode(WORD, WORD, BYTE, BYTE, ULONG uExecutedCycles); void __stdcall DiskIIInterfaceCard::DiskSetWriteMode(WORD, WORD, BYTE, BYTE, ULONG uExecutedCycles);
//#if LOG_DISK_NIBBLES_WRITE #if LOG_DISK_NIBBLES_WRITE
bool DiskIIInterfaceCard::LogWriteCheckSyncFF(ULONG& uCycleDelta); bool DiskIIInterfaceCard::LogWriteCheckSyncFF(ULONG& uCycleDelta);
}; #endif
//
// For sharing with class FormatTrack
struct Disk_t
{
TCHAR imagename[ MAX_DISK_IMAGE_NAME + 1 ]; // <FILENAME> (ie. no extension)
TCHAR fullname [ MAX_DISK_FULL_NAME + 1 ]; // <FILENAME.EXT> or <FILENAME.zip> : This is persisted to the snapshot file
std::string strFilenameInZip; // "" or <FILENAME.EXT>
ImageInfo* imagehandle; // Init'd by DiskInsert() -> ImageOpen()
bool bWriteProtected;
// //
int byte;
int nibbles; // Init'd by ReadTrack() -> ImageReadTrack()
LPBYTE trackimage;
bool trackimagedata;
bool trackimagedirty;
Disk_t() WORD currdrive;
{ Drive_t g_aFloppyDrive[NUM_DRIVES];
clear(); BYTE floppylatch;
} BOOL floppymotoron;
BOOL floppyloadmode; // for efficiency this is not used; it's extremely unlikely to affect emulation (nickw)
BOOL floppywritemode;
WORD phases; // state bits for stepper magnet phases 0 - 3
bool g_bSaveDiskImage;
UINT g_uSlot;
unsigned __int64 g_uDiskLastCycle;
unsigned __int64 g_uDiskLastReadLatchCycle;
FormatTrack g_formatTrack;
bool enhancedisk;
void clear() static const UINT SPINNING_CYCLES = 20000*64; // 1280000 cycles = 1.25s
{ static const UINT WRITELIGHT_CYCLES = 20000*64; // 1280000 cycles = 1.25s
ZeroMemory(imagename, sizeof(imagename));
ZeroMemory(fullname, sizeof(fullname)); // Debug:
strFilenameInZip.clear(); #if LOG_DISK_NIBBLES_USE_RUNTIME_VAR
imagehandle = NULL; bool g_bLogDisk_NibblesRW; // From VS Debugger, change this to true/false during runtime for precise nibble logging
bWriteProtected = false; #endif
// #if LOG_DISK_NIBBLES_WRITE
byte = 0; UINT64 g_uWriteLastCycle;
nibbles = 0; UINT g_uSyncFFCount;
trackimage = NULL; #endif
trackimagedata = false;
trackimagedirty = false;
}
}; };

View File

@ -45,8 +45,6 @@ Writes the following: (in 1 continuous write operation)
#include "StdAfx.h" #include "StdAfx.h"
#include "Disk.h" #include "Disk.h"
#include "DiskLog.h"
#include "DiskFormatTrack.h"
#include "Log.h" #include "Log.h"
#include "YamlHelper.h" #include "YamlHelper.h"

View File

@ -35,15 +35,15 @@ public:
void Reset(void); void Reset(void);
void DriveNotWritingTrack(void); void DriveNotWritingTrack(void);
void DriveSwitchedToReadMode(Disk_t* const pFloppy); void DriveSwitchedToReadMode(struct Disk_t* const pFloppy);
void DriveSwitchedToWriteMode(UINT uTrackIndex); void DriveSwitchedToWriteMode(UINT uTrackIndex);
void DecodeLatchNibbleRead(BYTE floppylatch); void DecodeLatchNibbleRead(BYTE floppylatch);
void DecodeLatchNibbleWrite(BYTE floppylatch, UINT uSpinNibbleCount, const Disk_t* const pFloppy, bool bIsSyncFF); void DecodeLatchNibbleWrite(BYTE floppylatch, UINT uSpinNibbleCount, const struct Disk_t* const pFloppy, bool bIsSyncFF);
void SaveSnapshot(class YamlSaveHelper& yamlSaveHelper); void SaveSnapshot(class YamlSaveHelper& yamlSaveHelper);
void LoadSnapshot(class YamlLoadHelper& yamlLoadHelper); void LoadSnapshot(class YamlLoadHelper& yamlLoadHelper);
private: private:
void UpdateOnWriteLatch(UINT uSpinNibbleCount, const Disk_t* const pFloppy); void UpdateOnWriteLatch(UINT uSpinNibbleCount, const struct Disk_t* const pFloppy);
void DecodeLatchNibble(BYTE floppylatch, bool bIsWrite, bool bIsSyncFF); void DecodeLatchNibble(BYTE floppylatch, bool bIsWrite, bool bIsSyncFF);
BYTE m_VolTrkSecChk[4]; BYTE m_VolTrkSecChk[4];