... | ... |
@@ -58,11 +58,13 @@ RTN |
58 | 58 |
- Shortcut to export/import disk state |
59 | 59 |
- Implement Uxambly REPL |
60 | 60 |
- Load disks at a different place than 0x0000. |
61 |
+- Curl device? 8-bit web browser? |
|
61 | 62 |
|
62 | 63 |
## Palettes |
63 | 64 |
|
64 |
-- `[ 6a03 4a0d aa0c ]`, purple/cyan |
|
65 |
-- `[ a1f3 a14d a16c ]`, grey-pink/teal |
|
65 |
+- `#6a03` `#4a0d` `#aa0c`, purple/cyan |
|
66 |
+- `#a1f3` `#a14d` `#a16c`, grey-pink/teal |
|
67 |
+- `#8c4b` `#884b` `#e8bb`, commodore64 |
|
66 | 68 |
|
67 | 69 |
## Refs |
68 | 70 |
|
39 | 39 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,46 @@ |
1 |
+</$objtype/mkfile |
|
2 |
+ |
|
3 |
+TARG=assembler debugger emulator |
|
4 |
+ROM=assembler left nasu neralie noodle orca |
|
5 |
+CFLAGS=$CFLAGS -I/sys/include/npe |
|
6 |
+BIN=/$objtype/bin/uxn |
|
7 |
+HFILES=\ |
|
8 |
+ /sys/include/npe/stdio.h\ |
|
9 |
+ src/apu.h\ |
|
10 |
+ src/ppu.h\ |
|
11 |
+ src/uxn.h\ |
|
12 |
+ |
|
13 |
+CLEANFILES=${TARG:%=bin/%} ${ROM:%=bin/%.rom} |
|
14 |
+ |
|
15 |
+default:V: all |
|
16 |
+ |
|
17 |
+all:V: ${TARG:%=bin/%} ${ROM:%=bin/%.rom} |
|
18 |
+ |
|
19 |
+</sys/src/cmd/mkmany |
|
20 |
+ |
|
21 |
+/sys/include/npe/stdio.h: |
|
22 |
+ hget https://git.sr.ht/~ft/npe/archive/master.tar.gz | tar xz && |
|
23 |
+ cd npe-master && |
|
24 |
+ mk install && |
|
25 |
+ rm -r npe-master |
|
26 |
+ |
|
27 |
+bin/%.rom: projects/software/%.usm bin/assembler |
|
28 |
+ bin/assembler projects/software/$stem.usm $target |
|
29 |
+ |
|
30 |
+bin/assembler:Q: $O.assembler |
|
31 |
+ mkdir -p bin && cp $prereq $target |
|
32 |
+ |
|
33 |
+bin/debugger:Q: $O.debugger |
|
34 |
+ mkdir -p bin && cp $prereq $target |
|
35 |
+ |
|
36 |
+bin/emulator:Q: $O.emulator |
|
37 |
+ mkdir -p bin && cp $prereq $target |
|
38 |
+ |
|
39 |
+$O.assembler: assembler.$O |
|
40 |
+ |
|
41 |
+$O.debugger: debugger.$O uxn.$O |
|
42 |
+ |
|
43 |
+$O.emulator: emulator.$O apu.$O ppu.$O uxn.$O |
|
44 |
+ |
|
45 |
+%.$O: src/%.c |
|
46 |
+ $CC $CFLAGS -Isrc -o $target src/$stem.c |
... | ... |
@@ -1,67 +1,188 @@ |
1 | 1 |
( Dev/File ) |
2 | 2 |
|
3 | 3 |
%RTN { JMP2r } |
4 |
+%STEP8 { #0033 SFT2 } |
|
5 |
+%++ { #01 ADD } |
|
6 |
+ |
|
7 |
+%MEMORY { #1000 } |
|
8 |
+ |
|
9 |
+;loadbtn { x 2 y 2 } |
|
10 |
+;output { x 2 y 2 } |
|
11 |
+;pointer { x 2 y 2 } |
|
12 |
+;label { x 2 y 2 color 1 addr 2 } |
|
4 | 13 |
|
5 | 14 |
( devices ) |
6 | 15 |
|
7 |
-|0100 ;Console { pad 8 char 1 byte 1 short 2 } |
|
8 |
-|0160 ;File { offset 2 append 1 pad 5 name 2 length 2 load 2 save 2 } |
|
9 |
-|01F0 .RESET .FRAME .ERROR ( vectors ) |
|
10 |
-|01F8 [ 13fd 1ef3 1bf2 ] ( palette ) |
|
16 |
+|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |
|
17 |
+|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 } |
|
18 |
+|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } |
|
19 |
+|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |
|
20 |
+|0170 ;File { vector 2 pad 6 name 2 length 2 load 2 save 2 } |
|
11 | 21 |
|
12 | 22 |
( program ) |
13 | 23 |
|
14 |
-|0200 @RESET |
|
15 |
- |
|
16 |
- #11 |
|
17 |
- $loop |
|
18 |
- ,text1 ,print-label JSR2 |
|
19 |
- ,scramble JSR2 |
|
20 |
- #01 SUB DUP ,$loop ROT JNZ2 |
|
24 |
+|0200 |
|
25 |
+ |
|
26 |
+ ( theme ) #804b =System.r #804b =System.g #e0bb =System.b |
|
27 |
+ ( vectors ) ,on-mouse =Mouse.vector |
|
28 |
+ ( vectors ) ,on-transfer =File.vector |
|
29 |
+ |
|
30 |
+ #0020 =loadbtn.x |
|
31 |
+ #0020 =loadbtn.y |
|
32 |
+ #0020 =output.x |
|
33 |
+ #0030 =output.y |
|
34 |
+ |
|
35 |
+ ~loadbtn.x ~loadbtn.y #26 ,load_txt ,draw-label JSR2 |
|
36 |
+ |
|
37 |
+ ,draw-file JSR2 |
|
21 | 38 |
|
22 | 39 |
BRK |
23 | 40 |
|
24 |
-@print-label ( text ) |
|
25 |
- |
|
26 |
- $loop NOP |
|
27 |
- ( send ) DUP2 PEK2 =Console.char |
|
28 |
- ( incr ) #0001 ADD2 |
|
29 |
- ( loop ) DUP2 PEK2 #00 NEQ ^$loop MUL JMP |
|
41 |
+@on-transfer ( -> ) |
|
42 |
+ |
|
43 |
+ ,draw-file JSR2 |
|
44 |
+ ~output.x ~output.y #0088 ADD2 #23 ,done_txt ,draw-label JSR2 |
|
45 |
+ ( release ) #00 =Mouse.state |
|
46 |
+ |
|
47 |
+BRK |
|
48 |
+ |
|
49 |
+@on-mouse ( -> ) |
|
50 |
+ |
|
51 |
+ ~loadbtn.x ~loadbtn.y #26 ,load_txt ,draw-label JSR2 |
|
52 |
+ ~loadbtn.x #0028 ADD2 ~loadbtn.y #23 ,srcpath ,draw-label JSR2 |
|
53 |
+ |
|
54 |
+ ~Mouse.state #00 EQU ^$touch-end JNZ |
|
55 |
+ |
|
56 |
+ ~Mouse.y STEP8 ~loadbtn.y NEQ2 ^$no-touch-load JNZ |
|
57 |
+ ~loadbtn.x ~loadbtn.y #27 ,load_txt ,draw-label JSR2 |
|
58 |
+ ,srcpath #0100 ,load-file JSR2 |
|
59 |
+ ( release ) #00 =Mouse.state |
|
60 |
+ $no-touch-load |
|
61 |
+ |
|
62 |
+ $touch-end |
|
63 |
+ |
|
64 |
+ ,draw-cursor JSR2 |
|
65 |
+ |
|
66 |
+BRK |
|
67 |
+ |
|
68 |
+@draw-file ( -- ) |
|
69 |
+ |
|
70 |
+ #00 #10 |
|
71 |
+ $ver |
|
72 |
+ ( pos-y ) OVR #00 SWP #0008 MUL2 ~output.y ADD2 =Screen.y |
|
73 |
+ #00 #10 |
|
74 |
+ $hor |
|
75 |
+ ( pos-x ) OVR #00 SWP #0008 MUL2 ~output.x ADD2 =Screen.x |
|
76 |
+ ( get x,y ) SWP2 OVR STH SWP2 OVR STHr |
|
77 |
+ ( get id ) #10 MUL ADD |
|
78 |
+ ( get data ) #00 SWP MEMORY ADD2 PEK2 |
|
79 |
+ ( get sprite ) #20 SUB #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr |
|
80 |
+ ( draw ) #2d =Screen.color |
|
81 |
+ ( incr ) SWP ++ SWP |
|
82 |
+ DUP2 NEQ ^$hor JNZ |
|
83 |
+ POP2 |
|
84 |
+ ( incr ) SWP ++ SWP |
|
85 |
+ DUP2 NEQ ^$ver JNZ |
|
30 | 86 |
POP2 |
31 | 87 |
|
32 | 88 |
RTN |
33 | 89 |
|
34 |
-@scramble |
|
35 |
- |
|
36 |
- ,filename =File.name |
|
37 |
- |
|
38 |
- #00 =File.append |
|
39 |
- #0000 =File.offset |
|
40 |
- #0003 =File.length |
|
41 |
- ,text1 #000d ADD2 =File.save |
|
42 |
- |
|
43 |
- #01 =File.append |
|
44 |
- #0003 =File.offset |
|
45 |
- #000d =File.length |
|
46 |
- ,text1 =File.save |
|
90 |
+@load-file ( path length -- ) |
|
47 | 91 |
|
48 |
- #0000 =File.offset |
|
49 |
- #0004 =File.length |
|
50 |
- ,text1 =File.load |
|
51 |
- |
|
52 |
- #0004 =File.offset |
|
53 |
- #0008 =File.length |
|
54 |
- ,text1 #0008 ADD2 =File.load |
|
92 |
+ =File.length =File.name MEMORY =File.load |
|
93 |
+ |
|
94 |
+RTN |
|
95 |
+ |
|
96 |
+@draw-cursor ( -- ) |
|
97 |
+ |
|
98 |
+ ( clear last cursor ) |
|
99 |
+ ,clear_icn =Screen.addr |
|
100 |
+ ~pointer.x =Screen.x |
|
101 |
+ ~pointer.y =Screen.y |
|
102 |
+ #30 =Screen.color |
|
103 |
+ |
|
104 |
+ ( record pointer positions ) |
|
105 |
+ ~Mouse.x =pointer.x ~Mouse.y =pointer.y |
|
106 |
+ |
|
107 |
+ ( draw new cursor ) |
|
108 |
+ ,cursor_icn =Screen.addr |
|
109 |
+ ~pointer.x =Screen.x |
|
110 |
+ ~pointer.y =Screen.y |
|
111 |
+ #32 ~Mouse.state #00 NEQ ADD =Screen.color |
|
112 |
+ |
|
113 |
+RTN |
|
114 |
+ |
|
115 |
+@draw-label ( x y color addr -- ) |
|
55 | 116 |
|
56 |
- #000c =File.offset |
|
57 |
- #0004 =File.length |
|
58 |
- ,text1 #0004 ADD2 =File.load |
|
117 |
+ ( load ) =label.addr =label.color =Screen.y =Screen.x |
|
118 |
+ ~label.addr |
|
119 |
+ $loop |
|
120 |
+ ( draw ) DUP2 PEK2 #20 SUB #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr ~label.color =Screen.color |
|
121 |
+ ( incr ) #0001 ADD2 |
|
122 |
+ ( incr ) ~Screen.x #0008 ADD2 =Screen.x |
|
123 |
+ DUP2 PEK2 #00 NEQ ^$loop JNZ |
|
124 |
+ POP2 |
|
59 | 125 |
|
60 | 126 |
RTN |
61 | 127 |
|
128 |
+@clear_icn [ 0000 0000 0000 0000 ] |
|
129 |
+@cursor_icn [ 80c0 e0f0 f8e0 1000 ] |
|
130 |
+ |
|
131 |
+@done_txt [ LOAD 20 SUCCESS! 00 ] |
|
132 |
+@load_txt [ LOAD 00 ] |
|
133 |
+@save_txt [ SAVE 00 ] |
|
62 | 134 |
|
63 |
-@text1 [ Welcome 20 to 20 UxnVM 0a00 ] |
|
64 |
-@filename [ textio.bit ] |
|
135 |
+@srcpath [ README.md 00 ] |
|
136 |
+@dstpath [ bin/export.md 00 ] |
|
65 | 137 |
|
66 |
-@FRAME BRK |
|
67 |
-@ERROR BRK |
|
138 |
+@font ( specter8-frag font ) |
|
139 |
+[ |
|
140 |
+ 0000 0000 0000 0000 0008 0808 0800 0800 |
|
141 |
+ 0014 1400 0000 0000 0024 7e24 247e 2400 |
|
142 |
+ 0008 1e28 1c0a 3c08 0000 2204 0810 2200 |
|
143 |
+ 0030 4832 4c44 3a00 0008 1000 0000 0000 |
|
144 |
+ 0004 0808 0808 0400 0020 1010 1010 2000 |
|
145 |
+ 0000 2214 0814 2200 0000 0808 3e08 0800 |
|
146 |
+ 0000 0000 0000 0810 0000 0000 3e00 0000 |
|
147 |
+ 0000 0000 0000 0800 0000 0204 0810 2000 |
|
148 |
+ 003c 464a 5262 3c00 0018 0808 0808 1c00 |
|
149 |
+ 003c 4202 3c40 7e00 003c 421c 0242 3c00 |
|
150 |
+ 000c 1424 447e 0400 007e 407c 0242 3c00 |
|
151 |
+ 003c 407c 4242 3c00 007e 0204 0810 1000 |
|
152 |
+ 003c 423c 4242 3c00 003c 4242 3e02 3c00 |
|
153 |
+ 0000 0010 0000 1000 0000 1000 0010 1020 |
|
154 |
+ 0000 0810 2010 0800 0000 003e 003e 0000 |
|
155 |
+ 0000 1008 0408 1000 003c 420c 1000 1000 |
|
156 |
+ 003c 4232 4a42 3c00 003c 4242 7e42 4200 |
|
157 |
+ 007c 427c 4242 7c00 003c 4240 4042 3c00 |
|
158 |
+ 007c 4242 4242 7c00 007e 4078 4040 7e00 |
|
159 |
+ 007e 4078 4040 4000 003c 4240 4642 3c00 |
|
160 |
+ 0042 427e 4242 4200 001c 0808 0808 1c00 |
|
161 |
+ 007e 0202 0242 3c00 0042 4478 4442 4200 |
|
162 |
+ 0040 4040 4040 7e00 0042 665a 4242 4200 |
|
163 |
+ 0042 6252 4a46 4200 003c 4242 4242 3c00 |
|
164 |
+ 007c 4242 7c40 4000 003c 4242 4244 3a00 |
|
165 |
+ 007c 4242 7c44 4200 003e 403c 0242 3c00 |
|
166 |
+ 007e 0808 0808 1000 0042 4242 4244 3a00 |
|
167 |
+ 0042 4242 4224 1800 0042 4242 5a66 4200 |
|
168 |
+ 0042 423c 4242 4200 0042 423e 0242 3c00 |
|
169 |
+ 007e 020c 3040 7e00 000c 0808 0808 0c00 |
|
170 |
+ 0040 2010 0804 0200 0030 1010 1010 3000 |
|
171 |
+ 0008 1400 0000 0000 0000 0000 0000 7e00 |
|
172 |
+ 0008 0400 0000 0000 0000 3c02 3e42 3a00 |
|
173 |
+ 0040 407c 4242 7c00 0000 3c42 4042 3c00 |
|
174 |
+ 0002 023e 4242 3e00 0000 3c42 7e40 3e00 |
|
175 |
+ 0000 3e40 7840 4000 0000 3c42 3e02 3c00 |
|
176 |
+ 0040 405c 6242 4200 0008 0018 0808 0400 |
|
177 |
+ 0008 0018 0808 4830 0040 4244 7844 4200 |
|
178 |
+ 0010 1010 1010 0c00 0000 6c52 5252 5200 |
|
179 |
+ 0000 5c62 4242 4200 0000 3c42 4242 3c00 |
|
180 |
+ 0000 7c42 427c 4040 0000 3e42 423e 0202 |
|
181 |
+ 0000 5c62 4040 4000 0000 3e40 3c02 7c00 |
|
182 |
+ 0008 7e08 0808 1000 0000 4242 4244 3a00 |
|
183 |
+ 0000 4242 4224 1800 0000 5252 5252 2e00 |
|
184 |
+ 0000 4224 1824 4200 0000 4242 3e02 7c00 |
|
185 |
+ 0000 7e02 3c40 7e00 000c 0810 1008 0c00 |
|
186 |
+ 0008 0808 0808 0800 0030 1008 0810 3000 |
|
187 |
+ 0000 0032 4c00 0000 3c42 99a1 a199 423c |
|
188 |
+] |
|
68 | 189 |
\ No newline at end of file |
... | ... |
@@ -13,6 +13,8 @@ |
13 | 13 |
;pointer { x 2 y 2 } |
14 | 14 |
;circle { xc 2 yc 2 x 2 y 2 r 2 d 2 } |
15 | 15 |
|
16 |
+( devices ) |
|
17 |
+ |
|
16 | 18 |
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |
17 | 19 |
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } |
18 | 20 |
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |
... | ... |
@@ -47,7 +47,7 @@ |
47 | 47 |
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } |
48 | 48 |
|0140 ;Controller { vector 2 button 1 key 1 } |
49 | 49 |
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |
50 |
-|0170 ;File { pad 8 name 2 length 2 load 2 save 2 } |
|
50 |
+|0170 ;File { vector 2 pad 6 name 2 length 2 load 2 save 2 } |
|
51 | 51 |
|
52 | 52 |
( program ) |
53 | 53 |
|
... | ... |
@@ -36,7 +36,7 @@ |
36 | 36 |
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } |
37 | 37 |
|0140 ;Controller { vector 2 button 1 key 1 } |
38 | 38 |
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |
39 |
-|0170 ;File { pad 8 name 2 length 2 load 2 save 2 } |
|
39 |
+|0170 ;File { vector 2 pad 6 name 2 length 2 load 2 save 2 } |
|
40 | 40 |
|
41 | 41 |
( program ) |
42 | 42 |
|
... | ... |
@@ -56,7 +56,7 @@ |
56 | 56 |
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } |
57 | 57 |
|0140 ;Controller { vector 2 button 1 key 1 } |
58 | 58 |
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |
59 |
-|0170 ;File { pad 8 name 2 length 2 load 2 save 2 } |
|
59 |
+|0170 ;File { vector 2 pad 6 name 2 length 2 load 2 save 2 } |
|
60 | 60 |
|
61 | 61 |
( program ) |
62 | 62 |
|
... | ... |
@@ -225,10 +225,11 @@ RTN |
225 | 225 |
( get right ) DUP2 SWP ++ SWP GET-CELL-VALUE STH |
226 | 226 |
( incr y ) ++ |
227 | 227 |
( get result ) SUBr STHr |
228 |
- DUP =Console.byte |
|
229 | 228 |
GET-CHAR |
230 | 229 |
SET-CELL |
231 | 230 |
|
231 |
+ ( NOTE: Issue is not with modulo, but with converting ff to 36 ) |
|
232 |
+ |
|
232 | 233 |
RTN |
233 | 234 |
|
234 | 235 |
@op-c ( x y char -- ) |
... | ... |
@@ -23,7 +23,7 @@ static SDL_Renderer *gRenderer; |
23 | 23 |
static SDL_Texture *gTexture; |
24 | 24 |
static Ppu ppu; |
25 | 25 |
static Apu apu; |
26 |
-static Device *devsystem, *devscreen, *devmouse, *devctrl, *devapu; |
|
26 |
+static Device *devsystem, *devscreen, *devmouse, *devctrl, *devapu, *devfile; |
|
27 | 27 |
|
28 | 28 |
Uint8 zoom = 0, debug = 0, reqdraw = 0; |
29 | 29 |
|
... | ... |
@@ -219,13 +219,14 @@ file_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1) |
219 | 219 |
Uint8 *m = u->ram.dat; |
220 | 220 |
char *name = (char *)&m[(m[ptr + 8] << 8) + m[ptr + 8 + 1]]; |
221 | 221 |
Uint16 length = (m[ptr + 8 + 2] << 8) + m[ptr + 8 + 3]; |
222 |
- Uint16 offset = (m[ptr + 0] << 8) + m[ptr + 1]; |
|
222 |
+ Uint16 offset = (m[ptr + 2] << 8) + m[ptr + 3]; |
|
223 | 223 |
if(b0 == 0x0d) { |
224 | 224 |
Uint16 addr = (m[ptr + 8 + 4] << 8) + b1; |
225 | 225 |
FILE *f = fopen(name, "r"); |
226 | 226 |
if(f && fseek(f, offset, SEEK_SET) != -1 && fread(&m[addr], length, 1, f)) { |
227 | 227 |
fclose(f); |
228 | 228 |
printf("Loaded %d bytes, at %04x from %s\n", length, addr, name); |
229 |
+ evaluxn(u, devfile->vector); |
|
229 | 230 |
} |
230 | 231 |
} else if(b0 == 0x0f) { |
231 | 232 |
Uint16 addr = (m[ptr + 8 + 6] << 8) + b1; |
... | ... |
@@ -233,6 +234,7 @@ file_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1) |
233 | 234 |
if(f && fseek(f, offset, SEEK_SET) != -1 && fwrite(&m[addr], length, 1, f)) { |
234 | 235 |
fclose(f); |
235 | 236 |
printf("Saved %d bytes, at %04x from %s\n", length, addr, name); |
237 |
+ evaluxn(u, devfile->vector); |
|
236 | 238 |
} |
237 | 239 |
} |
238 | 240 |
return b1; |
... | ... |
@@ -378,7 +380,7 @@ main(int argc, char **argv) |
378 | 380 |
devctrl = portuxn(&u, 0x04, "controller", ppnil); |
379 | 381 |
portuxn(&u, 0x05, "---", ppnil); |
380 | 382 |
devmouse = portuxn(&u, 0x06, "mouse", ppnil); |
381 |
- portuxn(&u, 0x07, "file", file_poke); |
|
383 |
+ devfile = portuxn(&u, 0x07, "file", file_poke); |
|
382 | 384 |
portuxn(&u, 0x08, "---", ppnil); |
383 | 385 |
portuxn(&u, 0x09, "midi", ppnil); |
384 | 386 |
portuxn(&u, 0x0a, "datetime", datetime_poke); |
... | ... |
@@ -12,7 +12,7 @@ WITH REGARD TO THIS SOFTWARE. |
12 | 12 |
|
13 | 13 |
#include "ppu.h" |
14 | 14 |
|
15 |
-Uint8 font[][8] = { |
|
15 |
+static Uint8 font[][8] = { |
|
16 | 16 |
{0x00, 0x3c, 0x46, 0x4a, 0x52, 0x62, 0x3c, 0x00}, |
17 | 17 |
{0x00, 0x18, 0x28, 0x08, 0x08, 0x08, 0x3e, 0x00}, |
18 | 18 |
{0x00, 0x3c, 0x42, 0x02, 0x3c, 0x40, 0x7e, 0x00}, |