* 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. */
| 405 | * @return False on failure, true on success. |
| 406 | */ |
| 407 | bool 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; |
no test coverage detected