Browse code

Ported screen example to new vectors

neauoire authored on 05/04/2021 20:14:37
Showing 6 changed files
... ...
@@ -28,7 +28,7 @@ else
28 28
 fi
29 29
 
30 30
 echo "Assembling.."
31
-./bin/assembler projects/examples/dev.keys.usm bin/boot.rom
31
+./bin/assembler projects/examples/dev.screen.usm bin/boot.rom
32 32
 
33 33
 echo "Running.."
34 34
 if [ "${2}" = '--cli' ]; 
... ...
@@ -28,7 +28,7 @@
28 28
 |0130 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
29 29
 |0140 ;Controller { buttons 1 }
30 30
 |0150 ;Keys { key 1 }
31
-|0160 ;Mouse { x 2 y 2 state 1 chord 1 change 1 }
31
+|0160 ;Mouse  { vector 2 x 2 y 2 state 1 chord 1 }
32 32
 |0170 ;File { pad 8 name 2 length 2 load 2 save 2 }
33 33
 |0180 ;Audio { ch1adsr 2 ch2adsr 2 ch3adsr 2 ch4adsr 2 ch1vol 1 ch1pitch 1 ch2vol 1 ch2pitch 1 ch3vol 1 ch3pitch 1 ch4vol 1 ch4pitch 1 }
34 34
 
... ...
@@ -16,7 +16,7 @@
16 16
 |0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
17 17
 |0140 ;Controller { vector 2 p1 1 }
18 18
 |0150 ;Keys { vector 2 key 1 }
19
-|0160 ;Mouse { x 2 y 2 state 1 chord 1 change 1 }
19
+|0160 ;Mouse  { vector 2 x 2 y 2 state 1 chord 1 }
20 20
 |0170 ;File { pad 8 name 2 length 2 load 2 save 2 }
21 21
 |0180 ;Audio { ch1adsr 2 ch2adsr 2 ch3adsr 2 ch4adsr 2 ch1vol 1 ch1pitch 1 ch2vol 1 ch2pitch 1 ch3vol 1 ch3pitch 1 ch4vol 1 ch4pitch 1 }
22 22
 
... ...
@@ -10,25 +10,24 @@
10 10
 ;pointer { x 2 y 2 }
11 11
 ;circle { xc 2 yc 2 x 2 y 2 r 2 d 2 }
12 12
 
13
-|0100 ;Console { pad 8 char 1 byte 1 short 2 }
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
-|0150 ;Mouse  { x 2 y 2 state 1 chord 1 }
17
-|0170 ;Audio { ch1adsr 2 ch2adsr 2 ch3adsr 2 ch4adsr 2 ch1vol 1 ch1pitch 1 ch2vol 1 ch2pitch 1 ch3vol 1 ch3pitch 1 ch4vol 1 ch4pitch 1 }
18
-|01F0 ;System { pad 8 r 2 g 2 b 2 }
13
+|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
14
+|0110 ;Console { pad 8 char 1 byte 1 short 2 }
15
+|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 }
16
+|0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
17
+|0140 ;Controller { vector 2 button 1 }
18
+|0150 ;Keys { vector 2 key 1 }
19
+|0160 ;Mouse  { vector 2 x 2 y 2 state 1 chord 1 }
19 20
 
20 21
 ( program )
21 22
 
22 23
 |0200 @RESET
23 24
 
24 25
 	( theme ) #03fd =System.r #0ef3 =System.g #0bf2 =System.b
25
-	( vectors ) ,FRAME =Screen.vector
26
-	
27
-	#004f =Audio.ch1adsr #33 =Audio.ch1vol
26
+	( vectors ) ,on-mouse =Mouse.vector
28 27
 
29 28
 BRK
30 29
 
31
-@FRAME
30
+@on-mouse
32 31
  	
33 32
  	( clear )
34 33
 	~circle.xc ~circle.yc ~circle.r #00 ,draw-circle JSR2
... ...
@@ -39,7 +38,6 @@ BRK
39 38
 		~Mouse.x DUP2 =circle.xc
40 39
 		~Mouse.y DUP2 =circle.yc
41 40
 		#0000 =circle.r
42
-		( play sound ) ~Screen.width #000c DIV2 ADD2 #0002 DIV2 SWP POP =Audio.ch1pitch
43 41
 		( release ) #00 =Mouse.state
44 42
 	$no-touch
45 43
 
... ...
@@ -97,7 +95,5 @@ RTN
97 95
 
98 96
 RTN
99 97
 
