mirror of
https://github.com/cmosher01/Epple-II.git
synced 2025-01-09 10:29:45 +00:00
use optimal bit timing from WOZ file during reading: thanks to STiVo
This commit is contained in:
parent
f310bae003
commit
06bc38c8be
@ -85,8 +85,7 @@ unsigned char DiskController::io(const unsigned short addr, const unsigned char
|
||||
* (When the motor is on, that is.)
|
||||
*/
|
||||
void DiskController::tick() {
|
||||
this->drive1.tick();
|
||||
this->drive2.tick();
|
||||
this->currentDrive->tick();
|
||||
|
||||
if (this->ioStepped) { // if we already ran it, above in io(), skip here
|
||||
this->ioStepped = false;
|
||||
@ -105,21 +104,24 @@ void DiskController::tick() {
|
||||
* then inject the next bit and subtract the optimal bit timing from your bit timing clock.
|
||||
* That will give you 125ns resolution on your bits being fed to the sequencer.
|
||||
*/
|
||||
rotateCurrentDisk();
|
||||
|
||||
// run two LSS cycles = 2MHz
|
||||
|
||||
rotateCurrentDisk();
|
||||
stepLss();
|
||||
|
||||
// pulse lasts only 500 nanoseconds (1 LSS clock cycle), so clear it now:
|
||||
this->currentDrive->clearPulse();
|
||||
|
||||
rotateCurrentDisk();
|
||||
stepLss();
|
||||
}
|
||||
|
||||
void DiskController::rotateCurrentDisk() {
|
||||
++this->t;
|
||||
if (4 <= this->t) { // 4us interval between bits
|
||||
this->t += 1.0f;
|
||||
if (this->currentDrive->optimal_timing()/4.0f <= this->t) { // 4us interval between bits
|
||||
this->currentDrive->rotateDiskOneBit(); // (will also generate a read-pulse when it reads a 1-bit)
|
||||
this->t = 0;
|
||||
this->t -= this->currentDrive->optimal_timing()/4.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ private:
|
||||
// On the real Apple the read pulse goes thru this LS174 too, but we don't emulate that here.
|
||||
|
||||
std::uint8_t prev_seq; // remember previous seq, to determine if A7 changes (indicating write a 1 bit)
|
||||
std::uint8_t t; // used to keep track of 4 MPU cycles
|
||||
double t; // used to keep track of optimal bit timing interval
|
||||
|
||||
// TODO for a rev. 0 motherboard, the disk controller will auto reset the CPU (see UA2, 9-13)
|
||||
|
||||
|
@ -47,6 +47,10 @@ bool Disk2Drive::isModified() const {
|
||||
return this->disk.isModified();
|
||||
}
|
||||
|
||||
int Disk2Drive::optimal_timing() const {
|
||||
return this->disk.optimal_timing();
|
||||
}
|
||||
|
||||
int Disk2Drive::position() const {
|
||||
return this->head.position();
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
void saveDisk();
|
||||
bool isWriteProtected() const;
|
||||
bool isModified() const;
|
||||
int optimal_timing() const;
|
||||
int position() const;
|
||||
void tick();
|
||||
void set_phase(int i_phase_0_to_3, bool on);
|
||||
|
@ -134,6 +134,13 @@ public:
|
||||
bool getBit(std::uint8_t currentQuarterTrack);
|
||||
void setBit(std::uint8_t currentQuarterTrack, bool on);
|
||||
void rawSet();
|
||||
|
||||
int optimal_timing() const {
|
||||
if (this->loaded) {
|
||||
return this->timing;
|
||||
}
|
||||
return 32;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // WOZFILE_H
|
||||
|
Loading…
Reference in New Issue
Block a user