Compare commits

..

No commits in common. "85f3767e1e834ea04eda5d1a42d6b9a764608985" and "c0dec444a4b84750542f9227c0e889070f8292c8" have entirely different histories.

28 changed files with 136 additions and 634 deletions

View file

@ -86,8 +86,7 @@ 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
: L<@ ( labelid -- addr ) cells anonlabels + @ ; : <@ ( labelid -- ) 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,7 +5,9 @@ s" asm.jrt" loadfile
:init segalloc ' comseg redefine ; :init segalloc ' comseg redefine ;
: writecom ( filename -- ) : writecom ( filename -- )
overwrite >r target 0x100 - 0x100 r@ comseg farfwrite <r close ; overwrite >r 0x100
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

View file

@ -1,4 +1,3 @@
: 2drop drop drop ;
: !+ ( v p -- ) dup @ <rot + swap ! ; : !+ ( v p -- ) dup @ <rot + swap ! ;
: b!+ ( v p -- ) dup b@ <rot + swap b! ; : b!+ ( v p -- ) dup b@ <rot + swap b! ;
: b!| ( f p -- ) dup b@ <rot | swap b! ; : b!| ( f p -- ) dup b@ <rot | swap b! ;

Binary file not shown.

View file

@ -1,21 +1,5 @@
0 var, quiet 1 var, quiet
0 var, quick
: quiet? quiet @ quick @ or ; : quick? quick @ ;
: noisy quiet? if rdrop then ;
: slow quick? if rdrop then ;
var last-delay
: delay-base
timer @ dup last-delay @ - dup 0 >= swap 5 < and if drop last-delay @ then ;
: delay dup not quick? and if drop else
delay-base + dup last-delay !
begin dup timer @ > while suspend repeat drop
then ;
var ms-error
: ms ms-error @ + 8 /mod ms-error ! delay ;
dbg" modem sounds"
array dtmf-col 1209 freq>div , 1336 freq>div , 1477 freq>div , array dtmf-col 1209 freq>div , 1336 freq>div , 1477 freq>div ,
array dtmf-row 697 freq>div , 770 freq>div , 852 freq>div , 941 freq>div , array dtmf-row 697 freq>div , 770 freq>div , 852 freq>div , 941 freq>div ,
@ -27,6 +11,8 @@ array dtmf-row 697 freq>div , 770 freq>div , 852 freq>div , 941 freq>div ,
-2 const D* -2 const D*
-1 const D# -1 const D#
: noisy quiet @ if rdrop then ;
: dtmf ( digit -- f1 f2 ) 1- : dtmf ( digit -- f1 f2 ) 1-
dup 0 < if abs 3 % 3 swap else 3 /mod then dup 0 < if abs 3 % 3 swap else 3 /mod then
cells dtmf-col + @ swap cells dtmf-row + @ ; cells dtmf-col + @ swap cells dtmf-row + @ ;
@ -40,7 +26,7 @@ array dtmf-row 697 freq>div , 770 freq>div , 852 freq>div , 941 freq>div ,
: dialst ( st -- ) chars each i dialch next ; : dialst ( st -- ) chars each i dialch next ;
: dialtone [ 350 freq>div lit 440 freq>div lit ] 200 arp ; : dialtone [ 350 freq>div lit 440 freq>div lit ] 200 arp ;
: offhook noisy 30 sleep-csec 3 2 boop 15 sleep-csec 7 2 boop 10 sleep-csec ; : offhook 30 sleep-csec 3 2 boop 15 sleep-csec 7 2 boop 10 sleep-csec ;
2100 freq>div const carrier-div 2100 freq>div const carrier-div
980 freq>div const hs-low 980 freq>div const hs-low
@ -67,203 +53,24 @@ array dtmf-row 697 freq>div , 770 freq>div , 852 freq>div , 941 freq>div ,
45 probe-hi 50 probe-lo 15 probe-hi 60 probe-lo 60 probe-hi 45 probe-hi 50 probe-lo 15 probe-hi 60 probe-lo 60 probe-hi
300 fullduplex ; 300 fullduplex ;
dbg" statusbar" ( terminal words )
var status : fixcursor texty 8 << textx | movecursor ;
var status-timer
var status-bg
: disconnect-status
s" DISCONNECTED" status ! 0 status-timer ! magenta status-bg ! ;
: connect-status
s" CONNECTED" status ! ticks status-timer ! green status-bg ! ;
disconnect-status
: connected? status-bg @ green = ;
: space-to ( x -- ) textx - sp draw-hrepeat ;
: .digit ( v -- ) [ key 0 lit ] + draw-char ;
: .2digit ( v -- ) 10 /mod swap 10 % .digit .digit ;
: .: [ key : lit ] draw-char ;
: draw-status-timer
ticks status-timer @ - 18 / 60 /mod swap 60 /mod swap
.2digit .: .2digit .: .2digit ;
: draw-status
status-bg @ bg! white fg! 0 0 textxy!
1 space-to status @ draw-text
connected? if 70 space-to draw-status-timer
else 65 space-to s" | ESC for menu" draw-text then
80 space-to ;
: init-statusbar
:| begin textstate draw-status textstate! suspend again |;
spawn-task drop ;
dbg" terminal"
: sleep-key begin key-waiting? not while suspend repeat wait-key ;
: pause sleep-key drop ;
: fixcursor
texty 24 - dup 0 > if times each 1 24 scrollup next 24 texty! else drop then
texty 8 << textx | movecursor ;
: nl nextline fixcursor ; : nl nextline fixcursor ;
: emit draw-char fixcursor ; : emit draw-char fixcursor ;
: xmit-iter each i emit 3 ms next ; : xmit ( st -- ) chars each i emit 1 sleep-csec next ;
: xmit ( st -- ) chars xmit-iter ; : call ( st -- ) s" ATDT" xmit dup xmit nl noisy offhook dialtone dialst ;
: xmit-line xmit nl ;
: repeated ( v n -- ) times >arg (( each dup map next drop )) ;
{ :timm x" t" t, xmit ; : connect ( st -- ) call noisy 200 sleep-csec handshake ;
:timm l" t" t, xmit-line ; }
79 const MAXLINE
array linebuf MAXLINE 1+ allot
: printable? ( k -- f ) key>ch dup 0x20 >= swap 0x7e <= and ;
: bs? ( k -- f ) key>scan dup %bs = swap %left = or ;
: bs textx 1- dup textx! sp draw-char textx! fixcursor ;
: enter? ( k -- f ) key>scan %enter = ;
: readline linebuf begin sleep-key
dup enter? not while
dup printable? if over linebuf MAXLINE + <
if key>ch 2dup swap b! emit 1+ else drop then else
dup bs? if drop dup linebuf > if bs 1- then else
drop then then
repeat drop 0 swap b! linebuf ;
: call ( st -- ) white fg! x" ATDT" dup xmit-line
quiet? if drop else offhook dialtone dialst then ;
: successful-call ( st -- ) call noisy 200 sleep-csec handshake ;
: hangup ( -- ) offhook nl disconnect-status white fg! l" NO CARRIER" ;
: connect ( cp st -- )
successful-call connect-status l" CONNECT 57600" execute hangup ;
dbg" downloading"
import embed.jrt import embed.jrt
array rick-welcome-rle { s" rickclub.bin" embed-rle }
: embed-write ( fp p -- ) dup embed-size swap embed-data <rot fwrite ; : xmit-screen ( rle -- ) 0 0 textxy! rle-decode each
: rand-write ( fp size -- ) dup prngstate ! ( write the same file every time ) i 8 >> textpen ! i emit
times each rand over fputc next drop reseed! ; next ;
{ : deffile ( filename desc file sizer writer ) ARRAY w>t w>t w>t w>t w>t ; : rick-welcome rick-welcome-rle xmit-screen ;
: defembed ( filename desc -- )
over T] open target swap embed-file
t' embed-size t' embed-write deffile ;
: deffake ( filename desc size -- ) t' noop t' rand-write deffile ; }
: filename ( file -- st ) 4 cells + @ ;
: filedesc ( file -- st ) 3 cells + @ ;
: filedata ( file -- data ) 2 cells + @ ;
: filesize ( file -- n ) dup filedata swap cell + @ execute ;
: write-file ( file -- )
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"
: 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 -- )
rle-decode textpen @
(( each i 8 >> textpen ! pass next )) xmit-iter
textpen ! ;
{ : lines-of pagew 2* * take ; }
import rick.jrt
dbg" menu"
var menu-onclose
: close-menu ( cp -- ) menu-onclose ! restore suspend ;
: menu-options ((
0 s" Phone Book:" yield2
:| :| ' rick s" 5551212" connect |; close-menu |;
s" Rick's Clubhouse BBS" yield2
0 0 yield2
quiet @ if :| 0 quiet !save |; s" Enable modem sounds" yield2 else
:| 1 quiet !save |; s" Disable modem sounds" yield2 then
:| connected? if hangup then textmode exit |; s" Exit to DOS" yield2 )) ;
var selection
: option-walk ( cpstop -- )
>r selection @ 0 menu-options each
i if dup selection ! then r@ execute if break then 1+
next 2drop rdrop ;
: prev-option :| 2dup 1+ <= |; option-walk ;
: next-option :| i if 2dup < else 0 then |; option-walk ;
: choose menu-options selection @ nth execute ;
: first-option 0 selection ! next-option prev-option ;
25 const menux 7 const menuy
pagew menux 2* - const menuw
: draw-options
menux 2 + menuy 1+ textxy!
0 menu-options each
dup selection @ = if green else magenta then bg!
textx j if j draw-text then menux menuw + 2 - space-to nextline textx!
1+ next drop ;
: draw-menubox
magenta bg! white fg! 1 boxstyle!
menux menuy textxy!
menuw menu-options count 2 + filled draw-box ;
: menu-interact sleep-key key>scan
dup %enter = if choose then
dup %up = if prev-option then
dup %down = if next-option then
%esc = if ' noop close-menu then ;
: menu-loop begin draw-options menu-interact menu-onclose @ until ;
: popup-menu snapshot textstate 0 menu-onclose ! first-option
draw-menubox menu-loop textstate! menu-onclose @ execute 0 menu-onclose ! ;
dbg" startup"
{ : X ( v -- v ) 2* 1 | ; { : X ( v -- v ) 2* 1 | ;
: o ( v -- v ) 2* ; } : o ( v -- v ) 2* ; }
7 const logoh 7 const logoh
@ -335,21 +142,21 @@ var curr-logobit
next drop next drop
next nextline textx! next ; next nextline textx! next ;
: animate-logo draw-logo slow : animate-logo
logobit-count 3 * times each draw-logo 10 sleep-csec nextlogo next ; logobit-count 3 * times each draw-logo 10 sleep-csec nextlogo next ;
: splash : splash
blue bg! lgray fg! sp fill-page lcyan fg! animate-logo blue bg! lgray fg! 32 fill-page lcyan fg! animate-logo
nl nl 15 textx! lblue bg! lred fg! s" Unregistered version" xmit nl nl 15 textx! lblue bg! lred fg! s" Unregistered version" xmit
blue bg! lcyan fg! s" - you have used 13246 / 30" xmit-line blue bg! lcyan fg! s" - you have used 13246 / 30" xmit nl
15 textx! s" days of your limited trial!" xmit-line nl nl nl 200 delay 15 textx! s" days of your limited trial!" xmit nl nl 200 sleep-csec
lgray fg! ; lgray fg! ;
: go init-statusbar splash : go splash 0 15 textxy!
popup-menu begin sleep-key key>scan %esc = if popup-menu then again ; s" 5551212" connect s" CONNECT 57600" xmit nl rick-welcome ;
' go ' main redefine ' go ' main redefine
dbg" saving" dbg" saving"
{ here s", dialer.com" s" dialtest.com" writeenv }
{ s" dialer.com" writecom }

