/* -------------------------------------------------------------------- ** File: main.c (mosaik effect) ** Date: 21.02.99 ** Author: Robert Jurziga ** Description: This shows a little mosaik effect on a 320x256x16 ** image. R1 and L1 modifies the mosiak tile size. ** Quit with START ** for improvements ** e-mail: datareg@home.centernet.de ** */ #include // -------------------------------------------------------------------- // E X T E R N A L S // -------------------------------------------------------------------- extern char NYLogo[]; // -------------------------------------------------------------------- // D E F I N E S // -------------------------------------------------------------------- #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 256 #define DEFSCRX 4 #define DEFSCRY 18 #define OT_LENGTH 1 #define PACKETMAX 10 #define PADLup (1<<12) #define PADLdown (1<<14) #define PADLleft (1<<15) #define PADLright (1<<13) #define PADRup (1<< 4) #define PADRdown (1<< 6) #define PADRleft (1<< 7) #define PADRright (1<< 5) #define PADi (1<< 9) #define PADj (1<<10) #define PADk (1<< 8) #define PADl (1<< 3) #define PADm (1<< 1) #define PADn (1<< 2) #define PADo (1<< 0) #define PADh (1<<11) #define PADL1 PADn #define PADL2 PADo #define PADR1 PADl #define PADR2 PADm #define PADstart PADh #define PADselect PADk // -------------------------------------------------------------------- // P R O T O T Y P E S // -------------------------------------------------------------------- void InitView(); void RestoreView(); short CheckController(); void DrawLogo(); // -------------------------------------------------------------------- // G L O B A L S // -------------------------------------------------------------------- GsOT WorldOT[2]; GsOT_TAG OTab[2][1< 2) { ptr = (u_short *)img.pixel; dr.y = (ActiBuf<<8); dr.h = tilesize; loop = (SCREEN_HEIGHT / tilesize)+1; ycount = SCREEN_HEIGHT; for (k=0; k tilesize) { colour=*ptr2; r=(colour&0x1f); g=((colour>>5)&0x1f); b=((colour>>10)&0x1f); r=truelookup[r]; g=truelookup[g]; b=truelookup[b]; ClearImage(&dr, r, g, b); ptr2+=tilesize; dr.x+=tilesize; xcount-=tilesize; } if (xcount != 0) { dr.w = xcount; colour=*ptr2; r=(colour&0x1f); g=((colour>>5)&0x1f); b=((colour>>10)&0x1f); r=truelookup[r]; g=truelookup[g]; b=truelookup[b]; ClearImage(&dr, r, g, b); } ptr+=(320*tilesize); dr.y+=tilesize; ycount-=tilesize; if (ycount == 0) break; if (ycount < tilesize) dr.h = ycount; } } else { dr.x = 0; dr.y = (ActiBuf<<8); dr.w = 320; dr.h=256; LoadImage(&dr, img.pixel); } } /* --------------------------------------------------------------------- // Function: CheckController // Purpose: This function checks out the port status. // if start is pressed it returns a non null */ short CheckController() { PadBits=(~(*(pport0+3) | *(pport0+2) << 8 | *(pport1+3) << 16 | *(pport1+2) << 24)); if (PadBits & PADstart) // return 1 here to signal exit!!! { return(1); } else { if (PadBits & PADR1) tilesize-=1; if (PadBits & PADL1) tilesize+=1; if (tilesize < 0) tilesize=0; return(0); } } /* --------------------------------------------------------------------- // Function: InitView // Purpose: Set up screen to display and save the previouse // screen datas. */ void InitView() { OldView = GetVideoMode(); // Set up graphics SetVideoMode(MODE_PAL); ResetGraph(0); GsInitGraph(SCREEN_WIDTH, SCREEN_HEIGHT, GsOFSGPU, 0, 0); GsDefDispBuff(0, 0, 0, SCREEN_HEIGHT); // Set display output GsDISPENV.screen.x=DEFSCRX; GsDISPENV.screen.y=DEFSCRY; GsDISPENV.screen.w=255; GsDISPENV.screen.h=255; // Set bg clear color and flag GsDRAWENV.r0 = 0x00; GsDRAWENV.g0 = 0x00; GsDRAWENV.b0 = 0x00; GsDRAWENV.isbg = 0; // set up ordering table WorldOT[0].length = OT_LENGTH; WorldOT[0].org = OTab[0]; WorldOT[1].length = OT_LENGTH; WorldOT[1].org = OTab[1]; // init ordering table GsClearOt(0, 0, &WorldOT[0]); GsClearOt(0, 0, &WorldOT[1]); } /* --------------------------------------------------------------------- // Function: RestoreView // Purpose: Restore the view. */ void RestoreView() { SetVideoMode(OldView); ResetGraph(0); }