From ef54463fcc3e6b4103b78faa120985a7343ee5d0 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Tue, 8 Nov 2022 18:59:14 +0300 Subject: [PATCH] Add pc bonus stats opcodes See #200 --- src/sfall_opcodes.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/sfall_opcodes.cc b/src/sfall_opcodes.cc index 9b4ba2b..37b30d5 100644 --- a/src/sfall_opcodes.cc +++ b/src/sfall_opcodes.cc @@ -5,11 +5,32 @@ #include "interpreter.h" #include "item.h" #include "mouse.h" +#include "object.h" #include "sfall_global_vars.h" +#include "stat.h" #include "svga.h" namespace fallout { +// set_pc_extra_stat +static void opSetPcBonusStat(Program* program) +{ + // CE: Implementation is different. Sfall changes value directly on the + // dude's proto, without calling |critterSetBonusStat|. This function has + // important call to update derived stats, which is not present in Sfall. + int value = programStackPopInteger(program); + int stat = programStackPopInteger(program); + critterSetBonusStat(gDude, stat, value); +} + +// get_pc_extra_stat +static void opGetPcBonusStat(Program* program) +{ + int stat = programStackPopInteger(program); + int value = critterGetBonusStat(gDude, stat); + programStackPushInteger(program, value); +} + // active_hand static void opGetCurrentHand(Program* program) { @@ -179,6 +200,8 @@ static void opArtExists(Program* program) void sfallOpcodesInit() { + interpreterRegisterOpcode(0x815B, opSetPcBonusStat); + interpreterRegisterOpcode(0x815D, opGetPcBonusStat); interpreterRegisterOpcode(0x8193, opGetCurrentHand); interpreterRegisterOpcode(0x819D, opSetGlobalVar); interpreterRegisterOpcode(0x819E, opGetGlobalInt);