Last active
August 29, 2015 14:01
-
-
Save PuercoPop/8bd65a5fcd599b12c49c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun play-rom (file) | |
(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 "~A~%" (pad-buttons *pad*)) | |
(format t "~A~%" (incf *counter*)))))) | |
(defun step-nes (times) | |
(with-accessors ((cpu nes-cpu) | |
(ppu nes-ppu)) *nes* | |
(dotimes (s times) | |
(let ((c-step (step-cpu cpu (get-byte (6502:cpu-pc cpu)))) | |
(p-step (ppu-step ppu (6502:cpu-cc cpu)))) | |
(when (ppu-result-vblank p-step) | |
(6502:nmi cpu)) | |
(when (ppu-result-new-frame p-step) | |
(sdl:update-display)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment