[comp.sys.cbm] Break signals on a Commodore 64

marka@m2-net.UUCP (Mark Anderson) (07/24/88)

I have the Commodore vt52 terminal program that came boxed with my 1670
modem, which I use on my Commodore 64. This program produces every special
signal I need for my use of UNIX and other systems, except for one, the
break signal

Is it possible to send a break signal from a Commodore 64, and if so does
someone have a routine to do this? Help will be appreciated.

Mark Anderson
(marka@m-net.UUCP)

eravin@dasys1.UUCP (Ed Ravin) (07/27/88)

In article <2026@m2-net.UUCP> marka@m2-net.UUCP (Mark Anderson) asks:
>
>Is it possible to send a break signal from a Commodore 64, and if so does
>someone have a routine to do this?
>
>Mark Anderson
>(marka@m-net.UUCP)

Yes, it is possible.  This was one of the first things I had to do when I
got my Commie, because I bought it primarily for telecommunications and
needed to send the break to interrupt the various hosts I was calling.
It was my first encounter with what was to become a familiar theme: what
the Commie was missing in hardware, you could compensate by writing things
in software.  And spending lots of time...

It's been a while since I last had my hands on the guts of a C64, so I don't
remember all the memory addresses and numbers off the top of my head, but
if you have the Commodore Programmer's reference guide and/or Compute!'s
Mapping the 64 (two books no C64 programmer should be without), this ought
to be enough:

The Commodore 64 has no serial hardware.  RS-232 signals are generated by
changing the state of one of the I/O pins each time a bit must be sent.

A break signal is defined as a space for approximately 100 milliseconds.
This signal is too long to be a normal bit, so the serial hardware
for the host recognizes it as a break.  Since we have control over every
bit the Commie sends, we'll play with the parameters of the software RS-232
routines so that the Commie will send a break signal.

First of all, peek each of the following memory locations and save their
contents:
	software baud rate (?665 and 666?)
	RS-232 word size (usually 8)

	Now, calculate a software baud rate that will cause one bit to last
100 milliseconds.  Formulas for the software baud rate are in either of the
references described above.  Next, poke 1 (one) into the RS-232 word size
location.  Then send a null character (chr$(0)) out the serial port through
the normal PRINT# or CHROUT routines.

	Since you've told the Commie to send a zero character with a word
size of only one bit word at a ridiculously low baud rate, the effect is
that of a break signal.  Now you have to wait until the bit has gone out.
Check the value of the "RS-232 state register", which has bits for whether
the system is receiving or still transmitting.  When that bit for
"system is transmitting" is clear, then the break has been sent.  Restore
the RS-232 word size location and the software baud rate locations, and
you're back to normal.

	If that's not enough, email me and maybe I'll dig up the godawful
numbers and the code fragment that does this.  Specify whether you want
assembly or BASIC.  Remember, you must either include this into your own
terminal software, or be hep enough to patch it into someone else's.  Most
packages out of the box just ignore the break signal, because most micro
systems such as BBS's never use it.

-- 
Ed Ravin                  | cucard!dasys1!eravin | "A mind is a terrible thing
(BigElectricCatPublicUNIX)| eravin@dasys1.UUCP   | to waste-- boycott TV!"
--------------------------+----------------------+-----------------------------
Reader bears responsibility for all opinions expressed in this article.