| |
Commodore 64 Slack Client [2016] |
Website :
http://1amstudios.com/2016/11/27/c64-slack-client/
Credits :
Download :
Look for downloads on external sites:
Pokefinder.org
Summary Submitted by hedning on 30 November 2016
Quoted from the blog:
"Slack is great. Many smarter people than me also think that Slack is great. Slack is great because its simple and easier to deal with than emails. With all the time it saves me on emails, I relax go the beach write more code send messages via Slack instead.
But while Slack might be great, it does not have a great native client for the Commodore 64. In fact, they have no client for Commodore 64 at all!
This is clearly a problem.
Reasoning that a pull request is better than a complaint, Im happy to present the first (and most likely only) Slack client for Commodore 64!
The C64 has an extension port called the Userport which, via an adapter, can communicate over RS-232 serial. I connected the Userport to a Raspberry Pi with a artisanal, locally sourced, homemade cable with the UserPort connector on one end, and a usb TTL-RS-232 converter on the other. The fastest I have been able to run this reliably is a solid 1200 baud / 150 bytes per second.
On the Commodore, I wrote an application in 6502 assembly. It uses built-in Kernal ROM functions to read and write the serial port and update the screen.
On the Pi, I wrote a NodeJS app which talks to the Slack RTM API. It is reponsible for translating a simple RPC protocol between the C64 and itself and connecting to the outside world (in this case, Slack). It uses serialport to talk to the USB serial driver.
RPC API
A simple RPC message format is defined between the C64 and Pi. The description below is all C-style, but of course on the C64 this is all implemented in 6502 assembly.
struct rpc_message_t {
char command_id;
void *payload;
char message_end_marker (0x7e);
}
struct channel_t {
char len;
char[9] channel_id;
char[len-9] channel_name;
}
When the Pi gets a connection to Slacks RTM api, it kicks off communication with the C64. The protocol follows like this:
[Pi >> ] HELLO {user: jeff}
[Commodore >> ] REQUEST_CHANNEL_LIST
[Pi >> ] CHANNELS_HEADER { channel_count, list_size_in_bytes }
[Pi >> ] CHANNELS_LIST { channel_data }
// user selects a channel on the C64
[Commodore >> ] CHANNEL_SELECT { channel_id }
// message arrives via Slack RTM api in the selected channel
[Pi >> ] MESSAGE_HEADER_LINE { ascii_data }
[Pi >> ] MESSAGE_LINE { ascii_data }
[Pi >> ] MESSAGE_LINE { ascii_data }
...
// user sends message from C64
[Commodore >> ] SEND_MESSAGE { message }
When the channel data has finished streaming, we switch to the Channels screen. This shows a scrollable list of all channels and groups, ordered by unread_count, name. Hitting [RETURN] on a channel name sends channel_id to the Pi and switches to the Messages screen.
When a channel is joined, the Pi app sends the last couple of messages in the channel to the C64. Subsequently, whenever a message for that channel is recieved via the Slack websocket connection, it gets converted into a multiple lines of C64-compatible characters and sent across the serial connection.
Slash commands work too! We use the undocumented chat.command API found with help from Chrome dev tools :)
Heres an example of the kind of code running on the C64. This is the top level processing loop:
.main_loop
jsr keyboard_read
jsr rs232_try_read_byte
cmp #0
bne .got_byte ; if we got a byte from serial conn, goto .got_byte...
jmp .main_loop ; ... otherwise, jump back to .main_loop
.got_byte
ldy flash_screen_on_data
beq .skip_screen_flash ; if screen flashing is not enabled, jump over flashing code
inc $d020 ; border_color++
.skip_screen_flash
cmp #COMMAND_TRAILER_CHAR ; is the byte read from serial conn the end-of-cmd marker?
bne .add_byte_to_buffer ; if not, just add it to the buffer
ldy #1
sty .end_of_command ; otherise, set end_of_command = 1
lda #0 ; replace end-of-cmd with '\0'
.add_byte_to_buffer
ldy #0
sta (COMMAND_BUFFER_PTR), y ; use indirect-indexed addressing mode to store the byte in our buffer
+inc16 COMMAND_BUFFER_PTR
ldy .end_of_command
cpy #1
bne .main_loop ; if end_of_command != 1, continue to loop
jsr command_handler ; ... otherwise, jump to a function to handle the complete command string
jmp .main_loop ; and then, continue to loop
Want to do this yourself? Of course you do. Why else are you still reading?
Hardware needed:
1 x Commodore64
1 x Raspberry Pi (really anything with usb which can run NodeJS)
1 x homemade C64 Userport <-> USB serial cable. instructions
Software:
* https://github.com/jeff-1amstudios/c64-slack-client
git clone https://github.com/jeff-1amstudios/c64-slack-client && vim c64-slack-client/README.md
Legal bit
It goes without saying (surely?!) that the company named Slack is not affiliated in any way with this project. Im not sure if they would be happy or horrified to see this creation." |
|
|
|
| Search CSDb |
| Navigate | |
|
| Detailed Info | |
· Summaries (1)
· User Comments
· Production Notes
|
|
| Fun Stuff | |
· Goofs · Hidden Parts · Trivia
|
|
| Forum | |
|
| Support CSDb | |
|
| |
|