This commit is contained in:
Joshua Bell 2018-02-18 15:28:33 -08:00
parent 7e0eb9b254
commit e5d9b598cb

396
mgtk.inc
View File

@ -53,7 +53,7 @@ MLI := $4000
;;; Point vertex2 ;;; Point vertex2
;;; ... ;;; ...
NoOp := $00 ; No-op NoOp := $00 ; No-op
;; (input length 0 bytes) ;; (input length 0 bytes)
;;; -------------------------------------------------- ;;; --------------------------------------------------
@ -62,107 +62,107 @@ NoOp := $00 ; No-op
InitGraf := $01 InitGraf := $01
SetSwitches := $02 ; Configure display switches SetSwitches := $02 ; Configure display switches
;; .byte flags bit 0=hires, 1=page2, 2=mixed, 3=text ;;; .byte flags bit 0=hires, 1=page2, 2=mixed, 3=text
;;; -------------------------------------------------- ;;; --------------------------------------------------
;;; GrafPort Commands ;;; GrafPort Commands
InitPort := $03 ; Initialize GrafPort to standard values InitPort := $03 ; Initialize GrafPort to standard values
;; (input is address of GrafPort record) ;;; (input is address of GrafPort record)
SetPort := $04 ; Set current port as specified SetPort := $04 ; Set current port as specified
;; (input is address of GrafPort record) ;;; (input is address of GrafPort record)
GetPort := $05 ; Get pointer to current port GetPort := $05 ; Get pointer to current port
;; .addr port (out) ;;; .addr port (out)
SetPortBits := $06 ; Set just the mapinfo (viewloc, mapbits) SetPortBits := $06 ; Set just the mapinfo (viewloc, mapbits)
;; (input is address of MapInfo record) ;;; (input is address of MapInfo record)
SetPenMode := $07 ; Set the current pen mode SetPenMode := $07 ; Set the current pen mode
;; .byte mode pen*/notpen* ;;; .byte mode pen*/notpen*
SetPattern := $08 ; Set the current pattern SetPattern := $08 ; Set the current pattern
;; .res 8 pattern 8x8 pixel pattern for PaintRect calls ;;; .res 8 pattern 8x8 pixel pattern for PaintRect calls
SetColorMasks := $09 ; Set the current color masks SetColorMasks := $09 ; Set the current color masks
;; .byte and_mask ;;; .byte and_mask
;; .byte or_mask ;;; .byte or_mask
SetPenSize := $0A ; Set the current pen size SetPenSize := $0A ; Set the current pen size
;; .byte penwidth horizontal pen thickness ;;; .byte penwidth horizontal pen thickness
;; .byte penheight vertical pen thickness ;;; .byte penheight vertical pen thickness
SetFont := $0B ; Set the current font SetFont := $0B ; Set the current font
;; .addr textfont font definition ;;; .addr textfont font definition
SetTextBG := $0C ; Set the current text background SetTextBG := $0C ; Set the current text background
;; .byte backcolor 0=black, $7F=white ;;; .byte backcolor 0=black, $7F=white
;;; -------------------------------------------------- ;;; --------------------------------------------------
;;; Drawing Commands ;;; Drawing Commands
Move := $0D ; Set current pen location (relative) Move := $0D ; Set current pen location (relative)
;; .word xdelta ;;; .word xdelta
;; .word ydelta ;;; .word ydelta
MoveTo := $0E ; Set current pen location (absolute) MoveTo := $0E ; Set current pen location (absolute)
;; Point pos ;;; Point pos
Line := $0F ; Draw line from current pen location (relative) Line := $0F ; Draw line from current pen location (relative)
;; .word xdelta ;;; .word xdelta
;; .word ydelta ;;; .word ydelta
LineTo := $10 ; Draw line from current pen location (absolute) LineTo := $10 ; Draw line from current pen location (absolute)
;; Point pos ;;; Point pos
PaintRect := $11 ; Fill rectangle with selected simple pattern/thickness PaintRect := $11 ; Fill rectangle with selected simple pattern/thickness
;; Rect rect ;;; Rect rect
FrameRect := $12 ; Draw rectangle with selected simple pattern/thickness FrameRect := $12 ; Draw rectangle with selected simple pattern/thickness
;; Rect rect ;;; Rect rect
InRect := $13 ; Is current position in bounds? A=$80 true, 0 false InRect := $13 ; Is current position in bounds? A=$80 true, 0 false
;; Rect rect ;;; Rect rect
PaintBits := $14 ; Draw pattern PaintBits := $14 ; Draw pattern
;; (input is address of MapInfo record) ;;; (input is address of MapInfo record)
PaintPoly := $15 PaintPoly := $15
;; (input is address of Polygon record) ;;; (input is address of Polygon record)
FramePoly := $16 ; Draw multiple closed polygons FramePoly := $16 ; Draw multiple closed polygons
;; (input is address of Polygon record) ;;; (input is address of Polygon record)
InPoly := $17 ; Is current position in bounds? A=$80 true, 0 false InPoly := $17 ; Is current position in bounds? A=$80 true, 0 false
;; (input is address of Polygon record) ;;; (input is address of Polygon record)
;;; -------------------------------------------------- ;;; --------------------------------------------------
;;; Text Commands ;;; Text Commands
TextWidth := $18 ; Measure the width of a string in pixels TextWidth := $18 ; Measure the width of a string in pixels
;; .addr data ;;; .addr data
;; .byte length ;;; .byte length
;; .word width (out) result in pixels ;;; .word width (out) result in pixels
DrawText := $19 ; Drawn at last SET_POS as left, baseline DrawText := $19 ; Drawn at last SET_POS as left, baseline
;; .addr data ;;; .addr data
;; .byte length ;;; .byte length
;;; -------------------------------------------------- ;;; --------------------------------------------------
;;; Utility Commands ;;; Utility Commands
SetZP1 := $1A ; Configure lower half of ZP usage by API (speed vs. convenience) SetZP1 := $1A ; Configure lower half of ZP usage by API (speed vs. convenience)
SetZP2 := $1B ; Configure upper half ZP usage by API (speed vs. convenience) SetZP2 := $1B ; Configure upper half ZP usage by API (speed vs. convenience)
;; .byte preserve 0=stash/no auto restore; 1=restore now and onward ;;; .byte preserve 0=stash/no auto restore; 1=restore now and onward
Version := $1C ; Get toolkit version Version := $1C ; Get toolkit version
;; .byte (out) major ;;; .byte (out) major
;; .byte (out) minor ;;; .byte (out) minor
;; .byte (out) patch ;;; .byte (out) patch
;; .byte (out) status ;;; .byte (out) status
;; .word (out) number ;;; .word (out) number
;;; ================================================== ;;; ==================================================
;;; Mouse Graphics Tool Kit Calls ;;; Mouse Graphics Tool Kit Calls
@ -171,61 +171,61 @@ Version := $1C ; Get toolkit version
;;; -------------------------------------------------- ;;; --------------------------------------------------
;;; Initialization Calls ;;; Initialization Calls
StartDeskTop := $1D ; Inits state, registers interrupt handler, draws desktop StartDeskTop := $1D ; Inits state, registers interrupt handler, draws desktop
;; .byte machine ROM FBB3 ($06 = IIe or later) ;;; .byte machine ROM FBB3 ($06 = IIe or later)
;; .byte subid ROM FBC0 ($EA = IIe, $E0 = IIe enh/IIgs, $00 = IIc/IIc+) ;;; .byte subid ROM FBC0 ($EA = IIe, $E0 = IIe enh/IIgs, $00 = IIc/IIc+)
;; .byte op_sys 0=ProDOS, 1=Pascal ;;; .byte op_sys 0=ProDOS, 1=Pascal
;; .byte slot_num: Mouse slot, 0 = search (will be filled in) ;;; .byte slot_num: Mouse slot, 0 = search (will be filled in)
;; .byte use_interrupts 0=passive, 1=interrupt ;;; .byte use_interrupts 0=passive, 1=interrupt
;; .addr sysfontptr ;;; .addr sysfontptr
;; .addr savearea buffer for saving screen data (e.g. behind menus) ;;; .addr savearea buffer for saving screen data (e.g. behind menus)
;; .word savesize bytes ;;; .word savesize bytes
StopDeskTop := $1E ; Deallocates interrupt, hides cursor StopDeskTop := $1E ; Deallocates interrupt, hides cursor
;; (no parameters) ;;; (no parameters)
SetUserHook := $1F SetUserHook := $1F
;; .byte hook_id 0=before, 1=after event checking ;;; .byte hook_id 0=before, 1=after event checking
;; .addr routine_ptr 0=remove hook_id ;;; .addr routine_ptr 0=remove hook_id
AttachDriver := $20 ; Install pointer driver; A=0 on success, $95 if mouse disabled AttachDriver := $20 ; Install pointer driver; A=0 on success, $95 if mouse disabled
;; .addr hook Mouse hook routine to install ;;; .addr hook Mouse hook routine to install
;; .addr mouse_state (out) Address of mouse state (.word x, y; .byte status) ;;; .addr mouse_state (out) Address of mouse state (.word x, y; .byte status)
ScaleMouse := $21 ; Set mouse/screen scaling ScaleMouse := $21 ; Set mouse/screen scaling
;; .byte x_exponent x-scale factor for mouse, 0...3 ;;; .byte x_exponent x-scale factor for mouse, 0...3
;; .byte y_exponent y-scale factor for mouse, 0...3 ;;; .byte y_exponent y-scale factor for mouse, 0...3
KeyboardMouse := $22 ; Next operation will be performed by keyboard KeyboardMouse := $22 ; Next operation will be performed by keyboard
;; (no parameters) ;;; (no parameters)
GetIntHandler := $23 ; Get address of interrupt handler GetIntHandler := $23 ; Get address of interrupt handler
;; .addr handler (out) Address of interrupt handler (after cld) ;;; .addr handler (out) Address of interrupt handler (after cld)
;;; -------------------------------------------------- ;;; --------------------------------------------------
;;; Cursor Manager Calls ;;; Cursor Manager Calls
;;; Cursor record: ;;; Cursor record:
;;; ;;;
;;; .res 24 bitmap 2x12 byte bitmap (XOR'd after mask) ;;; .res 24 bitmap 2x12 byte bitmap (XOR'd after mask)
;;; .res 24 mask 2x12 byte mask (OR'd with screen) ;;; .res 24 mask 2x12 byte mask (OR'd with screen)
;;; .byte hotx hotspot coords (pixels) ;;; .byte hotx hotspot coords (pixels)
;;; .byte hoty ;;; .byte hoty
SetCursor := $24 ; Set cursor definition SetCursor := $24 ; Set cursor definition
;; (input is address of Cursor record) ;;; (input is address of Cursor record)
ShowCursor := $25 ; Return cursor to visibility ShowCursor := $25 ; Return cursor to visibility
;; (no parameters) ;;; (no parameters)
HideCursor := $26 ; Cursor hidden until ShowCursor call HideCursor := $26 ; Cursor hidden until ShowCursor call
;; (no parameters) ;;; (no parameters)
ObscureCursor := $27 ; Cursor hidden until moved ObscureCursor := $27 ; Cursor hidden until moved
;; (no parameters) ;;; (no parameters)
GetCursorAddr := $28 ; Get cursor definition GetCursorAddr := $28 ; Get cursor definition
;; .addr definition (out) Address of cursor record ;;; .addr definition (out) Address of cursor record
;;; -------------------------------------------------- ;;; --------------------------------------------------
;;; Event Manager Calls ;;; Event Manager Calls
@ -238,232 +238,230 @@ GetCursorAddr := $28 ; Get cursor definition
;;; .byte modifiers (0=none, 1=open-apple, 2=solid-apple, 3=both) ;;; .byte modifiers (0=none, 1=open-apple, 2=solid-apple, 3=both)
;;; if kind is event_kind_update: ;;; if kind is event_kind_update:
;;; .byte window_id ;;; .byte window_id
;;; if kind otherwise: ;;; otherwise:
;;; .word xcoord ;;; .word xcoord
;;; .word ycoord ;;; .word ycoord
CheckEvents := $29 ; Process mouse/kbd if GetEvent will be delayed. CheckEvents := $29 ; Process mouse/kbd if GetEvent will be delayed.
;; (no parameters) ;;; (no parameters)
GetEvent := $2A GetEvent := $2A
;; (parameter is address of Event record) ;;; (parameter is address of Event record)
FlushEvents := $2B FlushEvents := $2B
;; (no parameters) ;;; (no parameters)
PeekEvent := $2C PeekEvent := $2C
;; (parameter is address of Event record) ;;; (parameter is address of Event record)
PostEvent := $2D ; Post event to queue PostEvent := $2D ; Post event to queue
;; (parameter is address of Event record) ;;; (parameter is address of Event record)
SetKeyEvent := $2E ; If set, keypresses are ignored by MGTK SetKeyEvent := $2E ; If set, keypresses are ignored by Tool Kit
;; .byte handle_keys high bit set = ignore keyboard, otherwise check ;;; .byte handle_keys high bit set = ignore keyboard, otherwise check
;;; -------------------------------------------------- ;;; --------------------------------------------------
;;; Menu Manager Calls ;;; Menu Manager Calls
;;; Menu Bar record: ;;; Menu Bar record:
;;; ;;;
;;; .word count Number of menu bar items ;;; .word count Number of menu bar items
;;; (array of...) ;;; (array of...)
;;; .byte menu_id Menu identifier ;;; .byte menu_id Menu identifier
;;; .byte disabled Flag ;;; .byte disabled Flag
;;; .addr title Address of length-prefixed string ;;; .addr title Address of length-prefixed string
;;; .addr menu Address of Menu record ;;; .addr menu Address of Menu record
;;; .res 6 Reserved ;;; .res 6 reserved Reserved
;;; ... ;;; ...
;;; ;;;
;;; Menu record: ;;; Menu record:
;;; ;;;
;;; .word count Number of items in menu ;;; .word count Number of items in menu
;;; (array of...) ;;; (array of...)
;;; .res 5 Reserved ;;; .res 5 reserved Reserved
;;; .byte options bit 0=OA, 1=SA, 2=mark, 5=check, 6=filler, 7=disabled ;;; .byte options bit 0=OA, 1=SA, 2=mark, 5=check, 6=filler, 7=disabled
;;; .byte mark_char Custom mark character if mark option set ;;; .byte mark_char Custom mark character if mark option set
;;; .byte char1 ASCII code of shortcut #1 (e.g. uppercase B); or 0 ;;; .byte char1 ASCII code of shortcut #1 (e.g. uppercase B); or 0
;;; .byte char2 ASCII code of shortcut #2 (e.g. lowercase b, or same); or 0 ;;; .byte char2 ASCII code of shortcut #2 (e.g. lowercase b, or same); or 0
;;; .addr name Address of length-prefixed string ;;; .addr name Address of length-prefixed string
;;; ... ;;; ...
InitMenu := $2F InitMenu := $2F
;; .byte solid_char char code to use for solid apple glyph ;;; .byte solid_char char code to use for solid apple glyph
;; .byte open_char char code to use for open apple glyph ;;; .byte open_char char code to use for open apple glyph
;; .byte check_char char code to use for checkmark glyph ;;; .byte check_char char code to use for checkmark glyph
;; .byte control_char char code to use for control key glyph ;;; .byte control_char char code to use for control key glyph
SetMenu := $30 ; Configure (and draw) menu SetMenu := $30 ; Configure (and draw) menu
;; (input is address of Menu Bar record) ;;; (input is address of Menu Bar record)
MenuSelect := $31 ; Enter modal loop for handling mouse-down on menu bar MenuSelect := $31 ; Enter modal loop for handling mouse-down on menu bar
;; .byte menu_id (out) Top level menu identifier, or 0 if none ;;; .byte menu_id (out) Top level menu identifier, or 0 if none
;; .byte menu_item (out) Index (1-based) of item in menu, or 0 if none ;;; .byte menu_item (out) Index (1-based) of item in menu, or 0 if none
MenuKey := $32 ; Find menu item corresponding to keypress MenuKey := $32 ; Find menu item corresponding to keypress
;; .byte menu_id (out) ;;; .byte menu_id (out)
;; .byte menu_item (out) ;;; .byte menu_item (out)
;; .byte which_key ;;; .byte which_key
;; .byte key_mods bit 0=OA, bit 1=SA ;;; .byte key_mods bit 0=OA, bit 1=SA
HiliteMenu := $33 ; Toggle highlight state of menu HiliteMenu := $33 ; Toggle highlight state of menu
;; .byte menu_id ;;; .byte menu_id
DisableMenu := $34 DisableMenu := $34
;; .byte menu_id ;;; .byte menu_id
;; .byte disable 0=enable, 1=disable ;;; .byte disable 0=enable, 1=disable
DisableItem := $35 DisableItem := $35
;; .byte menu_id ;;; .byte menu_id
;; .byte menu_item ;;; .byte menu_item
;; .byte disable 0=enable, 1=disable ;;; .byte disable 0=enable, 1=disable
CheckItem := $36 CheckItem := $36
;; .byte menu_id ;;; .byte menu_id
;; .byte menu_item ;;; .byte menu_item
;; .byte check 0=unchecked, 1=checked ;;; .byte check 0=unchecked, 1=checked
SetMark := $37 SetMark := $37
;; .byte menu_id ;;; .byte menu_id
;; .byte menu_item ;;; .byte menu_item
;; .byte set_char 0=use checkmark, 1=use mark_char ;;; .byte set_char 0=use checkmark, 1=use mark_char
;; .byte mark_char char code to use for mark ;;; .byte mark_char char code to use for mark
;;; -------------------------------------------------- ;;; --------------------------------------------------
;;; Window Manager Calls ;;; Window Manager Calls
;;; WInfo record: ;;; WInfo record:
;;; ;;;
;;; .byte id ;;; .byte id
;;; .byte options option_* ;;; .byte options option_*
;;; .addr title ;;; .addr title
;;; .byte hscroll scroll_option_* ;;; .byte hscroll scroll_option_*
;;; .byte vscroll scroll_option_* ;;; .byte vscroll scroll_option_*
;;; .byte hthumbmax ;;; .byte hthumbmax
;;; .byte hthumbpos ;;; .byte hthumbpos
;;; .byte vthumbmax ;;; .byte vthumbmax
;;; .byte vthumbpos ;;; .byte vthumbpos
;;; .byte status ;;; .byte status
;;; .byte reserved ;;; .byte reserved
;;; .word mincontwidth minimum content size (horizontal) ;;; .word mincontwidth minimum content size (horizontal)
;;; .word maxcontwidth maximum content size (horizontal) ;;; .word maxcontwidth maximum content size (horizontal)
;;; .word mincontlength minimum content size (vertical) ;;; .word mincontlength minimum content size (vertical)
;;; .word maxcontlength maximum content size (vertical) ;;; .word maxcontlength maximum content size (vertical)
;;; GrafPort windowport GrafPort record ;;; GrafPort windowport GrafPort record
;;; .addr nextwinfo address of next lower window in stack ;;; .addr nextwinfo address of next lower window in stack
OpenWindow := $38 OpenWindow := $38
;; (input is address of WInfo record) ;;; (input is address of WInfo record)
CloseWindow := $39 CloseWindow := $39
;; .byte window_id ;;; .byte window_id
CloseAll := $3A CloseAll := $3A
;; (no parameters) ;;; (no parameters)
GetWinPtr := $3B ; Get pointer to window params by id; A=0 on success GetWinPtr := $3B ; Get pointer to window params by id; A=0 on success
;; .byte window_id ;;; .byte window_id
;; .addr window_ptr (out) winfo address ;;; .addr window_ptr (out) winfo address
GetWinPort := $3C ; Get drawing state of window GetWinPort := $3C ; Get drawing state of window
;; .byte window_id ;;; .byte window_id
;; .addr port (out) grafport address ;;; .addr port (out) grafport address
SetWinPort := $3D ; Update port of window SetWinPort := $3D ; Update port of window
;; .byte window_id ;;; .byte window_id
;; .addr port GrafPort to copy from ;;; .addr port GrafPort to copy from
BeginUpdate := $3E ; Respond to update event for window BeginUpdate := $3E ; Respond to update event for window
;; .byte window_id ;;; .byte window_id
EndUpdate := $3F EndUpdate := $3F
;; (no paramters) ;;; (no paramters)
FindWindow := $40 FindWindow := $40
;; .word mousex screen coordinates ;;; .word mousex screen coordinates
;; .word mousey ;;; .word mousey
;; .byte which_area (out) area_* ;;; .byte which_area (out) area_*
;; .byte window_id (out) of window ;;; .byte window_id (out) of window
FrontWindow := $41 ; Get id of top window FrontWindow := $41 ; Get id of top window
;; .byte window_id (out) window, or 0 if none ;;; .byte window_id (out) window, or 0 if none
SelectWindow := $42 ; Make window topmost SelectWindow := $42 ; Make window topmost
;; .byte window_id ;;; .byte window_id
TrackGoAway := $43 TrackGoAway := $43
;; .byte clicked (out) 0 = cancelled, 1 = close ;;; .byte clicked (out) 0 = cancelled, 1 = close
;; .byte ?? (out) ;;; .byte ?? (out)
;; .byte ?? (out) ;;; .byte ?? (out)
DragWindow := $44 DragWindow := $44
;; (input length 5 bytes) ;;; (input length 5 bytes)
;; .byte window_id ;;; .byte window_id
;; .word dragx mouse coords ;;; .word dragx mouse coords
;; .word dragy ;;; .word dragy
;; .byte moved high bit set if moved, clear if not ;;; .byte moved high bit set if moved, clear if not
GrowWindow := $45 GrowWindow := $45
;; .byte window_id ;;; .byte window_id
;; .word mousex ;;; .word mousex
;; .word mousey ;;; .word mousey
;; .byte itgrew (out) 0 = no change, 1 = moved ;;; .byte itgrew (out) 0 = no change, 1 = moved
ScreenToWindow := $46 ; Map screen coords to client coords ScreenToWindow := $46 ; Map screen coords to client coords
;; .byte window_id ;;; .byte window_id
;; .word screenx ;;; .word screenx
;; .word screeny ;;; .word screeny
;; .word windowx (out) ;;; .word windowx (out)
;; .word windowy (out) ;;; .word windowy (out)
WindowToScreen := $47 WindowToScreen := $47
;; .byte window_id ;;; .byte window_id
;; .word windowx ;;; .word windowx
;; .word windowy ;;; .word windowy
;; .word screenx (out) ;;; .word screenx (out)
;; .word screeny (out) ;;; .word screeny (out)
;;; -------------------------------------------------- ;;; --------------------------------------------------
;;; Control Manager Calls ;;; Control Manager Calls
FindControl := $48 FindControl := $48
;; .word mousex ;;; .word mousex
;; .word mousey ;;; .word mousey
;; .byte which_ctl ctl_* ;;; .byte which_ctl ctl_*
;; .byte which_part part_* ;;; .byte which_part part_*
SetCtlMax := $49 SetCtlMax := $49
;; .byte which_ctl ctl_*_scroll_bar ;;; .byte which_ctl ctl_*_scroll_bar
;; .byte ctlmax maximum value ;;; .byte ctlmax maximum value
TrackThumb := $4A TrackThumb := $4A
;; .byte which_ctl ctl_*_scroll_bar ;;; .byte which_ctl ctl_*_scroll_bar
;; .word mousex ;;; .word mousex
;; .word mousey ;;; .word mousey
;; .byte thumbpos (out) 0...255 ;;; .byte thumbpos (out) 0...255
;; .byte thumbmobed (out) 0 = no change, 1 = moved ;;; .byte thumbmobed (out) 0 = no change, 1 = moved
UpdateThumb := $4B UpdateThumb := $4B
;; .byte which_ctl ctl_*_scroll_bar ;;; .byte which_ctl ctl_*_scroll_bar
;; .byte thumbpos new position 0...250 ;;; .byte thumbpos new position 0...250
ActivateCtl := $4C ; Activate/deactivate scroll bar ActivateCtl := $4C ; Activate/deactivate scroll bar
;; .byte which_ctl ctl_*_scroll_bar ;;; .byte which_ctl ctl_*_scroll_bar
;; .byte activate 0=deactivate, 1=activate ;;; .byte activate 0=deactivate, 1=activate
;;; $4D ??? ;;; $4D ???
;; (input length: 16 bytes) ;;; (input length: 16 bytes)
;;; $4E ??? ;;; $4E ???
;; (input length: 2 bytes) ;;; (input length: 2 bytes)
;;; ================================================== ;;; ==================================================
;;; Graphics Primitives Constants ;;; Graphics Primitives Constants
;;; Used in GetWinPort / SetPortBits ;;; Used in GetWinPort / SetPortBits
screen_mapbits := $2000 ; Screen address screen_mapbits := $2000 ; Screen address
screen_mapwidth := $80 ; Stride in bytes screen_mapwidth := $80 ; Stride in bytes
;;; Used in SetPenMode ;;; Used in SetPenMode
pencopy := 0 pencopy := 0