May need to brew install libsdl2-dev
brew install sbcl # or apt-get if you nasty playa
curl -O https://beta.quicklisp.org/quicklisp.lisp > quicklisp.lisp
sbcl --load quicklisp.lisp # and follow the prompts
git clone [email protected]:kingcons/clones.git ~/quicklisp/local-projects/clones.git
Start rlwrap sbcl
and ...
(ql:quickload :clones)
(in-package :clones)
(change-game "roms/commercial/dk.nes") ;; this path is relative to the clones installation folder/git checkout
(step-frames 4)
Make sure to do this on the mezzanine branch...
(ql:quickload :cl-json)
(defvar *nt* (clones.ppu::ppu-nametable (memory-ppu (cpu-memory *nes*))))
(cl-json:encode-json *nt*)
Make sure to brew install libpng
first and use my fork of cl-png...
git clone [email protected]:kingcons/cl-png.git ~/quicklisp/local-projects/cl-png
Then ...
(ql:quickload '(:zpng :clones))
(in-package :clones)
(change-game "roms/commercial/smb.nes")
(step-frames 30)
(defvar *image* (make-instance 'zpng:pixel-streamed-png :color-type :truecolor :width 256 :height 240))
(with-open-file (out "test.png" :element-type '(unsigned-byte 8) :direction :output
:if-does-not-exist :create :if-exists :supersede)
(zpng:start-png *image* out)
(dotimes (i (* 256 240))
(let ((pixel (list (aref clones.ppu:*framebuffer* (+ (* i 3) 0))
(aref clones.ppu:*framebuffer* (+ (* i 3) 1))
(aref clones.ppu:*framebuffer* (+ (* i 3) 2)))))
(zpng:write-pixel pixel *image*)))
(zpng:finish-png *image*))
Did some performance investigation. On the epidernes side, main performance improvement is likely not updating Disassembly/NES component unless the render loop is s topped. If things are still choppy after that, we should manually run an effect that updates the canvas rather than going through state management. Frames are heavy!
On the rawbones side, dropping sprite handling killed over 50% of our runtime! We can definitely optimize better than we're currently doing.
find_sprite
seems to be the main culprit. We can probably trade a one time Array allocation in the context for 256 ints, each one representing the pixel of a sprite on the scanline. Then, every scanline we could clear the array, loop over the sprite candidates, and render them into it all in one go. We'd just have to modify pixel priority to pull pixels from the context.More importantly, we've got some palette issues that still need to be fixed (visible in DK, ex: 68,43 should have same color as 66,51 and 90,50 should match 100,50; visible in SMB, ex: 35,200 should be same color as 30,200) and there's still some incorrect scrolling behavior that could be caused by periodic resets to CoarseX(0)/CoarseY(0). Could be something else but merits further investigation.