uxn-utils/gui/notepad/src/notepad.tal

558 lines
13 KiB
Tal
Raw Normal View History

2024-05-28 11:25:16 -04:00
( A port of the macintosh classic notepad )
2024-05-26 22:35:57 -04:00
|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2
|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
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1
2024-05-28 00:07:01 -04:00
|a0 @File &vector $2 &success $1 &success-lb $1 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
2024-05-27 23:01:57 -04:00
|000
2024-05-26 22:35:57 -04:00
@page $1
@collapsed $1
@selection &a $2 &b $2 &length $2
2024-05-28 11:36:49 -04:00
|100
2024-05-26 22:35:57 -04:00
2024-05-28 11:36:49 -04:00
@on-reset ( -> )
2024-05-28 11:25:16 -04:00
( | meta )
2024-05-26 22:35:57 -04:00
;meta #06 DEO2
2024-05-28 11:25:16 -04:00
( | theme )
2024-05-26 22:35:57 -04:00
#f00f .System/r DEO2
#f00f .System/g DEO2
#f00f .System/b DEO2
load-theme
2024-05-28 11:25:16 -04:00
( | size )
2024-05-26 22:35:57 -04:00
#00e0 .Screen/width DEO2
#00f8 .Screen/height DEO2
2024-05-28 11:25:16 -04:00
( | unlock )
2024-05-26 22:35:57 -04:00
;on-mouse-body .Mouse/vector DEO2
;on-frame .Screen/vector DEO2
;on-control .Controller/vector DEO2
2024-05-28 11:30:44 -04:00
( | let's go! )
2024-05-28 11:36:49 -04:00
file-init <draw-header>
#00 change-page BRK
2024-05-26 22:35:57 -04:00
@meta 00
( name ) "Note 20 "Pad 0a
( details ) "Original 20 "by 20 "Donn 20 "Denman 0a
( author ) "By 20 "Devine 20 "Lu 20 "Linvega 0a
2024-05-28 11:36:49 -04:00
( date ) "May 20 "28, 20 "2024 00 01
( icon ) 83 =appicon
2024-05-26 22:35:57 -04:00
(
@|vectors )
@on-control ( -> )
.Controller/key DEI .Controller/button DEI
2024-05-28 11:27:26 -04:00
( | shortcuts )
2024-05-28 11:36:49 -04:00
DUP2 [ LIT2 "a 01 ] NEQ2 ?{ POP2 <select-all>
BRK }
2024-05-28 11:25:16 -04:00
DUP2 [ LIT2 "x 01 ] NEQ2 ?{ POP2 edit-cut BRK }
DUP2 [ LIT2 "c 01 ] NEQ2 ?{ POP2 edit-copy BRK }
DUP2 [ LIT2 "v 01 ] NEQ2 ?{ POP2 edit-paste BRK }
2024-05-28 11:27:26 -04:00
( | mask shift key )
2024-05-26 22:35:57 -04:00
#fb AND
2024-05-28 11:27:26 -04:00
( | arrows )
2024-05-28 11:36:49 -04:00
DUP #10 NEQ ?{
get-to #0001 SUB2 find-line-start <select-variable> }
DUP #20 NEQ ?{ get-to INC2 find-line-end <select-variable> }
DUP #40 NEQ ?{ <select-left> }
DUP #80 NEQ ?{ <select-right> }
DUP #42 NEQ ?{
.selection/b LDZ2 #0001 SUB2 find-word-start <select-variable> }
DUP #82 NEQ ?{
.selection/b LDZ2 INC2 find-word-end <select-variable> }
2024-05-28 11:27:26 -04:00
( | pagination )
2024-05-27 23:01:57 -04:00
DUP #21 NEQ OVR #81 NEQ AND ?{ next-page }
DUP #11 NEQ OVR #41 NEQ AND ?{ prev-page }
2024-05-26 22:35:57 -04:00
POP
2024-05-28 11:27:26 -04:00
( | key )
2024-05-28 11:25:16 -04:00
DUP #08 NEQ ?{ erase }
DUP #7f NEQ ?{ delete }
DUP #09 LTH ?{ DUP insert }
2024-05-28 11:36:49 -04:00
POP #00 ;on-frame/f STA
BRK
2024-05-26 22:35:57 -04:00
@on-mouse-head ( -> )
2024-05-28 11:36:49 -04:00
[ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;mouse-icn <update-cursor>
2024-05-26 22:35:57 -04:00
.Mouse/state DEI #01 GTH .Mouse/y DEI2 #0012 LTH2 AND ?&toggle-collapse
2024-05-28 11:36:49 -04:00
<trap-mouse>
[ LIT &last $1 ] .Mouse/state DEI DUP ,&last STR
2024-05-26 22:35:57 -04:00
EQU ?&unchanged
2024-05-28 11:36:49 -04:00
<draw-header>
( release on close button ) .Mouse/state DEI ?&unchanged
2024-05-26 22:35:57 -04:00
.Mouse/x DEI2 #0008 SUB2 #000a GTH2 ?&unchanged
2024-05-28 11:36:49 -04:00
( exit ) #800f DEO
&unchanged BRK
&toggle-collapse ( -> )
#00f8 #0011 .collapsed LDZ ?{ SWP2 }
POP2 .Screen/height DEO2
2024-05-26 22:41:17 -04:00
[ LIT2 00 -collapsed ] LDZ EQU .collapsed STZ
2024-05-28 11:36:49 -04:00
<draw-header>
<redraw>
2024-05-26 22:35:57 -04:00
[ LIT2 00 -Mouse/state ] DEO
2024-05-28 11:36:49 -04:00
BRK
2024-05-26 22:35:57 -04:00
@on-mouse-body ( -> )
2024-05-28 11:36:49 -04:00
[ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;caret-icn <update-cursor>
<trap-mouse>
[ LIT &last $1 ] .Mouse/state DEI DUP #02 LTH ?{ get-position <select-word> }
DUP2 #0001 NEQ2 ?{ get-position <select-variable> }
DUP2 #0101 NEQ2 ?{ get-position <select-to> }
,&last STR
POP BRK
2024-05-26 22:35:57 -04:00
@on-mouse-foot ( -> )
2024-05-28 11:36:49 -04:00
[ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;mouse-icn <update-cursor>
<trap-mouse>
2024-05-26 22:41:17 -04:00
[ LIT2 00 -Mouse/state ] DEI NEQ .Mouse/x DEI2 #0018 LTH2 AND ?&on-mouse-down
2024-05-28 11:36:49 -04:00
BRK
&on-mouse-down ( -> )
2024-05-26 22:35:57 -04:00
[ LIT2 00 -Mouse/state ] DEO
2024-05-28 11:36:49 -04:00
.Mouse/y DEI2 #00d6 SUB2 NIP [ LIT2 18 -Mouse/x ] DEI2 NIP SUB ADD #18 LTH ?&go-next
prev-page BRK &go-next next-page BRK
2024-05-26 22:35:57 -04:00
@on-frame ( -> )
[ LIT2 &last $1 &f $1 ] INCk ,&f STR
2024-05-28 11:36:49 -04:00
#05 SFT DUP ,&last STR
EQU ?{ <draw-note> }
BRK
2024-05-26 22:35:57 -04:00
(
@|editor )
@insert ( char -- )
2024-05-28 11:36:49 -04:00
get-from scap/ get-page #1000 ADD2 LTH2 ?{ POP JMP2r }
2024-05-28 11:27:26 -04:00
( | convert linebreaks )
2024-05-28 11:36:49 -04:00
DUP #0d EQU #03 MUL SUB .selection/length LDZ2 #0000 EQU2 ?{ erase-selection }
get-from STH2k #0001 SUB2 get-eof #0001 <msfr>
2024-05-26 22:35:57 -04:00
STH2kr STA
2024-05-28 11:36:49 -04:00
STH2r INC2 <select-from>
!file-save
2024-05-26 22:35:57 -04:00
@erase ( -- )
2024-05-28 11:36:49 -04:00
.selection/length LDZ2 #0000 EQU2 ?{ erase-selection !<select-reset> }
get-from get-page NEQ2 [ JMP JMP2r ] get-from #0001 SUB2 DUP2 cut-char <select-from>
!file-save
2024-05-26 22:35:57 -04:00
@erase-selection ( -- )
2024-05-28 11:36:49 -04:00
get-from get-eof .selection/length LDZ2 <msfl>
!file-save
2024-05-26 22:35:57 -04:00
@delete ( -- )
2024-05-28 11:36:49 -04:00
get-eof get-from SUB2 ORA #01 [ JCN JMP2r ] .selection/length LDZ2 #0000 EQU2 ?{ erase-selection !<select-reset> }
get-from cut-char <redraw>
!file-save
2024-05-26 22:35:57 -04:00
@get-eof ( -- addr* )
2024-05-28 11:36:49 -04:00
get-page !scap/
2024-05-26 22:35:57 -04:00
@cut-char ( addr* -- )
2024-05-28 11:36:49 -04:00
get-eof #0001 !<msfl>
2024-05-26 22:35:57 -04:00
(
@|selection )
2024-05-28 11:36:49 -04:00
@<select-variable> ( addr* -- )
[ LIT2 04 -Controller/button ] DEI AND ?<select-to>
!<select-from>
2024-05-26 22:35:57 -04:00
2024-05-28 11:36:49 -04:00
@<select-reset> ( -- )
2024-05-26 22:35:57 -04:00
get-from
2024-05-28 11:36:49 -04:00
( >> )
2024-05-26 22:35:57 -04:00
2024-05-28 11:36:49 -04:00
@<select-from> ( addr* -- )
clamp-selection DUP2 .selection/a STZ2
2024-05-26 22:35:57 -04:00
.selection/b STZ2
2024-05-28 11:36:49 -04:00
!select
2024-05-26 22:35:57 -04:00
2024-05-28 11:36:49 -04:00
@<select-to> ( addr* -- )
clamp-selection .selection/b STZ2
!select
2024-05-26 22:35:57 -04:00
2024-05-28 11:36:49 -04:00
@<select-word> ( addr* -- )
DUP2 &back #0001 SUB2 LDAk #20 GTH ?&back
INC2 .selection/a STZ2
&next INC2 LDAk #20 GTH ?&next
.selection/b STZ2
!select
2024-05-26 22:35:57 -04:00
2024-05-28 11:36:49 -04:00
@<select-all> ( -- )
get-page DUP2 .selection/a STZ2
scap/ #0001 SUB2 .selection/b STZ2
( >> )
2024-05-26 22:35:57 -04:00
@select ( -- )
get-to get-from SUB2 .selection/length STZ2
#00 ;on-frame/f STA
2024-05-28 11:36:49 -04:00
!<redraw>
2024-05-26 22:35:57 -04:00
2024-05-28 11:36:49 -04:00
@<select-left> ( -- )
.selection/length LDZ2 #0000 EQU2 [ LIT2 04 -Controller/button ] DEI AND #00 NEQ ORA ?{ get-from !<select-from> }
.selection/b LDZ2 #0001 SUB2 !<select-variable>
2024-05-26 22:35:57 -04:00
2024-05-28 11:36:49 -04:00
@<select-right> ( -- )
.selection/length LDZ2 #0000 EQU2 [ LIT2 04 -Controller/button ] DEI AND #00 NEQ ORA ?{ get-to !<select-from> }
.selection/b LDZ2 INC2 !<select-variable>
2024-05-26 22:35:57 -04:00
@get-from ( -- addr* )
2024-05-28 11:36:49 -04:00
.selection/b LDZ2 .selection/a LDZ2 LTH2k [ JMP SWP2 POP2 ] JMP2r
2024-05-26 22:35:57 -04:00
@get-to ( -- addr* )
2024-05-28 11:36:49 -04:00
.selection/a LDZ2 .selection/b LDZ2 GTH2k [ JMP SWP2 POP2 ] JMP2r
2024-05-26 22:35:57 -04:00
@clamp-selection ( addr* -- addr* )
( min ) get-page GTH2k [ JMP SWP2 POP2 ]
2024-05-28 11:36:49 -04:00
( max ) get-eof #0001 SUB2 LTH2k [ JMP SWP2 POP2 ] JMP2r
2024-05-26 22:35:57 -04:00
@is-selected ( addr* -- addr* f )
DUP2 get-from LTH2 ?&false
DUP2 get-to #0001 SUB2 GTH2 ?&false
2024-05-28 11:36:49 -04:00
#01 JMP2r
2024-05-26 22:35:57 -04:00
&false #00 JMP2r
(
@|file )
@file-init ( -- )
2024-05-28 11:41:49 -04:00
;notepad-path file-size #0000 EQU2 ?file-new
2024-05-28 11:27:26 -04:00
( | load file )
2024-05-28 11:41:49 -04:00
;notepad-path .File/name DEO2
2024-05-26 22:35:57 -04:00
#8000 .File/length DEO2
;mem .File/read DEO2
2024-05-28 11:36:49 -04:00
JMP2r
2024-05-26 22:35:57 -04:00
@file-new ( -- )
#0801
2024-05-28 11:30:44 -04:00
&>l ( -- )
2024-05-28 11:36:49 -04:00
#00 OVR #c0 SFT2 ;mem ADD2 STH2
#20 STH2r STA
2024-05-28 11:30:44 -04:00
INC GTHk ?&>l
2024-05-28 11:36:49 -04:00
POP2 JMP2r
2024-05-26 22:35:57 -04:00
@file-save ( -- )
2024-05-28 11:41:49 -04:00
;notepad-path .File/name DEO2
2024-05-26 22:35:57 -04:00
#8000 .File/length DEO2
;mem .File/write DEO2
2024-05-28 11:36:49 -04:00
JMP2r
2024-05-26 22:35:57 -04:00
@file-size ( path* -- size* )
.File/name DEO2
#0001 .File/length DEO2
[ LIT2r 0000 ]
2024-05-28 11:30:44 -04:00
&>s ( -- )
2024-05-26 22:35:57 -04:00
;&b .File/read DEO2
2024-05-28 00:07:01 -04:00
[ LIT2 00 -File/success-lb ] DEI EQU ?&eof
2024-05-28 11:36:49 -04:00
INC2r !&>s
&eof STH2r JMP2r
2024-05-26 22:35:57 -04:00
&b $1
@file-inject ( name* -- )
2024-05-28 11:36:49 -04:00
DUP2 file-size ORAk ?{ POP2 POP2 JMP2r }
STH2
2024-05-26 22:35:57 -04:00
.File/name DEO2
STH2kr .File/length DEO2
2024-05-28 11:27:26 -04:00
( | erase when selection length )
2024-05-28 11:25:16 -04:00
.selection/length LDZ2 #0000 EQU2 ?{
2024-05-28 11:36:49 -04:00
get-from get-eof .selection/length LDZ2 <msfl> }
( push right ) get-from #0001 SUB2 get-eof STH2kr <msfr>
2024-05-26 22:35:57 -04:00
get-from .File/read DEO2
2024-05-28 11:36:49 -04:00
get-from STH2r ADD2 !<select-from>
2024-05-26 22:35:57 -04:00
@edit-cut ( -- )
2024-05-28 11:36:49 -04:00
.selection/length LDZ2 #0001 GTH2 [ JMP JMP2r ] edit-copy erase-selection <select-reset>
!file-save
2024-05-26 22:35:57 -04:00
@edit-copy ( -- )
2024-05-28 11:41:49 -04:00
.selection/length LDZ2 #0001 GTH2 [ JMP JMP2r ] ;snarf-path .File/name DEO2
2024-05-26 22:35:57 -04:00
.selection/length LDZ2 .File/length DEO2
get-from .File/write DEO2
2024-05-28 11:36:49 -04:00
JMP2r
2024-05-26 22:35:57 -04:00
@edit-paste ( -- )
2024-05-28 11:41:49 -04:00
;snarf-path file-inject !file-save
2024-05-26 22:35:57 -04:00
(
@|core )
2024-05-28 11:36:49 -04:00
@<trap-mouse> ( -- )
.Mouse/y DEI2 DUP2 #0018 GTH2 ?{
POP2 ;on-mouse-head .Mouse/vector DEO2
JMP2r }
2024-05-28 11:25:16 -04:00
DUP2 #00d6 LTH2 ?{
2024-05-28 11:36:49 -04:00
POP2 ;on-mouse-foot .Mouse/vector DEO2
JMP2r }
POP2 ;on-mouse-body .Mouse/vector DEO2
JMP2r
2024-05-26 22:35:57 -04:00
@change-page ( id -- )
.page STZ
2024-05-28 11:36:49 -04:00
get-page scap/ #0001 SUB2 !<select-from>
2024-05-26 22:35:57 -04:00
@prev-page ( -- )
2024-05-28 11:36:49 -04:00
.page LDZ #01 SUB #07 AND !change-page
2024-05-26 22:35:57 -04:00
@next-page ( -- )
2024-05-28 11:36:49 -04:00
.page LDZ INC #07 AND !change-page
2024-05-26 22:35:57 -04:00
@pos-to-line ( y* -- line )
2024-05-28 11:36:49 -04:00
#0012 SUB2 #04 SFT2 NIP JMP2r
2024-05-26 22:35:57 -04:00
@get-position ( -- addr* )
#0008 .Screen/x DEO2
#0018 .Screen/y DEO2
2024-05-28 11:27:26 -04:00
( | walk to line )
2024-05-26 22:35:57 -04:00
.Mouse/y DEI2 pos-to-line ,&line STR
get-page
2024-05-28 11:36:49 -04:00
&>walk-line ( -- )
2024-05-26 22:35:57 -04:00
.Screen/y DEI2 pos-to-line [ LIT &line $1 ] EQU ?&end-line
2024-05-28 11:36:49 -04:00
walk-char POP INC2 LDAk ?&>walk-line
&end-line ( walk to char )
2024-05-26 22:35:57 -04:00
.Mouse/x DEI2 #0001 SUB2 ,&x STR2
2024-05-28 11:36:49 -04:00
&>walk-char ( -- )
2024-05-26 22:35:57 -04:00
.Screen/x DEI2 [ LIT2 &x $2 ] GTH2 ?&end-char
walk-char ?&end-char
2024-05-28 11:30:44 -04:00
INC2 LDAk ?&>walk-char
2024-05-28 11:36:49 -04:00
&end-char JMP2r
2024-05-26 22:35:57 -04:00
@walk-char ( addr* -- addr* lb )
2024-05-28 11:27:26 -04:00
( | wrap )
2024-05-26 22:35:57 -04:00
LDAk #20 GTH ?&no-wrap
2024-05-28 11:36:49 -04:00
DUP2 word-width .Screen/x DEI2 ADD2 #00d0 LTH2 ?&no-wrap
( | tabbed )
DUP2 find-line-start LDA2 DUP2 #093e NEQ2 ?{ POP2 #01 #0021 !<draw-linebreak> }
DUP2 #092d NEQ2 ?{ POP2 #01 #0022 !<draw-linebreak> }
POP2 #01 #0008 !<draw-linebreak>
&no-wrap ( char )
LDAk char-width .Screen/x DEI2 ADD2 .Screen/x DEO2
2024-05-28 11:27:26 -04:00
( | tab )
2024-05-28 11:36:49 -04:00
LDAk #09 NEQ ?{ #00 !<draw-tab> }
2024-05-28 11:27:26 -04:00
( | linebreak )
2024-05-28 11:36:49 -04:00
LDAk #0a NEQ ?{ #01 #0008 !<draw-linebreak> }
#00 JMP2r
2024-05-26 22:35:57 -04:00
@get-page ( -- addr* )
2024-05-28 11:36:49 -04:00
;mem [ LIT2 00 -page ] LDZ #c0 SFT2 ADD2 JMP2r
2024-05-26 22:35:57 -04:00
2024-05-27 23:12:52 -04:00
@char-addr ( prev char -- addr* )
2024-05-26 22:35:57 -04:00
DUP #7e GTH ?&missing
DUP #20 LTH ?&blank
2024-05-28 00:07:01 -04:00
DUP2 #0a3e EQU2 ?&marker
2024-05-27 23:12:52 -04:00
DUP2 #093e EQU2 ?&marker
2024-05-27 23:38:21 -04:00
DUP2 #092d EQU2 ?&bullet
2024-05-28 11:36:49 -04:00
NIP #20 SUB #00 SWP #50 SFT2 ;font/glyphs ADD2 JMP2r
2024-05-27 23:12:52 -04:00
&blank POP2 ;font/glyphs JMP2r
&missing POP2 ;error-icn JMP2r
&marker POP2 ;marker-icn JMP2r
2024-05-27 23:38:21 -04:00
&bullet POP2 ;bullet-icn JMP2r
2024-05-26 22:35:57 -04:00
@char-width ( char -- width* )
2024-05-28 11:36:49 -04:00
DUP #7e GTH ?{
#20 SUB #00 SWP ;font ADD2 LDA #00 SWP JMP2r }
POP #0008 JMP2r
2024-05-26 22:35:57 -04:00
@word-width ( str* -- length* )
[ LIT2r 0000 ]
2024-05-28 11:30:44 -04:00
&>w ( -- )
2024-05-28 11:36:49 -04:00
LDAk char-width STH2
ADD2r INC2 LDAk #20 GTH ?&>w
POP2 STH2r JMP2r
2024-05-26 22:35:57 -04:00
@find-line-start ( addr* -- addr* )
;mem SWP2
2024-05-28 11:30:44 -04:00
&>l ( -- )
2024-05-28 11:36:49 -04:00
#0001 SUB2 LDAk DUP #0a EQU SWP #00 EQU ORA ?&end
2024-05-28 11:30:44 -04:00
LTH2k ?&>l
2024-05-28 11:36:49 -04:00
&end NIP2 INC2 JMP2r
2024-05-26 22:35:57 -04:00
@find-line-end ( addr* -- addr* )
get-eof SWP2
2024-05-28 11:30:44 -04:00
&>l ( -- )
2024-05-26 22:35:57 -04:00
LDAk #0a EQU ?&end
2024-05-27 23:25:39 -04:00
LDAk #00 EQU ?&end
2024-05-28 11:30:44 -04:00
INC2 GTH2k ?&>l
2024-05-28 11:36:49 -04:00
&end NIP2 JMP2r
2024-05-26 22:35:57 -04:00
@find-word-start ( addr* -- addr* )
;mem SWP2
2024-05-28 11:30:44 -04:00
&>l ( -- )
2024-05-26 22:35:57 -04:00
#0001 SUB2 LDAk #21 LTH ?&end
2024-05-28 11:30:44 -04:00
LTH2k ?&>l
2024-05-28 11:36:49 -04:00
&end NIP2 INC2 JMP2r
2024-05-26 22:35:57 -04:00
@find-word-end ( addr* -- addr* )
get-eof SWP2
2024-05-28 11:30:44 -04:00
&>l ( -- )
2024-05-26 22:35:57 -04:00
LDAk #21 LTH ?&end
2024-05-28 11:30:44 -04:00
INC2 GTH2k ?&>l
2024-05-28 11:36:49 -04:00
&end NIP2 JMP2r
2024-05-26 22:35:57 -04:00
(
@|drawing )
2024-05-28 11:36:49 -04:00
@<draw-header> ( -- )
2024-05-28 11:27:26 -04:00
( | a )
2024-05-28 11:36:49 -04:00
#0000 DUP2 .Screen/x DEO2
.Screen/y DEO2
2024-05-26 22:35:57 -04:00
[ LIT2 15 -Screen/auto ] DEO
;bar-icn/a .Screen/addr DEO2
[ LIT2 01 -Screen/sprite ] DEO
2024-05-28 11:27:26 -04:00
( | close )
2024-05-28 11:36:49 -04:00
;close-icn #00 [ LIT2 00 -Mouse/state ] DEI NEQ .Mouse/x DEI2 #0008 SUB2 #000a LTH2 AND #50 SFT2 ADD2 .Screen/addr DEO2
2024-05-26 22:35:57 -04:00
[ LIT2 01 -Screen/sprite ] DEOk DEO
2024-05-28 11:27:26 -04:00
( | lead )
2024-05-28 11:36:49 -04:00
#e9
&>l ( -- )
2024-05-26 22:35:57 -04:00
;bar-icn/b .Screen/addr DEO2
[ LIT2 01 -Screen/sprite ] DEO
2024-05-28 11:30:44 -04:00
INC DUP ?&>l
2024-05-28 11:36:49 -04:00
POP ;bar-icn/b .Screen/addr DEO2
2024-05-26 22:35:57 -04:00
[ LIT2 01 -Screen/sprite ] DEOk DEO
2024-05-28 11:27:26 -04:00
( | title )
2024-05-26 22:35:57 -04:00
#004b .Screen/x DEO2
[ LIT2 86 -Screen/auto ] DEO
;title-icn .Screen/addr DEO2
[ LIT2 01 -Screen/sprite ] DEOk DEO
2024-05-28 11:27:26 -04:00
( | line )
2024-05-26 22:35:57 -04:00
[ LIT2 d2 -Screen/auto ] DEO
#0000 .Screen/x DEO2
#0010 .Screen/y DEO2
;line-icn .Screen/addr DEO2
[ LIT2 01 -Screen/sprite ] DEO
#0070 .Screen/x DEO2
#0010 .Screen/y DEO2
[ LIT2 01 -Screen/sprite ] DEO
2024-05-28 11:36:49 -04:00
JMP2r
2024-05-26 22:35:57 -04:00
2024-05-28 11:36:49 -04:00
@<redraw> ( -- )
2024-05-26 22:35:57 -04:00
#0000 .Screen/x DEO2
#0018 .Screen/y DEO2
[ LIT2 80 -Screen/pixel ] DEO
2024-05-28 11:27:26 -04:00
( >> )
2024-05-26 22:35:57 -04:00
2024-05-28 11:36:49 -04:00
@<draw-note> ( -- )
2024-05-26 22:35:57 -04:00
[ LIT2 15 -Screen/auto ] DEO
#0008 .Screen/x DEO2
#0018 .Screen/y DEO2
get-page
2024-05-28 11:30:44 -04:00
&>w ( -- )
2024-05-28 11:27:26 -04:00
( | draw char )
2024-05-27 23:12:52 -04:00
DUP2 #0001 SUB2 LDA2 char-addr .Screen/addr DEO2
2024-05-28 11:36:49 -04:00
is-selected STH
#0701 STHr [ JMP SWP POP ] .Screen/sprite DEOk DEO
2024-05-26 22:35:57 -04:00
.Screen/x DEI2k #0010 SUB2 ROT DEO2
2024-05-28 11:27:26 -04:00
( | draw selector )
2024-05-26 22:35:57 -04:00
get-from get-to NEQ2 ?&block
DUP2 get-from NEQ2 ?&block
;on-frame/last LDA #01 AND ?&block
2024-05-28 11:36:49 -04:00
;blink-icn .Screen/addr DEO2
[ LIT2 05 -Screen/sprite ] DEO
.Screen/x DEI2k #0008 SUB2 ROT DEO2
&block walk-char POP INC2 LDAk ?&>w
2024-05-26 22:35:57 -04:00
POP2
2024-05-28 11:36:49 -04:00
@<draw-footer> ( -- )
.Screen/height DEI2 #0020 GTH2 ?{ JMP2r }
2024-05-26 22:35:57 -04:00
[ LIT2 26 -Screen/auto ] DEO
#0000 .Screen/x DEO2
.Screen/height DEI2 #0020 SUB2 .Screen/y DEO2
;page-icn .Screen/addr DEO2
[ LIT2 01 -Screen/sprite ] DEOk DEOk DEOk DEO
2024-05-28 11:27:26 -04:00
( | across )
2024-05-26 22:35:57 -04:00
[ LIT2 01 -Screen/auto ] DEO
#0018 .Screen/x DEO2
.Screen/height DEI2 #0008 SUB2 .Screen/y DEO2
;page-icn/bottom .Screen/addr DEO2
2024-05-28 11:36:49 -04:00
#e7
&>l ( -- )
2024-05-26 22:35:57 -04:00
[ LIT2 01 -Screen/sprite ] DEO
2024-05-28 11:30:44 -04:00
INC DUP ?&>l
2024-05-26 22:35:57 -04:00
POP
2024-05-28 11:27:26 -04:00
( | page number )
2024-05-26 22:35:57 -04:00
[ LIT2 15 -Screen/auto ] DEO
.Screen/width DEI2 #01 SFT2 #0003 SUB2 .Screen/x DEO2
.Screen/height DEI2 #0020 SUB2 .Screen/y DEO2
#0011 .page LDZ ADD #50 SFT2 ;font/glyphs ADD2 .Screen/addr DEO2
[ LIT2 01 -Screen/sprite ] DEOk DEO
2024-05-28 11:36:49 -04:00
JMP2r
2024-05-26 22:35:57 -04:00
2024-05-28 11:36:49 -04:00
@<draw-tab> ( -- )
2024-05-26 22:35:57 -04:00
.Screen/x DEI2k #0010 ADD2 #33 SFT2 ROT DEO2
2024-05-28 11:36:49 -04:00
JMP2r
2024-05-26 22:35:57 -04:00
2024-05-28 11:36:49 -04:00
@<draw-linebreak> ( x* -- )
2024-05-27 23:25:39 -04:00
.Screen/x DEO2
2024-05-26 22:35:57 -04:00
.Screen/y DEI2k #0010 ADD2 ROT DEO2
2024-05-28 11:36:49 -04:00
JMP2r
2024-05-26 22:35:57 -04:00
2024-05-28 11:36:49 -04:00
@<update-cursor> ( color addr* -- )
2024-05-26 22:35:57 -04:00
[ LIT2 15 -Screen/auto ] DEO
;fill-icn .Screen/addr DEO2
2024-05-28 11:36:49 -04:00
#40 <draw-cursor>
.Mouse/x DEI2 ,<draw-cursor>/x STR2
.Mouse/y DEI2 ,<draw-cursor>/y STR2
2024-05-26 22:35:57 -04:00
.Screen/addr DEO2
2024-05-27 23:12:52 -04:00
( >> )
2024-05-26 22:35:57 -04:00
2024-05-28 11:36:49 -04:00
@<draw-cursor> ( color -- )
2024-05-26 22:35:57 -04:00
[ LIT2 &x $2 ] .Screen/x DEO2
[ LIT2 &y $2 ] .Screen/y DEO2
.Screen/sprite DEO
2024-05-28 11:36:49 -04:00
JMP2r
2024-05-26 22:35:57 -04:00
(
@|stdlib )
2024-05-28 00:07:01 -04:00
@scap ( str* -- end* )
&>w ( -- )
INC2 & LDAk ?&>w
JMP2r
2024-05-27 23:12:52 -04:00
@<phex> ( short* -: )
SWP /b
&b ( byte -: )
2024-05-28 11:36:49 -04:00
DUP #04 SFT /c
2024-05-27 23:12:52 -04:00
&c ( byte -: )
2024-05-28 11:36:49 -04:00
#0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD #18 DEO
JMP2r
2024-05-27 23:12:52 -04:00
2024-05-26 22:35:57 -04:00
@load-theme ( -- )
2024-05-28 11:41:49 -04:00
;theme-path .File/name DEO2
2024-05-26 22:35:57 -04:00
#0002 .File/length DEO2
;&r .File/read DEO2
;&g .File/read DEO2
;&b .File/read DEO2
2024-05-28 00:07:01 -04:00
[ LIT2 00 -File/success-lb ] DEI EQU ?{
[ LIT2 &r $2 ] .System/r DEO2
[ LIT2 &g $2 ] .System/g DEO2
2024-05-28 11:36:49 -04:00
[ LIT2 &b $2 ] .System/b DEO2 }
JMP2r
2024-05-26 22:35:57 -04:00
2024-05-28 11:36:49 -04:00
@<msfl> ( b* a* len* -- )
STH2
SWP2 EQU2k ?&e
&>l ( -- )
DUP2k STH2kr ADD2 LDA ROT ROT STA
INC2 GTH2k ?&>l
POP2 POP2 &e POP2r JMP2r
2024-05-28 00:07:01 -04:00
2024-05-28 11:36:49 -04:00
@<msfr> ( b* a* len* -- )
STH2
EQU2k ?&e
&>l ( -- )
DUP2 LDAk ROT ROT STH2kr ADD2 STA
#0001 SUB2 LTH2k ?&>l
POP2 POP2 &e POP2r JMP2r
2024-05-26 22:35:57 -04:00
2024-05-28 11:41:49 -04:00
(
@|strings )
@snarf-path ".snarf $1
@theme-path ".theme $1
@notepad-path ".notepad $1
2024-05-26 22:35:57 -04:00
~src/assets.tal