100
-@ERROR BRK 
101
-
102 98
 @clear_icn   [ 0000 0000 0000 0000 ]
103 99
 @cursor_icn  [ 80c0 e0f0 f8e0 1000 ]
104 100
\ No newline at end of file
... ...
@@ -14,7 +14,6 @@
14 14
 ;window { x1 2 y1 2 x2 2 y2 2 w 2 h 2 }
15 15
 ;label { x 2 y 2 addr 2 }
16 16
 ;slider { x1 2 y 2 x2 2 pos 2 }
17
-;addr { short 2 }
18 17
 ;selection { byte 1 }
19 18
 ;theme { 
20 19
 	r1 1 r2 1 r3 1 r4 1 
... ...
@@ -22,17 +21,20 @@
22 21
 	b1 1 b2 1 b3 1 b4 1 
23 22
 }
24 23
 
25
-|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
26
-|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
27
-|0150 ;Mouse  { x 2 y 2 state 1 chord 1 }
28
-|01F0 ;System { pad 8 r 2 g 2 b 2 }
24
+|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
25
+|0110 ;Console { pad 8 char 1 byte 1 short 2 }
26
+|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 }
27
+|0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
28
+|0140 ;Controller { vector 2 button 1 }
29
+|0150 ;Keys { vector 2 key 1 }
30
+|0160 ;Mouse  { vector 2 x 2 y 2 state 1 chord 1 }
29 31
 
30 32
 ( program )
31 33
 
32 34
 |0200 @RESET
33 35
 
34 36
 	( theme ) #127f =System.r #34e7 =System.g #56c4 =System.b
35
-	( vectors ) ,FRAME =Screen.vector
37
+	( vectors ) ,on-mouse =Mouse.vector
36 38
 	
37 39
 	#00a0 =window.w
38 40
 	#0050 =window.h
... ...
@@ -84,7 +86,7 @@
84 86
 
85 87
 BRK
86 88
 
87
-@FRAME 
89
+@on-mouse 
88 90
 	
89 91
 	~Mouse.state #00 EQU ,$no-touch JNZ2
90 92
 
... ...
@@ -124,18 +126,18 @@ BRK
124 126
 
125 127
 @update-theme
126 128
 
127
-	#01F8 PEK2 #0f AND ~theme.r1 #40 SFT ADD #01F8 POK2
128
-	#01Fa PEK2 #0f AND ~theme.g1 #40 SFT ADD #01Fa POK2
129
-	#01Fc PEK2 #0f AND ~theme.b1 #40 SFT ADD #01Fc POK2
130
-	#01F8 PEK2 #f0 AND ~theme.r2 ADD #01F8 POK2
131
-	#01Fa PEK2 #f0 AND ~theme.g2 ADD #01Fa POK2
132
-	#01Fc PEK2 #f0 AND ~theme.b2 ADD #01Fc POK2
133
-	#01F9 PEK2 #0f AND ~theme.r3 #40 SFT ADD #01F9 POK2
134
-	#01Fb PEK2 #0f AND ~theme.g3 #40 SFT ADD #01Fb POK2
135
-	#01Fd PEK2 #0f AND ~theme.b3 #40 SFT ADD #01Fd POK2
136
-	#01F9 PEK2 #f0 AND ~theme.r4 ADD #01F9 POK2
137
-	#01Fb PEK2 #f0 AND ~theme.g4 ADD #01Fb POK2
138
-	#01Fd PEK2 #f0 AND ~theme.b4 ADD #01Fd POK2
129
+	#0108 PEK2 #0f AND ~theme.r1 #40 SFT ADD #0108 POK2
130
+	#010a PEK2 #0f AND ~theme.g1 #40 SFT ADD #010a POK2
131
+	#010c PEK2 #0f AND ~theme.b1 #40 SFT ADD #010c POK2
132
+	#0108 PEK2 #f0 AND ~theme.r2 ADD #0108 POK2
133
+	#010a PEK2 #f0 AND ~theme.g2 ADD #010a POK2
134
+	#010c PEK2 #f0 AND ~theme.b2 ADD #010c POK2
135
+	#0109 PEK2 #0f AND ~theme.r3 #40 SFT ADD #0109 POK2
136
+	#010b PEK2 #0f AND ~theme.g3 #40 SFT ADD #010b POK2
137
+	#010d PEK2 #0f AND ~theme.b3 #40 SFT ADD #010d POK2
138
+	#0109 PEK2 #f0 AND ~theme.r4 ADD #0109 POK2
139
+	#010b PEK2 #f0 AND ~theme.g4 ADD #010b POK2
140
+	#010d PEK2 #f0 AND ~theme.b4 ADD #010d POK2
139 141
 
