nes-emu
Version:
A NES emulator
26 lines (24 loc) • 877 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _registers = require("../../registers");
var _constants = require("../constants");
/** Sets the high 3 bits of a Pulse channel's timer and its length counter. */
class PulseLCLTimerHigh extends _registers.WriteOnlyInMemoryRegister {
constructor(id) {
super();
this.id = id;
this.addReadOnlyField("timerHigh", 0, 3).addReadOnlyField("lengthCounterLoad", 3, 5);
}
/** Updates timer value, length counter, and volume envelope's start flag. */
writeAt(__, byte) {
this.setValue(byte);
const channel = this.context.apu.channels.pulses[this.id];
channel.updateTimer();
channel.lengthCounter.counter = _constants.lengthTable[this.lengthCounterLoad];
channel.volumeEnvelope.startFlag = true;
}
}
exports.default = PulseLCLTimerHigh;