AES Function Reference


Application Services Library


The Application Services Library provides general use functions used in locating and working with other resident applications in addition to providing AES initialization and termination code. The members of the Application Services Library are:

appl_exit()

appl_find()

appl_getinfo()

appl_init()

appl_read()

appl_search()

appl_tplay()

appl_trecord()

appl_write()

appl_exit()

WORD appl_exit( VOID )

appl_exit() should be called at the termination of any program initialized with appl_init().
Opcode 19 (0x13)
Availability All AES versions.
Binding
return crys_if(0x13);
Return Value appl_exit() returns 0 if an error occurred or non-zero otherwise.
Comments The proper procedure for handling an error from this function is currently undefined.
See Also appl_init()

appl_find()

WORD appl_find( fname )

CHAR *fname;

appl_find() searches the AES's current process list for a program named fname and, if present, returns the application identifier of the process.
Opcode 13 (0x0D)
Availability All AES versions.
Parameters fname is a pointer to a null-terminated ASCII string containing a valid GEMDOS filename (not including an extension) padded with blanks to be exactly 8 characters long (not including the NULL).
Binding
addrin[0] = fname;

return crys_if(0x0D);
Return Value appl_find() returns the application identifier of the process if it is found or -1 otherwise.
Version Notes AES versions from 4.0 add several extensions to this call for the benefit of MultiTOS as follows: If the upper word of the CHAR * is 0xFFFF, the lower word is assumed to be the MiNT id and appl_find() will return the AES application identifier.

If the upper word of the CHAR * is 0xFFFE, the lower word is assumed to be the AES application identifier and the MiNT id is returned.

If the upper word of the CHAR * is 0x0000, the current processes' application identifier is returned.This functionality only exists if the AES version is 4.0 and above and appl_getinfo() indicates that it is available.

See Also appl_write(), appl_init()

appl_getinfo()

WORD appl_getinfo(ap_gtype, ap_gout1, ap_gout2, ap_gout3, ap_gout4 )

WORD ap_gtype;

WORD *ap_gout1, *ap_gout2, *ap_gout3, *ap_gout4;

appl_getinfo() returns information about the AES.
Opcode 130 (0x82)
Availability Available as of AES version 4.00.
Parameters ap_gtype specifies the type of information to be returned in the shorts pointed to by ap_gout1, ap_gout2, ap_gout3, and ap_gout4 as follows:
Name
Value
Returns
AES_LARGEFONT
0
AES Large Font Information

ap_gout1 is filled in with the AES font's point size.

ap_gout2 is filled in with the font id.

ap_gout3 is a code indicating the type of font:

SYSTEM_FONT (0) is the system font

OUTLINE_FONT (1) is an outline font

ap_gout4 is unused.

AES_SMALLFONT
1
AES Large Font Information

Same as above for the current small font.

AES_SYSTEM
2
AES System Specifics

ap_gout1 is filled in with the resolution number (as would be returned by Getrez()).

ap_gout2 is filled in with the number of colors supported by the AES object library.

ap_gout3 is 0 if color icons are not supported or 1 if they are.

ap_gout4 is 0 to indicate that the extended resource file format is not supported or 1 if it is.

AES_LANGUAGE
3
AES Globalization

ap_gout1 is filled in with the current AES language code as follows:Name ap_gout1 LanguageAESLANG_ENGLISH 0 English

AESLANG_GERMAN 1 German

AESLANG_FRENCH 2 French

- 3 (Reserved)

AESLANG_SPANISH 4 Spanish

AESLANG_ITALIAN 5 Italian

AESLANG_SWEDISH 6 Swedishap_gout2, ap_gout3, and ap_gout4 are unused.

AES_PROCESS
4
AES Multiple Process Support

ap_gout1 is 0 to indicate the use of non-pre-emptive multitasking and 1 to indicate the use of pre-emptive multitasking.

ap_gout2 is 0 if appl_find() cannot convert between MiNT and AES id's and 1 to indicate that it can.

ap_gout3 is 0 if appl_search() is not implemented and 1 if it is.

ap_gout4 is 0 if rsrc_rcfix() is not implemented and 1 if it is.

AES_PCGEM
5
AES PC-GEM Features

ap_gout1 is 0 if objc_xfind() is not implemented and 1 if it is.

ap_gout2 is currently reserved.

ap_gout3 is 0 if menu_click() is not implemented and 1 if it is.

ap_gout4 is 0 if shel_rdef() and shel_wdef() are not implemented and 1 if they are.

AES_INQUIRE
6
AES Extended Inquiry Functions

ap_gout1 is 0 if -1 is not a valid ap_id parameter to appl_read() or 1 if it is.

ap_gout2 is 0 if -1 is not a valid length parameter to shel_get() or 1 if it is.

ap_gout3 is 0 if -1 is not a valid mode parameter to menu_bar() or 1 if it is.

ap_gout4 is 0 if MENU_INSTL is not a valid mode parameter to menu_bar() or 1 if it is.

-
7
Currently reserved.
AES_MOUSE
8
AES Mouse Support

ap_gout1 is 0 to indicate that mode parameters of 258-260 are not supported by graf_mouse() and 1 if they are.

ap_gout2 is 0 to indicate that the application has control over the mouse form and 1 to indicate that the mouse form is maintained by the AES on a per-application basis.

ap_gout3 and ap_gout4 are currently unused.

AES_MENU
9
AES Menu Support

ap_gout1 is 0 to indicate that sub-menus are not supported and 1 if MultiTOS style sub-menus are.

ap_gout2 is 0 to indicate that popup menus are not supported and 1 if MultiTOS style popup menus are.

