Browse code

Moved devices in their own folders

neauoire authored on 11/05/2021 18:42:12
Showing 9 changed files
... ...
@@ -3,18 +3,18 @@
3 3
 echo "Formatting.."
4 4
 clang-format -i src/uxn.h
5 5
 clang-format -i src/uxn.c
6
-clang-format -i src/ppu.h
7
-clang-format -i src/ppu.c
8
-clang-format -i src/apu.h
9
-clang-format -i src/apu.c
10
-clang-format -i src/mpu.h
11
-clang-format -i src/mpu.c
6
+clang-format -i src/devices/ppu.h
7
+clang-format -i src/devices/ppu.c
8
+clang-format -i src/devices/apu.h
9
+clang-format -i src/devices/apu.c
10
+clang-format -i src/devices/mpu.h
11
+clang-format -i src/devices/mpu.c
12 12
 clang-format -i src/assembler.c
13 13
 clang-format -i src/emulator.c
14 14
 clang-format -i src/debugger.c
15 15
 
16 16
 echo "Cleaning.."
17
-rm -f ./bin/assembler
17
+rm -f ./bin/uxnasm
18 18
 rm -f ./bin/emulator
19 19
 rm -f ./bin/debugger
20 20
 rm -f ./bin/boot.rom
... ...
@@ -24,17 +24,17 @@ mkdir -p bin
24 24
 if [ "${1}" = '--debug' ]; 
25 25
 then
26 26
 	echo "[debug]"
27
-    cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/assembler.c -o bin/assembler
28
-	cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/uxn.c src/ppu.c src/apu.c src/mpu.c src/emulator.c -L/usr/local/lib -lSDL2 -lportmidi -o bin/emulator
27
+    cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/assembler.c -o bin/uxnasm
28
+	cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/uxn.c src/devices/ppu.c src/devices/apu.c src/devices/mpu.c src/emulator.c -L/usr/local/lib -lSDL2 -lportmidi -o bin/emulator
29 29
     cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/uxn.c src/debugger.c -o bin/debugger
30 30
 else
31
-	cc src/assembler.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o bin/assembler
31
+	cc src/assembler.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o bin/uxnasm
32 32
 	cc src/uxn.c src/debugger.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o bin/debugger
33
-	cc src/uxn.c src/ppu.c src/apu.c src/mpu.c src/emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -lportmidi -o bin/emulator
33
+	cc src/uxn.c src/devices/ppu.c src/devices/apu.c src/devices/mpu.c src/emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -lportmidi -o bin/emulator
34 34
 fi
35 35
 
36 36
 echo "Assembling.."
37
-./bin/assembler projects/demos/piano.usm bin/boot.rom
37
+./bin/uxnasm projects/demos/piano.usm bin/boot.rom
38 38
 
39 39
 echo "Running.."
40 40
 if [ "${2}" = '--cli' ]; 
... ...
@@ -47,10 +47,10 @@
47 47
 	#0f25 .System/b DEO2
48 48
 
49 49
 	( vectors ) 
50
+	;on-frame   .Screen/vector DEO2
50 51
 	;on-control .Controller/vector DEO2
51 52
 	;on-mouse   .Mouse/vector DEO2
52 53
 	;on-midi    .Midi/vector DEO2
53
-	;on-frame   .Screen/vector DEO2
54 54
 
55 55
 	( load waveform )
56 56
 	;piano-path  .File/name DEO2 #0100 .File/length DEO2 WAVEFORM .File/load DEO2
... ...
@@ -113,6 +113,52 @@ BRK
113 113
 
114 114
 BRK
115 115
 
