

(setf *windows02*

'(

(%print *reserve-space-1*)

(%print 50)

(%print (%+ 100 23))

(setq aaq 100)
(setq bbq 23)

(setq ccq (%+ bbq bbq))

(%print ccq)

(defun test (x y) (%+ x y))

(%print (test ccq ccq))

(defun update-getpt (getpt)
  (set-word 100 0 (next-i getpt 31)))

(defun main ()
  (main-init)
  (qprint sout "main-init done.")
  (setq *i* 0)
  (reset-peek-pt)
  (qprint sout "reset done.")
  (do () 
      (nil)
;    (print-hex 5380 (setq *i* (%+ *i* 1)))
    (let ((ch -1))
      (setf ch (peek-ch))
      (print-hex 5396 ch)
      (if (%/= ch -1)
          (progn
            (process-key-event ch)
            (set-peek-pt)))
      (if (new-event-ready)
          (main-dispatch)))))

;;;; (defun main ()
;;;;   (main-init)
;;;;   (setq *i* 0)
;;;;   (do-until (nil)
;;;; ;            (print-hex 5360 (setq *i* (%+ *i* 1)))
;;;;             (let ((getpt (get-word 100 0))
;;;;                   (insertpt (get-word 100 4)))
;;;;               (if (%/= getpt insertpt)
;;;;                   (main-dispatch getpt)))))

(%print 51)

(defun main-init ()
  (setf *edit-win* (make-window))
  (init-win *edit-win*))

(%print 52)

(defun main-dispatch ()
  (let ((ch (new-char))
        (modif (new-modifier))
        (ev nil))
 
    (print-hex 5320 modif)
    (print-hex 5360 ch)

    (print-hex 5380 (setq *i* (%+ *i* 1)))


;    (print-hex 5375 VK_D_ARROW)
;    (print-hex 5390 VK_PG_DN)

;    (%print 22222)
;    (%print (vk-p ch VK_D_ARROW))
;    (%print (vk-p ch VK_PG_DN))
;    (%print ch)

;    (print-hex 5187 (addr-and VK_D_ARROW ch))
;    (print-hex 5207 (addr-and VK_PG_DN ch))

    (setf *inst0* (get-info 0))


    (if (%= (addr-and modif 16) 0)
        (if (vk-p ch VK_F1)
            (progn
              (disable-irq) 
              (collect-garbage) 
              (enable-irq) 
;              (%print 1111)
;              (%print (test 100 200))
              (setf ch 255))
          (if (vk-p ch VK_F2)
              (progn
                (qprint sout "vn.")
                (setf ch 255)))))


    (if (%= (addr-and ch 256) 0)
        (progn
          (setq ch (addr-and ch 255))
          (if (%> ch 127)
              (setf ch nil)))
      (cond ((vk-p ch VK_U_ARROW) (setq ch ':up))
            ((vk-p ch VK_D_ARROW) (setq ch ':down))
            ((vk-p ch VK_L_ARROW) (setq ch ':left))
            ((vk-p ch VK_R_ARROW) (setq ch ':right))
            ((vk-p ch VK_HOME) (setq ch ':home))
            ((vk-p ch VK_END) (setq ch ':end))
            ((vk-p ch VK_PG_UP) (setq ch ':prior))
            ((vk-p ch VK_PG_DN) (setq ch ':next))
            ((vk-p ch VK_ENTER) (setq ch 13))
            ((vk-p ch VK_BKSP) (setq ch 8))
            ((vk-p ch VK_DELETE) (setq ch 127))
            (t (setf ch nil))))







 
    (setf ev (addr-and modif 16)) ;; setcode is 16

    (if ch (callback-edit-window *edit-win* ev ch modif))


    (setf *inst1* (get-info 0))
    (%print 22222)
    (%print (%- *inst1* *inst0*))  ;; instruction count

))

;    (update-getpt getpt)))

(%print 53)

(defconstant +upper-mask+ -16384)

(%print 54)

(defun vk-p (ch mask)
  (addr-eq mask (addr-and +upper-mask+ ch)))

(%print 100)

(funcall sout #\A)

(%print 1212)
(%print (p-shiftl 111 2))

(funcall sout #\W)
 

(qprint sout "juergen")
(qprint sout "und vn")

(main)))

