PIA cleanup
This commit is contained in:
parent
c129e717d8
commit
ee452e816e
10
io.cpp
10
io.cpp
|
@ -28,7 +28,7 @@ void io::reset() {
|
|||
screen[j][i] = ' ';
|
||||
|
||||
_loading = false;
|
||||
pia::reset();
|
||||
PIA::reset();
|
||||
}
|
||||
|
||||
void io::load() {
|
||||
|
@ -142,11 +142,11 @@ void io::display(uint8_t b) {
|
|||
void io::write_portb(uint8_t b) {
|
||||
b &= 0x7f;
|
||||
display(b);
|
||||
pia::write_portb(b);
|
||||
PIA::write_portb(b);
|
||||
}
|
||||
|
||||
uint8_t io::read_porta_cr() {
|
||||
uint8_t b = pia::read_porta_cr();
|
||||
uint8_t b = PIA::read_porta_cr();
|
||||
if (b != 0xa7)
|
||||
return b;
|
||||
|
||||
|
@ -160,7 +160,7 @@ uint8_t io::read_porta_cr() {
|
|||
}
|
||||
|
||||
void io::checkpoint(Stream &s) {
|
||||
pia::checkpoint(s);
|
||||
PIA::checkpoint(s);
|
||||
s.write(r);
|
||||
s.write(c);
|
||||
for (int j = 0; j < ROWS; j++)
|
||||
|
@ -169,7 +169,7 @@ void io::checkpoint(Stream &s) {
|
|||
}
|
||||
|
||||
void io::restore(Stream &s) {
|
||||
pia::restore(s);
|
||||
PIA::restore(s);
|
||||
r = s.read();
|
||||
c = s.read();
|
||||
for (int j = 0; j < ROWS; j++)
|
||||
|
|
8
io.h
8
io.h
|
@ -1,15 +1,17 @@
|
|||
#ifndef _IO_H
|
||||
#define _IO_H
|
||||
|
||||
// http://mamedev.org/source/src/mess/machine/apple1.c.html
|
||||
class io: public Display, Keyboard, public pia {
|
||||
class io: public Memory::Device, public Display, Keyboard, public PIA {
|
||||
public:
|
||||
io(filer &files): files(files) {}
|
||||
io(filer &files): Memory::Device(Memory::page_size), files(files) {}
|
||||
|
||||
virtual void reset();
|
||||
virtual void down(uint8_t scan);
|
||||
virtual void up(uint8_t scan);
|
||||
|
||||
virtual void operator=(uint8_t b) { PIA::write(_acc, b); }
|
||||
virtual operator uint8_t() { return PIA::read(_acc); }
|
||||
|
||||
virtual void checkpoint(Stream &);
|
||||
virtual void restore(Stream &);
|
||||
|
||||
|
|
17
pia.cpp
17
pia.cpp
|
@ -2,15 +2,15 @@
|
|||
#include <memory.h>
|
||||
#include "pia.h"
|
||||
|
||||
void pia::operator=(uint8_t b) {
|
||||
void PIA::write(Memory::address a, uint8_t b) {
|
||||
#if defined(DEBUGGING)
|
||||
Serial.print(millis());
|
||||
Serial.print(" > ");
|
||||
Serial.print(_acc, 16);
|
||||
Serial.print(a, 16);
|
||||
Serial.print(' ');
|
||||
Serial.println(b, 16);
|
||||
#endif
|
||||
switch(_acc % 4) {
|
||||
switch(a % 4) {
|
||||
case 0:
|
||||
write_porta(b);
|
||||
break;
|
||||
|
@ -26,13 +26,13 @@ void pia::operator=(uint8_t b) {
|
|||
}
|
||||
}
|
||||
|
||||
pia::operator uint8_t() {
|
||||
uint8_t PIA::read(Memory::address a) {
|
||||
#if defined(DEBUGGING)
|
||||
Serial.print(millis());
|
||||
Serial.print(" < ");
|
||||
Serial.println(_acc, 16);
|
||||
Serial.println(a, 16);
|
||||
#endif
|
||||
switch (_acc % 4) {
|
||||
switch (a % 4) {
|
||||
case 0:
|
||||
return read_porta();
|
||||
case 1:
|
||||
|
@ -45,17 +45,16 @@ pia::operator uint8_t() {
|
|||
return 0xff;
|
||||
}
|
||||
|
||||
void pia::checkpoint(Stream &s) {
|
||||
void PIA::checkpoint(Stream &s) {
|
||||
s.write(portb_cr);
|
||||
s.write(portb);
|
||||
s.write(porta_cr);
|
||||
s.write(porta);
|
||||
}
|
||||
|
||||
void pia::restore(Stream &s) {
|
||||
void PIA::restore(Stream &s) {
|
||||
portb_cr = s.read();
|
||||
portb = s.read();
|
||||
porta_cr = s.read();
|
||||
porta = s.read();
|
||||
}
|
||||
|
||||
|
|
9
pia.h
9
pia.h
|
@ -1,13 +1,14 @@
|
|||
#ifndef __PIA_H__
|
||||
#define __PIA_H__
|
||||
|
||||
class pia: public Memory::Device {
|
||||
// https://en.wikipedia.org/wiki/Peripheral_Interface_Adapter
|
||||
class PIA {
|
||||
public:
|
||||
pia(): Memory::Device(256), portb_cr(0), porta_cr(0) {}
|
||||
PIA(): portb_cr(0), porta_cr(0) {}
|
||||
virtual void reset() { portb_cr = porta_cr = 0; }
|
||||
|
||||
void operator=(uint8_t);
|
||||
operator uint8_t();
|
||||
void write(Memory::address, uint8_t);
|
||||
uint8_t read(Memory::address);
|
||||
|
||||
void checkpoint(Stream &);
|
||||
void restore(Stream &);
|
||||
|
|
Loading…
Reference in New Issue