a2d/mgtk.inc

722 lines
23 KiB
PHP
Raw Normal View History

;;; ==================================================
2018-01-29 05:18:00 +00:00
;;; Mouse Graphics Tool Kit (w/ Graphics Primitives)
;;; ==================================================
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-01-29 05:18:00 +00:00
;;; ==================================================
;;; Graphics Primitives
;;; ==================================================
2018-01-29 08:57:55 +00:00
NoOp := $00 ; No-op
;; (input length 0 bytes)
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-01-21 23:37:55 +00:00
2018-01-29 08:57:55 +00:00
SetSwitches := $02 ; Configure display switches
;; (input length 1 byte)
;; Turns on 80 col/DHR, and then:
;; bit 0: LoRes if clear, HiRes if set
;; bit 1: Page 1 if clear, Page 2 if set
;; bit 2: Full screen if clear, split screen if set
;; bit 3: Graphics if clear, text if set
2018-01-29 05:18:00 +00:00
;;; --------------------------------------------------
;;; GrafPort Commands
InitPort := $03 ; Get screen state
2017-09-11 02:40:52 +00:00
;; (input length 0 bytes)
2017-10-07 20:59:25 +00:00
;; (output length 36 bytes)
2018-01-29 16:25:56 +00:00
;; .word viewloc x
;; .word viewloc y
;; .addr mapbits screen_mapbits
;; .word mapwidth screen_mapwidth
;; .word maprect_x1
;; .word maprect_y1
;; .word maprect_x2 560-1
;; .word maprect_y2 192-1
;; .res 8 pattern
2017-09-14 04:35:23 +00:00
;; .byte mskand AND mask, default $FF
;; .byte mskor ORA mask, default $00
2017-10-07 20:59:25 +00:00
;; .word xpos
;; .word ypos
2018-01-29 16:25:56 +00:00
;; .byte penwidth horizontal pen thickness
;; .byte penheight vertical pen thickness
;; .byte penmode
;; .byte textback text background
;; .addr textfont
2017-09-16 03:04:56 +00:00
2018-01-29 05:18:00 +00:00
SetPort := $04 ; Set full drawing state
2017-09-11 02:40:52 +00:00
;; (input length 36 bytes)
;; .word left pixels from screen edge
;; .word top
2018-01-29 16:25:56 +00:00
;; .addr mapbits screen_mapbits
;; .word mapwidth screen_mapwidth
;; .word maprect_x1 pixels scrolled
;; .word maprect_y1
;; .word maprect_x2 pixels
;; .word maprect_y2
;; .res 8 pattern
2017-09-14 04:38:35 +00:00
;; .byte mskand AND mask, default $FF
;; .byte mskor ORA mask, default $00
2017-10-07 20:59:25 +00:00
;; .word xpos
;; .word ypos
2018-01-29 16:25:56 +00:00
;; .byte penwidth horizontal pen thickness
;; .byte penheight vertical pen thickness
;; .byte penmode
;; .byte textback text background
;; .addr textfont
2018-01-29 16:25:56 +00:00
GetPort := $05 ; Get pointer to current grafport
2017-09-16 02:30:49 +00:00
;; (input length 0 bytes)
2017-10-12 15:04:27 +00:00
;; (output length 2 bytes)
2018-01-29 16:25:56 +00:00
;; .addr port (out)
2017-09-16 02:30:49 +00:00
2018-01-29 16:25:56 +00:00
SetPortBits := $06 ; Set just the drawing port, subset of full state
2017-09-11 02:40:52 +00:00
;; (input length 16 bytes)
2017-09-02 04:02:00 +00:00
;; .word left pixels from screen edge
;; .word top
2018-01-29 16:25:56 +00:00
;; .addr mapbits screen_mapbits ($2000)
;; .word mapwidth screen_mapwidth ($80)
;; .word maprect_x1
;; .word maprect_y1
;; .word maprect_x2
;; .word maprect_y2
SetPenMode := $07 ; Set the current pen mode
2017-09-11 02:40:52 +00:00
;; (input length 1 byte)
2017-10-08 03:22:39 +00:00
;; .byte mode (>=4 also sets eor mask to $7f)
2018-01-21 23:37:55 +00:00
;; 0 = white (???)
;; 2 = black (???)
2018-01-29 16:25:56 +00:00
SetPattern := $08 ; Set the current pattern
2017-09-11 02:40:52 +00:00
;; (input length 8 bytes)
2018-01-29 05:18:00 +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
2017-10-07 20:59:25 +00:00
;; (input length 2 bytes)
;; .byte mskand
;; .byte mskor
2017-09-03 01:51:03 +00:00
2018-01-29 16:25:56 +00:00
SetPenSize := $0A ; Set the current pen size
2017-09-11 03:40:32 +00:00
;; (input length 2 bytes)
2018-01-29 16:25:56 +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
;; (input length 2 bytes)
2018-01-29 16:25:56 +00:00
;; .addr textfont font definition (see below)
2018-01-29 16:25:56 +00:00
SetTextBG := $0C ; Set the current text background
2017-09-11 02:40:52 +00:00
;; (input length 1 byte)
2017-09-19 05:51:24 +00:00
;; .byte mask
2017-09-03 01:51:03 +00:00
2018-01-29 05:18:00 +00:00
;;; --------------------------------------------------
;;; Drawing Commands
2018-01-29 08:57:55 +00:00
Move := $0D ; Adjust start of subsequent DRAW_TEXT, DRAW_LINE
2017-10-08 15:42:27 +00:00
;; (input length 4 bytes)
;; .word xdelta
;; .word ydelta
2018-01-29 16:25:56 +00:00
MoveTo := $0E ; Start of subsequent DRAW_TEXT, DRAW_LINE
2017-09-11 02:40:52 +00:00
;; (input length 4 bytes)
2017-09-19 04:43:35 +00:00
;; .word xcoord
;; .word ycoord
2017-09-01 15:15:05 +00:00
2018-01-29 16:25:56 +00:00
Line := $0F ; Draw line (from SET_POS)
2017-09-11 03:40:32 +00:00
;; (input length 4 bytes)
2017-09-19 04:43:35 +00:00
;; .word xdelta signed, delta in pixels
;; .word ydelta
2017-09-11 03:40:32 +00:00
2018-01-29 16:25:56 +00:00
LineTo := $10 ; Draw line (from SET_POS)
2017-10-07 22:07:12 +00:00
;; (input length 4 bytes)
;; .word xcoord end coords in pixels
;; .word ycoord
2018-01-29 08:57:55 +00:00
PaintRect := $11 ; Fill rectangle with selected simple pattern/thickness
2017-09-11 02:40:52 +00:00
;; (input length 8 bytes)
2017-09-07 06:43:40 +00:00
;; .word left (includes scroll pos)
;; .word top
;; .word right pixels
;; .word bottom
2018-01-29 08:57:55 +00:00
FrameRect := $12 ; Draw rectangle with selected simple pattern/thickness
2017-09-11 02:40:52 +00:00
;; (input length 8 bytes)
;; .word left pixels
2017-09-07 06:43:40 +00:00
;; .word top
;; .word right
2017-09-07 06:43:40 +00:00
;; .word bottom
2017-09-02 16:44:33 +00:00
2018-01-29 08:57:55 +00:00
InRect := $13 ; Is pos (via SET_POS) in bounds? Returns true/false in A
2017-09-11 02:40:52 +00:00
;; (input length 8 bytes)
2017-09-09 19:18:06 +00:00
;; .word left
;; .word top
;; .word right
;; .word bottom
2018-01-29 08:57:55 +00:00
PaintBits := $14 ; Draw pattern
2017-09-11 02:40:52 +00:00
;; (input length 16 bytes)
2017-09-10 00:43:37 +00:00
;; .word left
;; .word top
2017-09-25 00:57:57 +00:00
;; .addr bitmap bitmap is 7 bits per byte, 0 = black, 1 = white
;; .byte stride bitmap width in bytes
;; .byte 0 ???
2018-01-29 16:25:56 +00:00
;; .word x1 offset within bitmap definition (pixels)
;; .word y1
;; .word x2
;; .word y2
2017-09-02 16:44:33 +00:00
2018-01-29 08:57:55 +00:00
PaintPoly := $15
2017-09-16 02:30:49 +00:00
;; (input length 0 bytes)
2018-01-29 08:57:55 +00:00
FramePoly := $16 ; Draw multiple closed polygons
2017-09-16 02:30:49 +00:00
;; (input length 0 bytes)
2017-10-14 06:23:31 +00:00
;; Address points at struct:
;; .byte points count
;; .byte flag high bit clear if this is last polygon, set if not
;; .word x1, y1
;; .word x2, y2
;; ...
2017-09-16 02:30:49 +00:00
2018-01-29 16:38:23 +00:00
InPoly := $17
2017-09-16 02:30:49 +00:00
;; (input length 0 bytes)
2018-01-29 05:18:00 +00:00
;;; --------------------------------------------------
;;; Text Commands
2018-01-29 08:57:55 +00:00
TextWidth := $18 ; Measure the width of a string in pixels
2017-09-11 02:40:52 +00:00
;; (input length 3 bytes)
;; .addr data
;; .byte length
;; .word width result in pixels
2018-01-29 08:57:55 +00:00
DrawText := $19 ; Drawn at last SET_POS as left, baseline
2017-09-11 02:40:52 +00:00
;; (input length 3 bytes)
2017-08-31 03:30:46 +00:00
;; .addr data
;; .byte length
2018-01-29 05:18:00 +00:00
;;; --------------------------------------------------
;;; Utility Commands
2018-01-29 08:57:55 +00:00
SetZP1 := $1A ; Configure ZP usage by API (speed vs. convenience)
2017-09-11 02:40:52 +00:00
;; (input length 1 byte)
2017-09-21 15:09:11 +00:00
;; .byte flag (AWS_CZP_*; high bit set = preserve ZP during calls)
2018-01-29 08:57:55 +00:00
SetZP2 := $1B ; Stash or restore lower 128 bytes of ZP; calls are idempotent
2017-12-31 05:22:06 +00:00
;; (input length 1 byte)
;; .byte flag (high bit set = stash ZP, clear = unstash ZP)
2018-01-29 08:57:55 +00:00
Version := $1C ; ???
2018-01-29 05:18:00 +00:00
;;; ==================================================
;;; Mouse Graphics Tool Kit Calls
;;; ==================================================
;;; --------------------------------------------------
;;; Initialization Calls
2018-01-29 08:57:55 +00:00
StartDeskTop := $1D ; Inits state, registers interrupt handler, draws desktop
2017-10-15 05:09:00 +00:00
;; (input length 12 byte)
;; ???
2018-01-29 08:57:55 +00:00
StopDeskTop := $1E ; Deallocates interrupt, hides cursor
2017-10-15 05:09:00 +00:00
;; (no parameters; pass $0000 as address)
2018-01-29 08:57:55 +00:00
;;; $1F ???
SetUserHook := $20 ; Install mouse hook; A=0 on success, $95 if mouse disabled
;; NOTE: Doesn't set the internal flag - buggy ???
;; (input length 2 bytes)
;; (output length 2 bytes)
;; .addr hook Mouse hook routine to install
;; .addr mouse_state (out) Address of mouse state (.word x, y; .byte status)
2018-01-29 08:57:55 +00:00
ScaleMouse := $21 ; ???
KeyboardMouse := $22 ; ???
GetIntHandler := $23 ; Get address of interrupt handler
2017-10-16 03:20:54 +00:00
;; (input length 0)
;; (output length 2 bytes)
;; .addr handler (out) Address of interrupt handler (after cld)
2018-01-29 05:18:00 +00:00
;;; --------------------------------------------------
;;; Cursor Manager Calls
SetCursor := $24 ; Set cursor definition
2017-09-19 04:32:46 +00:00
;; (input not copied)
;; .res 24 bitmap 2x12 byte bitmap
;; .res 24 mask 2x12 byte mask
;; .byte hotx hotspot coords
2017-09-19 04:32:46 +00:00
;; .byte hoty
2018-01-29 05:18:00 +00:00
ShowCursor := $25 ; Return cursor to visibility
2017-09-11 02:40:52 +00:00
;; (no parameters; pass $0000 as address)
2017-09-07 06:43:40 +00:00
2018-01-29 05:18:00 +00:00
HideCursor := $26 ; Cursor hidden until ShowCursor call
2017-10-14 19:56:59 +00:00
;; (no parameters; pass $0000 as address)
2018-01-29 05:18:00 +00:00
ObscureCursor := $27 ; Cursor hidden until moved
2017-09-11 02:40:52 +00:00
;; (no parameters; pass $0000 as address)
2017-09-07 06:43:40 +00:00
2018-01-29 05:18:00 +00:00
GetCursorAddr := $28 ; Get cursor definition
2017-10-14 19:51:25 +00:00
;; (input length 0 bytes)
;; (output length 2 bytes)
2018-01-29 05:18:00 +00:00
;; .addr definition See SetCursor
;;; --------------------------------------------------
;;; Event Manager Calls
2017-10-14 19:51:25 +00:00
2018-01-29 08:57:55 +00:00
CheckEvents := $29 ; ???
GetEvent := $2A
2017-09-11 02:40:52 +00:00
;; (input length 0 bytes)
;; (output length 5 bytes)
2018-02-01 19:30:03 +00:00
;; .byte kind
2018-02-03 04:10:19 +00:00
;; if kind is event_kind_key_down:
;; .byte key (ASCII code; high bit clear)
2018-02-05 05:05:31 +00:00
;; .byte modifiers (0=none, 1=open-apple, 2=solid-apple, 3=both)
2018-02-01 19:30:03 +00:00
;; if kind otherwise:
2017-09-09 03:45:11 +00:00
;; .word xcoord
;; .word ycoord
2017-09-01 02:05:41 +00:00
2018-01-29 08:57:55 +00:00
FlushEvents := $2B
2017-09-11 02:40:52 +00:00
;; (no parameters; pass $0000 as address)
2018-01-29 16:25:56 +00:00
PeekEvent := $2C
2017-09-16 02:30:49 +00:00
;; (input length 0 bytes)
2018-02-01 19:30:03 +00:00
PostEvent := $2D ; Set pending input kind (mouse or keyboard)
2017-09-11 02:40:52 +00:00
;; (input length 5 bytes)
2018-02-01 19:30:03 +00:00
;; .byte kind
2018-02-03 04:10:19 +00:00
;; if kind is event_kind_key_down:
;; .byte key ASCII code; high bit clear
2018-02-05 05:05:31 +00:00
;; .byte modifiers 0=none, 1=open-apple, 2=solid-apple, 3=both
2018-02-01 19:30:03 +00:00
;; if kind otherwise:
2017-09-19 14:58:17 +00:00
;; .word xcoord
;; .word ycoord
2018-01-29 08:57:55 +00:00
SetKeyEvent := $2E ; When set, keyboard is ignored in $29 calls
2017-10-16 03:28:50 +00:00
;; (input length 1 byte)
;; .byte flag high bit set = ignore keyboard, otherwise check
2018-01-29 05:18:00 +00:00
;;; --------------------------------------------------
;;; Menu Manager Calls
2018-01-29 08:57:55 +00:00
InitMenu := $2F
SetMenu := $30 ; Configure (and draw) menu
2017-10-15 02:45:51 +00:00
;; (input not copied)
;; .word count Number of top-level menus
;;
;; .word menu_id Menu identifier
;; .addr label Address of pascal (length-prefixed) string
;; .addr menu_defn Address of menu definition
;; .word 0,0,0 (overwritten with ???, left edge, right edge)
;; ...
;;
;; Menu definitions are:
;; .word count Number of items in menu
;; Menu items are:
;; .word 0,0 ???
;; .word has_shortcut 1 if has keyboard shortcuts, 0 otherwise
;; .byte shortcut1 ASCII code of shortcut #1 (e.g. uppercase B); or 0
;; .byte shortcut2 ASCII code of shortcut #2 (e.g. uppercase b, or same); or 0
;; .addr label Address of pascal (length-prefixed) string
;; or for a separator:
;; .word $40, $13, $0
2018-01-29 08:57:55 +00:00
MenuSelect := $31 ; Enter modal loop for handling mouse-down on menu bar
2017-10-15 02:45:51 +00:00
;; (input not copied)
;; (output 2 bytes)
;; .byte menu_id Top level menu identifier, or 0 if none
;; .byte item_num Index (1-based) of item in menu, or 0 if none
2018-01-29 08:57:55 +00:00
MenuKey := $32
HiliteMenu := $33
DisableMenu := $34
DisableItem := $35
CheckItem := $36
SetMark := $37
2018-01-29 05:18:00 +00:00
;;; --------------------------------------------------
;;; Window Manager Calls
2018-01-29 08:57:55 +00:00
OpenWindow := $38
;; (input not copied)
2018-01-29 05:18:00 +00:00
;; .byte id
;; .byte options option_*
2017-09-02 01:32:37 +00:00
;; .addr title
2018-01-29 05:18:00 +00:00
;; .byte hscroll scroll_option_*
;; .byte vscroll scroll_option_*
;; .byte hsmax
;; .byte hspos
;; .byte vsmax
;; .byte vspos
2017-09-03 01:51:03 +00:00
;; .byte ???
;; .byte ???
;; .word width_a ??? possibly size of scroll area within window of scroll area?
;; .word height_a ???
;; .word width_b (of scroll area?)
;; .word height_b (of scroll area?)
2018-01-29 05:18:00 +00:00
;; - next section is identical to that for SetPort
;; .word left pixels from screen edge
;; .word top
;; .word screen_addr
;; .word screen_stride
2018-01-29 16:25:56 +00:00
;; .word maprect_x1 pixels scrolled
;; .word maprect_y1
;; .word maprect_x2 pixels
;; .word maprect_y2
;; .res 8 pattern
2017-09-14 04:38:35 +00:00
;; .byte mskand AND mask, default $FF
;; .byte mskor ORA mask, default $00
2017-10-07 20:59:25 +00:00
;; .word xpos
;; .word ypos
2018-01-29 16:25:56 +00:00
;; .byte penwidth
;; .byte penheight
;; .byte 0 ??? fill mode?
2018-01-29 16:25:56 +00:00
;; .byte textback text background
;; .addr textfont
;; .addr next address of next lower window in stack (filled in by call)
2017-09-01 02:05:41 +00:00
2018-01-29 08:57:55 +00:00
CloseWindow := $39
2017-09-11 02:40:52 +00:00
;; (input length 1 byte)
2017-09-06 06:24:21 +00:00
;; .byte id
2017-08-31 03:30:46 +00:00
2018-01-29 08:57:55 +00:00
CloseAll := $3A
GetWinPtr := $3B ; Get pointer to window params by id; A=0 on success
2017-09-16 02:30:49 +00:00
;; (input length 1 byte)
2017-10-12 04:33:23 +00:00
;; (output length 3 bytes)
;; .byte id of window
;; .addr window (out) window params
2017-09-16 02:30:49 +00:00
2018-01-29 05:18:00 +00:00
GetWinPort := $3C ; get drawing state of window
2017-09-11 02:40:52 +00:00
;; (input length 3 bytes)
2017-09-10 01:11:01 +00:00
;; .byte id window
2018-01-29 16:25:56 +00:00
;; .addr port port definition to populate, like SetPort
2018-01-29 16:25:56 +00:00
SetWinPort := $3D ; Update port by passed window id
2017-10-15 04:15:35 +00:00
;; ** Implementation appears buggy - or maybe just really cryptic ??? **
;; (input length 2 bytes)
;; .byte id window
;; .byte ???
2018-01-29 08:57:55 +00:00
BeginUpdate := $3E
;; (input length 1 byte)
;; .byte id
2018-01-29 08:57:55 +00:00
EndUpdate := $3F
FindWindow := $40
2017-09-11 02:40:52 +00:00
;; (input length 4 bytes)
;; .word queryx relative to screen
2017-09-09 03:45:11 +00:00
;; .word queryy
2018-01-29 05:18:00 +00:00
;; .byte element (out) area_*
2017-10-12 04:33:23 +00:00
;; .byte id (out) of window
2017-08-31 03:30:46 +00:00
2018-01-29 08:57:55 +00:00
FrontWindow := $41 ; Get id of top window
2017-09-16 02:30:49 +00:00
;; (input length 0 bytes)
2017-10-15 04:15:35 +00:00
;; (output length 1 byte)
;; .byte id (out) window, or 0 if none
2017-09-16 02:30:49 +00:00
2018-01-29 08:57:55 +00:00
SelectWindow := $42 ; Make window topmost
2017-10-12 04:33:23 +00:00
;; (input length 1 byte)
2017-10-15 04:15:35 +00:00
;; .byte id window
2017-10-12 04:33:23 +00:00
2018-01-29 08:57:55 +00:00
TrackGoAway := $43
2017-09-11 02:40:52 +00:00
;; (input length 0 bytes)
2017-10-12 04:33:23 +00:00
;; .byte clicked (out) 0 = cancelled, 1 = clicked
;; .byte ?? (out)
;; .byte ?? (out)
2017-08-31 03:30:46 +00:00
2018-01-29 08:57:55 +00:00
DragWindow := $44
2017-09-11 02:40:52 +00:00
;; (input length 5 bytes)
;; .byte id window
;; .word xcoord mouse coords
2017-09-11 02:40:52 +00:00
;; .word ycoord
2017-09-25 04:02:13 +00:00
;; .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
2017-09-11 02:40:52 +00:00
;; (input length 5 bytes)
;; .byte id window
;; .word xcoord mouse coords
;; .word ycoord
;; .byte ?? likely: moved? 0 = no change, 1 = moved
2017-09-02 02:54:04 +00:00
2018-01-29 05:18:00 +00:00
ScreenToWindow := $46 ; Map screen coords to client coords
2017-09-11 02:40:52 +00:00
;; (input length 5 bytes)
2017-09-09 03:13:09 +00:00
;; .byte window_id
;; .word screenx
;; .word screeny
;; .word clientx
;; .word clienty
2018-01-29 08:57:55 +00:00
WindowToScreen := $47
2018-01-29 05:18:00 +00:00
;;; --------------------------------------------------
;;; Control Manager Calls
2018-01-29 08:57:55 +00:00
FindControl := $48
2017-09-11 02:40:52 +00:00
;; (input length 4 bytes)
;; .word xcoord
;; .word ycoord
2018-01-29 05:18:00 +00:00
;; .byte part ctl_*
;; .byte scroll part_*
2017-09-01 05:12:02 +00:00
2018-01-29 08:57:55 +00:00
SetCtlMax := $49 ; ???
2017-09-11 02:40:52 +00:00
;; (input length 3 bytes)
;; .byte ??? maybe part (i.e. HSCROLL or VSCROLL) ???
;; .byte ??? width fraction ??
;; .byte ???
2017-09-02 02:54:04 +00:00
2018-01-29 08:57:55 +00:00
TrackThumb := $4A
2017-09-11 02:40:52 +00:00
;; (input length 5 bytes)
2018-01-29 05:18:00 +00:00
;; .byte type ctl_horizontal_scroll_bar or ctl_vertical_scroll_bar
;; .word mouse xcoord
;; .word mouse ycoord
;; .byte position 0...255
;; .byte moved 0 = no change, 1 = moved
2017-08-31 03:30:46 +00:00
2018-01-29 08:57:55 +00:00
UpdateThumb := $4B
2017-09-11 02:40:52 +00:00
;; (input length 3 bytes)
2018-01-29 05:18:00 +00:00
;; .byte type ctl_horizontal_scroll_bar or ctl_vertical_scroll_bar
;; .byte pos new position 0...250
2017-09-11 02:40:52 +00:00
;; .byte ???
2018-01-29 08:57:55 +00:00
ActivateCtl := $4C ; ???
2018-01-29 05:18:00 +00:00
;;; $4E is last call
;;; ==================================================
2018-01-29 05:18:00 +00:00
;;; Graphics Primitives Constants
2018-01-29 08:57:55 +00:00
;;; Used in GetWinPort / SetPortBits
2018-01-29 05:18:00 +00:00
screen_mapbits := $2000 ; Screen address
screen_mapwidth := $80 ; Stride in bytes
;;; Used in SetPenMode
pencopy := 0
notpenXOR := 6
;;; Used in SetZP1
zp_overwrite := 0
zp_preserve := 1<<7
2017-09-21 15:09:11 +00:00
2017-09-15 08:02:38 +00:00
;;; Used in various state blocks
2018-01-29 05:18:00 +00:00
colormask_and := $FF
colormask_or := $00
textbg_white := $7F
;;; ==================================================
;;; Mouse Graphics Tool Kit Constants
;;; Used in GetEvent
2018-02-03 04:10:19 +00:00
event_kind_no_event := 0 ; No mouse or keypress
event_kind_button_down := 1 ; Mouse button was depressed
event_kind_button_up := 2 ; Mouse button was released
event_kind_key_down := 3 ; Key was pressed
event_kind_drag := 4 ; Mouse button still down
event_kind_apple_key := 5 ; Mouse button was depressed, modifier key down
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
area_desktop := 0
area_menubar := 1
area_content := 2 ; Includes scroll bars
area_dragbar := 3
area_grow_box := 4
area_close_box := 5
;;; Used in FindControl, TrackThumb, UpdateThumb
ctl_not_a_control := 0
ctl_vertical_scroll_bar := 1
ctl_horizontal_scroll_bar := 2
2018-02-03 04:41:42 +00:00
ctl_dead_zone := 3
2018-01-29 05:18:00 +00:00
;;; Used in FindControl
part_up_arrow := 1
part_left_arrow := 1
part_down_arrow := 2
part_right_arrow := 2
part_page_up := 3
part_page_left := 3
part_page_down := 4
part_page_right := 4
part_thumb := 5
;;; Used in OpenWindow
option_dialog_box := 1 << 0
option_go_away_box := 1 << 1
option_grow_box := 1 << 2
scroll_option_none := 0
scroll_option_present := 1 << 7
scroll_option_thumb := 1 << 6
scroll_option_active := 1 << 0
scroll_option_normal := scroll_option_present | scroll_option_thumb | scroll_option_active
2018-01-30 07:34:12 +00:00
;;; Used in menu structs
2018-01-30 07:58:53 +00:00
menuopt_open_apple := 1 << 0
menuopt_solid_apple := 1 << 1
menuopt_item_has_mark := 1 << 2
menuopt_item_is_checked := 1 << 5
menuopt_item_is_filler := 1 << 6
menuopt_disable_flag := 1 << 7
2018-01-30 07:34:12 +00:00
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-01-29 05:18:00 +00:00
.endscope ; MGTK
2017-09-01 05:39:06 +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-01-30 07:58:53 +00:00
.byte MGTK::menuopt_open_apple ; option byte
.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-01-30 07:58:53 +00:00
.byte MGTK::menuopt_item_is_filler ; option byte
.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)
2017-09-28 02:41:40 +00:00
;;; px() has high bit clear, PX() has high bit set
.define px(bits) (((bits&$40)>>6)|((bits&$20)>>4)|((bits&$10)>>2)|(bits&$8)|((bits&$4)<<2)|((bits&$2)<<4)|((bits&$1)<<6))
2017-09-28 02:41:40 +00:00
.define PX(bits) (((bits&$40)>>6)|((bits&$20)>>4)|((bits&$10)>>2)|(bits&$8)|((bits&$4)<<2)|((bits&$2)<<4)|((bits&$1)<<6)|$80)