1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,155 @@ |
1 |
+( Draw a 8x8 font ) |
|
2 |
+ |
|
3 |
+%+ { ADD } %- { SUB } %* { MUL } %/ { DIV } |
|
4 |
+%< { LTH } %> { GTH } %= { EQU } %! { NEQ } |
|
5 |
+%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 } |
|
6 |
+%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 } |
|
7 |
+ |
|
8 |
+%AUTO-X { #01 .Screen/auto DEO } |
|
9 |
+ |
|
10 |
+( devices ) |
|
11 |
+ |
|
12 |
+|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1 |
|
13 |
+|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 |
|
14 |
+ |
|
15 |
+( variables ) |
|
16 |
+ |
|
17 |
+|0000 |
|
18 |
+ |
|
19 |
+( program ) |
|
20 |
+ |
|
21 |
+|0100 |
|
22 |
+ |
|
23 |
+ ( theme ) |
|
24 |
+ #f05d .System/r DEO2 |
|
25 |
+ #f0cd .System/g DEO2 |
|
26 |
+ #f0ad .System/b DEO2 |
|
27 |
+ |
|
28 |
+ ( draw hello world ) |
|
29 |
+ #0010 .Screen/x DEO2 |
|
30 |
+ #0010 .Screen/y DEO2 |
|
31 |
+ ;hello-txt #01 ;draw-uf1 JSR2 |
|
32 |
+ |
|
33 |
+ ( draw long text ) |
|
34 |
+ #0010 .Screen/x DEO2 |
|
35 |
+ #0030 .Screen/y DEO2 |
|
36 |
+ ;long-txt #02 ;draw-uf1-linebreaks JSR2 |
|
37 |
+ |
|
38 |
+BRK |
|
39 |
+ |
|
40 |
+@draw-uf1 ( string* color -- ) |
|
41 |
+ |
|
42 |
+ AUTO-X |
|
43 |
+ STH |
|
44 |
+ &while |
|
45 |
+ ( get sprite ) LDAk #20 - #00 SWP #30 SFT2 ;font ++ .Screen/addr DEO2 |
|
46 |
+ ( draw ) STHkr .Screen/sprite DEO |
|
47 |
+ INC2 LDAk ,&while JCN |
|
48 |
+ POPr |
|
49 |
+ |
|
50 |
+JMP2r |
|
51 |
+ |
|
52 |
+@draw-uf1-linebreaks ( string* color -- ) |
|
53 |
+ |
|
54 |
+ .Screen/x DEI2 ,&anchor STR2 |
|
55 |
+ AUTO-X |
|
56 |
+ STH |
|
57 |
+ &while |
|
58 |
+ LDAk #0a ! ,&no-lb JCN |
|
59 |
+ ( rewind ) LIT2 &anchor $2 .Screen/x DEO2 |
|
60 |
+ ( skip line ) .Screen/y DEI2k #0008 ++ ROT DEO2 |
|
61 |
+ ,&end JMP |
|
62 |
+ &no-lb |
|
63 |
+ ( get sprite ) LDAk #20 - #00 SWP #30 SFT2 ;font ++ .Screen/addr DEO2 |
|
64 |
+ ( draw ) STHkr .Screen/sprite DEO |
|
65 |
+ &end |
|
66 |
+ INC2 LDAk ,&while JCN |
|
67 |
+ POPr |
|
68 |
+ |
|
69 |
+JMP2r |
|
70 |
+ |
|
71 |
+@hello-txt "Hello 20 "Uxn! $1 |
|
72 |
+ |
|
73 |
+@long-txt |
|
74 |
+ 5275 7374 6963 2043 6f6d 7075 7469 6e67 |
|
75 |
+ 2072 6566 6572 7320 746f 2074 6865 2063 |
|
76 |
+ 6f6e 7374 7275 6374 696f 6e20 0a6f 6620 |
|
77 |
+ 6361 6c63 756c 6174 696f 6e20 6d61 6368 |
|
78 |
+ 696e 6573 2075 7369 6e67 2070 7265 2d69 |
|
79 |
+ 6e64 7573 7472 6961 6c20 0a6f 7220 6576 |
|
80 |
+ 656e 2070 7265 2d68 6973 746f 7269 6320 |
|
81 |
+ 7465 6368 6e6f 6c6f 6779 2e20 0a0a 4974 |
|
82 |
+ 2072 6576 6561 6c73 2061 2068 6973 746f |
|
83 |
+ 7279 206f 6620 636f 6d70 7574 696e 6720 |
|
84 |
+ 6173 2074 6865 200a 7061 7374 696d 6520 |
|
85 |
+ 6f66 2064 696c 6574 7461 6e74 6573 2c20 |
|
86 |
+ 616d 6174 6575 7220 7363 6965 6e74 6973 |
|
87 |
+ 7473 0a61 6e64 2074 6162 756c 6174 6f72 |
|
88 |
+ 7320 7768 6f20 636f 6e73 7472 7563 7420 |
|
89 |
+ 6d61 6368 696e 6573 2074 6f20 0a6d 616e |
|
90 |
+ 6970 756c 6174 6520 6162 7374 7261 6374 |
|
91 |
+ 2073 796d 626f 6c73 2077 6974 6820 6e6f |
|
92 |
+ 2070 7261 6374 6963 616c 200a 6170 706c |
|
93 |
+ 6963 6174 696f 6e2e 2041 7320 7468 6573 |
|
94 |
+ 6520 6d61 6368 696e 6573 2061 7265 2067 |
|
95 |
+ 656e 6572 616c 6c79 200a 6c65 7373 2065 |
|
96 |
+ 6666 6963 6965 6e74 2074 6861 6e20 636f |
|
97 |
+ 6e76 656e 7469 6f6e 616c 2070 656e 6369 |
|
98 |
+ 6c20 616e 6420 0a70 6170 6572 2063 6f6d |
|
99 |
+ 7075 7461 7469 6f6e 2c20 7468 6579 2061 |
|
100 |
+ 6c6c 7564 6520 746f 2061 206d 6f72 6520 |
|
101 |
+ 0a65 7069 6375 7265 616e 2070 7261 6374 |
|
102 |
+ 6963 6520 6f66 2063 6f6d 7075 7469 6e67 |
|
103 |
+ 2066 6f72 2070 6c65 6173 7572 6520 0a72 |
|
104 |
+ 6174 6865 7220 7468 616e 2070 726f 6475 |
|
105 |
+ 6374 696f 6e2e |
|
106 |
+ |
|
107 |
+@font ( bbcmicro ) |
|
108 |
+ 0000 0000 0000 0000 1818 1818 1800 1800 |
|
109 |
+ 6c6c 6c00 0000 0000 3636 7f36 7f36 3600 |
|
110 |
+ 0c3f 683e 0b7e 1800 6066 0c18 3066 0600 |
|
111 |
+ 386c 6c38 6d66 3b00 0c18 3000 0000 0000 |
|
112 |
+ 0c18 3030 3018 0c00 3018 0c0c 0c18 3000 |
|
113 |
+ 0018 7e3c 7e18 0000 0018 187e 1818 0000 |
|
114 |
+ 0000 0000 0018 1830 0000 007e 0000 0000 |
|
115 |
+ 0000 0000 0018 1800 0006 0c18 3060 0000 |
|
116 |
+ 3c66 6e7e 7666 3c00 1838 1818 1818 7e00 |
|
117 |
+ 3c66 060c 1830 7e00 3c66 061c 0666 3c00 |
|
118 |
+ 0c1c 3c6c 7e0c 0c00 7e60 7c06 0666 3c00 |
|
119 |
+ 1c30 607c 6666 3c00 7e06 0c18 3030 3000 |
|
120 |
+ 3c66 663c 6666 3c00 3c66 663e 060c 3800 |
|
121 |
+ 0000 1818 0018 1800 0000 1818 0018 1830 |
|
122 |
+ 0c18 3060 3018 0c00 0000 7e00 7e00 0000 |
|
123 |
+ 3018 0c06 0c18 3000 3c66 0c18 1800 1800 |
|
124 |
+ 3c66 6e6a 6e60 3c00 3c66 667e 6666 6600 |
|
125 |
+ 7c66 667c 6666 7c00 3c66 6060 6066 3c00 |
|
126 |
+ 786c 6666 666c 7800 7e60 607c 6060 7e00 |
|
127 |
+ 7e60 607c 6060 6000 3c66 606e 6666 3c00 |
|
128 |
+ 6666 667e 6666 6600 7e18 1818 1818 7e00 |
|
129 |
+ 3e0c 0c0c 0c6c 3800 666c 7870 786c 6600 |
|
130 |
+ 6060 6060 6060 7e00 6377 7f6b 6b63 6300 |
|
131 |
+ 6666 767e 6e66 6600 3c66 6666 6666 3c00 |
|
132 |
+ 7c66 667c 6060 6000 3c66 6666 6a6c 3600 |
|
133 |
+ 7c66 667c 6c66 6600 3c66 603c 0666 3c00 |
|
134 |
+ 7e18 1818 1818 1800 6666 6666 6666 3c00 |
|
135 |
+ 6666 6666 663c 1800 6363 6b6b 7f77 6300 |
|
136 |
+ 6666 3c18 3c66 6600 6666 663c 1818 1800 |
|
137 |
+ 7e06 0c18 3060 7e00 7c60 6060 6060 7c00 |
|
138 |
+ 0060 3018 0c06 0000 3e06 0606 0606 3e00 |
|
139 |
+ 183c 6642 0000 0000 0000 0000 0000 00ff |
|
140 |
+ 1c36 307c 3030 7e00 0000 3c06 3e66 3e00 |
|
141 |
+ 6060 7c66 6666 7c00 0000 3c66 6066 3c00 |
|
142 |
+ 0606 3e66 6666 3e00 0000 3c66 7e60 3c00 |
|
143 |
+ 1c30 307c 3030 3000 0000 3e66 663e 063c |
|
144 |
+ 6060 7c66 6666 6600 1800 3818 1818 3c00 |
|
145 |
+ 1800 3818 1818 1870 6060 666c 786c 6600 |
|
146 |
+ 3818 1818 1818 3c00 0000 367f 6b6b 6300 |
|
147 |
+ 0000 7c66 6666 6600 0000 3c66 6666 3c00 |
|
148 |
+ 0000 7c66 667c 6060 0000 3e66 663e 0607 |
|
149 |
+ 0000 6c76 6060 6000 0000 3e60 3c06 7c00 |
|
150 |
+ 3030 7c30 3030 1c00 0000 6666 6666 3e00 |
|
151 |
+ 0000 6666 663c 1800 0000 636b 6b7f 3600 |
|
152 |
+ 0000 663c 183c 6600 0000 6666 663e 063c |
|
153 |
+ 0000 7e0c 1830 7e00 0c18 1870 1818 0c00 |
|
154 |
+ 1818 1800 1818 1800 3018 180e 1818 3000 |
|
155 |
+ 316b 4600 0000 0000 ffff ffff ffff ffff |
... | ... |
@@ -23,19 +23,22 @@ static const char *errors[] = { |
23 | 23 |
"Return-stack division by zero"}; |
24 | 24 |
|
25 | 25 |
static void |
26 |
-print_stack(Stack *s, char *name) |
|
26 |
+system_print(Stack *s, char *name) |
|
27 | 27 |
{ |
28 |
- Uint8 x, y; |
|
29 |
- fprintf(stderr, "\n%s\n", name); |
|
30 |
- for(y = 0; y < 0x04; y++) { |
|
31 |
- for(x = 0; x < 0x08; x++) { |
|
32 |
- Uint8 p = y * 0x08 + x; |
|
33 |
- fprintf(stderr, |
|
34 |
- p == s->ptr ? "[%02x]" : " %02x ", |
|
35 |
- s->dat[p]); |
|
36 |
- } |
|
37 |
- fprintf(stderr, "\n"); |
|
38 |
- } |
|
28 |
+ Uint8 i; |
|
29 |
+ fprintf(stderr, "<%s> ", name); |
|
30 |
+ for(i = 0; i < s->ptr; i++) |
|
31 |
+ fprintf(stderr, i == s->ptr ? "[%02x]" : " %02x ", s->dat[i]); |
|
32 |
+ if(!i) |
|
33 |
+ fprintf(stderr, "empty"); |
|
34 |
+ fprintf(stderr, "\n"); |
|
35 |
+} |
|
36 |
+ |
|
37 |
+void |
|
38 |
+system_inspect(Uxn *u) |
|
39 |
+{ |
|
40 |
+ system_print(&u->wst, "wst"); |
|
41 |
+ system_print(&u->rst, "rst"); |
|
39 | 42 |
} |
40 | 43 |
|
41 | 44 |
int |
... | ... |
@@ -53,16 +56,11 @@ uxn_halt(Uxn *u, Uint8 error, Uint16 addr) |
53 | 56 |
vec += 0x0004; |
54 | 57 |
return uxn_eval(u, vec); |
55 | 58 |
} |
59 |
+ system_inspect(u); |
|
56 | 60 |
fprintf(stderr, "Halted: %s#%04x, at 0x%04x\n", errors[error], u->ram[addr], addr); |
57 | 61 |
return 0; |
58 | 62 |
} |
59 | 63 |
|
60 |
-void |
|
61 |
-system_inspect(Uxn *u){ |
|
62 |
- print_stack(&u->wst, "Working-stack"); |
|
63 |
- print_stack(&u->rst, "Return-stack"); |
|
64 |
-} |
|
65 |
- |
|
66 | 64 |
/* IO */ |
67 | 65 |
|
68 | 66 |
Uint8 |
... | ... |
@@ -42,7 +42,7 @@ static SDL_Rect gRect; |
42 | 42 |
|
43 | 43 |
/* devices */ |
44 | 44 |
|
45 |
-static Device *devsystem, *devscreen, *devmouse, *devctrl, *devaudio0; |
|
45 |
+static Device *devscreen, *devmouse, *devctrl, *devaudio0; |
|
46 | 46 |
static Uint8 zoom = 1; |
47 | 47 |
static Uint32 stdin_event, audio0_event; |
48 | 48 |
|
... | ... |
@@ -292,13 +292,6 @@ set_zoom(Uint8 scale) |
292 | 292 |
set_window_size(gWindow, (uxn_screen.width + PAD * 2) * zoom, (uxn_screen.height + PAD * 2) * zoom); |
293 | 293 |
} |
294 | 294 |
|
295 |
-static void |
|
296 |
-toggle_debugger(void) |
|
297 |
-{ |
|
298 |
- devsystem->dat[0xe] = !devsystem->dat[0xe]; |
|
299 |
- screen_clear(&uxn_screen, &uxn_screen.fg); |
|
300 |
-} |
|
301 |
- |
|
302 | 295 |
static void |
303 | 296 |
capture_screen(void) |
304 | 297 |
{ |
... | ... |
@@ -390,8 +383,9 @@ console_input(Uxn *u, char c) |
390 | 383 |
static int |
391 | 384 |
run(Uxn *u) |
392 | 385 |
{ |
386 |
+ Device *devsys = &u->dev[0]; |
|
393 | 387 |
redraw(); |
394 |
- while(!devsystem->dat[0xf]) { |
|
388 |
+ while(!devsys->dat[0xf]) { |
|
395 | 389 |
SDL_Event event; |
396 | 390 |
double elapsed, begin; |
397 | 391 |
if(!BENCH) |
... | ... |
@@ -454,7 +448,7 @@ run(Uxn *u) |
454 | 448 |
console_input(u, event.cbutton.button); |
455 | 449 |
} |
456 | 450 |
uxn_eval(u, GETVECTOR(devscreen)); |
457 |
- if(uxn_screen.fg.changed || uxn_screen.bg.changed || devsystem->dat[0xe]) |
|
451 |
+ if(uxn_screen.fg.changed || uxn_screen.bg.changed) |
|
458 | 452 |
redraw(); |
459 | 453 |
if(!BENCH) { |
460 | 454 |
elapsed = (SDL_GetPerformanceCounter() - begin) / (double)SDL_GetPerformanceFrequency() * 1000.0f; |