From 9b02f600dead3cea8925eeb104ce3404718d6447 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Wed, 19 Apr 2023 09:09:17 +0300 Subject: [PATCH] Add worldmap opcodes --- src/sfall_opcodes.cc | 25 +++++++++++++++++++++++++ src/worldmap.cc | 11 +++++++++++ src/worldmap.h | 3 +++ 3 files changed, 39 insertions(+) diff --git a/src/sfall_opcodes.cc b/src/sfall_opcodes.cc index fe642a7..8d5c57d 100644 --- a/src/sfall_opcodes.cc +++ b/src/sfall_opcodes.cc @@ -14,6 +14,7 @@ #include "sfall_lists.h" #include "stat.h" #include "svga.h" +#include "worldmap.h" namespace fallout { @@ -79,6 +80,20 @@ static void opGetPcBonusStat(Program* program) programStackPushInteger(program, value); } +// in_world_map +static void op_in_world_map(Program* program) +{ + programStackPushInteger(program, GameMode::isInGameMode(GameMode::kWorldmap) ? 1 : 0); +} + +// set_world_map_pos +static void op_set_world_map_pos(Program* program) +{ + int y = programStackPopInteger(program); + int x = programStackPopInteger(program); + wmSetPartyWorldPos(x, y); +} + // active_hand static void opGetCurrentHand(Program* program) { @@ -121,6 +136,13 @@ static void opGetGameMode(Program* program) programStackPushInteger(program, GameMode::getCurrentGameMode()); } +// set_car_current_town +static void op_set_car_current_town(Program* program) +{ + int area = programStackPopInteger(program); + wmCarSetCurrentArea(area); +} + // list_begin static void opListBegin(Program* program) { @@ -333,10 +355,13 @@ void sfallOpcodesInit() interpreterRegisterOpcode(0x815B, opSetPcBonusStat); interpreterRegisterOpcode(0x815C, op_get_pc_base_stat); interpreterRegisterOpcode(0x815D, opGetPcBonusStat); + interpreterRegisterOpcode(0x8170, op_in_world_map); + interpreterRegisterOpcode(0x8172, op_set_world_map_pos); interpreterRegisterOpcode(0x8193, opGetCurrentHand); interpreterRegisterOpcode(0x819D, opSetGlobalVar); interpreterRegisterOpcode(0x819E, opGetGlobalInt); interpreterRegisterOpcode(0x81AF, opGetGameMode); + interpreterRegisterOpcode(0x81B6, op_set_car_current_town); interpreterRegisterOpcode(0x820D, opListBegin); interpreterRegisterOpcode(0x820E, opListNext); interpreterRegisterOpcode(0x820F, opListEnd); diff --git a/src/worldmap.cc b/src/worldmap.cc index a02914f..9b6ff3d 100644 --- a/src/worldmap.cc +++ b/src/worldmap.cc @@ -6592,4 +6592,15 @@ void wmBlinkRndEncounterIcon(bool special) wmGenData.encounterIconIsVisible = false; } +void wmSetPartyWorldPos(int x, int y) +{ + wmGenData.worldPosX = x; + wmGenData.worldPosY = y; +} + +void wmCarSetCurrentArea(int area) +{ + wmGenData.currentCarAreaId = area; +} + } // namespace fallout diff --git a/src/worldmap.h b/src/worldmap.h index 1180d70..901b0a6 100644 --- a/src/worldmap.h +++ b/src/worldmap.h @@ -277,6 +277,9 @@ int wmSetMapMusic(int mapIdx, const char* name); int wmMatchAreaContainingMapIdx(int mapIdx, int* areaIdxPtr); int wmTeleportToArea(int areaIdx); +void wmSetPartyWorldPos(int x, int y); +void wmCarSetCurrentArea(int area); + } // namespace fallout #endif /* WORLD_MAP_H */