bitwise.tal (5769B)
1 ( bitwise ) 2 3 |00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 ] 4 |10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ] 5 |20 @Screen [ &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ] 6 |30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] 7 |40 @Audio1 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] 8 |50 @Audio2 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] 9 |60 @Audio3 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] 10 |80 @Controller [ &vector $2 &button $1 &key $1 ] 11 |90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ] 12 |a0 @File [ &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 ] 13 |c0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ] 14 15 ( variables ) 16 17 |0000 18 19 @a-frame 20 &x $2 &y $2 &x2 $2 &y2 $2 21 @b-frame 22 &x $2 &y $2 &x2 $2 &y2 $2 23 @input 24 &a $1 &b $1 25 @pointer 26 &x $2 &y $2 27 28 ( program ) 29 30 |0100 ( -> ) 31 32 ( theme ) 33 #0fe7 .System/r DEO2 34 #0fce .System/g DEO2 35 #0f2c .System/b DEO2 36 37 ;on-mouse .Mouse/vector DEO2 38 39 .Screen/width DEI2 #01 SFT2 40 DUP2 #0040 SUB2 .a-frame/x STZ2 DUP2 #0040 ADD2 .a-frame/x2 STZ2 41 DUP2 #0040 SUB2 .b-frame/x STZ2 #0040 ADD2 .b-frame/x2 STZ2 42 43 .Screen/height DEI2 #01 SFT2 #0020 SUB2 44 DUP2 #0010 SUB2 .a-frame/y STZ2 DUP2 .a-frame/y2 STZ2 45 DUP2 .b-frame/y STZ2 #0010 ADD2 .b-frame/y2 STZ2 46 47 ;redraw JSR2 48 49 BRK 50 51 @on-mouse ( -> ) 52 53 ;draw-cursor JSR2 54 55 .Mouse/state DEI #00 NEQ JMP [ BRK ] 56 57 .Mouse/x DEI2 .Mouse/y DEI2 .a-frame ;within-rect JSR2 58 ;on-touch-a JCN2 59 .Mouse/x DEI2 .Mouse/y DEI2 .b-frame ;within-rect JSR2 60 ;on-touch-b JCN2 61 62 BRK 63 64 @on-touch-a ( -> ) 65 66 .Mouse/x DEI2 .a-frame/x LDZ2 SUB2 67 #04 SFT2 NIP #07 SWP SUB STH 68 69 .input/a LDZ 70 #01 [ STHr #40 SFT ] SFT EOR 71 .input/a STZ 72 73 ;redraw JSR2 74 #00 .Mouse/state DEO 75 76 BRK 77 78 @on-touch-b ( -> ) 79 80 .Mouse/x DEI2 .b-frame/x LDZ2 SUB2 81 #04 SFT2 NIP #07 SWP SUB STH 82 83 .input/b LDZ 84 #01 [ STHr #40 SFT ] SFT EOR 85 .input/b STZ 86 87 ;redraw JSR2 88 #00 .Mouse/state DEO 89 90 BRK 91 92 @redraw ( -- ) 93 94 .a-frame/x LDZ2 .Screen/x DEO2 95 .a-frame/y LDZ2 .Screen/y DEO2 96 .input/a LDZ #01 ;draw-byte JSR2 97 98 .b-frame/x LDZ2 .Screen/x DEO2 99 .b-frame/y LDZ2 .Screen/y DEO2 100 .input/b LDZ #01 ;draw-byte JSR2 101 102 .b-frame/x LDZ2 .Screen/x DEO2 103 .Screen/y DEI2 #000d ADD2 .Screen/y DEO2 104 .input LDZ2 AND #03 ;draw-byte JSR2 105 106 .b-frame/x LDZ2 .Screen/x DEO2 107 .Screen/y DEI2 #000d ADD2 .Screen/y DEO2 108 .input LDZ2 ORA #03 ;draw-byte JSR2 109 110 .b-frame/x LDZ2 .Screen/x DEO2 111 .Screen/y DEI2 #000d ADD2 .Screen/y DEO2 112 .input LDZ2 EOR #03 ;draw-byte JSR2 113 114 ( labels ) 115 #05 .Screen/auto DEO 116 .b-frame/x LDZ2 #0020 SUB2 .Screen/x DEO2 117 ;names-icn/and .Screen/addr DEO2 118 .b-frame/y2 LDZ2 #0004 ADD2 .Screen/y DEO2 119 ,&draw-label JSR 120 .b-frame/y2 LDZ2 #0014 ADD2 .Screen/y DEO2 121 ,&draw-label JSR 122 .b-frame/y2 LDZ2 #0024 ADD2 .Screen/y DEO2 123 ,&draw-label JSR 124 #00 .Screen/auto DEO 125 126 JMP2r 127 &draw-label 128 .b-frame/x LDZ2 #0020 SUB2 .Screen/x DEO2 129 #03 .Screen/sprite DEOk DEOk DEO 130 JMP2r 131 132 @draw-byte ( value -- ) 133 134 STH STH 135 #0800 136 &loop 137 #07 OVR SUB 138 STHkr SWP SFT #01 AND OVRr STHr ;draw-bit JSR2 139 INC GTHk ,&loop JCN 140 POP2 141 .Screen/y DEI2 #0003 ADD2 .Screen/y DEO2 142 .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 143 STHr ;draw-hex JSR2 144 POPr 145 146 JMP2r 147 148 @draw-bit ( value color -- ) 149 150 STH STH 151 152 #05 .Screen/auto DEO 153 ;button-icns/off [ #00 STHkr #50 SFT ADD2 ] .Screen/addr DEO2 154 OVRr STHr .Screen/sprite DEO 155 OVRr STHr .Screen/sprite DEO 156 .Screen/y DEI2 #0008 ADD2 .Screen/y DEO2 157 .Screen/x DEI2 #0010 SUB2 .Screen/x DEO2 158 OVRr STHr .Screen/sprite DEO 159 OVRr STHr .Screen/sprite DEO 160 #00 .Screen/auto DEO 161 .Screen/y DEI2 #0008 SUB2 .Screen/y DEO2 162 163 POP2r 164 165 JMP2r 166 167 @draw-hex ( value -- ) 168 169 #01 .Screen/auto DEO 170 DUP #04 SFT ,&draw JSR 171 #0f AND ,&draw JSR 172 #01 .Screen/auto DEO 173 174 JMP2r 175 &draw 176 #00 SWP #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2 177 ( draw ) #01 .Screen/sprite DEO 178 JMP2r 179 180 @draw-cursor ( -- ) 181 182 ( clear last cursor ) 183 ;cursor .Screen/addr DEO2 184 .pointer/x LDZ2 .Screen/x DEO2 185 .pointer/y LDZ2 .Screen/y DEO2 186 #40 .Screen/sprite DEO 187 ( record pointer positions ) 188 .Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2 189 .Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2 190 ( colorize on state ) 191 #42 [ .Mouse/state DEI #00 NEQ ] ADD .Screen/sprite DEO 192 193 JMP2r 194 195 @within-rect ( x* y* rect -- flag ) 196 197 STH 198 ( y < rect.y1 ) DUP2 STHkr INC INC LDZ2 LTH2 ,&skip JCN 199 ( y > rect.y2 ) DUP2 STHkr #06 ADD LDZ2 GTH2 ,&skip JCN 200 SWP2 201 ( x < rect.x1 ) DUP2 STHkr LDZ2 LTH2 ,&skip JCN 202 ( x > rect.x2 ) DUP2 STHkr #04 ADD LDZ2 GTH2 ,&skip JCN 203 POP2 POP2 POPr 204 #01 205 JMP2r 206 &skip 207 POP2 POP2 POPr 208 #00 209 210 JMP2r 211 212 @cursor 213 80c0 e0f0 f8e0 1000 214 215 @button-icns 216 &off 217 3f40 8080 8080 8080 218 f804 0202 0202 0202 219 8080 8080 8040 3f00 220 0202 0202 0204 f800 221 &on 222 3f40 9fbf bfbf bfbf 223 f804 f2fa fafa fafa 224 bfbf bfbf 9f40 3f00 225 fafa fafa f204 f800 226 227 @names-icn 228 &and 229 fc02 027e 8286 fa00 230 bcc2 8282 8282 8200 231 fc82 8282 8282 fc00 232 &ora 233 7c82 8282 8282 7c00 234 fc82 82fc 8282 8200 235 fc02 027e 8286 fa00 236 &eor 237 8282 4438 4482 8200 238 7c82 8282 8282 7c00 239 fc82 82fc 8282 8200 240 241 @font-hex ( 0-F ) 242 007c 8282 8282 827c 0030 1010 1010 1010 243 007c 8202 7c80 80fe 007c 8202 1c02 827c 244 000c 1424 4484 fe04 00fe 8080 7c02 827c 245 007c 8280 fc82 827c 007c 8202 1e02 0202 246 007c 8282 7c82 827c 007c 8282 7e02 827c 247 007c 8202 7e82 827e 00fc 8282 fc82 82fc 248 007c 8280 8080 827c 00fc 8282 8282 82fc 249 007c 8280 f080 827c 007c 8280 f080 8080 250