diff options
author | Strangerke | 2017-01-01 11:51:48 -0800 |
---|---|---|
committer | Eugene Sandulenko | 2017-01-25 22:42:19 +0100 |
commit | f483b7c555de9fdb475db396263e4ca2f6e6be1f (patch) | |
tree | 8f38907bbf175c0caf40244f2cdaee578541d358 | |
parent | c85bfafefc66a810adf25eb0bf1b159489ddd919 (diff) | |
download | scummvm-rg350-f483b7c555de9fdb475db396263e4ca2f6e6be1f.tar.gz scummvm-rg350-f483b7c555de9fdb475db396263e4ca2f6e6be1f.tar.bz2 scummvm-rg350-f483b7c555de9fdb475db396263e4ca2f6e6be1f.zip |
CRYO: Some more renaming
-rw-r--r-- | engines/cryo/defs.h | 26 | ||||
-rw-r--r-- | engines/cryo/eden.cpp | 3224 | ||||
-rw-r--r-- | engines/cryo/eden.h | 103 |
3 files changed, 1675 insertions, 1678 deletions
diff --git a/engines/cryo/defs.h b/engines/cryo/defs.h index d65b94982e..3c973a61bc 100644 --- a/engines/cryo/defs.h +++ b/engines/cryo/defs.h @@ -835,23 +835,21 @@ extern int16 tab_2CF70[64]; extern int16 kActionCursors[299]; struct cubeface_t { - int tri; - char ff_4; - char ff_5; + int tri; + char ff_4; + char ff_5; byte *_texturePtr; - uint16 *indices; - int16 *uv; + uint16 *_indices; + int16 *_uv; }; -typedef struct cubeface_t cubeface_t; struct cube_t { - int num; - cubeface_t **faces; - int16 *projection; // projected XYZ coords - int16 *vertices; + int _num; + cubeface_t **_faces; + int16 *_projection; // projected XYZ coords + int16 *_vertices; }; -typedef struct cube_t cube_t; extern float flt_2DF7C; extern float flt_2DF80; @@ -862,9 +860,9 @@ struct XYZ { }; struct cubeCursor { - unsigned char _sides[6]; // spr idx for each side - unsigned char kind; - signed char speed; + uint8 _sides[6]; // spr idx for each side + uint8 _kind; + int8 _speed; }; } // End of namespace Cryo diff --git a/engines/cryo/eden.cpp b/engines/cryo/eden.cpp index c6929d29d0..3ebacd5340 100644 --- a/engines/cryo/eden.cpp +++ b/engines/cryo/eden.cpp @@ -88,12 +88,11 @@ EdenGame::EdenGame(CryoEngine *vm) : _vm(vm) { lastPhrasesFile = 0; dialogSkipFlags = 0; _voiceSamplesBuffer = nullptr; - needToFade = false; - lastMusicNum = 0; + _needToFade = false; _mainBankBuf = nullptr; _musicBuf = nullptr; - gameLipsync = nullptr; - gamePhrases = nullptr; + _gameLipsync = nullptr; + _gamePhrases = nullptr; _gameDialogs = nullptr; _gameConditions = nullptr; _placeRawBuf = nullptr; @@ -102,15 +101,15 @@ EdenGame::EdenGame(CryoEngine *vm) : _vm(vm) { _gameRooms = nullptr; _glowBuffer = nullptr; _gameFont = nullptr; - p_global = nullptr; + _globals = nullptr; _mouseCenterY = _mouseCenterX = 0; - bufferAllocationErrorFl = _quitFlag2 = _quitFlag3 = false; + _bufferAllocationErrorFl = _quitFlag2 = _quitFlag3 = false; _gameStarted = false; _soundAllocated = false; _musicChannel = _voiceChannel = nullptr; _hnmSoundChannel = nullptr; _voiceSound = nullptr; - p_view2 = p_underSubtitlesView = _subtitlesView = p_underBarsView = _mainView = _hnmView = nullptr; + _view2 = _underSubtitlesView = _subtitlesView = _underBarsView = _mainView = _hnmView = nullptr; _hnmContext = nullptr; _doubledScreen = false; _cirsorPanX = 0; @@ -131,17 +130,17 @@ EdenGame::EdenGame(CryoEngine *vm) : _vm(vm) { _musicPlayingFlag = false; _musicSamplesPtr = _musicPatternsPtr = _musSequencePtr = nullptr; _musicEnabledFlag = false; - pCurrentObjectLocation = nullptr; + _currentObjectLocation = nullptr; byte_31D64 = false; _noPalette = false; _gameLoaded = false; - memset(tapes, 0, sizeof(tapes)); - confirmMode = 0; - cur_slider_value_ptr = nullptr; + memset(_tapes, 0, sizeof(_tapes)); + _confirmMode = 0; + _curSliderValuePtr = nullptr; _lastMenuItemIdLo = 0; _lastTapeRoomNum = 0; - _curSliderX = cur_slider_y = 0; - destinationRoom = 0; + _curSliderX = _curSliderY = 0; + _destinationRoom = 0; word_31E7A = 0; word_378CC = 0; //TODO: set by CLComputer_Init to 0 word_378CE = 0; @@ -179,7 +178,7 @@ void EdenGame::scrollFrescoes() { if (_cursorPosY > 16 && _cursorPosY < 176) { if (_cursorPosX >= 0 && _cursorPosX < 32 && _scrollPos > 3) _scrollPos -= 4; - else if (_cursorPosX > 288 && _cursorPosX < 320 && _scrollPos < p_global->_frescoeWidth) + else if (_cursorPosX > 288 && _cursorPosX < 320 && _scrollPos < _globals->_frescoeWidth) _scrollPos += 4; } scroll(); @@ -187,9 +186,9 @@ void EdenGame::scrollFrescoes() { // Original name: afffresques void EdenGame::displayFrescoes() { - useBank(p_global->_frescoeImgBank); + useBank(_globals->_frescoeImgBank); noclipax(0, 0, 16); - useBank(p_global->_frescoeImgBank + 1); + useBank(_globals->_frescoeImgBank + 1); noclipax(0, 320, 16); _paletteUpdateRequired = true; } @@ -199,7 +198,7 @@ void EdenGame::gametofresques() { rundcurs(); saveFriezes(); displayFrescoes(); - p_global->_displayFlags = DisplayFlags::dfFrescoes; + _globals->_displayFlags = DisplayFlags::dfFrescoes; } // Original name: dofresques @@ -208,26 +207,26 @@ void EdenGame::doFrescoes() { _torchCursor = true; _glowX = -1; _glowY = -1; - p_global->_gameFlags |= GameFlags::gfFlag20; - p_global->_varD4 = 0; - p_global->_curObjectId = 0; - p_global->_iconsIndex = 13; - p_global->_autoDialog = false; + _globals->_gameFlags |= GameFlags::gfFlag20; + _globals->_varD4 = 0; + _globals->_curObjectId = 0; + _globals->_iconsIndex = 13; + _globals->_autoDialog = false; gametofresques(); - p_global->_frescoNumber = 3; + _globals->_frescoNumber = 3; } // Original name: finfresques void EdenGame::actionEndFrescoes() { _torchCursor = false; _cursorSaved = true; - p_global->_displayFlags = DisplayFlags::dfFlag1; + _globals->_displayFlags = DisplayFlags::dfFlag1; resetScroll(); - p_global->_var100 = 0xFF; - updateRoom(p_global->_roomNum); - if (p_global->_phaseNum == 114) - p_global->_narratorSequence = 1; - p_global->_eventType = EventType::etEvent8; + _globals->_var100 = 0xFF; + updateRoom(_globals->_roomNum); + if (_globals->_phaseNum == 114) + _globals->_narratorSequence = 1; + _globals->_eventType = EventType::etEvent8; showEvents(); } @@ -288,7 +287,7 @@ void EdenGame::characterInMirror() { Follower *suiveur = followerList; int16 num = 1; for (int i = 0; i < 16; i++) { - if (p_global->_party & (1 << i)) + if (_globals->_party & (1 << i)) num++; } icon += num; @@ -315,7 +314,7 @@ void EdenGame::characterInMirror() { if ((perso->_flags & PersonFlags::pfInParty) == 0) continue; - if (perso->_roomNum != p_global->_roomNum) + if (perso->_roomNum != _globals->_roomNum) continue; icon->sx = suiveur->sx; @@ -333,14 +332,14 @@ void EdenGame::characterInMirror() { // Original name: gametomiroir void EdenGame::gameToMirror(byte arg1) { - if (p_global->_displayFlags != DisplayFlags::dfFlag2) { + if (_globals->_displayFlags != DisplayFlags::dfFlag2) { rundcurs(); restoreFriezes(); drawTopScreen(); showObjects(); saveFriezes(); } - int16 bank = p_global->_roomBackgroundBankNum; + int16 bank = _globals->_roomBackgroundBankNum; uint16 resNum = bank + 326; if (_vm->getPlatform() == Common::kPlatformMacintosh) { if (bank == 76 || bank == 128) @@ -352,17 +351,17 @@ void EdenGame::gameToMirror(byte arg1) { noclipax(0, 320, 16); characterInMirror(); _paletteUpdateRequired = true; - p_global->_iconsIndex = 16; - p_global->_autoDialog = false; - p_global->_displayFlags = DisplayFlags::dfMirror; - p_global->_mirrorEffect = arg1; + _globals->_iconsIndex = 16; + _globals->_autoDialog = false; + _globals->_displayFlags = DisplayFlags::dfMirror; + _globals->_mirrorEffect = arg1; } void EdenGame::flipMode() { if (_personTalking) { endCharacterSpeech(); - if (p_global->_displayFlags == DisplayFlags::dfPerson) { - if (p_global->_characterPtr == &kPersons[PER_THOO] && p_global->_phaseNum >= 80) + if (_globals->_displayFlags == DisplayFlags::dfPerson) { + if (_globals->_characterPtr == &kPersons[PER_THOO] && _globals->_phaseNum >= 80) displaySubtitles(); else { getDataSync(); @@ -375,13 +374,13 @@ void EdenGame::flipMode() { displaySubtitles(); persovox(); } else { - if (p_global->_displayFlags != DisplayFlags::dfFrescoes && p_global->_displayFlags != DisplayFlags::dfFlag2) { + if (_globals->_displayFlags != DisplayFlags::dfFrescoes && _globals->_displayFlags != DisplayFlags::dfFlag2) { closeRoom(); - if (p_global->_displayFlags & DisplayFlags::dfFlag1) + if (_globals->_displayFlags & DisplayFlags::dfFlag1) gameToMirror(1); else { quitMirror(); - updateRoom(p_global->_roomNum); + updateRoom(_globals->_roomNum); if (byte_31D64) { dialautoon(); parle_moi(); @@ -398,10 +397,10 @@ void EdenGame::quitMirror() { display(); resetScroll(); saveFriezes(); - p_global->_displayFlags = DisplayFlags::dfFlag1; - p_global->_var100 = 0xFF; - p_global->_eventType = EventType::etEventC; - p_global->_mirrorEffect = 1; + _globals->_displayFlags = DisplayFlags::dfFlag1; + _globals->_var100 = 0xFF; + _globals->_eventType = EventType::etEventC; + _globals->_mirrorEffect = 1; } void EdenGame::clictimbre() { @@ -410,31 +409,31 @@ void EdenGame::clictimbre() { // Original name: clicplanval void EdenGame::actionClickValleyPlan() { - if ((p_global->_partyOutside & PersonMask::pmDina) && p_global->_phaseNum == 371) { + if ((_globals->_partyOutside & PersonMask::pmDina) && _globals->_phaseNum == 371) { quitMirror(); - updateRoom(p_global->_roomNum); + updateRoom(_globals->_roomNum); return; } - if (p_global->_roomNum == 8 || p_global->_roomNum < 16) + if (_globals->_roomNum == 8 || _globals->_roomNum < 16) return; rundcurs(); display(); - if (p_global->_displayFlags == DisplayFlags::dfMirror) + if (_globals->_displayFlags == DisplayFlags::dfMirror) quitMirror(); - deplaval((p_global->_roomNum & 0xFF00) | 1); //TODO: check me + deplaval((_globals->_roomNum & 0xFF00) | 1); //TODO: check me } // Original name: gotolieu void EdenGame::gotoPlace(Goto *go) { - p_global->_valleyVidNum = go->_arriveVideoNum; - p_global->_travelTime = go->_travelTime * 256; - p_global->_stepsToFindAppleFast = 0; - p_global->_eventType = EventType::etEvent2; + _globals->_valleyVidNum = go->_arriveVideoNum; + _globals->_travelTime = go->_travelTime * 256; + _globals->_stepsToFindAppleFast = 0; + _globals->_eventType = EventType::etEvent2; setChoiceYes(); showEvents(); if (!isAnswerYes()) return; - if (p_global->_var113) { + if (_globals->_var113) { waitEndSpeak(); if (!pomme_q) closeCharacterScreen(); @@ -442,81 +441,81 @@ void EdenGame::gotoPlace(Goto *go) { if (go->_enterVideoNum) { bars_out(); playHNM(go->_enterVideoNum); - needToFade = true; + _needToFade = true; } - initPlace(p_global->_newRoomNum); + initPlace(_globals->_newRoomNum); specialoutside(); - faire_suivre(p_global->_newRoomNum); + faire_suivre(_globals->_newRoomNum); closeRoom(); _adamMapMarkPos.x = -1; _adamMapMarkPos.y = -1; - temps_passe(p_global->_travelTime); - p_global->_var100 = p_global->_roomPtr->_id; - p_global->_roomNum = p_global->_newRoomNum; - p_global->_areaNum = p_global->_roomNum >> 8; - p_global->_eventType = EventType::etEvent5; - p_global->_newMusicType = MusicType::mt2; + temps_passe(_globals->_travelTime); + _globals->_var100 = _globals->_roomPtr->_id; + _globals->_roomNum = _globals->_newRoomNum; + _globals->_areaNum = _globals->_roomNum >> 8; + _globals->_eventType = EventType::etEvent5; + _globals->_newMusicType = MusicType::mt2; setCharacterHere(); musique(); - updateRoom1(p_global->_roomNum); + updateRoom1(_globals->_roomNum); drawTopScreen(); _adamMapMarkPos.x = -1; _adamMapMarkPos.y = -1; } void EdenGame::deplaval(uint16 roomNum) { - p_global->_newLocation = roomNum & 0xFF; - p_global->_valleyVidNum = 0; - p_global->_phaseActionsCount++; + _globals->_newLocation = roomNum & 0xFF; + _globals->_valleyVidNum = 0; + _globals->_phaseActionsCount++; closeRoom(); endCharacterSpeech(); byte c1 = roomNum & 0xFF; if (c1 == 0) return; if (c1 < 0x80) { - p_global->_displayFlags = DisplayFlags::dfFlag1; + _globals->_displayFlags = DisplayFlags::dfFlag1; setChoiceYes(); - p_global->_eventType = EventType::etEvent1; + _globals->_eventType = EventType::etEvent1; showEvents(); if (!isAnswerYes()) return; - if (p_global->_var113) { + if (_globals->_var113) { waitEndSpeak(); if (!pomme_q) closeCharacterScreen(); } specialout(); - if (p_global->_areaPtr->_type == AreaType::atValley) { + if (_globals->_areaPtr->_type == AreaType::atValley) { temps_passe(32); - p_global->_stepsToFindAppleFast++; - p_global->_stepsToFindAppleNormal++; - } - faire_suivre((roomNum & 0xFF00) | p_global->_newLocation); - p_global->_var100 = p_global->_roomPtr->_id; - p_global->_roomNum = roomNum; - p_global->_areaNum = roomNum >> 8; - p_global->_eventType = EventType::etEvent5; + _globals->_stepsToFindAppleFast++; + _globals->_stepsToFindAppleNormal++; + } + faire_suivre((roomNum & 0xFF00) | _globals->_newLocation); + _globals->_var100 = _globals->_roomPtr->_id; + _globals->_roomNum = roomNum; + _globals->_areaNum = roomNum >> 8; + _globals->_eventType = EventType::etEvent5; setCharacterHere(); - p_global->_newMusicType = MusicType::mtNormal; + _globals->_newMusicType = MusicType::mtNormal; musique(); updateRoom1(roomNum); - p_global->_chronoFlag = 0; - p_global->_chrono = 0; - p_global->_var54 = 0; - if (p_global->_roomCharacterType == PersonFlags::pftTyrann) + _globals->_chronoFlag = 0; + _globals->_chrono = 0; + _globals->_var54 = 0; + if (_globals->_roomCharacterType == PersonFlags::pftTyrann) setChrono(3000); return; } if (c1 == 0xFF) { - p_global->_eventType = EventType::etEventE; + _globals->_eventType = EventType::etEventE; showEvents(); if (!kPersons[PER_MESSENGER]._roomNum && checkEloiReturn()) setChrono(800); return; } - p_global->_stepsToFindAppleFast = 0; + _globals->_stepsToFindAppleFast = 0; byte newAreaNum = c1 & 0x7F; - byte curAreaNum = p_global->_roomNum >> 8; + byte curAreaNum = _globals->_roomNum >> 8; int16 newRoomNum = newAreaNum << 8; if (curAreaNum == Areas::arTausCave && newAreaNum == Areas::arMo) newRoomNum |= 0x16; @@ -524,7 +523,7 @@ void EdenGame::deplaval(uint16 roomNum) { newRoomNum |= 4; else newRoomNum |= 1; - p_global->_newRoomNum = newRoomNum; + _globals->_newRoomNum = newRoomNum; if (newAreaNum == Areas::arTausCave) gotoPlace(&gotos[0]); else { @@ -539,13 +538,13 @@ void EdenGame::deplaval(uint16 roomNum) { // Original name: deplacement void EdenGame::move(Direction dir) { - Room *room = p_global->_roomPtr; - int16 roomNum = p_global->_roomNum; + Room *room = _globals->_roomPtr; + int16 roomNum = _globals->_roomNum; debug("move: from room %4X", roomNum); char newLoc = 0; rundcurs(); display(); - p_global->_prevLocation = roomNum & 0xFF; + _globals->_prevLocation = roomNum & 0xFF; switch (dir) { case kCryoNorth: newLoc = room->_exits[0]; @@ -565,10 +564,10 @@ void EdenGame::move(Direction dir) { // Original name: deplacement2 void EdenGame::move2(Direction dir) { - Room *room = p_global->_roomPtr; - int16 roomNum = p_global->_roomNum; + Room *room = _globals->_roomPtr; + int16 roomNum = _globals->_roomNum; char newLoc = 0; - p_global->_prevLocation = roomNum & 0xFF; + _globals->_prevLocation = roomNum & 0xFF; switch (dir) { case kCryoNorth: newLoc = room->_exits[0]; @@ -588,7 +587,7 @@ void EdenGame::move2(Direction dir) { // Original name: dinosoufle void EdenGame::actionDinoBreath() { - if (p_global->_curObjectId == 0) { + if (_globals->_curObjectId == 0) { bars_out(); playHNM(148); maj2(); @@ -597,8 +596,8 @@ void EdenGame::actionDinoBreath() { // Original name: plaquemonk void EdenGame::actionPlateMonk() { - if (p_global->_curObjectId != 0) { - if (p_global->_curObjectId == Objects::obPrism) { + if (_globals->_curObjectId != 0) { + if (_globals->_curObjectId == Objects::obPrism) { loseObject(Objects::obPrism); bars_out(); _specialTextMode = true; @@ -606,23 +605,23 @@ void EdenGame::actionPlateMonk() { // CHECKME: Unused code // word_2F514 |= 0x8000; maj2(); - p_global->_eventType = EventType::etEventB; + _globals->_eventType = EventType::etEventB; showEvents(); } } else { bars_out(); playHNM(7); maj2(); - p_global->_eventType = EventType::etEvent4; + _globals->_eventType = EventType::etEvent4; showEvents(); } } // Original name: fresquesgraa void EdenGame::actionGraaFrescoe() { - if (p_global->_curObjectId == 0) { - p_global->_frescoeWidth = 320; - p_global->_frescoeImgBank = 113; + if (_globals->_curObjectId == 0) { + _globals->_frescoeWidth = 320; + _globals->_frescoeImgBank = 113; doFrescoes(); handleDinaDialog(); } @@ -630,16 +629,16 @@ void EdenGame::actionGraaFrescoe() { // Original name: fresqueslasc void EdenGame::actionLascFrescoe() { - if (p_global->_curObjectId == 0) { - p_global->_frescoeWidth = 112; - p_global->_frescoeImgBank = 315; + if (_globals->_curObjectId == 0) { + _globals->_frescoeWidth = 112; + _globals->_frescoeImgBank = 315; doFrescoes(); } } // Original name: pushpierre void EdenGame::actionPushStone() { - if (p_global->_curObjectId == 0) { + if (_globals->_curObjectId == 0) { _gameRooms[22]._exits[0] = 17; _gameRooms[26]._exits[2] = 9; move(kCryoNorth); @@ -648,23 +647,23 @@ void EdenGame::actionPushStone() { // Original name: tetemomie void EdenGame::actionMummyHead() { - if (p_global->_curObjectId == Objects::obTooth) { - p_global->_gameFlags |= GameFlags::gfMummyOpened; + if (_globals->_curObjectId == Objects::obTooth) { + _globals->_gameFlags |= GameFlags::gfMummyOpened; move(kCryoNorth); - } else if (p_global->_curObjectId == 0) { - if (p_global->_gameFlags & GameFlags::gfMummyOpened) + } else if (_globals->_curObjectId == 0) { + if (_globals->_gameFlags & GameFlags::gfMummyOpened) move(kCryoNorth); else { - p_global->_eventType = EventType::etEvent6; + _globals->_eventType = EventType::etEvent6; handleCharacterDialog(PersonId::pidMonk); - p_global->_eventType = 0; + _globals->_eventType = 0; } } } // Original name: tetesquel void EdenGame::actionSkelettonHead() { - if (p_global->_curObjectId == Objects::obTooth) { + if (_globals->_curObjectId == Objects::obTooth) { _gameRooms[22]._exits[0] = 16; _gameRooms[26]._exits[2] = 13; _gameIcons[16]._cursorId |= 0x8000; @@ -675,7 +674,7 @@ void EdenGame::actionSkelettonHead() { // Original name: squelmoorkong void EdenGame::actionSkelettonMoorkong() { - p_global->_eventType = EventType::etEvent9; + _globals->_eventType = EventType::etEvent9; showEvents(); } @@ -685,13 +684,13 @@ void EdenGame::actionChoose() { byte obj; switch (objid) { case 0: - obj = p_global->_giveObj1; + obj = _globals->_giveObj1; break; case 1: - obj = p_global->_giveObj2; + obj = _globals->_giveObj2; break; case 2: - obj = p_global->_giveObj3; + obj = _globals->_giveObj3; break; default: warning("Unexpected object_id in actionChoose()"); @@ -699,9 +698,9 @@ void EdenGame::actionChoose() { } objectmain(obj); winObject(obj); - p_global->_iconsIndex = 16; - p_global->_autoDialog = false; - p_global->_var60 = 0; + _globals->_iconsIndex = 16; + _globals->_autoDialog = false; + _globals->_var60 = 0; parle_moi(); } @@ -709,16 +708,16 @@ void EdenGame::actionChoose() { void EdenGame::handleDinaDialog() { int16 num; perso_t *perso = &kPersons[PER_DINA]; - if (perso->_partyMask & (p_global->_party | p_global->_partyOutside)) { - if (p_global->_frescoNumber < 3) - p_global->_frescoNumber = 3; - p_global->_frescoNumber++; - if (p_global->_frescoNumber < 15) { + if (perso->_partyMask & (_globals->_party | _globals->_partyOutside)) { + if (_globals->_frescoNumber < 3) + _globals->_frescoNumber = 3; + _globals->_frescoNumber++; + if (_globals->_frescoNumber < 15) { endCharacterSpeech(); - if (p_global->_frescoNumber == 7 && p_global->_phaseNum == 113) + if (_globals->_frescoNumber == 7 && _globals->_phaseNum == 113) incPhase(); - p_global->_characterPtr = perso; - p_global->_dialogType = DialogType::dtInspect; + _globals->_characterPtr = perso; + _globals->_dialogType = DialogType::dtInspect; num = (perso->_id << 3) | DialogType::dtInspect; //TODO: combine bool res = dialoscansvmas((dial_t *)getElem(_gameDialogs, num)); _frescoTalk = false; @@ -727,8 +726,8 @@ void EdenGame::handleDinaDialog() { _frescoTalk = true; persovox(); } - p_global->_varCA = 0; - p_global->_dialogType = DialogType::dtTalk; + _globals->_varCA = 0; + _globals->_dialogType = DialogType::dtTalk; } else actionEndFrescoes(); } @@ -736,49 +735,49 @@ void EdenGame::handleDinaDialog() { // Original name: roiparle void EdenGame::handleKingDialog() { - if (p_global->_phaseNum <= 400) + if (_globals->_phaseNum <= 400) handleCharacterDialog(0); } // Original name: roiparle1 void EdenGame::actionKingDialog1() { - if (p_global->_curObjectId == Objects::obSword) { - p_global->_gameFlags |= GameFlags::gfFlag80; + if (_globals->_curObjectId == Objects::obSword) { + _globals->_gameFlags |= GameFlags::gfFlag80; bars_out(); playHNM(76); move2(kCryoNorth); } else { - p_global->_frescoNumber = 1; + _globals->_frescoNumber = 1; handleKingDialog(); } } // Original name: roiparle2 void EdenGame::actionKingDialog2() { - p_global->_frescoNumber = 2; + _globals->_frescoNumber = 2; handleKingDialog(); } // Original name: roiparle3 void EdenGame::actionKingDialog3() { - p_global->_frescoNumber = 3; + _globals->_frescoNumber = 3; handleKingDialog(); } // Original name: getcouteau void EdenGame::actionGetKnife() { - if (p_global->_phaseNum >= 80) { + if (_globals->_phaseNum >= 80) { _gameRooms[113]._video = 0; getObject(Objects::obKnife); } - p_global->_eventType = EventType::etEvent7; + _globals->_eventType = EventType::etEvent7; showEvents(); } // Original name: getprisme void EdenGame::actionGetPrism() { getObject(Objects::obPrism); - p_global->_eventType = EventType::etEvent7; + _globals->_eventType = EventType::etEvent7; showEvents(); } @@ -799,41 +798,41 @@ void EdenGame::actionGetGold() { // Original name: getnido void EdenGame::actionGetFullNest() { - if (p_global->_curObjectId != 0) + if (_globals->_curObjectId != 0) return; - p_global->_roomPtr->_bank = 282; //TODO: fix me - p_global->_roomPtr--; - p_global->_roomPtr->_bank = 281; //TODO: fix me - p_global->_roomPtr->_id = 3; + _globals->_roomPtr->_bank = 282; //TODO: fix me + _globals->_roomPtr--; + _globals->_roomPtr->_bank = 281; //TODO: fix me + _globals->_roomPtr->_id = 3; getObject(Objects::obFullNest); } // Original name: getnidv void EdenGame::actionGetEmptyNest() { - if (p_global->_curObjectId != 0) + if (_globals->_curObjectId != 0) return; - p_global->_roomPtr->_bank = 282; //TODO: fix me - p_global->_roomPtr--; - p_global->_roomPtr->_bank = 281; //TODO: fix me - p_global->_roomPtr->_id = 3; + _globals->_roomPtr->_bank = 282; //TODO: fix me + _globals->_roomPtr--; + _globals->_roomPtr->_bank = 281; //TODO: fix me + _globals->_roomPtr->_id = 3; getObject(Objects::obNest); } // Original name: getcorne void EdenGame::actionGetHorn() { - if (p_global->_curObjectId != 0) + if (_globals->_curObjectId != 0) return; getObject(Objects::obHorn); - p_global->_eventType = EventType::etEvent7; + _globals->_eventType = EventType::etEvent7; showEvents(); bigphase1(); setCharacterHere(); - p_global->_roomPtr = getRoom(p_global->_roomNum); + _globals->_roomPtr = getRoom(_globals->_roomNum); } // Original name: getsoleil void EdenGame::actionGetSunStone() { - if (p_global->_curObjectId != 0) + if (_globals->_curObjectId != 0) return; _gameRooms[238]._video = 0; _gameRooms[238]._flags = RoomFlags::rf80; @@ -842,32 +841,32 @@ void EdenGame::actionGetSunStone() { // Original name: getoueuf void EdenGame::actionGetEgg() { - if (p_global->_curObjectId != 0) + if (_globals->_curObjectId != 0) return; - p_global->_roomPtr->_flags = 0; - p_global->_roomPtr->_video = 0; + _globals->_roomPtr->_flags = 0; + _globals->_roomPtr->_video = 0; getObject(Objects::obEgg); } // Original name: getplaque void EdenGame::actionGetTablet() { - if (p_global->_curObjectId != 0 && p_global->_curObjectId < Objects::obTablet1) + if (_globals->_curObjectId != 0 && _globals->_curObjectId < Objects::obTablet1) return; - p_global->_curObjectId = 0; + _globals->_curObjectId = 0; getObject(Objects::obTablet2); putObject(); for (int i = 0; i < 6; i++) _objects[Objects::obTablet1 - 1 + i]._count = 0; - p_global->_curObjectFlags = 0; - p_global->_inventoryScrollPos = 0; - p_global->_curObjectCursor = 9; + _globals->_curObjectFlags = 0; + _globals->_inventoryScrollPos = 0; + _globals->_curObjectCursor = 9; _gameIcons[16]._cursorId |= 0x8000; showObjects(); _gameRooms[131]._video = 0; bars_out(); playHNM(149); - p_global->_varF1 = RoomFlags::rf04; - p_global->_drawFlags = DrawFlags::drDrawFlag20; + _globals->_varF1 = RoomFlags::rf04; + _globals->_drawFlags = DrawFlags::drDrawFlag20; _normalCursor = true; maj2(); } @@ -875,14 +874,14 @@ void EdenGame::actionGetTablet() { // Original name: voirlac void EdenGame::actionLookLake() { perso_t *perso = &kPersons[PER_MORKUS]; - Room *room = p_global->_roomPtr; - Area *area = p_global->_areaPtr; - int16 vid = p_global->_curObjectId == Objects::obApple ? 81 : 54; + Room *room = _globals->_roomPtr; + Area *area = _globals->_areaPtr; + int16 vid = _globals->_curObjectId == Objects::obApple ? 81 : 54; for (++perso; perso->_roomNum != 0xFFFF; perso++) { - if (perso->_roomNum != p_global->_roomNum) + if (perso->_roomNum != _globals->_roomNum) continue; vid++; - if (p_global->_curObjectId != Objects::obApple) + if (_globals->_curObjectId != Objects::obApple) continue; //TODO: pc breaks here if ((perso->_flags & PersonFlags::pfTypeMask) != PersonFlags::pftMosasaurus) continue; @@ -890,58 +889,58 @@ void EdenGame::actionLookLake() { return; perso->_flags &= ~PersonFlags::pf80; //TODO: useless? see above area->_flags |= AreaFlags::afFlag8; - p_global->_curAreaFlags |= AreaFlags::afFlag8; + _globals->_curAreaFlags |= AreaFlags::afFlag8; room->_id = 3; } - debug("sea monster: room = %X, d0 = %X\n", p_global->_roomNum, p_global->_roomImgBank); + debug("sea monster: room = %X, d0 = %X\n", _globals->_roomNum, _globals->_roomImgBank); bars_out(); playHNM(vid); - updateRoom(p_global->_roomNum); //TODO: getting memory trashed here? - if (p_global->_curObjectId == Objects::obApple) + updateRoom(_globals->_roomNum); //TODO: getting memory trashed here? + if (_globals->_curObjectId == Objects::obApple) loseObject(Objects::obApple); - p_global->_eventType = EventType::etEventF; + _globals->_eventType = EventType::etEventF; showEvents(); } // Original name: gotohall void EdenGame::actionGotoHall() { - p_global->_prevLocation = p_global->_roomNum & 0xFF; - deplaval((p_global->_roomNum & 0xFF00) | 6); + _globals->_prevLocation = _globals->_roomNum & 0xFF; + deplaval((_globals->_roomNum & 0xFF00) | 6); } // Original name: demitourlabi void EdenGame::actionLabyrinthTurnAround() { - p_global->_prevLocation = p_global->_roomNum & 0xFF; - p_global->_var100 = 0xFF; - uint16 target = (p_global->_roomNum & 0xFF00) | p_global->_roomPtr->_exits[2]; + _globals->_prevLocation = _globals->_roomNum & 0xFF; + _globals->_var100 = 0xFF; + uint16 target = (_globals->_roomNum & 0xFF00) | _globals->_roomPtr->_exits[2]; faire_suivre(target); - p_global->_roomNum = target; - p_global->_eventType = EventType::etEvent5; - updateRoom(p_global->_roomNum); + _globals->_roomNum = target; + _globals->_eventType = EventType::etEvent5; + updateRoom(_globals->_roomNum); } // Original name: gotonido void EdenGame::actionGotoFullNest() { - p_global->_roomPtr++; - p_global->_eventType = 0; - p_global->_roomImgBank = p_global->_roomPtr->_bank; - p_global->_roomVidNum = p_global->_roomPtr->_video; - p_global->_curRoomFlags = p_global->_roomPtr->_flags; - p_global->_varF1 = p_global->_roomPtr->_flags; + _globals->_roomPtr++; + _globals->_eventType = 0; + _globals->_roomImgBank = _globals->_roomPtr->_bank; + _globals->_roomVidNum = _globals->_roomPtr->_video; + _globals->_curRoomFlags = _globals->_roomPtr->_flags; + _globals->_varF1 = _globals->_roomPtr->_flags; animpiece(); - p_global->_var100 = 0; + _globals->_var100 = 0; maj2(); } // Original name: gotoval void EdenGame::actionGotoVal() { - uint16 target = p_global->_roomNum; + uint16 target = _globals->_roomNum; char obj; rundcurs(); display(); _scrollPos = 0; obj = _curSpot2->_objectId - 14; //TODO - p_global->_prevLocation = target & 0xFF; + _globals->_prevLocation = target & 0xFF; deplaval((target & 0xFF00) | obj); //TODO careful! } @@ -949,73 +948,73 @@ void EdenGame::actionGotoVal() { void EdenGame::actionVisit() { bars_out(); playHNM(144); - p_global->_varF1 = RoomFlags::rf04; + _globals->_varF1 = RoomFlags::rf04; maj2(); } // Original name: final void EdenGame::actionFinal() { - if (p_global->_curObjectId != 0) + if (_globals->_curObjectId != 0) return; bars_out(); *(int16 *)(_gameRooms + 0x6DC) = 319; //TODO - p_global->_roomImgBank = 319; + _globals->_roomImgBank = 319; playHNM(97); maj2(); - p_global->_eventType = EventType::etEvent12; + _globals->_eventType = EventType::etEvent12; showEvents(); - p_global->_narratorSequence = 54; + _globals->_narratorSequence = 54; } // Original name: goto_nord void EdenGame::actionMoveNorth() { - if (p_global->_curObjectId == 0) + if (_globals->_curObjectId == 0) move(kCryoNorth); } // Original name: goto_est void EdenGame::actionMoveEast() { - if (p_global->_curObjectId == 0) + if (_globals->_curObjectId == 0) move(kCryoEast); } // Original name: goto_sud void EdenGame::actionMoveSouth() { - if (p_global->_curObjectId == 0) + if (_globals->_curObjectId == 0) move(kCryoSouth); } // Original name: goto_ouest void EdenGame::actionMoveWest() { - if (p_global->_curObjectId == 0) + if (_globals->_curObjectId == 0) move(kCryoWest); } // Original name: afficher void EdenGame::display() { - if (!p_global->_mirrorEffect && !p_global->_var103) { + if (!_globals->_mirrorEffect && !_globals->_var103) { if (_paletteUpdateRequired) { _paletteUpdateRequired = false; CLPalette_Send2Screen(_globalPalette, 0, 256); } CLBlitter_CopyView2Screen(_mainView); } else { - if (p_global->_mirrorEffect) + if (_globals->_mirrorEffect) displayEffect3(); else displayEffect2(); - p_global->_var103 = 0; - p_global->_mirrorEffect = 0; + _globals->_var103 = 0; + _globals->_mirrorEffect = 0; } } void EdenGame::afficher128() { - if (p_global->_updatePaletteFlag == 16) { + if (_globals->_updatePaletteFlag == 16) { CLPalette_Send2Screen(_globalPalette, 0, 129); CLBlitter_CopyView2Screen(_mainView); - p_global->_updatePaletteFlag = 0; + _globals->_updatePaletteFlag = 0; } else { clearScreen(); fadeToBlackLowPalette(1); @@ -1036,14 +1035,14 @@ void EdenGame::saveFriezes() { void EdenGame::saveTopFrieze(int16 x) { // Save top bar _underTopBarScreenRect = Common::Rect(x, 0, x + 320 - 1, 15); _underTopBarBackupRect = Common::Rect(0, 0, 320 - 1, 15); - CLBlitter_CopyViewRect(_mainView, p_underBarsView, &_underTopBarScreenRect, &_underTopBarBackupRect); + CLBlitter_CopyViewRect(_mainView, _underBarsView, &_underTopBarScreenRect, &_underTopBarBackupRect); } // Original name: sauvefrisesbas void EdenGame::saveBottomFrieze() { // Save bottom bar _underBottomBarScreenRect.left = 0; _underBottomBarScreenRect.right = 320 - 1; - CLBlitter_CopyViewRect(_mainView, p_underBarsView, &_underBottomBarScreenRect, &_underBottomBarBackupRect); + CLBlitter_CopyViewRect(_mainView, _underBarsView, &_underBottomBarScreenRect, &_underBottomBarBackupRect); } // Original name: restaurefrises @@ -1056,14 +1055,14 @@ void EdenGame::restoreFriezes() { void EdenGame::restoreTopFrieze() { _underTopBarScreenRect.left = _scrollPos; _underTopBarScreenRect.right = _scrollPos + 320 - 1; - CLBlitter_CopyViewRect(p_underBarsView, _mainView, &_underTopBarBackupRect, &_underTopBarScreenRect); + CLBlitter_CopyViewRect(_underBarsView, _mainView, &_underTopBarBackupRect, &_underTopBarScreenRect); } // Original name: restaurefrisesbas void EdenGame::restoreBottomFrieze() { _underBottomBarScreenRect.left = _scrollPos; _underBottomBarScreenRect.right = _scrollPos + 320 - 1; - CLBlitter_CopyViewRect(p_underBarsView, _mainView, &_underBottomBarBackupRect, &_underBottomBarScreenRect); + CLBlitter_CopyViewRect(_underBarsView, _mainView, &_underBottomBarBackupRect, &_underBottomBarScreenRect); } void EdenGame::useMainBank() { @@ -1304,7 +1303,7 @@ void EdenGame::glow(int16 index) { int16 x = _cursorPosX + _scrollPos - 38; int16 y = _cursorPosY - 28; - int16 ex = p_global->_frescoeWidth + 320; + int16 ex = _globals->_frescoeWidth + 320; if (x + w <= 0 || x >= ex || y + h <= 0 || y >= 176) return; @@ -1463,10 +1462,10 @@ void EdenGame::bars_out() { display(); _underTopBarScreenRect.left = _scrollPos; _underTopBarScreenRect.right = _scrollPos + 320 - 1; - CLBlitter_CopyViewRect(_mainView, p_underBarsView, &_underTopBarScreenRect, &_underTopBarBackupRect); + CLBlitter_CopyViewRect(_mainView, _underBarsView, &_underTopBarScreenRect, &_underTopBarBackupRect); _underBottomBarScreenRect.left = _underTopBarScreenRect.left; _underBottomBarScreenRect.right = _underTopBarScreenRect.right; - CLBlitter_CopyViewRect(_mainView, p_underBarsView, &_underBottomBarScreenRect, &_underBottomBarBackupRect); + CLBlitter_CopyViewRect(_mainView, _underBarsView, &_underBottomBarScreenRect, &_underBottomBarBackupRect); int16 r19 = 14; // TODO - init in decl? int16 r20 = 176; int16 r25 = 14; @@ -1482,7 +1481,7 @@ void EdenGame::bars_out() { _underTopBarScreenRect.bottom = 16 - 1; _underTopBarBackupRect.top = 0; _underTopBarBackupRect.bottom = r25 - 1; - CLBlitter_CopyViewRect(p_underBarsView, _mainView, &_underTopBarScreenRect, &_underTopBarBackupRect); + CLBlitter_CopyViewRect(_underBarsView, _mainView, &_underTopBarScreenRect, &_underTopBarBackupRect); scr40 = ((unsigned int *)_mainViewBuf) + r19 * 640 / 4; scr41 = scr40 + 640 / 4; for (int i = 0; i < 320; i += 4) { @@ -1494,7 +1493,7 @@ void EdenGame::bars_out() { _underTopBarScreenRect.bottom = r24 + 16 - 1; _underTopBarBackupRect.top = 200 - r24; _underTopBarBackupRect.bottom = 200 - 1; - CLBlitter_CopyViewRect(p_underBarsView, _mainView, &_underTopBarScreenRect, &_underTopBarBackupRect); + CLBlitter_CopyViewRect(_underBarsView, _mainView, &_underTopBarScreenRect, &_underTopBarBackupRect); scr40 = ((unsigned int *)_mainViewBuf) + r20 * 640 / 4; scr41 = scr40 + 640 / 4; scr42 = scr41 + 640 / 4; @@ -1546,13 +1545,13 @@ void EdenGame::showBars() { _underTopBarScreenRect.bottom = 16 - 1; _underTopBarBackupRect.top = 0; _underTopBarBackupRect.bottom = r29 - 1; - CLBlitter_CopyViewRect(p_underBarsView, _mainView, &_underTopBarScreenRect, &_underTopBarBackupRect); + CLBlitter_CopyViewRect(_underBarsView, _mainView, &_underTopBarScreenRect, &_underTopBarBackupRect); } _underTopBarScreenRect.top = 16; _underTopBarScreenRect.bottom = 16 + r28; _underTopBarBackupRect.top = 200 - 1 - r28; _underTopBarBackupRect.bottom = 200 - 1; - CLBlitter_CopyViewRect(p_underBarsView, _mainView, &_underTopBarScreenRect, &_underTopBarBackupRect); + CLBlitter_CopyViewRect(_underBarsView, _mainView, &_underTopBarScreenRect, &_underTopBarBackupRect); r29 += 2; r28 += 3; display(); @@ -1602,10 +1601,10 @@ void EdenGame::drawBlackBars() { } void EdenGame::drawTopScreen() { // Draw top bar (location / party / map) - p_global->_drawFlags &= ~DrawFlags::drDrawTopScreen; + _globals->_drawFlags &= ~DrawFlags::drDrawTopScreen; useBank(314); noclipax(36, 83, 0); - noclipax(p_global->_areaPtr->_num - 1, 0, 0); + noclipax(_globals->_areaPtr->_num - 1, 0, 0); noclipax(23, 145, 0); for (perso_t *perso = &kPersons[PER_DINA]; perso != &kPersons[PER_UNKN_156]; perso++) { if ((perso->_flags & PersonFlags::pfInParty) && !(perso->_flags & PersonFlags::pf80)) @@ -1619,17 +1618,17 @@ void EdenGame::drawTopScreen() { // Draw top bar (location / party / map) // Original name: affplanval void EdenGame::displayValleyMap() { // Draw mini-map - if (p_global->_areaPtr->_type == AreaType::atValley) { - noclipax(p_global->_areaPtr->_num + 9, 266, 1); + if (_globals->_areaPtr->_type == AreaType::atValley) { + noclipax(_globals->_areaPtr->_num + 9, 266, 1); for (perso_t *perso = &kPersons[PER_UNKN_18C]; perso->_roomNum != 0xFFFF; perso++) { - if (((perso->_roomNum >> 8) == p_global->_areaNum) + if (((perso->_roomNum >> 8) == _globals->_areaNum) && !(perso->_flags & PersonFlags::pf80) && (perso->_flags & PersonFlags::pf20)) displayMapMark(33, perso->_roomNum & 0xFF); } - if (p_global->_areaPtr->_citadelLevel) - displayMapMark(34, p_global->_areaPtr->_citadelRoomPtr->_location); + if (_globals->_areaPtr->_citadelLevel) + displayMapMark(34, _globals->_areaPtr->_citadelRoomPtr->_location); saveTopFrieze(0); - int16 loc = p_global->_roomNum & 0xFF; + int16 loc = _globals->_roomNum & 0xFF; if (loc >= 16) displayAdamMapMark(loc); restoreTopFrieze(); @@ -1653,8 +1652,8 @@ void EdenGame::displayAdamMapMark(int16 location) { x += (location & 15) * 4; y += ((location - 16) >> 4) * 3; saveAdamMapMark(x, y); - byte *pix = p_underBarsView->_bufferPtr; - int16 w = p_underBarsView->_width; + byte *pix = _underBarsView->_bufferPtr; + int16 w = _underBarsView->_width; pix += x + w * y; pix[1] = 0xC3; pix[2] = 0xC3; @@ -1676,8 +1675,8 @@ void EdenGame::restoreAdamMapMark() { int16 x = _adamMapMarkPos.x; int16 y = _adamMapMarkPos.y; - byte *pix = p_underBarsView->_bufferPtr; - int16 w = p_underBarsView->_width; + byte *pix = _underBarsView->_bufferPtr; + int16 w = _underBarsView->_width; pix += x + w * y; pix[1] = _oldPix[0]; pix[2] = _oldPix[1]; @@ -1695,8 +1694,8 @@ void EdenGame::restoreAdamMapMark() { void EdenGame::saveAdamMapMark(int16 x, int16 y) { _adamMapMarkPos.x = x; _adamMapMarkPos.y = y; - byte *pix = p_underBarsView->_bufferPtr; - int16 w = p_underBarsView->_width; + byte *pix = _underBarsView->_bufferPtr; + int16 w = _underBarsView->_width; pix += x + w * y; _oldPix[0] = pix[1]; _oldPix[1] = pix[2]; @@ -1792,12 +1791,12 @@ char EdenGame::getDirection(perso_t *perso) { // Original name: caselibre bool EdenGame::canMoveThere(char loc, perso_t *perso) { - Room *room = p_global->_citaAreaFirstRoom; + Room *room = _globals->_citaAreaFirstRoom; if (loc <= 0x10 || loc > 76 || (loc & 0xF) >= 12 || loc == perso->_lastLoc) return false; int16 roomNum = (perso->_roomNum & ~0xFF) | loc; //TODO: danger! signed - if (roomNum == p_global->_roomNum) + if (roomNum == _globals->_roomNum) return false; for (; room->_id != 0xFF; room++) { @@ -1848,7 +1847,7 @@ void EdenGame::scrambleDirections() { bool EdenGame::naitredino(char persoType) { for (perso_t *perso = &kPersons[PER_MORKUS]; (++perso)->_roomNum != 0xFFFF;) { char areaNum = perso->_roomNum >> 8; - if (areaNum != p_global->_citadelAreaNum) + if (areaNum != _globals->_citadelAreaNum) continue; if ((perso->_flags & PersonFlags::pf80) && (perso->_flags & PersonFlags::pfTypeMask) == persoType) { perso->_flags &= ~PersonFlags::pf80; @@ -1875,10 +1874,10 @@ void EdenGame::newCitadel(char area, int16 level, Room *room) { // Original name: citaevol void EdenGame::evolveCitadel(int16 level) { - Room *room = p_global->_curAreaPtr->_citadelRoomPtr; + Room *room = _globals->_curAreaPtr->_citadelRoomPtr; perso_t *perso = &kPersons[PER_UNKN_372]; byte loc = room->_location; - if (level >= 80 && !istrice((p_global->_citadelAreaNum << 8) | loc)) { + if (level >= 80 && !istrice((_globals->_citadelAreaNum << 8) | loc)) { room->_level = 79; return; } @@ -1887,20 +1886,20 @@ void EdenGame::evolveCitadel(int16 level) { level = 160; if (room->_level < 64 && level >= 64 && naitredino(PersonFlags::pftTriceraptor)) { - p_global->_curAreaPtr->_flags |= AreaFlags::HasTriceraptors; - addInfo(p_global->_citadelAreaNum + ValleyNews::vnTriceraptorsIn); + _globals->_curAreaPtr->_flags |= AreaFlags::HasTriceraptors; + addInfo(_globals->_citadelAreaNum + ValleyNews::vnTriceraptorsIn); } if (room->_level < 40 && level >= 40 && naitredino(PersonFlags::pftVelociraptor)) { - p_global->_curAreaPtr->_flags |= AreaFlags::HasVelociraptors; - addInfo(p_global->_citadelAreaNum + ValleyNews::vnVelociraptorsIn); + _globals->_curAreaPtr->_flags |= AreaFlags::HasVelociraptors; + addInfo(_globals->_citadelAreaNum + ValleyNews::vnVelociraptorsIn); } room->_level = level; - newCitadel(p_global->_citadelAreaNum, level, room); + newCitadel(_globals->_citadelAreaNum, level, room); byte speed = kDinoSpeedForCitaLevel[room->_level >> 4]; for (; perso->_roomNum != 0xFFFF; perso++) { if (perso->_flags & PersonFlags::pf80) continue; - if ((perso->_roomNum >> 8) == p_global->_citadelAreaNum && perso->_targetLoc == loc) + if ((perso->_roomNum >> 8) == _globals->_citadelAreaNum && perso->_targetLoc == loc) perso->_speed = speed; } } @@ -1908,14 +1907,14 @@ void EdenGame::evolveCitadel(int16 level) { // Original name: citacapoute void EdenGame::destroyCitadelRoom(int16 roomNum) { perso_t *perso = &kPersons[PER_UNKN_18C]; - Room *room = p_global->_curAreaPtr->_citadelRoomPtr; + Room *room = _globals->_curAreaPtr->_citadelRoomPtr; room->_flags |= RoomFlags::rf01; room->_flags &= ~RoomFlags::rfHasCitadel; room->_bank = 193; room->_video = 0; room->_level = 0; - p_global->_curAreaPtr->_citadelLevel = 0; - p_global->_curAreaPtr->_citadelRoomPtr = 0; + _globals->_curAreaPtr->_citadelLevel = 0; + _globals->_curAreaPtr->_citadelRoomPtr = 0; roomNum = (roomNum & ~0xFF) | room->_location; for (; perso->_roomNum != 0xFFFF; perso++) { if (perso->_roomNum == roomNum) { @@ -1928,54 +1927,54 @@ void EdenGame::destroyCitadelRoom(int16 roomNum) { // Original name: buildcita void EdenGame::buildCitadel() { - Area *area = p_global->_areaPtr; - p_global->_curAreaPtr = p_global->_areaPtr; + Area *area = _globals->_areaPtr; + _globals->_curAreaPtr = _globals->_areaPtr; if (area->_citadelRoomPtr) - destroyCitadelRoom(p_global->_roomNum); - p_global->_var6A = p_global->_var69; - p_global->_narratorSequence = p_global->_var69 | 0x80; - area->_citadelRoomPtr = p_global->_roomPtr; - p_global->_roomPtr->_flags &= ~RoomFlags::rf01; - p_global->_roomPtr->_flags |= RoomFlags::rfHasCitadel; - p_global->_roomPtr->_level = 32; - newCitadel(p_global->_areaNum, 32, p_global->_roomPtr); + destroyCitadelRoom(_globals->_roomNum); + _globals->_var6A = _globals->_var69; + _globals->_narratorSequence = _globals->_var69 | 0x80; + area->_citadelRoomPtr = _globals->_roomPtr; + _globals->_roomPtr->_flags &= ~RoomFlags::rf01; + _globals->_roomPtr->_flags |= RoomFlags::rfHasCitadel; + _globals->_roomPtr->_level = 32; + newCitadel(_globals->_areaNum, 32, _globals->_roomPtr); area->_flags &= ~AreaFlags::TyrannSighted; if (!(area->_flags & AreaFlags::afFlag8000)) { - if (p_global->_phaseNum == 304 || p_global->_phaseNum != 384) //TODO: wha + if (_globals->_phaseNum == 304 || _globals->_phaseNum != 384) //TODO: wha handleEloiReturn(); area->_flags |= AreaFlags::afFlag8000; } - p_global->_roomCharacterPtr->_flags |= PersonFlags::pf80; - p_global->_citadelAreaNum = p_global->_areaNum; + _globals->_roomCharacterPtr->_flags |= PersonFlags::pf80; + _globals->_citadelAreaNum = _globals->_areaNum; naitredino(1); - removeInfo(p_global->_areaNum + ValleyNews::vnCitadelLost); - removeInfo(p_global->_areaNum + ValleyNews::vnTyrannLost); - if (p_global->_phaseNum == 193 && p_global->_areaNum == Areas::arUluru) + removeInfo(_globals->_areaNum + ValleyNews::vnCitadelLost); + removeInfo(_globals->_areaNum + ValleyNews::vnTyrannLost); + if (_globals->_phaseNum == 193 && _globals->_areaNum == Areas::arUluru) bigphase1(); } void EdenGame::citatombe(char level) { if (level) - newCitadel(p_global->_citadelAreaNum, level, p_global->_curAreaPtr->_citadelRoomPtr); + newCitadel(_globals->_citadelAreaNum, level, _globals->_curAreaPtr->_citadelRoomPtr); else { - destroyCitadelRoom(p_global->_citadelAreaNum << 8); - addInfo(p_global->_citadelAreaNum + ValleyNews::vnCitadelLost); + destroyCitadelRoom(_globals->_citadelAreaNum << 8); + addInfo(_globals->_citadelAreaNum + ValleyNews::vnCitadelLost); } } void EdenGame::constcita() { // Room *room = p_global->_curAreaPtr->_citadelRoomPtr; //TODO: wrong? chk below // byte id = room->_location; - if (!p_global->_curAreaPtr->_citadelLevel || !p_global->_curAreaPtr->_citadelRoomPtr) + if (!_globals->_curAreaPtr->_citadelLevel || !_globals->_curAreaPtr->_citadelRoomPtr) return; - Room *room = p_global->_curAreaPtr->_citadelRoomPtr; //TODO: copied here by me + Room *room = _globals->_curAreaPtr->_citadelRoomPtr; //TODO: copied here by me byte loc = room->_location; _tyranPtr = &kPersons[PER_UNKN_372]; - if (istyran((p_global->_citadelAreaNum << 8) | loc)) { - if (!(p_global->_curAreaPtr->_flags & AreaFlags::TyrannSighted)) { - addInfo(p_global->_citadelAreaNum + ValleyNews::vnTyrannIn); - p_global->_curAreaPtr->_flags |= AreaFlags::TyrannSighted; + if (istyran((_globals->_citadelAreaNum << 8) | loc)) { + if (!(_globals->_curAreaPtr->_flags & AreaFlags::TyrannSighted)) { + addInfo(_globals->_citadelAreaNum + ValleyNews::vnTyrannIn); + _globals->_curAreaPtr->_flags |= AreaFlags::TyrannSighted; } byte level = room->_level - 1; if (level < 32) @@ -1983,7 +1982,7 @@ void EdenGame::constcita() { room->_level = level; citatombe(level); } else { - p_global->_curAreaPtr->_flags &= ~AreaFlags::TyrannSighted; + _globals->_curAreaPtr->_flags &= ~AreaFlags::TyrannSighted; evolveCitadel(room->_level + 1); } } @@ -2043,7 +2042,7 @@ void EdenGame::moveDino(perso_t *perso) { // Original name: deplaalldino void EdenGame::moveAllDino() { for (perso_t *perso = &kPersons[PER_UNKN_18C]; perso->_roomNum != 0xFFFF; perso++) { - if (((perso->_roomNum >> 8) & 0xFF) != p_global->_citadelAreaNum) + if (((perso->_roomNum >> 8) & 0xFF) != _globals->_citadelAreaNum) continue; if (perso->_flags & PersonFlags::pf80) continue; @@ -2052,7 +2051,7 @@ void EdenGame::moveAllDino() { if (--perso->_steps) continue; perso->_steps = 1; - if (perso->_roomNum == p_global->_roomNum) + if (perso->_roomNum == _globals->_roomNum) continue; perso->_steps = perso->_speed; moveDino(perso); @@ -2075,12 +2074,12 @@ void EdenGame::newValley() { } perso->_roomNum = 0xFFFF; kAreasTable[7]._flags |= AreaFlags::HasTyrann; - p_global->_worldHasTyran = 32; + _globals->_worldHasTyran = 32; } char EdenGame::whereIsCita() { char res = -1; - for (Room *room = p_global->_citaAreaFirstRoom; room->_id != 0xFF; room++) { + for (Room *room = _globals->_citaAreaFirstRoom; room->_id != 0xFF; room++) { if (!(room->_flags & RoomFlags::rfHasCitadel)) continue; res = room->_location; @@ -2091,7 +2090,7 @@ char EdenGame::whereIsCita() { bool EdenGame::isCita(int16 loc) { loc &= 0xFF; - for (Room *room = p_global->_citaAreaFirstRoom; room->_id != 0xFF; room++) { + for (Room *room = _globals->_citaAreaFirstRoom; room->_id != 0xFF; room++) { if (!(room->_flags & RoomFlags::rfHasCitadel)) continue; if (room->_location == loc + 16) @@ -2112,41 +2111,41 @@ void EdenGame::placeVava(Area *area) { istyranval(area); area->_citadelLevel = 0; if (area->_citadelRoomPtr) - area->_citadelLevel = p_global->_citaAreaFirstRoom->_level; //TODO: no search? + area->_citadelLevel = _globals->_citaAreaFirstRoom->_level; //TODO: no search? byte mask = ~(1 << (area->_num - Areas::arChamaar)); - p_global->_worldTyranSighted &= mask; - p_global->_var4E &= mask; - p_global->_worldGaveGold &= mask; - p_global->_worldHasVelociraptors &= mask; - p_global->_worldHasTriceraptors &= mask; - p_global->_worldHasTyran &= mask; - p_global->_var53 &= mask; + _globals->_worldTyranSighted &= mask; + _globals->_var4E &= mask; + _globals->_worldGaveGold &= mask; + _globals->_worldHasVelociraptors &= mask; + _globals->_worldHasTriceraptors &= mask; + _globals->_worldHasTyran &= mask; + _globals->_var53 &= mask; mask = ~mask; if (area->_flags & AreaFlags::TyrannSighted) - p_global->_worldTyranSighted |= mask; + _globals->_worldTyranSighted |= mask; if (area->_flags & AreaFlags::afFlag4) - p_global->_var4E |= mask; + _globals->_var4E |= mask; if (area->_flags & AreaFlags::HasTriceraptors) - p_global->_worldHasTriceraptors |= mask; + _globals->_worldHasTriceraptors |= mask; if (area->_flags & AreaFlags::afGaveGold) - p_global->_worldGaveGold |= mask; + _globals->_worldGaveGold |= mask; if (area->_flags & AreaFlags::HasVelociraptors) - p_global->_worldHasVelociraptors |= mask; + _globals->_worldHasVelociraptors |= mask; if (area->_flags & AreaFlags::HasTyrann) - p_global->_worldHasTyran |= mask; + _globals->_worldHasTyran |= mask; if (area->_flags & AreaFlags::afFlag20) - p_global->_var53 |= mask; - if (area == p_global->_areaPtr) { - p_global->_curAreaFlags = area->_flags; - p_global->_curCitadelLevel = area->_citadelLevel; + _globals->_var53 |= mask; + if (area == _globals->_areaPtr) { + _globals->_curAreaFlags = area->_flags; + _globals->_curCitadelLevel = area->_citadelLevel; } } - p_global->_var4D &= p_global->_worldTyranSighted; + _globals->_var4D &= _globals->_worldTyranSighted; } void EdenGame::vivredino() { for (perso_t *perso = &kPersons[PER_UNKN_18C]; perso->_roomNum != 0xFFFF; perso++) { - if (((perso->_roomNum >> 8) & 0xFF) != p_global->_citadelAreaNum) + if (((perso->_roomNum >> 8) & 0xFF) != _globals->_citadelAreaNum) continue; if (perso->_flags & PersonFlags::pf80) continue; @@ -2179,7 +2178,7 @@ void EdenGame::vivredino() { break; case PersonFlags::pftVelociraptor: if (perso->_flags & PersonFlags::pf10) { - if (perso->_roomNum == p_global->_roomNum) { + if (perso->_roomNum == _globals->_roomNum) { perso_t *perso2 = &kPersons[PER_UNKN_372]; bool found = false; for (; perso2->_roomNum != 0xFFFF; perso2++) { @@ -2197,21 +2196,21 @@ void EdenGame::vivredino() { } else { _tyranPtr = &kPersons[PER_UNKN_372]; if (istyran(perso->_roomNum)) { - if (p_global->_phaseNum < 481 && (perso->_powers & (1 << (p_global->_citadelAreaNum - 3)))) { + if (_globals->_phaseNum < 481 && (perso->_powers & (1 << (_globals->_citadelAreaNum - 3)))) { _tyranPtr->_flags |= PersonFlags::pf80; _tyranPtr->_roomNum = 0; perso->_flags &= ~PersonFlags::pf10; perso->_flags |= PersonFlags::pfInParty; - addInfo(p_global->_citadelAreaNum + ValleyNews::vnTyrannLost); - removeInfo(p_global->_citadelAreaNum + ValleyNews::vnTyrannIn); + addInfo(_globals->_citadelAreaNum + ValleyNews::vnTyrannLost); + removeInfo(_globals->_citadelAreaNum + ValleyNews::vnTyrannIn); if (naitredino(PersonFlags::pftTriceraptor)) - addInfo(p_global->_citadelAreaNum + ValleyNews::vnTriceraptorsIn); + addInfo(_globals->_citadelAreaNum + ValleyNews::vnTriceraptorsIn); constcita(); - p_global->_curAreaPtr->_flags &= ~AreaFlags::TyrannSighted; + _globals->_curAreaPtr->_flags &= ~AreaFlags::TyrannSighted; } else { perso->_flags &= ~PersonFlags::pf10; perso->_flags &= ~PersonFlags::pfInParty; - addInfo(p_global->_citadelAreaNum + ValleyNews::vnVelociraptorsLost); + addInfo(_globals->_citadelAreaNum + ValleyNews::vnVelociraptorsLost); } continue; } @@ -2234,18 +2233,18 @@ void EdenGame::vivredino() { } void EdenGame::vivreval(int16 areaNum) { - p_global->_citadelAreaNum = areaNum; - p_global->_curAreaPtr = &kAreasTable[areaNum - 1]; - p_global->_citaAreaFirstRoom = &_gameRooms[p_global->_curAreaPtr->_firstRoomIdx]; + _globals->_citadelAreaNum = areaNum; + _globals->_curAreaPtr = &kAreasTable[areaNum - 1]; + _globals->_citaAreaFirstRoom = &_gameRooms[_globals->_curAreaPtr->_firstRoomIdx]; moveAllDino(); constcita(); vivredino(); newMushroom(); newNestWithEggs(); newEmptyNest(); - if (p_global->_phaseNum >= 226) + if (_globals->_phaseNum >= 226) newor(); - placeVava(p_global->_curAreaPtr); + placeVava(_globals->_curAreaPtr); } void EdenGame::chaquejour() { @@ -2255,22 +2254,22 @@ void EdenGame::chaquejour() { vivreval(6); vivreval(7); vivreval(8); - p_global->_drawFlags |= DrawFlags::drDrawTopScreen; + _globals->_drawFlags |= DrawFlags::drDrawTopScreen; } void EdenGame::temps_passe(int16 t) { - int16 days = p_global->_gameDays; - int16 lo = p_global->_gameHours + t; + int16 days = _globals->_gameDays; + int16 lo = _globals->_gameHours + t; if (lo > 255) { days++; lo &= 0xFF; } - p_global->_gameHours = lo; + _globals->_gameHours = lo; t = ((t >> 8) & 0xFF) + days; - t -= p_global->_gameDays; + t -= _globals->_gameDays; if (t) { - p_global->_gameDays += t; + _globals->_gameDays += t; while (t--) chaquejour(); } @@ -2281,8 +2280,8 @@ void EdenGame::heurepasse() { } void EdenGame::anim_perso() { - if (_curBankNum != p_global->_characterImageBank) - loadCharacter(p_global->_characterPtr); + if (_curBankNum != _globals->_characterImageBank) + loadCharacter(_globals->_characterPtr); restoreUnderSubtitles(); if (_restartAnimation) { _lastAnimTicks = _vm->_timerTicks; @@ -2291,21 +2290,21 @@ void EdenGame::anim_perso() { _curAnimFrameNumb = (_vm->_timerTicks - _lastAnimTicks) >> 2; // TODO: check me!!! if (_curAnimFrameNumb > _numAnimFrames) // TODO: bug? _animateTalking = false; - if (p_global->_curCharacterAnimPtr && !p_global->_animationFlags && _curAnimFrameNumb != _lastAnimFrameNumb) { + if (_globals->_curCharacterAnimPtr && !_globals->_animationFlags && _curAnimFrameNumb != _lastAnimFrameNumb) { _lastAnimFrameNumb = _curAnimFrameNumb; - if (*p_global->_curCharacterAnimPtr == 0xFF) + if (*_globals->_curCharacterAnimPtr == 0xFF) getanimrnd(); useCharacterBank(); _numImgDesc = 0; - perso_spr(p_global->_curCharacterAnimPtr); - p_global->_curCharacterAnimPtr += _numImgDesc + 1; + perso_spr(_globals->_curCharacterAnimPtr); + _globals->_curCharacterAnimPtr += _numImgDesc + 1; _mouthAnimations = _imageDesc + 200; removeMouthSprite(); if (*_mouthAnimations) displayImage(); _animationDelay--; if (!_animationDelay) { //TODO: combine - p_global->_animationFlags = 1; + _globals->_animationFlags = 1; _animationDelay = 8; } } @@ -2317,7 +2316,7 @@ void EdenGame::anim_perso() { } if (_animateTalking) { if (!_animationTable) { - _animationTable = gameLipsync + 7262; //TODO: fix me + _animationTable = _gameLipsync + 7262; //TODO: fix me if (!_backgroundSaved) sauvefondbouche(); } @@ -2330,7 +2329,7 @@ void EdenGame::anim_perso() { useCharacterBank(); restaurefondbouche(); // debug("perso spr %d", animationIndex); - perso_spr(p_global->_persoSpritePtr2 + _animationIndex * 2); //TODO: int16s? + perso_spr(_globals->_persoSpritePtr2 + _animationIndex * 2); //TODO: int16s? _mouthAnimations = _imageDesc + 200; if (*_mouthAnimations) displayImage(); @@ -2343,33 +2342,33 @@ void EdenGame::anim_perso() { void EdenGame::getanimrnd() { _animationDelay = 8; int16 rnd = _vm->_rnd->getRandomNumber(65535) & (byte)~0x18; //TODO - dword_30724 = p_global->_persoSpritePtr + 16; //TODO - p_global->_curCharacterAnimPtr = p_global->_persoSpritePtr + ((dword_30724[1] << 8) + dword_30724[0]); - p_global->_animationFlags = 1; + dword_30724 = _globals->_persoSpritePtr + 16; //TODO + _globals->_curCharacterAnimPtr = _globals->_persoSpritePtr + ((dword_30724[1] << 8) + dword_30724[0]); + _globals->_animationFlags = 1; if (rnd >= 8) return; - p_global->_animationFlags = 0; + _globals->_animationFlags = 0; if (rnd <= 0) return; for (rnd *= 8; rnd > 0; rnd--) { - while (*p_global->_curCharacterAnimPtr) - p_global->_curCharacterAnimPtr++; - p_global->_curCharacterAnimPtr++; + while (*_globals->_curCharacterAnimPtr) + _globals->_curCharacterAnimPtr++; + _globals->_curCharacterAnimPtr++; } } void EdenGame::addanim() { _lastAnimationIndex = 0xFF; _lastAnimTicks = 0; - p_global->_animationFlags = 0xC0; - p_global->_curCharacterAnimPtr = p_global->_persoSpritePtr; + _globals->_animationFlags = 0xC0; + _globals->_curCharacterAnimPtr = _globals->_persoSpritePtr; getanimrnd(); _animationActive = true; - if (p_global->_characterPtr == &kPersons[PER_KING]) + if (_globals->_characterPtr == &kPersons[PER_KING]) return; - perso_spr(p_global->_persoSpritePtr + READ_LE_UINT16(p_global->_persoSpritePtr)); //TODO: GetElem(0) + perso_spr(_globals->_persoSpritePtr + READ_LE_UINT16(_globals->_persoSpritePtr)); //TODO: GetElem(0) _mouthAnimations = _imageDesc + 200; - if (p_global->_characterPtr->_id != PersonId::pidCabukaOfCantura && p_global->_characterPtr->_targetLoc != 7) //TODO: targetLoc is minisprite idx + if (_globals->_characterPtr->_id != PersonId::pidCabukaOfCantura && _globals->_characterPtr->_targetLoc != 7) //TODO: targetLoc is minisprite idx removeMouthSprite(); if (*_mouthAnimations) displayImage(); @@ -2399,7 +2398,7 @@ void EdenGame::removeMouthSprite() { } void EdenGame::anim_perfin() { - p_global->_animationFlags &= ~0x80; + _globals->_animationFlags &= ~0x80; _animationDelay = 0; _animationActive = false; } @@ -2424,7 +2423,7 @@ void EdenGame::perso_spr(byte *spr) { if (index > _maxPersoDesc) index = _maxPersoDesc; index *= 2; //TODO: src = GetElem(ff_C2, index) - src = p_global->_varC2; + src = _globals->_varC2; src += READ_LE_UINT16(src + index); while ((c = *src++)) { *img++ = c; @@ -2538,7 +2537,7 @@ void EdenGame::displayImage() { } void EdenGame::af_perso1() { - perso_spr(p_global->_persoSpritePtr + READ_LE_UINT16(p_global->_persoSpritePtr)); + perso_spr(_globals->_persoSpritePtr + READ_LE_UINT16(_globals->_persoSpritePtr)); displayImage(); } @@ -2548,7 +2547,7 @@ void EdenGame::af_perso() { } void EdenGame::ef_perso() { - p_global->_animationFlags &= 0x3F; + _globals->_animationFlags &= 0x3F; } // Original name: load_perso @@ -2557,12 +2556,12 @@ void EdenGame::loadCharacter(perso_t *perso) { if (!perso->_spriteBank) return; - if (perso->_spriteBank != p_global->_characterImageBank) { + if (perso->_spriteBank != _globals->_characterImageBank) { _curPersoRect = &perso_rects[perso->_id]; //TODO: array of int16? dword_30728 = tab_persxx[perso->_id]; ef_perso(); - p_global->_characterImageBank = perso->_spriteBank; - useBank(p_global->_characterImageBank); + _globals->_characterImageBank = perso->_spriteBank; + useBank(_globals->_characterImageBank); _characterBankData = _bankData; byte *ptr = _bankData; ptr += READ_LE_UINT16(ptr); @@ -2574,35 +2573,35 @@ void EdenGame::loadCharacter(perso_t *perso) { _gameIcons[0].ex = READ_LE_UINT16(ptr + 4); _gameIcons[0].ey = READ_LE_UINT16(ptr + 6); ptr += 8; - p_global->_varC2 = ptr + 2; + _globals->_varC2 = ptr + 2; _maxPersoDesc = READ_LE_UINT16(ptr) / 2; ptr += READ_LE_UINT16(ptr); baseptr = ptr; ptr += READ_LE_UINT16(ptr) - 2; - p_global->_persoSpritePtr = baseptr; - p_global->_persoSpritePtr2 = baseptr + READ_LE_UINT16(ptr); - debug("load perso: b6 len is %ld", p_global->_persoSpritePtr2 - p_global->_persoSpritePtr); + _globals->_persoSpritePtr = baseptr; + _globals->_persoSpritePtr2 = baseptr + READ_LE_UINT16(ptr); + debug("load perso: b6 len is %ld", _globals->_persoSpritePtr2 - _globals->_persoSpritePtr); } else { - useBank(p_global->_characterImageBank); + useBank(_globals->_characterImageBank); _characterBankData = _bankData; } } void EdenGame::load_perso_cour() { - loadCharacter(p_global->_characterPtr); + loadCharacter(_globals->_characterPtr); } void EdenGame::fin_perso() { - p_global->_animationFlags &= 0x3F; - p_global->_curCharacterAnimPtr = nullptr; - p_global->_varCA = 0; - p_global->_characterImageBank = -1; + _globals->_animationFlags &= 0x3F; + _globals->_curCharacterAnimPtr = nullptr; + _globals->_varCA = 0; + _globals->_characterImageBank = -1; anim_perfin(); } void EdenGame::no_perso() { - if (p_global->_displayFlags == DisplayFlags::dfPerson) { - p_global->_displayFlags = p_global->_oldDisplayFlags; + if (_globals->_displayFlags == DisplayFlags::dfPerson) { + _globals->_displayFlags = _globals->_oldDisplayFlags; fin_perso(); } endCharacterSpeech(); @@ -2611,59 +2610,59 @@ void EdenGame::no_perso() { // Original name: close_perso void EdenGame::closeCharacterScreen() { endCharacterSpeech(); - if (p_global->_displayFlags == DisplayFlags::dfPerson && p_global->_characterPtr->_id != PersonId::pidNarrator && p_global->_eventType != EventType::etEventE) { + if (_globals->_displayFlags == DisplayFlags::dfPerson && _globals->_characterPtr->_id != PersonId::pidNarrator && _globals->_eventType != EventType::etEventE) { rundcurs(); _savedUnderSubtitles = true; restoreUnderSubtitles(); display(); - p_global->_var103 = 16; - } - if (p_global->_characterPtr->_id == PersonId::pidNarrator) - p_global->_var103 = 69; - p_global->_eloiHaveNews &= 1; - p_global->_varCA = 0; - p_global->_varF6 = 0; - if (p_global->_displayFlags == DisplayFlags::dfPerson) { - p_global->_displayFlags = p_global->_oldDisplayFlags; - p_global->_animationFlags &= 0x3F; - p_global->_curCharacterAnimPtr = nullptr; + _globals->_var103 = 16; + } + if (_globals->_characterPtr->_id == PersonId::pidNarrator) + _globals->_var103 = 69; + _globals->_eloiHaveNews &= 1; + _globals->_varCA = 0; + _globals->_varF6 = 0; + if (_globals->_displayFlags == DisplayFlags::dfPerson) { + _globals->_displayFlags = _globals->_oldDisplayFlags; + _globals->_animationFlags &= 0x3F; + _globals->_curCharacterAnimPtr = nullptr; anim_perfin(); - if (p_global->_displayFlags & DisplayFlags::dfMirror) { + if (_globals->_displayFlags & DisplayFlags::dfMirror) { gameToMirror(1); _scrollPos = _oldScrollPos; scroll(); return; } - if (p_global->_numGiveObjs) { - if (!(p_global->_displayFlags & DisplayFlags::dfFlag2)) + if (_globals->_numGiveObjs) { + if (!(_globals->_displayFlags & DisplayFlags::dfFlag2)) showObjects(); - p_global->_numGiveObjs = 0; + _globals->_numGiveObjs = 0; } - if (p_global->_varF2 & 1) { - p_global->_mirrorEffect = 6; // CHECKME: Verify the value - p_global->_varF2 &= ~1; + if (_globals->_varF2 & 1) { + _globals->_mirrorEffect = 6; // CHECKME: Verify the value + _globals->_varF2 &= ~1; } - char oldLoc = p_global->_newLocation; - p_global->_newLocation = 0; - if (!(p_global->_narratorSequence & 0x80)) - p_global->_var100 = 0xFF; - updateRoom(p_global->_roomNum); - p_global->_newLocation = oldLoc; + char oldLoc = _globals->_newLocation; + _globals->_newLocation = 0; + if (!(_globals->_narratorSequence & 0x80)) + _globals->_var100 = 0xFF; + updateRoom(_globals->_roomNum); + _globals->_newLocation = oldLoc; } - if (p_global->_chrono) - p_global->_chronoFlag = 1; + if (_globals->_chrono) + _globals->_chronoFlag = 1; } // Original name: af_fondsuiveur void EdenGame::displayBackgroundFollower() { - char id = p_global->_characterPtr->_id; + char id = _globals->_characterPtr->_id; for (Follower *follower = followerList; follower->_id != -1; follower++) { if (follower->_id == id) { int bank = 326; if (follower->sx >= 320) bank = 327; - useBank(bank + p_global->_roomBackgroundBankNum); + useBank(bank + _globals->_roomBackgroundBankNum); noclipax_avecnoir(0, 0, 16); break; } @@ -2674,27 +2673,27 @@ void EdenGame::displayBackgroundFollower() { void EdenGame::displayCharacterBackground1() { byte bank; char *ptab; - if (p_global->_characterPtr == &kPersons[PER_MESSENGER]) { + if (_globals->_characterPtr == &kPersons[PER_MESSENGER]) { _gameIcons[0].sx = 0; perso_rects[PER_MESSENGER].left = 2; - bank = p_global->_characterBackgroundBankIdx; - if (p_global->_eventType == EventType::etEventE) { - p_global->_var103 = 1; + bank = _globals->_characterBackgroundBankIdx; + if (_globals->_eventType == EventType::etEventE) { + _globals->_var103 = 1; goto no_suiveur; } _gameIcons[0].sx = 60; perso_rects[PER_MESSENGER].left = 62; } - if (p_global->_characterPtr == &kPersons[PER_THOO]) { + if (_globals->_characterPtr == &kPersons[PER_THOO]) { bank = 37; - if (p_global->_curObjectId == Objects::obShell) + if (_globals->_curObjectId == Objects::obShell) goto no_suiveur; } - ptab = kPersoRoomBankTable + p_global->_characterPtr->_roomBankId; + ptab = kPersoRoomBankTable + _globals->_characterPtr->_roomBankId; bank = *ptab++; - if (!(p_global->_characterPtr->_partyMask & p_global->_party)) { + if (!(_globals->_characterPtr->_partyMask & _globals->_party)) { while ((bank = *ptab++) != 0xFF) { - if (bank == (p_global->_roomNum & 0xFF)) { //TODO: signed vs unsigned - chg r31 to uns? + if (bank == (_globals->_roomNum & 0xFF)) { //TODO: signed vs unsigned - chg r31 to uns? bank = *ptab; break; } @@ -2702,7 +2701,7 @@ void EdenGame::displayCharacterBackground1() { } if (bank != 0xFF) goto no_suiveur; - ptab = kPersoRoomBankTable + p_global->_characterPtr->_roomBankId; + ptab = kPersoRoomBankTable + _globals->_characterPtr->_roomBankId; bank = *ptab++; } displayBackgroundFollower(); @@ -2710,7 +2709,7 @@ no_suiveur: ; if (bank) { useBank(bank); - if (p_global->_characterPtr == &kPersons[PER_UNKN_156]) + if (_globals->_characterPtr == &kPersons[PER_UNKN_156]) noclipax_avecnoir(0, 0, 16); else noclipax(0, 0, 16); @@ -2719,7 +2718,7 @@ no_suiveur: // Original name: af_fondperso void EdenGame::displayCharacterBackground() { - if (p_global->_characterPtr->_spriteBank) { + if (_globals->_characterPtr->_spriteBank) { _backgroundSaved = false; displayCharacterBackground1(); } @@ -2727,11 +2726,11 @@ void EdenGame::displayCharacterBackground() { // Original name: setpersoicon void EdenGame::setCharacterIcon() { - if (p_global->_iconsIndex == 4) + if (_globals->_iconsIndex == 4) return; - if (p_global->_characterPtr == &kPersons[PER_MESSENGER] && p_global->_eventType == EventType::etEventE) { - p_global->_iconsIndex = 123; + if (_globals->_characterPtr == &kPersons[PER_MESSENGER] && _globals->_eventType == EventType::etEventE) { + _globals->_iconsIndex = 123; return; } Icon *icon = _gameIcons; @@ -2744,18 +2743,18 @@ void EdenGame::setCharacterIcon() { // Original name: show_perso void EdenGame::showCharacter() { - perso_t *perso = p_global->_characterPtr; + perso_t *perso = _globals->_characterPtr; if (perso->_spriteBank) { closeRoom(); - if (p_global->_displayFlags != DisplayFlags::dfPerson) { - if (p_global->_displayFlags & DisplayFlags::dfMirror) + if (_globals->_displayFlags != DisplayFlags::dfPerson) { + if (_globals->_displayFlags & DisplayFlags::dfMirror) resetScroll(); - p_global->_oldDisplayFlags = p_global->_displayFlags; - p_global->_displayFlags = DisplayFlags::dfPerson; + _globals->_oldDisplayFlags = _globals->_displayFlags; + _globals->_displayFlags = DisplayFlags::dfPerson; loadCharacter(perso); setCharacterIcon(); displayCharacterBackground(); - if (perso == &kPersons[PER_THOO] && p_global->_curObjectId == Objects::obShell) { + if (perso == &kPersons[PER_THOO] && _globals->_curObjectId == Objects::obShell) { displaySubtitles(); updateCursor(); _paletteUpdateRequired = true; @@ -2766,7 +2765,7 @@ void EdenGame::showCharacter() { } load_perso_cour(); addanim(); - if (!p_global->_curCharacterAnimPtr) { + if (!_globals->_curCharacterAnimPtr) { af_perso(); displaySubtitles(); } @@ -2786,16 +2785,16 @@ void EdenGame::showCharacter() { // Original name: showpersopanel void EdenGame::displayCharacterPanel() { - perso_t *perso = p_global->_characterPtr; + perso_t *perso = _globals->_characterPtr; load_perso_cour(); addanim(); - if (!p_global->_curCharacterAnimPtr) { + if (!_globals->_curCharacterAnimPtr) { af_perso(); displaySubtitles(); } _restartAnimation = true; _paletteUpdateRequired = true; - if (p_global->_drawFlags & DrawFlags::drDrawFlag8) + if (_globals->_drawFlags & DrawFlags::drDrawFlag8) return; anim_perso(); if (perso != &kPersons[PER_UNKN_156]) @@ -2803,15 +2802,15 @@ void EdenGame::displayCharacterPanel() { display(); if (perso != &kPersons[PER_UNKN_156]) rundcurs(); - p_global->_drawFlags |= DrawFlags::drDrawFlag8; - p_global->_iconsIndex = 112; + _globals->_drawFlags |= DrawFlags::drDrawFlag8; + _globals->_iconsIndex = 112; } void EdenGame::getDataSync() { - int16 num = p_global->_textNum; - if (p_global->_textBankIndex != 1) + int16 num = _globals->_textNum; + if (_globals->_textBankIndex != 1) num += 565; - if (p_global->_textBankIndex == 3) + if (_globals->_textBankIndex == 3) num += 707; if (num == 144) num = 142; @@ -2820,7 +2819,7 @@ void EdenGame::getDataSync() { _numAnimFrames = readFrameNumber(); else _numAnimFrames = 0; - if (p_global->_textNum == 144) + if (_globals->_textNum == 144) _numAnimFrames = 48; _animationTable = 0; } @@ -2828,7 +2827,7 @@ void EdenGame::getDataSync() { // Original name: ReadNombreFrames int16 EdenGame::readFrameNumber() { int16 num = 0; - _animationTable = gameLipsync + 7260 + 2; //TODO: fix me + _animationTable = _gameLipsync + 7260 + 2; //TODO: fix me while (*_animationTable++ != 0xFF) num++; return num; @@ -2858,18 +2857,18 @@ void EdenGame::waitEndSpeak() { } void EdenGame::my_bulle() { - if (!p_global->_textNum) + if (!_globals->_textNum) return; byte *icons = phraseIconsBuffer; byte *linesp = _sentenceCoordsBuffer; byte *sentencePtr = _sentenceBuffer; - p_global->_numGiveObjs = 0; - p_global->_giveObj1 = 0; - p_global->_giveObj2 = 0; - p_global->_giveObj3 = 0; - p_global->_textWidthLimit = _subtitlesXWidth; - byte *textPtr = gettxtad(p_global->_textNum); + _globals->_numGiveObjs = 0; + _globals->_giveObj1 = 0; + _globals->_giveObj2 = 0; + _globals->_giveObj3 = 0; + _globals->_textWidthLimit = _subtitlesXWidth; + byte *textPtr = gettxtad(_globals->_textNum); _numTextLines = 0; int16 words_on_line = 0; int16 word_width = 0; @@ -2877,9 +2876,9 @@ void EdenGame::my_bulle() { byte c; while ((c = *textPtr++) != 0xFF) { if (c == 0x11 || c == 0x13) { - if (p_global->_phaseNum <= 272 || p_global->_phaseNum == 386) { - p_global->_eloiHaveNews = c & 0xF; - p_global->_var4D = p_global->_worldTyranSighted; + if (_globals->_phaseNum <= 272 || _globals->_phaseNum == 386) { + _globals->_eloiHaveNews = c & 0xF; + _globals->_var4D = _globals->_worldTyranSighted; } } else if (c >= 0x80 && c < 0x90) SysBeep(1); @@ -2887,31 +2886,31 @@ void EdenGame::my_bulle() { while (*textPtr++ != 0xFF) ; textPtr--; } else if (c >= 0xA0 && c < 0xC0) - p_global->_textToken1 = c & 0xF; + _globals->_textToken1 = c & 0xF; else if (c >= 0xC0 && c < 0xD0) - p_global->_textToken2 = c & 0xF; + _globals->_textToken2 = c & 0xF; else if (c >= 0xD0 && c < 0xE0) { byte c1 = *textPtr++; if (c == 0xD2) #ifdef FAKE_DOS_VERSION - p_global->_textWidthLimit = c1 + 160; + _globals->_textWidthLimit = c1 + 160; #else - p_global->_textWidthLimit = c1 + _subtitlesXCenter; //TODO: signed? 160 in pc ver + _globals->_textWidthLimit = c1 + _subtitlesXCenter; //TODO: signed? 160 in pc ver #endif else { byte c2 = *textPtr++; - switch (p_global->_numGiveObjs) { + switch (_globals->_numGiveObjs) { case 0: - p_global->_giveObj1 = c2; + _globals->_giveObj1 = c2; break; case 1: - p_global->_giveObj2 = c2; + _globals->_giveObj2 = c2; break; case 2: - p_global->_giveObj3 = c2; + _globals->_giveObj3 = c2; break; } - p_global->_numGiveObjs++; + _globals->_numGiveObjs++; *icons++ = *textPtr++; *icons++ = *textPtr++; *icons++ = c2; @@ -2927,7 +2926,7 @@ void EdenGame::my_bulle() { #endif word_width += width; line_width += width; - int16 overrun = line_width - p_global->_textWidthLimit; + int16 overrun = line_width - _globals->_textWidthLimit; if (overrun > 0) { _numTextLines++; if (c != ' ') { @@ -2953,16 +2952,16 @@ void EdenGame::my_bulle() { *linesp++ = words_on_line + 1; *linesp++ = word_width; *sentencePtr = c; - if (p_global->_textBankIndex == 2 && p_global->_textNum == 101 && p_global->_prefLanguage == 1) + if (_globals->_textBankIndex == 2 && _globals->_textNum == 101 && _globals->_prefLanguage == 1) patchSentence(); my_pr_bulle(); - if (!p_global->_numGiveObjs) + if (!_globals->_numGiveObjs) return; useMainBank(); if (_numTextLines < 3) _numTextLines = 3; icons = phraseIconsBuffer; - for (byte i = 0; i < p_global->_numGiveObjs; i++) { + for (byte i = 0; i < _globals->_numGiveObjs; i++) { byte x = *icons++; byte y = *icons++; byte s = *icons++; @@ -2973,7 +2972,7 @@ void EdenGame::my_bulle() { void EdenGame::my_pr_bulle() { CLBlitter_FillView(_subtitlesView, 0); - if (p_global->_prefLanguage == 0) + if (_globals->_prefLanguage == 0) return; byte *coo = _sentenceCoordsBuffer; @@ -3002,7 +3001,7 @@ void EdenGame::my_pr_bulle() { } } else { int16 charWidth = _gameFont[c]; - if (!(p_global->_drawFlags & DrawFlags::drDrawMenu)) { + if (!(_globals->_drawFlags & DrawFlags::drDrawMenu)) { textout += _subtitlesXWidth; if (!_specialTextMode) drawSubtitleChar(c, 195, charWidth); @@ -3052,9 +3051,9 @@ void EdenGame::displaySubtitles() { byte *src = _subtitlesViewBuf; byte *dst = _mainViewBuf; int16 y; - if (p_global->_displayFlags & DisplayFlags::dfFlag2) { + if (_globals->_displayFlags & DisplayFlags::dfFlag2) { y = 174; - if ((p_global->_drawFlags & DrawFlags::drDrawMenu) && _numTextLines == 1) + if ((_globals->_drawFlags & DrawFlags::drDrawMenu) && _numTextLines == 1) y = 167; dst += 640 * (y - _numTextLines * FONT_HEIGHT) + _subtitlesXScrMargin; } else { @@ -3083,7 +3082,7 @@ void EdenGame::saveUnderSubtitles(int16 y) { _underSubtitlesScreenRect.bottom = y; _underSubtitlesBackupRect.top = 0; _underSubtitlesBackupRect.bottom = _numTextLines * FONT_HEIGHT; - CLBlitter_CopyViewRect(_mainView, p_underSubtitlesView, &_underSubtitlesScreenRect, &_underSubtitlesBackupRect); + CLBlitter_CopyViewRect(_mainView, _underSubtitlesView, &_underSubtitlesScreenRect, &_underSubtitlesBackupRect); _savedUnderSubtitles = true; } @@ -3091,7 +3090,7 @@ void EdenGame::saveUnderSubtitles(int16 y) { void EdenGame::restoreUnderSubtitles() { if (!_savedUnderSubtitles) return; - CLBlitter_CopyViewRect(p_underSubtitlesView, _mainView, &_underSubtitlesBackupRect, &_underSubtitlesScreenRect); + CLBlitter_CopyViewRect(_underSubtitlesView, _mainView, &_underSubtitlesBackupRect, &_underSubtitlesScreenRect); _savedUnderSubtitles = false; } @@ -3116,49 +3115,49 @@ void EdenGame::patchSentence() { } void EdenGame::vavapers() { - perso_t *perso = p_global->_characterPtr; - p_global->_curPersoFlags = perso->_flags; - p_global->_curPersoItems = perso->_items; - p_global->_curCharacterPowers = perso->_powers; + perso_t *perso = _globals->_characterPtr; + _globals->_curPersoFlags = perso->_flags; + _globals->_curPersoItems = perso->_items; + _globals->_curCharacterPowers = perso->_powers; } void EdenGame::citadelle() { - p_global->_var69++; - p_global->_varF6++; + _globals->_var69++; + _globals->_varF6++; parlemoiNormalFlag = true; _closeCharacterDialog = true; } void EdenGame::choixzone() { - if (p_global->_giveObj3) - p_global->_iconsIndex = 6; + if (_globals->_giveObj3) + _globals->_iconsIndex = 6; else - p_global->_iconsIndex = 10; - p_global->_autoDialog = false; + _globals->_iconsIndex = 10; + _globals->_autoDialog = false; putObject(); } void EdenGame::showEvents1() { - p_global->_var113 = 0; + _globals->_var113 = 0; perso_ici(3); } void EdenGame::showEvents() { - if (p_global->_eventType && p_global->_displayFlags != DisplayFlags::dfPerson) + if (_globals->_eventType && _globals->_displayFlags != DisplayFlags::dfPerson) showEvents1(); } void EdenGame::parle_mfin() { - perso_t *perso = p_global->_characterPtr; - if (p_global->_curObjectId) { - char curobj = p_global->_curObjectId; - if (p_global->_dialogType == DialogType::dtHint) + perso_t *perso = _globals->_characterPtr; + if (_globals->_curObjectId) { + char curobj = _globals->_curObjectId; + if (_globals->_dialogType == DialogType::dtHint) return; - object_t *obj = getObjectPtr(p_global->_curObjectId); - if (p_global->_dialogType == DialogType::dtDinoItem) - perso = p_global->_roomCharacterPtr; + object_t *obj = getObjectPtr(_globals->_curObjectId); + if (_globals->_dialogType == DialogType::dtDinoItem) + perso = _globals->_roomCharacterPtr; if (isAnswerYes()) { - loseObject(p_global->_curObjectId); + loseObject(_globals->_curObjectId); perso->_powers |= obj->_powerMask; } perso->_items |= obj->_itemMask; @@ -3168,20 +3167,20 @@ void EdenGame::parle_mfin() { if (!isAnswerYes()) return; nextInfo(); - if (!p_global->_lastInfo) + if (!_globals->_lastInfo) _closeCharacterDialog = true; else { - p_global->_nextDialogPtr = nullptr; + _globals->_nextDialogPtr = nullptr; _closeCharacterDialog = false; } } void EdenGame::parlemoi_normal() { dial_t *dial; - if (!p_global->_nextDialogPtr) { - perso_t *perso = p_global->_characterPtr; + if (!_globals->_nextDialogPtr) { + perso_t *perso = _globals->_characterPtr; if (perso) { - int16 num = (perso->_id << 3) | p_global->_dialogType; + int16 num = (perso->_id << 3) | _globals->_dialogType; dial = (dial_t *)getElem(_gameDialogs, num); } else { closeCharacterScreen(); @@ -3192,10 +3191,10 @@ void EdenGame::parlemoi_normal() { closeCharacterScreen(); return; } - dial = p_global->_nextDialogPtr; + dial = _globals->_nextDialogPtr; } char ok = dial_scan(dial); - p_global->_nextDialogPtr = p_global->_dialogPtr; + _globals->_nextDialogPtr = _globals->_dialogPtr; _closeCharacterDialog = false; if (!ok) closeCharacterScreen(); @@ -3205,27 +3204,27 @@ void EdenGame::parlemoi_normal() { void EdenGame::parle_moi() { endCharacterSpeech(); - byte r28 = p_global->_varF6; - p_global->_varF6 = 0; + byte r28 = _globals->_varF6; + _globals->_varF6 = 0; if (!r28) { setChoiceNo(); - if (p_global->_drawFlags & DrawFlags::drDrawInventory) + if (_globals->_drawFlags & DrawFlags::drDrawInventory) showObjects(); - if (p_global->_drawFlags & DrawFlags::drDrawTopScreen) + if (_globals->_drawFlags & DrawFlags::drDrawTopScreen) drawTopScreen(); - if (p_global->_curObjectId) { - if (p_global->_dialogType == DialogType::dtTalk) { - p_global->_dialogType = DialogType::dtItem; - p_global->_nextDialogPtr = nullptr; + if (_globals->_curObjectId) { + if (_globals->_dialogType == DialogType::dtTalk) { + _globals->_dialogType = DialogType::dtItem; + _globals->_nextDialogPtr = nullptr; _closeCharacterDialog = false; } parlemoi_normal(); return; } - if (p_global->_dialogType == DialogType::dtItem) { - p_global->_dialogType = DialogType::dtTalk; + if (_globals->_dialogType == DialogType::dtItem) { + _globals->_dialogType = DialogType::dtTalk; if (!_closeCharacterDialog) - p_global->_nextDialogPtr = nullptr; + _globals->_nextDialogPtr = nullptr; } if (parlemoiNormalFlag) { parlemoi_normal(); @@ -3233,22 +3232,22 @@ void EdenGame::parle_moi() { } dial_t *dial; - if (!p_global->_lastDialogPtr) { + if (!_globals->_lastDialogPtr) { int16 num = 160; - if (p_global->_phaseNum >= 400) + if (_globals->_phaseNum >= 400) num++; dial = (dial_t *)getElem(_gameDialogs, num); } else - dial = p_global->_lastDialogPtr; + dial = _globals->_lastDialogPtr; char ok = dial_scan(dial); - p_global->_lastDialogPtr = p_global->_dialogPtr; + _globals->_lastDialogPtr = _globals->_dialogPtr; parlemoiNormalFlag = false; if (!ok) { parlemoiNormalFlag = true; - if (p_global->_var60) { - if (p_global->_characterPtr == &kPersons[PER_MESSENGER]) { - p_global->_dialogType = DialogType::dtTalk; - if (p_global->_eloiHaveNews) + if (_globals->_var60) { + if (_globals->_characterPtr == &kPersons[PER_MESSENGER]) { + _globals->_dialogType = DialogType::dtTalk; + if (_globals->_eloiHaveNews) parlemoi_normal(); else closeCharacterScreen(); @@ -3263,27 +3262,27 @@ void EdenGame::parle_moi() { } void EdenGame::init_perso_ptr(perso_t *perso) { - p_global->_metPersonsMask1 |= perso->_partyMask; - p_global->_metPersonsMask2 |= perso->_partyMask; - p_global->_nextDialogPtr = nullptr; + _globals->_metPersonsMask1 |= perso->_partyMask; + _globals->_metPersonsMask2 |= perso->_partyMask; + _globals->_nextDialogPtr = nullptr; _closeCharacterDialog = false; dialogSkipFlags = DialogFlags::dfSpoken; - p_global->_var60 = 0; - p_global->_textToken1 = 0; + _globals->_var60 = 0; + _globals->_textToken1 = 0; } void EdenGame::perso1(perso_t *perso) { - p_global->_phaseActionsCount++; + _globals->_phaseActionsCount++; if (perso == &kPersons[PER_THOO]) - p_global->_phaseActionsCount--; - p_global->_characterPtr = perso; + _globals->_phaseActionsCount--; + _globals->_characterPtr = perso; init_perso_ptr(perso); parle_moi(); } void EdenGame::perso_normal(perso_t *perso) { - p_global->_lastDialogPtr = nullptr; - p_global->_dialogType = DialogType::dtTalk; + _globals->_lastDialogPtr = nullptr; + _globals->_dialogType = DialogType::dtTalk; parlemoiNormalFlag = false; perso1(perso); } @@ -3291,15 +3290,15 @@ void EdenGame::perso_normal(perso_t *perso) { // Original name: persoparle void EdenGame::handleCharacterDialog(int16 pers) { perso_t *perso = &kPersons[pers]; - p_global->_characterPtr = perso; - p_global->_dialogType = DialogType::dtInspect; - uint16 idx = perso->_id * 8 | p_global->_dialogType; + _globals->_characterPtr = perso; + _globals->_dialogType = DialogType::dtInspect; + uint16 idx = perso->_id * 8 | _globals->_dialogType; dialoscansvmas((dial_t *)getElem(_gameDialogs, idx)); displayPlace(); displaySubtitles(); persovox(); - p_global->_varCA = 0; - p_global->_dialogType = DialogType::dtTalk; + _globals->_varCA = 0; + _globals->_dialogType = DialogType::dtTalk; } // Original name: roi @@ -3351,7 +3350,7 @@ void EdenGame::actionAzia() { void EdenGame::actionMammi() { perso_t *perso; for (perso = &kPersons[PER_MAMMI]; perso->_partyMask == PersonMask::pmLeader; perso++) { - if (perso->_roomNum == p_global->_roomNum) { + if (perso->_roomNum == _globals->_roomNum) { perso_normal(perso); break; } @@ -3370,81 +3369,81 @@ void EdenGame::actionBamboo() { // Original name: kabuka void EdenGame::actionKabuka() { - if (p_global->_roomNum == 0x711) perso_normal(&kPersons[PER_KABUKA]); + if (_globals->_roomNum == 0x711) perso_normal(&kPersons[PER_KABUKA]); else actionBamboo(); } // Original name: fisher void EdenGame::actionFisher() { - if (p_global->_roomNum == 0x902) perso_normal(&kPersons[PER_FISHER]); + if (_globals->_roomNum == 0x902) perso_normal(&kPersons[PER_FISHER]); else actionKabuka(); } // Original name: dino void EdenGame::actionDino() { - perso_t *perso = p_global->_roomCharacterPtr; + perso_t *perso = _globals->_roomCharacterPtr; if (!perso) return; parlemoiNormalFlag = true; - p_global->_dialogType = DialogType::dtTalk; - p_global->_roomCharacterFlags = perso->_flags; - p_global->_roomPersoItems = perso->_items; - p_global->_roomCharacterPowers = perso->_powers; - p_global->_characterPtr = perso; + _globals->_dialogType = DialogType::dtTalk; + _globals->_roomCharacterFlags = perso->_flags; + _globals->_roomPersoItems = perso->_items; + _globals->_roomCharacterPowers = perso->_powers; + _globals->_characterPtr = perso; init_perso_ptr(perso); debug("beg dino talk"); parle_moi(); debug("end dino talk"); - if (p_global->_areaNum == Areas::arWhiteArch) + if (_globals->_areaNum == Areas::arWhiteArch) return; - if (p_global->_var60) + if (_globals->_var60) waitEndSpeak(); if (pomme_q) return; perso = &kPersons[PER_MANGO]; - if (!(p_global->_party & PersonMask::pmMungo)) { + if (!(_globals->_party & PersonMask::pmMungo)) { perso = &kPersons[PER_DINA]; - if (!(p_global->_party & PersonMask::pmDina)) { + if (!(_globals->_party & PersonMask::pmDina)) { perso = &kPersons[PER_EVE]; - if (!(p_global->_party & PersonMask::pmEve)) { + if (!(_globals->_party & PersonMask::pmEve)) { perso = &kPersons[PER_GUARDS]; } } } - p_global->_dialogType = DialogType::dtDinoAction; - if (p_global->_curObjectId) - p_global->_dialogType = DialogType::dtDinoItem; + _globals->_dialogType = DialogType::dtDinoAction; + if (_globals->_curObjectId) + _globals->_dialogType = DialogType::dtDinoItem; perso1(perso); - if (p_global->_roomCharacterType == PersonFlags::pftMosasaurus && !p_global->_curObjectId) { - p_global->_areaPtr->_flags |= AreaFlags::afFlag20; - placeVava(p_global->_areaPtr); + if (_globals->_roomCharacterType == PersonFlags::pftMosasaurus && !_globals->_curObjectId) { + _globals->_areaPtr->_flags |= AreaFlags::afFlag20; + placeVava(_globals->_areaPtr); } } // Original name: tyran void EdenGame::actionTyran() { - perso_t *perso = p_global->_roomCharacterPtr; + perso_t *perso = _globals->_roomCharacterPtr; if (!perso) return; parlemoiNormalFlag = true; - p_global->_dialogType = DialogType::dtTalk; - p_global->_roomCharacterFlags = perso->_flags; - p_global->_characterPtr = perso; + _globals->_dialogType = DialogType::dtTalk; + _globals->_roomCharacterFlags = perso->_flags; + _globals->_characterPtr = perso; init_perso_ptr(perso); perso = &kPersons[PER_MANGO]; - if (!(p_global->_party & PersonMask::pmMungo)) { + if (!(_globals->_party & PersonMask::pmMungo)) { perso = &kPersons[PER_DINA]; - if (!(p_global->_party & PersonMask::pmDina)) { + if (!(_globals->_party & PersonMask::pmDina)) { perso = &kPersons[PER_EVE]; - if (!(p_global->_party & PersonMask::pmEve)) { + if (!(_globals->_party & PersonMask::pmEve)) { perso = &kPersons[PER_GUARDS]; } } } - p_global->_dialogType = DialogType::dtDinoAction; - if (p_global->_curObjectId) - p_global->_dialogType = DialogType::dtDinoItem; + _globals->_dialogType = DialogType::dtDinoAction; + if (_globals->_curObjectId) + _globals->_dialogType = DialogType::dtDinoItem; perso1(perso); } @@ -3455,62 +3454,62 @@ void EdenGame::actionMorkus() { void EdenGame::comment() { perso_t *perso = &kPersons[PER_DINA]; - if (!(p_global->_party & PersonMask::pmDina)) { + if (!(_globals->_party & PersonMask::pmDina)) { perso = &kPersons[PER_EVE]; - if (!(p_global->_party & PersonMask::pmEve)) { + if (!(_globals->_party & PersonMask::pmEve)) { perso = &kPersons[PER_GUARDS]; - if (!(p_global->_party & PersonMask::pmThugg)) + if (!(_globals->_party & PersonMask::pmThugg)) return; } } - p_global->_dialogType = DialogType::dtHint; + _globals->_dialogType = DialogType::dtHint; perso1(perso); } // Original name: adam void EdenGame::actionAdam() { resetScroll(); - switch (p_global->_curObjectId) { + switch (_globals->_curObjectId) { case Objects::obNone: gotoPanel(); break; case Objects::obRoot: - if (p_global->_roomNum == 2817 - && p_global->_phaseNum > 496 && p_global->_phaseNum < 512) { + if (_globals->_roomNum == 2817 + && _globals->_phaseNum > 496 && _globals->_phaseNum < 512) { bigphase1(); loseObject(Objects::obRoot); - p_global->_var100 = 0xFF; + _globals->_var100 = 0xFF; quitMirror(); - updateRoom(p_global->_roomNum); + updateRoom(_globals->_roomNum); removeFromParty(PER_MESSENGER); - p_global->_eventType = EventType::etEvent3; + _globals->_eventType = EventType::etEvent3; showEvents(); waitEndSpeak(); if (pomme_q) return; closeCharacterScreen(); removeFromParty(PER_MESSENGER); - p_global->_roomNum = 2818; - p_global->_areaNum = Areas::arWhiteArch; - p_global->_eventType = EventType::etEvent5; - p_global->_valleyVidNum = 0; - p_global->_mirrorEffect = 6; // CHECKME: Verify the value - p_global->_newMusicType = MusicType::mtNormal; - updateRoom(p_global->_roomNum); + _globals->_roomNum = 2818; + _globals->_areaNum = Areas::arWhiteArch; + _globals->_eventType = EventType::etEvent5; + _globals->_valleyVidNum = 0; + _globals->_mirrorEffect = 6; // CHECKME: Verify the value + _globals->_newMusicType = MusicType::mtNormal; + updateRoom(_globals->_roomNum); } else { - p_global->_dialogType = DialogType::dtHint; + _globals->_dialogType = DialogType::dtHint; perso1(&kPersons[PER_EVE]); } break; case Objects::obShell: - p_global->_dialogType = DialogType::dtHint; + _globals->_dialogType = DialogType::dtHint; perso1(&kPersons[PER_THOO]); break; case Objects::obFlute: case Objects::obTrumpet: - if (p_global->_roomCharacterType) { + if (_globals->_roomCharacterType) { quitMirror(); - updateRoom(p_global->_roomNum); + updateRoom(_globals->_roomNum); actionDino(); } else comment(); @@ -3521,10 +3520,10 @@ void EdenGame::actionAdam() { case Objects::obTablet4: case Objects::obTablet5: case Objects::obTablet6: { - if ((p_global->_partyOutside & PersonMask::pmDina) - && p_global->_curObjectId == Objects::obTablet1 && p_global->_phaseNum == 370) + if ((_globals->_partyOutside & PersonMask::pmDina) + && _globals->_curObjectId == Objects::obTablet1 && _globals->_phaseNum == 370) incPhase(); - char *objvid = &kTabletView[(p_global->_curObjectId - Objects::obTablet1) * 2]; + char *objvid = &kTabletView[(_globals->_curObjectId - Objects::obTablet1) * 2]; object_t *object = getObjectPtr(*objvid++); int16 vid = 84; if (!object->_count) @@ -3533,7 +3532,7 @@ void EdenGame::actionAdam() { _specialTextMode = true; playHNM(vid); _paletteUpdateRequired = true; - p_global->_mirrorEffect = 16; // CHECKME: Verify the value + _globals->_mirrorEffect = 16; // CHECKME: Verify the value showBars(); gameToMirror(0); } @@ -3544,8 +3543,8 @@ void EdenGame::actionAdam() { case Objects::obNest: case Objects::obFullNest: case Objects::obDrum: - if (p_global->_party & PersonMask::pmThugg) { - p_global->_dialogType = DialogType::dtHint; + if (_globals->_party & PersonMask::pmThugg) { + _globals->_dialogType = DialogType::dtHint; perso1(&kPersons[PER_GUARDS]); } break; @@ -3572,8 +3571,8 @@ bool EdenGame::isAnswerYes() { // Original name: SpcChampi void EdenGame::specialMushroom(perso_t *perso) { perso->_flags |= PersonFlags::pf10; - p_global->_areaPtr->_flags |= AreaFlags::afFlag2; - p_global->_curAreaFlags |= AreaFlags::afFlag2; + _globals->_areaPtr->_flags |= AreaFlags::afFlag2; + _globals->_curAreaFlags |= AreaFlags::afFlag2; } // Original name: SpcNidv @@ -3581,17 +3580,17 @@ void EdenGame::specialEmptyNest(perso_t *perso) { if (!isAnswerYes()) return; perso->_flags |= PersonFlags::pf10; - p_global->_roomCharacterFlags |= PersonFlags::pf10; - p_global->_gameFlags |= GameFlags::gfFlag400; - if (p_global->_characterPtr == &kPersons[PER_EVE]) { - p_global->_areaPtr->_flags |= AreaFlags::afFlag4; - p_global->_curAreaFlags |= AreaFlags::afFlag4; + _globals->_roomCharacterFlags |= PersonFlags::pf10; + _globals->_gameFlags |= GameFlags::gfFlag400; + if (_globals->_characterPtr == &kPersons[PER_EVE]) { + _globals->_areaPtr->_flags |= AreaFlags::afFlag4; + _globals->_curAreaFlags |= AreaFlags::afFlag4; perso->_flags |= PersonFlags::pfInParty; - p_global->_roomCharacterFlags |= PersonFlags::pfInParty; - placeVava(p_global->_areaPtr); + _globals->_roomCharacterFlags |= PersonFlags::pfInParty; + placeVava(_globals->_areaPtr); } else { perso->_flags &= ~PersonFlags::pf10; - p_global->_roomCharacterFlags &= ~PersonFlags::pf10; + _globals->_roomCharacterFlags &= ~PersonFlags::pf10; } } @@ -3604,9 +3603,9 @@ void EdenGame::specialNestWithEggs(perso_t *perso) { // Original name: SpcPomme void EdenGame::specialApple(perso_t *perso) { perso->_flags |= PersonFlags::pf10; - p_global->_areaPtr->_flags |= AreaFlags::afFlag8; - p_global->_curAreaFlags |= AreaFlags::afFlag8; - p_global->_gameFlags |= GameFlags::gfFlag200; + _globals->_areaPtr->_flags |= AreaFlags::afFlag8; + _globals->_curAreaFlags |= AreaFlags::afFlag8; + _globals->_gameFlags |= GameFlags::gfFlag200; } // Original name: SpcOr @@ -3614,21 +3613,21 @@ void EdenGame::specialGold(perso_t *perso) { if (!isAnswerYes()) return; perso->_items = _curSpecialObject->_itemMask; - p_global->_roomPersoItems = _curSpecialObject->_itemMask; + _globals->_roomPersoItems = _curSpecialObject->_itemMask; perso->_flags |= PersonFlags::pf10; perso->_flags &= ~PersonFlags::pfInParty; perso->_targetLoc = 0; - p_global->_areaPtr->_flags |= AreaFlags::afGaveGold; - p_global->_curAreaFlags |= AreaFlags::afGaveGold; - if (p_global->_phaseNum == 226) + _globals->_areaPtr->_flags |= AreaFlags::afGaveGold; + _globals->_curAreaFlags |= AreaFlags::afGaveGold; + if (_globals->_phaseNum == 226) incPhase(); } // Original name: SpcPrisme void EdenGame::specialPrism(perso_t *perso) { if (perso == &kPersons[PER_DINA]) { - if (p_global->_partyOutside & PersonMask::pmMonk) - p_global->_gameFlags |= GameFlags::gfPrismAndMonk; + if (_globals->_partyOutside & PersonMask::pmMonk) + _globals->_gameFlags |= GameFlags::gfPrismAndMonk; } } @@ -3648,7 +3647,7 @@ void EdenGame::specialMask(perso_t *perso) { // Original name: SpcSac void EdenGame::specialBag(perso_t *perso) { - if (p_global->_textToken1 != 3) + if (_globals->_textToken1 != 3) return; if (perso == &kPersons[PER_KABUKA] || perso == &kPersons[PER_MAMMI_3]) loseObject(_curSpecialObject->_id); @@ -3658,11 +3657,11 @@ void EdenGame::specialBag(perso_t *perso) { void EdenGame::specialTrumpet(perso_t *perso) { if (!isAnswerYes()) return; - p_global->_var54 = 4; + _globals->_var54 = 4; winObject(Objects::obTrumpet); - p_global->_drawFlags |= DrawFlags::drDrawInventory; + _globals->_drawFlags |= DrawFlags::drDrawInventory; _closeCharacterDialog = true; - tyranDies(p_global->_roomCharacterPtr); + tyranDies(_globals->_roomCharacterPtr); } // Original name: SpcArmes @@ -3670,7 +3669,7 @@ void EdenGame::specialWeapons(perso_t *perso) { if (!isAnswerYes()) return; perso->_powers = _curSpecialObject->_powerMask; - p_global->_roomCharacterPowers = _curSpecialObject->_powerMask; + _globals->_roomCharacterPowers = _curSpecialObject->_powerMask; giveObject(); } @@ -3679,19 +3678,19 @@ void EdenGame::specialInstrument(perso_t *perso) { if (!isAnswerYes()) return; if (perso == &kPersons[PER_MONK]) { - p_global->_partyInstruments &= ~1; //TODO: check me + _globals->_partyInstruments &= ~1; //TODO: check me if (_curSpecialObject->_id == Objects::obRing) { - p_global->_partyInstruments |= 1; - p_global->_monkGotRing++; //TODO: |= 1 ? + _globals->_partyInstruments |= 1; + _globals->_monkGotRing++; //TODO: |= 1 ? } } if (perso == &kPersons[PER_GUARDS]) { - p_global->_partyInstruments &= ~2; + _globals->_partyInstruments &= ~2; if (_curSpecialObject->_id == Objects::obDrum) - p_global->_partyInstruments |= 2; + _globals->_partyInstruments |= 2; } perso->_powers = _curSpecialObject->_powerMask; - p_global->_curCharacterPowers = _curSpecialObject->_powerMask; + _globals->_curCharacterPowers = _curSpecialObject->_powerMask; giveObject(); } @@ -3700,7 +3699,7 @@ void EdenGame::specialEgg(perso_t *perso) { if (!isAnswerYes()) return; _gameIcons[131]._cursorId &= ~0x8000; - p_global->_characterBackgroundBankIdx = 62; + _globals->_characterBackgroundBankIdx = 62; dialautoon(); } @@ -3708,10 +3707,10 @@ void EdenGame::specialEgg(perso_t *perso) { void EdenGame::tyranDies(perso_t *perso) { perso->_flags |= PersonFlags::pf80; perso->_roomNum = 0; - removeInfo(p_global->_areaNum + ValleyNews::vnTyrannIn); - p_global->_roomCharacterType = 0; - p_global->_roomCharacterFlags = 0; - p_global->_chronoFlag = 0; + removeInfo(_globals->_areaNum + ValleyNews::vnTyrannIn); + _globals->_roomCharacterType = 0; + _globals->_roomCharacterFlags = 0; + _globals->_chronoFlag = 0; } void EdenGame::specialObjects(perso_t *perso, char objid) { @@ -3762,128 +3761,128 @@ void EdenGame::specialObjects(perso_t *perso, char objid) { } void EdenGame::dialautoon() { - p_global->_iconsIndex = 4; - p_global->_autoDialog = true; + _globals->_iconsIndex = 4; + _globals->_autoDialog = true; putObject(); } void EdenGame::dialautooff() { - p_global->_iconsIndex = 0x10; - p_global->_autoDialog = false; + _globals->_iconsIndex = 0x10; + _globals->_autoDialog = false; } void EdenGame::follow() { - if (p_global->_roomCharacterType == PersonFlags::pfType12) { - debug("follow: hiding person %ld", p_global->_roomCharacterPtr - kPersons); - p_global->_roomCharacterPtr->_flags |= PersonFlags::pf80; - p_global->_roomCharacterPtr->_roomNum = 0; - p_global->_gameFlags |= GameFlags::gfFlag8; + if (_globals->_roomCharacterType == PersonFlags::pfType12) { + debug("follow: hiding person %ld", _globals->_roomCharacterPtr - kPersons); + _globals->_roomCharacterPtr->_flags |= PersonFlags::pf80; + _globals->_roomCharacterPtr->_roomNum = 0; + _globals->_gameFlags |= GameFlags::gfFlag8; _gameIcons[123]._objectId = 18; _gameIcons[124]._objectId = 35; _gameIcons[125]._cursorId &= ~0x8000; - p_global->_characterBackgroundBankIdx = 56; + _globals->_characterBackgroundBankIdx = 56; } else AddCharacterToParty(); } void EdenGame::dialonfollow() { - p_global->_iconsIndex = 4; - p_global->_autoDialog = true; + _globals->_iconsIndex = 4; + _globals->_autoDialog = true; follow(); } void EdenGame::abortdial() { - p_global->_varF6++; - if (p_global->_roomCharacterType != PersonFlags::pftTriceraptor || p_global->_characterPtr != &kPersons[PER_EVE]) + _globals->_varF6++; + if (_globals->_roomCharacterType != PersonFlags::pftTriceraptor || _globals->_characterPtr != &kPersons[PER_EVE]) return; - p_global->_areaPtr->_flags |= AreaFlags::afFlag4; - p_global->_curAreaFlags |= AreaFlags::afFlag4; - p_global->_roomCharacterPtr->_flags |= PersonFlags::pfInParty; - p_global->_roomCharacterFlags |= PersonFlags::pfInParty; - placeVava(p_global->_areaPtr); + _globals->_areaPtr->_flags |= AreaFlags::afFlag4; + _globals->_curAreaFlags |= AreaFlags::afFlag4; + _globals->_roomCharacterPtr->_flags |= PersonFlags::pfInParty; + _globals->_roomCharacterFlags |= PersonFlags::pfInParty; + placeVava(_globals->_areaPtr); } void EdenGame::narrateur() { - if (!(p_global->_displayFlags & DisplayFlags::dfFlag1)) + if (!(_globals->_displayFlags & DisplayFlags::dfFlag1)) return; - if (!p_global->_narratorSequence) { - if (p_global->_var6A == p_global->_var69) + if (!_globals->_narratorSequence) { + if (_globals->_var6A == _globals->_var69) goto skip; buildCitadel(); } - p_global->_varF5 |= 0x80; - p_global->_varF2 &= ~1; //TODO: check me - p_global->_characterPtr = &kPersons[PER_UNKN_156]; - p_global->_var60 = 0; - p_global->_eventType = 0; - p_global->_var103 = 69; + _globals->_varF5 |= 0x80; + _globals->_varF2 &= ~1; //TODO: check me + _globals->_characterPtr = &kPersons[PER_UNKN_156]; + _globals->_var60 = 0; + _globals->_eventType = 0; + _globals->_var103 = 69; if (dialo_even(&kPersons[PER_UNKN_156])) { - p_global->_narratorDialogPtr = p_global->_dialogPtr; + _globals->_narratorDialogPtr = _globals->_dialogPtr; dialautoon(); - p_global->_varF2 |= 1; + _globals->_varF2 |= 1; waitEndSpeak(); if (pomme_q) return; endCharacterSpeech(); - while (dialoscansvmas(p_global->_narratorDialogPtr)) { - p_global->_narratorDialogPtr = p_global->_dialogPtr; + while (dialoscansvmas(_globals->_narratorDialogPtr)) { + _globals->_narratorDialogPtr = _globals->_dialogPtr; waitEndSpeak(); if (pomme_q) return; endCharacterSpeech(); } - p_global->_narratorDialogPtr = p_global->_dialogPtr; - p_global->_mirrorEffect = 0; - p_global->_var103 = 0; + _globals->_narratorDialogPtr = _globals->_dialogPtr; + _globals->_mirrorEffect = 0; + _globals->_var103 = 0; closeCharacterScreen(); - placeVava(p_global->_areaPtr); - if (p_global->_narratorSequence == 8) + placeVava(_globals->_areaPtr); + if (_globals->_narratorSequence == 8) deplaval(134); } - p_global->_var103 = 0; - if (p_global->_narratorSequence == 10) { + _globals->_var103 = 0; + if (_globals->_narratorSequence == 10) { addToParty(PER_MESSENGER); addToParty(PER_EVE); addToParty(PER_MONK); addToParty(PER_GUARDS); removeFromParty(PER_MANGO); - p_global->_eloiHaveNews = 0; + _globals->_eloiHaveNews = 0; deplaval(139); } - p_global->_eventType = EventType::etEventD; + _globals->_eventType = EventType::etEventD; showEvents(); - p_global->_varF5 &= ~0x80; + _globals->_varF5 &= ~0x80; skip: ; - p_global->_varF2 &= ~1; //TODO: check me - if (p_global->_narratorSequence > 50 && p_global->_narratorSequence <= 80) - p_global->_endGameFlag = 50; - if (p_global->_narratorSequence == 3) + _globals->_varF2 &= ~1; //TODO: check me + if (_globals->_narratorSequence > 50 && _globals->_narratorSequence <= 80) + _globals->_endGameFlag = 50; + if (_globals->_narratorSequence == 3) setChrono(1200); - p_global->_narratorSequence = 0; + _globals->_narratorSequence = 0; } void EdenGame::vrf_phrases_file() { int16 num = 3; - if (p_global->_dialogPtr < (dial_t *)getElem(_gameDialogs, 48)) + if (_globals->_dialogPtr < (dial_t *)getElem(_gameDialogs, 48)) num = 1; - else if (p_global->_dialogPtr < (dial_t *)getElem(_gameDialogs, 128)) + else if (_globals->_dialogPtr < (dial_t *)getElem(_gameDialogs, 128)) num = 2; - p_global->_textBankIndex = num; - if (p_global->_prefLanguage) - num += (p_global->_prefLanguage - 1) * 3; + _globals->_textBankIndex = num; + if (_globals->_prefLanguage) + num += (_globals->_prefLanguage - 1) * 3; if (num == lastPhrasesFile) return; lastPhrasesFile = num; num += 404; - loadRawFile(num, gamePhrases); - verifh(gamePhrases); + loadRawFile(num, _gamePhrases); + verifh(_gamePhrases); } byte *EdenGame::gettxtad(int16 id) { vrf_phrases_file(); - return (byte *)getElem(gamePhrases, id - 1); + return (byte *)getElem(_gamePhrases, id - 1); } // Original name: gotocarte @@ -3891,10 +3890,10 @@ void EdenGame::actionGotoMap() { Goto *go = &gotos[_curSpot2->_objectId]; endCharacterSpeech(); byte newArea = go->_areaNum; - p_global->_newRoomNum = (go->_areaNum << 8) | 1; - p_global->_newLocation = 1; - p_global->_prevLocation = p_global->_roomNum & 0xFF; - char curArea = p_global->_roomNum >> 8; + _globals->_newRoomNum = (go->_areaNum << 8) | 1; + _globals->_newLocation = 1; + _globals->_prevLocation = _globals->_roomNum & 0xFF; + char curArea = _globals->_roomNum >> 8; if (curArea == go->_areaNum) newArea = 0; else { @@ -3906,7 +3905,7 @@ void EdenGame::actionGotoMap() { if (go->_areaNum == 0xFF) return; } - p_global->_eventType = EventType::etGotoArea | newArea; + _globals->_eventType = EventType::etGotoArea | newArea; setChoiceYes(); showEvents1(); waitEndSpeak(); @@ -3919,21 +3918,21 @@ void EdenGame::actionGotoMap() { } void EdenGame::record() { - if (p_global->_curObjectId) + if (_globals->_curObjectId) return; - if (p_global->_characterPtr >= &kPersons[PER_UNKN_18C]) + if (_globals->_characterPtr >= &kPersons[PER_UNKN_18C]) return; - if (p_global->_eventType == EventType::etEventE || p_global->_eventType >= EventType::etGotoArea) + if (_globals->_eventType == EventType::etEventE || _globals->_eventType >= EventType::etGotoArea) return; - for (tape_t *tape = tapes; tape != tapes + MAX_TAPES; tape++) { - if (tape->_textNum == p_global->_textNum) + for (tape_t *tape = _tapes; tape != _tapes + MAX_TAPES; tape++) { + if (tape->_textNum == _globals->_textNum) return; } - tape_t *tape = tapes; + tape_t *tape = _tapes; for (int16 i = 0; i < MAX_TAPES - 1; i++) { tape->_textNum = tape[+1]._textNum; tape->_perso = tape[+1]._perso; @@ -3944,38 +3943,38 @@ void EdenGame::record() { tape++; } - perso_t *perso = p_global->_characterPtr; + perso_t *perso = _globals->_characterPtr; if (perso == &kPersons[PER_EVE]) - perso = p_global->_phaseNum >= 352 ? &kPersons[PER_UNKN_372] + perso = _globals->_phaseNum >= 352 ? &kPersons[PER_UNKN_372] : &kPersons[PER_UNKN_402]; - tape->_textNum = p_global->_textNum; + tape->_textNum = _globals->_textNum; tape->_perso = perso; - tape->_party = p_global->_party; - tape->_roomNum = p_global->_roomNum; - tape->_backgroundBankNum = p_global->_roomBackgroundBankNum; - tape->_dialog = p_global->_dialogPtr; + tape->_party = _globals->_party; + tape->_roomNum = _globals->_roomNum; + tape->_backgroundBankNum = _globals->_roomBackgroundBankNum; + tape->_dialog = _globals->_dialogPtr; } bool EdenGame::dial_scan(dial_t *dial) { - if (p_global->_numGiveObjs) { - if (!(p_global->_displayFlags & DisplayFlags::dfFlag2)) + if (_globals->_numGiveObjs) { + if (!(_globals->_displayFlags & DisplayFlags::dfFlag2)) showObjects(); - p_global->_numGiveObjs = 0; + _globals->_numGiveObjs = 0; } - p_global->_dialogPtr = dial; + _globals->_dialogPtr = dial; vavapers(); - p_global->_sentenceBufferPtr = _sentenceBuffer; + _globals->_sentenceBufferPtr = _sentenceBuffer; byte hidx, lidx; uint16 mask; - for (;; p_global->_dialogPtr++) { - for (;; p_global->_dialogPtr++) { - if (p_global->_dialogPtr->_flags == -1 && p_global->_dialogPtr->_condNumLow == -1) + for (;; _globals->_dialogPtr++) { + for (;; _globals->_dialogPtr++) { + if (_globals->_dialogPtr->_flags == -1 && _globals->_dialogPtr->_condNumLow == -1) return false; - byte flags = p_global->_dialogPtr->_flags; - p_global->_dialogFlags = flags; + byte flags = _globals->_dialogPtr->_flags; + _globals->_dialogFlags = flags; if (!(flags & DialogFlags::dfSpoken) || (flags & DialogFlags::dfRepeatable)) { - hidx = (p_global->_dialogPtr->_textCondHiMask >> 6) & 3; - lidx = p_global->_dialogPtr->_condNumLow; + hidx = (_globals->_dialogPtr->_textCondHiMask >> 6) & 3; + lidx = _globals->_dialogPtr->_condNumLow; if (flags & 0x10) hidx |= 4; if (testCondition(((hidx << 8) | lidx) & 0x7FF)) @@ -3983,34 +3982,34 @@ bool EdenGame::dial_scan(dial_t *dial) { } else { if (flags & dialogSkipFlags) continue; - hidx = (p_global->_dialogPtr->_textCondHiMask >> 6) & 3; - lidx = p_global->_dialogPtr->_condNumLow; + hidx = (_globals->_dialogPtr->_textCondHiMask >> 6) & 3; + lidx = _globals->_dialogPtr->_condNumLow; if (flags & 0x10) hidx |= 4; if (testCondition(((hidx << 8) | lidx) & 0x7FF)) break; } } - char bidx = (p_global->_dialogPtr->_textCondHiMask >> 2) & 0xF; + char bidx = (_globals->_dialogPtr->_textCondHiMask >> 2) & 0xF; if (!bidx) goto no_perso; //TODO: rearrange - mask = (p_global->_party | p_global->_partyOutside) & (1 << (bidx - 1)); + mask = (_globals->_party | _globals->_partyOutside) & (1 << (bidx - 1)); if (mask) break; } perso_t *perso; - for (perso = kPersons; !(perso->_partyMask == mask && perso->_roomNum == p_global->_roomNum); perso++) + for (perso = kPersons; !(perso->_partyMask == mask && perso->_roomNum == _globals->_roomNum); perso++) ; //Find matching - p_global->_characterPtr = perso; + _globals->_characterPtr = perso; init_perso_ptr(perso); no_perso(); no_perso: ; - hidx = p_global->_dialogPtr->_textCondHiMask; - lidx = p_global->_dialogPtr->_textNumLow; - p_global->_textNum = ((hidx << 8) | lidx) & 0x3FF; - if (p_global->_sentenceBufferPtr != _sentenceBuffer) { + hidx = _globals->_dialogPtr->_textCondHiMask; + lidx = _globals->_dialogPtr->_textNumLow; + _globals->_textNum = ((hidx << 8) | lidx) & 0x3FF; + if (_globals->_sentenceBufferPtr != _sentenceBuffer) { for (int16 i = 0; i < 32; i++) SysBeep(1); } else @@ -4033,14 +4032,14 @@ no_perso: &EdenGame::choixzone, &EdenGame::lostObject }; - char pnum = p_global->_dialogPtr->_flags & 0xF; + char pnum = _globals->_dialogPtr->_flags & 0xF; if (pnum) (this->*talk_subject[pnum - 1])(); - p_global->_var60 = 1; - p_global->_dialogPtr->_flags |= DialogFlags::dfSpoken; - p_global->_dialogPtr++; + _globals->_var60 = 1; + _globals->_dialogPtr->_flags |= DialogFlags::dfSpoken; + _globals->_dialogPtr++; } - if (p_global->_dialogType != DialogType::dtInspect) { + if (_globals->_dialogType != DialogType::dtInspect) { record(); getDataSync(); showCharacter(); @@ -4058,19 +4057,19 @@ bool EdenGame::dialoscansvmas(dial_t *dial) { } bool EdenGame::dialo_even(perso_t *perso) { - p_global->_characterPtr = perso; + _globals->_characterPtr = perso; int num = (perso->_id << 3) | DialogType::dtEvent; dial_t *dial = (dial_t *)getElem(_gameDialogs, num); bool res = dialoscansvmas(dial); - p_global->_lastDialogPtr = nullptr; + _globals->_lastDialogPtr = nullptr; parlemoiNormalFlag = false; return res; } // Original name: stay_here void EdenGame::subjectStayHere() { - if (p_global->_characterPtr == &kPersons[PER_DINA] && p_global->_roomNum == 260) - p_global->_gameFlags |= GameFlags::gfFlag1000; + if (_globals->_characterPtr == &kPersons[PER_DINA] && _globals->_roomNum == 260) + _globals->_gameFlags |= GameFlags::gfFlag1000; removeCharacterFromParty(); } @@ -4081,70 +4080,70 @@ void EdenGame::mort(int16 vid) { CLBlitter_FillScreenView(0); CLBlitter_FillView(_mainView, 0); showBars(); - p_global->_narratorSequence = 51; - p_global->_newMusicType = MusicType::mtNormal; + _globals->_narratorSequence = 51; + _globals->_newMusicType = MusicType::mtNormal; musique(); musicspy(); } void EdenGame::evenchrono() { - if (!(p_global->_displayFlags & DisplayFlags::dfFlag1)) + if (!(_globals->_displayFlags & DisplayFlags::dfFlag1)) return; - uint16 oldGameTime = p_global->_gameTime; + uint16 oldGameTime = _globals->_gameTime; _currentTime = _vm->_timerTicks / 100; - p_global->_gameTime = _currentTime; - if (p_global->_gameTime <= oldGameTime) + _globals->_gameTime = _currentTime; + if (_globals->_gameTime <= oldGameTime) return; heurepasse(); - if (!(p_global->_chronoFlag & 1)) + if (!(_globals->_chronoFlag & 1)) return; - p_global->_chrono -= 200; - if (p_global->_chrono == 0) - p_global->_chronoFlag |= 2; - if (!(p_global->_chronoFlag & 2)) + _globals->_chrono -= 200; + if (_globals->_chrono == 0) + _globals->_chronoFlag |= 2; + if (!(_globals->_chronoFlag & 2)) return; - p_global->_chronoFlag = 0; - p_global->_chrono = 0; - if (p_global->_roomCharacterType == PersonFlags::pftTyrann) { + _globals->_chronoFlag = 0; + _globals->_chrono = 0; + if (_globals->_roomCharacterType == PersonFlags::pftTyrann) { int16 vid = 272; - if (p_global->_curRoomFlags & 0xC0) { + if (_globals->_curRoomFlags & 0xC0) { vid += 2; - if ((p_global->_curRoomFlags & 0xC0) != 0x80) { + if ((_globals->_curRoomFlags & 0xC0) != 0x80) { vid += 2; mort(vid); return; } } - if (p_global->_areaNum == Areas::arUluru || p_global->_areaNum == Areas::arTamara) + if (_globals->_areaNum == Areas::arUluru || _globals->_areaNum == Areas::arTamara) mort(vid); else mort(vid + 1); return; } - if (p_global->_roomNum == 2817) { + if (_globals->_roomNum == 2817) { addToParty(PER_MESSENGER); - p_global->_gameFlags |= GameFlags::gfFlag40; + _globals->_gameFlags |= GameFlags::gfFlag40; dialautoon(); } else handleEloiReturn(); - p_global->_eventType = EventType::etEvent10; + _globals->_eventType = EventType::etEvent10; showEvents(); } // Original name: chronoon void EdenGame::setChrono(int16 t) { - p_global->_chrono = t; - p_global->_chronoFlag = 1; + _globals->_chrono = t; + _globals->_chronoFlag = 1; } void EdenGame::prechargephrases(int16 vid) { perso_t *perso = &kPersons[PER_MORKUS]; if (vid == 170) perso = &kPersons[PER_UNKN_156]; - p_global->_characterPtr = perso; - p_global->_dialogType = DialogType::dtInspect; - int num = (perso->_id << 3) | p_global->_dialogType; + _globals->_characterPtr = perso; + _globals->_dialogType = DialogType::dtInspect; + int num = (perso->_id << 3) | _globals->_dialogType; dial_t *dial = (dial_t *)getElem(_gameDialogs, num); dialoscansvmas(dial); } @@ -4158,9 +4157,9 @@ void EdenGame::displayEffect1() { for (int16 i = 16; i <= 96; i += 4) { for (int x = _mainView->_normal._dstLeft; x < _mainView->_normal._dstLeft + 320; x += 16) { setDestRect(x, y + i, x + 16 - 1, y + i + 4 - 1); - CLBlitter_CopyViewRect(p_view2, _vm->ScreenView, &rect_src, &rect_dst); + CLBlitter_CopyViewRect(_view2, _vm->ScreenView, &rect_src, &rect_dst); setDestRect(x, y + 192 - i, x + 16 - 1, y + 192 - i + 4 - 1); - CLBlitter_CopyViewRect(p_view2, _vm->ScreenView, &rect_src, &rect_dst); + CLBlitter_CopyViewRect(_view2, _vm->ScreenView, &rect_src, &rect_dst); } CLBlitter_UpdateScreen(); wait(1); @@ -4171,9 +4170,9 @@ void EdenGame::displayEffect1() { for (int16 i = 16 * 2; i <= 96 * 2; i += 4 * 2) { for (int x = _mainView->_zoom._dstLeft; x < _mainView->_zoom._dstLeft + 320 * 2; x += 16 * 2) { setDestRect(x, y + i, x + 16 * 2 - 1, y + i + 4 * 2 - 1); - CLBlitter_CopyViewRect(p_view2, _vm->ScreenView, &rect_src, &rect_dst); + CLBlitter_CopyViewRect(_view2, _vm->ScreenView, &rect_src, &rect_dst); setDestRect(x, y + 192 * 2 - i, x + 16 * 2 - 1, y + 192 * 2 - i + 4 * 2 - 1); - CLBlitter_CopyViewRect(p_view2, _vm->ScreenView, &rect_src, &rect_dst); + CLBlitter_CopyViewRect(_view2, _vm->ScreenView, &rect_src, &rect_dst); } wait(1); } @@ -4203,7 +4202,7 @@ void EdenGame::displayEffect1() { _mainView->_zoom._srcTop = 0; _mainView->_normal._dstTop = ny; _mainView->_zoom._dstTop = dy; - p_global->_varF1 = 0; + _globals->_varF1 = 0; } // Original name: effet2 @@ -4214,7 +4213,7 @@ void EdenGame::displayEffect2() { static int16 pattern4[] = {0, 3, 15, 12, 1, 7, 14, 8, 2, 11, 13, 4, 5, 6, 10, 9}; static int eff2pat = 0; - if (p_global->_var103 == 69) { + if (_globals->_var103 == 69) { displayEffect4(); return; } @@ -4568,7 +4567,7 @@ void EdenGame::fadeFromBlackLowPalette(int delay) { // Original name: rectanglenoir32 void EdenGame::blackRect32() { // blacken 32x32 rectangle - int *pix = (int *)p_view2_buf; + int *pix = (int *)_view2Buf; for (int16 i = 0; i < 32; i++) { pix[0] = 0; pix[1] = 0; @@ -4730,26 +4729,26 @@ void EdenGame::verifh(byte *ptr) { } void EdenGame::openbigfile() { - h_bigfile.open("EDEN.DAT"); + _bigfile.open("EDEN.DAT"); char buf[16]; - int count = h_bigfile.readUint16LE(); - bigfile_header = new PakHeaderNode(count); + int count = _bigfile.readUint16LE(); + _bigfileHeader = new PakHeaderNode(count); for (int j = 0; j < count; j++) { for (int k = 0; k < 16; k++) - buf[k] = h_bigfile.readByte(); - bigfile_header->_files[j]._name = Common::String(buf); - bigfile_header->_files[j]._size = h_bigfile.readUint32LE(); - bigfile_header->_files[j]._offs = h_bigfile.readUint32LE(); - bigfile_header->_files[j]._flag = h_bigfile.readByte(); + buf[k] = _bigfile.readByte(); + _bigfileHeader->_files[j]._name = Common::String(buf); + _bigfileHeader->_files[j]._size = _bigfile.readUint32LE(); + _bigfileHeader->_files[j]._offs = _bigfile.readUint32LE(); + _bigfileHeader->_files[j]._flag = _bigfile.readByte(); } _hnmContext = _vm->_video->resetInternals(); - _vm->_video->setFile(_hnmContext, &h_bigfile); + _vm->_video->setFile(_hnmContext, &_bigfile); } void EdenGame::closebigfile() { - h_bigfile.close(); + _bigfile.close(); } void EdenGame::loadRawFile(uint16 num, byte *buffer) { @@ -4758,13 +4757,13 @@ void EdenGame::loadRawFile(uint16 num, byte *buffer) { error("Trying to read invalid game resource"); } - assert(num < bigfile_header->_count); - PakHeaderItem *file = &bigfile_header->_files[num]; + assert(num < _bigfileHeader->_count); + PakHeaderItem *file = &_bigfileHeader->_files[num]; int32 size = file->_size; int32 offs = file->_offs; - h_bigfile.seek(offs, SEEK_SET); - h_bigfile.read(buffer, size); + _bigfile.seek(offs, SEEK_SET); + _bigfile.read(buffer, size); } void EdenGame::loadIconFile(uint16 num, Icon *buffer) { @@ -4773,31 +4772,31 @@ void EdenGame::loadIconFile(uint16 num, Icon *buffer) { error("Trying to read invalid game resource"); } - assert(num < bigfile_header->_count); - PakHeaderItem *file = &bigfile_header->_files[num]; + assert(num < _bigfileHeader->_count); + PakHeaderItem *file = &_bigfileHeader->_files[num]; int32 size = file->_size; int32 offs = file->_offs; debug("* Loading icon - Resource %d (%s) at 0x%X, %d bytes", num, file->_name.c_str(), offs, size); - h_bigfile.seek(offs, SEEK_SET); + _bigfile.seek(offs, SEEK_SET); int count = size / sizeof(Icon); for (int i = 0; i < count; i++) { if (_vm->getPlatform() == Common::kPlatformMacintosh) { - buffer[i].sx = h_bigfile.readSint16BE(); - buffer[i].sy = h_bigfile.readSint16BE(); - buffer[i].ex = h_bigfile.readSint16BE(); - buffer[i].ey = h_bigfile.readSint16BE(); - buffer[i]._cursorId = h_bigfile.readUint16BE();; - buffer[i]._actionId= h_bigfile.readUint32BE();; - buffer[i]._objectId= h_bigfile.readUint32BE();; + buffer[i].sx = _bigfile.readSint16BE(); + buffer[i].sy = _bigfile.readSint16BE(); + buffer[i].ex = _bigfile.readSint16BE(); + buffer[i].ey = _bigfile.readSint16BE(); + buffer[i]._cursorId = _bigfile.readUint16BE();; + buffer[i]._actionId= _bigfile.readUint32BE();; + buffer[i]._objectId= _bigfile.readUint32BE();; } else { - buffer[i].sx = h_bigfile.readSint16LE(); - buffer[i].sy = h_bigfile.readSint16LE(); - buffer[i].ex = h_bigfile.readSint16LE(); - buffer[i].ey = h_bigfile.readSint16LE(); - buffer[i]._cursorId = h_bigfile.readUint16LE();; - buffer[i]._actionId= h_bigfile.readUint32LE();; - buffer[i]._objectId= h_bigfile.readUint32LE();; + buffer[i].sx = _bigfile.readSint16LE(); + buffer[i].sy = _bigfile.readSint16LE(); + buffer[i].ex = _bigfile.readSint16LE(); + buffer[i].ey = _bigfile.readSint16LE(); + buffer[i]._cursorId = _bigfile.readUint16LE();; + buffer[i]._actionId= _bigfile.readUint32LE();; + buffer[i]._objectId= _bigfile.readUint32LE();; } } } @@ -4808,37 +4807,37 @@ void EdenGame::loadRoomFile(uint16 num, Room *buffer) { error("Trying to read invalid game resource"); } - assert(num < bigfile_header->_count); - PakHeaderItem *file = &bigfile_header->_files[num]; + assert(num < _bigfileHeader->_count); + PakHeaderItem *file = &_bigfileHeader->_files[num]; int32 size = file->_size; int32 offs = file->_offs; debug("* Loading room - Resource %d (%s) at 0x%X, %d bytes", num, file->_name.c_str(), offs, size); - h_bigfile.seek(offs, SEEK_SET); + _bigfile.seek(offs, SEEK_SET); int count = size / sizeof(Room); for (int i = 0; i < count; i++) { - buffer[i]._id = h_bigfile.readByte(); + buffer[i]._id = _bigfile.readByte(); for (int j = 0; j < 4; j++) - buffer[i]._exits[j] = h_bigfile.readByte(); - buffer[i]._flags = h_bigfile.readByte(); + buffer[i]._exits[j] = _bigfile.readByte(); + buffer[i]._flags = _bigfile.readByte(); if (_vm->getPlatform() == Common::kPlatformMacintosh) { - buffer[i]._bank = h_bigfile.readUint16BE(); - buffer[i]._party = h_bigfile.readUint16BE(); + buffer[i]._bank = _bigfile.readUint16BE(); + buffer[i]._party = _bigfile.readUint16BE(); } else { - buffer[i]._bank = h_bigfile.readUint16LE(); - buffer[i]._party = h_bigfile.readUint16LE(); + buffer[i]._bank = _bigfile.readUint16LE(); + buffer[i]._party = _bigfile.readUint16LE(); } - buffer[i]._level = h_bigfile.readByte(); - buffer[i]._video = h_bigfile.readByte(); - buffer[i]._location = h_bigfile.readByte(); - buffer[i]._backgroundBankNum = h_bigfile.readByte(); + buffer[i]._level = _bigfile.readByte(); + buffer[i]._video = _bigfile.readByte(); + buffer[i]._location = _bigfile.readByte(); + buffer[i]._backgroundBankNum = _bigfile.readByte(); } } void EdenGame::shnmfl(uint16 num) { unsigned int resNum = num - 1 + 485; - assert(resNum < bigfile_header->_count); - PakHeaderItem *file = &bigfile_header->_files[resNum]; + assert(resNum < _bigfileHeader->_count); + PakHeaderItem *file = &_bigfileHeader->_files[resNum]; int size = file->_size; int offs = file->_offs; debug("* Loading movie %d (%s) at 0x%X, %d bytes", num, file->_name.c_str(), (uint)offs, size); @@ -4847,8 +4846,8 @@ void EdenGame::shnmfl(uint16 num) { int EdenGame::ssndfl(uint16 num) { unsigned int resNum = num - 1 + ((_vm->getPlatform() == Common::kPlatformDOS && _vm->isDemo()) ? 656 : 661); - assert(resNum < bigfile_header->_count); - PakHeaderItem *file = &bigfile_header->_files[resNum]; + assert(resNum < _bigfileHeader->_count); + PakHeaderItem *file = &_bigfileHeader->_files[resNum]; int32 size = file->_size; int32 offs = file->_offs; debug("* Loading sound %d (%s) at 0x%X, %d bytes", num, file->_name.c_str(), (uint)offs, size); @@ -4861,36 +4860,36 @@ int EdenGame::ssndfl(uint16 num) { _soundAllocated = true; } - h_bigfile.seek(offs, SEEK_SET); + _bigfile.seek(offs, SEEK_SET); //For PC loaded data is a VOC file, on Mac version this is a raw samples if (_vm->getPlatform() == Common::kPlatformMacintosh) - h_bigfile.read(_voiceSamplesBuffer, size); + _bigfile.read(_voiceSamplesBuffer, size); else { // VOC files also include extra information for lipsync // 1. Standard VOC header - h_bigfile.read(_voiceSamplesBuffer, 0x1A); + _bigfile.read(_voiceSamplesBuffer, 0x1A); // 2. Lipsync? - unsigned char chunkType = h_bigfile.readByte(); + unsigned char chunkType = _bigfile.readByte(); uint32 val = 0; - h_bigfile.read(&val, 3); + _bigfile.read(&val, 3); unsigned int chunkLen = LE32(val); if (chunkType == 5) { - h_bigfile.read(gameLipsync + 7260, chunkLen); + _bigfile.read(_gameLipsync + 7260, chunkLen); // anim_buffer_ptr = gameLipsync + 7260 + 2; - chunkType = h_bigfile.readByte(); - h_bigfile.read(&val, 3); + chunkType = _bigfile.readByte(); + _bigfile.read(&val, 3); chunkLen = LE32(val); } // 3. Normal sound data if (chunkType == 1) { - /*unsigned short freq = */h_bigfile.readUint16LE(); + /*unsigned short freq = */_bigfile.readUint16LE(); size = chunkLen - 2; - h_bigfile.read(_voiceSamplesBuffer, size); + _bigfile.read(_voiceSamplesBuffer, size); } } @@ -4900,7 +4899,7 @@ int EdenGame::ssndfl(uint16 num) { void EdenGame::ConvertMacToPC() { // Convert all mac (big-endian) resources to native format // Array of longs - int *p = (int *)gameLipsync; + int *p = (int *)_gameLipsync; for (int i = 0; i < 7240 / 4; i++) p[i] = BE32(p[i]); } @@ -4948,7 +4947,7 @@ void EdenGame::loadpermfiles() { case Common::kPlatformMacintosh: loadIconFile(2498, _gameIcons); loadRoomFile(2497, _gameRooms); - loadRawFile(2486, gameLipsync); + loadRawFile(2486, _gameLipsync); ConvertMacToPC(); break; default: @@ -4975,7 +4974,7 @@ bool EdenGame::ReadDataSyncVOC(unsigned int num) { loadpartoffile(resNum, &chunkLen, filePos, 3); filePos += 3; chunkLen = LE32(chunkLen); - loadpartoffile(resNum, gameLipsync + 7260, filePos, chunkLen); + loadpartoffile(resNum, _gameLipsync + 7260, filePos, chunkLen); return true; } return false; @@ -4983,10 +4982,10 @@ bool EdenGame::ReadDataSyncVOC(unsigned int num) { bool EdenGame::ReadDataSync(uint16 num) { if (_vm->getPlatform() == Common::kPlatformMacintosh) { - long pos = READ_LE_UINT32(gameLipsync + num * 4); + long pos = READ_LE_UINT32(_gameLipsync + num * 4); if (pos != -1) { long len = 1024; - loadpartoffile(1936, gameLipsync + 7260, pos, len); + loadpartoffile(1936, _gameLipsync + 7260, pos, len); return true; } } else @@ -4995,12 +4994,12 @@ bool EdenGame::ReadDataSync(uint16 num) { } void EdenGame::loadpartoffile(uint16 num, void *buffer, int32 pos, int32 len) { - assert(num < bigfile_header->_count); - PakHeaderItem *file = &bigfile_header->_files[num]; + assert(num < _bigfileHeader->_count); + PakHeaderItem *file = &_bigfileHeader->_files[num]; int32 offs = READ_LE_UINT32(&file->_offs); debug("* Loading partial resource %d (%s) at 0x%X(+0x%X), %d bytes", num, file->_name.c_str(), offs, pos, len); - h_bigfile.seek(offs + pos, SEEK_SET); - h_bigfile.read(buffer, len); + _bigfile.seek(offs + pos, SEEK_SET); + _bigfile.read(buffer, len); } void EdenGame::expandHSQ(byte *input, byte *output) { @@ -5056,16 +5055,16 @@ void EdenGame::expandHSQ(byte *input, byte *output) { // Original name: ajouinfo void EdenGame::addInfo(byte info) { - byte idx = p_global->_nextInfoIdx; + byte idx = _globals->_nextInfoIdx; if (kPersons[PER_MESSENGER]._roomNum) info |= 0x80; _infoList[idx] = info; - if (idx == p_global->_lastInfoIdx) - p_global->_lastInfo = info; + if (idx == _globals->_lastInfoIdx) + _globals->_lastInfo = info; idx++; if (idx == 16) idx = 0; - p_global->_nextInfoIdx = idx; + _globals->_nextInfoIdx = idx; } void EdenGame::unlockInfo() { @@ -5073,19 +5072,19 @@ void EdenGame::unlockInfo() { if (_infoList[idx] != 0xFF) _infoList[idx] &= ~0x80; } - p_global->_lastInfo &= ~0x80; + _globals->_lastInfo &= ~0x80; } void EdenGame::nextInfo() { do { - byte idx = p_global->_lastInfoIdx; + byte idx = _globals->_lastInfoIdx; _infoList[idx] = 0; idx++; if (idx == 16) idx = 0; - p_global->_lastInfoIdx = idx; - p_global->_lastInfo = _infoList[idx]; - } while (p_global->_lastInfo == 0xFF); + _globals->_lastInfoIdx = idx; + _globals->_lastInfo = _infoList[idx]; + } while (_globals->_lastInfo == 0xFF); } // Original name: delinfo @@ -5093,7 +5092,7 @@ void EdenGame::removeInfo(byte info) { for (byte idx = 0; idx < 16; idx++) { if ((_infoList[idx] & ~0x80) == info) { _infoList[idx] = 0xFF; - if (idx == p_global->_lastInfoIdx) + if (idx == _globals->_lastInfoIdx) nextInfo(); break; } @@ -5108,150 +5107,150 @@ void EdenGame::updateInfoList() { void EdenGame::initGlobals() { _gameIcons[16]._cursorId |= 0x8000; - p_global->_areaNum = Areas::arMo; - p_global->_areaVisitCount = 1; - p_global->_menuItemIdLo = 0; - p_global->_menuItemIdHi = 0; - p_global->_randomNumber = 0; - p_global->_gameTime = 0; - p_global->_gameDays = 0; - p_global->_chrono = 0; - p_global->_eloiDepartureDay = 0; - p_global->_roomNum = 259; - p_global->_newRoomNum = 0; - p_global->_phaseNum = 0; - p_global->_metPersonsMask1 = 0; - p_global->_party = 0; - p_global->_partyOutside = 0; - p_global->_metPersonsMask2 = 0; - p_global->_phaseActionsCount = 0; - p_global->_curAreaFlags = 0; - p_global->_curItemsMask = 0; - p_global->_curPowersMask = 0; - p_global->_curPersoItems = 0; - p_global->_curCharacterPowers = 0; - p_global->_wonItemsMask = 0; - p_global->_wonPowersMask = 0; - p_global->_stepsToFindAppleFast = 0; - p_global->_stepsToFindAppleNormal = 0; - p_global->_roomPersoItems = 0; - p_global->_roomCharacterPowers = 0; - p_global->_gameFlags = GameFlags::gfNone; - p_global->_morkusSpyVideoNum1 = 89; - p_global->_morkusSpyVideoNum2 = 88; - p_global->_morkusSpyVideoNum3 = 83; - p_global->_morkusSpyVideoNum4 = 94; - p_global->_newMusicType = MusicType::mtDontChange; - p_global->_var43 = 0; - p_global->_videoSubtitleIndex = 0; - p_global->_partyInstruments = 0; - p_global->_monkGotRing = 0; - p_global->_chronoFlag = 0; - p_global->_curRoomFlags = 0; - p_global->_endGameFlag = 0; - p_global->_lastInfo = 0; - p_global->_autoDialog = false; - p_global->_worldTyranSighted = 0; - p_global->_var4D = 0; - p_global->_var4E = 0; - p_global->_worldGaveGold = 0; - p_global->_worldHasTriceraptors = 0; - p_global->_worldHasVelociraptors = 0; - p_global->_worldHasTyran = 0; - p_global->_var53 = 0; - p_global->_var54 = 0; - p_global->_var55 = 0; - p_global->_gameHours = 0; - p_global->_textToken1 = 0; - p_global->_textToken2 = 0; - p_global->_eloiHaveNews = 0; - p_global->_dialogFlags = 0; - p_global->_curAreaType = 0; - p_global->_curCitadelLevel = 0; - p_global->_newLocation = 0; - p_global->_prevLocation = 0; - p_global->_curPersoFlags = 0; - p_global->_var60 = 0; - p_global->_eventType = EventType::etEvent5; - p_global->_var62 = 0; - p_global->_curObjectId = 0; - p_global->_curObjectFlags = 0; - p_global->_var65 = 1; - p_global->_roomCharacterType = 0; - p_global->_roomCharacterFlags = 0; - p_global->_narratorSequence = 0; - p_global->_var69 = 0; - p_global->_var6A = 0; - p_global->_frescoNumber = 0; - p_global->_var6C = 0; - p_global->_var6D = 0; - p_global->_labyrinthDirections = 0; - p_global->_labyrinthRoom = 0; - p_global->_curCharacterAnimPtr = nullptr; - p_global->_characterImageBank = 0; - p_global->_roomImgBank = 0; - p_global->_characterBackgroundBankIdx = 55; - p_global->_varD4 = 0; - p_global->_frescoeWidth = 0; - p_global->_frescoeImgBank = 0; - p_global->_varDA = 0; - p_global->_varDC = 0; - p_global->_roomBaseX = 0; - p_global->_varE0 = 0; - p_global->_dialogType = DialogType::dtTalk; - p_global->_varE4 = 0; - p_global->_currMusicNum = 0; - p_global->_textNum = 0; - p_global->_travelTime = 0; - p_global->_varEC = 0; - p_global->_displayFlags = DisplayFlags::dfFlag1; - p_global->_oldDisplayFlags = 1; - p_global->_drawFlags = 0; - p_global->_varF1 = 0; - p_global->_varF2 = 0; - p_global->_menuFlags = 0; - p_global->_varF5 = 0; - p_global->_varF6 = 0; - p_global->_varF7 = 0; - p_global->_varF8 = 0; - p_global->_varF9 = 0; - p_global->_varFA = 0; - p_global->_animationFlags = 0; - p_global->_giveObj1 = 0; - p_global->_giveObj2 = 0; - p_global->_giveObj3 = 0; - p_global->_var100 = 0; - p_global->_roomVidNum = 0; - p_global->_mirrorEffect = 0; - p_global->_var103 = 0; - p_global->_roomBackgroundBankNum = 0; - p_global->_valleyVidNum = 0; - p_global->_updatePaletteFlag = 0; - p_global->_inventoryScrollPos = 0; - p_global->_objCount = 0; - p_global->_textBankIndex = 69; - p_global->_citadelAreaNum = 0; - p_global->_var113 = 0; - p_global->_lastPlaceNum = 0; - p_global->_dialogPtr = nullptr; - p_global->_tapePtr = tapes; - p_global->_nextDialogPtr = nullptr; - p_global->_narratorDialogPtr = nullptr; - p_global->_lastDialogPtr = nullptr; - p_global->_nextRoomIcon = nullptr; - p_global->_sentenceBufferPtr = nullptr; - p_global->_roomPtr = nullptr; - p_global->_areaPtr = nullptr; - p_global->_lastAreaPtr = nullptr; - p_global->_curAreaPtr = nullptr; - p_global->_citaAreaFirstRoom = 0; - p_global->_characterPtr = nullptr; - p_global->_roomCharacterPtr = 0; - p_global->_lastInfoIdx = 0; - p_global->_nextInfoIdx = 0; - p_global->_iconsIndex = 16; - p_global->_persoSpritePtr = nullptr; - p_global->_numGiveObjs = 0; + _globals->_areaNum = Areas::arMo; + _globals->_areaVisitCount = 1; + _globals->_menuItemIdLo = 0; + _globals->_menuItemIdHi = 0; + _globals->_randomNumber = 0; + _globals->_gameTime = 0; + _globals->_gameDays = 0; + _globals->_chrono = 0; + _globals->_eloiDepartureDay = 0; + _globals->_roomNum = 259; + _globals->_newRoomNum = 0; + _globals->_phaseNum = 0; + _globals->_metPersonsMask1 = 0; + _globals->_party = 0; + _globals->_partyOutside = 0; + _globals->_metPersonsMask2 = 0; + _globals->_phaseActionsCount = 0; + _globals->_curAreaFlags = 0; + _globals->_curItemsMask = 0; + _globals->_curPowersMask = 0; + _globals->_curPersoItems = 0; + _globals->_curCharacterPowers = 0; + _globals->_wonItemsMask = 0; + _globals->_wonPowersMask = 0; + _globals->_stepsToFindAppleFast = 0; + _globals->_stepsToFindAppleNormal = 0; + _globals->_roomPersoItems = 0; + _globals->_roomCharacterPowers = 0; + _globals->_gameFlags = GameFlags::gfNone; + _globals->_morkusSpyVideoNum1 = 89; + _globals->_morkusSpyVideoNum2 = 88; + _globals->_morkusSpyVideoNum3 = 83; + _globals->_morkusSpyVideoNum4 = 94; + _globals->_newMusicType = MusicType::mtDontChange; + _globals->_var43 = 0; + _globals->_videoSubtitleIndex = 0; + _globals->_partyInstruments = 0; + _globals->_monkGotRing = 0; + _globals->_chronoFlag = 0; + _globals->_curRoomFlags = 0; + _globals->_endGameFlag = 0; + _globals->_lastInfo = 0; + _globals->_autoDialog = false; + _globals->_worldTyranSighted = 0; + _globals->_var4D = 0; + _globals->_var4E = 0; + _globals->_worldGaveGold = 0; + _globals->_worldHasTriceraptors = 0; + _globals->_worldHasVelociraptors = 0; + _globals->_worldHasTyran = 0; + _globals->_var53 = 0; + _globals->_var54 = 0; + _globals->_var55 = 0; + _globals->_gameHours = 0; + _globals->_textToken1 = 0; + _globals->_textToken2 = 0; + _globals->_eloiHaveNews = 0; + _globals->_dialogFlags = 0; + _globals->_curAreaType = 0; + _globals->_curCitadelLevel = 0; + _globals->_newLocation = 0; + _globals->_prevLocation = 0; + _globals->_curPersoFlags = 0; + _globals->_var60 = 0; + _globals->_eventType = EventType::etEvent5; + _globals->_var62 = 0; + _globals->_curObjectId = 0; + _globals->_curObjectFlags = 0; + _globals->_var65 = 1; + _globals->_roomCharacterType = 0; + _globals->_roomCharacterFlags = 0; + _globals->_narratorSequence = 0; + _globals->_var69 = 0; + _globals->_var6A = 0; + _globals->_frescoNumber = 0; + _globals->_var6C = 0; + _globals->_var6D = 0; + _globals->_labyrinthDirections = 0; + _globals->_labyrinthRoom = 0; + _globals->_curCharacterAnimPtr = nullptr; + _globals->_characterImageBank = 0; + _globals->_roomImgBank = 0; + _globals->_characterBackgroundBankIdx = 55; + _globals->_varD4 = 0; + _globals->_frescoeWidth = 0; + _globals->_frescoeImgBank = 0; + _globals->_varDA = 0; + _globals->_varDC = 0; + _globals->_roomBaseX = 0; + _globals->_varE0 = 0; + _globals->_dialogType = DialogType::dtTalk; + _globals->_varE4 = 0; + _globals->_currMusicNum = 0; + _globals->_textNum = 0; + _globals->_travelTime = 0; + _globals->_varEC = 0; + _globals->_displayFlags = DisplayFlags::dfFlag1; + _globals->_oldDisplayFlags = 1; + _globals->_drawFlags = 0; + _globals->_varF1 = 0; + _globals->_varF2 = 0; + _globals->_menuFlags = 0; + _globals->_varF5 = 0; + _globals->_varF6 = 0; + _globals->_varF7 = 0; + _globals->_varF8 = 0; + _globals->_varF9 = 0; + _globals->_varFA = 0; + _globals->_animationFlags = 0; + _globals->_giveObj1 = 0; + _globals->_giveObj2 = 0; + _globals->_giveObj3 = 0; + _globals->_var100 = 0; + _globals->_roomVidNum = 0; + _globals->_mirrorEffect = 0; + _globals->_var103 = 0; + _globals->_roomBackgroundBankNum = 0; + _globals->_valleyVidNum = 0; + _globals->_updatePaletteFlag = 0; + _globals->_inventoryScrollPos = 0; + _globals->_objCount = 0; + _globals->_textBankIndex = 69; + _globals->_citadelAreaNum = 0; + _globals->_var113 = 0; + _globals->_lastPlaceNum = 0; + _globals->_dialogPtr = nullptr; + _globals->_tapePtr = _tapes; + _globals->_nextDialogPtr = nullptr; + _globals->_narratorDialogPtr = nullptr; + _globals->_lastDialogPtr = nullptr; + _globals->_nextRoomIcon = nullptr; + _globals->_sentenceBufferPtr = nullptr; + _globals->_roomPtr = nullptr; + _globals->_areaPtr = nullptr; + _globals->_lastAreaPtr = nullptr; + _globals->_curAreaPtr = nullptr; + _globals->_citaAreaFirstRoom = 0; + _globals->_characterPtr = nullptr; + _globals->_roomCharacterPtr = 0; + _globals->_lastInfoIdx = 0; + _globals->_nextInfoIdx = 0; + _globals->_iconsIndex = 16; + _globals->_persoSpritePtr = nullptr; + _globals->_numGiveObjs = 0; initRects(); @@ -5275,8 +5274,8 @@ void EdenGame::initRects() { // Original name: closesalle void EdenGame::closeRoom() { - if (p_global->_displayFlags & DisplayFlags::dfPanable) { - p_global->_displayFlags &= ~DisplayFlags::dfPanable; + if (_globals->_displayFlags & DisplayFlags::dfPanable) { + _globals->_displayFlags &= ~DisplayFlags::dfPanable; resetScroll(); } } @@ -5296,28 +5295,28 @@ void EdenGame::displaySingleRoom(Room *room) { int16 y = *ptr++; ptr++; index &= 0x1FF; - if (!(p_global->_displayFlags & 0x80)) { - if (index == 1 || p_global->_varF7) + if (!(_globals->_displayFlags & 0x80)) { + if (index == 1 || _globals->_varF7) noclipax_avecnoir(index - 1, x, y); } - p_global->_varF7 = 0; + _globals->_varF7 = 0; continue; } if (b1 & 0x40) { if (b1 & 0x20) { bool addIcon = false; - Icon *icon = p_global->_nextRoomIcon; + Icon *icon = _globals->_nextRoomIcon; if (b0 < 4) { - if (p_global->_roomPtr->_exits[b0]) + if (_globals->_roomPtr->_exits[b0]) addIcon = true; } else if (b0 > 229) { - if (p_global->_partyOutside & (1 << (b0 - 230))) + if (_globals->_partyOutside & (1 << (b0 - 230))) addIcon = true; } else if (b0 >= 100) { debug("add object %d", b0 - 100); if (isObjectHere(b0 - 100)) { addIcon = true; - p_global->_varF7 = 1; + _globals->_varF7 = 1; } } else addIcon = true; @@ -5333,8 +5332,8 @@ void EdenGame::displaySingleRoom(Room *room) { ptr += 2; int16 ey = READ_LE_UINT16(ptr); ptr += 2; - x += p_global->_roomBaseX; - ex += p_global->_roomBaseX; + x += _globals->_roomBaseX; + ex += _globals->_roomBaseX; debug("add hotspot at %3d:%3d - %3d:%3d, action = %d", x, y, ex, ey, b0); #ifdef EDEN_DEBUG for (int iii = x; iii < ex; iii++) @@ -5346,7 +5345,7 @@ void EdenGame::displaySingleRoom(Room *room) { icon->sy = y; icon->ex = ex; icon->ey = ey; - p_global->_nextRoomIcon = ++icon; + _globals->_nextRoomIcon = ++icon; icon->sx = -1; } else ptr += 8; @@ -5359,16 +5358,16 @@ void EdenGame::displaySingleRoom(Room *room) { // Original name: afsalle void EdenGame::displayRoom() { - Room *room = p_global->_roomPtr; - p_global->_displayFlags = DisplayFlags::dfFlag1; - p_global->_roomBaseX = 0; - p_global->_roomBackgroundBankNum = room->_backgroundBankNum; + Room *room = _globals->_roomPtr; + _globals->_displayFlags = DisplayFlags::dfFlag1; + _globals->_roomBaseX = 0; + _globals->_roomBackgroundBankNum = room->_backgroundBankNum; if (room->_flags & RoomFlags::rf08) { - p_global->_displayFlags |= DisplayFlags::dfFlag80; + _globals->_displayFlags |= DisplayFlags::dfFlag80; if (room->_flags & RoomFlags::rfPanable) { // Scrollable room on 2 screens - p_global->_displayFlags |= DisplayFlags::dfPanable; - p_global->_varF4 = 0; + _globals->_displayFlags |= DisplayFlags::dfPanable; + _globals->_varF4 = 0; rundcurs(); saveFriezes(); useBank(room->_bank - 1); @@ -5376,14 +5375,14 @@ void EdenGame::displayRoom() { useBank(room->_bank); noclipax_avecnoir(0, 320, 16); displaySingleRoom(room); - p_global->_roomBaseX = 320; + _globals->_roomBaseX = 320; displaySingleRoom(room + 1); } else displaySingleRoom(room); } else { //TODO: roomImgBank is garbage here! - debug("drawroom: room 0x%X using bank %d", p_global->_roomNum, p_global->_roomImgBank); - useBank(p_global->_roomImgBank); + debug("drawroom: room 0x%X using bank %d", _globals->_roomNum, _globals->_roomImgBank); + useBank(_globals->_roomImgBank); displaySingleRoom(room); assert(_vm->ScreenView->_pitch == 320); } @@ -5393,117 +5392,117 @@ void EdenGame::displayRoom() { void EdenGame::displayPlace() { no_perso(); if (!pomme_q) { - p_global->_iconsIndex = 16; - p_global->_autoDialog = false; + _globals->_iconsIndex = 16; + _globals->_autoDialog = false; } - p_global->_nextRoomIcon = &_gameIcons[_roomIconsBase]; + _globals->_nextRoomIcon = &_gameIcons[_roomIconsBase]; displayRoom(); _paletteUpdateRequired = true; } // Original name: loadsal void EdenGame::loadPlace(int16 num) { - if (num == p_global->_lastPlaceNum) + if (num == _globals->_lastPlaceNum) return; - p_global->_lastPlaceNum = num; + _globals->_lastPlaceNum = num; loadRawFile(num + 419, _placeRawBuf); } void EdenGame::specialoutside() { - if (p_global->_lastAreaPtr->_type == AreaType::atValley && (p_global->_party & PersonMask::pmLeader)) + if (_globals->_lastAreaPtr->_type == AreaType::atValley && (_globals->_party & PersonMask::pmLeader)) perso_ici(5); } void EdenGame::specialout() { - if (p_global->_gameDays - p_global->_eloiDepartureDay > 2) { + if (_globals->_gameDays - _globals->_eloiDepartureDay > 2) { if (checkEloiReturn()) handleEloiReturn(); } - if (p_global->_phaseNum >= 32 && p_global->_phaseNum < 48) { - if (p_global->_newLocation == 9 || p_global->_newLocation == 4 || p_global->_newLocation == 24) { + if (_globals->_phaseNum >= 32 && _globals->_phaseNum < 48) { + if (_globals->_newLocation == 9 || _globals->_newLocation == 4 || _globals->_newLocation == 24) { kPersons[PER_MESSENGER]._roomNum = 263; return; } } - if ((p_global->_phaseNum == 434) && (p_global->_newLocation == 5)) { + if ((_globals->_phaseNum == 434) && (_globals->_newLocation == 5)) { removeFromParty(PER_TORMENTOR); kPersons[PER_TORMENTOR]._roomNum = 264; return; } - if (p_global->_phaseNum < 400) { - if ((p_global->_gameFlags & GameFlags::gfFlag4000) && p_global->_prevLocation == 1 - && (p_global->_party & PersonMask::pmEloi) && p_global->_curAreaType == AreaType::atValley) + if (_globals->_phaseNum < 400) { + if ((_globals->_gameFlags & GameFlags::gfFlag4000) && _globals->_prevLocation == 1 + && (_globals->_party & PersonMask::pmEloi) && _globals->_curAreaType == AreaType::atValley) handleEloiDeparture(); } - if (p_global->_phaseNum == 386) { - if (p_global->_prevLocation == 1 - && (p_global->_party & PersonMask::pmEloi) && p_global->_areaNum == Areas::arCantura) + if (_globals->_phaseNum == 386) { + if (_globals->_prevLocation == 1 + && (_globals->_party & PersonMask::pmEloi) && _globals->_areaNum == Areas::arCantura) handleEloiDeparture(); } } void EdenGame::specialin() { - if (!(p_global->_party & PersonMask::pmEloi) && (p_global->_partyOutside & PersonMask::pmEloi) && (p_global->_roomNum & 0xFF) == 1) { + if (!(_globals->_party & PersonMask::pmEloi) && (_globals->_partyOutside & PersonMask::pmEloi) && (_globals->_roomNum & 0xFF) == 1) { addToParty(PER_MESSENGER); - p_global->_eloiHaveNews = 1; + _globals->_eloiHaveNews = 1; } - if (p_global->_roomNum == 288) - p_global->_gameFlags |= GameFlags::gfFlag100 | GameFlags::gfFlag2000; - if (p_global->_roomNum == 3075 && p_global->_phaseNum == 546) { + if (_globals->_roomNum == 288) + _globals->_gameFlags |= GameFlags::gfFlag100 | GameFlags::gfFlag2000; + if (_globals->_roomNum == 3075 && _globals->_phaseNum == 546) { incPhase(); - if (p_global->_curItemsMask & 0x2000) { // Morkus' tablet + if (_globals->_curItemsMask & 0x2000) { // Morkus' tablet bars_out(); playHNM(92); _gameRooms[129]._exits[0] = 0; _gameRooms[129]._exits[2] = 1; - p_global->_roomNum = 3074; + _globals->_roomNum = 3074; kPersons[PER_MANGO]._roomNum = 3074; - p_global->_eventType = EventType::etEvent5; - updateRoom(p_global->_roomNum); + _globals->_eventType = EventType::etEvent5; + updateRoom(_globals->_roomNum); return; } - p_global->_narratorSequence = 53; + _globals->_narratorSequence = 53; } - if (p_global->_roomNum == 1793 && p_global->_phaseNum == 336) + if (_globals->_roomNum == 1793 && _globals->_phaseNum == 336) handleEloiDeparture(); - if (p_global->_roomNum == 259 && p_global->_phaseNum == 129) - p_global->_narratorSequence = 12; - if (p_global->_roomNum >= 289 && p_global->_roomNum < 359) - p_global->_labyrinthDirections = kLabyrinthPath[(p_global->_roomNum & 0xFF) - 33]; - if (p_global->_roomNum == 305 && p_global->_prevLocation == 103) - p_global->_gameFlags &= ~GameFlags::gfFlag2000; - if (p_global->_roomNum == 304 && p_global->_prevLocation == 105) - p_global->_gameFlags &= ~GameFlags::gfFlag2000; - if (p_global->_phaseNum < 226) { - if (p_global->_roomNum == 842) - p_global->_gameFlags |= GameFlags::gfFlag2; - if (p_global->_roomNum == 1072) - p_global->_gameFlags |= GameFlags::gfFlag4; - if (p_global->_roomNum == 1329) - p_global->_gameFlags |= GameFlags::gfFlag8000; + if (_globals->_roomNum == 259 && _globals->_phaseNum == 129) + _globals->_narratorSequence = 12; + if (_globals->_roomNum >= 289 && _globals->_roomNum < 359) + _globals->_labyrinthDirections = kLabyrinthPath[(_globals->_roomNum & 0xFF) - 33]; + if (_globals->_roomNum == 305 && _globals->_prevLocation == 103) + _globals->_gameFlags &= ~GameFlags::gfFlag2000; + if (_globals->_roomNum == 304 && _globals->_prevLocation == 105) + _globals->_gameFlags &= ~GameFlags::gfFlag2000; + if (_globals->_phaseNum < 226) { + if (_globals->_roomNum == 842) + _globals->_gameFlags |= GameFlags::gfFlag2; + if (_globals->_roomNum == 1072) + _globals->_gameFlags |= GameFlags::gfFlag4; + if (_globals->_roomNum == 1329) + _globals->_gameFlags |= GameFlags::gfFlag8000; } } void EdenGame::animpiece() { - Room *room = p_global->_roomPtr; - if (p_global->_roomVidNum && p_global->_var100 != 0xFF) { - if (p_global->_valleyVidNum || !room->_level || (room->_flags & RoomFlags::rfHasCitadel) - || room->_level == p_global->_var100) { + Room *room = _globals->_roomPtr; + if (_globals->_roomVidNum && _globals->_var100 != 0xFF) { + if (_globals->_valleyVidNum || !room->_level || (room->_flags & RoomFlags::rfHasCitadel) + || room->_level == _globals->_var100) { bars_out(); - p_global->_updatePaletteFlag = 16; - if (!(p_global->_narratorSequence & 0x80)) //TODO: bug? !() @ 100DC - p_global->_mirrorEffect = 0; - if (!needToFade) - needToFade = room->_flags & RoomFlags::rf02; - playHNM(p_global->_roomVidNum); + _globals->_updatePaletteFlag = 16; + if (!(_globals->_narratorSequence & 0x80)) //TODO: bug? !() @ 100DC + _globals->_mirrorEffect = 0; + if (!_needToFade) + _needToFade = room->_flags & RoomFlags::rf02; + playHNM(_globals->_roomVidNum); return; } } - p_global->_varF1 &= ~RoomFlags::rf04; + _globals->_varF1 &= ~RoomFlags::rf04; } void EdenGame::getdino(Room *room) { @@ -5513,16 +5512,16 @@ void EdenGame::getdino(Room *room) { for (perso_t *perso = &kPersons[PER_UNKN_18C]; perso->_roomNum != 0xFFFF; perso++) { if (perso->_flags & PersonFlags::pf80) continue; - if (perso->_roomNum != p_global->_roomNum) + if (perso->_roomNum != _globals->_roomNum) continue; byte persoType = perso->_flags & PersonFlags::pfTypeMask; if (persoType == PersonFlags::pftVelociraptor) - removeInfo(p_global->_citadelAreaNum + ValleyNews::vnVelociraptorsIn); + removeInfo(_globals->_citadelAreaNum + ValleyNews::vnVelociraptorsIn); if (persoType == PersonFlags::pftTriceraptor) - removeInfo(p_global->_citadelAreaNum + ValleyNews::vnTriceraptorsIn); + removeInfo(_globals->_citadelAreaNum + ValleyNews::vnTriceraptorsIn); perso->_flags |= PersonFlags::pf20; int16 *tab = tab_2CF70; - if (p_global->_areaNum != Areas::arUluru && p_global->_areaNum != Areas::arTamara) + if (_globals->_areaNum != Areas::arUluru && _globals->_areaNum != Areas::arTamara) tab = tab_2CEF0; byte r27 = (room->_flags & 0xC0) >> 2; //TODO: check me (like pc) persoType = perso->_flags & PersonFlags::pfTypeMask; @@ -5530,68 +5529,68 @@ void EdenGame::getdino(Room *room) { persoType = 13; r27 |= (persoType & 7) << 1; //TODO: check me 13 & 7 = ??? tab += r27; - p_global->_roomVidNum = *tab++; + _globals->_roomVidNum = *tab++; int16 bank = *tab; if (bank & 0x8000) { bank &= ~0x8000; room->_flags |= RoomFlags::rf08; } room->_flags |= RoomFlags::rf04 | RoomFlags::rf02; - p_global->_roomImgBank = bank; + _globals->_roomImgBank = bank; break; } } // Original name: getsalle Room *EdenGame::getRoom(int16 loc) { //TODO: byte? - debug("get room for %X, starting from %d, looking for %X", loc, p_global->_areaPtr->_firstRoomIdx, p_global->_partyOutside); - Room *room = &_gameRooms[p_global->_areaPtr->_firstRoomIdx]; + debug("get room for %X, starting from %d, looking for %X", loc, _globals->_areaPtr->_firstRoomIdx, _globals->_partyOutside); + Room *room = &_gameRooms[_globals->_areaPtr->_firstRoomIdx]; loc &= 0xFF; for (;; room++) { for (; room->_location != loc; room++) { if (room->_id == 0xFF) return 0; } - if (p_global->_partyOutside == room->_party || room->_party == 0xFFFF) + if (_globals->_partyOutside == room->_party || room->_party == 0xFFFF) break; } debug("found room: party = %X, bank = %X", room->_party, room->_bank); - p_global->_roomImgBank = room->_bank; - p_global->_labyrinthRoom = 0; - if (p_global->_roomImgBank > 104 && p_global->_roomImgBank <= 112) - p_global->_labyrinthRoom = p_global->_roomImgBank - 103; - if (p_global->_valleyVidNum) - p_global->_roomVidNum = p_global->_valleyVidNum; + _globals->_roomImgBank = room->_bank; + _globals->_labyrinthRoom = 0; + if (_globals->_roomImgBank > 104 && _globals->_roomImgBank <= 112) + _globals->_labyrinthRoom = _globals->_roomImgBank - 103; + if (_globals->_valleyVidNum) + _globals->_roomVidNum = _globals->_valleyVidNum; else - p_global->_roomVidNum = room->_video; + _globals->_roomVidNum = room->_video; if ((room->_flags & 0xC0) == RoomFlags::rf40 || (room->_flags & RoomFlags::rf01)) getdino(room); if (room->_flags & RoomFlags::rfHasCitadel) { - removeInfo(p_global->_areaNum + ValleyNews::vnCitadelLost); - removeInfo(p_global->_areaNum + ValleyNews::vnTyrannIn); - removeInfo(p_global->_areaNum + ValleyNews::vnTyrannLost); - removeInfo(p_global->_areaNum + ValleyNews::vnVelociraptorsLost); + removeInfo(_globals->_areaNum + ValleyNews::vnCitadelLost); + removeInfo(_globals->_areaNum + ValleyNews::vnTyrannIn); + removeInfo(_globals->_areaNum + ValleyNews::vnTyrannLost); + removeInfo(_globals->_areaNum + ValleyNews::vnVelociraptorsLost); } - if (istyran(p_global->_roomNum)) - p_global->_gameFlags |= GameFlags::gfFlag10; + if (istyran(_globals->_roomNum)) + _globals->_gameFlags |= GameFlags::gfFlag10; else - p_global->_gameFlags &= ~GameFlags::gfFlag10; + _globals->_gameFlags &= ~GameFlags::gfFlag10; return room; } // Original name: initlieu void EdenGame::initPlace(int16 roomNum) { - p_global->_gameFlags |= GameFlags::gfFlag4000; + _globals->_gameFlags |= GameFlags::gfFlag4000; _gameIcons[18]._cursorId |= 0x8000; - p_global->_lastAreaPtr = p_global->_areaPtr; - p_global->_areaPtr = &kAreasTable[((roomNum >> 8) & 0xFF) - 1]; - Area *area = p_global->_areaPtr; + _globals->_lastAreaPtr = _globals->_areaPtr; + _globals->_areaPtr = &kAreasTable[((roomNum >> 8) & 0xFF) - 1]; + Area *area = _globals->_areaPtr; area->_visitCount++; - p_global->_areaVisitCount = area->_visitCount; - p_global->_curAreaFlags = area->_flags; - p_global->_curAreaType = area->_type; - p_global->_curCitadelLevel = area->_citadelLevel; - if (p_global->_curAreaType == AreaType::atValley) + _globals->_areaVisitCount = area->_visitCount; + _globals->_curAreaFlags = area->_flags; + _globals->_curAreaType = area->_type; + _globals->_curCitadelLevel = area->_citadelLevel; + if (_globals->_curAreaType == AreaType::atValley) _gameIcons[18]._cursorId &= ~0x8000; loadPlace(area->_placeNum); } @@ -5599,54 +5598,54 @@ void EdenGame::initPlace(int16 roomNum) { void EdenGame::maj2() { displayPlace(); assert(_vm->ScreenView->_pitch == 320); - if (p_global->_roomNum == 273 && p_global->_prevLocation == 18) - p_global->_mirrorEffect = 1; - if (p_global->_eventType == EventType::etEventC) { + if (_globals->_roomNum == 273 && _globals->_prevLocation == 18) + _globals->_mirrorEffect = 1; + if (_globals->_eventType == EventType::etEventC) { drawTopScreen(); showObjects(); } FRDevents(); assert(_vm->ScreenView->_pitch == 320); bool r30 = false; - if (p_global->_curAreaType == AreaType::atValley && !(p_global->_displayFlags & DisplayFlags::dfPanable)) + if (_globals->_curAreaType == AreaType::atValley && !(_globals->_displayFlags & DisplayFlags::dfPanable)) r30 = true; //TODO: ^^ inlined func? - if (p_global->_mirrorEffect || p_global->_var103) + if (_globals->_mirrorEffect || _globals->_var103) display(); - else if (p_global->_varF1 == (RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01)) { + else if (_globals->_varF1 == (RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01)) { drawBlackBars(); displayEffect1(); - } else if (p_global->_varF1 && !(p_global->_varF1 & RoomFlags::rf04) && !r30) { - if (!(p_global->_displayFlags & DisplayFlags::dfPanable)) + } else if (_globals->_varF1 && !(_globals->_varF1 & RoomFlags::rf04) && !r30) { + if (!(_globals->_displayFlags & DisplayFlags::dfPanable)) drawBlackBars(); - else if (p_global->_valleyVidNum) + else if (_globals->_valleyVidNum) drawBlackBars(); displayEffect1(); - } else if (r30 && !(p_global->_varF1 & RoomFlags::rf04)) + } else if (r30 && !(_globals->_varF1 & RoomFlags::rf04)) effetpix(); else afficher128(); musique(); - if (p_global->_eventType != EventType::etEventC) { + if (_globals->_eventType != EventType::etEventC) { drawTopScreen(); showObjects(); } showBars(); showEvents(); - p_global->_labyrinthDirections = 0; + _globals->_labyrinthDirections = 0; specialin(); } // Original name: majsalle1 void EdenGame::updateRoom1(int16 roomNum) { Room *room = getRoom(roomNum & 0xFF); - p_global->_roomPtr = room; - debug("DrawRoom: room 0x%X, arg = 0x%X", p_global->_roomNum, roomNum); - p_global->_curRoomFlags = room->_flags; - p_global->_varF1 = room->_flags; + _globals->_roomPtr = room; + debug("DrawRoom: room 0x%X, arg = 0x%X", _globals->_roomNum, roomNum); + _globals->_curRoomFlags = room->_flags; + _globals->_varF1 = room->_flags; animpiece(); - p_global->_var100 = 0; + _globals->_var100 = 0; maj2(); } @@ -5658,54 +5657,54 @@ void EdenGame::updateRoom(uint16 roomNum) { // Original name: initbuf void EdenGame::allocateBuffers() { -#define ALLOC(ptr, size, typ) if (!((ptr) = (typ*)malloc(size))) bufferAllocationErrorFl = true; +#define ALLOC(ptr, size, typ) if (!((ptr) = (typ*)malloc(size))) _bufferAllocationErrorFl = true; ALLOC(_gameRooms, 0x4000, Room); ALLOC(_gameIcons, 0x4000, Icon); ALLOC(_bankDataBuf, 0x10000, byte); - ALLOC(p_global, sizeof(*p_global), global_t); + ALLOC(_globals, sizeof(*_globals), global_t); ALLOC(_placeRawBuf, 2048, byte); ALLOC(_gameConditions, 0x4800, byte); ALLOC(_gameDialogs, 0x2800, byte); - ALLOC(gamePhrases, 0x10000, byte); + ALLOC(_gamePhrases, 0x10000, byte); ALLOC(_mainBankBuf, 0x9400, byte); ALLOC(_glowBuffer, 0x2800, byte); ALLOC(_gameFont, 0x900, byte); - ALLOC(gameLipsync, 0x205C, byte); + ALLOC(_gameLipsync, 0x205C, byte); ALLOC(_musicBuf, 0x140000, byte); #undef ALLOC } void EdenGame::freebuf() { - delete(bigfile_header); - bigfile_header = nullptr; + delete(_bigfileHeader); + _bigfileHeader = nullptr; free(_gameRooms); free(_gameIcons); free(_bankDataBuf); - free(p_global); + free(_globals); free(_placeRawBuf); free(_gameConditions); free(_gameDialogs); - free(gamePhrases); + free(_gamePhrases); free(_mainBankBuf); free(_glowBuffer); free(_gameFont); - free(gameLipsync); + free(_gameLipsync); free(_musicBuf); } void EdenGame::openWindow() { - p_underBarsView = new View(_vm, 320, 40); - p_underBarsView->_normal._width = 320; + _underBarsView = new View(_vm, 320, 40); + _underBarsView->_normal._width = 320; - p_view2 = new View(_vm, 32, 32); - p_view2_buf = p_view2->_bufferPtr; + _view2 = new View(_vm, 32, 32); + _view2Buf = _view2->_bufferPtr; _subtitlesView = new View(_vm, _subtitlesXWidth, 60); _subtitlesViewBuf = _subtitlesView->_bufferPtr; - p_underSubtitlesView = new View(_vm, _subtitlesXWidth, 60); - p_underSubtitlesView_buf = p_underSubtitlesView->_bufferPtr; + _underSubtitlesView = new View(_vm, _subtitlesXWidth, 60); + _underSubtitlesViewBuf = _underSubtitlesView->_bufferPtr; _mainView = new View(_vm, 640, 200); _mainView->_normal._width = 320; @@ -5749,7 +5748,7 @@ void EdenGame::run() { openWindow(); loadpermfiles(); - if (!bufferAllocationErrorFl) { + if (!_bufferAllocationErrorFl) { LostEdenMac_InitPrefs(); if (_vm->getPlatform() == Common::kPlatformMacintosh) initCubeMac(); @@ -5772,7 +5771,7 @@ void EdenGame::run() { fadeToBlack(3); clearScreen(); playHNM(95); - if (p_global->_endGameFlag == 50) { + if (_globals->_endGameFlag == 50) { loadrestart(); _gameLoaded = false; } @@ -5796,7 +5795,7 @@ void EdenGame::run() { void EdenGame::edmain() { //TODO enterGame(); - while (!bufferAllocationErrorFl && !_quitFlag3 && p_global->_endGameFlag != 50) { + while (!_bufferAllocationErrorFl && !_quitFlag3 && _globals->_endGameFlag != 50) { if (!_gameStarted) { // if in demo mode, reset game after a while _demoCurrentTicks = _vm->_timerTicks; @@ -5819,17 +5818,17 @@ void EdenGame::edmain() { FRDevents(); narrateur(); evenchrono(); - if (p_global->_drawFlags & DrawFlags::drDrawInventory) + if (_globals->_drawFlags & DrawFlags::drDrawInventory) showObjects(); - if (p_global->_drawFlags & DrawFlags::drDrawTopScreen) + if (_globals->_drawFlags & DrawFlags::drDrawTopScreen) drawTopScreen(); - if ((p_global->_displayFlags & DisplayFlags::dfPanable) && (p_global->_displayFlags != DisplayFlags::dfPerson)) + if ((_globals->_displayFlags & DisplayFlags::dfPanable) && (_globals->_displayFlags != DisplayFlags::dfPerson)) scrollPanel(); - if ((p_global->_displayFlags & DisplayFlags::dfMirror) && (p_global->_displayFlags != DisplayFlags::dfPerson)) + if ((_globals->_displayFlags & DisplayFlags::dfMirror) && (_globals->_displayFlags != DisplayFlags::dfPerson)) scrollMirror(); - if ((p_global->_displayFlags & DisplayFlags::dfFrescoes) && (p_global->_displayFlags != DisplayFlags::dfPerson)) + if ((_globals->_displayFlags & DisplayFlags::dfFrescoes) && (_globals->_displayFlags != DisplayFlags::dfPerson)) scrollFrescoes(); - if (p_global->_displayFlags & DisplayFlags::dfFlag2) + if (_globals->_displayFlags & DisplayFlags::dfFlag2) noclicpanel(); if (_animationActive) anim_perso(); @@ -5866,34 +5865,34 @@ void EdenGame::intro() { void EdenGame::enterGame() { char flag = 0; _currentTime = _vm->_timerTicks / 100; - p_global->_gameTime = _currentTime; + _globals->_gameTime = _currentTime; _demoStartTicks = _vm->_timerTicks; _gameStarted = false; if (!_gameLoaded) { - p_global->_roomNum = 279; - p_global->_areaNum = Areas::arMo; - p_global->_var100 = 0xFF; - initPlace(p_global->_roomNum); - p_global->_currMusicNum = 0; + _globals->_roomNum = 279; + _globals->_areaNum = Areas::arMo; + _globals->_var100 = 0xFF; + initPlace(_globals->_roomNum); + _globals->_currMusicNum = 0; startmusique(1); } else { - flag = p_global->_autoDialog; //TODO + flag = _globals->_autoDialog; //TODO initafterload(); - lastMusicNum = p_global->_currMusicNum; //TODO: ??? - p_global->_currMusicNum = 0; + byte lastMusicNum = _globals->_currMusicNum; //TODO: ??? + _globals->_currMusicNum = 0; startmusique(lastMusicNum); - p_global->_inventoryScrollPos = 0; + _globals->_inventoryScrollPos = 0; _gameStarted = true; } showObjects(); drawTopScreen(); saveFriezes(); _showBlackBars = true; - p_global->_mirrorEffect = 1; - updateRoom(p_global->_roomNum); + _globals->_mirrorEffect = 1; + updateRoom(_globals->_roomNum); if (flag) { - p_global->_iconsIndex = 4; - p_global->_autoDialog = true; + _globals->_iconsIndex = 4; + _globals->_autoDialog = true; parle_moi(); } } @@ -5936,15 +5935,15 @@ void EdenGame::FRDevents() { _cursorPosX = CLIP<int16>(_cursorPosX, 4, 292); _cursorPosY += mouseY; - int16 maxY = p_global->_displayFlags == DisplayFlags::dfFlag2 ? 190 : 170; + int16 maxY = _globals->_displayFlags == DisplayFlags::dfFlag2 ? 190 : 170; _cursorPosY = CLIP<int16>(_cursorPosY, 4, maxY); _cirsorPanX = _cursorPosX; - if (_cursorPosY >= 10 && _cursorPosY <= 164 && !(p_global->_displayFlags & DisplayFlags::dfFrescoes)) + if (_cursorPosY >= 10 && _cursorPosY <= 164 && !(_globals->_displayFlags & DisplayFlags::dfFrescoes)) _cirsorPanX += _scrollPos; if (_normalCursor) { _currCursor = 0; - _currSpot = scan_icon_list(_cirsorPanX + _cursCenter, _cursorPosY + _cursCenter, p_global->_iconsIndex); + _currSpot = scan_icon_list(_cirsorPanX + _cursCenter, _cursorPosY + _cursCenter, _globals->_iconsIndex); if (_currSpot) _currCursor = _currSpot->_cursorId; } @@ -5956,7 +5955,7 @@ void EdenGame::FRDevents() { _cursCenter = 0; _cursorPosX += 11; } - if (p_global->_displayFlags & DisplayFlags::dfPanable) { + if (_globals->_displayFlags & DisplayFlags::dfPanable) { //TODO: _currSpot may be zero (due to scan_icon_list failure) if cursor slips between hot areas. //fix me here or above? if (_currSpot) { // ok, plug it here @@ -5964,9 +5963,9 @@ void EdenGame::FRDevents() { displayAdamMapMark(_curSpot2->_actionId - 14); } } - if (p_global->_displayFlags == DisplayFlags::dfFlag2 && _currSpot) + if (_globals->_displayFlags == DisplayFlags::dfFlag2 && _currSpot) _curSpot2 = _currSpot; - if (p_global->_displayFlags & DisplayFlags::dfFrescoes) { + if (_globals->_displayFlags & DisplayFlags::dfFrescoes) { if (_frescoTalk) restoreUnderSubtitles(); if (_currCursor == 9 && !_torchCursor) { @@ -5988,17 +5987,17 @@ void EdenGame::FRDevents() { } } else _mouseHeld = false; - if (p_global->_displayFlags != DisplayFlags::dfFlag2) { + if (_globals->_displayFlags != DisplayFlags::dfFlag2) { if (--_inventoryScrollDelay <= 0) { - if (p_global->_objCount > _invIconsCount && _cursorPosY > 164) { - if (_cursorPosX > 284 && p_global->_inventoryScrollPos + _invIconsCount < p_global->_objCount) { - p_global->_inventoryScrollPos++; + if (_globals->_objCount > _invIconsCount && _cursorPosY > 164) { + if (_cursorPosX > 284 && _globals->_inventoryScrollPos + _invIconsCount < _globals->_objCount) { + _globals->_inventoryScrollPos++; _inventoryScrollDelay = 20; showObjects(); } - if (_cursorPosX < 30 && p_global->_inventoryScrollPos != 0) { - p_global->_inventoryScrollPos--; + if (_cursorPosX < 30 && _globals->_inventoryScrollPos != 0) { + _globals->_inventoryScrollPos--; _inventoryScrollDelay = 20; showObjects(); } @@ -6356,7 +6355,7 @@ void EdenGame::mouse() { }; if (!(_currSpot = scan_icon_list(_cirsorPanX + _cursCenter, - _cursorPosY + _cursCenter, p_global->_iconsIndex))) + _cursorPosY + _cursCenter, _globals->_iconsIndex))) return; _curSpot2 = _currSpot; debug("invoking mouse action %d", _currSpot->_actionId); @@ -6433,16 +6432,16 @@ void EdenGame::playHNM(int16 num) { int16 oldDialogType = -1; _vm->_video->_curVideoNum = num; if (num != 2001 && num != 2012 && num != 98 && num != 171) { - byte oldMusicType = p_global->_newMusicType; - p_global->_newMusicType = MusicType::mtEvent; + byte oldMusicType = _globals->_newMusicType; + _globals->_newMusicType = MusicType::mtEvent; musique(); musicspy(); - p_global->_newMusicType = oldMusicType; + _globals->_newMusicType = oldMusicType; } - p_global->_videoSubtitleIndex = 1; + _globals->_videoSubtitleIndex = 1; if (_specialTextMode) { - perso = p_global->_characterPtr; - oldDialogType = p_global->_dialogType; + perso = _globals->_characterPtr; + oldDialogType = _globals->_dialogType; prechargephrases(num); fademusica0(1); _musicChannel->stop(); @@ -6452,10 +6451,10 @@ void EdenGame::playHNM(int16 num) { shnmfl(num); _vm->_video->reset(_hnmContext); _vm->_video->flushPreloadBuffer(_hnmContext); - if (needToFade) { + if (_needToFade) { fadeToBlack(4); clearScreen(); - needToFade = false; + _needToFade = false; } if (num == 2012 || num == 98 || num == 171) showMovie(0); @@ -6466,22 +6465,22 @@ void EdenGame::playHNM(int16 num) { if (_specialTextMode) { _musicFadeFlag = 3; musicspy(); - p_global->_characterPtr = perso; - p_global->_dialogType = oldDialogType; + _globals->_characterPtr = perso; + _globals->_dialogType = oldDialogType; _specialTextMode = false; } if (_videoCanceledFlag) - p_global->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; + _globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; if (_vm->_video->_curVideoNum == 167) - p_global->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; + _globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; if (_vm->_video->_curVideoNum == 104) - p_global->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; + _globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; if (_vm->_video->_curVideoNum == 102) - p_global->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; + _globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; if (_vm->_video->_curVideoNum == 77) - p_global->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; + _globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; if (_vm->_video->_curVideoNum == 149) - p_global->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; + _globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; } // Original name bullehnm @@ -6526,10 +6525,10 @@ void EdenGame::handleHNMSubtitles() { if (frame & 0x8000) _showVideoSubtitle = false; else { - p_global->_videoSubtitleIndex = (frames - frames_start) / 2 + 1; - p_global->_characterPtr = perso; - p_global->_dialogType = DialogType::dtInspect; - int16 num = (perso->_id << 3) | p_global->_dialogType; + _globals->_videoSubtitleIndex = (frames - frames_start) / 2 + 1; + _globals->_characterPtr = perso; + _globals->_dialogType = DialogType::dtInspect; + int16 num = (perso->_id << 3) | _globals->_dialogType; dialoscansvmas((dial_t *)getElem(_gameDialogs, num)); _showVideoSubtitle = true; } @@ -6539,7 +6538,7 @@ void EdenGame::handleHNMSubtitles() { ////// sound.c void EdenGame::musique() { - if (p_global->_newMusicType == MusicType::mtDontChange) + if (_globals->_newMusicType == MusicType::mtDontChange) return; dial_t *dial = (dial_t *)getElem(_gameDialogs, 128); @@ -6555,13 +6554,13 @@ void EdenGame::musique() { break; } byte mus = dial->_textNumLow; - p_global->_newMusicType = MusicType::mtDontChange; + _globals->_newMusicType = MusicType::mtDontChange; if (mus != 0 && mus != 2 && mus < 50) startmusique(mus); } void EdenGame::startmusique(byte num) { - if (num == p_global->_currMusicNum) + if (num == _globals->_currMusicNum) return; if (_musicPlayingFlag) { @@ -6569,7 +6568,7 @@ void EdenGame::startmusique(byte num) { _musicChannel->stop(); } loadmusicfile(num); - p_global->_currMusicNum = num; + _globals->_currMusicNum = num; _musSequencePtr = _musicBuf + 32; //TODO: rewrite it properly int16 seq_size = READ_LE_UINT16(_musicBuf + 30); _musicPatternsPtr = _musicBuf + 30 + seq_size; @@ -6582,16 +6581,16 @@ void EdenGame::startmusique(byte num) { _musicEnabledFlag = true; _musicSequencePos = 0; - _musicLeftVol = p_global->_prefMusicVol[0]; - _musicRightVol = p_global->_prefMusicVol[1]; + _musicLeftVol = _globals->_prefMusicVol[0]; + _musicRightVol = _globals->_prefMusicVol[1]; _musicChannel->setVolume(_musicLeftVol, _musicRightVol); } void EdenGame::musicspy() { if (!_musicEnabledFlag) return; - _musicLeftVol = p_global->_prefMusicVol[0]; - _musicRightVol = p_global->_prefMusicVol[1]; + _musicLeftVol = _globals->_prefMusicVol[0]; + _musicRightVol = _globals->_prefMusicVol[1]; if (_musicFadeFlag & 3) fademusicup(); if (_personTalking && !_voiceChannel->numQueued()) @@ -6613,26 +6612,26 @@ void EdenGame::musicspy() { } int EdenGame::loadmusicfile(int16 num) { - PakHeaderItem *file = &bigfile_header->_files[num + 435]; + PakHeaderItem *file = &_bigfileHeader->_files[num + 435]; int32 size = file->_size; int32 offs = file->_offs; - h_bigfile.seek(offs, SEEK_SET); + _bigfile.seek(offs, SEEK_SET); int32 numread = size; if (numread > 0x140000) //TODO: const numread = 0x140000; - h_bigfile.read(_musicBuf, numread); + _bigfile.read(_musicBuf, numread); return size; } void EdenGame::persovox() { - int16 num = p_global->_textNum; - if (p_global->_textBankIndex != 1) + int16 num = _globals->_textNum; + if (_globals->_textBankIndex != 1) num += 565; - if (p_global->_textBankIndex == 3) + if (_globals->_textBankIndex == 3) num += 707; _voiceSamplesSize = ssndfl(num); - int16 volumeLeft = p_global->_prefSoundVolume[0]; - int16 volumeRight = p_global->_prefSoundVolume[1]; + int16 volumeLeft = _globals->_prefSoundVolume[0]; + int16 volumeRight = _globals->_prefSoundVolume[1]; int16 stepLeft = _musicChannel->_volumeLeft < volumeLeft ? stepLeft = 1 : -1; int16 stepRight = _musicChannel->_volumeRight < volumeRight ? stepRight = 1 : -1; do { @@ -6641,8 +6640,8 @@ void EdenGame::persovox() { if (volumeRight != _musicChannel->_volumeRight) _musicChannel->setVolumeRight(_musicChannel->_volumeRight + stepRight); } while (_musicChannel->_volumeLeft != volumeLeft || _musicChannel->_volumeRight != volumeRight); - volumeLeft = p_global->_prefVoiceVol[0]; - volumeRight = p_global->_prefVoiceVol[1]; + volumeLeft = _globals->_prefVoiceVol[0]; + volumeRight = _globals->_prefVoiceVol[1]; _voiceChannel->setVolume(volumeLeft, volumeRight); _voiceChannel->queueBuffer(_voiceSamplesBuffer, _voiceSamplesSize, true); _personTalking = true; @@ -6743,17 +6742,17 @@ show_all_objects: if (count) { total += count; while (count--) - own_objects[index++] = _objects[i]._id; + _ownObjects[index++] = _objects[i]._id; } } - p_global->_objCount = total; + _globals->_objCount = total; } void EdenGame::showObjects() { Icon *icon = &_gameIcons[_invIconsBase]; - p_global->_drawFlags &= ~(DrawFlags::drDrawInventory | DrawFlags::drDrawFlag2); + _globals->_drawFlags &= ~(DrawFlags::drDrawInventory | DrawFlags::drDrawFlag2); countObjects(); - int16 total = p_global->_objCount; + int16 total = _globals->_objCount; for (int16 i = _invIconsCount; i--; icon++) { if (total) { icon->_cursorId &= ~0x8000; @@ -6764,15 +6763,15 @@ void EdenGame::showObjects() { useMainBank(); noclipax(55, 0, 176); icon = &_gameIcons[_invIconsBase]; - total = p_global->_objCount; - int16 index = p_global->_inventoryScrollPos; + total = _globals->_objCount; + int16 index = _globals->_inventoryScrollPos; for (int16 i = _invIconsCount; total-- && i--; icon++) { - char obj = own_objects[index++]; + char obj = _ownObjects[index++]; icon->_objectId = obj; noclipax(obj + 9, icon->sx, 178); } _paletteUpdateRequired = true; - if ((p_global->_displayFlags & DisplayFlags::dfMirror) || (p_global->_displayFlags & DisplayFlags::dfPanable)) { + if ((_globals->_displayFlags & DisplayFlags::dfMirror) || (_globals->_displayFlags & DisplayFlags::dfPanable)) { saveBottomFrieze(); scroll(); } @@ -6782,10 +6781,10 @@ void EdenGame::winObject(int16 id) { object_t *object = getObjectPtr(id); object->_flags |= ObjectFlags::ofFlag1; object->_count++; - p_global->_curItemsMask |= object->_itemMask; - p_global->_wonItemsMask |= object->_itemMask; - p_global->_curPowersMask |= object->_powerMask; - p_global->_wonPowersMask |= object->_powerMask; + _globals->_curItemsMask |= object->_itemMask; + _globals->_wonItemsMask |= object->_itemMask; + _globals->_curPowersMask |= object->_powerMask; + _globals->_wonPowersMask |= object->_powerMask; } void EdenGame::loseObject(int16 id) { @@ -6794,12 +6793,12 @@ void EdenGame::loseObject(int16 id) { object->_count--; if (!object->_count) { object->_flags &= ~ObjectFlags::ofFlag1; - p_global->_curItemsMask &= ~object->_itemMask; - p_global->_curPowersMask &= ~object->_powerMask; + _globals->_curItemsMask &= ~object->_itemMask; + _globals->_curPowersMask &= ~object->_powerMask; } - p_global->_curObjectId = 0; - p_global->_curObjectFlags = 0; - p_global->_curObjectCursor = 9; + _globals->_curObjectId = 0; + _globals->_curObjectFlags = 0; + _globals->_curObjectCursor = 9; _gameIcons[16]._cursorId |= 0x8000; object->_flags &= ~ObjectFlags::ofInHands; _normalCursor = true; @@ -6809,15 +6808,15 @@ void EdenGame::loseObject(int16 id) { void EdenGame::lostObject() { parlemoiNormalFlag = true; - if (p_global->_curObjectId) - loseObject(p_global->_curObjectId); + if (_globals->_curObjectId) + loseObject(_globals->_curObjectId); } // Original name: objecthere bool EdenGame::isObjectHere(int16 id) { object_t *object = getObjectPtr(id); - for (pCurrentObjectLocation = &kObjectLocations[object->_locations]; *pCurrentObjectLocation != 0xFFFF; pCurrentObjectLocation++) { - if (*pCurrentObjectLocation == p_global->_roomNum) + for (_currentObjectLocation = &kObjectLocations[object->_locations]; *_currentObjectLocation != 0xFFFF; _currentObjectLocation++) { + if (*_currentObjectLocation == _globals->_roomNum) return true; } return false; @@ -6826,41 +6825,41 @@ bool EdenGame::isObjectHere(int16 id) { void EdenGame::objectmain(int16 id) { object_t *object = getObjectPtr(id); _gameIcons[16]._cursorId &= ~0x8000; - p_global->_curObjectId = object->_id; - p_global->_curObjectCursor = p_global->_curObjectId + 9; + _globals->_curObjectId = object->_id; + _globals->_curObjectCursor = _globals->_curObjectId + 9; object->_flags |= ObjectFlags::ofInHands; - p_global->_curObjectFlags = object->_flags; - _currCursor = p_global->_curObjectId + 9; + _globals->_curObjectFlags = object->_flags; + _currCursor = _globals->_curObjectId + 9; _normalCursor = false; } void EdenGame::getObject(int16 id) { - Room *room = p_global->_roomPtr; - if (p_global->_curObjectId) + Room *room = _globals->_roomPtr; + if (_globals->_curObjectId) return; if (!isObjectHere(id)) return; - *pCurrentObjectLocation |= 0x8000; + *_currentObjectLocation |= 0x8000; objectmain(id); winObject(id); showObjects(); - p_global->_roomImgBank = room->_bank; - p_global->_roomVidNum = room->_video; + _globals->_roomImgBank = room->_bank; + _globals->_roomVidNum = room->_video; displayPlace(); } void EdenGame::putObject() { - if (!p_global->_curObjectId) + if (!_globals->_curObjectId) return; _gameIcons[16]._cursorId |= 0x8000; - object_t *object = getObjectPtr(p_global->_curObjectId); - p_global->_curObjectCursor = 9; - p_global->_curObjectId = 0; - p_global->_curObjectFlags = 0; + object_t *object = getObjectPtr(_globals->_curObjectId); + _globals->_curObjectCursor = 9; + _globals->_curObjectId = 0; + _globals->_curObjectFlags = 0; object->_flags &= ~ObjectFlags::ofInHands; - p_global->_nextDialogPtr = nullptr; + _globals->_nextDialogPtr = nullptr; _closeCharacterDialog = false; - p_global->_dialogType = DialogType::dtTalk; + _globals->_dialogType = DialogType::dtTalk; showObjects(); _normalCursor = true; } @@ -6880,29 +6879,29 @@ void EdenGame::giveobjectal(int16 id) { if (id == Objects::obKnife) kObjectLocations[2] = 0; if (id == Objects::obApple) - p_global->_stepsToFindAppleNormal = 0; - if (id >= Objects::obEyeInTheStorm && id < (Objects::obRiverThatWinds + 1) && p_global->_roomCharacterType == PersonFlags::pftVelociraptor) { + _globals->_stepsToFindAppleNormal = 0; + if (id >= Objects::obEyeInTheStorm && id < (Objects::obRiverThatWinds + 1) && _globals->_roomCharacterType == PersonFlags::pftVelociraptor) { //TODO: fix that cond above object_t *object = getObjectPtr(id); - p_global->_roomCharacterPtr->_powers &= ~object->_powerMask; + _globals->_roomCharacterPtr->_powers &= ~object->_powerMask; } winObject(id); } void EdenGame::giveObject() { - byte id = p_global->_giveObj1; + byte id = _globals->_giveObj1; if (id) { - p_global->_giveObj1 = 0; + _globals->_giveObj1 = 0; giveobjectal(id); } - id = p_global->_giveObj2; + id = _globals->_giveObj2; if (id) { - p_global->_giveObj2 = 0; + _globals->_giveObj2 = 0; giveobjectal(id); } - id = p_global->_giveObj3; + id = _globals->_giveObj3; if (id) { - p_global->_giveObj3 = 0; + _globals->_giveObj3 = 0; giveobjectal(id); } } @@ -6910,11 +6909,11 @@ void EdenGame::giveObject() { // Original name: takeObject void EdenGame::actionTakeObject() { objectmain(_curSpot2->_objectId); - p_global->_nextDialogPtr = nullptr; + _globals->_nextDialogPtr = nullptr; _closeCharacterDialog = false; - p_global->_dialogType = DialogType::dtTalk; - if (p_global->_inventoryScrollPos) - p_global->_inventoryScrollPos--; + _globals->_dialogType = DialogType::dtTalk; + if (_globals->_inventoryScrollPos) + _globals->_inventoryScrollPos--; showObjects(); } //// @@ -6922,19 +6921,19 @@ void EdenGame::actionTakeObject() { // Original name: newchampi void EdenGame::newMushroom() { if (_objects[Objects::obShroom - 1]._count == 0) { - newObject(Objects::obShroom, p_global->_citadelAreaNum); - newObject(Objects::obBadShroom, p_global->_citadelAreaNum); + newObject(Objects::obShroom, _globals->_citadelAreaNum); + newObject(Objects::obBadShroom, _globals->_citadelAreaNum); } } // Original name: newnidv void EdenGame::newEmptyNest() { - Room *room = p_global->_citaAreaFirstRoom; + Room *room = _globals->_citaAreaFirstRoom; if (_objects[Objects::obNest - 1]._count) return; object_t *obj = getObjectPtr(Objects::obNest); for (uint16 *ptr = kObjectLocations + obj->_locations; *ptr != 0xFFFF; ptr++) { - if ((*ptr & ~0x8000) >> 8 != p_global->_citadelAreaNum) + if ((*ptr & ~0x8000) >> 8 != _globals->_citadelAreaNum) continue; *ptr &= ~0x8000; for (; room->_id != 0xFF; room++) { @@ -6951,14 +6950,14 @@ void EdenGame::newEmptyNest() { // Original name: newnido void EdenGame::newNestWithEggs() { - Room *room = p_global->_citaAreaFirstRoom; + Room *room = _globals->_citaAreaFirstRoom; if (_objects[Objects::obFullNest - 1]._count) return; if (_objects[Objects::obNest - 1]._count) return; object_t *obj = getObjectPtr(Objects::obFullNest); for (uint16 *ptr = kObjectLocations + obj->_locations; *ptr != 0xFFFF; ptr++) { - if ((*ptr & ~0x8000) >> 8 != p_global->_citadelAreaNum) + if ((*ptr & ~0x8000) >> 8 != _globals->_citadelAreaNum) continue; *ptr &= ~0x8000; for (; room->_id != 0xFF; room++) { @@ -6975,19 +6974,19 @@ void EdenGame::newNestWithEggs() { void EdenGame::newor() { if (_objects[Objects::obGold - 1]._count == 0) { - newObject(Objects::obGold, p_global->_citadelAreaNum); + newObject(Objects::obGold, _globals->_citadelAreaNum); } } void EdenGame::gotoPanel() { if (pomme_q) - byte_31D64 = p_global->_autoDialog; //TODO: check me + byte_31D64 = _globals->_autoDialog; //TODO: check me _noPalette = false; - p_global->_iconsIndex = 85; - p_global->_characterPtr = nullptr; - p_global->_drawFlags |= DrawFlags::drDrawMenu; - p_global->_displayFlags = DisplayFlags::dfFlag2; - p_global->_menuFlags = 0; + _globals->_iconsIndex = 85; + _globals->_characterPtr = nullptr; + _globals->_drawFlags |= DrawFlags::drDrawMenu; + _globals->_displayFlags = DisplayFlags::dfFlag2; + _globals->_menuFlags = 0; displayPanel(); fadeToBlack(3); displayTopPanel(); @@ -6999,45 +6998,45 @@ void EdenGame::gotoPanel() { } void EdenGame::noclicpanel() { - if (p_global->_menuFlags & MenuFlags::mfFlag4) { + if (_globals->_menuFlags & MenuFlags::mfFlag4) { depcurstape(); return; } - if (p_global->_drawFlags & DrawFlags::drDrawFlag8) + if (_globals->_drawFlags & DrawFlags::drDrawFlag8) return; - if (p_global->_menuFlags & MenuFlags::mfFlag1) { + if (_globals->_menuFlags & MenuFlags::mfFlag1) { changervol(); return; } byte num; if (_curSpot2 >= &_gameIcons[119]) { - debug("noclic: objid = %p, glob3,2 = %2X %2X", (void *)_curSpot2, p_global->_menuItemIdHi, p_global->_menuItemIdLo); - if (_curSpot2->_objectId == (uint16)((p_global->_menuItemIdLo + p_global->_menuItemIdHi) << 8)) //TODO: check me + debug("noclic: objid = %p, glob3,2 = %2X %2X", (void *)_curSpot2, _globals->_menuItemIdHi, _globals->_menuItemIdLo); + if (_curSpot2->_objectId == (uint16)((_globals->_menuItemIdLo + _globals->_menuItemIdHi) << 8)) //TODO: check me return; } else { int idx = _curSpot2 - &_gameIcons[105]; if (idx == 0) { - p_global->_menuItemIdLo = 1; + _globals->_menuItemIdLo = 1; num = 1; goto skip; } num = idx & 0x7F + 1; if (num >= 5) num = 1; - if (num == p_global->_var43) + if (num == _globals->_var43) return; - p_global->_var43 = 0; + _globals->_var43 = 0; } - num = p_global->_menuItemIdLo; - p_global->_menuItemIdLo = _curSpot2->_objectId & 0xFF; + num = _globals->_menuItemIdLo; + _globals->_menuItemIdLo = _curSpot2->_objectId & 0xFF; skip: ; - p_global->_menuItemIdHi = (_curSpot2->_objectId & 0xFF00) >> 8; - debug("noclic: new glob3,2 = %2X %2X", p_global->_menuItemIdHi, p_global->_menuItemIdLo); + _globals->_menuItemIdHi = (_curSpot2->_objectId & 0xFF00) >> 8; + debug("noclic: new glob3,2 = %2X %2X", _globals->_menuItemIdHi, _globals->_menuItemIdLo); displayResult(); num &= 0xF0; if (num != 0x30) - num = p_global->_menuItemIdLo & 0xF0; + num = _globals->_menuItemIdLo & 0xF0; if (num == 0x30) displayCursors(); } @@ -7047,7 +7046,7 @@ void EdenGame::generique() { display(); fadeToBlack(3); clearScreen(); - int oldmusic = p_global->_currMusicNum; + int oldmusic = _globals->_currMusicNum; playHNM(95); displayPanel(); displayTopPanel(); @@ -7058,30 +7057,30 @@ void EdenGame::generique() { void EdenGame::cancel2() { drawTopScreen(); showObjects(); - p_global->_iconsIndex = 16; - p_global->_drawFlags &= ~DrawFlags::drDrawMenu; + _globals->_iconsIndex = 16; + _globals->_drawFlags &= ~DrawFlags::drDrawMenu; gameToMirror(1); } void EdenGame::testvoice() { - p_global->_frescoNumber = 0; - p_global->_characterPtr = kPersons; - p_global->_dialogType = DialogType::dtInspect; - int16 num = (kPersons[PER_KING]._id << 3) | p_global->_dialogType; + _globals->_frescoNumber = 0; + _globals->_characterPtr = kPersons; + _globals->_dialogType = DialogType::dtInspect; + int16 num = (kPersons[PER_KING]._id << 3) | _globals->_dialogType; dialoscansvmas((dial_t *)getElem(_gameDialogs, num)); restoreUnderSubtitles(); displaySubtitles(); persovox(); waitEndSpeak(); endCharacterSpeech(); - p_global->_varCA = 0; - p_global->_dialogType = DialogType::dtTalk; + _globals->_varCA = 0; + _globals->_dialogType = DialogType::dtTalk; } void EdenGame::load() { char name[132]; _gameLoaded = false; - byte oldMusic = p_global->_currMusicNum; //TODO: from uint16 to byte?! + byte oldMusic = _globals->_currMusicNum; //TODO: from uint16 to byte?! fademusica0(1); desktopcolors(); FlushEvents(-1, 0); @@ -7101,50 +7100,50 @@ void EdenGame::load() { _paletteUpdateRequired = true; return; } - if ((oldMusic & 0xFF) != p_global->_currMusicNum) { //TODO: r30 is uns char/bug??? - oldMusic = p_global->_currMusicNum; - p_global->_currMusicNum = 0; + if ((oldMusic & 0xFF) != _globals->_currMusicNum) { //TODO: r30 is uns char/bug??? + oldMusic = _globals->_currMusicNum; + _globals->_currMusicNum = 0; startmusique(oldMusic); } else { _musicFadeFlag = 3; musicspy(); } - bool talk = p_global->_autoDialog; //TODO check me + bool talk = _globals->_autoDialog; //TODO check me initafterload(); fadeToBlack(3); CLBlitter_FillScreenView(0); CLBlitter_FillView(_mainView, 0); drawTopScreen(); - p_global->_inventoryScrollPos = 0; + _globals->_inventoryScrollPos = 0; showObjects(); - updateRoom(p_global->_roomNum); + updateRoom(_globals->_roomNum); if (talk) { - p_global->_iconsIndex = 4; - p_global->_autoDialog = true; + _globals->_iconsIndex = 4; + _globals->_autoDialog = true; parle_moi(); } } void EdenGame::initafterload() { - p_global->_characterImageBank = 0; - p_global->_lastPlaceNum = 0; - loadPlace(p_global->_areaPtr->_placeNum); + _globals->_characterImageBank = 0; + _globals->_lastPlaceNum = 0; + loadPlace(_globals->_areaPtr->_placeNum); _gameIcons[18]._cursorId |= 0x8000; - if (p_global->_curAreaType == AreaType::atValley) + if (_globals->_curAreaType == AreaType::atValley) _gameIcons[18]._cursorId &= ~0x8000; kPersoRoomBankTable[30] = 27; - if (p_global->_phaseNum >= 352) + if (_globals->_phaseNum >= 352) kPersoRoomBankTable[30] = 26; _animateTalking = false; _animationActive = false; - p_global->_var100 = 0; - p_global->_eventType = EventType::etEventC; - p_global->_valleyVidNum = 0; - p_global->_drawFlags &= ~DrawFlags::drDrawMenu; + _globals->_var100 = 0; + _globals->_eventType = EventType::etEventC; + _globals->_valleyVidNum = 0; + _globals->_drawFlags &= ~DrawFlags::drDrawMenu; _currentTime = _vm->_timerTicks / 100; - p_global->_gameTime = _currentTime; - if (p_global->_roomCharacterType == PersonFlags::pftTyrann) + _globals->_gameTime = _currentTime; + if (_globals->_roomCharacterType == PersonFlags::pftTyrann) setChrono(3000); _adamMapMarkPos.x = -1; _adamMapMarkPos.y = -1; @@ -7177,34 +7176,34 @@ void EdenGame::desktopcolors() { void EdenGame::panelrestart() { _gameLoaded = false; - byte curmus = p_global->_currMusicNum; - byte curlng = p_global->_prefLanguage; + byte curmus = _globals->_currMusicNum; + byte curlng = _globals->_prefLanguage; loadrestart(); - p_global->_prefLanguage = curlng; + _globals->_prefLanguage = curlng; if (!_gameLoaded) //TODO always? return; - p_global->_characterImageBank = 0; - p_global->_lastPlaceNum = 0; - loadPlace(p_global->_areaPtr->_placeNum); - p_global->_displayFlags = DisplayFlags::dfFlag1; + _globals->_characterImageBank = 0; + _globals->_lastPlaceNum = 0; + loadPlace(_globals->_areaPtr->_placeNum); + _globals->_displayFlags = DisplayFlags::dfFlag1; _gameIcons[18]._cursorId |= 0x8000; - if (p_global->_curAreaType == AreaType::atValley) + if (_globals->_curAreaType == AreaType::atValley) _gameIcons[18]._cursorId &= ~0x8000; kPersoRoomBankTable[30] = 27; - if (p_global->_phaseNum >= 352) + if (_globals->_phaseNum >= 352) kPersoRoomBankTable[30] = 26; _animateTalking = false; _animationActive = false; - p_global->_var100 = 0; - p_global->_eventType = 0; - p_global->_valleyVidNum = 0; - p_global->_drawFlags &= ~DrawFlags::drDrawMenu; - p_global->_inventoryScrollPos = 0; + _globals->_var100 = 0; + _globals->_eventType = 0; + _globals->_valleyVidNum = 0; + _globals->_drawFlags &= ~DrawFlags::drDrawMenu; + _globals->_inventoryScrollPos = 0; _adamMapMarkPos.x = -1; _adamMapMarkPos.y = -1; - if (curmus != p_global->_currMusicNum) { - curmus = p_global->_currMusicNum; - p_global->_currMusicNum = 0; + if (curmus != _globals->_currMusicNum) { + curmus = _globals->_currMusicNum; + _globals->_currMusicNum = 0; startmusique(curmus); } fadeToBlack(3); @@ -7214,7 +7213,7 @@ void EdenGame::panelrestart() { showObjects(); saveFriezes(); _showBlackBars = true; - updateRoom(p_global->_roomNum); + updateRoom(_globals->_roomNum); } void EdenGame::reallyquit() { @@ -7223,9 +7222,9 @@ void EdenGame::reallyquit() { } void EdenGame::confirmer(char mode, char yesId) { - p_global->_iconsIndex = 119; + _globals->_iconsIndex = 119; _gameIcons[119]._objectId = yesId; - confirmMode = mode; + _confirmMode = mode; useBank(65); noclipax(12, 117, 74); _cursorPosX = 156; @@ -7236,8 +7235,8 @@ void EdenGame::confirmer(char mode, char yesId) { void EdenGame::confirmyes() { displayPanel(); - p_global->_iconsIndex = 85; - switch (confirmMode) { + _globals->_iconsIndex = 85; + switch (_confirmMode) { case 1: panelrestart(); break; @@ -7249,7 +7248,7 @@ void EdenGame::confirmyes() { void EdenGame::confirmno() { displayPanel(); - p_global->_iconsIndex = 85; + _globals->_iconsIndex = 85; pomme_q = false; } @@ -7264,41 +7263,41 @@ void EdenGame::edenQuit() { // Original name: choixsubtitle void EdenGame::choseSubtitleOption() { byte lang = _curSpot2->_objectId & 0xF; - if (lang == p_global->_prefLanguage) + if (lang == _globals->_prefLanguage) return; if (lang > 5) return; - p_global->_prefLanguage = lang; + _globals->_prefLanguage = lang; langbuftopanel(); displayLanguage(); } // Original name: reglervol void EdenGame::changeVolume() { - byte *valptr = &p_global->_prefMusicVol[_curSpot2->_objectId & 7]; + byte *valptr = &_globals->_prefMusicVol[_curSpot2->_objectId & 7]; _cursorPosY = 104 - ((*valptr >> 2) & 0x3F); // TODO: check me - cur_slider_value_ptr = valptr; - p_global->_menuFlags |= MenuFlags::mfFlag1; + _curSliderValuePtr = valptr; + _globals->_menuFlags |= MenuFlags::mfFlag1; if (_curSpot2->_objectId & 8) - p_global->_menuFlags |= MenuFlags::mfFlag2; + _globals->_menuFlags |= MenuFlags::mfFlag2; _curSliderX = _curSpot2->sx; - cur_slider_y = _cursorPosY; + _curSliderY = _cursorPosY; } void EdenGame::changervol() { if (_mouseHeld) { restrictCursorArea(_curSliderX - 1, _curSliderX + 3, 40, 110); - int16 delta = cur_slider_y - _cursorPosY; + int16 delta = _curSliderY - _cursorPosY; if (delta == 0) return; - newvol(cur_slider_value_ptr, delta); - if (p_global->_menuFlags & MenuFlags::mfFlag2) - newvol(cur_slider_value_ptr + 1, delta); + newvol(_curSliderValuePtr, delta); + if (_globals->_menuFlags & MenuFlags::mfFlag2) + newvol(_curSliderValuePtr + 1, delta); cursbuftopanel(); displayCursors(); - cur_slider_y = _cursorPosY; + _curSliderY = _cursorPosY; } else - p_global->_menuFlags &= ~(MenuFlags::mfFlag1 | MenuFlags::mfFlag2); + _globals->_menuFlags &= ~(MenuFlags::mfFlag1 | MenuFlags::mfFlag2); } void EdenGame::newvol(byte *volptr, int16 delta) { @@ -7309,58 +7308,58 @@ void EdenGame::newvol(byte *volptr, int16 delta) { if (vol > 63) vol = 63; *volptr = vol * 4; - _musicChannel->setVolume(p_global->_prefMusicVol[0], p_global->_prefMusicVol[1]); + _musicChannel->setVolume(_globals->_prefMusicVol[0], _globals->_prefMusicVol[1]); } void EdenGame::playtape() { - if (p_global->_menuItemIdHi & 8) - p_global->_tapePtr++; - for (;; p_global->_tapePtr++) { - if (p_global->_tapePtr == &tapes[MAX_TAPES]) { - p_global->_tapePtr--; + if (_globals->_menuItemIdHi & 8) + _globals->_tapePtr++; + for (;; _globals->_tapePtr++) { + if (_globals->_tapePtr == &_tapes[MAX_TAPES]) { + _globals->_tapePtr--; stoptape(); return; } - if (p_global->_tapePtr->_textNum) + if (_globals->_tapePtr->_textNum) break; } - p_global->_menuFlags |= MenuFlags::mfFlag8; - p_global->_drawFlags &= ~DrawFlags::drDrawMenu; - uint16 oldRoomNum = p_global->_roomNum; - uint16 oldParty = p_global->_party; - byte oldBack = p_global->_roomBackgroundBankNum; - perso_t *oldPerso = p_global->_characterPtr; - p_global->_party = p_global->_tapePtr->_party; - p_global->_roomNum = p_global->_tapePtr->_roomNum; - p_global->_roomBackgroundBankNum = p_global->_tapePtr->_backgroundBankNum; - p_global->_dialogPtr = p_global->_tapePtr->_dialog; - p_global->_characterPtr = p_global->_tapePtr->_perso; + _globals->_menuFlags |= MenuFlags::mfFlag8; + _globals->_drawFlags &= ~DrawFlags::drDrawMenu; + uint16 oldRoomNum = _globals->_roomNum; + uint16 oldParty = _globals->_party; + byte oldBack = _globals->_roomBackgroundBankNum; + perso_t *oldPerso = _globals->_characterPtr; + _globals->_party = _globals->_tapePtr->_party; + _globals->_roomNum = _globals->_tapePtr->_roomNum; + _globals->_roomBackgroundBankNum = _globals->_tapePtr->_backgroundBankNum; + _globals->_dialogPtr = _globals->_tapePtr->_dialog; + _globals->_characterPtr = _globals->_tapePtr->_perso; endCharacterSpeech(); affcurstape(); - if (p_global->_characterPtr != oldPerso - || p_global->_roomNum != _lastTapeRoomNum) { - _lastTapeRoomNum = p_global->_roomNum; - p_global->_curCharacterAnimPtr = nullptr; - p_global->_varCA = 0; - p_global->_characterImageBank = -1; + if (_globals->_characterPtr != oldPerso + || _globals->_roomNum != _lastTapeRoomNum) { + _lastTapeRoomNum = _globals->_roomNum; + _globals->_curCharacterAnimPtr = nullptr; + _globals->_varCA = 0; + _globals->_characterImageBank = -1; anim_perfin(); load_perso_cour(); } displayCharacterBackground(); - p_global->_textNum = p_global->_tapePtr->_textNum; + _globals->_textNum = _globals->_tapePtr->_textNum; my_bulle(); getDataSync(); displayCharacterPanel(); persovox(); - p_global->_roomBackgroundBankNum = oldBack; - p_global->_party = oldParty; - p_global->_roomNum = oldRoomNum; + _globals->_roomBackgroundBankNum = oldBack; + _globals->_party = oldParty; + _globals->_roomNum = oldRoomNum; } void EdenGame::rewindtape() { - if (p_global->_tapePtr > tapes) { - p_global->_tapePtr--; - p_global->_menuFlags &= ~MenuFlags::mfFlag8; + if (_globals->_tapePtr > _tapes) { + _globals->_tapePtr--; + _globals->_menuFlags &= ~MenuFlags::mfFlag8; affcurstape(); } } @@ -7373,25 +7372,25 @@ void EdenGame::depcurstape() { idx = 0; idx /= 8; - tape_t *tape = tapes + idx; - if (tape >= tapes + 16) - tape = tapes + 16 - 1; + tape_t *tape = _tapes + idx; + if (tape >= _tapes + 16) + tape = _tapes + 16 - 1; - if (tape != p_global->_tapePtr) { - p_global->_tapePtr = tape; + if (tape != _globals->_tapePtr) { + _globals->_tapePtr = tape; affcurstape(); - p_global->_menuFlags &= ~MenuFlags::mfFlag8; + _globals->_menuFlags &= ~MenuFlags::mfFlag8; } } else - p_global->_menuFlags &= ~MenuFlags::mfFlag4; + _globals->_menuFlags &= ~MenuFlags::mfFlag4; } void EdenGame::affcurstape() { - if (p_global->_drawFlags & DrawFlags::drDrawFlag8) + if (_globals->_drawFlags & DrawFlags::drDrawFlag8) _noPalette = true; useBank(65); noclipax(2, 0, 176); - int x = (p_global->_tapePtr - tapes) * 8 + 97; + int x = (_globals->_tapePtr - _tapes) * 8 + 97; _gameIcons[112].sx = x - 3; _gameIcons[112].ex = x + 3; noclipax(5, x, 179); @@ -7399,21 +7398,21 @@ void EdenGame::affcurstape() { } void EdenGame::forwardtape() { - if (p_global->_tapePtr < tapes + 16) { - p_global->_tapePtr++; - p_global->_menuFlags &= ~MenuFlags::mfFlag8; + if (_globals->_tapePtr < _tapes + 16) { + _globals->_tapePtr++; + _globals->_menuFlags &= ~MenuFlags::mfFlag8; affcurstape(); } } void EdenGame::stoptape() { - if (!(p_global->_drawFlags & DrawFlags::drDrawFlag8)) + if (!(_globals->_drawFlags & DrawFlags::drDrawFlag8)) return; - p_global->_menuFlags &= ~MenuFlags::mfFlag8; - p_global->_drawFlags &= ~DrawFlags::drDrawFlag8; - p_global->_menuFlags |= MenuFlags::mfFlag10; - p_global->_iconsIndex = 85; - p_global->_characterPtr = nullptr; + _globals->_menuFlags &= ~MenuFlags::mfFlag8; + _globals->_drawFlags &= ~DrawFlags::drDrawFlag8; + _globals->_menuFlags |= MenuFlags::mfFlag10; + _globals->_iconsIndex = 85; + _globals->_characterPtr = nullptr; _lastTapeRoomNum = 0; endCharacterSpeech(); fin_perso(); @@ -7423,7 +7422,7 @@ void EdenGame::stoptape() { } void EdenGame::cliccurstape() { - p_global->_menuFlags |= MenuFlags::mfFlag4; + _globals->_menuFlags |= MenuFlags::mfFlag4; } void EdenGame::paneltobuf() { @@ -7457,11 +7456,11 @@ void EdenGame::displayPanel() { // Original name: afflangue void EdenGame::displayLanguage() { useBank(65); - if (p_global->_prefLanguage < 0 //TODO: never happens - || p_global->_prefLanguage > 5) + if (_globals->_prefLanguage < 0 //TODO: never happens + || _globals->_prefLanguage > 5) return; - noclipax(6, 8, p_global->_prefLanguage * 9 + 43); //TODO: * FONT_HEIGHT - noclipax(7, 77, p_global->_prefLanguage * 9 + 44); + noclipax(6, 8, _globals->_prefLanguage * 9 + 43); //TODO: * FONT_HEIGHT + noclipax(7, 77, _globals->_prefLanguage * 9 + 44); } // Original name: affcursvol @@ -7479,19 +7478,19 @@ void EdenGame::displayVolCursor(int16 x, int16 vol1, int16 vol2) { // Original name: affcurseurs void EdenGame::displayCursors() { useBank(65); - if (p_global->_drawFlags & DrawFlags::drDrawFlag8) + if (_globals->_drawFlags & DrawFlags::drDrawFlag8) return; selectCursor(48); - displayVolCursor(114, p_global->_prefMusicVol[0] / 4, p_global->_prefMusicVol[1] / 4); + displayVolCursor(114, _globals->_prefMusicVol[0] / 4, _globals->_prefMusicVol[1] / 4); selectCursor(50); - displayVolCursor(147, p_global->_prefVoiceVol[0] / 4, p_global->_prefVoiceVol[1] / 4); + displayVolCursor(147, _globals->_prefVoiceVol[0] / 4, _globals->_prefVoiceVol[1] / 4); selectCursor(52); - displayVolCursor(179, p_global->_prefSoundVolume[0] / 4, p_global->_prefSoundVolume[1] / 4); + displayVolCursor(179, _globals->_prefSoundVolume[0] / 4, _globals->_prefSoundVolume[1] / 4); } // Original name: curseurselect void EdenGame::selectCursor(int itemId) { - _lastMenuItemIdLo = p_global->_menuItemIdLo; + _lastMenuItemIdLo = _globals->_menuItemIdLo; if ((_lastMenuItemIdLo & ~9) != itemId) _lastMenuItemIdLo = 0; } @@ -7504,14 +7503,14 @@ void EdenGame::displayTopPanel() { // Original name: affresult void EdenGame::displayResult() { restoreUnderSubtitles(); - p_global->_characterPtr = &kPersons[19]; - p_global->_dialogType = DialogType::dtInspect; - int16 num = (kPersons[PER_UNKN_156]._id << 3) | p_global->_dialogType; + _globals->_characterPtr = &kPersons[19]; + _globals->_dialogType = DialogType::dtInspect; + int16 num = (kPersons[PER_UNKN_156]._id << 3) | _globals->_dialogType; if (dialoscansvmas((dial_t *)getElem(_gameDialogs, num))) displaySubtitles(); - p_global->_varCA = 0; - p_global->_dialogType = DialogType::dtTalk; - p_global->_characterPtr = nullptr; + _globals->_varCA = 0; + _globals->_dialogType = DialogType::dtTalk; + _globals->_characterPtr = nullptr; } // Original name: limitezonecurs @@ -7523,31 +7522,31 @@ void EdenGame::restrictCursorArea(int16 xmin, int16 xmax, int16 ymin, int16 ymax // Original name: PommeQ void EdenGame::edenShudown() { Icon *icon = &_gameIcons[85]; - if (p_global->_displayFlags & DisplayFlags::dfFrescoes) { + if (_globals->_displayFlags & DisplayFlags::dfFrescoes) { _torchCursor = false; _cursorSaved = true; - if (p_global->_displayFlags & DisplayFlags::dfPerson) + if (_globals->_displayFlags & DisplayFlags::dfPerson) closeCharacterScreen(); - p_global->_displayFlags = DisplayFlags::dfFlag1; + _globals->_displayFlags = DisplayFlags::dfFlag1; resetScroll(); - p_global->_var100 = 0xFF; - updateRoom(p_global->_roomNum); + _globals->_var100 = 0xFF; + updateRoom(_globals->_roomNum); } - if (p_global->_displayFlags & DisplayFlags::dfPerson) + if (_globals->_displayFlags & DisplayFlags::dfPerson) closeCharacterScreen(); - if (p_global->_displayFlags & DisplayFlags::dfPanable) + if (_globals->_displayFlags & DisplayFlags::dfPanable) resetScroll(); - if (p_global->_displayFlags & DisplayFlags::dfMirror) + if (_globals->_displayFlags & DisplayFlags::dfMirror) resetScroll(); - if (p_global->_drawFlags & DrawFlags::drDrawFlag8) + if (_globals->_drawFlags & DrawFlags::drDrawFlag8) stoptape(); if (_personTalking) endCharacterSpeech(); - p_global->_var103 = 0; - p_global->_mirrorEffect = 0; + _globals->_var103 = 0; + _globals->_mirrorEffect = 0; putObject(); _currCursor = 53; - if (p_global->_displayFlags != DisplayFlags::dfFlag2) + if (_globals->_displayFlags != DisplayFlags::dfFlag2) gotoPanel(); _curSpot2 = icon + 7; //TODO edenQuit(); @@ -7556,30 +7555,30 @@ void EdenGame::edenShudown() { void EdenGame::habitants(perso_t *perso) { char persType = perso->_flags & PersonFlags::pfTypeMask; //TODO rename if (persType && persType != PersonFlags::pfType2) { - p_global->_roomCharacterPtr = perso; - p_global->_roomCharacterType = persType; - p_global->_roomCharacterFlags = perso->_flags; - p_global->_roomPersoItems = perso->_items; - p_global->_roomCharacterPowers = perso->_powers; - p_global->_partyOutside |= perso->_partyMask; - if (p_global->_roomCharacterType == PersonFlags::pftTriceraptor) - removeInfo(p_global->_areaNum + ValleyNews::vnTriceraptorsIn); - else if (p_global->_roomCharacterType == PersonFlags::pftVelociraptor) - removeInfo(p_global->_areaNum + ValleyNews::vnVelociraptorsIn); + _globals->_roomCharacterPtr = perso; + _globals->_roomCharacterType = persType; + _globals->_roomCharacterFlags = perso->_flags; + _globals->_roomPersoItems = perso->_items; + _globals->_roomCharacterPowers = perso->_powers; + _globals->_partyOutside |= perso->_partyMask; + if (_globals->_roomCharacterType == PersonFlags::pftTriceraptor) + removeInfo(_globals->_areaNum + ValleyNews::vnTriceraptorsIn); + else if (_globals->_roomCharacterType == PersonFlags::pftVelociraptor) + removeInfo(_globals->_areaNum + ValleyNews::vnVelociraptorsIn); } else if (!(perso->_flags & PersonFlags::pfInParty)) - p_global->_partyOutside |= perso->_partyMask; + _globals->_partyOutside |= perso->_partyMask; } void EdenGame::suiveurs(perso_t *perso) { char persType = perso->_flags & PersonFlags::pfTypeMask; if (persType == 0 || persType == PersonFlags::pfType2) { if (perso->_flags & PersonFlags::pfInParty) - p_global->_party |= perso->_partyMask; + _globals->_party |= perso->_partyMask; } } void EdenGame::evenements(perso_t *perso) { - if (p_global->_var113) + if (_globals->_var113) return; if (perso >= &kPersons[PER_UNKN_18C]) @@ -7588,20 +7587,20 @@ void EdenGame::evenements(perso_t *perso) { if (!dialo_even(perso)) return; - p_global->_var113++; - p_global->_oldDisplayFlags = 1; - perso = p_global->_characterPtr; + _globals->_var113++; + _globals->_oldDisplayFlags = 1; + perso = _globals->_characterPtr; init_perso_ptr(perso); if (!(perso->_partyMask & PersonMask::pmLeader)) - p_global->_var60 = 1; - p_global->_eventType = 0; + _globals->_var60 = 1; + _globals->_eventType = 0; } void EdenGame::followme(perso_t *perso) { if (perso->_flags & PersonFlags::pfTypeMask) return; if (perso->_flags & PersonFlags::pfInParty) - perso->_roomNum = destinationRoom; + perso->_roomNum = _destinationRoom; } void EdenGame::rangermammi(perso_t *perso, Room *room) { @@ -7621,7 +7620,7 @@ void EdenGame::rangermammi(perso_t *perso, Room *room) { perso->_roomNum &= ~0xFF; perso->_roomNum |= found_room->_location; perso->_flags &= ~PersonFlags::pfInParty; - p_global->_party &= ~perso->_partyMask; + _globals->_party &= ~perso->_partyMask; } void EdenGame::perso_ici(int16 action) { @@ -7641,12 +7640,12 @@ void EdenGame::perso_ici(int16 action) { followme(perso); break; case 5: - rangermammi(perso, p_global->_lastAreaPtr->_citadelRoomPtr); + rangermammi(perso, _globals->_lastAreaPtr->_citadelRoomPtr); break; } perso = kPersons; do { - if (perso->_roomNum == p_global->_roomNum && !(perso->_flags & PersonFlags::pf80)) { + if (perso->_roomNum == _globals->_roomNum && !(perso->_flags & PersonFlags::pf80)) { switch (action) { case 0: suiveurs(perso); @@ -7661,7 +7660,7 @@ void EdenGame::perso_ici(int16 action) { followme(perso); break; case 5: - rangermammi(perso, p_global->_lastAreaPtr->_citadelRoomPtr); + rangermammi(perso, _globals->_lastAreaPtr->_citadelRoomPtr); break; } } @@ -7671,94 +7670,94 @@ void EdenGame::perso_ici(int16 action) { // Original name: setpersohere void EdenGame::setCharacterHere() { - debug("setCharacterHere, perso is %ld", p_global->_characterPtr - kPersons); - p_global->_partyOutside = 0; - p_global->_party = 0; - p_global->_roomCharacterPtr = nullptr; - p_global->_roomCharacterType = 0; - p_global->_roomCharacterFlags = 0; + debug("setCharacterHere, perso is %ld", _globals->_characterPtr - kPersons); + _globals->_partyOutside = 0; + _globals->_party = 0; + _globals->_roomCharacterPtr = nullptr; + _globals->_roomCharacterType = 0; + _globals->_roomCharacterFlags = 0; perso_ici(1); perso_ici(0); - if (p_global->_roomCharacterType == PersonFlags::pftTyrann) - removeInfo(p_global->_areaNum + ValleyNews::vnTyrannIn); - if (p_global->_roomCharacterType == PersonFlags::pftTriceraptor) - removeInfo(p_global->_areaNum + ValleyNews::vnTriceraptorsIn); - if (p_global->_roomCharacterType == PersonFlags::pftVelociraptor) { - removeInfo(p_global->_areaNum + ValleyNews::vnTyrannIn); - removeInfo(p_global->_areaNum + ValleyNews::vnTyrannLost); - removeInfo(p_global->_areaNum + ValleyNews::vnVelociraptorsLost); + if (_globals->_roomCharacterType == PersonFlags::pftTyrann) + removeInfo(_globals->_areaNum + ValleyNews::vnTyrannIn); + if (_globals->_roomCharacterType == PersonFlags::pftTriceraptor) + removeInfo(_globals->_areaNum + ValleyNews::vnTriceraptorsIn); + if (_globals->_roomCharacterType == PersonFlags::pftVelociraptor) { + removeInfo(_globals->_areaNum + ValleyNews::vnTyrannIn); + removeInfo(_globals->_areaNum + ValleyNews::vnTyrannLost); + removeInfo(_globals->_areaNum + ValleyNews::vnVelociraptorsLost); } } void EdenGame::faire_suivre(int16 roomNum) { - destinationRoom = roomNum; + _destinationRoom = roomNum; perso_ici(4); } // Original name: suis_moi5 void EdenGame::AddCharacterToParty() { - debug("adding person %ld to party", p_global->_characterPtr - kPersons); - p_global->_characterPtr->_flags |= PersonFlags::pfInParty; - p_global->_characterPtr->_roomNum = p_global->_roomNum; - p_global->_party |= p_global->_characterPtr->_partyMask; - p_global->_drawFlags |= DrawFlags::drDrawTopScreen; + debug("adding person %ld to party", _globals->_characterPtr - kPersons); + _globals->_characterPtr->_flags |= PersonFlags::pfInParty; + _globals->_characterPtr->_roomNum = _globals->_roomNum; + _globals->_party |= _globals->_characterPtr->_partyMask; + _globals->_drawFlags |= DrawFlags::drDrawTopScreen; } // Original name: suis_moi void EdenGame::addToParty(int16 index) { - perso_t *old_perso = p_global->_characterPtr; - p_global->_characterPtr = &kPersons[index]; + perso_t *old_perso = _globals->_characterPtr; + _globals->_characterPtr = &kPersons[index]; AddCharacterToParty(); - p_global->_characterPtr = old_perso; + _globals->_characterPtr = old_perso; } // Original name: reste_ici5 void EdenGame::removeCharacterFromParty() { - debug("removing person %ld from party", p_global->_characterPtr - kPersons); - p_global->_characterPtr->_flags &= ~PersonFlags::pfInParty; - p_global->_partyOutside |= p_global->_characterPtr->_partyMask; - p_global->_party &= ~p_global->_characterPtr->_partyMask; - p_global->_drawFlags |= DrawFlags::drDrawTopScreen; + debug("removing person %ld from party", _globals->_characterPtr - kPersons); + _globals->_characterPtr->_flags &= ~PersonFlags::pfInParty; + _globals->_partyOutside |= _globals->_characterPtr->_partyMask; + _globals->_party &= ~_globals->_characterPtr->_partyMask; + _globals->_drawFlags |= DrawFlags::drDrawTopScreen; } // Original name: reste_ici void EdenGame::removeFromParty(int16 index) { - perso_t *old_perso = p_global->_characterPtr; - p_global->_characterPtr = &kPersons[index]; + perso_t *old_perso = _globals->_characterPtr; + _globals->_characterPtr = &kPersons[index]; removeCharacterFromParty(); - p_global->_characterPtr = old_perso; + _globals->_characterPtr = old_perso; } // Original name: eloipart void EdenGame::handleEloiDeparture() { removeFromParty(PER_MESSENGER); - p_global->_gameFlags &= ~GameFlags::gfFlag4000; + _globals->_gameFlags &= ~GameFlags::gfFlag4000; kPersons[PER_MESSENGER]._roomNum = 0; - p_global->_partyOutside &= ~kPersons[PER_MESSENGER]._partyMask; - if (p_global->_roomNum == 2817) + _globals->_partyOutside &= ~kPersons[PER_MESSENGER]._partyMask; + if (_globals->_roomNum == 2817) setChrono(3000); - p_global->_eloiDepartureDay = p_global->_gameDays; - p_global->_eloiHaveNews = 0; + _globals->_eloiDepartureDay = _globals->_gameDays; + _globals->_eloiHaveNews = 0; unlockInfo(); } // Original name: eloirevientq bool EdenGame::checkEloiReturn() { - if (p_global->_phaseNum < 304) + if (_globals->_phaseNum < 304) return true; - if ((p_global->_phaseNum <= 353) || (p_global->_phaseNum == 370) || (p_global->_phaseNum == 384)) + if ((_globals->_phaseNum <= 353) || (_globals->_phaseNum == 370) || (_globals->_phaseNum == 384)) return false; - if (p_global->_areaNum != Areas::arShandovra) + if (_globals->_areaNum != Areas::arShandovra) return true; - if (p_global->_phaseNum < 480) + if (_globals->_phaseNum < 480) return false; return true; } // Original name: eloirevient void EdenGame::handleEloiReturn() { - if (p_global->_areaPtr->_type == AreaType::atValley && !kPersons[PER_MESSENGER]._roomNum) - kPersons[PER_MESSENGER]._roomNum = (p_global->_roomNum & 0xFF00) + 1; + if (_globals->_areaPtr->_type == AreaType::atValley && !kPersons[PER_MESSENGER]._roomNum) + kPersons[PER_MESSENGER]._roomNum = (_globals->_roomNum & 0xFF00) + 1; } //// phase.c void EdenGame::incPhase() { @@ -7789,11 +7788,11 @@ void EdenGame::incPhase() { { -1, nullptr } }; - p_global->_phaseNum++; - debug("!!! next phase - %4X , room %4X", p_global->_phaseNum, p_global->_roomNum); - p_global->_phaseActionsCount = 0; + _globals->_phaseNum++; + debug("!!! next phase - %4X , room %4X", _globals->_phaseNum, _globals->_roomNum); + _globals->_phaseActionsCount = 0; for (phase_t *phase = phases; phase->_id != -1; phase++) { - if (p_global->_phaseNum == phase->_id) { + if (_globals->_phaseNum == phase->_id) { (this->*phase->disp)(); break; } @@ -7811,11 +7810,11 @@ void EdenGame::phase130() { } void EdenGame::phase161() { - Area *area = p_global->_areaPtr; + Area *area = _globals->_areaPtr; addToParty(PER_MAMMI); kPersons[PER_MAMMI]._flags |= PersonFlags::pf10; area->_flags |= AreaFlags::afFlag1; - p_global->_curAreaFlags |= AreaFlags::afFlag1; + _globals->_curAreaFlags |= AreaFlags::afFlag1; } void EdenGame::phase226() { @@ -7826,7 +7825,7 @@ void EdenGame::phase226() { void EdenGame::phase257() { _gameIcons[127]._cursorId &= ~0x8000; - p_global->_characterBackgroundBankIdx = 58; + _globals->_characterBackgroundBankIdx = 58; dialautooff(); } @@ -7838,7 +7837,7 @@ void EdenGame::phase353() { void EdenGame::phase369() { addToParty(PER_MESSENGER); - p_global->_narratorSequence = 2; + _globals->_narratorSequence = 2; _gameRooms[334]._exits[0] = 134; _gameRooms[335]._exits[0] = 134; } @@ -7848,7 +7847,7 @@ void EdenGame::phase371() { _gameIcons[128]._cursorId &= ~0x8000; _gameIcons[129]._cursorId &= ~0x8000; _gameIcons[127]._cursorId |= 0x8000; - p_global->_characterBackgroundBankIdx = 59; + _globals->_characterBackgroundBankIdx = 59; _gameRooms[334]._exits[0] = 0xFF; _gameRooms[335]._exits[0] = 0xFF; _gameIcons[123]._objectId = 9; @@ -7860,10 +7859,10 @@ void EdenGame::phase371() { void EdenGame::phase385() { dialautooff(); handleEloiReturn(); - p_global->_nextInfoIdx = 0; - p_global->_lastInfoIdx = 0; + _globals->_nextInfoIdx = 0; + _globals->_lastInfoIdx = 0; updateInfoList(); - p_global->_lastInfo = 0; + _globals->_lastInfo = 0; } void EdenGame::phase418() { @@ -7877,16 +7876,16 @@ void EdenGame::phase433() { kPersons[PER_MAMMI_4]._flags &= ~PersonFlags::pf80; kPersons[PER_TORMENTOR]._flags &= ~PersonFlags::pf80; setCharacterHere(); - p_global->_chronoFlag = 0; - p_global->_chrono = 0; + _globals->_chronoFlag = 0; + _globals->_chrono = 0; } void EdenGame::phase434() { - p_global->_roomNum = 275; + _globals->_roomNum = 275; _gameRooms[16]._bank = 44; _gameRooms[18]._bank = 44; _gameIcons[132]._cursorId &= ~0x8000; - p_global->_characterBackgroundBankIdx = 61; + _globals->_characterBackgroundBankIdx = 61; _gameRooms[118]._exits[2] = 0xFF; abortdial(); _gameRooms[7]._bank = 322; @@ -7895,11 +7894,11 @@ void EdenGame::phase434() { removeFromParty(PER_MESSENGER); removeFromParty(PER_GUARDS); removeFromParty(PER_TORMENTOR); - p_global->_drawFlags |= DrawFlags::drDrawTopScreen; + _globals->_drawFlags |= DrawFlags::drDrawTopScreen; } void EdenGame::phase513() { - p_global->_lastDialogPtr = nullptr; + _globals->_lastDialogPtr = nullptr; parlemoiNormalFlag = false; dialautoon(); } @@ -7910,14 +7909,14 @@ void EdenGame::phase514() { void EdenGame::phase529() { _gameIcons[133]._cursorId &= ~0x8000; - p_global->_characterBackgroundBankIdx = 63; + _globals->_characterBackgroundBankIdx = 63; } void EdenGame::phase545() { } void EdenGame::phase561() { - p_global->_narratorSequence = 10; + _globals->_narratorSequence = 10; } void EdenGame::bigphase1() { @@ -7959,10 +7958,10 @@ void EdenGame::bigphase1() { &EdenGame::phase560 }; - int16 phase = (p_global->_phaseNum & ~3) + 0x10; //TODO: check me + int16 phase = (_globals->_phaseNum & ~3) + 0x10; //TODO: check me debug("!!! big phase - %4X", phase); - p_global->_phaseActionsCount = 0; - p_global->_phaseNum = phase; + _globals->_phaseActionsCount = 0; + _globals->_phaseNum = phase; if (phase > 560) return; phase >>= 4; @@ -7970,7 +7969,7 @@ void EdenGame::bigphase1() { } void EdenGame::bigphase() { - if (!(p_global->_dialogPtr->_flags & DialogFlags::dfSpoken)) + if (!(_globals->_dialogPtr->_flags & DialogFlags::dfSpoken)) bigphase1(); } @@ -8022,12 +8021,12 @@ void EdenGame::phase176() { } void EdenGame::phase192() { - Area *area = p_global->_areaPtr; + Area *area = _globals->_areaPtr; addToParty(PER_MAMMI_1); kPersons[PER_MAMMI_1]._flags |= PersonFlags::pf10; dialautoon(); area->_flags |= AreaFlags::afFlag1; - p_global->_curAreaFlags |= AreaFlags::afFlag1; + _globals->_curAreaFlags |= AreaFlags::afFlag1; } void EdenGame::phase208() { @@ -8036,16 +8035,16 @@ void EdenGame::phase208() { void EdenGame::phase224() { _gameIcons[126]._cursorId &= ~0x8000; - p_global->_characterBackgroundBankIdx = 57; + _globals->_characterBackgroundBankIdx = 57; dialautooff(); } void EdenGame::phase240() { - Area *area = p_global->_areaPtr; + Area *area = _globals->_areaPtr; addToParty(PER_MAMMI_2); kPersons[PER_MAMMI_2]._flags |= PersonFlags::pf10; area->_flags |= AreaFlags::afFlag1; - p_global->_curAreaFlags |= AreaFlags::afFlag1; + _globals->_curAreaFlags |= AreaFlags::afFlag1; } void EdenGame::phase256() { @@ -8054,7 +8053,7 @@ void EdenGame::phase256() { void EdenGame::phase272() { dialautoon(); - p_global->_eloiHaveNews = 0; + _globals->_eloiHaveNews = 0; } void EdenGame::phase288() { @@ -8062,17 +8061,17 @@ void EdenGame::phase288() { kPersons[PER_MANGO]._roomNum = 0; removeFromParty(PER_MANGO); addToParty(PER_MESSENGER); - p_global->_narratorSequence = 8; + _globals->_narratorSequence = 8; } void EdenGame::phase304() { - Area *area = p_global->_areaPtr; + Area *area = _globals->_areaPtr; addToParty(PER_EVE); addToParty(PER_MAMMI_5); kPersons[PER_MAMMI_5]._flags |= PersonFlags::pf10; dialautoon(); area->_flags |= AreaFlags::afFlag1; - p_global->_curAreaFlags |= AreaFlags::afFlag1; + _globals->_curAreaFlags |= AreaFlags::afFlag1; } void EdenGame::phase320() { @@ -8082,7 +8081,7 @@ void EdenGame::phase320() { void EdenGame::phase336() { _gameRooms[288]._exits[0] = 135; _gameRooms[289]._exits[0] = 135; - loseObject(p_global->_curObjectId); + loseObject(_globals->_curObjectId); dialautoon(); } @@ -8106,12 +8105,12 @@ void EdenGame::phase368() { } void EdenGame::phase384() { - Area *area = p_global->_areaPtr; + Area *area = _globals->_areaPtr; addToParty(PER_EVE); removeFromParty(PER_DINA); dialautoon(); area->_flags |= AreaFlags::afFlag1; - p_global->_curAreaFlags |= AreaFlags::afFlag1; + _globals->_curAreaFlags |= AreaFlags::afFlag1; handleEloiDeparture(); } @@ -8119,24 +8118,24 @@ void EdenGame::phase400() { dialonfollow(); kPersons[PER_KING]._roomNum = 0; kPersons[PER_MONK]._roomNum = 259; - p_global->_eloiHaveNews = 0; + _globals->_eloiHaveNews = 0; kObjectLocations[20] = 259; } void EdenGame::phase416() { addToParty(PER_MONK); _gameIcons[130]._cursorId &= ~0x8000; - p_global->_characterBackgroundBankIdx = 60; + _globals->_characterBackgroundBankIdx = 60; _gameRooms[0]._exits[0] = 138; } void EdenGame::phase432() { - p_global->_narratorSequence = 3; + _globals->_narratorSequence = 3; kPersons[PER_MAMMI_4]._flags |= PersonFlags::pf80; kPersons[PER_TORMENTOR]._flags |= PersonFlags::pf80; kPersons[PER_MESSENGER]._roomNum = 257; _gameRooms[0]._exits[0] = 0xFF; - p_global->_drawFlags |= DrawFlags::drDrawTopScreen; + _globals->_drawFlags |= DrawFlags::drDrawTopScreen; } void EdenGame::phase448() { @@ -8145,11 +8144,11 @@ void EdenGame::phase448() { } void EdenGame::phase464() { - p_global->_areaPtr->_flags |= AreaFlags::afFlag1; - p_global->_curAreaFlags |= AreaFlags::afFlag1; + _globals->_areaPtr->_flags |= AreaFlags::afFlag1; + _globals->_curAreaFlags |= AreaFlags::afFlag1; kPersons[PER_MAMMI_6]._flags |= PersonFlags::pf10; addToParty(PER_AZIA); - p_global->_citadelAreaNum = p_global->_areaNum; + _globals->_citadelAreaNum = _globals->_areaNum; naitredino(8); } @@ -8162,7 +8161,7 @@ void EdenGame::phase480() { void EdenGame::phase496() { dialautoon(); - p_global->_lastDialogPtr = nullptr; + _globals->_lastDialogPtr = nullptr; parlemoiNormalFlag = false; } @@ -8174,7 +8173,7 @@ void EdenGame::phase512() { } void EdenGame::phase528() { - p_global->_narratorSequence = 11; + _globals->_narratorSequence = 11; addToParty(PER_MONK); addToParty(PER_MESSENGER); addToParty(PER_EVE); @@ -8213,8 +8212,8 @@ debug("writing 0x%X bytes", *size); \ h->write(ptr, *size); vavaoffsetout(); - size = (char *)(&p_global->_saveEnd) - (char *)(p_global); - CLFile_Write(handle, p_global, &size); + size = (char *)(&_globals->_saveEnd) - (char *)(_globals); + CLFile_Write(handle, _globals, &size); size = (char *)(&_gameIcons[134]) - (char *)(&_gameIcons[123]); CLFile_Write(handle, &_gameIcons[123], &size); lieuoffsetout(); @@ -8231,8 +8230,8 @@ h->write(ptr, *size); size = (char *)(&kPersons[PER_UNKN_3DE]) - (char *)(&kPersons[PER_KING]); CLFile_Write(handle, &kPersons[PER_KING], &size); bandeoffsetout(); - size = (char *)(&tapes[16]) - (char *)(&tapes[0]); - CLFile_Write(handle, &tapes[0], &size); + size = (char *)(&_tapes[16]) - (char *)(&_tapes[0]); + CLFile_Write(handle, &_tapes[0], &size); size = (char *)(&kTabletView[6]) - (char *)(&kTabletView[0]); CLFile_Write(handle, &kTabletView[0], &size); size = (char *)(&_gameDialogs[10240]) - (char *)(&_gameDialogs[0]); //TODO: const size 10240 @@ -8255,8 +8254,8 @@ void EdenGame::loadrestart() { assert(0); //TODO: this won't work atm - all snapshots are BE int32 offs = 0; int32 size; - size = (char *)(&p_global->_saveEnd) - (char *)(p_global); - loadpartoffile(2495, p_global, offs, size); + size = (char *)(&_globals->_saveEnd) - (char *)(_globals); + loadpartoffile(2495, _globals, offs, size); offs += size; vavaoffsetin(); size = (char *)(&_gameIcons[134]) - (char *)(&_gameIcons[123]); @@ -8281,8 +8280,8 @@ void EdenGame::loadrestart() { size = (char *)(&kPersons[PER_UNKN_3DE]) - (char *)(&kPersons[PER_KING]); loadpartoffile(2495, &kPersons[PER_KING], offs, size); offs += size; - size = (char *)(&tapes[16]) - (char *)(&tapes[0]); - loadpartoffile(2495, &tapes[0], offs, size); + size = (char *)(&_tapes[16]) - (char *)(&_tapes[0]); + loadpartoffile(2495, &_tapes[0], offs, size); offs += size; bandeoffsetin(); size = (char *)(&kTabletView[6]) - (char *)(&kTabletView[0]); @@ -8306,8 +8305,8 @@ void EdenGame::loadgame(char *name) { #define CLFile_Read(h, ptr, size) \ h->read(ptr, *size); - int32 size = (char *)(&p_global->_saveEnd) - (char *)(p_global); - CLFile_Read(handle, p_global, &size); + int32 size = (char *)(&_globals->_saveEnd) - (char *)(_globals); + CLFile_Read(handle, _globals, &size); vavaoffsetin(); size = (char *)(&_gameIcons[134]) - (char *)(&_gameIcons[123]); CLFile_Read(handle, &_gameIcons[123], &size); @@ -8324,8 +8323,8 @@ void EdenGame::loadgame(char *name) { CLFile_Read(handle, &followerList[13], &size); size = (char *)(&kPersons[55]) - (char *)(&kPersons[0]); CLFile_Read(handle, &kPersons[0], &size); - size = (char *)(&tapes[16]) - (char *)(&tapes[0]); - CLFile_Read(handle, &tapes[0], &size); + size = (char *)(&_tapes[16]) - (char *)(&_tapes[0]); + CLFile_Read(handle, &_tapes[0], &size); bandeoffsetin(); size = (char *)(&kTabletView[6]) - (char *)(&kTabletView[0]); CLFile_Read(handle, &kTabletView[0], &size); @@ -8345,35 +8344,35 @@ void EdenGame::loadgame(char *name) { #define OFSIN(val, base, typ) if ((void*)(val) != NULLPTR) (val) = (typ*)((char*)(val) + (size_t)(base)); else (val) = 0; void EdenGame::vavaoffsetout() { - OFSOUT(p_global->_dialogPtr, _gameDialogs, dial_t); - OFSOUT(p_global->_nextDialogPtr, _gameDialogs, dial_t); - OFSOUT(p_global->_narratorDialogPtr, _gameDialogs, dial_t); - OFSOUT(p_global->_lastDialogPtr, _gameDialogs, dial_t); - OFSOUT(p_global->_tapePtr, tapes, tape_t); - OFSOUT(p_global->_nextRoomIcon, _gameIcons, Icon); - OFSOUT(p_global->_roomPtr, _gameRooms, Room); - OFSOUT(p_global->_citaAreaFirstRoom, _gameRooms, Room); - OFSOUT(p_global->_areaPtr, kAreasTable, Area); - OFSOUT(p_global->_lastAreaPtr, kAreasTable, Area); - OFSOUT(p_global->_curAreaPtr, kAreasTable, Area); - OFSOUT(p_global->_characterPtr, kPersons, perso_t); - OFSOUT(p_global->_roomCharacterPtr, kPersons, perso_t); + OFSOUT(_globals->_dialogPtr, _gameDialogs, dial_t); + OFSOUT(_globals->_nextDialogPtr, _gameDialogs, dial_t); + OFSOUT(_globals->_narratorDialogPtr, _gameDialogs, dial_t); + OFSOUT(_globals->_lastDialogPtr, _gameDialogs, dial_t); + OFSOUT(_globals->_tapePtr, _tapes, tape_t); + OFSOUT(_globals->_nextRoomIcon, _gameIcons, Icon); + OFSOUT(_globals->_roomPtr, _gameRooms, Room); + OFSOUT(_globals->_citaAreaFirstRoom, _gameRooms, Room); + OFSOUT(_globals->_areaPtr, kAreasTable, Area); + OFSOUT(_globals->_lastAreaPtr, kAreasTable, Area); + OFSOUT(_globals->_curAreaPtr, kAreasTable, Area); + OFSOUT(_globals->_characterPtr, kPersons, perso_t); + OFSOUT(_globals->_roomCharacterPtr, kPersons, perso_t); } void EdenGame::vavaoffsetin() { - OFSIN(p_global->_dialogPtr, _gameDialogs, dial_t); - OFSIN(p_global->_nextDialogPtr, _gameDialogs, dial_t); - OFSIN(p_global->_narratorDialogPtr, _gameDialogs, dial_t); - OFSIN(p_global->_lastDialogPtr, _gameDialogs, dial_t); - OFSIN(p_global->_tapePtr, tapes, tape_t); - OFSIN(p_global->_nextRoomIcon, _gameIcons, Icon); - OFSIN(p_global->_roomPtr, _gameRooms, Room); - OFSIN(p_global->_citaAreaFirstRoom, _gameRooms, Room); - OFSIN(p_global->_areaPtr, kAreasTable, Area); - OFSIN(p_global->_lastAreaPtr, kAreasTable, Area); - OFSIN(p_global->_curAreaPtr, kAreasTable, Area); - OFSIN(p_global->_characterPtr, kPersons, perso_t); - OFSIN(p_global->_roomCharacterPtr, kPersons, perso_t); + OFSIN(_globals->_dialogPtr, _gameDialogs, dial_t); + OFSIN(_globals->_nextDialogPtr, _gameDialogs, dial_t); + OFSIN(_globals->_narratorDialogPtr, _gameDialogs, dial_t); + OFSIN(_globals->_lastDialogPtr, _gameDialogs, dial_t); + OFSIN(_globals->_tapePtr, _tapes, tape_t); + OFSIN(_globals->_nextRoomIcon, _gameIcons, Icon); + OFSIN(_globals->_roomPtr, _gameRooms, Room); + OFSIN(_globals->_citaAreaFirstRoom, _gameRooms, Room); + OFSIN(_globals->_areaPtr, kAreasTable, Area); + OFSIN(_globals->_lastAreaPtr, kAreasTable, Area); + OFSIN(_globals->_curAreaPtr, kAreasTable, Area); + OFSIN(_globals->_characterPtr, kPersons, perso_t); + OFSIN(_globals->_roomCharacterPtr, kPersons, perso_t); } void EdenGame::lieuoffsetout() { @@ -8388,15 +8387,15 @@ void EdenGame::lieuoffsetin() { void EdenGame::bandeoffsetout() { for (int i = 0; i < 16; i++) { - OFSOUT(tapes[i]._perso, kPersons, perso_t); - OFSOUT(tapes[i]._dialog, _gameDialogs, dial_t); + OFSOUT(_tapes[i]._perso, kPersons, perso_t); + OFSOUT(_tapes[i]._dialog, _gameDialogs, dial_t); } } void EdenGame::bandeoffsetin() { for (int i = 0; i < 16; i++) { - OFSIN(tapes[i]._perso, kPersons, perso_t); - OFSIN(tapes[i]._dialog, _gameDialogs, dial_t); + OFSIN(_tapes[i]._perso, kPersons, perso_t); + OFSIN(_tapes[i]._dialog, _gameDialogs, dial_t); } } @@ -8528,9 +8527,9 @@ uint16 EdenGame::cher_valeur() { if (typ < 0x80) { byte ofs = *_codePtr++; if (typ == 1) - val = *(byte *)(ofs + (byte *)p_global); + val = *(byte *)(ofs + (byte *)_globals); else - val = *(uint16 *)(ofs + (byte *)p_global); + val = *(uint16 *)(ofs + (byte *)_globals); } else if (typ == 0x80) val = *_codePtr++; else { @@ -8575,9 +8574,9 @@ void EdenGame::make_matrice_fix() { void EdenGame::projectionFix(cube_t *cubep, int n) { for (int i = 0; i < n; i++) { - int r28 = cubep->vertices[i * 4]; - int r27 = cubep->vertices[i * 4 + 1]; - int r26 = cubep->vertices[i * 4 + 2]; + int r28 = cubep->_vertices[i * 4]; + int r27 = cubep->_vertices[i * 4 + 1]; + int r26 = cubep->_vertices[i * 4 + 2]; int r25 = dword_32424 * r28 + dword_32428 * r27 + dword_3242C * r26 + (int)(flt_32454 * 256.0f); int r24 = dword_32430 * r28 + dword_32434 * r27 + dword_32438 * r26 + (int)(flt_32450 * 256.0f); @@ -8586,9 +8585,9 @@ void EdenGame::projectionFix(cube_t *cubep, int n) { r29 >>= 8; if (r29 == -256) r29++; - cubep->projection[i * 4 ] = r25 / (r29 + 256) + _cursorPosX + 14 + _scrollPos; - cubep->projection[i * 4 + 1] = r24 / (r29 + 256) + _cursorPosY + 14; - cubep->projection[i * 4 + 2] = r29; + cubep->_projection[i * 4 ] = r25 / (r29 + 256) + _cursorPosX + 14 + _scrollPos; + cubep->_projection[i * 4 + 1] = r24 / (r29 + 256) + _cursorPosY + 14; + cubep->_projection[i * 4 + 2] = r29; // assert(cube->projection[i * 4] < 640); // assert(cube->projection[i * 4 + 1] < 200); @@ -8597,22 +8596,22 @@ void EdenGame::projectionFix(cube_t *cubep, int n) { // Original name init_cube void EdenGame::initCubeMac() { - loadMap(2493, cube_texture); - NEWcharge_objet_mob(&cube, 2494, cube_texture); + loadMap(2493, _cubeTexture); + NEWcharge_objet_mob(&_cube, 2494, _cubeTexture); initCosTable(); } void EdenGame::engineMac() { Eden_dep_and_rot(); make_matrice_fix(); - projectionFix(&cube, cube_faces); - displayObject(&cube); + projectionFix(&_cube, _cubeFaces); + displayObject(&_cube); } // Original name: affiche_objet void EdenGame::displayObject(cube_t *cubep) { - for (int i = 0; i < cubep->num; i++) - affiche_polygone_mapping(cubep, cubep->faces[i]); + for (int i = 0; i < cubep->_num; i++) + displayPolygoneMapping(cubep, cubep->_faces[i]); } // Original name: NEWcharge_map @@ -8676,10 +8675,10 @@ void EdenGame::NEWcharge_objet_mob(cube_t *cubep, int fileNum, byte *texturePtr) char *next = tmp1; char error; - cube_faces = nextVal(&next, &error); - int16 *vertices = (int16 *)malloc(cube_faces * 4 * sizeof(*vertices)); - int16 *projection = (int16 *)malloc(cube_faces * 4 * sizeof(*projection)); - for (int i = 0; i < cube_faces; i++) { + _cubeFaces = nextVal(&next, &error); + int16 *vertices = (int16 *)malloc(_cubeFaces * 4 * sizeof(*vertices)); + int16 *projection = (int16 *)malloc(_cubeFaces * 4 * sizeof(*projection)); + for (int i = 0; i < _cubeFaces; i++) { vertices[i * 4] = nextVal(&next, &error); vertices[i * 4 + 1] = nextVal(&next, &error); vertices[i * 4 + 2] = nextVal(&next, &error); @@ -8691,13 +8690,13 @@ void EdenGame::NEWcharge_objet_mob(cube_t *cubep, int fileNum, byte *texturePtr) tmp4[i]->tri = 3; char textured = nextVal(&next, &error); tmp4[i]->ff_5 = nextVal(&next, &error); - tmp4[i]->indices = (uint16 *)malloc(3 * sizeof(*tmp4[i]->indices)); - tmp4[i]->uv = (int16 *)malloc(3 * 2 * sizeof(*tmp4[i]->uv)); + tmp4[i]->_indices = (uint16 *)malloc(3 * sizeof(*tmp4[i]->_indices)); + tmp4[i]->_uv = (int16 *)malloc(3 * 2 * sizeof(*tmp4[i]->_uv)); for (int j = 0; j < 3; j++) { - tmp4[i]->indices[j] = nextVal(&next, &error); + tmp4[i]->_indices[j] = nextVal(&next, &error); if (textured) { - tmp4[i]->uv[j * 2] = nextVal(&next, &error); - tmp4[i]->uv[j * 2 + 1] = nextVal(&next, &error); + tmp4[i]->_uv[j * 2] = nextVal(&next, &error); + tmp4[i]->_uv[j * 2 + 1] = nextVal(&next, &error); } } if (textured) { @@ -8707,10 +8706,10 @@ void EdenGame::NEWcharge_objet_mob(cube_t *cubep, int fileNum, byte *texturePtr) tmp4[i]->ff_4 = 0; } free(tmp1); - cubep->num = count2; - cubep->faces = tmp4; - cubep->projection = projection; - cubep->vertices = vertices; + cubep->_num = count2; + cubep->_faces = tmp4; + cubep->_projection = projection; + cubep->_vertices = vertices; } int EdenGame::nextVal(char **ptr, char *error) { @@ -8789,22 +8788,22 @@ void EdenGame::selectMap(int16 num) { } }; - curs_cur_map = num; + _cursCurPCMap = num; int16 k = 0; int mode = mapMode[num]; int16 x = (num & 7) * 32; int16 y = (num & 0x18) * 4; for (int i = 0; i < 6 * 2; i++) { for (int j = 0; j < 3; j++) { - cube.faces[i]->uv[j * 2 ] = x + cube_texcoords[mode][k++]; - cube.faces[i]->uv[j * 2 + 1] = y + cube_texcoords[mode][k++]; + _cube._faces[i]->_uv[j * 2 ] = x + cube_texcoords[mode][k++]; + _cube._faces[i]->_uv[j * 2 + 1] = y + cube_texcoords[mode][k++]; } } } void EdenGame::Eden_dep_and_rot() { int16 curs = _currCursor; - if (_normalCursor && (p_global->_drawFlags & DrawFlags::drDrawFlag20)) + if (_normalCursor && (_globals->_drawFlags & DrawFlags::drDrawFlag20)) curs = 10; selectMap(curs); _cursorNewTick = TickCount(); @@ -8882,36 +8881,37 @@ void EdenGame::restoreZDEP() { flt_2DF7C -= flt_2DF84; } -void EdenGame::affiche_polygone_mapping(cube_t *cubep, cubeface_t *face) { - uint16 *indices = face->indices; +// Original name: affiche_polygone_mapping +void EdenGame::displayPolygoneMapping(cube_t *cubep, cubeface_t *face) { + uint16 *indices = face->_indices; int idx = indices[0] * 4; - int16 v46 = cubep->projection[idx]; - int16 v48 = cubep->projection[idx + 1]; + int16 v46 = cubep->_projection[idx]; + int16 v48 = cubep->_projection[idx + 1]; idx = indices[1] * 4; - int16 v4A = cubep->projection[idx]; - int16 v4C = cubep->projection[idx + 1]; + int16 v4A = cubep->_projection[idx]; + int16 v4C = cubep->_projection[idx + 1]; idx = indices[2] * 4; - int16 v4E = cubep->projection[idx]; - int16 v50 = cubep->projection[idx + 1]; + int16 v4E = cubep->_projection[idx]; + int16 v50 = cubep->_projection[idx + 1]; if ((v4C - v48) * (v4E - v46) - (v50 - v48) * (v4A - v46) > 0) return; - int16 *uv = face->uv; + int16 *uv = face->_uv; int16 ymin = 200; // min y int16 ymax = 0; // max y idx = indices[0] * 4; - int16 r20 = cubep->projection[idx]; - int16 r30 = cubep->projection[idx + 1]; + int16 r20 = cubep->_projection[idx]; + int16 r30 = cubep->_projection[idx + 1]; int16 r19 = *uv++; int16 r18 = *uv++; indices++; - for (int r17 = 0; r17 < face->tri - 1; r17++, indices++) { + for (int i = 0; i < face->tri - 1; i++, indices++) { idx = indices[0] * 4; - int16 r26 = cubep->projection[idx]; - int16 r31 = cubep->projection[idx + 1]; + int16 r26 = cubep->_projection[idx]; + int16 r31 = cubep->_projection[idx + 1]; uint16 r25 = *uv++; //TODO: unsigned int16 r24 = *uv++; //TODO: unsigned if (r30 < ymin) @@ -8928,12 +8928,12 @@ void EdenGame::affiche_polygone_mapping(cube_t *cubep, cubeface_t *face) { r19 = r25; r18 = r24; } - idx = face->indices[0] * 4; - int16 r26 = cubep->projection[idx]; - int16 r31 = cubep->projection[idx + 1]; - uv = face->uv; - uint16 r25 = *uv++; //TODO: this is unsigned - int16 r24 = *uv; //TODO: this is signed + idx = face->_indices[0] * 4; + int16 r26 = cubep->_projection[idx]; + int16 r31 = cubep->_projection[idx + 1]; + uv = face->_uv; + uint16 r25 = *uv++; + int16 r24 = *uv; if (r30 < ymin) ymin = r30; if (r30 > ymax) @@ -9039,7 +9039,7 @@ void EdenGame::displayMappingLine(int16 r3, int16 r4, byte *target, byte *textur } // PC cursor -cubeCursor pc_cursors[9] = { +cubeCursor _cursorsPC[9] = { { { 0, 0, 0, 0, 0, 0 }, 3, 2 }, { { 1, 1, 0, 1, 1, 0 }, 2, -2 }, { { 2, 2, 2, 2, 2, 2 }, 1, 2 }, @@ -9052,7 +9052,7 @@ cubeCursor pc_cursors[9] = { { { 0, 8, 0, 0, 8, 8 }, 2, 2 } }; -XYZ pc_cube[6][3] = { +XYZ _cubePC[6][3] = { { { -15, -15, -15 }, { -15, 15, -15 }, { 15, 15, -15 } }, { { -15, -15, 15 }, { -15, 15, 15 }, { -15, 15, -15 } }, { { -15, -15, 15 }, { -15, -15, -15 }, { 15, -15, -15 } }, @@ -9061,7 +9061,7 @@ XYZ pc_cube[6][3] = { { { 15, 15, 15 }, { 15, 15, -15 }, { -15, 15, -15 } } }; -signed short cosine[] = { +signed short cosineTable[] = { // = cos(n) << 7; n += 10; 128, 126, 120, 111, 98, 82, 64, 44, 22, 0, -22, -44, -64, -82, -98, -111, -120, -126, -128, -126, -120, -111, -98, -82, -64, -44, -22, 0, 22, 44, 64, 82, 98, 111, 120, 126, @@ -9077,7 +9077,7 @@ void EdenGame::makeTables() { for (int i = 0; i < 36; i++) { for (int j = -35; j < 36; j++) - tab3[i][j + 35] = (cosine[i] * j) >> 7; + tab3[i][j + 35] = (cosineTable[i] * j) >> 7; } } @@ -9243,7 +9243,7 @@ void EdenGame::renderCube() { getSinCosTables(_angleZ, &_cosZ, &_sinZ); for (int i = 0; i < 6; i++) { - int area = calcFaceArea(pc_cube[i]); + int area = calcFaceArea(_cubePC[i]); if (area <= 0) { _face[i] = _newface[i]; // set new texture for invisible area, _faceSkip |= 1 << i; // but don't draw it just yet @@ -9299,7 +9299,7 @@ void EdenGame::decAngleY() { void EdenGame::incZoom() { if (_zoomZ == 170) _zoomZStep = 40; - if (_zoomZ == 570) + else if (_zoomZ == 570) _zoomZStep = -40; _zoomZ += _zoomZStep; } @@ -9317,35 +9317,35 @@ void EdenGame::initCubePC() { _zoomZ = 170; _zoomZStep = 40; _angleX = _angleY = _angleZ = 0; - _pcCursor = &pc_cursors[0]; - curs_cur_map = -1; + _pcCursor = &_cursorsPC[0]; + _cursCurPCMap = -1; makeTables(); } void EdenGame::selectPCMap(int16 num) { - if (num != curs_cur_map) { - _pcCursor = &pc_cursors[num]; + if (num != _cursCurPCMap) { + _pcCursor = &_cursorsPC[num]; unsigned char *bank = _mainBankBuf + READ_LE_UINT16(_mainBankBuf); for (int i = 0; i < 6; i++) { _newface[i] = 4 + (unsigned char*)getElem(bank, _pcCursor->_sides[i]); - if (curs_cur_map == -1) + if (_cursCurPCMap == -1) _face[i] = _newface[i]; } - curs_cur_map = num; + _cursCurPCMap = num; } } void EdenGame::enginePC() { int16 curs = _currCursor; - if (_normalCursor && (p_global->_drawFlags & DrawFlags::drDrawFlag20)) + if (_normalCursor && (_globals->_drawFlags & DrawFlags::drDrawFlag20)) curs = 9; selectPCMap(curs); _cursorNewTick = TickCount(); if (_cursorNewTick - _cursorOldTick < 1) return; _cursorOldTick = _cursorNewTick; - int step = _pcCursor->speed; - switch (_pcCursor->kind) { + int step = _pcCursor->_speed; + switch (_pcCursor->_kind) { case 0: break; case 1: // rot up-down @@ -9386,14 +9386,14 @@ int16 EdenGame::OpenDialog(void *arg1, void *arg2) { //void LostEdenMac_LoadPrefs() { } void EdenGame::LostEdenMac_InitPrefs() { - p_global->_prefLanguage = 1; + _globals->_prefLanguage = 1; _doubledScreen = false; // TODO: set to true - p_global->_prefMusicVol[0] = 192; - p_global->_prefMusicVol[1] = 192; - p_global->_prefVoiceVol[0] = 255; - p_global->_prefVoiceVol[1] = 255; - p_global->_prefSoundVolume[0] = 32; - p_global->_prefSoundVolume[1] = 32; + _globals->_prefMusicVol[0] = 192; + _globals->_prefMusicVol[1] = 192; + _globals->_prefVoiceVol[0] = 255; + _globals->_prefVoiceVol[1] = 255; + _globals->_prefSoundVolume[0] = 32; + _globals->_prefSoundVolume[1] = 32; } //void MacGame_DoAbout() { } diff --git a/engines/cryo/eden.h b/engines/cryo/eden.h index c7f2b8b767..be873a87a8 100644 --- a/engines/cryo/eden.h +++ b/engines/cryo/eden.h @@ -499,7 +499,7 @@ private: void selectMap(int16 num); void Eden_dep_and_rot(); void restoreZDEP(); - void affiche_polygone_mapping(cube_t *cube, cubeface_t *face); + void displayPolygoneMapping(cube_t *cube, cubeface_t *face); void drawMappingLine(int16 r3, int16 r4, int16 r5, int16 r6, int16 r7, int16 r8, int16 r9, int16 r10, int16 *lines); void displayMappingLine(int16 r3, int16 r4, byte *target, byte *texture); int16 OpenDialog(void *arg1, void *arg2); @@ -611,31 +611,30 @@ private: color_t newPalette[256]; Common::Rect rect_dst, rect_src; byte *_voiceSamplesBuffer; //TODO: sound sample buffer - Common::File h_bigfile; - byte _infoList[16]; - bool needToFade; - byte lastMusicNum; - byte *_mainBankBuf; - byte *_musicBuf; - byte *gameLipsync; - byte *gamePhrases; - byte *_gameDialogs; //TODO: rename to dialogs? - byte *_gameConditions; + Common::File _bigfile; + byte _infoList[16]; + bool _needToFade; + byte *_mainBankBuf; + byte *_musicBuf; + byte *_gameLipsync; + byte *_gamePhrases; + byte *_gameDialogs; //TODO: rename to dialogs? + byte *_gameConditions; byte *_placeRawBuf; //TODO: fixme byte *_bankDataBuf; Icon *_gameIcons; Room *_gameRooms; - PakHeaderNode *bigfile_header; + PakHeaderNode *_bigfileHeader; byte *_glowBuffer; byte *_mainViewBuf; - byte *p_view2_buf; + byte *_view2Buf; byte *_gameFont; //TODO: rename to font? byte *_subtitlesViewBuf; - byte *p_underSubtitlesView_buf; - global_t *p_global; + byte *_underSubtitlesViewBuf; // CHECKME: Useless? + global_t *_globals; uint16 _mouseCenterX; uint16 _mouseCenterY; - bool bufferAllocationErrorFl; + bool _bufferAllocationErrorFl; bool _quitFlag2; bool _quitFlag3; bool _gameStarted; @@ -646,10 +645,10 @@ private: soundchannel_t *_hnmSoundChannel; sound_t *_voiceSound; - View *p_view2; - View *p_underSubtitlesView; + View *_view2; + View *_underSubtitlesView; View *_subtitlesView; - View *p_underBarsView; + View *_underBarsView; View *_mainView; View *_hnmView; hnm_t *_hnmContext; @@ -671,49 +670,49 @@ private: Icon *_currSpot; Icon *_curSpot2; bool pomme_q; - bool _keyboardHeld; - bool _mouseHeld; - bool _normalCursor; + bool _keyboardHeld; + bool _mouseHeld; + bool _normalCursor; byte *_hnmViewBuf; - bool _showVideoSubtitle; - bool _videoCanceledFlag; //TODO: hnm_canceled - bool _specialTextMode; - int _hnmFrameNum; - int _voiceSamplesSize; //TODO: perso vox sample data len + bool _showVideoSubtitle; + bool _videoCanceledFlag; //TODO: hnm_canceled + bool _specialTextMode; + int _hnmFrameNum; + int _voiceSamplesSize; //TODO: perso vox sample data len int16 _musicRightVol; int16 _musicLeftVol; - bool _animateTalking; - bool _personTalking; - byte _musicFadeFlag; + bool _animateTalking; + bool _personTalking; + byte _musicFadeFlag; - char _musicSequencePos; - bool _musicPlayingFlag; + char _musicSequencePos; + bool _musicPlayingFlag; byte *_musicSamplesPtr; byte *_musicPatternsPtr; //TODO: sndblock_t ? byte *_musSequencePtr; - bool _musicEnabledFlag; - uint16 *pCurrentObjectLocation; - byte own_objects[128]; - bool byte_31D64; + bool _musicEnabledFlag; + uint16 *_currentObjectLocation; + byte _ownObjects[128]; + bool byte_31D64; - bool _noPalette; - bool _gameLoaded; + bool _noPalette; + bool _gameLoaded; #define MAX_TAPES 16 - tape_t tapes[MAX_TAPES]; - byte confirmMode; - byte *cur_slider_value_ptr; + tape_t _tapes[MAX_TAPES]; + byte _confirmMode; + byte *_curSliderValuePtr; byte _lastMenuItemIdLo; int16 _lastTapeRoomNum; int16 _curSliderX; - int16 cur_slider_y; - int16 destinationRoom; - int16 word_31E7A; + int16 _curSliderY; + int16 _destinationRoom; + int16 word_31E7A; // CHECKME: Unused? - int16 word_378CC; // TODO: set by CLComputer_Init to 0 - int16 word_378CE; // CHECKME: Unused + int16 word_378CC; // TODO: set by CLComputer_Init to 0 + int16 word_378CE; // CHECKME: Unused int _invIconsCount; int _invIconsBase; @@ -724,14 +723,14 @@ private: int dword_32424, dword_32428, dword_3242C; int dword_32430, dword_32434, dword_32438; int dword_3243C, dword_32440, dword_32444; - int16 word_32448; + int16 word_32448; // CHECKME: USeless? int16 word_3244A, word_3244C; - float flt_32450, flt_32454; - cube_t cube; - int16 curs_cur_map; + float flt_32450, flt_32454; // CHECKME: Useless? + cube_t _cube; + int16 _cursCurPCMap; int16 _lines[200 * 8]; - byte cube_texture[0x4000]; - int cube_faces; + byte _cubeTexture[0x4000]; + int _cubeFaces; int32 _cursorOldTick, _cursorNewTick; byte *_codePtr; }; |