quephird / happiNESs

An attempt at an NES emulator written in Swift
5 stars 0 forks source link

Cache all the things #38

Closed quephird closed 1 month ago

quephird commented 1 month ago

This PR is another step forward towards properly emulating the NES, specifically that we ultimately want to be able to cache multiple pieces of data during the rendering phase and compute color values based on them, versus computing colors dependent on the live values of multiple pieces of state. There are several motivations for this:

This set of changes is modeled largely on relevant portions of implementations in two codebases, https://github.com/robb/NES.swift and https://github.com/fogleman/nes. The main things are:

NOTA BENE: It should be made clear up front that up until this PR, a good deal of the design of this emulator was based on the tutorial that I had originally started following, https://bugzmanov.github.io/nes_ebook/. However, this codebase has been significantly veering away from that design with the last several PRs, and I think I've reached the point where the modeling of PPU registers needs to be revisited. However, in the interest of preserving current behavior and minimizing regressions, I am taking an iterative approach, slowing introducing new (and hopefully improved) code while keeping as much of the old code as possible to be able to play games as I have been able to previously.