From e089121f22223182fe7bdb0f1987dbb8946a0f28 Mon Sep 17 00:00:00 2001 From: Philip Zembrod Date: Mon, 10 Jan 2022 22:42:25 +0100 Subject: [PATCH] Add Makefile rules to convert uppercase XYZ.FB block files into lowercase xyz.fth stream files, and convert files in src/ and tests/ --- 8086/msdos/Makefile | 19 ++++++- 8086/msdos/src/include.fth | 95 +++++++++++++++++++++++++++++++++++ 8086/msdos/tests/log2file.fth | 76 ++++++++++++++++++++++++++++ 8086/msdos/tests/logtest.fth | 38 ++++++++++++++ 4 files changed, 226 insertions(+), 2 deletions(-) create mode 100644 8086/msdos/src/include.fth create mode 100644 8086/msdos/tests/log2file.fth create mode 100644 8086/msdos/tests/logtest.fth diff --git a/8086/msdos/Makefile b/8086/msdos/Makefile index e94fd1e..6ab9855 100644 --- a/8086/msdos/Makefile +++ b/8086/msdos/Makefile @@ -1,12 +1,12 @@ - test: logtest.result clean: rm -f *.log *.LOG *.result *.golden -logtest.log: volks4th.com tests/LOG2FILE.FB tests/LOGTEST.FB emulator/run-in-dosbox.sh +logtest.log: volks4th.com tests/LOG2FILE.FB tests/LOGTEST.FB \ + emulator/run-in-dosbox.sh ./emulator/run-in-dosbox.sh volks4th.com logtest logtest.golden: tests/golden/logtest.golden @@ -16,3 +16,18 @@ logtest.golden: tests/golden/logtest.golden rm -f $@ tests/evaluate-test.sh $(basename $@) +fbfiles = $(wildcard src/*.FB tests/*.FB) +fthfiles = $(patsubst %.fb, %.fth, \ + $(shell ../../tools/echo-tolower.py $(fbfiles))) + +fth: $(fthfiles) + +.ONESHELL: +$(fthfiles): $(fbfiles) + set -x + for fb in $^ + do + echo fb: $$fb + fth=$$(../../tools/echo-tolower.py $$fb | sed -e 's/fb$$/fth/') + ../../tools/fb2fth.py $$fb $$fth + done diff --git a/8086/msdos/src/include.fth b/8086/msdos/src/include.fth new file mode 100644 index 0000000..292c4d5 --- /dev/null +++ b/8086/msdos/src/include.fth @@ -0,0 +1,95 @@ + +\ *** Block No. 0, Hexblock 0 + +\ include for stream sources phz 06jan22 + + + + + + + + + + + + + + + + +\ *** Block No. 1, Hexblock 1 + +\ load screen phz 06jan22 + + 1 3 +thru + + + + + + + + + + + + + + +\ *** Block No. 2, Hexblock 2 + +\ fib /fib #fib eolf? phz 06jan22 + + context @ dos also context ! + $50 constant /tib + variable tibeof tibeof off + + : eolf? ( c -- f ) + \ f=-1: not yet eol; store c and continue + \ f=0: eol but not yet eof; return line and flag continue + \ f=1: eof: return line and flag eof + tibeof off + dup #lf = IF drop 0 exit THEN + -1 = IF tibeof on 1 ELSE -1 THEN ; + + + + +\ *** Block No. 3, Hexblock 3 + +\ freadline probe-for-fb phz 06jan22 + + : freadline ( -- eof ) + tib /tib bounds DO + isfile@ fgetc dup eolf? under 0< IF I c! ELSE drop THEN + 0< 0= IF I tib - #tib ! ENDLOOP tibeof @ exit THEN + LOOP /tib #tib ! + ." warning: line exteeds max " /tib . cr + ." extra chars ignored" cr + BEGIN isfile@ fgetc eolf? 1+ UNTIL tibeof @ ; + + : probe-for-fb ( -- flag ) + \ probes whether current file looks like a block file + /tib 2+ 0 DO isfile@ fgetc #lf = IF ENDLOOP false exit THEN + LOOP true ; + + +\ *** Block No. 4, Hexblock 4 + +\ interpret-via-tib include phz 06jan22 + + : interpret-via-tib + BEGIN freadline >r .status >in off interpret + r> UNTIL ; + + : include ( -- ) + pushfile use + probe-for-fb isfile@ freset IF 1 load close exit THEN + blk @ Abort" no include from blk" + interpret-via-tib close + #tib off >in off ; + + + + diff --git a/8086/msdos/tests/log2file.fth b/8086/msdos/tests/log2file.fth new file mode 100644 index 0000000..255ee47 --- /dev/null +++ b/8086/msdos/tests/log2file.fth @@ -0,0 +1,76 @@ + +\ *** Block No. 0, Hexblock 0 + +\ logging to a text file phz 03jan22 + + + + + + + + + + + + + + + + +\ *** Block No. 1, Hexblock 1 + +\ load screen phz 04jan22 + + 1 2 +thru + + + + + + + + + + + + + + +\ *** Block No. 2, Hexblock 2 + +\ log-type log-emit log-cr alsologtofile phz 04jan22 + context @ dos also context ! +\ vocabulary log dos also log definitions + file logfile + variable logfcb + + : log-type 2dup (type ds@ -rot logfcb @ lfputs ; + + : log-emit dup (emit logfcb @ fputc ; + + : log-cr (cr #cr logfcb @ fputc #lf logfcb @ fputc ; + +Output: alsologtofile + log-emit log-cr log-type (del (page (at (at? ; + + + +\ *** Block No. 3, Hexblock 3 + +\ logopen logclose phz 04jan22 + + : logopen ( -- ) + logfile make isfile@ dup freset logfcb ! + alsologtofile ; + + : logclose ( -- ) display logfcb @ fclose ; + + + + + + + + + diff --git a/8086/msdos/tests/logtest.fth b/8086/msdos/tests/logtest.fth new file mode 100644 index 0000000..fbcdda2 --- /dev/null +++ b/8086/msdos/tests/logtest.fth @@ -0,0 +1,38 @@ + +\ *** Block No. 0, Hexblock 0 + +\ logtest.fb phz 04jan22 + + basic tests for log2file.fb + + + + + + + + + + + + + + +\ *** Block No. 1, Hexblock 1 + +\ loadscreen phz 04jan22 + + include log2file.fb + + logopen logtest.log + .( logtest done) cr + logclose + + + + + + + + +