
   IFND  INTUITION_INTUITION_I
INTUITION_INTUITION_I   SET   1

;** intuition.i *************************************************************
;*  Commodore-Amiga, Inc.
;*
;*  intuition.i main include file for assembly-language programmers
;*
;*          Modification History
;*      date    :   author :    Comments
;*     ------       ------      -------------------------------------
;*     1-30-85     -=RJ=-  created this file!
;*     6-12-85      Dale and Carl translated this from the c version
;*     6-13-85      =VoodooDrRj= added back the comments
;*
;****************************************************************************/

   IFND  GRAPHICS_GFX_I
   include  'graphics/gfx.i'
   ENDC

   IFND  GRAPHICS_CLIP_I
   include  'graphics/clip.i'
   ENDC

   IFND  GRAPHICS_VIEW_I
   include  'graphics/view.i'
   ENDC

   IFND  GRAPHICS_RASTPORT_I
   include  'graphics/rastport.i'
   ENDC

   IFND  GRAPHICS_LAYERS_I
   include  'graphics/layers.i'
   ENDC

   IFND  GRAPHICS_TEXT_I
   include 'graphics/text.i'
   ENDC

   IFND EXEC_PORTS_I
   include 'exec/ports.i'
   ENDC

   IFND  DEVICES_TIMER_I
   include  'devices/timer.i'
   ENDC

   IFND  DEVICES_INPUTEVENT_I
   include 'devices/inputevent.i'
   ENDC


; ========================================================================;
; === Menu ===============================================================;
; ========================================================================;
 STRUCTURE Menu,0

    APTR  mu_NextMenu   ; menu pointer, same level
    WORD mu_LeftEdge    ; dimensions of the select box;
    WORD mu_TopEdge  ; dimensions of the select box;
    WORD mu_Width ; dimensions of the select box;
    WORD mu_Height   ; dimensions of the select box;
    WORD mu_Flags ; see flag definitions below;
    APTR mu_MenuName ; text for this Menu header
    APTR  mu_FirstItem  ; pointer to first in chain;

    ; these mysteriously-named variables are for internal use only
    WORD mu_JazzX
    WORD mu_JazzY
    WORD mu_BeatX
    WORD mu_BeatY

    LABEL mu_SIZEOF

; FLAGS SET BY BOTH THE APPLIPROG AND INTUITION
MENUENABLED equ $0001   ; whether or not this menu is enabled;

; FLAGS SET BY INTUITION;
MIDRAWN equ $0100 ; this menu's items are currently drawn;





; ========================================================================;
; === MenuItem ===========================================================;
; ========================================================================;
 STRUCTURE MenuItem,0

    APTR mi_NextItem ; pointer to next in chained list
    WORD mi_LeftEdge ; dimensions of the select box
    WORD mi_TopEdge  ; dimensions of the select box
    WORD mi_Width ; dimensions of the select box
    WORD mi_Height   ; dimensions of the select box
    WORD mi_Flags ; see the defines below

    LONG mi_MutualExclude ; set bits mean this item excludes that item

    APTR mi_ItemFill ; points to Image, IntuiText, or NULL

    ; when this item is pointed to by the cursor and the items highlight
    ; mode HIGHIMAGE is selected, this alternate image will be displayed
    APTR mi_SelectFill  ; points to Image, IntuiText, or NULL

    BYTE mi_Command  ; only if appliprog sets the COMMSEQ flag

    ; The following variable is strictly from Kludge-City, where some people
    ; still live.  It is included solely because our types.i macros aren't
    ; smart enough to do the right thing, which would be the automatic 
    ; word-alignment to these references as it SHOULD be in order to duplicate
    ; the way alignments are adjusted in the c-language.  And instead of 
    ; correcting the problem, I am obliged to kludge up my include.i files.
    ; So here it is!
    BYTE mi_KludgeFill00 ; defined as a BYTE because this does

    APTR mi_SubItem  ; if non-zero, DrawMenu shows "->"

   ; The NextSelect field represents the menu number of next selected 
   ; item (when user has drag-selected several items)
    WORD mi_NextSelect

    LABEL  mi_SIZEOF

; --- FLAGS SET BY THE APPLIPROG --------------------------------------------
CHECKIT     equ $0001   ; whether to check this item if selected
ITEMTEXT equ $0002   ; set if textual, clear if graphical item
COMMSEQ     equ $0004   ; set if there's an command sequence
MENUTOGGLE  equ $0008   ; set to toggle the check of a menu item 
ITEMENABLED equ $0010   ; set if this item is enabled

; these are the SPECIAL HIGHLIGHT FLAG state meanings 
HIGHFLAGS   equ $00C0   ; see definitions below for these bits
HIGHIMAGE   equ $0000   ; use the user's "select image"
HIGHCOMP equ $0040   ; highlight by complementing the select box
HIGHBOX     equ $0080   ; highlight by drawing a box around the image
HIGHNONE equ $00C0   ; don't highlight

; --- FLAGS SET BY BOTH APPLIPROG AND INTUITION -----------------------------
CHECKED equ $0100    ; if CHECKIT, then set this when selected


; --- FLAGS SET BY INTUITION ------------------------------------------------
ISDRAWN     equ $1000   ; this item's subs are currently drawn
HIGHITEM equ $2000   ; this item is currently highlighted
MENUTOGGLED equ $4000   ; this item was already toggled 






