From 6c2f866b01ac2472f1a0dbffbaf103678c082f39 Mon Sep 17 00:00:00 2001 From: CrazyEttin <> Date: Sun, 21 Aug 2022 10:27:02 +0300 Subject: [PATCH] Enforce the emulated terminal being dumb, rename settape to tape, and reword the readme slightly --- emulator.pas | 21 ++++++++++++++++++--- readme.md | 8 ++++---- settape.pas => tape.pas | 12 ++++++------ 3 files changed, 28 insertions(+), 13 deletions(-) rename settape.pas => tape.pas (87%) diff --git a/emulator.pas b/emulator.pas index 6d09976..f226b4e 100644 --- a/emulator.pas +++ b/emulator.pas @@ -31,6 +31,22 @@ var {$endif} Ch, Scan: ansichar; //Character for input and output and scancode for non-ASCII keys +//Terminal output +procedure Output; +begin + //Do not output most of the control codes + if Ch <= ansichar ($1f) then begin + if Ch = ansichar (7) then write (Ch) //Bell + else if Ch = ansichar (8) then write (Ch) //Backspace + else if Ch = ansichar ($a) then write (Ch) //Line feed + else if Ch = ansichar ($d) then write (Ch) //Carriage return + else write (''); //Others + end + else if Ch = ansichar ($7f) then write ('') //Delete + //Output all regular characters + else write (Ch); +end; + begin //Initialise the halt flag and the pointers @@ -187,7 +203,7 @@ begin end; end; //Process the keypress - write (Ch); //Local echo + Output; //Local echo R [X] := byte (Ch); end //Tape reader @@ -225,7 +241,6 @@ begin except end; end; - end {$endif} //Regular load @@ -236,7 +251,7 @@ begin //Terminal output if Addr = IO then begin Ch := ansichar (R [X]); - write (Ch); + Output; end //Printer {$ifdef printer} diff --git a/readme.md b/readme.md index 6b16992..d6811bc 100644 --- a/readme.md +++ b/readme.md @@ -87,7 +87,7 @@ Memory-Mapped Devices --------------------- Input (when read from) and output (when written to) are mapped to -address FFFF. The emulator emulates a dumb terminal with local echo. +address FFFF. The emulator emulates a glass teletype with local echo. Arbitrary devices can be mapped to the other reserved addresses. @@ -96,13 +96,13 @@ and an emulated punched tape reader and punch with the arguments -dprinter and -dtape respectively. The printer is mapped to address FFFE and the tape reader and punch to FFFD. The printer prints into /dev/usb/lp0 and the tape files read from and punched to are (re)set -using the settape program. If you wish to use a different setup you have -to modify the code yourself. +using the program tape. If you wish to use a different setup you have to +modify the code yourself. Initial Program Loader ---------------------- At boot the initial program loader loads a program to the memory starting from address 0 after which is cedes control to the CPU. The -emulator loads the program from a file. +emulator loads the program from a ROM file.  \ No newline at end of file diff --git a/settape.pas b/tape.pas similarity index 87% rename from settape.pas rename to tape.pas index 9e06228..db9beca 100644 --- a/settape.pas +++ b/tape.pas @@ -1,4 +1,4 @@ -program Settape; +program Tape; {$MODE OBJFPC} @@ -6,22 +6,22 @@ uses SysUtils; type //Tape file path and reset state - Tape = record + TapeState = record Path: shortstring; Reset: boolean; Pos: integer; end; var - Reader, Punch: Tape; //States of the reader and punch - State: file of Tape; //File storing the states of the reader and punch + Reader, Punch: TapeState; //States of the reader and punch + State: file of TapeState; //File storing the states of the reader and punch DoRead, DoPunch: boolean; //Whether to reset the reader or the punch begin //Check whether to set the reader, the punch, or both if ParamCount <> 1 then begin - writeln ('Usage: settape reader/punch/both'); + writeln ('Usage: tape reader/punch/both'); halt; end; if ParamStr (1) = 'reader' then begin @@ -37,7 +37,7 @@ begin DoPunch := true; end else begin - writeln ('Usage: settape reader/punch/both'); + writeln ('Usage: tape reader/punch/both'); halt; end;