Emulation of RS232 VIC20 for running multiplayer games

You need an actual VIC.

Moderator: Moderators

mimmosic
Vic 20 Drifter
Posts: 23
Joined: Mon Jul 01, 2019 8:28 am
Website: https://vic20reloaded.com
Location: Bologna
Occupation: programmer

Emulation of RS232 VIC20 for running multiplayer games

Post by mimmosic »

Hello guys,
back in the 80s I was able to connect two VIC20s (mine and a friend's) and developed a few two-player, network games, plus a chat program.

Nowadays, I have got all programs on a .d64 and would really like to see them running on two emulators, installed on two computer connected to the net.

I am running WinVICE and saw that it has a nice RS232 emulation option but, despite the several efforts, I could not get two machines to communicate using the same LAN.

Here is the simple program I am using on both machines:

Code: Select all

10 OPEN2,2,0,CHR$(138)+CHR$(32)
20 GET#2,A$:PRINTA$;
30 GETA$:PRINTA$;:IFA$<>""THENS$=S$+A$
40 IFA$=CHR$(13)THENPRINT#2,S$;:S$=""
50 GOTO20
the above would set up a 2400 baud comm channel on the RS232 and send whatever you type on the keyboard to the other end, and printing out what it receives.

On both emulators I set up RS232 emulation:
Settings/RS232 userport settings,Enable ON, Userport device 2 and 2400 baud.
Then Settings/RS232 settings, device #2, the IP address of the other PC plus the suggested port (25232) eg.: 192.168.0.193:25232

unfortunately they will not speak each other and I have no clue at what's going wrong.

I can guarantee that with two physical VIC20s it works - I have a cross-linked cable working with the above program, I use it just to see if the two VICs are communicating then I know I can run the network games successfully.

Anybody out there had been successful in making two emulators speak each other this way?
mimmosic
Vic 20 Drifter
Posts: 23
Joined: Mon Jul 01, 2019 8:28 am
Website: https://vic20reloaded.com
Location: Bologna
Occupation: programmer

Re: Emulation of RS232 VIC20 for running multiplayer games

Post by mimmosic »

Hello, an update.

It seems that VICE emulator cannot communicate with another VICE emulator by simply filling out the correct RS232 settings.

I have found out that a program named tcpser is needed to map the virtual RS232 with a tcpip transport.
Too bad that it won't work on my Windows 10 machine. The command to activate tcpser:

Code: Select all

tcpser -v 25232 -l 4 -s 2400
would always end with:

FATAL:Server socket could not be bound to port (Cannot assign requested address)
ENTER_EXIT:Exitting ip_init_server_conn function
FATAL:Could not initialize ip232 server socket (Cannot assign requested address)

If anybody has successfully experienced using tcpser with VICE on Windows recently, I'm very interested.

Anyway, I will be posting here soon the programs/multiplayer games diskette image and the schematics to cross connect two VICs in case one wants to try them out on physical devices.
User avatar
joshuadenmark
Big Mover
Posts: 1218
Joined: Sat Oct 23, 2010 11:32 am
Location: Fr-Havn, Denmark
Occupation: Service engineer

Re: Emulation of RS232 VIC20 for running multiplayer games

Post by joshuadenmark »

Following with interest :D
Kind regards, Peter.
____________________________________________________
In need of a wiki logon - PM me
mimmosic
Vic 20 Drifter
Posts: 23
Joined: Mon Jul 01, 2019 8:28 am
Website: https://vic20reloaded.com
Location: Bologna
Occupation: programmer

Re: Emulation of RS232 VIC20 for running multiplayer games

Post by mimmosic »

Here is the direct link to the networking games and programs diskette

https://files.vic20reloaded.com/download/network-vic20

Contents:

1. TERM - very simple terminal program for testing connection, the one I typed at the beginning of the thread
2. HAPPYLINK - full chat program between two connected VICs
3. BATTNAVALE - The classic ship battle, played against each other
4. HORSE RACING - Nice horse racing betting program, both player will see the same race. Serious fun.

Sorry for they all are in Italian, but they are so simple that they are easy to figure out. Obviously if you run them onto a VIC that's not connected, you won't get very far so I advise to start from TERM to check if the connection between the VICs work.

Next, I will snap a pic of the cable (very simple - it's actually a normal audio stereo cable) I used to connect the two VICs, and the schematics.

It would awesome to get the above to work between two emulated VICs, but at present I had no luck under Win10.
mimmosic
Vic 20 Drifter
Posts: 23
Joined: Mon Jul 01, 2019 8:28 am
Website: https://vic20reloaded.com
Location: Bologna
Occupation: programmer

Re: Emulation of RS232 VIC20 for running multiplayer games

Post by mimmosic »

Building the connection cable is easy.

1. get a normal stereo audio cable (two lines plus the ground) and two connectors for the RS232 port.
2. Mark each oonnector with a label "TOP SIDE" just to avoid confusion later
3. Solder the ground of the cable to the A pin of both connectors.
4. Connector 1: Solder pins B and C together to red cable, Solder pin M to white cable
5. Connector 2, do the opposite: Solder pins B and C together to WHITE cable, Solder pin M to RED cable

Connect to VICs, turn them on, test.
Below the schematics of the VICs user port. Pins B and C are CB1/PB0 (input), M pins is CB2 (output)

Image

Next, I'll be posting the photos of my cable's finished connectors. I tested the above with a 50m+ cable and worked great.

After seeing it working on real VICs, you will want to test it on emulators like I do!
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: Emulation of RS232 VIC20 for running multiplayer games

Post by srowe »

You're missing a GND connection between the two systems.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Emulation of RS232 VIC20 for running multiplayer games

Post by Mike »

srowe wrote:You're missing a GND connection between the two systems.
mimmosic wrote:3. Solder the ground of the cable to the A pin of both connectors.
;)

BTW, I'm also interested in a working solution (particularly, on Win10) so I'm able to test a scenario that *is* supposed to work - i.e. two (emulated) VIC-20s connected with a null modem cable, a vanilla terminal program running on one VIC-20 and some other program with redirected I/O running on the other VIC-20.

I also tried out tcpser some time ago and, like you, couldn't get it to work. For the time being, my bet would be on a small pipe program, which opens sockets on two different ports, receiving on port A and sending the data to port B, receiving other data on port B and sending the data to port A. (Win)VICE #1 would use port A, (Win)VICE #2 would use port B, on localhost. Will have to try out this idea in the next time (unless someone else picks up that idea and spares me the work...).
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: Emulation of RS232 VIC20 for running multiplayer games

Post by srowe »

Yeh, I can't read tonight.
mimmosic
Vic 20 Drifter
Posts: 23
Joined: Mon Jul 01, 2019 8:28 am
Website: https://vic20reloaded.com
Location: Bologna
Occupation: programmer

Re: Emulation of RS232 VIC20 for running multiplayer games

Post by mimmosic »

Here are the pictures of the cable I use.

Image
Image
Image

Now I agree with @Mike the mentioned solution would be just perfect for experiemnting and developing, it would overcome the need to use two different IPs (so using two physical computers or at least two networking interfaces). Perhaps starting working on the source code of tcpser could be a starting point.

What puzzles me is that tcpser seems not to be working but there are a number of posts on the net of people having successfully used it in the past.
Is there somebody having a 32-bit windows who can give it a go and see if it works?
It can be downloaded from here: http://gbbs.applearchives.com/misc-util ... r-package/
and once you put all the zip contents in the same foler the command is this:

Code: Select all

tcpser -v 25232 -l 4 -s 2400
and if you get no errors... well it's just because it needs the 32bit windows then.

In the meantime, I'll be getting a pendrive version of Linux in both computers and try the linux way (vice + tcpser). It seems that under linux this solution runs better. :wink:
User avatar
beamrider
Vic 20 Scientist
Posts: 1452
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: Emulation of RS232 VIC20 for running multiplayer games

Post by beamrider »

there was an issue with VICE serial port handling

https://sourceforge.net/p/vice-emu/bugs/609/

according to the comments, it's been fixed, but I haven't verified this myself
mimmosic
Vic 20 Drifter
Posts: 23
Joined: Mon Jul 01, 2019 8:28 am
Website: https://vic20reloaded.com
Location: Bologna
Occupation: programmer

Re: Emulation of RS232 VIC20 for running multiplayer games

Post by mimmosic »

Hello,
I have been able to get a 64bit compiled version of tcpser and this one somehow works. Let's say that with it, at least something happens.

The VIC20 emulator equipped with the basic terminal program transmits but (this is the weirdest part) also receives its own transmission, like it's in a loop.

Despite trying different configurations, I never was able to make two VICE (on different machines, or on the same machine) to communicate each other.

My main problem is that I do not understand what actually VICE RS232 settings are supposed to do.
The link cable I used is so simple, but I can't find a software equivalent for emulators.
I can't even seem to find any complete documentation around. If anybody has experience in this, or can share docs, please do!

Emulators on modern PCs (if the RS232 interface could be properly emulated over tcp/ip!) could allow people to quickly and cheaply experience and develop software for multiplayer gaming and using network services to be executed on vintage commodore computers. This will give them fresh air for a new life.
User avatar
Schema
factor
Posts: 1430
Joined: Tue Mar 23, 2004 7:07 am
Website: http://www.jammingsignal.com
Location: Toronto, Ontario

Re: Emulation of RS232 VIC20 for running multiplayer games

Post by Schema »

mimmosic wrote:The VIC20 emulator equipped with the basic terminal program transmits but (this is the weirdest part) also receives its own transmission, like it's in a loop.
Is there a way to disable echo in tcpser?
mimmosic
Vic 20 Drifter
Posts: 23
Joined: Mon Jul 01, 2019 8:28 am
Website: https://vic20reloaded.com
Location: Bologna
Occupation: programmer

Re: Emulation of RS232 VIC20 for running multiplayer games

Post by mimmosic »

@Schema: I have read from tcpser help that modem command:

ate0

should disable echo, but I cannot understand if what terminal program receives is an echo or the main result of the transmission... the other VICE instance receives nothing.

The issue remains open: while it's pretty simple to make two physical VICs to communicate, I am still seeking someone who has succeeded in making two VICE instances to communicate between them.
mimmosic
Vic 20 Drifter
Posts: 23
Joined: Mon Jul 01, 2019 8:28 am
Website: https://vic20reloaded.com
Location: Bologna
Occupation: programmer

Re: Emulation of RS232 VIC20 for running multiplayer games

Post by mimmosic »

Hello,
an update on the topic.

I am still researching the way to make two emulated VIC20s to communicate through the emulated RS232.

After experimenting a while with tcpser, I understood this tool is not what I need to accomplish my goal - mostly because tcpser is designed to work, or to be seen, as a MODEM and party because of too few examples/docs on uses different than accessing BBSes. When correctly configured, tcpser replies OK when you type AT to it, and its purpose - if I understood it correctly - is simply to emulate a modem and incapsulating modem communication inside tcp/ip to let you connect to a BBS via the Internet exactly as you would on a modem-operated landline call.

My many attempts of making two VICs to mutually speak/listen (using their own tcpser of course) has failed.
Clearly tcpser is not designed for this task, plus has all the modem emulation stuff which is not required, plus I cannot find enough documentation on it. For example it has a nice -D direct connection option, too bad I cannot find any docs where they say how to use it.

So, I bounced back on Google and found this nifty program: netcat, available for windows:

https://joncraton.org/blog/46/netcat-for-windows/

My aim is firstly to see what exactly comes out from the WinVICE window and especially if it's good enough to do something with it.
Now, if you open a windows command shell and run netcat by typing:

nc -l -p 25232 -o out.txt

then you have netcat listening on port 25232 and echoing everything it receives.

I could then fiddle with communication parameters inside the emulated VIC and bingo!
I saw that, inside WinVice, by opening the communication channel with the following combinations:

OPEN 2,2,0,CHR$(8)+CHR$(0) - for RS232 emulated at 1200 baud
OPEN 2,2,0,CHR$(138)+CHR$(0) - for RS232 emulated at 2400 baud

both produce a crystal clean output as received by the netcat program!
The contents of the out.txt will be exactly what you typed inside the emulated VIC, with its ASCII CR (decimal 13) at the end of each line.
So, the emulated vic correctly sends data out of the window and I can now capture and use it from inside a C program. :D

Now, the next step would be that of modifying that netcat, making it echo that received chars on another port specified by me (say, 25233) where I will have the second emulated VIC listening.

My final goal is not only to allow existing software to work also on emulated VIC20s (there's a nice diskette I shared at https://vic20reloaded.com/networking-vic-20/ with 2 distributed games and 1 chat program) - I would like to have the chance to use emulated VICs to comfortably develop new software.

If someone is familiar with C and wants to help me in the task, that would be really appreciated!
mimmosic
Vic 20 Drifter
Posts: 23
Joined: Mon Jul 01, 2019 8:28 am
Website: https://vic20reloaded.com
Location: Bologna
Occupation: programmer

Re: Emulation of RS232 VIC20 for running multiplayer games

Post by mimmosic »

Problem resolved!

Two emulated VIC-20s correctly comunicate and play inside WinVice emulators on the same machine (and most likely between internet-connected machines) using socat to make the tunnel between the two machines and my software.

I was able to play ship battle between two emulated VIC20s, and even have an emulated VIC20 to speak with an emulated c64.

Image
Image

The key was the socat utility to implement the virtual cable:

socat tcp-listen:25232 tcp-listen:25231

The full tutorial here if somebody's interested:
https://vic20reloaded.com/vic20-c64-net ... g-winvice/
Post Reply