chipgr8-archive/sdl.lisp
Juhani Krekelä faea86bc8c First commit
Status of the project as it was on 2025-03-07. The commit date is based
on the modification time of the files.
2025-03-07 23:56:06 +02:00

25 lines
753 B
Common Lisp

(in-package :chipgr8)
; 10x10px for one CHIP-8 pixel
(defparameter +pixel-width+ 10)
(defparameter +pixel-height+ 10)
(defun update-display ()
(dotimes (y 32)
(dotimes (x 64)
(sdl:draw-box-* (* x +pixel-width+) (* y +pixel-height+) +pixel-width+ +pixel-height+
:color (if (aref *framebuffer* y x) sdl:*white* sdl:*black*))))
(sdl:update-display))
(defun graphics-mainloop ()
(sdl:with-init ()
(sdl:window (* 64 +pixel-width+) (* 32 +pixel-height+)
:title-caption "Chipgr8"
:fps (make-instance 'sdl:fps-timestep :dt 1/6000)) ; Lock simulation to constant "clock speed", 6MHz
(sdl:with-events ()
(:quit-event () t)
(:video-expose-event () (sdl:update-display))
(:idle
(sdl:with-timestep ()
(emulator-step))))))