TI-92 Remote mode controller in C?
[Prev][Next][Index][Thread]
TI-92 Remote mode controller in C?
-
Subject: TI-92 Remote mode controller in C?
-
From: Tim Gerla <timg@climax.polaristel.net>
-
Date: Sat, 28 Sep 1996 15:51:46 GMT
-
In-Reply-To: <>
Can anyone help me with this? I wrote a little program using the
source in LINK92.ZIP from Ben and George Software. It's supposed
to be used when the 92 is in remote mode, but it does not work!!
On the PC end of it it looks fine, there is a small delay before
anything gets echoed to the computer, but the 92 just freezes up.
I'm compiling it in DJGPP 2.0. Here is the program:
#include <conio.h>
#include <stdlib.h>
#include <io.h>
#include <stdio.h>
#define lpt_out 0x378
#define lpt_in (lpt_out+1)
#define word unsigned int
#define byte unsigned char
#define getword92() (get92() | (get92() << 8))
#define putword92(x) put92((x) & 0xff); put92(((x) & 0xff00) >> 8)
#define NAMELENGTH(p) ((p)->data[5])
#define DATALENGTH(p) (((p)->data[1] << 8) | ((p)->data[0] & 0xff))
#define TIMER *(unsigned int far *)0x46CL
#define TESTABORT if (kbhit()) { if (getch()==27) {abortcode=1; return
0; } }
// Turn on send light
void tx(int i)
{
outportb(0xb800, 25*160-3); //??
}
// Turn on receive light
void rx(int i)
{
outportb(0xb800, 25*160-1);
}
/*
* Sends a byte to the calculator
*/
int put92(char data)
{
int bit,a;
for (bit=0; bit<8; bit++) {
//if (bit==1) tx(1);
if (data&1) {
outportb(lpt_out, 2);
while (inportb(lpt_in)&0x10);
outportb(lpt_out, 3);
while ((inportb(lpt_in)&0x10)==0x00);
} else {
outportb(lpt_out, 1);
while (inportb(lpt_in)&0x20);
outportb(lpt_out, 3);
while ((inportb(lpt_in)&0x20)==0x00);
}
data>>=1;
for(a=1;a<100;a++);// may need 10us delay here
}
}
/*
* Reads a byte from the calculator
*/
unsigned char get92(void)
{
int bit,a;
unsigned char data=0, v;
for (bit=0; bit<8; bit++) {
while ((v=inportb(lpt_in)&0x30) == 0x30);
if (v==0x10) {
data=(data>>1)|0x80;
outportb(lpt_out, 1);
while ((inportb(lpt_in)&0x20)==0x00);
outportb(lpt_out, 3);
} else {
data=data>>1;
outportb(lpt_out, 2);
while ((inportb(lpt_in)&0x10)==0x00);
outportb(lpt_out, 3);
}
for(a=1;a<100;a++); //delay
}
return data;
}
main()
{
int k;
while(k!=27) //do until user pressed 'ESC'
{
k=getch();
put92(k); //send to 92
putch(k); //echo sent byte
}
put92(00); // maybe reset the port?
}
Thanks for any help!
-Tim
__
/_/\
Tim Gerla - timg@climax.polaristel.net / /\ \
/ /\ \ \
Tyball Dragon -==(UDIC)==- / / /\ \ \
/ / / \ \ \
www.geocities.com/SiliconValley/Park/1691/ /_/____\ \ \
TI-92, HTML, Links, POV-Ray, Fractint! /_/________\_\/\
\_\___________\/