This commit is contained in:
michaelangel007 2019-04-18 15:58:19 -07:00
commit a0f7fe46bf
19 changed files with 678 additions and 651 deletions

View File

@ -105,6 +105,7 @@ int g_nMemoryClearType = MIP_FF_FF_00_00; // Note: -1 = random MIP in Memory.c
IPropertySheet& sg_PropertySheet = * new CPropertySheet;
CSuperSerialCard sg_SSC;
CMouseInterface sg_Mouse;
Disk2InterfaceCard sg_Disk2Card;
SS_CARDTYPE g_Slot0 = CT_LanguageCard; // Just for Apple II or II+ or similar clones
SS_CARDTYPE g_Slot4 = CT_Empty;
@ -269,7 +270,7 @@ static void ContinueExecution(void)
const bool bWasFullSpeed = g_bFullSpeed;
g_bFullSpeed = (g_dwSpeed == SPEED_MAX) ||
bScrollLock_FullSpeed ||
(Disk_IsConditionForFullSpeed() && !Spkr_IsActive() && !MB_IsActive()) ||
(sg_Disk2Card.IsConditionForFullSpeed() && !Spkr_IsActive() && !MB_IsActive()) ||
IsDebugSteppingAtFullSpeed();
if (g_bFullSpeed)
@ -316,7 +317,7 @@ static void ContinueExecution(void)
const DWORD uActualCyclesExecuted = CpuExecute(uCyclesToExecute, bVideoUpdate);
g_dwCyclesThisFrame += uActualCyclesExecuted;
DiskUpdateDriveState(uActualCyclesExecuted);
sg_Disk2Card.UpdateDriveState(uActualCyclesExecuted);
JoyUpdateButtonLatch(nExecutionPeriodUsec); // Button latch time is independent of CPU clock frequency
PrintUpdate(uActualCyclesExecuted);
@ -624,7 +625,7 @@ void LoadConfiguration(void)
DWORD dwEnhanceDisk;
REGLOAD(TEXT(REGVALUE_ENHANCE_DISK_SPEED), &dwEnhanceDisk);
Disk_SetEnhanceDisk(dwEnhanceDisk ? true : false);
sg_Disk2Card.SetEnhanceDisk(dwEnhanceDisk ? true : false);
Config_Load_Video();
@ -713,8 +714,8 @@ void LoadConfiguration(void)
GetCurrentDirectory(sizeof(szFilename), szFilename);
SetCurrentImageDir(szFilename);
Disk_LoadLastDiskImage(DRIVE_1);
Disk_LoadLastDiskImage(DRIVE_2);
sg_Disk2Card.LoadLastDiskImage(DRIVE_1);
sg_Disk2Card.LoadLastDiskImage(DRIVE_2);
//
@ -1061,7 +1062,7 @@ static bool DoDiskInsert(const int nDrive, LPCSTR szFileName)
std::string strPathName = GetFullPath(szFileName);
if (strPathName.empty()) return false;
ImageError_e Error = DiskInsert(nDrive, strPathName.c_str(), IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE);
ImageError_e Error = sg_Disk2Card.InsertDisk(nDrive, strPathName.c_str(), IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE);
return Error == eIMAGE_ERROR_NONE;
}
@ -1521,9 +1522,6 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
ImageInitialize();
LogFileOutput("Init: ImageInitialize()\n");
DiskInitialize();
LogFileOutput("Init: DiskInitialize()\n");
//
do
@ -1615,7 +1613,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
}
// Need to test if it's safe to call ResetMachineState(). In the meantime, just call DiskReset():
DiskReset(); // Switch from a booting A][+ to a non-autostart A][, so need to turn off floppy motor
sg_Disk2Card.Reset(); // Switch from a booting A][+ to a non-autostart A][, so need to turn off floppy motor
LogFileOutput("Main: DiskReset()\n");
HD_Reset(); // GH#515
LogFileOutput("Main: HDDReset()\n");

View File

