#include #include "Header.h" #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif #ifndef MAX_OBJECTS #define MAX_OBJECTS 256 #endif // Probability of colours dropping int colours[64] = { 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 5, 5, 6, 6, 1, 2, 3, 3, 5, 5, 6, 6, 4, 7 }; void NewBlockPair(blocks *blockPair, int player) { if (player == 1) { blockPair->x1 = 4; blockPair->x2 = 4; blockPair->y1 = 0; blockPair->y2 = 1; blockPair->col1 = colours[rand() & 63]; blockPair->col2 = colours[rand() & 63]; } else { blockPair->x1 = 12; blockPair->x2 = 12; blockPair->y1 = 0; blockPair->y2 = 1; blockPair->col1 = colours[rand() & 63]; blockPair->col2 = colours[rand() & 63]; } } void InitialiseBlock(GsSPRITE *block, long TIMdata, GsIMAGE *image) { ProperInitialiseTexture(TIMdata, image); block->attribute = (1<<25); block->w = 16; block->h = 16; block->u = 0; block->v = 0; block->r = 128; block->g = 128; block->b = 128; block->mx = 0; block->my = 0; block->scalex = ONE; block->scaley = ONE; block->rotate = 0; block->tpage = GetTPage(2,0,image->px,image->py); } void InitialiseSmash(GsSPRITE *smash, long TIMdata, GsIMAGE *image) { ProperInitialiseTexture(TIMdata, image); smash->attribute = (1<<25)+(1<<30)+(1<<28); smash->w = 16; smash->h = 16; smash->u = 0; smash->v = 0; smash->r = 128; smash->g = 128; smash->b = 128; smash->mx = 8; smash->my = 8; smash->scalex = ONE; smash->scaley = ONE; smash->rotate = 0; smash->tpage = GetTPage(2,1,image->px,image->py); } void InitialiseFont(GsSPRITE *font, long TIMdata, GsIMAGE *image) { ProperInitialiseTexture(TIMdata, image); font->attribute = (1<<28)+(1<<30)+(1<<24); font->w = 16; font->h = 18; font->u = 0; font->v = 0; font->cx = image->cx; font->cy = image->cy; font->r = 128; font->g = 128; font->b = 128; font->mx = 0; font->my = 0; font->scalex = ONE; font->scaley = ONE; font->rotate = 0; font->tpage = GetTPage(1,1,image->px,image->py); } void InitialiseWell(GsSPRITE *wellsprite, long TIMdata, GsIMAGE *image) { ProperInitialiseTexture(TIMdata, image); wellsprite->attribute = (1<<30); wellsprite->w = 128; wellsprite->h = 216; wellsprite->u = image->px % 64; wellsprite->v = image->py & 255; wellsprite->cx = image->cx; wellsprite->cy = image->cy; wellsprite->r = 128; wellsprite->g = 128; wellsprite->b = 128; wellsprite->mx = 0; wellsprite->my = 0; wellsprite->scalex = ONE; wellsprite->scaley = ONE; wellsprite->rotate = 0; wellsprite->tpage = GetTPage(0,0,image->px,image->py); } void InitialisePlayer(GsSPRITE *player, long TIMdata, GsIMAGE *image) { ProperInitialiseTexture(TIMdata, image); player->attribute = (1<<25); player->w = 70; player->h = 68; player->u = image->px % 64; player->v = image->py & 255; player->r = 128; player->g = 128; player->b = 128; player->mx = 35; player->my = 68; player->scalex = ONE; player->scaley = ONE; player->rotate = 0; player->tpage = GetTPage(2,0,image->px,image->py); } void InitialiseMenu(GsSPRITE *menu, long TIMdata, GsIMAGE *image) { ProperInitialiseTexture(TIMdata, image); menu->attribute = (1<<28)+(1<<30)+(1<<24); menu->w = 96; menu->h = 18; menu->u = 0; menu->v = 0; menu->cx = image->cx; menu->cy = image->cy; menu->r = 128; menu->g = 128; menu->b = 128; menu->mx = 48; menu->my = 0; menu->scalex = ONE; menu->scaley = ONE; menu->rotate = 0; menu->tpage = GetTPage(1,1,image->px,image->py); } void InitialiseLogo(GsSPRITE *logo, long TIMdata, GsIMAGE *image) { ProperInitialiseTexture(TIMdata, image); logo->attribute = (1<<25)+(1<<30)+(1<<28); logo->w = 64; logo->h = 64; logo->u = 0; logo->v = 128; logo->cx = image->cx; logo->cy = image->cy; logo->r = 128; logo->g = 128; logo->b = 128; logo->mx = 32; logo->my = 32; logo->scalex = ONE; logo->scaley = ONE; logo->rotate = 0; logo->tpage = GetTPage(2,1,image->px,image->py); } void InitialiseWeight(GsSPRITE *weight, long TIMdata, GsIMAGE *image) { ProperInitialiseTexture(TIMdata, image); weight->attribute = (1<<24); weight->w = 98; weight->h = 97; weight->u = image->px % 64; weight->v = image->py & 255; weight->cx = image->cx; weight->cy = image->cy; weight->r = 128; weight->g = 128; weight->b = 128; weight->mx = 49; weight->my = 97; weight->scalex = ONE; weight->scaley = ONE; weight->rotate = 0; weight->tpage = GetTPage(1,0,image->px,image->py); } void ProperInitialiseTexture(long TIMdata, GsIMAGE *imageInfo) { RECT rect; // Frame buffer rectangular area // +4 because we need to skip head of TIM file // Put TIM data into GsIMAGE structure GsGetTimInfo((u_long *)(TIMdata+4), imageInfo); rect.x = imageInfo->px; rect.y = imageInfo->py; rect.w = imageInfo->pw; rect.h = imageInfo->ph; LoadImage(&rect, imageInfo->pixel); // using rect data puts pixel data into address (image->pixel) DrawSync(0); // if image needs a CLUT, load it up // (pmode: 8 or 9 ==> texture is 4-bit or 8-bit) if ((imageInfo->pmode>>3) & 0x01) { rect.x = imageInfo->cx; rect.y = imageInfo->cy; rect.w = imageInfo->cw; rect.h = imageInfo->ch; LoadImage(&rect, imageInfo->clut); // same thing } // wait for loading to finish DrawSync(0); }