Jump to content
IGNORED

Running a BBS in CP/M (BYE and LISTEN)


tschak909

Recommended Posts

the implementation of BYE for FujiNet is easily the simplest, ever:

 

/**
 * #FujiNet BYE.COM
 *
 * Author:
 *  Thom Cherryhomes <thom.cherryhomes@gmail.com>
 *
 */

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
  // Hang up!
  printf("Thanks for calling!\n");

  sleep(2);

  bdos(182,0);

  printf("Waiting for connection...");

  while (bdos(180,0) == 0)
    {
      csleep(1);
    }

  printf("Accepting connection.");

  bdos(181,0);

  execv("A:BBS.COM",NULL);

  return 0;

}

BDOS call 182 is TCP DROP.

BDOS call 181 is TCP Accept connection and go to Tee mode (echo console to socket)

BDOS call 180 is TCP Connection available?

 

The additional program is LISTEN.COM which binds a TCP server socket and sets it to listen:

 

/**
 * #FujiNet LISTEN.COM
 *
 * Author:
 *  Thom Cherryhomes <thom.cherryhomes@gmail.com>
 *
 */

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
  unsigned short port = atoi(argv[1]);

  if (argc<2)
    {
      printf("\nPort # 1-65535 required.\n");
      return 1;
    }

  // Request to listen for connections.
  bdos(179,port);

  printf("\nNow listening for TCP connections on port %u\n",port);

  return 0;
}

These bdos functions funnel into _bdos() inside runcpm/cpm.h

	case 179:
		HL = bios_tcpListen(DE);
		break;
	case 180:
		HL = bios_tcpAvailable();
		break;
	case 181:
		HL = bios_tcpTeeAccept();
		break;
	case 182:
		HL = bios_tcpDrop();
		break;

and those are calls inside runcpm/abstraction_fujinet.h

uint8_t bios_tcpListen(uint16_t port)
{
	Debug_printf("Do we get here?\n");

	if (client.connected())
		client.stop();

	if (server != nullptr && port != portActive)
	{
		server->stop();
		delete server;
	}

	server = new fnTcpServer(port,1);
	server->begin(port);

	Debug_printf("bios_tcpListen - Now listening on port %u\n", port);
	return server != nullptr;
}

uint8_t bios_tcpAvailable(void)
{
	if (server == nullptr)
		return 0;

	return server->hasClient();
}

uint8_t bios_tcpTeeAccept(void)
{
	if (server == nullptr)
		return false;

	if (server->hasClient())
		client = server->accept();

	teeMode = true;

	return client.connected();
}

uint8_t bios_tcpDrop(void)
{
	if (server == nullptr)
		return false;

	client.stop();

	return true;
}

note the teeMode variable, it's a flag, that's checked in the console abstractions to redirect console I/O out the connected socket:

/* Console abstraction functions */
/*===============================================================================*/

int _kbhit(void)
{
	if (teeMode == true)
		return client.available() | fnUartSIO.available();
	else
		return fnUartSIO.available();
}

uint8_t _getch(void)
{
	if (teeMode == true)
	{
		while (!fnUartSIO.available())
		{
			if (client.available())
			{
				uint8_t ch;
				client.read(&ch, 1);
				return ch & 0x7F;
			}
		}
		return fnUartSIO.read() & 0x7F;
	}
	else
	{
		while (!fnUartSIO.available())
		{
		}
		return fnUartSIO.read() & 0x7f;
	}
}

uint8_t _getche(void)
{
	uint8_t ch = _getch() & 0x7f;
	fnUartSIO.write(ch);
	if (teeMode == true)
		client.write(ch);
	return ch;
}

void _putch(uint8_t ch)
{
	fnUartSIO.write(ch & 0x7f);
	if (teeMode == true)
		client.write(ch);
}

and with that, you can support BYE.COM style BBS programs.

 

Would love to add support for BBSes that are self hosted, like Citadel or CBBS, perhaps this could inspire someone? (please? I really need to get back on N:)

 

-Thom

Link to comment
Share on other sites

My father and I first ran a copy of RBBS as our first BBS (1982), later shifting to SBBS and TBBS, with a copy of TP-BBS along the way, all of these boards shared the name Nak-Attack 1.

 

I had hoped to find a copy of TBBS to run, but I can't find one, and Jason Scott lists it, but doesn't have a copy of it.

 

Later, with the very first version of Fido, we launched Nak Attack II.

 

Afterwards, We would go through various iterations:

 

* Colossus

* Collie

* Opus-CBCS 0.00 to 1.03

 

The Opus incarnation would run from 1986 to 1993.

 

Because of my father's deep hatred of Maximus-CBCS, he shifted gears to Wildcat! (which, ironically, shares code with Colossus), we ran that until the whole thing was shuttered in 1996, as Nak Attack VII.

 

-Thom

 

 

  • Like 1
Link to comment
Share on other sites

interesting as a local community college nacc-acc (northampton area community college was the name but it's changed now)... also ran some of those BBS software choices... they of course provided an Atari area.... and the college hosted ABE's ACE's meetings for a time...

Edited by _The Doctor__
  • Like 1
Link to comment
Share on other sites

2 hours ago, Kyle22 said:

That's great. I love the speed. Now, about the memory... I suspect I already know the answer, but: Is Z380 with some RAM out of the question?

Wishful thinking...

:)

 

whatever somebody has the time and inclination to implement. I saw a straight path to a working Z80 CP/M implementation, and I went for it.

-Thom

 

  • Like 1
Link to comment
Share on other sites

2 minutes ago, phigan said:

Do you have a link to your compiled bye.com and listen.com? And if you removed the A: from the BBS.COM would it just run it from the current directory?

Yes, it's part of the fujinet-cpm-tools (and I did build a package), and yes, it would.

 

https://github.com/FujiNetWIFI/fujinet-cpm-tools

 

Currently to use, you will need a firmware built from the master branch via platform.io.

 

-Thom

 

Edited by tschak909
  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...