Skip to content

Instantly share code, notes, and snippets.

(in-package :famiclom)
;; Launch an sdl-window. After Pressing R, the inputs are polled and
;; then. displayed in the window or written to stdout.
(defvar *last-key-pressed* nil)
(defclass pad ()
((a :initform nil :accessor button-a
(in-package :famiclom)
;; Launch an sdl-window. After Pressing p, the inputs are polled and
;; then. displayed in the window or written to stdout.
(defstruct pad
(buttons (make-array 8 :element-type 'boolean :initial-element nil))
(strobe '(:a :b :select :start :up :down :left :right))
(index 0 :type fixnum)) ;; Used for strobe method
(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)
@PuercoPop
PuercoPop / profile-with-sdl-event-loop.lisp
Last active August 29, 2015 14:01
profile famiclom with sdl event loop. Most of the time spent busy-waiting.
(defun profile! (&optional (mode :time))
(reset *nes*)
(load-rom "/home/puercopop/quicklisp/local-projects/famiclom/roms/smb.nes")
(sb-sprof:with-profiling (:sample-interval 0.001
:alloc-interval 2
:max-samples 1000
:show-progress t
:report :graph
:mode :time
:reset t)
(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))
@PuercoPop
PuercoPop / First draft.lisp
Last active August 29, 2015 14:01
Fuck lispbuilder's event-loop
(in-package :famiclom)
(require 'sb-sprof)
(defun check-for-input ()
(let ((event (sdl:new-event)))
(loop
;; Pops the event-queue and binds it to event, return 0 if no pending
;; events.
:for event-poll = (sdl-cffi::SDL-Poll-event event)
(defpattern sdl-event (type key state)
`(and (sdl:event-type (type (eq ,type)))
(sdl::key-key (key (eq ,key)) ,state)))
(setf (fdefinition 'event-typep) #'sdl:key-down-p)
(sdl:with-init (sdl:sdl-init-video)
(sdl:window 256 240 :bpp 24 :sw t)
(sdl:enable-key-repeat 10 10)
(unwind-protect (let ((event (sdl:new-event)))
(setq shoes-off-config
`((:username ,(getenv "rcirc_bouncer_username")
:password ,(getenv "rcirc_bouncer_password")
:server-alist (("irc.freenode.net"
:nick "PuercoPop"
:port 6667
:user-name "PuercoPop"
:password "NinjaKittens"
:full-name "Full Name"
:channels ("#emacs" "#lisp" "#limajs" "#python.pe"))))))
#!/usr/bin/cl -Q -sp coleslaw --entry entry
;;;;
;; This script assumes it is executed from the repository's top level directory
;; to determine correctly the blog-dir variable.
;;;;
;; (coleslaw:preview #P"/home/puercopop/Projects/RunaRimac/hello-world.md")
(defun entry (argv)
(declare (ignorable argv))
(let
LISPKIT> (load-ui-from-file (asdf:system-relative-pathname :lispkit "main.ui"))
#<GTK-BUILDER {10070732D3}>
LISPKIT> (gtk:gtk-builder-get-object #<GTK-BUILDER {10070732D3}> "webviewcontainer" )
NIL
LISPKIT> (gtk:gtk-builder-get-object #<GTK-BUILDER {10070732D3}> "mainwindow" )
NIL
LISPKIT> (asdf:system-relative-pathname :lispkit "main.ui")
#P"/home/puercopop/quicklisp/local-projects/lispkit/main.ui"
LISPKIT> (gtk:gtk-builder-get-object #<GTK-BUILDER {10070732D3}> "scrolledwindow" )
NIL