116
+@on-control ( -> )
117
+
118
+	( clear last cursor )
119
+	#fff8 .Screen/addr DEO2 
120
+	.pointer/x LDZ2 .Screen/x DEO2 
121
+	.pointer/y LDZ2 .Screen/y DEO2 
122
+	#30 .Screen/color DEO
123
+
124
+	.Controller/key DEI
125
+	DUP #61 ! ,&no-c JCN
126
+		#00 .last-note STZ ;notes LDA ;play JSR2 &no-c
127
+	DUP #73 ! ,&no-d JCN
128
+		#01 .last-note STZ ;notes #0001 ++ LDA ;play JSR2 &no-d
129
+	DUP #64 ! ,&no-e JCN
130
+		#02 .last-note STZ ;notes #0002 ++ LDA ;play JSR2 &no-e
131
+	DUP #66 ! ,&no-f JCN
132
+		#03 .last-note STZ ;notes #0003 ++ LDA ;play JSR2 &no-f
133
+	DUP #67 ! ,&no-g JCN
134
+		#04 .last-note STZ ;notes #0004 ++ LDA ;play JSR2 &no-g
135
+	DUP #68 ! ,&no-a JCN
136
+		#05 .last-note STZ ;notes #0005 ++ LDA ;play JSR2 &no-a
137
+	DUP #6a ! ,&no-b JCN
138
+		#06 .last-note STZ ;notes #0006 ++ LDA ;play JSR2 &no-b
139
+	DUP #6b ! ,&no-c2 JCN
140
+		#07 .last-note STZ ;notes #0007 ++ LDA ;play JSR2 &no-c2
141
+	POP
142
+
143
+	( release )
144
+	#00 .Controller/key DEO
145
+
146
+	.Controller/button DEI #f0 AND
147
+	DUP #04 SFT #01 AND #01 ! ,&no-up JCN
148
+		( move ) .Audio0/addr DEI2 #0001 -- .Audio0/addr DEO2 &no-up
149
+	DUP #05 SFT #01 AND #01 ! ,&no-down JCN
150
+		( move ) .Audio0/addr DEI2 #0001 ++ .Audio0/addr DEO2 &no-down
151
+	DUP #06 SFT #01 AND #01 ! ,&no-left JCN
152
+		( move ) .Audio0/addr DEI2 #0010 -- .Audio0/addr DEO2 &no-left
153
+	DUP #07 SFT #01 AND #01 ! ,&no-right JCN
154
+		( move ) .Audio0/addr DEI2 #0010 ++ .Audio0/addr DEO2 &no-right
155
+	POP
156
+
157
+	;draw-octave JSR2
158
+	;draw-wave JSR2
159
+
160
+BRK
161
+
116 162
 @on-midi ( -> )
117 163
 	
118 164
 	.Midi/note DEI #00 ! #01 JCN [ BRK ]
... ...
@@ -204,49 +250,6 @@ BRK
204 250
 
205 251
 BRK
206 252
 