ap_gout3 is 0 to indicate that scrollable menus are not supported and 1 if MultiTOS style scrollable menus are.

ap_gout4 is 0 to indicate that the MN_SELECTED message does not contain object tree information in msg[57] and 1 to indicate that it does.

AES_SHELL
10
AES Shell Support

ap_gout1 & 0x00FF indicates the highest legal value for the mode parameter of shel_write(). ap_gout1 & 0xFF00 indicate which extended shel_write() mode bits are supported.

ap_gout2 is 0 if shel_write() with a mode parameter of 0 launches an application or 1 if it cancels the previous shel_write().

ap_gout3 is 0 if shel_write() with a mode parameter of 1 launches an application immediately or 1 if it takes effect when the current application exits.

ap_gout4 is 0 if ARGV style parameter passing is not supported or 1 if it is.

AES_WINDOW
11
AES Window Features

ap_gout1 is a bitmap of extended modes supported by wind_get() and wind_set() (if a bit is set, it is supported) as follows: Bit mode

0 WF_TOP returns window below the top also.

1 wind_get( WF_NEWDESK, ... ) supported.

2 WF_COLOR get/set.

3 WF_DCOLOR get/set.

4 WF_OWNER get/set.

5 WF_BEVENT get/set.

6 WF_BOTTOM set.

7 WF_ICONIFY set.

8 WF_UNICONIFY set.

9-15 Unused

ap_gout2 is current unused.

ap_gout3 is a bitmap of supported window behaviors (if a bit is set, it is supported) as follows:

Bit Behaviour

0 Iconifier gadget present.

1 Bottomer gadget present.

2 shift-click sends window to bottom.

3 "hot" close box supported.

4-15 Unused

ap_gout4 is currently unused.

AES_MESSAGE
12
AES Extended Messages

ap_gout1 is a bitmap of extra messages supported (if a bit is set, it is supported) as follows: Bit Message

0 WM_NEWTOP is meaningful.

1 WM_UNTOPPED is sent.

2 WM_ONTOP is sent.

3 AP_TERM is sent.

4 Shutdown and resolution change messages.

5 CH_EXIT is sent.

6 WM_BOTTOMED is sent.

7 WM_ICONIFY is sent.

8 WM_UNICONIFY is sent.

9 WM_ALLICONIFY is sent.

10-15 Unused

ap_gout2 is a bitmap of extra messages supported. Current all bits are unused.

ap_gout3 is a bitmap indicating message behaviour (if a bit is set, the behaviour exists) as follows:

Bit Message

0 WM_ICONIFY message gives coordinates.

1-15 Unused

ap_gout4 is currently unused.

AES_OBJECT
13
AES Extended Objects

ap_gout1 is 0 if 3D objects are not supported or 1 if they are.

ap_gout2 is 0 if objc_sysvar() is not present, 1 if MultiTOS v1.01 objc_sysvar() is present, or 2 if extended objc_sysvar() is present.

ap_gout3 is 0 if the system font is the only font supported or 1 if GDOS fonts are also supported.

ap_gout4 is reserved for OS extensions.

AES_FORM
14
AES Form Support

ap_gout1 is 0 if 'flying dialogs' are not supported or 1 if they are.

ap_gout2 is 0 if keyboard tables are not supported or 1 if Mag!X style keyboard tables are supported.

ap_gout3 is 0 if the last cursor position from objc_edit() is not returned or 1 if it is.

ap_gout4 is currently reserved.

Binding
intin[0] = ap_gtype;

crys_if(0x82);

*ap_gout1 = intout[1];
*ap_gout2 = intout[2];
*ap_gout3 = intout[3];
*ap_gout4 = intout[4];

return intout[0];
Return Value appl_getinfo() returns 1 if an error occurred or 0 otherwise.
Version Notes Using an ap_gtype value of 4 and above is only supported as of AES version 4.1.
Comments Many of the ap_gtype return values identify features of TOS not supported by Atari but for the benefit of third-party vendors. You should contact the appropriate third-party for documentation on these functions.
See Also appl_init()

appl_init()

WORD appl_init( VOID )

appl_init() should be the first function called in any application that intends to use GEM calls.
Opcode 10 (0x0A)
Availability All AES versions.
Parameters The function as prototyped accepts no parameters, however, all 'C' compilers use this call to set up internal information as well as to update the applications' global array.
Binding
return crys_if(0x0A);
Return Value appl_init() returns the applications' global identifier if successful or -1 if the AES cannot register the application. If successful, the global identifier should be stored in a global variable for later use.

Besides the return value, the AES fills in the application's global array (to reference the global array see your programming languages' manual).

Name
global[x]
Meaning
_AESversion
0
AES version number.
_AESnumapps
1
Number of concurrent applications possible (normally 1). MultiTOS will return -1.
_AESapid
2
Application identifier (same as appl_init() return value).
_AESappglobal
3-4
LONG global available for use by the application.
_AESrscfile
5-6
Pointer to the base of the resource loaded via rsrc_load().
-
7-12
Reserved
_AESmaxchar
13
Current maximum character used by the AES to do vst_height() prior to writing to the screen. This entry is only present as of AES version 0x0400.
_AESminchar
14
Current minimum character used by the AES to do vst_height() prior to writing to the screen. This entry is only present as of AES version 0x0400.
Version Notes See above.
See Also appl_exit()

appl_read()

WORD appl_read( ap_id, length, message )

WORD ap_id, length;

VOIDP message;

