Home » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199611.adf » Features » WIMPC/!RAPS/c/AULib

WIMPC/!RAPS/c/AULib

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199611.adf » Features
Filename: WIMPC/!RAPS/c/AULib
Read OK:
File size: 2FFA bytes
Load address: 0000
Exec address: 0000
File contents
/* Acorn User library for WIMP programming in C */
/* By Steve Mumford, 8th September 1996 */

/* #Include the appropriate files - AULib.h contains everything we need */ 

#include "AUlib.h"

int
au_initialise(int v_number, char *appname, long int msglist[])
{
	_kernel_swi_regs	regs_in, regs_out;

	regs_in.r[0] = v_number;
	regs_in.r[1] = *(int *)"TASK";
	regs_in.r[2] = (int) appname;
	regs_in.r[3] = (int) msglist;

	_kernel_swi(Wimp_Initialise, &regs_in, &regs_out);
	return regs_out.r[1]; /* this is the task handle, returned for later use */
}

void
au_closedown(int taskhandle)
{
	_kernel_swi_regs	regs_in, regs_out;

	regs_in.r[0] = taskhandle;
	regs_in.r[1] = *(int *)"TASK";
	_kernel_swi(Wimp_CloseDown, &regs_in, &regs_out);
}

int
au_create_iconbar_icon(int priority, unsigned long int whichside, unsigned long int iconflags, char *sprname)
{
	_kernel_swi_regs	regs_in, regs_out;
	unsigned char icon_block[ICON_BLOCK_SIZE];
	/* We need to build up an icon information datablock */
	au_wordtobyte(whichside, icon_block, 0);
	au_wordtobyte(IBAR_BBOX_MINX, icon_block, 4);
	au_wordtobyte(IBAR_BBOX_MINY, icon_block, 8);
	au_wordtobyte(IBAR_BBOX_MAXX, icon_block, 12);
	au_wordtobyte(IBAR_BBOX_MAXY, icon_block, 16);
	au_wordtobyte(iconflags, icon_block, 20);

	/* Copy the icon name into the appropriate place */
	strcpy( (char *) &icon_block[24], sprname);
	regs_in.r[0] = priority;
	regs_in.r[1] = (int) icon_block;
	_kernel_swi(Wimp_CreateIcon, &regs_in, &regs_out);
	return regs_out.r[0]; /* Return the icon handle */
}

void
au_wordtobyte(unsigned long int input, unsigned char block[], int index)
{
	unsigned long int mask = 255;

	/* The opposite of btow() - this function takes a 32-bit integer, splits
	 * it up into 4 bytes, and stores those in 4 consecutive cells of a
	 * character array indexed by index. This is done by using a mask to
	 * extract the data in sequence, with the & bitwise-and operator */

	block[index++] = (char) (input & mask); 
	/* shift mask to get second byte, and supply result as byte size */
	mask <<= 8;
	block[index++] = (char) ((input & mask) >> 8);
	mask <<= 8;
	block[index++] = (char) ((input & mask) >> 16);
	mask <<= 8;
	block[index++] = (char) ((input & mask) >> 24);

	return;
}

unsigned long int
au_bytetoword(unsigned char block[], int index)
{
	unsigned long int result = 0;
	int loop;

	/* This routine takes a data block and a starting byte, and converts the
	 * next four bytes into a word - we have to start at the most significant
	 * byte and work backwards */

	index += 3;
	result = block[index--];
	for(loop = 0; loop < 3; loop++) {
		result = result << 8; /* this shifts bits in result left by 8 spaces */
		result += block[index--];
	}

	return result;
}

void
au_opentemplate(char *filename)
{
	_kernel_swi_regs	regs_in, regs_out;
	regs_in.r[1] = (int) filename;
	_kernel_swi(Wimp_OpenTemplate, &regs_in, &regs_out);
}

void
au_closetemplate(void)
{
	_kernel_swi_regs	regs_in, regs_out;
	/* No data needed for CloseTemplate */
	_kernel_swi(Wimp_CloseTemplate, &regs_in, &regs_out);
}

int
au_loadtemplate(char *template_name, window_data *win_data, int call)
{
	_kernel_swi_regs	regs_in, regs_out;
	int	workspace_length = 0;
	int	next_entry;

	/* interrogate file to find out how much space we need */
	regs_in.r[1] = 0; /* tell SWI to find sizes */
	regs_in.r[5] = (int) template_name; /* pass name to SWI */
	regs_in.r[6] = call; /* 0 for first call */

	_kernel_swi(Wimp_LoadTemplate, &regs_in, &regs_out);
	win_data->buffer = calloc(regs_out.r[1], sizeof(unsigned char));
	workspace_length = regs_out.r[2]; /* err on side of caution */
	win_data->workspace = calloc(workspace_length, sizeof(unsigned char));
	win_data->win_name = calloc(strlen( (char *) regs_out.r[5]) + 1, sizeof(char));
	strcpy(win_data->win_name, (char *) regs_out.r[5]);

	/* Now reload template from file into memory */
	regs_in.r[1] = (int) win_data->buffer;
	regs_in.r[2] = (int) win_data->workspace;
	regs_in.r[3] = (int) win_data->workspace + workspace_length;
	regs_in.r[4] = -1; /* NO FONTS CATERED FOR IN TEMPLATES YET */
	regs_in.r[5] = (int) win_data->win_name;
	regs_in.r[6] = call;

	_kernel_swi(Wimp_LoadTemplate, &regs_in, &regs_out);
	next_entry = regs_out.r[6];

	/* Create the window, store window handle */
	regs_in.r[1] = (int) win_data->buffer;
	_kernel_swi(Wimp_CreateWindow, &regs_in, &regs_out);
	win_data->win_handle = regs_out.r[0];
	return next_entry; /* in case of wildcarded searches */
}

int
au_report_error(int errno, char *errmess, int flags, char *app_name)
{
   unsigned char errorblock[260];
   _kernel_swi_regs in, out;

   /* Set up the standard error block with the error number and message
      (zero terminated) */
   au_wordtobyte(errno, errorblock, 0);
   strcpy( (char *) &errorblock[4], errmess);

   /* R0 - pointer to standard error block
      R1 - error window flags
      R2 - pointer to application name for error box title */

   in.r[0] = (int) errorblock;
   in.r[1] = flags;
   in.r[2] = (int) app_name;

   _kernel_swi(Wimp_ReportError, &in, &out);

   /* Returns 1 if OK selected, 2 if Cancel selected */
   return out.r[1];
}

void
au_openwin_from_templatedata(window_data *win_data, long int position)
{
	_kernel_swi_regs	regs_in, regs_out;
	unsigned char	openwindow_buffer[36];
	int	i;

	au_wordtobyte( (unsigned long int) win_data->win_handle, openwindow_buffer, 0);
	for(i = 0; i < 6; i++) {
		au_wordtobyte(au_bytetoword(win_data->buffer, i*4), openwindow_buffer, (i+1) * 4);
	}
	au_wordtobyte(position, openwindow_buffer, 28);
	regs_in.r[1] = (int) openwindow_buffer;
	_kernel_swi(Wimp_OpenWindow, &regs_in, &regs_out);
	return;
}

int
au_wimp_poll(int pollmask, unsigned char *pollblock)
{
	_kernel_swi_regs	regs_in, regs_out;

	regs_in.r[0] = pollmask;
	regs_in.r[1] = (int) pollblock;

	_kernel_swi(Wimp_Poll, &regs_in, &regs_out);
	return regs_out.r[0]; /* Return the event code */
}

void
au_icon_text_change(char *text, unsigned long int win_h, unsigned long int icon_h)
{
   _kernel_swi_regs regs_in, regs_out;
   char *text_pointer;
   unsigned char temp_buffer[255];

   /* Find out where the icon's indirected text is stored in memory and copy
      a new string to it */
   text_pointer = au_get_ptr_to_icontext(win_h, icon_h);
   strcpy(text_pointer, text);

   /* Now we need to inform the WIMP that the icon needs redrawing by setting
      the icon flags - we don't actually change them with this call, but this
      spurs the WIMP into action */

   au_wordtobyte(win_h, temp_buffer, 0);
   au_wordtobyte(icon_h, temp_buffer, 4);
   au_wordtobyte(0, temp_buffer, 8);
   au_wordtobyte(0, temp_buffer, 12);

   regs_in.r[1] = (int) temp_buffer;

   _kernel_swi(Wimp_SetIconState, &regs_in, &regs_out);
   return;
}

void
au_icon_get_text(char *dest_string, unsigned long int win_hdl, unsigned long int icon_hdl)
{
	char	*text_pointer;

	/* Assumes dest_string has enough space */
	text_pointer = au_get_ptr_to_icontext(win_hdl, icon_hdl);
	strcpy(dest_string, text_pointer);
	return;
}

char *
au_get_ptr_to_icontext(unsigned long int winhdl, unsigned long int iconhdl)
{
   /* This procedure interrogates an icon to determine the address where its
      indirected text data is stored in memory, and returns it */

   unsigned char temp_buffer[255];
   _kernel_swi_regs regs_in, regs_out;
   char *result;

   au_wordtobyte(winhdl, temp_buffer, 0);
   au_wordtobyte(iconhdl, temp_buffer, 4);

   regs_in.r[1] = (int) temp_buffer;
   _kernel_swi(Wimp_GetIconState, &regs_in, &regs_out);

   result = (char *) au_bytetoword(temp_buffer, 28);
   return result;
}

void
au_buildmenu(char *title, menu_data *menu_dat)
{
	if(strlen(title) > 11) return; /* Do this more neatly! */
	/* Fill in the menu header with standard information */
	strcpy(menu_dat->title, title);
	menu_dat->colours = MENU_TITLEFORE | MENU_TITLEBACK | MENU_WORKFORE | MENU_WORKBACK;
	menu_dat->width = MENU_WIDTH;
	menu_dat->height = MENU_HEIGHT;
	menu_dat->vert_gap = MENU_VERTGAP;
	menu_dat->next_menuelem = NULL;
	menu_dat->size = sizeof(menu_data);
	return;
}

void
au_addtomenu(char *text, long int menu_flags, long int submenu, long int icon_flags, menu_data *
menu_dat)
{
	menu_element *pointer;

	if(strlen(text) > 11) return;
	/* Work our way to end of menu list */
	if(menu_dat->next_menuelem == NULL) {
		menu_dat->next_menuelem = calloc(1, sizeof(menu_element));
		menu_dat->size += sizeof(menu_element);
		pointer = menu_dat->next_menuelem;
	} else {
		pointer = menu_dat->next_menuelem;
		while (pointer->next_menuelem != 0) {
			pointer = pointer->next_menuelem;
		}
		pointer->next_menuelem = calloc(1, sizeof(menu_element));
		menu_dat->size += sizeof(menu_element);
		pointer = pointer->next_menuelem;
	}
	/* set up data */
	strcpy(pointer->menu_text, text);
	pointer->flags = menu_flags;
	pointer->submenu = submenu;

	/* Apply standard icon flags */
	icon_flags = icon_flags | MENUITEM_FORE | MENUITEM_BACK | ICON_ISTEXT | ICON_ISFILLED;
	pointer->menu_iconflags = icon_flags;
	return;
}

void
au_createmenu(menu_data *menu_dat)
{
	menu_element	*pointer;
	int	i;

	/* Assign memory */
	menu_dat->datablock = calloc(1, menu_dat->size);
	/* Begin copying data */
	strcpy((char *)menu_dat->datablock, menu_dat->title);
	au_wordtobyte(menu_dat->colours, menu_dat->datablock, 12);
	au_wordtobyte(menu_dat->width, menu_dat->datablock, 16);
	au_wordtobyte(menu_dat->height, menu_dat->datablock, 20);
	au_wordtobyte(menu_dat->vert_gap, menu_dat->datablock, 24);
	/* end of header info */
	i = 28;

	pointer = menu_dat->next_menuelem;

	while(pointer != NULL) {

		au_wordtobyte(pointer->flags, menu_dat->datablock, i);
		i += 4;
		au_wordtobyte(pointer->submenu, menu_dat->datablock, i);
		i += 4;
		au_wordtobyte(pointer->menu_iconflags, menu_dat->datablock, i);
		i += 4;
		strcpy((char *) &menu_dat->datablock[i], pointer->menu_text);
		i += 12;
		pointer = pointer->next_menuelem;
	}
	return;
}

void
au_openmenu(menu_data *menu_dat, int mouse_x, int mouse_y)
{
	_kernel_swi_regs	regs_in, regs_out;

	regs_in.r[1] = (int) menu_dat->datablock;
	regs_in.r[2] = mouse_x;
	regs_in.r[3] = mouse_y;
	_kernel_swi(Wimp_CreateMenu, &regs_in, &regs_out);
	return;
}

void
au_losecaret(void)
{
	_kernel_swi_regs	regs_in, regs_out;

	regs_in.r[0] = -1;
	regs_in.r[1] = -1;
	regs_in.r[0] = -1;
	regs_in.r[0] = -1;
	regs_in.r[4] = -1;
	regs_in.r[5] = -1;

	_kernel_swi(Wimp_SetCaretPosition, &regs_in, &regs_out);
}

void
au_dragbox(unsigned long int winhdl, unsigned long int iconhdl)
{
	_kernel_swi_regs	regs_in, regs_out;
	unsigned char	temp_buffer[256];
	unsigned char	temp_buffer2[256];
	long int	min_x, min_y, max_x, max_y = 0;

	/* Get some icon information */
	au_geticoninfo(winhdl, iconhdl, temp_buffer2);

	au_wordtobyte(winhdl, temp_buffer, 0);
	au_wordtobyte(SAVEDRAG_TYPE, temp_buffer, 4);

	/* Copy in max and min coordinates for bounding box */
	min_x = au_bytetoword(temp_buffer2, 8);
	min_y = au_bytetoword(temp_buffer2, 12);
	max_x = au_bytetoword(temp_buffer2, 16);
	max_y = au_bytetoword(temp_buffer2, 20);

	au_wordtobyte(winhdl, temp_buffer2, 0);
	regs_in.r[1] = (int) temp_buffer2;
	_kernel_swi(Wimp_GetWindowState, &regs_in, &regs_out);

	min_x += au_bytetoword(temp_buffer2, 4);
	max_x += au_bytetoword(temp_buffer2, 4);
	min_x -= au_bytetoword(temp_buffer2, 20);
	max_x -= au_bytetoword(temp_buffer2, 20);
	min_y += au_bytetoword(temp_buffer2, 16);
	max_y += au_bytetoword(temp_buffer2, 16);
	min_y -= au_bytetoword(temp_buffer2, 24);
	max_y -= au_bytetoword(temp_buffer2, 24);


	au_wordtobyte(min_x, temp_buffer, 8);
	au_wordtobyte(min_y, temp_buffer, 12);
	au_wordtobyte(max_x, temp_buffer, 16);
	au_wordtobyte(max_y, temp_buffer, 20);
	au_wordtobyte(0, temp_buffer, 24);
	au_wordtobyte(0, temp_buffer, 28);
	au_wordtobyte(0, temp_buffer, 32);
	au_wordtobyte(0, temp_buffer, 36);

	regs_in.r[1] = (int) temp_buffer;
	_kernel_swi(Wimp_DragBox, &regs_in, &regs_out);
	/* The end-of-drag should be caught with the appropriate poll message */
	return;
}

