Add support for non-ASCII keys and better the punched tape support
This commit is contained in:
parent
cbea508d91
commit
2b92cf26a5
48
emulator.pas
48
emulator.pas
|
@ -8,7 +8,7 @@ const
|
||||||
IO = $ffff;
|
IO = $ffff;
|
||||||
|
|
||||||
var
|
var
|
||||||
Hlt: boolean; //Halt flag
|
Hlt, ASCII: boolean; //Halt and ASCII flags
|
||||||
Op: 0 .. $f; //Opcode
|
Op: 0 .. $f; //Opcode
|
||||||
X, Y: 0 .. 3; //Register arguments
|
X, Y: 0 .. 3; //Register arguments
|
||||||
Addr, IP, RP: word; //Address argument and instruction and return pointers
|
Addr, IP, RP: word; //Address argument and instruction and return pointers
|
||||||
|
@ -16,9 +16,10 @@ var
|
||||||
Mem: array [0 .. $ffef] of byte; //Memory
|
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
|
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}
|
{$ifdef tape}
|
||||||
TapePos: integer; //Punched tape reader position pointer
|
TapeInFile: string; //Punched tape reader source file
|
||||||
|
TapeInPos: integer; //Punched tape reader position pointer
|
||||||
{$endif}
|
{$endif}
|
||||||
Ch: ansichar; //Character for input and output
|
Ch, Scan: ansichar; //Character for input and output and scancode for non-ASCII keys
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
||||||
|
@ -27,7 +28,8 @@ begin
|
||||||
IP := 0;
|
IP := 0;
|
||||||
RP := $fff0;
|
RP := $fff0;
|
||||||
{$ifdef tape}
|
{$ifdef tape}
|
||||||
TapePos := 0;
|
TapeInFile := ' ';
|
||||||
|
TapeInPos := 0;
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
//Read a program file and check for errors
|
//Read a program file and check for errors
|
||||||
|
@ -129,26 +131,48 @@ begin
|
||||||
else if Op = $a then begin
|
else if Op = $a then begin
|
||||||
//Terminal input
|
//Terminal input
|
||||||
if Addr = IO then begin
|
if Addr = IO then begin
|
||||||
|
//Read a keypress
|
||||||
|
repeat
|
||||||
Ch := ReadKey;
|
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
|
write (Ch); //Local echo
|
||||||
R [X] := byte (Ch);
|
R [X] := byte (Ch);
|
||||||
end
|
end
|
||||||
//Tape reader
|
//Tape reader
|
||||||
{$ifdef tape}
|
{$ifdef tape}
|
||||||
else if Addr = $fffd then begin
|
else if Addr = $fffd then begin
|
||||||
assign (TapeIn, 'tapein');
|
assign (TapeIn, TapeInFile);
|
||||||
try
|
try
|
||||||
reset (TapeIn);
|
reset (TapeIn);
|
||||||
seek (TapeIn, TapePos);
|
seek (TapeIn, TapeInPos);
|
||||||
if eof (TapeIn) = false then begin
|
read (TapeIn, R [X]);
|
||||||
read (TapeIn, R [X]);
|
TapeInPos := TapeInPos + 1;
|
||||||
TapePos := TapePos + 1;
|
|
||||||
end
|
|
||||||
else R [X] := 0;
|
|
||||||
close (TapeIn);
|
close (TapeIn);
|
||||||
except
|
except
|
||||||
R [X] := 0;
|
R [X] := 0;
|
||||||
TapePos := 0;
|
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
16
readme.md
16
readme.md
|
@ -91,14 +91,14 @@ this.
|
||||||
|
|
||||||
Arbitrary devices can be mapped to the other reserved addresses.
|
Arbitrary devices can be mapped to the other reserved addresses.
|
||||||
|
|
||||||
The emulator can be compiled with support for a line printer at
|
The emulator can be compiled with support for a line printer and an
|
||||||
/dev/usb/lp0 with the argument -dprinter, and for an emulated punched
|
emulated punched tape reader and punch with the arguments -dprinter and
|
||||||
tape reader and punch at tapein and tapeout respectively with -dtape.
|
-dtape respectively. The printer outputs into /dev/usb/lp0 and the tape
|
||||||
The printer is mapped to address FFFE in the emulator and the tape
|
punch to tapeout. To (re)set the tape to be read press the insert key at
|
||||||
reader and punch to FFFD. To reset the tape reader to the beginning of a
|
any input and enter a file name; the input will resume after this. The
|
||||||
tape, for example to change the tape, read once with no file at tapein.
|
printer is mapped to address FFFE in the emulator and the tape reader
|
||||||
If you wish to use a different setup you have to modify the code
|
and punch to FFFD. If you wish to use a different setup you have to
|
||||||
yourself.
|
modify the code yourself.
|
||||||
|
|
||||||
Initial Program Loader
|
Initial Program Loader
|
||||||
----------------------
|
----------------------
|
||||||
|
|
Loading…
Reference in New Issue