implement LSS writing (to WOZ TRKS in memory)

This commit is contained in:
Christopher A. Mosher 2018-12-19 23:52:21 -05:00
parent 69512a4c05
commit 23a1e64e9f
3 changed files with 12 additions and 7 deletions

View File

@ -90,8 +90,11 @@ void DiskController::tick() {
rotateCurrentDisk();
// run two LSS cycles = 2MHz
stepLss();
// pulse lasts only 500 nanoseconds (1 LSS clock cycle), so clear it now:
this->currentDrive->clearPulse();
stepLss();
}
@ -109,8 +112,14 @@ void DiskController::stepLss() {
this->seq = cmd & 0xF0u;
// LSS command functions (UA2, 9-15, Table 9.3)
// printf("%02x:", cmd);
if (cmd & 8u) {
if (cmd & 3u) {
if (this->write) {
const bool one = (seq&0x80u) != (this->prev_seq&0x80u);
this->prev_seq = seq;
this->currentDrive->writeBit(one);
}
}
switch (cmd & 3u) {
case 3:
this->dataRegister = this->dataBusReadOnlyCopy;
@ -118,15 +127,10 @@ void DiskController::stepLss() {
case 2:
this->dataRegister >>= 1;
this->dataRegister |= (isWriteProtected() << 7);
// TODO how to handle writing?
break;
case 1:
this->dataRegister <<= 1;
this->dataRegister |= ((cmd & 4u) >> 2);
// printf(this->dataRegister & 0x80u ? "\x1b[30;42m" : "\x1b[30;43m");
// printf("%02X\x1b[0m ", this->dataRegister);
// if (this->dataRegister & 0x80u) printf("\n");
// TODO how to handle writing?
break;
}
} else {

View File

@ -58,6 +58,7 @@ private:
// For ease of use, we store the 4-bit seq number in the _high order_ nibble here.
// 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
// TODO for a rev. 0 motherboard, the disk controller will auto reset the CPU (see UA2, 9-13)

View File

@ -254,7 +254,7 @@ static std::uint8_t cb(std::uint8_t bit) {
/*
* Rotate the floppy disk by one bit.
* In real life we don't care what track we're one, but for the
* In real life we don't care what track we're on, but for the
* emulator we need to know. This is because the tracks within the
* WOZ file could be different lengths. So in order to know when
* we need to loop back to the beginning of the track (circular