| ... | ... |
@@ -1,16 +1,5 @@ |
| 1 | 1 |
( uxnasm projects/examples/demos/snake.tal bin/snake.rom && uxnemu bin/snake.rom ) |
| 2 | 2 |
|
| 3 |
-%2/ { #01 SFT } %2* { #10 SFT }
|
|
| 4 |
-%8// { #03 SFT2 } %8** { #30 SFT2 }
|
|
| 5 |
-%MOD { DIVk MUL SUB }
|
|
| 6 |
-%MAX { LTHk JMP SWP POP }
|
|
| 7 |
-%RTN { JMP2r }
|
|
| 8 |
-%TOS { #00 SWP }
|
|
| 9 |
-%BRK? { #01 JCN BRK }
|
|
| 10 |
- |
|
| 11 |
- |
|
| 12 |
-%DIFFICULTY { #06 }
|
|
| 13 |
- |
|
| 14 | 3 |
( devices ) |
| 15 | 4 |
|
| 16 | 5 |
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 ] |
| ... | ... |
@@ -51,8 +40,8 @@ |
| 51 | 40 |
#0100 .Screen/height DEO2 |
| 52 | 41 |
|
| 53 | 42 |
( set arena ) |
| 54 |
- .Screen/width DEI2 8// NIP .arena/w STZ |
|
| 55 |
- .Screen/height DEI2 8// NIP .arena/h STZ |
|
| 43 |
+ .Screen/width DEI2 #03 SFT2 NIP .arena/w STZ |
|
| 44 |
+ .Screen/height DEI2 #03 SFT2 NIP .arena/h STZ |
|
| 56 | 45 |
|
| 57 | 46 |
;reset JSR2 |
| 58 | 47 |
|
| ... | ... |
@@ -61,7 +50,8 @@ BRK |
| 61 | 50 |
@on-frame ( -> ) |
| 62 | 51 |
|
| 63 | 52 |
.arena/timer LDZ INC DUP .arena/timer STZ |
| 64 |
- DIFFICULTY EQU BRK? |
|
| 53 |
+ #06 ( difficulty - lower value produces faster gameplay ) |
|
| 54 |
+ EQU JMP BRK |
|
| 65 | 55 |
|
| 66 | 56 |
( clear ) #00 ;draw-snake JSR2 |
| 67 | 57 |
( update ) ;move JSR2 |
| ... | ... |
@@ -90,8 +80,8 @@ BRK |
| 90 | 80 |
#00 ;draw-snake JSR2 |
| 91 | 81 |
#00 ;draw-apple JSR2 |
| 92 | 82 |
|
| 93 |
- .arena/w LDZ 2/ #01 SUB .snake/x STZ |
|
| 94 |
- .arena/h LDZ 2/ #01 SUB .snake/y STZ |
|
| 83 |
+ .arena/w LDZ #01 SFT #01 SUB .snake/x STZ |
|
| 84 |
+ .arena/h LDZ #01 SFT #01 SUB .snake/y STZ |
|
| 95 | 85 |
#00 .snake/dead STZ |
| 96 | 86 |
#00 .snake/length STZ |
| 97 | 87 |
#00 .snake/direction STZ |
| ... | ... |
@@ -99,7 +89,7 @@ BRK |
| 99 | 89 |
#03 ;draw-snake JSR2 |
| 100 | 90 |
;add-apple JSR2 |
| 101 | 91 |
|
| 102 |
-RTN |
|
| 92 |
+JMP2r |
|
| 103 | 93 |
|
| 104 | 94 |
@move ( -- ) |
| 105 | 95 |
|
| ... | ... |
@@ -107,33 +97,33 @@ RTN |
| 107 | 97 |
.snake/x LDZ2 STH2 |
| 108 | 98 |
.snake/length LDZ #00 |
| 109 | 99 |
&loop |
| 110 |
- ( pop ) DUP 2* .snake/tail ADD LDZ2 STH2 SWP2r |
|
| 111 |
- ( push ) DUP 2* .snake/tail ADD STH2r ROT STZ2 |
|
| 100 |
+ ( pop ) DUPk ADD .snake/tail ADD LDZ2 STH2 SWP2r |
|
| 101 |
+ ( push ) DUPk ADD .snake/tail ADD STH2r ROT STZ2 |
|
| 112 | 102 |
INC GTHk ,&loop JCN |
| 113 | 103 |
POP2 |
| 114 | 104 |
POP2r |
| 115 | 105 |
|
| 116 |
- .snake/dead LDZ #00 EQU JMP RTN |
|
| 106 |
+ .snake/dead LDZ #00 EQU JMP JMP2r |
|
| 117 | 107 |
|
| 118 | 108 |
.snake/direction LDZ |
| 119 | 109 |
DUP #01 NEQ ,&no-up JCN |
| 120 | 110 |
.snake/y LDZ #01 SUB |
| 121 |
- .arena/h LDZ MAX |
|
| 111 |
+ .arena/h LDZ LTHk JMP SWP POP |
|
| 122 | 112 |
.snake/y STZ |
| 123 | 113 |
&no-up |
| 124 | 114 |
DUP #02 NEQ ,&no-down JCN |
| 125 | 115 |
.snake/y LDZ INC |
| 126 |
- .arena/h LDZ MOD |
|
| 116 |
+ .arena/h LDZ DIVk MUL SUB |
|
| 127 | 117 |
.snake/y STZ |
| 128 | 118 |
&no-down |
| 129 | 119 |
DUP #04 NEQ ,&no-left JCN |
| 130 | 120 |
.snake/x LDZ #01 SUB |
| 131 |
- .arena/w LDZ MAX |
|
| 121 |
+ .arena/w LDZ LTHk JMP SWP POP |
|
| 132 | 122 |
.snake/x STZ |
| 133 | 123 |
&no-left |
| 134 | 124 |
DUP #08 NEQ ,&no-right JCN |
| 135 | 125 |
.snake/x LDZ INC |
| 136 |
- .arena/w LDZ MOD |
|
| 126 |
+ .arena/w LDZ DIVk MUL SUB |
|
| 137 | 127 |
.snake/x STZ |
| 138 | 128 |
&no-right |
| 139 | 129 |
POP |
| ... | ... |
@@ -148,7 +138,7 @@ RTN |
| 148 | 138 |
|
| 149 | 139 |
.snake/length LDZ #01 |
| 150 | 140 |
&loop-body |
| 151 |
- ( pop ) DUP 2* .snake/tail ADD LDZ2 |
|
| 141 |
+ ( pop ) DUPk ADD .snake/tail ADD LDZ2 |
|
| 152 | 142 |
.snake/x LDZ2 NEQ2 ,&no-collision-body JCN |
| 153 | 143 |
#01 .snake/dead STZ |
| 154 | 144 |
#03 ;draw-snake JSR2 |
| ... | ... |
@@ -156,16 +146,16 @@ RTN |
| 156 | 146 |
INC GTHk ,&loop-body JCN |
| 157 | 147 |
POP2 |
| 158 | 148 |
|
| 159 |
-RTN |
|
| 149 |
+JMP2r |
|
| 160 | 150 |
|
| 161 | 151 |
@add-apple ( -- ) |
| 162 | 152 |
|
| 163 | 153 |
.DateTime/hour DEI2 .DateTime/minute DEI2 MUL2 #1234 MUL2 ADD |
| 164 |
- .arena/w LDZ MOD .apple/x STZ |
|
| 154 |
+ .arena/w LDZ DIVk MUL SUB .apple/x STZ |
|
| 165 | 155 |
.DateTime/hour DEI2 .DateTime/minute DEI2 MUL2 #abcd MUL2 ADD |
| 166 |
- .arena/h LDZ MOD .apple/y STZ |
|
| 156 |
+ .arena/h LDZ DIVk MUL SUB .apple/y STZ |
|
| 167 | 157 |
|
| 168 |
-RTN |
|
| 158 |
+JMP2r |
|
| 169 | 159 |
|
| 170 | 160 |
@draw-snake ( color -- ) |
| 171 | 161 |
|
| ... | ... |
@@ -174,41 +164,41 @@ RTN |
| 174 | 164 |
;snake-icns .Screen/addr DEO2 |
| 175 | 165 |
.snake/length LDZ #00 |
| 176 | 166 |
&loop |
| 177 |
- DUP 2* .snake/tail ADD LDZ TOS 8** .Screen/x DEO2 |
|
| 178 |
- DUP 2* .snake/tail ADD INC LDZ TOS 8** .Screen/y DEO2 |
|
| 167 |
+ DUPk ADD .snake/tail ADD LDZ #0005 SFT2 .Screen/x DEO2 |
|
| 168 |
+ DUPk ADD .snake/tail ADD INC LDZ #0005 SFT2 .Screen/y DEO2 |
|
| 179 | 169 |
STHkr .Screen/sprite DEO |
| 180 | 170 |
INC GTHk ,&loop JCN |
| 181 | 171 |
POP2 |
| 182 | 172 |
( draw head ) |
| 183 |
- .snake/x LDZ TOS 8** .Screen/x DEO2 |
|
| 184 |
- .snake/y LDZ TOS 8** .Screen/y DEO2 |
|
| 173 |
+ .snake/x LDZ #0005 SFT2 .Screen/x DEO2 |
|
| 174 |
+ .snake/y LDZ #0005 SFT2 .Screen/y DEO2 |
|
| 185 | 175 |
;snake-icns/face .Screen/addr DEO2 |
| 186 | 176 |
STHr .Screen/sprite DEO |
| 187 | 177 |
|
| 188 |
-RTN |
|
| 178 |
+JMP2r |
|
| 189 | 179 |
|
| 190 | 180 |
@draw-apple ( color -- ) |
| 191 | 181 |
|
| 192 |
- .apple/x LDZ TOS 8** .Screen/x DEO2 |
|
| 193 |
- .apple/y LDZ TOS 8** .Screen/y DEO2 |
|
| 182 |
+ .apple/x LDZ #0005 SFT2 .Screen/x DEO2 |
|
| 183 |
+ .apple/y LDZ #0005 SFT2 .Screen/y DEO2 |
|
| 194 | 184 |
;apple-chr .Screen/addr DEO2 |
| 195 | 185 |
.Screen/sprite DEO |
| 196 | 186 |
|
| 197 |
-RTN |
|
| 187 |
+JMP2r |
|
| 198 | 188 |
|
| 199 | 189 |
@draw-score ( score color -- ) |
| 200 | 190 |
|
| 201 | 191 |
STH |
| 202 | 192 |
#0010 .Screen/x DEO2 |
| 203 | 193 |
#0010 .Screen/y DEO2 |
| 204 |
- DUP #04 SFT TOS 8** ;font-hex ADD2 .Screen/addr DEO2 |
|
| 194 |
+ DUP #04 SFT #0005 SFT2 ;font-hex ADD2 .Screen/addr DEO2 |
|
| 205 | 195 |
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 |
| 206 | 196 |
( draw ) STHkr .Screen/sprite DEO |
| 207 |
- #0f AND TOS 8** ;font-hex ADD2 .Screen/addr DEO2 |
|
| 197 |
+ #0f AND #0005 SFT2 ;font-hex ADD2 .Screen/addr DEO2 |
|
| 208 | 198 |
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 |
| 209 | 199 |
( draw ) STHr .Screen/sprite DEO |
| 210 | 200 |
|
| 211 |
-RTN |
|
| 201 |
+JMP2r |
|
| 212 | 202 |
|
| 213 | 203 |
( assets ) |
| 214 | 204 |
|
| ... | ... |
@@ -1,7 +1,5 @@ |
| 1 | 1 |
( dev/audio ) |
| 2 | 2 |
|
| 3 |
-%MOD { DIVk MUL SUB }
|
|
| 4 |
- |
|
| 5 | 3 |
( devices ) |
| 6 | 4 |
|
| 7 | 5 |
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] |
| ... | ... |
@@ -57,7 +55,7 @@ BRK |
| 57 | 55 |
( skip ) .timer LDZ #10 EQU #01 JCN [ BRK ] |
| 58 | 56 |
|
| 59 | 57 |
( get note ) |
| 60 |
- .counter LDZ #18 MOD #30 ADD |
|
| 58 |
+ .counter LDZ #18 DIVk MUL SUB #30 ADD |
|
| 61 | 59 |
.Audio0/pitch .counter LDZ #03 AND #40 SFT ADD DEO |
| 62 | 60 |
|
| 63 | 61 |
.counter LDZ INC .counter STZ |
| ... | ... |
@@ -1,15 +1,5 @@ |
| 1 | 1 |
( art by @ritualdust ) |
| 2 | 2 |
|
| 3 |
-%8** { #30 SFT2 }
|
|
| 4 |
-%10** { #40 SFT2 }
|
|
| 5 |
- |
|
| 6 |
-%DEBUG { ;print-hex JSR2 #0a .Console/write DEO }
|
|
| 7 |
-%DEBUG2 { SWP ;print-hex JSR2 ;print-hex JSR2 #0a .Console/write DEO }
|
|
| 8 |
- |
|
| 9 |
-%RTN { JMP2r }
|
|
| 10 |
-%TOS { #00 SWP }
|
|
| 11 |
-%DEC { #01 SUB }
|
|
| 12 |
- |
|
| 13 | 3 |
%MOUSE { #82 }
|
| 14 | 4 |
|
| 15 | 5 |
( devices ) |
| ... | ... |
@@ -65,7 +55,7 @@ BRK |
| 65 | 55 |
DUP #10 NEQ ,&no-up JCN |
| 66 | 56 |
#00 .player/d STZ |
| 67 | 57 |
#00 ;draw-mouse JSR2 |
| 68 |
- .player/y LDZk DEC SWP STZ |
|
| 58 |
+ .player/y LDZk #01 SUB SWP STZ |
|
| 69 | 59 |
MOUSE ;draw-mouse JSR2 |
| 70 | 60 |
&no-up |
| 71 | 61 |
DUP #20 NEQ ,&no-down JCN |
| ... | ... |
@@ -77,7 +67,7 @@ BRK |
| 77 | 67 |
DUP #40 NEQ ,&no-left JCN |
| 78 | 68 |
#02 .player/d STZ |
| 79 | 69 |
#00 ;draw-mouse JSR2 |
| 80 |
- .player/x LDZk DEC SWP STZ |
|
| 70 |
+ .player/x LDZk #01 SUB SWP STZ |
|
| 81 | 71 |
MOUSE ;draw-mouse JSR2 |
| 82 | 72 |
&no-left |
| 83 | 73 |
DUP #80 NEQ ,&no-right JCN |
| ... | ... |
@@ -98,24 +88,24 @@ BRK |
| 98 | 88 |
|
| 99 | 89 |
@draw-mouse ( color -- ) |
| 100 | 90 |
|
| 101 |
- ;spritesheet #29 .player/d LDZ ADD TOS DUP2 DEBUG2 10** ADD2 .Screen/addr DEO2 |
|
| 102 |
- .player/x LDZ TOS 8** .room/x LDZ2 ADD2 .Screen/x DEO2 |
|
| 103 |
- .player/y LDZ TOS 8** .room/y LDZ2 ADD2 .Screen/y DEO2 |
|
| 91 |
+ ;spritesheet #29 .player/d LDZ ADD #0004 SFT2 ADD2 .Screen/addr DEO2 |
|
| 92 |
+ .player/x LDZ #0005 SFT2 .room/x LDZ2 ADD2 .Screen/x DEO2 |
|
| 93 |
+ .player/y LDZ #0005 SFT2 .room/y LDZ2 ADD2 .Screen/y DEO2 |
|
| 104 | 94 |
#40 ADD .Screen/sprite DEO |
| 105 | 95 |
|
| 106 |
-RTN |
|
| 96 |
+JMP2r |
|
| 107 | 97 |
|
| 108 | 98 |
@draw-dungeon ( stage* -- ) |
| 109 | 99 |
|
| 110 | 100 |
STH2 |
| 111 | 101 |
#1000 |
| 112 | 102 |
&ver |
| 113 |
- DUP TOS 8** .room/y LDZ2 ADD2 .Screen/y DEO2 |
|
| 103 |
+ DUP #0005 SFT2 .room/y LDZ2 ADD2 .Screen/y DEO2 |
|
| 114 | 104 |
#1000 |
| 115 | 105 |
&hor |
| 116 |
- DUP TOS 8** .room/x LDZ2 ADD2 .Screen/x DEO2 |
|
| 117 |
- ( get id ) STH2 DUP STH2r ROT OVR SWP #40 SFT ADD TOS |
|
| 118 |
- ( tile ) DUP2 STH2kr ADD2 LDA TOS 10** ;spritesheet ADD2 .Screen/addr DEO2 |
|
| 106 |
+ DUP #0005 SFT2 .room/x LDZ2 ADD2 .Screen/x DEO2 |
|
| 107 |
+ ( get id ) STH2 DUP STH2r ROT OVR SWP #40 SFT ADD #00 SWP |
|
| 108 |
+ ( tile ) DUP2 STH2kr ADD2 LDA #0004 SFT2 ;spritesheet ADD2 .Screen/addr DEO2 |
|
| 119 | 109 |
( color ) STH2kr #0100 ADD2 ADD2 LDA .Screen/sprite DEO |
| 120 | 110 |
INC GTHk ,&hor JCN |
| 121 | 111 |
POP2 |
| ... | ... |
@@ -123,17 +113,17 @@ RTN |
| 123 | 113 |
POP2 |
| 124 | 114 |
POP2r |
| 125 | 115 |
|
| 126 |
-RTN |
|
| 116 |
+JMP2r |
|
| 127 | 117 |
|
| 128 | 118 |
@print-hex ( value -- ) |
| 129 | 119 |
|
| 130 | 120 |
STHk #04 SFT ,&parse JSR .Console/write DEO |
| 131 | 121 |
STHr #0f AND ,&parse JSR .Console/write DEO |
| 132 |
- RTN |
|
| 122 |
+ JMP2r |
|
| 133 | 123 |
&parse ( value -- char ) |
| 134 |
- DUP #09 GTH ,&above JCN #30 ADD RTN &above #09 SUB #60 ADD RTN |
|
| 124 |
+ DUP #09 GTH ,&above JCN #30 ADD JMP2r &above #09 SUB #60 ADD JMP2r |
|
| 135 | 125 |
|
| 136 |
-RTN |
|
| 126 |
+JMP2r |
|
| 137 | 127 |
|
| 138 | 128 |
@mouse-icn |
| 139 | 129 |
ffff ffff ffff ffff 0000 0000 0000 0000 |
| ... | ... |
@@ -11,12 +11,6 @@ |
| 11 | 11 |
examples of asma's usage and can be discarded. |
| 12 | 12 |
) |
| 13 | 13 |
|
| 14 |
-( |
|
| 15 |
- Common macros for use later on. |
|
| 16 |
-) |
|
| 17 |
- |
|
| 18 |
-%asma-IF-ERROR { ;asma/error LDA2 ORA }
|
|
| 19 |
- |
|
| 20 | 14 |
( |
| 21 | 15 |
Asma's public interface. |
| 22 | 16 |
These routines are what are expected to be called from programs that bundle |
| ... | ... |
@@ -32,7 +26,7 @@ |
| 32 | 26 |
;asma-init-first-pass JSR2 |
| 33 | 27 |
;asma-flush-ignore ;asma/flush-fn STA2 |
| 34 | 28 |
;asma/src-filename LDA2 ;asma-assemble-file-pass JSR2 |
| 35 |
- asma-IF-ERROR ,&error JCN |
|
| 29 |
+ ;asma/error LDA2 ORA ,&error JCN |
|
| 36 | 30 |
|
| 37 | 31 |
;asma-init-next-pass JSR2 |
| 38 | 32 |
;asma-flush-to-file ;asma/flush-fn STA2 |
| ... | ... |
@@ -40,7 +34,7 @@ |
| 40 | 34 |
;asma-flush-to-console ;asma/flush-fn STA2 |
| 41 | 35 |
&filename-present |
| 42 | 36 |
;asma/src-filename LDA2 ;asma-assemble-file-pass JSR2 |
| 43 |
- asma-IF-ERROR ,&error JCN |
|
| 37 |
+ ;asma/error LDA2 ORA ,&error JCN |
|
| 44 | 38 |
|
| 45 | 39 |
( flush output buffer ) |
| 46 | 40 |
;asma-output/ptr LDA2 ;asma-write-buffer SUB2 ;asma/flush-fn LDA2 JSR2 |
| ... | ... |
@@ -226,7 +220,7 @@ |
| 226 | 220 |
ROT2 ( func* line^ buf* size^ filename* ) |
| 227 | 221 |
,file-read-chunks JSR |
| 228 | 222 |
|
| 229 |
- asma-IF-ERROR ,&error JCN |
|
| 223 |
+ ;asma/error LDA2 ORA ,&error JCN |
|
| 230 | 224 |
|
| 231 | 225 |
&error |
| 232 | 226 |
POP2 POP2 POP2 POP2 POP2 |
| ... | ... |
@@ -318,7 +312,7 @@ |
| 318 | 312 |
LDAk #0a NEQ ( end-chunk* ws-char* not-newline / line^ start-of-token* ) |
| 319 | 313 |
#00 OVR2 STA |
| 320 | 314 |
STH2r ,asma-assemble-token JSR ( end-chunk* ws-char* not-newline / line^ ) |
| 321 |
- asma-IF-ERROR ,&error JCN |
|
| 315 |
+ ;asma/error LDA2 ORA ,&error JCN |
|
| 322 | 316 |
,¬-newline JCN |
| 323 | 317 |
,asma/lines LDR2 INC2 ,asma/lines STR2 |
| 324 | 318 |
¬-newline ( end-chunk* ws-char* / line^ ) |
| ... | ... |
@@ -362,9 +356,9 @@ |
| 362 | 356 |
asma/state contains several meaningful bits: |
| 363 | 357 |
0x02 we are in a comment, |
| 364 | 358 |
0x04 we are in a macro body, |
| 365 |
- 0x10 we are in a macro body that we are ignoring |
|
| 359 |
+ 0x08 we are in a macro body that we are ignoring |
|
| 366 | 360 |
(because the macro was already defined in a previous pass). |
| 367 |
- Since 0x10 never appears without 0x04, the lowest bit set in asma/state is |
|
| 361 |
+ Since 0x08 never appears without 0x04, the lowest bit set in asma/state is |
|
| 368 | 362 |
always 0x00, 0x02, or 0x04, which is very handy for use with jump tables. |
| 369 | 363 |
The lowest bit set can be found easily by #00 (n) SUBk AND. |
| 370 | 364 |
) |
| ... | ... |
@@ -596,14 +590,11 @@ |
| 596 | 590 |
-body routines) tokens that fail to match any first letter in their tree. |
| 597 | 591 |
) |
| 598 | 592 |
|
| 599 |
-%asma-STATE-SET { ;asma/state LDA ORA ;asma/state STA }
|
|
| 600 |
-%asma-STATE-CLEAR { #ff EOR ;asma/state LDA AND ;asma/state STA }
|
|
| 601 |
- |
|
| 602 | 593 |
@asma-comment-more |
| 603 | 594 |
;asma/token LDA2 ;strlen JSR2 ORA ,asma-ignore JCN |
| 604 | 595 |
@asma-comment-start |
| 605 | 596 |
;asma/comment-level LDAk INC ROT ROT STA |
| 606 |
- #02 asma-STATE-SET |
|
| 597 |
+ ;asma/state LDA #02 ORA ;asma/state STA |
|
| 607 | 598 |
@asma-ignore |
| 608 | 599 |
JMP2r |
| 609 | 600 |
|
| ... | ... |
@@ -611,7 +602,7 @@ |
| 611 | 602 |
;asma/token LDA2 ;strlen JSR2 ORA ,asma-ignore JCN |
| 612 | 603 |
;asma/comment-level LDAk #01 SUB DUP SWP2 STA ,asma-ignore JCN |
| 613 | 604 |
@asma-comment-end |
| 614 |
- #02 asma-STATE-CLEAR |
|
| 605 |
+ ;asma/state LDA #0c AND ;asma/state STA |
|
| 615 | 606 |
JMP2r |
| 616 | 607 |
|
| 617 | 608 |
@asma-macro-define |
| ... | ... |
@@ -628,22 +619,22 @@ |
| 628 | 619 |
#0000 ;append-heap-short JSR2 ( less-than pointer ) |
| 629 | 620 |
#0000 ;append-heap-short JSR2 ( greater-than pointer ) |
| 630 | 621 |
;asma/token LDA2 ;append-heap-string JSR2 ( key ) |
| 631 |
- #04 asma-STATE-SET |
|
| 622 |
+ ;asma/state LDA #04 ORA ;asma/state STA |
|
| 632 | 623 |
JMP2r |
| 633 | 624 |
|
| 634 | 625 |
&ignore-macro |
| 635 |
- #14 asma-STATE-SET |
|
| 626 |
+ ;asma/state LDA #0c ORA ;asma/state STA |
|
| 636 | 627 |
JMP2r |
| 637 | 628 |
|
| 638 | 629 |
@asma-macro-body |
| 639 |
- ;asma/state LDA #10 AND ,&skip JCN |
|
| 630 |
+ ;asma/state LDA #08 AND ,&skip JCN |
|
| 640 | 631 |
;asma/token LDA2 ;append-heap-string JSR2 |
| 641 | 632 |
&skip |
| 642 | 633 |
JMP2r |
| 643 | 634 |
|
| 644 | 635 |
@asma-macro-end |
| 645 | 636 |
#00 ;append-heap-byte JSR2 |
| 646 |
- #14 asma-STATE-CLEAR |
|
| 637 |
+ ;asma/state LDA #02 AND ;asma/state STA |
|
| 647 | 638 |
JMP2r |
| 648 | 639 |
|
| 649 | 640 |
@asma-label-define |
| ... | ... |
@@ -852,7 +843,7 @@ |
| 852 | 843 |
|
| 853 | 844 |
&keep-going |
| 854 | 845 |
DUP2k ;strlen JSR2 INC2 ADD2 |
| 855 |
- SWP2 ;asma-assemble-token JSR2 asma-IF-ERROR ,¯o-error JCN |
|
| 846 |
+ SWP2 ;asma-assemble-token JSR2 ;asma/error LDA2 ORA ,¯o-error JCN |
|
| 856 | 847 |
,¯o-loop JMP |
| 857 | 848 |
|
| 858 | 849 |
¯o-error |
| ... | ... |
@@ -54,10 +54,6 @@ |
| 54 | 54 |
( - mul32 memory, 12 bytes ) |
| 55 | 55 |
( - _divmod32 memory, 16 bytes ) |
| 56 | 56 |
|
| 57 |
-%COMPLEMENT32 { SWP2 #ffff EOR2 SWP2 #ffff EOR2 }
|
|
| 58 |
-%DUP4 { OVR2 OVR2 }
|
|
| 59 |
-%POP4 { POP2 POP2 }
|
|
| 60 |
- |
|
| 61 | 57 |
( bitcount: number of bits needed to represent number ) |
| 62 | 58 |
( equivalent to floor[log2[x]] + 1 ) |
| 63 | 59 |
|
| ... | ... |
@@ -164,7 +160,7 @@ |
| 164 | 160 |
|
| 165 | 161 |
( ~x ) |
| 166 | 162 |
@complement32 ( x** -> ~x** ) |
| 167 |
- COMPLEMENT32 JMP2r |
|
| 163 |
+ SWP2 #ffff EOR2 SWP2 #ffff EOR2 JMP2r |
|
| 168 | 164 |
|
| 169 | 165 |
( temporary registers ) |
| 170 | 166 |
( shared by most operations, except mul32 and div32 ) |
| ... | ... |
@@ -289,7 +285,7 @@ |
| 289 | 285 |
|
| 290 | 286 |
( -x ) |
| 291 | 287 |
@negate32 ( x** -> -x** ) |
| 292 |
- COMPLEMENT32 |
|
| 288 |
+ ;complement32 JSR2 |
|
| 293 | 289 |
INC2 ( ~xhi -xlo ) |
| 294 | 290 |
DUP2 #0000 NEQ2 ( ~xhi -xlo non-zero? ) |
| 295 | 291 |
,&done JCN ( xlo non-zero => don't inc hi ) |
| ... | ... |
@@ -414,10 +410,10 @@ |
| 414 | 410 |
( greatest common divisor - euclidean algorithm ) |
| 415 | 411 |
@gcd32 ( x** y** -> z** ) |
| 416 | 412 |
&loop ( x y ) |
| 417 |
- DUP4 ( x y y ) |
|
| 413 |
+ OVR2 OVR2 ( x y y ) |
|
| 418 | 414 |
;is-zero32 JSR2 ( x y y=0? ) |
| 419 | 415 |
,&done JCN ( x y ) |
| 420 |
- DUP4 ( x y y ) |
|
| 416 |
+ OVR2 OVR2 ( x y y ) |
|
| 421 | 417 |
STH2 STH2 ( x y [y] ) |
| 422 | 418 |
;mod32 JSR2 ( r=x%y [y] ) |
| 423 | 419 |
STH2r ( rhi rlo yhi [ylo] ) |
| ... | ... |
@@ -428,5 +424,5 @@ |
| 428 | 424 |
ROT2 ( yhi ylo rhi rlo ) |
| 429 | 425 |
,&loop JMP |
| 430 | 426 |
&done |
| 431 |
- POP4 ( x ) |
|
| 427 |
+ POP2 POP2 ( x ) |
|
| 432 | 428 |
JMP2r |
| ... | ... |
@@ -1,14 +1,5 @@ |
| 1 | 1 |
( app/neralie : clock with arvelie date ) |
| 2 | 2 |
|
| 3 |
-%PAD { #0018 }
|
|
| 4 |
- |
|
| 5 |
-%MOD { DIVk MUL SUB }
|
|
| 6 |
-%MOD2 { DIV2k MUL2 SUB2 }
|
|
| 7 |
- |
|
| 8 |
-%h { .DateTime/hour DEI }
|
|
| 9 |
-%m { .DateTime/minute DEI }
|
|
| 10 |
-%s { .DateTime/second DEI }
|
|
| 11 |
- |
|
| 12 | 3 |
( devices ) |
| 13 | 4 |
|
| 14 | 5 |
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] |
| ... | ... |
@@ -47,7 +38,7 @@ |
| 47 | 38 |
#01 .fps/current STZ |
| 48 | 39 |
|
| 49 | 40 |
( set size ) |
| 50 |
- PAD |
|
| 41 |
+ #0018 ( padding ) |
|
| 51 | 42 |
DUP2 .frame/x1 STZ2 |
| 52 | 43 |
DUP2 .frame/y1 STZ2 |
| 53 | 44 |
DUP2 .Screen/width DEI2 SWP2 SUB2 #0001 SUB2 .frame/x2 STZ2 |
| ... | ... |
@@ -79,22 +70,22 @@ BRK |
| 79 | 70 |
@neralie-calc ( -- ) |
| 80 | 71 |
|
| 81 | 72 |
( add up fractions of a pulse, store tenths in n6 ) |
| 82 |
- #0120 #00 h MUL2 |
|
| 83 |
- #00c0 #00 m MUL2 ADD2 |
|
| 84 |
- #00f8 #00 s MUL2 ADD2 |
|
| 73 |
+ #0120 #00 .DateTime/hour DEI MUL2 |
|
| 74 |
+ #00c0 #00 .DateTime/minute DEI MUL2 ADD2 |
|
| 75 |
+ #00f8 #00 .DateTime/second DEI MUL2 ADD2 |
|
| 85 | 76 |
#0271 #00 .fps/next LDZ MUL2 #00 .fps/current LDZ DIV2 #30 SFT2 ADD2 |
| 86 | 77 |
#01b0 ;modf JSR2 SWP2 #0017 MUL2 #03e8 DIV2 .neralie/n6 STZ POP |
| 87 | 78 |
|
| 88 | 79 |
( add up units and tens of pulses, store in n5 and n4 ) |
| 89 |
- #0042 #00 h MUL2 ADD2 |
|
| 90 |
- #005e #00 m MUL2 ADD2 |
|
| 91 |
- #000b #00 s MUL2 ADD2 |
|
| 80 |
+ #0042 #00 .DateTime/hour DEI MUL2 ADD2 |
|
| 81 |
+ #005e #00 .DateTime/minute DEI MUL2 ADD2 |
|
| 82 |
+ #000b #00 .DateTime/second DEI MUL2 ADD2 |
|
| 92 | 83 |
#000a ;modf JSR2 SWP2 .neralie/n5 STZ POP |
| 93 | 84 |
#000a ;modf JSR2 SWP2 .neralie/n4 STZ POP |
| 94 | 85 |
|
| 95 | 86 |
( add up hundreds of pulses + 10 x beats, store in n0123 ) |
| 96 |
- #01a0 #00 h MUL2 ADD2 |
|
| 97 |
- #0006 #00 m MUL2 ADD2 .neralie/n0123 STZ2 |
|
| 87 |
+ #01a0 #00 .DateTime/hour DEI MUL2 ADD2 |
|
| 88 |
+ #0006 #00 .DateTime/minute DEI MUL2 ADD2 .neralie/n0123 STZ2 |
|
| 98 | 89 |
|
| 99 | 90 |
JMP2r |
| 100 | 91 |
|
| ... | ... |
@@ -109,14 +100,14 @@ JMP2r |
| 109 | 100 |
.DateTime/year DEI2 #07d6 SUB2 NIP |
| 110 | 101 |
DUP #0a DIV #00 SWP #30 SFT2 ;font-numbers ADD2 .Screen/addr DEO2 |
| 111 | 102 |
#01 .Screen/sprite DEO |
| 112 |
- #0a MOD #00 SWP #30 SFT2 ;font-numbers ADD2 .Screen/addr DEO2 |
|
| 103 |
+ #0a DIVk MUL SUB #00 SWP #30 SFT2 ;font-numbers ADD2 .Screen/addr DEO2 |
|
| 113 | 104 |
#01 .Screen/sprite DEO |
| 114 | 105 |
.DateTime/doty DEI2 |
| 115 | 106 |
DUP2 #000e DIV2 #30 SFT2 ;font-letters ADD2 .Screen/addr DEO2 |
| 116 | 107 |
#01 .Screen/sprite DEO |
| 117 |
- #000e MOD2 |
|
| 108 |
+ #000e DIV2k MUL2 SUB2 |
|
| 118 | 109 |
DUP2 #000a DIV2 ,digit JSR |
| 119 |
- #000a MOD2 ,digit JSR |
|
| 110 |
+ #000a DIV2k MUL2 SUB2 ,digit JSR |
|
| 120 | 111 |
|
| 121 | 112 |
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 |
| 122 | 113 |
|
| ... | ... |
@@ -223,8 +214,8 @@ JMP2r |
| 223 | 214 |
|
| 224 | 215 |
@update-fps ( -- ) |
| 225 | 216 |
.fps/next LDZ INC .fps/next STZ |
| 226 |
- s .fps/second LDZ NEQ JMP JMP2r |
|
| 227 |
- s .fps/second STZ |
|
| 217 |
+ .DateTime/second DEI .fps/second LDZ NEQ JMP JMP2r |
|
| 218 |
+ .DateTime/second DEI .fps/second STZ |
|
| 228 | 219 |
.fps/next LDZ .fps/current STZ |
| 229 | 220 |
|
| 230 | 221 |
#00 .fps/next STZ |