appl_read() is designed to facilitate inter-process communication between processes running under the AES. The call will halt the application until a message of sufficient length is available (see version notes below).
Opcode 11 (0x0B)
Availability All AES versions.
Parameters ap_id is your application identifier as returned by appl_init(). length is the length (in bytes) of the message to read. message is a pointer to a memory buffer where the incoming message should be copied to.
Binding
intin[0] = ap_id;
intin[1] = length;

addrin[0] = message;

return crys_if(0x0B);
Return Value appl_read() returns 0 if an error occurred or non-zero otherwise.
Version Notes If the AES version is 4.0 or higher and appl_getinfo() indicates that this feature is supported, ap_id takes on an additional meaning. If APR_NOWAIT (-1) is passed instead of ap_id, appl_read() will return immediately if no message is currently waiting.
Comments Normally this call is not used. evnt_multi() or evnt_mesag() is used instead for standard message reception. appl_read() is required for reading messages that are long and/or of variable length.

It is recommended that message lengths in multiples of 16 bytes be used.

See Also appl_write()

appl_search()

WORD appl_search( mode, fname, type, ap_id )

WORD mode;

CHAR *fname;

WORD *type,*ap_id;

appl_search() provides a method of identifying all of the currently running processes.
Opcode 18 (0x12)
Availability Available only in AES versions 4.0 and above when appl_getinfo() indicates its presence.
Parameters mode specifies the search mode as follows:
Name
mode
Meaning
APP_FIRST
0
Return the filename of the first process
APP_NEXT
1
Return the filename of subsequent processes
fname should point to a memory location at least 9 bytes long to hold the 8 character process filename found and the NULL byte. type is a pointer to a WORD into which will be placed the process type as follows:
Name
type
Meaning
APP_SYSTEM
0x01
System process
APP_APPLICATION
0x02
Application
APP_ACCESSORY
0x04
Accessory
APP_SHELL
0x08
The type parameter is actually a bit mask so it is possible that a process containing more than one characteristic will appear. The currently running shell process (usually the desktop) will return a value of APP_APPLICATION | APP_SHELL (0x0A).

ap_id is a pointer to a word into which will be placed the processes' application identifier.

Binding
intin[0] = mode;

addrin[0] = fname;
addrin[1] = type;
addrin[2] = ap_id;

return crys_if(0x12);
Return Value appl_search() returns 0 if no more applications exist or 1 when more processes exist that meet the search criteria.

appl_tplay()

WORD appl_tplay( mem, num, scale )

VOIDP mem;

WORD num, scale;

appl_tplay() plays back events originally recorded with appl_trecord().
Opcode 14 (0x0E)
Availability All AES versions.
Parameters mem is a pointer to an array of EVNTREC structures (see appl_trecord()). num indicates the number of EVNTREC's to play back.

scale indicates on a scale of 1 to 10000 how fast the AES will attempt to play back your recording. A value of 100 will play it back at recorded speed. A value of 200 will play the events back at twice the recorded speed, and 50 will play back the events at half of the recorded speed. Other values will respond accordingly.

Binding
intin[0] = num;
intin[1] = scale;

addrin[0] = mem;

return crys_if(0x0E);
Return Value appl_tplay() always returns 1 meaning no error occurred.
Caveats This function does not work correctly on AES versions less than 1.40 without a patch program available from Atari Corp.
See Also appl_trecord()

appl_trecord()

WORD appl_trecord( mem, num )

VOIDP mem;

WORD num;

appl_trecord() records AES events for later playback.
Opcode 15 (0x0F)
Availability All AES versions.
Parameters mem points to an array of num EVNTREC structures into which the AES will record events as indicated here:
typedef struct pEvntrec
{
 WORD ap_event;
 LONG ap_value;
} EVNTREC;ap_event defines the required interpretation of ap_value as follows:
Name
ap_event
Event ap_value
APPEVNT_TIMER
0
Timer Elapsed Time (in milliseconds)
APPEVNT_BUTTON
1
Button low word = state (1 = down)

high word = # of clicks

APPEVNT_MOUSE
2
Mouse low word = X pos

high word = Y pos

APPEVNT_KEYBOARD
3
Keyboard bits 0-7: ASCII code

bits 8-15: scan code

bits 16-31: shift key state

Binding
intin[0] = num;

addrin[0] = mem;

return crys_if(0x0F);
Return Value appl_trecord() returns the number of events actually recorded.
Caveats This function does not work correctly on AES versions less than 1.40 without a patch program available from Atari Corp.
See Also appl_tplay()

appl_write()

WORD appl_write( ap_id, length, msg )

WORD ap_id, length;

VOIDP msg;

appl_write() can be used to send a message to a valid message pipe.
Opcode 12 (0x0C)
Availability All AES versions.
Parameters ap_id is the application identifier of the process to which you wish to send the message. length specifies the number of bytes present in the message. msg is a pointer to a memory buffer with at least length bytes available.
Binding
intin[0] = ap_id;
intin[1] = length;

addrin[0] = msg;

return crys_if(0x0C);
Return Value appl_write() returns 0 if an error occurred or greater than 0 if the message was sent successfully.
Version Notes As of AES version 1.40, desk accessories may send MN_SELECTED messages to the desktop to trigger desktop functions.

As of AES version 4.00 you can use shel_write(7,...) to 'broadcast' a message to all processes running with the exception of the AES itself, the desktop, and your own application. See shel_write() for details.

Comments It is recommended that you always send messages in 16 byte blocks using a WORD array of 8 elements as the AES does.
See Also appl_read(), shel_write()

Event Library


The Event Library consists of a group of system calls which are used to monitor system messages including mouse clicks, keyboard usage, menu bar interaction, timer calls, and mouse tracking. The library consists of the following calls:

evnt_button()

evnt_dclick()

evnt_keybd()

evnt_mesag()

