Browse code

Rewriting polycat

neauoire authored on 30/04/2021 19:08:24
Showing 4 changed files
... ...
@@ -34,7 +34,7 @@ else
34 34
 fi
35 35
 
36 36
 echo "Assembling.."
37
-./bin/assembler projects/demos/piano.usm bin/boot.rom
37
+./bin/assembler projects/demos/polycat.usm bin/boot.rom
38 38
 
39 39
 echo "Running.."
40 40
 if [ "${2}" = '--cli' ]; 
... ...
@@ -16,9 +16,6 @@
16 16
 |10 @Console    [ &pad    $8 &char     $1 &byte   $1 &short $2 &string $2 ]
17 17
 |20 @Screen     [ &vector $2 &width    $2 &height $2 &pad   $2 &x      $2 &y      $2 &addr $2 &color $1 ]
18 18
 |30 @Audio0     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
19
-|40 @Audio1     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
20
-|50 @Audio2     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
21
-|60 @Audio3     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
22 19
 |70 @Midi       [ &vector $2 &channel  $1 &note   $1 &velocity $1 ]
23 20
 |80 @Controller [ &vector $2 &button   $1 &key    $1 ]
24 21
 |90 @Mouse      [ &vector $2 &x        $2 &y      $2 &state $1 &chord  $1 ]
... ...
@@ -28,13 +25,12 @@
28 25
 
29 26
 |0000
30 27
 
31
-@last-note $1
32
-@octave $1
33
-@addr $1
34
-@color $1
28
+@last-note   $1
29
+@octave      $1
30
+@color       $1
35 31
 @pointer     [ &x $2 &y $2 ]
36
-@knob        [ &x $2 &y $2 &value $1 ]
37 32
 @center      [ &x $2 &y $2 ]
