d18676cbb4f2

Open the debugger when running the main UI
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Fri, 18 Nov 2016 15:06:50 +0000
parents cf5f62fff15b
children 15e3dd889f0b
branches/tags (none)
files src/debugger.lisp src/gui.lisp

Changes

--- a/src/debugger.lisp	Fri Nov 18 14:58:05 2016 +0000
+++ b/src/debugger.lisp	Fri Nov 18 15:06:50 2016 +0000
@@ -166,12 +166,15 @@
     (q+:add-layout layout stack)))
 
 
-(defun run (chip)
+(defun make-debugger (chip)
   (let ((model-disassembly (make-instance 'disassembly-model :chip chip))
         (model-stack (make-instance 'stack-model :chip chip)))
-    (with-main-window (window (make-instance 'debugger
-                                :model-disassembly model-disassembly
-                                :model-stack model-stack)))))
+    (make-instance 'debugger
+      :model-disassembly model-disassembly
+      :model-stack model-stack)))
+
+(defun run (chip)
+  (with-main-window (window (make-debugger chip))))
 
 
 (defparameter *c* (chip8::make-chip))
--- a/src/gui.lisp	Fri Nov 18 14:58:05 2016 +0000
+++ b/src/gui.lisp	Fri Nov 18 15:06:50 2016 +0000
@@ -34,15 +34,25 @@
 ;;;; Screen -------------------------------------------------------------------
 (define-widget screen (QGLWidget)
   ((texture :accessor screen-texture)
+   (debugger :accessor screen-debugger :initarg :debugger)
    (chip :accessor screen-chip :initarg :chip)))
 
+(defun make-screen (chip)
+  (let ((debugger (chip8.debugger::make-debugger chip)))
+    (make-instance 'screen
+      :debugger debugger
+      :chip chip)))
+
+
 (defun die (screen)
   (setf chip8::*running* nil)
+  (q+:close (screen-debugger screen))
   (q+:close screen))
 
 (define-initializer (screen setup)
   (setf (q+:window-title screen) "cl-chip8"
-        (q+:fixed-size screen) (values *width* *height*)))
+        (q+:fixed-size screen) (values *width* *height*))
+  (q+:show debugger))
 
 (define-override (screen "initializeGL") ()
   (setf (screen-texture screen) (initialize-texture 64))
@@ -172,6 +182,6 @@
 ;;;; Main ---------------------------------------------------------------------
 (defun run-gui (chip)
   (with-main-window
-    (window (make-instance 'screen :chip chip))))
+    (window (make-screen chip))))