From 2818ea170e89bf3dd95bba98ae68f06a49ca0c45 Mon Sep 17 00:00:00 2001 From: CrazyEttin <> Date: Fri, 26 Aug 2022 19:49:58 +0300 Subject: [PATCH] Add a compiling option to remove speed limitations --- emulator.pas | 21 +++++++++++++++++---- readme.md | 16 +++++++++------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/emulator.pas b/emulator.pas index fd418c7..f8ac342 100644 --- a/emulator.pas +++ b/emulator.pas @@ -15,8 +15,7 @@ type {$endif} const - IO = $ffff; - LastRAM = $ffef; + LastRAM = $ffef; //The last address of RAM var Hlt, ASCII, Verbose: boolean; //Halt, ASCII, and verbose flags @@ -55,12 +54,14 @@ begin end; //Wait to emulate CPU speed of ~500 KIPS +{$ifndef fast} procedure wait; begin if IC div 500 = 0 then sleep (1) else sleep (IC div 500); IC := 0; end; +{$endif} //Load a byte from memory function LoadByte (W: word): byte; @@ -68,8 +69,10 @@ var B: byte; begin //Terminal input - if W = IO then begin + if W = $ffff then begin + {$ifndef fast} wait; + {$endif} //Read a keypress repeat Ch := ReadKey; @@ -116,7 +119,9 @@ begin //Tape reader {$ifdef tape} else if W = $fffd then begin + {$ifndef fast} wait; + {$endif} assign (State, ExpandFileName ('~/.tapes.thingamajig')); //Check the reader state if FileExists (ExpandFileName ('~/.tapes.thingamajig')) then begin @@ -162,15 +167,19 @@ end; procedure StoreByte (W: word; B: byte); begin //Terminal output - if W = IO then begin + if W = $ffff then begin + {$ifndef fast} wait; + {$endif} Ch := ansichar (B); Output; end //Printer {$ifdef printer} else if W = $fffe then begin + {$ifndef fast} wait; + {$endif} assign (Prn, '/dev/usb/lp0'); try rewrite (Prn); @@ -183,7 +192,9 @@ begin //Tape punch {$ifdef tape} else if W = $fffd then begin + {$ifndef fast} wait; + {$endif} assign (State, ExpandFileName ('~/.tapes.thingamajig')); //Check the punch state if FileExists (ExpandFileName ('~/.tapes.thingamajig')) then begin @@ -413,6 +424,8 @@ begin end; + {$ifndef fast} wait; + {$endif} end. diff --git a/readme.md b/readme.md index 2aed37d..4639339 100644 --- a/readme.md +++ b/readme.md @@ -92,14 +92,16 @@ uninitialised. Emulator -------- -The emulator runs at roughly 500 KIPS and has the full 65520 bytes of -RAM. +The emulator runs at roughly 500 KIPS, has the full 65520 bytes of RAM, +and interacts with memory mapped devices at roughly 1000 CPS. The speed +limitations can be removed by compiling the emulator with the argument +-dfast. -Input and output are handled by an emulated roughly 1000 CPS glass -teletype terminal with local echo. Note that of the control characters -only bell, backspace, line feed, and carriage return are used by the -terminal, and the backspace and delete keys are tied to their respective -characters and non-character keys to null. +Input and output are handled by an emulated glass teletype terminal with +local echo. Note that of the control characters only bell, backspace, +line feed, and carriage return are used by the terminal, and the +backspace and delete keys are tied to their respective characters and +non-character keys to null. In Linux the emulator can be compiled with support for a character printer and an emulated punched tape reader and punch with the arguments