Binary file not shown.

Binary file not shown.

View file

@ -32,17 +32,15 @@ var rle-run
: >rle-done 0 rle-run ! target rle-start @ !t ; : >rle-done 0 rle-run ! target rle-start @ !t ;
: encode-rle ( call with iterator that returns bytes ) : encode-rle ( -- , with iterator that returns bytes )
>rle-start each i iterate if i 8 << | >rle else drop then next >rle-done ; >rle-start each i iteration 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-file ( fp -- ) : embed ( host-filename -- )
>r target 0 w>t 0xffff target r@ T] fread <r close target 0 w>t open filebytes each i >t next target swap !t ;
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,36 +55,24 @@
NEXT NEXT
0 VAR, fcount 0 VAR, fcount
:ASM farfread :ASM fread
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
DEF fread 0 L<@ w>t :ASM fwrite
: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 )

274
iter.jrt
View file

@ -1,10 +1,8 @@
( iteration control stacks ( iteration control stacks
We create two new stacks - a small stack to hold the "current" value We create two new stacks - a small stack to hold the "current" value
of the loop, or the "i" stack, and a larger stack to hold any extra of the loop, or the "i" stack, and a larger stack to hold any extra
state, which we call the "next" stack. Typically the top of the next state, as well as the cp of a word that moves to the next value, which
stack would contain an "iterator" that knows how to advance to the next we call the "next" stack.
value and how to be cancelled, depending on the needs of the calling code.
With these two new stacks, we can create a generic loop construct for With these two new stacks, we can create a generic loop construct for
iterating over streaming values. Not only that, but those values can be iterating over streaming values. Not only that, but those values can be
arbitrarily filtered and transformed simply by pushing a new value onto arbitrarily filtered and transformed simply by pushing a new value onto
@ -41,23 +39,10 @@ nexttop :peek nextpeek
MOV BX @[ SS: r@ @] MOV BX @[ SS: r@ @]
INC BX INC BX INC BX INC BX
MOV @[ SS: <r @] BX MOV @[ SS: <r @] BX
NEXT ;
: :ndrop ( pixp -- )
:ASM >r ( c -- )
MOV BX @[ SS: r@ @]
POP CX
SHL CX 1 #
ADD BX CX
MOV @[ SS: <r @] BX
NEXT ; } NEXT ; }
itop :drop idrop itop :drop idrop
itop :ndrop n-idrop
nexttop :drop nextdrop nexttop :drop nextdrop
nexttop :ndrop n-nextdrop
: iterdrop ( n-next -- ) n-nextdrop idrop ;
: 1-iterdrop nextdrop idrop ;
{ : :push ( pixp -- ) { : :push ( pixp -- )
:ASM >r :ASM >r
@ -76,219 +61,108 @@ nexttop :push >next
: <next 0 nextpeek nextdrop ; : <next 0 nextpeek nextdrop ;
: i 0 ipeek ; : j 1 ipeek ; : i 0 ipeek ; : j 1 ipeek ;
:asm n-<next ( n |n| args... -- args... |n| ) ( iterator words must have the following shape: )
MOV AX SS ( -- more nextcount )
MOV ES AX ( It must take care of updating the i-stack directly. if there are
POP CX no more values, it must remove the values from the i-stack and return
JCXZ 2 @> 0 in the "more" place.
MOV DI @[ SS: nexttop @]
( make SP affect the nextstack and DI affect the data stack. )
STD ( data stack grows down )
XCHG DI SP
( PUSH decrements and then stores; STOSW stores then decrements. )
SCASW ( pre-decrement )
1 :>
POP AX
STOSW
LOOP 1 <@
( fix SP - DI is one word past the end of the stack )
CLD SCASW XCHG SP DI
( update nexttop )
MOV @[ SS: nexttop @] DI
2 <:
NEXT
:asm n->next ( args... n |n| -- |n| args... ) "nextcount" must be the number of items that are being taken up on the next
MOV AX SS stack by this word. For simple iterators this will be 1, for the space
MOV ES AX the iterator word takes. If "more" is 0, this number of items will be
POP CX dropped. This is always returned even if there are more items to iterate
JCXZ 1 @> over, in order to support efficient cancellation. ">cancel" will push a word
MOV DI @[ SS: nexttop @] onto the next-stack that will query the iterator below it to determine how
STD ( next-stack grows down ) many items need to be dropped. It will drop one item from the i-stack if the
SCASW ( pre-decrement ) iterator indicates that there are more items.
0 :>
POP AX
STOSW
LOOP 0 <@
CLD SCASW ( correct DI - off by one word )
MOV @[ SS: nexttop @] DI
1 <:
NEXT
( iterators are pointers to an array containing two function pointers: If an iterator requires any more complex cleanup to happen as the result
xt-iter xt-cancel of a cancellation, such as dropping multiple items off the i-stack, or
The xt-iter word must take care of updating the stacks directly. If aborting a task, it should check the "cancelled" flag to determine whether
there are no more values, it must remove the values from the i-stack, to perform it. An iterator that returns 0 0 will not cause any further
drop itself from the next-stack, and return 0. "finished" and "finish?" changes to occur to the iteration stacks, which allows it to be in complete
are useful words to help with this. control of this scenario if needed.
The xt-cancel word should remove all of the iterator's state from the
iteration stacks and return nothing. "n-nextdrop" and "iterdrop" are useful
words to help with this. If the iterator is itself making use of an
iterator below it on the stack, the xt-cancel word should call "cancel" to
recursively clean that up once it's done.
Note that all "next" words _must_ be defined in the target Forth! Note that all "next" words _must_ be defined in the target Forth!
This means that any iterator that dereferences near memory, such as "links", This means that any iterator that dereferences near memory, such as "links",
WILL NOT WORK on the host Forth! ) WILL NOT WORK on the host Forth! )
: iterate 0 nextpeek @ execute ; ( get-next returns the result of the iterator in swapped order - it is usually
: cancel 0 nextpeek cell + @ execute ; more convenient to specify the count last when writing iterators, but it's
always more convenient to check the flag first when consuming the result. )
: finished ( -- 0 ) cancel 0 ; : get-next ( -- c f ) 0 nextpeek execute swap ;
: finish? ( f -- f ) if 1 else finished then ; : n-nextdrop ( c -- ) dup if begin nextdrop 1- dup not until then drop ;
: iteration get-next if drop 1 else n-nextdrop 0 then ;
: EACH_ <r iterate if cell + else @ then >r ; : EACH_ <r iteration if cell + else @ then >r ;
{ ( Because we dereference pointers on the return stack, we must run this { ( Because we dereference pointers on the return stack, we must run this
from the caller's segment. Copy the definition into the host segment. ) from the caller's segment. Copy the definition into the host segment. )
: EACH_ <r iterate if cell + else @ then >r ; : EACH_ <r iteration if cell + else @ then >r ;
: each ' EACH_ , here >i 0 , ; immediate : each ' EACH_ , here >i 0 , ; immediate
: continue ' GOTO_ , i cell - , ; immediate : continue ' GOTO_ , i cell - , ; immediate
: next ['] continue here <i ! ; immediate : next ['] continue here <i ! ; immediate
:timm each t, EACH_ patchpt >i ; :timm each t, EACH_ patchpt >i ;
: CONTINUE t, GOTO_ i cell - w>t ; : CONTINUE t, GOTO_ i cell - w>t ;
:timm continue CONTINUE ; :timm continue CONTINUE ;
:timm next CONTINUE <i patch!t ; :timm next CONTINUE <i patch!t ; }
: blankiter, t' finished w>t t' 1-iterdrop w>t ; }
{ : defiter CREATE blankiter, DOES} >next ;
{ : :iter CREATE blankiter, startcolon DOES}
>r r@ [ 2 cells lit ] + execute <r >next ;
{ : iter! ( val off -- ) cells latest entry>tcp + !t ;
: next! 2 iter! ; : cancel! 3 iter! ;
: :next target next! startcolon ; : :cancel target cancel! startcolon ; }
defiter >cancel
:cancel nextdrop cancel ;
0 var, cancelled
: >cancel :| 1 cancelled ! nextdrop get-next if idrop then
0 cancelled ! 0 swap |; >next ;
{ : break ' >cancel , ['] continue ; immediate { : break ' >cancel , ['] continue ; immediate
:timm break t, >cancel CONTINUE ; } :timm break t, >cancel CONTINUE ; }
defiter nothing : nothing :| 0 1 |; >next ;
' nextdrop cancel! : single >i :| nextdrop :| idrop 0 1 |; >next 1 1 |; >next ;
: times ( n -- ) >i :| <i dup if 1- >i 1 then 1 |; >next ;
: links ( p -- )
dup if >i :| <i @ dup if >i 1 then 1 |; >next else nothing then ;
: +for? ( n -- f ) <i + dup 1 nextpeek = if drop 0 else >i 1 then ;
: for ( start lim -- ) >next 1- >i :| 1 +for? 2 |; >next ;
: for+ ( start lim inc -- )
>next >next 1 nextpeek - >i :| 2 nextpeek +for? 3 |; >next ;
: pchars ( st -- ) 1- >i :| <i 1+ dup b@ if >i 1 else drop 0 then 1 |; >next ;
defiter >single-done :asm tail ( TODO: support CREATE words )
:iter single >i ; LODSW
:next nextdrop 1 >single-done ; MOV BX AX
INC BX INC BX
:iter times ( n -- ) >i ; MOV SI BX
:next <i dup 1- >i finish? ;
defiter >links
:next <i @ dup >i finish? ;
: links ( p -- ) dup if >i >links else nothing then ;
: +for? ( n -- f ) <i + dup >i 1 nextpeek != finish? ;
:iter for ( start lim -- ) >next 1- >i ;
:next 1 +for? ;
:cancel 2 iterdrop ;
:iter for+ ( start lim inc -- ) >next >next 1 nextpeek - >i ;
:next 2 nextpeek +for? ;
:cancel 3 iterdrop ;
:iter pchars ( st -- ) 1- >i ;
:next <i 1+ dup >i b@ finish? ;
: nth ( i -- v ) 0 each 2dup = if drop i break then 1+ next swap drop ;
: count 0 each 1+ next ;
:asm _suspend>args
( iter |r| yieldpoint -- argcount |r| yieldpoint iter )
MOV DI @[ -2 @+ BP]
POP @[ BP]
INC BP INC BP
XOR AH AH
MOV AL @[ DS: DI]
PUSH AX
NEXT NEXT
:asm 2r>next : gen-save-args ( extra-args... extra-arg-count -- )
MOV BX @[ SS: nexttop @] begin dup while swap >next 1- repeat drop ;
( bp grows up. top: BP-2, second: BP-4 : gen-save ( 0 0 extra-args... extra-arg-count -- 1 cnext )
nexttop grows down. top: nexttop, second: nexttop+2 ) >r r@ gen-save-args <r 2 + >rot drop drop 1 swap ;
SUB BX 4 # ( make room for 2 more items on next stack ) : gen-restore ( arg-count -- args... )
MOV AX @[ -4 @+ BP] begin dup while <next swap 1- repeat drop ;
MOV @[ SS: 2 @+ BX] AX
MOV AX @[ -2 @+ BP]
MOV @[ SS: BX] AX
SUB BP 4 # ( pop two off return stack )
MOV @[ SS: nexttop @] BX
NEXT
:asm _resume>args ( |n| yieldpoint xt-next -- argcount |n| |r| resumepoint ) : cancel >cancel iteration drop ;
MOV BX @[ SS: nexttop @] : _resume ( cpcancel -- c f args... )
MOV DI @[ SS: 2 @+ BX] nextdrop 0 0 <rot
ADD BX 4 # cancelled @ if <next ub@ n-nextdrop execute rdrop return then
MOV @[ SS: nexttop @] BX drop <next dup 1+ >r rswap ub@ gen-restore ;
XOR AH AH : _suspend ( cpresume -- )
MOV AL @[ DS: DI] rswap r@ ub@ swap >r gen-save <r <r >next >next ;
INC DI
PUSH AX ( argcount )
MOV @[ BP] DI
INC BP INC BP
NEXT
: _resume _resume>args n-<next rswap ; : GENSTART_ <r >next :| ' noop _resume |; >next ;
: _suspend
( args... iter |r| yieldpoint ret -- 1 |r| ret |n| args... yieldpoint iter )
rswap _suspend>args n->next 2r>next 1 ;
: _cancel _resume>args n-nextdrop rdrop ;
defiter >genstart
:next _resume>args n-<next ;
' _cancel cancel!
: GENSTART_ <r >next >genstart ;
( yielding from a generator has three moving parts:
suspend: run immediately when the generator yields. takes care of updating
the i-stack appropriately, as well as potentially saving any
yield-specific state to the next-stack. After this runs, the
generator's extra parameters are pushed to the next-stack, along
with the generator's "resume" pointer and the yielder's iterator.
resume: run when the generator is resumed by iterating. Before this runs,
the yielder will take care of placing the "resume" pointer back
on the stack and restoring the generator's arguments, so the
stack environments should match what they were when the suspension
happened. This deals with cleaning up after the yielder so the
rest of the generator can run.
cancel: run when the generator is aborted. Before this runs, the next-stack
is cleared of the "resume" pointer and all of the generator's
arguments. This should remove any yield-specific data from the
iteration stacks, and potentially call "cancel" to clean up the
iterator underneath if the yielder is intended to map or filter
another iterator. )
{ var gen-arg-count { var gen-arg-count
:timm (( t:| t, GENSTART_ gen-arg-count @ >t ; :timm (( t:| t, GENSTART_ gen-arg-count @ >t ;
:timm )) t, 0 t|; t, execute 0 gen-arg-count ! ; :timm )) t|; t, execute 0 gen-arg-count ! ;
: +arg 1 gen-arg-count !+ ; :timm +arg +arg ; : +arg 1 gen-arg-count !+ ; :timm +arg +arg ;
: -arg -1 gen-arg-count !+ ; :timm -arg -arg ; : -arg -1 gen-arg-count !+ ; :timm -arg -arg ;
:timm >arg t, >next +arg ; :timm >arg t, >next +arg ;
: colonpair ( xt-first xt-second -- xt ) : :yield } create immediate target , startcolon
target <rot gencolon w>t swap w>t t, return ; does> @ w>t gen-arg-count @ >t ; }
: :yield ( xt-suspend xt-resume xt-cancel -- )
} t' _cancel swap colonpair swap t' _resume swap colonpair
target >r w>t w>t gencolon w>t r@ compilenum t, _suspend t, return
create immediate <r 2 cells + , does> @ w>t gen-arg-count @ >t ; }
: shadow-i <i >next >i ; : 2>i >i >i ; : 2idrop idrop idrop ; :yield yield0 :| ' noop _resume |; _suspend ;
: unmap idrop <next >i ; : mapcancel unmap cancel ; :yield yield >i :| ' idrop _resume idrop |; _suspend ;
: unsuspend rdrop rdrop <r 1+ >r ; ( don't yield at all, skip past the yielder ) :yield yield> >i :| ' idrop _resume <i |; _suspend ;
: suspend? not if unsuspend then ; :yield map <i >next >i :| :| idrop <next >i cancel |;
_resume idrop <next >i |; _suspend 1+ ;
: _pass-suspend rdrop :| ' cancel _resume |; _suspend ;
:yield pass _pass-suspend ;
:yield filter if _pass-suspend else <r 1+ >r then ;
( suspend resume cancel ) : chars pchars (( each i b@ map next )) ;
' noop ' noop ' noop :yield yield0 [
' >i ' idrop ' idrop :yield yield
' >i ' <i ' idrop :yield yield>
' 2>i ' 2idrop dup :yield yield2
' shadow-i ' unmap ' mapcancel :yield map
' noop ' noop ' cancel :yield pass
' suspend? ' noop ' cancel :yield filter
: take ( n -- ) >arg (( each dup if pass else break then 1- next drop )) ;
: readbytes ( -- ) (( each i b@ map next )) ;
: chars ( p -- ) pchars readbytes ;

BIN
jort.com

Binary file not shown.

View file

@ -10,16 +10,6 @@
PUSH AX PUSH AX
NEXT NEXT
:asm key-waiting? ( -- f )
MOV AH 1 #
INT 0x16 #
JNZ 0 @>
PUSH FALSE
NEXT
0 <:
PUSH TRUE
NEXT
: key>scan 8 >> ; : key>scan 8 >> ;
: key>ch 0xff & ; : key>ch 0xff & ;
: scanup 0x80 | ; : scanup 0x80 | ;

100
rick.jrt
View file

@ -1,100 +0,0 @@
dbg" Rick's Clubhouse BBS"
array rick-welcome-rle
{ s" rickclub.bin" open filebytes 18 lines-of encode-rle }
array rick-menu-rle
{ s" rickmenu.bin" open filebytes 7 lines-of encode-rle }
dbg" login"
: login
l" To login as a guest, leave your name blank."
begin
x" Enter your name: " readline nl
dup b@ while x" Sorry, I don't recognize " xmit l" !" nl
repeat nl
cyan fg!
l" Welcome, guest! We hope you decide to apply for a full membership."
l" Guest accounts have limited access."
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" -- Rick" nl ;
deferred rick-menu noop
: page-rick
x" Paging Sysop..."
5 times each 100 delay [ key . lit ] emit next nl
l" Sorry, guess they're not home!"
' rick-menu ;
dbg" files"
s" swine.com"
s" Swine Meeper - A fun freeware puzzler. Find all the truffles!"
defembed swine.com
s" dirtrect.com"
s" A simple textmode graphics demo advertising the game development collective\called Dirty Rectangles."
defembed dirtrect.com
s" assemble.com"
s" This claims to be some kind of combination Forth system / 8086 assembler??\I don't know Forth and I don't have any documentation for it, and it\doesn't use a standard assembly syntax, so your guess is as good as mine."
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."
59943 deffake kpshrink4.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."
48371 deffake mazecr3d.kps
)
: rick-filelist ((
swine.com yield
dirtrect.com yield
assemble.com yield
)) ;
: list-files 1 each
blue bg! yellow fg! x" [" dup .digit x" ]"
lcyan fg! black bg! sp emit i filename xmit
cyan fg! x" (" i filesize n>st xmit l" bytes)"
lgray fg! nl i filedesc xmit-desc nl
nl 1+ next drop ;
: select-file
black bg! white fg!
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
[ key 1 lit ] - dup 0 >= over rick-filelist count < and if
rick-filelist nth
lblue fg! x" Downloading " dup filename xmit l" ..."
download-file l" Done!" else
drop lred fg! l" Sorry, that is not a valid selection." then
' select-file ;
: rick-files nl rick-filelist list-files ' select-file ;
dbg" menu"
:noname ( -- cp )
nl rick-menu-rle xmit-screen nl
0 begin
yellow fg! black bg!
nl x" Your selection: " inputch
dup [ key m lit ] = if
lred fg! l" Sorry, message boards are not available to guests." then
dup [ key g lit ] = if
lred fg! l" Sorry, games are not available to guests." then
dup [ key p lit ] = if swap drop ' page-rick swap then
dup [ key f lit ] = if swap drop ' rick-files swap then
[ key h lit ] = if
lcyan fg! l" Thank you for calling!" 300 delay return then
dup until ; ' rick-menu redefine
: rick
black bg! white fg!
sp [ pagew 3 * lit ] repeated xmit-iter
rick-welcome-rle xmit-screen login
' rick-menu begin execute dup not until ;

