header_2.gif (908 Byte) logo_v1.gif (3356 Byte) header_1.gif (905 Byte)
Pages
TI92
TI89
HowTo
Linking
MXM Programs

Powered by

[ticalc.org]
[levante.de]
[xoom.com]
[listbot.com]
[fastcounter.com]

Page design by DMnow!

In this section we offer some articles, how to program some specific parts of a game or the TI92!
We will add articles, so revisit this section!

How to link with the PC

First of all, here we describe, how to link with the parallel link cable.

The TI92 uses a non standard link interface. To communicate with the TI92, you have to send a "I'll send a bit" code and then wait for the reply. The codes are not standard! It's just the same way from the TI92 to the PC! The easier code is the TI92 code, because you can use the TIOS functions tios::transmit / tios::receive function, and your TI will send byte per byte through the link port. So, first of all we show you the TI92 code
Notice: Before you send something, you have to check, if the link buffer has got enough space (function tios::tx_free).

; Function SendByte
; In	    d0		Byte to send

puffer     dc.l     0
SendByte:
   movem.l d0-d7/a0-a6,-(a7)
   move.b  d0,puffer
   move.w  #1,-(a7)
   pea     puffer(PC)
   jsr     tios::transmit
   lea     6(a7),a7
   movem.l (a7)+,d0-d7/a0-a6
   rts
    
; ReceiveByte
; receives a byte from the I/O puffer
; Out       d1          received byte
;           d0          byte received (d0 = 0, no, d0 != 0, yes)?
ReceiveByte:
   movem.l d2-d7/a1-a6,-(a7)
   move.w  #1,-(a7)
   pea     puffer(PC)
   jsr     tios::receive
   lea     4(a7),a6
   move.b  puffer,d1
   movem.l (a7)+,d2-d7/a1-a6
   rts

Now the more difficult part of the link routines are the PC link routines. Currently, I release the DOS/Windows code, although the Linux version just has to output the bytes through the /dev/lpx device! The code is written in C/C++, a Pascal version is availabel in our archive!

#include <pc.h>
#define   LPT_PORT     0x378    /* Define your LPT port, ... */

#define   LPT_IN_PORT  LPT_PORT + 1
#define   LPT_OUT_PORT LPT_PORT

/* Wait for the TI92 Acknowledge */
int Wait (int Code, int Until)
{
   int timeout = 1 << 15;
   while ((inportb (LPT_IN_PORT) & Code) != Until && timeout > 0);
   if (timeout == 0)
      return 0;
   else
      return 1;
} /* Wait */

/* Returns if the byte was sent */
int SendByte (int Byte)
{
  int n;
  for (n = 0; n < 8; n++)
  {
     outportb (LPT_OUT_PORT, 0x3)  
     if ((x & (1 << n)) == 0)
     {
        /* Bit set */
        outportb (LPT_OUT_PORT, 0x1);
        /* Acknowledge from the TI92 */
        if (!Wait (0x20, 0)) return 0;
          
        outportb (0x3);
     } else {
        /* Bit not set */
        outportb (LPT_OUT_PORT, 0x2);
        /* Acknowledge from the TI92 */
        if (!Wait (0x10, 0)) return 0;
        outportb (LPT_OUT_PORT, 0x3);
     } /* if */
  } /* for */
  return 1;
} /* SendByte */

/* ReceiveByte:  Gets a byte from the TI92, returns 0 when timeout! */
int ReceiveByte (int *SaveIn)
{
   int n, x = 0, timeout;
   
   for (n = 0; n < 8; n++)
   {
      x *= 2;
      i = 0x30;
      timeout = 1 << 15;
      while (i == 0x30 && timeout > 0) i = inportb (LPT_IN_PORT) & 0x30;
      if (timeout == 0) return 0;
      if (i == 0x10)
      {
         /* Bit = 1 */
         x++;
         outportb (LPT_OUT_PORT, 0x1);
         if (!Wait (0x20, 0x20)) return 0;
      } else {
         /* Bit = 0 */
         outportb (LPT_OUT_PORT, 0x2);
         if (!Wait (0x10, 0x10)) return 0;
      } /* if */
   } /* for */
   *SaveIn = x;
   return 1;
} /* ReceiveByte */

That's all
header_3.gif (882 Byte)
[Back to the top] [Back to the index] [Other HOWTO's]
header_4.gif (881 Byte)