; ========================================================================
; === Requester ==========================================================
; ========================================================================
 STRUCTURE Requester,0

    ; the ClipRect and BitMap and used for rendering the requester
    APTR  rq_OlderRequest
    WORD rq_LeftEdge    ; dimensions of the entire box
    WORD rq_TopEdge     ; dimensions of the entire box
    WORD rq_Width    ; dimensions of the entire box
    WORD rq_Height      ; dimensions of the entire box

    WORD rq_RelLeft     ; get POINTREL Pointer relativity offsets
    WORD rq_RelTop      ; get POINTREL Pointer relativity offsets

    APTR  rq_ReqGadget        ; pointer to the first of a list of gadgets
    APTR  rq_ReqBorder     ; the box's border
    APTR  rq_ReqText    ; the box's text

    USHORT rq_Flags     ; see definitions below

    UBYTE rq_BackFill      ; pen number for back-plane fill before draws

    ; The following variable is strictly from Kludge-City, where some people
    ; still live.  It is included solely because our types.i macros aren't
    ; smart enough to do the right thing, which would be the automatic 
    ; word-alignment to these references as it SHOULD be in order to duplicate
    ; the way alignments are adjusted in the c-language.  And instead of 
    ; correcting the problem, I am obliged to kludge up my include.i files.
    ; So here it is!
    BYTE rq_KludgeFill00   ; defined as a BYTE because this does

    APTR rq_ReqLayer    ; layer in which requester rendered
    STRUCT rq_ReqPad1,32   ; for backwards compatibility (reserved)

    ; If the BitMap plane pointers are non-zero, this tells the system 
    ; that the image comes pre-drawn (if the appliprog wants to define 
    ; it's own box, in any shape or size it wants!); this is OK by 
    ; Intuition as long as there's a good correspondence between the image 
    ; and the specified Gadgets
    APTR  rq_ReqBMap    ; points to the BitMap of PREDRAWN imagery

    APTR  rq_RWindow    ; points back to requester's window
    STRUCT rq_ReqPad2,36   ; for backwards compatibility (reserved)

    LABEL rq_SIZEOF

; FLAGS SET BY THE APPLIPROG
POINTREL equ $0001  ; if POINTREL set, TopLeft is relative to pointer
PREDRAWN equ $0002  ; if ReqBMap points to predrawn Requester imagery

; FLAGS SET BY INTUITION;
REQOFFWINDOW   equ $1000   ; part of one of the Gadgets was offwindow
REQACTIVE   equ $2000   ; this requester is active
SYSREQUEST  equ $4000   ; this requester caused by system
DEFERREFRESH   equ $8000   ; this Requester stops a Refresh broadcast





; ========================================================================
; === Gadget =============================================================
; ========================================================================
 STRUCTURE Gadget,0

    APTR gg_NextGadget     ; next gadget in the list

    WORD gg_LeftEdge    ; "hit box" of gadget
    WORD gg_TopEdge     ; "hit box" of gadget
    WORD gg_Width    ; "hit box" of gadget
    WORD gg_Height      ; "hit box" of gadget

    WORD gg_Flags       ; see below for list of defines

    WORD gg_Activation     ; see below for list of defines

    WORD gg_GadgetType     ; see below for defines

    ; appliprog can specify that the Gadget be rendered as either as Border
    ; or an Image.  This variable points to which (or equals NULL if there's
    ; nothing to be rendered about this Gadget)
    APTR gg_GadgetRender

    ; appliprog can specify "highlighted" imagery rather than algorithmic
    ; this can point to either Border or Image data
    APTR gg_SelectRender

    APTR gg_GadgetText     ; text for this gadget;

    ; by using the MutualExclude word, the appliprog can describe 
    ; which gadgets mutually-exclude which other ones.  The bits in 
    ; MutualExclude correspond to the gadgets in object containing 
    ; the gadget list.  If this gadget is selected and a bit is set 
    ; in this gadget's MutualExclude and the gadget corresponding to 
    ; that bit is currently selected (e.g. bit 2 set and gadget 2 
    ; is currently selected) that gadget must be unselected.  Intuition 
    ; does the visual unselecting (with checkmarks) and leaves it up 
    ; to the program to unselect internally
    LONG gg_MutualExclude  ; set bits mean this gadget excludes that

    ; pointer to a structure of special data required by Proportional, String 
    ; and Integer Gadgets
    APTR gg_SpecialInfo

    WORD gg_GadgetID ; user-definable ID field
    APTR  gg_UserData   ; ptr to general purpose User data (ignored by Intuit)

    LABEL gg_SIZEOF

; --- FLAGS SET BY THE APPLIPROG --------------------------------------------
; combinations in these bits describe the highlight technique to be used
GADGHIGHBITS   equ $0003
GADGHCOMP   equ $0000   ; Complement the select box
GADGHBOX equ $0001   ; Draw a box around the image
GADGHIMAGE  equ $0002   ; Blast in this alternate image
GADGHNONE   equ $0003   ; don't highlight

; set this flag if the GadgetRender and SelectRender point to Image imagery, 
; clear if it's a Border 
GADGIMAGE   equ $0004 

; combinations in these next two bits specify to which corner the gadget's
; Left & Top coordinates are relative.  If relative to Top/Left,
; these are "normal" coordinates (everything is relative to something in
; this universe)
GRELBOTTOM  equ $0008   ; set if rel to bottom, clear if rel top
GRELRIGHT   equ $0010   ; set if rel to right, clear if to left
; set the RELWIDTH bit to spec that Width is relative to width of screen
GRELWIDTH   equ $0020
; set the RELHEIGHT bit to spec that Height is rel to height of screen
GRELHEIGHT  equ $0040

; the SELECTED flag is initialized by you and set by Intuition.  It 
; specifies whether or not this Gadget is currently selected/highlighted
SELECTED equ $0080


; the GADGDISABLED flag is initialized by you and later set by Intuition
; according to your calls to On/OffGadget().  It specifies whether or not 
; this Gadget is currently disabled from being selected
GADGDISABLED   equ $0100


; --- These are the Activation flag bits ----------------------------------
; RELVERIFY is set if you want to verify that the pointer was still over
; the gadget when the select button was released
RELVERIFY   equ $0001

; the flag GADGIMMEDIATE, when set, informs the caller that the gadget
; was activated when it was activated.  this flag works in conjunction with
; the RELVERIFY flag
GADGIMMEDIATE  equ $0002

; the flag ENDGADGET, when set, tells the system that this gadget, when
; selected, causes the Requester or AbsMessage to be ended.  Requesters or
; AbsMessages that are ended are erased and unlinked from the system
ENDGADGET   equ $0004

; the FOLLOWMOUSE flag, when set, specifies that you want to receive
; reports on mouse movements (ie, you want the REPORTMOUSE function for
; your Window).  When the Gadget is deselected (immediately if you have
; no RELVERIFY) the previous state of the REPORTMOUSE flag is restored
; You probably want to set the GADGIMMEDIATE flag when using FOLLOWMOUSE,
; since that's the only reasonable way you have of learning why Intuition
; is suddenly sending you a stream of mouse movement events.  If you don't
; set RELVERIFY, you'll get at least one Mouse Position event.
FOLLOWMOUSE equ $0008

; if any of the BORDER flags are set in a Gadget that's included in the
; Gadget list when a Window is opened, the corresponding Border will
; be adjusted to make room for the Gadget
RIGHTBORDER equ $0010
LEFTBORDER  equ $0020
TOPBORDER   equ $0040
BOTTOMBORDER   equ $0080

TOGGLESELECT   equ $0100   ; this bit for toggle-select mode

STRINGCENTER   equ $0200   ; center the String
STRINGRIGHT equ $0400   ; right-justify the String

LONGINT     equ $0800   ; This String Gadget is a Long Integer

ALTKEYMAP   equ $1000   ; This String has an alternate keymapping


; --- GADGET TYPES -----------------------------------------------------------
; These are the Gaget Type definitions for the variable GadgetType.
; Gadget number type MUST start from one.  NO TYPES OF ZERO ALLOWED.
; first comes the mask for Gadget flags reserved for Gadget typing
GADGETTYPE  equ $FC00   ; all Gadget Global Type flags (padded)
SYSGADGET   equ $8000   ; 1 = SysGadget, 0 = AppliGadget
SCRGADGET   equ $4000   ; 1 = ScreenGadget, 0 = WindowGadget
GZZGADGET   equ $2000   ; 1 = Gadget for GIMMEZEROZERO borders
REQGADGET   equ $1000   ; 1 = this is a Requester Gadget
; system gadgets
SIZING      equ $0010
WDRAGGING   equ $0020
SDRAGGING   equ $0030
WUPFRONT equ $0040
SUPFRONT equ $0050
WDOWNBACK   equ $0060
SDOWNBACK   equ $0070
CLOSE    equ $0080
; application gadgets
BOOLGADGET  equ $0001
GADGET0002  equ $0002
PROPGADGET  equ $0003
STRGADGET   equ $0004






; ========================================================================
; === PropInfo ===========================================================
; ========================================================================
; this is the special data required by the proportional Gadget
; typically, this data will be pointed to by the Gadget variable SpecialInfo
 STRUCTURE PropInfo,0

    WORD pi_Flags ; general purpose flag bits (see defines below)

    ; You initialize the Pot variables before the Gadget is added to 
    ; the system.  Then you can look here for the current settings 
    ; any time, even while User is playing with this Gadget.  To 
    ; adjust these after the Gadget is added to the System, use 
    ; ModifyProp(); The Pots are the actual proportional settings, 
    ; where a value of zero means zero and a value of MAXPOT means 
    ; that the Gadget is set to its maximum setting.
    WORD pi_HorizPot ; 16-bit FixedPoint horizontal quantity percentage;
    WORD pi_VertPot  ; 16-bit FixedPoint vertical quantity percentage;

    ; the 16-bit FixedPoint Body variables describe what percentage 
    ; of the entire body of stuff referred to by this Gadget is 
    ; actually shown at one time.  This is used with the AUTOKNOB 
    ; routines, to adjust the size of the AUTOKNOB according to how 
    ; much of the data can be seen.  This is also used to decide how 
    ; far to advance the Pots when User hits the Container of the Gadget.  
    ; For instance, if you were controlling the display of a 5-line 
    ; Window of text with this Gadget, and there was a total of 15 
    ; lines that could be displayed, you would set the VertBody value to 
    ;    (MAXBODY / (TotalLines / DisplayLines)) = MAXBODY / 3.
    ; Therefore, the AUTOKNOB would fill 1/3 of the container, and if 
    ; User hits the Cotainer outside of the knob, the pot would advance 
    ; 1/3 (plus or minus) If there's no body to show, or the total 
    ; amount of displayable info is less than the display area, set the 
    ; Body variables to the MAX.  To adjust these after the Gadget is 
    ; added to the System, use ModifyProp().
    WORD pi_HorizBody   ; horizontal Body
    WORD pi_VertBody ; vertical Body

    ; these are the variables that Intuition sets and maintains
    WORD pi_CWidth   ; Container width (with any relativity absoluted)
    WORD pi_CHeight  ; Container height (with any relativity absoluted)
    WORD pi_HPotRes  ; pot increments
    WORD pi_VPotRes  ; pot increments
    WORD pi_LeftBorder  ; Container borders
    WORD pi_TopBorder   ; Container borders
    LABEL  pi_SIZEOF

; --- FLAG BITS --------------------------------------------------------------
AUTOKNOB equ $0001   ; this flag sez:  gimme that old auto-knob
FREEHORIZ   equ $0002   ; if set, the knob can move horizontally
FREEVERT equ $0004   ; if set, the knob can move vertically
PROPBORDERLESS equ $0008   ; if set, no border will be rendered
KNOBHIT     equ $0100   ; set when this Knob is hit


KNOBHMIN equ 6    ; minimum horizontal size of the knob
KNOBVMIN    equ 4    ; minimum vertical size of the knob
MAXBODY     equ $FFFF   ; maximum body value
MAXPOT      equ $FFFF   ; maximum pot value






; ========================================================================
; === StringInfo =========================================================
; ========================================================================
; this is the special data required by the string Gadget
; typically, this data will be pointed to by the Gadget variable SpecialInfo
 STRUCTURE StringInfo,0

    ; you initialize these variables, and then Intuition maintains them
    APTR  si_Buffer  ; the buffer containing the start and final string
    APTR  si_UndoBuffer ; optional buffer for undoing current entry
    WORD si_BufferPos   ; character position in Buffer
    WORD si_MaxChars ; max number of chars in Buffer (including NULL)
    WORD si_DispPos  ; Buffer position of first displayed character

    ; Intuition initializes and maintains these variables for you
    WORD si_UndoPos  ; character position in the undo buffer
    WORD si_NumChars ; number of characters currently in Buffer
    WORD si_DispCount   ; number of whole characters visible in Container
    WORD si_CLeft ; topleft offset of the container
    WORD si_CTop  ; topleft offset of the container
    APTR  si_LayerPtr   ; the RastPort containing this Gadget

    ; you can initialize this variable before the gadget is submitted to
    ; Intuition, and then examine it later to discover what integer 
    ; the user has entered (if the user never plays with the gadget, 
    ; the value will be unchanged from your initial setting)
    LONG  si_LongInt ; the LONG return value of a LONGINT String Gadget

    ; If you want this Gadget to use your own Console keymapping, you
    ; set the ALTKEYMAP bit in the Activation flags of the Gadget, and then
    ; set this variable to point to your keymap.  If you don't set the
    ; ALTKEYMAP, you'll get the standard ASCII keymapping.
    APTR si_AltKeyMap

    LABEL si_SIZEOF




; ========================================================================
; === IntuiText ==========================================================
; ========================================================================
; IntuiText is a series of strings that start with a screen location
; (always relative to the upper-left corner of something) and then the
; text of the string.  The text is null-terminated.
 STRUCTURE IntuiText,0

    UBYTE it_FrontPen      ; the pens for rendering the text
    UBYTE it_BackPen    ; the pens for rendering the text

    UBYTE it_DrawMode      ; the mode for rendering the text

    ; The following variable is strictly from Kludge-City, where some people
    ; still live.  It is included solely because our types.i macros aren't
    ; smart enough to do the right thing, which would be the automatic 
    ; word-alignment to these references as it SHOULD be in order to duplicate
    ; the way alignments are adjusted in the c-language.  And instead of 
    ; correcting the problem, I am obliged to kludge up my include.i files.
    ; So here it is!
    BYTE it_KludgeFill00   ; defined as a BYTE because this does

    WORD it_LeftEdge    ; relative start location for the text
    WORD it_TopEdge     ; relative start location for the text

    APTR  it_ITextFont     ; if NULL, you accept the defaults

    APTR it_IText    ; pointer to null-terminated text

    APTR  it_NextText      ; continuation to TxWrite another text

    LABEL it_SIZEOF





; ========================================================================
; === Border =============================================================
; ========================================================================
; Data type Border, used for drawing a series of lines which is intended for
; use as a border drawing, but which may, in fact, be used to render any
; arbitrary vector shape.
; The routine DrawBorder sets up the RastPort with the appropriate
; variables, then does a Move to the first coordinate, then does Draws
; to the subsequent coordinates.
; After all the Draws are done, if NextBorder is non-zero we call DrawBorder
; recursively
 STRUCTURE Border,0

    WORD bd_LeftEdge    ; initial offsets from the origin
    WORD bd_TopEdge     ; initial offsets from the origin
    UBYTE bd_FrontPen      ; pen number for rendering 
    UBYTE bd_BackPen    ; pen number for rendering 
    UBYTE bd_DrawMode      ; mode for rendering 
    BYTE  bd_Count      ; number of XY pairs
    APTR  bd_XY         ; vector coordinate pairs rel to LeftTop
    APTR  bd_NextBorder    ; pointer to any other Border too

    LABEL bd_SIZEOF


; ======================================================================== 
; === Image ============================================================== 
; ======================================================================== 
; This is a brief image structure for very simple transfers of 
; image data to a RastPort
 STRUCTURE Image,0

    WORD ig_LeftEdge    ; starting offset relative to something 
    WORD ig_TopEdge     ; starting offset relative to something 
    WORD ig_Width    ; pixel size (though data is word-aligned)
    WORD ig_Height      ; pixel size 
    WORD ig_Depth    ; pixel size 
    APTR ig_ImageData      ; pointer to the actual image bits

    ; the PlanePick and PlaneOnOff variables work much the same way as the
    ; equivalent GELS Bob variables.  It's a space-saving 
    ; mechanism for image data.  Rather than defining the image data
    ; for every plane of the RastPort, you need define data only for planes 
    ; that are not entirely zero or one.  As you define your Imagery, you will
    ; often find that most of the planes ARE just as color selectors.  For
    ; instance, if you're designing a two-color Gadget to use colors two and
    ; three, and the Gadget will reside in a five-plane display, plane zero
    ; of your imagery would be all ones, bit plane one would have data that
    ; describes the imagery, and bit planes two through four would be
    ; all zeroes.  Using these flags allows you to avoid wasting all that 
    ; memory in this way:  
    ; first, you specify which planes you want your data to appear 
    ; in using the PlanePick variable.  For each bit set in the variable, the 
    ; next "plane" of your image data is blitted to the display.  For each bit
    ; clear in this variable, the corresponding bit in PlaneOnOff is examined.
    ; If that bit is clear, a "plane" of zeroes will be used.  If the bit is 
    ; set, ones will go out instead.  So, for our example:
    ;   Gadget.PlanePick = 0x02;
    ;   Gadget.PlaneOnOff = 0x01;
    ; Note that this also allows for generic Gadgets, like the System Gadgets,
    ; which will work in any number of bit planes
    ; Note also that if you want an Image that is only a filled rectangle,
    ; you can get this by setting PlanePick to zero (pick no planes of data)
    ; and set PlaneOnOff to describe the pen color of the rectangle.
    BYTE ig_PlanePick
    BYTE ig_PlaneOnOff

    ; if the NextImage variable is not NULL, Intuition presumes that 
    ; it points to another Image structure with another Image to be 
    ; rendered
    APTR ig_NextImage


    LABEL ig_SIZEOF




; ======================================================================== 
; === IntuiMessage ======================================================= 
; ======================================================================== 
 STRUCTURE IntuiMessage,0

    STRUCT im_ExecMessage,MN_SIZE

    ; the Class bits correspond directly with the IDCMP Flags, except for the
    ; special bit LONELYMESSAGE (defined below)
    ULONG im_Class

    ; the Code field is for special values like MENU number 
    WORD im_Code

    ; the Qualifier field is a copy of the current InputEvent's Qualifier 
    WORD im_Qualifier

    ; IAddress contains particular addresses for Intuition functions, like
    ; the pointer to the Gadget or the Screen
    APTR im_IAddress

    ; when getting mouse movement reports, any event you get will have the
    ; the mouse coordinates in these variables.  the coordinates are relative
    ; to the upper-left corner of your Window (GIMMEZEROZERO notwithstanding)
    WORD im_MouseX
    WORD im_MouseY

    ; the time values are copies of the current system clock time.  Micros
    ; are in units of microseconds, Seconds in seconds.
    LONG im_Seconds
    LONG im_Micros

    ; the IDCMPWindow variable will always have the address of the Window of 
    ; this IDCMP 
    APTR im_IDCMPWindow

    ; system-use variable 
    APTR im_SpecialLink

    LABEL  im_SIZEOF



; --- IDCMP Classes ------------------------------------------------------ 
SIZEVERIFY  equ   $00000001   ; See the Programmer's Guide
NEWSIZE     equ   $00000002   ; See the Programmer's Guide
REFRESHWINDOW  equ   $00000004   ; See the Programmer's Guide
MOUSEBUTTONS   equ   $00000008   ; See the Programmer's Guide
MOUSEMOVE   equ   $00000010   ; See the Programmer's Guide 
GADGETDOWN  equ   $00000020   ; See the Programmer's Guide
GADGETUP equ   $00000040   ; See the Programmer's Guide 
REQSET      equ   $00000080   ; See the Programmer's Guide
MENUPICK equ   $00000100   ; See the Programmer's Guide 
CLOSEWINDOW equ   $00000200   ; See the Programmer's Guide
RAWKEY      equ   $00000400   ; See the Programmer's Guide 
REQVERIFY   equ   $00000800   ; See the Programmer's Guide
REQCLEAR equ   $00001000   ; See the Programmer's Guide 
MENUVERIFY  equ   $00002000   ; See the Programmer's Guide
NEWPREFS equ   $00004000   ; See the Programmer's Guide 
DISKINSERTED   equ   $00008000   ; See the Programmer's Guide
DISKREMOVED equ   $00010000   ; See the Programmer's Guide 
WBENCHMESSAGE  equ   $00020000   ; See the Programmer's Guide
ACTIVEWINDOW   equ   $00040000   ; See the Programmer's Guide
INACTIVEWINDOW equ   $00080000   ; See the Programmer's Guide
DELTAMOVE   equ   $00100000   ; See the Programmer's Guide
VANILLAKEY  equ   $00200000   ; See the Programmer's Guide
INTUITICKS  equ   $00400000   ; See the Programmer's Guide
; NOTEZ-BIEN:     $80000000 is reserved for internal use by IDCMP

; the IDCMP Flags do not use this special bit, which is cleared when
; Intuition sends its special message to the Task, and set when Intuition
; gets its Message back from the Task.  Therefore, I can check here to
; find out fast whether or not this Message is available for me to send
LONELYMESSAGE  equ   $80000000



; --- IDCMP Codes -------------------------------------------------------- 
; This group of codes is for the MENUVERIFY function 
MENUHOT     equ   $0001 ; IntuiWants verification or MENUCANCEL    
MENUCANCEL  equ   $0002 ; HOT Reply of this cancels Menu operation 
MENUWAITING equ   $0003 ; Intuition simply wants a ReplyMsg() ASAP 

; This group of codes is for the WBENCHMESSAGE messages
WBENCHOPEN  equ $0001
WBENCHCLOSE equ $0002




; ======================================================================== 
; === Window ============================================================= 
; ======================================================================== 
 STRUCTURE Window,0

    APTR wd_NextWindow     ; for the linked list of a Screen

    WORD wd_LeftEdge    ; screen dimensions
    WORD wd_TopEdge     ; screen dimensions
    WORD wd_Width    ; screen dimensions
    WORD wd_Height      ; screen dimensions

    WORD wd_MouseY      ; relative top top-left corner 
    WORD wd_MouseX      ; relative top top-left corner 

    WORD wd_MinWidth    ; minimum sizes
    WORD wd_MinHeight      ; minimum sizes
    WORD wd_MaxWidth    ; maximum sizes
    WORD wd_MaxHeight      ; maximum sizes

    LONG wd_Flags    ; see below for definitions

    APTR wd_MenuStrip      ; first in a list of menu headers

    APTR wd_Title    ; title text for the Window

    APTR wd_FirstRequest   ; first in linked list of active Requesters 
    APTR wd_DMRequest      ; the double-menu Requester 
    WORD wd_ReqCount    ; number of Requesters blocking this Window
    APTR wd_WScreen     ; this Window's Screen
    APTR wd_RPort    ; this Window's very own RastPort

    ; the border variables describe the window border.  If you specify
    ; GIMMEZEROZERO when you open the window, then the upper-left of the
    ; ClipRect for this window will be upper-left of the BitMap (with correct
    ; offsets when in SuperBitMap mode; you MUST select GIMMEZEROZERO when
    ; using SuperBitMap).  If you don't specify ZeroZero, then you save
    ; memory (no allocation of RastPort, Layer, ClipRect and associated
    ; Bitmaps), but you also must offset all your writes by BorderTop,
    ; BorderLeft and do your own mini-clipping to prevent writing over the
    ; system gadgets
    BYTE wd_BorderLeft
    BYTE wd_BorderTop
    BYTE wd_BorderRight
    BYTE wd_BorderBottom
    APTR wd_BorderRPort

    ; You supply a linked-list of gadget that you want for your Window.
    ; This list DOES NOT include system Gadgets.  You get the standard
    ; window system Gadgets by setting flag-bits in the variable Flags (see
    ; the bit definitions below)
    APTR wd_FirstGadget

    ; these are for opening/closing the windows 
    APTR wd_Parent
    APTR wd_Descendant

    ; sprite data information for your own Pointer
    ; set these AFTER you Open the Window by calling SetPointer()
    APTR wd_Pointer
    BYTE wd_PtrHeight
    BYTE wd_PtrWidth
    BYTE wd_XOffset
    BYTE wd_YOffset

    ; the IDCMP Flags and User's and Intuition's Message Ports 
    ULONG wd_IDCMPFlags
    APTR wd_UserPort
    APTR wd_WindowPort
    APTR wd_MessageKey

    BYTE wd_DetailPen
    BYTE wd_BlockPen

    ; the CheckMark is a pointer to the imagery that will be used when 
    ; rendering MenuItems of this Window that want to be checkmarked
    ; if this is equal to NULL, you'll get the default imagery
    APTR wd_CheckMark

    ; if non-null, Screen title when Window is active 
    APTR wd_ScreenTitle

    ; These variables have the mouse coordinates relative to the 
    ; inner-Window of GIMMEZEROZERO Windows.  This is compared with the
    ; MouseX and MouseY variables, which contain the mouse coordinates
    ; relative to the upper-left corner of the Window, GIMMEZEROZERO
    ; notwithstanding
    SHORT wd_GZZMouseX
    SHORT wd_GZZMouseY
    ; these variables contain the width and height of the inner-Window of
    ; GIMMEZEROZERO Windows
    SHORT wd_GZZWidth
    SHORT wd_GZZHeight

    APTR wd_ExtData

    ; general-purpose pointer to User data extension 
    APTR wd_UserData
    APTR wd_WLayer   ; stash of Window.RPort->Layer

    LABEL wd_Size

; --- FLAGS REQUESTED (NOT DIRECTLY SET THOUGH) BY THE APPLIPROG -------------
WINDOWSIZING   equ $0001   ; include sizing system-gadget? 
WINDOWDRAG     equ $0002   ; include dragging system-gadget? 
WINDOWDEPTH    equ $0004   ; include depth arrangement gadget? 
WINDOWCLOSE    equ $0008   ; include close-box system-gadget? 

SIZEBRIGHT  equ $0010   ; size gadget uses right border 
SIZEBBOTTOM equ $0020   ; size gadget uses bottom border 

; --- refresh modes ----------------------------------------------------------
; combinations of the REFRESHBITS select the refresh type 
REFRESHBITS equ $00C0
SMART_REFRESH  equ $0000
SIMPLE_REFRESH equ $0040
SUPER_BITMAP   equ $0080
OTHER_REFRESH  equ $00C0

BACKDROP equ $0100   ; this is an ever-popular BACKDROP window 

REPORTMOUSE equ $0200   ; set this to hear about every mouse move 

GIMMEZEROZERO  equ $0400   ; make extra border stuff 

BORDERLESS  equ $0800   ; set this to get a Window sans border 

ACTIVATE equ $1000   ; when Window opens, it's the Active one 

; FLAGS SET BY INTUITION 
WINDOWACTIVE   equ $2000   ; this window is the active one 
INREQUEST      equ $4000   ; this window is in request mode 
MENUSTATE      equ $8000   ; this Window is active with its Menus on 

; --- Other User Flags -------------------------------------------------------
RMBTRAP     equ $00010000  ; Catch RMB events for your own 
NOCAREREFRESH  equ $00020000  ; not to be bothered with REFRESH


WINDOWREFRESH  equ $01000000  ; Window is currently refreshing
WBENCHWINDOW   equ $02000000  ; WorkBench Window
WINDOWTICKED   equ $04000000  ; only one timer tick at a time

SUPER_UNUSED   equ $FCFC0000  ;bits of Flag unused yet




; --- see struct IntuiMessage for the IDCMP Flag definitions -----------------









; ======================================================================== 
; === NewWindow ========================================================== 
; ======================================================================== 
 STRUCTURE NewWindow,0

    WORD nw_LeftEdge    ; initial Window dimensions
    WORD nw_TopEdge     ; initial Window dimensions
    WORD nw_Width    ; initial Window dimensions
    WORD nw_Height      ; initial Window dimensions

    BYTE nw_DetailPen      ; for rendering the detail bits of the Window
    BYTE nw_BlockPen    ; for rendering the block-fill bits 

    ULONG nw_IDCMPFlags    ; initial IDCMP state

    LONG nw_Flags    ; see the Flag definition under Window

    ; You supply a linked-list of Gadgets for your Window.
    ; This list DOES NOT include system Gadgets.  You get the standard
    ; system Window Gadgets by setting flag-bits in the variable Flags (see
    ; the bit definitions under the Window structure definition)
    APTR nw_FirstGadget

    ; the CheckMark is a pointer to the imagery that will be used when 
    ; rendering MenuItems of this Window that want to be checkmarked
    ; if this is equal to NULL, you'll get the default imagery
    APTR nw_CheckMark

    APTR nw_Title    ; title text for the Window
    
    ; the Screen pointer is used only if you've defined a CUSTOMSCREEN and
    ; want this Window to open in it.  If so, you pass the address of the
    ; Custom Screen structure in this variable.  Otherwise, this variable
    ; is ignored and doesn't have to be initialized.
    APTR nw_Screen
    
    ; SUPER_BITMAP Window?  If so, put the address of your BitMap structure
    ; in this variable.  If not, this variable is ignored and doesn't have 
    ; to be initialized
    APTR nw_BitMap

    ; the values describe the minimum and maximum sizes of your Windows.
    ; these matter only if you've chosen the WINDOWSIZING Gadget option,
    ; which means that you want to let the User to change the size of 
    ; this Window.  You describe the minimum and maximum sizes that the
    ; Window can grow by setting these variables.  You can initialize
    ; any one these to zero, which will mean that you want to duplicate
    ; the setting for that dimension (if MinWidth == 0, MinWidth will be
    ; set to the opening Width of the Window).
    ; You can change these settings later using SetWindowLimits().
    ; If you haven't asked for a SIZING Gadget, you don't have to
    ; initialize any of these variables.
    WORD nw_MinWidth
    WORD nw_MinHeight
    WORD nw_MaxWidth
    WORD nw_MaxHeight

    ; the type variable describes the Screen in which you want this Window to
    ; open.  The type value can either be CUSTOMSCREEN or one of the
    ; system standard Screen Types such as WBENCHSCREEN.  See the
    ; type definitions under the Screen structure
    WORD nw_Type

    LABEL nw_SIZE




; ======================================================================== 
; === Screen ============================================================= 
; ======================================================================== 
 STRUCTURE Screen,0

    APTR sc_NextScreen     ; linked list of screens
    APTR sc_FirstWindow    ; linked list Screen's Windows

    WORD sc_LeftEdge    ; parameters of the screen
    WORD sc_TopEdge     ; parameters of the screen

    WORD sc_Width    ; null-terminated Title text
    WORD sc_Height      ; for Windows without ScreenTitle

    WORD sc_MouseY      ; position relative to upper-left
    WORD sc_MouseX      ; position relative to upper-left

    WORD sc_Flags    ; see definitions below

    APTR sc_Title
    APTR sc_DefaultTitle

    ; Bar sizes for this Screen and all Window's in this Screen
    BYTE sc_BarHeight
    BYTE sc_BarVBorder
    BYTE sc_BarHBorder
    BYTE sc_MenuVBorder
    BYTE sc_MenuHBorder
    BYTE sc_WBorTop
    BYTE sc_WBorLeft
    BYTE sc_WBorRight
    BYTE sc_WBorBottom

    ; The following variable is strictly from Kludge-City, where some people
    ; still live.  It is included solely because our types.i macros aren't
    ; smart enough to do the right thing, which would be the automatic 
    ; word-alignment to these references as it SHOULD be in order to duplicate
    ; the way alignments are adjusted in the c-language.  And instead of 
    ; correcting the problem, I am obliged to kludge up my include.i files.
    ; So here it is!
    BYTE sc_KludgeFill00   ; defined as a BYTE because this does

    ; the display data structures for this Screen
    APTR sc_Font        ; this screen's default font
    STRUCT sc_ViewPort,vp_SIZEOF ; describing the Screen's display
    STRUCT sc_RastPort,rp_SIZEOF ; describing Screen rendering
    STRUCT sc_BitMap,bm_SIZEOF      ; auxiliary graphexcess baggage
    STRUCT sc_LayerInfo,li_SIZEOF   ; each screen gets a LayerInfo

    ; You supply a linked-list of Gadgets for your Screen.
    ; This list DOES NOT include system Gadgets.  You get the standard
    ; system Screen Gadgets by default
    APTR sc_FirstGadget

    BYTE sc_DetailPen      ; for bar/border/gadget rendering
    BYTE sc_BlockPen    ; for bar/border/gadget rendering

    ; the following variable(s) are maintained by Intuition to support the
    ; DisplayBeep() color flashing technique
    WORD sc_SaveColor0

    ; This layer is for the Screen and Menu bars
    APTR BarLayer; 

    APTR sc_ExtData

    APTR sc_UserData    ; general-purpose pointer to User data 

    LABEL sc_SIZEOF


; --- FLAGS SET BY INTUITION -------------------------------------------------
; The SCREENTYPE bits are reserved for describing various Screen types
; available under Intuition.  
SCREENTYPE  equ   $000F ; all the screens types available 
; --- the definitions for the Screen Type ------------------------------------
WBENCHSCREEN   equ   $0001 ; Ta Da!  The Workbench
CUSTOMSCREEN   equ   $000F ; for that special look

SHOWTITLE   equ   $0010 ; this gets set by a call to ShowTitle() 

BEEPING     equ   $0020 ; set when Screen is beeping 

CUSTOMBITMAP   equ   $0040 ; if you are supplying your own BitMap




; ======================================================================== 
; === NewScreen ========================================================== 
; ======================================================================== 
 STRUCTURE NewScreen,0

    WORD ns_LeftEdge    ; initial Screen dimensions
    WORD ns_TopEdge     ; initial Screen dimensions
    WORD ns_Width    ; initial Screen dimensions
    WORD ns_Height      ; initial Screen dimensions
    WORD ns_Depth    ; initial Screen dimensions

    BYTE ns_DetailPen      ; default rendering pens (for Windows too)
    BYTE ns_BlockPen    ; default rendering pens (for Windows too)

    WORD ns_ViewModes      ; display "modes" for this Screen

    WORD ns_Type     ; Intuition Screen Type specifier

    APTR ns_Font     ; default font for Screen and Windows

    APTR ns_DefaultTitle   ; Title when Window doesn't care

    APTR ns_Gadgets     ; Your own initial Screen Gadgets

    ; if you are opening a CUSTOMSCREEN and already have a BitMap 
    ; that you want used for your Screen, you set the flags CUSTOMBITMAP in
    ; the Types variable and you set this variable to point to your BitMap
    ; structure.  The structure will be copied into your Screen structure,
    ; after which you may discard your own BitMap if you want
    APTR ns_CustomBitMap;

 LABEL    ns_SIZEOF








; ======================================================================== 
; === Preferences ======================================================== 
; ======================================================================== 

; these are the definitions for the printer configurations 
FILENAME_SIZE equ 30       ; Filename size 

POINTERSIZE    equ   (1+16+1)*2  ; Size of Pointer data buffer 

; These defines are for the default font size.  These actually describe the
; height of the defaults fonts.  The default font type is the topaz
; font, which is a fixed width font that can be used in either 
; eighty-column or sixty-column mode.  The Preferences structure reflects
; which is currently selected by the value found in the variable FontSize,
; which may have either of the values defined below.  These values actually
; are used to select the height of the default font.  By changing the
; height, the resolution of the font changes as well.
TOPAZ_EIGHTY   equ   8  
TOPAZ_SIXTY    equ   9

; ------------------------------------------------------------------------
 STRUCTURE Preferences,0

    ; the default font height
    BYTE pf_FontHeight     ; height for system default font

    ; constant describing what's hooked up to the port
    UBYTE pf_PrinterPort   ; printer port connection

    ; the baud rate of the port
    USHORT pf_BaudRate     ; baud rate for the serial port
    
    ; various timing rates
    STRUCT pf_KeyRptSpeed,TV_SIZE ; repeat speed for keyboard
    STRUCT pf_KeyRptDelay,TV_SIZE ; Delay before keys repeat
    STRUCT pf_DoubleClick,TV_SIZE ; Interval allowed between clicks

    ; Intuition Pointer data
    STRUCT pf_PointerMatrix,POINTERSIZE*2 ; Definition of pointer sprite
    BYTE pf_XOffset     ; X-Offset for active 'bit'
    BYTE pf_YOffset     ; Y-Offset for active 'bit'
    WORD pf_color17     ;********************************
    WORD pf_color18     ; Colours for sprite pointer
    WORD pf_color19     ;********************************
    WORD pf_PointerTicks   ; Sensitivity of the pointer

    ; Workbench Screen colors
    WORD pf_color0      ;********************************
    WORD pf_color1      ;  Standard default colours
    WORD pf_color2      ;   Used in the Workbench
    WORD pf_color3      ;********************************

    ; positioning data for the Intuition View
    BYTE pf_ViewXOffset    ; Offset for top lefthand corner
    BYTE pf_ViewYOffset    ; X and Y dimensions
    WORD pf_ViewInitX      ; View initial offsets at startup
    WORD pf_ViewInitY      ; View initial offsets at startup

    BOOL EnableCLI      ; CLI availability switch

    ; printer configurations
    WORD pf_PrinterType    ; printer type
    STRUCT pf_PrinterFilename,FILENAME_SIZE ; file for printer

    ; print format and quality configurations
    SHORT pf_PrintPitch       ; print pitch
    WORD pf_PrintQuality   ; print quality
    WORD pf_PrintSpacing   ; number of lines per inch
    UWORD pf_PrintLeftMargin  ; left margin in characters
    UWORD pf_PrintRightMargin ; right margin in characters
    WORD  pf_PrintImage    ; positive or negative
    WORD pf_PrintAspect    ; horizontal or vertical
    WORD pf_PrintShade     ; b&w, half-tone, or color
    WORD pf_PrintThreshold ; darkness ctrl for b/w dumps


    ; print paper description
    WORD pf_PaperSize      ; paper size
    UWORD pf_PaperLength   ; paper length in lines
    WORD pf_PaperType      ; continuous or single sheet

    STRUCT pf_padding,50   ; For further system expansion

    LABEL pf_SIZEOF


; === Preferences definitions ===========================================

; PrinterPort
PARALLEL_PRINTER equ $00
SERIAL_PRINTER equ   $01

; BaudRate
BAUD_110 equ   $00
BAUD_300 equ   $01
BAUD_1200   equ   $02
BAUD_2400   equ   $03
BAUD_4800   equ   $04
BAUD_9600   equ   $05
BAUD_19200  equ   $06
BAUD_MIDI   equ   $07

; PaperType
FANFOLD  equ   $00
SINGLE      equ   $80

; PrintPitch
PICA     equ   $000
ELITE       equ   $400
FINE     equ   $800

; PrintQuality
DRAFT       equ   $000
LETTER      equ   $100

; PrintSpacing
SIX_LPI     equ   $000
EIGHT_LPI   equ   $200

; Print Image
IMAGE_POSITIVE equ   0
IMAGE_NEGATIVE equ   1

; PrintAspect
ASPECT_HORIZ   equ   0
ASPECT_VERT equ   1

; PrintShade
SHADE_BW equ   $00
SHADE_GREYSCALE   equ   $01
SHADE_COLOR equ   $02

; PaperSize
US_LETTER   equ   $00
US_LEGAL equ   $10
N_TRACTOR   equ   $20
W_TRACTOR   equ   $30
CUSTOM      equ   $40

; PrinterType
CUSTOM_NAME equ   $00
ALPHA_P_101 equ   $01
BROTHER_15XL   equ   $02
CBM_MPS1000 equ   $03
DIAB_630 equ   $04
DIAB_ADV_D25   equ   $05
DIAB_C_150  equ   $06
EPSON    equ   $07
EPSON_JX_80 equ   $08
OKIMATE_20  equ   $09
QUME_LP_20  equ   $0A
; new printer entries, 3 October 1985
HP_LASERJET equ   $0B
HP_LASERJET_PLUS equ $0C




; ========================================================================
; === Remember ===========================================================
; ========================================================================
; this structure is used for remembering what memory has been allocated to
; date by a given routine, so that a premature abort or systematic exit
; can deallocate memory cleanly, easily, and completely
 STRUCTURE Remember,0

    APTR rm_NextRemember
    ULONG rm_RememberSize
    APTR rm_Memory

 LABEL    rm_SIZEOF



; ======================================================================== 
; === Miscellaneous ====================================================== 
; ======================================================================== 

; = MACROS ============================================================== 
;#define MENUNUM(n) (n & 0x1F)
;#define ITEMNUM(n) ((n >> 5) & 0x003F)
;#define SUBNUM(n) ((n >> 11) & 0x001F)
;
;#define SHIFTMENU(n) (n & 0x1F)
;#define SHIFTITEM(n) ((n & 0x3F) << 5)
;#define SHIFTSUB(n) ((n & 0x1F) << 11)
;
; = MENU STUFF =========================================================== 
NOMENU equ  $001F
NOITEM equ  $003F
NOSUB  equ  $001F
MENUNULL equ   $FFFF


; = =RJ='s peculiarities ================================================= 
;#define FOREVER for(;;)
;#define SIGN(x) ( ((x) > 0) - ((x) < 0) )


; these defines are for the COMMSEQ and CHECKIT menu stuff.  If CHECKIT,
; I'll use a generic Width (for all resolutions) for the CheckMark.
; If COMMSEQ, likewise I'll use this generic stuff
CHECKWIDTH  equ   19
COMMWIDTH   equ   27
LOWCHECKWIDTH  equ   13
LOWCOMMWIDTH   equ   16


; these are the AlertNumber defines.  if you are calling DisplayAlert()
; the AlertNumber you supply must have the ALERT_TYPE bits set to one
; of these patterns
ALERT_TYPE  equ   $80000000
RECOVERY_ALERT equ   $00000000   ; the system can recover from this 
DEADEND_ALERT  equ   $80000000   ; no recovery possible, this is it 


; When you're defining IntuiText for the Positive and Negative Gadgets 
; created by a call to AutoRequest(), these defines will get you 
; reasonable-looking text.  The only field without a define is the IText
; field; you decide what text goes with the Gadget
AUTOFRONTPEN   equ   0
AUTOBACKPEN equ   1
AUTODRAWMODE   equ   RP_JAM2
AUTOLEFTEDGE   equ   6
AUTOTOPEDGE equ   3
AUTOITEXTFONT  equ   0
AUTONEXTTEXT   equ   0



   ENDC



