Merge branch 'main' of git.sr.ht:~rabbits/uxn

This commit is contained in:
neauoire 2022-09-04 13:08:49 -07:00
commit 36136ccb0e
48 changed files with 691 additions and 1186 deletions

View File

@ -44,30 +44,6 @@ BRK
BRK
@clear-ball ( -- )
.ball/x LDZ2 .Screen/x DEO2
.ball/y LDZ2 .Screen/y DEO2
#76 .Screen/auto DEO
#0800
&loop-bg
#40 .Screen/sprite DEO
INC GTHk ,&loop-bg JCN
POP2
JMP2r
@move-ball ( -- )
,clear-ball JSR
.ball/vx LDZ2k STH2k ROT STZ2
.ball/x LDZ2k STH2r ADD2 ,check-flip-vx JSR ROT STZ2
.ball/vy LDZ2k INC2 STH2k ROT STZ2
.ball/y LDZ2k STH2r ADD2 ,check-flip-vy JSR ROT STZ2
,draw-ball JSR
JMP2r
@check-flip-vx ( x -- x )
( left ) DUP2 #0010 LTH2 ,&flip JCN
@ -85,6 +61,23 @@ JMP2r
JMP2r
@move-ball ( -- )
( clear )
.ball/x LDZ2 .Screen/x DEO2
.ball/y LDZ2 .Screen/y DEO2
#76 .Screen/auto DEO
#0800
&loop-bg
#40 .Screen/sprite DEO
INC GTHk ,&loop-bg JCN
POP2
.ball/vx LDZ2k STH2k ROT STZ2
.ball/x LDZ2k STH2r ADD2 ,check-flip-vx JSR ROT STZ2
.ball/vy LDZ2k INC2 STH2k ROT STZ2
.ball/y LDZ2k STH2r ADD2 ,check-flip-vy JSR ROT STZ2
@draw-ball ( -- )
( shadow )

View File