evnt_mouse()

evnt_multi()

evnt_timer()

evnt_button()

evnt_button()

WORD evnt_button( clicks, mask, state, mx, my, button, kstate )

WORD clicks, mask, state;

WORD *mx, *my, *button, *kstate;

evnt_button() releases control to the operating system until the specified mouse button event has occurred.
Opcode 21 (0x15)
Availability All AES versions.
Parameters clicks specifies the number of mouse-clicks that must occur before returning. mask specifies the mouse buttons to wait for as follows:
Name
mask
Meaning
LEFT_BUTTON
0x01
Left mouse button
RIGHT_BUTTON
0x02
Right mouse button
MIDDLE_BUTTON
0x04
Middle button (this button would be the first button to the left of the rightmost button on the device).
-
0x08
.
.
Other buttons (0x08 is the mask for the button to the immediate left of the middle button. Masks continue leftwards).
state specifies the button state that must occur before returning as follows:
mask
Meaning
0x00
All buttons released
0x01
Left button depressed
0x02
Right button depressed
0x04
MIddle button depressed
0x08
.
.
etc...
mx is a pointer to a WORD which upon return will contain the x-position of the mouse pointer at the time of the event. my is a pointer to a WORD which upon return will contain the y-position of the mouse pointer at the time of the event.

button is a pointer to a WORD which upon return will contain the mouse button state as defined in state.

kstate is a pointer to a WORD which upon return will contain the current status of the keyboard shift keys. The value is a bit-mask defined as follows:

Name
Mask
Key
K_RSHIFT
0x01
Right Shift
K_LSHIFT
0x02
Left Shift
K_CTRL
0x04
Control
K_ALT
0x08
Alternate
Binding
intin[0] = clicks;
intin[1] = mask;
intin[2] = state;

crys_if(0x15);

*mx = intout[1];
*my = intout[2];
*button = intout[3];
*kstate = intout[4];

return intout[0];
Return Value Upon exit, evnt_button() returns a WORD indicating the number of times the mouse button state matched state.
Comments A previously undocumented feature of this call is accessed by logically OR'ing the mask parameter with 0x100. This causes the call to return when independent buttons are depressed. For example, a mask value of 0x03 will return when both the left and right mouse buttons are depressed. A mask value of 0x103 will cause the call to return when either button is depressed.
See Also evnt_multi()

evnt_dclick()

WORD evnt_dclick( new, flag )

WORD new, flag;

evnt_dclick() sets the mouse double-click response rate. This call is global, and thus, affects all applications.
Opcode 26 (0x1A)
Availability All AES versions.
Parameters If flag is EDC_INQUIRE (0), new is ignored and the current double-click rate is returned. If flag is EDC_SET (1), new specifies the new double-click rate as follows:
flag
Response
0
1
2
3
4
Slowest

Fastest

Binding
intin[0] = new;
intin[1] = flag;

return crys_if(0x1A);
Return Value evnt_dclick() returns the newly set or current double-click rate based on flag.
Comments Because this setting is global for all applications, Atari has strongly recommended that developers use this call only where appropriate (such as in a configuration CPX like the General Setup CPX included with XCONTROL).

evnt_keybd()

WORD evnt_keybd( VOID )

evnt_keybd() relinquishes program control to the operating system until a valid keypress is available in the applications' message pipe.
Opcode 20 (0x14)
Availability All AES versions.
Parameters None
Binding
return crys_if(0x14);
Return Value evnt_keybd() returns a 16-bit value containing the ASCII code of the key entered in the lower eight bits and the scan code in the upper 8-bits.
Version Notes TOS versions released at or above 2.06 and 3.06 disabled reception of keys 1 through 9 on the numeric keypad when used in conjunction with the alternate key. Users may now enter the full range of ASCII values by holding down alt, typing in the decimal ASCII code, and then releasing the alt key. These keys, therefore, should not be used by applications. The standard numeric keypad is still available.
See Also evnt_multi()

evnt_mesag()

WORD evnt_mesag( msg )

WORD *msg;

evnt_mesag() releases control to the operating system until a valid system message is available in the applications' message pipe.
Opcode 23 (0x17)
Availability All AES versions.
Parameters msg is a pointer to an array of 8 WORD's to be used as a message buffer.
Binding
addrin[0] = msg

return crys_if(0x17);
Return Value The return value is currently reserved by Atari and currently is defined as 1. The array msg is filed in with the following values:
Index Description Possible Values #
msg[0] Message Type MN_SELECTED

WM_REDRAW

WM_TOPPED

WM_CLOSED

WM_FULLED

WM_ARROWED

WM_HSLID

WM_VSLID

WM_SIZED

WM_MOVED

WM_UNTOPPED

WM_ONTOP

WM_BOTTOM

WM_ICONIFY

WM_UNICONIFY

WM_ALLICONIFY

WM_TOOLBAR

AC_OPEN

AC_CLOSE

AP_TERM

AP_TFAIL

AP_RESCHG

SHUT_COMPLETED

RESCH_COMPLETED

AP_DRAGDROP

SH_WDRAW

CH_EXIT

10

20

21

22

23

24

25

26

27

28

30

31

33

34

35

36

37

40

41

50

51

57

60

61

63

72

90

msg[1] The application identifier of the sending application. Any valid ap_id.
msg[2] The length of the message beyond 16 bytes (use appl_read() to read the excess). Currently all system messages return 0 in this slot. Only user-defined messages utilize a higher value.
Each system message can be interpreted as follows:
Message Extended Information
MN_SELECTED A menu item has been selected by the user. msg[3] contains the object number of the menu title and msg[4] contains the object number of the menu item.

