;;; -*- Mode:Common-Lisp; Package:MACTOOLBOX; Base:10; Fonts:(CPTFONT HL10B HL12I CPTFONT CPTFONTB); Patch-File:t -*-

;;;			    RESTRICTED RIGHTS LEGEND
;;; Use, duplication, or disclosure by the Government is subject to restrictions as
;;; set forth in subdivision (c)(1)(ii) of the Rights in Technical Data and 
;;; Computer Software clause at 52.227-7013.
;;; 	 TEXAS INSTRUMENTS INCORPORATED, P.O. BOX 2909, AUSTIN, TEXAS 78769
;;;      Copyright (C) 1989 Texas Instruments Incorporated.  All rights reserved.


;Ï1;; Loading this patch file redefines a number of trap functions as inline functions which are much fasterÏ*
;Ï1;; than the original versions.Ï*

;Ï1;; All Macintosh Toolbox traps nominally execute in the Macintosh OS.  However, a few of these definedÏ*
;Ï1;; traps are trivial (e.g., ANDing to integers) and are therefore independent of any hardware or OS.  Also,Ï*
;Ï1;; a few of the non-trivial ones use and modify only application-specific data structures--data structuresÏ*
;Ï1;; which are not need on the Macintosh side for anything else.  Therefore, these data structures mightÏ*
;Ï1;; just as well reside on the microExplorer side.Ï*
;Ï1;;Ï*
;Ï1;; The traps which uses these microExplorer-side data strucutres still execute on the Macintosh side soÏ*
;Ï1;; that the execution sequence looks something like this starting with a call to the trap:Ï*
;Ï1;;Ï*
;Ï1;;Ï*	Ï1*  Tear the microExplorer data strucuture down into it components and individually stuff themÏ*
;Ï1;;                  into a microNet packet along with other arguments.Ï*
;Ï1;;Ï*	Ï1*  Relay that packet to the Macintosh side.Ï*
;Ï1;;Ï*	Ï1*  Reassemble the individual packet contents into a suitable Macintosh data structure.Ï*
;Ï1;;Ï*	Ï1*  Call the Macintosh trap who merely modifies this data structure often does little more thanÏ*
;Ï1;;                 stuff some of the other arguments that came in the packet into the structure.Ï*
;Ï1;;Ï*	Ï1*  Tear the modified Macintosh structure down into its components and individually stuff themÏ*
;Ï1;;                  into a microNet package for the return trip.Ï*
;Ï1;;Ï*	Ï1*  Relay that return packet back to the microExplorer side.Ï*
;Ï1;;Ï*	Ï1*  Reassemble the individual return packet contents into a newly consed microExplorer dataÏ*
;Ï1;;                 structure.Ï*
;Ï1;;Ï*
;Ï1;; The functions in this file offer a better way.Ï*


