bifurcan.tal (3550B)
1 ( Bifurcan ) 2 3 |00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2 4 |20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 5 |90 @Mouse &vector $2 &x $2 &y $2 &state $1 &wheel $1 6 |c0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 7 |80 @Controller &vector $2 &button $1 &key $1 8 |000 9 10 @last $1 11 @style $1 12 @center &x $2 &y $2 13 14 |100 15 16 @on-reset ( -> ) 17 ( | theme ) 18 #0f3a .System/r DEO2 19 #0fda .System/g DEO2 20 #0faa .System/b DEO2 21 ( | vectors ) 22 ;on-frame .Screen/vector DEO2 23 ;on-mouse .Mouse/vector DEO2 24 ;on-button .Controller/vector DEO2 25 ( | find center ) 26 .Screen/width DEI2 #01 SFT2 #33 SFT2 .center/x STZ2 27 .Screen/height DEI2 #01 SFT2 #33 SFT2 .center/y STZ2 28 ( | background ) 29 ;tiles <cover-pattern> 30 <redraw> 31 BRK 32 33 @on-frame ( -> ) 34 ( | only draw once per second ) 35 .DateTime/second DEI .last LDZ NEQk ?{ POP2 BRK } 36 .last STZ 37 POP <redraw> 38 BRK 39 40 @on-mouse ( -> ) 41 [ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;cursor-icn <update-cursor> 42 .Mouse/state DEI ?{ BRK } 43 select [ LIT2 00 -Mouse/state ] DEO 44 BRK 45 46 @on-button ( -> ) 47 .Controller/button DEI ?{ BRK } 48 select [ LIT2 00 -Controller/button ] DEO 49 BRK 50 51 @select ( -- ) 52 .style LDZ INC #03 DIVk MUL SUB .style STZ 53 ;tiles [ LIT2 00 -style ] LDZ #40 SFT ADD2 <cover-pattern> 54 ( >> ) 55 56 ( 57 @|drawing ) 58 59 @<redraw> ( -- ) 60 ( | hrs ) 61 [ .center/x LDZ2 #0018 SUB2 ] [ .center/y LDZ2 #0048 SUB2 ] .DateTime/hour DEI #0a DIV <draw-number> 62 [ .center/x LDZ2 #0008 ADD2 ] [ .center/y LDZ2 #0048 SUB2 ] .DateTime/hour DEI #0a DIVk MUL SUB <draw-number> 63 ( | min ) 64 [ .center/x LDZ2 #0018 SUB2 ] [ .center/y LDZ2 #0018 SUB2 ] .DateTime/minute DEI #0a DIV <draw-number> 65 [ .center/x LDZ2 #0008 ADD2 ] [ .center/y LDZ2 #0018 SUB2 ] .DateTime/minute DEI #0a DIVk MUL SUB <draw-number> 66 ( | sec ) 67 [ .center/x LDZ2 #0018 SUB2 ] [ .center/y LDZ2 #0018 ADD2 ] .DateTime/second DEI #0a DIV <draw-number> 68 [ .center/x LDZ2 #0008 ADD2 ] [ .center/y LDZ2 #0018 ADD2 ] .DateTime/second DEI #0a DIVk MUL SUB 69 70 @<draw-number> ( x* y* n -- ) 71 ,&digit STR 72 ,&y STR2 73 ,&x STR2 74 #0f00 75 &>loop ( -- ) 76 ( save-x ) DUP #03 DIVk MUL SUB #00 SWP #30 SFT2 [ LIT2 &x $2 ] ADD2 .Screen/x DEO2 77 ( save-y ) DUP #03 DIV #00 SWP #30 SFT2 [ LIT2 &y $2 ] ADD2 .Screen/y DEO2 78 ( get digit* ) DUP [ LIT &digit $1 ] DUP ADD #00 SWP ;digits ADD2 LDA2 79 ( get bit ) ROT #0e SWP SUB SFT2 #0001 AND2 80 ( set tile ) #30 SFT2 ;tiles ADD2 81 ( set style ) .style LDZ #40 SFT #00 SWP ADD2 .Screen/addr DEO2 82 ( draw ) [ LIT2 01 -Screen/sprite ] DEO 83 INC GTHk ?&>loop 84 POP2 JMP2r 85 86 @<cover-pattern> ( addr* -- ) 87 .Screen/addr DEO2 88 .Screen/height DEI2 #03 SFT2 ,&h STR 89 POP .Screen/width DEI2 #03 SFT2 ,&w STR 90 POP [ LIT &h $1 ] #00 91 &>ver ( -- ) 92 #00 OVR #30 SFT2 .Screen/y DEO2 93 [ LIT &w $1 ] #00 94 &>hor ( -- ) 95 #00 OVR #30 SFT2 .Screen/x DEO2 96 [ LIT2 01 -Screen/sprite ] DEO 97 INC GTHk ?&>hor 98 POP2 INC GTHk ?&>ver 99 POP2 JMP2r 100 101 @<update-cursor> ( color addr* -- ) 102 [ LIT2 00 -Screen/auto ] DEO 103 ;fill-icn .Screen/addr DEO2 104 #40 <draw-cursor> 105 .Mouse/x DEI2 ,<draw-cursor>/x STR2 106 .Mouse/y DEI2 ,<draw-cursor>/y STR2 107 .Screen/addr DEO2 108 ( >> ) 109 110 @<draw-cursor> ( color -- ) 111 [ LIT2 &x $2 ] .Screen/x DEO2 112 [ LIT2 &y $2 ] .Screen/y DEO2 113 .Screen/sprite DEO 114 JMP2r 115 116 ( 117 @|assets ) 118 119 @cursor-icn [ 80c0 e0f0 f8e0 1000 ] 120 121 @fill-icn [ ffff ffff ffff ffff ] 122 123 @digits [ 124 7b6f 2492 73e7 73cf 5bc9 79cf 49ef 7249 125 7bef 7bc9 ] 126 127 @tiles [ 128 0102 0408 1020 4080 8040 2010 0804 0201 129 0718 2040 4080 8080 0101 0102 0204 18e0 130 0808 0810 e304 0808 0808 0804 e310 0808 ] 131