As of AES version 3.30 (and when indicated by appl_getinfo() ), msg[5] and msg[6] contain the high and low word, respectively, of the object tree of the menu item. msg[7] contains the parent object index of the menu item.

WM_REDRAW This message alerts an application that a portion of the screen needs to be redrawn. msg[3] contains the handle of the window to redraw. msg[4-7] are the x, y, w, and h respectively of the 'dirtied' area.

When the message is received the window contents should be drawn (or a representative icon if the window is iconified).

WM_TOPPED This message is sent when an application window which is currently not the top window is clicked on by the user. msg[3] contains the handle of the window.

You should use wind_set( msg[3], WF_TOP, 0, 0, 0, 0) to actually cause the window to be topped.

WM_CLOSED This message is sent when the user clicks on a windows' close box. msg[3] contains the handle of the window to close.

You should react to this message with wind_close().

WM_FULLED This message is sent when the user clicks on a windows' full box. If the window is not at full size, the window should be resized using wind_set(handle, WF_CURRXYWH,... to occupy the entire screen minus the menu bar (see wind_get()).

If the window was previously 'fulled' and has not been resized since, the application should return the window to its previous size.

WM_ARROWED This message is sent to inform an application that one of its slider gadgets has been clicked on.

A row or column message is sent when a slider arrow is selected. A 'page' message is sent when a darkened area of the scroll bar is clicked. This usually indicates that the application should adjust the window's contents by a larger amount than with the row or column messages.

msg[3] indicates which action was actually selected as follows: Name Value Meaning

WA_UPPAGE 0 Page Up

WA_DNPAGE 1 Page Down

WA_UPLINE 2 Row Up

WA_DNLINE 3 Row Down

WA_LFPAGE 4 Page Left

WA_RTPAGE 5 Page Right

WA_LFLINE 6 Column Left

WA_RTLINE 7 Column Right

WM_HSLID This message indicates that the horizontal slider has been moved. msg[3] contains the new slider position ranging from 0 to 1000.

Note: Slider position is relative and not related to slider size.

WM_VSLID This message indicates that the vertical slider has been moved. msg[3] contains the new slider position ranging from 0 to 1000.

Note: Slider position is relative and not related to slider size.

WM_SIZED This message occurs when the user drags the window sizing gadget. msg[3] contains the window handle. msg[4-7] indicate the x, y, w, and h respectively of the new window location.

