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
|
#include "cpu/core.h"
#include "apple.h"
#include "video/interface.h"
#include <ncurses.h>
#include <unistd.h>
/*
README
Assumes that the definition of ROM in apple.c has
been commented out.
This program is a successor to my 'interpreter.c'
utility, which unfortunately did not keep up with
the progress of my program.
This one works by letting you program the ROM with
whatever machine code you want.
*/
byte ROM[] = {
// ADC : 0xFF00
0x18,
0xA5, 0x20,
0x65, 0x22,
0x85, 0x24,
0xA5, 0x21,
0x65, 0x23,
0x85, 0x25,
// SBC : 0xFF0D
0x38,
0xA5, 0x30,
0xE5, 0x32,
0x85, 0x34,
0xA5, 0x31,
0xE5, 0x33,
0x85, 0x35
};
int main() {
AppleOn();
PC = 0xFF0D;
// ADC Memory
SetMemory(0x0020, 0x31);
SetMemory(0x0021, 0x11);
SetMemory(0x0022, 0xF9);
SetMemory(0x0023, 0x0A);
// SBC Memory
SetMemory(0x0030, 0x34);
SetMemory(0x0031, 0x12);
SetMemory(0x0032, 0x43);
SetMemory(0x0033, 0x01);
DisplayInit();
while(1) {
// Computing
CallInstructionTable(GetMemory(PC), 0);
// Display information
PrintInfo();
// Wait to proceed
WAIT_ON_USER:
char c = getch();
mvprintw(28, 4, " ");
// If user presses enter, get input.
if (c == 0x0A) {
address a = 0x0000;
mvprintw(28, 4, "Enter address: 0x");
for (int i = 3; i >= 0; i--) {
GET_HEX:
c = getch();
char cc;
if ((c >= '0') && (c <= '9')) {
cc = c-'0';
}
else if ((c >= 'A') && (c <= 'F')) {
cc = c-'A'+10;
}
else {
goto GET_HEX;
// Direct all complaints to /dev/null
}
mvaddch(28, 24-i, c);
a |= ((address)cc) << 4*i;
}
mvprintw(28, 25, " -> %02x", GetMemory(a));
goto WAIT_ON_USER;
}
}
DisplayClose();
return 0;
}
|