@ -130,19 +130,19 @@ BOOL CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM l
case WM_INITDIALOG:
{
m_PropertySheetHelper.FillComboBox(hWnd, IDC_DISKTYPE, m_discchoices, Disk_GetEnhanceDisk() ? 1 : 0);
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(DiskGetFullName(DRIVE_1)) > 0)
if (strlen(sg_Disk2Card.GetFullName(DRIVE_1)) > 0)
{
SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_INSERTSTRING, 0, (LPARAM)DiskGetFullName(DRIVE_1));
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(DiskGetFullName(DRIVE_2)) > 0)
if (strlen(sg_Disk2Card.GetFullName(DRIVE_2)) > 0)
{
SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_INSERTSTRING, 0, (LPARAM)DiskGetFullName(DRIVE_2));
SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_INSERTSTRING, 0, (LPARAM)sg_Disk2Card.GetFullName(DRIVE_2));
SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_SETCURSEL, 0, 0);
}
@ -187,9 +187,9 @@ void CPageDisk::InitComboHDD(HWND hWnd)
void CPageDisk::DlgOK(HWND hWnd)
{
const bool bNewEnhanceDisk = SendDlgItemMessage(hWnd, IDC_DISKTYPE,CB_GETCURSEL, 0, 0) ? true : false;
if (bNewEnhanceDisk != Disk_GetEnhanceDisk())
if (bNewEnhanceDisk != sg_Disk2Card.GetEnhanceDisk())
{
Disk_SetEnhanceDisk(bNewEnhanceDisk);
sg_Disk2Card.SetEnhanceDisk(bNewEnhanceDisk);
REGSAVE(TEXT(REGVALUE_ENHANCE_DISK_SPEED), (DWORD)bNewEnhanceDisk);
}
@ -299,7 +299,7 @@ void CPageDisk::HandleDiskCombo(HWND hWnd, UINT driveSelected, UINT comboSelecte
if (dwComboSelection == dwOpenDialogIndex)
{
EnableDisk(hWnd, FALSE); // Prevent multiple Selection dialogs to be triggered
bool bRes = DiskSelect(driveSelected);
bool bRes = sg_Disk2Card.UserSelectNewDiskImage(driveSelected);
EnableDisk(hWnd, TRUE);
if (!bRes)
@ -316,13 +316,13 @@ void CPageDisk::HandleDiskCombo(HWND hWnd, UINT driveSelected, UINT comboSelecte
SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0);
}
SendDlgItemMessage(hWnd, comboSelected, CB_INSERTSTRING, 0, (LPARAM)DiskGetFullName(driveSelected));
SendDlgItemMessage(hWnd, comboSelected, CB_INSERTSTRING, 0, (LPARAM)sg_Disk2Card.GetFullName(driveSelected));
SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, 0, 0);
// If the FD was in the other combo, remove now
DWORD comboOther = (comboSelected == IDC_COMBO_DISK1) ? IDC_COMBO_DISK2 : IDC_COMBO_DISK1;
DWORD duplicated = (DWORD)SendDlgItemMessage(hWnd, comboOther, CB_FINDSTRINGEXACT, -1, (LPARAM)DiskGetFullName(driveSelected));
DWORD duplicated = (DWORD)SendDlgItemMessage(hWnd, comboOther, CB_FINDSTRINGEXACT, -1, (LPARAM)sg_Disk2Card.GetFullName(driveSelected));
if (duplicated != CB_ERR)
{
SendDlgItemMessage(hWnd, comboOther, CB_DELETESTRING, duplicated, 0);
@ -337,7 +337,7 @@ void CPageDisk::HandleDiskCombo(HWND hWnd, UINT driveSelected, UINT comboSelecte
if (RemovalConfirmation(uCommand))
{
// Eject selected disk
DiskEject(driveSelected);
sg_Disk2Card.EjectDisk(driveSelected);
// Remove drive from list
SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0);
}

View File

@ -198,7 +198,7 @@ void CPropertySheetHelper::SaveStateUpdate()
void CPropertySheetHelper::GetDiskBaseNameWithAWS(TCHAR* pszFilename)
{
LPCTSTR pDiskName = DiskGetBaseName(DRIVE_1);
LPCTSTR pDiskName = sg_Disk2Card.GetBaseName(DRIVE_1);
if (pDiskName && pDiskName[0])
{
strcpy(pszFilename, pDiskName);

View File

@ -3727,15 +3727,15 @@ Update_t CmdDisk ( int nArgs)
if (nArgs > 2)
goto _Help;
int drive = DiskGetCurrentDrive() + 1;
int drive = sg_Disk2Card.GetCurrentDrive() + 1;
char buffer[200] = "";
ConsoleBufferPushFormat(buffer, "D%d at T$%X (%d), phase $%X, offset $%X, %s",
drive,
DiskGetCurrentTrack(),
DiskGetCurrentTrack(),
DiskGetCurrentPhase(),
DiskGetCurrentOffset(),
DiskGetCurrentState());
sg_Disk2Card.GetCurrentTrack(),
sg_Disk2Card.GetCurrentTrack(),
sg_Disk2Card.GetCurrentPhase(),
sg_Disk2Card.GetCurrentOffset(),
sg_Disk2Card.GetCurrentState());
return ConsoleUpdate();
}
@ -3762,7 +3762,7 @@ Update_t CmdDisk ( int nArgs)
if (nArgs > 2)
goto _Help;
DiskEject( iDrive );
sg_Disk2Card.EjectDisk( iDrive );
FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES);
}
else
@ -3776,7 +3776,7 @@ Update_t CmdDisk ( int nArgs)
if (nArgs == 3)
bProtect = g_aArgs[ 3 ].nValue ? true : false;
DiskSetProtect( iDrive, bProtect );
sg_Disk2Card.SetProtect( iDrive, bProtect );
FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES);
}
else
@ -3787,7 +3787,7 @@ Update_t CmdDisk ( int nArgs)
LPCTSTR pDiskName = g_aArgs[ 3 ].sArg;
// DISK # "Diskname"
DiskInsert( iDrive, pDiskName, IMAGE_FORCE_WRITE_PROTECTED, IMAGE_DONT_CREATE );
sg_Disk2Card.InsertDisk( iDrive, pDiskName, IMAGE_FORCE_WRITE_PROTECTED, IMAGE_DONT_CREATE );
FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES);
}

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ AppleWin : An Apple //e emulator for Windows
Copyright (C) 1994-1996, Michael O'Brien
Copyright (C) 1999-2001, Oliver Schmidt
Copyright (C) 2002-2005, Tom Charlesworth
Copyright (C) 2006-2010, Tom Charlesworth, Michael Pohoreski
Copyright (C) 2006-2019, Tom Charlesworth, Michael Pohoreski, Nick Westgate
AppleWin is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -23,9 +23,11 @@ along with AppleWin; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "DiskLog.h"
#include "DiskFormatTrack.h"
#include "DiskImage.h"
// Floppy Disk Drives
extern class Disk2InterfaceCard sg_Disk2Card;
enum Drive_e
{
@ -39,86 +41,171 @@ const bool IMAGE_FORCE_WRITE_PROTECTED = true;
const bool IMAGE_DONT_CREATE = false;
const bool IMAGE_CREATE = true;
const char* DiskGetDiskPathFilename(const int iDrive);
void DiskInitialize(void); // DiskIIManagerStartup()
void DiskDestroy(void); // no, doesn't "destroy" the disk image. DiskIIManagerShutdown()
void DiskBoot(void);
void DiskEject(const int iDrive);
void DiskFlushCurrentTrack(const int iDrive);
LPCTSTR DiskGetFullName(const int iDrive);
LPCTSTR DiskGetFullDiskFilename(const int iDrive);
LPCTSTR DiskGetBaseName(const int iDrive);
void DiskGetLightStatus (Disk_Status_e* pDisk1Status, Disk_Status_e* pDisk2Status);
ImageError_e DiskInsert(const int iDrive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary);
bool Disk_IsConditionForFullSpeed(void);
BOOL DiskIsSpinning(void);
void DiskNotifyInvalidImage(const int iDrive, LPCTSTR pszImageFilename, const ImageError_e Error);
void DiskReset(const bool bIsPowerCycle=false);
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();
const char* DiskGetCurrentState();
bool DiskSelect(const int iDrive);
void DiskUpdateDriveState(DWORD);
bool DiskDriveSwap(void);
void DiskLoadRom(LPBYTE pCxRomPeripheral, UINT uSlot);
std::string DiskGetSnapshotCardName(void);
void DiskSaveSnapshot(class YamlSaveHelper& yamlSaveHelper);
bool DiskLoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version);
void Disk_LoadLastDiskImage(const int iDrive);
void Disk_SaveLastDiskImage(const int iDrive);
bool Disk_ImageIsWriteProtected(const int iDrive);
bool Disk_IsDriveEmpty(const int iDrive);
bool Disk_GetEnhanceDisk(void);
void Disk_SetEnhanceDisk(bool bEnhanceDisk);
//
// For sharing with class FormatTrack
struct Disk_t
class FloppyDisk
{
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()
public:
FloppyDisk()
{
clear();
}
~FloppyDisk(){}
void clear()
{
ZeroMemory(imagename, sizeof(imagename));
ZeroMemory(fullname, sizeof(fullname));
strFilenameInZip.clear();
imagehandle = NULL;
bWriteProtected = false;
ZeroMemory(m_imagename, sizeof(m_imagename));
ZeroMemory(m_fullname, sizeof(m_fullname));
m_strFilenameInZip.clear();
m_imagehandle = NULL;
m_bWriteProtected = false;
//
byte = 0;
nibbles = 0;
trackimage = NULL;
trackimagedata = false;
trackimagedirty = false;
m_byte = 0;
m_nibbles = 0;
m_trackimage = NULL;
m_trackimagedata = false;
m_trackimagedirty = false;
}
public:
TCHAR m_imagename[ MAX_DISK_IMAGE_NAME + 1 ]; // <FILENAME> (ie. no extension)
TCHAR m_fullname [ MAX_DISK_FULL_NAME + 1 ]; // <FILENAME.EXT> or <FILENAME.zip> : This is persisted to the snapshot file
std::string m_strFilenameInZip; // "" or <FILENAME.EXT>
ImageInfo* m_imagehandle; // Init'd by InsertDisk() -> ImageOpen()
bool m_bWriteProtected;
int m_byte;
int m_nibbles; // Init'd by ReadTrack() -> ImageReadTrack()
LPBYTE m_trackimage;
bool m_trackimagedata;
bool m_trackimagedirty;
};
class FloppyDrive
{
public:
FloppyDrive()
{
clear();
}
~FloppyDrive(){}
void clear()
{
m_phase = 0;
m_track = 0;
m_spinning = 0;
m_writelight = 0;
m_disk.clear();
}
public:
int m_phase;
int m_track;
DWORD m_spinning;
DWORD m_writelight;
FloppyDisk m_disk;
};
class Disk2InterfaceCard
{
public:
Disk2InterfaceCard(void);
virtual ~Disk2InterfaceCard(void){}
void Initialize(LPBYTE pCxRomPeripheral, UINT uSlot);
void Destroy(void); // no, doesn't "destroy" the disk image. DiskIIManagerShutdown()
void Boot(void);
void FlushCurrentTrack(const int drive);
LPCTSTR GetFullDiskFilename(const int drive);
LPCTSTR GetFullName(const int drive);
LPCTSTR GetBaseName(const int drive);
void GetLightStatus (Disk_Status_e* pDisk1Status, Disk_Status_e* pDisk2Status);
ImageError_e InsertDisk(const int drive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary);
void EjectDisk(const int drive);
bool IsConditionForFullSpeed(void);
void NotifyInvalidImage(const int drive, LPCTSTR pszImageFilename, const ImageError_e Error);
void Reset(const bool bIsPowerCycle=false);
bool GetProtect(const int drive);
void SetProtect(const int drive, const bool bWriteProtect);
int GetCurrentDrive(void);
int GetCurrentTrack();
int GetTrack(const int drive);
int GetCurrentPhase(void);
int GetCurrentOffset(void);
LPCTSTR GetCurrentState(void);
bool UserSelectNewDiskImage(const int drive, LPCSTR pszFilename="");
void UpdateDriveState(DWORD cycles);
bool DriveSwap(void);
std::string GetSnapshotCardName(void);
void SaveSnapshot(class YamlSaveHelper& yamlSaveHelper);
bool LoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version);
void LoadLastDiskImage(const int drive);
void SaveLastDiskImage(const int drive);
bool IsDiskImageWriteProtected(const int drive);
bool IsDriveEmpty(const int drive);
bool GetEnhanceDisk(void);
void SetEnhanceDisk(bool bEnhanceDisk);
static BYTE __stdcall IORead(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles);
static BYTE __stdcall IOWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles);
private:
void CheckSpinning(const ULONG nExecutedCycles);
Disk_Status_e GetDriveLightStatus(const int drive);
bool IsDriveValid(const int drive);
void AllocTrack(const int drive);
void ReadTrack(const int drive);
void RemoveDisk(const int drive);
void WriteTrack(const int drive);
LPCTSTR DiskGetFullPathName(const int drive);
void SaveSnapshotDisk2Unit(YamlSaveHelper& yamlSaveHelper, UINT unit);
void LoadSnapshotDriveUnit(YamlLoadHelper& yamlLoadHelper, UINT unit);
void __stdcall ControlStepper(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles);
void __stdcall ControlMotor(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles);
void __stdcall Enable(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles);
void __stdcall ReadWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles);
void __stdcall LoadWriteProtect(WORD, WORD, BYTE write, BYTE value, ULONG);
void __stdcall SetReadMode(WORD, WORD, BYTE, BYTE, ULONG);
void __stdcall SetWriteMode(WORD, WORD, BYTE, BYTE, ULONG uExecutedCycles);
#if LOG_DISK_NIBBLES_WRITE
bool LogWriteCheckSyncFF(ULONG& uCycleDelta);
#endif
//
WORD m_currDrive;
FloppyDrive m_floppyDrive[NUM_DRIVES];
BYTE m_floppyLatch;
BOOL m_floppyMotorOn;
BOOL m_floppyLoadMode; // for efficiency this is not used; it's extremely unlikely to affect emulation (nickw)
BOOL m_floppyWriteMode;
WORD m_phases; // state bits for stepper magnet phases 0 - 3
bool m_saveDiskImage;
UINT m_slot;
unsigned __int64 m_diskLastCycle;
unsigned __int64 m_diskLastReadLatchCycle;
FormatTrack m_formatTrack;
bool m_enhanceDisk;
static const UINT SPINNING_CYCLES = 20000*64; // 1280000 cycles = 1.25s
static const UINT WRITELIGHT_CYCLES = 20000*64; // 1280000 cycles = 1.25s
// Debug:
#if LOG_DISK_NIBBLES_USE_RUNTIME_VAR
bool m_bLogDisk_NibblesRW; // From VS Debugger, change this to true/false during runtime for precise nibble logging
#endif
#if LOG_DISK_NIBBLES_WRITE
UINT64 m_uWriteLastCycle;
UINT m_uSyncFFCount;
#endif
};

