text stringlengths 0 99.6k |
|---|
5 (SER DAT) 5 (DATA3) |
6 (RST) 6 (DATA4) |
The software uses the PC parallel port to emulate a C64 serial port. The |
example program, C64.C (Listing 1), is written in Borland's Turbo C. It reads |
input and sends each character to the printer. It can be used as a filter in |
an MS-DOS command line pipe. For example, DOS commands such as: dir | c64 |
would print a directory listing, or type a_file | c64 would print the contents |
of a file. |
I have also written an MS-DOS device driver which can be used to allow any PC |
application to print to a C64 compatible printer, and it supports multiple |
printers connected to a single PC parallel port. The listing for this software |
is too lengthy to print, however I will make this software and assembled cables |
available to Commodore 64 enthusiasts for a nominal charge; just write me for |
details. With these C64 compatible printers often selling for less than $25 at |
garage sales and flea markets, it's easy to add a couple of additional |
"scratch" printers to any PC system. |
John Keyerleber |
26300 Chardonview Drive |
Cleveland, OH 44143 |
(216) 261-9676 |
E-mail: jkeyerleber@bailey.com |
Listing 1: |
#include <stdio.h> |
#include <ctype.h> |
#include <dos.h> |
#define PORTADR 0x378 // LPT1=0x378, LPT2 = 0x278 |
#define PRINTADR 0x04 // C64 compatible printer address |
#define SRQ 0x01 // C64 SRQ IN signal |
#define ATN 0x02 // C64 ATN signal |
#define CLK 0x04 // C64 CLK signal |
#define DAT 0x08 // C64 DAT signal |
#define RST 0x10 // C64 RST signal |
// function prototypes |
void initc64(void); |
void putc64(unsigned char); |
void puts64(char *); |
void putbyte(unsigned char, unsigned char); |
// function main() loops to read input characters and send them to the printer |
void main(void) |
{ |
char buff[128], *ptr; |
initc64(); |
while(fgets(buff, 80, stdin)) |
{ |
for(ptr = buff; *ptr; putc64(*ptr++)); |
} |
} |
// function init64() initializes the driver and the C64 compatible printer |
void initc64(void) |
{ |
// set initial port output value to all bits high |
outportb(PORTADR, RST | SRQ | ATN | CLK | DAT); |
// initialize printer: RST=0, then RST=1 |
outportb(PORTADR, SRQ | ATN | CLK | DAT); |
delay(250); |
outportb(PORTADR, RST | SRQ | ATN | CLK | DAT); |
delay(2250); |
// Set printer to listener: ATN and CLK low, printer will ACK with DAT low |
outportb(PORTADR, RST | SRQ | DAT); |
while((inportb(PORTADR) & DAT)); |
// Send printer address (currently set for address 4) |
putbyte(0x20 | PRINTADR, 0); |
// Send printer mode |
putbyte(0x67, 0); |
} |
// function putc64() sends a byte of data (byteval) to the C64 compatible printer |
void putc64(unsigned char byteval) |
{ |
// Check for upper/lower case conversion |
if (isalpha(byteval)) |
{ |
byteval = (isupper(byteval)) ? tolower(byteval) : toupper(byteval); |
} |
// Send character |
putbyte(byteval, ATN); |
} |
// function putbyte clocks the actual byte to the C64 compatible printer bit by bit |
void putbyte(unsigned char byteval, unsigned char mode) |
{ |
register int bitloop; |
// Set CLK high, printer will ACK with DAT high |
outportb(PORTADR, RST | SRQ | CLK | DAT | mode); |
while(!(inportb(PORTADR) & DAT)); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.