speed up embedding, download dialog

This commit is contained in:
Jeremy Penner 2023-10-15 21:05:54 -04:00
parent 57f2f4b3d3
commit 314ee8b476
14 changed files with 104 additions and 61 deletions

View file

@ -86,7 +86,8 @@ array patchtable 10 2 cells * allot
: L! [ ' ' , ] 2 cells + target swap ! ; : L! [ ' ' , ] 2 cells + target swap ! ;
array anonlabels 10 cells allot array anonlabels 10 cells allot
: <@ ( labelid -- ) cells anonlabels + @ @+ ; : L<@ ( labelid -- addr ) cells anonlabels + @ ;
: <@ ( labelid -- ) L<@ @+ ;
: :> ( labelid -- ) cells anonlabels + target swap ! ; : :> ( labelid -- ) cells anonlabels + target swap ! ;
: memreg create , does> @ oparg-base ! oparg-complete! ; : memreg create , does> @ oparg-base ! oparg-complete! ;

Binary file not shown.

View file

@ -5,9 +5,7 @@ s" asm.jrt" loadfile
:init segalloc ' comseg redefine ; :init segalloc ' comseg redefine ;
: writecom ( filename -- ) : writecom ( filename -- )
overwrite >r 0x100 overwrite >r target 0x100 - 0x100 r@ comseg farfwrite <r close ;
begin dup target < while dup b@t r@ fputc 1+ repeat
drop <r close ;
: writeself overwrite >r here 0x100 - 0x100 r@ fwrite <r close ; : writeself overwrite >r here 0x100 - 0x100 r@ fwrite <r close ;
s" assemble.com" writeself s" assemble.com" writeself

Binary file not shown.

View file

