Remove many macros.
This commit is contained in:
parent
5eadd7695b
commit
42aab23dc1
|
@ -1,16 +1,5 @@
|
||||||
( uxnasm projects/examples/demos/snake.tal bin/snake.rom && uxnemu bin/snake.rom )
|
( uxnasm projects/examples/demos/snake.tal bin/snake.rom && uxnemu bin/snake.rom )
|
||||||
|
|
||||||
%2/ { #01 SFT } %2* { #10 SFT }
|
|
||||||
%8// { #03 SFT2 } %8** { #30 SFT2 }
|
|
||||||
%MOD { DIVk MUL SUB }
|
|
||||||
%MAX { LTHk JMP SWP POP }
|
|
||||||
%RTN { JMP2r }
|
|
||||||
%TOS { #00 SWP }
|
|
||||||
%BRK? { #01 JCN BRK }
|
|
||||||
|
|
||||||
|
|
||||||
%DIFFICULTY { #06 }
|
|
||||||
|
|
||||||
( devices )
|
( devices )
|
||||||
|
|
||||||
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 ]
|
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 ]
|
||||||
|
@ -51,8 +40,8 @@
|
||||||
#0100 .Screen/height DEO2
|
#0100 .Screen/height DEO2
|
||||||
|
|
||||||
( set arena )
|
( set arena )
|
||||||
.Screen/width DEI2 8// NIP .arena/w STZ
|
.Screen/width DEI2 #03 SFT2 NIP .arena/w STZ
|
||||||
.Screen/height DEI2 8// NIP .arena/h STZ
|
.Screen/height DEI2 #03 SFT2 NIP .arena/h STZ
|
||||||
|
|
||||||
;reset JSR2
|
;reset JSR2
|
||||||
|
|
||||||
|
@ -61,7 +50,8 @@ BRK
|
||||||
@on-frame ( -> )
|
@on-frame ( -> )
|
||||||
|
|
||||||
.arena/timer LDZ INC DUP .arena/timer STZ
|
.arena/timer LDZ INC DUP .arena/timer STZ
|
||||||
DIFFICULTY EQU BRK?
|
#06 ( difficulty - lower value produces faster gameplay )
|
||||||
|
EQU JMP BRK
|
||||||
|
|
||||||
( clear ) #00 ;draw-snake JSR2
|
( clear ) #00 ;draw-snake JSR2
|
||||||
( update ) ;move JSR2
|
( update ) ;move JSR2
|
||||||
|
@ -90,8 +80,8 @@ BRK
|
||||||
#00 ;draw-snake JSR2
|
#00 ;draw-snake JSR2
|
||||||
#00 ;draw-apple JSR2
|
#00 ;draw-apple JSR2
|
||||||
|
|
||||||
.arena/w LDZ 2/ #01 SUB .snake/x STZ
|
.arena/w LDZ #01 SFT #01 SUB .snake/x STZ
|
||||||
.arena/h LDZ 2/ #01 SUB .snake/y STZ
|
.arena/h LDZ #01 SFT #01 SUB .snake/y STZ
|
||||||
#00 .snake/dead STZ
|
#00 .snake/dead STZ
|
||||||
#00 .snake/length STZ
|
#00 .snake/length STZ
|
||||||
#00 .snake/direction STZ
|
#00 .snake/direction STZ
|
||||||
|
@ -99,7 +89,7 @@ BRK
|
||||||
#03 ;draw-snake JSR2
|
#03 ;draw-snake JSR2
|
||||||
;add-apple JSR2
|
;add-apple JSR2
|
||||||
|
|
||||||
RTN
|
JMP2r
|
||||||
|
|
||||||
@move ( -- )
|
@move ( -- )
|
||||||
|
|
||||||
|
@ -107,33 +97,33 @@ RTN
|
||||||
.snake/x LDZ2 STH2
|
.snake/x LDZ2 STH2
|
||||||
.snake/length LDZ #00
|
.snake/length LDZ #00
|
||||||
&loop
|
&loop
|
||||||
( pop ) DUP 2* .snake/tail ADD LDZ2 STH2 SWP2r
|
( pop ) DUPk ADD .snake/tail ADD LDZ2 STH2 SWP2r
|
||||||
( push ) DUP 2* .snake/tail ADD STH2r ROT STZ2
|
( push ) DUPk ADD .snake/tail ADD STH2r ROT STZ2
|
||||||
INC GTHk ,&loop JCN
|
INC GTHk ,&loop JCN
|
||||||
POP2
|
POP2
|
||||||
POP2r
|
POP2r
|
||||||
|
|
||||||
.snake/dead LDZ #00 EQU JMP RTN
|
.snake/dead LDZ #00 EQU JMP JMP2r
|
||||||
|
|
||||||
.snake/direction LDZ
|
.snake/direction LDZ
|
||||||
DUP #01 NEQ ,&no-up JCN
|
DUP #01 NEQ ,&no-up JCN
|
||||||
.snake/y LDZ #01 SUB
|
.snake/y LDZ #01 SUB
|
||||||
.arena/h LDZ MAX
|
.arena/h LDZ LTHk JMP SWP POP
|
||||||
.snake/y STZ
|
.snake/y STZ
|
||||||
&no-up
|
&no-up
|
||||||
DUP #02 NEQ ,&no-down JCN
|
DUP #02 NEQ ,&no-down JCN
|
||||||
.snake/y LDZ INC
|
.snake/y LDZ INC
|
||||||
.arena/h LDZ MOD
|
.arena/h LDZ DIVk MUL SUB
|
||||||
.snake/y STZ
|
.snake/y STZ
|
||||||
&no-down
|
&no-down
|
||||||
DUP #04 NEQ ,&no-left JCN
|
DUP #04 NEQ ,&no-left JCN
|
||||||
.snake/x LDZ #01 SUB
|
.snake/x LDZ #01 SUB
|
||||||
.arena/w LDZ MAX
|
.arena/w LDZ LTHk JMP SWP POP
|
||||||
.snake/x STZ
|
.snake/x STZ
|
||||||
&no-left
|
&no-left
|
||||||
DUP #08 NEQ ,&no-right JCN
|
DUP #08 NEQ ,&no-right JCN
|
||||||
.snake/x LDZ INC
|
.snake/x LDZ INC
|
||||||
.arena/w LDZ MOD
|
.arena/w LDZ DIVk MUL SUB
|
||||||
.snake/x STZ
|
.snake/x STZ
|
||||||
&no-right
|
&no-right
|
||||||
POP
|
POP
|
||||||
|
@ -148,7 +138,7 @@ RTN
|
||||||
|
|
||||||
.snake/length LDZ #01
|
.snake/length LDZ #01
|
||||||
&loop-body
|
&loop-body
|
||||||
( pop ) DUP 2* .snake/tail ADD LDZ2
|
( pop ) DUPk ADD .snake/tail ADD LDZ2
|
||||||
.snake/x LDZ2 NEQ2 ,&no-collision-body JCN
|
.snake/x LDZ2 NEQ2 ,&no-collision-body JCN
|
||||||
#01 .snake/dead STZ
|
#01 .snake/dead STZ
|
||||||
#03 ;draw-snake JSR2
|
#03 ;draw-snake JSR2
|
||||||
|
@ -156,16 +146,16 @@ RTN
|
||||||
INC GTHk ,&loop-body JCN
|
INC GTHk ,&loop-body JCN
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
RTN
|
JMP2r
|
||||||
|
|
||||||
@add-apple ( -- )
|
@add-apple ( -- )
|
||||||
|
|
||||||
.DateTime/hour DEI2 .DateTime/minute DEI2 MUL2 #1234 MUL2 ADD
|
.DateTime/hour DEI2 .DateTime/minute DEI2 MUL2 #1234 MUL2 ADD
|
||||||
.arena/w LDZ MOD .apple/x STZ
|
.arena/w LDZ DIVk MUL SUB .apple/x STZ
|
||||||
.DateTime/hour DEI2 .DateTime/minute DEI2 MUL2 #abcd MUL2 ADD
|
.DateTime/hour DEI2 .DateTime/minute DEI2 MUL2 #abcd MUL2 ADD
|
||||||
.arena/h LDZ MOD .apple/y STZ
|
.arena/h LDZ DIVk MUL SUB .apple/y STZ
|
||||||
|
|
||||||
RTN
|
JMP2r
|
||||||
|
|
||||||
@draw-snake ( color -- )
|
@draw-snake ( color -- )
|
||||||
|
|
||||||
|
@ -174,41 +164,41 @@ RTN
|
||||||
;snake-icns .Screen/addr DEO2
|
;snake-icns .Screen/addr DEO2
|
||||||
.snake/length LDZ #00
|
.snake/length LDZ #00
|
||||||
&loop
|
&loop
|
||||||
DUP 2* .snake/tail ADD LDZ TOS 8** .Screen/x DEO2
|
DUPk ADD .snake/tail ADD LDZ #0005 SFT2 .Screen/x DEO2
|
||||||
DUP 2* .snake/tail ADD INC LDZ TOS 8** .Screen/y DEO2
|
DUPk ADD .snake/tail ADD INC LDZ #0005 SFT2 .Screen/y DEO2
|
||||||
STHkr .Screen/sprite DEO
|
STHkr .Screen/sprite DEO
|
||||||
INC GTHk ,&loop JCN
|
INC GTHk ,&loop JCN
|
||||||
POP2
|
POP2
|
||||||
( draw head )
|
( draw head )
|
||||||
.snake/x LDZ TOS 8** .Screen/x DEO2
|
.snake/x LDZ #0005 SFT2 .Screen/x DEO2
|
||||||
.snake/y LDZ TOS 8** .Screen/y DEO2
|
.snake/y LDZ #0005 SFT2 .Screen/y DEO2
|
||||||
;snake-icns/face .Screen/addr DEO2
|
;snake-icns/face .Screen/addr DEO2
|
||||||
STHr .Screen/sprite DEO
|
STHr .Screen/sprite DEO
|
||||||
|
|
||||||
RTN
|
JMP2r
|
||||||
|
|
||||||
@draw-apple ( color -- )
|
@draw-apple ( color -- )
|
||||||
|
|
||||||
.apple/x LDZ TOS 8** .Screen/x DEO2
|
.apple/x LDZ #0005 SFT2 .Screen/x DEO2
|
||||||
.apple/y LDZ TOS 8** .Screen/y DEO2
|
.apple/y LDZ #0005 SFT2 .Screen/y DEO2
|
||||||
;apple-chr .Screen/addr DEO2
|
;apple-chr .Screen/addr DEO2
|
||||||
.Screen/sprite DEO
|
.Screen/sprite DEO
|
||||||
|
|
||||||
RTN
|
JMP2r
|
||||||
|
|
||||||
@draw-score ( score color -- )
|
@draw-score ( score color -- )
|
||||||
|
|
||||||
STH
|
STH
|
||||||
#0010 .Screen/x DEO2
|
#0010 .Screen/x DEO2
|
||||||
#0010 .Screen/y DEO2
|
#0010 .Screen/y DEO2
|
||||||
DUP #04 SFT TOS 8** ;font-hex ADD2 .Screen/addr DEO2
|
DUP #04 SFT #0005 SFT2 ;font-hex ADD2 .Screen/addr DEO2
|
||||||
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
|
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
|
||||||
( draw ) STHkr .Screen/sprite DEO
|
( draw ) STHkr .Screen/sprite DEO
|
||||||
#0f AND TOS 8** ;font-hex ADD2 .Screen/addr DEO2
|
#0f AND #0005 SFT2 ;font-hex ADD2 .Screen/addr DEO2
|
||||||
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
|
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
|
||||||
( draw ) STHr .Screen/sprite DEO
|
( draw ) STHr .Screen/sprite DEO
|
||||||
|
|
||||||
RTN
|
JMP2r
|
||||||
|
|
||||||
( assets )
|
( assets )
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
( dev/audio )
|
( dev/audio )
|
||||||
|
|
||||||
%MOD { DIVk MUL SUB }
|
|
||||||
|
|
||||||
( devices )
|
( devices )
|
||||||
|
|
||||||
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
||||||
|
@ -57,7 +55,7 @@ BRK
|
||||||
( skip ) .timer LDZ #10 EQU #01 JCN [ BRK ]
|
( skip ) .timer LDZ #10 EQU #01 JCN [ BRK ]
|
||||||
|
|
||||||
( get note )
|
( get note )
|
||||||
.counter LDZ #18 MOD #30 ADD
|
.counter LDZ #18 DIVk MUL SUB #30 ADD
|
||||||
.Audio0/pitch .counter LDZ #03 AND #40 SFT ADD DEO
|
.Audio0/pitch .counter LDZ #03 AND #40 SFT ADD DEO
|
||||||
|
|
||||||
.counter LDZ INC .counter STZ
|
.counter LDZ INC .counter STZ
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
( art by @ritualdust )
|
( art by @ritualdust )
|
||||||
|
|
||||||
%8** { #30 SFT2 }
|
|
||||||
%10** { #40 SFT2 }
|
|
||||||
|
|
||||||
%DEBUG { ;print-hex JSR2 #0a .Console/write DEO }
|
|
||||||
%DEBUG2 { SWP ;print-hex JSR2 ;print-hex JSR2 #0a .Console/write DEO }
|
|
||||||
|
|
||||||
%RTN { JMP2r }
|
|
||||||
%TOS { #00 SWP }
|
|
||||||
%DEC { #01 SUB }
|
|
||||||
|
|
||||||
%MOUSE { #82 }
|
%MOUSE { #82 }
|
||||||
|
|
||||||
( devices )
|
( devices )
|
||||||
|
@ -65,7 +55,7 @@ BRK
|
||||||
DUP #10 NEQ ,&no-up JCN
|
DUP #10 NEQ ,&no-up JCN
|
||||||
#00 .player/d STZ
|
#00 .player/d STZ
|
||||||
#00 ;draw-mouse JSR2
|
#00 ;draw-mouse JSR2
|
||||||
.player/y LDZk DEC SWP STZ
|
.player/y LDZk #01 SUB SWP STZ
|
||||||
MOUSE ;draw-mouse JSR2
|
MOUSE ;draw-mouse JSR2
|
||||||
&no-up
|
&no-up
|
||||||
DUP #20 NEQ ,&no-down JCN
|
DUP #20 NEQ ,&no-down JCN
|
||||||
|
@ -77,7 +67,7 @@ BRK
|
||||||
DUP #40 NEQ ,&no-left JCN
|
DUP #40 NEQ ,&no-left JCN
|
||||||
#02 .player/d STZ
|
#02 .player/d STZ
|
||||||
#00 ;draw-mouse JSR2
|
#00 ;draw-mouse JSR2
|
||||||
.player/x LDZk DEC SWP STZ
|
.player/x LDZk #01 SUB SWP STZ
|
||||||
MOUSE ;draw-mouse JSR2
|
MOUSE ;draw-mouse JSR2
|
||||||
&no-left
|
&no-left
|
||||||
DUP #80 NEQ ,&no-right JCN
|
DUP #80 NEQ ,&no-right JCN
|
||||||
|
@ -98,24 +88,24 @@ BRK
|
||||||
|
|
||||||
@draw-mouse ( color -- )
|
@draw-mouse ( color -- )
|
||||||
|
|
||||||
;spritesheet #29 .player/d LDZ ADD TOS DUP2 DEBUG2 10** ADD2 .Screen/addr DEO2
|
;spritesheet #29 .player/d LDZ ADD #0004 SFT2 ADD2 .Screen/addr DEO2
|
||||||
.player/x LDZ TOS 8** .room/x LDZ2 ADD2 .Screen/x DEO2
|
.player/x LDZ #0005 SFT2 .room/x LDZ2 ADD2 .Screen/x DEO2
|
||||||
.player/y LDZ TOS 8** .room/y LDZ2 ADD2 .Screen/y DEO2
|
.player/y LDZ #0005 SFT2 .room/y LDZ2 ADD2 .Screen/y DEO2
|
||||||
#40 ADD .Screen/sprite DEO
|
#40 ADD .Screen/sprite DEO
|
||||||
|
|
||||||
RTN
|
JMP2r
|
||||||
|
|
||||||
@draw-dungeon ( stage* -- )
|
@draw-dungeon ( stage* -- )
|
||||||
|
|
||||||
STH2
|
STH2
|
||||||
#1000
|
#1000
|
||||||
&ver
|
&ver
|
||||||
DUP TOS 8** .room/y LDZ2 ADD2 .Screen/y DEO2
|
DUP #0005 SFT2 .room/y LDZ2 ADD2 .Screen/y DEO2
|
||||||
#1000
|
#1000
|
||||||
&hor
|
&hor
|
||||||
DUP TOS 8** .room/x LDZ2 ADD2 .Screen/x DEO2
|
DUP #0005 SFT2 .room/x LDZ2 ADD2 .Screen/x DEO2
|
||||||
( get id ) STH2 DUP STH2r ROT OVR SWP #40 SFT ADD TOS
|
( get id ) STH2 DUP STH2r ROT OVR SWP #40 SFT ADD #00 SWP
|
||||||
( tile ) DUP2 STH2kr ADD2 LDA TOS 10** ;spritesheet ADD2 .Screen/addr DEO2
|
( tile ) DUP2 STH2kr ADD2 LDA #0004 SFT2 ;spritesheet ADD2 .Screen/addr DEO2
|
||||||
( color ) STH2kr #0100 ADD2 ADD2 LDA .Screen/sprite DEO
|
( color ) STH2kr #0100 ADD2 ADD2 LDA .Screen/sprite DEO
|
||||||
INC GTHk ,&hor JCN
|
INC GTHk ,&hor JCN
|
||||||
POP2
|
POP2
|
||||||
|
@ -123,17 +113,17 @@ RTN
|
||||||
POP2
|
POP2
|
||||||
POP2r
|
POP2r
|
||||||
|
|
||||||
RTN
|
JMP2r
|
||||||
|
|
||||||
@print-hex ( value -- )
|
@print-hex ( value -- )
|
||||||
|
|
||||||
STHk #04 SFT ,&parse JSR .Console/write DEO
|
STHk #04 SFT ,&parse JSR .Console/write DEO
|
||||||
STHr #0f AND ,&parse JSR .Console/write DEO
|
STHr #0f AND ,&parse JSR .Console/write DEO
|
||||||
RTN
|
JMP2r
|
||||||
&parse ( value -- char )
|
&parse ( value -- char )
|
||||||
DUP #09 GTH ,&above JCN #30 ADD RTN &above #09 SUB #60 ADD RTN
|
DUP #09 GTH ,&above JCN #30 ADD JMP2r &above #09 SUB #60 ADD JMP2r
|
||||||
|
|
||||||
RTN
|
JMP2r
|
||||||
|
|
||||||
@mouse-icn
|
@mouse-icn
|
||||||
ffff ffff ffff ffff 0000 0000 0000 0000
|
ffff ffff ffff ffff 0000 0000 0000 0000
|
||||||
|
|
|
@ -11,12 +11,6 @@
|
||||||
examples of asma's usage and can be discarded.
|
examples of asma's usage and can be discarded.
|
||||||
)
|
)
|
||||||
|
|
||||||
(
|
|
||||||
Common macros for use later on.
|
|
||||||
)
|
|
||||||
|
|
||||||
%asma-IF-ERROR { ;asma/error LDA2 ORA }
|
|
||||||
|
|
||||||
(
|
(
|
||||||
Asma's public interface.
|
Asma's public interface.
|
||||||
These routines are what are expected to be called from programs that bundle
|
These routines are what are expected to be called from programs that bundle
|
||||||
|
@ -32,7 +26,7 @@
|
||||||
;asma-init-first-pass JSR2
|
;asma-init-first-pass JSR2
|
||||||
;asma-flush-ignore ;asma/flush-fn STA2
|
;asma-flush-ignore ;asma/flush-fn STA2
|
||||||
;asma/src-filename LDA2 ;asma-assemble-file-pass JSR2
|
;asma/src-filename LDA2 ;asma-assemble-file-pass JSR2
|
||||||
asma-IF-ERROR ,&error JCN
|
;asma/error LDA2 ORA ,&error JCN
|
||||||
|
|
||||||
;asma-init-next-pass JSR2
|
;asma-init-next-pass JSR2
|
||||||
;asma-flush-to-file ;asma/flush-fn STA2
|
;asma-flush-to-file ;asma/flush-fn STA2
|
||||||
|
@ -40,7 +34,7 @@
|
||||||
;asma-flush-to-console ;asma/flush-fn STA2
|
;asma-flush-to-console ;asma/flush-fn STA2
|
||||||
&filename-present
|
&filename-present
|
||||||
;asma/src-filename LDA2 ;asma-assemble-file-pass JSR2
|
;asma/src-filename LDA2 ;asma-assemble-file-pass JSR2
|
||||||
asma-IF-ERROR ,&error JCN
|
;asma/error LDA2 ORA ,&error JCN
|
||||||
|
|
||||||
( flush output buffer )
|
( flush output buffer )
|
||||||
;asma-output/ptr LDA2 ;asma-write-buffer SUB2 ;asma/flush-fn LDA2 JSR2
|
;asma-output/ptr LDA2 ;asma-write-buffer SUB2 ;asma/flush-fn LDA2 JSR2
|
||||||
|
@ -226,7 +220,7 @@
|
||||||
ROT2 ( func* line^ buf* size^ filename* )
|
ROT2 ( func* line^ buf* size^ filename* )
|
||||||
,file-read-chunks JSR
|
,file-read-chunks JSR
|
||||||
|
|
||||||
asma-IF-ERROR ,&error JCN
|
;asma/error LDA2 ORA ,&error JCN
|
||||||
|
|
||||||
&error
|
&error
|
||||||
POP2 POP2 POP2 POP2 POP2
|
POP2 POP2 POP2 POP2 POP2
|
||||||
|
@ -318,7 +312,7 @@
|
||||||
LDAk #0a NEQ ( end-chunk* ws-char* not-newline / line^ start-of-token* )
|
LDAk #0a NEQ ( end-chunk* ws-char* not-newline / line^ start-of-token* )
|
||||||
#00 OVR2 STA
|
#00 OVR2 STA
|
||||||
STH2r ,asma-assemble-token JSR ( end-chunk* ws-char* not-newline / line^ )
|
STH2r ,asma-assemble-token JSR ( end-chunk* ws-char* not-newline / line^ )
|
||||||
asma-IF-ERROR ,&error JCN
|
;asma/error LDA2 ORA ,&error JCN
|
||||||
,¬-newline JCN
|
,¬-newline JCN
|
||||||
,asma/lines LDR2 INC2 ,asma/lines STR2
|
,asma/lines LDR2 INC2 ,asma/lines STR2
|
||||||
¬-newline ( end-chunk* ws-char* / line^ )
|
¬-newline ( end-chunk* ws-char* / line^ )
|
||||||
|
@ -362,9 +356,9 @@
|
||||||
asma/state contains several meaningful bits:
|
asma/state contains several meaningful bits:
|
||||||
0x02 we are in a comment,
|
0x02 we are in a comment,
|
||||||
0x04 we are in a macro body,
|
0x04 we are in a macro body,
|
||||||
0x10 we are in a macro body that we are ignoring
|
0x08 we are in a macro body that we are ignoring
|
||||||
(because the macro was already defined in a previous pass).
|
(because the macro was already defined in a previous pass).
|
||||||
Since 0x10 never appears without 0x04, the lowest bit set in asma/state is
|
Since 0x08 never appears without 0x04, the lowest bit set in asma/state is
|
||||||
always 0x00, 0x02, or 0x04, which is very handy for use with jump tables.
|
always 0x00, 0x02, or 0x04, which is very handy for use with jump tables.
|
||||||
The lowest bit set can be found easily by #00 (n) SUBk AND.
|
The lowest bit set can be found easily by #00 (n) SUBk AND.
|
||||||
)
|
)
|
||||||
|
@ -596,14 +590,11 @@
|
||||||
-body routines) tokens that fail to match any first letter in their tree.
|
-body routines) tokens that fail to match any first letter in their tree.
|
||||||
)
|
)
|
||||||
|
|
||||||
%asma-STATE-SET { ;asma/state LDA ORA ;asma/state STA }
|
|
||||||
%asma-STATE-CLEAR { #ff EOR ;asma/state LDA AND ;asma/state STA }
|
|
||||||
|
|
||||||
@asma-comment-more
|
@asma-comment-more
|
||||||
;asma/token LDA2 ;strlen JSR2 ORA ,asma-ignore JCN
|
;asma/token LDA2 ;strlen JSR2 ORA ,asma-ignore JCN
|
||||||
@asma-comment-start
|
@asma-comment-start
|
||||||
;asma/comment-level LDAk INC ROT ROT STA
|
;asma/comment-level LDAk INC ROT ROT STA
|
||||||
#02 asma-STATE-SET
|
;asma/state LDA #02 ORA ;asma/state STA
|
||||||
@asma-ignore
|
@asma-ignore
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
|
@ -611,7 +602,7 @@
|
||||||
;asma/token LDA2 ;strlen JSR2 ORA ,asma-ignore JCN
|
;asma/token LDA2 ;strlen JSR2 ORA ,asma-ignore JCN
|
||||||
;asma/comment-level LDAk #01 SUB DUP SWP2 STA ,asma-ignore JCN
|
;asma/comment-level LDAk #01 SUB DUP SWP2 STA ,asma-ignore JCN
|
||||||
@asma-comment-end
|
@asma-comment-end
|
||||||
#02 asma-STATE-CLEAR
|
;asma/state LDA #0c AND ;asma/state STA
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
@asma-macro-define
|
@asma-macro-define
|
||||||
|
@ -628,22 +619,22 @@
|
||||||
#0000 ;append-heap-short JSR2 ( less-than pointer )
|
#0000 ;append-heap-short JSR2 ( less-than pointer )
|
||||||
#0000 ;append-heap-short JSR2 ( greater-than pointer )
|
#0000 ;append-heap-short JSR2 ( greater-than pointer )
|
||||||
;asma/token LDA2 ;append-heap-string JSR2 ( key )
|
;asma/token LDA2 ;append-heap-string JSR2 ( key )
|
||||||
#04 asma-STATE-SET
|
;asma/state LDA #04 ORA ;asma/state STA
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
&ignore-macro
|
&ignore-macro
|
||||||
#14 asma-STATE-SET
|
;asma/state LDA #0c ORA ;asma/state STA
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
@asma-macro-body
|
@asma-macro-body
|
||||||
;asma/state LDA #10 AND ,&skip JCN
|
;asma/state LDA #08 AND ,&skip JCN
|
||||||
;asma/token LDA2 ;append-heap-string JSR2
|
;asma/token LDA2 ;append-heap-string JSR2
|
||||||
&skip
|
&skip
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
@asma-macro-end
|
@asma-macro-end
|
||||||
#00 ;append-heap-byte JSR2
|
#00 ;append-heap-byte JSR2
|
||||||
#14 asma-STATE-CLEAR
|
;asma/state LDA #02 AND ;asma/state STA
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
@asma-label-define
|
@asma-label-define
|
||||||
|
@ -852,7 +843,7 @@
|
||||||
|
|
||||||
&keep-going
|
&keep-going
|
||||||
DUP2k ;strlen JSR2 INC2 ADD2
|
DUP2k ;strlen JSR2 INC2 ADD2
|
||||||
SWP2 ;asma-assemble-token JSR2 asma-IF-ERROR ,¯o-error JCN
|
SWP2 ;asma-assemble-token JSR2 ;asma/error LDA2 ORA ,¯o-error JCN
|
||||||
,¯o-loop JMP
|
,¯o-loop JMP
|
||||||
|
|
||||||
¯o-error
|
¯o-error
|
||||||
|
|
|
@ -54,10 +54,6 @@
|
||||||
( - mul32 memory, 12 bytes )
|
( - mul32 memory, 12 bytes )
|
||||||
( - _divmod32 memory, 16 bytes )
|
( - _divmod32 memory, 16 bytes )
|
||||||
|
|
||||||
%COMPLEMENT32 { SWP2 #ffff EOR2 SWP2 #ffff EOR2 }
|
|
||||||
%DUP4 { OVR2 OVR2 }
|
|
||||||
%POP4 { POP2 POP2 }
|
|
||||||
|
|
||||||
( bitcount: number of bits needed to represent number )
|
( bitcount: number of bits needed to represent number )
|
||||||
( equivalent to floor[log2[x]] + 1 )
|
( equivalent to floor[log2[x]] + 1 )
|
||||||
|
|
||||||
|
@ -164,7 +160,7 @@
|
||||||
|
|
||||||
( ~x )
|
( ~x )
|
||||||
@complement32 ( x** -> ~x** )
|
@complement32 ( x** -> ~x** )
|
||||||
COMPLEMENT32 JMP2r
|
SWP2 #ffff EOR2 SWP2 #ffff EOR2 JMP2r
|
||||||
|
|
||||||
( temporary registers )
|
( temporary registers )
|
||||||
( shared by most operations, except mul32 and div32 )
|
( shared by most operations, except mul32 and div32 )
|
||||||
|
@ -289,7 +285,7 @@
|
||||||
|
|
||||||
( -x )
|
( -x )
|
||||||
@negate32 ( x** -> -x** )
|
@negate32 ( x** -> -x** )
|
||||||
COMPLEMENT32
|
;complement32 JSR2
|
||||||
INC2 ( ~xhi -xlo )
|
INC2 ( ~xhi -xlo )
|
||||||
DUP2 #0000 NEQ2 ( ~xhi -xlo non-zero? )
|
DUP2 #0000 NEQ2 ( ~xhi -xlo non-zero? )
|
||||||
,&done JCN ( xlo non-zero => don't inc hi )
|
,&done JCN ( xlo non-zero => don't inc hi )
|
||||||
|
@ -414,10 +410,10 @@
|
||||||
( greatest common divisor - euclidean algorithm )
|
( greatest common divisor - euclidean algorithm )
|
||||||
@gcd32 ( x** y** -> z** )
|
@gcd32 ( x** y** -> z** )
|
||||||
&loop ( x y )
|
&loop ( x y )
|
||||||
DUP4 ( x y y )
|
OVR2 OVR2 ( x y y )
|
||||||
;is-zero32 JSR2 ( x y y=0? )
|
;is-zero32 JSR2 ( x y y=0? )
|
||||||
,&done JCN ( x y )
|
,&done JCN ( x y )
|
||||||
DUP4 ( x y y )
|
OVR2 OVR2 ( x y y )
|
||||||
STH2 STH2 ( x y [y] )
|
STH2 STH2 ( x y [y] )
|
||||||
;mod32 JSR2 ( r=x%y [y] )
|
;mod32 JSR2 ( r=x%y [y] )
|
||||||
STH2r ( rhi rlo yhi [ylo] )
|
STH2r ( rhi rlo yhi [ylo] )
|
||||||
|
@ -428,5 +424,5 @@
|
||||||
ROT2 ( yhi ylo rhi rlo )
|
ROT2 ( yhi ylo rhi rlo )
|
||||||
,&loop JMP
|
,&loop JMP
|
||||||
&done
|
&done
|
||||||
POP4 ( x )
|
POP2 POP2 ( x )
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
|
@ -1,14 +1,5 @@
|
||||||
( app/neralie : clock with arvelie date )
|
( app/neralie : clock with arvelie date )
|
||||||
|
|
||||||
%PAD { #0018 }
|
|
||||||
|
|
||||||
%MOD { DIVk MUL SUB }
|
|
||||||
%MOD2 { DIV2k MUL2 SUB2 }
|
|
||||||
|
|
||||||
%h { .DateTime/hour DEI }
|
|
||||||
%m { .DateTime/minute DEI }
|
|
||||||
%s { .DateTime/second DEI }
|
|
||||||
|
|
||||||
( devices )
|
( devices )
|
||||||
|
|
||||||
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
||||||
|
@ -47,7 +38,7 @@
|
||||||
#01 .fps/current STZ
|
#01 .fps/current STZ
|
||||||
|
|
||||||
( set size )
|
( set size )
|
||||||
PAD
|
#0018 ( padding )
|
||||||
DUP2 .frame/x1 STZ2
|
DUP2 .frame/x1 STZ2
|
||||||
DUP2 .frame/y1 STZ2
|
DUP2 .frame/y1 STZ2
|
||||||
DUP2 .Screen/width DEI2 SWP2 SUB2 #0001 SUB2 .frame/x2 STZ2
|
DUP2 .Screen/width DEI2 SWP2 SUB2 #0001 SUB2 .frame/x2 STZ2
|
||||||
|
@ -79,22 +70,22 @@ BRK
|
||||||
@neralie-calc ( -- )
|
@neralie-calc ( -- )
|
||||||
|
|
||||||
( add up fractions of a pulse, store tenths in n6 )
|
( add up fractions of a pulse, store tenths in n6 )
|
||||||
#0120 #00 h MUL2
|
#0120 #00 .DateTime/hour DEI MUL2
|
||||||
#00c0 #00 m MUL2 ADD2
|
#00c0 #00 .DateTime/minute DEI MUL2 ADD2
|
||||||
#00f8 #00 s MUL2 ADD2
|
#00f8 #00 .DateTime/second DEI MUL2 ADD2
|
||||||
#0271 #00 .fps/next LDZ MUL2 #00 .fps/current LDZ DIV2 #30 SFT2 ADD2
|
#0271 #00 .fps/next LDZ MUL2 #00 .fps/current LDZ DIV2 #30 SFT2 ADD2
|
||||||
#01b0 ;modf JSR2 SWP2 #0017 MUL2 #03e8 DIV2 .neralie/n6 STZ POP
|
#01b0 ;modf JSR2 SWP2 #0017 MUL2 #03e8 DIV2 .neralie/n6 STZ POP
|
||||||
|
|
||||||
( add up units and tens of pulses, store in n5 and n4 )
|
( add up units and tens of pulses, store in n5 and n4 )
|
||||||
#0042 #00 h MUL2 ADD2
|
#0042 #00 .DateTime/hour DEI MUL2 ADD2
|
||||||
#005e #00 m MUL2 ADD2
|
#005e #00 .DateTime/minute DEI MUL2 ADD2
|
||||||
#000b #00 s MUL2 ADD2
|
#000b #00 .DateTime/second DEI MUL2 ADD2
|
||||||
#000a ;modf JSR2 SWP2 .neralie/n5 STZ POP
|
#000a ;modf JSR2 SWP2 .neralie/n5 STZ POP
|
||||||
#000a ;modf JSR2 SWP2 .neralie/n4 STZ POP
|
#000a ;modf JSR2 SWP2 .neralie/n4 STZ POP
|
||||||
|
|
||||||
( add up hundreds of pulses + 10 x beats, store in n0123 )
|
( add up hundreds of pulses + 10 x beats, store in n0123 )
|
||||||
#01a0 #00 h MUL2 ADD2
|
#01a0 #00 .DateTime/hour DEI MUL2 ADD2
|
||||||
#0006 #00 m MUL2 ADD2 .neralie/n0123 STZ2
|
#0006 #00 .DateTime/minute DEI MUL2 ADD2 .neralie/n0123 STZ2
|
||||||
|
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
|
@ -109,14 +100,14 @@ JMP2r
|
||||||
.DateTime/year DEI2 #07d6 SUB2 NIP
|
.DateTime/year DEI2 #07d6 SUB2 NIP
|
||||||
DUP #0a DIV #00 SWP #30 SFT2 ;font-numbers ADD2 .Screen/addr DEO2
|
DUP #0a DIV #00 SWP #30 SFT2 ;font-numbers ADD2 .Screen/addr DEO2
|
||||||
#01 .Screen/sprite DEO
|
#01 .Screen/sprite DEO
|
||||||
#0a MOD #00 SWP #30 SFT2 ;font-numbers ADD2 .Screen/addr DEO2
|
#0a DIVk MUL SUB #00 SWP #30 SFT2 ;font-numbers ADD2 .Screen/addr DEO2
|
||||||
#01 .Screen/sprite DEO
|
#01 .Screen/sprite DEO
|
||||||
.DateTime/doty DEI2
|
.DateTime/doty DEI2
|
||||||
DUP2 #000e DIV2 #30 SFT2 ;font-letters ADD2 .Screen/addr DEO2
|
DUP2 #000e DIV2 #30 SFT2 ;font-letters ADD2 .Screen/addr DEO2
|
||||||
#01 .Screen/sprite DEO
|
#01 .Screen/sprite DEO
|
||||||
#000e MOD2
|
#000e DIV2k MUL2 SUB2
|
||||||
DUP2 #000a DIV2 ,digit JSR
|
DUP2 #000a DIV2 ,digit JSR
|
||||||
#000a MOD2 ,digit JSR
|
#000a DIV2k MUL2 SUB2 ,digit JSR
|
||||||
|
|
||||||
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
|
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
|
||||||
|
|
||||||
|
@ -223,8 +214,8 @@ JMP2r
|
||||||
|
|
||||||
@update-fps ( -- )
|
@update-fps ( -- )
|
||||||
.fps/next LDZ INC .fps/next STZ
|
.fps/next LDZ INC .fps/next STZ
|
||||||
s .fps/second LDZ NEQ JMP JMP2r
|
.DateTime/second DEI .fps/second LDZ NEQ JMP JMP2r
|
||||||
s .fps/second STZ
|
.DateTime/second DEI .fps/second STZ
|
||||||
.fps/next LDZ .fps/current STZ
|
.fps/next LDZ .fps/current STZ
|
||||||
|
|
||||||
#00 .fps/next STZ
|
#00 .fps/next STZ
|
||||||
|
|
Loading…
Reference in New Issue