What happens if you connect two computers to a 1541?

Modding and Technical Issues

Moderator: Moderators

Post Reply
IsaacKuo
Vic 20 Hobbyist
Posts: 147
Joined: Tue Aug 04, 2009 5:45 am

What happens if you connect two computers to a 1541?

Post by IsaacKuo »

I'm half tempted to just try it to see what happens, but I'd rather not risk damaging my equipment.

My guess is that either computer may access the 1541, just not at the same time. Is that right?

Since the 1541 is programmable, I'm hoping this may allow for networking via alternating access to a small message buffer (rather than constant reading/writing a "shared" physical file). Since the hardware to connect a PC to a 1541 is cheap and common, this may be a good way to implement multiplayer online games.

Even without customized network functionality, it would be convenient to connect both a PC and a VIC to a single 1541 rather than frequently swapping cables/floppies around. So...does this work?

Thanks!
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Post by Jeff-20 »

I was curious too, but not very brave. I still don't know.
High Scores, Links, and Jeff's Basic Games page.
matsondawson
The Most Noble Order of Denial
Posts: 343
Joined: Fri May 01, 2009 4:44 pm

Post by matsondawson »

The bus works by the computer supplying power and the the peripherals pulling that power low to signal the computer. If you plugged two computers in, i think, that when one computer released its line to signal the bus, the other computer would still hold the line high thus preventing it from working.
Unseen
Vic 20 Amateur
Posts: 47
Joined: Sun Feb 01, 2009 9:16 am

Re: What happens if you connect two computers to a 1541?

Post by Unseen »

IsaacKuo wrote:My guess is that either computer may access the 1541, just not at the same time. Is that right?
Yes. The kernal has a bug though in its reset code that will block the bus until you access it once or manually reset the bus register to release the offending lines. On a VIC20 you can do that with "POKE 37137, PEEK(37137) OR 3", on a C64 with "POKE 56576, PEEK(56576) AND 239". (pokes copied from the Star Commander manual)
Since the 1541 is programmable, I'm hoping this may allow for networking via alternating access to a small message buffer (rather than constant reading/writing a "shared" physical file).
You'd have to make sure that the computers won't try to access the drive at the same time, there is nothing in the protocol that checks for a bus collision.
matsondawson wrote:The bus works by the computer supplying power and the the peripherals pulling that power low to signal the computer.
No, it works by weakly pulling the lines up in every device connected to the bus (default state, 1) and strongly pulling the lines to ground when required (signalling a 0).
matsondawson
The Most Noble Order of Denial
Posts: 343
Joined: Fri May 01, 2009 4:44 pm

Post by matsondawson »

No, it works by weakly pulling the lines up in every device connected to the bus (default state, 1) and strongly pulling the lines to ground when required (signalling a 0).
Think you need to reread what I said, maybe.
I said peripheral pulls line low to signal computer, i didn't say computer didn't set line low to signal peripheral.
IsaacKuo
Vic 20 Hobbyist
Posts: 147
Joined: Tue Aug 04, 2009 5:45 am

Post by IsaacKuo »

It works! Thanks, Unseen, your post gave me the courage to try it and the info needed to make it work.

As you noted, it wouldn't work until both computers first attempted to access the drive. I didn't feel like remembering the POKEs, so I just did LOAD"$",8 on each computer a couple times until it all started working.

Wow! I wish I had known about this a couple decades ago. It's like my 1541 is a file server with my VIC20 and C128 as clients.

I tried simultaneous file access and unsurprisingly both accesses failed. It didn't crash anything, which is the important thing.

I've been having woes with trying to load/save PRG files in an emulator, but if I use a 1541 as a "file server" between my PC and my VIC20 then I can avoid using an emulator altogether.

As for the idea of implementing an online game network protocol through it...I'm not sure how you'd go about synchronizing access attempts so they don't collide. Maybe you could purposefully use the kernal bug so the 1541 stays busy until a chosen moment. Here's the sequence of events:

1) The PC daemon is started; it accesses the 1541 every 2 seconds.

2) The VIC game client starts and blocks the bus for over 2 seconds (maybe 5 seconds).

3) The PC detects that DEVICE IS NOT READY and begins rapidly polling to detect when the VIC stops blocking the bus.

4) The VIC game client unblocks the bus with POKE37137,PEEK(37137)OR3 at the end of the five seconds. This is the synchronization "mark".

5) The PC succeeds in access, and from then on it regularly accesses the 1541 once every two seconds

6) The VIC game client waits one second before it starts regularly accessing the 1541, once every two seconds.

Thus, the PC and VIC take turns accessing the 1541 each second. This produces a game latency on the order of 6 seconds or so. This isn't good enough for an action game, of course, but it may be good enough for a graphical MUD or a turn based game.
Mermaid
Vic 20 Newbie
Posts: 18
Joined: Sat Jun 19, 2004 2:20 pm

Post by Mermaid »

Hehe, I was both curious and brave (or stupid?); when I was writing Vic 20 programs on my C128D I used to have my Vic connected to the internal 1571 so I could load the programs and test them right after saving to disk. I did the same when doing C16 stuff on the C128D. No disk juggling needed, and it saved some precious space on my already cramped desk!
Post Reply