anchor.diff:  (in-package :famiclom)
   
  -;;;; TODO: Understand the magic of PPUs.
  +;;;; TODO: Understand the magic of PPUs. A nightmare of state.
   
   (defvar *resolution* '(:width 256 :height 240) "NES output resolution.")
   
  
positive.code:       (4 (store-oam ppu new-val))
        (5 (update-scroll ppu new-val))
        (6 (update-addr ppu new-val))
        (7 'vram-store))))
  
  (defgeneric ppu-step (ppu to-cycle))
  
negative.code:         ((< addr #x4000) (let ((addr (logand addr #x1f)))
                             (when (= addr #x10) (setf addr #x00))
                             (setf (aref (ppu-palette ppu) addr) val)))
          (t (error "WRITE: invalid vram address ~a" addr)))
    (incf (getf (ppu-addr ppu) :val) (incf-vram-addr ppu)))
  
  (defmethod store-oam ((ppu ppu) val)
    (with-accessors ((addr ppu-oam-addr)) ppu
      (setf (aref (ppu-oam ppu) addr) val)
      (incf addr)))
  
  (defun buffered-read (ppu)
    (let ((result (read-vram ppu (getf (ppu-addr ppu) :val))))
      (incf (getf (ppu-addr ppu) :val) (incf-vram-addr ppu))
      (if (< addr #x3f00)
          (prog1
              (getf (ppu-meta ppu) :buffer)
            (setf (getf (ppu-meta ppu) :buffer) result))
          result)))
  
  ;;;; Misc Helpers
  
  