Browse code

Ported examples to new devices addr

neauoire authored on 21/03/2021 21:16:19
Showing 12 changed files
... ...
@@ -35,7 +35,7 @@ typedef struct {
35 35
 
36 36
 typedef struct {
37 37
 	Uint8 data[256 * 256], llen, mlen;
38
-	Uint16 ptr, count;
38
+	Uint16 ptr;
39 39
 	Label labels[256];
40 40
 	Macro macros[256];
41 41
 } Program;
... ...
@@ -69,7 +69,6 @@ pushbyte(Uint8 b, int lit)
69 69
 {
70 70
 	if(lit) pushbyte(0x02, 0);
71 71
 	p.data[p.ptr++] = b;
72
-	p.count++;
73 72
 }
74 73
 
75 74
 void
... ...
@@ -425,7 +424,7 @@ void
425 424
 cleanup(char *filename)
426 425
 {
427 426
 	int i;
428
-	printf("Assembled %s(%0.2fkb), %d labels, %d macros.\n\n", filename, p.count / 1000.0, p.llen, p.mlen);
427
+	printf("Assembled %s(%0.2fkb), %d labels, %d macros.\n\n", filename, p.ptr / 1000.0, p.llen, p.mlen);
429 428
 	for(i = 0; i < p.llen; ++i)
430 429
 		if(!p.labels[i].refs)
431 430
 			printf("--- Unused label: %s\n", p.labels[i].name);
... ...
@@ -450,7 +449,7 @@ main(int argc, char *argv[])
450 449
 		error("Assembly", "Failed");
451 450
 		return 1;
452 451
 	}
453
-	fwrite(p.data, sizeof(p.data), 1, fopen(argv[2], "wb"));
452
+	fwrite(p.data, p.ptr, 1, fopen(argv[2], "wb"));
454 453
 	fclose(f);
455 454
 	cleanup(argv[2]);
456 455
 	return 0;
... ...
@@ -20,5 +20,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr
20 20
 # cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator
21 21
 
22 22
 # run
23
-./bin/assembler projects/software/left.usm bin/boot.rom
23
+./bin/assembler projects/software/nasu.usm bin/boot.rom
24 24
 ./bin/emulator bin/boot.rom
... ...
@@ -2,7 +2,15 @@
2 2
 
3 3
 %RTN { JMP2r }
4 4
 
5
-@RESET 
5
+( devices )
6
+
7
+|0100 ;Console { pad 8 char 1 byte 1 short 2 }
8
+|01F0 .RESET .FRAME .ERROR ( vectors )
9
+|01F8 [ 13fd 1ef3 1bf2 ] ( palette )
10
+
11
+( program )
12
+
13
+|0200 @RESET 
6 14
 	
7 15
 	,text1 ,print-label JSR2
8 16
 	,text2 ,print-label JSR2
... ...
@@ -27,7 +35,3 @@ RTN
27 35
 |c000 @FRAME
28 36
 |d000 @ERROR 
29 37
 
30
-|FF00 ;Console { pad 8 char 1 byte 1 short 2 }
31
-
32
-|FFF0 .RESET .FRAME .ERROR ( vectors )
33
-|FFF8 [ 13fd 1ef3 1bf2 ] ( palette )
34 38
\ No newline at end of file
... ...
@@ -4,9 +4,19 @@
4 4
 %-- { #0001 SUB2 }
5 5
 %2/ { #0002 DIV2 }
6 6
 
7
+( variables )
8
+
7 9
 ;slime { color 1 }
8 10
 
9
-|0100 @RESET 
11
+( devices )
12
+
13
+|0110 ;Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
14
+|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
15
+|0130 ;Controller { buttons 1 }
16
+|01F0 .RESET .FRAME .ERROR ( vectors )
17
+|01F8 [ 0daf 02ff 035f ] ( palette )
18
+
19
+|0200 @RESET 
10 20
 	
11 21
 	( set origin )
12 22
 	~Screen.width 2/ =Sprite.x 
... ...
@@ -60,11 +70,4 @@ BRK
60 70
 @right_icn   [ 3c7e f7f8 f8f7 7e3c ]
61 71
 @slime_icn   [ 0000 183c 3c18 0000 ]
62 72
 
63
-|d000 @ERROR BRK 
64
-
65
-|FF10 ;Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
66
-|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
67
-|FF30 ;Controller { buttons 1 }
68
-
69
-|FFF0 .RESET .FRAME .ERROR ( vectors )
70
-|FFF8 [ 0daf 02ff 035f ] ( palette )
73
+@ERROR BRK 
... ...
@@ -8,7 +8,17 @@
8 8
 ;color { byte 1 }
9 9
 ;timer { byte 1 }
10 10
 
11
-|0100 @RESET 
11
+( devices )
12
+
13
+|0110 ;Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
14
+|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
15
+|0150 ;Mouse  { x 2 y 2 state 1 chord 1 }
16
+|01F0 .RESET .FRAME .ERROR ( vectors )
17
+|01F8 [ 0f85 0fd5 0fb5 ] ( palette )
18
+
19
+( program )
20
+
21
+|0200 @RESET 
12 22
 
13 23
 	( position cat )
14 24
 	~Screen.width #0002 DIV2 =cat.x 
... ...
@@ -219,12 +229,5 @@ RTN
219 229
 @mouse1_text   [ mouse 1_ 00 ]
220 230
 @mouse2_text   [ mouse _2 00 ]
221 231
 @mouse12_text  [ mouse 12 00 ]
222
-
223
-|d000 @ERROR BRK 
224
-
225
-|FF10 ;Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
226
-|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
227
-|FF50 ;Mouse  { x 2 y 2 state 1 chord 1 }
228
-
229
-|FFF0 .RESET .FRAME .ERROR ( vectors )
230
-|FFF8 [ 0f85 0fd5 0fb5 ] ( palette )
232
+ 
233
+@ERROR BRK 
231 234
\ No newline at end of file
... ...
@@ -3,7 +3,16 @@
3 3
 ;center { x 2 y 2 }
4 4
 ;timer { byte 1 }
5 5
 
6
-|0100 @RESET 
6
+( devices )
7
+
8
+|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
9
+|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
10
+|01F0 .RESET .FRAME .ERROR ( vectors )
11
+|01F8 [ f0ac f0bb f053 ] ( palette )
12
+
13
+( program )
14
+
15
+|0200 @RESET 
7 16
 
8 17
 	( find screen center )
9 18
 	~Screen.width #0002 DIV2 =center.x
... ...
@@ -60,10 +69,4 @@ BRK
60 69
 
61 70
 @icon [ 3c7e e7c3 c3e7 7e3c ]
62 71
 
63
-|d000 @ERROR BRK 
64
-
65
-|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
66
-|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
67
-
68
-|FFF0 .RESET .FRAME .ERROR ( vectors )
69
-|FFF8 [ f0ac f0bb f053 ] ( palette )
72
+@ERROR BRK 
... ...
@@ -10,7 +10,14 @@
10 10
 ;rect { x1 2 y1 2 x2 2 y2 2 }
11 11
 ;color { byte 1 }
12 12
 
13
-|0100 @RESET
13
+|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
14
+|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
15
+|0130 ;Controller { buttons 1 }
16
+|0150 ;Mouse { x 2 y 2 state 1 chord 1 }
17
+|01F0 .RESET .FRAME .ERROR ( vectors )
18
+|01F8 [ 0fcf 0fc4 0fc4 ] ( palette )
19
+
20
+|0200 @RESET
14 21
 	
15 22
 	#0030 =window.x1 #0030 =window.y1 #0090 =window.x2 #0090 =window.y2
16 23
 
... ...
@@ -223,12 +230,4 @@ RTN
223 230
 	0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c
224 231
 ]
225 232
 
226
-|d000 @ERROR BRK 
227
-
228
-|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
229
-|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
230
-|FF30 ;Controller { buttons 1 }
231
-|FF50 ;Mouse { x 2 y 2 state 1 chord 1 }
232
-
233
-|FFF0 .RESET .FRAME .ERROR ( vectors )
234
-|FFF8 [ 0fcf 0fc4 0fc4 ] ( palette )
235 233
\ No newline at end of file
234
+@ERROR BRK 
... ...
@@ -9,7 +9,14 @@
9 9
 ;r2 { x1 2 y1 2 x2 2 y2 2 }
10 10
 ;r3 { x1 2 y1 2 x2 2 y2 2 }
11 11
 
12
-|0100 @RESET
12
+|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
13
+|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
14
+|0150 ;Mouse  { x 2 y 2 state 1 chord 1 }
15
+
16
+|01F0 .RESET .FRAME .ERROR ( vectors )
17
+|01F8 [ 0f0f 0fff 0ff0 ] ( palette )
18
+
19
+|0200 @RESET
13 20
 	
14 21
 	#0020 #0030 #0060 #0060 =r1.y2 =r1.x2 =r1.y1 =r1.x1
15 22
 	#0058 #0050 #0090 #0080 =r2.y2 =r2.x2 =r2.y1 =r2.x1
... ...
@@ -93,11 +100,4 @@ RTN
93 100
 @pointer_icn [ 80c0 e0f0 f8e0 1000 ]
94 101
 @hand_icn    [ 4040 4070 f8f8 f870 ]
95 102
 
96
-|d000 @ERROR BRK 
97
-
98
-|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
99
-|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
100
-|FF50 ;Mouse  { x 2 y 2 state 1 chord 1 }
101
-
102
-|FFF0 .RESET .FRAME .ERROR ( vectors )
103
-|FFF8 [ 0f0f 0fff 0ff0 ] ( palette )
104 103
\ No newline at end of file
104
+@ERROR BRK 
... ...
@@ -7,7 +7,12 @@
7 7
 ;center { x 2 y 2 }
8 8
 ;i { short 2 }
9 9
 
10
-|0100 @RESET
10
+|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
11
+|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
12
+|01F0 .RESET .FRAME .ERROR ( vectors )
13
+|01F8 [ 0f0f 0fff 0ff0 ] ( palette )
14
+
15
+|0200 @RESET
11 16
 	
12 17
 	( find screen center )
13 18
 	~Screen.width #0002 DIV2 =center.x
... ...
@@ -121,11 +126,5 @@ RTN
121 126
 @text4 [ even 00 ]
122 127
 @text5 [ odd 00 ]
123 128
 
124
-|c000 @FRAME BRK 
125
-|d000 @ERROR BRK 
126
-
127
-|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
128
-|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
129
-
130
-|FFF0 .RESET .FRAME .ERROR ( vectors )
131
-|FFF8 [ 0f0f 0fff 0ff0 ] ( palette )
132 129
\ No newline at end of file
130
+@FRAME BRK 
131
+@ERROR BRK 
... ...
@@ -4,7 +4,11 @@
4 4
 
5 5
 ;pict { x 2 y 2 width 2 height 2 color 1 addr 2 }
6 6
 
7
-|0100 @RESET
7
+|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
8
+|01F0 .RESET .FRAME .ERROR ( vectors )
9
+|01F8 [ 0ffc 0f0b 0f03 ] ( palette )
10
+
11
+|0200 @RESET
8 12
 
9 13
 	#0000 #0000 #0100 #0100 #01 ,pict_large ,draw-picture JSR2
10 14
 	#0098 #0060 #0080 #0080 #01 ,pict_medium ,draw-picture JSR2
... ...
@@ -302,10 +306,5 @@ RTN
302 306
 
303 307
 ]
304 308
 
305
-|c000 @FRAME BRK 
306
-|d000 @ERROR BRK 
307
-
308
-|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
309
-
310
-|FFF0 .RESET .FRAME .ERROR ( vectors )
311
-|FFF8 [ 0ffc 0f0b 0f03 ] ( palette )
309
+@FRAME BRK 
310
+@ERROR BRK 
... ...
@@ -11,7 +11,12 @@
11 11
 ;line { x 2 y 2 sx 2 sy 2 dx 2 dy 2 e1 2 e2 2 }
12 12
 ;color { byte 1 }
13 13
 
14
-|0100 @RESET
14
+|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
15
+|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
16
+|01F0 .RESET .FRAME .ERROR ( vectors )
17
+|01F8 [ 13fd 1ef3 1bf2 ] ( palette )
18
+
19
+|0200 @RESET
15 20
 	
16 21
 	#0010 #0020 #0040 #0060 #01 ,fill-rect JSR2
17 22
 	#0020 #0030 #0050 #0070 #02 ,fill-rect JSR2
... ...
@@ -171,11 +176,5 @@ RTN
171 176
 
172 177
 @text [ Label 20 Text 00 ] ( add characters to memory )
173 178
 
174
-|c000 @FRAME BRK 
175
-|d000 @ERROR BRK 
176
-
177
-|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
178
-|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
179
-
180
-|FFF0 .RESET .FRAME .ERROR ( vectors )
181
-|FFF8 [ 13fd 1ef3 1bf2 ] ( palette )
182 179
\ No newline at end of file
180
+@FRAME BRK 
181
+@ERROR BRK 
... ...
@@ -525,6 +525,6 @@ RTN
525 525
 	007c 8280 f080 827c 007c 8280 f080 8080
526 526
 ]
527 527
 
528
-|E000 @bank [ ]	
528
+@ERROR BRK 
529 529
 
530
-|FE00 @ERROR BRK 
531 530
\ No newline at end of file
531
+@bank [ ]