MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / TelcomDoPowerEffect

Function TelcomDoPowerEffect

Descent3/TelCom.cpp:2295–2385  ·  view source on GitHub ↗

Draws a frame of the power up/down effect

Source from the content-addressed store, hash-verified

2293
2294// Draws a frame of the power up/down effect
2295void TelcomDoPowerEffect(bool power_down, float frametime) {
2296 int height = (Telcom_system.Monitor_coords[MONITOR_MAIN].bottom) - (Telcom_system.Monitor_coords[MONITOR_MAIN].top);
2297 int width = (Telcom_system.Monitor_coords[MONITOR_MAIN].right) - (Telcom_system.Monitor_coords[MONITOR_MAIN].left);
2298 int xoff = Telcom_system.Monitor_coords[MONITOR_MAIN].left;
2299 int yoff = Telcom_system.Monitor_coords[MONITOR_MAIN].top;
2300
2301 if (!power_down && TC_effect_position >= TCPE_STAGE2)
2302 goto tcpe_adjust;
2303
2304 // draw the power effect at it's current state
2305 rend_SetAlphaType(AT_CONSTANT_TEXTURE);
2306 rend_SetAlphaValue(255);
2307 rend_SetLighting(LS_NONE);
2308 rend_SetColorModel(CM_MONO);
2309 rend_SetOverlayType(OT_NONE);
2310 rend_SetWrapType(WT_CLAMP);
2311 rend_SetFiltering(0);
2312 rend_SetZBufferState(0);
2313
2314 if (TC_effect_position <= TCPE_STAGE1) {
2315 // stage 1
2316 int i, x, y;
2317 int line_count = (TC_effect_position - TCPE_START) / (TCPE_STAGE1 - TCPE_START) * ((float)((width / 32) + 3));
2318 if (line_count < 0)
2319 line_count = 0;
2320
2321 for (y = 0; y < height; y += 32)
2322 for (x = 0; x < width; x += 32) {
2323 rend_DrawScaledBitmap(x + xoff, y + yoff, x + 32 + xoff, y + 32 + yoff, PowerBmps[0], 0, 0, 1, 1);
2324 }
2325
2326 if (TC_effect_position < TCPE_START)
2327 goto tcpe_adjust;
2328
2329 x = (width / 2) - (16 * line_count) + xoff;
2330 y = (height / 2) - 16 + yoff;
2331
2332 for (i = 0; i < line_count; i++) {
2333 rend_DrawScaledBitmap(x, y, x + 32, y + 32, PowerBmps[1], 0, 0, 1, 1);
2334 x += 32;
2335 }
2336 } else {
2337 // stage 2
2338 int x, y, i;
2339 int gap;
2340
2341 gap = ((float)height) * (TC_effect_position - TCPE_STAGE1) / (TCPE_STAGE2 - TCPE_STAGE1);
2342 int hcount = ((((float)height) / 2.0f) - (((float)gap) / 2.0f)) / 32.0f;
2343
2344 for (i = 0; i < hcount; i++)
2345 for (x = 0; x < width; x += 32) {
2346 y = (i << 5);
2347 if (i == (hcount - 1)) {
2348 rend_SetAlphaType(AT_SATURATE_TEXTURE);
2349 rend_DrawScaledBitmap(x + xoff, y + 10 + yoff, x + 32 + xoff, y + 42 + yoff, PowerBmps[1], 0, 0, 1, 1);
2350 rend_SetAlphaType(AT_CONSTANT_TEXTURE);
2351 }
2352 rend_DrawScaledBitmap(x + xoff, y + yoff, x + 32 + xoff, y + 32 + yoff, PowerBmps[0], 0, 0, 1, 1);

Callers 1

TelcomRenderScreenFunction · 0.85

Calls 9

rend_SetAlphaTypeFunction · 0.50
rend_SetAlphaValueFunction · 0.50
rend_SetLightingFunction · 0.50
rend_SetColorModelFunction · 0.50
rend_SetOverlayTypeFunction · 0.50
rend_SetWrapTypeFunction · 0.50
rend_SetFilteringFunction · 0.50
rend_SetZBufferStateFunction · 0.50
rend_DrawScaledBitmapFunction · 0.50

Tested by

no test coverage detected