-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheCPM.ino
More file actions
139 lines (115 loc) · 2.59 KB
/
eCPM.ino
File metadata and controls
139 lines (115 loc) · 2.59 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/**
Embedded CP/M Machine
Copyright (C) 2020 Costin STROIE <costinstroie@eridu.eu.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <SPI.h>
#include <SD.h>
// Configuration
#include "config.h"
// Global parameters
#include "global.h"
#ifdef SPI_RAM
# include "spiram.h"
#else
# include "mcuram.h"
#endif
#include "i8080.h"
#include "bios.h"
#include "bdos.h"
// Some declarations
uint8_t callBDOS(int port);
void callBIOS(int port, int value);
#ifdef SPI_RAM
// SPI RAM
SPIRAM ram(RS, RAM_BUFFER_SIZE);
#else
// MCU RAM
MCURAM ram;
#endif
int I8080::read_word(int addr) {
return ram.getWord(addr);
}
void I8080::write_word(int addr, int word) {
return ram.setWord(addr, word);
}
int I8080::read_byte(int addr) {
return ram.getByte(addr);
}
void I8080::write_byte(int addr, int byte) {
ram.setByte(addr, byte);
}
int I8080::io_input(int port) {
return callBDOS(port);
}
void I8080::io_output(int port, int value) {
callBIOS(port, value);
}
void I8080::iff(int on) {
state = 0;
}
I8080 cpu;
DRIVE drv(&ram, "eCPM");
BIOS bios(&cpu, &ram, &drv);
BDOS bdos(&cpu, &ram, &drv, &bios);
void callBIOS(int port, int value) {
bios.call(port);
}
uint8_t callBDOS(int port) {
return bdos.call(port);
}
/**
Main Arduino setup function
*/
void setup() {
// LED configuration
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW ^ LEDinv);
// Serial port configuration
Serial.flush();
Serial.begin(SERIAL_SPEED);
Serial.print(F("\r\n"));
Serial.print(F("\r\n"));
// SPI
SPI.begin();
// Init the DRIVE
drv.init();
#ifdef SPI_RAM
// Init the SPI RAM
// FIXME This breaks the SPI
//ram.init();
#else
// Init additional RAM if possible
ram.init();
#endif
// Init the BIOS
bios.init();
// Init the BDOS
bdos.init();
// RAM hex dump
//ram.hexdump(0x0000, 0x0200);
// Start BIOS
cpu.jump(BIOSCODE);
}
/**
Main Arduino loop
*/
void loop() {
// Check the CPU state and run
if (cpu.state) {
cpu.instruction();
//cpu.trace();
}
// Ticker
bios.tick();
//delay(100);
}