#include #include #include #include /*{{{ defines*/ #define out_link(i) (Channel *) (0x80000000 | (i<<2)) #define pixel(r,g,b) ((b&0xff)<<8)|((g&0xff)<<16)|((r&0xff)<<24) /*}}} */ /*{{{ void boot_grafix ( char *s, int linkno )*/ void boot_grafix ( char *s, int linkno, int magic ) { FILE *fp; char *blk=malloc(256); int c, i=0; Channel *out=out_link(linkno); if (fp=fopen(s, "rb")) { for (c=fgetc(fp); c!=EOF; c=fgetc(fp)) { blk[i++]=c; if (i==256) { ChanOut ( out, blk, 256 ); i=0; } } if (i!=0) { ChanOut ( out, blk, i ); } ChanOut ( out, (char *) &magic, 4 ); fclose ( fp); } else printf("Couldnt open file %s\n", s); free(blk); } /*}}} */ /*{{{ void pump_raster ( int link_no, int *raster, int y_coord, int x0, int pixels )*/ void pump_raster ( int link_no, int *raster, int y_coord, int x0, int pixels ) { Channel *out=out_link(link_no); int packet[3]; packet[0]=x0; packet[1]=y_coord; packet[2]=pixels; ChanOut ( out, (char *)&packet, 12 ); ChanOut ( out, (char *) raster, pixels<<2 ); } /*}}} */ /*{{{ void work( link_no)*/ void work( int link_no) { unsigned int *raster=(unsigned int *) malloc(768*sizeof(int)); int i, j; /* compute red = 0..255 in x */ /* compute green = 255..0 in x */ /* compute blue = 255..0 in y */ for (j=0; j<480; j++ ) { for (i=0; i<768; i++) { int r, g, b; r=(i*255)/768; g=((767-i)*255)/768; b=((479-j)*255)/480; raster [i]=pixel(r,g,b); } pump_raster ( link_no, (int *) raster, j, 0, 768 ); } } /*}}} */ /*{{{ int main (int argc, char **argv )*/ int main (int argc, char **argv ) { boot_grafix("..\\HSP\\HSP32.btl", 1, 0x6000481 ); work(1); } /*}}} */