home *** CD-ROM | disk | FTP | other *** search
- \ OVERLAY.SEQ An overlay mechanism for assembler and editor.
-
- defined ovdp nip #if
- .comment:
- The OVERLAY file has already been loaded.
- comment;
- \s
- #endif
-
- .comment:
-
- An overlay memory scheme to allow things to be loaded and take up
- dictionary space only when needed. This is normally used only for the
- assembler, and editor.
-
- comment;
-
- warning dup @ swap off
-
- only forth also definitions hidden definitions also
-
- 15 1024 * constant xovlen
- 10 1024 * constant ovlen
- #listsegs 16 *
- xovlen - 1024 - constant xovstart
- sp@ ovlen - 1024 - constant ovstart
-
- variable ovdp ovdp off
- variable xovdp
- variable dpsave
- variable xdpsave
- variable ovseg ovseg off
- variable xovseg xovseg off
- variable ovstat ovstat off
- variable filelistsave
- 2variable ovoffset
-
- forth definitions
-
- : >overlay ( --- )
- ovstat @ 0=
- if ovstat on
- dp @ dpsave ! ovdp @ dp !
- xdp @ xdpsave ! xovdp @ xdp !
- then ;
-
- : overlay> ( --- )
- ovstat @
- if ovstat off
- ?gotov on
- dp @ ovdp ! dpsave @ dp !
- xdp @ xovdp ! xdpsave @ xdp !
- then ;
-
- hidden definitions
-
- : ovinit ( --- )
- ovdp @ 0=
- if xovstart xovdp !
- ovstart ovdp !
- >overlay
- 12345 , ctime 2@ , ,
- overlay>
- then ;
-
- : mem>save ( --- )
- ?cs: ovstart ovseg @ 0 ovlen cmovel
- xovstart xs: xovseg @ 0 xovlen cmovel ;
-
- : mem>ov ( --- )
- ?cs: ovstart ovseg @ ovlen ovdp @ ovstart - cmovel
- xovstart xs: xovseg @ xovlen xovdp @ xovstart - cmovel ;
-
- : save>mem ( --- )
- ovseg @ 0 ?cs: ovstart ovlen cmovel
- xovseg @ 0 xovstart xs: xovlen cmovel ;
-
- : ov>mem ( --- )
- ovseg @ ovlen ?cs: ovstart ovdp @ ovstart - cmovel
- xovseg @ xovlen xovstart xs: xovdp @ xovstart - cmovel ;
-
- : ?overlay ( --- f1 ) \ Is the overlay already in memory good?
- ovseg @ ovlen @l 12345 <>
- ovseg @ ovlen 2+ @l ctime @ <> or
- ovseg @ ovlen 4 + @l ctime 2+ @ <> or 0= ;
-
- : ovsave ( --- )
- ?overlay 0=
- if ." No overlay to save. "
- else exehcb endfile ovoffset 2!
- ovlen ovdp @ ovstart - dup >r exehcb ovseg @ exhwrite r> <>
- abort" Write Error in Overlay Code section"
- xovlen xovdp @ xovstart - dup >r
- exehcb xovseg @ exhwrite r> <>
- abort" Write Error on Overlay List section"
- then ;
-
- : ?ovread ( --- )
- ?overlay 0=
- if dosver 3 <
- if " OVERLAY.BIN" ">$ \ if dos = 2.x, try this
- 0.0 ovoffset 2! \ and clear file offset
- else me@ me$ \ else read my own name
- then shndl+ $>handle
- shndl+ hopen
- if cr ." Could not open " shndl+ count type
- ." to read Overlay." abort
- then
- ovoffset 2@ shndl+ movepointer
- ovlen ovdp @ ovstart - shndl+ ovseg @ exhread drop
- ?overlay 0=
- if cr ." Sorry, defective OVERLAY file."
- shndl+ hclose drop abort
- else
- xovlen xovdp @ xovstart - shndl+
- xovseg @ exhread drop
- shndl+ hclose drop
- then
- then ;
-
- : ?ovalloc_err ( n1 --- )
- 8 = abort" Could not allocate overlay memory" ;
-
- : ?ovalloc ( --- )
- ovseg @ 0=
- if ovlen 16 / 1+ 2* alloc ?ovalloc_err nip ovseg !
- xovlen 16 / 1+ 2* alloc ?ovalloc_err nip xovseg !
- then ;
-
- : cold_ovalloc ( --- )
- defers initstuff
- ovseg off
- xovseg off ;
-
- ' cold_ovalloc is initstuff
-
- forth definitions
-
- : ovon ( --- )
- >overlay
- ?ovalloc
- ?ovread
- mem>save
- ov>mem ;
-
- : ovoff ( --- )
- overlay>
- mem>ov
- save>mem ;
-
- : appendoverlay ( --- )
- ovon ovsave ovoff ;
-
- ' appendoverlay is append-ov
-
- warning ! \ restore warning
-
- ovinit
-
- only forth also definitions
-