/*************************************/ /* */ /* AUoH Progressive Door Prize Lotto */ /* */ /* DISPLAY routines */ /* */ /* Michael D. Groshart - 16 Aug 89 */ /* */ /*************************************/ #include #include extern struct Window *win; extern struct RastPort *rp; extern struct ViewPort *vp; #define XOFFSET 96 static long colreg = 2, rand(); static long led[7][6][2] = { 32, 82, 26, 76, 26, 28, 32, 22, 39, 29, 39, 75, 34, 20, 40, 14, 88, 14, 94, 20, 87, 27, 41, 27, 96, 22, 102, 28, 102, 76, 96, 82, 89, 75, 89, 29, 94, 84, 87, 91, 41, 91, 34, 84, 41, 77, 87, 77, 32, 86, 39, 93, 39, 139, 32, 146, 26, 140, 26, 92, 34, 148, 41, 141, 87, 141, 94, 148, 88, 154, 40, 154, 96, 146, 89, 139, 89, 93, 96, 86, 102, 92, 102, 140 }; static long fill[7][2] = { 32, 81, 35, 20, 96, 23, 93, 84, 32, 87, 35, 148, 96, 145 }; static int digit[10][7] = { 1, 1, 1, 0, 1, 1, 1, /* 0 */ 0, 0, 1, 0, 0, 0, 1, /* 1 */ 0, 1, 1, 1, 1, 1, 0, /* 2 */ 0, 1, 1, 1, 0, 1, 1, /* 3 */ 1, 0, 1, 1, 0, 0, 1, /* 4 */ 1, 1, 0, 1, 0, 1, 1, /* 5 */ 1, 1, 0, 1, 1, 1, 1, /* 6 */ 0, 1, 1, 0, 0, 0, 1, /* 7 */ 1, 1, 1, 1, 1, 1, 1, /* 8 */ 1, 1, 1, 1, 0, 1, 1 /* 9 */ }; init_digits() { register long color = 2; register int a,b,c; for (a = 0; a < 3; a++) { for (b = 0; b < 7; b++) { SetAPen(rp,color++); Move(rp,led[b][5][0],led[b][5][1]); for (c = 0; c < 6; c++) { Draw(rp,led[b][c][0],led[b][c][1]); led[b][c][0] += XOFFSET; } Flood(rp,1L,fill[b][0],fill[b][1]); fill[b][0] += XOFFSET; } } SetAPen(rp,25L); /* draw bottom text box */ Move(rp, 6L,172L); Draw(rp,313L,172L); Draw(rp,313L,183L); Draw(rp, 6L,183L); Draw(rp, 6L,172L); } erase() { SetAPen(rp,0L); RectFill(rp,7L,173L,312L,182L); } flash() { SetRGB4(vp,colreg,rand(16L),rand(16L),rand(16L)); if (++colreg == 23) colreg = 2; } char message[80]; scroll(text) register char *text; { register struct IntuiMessage *im; register char *ptr = message; register int n; strcpy(message,text); strcat(message," "); SetAPen(rp,1L); while (!(im = (struct IntuiMessage *) GetMsg(win->UserPort))) { for (n = 0; n < 4; n++) { WaitTOF(); ScrollRaster(rp,2L,0L,8L,174L,311L,181L); } Move(rp, 304L, 180L); Text(rp, ptr, 1L); if (*++ptr == '\0') ptr = message; } ReplyMsg(im); } display(num) int num; { register int i; for (i = 16; i >= 2; i -= 7) { set_led(i,num % 10); num /= 10; } } static set_led(pos,val) int pos,val; { register long n; for (n = 0; n < 7; n++) { if (digit[val][n]) SetRGB4(vp,pos + n,15L,15L,0L); else SetRGB4(vp,pos + n,0L,0L,0L); } }