... | ... |
@@ -1,4 +1,6 @@ |
1 |
-( a simple calculator ) |
|
1 |
+( |
|
2 |
+ a simple calculator |
|
3 |
+ uxnasm projects/software/calc.tal bin/calc.rom && uxnemu bin/calc.rom ) |
|
2 | 4 |
|
3 | 5 |
%+ { ADD } %- { SUB } %/ { DIV } |
4 | 6 |
%< { LTH } %> { GTH } %= { EQU } %! { NEQ } |
... | ... |
@@ -34,7 +36,6 @@ |
34 | 36 |
|80 @Controller [ &vector $2 &button $1 &key $1 ] |
35 | 37 |
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ] |
36 | 38 |
|a0 @File [ &vector $2 &success $2 &offset-hs $2 &offset-ls $2 &name $2 &length $2 &load $2 &save $2 ] |
37 |
-|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ] |
|
38 | 39 |
|
39 | 40 |
( variables ) |
40 | 41 |
|
... | ... |
@@ -48,7 +49,7 @@ |
48 | 49 |
@center |
49 | 50 |
&x $2 &y $2 |
50 | 51 |
@pointer |
51 |
- &x $2 &y $2 |
|
52 |
+ &x $2 &y $2 &last $1 |
|
52 | 53 |
@keypad-frame |
53 | 54 |
&x $2 &y $2 &x2 $2 &y2 $2 |
54 | 55 |
@modpad-frame |
... | ... |
@@ -63,9 +64,9 @@ |
63 | 64 |
|0100 ( -> ) |
64 | 65 |
|
65 | 66 |
( theme ) |
66 |
- #6e7d .System/r DEO2 |
|
67 |
- #6ec6 .System/g DEO2 |
|
68 |
- #6e95 .System/b DEO2 |
|
67 |
+ #0e7d .System/r DEO2 |
|
68 |
+ #0ec6 .System/g DEO2 |
|
69 |
+ #0e95 .System/b DEO2 |
|
69 | 70 |
|
70 | 71 |
( size ) |
71 | 72 |
#0090 .Screen/width DEO2 |
... | ... |
@@ -109,7 +110,7 @@ |
109 | 110 |
.center/x LDZ2 #0020 -- |
110 | 111 |
DUP2 .input-frame/x STZ2 |
111 | 112 |
#0040 ++ .input-frame/x2 STZ2 |
112 |
- .center/y LDZ2 #0030 -- |
|
113 |
+ .center/y LDZ2 #002a -- |
|
113 | 114 |
DUP2 .input-frame/y STZ2 |
114 | 115 |
#0010 ++ .input-frame/y2 STZ2 |
115 | 116 |
|
... | ... |
@@ -164,20 +165,29 @@ BRK |
164 | 165 |
.pointer/y LDZ2 .Screen/y DEO2 |
165 | 166 |
#41 .Mouse/state DEI #01 = + .Screen/sprite DEO |
166 | 167 |
|
167 |
- .Mouse/state DEI #00 ! ,&continue JCN |
|
168 |
- ;redraw JSR2 BRK |
|
169 |
- &continue |
|
170 |
- |
|
171 |
- .Mouse/x DEI2 .Mouse/y DEI2 |
|
172 |
- OVR2 OVR2 .keypad-frame |
|
173 |
- ;within-rect JSR2 ;click-keypad JCN2 |
|
174 |
- OVR2 OVR2 .input-frame |
|
175 |
- ;within-rect JSR2 ;click-input JCN2 |
|
176 |
- OVR2 OVR2 .modpad-frame |
|
177 |
- ;within-rect JSR2 ;click-modpad JCN2 |
|
178 |
- OVR2 OVR2 .bitpad-frame |
|
179 |
- ;within-rect JSR2 ;click-bitpad JCN2 |
|
180 |
- POP2 POP2 |
|
168 |
+ ( handle events ) |
|
169 |
+ .Mouse/state DEI .pointer/last LDZ |
|
170 |
+ DUP2 #0100 !! ,&no-down JCN |
|
171 |
+ .Mouse/state DEI .pointer/last STZ |
|
172 |
+ POP2 |
|
173 |
+ .Mouse/x DEI2 .Mouse/y DEI2 |
|
174 |
+ OVR2 OVR2 .keypad-frame |
|
175 |
+ ;within-rect JSR2 ;click-keypad JCN2 |
|
176 |
+ OVR2 OVR2 .input-frame |
|
177 |
+ ;within-rect JSR2 ;click-input JCN2 |
|
178 |
+ OVR2 OVR2 .modpad-frame |
|
179 |
+ ;within-rect JSR2 ;click-modpad JCN2 |
|
180 |
+ OVR2 OVR2 .bitpad-frame |
|
181 |
+ ;within-rect JSR2 ;click-bitpad JCN2 |
|
182 |
+ POP2 POP2 |
|
183 |
+ BRK |
|
184 |
+ &no-down |
|
185 |
+ DUP2 #0001 !! ,&no-up JCN |
|
186 |
+ .Mouse/state DEI .pointer/last STZ |
|
187 |
+ POP2 ;redraw JSR2 BRK |
|
188 |
+ &no-up |
|
189 |
+ POP2 |
|
190 |
+ .Mouse/state DEI .pointer/last STZ |
|
181 | 191 |
|
182 | 192 |
BRK |
183 | 193 |
|
... | ... |
@@ -230,12 +240,10 @@ BRK |
230 | 240 |
|
231 | 241 |
POP2 |
232 | 242 |
.input-frame/x LDZ2 -- 8// NIP |
233 |
- DUP #06 ! ,&no-push JCN |
|
234 |
- .input/value LDZ2 #0001 << ,&no-push-empty JCN |
|
235 |
- ;do-push JSR2 |
|
236 |
- &no-push-empty |
|
243 |
+ DUP #00 ! ,&no-push JCN |
|
244 |
+ ;do-push JSR2 |
|
237 | 245 |
&no-push |
238 |
- DUP #07 ! ,&no-pop JCN |
|
246 |
+ DUP #01 ! ,&no-pop JCN |
|
239 | 247 |
;do-pop JSR2 |
240 | 248 |
&no-pop |
241 | 249 |
POP |
... | ... |
@@ -277,9 +285,12 @@ RTN |
277 | 285 |
|
278 | 286 |
@do-push ( -- ) |
279 | 287 |
|
280 |
- .stack/length LDZ #07 < ,&continue JCN |
|
288 |
+ .input/value LDZ2 #0000 >> ,¬-empty JCN |
|
281 | 289 |
RTN |
282 |
- &continue |
|
290 |
+ ¬-empty |
|
291 |
+ .stack/length LDZ #07 < ,¬-full JCN |
|
292 |
+ RTN |
|
293 |
+ ¬-full |
|
283 | 294 |
#40 .Audio0/pitch DEO |
284 | 295 |
.input/value LDZ2 ;push JSR2 |
285 | 296 |
|
... | ... |
@@ -374,7 +385,7 @@ RTN |
374 | 385 |
#ff ;draw-modpad JSR2 |
375 | 386 |
#ff ;draw-input JSR2 |
376 | 387 |
;draw-bitpad JSR2 |
377 |
- ;draw-stack JSR2 |
|
388 |
+ ,draw-stack JSR |
|
378 | 389 |
|
379 | 390 |
RTN |
380 | 391 |
|
... | ... |
@@ -384,8 +395,8 @@ RTN |
384 | 395 |
&loop |
385 | 396 |
( color ) DUP #08 .stack/length LDZ - #01 - > STH |
386 | 397 |
( value ) DUP 2* .stack/items + [ #10 .stack/length LDZ 2* - - ] LDZ2 STH2 |
387 |
- ( y ) DUP TOS 8** .input-frame/y LDZ2 ++ #0048 -- STH2 |
|
388 |
- ( x ) .input-frame/x LDZ2 #0020 ++ STH2r STH2r STHr ;draw-short JSR2 |
|
398 |
+ ( y ) DUP TOS 8** .input-frame/y LDZ2 ++ #004c -- STH2 |
|
399 |
+ ( x ) .input-frame/x LDZ2 #0020 ++ STH2r STH2r STHr ,draw-short JSR |
|
389 | 400 |
INC GTHk ,&loop JCN |
390 | 401 |
POP2 |
391 | 402 |
|
... | ... |
@@ -395,13 +406,20 @@ RTN |
395 | 406 |
|
396 | 407 |
STH STH2 |
397 | 408 |
.Screen/y DEO2 |
398 |
- .Screen/x DEO2 |
|
409 |
+ #0020 ++ .Screen/x DEO2 |
|
399 | 410 |
#04 #00 |
400 | 411 |
&loop |
401 | 412 |
.Screen/x DEI2 #0008 -- .Screen/x DEO2 |
402 | 413 |
( value ) DUP STH2kr ROT 4* SFT2 #000f AND2 |
403 | 414 |
( value glyph ) 8** ;font-hex ++ .Screen/addr DEO2 |
404 |
- ROTr STHkr ROTr ROTr .Screen/sprite DEO |
|
415 |
+ ( no not draw zeros ) |
|
416 |
+ ( get color ) ROTr STHkr |
|
417 |
+ ( place stack ) ROTr ROTr |
|
418 |
+ ( no leading zeros ) |
|
419 |
+ OVR STH2kr ,get-length JSR < ,&visible JCN |
|
420 |
+ POP #00 |
|
421 |
+ &visible |
|
422 |
+ ( draw ) .Screen/sprite DEO |
|
405 | 423 |
INC GTHk ,&loop JCN |
406 | 424 |
POP2 |
407 | 425 |
POP2r POPr |
... | ... |
@@ -420,24 +438,21 @@ RTN |
420 | 438 |
@draw-input ( key -- ) |
421 | 439 |
|
422 | 440 |
STH |
423 |
- .input-frame/y LDZ2 #0003 ++ .Screen/y DEO2 |
|
424 |
- #04 #00 |
|
425 |
- &loop |
|
426 |
- ( x ) DUP TOS 8** .input-frame/x LDZ2 #0018 ++ SWP2 -- .Screen/x DEO2 |
|
427 |
- ( value ) STHk .input/value LDZ2 STHr 4* SFT2 #000f AND2 |
|
428 |
- ( value glyph ) 8** ;font-hex ++ .Screen/addr DEO2 |
|
429 |
- ( color ) DUP INC .input/value LDZ2 ,get-length JSR > |
|
430 |
- #01 + .Screen/sprite DEO |
|
431 |
- INC GTHk ,&loop JCN |
|
432 |
- POP2 |
|
441 |
+ |
|
442 |
+ ( draw value ) |
|
443 |
+ .input-frame/x LDZ2 #0020 ++ |
|
444 |
+ .input-frame/y LDZ2 #0003 ++ |
|
445 |
+ .input/value LDZ2 |
|
446 |
+ #02 |
|
447 |
+ ;draw-short JSR2 |
|
433 | 448 |
|
434 | 449 |
( controls ) |
435 |
- .input-frame/x LDZ2 #0030 ++ |
|
450 |
+ .input-frame/x LDZ2 |
|
436 | 451 |
.input-frame/y LDZ2 |
437 | 452 |
;stack-icns/push [ STHkr #00 = ] #02 |
438 | 453 |
;draw-key-thin JSR2 |
439 | 454 |
|
440 |
- .input-frame/x LDZ2 #0038 ++ |
|
455 |
+ .input-frame/x LDZ2 #0008 ++ |
|
441 | 456 |
.input-frame/y LDZ2 |
442 | 457 |
;stack-icns/pop [ STHkr #01 = ] #03 |
443 | 458 |
;draw-key-thin JSR2 |