Add support for non-ASCII keys and better the punched tape support

This commit is contained in:
CrazyEttin 2022-08-15 17:21:01 +03:00
parent cbea508d91
commit 2b92cf26a5
2 changed files with 44 additions and 20 deletions

View File

@ -8,7 +8,7 @@ const
IO = $ffff;
var
Hlt: boolean; //Halt flag
Hlt, ASCII: boolean; //Halt and ASCII flags
Op: 0 .. $f; //Opcode
X, Y: 0 .. 3; //Register arguments
Addr, IP, RP: word; //Address argument and instruction and return pointers
@ -16,9 +16,10 @@ var
Mem: array [0 .. $ffef] of byte; //Memory
Prog{$ifdef printer}, Prn{$endif}{$ifdef tape}, TapeIn, TapeOut{$endif}: file of byte; //Program file, line printer, and punched tape reader and punch
{$ifdef tape}
TapePos: integer; //Punched tape reader position pointer
TapeInFile: string; //Punched tape reader source file
TapeInPos: integer; //Punched tape reader position pointer
{$endif}
Ch: ansichar; //Character for input and output
Ch, Scan: ansichar; //Character for input and output and scancode for non-ASCII keys
begin
@ -27,7 +28,8 @@ begin
IP := 0;
RP := $fff0;
{$ifdef tape}
TapePos := 0;
TapeInFile := ' ';
TapeInPos := 0;
{$endif}
//Read a program file and check for errors
@ -129,26 +131,48 @@ begin
else if Op = $a then begin
//Terminal input
if Addr = IO then begin
//Read a keypress
repeat
Ch := ReadKey;
//Check for non-ASCII keys
if Ch = ansichar (0) then begin
//Non-ASCII
if keypressed then begin
Scan := ReadKey;
{$ifdef tape}
//Insert a tape in the tape reader
if Scan = ansichar ($52) then begin
writeln ();
write ('Tape to be read: ');
readln (TapeInFile);
if TapeInFile = '' then TapeInFile := ' ';
TapeInPos := 0
end;
{$endif}
ASCII := false;
end
//Null
else ASCII := true;
end
//Other ASCII
else ASCII := true;
until ASCII = true;
//Process the keypress
write (Ch); //Local echo
R [X] := byte (Ch);
end
//Tape reader
{$ifdef tape}
else if Addr = $fffd then begin
assign (TapeIn, 'tapein');
assign (TapeIn, TapeInFile);
try
reset (TapeIn);
seek (TapeIn, TapePos);
if eof (TapeIn) = false then begin
read (TapeIn, R [X]);
TapePos := TapePos + 1;
end
else R [X] := 0;
seek (TapeIn, TapeInPos);
read (TapeIn, R [X]);
TapeInPos := TapeInPos + 1;
close (TapeIn);
except
R [X] := 0;
TapePos := 0;
end;
end
{$endif}

View File

@ -91,14 +91,14 @@ this.
Arbitrary devices can be mapped to the other reserved addresses.
The emulator can be compiled with support for a line printer at
/dev/usb/lp0 with the argument -dprinter, and for an emulated punched
tape reader and punch at tapein and tapeout respectively with -dtape.
The printer is mapped to address FFFE in the emulator and the tape
reader and punch to FFFD. To reset the tape reader to the beginning of a
tape, for example to change the tape, read once with no file at tapein.
If you wish to use a different setup you have to modify the code
yourself.
The emulator can be compiled with support for a line printer and an
emulated punched tape reader and punch with the arguments -dprinter and
-dtape respectively. The printer outputs into /dev/usb/lp0 and the tape
punch to tapeout. To (re)set the tape to be read press the insert key at
any input and enter a file name; the input will resume after this. The
printer is mapped to address FFFE in the emulator and the tape reader
and punch to FFFD. If you wish to use a different setup you have to
modify the code yourself.
Initial Program Loader
----------------------