commit e806122

zzo38  ·  2023-08-23 04:14:56 +0000 UTC
parent 0301ad9
Add stack pointer ports.
2 files changed,  +20, -5
M main.c
M main.c
+15, -0
 1@@ -386,6 +386,14 @@ static Uint8 default_in(Device*misc1,Uint8 misc2) { return misc1->d[misc2&15]; }
 2 static void default_out(Device*misc1,Uint8 misc2) {}
 3 static void default_exp(Device*misc1,Uint16 misc2) {}
 4 
 5+static Uint8 system_in(Device*dev,Uint8 id) {
 6+  switch(id) {
 7+    case 4: return ds.p;
 8+    case 5: return rs.p;
 9+    default: return dev->d[id];
10+  }
11+}
12+
13 static void system_out(Device*dev,Uint8 id) {
14   Uint16 x;
15   switch(id) {
16@@ -393,6 +401,12 @@ static void system_out(Device*dev,Uint8 id) {
17       x=GET16(dev->d+2);
18       device[mem[x]>>4].exp(device+(mem[x]>>4),x);
19       break;
20+    case 4:
21+      ds.p=dev->d[4];
22+      break;
23+    case 5:
24+      rs.p=dev->d[5];
25+      break;
26     case 8 ... 13:
27       colors[070].r=colors[074].r=(dev->d[8]>>4)*0x11;
28       colors[071].r=colors[075].r=(dev->d[8]&15)*0x11;
29@@ -1644,6 +1658,7 @@ int main(int argc,char**argv) {
30     device[i].out=default_out;
31     device[i].exp=default_exp;
32   }
33+  device[0].in=system_in;
34   device[0].out=system_out;
35   device[0].exp=system_exp;
36   device[10].aux=&uxnfile0;
+5, -5
 1@@ -28,6 +28,8 @@ In the below lists, asterisks indicate 16-bit ports.
 2 
 3 00 = Vector *
 4 02 = Expansion *
 5+04 = Primary stack count
 6+05 = Secondary stack count
 7 06 = Metadata *
 8 08 = Colours (red) *
 9 0A = Colours (green) *
10@@ -42,6 +44,9 @@ operation, which is a record stored at that address; the first byte of
11 that data is the operation code, and the rest are the arguments. See the
12 below list of expansion operations.
13 
14+The stack counts are the number of bytes in the specified stack. They can
15+be read and written; writing zero will clear the stack.
16+
17 The colours control the colours of the display, where the high nybble of
18 each controls the value for colour index 0, and the low nybble of each
19 controls the value for colour index 3.
20@@ -55,11 +60,6 @@ of the number written is the exit code (if exit code is meaningful for the
21 operating system that it is running on) (writing 0x80 exits with code 0
22 which means successful).
23 
24-(In previous versions of this specification, port 02 is the data stack
25-port and port 03 is the return stack port. The data stack and return stack
26-ports have a different meaning in different implementations, and probably
27-should not be used by most programs.)
28-
29 
30 === Standard I/O ===
31