Browse code

Progress on macros experiments

neauoire authored on 22/04/2021 22:57:40
Showing 3 changed files
... ...
@@ -26,10 +26,20 @@ contexts:
26 26
       scope: variable.control
27 27
       pop: true
28 28
     # constants
29
-    # structs
30
-
31
-    # Special
32 29
 
30
+    # templated
31
+    - match: '(\S+)\^\s?'
32
+      scope: storage.type
33
+      pop: true
34
+    - match: '(\S+)\=\s?'
35
+      scope:  constant.numeric
36
+      pop: true
37
+    - match: '(\S+)\?\s?'
38
+      scope: storage.type
39
+      pop: true
40
+    - match: '(\S+)\!\s?'
41
+      scope: constant.numeric
42
+      pop: true
33 43
 
34 44
     # Pushing to stack
35 45
 
... ...
@@ -6,6 +6,11 @@
6 6
 %-- { #0001 SUB2 }
7 7
 %ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 }
8 8
 
9
+(
10
+%%^ { .% PEK } %%= { .% POK }
11
+%%? { .% DEI } %%! { .% DEO }
12
+)
13
+
9 14
 %%^ { .% PEK2 } %%= { .% POK2 }
10 15
 %%? { .% DEI2 } %%! { .% DEO2 }
11 16
 
... ...
@@ -28,11 +33,12 @@
28 33
 |0100 ( -> )
29 34
 
30 35
 	( theme ) 
31
-	#f0fd System/r! 
32
-	#f003 System/g! 
33
-	#f002 System/b!
36
+	#f0f0 System/r! 
37
+	#f00f System/g! 
38
+	#f000 System/b!
34 39
 
35
-	( vectors ) ;on-mouse Mouse/vector!
40
+	( vectors ) 
41
+	;on-mouse Mouse/vector!
36 42
 
37 43
 BRK
38 44
 
... ...
@@ -41,13 +47,10 @@ BRK
41 47
 	;draw-cursor JSR2
42 48
 
43 49
 	( on down )
44
-	.Mouse/state DEI #00 NEQ 
45
-	.pointer/state PEK #00 EQU
46
-	#0101 EQU2 ,on-mouse-down JNZ
50
+	.Mouse/state DEI #00 NEQ .pointer/state PEK #00 EQU #0101 EQU2 ,on-mouse-down JNZ
47 51
 
48 52
 	( on drag )
49
-	.Mouse/state DEI 
50
-	#00 NEQ ,on-mouse-drag JNZ
53
+	.Mouse/state DEI #00 NEQ ,on-mouse-drag JNZ
51 54
 
52 55
 	.Mouse/state DEI .pointer/state POK
53 56
 
... ...
@@ -58,6 +61,7 @@ BRK
58 61
 	( record start position )
59 62
 	Mouse/x? DUP2 pointer/x= pointer/lastx= 
60 63
 	Mouse/y? DUP2 pointer/y= pointer/lasty=
64
+
61 65
 	.Mouse/state DEI .pointer/state POK
62 66
 
63 67
 BRK
... ...
@@ -70,11 +74,12 @@ BRK
70 74
 	pointer/x^ 
71 75
 	pointer/y^ 
72 76
 	#01 ( add mouse state ) [ .Mouse/state DEI #10 EQU #02 MUL ADD ] 
73
-	;hairline JSR2
77
+	;draw-line JSR2
74 78
 
75 79
 	( record last position )
76 80
 	Mouse/x? pointer/lastx= 
77 81
 	Mouse/y? pointer/lasty=
82
+
78 83
 	.Mouse/state DEI .pointer/state POK
79 84
 
80 85
 BRK
... ...
@@ -102,7 +107,7 @@ BRK
102 107
 
103 108
 RTN
104 109
 
105
-@hairline ( x1 y1 x2 y2 color -- )
110
+@draw-line ( x1 y1 x2 y2 color -- )
106 111
 	
107 112
 	( load ) .color POK line/y0= line/x0= line/y= line/x=
108 113
 	line/x0^ line/x^ SUB2 ABS2 line/dx=
... ...
@@ -111,7 +116,11 @@ RTN
111 116
 	#ffff #00 line/y^ line/y0^ LTS2 #0002 MUL2 ADD2 line/sy= 
112 117
 	line/dx^ line/dy^ ADD2 line/e1=
113 118
 	&loop
114
-		line/x^ Screen/x! line/y^ Screen/y! .color PEK .Screen/color DEO
119
+		( draw ) 
120
+		line/x^ Screen/x! 
121
+		line/y^ Screen/y! 
122
+		.color PEK 
123
+		.Screen/color DEO
115 124
 		line/x^ line/x0^ EQU2 line/y^ line/y0^ EQU2 #0101 EQU2 ,&end JNZ
116 125
 		line/e1^ #0002 MUL2 line/e2=
117 126
 		line/e2^ line/dy^ LTS2 ,&skipy JNZ
... ...
@@ -112,8 +112,8 @@ drawdebugger(Ppu *p, Uint8 *stack, Uint8 ptr)
112 112
 	Uint8 i, x, y, b;
113 113
 	for(i = 0; i < 0x20; ++i) { /* memory */
114 114
 		x = ((i % 8) * 3 + 1) * 8, y = (i / 8 + 1) * 8, b = stack[i];
115
-		puticn(p, p->bg, x, y, font[(b >> 4) & 0xf], 2 + (ptr == i));
116
-		puticn(p, p->bg, x + 8, y, font[b & 0xf], 2 + (ptr == i));
115
+		puticn(p, p->bg, x, y, font[(b >> 4) & 0xf], 1 + (ptr == i) * 0x7);
116
+		puticn(p, p->bg, x + 8, y, font[b & 0xf], 1 + (ptr == i) * 0x7);
117 117
 	}
118 118
 	for(x = 0; x < 0x20; ++x) {
119 119
 		drawpixel(p, x, p->height / 2, 2);