View file

@ -1 +1 @@
ÛÛÛÛÛÛ»  ÛÛ»  ÛÛÛÛÛÛ» ÛÛ»  ÛÛ» ÜÛ» ÛÛÛÛÛÛÛ»          ÛÛÉÍÍÛÛ» ÛÛº ÛÛÉÍÍÍͼ ÛÛº ÛÛɼ ßͼ ÛÛÉÍÍÍͼ     ÿ ÛÛÛÛÛÛɼ ÛÛº ÛÛº      ÛÛÛÛÛɼ      ÛÛÛÛÛÛÛ»        ( 2 7 3 ) 5 5 5 - 1 2 1 2 ÛÛÉÍÍÛÛ» ÛÛº ÛÛº      ÛÛÉÍÛÛ»      ÈÍÍÍÍÛÛº        ÛÛº  ÛÛº ÛÛº ÈÛÛÛÛÛÛ» ÛÛº  ÛÛ»     ÛÛÛÛÛÛÛº        Èͼ  Èͼ Èͼ  ÈÍÍÍÍͼ Èͼ  Èͼ     ÈÍÍÍÍÍͼ        ÜÜÜÜÜÜÜ ÜÜÜ ÜÜÜ ÜÜÜ ÜÜÜÜÜÜ ÜÜÜ ÜÜÜ ÜÜÜÜÜÜÜ ÜÜÜ ÜÜÜ ÜÜÜÜÜÜÜ ÜÜÜÜÜÜÜ     ÛÿÜÜÜÜÛ ÛÿÛ ÛÿÛ ÛÿÛ ÛÿÜÜÿÛÜ ÛÿÛÜÛÿÛ ÛÿÜÜÜÿÛ ÛÿÛ ÛÿÛ ÛÿÜÜÜÜÛ ÛÿÜÜÜÜÛ ÛÿÛÜÜÜÜ ÛÿÛÜÜÜÜ ÛÿÛÜÛÿÛ ÛÿÜÜÜÿÛ ÛÿÜÜÜÿÛ ÛÿÛÜÛÿÛ ÛÿÛÜÛÿÛ ÛÜÜÜÜÿÛ ÛÿÜÜÜÛÜ ÛÜÜÜÜÜÛ ÛÜÜÜÜÜÛ ÛÜÜÜÜÜÛ ÛÜÜÜÜÜÛ ÛÜÛ ÛÜÛ ÛÜÜÜÜÜÛ ÛÜÜÜÜÜÛ ÛÜÜÜÜÜÛ ÛÜÜÜÜÜÛ SYSOP:ÿRick Fehr  ßÛßßÜ ßÛßßÜ ÜßßßÜ ÚOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄO¿O Û Û Û Û Û ³O O OYOoOuOrO OfOrOiOeOnOdOlOyO OlOoOcOaOlO OcOoOmOpOuOtOeOrO O O³O ßÛßßßÛ ßÛßßßÛ ßßÜÜ ³O O O O O O O O O O O OhOaOnOgOoOuOtO!O O O O O O O O O O O O O O³O Û Û Û Û Û ÀOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÙO ß ßßß ß ßßß ßÜÜÜÜß ÛÛÛÛÛÛ»  ÛÛ»  ÛÛÛÛÛÛ» ÛÛ»  ÛÛ» ÜÛ» ÛÛÛÛÛÛÛ»          ÛÛÉÍÍÛÛ» ÛÛº ÛÛÉÍÍÍͼ ÛÛº ÛÛɼ ßͼ ÛÛÉÍÍÍͼ     ÿ ÛÛÛÛÛÛɼ ÛÛº ÛÛº      ÛÛÛÛÛɼ      ÛÛÛÛÛÛÛ»        ( 2 7 3 ) 5 5 5 - 1 2 1 2 ÛÛÉÍÍÛÛ» ÛÛº ÛÛº      ÛÛÉÍÛÛ»      ÈÍÍÍÍÛÛº        ÛÛº  ÛÛº ÛÛº ÈÛÛÛÛÛÛ» ÛÛº  ÛÛ»     ÛÛÛÛÛÛÛº        Èͼ  Èͼ Èͼ  ÈÍÍÍÍͼ Èͼ  Èͼ     ÈÍÍÍÍÍͼ        ÜÜÜÜÜÜÜ ÜÜÜ ÜÜÜ ÜÜÜ ÜÜÜÜÜÜ ÜÜÜ ÜÜÜ ÜÜÜÜÜÜÜ ÜÜÜ ÜÜÜ ÜÜÜÜÜÜÜ ÜÜÜÜÜÜÜ     ÛÿÜÜÜÜÛ ÛÿÛ ÛÿÛ ÛÿÛ ÛÿÜÜÿÛÜ ÛÿÛÜÛÿÛ ÛÿÜÜÜÿÛ ÛÿÛ ÛÿÛ ÛÿÜÜÜÜÛ ÛÿÜÜÜÜÛ ÛÿÛÜÜÜÜ ÛÿÛÜÜÜÜ ÛÿÛÜÛÿÛ ÛÿÜÜÜÿÛ ÛÿÜÜÜÿÛ ÛÿÛÜÛÿÛ ÛÿÛÜÛÿÛ ÛÜÜÜÜÿÛ ÛÿÜÜÜÛÜ ÛÜÜÜÜÜÛ ÛÜÜÜÜÜÛ ÛÜÜÜÜÜÛ ÛÜÜÜÜÜÛ ÛÜÛ ÛÜÛ ÛÜÜÜÜÜÛ ÛÜÜÜÜÜÛ ÛÜÜÜÜÜÛ ÛÜÜÜÜÜÛ SYSOP:ÿRick Toews ßÛßßÜ ßÛßßÜ ÜßßßÜ ÚOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄO¿O Û Û Û Û Û ³O O OYOoOuOrO OfOrOiOeOnOdOlOyO OlOoOcOaOlO OcOoOmOpOuOtOeOrO O O³O ßÛßßßÛ ßÛßßßÛ ßßÜÜ ³O O O O O O O O O O O OhOaOnOgOoOuOtO!O O O O O O O O O O O O O O³O Û Û Û Û Û ÀOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÄOÙO ß ßßß ß ßßß ßÜÜÜÜß

