1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-09-27 18:55:48 +00:00

Mildly increased work in here, still primarily oriented towards logging what I actually need to get done.

This commit is contained in:
Thomas Harte 2017-08-05 22:26:59 -04:00
parent 4d60b8801c
commit 25fd3f7e50
2 changed files with 77 additions and 2 deletions

View File

@ -8,11 +8,82 @@
#include "i8272.hpp"
#include <cstdio>
using namespace Intel;
void i8272::set_register(int address, uint8_t value) {
if(!address) return;
// TODO: if not accepting commands, return
command_.push_back(value);
size_t necessary_length;
switch(command_[0] & 0x1f) {
case 0x06: // read data
necessary_length = 9;
break;
case 0x0b: // read deleted data
necessary_length = 9;
break;
case 0x05: // write data
necessary_length = 9;
break;
case 0x09: // write deleted data
necessary_length = 9;
break;
case 0x02: // read track
necessary_length = 9;
break;
case 0x0a: // read ID
necessary_length = 2;
break;
case 0x0d: // format track
necessary_length = 6;
break;
case 0x11: // scan low
necessary_length = 9;
break;
case 0x19: // scan low or equal
necessary_length = 9;
break;
case 0x1d: // scan high or equal
necessary_length = 9;
break;
case 0x07: // recalibrate
necessary_length = 2;
break;
case 0x08: // sense interrupt status
necessary_length = 1;
break;
case 0x03: // specify
necessary_length = 3;
break;
case 0x04: // sense drive status
necessary_length = 2;
break;
case 0x0f: // seek
necessary_length = 3;
break;
default: // invalid
necessary_length = 1;
break;
}
printf("8272 set register %d to %02x\n", address, value);
if(command_.size() == necessary_length) {
printf("8272 Perform!\n");
command_.clear();
}
}
uint8_t i8272::get_register(int address) {
return 0xff;
if(address) {
printf("8272 get data\n");
return 0xff;
} else {
printf("8272 get status\n");
return 0x80;
}
}

View File

@ -10,14 +10,18 @@
#define i8272_hpp
#include <cstdint>
#include <vector>
namespace Intel {
class i8272 {
public:
void set_register(int address, uint8_t value);
uint8_t get_register(int address);
private:
uint8_t status_;
std::vector<uint8_t> command_;
};
}