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 tape}
{$define floppy} {$define floppy}
{$define modem} {$define modem}
{$define status}
{$endif} {$endif}
uses SysUtils, Crt{$ifdef modem}, Sockets{$endif}; uses SysUtils, Crt{$ifdef modem}, Sockets{$endif}{$ifdef status}, BaseUnix{$endif};
type type
{$ifdef tape} {$ifdef tape}
@ -70,7 +71,7 @@ var
{$endif} {$endif}
Ch, Scan: ansichar; //Character for input and output and scancode for non-ASCII keys 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 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} {$ifdef floppy}
DiscDrive: 0 .. 1; //Current disc drive number DiscDrive: 0 .. 1; //Current disc drive number
{$endif} {$endif}
@ -80,6 +81,9 @@ var
ServerSocket: longint; //Server socket ServerSocket: longint; //Server socket
ServerAddr: TInetSockAddr; //Server address ServerAddr: TInetSockAddr; //Server address
{$endif} {$endif}
{$ifdef status}
FileDescs: TFDset; //File descriptor set
{$endif}
//Terminal output //Terminal output
procedure Output; procedure Output;
@ -266,6 +270,46 @@ begin
else B := 0; else B := 0;
end end
{$endif} {$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 //Unused addresses
else if W > LastRAM then B := 0 else if W > LastRAM then B := 0
//Regular load //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 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) 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 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, system, a roughly 300 b/s modem, and an input status register with the
-dtape, -dfloppy, and -dmodem respectively. Full 64 KiB of RAM and all arguments -dprinter, -dtape, -dfloppy, -dmodem, and -dstatus
of these options can also be enabled with the argument -dfull. The respectively. Full 64 KiB of RAM and all of these options can also be
printer is mapped to address FFFE, the tape reader and punch to FFFD, enabled with the argument -dfull. The printer is mapped to address FFFE,
the disc system to FFFB and FFFC, and the modem to FFFA. The printer the tape reader and punch to FFFD, the disc system to FFFB and FFFC, the
prints into /dev/usb/lp0. The tape files read from and punched to are modem to FFFA, and the input status register to FFF8. The printer prints
(re)set using the program tapectl with the arguments -r and -p into /dev/usb/lp0. The tape files read from and punched to are (re)set
respectively and the disc files in drives 0 and 1 using the program using the program tapectl with the arguments -r and -p respectively and
floppyctl with the arguments -0 and -1 respectively. The disc system the disc files in drives 0 and 1 using the program floppyctl with the
uses hard sectored single-sided discs with 77 tracks of 32 sectors of arguments -0 and -1 respectively. The disc system uses hard sectored
137 bytes, or 337568 bytes in total: the disc files must be of this single-sided discs with 77 tracks of 32 sectors of 137 bytes, or 337568
size. The modem is controlled by the program modemctl: the option -c is bytes in total: the disc files must be of this size. The modem is
used to "call" an IP address and port, -a to set the modem ready for controlled by the program modemctl: the option -c is used to call an IP
"answering" "calls" to port 1337, and -h to "hang". "Hanging" manually address and port, -a to set the modem ready for answering calls to port
is not necessary when "calling" a different address or switching between 1337, and -h to hang. Hanging manually is not necessary when making a
"calling" and "answering". Note: "Answering" is not functional yet. 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. 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 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. 6: Read a sector from a disc to the buffer.
7: Write a sector from the buffer to a disc. 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 The IPL loads the program specified as an argument when running the
emulator. emulator.