Use wind_set(handle, WF_CURRXYWH,... to actually size the window.

WM_SIZED and WM_MOVED usually share common handling code.

WM_MOVED This message occurs when the user moves the window by dragging the windows' title bar. msg[3] contains the handle of the window being moved. msg[4-7] indicate the x, y, w, and h respectively of the new window location.

Use wind_set(handle, WF_CURRXYWH,... ) to actually move the window.

WM_MOVED and WM_SIZED usually share common handling code.

WM_UNTOPPED This message is sent when the current window is sent behind one or more windows as the result of another window being topped. msg[3] contains the handle of the window being untopped.

The application need take no action. The message is for informational use only.

WM_ONTOP This message is sent when an applications' window is brought to the front on a multitasking AES. msg[3] is the handle of the window being brought to the front.

This message requires no action, it is for informational purposes only.

WM_BOTTOMED This message is sent when the user shift-clicks on the window's (specified in msg[3]) mover bar to indicate that the window should be sent to the bottom of the window stack by using wind_set() with a parameter of WF_BOTTOM.
WM_ICONIFY This message is sent when the user clicks on the SMALLER window gadget. msg[3] indicates the handle of the window to be iconified. msg[4-7] indicate the x, y, w, and h of the iconified window.

If the iconified window represents a single window this message should be responded to by using wind_set() with a parameter of WF_ICONIFY.

WM_UNICONIFY This message is sent when the user double-clicks on an iconified window. msg[3] indicates the handle of the window to be iconified. msg[4-7] indicate the x, y, w, and h of the original window.

This message should be responded to by using wind_set() with a parameter of WF_UNICONIFY.

WM_ALLICONIFY This message is sent when the user ctrl-clicks on the SMALLER window gadget. msg[3] indicates which window's gadget was clicked. msg[4-7] indicates the position at which the new iconified window should be placed.

The application should respond to this message by closing all open windows and opening a new iconified window at the position indicated which represents the application.

WM_TOOLBAR This message is sent when a toolbar object is clicked. msg[3] contains the handle of the window containing the toolbar.

msg[4] contains the object index of the object clicked. msg[5] contains the number of clicks. msg[6] contains the state of the keyboard shift keys at the time of the click (as in evnt_keybd() ).

AC_OPEN This message is sent when the user has selected a desk accessory to open. msg[4] contains the application identifier (as returned by appl_init()) of the accessory to open.
AC_CLOSE This message is sent to a desk accessory when the accessory should be closed. msg[3] is the application identifier (as returned by appl_init()) of the accessory to close.

Do not close any windows your accessory had open, the system will do this for you. Also, do not require any feedback from the user when this is received. Treat this message as a 'Cancel' from the user.

AP_TERM This message is sent when the system requests that the application terminate. This is usually the result of a resolution change but may also occur if another application sends this message to gain total control of the system.

The application should shut down immediately after closing windows, freeing resources, etc... msg[5] indicates the reason for the shut down as follows: AP_TERM (50) = Just shut down.

AP_RESCHG (57) = Resolution Change.If for some reason, your process can not shut down you must inform the AES by sending an AP_TFAIL (51) message by using shel_write() mode 10 (see shel_write()).

Note: Desk Accessories wil always be sent AC_CLOSE messages, not AP_TERM.

AP_TFAIL This message should be sent to the system (see shel_write()) when an application has received an AP_TERM (50) message and cannot shut down.

msg[0] should contain AP_TFAIL and msg[1] should contain the application error code.

AP_RESCHG This message is actually a sub-command and is only found as a possible value in the AP_TERM (50) message (see above).
SHUT_COMPLETED This message is sent to the application which requested a shutdown when the shutdown is complete and was successful.
RESCH_COMPLETED This message is sent to an application when a resolution change it requested is completed. msg[3] contains 1 if the resolution change was successful and 0 if an error occurred.
AP_DRAGDROP This message indicates that another application wishes to initiate a drap and drop session. msg[3] indicates the handle of the window which had an object dropped on it or -1 if no specific window was targeted.

msg[4-5] contains the X and Y position of the mouse when the object was 'dropped'. msg[6] indicates the keyboard shift state at the time of the drop (as in evnt_keybd() ).

msg[7] is a two-byte ASCII packed pipe identifier which gives the file extension of the pipe to open.

For more information about the drag & drop protocal, see Chapter 2: GEMDOS.

SH_WDRAW This message is sent to the Desktop to ask it to update an open drive window. msg[3] should contain the drive number to update (0 = A:, 1 = B:) or -1 to update all windows.
CH_EXIT This message is sent when a child process that the application has started, returns. msg[3] contains the child's application identifier and msg[4] contains its exit code.
Version Notes WM_UNTOPPED, WM_ONTOP, AP_TERM, AP_TFAIL, AP_RESCHG, SHUT_COMPLETED, RESCH_COMPLETED, and CH_EXIT are new as of AES version 4.0.

WM_BOTTOM, WM_ICONIFY, WM_UNICONIFY, WM_ALLICONIFY, and WM_TOOLBAR are new as of AES version 4.1.

No lower version AES will send these messages.

The existence (or acceptance) of these messages should also be checked for by using appl_getinfo().

See Also evnt_multi()

evnt_mouse()

WORD evnt_mouse( flag, x, y, w, h, mx, my, button, kstate )

WORD flag, x, y, w, h;

WORD *mx, *mx, *button, *kstate;

evnt_mouse() releases control to the operating system until the mouse enters or leaves a specified area of the screen .
Opcode 22 (0x16)
Availability All AES versions.
Parameters flag specifies the event to wait for as follows:
Name
Value
Meaning
MO_ENTER
0
Wait for mouse to enter rectangle.
MO_LEAVE
1
Wait for mouse to leave rectangle.
The rectangle to watch is specified in x, y, w, h. mx and my are WORD pointers which will be filled in with the final position of the mouse.

button is a WORD pointer which will be filled in upon return with the final state of the mouse button as defined in evnt_button().

kstate is a WORD pointer which will be filled in upon return with the final state of the keyboard shift keys as defined in evnt_button().

Binding
intin[0] = flag;
intin[1] = x;
intin[2] = y;
intin[3] = w;
intin[4] = h;

crys_if(0x16);

*mx = intout[1];
*my = intout[2];
*button = intout[3];
*kstate = intout[4];

return intout[0];
Return Value The return value of this function is reserved. Currently it always returns 1.
Comments The evnt_multi() function can be used to watch two mouse/rectangle events as opposed to one.
See Also evnt_multi()

evnt_multi()

WORD evnt_multi( events, bclicks, bmask, bstate, m1flag, m1x, m1y, m1w, m1h, m2flag, m2x, m2y, m2w, m2h, msg, locount, hicount, mx, my,mb, ks, kc, mc )

WORD events, bclicks, bmask, bstate, m1flag, m1x, m1y, m1w, m1h, m2flag, m2x, m2y, m2w, m2h;

WORD *msg;

WORD locount, hicount;

WORD *mx, *my, *ks, *kc, *mc;

evnt_multi() suspends the application until a valid message that the application is interested in occurs. This call combines the functionality of evnt_button(), evnt_keybd(), evnt_mesag(), evnt_mouse(), and evnt_timer() into one call.

This call is usually the cornerstone of all GEM applications that must process system events.

Opcode 25 (0x19)
Availability All AES versions.
Parameters events is a bit mask which tells the function which events your application is interested in. You should logically 'OR' any of the following values together:
Name
Mask
Function
MU_KEYBD
0x01
Wait for a user keypress.
MU_BUTTON
0x02
Wait for the specified mouse button state.
MU_M1
0x04
Wait for a mouse/rectangle event as specified.
MU_M2
0x08
Wait for a mouse/rectangle event as specified.
MU_MESAG
0x10
Wait for a message.
MU_TIMER
0x20
Wait the specified amount of time.
For usage of bclicks, bmask, bstate, mx, my, kc, and ks, you should consult evnt_button().

For usage of m1flag, m1x, m1y, m1w, m1h, m2flag, m2x, m2y, m2w, and m2h, consult evnt_mouse().

For usage of msg, see evnt_mesag().

For usage of locount and hicount, see evnt_timer().

Binding
intin[0] = events;
intin[1] = bclicks;
intin[2] = bmask;
intin[3] = bstate;
intin[4] = m1flag;
intin[5] = m1x;
intin[6] = m1y;
intin[7] = m1w;
intin[8] = m1h;
intin[9] = m2flag;
intin[10] = m2x;
intin[11] = m2y;
intin[12] = m2w;
intin[13] = m2h;
intin[14] = locount;
intin[15] = hicount;

addrin[0] = msg;

crys_if(0x19);

*mx = intout[1];
*my = intout[2];
*mb = intout[3];
*ks = intout[4];
*kc = intout[5];
*mc = intout[6];

return intout[0];
Return Value The function returns a bit mask of which events actually happened as in events. This may be one or more events and your application should be prepared to handle each.
Version Notes The only facet of evnt_multi() which has changed from AES version 4.0 is that which relates to evnt_mesag(). For further information you should consult that section.
Caveats Under TOS 1.0, calling this function from a desk accessory with the MU_TIMER mask and locount and hicount being equal to 0 could hang the system.
See Also evnt_button(), evnt_keybd(), evnt_mesag(), evnt_mouse(), evnt_timer()

evnt_timer()

WORD evnt_timer( locount, hicount )

WORD locount, hicount;

evnt_timer() releases control to the operating system until a specified amount of time has passed.
Opcode 24 (0x18)
Availability All AES versions.
Parameters locount is the low word of a 32-bit time value specified in milliseconds.

hicount is the high portion of that 32-bit value.

Binding
intin[0] = locount;
intin[1] = hicount;

return crys_if(0x18);
Return Value The return value is reserved and is currently always 1.
Caveats Under TOS 1.0, calling this function from a desk accessory with a both parameters having a value of 0 will hang the system.
Comments This function should not be relyed on as an accurate clock. The time specified is used as a minimum time value only and the function will return at some point after that duration has passed.
See Also evnt_multi()

Form Library


The Form Library contains utility functions for the use and control of dialog boxes, alert boxes, and user input. The members of the Form Library are:

form_alert()

form_button()

form_center()

form_dial()

form_do()

form_error()

form_keybd()

form_alert()

WORD form_alert( default, alertstr )

WORD default;

CHAR *alertstr;

form_alert() displays a standardized alert box and returns the user's selection.
Opcode 52 (0x34)
Availability All AES versions.
Parameters default contains the number of the exit button which is to be made default (1-3). alertstr contains a formatted string as follows: "[#][Alert Text][Buttons]".

# specifies the icon to display in the alert as follows:


#
Icon Displayed
0
No Icon
1
2
3
4
5
'Alert Text' is a text string of as many as 5 lines composed of up to 30 characters each. Each line is separated by a '|' character.

'Buttons' is a text string to define as many as 3 buttons up to 10 characters each. If only one button is used, its text may be as long as 30 characters. Again, each button is separated by a '|' character

Binding
intin[0] = default;

addrin[0] = alertstr;

return crys_if(0x34);
Return Value form_alert() returns a WORD indicating which button was used to exit by the user (A possible value of 1-3).
Version Notes Icons #4-5 are only available as of AES version 4.1.
Caveats Several versions of the AES have special quirks related to this function. By following the quidelines below you should avoid any difficulty:1. All AES versions below 1.06 have some difficulty formatting alert strings padded with spaces. If you want your alerts to look right on all AES versions, do not pad any button or line with spaces with the exception below.

2. Add one space to the end of the longest text line on an alert. This will prevent the right edge from touching the border in some AES versions.


form_button()

WORD form_button( tree, obj, clicks, newobj )

OBJECT *tree;

WORD obj, clicks, newobj;

form_button() is a utility function designed to aid in the creation of a custom form_do() handler.
Opcode 56 (0x38)
Availability All AES versions.
Parameters tree is a pointer to a valid object tree in memory you wish to process button events for. obj is the object index into tree which was clicked on and which needs to be processed.

clicks is the number of times the mouse button was clicked.

newobj returns the next object to gain edit focus or 0 if there are no editable objects. If the top bit of newobj is set, this indicates that a TOUCHEXIT object was double-clicked.

Binding
intin[0] = obj;
intin[1] = clicks;

addrin[0] = tree;

crys_if(0x38);

*newobj = intout[1];

return intout[0];
Return Value form_button() returns a 0 if it exits finding an EXIT or TOUCHEXIT object selected or 1 otherwise.
Comments To use this function properly, the application should take the following steps:1. Monitor mouse clicks with evnt_multi() or evnt_button().

2. When a click occurs, use objc_find() to determine if the click occurred over the object.

3. If so, call form_button() with the appropriate values.This function was not originally documented by Atari. You may have to add bindings for this function to some earlier 'C' compilers.

See Also form_do(), form_keybd()

form_center()

WORD form_center( tree, x, y, w, h )

OBJECT *tree;

WORD *x, *y, *w, *h;

form_center() is used to modify an object's coordinates so that it will appear in the center of the display screen.
Opcode 54 (0x36)
Availability All AES versions.
Parameters tree points to a valid OBJECT structure (see discussion of resources) which the application wishes to have centered. x, y, w, and h, return a clipping rectangle suitable for use in objc_draw().
Binding
addrin[0] = tree;

crys_if(0x36);

*x = intout[1];
*y = intout[2];
*w = intout[3];
*h = intout[4];

return intout[0];
Return Value The return value is currently reserved. Currently it equals 1.
Comments The values that form_center() returns in x, y, w, and h, are not necessarily the same as the object's. These values take into account negative borders, outlining, and shadowing. This is meant to provide a suitable clipping rectangle for objc_draw()
See Also objc_draw()

form_dial()

WORD form_dial( mode, x1, y1, w1, h1, x2, y2, w2, h2 )

WORD mode, x1, y1, w1, h1, x2, y2, w2, h2;

form_dial() is used to reserve and release screen space for dialog usage. In addition, it also optionally provides grow/shrink box effects.
Opcode 51 (0x33)
Availability All AES versions.
Parameters mode specifies the action to take and the meaning of remaining parameters as follows:
Name
#
Action
FMD_START
0
This mode reserves the screen space for a dialog. x2, y2, w2, and h2, contain the coordinates of the dialog to be used (usually obtained through form_center()).
FMD_GROW
1
This mode draws an expanding box from the coordinates specified in x1, y1, w1, and h1 to the coordinates specified in x2, y2, w2, and h2. This call is optional and is not required to display a dialog.
FMD_SHRINK
2
This mode draws a shrinking box from the coordinates specified in x2, y2, w2, and h2 to the coordinates specified in x1, y1, w1, and h1. This call is optional and is not required to display a dialog.
FMD_FINISH
3
This mode releases the screen space for a dialog (previously reserved with mode 0). x2, y2, w2, and h2 contain the coordinates of the space to release. One of the side-effects of this call is a WM_REDRAW message sent to any window which the dialog was covering.
Binding
intin[0] = mode;
intin[1] = x1;
intin[2] = y1;
intin[3] = w1;
intin[4] = h1;
intin[5] = x2;
intin[6] = y2;
intin[7] = w2;
intin[8] = h2;

return crys_if(0x33);
Return Value The function returns 0 is an error occurred or non-zero otherwise.
Version Notes The AES does not currently make use of mode FMD_START. The call should, however, still be executed for upward compatibility.
See Also graf_growbox(), graf_shrinkbox()

form_do()

WORD form_do( tree, editobj )

OBJECT *tree;

WORD editobj;

form_do() provides an automated dialog handling function to the calling application. It suspends program control, handling all radio buttons, selectable objects, etc... until an object with the TOUCHEXIT or EXIT flag is selected.
Opcode 50 (0x32)
Availability All AES versions.
Parameters tree is a pointer to a valid object tree (see the discussion on objects in this chapter) which contains a dialog with at least one EXIT or TOUCHEXIT button or object.

editobj is the object index into tree which specifies the desired initial location of the edit cursor (the object must be flagged as EDITABLE). If the form has no text editable fields, you should use 0.

Binding
intin[0] = editobj;

addrin[0] = tree;

return crys_if(0x32);
Return Value form_do() returns the object index of the EXIT or TOUCHEXIT button which was selected. If the object was double clicked, bit 15 will be set. This means that to obtain the actual object number you should mask off the result with 0x7FFF.

form_error()

WORD form_error( error )

WORD error;

form_error() displays a pre-defined error alert box to the user.
Opcode 53 (0x35)
Availability All AES versions.
Parameters error specifies a MS-DOS error code as follows:
Name
GEMDOS Error #
error
Message
FERR_FILENOTFOUND
-33
2
File Not Found

The application can not find the folder or file that you tried to access.

FERR_PATHNOTFOUND
-34
3
Path Not Found

The application cannot find the folder or file that you tried to access.

FERR_NOHANDLES
-35
4
No More File Handles

The application does not have room to open another document. To make room, close any open document that you do not need.

FERR_ACCESSDENIED
-36
5
Access Denied

An item with this name already exists in the directory, or this item is set to read-only status.

FERR_LOWMEM
-39
8
Insufficient Memory

There is not enough memory for the application you just tried to run.

FERR_BADENVIRON
-41
10
Invalid Environment

There is not enough memory for the application you just tried to run.

FERR_BADFORMAT
-42
11
Invalid Format

There is not enough memory for the application you just tried to run.

FERR_BADDRIVE
-46
15
Invalid Drive Specification

The drive you specified does not exist.

FERR_DELETEDIR
-47
16
Attempt To Delete Working Directory

You cannot delete the folder in which you are working.

FERR_NOFILES
-49
18
No More Files

The application can not find the folder or file that you tried to access.

The GEMDOS error number can be translated into a MS-DOS code by subtracting 31 from the absolute value of the error code.
Binding
intin[0] = error;

return crys_if(0x35);
Return Value The function returns the exit button clicked as in form_alert(). It is, however, insignifigant as all of the error alerts have only one button.
Caveats Not every GEMDOS error code has a matching alert box.
See Also form_alert()

form_keybd()

WORD form_keybd( tree, obj, nextobj, kc, newobj, keyout )

OBJECT *tree;

WORD obj, nextobj, kc;

WORD *newobj, *keyout;

form_keybd() processes keyboard input for dialog box control. It handles special keys such as return, escape, tab, etc... It is only of real use if you are writing a customized form_do() routine.
Opcode 55 (0x37)
Availability All AES versions.
Parameters tree points to a valid OBJECT tree containing the dialog you wish to process. obj is the object index of the object which currently has edit focus (0 if none). nextobj is reserved and should be 1.

kc is the value returned from evnt_keybd() or evnt_multi() which represents the keypresses' scan code and ASCII value.

newobj is a WORD pointer which is filled in on function exit to be the new object with edit focus unless the return key was pressed with a default object present in which case it equals the object index of the object that was the default.

keyout is the value ready to be passed on to objc_edit() if no processing was required or 0 if the key was processed and handled by the call.

Binding
intin[0] = obj;
intin[1] = kc;
intin[2] = nextobj;

addrin[0] = tree;

crys_if(0x37);

*newobj = intout[1];
*keyout = intout[2];

return intout[0];
Return Value form_keybd() returns 0 if a default EXIT object was triggered by this call or 1 if the dialog should continue to be processed.
Comments This function was not originally documented by Atari. You may need to add bindings for this function into some older 'C' compilers.
See Also objc_edit(), form_do(), form_button()

File Selector Library


The File Selector Library contains two functions for displaying the system file selector (or currently installed alternate file selector) and prompting the user to select a file. The members of this library are:

fsel_exinput()

fsel_input()

fsel_exinput()

WORD fsel_exinput( path, file, button, title )

CHAR *path, *file;

WORD *button;

CHAR *title;