mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-07 03:18:17 +00:00
EMI: Implement sleep_for in the engine
This commit is contained in:
parent
211fee89ac
commit
d72bea895b
@ -512,6 +512,7 @@ static struct luaL_reg int_funcs[] = {
|
||||
{ "pause_scripts", pause_scripts },
|
||||
{ "unpause_scripts", unpause_scripts },
|
||||
{ "find_script", find_script },
|
||||
{ "sleep_for", sleep_for },
|
||||
{ "break_here", break_here }
|
||||
};
|
||||
|
||||
|
@ -15,6 +15,7 @@ void find_script();
|
||||
void identify_script();
|
||||
void next_script();
|
||||
void break_here();
|
||||
void sleep_for();
|
||||
void pause_scripts();
|
||||
void unpause_scripts();
|
||||
|
||||
|
@ -281,7 +281,7 @@ int32 luaD_call(StkId base, int32 nResults) {
|
||||
base = lua_state->task->some_base;
|
||||
}
|
||||
|
||||
if (function == break_here) {
|
||||
if (function == break_here || function == sleep_for) {
|
||||
if (!lua_state->state_counter1) {
|
||||
lua_state->some_task = tmpTask;
|
||||
return 1;
|
||||
|
@ -92,6 +92,7 @@ void lua_stateinit(LState *state) {
|
||||
state->task = NULL;
|
||||
state->some_task = NULL;
|
||||
state->taskFunc.ttype = LUA_T_NIL;
|
||||
state->sleepFor = 0;
|
||||
|
||||
state->stack.stack = luaM_newvector(STACK_UNIT, TObject);
|
||||
state->stack.top = state->stack.stack;
|
||||
|
@ -90,6 +90,7 @@ struct LState {
|
||||
TObject taskFunc;
|
||||
struct C_Lua_Stack Cblocks[MAX_C_BLOCKS];
|
||||
int numCblocks; // number of nested Cblocks
|
||||
int sleepFor;
|
||||
};
|
||||
|
||||
extern LState *lua_state, *lua_rootState;
|
||||
|
@ -243,6 +243,15 @@ void current_script() {
|
||||
|
||||
void break_here() {}
|
||||
|
||||
void sleep_for() {
|
||||
lua_Object msObj = lua_getparam(1);
|
||||
|
||||
if (lua_isnumber(msObj)) {
|
||||
int ms = (int)lua_getnumber(msObj);
|
||||
lua_state->sleepFor = ms;
|
||||
}
|
||||
}
|
||||
|
||||
void lua_runtasks() {
|
||||
if (!lua_state || !lua_state->next) {
|
||||
return;
|
||||
@ -251,7 +260,11 @@ void lua_runtasks() {
|
||||
// Mark all the states to be updated
|
||||
LState *state = lua_state->next;
|
||||
do {
|
||||
state->updated = false;
|
||||
if (state->sleepFor > 0) {
|
||||
state->sleepFor -= g_grim->getFrameTime();
|
||||
} else {
|
||||
state->updated = false;
|
||||
}
|
||||
state = state->next;
|
||||
} while (state);
|
||||
|
||||
|
@ -32,6 +32,7 @@ void pause_scripts();
|
||||
void unpause_scripts();
|
||||
void find_script();
|
||||
void break_here();
|
||||
void sleep_for();
|
||||
|
||||
void runtasks(LState *const rootState);
|
||||
|
||||
|
@ -73,16 +73,6 @@ void Lua_V2::UndimRegion() {
|
||||
}
|
||||
}
|
||||
|
||||
void Lua_V2::SleepFor() {
|
||||
lua_Object msObj = lua_getparam(1);
|
||||
|
||||
if (lua_isnumber(msObj)) {
|
||||
int ms = (int)lua_getnumber(msObj);
|
||||
// FIXME func(ms);
|
||||
warning("Lua_V2::SleepFor: ms: %d", ms);
|
||||
}
|
||||
}
|
||||
|
||||
void Lua_V2::DimScreen() {
|
||||
lua_Object dimObj = lua_getparam(1);
|
||||
float dim = 0.6999f;
|
||||
@ -1046,8 +1036,7 @@ struct luaL_reg monkeyMainOpcodes[] = {
|
||||
{ "SectEditSortAdd", LUA_OPCODE(Lua_V2, SectEditSortAdd) },
|
||||
{ "SectEditForgetIt", LUA_OPCODE(Lua_V2, SectEditForgetIt) },
|
||||
{ "FRUTEY_Begin", LUA_OPCODE(Lua_V2, FRUTEY_Begin) },
|
||||
{ "FRUTEY_End", LUA_OPCODE(Lua_V2, FRUTEY_End) },
|
||||
{ "sleep_for", LUA_OPCODE(Lua_V2, SleepFor) }
|
||||
{ "FRUTEY_End", LUA_OPCODE(Lua_V2, FRUTEY_End) }
|
||||
};
|
||||
|
||||
void Lua_V2::registerOpcodes() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user