Add input status register to the emulator

This commit is contained in:
CrazyEttin 2022-09-30 17:07:10 +03:00
parent da67a19ac6
commit 7c2905b558
2 changed files with 68 additions and 18 deletions

View File

@ -8,9 +8,10 @@ program Emulator;
{$define tape}
{$define floppy}
{$define modem}
{$define status}
{$endif}
uses SysUtils, Crt{$ifdef modem}, Sockets{$endif};
uses SysUtils, Crt{$ifdef modem}, Sockets{$endif}{$ifdef status}, BaseUnix{$endif};
type
{$ifdef tape}
@ -70,7 +71,7 @@ var
{$endif}
Ch, Scan: ansichar; //Character for input and output and scancode for non-ASCII keys
Verbose, IC, LFX: integer; //Verbose flag, instruction counter for CPU speed, and line feed position marker
Fetched{$ifdef floppy}, Disc0Track, Disc1Track, Disc0Sect, Disc1Sect{$endif}: byte; //Fetched byte, and disc drive locations
Fetched{$ifdef floppy}, Disc0Track, Disc1Track, Disc0Sect, Disc1Sect{$endif}: byte; //Fetched byte and disc drive locations
{$ifdef floppy}
DiscDrive: 0 .. 1; //Current disc drive number
{$endif}
@ -80,6 +81,9 @@ var
ServerSocket: longint; //Server socket
ServerAddr: TInetSockAddr; //Server address
{$endif}
{$ifdef status}
FileDescs: TFDset; //File descriptor set
{$endif}
//Terminal output
procedure Output;
@ -266,6 +270,46 @@ begin
else B := 0;
end
{$endif}
{$ifdef status}
//Input status register
else if W = $fff8 then begin
{$ifndef fast}
wait (1);
{$endif}
//Initialise the register
B := 0;
//FFFF: Terminal
fpfd_zero (FileDescs);
fpfd_set (0, FileDescs);
if fpSelect (1, @FileDescs, nil, nil, 1) > 0 then B := B or 1;
//FFFE: No input
B := B or 2;
//FFFD: Tape reader or no input
B := B or 4;
//FFFC: Disc system data or no input
B := B or 8;
//FFFB: No input
B := B or $10;
//FFFA: Modem or no input
{$ifdef modem}
//Connect
CallServer;
//Check the connection
if Calling then begin
fpfd_zero (FileDescs);
fpfd_set (ServerSocket, FileDescs);
if fpSelect (ServerSocket + 1, @FileDescs, nil, nil, 0) > 0 then B := B or $20;
end;
{$endif}
{$ifndef modem}
B := B or $20;
{$endif}
//FFF9: No input
B := B or $40;
//FFF8: Input status register
B := B or $80;
end
{$endif}
//Unused addresses
else if W > LastRAM then B := 0
//Regular load

View File

@ -120,22 +120,23 @@ characters and non-character keys null.
In Linux the emulator can be compiled with support for a character
printer, an emulated high speed (roughly 500 CPS in and 50 CPS out)
8-bit paper tape reader and punch, an emulated two-drive 8" floppy disc
system, and a roughly 300 b/s modem with the arguments -dprinter,
-dtape, -dfloppy, and -dmodem respectively. Full 64 KiB of RAM and all
of these options can also be enabled with the argument -dfull. The
printer is mapped to address FFFE, the tape reader and punch to FFFD,
the disc system to FFFB and FFFC, and the modem to FFFA. The printer
prints into /dev/usb/lp0. The tape files read from and punched to are
(re)set using the program tapectl with the arguments -r and -p
respectively and the disc files in drives 0 and 1 using the program
floppyctl with the arguments -0 and -1 respectively. The disc system
uses hard sectored single-sided discs with 77 tracks of 32 sectors of
137 bytes, or 337568 bytes in total: the disc files must be of this
size. The modem is controlled by the program modemctl: the option -c is
used to "call" an IP address and port, -a to set the modem ready for
"answering" "calls" to port 1337, and -h to "hang". "Hanging" manually
is not necessary when "calling" a different address or switching between
"calling" and "answering". Note: "Answering" is not functional yet.
system, a roughly 300 b/s modem, and an input status register with the
arguments -dprinter, -dtape, -dfloppy, -dmodem, and -dstatus
respectively. Full 64 KiB of RAM and all of these options can also be
enabled with the argument -dfull. The printer is mapped to address FFFE,
the tape reader and punch to FFFD, the disc system to FFFB and FFFC, the
modem to FFFA, and the input status register to FFF8. The printer prints
into /dev/usb/lp0. The tape files read from and punched to are (re)set
using the program tapectl with the arguments -r and -p respectively and
the disc files in drives 0 and 1 using the program floppyctl with the
arguments -0 and -1 respectively. The disc system uses hard sectored
single-sided discs with 77 tracks of 32 sectors of 137 bytes, or 337568
bytes in total: the disc files must be of this size. The modem is
controlled by the program modemctl: the option -c is used to call an IP
address and port, -a to set the modem ready for answering calls to port
1337, and -h to hang. Hanging manually is not necessary when making a
new call or switching between calling and answering. Note: Answering is
not implemented yet.
The floppy disc system uses two ports: command at FFFB and data at FFFC.
Only the low nibble of the command port is used, consisting of a
@ -157,6 +158,11 @@ The commands for the disc system are:
6: Read a sector from a disc to the buffer.
7: Write a sector from the buffer to a disc.
The input status register can be used to check if a device is ready to
be read from. The reserved addresses FFF8-FFFF are mapped to the bits
7-0: a set bit means either that the device is ready or that no input
device is mapped to the address in question.
The IPL loads the program specified as an argument when running the
emulator.