              GameBoy Terminal V1.7

 This program allows you to use an IBM-PC as a
terminal interface with GB Basic V1.20 or later
for GameBoy. To use this program you need to
build the GameBoy - to - Parallel Port cable.

 Besides being able to edit and run programs on
the GameBoy this program also allows you to
upload and download files over the cable. Any
ascii file can be downloaded to the gameboy.
Each line of text in the file acts as if you
had typed that line in by hand and pressed enter.

 Because of this flexibility, you can control
the GameBoy real-time. For example, if you
do a 'gbt -d abc.bas' and the only command in
abc.bas is POKE x,y then you just wrote to a
GameBoy memory location with your PC over the
GB-to-PC cable.

 Because of interrupt conflicts, this program
currently won't work when servos are enabled
on the GameBoy. 

 Run the program with no options to get the
help menu.

Theory of operation
-------------------

 The way the GameBoy serial port works is that
one end of the serial connection has to supply
a clock for the serial transfer. Since the IBM-PC
has unpredictable interrupts, I chose to use it
as the clock generator in order to better keep
things in sync.

 When 8 clocks are generated a byte is shifted
in and out of the GameBoy serial port. Since
the PC has control of the clock, it generates
it continuously so that the GameBoy can send
out a byte whenever it wants to.

 There are no start & stop bits so determining
which bit is which is a little tricky. A
connection between the two ends start with each
end sending out an 80 hex. I use an 80 hex
value sent continuously both ways as an indicator
that the serial bus is idle. If the PC end doesn't
get an 80 hex, then it throws in an extra clock
cycle before receiving the next byte. This
effectively rotates the incoming data one bit
per incoming byte. This is continued until an
80 hex value is received.

 Once both ends are in sync, a '@' character is
sent to the GameBoy as a command to clear it's
input buffer. Communication is then allowed to
begin. A byte greater than 80 hex received from
the GameBoy is currently an impossible situation
and is used as an indicator that sync is lost.


jfrohwei@hiwaay.net

