Skip to content

Commit

Permalink
-Change: define HOUSEANIM_FLAGS_* to use in GameLoop_PlayAnimations()
Browse files Browse the repository at this point in the history
  • Loading branch information
miniupnp committed Apr 15, 2018
1 parent aea1d7b commit 30cbf7d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 22 deletions.
45 changes: 23 additions & 22 deletions src/cutscene.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ static void GameLoop_PlayAnimation(const HouseAnimation_Animation *animation)

while (animation->duration != 0) {
uint16 frameCount;
uint16 posX = 0;
uint16 posY = 0;
uint16 posX;
uint16 posY;
uint32 timeout = g_timerGUI + animation->duration * 6;
uint32 timeout2 = timeout + 30; /* timeout + 0.5 s */
uint32 timeLeftForFrame;
Expand All @@ -311,7 +311,10 @@ static void GameLoop_PlayAnimation(const HouseAnimation_Animation *animation)
uint16 frame;
void *wsa;

if ((animation->flags & 0x20) == 0) {
if ((animation->flags & HOUSEANIM_FLAGS_POS0_0) != 0) {
posX = 0;
posY = 0;
} else {
posX = 8;
posY = 24;
}
Expand All @@ -332,10 +335,10 @@ static void GameLoop_PlayAnimation(const HouseAnimation_Animation *animation)
wsaReservedDisplayFrame = true;
} else {
frame = 0;
wsaReservedDisplayFrame = ((animation->flags & 0x40) != 0) ? true : false;
wsaReservedDisplayFrame = ((animation->flags & HOUSEANIM_FLAGS_DISPLAYFRAME) != 0) ? true : false;
}

if ((animation->flags & 0x480) != 0) {
if ((animation->flags & (HOUSEANIM_FLAGS_FADEIN2 | HOUSEANIM_FLAGS_FADEIN)) != 0) {
GUI_ClearScreen(SCREEN_1);

wsa = GFX_Screen_Get_ByIndex(SCREEN_2);
Expand All @@ -353,15 +356,15 @@ static void GameLoop_PlayAnimation(const HouseAnimation_Animation *animation)
}

addFrameCount = 0;
if ((animation->flags & 0x8) != 0) {
if ((animation->flags & HOUSEANIM_FLAGS_FADEOUTTEXT) != 0) {
timeout -= 45;
addFrameCount++;
} else if ((animation->flags & 0x10) != 0) {
} else if ((animation->flags & HOUSEANIM_FLAGS_FADETOWHITE) != 0) {
timeout -= 15;
addFrameCount++;
}

if ((animation->flags & 0x4) != 0) {
if ((animation->flags & HOUSEANIM_FLAGS_FADEINTEXT) != 0) {
GameLoop_PlaySubtitle(animationStep);
WSA_DisplayFrame(wsa, frame++, posX, posY, SCREEN_0);
GameLoop_PalettePart_Update(true);
Expand All @@ -371,17 +374,15 @@ static void GameLoop_PlayAnimation(const HouseAnimation_Animation *animation)
GUI_SetPaletteAnimated(g_palette1, 45);

addFrameCount++;
} else {
if ((animation->flags & 0x480) != 0) {
GameLoop_PlaySubtitle(animationStep);
WSA_DisplayFrame(wsa, frame++, posX, posY, SCREEN_1);
addFrameCount++;
} else if ((animation->flags & (HOUSEANIM_FLAGS_FADEIN2 | HOUSEANIM_FLAGS_FADEIN)) != 0) {
GameLoop_PlaySubtitle(animationStep);
WSA_DisplayFrame(wsa, frame++, posX, posY, SCREEN_1);
addFrameCount++;

if ((animation->flags & 0x480) == 0x80) {
GUI_Screen_FadeIn2(8, 24, 304, 120, SCREEN_1, SCREEN_0, 1, false);
} else if ((animation->flags & 0x480) == 0x400) {
GUI_Screen_FadeIn(1, 24, 1, 24, 38, 120, SCREEN_1, SCREEN_0);
}
if ((animation->flags & (HOUSEANIM_FLAGS_FADEIN2 | HOUSEANIM_FLAGS_FADEIN)) == HOUSEANIM_FLAGS_FADEIN2) {
GUI_Screen_FadeIn2(8, 24, 304, 120, SCREEN_1, SCREEN_0, 1, false);
} else if ((animation->flags & (HOUSEANIM_FLAGS_FADEIN2 | HOUSEANIM_FLAGS_FADEIN)) == HOUSEANIM_FLAGS_FADEIN) {
GUI_Screen_FadeIn(1, 24, 1, 24, 38, 120, SCREEN_1, SCREEN_0);
}
}

Expand Down Expand Up @@ -426,8 +427,8 @@ static void GameLoop_PlayAnimation(const HouseAnimation_Animation *animation)

if (mode == 1 && frame == frameCount) {
frame = 0;
} else {
if (mode == 3) frame--;
} else if (mode == 3) {
frame--;
}

if (Input_Keyboard_NextKey() != 0 && g_canSkipIntro) {
Expand All @@ -450,7 +451,7 @@ static void GameLoop_PlayAnimation(const HouseAnimation_Animation *animation)
} while (displayed);
}

if ((animation->flags & 0x10) != 0) {
if ((animation->flags & HOUSEANIM_FLAGS_FADETOWHITE) != 0) {
memset(&g_palette_998A[3 * 1], 63, 255 * 3);

memcpy(&g_palette_998A[215 * 3], s_palettePartCurrent, 18);
Expand All @@ -460,7 +461,7 @@ static void GameLoop_PlayAnimation(const HouseAnimation_Animation *animation)
memcpy(g_palette_998A, g_palette1, 256 * 3);
}

if ((animation->flags & 0x8) != 0) {
if ((animation->flags & HOUSEANIM_FLAGS_FADEOUTTEXT) != 0) {
GameLoop_PalettePart_Update(true);

memcpy(&g_palette_998A[215 * 3], s_palettePartCurrent, 18);
Expand Down
16 changes: 16 additions & 0 deletions src/house.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,22 @@ typedef struct HouseInfo {
const char *voiceFilename; /*!< Pointer to filename with the voices of the house. */
} HouseInfo;

/**
* HouseAnimation flags
* see GameLoop_PlayAnimation()
*/
#define HOUSEANIM_FLAGS_MODE0 0 /* no WSA, only text or voice */
#define HOUSEANIM_FLAGS_MODE1 1 /* WSA Looping */
#define HOUSEANIM_FLAGS_MODE2 2 /* WSA display from first to end frame*/
#define HOUSEANIM_FLAGS_MODE3 3 /* display WSA unique frame (frameCount field) */
#define HOUSEANIM_FLAGS_FADEINTEXT 0x04 /* fade in text at the beginning */
#define HOUSEANIM_FLAGS_FADEOUTTEXT 0x08 /* fade out text at the end */
#define HOUSEANIM_FLAGS_FADETOWHITE 0x10 /* Fade palette to all while at the end */
#define HOUSEANIM_FLAGS_POS0_0 0x20 /* Position (0,0) - default is (8,24) */
#define HOUSEANIM_FLAGS_DISPLAYFRAME 0x40 /* force display in frame buffer (not screen) */
#define HOUSEANIM_FLAGS_FADEIN2 0x80 /* */
#define HOUSEANIM_FLAGS_FADEIN 0x400 /* */

/**
* The information for a single animation frame in House Animation. It is part
* of an array that stops when duration is 0.
Expand Down
1 change: 1 addition & 0 deletions src/table/houseanimation.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "../house.h"
#include "strings.h"

/* TODO : use HOUSEANIM_FLAGS_* */
const HouseAnimation_Animation g_table_houseAnimation_animation[HOUSEANIMATION_MAX][32] = {
{ /* 0 - intro */
{ /* 0 */
Expand Down

0 comments on commit 30cbf7d

Please sign in to comment.