mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-09-29 21:56:12 +00:00
Disk.cpp tidy-up. Removed superfluous "if" and tried to give the logging another facelift.
This commit is contained in:
parent
a1debc40e4
commit
9d5c56bc1c
@ -40,12 +40,11 @@ static BYTE __stdcall DiskSetWriteMode (WORD pc, WORD addr, BYTE bWrite, BYTE d,
|
|||||||
|
|
||||||
#define LOG_DISK_ENABLED 1
|
#define LOG_DISK_ENABLED 1
|
||||||
|
|
||||||
#ifndef _VC71 // __VA_ARGS__ not supported on MSVC++ .NET 7.x
|
// __VA_ARGS__ not supported on MSVC++ .NET 7.x
|
||||||
#if LOG_DISK_ENABLED
|
#if (LOG_DISK_ENABLED) && !defined(_VC71)
|
||||||
#define LOG_DISK(format, ...) LOG(format, __VA_ARGS__)
|
#define LOG_DISK(format, ...) LOG(format, __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define LOG_DISK(...)
|
#define LOG_DISK(...)
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Public _________________________________________________________________________________________
|
// Public _________________________________________________________________________________________
|
||||||
@ -207,9 +206,8 @@ static void ReadTrack (int iDrive)
|
|||||||
|
|
||||||
if (pFloppy->trackimage && pFloppy->imagehandle)
|
if (pFloppy->trackimage && pFloppy->imagehandle)
|
||||||
{
|
{
|
||||||
#ifndef _VC71
|
|
||||||
LOG_DISK("read track %2X%s\r", pFloppy->track, (pFloppy->phase & 1) ? ".5" : "");
|
LOG_DISK("read track %2X%s\r", pFloppy->track, (pFloppy->phase & 1) ? ".5" : "");
|
||||||
#endif
|
|
||||||
ImageReadTrack(
|
ImageReadTrack(
|
||||||
pFloppy->imagehandle,
|
pFloppy->imagehandle,
|
||||||
pFloppy->track,
|
pFloppy->track,
|
||||||
@ -302,17 +300,13 @@ static BYTE __stdcall DiskControlStepper (WORD, WORD address, BYTE, BYTE, ULONG)
|
|||||||
{
|
{
|
||||||
// phase on
|
// phase on
|
||||||
phases |= phase_bit;
|
phases |= phase_bit;
|
||||||
#ifndef _VC71
|
|
||||||
LOG_DISK("track %02X phases %X phase %d on address $C0E%X\r", fptr->phase, phases, phase, address & 0xF);
|
LOG_DISK("track %02X phases %X phase %d on address $C0E%X\r", fptr->phase, phases, phase, address & 0xF);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// phase off
|
// phase off
|
||||||
phases &= ~phase_bit;
|
phases &= ~phase_bit;
|
||||||
#ifndef _VC71
|
|
||||||
LOG_DISK("track %02X phases %X phase %d off address $C0E%X\r", fptr->phase, phases, phase, address & 0xF);
|
LOG_DISK("track %02X phases %X phase %d off address $C0E%X\r", fptr->phase, phases, phase, address & 0xF);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for any stepping effect from a magnet
|
// check for any stepping effect from a magnet
|
||||||
@ -321,22 +315,17 @@ static BYTE __stdcall DiskControlStepper (WORD, WORD address, BYTE, BYTE, ULONG)
|
|||||||
// - do not move if both adjacent magnets are on
|
// - do not move if both adjacent magnets are on
|
||||||
// momentum and timing are not accounted for ... maybe one day!
|
// momentum and timing are not accounted for ... maybe one day!
|
||||||
int direction = 0;
|
int direction = 0;
|
||||||
if ((phases & (1 << fptr->phase)) == 0)
|
if (phases & (1 << ((fptr->phase + 1) & 3)))
|
||||||
{
|
direction += 1;
|
||||||
if (phases & (1 << ((fptr->phase + 1) & 3)))
|
if (phases & (1 << ((fptr->phase + 3) & 3)))
|
||||||
direction += 1;
|
direction -= 1;
|
||||||
if (phases & (1 << ((fptr->phase + 3) & 3)))
|
|
||||||
direction -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// apply magnet step, if any
|
// apply magnet step, if any
|
||||||
if (direction)
|
if (direction)
|
||||||
{
|
{
|
||||||
fptr->phase = MAX(0, MIN(79, fptr->phase + direction));
|
fptr->phase = MAX(0, MIN(79, fptr->phase + direction));
|
||||||
int newtrack = MIN(TRACKS-1, fptr->phase >> 1); // (round half tracks down)
|
int newtrack = MIN(TRACKS-1, fptr->phase >> 1); // (round half tracks down)
|
||||||
#ifndef _VC71
|
|
||||||
LOG_DISK("newtrack %2X%s\r", newtrack, (fptr->phase & 1) ? ".5" : "");
|
LOG_DISK("newtrack %2X%s\r", newtrack, (fptr->phase & 1) ? ".5" : "");
|
||||||
#endif
|
|
||||||
if (newtrack != fptr->track)
|
if (newtrack != fptr->track)
|
||||||
{
|
{
|
||||||
if (fptr->trackimage && fptr->trackimagedirty)
|
if (fptr->trackimage && fptr->trackimagedirty)
|
||||||
@ -518,14 +507,10 @@ static BYTE __stdcall DiskReadWrite (WORD programcounter, WORD, BYTE, BYTE, ULON
|
|||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
result = *(fptr->trackimage+fptr->byte);
|
result = *(fptr->trackimage+fptr->byte);
|
||||||
#if LOG_DISK_ENABLED
|
|
||||||
if (0)
|
if (0)
|
||||||
{
|
{
|
||||||
#ifndef _VC71
|
|
||||||
LOG_DISK("nib %4X = %2X\r", fptr->byte, result);
|
LOG_DISK("nib %4X = %2X\r", fptr->byte, result);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (++fptr->byte >= fptr->nibbles)
|
if (++fptr->byte >= fptr->nibbles)
|
||||||
fptr->byte = 0;
|
fptr->byte = 0;
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user