Home » Archimedes archive » Acorn User » AU 1996-06.adf » Regulars » StarInfo/WimpC/!NewWimpC/c/!RunImage

StarInfo/WimpC/!NewWimpC/c/!RunImage

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 » Archimedes archive » Acorn User » AU 1996-06.adf » Regulars
Filename: StarInfo/WimpC/!NewWimpC/c/!RunImage
Read OK:
File size: 1700 bytes
Load address: 0000
Exec address: 0000
File contents
/* An example program which uses the new AULib library -
   this will compile with Acorn's C as well as Beebug's EasyC */
/* by Steve Mumford for Acorn User - June 1996 */

#include <stdio.h>
#include <string.h>
#include "AULib.h"

/* We also define a poll mask here to tell the WIMP about any events we're not
   intererested in */

#define POLL_MASK 1 /* Don't return null events */
#define MAX_WINDOWS 3

/* If we set QUIT_FLAG up as a global variable, it means that we can change it
 * anywhere within the program and shut things down next time we end the
 * polling loop */

int QUIT_FLAG = 0;
int DISPLAY_ICON = 1;
char appname[] = "New WIMPC Example";
window_data win_array[MAX_WINDOWS];
menu_data   globmen, globmen2;

/* Function prototyping */

int      main(void);
void     wimpmsg(int, unsigned char[]);
void     mouseclick(unsigned char[]);
void     menuselection(unsigned char[]);
int      load_templates(void);
void     openwindow(unsigned char[]);
void     closewindow(unsigned char[]);

/* Program functions */

int
main(void) {
    int task_handle;
    unsigned char pollblock[257]; /* A byte array large enough for our polling block */
    int ibar_icon_handle; /* A variable to store our iconbar icon handle */
    int pollresult;
    int i;
    long int msglist[1] = {0}; /* Set up the acceptable message list for initialisation */

    task_handle = au_initialise(310, appname, msglist);
    /* Now, we'll put an icon on the icon bar */
    ibar_icon_handle = au_create_iconbar_icon(IBAR_PRIOR_APP,
        IBAR_ONRIGHT,
        ICON_ISSPRITE | ICON_HCENTRE | ICON_VCENTRE | ICON_CLICKNOTIFIESONCE,
        "!newwimpc");

/* Now open a template file ready for loading */

    load_templates();
    au_openwin_from_templatedata(&win_array[0], -1); /* Open first window at front (-1) */

    while (QUIT_FLAG == 0) {
    pollresult = au_wimp_poll(POLL_MASK, pollblock);
        switch (pollresult) {
            case  2: openwindow(pollblock);
                     break;
            case  3: closewindow(pollblock);
                     break;
            case  6: mouseclick(pollblock);
                     break;
                     /* If our icon is clicked on, we jump to mouseclick() */
            case  9: menuselection(pollblock);
                     break;
            case 17:
            case 18:
            case 19: wimpmsg(pollresult, pollblock);
                break;
            /* The above section listens for event codes 17, 18 and 19 - the
               ones which indicate we're being sent a message */
        }
    }
    /* If QUIT_FLAG changes to anything but 0, we stop going round the polling
     * loop and shut down */

    au_closedown(task_handle);
    /* Need to release malloc memory from window structures */
    for(i = 0; i < MAX_WINDOWS; i++) {
        free(win_array[i].win_name);
        free(win_array[i].buffer);
        free(win_array[i].workspace);
    }
}

void
wimpmsg(int result, unsigned char pollblock[])
{
    unsigned long int   message_action;

    /* The next line takes bytes 16 to 19 of the polling block and forms them
       into a word holding the message action number */
    message_action = au_bytetoword(pollblock, 16);
    
    switch (message_action) {
        case 0: QUIT_FLAG = 1; /* Message_Quit - time to go */
                break;
        case 0x400c2: au_icon_text_change((char *) &pollblock[28], win_array[0].win_handle, DISPLAY_ICON);
                break;        
        /* More message actions can be added here */
    }
}

void
menuselection(unsigned char block[])
{
   /* We would check which menu was active etc. here */
   
   if(au_bytetoword(block, 0) == 1) {
       /* This is the 'quit' entry */
       QUIT_FLAG = 1;
   }
   return;
}

void
mouseclick(unsigned char pollblock[])
{
   char message[255];
   /* A buffer to hold an 'error' message */

   int clk;
   _kernel_swi_regs in, out;
   unsigned char temp_buffer[255];

   /* Determine which button was pressed */
   clk = (int) au_bytetoword(pollblock, 8);

   /* If the 'Select' button was clicked on the icon bar (pollblock + 12 = -2)
      then re-open main window and return */

   if((au_bytetoword(pollblock, 12) == -2) && (clk == 4)) {
      au_wordtobyte(win_array[0].win_handle, temp_buffer, 0);
      in.r[1] = (int) temp_buffer;
      _kernel_swi(Wimp_GetWindowInfo, &in, &out);
      _kernel_swi(Wimp_OpenWindow, &in, &out);
      return;
   }

   if((au_bytetoword(pollblock, 12) == -2) && (clk == 2)) {
      /* 'Menu' has been clicked on the icon bar icon - now we produce
         a menu */
    au_buildmenu("Submenu", &globmen2);
    au_addtomenu("Entry", MENU_LASTITEM, -1, 0, &globmen2);
    au_createmenu(&globmen2);

    au_buildmenu("Test menu", &globmen);
    au_addtomenu("Entry 1", MENU_TICK | MENU_DOTTED, (int) globmen2.datablock, 0, &globmen);
    au_addtomenu("Quit", MENU_LASTITEM, -1, 0, &globmen);
    au_createmenu(&globmen);
    au_openmenu(&globmen, (int) au_bytetoword(pollblock, 0) - 64, (44*2)+96);
    return;
   }

   strcpy(message, "Mouse click detected (type");
   sprintf(message, "%s %d) - do you wish to stop the program?", message, clk);
   if(au_report_error(1, message, 3, appname) == 1) QUIT_FLAG = 1;
}

int
load_templates(void)
{
    au_opentemplate("<WimpC$Dir>.Templates");
    if(au_loadtemplate("MainWindow", &win_array[0], 0) == 0) {
        au_report_error(1, "Template not found!", 1, appname);
        QUIT_FLAG = 1;
    }
    /* Now we've finished reading the templates, close the file */
    au_closetemplate();
    return 0;
}

void openwindow(unsigned char pollblock[])
{
   _kernel_swi_regs in, out;

   in.r[1] = (int) pollblock;
   _kernel_swi(Wimp_OpenWindow, &in, &out);
   return;
}