140 142
 RTN
141 143
 
... ...
@@ -155,10 +157,6 @@ RTN
155 157
 	~window.x1 #0050 ADD2 ~window.y1 #0020 ADD2 ~window.x1 #0080 ADD2 #00 ,theme.g1 ~selection ADD PEK2 #0004 MUL2 #01 ,draw-slider JSR2
156 158
 	~window.x1 #0050 ADD2 ~window.y1 #0030 ADD2 ~window.x1 #0080 ADD2 #00 ,theme.b1 ~selection ADD PEK2 #0004 MUL2 #01 ,draw-slider JSR2
157 159
 
158
-	~window.x1 #0008 ADD2 =Sprite.x ~window.y1 =Sprite.y ~System.r ,draw-short JSR2
159
-	~window.x1 #0030 ADD2 =Sprite.x ~window.y1 =Sprite.y ~System.g ,draw-short JSR2
160
-	~window.x1 #0058 ADD2 =Sprite.x ~window.y1 =Sprite.y ~System.b ,draw-short JSR2
161
-
162 160
 	~window.x1 #0050 ADD2 =Sprite.x
163 161
 	~window.y1 #0040 ADD2 =Sprite.y
164 162
 	,radio_icns #00 ~selection #00 EQU #0008 MUL2 ADD2 =Sprite.addr
... ...
@@ -200,23 +198,6 @@ RTN
200 198
 
201 199
 RTN
202 200
 
203
-@draw-short ( short )
204
-
205
-	=addr
206
-	,font_hex #00 ~addr PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Sprite.addr
207
-	( draw ) #04 =Sprite.color
208
-	~Sprite.x 8+ =Sprite.x
209
-	,font_hex #00 ~addr PEK2 #0f AND #08 MUL ADD2 =Sprite.addr
210
-	( draw ) #04 =Sprite.color
211
-	~Sprite.x 8+ =Sprite.x
212
-	,font_hex #00 ~addr ++ PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Sprite.addr
213
-	( draw ) #04 =Sprite.color
214
-	~Sprite.x 8+ =Sprite.x
215
-	,font_hex #00 ~addr ++ PEK2 #0f AND #08 MUL ADD2 =Sprite.addr
216
-	( draw ) #04 =Sprite.color
217
-
218
-RTN
219
-
220 201
 @draw-slider ( x1 y x2 pos color )
221 202
 	
222 203
 	( load ) =color =slider.pos =slider.x2 =slider.y =slider.x1
... ...
@@ -303,19 +284,6 @@ RTN
303 284
 @green_txt    [ Green 00 ]
304 285
 @blue_txt     [ Blue 00 ]
305 286
 
306
-
307
-@font_hex ( 0-F TODO: should pull from @font instead.. ) 
308
-[
309
-	003c 464a 5262 3c00 0018 0808 0808 1c00
310
-	003c 4202 3c40 7e00 003c 421c 0242 3c00
311
-	000c 1424 447e 0400 007e 407c 0242 3c00
312
-	003c 407c 4242 3c00 007e 0204 0810 1000
313
-	003c 423c 4242 3c00 003c 4242 3e02 3c00
314
-	003c 4242 7e42 4200 007c 427c 4242 7c00 
315
-	003c 4240 4042 3c00 007c 4242 4242 7c00 
316
-	007e 4078 4040 7e00 007e 4078 4040 4000
317
-]
318
-
319 287
 @font ( spectrum-zx font ) 
320 288
 [
321 289
 	0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000
... ...
@@ -351,5 +319,3 @@ RTN
351 319
 	0000 4428 1028 4400 0000 4444 443c 0438 0000 7c08 1020 7c00 000c 0810 1008 0c00
352 320
 	0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c
353 321
 ]
354
-
355
-@ERROR BRK 
... ...
@@ -561,10 +561,9 @@ Uint8
561 561
 system_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1)
562 562
 {
563 563
 	Uint8 *m = u->ram.dat;
564
-	m[PAGE_DEVICE + 0x00f0 + b0] = b1;
565
-	loadtheme(&m[PAGE_DEVICE + 0x00f8]);
564
+	m[PAGE_DEVICE + b0] = b1;
565
+	loadtheme(&m[PAGE_DEVICE + 0x0008]);
566 566
 	(void)ptr;
567
-	(void)b0;
568 567
 	return b1;
569 568
 }
570 569