#include #include "hack.h" char **iconH; int icon_number; int frame_number = 0; int image_dirty = TRUE; static long msg_len; #define EXT(n,b) (((n)>>(b))&1) #define INS(n,b) (((n)&1)< 200) { if (!at_least_one) return FALSE; icon = 128; } continue; } at_least_one = TRUE; iconH = rotate_icon(iH); break; } icon_number = icon; frame_number = a >> 7; image_dirty = TRUE; icon++; for (n = 0; n < 128; n++) { send_to_blaster(1,a,(*iconH)[n]); a++; } // HACK // insert blank frame between icon frames for (n = 0; n < 128; n++) { send_to_blaster(1,a,0); a++; } if (a < 0x2000) return TRUE; // put blaster into a safe state send_to_blaster(0,0,0); a = 0; icon = 128; return FALSE; } static void send_to_blaster(int write, long a, int d) { static int inited = FALSE; static short refNum = aoutRefNum; char msg[8]; long count; // HACK // flip address and data to avoid inverter in controller a = ~a; d = ~d; // HACK // add 1 at A1 to avoid inverter in controller (to generate PLOAD) a += 2; if (!inited) { inited = TRUE; OpenDriver("\p.Aout",&refNum); SerReset(refNum,baud57600+stop10+noParity+data8); } if (write) { msg[0] = 0x92 | INS(EXT(a,11),6) | INS(EXT(a,12),3) ; msg[1] = 0x92 | INS(EXT(a, 8),6) | INS(EXT(a, 9),3) | INS(EXT(a,10),0); msg[2] = 0x92 | INS(EXT(a, 5),6) | INS(EXT(a, 6),3) | INS(EXT(a, 7),0); msg[3] = 0x92 | INS(EXT(a, 2),6) | INS(EXT(a, 3),3) | INS(EXT(a, 4),0); msg[4] = 0x92 | INS(EXT(d, 0),6) | INS(EXT(a, 0),3) | INS(EXT(a, 1),0); msg[5] = 0x92 | INS(EXT(d, 3),6) | INS(EXT(d, 2),3) | INS(EXT(d, 1),0); msg[6] = 0x92 | INS(EXT(d, 6),6) | INS(EXT(d, 5),3) | INS(EXT(d, 4),0); msg[7] = 0xa2 | INS(EXT(d, 7),0); } else { msg[0] = 0xdb; msg[1] = 0xdb; msg[2] = 0xdb; msg[3] = 0xdb; msg[4] = 0xdb; msg[5] = 0xdb; msg[6] = 0xdb; msg[7] = 0xdb; } count = 8; FSWrite(refNum,&count,msg); } // // rotate icon 90 degress counter-clockwise // since the shark scanner is vertical // static char **rotate_icon(char **iH) { static char buf[128]; char *i = *iH; int c; int x; int b; int bb; for (c = 0; c < 32; c++) { bb = c * 4; b = c & 7; x = 3 - ((c - b) >> 3); buf[bb+0] = MAKE_BYTE( EXT(i[ 0*4+x],b), EXT(i[ 1*4+x],b), EXT(i[ 2*4+x],b), EXT(i[ 3*4+x],b), EXT(i[ 4*4+x],b), EXT(i[ 5*4+x],b), EXT(i[ 6*4+x],b), EXT(i[ 7*4+x],b) ); buf[bb+1] = MAKE_BYTE( EXT(i[ 8*4+x],b), EXT(i[ 9*4+x],b), EXT(i[10*4+x],b), EXT(i[11*4+x],b), EXT(i[12*4+x],b), EXT(i[13*4+x],b), EXT(i[14*4+x],b), EXT(i[15*4+x],b) ); buf[bb+2] = MAKE_BYTE( EXT(i[16*4+x],b), EXT(i[17*4+x],b), EXT(i[18*4+x],b), EXT(i[19*4+x],b), EXT(i[20*4+x],b), EXT(i[21*4+x],b), EXT(i[22*4+x],b), EXT(i[23*4+x],b) ); buf[bb+3] = MAKE_BYTE( EXT(i[24*4+x],b), EXT(i[25*4+x],b), EXT(i[26*4+x],b), EXT(i[27*4+x],b), EXT(i[28*4+x],b), EXT(i[29*4+x],b), EXT(i[30*4+x],b), EXT(i[31*4+x],b) ); } { static char *p; static char **h; p = buf; h = &p; return h; } }