/* -------------------------------------------------------------------- ** File: main.c (Yaroze Intro) ** Date: 12.02.99 ** Author: Robert Jurziga ** Description: This is a little intro for my NetYaroze side. ** (Quit with START) ** Check out the other examples of my code on the ** NetYaroze (\~jbob) ** Please send me bug reports or improve tips how to code ** in C, becouse i'm not so familiar in C coding. ** e-mail: datareg@home.centernet.de */ #include // -------------------------------------------------------------------- // E X T E R N A L S // -------------------------------------------------------------------- extern char stone16_left[]; extern char stone16_right[]; extern char Banner1[]; extern char Banner2[]; // -------------------------------------------------------------------- // D E F I N E S // -------------------------------------------------------------------- #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 256 #define DEFSCRX 4 #define DEFSCRY 18 #define OT_LENGTH 2 #define PACKETMAX 1000 #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(); void InitBackground(); void DrawBackground(); short CheckController(); void InitBanner(char *banner, GsSPRITE *sprite); void DrawBanner(); // -------------------------------------------------------------------- // G L O B A L S // -------------------------------------------------------------------- GsOT WorldOT[2]; GsOT_TAG OTab[2][1<x-=8; if (spr->x == (320-256)) {banner_phase++; banner_count=0;} break; } case 1: { if (banner_count == 350) banner_phase++; banner_count++; break; } case 2: { spr->y+=8; if (spr->y == (256)) banner_phase++; break; } case 3: { banner_to_come++; if (banner_to_come == 2) banner_to_come=0; spr->y=0; spr->x=320; banner_phase=0; } } GsSortFastSprite(spr, &WorldOT[ActiBuf],0); } } /* --------------------------------------------------------------------- // Function: DrawBackground // Purpose: Do the background. */ void DrawBackground() { if (BG_Left.y != 0) { BG_Left.y-=16; BG_Right.y-=16; } GsSortFastSprite(&BG_Left,&WorldOT[ActiBuf],1); // background GsSortFastSprite(&BG_Right,&WorldOT[ActiBuf],1); // gets the lowest // proprity (Z-Cord) } /* --------------------------------------------------------------------- // 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 { return(0); } } /* --------------------------------------------------------------------- // Function: InitBanner // Purpose: This function checks out the port status. // if start is pressed it returns a non null */ void InitBanner(char *banner, GsSPRITE *sprite) { GsSPRITE *spr; u_long *ptr; GsIMAGE tim; RECT rect; int spr_v=0; spr = sprite; ptr = (u_long *)banner; ptr++; GsGetTimInfo(ptr, &tim); rect.x=tim.px; rect.y=tim.py; rect.w=tim.pw; rect.h=tim.ph; LoadImage(&rect, tim.pixel); DrawSync(0); if (tim.py == 128) spr_v = 128; rect.x=tim.cx; rect.y=tim.cy; rect.w=tim.cw; rect.h=tim.ch; LoadImage(&rect, tim.clut); DrawSync(0); spr->attribute = 0; spr->x=320; spr->y=0; spr->w=256; spr->h=128; spr->tpage = GetTPage(0, 0, tim.px, tim.py); spr->u=0; spr->v=spr_v; spr->cx=tim.cx; spr->cy=tim.cy; spr->r = spr->g = spr->b = 128; spr->mx = spr->my = 0; spr->scalex = spr->scaley = ONE; spr->rotate = 0; } /* --------------------------------------------------------------------- // Function: InitBackground // Purpose: Init the background sprites. // There are 2 16bit 160x256 big sprites */ void InitBackground() { GsIMAGE timl; GsIMAGE timr; RECT rect; u_long *ptr; // Trnsfer left side ptr = (u_long *)stone16_left; ptr++; GsGetTimInfo(ptr, &timl); rect.x = timl.px; rect.y = timl.py; rect.w = timl.pw; rect.h = timl.ph; LoadImage(&rect, timl.pixel); DrawSync(0); // Trnasfer right side ptr = (u_long *)stone16_right; ptr++; GsGetTimInfo(ptr, &timr); rect.x = timr.px; rect.y = timr.py; rect.w = timr.pw; rect.h = timr.ph; LoadImage(&rect, timr.pixel); DrawSync(0); // Initalize sprites BG_Left.attribute=(2<<24); // 15bit direct BG_Left.x=0; BG_Left.y=256; // the background comes from bottom BG_Left.w=160; BG_Left.h=256; BG_Left.tpage = GetTPage(2, 0, timl.px, timl.py); BG_Left.u=0; BG_Left.v=0; BG_Left.cx=0; BG_Left.cy=0; BG_Left.r=128; BG_Left.g=128; BG_Left.b=128; BG_Left.mx=0; BG_Left.my=0; BG_Left.scalex=ONE; BG_Left.scaley=ONE; BG_Left.rotate=0; BG_Right.attribute=(2<<24); BG_Right.x=160; // attach right side BG_Right.y=256; BG_Right.w=160; BG_Right.h=256; BG_Right.tpage = GetTPage(2, 0, timr.px, timr.py); BG_Right.u=0; BG_Right.v=0; BG_Right.cx=0; BG_Right.cy=0; BG_Right.r=128; BG_Right.g=128; BG_Right.b=128; BG_Right.mx=0; BG_Right.my=0; BG_Right.scalex=ONE; BG_Right.scaley=ONE; BG_Right.rotate=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 = 1; WorldOT[0].org = OTab[0]; WorldOT[1].length = 1; 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); }