loading programs
This commit is contained in:
parent
56b1e7e6ed
commit
b68f563dc6
1
TODO.md
1
TODO.md
|
@ -1,4 +1,3 @@
|
||||||
- make TinyFont hardware-default?
|
- make TinyFont hardware-default?
|
||||||
- break out PIA abstraction
|
- break out PIA abstraction
|
||||||
- loading programs from, e.g., http://www.brielcomputers.com/files/games.zip
|
|
||||||
- checkpoint and restore images (i.e., startrek)
|
- checkpoint and restore images (i.e., startrek)
|
||||||
|
|
17
apple1.ino
17
apple1.ino
|
@ -29,10 +29,16 @@ void status(const char *fmt, ...) {
|
||||||
jmp_buf ex;
|
jmp_buf ex;
|
||||||
r6502 cpu(&memory, &ex, status);
|
r6502 cpu(&memory, &ex, status);
|
||||||
bool halted = false;
|
bool halted = false;
|
||||||
|
const char *filename;
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
bool sd = hardware_reset();
|
bool sd = hardware_reset();
|
||||||
|
|
||||||
io.reset();
|
io.reset();
|
||||||
|
if (sd)
|
||||||
|
io.tape.start(PROGRAMS);
|
||||||
|
else
|
||||||
|
io.status("No SD Card");
|
||||||
|
|
||||||
halted = (setjmp(ex) != 0);
|
halted = (setjmp(ex) != 0);
|
||||||
}
|
}
|
||||||
|
@ -62,6 +68,17 @@ void loop() {
|
||||||
case PS2_F1:
|
case PS2_F1:
|
||||||
reset();
|
reset();
|
||||||
break;
|
break;
|
||||||
|
case PS2_F2:
|
||||||
|
filename = io.tape.advance();
|
||||||
|
io.status(filename);
|
||||||
|
break;
|
||||||
|
case PS2_F3:
|
||||||
|
filename = io.tape.rewind();
|
||||||
|
io.status(filename);
|
||||||
|
break;
|
||||||
|
case PS2_F4:
|
||||||
|
io.load();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
io.up(key);
|
io.up(key);
|
||||||
break;
|
break;
|
||||||
|
|
1
config.h
1
config.h
|
@ -6,5 +6,6 @@
|
||||||
|
|
||||||
#define TFT_FG VGA_LIME
|
#define TFT_FG VGA_LIME
|
||||||
#define TFT_BG VGA_BLACK
|
#define TFT_BG VGA_BLACK
|
||||||
|
#define PROGRAMS "/apple1/"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
35
io.cpp
35
io.cpp
|
@ -1,7 +1,9 @@
|
||||||
#include <UTFT.h>
|
#include <UTFT.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <utftdisplay.h>
|
#include <utftdisplay.h>
|
||||||
|
#include <sdtape.h>
|
||||||
#include <keyboard.h>
|
#include <keyboard.h>
|
||||||
|
#include <timed.h>
|
||||||
|
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -18,8 +20,7 @@ static char screen[ROWS][COLS];
|
||||||
#include "TinyFont.h"
|
#include "TinyFont.h"
|
||||||
|
|
||||||
void io::reset() {
|
void io::reset() {
|
||||||
utft.setFont((uint8_t *)TinyFont);
|
UTFTDisplay::begin(TFT_BG, TFT_FG, (uint8_t *)TinyFont);
|
||||||
UTFTDisplay::begin(TFT_BG, TFT_FG);
|
|
||||||
clear();
|
clear();
|
||||||
_cy += 2;
|
_cy += 2;
|
||||||
|
|
||||||
|
@ -28,11 +29,20 @@ void io::reset() {
|
||||||
for (int i = 0; i < COLS; i++)
|
for (int i = 0; i < COLS; i++)
|
||||||
screen[j][i] = ' ';
|
screen[j][i] = ' ';
|
||||||
|
|
||||||
|
_loading = false;
|
||||||
|
|
||||||
// PIA state
|
// PIA state
|
||||||
dsp_cr = kbd_cr = 0;
|
dsp_cr = kbd_cr = 0;
|
||||||
kbd_int = dsp_out = 0;
|
kbd_int = dsp_out = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void io::load() {
|
||||||
|
if (tape.more()) {
|
||||||
|
_loading = true;
|
||||||
|
enter(tape.read());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ascii map for scan-codes
|
// ascii map for scan-codes
|
||||||
static const byte scanmap[] = {
|
static const byte scanmap[] = {
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 0x00
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 0x00
|
||||||
|
@ -78,14 +88,17 @@ void io::down(byte scan) {
|
||||||
_shift = true;
|
_shift = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void io::enter(byte key) {
|
||||||
|
kbd = key + 0x80;
|
||||||
|
kbd_cr = 0xa7;
|
||||||
|
}
|
||||||
|
|
||||||
void io::up(byte scan) {
|
void io::up(byte scan) {
|
||||||
if (isshift(scan)) {
|
if (isshift(scan)) {
|
||||||
_shift = false;
|
_shift = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
byte m = _shift? shiftmap[scan]: scanmap[scan];
|
enter(_shift? shiftmap[scan]: scanmap[scan]);
|
||||||
kbd = m + 0x80;
|
|
||||||
kbd_cr = 0xa7;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void io::draw(char ch, int i, int j) {
|
void io::draw(char ch, int i, int j) {
|
||||||
|
@ -134,12 +147,10 @@ void io::display(byte b) {
|
||||||
|
|
||||||
void io::operator=(byte b) {
|
void io::operator=(byte b) {
|
||||||
|
|
||||||
/*
|
|
||||||
Serial.print(">");
|
Serial.print(">");
|
||||||
Serial.print(_acc, 16);
|
Serial.print(_acc, 16);
|
||||||
Serial.print(" ");
|
Serial.print(" ");
|
||||||
Serial.println(b, 16);
|
Serial.println(b, 16);
|
||||||
*/
|
|
||||||
|
|
||||||
switch(_acc % 4) {
|
switch(_acc % 4) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -170,22 +181,24 @@ io::operator byte() {
|
||||||
|
|
||||||
switch (_acc % 4) {
|
switch (_acc % 4) {
|
||||||
case 0:
|
case 0:
|
||||||
/*
|
|
||||||
Serial.print("<");
|
Serial.print("<");
|
||||||
Serial.print(_acc, 16);
|
Serial.print(_acc, 16);
|
||||||
Serial.print(" ");
|
Serial.print(" ");
|
||||||
Serial.println(kbd, 16);
|
Serial.println(kbd, 16);
|
||||||
*/
|
|
||||||
return kbd;
|
return kbd;
|
||||||
case 1:
|
case 1:
|
||||||
if (kbd_int && kbd_cr >= 0x80) {
|
if (kbd_int && kbd_cr >= 0x80) {
|
||||||
kbd_cr = 0;
|
kbd_cr = 0;
|
||||||
/*
|
|
||||||
Serial.print("<");
|
Serial.print("<");
|
||||||
Serial.print(_acc, 16);
|
Serial.print(_acc, 16);
|
||||||
Serial.print(" ");
|
Serial.print(" ");
|
||||||
Serial.println(0xa7, 16);
|
Serial.println(0xa7, 16);
|
||||||
*/
|
if (_loading) {
|
||||||
|
if (tape.more())
|
||||||
|
enter(tape.read());
|
||||||
|
else
|
||||||
|
_loading = false;
|
||||||
|
}
|
||||||
return 0xa7;
|
return 0xa7;
|
||||||
}
|
}
|
||||||
//Serial.println(kbd_cr, 16);
|
//Serial.println(kbd_cr, 16);
|
||||||
|
|
6
io.h
6
io.h
|
@ -1,7 +1,7 @@
|
||||||
#ifndef _IO_H
|
#ifndef _IO_H
|
||||||
#define _IO_H
|
#define _IO_H
|
||||||
|
|
||||||
class io: public UTFTDisplay, public Keyboard {
|
class io: public UTFTDisplay, Keyboard {
|
||||||
public:
|
public:
|
||||||
io(): UTFTDisplay(256) {}
|
io(): UTFTDisplay(256) {}
|
||||||
|
|
||||||
|
@ -15,11 +15,15 @@ public:
|
||||||
void checkpoint(Stream &);
|
void checkpoint(Stream &);
|
||||||
void restore(Stream &);
|
void restore(Stream &);
|
||||||
|
|
||||||
|
void load();
|
||||||
|
sdtape tape;
|
||||||
private:
|
private:
|
||||||
void display(byte);
|
void display(byte);
|
||||||
void draw(char, int, int);
|
void draw(char, int, int);
|
||||||
|
void enter(byte);
|
||||||
|
|
||||||
bool _shift;
|
bool _shift;
|
||||||
|
bool _loading;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue