-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpm80.ino
79 lines (59 loc) · 1.19 KB
/
cpm80.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <stdarg.h>
#include <SPI.h>
#include <r65emu.h>
#include <ports.h>
#include "config.h"
#include PROCESSOR_H
#include "screen.h"
#include "io.h"
#if defined(PS2_SERIAL_KBD)
ps2_serial_kbd kbd;
#else
hw_serial_kbd kbd(Serial);
#endif
#if defined(SCREEN_SERIAL_DSP)
screen dsp;
#else
hw_serial_dsp dsp(Serial);
#endif
#include "banked_memory.h"
BankedMemory memory;
IO io(memory, kbd, dsp);
processor_t cpu(memory, io);
#if defined(BRAM_PAGES)
ram<> boot[BRAM_PAGES];
#endif
#if defined(RAM_PAGES)
ram<> pages[RAM_PAGES];
#endif
void reset(void) {
bool disk = hardware_reset();
if (disk)
io.reset();
else
DBG(println(F("Disk initialisation failed")));
cpu.reset();
}
void function_key(uint8_t fn) {
if (fn == 1)
reset();
else if (fn == 10)
hardware_debug_cpu();
}
void setup(void) {
hardware_init(cpu);
#if defined(BRAM_PAGES)
for (unsigned i = 0; i < BRAM_PAGES; i++)
memory.put(boot[i], BRAM_BASE + 1024*i);
#endif
#if defined(USE_SPIRAM)
memory.put(sram, SPIRAM_BASE, SPIRAM_EXTENT);
#endif
for (unsigned i = 0; i < RAM_PAGES; i++)
memory.put(pages[i], RAM_BASE + 1024*i);
kbd.register_fnkey_handler(function_key);
reset();
}
void loop(void) {
hardware_run();
}