From cd52ca45763f05112d6d7490caba493d3982ffe5 Mon Sep 17 00:00:00 2001 From: jtuu Date: Thu, 17 Oct 2019 20:02:53 +0300 Subject: [PATCH] [VM] Made the implementation of opcodes letb and letw more correct. --- src/quest_editor/scripting/vm/index.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/quest_editor/scripting/vm/index.ts b/src/quest_editor/scripting/vm/index.ts index cb1e43c9..09b2529c 100644 --- a/src/quest_editor/scripting/vm/index.ts +++ b/src/quest_editor/scripting/vm/index.ts @@ -248,8 +248,10 @@ export class VirtualMachine { this.set_register_signed(arg0, arg1); break; case OP_LETB.code: + this.set_register_byte(arg0, arg1); + break; case OP_LETW.code: - this.set_register_unsigned(arg0, arg1); + this.set_register_word(arg0, arg1); break; case OP_LETA.code: this.set_register_unsigned(arg0, this.get_register_address(arg0)); @@ -596,6 +598,22 @@ export class VirtualMachine { this.registers.write_u32_at(REGISTER_SIZE * reg, value); } + public get_register_word(reg: number): number { + return this.registers.u16_at(REGISTER_SIZE * reg); + } + + private set_register_word(reg: number, value: number): void { + this.registers.write_u16_at(REGISTER_SIZE * reg, value); + } + + public get_register_byte(reg: number): number { + return this.registers.u8_at(REGISTER_SIZE * reg); + } + + public set_register_byte(reg: number, value: number): void { + this.registers.write_u8_at(REGISTER_SIZE * reg, value) + } + public get_register_float(reg: number): number { return this.registers.f32_at(REGISTER_SIZE * reg); }