diff --git a/blk/104 b/blk/104 index 3ef1cfe..a671441 100644 --- a/blk/104 +++ b/blk/104 @@ -10,7 +10,7 @@ VARIABLE EDPOS 2DUP SWAP I + C! DUP IF DROP C< THEN LOOP + 2DROP + BLK!! ; - - diff --git a/emul/Makefile b/emul/Makefile index e47bc08..9a7104d 100644 --- a/emul/Makefile +++ b/emul/Makefile @@ -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 diff --git a/forth/blk.fs b/forth/blk.fs index e4fde66..7e9d610 100644 --- a/forth/blk.fs +++ b/forth/blk.fs @@ -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 diff --git a/forth/core.fs b/forth/core.fs index 129b912..5e05eb4 100644 --- a/forth/core.fs +++ b/forth/core.fs @@ -178,6 +178,7 @@ DUP ( I I ) R> DROP I 2- @ ( I I a ) = UNTIL + DROP ; ( a -- a+1 c ) diff --git a/tools/blkunpack.c b/tools/blkunpack.c index c252671..19fc271 100644 --- a/tools/blkunpack.c +++ b/tools/blkunpack.c @@ -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]);