From cf4921de1ef4d59f2939c6272766e4f0eb9f6c54 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Thu, 20 Apr 2023 10:25:13 +0300 Subject: [PATCH] Add op_tile_under_cursor --- src/sfall_opcodes.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/sfall_opcodes.cc b/src/sfall_opcodes.cc index dd1580c..f918d79 100644 --- a/src/sfall_opcodes.cc +++ b/src/sfall_opcodes.cc @@ -17,6 +17,7 @@ #include "sfall_lists.h" #include "stat.h" #include "svga.h" +#include "tile.h" #include "worldmap.h" namespace fallout { @@ -421,6 +422,17 @@ static void op_atof(Program* program) programStackPushFloat(program, static_cast(atof(string))); } +// tile_under_cursor +static void op_tile_under_cursor(Program* program) +{ + int x; + int y; + mouseGetPosition(&x, &y); + + int tile = tileFromScreenXY(x, y, gElevation); + programStackPushInteger(program, tile); +} + // strlen static void opGetStringLength(Program* program) { @@ -532,6 +544,7 @@ void sfallOpcodesInit() interpreterRegisterOpcode(0x8221, opGetScreenHeight); interpreterRegisterOpcode(0x8237, opParseInt); interpreterRegisterOpcode(0x8238, op_atof); + interpreterRegisterOpcode(0x824B, op_tile_under_cursor); interpreterRegisterOpcode(0x824F, opGetStringLength); interpreterRegisterOpcode(0x8263, op_power); interpreterRegisterOpcode(0x826B, opGetMessage);