View file

@ -1 +0,0 @@
                       ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸                             ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ;  ððð M A I N   M E N U ððð  ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸         ³                                                                     ³         ³  M)essage Boards            Door G)ames          F)ile Area         ³         ³  P)age Sysop                                     H)ang Up           ³         ³                                                                     ³         ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     

BIN
swine.com

Binary file not shown.

View file

@ -59,6 +59,8 @@ array board maxw maxh * allot
: revealed? ( p -- f ) b@ FREVEALED & ; : revealed? ( p -- f ) b@ FREVEALED & ;
: squarecount ( p -- c ) b@ NEIGHBOUR-MASK & ; : squarecount ( p -- c ) b@ NEIGHBOUR-MASK & ;
:yield yield2 >i >i :| idrop idrop ' noop _resume |; _suspend ;
: 8-neighbours ( x y -- ) >arg >arg (( : 8-neighbours ( x y -- ) >arg >arg ((
over 1- over 1- yield2 over 1- over 1- yield2
over 1- over yield2 over 1- over yield2
@ -389,22 +391,11 @@ array title-text t", SWINE MEEPER"
blue bg! yellow fg! clear blue bg! yellow fg! clear
17 3 textxy! title-text draw-spaced-text ; 17 3 textxy! title-text draw-spaced-text ;
import embed.jrt 4 ' draw-title defmenu title-menu
array instructiontext { s" swine.txt" embed } ' start s" Start Game" 0 defitem
' difficulty-menu s" Difficulty" 1 defitem
: instructions ' theme-menu s" Themes" 2 defitem
lgray bg! blue fg! clear ' leave s" Quit" 3 defitem
2 1 textxy!
instructiontext dup embed-data swap @ for each
i b@ dup 32 >= if draw-char else 10 = if 2 texty 1+ textxy! then then
next wait-key drop ;
5 ' draw-title defmenu title-menu
' start s" Start Game" 0 defitem
' instructions s" Instructions" 1 defitem
' difficulty-menu s" Difficulty" 2 defitem
' theme-menu s" Themes" 3 defitem
' leave s" Quit" 4 defitem
' main :chain textmode reseed! hidecursor title-menu textmode ; ' main :chain textmode reseed! hidecursor title-menu textmode ;

View file

@ -1,15 +1,18 @@
S * W * I * N * E M * E * E * P * E * R
Waddles, your trusty pig, is ready to go on the hunt for truffles! Leash him Waddles, your trusty pig, is ready to go on the hunt for truffles! Leash him
up and make your way through the grove. But be warned! Digging too close can up and make your way through the grove. But be warned! Digging too close can
cause damage to the truffles' mycelia, which can take years to recover from! cause damage to the truffles' mycelia, which can take years to recover from!
HOW TO PLAY: Select a square with the arrow keys, and press the space bar or HOW TO PLAY:
enter to dig. Waddles will tell you how many truffles are nearby by marking Select a square with the arrow keys, and press the space bar or enter to dig.
the square with a number. This is the number of neighbouring squares Waddles will tell you how many truffles are nearby by marking the square with
(including diagonals) that have truffles. a number. This is the number of neighbouring squares (including diagonals)
that have truffles.
If you select a square with no truffles nearby, the neighbouring squares If you select a square with no truffles nearby, the neighbouring squares will
will automatically be cleared out. If you select a square with a truffle, automatically be cleared out. If you select a square with a truffle, it's
it's game over! game over!
You can use the "F" key to flag and unflag a square as containing a truffle You can use the "F" key to flag and unflag a square as containing a truffle
without digging there. If you select a square that has already been dug up, without digging there. If you select a square that has already been dug up,

View file

@ -6,8 +6,7 @@
0 var, textpageid 0 var, textpageid
0 var, textpage 0 var, textpage
: id>page 12 << ; : page! dup textpageid ! 12 << textpage ! ;
: page! dup textpageid ! id>page textpage ! ;
:asm showpage :asm showpage
POP AX POP AX
@ -173,40 +172,3 @@ var boxstyle
swap 2 - over boxmiddle swap 2 - over boxmiddle
boxbottom ; boxbottom ;
:asm segwordmove ( dst src count seg -- )
MOV BX DS
MOV AX SI
POP ES
MOV DX ES
MOV DS DX
POP CX
POP SI
POP DI
CMP DI SI
JL 0 @> ( if dst < src, then copy from the top )
STD
SHL CX 1 #
ADD DI CX
ADD SI CX
SHR CX 1 #
CMPSW ( decrement back to the beginning of the copy )
0 <:
REPZ MOVSW
CLD
MOV SI AX
MOV DS BX
NEXT
32 const sp
: scrollup ( y ybottom -- )
>r r@ over - pagew * swap
pagew 2* * textpage @ +
dup pagew 2* + <rot SCREENSEG segwordmove
textpos @ 0 <r textxy! pagew sp draw-hrepeat textpos ! ;
: pagecopy ( dstpage srcpage -- )
id>page swap id>page swap [ pagew pageh * lit ] SCREENSEG segwordmove ;
: textstate textpen @ textpos @ boxstyle @ ;
: textstate! boxstyle ! textpos ! textpen ! ;

View file

@ -60,7 +60,7 @@ var timer
( the timer is set to run at just under 150hz, so a "csec" is closer to 7.5ms ( the timer is set to run at just under 150hz, so a "csec" is closer to 7.5ms
than 10ms. ) than 10ms. )
: over-csec ( csec -- ) : over-csec ( csec -- )
timer @ + >arg (( begin dup timer @ > while yield0 repeat drop )) ; timer @ + >arg (( begin yield0 dup timer @ <= until drop )) ;
: sleep-csec ( cs -- ) over-csec each suspend next ; : sleep-csec ( cs -- ) over-csec each suspend next ;
' init :chain [ 0xffff 3 >> lit ] set-timer-div timer-isr install-isr ; ' init :chain [ 0xffff 3 >> lit ] set-timer-div timer-isr install-isr ;

Binary file not shown.

View file

@ -489,8 +489,6 @@ dbg" flow control words and misc."
:t :init initscripts @ here initscripts ! , ] ; :t :init initscripts @ here initscripts ! , ] ;
: :INIT [ t& initscripts lit ] dup @t swap target swap !t w>t ] compt ; : :INIT [ t& initscripts lit ] dup @t swap target swap !t w>t ] compt ;
:INIT 0 inptr @ b! ; ( ensure input buffer starts empty )
:t doinit initscripts @ :t doinit initscripts @
[ target ] dup BZ_ [ patchpt ] dup cell + >r @ GOTO_ [ swap w>t ] [ target ] dup BZ_ [ patchpt ] dup cell + >r @ GOTO_ [ swap w>t ]
[ patch!t ] drop ; [ patch!t ] drop ;
@ -507,10 +505,9 @@ dbg" boot"
POP AX POP AX
ADD AX 4096 # ADD AX 4096 #
MOV SS AX MOV SS AX
MOV SP 0x100 #
MOV t& lastseg @+ AX MOV t& lastseg @+ AX
MOV SP 0x100 #
MOV BP 0x00 # MOV BP 0x00 #
CLD
NEXT NEXT
target t& &here !t target t& &here !t