;Ï1;;; Ï4POINTÏ*sÏ*
(proclaim '(inline !AddPt))
(defun Ï4!AddPt Ï*(Ï3srcPointÏ* Ï3dstPointÏ*)
  (declare (arglist |Ï3srcPoint|Ï* |Ï3dstPoint|Ï*))
  (send Ï3dstPointÏ* :add Ï3srcPointÏ*))
(remprop '!AddPt 'compiler:style-checker)

(proclaim '(inline !EqualPt))
(defun Ï4!EqualPt Ï*(Ï3ptAÏ* Ï3ptBÏ*)
  (declare (arglist |Ï3ptA|Ï* |Ï3ptB|Ï*))
  (send Ï3ptAÏ* :equal Ï3ptBÏ*))
(remprop '!EqualPt 'compiler:style-checker)

(proclaim '(inline !MapPt))
(defun Ï4!MapPt Ï*(point srcRect dstRect)
  (declare (arglist |pointÏ3|Ï* |srcRectÏ3|Ï* |dstRectÏ3|Ï*))
  (send point :map srcRect dstRect))
(remprop '!MapPt 'compiler:style-checker)

(proclaim '(inline !ScalePt))
(defun Ï4!ScalePt Ï*(point srcRect dstRect)
  (declare (arglist |pointÏ3|Ï* |srcRectÏ3|Ï* |dstRectÏ3|Ï*))
  (send point :scale srcRect dstRect))
(remprop '!ScalePt 'compiler:style-checker)

(proclaim '(inline !SetPt))
(defun Ï4!SetPt Ï*(Ï3pointÏ* Ï3hÏ* Ï3vÏ*)
  (declare (arglist |Ï3point|Ï* |Ï3h|Ï* |Ï3v|Ï*))
  (send Ï3pointÏ* :set Ï3hÏ* Ï3vÏ*))
(remprop '!SetPt 'compiler:style-checker)

(proclaim '(inline !SubPt))
(defun Ï4!SubPt Ï*(Ï3srcPointÏ* Ï3dstPointÏ*)
  (declare (arglist |Ï3srcPoint|Ï* |Ï3dstPoint|Ï*))
  (send Ï3dstPointÏ* :sub Ï3srcPointÏ*))
(remprop '!SubPt 'compiler:style-checker)


;Ï1;;; Ï4RECTÏ*sÏ*
(proclaim '(inline !EmptyRect))
(defun Ï4!EmptyRect Ï*(rect)
  (declare (arglist |Ï3rect|Ï*))
  (send rect :empty-p))
(remprop '!EmptyRect 'compiler:style-checker)

(proclaim '(inline !EqualRect))
(defun Ï4!EqualRect Ï*(rectA rectB)
  (declare (arglist |Ï3rectA|Ï* |Ï3rectB|Ï*))
  (send rectA :equal rectB))
(remprop '!EqualRect 'compiler:style-checker)

(proclaim '(inline !InsetRect))
(defun Ï4!InsetRect Ï*(rect dh dv)
  (declare (arglist |Ï3rect|Ï* |Ï3dh|Ï* |Ï3dv|Ï*))
  (send rect :inset dh dv))
(remprop '!InsetRect 'compiler:style-checker)

(proclaim '(inline !MapRect))
(defun Ï4!MapRect Ï*(resultRect srcRect dstRect)
  (declare (arglist |Ï3resultRect|Ï* |srcRectÏ3|Ï* |dstRectÏ3|Ï*))
  (send resultRect :map srcRect dstRect))
(remprop '!MapRect 'compiler:style-checker)

(proclaim '(inline !OffsetRect))
(defun Ï4!OffsetRect Ï*(rect dh dv)
  (declare (arglist |Ï3rect|Ï* |Ï3dh|Ï* |Ï3dv|Ï*))
  (send rect :offset dh dv))
(remprop '!OffsetRect 'compiler:style-checker)

(proclaim '(inline !PtInRect))
(defun Ï4!PtInRect Ï*(point rect)
  (declare (arglist |Ï3point|Ï* |Ï3rect|Ï*))
  (send rect :inside-p point))
(remprop '!PtInRect 'compiler:style-checker)

(proclaim '(inline !Pt2Rect))
(defun Ï4!Pt2Rect Ï*(ptA ptB rect)
  (declare (arglist |Ï3ptA|Ï* |Ï3ptB|Ï* |Ï3rect|Ï*))
  (send rect :set ptA ptB))
(remprop '!Pt2Rect 'compiler:style-checker)
  
(proclaim '(inline !SetRect))
(defun Ï4!SetRect Ï*(rect left top right bottom)
  (declare (arglist |rectÏ3|Ï* |leftÏ3|Ï* |topÏ3|Ï* |rightÏ3|Ï* |bottomÏ3|Ï*))
  (send rect :set top left bottom right))
(remprop '!SetRect 'compiler:style-checker)



;Ï1;;; Ï4BIT FunctionsÏ*Ï*
(proclaim '(inline !BitAnd))
(defun Ï4!BitAnd Ï*(value1 value2)
  (declare (arglist |Ï3value1|Ï* |Ï3value2|Ï*))
  (logand value1 value2 #xFFFFFFFF))
(remprop '!BitAnd 'compiler:style-checker)

(proclaim '(inline !BitOr))
(defun Ï4!BitOr Ï*(value1 value2)
  (declare (arglist |Ï3value1|Ï* |Ï3value2|Ï*))
  (logand #xFFFFFFFF (logior value1 value2)))
(remprop '!BitOr 'compiler:style-checker)

(proclaim '(inline !BitXor))
(defun Ï4!BitXor Ï*(value1 value2)
  (declare (arglist |Ï3value1|Ï* |Ï3value2|Ï*))
  (logand #xFFFFFFFF (logxor value1 value2)))
(remprop '!BitXor 'compiler:style-checker)

(proclaim '(inline !BitNot))
(defun Ï4!BitNot Ï*(value)
  (declare (arglist |Ï3value|Ï*))
  (logand #xFFFFFFFF (lognot value)))
(remprop '!BitNot 'compiler:style-checker)

(proclaim '(inline !BitShift))
(defun Ï4!BitShift Ï*(value count)
  (declare (arglist |Ï3value|Ï* |Ï3count|Ï*))
  (logand #xFFFFFFFF (ash (logand #xFFFFFFFF value) count)))
(remprop '!BitShift 'compiler:style-checker)