Found my file copy of the SIO to Joystick information on my NAS, that I believe Curt Vendel posted several years ago. Here goes:
Wanna have some fun, check out this file I found from some materials out of Atari's on computer engineering department in 1984:
It details making a disk drive simulator through the joystick port from one Atari to another:
TITLE 'DISK SIMULATOR'
SUBTTL 'MAINLINE'
;FILE DISKSIM.ASM
;7/17/84
;This program simulates a disk drive which understands the SIO
;fast mode protocol. Joystick port #2 of the computer running this
;program is connected to the SIO port of another computer equipped
;with Rev 4 (or later) OS, as follows:
;
; SIO CONNECTOR JOYSTICK PLUG
;
; GND 4 --------------------- 8 GND
; DATA IN 3 --------------------- 2 BACK
; COMMAND 7 --------------------- 3 LEFT
; DATA OUT 5 --------------------- 4 RIGHT
DATIN EQU $20
DATOUT EQU $80
COMAND EQU $40
;EQUATES
PORTA EQU $D300
PACTL EQU $D302
NMIEN EQU $D40E
SDMCTL EQU $22F
DMACTL EQU $D400
;PROGRAM ORIGIN
ORG $4000
;TURN OFF SCREEN TO GET ACCURATE TIMING
START
LDA #0
STA NMIEN
STA SDMCTL
STA DMACTL
;DISABLE OUTPUT
DISOUT
LDA #$38
STA PACTL ;DIRECTION
LDA #$00
STA PORTA ;DISABLE OUTPUT TO DATA IN LINE
LDA #$3C
STA PACTL
;RECEIVE COMMAND FRAME
COMFRM
BIT PORTA
BVC COMFRM ;WAIT FOR COMMAND TO GO HIGH
COM1
BIT PORTA
BVS COM1 ;WAIT FOR COMMAND TO GO LOW
LDY #4
JSR RXF192 ;RECEIVE COMMAND FRAME
BCS COMFRM ;IF ERROR
LDY #4
JSR CHKSUM
BNE COMFRM ;IF BAD CHECKSUM
LDA FRAME+4
CMP #$80
BNE COMFRM ;IF NOT THIS DEVICE
;ENABLE OUTPUT
LDA #$20
STA PORTA ;PRECONDITION OUTPUT
LDA #$38
STA PACTL ;DIRECTION
LDA #$20
STA PORTA ;ENABLE OUTPUT TO DATA IN LINE
LDA #$3C
STA PACTL
LDA #$20
STA PORTA
;CHECK COMMAND
COM2
BIT PORTA
BVC COM2 ;WAIT FOR COMMAND TO GO HIGH
LDA FRAME+3
CMP #$52
BEQ GET ;IF GET COMMAND
CMP #$50
BEQ PUT ;IF PUT COMMAND
;UNRECOGNIZED COMMAND, SEND NAK
NAK
LDA #'N'
STA FRAME
LDY #0
JSR TXF192
JMP DISOUT
;PROCESS GET COMMAND (WE SEND)
GET
LDA #'H'
STA FRAME
LDY #0
JSR TXF192 ;HIGH SPEED ACK
BCS GET1 ;IF ERROR
JSR D1000 ;DELAY 1000 US
LDA #'C'
STA FRAME
LDY #0
JSR TXF384 ;SEND COMPLETE
BCS GET1 ;IF ERROR
LDY #128
JSR CHKSUM ;CALCULATE CHECKSUM
LDY #128
JSR TXF384 ;SEND THE FRAME
GET1
JMP DISOUT
;PROCESS PUT COMMAND (WE RECEIVE)
PUT
LDA #'H'
STA FRAME
LDY #0
JSR TXF192 ;SEND HIGH SPEED ACK
BCS PUT1 ;IF ERROR
LDY #128
JSR RXF384 ;RECEIVE THE FRAME
BCS PUT1 ;IF ERROR, DO NOTHING
JSR D1000 ;DELAY 1000 US
LDY #128
JSR CHKSUM
BNE PUT2 ;IF CHECKSUM ERROR
LDA #'A'
STA FRAME
LDY #0
JSR TXF384 ;SEND ACK
BCS PUT1 ;IF ERROR
JSR D1000 ;DELAY 1000 US
LDA #'C'
PUT3
STA FRAME
LDY #0
JSR TXF384 ;SEND COMPLETE
PUT1
JMP DISOUT ;DONE
PUT2
LDA #'N'
JMP PUT3 ;SEND NAK, RETURN
SUBTTL 'TRANSMIT/RECEIVE SUBROUTINES'
ORG $6000
;RECEIVE A COMMAND FRAME AT 19200 BAUD
;ON ENTRY, FRAME SIZE-1 IN Y (<=128)
;RETURNS CS IF ERROR
RXF192
BIT PORTA
BPL RXSB1 ;IF START BIT DETECTED
BVC RXF192 ;IF COMMAND LOW
RXSB2
SEC ;ERROR
RTS
RXSB1
LDA #$80 ;INITIAL BYTE
LDX #9
RXSB4
DEX
BNE RXSB4 ;DELAY 46 CYCLES
RXSB5
LDX #13
RXSB3
DEX
BNE RXSB3
NOP ;DELAY 68 CYCLES
PHA
LDA PORTA
ASL A ;MOVE BIT INTO CARRY
PLA
ROR A ;MOVE BIT INTO BYTE
BCC RXSB5 ;IF NOT DONE WITH 8 BITS
STA FRAME,Y
LDX #12
RXSB6
DEX
BNE RXSB6
NOP
NOP
NOP
NOP ;DELAY 69 CYCLES
LDX PORTA ;GET THE STOP BIT
BPL RXSB2 ;IF IT'S INCORRECT
DEY
BPL RXF192 ;IF NOT DONE WITH FRAME
CLC ;SUCCESS
RTS
;RECEIVE A DATA FRAME AT 38400 BAUD
;ON ENTRY, FRAME SIZE-1 IN Y (<=128)
;RETURNS CS IF ERROR
RXF384
BIT PORTA
BPL RXFB1 ;IF START BIT DETECTED
BVS RXF384 ;IF COMMAND HIGH
RXFB2
SEC ;ERROR
RTS
RXFB1
LDA #$80 ;INITIAL BYTE
LDX #3
RXFB4
DEX
BNE RXFB4
NOP
NOP
NOP
NOP ;DELAY 24 CYCLES
RXFB5
LDX #4
RXFB3
DEX
BNE RXFB3
NOP
NOP ;DELAY 25 CYCLES
PHA
LDA PORTA
ASL A ;MOVE BIT INTO CARRY
PLA
ROR A ;MOVE BIT INTO BYTE
BCC RXFB5 ;IF NOT DONE WITH 8 BITS
STA FRAME,Y
LDX #5
RXFB6
DEX
BNE RXFB6 ;DELAY 26 CYCLES
LDX PORTA ;GET THE STOP BIT
BPL RXFB2 ;IF IT'S INCORRECT
DEY
BPL RXF384 ;IF NOT DONE WITH FRAME
CLC ;SUCCESS
RTS
ASSERT *<$6101
ORG $6100
;TRANSMIT A FRAME AT 19200 BAUD
;ON ENTRY, FRAME SIZE-1 IN Y
;RETURNS CS IF ERROR
TXF192
BIT PORTA
BVC TXSB4 ;IF COMMAND LOW
LDX #0
STX PORTA ;WRITE START BIT
SEC
LDA FRAME,Y
NOP ;DELAY 2 CYCLES
TXSB1
LDX #11
TXSB2
DEX
BNE TXSB2
NOP
NOP
NOP ;DELAY 62 CYCLES
ROR A
PHA
ROR A
ROR A
ROR A
STA PORTA ;WRITE BIT
PLA
CLC
BNE TXSB1 ;IF NOT DONE
LDX #11
TXSB3
DEX
BNE TXSB3
NOP
NOP
NOP ;DELAY 62 CYCLES
DEY
BPL TXF192 ;IF NOT DONE WITH FRAME
CLC
RTS
TXSB4
SEC
RTS
;TRANSMIT A FRAME AT 38400 BAUD
;ON ENTRY, FRAME SIZE-1 IN Y
;RETURNS CS IF ERROR
TXF384
BIT PORTA
BVC TXFB4 ;IF COMMAND LOW
LDX #0
STX PORTA ;WRITE START BIT
SEC
LDA FRAME,Y
NOP ;DELAY 2 CYCLES
TXFB1
LDX #2
TXFB2
DEX
BNE TXFB2
NOP
NOP
NOP
NOP ;DELAY 19 CYCLES
ROR A
PHA
ROR A
ROR A
ROR A
STA PORTA ;WRITE BIT
PLA
CLC
BNE TXFB1 ;IF NOT DONE
LDX #2
TXFB3
DEX
BNE TXFB3
NOP
NOP
NOP
NOP ;DELAY 19 CYCLES
DEY
BPL TXF384 ;IF NOT DONE WITH FRAME
CLC
RTS
TXFB4
SEC
RTS
ASSERT *<$6201 ;BYTE I/O ROUTINES MUST BE WITHIN PAGE
ORG $6200
FRAME DS 256
SUBTTL 'SUBROUTINES'
;CALCULATE CHECKSUM
;ON ENTRY, FRAME SIZE-1 IN Y
;ON EXIT, CHECKSUM IN FRAME, ZS IF CHECKSUM WAS CORRECT
CHKSUM
LDA #0
CHKS1
CLC
ADC FRAME,Y
ADC #0
DEY
BNE CHKS1
LDX FRAME
STA FRAME
CPX FRAME
RTS
;DELAY 1000 US
D1000
LDX #236
D1001
NOP
DEX
BNE D1001
RTS
END START
__________
[ SOURCE: https://atariage.com/forums/topic/2...n-porta-bit-0/?do=findComment&comment=3499979 ]
-
Not old. Vintage. :)
Bit-Bang Serial (RS232) via PORTA on Atari 8-Bit
Credit: David_P
Tags:
Rate This Article: