diff --git a/src/sfall_arrays.cc b/src/sfall_arrays.cc index e4d02cf..7350a01 100644 --- a/src/sfall_arrays.cc +++ b/src/sfall_arrays.cc @@ -102,6 +102,8 @@ int LenArray(ArrayId array_id) ProgramValue GetArray(ArrayId array_id, const SFallScriptValue& key) { + // TODO: If type is string then do substr + auto arr = get_array_by_id(array_id); if (arr == nullptr) { return SFallScriptValue(0); diff --git a/src/sfall_opcodes.cc b/src/sfall_opcodes.cc index 16ed986..70f6a42 100644 --- a/src/sfall_opcodes.cc +++ b/src/sfall_opcodes.cc @@ -317,6 +317,16 @@ static void opTempArray(Program* program) programStackPushInteger(program, array_id); } +// set_array +static void opSetArray(Program* program) +{ + auto value = programStackPopValue(program); + auto key = programStackPopValue(program); + auto arrayId = programStackPopInteger(program); + + SetArray(arrayId, SFallScriptValue { key }, SFallScriptValue { value }, true); +} + // get_array static void opGetArray(Program* program) { @@ -395,6 +405,7 @@ void sfallOpcodesInit() interpreterRegisterOpcode(0x8220, opGetScreenWidth); interpreterRegisterOpcode(0x8221, opGetScreenHeight); interpreterRegisterOpcode(0x822D, opCreateArray); + interpreterRegisterOpcode(0x822E, opSetArray); interpreterRegisterOpcode(0x822F, opGetArray); interpreterRegisterOpcode(0x8230, opFreeArray); interpreterRegisterOpcode(0x8231, opLenArray);