// *********************************************************************************** // Program written by B. Swan - BURROWINGGERBIL@HOTMAIL.COM // *********************************************************************************** // *********************************************************************************** // Main initialisation function // *********************************************************************************** // **** subroutines ****************************************************************** void Initialise() { u_short tTemp1, tTemp2; u_char *tTemp3; RECT tRect; FntLoad(960, 256); // load the standard font into memory FntOne = FntOpen(32, 32, 320, 100, 0, 256); // give display window info for font InitialiseScreen(); // set screen info PadInit(); // set pad info LoadTIMData(TIM_ADDRESS1); // copy TIM data into video ram LoadTIMData(TIM_ADDRESS2); LoadTIMData(TIM_ADDRESS3); LoadTIMData(TIM_ADDRESS4); LoadTIMData(TIM_ADDRESS5); // Load sound data VBRet = SsVabTransfer((unsigned char *) VH_ADDRESS,(unsigned char *) VB_ADDRESS,-1,1); // Set main volume SsSetMVol(127, 127); // Calculate sin and cos for (tTemp1 = 0; tTemp1<360; tTemp1++) { SIN[tTemp1] = sin(((double) tTemp1) / 180.0 * 3.1416); COS[tTemp1] = cos(((double) tTemp1) / 180.0 * 3.1416); } // Get block data from main memory into array for (tTemp1 = 0; tTemp1<256; tTemp1++) { for (tTemp2 = 0; tTemp2<2; tTemp2++) { tTemp3 = (u_char*)(BLOCK_ADDRESS + tTemp1 * 2 + tTemp2); BlockData[tTemp1][tTemp2] = *tTemp3; } } // Split a loaded grahic up into foreground sprites tRect.w = tRect.h = 16; for (tTemp1 = 0; tTemp1<64; tTemp1++) { tRect.y = (tTemp1 / 4) * 16; for (tTemp2 = 0; tTemp2<4; tTemp2++) { tRect.x = 320 + (tTemp1 % 4) * 16 + tTemp2 * 64; SetBlocksInfo(&LevelBlocks[tTemp1 + tTemp2 * 64], &tRect, 0, 480, 8); if (BlockData[tTemp1 + tTemp2 * 64][1] != 255) { LevelBlocks[tTemp1 + tTemp2 * 64].attribute += (1 << 30) + (BlockData[tTemp1 + tTemp2 * 64][1] << 28); } } } // Split a loaded grahic up into player sprites tRect.w = 40; tRect.h = 23; for (tTemp1 = 0; tTemp1<16; tTemp1++) { tRect.x = 832 + tTemp1 / 8 * 40; tRect.y = tTemp1 % 8 * 23; SetBlocksInfo(&PlayerShip[tTemp1], &tRect, 0, 483, 8); } tRect.x = 320; tRect.y = 432; tRect.w = tRect.h = 16; SetBlocksInfo(&Splash, &tRect, 0, 484, 8); Splash.attribute += (1 << 30) + (1 << 28); Splash.my = 2; // Split a loaded grahic up into glows tRect.x = 704; tRect.w = tRect.h = 64; for (tTemp1 = 0; tTemp1<3; tTemp1++) { tRect.y = tTemp1 * 64; SetBlocksInfo(&Glows[tTemp1], &tRect, 0, 482, 8); Glows[tTemp1].attribute += (1 << 30) + (1 << 28); Glows[tTemp1].mx = Glows[tTemp1].my = 32; } tRect.y = 192; tRect.w = tRect.h = 32; for (tTemp1 = 0; tTemp1<2; tTemp1++) { tRect.x = 704 + tTemp1 * 32; SetBlocksInfo(&Glows[tTemp1 + 3], &tRect, 0, 482, 8); Glows[tTemp1 + 3].attribute += (1 << 30) + (1 << 28); Glows[tTemp1 + 3].mx = Glows[tTemp1 + 3].my = 16; } tRect.y = 224; tRect.w = tRect.h = 16; for (tTemp1 = 0; tTemp1<4; tTemp1++) { tRect.x = 704 + tTemp1 * 16; SetBlocksInfo(&Glows[tTemp1 + 5], &tRect, 0, 482, 8); Glows[tTemp1 + 5].attribute += (1 << 30) + (1 << 28); Glows[tTemp1 + 5].mx = Glows[tTemp1 + 5].my = 8; } // bullet glows tRect.x = 320; tRect.h = 16; for (tTemp1 = 0; tTemp1<4; tTemp1++) { tRect.y = 432 + (tTemp1 + 1) * 16; tRect.w = (tTemp1 + 1) * 16; SetBlocksInfo(&Glows[tTemp1 + 9], &tRect, 0, 484, 8); Glows[tTemp1 + 9].attribute += (1 << 30) + (1 << 28); Glows[tTemp1 + 9].mx = Glows[tTemp1 + 9].my = 7; } // Split a loaded grahic up into enemies // Comet tRect.x = 320; tRect.y = 256; tRect.w = 32; tRect.h = 32; SetBlocksInfo(&Comet, &tRect, 0, 484, 8); // Power up tRect.x = 352; tRect.y = 256; tRect.w = 32; tRect.h = 32; SetBlocksInfo(&PowerUp, &tRect, 0, 484, 8); // Worm tRect.y = 288; tRect.w = 16; tRect.h = 16; for (tTemp1 = 0; tTemp1<3; tTemp1++) { if (tTemp1 == 2) tRect.w = 32; tRect.x = 320 + tTemp1 * 16; SetBlocksInfo(&Worm[tTemp1], &tRect, 0, 484, 8); } Worm[2].mx = 8; // Rock tRect.x = 320; tRect.y = 304; tRect.w = tRect.h = 16; SetBlocksInfo(&Rock, &tRect, 0, 484, 8); Rock.r = 127; Rock.g = Rock.b = 96; // Get level data from main memory into array for (tTemp1 = 0; tTemp1<400; tTemp1++) { for (tTemp2 = 0; tTemp2<15; tTemp2++) { tTemp3 = (u_char*)(LEVEL_ADDRESS + tTemp1 * 15 + tTemp2); LevelDATA[tTemp1][tTemp2] = *tTemp3; } } // Set up back layer of parallax data for (tTemp1 = 0; tTemp1<100; tTemp1++) { for (tTemp2 = 0; tTemp2<15; tTemp2++) { LevelBackDATA[tTemp1][tTemp2] = tTemp2 % 4 + (tTemp1 % 4) * 4; } } // Set up cell graphical data for (tTemp1 = 0; tTemp1<64; tTemp1++) { LevelCELL[tTemp1].u = (tTemp1 % 4) * 16; LevelCELL[tTemp1].v = (tTemp1 / 4) * 16; LevelCELL[tTemp1].cba = GetClut(0, 481); LevelCELL[tTemp1].tpage = GetTPage(1, 0, 576, 0); } LevelMAP.cellw = LevelMAP.cellh = 16; LevelMAP.ncellw = 15; LevelMAP.ncellh = 100; LevelMAP.base = &LevelCELL[0]; LevelMAP.index = &LevelBackDATA[0][0]; LevelBG.attribute += (1 << 24); LevelBG.scrollx = LevelBG.scrolly = 0; LevelBG.map = &LevelMAP; GsInitFixBg16(&LevelBG, &LevelBGWork[0]); // Set up stars for (tTemp1 = 0; tTemp1<15; tTemp1++) { Stars[tTemp1].speed = rand() % 3 + 5; Stars[tTemp1].x = (rand() % 320) << 4; Stars[tTemp1].y = rand() % 240; Stars[tTemp1].r = Stars[tTemp1].g = Stars[tTemp1].b = rand() % 128; } for (tTemp1 = 15; tTemp1<50; tTemp1++) { Stars[tTemp1].speed = rand() % 16 + 9; Stars[tTemp1].x = (rand() % 320) << 4; Stars[tTemp1].y = rand() % 240; Stars[tTemp1].r = Stars[tTemp1].g = Stars[tTemp1].b = rand() % 128; } // Set up players for (tTemp1 = 0; tTemp1<2; tTemp1++) { Player[tTemp1].alive = 0; Player[tTemp1].lives = 3; Player[tTemp1].speed = 2; Player[tTemp1].weapon = 1; Player[tTemp1].weaponlevel = 0; Player[tTemp1].score = 0; Player[tTemp1].firestatus = 0; Player[tTemp1].firetimer = 0; Player[tTemp1].fireglow = 0; Player[tTemp1].firehaze = 0; Player[tTemp1].timer = 0; Player[tTemp1].invincible = 64 * 3; } Player[0].xreal = 70 << 2; Player[0].yreal = 60 << 2; Player[0].x = Player[0].xreal >> 2; Player[0].y = Player[0].yreal >> 2; Player[0].r = 160; Player[0].g = 128; Player[0].b = 96; Player[1].xreal = 70 << 2; Player[1].yreal = 160 << 2; Player[1].x = Player[1].xreal >> 2; Player[1].y = Player[1].yreal >> 2; Player[1].r = 96; Player[1].g = 128; Player[1].b = 160; // Set up player bullets for (tTemp1 = 0; tTemp1<2; tTemp1++) { for (tTemp2 = 0; tTemp2