void Monster::setFrozen(bool frozen) { Entity::setFrozen(frozen); if(mIsFrozen) { mFreezeTimer.start(); if(mpAnim) { mpAnim->setPaused(true); mpAnim->setTint(Color(0.35f,0.35f,2.0f)); } shutUp(); game->getSoundEngine()->play3DSound(*game->getResourceManager()->get("freeze" + std::to_string(rand() % 5 + 1)), mPosition); } else { mFreezeTimer.stop(); if(mpAnim) { mpAnim->setPaused(false); mpAnim->setTint(Color(1,1,1)); } } }
/* =============================================================================== SL_SafeMalloc SafeMalloc routine for .S3M loader =============================================================================== */ static void *SL_SafeMalloc(udword ile) { void *temp; temp = malloc(ile); if (!temp) shutUp("Cannot allocate memory! I need %lu bytes!", ile); return temp; }
// Not all the talking actors are in the current set, and so on not all the talking actors // update() is called. For example, Don when he comes out of his office after reaping Meche. bool Actor::updateTalk(uint frameTime) { if (_talking) { // If there's no sound file then we're obviously not talking GrimEngine::SpeechMode m = g_grim->getSpeechMode(); TextObject *textObject = NULL; if (_sayLineText) textObject = TextObject::getPool().getObject(_sayLineText); if (m == GrimEngine::TextOnly && !textObject) { shutUp(); return false; } else if (m != GrimEngine::TextOnly && (_talkSoundName.empty() || !g_sound->getSoundStatus(_talkSoundName.c_str()))) { _talkDelay -= frameTime; if (_talkDelay <= 0) { _talkDelay = 0; shutUp(); return false; } } return true; } return false; }
/* =============================================================================== SL_LoadHeader Alloc memory for basic structures, read header, convert header information =============================================================================== */ static void SL_LoadHeader(FILE *f) { /* be careful with this! */ Mod.WModName = (char *)SL_SafeMalloc(32); Mod.WModType = (char *)SL_SafeMalloc(40); /* read header & verify it */ SafeFRead(&S3MHdr, sizeof(S3MHDR), f); if (memcmp(S3MHdr.SCRM, "SCRM", 4)) shutUp("SL_LoadHeader(): Invalid S3M file (SCRM signature not found)!"); /* copy header information */ Mod.NrOrders = S3MHdr.SongLen; Mod.NrPats = S3MHdr.NrPats; Mod.NrIns = S3MHdr.NrIns; Mod.InitVol = S3MHdr.GlobalVol; Mod.InitSpeed = S3MHdr.InitSpeed; if (S3MHdr.InitTempo > 0x20) Mod.InitTempo = S3MHdr.InitTempo; else Mod.InitTempo = 0x7F; Mod.Stereo = S3MHdr.MasterVol >> 7; Mod.Flags = 0x0; if ((S3MHdr.Flags & 64) || (S3MHdr.CWTV == 0x1300)) Mod.Flags |= MF_FASTVSLIDES; /* copy module name */ strncpy(Mod.WModName, S3MHdr.SongName, 28); Mod.WModName[28] = '\0'; /* prepare module type */ strcpy(Mod.WModType, "ST"); switch(S3MHdr.CWTV) { case 0x1300: strcat(Mod.WModType, "3.00 "); break; case 0x1301: strcat(Mod.WModType, "3.01 "); break; case 0x1303: strcat(Mod.WModType, "3.03 "); break; case 0x1320: strcat(Mod.WModType, "3.20 "); break; } }
int main(int argc, char **argv) { serial_init(); serial_puts("\r\nPortal - Still alive\r\n"); long *address = (long *)(&partition_begin); long allTime = 0; initPE6(); long time = *address; address ++; long duration = *address; address ++; long waveLenght = *address; short c = 256; short previousLed = time%4; short currentLed = previousLed; while ((time != 0xFFFFFFFF || duration != 0xFFFFFFFF || waveLenght != 0xFFFFFFFF) && c > 255) { currentLed = time%4 == previousLed ? (time+1) % 4 : time % 4; turnOnLed(currentLed); allTime = time+duration; c = serial_getc_nb(); initMsTimer0(duration); playWaveLenghtMm(waveLenght); launchAndWaitTimer0(); shutUp(); address ++; turnOffLed(currentLed); previousLed = currentLed; time = *address; address ++; duration = *address; address ++; waveLenght = *address; } unsigned int a = 0; asm volatile("bx %0"::"r"(a)); return 0; }
void Actor::sayLine(const char *msgId, bool background) { assert(msgId); char id[50]; Common::String msg = LuaBase::instance()->parseMsgText(msgId, id); if (msgId[0] == 0) { error("Actor::sayLine: No message ID for text"); return; } // During Fullscreen movies SayLine is usually called for text display only. // The movie with Charlie screaming after Manny put the sheet on him instead // uses sayLine for the voice too. // However, normal SMUSH movies may call SayLine, for example: // When Domino yells at Manny (a SMUSH movie) he does it with // a SayLine request rather than as part of the movie! Common::String soundName = id; if (g_grim->getGameType() == GType_GRIM) { soundName += ".wav"; } else if (g_grim->getGameType() == GType_MONKEY4 && g_grim->getGamePlatform() == Common::kPlatformPS2) { soundName += ".scx"; } else { soundName += ".wVC"; } if (_talkSoundName == soundName) return; if (_talking || msg.empty()) shutUp(); _talkSoundName = soundName; if (g_grim->getSpeechMode() != GrimEngine::TextOnly) { _talkDelay = 500; if (g_sound->startVoice(_talkSoundName.c_str()) && g_grim->getCurrSet()) { g_grim->getCurrSet()->setSoundPosition(_talkSoundName.c_str(), _pos); } } // If the actor is clearly not visible then don't try to play the lip sync if (_visible && (!g_movie->isPlaying() || g_grim->getMode() == GrimEngine::NormalMode)) { Common::String soundLip = id; soundLip += ".lip"; if (!_talkChore[0].isPlaying()) { // _talkChore[0] is *_stop_talk _talkChore[0].setLastFrame(); } // Sometimes actors speak offscreen before they, including their // talk chores are initialized. // For example, when reading the work order (a LIP file exists for no reason). // Also, some lip sync files have no entries // In these cases, revert to using the mumble chore. if (g_grim->getSpeechMode() != GrimEngine::TextOnly) _lipSync = g_resourceloader->getLipSync(soundLip); // If there's no lip sync file then load the mumble chore if it exists // (the mumble chore doesn't exist with the cat races announcer) if (!_lipSync) _mumbleChore.playLooping(); _talkAnim = -1; } _talking = true; g_grim->addTalkingActor(this); _backgroundTalk = background; if (background) _isTalkingBackground = true; if (_sayLineText && g_grim->getMode() != GrimEngine::SmushMode) { delete TextObject::getPool().getObject(_sayLineText); _sayLineText = 0; } if (!msg.empty()) { GrimEngine::SpeechMode m = g_grim->getSpeechMode(); if (!g_grim->_sayLineDefaults.getFont() || m == GrimEngine::VoiceOnly) return; TextObject *textObject = new TextObject(false, true); textObject->setDefaults(&g_grim->_sayLineDefaults); textObject->setFGColor(_talkColor); if (m == GrimEngine::TextOnly || g_grim->getMode() == GrimEngine::SmushMode) { textObject->setDuration(500 + msg.size() * 15 * (11 - g_grim->getTextSpeed())); } if (g_grim->getMode() == GrimEngine::SmushMode) { textObject->setX(640 / 2); textObject->setY(456); g_grim->setMovieSubtitle(textObject); } else { if (_visible && isInSet(g_grim->getCurrSet()->getName())) { _mustPlaceText = true; } else { _mustPlaceText = false; textObject->setX(640 / 2); textObject->setY(463); } } textObject->setText(msgId); if (g_grim->getMode() != GrimEngine::SmushMode) _sayLineText = textObject->getId(); } }
/* =============================================================================== SL_LoadPats Load and depack all used patterns. =============================================================================== */ static void SL_LoadPats(FILE *f) { int Pat, Row, i; udword AllPSize = 64 * sizeof(PATT) * Mod.NrChans; char Tmp8, Tmp82; word Tmp16; char Chn; PATT *CurPat; /* get memory for pointers to patterns */ /* remember that patterns go like: */ /* 0 -- number_of_patterns, not */ /* 0 -- number_of_patterns-1 as you could think */ Mod.Patterns = malloc((Mod.NrPats+1) * sizeof(PATT *)); if (!Mod.Patterns) shutUp("SL_LoadPats: Cannot Allocate Mem For Pattern Pointers!"); Mod.MemoryUsed += (Mod.NrPats+1) * sizeof(PATT *); //------------------------------------------------------------------------------- // LET'S GO! //------------------------------------------------------------------------------- for (Pat = 0; Pat <= Mod.NrPats; Pat++) { fseek(f, PatsParaPtrs[Pat] << 4, SEEK_SET); /* seek at valid position */ SafeFRead(&Tmp16, sizeof(Tmp16), f); /* read size of pattern */ Mod.Patterns[Pat] = malloc(AllPSize); /* allocate next pattern */ if (!Mod.Patterns[Pat]) shutUp("SL_LoadPats: Cannot Allocate Mem For Pattern #%d!", i); Mod.MemoryUsed += AllPSize; /* now, let's clear da pattern, fill it with impossible/invalid values */ for (Row = 0; Row < 64; Row++) { for (Chn = 0; Chn < Mod.NrChans; Chn++) { CurPat = Mod.Patterns[Pat] + (Row * Mod.NrChans) + Chn; CurPat->Note = NONOTE; CurPat->Sample = 0; CurPat->Vol = NOVOL; CurPat->Cmd = NOCMD; CurPat->CmdParm = 0; } } //------------------------------------------------------------------------------- // main loop for every pattern //------------------------------------------------------------------------------- Row = 0; /* row = 0 */ while (Row < 64) { SafeFRead(&Tmp8, sizeof(Tmp8), f); /* get byte */ if (Tmp8 > 0) { Chn = S3MRemap[Tmp8 & 31]; /* we got the channel! */ /* first, let's check if the channel is valid! */ if (Chn == 0xFF || Chn >= Mod.NrChans) { /* channel is invalid, let's move da pointer! */ if ((Tmp8 & 32) > 0) fseek(f, 2, SEEK_CUR); if ((Tmp8 & 64) > 0) fseek(f, 1, SEEK_CUR); if ((Tmp8 & 128) > 0) fseek(f, 2, SEEK_CUR); } else { /* channel is OK, let's read da pattern data */ CurPat = Mod.Patterns[Pat] + (Row * Mod.NrChans) + Chn; /**** Is Note/Sample Given? ****/ if ((Tmp8 & 32) > 0) { SafeFRead(&Tmp82, sizeof(Tmp82), f); if (Tmp82 == 255) CurPat->Note = NONOTE; else if (Tmp82 == 254) CurPat->Note = KEYOFF; else CurPat->Note = ((Tmp82 >> 4) * 12) + (Tmp82 & 0xF); /* octave*12+note */ SafeFRead(&CurPat->Sample, sizeof(CurPat->Sample), f); } /**** Is Volume Given ****/ if ((Tmp8 & 64) > 0) SafeFRead(&CurPat->Vol, sizeof(CurPat->Vol), f); /**** Is Cmd/CmdParm Given? ****/ if ((Tmp8 & 128) > 0) { SafeFRead(&CurPat->Cmd, sizeof(CurPat->Cmd), f); SafeFRead(&CurPat->CmdParm, sizeof(CurPat->CmdParm), f); } } } else