-
Notifications
You must be signed in to change notification settings - Fork 5
/
CPMduino.ino
79 lines (71 loc) · 1.52 KB
/
CPMduino.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 "globals.h"
#include <SPI.h>
#include <SdFat.h>
SdFat SD;
SdFile dir;
#define LED 13
#define DELAY 500
#define SDcs 4 // Pin for the SD chip select signal
#include "abstraction_arduino.h"
#include "cpu.h"
#include "console.h"
#include "ram.h"
#include "disk.h"
#include "cpm.h"
void setup(void)
{
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
pinMode(SDcs, OUTPUT);
digitalWrite(SDcs, LOW);
Serial.begin(9600);
while (!Serial); // Wait until serial is connected
_puts("CP/M 2.2 Emulator v2.0 by Marcelo Dantas.\r\n");
_puts("Arduino read/write support by Krzysztof Klis\r\n");
_puts(" Build " __DATE__ " - " __TIME__ "\r\n");
_puts("--------------------------------------------\r\n");
if (SD.begin(SDcs, SPI_HALF_SPEED))
{
if (SD.exists(CCPname))
{
while (true)
{
_puts("\n64k CP/M Vers 2.2\r\n");
SD.chdir();
if (_RamLoad(CCPname, CCPaddr))
{
if (_RamVerify(CCPname, CCPaddr))
{
_PatchCPM();
Z80reset();
SET_LOW_REGISTER(BC, _RamRead(0x0004));
PC = CCPaddr;
Z80run();
if (Status == 1)
_RamWrite(0x0004, 0);
}
else {
_puts("Error writing the CCP to RAM. CPU halted.\r\n");
}
}
else {
_puts("Unable to load the CCP. CPU halted.\r\n");
break;
}
}
}
else {
_puts("Unable to load CP/M CCP. CPU halted.\r\n");
}
}
else {
_puts("Unable to initialize SD card. CPU halted.\r\n");
}
}
void loop(void)
{
digitalWrite(LED, HIGH);
delay(DELAY);
digitalWrite(LED, LOW);
delay(DELAY);
}