| require struct.fs |
require struct.fs |
| |
|
| struct |
struct |
| 1 cells: field buffer-block \ the block number |
cell% field buffer-block \ the block number |
| 1 cells: field buffer-fid \ the block's fid |
cell% field buffer-fid \ the block's fid |
| 1 cells: field buffer-dirty \ the block dirty flag |
cell% field buffer-dirty \ the block dirty flag |
| chars/block chars: field block-buffer \ the data |
char% chars/block * field block-buffer \ the data |
| 0 cells: field next-buffer |
cell% 0 * field next-buffer |
| end-struct buffer-struct |
end-struct buffer-struct |
| |
|
| Variable block-buffers |
Variable block-buffers |
| |
|
| User block-fid |
User block-fid |
| |
|
| : block-cold |
: block-cold ( -- ) |
| block-fid off last-block off |
block-fid off last-block off |
| buffers buffer-struct drop * allocate throw dup block-buffers ! |
buffer-struct buffers * %alloc dup block-buffers ! ( addr ) |
| buffers buffer-struct drop * erase ; |
buffer-struct %size buffers * erase ; |
| |
|
| ' block-cold INIT8 chained |
' block-cold INIT8 chained |
| |
|
| ' flush IS flush-blocks |
' flush IS flush-blocks |
| |
|
| : get-buffer ( n -- a-addr ) |
: get-buffer ( n -- a-addr ) |
| buffers mod buffer-struct drop * block-buffers @ + ; |
buffers mod buffer-struct %size * block-buffers @ + ; |
| |
|
| : block ( u -- a-addr ) |
: block ( u -- a-addr ) |
| dup 0= -35 and throw |
dup 0= -35 and throw |