View File

@ -45,8 +45,6 @@ Writes the following: (in 1 continuous write operation)
#include "StdAfx.h"
#include "Disk.h"
#include "DiskLog.h"
#include "DiskFormatTrack.h"
#include "Log.h"
#include "YamlHelper.h"
@ -84,15 +82,15 @@ void FormatTrack::DriveNotWritingTrack(void)
#endif
}
void FormatTrack::UpdateOnWriteLatch(UINT uSpinNibbleCount, const Disk_t* const pFloppy)
void FormatTrack::UpdateOnWriteLatch(UINT uSpinNibbleCount, const FloppyDisk* const pFloppy)
{
if (pFloppy->bWriteProtected)
if (pFloppy->m_bWriteProtected)
return;
if (m_bmWrittenSectorAddrFields == 0x0000)
{
if (m_WriteTrackStartIndex == (UINT)-1) // waiting for 1st write?
m_WriteTrackStartIndex = pFloppy->byte;
m_WriteTrackStartIndex = pFloppy->m_byte;
return;
}
@ -108,8 +106,8 @@ void FormatTrack::UpdateOnWriteLatch(UINT uSpinNibbleCount, const Disk_t* const
return;
}
UINT uTrackIndex = pFloppy->byte;
const UINT& kTrackMaxNibbles = pFloppy->nibbles;
UINT uTrackIndex = pFloppy->m_byte;
const UINT& kTrackMaxNibbles = pFloppy->m_nibbles;
// NB. spin in write mode is only max 1-2 bytes
do
@ -128,7 +126,7 @@ void FormatTrack::UpdateOnWriteLatch(UINT uSpinNibbleCount, const Disk_t* const
while (uSpinNibbleCount--);
}
void FormatTrack::DriveSwitchedToReadMode(Disk_t* const pFloppy)
void FormatTrack::DriveSwitchedToReadMode(FloppyDisk* const pFloppy)
{
if (m_bAddressPrologueIsDOS3_2)
{
@ -154,10 +152,10 @@ void FormatTrack::DriveSwitchedToReadMode(Disk_t* const pFloppy)
// So need a track size between 0x18B0 (rounding down) and 0x182F
const UINT kShortTrackLen = 0x18B0;
LPBYTE TrackBuffer = pFloppy->trackimage;
const UINT kLongTrackLen = pFloppy->nibbles;
LPBYTE TrackBuffer = pFloppy->m_trackimage;
const UINT kLongTrackLen = pFloppy->m_nibbles;
UINT uWriteTrackEndIndex = pFloppy->byte;
UINT uWriteTrackEndIndex = pFloppy->m_byte;
UINT uWrittenTrackSize = m_WriteTrackHasWrapped ? kLongTrackLen : 0;
if (m_WriteTrackStartIndex <= uWriteTrackEndIndex)
@ -216,7 +214,7 @@ void FormatTrack::DecodeLatchNibbleRead(BYTE floppylatch)
DecodeLatchNibble(floppylatch, false, false);
}
void FormatTrack::DecodeLatchNibbleWrite(BYTE floppylatch, UINT uSpinNibbleCount, const Disk_t* const pFloppy, bool bIsSyncFF)
void FormatTrack::DecodeLatchNibbleWrite(BYTE floppylatch, UINT uSpinNibbleCount, const FloppyDisk* const pFloppy, bool bIsSyncFF)
{
DecodeLatchNibble(floppylatch, true, bIsSyncFF);
UpdateOnWriteLatch(uSpinNibbleCount, pFloppy);

View File

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

View File

@ -155,7 +155,8 @@ void ImageReadTrack( ImageInfo* const pImageInfo,
const int nTrack,
const int nQuarterTrack,
LPBYTE pTrackImageBuffer,
int* pNibbles)
int* pNibbles,
bool enhanceDisk)
{
_ASSERT(nTrack >= 0);
if (nTrack < 0)
@ -163,7 +164,7 @@ void ImageReadTrack( ImageInfo* const pImageInfo,
if (pImageInfo->pImageType->AllowRW() && pImageInfo->ValidTrack[nTrack])
{
pImageInfo->pImageType->Read(pImageInfo, nTrack, nQuarterTrack, pTrackImageBuffer, pNibbles);
pImageInfo->pImageType->Read(pImageInfo, nTrack, nQuarterTrack, pTrackImageBuffer, pNibbles, enhanceDisk);
}
else
{

View File

@ -71,7 +71,7 @@ BOOL ImageBoot(ImageInfo* const pImageInfo);
void ImageDestroy(void);
void ImageInitialize(void);
void ImageReadTrack(ImageInfo* const pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles);
void ImageReadTrack(ImageInfo* const pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles, bool enhanceDisk);
void ImageWriteTrack(ImageInfo* const pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImage, int nNibbles);
bool ImageReadBlock(ImageInfo* const pImageInfo, UINT nBlock, LPBYTE pBlockBuffer);
bool ImageWriteBlock(ImageInfo* const pImageInfo, UINT nBlock, LPBYTE pBlockBuffer);

View File

@ -34,7 +34,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "unzip.h"
#include "CPU.h"
#include "Disk.h"
#include "DiskImage.h"
#include "DiskImageHelper.h"
#include "Memory.h"
@ -631,11 +630,11 @@ public:
return ePossibleMatch;
}
virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles)
virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles, bool enhanceDisk)
{
ReadTrack(pImageInfo, nTrack, ms_pWorkBuffer, TRACK_DENIBBLIZED_SIZE);
*pNibbles = NibblizeTrack(pTrackImageBuffer, eDOSOrder, nTrack);
if (!Disk_GetEnhanceDisk())
if (!enhanceDisk)
SkewTrack(nTrack, *pNibbles, pTrackImageBuffer);
}
@ -697,11 +696,11 @@ public:
return ePossibleMatch;
}
virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles)
virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles, bool enhanceDisk)
{
ReadTrack(pImageInfo, nTrack, ms_pWorkBuffer, TRACK_DENIBBLIZED_SIZE);
*pNibbles = NibblizeTrack(pTrackImageBuffer, eProDOSOrder, nTrack);
if (!Disk_GetEnhanceDisk())
if (!enhanceDisk)
SkewTrack(nTrack, *pNibbles, pTrackImageBuffer);
}
@ -736,7 +735,7 @@ public:
return eMatch;
}
virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles)
virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles, bool enhanceDisk)
{
ReadTrack(pImageInfo, nTrack, pTrackImageBuffer, NIB1_TRACK_SIZE);
*pNibbles = NIB1_TRACK_SIZE;
@ -776,7 +775,7 @@ public:
return eMatch;
}
virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles)
virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles, bool enhanceDisk)
{
ReadTrack(pImageInfo, nTrack, pTrackImageBuffer, NIB2_TRACK_SIZE);
*pNibbles = NIB2_TRACK_SIZE;
@ -852,7 +851,7 @@ public:
return eMatch;
}
virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles)
virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles, bool enhanceDisk)
{
// IF WE HAVEN'T ALREADY DONE SO, READ THE IMAGE FILE HEADER
if (!m_pHeader)

View File

@ -54,7 +54,7 @@ public:
virtual bool Boot(ImageInfo* pImageInfo) { return false; }
virtual eDetectResult Detect(const LPBYTE pImage, const DWORD dwImageSize, const TCHAR* pszExt) = 0;
virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles) { }
virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles, bool enhanceDisk) { }
virtual bool Read(ImageInfo* pImageInfo, UINT nBlock, LPBYTE pBlockBuffer) { return false; }
virtual void Write(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImage, int nNibbles) { }
virtual bool Write(ImageInfo* pImageInfo, UINT nBlock, LPBYTE pBlockBuffer) { return false; }

