121 lines
3.3 KiB
C
121 lines
3.3 KiB
C
/**
|
|
* Copyright (c) 2025 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "engine.h"
|
|
#include "util/memory.h"
|
|
#include "time/time.h"
|
|
#include "input/input.h"
|
|
#include "locale/localemanager.h"
|
|
#include "display/display.h"
|
|
#include "scene/scene.h"
|
|
#include "asset/asset.h"
|
|
#include "ui/ui.h"
|
|
#include "map/map.h"
|
|
#include "script/scriptmanager.h"
|
|
#include "debug/debug.h"
|
|
#include "item/backpack.h"
|
|
#include "assert/assert.h"
|
|
|
|
engine_t ENGINE;
|
|
|
|
errorret_t engineInit(const int32_t argc, const char_t **argv) {
|
|
memoryZero(&ENGINE, sizeof(engine_t));
|
|
ENGINE.running = true;
|
|
ENGINE.argc = argc;
|
|
ENGINE.argv = argv;
|
|
|
|
// Init systems. Order is important.
|
|
timeInit();
|
|
inputInit();
|
|
// errorChain(assetInit());
|
|
errorChain(localeManagerInit());
|
|
errorChain(scriptManagerInit());
|
|
errorChain(displayInit());
|
|
errorChain(uiInit());
|
|
errorChain(mapInit());
|
|
errorChain(sceneInit());
|
|
backpackInit();
|
|
|
|
// Run the initial script.
|
|
scriptcontext_t ctx;
|
|
errorChain(scriptContextInit(&ctx));
|
|
// errorChain(scriptContextExecFile(&ctx, "init.dsf"));
|
|
|
|
errorChain(scriptContextExec(&ctx,
|
|
"printf('Lua still working')"
|
|
// "module('platform')\n"
|
|
// "module('input')\n"
|
|
// "module('scene')\n"
|
|
// "module('locale')\n"
|
|
// "if PLATFORM == \"psp\" then\n"
|
|
// " inputBind(\"up\", INPUT_ACTION_UP)\n"
|
|
// " inputBind(\"down\", INPUT_ACTION_DOWN)\n"
|
|
// " inputBind(\"left\", INPUT_ACTION_LEFT)\n"
|
|
// " inputBind(\"right\", INPUT_ACTION_RIGHT)\n"
|
|
// " inputBind(\"circle\", INPUT_ACTION_CANCEL)\n"
|
|
// " inputBind(\"cross\", INPUT_ACTION_ACCEPT)\n"
|
|
// " inputBind(\"select\", INPUT_ACTION_RAGEQUIT)\n"
|
|
// " inputBind(\"lstick_up\", INPUT_ACTION_UP)\n"
|
|
// " inputBind(\"lstick_down\", INPUT_ACTION_DOWN)\n"
|
|
// " inputBind(\"lstick_left\", INPUT_ACTION_LEFT)\n"
|
|
// " inputBind(\"lstick_right\", INPUT_ACTION_RIGHT)\n"
|
|
// "else\n"
|
|
// " if INPUT_KEYBOARD then\n"
|
|
// " inputBind(\"w\", INPUT_ACTION_UP)\n"
|
|
// " inputBind(\"s\", INPUT_ACTION_DOWN)\n"
|
|
// " inputBind(\"a\", INPUT_ACTION_LEFT)\n"
|
|
// " inputBind(\"d\", INPUT_ACTION_RIGHT)\n"
|
|
// " inputBind(\"left\", INPUT_ACTION_LEFT)\n"
|
|
// " inputBind(\"right\", INPUT_ACTION_RIGHT)\n"
|
|
// " inputBind(\"up\", INPUT_ACTION_UP)\n"
|
|
// " inputBind(\"down\", INPUT_ACTION_DOWN)\n"
|
|
// " inputBind(\"enter\", INPUT_ACTION_ACCEPT)\n"
|
|
// " inputBind(\"e\", INPUT_ACTION_ACCEPT)\n"
|
|
// " inputBind(\"q\", INPUT_ACTION_CANCEL)\n"
|
|
// " inputBind(\"escape\", INPUT_ACTION_RAGEQUIT)\n"
|
|
// " end \n"
|
|
// "end\n"
|
|
// "localeSet(DUSK_LOCALE_EN_US)\n"
|
|
// "print('Good here')"
|
|
));
|
|
|
|
scriptContextDispose(&ctx);
|
|
|
|
errorOk();
|
|
}
|
|
|
|
errorret_t engineUpdate(void) {
|
|
#if DOLPHIN
|
|
ENGINE.running = SYS_MainLoop();
|
|
#endif
|
|
|
|
timeUpdate();
|
|
inputUpdate();
|
|
|
|
uiUpdate();
|
|
errorChain(sceneUpdate());
|
|
mapUpdate();
|
|
errorChain(displayUpdate());
|
|
|
|
if(inputPressed(INPUT_ACTION_RAGEQUIT)) ENGINE.running = false;
|
|
|
|
errorOk();
|
|
}
|
|
|
|
void engineExit(void) {
|
|
ENGINE.running = false;
|
|
}
|
|
|
|
errorret_t engineDispose(void) {
|
|
sceneDispose();
|
|
mapDispose();
|
|
localeManagerDispose();
|
|
uiDispose();
|
|
errorChain(displayDispose());
|
|
assetDispose();
|
|
errorOk();
|
|
} |