Added support for map_designate and map_designate_ex to the VM.

This commit is contained in:
Daan Vanden Bosch 2020-01-02 18:54:18 +01:00
parent 93e05ea614
commit 70e6eef27c
3 changed files with 19 additions and 14 deletions

View File

@ -276,11 +276,7 @@ export class QuestRunner {
}
return {
bb_map_designate: (
area_id: number,
map_number: number,
area_variant_id: number,
): void => {
map_designate: (area_id: number, area_variant_id: number): void => {
this._game_state.area_variants.set(
area_id,
this.area_store.get_variant(this._game_state.episode, area_id, area_variant_id),

View File

@ -51,6 +51,8 @@ import {
OP_LETI,
OP_LETW,
OP_LIST,
OP_MAP_DESIGNATE,
OP_MAP_DESIGNATE_EX,
OP_MOD,
OP_MODI,
OP_MUL,
@ -477,7 +479,7 @@ export class VirtualMachine {
let advance = true;
const arg_vals = inst.args.map(arg => arg.value);
const [arg0, arg1, arg2, arg3] = arg_vals;
const [arg0, arg1, arg2] = arg_vals;
// previous instruction must've been `list`.
// list may not exist after the instruction
@ -814,6 +816,18 @@ export class VirtualMachine {
case OP_THREAD_STG.code:
this.start_thread(arg0);
break;
case OP_MAP_DESIGNATE.code:
this.io.map_designate(
this.get_register_signed(arg0),
this.get_register_signed(arg0 + 2),
);
break;
case OP_MAP_DESIGNATE_EX.code:
this.io.map_designate(
this.get_register_signed(arg0),
this.get_register_signed(arg0 + 3),
);
break;
case OP_GET_RANDOM.code:
{
const low = this.get_register_signed(arg0);
@ -860,7 +874,7 @@ export class VirtualMachine {
break;
case OP_BB_MAP_DESIGNATE.code:
this.io.bb_map_designate(arg0, arg1, arg2, arg3);
this.io.map_designate(arg0, arg2);
break;
default:
if (!this.unsupported_opcodes_logged.has(inst.opcode.code)) {

View File

@ -16,12 +16,7 @@ export interface VirtualMachineInput {
* The virtual machine calls these methods when it outputs something.
*/
export interface VirtualMachineOutput {
bb_map_designate(
area_id: number,
map_number: number,
area_variant_id: number,
unknown: number,
): void;
map_designate(area_id: number, area_variant_id: number): void;
set_floor_handler(area_id: number, label: number): void;
window_msg(msg: string): void;
message(msg: string): void;
@ -53,7 +48,7 @@ export interface VirtualMachineIO
VirtualMachineMetaIO {}
export class DefaultVirtualMachineIO implements VirtualMachineIO {
bb_map_designate(area_id: number, area_variant_id: number): void {
map_designate(area_id: number, area_variant_id: number): void {
logger.warn(`bb_map_designate(${area_id}, ${area_variant_id})`);
}