| 39 | 39 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,178 @@ |
| 1 |
+( a blank file ) |
|
| 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 &pad $6 &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 |
+|60 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ] |
|
| 16 |
+|a0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 &refresh $1 ] |
|
| 17 |
+ |
|
| 18 |
+( variables ) |
|
| 19 |
+ |
|
| 20 |
+|0000 |
|
| 21 |
+ |
|
| 22 |
+@last $1 |
|
| 23 |
+@color $1 |
|
| 24 |
+@style $1 |
|
| 25 |
+@pointer [ &x $2 &y $2 ] |
|
| 26 |
+@center [ &x $2 &y $2 ] |
|
| 27 |
+@anchor [ &x $2 &y $2 ] |
|
| 28 |
+ |
|
| 29 |
+( program ) |
|
| 30 |
+ |
|
| 31 |
+|0100 ( -> ) |
|
| 32 |
+ |
|
| 33 |
+ ( theme ) |
|
| 34 |
+ #0f3a .System/r DEO2 |
|
| 35 |
+ #0fda .System/g DEO2 |
|
| 36 |
+ #0faa .System/b DEO2 |
|
| 37 |
+ |
|
| 38 |
+ ( vectors ) |
|
| 39 |
+ ;on-frame .Screen/vector DEO2 |
|
| 40 |
+ ;on-mouse .Mouse/vector DEO2 |
|
| 41 |
+ |
|
| 42 |
+ ( find center ) |
|
| 43 |
+ .Screen/width DEI2 2/ .center/x POK2 |
|
| 44 |
+ .Screen/height DEI2 2/ .center/y POK2 |
|
| 45 |
+ |
|
| 46 |
+ ( background ) |
|
| 47 |
+ ;tiles #21 ;cover-pattern JSR2 |
|
| 48 |
+ ;redraw JSR2 |
|
| 49 |
+ |
|
| 50 |
+BRK |
|
| 51 |
+ |
|
| 52 |
+@on-frame ( -> ) |
|
| 53 |
+ |
|
| 54 |
+ #00 .DateTime/refresh DEO |
|
| 55 |
+ |
|
| 56 |
+ ( only draw once per second ) |
|
| 57 |
+ .DateTime/second DEI .last PEK NEQ #01 JNZ [ BRK ] |
|
| 58 |
+ .DateTime/second DEI .last POK |
|
| 59 |
+ |
|
| 60 |
+ ;redraw JSR2 |
|
| 61 |
+ |
|
| 62 |
+BRK |
|
| 63 |
+ |
|
| 64 |
+@on-mouse ( -> ) |
|
| 65 |
+ |
|
| 66 |
+ ;draw-cursor JSR2 |
|
| 67 |
+ |
|
| 68 |
+ .Mouse/state DEI #00 EQU ,&no-touch JNZ |
|
| 69 |
+ .style PEK INC #03 MOD .style POK |
|
| 70 |
+ .style PEK .Console/byte DEO |
|
| 71 |
+ ;tiles .style PEK #10 MUL TOS ADD2 #21 ;cover-pattern JSR2 |
|
| 72 |
+ ;redraw JSR2 |
|
| 73 |
+ ( release ) #00 .Mouse/state DEO |
|
| 74 |
+ &no-touch |
|
| 75 |
+ |
|
| 76 |
+BRK |
|
| 77 |
+ |
|
| 78 |
+@redraw ( -- ) |
|
| 79 |
+ |
|
| 80 |
+ ( hrs ) |
|
| 81 |
+ [ .center/x PEK2 #0018 SUB2 ] |
|
| 82 |
+ [ .center/y PEK2 #0048 SUB2 ] |
|
| 83 |
+ .DateTime/hour DEI #0a DIV ;draw-number JSR2 |
|
| 84 |
+ [ .center/x PEK2 #0008 ADD2 ] |
|
| 85 |
+ [ .center/y PEK2 #0048 SUB2 ] |
|
| 86 |
+ .DateTime/hour DEI #0a MOD ;draw-number JSR2 |
|
| 87 |
+ ( min ) |
|
| 88 |
+ [ .center/x PEK2 #0018 SUB2 ] |
|
| 89 |
+ [ .center/y PEK2 #0018 SUB2 ] |
|
| 90 |
+ .DateTime/minute DEI #0a DIV ;draw-number JSR2 |
|
| 91 |
+ [ .center/x PEK2 #0008 ADD2 ] |
|
| 92 |
+ [ .center/y PEK2 #0018 SUB2 ] |
|
| 93 |
+ .DateTime/minute DEI #0a MOD ;draw-number JSR2 |
|
| 94 |
+ ( sec ) |
|
| 95 |
+ [ .center/x PEK2 #0018 SUB2 ] |
|
| 96 |
+ [ .center/y PEK2 #0018 ADD2 ] |
|
| 97 |
+ .DateTime/second DEI #0a DIV |
|
| 98 |
+ ;draw-number JSR2 |
|
| 99 |
+ [ .center/x PEK2 #0008 ADD2 ] |
|
| 100 |
+ [ .center/y PEK2 #0018 ADD2 ] |
|
| 101 |
+ .DateTime/second DEI #0a MOD |
|
| 102 |
+ ;draw-number JSR2 |
|
| 103 |
+ |
|
| 104 |
+RTN |
|
| 105 |
+ |
|
| 106 |
+@draw-number ( x y n -- ) |
|
| 107 |
+ |
|
| 108 |
+ STH |
|
| 109 |
+ ( save pos ) .anchor/y POK2 .anchor/x POK2 |
|
| 110 |
+ #00 #0f |
|
| 111 |
+ &loop |
|
| 112 |
+ ( save-x ) OVR #03 MOD TOS #0008 MUL2 .anchor/x PEK2 ADD2 .Screen/x DEO2 |
|
| 113 |
+ ( save-y ) OVR #03 DIV TOS #0008 MUL2 .anchor/y PEK2 ADD2 .Screen/y DEO2 |
|
| 114 |
+ ( get digit* ) OVR DUPr STHr #02 MUL TOS ;digits ADD2 GET2 |
|
| 115 |
+ ( get bit ) ROT #0e SWP SUB TOS SFT2 #0001 AND2 |
|
| 116 |
+ ( set tile ) #0008 MUL2 ;tiles ADD2 |
|
| 117 |
+ ( set style ) .style PEK #10 MUL TOS ADD2 |
|
| 118 |
+ .Screen/addr DEO2 |
|
| 119 |
+ ( draw ) #21 .Screen/color DEO |
|
| 120 |
+ ( incr ) SWP INC SWP |
|
| 121 |
+ DUP2 LTH ,&loop JNZ |
|
| 122 |
+ POP2 |
|
| 123 |
+ POPr |
|
| 124 |
+ |
|
| 125 |
+RTN |
|
| 126 |
+ |
|
| 127 |
+@cover-pattern ( addr color -- ) |
|
| 128 |
+ |
|
| 129 |
+ ( load ) .color POK .Screen/addr DEO2 |
|
| 130 |
+ #0000 .Screen/height DEI2 |
|
| 131 |
+ &ver |
|
| 132 |
+ ( save ) OVR2 .Screen/y DEO2 |
|
| 133 |
+ #0000 .Screen/width DEI2 |
|
| 134 |
+ &hor |
|
| 135 |
+ ( save ) OVR2 .Screen/x DEO2 |
|
| 136 |
+ ( draw ) .color PEK .Screen/color DEO |
|
| 137 |
+ ( incr ) SWP2 8+ SWP2 |
|
| 138 |
+ OVR2 OVR2 LTH2 ,&hor JNZ |
|
| 139 |
+ POP2 POP2 |
|
| 140 |
+ ( incr ) SWP2 8+ SWP2 |
|
| 141 |
+ OVR2 OVR2 LTH2 ,&ver JNZ |
|
| 142 |
+ POP2 POP2 |
|
| 143 |
+ |
|
| 144 |
+RTN |
|
| 145 |
+ |
|
| 146 |
+@draw-cursor ( -- ) |
|
| 147 |
+ |
|
| 148 |
+ ( clear last cursor ) |
|
| 149 |
+ ;clear .Screen/addr DEO2 |
|
| 150 |
+ .pointer/x PEK2 .Screen/x DEO2 |
|
| 151 |
+ .pointer/y PEK2 .Screen/y DEO2 |
|
| 152 |
+ #30 .Screen/color DEO |
|
| 153 |
+ ( record pointer positions ) |
|
| 154 |
+ .Mouse/x DEI2 .pointer/x POK2 |
|
| 155 |
+ .Mouse/y DEI2 .pointer/y POK2 |
|
| 156 |
+ ( draw new cursor ) |
|
| 157 |
+ ;cursor .Screen/addr DEO2 |
|
| 158 |
+ .pointer/x PEK2 .Screen/x DEO2 |
|
| 159 |
+ .pointer/y PEK2 .Screen/y DEO2 |
|
| 160 |
+ ( colorize on state ) |
|
| 161 |
+ #31 [ .Mouse/state DEI #00 NEQ ] ADD .Screen/color DEO |
|
| 162 |
+ |
|
| 163 |
+RTN |
|
| 164 |
+ |
|
| 165 |
+@clear [ |
|
| 166 |
+ 0000 0000 0000 0000 ] |
|
| 167 |
+@cursor [ |
|
| 168 |
+ 80c0 e0f0 f8e0 1000 ] |
|
| 169 |
+@digits [ |
|
| 170 |
+ 7b6f 2492 73e7 73cf 5bc9 |
|
| 171 |
+ 79cf 49ef 7249 7bef 7bc9 ] |
|
| 172 |
+@tiles [ |
|
| 173 |
+ 0102 0408 1020 4080 |
|
| 174 |
+ 8040 2010 0804 0201 |
|
| 175 |
+ 0718 2040 4080 8080 |
|
| 176 |
+ 0101 0102 0204 18e0 |
|
| 177 |
+ 0808 0810 e304 0808 |
|
| 178 |
+ 0808 0804 e310 0808 ] |