12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214 |
- #include "RSPiX.h"
- #include "cutscene.h"
- #include "game.h"
- #include "update.h"
- #include "SampleMaster.h"
- #include "AlphaAnimType.h"
- #define FONT_FILE "res/fonts/smash.fnt"
- #define DEFAULT_TITLE "Loading..."
- #define DEFAULT_BG "res/cutscene/abstract.bmp"
- #define DEFAULT_TEXT ""
- #define DEFAULT_MULTIALPHA "res/cutscene/abstract.mlp"
- #define DEFAULT_MUSIC "psychedelic1.wav"
- #define BG_X (ms_pCut->m_pimDst->m_sWidth / 2 - ms_pCut->m_pimBGLayer->m_sWidth / 2)
- #define BG_Y (ms_pCut->m_pimDst->m_sHeight / 2 - ms_pCut->m_pimBGLayer->m_sHeight / 2)
- #define NAME_Y 85
- #define TEXT_Y (280 - 48)
- #define MARGIN 24
- #define BLOOD_FORE_R 128
- #define BLOOD_FORE_G 0
- #define BLOOD_FORE_B 0
- #define FONT_FORE_R 255
- #define FONT_FORE_G 0
- #define FONT_FORE_B 0
- #define FONT_SHAD_R 0
- #define FONT_SHAD_G 0
- #define FONT_SHAD_B 0
- #define PROGRESS_BAR_START_X 165
- #define PROGRESS_BAR_START_Y 460
- #define PROGRESS_BAR_WIDTH 310
- #define PROGRESS_BAR_RANDOM_X 7
- #define PROGRESS_BAR_RANDOM_Y 2
- #define PROGRESS_BAR_DENSITY 10
- #define PROGRESS_BAR_UPDATE_TIME 250
- #define PROGRESS_BOX_X 96
- #define PROGRESS_BOX_Y 440
- #define PROGRESS_BOX_WIDTH 448
- #define PROGRESS_BOX_HEIGHT 40
- #define RandomPlusMinus(x) ((MyRandom() % (((x) + 1) * 2)) - (x))
- #define NUM_ELEMENTS(a) (sizeof(a) / sizeof(a[0]) )
- static int ms_lRandom;
- inline void MySeedRandom(long seed)
- {
- ms_lRandom = seed;
- }
- inline long MyRandom(void)
- {
- return (((ms_lRandom = ms_lRandom * 214013L + 2531011L) >> 16) & 0x7fff);
- }
- class CCutSceneInfo
- {
- public:
-
- RFont* m_pFont;
- char m_szTitle[256];
- char m_szText[4096];
- char m_szMusic[RSP_MAX_PATH];
- UCHAR m_ucForeText;
- UCHAR m_ucShadowText;
- RImage* m_pimBGLayer;
- RImage* m_pimTextLayer;
- RImage* m_pimDst;
- RMultiAlpha* m_pmaAlpha;
- bool m_bDeleteFont;
- short m_sDelW;
- short m_sDelH;
- long m_lTotalBytes;
- long m_lTimeToUpdate;
- long m_lBytesSoFar;
- U8 m_u8BloodColor;
- short m_sLastDistance;
- SampleMasterID m_musicID;
-
- void Clear()
- {
- m_pFont = NULL;
- m_szTitle[0] = 0;
- m_szText[0] = 0;
- m_szMusic[0] = 0;
- m_ucForeText = 0;
- m_ucShadowText = 0;
- m_pimBGLayer = NULL;
- m_pimTextLayer = NULL;
- m_pimDst = NULL;
- m_pmaAlpha = NULL;
- m_bDeleteFont = true;
- m_sDelW = 0;
- m_sDelH = 0;
- m_lTotalBytes = 0;
- m_lTimeToUpdate = 0;
- m_lBytesSoFar = 0;
- m_u8BloodColor = 0;
- m_sLastDistance = 0;
- m_musicID = g_smidNil;
- }
- CCutSceneInfo()
- {
- Clear();
- }
- ~CCutSceneInfo()
- {
- if (m_bDeleteFont && m_pFont) delete m_pFont;
- if (m_pimBGLayer) delete m_pimBGLayer;
- if (m_pimTextLayer) delete m_pimTextLayer;
- if (m_pmaAlpha) delete m_pmaAlpha;
- Clear();
- }
- };
- short MartiniDo( RImage* pimBackground,
- short sStartX,
- short sStartY,
- RMultiAlpha* pAlpha,
- long lMilliLen,
- short sRadius,
- long lSpinTime,
- long lSwayTime,
- RRect* prCenter,
- long lFadeTime,
- SampleMaster::SoundInstance siFade
- )
- {
-
- RImage imSwirl;
- rspGeneralLock(pimBackground);
- if (prCenter)
- {
-
- imSwirl.CreateImage(prCenter->sW,prCenter->sH,RImage::BMP8);
- rspBlit(pimBackground,&imSwirl,
- prCenter->sX,prCenter->sY,0,0,
- prCenter->sW,prCenter->sH);
- sStartX += prCenter->sX;
- sStartY += prCenter->sY;
- }
- else
- {
- imSwirl.CreateImage(pimBackground->m_sWidth,pimBackground->m_sHeight,RImage::BMP8);
- rspBlit(pimBackground,&imSwirl,0,0,0,0,pimBackground->m_sWidth,pimBackground->m_sHeight);
- }
- rspGeneralUnlock(pimBackground);
- rspLockBuffer();
- rspRect(RSP_BLACK_INDEX,g_pimScreenBuf,0,0,g_pimScreenBuf->m_sWidth,g_pimScreenBuf->m_sHeight);
- rspUnlockBuffer();
-
-
- RRect rClip(sStartX,sStartY,imSwirl.m_sWidth,imSwirl.m_sHeight);
-
- rClip.sX += sRadius;
- rClip.sY += sRadius;
- rClip.sW -= sRadius<<1;
- rClip.sH -= sRadius<<1;
-
-
- UCHAR PaletteCopy[256 * 3] = {0,};
- rspGetPaletteEntries(10,236,PaletteCopy+30,PaletteCopy + 31,PaletteCopy + 32,3);
- long lStartTime = rspGetMilliseconds();
- long lCurrentTime = -1;
- long lStartFadeTime = lMilliLen - lFadeTime;
-
- while (((lCurrentTime = (rspGetMilliseconds() - lStartTime)) < lMilliLen) && !(rspGetQuitStatus()))
- {
- long lCurrentFadeTime = lCurrentTime - lStartFadeTime;
-
-
-
- short sDeg = short((360 * lCurrentTime)/lSpinTime);
- sDeg = rspMod360(sDeg);
- short sSwayDeg = short((360 * lCurrentTime)/lSwayTime);
- sSwayDeg = rspMod360(sSwayDeg);
-
- short sR = short(sRadius * rspSin(sSwayDeg));
- short sOffX = short(rspCos(sDeg) * sR);
- short sOffY = short(rspSin(sDeg) * sR);
-
-
- rspLockBuffer();
-
- rspBlit(&imSwirl,g_pimScreenBuf,0,0,sStartX + sOffX,sStartY + sOffY,
- imSwirl.m_sWidth,imSwirl.m_sHeight,&rClip);
-
- rspAlphaBlitT(128,pAlpha,&imSwirl,g_pimScreenBuf,
- sStartX - sOffX,sStartY - sOffY,&rClip);
- rspUnlockBuffer();
- rspUpdateDisplay();
-
-
- if (lCurrentFadeTime > 0)
- {
-
- short i=0;
- short sCurPal = 10 * 3;
- short sByteLevel = short((255.0 * lCurrentFadeTime) / lFadeTime);
- for (i=10; i < 246; i++, sCurPal += 3)
- {
- rspSetPaletteEntry( i,
- (PaletteCopy[sCurPal + 0] * (256 - sByteLevel)) / 256,
- (PaletteCopy[sCurPal + 1] * (256 - sByteLevel)) / 256,
- (PaletteCopy[sCurPal + 2] * (256 - sByteLevel)) / 256
- );
- }
- rspUpdatePalette();
- if (siFade)
- {
- SetInstanceVolume(siFade,255 - sByteLevel);
- }
- }
-
- UpdateSystem();
- }
-
-
-
- rspLockBuffer();
- rspRect(RSP_BLACK_INDEX,g_pimScreenBuf,0,0,g_pimScreenBuf->m_sWidth,g_pimScreenBuf->m_sHeight);
- rspUpdateDisplay();
- rspUnlockBuffer();
- return SUCCESS;
- }
- class CSwirlMe
- {
- public:
-
- short m_sCenX;
- short m_sRadX;
- short m_sCenY;
- short m_sRadY;
- double m_dCenA;
- double m_dRadA;
- long m_lCycleTimeX;
- long m_lCycleTimeY;
- long m_lCycleTimeA;
- long m_lTimeSpin;
- long m_lBaseTime;
- RRect m_rClip;
- SampleMaster::SoundInstance m_siSound;
- CCutSceneInfo* m_pCut;
-
-
-
-
- short MakeFrame(SampleMasterID* psmid)
- {
- if (!IsSamplePlaying(*psmid))
- {
- PlaySample(
-
- *psmid,
- SampleMaster::Unspecified,
- 255,
- &m_siSound,
- NULL,
- 0,
-
-
- 0,
-
- true);
- }
- if (!m_lBaseTime) m_lBaseTime = rspGetMilliseconds();
- long lDeltaTime = rspGetMilliseconds() - m_lBaseTime;
- short sDegX = (360 * lDeltaTime) / m_lCycleTimeX;
- short sDegY = (360 * lDeltaTime) / m_lCycleTimeY;
- short sDegAlpha = (360 * lDeltaTime) / m_lCycleTimeA;
- short sDegSpin = (360 * lDeltaTime) / m_lTimeSpin;
- sDegX = rspMod360(sDegX);
- sDegY = rspMod360(sDegY);
- sDegAlpha = rspMod360(sDegAlpha);
- sDegSpin = rspMod360(sDegSpin);
- short sRx = m_sCenX + short(rspSin(sDegX) * m_sRadX);
- short sRy = m_sCenY + short(rspSin(sDegY) * m_sRadY);
- if (sRx < 0) sRx = 0;
- if (sRy < 0) sRy = 0;
- short sOffX = short(rspCos(sDegSpin) * sRx);
- short sOffY = -short(rspSin(sDegSpin) * sRy);
- sOffX >>= 1;
- sOffY >>= 1;
- double dAlpha = m_dCenA + rspSin(sDegAlpha) * m_dRadA;
-
- RRect rSafeClip = m_rClip;
- rSafeClip.sX += m_sRadX;
- rSafeClip.sY += m_sRadY;
- rSafeClip.sW -= (m_sRadX<<1);
- rSafeClip.sH -= (m_sRadY<<1);
- rSafeClip.sY += 40;
- rSafeClip.sH -= 80;
-
- if (m_pCut->m_pimBGLayer)
- {
- rspLockBuffer();
- rspBlit(m_pCut->m_pimBGLayer,m_pCut->m_pimDst,0,0,m_rClip.sX - sOffX,m_rClip.sY - sOffY,
- m_rClip.sW,m_rClip.sH,&rSafeClip);
-
- if (m_pCut->m_pmaAlpha != NULL)
- {
- rspAlphaBlitT(short(255.9*dAlpha),m_pCut->m_pmaAlpha,m_pCut->m_pimBGLayer,m_pCut->m_pimDst,
- m_rClip.sX + sOffX,m_rClip.sY + sOffY,&rSafeClip);
- }
-
- rspBlit(m_pCut->m_pimTextLayer,m_pCut->m_pimDst,0,0);
-
-
- rspUnlockBuffer();
- }
- return SUCCESS;
- }
-
-
-
- short Configure(
- long lTimeSpin,
- short sMinX,short sMaxX,long lTimeX,
- short sMinY,short sMaxY,long lTimeY,
- double dMinA,double dMaxA,long lTimeA,
- short sX,short sY,short sW,short sH)
- {
- ASSERT(m_pCut);
- ASSERT(lTimeX > 0);
- ASSERT(lTimeY > 0);
- ASSERT(lTimeA > 0);
- ASSERT(lTimeSpin > 0);
- ASSERT((dMinA >= 0.0) && (dMinA <= 1.0));
- ASSERT((dMaxA >= 0.0) && (dMaxA <= 1.0));
- ASSERT(sW > 0);
- ASSERT(sH> 0);
-
- m_sRadX = (sMaxX - sMinX)>>1;
- m_sCenX = sMinX + m_sRadX;
- m_sRadY = (sMaxY - sMinY)>>1;
- m_sCenY = sMinY + m_sRadY;
- m_dRadA = (dMaxA - dMinA)/2.0;
- m_dCenA = dMinA + m_dRadA;
- m_lCycleTimeX = lTimeX;
- m_lCycleTimeY = lTimeY;
- m_lCycleTimeA = lTimeA;
- m_lTimeSpin = lTimeSpin;
-
- if (m_pCut->m_pimBGLayer)
- {
- m_pCut->m_sDelW = m_pCut->m_pimDst->m_sWidth - m_pCut->m_pimBGLayer->m_sWidth;
- m_pCut->m_sDelH = m_pCut->m_pimDst->m_sHeight - m_pCut->m_pimBGLayer->m_sHeight;
- }
- else
- {
- m_pCut->m_sDelW = 0;
- m_pCut->m_sDelH = 0;
- }
- m_rClip.sX = sX + (m_pCut->m_sDelW >> 1);
- m_rClip.sY = sY + (m_pCut->m_sDelH >> 1);
- m_rClip.sW = sW - m_pCut->m_sDelW;
- m_rClip.sH = sH - m_pCut->m_sDelH;
- rspLockBuffer();
- rspRect(RSP_BLACK_INDEX,m_pCut->m_pimDst,0,0,m_pCut->m_pimDst->m_sWidth,m_pCut->m_pimDst->m_sHeight);
- rspUnlockBuffer();
- m_lBaseTime = 0;
- return SUCCESS;
- }
-
-
-
- void Erase()
- {
- m_sCenX = m_sCenY = m_sRadX = m_sRadY =
- m_lTimeSpin = m_lCycleTimeX = m_lCycleTimeY = m_lCycleTimeA = 0;
- m_dCenA = m_dRadA = 0.0;
- m_rClip = RRect(0,0,0,0);
- m_siSound = NULL;
- }
-
-
-
- CSwirlMe(
- CCutSceneInfo* pCut)
- {
- m_pCut = pCut;
- Erase();
- }
-
-
-
- ~CSwirlMe()
- {
- if (m_siSound != 0) AbortSample(m_siSound);
- m_siSound = 0;
- m_pCut = NULL;
- }
-
-
-
- void Update()
- {
- rspUpdateDisplay(m_rClip.sX,m_rClip.sY,m_rClip.sW,m_rClip.sH);
- }
-
-
-
- void Clear()
- {
-
- Erase();
- }
- };
- static CCutSceneInfo* ms_pCut = NULL;
- static CSwirlMe* pSwirl = NULL;
- static void CutScene_RFileCallback(long lBytes);
- extern void CutSceneStart(
- bool bSimple,
- const RString* pstrSection,
- const RString* pstrEntry,
- short sBorderX,
- short sBorderY)
- {
-
- char szText[2048];
-
- ms_pCut = new CCutSceneInfo;
- ms_pCut->m_pimDst = g_pimScreenBuf;
-
- rspLockBuffer();
- rspRect(RSP_BLACK_INDEX, ms_pCut->m_pimDst, 0, 0, ms_pCut->m_pimDst->m_sWidth, ms_pCut->m_pimDst->m_sHeight);
- rspUnlockBuffer();
- rspUpdateDisplay();
-
- RPrefs prefsRealm;
- if (prefsRealm.Open(FullPathHD(g_GameSettings.m_pszRealmPrefsFile), "rt") != 0)
- {
- TRACE("CutSceneStart(): Error opening prefs file.\n");
- return ;
- }
-
-
-
-
- if (bSimple)
- {
- strcpy(szText, DEFAULT_BG);
- }
- else
- {
- prefsRealm.GetVal(*pstrSection, "Bg", DEFAULT_BG, szText);
- if ((strlen(szText) + 1) >= RSP_MAX_PATH)
- {
- TRACE("CutScene(): Bg file name/path too long: '%s'!\n", szText);
- strcpy(szText, DEFAULT_BG);
- }
- }
-
- ms_pCut->m_pimBGLayer = new RImage;
- if ((ms_pCut->m_pimBGLayer->Load(FullPathHD(szText)) == 0) ||
- (ms_pCut->m_pimBGLayer->Load(FullPathVD(szText)) == 0))
- {
-
- ASSERT(ms_pCut->m_pimBGLayer->m_pPalette != NULL);
- ASSERT(ms_pCut->m_pimBGLayer->m_pPalette->m_type == RPal::PDIB);
- rspSetPaletteEntries(
- 0, 256, ms_pCut->m_pimBGLayer->m_pPalette->Red(0),
- ms_pCut->m_pimBGLayer->m_pPalette->Green(0),
- ms_pCut->m_pimBGLayer->m_pPalette->Blue(0),
- ms_pCut->m_pimBGLayer->m_pPalette->m_sPalEntrySize);
- rspUpdatePalette();
- }
- else
- {
- TRACE("CutScene(): Error loading bg image: '%s'\n", FullPathVD(szText));
- delete ms_pCut->m_pimBGLayer;
- ms_pCut->m_pimBGLayer = NULL;
- }
-
-
-
- U8 au8Red[256];
- U8 au8Green[256];
- U8 au8Blue[256];
- rspGetPaletteEntries(0, 256, au8Red, au8Green, au8Blue, sizeof(U8));
-
-
-
- ms_pCut->m_pmaAlpha = new RMultiAlpha;
- prefsRealm.GetVal(*pstrSection, "Alpha", DEFAULT_MULTIALPHA, szText);
- if ((ms_pCut->m_pmaAlpha->Load(FullPathHD(szText)) == 0) ||
- (ms_pCut->m_pmaAlpha->Load(FullPathVD(szText)) == 0))
- {
- }
- else
- {
- TRACE("CutScene(): Error loading multialpha: '%s'\n", FullPathVD(szText));
- delete ms_pCut->m_pmaAlpha;
- ms_pCut->m_pmaAlpha = NULL;
- }
-
-
-
-
- ms_pCut->m_bDeleteFont = true;
- ms_pCut->m_pFont = new RFont;
- if (ms_pCut->m_pFont->Load(FullPathVD(FONT_FILE)) != SUCCESS)
- {
- TRACE("CutScene(): Error loading font: '%s'!\n", FullPathVD(FONT_FILE));
- delete ms_pCut->m_pFont;
- ms_pCut->m_pFont = &g_fontBig;
- ms_pCut->m_bDeleteFont = false;
- }
-
- ms_pCut->m_ucForeText = rspMatchColorRGB(
- FONT_FORE_R, FONT_FORE_G, FONT_FORE_B, 10, 236, au8Red, au8Green, au8Blue, sizeof(U8));
- ms_pCut->m_ucShadowText = rspMatchColorRGB(
- FONT_SHAD_R, FONT_SHAD_G, FONT_SHAD_B, 10, 236, au8Red, au8Green, au8Blue, sizeof(U8));
-
- RPrint print;
-
-
-
-
- if (bSimple)
- {
- strcpy(ms_pCut->m_szTitle, DEFAULT_TITLE);
- }
- else
- {
- prefsRealm.GetVal(*pstrSection, "Title", DEFAULT_TITLE, ms_pCut->m_szTitle);
- if ((strlen(ms_pCut->m_szTitle) + 1) >= sizeof(ms_pCut->m_szTitle))
- {
- TRACE("CutScene(): Title too long: '%s'!\n", ms_pCut->m_szTitle);
- strcpy(ms_pCut->m_szTitle, DEFAULT_TITLE);
- }
- }
-
-
-
-
- if (bSimple)
- {
- strcpy(ms_pCut->m_szMusic, DEFAULT_MUSIC);
- }
- else
- {
- prefsRealm.GetVal(*pstrSection, "Music", DEFAULT_MUSIC, ms_pCut->m_szMusic);
- if ((strlen(ms_pCut->m_szMusic) + 1) >= sizeof(ms_pCut->m_szMusic))
- {
- TRACE("CutScene(): Music filename too long: '%s'!\n", ms_pCut->m_szMusic);
- strcpy(ms_pCut->m_szMusic, DEFAULT_MUSIC);
- }
- }
-
- ms_pCut->m_musicID.pszId = ms_pCut->m_szMusic;
- ms_pCut->m_musicID.usDescFlags = SMDF_NO_DESCRIPT;
-
-
-
-
- ms_pCut->m_pimTextLayer = new RImage;
- ms_pCut->m_pimTextLayer->CreateImage(ms_pCut->m_pimDst->m_sWidth,ms_pCut->m_pimDst->m_sHeight,RImage::BMP8);
-
- print.SetDestination(ms_pCut->m_pimTextLayer);
- print.SetFont(48, ms_pCut->m_pFont);
- print.SetColor(ms_pCut->m_ucForeText, 0, ms_pCut->m_ucShadowText);
- print.SetEffectAbs(RPrint::SHADOW_X, 2);
- print.SetEffectAbs(RPrint::SHADOW_Y, 2);
- print.print(((ms_pCut->m_pimTextLayer->m_sWidth - print.GetWidth(ms_pCut->m_szTitle)) / 2),
- NAME_Y, ms_pCut->m_szTitle);
-
- if (bSimple)
- {
- strcpy(ms_pCut->m_szText, DEFAULT_TEXT);
- }
- else
- {
- prefsRealm.GetVal(*pstrSection, "Text", DEFAULT_TEXT, ms_pCut->m_szText);
- if ((strlen(ms_pCut->m_szText) + 1) >= sizeof(ms_pCut->m_szText))
- {
- TRACE("CutScene(): Text too long: '%s'!\n", ms_pCut->m_szText);
- strcpy(ms_pCut->m_szText, DEFAULT_TEXT);
- }
- }
-
-
- RRect rCrop;
- if (ms_pCut->m_pimBGLayer)
- {
- rCrop = RRect(
- BG_X + sBorderX,
- BG_Y + sBorderY + 40,
- ms_pCut->m_pimBGLayer->m_sWidth - (sBorderX * 2),
- ms_pCut->m_pimBGLayer->m_sHeight - (sBorderY * 2) - 80);
- }
- else
- {
- rCrop.sX = 0;
- rCrop.sY = 0;
- rCrop.sW = g_pimScreenBuf->m_sWidth - (sBorderX * 2);
- rCrop.sH = g_pimScreenBuf->m_sHeight - (sBorderY * 2) - 80;
- }
-
- print.SetFont(28, ms_pCut->m_pFont);
- print.SetColor(ms_pCut->m_ucForeText, 0, ms_pCut->m_ucShadowText);
- print.SetEffectAbs(RPrint::SHADOW_X, 1);
- print.SetEffectAbs(RPrint::SHADOW_Y, 1);
- print.SetWordWrap(TRUE);
- print.SetColumn(rCrop.sX + MARGIN, rCrop.sY, rCrop.sW - (MARGIN*2), rCrop.sH);
- print.print(0, TEXT_Y, ms_pCut->m_szText);
- ms_pCut->m_pimTextLayer->Convert(RImage::FSPR8);
-
-
-
-
- rspLockBuffer();
-
- rspRect(
- RSP_BLACK_INDEX,
- ms_pCut->m_pimDst,
- 0, 0,
- ms_pCut->m_pimDst->m_sWidth, ms_pCut->m_pimDst->m_sHeight);
- if (ms_pCut->m_pimBGLayer)
- {
-
- rspBlit(
- ms_pCut->m_pimBGLayer,
- ms_pCut->m_pimDst,
- 0, 0,
- BG_X, BG_Y,
- ms_pCut->m_pimBGLayer->m_sWidth, ms_pCut->m_pimBGLayer->m_sHeight,
- &rCrop);
- RRect rcBGClipper(
- 0,
- 0,
- ms_pCut->m_pimBGLayer->m_sWidth,
- ms_pCut->m_pimBGLayer->m_sHeight);
-
-
- rspBlit(
- ms_pCut->m_pimBGLayer,
- ms_pCut->m_pimDst,
- PROGRESS_BOX_X, PROGRESS_BOX_Y,
- PROGRESS_BOX_X, PROGRESS_BOX_Y,
- PROGRESS_BOX_WIDTH, PROGRESS_BOX_HEIGHT,
- NULL,
- &rcBGClipper);
- }
-
- rspBlit(
- ms_pCut->m_pimTextLayer,
- ms_pCut->m_pimDst,
- 0, 0,
- &rCrop);
-
- rspUnlockBuffer();
-
- rspUpdateDisplay();
-
-
-
- prefsRealm.Close();
-
-
-
-
- RFile::ms_criticall = CutScene_RFileCallback;
-
- ms_pCut->m_lBytesSoFar = 0;
- ms_pCut->m_lTotalBytes = 12000000;
- ms_pCut->m_lTimeToUpdate = rspGetMilliseconds();
- ms_pCut->m_sLastDistance = 0;
-
- ms_pCut->m_u8BloodColor = rspMatchColorRGB(
- BLOOD_FORE_R, BLOOD_FORE_G, BLOOD_FORE_B, 1, 254, au8Red, au8Green, au8Blue, sizeof(U8));
- }
- extern short CutSceneConfig(
- long lTimeSpin,
- short sMinX,short sMaxX,long lTimeX,
- short sMinY,short sMaxY,long lTimeY,
- double dMinA,double dMaxA,long lTimeA,
- short sX,short sY,short sW,short sH)
- {
- ASSERT(ms_pCut);
- pSwirl = new CSwirlMe(ms_pCut);
- if (ms_pCut->m_pimBGLayer)
- {
-
-
-
-
-
-
- rspRect(
- *(ms_pCut->m_pimBGLayer->m_pData),
- ms_pCut->m_pimBGLayer,
- PROGRESS_BOX_X, PROGRESS_BOX_Y,
- PROGRESS_BOX_WIDTH, PROGRESS_BOX_HEIGHT);
- RRect rcBGClipper(
- 0,
- 0,
- ms_pCut->m_pimBGLayer->m_sWidth,
- ms_pCut->m_pimBGLayer->m_sHeight);
- rspLockBuffer();
-
-
- rspBlit(
- ms_pCut->m_pimBGLayer,
- ms_pCut->m_pimDst,
- PROGRESS_BOX_X, PROGRESS_BOX_Y,
- PROGRESS_BOX_X, PROGRESS_BOX_Y,
- PROGRESS_BOX_WIDTH, PROGRESS_BOX_HEIGHT,
- NULL,
- &rcBGClipper);
- rspUnlockBuffer();
- rspUpdateDisplay(PROGRESS_BOX_X, PROGRESS_BOX_Y, PROGRESS_BOX_WIDTH, PROGRESS_BOX_HEIGHT);
- }
-
- RFile::ms_criticall = 0;
- return pSwirl->Configure(
- lTimeSpin,
- sMinX, sMaxX, lTimeX,
- sMinY, sMaxY, lTimeY,
- dMinA, dMaxA, lTimeA,
- sX, sY, sW, sH);
- }
- extern void CutSceneUpdate(void)
- {
- ASSERT(ms_pCut);
- ASSERT(pSwirl);
- pSwirl->MakeFrame(&(ms_pCut->m_musicID));
- pSwirl->Update();
- }
- extern void CutSceneEnd(void)
- {
- delete ms_pCut;
- ms_pCut = 0;
- delete pSwirl;
- pSwirl = 0;
-
- RFile::ms_criticall = 0;
- }
- static void CutScene_RFileCallback(long lBytes)
- {
- static short asWavyY[] =
- {
- 0, 1, 2, 0, -2, -1, 1, 0, -1, 0, 1, 2, 1, 0,
- 1, 0, -1, -2, -1, -2, 0, 1, 2, 0, -2, -1, 0, 0
- };
- if (ms_pCut)
- {
- if (ms_pCut->m_pimBGLayer && ms_pCut->m_pmaAlpha)
- {
- if (ms_pCut->m_pimBGLayer->m_type != RImage::NOT_SUPPORTED)
- {
-
- ms_pCut->m_lBytesSoFar += lBytes;
-
- long lNow = rspGetMilliseconds();
- if ((lNow - ms_pCut->m_lTimeToUpdate) > PROGRESS_BAR_UPDATE_TIME)
- {
-
- double dPercentage = (double)ms_pCut->m_lBytesSoFar / (double)ms_pCut->m_lTotalBytes;
- if (dPercentage > 1.0)
- dPercentage = 1.0;
- short sDistance = (short)((double)PROGRESS_BAR_WIDTH * dPercentage);
- short sBaseY = asWavyY[(short)(dPercentage * (NUM_ELEMENTS(asWavyY) - 1) )];
-
-
- for (short sBaseX = ms_pCut->m_sLastDistance; sBaseX <= sDistance; sBaseX++)
- {
-
- for (short i = 0; i < PROGRESS_BAR_DENSITY; i++)
- {
-
- short sX = PROGRESS_BAR_START_X + sBaseX + RandomPlusMinus(PROGRESS_BAR_RANDOM_X);
- short sY = PROGRESS_BAR_START_Y + sBaseY + RandomPlusMinus(PROGRESS_BAR_RANDOM_Y);
-
- U8 u8dst = *(ms_pCut->m_pimBGLayer->m_pData + (sY * ms_pCut->m_pimBGLayer->m_lPitch) + sX);
- rspPlot(
- rspBlendColor(150, ms_pCut->m_pmaAlpha, ms_pCut->m_u8BloodColor, u8dst),
- ms_pCut->m_pimBGLayer,
- sX,
- sY);
- }
- }
-
- ms_pCut->m_sLastDistance = sDistance;
-
-
- RRect rcBGClipper(
- 0,
- 0,
- ms_pCut->m_pimBGLayer->m_sWidth,
- ms_pCut->m_pimBGLayer->m_sHeight);
- rspLockBuffer();
-
-
- rspBlit(
- ms_pCut->m_pimBGLayer,
- ms_pCut->m_pimDst,
- PROGRESS_BOX_X, PROGRESS_BOX_Y,
- PROGRESS_BOX_X, PROGRESS_BOX_Y,
- PROGRESS_BOX_WIDTH, PROGRESS_BOX_HEIGHT,
- NULL,
- &rcBGClipper);
- rspUnlockBuffer();
- rspUpdateDisplay(PROGRESS_BOX_X, PROGRESS_BOX_Y, PROGRESS_BOX_WIDTH, PROGRESS_BOX_HEIGHT);
-
-
- UpdateSystem();
-
- ms_pCut->m_lTimeToUpdate = lNow;
- }
- }
- }
- }
- }
|