void AgiEngine::interpretCycle() { ScreenObjEntry *screenObjEgo = &_game.screenObjTable[SCREENOBJECTS_EGO_ENTRY]; bool oldSound; byte oldScore; if (!_game.playerControl) setVar(VM_VAR_EGO_DIRECTION, screenObjEgo->direction); else screenObjEgo->direction = getVar(VM_VAR_EGO_DIRECTION); checkAllMotions(); oldScore = getVar(VM_VAR_SCORE); oldSound = getFlag(VM_FLAG_SOUND_ON); // Reset script heuristic here resetGetVarSecondsHeuristic(); _game.exitAllLogics = false; while (runLogic(0) == 0 && !(shouldQuit() || _restartGame)) { setVar(VM_VAR_WORD_NOT_FOUND, 0); setVar(VM_VAR_BORDER_TOUCH_OBJECT, 0); setVar(VM_VAR_BORDER_CODE, 0); oldScore = getVar(VM_VAR_SCORE); setFlag(VM_FLAG_ENTERED_CLI, false); _game.exitAllLogics = false; artificialDelay_CycleDone(); resetControllers(); } artificialDelay_CycleDone(); resetControllers(); screenObjEgo->direction = getVar(VM_VAR_EGO_DIRECTION); if (getVar(VM_VAR_SCORE) != oldScore || getFlag(VM_FLAG_SOUND_ON) != oldSound) _game._vm->_text->statusDraw(); setVar(VM_VAR_BORDER_TOUCH_OBJECT, 0); setVar(VM_VAR_BORDER_CODE, 0); setFlag(VM_FLAG_NEW_ROOM_EXEC, false); setFlag(VM_FLAG_RESTART_GAME, false); setFlag(VM_FLAG_RESTORE_JUST_RAN, false); if (_game.gfxMode) { updateScreenObjTable(); } _gfx->updateScreen(); //_gfx->doUpdate(); }
/* * * Return the lowest number controller connected to system */ int initControllers() { OSMesgQueue serialMsgQ; OSMesg serialMsg; int i; u8 pattern; resetControllers(); osCreateMesgQueue(&serialMsgQ, &serialMsg, 1); osSetEventMesg(OS_EVENT_SI, &serialMsgQ, (OSMesg)1); osContInit(&serialMsgQ, &pattern, &statusdata[0]); osCreateMesgQueue(&controllerMsgQ, &controllerMsgBuf, 1); osSetEventMesg(OS_EVENT_SI, &controllerMsgQ, (OSMesg)0); for (i = 0; i < MAXCONTROLLERS; i++) { if ((pattern & (1<<i)) && !(statusdata[i].errno & CONT_NO_RESPONSE_ERROR)) return i; } return -1; }
void musicBlock::resetAllControllers(int vol) { uint32_t i; for (i = 0; i < NUM_CHANNELS; i++) { resetControllers(i, vol); } }
AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBase(syst, gameDesc) { // Setup mixer syncSoundSettings(); parseFeatures(); DebugMan.addDebugChannel(kDebugLevelMain, "Main", "Generic debug level"); DebugMan.addDebugChannel(kDebugLevelResources, "Resources", "Resources debugging"); DebugMan.addDebugChannel(kDebugLevelSprites, "Sprites", "Sprites debugging"); DebugMan.addDebugChannel(kDebugLevelInventory, "Inventory", "Inventory debugging"); DebugMan.addDebugChannel(kDebugLevelInput, "Input", "Input events debugging"); DebugMan.addDebugChannel(kDebugLevelMenu, "Menu", "Menu debugging"); DebugMan.addDebugChannel(kDebugLevelScripts, "Scripts", "Scripts debugging"); DebugMan.addDebugChannel(kDebugLevelSound, "Sound", "Sound debugging"); DebugMan.addDebugChannel(kDebugLevelText, "Text", "Text output debugging"); DebugMan.addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging"); memset(&_game, 0, sizeof(struct AgiGame)); memset(&_debug, 0, sizeof(struct AgiDebug)); memset(&_mouse, 0, sizeof(struct Mouse)); _game._vm = this; _game.clockEnabled = false; _game.state = STATE_INIT; _keyQueueStart = 0; _keyQueueEnd = 0; _allowSynthetic = false; _intobj = NULL; _menu = NULL; _menuSelected = false; _lastSentence[0] = 0; memset(&_stringdata, 0, sizeof(struct StringData)); _objects = NULL; _restartGame = false; _oldMode = INPUT_NONE; _firstSlot = 0; resetControllers(); setupOpcodes(); _game._curLogic = NULL; _timerHack = 0; }
void AgiEngine::interpretCycle() { int oldSound, oldScore; if (_game.playerControl) _game.vars[vEgoDir] = _game.viewTable[0].direction; else _game.viewTable[0].direction = _game.vars[vEgoDir]; checkAllMotions(); oldScore = _game.vars[vScore]; oldSound = getflag(fSoundOn); _game.exitAllLogics = false; while (runLogic(0) == 0 && !(shouldQuit() || _restartGame)) { _game.vars[vWordNotFound] = 0; _game.vars[vBorderTouchObj] = 0; _game.vars[vBorderCode] = 0; oldScore = _game.vars[vScore]; setflag(fEnteredCli, false); _game.exitAllLogics = false; resetControllers(); } resetControllers(); _game.viewTable[0].direction = _game.vars[vEgoDir]; if (_game.vars[vScore] != oldScore || getflag(fSoundOn) != oldSound) writeStatus(); _game.vars[vBorderTouchObj] = 0; _game.vars[vBorderCode] = 0; setflag(fNewRoomExec, false); setflag(fRestartGame, false); setflag(fRestoreJustRan, false); if (_game.gfxMode) { updateViewtable(); _gfx->doUpdate(); } }
AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBase(syst, gameDesc) { // Setup mixer syncSoundSettings(); DebugMan.addDebugChannel(kDebugLevelMain, "Main", "Generic debug level"); DebugMan.addDebugChannel(kDebugLevelResources, "Resources", "Resources debugging"); DebugMan.addDebugChannel(kDebugLevelSprites, "Sprites", "Sprites debugging"); DebugMan.addDebugChannel(kDebugLevelInventory, "Inventory", "Inventory debugging"); DebugMan.addDebugChannel(kDebugLevelInput, "Input", "Input events debugging"); DebugMan.addDebugChannel(kDebugLevelMenu, "Menu", "Menu debugging"); DebugMan.addDebugChannel(kDebugLevelScripts, "Scripts", "Scripts debugging"); DebugMan.addDebugChannel(kDebugLevelSound, "Sound", "Sound debugging"); DebugMan.addDebugChannel(kDebugLevelText, "Text", "Text output debugging"); DebugMan.addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging"); memset(&_game, 0, sizeof(struct AgiGame)); memset(&_debug, 0, sizeof(struct AgiDebug)); memset(&_mouse, 0, sizeof(struct Mouse)); _game.mouseEnabled = true; _game.mouseHidden = false; // don't check for Amiga, Amiga doesn't allow disabling mouse support. It's mandatory. if (!ConfMan.getBool("mousesupport")) { // we effectively disable the mouse for games, that explicitly do not want mouse support to be enabled _game.mouseEnabled = false; _game.mouseHidden = true; } _game._vm = this; _game.gfxMode = true; _keyQueueStart = 0; _keyQueueEnd = 0; _allowSynthetic = false; _intobj = NULL; memset(&_stringdata, 0, sizeof(struct StringData)); _objects = NULL; _restartGame = false; _firstSlot = 0; resetControllers(); setupOpcodes(); _game._curLogic = NULL; _veryFirstInitialCycle = true; _instructionCounter = 0; resetGetVarSecondsHeuristic(); _setVolumeBrokenFangame = false; // for further study see AgiEngine::setVolumeViaScripts() _lastSaveTime = 0; memset(_keyQueue, 0, sizeof(_keyQueue)); _console = nullptr; _font = nullptr; _gfx = nullptr; _sound = nullptr; _picture = nullptr; _sprites = nullptr; _text = nullptr; _loader = nullptr; _menu = nullptr; _systemUI = nullptr; _inventory = nullptr; _keyHoldMode = false; }
void readController(int controllerSlot) { static u16 button, lastbutton; int stick_x, stick_y; if (controllerSlot < 0) { osSyncPrintf("no controller connection\n"); return; } osContStartReadData(&controllerMsgQ); (void)osRecvMesg(&controllerMsgQ, NULL, OS_MESG_BLOCK); osContGetReadData(controllerdata); button = controllerdata[controllerSlot].button; stick_x = controllerdata[controllerSlot].stick_x; stick_y = controllerdata[controllerSlot].stick_y; if ((stick_x >= -5 && stick_x <= 5) && (stick_y >= -5 && stick_y <= 5)) { stop_walk_cycle(); } else { start_walk_cycle(); p1_dx = (float) ((float)stick_x/90.0); p1_dz = (float) ((float)stick_y/90.0); p1_tx = (float) ((float)stick_x/90.0); p1_tz = (float) -((float)stick_y/90.0); } if (button & CONT_A && !(lastbutton & CONT_A)) { which_char++; which_char = which_char % 4; } if (button & CONT_B && !(lastbutton & CONT_B)) { do_turbo_z ^= 0x01; } if (button & CONT_G && !(lastbutton & CONT_G)) { if (do_view_rotate) do_view_rotate = FALSE; else do_view_rotate = TRUE; } if (button & CONT_START) { resetControllers(); } if (button & CONT_UP) { view_dist -= 2.0; } if (button & CONT_DOWN) { view_dist += 2.0; } if ((button & CONT_LEFT) && !(lastbutton & CONT_LEFT)) { } if ((button & CONT_RIGHT) && !(lastbutton & CONT_RIGHT)) { } if (button & CONT_L) { view_rotate_inc = -(6.28/1200.0); } if (button & CONT_R) { view_rotate_inc = (6.28/1200.0); } if ((button & CONT_E) && !(lastbutton & CONT_E)) { } if ((button & CONT_D) && !(lastbutton & CONT_D)) { use_fifo_ucode ^= TRUE; } if ((button & CONT_C) && !(lastbutton & CONT_C)) { do_left_punch = TRUE; } if ((button & CONT_F) && !(lastbutton & CONT_F)) { do_right_punch = TRUE; } lastbutton = button; }