From db9de4bddea1d2be83cc83a79379db6c37683181 Mon Sep 17 00:00:00 2001 From: Stephen Crane Date: Tue, 14 Aug 2018 11:00:03 +0100 Subject: [PATCH] update --- io.cpp | 18 +++++++++--------- io.h | 12 ++++++------ pia.cpp | 8 +++++--- pia.h | 24 ++++++++++++------------ 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/io.cpp b/io.cpp index 7024558..0dd42cf 100644 --- a/io.cpp +++ b/io.cpp @@ -37,7 +37,7 @@ void io::load() { } // ascii map for scan-codes -static const byte scanmap[] = { +static const uint8_t scanmap[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 0x00 0xff, 0xff, 0xff, 0xff, 0xff, 0x09, 0x60, 0xff, // 0x08 0xff, 0xff, 0xff, 0xff, 0xff, 0x51, 0x31, 0xff, // 0x10 @@ -56,7 +56,7 @@ static const byte scanmap[] = { 0xff, 0x2b, 0x33, 0x2d, 0x2a, 0x39, 0xff, 0xff, // 0x78 }; -static const byte shiftmap[] = { +static const uint8_t shiftmap[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 0x00 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 0x08 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x21, 0xff, // 0x10 @@ -75,17 +75,17 @@ static const byte shiftmap[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 0x78 }; -void io::down(byte scan) { +void io::down(uint8_t scan) { set_porta(0); if (isshift(scan)) _shift = true; } -void io::enter(byte key) { +void io::enter(uint8_t key) { set_porta(key + 0x80); } -void io::up(byte scan) { +void io::up(uint8_t scan) { if (isshift(scan)) { _shift = false; return; @@ -101,7 +101,7 @@ void io::draw(char ch, int i, int j) { } } -void io::display(byte b) { +void io::display(uint8_t b) { char ch = (char)b; switch(ch) { case 0x5f: @@ -137,14 +137,14 @@ void io::display(byte b) { draw('_', c, r); } -void io::write_portb(byte b) { +void io::write_portb(uint8_t b) { b &= 0x7f; display(b); pia::write_portb(b); } -byte io::read_porta_cr() { - byte b = pia::read_porta_cr(); +uint8_t io::read_porta_cr() { + uint8_t b = pia::read_porta_cr(); if (b != 0xa7) return b; diff --git a/io.h b/io.h index eec145c..7f3396e 100644 --- a/io.h +++ b/io.h @@ -5,21 +5,21 @@ class io: public UTFTDisplay, Keyboard, public pia { public: virtual void reset(); - virtual void down(byte scan); - virtual void up(byte scan); + virtual void down(uint8_t scan); + virtual void up(uint8_t scan); virtual void checkpoint(Stream &); virtual void restore(Stream &); - virtual void write_portb(byte); - virtual byte read_porta_cr(); + virtual void write_portb(uint8_t); + virtual uint8_t read_porta_cr(); void load(); sdtape tape; private: - void display(byte); + void display(uint8_t); void draw(char, int, int); - void enter(byte); + void enter(uint8_t); bool _shift; bool _loading; diff --git a/pia.cpp b/pia.cpp index 9ede66e..063da6f 100644 --- a/pia.cpp +++ b/pia.cpp @@ -1,13 +1,15 @@ -#include +#include #include #include "pia.h" -void pia::operator=(byte b) { +void pia::operator=(uint8_t b) { +/* Serial.print(millis()); Serial.print(" > "); Serial.print(_acc, 16); Serial.print(' '); Serial.println(b, 16); +*/ switch(_acc % 4) { case 0: write_porta(b); @@ -24,7 +26,7 @@ Serial.println(b, 16); } } -pia::operator byte() { +pia::operator uint8_t() { /* Serial.print(millis()); Serial.print(" < "); diff --git a/pia.h b/pia.h index 975b25f..1818429 100644 --- a/pia.h +++ b/pia.h @@ -6,46 +6,46 @@ public: pia(): Memory::Device(256), portb_cr(0), porta_cr(0) {} virtual void reset() { portb_cr = porta_cr = 0; } - void operator=(byte); - operator byte(); + void operator=(uint8_t); + operator uint8_t(); void checkpoint(Stream &); void restore(Stream &); protected: // write to the "external" side of the port - void set_porta(byte b) { + void set_porta(uint8_t b) { porta = b; if (b & 0x80) porta_cr = 0xa7; } // "device-side" operations (called from memory interface) - byte read_porta() { return porta; } - virtual byte read_porta_cr() { + uint8_t read_porta() { return porta; } + virtual uint8_t read_porta_cr() { if (porta_cr & 0x80) { porta_cr = 0; return 0xa7; } return porta_cr; } - byte read_portb() { return portb; } - byte read_portb_cr() { return portb_cr; } + uint8_t read_portb() { return portb; } + uint8_t read_portb_cr() { return portb_cr; } - void write_porta(byte b) { porta = b; } - void write_porta_cr(byte b) { + void write_porta(uint8_t b) { porta = b; } + void write_porta_cr(uint8_t b) { if (!(porta_cr & 0x80) && b >= 0x80) porta_cr |= 0x80; else porta_cr = b; } - virtual void write_portb(byte b) { portb = b; } - void write_portb_cr(byte b) { + virtual void write_portb(uint8_t b) { portb = b; } + void write_portb_cr(uint8_t b) { if (portb_cr < 0x80) portb_cr = b; } private: - byte portb_cr, portb, porta_cr, porta; + uint8_t portb_cr, portb, porta_cr, porta; }; #endif