Created
May 4, 2020 21:42
-
-
Save leiradel/34fe608dde33697a3c9e91eb140b7cbd to your computer and use it in GitHub Desktop.
Core FSM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
header { | |
#include "Core.h" | |
#include <string> | |
typedef const std::string const_string; | |
} | |
fsm CoreFsm { | |
class lrcpp::Core as ctx; | |
Start { | |
load(const_string corePath) => CoreLoaded { | |
if (!ctx.load(corePath)) { | |
forbid; | |
} | |
} | |
} | |
CoreLoaded { | |
setEnvironment(retro_environment_t cb) => EnvironmentSet { | |
ctx.setEnvironment(cb); | |
} | |
unload() => Start { | |
ctx.unload(); | |
} | |
} | |
EnvironmentSet { | |
init() => CoreInitialized { | |
ctx.init(); | |
} | |
unload() => Start { | |
ctx.unload(); | |
} | |
} | |
CoreInitialized { | |
loadGame(const_string gamePath) => GameLoaded { | |
if (!ctx.loadGame(path)) { | |
forbid; | |
} | |
} | |
deinit() => EnvironmentSet { | |
ctx.deinit(); | |
} | |
unload() => deinit() => unload(); | |
} | |
GameLoaded { | |
setupGame( | |
retro_video_refresh_t videoRefresh, | |
retro_audio_sample_t audioSample, | |
retro_audio_sample_batch_t audioSampleBatch, | |
retro_input_poll_t inputPoll, | |
retro_input_state_t inputState | |
) => GameRunning { | |
ctx.setVideoRefresh(videoRefresh); | |
ctx.setAudioSample(audioSample); | |
ctx.setAudioSampleBatch(audioSampleBatch); | |
ctx.setInputPoll(inputPoll); | |
ctx.setInputState(inputState); | |
} | |
unloadGame() => CoreInitialized { | |
ctx.unloadGame(); | |
} | |
deinit() => unloadGame() => deinit(); | |
unload() => unloadGame() => unload(); | |
} | |
GameRunning { | |
run() => GameRunning { | |
ctx.run(); | |
} | |
reset() => GameRunning { | |
ctx.reset(); | |
} | |
serializedSize(size_t& size) => GameRunning { | |
size = ctx.serializeSize(); | |
} | |
serialize(void* data, size_t size) => GameRunning { | |
ctx.serialize(data, size); | |
} | |
unserialize(const void* data, size_t size) => GameRunning { | |
ctx.unserialize(data, size); | |
} | |
unloadGame() => CoreInitialized { | |
ctx.unloadGame(); | |
} | |
deinit() => unloadGame() => deinit(); | |
unload() => unloadGame() => unload(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment