[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Redirecting input and ouput
- Subject: Re: Redirecting input and ouput
- From: dalloff@gcfn.org (Dave Althoff Jr)
- Date: 14 Nov 2003 23:58:29 -0500
- Newsgroups: comp.sys.apple2
- Organization: GCFN (http://www.gcfn.org/)
- References: <jdgtb.17520$IK2.1397439@news20.bellglobal.com>
- Xref: archiver1.google.com comp.sys.apple2:872
Robert Finch (robfinch@sympatico.ca) wrote:
: Hi,
: How do I redirect input and output through a home-built serial port ?
If you followed The Rules, then you should have a routine which handles
I/O through your port. To direct I/O to that routine, you have to reset
the CSW and KSW hooks.
I'm not sure the protocol for doing this in ProDOS, but I think it's the
same as under DOS 3.3:
CSW: Standard output is directed indirectly to the routine pointed to by
(CSW), zero-page locations $36-37.
KSW: Standard input is directed through the routine pointed to by (KSW),
zero page locations $38-39
When you change these locations, there are other things that also need to
be changed, and I can't for the life of me remember what all they are;
something about making sure that COUT and KEYIN get properly patched to
actually use your routine instead of automatically "fixing" CSW and KSW.
Fortunately, you don't have to remember all the steps; there's a ROM
routine that does it for you at $FB6F. Then you should reconnect DOS with
a call to the warmstart entry. Technically at $03D0 (even in
ProDOS/BASIC.SYSTEM!) but once 8-bit memory was frozen at 48k, we all
learned that:
03D0- 4C BF 9D JMP $9DBF
...so typical lazy 1980's Apple ][ programmers leave out the middle-man with a
bad-form JMP directly to $9DBF.
I've written I/O routines over the years, for pre-processing I/O before
passing it along to DOS. My favorite was a baton-twirling cursor that
also ran pre-programmed keyboard macros. I wonder if I still have that
disk. Anyway, the basic initialization is something like this--
INIT LDA #<MYCOUT ;Low order byte
STA $36 ;CSWL
LDA #>MYCOUT ;High byte
STA $37 ;CSWH
LDA #<MYKEYIN ;low byte
STA $38 ;KSWL
LDA #>MYKEYIN ;high byte
STA $39 ;KSWH
JSR $FB6F ;Magic vector fixer 8-)
JMP $9DBF ;48k DOS 3.3 entry point. Technically
;should be JMP $03D0, although on every
;"modern" DOS machine, $03D0 contains
;"4C BF 9D". 8-)
MYKEYIN NOP
* Fill this section with a routine that gets a byte from somewhere
* loads it into the accumulator, and RTS's.
MYCOUT NOP
* Fill this section with a routine that dumps the byte in the accumulator
* wherever you want it, and RTS's.
--Dave Althoff, ][.
--
/-\ _ *** Respect rides. They do not respect you. ***
/XXX\ /X\ /X\_ _ /X\__ _ _ _____
/XXXXX\ /XXX\ _/XXXX\_ /X\ /XXXXX\ /X\ /X\ /XXXXX
_/XXXXXXX\__/XXXXX\/XXXXXXXX\_/XXX\_/XXXXXXX\__/XXX\_/XXX\_/\_/XXXXXX