@ -90,9 +90,6 @@ JMP2r
[ .center/x LDZ2 #0008 ADD2 ]
[ .center/y LDZ2 #0018 ADD2 ]
.DateTime/second DEI #0a ;mod JSR2
;draw-number JSR2
JMP2r
@draw-number ( x* y* n -- )
@ -146,7 +143,7 @@ JMP2r
JMP2r
@mod DUP2 DIV MUL SUB JMP2r
@mod DIVk MUL SUB JMP2r
@cursor
80c0 e0f0 f8e0 1000

View File

@ -1,31 +1,4 @@
( logic )
%+ { ADD } %- { SUB } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%2* { #10 SFT } %2/ { #01 SFT }
%4* { #20 SFT } %4/ { #02 SFT }
%8* { #30 SFT } %8/ { #03 SFT }
%10* { #40 SFT } %10/ { #04 SFT }
%20* { #50 SFT } %20/ { #05 SFT }
%2** { #10 SFT2 } %2// { #01 SFT2 }
%4** { #20 SFT2 } %4// { #02 SFT2 }
%8** { #30 SFT2 } %8// { #03 SFT2 }
%10** { #40 SFT2 } %10// { #04 SFT2 }
%20** { #50 SFT2 } %20// { #05 SFT2 }
%RELEASE-MOUSE { #0096 DEO }
%AUTO-X { #01 .Screen/auto DEO }
%AUTO-X-ADDR { #05 .Screen/auto DEO }
%AUTO-NONE { #00 .Screen/auto DEO }
%RTN { JMP2r }
%TOS { #00 SWP }
( devices )
( bitwise )
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 ]
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ]
@ -63,13 +36,13 @@
;on-mouse .Mouse/vector DEO2
.Screen/width DEI2 2//
DUP2 #0040 -- .a-frame/x STZ2 DUP2 #0040 ++ .a-frame/x2 STZ2
DUP2 #0040 -- .b-frame/x STZ2 #0040 ++ .b-frame/x2 STZ2
.Screen/width DEI2 #01 SFT2
DUP2 #0040 SUB2 .a-frame/x STZ2 DUP2 #0040 ADD2 .a-frame/x2 STZ2
DUP2 #0040 SUB2 .b-frame/x STZ2 #0040 ADD2 .b-frame/x2 STZ2
.Screen/height DEI2 2// #0020 --
DUP2 #0010 -- .a-frame/y STZ2 DUP2 #0000 ++ .a-frame/y2 STZ2
DUP2 .b-frame/y STZ2 #0010 ++ .b-frame/y2 STZ2
.Screen/height DEI2 #01 SFT2 #0020 SUB2
DUP2 #0010 SUB2 .a-frame/y STZ2 DUP2 .a-frame/y2 STZ2
DUP2 .b-frame/y STZ2 #0010 ADD2 .b-frame/y2 STZ2
;redraw JSR2
@ -79,7 +52,7 @@ BRK
;draw-cursor JSR2
.Mouse/state DEI #00 ! JMP [ BRK ]
.Mouse/state DEI #00 NEQ JMP [ BRK ]
.Mouse/x DEI2 .Mouse/y DEI2 .a-frame ;within-rect JSR2
;on-touch-a JCN2
@ -90,29 +63,29 @@ BRK
@on-touch-a ( -> )
.Mouse/x DEI2 .a-frame/x LDZ2 --
10// NIP #07 SWP - STH
.Mouse/x DEI2 .a-frame/x LDZ2 SUB2
#04 SFT2 NIP #07 SWP SUB STH
.input/a LDZ
#01 [ STHr #40 SFT ] SFT EOR
.input/a STZ
;redraw JSR2
RELEASE-MOUSE
#00 .Mouse/state DEO
BRK
@on-touch-b ( -> )
.Mouse/x DEI2 .b-frame/x LDZ2 --
10// NIP #07 SWP - STH
.Mouse/x DEI2 .b-frame/x LDZ2 SUB2
#04 SFT2 NIP #07 SWP SUB STH
.input/b LDZ
#01 [ STHr #40 SFT ] SFT EOR
.input/b STZ
;redraw JSR2
RELEASE-MOUSE
#00 .Mouse/state DEO
BRK
@ -127,82 +100,82 @@ BRK
.input/b LDZ #01 ;draw-byte JSR2
.b-frame/x LDZ2 .Screen/x DEO2
.Screen/y DEI2 #000d ++ .Screen/y DEO2
.Screen/y DEI2 #000d ADD2 .Screen/y DEO2
.input LDZ2 AND #03 ;draw-byte JSR2
.b-frame/x LDZ2 .Screen/x DEO2
.Screen/y DEI2 #000d ++ .Screen/y DEO2
.Screen/y DEI2 #000d ADD2 .Screen/y DEO2
.input LDZ2 ORA #03 ;draw-byte JSR2
.b-frame/x LDZ2 .Screen/x DEO2
.Screen/y DEI2 #000d ++ .Screen/y DEO2
.Screen/y DEI2 #000d ADD2 .Screen/y DEO2
.input LDZ2 EOR #03 ;draw-byte JSR2
( labels )
AUTO-X-ADDR
.b-frame/x LDZ2 #0020 -- .Screen/x DEO2
#05 .Screen/auto DEO
.b-frame/x LDZ2 #0020 SUB2 .Screen/x DEO2
;names-icn/and .Screen/addr DEO2
.b-frame/y2 LDZ2 #0004 ++ .Screen/y DEO2
.b-frame/y2 LDZ2 #0004 ADD2 .Screen/y DEO2
,&draw-label JSR
.b-frame/y2 LDZ2 #0014 ++ .Screen/y DEO2
.b-frame/y2 LDZ2 #0014 ADD2 .Screen/y DEO2
,&draw-label JSR
.b-frame/y2 LDZ2 #0024 ++ .Screen/y DEO2
.b-frame/y2 LDZ2 #0024 ADD2 .Screen/y DEO2
,&draw-label JSR
AUTO-NONE
#00 .Screen/auto DEO
RTN
JMP2r
&draw-label
.b-frame/x LDZ2 #0020 -- .Screen/x DEO2
.b-frame/x LDZ2 #0020 SUB2 .Screen/x DEO2
#03 .Screen/sprite DEOk DEOk DEO
RTN
JMP2r
@draw-byte ( value -- )
STH STH
#0800
&loop
DUP #07 SWP -
#07 OVR SUB
STHkr SWP SFT #01 AND OVRr STHr ;draw-bit JSR2
INC GTHk ,&loop JCN
POP2
.Screen/y DEI2 #0003 ++ .Screen/y DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
.Screen/y DEI2 #0003 ADD2 .Screen/y DEO2
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
STHr ;draw-hex JSR2
POPr
RTN
JMP2r
@draw-bit ( value color -- )
STH STH
AUTO-X-ADDR
;button-icns/off [ #00 STHkr 20* ++ ] .Screen/addr DEO2
#05 .Screen/auto DEO
;button-icns/off [ #00 STHkr #50 SFT ADD2 ] .Screen/addr DEO2
OVRr STHr .Screen/sprite DEO
OVRr STHr .Screen/sprite DEO
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
.Screen/x DEI2 #0010 -- .Screen/x DEO2
.Screen/y DEI2 #0008 ADD2 .Screen/y DEO2
.Screen/x DEI2 #0010 SUB2 .Screen/x DEO2
OVRr STHr .Screen/sprite DEO
OVRr STHr .Screen/sprite DEO
AUTO-NONE
.Screen/y DEI2 #0008 -- .Screen/y DEO2
#00 .Screen/auto DEO
.Screen/y DEI2 #0008 SUB2 .Screen/y DEO2
POPr POPr
POP2r
RTN
JMP2r
@draw-hex ( value -- )
AUTO-X
#01 .Screen/auto DEO
DUP #04 SFT ,&draw JSR
#0f AND ,&draw JSR
AUTO-X
#01 .Screen/auto DEO
RTN
JMP2r
&draw
TOS 8** ;font-hex ++ .Screen/addr DEO2
#00 SWP #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2
( draw ) #01 .Screen/sprite DEO
RTN
JMP2r
@draw-cursor ( -- )
@ -215,26 +188,26 @@ RTN
.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2
( colorize on state )
#42 [ .Mouse/state DEI #00 ! ] + .Screen/sprite DEO
#42 [ .Mouse/state DEI #00 NEQ ] ADD .Screen/sprite DEO
RTN
JMP2r
@within-rect ( x* y* rect -- flag )
STH
( y < rect.y1 ) DUP2 STHkr #02 ADD LDZ2 LTH2 ,&skip JCN
( y < rect.y1 ) DUP2 STHkr INC INC LDZ2 LTH2 ,&skip JCN
( y > rect.y2 ) DUP2 STHkr #06 ADD LDZ2 GTH2 ,&skip JCN
SWP2
( x < rect.x1 ) DUP2 STHkr LDZ2 LTH2 ,&skip JCN
( x > rect.x2 ) DUP2 STHkr #04 ADD LDZ2 GTH2 ,&skip JCN
POP2 POP2 POPr
#01
RTN
JMP2r
&skip
POP2 POP2 POPr
#00
RTN
JMP2r
@cursor
80c0 e0f0 f8e0 1000

View File

@ -110,9 +110,9 @@ BRK
( top )
[ LDA2k ] #05 SFT2 .Screen/x DEO2
[ INC2 INC2 LDA2 ] #05 SFT2 .Screen/y DEO2
#85 ,draw-sprite JSR
#85 ,draw-sprite ( .. )
JMP2r
JMP
@draw-sprite ( color -- )
@ -183,7 +183,7 @@ JMP2r
;sprite/length LDA2
( don't let length go below 0 )
DUP2 #0000 EQU2 ,&bail JCN
ORAk #00 EQU ,&bail JCN
( clear the old sprite location )
DUP2 #0001 SUB2 #30 SFT2 ;sprite/array ADD2
( top )
@ -217,7 +217,7 @@ JMP2r
( z = a )
,&a LDR DUP ,&z STR
( a = z ^ t ^ (z >> 1) ^ (t << 1) )
DUP #10 SFT EOR SWP DUP #01 SFT EOR EOR
DUPk ADD EOR SWP DUP #01 SFT EOR EOR
DUP ,&a STR
JMP2r

View File

@ -43,22 +43,22 @@ BRK
STHk
#00 .timer LDZ [ #00 STHkr INC #07 AND #60 SFT ADD2 ] #00ff AND2 ;table ADD2 LDA #01 SFT
#00 .timer LDZ [ #00 STHkr #60 SFT ADD2 ] #00ff AND2 ;table ADD2 LDA #02 SFT [ #00 STHkr #62 SFT2 ADD2 ]
.cube/v0 STHr #10 SFT ADD STZ2
.cube/v0 STHr DUP ADD ADD STZ2
INC GTHk ,&loop JCN
POP2
( vertices )
#0800
&ver-loop
DUP #10 SFT .cube ADD LDZ2 ;draw-vertex JSR2
DUP DUP ADD .cube ADD LDZ2 ;draw-vertex JSR2
INC GTHk ,&ver-loop JCN
POP2
( lines )
#0400
&line-loop
STHk
.cube/v0 STHkr #10 SFT ADD .cube/v0 STHkr INC #03 AND #10 SFT ADD ,trace JSR
.cube/v0 STHkr #10 SFT ADD .cube/v4 STHkr #10 SFT ADD ,trace JSR
.cube/v4 STHkr #10 SFT ADD .cube/v4 STHr INC #03 AND #10 SFT ADD ,trace JSR
.cube/v0 STHkr DUP ADD ADD .cube/v0 STHkr INC #03 AND DUP ADD ADD ,trace JSR
.cube/v0 STHkr DUP ADD ADD .cube/v4 STHkr DUP ADD ADD ,trace JSR
.cube/v4 STHkr DUP ADD ADD .cube/v4 STHr INC #03 AND DUP ADD ADD ,trace JSR
INC GTHk ,&line-loop JCN
POP2
@ -88,15 +88,15 @@ JMP2r
( load ) STH ,&y STR2 ,&x STR2 .line/y STZ2 .line/x STZ2
,&x LDR2 .line/x LDZ2 SUB2 ;abs2 JSR2 .line/dx STZ2
#0000 ,&y LDR2 .line/y LDZ2 SUB2 ;abs2 JSR2 SUB2 .line/dy STZ2
#ffff #00 .line/x LDZ2 ,&x LDR2 ;lts2 JSR2 #10 SFT2 ADD2 ,&sx STR2
#ffff #00 .line/y LDZ2 ,&y LDR2 ;lts2 JSR2 #10 SFT2 ADD2 ,&sy STR2
#ffff #00 .line/x LDZ2 ,&x LDR2 ;lts2 JSR2 DUP2 ADD2 ADD2 ,&sx STR2
#ffff #00 .line/y LDZ2 ,&y LDR2 ;lts2 JSR2 DUP2 ADD2 ADD2 ,&sy STR2
.line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
&loop
.line/x LDZ2 DUP2 .Screen/x DEO2 [ LIT2 &x $2 ] EQU2
.line/y LDZ2 DUP2 .Screen/y DEO2 [ LIT2 &y $2 ] EQU2
STHkr .Screen/pixel DEO
AND ,&end JCN
.line/e1 LDZ2 #10 SFT2 DUP2
.line/e1 LDZ2 DUP2 ADD2 DUP2
.line/dy LDZ2 ;lts2 JSR2 ,&skipy JCN
.line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
.line/x LDZ2 [ LIT2 &sx $2 ] ADD2 .line/x STZ2

View File

@ -22,7 +22,7 @@
#00 .DateTime/minute DEI #60 SFT2 EOR2
#00 .DateTime/hour DEI #c0 SFT2 EOR2 ;prng/x STA2
#00 .DateTime/hour DEI #04 SFT2
#00 .DateTime/day DEI #10 SFT2 EOR2
#00 .DateTime/day DEI DUP2 ADD2 EOR2
#00 .DateTime/month DEI #60 SFT2 EOR2
.DateTime/year DEI2 #a0 SFT2 EOR2 ;prng/y STA2
;prng/x LDA2 ;prng/y LDA2 EOR2
@ -160,7 +160,7 @@
( rabbit is in-between two frames )
#08 OVR SUB ,&from-weight STR
,&to-weight STR ( color n / frame )
#00 SWP #10 SFT2 ;rabbits ADD2 #00c8 #00 STHr MUL2 ADD2 ( color from-addr* )
#00 SWP DUP2 ADD2 ;rabbits ADD2 #00c8 #00 STHr MUL2 ADD2 ( color from-addr* )
LDA2k STH2 #00c8 ADD2 LDA2
&draw ( color to-x to-y / from-x from-y )
STHr ,&mix JSR LIT2 &yoffset $2 ADD2 .Screen/y DEO2
@ -181,7 +181,7 @@
&static ( color n counter / frame )
INCr
POP
#00 SWP #10 SFT2 ;rabbits ADD2 #00c8 #00 STHr MUL2 ADD2
#00 SWP DUP2 ADD2 ;rabbits ADD2 #00c8 #00 STHr MUL2 ADD2
LDA2 STH2k
,&draw JMP

View File

@ -35,13 +35,13 @@ BRK
STH2k #0000 EQU2 ,&flip-x JCN
STH2kr [ LIT2 &hit-hor $2 ] EQU2 ,&flip-x JCN
&no-x
STH2r [ #00 .dvd/dx LDZ ] #10 SFT2 ADD2 #ffff ADD2 .dvd/x STZ2
STH2r [ #00 .dvd/dx LDZ ] DUP2 ADD2 ADD2 #ffff ADD2 .dvd/x STZ2
( y )
.dvd/y LDZ2
STH2k #0000 EQU2 ,&flip-y JCN
STH2kr [ LIT2 &hit-ver $2 ] EQU2 ,&flip-y JCN
&no-y
STH2r [ #00 .dvd/dy LDZ ] #10 SFT2 ADD2 #ffff ADD2 .dvd/y STZ2
STH2r [ #00 .dvd/dy LDZ ] DUP2 ADD2 ADD2 #ffff ADD2 .dvd/y STZ2
#01 ,draw-dvd JSR
BRK

View File

@ -31,11 +31,11 @@
;on-mouse .Mouse/vector DEO2
;on-control .Controller/vector DEO2
( glider )
#07 #03 ;set-cell JSR2
#07 #04 ;set-cell JSR2
#05 #04 ;set-cell JSR2
#07 #05 ;set-cell JSR2
#06 #05 ;set-cell JSR2
#0703 ;set-cell JSR2
#0704 ;set-cell JSR2
#0504 ;set-cell JSR2
#0705 ;set-cell JSR2
#0605 ;set-cell JSR2
( center )
.Screen/width DEI2 #01 SFT2 #0040 SUB2
DUP2 .anchor/x STZ2
@ -118,9 +118,9 @@ BRK
( move buffer )
;bank2 ;bank1 #1000 ;mcpy JSR2
( draw )
;draw-grid JSR2
;draw-grid ( .. )
JMP2r
JMP2
@run-cell ( x y -- )
@ -130,13 +130,13 @@ JMP2r
#00 EQU ,&dead JCN
DUP #02 LTH ,&dies JCN
DUP #03 GTH ,&dies JCN
POP ;&save JSR2 JMP2r
POP ;&save JMP2
&dies POP POP2 JMP2r
&dead
DUP #03 EQU ,&birth JCN POP POP2 JMP2r
&birth POP ;&save JSR2
&birth POP ;&save ( .. )
JMP2r
JMP2
&save ( x y -- )
STH2 #01 STH2r ,get-index JSR [ #1000 ADD2 ] STA
.world/count LDZ2 INC2 .world/count STZ2
@ -168,7 +168,7 @@ JMP2r
LITr 00
#0800
&loop
#00 OVR #10 SFT2 ;&mask ADD2 LDA2 [ LIT2 &origin $2 ]
#00 OVRk ADD2 ;&mask ADD2 LDA2 [ LIT2 &origin $2 ]
ROT ADD STH ADD STHr ;get-cell JSR2 STH ADDr
INC GTHk ,&loop JCN
POP2
@ -187,11 +187,11 @@ JMP2r
#00 .Screen/auto DEO
#4000
&ver
#00 OVR #10 SFT2 .anchor/y LDZ2 ADD2 .Screen/y DEO2
#00 OVRk ADD2 .anchor/y LDZ2 ADD2 .Screen/y DEO2
STHk
#4000
&hor
#00 OVR #10 SFT2 .anchor/x LDZ2 ADD2 .Screen/x DEO2
#00 OVRk ADD2 .anchor/x LDZ2 ADD2 .Screen/x DEO2
DUP STHkr ;get-cell JSR2 INC .Screen/pixel DEO
INC GTHk ,&hor JCN
POP2

View File

@ -2,10 +2,8 @@
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%GTS2 { #8000 ++ SWP2 #8000 ++ << }
%GTS2 { #8000 ADD2 SWP2 #8000 ADD2 LTH2 }
%AUTO-X { #01 .Screen/auto DEO }
%NEXT-LINE { #0000 .Screen/x DEO2 .Screen/y DEI2k INC2 ROT DEO2 }
@ -17,8 +15,8 @@
%YMIN { #ecc7 } ( -4915 )
%YMAX { #1333 } ( 4915 )
%MAXI { #20 } ( 32 )
%DX { XMAX XMIN -- WIDTH // } ( (XMAX-XMIN)/W )
%DY { YMAX YMIN -- HEIGHT // } ( (YMAX-YMIN)/H )
%DX { XMAX XMIN SUB2 WIDTH DIV2 } ( (XMAX-XMIN)/W )
%DY { YMAX YMIN SUB2 HEIGHT DIV2 } ( (YMAX-YMIN)/H )
%X { .x LDZ2 } %Y { .y LDZ2 }
%X2 { .x2 LDZ2 } %Y2 { .y2 LDZ2 }
@ -54,21 +52,21 @@ BRK
XMAX XMIN
&hor
DUP2 ,&x STR2
#0000 DUP2 DUP2 DUP2 .x STZ2 .y STZ2 .x2 STZ2 .y2 STZ2
#0000 DUP2k DUP2 .x STZ2 .y STZ2 .x2 STZ2 .y2 STZ2
MAXI #00
&loop
X Y ;smul2 JSR2 DUP2 ADD2 [ LIT2 &y $2 ] ++ .y STZ2
X2 Y2 -- [ LIT2 &x $2 ] ++ .x STZ2
X Y ;smul2 JSR2 DUP2 ADD2 [ LIT2 &y $2 ] ADD2 .y STZ2
X2 Y2 SUB2 [ LIT2 &x $2 ] ADD2 .x STZ2
X DUP2 ;smul2 JSR2 .x2 STZ2
Y DUP2 ;smul2 JSR2 .y2 STZ2
X2 Y2 ++ #4000 >> ,&end JCN
X2 Y2 ADD2 #4000 GTH2 ,&end JCN
INC GTHk ,&loop JCN
&end
NIP .Screen/pixel DEO
DX ++ OVR2 OVR2 GTS2 ;&hor JCN2
DX ADD2 OVR2 OVR2 GTS2 ;&hor JCN2
POP2 POP2
NEXT-LINE
DY ++ OVR2 OVR2 GTS2 ;&ver JCN2
DY ADD2 OVR2 OVR2 GTS2 ;&ver JCN2
POP2 POP2
JMP2r

View File

@ -30,7 +30,7 @@ BRK
@on-frame ( -> )
.Controller/button DEI
DUP #00 NEQ ,&continue JCN
DUP ,&continue JCN
POP BRK
&continue
( clear )

View File

@ -54,9 +54,9 @@ BRK
#81 .Screen/sprite DEO
( eye/tail )
#00 ,draw-eye JSR
#00 ;draw-tail JSR2
#00 ;draw-tail ( .. )
JMP2r
JMP2
@on-mouse ( -> )
@ -74,8 +74,7 @@ BRK
DUP ,&last LDR NEQ ,&changed JCN
POP JMP2r &changed
( only redraw on change )
DUP
#00 SWP ;eye ADD2 .Screen/addr DEO2
#00 OVR ;eye ADD2 .Screen/addr DEO2
.cat/y LDZ2 #0008 ADD2 .Screen/y DEO2
.cat/x LDZ2 #0008 SUB2 .Screen/x DEO2
#81 .Screen/sprite DEOk DEO

View File

@ -201,7 +201,7 @@ JMP2r
@transform ( xy cell -- cell )
DUP #00 NEQ ,&no-null JCN NIP NIP JMP2r &no-null
DUP ,&no-null JCN NIP NIP JMP2r &no-null
DUP #03 NEQ ,&no-head JCN POP POP2 #02 JMP2r &no-head
DUP #02 NEQ ,&no-tail JCN POP POP2 #01 JMP2r &no-tail
DUP #01 NEQ ,&no-cond JCN POP
@ -217,8 +217,8 @@ JMP2r
( bl ) #0001 SUB2 LDAk #03 NEQ JMP INCr
( bc ) INC2 LDAk #03 NEQ JMP INCr
( br ) INC2 LDA #03 NEQ JMP INCr
STHkr #02 EQU STHr #01 EQU #0000 GTH2
#10 SFT INC JMP2r
STHkr #02 EQU STHr #01 EQU ORA
DUP ADD INC JMP2r
&no-cond
( unknown )
NIP NIP

View File

@ -1,6 +1,6 @@
( dev/audio )
%MOD { DUP2 DIV MUL SUB }
%MOD { DIVk MUL SUB }
( devices )

View File

@ -1,13 +1,7 @@
( dev/audio )
%2// { #01 SFT2 }
%4** { #20 SFT2 }
%8** { #30 SFT2 }
%20MOD { #1f AND }
%RTN { JMP2r }
%GET-NOTE { #00 SWP ;melody ADD2 LDA }
%GET-HEXCHAR { #00 SWP 8** ;font-hex ADD2 .Screen/addr DEO2 }
%GET-HEXCHAR { #00 SWP #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2 }
( devices )
@ -44,8 +38,8 @@
#dd .Audio0/volume DEO ( TODO: turn ON )
( center )
.Screen/width DEI2 2// #0080 SUB2 .offset/x STZ2
.Screen/height DEI2 2// #0040 SUB2 .offset/y STZ2
.Screen/width DEI2 #01 SFT2 #0080 SUB2 .offset/x STZ2
.Screen/height DEI2 #01 SFT2 #0040 SUB2 .offset/y STZ2
;draw JSR2
#02 ;draw-selector JSR2
@ -71,12 +65,12 @@ BRK
&no-down
[ #04 ] NEQk NIP ,&no-left JCN
#00 ;draw-selector JSR2
.selection LDZ #01 SUB 20MOD .selection STZ
.selection LDZ #01 SUB #1f AND .selection STZ
#02 ;draw-selector JSR2
&no-left
[ #08 ] NEQk NIP ,&no-right JCN
#00 ;draw-selector JSR2
.selection LDZ INC 20MOD .selection STZ
.selection LDZ INC #1f AND .selection STZ
#02 ;draw-selector JSR2
&no-right
POP
@ -89,9 +83,9 @@ BRK
( skip ) .timer LDZ #10 EQU #01 JCN [ BRK ]
.progress LDZ
( play note ) DUP GET-NOTE .Audio0/pitch DEO
( erase last ) DUP #01 SUB 20MOD #01 ,draw-note JSR
( erase last ) DUP #01 SUB #1f AND #01 ,draw-note JSR
( draw current ) #01 ,draw-note JSR
( incr ) .progress LDZ INC 20MOD .progress STZ
( incr ) .progress LDZ INC #1f AND .progress STZ
#00 .timer STZ
BRK
@ -104,30 +98,30 @@ BRK
INC GTHk ,&loop JCN
POP2
RTN
JMP2r
@draw-note ( id color -- )
STH STH
( set x ) [ #00 STHkr ] 8** .offset/x LDZ2 ADD2 .Screen/x DEO2
( set y ) [ #00 #00 STHkr ;melody ADD2 LDA ] 4** #0100 SWP2 SUB2 .offset/y LDZ2 ADD2 #0080 ADD2 .Screen/y DEO2
( set x ) [ #00 STHkr ] #30 SFT2 .offset/x LDZ2 ADD2 .Screen/x DEO2
( set y ) [ #00 #00 STHkr ;melody ADD2 LDA ] #20 SFT2 #0100 SWP2 SUB2 .offset/y LDZ2 ADD2 #0080 ADD2 .Screen/y DEO2
( set addr ) ;marker-icn [ #00 .progress LDZ STHr EQU #08 MUL ADD2 ] .Screen/addr DEO2
( draw ) STHr .Screen/sprite DEO
RTN
JMP2r
@draw-selector ( color -- )
STH
[ #00 .selection LDZ ] 8** .offset/x LDZ2 ADD2 .Screen/x DEO2
[ #00 .selection LDZ ] #30 SFT2 .offset/x LDZ2 ADD2 .Screen/x DEO2
#0070 .offset/y LDZ2 ADD2 .Screen/y DEO2
;selector-icn .Screen/addr DEO2
STHkr .Screen/sprite DEO
.Screen/y DEI2 #0008 ADD2 .Screen/y DEO2
.Screen/y DEI2k #0008 ADD2 ROT DEO2
.selection LDZ GET-NOTE STHr ,draw-byte JSR
RTN
JMP2r
@draw-byte ( byte color -- )
@ -139,7 +133,7 @@ RTN
#0f AND GET-HEXCHAR
( draw ) STHr .Screen/sprite DEO
RTN
JMP2r
@melody
54 52 54 4f 4b 4f 48 ff
@ -180,4 +174,4 @@ RTN
007c 8282 7c82 827c 007c 8282 7e02 827c
007c 8202 7e82 827e 00fc 8282 fc82 82fc
007c 8280 8080 827c 00fc 8282 8282 82fc
007c 8280 f080 827c 007c 8280 f080 8080
007c 8280 f080 827c 007c 8280 f080 8080

View File

@ -81,7 +81,7 @@ BRK
#03 STHkr #03 SFT #01 AND DUP ADD SUB .Screen/sprite DEO
( buttons )
.center/y LDZ2 #0000 ADD2 .Screen/y DEO2
.center/y LDZ2 .Screen/y DEO2
.center/x LDZ2 #0018 ADD2 .Screen/x DEO2
;controller-icn/button .Screen/addr DEO2
#03 STHkr #01 SFT #01 AND SUB .Screen/sprite DEO
@ -89,7 +89,7 @@ BRK
;font-hex #0058 ADD2 .Screen/addr DEO2
#03 .Screen/sprite DEO
.center/y LDZ2 #0000 ADD2 .Screen/y DEO2
.center/y LDZ2 .Screen/y DEO2
.center/x LDZ2 #0024 ADD2 .Screen/x DEO2
;controller-icn/button .Screen/addr DEO2
#03 STHr #01 AND SUB .Screen/sprite DEO

View File

@ -9,18 +9,31 @@
@line
&x $2 &y $2 &dx $2 &dy $2 &e1 $2
@length $2
@frame $2
@pen
&x $2 &y $2 &x2 $2 &y2 $2
@pointer
&x $2 &y $2 &lastx $2 &lasty $2 &state $1
|0100 ( -> )
( theme )
#a0f0 .System/r DEO2
#40ff .System/g DEO2
#60ff .System/b DEO2
#4cfd .System/r DEO2
#4cf3 .System/g DEO2
#dcf2 .System/b DEO2
( vectors )
;on-mouse .Mouse/vector DEO2
;on-frame .Screen/vector DEO2
BRK
@on-frame ( -> )
.Mouse/state DEI ,&skip JCN
;run DUP2 JSR2 JSR2
&skip
BRK
@ -34,7 +47,7 @@ BRK
( draw new cursor )
.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2
#43 .Mouse/state DEI #00 NEQ DUP ADD SUB .Screen/sprite DEO
#42 .Mouse/state DEI #00 NEQ ADD .Screen/sprite DEO
( on down )
.Mouse/state DEI #00 NEQ .pointer/state LDZ #00 EQU AND ,on-mouse-down JCN
( on drag )
@ -45,6 +58,8 @@ BRK
@on-mouse-down ( -> )
#0000 DUP2 .length STZ2 .frame STZ2
;clear-screen JSR2
( record start position )
.Mouse/x DEI2 DUP2 .pointer/x STZ2 .pointer/lastx STZ2
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .pointer/lasty STZ2
@ -53,36 +68,65 @@ BRK
BRK
@on-mouse-drag ( -> )
( record )
;stroke .length LDZ2 #20 SFT2 ADD2 STH2
.pointer/x LDZ2 .pointer/lastx LDZ2 SUB2 STH2kr STA2
.pointer/y LDZ2 .pointer/lasty LDZ2 SUB2 STH2r INC2 INC2 STA2
( move ptr )
.length LDZ2 INC2 .length STZ2
( draw line )
.pointer/lastx LDZ2
.pointer/lasty LDZ2
.pointer/x LDZ2
.pointer/y LDZ2
.Mouse/state DEI INC
;draw-line JSR2
#01
;draw-line JSR2
( record last position )
.Mouse/x DEI2 .pointer/lastx STZ2
.Mouse/y DEI2 .pointer/lasty STZ2
.Mouse/x DEI2
DUP2 .pointer/lastx STZ2
DUP2 .pen/x STZ2
.pen/x2 STZ2
.Mouse/y DEI2
DUP2 .pointer/lasty STZ2
DUP2 .pen/y STZ2
.pen/y2 STZ2
.Mouse/state DEI .pointer/state STZ
BRK
@run ( -- )
( read )
;stroke .frame LDZ2 #20 SFT2 ADD2 STH2
.pen/x LDZ2 STH2kr LDA2 ADD2 .pen/x STZ2
.pen/y LDZ2 STH2r INC2 INC2 LDA2 ADD2 .pen/y STZ2
( line )
.pen/x LDZ2 .pen/y LDZ2
.pen/x2 LDZ2 .pen/y2 LDZ2
.frame LDZ2 #01 SFT2 NIP #01 AND INC ;draw-line JSR2
( history )
.pen/x LDZ2 .pen/x2 STZ2
.pen/y LDZ2 .pen/y2 STZ2
( incr frame )
.frame LDZ2 INC2 .length LDZ2 INC2 ( mod2 ) DIV2k MUL2 SUB2 .frame STZ2
JMP2r
@draw-line ( x1* y1* x2* y2* color -- )
( load ) STH ,&y STR2 ,&x STR2 .line/y STZ2 .line/x STZ2
,&x LDR2 .line/x LDZ2 SUB2 ;abs2 JSR2 .line/dx STZ2
#0000 ,&y LDR2 .line/y LDZ2 SUB2 ;abs2 JSR2 SUB2 .line/dy STZ2
#ffff #00 .line/x LDZ2 ,&x LDR2 ;lts2 JSR2 #10 SFT2 ADD2 ,&sx STR2
#ffff #00 .line/y LDZ2 ,&y LDR2 ;lts2 JSR2 #10 SFT2 ADD2 ,&sy STR2
#ffff #00 .line/x LDZ2 ,&x LDR2 ;lts2 JSR2 DUP2 ADD2 ADD2 ,&sx STR2
#ffff #00 .line/y LDZ2 ,&y LDR2 ;lts2 JSR2 DUP2 ADD2 ADD2 ,&sy STR2
.line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
&loop
.line/x LDZ2 DUP2 .Screen/x DEO2 [ LIT2 &x $2 ] EQU2
.line/y LDZ2 DUP2 .Screen/y DEO2 [ LIT2 &y $2 ] EQU2
STHkr .Screen/pixel DEO
AND ,&end JCN
.line/e1 LDZ2 #10 SFT2 DUP2
.line/e1 LDZ2 DUP2 ADD2 DUP2
.line/dy LDZ2 ;lts2 JSR2 ,&skipy JCN
.line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
.line/x LDZ2 [ LIT2 &sx $2 ] ADD2 .line/x STZ2
@ -101,4 +145,24 @@ JMP2r
@lts2 #8000 STH2k ADD2 SWP2 STH2r ADD2 GTH2 JMP2r
@gts2 #8000 STH2k ADD2 SWP2 STH2r ADD2 LTH2 JMP2r
@pointer-icn 80c0 e0f0 f8e0 1000
@clear-screen ( -- )
.Screen/height DEI2 #03 SFT2 NIP #00
&y
#00 OVR #30 SFT2 .Screen/y DEO2
.Screen/width DEI2 #03 SFT2 NIP #00
&x
#00 OVR #30 SFT2 .Screen/x DEO2
#00 .Screen/sprite DEO
INC GTHk ,&x JCN
POP2
INC GTHk ,&y JCN
POP2
JMP2r
@pointer-icn
80c0 e0f0 f8e0 1000
@stroke

View File

@ -0,0 +1,15 @@
X::=~_
Y::=~*
Z::=~`
_.::=._X
_*::=*_Y
._|::=.Z-|
*_|::=Z
..-::=.-.
**-::=*-.
*.-::=*-*
.*-::=.-*
@.-::=@_.
@*-::=@_*
::=
@_*...............................|

View File

@ -15,7 +15,7 @@ BRK
@print ( short* -- )
&short ( short* -- ) SWP ,&byte JSR
SWP ,&byte JSR
&byte ( byte -- ) DUP #04 SFT ,&char JSR
&char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO

View File

@ -25,8 +25,8 @@ JMP2r
@input-main ( -> )
.Console/read DEI
LIT '0 EQUk NIP ,&no JCN
LIT '1 EQUk NIP ,&yes JCN
LIT "0 EQUk NIP ,&no JCN
LIT "1 EQUk NIP ,&yes JCN
( ignore other inputs )
POP
@ -56,7 +56,7 @@ JMP2r
@pstr ( str* -- )
&while
LDAk DUP LIT '_ EQU #3f MUL SUB .Console/write DEO
LDAk DUP LIT "_ EQU #3f MUL SUB .Console/write DEO
INC2 LDAk ,&while JCN
POP2

View File

@ -4,7 +4,7 @@
|0100 ( -> ) @reset
#0000 #0001
#0000 INC2k
&loop
DUP2 ,is-prime JSR #00 EQU ,&skip JCN
( print ) DUP2 ,print/short JSR

View File

@ -30,14 +30,14 @@ BRK
.a LDZ2 #ffff EQU2 ,&input JCN
.b LDZ2 #ffff EQU2 ,&output JCN
( SUBLEQ )
.b LDZ2 STH2k ,&get JSR .a LDZ2 ,&get JSR SUB2 STH2r #10 SFT2 ;program ADD2 STA2
.b LDZ2 STH2k ,&get JSR .a LDZ2 ,&get JSR SUB2 STH2r DUP2 ADD2 ;program ADD2 STA2
( SET )
.b LDZ2 ,&get JSR #0001 SUB2 #8000 LTH2 ,&end JCN POP2 .c LDZ2 &end
JMP2r
&input ( -- ) JMP2r
&output ( -- ) .a LDZ2 ,&get JSR NIP #18 DEO JMP2r
&get ( a* -- b* ) #10 SFT2 ;program ADD2 LDA2 JMP2r
&get ( a* -- b* ) DUP2 ADD2 ;program ADD2 LDA2 JMP2r
@program ( hello world )
000f 0011 ffff 0011 ffff ffff 0010 0001

View File

@ -0,0 +1,155 @@
( thue interpreter
usage: thue.rom demo.t )
|10 @Console &vector $2 &read $1 &pad $5 &write $1
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|0000
@src $40
@ptr $2
@len $2
|0100 ( -> )
;on-console .Console/vector DEO2
BRK
@on-console ( -> )
;src STH2
( read )
.Console/read DEI
DUP #20 LTH OVR #7f GTH ORA ,&end JCN
STH2kr ;slen JSR2 #003f GTH2 ,&end JCN
STH2r ;sput JSR2 BRK
&end
POP
( parse )
STH2r .File/name DEO2
#0001 .File/length DEO2
;program .ptr STZ2
&s
;&buf .File/read DEO2
.File/success DEI2 #0000 EQU2 ,&eof JCN
[ LIT &buf $1 ] ;walk JSR2
,&s JMP
&eof
( assemble )
;program/assembly .ptr STZ2
;program
&w
( save ) DUP2 .ptr LDZ2 STA2
( incr ) .ptr LDZ2k INC2 INC2 ROT STZ2
( next ) &eos INC2 LDAk ,&eos JCN INC2
LDAk ,&w JCN
( save acc )
INC2 ;program/accumulator ;scpy JSR2
( run )
&eval ,step JSR ,&eval JCN
#010f DEO
BRK
@step ( -- done )
;program/assembly
&while
DUP2 ;run-rule JSR2 ,&found JCN
#0004 ADD2 LDA2k ORA ,&while JCN
POP2
#00
JMP2r
&found #01 JMP2r
@walk ( char -- )
.ptr LDZ2 STA
( check for left-side )
.ptr LDZ2 #0002 SUB2 ;&marker ;scmp JSR2 #01 NEQ ,&no-marker JCN
#00 .ptr LDZ2 #0002 SUB2 STA
.ptr LDZ2k #0002 SUB2 ROT STZ2
.len LDZ2k INC2 ROT STZ2
&no-marker
( check for right-side )
.ptr LDZ2 LDA #0a NEQ ,&no-lb JCN
#00 .ptr LDZ2 STA
&no-lb
.ptr LDZ2k INC2 ROT STZ2
JMP2r
&marker "::= $1
@run-rule ( rule* -- )
LDA2k ,&a STR2
INC2 INC2 LDA2 ,&b STR2
;program/accumulator
&w
[ LIT2 &a $2 ] OVR2 ;sseg JSR2 #01 NEQ ,&no-found JCN
,&b LDR2 LDA LIT "~ EQU ,&output JCN
( shift ) DUP2 [ ,&b LDR2 ;slen JSR2 ,&a LDR2 ;slen JSR2 SUB2 ] ;ssft JSR2
( write ) [ LIT2 &b $2 ] SWP2 OVR2 ;slen JSR2 ;mcpy JSR2
POP2 #01 JMP2r
&no-found
INC2 LDAk ,&w JCN
POP2
#00
JMP2r
&output
,&a LDR2 ;slen JSR2 #0000 SWP2 SUB2 ;ssft JSR2
POP2 ,&b LDR2 INC2
LDAk LIT "` NEQ ,&no-lb JCN
#0a18 DEO #01 JMP2r
&no-lb
,print-str JSR #01
JMP2r
@print-str ( str* -- )
&while
LDAk #18 DEO
INC2 LDAk ,&while JCN
POP2
JMP2r
@ssft ( str* len* -- )
STH2 DUP2k ;slen JSR2 ADD2 STH2r
DUP2 #8000 GTH2 ,&l JCN
ORAk ,&r JCN
POP2 POP2 POP2
JMP2r
&l #8000 SWP2 SUB2 #8000 ADD2 ,msfl JSR JMP2r
&r ,msfr JSR JMP2r
( stdlib )
@mcpy ( src* dst* len* -- ) SWP2 STH2 OVR2 ADD2 SWP2 &l LDAk STH2kr STA INC2r INC2 GTH2k ,&l JCN POP2 POP2 POP2r JMP2r
@msfl ( b* a* len* -- ) STH2 SWP2 EQU2k ,&e JCN &l DUP2k STH2kr ADD2 LDA ROT ROT STA INC2 GTH2k ,&l JCN POP2 POP2 &e POP2r JMP2r
@msfr ( b* a* len* -- ) STH2 EQU2k ,&e JCN &l DUP2 LDAk ROT ROT STH2kr ADD2 STA #0001 SUB2 LTH2k ,&l JCN POP2 POP2 &e POP2r JMP2r
@scap ( str* -- end* ) LDAk #00 NEQ JMP JMP2r &w INC2 LDAk ,&w JCN JMP2r
@sput ( chr str* -- ) ,scap JSR STA JMP2r
@slen ( str* -- len* ) DUP2 ,scap JSR SWP2 SUB2 JMP2r
@scpy ( src* dst* -- ) STH2 &w LDAk STH2kr STA INC2r INC2 LDAk ,&w JCN POP2 #00 STH2r STA JMP2r
@scmp ( a* b* -- f ) STH2 &l LDAk LDAkr STHr ANDk #00 EQU ,&e JCN NEQk ,&e JCN POP2 INC2 INC2r ,&l JMP &e NIP2 POP2r EQU JMP2r
@sseg ( a* b* -- f ) STH2 &l LDAk LDAkr STHr NEQ ,&e JCN INC2k LDA #00 EQU ,&e JCN INC2 INC2r ,&l JMP &e LDA LDAr STHr EQU JMP2r
$10
@program $4000
&assembly $4000
&accumulator $4000

View File

@ -13,27 +13,31 @@
#a0dc .System/r DEO2
#a0dc .System/g DEO2
#a0dc .System/b DEO2
( find screen center )
.Screen/width DEI2 #01 SFT2 .center/x STZ2
.Screen/height DEI2 #01 SFT2 .center/y STZ2
( ver )
( dashed line )
#02 .Screen/auto DEO
#0000 .Screen/y DEO2
.center/x LDZ2 .Screen/x DEO2
.Screen/height DEI2 #0000
&ver
#43 .Screen/pixel DEO
.Screen/y DEI2k INC2 ROT DEO2
DUP #01 AND .Screen/pixel DEO
INC2 GTH2k ,&ver JCN
POP2 POP2
( left )
.center/x LDZ2 .Screen/x DEO2
.center/y LDZ2 #0018 SUB2 .Screen/y DEO2
;left-txt ,draw-uf2 JSR
( center )
.center/x LDZ2 .Screen/x DEO2
.center/y LDZ2 .Screen/y DEO2
;center-txt ,draw-uf2-center JSR
( right )
.center/x LDZ2 .Screen/x DEO2
.center/y LDZ2 #0018 ADD2 .Screen/y DEO2
@ -41,23 +45,7 @@
BRK
@draw-uf2-center ( text* color -- )
DUP2 ,get-width JSR #01 SFT2 STH2
.Screen/x DEI2k STH2r SUB2 ROT DEO2
,draw-uf2 JSR
JMP2r
@draw-uf2-right ( text* color -- )
DUP2 ,get-width JSR STH2
.Screen/x DEI2k STH2r SUB2 ROT DEO2
,draw-uf2 JSR
JMP2r
@get-width ( text* -- width* )
@get-uf2-width ( text* -- width* )
LIT2r 0000
&while
@ -68,14 +56,25 @@ JMP2r
JMP2r
@draw-uf2-center ( text* -- )
DUP2 ,get-uf2-width JSR #01 SFT2 STH2
.Screen/x DEI2k STH2r SUB2 ROT DEO2
,draw-uf2 JMP
@draw-uf2-right ( text* -- )
DUP2 ,get-uf2-width JSR STH2
.Screen/x DEI2k STH2r SUB2 ROT DEO2
@draw-uf2 ( text* -- )
#15 .Screen/auto DEO
&while
LDAk #20 SUB #00 SWP
DUP2 #50 SFT2 ;font/glyphs ADD2 .Screen/addr DEO2
;font ADD2 LDA #00 SWP .Screen/x DEI2 ADD2
#01 .Screen/sprite DEOk DEO
;font ADD2 LDA STHk #00 SWP .Screen/x DEI2 ADD2
#01 .Screen/sprite DEOk STHr #08 LTH ,&thin JCN DEOk &thin POP2
.Screen/x DEO2
INC2 LDAk ,&while JCN
POP2

View File

@ -1,13 +1,8 @@
( GUI Shapes )
%2** { #10 SFT2 }
%4** { #20 SFT2 }
%2// { #01 SFT2 }
%4// { #02 SFT2 }
%ABS2 { DUP2 #0f SFT2 EQU #05 JCN #0000 SWP2 SUB2 }
%LTS2 { #8000 ADD2 SWP2 #8000 ADD2 GTH2 }
%GTS2 { #8000 ADD2 SWP2 #8000 ADD2 LTH2 }
%WIDTH { #0100 } %HEIGHT { #00a0 }
( devices )
@ -35,24 +30,24 @@
#f03c .System/g DEO2
#f03f .System/b DEO2
( background ) ;checker_icn #03 ;cover-pattern JSR2
( background ) ;checker-icn #03 ;cover-pattern JSR2
.Screen/width DEI2 2// WIDTH 2// SUB2 #0008 ADD2
.Screen/height DEI2 2// HEIGHT 2// SUB2 #0008 ADD2
.Screen/width DEI2 #01 SFT2 WIDTH #01 SFT2 SUB2 #0008 ADD2
.Screen/height DEI2 #01 SFT2 HEIGHT #01 SFT2 SUB2 #0008 ADD2
WIDTH HEIGHT
STH2 STH2 OVR2 STH2r ADD2 OVR2 STH2r ADD2 #02 ;fill-rect JSR2
.Screen/width DEI2 2// WIDTH 2// SUB2
.Screen/height DEI2 2// HEIGHT 2// SUB2
.Screen/width DEI2 #01 SFT2 WIDTH #01 SFT2 SUB2
.Screen/height DEI2 #01 SFT2 HEIGHT #01 SFT2 SUB2
WIDTH HEIGHT
STH2 STH2 OVR2 STH2r ADD2 OVR2 STH2r ADD2 #01 ;fill-rect JSR2
.Screen/width DEI2 2// WIDTH 2// SUB2 #0008 ADD2
.Screen/height DEI2 2// HEIGHT 2// SUB2 #0008 ADD2
.Screen/width DEI2 #01 SFT2 WIDTH #01 SFT2 SUB2 #0008 ADD2
.Screen/height DEI2 #01 SFT2 HEIGHT #01 SFT2 SUB2 #0008 ADD2
WIDTH #0010 SUB2 HEIGHT #0010 SUB2
STH2 STH2 OVR2 STH2r ADD2 OVR2 STH2r ADD2 #03 ;line-rect JSR2
.Screen/width DEI2 2// .Screen/height DEI2 2// WIDTH 4// #02 ;draw-circle JSR2
.Screen/width DEI2 #01 SFT2 .Screen/height DEI2 #01 SFT2 WIDTH #02 SFT2 #02 ;draw-circle JSR2
#0010 #0030 #0068 #02 ;line-hor JSR2
#0020 #0058 #0078 #02 ;line-ver JSR2
@ -64,13 +59,13 @@ BRK
( load ) .color STZ #0001 SUB2 .line/y0 STZ2 #0001 SUB2 .line/x0 STZ2 .line/y STZ2 .line/x STZ2
.line/x0 LDZ2 .line/x LDZ2 SUB2 ABS2 .line/dx STZ2
.line/y0 LDZ2 .line/y LDZ2 SUB2 ABS2 #0000 SWP2 SUB2 .line/dy STZ2
#ffff #00 .line/x LDZ2 .line/x0 LDZ2 LTS2 2** ADD2 .line/sx STZ2
#ffff #00 .line/y LDZ2 .line/y0 LDZ2 LTS2 2** ADD2 .line/sy STZ2
#ffff #00 .line/x LDZ2 .line/x0 LDZ2 LTS2 #10 SFT2 ADD2 .line/sx STZ2
#ffff #00 .line/y LDZ2 .line/y0 LDZ2 LTS2 #10 SFT2 ADD2 .line/sy STZ2
.line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
&loop
.line/x LDZ2 .Screen/x DEO2 .line/y LDZ2 .Screen/y DEO2 .color LDZ .Screen/pixel DEO
.line/x LDZ2 .line/x0 LDZ2 EQU2 .line/y LDZ2 .line/y0 LDZ2 EQU2 #0101 EQU2 ,&end JCN
.line/e1 LDZ2 2** .line/e2 STZ2
.line/x LDZ2 .line/x0 LDZ2 EQU2 .line/y LDZ2 .line/y0 LDZ2 EQU2 AND ,&end JCN
.line/e1 LDZ2 #10 SFT2 .line/e2 STZ2
.line/e2 LDZ2 .line/dy LDZ2 LTS2 ,&skipy JCN
.line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
.line/x LDZ2 .line/sx LDZ2 ADD2 .line/x STZ2
@ -136,16 +131,16 @@ JMP2r
( load ) .color STZ .circle/r STZ2 .circle/yc STZ2 .circle/xc STZ2
#0000 .circle/x STZ2 .circle/r LDZ2 .circle/y STZ2
.circle/r LDZ2 2** .circle/d STZ2
.circle/r LDZ2 #10 SFT2 .circle/d STZ2
( draw ) ;&seg JSR2
&loop
( incr ) .circle/x LDZ2 INC2 .circle/x STZ2
.circle/d LDZ2 #0001 LTS2 ,&else JCN
( decr ) .circle/y LDZ2 #0001 SUB2 .circle/y STZ2
.circle/x LDZ2 .circle/y LDZ2 SUB2 4** .circle/d LDZ2 ADD2 .circle/d STZ2
.circle/x LDZ2 .circle/y LDZ2 SUB2 #20 SFT2 .circle/d LDZ2 ADD2 .circle/d STZ2
;&end JMP2
&else
.circle/x LDZ2 4** .circle/d LDZ2 ADD2 .circle/d STZ2
.circle/x LDZ2 #20 SFT2 .circle/d LDZ2 ADD2 .circle/d STZ2
&end
( draw ) ;&seg JSR2
.circle/y LDZ2 .circle/x LDZ2 #0001 SUB2 GTS2 ,&loop JCN
@ -204,4 +199,5 @@ JMP2r
JMP2r
@checker_icn [ f0f0 f0f0 0f0f 0f0f ]
@checker-icn
f0f0 f0f0 0f0f 0f0f

View File

@ -34,7 +34,7 @@ BRK
@on-button ( -> )
.Controller/key DEI
DUP #00 NEQ ,&no-null JCN
DUP ,&no-null JCN
POP BRK
&no-null
DUP #0d NEQ ,&no-enter JCN
@ -75,7 +75,7 @@ BRK
LIT 22 #02 ;draw-char JSR2
;buffer #03 ;draw-str JSR2
LIT 22 #02 ;draw-char JSR2
LIT '. #02 ;draw-char JSR2
LIT ". #02 ;draw-char JSR2
JMP2r
@ -85,7 +85,7 @@ JMP2r
#0010 .Screen/x DEO2
.Screen/height DEI2 #0020 SUB2 .Screen/y DEO2
( marker ) LIT '> #03 ;draw-char JSR2
( marker ) LIT "> #03 ;draw-char JSR2
;buffer STHr ;draw-str JSR2

View File

@ -137,8 +137,8 @@
DUP2 ,asma-print-labels JSR
( here )
DUP2 #0004 ADD2
LDAk LIT 'A LTH ,&loop JCN
LDAk LIT 'Z GTH ,&loop JCN
LDAk LIT "A LTH ,&loop JCN
LDAk LIT "Z GTH ,&loop JCN
POP2
,&skip-device-label JMP
&loop
@ -169,8 +169,8 @@
,asma-print-string JMP
@asma-print-short ( short* -- )
LIT '0 .Console/error DEO
LIT 'x .Console/error DEO
LIT "0 .Console/error DEO
LIT "x .Console/error DEO
OVR #04 SFT ,&hex JSR
SWP #0f AND ,&hex JSR
DUP #04 SFT ,&hex JSR
@ -210,9 +210,9 @@
JMP2r
&preamble
"%BRK 20 '{ 20 "00 20 '} 20
"%[ 20 '{ 20 '} 20
"%] 20 '{ 20 '} 20
"%BRK 20 "{ 20 "00 20 "} 20
"%[ 20 "{ 20 "} 20
"%] 20 "{ 20 "} 20
"@on-reset 20
&preamble-end
@ -496,15 +496,15 @@
JMP2r
&not-end
DUP LIT '2 NEQ ,&not-two JCN
DUP LIT "2 NEQ ,&not-two JCN
POP LIT &short-flag $1 ORA ,&loop JMP
&not-two
DUP LIT 'r NEQ ,&not-return JCN
DUP LIT "r NEQ ,&not-return JCN
POP LIT &return-flag $1 ORA ,&loop JMP
&not-return
LIT 'k NEQ ,&not-keep JCN
LIT "k NEQ ,&not-keep JCN
&set-keep LIT &keep-flag $1 ORA ,&loop JMP
&not-keep ( 00 byte / end* )
@ -947,33 +947,33 @@
than than string data )
@asma-first-char-comment
&28 $2 $2 '( 00 :asma-comment-more
&_entry :&28 $2 ') 00 :asma-comment-less
&28 $2 $2 "( 00 :asma-comment-more
&_entry :&28 $2 ") 00 :asma-comment-less
@asma-first-char-macro
&28 $2 $2 '( 00 :asma-comment-start
&29 :&28 $2 ') 00 :asma-comment-end
&_entry :&29 :&7d '{ 00 :asma-ignore
&7d $2 $2 '} 00 :asma-macro-end
&28 $2 $2 "( 00 :asma-comment-start
&29 :&28 $2 ") 00 :asma-comment-end
&_entry :&29 :&7d "{ 00 :asma-ignore
&7d $2 $2 "} 00 :asma-macro-end
@asma-first-char-normal
&22 $2 $2 '" 00 :asma-raw-word
&23 :&22 $2 '# 00 :asma-literal-hex
&24 :&23 :&25 '$ 00 :asma-pad-relative
&25 $2 $2 '% 00 :asma-macro-define
&22 $2 $2 "" 00 :asma-raw-word
&23 :&22 $2 "# 00 :asma-literal-hex
&24 :&23 :&25 "$ 00 :asma-pad-relative
&25 $2 $2 "% 00 :asma-macro-define
&26 :&24 :&29 26 00 ( & ) :asma-sublabel-define
&27 $2 $2 '' 00 :asma-raw-char
&28 :&27 $2 '( 00 :asma-comment-start
&29 :&28 :&2c ') 00 :asma-comment-end
&2c $2 $2 ', 00 :asma-literal-rel-addr
&_entry :&26 :&7b '. 00 :asma-literal-zero-addr
&3a $2 $2 ': 00 :asma-abs-addr
&3b :&3a :&40 '; 00 :asma-literal-abs-addr
&40 $2 $2 '@ 00 :asma-label-define
&7b :&3b :&7d '{ 00 :asma-ignore
&7c $2 $2 '| 00 :asma-pad-absolute
&7d :&7c :&7e '} 00 :asma-ignore
&7e $2 $2 '~ 00 :asma-include
&27 $2 $2 "' 00 :asma-raw-char
&28 :&27 $2 "( 00 :asma-comment-start
&29 :&28 :&2c ") 00 :asma-comment-end
&2c $2 $2 ", 00 :asma-literal-rel-addr
&_entry :&26 :&7b ". 00 :asma-literal-zero-addr
&3a $2 $2 ": 00 :asma-abs-addr
&3b :&3a :&40 "; 00 :asma-literal-abs-addr
&40 $2 $2 "@ 00 :asma-label-define
&7b :&3b :&7d "{ 00 :asma-ignore
&7c $2 $2 "| 00 :asma-pad-absolute
&7d :&7c :&7e "} 00 :asma-ignore
&7e $2 $2 "~ 00 :asma-include
@asma-opcodes
&_entry :&GTH :&ROT &_disasm "LIT 00

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -69,15 +69,15 @@ BRK
[ #1b ] NEQk NIP ,&no-esc JCN ;do-pop JSR2 POP BRK &no-esc
[ #08 ] NEQk NIP ,&no-backspace JCN ;do-erase JSR2 POP BRK &no-backspace
( arithmetic )
[ LIT '+ ] NEQk NIP ,&no-add JCN ;do-add JSR2 POP BRK &no-add
[ LIT '- ] NEQk NIP ,&no-sub JCN ;do-sub JSR2 POP BRK &no-sub
[ LIT '* ] NEQk NIP ,&no-mul JCN ;do-mul JSR2 POP BRK &no-mul
[ LIT '/ ] NEQk NIP ,&no-div JCN ;do-div JSR2 POP BRK &no-div
[ LIT "+ ] NEQk NIP ,&no-add JCN ;do-add JSR2 POP BRK &no-add
[ LIT "- ] NEQk NIP ,&no-sub JCN ;do-sub JSR2 POP BRK &no-sub
[ LIT "* ] NEQk NIP ,&no-mul JCN ;do-mul JSR2 POP BRK &no-mul
[ LIT "/ ] NEQk NIP ,&no-div JCN ;do-div JSR2 POP BRK &no-div
( bitwise )
[ LIT '& ] NEQk NIP ,&no-and JCN ;do-and JSR2 POP BRK &no-and
[ LIT '| ] NEQk NIP ,&no-ora JCN ;do-ora JSR2 POP BRK &no-ora
[ LIT '^ ] NEQk NIP ,&no-eor JCN ;do-eor JSR2 POP BRK &no-eor
[ LIT '~ ] NEQk NIP ,&no-not JCN ;do-not JSR2 POP BRK &no-not
[ LIT "& ] NEQk NIP ,&no-and JCN ;do-and JSR2 POP BRK &no-and
[ LIT "| ] NEQk NIP ,&no-ora JCN ;do-ora JSR2 POP BRK &no-ora
[ LIT "^ ] NEQk NIP ,&no-eor JCN ;do-eor JSR2 POP BRK &no-eor
[ LIT "~ ] NEQk NIP ,&no-not JCN ;do-not JSR2 POP BRK &no-not
( value )
;key-value JSR2 ;push-input JSR2
@ -131,7 +131,7 @@ BRK
( y ) .modpad-frame/y LDZ2 SUB2 #24 SFT2 NIP STH
( x ) .modpad-frame/x LDZ2 SUB2 #04 SFT2
( lookup ) STHr ADD #10 SFT2 ;keypad/ops ADD2 LDA2 JSR2
( lookup ) STHr ADD DUP2 ADD2 ;keypad/ops ADD2 LDA2 JSR2
;draw-bitpad JSR2
#00 .Mouse/state DEO POP2
@ -141,7 +141,7 @@ BRK
POP2
.input-frame/x LDZ2 SUB2 #03 SFT2 NIP
DUP #00 NEQ ,&no-push JCN
DUP ,&no-push JCN
;do-push JSR2 &no-push
DUP #01 NEQ ,&no-pop JCN
;do-pop JSR2 &no-pop
@ -183,7 +183,7 @@ JMP2r
@push ( value* -- )
( store ) .stack/length LDZ #10 SFT .stack/items ADD STZ2
( store ) .stack/length LDZ DUP ADD .stack/items ADD STZ2
( INCZ ) .stack/length LDZk INC SWP STZ
( reset ) #0000 .input/value STZ2
#00 ;draw-input JSR2
@ -193,8 +193,8 @@ JMP2r
@pop ( -- value* )
.stack/length LDZ #01 SUB #10 SFT .stack/items ADD LDZ2
( clear ) #0000 [ .stack/length LDZ #01 SUB #10 SFT .stack/items ADD ] STZ2
.stack/length LDZ #01 SUB DUP ADD .stack/items ADD LDZ2
( clear ) #0000 [ .stack/length LDZ #01 SUB DUP ADD .stack/items ADD ] STZ2
( DECZ ) .stack/length LDZk #01 SUB SWP STZ
#01 ;draw-input JSR2
;draw-stack JSR2
@ -396,7 +396,7 @@ JMP2r
.input-frame/x LDZ2 #0018 ADD2 .Screen/x DEO2
#00 OVR #30 SFT2 .input-frame/y LDZ2 ADD2 #004c SUB2 .Screen/y DEO2
( color ) DUP #08 .stack/length LDZ SUB #01 SUB GTH STH
( value ) DUP #10 SFT .stack/items ADD [ #10 .stack/length LDZ #10 SFT SUB SUB ] LDZ2
( value ) DUP DUP ADD .stack/items ADD [ #10 .stack/length LDZ DUP ADD SUB SUB ] LDZ2
STHr ;draw-number JSR2
INC GTHk ,&loop JCN
POP2

View File

@ -47,7 +47,7 @@
#006c ADD2 .time/y STZ2
;draw-watchface JSR2
( time buffer )
LIT ':
LIT ":
DUP .buf/s1 STZ
.buf/s2 STZ
@ -121,8 +121,8 @@ JMP2r
DUP ;is-lc JSR2 ,&lc JCN
DUP ;is-uc JSR2 ,&uc JCN
DUP ;is-num JSR2 ,&num JCN
DUP LIT '/ EQU ,&slash JCN
DUP LIT ': EQU ,&colon JCN
DUP LIT "/ EQU ,&slash JCN
DUP LIT ": EQU ,&colon JCN
POP ;font/blank
&end
.Screen/addr DEO2
@ -144,15 +144,15 @@ JMP2r
( load ) STH ,&y STR2 ,&x STR2 .line/y STZ2 .line/x STZ2
,&x LDR2 .line/x LDZ2 SUB2 ;abs2 JSR2 .line/dx STZ2
#0000 ,&y LDR2 .line/y LDZ2 SUB2 ;abs2 JSR2 SUB2 .line/dy STZ2
#ffff #00 .line/x LDZ2 ,&x LDR2 ;lts2 JSR2 #10 SFT2 ADD2 ,&sx STR2
#ffff #00 .line/y LDZ2 ,&y LDR2 ;lts2 JSR2 #10 SFT2 ADD2 ,&sy STR2
#ffff #00 .line/x LDZ2 ,&x LDR2 ;lts2 JSR2 DUP2 ADD2 ADD2 ,&sx STR2
#ffff #00 .line/y LDZ2 ,&y LDR2 ;lts2 JSR2 DUP2 ADD2 ADD2 ,&sy STR2
.line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
&loop
.line/x LDZ2 DUP2 .Screen/x DEO2 [ LIT2 &x $2 ] EQU2
.line/y LDZ2 DUP2 .Screen/y DEO2 [ LIT2 &y $2 ] EQU2
STHkr .Screen/pixel DEO
AND ,&end JCN
.line/e1 LDZ2 #10 SFT2 DUP2
.line/e1 LDZ2 DUP2 ADD2 DUP2
.line/dy LDZ2 ;lts2 JSR2 ,&skipy JCN
.line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
.line/x LDZ2 [ LIT2 &sx $2 ] ADD2 .line/x STZ2
@ -172,12 +172,12 @@ JMP2r
#3c00
&loop
( dots )
#00 OVR #10 SFT2 ;table ADD2 LDA2
#00 OVRk ADD2 ;table ADD2 LDA2
#0018 ;circle JSR2
.Screen/x DEO2 .Screen/y DEO2 #01 .Screen/pixel DEO
( markers )
DUP #05 ;mod JSR2 ,&no-marker JCN
#00 OVR #10 SFT2 ;table ADD2 LDA2
#00 OVRk ADD2 ;table ADD2 LDA2
STH2k #0018 ;circle JSR2 SWP2
STH2r #001c ;circle JSR2 SWP2
#01 ;draw-line JSR2
@ -189,14 +189,14 @@ JMP2r
@make-needles ( -- )
[ #00 .DateTime/second DEI #1e ADD #3c ;mod JSR2 ] #10 SFT2 ;table ADD2 LDA2
[ #00 .DateTime/second DEI #1e ADD #3c ;mod JSR2 ] DUP2 ADD2 ;table ADD2 LDA2
#00a0 ,circle JSR .needles/zx STZ2 .needles/zy STZ2
[ #00 .DateTime/second DEI ] #10 SFT2 ;table ADD2 LDA2
[ #00 .DateTime/second DEI ] DUP2 ADD2 ;table ADD2 LDA2
#0020 ,circle JSR .needles/sx STZ2 .needles/sy STZ2
[ #00 .DateTime/minute DEI ] #10 SFT2 ;table ADD2 LDA2
[ #00 .DateTime/minute DEI ] DUP2 ADD2 ;table ADD2 LDA2
#0022 ,circle JSR .needles/mx STZ2 .needles/my STZ2
[ #00 .DateTime/hour DEI #0c ;mod JSR2 #20 SFTk NIP ADD ]
( minute offset ) [ #00 .DateTime/minute DEI #0f DIV ADD2 ] #10 SFT2 ;table ADD2 LDA2
( minute offset ) [ #00 .DateTime/minute DEI #0f DIV ADD2 ] DUP2 ADD2 ;table ADD2 LDA2
#002a ,circle JSR .needles/hx STZ2 .needles/hy STZ2
JMP2r
@ -219,7 +219,7 @@ JMP2r
JMP2r
@mod DUP2 DIV MUL SUB JMP2r
@mod DIVk MUL SUB JMP2r
@abs2 DUP2 #0f SFT2 EQU #05 JCN #0000 SWP2 SUB2 JMP2r
@lts2 #8000 STH2k ADD2 SWP2 STH2r ADD2 GTH2 JMP2r
@gts2 #8000 STH2k ADD2 SWP2 STH2r ADD2 LTH2 JMP2r

View File

@ -1,705 +0,0 @@
( UXN-DOS )
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%HALT { #010f DEO }
%EMIT { #18 DEO }
%PRINT { ;print-str JSR2 #0a EMIT }
%DEBUG { ;print-hex/byte JSR2 #0a EMIT }
%DEBUG2 { ;print-hex JSR2 #0a EMIT }
%2* { #10 SFT } %2/ { #01 SFT } %2** { #10 SFT2 } %2// { #01 SFT2 }
%4* { #20 SFT } %4/ { #02 SFT } %4** { #20 SFT2 } %4// { #02 SFT2 }
%8* { #30 SFT } %8/ { #03 SFT } %8** { #30 SFT2 } %8// { #03 SFT2 }
%10* { #40 SFT } %10/ { #04 SFT } %10** { #40 SFT2 } %10// { #04 SFT2 }
%20* { #50 SFT } %20/ { #05 SFT } %20** { #50 SFT2 } %20// { #05 SFT2 }
%2MOD { #01 AND } %2MOD2 { #0001 AND2 }
%4MOD { #03 AND } %4MOD2 { #0003 AND2 }
%8MOD { #07 AND } %8MOD2 { #0007 AND2 }
%10MOD { #0f AND } %10MOD2 { #000f AND2 }
%MOD { DIVk MUL SUB }
%MOD2 { DIV2k MUL2 SUB2 }
%AUTO-X { #01 .Screen/auto DEO }
%AUTO-Y { #02 .Screen/auto DEO }
%AUTO-XY { #03 .Screen/auto DEO }
%AUTO-ADDR { #04 .Screen/auto DEO }
%AUTO-XADDR { #05 .Screen/auto DEO }
%AUTO-YADDR { #06 .Screen/auto DEO }
%AUTO-XYADDR { #07 .Screen/auto DEO }
%RELEASE-MOUSE { #0096 DEO }
%RTN { JMP2r }
%WIDTH { #38 }
%HEIGHT { #20 }
%PAD { #0018 }
( devices )
|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|80 @Controller &vector $2 &button $1 &key $1
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|c0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
( variables )
|0000
@buffer $3
&input $80
@path $40
@frame $1
( init )
|0100 ( -> )
( theme )
#50f8 .System/r DEO2
#c0f8 .System/g DEO2
#a0f8 .System/b DEO2
( vectors )
;on-button .Controller/vector DEO2
( resize )
#00 WIDTH 8** PAD 2** ++ .Screen/width DEO2
#00 HEIGHT 8** PAD 2** ++ .Screen/height DEO2
#04 ;draw-input JSR2
LIT '. .path STZ
;clear JSR2
BRK
@on-button ( -> )
.Controller/key DEI
DUP #00 ! ,&no-null JCN
POP BRK
&no-null
DUP #0d ! ,&no-enter JCN
#00 ;draw-input JSR2
;validate JSR2
#01 ;draw-input JSR2
.frame LDZk INC SWP STZ
&no-enter
DUP #08 ! ,&no-backspace JCN
#00 ;draw-input JSR2
;buffer ;spop JSR2
#04 ;draw-input JSR2
.frame LDZk INC SWP STZ
&no-backspace
DUP STHk #1f > STHr #7b < #0101 !! ,&no-valid JCN
;buffer ;slen JSR2 #007f >> ,&no-valid JCN
STHk ;buffer STHr ;sput JSR2
#04 ;draw-input JSR2
.frame LDZk INC SWP STZ
&no-valid
POP
BRK
@clear ( -- )
PAD .Screen/x DEO2
PAD .Screen/y DEO2
;&blank-icn .Screen/addr DEO2
AUTO-X
HEIGHT #00
&ver
WIDTH #00
&hor
#02 .Screen/sprite DEO
INC GTHk ,&hor JCN
POP2
PAD .Screen/x DEO2
.Screen/y DEI2k #0008 ++ ROT DEO2
INC GTHk ,&ver JCN
POP2
#00 .Screen/auto DEO
RTN
&blank-icn 8000 0000 0000 0000
( DOS )
@validate ( -- )
;clear JSR2
PAD .Screen/x DEO2
PAD .Screen/y DEO2
;get-cmd JSR2 ;commands-func ++ LDA2 JSR2
;buffer #0080 ;mclr JSR2
JMP2r
@get-cmd ( -- cmd* )
;commands/end ;commands
&loop
LDA2k ;buffer ;scmp-seg JSR2 #00 = ,&continue JCN
NIP2 ;commands -- RTN
&continue
INC2 INC2 GTH2k ,&loop JCN
POP2 ;commands --
RTN
@cmd-ls "ls $1 &docs "list 20 "folder 20 "content $1 &func
( load )
;path .File/name DEO2
#8000 .File/length DEO2
;view .File/read DEO2
;view #01 ;draw-tx JSR2
RTN
@cmd-mk "mk $1 &docs "make 20 "file $1 &func
;buffer/input ;file-exists JSR2 #01 ! ,&no-exists JCN
;error-exists-txt ;buffer/input ;draw-message JSR2 RTN
&no-exists
( save )
;buffer/input .File/name DEO2
#0001 .File/length DEO2
;&buf .File/write DEO2
( message )
;make-success-txt ;buffer/input ;draw-message JSR2
RTN
&buf 0a
@cmd-cp "cp $1 &docs "copy 20 "file 20 "to 20 "name $1 &func
( b ) ;buffer/input #20 ;next-char JSR2 STH2k INC2
#00 STH2r STA
( a ) ;buffer/input
( a exists )
;buffer/input ;file-exists JSR2 ,&valid JCN
;error-unexists-txt ;buffer/input ;draw-message JSR2 POP2 POP2 RTN
&valid
( b unexists )
OVR2 ;file-exists JSR2 #00 = ,&available JCN
OVR2 ;error-exists-txt SWP2 ;draw-message JSR2 POP2 POP2 RTN
&available
( load )
.File/name DEO2
#8000 .File/length DEO2
;view .File/read DEO2
( save )
DUP2 .File/name DEO2
#8000 .File/length DEO2
;view .File/write DEO2
( message )
;copy-success-txt SWP2 ;draw-message JSR2
RTN
@cmd-mv "mv $1 &docs "move 20 "file 20 "to 20 "name $1
&func
( todo )
RTN
@cmd-rm "rm $1 &docs "remove 20 "file $1
&func
( exists )
;buffer/input ;file-exists JSR2 ,&valid JCN
;error-unexists-txt ;buffer/input ;draw-message JSR2 RTN
&valid
( delete )
;buffer/input .File/name DEO2
#01 .File/delete DEO
( message )
;remove-success-txt ;buffer/input ;draw-message JSR2
RTN
@cmd-tx "tx $1 &docs "display 20 "file 20 "as 20 "text $1
&func
( exists )
;buffer/input ;file-exists JSR2 ,&valid JCN
;error-unexists-txt ;buffer/input ;draw-message JSR2 RTN
&valid
( load )
;buffer/input .File/name DEO2
#8000 .File/length DEO2
;view .File/read DEO2
( message )
;view #01 ;draw-tx JSR2
RTN
@cmd-hx "hx $1 &docs "display 20 "file 20 "as 20 "hex $1
&func
( exists )
;buffer/input ;file-exists JSR2 ,&valid JCN
;error-unexists-txt ;buffer/input ;draw-message JSR2 RTN
&valid
( load )
;buffer/input .File/name DEO2
#8000 .File/length DEO2
;view .File/read DEO2
( message )
AUTO-YADDR
.File/success DEI2 #0000
&loop
DUP2 ;view ++ LDA #01 ;draw-hex JSR2
( make shorts )
DUP2 #0001 AND2 #0000 == ,&no-short JCN
.Screen/x DEI2k #0008 ++ ROT DEO2
&no-short
( make lines )
DUP2 #000f AND2 #000f !! ,&no-lines JCN
.Screen/y DEI2k #0010 ++ ROT DEO2
PAD .Screen/x DEO2
.Screen/y DEI2 .Screen/height DEI2 PAD -- #0010 -- >> ,&end JCN
&no-lines
INC2 GTH2k ,&loop JCN
&end
POP2 POP2
RTN
@cmd-do "do $1 &docs "run 20 "file 20 "as 20 "rom $1
&func
( release inputs )
#0000 .Controller/button DEO2
;buffer/input
DUP2 ;check-rom JSR2 ,&valid JCN
PAD .Screen/x DEO2
PAD .Screen/y DEO2
;&invalid-txt #02 ;draw-str JSR2
#01 ;draw-str JSR2
RTN
&valid
;load-rom JSR2
RTN
&invalid-txt "invalid 20 "rom: $1
@cmd-tm "tm $1 &docs "display 20 "time $1
&func
#00 .DateTime/month DEI 4* ;month-txt ++ #01 ;draw-str JSR2
#20 #01 ;draw-char JSR2
.DateTime/day DEI #01 ;draw-dec JSR2
#20 #01 ;draw-char JSR2
#00 .DateTime/dotw DEI 4* ;week-txt ++ #01 ;draw-str JSR2
#20 #01 ;draw-char JSR2
.DateTime/hour DEI #01 ;draw-dec JSR2
LIT ': #01 ;draw-char JSR2
.DateTime/minute DEI #01 ;draw-dec JSR2
LIT ': #01 ;draw-char JSR2
.DateTime/second DEI #01 ;draw-dec JSR2
RTN
@cmd-1b "1b $1 &docs "display 20 "1bit 20 "file $1
&func
( todo )
RTN
@cmd-2b "2b $1 &docs "display 20 "2bit 20 "file $1
&func
( todo )
RTN
@cmd-sn "sn $1 &docs "play 20 "sound 20 "file $1
&func
( todo )
RTN
@cmd-?? "-- $1 &docs "display 20 "commands $1
&func
;&help-txt #01 ;draw-tx JSR2
PAD #0010 ++ .Screen/y DEO2
;commands/end ;commands
&loop
PAD .Screen/x DEO2
( name ) LDA2k #04 ;draw-str JSR2
PAD #0020 ++ .Screen/x DEO2
( docs ) DUP2 ;commands -- ;commands-docs ++ LDA2 #01 ;draw-str JSR2
.Screen/y DEI2k #0010 ++ ROT DEO2
INC2 INC2 GTH2k ,&loop JCN
POP2 POP2
RTN
&help-txt "Commands: $1
@commands
:cmd-ls :cmd-mk :cmd-cp :cmd-mv :cmd-rm
:cmd-hx :cmd-tx :cmd-do :cmd-tm
:cmd-1b :cmd-2b :cmd-sn
&end :cmd-??
@commands-docs
:cmd-ls/docs :cmd-mk/docs :cmd-cp/docs :cmd-mv/docs :cmd-rm/docs
:cmd-hx/docs :cmd-tx/docs :cmd-do/docs :cmd-tm/docs
:cmd-1b/docs :cmd-2b/docs :cmd-sn/docs
&end :cmd-??/docs
@commands-func
:cmd-ls/func :cmd-mk/func :cmd-cp/func :cmd-mv/func :cmd-rm/func
:cmd-hx/func :cmd-tx/func :cmd-do/func :cmd-tm/func
:cmd-1b/func :cmd-2b/func :cmd-sn/func
&end :cmd-??/func
@file-exists ( name* -- bool )
.File/name DEO2
#0040 .File/length DEO2
;&buf .File/stat DEO2
.File/success DEI2 #0000 >>
RTN
&buf $40
( gui )
@draw-input ( color -- )
AUTO-YADDR
STH
PAD .Screen/x DEO2
.Screen/height DEI2 PAD -- .Screen/y DEO2
( flower )
;flowers-icn #00 .frame LDZ #06 MOD 20** ++ .Screen/addr DEO2
#81 .Screen/sprite DEOk DEO
.Screen/y DEI2 #0010 -- .Screen/y DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
#20 #00 ;draw-char JSR2
;buffer STHkr ;draw-str JSR2
;cursor-icn .Screen/addr DEO2
STHr .Screen/sprite DEOk DEO
.Screen/y DEI2 #0010 -- .Screen/y DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
JMP2r
@draw-message ( a* b* -- )
SWP2 #02 ;draw-str JSR2
#01 ;draw-str JSR2
RTN
@draw-tx ( str* color -- )
AUTO-YADDR
.Screen/x DEI2 ,&anchor STR2
STH
&while
( outside view )
.Screen/x DEI2 .Screen/width DEI2 PAD -- #0010 -- >> ,&lb JCN
( linebreak )
LDAk #0a ! ,&no-lb JCN
&lb
LIT2 &anchor $2 .Screen/x DEO2
.Screen/y DEI2k #0010 ++ STH2k ROT DEO2
STH2r .Screen/height DEI2 PAD -- #0010 -- >> ,&end JCN
,&skip JMP
&no-lb
LDAk STHkr ,draw-char JSR
&skip
INC2 LDAk ,&while JCN
&end
POP2
POPr
RTN
@draw-dec ( byte color -- )
STH
DUP #0a DIV LIT '0 + STHkr ,draw-char JSR
#0a MOD LIT '0 + STHr ,draw-char JSR
RTN
@draw-hex ( byte color -- )
STH
DUP #04 SFT ,&parse JSR STHkr ,draw-char JSR
#0f AND ,&parse JSR STHr ,draw-char JSR
RTN
&parse ( value -- char )
DUP #09 > ,&above JCN
#30 + RTN
&above
#09 - #60 + RTN
RTN
@draw-str ( str* color -- )
AUTO-YADDR
STH
&while
LDAk STHkr ,draw-char JSR
INC2 LDAk ,&while JCN
POP2
POPr
RTN
@draw-char ( char color -- )
SWP
[ #20 - #00 SWP #40 SFT2 ;font ++ ] .Screen/addr DEO2
.Screen/sprite DEOk DEO
.Screen/y DEI2 #0010 -- .Screen/y DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
RTN
( utils )
@next-char ( addr* char -- addr* )
STH
&while
LDAk STHkr = ,&end JCN
LDAk #00 = ,&end JCN
INC2 LDAk ,&while JCN
&end
POPr
RTN
@slen ( str* -- len* )
DUP2 ,scap JSR SWP2 --
RTN
@scap ( str* -- str-end* )
( clamp ) LDAk #00 ! JMP RTN
&while INC2 LDAk ,&while JCN
RTN
@sput ( str* char -- )
ROT ROT ,scap JSR STA
RTN
@spop ( str* -- )
( clamp ) LDAk #00 ! JMP RTN
#00 ROT ROT ,scap JSR #0001 -- STA
RTN
@scmp-seg ( a* b* -- flag )
STH2
&loop
LDAk LDAkr STHr = ,&not-diff JCN
POP2 POP2r #00 RTN
&not-diff
INC2k LDA #00 ! ,&continue JCN
POP2 POP2r #01 RTN
&continue
INC2 INC2r
,&loop JMP
POP2 POP2r #00
RTN
@mclr ( addr* len* -- )
OVR2 ++ SWP2
&loop
STH2k #00 STH2r STA
INC2 GTH2k ,&loop JCN
POP2 POP2
JMP2r
@print-hex ( value* -- )
SWP ,&byte JSR
&byte ( byte -- )
STHk #04 SFT ,&parse JSR #18 DEO
STHr #0f AND ,&parse JSR #18 DEO
JMP2r
&parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD JMP2r
&above #57 ADD JMP2r
JMP2r
@print-str ( string* -- )
#0001 SUB2
&while
INC2 LDAk DUP #18 DEO ,&while JCN
POP2
JMP2r
@error-exists-txt "file_exists: 20 $1
@error-unexists-txt "file_does_not_exists: 20 $1
@make-success-txt "made: 20 $1
@copy-success-txt "copied: 20 $1
@remove-success-txt "removed: 20 $1
@week-txt
"Sun $1 "Mon $1 "Tue $1 "Wed $1 "Thu $1 "Fri $1
"Sat $1
@month-txt
"Jan $1 "Feb $1 "Mar $1 "Apr $1 "May $1 "Jun $1
"Jul $1 "Aug $1 "Sep $1 "Oct $1 "Nov $1 "Dec $1
@cursor-icn
aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55
aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55
@flowers-icn ( by elioat )
0000 0020 1408 0810 40a0 4205 0200 40a0
0810 103c 7e7e 3c18 4205 0234 7e7e 3c18
0000 0020 100c 0818 0040 a042 0522 5024
0008 083c 7e7e 3c18 0a04 002c 7e7e 3c18
0000 0000 0000 000c 0000 0000 0000 0000
1c10 083c 7e7e 3c18 0000 002c 7e7e 3c18
0000 0000 0000 0004 0000 0000 0002 0502
0810 103c 7e7e 3c18 0000 0034 7e7e 3c18
0000 0000 0000 0010 0000 0000 0020 5225
080c 083c 7e7e 3c18 0200 002c 7e7e 3c18
0000 0000 0800 1800 0000 040a 2450 240a
1010 103c 7e7e 3c18 0400 0034 7e7e 3c18
@font ( terminus01x02 )
0000 0000 0000 0000 0000 0000 0000 0000
0000 183c 3c3c 1818 1800 1818 0000 0000
0066 6666 2400 0000 0000 0000 0000 0000
0000 006c 6cfe 6c6c 6cfe 6c6c 0000 0000
1818 7cc6 c2c0 7c06 0686 c67c 1818 0000
0000 0000 c2c6 0c18 3060 c686 0000 0000
0000 386c 6c38 76dc cccc cc76 0000 0000
0030 3030 6000 0000 0000 0000 0000 0000
0000 0c18 3030 3030 3030 180c 0000 0000
0000 3018 0c0c 0c0c 0c0c 1830 0000 0000
0000 0000 0066 3cff 3c66 0000 0000 0000
0000 0000 0018 187e 1818 0000 0000 0000
0000 0000 0000 0000 0018 1818 3000 0000
0000 0000 0000 00fe 0000 0000 0000 0000
0000 0000 0000 0000 0000 1818 0000 0000
0000 0000 0206 0c18 3060 c080 0000 0000
0000 386c c6c6 d6d6 c6c6 6c38 0000 0000
0000 1838 7818 1818 1818 187e 0000 0000
0000 7cc6 060c 1830 60c0 c6fe 0000 0000
0000 7cc6 0606 3c06 0606 c67c 0000 0000
0000 0c1c 3c6c ccfe 0c0c 0c1e 0000 0000
0000 fec0 c0c0 fc06 0606 c67c 0000 0000
0000 3860 c0c0 fcc6 c6c6 c67c 0000 0000
0000 fec6 0606 0c18 3030 3030 0000 0000
0000 7cc6 c6c6 7cc6 c6c6 c67c 0000 0000
0000 7cc6 c6c6 7e06 0606 0c78 0000 0000
0000 0000 1818 0000 0018 1800 0000 0000
0000 0000 1818 0000 0018 1830 0000 0000
0000 0006 0c18 3060 3018 0c06 0000 0000
0000 0000 007e 0000 7e00 0000 0000 0000
0000 0060 3018 0c06 0c18 3060 0000 0000
0000 7cc6 c60c 1818 1800 1818 0000 0000
0000 007c c6c6 dede dedc c07c 0000 0000
0000 1038 6cc6 c6fe c6c6 c6c6 0000 0000
0000 fc66 6666 7c66 6666 66fc 0000 0000
0000 3c66 c2c0 c0c0 c0c2 663c 0000 0000
0000 f86c 6666 6666 6666 6cf8 0000 0000
0000 fe66 6268 7868 6062 66fe 0000 0000
0000 fe66 6268 7868 6060 60f0 0000 0000
0000 3c66 c2c0 c0de c6c6 663a 0000 0000
0000 c6c6 c6c6 fec6 c6c6 c6c6 0000 0000
0000 3c18 1818 1818 1818 183c 0000 0000
0000 1e0c 0c0c 0c0c cccc cc78 0000 0000
0000 e666 666c 7878 6c66 66e6 0000 0000
0000 f060 6060 6060 6062 66fe 0000 0000
0000 c6ee fefe d6c6 c6c6 c6c6 0000 0000
0000 c6e6 f6fe dece c6c6 c6c6 0000 0000
0000 7cc6 c6c6 c6c6 c6c6 c67c 0000 0000
0000 fc66 6666 7c60 6060 60f0 0000 0000
0000 7cc6 c6c6 c6c6 c6d6 de7c 0c0e 0000
0000 fc66 6666 7c6c 6666 66e6 0000 0000
0000 7cc6 c660 380c 06c6 c67c 0000 0000
0000 7e7e 5a18 1818 1818 183c 0000 0000
0000 c6c6 c6c6 c6c6 c6c6 c67c 0000 0000
0000 c6c6 c6c6 c6c6 c66c 3810 0000 0000
0000 c6c6 c6c6 d6d6 d6fe ee6c 0000 0000
0000 c6c6 6c7c 3838 7c6c c6c6 0000 0000
0000 6666 6666 3c18 1818 183c 0000 0000
0000 fec6 860c 1830 60c2 c6fe 0000 0000
0000 3c30 3030 3030 3030 303c 0000 0000
0000 0080 c0e0 7038 1c0e 0602 0000 0000
0000 3c0c 0c0c 0c0c 0c0c 0c3c 0000 0000
1038 6cc6 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 00ff 0000
3030 1800 0000 0000 0000 0000 0000 0000
0000 0000 0078 0c7c cccc cc76 0000 0000
0000 e060 6078 6c66 6666 667c 0000 0000
0000 0000 007c c6c0 c0c0 c67c 0000 0000
0000 1c0c 0c3c 6ccc cccc cc76 0000 0000
0000 0000 007c c6fe c0c0 c67c 0000 0000
0000 386c 6460 f060 6060 60f0 0000 0000
0000 0000 0076 cccc cccc cc7c 0ccc 7800
0000 e060 606c 7666 6666 66e6 0000 0000
0000 1818 0038 1818 1818 183c 0000 0000
0000 0606 000e 0606 0606 0606 6666 3c00
0000 e060 6066 6c78 786c 66e6 0000 0000
0000 3818 1818 1818 1818 183c 0000 0000
0000 0000 00ec fed6 d6d6 d6c6 0000 0000
0000 0000 00dc 6666 6666 6666 0000 0000
0000 0000 007c c6c6 c6c6 c67c 0000 0000
0000 0000 00dc 6666 6666 667c 6060 f000
0000 0000 0076 cccc cccc cc7c 0c0c 1e00
0000 0000 00dc 7666 6060 60f0 0000 0000
0000 0000 007c c660 380c c67c 0000 0000
0000 1030 30fc 3030 3030 361c 0000 0000
0000 0000 00cc cccc cccc cc76 0000 0000
0000 0000 0066 6666 6666 3c18 0000 0000
0000 0000 00c6 c6d6 d6d6 fe6c 0000 0000
0000 0000 00c6 6c38 3838 6cc6 0000 0000
0000 0000 00c6 c6c6 c6c6 c67e 060c f800
0000 0000 00fe cc18 3060 c6fe 0000 0000
0000 0e18 1818 7018 1818 180e 0000 0000
0000 1818 1818 0018 1818 1818 0000 0000
0000 7018 1818 0e18 1818 1870 0000 0000
~projects/library/check-rom.tal
~projects/library/load-rom.tal
@view

View File

@ -191,7 +191,7 @@ JMP2r
#0010 .Screen/x DEO2
#0080 .Screen/y DEO2
.browser/sel LDZ #02 ;draw-byte JSR2
LIT '/ #02 ;draw-char JSR2
LIT "/ #02 ;draw-char JSR2
.browser/lines LDZ #01 SUB #02 ;draw-byte JSR2
#00 .Screen/auto DEO
@ -200,7 +200,7 @@ JMP2r
@follow-selection ( -- )
.browser/y2 LDZ2 .browser/y LDZ2 SUB2 #04 SFT2 NIP .browser/sel LDZ .browser/scroll LDZ SUB
DUP2 GTH ,&no-down JCN
GTHk ,&no-down JCN
.browser/scroll LDZ INC ,scroll-to JSR
&no-down
DUP2 SWP LTH ,&no-up JCN
@ -215,7 +215,7 @@ JMP2r
STH
( more lines than visible )
.browser/lines LDZ .browser/y2 LDZ2 .browser/y LDZ2 SUB2 #04 SFT2 NIP
DUP2 GTH ,&can-scroll JCN
GTHk ,&can-scroll JCN
POPr POP2 JMP2r
&can-scroll
( less than max scroll )
@ -321,7 +321,7 @@ JMP2r
EQUkr STHr #00 EQU ,&no-reached JCN
POP2r NIP2 ;dir/data ADD2 JMP2r
&no-reached
DUP2 ;dir/data ADD2 LDA #00 NEQ ,&no-lb JCN
DUP2 ;dir/data ADD2 LDA ,&no-lb JCN
INCr
&no-lb
INC2 GTH2k ,&loop JCN

View File

@ -1,40 +1,14 @@
(
app/neralie : clock with arvelie date
( app/neralie : clock with arvelie date )
TODO
- use splash screen when FPS calculation is unstable
)
%PAD { #0018 }
%+ { ADD } %- { SUB } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%2* { #10 SFT } %2/ { #01 SFT }
%4* { #20 SFT } %4/ { #02 SFT }
%8* { #30 SFT } %8/ { #03 SFT }
%10* { #40 SFT } %10/ { #04 SFT }
%20* { #50 SFT } %20/ { #05 SFT }
%2** { #10 SFT2 } %2// { #01 SFT2 }
%4** { #20 SFT2 } %4// { #02 SFT2 }
%8** { #30 SFT2 } %8// { #03 SFT2 }
%10** { #40 SFT2 } %10// { #04 SFT2 }
%20** { #50 SFT2 } %20// { #05 SFT2 }
%MOD { DUP2 DIV MUL SUB }
%MOD { DIVk MUL SUB }
%MOD2 { DIV2k MUL2 SUB2 }
%TOS { #00 SWP }
%h { .DateTime/hour DEI }
%m { .DateTime/minute DEI }
%s { .DateTime/second DEI }
%1-- { #0001 -- }
%PAD { #0018 }
%RTN { JMP2r }
( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
@ -76,15 +50,15 @@
PAD
DUP2 .frame/x1 STZ2
DUP2 .frame/y1 STZ2
DUP2 .Screen/width DEI2 SWP2 -- #0001 -- .frame/x2 STZ2
.Screen/height DEI2 SWP2 -- .frame/y2 STZ2
DUP2 .Screen/width DEI2 SWP2 SUB2 #0001 SUB2 .frame/x2 STZ2
.Screen/height DEI2 SWP2 SUB2 .frame/y2 STZ2
#01 .neralie/color STZ
.frame/x1 LDZ2 .frame/x2 LDZ2
OVR2 OVR2 .frame/y1 LDZ2 ;h JSR2
.frame/y2 LDZ2 ;h JSR2
.frame/y1 LDZ2 #0001 -- .frame/y2 LDZ2 INC2
.frame/y1 LDZ2 #0001 SUB2 .frame/y2 LDZ2 INC2
OVR2 OVR2 .frame/x1 LDZ2 ;v JSR2
.frame/x2 LDZ2 ;v JSR2
@ -108,7 +82,7 @@ BRK
#0120 #00 h MUL2
#00c0 #00 m MUL2 ADD2
#00f8 #00 s MUL2 ADD2
#0271 #00 .fps/next LDZ MUL2 #00 .fps/current LDZ DIV2 8** 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
( add up units and tens of pulses, store in n5 and n4 )
@ -122,29 +96,29 @@ BRK
#01a0 #00 h MUL2 ADD2
#0006 #00 m MUL2 ADD2 .neralie/n0123 STZ2
RTN
JMP2r
@draw-date ( -- )
( auto x ) #01 .Screen/auto DEO
.Screen/width DEI2 2// #0034 -- .Screen/x DEO2
.Screen/height DEI2 #0010 -- .Screen/y DEO2
.Screen/width DEI2 #01 SFT2 #0034 SUB2 .Screen/x DEO2
.Screen/height DEI2 #0010 SUB2 .Screen/y DEO2
( arvelie )
.DateTime/year DEI2 #07d6 -- NIP
DUP #0a DIV TOS 8** ;font-numbers ++ .Screen/addr DEO2
.DateTime/year DEI2 #07d6 SUB2 NIP
DUP #0a DIV #00 SWP #30 SFT2 ;font-numbers ADD2 .Screen/addr DEO2
#01 .Screen/sprite DEO
#0a MOD TOS 8** ;font-numbers ++ .Screen/addr DEO2
#0a MOD #00 SWP #30 SFT2 ;font-numbers ADD2 .Screen/addr DEO2
#01 .Screen/sprite DEO
.DateTime/doty DEI2
DUP2 #000e DIV2 8** ;font-letters ++ .Screen/addr DEO2
DUP2 #000e DIV2 #30 SFT2 ;font-letters ADD2 .Screen/addr DEO2
#01 .Screen/sprite DEO
#000e MOD2
DUP2 #000a DIV2 ,digit JSR
#000a MOD2 ,digit JSR
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
( neralie )
.neralie/n0123 LDZ2
@ -158,14 +132,14 @@ RTN
( auto none ) #00 .Screen/auto DEO
RTN
JMP2r
@digit ( index* -- )
8** ;font-numbers ++ .Screen/addr DEO2
#30 SFT2 ;font-numbers ADD2 .Screen/addr DEO2
.neralie/color LDZ .Screen/sprite DEO
RTN
JMP2r
@draw-clock ( -- )
@ -197,7 +171,7 @@ RTN
&next ( digit-addr number* -- next-digit-addr next-number* prev-digit* )
#03e8 ;modf JSR2 STH2 #000a MUL2
ROT DUP STH INC ROT ROT
ROT STHk INC ROT ROT
#00 STHr LDZ ADD2
STH2r
JMP2r
@ -233,7 +207,7 @@ RTN
.Screen/y .lines/addr STZ
&draw-line ( v1* v2* -- )
OVR2 OVR2 LTH2 #01 JCN SWP2
LTH2k #01 JCN SWP2
STH2
&loop
@ -256,8 +230,8 @@ RTN
#00 .fps/next STZ
JMP2r
@modf ( dividend* divisor* -- remainder* quotient* )
OVR2 OVR2 DIV2 DUP2 STH2 MUL2 SUB2 STH2r JMP2r
@modf ( dividend* divisor* SUB2 remainder* quotient* )
DIV2k STH2k MUL2 SUB2 STH2r JMP2r
@mul2hi ( a* b* -- product-top-16-bits* )
(

View File

@ -88,14 +88,14 @@ BRK
#40 .Screen/sprite DEO
.Controller/key DEI
[ LIT 'a ] NEQk NIP ,&no-c JCN #30 .octave LDZ #0c MUL ADD ;play JSR2 &no-c
[ LIT 's ] NEQk NIP ,&no-d JCN #32 .octave LDZ #0c MUL ADD ;play JSR2 &no-d
[ LIT 'd ] NEQk NIP ,&no-e JCN #34 .octave LDZ #0c MUL ADD ;play JSR2 &no-e
[ LIT 'f ] NEQk NIP ,&no-f JCN #35 .octave LDZ #0c MUL ADD ;play JSR2 &no-f
[ LIT 'g ] NEQk NIP ,&no-g JCN #37 .octave LDZ #0c MUL ADD ;play JSR2 &no-g
[ LIT 'h ] NEQk NIP ,&no-a JCN #39 .octave LDZ #0c MUL ADD ;play JSR2 &no-a
[ LIT 'j ] NEQk NIP ,&no-b JCN #3b .octave LDZ #0c MUL ADD ;play JSR2 &no-b
[ LIT 'k ] NEQk NIP ,&no-c2 JCN #3c .octave LDZ #0c MUL ADD ;play JSR2 &no-c2
[ LIT "a ] NEQk NIP ,&no-c JCN #30 .octave LDZ #0c MUL ADD ;play JSR2 &no-c
[ LIT "s ] NEQk NIP ,&no-d JCN #32 .octave LDZ #0c MUL ADD ;play JSR2 &no-d
[ LIT "d ] NEQk NIP ,&no-e JCN #34 .octave LDZ #0c MUL ADD ;play JSR2 &no-e
[ LIT "f ] NEQk NIP ,&no-f JCN #35 .octave LDZ #0c MUL ADD ;play JSR2 &no-f
[ LIT "g ] NEQk NIP ,&no-g JCN #37 .octave LDZ #0c MUL ADD ;play JSR2 &no-g
[ LIT "h ] NEQk NIP ,&no-a JCN #39 .octave LDZ #0c MUL ADD ;play JSR2 &no-a
[ LIT "j ] NEQk NIP ,&no-b JCN #3b .octave LDZ #0c MUL ADD ;play JSR2 &no-b
[ LIT "k ] NEQk NIP ,&no-c2 JCN #3c .octave LDZ #0c MUL ADD ;play JSR2 &no-c2
[ #1b ] NEQk NIP ,&no-esc JCN #010f DEO &no-esc
POP

View File

@ -28,15 +28,14 @@ BRK
LIT2r 0000
&stream
#0000 ,&buf STR2
;&buf
DUP2 .File/read DEO2
LDA2 ,print JSR #2018 DEO
;&buf .File/read DEO2
.File/success DEI2 #0000 EQU2 ,&eof JCN
;&buf LDA2 ,print JSR #2018 DEO
INC2r
( linebreak )
STH2kr #0007 AND2 ORA ,&no-lb JCN
#0a18 DEO
&no-lb
.File/success DEI2 ORA ,&stream JCN
STH2kr #000f AND2 ORA ,&no-lb JCN
#0a18 DEO &no-lb
,&stream JMP &eof
POP2r
#010f DEO

View File

@ -2,9 +2,7 @@
( Requirements:
EQU/EQU2 should put #00 or #01 on the stack
#18 DEO should output ascii character to console
#02 DEO should set location of working stack in memory
#03 DEO should set location of return stack in memory )
#18 DEO should output ascii character to console )
%EMIT { #18 DEO }
%TEST-SHORT { EQU2 #30 ADD EMIT }
@ -12,11 +10,6 @@
%MODE { #20 EMIT }
%OPCODE { #0a EMIT }
%TYPE { OPCODE OPCODE }
%GET-ERR { #fe LDA }
%WST { #ff }
%RST { #fe }
|00 @System &vector $2 &stacks &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2
|0000
@ -25,9 +18,6 @@
|0100
( set stacks location )
WST RST .System/stacks DEO2
( Logic )
( EQU )
@ -40,6 +30,16 @@
#01f8 #01f8 EQU2 [ #01 ] TEST-BYTE
#f801 #01f8 EQU2 [ #00 ] TEST-BYTE
#01f8 #f801 EQU2 [ #00 ] TEST-BYTE
MODE
#f8 #f8 EQUk ADD ADD [ #f1 ] TEST-BYTE
#01 #01 EQUk ADD ADD [ #03 ] TEST-BYTE
#f8 #01 EQUk ADD ADD [ #f9 ] TEST-BYTE
#01 #f8 EQUk ADD ADD [ #f9 ] TEST-BYTE
MODE
#f801 #f801 EQU2k #00 ADD2 ADD2 [ #f102 ] TEST-SHORT
#01f8 #01f8 EQU2k #00 ADD2 ADD2 [ #04f0 ] TEST-SHORT
#f801 #01f8 EQU2k #00 ADD2 ADD2 [ #f9f9 ] TEST-SHORT
#01f8 #f801 EQU2k #00 ADD2 ADD2 [ #f9f9 ] TEST-SHORT
OPCODE
( NEQ )
@ -52,6 +52,16 @@
#01f8 #01f8 NEQ2 [ #00 ] TEST-BYTE
#f801 #01f8 NEQ2 [ #01 ] TEST-BYTE
#01f8 #f801 NEQ2 [ #01 ] TEST-BYTE
MODE
#f8 #f8 NEQk ADD ADD [ #f0 ] TEST-BYTE
#01 #01 NEQk ADD ADD [ #02 ] TEST-BYTE
#f8 #01 NEQk ADD ADD [ #fa ] TEST-BYTE
#01 #f8 NEQk ADD ADD [ #fa ] TEST-BYTE
MODE
#f801 #f801 NEQ2k #00 ADD2 ADD2 [ #f002 ] TEST-SHORT
#01f8 #01f8 NEQ2k #00 ADD2 ADD2 [ #03f0 ] TEST-SHORT
#f801 #01f8 NEQ2k #00 ADD2 ADD2 [ #faf9 ] TEST-SHORT
#01f8 #f801 NEQ2k #00 ADD2 ADD2 [ #faf9 ] TEST-SHORT
OPCODE
( GTH )
@ -64,6 +74,16 @@
#01f8 #01f8 GTH2 [ #00 ] TEST-BYTE
#f801 #01f8 GTH2 [ #01 ] TEST-BYTE
#01f8 #f801 GTH2 [ #00 ] TEST-BYTE
MODE
#f8 #f8 GTHk ADD ADD [ #f0 ] TEST-BYTE
#01 #01 GTHk ADD ADD [ #02 ] TEST-BYTE
#f8 #01 GTHk ADD ADD [ #fa ] TEST-BYTE
#01 #f8 GTHk ADD ADD [ #f9 ] TEST-BYTE
MODE
#f801 #f801 GTH2k #00 ADD2 ADD2 [ #f002 ] TEST-SHORT
#01f8 #01f8 GTH2k #00 ADD2 ADD2 [ #03f0 ] TEST-SHORT
#f801 #01f8 GTH2k #00 ADD2 ADD2 [ #faf9 ] TEST-SHORT
#01f8 #f801 GTH2k #00 ADD2 ADD2 [ #f9f9 ] TEST-SHORT
OPCODE
( LTH )
@ -76,6 +96,16 @@
#01f8 #01f8 LTH2 [ #00 ] TEST-BYTE
#f801 #01f8 LTH2 [ #00 ] TEST-BYTE
#01f8 #f801 LTH2 [ #01 ] TEST-BYTE
MODE
#f8 #f8 LTHk ADD ADD [ #f0 ] TEST-BYTE
#01 #01 LTHk ADD ADD [ #02 ] TEST-BYTE
#f8 #01 LTHk ADD ADD [ #f9 ] TEST-BYTE
#01 #f8 LTHk ADD ADD [ #fa ] TEST-BYTE
MODE
#f801 #f801 LTH2k #00 ADD2 ADD2 [ #f002 ] TEST-SHORT
#01f8 #01f8 LTH2k #00 ADD2 ADD2 [ #03f0 ] TEST-SHORT
#f801 #01f8 LTH2k #00 ADD2 ADD2 [ #f9f9 ] TEST-SHORT
#01f8 #f801 LTH2k #00 ADD2 ADD2 [ #faf9 ] TEST-SHORT
TYPE
( Arithmetic )
@ -91,6 +121,15 @@
#ffff #ffff ADD2 [ #fffe ] TEST-SHORT
#fffe #ffff ADD2 [ #fffd ] TEST-SHORT
MODE
#ff #00 ADDk ADD ADD [ #fe ] TEST-BYTE
#01 #ff ADDk ADD ADD [ #00 ] TEST-BYTE
#ff #ff ADDk ADD ADD [ #fc ] TEST-BYTE
#fe #ff ADDk ADD ADD [ #fa ] TEST-BYTE
MODE
#ffff #0000 ADD2k ADD2 ADD2 [ #fffe ] TEST-SHORT
#0001 #ffff ADD2k ADD2 ADD2 [ #0000 ] TEST-SHORT
#ffff #ffff ADD2k ADD2 ADD2 [ #fffc ] TEST-SHORT
#fffe #ffff ADD2k ADD2 ADD2 [ #fffa ] TEST-SHORT
OPCODE
( SUB )
@ -104,6 +143,15 @@
#ffff #ffff SUB2 [ #0000 ] TEST-SHORT
#fffe #ffff SUB2 [ #ffff ] TEST-SHORT
MODE
#ff #00 SUBk ADD ADD [ #fe ] TEST-BYTE
#01 #ff SUBk ADD ADD [ #02 ] TEST-BYTE
#ff #ff SUBk ADD ADD [ #fe ] TEST-BYTE
#fe #ff SUBk ADD ADD [ #fc ] TEST-BYTE
MODE
#ffff #0000 SUB2k ADD2 ADD2 [ #fffe ] TEST-SHORT
#0001 #ffff SUB2k ADD2 ADD2 [ #0002 ] TEST-SHORT
#ffff #ffff SUB2k ADD2 ADD2 [ #fffe ] TEST-SHORT
#fffe #ffff SUB2k ADD2 ADD2 [ #fffc ] TEST-SHORT
OPCODE
( MUL )
@ -116,6 +164,16 @@
#abcd #1234 MUL2 [ #4fa4 ] TEST-SHORT
#8000 #0200 MUL2 [ #0000 ] TEST-SHORT
#2222 #0003 MUL2 [ #6666 ] TEST-SHORT
MODE
#00 #01 MULk ADD ADD [ #01 ] TEST-BYTE
#3f #e7 MULk ADD ADD [ #ff ] TEST-BYTE
#37 #3f MULk ADD ADD [ #ff ] TEST-BYTE
#10 #02 MULk ADD ADD [ #32 ] TEST-BYTE
MODE
#1000 #0003 MUL2k ADD2 ADD2 [ #4003 ] TEST-SHORT
#abcd #1234 MUL2k ADD2 ADD2 [ #0da5 ] TEST-SHORT
#8000 #0200 MUL2k ADD2 ADD2 [ #8200 ] TEST-SHORT
#2222 #0003 MUL2k ADD2 ADD2 [ #888b ] TEST-SHORT
OPCODE
( DIV )
@ -128,6 +186,16 @@
#abcd #1234 DIV2 [ #0009 ] TEST-SHORT
#8000 #0200 DIV2 [ #0040 ] TEST-SHORT
#2222 #0003 DIV2 [ #0b60 ] TEST-SHORT
MODE
#10 #02 DIVk ADD ADD [ #1a ] TEST-BYTE
#20 #20 DIVk ADD ADD [ #41 ] TEST-BYTE
#34 #01 DIVk ADD ADD [ #69 ] TEST-BYTE
#02 #ef DIVk ADD ADD [ #f1 ] TEST-BYTE
MODE
#1000 #0040 DIV2k ADD2 ADD2 [ #1080 ] TEST-SHORT
#abcd #1234 DIV2k ADD2 ADD2 [ #be0a ] TEST-SHORT
#8000 #0200 DIV2k ADD2 ADD2 [ #8240 ] TEST-SHORT
#2222 #0003 DIV2k ADD2 ADD2 [ #2d85 ] TEST-SHORT
TYPE
( Stack )
@ -142,6 +210,16 @@
#ffff INC2 [ #0000 ] TEST-SHORT
#fffe INC2 [ #ffff ] TEST-SHORT
#0000 INC2 [ #0001 ] TEST-SHORT
MODE
#01 INCk ADD [ #03 ] TEST-BYTE
#ff INCk ADD [ #ff ] TEST-BYTE
#fe INCk ADD [ #fd ] TEST-BYTE
#00 INCk ADD [ #01 ] TEST-BYTE
MODE
#0001 INC2k ADD2 [ #0003 ] TEST-SHORT
#ffff INC2k ADD2 [ #ffff ] TEST-SHORT
#fffe INC2k ADD2 [ #fffd ] TEST-SHORT
#0000 INC2k ADD2 [ #0001 ] TEST-SHORT
OPCODE
( POP )
@ -154,36 +232,66 @@
#0a0b #0c0d #0e0f POP2 POP2 [ #0a0b ] TEST-SHORT
#0a0b #0c0d #0e0f ADD2 POP2 [ #0a0b ] TEST-SHORT
#0a0b #0c0d #0e0f POP2 ADD2 [ #1618 ] TEST-SHORT
MODE
#0a #0b POPk [ #0b ] TEST-BYTE POP
#0a #0b #0c POPk POP [ #0b ] TEST-BYTE POP
#0a #0b #0c ADD POPk [ #17 ] TEST-BYTE POP
#0a #0b #0c POPk ADD [ #17 ] TEST-BYTE POP
MODE
#0a0b #0c0d POP2k [ #0c0d ] TEST-SHORT POP2
#0a0b #0c0d #0e0f POP2k POP2 [ #0c0d ] TEST-SHORT POP2
#0a0b #0c0d #0e0f ADD2 POP2k [ #1a1c ] TEST-SHORT POP2
#0a0b #0c0d #0e0f POP2k ADD2 [ #1a1c ] TEST-SHORT POP2
OPCODE
( DUP )
#0a #0b DUP ADD ADD [ #20 ] TEST-BYTE
MODE
#0a0b DUP2 ADD2 [ #1416 ] TEST-SHORT
MODE
#0a #0b DUPk ADD ADD ADD [ #2b ] TEST-BYTE
MODE
#0a0b DUP2k ADD2 ADD2 [ #1e21 ] TEST-SHORT
OPCODE
( NIP )
#12 #34 #56 NIP ADD [ #68 ] TEST-BYTE
MODE
#1234 #5678 #9abc NIP2 ADD2 [ #acf0 ] TEST-SHORT
MODE
#12 #34 #56 NIPk ADD ADD [ #e0 ] TEST-BYTE POP
MODE
#1234 #5678 #9abc NIP2k ADD2 ADD2 [ #8bf0 ] TEST-SHORT POP2
OPCODE
( SWP )
#02 #10 SWP DIV [ #08 ] TEST-BYTE
MODE
#0a0b #0c0d SWP2 NIP2 [ #0a0b ] TEST-SHORT
MODE
#02 #10 SWPk DIV ADD ADD [ #1a ] TEST-BYTE
MODE
#0a0b #0c0d SWP2k POP2 POP2 POP2 [ #0a0b ] TEST-SHORT
OPCODE
( OVR )
#02 #10 OVR DIV ADD [ #0a ] TEST-BYTE
MODE
#0a0b #0c0d OVR2 NIP2 ADD2 [ #1416 ] TEST-SHORT
MODE
#02 #10 OVRk DIV ADD ADD ADD [ #1c ] TEST-BYTE
MODE
#0a0b #0c0d OVR2k NIP2 ADD2 ADD2 ADD2 [ #2a2e ] TEST-SHORT
OPCODE
( ROT )
#02 #04 #10 ROT DIV ADD [ #0c ] TEST-BYTE
MODE
#0a0b #0c0d #0c0f ROT2 ADD2 NIP2 [ #161a ] TEST-SHORT
MODE
#02 #04 #10 ROTk DIV ADD ADD ADD ADD [ #22 ] TEST-BYTE
MODE
#0a0b #0c0d #0c0f ROT2k ADD2 NIP2 ADD2 ADD2 ADD2 [ #3841 ] TEST-SHORT
TYPE
( Bitwise )
@ -198,6 +306,16 @@
#aaaa #5555 AND2 [ #0000 ] TEST-SHORT
#ffff #1234 AND2 [ #1234 ] TEST-SHORT
#abcd #0a0c AND2 [ #0a0c ] TEST-SHORT
MODE
#fc #3f ANDk ADD ADD [ #77 ] TEST-BYTE
#f0 #0f ANDk ADD ADD [ #ff ] TEST-BYTE
#ff #3c ANDk ADD ADD [ #77 ] TEST-BYTE
#02 #03 ANDk ADD ADD [ #07 ] TEST-BYTE
MODE
#f0f0 #00f0 AND2k ADD2 ADD2 [ #f2d0 ] TEST-SHORT
#aaaa #5555 AND2k ADD2 ADD2 [ #ffff ] TEST-SHORT
#ffff #1234 AND2k ADD2 ADD2 [ #2467 ] TEST-SHORT
#abcd #0a0c AND2k ADD2 ADD2 [ #bfe5 ] TEST-SHORT
OPCODE
( ORA )
@ -210,6 +328,16 @@
#abab #cdcd ORA2 [ #efef ] TEST-SHORT
#1122 #1234 ORA2 [ #1336 ] TEST-SHORT
#8888 #1000 ORA2 [ #9888 ] TEST-SHORT
MODE
#0f #f0 ORAk ADD ADD [ #fe ] TEST-BYTE
#ab #cd ORAk ADD ADD [ #67 ] TEST-BYTE
#12 #34 ORAk ADD ADD [ #7c ] TEST-BYTE
#88 #10 ORAk ADD ADD [ #30 ] TEST-BYTE
MODE
#0f0f #f0f0 ORA2k ADD2 ADD2 [ #fffe ] TEST-SHORT
#abab #cdcd ORA2k ADD2 ADD2 [ #6967 ] TEST-SHORT
#1122 #1234 ORA2k ADD2 ADD2 [ #368c ] TEST-SHORT
#8888 #1000 ORA2k ADD2 ADD2 [ #3110 ] TEST-SHORT
OPCODE
( EOR )
@ -222,6 +350,16 @@
#aaaa #5555 EOR2 [ #ffff ] TEST-SHORT
#1122 #1234 EOR2 [ #0316 ] TEST-SHORT
#8888 #1000 EOR2 [ #9888 ] TEST-SHORT
MODE
#00 #00 EORk ADD ADD [ #00 ] TEST-BYTE
#ff #00 EORk ADD ADD [ #fe ] TEST-BYTE
#aa #55 EORk ADD ADD [ #fe ] TEST-BYTE
#ff #ff EORk ADD ADD [ #fe ] TEST-BYTE
MODE
#ffff #ff00 EOR2k ADD2 ADD2 [ #fffe ] TEST-SHORT
#aaaa #5555 EOR2k ADD2 ADD2 [ #fffe ] TEST-SHORT
#1122 #1234 EOR2k ADD2 ADD2 [ #266c ] TEST-SHORT
#8888 #1000 EOR2k ADD2 ADD2 [ #3110 ] TEST-SHORT
OPCODE
( SFT )
@ -234,6 +372,16 @@
#ffff #70 SFT2 [ #ff80 ] TEST-SHORT
#ffff #7e SFT2 [ #0180 ] TEST-SHORT
#ffff #e3 SFT2 [ #c000 ] TEST-SHORT
MODE
#ff #08 SFTk ADD ADD [ #07 ] TEST-BYTE
#ff #e0 SFTk ADD ADD [ #df ] TEST-BYTE
#ff #11 SFTk ADD ADD [ #0e ] TEST-BYTE
#ff #12 SFTk ADD ADD [ #8f ] TEST-BYTE
MODE
#ffff #01 SFT2k ROT POP ADD2 [ #7ffe ] TEST-SHORT
#ffff #70 SFT2k ROT POP ADD2 [ #ff7f ] TEST-SHORT
#ffff #7e SFT2k ROT POP ADD2 [ #017f ] TEST-SHORT
#ffff #e3 SFT2k ROT POP ADD2 [ #bfff ] TEST-SHORT
TYPE
( Memory )
@ -267,8 +415,8 @@
OPCODE
( DEI/DEO )
LIT '1 EMIT
LIT '1 EMIT
LIT "1 EMIT
LIT "1 EMIT
TYPE
( Branching )
@ -301,21 +449,6 @@
#12 #34 ADDk ADD ADD [ #8c ] TEST-BYTE
OPCODE
( Error: Division By Zero )
;on-error-division #00 DEO2
#10 #00 DIV
@err2
( Error: Working Stack Underflow )
;on-error-underflow #00 DEO2
POP
@err3
( Error: Return Stack Underflow )
;on-error-underflowr #00 DEO2
POPr
@end
#010e DEO
#010f DEO
@ -327,57 +460,5 @@ BRK
JMP2r
@on-error-division ( -> )
WST ;print-err JSR2
;err2 JMP2
BRK
@on-error-underflow ( -> )
WST ;print-err JSR2
;err3 JMP2
BRK
@on-error-underflowr ( -> )
RST ;print-err JSR2
;end JMP2
BRK
@print-err ( page -- )
;err-txt ;print-str JSR2
;rst-txt ;print-str JSR2
#20 EMIT
GET-ERR ;print/byte JSR2
#0a EMIT
JMP2r
@print-str ( str* -- )
&while
LDAk #18 DEO
INC2 LDAk ,&while JCN
POP2
JMP2r
@print ( short* -- )
SWP ,&byte JSR
&byte ( byte -- ) DUP #04 SFT ,&char JSR
&char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
JMP2r
@err-txt "Error $1
@wst-txt "(wst) $1
@rst-txt "(rst) $1
@absolute
&byte $1 &short $2

View File

@ -44,8 +44,6 @@ typedef struct {
} Program;
Program p;
static int litlast = 0;
static int jsrlast = 0;
/* clang-format off */
@ -207,8 +205,6 @@ writebyte(Uint8 b)
return error("Memory overwrite", "");
p.data[p.ptr++] = b;
p.length = p.ptr;
litlast = 0;
jsrlast = 0;
return 1;
}
@ -216,16 +212,7 @@ static int
writeopcode(char *w)
{
Uint8 res;
if(jsrlast && scmp(w, "JMP2r", 5)) { /* tail-call optimization */
p.data[p.ptr - 1] = jsrlast == 2 ? findopcode("JMP2") : findopcode("JMP");
jsrlast = 0;
return 1;
}
res = writebyte(findopcode(w));
if(scmp(w, "JSR2", 4))
jsrlast = 2;
else if(scmp(w, "JSR", 3))
jsrlast = 1;
return res;
}
@ -240,15 +227,8 @@ writeshort(Uint16 s, int lit)
static int
writelitbyte(Uint8 b)
{
if(litlast) { /* literals optimization */
Uint8 hb = p.data[p.ptr - 1];
p.ptr -= 2;
p.length = p.ptr;
return writeshort((hb << 8) + b, 1);
}
if(!writebyte(findopcode("LIT"))) return 0;
if(!writebyte(b)) return 0;
litlast = 1;
return 1;
}
@ -299,24 +279,20 @@ parse(char *w, FILE *f)
if(!sihx(w + 1))
return error("Invalid padding", w);
p.ptr = shex(w + 1);
litlast = jsrlast = 0;
break;
case '$': /* pad-relative */
if(!sihx(w + 1))
return error("Invalid padding", w);
p.ptr += shex(w + 1);
litlast = jsrlast = 0;
break;
case '@': /* label */
if(!makelabel(w + 1))
return error("Invalid label", w);
scpy(w + 1, p.scope, 0x40);
litlast = jsrlast = 0;
break;
case '&': /* sublabel */
if(!makelabel(sublabel(subw, p.scope, w + 1)))
return error("Invalid sublabel", w);
litlast = jsrlast = 0;
break;
case '#': /* literals hex */
if(!sihx(w + 1) || (slen(w) != 3 && slen(w) != 5))
@ -328,11 +304,11 @@ parse(char *w, FILE *f)
}
break;
case '.': /* literal byte zero-page */
makereference(p.scope, w, p.ptr - litlast);
makereference(p.scope, w, p.ptr);
if(!writelitbyte(0xff)) return 0;
break;
case ',': /* literal byte relative */
makereference(p.scope, w, p.ptr - litlast);
makereference(p.scope, w, p.ptr);
if(!writelitbyte(0xff)) return 0;
break;
case ';': /* literal short absolute */
@ -343,9 +319,6 @@ parse(char *w, FILE *f)
makereference(p.scope, w, p.ptr);
if(!writeshort(0xffff, 0)) return 0;
break;
case '\'': /* raw char */
if(!writebyte((Uint8)w[1])) return 0;
break;
case '"': /* raw string */
i = 0;
while((c = w[++i]))