home *** CD-ROM | disk | FTP | other *** search
- \ BLOCKS.SEQ Blocks support for FF by Tom Zimmer
-
- 1024 constant b/buf
- 64 constant c/l
- variable updated
- variable blk
- variable scr
-
- create block_buffer b/buf allot
-
- : empty-buffers ( -- )
- block_buffer b/buf erase ;
-
- : set_offset ( --- )
- blk @ b/buf um* shndl @ movepointer ;
-
- : save-buffers ( -- )
- updated @
- if set_offset
- block_buffer b/buf shndl @ hwrite drop
- updated off
- then ;
-
- : flush ( -- )
- save-buffers empty-buffers ;
-
- : capacity ( -- n )
- shndl @ endfile b/buf um/mod nip ;
-
- : update ( -- ) updated on ;
-
- : discard ( -- ) updated off ;
-
- : buffer ( n -- a )
- save-buffers
- blk !
- block_buffer ;
-
- : block ( n1 --- a1 )
- blk @ over =
- if drop
- else save-buffers
- blk !
- set_offset
- block_buffer b/buf shndl @ hread b/buf - disk-error !
- then block_buffer ;
-
- : ?BLOCKFILE ( --- F1 )
- SHNDL @ HANDLE>EXT " .BLK" CAPS-COMP 0= ;
-
- : BLOCK_LOAD ( n -- )
- DUP BLOCK
- 'TIB DUP @ >R !
- BLK DUP @ >R !
- >IN DUP @ >R OFF
- B/BUF DUP SPAN DUP @ >R ! #TIB !
- RUN
- R> DUP SPAN ! #TIB !
- R> >IN !
- R> BLK !
- R> 'TIB ! ;
-
- : thru ( N1 N2 --- )
- 1+ swap over min
- ?do i block_load
- loop ;
-
- warning dup @ swap off \ save warning for later, but OFF for now.
-
- : load ( n1 --- )
- ?blockfile
- if block_load
- else load
- then ;
-
- : loadall ( N1 --- )
- capacity 2/ 1- thru ;
-
- \ Must NOT use any \ type comments following this next
- \ definition in this file.
-
- : \ ( --- )
- ?blockfile
- if >in @ negate c/l mod >in +!
- else \
- then ; immediate
-
- : \s ( --- )
- ?blockfile
- if end? on
- else \s
- then ;
-
- : (s ( --- )
- [compile] ( ; immediate
-
- : ok ( --- )
- ?blockfile
- if 1 block_load
- else ok
- then ;
-
- : ed ( --- )
- ?blockfile abort" Mustn't edit BLOCK files, use BLKTOSEQ first."
- ed ;
-
- : edit ( n1 --- )
- ?blockfile abort" Mustn't edit BLOCK files, use BLKTOSEQ first."
- edit ;
-
- : block_list ( n1 --- )
- dark cr
- dup scr ! cr ." Screen " dup . ." of " .file
- block 16 0
- do cr i 3 .r space
- i c/l * over + c/l -trailing type
- loop cr drop ;
-
- : list ( n1 --- )
- ?blockfile
- if block_list
- else list
- then ;
-
- : l ( --- )
- ?blockfile
- if scr @ list
- else l
- then ;
-
- : n ( --- )
- ?blockfile
- if scr @ 1+ capacity 1- min list
- else n
- then ;
-
- : b ( --- )
- ?blockfile
- if scr @ 1- 0 max list
- else b
- then ;
-
- warning !
-