nes-emu
Version:
A NES emulator
43 lines (37 loc) • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _registers = require("../../registers");
/**
* PPU Status Register (< read)
*
* Reflects the state of various functions inside the PPU.
* It is often used for determining timing.
*/
class PPUStatus extends _registers.InMemoryRegister {
constructor() {
super();
this.addField("spriteOverflow", 5).addField("sprite0Hit", 6).addField("isInVBlankInterval", 7);
}
/** When a context is loaded. */
onLoad() {
this.setValue(0b10000000);
}
/** Reads the status flags, with some side effects. */
readAt() {
const value = this.value;
// this has two side effects:
if (!this.context.isDebugging) {
// - it resets the vertical blank flag
this.isInVBlankInterval = 0;
// - it resets the write latch
this.context.ppu.loopy.onPPUStatusRead();
}
return value;
}
/** Writes nothing (read-only address). */
writeAt() {}
}
exports.default = PPUStatus;