# HG changeset patch # User Steve Losh # Date 1479558193 0 # Node ID 8b67739b3eb8d1de04ae070dd22dba9328bc4521 # Parent 8ca52e1d0bb0f252c9adcd5b0f04076edb3af430 Clean up key await functionality, add resetting diff -r 8ca52e1d0bb0 -r 8b67739b3eb8 src/emulator.lisp --- a/src/emulator.lisp Sat Nov 19 11:57:42 2016 +0000 +++ b/src/emulator.lisp Sat Nov 19 12:23:13 2016 +0000 @@ -94,8 +94,6 @@ (keys (make-simple-array 'boolean 16) :type (basic-array boolean 16) :read-only t) - (awaiting-key nil - :type (or null (integer 0 15))) (video (make-simple-array 'fixnum (* 32 64)) :type (basic-array fixnum #.(* 32 64)) :read-only t) @@ -111,7 +109,9 @@ :adjustable nil :fill-pointer 0 :element-type 'int12) - :type (stack 16)) + :type (stack 16) + :read-only t) + (loaded-rom nil :type (or null string)) (debugger (make-debugger) :type debugger :read-only t)) (define-with-macro chip @@ -122,8 +122,9 @@ delay-timer sound-timer random-state video video-dirty - keys awaiting-key + keys stack + loaded-rom debugger) (define-with-macro debugger @@ -366,11 +367,7 @@ (declaim (ftype (function (chip (integer 0 (16)))) keydown keyup)) (defun keydown (chip key) - (with-chip (chip) - (setf (aref keys key) t) - (when-let* ((waiting-for awaiting-key)) - (setf (aref registers waiting-for) key - awaiting-key nil)))) + (setf (aref (chip-keys chip) key) t)) (defun keyup (chip key) (setf (aref (chip-keys chip) key) nil)) @@ -492,7 +489,18 @@ (replace registers memory :end1 n :start2 index)) (define-opcode op-ld-reg chip chip8::chip-debugger chip8::debugger-toggle-pause)) + ((q+:qt.key_r) + (-> chip chip8::reset)) + ((q+:qt.key_f7) (-> chip chip8::chip-debugger chip8::debugger-step))