void
au_geticoninfo(unsigned long int winhdl, unsigned long int iconhdl, unsigned char *buffer)
{
	_kernel_swi_regs	regs_in, regs_out;

	au_wordtobyte(winhdl, buffer, 0);
	au_wordtobyte(iconhdl, buffer, 4);
	regs_in.r[1] = (int) buffer;
	_kernel_swi(Wimp_GetIconState, &regs_in, &regs_out);
	return;
}
00000000  2f 2a 20 41 63 6f 72 6e  20 55 73 65 72 20 6c 69  |/* Acorn User li|
00000010  62 72 61 72 79 20 66 6f  72 20 57 49 4d 50 20 70  |brary for WIMP p|
00000020  72 6f 67 72 61 6d 6d 69  6e 67 20 69 6e 20 43 20  |rogramming in C |
00000030  2a 2f 0a 2f 2a 20 42 79  20 53 74 65 76 65 20 4d  |*/./* By Steve M|
00000040  75 6d 66 6f 72 64 2c 20  38 74 68 20 53 65 70 74  |umford, 8th Sept|
00000050  65 6d 62 65 72 20 31 39  39 36 20 2a 2f 0a 0a 2f  |ember 1996 */../|
00000060  2a 20 23 49 6e 63 6c 75  64 65 20 74 68 65 20 61  |* #Include the a|
00000070  70 70 72 6f 70 72 69 61  74 65 20 66 69 6c 65 73  |ppropriate files|
00000080  20 2d 20 41 55 4c 69 62  2e 68 20 63 6f 6e 74 61  | - AULib.h conta|
00000090  69 6e 73 20 65 76 65 72  79 74 68 69 6e 67 20 77  |ins everything w|
000000a0  65 20 6e 65 65 64 20 2a  2f 20 0a 0a 23 69 6e 63  |e need */ ..#inc|
000000b0  6c 75 64 65 20 22 41 55  6c 69 62 2e 68 22 0a 0a  |lude "AUlib.h"..|
000000c0  69 6e 74 0a 61 75 5f 69  6e 69 74 69 61 6c 69 73  |int.au_initialis|
000000d0  65 28 69 6e 74 20 76 5f  6e 75 6d 62 65 72 2c 20  |e(int v_number, |
000000e0  63 68 61 72 20 2a 61 70  70 6e 61 6d 65 2c 20 6c  |char *appname, l|
000000f0  6f 6e 67 20 69 6e 74 20  6d 73 67 6c 69 73 74 5b  |ong int msglist[|
00000100  5d 29 0a 7b 0a 09 5f 6b  65 72 6e 65 6c 5f 73 77  |]).{.._kernel_sw|
00000110  69 5f 72 65 67 73 09 72  65 67 73 5f 69 6e 2c 20  |i_regs.regs_in, |
00000120  72 65 67 73 5f 6f 75 74  3b 0a 0a 09 72 65 67 73  |regs_out;...regs|
00000130  5f 69 6e 2e 72 5b 30 5d  20 3d 20 76 5f 6e 75 6d  |_in.r[0] = v_num|
00000140  62 65 72 3b 0a 09 72 65  67 73 5f 69 6e 2e 72 5b  |ber;..regs_in.r[|
00000150  31 5d 20 3d 20 2a 28 69  6e 74 20 2a 29 22 54 41  |1] = *(int *)"TA|
00000160  53 4b 22 3b 0a 09 72 65  67 73 5f 69 6e 2e 72 5b  |SK";..regs_in.r[|
00000170  32 5d 20 3d 20 28 69 6e  74 29 20 61 70 70 6e 61  |2] = (int) appna|
00000180  6d 65 3b 0a 09 72 65 67  73 5f 69 6e 2e 72 5b 33  |me;..regs_in.r[3|
00000190  5d 20 3d 20 28 69 6e 74  29 20 6d 73 67 6c 69 73  |] = (int) msglis|
000001a0  74 3b 0a 0a 09 5f 6b 65  72 6e 65 6c 5f 73 77 69  |t;..._kernel_swi|
000001b0  28 57 69 6d 70 5f 49 6e  69 74 69 61 6c 69 73 65  |(Wimp_Initialise|
000001c0  2c 20 26 72 65 67 73 5f  69 6e 2c 20 26 72 65 67  |, &regs_in, &reg|
000001d0  73 5f 6f 75 74 29 3b 0a  09 72 65 74 75 72 6e 20  |s_out);..return |
000001e0  72 65 67 73 5f 6f 75 74  2e 72 5b 31 5d 3b 20 2f  |regs_out.r[1]; /|
000001f0  2a 20 74 68 69 73 20 69  73 20 74 68 65 20 74 61  |* this is the ta|
00000200  73 6b 20 68 61 6e 64 6c  65 2c 20 72 65 74 75 72  |sk handle, retur|
00000210  6e 65 64 20 66 6f 72 20  6c 61 74 65 72 20 75 73  |ned for later us|
00000220  65 20 2a 2f 0a 7d 0a 0a  76 6f 69 64 0a 61 75 5f  |e */.}..void.au_|
00000230  63 6c 6f 73 65 64 6f 77  6e 28 69 6e 74 20 74 61  |closedown(int ta|
00000240  73 6b 68 61 6e 64 6c 65  29 0a 7b 0a 09 5f 6b 65  |skhandle).{.._ke|
00000250  72 6e 65 6c 5f 73 77 69  5f 72 65 67 73 09 72 65  |rnel_swi_regs.re|
00000260  67 73 5f 69 6e 2c 20 72  65 67 73 5f 6f 75 74 3b  |gs_in, regs_out;|
00000270  0a 0a 09 72 65 67 73 5f  69 6e 2e 72 5b 30 5d 20  |...regs_in.r[0] |
00000280  3d 20 74 61 73 6b 68 61  6e 64 6c 65 3b 0a 09 72  |= taskhandle;..r|
00000290  65 67 73 5f 69 6e 2e 72  5b 31 5d 20 3d 20 2a 28  |egs_in.r[1] = *(|
000002a0  69 6e 74 20 2a 29 22 54  41 53 4b 22 3b 0a 09 5f  |int *)"TASK";.._|
000002b0  6b 65 72 6e 65 6c 5f 73  77 69 28 57 69 6d 70 5f  |kernel_swi(Wimp_|
000002c0  43 6c 6f 73 65 44 6f 77  6e 2c 20 26 72 65 67 73  |CloseDown, &regs|
000002d0  5f 69 6e 2c 20 26 72 65  67 73 5f 6f 75 74 29 3b  |_in, &regs_out);|
000002e0  0a 7d 0a 0a 69 6e 74 0a  61 75 5f 63 72 65 61 74  |.}..int.au_creat|
000002f0  65 5f 69 63 6f 6e 62 61  72 5f 69 63 6f 6e 28 69  |e_iconbar_icon(i|
00000300  6e 74 20 70 72 69 6f 72  69 74 79 2c 20 75 6e 73  |nt priority, uns|
00000310  69 67 6e 65 64 20 6c 6f  6e 67 20 69 6e 74 20 77  |igned long int w|
00000320  68 69 63 68 73 69 64 65  2c 20 75 6e 73 69 67 6e  |hichside, unsign|
00000330  65 64 20 6c 6f 6e 67 20  69 6e 74 20 69 63 6f 6e  |ed long int icon|
00000340  66 6c 61 67 73 2c 20 63  68 61 72 20 2a 73 70 72  |flags, char *spr|
00000350  6e 61 6d 65 29 0a 7b 0a  09 5f 6b 65 72 6e 65 6c  |name).{.._kernel|
00000360  5f 73 77 69 5f 72 65 67  73 09 72 65 67 73 5f 69  |_swi_regs.regs_i|
00000370  6e 2c 20 72 65 67 73 5f  6f 75 74 3b 0a 09 75 6e  |n, regs_out;..un|
00000380  73 69 67 6e 65 64 20 63  68 61 72 20 69 63 6f 6e  |signed char icon|
00000390  5f 62 6c 6f 63 6b 5b 49  43 4f 4e 5f 42 4c 4f 43  |_block[ICON_BLOC|
000003a0  4b 5f 53 49 5a 45 5d 3b  0a 09 2f 2a 20 57 65 20  |K_SIZE];../* We |
000003b0  6e 65 65 64 20 74 6f 20  62 75 69 6c 64 20 75 70  |need to build up|
000003c0  20 61 6e 20 69 63 6f 6e  20 69 6e 66 6f 72 6d 61  | an icon informa|
000003d0  74 69 6f 6e 20 64 61 74  61 62 6c 6f 63 6b 20 2a  |tion datablock *|
000003e0  2f 0a 09 61 75 5f 77 6f  72 64 74 6f 62 79 74 65  |/..au_wordtobyte|
000003f0  28 77 68 69 63 68 73 69  64 65 2c 20 69 63 6f 6e  |(whichside, icon|
00000400  5f 62 6c 6f 63 6b 2c 20  30 29 3b 0a 09 61 75 5f  |_block, 0);..au_|
00000410  77 6f 72 64 74 6f 62 79  74 65 28 49 42 41 52 5f  |wordtobyte(IBAR_|
00000420  42 42 4f 58 5f 4d 49 4e  58 2c 20 69 63 6f 6e 5f  |BBOX_MINX, icon_|
00000430  62 6c 6f 63 6b 2c 20 34  29 3b 0a 09 61 75 5f 77  |block, 4);..au_w|
00000440  6f 72 64 74 6f 62 79 74  65 28 49 42 41 52 5f 42  |ordtobyte(IBAR_B|
00000450  42 4f 58 5f 4d 49 4e 59  2c 20 69 63 6f 6e 5f 62  |BOX_MINY, icon_b|
00000460  6c 6f 63 6b 2c 20 38 29  3b 0a 09 61 75 5f 77 6f  |lock, 8);..au_wo|
00000470  72 64 74 6f 62 79 74 65  28 49 42 41 52 5f 42 42  |rdtobyte(IBAR_BB|
00000480  4f 58 5f 4d 41 58 58 2c  20 69 63 6f 6e 5f 62 6c  |OX_MAXX, icon_bl|
00000490  6f 63 6b 2c 20 31 32 29  3b 0a 09 61 75 5f 77 6f  |ock, 12);..au_wo|
000004a0  72 64 74 6f 62 79 74 65  28 49 42 41 52 5f 42 42  |rdtobyte(IBAR_BB|
000004b0  4f 58 5f 4d 41 58 59 2c  20 69 63 6f 6e 5f 62 6c  |OX_MAXY, icon_bl|
000004c0  6f 63 6b 2c 20 31 36 29  3b 0a 09 61 75 5f 77 6f  |ock, 16);..au_wo|
000004d0  72 64 74 6f 62 79 74 65  28 69 63 6f 6e 66 6c 61  |rdtobyte(iconfla|
000004e0  67 73 2c 20 69 63 6f 6e  5f 62 6c 6f 63 6b 2c 20  |gs, icon_block, |
000004f0  32 30 29 3b 0a 0a 09 2f  2a 20 43 6f 70 79 20 74  |20);.../* Copy t|
00000500  68 65 20 69 63 6f 6e 20  6e 61 6d 65 20 69 6e 74  |he icon name int|
00000510  6f 20 74 68 65 20 61 70  70 72 6f 70 72 69 61 74  |o the appropriat|
00000520  65 20 70 6c 61 63 65 20  2a 2f 0a 09 73 74 72 63  |e place */..strc|
00000530  70 79 28 20 28 63 68 61  72 20 2a 29 20 26 69 63  |py( (char *) &ic|
00000540  6f 6e 5f 62 6c 6f 63 6b  5b 32 34 5d 2c 20 73 70  |on_block[24], sp|
00000550  72 6e 61 6d 65 29 3b 0a  09 72 65 67 73 5f 69 6e  |rname);..regs_in|
00000560  2e 72 5b 30 5d 20 3d 20  70 72 69 6f 72 69 74 79  |.r[0] = priority|
00000570  3b 0a 09 72 65 67 73 5f  69 6e 2e 72 5b 31 5d 20  |;..regs_in.r[1] |
00000580  3d 20 28 69 6e 74 29 20  69 63 6f 6e 5f 62 6c 6f  |= (int) icon_blo|
00000590  63 6b 3b 0a 09 5f 6b 65  72 6e 65 6c 5f 73 77 69  |ck;.._kernel_swi|
000005a0  28 57 69 6d 70 5f 43 72  65 61 74 65 49 63 6f 6e  |(Wimp_CreateIcon|
000005b0  2c 20 26 72 65 67 73 5f  69 6e 2c 20 26 72 65 67  |, &regs_in, &reg|
000005c0  73 5f 6f 75 74 29 3b 0a  09 72 65 74 75 72 6e 20  |s_out);..return |
000005d0  72 65 67 73 5f 6f 75 74  2e 72 5b 30 5d 3b 20 2f  |regs_out.r[0]; /|
000005e0  2a 20 52 65 74 75 72 6e  20 74 68 65 20 69 63 6f  |* Return the ico|
000005f0  6e 20 68 61 6e 64 6c 65  20 2a 2f 0a 7d 0a 0a 76  |n handle */.}..v|
00000600  6f 69 64 0a 61 75 5f 77  6f 72 64 74 6f 62 79 74  |oid.au_wordtobyt|
00000610  65 28 75 6e 73 69 67 6e  65 64 20 6c 6f 6e 67 20  |e(unsigned long |
00000620  69 6e 74 20 69 6e 70 75  74 2c 20 75 6e 73 69 67  |int input, unsig|
00000630  6e 65 64 20 63 68 61 72  20 62 6c 6f 63 6b 5b 5d  |ned char block[]|
00000640  2c 20 69 6e 74 20 69 6e  64 65 78 29 0a 7b 0a 09  |, int index).{..|
00000650  75 6e 73 69 67 6e 65 64  20 6c 6f 6e 67 20 69 6e  |unsigned long in|
00000660  74 20 6d 61 73 6b 20 3d  20 32 35 35 3b 0a 0a 09  |t mask = 255;...|
00000670  2f 2a 20 54 68 65 20 6f  70 70 6f 73 69 74 65 20  |/* The opposite |
00000680  6f 66 20 62 74 6f 77 28  29 20 2d 20 74 68 69 73  |of btow() - this|
00000690  20 66 75 6e 63 74 69 6f  6e 20 74 61 6b 65 73 20  | function takes |
000006a0  61 20 33 32 2d 62 69 74  20 69 6e 74 65 67 65 72  |a 32-bit integer|
000006b0  2c 20 73 70 6c 69 74 73  0a 09 20 2a 20 69 74 20  |, splits.. * it |
000006c0  75 70 20 69 6e 74 6f 20  34 20 62 79 74 65 73 2c  |up into 4 bytes,|
000006d0  20 61 6e 64 20 73 74 6f  72 65 73 20 74 68 6f 73  | and stores thos|
000006e0  65 20 69 6e 20 34 20 63  6f 6e 73 65 63 75 74 69  |e in 4 consecuti|
000006f0  76 65 20 63 65 6c 6c 73  20 6f 66 20 61 0a 09 20  |ve cells of a.. |
00000700  2a 20 63 68 61 72 61 63  74 65 72 20 61 72 72 61  |* character arra|
00000710  79 20 69 6e 64 65 78 65  64 20 62 79 20 69 6e 64  |y indexed by ind|
00000720  65 78 2e 20 54 68 69 73  20 69 73 20 64 6f 6e 65  |ex. This is done|
00000730  20 62 79 20 75 73 69 6e  67 20 61 20 6d 61 73 6b  | by using a mask|
00000740  20 74 6f 0a 09 20 2a 20  65 78 74 72 61 63 74 20  | to.. * extract |
00000750  74 68 65 20 64 61 74 61  20 69 6e 20 73 65 71 75  |the data in sequ|
00000760  65 6e 63 65 2c 20 77 69  74 68 20 74 68 65 20 26  |ence, with the &|
00000770  20 62 69 74 77 69 73 65  2d 61 6e 64 20 6f 70 65  | bitwise-and ope|
00000780  72 61 74 6f 72 20 2a 2f  0a 0a 09 62 6c 6f 63 6b  |rator */...block|
00000790  5b 69 6e 64 65 78 2b 2b  5d 20 3d 20 28 63 68 61  |[index++] = (cha|
000007a0  72 29 20 28 69 6e 70 75  74 20 26 20 6d 61 73 6b  |r) (input & mask|
000007b0  29 3b 20 0a 09 2f 2a 20  73 68 69 66 74 20 6d 61  |); ../* shift ma|
000007c0  73 6b 20 74 6f 20 67 65  74 20 73 65 63 6f 6e 64  |sk to get second|
000007d0  20 62 79 74 65 2c 20 61  6e 64 20 73 75 70 70 6c  | byte, and suppl|
000007e0  79 20 72 65 73 75 6c 74  20 61 73 20 62 79 74 65  |y result as byte|
000007f0  20 73 69 7a 65 20 2a 2f  0a 09 6d 61 73 6b 20 3c  | size */..mask <|
00000800  3c 3d 20 38 3b 0a 09 62  6c 6f 63 6b 5b 69 6e 64  |<= 8;..block[ind|
00000810  65 78 2b 2b 5d 20 3d 20  28 63 68 61 72 29 20 28  |ex++] = (char) (|
00000820  28 69 6e 70 75 74 20 26  20 6d 61 73 6b 29 20 3e  |(input & mask) >|
00000830  3e 20 38 29 3b 0a 09 6d  61 73 6b 20 3c 3c 3d 20  |> 8);..mask <<= |
00000840  38 3b 0a 09 62 6c 6f 63  6b 5b 69 6e 64 65 78 2b  |8;..block[index+|
00000850  2b 5d 20 3d 20 28 63 68  61 72 29 20 28 28 69 6e  |+] = (char) ((in|
00000860  70 75 74 20 26 20 6d 61  73 6b 29 20 3e 3e 20 31  |put & mask) >> 1|
00000870  36 29 3b 0a 09 6d 61 73  6b 20 3c 3c 3d 20 38 3b  |6);..mask <<= 8;|
00000880  0a 09 62 6c 6f 63 6b 5b  69 6e 64 65 78 2b 2b 5d  |..block[index++]|
00000890  20 3d 20 28 63 68 61 72  29 20 28 28 69 6e 70 75  | = (char) ((inpu|
000008a0  74 20 26 20 6d 61 73 6b  29 20 3e 3e 20 32 34 29  |t & mask) >> 24)|
000008b0  3b 0a 0a 09 72 65 74 75  72 6e 3b 0a 7d 0a 0a 75  |;...return;.}..u|
000008c0  6e 73 69 67 6e 65 64 20  6c 6f 6e 67 20 69 6e 74  |nsigned long int|
000008d0  0a 61 75 5f 62 79 74 65  74 6f 77 6f 72 64 28 75  |.au_bytetoword(u|
000008e0  6e 73 69 67 6e 65 64 20  63 68 61 72 20 62 6c 6f  |nsigned char blo|
000008f0  63 6b 5b 5d 2c 20 69 6e  74 20 69 6e 64 65 78 29  |ck[], int index)|
00000900  0a 7b 0a 09 75 6e 73 69  67 6e 65 64 20 6c 6f 6e  |.{..unsigned lon|
00000910  67 20 69 6e 74 20 72 65  73 75 6c 74 20 3d 20 30  |g int result = 0|
00000920  3b 0a 09 69 6e 74 20 6c  6f 6f 70 3b 0a 0a 09 2f  |;..int loop;.../|
00000930  2a 20 54 68 69 73 20 72  6f 75 74 69 6e 65 20 74  |* This routine t|
00000940  61 6b 65 73 20 61 20 64  61 74 61 20 62 6c 6f 63  |akes a data bloc|
00000950  6b 20 61 6e 64 20 61 20  73 74 61 72 74 69 6e 67  |k and a starting|
00000960  20 62 79 74 65 2c 20 61  6e 64 20 63 6f 6e 76 65  | byte, and conve|
00000970  72 74 73 20 74 68 65 0a  09 20 2a 20 6e 65 78 74  |rts the.. * next|
00000980  20 66 6f 75 72 20 62 79  74 65 73 20 69 6e 74 6f  | four bytes into|
00000990  20 61 20 77 6f 72 64 20  2d 20 77 65 20 68 61 76  | a word - we hav|
000009a0  65 20 74 6f 20 73 74 61  72 74 20 61 74 20 74 68  |e to start at th|
000009b0  65 20 6d 6f 73 74 20 73  69 67 6e 69 66 69 63 61  |e most significa|
000009c0  6e 74 0a 09 20 2a 20 62  79 74 65 20 61 6e 64 20  |nt.. * byte and |
000009d0  77 6f 72 6b 20 62 61 63  6b 77 61 72 64 73 20 2a  |work backwards *|
000009e0  2f 0a 0a 09 69 6e 64 65  78 20 2b 3d 20 33 3b 0a  |/...index += 3;.|
000009f0  09 72 65 73 75 6c 74 20  3d 20 62 6c 6f 63 6b 5b  |.result = block[|
00000a00  69 6e 64 65 78 2d 2d 5d  3b 0a 09 66 6f 72 28 6c  |index--];..for(l|
00000a10  6f 6f 70 20 3d 20 30 3b  20 6c 6f 6f 70 20 3c 20  |oop = 0; loop < |
00000a20  33 3b 20 6c 6f 6f 70 2b  2b 29 20 7b 0a 09 09 72  |3; loop++) {...r|
00000a30  65 73 75 6c 74 20 3d 20  72 65 73 75 6c 74 20 3c  |esult = result <|
00000a40  3c 20 38 3b 20 2f 2a 20  74 68 69 73 20 73 68 69  |< 8; /* this shi|
00000a50  66 74 73 20 62 69 74 73  20 69 6e 20 72 65 73 75  |fts bits in resu|
00000a60  6c 74 20 6c 65 66 74 20  62 79 20 38 20 73 70 61  |lt left by 8 spa|
00000a70  63 65 73 20 2a 2f 0a 09  09 72 65 73 75 6c 74 20  |ces */...result |
00000a80  2b 3d 20 62 6c 6f 63 6b  5b 69 6e 64 65 78 2d 2d  |+= block[index--|
00000a90  5d 3b 0a 09 7d 0a 0a 09  72 65 74 75 72 6e 20 72  |];..}...return r|
00000aa0  65 73 75 6c 74 3b 0a 7d  0a 0a 76 6f 69 64 0a 61  |esult;.}..void.a|
00000ab0  75 5f 6f 70 65 6e 74 65  6d 70 6c 61 74 65 28 63  |u_opentemplate(c|
00000ac0  68 61 72 20 2a 66 69 6c  65 6e 61 6d 65 29 0a 7b  |har *filename).{|
00000ad0  0a 09 5f 6b 65 72 6e 65  6c 5f 73 77 69 5f 72 65  |.._kernel_swi_re|
00000ae0  67 73 09 72 65 67 73 5f  69 6e 2c 20 72 65 67 73  |gs.regs_in, regs|
00000af0  5f 6f 75 74 3b 0a 09 72  65 67 73 5f 69 6e 2e 72  |_out;..regs_in.r|
00000b00  5b 31 5d 20 3d 20 28 69  6e 74 29 20 66 69 6c 65  |[1] = (int) file|
00000b10  6e 61 6d 65 3b 0a 09 5f  6b 65 72 6e 65 6c 5f 73  |name;.._kernel_s|
00000b20  77 69 28 57 69 6d 70 5f  4f 70 65 6e 54 65 6d 70  |wi(Wimp_OpenTemp|
00000b30  6c 61 74 65 2c 20 26 72  65 67 73 5f 69 6e 2c 20  |late, &regs_in, |
00000b40  26 72 65 67 73 5f 6f 75  74 29 3b 0a 7d 0a 0a 76  |&regs_out);.}..v|
00000b50  6f 69 64 0a 61 75 5f 63  6c 6f 73 65 74 65 6d 70  |oid.au_closetemp|
00000b60  6c 61 74 65 28 76 6f 69  64 29 0a 7b 0a 09 5f 6b  |late(void).{.._k|
00000b70  65 72 6e 65 6c 5f 73 77  69 5f 72 65 67 73 09 72  |ernel_swi_regs.r|
00000b80  65 67 73 5f 69 6e 2c 20  72 65 67 73 5f 6f 75 74  |egs_in, regs_out|
00000b90  3b 0a 09 2f 2a 20 4e 6f  20 64 61 74 61 20 6e 65  |;../* No data ne|
00000ba0  65 64 65 64 20 66 6f 72  20 43 6c 6f 73 65 54 65  |eded for CloseTe|
00000bb0  6d 70 6c 61 74 65 20 2a  2f 0a 09 5f 6b 65 72 6e  |mplate */.._kern|
00000bc0  65 6c 5f 73 77 69 28 57  69 6d 70 5f 43 6c 6f 73  |el_swi(Wimp_Clos|
00000bd0  65 54 65 6d 70 6c 61 74  65 2c 20 26 72 65 67 73  |eTemplate, &regs|
00000be0  5f 69 6e 2c 20 26 72 65  67 73 5f 6f 75 74 29 3b  |_in, &regs_out);|
00000bf0  0a 7d 0a 0a 69 6e 74 0a  61 75 5f 6c 6f 61 64 74  |.}..int.au_loadt|
00000c00  65 6d 70 6c 61 74 65 28  63 68 61 72 20 2a 74 65  |emplate(char *te|
00000c10  6d 70 6c 61 74 65 5f 6e  61 6d 65 2c 20 77 69 6e  |mplate_name, win|
00000c20  64 6f 77 5f 64 61 74 61  20 2a 77 69 6e 5f 64 61  |dow_data *win_da|
00000c30  74 61 2c 20 69 6e 74 20  63 61 6c 6c 29 0a 7b 0a  |ta, int call).{.|
00000c40  09 5f 6b 65 72 6e 65 6c  5f 73 77 69 5f 72 65 67  |._kernel_swi_reg|
00000c50  73 09 72 65 67 73 5f 69  6e 2c 20 72 65 67 73 5f  |s.regs_in, regs_|
00000c60  6f 75 74 3b 0a 09 69 6e  74 09 77 6f 72 6b 73 70  |out;..int.worksp|
00000c70  61 63 65 5f 6c 65 6e 67  74 68 20 3d 20 30 3b 0a  |ace_length = 0;.|
00000c80  09 69 6e 74 09 6e 65 78  74 5f 65 6e 74 72 79 3b  |.int.next_entry;|
00000c90  0a 0a 09 2f 2a 20 69 6e  74 65 72 72 6f 67 61 74  |.../* interrogat|
00000ca0  65 20 66 69 6c 65 20 74  6f 20 66 69 6e 64 20 6f  |e file to find o|
00000cb0  75 74 20 68 6f 77 20 6d  75 63 68 20 73 70 61 63  |ut how much spac|
00000cc0  65 20 77 65 20 6e 65 65  64 20 2a 2f 0a 09 72 65  |e we need */..re|
00000cd0  67 73 5f 69 6e 2e 72 5b  31 5d 20 3d 20 30 3b 20  |gs_in.r[1] = 0; |
00000ce0  2f 2a 20 74 65 6c 6c 20  53 57 49 20 74 6f 20 66  |/* tell SWI to f|
00000cf0  69 6e 64 20 73 69 7a 65  73 20 2a 2f 0a 09 72 65  |ind sizes */..re|
00000d00  67 73 5f 69 6e 2e 72 5b  35 5d 20 3d 20 28 69 6e  |gs_in.r[5] = (in|
00000d10  74 29 20 74 65 6d 70 6c  61 74 65 5f 6e 61 6d 65  |t) template_name|
00000d20  3b 20 2f 2a 20 70 61 73  73 20 6e 61 6d 65 20 74  |; /* pass name t|
00000d30  6f 20 53 57 49 20 2a 2f  0a 09 72 65 67 73 5f 69  |o SWI */..regs_i|
00000d40  6e 2e 72 5b 36 5d 20 3d  20 63 61 6c 6c 3b 20 2f  |n.r[6] = call; /|
00000d50  2a 20 30 20 66 6f 72 20  66 69 72 73 74 20 63 61  |* 0 for first ca|
00000d60  6c 6c 20 2a 2f 0a 0a 09  5f 6b 65 72 6e 65 6c 5f  |ll */..._kernel_|
00000d70  73 77 69 28 57 69 6d 70  5f 4c 6f 61 64 54 65 6d  |swi(Wimp_LoadTem|
00000d80  70 6c 61 74 65 2c 20 26  72 65 67 73 5f 69 6e 2c  |plate, &regs_in,|
00000d90  20 26 72 65 67 73 5f 6f  75 74 29 3b 0a 09 77 69  | &regs_out);..wi|
00000da0  6e 5f 64 61 74 61 2d 3e  62 75 66 66 65 72 20 3d  |n_data->buffer =|
00000db0  20 63 61 6c 6c 6f 63 28  72 65 67 73 5f 6f 75 74  | calloc(regs_out|
00000dc0  2e 72 5b 31 5d 2c 20 73  69 7a 65 6f 66 28 75 6e  |.r[1], sizeof(un|
00000dd0  73 69 67 6e 65 64 20 63  68 61 72 29 29 3b 0a 09  |signed char));..|
00000de0  77 6f 72 6b 73 70 61 63  65 5f 6c 65 6e 67 74 68  |workspace_length|
00000df0  20 3d 20 72 65 67 73 5f  6f 75 74 2e 72 5b 32 5d  | = regs_out.r[2]|
00000e00  3b 20 2f 2a 20 65 72 72  20 6f 6e 20 73 69 64 65  |; /* err on side|
00000e10  20 6f 66 20 63 61 75 74  69 6f 6e 20 2a 2f 0a 09  | of caution */..|
00000e20  77 69 6e 5f 64 61 74 61  2d 3e 77 6f 72 6b 73 70  |win_data->worksp|
00000e30  61 63 65 20 3d 20 63 61  6c 6c 6f 63 28 77 6f 72  |ace = calloc(wor|
00000e40  6b 73 70 61 63 65 5f 6c  65 6e 67 74 68 2c 20 73  |kspace_length, s|
00000e50  69 7a 65 6f 66 28 75 6e  73 69 67 6e 65 64 20 63  |izeof(unsigned c|
00000e60  68 61 72 29 29 3b 0a 09  77 69 6e 5f 64 61 74 61  |har));..win_data|
00000e70  2d 3e 77 69 6e 5f 6e 61  6d 65 20 3d 20 63 61 6c  |->win_name = cal|
00000e80  6c 6f 63 28 73 74 72 6c  65 6e 28 20 28 63 68 61  |loc(strlen( (cha|
00000e90  72 20 2a 29 20 72 65 67  73 5f 6f 75 74 2e 72 5b  |r *) regs_out.r[|
00000ea0  35 5d 29 20 2b 20 31 2c  20 73 69 7a 65 6f 66 28  |5]) + 1, sizeof(|
00000eb0  63 68 61 72 29 29 3b 0a  09 73 74 72 63 70 79 28  |char));..strcpy(|
00000ec0  77 69 6e 5f 64 61 74 61  2d 3e 77 69 6e 5f 6e 61  |win_data->win_na|
00000ed0  6d 65 2c 20 28 63 68 61  72 20 2a 29 20 72 65 67  |me, (char *) reg|
00000ee0  73 5f 6f 75 74 2e 72 5b  35 5d 29 3b 0a 0a 09 2f  |s_out.r[5]);.../|
00000ef0  2a 20 4e 6f 77 20 72 65  6c 6f 61 64 20 74 65 6d  |* Now reload tem|
00000f00  70 6c 61 74 65 20 66 72  6f 6d 20 66 69 6c 65 20  |plate from file |
00000f10  69 6e 74 6f 20 6d 65 6d  6f 72 79 20 2a 2f 0a 09  |into memory */..|
00000f20  72 65 67 73 5f 69 6e 2e  72 5b 31 5d 20 3d 20 28  |regs_in.r[1] = (|
00000f30  69 6e 74 29 20 77 69 6e  5f 64 61 74 61 2d 3e 62  |int) win_data->b|
00000f40  75 66 66 65 72 3b 0a 09  72 65 67 73 5f 69 6e 2e  |uffer;..regs_in.|
00000f50  72 5b 32 5d 20 3d 20 28  69 6e 74 29 20 77 69 6e  |r[2] = (int) win|
00000f60  5f 64 61 74 61 2d 3e 77  6f 72 6b 73 70 61 63 65  |_data->workspace|
00000f70  3b 0a 09 72 65 67 73 5f  69 6e 2e 72 5b 33 5d 20  |;..regs_in.r[3] |
00000f80  3d 20 28 69 6e 74 29 20  77 69 6e 5f 64 61 74 61  |= (int) win_data|
00000f90  2d 3e 77 6f 72 6b 73 70  61 63 65 20 2b 20 77 6f  |->workspace + wo|
00000fa0  72 6b 73 70 61 63 65 5f  6c 65 6e 67 74 68 3b 0a  |rkspace_length;.|
00000fb0  09 72 65 67 73 5f 69 6e  2e 72 5b 34 5d 20 3d 20  |.regs_in.r[4] = |
00000fc0  2d 31 3b 20 2f 2a 20 4e  4f 20 46 4f 4e 54 53 20  |-1; /* NO FONTS |
00000fd0  43 41 54 45 52 45 44 20  46 4f 52 20 49 4e 20 54  |CATERED FOR IN T|
00000fe0  45 4d 50 4c 41 54 45 53  20 59 45 54 20 2a 2f 0a  |EMPLATES YET */.|
00000ff0  09 72 65 67 73 5f 69 6e  2e 72 5b 35 5d 20 3d 20  |.regs_in.r[5] = |
00001000  28 69 6e 74 29 20 77 69  6e 5f 64 61 74 61 2d 3e  |(int) win_data->|
00001010  77 69 6e 5f 6e 61 6d 65  3b 0a 09 72 65 67 73 5f  |win_name;..regs_|
00001020  69 6e 2e 72 5b 36 5d 20  3d 20 63 61 6c 6c 3b 0a  |in.r[6] = call;.|
00001030  0a 09 5f 6b 65 72 6e 65  6c 5f 73 77 69 28 57 69  |.._kernel_swi(Wi|
00001040  6d 70 5f 4c 6f 61 64 54  65 6d 70 6c 61 74 65 2c  |mp_LoadTemplate,|
00001050  20 26 72 65 67 73 5f 69  6e 2c 20 26 72 65 67 73  | &regs_in, &regs|
00001060  5f 6f 75 74 29 3b 0a 09  6e 65 78 74 5f 65 6e 74  |_out);..next_ent|
00001070  72 79 20 3d 20 72 65 67  73 5f 6f 75 74 2e 72 5b  |ry = regs_out.r[|
00001080  36 5d 3b 0a 0a 09 2f 2a  20 43 72 65 61 74 65 20  |6];.../* Create |
00001090  74 68 65 20 77 69 6e 64  6f 77 2c 20 73 74 6f 72  |the window, stor|
000010a0  65 20 77 69 6e 64 6f 77  20 68 61 6e 64 6c 65 20  |e window handle |
000010b0  2a 2f 0a 09 72 65 67 73  5f 69 6e 2e 72 5b 31 5d  |*/..regs_in.r[1]|
000010c0  20 3d 20 28 69 6e 74 29  20 77 69 6e 5f 64 61 74  | = (int) win_dat|
000010d0  61 2d 3e 62 75 66 66 65  72 3b 0a 09 5f 6b 65 72  |a->buffer;.._ker|
000010e0  6e 65 6c 5f 73 77 69 28  57 69 6d 70 5f 43 72 65  |nel_swi(Wimp_Cre|
000010f0  61 74 65 57 69 6e 64 6f  77 2c 20 26 72 65 67 73  |ateWindow, &regs|
00001100  5f 69 6e 2c 20 26 72 65  67 73 5f 6f 75 74 29 3b  |_in, &regs_out);|
00001110  0a 09 77 69 6e 5f 64 61  74 61 2d 3e 77 69 6e 5f  |..win_data->win_|
00001120  68 61 6e 64 6c 65 20 3d  20 72 65 67 73 5f 6f 75  |handle = regs_ou|
00001130  74 2e 72 5b 30 5d 3b 0a  09 72 65 74 75 72 6e 20  |t.r[0];..return |
00001140  6e 65 78 74 5f 65 6e 74  72 79 3b 20 2f 2a 20 69  |next_entry; /* i|
00001150  6e 20 63 61 73 65 20 6f  66 20 77 69 6c 64 63 61  |n case of wildca|
00001160  72 64 65 64 20 73 65 61  72 63 68 65 73 20 2a 2f  |rded searches */|
00001170  0a 7d 0a 0a 69 6e 74 0a  61 75 5f 72 65 70 6f 72  |.}..int.au_repor|
00001180  74 5f 65 72 72 6f 72 28  69 6e 74 20 65 72 72 6e  |t_error(int errn|
00001190  6f 2c 20 63 68 61 72 20  2a 65 72 72 6d 65 73 73  |o, char *errmess|
000011a0  2c 20 69 6e 74 20 66 6c  61 67 73 2c 20 63 68 61  |, int flags, cha|
000011b0  72 20 2a 61 70 70 5f 6e  61 6d 65 29 0a 7b 0a 20  |r *app_name).{. |
000011c0  20 20 75 6e 73 69 67 6e  65 64 20 63 68 61 72 20  |  unsigned char |
000011d0  65 72 72 6f 72 62 6c 6f  63 6b 5b 32 36 30 5d 3b  |errorblock[260];|
000011e0  0a 20 20 20 5f 6b 65 72  6e 65 6c 5f 73 77 69 5f  |.   _kernel_swi_|
000011f0  72 65 67 73 20 69 6e 2c  20 6f 75 74 3b 0a 0a 20  |regs in, out;.. |
00001200  20 20 2f 2a 20 53 65 74  20 75 70 20 74 68 65 20  |  /* Set up the |
00001210  73 74 61 6e 64 61 72 64  20 65 72 72 6f 72 20 62  |standard error b|
00001220  6c 6f 63 6b 20 77 69 74  68 20 74 68 65 20 65 72  |lock with the er|
00001230  72 6f 72 20 6e 75 6d 62  65 72 20 61 6e 64 20 6d  |ror number and m|
00001240  65 73 73 61 67 65 0a 20  20 20 20 20 20 28 7a 65  |essage.      (ze|
00001250  72 6f 20 74 65 72 6d 69  6e 61 74 65 64 29 20 2a  |ro terminated) *|
00001260  2f 0a 20 20 20 61 75 5f  77 6f 72 64 74 6f 62 79  |/.   au_wordtoby|
00001270  74 65 28 65 72 72 6e 6f  2c 20 65 72 72 6f 72 62  |te(errno, errorb|
00001280  6c 6f 63 6b 2c 20 30 29  3b 0a 20 20 20 73 74 72  |lock, 0);.   str|
00001290  63 70 79 28 20 28 63 68  61 72 20 2a 29 20 26 65  |cpy( (char *) &e|
000012a0  72 72 6f 72 62 6c 6f 63  6b 5b 34 5d 2c 20 65 72  |rrorblock[4], er|
000012b0  72 6d 65 73 73 29 3b 0a  0a 20 20 20 2f 2a 20 52  |rmess);..   /* R|
000012c0  30 20 2d 20 70 6f 69 6e  74 65 72 20 74 6f 20 73  |0 - pointer to s|
000012d0  74 61 6e 64 61 72 64 20  65 72 72 6f 72 20 62 6c  |tandard error bl|
000012e0  6f 63 6b 0a 20 20 20 20  20 20 52 31 20 2d 20 65  |ock.      R1 - e|
000012f0  72 72 6f 72 20 77 69 6e  64 6f 77 20 66 6c 61 67  |rror window flag|
00001300  73 0a 20 20 20 20 20 20  52 32 20 2d 20 70 6f 69  |s.      R2 - poi|
00001310  6e 74 65 72 20 74 6f 20  61 70 70 6c 69 63 61 74  |nter to applicat|
00001320  69 6f 6e 20 6e 61 6d 65  20 66 6f 72 20 65 72 72  |ion name for err|
00001330  6f 72 20 62 6f 78 20 74  69 74 6c 65 20 2a 2f 0a  |or box title */.|
00001340  0a 20 20 20 69 6e 2e 72  5b 30 5d 20 3d 20 28 69  |.   in.r[0] = (i|
00001350  6e 74 29 20 65 72 72 6f  72 62 6c 6f 63 6b 3b 0a  |nt) errorblock;.|
00001360  20 20 20 69 6e 2e 72 5b  31 5d 20 3d 20 66 6c 61  |   in.r[1] = fla|
00001370  67 73 3b 0a 20 20 20 69  6e 2e 72 5b 32 5d 20 3d  |gs;.   in.r[2] =|
00001380  20 28 69 6e 74 29 20 61  70 70 5f 6e 61 6d 65 3b  | (int) app_name;|
00001390  0a 0a 20 20 20 5f 6b 65  72 6e 65 6c 5f 73 77 69  |..   _kernel_swi|
000013a0  28 57 69 6d 70 5f 52 65  70 6f 72 74 45 72 72 6f  |(Wimp_ReportErro|
000013b0  72 2c 20 26 69 6e 2c 20  26 6f 75 74 29 3b 0a 0a  |r, &in, &out);..|
000013c0  20 20 20 2f 2a 20 52 65  74 75 72 6e 73 20 31 20  |   /* Returns 1 |
000013d0  69 66 20 4f 4b 20 73 65  6c 65 63 74 65 64 2c 20  |if OK selected, |
000013e0  32 20 69 66 20 43 61 6e  63 65 6c 20 73 65 6c 65  |2 if Cancel sele|
000013f0  63 74 65 64 20 2a 2f 0a  20 20 20 72 65 74 75 72  |cted */.   retur|
00001400  6e 20 6f 75 74 2e 72 5b  31 5d 3b 0a 7d 0a 0a 76  |n out.r[1];.}..v|
00001410  6f 69 64 0a 61 75 5f 6f  70 65 6e 77 69 6e 5f 66  |oid.au_openwin_f|
00001420  72 6f 6d 5f 74 65 6d 70  6c 61 74 65 64 61 74 61  |rom_templatedata|
00001430  28 77 69 6e 64 6f 77 5f  64 61 74 61 20 2a 77 69  |(window_data *wi|
00001440  6e 5f 64 61 74 61 2c 20  6c 6f 6e 67 20 69 6e 74  |n_data, long int|
00001450  20 70 6f 73 69 74 69 6f  6e 29 0a 7b 0a 09 5f 6b  | position).{.._k|
00001460  65 72 6e 65 6c 5f 73 77  69 5f 72 65 67 73 09 72  |ernel_swi_regs.r|
00001470  65 67 73 5f 69 6e 2c 20  72 65 67 73 5f 6f 75 74  |egs_in, regs_out|
00001480  3b 0a 09 75 6e 73 69 67  6e 65 64 20 63 68 61 72  |;..unsigned char|
00001490  09 6f 70 65 6e 77 69 6e  64 6f 77 5f 62 75 66 66  |.openwindow_buff|
000014a0  65 72 5b 33 36 5d 3b 0a  09 69 6e 74 09 69 3b 0a  |er[36];..int.i;.|
000014b0  0a 09 61 75 5f 77 6f 72  64 74 6f 62 79 74 65 28  |..au_wordtobyte(|
000014c0  20 28 75 6e 73 69 67 6e  65 64 20 6c 6f 6e 67 20  | (unsigned long |
000014d0  69 6e 74 29 20 77 69 6e  5f 64 61 74 61 2d 3e 77  |int) win_data->w|
000014e0  69 6e 5f 68 61 6e 64 6c  65 2c 20 6f 70 65 6e 77  |in_handle, openw|
000014f0  69 6e 64 6f 77 5f 62 75  66 66 65 72 2c 20 30 29  |indow_buffer, 0)|
00001500  3b 0a 09 66 6f 72 28 69  20 3d 20 30 3b 20 69 20  |;..for(i = 0; i |
00001510  3c 20 36 3b 20 69 2b 2b  29 20 7b 0a 09 09 61 75  |< 6; i++) {...au|
00001520  5f 77 6f 72 64 74 6f 62  79 74 65 28 61 75 5f 62  |_wordtobyte(au_b|
00001530  79 74 65 74 6f 77 6f 72  64 28 77 69 6e 5f 64 61  |ytetoword(win_da|
00001540  74 61 2d 3e 62 75 66 66  65 72 2c 20 69 2a 34 29  |ta->buffer, i*4)|
00001550  2c 20 6f 70 65 6e 77 69  6e 64 6f 77 5f 62 75 66  |, openwindow_buf|
00001560  66 65 72 2c 20 28 69 2b  31 29 20 2a 20 34 29 3b  |fer, (i+1) * 4);|
00001570  0a 09 7d 0a 09 61 75 5f  77 6f 72 64 74 6f 62 79  |..}..au_wordtoby|
00001580  74 65 28 70 6f 73 69 74  69 6f 6e 2c 20 6f 70 65  |te(position, ope|
00001590  6e 77 69 6e 64 6f 77 5f  62 75 66 66 65 72 2c 20  |nwindow_buffer, |
000015a0  32 38 29 3b 0a 09 72 65  67 73 5f 69 6e 2e 72 5b  |28);..regs_in.r[|
000015b0  31 5d 20 3d 20 28 69 6e  74 29 20 6f 70 65 6e 77  |1] = (int) openw|
000015c0  69 6e 64 6f 77 5f 62 75  66 66 65 72 3b 0a 09 5f  |indow_buffer;.._|
000015d0  6b 65 72 6e 65 6c 5f 73  77 69 28 57 69 6d 70 5f  |kernel_swi(Wimp_|
000015e0  4f 70 65 6e 57 69 6e 64  6f 77 2c 20 26 72 65 67  |OpenWindow, &reg|
000015f0  73 5f 69 6e 2c 20 26 72  65 67 73 5f 6f 75 74 29  |s_in, &regs_out)|
00001600  3b 0a 09 72 65 74 75 72  6e 3b 0a 7d 0a 0a 69 6e  |;..return;.}..in|
00001610  74 0a 61 75 5f 77 69 6d  70 5f 70 6f 6c 6c 28 69  |t.au_wimp_poll(i|
00001620  6e 74 20 70 6f 6c 6c 6d  61 73 6b 2c 20 75 6e 73  |nt pollmask, uns|
00001630  69 67 6e 65 64 20 63 68  61 72 20 2a 70 6f 6c 6c  |igned char *poll|
00001640  62 6c 6f 63 6b 29 0a 7b  0a 09 5f 6b 65 72 6e 65  |block).{.._kerne|
00001650  6c 5f 73 77 69 5f 72 65  67 73 09 72 65 67 73 5f  |l_swi_regs.regs_|
00001660  69 6e 2c 20 72 65 67 73  5f 6f 75 74 3b 0a 0a 09  |in, regs_out;...|
00001670  72 65 67 73 5f 69 6e 2e  72 5b 30 5d 20 3d 20 70  |regs_in.r[0] = p|
00001680  6f 6c 6c 6d 61 73 6b 3b  0a 09 72 65 67 73 5f 69  |ollmask;..regs_i|
00001690  6e 2e 72 5b 31 5d 20 3d  20 28 69 6e 74 29 20 70  |n.r[1] = (int) p|
000016a0  6f 6c 6c 62 6c 6f 63 6b  3b 0a 0a 09 5f 6b 65 72  |ollblock;..._ker|
000016b0  6e 65 6c 5f 73 77 69 28  57 69 6d 70 5f 50 6f 6c  |nel_swi(Wimp_Pol|
000016c0  6c 2c 20 26 72 65 67 73  5f 69 6e 2c 20 26 72 65  |l, &regs_in, &re|
000016d0  67 73 5f 6f 75 74 29 3b  0a 09 72 65 74 75 72 6e  |gs_out);..return|
000016e0  20 72 65 67 73 5f 6f 75  74 2e 72 5b 30 5d 3b 20  | regs_out.r[0]; |
000016f0  2f 2a 20 52 65 74 75 72  6e 20 74 68 65 20 65 76  |/* Return the ev|
00001700  65 6e 74 20 63 6f 64 65  20 2a 2f 0a 7d 0a 0a 76  |ent code */.}..v|
00001710  6f 69 64 0a 61 75 5f 69  63 6f 6e 5f 74 65 78 74  |oid.au_icon_text|
00001720  5f 63 68 61 6e 67 65 28  63 68 61 72 20 2a 74 65  |_change(char *te|
00001730  78 74 2c 20 75 6e 73 69  67 6e 65 64 20 6c 6f 6e  |xt, unsigned lon|
00001740  67 20 69 6e 74 20 77 69  6e 5f 68 2c 20 75 6e 73  |g int win_h, uns|
00001750  69 67 6e 65 64 20 6c 6f  6e 67 20 69 6e 74 20 69  |igned long int i|
00001760  63 6f 6e 5f 68 29 0a 7b  0a 20 20 20 5f 6b 65 72  |con_h).{.   _ker|
00001770  6e 65 6c 5f 73 77 69 5f  72 65 67 73 20 72 65 67  |nel_swi_regs reg|
00001780  73 5f 69 6e 2c 20 72 65  67 73 5f 6f 75 74 3b 0a  |s_in, regs_out;.|
00001790  20 20 20 63 68 61 72 20  2a 74 65 78 74 5f 70 6f  |   char *text_po|
000017a0  69 6e 74 65 72 3b 0a 20  20 20 75 6e 73 69 67 6e  |inter;.   unsign|
000017b0  65 64 20 63 68 61 72 20  74 65 6d 70 5f 62 75 66  |ed char temp_buf|
000017c0  66 65 72 5b 32 35 35 5d  3b 0a 0a 20 20 20 2f 2a  |fer[255];..   /*|
000017d0  20 46 69 6e 64 20 6f 75  74 20 77 68 65 72 65 20  | Find out where |
000017e0  74 68 65 20 69 63 6f 6e  27 73 20 69 6e 64 69 72  |the icon's indir|
000017f0  65 63 74 65 64 20 74 65  78 74 20 69 73 20 73 74  |ected text is st|
00001800  6f 72 65 64 20 69 6e 20  6d 65 6d 6f 72 79 20 61  |ored in memory a|
00001810  6e 64 20 63 6f 70 79 0a  20 20 20 20 20 20 61 20  |nd copy.      a |
00001820  6e 65 77 20 73 74 72 69  6e 67 20 74 6f 20 69 74  |new string to it|
00001830  20 2a 2f 0a 20 20 20 74  65 78 74 5f 70 6f 69 6e  | */.   text_poin|
00001840  74 65 72 20 3d 20 61 75  5f 67 65 74 5f 70 74 72  |ter = au_get_ptr|
00001850  5f 74 6f 5f 69 63 6f 6e  74 65 78 74 28 77 69 6e  |_to_icontext(win|
00001860  5f 68 2c 20 69 63 6f 6e  5f 68 29 3b 0a 20 20 20  |_h, icon_h);.   |
00001870  73 74 72 63 70 79 28 74  65 78 74 5f 70 6f 69 6e  |strcpy(text_poin|
00001880  74 65 72 2c 20 74 65 78  74 29 3b 0a 0a 20 20 20  |ter, text);..   |
00001890  2f 2a 20 4e 6f 77 20 77  65 20 6e 65 65 64 20 74  |/* Now we need t|
000018a0  6f 20 69 6e 66 6f 72 6d  20 74 68 65 20 57 49 4d  |o inform the WIM|
000018b0  50 20 74 68 61 74 20 74  68 65 20 69 63 6f 6e 20  |P that the icon |
000018c0  6e 65 65 64 73 20 72 65  64 72 61 77 69 6e 67 20  |needs redrawing |
000018d0  62 79 20 73 65 74 74 69  6e 67 0a 20 20 20 20 20  |by setting.     |
000018e0  20 74 68 65 20 69 63 6f  6e 20 66 6c 61 67 73 20  | the icon flags |
000018f0  2d 20 77 65 20 64 6f 6e  27 74 20 61 63 74 75 61  |- we don't actua|
00001900  6c 6c 79 20 63 68 61 6e  67 65 20 74 68 65 6d 20  |lly change them |
00001910  77 69 74 68 20 74 68 69  73 20 63 61 6c 6c 2c 20  |with this call, |
00001920  62 75 74 20 74 68 69 73  0a 20 20 20 20 20 20 73  |but this.      s|
00001930  70 75 72 73 20 74 68 65  20 57 49 4d 50 20 69 6e  |purs the WIMP in|
00001940  74 6f 20 61 63 74 69 6f  6e 20 2a 2f 0a 0a 20 20  |to action */..  |
00001950  20 61 75 5f 77 6f 72 64  74 6f 62 79 74 65 28 77  | au_wordtobyte(w|
00001960  69 6e 5f 68 2c 20 74 65  6d 70 5f 62 75 66 66 65  |in_h, temp_buffe|
00001970  72 2c 20 30 29 3b 0a 20  20 20 61 75 5f 77 6f 72  |r, 0);.   au_wor|
00001980  64 74 6f 62 79 74 65 28  69 63 6f 6e 5f 68 2c 20  |dtobyte(icon_h, |
00001990  74 65 6d 70 5f 62 75 66  66 65 72 2c 20 34 29 3b  |temp_buffer, 4);|
000019a0  0a 20 20 20 61 75 5f 77  6f 72 64 74 6f 62 79 74  |.   au_wordtobyt|
000019b0  65 28 30 2c 20 74 65 6d  70 5f 62 75 66 66 65 72  |e(0, temp_buffer|
000019c0  2c 20 38 29 3b 0a 20 20  20 61 75 5f 77 6f 72 64  |, 8);.   au_word|
000019d0  74 6f 62 79 74 65 28 30  2c 20 74 65 6d 70 5f 62  |tobyte(0, temp_b|
000019e0  75 66 66 65 72 2c 20 31  32 29 3b 0a 0a 20 20 20  |uffer, 12);..   |
000019f0  72 65 67 73 5f 69 6e 2e  72 5b 31 5d 20 3d 20 28  |regs_in.r[1] = (|
00001a00  69 6e 74 29 20 74 65 6d  70 5f 62 75 66 66 65 72  |int) temp_buffer|
00001a10  3b 0a 0a 20 20 20 5f 6b  65 72 6e 65 6c 5f 73 77  |;..   _kernel_sw|
00001a20  69 28 57 69 6d 70 5f 53  65 74 49 63 6f 6e 53 74  |i(Wimp_SetIconSt|
00001a30  61 74 65 2c 20 26 72 65  67 73 5f 69 6e 2c 20 26  |ate, &regs_in, &|
00001a40  72 65 67 73 5f 6f 75 74  29 3b 0a 20 20 20 72 65  |regs_out);.   re|
00001a50  74 75 72 6e 3b 0a 7d 0a  0a 76 6f 69 64 0a 61 75  |turn;.}..void.au|
00001a60  5f 69 63 6f 6e 5f 67 65  74 5f 74 65 78 74 28 63  |_icon_get_text(c|
00001a70  68 61 72 20 2a 64 65 73  74 5f 73 74 72 69 6e 67  |har *dest_string|
00001a80  2c 20 75 6e 73 69 67 6e  65 64 20 6c 6f 6e 67 20  |, unsigned long |
00001a90  69 6e 74 20 77 69 6e 5f  68 64 6c 2c 20 75 6e 73  |int win_hdl, uns|
00001aa0  69 67 6e 65 64 20 6c 6f  6e 67 20 69 6e 74 20 69  |igned long int i|
00001ab0  63 6f 6e 5f 68 64 6c 29  0a 7b 0a 09 63 68 61 72  |con_hdl).{..char|
00001ac0  09 2a 74 65 78 74 5f 70  6f 69 6e 74 65 72 3b 0a  |.*text_pointer;.|
00001ad0  0a 09 2f 2a 20 41 73 73  75 6d 65 73 20 64 65 73  |../* Assumes des|
00001ae0  74 5f 73 74 72 69 6e 67  20 68 61 73 20 65 6e 6f  |t_string has eno|
00001af0  75 67 68 20 73 70 61 63  65 20 2a 2f 0a 09 74 65  |ugh space */..te|
00001b00  78 74 5f 70 6f 69 6e 74  65 72 20 3d 20 61 75 5f  |xt_pointer = au_|
00001b10  67 65 74 5f 70 74 72 5f  74 6f 5f 69 63 6f 6e 74  |get_ptr_to_icont|
00001b20  65 78 74 28 77 69 6e 5f  68 64 6c 2c 20 69 63 6f  |ext(win_hdl, ico|
00001b30  6e 5f 68 64 6c 29 3b 0a  09 73 74 72 63 70 79 28  |n_hdl);..strcpy(|
00001b40  64 65 73 74 5f 73 74 72  69 6e 67 2c 20 74 65 78  |dest_string, tex|
00001b50  74 5f 70 6f 69 6e 74 65  72 29 3b 0a 09 72 65 74  |t_pointer);..ret|
00001b60  75 72 6e 3b 0a 7d 0a 0a  63 68 61 72 20 2a 0a 61  |urn;.}..char *.a|
00001b70  75 5f 67 65 74 5f 70 74  72 5f 74 6f 5f 69 63 6f  |u_get_ptr_to_ico|
00001b80  6e 74 65 78 74 28 75 6e  73 69 67 6e 65 64 20 6c  |ntext(unsigned l|
00001b90  6f 6e 67 20 69 6e 74 20  77 69 6e 68 64 6c 2c 20  |ong int winhdl, |
00001ba0  75 6e 73 69 67 6e 65 64  20 6c 6f 6e 67 20 69 6e  |unsigned long in|
00001bb0  74 20 69 63 6f 6e 68 64  6c 29 0a 7b 0a 20 20 20  |t iconhdl).{.   |
00001bc0  2f 2a 20 54 68 69 73 20  70 72 6f 63 65 64 75 72  |/* This procedur|
00001bd0  65 20 69 6e 74 65 72 72  6f 67 61 74 65 73 20 61  |e interrogates a|
00001be0  6e 20 69 63 6f 6e 20 74  6f 20 64 65 74 65 72 6d  |n icon to determ|
00001bf0  69 6e 65 20 74 68 65 20  61 64 64 72 65 73 73 20  |ine the address |
00001c00  77 68 65 72 65 20 69 74  73 0a 20 20 20 20 20 20  |where its.      |
00001c10  69 6e 64 69 72 65 63 74  65 64 20 74 65 78 74 20  |indirected text |
00001c20  64 61 74 61 20 69 73 20  73 74 6f 72 65 64 20 69  |data is stored i|
00001c30  6e 20 6d 65 6d 6f 72 79  2c 20 61 6e 64 20 72 65  |n memory, and re|
00001c40  74 75 72 6e 73 20 69 74  20 2a 2f 0a 0a 20 20 20  |turns it */..   |
00001c50  75 6e 73 69 67 6e 65 64  20 63 68 61 72 20 74 65  |unsigned char te|
00001c60  6d 70 5f 62 75 66 66 65  72 5b 32 35 35 5d 3b 0a  |mp_buffer[255];.|
00001c70  20 20 20 5f 6b 65 72 6e  65 6c 5f 73 77 69 5f 72  |   _kernel_swi_r|
00001c80  65 67 73 20 72 65 67 73  5f 69 6e 2c 20 72 65 67  |egs regs_in, reg|
00001c90  73 5f 6f 75 74 3b 0a 20  20 20 63 68 61 72 20 2a  |s_out;.   char *|
00001ca0  72 65 73 75 6c 74 3b 0a  0a 20 20 20 61 75 5f 77  |result;..   au_w|
00001cb0  6f 72 64 74 6f 62 79 74  65 28 77 69 6e 68 64 6c  |ordtobyte(winhdl|
00001cc0  2c 20 74 65 6d 70 5f 62  75 66 66 65 72 2c 20 30  |, temp_buffer, 0|
00001cd0  29 3b 0a 20 20 20 61 75  5f 77 6f 72 64 74 6f 62  |);.   au_wordtob|
00001ce0  79 74 65 28 69 63 6f 6e  68 64 6c 2c 20 74 65 6d  |yte(iconhdl, tem|
00001cf0  70 5f 62 75 66 66 65 72  2c 20 34 29 3b 0a 0a 20  |p_buffer, 4);.. |
00001d00  20 20 72 65 67 73 5f 69  6e 2e 72 5b 31 5d 20 3d  |  regs_in.r[1] =|
00001d10  20 28 69 6e 74 29 20 74  65 6d 70 5f 62 75 66 66  | (int) temp_buff|
00001d20  65 72 3b 0a 20 20 20 5f  6b 65 72 6e 65 6c 5f 73  |er;.   _kernel_s|
00001d30  77 69 28 57 69 6d 70 5f  47 65 74 49 63 6f 6e 53  |wi(Wimp_GetIconS|
00001d40  74 61 74 65 2c 20 26 72  65 67 73 5f 69 6e 2c 20  |tate, &regs_in, |
00001d50  26 72 65 67 73 5f 6f 75  74 29 3b 0a 0a 20 20 20  |&regs_out);..   |
00001d60  72 65 73 75 6c 74 20 3d  20 28 63 68 61 72 20 2a  |result = (char *|
00001d70  29 20 61 75 5f 62 79 74  65 74 6f 77 6f 72 64 28  |) au_bytetoword(|
00001d80  74 65 6d 70 5f 62 75 66  66 65 72 2c 20 32 38 29  |temp_buffer, 28)|
00001d90  3b 0a 20 20 20 72 65 74  75 72 6e 20 72 65 73 75  |;.   return resu|
00001da0  6c 74 3b 0a 7d 0a 0a 76  6f 69 64 0a 61 75 5f 62  |lt;.}..void.au_b|
00001db0  75 69 6c 64 6d 65 6e 75  28 63 68 61 72 20 2a 74  |uildmenu(char *t|
00001dc0  69 74 6c 65 2c 20 6d 65  6e 75 5f 64 61 74 61 20  |itle, menu_data |
00001dd0  2a 6d 65 6e 75 5f 64 61  74 29 0a 7b 0a 09 69 66  |*menu_dat).{..if|
00001de0  28 73 74 72 6c 65 6e 28  74 69 74 6c 65 29 20 3e  |(strlen(title) >|
00001df0  20 31 31 29 20 72 65 74  75 72 6e 3b 20 2f 2a 20  | 11) return; /* |
00001e00  44 6f 20 74 68 69 73 20  6d 6f 72 65 20 6e 65 61  |Do this more nea|
00001e10  74 6c 79 21 20 2a 2f 0a  09 2f 2a 20 46 69 6c 6c  |tly! */../* Fill|
00001e20  20 69 6e 20 74 68 65 20  6d 65 6e 75 20 68 65 61  | in the menu hea|
00001e30  64 65 72 20 77 69 74 68  20 73 74 61 6e 64 61 72  |der with standar|
00001e40  64 20 69 6e 66 6f 72 6d  61 74 69 6f 6e 20 2a 2f  |d information */|
00001e50  0a 09 73 74 72 63 70 79  28 6d 65 6e 75 5f 64 61  |..strcpy(menu_da|
00001e60  74 2d 3e 74 69 74 6c 65  2c 20 74 69 74 6c 65 29  |t->title, title)|
00001e70  3b 0a 09 6d 65 6e 75 5f  64 61 74 2d 3e 63 6f 6c  |;..menu_dat->col|
00001e80  6f 75 72 73 20 3d 20 4d  45 4e 55 5f 54 49 54 4c  |ours = MENU_TITL|
00001e90  45 46 4f 52 45 20 7c 20  4d 45 4e 55 5f 54 49 54  |EFORE | MENU_TIT|
00001ea0  4c 45 42 41 43 4b 20 7c  20 4d 45 4e 55 5f 57 4f  |LEBACK | MENU_WO|
00001eb0  52 4b 46 4f 52 45 20 7c  20 4d 45 4e 55 5f 57 4f  |RKFORE | MENU_WO|
00001ec0  52 4b 42 41 43 4b 3b 0a  09 6d 65 6e 75 5f 64 61  |RKBACK;..menu_da|
00001ed0  74 2d 3e 77 69 64 74 68  20 3d 20 4d 45 4e 55 5f  |t->width = MENU_|
00001ee0  57 49 44 54 48 3b 0a 09  6d 65 6e 75 5f 64 61 74  |WIDTH;..menu_dat|
00001ef0  2d 3e 68 65 69 67 68 74  20 3d 20 4d 45 4e 55 5f  |->height = MENU_|
00001f00  48 45 49 47 48 54 3b 0a  09 6d 65 6e 75 5f 64 61  |HEIGHT;..menu_da|
00001f10  74 2d 3e 76 65 72 74 5f  67 61 70 20 3d 20 4d 45  |t->vert_gap = ME|
00001f20  4e 55 5f 56 45 52 54 47  41 50 3b 0a 09 6d 65 6e  |NU_VERTGAP;..men|
00001f30  75 5f 64 61 74 2d 3e 6e  65 78 74 5f 6d 65 6e 75  |u_dat->next_menu|
00001f40  65 6c 65 6d 20 3d 20 4e  55 4c 4c 3b 0a 09 6d 65  |elem = NULL;..me|
00001f50  6e 75 5f 64 61 74 2d 3e  73 69 7a 65 20 3d 20 73  |nu_dat->size = s|
00001f60  69 7a 65 6f 66 28 6d 65  6e 75 5f 64 61 74 61 29  |izeof(menu_data)|
00001f70  3b 0a 09 72 65 74 75 72  6e 3b 0a 7d 0a 0a 76 6f  |;..return;.}..vo|
00001f80  69 64 0a 61 75 5f 61 64  64 74 6f 6d 65 6e 75 28  |id.au_addtomenu(|
00001f90  63 68 61 72 20 2a 74 65  78 74 2c 20 6c 6f 6e 67  |char *text, long|
00001fa0  20 69 6e 74 20 6d 65 6e  75 5f 66 6c 61 67 73 2c  | int menu_flags,|
00001fb0  20 6c 6f 6e 67 20 69 6e  74 20 73 75 62 6d 65 6e  | long int submen|
00001fc0  75 2c 20 6c 6f 6e 67 20  69 6e 74 20 69 63 6f 6e  |u, long int icon|
00001fd0  5f 66 6c 61 67 73 2c 20  6d 65 6e 75 5f 64 61 74  |_flags, menu_dat|
00001fe0  61 20 2a 0a 6d 65 6e 75  5f 64 61 74 29 0a 7b 0a  |a *.menu_dat).{.|
00001ff0  09 6d 65 6e 75 5f 65 6c  65 6d 65 6e 74 20 2a 70  |.menu_element *p|
00002000  6f 69 6e 74 65 72 3b 0a  0a 09 69 66 28 73 74 72  |ointer;...if(str|
00002010  6c 65 6e 28 74 65 78 74  29 20 3e 20 31 31 29 20  |len(text) > 11) |
00002020  72 65 74 75 72 6e 3b 0a  09 2f 2a 20 57 6f 72 6b  |return;../* Work|
00002030  20 6f 75 72 20 77 61 79  20 74 6f 20 65 6e 64 20  | our way to end |
00002040  6f 66 20 6d 65 6e 75 20  6c 69 73 74 20 2a 2f 0a  |of menu list */.|
00002050  09 69 66 28 6d 65 6e 75  5f 64 61 74 2d 3e 6e 65  |.if(menu_dat->ne|
00002060  78 74 5f 6d 65 6e 75 65  6c 65 6d 20 3d 3d 20 4e  |xt_menuelem == N|
00002070  55 4c 4c 29 20 7b 0a 09  09 6d 65 6e 75 5f 64 61  |ULL) {...menu_da|
00002080  74 2d 3e 6e 65 78 74 5f  6d 65 6e 75 65 6c 65 6d  |t->next_menuelem|
00002090  20 3d 20 63 61 6c 6c 6f  63 28 31 2c 20 73 69 7a  | = calloc(1, siz|
000020a0  65 6f 66 28 6d 65 6e 75  5f 65 6c 65 6d 65 6e 74  |eof(menu_element|
000020b0  29 29 3b 0a 09 09 6d 65  6e 75 5f 64 61 74 2d 3e  |));...menu_dat->|
000020c0  73 69 7a 65 20 2b 3d 20  73 69 7a 65 6f 66 28 6d  |size += sizeof(m|
000020d0  65 6e 75 5f 65 6c 65 6d  65 6e 74 29 3b 0a 09 09  |enu_element);...|
000020e0  70 6f 69 6e 74 65 72 20  3d 20 6d 65 6e 75 5f 64  |pointer = menu_d|
000020f0  61 74 2d 3e 6e 65 78 74  5f 6d 65 6e 75 65 6c 65  |at->next_menuele|
00002100  6d 3b 0a 09 7d 20 65 6c  73 65 20 7b 0a 09 09 70  |m;..} else {...p|
00002110  6f 69 6e 74 65 72 20 3d  20 6d 65 6e 75 5f 64 61  |ointer = menu_da|
00002120  74 2d 3e 6e 65 78 74 5f  6d 65 6e 75 65 6c 65 6d  |t->next_menuelem|
00002130  3b 0a 09 09 77 68 69 6c  65 20 28 70 6f 69 6e 74  |;...while (point|
00002140  65 72 2d 3e 6e 65 78 74  5f 6d 65 6e 75 65 6c 65  |er->next_menuele|
00002150  6d 20 21 3d 20 30 29 20  7b 0a 09 09 09 70 6f 69  |m != 0) {....poi|
00002160  6e 74 65 72 20 3d 20 70  6f 69 6e 74 65 72 2d 3e  |nter = pointer->|
00002170  6e 65 78 74 5f 6d 65 6e  75 65 6c 65 6d 3b 0a 09  |next_menuelem;..|
00002180  09 7d 0a 09 09 70 6f 69  6e 74 65 72 2d 3e 6e 65  |.}...pointer->ne|
00002190  78 74 5f 6d 65 6e 75 65  6c 65 6d 20 3d 20 63 61  |xt_menuelem = ca|
000021a0  6c 6c 6f 63 28 31 2c 20  73 69 7a 65 6f 66 28 6d  |lloc(1, sizeof(m|
000021b0  65 6e 75 5f 65 6c 65 6d  65 6e 74 29 29 3b 0a 09  |enu_element));..|
000021c0  09 6d 65 6e 75 5f 64 61  74 2d 3e 73 69 7a 65 20  |.menu_dat->size |
000021d0  2b 3d 20 73 69 7a 65 6f  66 28 6d 65 6e 75 5f 65  |+= sizeof(menu_e|
000021e0  6c 65 6d 65 6e 74 29 3b  0a 09 09 70 6f 69 6e 74  |lement);...point|
000021f0  65 72 20 3d 20 70 6f 69  6e 74 65 72 2d 3e 6e 65  |er = pointer->ne|
00002200  78 74 5f 6d 65 6e 75 65  6c 65 6d 3b 0a 09 7d 0a  |xt_menuelem;..}.|
00002210  09 2f 2a 20 73 65 74 20  75 70 20 64 61 74 61 20  |./* set up data |
00002220  2a 2f 0a 09 73 74 72 63  70 79 28 70 6f 69 6e 74  |*/..strcpy(point|
00002230  65 72 2d 3e 6d 65 6e 75  5f 74 65 78 74 2c 20 74  |er->menu_text, t|
00002240  65 78 74 29 3b 0a 09 70  6f 69 6e 74 65 72 2d 3e  |ext);..pointer->|
00002250  66 6c 61 67 73 20 3d 20  6d 65 6e 75 5f 66 6c 61  |flags = menu_fla|
00002260  67 73 3b 0a 09 70 6f 69  6e 74 65 72 2d 3e 73 75  |gs;..pointer->su|
00002270  62 6d 65 6e 75 20 3d 20  73 75 62 6d 65 6e 75 3b  |bmenu = submenu;|
00002280  0a 0a 09 2f 2a 20 41 70  70 6c 79 20 73 74 61 6e  |.../* Apply stan|
00002290  64 61 72 64 20 69 63 6f  6e 20 66 6c 61 67 73 20  |dard icon flags |
000022a0  2a 2f 0a 09 69 63 6f 6e  5f 66 6c 61 67 73 20 3d  |*/..icon_flags =|
000022b0  20 69 63 6f 6e 5f 66 6c  61 67 73 20 7c 20 4d 45  | icon_flags | ME|
000022c0  4e 55 49 54 45 4d 5f 46  4f 52 45 20 7c 20 4d 45  |NUITEM_FORE | ME|
000022d0  4e 55 49 54 45 4d 5f 42  41 43 4b 20 7c 20 49 43  |NUITEM_BACK | IC|
000022e0  4f 4e 5f 49 53 54 45 58  54 20 7c 20 49 43 4f 4e  |ON_ISTEXT | ICON|
000022f0  5f 49 53 46 49 4c 4c 45  44 3b 0a 09 70 6f 69 6e  |_ISFILLED;..poin|
00002300  74 65 72 2d 3e 6d 65 6e  75 5f 69 63 6f 6e 66 6c  |ter->menu_iconfl|
00002310  61 67 73 20 3d 20 69 63  6f 6e 5f 66 6c 61 67 73  |ags = icon_flags|
00002320  3b 0a 09 72 65 74 75 72  6e 3b 0a 7d 0a 0a 76 6f  |;..return;.}..vo|
00002330  69 64 0a 61 75 5f 63 72  65 61 74 65 6d 65 6e 75  |id.au_createmenu|
00002340  28 6d 65 6e 75 5f 64 61  74 61 20 2a 6d 65 6e 75  |(menu_data *menu|
00002350  5f 64 61 74 29 0a 7b 0a  09 6d 65 6e 75 5f 65 6c  |_dat).{..menu_el|
00002360  65 6d 65 6e 74 09 2a 70  6f 69 6e 74 65 72 3b 0a  |ement.*pointer;.|
00002370  09 69 6e 74 09 69 3b 0a  0a 09 2f 2a 20 41 73 73  |.int.i;.../* Ass|
00002380  69 67 6e 20 6d 65 6d 6f  72 79 20 2a 2f 0a 09 6d  |ign memory */..m|
00002390  65 6e 75 5f 64 61 74 2d  3e 64 61 74 61 62 6c 6f  |enu_dat->datablo|
000023a0  63 6b 20 3d 20 63 61 6c  6c 6f 63 28 31 2c 20 6d  |ck = calloc(1, m|
000023b0  65 6e 75 5f 64 61 74 2d  3e 73 69 7a 65 29 3b 0a  |enu_dat->size);.|
000023c0  09 2f 2a 20 42 65 67 69  6e 20 63 6f 70 79 69 6e  |./* Begin copyin|
000023d0  67 20 64 61 74 61 20 2a  2f 0a 09 73 74 72 63 70  |g data */..strcp|
000023e0  79 28 28 63 68 61 72 20  2a 29 6d 65 6e 75 5f 64  |y((char *)menu_d|
000023f0  61 74 2d 3e 64 61 74 61  62 6c 6f 63 6b 2c 20 6d  |at->datablock, m|
00002400  65 6e 75 5f 64 61 74 2d  3e 74 69 74 6c 65 29 3b  |enu_dat->title);|
00002410  0a 09 61 75 5f 77 6f 72  64 74 6f 62 79 74 65 28  |..au_wordtobyte(|
00002420  6d 65 6e 75 5f 64 61 74  2d 3e 63 6f 6c 6f 75 72  |menu_dat->colour|
00002430  73 2c 20 6d 65 6e 75 5f  64 61 74 2d 3e 64 61 74  |s, menu_dat->dat|
00002440  61 62 6c 6f 63 6b 2c 20  31 32 29 3b 0a 09 61 75  |ablock, 12);..au|
00002450  5f 77 6f 72 64 74 6f 62  79 74 65 28 6d 65 6e 75  |_wordtobyte(menu|
00002460  5f 64 61 74 2d 3e 77 69  64 74 68 2c 20 6d 65 6e  |_dat->width, men|
00002470  75 5f 64 61 74 2d 3e 64  61 74 61 62 6c 6f 63 6b  |u_dat->datablock|
00002480  2c 20 31 36 29 3b 0a 09  61 75 5f 77 6f 72 64 74  |, 16);..au_wordt|
00002490  6f 62 79 74 65 28 6d 65  6e 75 5f 64 61 74 2d 3e  |obyte(menu_dat->|
000024a0  68 65 69 67 68 74 2c 20  6d 65 6e 75 5f 64 61 74  |height, menu_dat|
000024b0  2d 3e 64 61 74 61 62 6c  6f 63 6b 2c 20 32 30 29  |->datablock, 20)|
000024c0  3b 0a 09 61 75 5f 77 6f  72 64 74 6f 62 79 74 65  |;..au_wordtobyte|
000024d0  28 6d 65 6e 75 5f 64 61  74 2d 3e 76 65 72 74 5f  |(menu_dat->vert_|
000024e0  67 61 70 2c 20 6d 65 6e  75 5f 64 61 74 2d 3e 64  |gap, menu_dat->d|
000024f0  61 74 61 62 6c 6f 63 6b  2c 20 32 34 29 3b 0a 09  |atablock, 24);..|
00002500  2f 2a 20 65 6e 64 20 6f  66 20 68 65 61 64 65 72  |/* end of header|
00002510  20 69 6e 66 6f 20 2a 2f  0a 09 69 20 3d 20 32 38  | info */..i = 28|
00002520  3b 0a 0a 09 70 6f 69 6e  74 65 72 20 3d 20 6d 65  |;...pointer = me|
00002530  6e 75 5f 64 61 74 2d 3e  6e 65 78 74 5f 6d 65 6e  |nu_dat->next_men|
00002540  75 65 6c 65 6d 3b 0a 0a  09 77 68 69 6c 65 28 70  |uelem;...while(p|
00002550  6f 69 6e 74 65 72 20 21  3d 20 4e 55 4c 4c 29 20  |ointer != NULL) |
00002560  7b 0a 0a 09 09 61 75 5f  77 6f 72 64 74 6f 62 79  |{....au_wordtoby|
00002570  74 65 28 70 6f 69 6e 74  65 72 2d 3e 66 6c 61 67  |te(pointer->flag|
00002580  73 2c 20 6d 65 6e 75 5f  64 61 74 2d 3e 64 61 74  |s, menu_dat->dat|
00002590  61 62 6c 6f 63 6b 2c 20  69 29 3b 0a 09 09 69 20  |ablock, i);...i |
000025a0  2b 3d 20 34 3b 0a 09 09  61 75 5f 77 6f 72 64 74  |+= 4;...au_wordt|
000025b0  6f 62 79 74 65 28 70 6f  69 6e 74 65 72 2d 3e 73  |obyte(pointer->s|
000025c0  75 62 6d 65 6e 75 2c 20  6d 65 6e 75 5f 64 61 74  |ubmenu, menu_dat|
000025d0  2d 3e 64 61 74 61 62 6c  6f 63 6b 2c 20 69 29 3b  |->datablock, i);|
000025e0  0a 09 09 69 20 2b 3d 20  34 3b 0a 09 09 61 75 5f  |...i += 4;...au_|
000025f0  77 6f 72 64 74 6f 62 79  74 65 28 70 6f 69 6e 74  |wordtobyte(point|
00002600  65 72 2d 3e 6d 65 6e 75  5f 69 63 6f 6e 66 6c 61  |er->menu_iconfla|
00002610  67 73 2c 20 6d 65 6e 75  5f 64 61 74 2d 3e 64 61  |gs, menu_dat->da|
00002620  74 61 62 6c 6f 63 6b 2c  20 69 29 3b 0a 09 09 69  |tablock, i);...i|
00002630  20 2b 3d 20 34 3b 0a 09  09 73 74 72 63 70 79 28  | += 4;...strcpy(|
00002640  28 63 68 61 72 20 2a 29  20 26 6d 65 6e 75 5f 64  |(char *) &menu_d|
00002650  61 74 2d 3e 64 61 74 61  62 6c 6f 63 6b 5b 69 5d  |at->datablock[i]|
00002660  2c 20 70 6f 69 6e 74 65  72 2d 3e 6d 65 6e 75 5f  |, pointer->menu_|
00002670  74 65 78 74 29 3b 0a 09  09 69 20 2b 3d 20 31 32  |text);...i += 12|
00002680  3b 0a 09 09 70 6f 69 6e  74 65 72 20 3d 20 70 6f  |;...pointer = po|
00002690  69 6e 74 65 72 2d 3e 6e  65 78 74 5f 6d 65 6e 75  |inter->next_menu|
000026a0  65 6c 65 6d 3b 0a 09 7d  0a 09 72 65 74 75 72 6e  |elem;..}..return|
000026b0  3b 0a 7d 0a 0a 76 6f 69  64 0a 61 75 5f 6f 70 65  |;.}..void.au_ope|
000026c0  6e 6d 65 6e 75 28 6d 65  6e 75 5f 64 61 74 61 20  |nmenu(menu_data |
000026d0  2a 6d 65 6e 75 5f 64 61  74 2c 20 69 6e 74 20 6d  |*menu_dat, int m|
000026e0  6f 75 73 65 5f 78 2c 20  69 6e 74 20 6d 6f 75 73  |ouse_x, int mous|
000026f0  65 5f 79 29 0a 7b 0a 09  5f 6b 65 72 6e 65 6c 5f  |e_y).{.._kernel_|
00002700  73 77 69 5f 72 65 67 73  09 72 65 67 73 5f 69 6e  |swi_regs.regs_in|
00002710  2c 20 72 65 67 73 5f 6f  75 74 3b 0a 0a 09 72 65  |, regs_out;...re|
00002720  67 73 5f 69 6e 2e 72 5b  31 5d 20 3d 20 28 69 6e  |gs_in.r[1] = (in|
00002730  74 29 20 6d 65 6e 75 5f  64 61 74 2d 3e 64 61 74  |t) menu_dat->dat|
00002740  61 62 6c 6f 63 6b 3b 0a  09 72 65 67 73 5f 69 6e  |ablock;..regs_in|
00002750  2e 72 5b 32 5d 20 3d 20  6d 6f 75 73 65 5f 78 3b  |.r[2] = mouse_x;|
00002760  0a 09 72 65 67 73 5f 69  6e 2e 72 5b 33 5d 20 3d  |..regs_in.r[3] =|
00002770  20 6d 6f 75 73 65 5f 79  3b 0a 09 5f 6b 65 72 6e  | mouse_y;.._kern|
00002780  65 6c 5f 73 77 69 28 57  69 6d 70 5f 43 72 65 61  |el_swi(Wimp_Crea|
00002790  74 65 4d 65 6e 75 2c 20  26 72 65 67 73 5f 69 6e  |teMenu, &regs_in|
000027a0  2c 20 26 72 65 67 73 5f  6f 75 74 29 3b 0a 09 72  |, &regs_out);..r|
000027b0  65 74 75 72 6e 3b 0a 7d  0a 0a 76 6f 69 64 0a 61  |eturn;.}..void.a|
000027c0  75 5f 6c 6f 73 65 63 61  72 65 74 28 76 6f 69 64  |u_losecaret(void|
000027d0  29 0a 7b 0a 09 5f 6b 65  72 6e 65 6c 5f 73 77 69  |).{.._kernel_swi|
000027e0  5f 72 65 67 73 09 72 65  67 73 5f 69 6e 2c 20 72  |_regs.regs_in, r|
000027f0  65 67 73 5f 6f 75 74 3b  0a 0a 09 72 65 67 73 5f  |egs_out;...regs_|
00002800  69 6e 2e 72 5b 30 5d 20  3d 20 2d 31 3b 0a 09 72  |in.r[0] = -1;..r|
00002810  65 67 73 5f 69 6e 2e 72  5b 31 5d 20 3d 20 2d 31  |egs_in.r[1] = -1|
00002820  3b 0a 09 72 65 67 73 5f  69 6e 2e 72 5b 30 5d 20  |;..regs_in.r[0] |
00002830  3d 20 2d 31 3b 0a 09 72  65 67 73 5f 69 6e 2e 72  |= -1;..regs_in.r|
00002840  5b 30 5d 20 3d 20 2d 31  3b 0a 09 72 65 67 73 5f  |[0] = -1;..regs_|
00002850  69 6e 2e 72 5b 34 5d 20  3d 20 2d 31 3b 0a 09 72  |in.r[4] = -1;..r|
00002860  65 67 73 5f 69 6e 2e 72  5b 35 5d 20 3d 20 2d 31  |egs_in.r[5] = -1|
00002870  3b 0a 0a 09 5f 6b 65 72  6e 65 6c 5f 73 77 69 28  |;..._kernel_swi(|
00002880  57 69 6d 70 5f 53 65 74  43 61 72 65 74 50 6f 73  |Wimp_SetCaretPos|
00002890  69 74 69 6f 6e 2c 20 26  72 65 67 73 5f 69 6e 2c  |ition, &regs_in,|
000028a0  20 26 72 65 67 73 5f 6f  75 74 29 3b 0a 7d 0a 0a  | &regs_out);.}..|
000028b0  76 6f 69 64 0a 61 75 5f  64 72 61 67 62 6f 78 28  |void.au_dragbox(|
000028c0  75 6e 73 69 67 6e 65 64  20 6c 6f 6e 67 20 69 6e  |unsigned long in|
000028d0  74 20 77 69 6e 68 64 6c  2c 20 75 6e 73 69 67 6e  |t winhdl, unsign|
000028e0  65 64 20 6c 6f 6e 67 20  69 6e 74 20 69 63 6f 6e  |ed long int icon|
000028f0  68 64 6c 29 0a 7b 0a 09  5f 6b 65 72 6e 65 6c 5f  |hdl).{.._kernel_|
00002900  73 77 69 5f 72 65 67 73  09 72 65 67 73 5f 69 6e  |swi_regs.regs_in|
00002910  2c 20 72 65 67 73 5f 6f  75 74 3b 0a 09 75 6e 73  |, regs_out;..uns|
00002920  69 67 6e 65 64 20 63 68  61 72 09 74 65 6d 70 5f  |igned char.temp_|
00002930  62 75 66 66 65 72 5b 32  35 36 5d 3b 0a 09 75 6e  |buffer[256];..un|
00002940  73 69 67 6e 65 64 20 63  68 61 72 09 74 65 6d 70  |signed char.temp|
00002950  5f 62 75 66 66 65 72 32  5b 32 35 36 5d 3b 0a 09  |_buffer2[256];..|
00002960  6c 6f 6e 67 20 69 6e 74  09 6d 69 6e 5f 78 2c 20  |long int.min_x, |
00002970  6d 69 6e 5f 79 2c 20 6d  61 78 5f 78 2c 20 6d 61  |min_y, max_x, ma|
00002980  78 5f 79 20 3d 20 30 3b  0a 0a 09 2f 2a 20 47 65  |x_y = 0;.../* Ge|
00002990  74 20 73 6f 6d 65 20 69  63 6f 6e 20 69 6e 66 6f  |t some icon info|
000029a0  72 6d 61 74 69 6f 6e 20  2a 2f 0a 09 61 75 5f 67  |rmation */..au_g|
000029b0  65 74 69 63 6f 6e 69 6e  66 6f 28 77 69 6e 68 64  |eticoninfo(winhd|
000029c0  6c 2c 20 69 63 6f 6e 68  64 6c 2c 20 74 65 6d 70  |l, iconhdl, temp|
000029d0  5f 62 75 66 66 65 72 32  29 3b 0a 0a 09 61 75 5f  |_buffer2);...au_|
000029e0  77 6f 72 64 74 6f 62 79  74 65 28 77 69 6e 68 64  |wordtobyte(winhd|
000029f0  6c 2c 20 74 65 6d 70 5f  62 75 66 66 65 72 2c 20  |l, temp_buffer, |
00002a00  30 29 3b 0a 09 61 75 5f  77 6f 72 64 74 6f 62 79  |0);..au_wordtoby|
00002a10  74 65 28 53 41 56 45 44  52 41 47 5f 54 59 50 45  |te(SAVEDRAG_TYPE|
00002a20  2c 20 74 65 6d 70 5f 62  75 66 66 65 72 2c 20 34  |, temp_buffer, 4|
00002a30  29 3b 0a 0a 09 2f 2a 20  43 6f 70 79 20 69 6e 20  |);.../* Copy in |
00002a40  6d 61 78 20 61 6e 64 20  6d 69 6e 20 63 6f 6f 72  |max and min coor|
00002a50  64 69 6e 61 74 65 73 20  66 6f 72 20 62 6f 75 6e  |dinates for boun|
00002a60  64 69 6e 67 20 62 6f 78  20 2a 2f 0a 09 6d 69 6e  |ding box */..min|
00002a70  5f 78 20 3d 20 61 75 5f  62 79 74 65 74 6f 77 6f  |_x = au_bytetowo|
00002a80  72 64 28 74 65 6d 70 5f  62 75 66 66 65 72 32 2c  |rd(temp_buffer2,|
00002a90  20 38 29 3b 0a 09 6d 69  6e 5f 79 20 3d 20 61 75  | 8);..min_y = au|
00002aa0  5f 62 79 74 65 74 6f 77  6f 72 64 28 74 65 6d 70  |_bytetoword(temp|
00002ab0  5f 62 75 66 66 65 72 32  2c 20 31 32 29 3b 0a 09  |_buffer2, 12);..|
00002ac0  6d 61 78 5f 78 20 3d 20  61 75 5f 62 79 74 65 74  |max_x = au_bytet|
00002ad0  6f 77 6f 72 64 28 74 65  6d 70 5f 62 75 66 66 65  |oword(temp_buffe|
00002ae0  72 32 2c 20 31 36 29 3b  0a 09 6d 61 78 5f 79 20  |r2, 16);..max_y |
00002af0  3d 20 61 75 5f 62 79 74  65 74 6f 77 6f 72 64 28  |= au_bytetoword(|
00002b00  74 65 6d 70 5f 62 75 66  66 65 72 32 2c 20 32 30  |temp_buffer2, 20|
00002b10  29 3b 0a 0a 09 61 75 5f  77 6f 72 64 74 6f 62 79  |);...au_wordtoby|
00002b20  74 65 28 77 69 6e 68 64  6c 2c 20 74 65 6d 70 5f  |te(winhdl, temp_|
00002b30  62 75 66 66 65 72 32 2c  20 30 29 3b 0a 09 72 65  |buffer2, 0);..re|
00002b40  67 73 5f 69 6e 2e 72 5b  31 5d 20 3d 20 28 69 6e  |gs_in.r[1] = (in|
00002b50  74 29 20 74 65 6d 70 5f  62 75 66 66 65 72 32 3b  |t) temp_buffer2;|
00002b60  0a 09 5f 6b 65 72 6e 65  6c 5f 73 77 69 28 57 69  |.._kernel_swi(Wi|
00002b70  6d 70 5f 47 65 74 57 69  6e 64 6f 77 53 74 61 74  |mp_GetWindowStat|
00002b80  65 2c 20 26 72 65 67 73  5f 69 6e 2c 20 26 72 65  |e, &regs_in, &re|
00002b90  67 73 5f 6f 75 74 29 3b  0a 0a 09 6d 69 6e 5f 78  |gs_out);...min_x|
00002ba0  20 2b 3d 20 61 75 5f 62  79 74 65 74 6f 77 6f 72  | += au_bytetowor|
00002bb0  64 28 74 65 6d 70 5f 62  75 66 66 65 72 32 2c 20  |d(temp_buffer2, |
00002bc0  34 29 3b 0a 09 6d 61 78  5f 78 20 2b 3d 20 61 75  |4);..max_x += au|
00002bd0  5f 62 79 74 65 74 6f 77  6f 72 64 28 74 65 6d 70  |_bytetoword(temp|
00002be0  5f 62 75 66 66 65 72 32  2c 20 34 29 3b 0a 09 6d  |_buffer2, 4);..m|
00002bf0  69 6e 5f 78 20 2d 3d 20  61 75 5f 62 79 74 65 74  |in_x -= au_bytet|
00002c00  6f 77 6f 72 64 28 74 65  6d 70 5f 62 75 66 66 65  |oword(temp_buffe|
00002c10  72 32 2c 20 32 30 29 3b  0a 09 6d 61 78 5f 78 20  |r2, 20);..max_x |
00002c20  2d 3d 20 61 75 5f 62 79  74 65 74 6f 77 6f 72 64  |-= au_bytetoword|
00002c30  28 74 65 6d 70 5f 62 75  66 66 65 72 32 2c 20 32  |(temp_buffer2, 2|
00002c40  30 29 3b 0a 09 6d 69 6e  5f 79 20 2b 3d 20 61 75  |0);..min_y += au|
00002c50  5f 62 79 74 65 74 6f 77  6f 72 64 28 74 65 6d 70  |_bytetoword(temp|
00002c60  5f 62 75 66 66 65 72 32  2c 20 31 36 29 3b 0a 09  |_buffer2, 16);..|
00002c70  6d 61 78 5f 79 20 2b 3d  20 61 75 5f 62 79 74 65  |max_y += au_byte|
00002c80  74 6f 77 6f 72 64 28 74  65 6d 70 5f 62 75 66 66  |toword(temp_buff|
00002c90  65 72 32 2c 20 31 36 29  3b 0a 09 6d 69 6e 5f 79  |er2, 16);..min_y|
00002ca0  20 2d 3d 20 61 75 5f 62  79 74 65 74 6f 77 6f 72  | -= au_bytetowor|
00002cb0  64 28 74 65 6d 70 5f 62  75 66 66 65 72 32 2c 20  |d(temp_buffer2, |
00002cc0  32 34 29 3b 0a 09 6d 61  78 5f 79 20 2d 3d 20 61  |24);..max_y -= a|
00002cd0  75 5f 62 79 74 65 74 6f  77 6f 72 64 28 74 65 6d  |u_bytetoword(tem|
00002ce0  70 5f 62 75 66 66 65 72  32 2c 20 32 34 29 3b 0a  |p_buffer2, 24);.|
00002cf0  0a 0a 09 61 75 5f 77 6f  72 64 74 6f 62 79 74 65  |...au_wordtobyte|
00002d00  28 6d 69 6e 5f 78 2c 20  74 65 6d 70 5f 62 75 66  |(min_x, temp_buf|
00002d10  66 65 72 2c 20 38 29 3b  0a 09 61 75 5f 77 6f 72  |fer, 8);..au_wor|
00002d20  64 74 6f 62 79 74 65 28  6d 69 6e 5f 79 2c 20 74  |dtobyte(min_y, t|
00002d30  65 6d 70 5f 62 75 66 66  65 72 2c 20 31 32 29 3b  |emp_buffer, 12);|
00002d40  0a 09 61 75 5f 77 6f 72  64 74 6f 62 79 74 65 28  |..au_wordtobyte(|
00002d50  6d 61 78 5f 78 2c 20 74  65 6d 70 5f 62 75 66 66  |max_x, temp_buff|
00002d60  65 72 2c 20 31 36 29 3b  0a 09 61 75 5f 77 6f 72  |er, 16);..au_wor|
00002d70  64 74 6f 62 79 74 65 28  6d 61 78 5f 79 2c 20 74  |dtobyte(max_y, t|
00002d80  65 6d 70 5f 62 75 66 66  65 72 2c 20 32 30 29 3b  |emp_buffer, 20);|
00002d90  0a 09 61 75 5f 77 6f 72  64 74 6f 62 79 74 65 28  |..au_wordtobyte(|
00002da0  30 2c 20 74 65 6d 70 5f  62 75 66 66 65 72 2c 20  |0, temp_buffer, |
00002db0  32 34 29 3b 0a 09 61 75  5f 77 6f 72 64 74 6f 62  |24);..au_wordtob|
00002dc0  79 74 65 28 30 2c 20 74  65 6d 70 5f 62 75 66 66  |yte(0, temp_buff|
00002dd0  65 72 2c 20 32 38 29 3b  0a 09 61 75 5f 77 6f 72  |er, 28);..au_wor|
00002de0  64 74 6f 62 79 74 65 28  30 2c 20 74 65 6d 70 5f  |dtobyte(0, temp_|
00002df0  62 75 66 66 65 72 2c 20  33 32 29 3b 0a 09 61 75  |buffer, 32);..au|
00002e00  5f 77 6f 72 64 74 6f 62  79 74 65 28 30 2c 20 74  |_wordtobyte(0, t|
00002e10  65 6d 70 5f 62 75 66 66  65 72 2c 20 33 36 29 3b  |emp_buffer, 36);|
00002e20  0a 0a 09 72 65 67 73 5f  69 6e 2e 72 5b 31 5d 20  |...regs_in.r[1] |
00002e30  3d 20 28 69 6e 74 29 20  74 65 6d 70 5f 62 75 66  |= (int) temp_buf|
00002e40  66 65 72 3b 0a 09 5f 6b  65 72 6e 65 6c 5f 73 77  |fer;.._kernel_sw|
00002e50  69 28 57 69 6d 70 5f 44  72 61 67 42 6f 78 2c 20  |i(Wimp_DragBox, |
00002e60  26 72 65 67 73 5f 69 6e  2c 20 26 72 65 67 73 5f  |&regs_in, &regs_|
00002e70  6f 75 74 29 3b 0a 09 2f  2a 20 54 68 65 20 65 6e  |out);../* The en|
00002e80  64 2d 6f 66 2d 64 72 61  67 20 73 68 6f 75 6c 64  |d-of-drag should|
00002e90  20 62 65 20 63 61 75 67  68 74 20 77 69 74 68 20  | be caught with |
00002ea0  74 68 65 20 61 70 70 72  6f 70 72 69 61 74 65 20  |the appropriate |
00002eb0  70 6f 6c 6c 20 6d 65 73  73 61 67 65 20 2a 2f 0a  |poll message */.|
00002ec0  09 72 65 74 75 72 6e 3b  0a 7d 0a 0a 76 6f 69 64  |.return;.}..void|
00002ed0  0a 61 75 5f 67 65 74 69  63 6f 6e 69 6e 66 6f 28  |.au_geticoninfo(|
00002ee0  75 6e 73 69 67 6e 65 64  20 6c 6f 6e 67 20 69 6e  |unsigned long in|
00002ef0  74 20 77 69 6e 68 64 6c  2c 20 75 6e 73 69 67 6e  |t winhdl, unsign|
00002f00  65 64 20 6c 6f 6e 67 20  69 6e 74 20 69 63 6f 6e  |ed long int icon|
00002f10  68 64 6c 2c 20 75 6e 73  69 67 6e 65 64 20 63 68  |hdl, unsigned ch|
00002f20  61 72 20 2a 62 75 66 66  65 72 29 0a 7b 0a 09 5f  |ar *buffer).{.._|
00002f30  6b 65 72 6e 65 6c 5f 73  77 69 5f 72 65 67 73 09  |kernel_swi_regs.|
00002f40  72 65 67 73 5f 69 6e 2c  20 72 65 67 73 5f 6f 75  |regs_in, regs_ou|
00002f50  74 3b 0a 0a 09 61 75 5f  77 6f 72 64 74 6f 62 79  |t;...au_wordtoby|
00002f60  74 65 28 77 69 6e 68 64  6c 2c 20 62 75 66 66 65  |te(winhdl, buffe|
00002f70  72 2c 20 30 29 3b 0a 09  61 75 5f 77 6f 72 64 74  |r, 0);..au_wordt|
00002f80  6f 62 79 74 65 28 69 63  6f 6e 68 64 6c 2c 20 62  |obyte(iconhdl, b|
00002f90  75 66 66 65 72 2c 20 34  29 3b 0a 09 72 65 67 73  |uffer, 4);..regs|
00002fa0  5f 69 6e 2e 72 5b 31 5d  20 3d 20 28 69 6e 74 29  |_in.r[1] = (int)|
00002fb0  20 62 75 66 66 65 72 3b  0a 09 5f 6b 65 72 6e 65  | buffer;.._kerne|
00002fc0  6c 5f 73 77 69 28 57 69  6d 70 5f 47 65 74 49 63  |l_swi(Wimp_GetIc|
00002fd0  6f 6e 53 74 61 74 65 2c  20 26 72 65 67 73 5f 69  |onState, &regs_i|
00002fe0  6e 2c 20 26 72 65 67 73  5f 6f 75 74 29 3b 0a 09  |n, &regs_out);..|
00002ff0  72 65 74 75 72 6e 3b 0a  7d 0a                    |return;.}.|
00002ffa