View File

@ -512,7 +512,7 @@ static void DrawButton (HDC passdc, int number) {
SetTextColor(dc,RGB(0,0,0));
SetTextAlign(dc,TA_CENTER | TA_TOP);
SetBkMode(dc,TRANSPARENT);
LPCTSTR pszBaseName = DiskGetBaseName(number-BTN_DRIVE1);
LPCTSTR pszBaseName = sg_Disk2Card.GetBaseName(number-BTN_DRIVE1);
ExtTextOut(dc,x+offset+22,rect.top,ETO_CLIPPED,&rect,
pszBaseName,
MIN(8,_tcslen(pszBaseName)),
@ -702,7 +702,7 @@ void FrameDrawDiskLEDS( HDC passdc )
{
Disk_Status_e eDrive1Status;
Disk_Status_e eDrive2Status;
DiskGetLightStatus(&eDrive1Status, &eDrive2Status);
sg_Disk2Card.GetLightStatus(&eDrive1Status, &eDrive2Status);
g_eStatusDrive1 = eDrive1Status;
g_eStatusDrive2 = eDrive2Status;
@ -755,11 +755,11 @@ void FrameDrawDiskStatus( HDC passdc )
// Track $B7EC LC1 $D356
// Sector $B7ED LC1 $D357
// RWTS LC1 $D300
int nActiveFloppy = DiskGetCurrentDrive();
int nActiveFloppy = sg_Disk2Card.GetCurrentDrive();
int nDisk1Track = sg_Disk2Card.GetTrack(DRIVE_1);
int nDisk2Track = sg_Disk2Card.GetTrack(DRIVE_2);
int nDisk1Track = DiskGetTrack(0);
int nDisk2Track = DiskGetTrack(1);
// Probe known OS's for Track/Sector
int isProDOS = mem[ 0xBF00 ] == 0x4C;
bool isValid = true;
@ -1103,7 +1103,7 @@ LRESULT CALLBACK FrameWndProc (
Snapshot_Shutdown();
DebugDestroy();
if (!g_bRestart) {
DiskDestroy();
sg_Disk2Card.Destroy();
ImageDestroy();
HD_Destroy();
}
@ -1161,7 +1161,7 @@ LRESULT CALLBACK FrameWndProc (
LogFileOutput("WM_DDE_EXECUTE\n");
LPTSTR filename = (LPTSTR)GlobalLock((HGLOBAL)lparam);
//MessageBox( g_hFrameWindow, filename, "DDE Exec", MB_OK );
ImageError_e Error = DiskInsert(DRIVE_1, filename, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE);
ImageError_e Error = sg_Disk2Card.InsertDisk(DRIVE_1, filename, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE);
if (Error == eIMAGE_ERROR_NONE)
{
if (!g_bIsFullScreen)
@ -1171,7 +1171,7 @@ LRESULT CALLBACK FrameWndProc (
}
else
{
DiskNotifyInvalidImage(DRIVE_1, filename, Error);
sg_Disk2Card.NotifyInvalidImage(DRIVE_1, filename, Error);
}
GlobalUnlock((HGLOBAL)lparam);
LogFileOutput("WM_DDE_EXECUTE (done)\n");
@ -1193,7 +1193,7 @@ LRESULT CALLBACK FrameWndProc (
rect.top = buttony+BTN_DRIVE2*BUTTONCY+1;
rect.bottom = rect.top+BUTTONCY;
const int iDrive = PtInRect(&rect,point) ? DRIVE_2 : DRIVE_1;
ImageError_e Error = DiskInsert(iDrive, filename, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE);
ImageError_e Error = sg_Disk2Card.InsertDisk(iDrive, filename, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE);
if (Error == eIMAGE_ERROR_NONE)
{
if (!g_bIsFullScreen)
@ -1207,7 +1207,7 @@ LRESULT CALLBACK FrameWndProc (
}
else
{
DiskNotifyInvalidImage(iDrive, filename, Error);
sg_Disk2Card.NotifyInvalidImage(iDrive, filename, Error);
}
DragFinish((HDROP)wparam);
break;
@ -1653,7 +1653,7 @@ LRESULT CALLBACK FrameWndProc (
if(((LPNMTTDISPINFO)lparam)->hdr.hwndFrom == tooltipwindow &&
((LPNMTTDISPINFO)lparam)->hdr.code == TTN_GETDISPINFO)
((LPNMTTDISPINFO)lparam)->lpszText =
(LPTSTR)DiskGetFullDiskFilename(((LPNMTTDISPINFO)lparam)->hdr.idFrom);
(LPTSTR)sg_Disk2Card.GetFullDiskFilename(((LPNMTTDISPINFO)lparam)->hdr.idFrom);
break;
case WM_PAINT:
@ -1967,7 +1967,7 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/)
if (g_nAppMode == MODE_LOGO)
{
DiskBoot();
sg_Disk2Card.Boot();
LogFileTimeUntilFirstKeyReadReset();
g_nAppMode = MODE_RUNNING;
}
@ -1990,13 +1990,13 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/)
case BTN_DRIVE1:
case BTN_DRIVE2:
DiskSelect(button-BTN_DRIVE1);
sg_Disk2Card.UserSelectNewDiskImage(button-BTN_DRIVE1);
if (!g_bIsFullScreen)
DrawButton((HDC)0,button);
break;
case BTN_DRIVESWAP:
DiskDriveSwap();
sg_Disk2Card.DriveSwap();
break;
case BTN_FULLSCR:
@ -2057,7 +2057,7 @@ 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.
std::string filename1= "\"";
filename1.append( DiskGetDiskPathFilename(iDrive) );
filename1.append( sg_Disk2Card.GetFullName(iDrive) );
filename1.append("\"");
std::string sFileNameEmpty = "\"";
sFileNameEmpty.append("\"");
@ -2079,16 +2079,16 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive)
// Check menu depending on current floppy protection
{
int iMenuItem = ID_DISKMENU_WRITEPROTECTION_OFF;
if (DiskGetProtect( iDrive ))
if (sg_Disk2Card.GetProtect( iDrive ))
iMenuItem = ID_DISKMENU_WRITEPROTECTION_ON;
CheckMenuItem(hmenu, iMenuItem, MF_CHECKED);
}
if (Disk_IsDriveEmpty(iDrive))
if (sg_Disk2Card.IsDriveEmpty(iDrive))
EnableMenuItem(hmenu, ID_DISKMENU_EJECT, MF_GRAYED);
if (Disk_ImageIsWriteProtected(iDrive))
if (sg_Disk2Card.IsDiskImageWriteProtected(iDrive))
{
// If image-file is read-only (or a gzip) then disable these menu items
EnableMenuItem(hmenu, ID_DISKMENU_WRITEPROTECTION_ON, MF_GRAYED);
@ -2104,13 +2104,13 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive)
, hwnd, NULL );
if (iCommand == ID_DISKMENU_EJECT)
DiskEject( iDrive );
sg_Disk2Card.EjectDisk( iDrive );
else
if (iCommand == ID_DISKMENU_WRITEPROTECTION_ON)
DiskSetProtect( iDrive, true );
sg_Disk2Card.SetProtect( iDrive, true );
else
if (iCommand == ID_DISKMENU_WRITEPROTECTION_OFF)
DiskSetProtect( iDrive, false );
sg_Disk2Card.SetProtect( iDrive, false );
else
if (iCommand == ID_DISKMENU_SENDTO_CIDERPRESS)
{
@ -2119,7 +2119,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive)
"Please install CiderPress.\n"
"Otherwise set the path to CiderPress from Configuration->Disk.";
DiskFlushCurrentTrack(iDrive);
sg_Disk2Card.FlushCurrentTrack(iDrive);
//if(!filename1.compare("\"\"") == false) //Do not use this, for some reason it does not work!!!
if(!filename1.compare(sFileNameEmpty) )
@ -2181,14 +2181,15 @@ void RelayEvent (UINT message, WPARAM wparam, LPARAM lparam) {
// todo: consolidate CtrlReset() and ResetMachineState()
void ResetMachineState ()
{
DiskReset(true);
sg_Disk2Card.Reset(true);
HD_Reset();
g_bFullSpeed = 0; // Might've hit reset in middle of InternalCpuExecute() - so beep may get (partially) muted
MemReset(); // calls CpuInitialize()
PravetsReset();
DiskBoot();
sg_Disk2Card.Boot();
VideoResetState();
KeybReset();
sg_SSC.CommReset();
PrintReset();
JoyReset();
@ -2225,7 +2226,7 @@ void CtrlReset()
}
PravetsReset();
DiskReset();
sg_Disk2Card.Reset();
HD_Reset();
KeybReset();
sg_SSC.CommReset();

View File

@ -140,7 +140,7 @@ struct HDD
#endif
}
// From Disk_t
// From FloppyDisk
TCHAR imagename[ MAX_DISK_IMAGE_NAME + 1 ]; // <FILENAME> (ie. no extension) [not used]
TCHAR fullname[ MAX_DISK_FULL_NAME + 1 ]; // <FILENAME.EXT> or <FILENAME.zip>
std::string strFilenameInZip; // "" or <FILENAME.EXT> [not used]

View File

@ -68,6 +68,7 @@ void KeybSetAltGrSendsWM_CHAR(bool state)
void KeybReset()
{
keycode = 0;
keywaiting = 0;
}

View File

@ -1692,7 +1692,7 @@ void MemInitializeIO(void)
ConfigureSAM(pCxRomPeripheral, 5); // $C500 : Z80 card
}
DiskLoadRom(pCxRomPeripheral, 6); // $C600 : Disk][ f/w
sg_Disk2Card.Initialize(pCxRomPeripheral, 6); // $C600 : Disk][ card
HD_Load_Rom(pCxRomPeripheral, 7); // $C700 : HDD f/w
//

View File

@ -445,7 +445,7 @@ static void SY6522_Write(BYTE nDevice, BYTE nReg, BYTE nValue)
pMB->sy6522.TIMER2_COUNTER.w = pMB->sy6522.TIMER2_LATCH.w;
StartTimer2(pMB);
CpuAdjustIrqCheck(pMB->sy6522.TIMER1_LATCH.w); // Sync IRQ check timeout with 6522 counter underflow - GH#608
CpuAdjustIrqCheck(pMB->sy6522.TIMER2_LATCH.w); // Sync IRQ check timeout with 6522 counter underflow - GH#608
break;
case 0x0a: // SERIAL_SHIFT
break;

View File

@ -286,9 +286,9 @@ static void ParseSlots(YamlLoadHelper& yamlLoadHelper, UINT unitVersion)
bRes = Phasor_LoadSnapshot(yamlLoadHelper, slot, cardVersion);
type = CT_Phasor;
}
else if (card == DiskGetSnapshotCardName())
else if (card == sg_Disk2Card.GetSnapshotCardName())
{
bRes = DiskLoadSnapshot(yamlLoadHelper, slot, cardVersion);
bRes = sg_Disk2Card.LoadSnapshot(yamlLoadHelper, slot, cardVersion);
type = CT_Disk2;
}
else if (card == HD_GetSnapshotCardName())
@ -391,7 +391,7 @@ static void Snapshot_LoadState_v2(void)
MemReset();
PravetsReset();
DiskReset();
sg_Disk2Card.Reset();
HD_Reset();
KeybReset();
VideoResetState();
@ -519,7 +519,7 @@ void Snapshot_SaveState(void)
if (g_Slot4 == CT_Phasor)
Phasor_SaveSnapshot(yamlSaveHelper, 4);
DiskSaveSnapshot(yamlSaveHelper);
sg_Disk2Card.SaveSnapshot(yamlSaveHelper);
HD_SaveSnapshot(yamlSaveHelper);
}

View File

@ -304,7 +304,7 @@ void VideoBenchmark () {
while (cycles > 0) {
DWORD executedcycles = CpuExecute(103, true);
cycles -= executedcycles;
DiskUpdateDriveState(executedcycles);
sg_Disk2Card.UpdateDriveState(executedcycles);
JoyUpdateButtonLatch(executedcycles);
}
}