Audio networked multi-player: Battle Chip!

Show us what you're working on, (preferably with screenshots).
Post Reply
User avatar
Red Zebra
Drutt
Posts: 36
Joined: Fri Jan 20, 2023 7:53 am

Audio networked multi-player: Battle Chip!

Post by Red Zebra »

A few months back I thought it'd be fun to try and write a networked multi-player speccy game (not split-screen).
Since I don't have any of the various communication options available between speccys (interface 1,disciple,spectranet,midi/serial ports...) I thought I'd try to get it running just using the audio sockets. After all, you can read/write to/from tape just using audio.

My first (and obvious) attempt was to try SAVE on one spectrum and simultaneously LOAD on another. This (to my surprise) did not work. So I did some research, and found someone else had been investigating the same thing: https://retrocomputing.stackexchange.co ... x-spectrum

They concluded it should be possible, so after much trial/error/experimentation I produced my own (basic) audio signal detection, then expanded it into a simple Battle Ship clone.
The protocol is way simpler and deliberately slower than the ROM tape functionality and it averages input over time. Hopefully this makes it less error prone (since there's no error correction). There is a basic checksum to attempt to detect errors, but it can't correct errors. Also, because the speaker is usually being listened to by the other speccy (and expecting data) the game has to have no sound effects.

I've tested it on all the rubber-key speccies I have access to (Issue 2 16k, Issue 3B 48k, Issue 6A 48k) and it works on (and between) the 3B and 6A. It did not work on the Issue 2. The software runs, but can't 'hear' the signal. I suspect it's something to do with the ULA in Issue 2s.

I don't have access to any 128k speccies, so I have no idea if it will work between/to/from them (due to electrical differences). The software does run in 128k emulation. The lack of EAR/MIC sockets on the +2 will definitely be an issue. If anyone is willing to test (at your own risk) on any 128k machines, I'd be grateful to know if it works or not.
I also have no idea about recreated speccies and clones.

The longest audio cable I had on hand was 3 metres (which worked), but I don't know how far apart the speccies can get before the signal becomes too weak.

I've "released" it as "In development" on itch.io if you want to try it out. I'm probably going to tweak it a bit (eventually) and maybe get Issue 2s working (and perhaps other hardware).

USE AT OWN RISK: this requires connecting two ZX Spectrums together by their EAR sockets using an audio cable. I've had no issues (so far on rubber-key spectrums), and it seems electrically safe to do so, but do so at your own risk! I take no responsibility for damage.

Link: https://redzebra.itch.io/battle-chip
C.Born
Manic Miner
Posts: 237
Joined: Sat Dec 09, 2017 4:09 pm

Re: Audio networked multi-player: Battle Chip!

Post by C.Born »

Funny ships you have!
In the old days there was a copy 'trick' by placing a second recorder at the MIC and then record the signal 'again'. probably it did not work properly.
did you use bit 3 or 4 for OUT ?
bit 3 is MIC and bit 4 is loudspeaker/ but you probably tried that.

ps
about error detection, do you know hamming code ?
https://en.wikipedia.org/wiki/Hamming_code
its cpu intensive since it works bitwise, probably not good for this connection
User avatar
Red Zebra
Drutt
Posts: 36
Joined: Fri Jan 20, 2023 7:53 am

Re: Audio networked multi-player: Battle Chip!

Post by Red Zebra »

Thanks!

Yeah, I think the signal needs to be amplified before the other computer would be able to hear it. But, I wanted to get this working with just a cable between stock Spectrums.

I tried different combinations of bit 3 and 4. Just using 4 (EAR) was fine, and in the end I just used the ROM BEEP routine since it was simple and could be ‘heard’. What was important was to set bit 3 (MIC) high on the receiving machine.

If I ever expand on this I would definitely look into some sort of error correction. I would want to speed up transmissions rates over this proof of concept, but I doubt it would ever get fast enough that using a slow check would be a problem.
firelord
Manic Miner
Posts: 557
Joined: Wed Nov 03, 2021 10:57 am
Location: Greece - Thessaloniki

Re: Audio networked multi-player: Battle Chip!

Post by firelord »

Imagine having this capability in the 80s...
It would be interesting to check if signal could be passed via the audio jack of a mobile phone ...

It would be easier to test this using 2 distant PCs connected to a spectrum via the audio/mic jacks :)
Wall_Axe
Manic Miner
Posts: 500
Joined: Mon Nov 13, 2017 11:13 pm

Re: Audio networked multi-player: Battle Chip!

Post by Wall_Axe »

thats pretty cool. If my brother and I had this, we'd have bought two speccies to try it out..(bugged our parents continously for 2 years to buy another spectrum)
Post Reply