a2d/mgtk.inc

785 lines
23 KiB
PHP
Raw Normal View History

2018-03-05 05:36:00 +00:00
;;; ============================================================
2018-02-21 16:06:38 +00:00
;;; MouseGraphics ToolKit (w/ Graphics Primitives)
2018-03-05 05:36:00 +00:00
;;; ============================================================
2018-01-29 05:18:00 +00:00
.scope MGTK
2018-01-29 05:18:00 +00:00
MLI := $4000
;; MLI-style call (jsr MLI ; .byte call ; .addr params)
;; Call from AUX (RAMRDON/RAMWRTON)
2018-03-05 05:36:00 +00:00
;;; ============================================================
2018-01-29 05:18:00 +00:00
;;; Graphics Primitives
2018-03-05 05:36:00 +00:00
;;; ============================================================
2018-05-26 07:35:28 +00:00
.struct Point
xcoord .word
ycoord .word
.endstruct
2018-02-18 20:49:59 +00:00
2018-05-26 07:35:28 +00:00
.struct Rect
x1 .word
y1 .word
x2 .word
y2 .word
.endstruct
2018-02-18 20:49:59 +00:00
2018-05-26 07:35:28 +00:00
.struct Pattern
2018-06-02 18:32:30 +00:00
row0 .byte
row1 .byte
row2 .byte
row3 .byte
row4 .byte
row5 .byte
row6 .byte
row7 .byte
2018-05-26 07:35:28 +00:00
.endstruct
2018-02-18 20:49:59 +00:00
2018-05-26 07:35:28 +00:00
.struct MapInfo
viewloc .tag Point
2018-06-02 18:32:30 +00:00
mapbits .word ; screen_mapbits=$2000 for windows, or bitmap bits
mapwidth .byte ; screen_mapwidth=$80 for windows, or stride for bitmap
2018-05-26 07:35:28 +00:00
reserved .byte
maprect .tag Rect ; a.k.a. cliprect
.endstruct
.struct GrafPort
;; MapInfo
viewloc .tag Point
mapbits .addr
mapwidth .byte
reserved .byte
maprect .tag Rect
pattern .tag Pattern
colormasks .byte 2 ; colormask_and, colormask_or
penloc .tag Point
penwidth .byte ; horizontal pen thickness
penheight .byte ; vertical pen thickness
penmode .byte
textback .byte ; text background
textfont .addr
.endstruct
2018-02-18 20:49:59 +00:00
2018-02-19 01:08:11 +00:00
;;; PolyList record:
2018-02-18 20:49:59 +00:00
;;; .byte count number of vertices in this polygon
;;; .byte last high bit set if there are more polygons
;;; Point vertex1
;;; Point vertex2
;;; ...
2018-05-26 07:35:28 +00:00
.struct Font
fonttype .byte ; 0=regular, $80=double-width
lastchar .byte ; char code of last character (usually $7F)
height .byte ; pixels (1-16)
2018-06-02 02:00:00 +00:00
charwidth .byte ; pixels, for each char
2018-05-26 07:35:28 +00:00
;; row0 .res N bits
;; row0right .res N bits (double-width only)
.endstruct
2018-02-19 01:08:11 +00:00
2018-02-20 05:32:47 +00:00
NoOp := $00 ; No-op
2018-03-01 03:02:39 +00:00
;;; (no parameters)
2018-01-29 08:57:55 +00:00
2018-01-29 05:18:00 +00:00
;;; --------------------------------------------------
;;; Initialization Commands
2017-09-11 02:40:52 +00:00
2018-01-29 08:57:55 +00:00
InitGraf := $01
2018-03-01 03:02:39 +00:00
;;; (no parameters)
2018-01-21 23:37:55 +00:00
2018-02-18 20:49:59 +00:00
SetSwitches := $02 ; Configure display switches
2018-02-18 23:28:33 +00:00
;;; .byte flags bit 0=hires, 1=page2, 2=mixed, 3=text
2018-01-29 05:18:00 +00:00
;;; --------------------------------------------------
;;; GrafPort Commands
2018-02-18 20:49:59 +00:00
InitPort := $03 ; Initialize GrafPort to standard values
2018-02-18 23:28:33 +00:00
;;; (input is address of GrafPort record)
2018-02-18 20:49:59 +00:00
SetPort := $04 ; Set current port as specified
2018-02-18 23:28:33 +00:00
;;; (input is address of GrafPort record)
2018-02-18 20:49:59 +00:00
GetPort := $05 ; Get pointer to current port
2018-02-18 23:28:33 +00:00
;;; .addr port (out)
2018-02-18 20:49:59 +00:00
SetPortBits := $06 ; Set just the mapinfo (viewloc, mapbits)
2018-02-18 23:28:33 +00:00
;;; (input is address of MapInfo record)
2018-01-29 16:25:56 +00:00
SetPenMode := $07 ; Set the current pen mode
2018-02-18 23:28:33 +00:00
;;; .byte mode pen*/notpen*
2018-01-29 16:25:56 +00:00
SetPattern := $08 ; Set the current pattern
2018-02-18 23:28:33 +00:00
;;; .res 8 pattern 8x8 pixel pattern for PaintRect calls
2017-10-07 20:59:25 +00:00
2018-01-29 16:25:56 +00:00
SetColorMasks := $09 ; Set the current color masks
2018-02-18 23:28:33 +00:00
;;; .byte and_mask
;;; .byte or_mask
2017-09-03 01:51:03 +00:00
2018-01-29 16:25:56 +00:00
SetPenSize := $0A ; Set the current pen size
2018-02-18 23:28:33 +00:00
;;; .byte penwidth horizontal pen thickness
;;; .byte penheight vertical pen thickness
2017-09-11 03:40:32 +00:00
2018-01-29 16:25:56 +00:00
SetFont := $0B ; Set the current font
2018-02-18 23:28:33 +00:00
;;; .addr textfont font definition
2018-01-29 16:25:56 +00:00
SetTextBG := $0C ; Set the current text background
2018-02-18 23:28:33 +00:00
;;; .byte backcolor 0=black, $7F=white
2017-09-03 01:51:03 +00:00
2018-01-29 05:18:00 +00:00
;;; --------------------------------------------------
;;; Drawing Commands
2018-02-18 20:49:59 +00:00
Move := $0D ; Set current pen location (relative)
2018-02-18 23:28:33 +00:00
;;; .word xdelta
;;; .word ydelta
2017-10-08 15:42:27 +00:00
2018-02-18 20:49:59 +00:00
MoveTo := $0E ; Set current pen location (absolute)
2018-02-18 23:28:33 +00:00
;;; Point pos
2017-09-01 15:15:05 +00:00
2018-02-18 20:49:59 +00:00
Line := $0F ; Draw line from current pen location (relative)
2018-02-18 23:28:33 +00:00
;;; .word xdelta
;;; .word ydelta
2017-09-11 03:40:32 +00:00
2018-02-18 20:49:59 +00:00
LineTo := $10 ; Draw line from current pen location (absolute)
2018-02-18 23:28:33 +00:00
;;; Point pos
2017-10-07 22:07:12 +00:00
2018-01-29 08:57:55 +00:00
PaintRect := $11 ; Fill rectangle with selected simple pattern/thickness
2018-02-18 23:28:33 +00:00
;;; Rect rect
2017-09-07 06:43:40 +00:00
2018-01-29 08:57:55 +00:00
FrameRect := $12 ; Draw rectangle with selected simple pattern/thickness
2018-02-18 23:28:33 +00:00
;;; Rect rect
2018-02-18 20:49:59 +00:00
InRect := $13 ; Is current position in bounds? A=$80 true, 0 false
2018-02-18 23:28:33 +00:00
;;; Rect rect
2017-09-09 19:18:06 +00:00
2018-01-29 08:57:55 +00:00
PaintBits := $14 ; Draw pattern
2018-02-18 23:28:33 +00:00
;;; (input is address of MapInfo record)
2017-09-02 16:44:33 +00:00
2018-01-29 08:57:55 +00:00
PaintPoly := $15
2018-02-19 01:08:11 +00:00
;;; (input is address of PolyList record)
2018-02-18 20:49:59 +00:00
FramePoly := $16 ; Draw multiple closed polygons
2018-02-19 01:08:11 +00:00
;;; (input is address of PolyList record)
2018-02-18 20:49:59 +00:00
InPoly := $17 ; Is current position in bounds? A=$80 true, 0 false
2018-02-19 01:08:11 +00:00
;;; (input is address of PolyList record)
2017-09-16 02:30:49 +00:00
2018-01-29 05:18:00 +00:00
;;; --------------------------------------------------
;;; Text Commands
2018-02-18 23:28:33 +00:00
TextWidth := $18 ; Measure the width of a string in pixels
;;; .addr data
;;; .byte length
;;; .word width (out) result in pixels
2018-03-01 03:02:39 +00:00
DrawText := $19 ; Drawn at penpos as left, baseline
2018-02-18 23:28:33 +00:00
;;; .addr data
;;; .byte length
2017-08-31 03:30:46 +00:00
2018-01-29 05:18:00 +00:00
;;; --------------------------------------------------
;;; Utility Commands
2018-02-20 05:32:47 +00:00
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)
2018-02-18 23:28:33 +00:00
;;; .byte preserve 0=stash/no auto restore; 1=restore now and onward
2017-12-31 05:22:06 +00:00
2018-02-18 20:49:59 +00:00
Version := $1C ; Get toolkit version
2018-02-18 23:28:33 +00:00
;;; .byte (out) major
;;; .byte (out) minor
;;; .byte (out) patch
;;; .byte (out) status
;;; .word (out) number
2018-01-29 05:18:00 +00:00
2018-03-05 05:36:00 +00:00
;;; ============================================================
2018-02-21 16:06:38 +00:00
;;; MouseGraphics ToolKit Calls
2018-03-05 05:36:00 +00:00
;;; ============================================================
2018-01-29 05:18:00 +00:00
;;; --------------------------------------------------
;;; Initialization Calls
2018-02-18 23:28:33 +00:00
StartDeskTop := $1D ; Inits state, registers interrupt handler, draws desktop
;;; .byte machine ROM FBB3 ($06 = IIe or later)
;;; .byte subid ROM FBC0 ($EA = IIe, $E0 = IIe enh/IIgs, $00 = IIc/IIc+)
;;; .byte op_sys 0=ProDOS, 1=Pascal
;;; .byte slot_num Mouse slot, 0 = search (will be filled in)
2018-02-18 23:28:33 +00:00
;;; .byte use_interrupts 0=passive, 1=interrupt
;;; .addr sysfontptr
;;; .addr savearea buffer for saving screen data (e.g. behind menus)
;;; .word savesize bytes
2017-10-15 05:09:00 +00:00
2018-02-18 23:28:33 +00:00
StopDeskTop := $1E ; Deallocates interrupt, hides cursor
;;; (no parameters)
2017-10-15 05:09:00 +00:00
2018-02-18 19:33:21 +00:00
SetUserHook := $1F
2018-02-18 23:28:33 +00:00
;;; .byte hook_id 0=before, 1=after event checking
;;; .addr routine_ptr 0=remove hook_id
2018-01-29 08:57:55 +00:00
2018-02-18 23:28:33 +00:00
AttachDriver := $20 ; Install pointer driver; A=0 on success, $95 if mouse disabled
;;; .addr hook Mouse hook routine to install
;;; .addr mouse_state (out) Address of mouse state (.word x, y; .byte status)
2018-02-18 19:33:21 +00:00
ScaleMouse := $21 ; Set mouse/screen scaling
2018-02-18 23:28:33 +00:00
;;; .byte x_exponent x-scale factor for mouse, 0...3
;;; .byte y_exponent y-scale factor for mouse, 0...3
2018-01-29 08:57:55 +00:00
2018-02-18 19:33:21 +00:00
KeyboardMouse := $22 ; Next operation will be performed by keyboard
2018-02-18 23:28:33 +00:00
;;; (no parameters)
2018-01-29 08:57:55 +00:00
2018-02-18 19:33:21 +00:00
GetIntHandler := $23 ; Get address of interrupt handler
2018-02-18 23:28:33 +00:00
;;; .addr handler (out) Address of interrupt handler (after cld)
2017-10-16 03:20:54 +00:00
2018-01-29 05:18:00 +00:00
;;; --------------------------------------------------
;;; Cursor Manager Calls
2018-02-18 19:33:21 +00:00
;;; Cursor record:
;;;
2018-05-26 07:35:28 +00:00
cursor_height := 12
cursor_width := 2
.struct Cursor
bits .byte 24 ; 2x12 byte bitmap (XOR'd after mask)
mask .byte 24 ; 2x12 byte mask (OR'd with screen)
hotspot .byte 2 ; x, y - hotspot coords (pixels)
.endstruct
2018-02-18 23:28:33 +00:00
SetCursor := $24 ; Set cursor definition
;;; (input is address of Cursor record)
2017-09-07 06:43:40 +00:00
2018-02-18 23:28:33 +00:00
ShowCursor := $25 ; Return cursor to visibility
;;; (no parameters)
2017-10-14 19:56:59 +00:00
2018-02-18 23:28:33 +00:00
HideCursor := $26 ; Cursor hidden until ShowCursor call
;;; (no parameters)
2017-09-07 06:43:40 +00:00
2018-02-18 23:28:33 +00:00
ObscureCursor := $27 ; Cursor hidden until moved
;;; (no parameters)
2018-02-18 19:33:21 +00:00
2018-02-18 23:28:33 +00:00
GetCursorAddr := $28 ; Get cursor definition
;;; .addr definition (out) Address of cursor record
2018-01-29 05:18:00 +00:00
;;; --------------------------------------------------
;;; Event Manager Calls
2017-10-14 19:51:25 +00:00
2018-07-05 04:12:20 +00:00
.struct Event
kind .byte ; event_kind_*
.union
.struct ; event_kind_down
key .byte ; ASCII code; high bit clear
modifiers .byte ; 0=none, 1=open-apple, 2=solid-apple, 3=both
.endstruct
.struct ; event_kind_update
window_id .byte
.endstruct
.struct ; otherwise
xcoord .word
ycoord .word
.endstruct
.endunion
.endstruct
2018-02-18 19:33:21 +00:00
CheckEvents := $29 ; Process mouse/kbd if GetEvent will be delayed.
2018-02-18 23:28:33 +00:00
;;; (no parameters)
2018-01-29 08:57:55 +00:00
GetEvent := $2A
2018-02-18 23:28:33 +00:00
;;; (parameter is address of Event record)
2017-09-01 02:05:41 +00:00
2018-01-29 08:57:55 +00:00
FlushEvents := $2B
2018-02-18 23:28:33 +00:00
;;; (no parameters)
2018-01-29 16:25:56 +00:00
PeekEvent := $2C
2018-02-18 23:28:33 +00:00
;;; (parameter is address of Event record)
2017-09-16 02:30:49 +00:00
2018-02-18 19:33:21 +00:00
PostEvent := $2D ; Post event to queue
2018-02-18 23:28:33 +00:00
;;; (parameter is address of Event record)
2018-02-18 19:33:21 +00:00
2018-02-18 23:28:33 +00:00
SetKeyEvent := $2E ; If set, keypresses are ignored by Tool Kit
;;; .byte handle_keys high bit set = ignore keyboard, otherwise check
2017-10-16 03:28:50 +00:00
2018-01-29 05:18:00 +00:00
;;; --------------------------------------------------
;;; Menu Manager Calls
2018-02-18 19:33:21 +00:00
;;; Menu Bar record:
;;;
2018-02-18 23:28:33 +00:00
;;; .word count Number of menu bar items
2018-02-18 19:33:21 +00:00
;;; (array of...)
2018-05-26 07:35:28 +00:00
.struct MenuBarItem
menu_id .byte ; Menu identifier
disabled .byte ; Flag
title .addr ; Address of length-prefixed string
menu .addr ; Address of Menu record
reserved .res 6 ; Reserved
.endstruct
2018-02-18 19:33:21 +00:00
;;; Menu record:
;;;
2018-04-02 15:00:43 +00:00
;;; .byte count Number of items in menu
2018-02-18 23:28:33 +00:00
;;; .res 5 reserved Reserved
2018-04-02 15:00:43 +00:00
;;; (array of...)
2018-05-26 07:35:28 +00:00
.struct MenuItem
options .byte ; bit 0=OA, 1=SA, 2=mark, 5=check, 6=filler, 7=disabled
mark_char .byte ; Custom mark character if mark option set
char1 .byte ; ASCII code of shortcut #1 (e.g. uppercase B); or 0
char2 .byte ; ASCII code of shortcut #2 (e.g. lowercase b, or same); or 0
name .addr ; Address of length-prefixed string
.endstruct
2018-02-18 19:33:21 +00:00
2018-01-29 08:57:55 +00:00
InitMenu := $2F
2018-02-18 23:28:33 +00:00
;;; .byte solid_char char code to use for solid apple glyph
;;; .byte open_char char code to use for open apple glyph
;;; .byte check_char char code to use for checkmark glyph
;;; .byte control_char char code to use for control key glyph
2018-01-29 08:57:55 +00:00
2018-02-18 23:28:33 +00:00
SetMenu := $30 ; Configure (and draw) menu
;;; (input is address of Menu Bar record)
2017-10-15 02:45:51 +00:00
2018-02-18 23:28:33 +00:00
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_item (out) Index (1-based) of item in menu, or 0 if none
2018-02-18 19:33:21 +00:00
MenuKey := $32 ; Find menu item corresponding to keypress
2018-02-18 23:28:33 +00:00
;;; .byte menu_id (out)
;;; .byte menu_item (out)
;;; .byte which_key
;;; .byte key_mods bit 0=OA, bit 1=SA
2018-02-18 19:33:21 +00:00
HiliteMenu := $33 ; Toggle highlight state of menu
2018-02-18 23:28:33 +00:00
;;; .byte menu_id
2017-10-15 02:45:51 +00:00
2018-01-29 08:57:55 +00:00
DisableMenu := $34
2018-02-18 23:28:33 +00:00
;;; .byte menu_id
;;; .byte disable 0=enable, 1=disable
2018-02-18 19:33:21 +00:00
2018-01-29 08:57:55 +00:00
DisableItem := $35
2018-02-18 23:28:33 +00:00
;;; .byte menu_id
;;; .byte menu_item
;;; .byte disable 0=enable, 1=disable
2018-02-18 19:33:21 +00:00
2018-01-29 08:57:55 +00:00
CheckItem := $36
2018-02-18 23:28:33 +00:00
;;; .byte menu_id
;;; .byte menu_item
;;; .byte check 0=unchecked, 1=checked
2018-02-18 19:33:21 +00:00
2018-01-29 08:57:55 +00:00
SetMark := $37
2018-02-18 23:28:33 +00:00
;;; .byte menu_id
;;; .byte menu_item
;;; .byte set_char 0=use checkmark, 1=use mark_char
;;; .byte mark_char char code to use for mark
2018-01-29 08:57:55 +00:00
2018-01-29 05:18:00 +00:00
;;; --------------------------------------------------
;;; Window Manager Calls
2018-05-26 07:35:28 +00:00
.struct Winfo
window_id .byte
options .byte ; option_*
title .addr
hscroll .byte ; scroll_option_*
vscroll .byte ; scroll_option_*
hthumbmax .byte
hthumbpos .byte
vthumbmax .byte
vthumbpos .byte
status .byte
reserved .byte
mincontwidth .word ; minimum content size (horizontal)
mincontheight .word ; minimum content size (vertical)
maxcontwidth .word ; maximum content size (horizontal)
maxcontheight .word ; maximum content size (vertical)
port .tag GrafPort
nextwinfo .addr ; address of next lower window in stack
.endstruct
2018-02-18 19:33:21 +00:00
2018-01-29 08:57:55 +00:00
OpenWindow := $38
2018-05-26 07:35:28 +00:00
;;; (input is address of Winfo record)
2017-09-01 02:05:41 +00:00
2018-01-29 08:57:55 +00:00
CloseWindow := $39
2018-02-18 23:28:33 +00:00
;;; .byte window_id
2017-08-31 03:30:46 +00:00
2018-01-29 08:57:55 +00:00
CloseAll := $3A
2018-02-18 23:28:33 +00:00
;;; (no parameters)
2018-01-29 08:57:55 +00:00
2018-02-18 19:33:21 +00:00
GetWinPtr := $3B ; Get pointer to window params by id; A=0 on success
2018-02-18 23:28:33 +00:00
;;; .byte window_id
;;; .addr window_ptr (out) winfo address
2017-09-16 02:30:49 +00:00
2018-04-06 15:05:35 +00:00
GetWinPort := $3C ; Get drawing state of window (possibly clipped)
2018-02-18 23:28:33 +00:00
;;; .byte window_id
2018-04-06 15:05:35 +00:00
;;; .addr port address of grafport to populate
2017-10-15 04:15:35 +00:00
2018-02-18 20:18:42 +00:00
SetWinPort := $3D ; Update port of window
2018-02-18 23:28:33 +00:00
;;; .byte window_id
;;; .addr port GrafPort to copy from
2017-10-15 04:15:35 +00:00
2018-02-18 20:18:42 +00:00
BeginUpdate := $3E ; Respond to update event for window
2018-02-18 23:28:33 +00:00
;;; .byte window_id
2018-01-29 08:57:55 +00:00
EndUpdate := $3F
2018-03-01 03:02:39 +00:00
;;; (no parameters)
2018-01-29 08:57:55 +00:00
FindWindow := $40
2018-02-18 23:28:33 +00:00
;;; .word mousex screen coordinates
;;; .word mousey
;;; .byte which_area (out) area_*
;;; .byte window_id (out) of window
2017-08-31 03:30:46 +00:00
2018-02-18 23:28:33 +00:00
FrontWindow := $41 ; Get id of top window
;;; .byte window_id (out) window, or 0 if none
2017-09-16 02:30:49 +00:00
2018-02-18 23:28:33 +00:00
SelectWindow := $42 ; Make window topmost
;;; .byte window_id
2017-10-12 04:33:23 +00:00
2018-01-29 08:57:55 +00:00
TrackGoAway := $43
2018-02-18 23:28:33 +00:00
;;; .byte clicked (out) 0 = cancelled, 1 = close
2017-08-31 03:30:46 +00:00
2018-01-29 08:57:55 +00:00
DragWindow := $44
2018-02-18 23:28:33 +00:00
;;; .byte window_id
;;; .word dragx mouse coords
;;; .word dragy
;;; .byte moved high bit set if moved, clear if not
2017-09-11 02:40:52 +00:00
2018-01-29 08:57:55 +00:00
GrowWindow := $45
2018-02-18 23:28:33 +00:00
;;; .byte window_id
;;; .word mousex
;;; .word mousey
;;; .byte itgrew (out) 0 = no change, 1 = moved
2017-09-02 02:54:04 +00:00
2018-03-01 03:02:39 +00:00
ScreenToWindow := $46 ; Map screen coords to content coords
2018-02-18 23:28:33 +00:00
;;; .byte window_id
;;; .word screenx
;;; .word screeny
;;; .word windowx (out)
;;; .word windowy (out)
2018-03-01 03:02:39 +00:00
WindowToScreen := $47 ; Map content coords to screen coords
2018-02-18 23:28:33 +00:00
;;; .byte window_id
;;; .word windowx
;;; .word windowy
;;; .word screenx (out)
;;; .word screeny (out)
2018-01-29 08:57:55 +00:00
2018-01-29 05:18:00 +00:00
;;; --------------------------------------------------
;;; Control Manager Calls
2018-01-29 08:57:55 +00:00
FindControl := $48
2018-02-18 23:28:33 +00:00
;;; .word mousex
;;; .word mousey
;;; .byte which_ctl ctl_*
;;; .byte which_part part_*
2017-09-01 05:12:02 +00:00
2018-02-18 20:49:59 +00:00
SetCtlMax := $49
2018-02-18 23:28:33 +00:00
;;; .byte which_ctl ctl_*_scroll_bar
;;; .byte ctlmax maximum value
2017-09-02 02:54:04 +00:00
2018-01-29 08:57:55 +00:00
TrackThumb := $4A
2018-02-18 23:28:33 +00:00
;;; .byte which_ctl ctl_*_scroll_bar
;;; .word mousex
;;; .word mousey
;;; .byte thumbpos (out) 0...255
;;; .byte thumbmoved (out) 0 = no change, 1 = moved
2017-08-31 03:30:46 +00:00
2018-01-29 08:57:55 +00:00
UpdateThumb := $4B
2018-02-18 23:28:33 +00:00
;;; .byte which_ctl ctl_*_scroll_bar
;;; .byte thumbpos new position 0...250
2017-09-11 02:40:52 +00:00
2018-02-18 20:18:42 +00:00
ActivateCtl := $4C ; Activate/deactivate scroll bar
2018-02-18 23:28:33 +00:00
;;; .byte which_ctl ctl_*_scroll_bar
;;; .byte activate 0=deactivate, 1=activate
2018-02-18 20:18:42 +00:00
;;; $4D ???
2018-02-18 23:28:33 +00:00
;;; (input length: 16 bytes)
2018-01-29 08:57:55 +00:00
2018-02-18 20:18:42 +00:00
;;; $4E ???
2018-02-18 23:28:33 +00:00
;;; (input length: 2 bytes)
2018-03-05 05:36:00 +00:00
;;; ============================================================
2018-01-29 05:18:00 +00:00
;;; Graphics Primitives Constants
2018-01-29 08:57:55 +00:00
;;; Used in GetWinPort / SetPortBits
2018-02-18 23:28:33 +00:00
screen_mapbits := $2000 ; Screen address
screen_mapwidth := $80 ; Stride in bytes
2018-01-29 05:18:00 +00:00
;;; Used in SetPenMode
2018-02-18 20:49:59 +00:00
pencopy := 0
penOR := 1
penXOR := 2
penBIC := 3
notpencopy := 4
notpenOR := 5
notpenXOR := 6
notpenBIC := 7
2018-01-29 05:18:00 +00:00
;;; Used in SetZP1
zp_overwrite := 0
zp_preserve := 1<<7
2017-09-21 15:09:11 +00:00
2018-02-19 01:08:11 +00:00
;;; Used in GrafPorts
2018-01-29 05:18:00 +00:00
colormask_and := $FF
colormask_or := $00
2018-02-07 05:59:25 +00:00
textbg_black := $00
2018-01-29 05:18:00 +00:00
textbg_white := $7F
2018-03-05 05:36:00 +00:00
;;; ============================================================
2018-02-21 16:06:38 +00:00
;;; MouseGraphics ToolKit Constants
2018-01-29 05:18:00 +00:00
;;; Used in GetEvent
2018-11-18 04:34:17 +00:00
.enum EventKind
no_event = 0 ; No mouse or keypress
button_down = 1 ; Mouse button was depressed
button_up = 2 ; Mouse button was released
key_down = 3 ; Key was pressed
drag = 4 ; Mouse button still down
apple_key = 5 ; Mouse button was depressed, modifier key down
update = 6 ; Window update needed
.endenum
2018-01-29 05:18:00 +00:00
2018-02-04 07:22:56 +00:00
event_modifier_open_apple := 1 << 0
event_modifier_solid_apple := 1 << 1
2018-01-29 05:18:00 +00:00
;;; Used in FindWindow
2018-11-18 04:34:17 +00:00
.enum Area
desktop = 0
menubar = 1
content = 2 ; Includes scroll bars
dragbar = 3
grow_box = 4
close_box = 5
.endenum
2018-01-29 05:18:00 +00:00
;;; Used in FindControl, TrackThumb, UpdateThumb
2018-11-18 04:34:17 +00:00
.enum Ctl
not_a_control = 0
vertical_scroll_bar = 1
horizontal_scroll_bar = 2
dead_zone = 3
.endenum
2018-01-29 05:18:00 +00:00
;;; Used in FindControl
2018-11-18 04:34:17 +00:00
.enum Part
up_arrow = 1
left_arrow = 1
down_arrow = 2
right_arrow = 2
page_up = 3
page_left = 3
page_down = 4
page_right = 4
thumb = 5
.endenum
2018-01-29 05:18:00 +00:00
;;; Used in OpenWindow
2018-11-18 04:34:17 +00:00
.enum Option
dialog_box = 1 << 0
go_away_box = 1 << 1
grow_box = 1 << 2
.endenum
.enum Scroll
option_none = 0
option_present = 1 << 7
option_thumb = 1 << 6
option_active = 1 << 0
option_normal = Scroll::option_present | Scroll::option_thumb | Scroll::option_active
.endenum
2018-01-29 05:18:00 +00:00
2018-01-30 07:34:12 +00:00
;;; Used in menu structs
2018-11-18 04:34:17 +00:00
.enum MenuOpt
open_apple = 1 << 0
solid_apple = 1 << 1
item_has_mark = 1 << 2
item_is_checked = 1 << 5
item_is_filler = 1 << 6
disable_flag = 1 << 7
.endenum
2018-01-30 07:34:12 +00:00
2018-02-07 05:59:25 +00:00
disablemenu_enable := 0
disablemenu_disable := 1
disableitem_enable := 0
disableitem_disable := 1
2018-02-14 02:53:02 +00:00
checkitem_uncheck := 0
checkitem_check := 1
2018-02-14 03:15:45 +00:00
;;; Used in ActivateCtl
activatectl_deactivate := 0
activatectl_activate := 1
2018-02-05 03:13:21 +00:00
;;; Response from InRect/InPoly
2018-02-04 04:06:16 +00:00
inrect_inside := $80
inrect_outside := $00
2018-02-05 03:13:21 +00:00
inpoly_inside := $80
inpoly_outside := $00
2018-02-04 04:06:16 +00:00
2018-03-05 05:36:00 +00:00
;;; ============================================================
2018-02-13 05:14:23 +00:00
;;; Offsets
short_event_size := 4 ; events that don't have mouse coordinates
event_size := 5 ; any kind of event
2018-05-26 07:35:28 +00:00
;;; ============================================================
;;; Errors
2018-11-18 04:34:17 +00:00
.enum Error
empty_object = $81
bad_object = $82
font_too_big = $83
invalid_op_sys = $90
no_mouse = $92
invalid_irq_setting = $93
invalid_hook = $94
desktop_already_initialized = $95
irq_in_use = $97
invalid_event = $98
event_queue_full = $99
menu_not_found = $9A
menu_item_not_found = $9B
insufficient_savebehind_area = $9C
window_already_exists = $9D
window_id_required = $9E
window_not_found = $9F
no_active_window = $A0
window_not_draggable = $A1
window_not_resizable = $A2
window_obscured = $A3
control_not_found = $A4
.endenum
2018-01-29 05:18:00 +00:00
.endscope ; MGTK
2017-09-01 05:39:06 +00:00
2018-03-05 05:36:00 +00:00
;;; ============================================================
;;; Macros
2018-01-29 05:18:00 +00:00
;;; Call an MGTK entry point:
;;; MGTK_CALL n - params is $0000
;;; MGTK_CALL n, params_addr
;;; MGTK_CALL m, params_addr, label - params_addr is labeled for modifying
2018-01-29 05:18:00 +00:00
.macro MGTK_CALL op, addr, label
jsr MGTK::MLI
.byte op
2017-09-07 04:33:22 +00:00
.if .paramcount > 2
label := *
.endif
2017-09-07 06:43:40 +00:00
.if .paramcount > 1
.addr addr
2017-09-07 06:43:40 +00:00
.else
.addr 0
.endif
.endmacro
;;; ------------------------------------
;;; Rect definition. Option fifth param gives scope.
;;; DEFINE_RECT 0,0,20,30
;;; DEFINE_RECT 0,0,20,30,rect ; rect::x1, rect::y1, rect::x2, rect::y2
.macro DEFINE_RECT left, top, right, bottom, opt_scope
2018-01-31 03:04:33 +00:00
.if .paramcount > 4
.scope opt_scope
2018-01-31 03:04:33 +00:00
x1: .word left
y1: .word top
x2: .word right
y2: .word bottom
.endscope
2018-01-31 03:04:33 +00:00
.else
2018-01-30 07:34:12 +00:00
.word left
.word top
.word right
.word bottom
2018-01-31 03:04:33 +00:00
.endif
2018-01-30 07:34:12 +00:00
.endmacro
;;; Point definition. Option third param gives scope.
;;; DEFINE_POINT 10,20
;;; DEFINE_POINT 10,20,pt ; pt::xcoord, pt::ycoord
.macro DEFINE_POINT left, top, opt_scope
2018-01-31 05:22:13 +00:00
.if .paramcount > 2
.scope opt_scope
2018-01-31 05:22:13 +00:00
xcoord: .word left
ycoord: .word top
.endscope
2018-01-31 05:22:13 +00:00
.else
2018-01-30 07:34:12 +00:00
.word left
.word top
2018-01-31 05:22:13 +00:00
.endif
2018-01-30 07:34:12 +00:00
.endmacro
;;; String definition w/ inline data, for use with DrawText
;;; DEFINE_STRING "abc"
;;; DEFINE_STRING {"Ring a bell",$07,"!!!"} ; control characters
;;; Optional second param gives label to internal Pascal string
.macro DEFINE_STRING str, opt_label
.local data
.local end
.addr data ; textptr
.if .paramcount > 1
opt_label:
.endif
.byte end - data ; textlen
2017-09-28 19:24:41 +00:00
data: .byte str
2017-09-13 04:27:27 +00:00
end:
.endmacro
2017-09-04 04:47:45 +00:00
2018-01-30 07:34:12 +00:00
;;; Menus (common cases; other options are possible)
.macro DEFINE_MENU_BAR count
.byte count ; num menus
.byte 0 ; reserved
.endmacro
.macro DEFINE_MENU_BAR_ITEM id, label, menu
.byte id ; menu id
.byte 0 ; disable flag
.addr label ; title pointer
.addr menu ; pointer to menu
.res 6, 0 ; 6 reserved bytes
.endmacro
.macro DEFINE_MENU count
.byte count ; num items
.res 5, 0 ; 5 reserved bytes
.endmacro
.macro DEFINE_MENU_ITEM saddr, shortcut1, shortcut2
.if .paramcount > 1
2018-11-18 04:34:17 +00:00
.byte MGTK::MenuOpt::open_apple ; option byte
2018-01-30 07:58:53 +00:00
.byte 0 ; mark_char
.byte shortcut1 ; char1
.byte shortcut2 ; char2
.addr saddr ; item_str_pointer
2018-01-30 07:34:12 +00:00
.else
.byte 0 ; option byte
2018-01-30 07:58:53 +00:00
.byte 0 ; mark_char
.byte 0 ; char1
.byte 0 ; char2
.addr saddr ; item_str_pointer
2018-01-30 07:34:12 +00:00
.endif
.endmacro
.macro DEFINE_MENU_SEPARATOR
2018-11-18 04:34:17 +00:00
.byte MGTK::MenuOpt::item_is_filler ; option byte
2018-01-30 07:58:53 +00:00
.byte 0 ; mark_char
.byte 19 ; char1 - Ctrl+S for separator ???
.byte 0 ; char2
.addr 0 ; item_str_pointer
2018-01-30 07:34:12 +00:00
.endmacro
;;; ------------------------------------
2017-09-29 20:57:02 +00:00
2018-01-29 05:18:00 +00:00
;;; Define pattern for PaintBits - low 7 bits are reversed
;;; e.g. .byte px(%1000000)
.define px(bits) (((bits&$40)>>6)|((bits&$20)>>4)|((bits&$10)>>2)|(bits&$8)|((bits&$4)<<2)|((bits&$2)<<4)|((bits&$1)<<6))