mirror of
https://github.com/jscrane/Apple1.git
synced 2024-11-22 21:33:01 +00:00
checkpointing io state
This commit is contained in:
parent
a37eaee362
commit
8cc440325c
10
apple1.ino
10
apple1.ino
@ -64,7 +64,7 @@ void loop() {
|
||||
unsigned key = ps2.read();
|
||||
if (!ps2.isbreak())
|
||||
io.down(key);
|
||||
else {
|
||||
else
|
||||
switch (key) {
|
||||
case PS2_F1:
|
||||
reset();
|
||||
@ -80,11 +80,17 @@ void loop() {
|
||||
case PS2_F4:
|
||||
io.load();
|
||||
break;
|
||||
case PS2_F6:
|
||||
io.status(checkpoint(io.tape, PROGRAMS));
|
||||
break;
|
||||
case PS2_F7:
|
||||
if (filename)
|
||||
restore(io.tape, PROGRAMS, filename);
|
||||
break;
|
||||
default:
|
||||
io.up(key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (!halted)
|
||||
cpu.run(CPU_INSTRUCTIONS);
|
||||
}
|
||||
|
26
io.cpp
26
io.cpp
@ -228,7 +228,33 @@ Serial.println(dsp_cr, 16);
|
||||
}
|
||||
|
||||
void io::checkpoint(Stream &s) {
|
||||
s.write(dsp_cr);
|
||||
s.write(dsp);
|
||||
s.write(kbd_cr);
|
||||
s.write(kbd);
|
||||
s.write(kbd_int);
|
||||
s.write(dsp_out);
|
||||
s.write(r);
|
||||
s.write(c);
|
||||
for (int j = 0; j < ROWS; j++)
|
||||
for (int i = 0; i < COLS; i++)
|
||||
s.write(screen[j][i]);
|
||||
}
|
||||
|
||||
void io::restore(Stream &s) {
|
||||
dsp_cr = s.read();
|
||||
dsp = s.read();
|
||||
kbd_cr = s.read();
|
||||
kbd = s.read();
|
||||
kbd_int = s.read();
|
||||
dsp_out = s.read();
|
||||
r = s.read();
|
||||
c = s.read();
|
||||
for (int j = 0; j < ROWS; j++)
|
||||
for (int i = 0; i < COLS; i++) {
|
||||
char c = s.read();
|
||||
screen[j][i] = c;
|
||||
draw(c, i, j);
|
||||
}
|
||||
draw('_', c, r);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user