mirror of
https://github.com/cmosher01/Epple-II.git
synced 2024-09-27 07:54:58 +00:00
fix random bit generation if no disk or no track
This commit is contained in:
parent
b6b2fde6ea
commit
55a43d19f0
@ -72,8 +72,13 @@ void Disk2Drive::rotateDiskOneBit() {
|
||||
this->disk.rotateOneBit(this->head.position());
|
||||
|
||||
bitBufferRead <<= 1;
|
||||
bitBufferRead |= this->disk.getBit(this->head.position());
|
||||
if (bitBufferRead & 0x0Fu) {
|
||||
|
||||
const bool exists(this->disk.exists(this->head.position()));
|
||||
if (exists) {
|
||||
bitBufferRead |= this->disk.getBit(this->head.position());
|
||||
}
|
||||
|
||||
if ((bitBufferRead & 0x0Fu) && exists) {
|
||||
this->pulse = (bitBufferRead & 0x02u) >> 1;
|
||||
} else {
|
||||
this->pulse = randomBit();
|
||||
|
@ -533,19 +533,11 @@ void WozFile::rotateOneBit(std::uint8_t currentQuarterTrack) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool WozFile::exists(std::uint8_t currentQuarterTrack) {
|
||||
return isLoaded() && (this->tmap[currentQuarterTrack] != 0xFFu);
|
||||
}
|
||||
|
||||
bool WozFile::getBit(std::uint8_t currentQuarterTrack) {
|
||||
if (!isLoaded()) {
|
||||
// printf("No disk to read from; will generate random data.\n");
|
||||
return false; // there's no disk, so no pulse
|
||||
}
|
||||
|
||||
if (this->tmap[currentQuarterTrack] == 0xFFu) {
|
||||
// printf("Reading from uninitialized track; will generate random data.\n");
|
||||
return false; // empty track
|
||||
}
|
||||
|
||||
return this->trk[this->tmap[currentQuarterTrack]][this->byt] & this->bit;
|
||||
}
|
||||
|
||||
|
@ -131,6 +131,7 @@ public:
|
||||
}
|
||||
|
||||
void rotateOneBit(std::uint8_t currentQuarterTrack);
|
||||
bool exists(std::uint8_t currentQuarterTrack);
|
||||
bool getBit(std::uint8_t currentQuarterTrack);
|
||||
void setBit(std::uint8_t currentQuarterTrack, bool on);
|
||||
void rawSet();
|
||||
|
Loading…
Reference in New Issue
Block a user