SBSPSS/source/gfx/fader.cpp

267 lines
5.0 KiB
C++
Raw Normal View History

2000-11-20 16:31:03 +01:00
/*=========================================================================
fader.cpp
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2000 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
#include "fader.h"
#ifndef __PRIM_HEADER__
#include "gfx\prim.h"
#endif
#ifndef __GFX_BUBICLES_H__
#include "gfx\bubicles.h"
#endif
2001-01-03 21:43:49 +01:00
#ifndef __SOUND_SOUND_H__
#include "sound\sound.h"
#endif
2001-06-21 21:19:15 +02:00
#include "system\vid.h"
2001-08-14 14:57:28 +02:00
#include "pad\vibe.h"
2000-11-20 16:31:03 +01:00
/* Std Lib
------- */
/* Data
---- */
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
CFader::FADE_MODE CFader::s_fadeMode=FADED_IN;
2001-01-11 21:26:42 +01:00
CFader::FADE_STYLE CFader::s_fadeStyle;
2001-06-21 00:57:27 +02:00
int CFader::s_fadeValue=0;
int CFader::s_waitFrames=0;
2000-11-20 16:31:03 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFader::render()
{
2001-08-23 17:30:32 +02:00
int TMode;
TPOLY_F4 *f4;
TMode=(s_fadeStyle==BLACK_FADE?2:1);
2000-11-20 16:31:03 +01:00
switch(s_fadeMode)
{
case FADED_IN:
return;
2001-07-13 16:55:52 +02:00
case PAUSE_BEFORE_FADING_IN:
2000-11-20 16:31:03 +01:00
case FADING_IN:
{
2001-01-11 21:26:42 +01:00
switch(s_fadeStyle)
2000-11-20 16:31:03 +01:00
{
2001-01-11 21:26:42 +01:00
case BLACK_FADE:
2001-04-02 17:48:02 +02:00
case WHITE_FADE:
2001-01-11 21:26:42 +01:00
{
2001-08-23 17:30:32 +02:00
f4=GetPrimTF4();
2001-07-05 23:26:39 +02:00
setXYWH(f4,0,0,VidGetScrW()+1,VidGetScrH()+1);
2001-01-11 21:26:42 +01:00
setRGB0(f4,s_fadeValue,s_fadeValue,s_fadeValue);
2001-08-23 17:30:32 +02:00
setTShadeTex(f4,0);
setTSemiTrans(f4,1);
setTABRMode(f4,TMode);
2001-01-11 21:26:42 +01:00
AddPrimToList(f4,0);
break;
}
2000-11-20 16:31:03 +01:00
}
}
break;
case FADING_OUT:
2001-06-21 00:57:27 +02:00
case PAUSE_AFTER_FADING_OUT:
2000-11-20 16:31:03 +01:00
{
2001-01-11 21:26:42 +01:00
switch(s_fadeStyle)
{
case BLACK_FADE:
2001-04-02 17:48:02 +02:00
case WHITE_FADE:
2001-01-11 21:26:42 +01:00
{
int col;
col=255-s_fadeValue;
2001-08-23 17:30:32 +02:00
f4=GetPrimTF4();
2001-07-05 23:26:39 +02:00
setXYWH(f4,0,0,VidGetScrW()+1,VidGetScrH()+1);
2001-01-11 21:26:42 +01:00
setRGB0(f4,col,col,col);
2001-08-23 17:30:32 +02:00
setTShadeTex(f4,0);
setTSemiTrans(f4,1);
setTABRMode(f4,TMode);
2001-01-11 21:26:42 +01:00
AddPrimToList(f4,0);
break;
}
}
2000-11-20 16:31:03 +01:00
}
break;
case FADED_OUT:
{
2001-08-23 17:30:32 +02:00
f4=GetPrimTF4();
2001-07-05 23:26:39 +02:00
setXYWH(f4,0,0,VidGetScrW()+1,VidGetScrH());
2001-01-11 21:26:42 +01:00
switch(s_fadeStyle)
{
case BLACK_FADE:
setRGB0(f4,0,0,0);
break;
2001-04-02 17:48:02 +02:00
case WHITE_FADE:
setRGB0(f4,255,255,255);
break;
2001-01-11 21:26:42 +01:00
}
AddPrimToList(f4,0);
2000-11-20 16:31:03 +01:00
return;
}
}
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFader::think(int _frames)
{
2001-06-21 00:57:27 +02:00
switch(s_fadeMode)
{
case FADING_IN:
case FADING_OUT:
s_fadeValue-=_frames*FADE_SPEED;
switch(s_fadeStyle)
2001-01-03 21:43:49 +01:00
{
2001-06-21 00:57:27 +02:00
case BLACK_FADE:
case WHITE_FADE:
2001-01-11 21:26:42 +01:00
{
2001-06-21 00:57:27 +02:00
if(s_fadeValue<0)
2001-01-11 21:26:42 +01:00
{
2001-06-21 00:57:27 +02:00
s_fadeValue=0;
if(s_fadeMode==FADING_OUT)
{
s_waitFrames=FRAMES_TO_WAIT;
2001-07-13 16:55:52 +02:00
s_fadeMode=PAUSE_AFTER_FADING_OUT;
CSoundMediator::setVolume(CSoundMediator::VOL_FADE,0);
2001-06-21 00:57:27 +02:00
}
else
{
s_fadeMode=FADED_IN;
CSoundMediator::setVolume(CSoundMediator::VOL_FADE,255);
}
2001-01-11 21:26:42 +01:00
}
else
{
CSoundMediator::setVolume(CSoundMediator::VOL_FADE,s_fadeMode==FADING_OUT?s_fadeValue:255-s_fadeValue);
}
2001-06-21 00:57:27 +02:00
break;
2001-01-11 21:26:42 +01:00
}
2001-01-03 21:43:49 +01:00
}
2001-06-21 00:57:27 +02:00
break;
2001-01-11 21:26:42 +01:00
2001-06-21 00:57:27 +02:00
case PAUSE_BEFORE_FADING_IN:
if(--s_waitFrames==0)
2001-01-03 21:43:49 +01:00
{
2001-07-13 16:55:52 +02:00
s_fadeMode=FADING_IN;
2001-06-21 00:57:27 +02:00
}
break;
case PAUSE_AFTER_FADING_OUT:
if(--s_waitFrames==0)
{
2001-07-13 16:55:52 +02:00
s_fadeMode=FADED_OUT;
2001-06-21 00:57:27 +02:00
}
break;
default:
break;
2000-11-20 16:31:03 +01:00
}
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-01-11 21:26:42 +01:00
void CFader::setFadingOut(FADE_STYLE _style)
2000-11-20 16:31:03 +01:00
{
2001-01-11 21:26:42 +01:00
switch(_style)
{
case BLACK_FADE:
2001-04-02 17:48:02 +02:00
case WHITE_FADE:
2001-01-11 21:26:42 +01:00
s_fadeValue=255;
break;
}
2001-07-13 16:55:52 +02:00
2000-11-20 16:31:03 +01:00
s_fadeMode=FADING_OUT;
2001-01-11 21:26:42 +01:00
s_fadeStyle=_style;
2001-06-21 00:57:27 +02:00
s_waitFrames=FRAMES_TO_WAIT;
2001-08-14 14:57:28 +02:00
CPadVibrationManager::stopAllVibration();
2000-11-20 16:31:03 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-01-11 21:26:42 +01:00
void CFader::setFadingIn(FADE_STYLE _style)
2000-11-20 16:31:03 +01:00
{
2001-01-11 21:26:42 +01:00
switch(_style)
{
case BLACK_FADE:
2001-04-02 17:48:02 +02:00
case WHITE_FADE:
2001-01-11 21:26:42 +01:00
s_fadeValue=255;
break;
}
s_fadeStyle=_style;
2001-07-13 16:55:52 +02:00
s_fadeMode=PAUSE_BEFORE_FADING_IN;
2001-06-21 00:57:27 +02:00
s_waitFrames=FRAMES_TO_WAIT;
2001-08-14 14:57:28 +02:00
CPadVibrationManager::stopAllVibration();
2000-11-20 16:31:03 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
int CFader::isFading()
{
2001-07-13 16:55:52 +02:00
return s_fadeMode!=FADED_IN&&s_fadeMode!=FADED_OUT;
2000-11-20 16:31:03 +01:00
}
/*===========================================================================
end */