uxn/projects/examples/demos/font.tal

194 lines
4.5 KiB
Tal
Raw Normal View History

2021-12-16 18:46:27 +00:00
( uxnasm projects/examples/demos/font.tal bin/font.rom && uxnemu bin/font.rom )
2021-07-02 17:57:50 +00:00
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%RTN { JMP2r }
%TOS { #00 SWP }
2021-12-16 18:46:27 +00:00
%GET-WIDTH { TOS ;font-data ++ LDA }
%GET-GLYPH { TOS #50 SFT2 ;font-data/glyphs ++ }
%AUTO-NONE { #00 .Screen/auto DEO }
%AUTO-X { #01 .Screen/auto DEO }
%AUTO-Y { #02 .Screen/auto DEO }
%AUTO-ADDR { #04 .Screen/auto DEO }
%AUTO-X-ADDR { #05 .Screen/auto DEO }
%AUTO-Y-ADDR { #06 .Screen/auto DEO }
2021-07-02 17:57:50 +00:00
( devices )
2021-07-03 17:24:23 +00:00
|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2
2021-12-16 18:46:27 +00:00
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
2021-11-07 19:10:30 +00:00
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
2021-07-02 17:57:50 +00:00
( variables )
|0000
( init )
|0100 ( -> )
( theme )
2021-07-04 18:44:19 +00:00
#0fa7 .System/r DEO2
#0fa7 .System/g DEO2
#0fa7 .System/b DEO2
2021-07-02 17:57:50 +00:00
( load font )
2021-07-10 19:22:17 +00:00
#4900 .File/length DEO2
2021-07-03 17:24:23 +00:00
;font-path-large .File/name DEO2
2021-11-07 19:10:30 +00:00
;font-data .File/read DEO2
2021-07-03 19:13:48 +00:00
( draw label )
#0020 #0020 ;title #01 ;draw-uf3 JSR2
2021-07-03 17:24:23 +00:00
( load font )
2021-07-10 19:22:17 +00:00
#2100 .File/length DEO2
2021-07-03 17:24:23 +00:00
;font-path-medium .File/name DEO2
2021-11-07 19:10:30 +00:00
;font-data .File/read DEO2
2021-07-03 19:13:48 +00:00
( draw label )
#0020 #0048 ;body #02 ;draw-uf2 JSR2
2021-07-03 17:24:23 +00:00
( load font )
2021-07-10 19:22:17 +00:00
#0900 .File/length DEO2
2021-07-03 17:24:23 +00:00
;font-path-small .File/name DEO2
2021-11-07 19:10:30 +00:00
;font-data .File/read DEO2
2021-07-03 19:13:48 +00:00
( draw label )
#0030 #00b8 ;footer #03 ;draw-uf1 JSR2
2021-07-02 17:57:50 +00:00
BRK
2021-07-05 02:17:56 +00:00
@draw-uf1 ( x* y* text* color -- )
STH
SWP2 .Screen/y DEO2
SWP2 DUP2 .Screen/x DEO2 SWP2
&loop
LDAk
DUP #0a ! ,&no-linebreak JCN
( move down ) STH OVR2 .Screen/x DEO2 STHr
( incr y ) .Screen/y DEI2 #0010 ++ .Screen/y DEO2
POP ,&continue JMP &no-linebreak
( get addr ) STHk TOS #30 SFT2 ;font-data #0100 ++ ++ .Screen/addr DEO2
2021-07-05 02:17:56 +00:00
( get width ) STHr TOS ;font-data ++ LDA TOS
( draw ) STHkr .Screen/sprite DEO
2021-07-05 02:17:56 +00:00
( use width ) .Screen/x DEI2 ++ .Screen/x DEO2
&continue
2021-08-26 22:27:18 +00:00
( incr addr ) INC2
2021-07-05 02:17:56 +00:00
LDAk ,&loop JCN
POP2 POP2 POPr
RTN
2021-07-03 16:11:29 +00:00
@draw-uf2 ( x* y* text* color -- )
2021-07-02 17:57:50 +00:00
STH
2021-07-03 16:11:29 +00:00
SWP2 .Screen/y DEO2
2021-12-16 18:46:27 +00:00
SWP2 .Screen/x DEO2
AUTO-Y-ADDR
&while
LDAk #0a ! ,&no-linebreak JCN
( reset ) #0020 .Screen/x DEO2
( down ) .Screen/y DEI2k #0010 ++ ROT DEO2
,&continue JMP &no-linebreak
LDAk STHkr ,&sprite JSR
2021-07-03 16:11:29 +00:00
&continue
2021-12-16 18:46:27 +00:00
INC2 LDAk ,&while JCN
POP2 POPr
AUTO-NONE
2021-07-03 16:11:29 +00:00
RTN
2021-07-02 17:57:50 +00:00
2021-07-03 16:11:29 +00:00
&sprite ( char color -- )
2021-12-16 18:46:27 +00:00
.Screen/x DEI2 STH2
.Screen/y DEI2 STH2
( glyph ) OVR GET-GLYPH .Screen/addr DEO2
DUP .Screen/sprite DEOk DEO
STH2kr .Screen/y DEO2
SWP GET-WIDTH
DUP #09 < ,&narrow JCN
.Screen/x DEI2k #0008 ++ ROT DEO2
OVR .Screen/sprite DEOk DEO
STH2kr .Screen/y DEO2
&narrow
POP2r
( width ) TOS STH2r ++ .Screen/x DEO2
POP
2021-07-02 17:57:50 +00:00
RTN
RTN
2021-07-03 19:13:48 +00:00
@draw-uf3 ( x* y* text* color -- )
STH
SWP2 .Screen/y DEO2
SWP2 DUP2 .Screen/x DEO2 SWP2
&loop
LDAk
DUP #0a ! ,&no-linebreak JCN
( move down ) OVR2 .Screen/x DEO2
( incr y ) .Screen/y DEI2 #0010 ++ .Screen/y DEO2
POP ,&continue JMP &no-linebreak
STHkr ,&sprite JSR
&continue
2021-08-26 22:27:18 +00:00
( incr addr ) INC2
2021-07-03 19:13:48 +00:00
LDAk ,&loop JCN
POP2 POP2 POPr
RTN
&sprite ( char color -- )
STH
( get addr ) DUP TOS #30 SFT2 #30 SFT2k ROT POP ADD2 ;font-data #0100 ++ ++ .Screen/addr DEO2
2021-07-03 19:13:48 +00:00
( get width ) TOS ;font-data ++ LDA TOS
2021-08-26 22:50:27 +00:00
#0300
2021-07-03 19:13:48 +00:00
&ver
2021-08-26 22:50:27 +00:00
#0300
2021-07-03 19:13:48 +00:00
&hor
STHkr .Screen/sprite DEO
2021-07-03 19:13:48 +00:00
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
.Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
2021-08-26 22:50:27 +00:00
INC GTHk ,&hor JCN
2021-07-03 19:13:48 +00:00
POP2
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
.Screen/x DEI2 #0018 -- .Screen/x DEO2
2021-08-26 22:50:27 +00:00
INC GTHk ,&ver JCN
2021-07-03 19:13:48 +00:00
POP2
.Screen/y DEI2 #0018 -- .Screen/y DEO2
( use width ) .Screen/x DEI2 ++ .Screen/x DEO2
POPr
RTN
RTN
2021-07-03 17:24:23 +00:00
@title
5468 6520 466f 6720 486f 726e $1
2021-07-03 16:11:29 +00:00
@body
2021-07-02 17:57:50 +00:00
4927 6c6c 206d 616b 6520 6120 736f 756e
6420 7468 6174 2773 2073 6f20 616c 6f6e
6520 0a74 6861 7420 6e6f 206f 6e65 2063
616e 206d 6973 7320 6974 2c20 7468 6174
2077 686f 6576 6572 200a 6865 6172 7320
6974 2077 696c 6c20 7765 6570 2069 6e20
7468 6569 7220 736f 756c 732c 200a 616e
6420 6865 6172 7468 7320 7769 6c6c 2073
6565 6d20 7761 726d 6572 2c20 0a61 6e64
2062 6569 6e67 2069 6e73 6964 6520 7769
6c6c 2073 6565 6d20 6265 7474 6572 200a
746f 2061 6c6c 2077 686f 2068 6561 7220
6974 2069 6e20 7468 6520 6469 7374 616e
7420 746f 776e 732e 20 $1
2021-07-03 17:24:23 +00:00
@footer
2d20 4279 2052 6179 2042 7261 6462 7572
79 $1
@font-path-large
2021-07-05 02:17:56 +00:00
"projects/fonts/geneva24.uf3 $1
2021-07-03 17:24:23 +00:00
@font-path-medium
"projects/fonts/venice14.uf2 $1
2021-07-03 17:24:23 +00:00
@font-path-small
"projects/fonts/atari8.uf1 $1
2021-07-02 17:57:50 +00:00
2021-12-16 18:46:27 +00:00
@font-data $100 &glyphs