1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-23 11:48:05 +11:00

blk: add dirty flag and auto write blocks on fetch

Also, fix some PSP leaks related to LOAD.
This commit is contained in:
Virgil Dupras 2020-04-16 20:59:20 -04:00
parent 79ce88c12c
commit 9edab10a3a
5 changed files with 31 additions and 9 deletions

View File

@ -10,7 +10,7 @@ VARIABLE EDPOS
2DUP SWAP I + C!
DUP IF DROP C< THEN
LOOP
2DROP
BLK!!
;

View File

@ -16,6 +16,7 @@ SLATEST = ../tools/slatest
STRIPFC = ../tools/stripfc
BIN2C = ../tools/bin2c
BLKPACK = ../tools/blkpack
BLKUNPACK = ../tools/blkunpack
.PHONY: all
all: $(TARGETS)
@ -27,6 +28,7 @@ $(BLKPACK):
$(STRIPFC): $(BLKPACK)
$(SLATEST): $(BLKPACK)
$(BIN2C): $(BLKPACK)
$(BLKUNPACK): $(BLKPACK)
# z80c.bin is not in the prerequisites because it's a bootstrap
# binary that should be updated manually through make updatebootstrap.
@ -77,6 +79,14 @@ emul.o: emul.c
updatebootstrap: forth/stage2
cat $(BOOTSRCS) | ./forth/stage2 > ./forth/z80c.bin
.PHONY: pack
pack:
rm blkfs && $(MAKE) blkfs
.PHONY: unpack
unpack:
$(BLKUNPACK) ../blk < blkfs
.PHONY: clean
clean:
rm -f $(TARGETS) emul.o forth/*-bin.h forth/forth?.bin blkfs

View File

@ -7,26 +7,35 @@
: BLK!* 2 BLKMEM+ ;
( Current blk pointer in ( )
: BLK> 4 BLKMEM+ ;
: BLK( 6 BLKMEM+ ;
( Whether buffer is dirty )
: BLKDTY 6 BLKMEM+ ;
: BLK( 8 BLKMEM+ ;
: BLK$
H@ 0x57 RAM+ !
( 1024 for the block, 6 for variables )
1030 ALLOT
( 1024 for the block, 8 for variables )
1032 ALLOT
( LOAD detects end of block with ASCII EOT. This is why
we write it there. EOT == 0x04 )
4 C,
0 BLKDTY !
-1 BLK> !
;
( -- )
: BLK!
BLK> @ BLK!* @ EXECUTE
0 BLKDTY !
;
( n -- )
: BLK@
DUP BLK> @ = IF DROP EXIT THEN
BLKDTY @ IF BLK! THEN
DUP BLK> ! BLK@* @ EXECUTE
;
( -- )
: BLK! BLK> @ BLK!* @ EXECUTE ;
: BLK!! 1 BLKDTY ! ;
: .2 DUP 10 < IF SPC THEN . ;
@ -42,7 +51,10 @@
: _
(boot<)
DUP 4 = IF
DROP
( We drop our char, but also "a" from WORD: it won't
have the opportunity to balance PSP because we're
EXIT!ing. )
2DROP
( We're finished interpreting )
EXIT!
THEN

View File

@ -178,6 +178,7 @@
DUP ( I I )
R> DROP I 2- @ ( I I a )
= UNTIL
DROP
;
( a -- a+1 c )

View File

@ -26,7 +26,6 @@ int main(int argc, char *argv[])
}
if (c) {
// not an empty block
printf("%s\n", fullpath);
FILE *fp = fopen(fullpath, "w");
for (int i=0; i<16; i++) {
int len = strlen(&buf[i*64]);