Skip to content

Instantly share code, notes, and snippets.

@PuercoPop
Created May 17, 2014 02:02
Show Gist options
  • Save PuercoPop/bc4e22727fffeb5b8ba8 to your computer and use it in GitHub Desktop.
Save PuercoPop/bc4e22727fffeb5b8ba8 to your computer and use it in GitHub Desktop.
(in-package :famiclom)
(defun get-byte-input% (addr)
(declare (ignore addr))
(format t "Reading button ~A: ~A~%" (first (pad-strobe *pad*)) (get-state *pad*))
(prog1 (get-state *pad*)
(next-state *pad*)))
(let ((last-input 0))
(defun (setf get-byte-input%) (new-val addr)
(declare (ignore addr))
(format t "Writing to $4016~%")
(prog1
(when (and (eql 0 new-val)
(eql 1 last-input))
(reset-strobe *pad*)
(format t "Reset strobe~%"))
(setf last-input new-val))))
(defun play-rom-debug (file)
(defparameter *counter* 0)
(reset *nes*)
(load-rom file)
(sdl:with-init (sdl:sdl-init-video sdl:sdl-init-audio)
(sdl:window 256 240 :bpp 24 :sw t)
(sdl:enable-key-repeat 10 10)
(sdl:with-events (:poll)
(:quit-event () t)
(:key-down-event
(:key key-pressed)
(set-key key-pressed *pad* 1))
(:key-up-event
(:key key-pressed)
(set-key key-pressed *pad* 0))
(:idle ()
(step-nes 1000)
;; (format t "Buttons: ~A~%" (pad-buttons *pad*))
(format t "Idle cycle #~A~%" (incf *counter*))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment