MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / WSA_DisplayFrame

Function WSA_DisplayFrame

src/wsa.c:407–488  ·  view source on GitHub ↗

* Display a frame. * @param wsa The pointer to the WSA. * @param frameNext The next frame to display. * @param posX The X-position of the WSA. * @param posY The Y-position of the WSA. * @param screenID The screenID to draw on. * @return False on failure, true on success. */

Source from the content-addressed store, hash-verified

405 * @return False on failure, true on success.
406 */
407bool WSA_DisplayFrame(void *wsa, uint16 frameNext, uint16 posX, uint16 posY, Screen screenID)
408{
409 WSAHeader *header = (WSAHeader *)wsa;
410 uint8 *dst;
411
412 uint16 i;
413 uint16 frame;
414 int16 frameDiff;
415 int16 direction;
416 int16 frameCount;
417
418 if (wsa == NULL) return false;
419 if (frameNext >= header->frames) return false;
420
421 if (header->flags.displayInBuffer) {
422 dst = (uint8 *)wsa + sizeof(WSAHeader);
423 } else {
424 dst = GFX_Screen_Get_ByIndex(screenID);
425 dst += posX + posY * SCREEN_WIDTH;
426 }
427
428 if (header->frameCurrent == header->frames) {
429 if (!header->flags.hasNoFirstFrame) {
430 if (!header->flags.displayInBuffer) {
431 Format40_Decode_ToScreen(dst, header->buffer, header->width);
432 } else {
433 Format40_Decode(dst, header->buffer);
434 }
435 }
436
437 header->frameCurrent = 0;
438 }
439
440 frameDiff = abs(header->frameCurrent - frameNext);
441 direction = 1;
442
443 if (frameNext > header->frameCurrent) {
444 frameCount = header->frames - frameNext + header->frameCurrent;
445
446 if (frameCount < frameDiff && !header->flags.noAnimation) {
447 direction = -1;
448 } else {
449 frameCount = frameDiff;
450 }
451 } else {
452 frameCount = header->frames - header->frameCurrent + frameNext;
453
454 if (frameCount < frameDiff && !header->flags.noAnimation) {
455 } else {
456 direction = -1;
457 frameCount = frameDiff;
458 }
459 }
460
461 frame = header->frameCurrent;
462 if (direction > 0) {
463 for (i = 0; i < frameCount; i++) {
464 frame += direction;

Callers 9

House_UpdateRadarStateFunction · 0.85
GameLoop_PlayAnimationFunction · 0.85
Gameloop_LogosFunction · 0.85
GUI_FactoryWindow_InitFunction · 0.85
GUI_Mentat_ShowFunction · 0.85
GUI_Mentat_DisplayFunction · 0.85
GUI_Mentat_LoopFunction · 0.85
GUI_Security_ShowFunction · 0.85

Calls 6

GFX_Screen_Get_ByIndexFunction · 0.85
Format40_Decode_ToScreenFunction · 0.85
Format40_DecodeFunction · 0.85
WSA_GotoNextFrameFunction · 0.85
WSA_DrawFrameFunction · 0.85
GFX_Screen_SetDirtyFunction · 0.85

Tested by

no test coverage detected