commit 55fab05

zzo38  ·  2026-03-31 03:34:54 +0000 UTC
parent 44c7245
Add assembler command to automatically switch the "r" mode for several instructions at once
3 files changed,  +21, -14
+5, -0
 1@@ -149,6 +149,11 @@ The following nonstandard tokens are available:
 2  for 2bpp tiles. The colour codes are . or 0 for the background colour,
 3  and numbers 1 2 3 for the other colours.
 4 
 5+ \r will cause it to automatically change opcodes without "r" to the ones
 6+ with "r" and vice-versa until the next \r token. This also affects the
 7+ # and , and . and ; tokens, and causes the uses of JSI and JCI to be
 8+ errors (but JMI and BRK are OK and are not affected by \r).
 9+
10  [@ makes a anonymous label; the matching ] command will reference the
11  same anonymous label as this one. (Nesting is allowed.)
12 
+11, -13
 1@@ -27,7 +27,7 @@
 2   random random POP2 random random POP2
 3 @reset
 4   \\ Initialize variables
 5-  [& 00 0100 0000 0000 00 ]@ LITr 02 DEO2r
 6+  ;Vinit #02 DEO2
 7   LIT2 03 -Mani STZ
 8   \\ Set up deck
 9   #4000 [@ #01 OVR #03 AND #40 SFT SFT OVR STZ INC EORk ]?
10@@ -82,7 +82,6 @@
11 
12 @deal2
13   [& ]@
14-@deal1
15   STH INC LDZk #80 ORA
16   STHrk .Tableau ADD STZ
17   STHr INC JMP2r
18@@ -96,29 +95,27 @@
19   LIT2 &mem ff82 DEI EQUk ?brk
20   DUPk ,&mem STR #08 EQU ?reset
21   LIT2 0c -Score LDZ LTH ?brk
22+  LITr -Cursor
23   DUPk #80 EQU ?/r #40 EQU ?/l
24-  DUPk #20 EQU ?/d #10 EQU ?/u
25+  INCrk
26+  DUPk #20 EQU ?/d #10 EQU ?/l
27   DUPk #02 EQU ?/b EQUk EQU ?/a
28   &sh showcursor
29 
30   &r
31-    .Cursor/X LDZk DUP #05 LTH ADD DUP #04 EQU &rsa ADD &rsh SWP STZ
32+    \r LDZk DUP #05 LTH ADD DUP #04 EQU &rsa ADD &rsh SWP STZ \r
33   !/sh
34 
35   &l
36-    .Cursor/X &rss LDZk DUPk DIV SUB DUP #04 EQU SUB
37+    \r LDZk DUPk DIV SUB DUP #04 EQU SUB \r
38   !/rsh
39 
40   &d
41-    .Cursor/Y LDZk DUP #03 LTH
42+    \r LDZk DUP #03 LTH \r
43   !/rsa
44 
45-  &u
46-    .Cursor/Y
47-  !/rss
48-
49   &b
50-    LITr -Cursor LDZ2r DUP2r LITr 20 SFTr ADDr
51+    POPr LDZ2r DUP2r LITr 20 SFTr ADDr
52     .Mark LDZ2 ORAk ?/un ( 00 00 )
53     STHrk .Height ADD LDZ EQU ?/sh ( 00 )
54     LIT2 05 -Cursor/X LDZ EQU ?/sh /nm
55@@ -239,12 +236,12 @@
56   DUP .Height ADD LDZ DUP [? NIP JMP2r ]@
57   .Tableau-1 ADD SWP #0a MUL ADD LDZ JMP2r
58 
59-@cls cls2 #802e DEO JMP2r
60+\\ @cls cls2 #802e DEO JMP2r
61 @cls2 DUP2k EOR2 #28 DEO2k INC INC DEO2 #c02e DEO @return JMP2r
62 
63 @dispspare [& ]@ DUP2 cursorxy LDZk showcard INC JMP2r
64 
65-@decmani .Mani LDZk #01 SUB SWP STZ JMP2r
66+@decmani .Mani LDZk NEQk SUB SWP STZ JMP2r
67 
68 @cursorat ( addr -- )
69   LDZ2
70@@ -390,4 +387,5 @@
71   \=..2.....
72   \=..3.....;
73 
74+@Vinit 0001
75 \mk3039 \m20~ascii.font \@Font
+5, -1
 1@@ -81,6 +81,7 @@ static Uint16 bstack[256];
 2 static char spec_rune[128];
 3 static Uint16 exstart;
 4 static FILE*subas;
 5+static Uint8 exchstack;
 6 
 7 static Uint8 fontkeep[LENGTH/8];
 8 static Uint8 fontmap[256];
 9@@ -160,7 +161,7 @@ findopcode(char *s)
10 				return 0; /* failed to match */
11 			m++;
12 		}
13-		return i;
14+		return i^exchstack;
15 	}
16 	return 0;
17 }
18@@ -567,6 +568,7 @@ parse(char *w, FILE *f)
19 			if(!writebyte1(c)) return 0;
20 		break;
21 	case '?': /* JCI */
22+		if(exchstack) return error("Cannot use JCI with \\r", w);
23 		makereference(p.scope, w, p.ptr + 1);
24 		return writebyte(0x20) && writeshort(0xffff, 0);
25 	case '!': /* JMI */
26@@ -636,6 +638,7 @@ parse(char *w, FILE *f)
27 		      if(!doinclude_font(w+i+1,shex(w+2))) return 0;
28 		    }
29 		    break;
30+		  case 'r': exchstack^=0x40; break;
31 		  default: return error("Invalid special",w);
32 		}
33 		break;
34@@ -712,6 +715,7 @@ parse(char *w, FILE *f)
35 			line_comment=0;
36 			return 1;
37 		} else {
38+			if(exchstack) return error("Cannot use JSI with \\r", w);
39 			*word='!';
40 			scpy(w,word+1,62);
41 			makereference(p.scope, word, p.ptr + 1);