UNPKG

nes-emu

Version:

A NES emulator

43 lines (37 loc) 884 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; /** A CPU register that can handle overflows and underflows. */ class Register { constructor(TypedArray) { let initialValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; this.bytes = new TypedArray(1); this.value = this.initialValue = initialValue; } /** Resets the `value` to the `initialValue`. */ reset() { this.value = this.initialValue; } /** Increments the value. */ increment() { this.value++; } /** Decrements the value. */ decrement() { this.value--; } /** Returns the actual value. */ get value() { return this.bytes[0]; } /** Sets the actual value. */ set value(value) { this.bytes[0] = value; } toString() { return "[REGISTER]"; } } exports.default = Register;