mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-12-23 00:30:17 +00:00
DiskFormat: tweaks and fixed some TODOs in comments
This commit is contained in:
parent
4a69ba8a97
commit
02a6df73c5
@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define NIBBLES_PER_TRACK 0x1A00
|
||||
|
||||
const UINT NUM_SECTORS = 16;
|
||||
|
@ -120,13 +120,13 @@ void FormatTrack::DriveSwitchedToReadMode(Disk_t* const fptr)
|
||||
// Either up to 0x18F0 (if less than 0x18F0) or up to 0x1A00 (for .nib).
|
||||
|
||||
// When there's no spin (enhanced=1), then 0x18F0 is still too long, eg: (see GH#125)
|
||||
// Gap1 = 0x81, Gap3 = 0x1D (29), TrackSize = 0x1963
|
||||
// Gap1 = 0x81, Gap3 = 0x1C (28), TrackSize = 0x1954
|
||||
// Gap1 = 0x81, Gap3 = 0x1B (27), TrackSize = 0x1945
|
||||
// Gap1 = 0x81, Gap3 = 0x1A (26), TrackSize = 0x1936
|
||||
// Gap1 = 0x81, Gap2 = 0x05, Gap3 = 0x1D (29), TrackSize = 0x1963
|
||||
// Gap1 = 0x81, Gap2 = 0x05, Gap3 = 0x1C (28), TrackSize = 0x1954
|
||||
// Gap1 = 0x81, Gap2 = 0x05, Gap3 = 0x1B (27), TrackSize = 0x1945
|
||||
// Gap1 = 0x81, Gap2 = 0x05, Gap3 = 0x1A (26), TrackSize = 0x1936
|
||||
//
|
||||
// 0x1936 - 0x81(gap1) = 0x18B5
|
||||
// So need a track size of 0x18B0 (rounding down)
|
||||
// And 0x1936 - 0x81(gap1) = 0x18B5
|
||||
// So need a track size between 0x18B0 (rounding down) and 0x182F
|
||||
const UINT kShortTrackLen = 0x18B0;
|
||||
|
||||
LPBYTE TrackBuffer = fptr->trackimage;
|
||||
@ -171,22 +171,18 @@ void FormatTrack::DriveSwitchedToReadMode(Disk_t* const fptr)
|
||||
|
||||
void FormatTrack::DriveSwitchedToWriteMode(UINT uTrackIndex)
|
||||
{
|
||||
DecodeLatchNibbleReset();
|
||||
|
||||
if (m_bmWrittenSectorAddrFields == 0x0000) // written no sectors
|
||||
{
|
||||
m_WriteTrackStartIndex = (UINT)-1; // wait for 1st write
|
||||
}
|
||||
}
|
||||
|
||||
void FormatTrack::DecodeLatchNibbleReset(void)
|
||||
{
|
||||
// ProDOS: switches to write mode between Address Field & Gap2; and between Data Field & Gap3
|
||||
// ProDOS/DOS3.3: during track write, switches to read mode then back to write mode:
|
||||
// . between Address Field & Gap2; and between Data Field & Gap3
|
||||
// . so if at TS_GAP2_START then stay at TS_GAP2_START
|
||||
if (m_trackState != TS_GAP2_START)
|
||||
m_trackState = (m_bmWrittenSectorAddrFields == 0x0000) ? TS_GAP1 : TS_GAP3;
|
||||
m_uLast3Bytes = 0;
|
||||
m_4and4idx = 0;
|
||||
|
||||
if (m_bmWrittenSectorAddrFields == 0x0000) // written no sectors
|
||||
{
|
||||
m_WriteTrackStartIndex = (UINT)-1; // wait for 1st write
|
||||
}
|
||||
}
|
||||
|
||||
// This is just for debug/logging: used to output when a new Address Field has been read
|
||||
|
@ -43,7 +43,6 @@ public:
|
||||
void LoadSnapshot(class YamlLoadHelper& yamlLoadHelper);
|
||||
|
||||
private:
|
||||
void DecodeLatchNibbleReset(void);
|
||||
void UpdateOnWriteLatch(UINT uSpinNibbleCount, const Disk_t* const fptr);
|
||||
void DecodeLatchNibble(BYTE floppylatch, BOOL bIsWrite);
|
||||
|
||||
|
@ -419,8 +419,8 @@ void CImageBase::DenibblizeTrack(LPBYTE trackimage, SectorOrder_e SectorOrder, i
|
||||
#endif
|
||||
|
||||
int offset = 0;
|
||||
int partsleft = 33; // TODO-TC: 32 = 16*2 prologues
|
||||
int sector = 0;
|
||||
int partsleft = NUM_SECTORS*2+1; // TC: 32+1 prologues - need 1 extra if trackimage starts between Addr Field & Data Field
|
||||
int sector = -1;
|
||||
while (partsleft--)
|
||||
{
|
||||
BYTE byteval[3] = {0,0,0};
|
||||
@ -454,8 +454,8 @@ void CImageBase::DenibblizeTrack(LPBYTE trackimage, SectorOrder_e SectorOrder, i
|
||||
| (*(ms_pWorkBuffer+TRACK_DENIBBLIZED_SIZE+5) & 0x55);
|
||||
|
||||
#ifdef _DEBUG
|
||||
_ASSERT( sector <= 15 );
|
||||
if (partsleft != 0) // Don't need this if partsleft is initialised to 32 (not 33)
|
||||
_ASSERT( sector < NUM_SECTORS );
|
||||
if (partsleft != 0)
|
||||
{
|
||||
_ASSERT( (bmWrittenSectorAddrFields & (1<<sector)) == 0 );
|
||||
bmWrittenSectorAddrFields |= (1<<sector);
|
||||
@ -464,12 +464,14 @@ void CImageBase::DenibblizeTrack(LPBYTE trackimage, SectorOrder_e SectorOrder, i
|
||||
}
|
||||
else if (byteval[2] == 0xAD)
|
||||
{
|
||||
if (sector >= 0 && sector < NUM_SECTORS)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
uWriteDataFieldPrologueCount++;
|
||||
_ASSERT(uWriteDataFieldPrologueCount <= 16);
|
||||
uWriteDataFieldPrologueCount++;
|
||||
_ASSERT(uWriteDataFieldPrologueCount <= NUM_SECTORS);
|
||||
#endif
|
||||
|
||||
Decode62(ms_pWorkBuffer+(ms_SectorNumber[SectorOrder][sector] << 8));
|
||||
Decode62(ms_pWorkBuffer+(ms_SectorNumber[SectorOrder][sector] << 8));
|
||||
}
|
||||
sector = 0;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "DiskDefs.h"
|
||||
#include "zip.h"
|
||||
|
||||
#define GZ_SUFFIX ".gz"
|
||||
@ -90,7 +91,7 @@ public:
|
||||
|
||||
protected:
|
||||
static BYTE ms_DiskByte[0x40];
|
||||
static BYTE ms_SectorNumber[NUM_SECTOR_ORDERS][0x10];
|
||||
static BYTE ms_SectorNumber[NUM_SECTOR_ORDERS][NUM_SECTORS];
|
||||
BYTE m_uVolumeNumber;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user