@ -1,4 +1,4 @@
1 var, quiet 0 var, quiet
0 var, quick 0 var, quick
: quiet? quiet @ quick @ or ; : quick? quick @ ; : quiet? quiet @ quick @ or ; : quick? quick @ ;
@ -149,7 +149,7 @@ import embed.jrt
{ : deffile ( filename desc file sizer writer ) ARRAY w>t w>t w>t w>t w>t ; { : deffile ( filename desc file sizer writer ) ARRAY w>t w>t w>t w>t w>t ;
: defembed ( filename desc -- ) : defembed ( filename desc -- )
over [ tdict-lookup open drop , ] filebytes target embed-bytes over T] open target swap embed-file
t' embed-size t' embed-write deffile ; t' embed-size t' embed-write deffile ;
: deffake ( filename desc size -- ) t' noop t' rand-write deffile ; } : deffake ( filename desc size -- ) t' noop t' rand-write deffile ; }
@ -160,8 +160,54 @@ import embed.jrt
: write-file ( file -- ) : write-file ( file -- )
dup filename overwrite >r r@ over filedata <rot @ execute <r close ; dup filename overwrite >r r@ over filedata <rot @ execute <r close ;
: snapshot 1 0 pagecopy ; : restore 0 1 pagecopy ;
: xmit-desc ( st -- )
chars (( each i [ key \ lit ] = if nl else pass then next ))
xmit-iter ;
array numstr 7 allot
key 0 const $0
: char>> ( st ch -- st+1 ) over b! 1+ ;
: digit>> ( st state n div -- st state n )
/mod swap dup if ( st state n digit )
$0 + >r <rot <r char>> ( state n st )
<rot drop 1 <rot
else drop over if <rot $0 char>> >rot then then ;
: nsep>> ( st state n -- st state n )
over if <rot [ key , lit ] char>> >rot then ;
: n>st ( n -- st )
numstr 0 <rot
10000 digit>> 1000 digit>> nsep>> 100 digit>> 10 digit>>
swap drop $0 + char>> 0 char>> drop numstr ;
: draw-download-progress ( size progress -- )
12 12 textxy! dup n>st draw-text
swap 40 / / 20 12 textxy! 0xb2 draw-hrepeat ;
: download-file ( file -- ) dup write-file
>r textstate <r snapshot green bg! white fg! 1 boxstyle!
10 10 textxy! 60 4 filled draw-box
12 11 textxy! s" Downloading " draw-text dup filename draw-text
filesize 0 62 12 textxy! over n>st draw-text
20 12 textxy! 40 0xb0 draw-hrepeat
2dup draw-download-progress
30 delay
begin 15 delay 256 rand 0x1f & + + 2dup > while
2dup draw-download-progress repeat
drop dup draw-download-progress 60 delay restore textstate! ;
dbg" BBSes" dbg" BBSes"
: tolower ( ch -- ch )
dup [ key A lit ] >= over [ key Z lit ] <= and
if [ key a key A - lit ] + then ;
: readch ( -- ch )
begin sleep-key key>ch dup printable? not while drop repeat ;
: inputch readch tolower dup emit nl ;
: xmit-screen ( rle -- ) : xmit-screen ( rle -- )
rle-decode textpen @ rle-decode textpen @
(( each i 8 >> textpen ! pass next )) xmit-iter (( each i 8 >> textpen ! pass next )) xmit-iter
@ -171,8 +217,6 @@ dbg" BBSes"
import rick.jrt import rick.jrt
dbg" menu" dbg" menu"
: snapshot 1 0 pagecopy ; : restore 0 1 pagecopy ;
var menu-onclose var menu-onclose
: close-menu ( cp -- ) menu-onclose ! restore suspend ; : close-menu ( cp -- ) menu-onclose ! restore suspend ;
: menu-options (( : menu-options ((
@ -307,5 +351,5 @@ var curr-logobit
' go ' main redefine ' go ' main redefine
dbg" saving" dbg" saving"
{ here s", dialer.com" s" dialtest.com" writeenv }
{ s" dialer.com" writecom }

BIN
dialtest.com Executable file

Binary file not shown.

View file

@ -35,12 +35,14 @@ var rle-run
: encode-rle ( call with iterator that returns bytes ) : encode-rle ( call with iterator that returns bytes )
>rle-start each i iterate if i 8 << | >rle else drop then next >rle-done ; >rle-start each i iterate if i 8 << | >rle else drop then next >rle-done ;
: embed-rle ( host-filename -- ) open filebytes encode-rle ; : embed-rle ( host-filename -- ) open filebytes encode-rle ;
: embed-bytes ( -- ) target 0 w>t each i >t next target swap !t ; : embed-file ( fp -- )
: embed ( host-filename -- ) open filebytes embed-bytes ; >r target 0 w>t 0xffff target r@ T] fread <r close
T] fcount @t target + target! target swap !t ;
: embed ( host-filename -- ) open embed-file ;
} }
: embed-size ( embed -- v ) dup @ swap - ;
: embed-data ( embed -- p ) cell + ; : embed-data ( embed -- p ) cell + ;
: embed-size ( embed -- v ) dup @ swap embed-data - ;
: rle-decode ( p -- ) : rle-decode ( p -- )
>arg (( dup @ swap cell + +arg ( pend p ) >arg (( dup @ swap cell + +arg ( pend p )

View file

@ -55,24 +55,36 @@
NEXT NEXT
0 VAR, fcount 0 VAR, fcount
:ASM fread :ASM farfread
POP DS ( seg )
0 :>
MOV AH 0x3f # MOV AH 0x3f #
POP BX ( fp ) POP BX ( fp )
POP DX ( buffer ) POP DX ( buffer )
POP CX ( length ) POP CX ( length )
INT 0x21 # INT 0x21 #
MOV BX CS
MOV DS BX
MOV t& fcount @+ AX ( save number of bytes read ) MOV t& fcount @+ AX ( save number of bytes read )
NEXT NEXT
:ASM fwrite DEF fread 0 L<@ w>t
:ASM farfwrite
POP DS ( seg )
0 :>
MOV AH 0x40 # MOV AH 0x40 #
POP BX ( fp ) POP BX ( fp )
POP DX ( buffer ) POP DX ( buffer )
POP CX ( length ) POP CX ( length )
INT 0x21 # INT 0x21 #
MOV BX CS
MOV DS BX
MOV t& fcount @+ AX ( save number of bytes written ) MOV t& fcount @+ AX ( save number of bytes written )
NEXT NEXT
DEF fwrite 0 L<@ w>t
-1 CONST EOF -1 CONST EOF
0 VAR, fbuffer 0 VAR, fbuffer
:t fgetc ( fp -- c ) :t fgetc ( fp -- c )

BIN
jort.com

Binary file not shown.

View file

@ -1,76 +1,60 @@
dbg" Rick's Clubhouse BBS"
array rick-welcome-rle array rick-welcome-rle
{ s" rickclub.bin" open filebytes 18 lines-of encode-rle } { s" rickclub.bin" open filebytes 18 lines-of encode-rle }
array rick-menu-rle array rick-menu-rle
{ s" rickmenu.bin" open filebytes 7 lines-of encode-rle } { s" rickmenu.bin" open filebytes 7 lines-of encode-rle }
dbg" login"
: login : login
l" To login as a guest, leave your name blank." l" To login as a guest, leave your name blank."
begin begin
x" Enter your name: " readline nl x" Enter your name: " readline nl
dup b@ while x" Sorry, I don't recognize " xmit l" !" nl dup b@ while x" Sorry, I don't recognize " xmit l" !" nl
repeat nl repeat nl
cyan fg!
l" Welcome, guest! We hope you decide to apply for a full membership." l" Welcome, guest! We hope you decide to apply for a full membership."
l" Guest accounts have limited access." l" Guest accounts have limited access."
l" If you have any questions, feel free to page the sysop - I'll be happy" l" If you have any questions, feel free to page the sysop - I'll be happy"
l" to chat with you if I'm around!" l" to chat with you if I'm around!"
l" -- Rick" nl ; l" -- Rick" nl ;
: tolower ( ch -- ch )
dup [ key A lit ] >= over [ key Z lit ] <= and
if [ key a key A - lit ] + then ;
: readch ( -- ch )
begin sleep-key key>ch dup printable? not while drop repeat ;
deferred rick-menu noop deferred rick-menu noop
: page-rick : page-rick
l" Paging Sysop........" x" Paging Sysop..."
500 delay 5 times each 100 delay [ key . lit ] emit next nl
l" Sorry, guess he's not home!" l" Sorry, guess they're not home!"
' rick-menu ; ' rick-menu ;
dbg" swine.com" s" swine.com" dbg" files"
s" swine.com"
s" Swine Meeper - A fun freeware puzzler. Find all the truffles!" s" Swine Meeper - A fun freeware puzzler. Find all the truffles!"
defembed swine.com defembed swine.com
dbg" dirtrect.com" s" dirtrect.com" s" dirtrect.com"
s" Dirty Rectangles - A simple textmode graphics demo" s" A simple textmode graphics demo advertising the game development collective\called Dirty Rectangles."
defembed dirtrect.com defembed dirtrect.com
dbg" kpshrink4.kps" s" kpshrink4.kps" s" assemble.com"
s" I think this is an 8086 assembler, but I don't have any documentation for\it and it doesn't use a standard syntax. Some kind of Forth system?"
defembed assemble.com
(
s" kpshrink4.kps"
s" KP Shrinker 4.0 - Compressor and decompressor for KPS files\Requires an earlier version of PK Shrinker to extract." s" KP Shrinker 4.0 - Compressor and decompressor for KPS files\Requires an earlier version of PK Shrinker to extract."
59943 deffake kpshrink4.kps 59943 deffake kpshrink4.kps
dbg" mazecr3d.kps" s" mazecr3d.kps" s" mazecr3d.kps"
s" Maze Crazy 3D - Explore a fascinating maze filled with twists and turns\in 3 incredible dimensions! Includes instructions for building a PC adapter\for the Virtua Glove." s" Maze Crazy 3D - Explore a fascinating maze filled with twists and turns\in 3 incredible dimensions! Includes instructions for building a PC adapter\for the Virtua Glove."
48371 deffake mazecr3d.kps 48371 deffake mazecr3d.kps
)
: rick-filelist (( : rick-filelist ((
kpshrink4.kps yield
dirtrect.com yield
mazecr3d.kps yield
swine.com yield swine.com yield
dirtrect.com yield
assemble.com yield
)) ; )) ;
: xmit-desc ( st -- )
chars (( each i [ key \ lit ] = if nl else pass then next ))
xmit-iter ;
array numstr 7 allot
key 0 const $0
: char>> ( st ch -- st+1 ) over b! 1+ ;
: digit>> ( st state n div -- st state n )
/mod swap dup if ( st state n digit )
$0 + >r <rot <r char>> ( state n st )
<rot drop 1 <rot
else drop over if <rot $0 char>> >rot then then ;
: nsep>> ( st state n -- st state n )
over if <rot [ key , lit ] char>> >rot then ;
: n>st ( n -- st )
numstr 0 <rot
10000 digit>> 1000 digit>> nsep>> 100 digit>> 10 digit>>
swap drop $0 + char>> 0 char>> drop numstr ;
: list-files 1 each : list-files 1 each
blue bg! yellow fg! x" [" dup .digit x" ]" blue bg! yellow fg! x" [" dup .digit x" ]"
lcyan fg! black bg! sp emit i filename xmit lcyan fg! black bg! sp emit i filename xmit
@ -78,20 +62,20 @@ key 0 const $0
lgray fg! nl i filedesc xmit-desc nl lgray fg! nl i filedesc xmit-desc nl
nl 1+ next drop ; nl 1+ next drop ;
: inputch readch tolower dup emit nl ;
: download-file ( file -- ) write-file ; ( todo: more elaborate )
: select-file : select-file
x" Type the number of a file, or Q to return to the menu: " inputch x" Type the number of a file, or Q to return to the menu: " inputch
dup [ key q lit ] = if drop ' rick-menu return then dup [ key q lit ] = if drop ' rick-menu return then
[ key 1 lit ] - dup 0 >= over rick-filelist count < and if [ key 1 lit ] - dup 0 >= over rick-filelist count < and if
rick-filelist nth rick-filelist nth
lblue fg! x" Downloading " dup filename xmit l" ..." lblue fg! x" Downloading " dup filename xmit l" ..."
download-file l" Done!" ' rick-menu return then download-file l" Done!" else
drop lred fg! l" Sorry, that is not a valid selection." ' select-file ; drop lred fg! l" Sorry, that is not a valid selection." then
' select-file ;
: rick-files nl rick-filelist list-files ' select-file ; : rick-files nl rick-filelist list-files ' select-file ;
dbg" menu"
:noname ( -- cp ) :noname ( -- cp )
nl rick-menu-rle xmit-screen nl nl rick-menu-rle xmit-screen nl
0 begin 0 begin

Binary file not shown.

Binary file not shown.

View file

@ -39,6 +39,7 @@ array $DOFAR
asm-com asm-com
: tdict-lookup word tdict dict-lookup ; : tdict-lookup word tdict dict-lookup ;
: T] tdict-lookup not if err return then state if , then ; immediate
: te tdict-lookup interpretword ; immediate : te tdict-lookup interpretword ; immediate
: tlookup ( -- tcp ) tdict-lookup not if dup err then cell + @ ; : tlookup ( -- tcp ) tdict-lookup not if dup err then cell + @ ;
: t' tlookup interpretnumber ; immediate : t' tlookup interpretnumber ; immediate
@ -144,20 +145,21 @@ dbg" CREATE"
var comfilename var comfilename
: readcom ( filename ) open 0x100 target! : readcom ( filename ) open >r
begin dup fgetc dup EOF != while >t repeat drop close ; 0x100 0xffff over r@ comseg farfread
fcount @ + target! <r close ;
DEFERRED init noop DEFERRED init noop
DEFERRED main noop DEFERRED main noop
DEFERRED cleanup noop DEFERRED cleanup noop
tdict-lookup cleanup drop ' cleanup redefine T] cleanup ' cleanup redefine
:init :init
( we write a fake all-null PSP so openself can fail gracefully ) ( we write a fake all-null PSP so openself can fail gracefully )
0 target! 0xff ALLOT 0 target! 0xff ALLOT
comfilename @ readcom } comfilename @ readcom }
[ tdict-lookup init drop , ] ; T] init ;
: writeenv ( comfile wrapper -- ) : writeenv ( comfile wrapper -- )
swap comfilename ! swap comfilename !
@ -180,7 +182,7 @@ dbg" boot"
} import common.jrt { } import common.jrt {
tdict-lookup init drop execute T] init execute
here s", zipstub.seg" s" zipoff.com" writeenv here s", zipstub.seg" s" zipoff.com" writeenv

Binary file not shown.