1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,186 @@ |
1 |
+( a blank file ) |
|
2 |
+ |
|
3 |
+%+ { ADD } %- { SUB } %/ { DIV } |
|
4 |
+%< { LTH } %> { GTH } %= { EQU } %! { NEQ } |
|
5 |
+%++ { ADD2 } %-- { SUB2 } %// { DIV2 } |
|
6 |
+%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 } |
|
7 |
+ |
|
8 |
+%2* { #10 SFT } %2/ { #01 SFT } |
|
9 |
+%4* { #20 SFT } %4/ { #02 SFT } |
|
10 |
+%8* { #30 SFT } %8/ { #03 SFT } |
|
11 |
+%10* { #40 SFT } %10/ { #04 SFT } |
|
12 |
+%20* { #50 SFT } %20/ { #05 SFT } |
|
13 |
+ |
|
14 |
+%2** { #10 SFT2 } %2// { #01 SFT2 } |
|
15 |
+%4** { #20 SFT2 } %4// { #02 SFT2 } |
|
16 |
+%8** { #30 SFT2 } %8// { #03 SFT2 } |
|
17 |
+%10** { #40 SFT2 } %10// { #04 SFT2 } |
|
18 |
+%20** { #50 SFT2 } %20// { #05 SFT2 } |
|
19 |
+ |
|
20 |
+%DEBUG { ;print-hex JSR2 #0a .Console/write DEO } |
|
21 |
+%DEBUG2 { SWP ;print-hex JSR2 ;print-hex JSR2 #0a .Console/write DEO } |
|
22 |
+ |
|
23 |
+%RTN { JMP2r } |
|
24 |
+%TOS { #00 SWP } |
|
25 |
+ |
|
26 |
+( devices ) |
|
27 |
+ |
|
28 |
+|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 ] |
|
29 |
+|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ] |
|
30 |
+|20 @Screen [ &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ] |
|
31 |
+|30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |
|
32 |
+|40 @Audio1 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |
|
33 |
+|50 @Audio2 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |
|
34 |
+|60 @Audio3 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |
|
35 |
+|80 @Controller [ &vector $2 &button $1 &key $1 ] |
|
36 |
+|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ] |
|
37 |
+|a0 @File [ &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 ] |
|
38 |
+|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ] |
|
39 |
+ |
|
40 |
+( variables ) |
|
41 |
+ |
|
42 |
+|0000 |
|
43 |
+ |
|
44 |
+@input |
|
45 |
+ &a $1 &b $1 |
|
46 |
+@center |
|
47 |
+ &x $2 &y $2 |
|
48 |
+@pointer |
|
49 |
+ &x $2 &y $2 |
|
50 |
+ |
|
51 |
+( program ) |
|
52 |
+ |
|
53 |
+|0100 ( -> ) |
|
54 |
+ |
|
55 |
+ ( theme ) |
|
56 |
+ #0fe5 .System/r DEO2 |
|
57 |
+ #0fc5 .System/g DEO2 |
|
58 |
+ #0f25 .System/b DEO2 |
|
59 |
+ |
|
60 |
+ ;on-mouse .Mouse/vector DEO2 |
|
61 |
+ |
|
62 |
+ .Screen/width DEI2 2// .center/x STZ2 |
|
63 |
+ .Screen/height DEI2 2// .center/y STZ2 |
|
64 |
+ |
|
65 |
+ ;redraw JSR2 |
|
66 |
+ |
|
67 |
+BRK |
|
68 |
+ |
|
69 |
+@on-mouse ( -> ) |
|
70 |
+ |
|
71 |
+ ;draw-cursor JSR2 |
|
72 |
+ |
|
73 |
+ .Mouse/state DEI #00 ! JMP [ BRK ] |
|
74 |
+ |
|
75 |
+BRK |
|
76 |
+ |
|
77 |
+@redraw ( -- ) |
|
78 |
+ |
|
79 |
+ .center/x LDZ2 #0040 -- .Screen/x DEO2 |
|
80 |
+ .center/y LDZ2 #0010 -- .Screen/y DEO2 |
|
81 |
+ |
|
82 |
+ #4f ;draw-byte JSR2 |
|
83 |
+ |
|
84 |
+ .center/x LDZ2 #0040 -- .Screen/x DEO2 |
|
85 |
+ .center/y LDZ2 #0000 ++ .Screen/y DEO2 |
|
86 |
+ |
|
87 |
+ #e7 ;draw-byte JSR2 |
|
88 |
+ |
|
89 |
+RTN |
|
90 |
+ |
|
91 |
+@draw-byte ( value -- ) |
|
92 |
+ |
|
93 |
+ STH |
|
94 |
+ #0800 |
|
95 |
+ &loop |
|
96 |
+ DUP STHkr SWP SFT #01 AND ;draw-bit JSR2 |
|
97 |
+ INC GTHk ,&loop JCN |
|
98 |
+ POP2 |
|
99 |
+ .Screen/y DEI2 #0003 ++ .Screen/y DEO2 |
|
100 |
+ STHr ;draw-hex JSR2 |
|
101 |
+ |
|
102 |
+RTN |
|
103 |
+ |
|
104 |
+@draw-bit ( value -- ) |
|
105 |
+ |
|
106 |
+ STH |
|
107 |
+ |
|
108 |
+ #05 .Screen/auto DEO |
|
109 |
+ ;button-icns/off [ #00 STHkr 20* ++ ] .Screen/addr DEO2 |
|
110 |
+ #01 .Screen/sprite DEO |
|
111 |
+ #01 .Screen/sprite DEO |
|
112 |
+ .Screen/y DEI2 #0008 ++ .Screen/y DEO2 |
|
113 |
+ .Screen/x DEI2 #0010 -- .Screen/x DEO2 |
|
114 |
+ |
|
115 |
+ #01 .Screen/sprite DEO |
|
116 |
+ #01 .Screen/sprite DEO |
|
117 |
+ |
|
118 |
+ #00 .Screen/auto DEO |
|
119 |
+ .Screen/y DEI2 #0008 -- .Screen/y DEO2 |
|
120 |
+ |
|
121 |
+ POPr |
|
122 |
+ |
|
123 |
+RTN |
|
124 |
+ |
|
125 |
+@draw-hex ( value -- ) |
|
126 |
+ |
|
127 |
+ DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2 |
|
128 |
+ .Screen/x DEI2 #0008 ++ .Screen/x DEO2 |
|
129 |
+ ( draw ) #01 .Screen/sprite DEO |
|
130 |
+ #0f AND TOS 8** ;font-hex ++ .Screen/addr DEO2 |
|
131 |
+ .Screen/x DEI2 #0008 ++ .Screen/x DEO2 |
|
132 |
+ ( draw ) #01 .Screen/sprite DEO |
|
133 |
+ |
|
134 |
+RTN |
|
135 |
+ |
|
136 |
+@draw-cursor ( -- ) |
|
137 |
+ |
|
138 |
+ ( clear last cursor ) |
|
139 |
+ ;cursor .Screen/addr DEO2 |
|
140 |
+ .pointer/x LDZ2 .Screen/x DEO2 |
|
141 |
+ .pointer/y LDZ2 .Screen/y DEO2 |
|
142 |
+ #40 .Screen/sprite DEO |
|
143 |
+ ( record pointer positions ) |
|
144 |
+ .Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2 |
|
145 |
+ .Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2 |
|
146 |
+ ( colorize on state ) |
|
147 |
+ #41 [ .Mouse/state DEI #00 ! ] + .Screen/sprite DEO |
|
148 |
+ |
|
149 |
+RTN |
|
150 |
+ |
|
151 |
+@print-hex ( value -- ) |
|
152 |
+ |
|
153 |
+ STHk #04 SFT ,&parse JSR .Console/write DEO |
|
154 |
+ STHr #0f AND ,&parse JSR .Console/write DEO |
|
155 |
+ RTN |
|
156 |
+ &parse ( value -- char ) |
|
157 |
+ DUP #09 GTH ,&above JCN #30 ADD RTN &above #09 SUB #60 ADD RTN |
|
158 |
+ |
|
159 |
+RTN |
|
160 |
+ |
|
161 |
+@cursor |
|
162 |
+ 80c0 e0f0 f8e0 1000 |
|
163 |
+ |
|
164 |
+@button-icns |
|
165 |
+ &off |
|
166 |
+ 3f40 8080 8080 8080 |
|
167 |
+ f804 0202 0202 0202 |
|
168 |
+ 8080 8080 8040 3f00 |
|
169 |
+ 0202 0202 0204 f800 |
|
170 |
+ &on |
|
171 |
+ 3f40 9fbf bfbf bfbf |
|
172 |
+ f804 f2fa fafa fafa |
|
173 |
+ bfbf bfbf 9f40 3f00 |
|
174 |
+ fafa fafa f204 f800 |
|
175 |
+ |
|
176 |
+@font-hex ( 0-F ) |
|
177 |
+ 007c 8282 8282 827c 0030 1010 1010 1010 |
|
178 |
+ 007c 8202 7c80 80fe 007c 8202 1c02 827c |
|
179 |
+ 000c 1424 4484 fe04 00fe 8080 7c02 827c |
|
180 |
+ 007c 8280 fc82 827c 007c 8202 1e02 0202 |
|
181 |
+ 007c 8282 7c82 827c 007c 8282 7e02 827c |
|
182 |
+ 007c 8202 7e82 827e 00fc 8282 fc82 82fc |
|
183 |
+ 007c 8280 8080 827c 00fc 8282 8282 82fc |
|
184 |
+ 007c 8280 f080 827c 007c 8280 f080 8080 |
|
185 |
+ |
|
186 |
+ |