Device #2 for Serial I/O?
Device #2 for Serial I/O?
I was idly thinking about writing a game that could interact with other players via a server.
So, serial I/O via a card attached to the User Port or *wherever*. Maybe a modem, or ethernet, or heliograph, or carrier pigeon. Just thinking about it, and how it might be nice to abstract that protocol into the existing KERNAL I/O. A driver to patch the lines, and custom handler code (probably a lot of code on the card itself). That sort of thing...
...but to make programming easier, it seems right to allocate a device number for that I/O channel.
On the C64, the RS-232 interface was Device #2.
Seems the right place to start here, as well.
- JimmyDansbo
- Posts: 476
- Joined: Sun Apr 26, 2020 8:10 pm
- Location: Denmark
- Contact:
Device #2 for Serial I/O?
I see no reason why we could not use #2. If we have to use something different, I was thinking that we might as well choose something that is recognizable from other platforms such as the PC, like $3F8. Only after I submitted my answer, I realized that we probably only have a single byte for the ID. ?
Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
Device #2 for Serial I/O?
I expect that the bit banged User Port serial interface will be on #2, so that is the natural one for the "main" serial port on a User Port or expansion board hardware serial port.
Device #2 for Serial I/O?
of course, it will be #2.
Back in the Commodore days, it was #2, and even if users added a Swiftlink (which used a 6551 ACIA), the new 6551 serial port was still accessed via port 2. The Swiftlink cartridge provided a ROM update that replaced the User port serial code with code on the cartridge.
So add-on serial ports could either patch the KERNAL or provide their own routine in Golden RAM or in a bank at $A000
For example:
$400 : Port number (for multi-port cards)
$401 : bytes waiting in read buffer on UART
$402 : bytes waiting in write buffer on UART
$403 : flow control state
$404 : data to send
$405 : 1 if byte was read in last call, 0 if no data received
$406 : last byte read
And the read/write routines at $410, $440, and so on:
$410 : Update status registers
$413 : Send a byte
$415 : Read a byte
So BASIC code would look like:
Send a byte: POKE $404 : SYS $413
Read a byte: SYS $415 : IF PEEK(405) > 0 THEN A$=CHR$(406)
Check the modem status: SYS 410 : S = PEEK($403)