void closewindow(unsigned char pollblock[])
{
   _kernel_swi_regs in, out;

   in.r[1] = (int) pollblock;
   _kernel_swi(Wimp_CloseWindow, &in, &out);
   return;
}
00000000  2f 2a 20 41 6e 20 65 78  61 6d 70 6c 65 20 70 72  |/* An example pr|
00000010  6f 67 72 61 6d 20 77 68  69 63 68 20 75 73 65 73  |ogram which uses|
00000020  20 74 68 65 20 6e 65 77  20 41 55 4c 69 62 20 6c  | the new AULib l|
00000030  69 62 72 61 72 79 20 2d  0a 20 20 20 74 68 69 73  |ibrary -.   this|
00000040  20 77 69 6c 6c 20 63 6f  6d 70 69 6c 65 20 77 69  | will compile wi|
00000050  74 68 20 41 63 6f 72 6e  27 73 20 43 20 61 73 20  |th Acorn's C as |
00000060  77 65 6c 6c 20 61 73 20  42 65 65 62 75 67 27 73  |well as Beebug's|
00000070  20 45 61 73 79 43 20 2a  2f 0a 2f 2a 20 62 79 20  | EasyC */./* by |
00000080  53 74 65 76 65 20 4d 75  6d 66 6f 72 64 20 66 6f  |Steve Mumford fo|
00000090  72 20 41 63 6f 72 6e 20  55 73 65 72 20 2d 20 4a  |r Acorn User - J|
000000a0  75 6e 65 20 31 39 39 36  20 2a 2f 0a 0a 23 69 6e  |une 1996 */..#in|
000000b0  63 6c 75 64 65 20 3c 73  74 64 69 6f 2e 68 3e 0a  |clude <stdio.h>.|
000000c0  23 69 6e 63 6c 75 64 65  20 3c 73 74 72 69 6e 67  |#include <string|
000000d0  2e 68 3e 0a 23 69 6e 63  6c 75 64 65 20 22 41 55  |.h>.#include "AU|
000000e0  4c 69 62 2e 68 22 0a 0a  2f 2a 20 57 65 20 61 6c  |Lib.h"../* We al|
000000f0  73 6f 20 64 65 66 69 6e  65 20 61 20 70 6f 6c 6c  |so define a poll|
00000100  20 6d 61 73 6b 20 68 65  72 65 20 74 6f 20 74 65  | mask here to te|
00000110  6c 6c 20 74 68 65 20 57  49 4d 50 20 61 62 6f 75  |ll the WIMP abou|
00000120  74 20 61 6e 79 20 65 76  65 6e 74 73 20 77 65 27  |t any events we'|
00000130  72 65 20 6e 6f 74 0a 20  20 20 69 6e 74 65 72 65  |re not.   intere|
00000140  72 65 73 74 65 64 20 69  6e 20 2a 2f 0a 0a 23 64  |rested in */..#d|
00000150  65 66 69 6e 65 20 50 4f  4c 4c 5f 4d 41 53 4b 20  |efine POLL_MASK |
00000160  31 20 2f 2a 20 44 6f 6e  27 74 20 72 65 74 75 72  |1 /* Don't retur|
00000170  6e 20 6e 75 6c 6c 20 65  76 65 6e 74 73 20 2a 2f  |n null events */|
00000180  0a 23 64 65 66 69 6e 65  20 4d 41 58 5f 57 49 4e  |.#define MAX_WIN|
00000190  44 4f 57 53 20 33 0a 0a  2f 2a 20 49 66 20 77 65  |DOWS 3../* If we|
000001a0  20 73 65 74 20 51 55 49  54 5f 46 4c 41 47 20 75  | set QUIT_FLAG u|
000001b0  70 20 61 73 20 61 20 67  6c 6f 62 61 6c 20 76 61  |p as a global va|
000001c0  72 69 61 62 6c 65 2c 20  69 74 20 6d 65 61 6e 73  |riable, it means|
000001d0  20 74 68 61 74 20 77 65  20 63 61 6e 20 63 68 61  | that we can cha|
000001e0  6e 67 65 20 69 74 0a 20  2a 20 61 6e 79 77 68 65  |nge it. * anywhe|
000001f0  72 65 20 77 69 74 68 69  6e 20 74 68 65 20 70 72  |re within the pr|
00000200  6f 67 72 61 6d 20 61 6e  64 20 73 68 75 74 20 74  |ogram and shut t|
00000210  68 69 6e 67 73 20 64 6f  77 6e 20 6e 65 78 74 20  |hings down next |
00000220  74 69 6d 65 20 77 65 20  65 6e 64 20 74 68 65 0a  |time we end the.|
00000230  20 2a 20 70 6f 6c 6c 69  6e 67 20 6c 6f 6f 70 20  | * polling loop |
00000240  2a 2f 0a 0a 69 6e 74 20  51 55 49 54 5f 46 4c 41  |*/..int QUIT_FLA|
00000250  47 20 3d 20 30 3b 0a 69  6e 74 20 44 49 53 50 4c  |G = 0;.int DISPL|
00000260  41 59 5f 49 43 4f 4e 20  3d 20 31 3b 0a 63 68 61  |AY_ICON = 1;.cha|
00000270  72 20 61 70 70 6e 61 6d  65 5b 5d 20 3d 20 22 4e  |r appname[] = "N|
00000280  65 77 20 57 49 4d 50 43  20 45 78 61 6d 70 6c 65  |ew WIMPC Example|
00000290  22 3b 0a 77 69 6e 64 6f  77 5f 64 61 74 61 20 77  |";.window_data w|
000002a0  69 6e 5f 61 72 72 61 79  5b 4d 41 58 5f 57 49 4e  |in_array[MAX_WIN|
000002b0  44 4f 57 53 5d 3b 0a 6d  65 6e 75 5f 64 61 74 61  |DOWS];.menu_data|
000002c0  20 20 20 67 6c 6f 62 6d  65 6e 2c 20 67 6c 6f 62  |   globmen, glob|
000002d0  6d 65 6e 32 3b 0a 0a 2f  2a 20 46 75 6e 63 74 69  |men2;../* Functi|
000002e0  6f 6e 20 70 72 6f 74 6f  74 79 70 69 6e 67 20 2a  |on prototyping *|
000002f0  2f 0a 0a 69 6e 74 20 20  20 20 20 20 6d 61 69 6e  |/..int      main|
00000300  28 76 6f 69 64 29 3b 0a  76 6f 69 64 20 20 20 20  |(void);.void    |
00000310  20 77 69 6d 70 6d 73 67  28 69 6e 74 2c 20 75 6e  | wimpmsg(int, un|
00000320  73 69 67 6e 65 64 20 63  68 61 72 5b 5d 29 3b 0a  |signed char[]);.|
00000330  76 6f 69 64 20 20 20 20  20 6d 6f 75 73 65 63 6c  |void     mousecl|
00000340  69 63 6b 28 75 6e 73 69  67 6e 65 64 20 63 68 61  |ick(unsigned cha|
00000350  72 5b 5d 29 3b 0a 76 6f  69 64 20 20 20 20 20 6d  |r[]);.void     m|
00000360  65 6e 75 73 65 6c 65 63  74 69 6f 6e 28 75 6e 73  |enuselection(uns|
00000370  69 67 6e 65 64 20 63 68  61 72 5b 5d 29 3b 0a 69  |igned char[]);.i|
00000380  6e 74 20 20 20 20 20 20  6c 6f 61 64 5f 74 65 6d  |nt      load_tem|
00000390  70 6c 61 74 65 73 28 76  6f 69 64 29 3b 0a 76 6f  |plates(void);.vo|
000003a0  69 64 20 20 20 20 20 6f  70 65 6e 77 69 6e 64 6f  |id     openwindo|
000003b0  77 28 75 6e 73 69 67 6e  65 64 20 63 68 61 72 5b  |w(unsigned char[|
000003c0  5d 29 3b 0a 76 6f 69 64  20 20 20 20 20 63 6c 6f  |]);.void     clo|
000003d0  73 65 77 69 6e 64 6f 77  28 75 6e 73 69 67 6e 65  |sewindow(unsigne|
000003e0  64 20 63 68 61 72 5b 5d  29 3b 0a 0a 2f 2a 20 50  |d char[]);../* P|
000003f0  72 6f 67 72 61 6d 20 66  75 6e 63 74 69 6f 6e 73  |rogram functions|
00000400  20 2a 2f 0a 0a 69 6e 74  0a 6d 61 69 6e 28 76 6f  | */..int.main(vo|
00000410  69 64 29 20 7b 0a 20 20  20 20 69 6e 74 20 74 61  |id) {.    int ta|
00000420  73 6b 5f 68 61 6e 64 6c  65 3b 0a 20 20 20 20 75  |sk_handle;.    u|
00000430  6e 73 69 67 6e 65 64 20  63 68 61 72 20 70 6f 6c  |nsigned char pol|
00000440  6c 62 6c 6f 63 6b 5b 32  35 37 5d 3b 20 2f 2a 20  |lblock[257]; /* |
00000450  41 20 62 79 74 65 20 61  72 72 61 79 20 6c 61 72  |A byte array lar|
00000460  67 65 20 65 6e 6f 75 67  68 20 66 6f 72 20 6f 75  |ge enough for ou|
00000470  72 20 70 6f 6c 6c 69 6e  67 20 62 6c 6f 63 6b 20  |r polling block |
00000480  2a 2f 0a 20 20 20 20 69  6e 74 20 69 62 61 72 5f  |*/.    int ibar_|
00000490  69 63 6f 6e 5f 68 61 6e  64 6c 65 3b 20 2f 2a 20  |icon_handle; /* |
000004a0  41 20 76 61 72 69 61 62  6c 65 20 74 6f 20 73 74  |A variable to st|
000004b0  6f 72 65 20 6f 75 72 20  69 63 6f 6e 62 61 72 20  |ore our iconbar |
000004c0  69 63 6f 6e 20 68 61 6e  64 6c 65 20 2a 2f 0a 20  |icon handle */. |
000004d0  20 20 20 69 6e 74 20 70  6f 6c 6c 72 65 73 75 6c  |   int pollresul|
000004e0  74 3b 0a 20 20 20 20 69  6e 74 20 69 3b 0a 20 20  |t;.    int i;.  |
000004f0  20 20 6c 6f 6e 67 20 69  6e 74 20 6d 73 67 6c 69  |  long int msgli|
00000500  73 74 5b 31 5d 20 3d 20  7b 30 7d 3b 20 2f 2a 20  |st[1] = {0}; /* |
00000510  53 65 74 20 75 70 20 74  68 65 20 61 63 63 65 70  |Set up the accep|
00000520  74 61 62 6c 65 20 6d 65  73 73 61 67 65 20 6c 69  |table message li|
00000530  73 74 20 66 6f 72 20 69  6e 69 74 69 61 6c 69 73  |st for initialis|
00000540  61 74 69 6f 6e 20 2a 2f  0a 0a 20 20 20 20 74 61  |ation */..    ta|
00000550  73 6b 5f 68 61 6e 64 6c  65 20 3d 20 61 75 5f 69  |sk_handle = au_i|
00000560  6e 69 74 69 61 6c 69 73  65 28 33 31 30 2c 20 61  |nitialise(310, a|
00000570  70 70 6e 61 6d 65 2c 20  6d 73 67 6c 69 73 74 29  |ppname, msglist)|
00000580  3b 0a 20 20 20 20 2f 2a  20 4e 6f 77 2c 20 77 65  |;.    /* Now, we|
00000590  27 6c 6c 20 70 75 74 20  61 6e 20 69 63 6f 6e 20  |'ll put an icon |
000005a0  6f 6e 20 74 68 65 20 69  63 6f 6e 20 62 61 72 20  |on the icon bar |
000005b0  2a 2f 0a 20 20 20 20 69  62 61 72 5f 69 63 6f 6e  |*/.    ibar_icon|
000005c0  5f 68 61 6e 64 6c 65 20  3d 20 61 75 5f 63 72 65  |_handle = au_cre|
000005d0  61 74 65 5f 69 63 6f 6e  62 61 72 5f 69 63 6f 6e  |ate_iconbar_icon|
000005e0  28 49 42 41 52 5f 50 52  49 4f 52 5f 41 50 50 2c  |(IBAR_PRIOR_APP,|
000005f0  0a 20 20 20 20 20 20 20  20 49 42 41 52 5f 4f 4e  |.        IBAR_ON|
00000600  52 49 47 48 54 2c 0a 20  20 20 20 20 20 20 20 49  |RIGHT,.        I|
00000610  43 4f 4e 5f 49 53 53 50  52 49 54 45 20 7c 20 49  |CON_ISSPRITE | I|
00000620  43 4f 4e 5f 48 43 45 4e  54 52 45 20 7c 20 49 43  |CON_HCENTRE | IC|
00000630  4f 4e 5f 56 43 45 4e 54  52 45 20 7c 20 49 43 4f  |ON_VCENTRE | ICO|
00000640  4e 5f 43 4c 49 43 4b 4e  4f 54 49 46 49 45 53 4f  |N_CLICKNOTIFIESO|
00000650  4e 43 45 2c 0a 20 20 20  20 20 20 20 20 22 21 6e  |NCE,.        "!n|
00000660  65 77 77 69 6d 70 63 22  29 3b 0a 0a 2f 2a 20 4e  |ewwimpc");../* N|
00000670  6f 77 20 6f 70 65 6e 20  61 20 74 65 6d 70 6c 61  |ow open a templa|
00000680  74 65 20 66 69 6c 65 20  72 65 61 64 79 20 66 6f  |te file ready fo|
00000690  72 20 6c 6f 61 64 69 6e  67 20 2a 2f 0a 0a 20 20  |r loading */..  |
000006a0  20 20 6c 6f 61 64 5f 74  65 6d 70 6c 61 74 65 73  |  load_templates|
000006b0  28 29 3b 0a 20 20 20 20  61 75 5f 6f 70 65 6e 77  |();.    au_openw|
000006c0  69 6e 5f 66 72 6f 6d 5f  74 65 6d 70 6c 61 74 65  |in_from_template|
000006d0  64 61 74 61 28 26 77 69  6e 5f 61 72 72 61 79 5b  |data(&win_array[|
000006e0  30 5d 2c 20 2d 31 29 3b  20 2f 2a 20 4f 70 65 6e  |0], -1); /* Open|
000006f0  20 66 69 72 73 74 20 77  69 6e 64 6f 77 20 61 74  | first window at|
00000700  20 66 72 6f 6e 74 20 28  2d 31 29 20 2a 2f 0a 0a  | front (-1) */..|
00000710  20 20 20 20 77 68 69 6c  65 20 28 51 55 49 54 5f  |    while (QUIT_|
00000720  46 4c 41 47 20 3d 3d 20  30 29 20 7b 0a 20 20 20  |FLAG == 0) {.   |
00000730  20 70 6f 6c 6c 72 65 73  75 6c 74 20 3d 20 61 75  | pollresult = au|
00000740  5f 77 69 6d 70 5f 70 6f  6c 6c 28 50 4f 4c 4c 5f  |_wimp_poll(POLL_|
00000750  4d 41 53 4b 2c 20 70 6f  6c 6c 62 6c 6f 63 6b 29  |MASK, pollblock)|
00000760  3b 0a 20 20 20 20 20 20  20 20 73 77 69 74 63 68  |;.        switch|
00000770  20 28 70 6f 6c 6c 72 65  73 75 6c 74 29 20 7b 0a  | (pollresult) {.|
00000780  20 20 20 20 20 20 20 20  20 20 20 20 63 61 73 65  |            case|
00000790  20 20 32 3a 20 6f 70 65  6e 77 69 6e 64 6f 77 28  |  2: openwindow(|
000007a0  70 6f 6c 6c 62 6c 6f 63  6b 29 3b 0a 20 20 20 20  |pollblock);.    |
000007b0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000007c0  20 62 72 65 61 6b 3b 0a  20 20 20 20 20 20 20 20  | break;.        |
000007d0  20 20 20 20 63 61 73 65  20 20 33 3a 20 63 6c 6f  |    case  3: clo|
000007e0  73 65 77 69 6e 64 6f 77  28 70 6f 6c 6c 62 6c 6f  |sewindow(pollblo|
000007f0  63 6b 29 3b 0a 20 20 20  20 20 20 20 20 20 20 20  |ck);.           |
00000800  20 20 20 20 20 20 20 20  20 20 62 72 65 61 6b 3b  |          break;|
00000810  0a 20 20 20 20 20 20 20  20 20 20 20 20 63 61 73  |.            cas|
00000820  65 20 20 36 3a 20 6d 6f  75 73 65 63 6c 69 63 6b  |e  6: mouseclick|
00000830  28 70 6f 6c 6c 62 6c 6f  63 6b 29 3b 0a 20 20 20  |(pollblock);.   |
00000840  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000850  20 20 62 72 65 61 6b 3b  0a 20 20 20 20 20 20 20  |  break;.       |
00000860  20 20 20 20 20 20 20 20  20 20 20 20 20 20 2f 2a  |              /*|
00000870  20 49 66 20 6f 75 72 20  69 63 6f 6e 20 69 73 20  | If our icon is |
00000880  63 6c 69 63 6b 65 64 20  6f 6e 2c 20 77 65 20 6a  |clicked on, we j|
00000890  75 6d 70 20 74 6f 20 6d  6f 75 73 65 63 6c 69 63  |ump to mouseclic|
000008a0  6b 28 29 20 2a 2f 0a 20  20 20 20 20 20 20 20 20  |k() */.         |
000008b0  20 20 20 63 61 73 65 20  20 39 3a 20 6d 65 6e 75  |   case  9: menu|
000008c0  73 65 6c 65 63 74 69 6f  6e 28 70 6f 6c 6c 62 6c  |selection(pollbl|
000008d0  6f 63 6b 29 3b 0a 20 20  20 20 20 20 20 20 20 20  |ock);.          |
000008e0  20 20 20 20 20 20 20 20  20 20 20 62 72 65 61 6b  |           break|
000008f0  3b 0a 20 20 20 20 20 20  20 20 20 20 20 20 63 61  |;.            ca|
00000900  73 65 20 31 37 3a 0a 20  20 20 20 20 20 20 20 20  |se 17:.         |
00000910  20 20 20 63 61 73 65 20  31 38 3a 0a 20 20 20 20  |   case 18:.    |
00000920  20 20 20 20 20 20 20 20  63 61 73 65 20 31 39 3a  |        case 19:|
00000930  20 77 69 6d 70 6d 73 67  28 70 6f 6c 6c 72 65 73  | wimpmsg(pollres|
00000940  75 6c 74 2c 20 70 6f 6c  6c 62 6c 6f 63 6b 29 3b  |ult, pollblock);|
00000950  0a 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |.               |
00000960  20 62 72 65 61 6b 3b 0a  20 20 20 20 20 20 20 20  | break;.        |
00000970  20 20 20 20 2f 2a 20 54  68 65 20 61 62 6f 76 65  |    /* The above|
00000980  20 73 65 63 74 69 6f 6e  20 6c 69 73 74 65 6e 73  | section listens|
00000990  20 66 6f 72 20 65 76 65  6e 74 20 63 6f 64 65 73  | for event codes|
000009a0  20 31 37 2c 20 31 38 20  61 6e 64 20 31 39 20 2d  | 17, 18 and 19 -|
000009b0  20 74 68 65 0a 20 20 20  20 20 20 20 20 20 20 20  | the.           |
000009c0  20 20 20 20 6f 6e 65 73  20 77 68 69 63 68 20 69  |    ones which i|
000009d0  6e 64 69 63 61 74 65 20  77 65 27 72 65 20 62 65  |ndicate we're be|
000009e0  69 6e 67 20 73 65 6e 74  20 61 20 6d 65 73 73 61  |ing sent a messa|
000009f0  67 65 20 2a 2f 0a 20 20  20 20 20 20 20 20 7d 0a  |ge */.        }.|
00000a00  20 20 20 20 7d 0a 20 20  20 20 2f 2a 20 49 66 20  |    }.    /* If |
00000a10  51 55 49 54 5f 46 4c 41  47 20 63 68 61 6e 67 65  |QUIT_FLAG change|
00000a20  73 20 74 6f 20 61 6e 79  74 68 69 6e 67 20 62 75  |s to anything bu|
00000a30  74 20 30 2c 20 77 65 20  73 74 6f 70 20 67 6f 69  |t 0, we stop goi|
00000a40  6e 67 20 72 6f 75 6e 64  20 74 68 65 20 70 6f 6c  |ng round the pol|
00000a50  6c 69 6e 67 0a 20 20 20  20 20 2a 20 6c 6f 6f 70  |ling.     * loop|
00000a60  20 61 6e 64 20 73 68 75  74 20 64 6f 77 6e 20 2a  | and shut down *|
00000a70  2f 0a 0a 20 20 20 20 61  75 5f 63 6c 6f 73 65 64  |/..    au_closed|
00000a80  6f 77 6e 28 74 61 73 6b  5f 68 61 6e 64 6c 65 29  |own(task_handle)|
00000a90  3b 0a 20 20 20 20 2f 2a  20 4e 65 65 64 20 74 6f  |;.    /* Need to|
00000aa0  20 72 65 6c 65 61 73 65  20 6d 61 6c 6c 6f 63 20  | release malloc |
00000ab0  6d 65 6d 6f 72 79 20 66  72 6f 6d 20 77 69 6e 64  |memory from wind|
00000ac0  6f 77 20 73 74 72 75 63  74 75 72 65 73 20 2a 2f  |ow structures */|
00000ad0  0a 20 20 20 20 66 6f 72  28 69 20 3d 20 30 3b 20  |.    for(i = 0; |
00000ae0  69 20 3c 20 4d 41 58 5f  57 49 4e 44 4f 57 53 3b  |i < MAX_WINDOWS;|
00000af0  20 69 2b 2b 29 20 7b 0a  20 20 20 20 20 20 20 20  | i++) {.        |
00000b00  66 72 65 65 28 77 69 6e  5f 61 72 72 61 79 5b 69  |free(win_array[i|
00000b10  5d 2e 77 69 6e 5f 6e 61  6d 65 29 3b 0a 20 20 20  |].win_name);.   |
00000b20  20 20 20 20 20 66 72 65  65 28 77 69 6e 5f 61 72  |     free(win_ar|
00000b30  72 61 79 5b 69 5d 2e 62  75 66 66 65 72 29 3b 0a  |ray[i].buffer);.|
00000b40  20 20 20 20 20 20 20 20  66 72 65 65 28 77 69 6e  |        free(win|
00000b50  5f 61 72 72 61 79 5b 69  5d 2e 77 6f 72 6b 73 70  |_array[i].worksp|
00000b60  61 63 65 29 3b 0a 20 20  20 20 7d 0a 7d 0a 0a 76  |ace);.    }.}..v|
00000b70  6f 69 64 0a 77 69 6d 70  6d 73 67 28 69 6e 74 20  |oid.wimpmsg(int |
00000b80  72 65 73 75 6c 74 2c 20  75 6e 73 69 67 6e 65 64  |result, unsigned|
00000b90  20 63 68 61 72 20 70 6f  6c 6c 62 6c 6f 63 6b 5b  | char pollblock[|
00000ba0  5d 29 0a 7b 0a 20 20 20  20 75 6e 73 69 67 6e 65  |]).{.    unsigne|
00000bb0  64 20 6c 6f 6e 67 20 69  6e 74 20 20 20 6d 65 73  |d long int   mes|
00000bc0  73 61 67 65 5f 61 63 74  69 6f 6e 3b 0a 0a 20 20  |sage_action;..  |
00000bd0  20 20 2f 2a 20 54 68 65  20 6e 65 78 74 20 6c 69  |  /* The next li|
00000be0  6e 65 20 74 61 6b 65 73  20 62 79 74 65 73 20 31  |ne takes bytes 1|
00000bf0  36 20 74 6f 20 31 39 20  6f 66 20 74 68 65 20 70  |6 to 19 of the p|
00000c00  6f 6c 6c 69 6e 67 20 62  6c 6f 63 6b 20 61 6e 64  |olling block and|
00000c10  20 66 6f 72 6d 73 20 74  68 65 6d 0a 20 20 20 20  | forms them.    |
00000c20  20 20 20 69 6e 74 6f 20  61 20 77 6f 72 64 20 68  |   into a word h|
00000c30  6f 6c 64 69 6e 67 20 74  68 65 20 6d 65 73 73 61  |olding the messa|
00000c40  67 65 20 61 63 74 69 6f  6e 20 6e 75 6d 62 65 72  |ge action number|
00000c50  20 2a 2f 0a 20 20 20 20  6d 65 73 73 61 67 65 5f  | */.    message_|
00000c60  61 63 74 69 6f 6e 20 3d  20 61 75 5f 62 79 74 65  |action = au_byte|
00000c70  74 6f 77 6f 72 64 28 70  6f 6c 6c 62 6c 6f 63 6b  |toword(pollblock|
00000c80  2c 20 31 36 29 3b 0a 20  20 20 20 0a 20 20 20 20  |, 16);.    .    |
00000c90  73 77 69 74 63 68 20 28  6d 65 73 73 61 67 65 5f  |switch (message_|
00000ca0  61 63 74 69 6f 6e 29 20  7b 0a 20 20 20 20 20 20  |action) {.      |
00000cb0  20 20 63 61 73 65 20 30  3a 20 51 55 49 54 5f 46  |  case 0: QUIT_F|
00000cc0  4c 41 47 20 3d 20 31 3b  20 2f 2a 20 4d 65 73 73  |LAG = 1; /* Mess|
00000cd0  61 67 65 5f 51 75 69 74  20 2d 20 74 69 6d 65 20  |age_Quit - time |
00000ce0  74 6f 20 67 6f 20 2a 2f  0a 20 20 20 20 20 20 20  |to go */.       |
00000cf0  20 20 20 20 20 20 20 20  20 62 72 65 61 6b 3b 0a  |         break;.|
00000d00  20 20 20 20 20 20 20 20  63 61 73 65 20 30 78 34  |        case 0x4|
00000d10  30 30 63 32 3a 20 61 75  5f 69 63 6f 6e 5f 74 65  |00c2: au_icon_te|
00000d20  78 74 5f 63 68 61 6e 67  65 28 28 63 68 61 72 20  |xt_change((char |
00000d30  2a 29 20 26 70 6f 6c 6c  62 6c 6f 63 6b 5b 32 38  |*) &pollblock[28|
00000d40  5d 2c 20 77 69 6e 5f 61  72 72 61 79 5b 30 5d 2e  |], win_array[0].|
00000d50  77 69 6e 5f 68 61 6e 64  6c 65 2c 20 44 49 53 50  |win_handle, DISP|
00000d60  4c 41 59 5f 49 43 4f 4e  29 3b 0a 20 20 20 20 20  |LAY_ICON);.     |
00000d70  20 20 20 20 20 20 20 20  20 20 20 62 72 65 61 6b  |           break|
00000d80  3b 20 20 20 20 20 20 20  20 0a 20 20 20 20 20 20  |;        .      |
00000d90  20 20 2f 2a 20 4d 6f 72  65 20 6d 65 73 73 61 67  |  /* More messag|
00000da0  65 20 61 63 74 69 6f 6e  73 20 63 61 6e 20 62 65  |e actions can be|
00000db0  20 61 64 64 65 64 20 68  65 72 65 20 2a 2f 0a 20  | added here */. |
00000dc0  20 20 20 7d 0a 7d 0a 0a  76 6f 69 64 0a 6d 65 6e  |   }.}..void.men|
00000dd0  75 73 65 6c 65 63 74 69  6f 6e 28 75 6e 73 69 67  |uselection(unsig|
00000de0  6e 65 64 20 63 68 61 72  20 62 6c 6f 63 6b 5b 5d  |ned char block[]|
00000df0  29 0a 7b 0a 20 20 20 2f  2a 20 57 65 20 77 6f 75  |).{.   /* We wou|
00000e00  6c 64 20 63 68 65 63 6b  20 77 68 69 63 68 20 6d  |ld check which m|
00000e10  65 6e 75 20 77 61 73 20  61 63 74 69 76 65 20 65  |enu was active e|
00000e20  74 63 2e 20 68 65 72 65  20 2a 2f 0a 20 20 20 0a  |tc. here */.   .|
00000e30  20 20 20 69 66 28 61 75  5f 62 79 74 65 74 6f 77  |   if(au_bytetow|
00000e40  6f 72 64 28 62 6c 6f 63  6b 2c 20 30 29 20 3d 3d  |ord(block, 0) ==|
00000e50  20 31 29 20 7b 0a 20 20  20 20 20 20 20 2f 2a 20  | 1) {.       /* |
00000e60  54 68 69 73 20 69 73 20  74 68 65 20 27 71 75 69  |This is the 'qui|
00000e70  74 27 20 65 6e 74 72 79  20 2a 2f 0a 20 20 20 20  |t' entry */.    |
00000e80  20 20 20 51 55 49 54 5f  46 4c 41 47 20 3d 20 31  |   QUIT_FLAG = 1|
00000e90  3b 0a 20 20 20 7d 0a 20  20 20 72 65 74 75 72 6e  |;.   }.   return|
00000ea0  3b 0a 7d 0a 0a 76 6f 69  64 0a 6d 6f 75 73 65 63  |;.}..void.mousec|
00000eb0  6c 69 63 6b 28 75 6e 73  69 67 6e 65 64 20 63 68  |lick(unsigned ch|
00000ec0  61 72 20 70 6f 6c 6c 62  6c 6f 63 6b 5b 5d 29 0a  |ar pollblock[]).|
00000ed0  7b 0a 20 20 20 63 68 61  72 20 6d 65 73 73 61 67  |{.   char messag|
00000ee0  65 5b 32 35 35 5d 3b 0a  20 20 20 2f 2a 20 41 20  |e[255];.   /* A |
00000ef0  62 75 66 66 65 72 20 74  6f 20 68 6f 6c 64 20 61  |buffer to hold a|
00000f00  6e 20 27 65 72 72 6f 72  27 20 6d 65 73 73 61 67  |n 'error' messag|
00000f10  65 20 2a 2f 0a 0a 20 20  20 69 6e 74 20 63 6c 6b  |e */..   int clk|
00000f20  3b 0a 20 20 20 5f 6b 65  72 6e 65 6c 5f 73 77 69  |;.   _kernel_swi|
00000f30  5f 72 65 67 73 20 69 6e  2c 20 6f 75 74 3b 0a 20  |_regs in, out;. |
00000f40  20 20 75 6e 73 69 67 6e  65 64 20 63 68 61 72 20  |  unsigned char |
00000f50  74 65 6d 70 5f 62 75 66  66 65 72 5b 32 35 35 5d  |temp_buffer[255]|
00000f60  3b 0a 0a 20 20 20 2f 2a  20 44 65 74 65 72 6d 69  |;..   /* Determi|
00000f70  6e 65 20 77 68 69 63 68  20 62 75 74 74 6f 6e 20  |ne which button |
00000f80  77 61 73 20 70 72 65 73  73 65 64 20 2a 2f 0a 20  |was pressed */. |
00000f90  20 20 63 6c 6b 20 3d 20  28 69 6e 74 29 20 61 75  |  clk = (int) au|
00000fa0  5f 62 79 74 65 74 6f 77  6f 72 64 28 70 6f 6c 6c  |_bytetoword(poll|
00000fb0  62 6c 6f 63 6b 2c 20 38  29 3b 0a 0a 20 20 20 2f  |block, 8);..   /|
00000fc0  2a 20 49 66 20 74 68 65  20 27 53 65 6c 65 63 74  |* If the 'Select|
00000fd0  27 20 62 75 74 74 6f 6e  20 77 61 73 20 63 6c 69  |' button was cli|
00000fe0  63 6b 65 64 20 6f 6e 20  74 68 65 20 69 63 6f 6e  |cked on the icon|
00000ff0  20 62 61 72 20 28 70 6f  6c 6c 62 6c 6f 63 6b 20  | bar (pollblock |
00001000  2b 20 31 32 20 3d 20 2d  32 29 0a 20 20 20 20 20  |+ 12 = -2).     |
00001010  20 74 68 65 6e 20 72 65  2d 6f 70 65 6e 20 6d 61  | then re-open ma|
00001020  69 6e 20 77 69 6e 64 6f  77 20 61 6e 64 20 72 65  |in window and re|
00001030  74 75 72 6e 20 2a 2f 0a  0a 20 20 20 69 66 28 28  |turn */..   if((|
00001040  61 75 5f 62 79 74 65 74  6f 77 6f 72 64 28 70 6f  |au_bytetoword(po|
00001050  6c 6c 62 6c 6f 63 6b 2c  20 31 32 29 20 3d 3d 20  |llblock, 12) == |
00001060  2d 32 29 20 26 26 20 28  63 6c 6b 20 3d 3d 20 34  |-2) && (clk == 4|
00001070  29 29 20 7b 0a 20 20 20  20 20 20 61 75 5f 77 6f  |)) {.      au_wo|
00001080  72 64 74 6f 62 79 74 65  28 77 69 6e 5f 61 72 72  |rdtobyte(win_arr|
00001090  61 79 5b 30 5d 2e 77 69  6e 5f 68 61 6e 64 6c 65  |ay[0].win_handle|
000010a0  2c 20 74 65 6d 70 5f 62  75 66 66 65 72 2c 20 30  |, temp_buffer, 0|
000010b0  29 3b 0a 20 20 20 20 20  20 69 6e 2e 72 5b 31 5d  |);.      in.r[1]|
000010c0  20 3d 20 28 69 6e 74 29  20 74 65 6d 70 5f 62 75  | = (int) temp_bu|
000010d0  66 66 65 72 3b 0a 20 20  20 20 20 20 5f 6b 65 72  |ffer;.      _ker|
000010e0  6e 65 6c 5f 73 77 69 28  57 69 6d 70 5f 47 65 74  |nel_swi(Wimp_Get|
000010f0  57 69 6e 64 6f 77 49 6e  66 6f 2c 20 26 69 6e 2c  |WindowInfo, &in,|
00001100  20 26 6f 75 74 29 3b 0a  20 20 20 20 20 20 5f 6b  | &out);.      _k|
00001110  65 72 6e 65 6c 5f 73 77  69 28 57 69 6d 70 5f 4f  |ernel_swi(Wimp_O|
00001120  70 65 6e 57 69 6e 64 6f  77 2c 20 26 69 6e 2c 20  |penWindow, &in, |
00001130  26 6f 75 74 29 3b 0a 20  20 20 20 20 20 72 65 74  |&out);.      ret|
00001140  75 72 6e 3b 0a 20 20 20  7d 0a 0a 20 20 20 69 66  |urn;.   }..   if|
00001150  28 28 61 75 5f 62 79 74  65 74 6f 77 6f 72 64 28  |((au_bytetoword(|
00001160  70 6f 6c 6c 62 6c 6f 63  6b 2c 20 31 32 29 20 3d  |pollblock, 12) =|
00001170  3d 20 2d 32 29 20 26 26  20 28 63 6c 6b 20 3d 3d  |= -2) && (clk ==|
00001180  20 32 29 29 20 7b 0a 20  20 20 20 20 20 2f 2a 20  | 2)) {.      /* |
00001190  27 4d 65 6e 75 27 20 68  61 73 20 62 65 65 6e 20  |'Menu' has been |
000011a0  63 6c 69 63 6b 65 64 20  6f 6e 20 74 68 65 20 69  |clicked on the i|
000011b0  63 6f 6e 20 62 61 72 20  69 63 6f 6e 20 2d 20 6e  |con bar icon - n|
000011c0  6f 77 20 77 65 20 70 72  6f 64 75 63 65 0a 20 20  |ow we produce.  |
000011d0  20 20 20 20 20 20 20 61  20 6d 65 6e 75 20 2a 2f  |       a menu */|
000011e0  0a 20 20 20 20 61 75 5f  62 75 69 6c 64 6d 65 6e  |.    au_buildmen|
000011f0  75 28 22 53 75 62 6d 65  6e 75 22 2c 20 26 67 6c  |u("Submenu", &gl|
00001200  6f 62 6d 65 6e 32 29 3b  0a 20 20 20 20 61 75 5f  |obmen2);.    au_|
00001210  61 64 64 74 6f 6d 65 6e  75 28 22 45 6e 74 72 79  |addtomenu("Entry|
00001220  22 2c 20 4d 45 4e 55 5f  4c 41 53 54 49 54 45 4d  |", MENU_LASTITEM|
00001230  2c 20 2d 31 2c 20 30 2c  20 26 67 6c 6f 62 6d 65  |, -1, 0, &globme|
00001240  6e 32 29 3b 0a 20 20 20  20 61 75 5f 63 72 65 61  |n2);.    au_crea|
00001250  74 65 6d 65 6e 75 28 26  67 6c 6f 62 6d 65 6e 32  |temenu(&globmen2|
00001260  29 3b 0a 0a 20 20 20 20  61 75 5f 62 75 69 6c 64  |);..    au_build|
00001270  6d 65 6e 75 28 22 54 65  73 74 20 6d 65 6e 75 22  |menu("Test menu"|
00001280  2c 20 26 67 6c 6f 62 6d  65 6e 29 3b 0a 20 20 20  |, &globmen);.   |
00001290  20 61 75 5f 61 64 64 74  6f 6d 65 6e 75 28 22 45  | au_addtomenu("E|
000012a0  6e 74 72 79 20 31 22 2c  20 4d 45 4e 55 5f 54 49  |ntry 1", MENU_TI|
000012b0  43 4b 20 7c 20 4d 45 4e  55 5f 44 4f 54 54 45 44  |CK | MENU_DOTTED|
000012c0  2c 20 28 69 6e 74 29 20  67 6c 6f 62 6d 65 6e 32  |, (int) globmen2|
000012d0  2e 64 61 74 61 62 6c 6f  63 6b 2c 20 30 2c 20 26  |.datablock, 0, &|
000012e0  67 6c 6f 62 6d 65 6e 29  3b 0a 20 20 20 20 61 75  |globmen);.    au|
000012f0  5f 61 64 64 74 6f 6d 65  6e 75 28 22 51 75 69 74  |_addtomenu("Quit|
00001300  22 2c 20 4d 45 4e 55 5f  4c 41 53 54 49 54 45 4d  |", MENU_LASTITEM|
00001310  2c 20 2d 31 2c 20 30 2c  20 26 67 6c 6f 62 6d 65  |, -1, 0, &globme|
00001320  6e 29 3b 0a 20 20 20 20  61 75 5f 63 72 65 61 74  |n);.    au_creat|
00001330  65 6d 65 6e 75 28 26 67  6c 6f 62 6d 65 6e 29 3b  |emenu(&globmen);|
00001340  0a 20 20 20 20 61 75 5f  6f 70 65 6e 6d 65 6e 75  |.    au_openmenu|
00001350  28 26 67 6c 6f 62 6d 65  6e 2c 20 28 69 6e 74 29  |(&globmen, (int)|
00001360  20 61 75 5f 62 79 74 65  74 6f 77 6f 72 64 28 70  | au_bytetoword(p|
00001370  6f 6c 6c 62 6c 6f 63 6b  2c 20 30 29 20 2d 20 36  |ollblock, 0) - 6|
00001380  34 2c 20 28 34 34 2a 32  29 2b 39 36 29 3b 0a 20  |4, (44*2)+96);. |
00001390  20 20 20 72 65 74 75 72  6e 3b 0a 20 20 20 7d 0a  |   return;.   }.|
000013a0  0a 20 20 20 73 74 72 63  70 79 28 6d 65 73 73 61  |.   strcpy(messa|
000013b0  67 65 2c 20 22 4d 6f 75  73 65 20 63 6c 69 63 6b  |ge, "Mouse click|
000013c0  20 64 65 74 65 63 74 65  64 20 28 74 79 70 65 22  | detected (type"|
000013d0  29 3b 0a 20 20 20 73 70  72 69 6e 74 66 28 6d 65  |);.   sprintf(me|
000013e0  73 73 61 67 65 2c 20 22  25 73 20 25 64 29 20 2d  |ssage, "%s %d) -|
000013f0  20 64 6f 20 79 6f 75 20  77 69 73 68 20 74 6f 20  | do you wish to |
00001400  73 74 6f 70 20 74 68 65  20 70 72 6f 67 72 61 6d  |stop the program|
00001410  3f 22 2c 20 6d 65 73 73  61 67 65 2c 20 63 6c 6b  |?", message, clk|
00001420  29 3b 0a 20 20 20 69 66  28 61 75 5f 72 65 70 6f  |);.   if(au_repo|
00001430  72 74 5f 65 72 72 6f 72  28 31 2c 20 6d 65 73 73  |rt_error(1, mess|
00001440  61 67 65 2c 20 33 2c 20  61 70 70 6e 61 6d 65 29  |age, 3, appname)|
00001450  20 3d 3d 20 31 29 20 51  55 49 54 5f 46 4c 41 47  | == 1) QUIT_FLAG|
00001460  20 3d 20 31 3b 0a 7d 0a  0a 69 6e 74 0a 6c 6f 61  | = 1;.}..int.loa|
00001470  64 5f 74 65 6d 70 6c 61  74 65 73 28 76 6f 69 64  |d_templates(void|
00001480  29 0a 7b 0a 20 20 20 20  61 75 5f 6f 70 65 6e 74  |).{.    au_opent|
00001490  65 6d 70 6c 61 74 65 28  22 3c 57 69 6d 70 43 24  |emplate("<WimpC$|
000014a0  44 69 72 3e 2e 54 65 6d  70 6c 61 74 65 73 22 29  |Dir>.Templates")|
000014b0  3b 0a 20 20 20 20 69 66  28 61 75 5f 6c 6f 61 64  |;.    if(au_load|
000014c0  74 65 6d 70 6c 61 74 65  28 22 4d 61 69 6e 57 69  |template("MainWi|
000014d0  6e 64 6f 77 22 2c 20 26  77 69 6e 5f 61 72 72 61  |ndow", &win_arra|
000014e0  79 5b 30 5d 2c 20 30 29  20 3d 3d 20 30 29 20 7b  |y[0], 0) == 0) {|
000014f0  0a 20 20 20 20 20 20 20  20 61 75 5f 72 65 70 6f  |.        au_repo|
00001500  72 74 5f 65 72 72 6f 72  28 31 2c 20 22 54 65 6d  |rt_error(1, "Tem|
00001510  70 6c 61 74 65 20 6e 6f  74 20 66 6f 75 6e 64 21  |plate not found!|
00001520  22 2c 20 31 2c 20 61 70  70 6e 61 6d 65 29 3b 0a  |", 1, appname);.|
00001530  20 20 20 20 20 20 20 20  51 55 49 54 5f 46 4c 41  |        QUIT_FLA|
00001540  47 20 3d 20 31 3b 0a 20  20 20 20 7d 0a 20 20 20  |G = 1;.    }.   |
00001550  20 2f 2a 20 4e 6f 77 20  77 65 27 76 65 20 66 69  | /* Now we've fi|
00001560  6e 69 73 68 65 64 20 72  65 61 64 69 6e 67 20 74  |nished reading t|
00001570  68 65 20 74 65 6d 70 6c  61 74 65 73 2c 20 63 6c  |he templates, cl|
00001580  6f 73 65 20 74 68 65 20  66 69 6c 65 20 2a 2f 0a  |ose the file */.|
00001590  20 20 20 20 61 75 5f 63  6c 6f 73 65 74 65 6d 70  |    au_closetemp|
000015a0  6c 61 74 65 28 29 3b 0a  20 20 20 20 72 65 74 75  |late();.    retu|
000015b0  72 6e 20 30 3b 0a 7d 0a  0a 76 6f 69 64 20 6f 70  |rn 0;.}..void op|
000015c0  65 6e 77 69 6e 64 6f 77  28 75 6e 73 69 67 6e 65  |enwindow(unsigne|
000015d0  64 20 63 68 61 72 20 70  6f 6c 6c 62 6c 6f 63 6b  |d char pollblock|
000015e0  5b 5d 29 0a 7b 0a 20 20  20 5f 6b 65 72 6e 65 6c  |[]).{.   _kernel|
000015f0  5f 73 77 69 5f 72 65 67  73 20 69 6e 2c 20 6f 75  |_swi_regs in, ou|
00001600  74 3b 0a 0a 20 20 20 69  6e 2e 72 5b 31 5d 20 3d  |t;..   in.r[1] =|
00001610  20 28 69 6e 74 29 20 70  6f 6c 6c 62 6c 6f 63 6b  | (int) pollblock|
00001620  3b 0a 20 20 20 5f 6b 65  72 6e 65 6c 5f 73 77 69  |;.   _kernel_swi|
00001630  28 57 69 6d 70 5f 4f 70  65 6e 57 69 6e 64 6f 77  |(Wimp_OpenWindow|
00001640  2c 20 26 69 6e 2c 20 26  6f 75 74 29 3b 0a 20 20  |, &in, &out);.  |
00001650  20 72 65 74 75 72 6e 3b  0a 7d 0a 0a 76 6f 69 64  | return;.}..void|
00001660  20 63 6c 6f 73 65 77 69  6e 64 6f 77 28 75 6e 73  | closewindow(uns|
00001670  69 67 6e 65 64 20 63 68  61 72 20 70 6f 6c 6c 62  |igned char pollb|
00001680  6c 6f 63 6b 5b 5d 29 0a  7b 0a 20 20 20 5f 6b 65  |lock[]).{.   _ke|
00001690  72 6e 65 6c 5f 73 77 69  5f 72 65 67 73 20 69 6e  |rnel_swi_regs in|
000016a0  2c 20 6f 75 74 3b 0a 0a  20 20 20 69 6e 2e 72 5b  |, out;..   in.r[|
000016b0  31 5d 20 3d 20 28 69 6e  74 29 20 70 6f 6c 6c 62  |1] = (int) pollb|
000016c0  6c 6f 63 6b 3b 0a 20 20  20 5f 6b 65 72 6e 65 6c  |lock;.   _kernel|
000016d0  5f 73 77 69 28 57 69 6d  70 5f 43 6c 6f 73 65 57  |_swi(Wimp_CloseW|
000016e0  69 6e 64 6f 77 2c 20 26  69 6e 2c 20 26 6f 75 74  |indow, &in, &out|
000016f0  29 3b 0a 20 20 20 72 65  74 75 72 6e 3b 0a 7d 0a  |);.   return;.}.|
00001700