Skip to content

Commit

Permalink
Fixed code.
Browse files Browse the repository at this point in the history
  • Loading branch information
FakelsHub committed Oct 24, 2020
1 parent e8487ec commit dfb1ba5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
10 changes: 4 additions & 6 deletions sfall/Modules/Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -943,14 +943,12 @@ static void __declspec(naked) main_death_scene_hook() {
}

static void __declspec(naked) display_body_hook() {
static const DWORD display_body_hook_Ret = 0x47098D;
__asm {
mov ebx, [esp + 0x60 - 0x28 + 8];
cmp ebx, 1; // check mode 0 or 1
jbe fix;
add esp, 8;
mov dword ptr [esp + 0x60 - 0x40], 0; // frm_ptr
jmp display_body_hook_Ret;
xor ebx, ebx;
jmp fo::funcoffs::art_id_;
fix:
dec edx; // USE.FRM
mov ecx, 48; // INVBOX.FRM
Expand Down Expand Up @@ -989,15 +987,15 @@ void Interface::init() {
if (hrpIsEnabled == false || hrpVersionValid) SafeWrite8(0x481345, 4); // main_death_scene_
if (hrpVersionValid) SafeWrite8(HRPAddress(0x10011738), 10);

// Cosmetic fix for the background image of the character portrait on the inventory and character screens
// Cosmetic fix for the background image of the character portrait for the player's inventory screen
HookCall(0x47093C, display_body_hook);
BYTE code[11] = {
0x8B, 0xD3, // mov edx, ebx
0x66, 0x8B, 0x58, 0xF4, // mov bx, [eax - 12] [sizeof(frame)]
0x0F, 0xAF, 0xD3, // imul edx, ebx (y * frame width)
0x53, 0x90 // push ebx (frame width)
};
SafeWriteBytes(0x470971, code, 11);
SafeWriteBytes(0x470971, code, 11); // calculates the offset in the pixel array for x/y coordinates
}

void Interface::exit() {
Expand Down
9 changes: 4 additions & 5 deletions sfall/Modules/Scripting/Handlers/Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,8 @@ static long GetArtFIDFile(long fid, const char* &file) {
}

static long DrawImage(OpcodeContext& ctx, bool isScaled) {
fo::func::selectWindowID(ctx.program()->currentScriptWin);
if (*(DWORD*)FO_VAR_currentWindow == -1) {
ctx.printOpcodeError("%s() - no created/selected window for the image.", ctx.getMetaruleName());
if (!fo::func::selectWindowID(ctx.program()->currentScriptWin) || *(DWORD*)FO_VAR_currentWindow == -1) {
ctx.printOpcodeError("%s() - no created or selected window.", ctx.getMetaruleName());
return 0;
}
long direction = 0;
Expand Down Expand Up @@ -785,9 +784,9 @@ void mf_interface_print(OpcodeContext& ctx) { // same as vanilla PrintRect
}

void mf_win_fill_color(OpcodeContext& ctx) {
fo::func::selectWindowID(ctx.program()->currentScriptWin);
long result = fo::func::selectWindowID(ctx.program()->currentScriptWin);
long iWin = *(DWORD*)FO_VAR_currentWindow;
if (iWin == -1) {
if (!result || iWin == -1) {
ctx.printOpcodeError("%s() - no created or selected window.", ctx.getMetaruleName());
ctx.setReturn(-1);
return;
Expand Down

0 comments on commit dfb1ba5

Please sign in to comment.