From 457cbafade0a833841fcc46eae96c3492690d810 Mon Sep 17 00:00:00 2001 From: Stephen White Date: Sun, 3 Jun 2018 17:45:17 +1000 Subject: [PATCH] Inlined some of the drive functions. --- src/Drive.cpp | 29 ----------------------------- src/Drive.h | 33 +++++++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/src/Drive.cpp b/src/Drive.cpp index 8ff7b6a..6df8aa9 100644 --- a/src/Drive.cpp +++ b/src/Drive.cpp @@ -386,35 +386,6 @@ void Drive::OnPortOut(void* pThis, unsigned char status) pDrive->LED = (status & 8) != 0; } -u32 Drive::AdvanceSectorPositionR(int& byteOffset) -{ - ++headBitOffset %= bitsInTrack; - byteOffset = headBitOffset >> 3; - return (~headBitOffset) & 7; -} - -u32 Drive::AdvanceSectorPositionW(int& byteOffset) -{ - byteOffset = headBitOffset >> 3; - u32 bit = (~headBitOffset) & 7; - ++headBitOffset %= bitsInTrack; - return bit; -} - -bool Drive::GetNextBit() -{ - int byteOffset; - int bit = AdvanceSectorPositionR(byteOffset); - return diskImage->GetNextBit(headTrackPos, byteOffset, bit); -} - -void Drive::SetNextBit(bool value) -{ - int byteOffset; - int bit = AdvanceSectorPositionW(byteOffset); - diskImage->SetBit(headTrackPos, byteOffset, bit, value); -} - bool Drive::Update() { bool dataReady = false; diff --git a/src/Drive.h b/src/Drive.h index db28eaf..1640358 100644 --- a/src/Drive.h +++ b/src/Drive.h @@ -88,10 +88,35 @@ private: void DumpTrack(unsigned track); // Used for debugging disk images. - u32 AdvanceSectorPositionR(int& byte_offset); // No reason why I seperate these into individual read and write versions. I was just trying to get the bit stream to line up when rewriting over existing data. - u32 AdvanceSectorPositionW(int& byte_offset); - bool GetNextBit(); - void SetNextBit(bool value); + // No reason why I seperate these into individual read and write versions. I was just trying to get the bit stream to line up when rewriting over existing data. + inline u32 AdvanceSectorPositionR(int& byteOffset) + { + ++headBitOffset %= bitsInTrack; + byteOffset = headBitOffset >> 3; + return (~headBitOffset) & 7; + } + + inline u32 AdvanceSectorPositionW(int& byteOffset) + { + byteOffset = headBitOffset >> 3; + u32 bit = (~headBitOffset) & 7; + ++headBitOffset %= bitsInTrack; + return bit; + } + + inline bool GetNextBit() + { + int byteOffset; + int bit = AdvanceSectorPositionR(byteOffset); + return diskImage->GetNextBit(headTrackPos, byteOffset, bit); + } + + inline void SetNextBit(bool value) + { + int byteOffset; + int bit = AdvanceSectorPositionW(byteOffset); + diskImage->SetBit(headTrackPos, byteOffset, bit, value); + } DiskImage* diskImage; // When swapping disks some code waits for the write protect signal to go high which will happen if a human ejects a disk.