...
|
...
|
@@ -24,6 +24,11 @@ typedef struct {
|
24
|
24
|
Uint8 dat[256];
|
25
|
25
|
} Stack;
|
26
|
26
|
|
|
27
|
+typedef struct {
|
|
28
|
+ Uint8 ptr;
|
|
29
|
+ Uint16 dat[256];
|
|
30
|
+} Stack16;
|
|
31
|
+
|
27
|
32
|
typedef struct {
|
28
|
33
|
Uint16 ptr;
|
29
|
34
|
Uint8 dat[65536];
|
...
|
...
|
@@ -32,7 +37,8 @@ typedef struct {
|
32
|
37
|
typedef struct {
|
33
|
38
|
Uint8 literal, status;
|
34
|
39
|
Uint16 counter, vreset, vframe, verror;
|
35
|
|
- Stack wst, rst;
|
|
40
|
+ Stack wst;
|
|
41
|
+ Stack16 rst;
|
36
|
42
|
Memory rom, ram;
|
37
|
43
|
} Computer;
|
38
|
44
|
|
...
|
...
|
@@ -93,13 +99,11 @@ void wspush8(Uint8 b) { cpu.wst.dat[cpu.wst.ptr++] = b; }
|
93
|
99
|
Uint8 wspop8(void) { return cpu.wst.dat[--cpu.wst.ptr]; }
|
94
|
100
|
Uint16 wspop16(void) { return wspop8() + (wspop8() << 8); }
|
95
|
101
|
Uint8 wspeek8(void) { return cpu.wst.dat[cpu.wst.ptr - 1]; }
|
96
|
|
-Uint16 rspop16(void) { return cpu.rst.dat[--cpu.rst.ptr] + (cpu.rst.dat[--cpu.rst.ptr] << 8); }
|
|
102
|
+Uint16 rspop16(void) { return cpu.rst.dat[--cpu.rst.ptr]; }
|
|
103
|
+void rspush16(Uint16 a) { cpu.rst.dat[cpu.rst.ptr++] = a; }
|
97
|
104
|
|
98
|
105
|
void op_brk() { setflag(FLAG_HALT, 1); }
|
99
|
|
-void op_rts() {
|
100
|
|
- cpu.rom.ptr = rspop16();
|
101
|
|
- printf("RTS: %04x\n", cpu.rom.ptr);
|
102
|
|
-}
|
|
106
|
+void op_rts() { cpu.rom.ptr = rspop16(); }
|
103
|
107
|
void op_lit() { cpu.literal += cpu.rom.dat[cpu.rom.ptr++]; }
|
104
|
108
|
void op_drp() { wspop8(); }
|
105
|
109
|
void op_dup() { wspush8(wspeek8()); }
|
...
|
...
|
@@ -107,7 +111,7 @@ void op_swp() { Uint8 b = wspop8(), a = wspop8(); wspush8(b); wspush8(a); }
|
107
|
111
|
void op_ovr() { wspush8(cpu.wst.dat[cpu.wst.ptr - 2]); }
|
108
|
112
|
void op_rot() { Uint8 c = wspop8(),b = wspop8(),a = wspop8(); wspush8(b); wspush8(c); wspush8(a); }
|
109
|
113
|
void op_jmu() { cpu.rom.ptr = wspop8(); }
|
110
|
|
-void op_jsu() { cpu.rst.dat[cpu.rst.ptr++] = (cpu.rom.ptr >> 8) & 0xff; cpu.rst.dat[cpu.rst.ptr++] = cpu.rom.ptr; cpu.rom.ptr = wspop16(); }
|
|
114
|
+void op_jsu() { rspush16(cpu.rom.ptr); cpu.rom.ptr = wspop16(); }
|
111
|
115
|
void op_jmc() { if(wspop8()) op_jmu(); }
|
112
|
116
|
void op_jsc() { if(wspop8()) op_jsu(); }
|
113
|
117
|
void op_equ() { wspush8(wspop8() == wspop8()); }
|