Add pc bonus stats opcodes

See #200
This commit is contained in:
Alexander Batalov 2022-11-08 18:59:14 +03:00
parent 2255481d50
commit ef54463fcc
1 changed files with 23 additions and 0 deletions

View File

@ -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);