// *********************************************************************************** // Program written by B. Swan - BURROWINGGERBIL@HOTMAIL.COM // *********************************************************************************** // *********************************************************************************** // Setup the screen and screen variables for each frame // *********************************************************************************** void RenderStart() { currentBuffer = GsGetActiveBuff(); // determine which buffer is to be used GsClearOt(0, 0, &OTable_Header[currentBuffer]); // clear out OTable sorting info GsSetWorkBase((PACKET*)Packet_Memory[currentBuffer]); // set scratchpad area for the OT } // *********************************************************************************** // Draw all the screen // *********************************************************************************** void RenderWorld() { // currentBuffer = GsGetActiveBuff(); // determine which buffer is to be used // GsClearOt(0, 0, &OTable_Header[currentBuffer]); // clear out OTable sorting info // GsSetWorkBase((PACKET*)Packet_Memory[currentBuffer]); // set scratchpad area for the OT DrawFront(); // draw front layer of parallax DrawBack(); // draw back layer of parallax DrawPlayers(); // draw player ships DrawPlayerBullets(); // draw player bullets DrawStars(); // draw stars DrawInfo(); // draw information DrawSync(0); // wait for completion of all output ScreenDrawTiming = VSync(0); // wait for blank and time it GsSwapDispBuff(); // swap buffer information //GsSortClear(0, 0, 0, &OTable_Header[currentBuffer]); // send a request to clear the screen // to the ordering table GsDrawOt(&OTable_Header[currentBuffer]); // draw commands in queue FntFlush(FntOne); // output any text onto the screen } // *********************************************************************************** // Draw front layer of parallax // *********************************************************************************** void DrawFront() { u_short tTemp1, tTemp2; u_short tTempBlock; for (tTemp1 = 0; tTemp1 < 16; tTemp1++) { for (tTemp2 = 0; tTemp2 < 21; tTemp2++) { tTempBlock = LevelDATA[(LevelX >> 4) + tTemp2][tTemp1]; if (tTempBlock != 0) { LevelBlocks[tTempBlock].x = tTemp2 * 16 - LevelX % 16; LevelBlocks[tTempBlock].y = tTemp1 * 16; GsSortFastSprite(&LevelBlocks[tTempBlock], &OTable_Header[currentBuffer], 3); } } } } // *********************************************************************************** // Draw back layer of parallax // *********************************************************************************** void DrawBack() { LevelBG.scrollx = (LevelX >> 1); GsSortFixBg16(&LevelBG, &LevelBGWork[0], &OTable_Header[currentBuffer], 7); } // *********************************************************************************** // Draw stars // *********************************************************************************** void DrawStars() { u_short tTemp; GsGLINE tGLine; tGLine.attribute = (1 << 28) + (1 << 30); tGLine.r1 = tGLine.g1 = tGLine.b1 = 0; for (tTemp = 0; tTemp<50; tTemp++) { tGLine.r0 = Stars[tTemp].r; tGLine.g0 = Stars[tTemp].g; tGLine.b0 = Stars[tTemp].b; tGLine.x0 = Stars[tTemp].x >> 4; tGLine.y0 = tGLine.y1 = Stars[tTemp].y; tGLine.x1 = tGLine.x0 + Stars[tTemp].speed; if (tTemp < 15) { GsSortGLine(&tGLine, &OTable_Header[currentBuffer], 5); } else { GsSortGLine(&tGLine, &OTable_Header[currentBuffer], 2); } Stars[tTemp].x -= Stars[tTemp].speed; if (tGLine.x0 < -20) { Stars[tTemp].x = 320 << 4; Stars[tTemp].y = rand() % 240; } } } // *********************************************************************************** // Draw information // *********************************************************************************** void DrawInfo() { GsBOXF tBox; // Draw player 1 power up if necessary if ((Player[0].alive == 1) && (Player[0].firetimer > HOLDTIME)) { tBox.x = 35; tBox.y = 10; tBox.w = (Player[0].firetimer - HOLDTIME) * 2.5 + 1; tBox.h = 5; tBox.r = 127; tBox.g = tBox.b = 0; tBox.attribute = (1 << 30) + (1 << 28); GsSortBoxFill(&tBox, &OTable_Header[currentBuffer], 0); } // Draw player 2 power up if necessary if ((Player[1].alive == 1) && (Player[1].firetimer > HOLDTIME)) { tBox.x = 35; tBox.y = 225; tBox.w = (Player[1].firetimer - HOLDTIME) * 2.5 + 1; tBox.h = 5; tBox.r = tBox.g = 0; tBox.b = 127; tBox.attribute = (1 << 30) + (1 << 28); GsSortBoxFill(&tBox, &OTable_Header[currentBuffer], 0); } // Draw dark regions for power bar tBox.x = 32; tBox.y = 8; tBox.w = 256; tBox.h = 9; tBox.r = tBox.g = tBox.b = 128; tBox.attribute = (1 << 30) + (0 << 28); GsSortBoxFill(&tBox, &OTable_Header[currentBuffer], 0); tBox.y = 223; GsSortBoxFill(&tBox, &OTable_Header[currentBuffer], 0); // FntPrint(FntOne, "\n ScreenDrawTiming = %d\n", ScreenDrawTiming); // FntPrint(FntOne, "LevelX = %d\n", LevelX); // FntPrint(FntOne, "TotalEnemies = %d\n", TotalEnemies); // FntPrint(FntOne, "Trigger = %d\n", CurrentTrigger); // FntPrint(FntOne, "Trigger.position = %d\n", LevelTriggers[CurrentTrigger].position); }