Displaying TI Graphics Files

Publication

Pub Details

Date

Pages

See all articles from QL Hacker's Journal 19
[Jeff Kuhlmann has written an interesting program to display a TI-Artist instance file on the QL. I don’t know how many have been wanting to do this, but here it is. On the disk that Jeff sent me, were many example files. If you are interested in this, I can provide a disk with all of the sample files. – ED ]
/* SHOWTIA_C - a c68 file for the QL to display */
/* TI-ARTIST instances. This is NOT the proper way */
/* to program in that I write directly to the screen */
/* This is because: a) it's a LOT faster and */
/* b) I couldn't figure out how to */
/* scale the window properly */
/* December 10, 1993 Ver 1.0 Jeffrey A. Kuhlmann */

#include "qlib.h" /* because I use QDOS calls */
#include "stdio.h" /* because I open files */
#include "string.h" /* because I use string functions */
#include "stdlib.h" /* because I use atoi() function */

char infn[81]; /* input file name */
char str1[81]; /* input string from file */
FILE *inf,*outf; /* files to open */
int arry[20]; /* utility array */
char rows[81]; /* row string */
char cols[81]; /* columns string */
int ctr,end,delim,col,row;
int rctr,cctr,cptr;
int chardat[8],chrptr;
long qres;
char *scrn; /* pointer to absolute screen memory */
char *_endmsg=NULL; /* omit end message */

main(argc,argv)
int argc;
char *argv[];
{
if(argc<2)
{
puts("TI-ARTIST VIEWER FOR QDOS");
puts("Press any key when done");
puts("viewing picture...");
puts("TI-Artist file name? (w/o _I)");
gets(infn); /* get filename from user */
}
else strcpy(infn,argv[1]);
strcat(infn,"_I"); /* add necessary _i to name */
inf=fopen(infn,"r"); /* try to open file */
/* this function forces 4 color, monitor mode */
mt_dmode("4","0");
/* open whole screen for access */
outf=fopen("con_512x256a0x0_32","w");
qres=fgetchid(outf);
if (!inf)
{printf("Can't open %s",infn);
exit(7);} /* error opening file */
sd_clear(qres,-1); /* clear screen */
/* for(ctr=0;ctr<16;ctr++)puts(""); */
/* needed only when end message */
/* enabled */
fgets(str1,81,inf);/* read # of rows, cols needed */
rowcol();
for(rctr=0;rctr<row;rctr++)
for(cctr=0;cctr<col;cctr++)
{if(feof(inf)){puts("EOF encountered - task
aborted\n"); exit(7);}
fgets(str1,81,inf);
defchr(); /* display dots */
}

/* while(!poll(0)); */ /* wait for a key */
/* sd_pos(qres,-1,1,10); */
fclose(inf);
fclose(outf);

exit(0);
}

/* rowcol() takes the first line of the TIA file & */
/* figures out the total */
/* rows and columns used */
void rowcol()
{
end=strlen(str1);
/* find ',' */
delim=strfnd(",",str1,1);
for(ctr=0;ctr<=delim-1;ctr++)cols[ctr]=str1[ctr];
cols[ctr]=0;
col=atoi(cols);
for(ctr=delim;ctr<end;ctr++)rows[ctr-delim]=str1[ctr+1];
rows[ctr]=0;
row=atoi(rows);
return;
}

/* DEFine CHaRacter */
/* more correctly, plot points */
void defchr()
{
int temp,temptr,more;
end=strlen(str1);
temptr=0;
chrptr=0;
for(ctr=0;ctr<end;ctr++)
{
temp=str1[ctr];
if(temp!=',')rows[temptr++]=temp;
else {rows[temptr]=0; chardat[chrptr]=atoi(rows);
temptr=0;
chrptr=chrptr+1; }
rows[temptr]=0;chardat[chrptr]=atoi(rows);
/* define last one */
}

for(ctr=0;ctr<8;ctr++) /* 8 pixels high */
{
/* The next line is the bad way of doing things!!!! */
scrn=131072+(rctr*8+ctr)*128+(cctr+10)*2;
*scrn=chardat[ctr];
}
return;
}

Products

 

Downloadable Media

 

Image Gallery

Scroll to Top