33
+@knob        [ &x $2 &y $2 &value $1 ]
38 34
 @adsr-view   [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
39 35
 @wave-view   [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
40 36
 @octave-view [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
... ...
@@ -88,16 +84,6 @@
88 84
 	WAVEFORM .Audio0/addr DEO2
89 85
 	#0100 .Audio0/length DEO2
90 86
 
91
-	#011a .Audio1/adsr DEO2
92
-	#88 .Audio1/volume DEO
93
-	WAVEFORM #0100 ADD2 .Audio1/addr DEO2
94
-	#0100 .Audio1/length DEO2
95
-
96
-	#1118 .Audio2/adsr DEO2
97
-	#88 .Audio2/volume DEO
98
-	WAVEFORM #0200 ADD2 .Audio2/addr DEO2
99
-	#0100 .Audio2/length DEO2
100
-
101 87
 	( inital drawing ) 
102 88
 	;draw-octave JSR2
103 89
 	;draw-adsr JSR2
104 90
new file mode 100644
... ...
@@ -0,0 +1,187 @@
1
+( polycat )
2
+
3
+%RTN { JMP2r }
4
+%8+ { #0008 ADD2 }
5
+%2/ { #0002 DIV2 }
6
+%MOD { DUP2 DIV MUL SUB }
7
+%INC { #01 ADD }
8
+%TOS { #00 SWP }
9
+
10
+( devices )
11
+
12
+|00 @System     [ &vector $2 &wst      $1 &rst    $1 &pad   $4 &r      $2 &g     $2 &b      $2 ]
13
+|10 @Console    [ &pad    $8 &char     $1 &byte   $1 &short $2 &string $2 ]
14
+|20 @Screen     [ &vector $2 &width    $2 &height $2 &pad   $2 &x      $2 &y      $2 &addr  $2 &color $1 ]
15
+|30 @Audio0     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr  $2 &volume $1 &pitch $1 ]
16
+|40 @Audio1     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr  $2 &volume $1 &pitch $1 ]
17
+|50 @Audio2     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr  $2 &volume $1 &pitch $1 ]
18
+|60 @Audio3     [ &vector $2 &position $2 &output $1 &pad   $3 &adsr   $2 &length $2 &addr  $2 &volume $1 &pitch $1 ]
19
+|70 @Midi       [ &vector $2 &channel  $1 &note   $1 &velocity $1 ]
20
+|80 @Controller [ &vector $2 &button   $1 &key    $1 ]
21
+|90 @Mouse      [ &vector $2 &x        $2 &y      $2 &state $1 &chord $1 ]
22
+|a0 @File       [ &vector $2 &success  $2 &offset $2 &pad   $2 &name  $2 &length $2 &load $2 &save $2 ]
23
+|b0 @DateTime   [ &year   $2 &month    $1 &day    $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
24
+
25
+( variables )
26
+
27
+|0000
28
+
29
+@cat     [ &x $2 &y $2 &timer $1 ]
30
+@pointer [ &x $2 &y $2 ]
31
+
32
+( program )
33
+
34
+|0100 ( -> )
35
+	
36
+	( theme ) 
37
+	#0a3f .System/r DEO2 
38
+	#05df .System/g DEO2 
39
+	#0caf .System/b DEO2
40
+
41
+	( find center )
42
+	.Screen/width DEI2 2/ #0008 SUB2 .cat/x POK2
43
+	.Screen/height DEI2 #0004 DIV2 #0003 MUL2 #0018 SUB2 .cat/y POK2
44
+
45
+	( place polycat )
46
+
47
+	( vectors )
48
+	;on-mouse .Mouse/vector DEO2
49
+	;on-frame .Screen/vector DEO2
50
+
51
+	;draw-polycat JSR2
52
+	;draw-ground JSR2
53
+
54
+BRK
55
+
56
+@on-mouse ( -> )
57
+	
58
+	;draw-cursor JSR2
59
+
60
+	.Mouse/x DEI2 .cat/x PEK2 GTH2 #20 MUL
61
+	.Mouse/y DEI2 .cat/y PEK2 GTH2 #40 MUL
62
+	ADD #00 SWP ;draw-eye JSR2
63
+
64
+BRK
65
+
66
+@on-frame ( -> )
67
+
68
+	.cat/timer PEK #01 ADD [ DUP ] .cat/timer POK
69
+	DUP #00 NEQ ,&skip0 JNZ #0000 ;draw-tail JSR2 &skip0
70
+	DUP #10 NEQ ,&skip1 JNZ #0001 ;draw-tail JSR2 &skip1
71
+	DUP #20 NEQ ,&skip2 JNZ #0002 ;draw-tail JSR2 &skip2
72
+	DUP #30 NEQ ,&skip3 JNZ #0003 ;draw-tail JSR2 &skip3
73
+	DUP #40 NEQ ,&skip4 JNZ #0002 ;draw-tail JSR2 &skip4
74
+	DUP #50 NEQ ,&skip5 JNZ #0001 ;draw-tail JSR2 &skip5
75
+	POP
76
+
77
+BRK
78
+
79
+@draw-polycat ( -- )
80
+
81
+	( ears )
82
+	.cat/y PEK2 .Screen/y DEO2
83
+
84
+	.cat/x PEK2 #0008 SUB2 .Screen/x DEO2
85
+	;ears .Screen/addr DEO2
86
+	#41 .Screen/color DEO
87
+	.cat/x PEK2 .Screen/x DEO2
88
+	;ears #0010 ADD2 .Screen/addr DEO2
89
+	#41 .Screen/color DEO
90
+
91
+	#0000 ;draw-eye JSR2
92
+	#0000 ;draw-tail JSR2
93
+
94
+RTN
95
+
96
+@draw-eye ( quad* -- )
97
+	
98
+	.cat/y PEK2 #0008 ADD2 .Screen/y DEO2
99
+	.cat/x PEK2 #0008 SUB2 .Screen/x DEO2
100
+
101
+	DUP2 ;eye ADD2 .Screen/addr DEO2
102
+	#41 .Screen/color DEO
103
+	.cat/x PEK2 .Screen/x DEO2
104
+	;eye #0010 ADD2 ADD2 .Screen/addr DEO2
105
+	#41 .Screen/color DEO
106
+
107
+RTN
108
+
109
+@draw-tail ( frame* -- )
110
+
111
+	.cat/y PEK2 #0010 ADD2 .Screen/y DEO2
112
+
113
+	.cat/x PEK2 #0008 SUB2 .Screen/x DEO2
114
+	;body .Screen/addr DEO2
115
+	#41 .Screen/color DEO
116
+	.cat/x PEK2 .Screen/x DEO2
117
+	#0010 MUL2 ;body #0010 ADD2 ADD2 .Screen/addr DEO2
118
+	#41 .Screen/color DEO
119
+
120
+RTN
121
+
122
+@draw-cursor ( -- )
123
+	
124
+	( clear last cursor )
125
+	#fff8 .Screen/addr DEO2 
126
+	.pointer/x PEK2 .Screen/x DEO2 
127
+	.pointer/y PEK2 .Screen/y DEO2 
128
+	#30 .Screen/color DEO
129
+	( record pointer positions )
130
+	.Mouse/x DEI2 .pointer/x POK2 
131
+	.Mouse/y DEI2 .pointer/y POK2
132
+	( draw new cursor )
133
+	;cursor .Screen/addr DEO2 
134
+	.pointer/x PEK2 .Screen/x DEO2 
135
+	.pointer/y PEK2 .Screen/y DEO2 
136
+	( colorize on state )
137
+	#31 [ .Mouse/state DEI #00 NEQ ] ADD .Screen/color DEO
138
+
139
+RTN
140
+
141
+@draw-ground ( -- )
142
+
143
+	.cat/y PEK2 #0018 ADD2 .Screen/y DEO2
144
+	.cat/x PEK2 #0010 SUB2 .Screen/x DEO2
145
+	;ground .Screen/addr DEO2
146
+
147
+	#00 #10
148
+	&loop
149
+		#21 .Screen/color DEO
150
+		.Screen/addr DEI2 #0008 ADD2 .Screen/addr DEO2
151
+		.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
152
+		SWP #01 ADD SWP
153
+		DUP2 LTH ,&loop JNZ
154
+	POP2
155
+
156
+RTN
157
+
158
+@cursor [ 
159
+	80c0 e0f0 f8e0 1000 ]
160
+
161
+@ears [
162
+	081c 3e3e 7f7f ffff 081c 3e3e 7f7f fffc
163
+	081c 3c3e 7e7e ffff 081c 3c3e 7e7e ff1f ]
164
+
165
+@eye [
166
+	ffff ffff ff7f 3f0f f7ef cfe7 f07c 3f0f
167
+	ffff ffff fffe fcf0 87c3 c183 071e fcf0
168
+	ffff ffff ff7f 3f0f f0e1 c1e0 f07c 3f0f
169
+	ffff ffff fffe fcf0 f7fb f9f3 071e fcf0
170
+	ffff ffff ff7f 3f0f f0e7 cfef f77c 3f0f
171
+	ffff ffff fffe fcf0 0783 c1c3 871e fcf0
172
+	ffff ffff ff7f 3f0f f0e0 c1e1 f07c 3f0f
173
+	ffff ffff fffe fcf0 07f3 f9fb f71e fcf0
174
+]
175
+
176
+@body [
177
+	0707 0707 0302 0200 0107 0707 0300 0000
178
+	e0f0 f0e0 e080 8000 c0f2 f9f9 fef8 b000
179
+	e0f0 f0e0 e080 8000 c0f2 f9f9 fef8 b000
180
+	e0f0 f0e0 e080 8000 c0f2 faf9 fef8 b000
181
+	e0f0 f0e0 e080 8000 c0f1 faf9 fef8 b000
182
+	0707 0707 0f08 1000 0307 0707 0f00 0000
183
+	e0e0 e0e0 e080 8000 f2f9 f9fe b884 8400 ]
184
+
185
+@ground [
186
+	bf15 0210 0200 0200 ff55 aa54 a900 2000
187
+	fb55 aa45 2200 0400 ba40 a040 8880 0080 ]
0 188
\ No newline at end of file
... ...
@@ -48,4 +48,4 @@ int evaluxn(Uxn *u, Uint16 vec);
48 48
 void mempoke16(Uint8 *m, Uint16 a, Uint16 b);
49 49
 Uint16 mempeek16(Uint8 *m, Uint16 a);
50 50
 
51
-Device *portuxn(Uxn *u, Uint8 id, char *name, void (*talkfn)(Device *, Uint8, Uint8));
52 51
\ No newline at end of file
52
+Device *portuxn(Uxn *u, Uint8 id, char *name, void (*talkfn)(Device *, Uint8, Uint8));