mirror of
https://github.com/jscrane/Apple1.git
synced 2025-02-25 16:28:59 +00:00
SimpleTimer + more (#12)
This commit is contained in:
parent
9c20f5f15b
commit
c89018940b
4
Makefile
4
Makefile
@ -2,7 +2,7 @@ t ?= esp32
|
|||||||
|
|
||||||
TERMINAL_SPEED := 115200
|
TERMINAL_SPEED := 115200
|
||||||
CPPFLAGS = -Wall -DDEBUGGING -DCPU_DEBUG=false -DTERMINAL_SPEED=$(TERMINAL_SPEED) -DUSE_OWN_KBD
|
CPPFLAGS = -Wall -DDEBUGGING -DCPU_DEBUG=false -DTERMINAL_SPEED=$(TERMINAL_SPEED) -DUSE_OWN_KBD
|
||||||
LIBRARIES = PS2KeyAdvanced PS2KeyMap
|
LIBRARIES = PS2KeyAdvanced PS2KeyMap SimpleTimer
|
||||||
|
|
||||||
ifeq ($t, esp8266)
|
ifeq ($t, esp8266)
|
||||||
BOARD := d1_mini
|
BOARD := d1_mini
|
||||||
@ -11,7 +11,7 @@ EESZ := 4M1M
|
|||||||
F_CPU := 80
|
F_CPU := 80
|
||||||
CPPFLAGS += -DUSER_SETUP_LOADED -DILI9341_DRIVER -DTFT_CS=PIN_D8 -DTFT_DC=PIN_D1 \
|
CPPFLAGS += -DUSER_SETUP_LOADED -DILI9341_DRIVER -DTFT_CS=PIN_D8 -DTFT_DC=PIN_D1 \
|
||||||
-DTFT_RST=-1 -DSPI_FREQUENCY=40000000 -DLOAD_GLCD \
|
-DTFT_RST=-1 -DSPI_FREQUENCY=40000000 -DLOAD_GLCD \
|
||||||
-DHARDWARE_H=\"hw/esp8bit.h\" -DPS2_SERIAL_KBD=\"UK\"
|
-DHARDWARE_H=\"hw/esp8bit.h\"
|
||||||
LIBRARIES += TFT_eSPI SpiRAM LittleFS
|
LIBRARIES += TFT_eSPI SpiRAM LittleFS
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
34
io.cpp
34
io.cpp
@ -6,23 +6,24 @@
|
|||||||
#include <serial_kbd.h>
|
#include <serial_kbd.h>
|
||||||
#include <serial_dsp.h>
|
#include <serial_dsp.h>
|
||||||
#include <pia.h>
|
#include <pia.h>
|
||||||
#include <timed.h>
|
#include <hardware.h>
|
||||||
|
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "disp.h"
|
#include "disp.h"
|
||||||
#include "hardware.h"
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
void io::reset() {
|
void io::reset() {
|
||||||
|
_loading = false;
|
||||||
_dsp.reset();
|
_dsp.reset();
|
||||||
_kbd.reset();
|
_kbd.reset();
|
||||||
|
_pia.reset();
|
||||||
_loading = false;
|
_ch = 0;
|
||||||
PIA::reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool io::start() {
|
bool io::start() {
|
||||||
|
hardware_interval_timer(10, [this]() { poll(); });
|
||||||
|
_pia.register_portb_write_handler([this](uint8_t b) { _dsp.write(b & 0x7f); });
|
||||||
|
_pia.register_porta_read_handler([this]() { uint8_t c = _ch; _ch = 0; return c; });
|
||||||
return files.start();
|
return files.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,18 +35,15 @@ void io::load() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void io::enter(uint8_t key) {
|
void io::enter(uint8_t key) {
|
||||||
PIA::write_ca1(false);
|
_pia.write_ca1(false);
|
||||||
PIA::write_porta_in(key + 0x80);
|
_ch = key | 0x80;
|
||||||
PIA::write_ca1(true);
|
_pia.write_ca1(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void io::write_portb(uint8_t b) {
|
void io::poll() {
|
||||||
b &= 0x7f;
|
if (_ch)
|
||||||
_dsp.write(b);
|
return;
|
||||||
PIA::write_portb(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t io::read_cra() {
|
|
||||||
if (_loading) {
|
if (_loading) {
|
||||||
if (files.more())
|
if (files.more())
|
||||||
enter(files.read());
|
enter(files.read());
|
||||||
@ -56,16 +54,14 @@ uint8_t io::read_cra() {
|
|||||||
if (c != -1)
|
if (c != -1)
|
||||||
enter(c);
|
enter(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
return PIA::read_cra();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void io::checkpoint(Stream &s) {
|
void io::checkpoint(Stream &s) {
|
||||||
PIA::checkpoint(s);
|
_pia.checkpoint(s);
|
||||||
_dsp.checkpoint(s);
|
_dsp.checkpoint(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void io::restore(Stream &s) {
|
void io::restore(Stream &s) {
|
||||||
PIA::restore(s);
|
_pia.restore(s);
|
||||||
_dsp.restore(s);
|
_dsp.restore(s);
|
||||||
}
|
}
|
||||||
|
17
io.h
17
io.h
@ -1,10 +1,9 @@
|
|||||||
#ifndef _IO_H
|
#pragma once
|
||||||
#define _IO_H
|
|
||||||
|
|
||||||
class serial_kbd;
|
class serial_kbd;
|
||||||
class disp;
|
class disp;
|
||||||
|
|
||||||
class io: public Memory::Device, public PIA {
|
class io: public Memory::Device {
|
||||||
public:
|
public:
|
||||||
io(filer &files, serial_kbd &kbd, disp &dsp):
|
io(filer &files, serial_kbd &kbd, disp &dsp):
|
||||||
Memory::Device(Memory::page_size), files(files), _kbd(kbd), _dsp(dsp) {}
|
Memory::Device(Memory::page_size), files(files), _kbd(kbd), _dsp(dsp) {}
|
||||||
@ -12,24 +11,22 @@ public:
|
|||||||
void reset();
|
void reset();
|
||||||
bool start();
|
bool start();
|
||||||
|
|
||||||
void operator=(uint8_t b) { PIA::write(_acc, b); }
|
void operator=(uint8_t b) { _pia.write(_acc, b); }
|
||||||
operator uint8_t() { return PIA::read(_acc); }
|
operator uint8_t() { return _pia.read(_acc); }
|
||||||
|
|
||||||
void checkpoint(Stream &);
|
void checkpoint(Stream &);
|
||||||
void restore(Stream &);
|
void restore(Stream &);
|
||||||
|
|
||||||
void write_portb(uint8_t);
|
void poll();
|
||||||
uint8_t read_cra();
|
|
||||||
|
|
||||||
void load();
|
void load();
|
||||||
filer &files;
|
filer &files;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
PIA _pia;
|
||||||
serial_kbd &_kbd;
|
serial_kbd &_kbd;
|
||||||
disp &_dsp;
|
disp &_dsp;
|
||||||
|
|
||||||
void enter(uint8_t);
|
void enter(uint8_t);
|
||||||
bool _loading;
|
bool _loading;
|
||||||
|
uint8_t _ch;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -2,29 +2,23 @@
|
|||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <display.h>
|
#include <display.h>
|
||||||
#include <serial_dsp.h>
|
#include <serial_dsp.h>
|
||||||
#include <timed.h>
|
|
||||||
#include <hardware.h>
|
#include <hardware.h>
|
||||||
|
|
||||||
#include "disp.h"
|
#include "disp.h"
|
||||||
#include "screen_disp.h"
|
#include "screen_disp.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
static screen_disp *i;
|
|
||||||
|
|
||||||
const int TICK_FREQ = 2;
|
|
||||||
|
|
||||||
void IRAM_ATTR screen_disp::on_tick() {
|
|
||||||
|
|
||||||
static int tick = 0;
|
|
||||||
tick = (tick + 1) % 3;
|
|
||||||
i->cursor(tick < 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void screen_disp::reset() {
|
void screen_disp::reset() {
|
||||||
|
|
||||||
if (!i) {
|
static bool first_time = true;
|
||||||
i = this;
|
|
||||||
timer_create(TICK_FREQ, on_tick);
|
if (first_time) {
|
||||||
|
hardware_interval_timer(500, [this]() {
|
||||||
|
static int tick = 0;
|
||||||
|
tick = (tick + 1) % 3;
|
||||||
|
cursor(tick < 2);
|
||||||
|
});
|
||||||
|
first_time = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Display::begin(BG_COLOUR, FG_COLOUR, ORIENT);
|
Display::begin(BG_COLOUR, FG_COLOUR, ORIENT);
|
||||||
|
@ -11,12 +11,8 @@ public:
|
|||||||
void write(uint8_t);
|
void write(uint8_t);
|
||||||
void status(const char *s) { Display::status(s); }
|
void status(const char *s) { Display::status(s); }
|
||||||
|
|
||||||
protected:
|
|
||||||
static void on_tick();
|
|
||||||
|
|
||||||
void cursor(bool on);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void cursor(bool on);
|
||||||
void draw(char, int, int);
|
void draw(char, int, int);
|
||||||
|
|
||||||
static const uint8_t ROWS = 24;
|
static const uint8_t ROWS = 24;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user