207
-@on-control ( -> )
208
-
209
-	( clear last cursor )
210
-	#fff8 .Screen/addr DEO2 
211
-	.pointer/x LDZ2 .Screen/x DEO2 
212
-	.pointer/y LDZ2 .Screen/y DEO2 
213
-	#30 .Screen/color DEO
214
-
215
-	.Controller/key DEI
216
-	DUP #61 ! ,&no-c JCN
217
-		#00 .last-note STZ ;notes LDA ;play JSR2 &no-c
218
-	DUP #73 ! ,&no-d JCN
219
-		#01 .last-note STZ ;notes #0001 ++ LDA ;play JSR2 &no-d
220
-	DUP #64 ! ,&no-e JCN
221
-		#02 .last-note STZ ;notes #0002 ++ LDA ;play JSR2 &no-e
222
-	DUP #66 ! ,&no-f JCN
223
-		#03 .last-note STZ ;notes #0003 ++ LDA ;play JSR2 &no-f
224
-	DUP #67 ! ,&no-g JCN
225
-		#04 .last-note STZ ;notes #0004 ++ LDA ;play JSR2 &no-g
226
-	DUP #68 ! ,&no-a JCN
227
-		#05 .last-note STZ ;notes #0005 ++ LDA ;play JSR2 &no-a
228
-	DUP #6a ! ,&no-b JCN
229
-		#06 .last-note STZ ;notes #0006 ++ LDA ;play JSR2 &no-b
230
-	DUP #6b ! ,&no-c2 JCN
231
-		#07 .last-note STZ ;notes #0007 ++ LDA ;play JSR2 &no-c2
232
-	POP
233
-
234
-	.Controller/button DEI #f0 AND
235
-	DUP #04 SFT #01 AND #01 ! ,&no-up JCN
236
-		( move ) .Audio0/addr DEI2 #0001 -- .Audio0/addr DEO2 &no-up
237
-	DUP #05 SFT #01 AND #01 ! ,&no-down JCN
238
-		( move ) .Audio0/addr DEI2 #0001 ++ .Audio0/addr DEO2 &no-down
239
-	DUP #06 SFT #01 AND #01 ! ,&no-left JCN
240
-		( move ) .Audio0/addr DEI2 #0010 -- .Audio0/addr DEO2 &no-left
241
-	DUP #07 SFT #01 AND #01 ! ,&no-right JCN
242
-		( move ) .Audio0/addr DEI2 #0010 ++ .Audio0/addr DEO2 &no-right
243
-	POP
244
-
245
-	;draw-octave JSR2
246
-	;draw-wave JSR2
247
-
248
-BRK
249
-
250 253
 @play ( pitch -- )
251 254
 	
252 255
 	DUP .octave LDZ #0c * + .Audio0/pitch DEO
253 256
similarity index 99%
254 257
rename from src/apu.c
255 258
rename to src/devices/apu.c
... ...
@@ -10,7 +10,7 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 10
 WITH REGARD TO THIS SOFTWARE.
11 11
 */
12 12
 
13
-#include "uxn.h"
13
+#include "../uxn.h"
14 14
 #include "apu.h"
15 15
 
16 16
 #define NOTE_PERIOD 0x10000
17 17
similarity index 100%
18 18
rename from src/apu.h
19 19
rename to src/devices/apu.h
20 20
similarity index 100%
21 21
rename from src/mpu.c
22 22
rename to src/devices/mpu.c
23 23
similarity index 100%
24 24
rename from src/mpu.h
25 25
rename to src/devices/mpu.h
26 26
similarity index 100%
27 27
rename from src/ppu.c
28 28
rename to src/devices/ppu.c
29 29
similarity index 100%
30 30
rename from src/ppu.h
31 31
rename to src/devices/ppu.h
... ...
@@ -14,9 +14,9 @@ WITH REGARD TO THIS SOFTWARE.
14 14
 */
15 15
 
16 16
 #include "uxn.h"
17
-#include "ppu.h"
18
-#include "apu.h"
19
-#include "mpu.h"
17
+#include "devices/ppu.h"
18
+#include "devices/apu.h"
19
+#include "devices/mpu.h"
20 20
 
21 21
 static SDL_AudioDeviceID audio_id;
22 22
 static SDL_Window *gWindow;
... ...
@@ -328,11 +328,10 @@ start(Uxn *u)
328 328
 				quit();
329 329
 				break;
330 330
 			case SDL_TEXTINPUT:
331
-				if(event.text.text[0] >= ' ' || event.text.text[0] <= '~')
332
-					devctrl->dat[3] = event.text.text[0];
333
-				break;
334 331
 			case SDL_KEYDOWN:
335 332
 			case SDL_KEYUP:
333
+				if(event.text.text[0] >= ' ' || event.text.text[0] <= '~')
334
+					devctrl->dat[3] = event.text.text[0];
336 335
 				doctrl(u, &event, event.type == SDL_KEYDOWN);
337 336
 				evaluxn(u, mempeek16(devctrl->dat, 0));
338 337
 				devctrl->dat[3] = 0;