... | ... |
@@ -1,15 +1,4 @@ |
1 |
-( |
|
2 |
- Bifurcan |
|
3 |
- Every second, the Labyrinth reorganize itself to display the time. |
|
4 |
-) |
|
5 |
- |
|
6 |
-%RTN { JMP2r } |
|
7 |
-%MOD { DUP2 DIV MUL SUB } |
|
8 |
-%TOS { #00 SWP } |
|
9 |
-%2// { #01 SFT2 } |
|
10 |
-%8** { #30 SFT2 } |
|
11 |
- |
|
12 |
-( devices ) |
|
1 |
+( Bifurcan ) |
|
13 | 2 |
|
14 | 3 |
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] |
15 | 4 |
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ] |
... | ... |
@@ -17,17 +6,12 @@ |
17 | 6 |
|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ] |
18 | 7 |
|80 @Controller [ &vector $2 &button $1 &key $1 ] |
19 | 8 |
|
20 |
-( variables ) |
|
21 |
- |
|
22 | 9 |
|0000 |
23 | 10 |
|
24 | 11 |
@last $1 |
25 | 12 |
@style $1 |
26 | 13 |
@pointer [ &x $2 &y $2 ] |
27 | 14 |
@center [ &x $2 &y $2 ] |
28 |
-@anchor [ &x $2 &y $2 ] |
|
29 |
- |
|
30 |
-( program ) |
|
31 | 15 |
|
32 | 16 |
|0100 ( -> ) |
33 | 17 |
|
... | ... |
@@ -35,16 +19,13 @@ |
35 | 19 |
#0f3a .System/r DEO2 |
36 | 20 |
#0fda .System/g DEO2 |
37 | 21 |
#0faa .System/b DEO2 |
38 |
- |
|
39 | 22 |
( vectors ) |
40 | 23 |
;on-frame .Screen/vector DEO2 |
41 | 24 |
;on-mouse .Mouse/vector DEO2 |
42 | 25 |
;on-button .Controller/vector DEO2 |
43 |
- |
|
44 | 26 |
( find center ) |
45 |
- .Screen/width DEI2 2// .center/x STZ2 |
|
46 |
- .Screen/height DEI2 2// .center/y STZ2 |
|
47 |
- |
|
27 |
+ .Screen/width DEI2 #01 SFT2 .center/x STZ2 |
|
28 |
+ .Screen/height DEI2 #01 SFT2 .center/y STZ2 |
|
48 | 29 |
( background ) |
49 | 30 |
;tiles ;cover-pattern JSR2 |
50 | 31 |
;redraw JSR2 |
... | ... |
@@ -54,8 +35,7 @@ BRK |
54 | 35 |
@on-frame ( -> ) |
55 | 36 |
|
56 | 37 |
( only draw once per second ) |
57 |
- .DateTime/second DEI .last LDZ NEQ #01 JCN [ BRK ] |
|
58 |
- |
|
38 |
+ .DateTime/second DEI .last LDZ NEQ JMP [ BRK ] |
|
59 | 39 |
.DateTime/second DEI .last STZ |
60 | 40 |
;redraw JSR2 |
61 | 41 |
|
... | ... |
@@ -65,26 +45,27 @@ BRK |
65 | 45 |
|
66 | 46 |
;draw-cursor JSR2 |
67 | 47 |
|
68 |
- .Mouse/state DEI #00 EQU ,&no-touch JCN |
|
69 |
- ( incr ) .style LDZ INC #03 MOD .style STZ |
|
70 |
- ( bg ) ;tiles .style LDZ #40 SFT TOS ADD2 ;cover-pattern JSR2 |
|
71 |
- ( fg ) ;redraw JSR2 |
|
72 |
- ( release ) #00 .Mouse/state DEO |
|
73 |
- &no-touch |
|
48 |
+ .Mouse/state DEI #00 NEQ JMP BRK |
|
49 |
+ ,select JSR |
|
74 | 50 |
|
75 | 51 |
BRK |
76 | 52 |
|
77 | 53 |
@on-button ( -> ) |
78 | 54 |
|
79 |
- .Controller/button DEI #00 EQU ,&no-touch JCN |
|
80 |
- ( incr ) .style LDZ INC #03 MOD .style STZ |
|
81 |
- ( bg ) ;tiles .style LDZ #40 SFT TOS ADD2 ;cover-pattern JSR2 |
|
82 |
- ( fg ) ;redraw JSR2 |
|
83 |
- ( release ) #00 .Mouse/state DEO |
|
84 |
- &no-touch |
|
85 |
- |
|
55 |
+ .Controller/button DEI #00 NEQ JMP BRK |
|
56 |
+ ,select JSR |
|
57 |
+ |
|
86 | 58 |
BRK |
87 | 59 |
|
60 |
+@select ( -- ) |
|
61 |
+ |
|
62 |
+ ( incr ) .style LDZ INC #03 ;mod JSR2 .style STZ |
|
63 |
+ ( bg ) ;tiles [ #00 .style LDZ #40 SFT ] ADD2 ;cover-pattern JSR2 |
|
64 |
+ ( fg ) ;redraw JSR2 |
|
65 |
+ ( release ) #0000 .Mouse/state DEO .Controller/button DEO |
|
66 |
+ |
|
67 |
+JMP2r |
|
68 |
+ |
|
88 | 69 |
@redraw ( -- ) |
89 | 70 |
|
90 | 71 |
( hrs ) |
... | ... |
@@ -93,14 +74,14 @@ BRK |
93 | 74 |
.DateTime/hour DEI #0a DIV ;draw-number JSR2 |
94 | 75 |
[ .center/x LDZ2 #0008 ADD2 ] |
95 | 76 |
[ .center/y LDZ2 #0048 SUB2 ] |
96 |
- .DateTime/hour DEI #0a MOD ;draw-number JSR2 |
|
77 |
+ .DateTime/hour DEI #0a ;mod JSR2 ;draw-number JSR2 |
|
97 | 78 |
( min ) |
98 | 79 |
[ .center/x LDZ2 #0018 SUB2 ] |
99 | 80 |
[ .center/y LDZ2 #0018 SUB2 ] |
100 | 81 |
.DateTime/minute DEI #0a DIV ;draw-number JSR2 |
101 | 82 |
[ .center/x LDZ2 #0008 ADD2 ] |
102 | 83 |
[ .center/y LDZ2 #0018 SUB2 ] |
103 |
- .DateTime/minute DEI #0a MOD ;draw-number JSR2 |
|
84 |
+ .DateTime/minute DEI #0a ;mod JSR2 ;draw-number JSR2 |
|
104 | 85 |
( sec ) |
105 | 86 |
[ .center/x LDZ2 #0018 SUB2 ] |
106 | 87 |
[ .center/y LDZ2 #0018 ADD2 ] |
... | ... |
@@ -108,50 +89,47 @@ BRK |
108 | 89 |
;draw-number JSR2 |
109 | 90 |
[ .center/x LDZ2 #0008 ADD2 ] |
110 | 91 |
[ .center/y LDZ2 #0018 ADD2 ] |
111 |
- .DateTime/second DEI #0a MOD |
|
92 |
+ .DateTime/second DEI #0a ;mod JSR2 |
|
112 | 93 |
;draw-number JSR2 |
113 | 94 |
|
114 |
-RTN |
|
95 |
+JMP2r |
|
115 | 96 |
|
116 | 97 |
@draw-number ( x* y* n -- ) |
117 | 98 |
|
118 |
- STH |
|
119 |
- ( save pos ) .anchor/y STZ2 .anchor/x STZ2 |
|
120 |
- #00 #0f |
|
99 |
+ ,&digit STR ,&y STR2 ,&x STR2 |
|
100 |
+ #0f00 |
|
121 | 101 |
&loop |
122 |
- ( save-x ) OVR #03 MOD TOS 8** .anchor/x LDZ2 ADD2 .Screen/x DEO2 |
|
123 |
- ( save-y ) OVR #03 DIV TOS 8** .anchor/y LDZ2 ADD2 .Screen/y DEO2 |
|
124 |
- ( get digit* ) OVR STHkr DUP ADD TOS ;digits ADD2 LDA2 |
|
102 |
+ ( save-x ) DUP #03 ;mod JSR2 #00 SWP #30 SFT2 [ LIT2 &x $2 ] ADD2 .Screen/x DEO2 |
|
103 |
+ ( save-y ) DUP #03 DIV #00 SWP #30 SFT2 [ LIT2 &y $2 ] ADD2 .Screen/y DEO2 |
|
104 |
+ ( get digit* ) DUP [ LIT &digit $1 ] DUP ADD #00 SWP ;digits ADD2 LDA2 |
|
125 | 105 |
( get bit ) ROT #0e SWP SUB SFT2 #0001 AND2 |
126 |
- ( set tile ) 8** ;tiles ADD2 |
|
127 |
- ( set style ) .style LDZ #40 SFT TOS ADD2 |
|
128 |
- .Screen/addr DEO2 |
|
106 |
+ ( set tile ) #30 SFT2 ;tiles ADD2 |
|
107 |
+ ( set style ) .style LDZ #40 SFT #00 SWP ADD2 |
|
108 |
+ .Screen/addr DEO2 |
|
129 | 109 |
( draw ) #01 .Screen/sprite DEO |
130 |
- ( incr ) SWP INC SWP |
|
131 |
- LTHk ,&loop JCN |
|
110 |
+ INC GTHk ,&loop JCN |
|
132 | 111 |
POP2 |
133 |
- POPr |
|
134 | 112 |
|
135 |
-RTN |
|
113 |
+JMP2r |
|
136 | 114 |
|
137 | 115 |
@cover-pattern ( addr* -- ) |
138 | 116 |
|
139 |
- ( load ) .Screen/addr DEO2 |
|
140 |
- #0000 .Screen/height DEI2 |
|
117 |
+ .Screen/addr DEO2 |
|
118 |
+ .Screen/height DEI2 #03 SFT2 NIP ,&h STR |
|
119 |
+ .Screen/width DEI2 #03 SFT2 NIP ,&w STR |
|
120 |
+ [ LIT &h $1 ] #00 |
|
141 | 121 |
&ver |
142 |
- ( save ) OVR2 .Screen/y DEO2 |
|
143 |
- #0000 .Screen/width DEI2 |
|
122 |
+ #00 OVR #30 SFT2 .Screen/y DEO2 |
|
123 |
+ [ LIT &w $1 ] #00 |
|
144 | 124 |
&hor |
145 |
- ( save ) OVR2 .Screen/x DEO2 |
|
146 |
- ( draw ) #01 .Screen/sprite DEO |
|
147 |
- ( incr ) SWP2 #0008 ADD2 SWP2 |
|
148 |
- LTH2k ,&hor JCN |
|
149 |
- POP2 POP2 |
|
150 |
- ( incr ) SWP2 #0008 ADD2 SWP2 |
|
151 |
- LTH2k ,&ver JCN |
|
152 |
- POP2 POP2 |
|
125 |
+ #00 OVR #30 SFT2 .Screen/x DEO2 |
|
126 |
+ #01 .Screen/sprite DEO |
|
127 |
+ INC GTHk ,&hor JCN |
|
128 |
+ POP2 |
|
129 |
+ INC GTHk ,&ver JCN |
|
130 |
+ POP2 |
|
153 | 131 |
|
154 |
-RTN |
|
132 |
+JMP2r |
|
155 | 133 |
|
156 | 134 |
@draw-cursor ( -- ) |
157 | 135 |
|
... | ... |
@@ -166,20 +144,22 @@ RTN |
166 | 144 |
( colorize on state ) |
167 | 145 |
#41 [ .Mouse/state DEI #00 NEQ ] ADD .Screen/sprite DEO |
168 | 146 |
|
169 |
-RTN |
|
147 |
+JMP2r |
|
148 |
+ |
|
149 |
+@mod DUP2 DIV MUL SUB JMP2r |
|
170 | 150 |
|
171 |
-@cursor [ |
|
172 |
- 80c0 e0f0 f8e0 1000 ] |
|
151 |
+@cursor |
|
152 |
+ 80c0 e0f0 f8e0 1000 |
|
173 | 153 |
|
174 |
-@digits [ |
|
154 |
+@digits |
|
175 | 155 |
7b6f 2492 73e7 73cf |
176 | 156 |
5bc9 79cf 49ef 7249 |
177 |
- 7bef 7bc9 ] |
|
157 |
+ 7bef 7bc9 |
|
178 | 158 |
|
179 |
-@tiles [ |
|
159 |
+@tiles |
|
180 | 160 |
0102 0408 1020 4080 |
181 | 161 |
8040 2010 0804 0201 |
182 | 162 |
0718 2040 4080 8080 |
183 | 163 |
0101 0102 0204 18e0 |
184 | 164 |
0808 0810 e304 0808 |
185 |
- 0808 0804 e310 0808 ] |
|
165 |
+ 0808 0804 e310 0808 |
186 | 166 |
similarity index 68% |
187 | 167 |
rename from projects/examples/gui/animation.tal |
188 | 168 |
rename to projects/examples/demos/dvd.tal |
... | ... |
@@ -1,20 +1,11 @@ |
1 |
-( GUI Animation ) |
|
2 |
- |
|
3 |
-%2// { #01 SFT2 } |
|
4 |
-%AUTO-XADDR { #05 .Screen/auto DEO } |
|
5 |
- |
|
6 |
-( devices ) |
|
1 |
+( DVD Bounce ) |
|
7 | 2 |
|
8 | 3 |
|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1 |
9 | 4 |
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 |
10 | 5 |
|
11 | 6 |
|0000 |
12 | 7 |
|
13 |
-@dvd |
|
14 |
- &x $2 &y $2 |
|
15 |
- &dx $1 &dy $1 |
|
16 |
- |
|
17 |
-( program ) |
|
8 |
+@dvd &x $2 &y $2 &dx $1 &dy $1 |
|
18 | 9 |
|
19 | 10 |
|0100 ( -> ) |
20 | 11 |
|
... | ... |
@@ -22,57 +13,41 @@ |
22 | 13 |
#4cfd .System/r DEO2 |
23 | 14 |
#4cf3 .System/g DEO2 |
24 | 15 |
#dcf2 .System/b DEO2 |
25 |
- |
|
26 | 16 |
( vectors ) |
27 | 17 |
;on-frame .Screen/vector DEO2 |
28 |
- |
|
29 | 18 |
( starting position ) |
30 |
- .Screen/width DEI2 2// .dvd/x STZ2 |
|
31 |
- .Screen/height DEI2 2// .dvd/y STZ2 |
|
32 |
- |
|
33 |
- AUTO-XADDR |
|
34 |
- |
|
35 |
- #01 ;draw-dvd JSR2 |
|
19 |
+ .Screen/width DEI2 #01 SFT2 .dvd/x STZ2 |
|
20 |
+ .Screen/height DEI2 #01 SFT2 .dvd/y STZ2 |
|
21 |
+ #36 .Screen/auto DEO |
|
22 |
+ #01 ,draw-dvd JSR |
|
36 | 23 |
|
37 | 24 |
BRK |
38 | 25 |
|
39 | 26 |
@on-frame ( -> ) |
40 | 27 |
|
41 |
- #00 ;draw-dvd JSR2 |
|
42 |
- |
|
28 |
+ #00 ,draw-dvd JSR |
|
43 | 29 |
( case: hit-right ) .dvd/x LDZ2 .Screen/width DEI2 #0020 SUB2 EQU2 |
44 | 30 |
( case: hit-left ) .dvd/x LDZ2 #0000 EQU2 |
45 | 31 |
#0000 EQU2 ,&no-flipx JCN |
46 |
- .dvd/dx LDZk #00 EQU SWP STZ &no-flipx |
|
47 |
- |
|
32 |
+ .dvd/dx LDZk #00 EQU SWP STZ |
|
33 |
+ &no-flipx |
|
48 | 34 |
( case: hit-bottom ) .dvd/y LDZ2 .Screen/height DEI2 #0010 SUB2 EQU2 |
49 | 35 |
( case: hit-top ) .dvd/y LDZ2 #0000 EQU2 |
50 | 36 |
#0000 EQU2 ,&no-flipy JCN |
51 |
- .dvd/dy LDZk #00 EQU SWP STZ &no-flipy |
|
52 |
- |
|
37 |
+ .dvd/dy LDZk #00 EQU SWP STZ |
|
38 |
+ &no-flipy |
|
53 | 39 |
( incr ) .dvd/x LDZ2 #0001 #00 .dvd/dx LDZ #00 EQU DUP2 ADD2 SUB2 ADD2 .dvd/x STZ2 |
54 | 40 |
( incr ) .dvd/y LDZ2 #0001 #00 .dvd/dy LDZ #00 EQU DUP2 ADD2 SUB2 ADD2 .dvd/y STZ2 |
55 |
- |
|
56 |
- #01 ;draw-dvd JSR2 |
|
41 |
+ #01 ,draw-dvd JSR |
|
57 | 42 |
|
58 | 43 |
BRK |
59 | 44 |
|
60 | 45 |
@draw-dvd ( color -- ) |
61 | 46 |
|
62 |
- STH |
|
63 | 47 |
;dvd_icn .Screen/addr DEO2 |
64 | 48 |
.dvd/x LDZ2 .Screen/x DEO2 |
65 | 49 |
.dvd/y LDZ2 .Screen/y DEO2 |
66 |
- #0800 |
|
67 |
- &loop |
|
68 |
- DUP #04 NEQ ,&no-lb JCN |
|
69 |
- .Screen/x DEI2k #0020 SUB2 ROT DEO2 |
|
70 |
- .Screen/y DEI2k #0008 ADD2 ROT DEO2 |
|
71 |
- &no-lb |
|
72 |
- STHkr .Screen/sprite DEO |
|
73 |
- INC GTHk ,&loop JCN |
|
74 |
- POP2 |
|
75 |
- POPr |
|
50 |
+ .Screen/sprite DEOk DEO |
|
76 | 51 |
|
77 | 52 |
JMP2r |
78 | 53 |
|
... | ... |
@@ -4,14 +4,10 @@ |
4 | 4 |
|0020 @Screen &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 |
5 | 5 |
|0080 @Controller &vector $2 &button $1 &key $1 |
6 | 6 |
|
7 |
-( variables ) |
|
8 |
- |
|
9 | 7 |
|0000 |
10 | 8 |
|
11 | 9 |
@slime $1 |
12 | 10 |
|
13 |
-( init ) |
|
14 |
- |
|
15 | 11 |
|0100 ( -> ) @program |
16 | 12 |
|
17 | 13 |
( theme ) |
... | ... |
@@ -4,8 +4,6 @@ |
4 | 4 |
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 |
5 | 5 |
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2 |
6 | 6 |
|
7 |
-( variables ) |
|
8 |
- |
|
9 | 7 |
|0000 |
10 | 8 |
|
11 | 9 |
@cat |
... | ... |
@@ -13,8 +11,6 @@ |
13 | 11 |
@pointer |
14 | 12 |
&x $2 &y $2 |
15 | 13 |
|
16 |
-( program ) |
|
17 |
- |
|
18 | 14 |
|0100 ( -> ) |
19 | 15 |
|
20 | 16 |
( theme ) |
... | ... |
@@ -98,11 +94,10 @@ JMP2r |
98 | 94 |
|
99 | 95 |
@draw-tail ( frame -- ) |
100 | 96 |
|
101 |
- DUP ,&last LDR NEQ ,&changed JCN |
|
102 |
- POP JMP2r &changed |
|
97 |
+ STHk ,&last LDR NEQ ,&changed JCN |
|
98 |
+ POPr JMP2r &changed |
|
103 | 99 |
( only redraw on change ) |
104 |
- DUP |
|
105 |
- ;frames ROT #00 SWP ADD2 LDA |
|
100 |
+ STHr #00 OVR ;frames ADD2 LDA |
|
106 | 101 |
#00 SWP #40 SFT2 ;body/tail ADD2 |
107 | 102 |
.Screen/addr DEO2 |
108 | 103 |
.cat/x LDZ2 .Screen/x DEO2 |