anchor.diff:    ; TODO
     )
   
  +(defun on-top (x y)
  +  ; TODO: determine sprite priority
  +  )
  +
   (defun get-visible-sprites (ppu)
     (let ((count 0)
           (result (make-array 8 :initial-element nil)))
  
positive.code:       (logior (ash 1 bit-1) bit-0))))
  
  (defun nametable-addr (x y)
    ; TODO
    )
  
  (defun pixel-opaque-p (ppu x)
    (let* ((x (+ (getf (ppu-meta ppu) :x) x))
           (y (+ (getf (ppu-meta ppu) :y) (getf (ppu-meta ppu) :scanline)))
           (base (nametable-addr (round x 8) (round y 8))) ; TODO: Use floor instead?
  
negative.code:       (7 (store-vram ppu (getf (ppu-addr ppu) :val) new-val)))))
  
  (defgeneric render-scanline (ppu)
    (:method ((ppu ppu)) ;; TODO: Mirroring. Scrolling?
      (let* ((sprites (get-visible-sprites ppu))
             (bd-index (logand (read-vram ppu #x3f00) #x3f))
             (bd-color (get-color bd-index)))
        (dotimes (x (getf *resolution* :width))
          (let* ((bg-color (when (show-bg ppu)
                             (get-bg-pixel ppu x)))
                 (sprite-color (when (show-sprites ppu)
                                 (get-sprite-pixel sprites x bg-color)))
                 (color (cond ((and bg-color sprite-color)
                               (on-top bg-color sprite-color))
                              (bg-color bg-color)
                              (sprite-color sprite-color)
                              (t bd-color))))
            (put-pixel x (getf (ppu-meta ppu) :scanline) color))))))
  
  (defgeneric start-vblank (ppu)
    (:method ((ppu ppu))
  