Add worldmap opcodes

This commit is contained in:
Alexander Batalov 2023-04-19 09:09:17 +03:00
parent 0bb07dbd50
commit 9b02f600de
3 changed files with 39 additions and 0 deletions

View File

@ -14,6 +14,7 @@
#include "sfall_lists.h" #include "sfall_lists.h"
#include "stat.h" #include "stat.h"
#include "svga.h" #include "svga.h"
#include "worldmap.h"
namespace fallout { namespace fallout {
@ -79,6 +80,20 @@ static void opGetPcBonusStat(Program* program)
programStackPushInteger(program, value); 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 // active_hand
static void opGetCurrentHand(Program* program) static void opGetCurrentHand(Program* program)
{ {
@ -121,6 +136,13 @@ static void opGetGameMode(Program* program)
programStackPushInteger(program, GameMode::getCurrentGameMode()); 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 // list_begin
static void opListBegin(Program* program) static void opListBegin(Program* program)
{ {
@ -333,10 +355,13 @@ void sfallOpcodesInit()
interpreterRegisterOpcode(0x815B, opSetPcBonusStat); interpreterRegisterOpcode(0x815B, opSetPcBonusStat);
interpreterRegisterOpcode(0x815C, op_get_pc_base_stat); interpreterRegisterOpcode(0x815C, op_get_pc_base_stat);
interpreterRegisterOpcode(0x815D, opGetPcBonusStat); interpreterRegisterOpcode(0x815D, opGetPcBonusStat);
interpreterRegisterOpcode(0x8170, op_in_world_map);
interpreterRegisterOpcode(0x8172, op_set_world_map_pos);
interpreterRegisterOpcode(0x8193, opGetCurrentHand); interpreterRegisterOpcode(0x8193, opGetCurrentHand);
interpreterRegisterOpcode(0x819D, opSetGlobalVar); interpreterRegisterOpcode(0x819D, opSetGlobalVar);
interpreterRegisterOpcode(0x819E, opGetGlobalInt); interpreterRegisterOpcode(0x819E, opGetGlobalInt);
interpreterRegisterOpcode(0x81AF, opGetGameMode); interpreterRegisterOpcode(0x81AF, opGetGameMode);
interpreterRegisterOpcode(0x81B6, op_set_car_current_town);
interpreterRegisterOpcode(0x820D, opListBegin); interpreterRegisterOpcode(0x820D, opListBegin);
interpreterRegisterOpcode(0x820E, opListNext); interpreterRegisterOpcode(0x820E, opListNext);
interpreterRegisterOpcode(0x820F, opListEnd); interpreterRegisterOpcode(0x820F, opListEnd);

View File

@ -6592,4 +6592,15 @@ void wmBlinkRndEncounterIcon(bool special)
wmGenData.encounterIconIsVisible = false; wmGenData.encounterIconIsVisible = false;
} }
void wmSetPartyWorldPos(int x, int y)
{
wmGenData.worldPosX = x;
wmGenData.worldPosY = y;
}
void wmCarSetCurrentArea(int area)
{
wmGenData.currentCarAreaId = area;
}
} // namespace fallout } // namespace fallout

View File

@ -277,6 +277,9 @@ int wmSetMapMusic(int mapIdx, const char* name);
int wmMatchAreaContainingMapIdx(int mapIdx, int* areaIdxPtr); int wmMatchAreaContainingMapIdx(int mapIdx, int* areaIdxPtr);
int wmTeleportToArea(int areaIdx); int wmTeleportToArea(int areaIdx);
void wmSetPartyWorldPos(int x, int y);
void wmCarSetCurrentArea(int area);
} // namespace fallout } // namespace fallout
#endif /* WORLD_MAP_H */ #endif /* WORLD_MAP_H */