From e626369a160ec0da7f2d91e8818bcaf6f664acc4 Mon Sep 17 00:00:00 2001 From: CrazyEttin <> Date: Mon, 3 Oct 2022 00:57:36 +0300 Subject: [PATCH] Correct some bugs in the emulator and tweak the readme --- emulator.pas | 23 +++++++++++++---------- readme.md | 8 ++++---- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/emulator.pas b/emulator.pas index e73cef3..10cd334 100644 --- a/emulator.pas +++ b/emulator.pas @@ -13,17 +13,18 @@ program Emulator; uses SysUtils, Crt{$ifdef modem}, BaseUnix, Sockets{$endif}{$ifdef status}{$ifndef modem}, BaseUnix{$endif}{$endif}; +{$ifdef tape} +//Tape file path and reset state type - {$ifdef tape} - //Tape file path and reset state Tape = record Path: shortstring; Reset: boolean; Pos: integer; end; - {$endif} - {$ifdef modem} - //Modem connection state +{$endif} +{$ifdef modem} +//Modem connection state +type Connection = record Call: boolean; Answer: boolean; @@ -31,7 +32,7 @@ type Port: word; Hang: boolean; end; - {$endif} +{$endif} const //The last address of RAM @@ -87,9 +88,11 @@ var {$endif} //Ignore signal +{$ifdef modem} procedure DoSig (Sig: cint); cdecl; begin end; +{$endif} //Terminal output procedure Output; @@ -179,7 +182,7 @@ begin //Create a socket ServerSocket := fpSocket (AF_INET, SOCK_STREAM, 0); if ServerSocket <> -1 then begin - //Connect + //Call ServerAddr.sin_family := AF_INET; ServerAddr.sin_addr.s_addr := htonl (ModemConn.Addr); ServerAddr.sin_port := htons (ModemConn.Port); @@ -189,7 +192,7 @@ begin end; end; end; - //Answer + //Listen and answer if ModemConn.Answer then if Answering = false then begin //Create a socket ListenSocket := fpSocket (AF_INET, SOCK_STREAM, 0); @@ -198,9 +201,9 @@ begin ServerAddr.sin_family := AF_INET; ServerAddr.sin_addr.s_addr := htonl (ModemConn.Addr); ServerAddr.sin_port := htons (ModemConn.Port); - if fpBind (ListenSocket, @ServerAddr, Sizeof (ServerAddr)) <> -1 then begin + if fpBind (ListenSocket, @ServerAddr, Sizeof (ServerAddr)) <> -1 then begin if fpListen (ListenSocket, 1) <> -1 then begin - //Accept + //Answer ClientAddrSize := sizeof (ClientAddr); ClientSocket := fpAccept (ListenSocket, @ClientAddr, @ClientAddrSize) ; if ClientSocket <> -1 then begin diff --git a/readme.md b/readme.md index 28d529c..181ca59 100644 --- a/readme.md +++ b/readme.md @@ -133,10 +133,10 @@ 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 a -loopback or local IP address and port, and -h to hang. Hanging manually -is not necessary when making or answering a new call or switching -between calling and answering. +address and port, -a to get ready for answering a call to a loopback or +local IP address and port, and -h to hang. Hanging manually is not +necessary when making or getting ready to answer a new call, switching +between calling and answering, or shutting down the emulator. 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