home *** CD-ROM | disk | FTP | other *** search
- (in-package :oou)
- (oou-provide :RO364-vd)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; RO364-vd.Lisp
- ;;
- ;; Copyright ⌐ 1990 Northwestern University Institute for the Learning Sciences
- ;; All Rights Reserved
- ;;
- ;; author: Michael S. Engber
- ;;
- ;; video digitizer object for controling RasterOps 364 video digitizer boards
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (oou-dependencies
- :+Devices
- :RO-vd
- :Records-u
- )
-
- (export '(RO364-vd RO364vd-install-332-table
- ))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
- (defclass RO364-vd (RO-vd)
- ((brightness :initarg :brightness
- :accessor brightness)
- (red-inhibit :initarg :red-inhibit
- :accessor red-inhibit)
- (green-inhibit :initarg :green-inhibit
- :accessor green-inhibit)
- (blue-inhibit :initarg :blue-inhibit
- :accessor blue-inhibit))
- (:default-initargs
- :board-id CB364-board-id
- ;default values determined empically
- :black-level #.(ash 29 10)
- :white-level #.(ash 56 10)
- :contrast #.(ash 32 10)
- :hue #.(ash 32 10)
- :saturation #.(ash 32 10)
- :brightness 32
- :red-inhibit nil
- :green-inhibit nil
- :blue-inhibit nil
- ))
-
-
- (defmethod vd-init :before ((vd RO364-vd))
- (setf (slot-value vd 'drvr-refnum) (RO364-get-drvr-refnum (card-num vd))))
-
- ;;;;;;;;;;
- ;;RO364 uses a 0-63 range for black-level,white-level,contrast,hue,saturation
- ;; ash +/- 10 converts to/from the QuickTime range (0-65535)
-
- (defmethod vd-set-black-level ((vd RO364-vd) level)
- (RO364vd-set-black-level vd (ash level -10))
- level)
-
- (defmethod vd-get-black-level ((vd RO364-vd))
- (ash (RO364vd-get-black-level vd) 10))
-
- (defmethod vd-set-white-level ((vd RO364-vd) level)
- (RO364vd-set-white-level vd (ash level -10))
- level)
-
- (defmethod vd-get-white-level ((vd RO364-vd))
- (ash (RO364vd-get-white-level vd) 10))
-
- (defmethod vd-set-contrast ((vd RO364-vd) contrast)
- (RO364vd-set-contrast vd (ash contrast -10))
- contrast)
-
- (defmethod vd-get-contrast ((vd RO364-vd))
- (ash (RO364vd-get-contrast vd) 10))
-
- (defmethod vd-set-hue ((vd RO364-vd) hue)
- (ROvd-set-hue vd (ash hue -10))
- hue)
-
- (defmethod vd-get-hue ((vd RO364-vd))
- (ash (ROvd-get-hue vd) 10))
-
- (defmethod vd-set-saturation ((vd RO364-vd) saturation)
- (ROvd-set-saturation vd (ash saturation -10))
- saturation)
-
- (defmethod vd-get-saturation ((vd RO364-vd))
- (ash (ROvd-get-saturation vd) 10))
-
- (defmethod vd-install-settings :after ((vd RO364-vd))
- (RO364vd-set-brightness vd (brightness vd))
- (RO364vd-set-red-inhibit vd (red-inhibit vd))
- (RO364vd-set-green-inhibit vd (green-inhibit vd))
- (RO364vd-set-blue-inhibit vd (blue-inhibit vd)))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;RO364 specific settings
-
- (defmethod (setf brightness) :after (brightness (vd RO364-vd))
- (when (vd-digitizing-p vd)
- (RO364vd-set-brightness vd brightness)))
-
- (defmethod (setf red-inhibit) :after (inhibit-p (vd RO364-vd))
- (when (vd-digitizing-p vd)
- (RO364vd-set-red-inhibit vd inhibit-p)))
-
- (defmethod (setf green-inhibit) :after (inhibit-p (vd RO364-vd))
- (when (vd-digitizing-p vd)
- (RO364vd-set-green-inhibit vd inhibit-p)))
-
- (defmethod (setf blue-inhibit) :after (inhibit-p (vd RO364-vd))
- (when (vd-digitizing-p vd)
- (RO364vd-set-blue-inhibit vd inhibit-p)))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; RO364 functions
-
-
- (defun RO364-get-drvr-refnum (card-num)
- ;returns the driver reference number of the specified RO364 card
- (rlet ((spb :SpBlock
- :spSlot 0
- :spID 0
- :spExtDev 0
- :spHwDev 0
- :spTBMask #x000E
- :spDrvrHW #x026F))
- (dotimes (i card-num (pref spb :SpBlock.spRefNum))
- (unless (zerop (#_SNextTypeSRsrc spb)) (return nil)))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;Control calls
-
- (defmethod RO364vd-set-contrast ((vd RO364-vd) value)
- ; value = [0-63]
- ;controls the contrast of the digitized video image
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) value))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9009 csParamPtr))))
-
-
- (defmethod RO364vd-set-black-level ((vd RO364-vd) value)
- ; value = [0-63]
- ;controls the black level of the digitized video image
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) value))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9011 csParamPtr))))
-
-
- (defmethod RO364vd-set-brightness ((vd RO364-vd) value)
- ; value = [0-63]
- ;controls the brightness of the digitized video image
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) value))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9008 csParamPtr))))
-
-
- (defmethod RO364vd-set-red-inhibit ((vd RO364-vd) inhibit-p)
- ;controls writing of the red video component
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) (if inhibit-p 1 0)))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9019 csParamPtr))))
-
-
- (defmethod RO364vd-set-green-inhibit ((vd RO364-vd) inhibit-p)
- ;controls writing the green video component
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) (if inhibit-p 1 0)))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9020 csParamPtr))))
-
-
- (defmethod RO364vd-set-blue-inhibit ((vd RO364-vd) inhibit-p)
- ;conrols writing the blue video component
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) (if inhibit-p 1 0)))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9021 csParamPtr))))
-
-
- (defmethod RO364vd-set-white-level ((vd RO364-vd) value)
- ; value = [0-63]
- ;controls the white-level of the digitized video image
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) value))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9010 csParamPtr))))
-
- (defmethod RO364vd-write-nvram ((vd RO364-vd) byte-offset byte-value)
- ; offset = [0-63], value = [0-255]
- ;write the low-order byte of byte-value into nonvolatile RAM at byte-offset
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) byte-offset
- (:csParam 1) byte-value))
- (vd-nz-error-check vd (#~Control (drvr-refnum vd) 9032 csParamPtr))))
-
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;Status calls
-
- (defmethod RO364vd-get-black-level ((vd RO364-vd))
- ;returns the black level [0-63]
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9011 csParamPtr))
- (pref csParamPtr (:ROCsParam.csParam 0))))
-
- (defmethod RO364vd-get-brightness ((vd RO364-vd))
- ;returns the brightness level [0-63]
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9008 csParamPtr))
- (pref csParamPtr (:ROCsParam.csParam 0))))
-
- (defmethod RO364vd-get-contrast ((vd RO364-vd))
- ;returns the contrast level [0-63]
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9009 csParamPtr))
- (pref csParamPtr (:ROCsParam.csParam 0))))
-
- (defmethod RO364vd-get-white-level ((vd RO364-vd))
- ;returns the white-level [0-63]
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9010 csParamPtr))
- (pref csParamPtr (:ROCsParam.csParam 0))))
-
- (defmethod RO364vd-read-NVRam ((vd RO364-vd) byte-offset)
- ;returns the byte at offset from nonvolatile RAM
- (rlet ((csParamPtr :ROCsParam
- (:csParam 0) byte-offset))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9031 csParamPtr))
- (pref csParamPtr (:ROCsParam.csParam 1))))
-
- (defmethod RO364vd-red-inhibited-p ((vd RO364-vd))
- ;returns t if the red video component is inhibited
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9019 csParamPtr))
- (= 1 (pref csParamPtr (:ROCsParam.csParam 0)))))
-
- (defmethod RO364vd-green-inhibited-p ((vd RO364-vd))
- ;returns t if the green video component is inhibited
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9020 csParamPtr))
- (= 1 (pref csParamPtr (:ROCsParam.csParam 0)))))
-
- (defmethod RO364vd-blue-inhibited-p ((vd RO364-vd))
- ;returns t if the blue video component is inhibited
- (rlet ((csParamPtr :ROCsParam))
- (vd-nz-error-check vd (#~Status (drvr-refnum vd) 9021 csParamPtr))
- (= 1 (pref csParamPtr (:ROCsParam.csParam 0)))))
-
- (defmethod RO364vd-install-332-table ((vd RO364-vd))
- (%stack-block ((ctTable (* 8 256)))
- (with-macptrs ((old-GD (#_GetGDevice)))
- (unwind-protect
- (progn
- (with-macptrs ((color-spec ctTable))
- (dotimes (i 256)
- (pset color-spec :colorSpec.value i)
- (let ((j (- 255 i)))
- (pset color-spec :colorSpec.rgb.red (* #x0101 (truncate (* 255 (logand (ash j -5) 7)) 7)))
- (pset color-spec :colorSpec.rgb.green (* #x0101 (truncate (* 255 (logand (ash j -2) 7)) 7)))
- (pset color-spec :colorSpec.rgb.blue (* #x0101 (truncate (* 255 (logand (ash j 0) 3)) 3))))
- (%incf-ptr color-spec (rlength :ColorSpec))))
- (#_SetGDevice (ROvd-get-GDevice vd))
- (#_SetEntries 0 255 ctTable))
- (#_SetGDevice old-GD)))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- #|
-
- ;; a modest example
-
- (oou-dependencies :video-digitizer-svm)
-
- (defclass vsview (video-digitizer-svm simple-view) () )
-
- (progn
- (setf *test-w*
- (make-instance 'window
- :window-type :document
- :view-position #@(10 40)
- :view-size #@(320 300)
- :window-title "video demo"
- :color-p t
- ))
- (add-subviews *test-w* (make-instance 'vsview
- :view-position #@(10 10)
- :view-size #@(300 250)
- :view-nick-name :vview
- :digitizer-class 'RO364-vd
- )))
-
- (start-digitizing (view-named :vview *test-w*))
-
- (stop-digitizing (view-named :vview *test-w*))
-
- ;; set the monitor to 8-bit and see what a dif this makes
- (let* ((v (view-named :vview *test-w*))
- (vd (digitizer-object v)))
- (RO364vd-install-332-table vd))
-
-
- |#