Binary file not shown.

Binary file not shown.

View file

@ -39,7 +39,6 @@ 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
@ -99,11 +98,9 @@ s" coredefs.jrt" loadfile
:timm until t, BZ_ w>t ; :timm until t, BZ_ w>t ;
: t", begin key dup [ key " lit ] != while >t repeat drop 0 >t ; : t", begin key dup [ key " lit ] != while >t repeat drop 0 >t ;
: t" t, INLINEDATA_ patchpt t", patch!t ; :timm s" state if t, INLINEDATA_ patchpt t", patch!t else target t", then ;
:timm s" state if t" else target t", then ;
: gencolon t& $DOCOLON w>t ; : startcolon t& $DOCOLON w>t ] ;
: startcolon gencolon ] ;
: t:| t, INLINEDATA_ patchpt startcolon ; : t:| t, INLINEDATA_ patchpt startcolon ;
: t|; t, return patch!t ; : t|; t, return patch!t ;
:timm :| t:| ; :timm :| t:| ;
@ -129,8 +126,7 @@ s" coredefs.jrt" loadfile
dbg" CREATE" dbg" CREATE"
: CREATE DEF t& $DOCREATE w>t 0 w>t ; : CREATE DEF t& $DOCREATE w>t 0 w>t ;
: entry>tcp codepointer cell + @ ; : FINISHCREATE ' latest ' tdict with-dict codepointer cell + @ cell + !t ;
: FINISHCREATE ' latest ' tdict with-dict entry>tcp cell + !t ;
: DOES} target lit ' FINISHCREATE , ' return , } ; immediate : DOES} target lit ' FINISHCREATE , ' return , } ; immediate
( s" blah.jrt" loadfile doesn't work in target mode because s" writes ( s" blah.jrt" loadfile doesn't work in target mode because s" writes
@ -147,21 +143,20 @@ dbg" CREATE"
var comfilename var comfilename
: readcom ( filename ) open >r : readcom ( filename ) open 0x100 target!
0x100 0xffff over r@ comseg farfread begin dup fgetc dup EOF != while >t repeat drop close ;
fcount @ + target! <r close ;
DEFERRED init noop DEFERRED init noop
DEFERRED main noop DEFERRED main noop
DEFERRED cleanup noop DEFERRED cleanup noop
T] cleanup ' cleanup redefine tdict-lookup cleanup drop ' 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 }
T] init ; [ tdict-lookup init drop , ] ;
: writeenv ( comfile wrapper -- ) : writeenv ( comfile wrapper -- )
swap comfilename ! swap comfilename !
@ -170,7 +165,7 @@ T] cleanup ' cleanup redefine
dbg" boot" dbg" boot"
} : exit cleanup terminate ; : start init main exit ; { } : start init main cleanup terminate ; {
9 <: ( actual entry point ) 9 <: ( actual entry point )
MOV SI t& start # MOV SI t& start #
@ -182,11 +177,9 @@ dbg" boot"
MOV BP 0x00 # MOV BP 0x00 #
NEXT NEXT
here s", zipstub.min" s" zipmin.com" writeenv
} import common.jrt { } import common.jrt {
T] init execute tdict-lookup init drop execute
here s", zipstub.seg" s" zipoff.com" writeenv here s", zipstub.seg" s" zipoff.com" writeenv

Binary file not shown.

Binary file not shown.