3 #include "screeneffect.h"
4 #include "screeneffect.fdh"
6 SE_FlashScreen flashscreen
;
7 SE_Starflash starflash
;
11 void c------------------------------() {}
14 // FlashScreen simply flashes the screen white several times,
15 // and is used in various places, such as when Misery casts spells.
16 void SE_FlashScreen::Start(void)
25 void SE_FlashScreen::Draw(void)
34 if (--flashes_left
<= 0)
40 ClearScreen(0xff, 0xff, 0xff);
44 void c------------------------------() {}
47 // Starflash is a full-screen white explosion in the shape of a '+',
48 // used when some bosses are defeated.
50 void SE_Starflash::Start(int x
, int y
)
52 sound(SND_EXPLOSION1
);
60 void SE_Starflash::Draw(void)
62 SE_Starflash
* const &star
= this;
63 int scr_x1
, scr_y1
, scr_x2
, scr_y2
;
67 { // flash getting bigger
68 star
->speed
+= (1 << CSF
);
69 star
->size
+= star
->speed
;
72 { // flash getting smaller
73 star
->size
-= (star
->size
>> 3);
83 rel_x
= (star
->centerx
- map
.displayed_xscroll
);
84 rel_y
= (star
->centery
- map
.displayed_yscroll
);
86 // draw a horizontal bar
87 scr_y1
= (rel_y
- star
->size
) >> CSF
;
88 scr_y2
= (rel_y
+ star
->size
) >> CSF
;
89 FillRect(0, scr_y1
, SCREEN_WIDTH
, scr_y2
, 255, 255, 255);
93 // draw a vertical bar
94 scr_x1
= (rel_x
- starflash
.size
) >> CSF
;
95 scr_x2
= (rel_x
+ starflash
.size
) >> CSF
;
96 FillRect(scr_x1
, 0, scr_x2
, SCREEN_HEIGHT
, 255, 255, 255);
98 // once it's big enough, switch to making it smaller
99 if (star
->size
> (1280<<CSF
))
101 star
->size
= (SCREEN_HEIGHT
<< CSF
);
108 void c------------------------------() {}
111 #define FADE_LAST_FRAME 15
113 // Fade is the fade-in/out used on every stage transistion/TRA.
114 // Unlike other effects, it is drawn underneath the textboxes and Nikumaru counter,
115 // and so isn't drawn from ScreenEffects::Draw().
123 // start a fade in or out.
124 // fadedir: either FADE_IN or FADE_OUT
125 // sweepdir: direction to "sweep" the fade
126 // spr: the sprite to use for the fading
127 void SE_Fade::Start(int fadedir
, int sweepdir
, int spr
)
129 if (fadedir
== FADE_OUT
)
131 // when fading out, the directions are reversed
134 case FADE_LEFT
: sweepdir
= FADE_RIGHT
; break;
135 case FADE_RIGHT
: sweepdir
= FADE_LEFT
; break;
136 case FADE_UP
: sweepdir
= FADE_DOWN
; break;
137 case FADE_DOWN
: sweepdir
= FADE_UP
; break;
146 fade
.fadedir
= fadedir
;
147 fade
.sweepdir
= sweepdir
;
148 fade
.curframe
= (fadedir
== FADE_OUT
) ? -FADE_LAST_FRAME
: FADE_LAST_FRAME
;
152 void SE_Fade::Draw(void)
156 #define DRAW_VCOLUMN \
160 if (frame > FADE_LAST_FRAME) frame = FADE_LAST_FRAME; \
162 for(y=0;y<SCREEN_HEIGHT;y+=16) \
163 draw_sprite(x, y, fade.sprite, frame); \
171 if (frame > FADE_LAST_FRAME) frame = FADE_LAST_FRAME; \
173 for(x=0;x<SCREEN_WIDTH;x+=16) \
174 draw_sprite(x, y, fade.sprite, frame); \
178 if (state
== FS_NO_FADE
)
182 else if (state
== FS_FADED_OUT
)
184 ClearScreen(DK_BLUE
);
188 int frame
= fade
.curframe
;
189 switch(fade
.sweepdir
)
191 case FADE_RIGHT
:for(x
=0;x
<SCREEN_WIDTH
;x
+=16) { DRAW_VCOLUMN
; frame
++; } break;
192 case FADE_LEFT
: for(x
=SCREEN_WIDTH
-1;x
>=-16;x
-=16) { DRAW_VCOLUMN
; frame
++; } break;
193 case FADE_DOWN
: for(y
=0;y
<SCREEN_HEIGHT
;y
+=16) { DRAW_HROW
; frame
++; } break;
194 case FADE_UP
: for(y
=SCREEN_HEIGHT
-1;y
>=-16;y
-=16) { DRAW_HROW
; frame
++; } break;
198 int startframe
= fade
.curframe
;
199 int centerx
= (SCREEN_WIDTH
/2)-8;
200 int centery
= (SCREEN_HEIGHT
/2)-8;
202 for(x
=0;x
<centerx
+16;x
+=16)
206 for(y
=0;y
<centery
+16;y
+=16)
210 if (frame
> FADE_LAST_FRAME
) frame
= FADE_LAST_FRAME
;
212 draw_sprite(centerx
+x
, centery
+y
, fade
.sprite
, frame
);
213 draw_sprite(centerx
-x
, centery
+y
, fade
.sprite
, frame
);
214 draw_sprite(centerx
+x
, centery
-y
, fade
.sprite
, frame
);
215 draw_sprite(centerx
-x
, centery
-y
, fade
.sprite
, frame
);
227 if (fade
.fadedir
== FADE_OUT
)
230 if (fade
.curframe
> FADE_LAST_FRAME
)
231 state
= FS_FADED_OUT
;
234 { // fading in--terminate fade when done
236 if (fade
.curframe
< -20)
244 void SE_Fade::set_full(int dir
)
248 state
= FS_FADED_OUT
;
250 fade
.fadedir
= FADE_OUT
;
251 fade
.sweepdir
= FADE_RIGHT
; // doesn't matter
252 fade
.curframe
= FADE_LAST_FRAME
;
253 fade
.sprite
= SPR_FADE_DIAMOND
;
262 int SE_Fade::getstate(void)
268 void c------------------------------() {}
271 void ScreenEffects::Draw(void)
273 if (starflash
.enabled
)
276 if (flashscreen
.enabled
)
280 void ScreenEffects::Stop()
282 starflash
.enabled
= false;
283 flashscreen
.enabled
= false;