Skip to content

Instantly share code, notes, and snippets.

@jeaye

jeaye/gpu.clj Secret

Last active February 16, 2023 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeaye/274dfc6ffb0be4e020fcffd3bacd5f22 to your computer and use it in GitHub Desktop.
Save jeaye/274dfc6ffb0be4e020fcffd3bacd5f22 to your computer and use it in GitHub Desktop.
(defn read-8 [emu addr]
(println "gpu read at" (binary/int->hex-string addr))
(cond
(and (<= 0x8000 addr) (<= addr 0x9fff))
(.getUint8 (-> emu :gpu :vram) addr)
; TODO: Read CTRL.
(= 0xff40 addr) 0
; TODO: Read status.
(= 0xff41 addr) 0
; TODO: Read scy.
(= 0xff42 addr) 0
; TODO: Read scx.
(= 0xff43 addr) 0
; TODO: Read ly.
(= 0xff44 addr) 0
; TODO: Read lyc.
(= 0xff45 addr) 0
(= 0xff46 addr)
(throw (ex-info "Unreachable GPU read: DMA request" {:addr (binary/int->hex-string addr)}))
; TODO: Read BG palette.
(= 0xff47 addr) 0
; TODO: Read object palette 0.
(= 0xff48 addr) 0
; TODO: Read object palette 1.
(= 0xff49 addr) 0
; TODO: Read wy.
(= 0xff4a addr) 0
; TODO: Read wx.
(= 0xff4b addr) 0
; TODO: Read vram_select.
(= 0xff4f addr) 0
; TODO: Read HDMA src_high.
(= 0xff51 addr) 0
; TODO: Read HDMA src_low.
(= 0xff52 addr) 0
; TODO: Read HDMA dest_high.
(= 0xff53 addr) 0
; TODO: Read HDMA dest_low.
(= 0xff54 addr) 0
:else
(throw (ex-info "Unsupported GPU register read" {:addr (binary/int->hex-string addr)}))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment