mirror of
https://github.com/DaanVandenBosch/phantasmal-world.git
synced 2025-04-05 15:28:29 +08:00
[VM] Implemented gettime opcode.
This commit is contained in:
parent
260c070f34
commit
c726cd3461
@ -80,6 +80,7 @@ import {
|
|||||||
OP_FLET,
|
OP_FLET,
|
||||||
OP_FLETI,
|
OP_FLETI,
|
||||||
OP_GET_RANDOM,
|
OP_GET_RANDOM,
|
||||||
|
OP_GETTIME,
|
||||||
} from "../opcodes";
|
} from "../opcodes";
|
||||||
import { VirtualMachineMemoryBuffer, VirtualMachineMemory } from "./memory";
|
import { VirtualMachineMemoryBuffer, VirtualMachineMemory } from "./memory";
|
||||||
import {
|
import {
|
||||||
@ -103,7 +104,7 @@ const ARG_STACK_SLOT_SIZE = 4;
|
|||||||
const ARG_STACK_LENGTH = 8;
|
const ARG_STACK_LENGTH = 8;
|
||||||
const STRING_ARG_STORE_ADDRESS = 0x00a92700;
|
const STRING_ARG_STORE_ADDRESS = 0x00a92700;
|
||||||
const STRING_ARG_STORE_SIZE = 1024; // TODO: verify this value
|
const STRING_ARG_STORE_SIZE = 1024; // TODO: verify this value
|
||||||
const FLOAT_EPSILON = 1.19e-07;
|
const FLOAT_EPSILON = 1.19e-7;
|
||||||
|
|
||||||
export enum ExecutionResult {
|
export enum ExecutionResult {
|
||||||
Ok,
|
Ok,
|
||||||
@ -545,6 +546,9 @@ export class VirtualMachine {
|
|||||||
this.io.add_msg(str);
|
this.io.add_msg(str);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case OP_GETTIME.code:
|
||||||
|
this.set_register_unsigned(arg0, Math.floor(Date.now() / 1000));
|
||||||
|
break;
|
||||||
case OP_WINEND.code:
|
case OP_WINEND.code:
|
||||||
if (this.window_msg_open) {
|
if (this.window_msg_open) {
|
||||||
this.window_msg_open = false;
|
this.window_msg_open = false;
|
||||||
@ -639,13 +643,13 @@ export class VirtualMachine {
|
|||||||
private set_register_word(reg: number, value: number): void {
|
private set_register_word(reg: number, value: number): void {
|
||||||
this.registers.write_u16_at(REGISTER_SIZE * reg, value);
|
this.registers.write_u16_at(REGISTER_SIZE * reg, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get_register_byte(reg: number): number {
|
public get_register_byte(reg: number): number {
|
||||||
return this.registers.u8_at(REGISTER_SIZE * reg);
|
return this.registers.u8_at(REGISTER_SIZE * reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public set_register_byte(reg: number, value: number): void {
|
public set_register_byte(reg: number, value: number): void {
|
||||||
this.registers.write_u8_at(REGISTER_SIZE * reg, value)
|
this.registers.write_u8_at(REGISTER_SIZE * reg, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get_register_float(reg: number): number {
|
public get_register_float(reg: number): number {
|
||||||
|
Loading…
Reference in New Issue
Block a user