... | ... |
@@ -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 examples/devmouse.usm bin/boot.rom |
|
23 |
+./bin/assembler examples/paint.usm bin/boot.rom |
|
24 | 24 |
./bin/emulator bin/boot.rom |
... | ... |
@@ -322,10 +322,10 @@ Uint8 |
322 | 322 |
screenr(Device *d, Memory *m, Uint8 b) |
323 | 323 |
{ |
324 | 324 |
switch(b) { |
325 |
- case 0: return (WIDTH >> 8) & 0xff; |
|
326 |
- case 1: return WIDTH & 0xff; |
|
327 |
- case 2: return (HEIGHT >> 8) & 0xff; |
|
328 |
- case 3: return HEIGHT & 0xff; |
|
325 |
+ case 0: return (HOR * 8 >> 8) & 0xff; |
|
326 |
+ case 1: return HOR * 8 & 0xff; |
|
327 |
+ case 2: return (VER * 8 >> 8) & 0xff; |
|
328 |
+ case 3: return VER * 8 & 0xff; |
|
329 | 329 |
} |
330 | 330 |
loadtheme(m->dat + 0xfff0); |
331 | 331 |
(void)m; |
... | ... |
@@ -336,13 +336,13 @@ Uint8 |
336 | 336 |
screenw(Device *d, Memory *m, Uint8 b) |
337 | 337 |
{ |
338 | 338 |
d->mem[d->ptr++] = b; |
339 |
- if(d->ptr > 5) { |
|
340 |
- putpixel(pixels, |
|
341 |
- (d->mem[2] << 8) + d->mem[3], |
|
342 |
- (d->mem[0] << 8) + d->mem[1], |
|
343 |
- d->mem[4]); |
|
344 |
- if(d->mem[5] == 1) |
|
345 |
- screen.reqdraw = 1; |
|
339 |
+ if(d->ptr > 4) { |
|
340 |
+ Uint16 x = (d->mem[2] << 8) + d->mem[3]; |
|
341 |
+ Uint16 y = (d->mem[0] << 8) + d->mem[1]; |
|
342 |
+ Uint8 clr = d->mem[4] & 0xf; |
|
343 |
+ Uint8 layer = d->mem[4] >> 4 & 0xf; |
|
344 |
+ paintpixel(layer ? screen.fg : screen.bg, x, y, clr); |
|
345 |
+ screen.reqdraw = 1; |
|
346 | 346 |
d->ptr = 0; |
347 | 347 |
} |
348 | 348 |
(void)m; |
349 | 349 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,30 @@ |
1 |
+( hello world ) |
|
2 |
+ |
|
3 |
+:dev/w fff9 ( const write port ) |
|
4 |
+ |
|
5 |
+;x 2 ;y 2 ;color 1 |
|
6 |
+ |
|
7 |
+|0100 @RESET |
|
8 |
+ |
|
9 |
+ ( set dev/write to console ) |
|
10 |
+ #00 =dev/w |
|
11 |
+ ( print to console ) |
|
12 |
+ ,text ,displaycli JSR |
|
13 |
+ |
|
14 |
+BRK |
|
15 |
+ |
|
16 |
+@displaycli |
|
17 |
+ |
|
18 |
+ @cliloop |
|
19 |
+ DUP2 LDR IOW ( write pointer value to console ) |
|
20 |
+ #0001 ADD2 ( increment string pointer ) |
|
21 |
+ DUP2 LDR #00 NEQ ,cliloop ROT JMP? POP2 ( while *ptr!=0 goto loop ) |
|
22 |
+RTS |
|
23 |
+ |
|
24 |
+@text " Hello World " ( add characters to memory ) |
|
25 |
+ |
|
26 |
+|c000 @FRAME |
|
27 |
+|d000 @ERROR |
|
28 |
+ |
|
29 |
+|FFF0 [ f3f0 f30b f30a ] ( palette ) |
|
30 |
+|FFFA .RESET .FRAME .ERROR |
|
0 | 31 |
\ No newline at end of file |
... | ... |
@@ -111,7 +111,7 @@ RTS |
111 | 111 |
@cursor_icn [ 80c0 e0f0 f8e0 1000 ] |
112 | 112 |
|
113 | 113 |
@polycat [ |
114 |
- 0081c 3e3e 7f7f ffff 081c 3e3e 7f7f fffc |
|
114 |
+ 081c 3e3e 7f7f ffff 081c 3e3e 7f7f fffc |
|
115 | 115 |
081c 3c3e 7e7e ffff 081c 3c3e 7e7e ff1f |
116 | 116 |
ffff ffff ff7f 3f0f f0e7 cfef f77c 3f0f |
117 | 117 |
ffff ffff fffe fcf0 0783 c1c3 871e fcf0 |
118 | 118 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,45 @@ |
1 |
+( screen ) |
|
2 |
+ |
|
3 |
+:dev/r fff8 ( std read port ) |
|
4 |
+:dev/w fff9 ( std write port ) |
|
5 |
+ |
|
6 |
+;centerx 2 ;centery 2 ;i 2 |
|
7 |
+ |
|
8 |
+|0100 @RESET |
|
9 |
+ |
|
10 |
+ ( set read/write to dev/screen ) |
|
11 |
+ #01 DUP =dev/r =dev/w |
|
12 |
+ |
|
13 |
+ ( find screen center ) |
|
14 |
+ #00 IOR2 #0002 DIV2 =centerx |
|
15 |
+ #02 IOR2 #0002 DIV2 =centery |
|
16 |
+ |
|
17 |
+ ( draw hor line ) |
|
18 |
+ #0000 =i |
|
19 |
+ @draw-hor |
|
20 |
+ #03 ~i ~centery ,draw-pixel JSR |
|
21 |
+ ~i #0002 ADD2 =i ( increment ) |
|
22 |
+ ~i #00 IOR2 LTH2 ,draw-hor ROT JMP? POP2 |
|
23 |
+ |
|
24 |
+ ( draw ver line ) |
|
25 |
+ #0000 =i |
|
26 |
+ @draw-ver |
|
27 |
+ #03 ~centerx ~i ,draw-pixel JSR |
|
28 |
+ ~i #0002 ADD2 =i ( increment ) |
|
29 |
+ ~i #02 IOR2 LTH2 ,draw-ver ROT JMP? POP2 |
|
30 |
+ |
|
31 |
+ ( draw pixel in the middle ) |
|
32 |
+ #01 ~centerx ~centery ,draw-pixel JSR |
|
33 |
+ |
|
34 |
+BRK |
|
35 |
+ |
|
36 |
+@draw-pixel |
|
37 |
+ IOW2 ( y short ) |
|
38 |
+ IOW2 ( x short ) |
|
39 |
+ IOW ( color byte ) |
|
40 |
+ RTS |
|
41 |
+ |
|
42 |
+|c000 @FRAME BRK |
|
43 |
+|d000 @ERROR BRK |
|
44 |
+|FFF0 [ f0ac f0bb f053 ] ( palette ) |
|
45 |
+|FFFA .RESET .FRAME .ERROR |
0 | 46 |
deleted file mode 100644 |
... | ... |
@@ -1,43 +0,0 @@ |
1 |
-( pixels ) |
|
2 |
- |
|
3 |
-:dev/r fff8 ( std read port ) |
|
4 |
-:dev/w fff9 ( std write port ) |
|
5 |
- |
|
6 |
-;x 2 ;y 2 ;color 1 ;alive 1 |
|
7 |
- |
|
8 |
-|0100 @RESET |
|
9 |
- |
|
10 |
- #01 =dev/w ( set dev/write to screen ) |
|
11 |
- #01 =color ( set color ) |
|
12 |
- #0020 =x #0030 =y ( set origin ) |
|
13 |
- #01 =alive ( set alive = true ) |
|
14 |
- |
|
15 |
-BRK |
|
16 |
- |
|
17 |
-|c000 @FRAME |
|
18 |
- |
|
19 |
- ~alive #00 EQU BRK? |
|
20 |
- #01 ~color ~x ~y ,putpixel JSR |
|
21 |
- ,move JSR |
|
22 |
- |
|
23 |
-BRK |
|
24 |
- |
|
25 |
-@move |
|
26 |
- ~x #0001 ADD2 =x ( incr x ) |
|
27 |
- ~x #0040 LTH2 RTS? ( if x > 60 ) |
|
28 |
- #0020 =x ( x = 0x0020 ) |
|
29 |
- ~y #0001 ADD2 =y ( incr y ) |
|
30 |
- ~y #0050 LTH2 RTS? ( y > 50 ) |
|
31 |
- #00 ,alive STR ( alive = 0 ) |
|
32 |
- RTS |
|
33 |
- |
|
34 |
-@putpixel |
|
35 |
- IOW2 ( y short ) |
|
36 |
- IOW2 ( x short ) |
|
37 |
- IOW ( color byte ) |
|
38 |
- IOW ( redraw byte ) |
|
39 |
- RTS |
|
40 |
- |
|
41 |
-|d000 @ERROR BRK |
|
42 |
-|FFF0 [ f2ac 35bb 2b53 ] ( palette ) |
|
43 |
-|FFFA .RESET .FRAME .ERROR |
44 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,36 +0,0 @@ |
1 |
-( screen ) |
|
2 |
- |
|
3 |
-:dev/r fff8 ( std read port ) |
|
4 |
-:dev/w fff9 ( std write port ) |
|
5 |
- |
|
6 |
-;width 2 ;height 2 |
|
7 |
- |
|
8 |
-|0100 @RESET |
|
9 |
- |
|
10 |
- ( set read/write to dev/screen ) |
|
11 |
- #01 DUP =dev/r =dev/w |
|
12 |
- |
|
13 |
- ( load screen size ) |
|
14 |
- #00 IOR2 =width |
|
15 |
- #02 IOR2 =height |
|
16 |
- |
|
17 |
- ( draw pixel at screen center ) |
|
18 |
- #0101 |
|
19 |
- ~width #0002 DIV2 |
|
20 |
- ~height #0002 DIV2 |
|
21 |
- ,putpixel JSR |
|
22 |
- |
|
23 |
-BRK |
|
24 |
- |
|
25 |
-|c000 @FRAME BRK |
|
26 |
- |
|
27 |
-@putpixel |
|
28 |
- IOW2 ( y short ) |
|
29 |
- IOW2 ( x short ) |
|
30 |
- IOW ( color byte ) |
|
31 |
- IOW ( redraw byte ) |
|
32 |
- RTS |
|
33 |
- |
|
34 |
-|d000 @ERROR BRK |
|
35 |
-|FFF0 [ f2ac 35bb 2b53 ] ( palette ) |
|
36 |
-|FFFA .RESET .FRAME .ERROR |
37 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,35 +0,0 @@ |
1 |
-( sprite ) |
|
2 |
- |
|
3 |
-:dev/w fff9 ( const write port ) |
|
4 |
- |
|
5 |
-|0100 @RESET |
|
6 |
- |
|
7 |
- #01 =dev/w ( set dev/write to screen ) |
|
8 |
- #02 =dev/w ( set dev/write to sprite ) |
|
9 |
- |
|
10 |
- #0110 ,cursor_icn #20 #38 ,drawsprite JSR |
|
11 |
- #0010 ,rounds_chr #28 #38 ,drawsprite JSR |
|
12 |
- #3210 ,cursor_icn #20 #40 ,drawsprite JSR |
|
13 |
- #0010 ,rounds_chr #28 #40 ,drawsprite JSR |
|
14 |
- |
|
15 |
-BRK |
|
16 |
- |
|
17 |
-@drawsprite |
|
18 |
- IOW ( y byte ) |
|
19 |
- IOW ( x byte ) |
|
20 |
- IOW2 ( sprite address ) |
|
21 |
- IOW2 ( redraw byte ) |
|
22 |
- RTS |
|
23 |
- |
|
24 |
-|0200 @SPRITESHEET |
|
25 |
- |
|
26 |
-@cursor_icn [ 80c0 e0f0 f8e0 1000 ] |
|
27 |
-@rounds_chr [ 3844 92aa 9244 3800 0038 7c7c 7c38 0000 ] |
|
28 |
- |
|
29 |
-BRK |
|
30 |
- |
|
31 |
-|c000 @FRAME BRK |
|
32 |
-|d000 @ERROR BRK |
|
33 |
- |
|
34 |
-|FFF0 [ f2ac 35bb 2b53 ] ( palette ) |
|
35 |
-|FFFA .RESET .FRAME .ERROR |