From fa475c754e3d33726608a7ecbc782f3b8742b196 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Wed, 9 Nov 2022 13:09:56 +0300 Subject: [PATCH] Add opReadByte See #200 --- src/combat.cc | 5 +++++ src/combat.h | 1 + src/sfall_opcodes.cc | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/src/combat.cc b/src/combat.cc index 071ac85..6da77dd 100644 --- a/src/combat.cc +++ b/src/combat.cc @@ -6002,6 +6002,11 @@ void _combatKillCritterOutsideCombat(Object* critter_obj, char* msg) } } +int combatGetTargetHighlight() +{ + return _combat_highlight; +} + static void criticalsInit() { int mode = 2; diff --git a/src/combat.h b/src/combat.h index a648662..5775eae 100644 --- a/src/combat.h +++ b/src/combat.h @@ -58,6 +58,7 @@ int _combat_explode_scenery(Object* a1, Object* a2); void _combat_delete_critter(Object* obj); void _combatKillCritterOutsideCombat(Object* critter_obj, char* msg); +int combatGetTargetHighlight(); int criticalsGetValue(int killType, int hitLocation, int effect, int dataMember); void criticalsSetValue(int killType, int hitLocation, int effect, int dataMember, int value); void criticalsResetValue(int killType, int hitLocation, int effect, int dataMember); diff --git a/src/sfall_opcodes.cc b/src/sfall_opcodes.cc index d3a7a57..6972614 100644 --- a/src/sfall_opcodes.cc +++ b/src/sfall_opcodes.cc @@ -1,6 +1,8 @@ #include "sfall_opcodes.h" #include "art.h" +#include "combat.h" +#include "debug.h" #include "interface.h" #include "interpreter.h" #include "item.h" @@ -13,6 +15,24 @@ namespace fallout { +// read_byte +static void opReadByte(Program* program) +{ + int addr = programStackPopInteger(program); + + int value = 0; + switch (addr) { + case 0x56D38C: + value = combatGetTargetHighlight(); + break; + default: + debugPrint("%s: attempt to 'read_byte' at 0x%x", program->name, addr); + break; + } + + programStackPushInteger(program, value); +} + // set_pc_extra_stat static void opSetPcBonusStat(Program* program) { @@ -224,6 +244,7 @@ static void opArtExists(Program* program) void sfallOpcodesInit() { + interpreterRegisterOpcode(0x8156, opReadByte); interpreterRegisterOpcode(0x815B, opSetPcBonusStat); interpreterRegisterOpcode(0x815D, opGetPcBonusStat); interpreterRegisterOpcode(0x8193, opGetCurrentHand);