UNPKG

nes-emu

Version:

A NES emulator

29 lines (28 loc) 927 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _helpers = require("../../helpers"); var _getValue = _interopRequireDefault(require("./_getValue")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } /** * "Relative" addressing mode. * * The parameter is a signed relative offset from the following instruction. */ var _default = exports.default = { id: "RELATIVE", parameterSize: 1, getAddress: (_ref, offset, canTakeExtraCycles) => { let { cpu } = _ref; const address = cpu.pc.value; const newAddress = address + _helpers.Byte.toNumber(offset); const pageCrossed = _helpers.Byte.highPartOf(address) !== _helpers.Byte.highPartOf(newAddress); if (pageCrossed && canTakeExtraCycles) cpu.extraCycles += 2; return _helpers.Byte.force16Bit(newAddress); }, getValue: _getValue.default };