Parallel Port I/F with CBM-64

The following code fragment is 6502 assembler which can be used on the Commodore-64 to drive the 8-bit User Port for parallel communications purposes. This port can connect to another computer with a similar parallel port eg. the Dragon's printer port (or add-on PIA) or PC printer port to allow transfers between the two machines. This is the only method I am aware of to easily transfer CBM-64 files since it used non-standard disks. The 6809 equivalent of this transfer code for the Dragon is listed in the section on Parallel communications where the principals of this type of comms are also covered.

I found the basis of this routine written jotted down by hand in one of my old folders, as I remember it does work okay though I can't guarantee it as it's been a good few years since trying it with my Dragon. Hopefully it may be of some use to anyone trying to port stuff between the Commodore and another machine.

User In Routine

Transfer a block of data from the parallel port into the CBM-64's memory. Prior to calling the routine via a SYS call, POKE in the following information:

$00FB:C - Start address
$00FD:E - Length

All values stored LSB/MSB order:

	SEI		- disable ints
	LDY #&00	- offset counter
	LDX &FD		- LSB of length
	LDA &DD01	- clear any data pending by read of data reg.
.LOOP	LDA &DD0D	- read PIO status reg.
	ANDA #16	- wait for FLAG bit to be set
	BNE LOOP
	LDA &DD01	- fetch byte from port
	STA (&FB),Y	- store at reqd address
	INY		- increment LSB offset
	BNE DECRX	- check for byte wrap round
	INC &FC		- inc MSB count
.DECRX	DEX		- dec LSB length
	BNE LOOP
	DEC &FE		- dec MSB length
.CHECK	BPL LOOP
	CLI		- restore ints
	RTS

A User-Out routine can be similarly constructed I believe, by reversing the LDA/STA combination, except the port will need to be configured for output first.

User Port Pinout

The pinout should be in the back of the Commodore 64 User's manual (if I remember correctly), however if viewed from the back of the machine with pins 1-12 from left to right along the top and pins 13-24 right to left along the bottom the following connections should be made to make a parallel link between CBM-64 and Dragon:

	Pin #1,12,13 or 24	0V 	to Dragon 0V
	Pin #8			PC2~	to Dragon (PIA21) CA(B)1 or (Printer)ACK
	Pin #23			FLAG~	to Dragon (PIA21) CA(B)2 or (Printer)STROBE
	Pins #22-15		PB0-PB7	to Dragon (PIA21) PA(B)0-7 or (Printer)D0-D7