Home » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199607.adf » Regulars » Wimp_C/!NewWimpC/c/!RunImage » Compare
Compare Wimp_C/!NewWimpC/c/!RunImage with StarInfo/WimpC/!NewWimpC/c/!RunImage
| File: | Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199607.adf » Regulars » Wimp_C/!NewWimpC/c/!RunImage |
| Compared with: | Archimedes archive » Acorn User » AU 1996-06.adf » Regulars » StarInfo/WimpC/!NewWimpC/c/!RunImage |
| Similarity: | 96% of bytes duplicated |
96.4% of the bytes in these files are duplicated between them. Duplicated Different Padding (ignored)
Bytes are marked as duplicated if they lie within a run of at least 16 bytes which also appears somewhere in the other file, in any position. Long runs of padding bytes
(zeros, spaces, &FF and &E5) are ignored.
Wimp_C/!NewWimpC/c/!RunImage
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 6d 61 6b 65 |ogram which make| 00000020 73 20 75 73 65 20 6f 66 20 74 68 65 20 6b 65 72 |s use of the ker| 00000030 6e 65 6c 20 53 57 49 20 63 61 6c 6c 73 20 2d 0a |nel SWI calls -.| 00000040 20 20 20 74 68 69 73 20 77 69 6c 6c 20 63 6f 6d | this will com| 00000050 70 69 6c 65 20 77 69 74 68 20 41 63 6f 72 6e 27 |pile with Acorn'| 00000060 73 20 43 20 61 73 20 77 65 6c 6c 20 61 73 20 42 |s C as well as B| 00000070 65 65 62 75 67 27 73 20 45 61 73 79 43 20 2a 2f |eebug's EasyC */| 00000080 0a 2f 2a 20 62 79 20 53 74 65 76 65 20 4d 75 6d |./* by Steve Mum| 00000090 66 6f 72 64 20 66 6f 72 20 41 63 6f 72 6e 20 55 |ford for Acorn U| 000000a0 73 65 72 20 2d 20 4a 75 6e 65 20 31 39 39 36 20 |ser - June 1996 | 000000b0 2a 2f 0a 0a 23 69 6e 63 6c 75 64 65 20 3c 73 74 |*/..#include <st| 000000c0 64 69 6f 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 |dio.h>.#include | 000000d0 3c 73 74 72 69 6e 67 2e 68 3e 0a 23 69 6e 63 6c |<string.h>.#incl| 000000e0 75 64 65 20 22 41 55 4c 69 62 2e 68 22 0a 0a 2f |ude "AULib.h"../| 000000f0 2a 20 57 65 20 61 6c 73 6f 20 64 65 66 69 6e 65 |* We also define| 00000100 20 61 20 70 6f 6c 6c 20 6d 61 73 6b 20 68 65 72 | a poll mask her| 00000110 65 20 74 6f 20 74 65 6c 6c 20 74 68 65 20 57 49 |e to tell the WI| 00000120 4d 50 20 61 62 6f 75 74 20 61 6e 79 20 65 76 65 |MP about any eve| 00000130 6e 74 73 20 77 65 27 72 65 20 6e 6f 74 0a 20 20 |nts we're not. | 00000140 20 69 6e 74 65 72 65 72 65 73 74 65 64 20 69 6e | intererested in| 00000150 20 2a 2f 0a 0a 23 64 65 66 69 6e 65 20 50 4f 4c | */..#define POL| 00000160 4c 5f 4d 41 53 4b 20 31 0a 23 64 65 66 69 6e 65 |L_MASK 1.#define| 00000170 20 4d 41 58 5f 57 49 4e 44 4f 57 53 20 33 0a 0a | MAX_WINDOWS 3..| 00000180 2f 2a 20 49 66 20 77 65 20 73 65 74 20 51 55 49 |/* If we set QUI| 00000190 54 5f 46 4c 41 47 20 75 70 20 61 73 20 61 20 67 |T_FLAG up as a g| 000001a0 6c 6f 62 61 6c 20 76 61 72 69 61 62 6c 65 2c 20 |lobal variable, | 000001b0 69 74 20 6d 65 61 6e 73 20 74 68 61 74 20 77 65 |it means that we| 000001c0 20 63 61 6e 20 63 68 61 6e 67 65 20 69 74 0a 20 | can change it. | 000001d0 2a 20 61 6e 79 77 68 65 72 65 20 77 69 74 68 69 |* anywhere withi| 000001e0 6e 20 74 68 65 20 70 72 6f 67 72 61 6d 20 61 6e |n the program an| 000001f0 64 20 73 68 75 74 20 74 68 69 6e 67 73 20 64 6f |d shut things do| 00000200 77 6e 20 6e 65 78 74 20 74 69 6d 65 20 77 65 20 |wn next time we | 00000210 65 6e 64 20 74 68 65 0a 20 2a 20 70 6f 6c 6c 69 |end the. * polli| 00000220 6e 67 20 6c 6f 6f 70 20 2a 2f 0a 0a 69 6e 74 20 |ng loop */..int | 00000230 51 55 49 54 5f 46 4c 41 47 20 3d 20 30 3b 0a 69 |QUIT_FLAG = 0;.i| 00000240 6e 74 20 44 49 53 50 4c 41 59 5f 49 43 4f 4e 20 |nt DISPLAY_ICON | 00000250 3d 20 31 3b 0a 63 68 61 72 20 61 70 70 6e 61 6d |= 1;.char appnam| 00000260 65 5b 5d 20 3d 20 22 4e 65 77 20 57 49 4d 50 43 |e[] = "New WIMPC| 00000270 20 45 78 61 6d 70 6c 65 22 3b 0a 77 69 6e 64 6f | Example";.windo| 00000280 77 5f 64 61 74 61 09 77 69 6e 5f 61 72 72 61 79 |w_data.win_array| 00000290 5b 4d 41 58 5f 57 49 4e 44 4f 57 53 5d 3b 0a 6d |[MAX_WINDOWS];.m| 000002a0 65 6e 75 5f 64 61 74 61 09 67 6c 6f 62 6d 65 6e |enu_data.globmen| 000002b0 2c 20 67 6c 6f 62 6d 65 6e 32 3b 0a 0a 2f 2a 20 |, globmen2;../* | 000002c0 46 75 6e 63 74 69 6f 6e 20 70 72 6f 74 6f 74 79 |Function prototy| 000002d0 70 69 6e 67 20 2a 2f 0a 0a 69 6e 74 20 20 20 20 |ping */..int | 000002e0 20 20 6d 61 69 6e 28 76 6f 69 64 29 3b 0a 76 6f | main(void);.vo| 000002f0 69 64 20 20 20 20 20 77 69 6d 70 6d 73 67 28 69 |id wimpmsg(i| 00000300 6e 74 2c 20 75 6e 73 69 67 6e 65 64 20 63 68 61 |nt, unsigned cha| 00000310 72 5b 5d 29 3b 0a 76 6f 69 64 20 20 20 20 20 6d |r[]);.void m| 00000320 6f 75 73 65 63 6c 69 63 6b 28 75 6e 73 69 67 6e |ouseclick(unsign| 00000330 65 64 20 63 68 61 72 5b 5d 29 3b 0a 76 6f 69 64 |ed char[]);.void| 00000340 20 20 20 20 20 6d 65 6e 75 73 65 6c 65 63 74 69 | menuselecti| 00000350 6f 6e 28 75 6e 73 69 67 6e 65 64 20 63 68 61 72 |on(unsigned char| 00000360 5b 5d 29 3b 0a 69 6e 74 20 20 20 20 20 20 6c 6f |[]);.int lo| 00000370 61 64 5f 74 65 6d 70 6c 61 74 65 73 28 76 6f 69 |ad_templates(voi| 00000380 64 29 3b 0a 76 6f 69 64 20 20 20 20 20 6f 70 65 |d);.void ope| 00000390 6e 77 69 6e 64 6f 77 28 75 6e 73 69 67 6e 65 64 |nwindow(unsigned| 000003a0 20 63 68 61 72 5b 5d 29 3b 0a 76 6f 69 64 20 20 | char[]);.void | 000003b0 20 20 20 63 6c 6f 73 65 77 69 6e 64 6f 77 28 75 | closewindow(u| 000003c0 6e 73 69 67 6e 65 64 20 63 68 61 72 5b 5d 29 3b |nsigned char[]);| 000003d0 0a 0a 2f 2a 20 50 72 6f 67 72 61 6d 20 66 75 6e |../* Program fun| 000003e0 63 74 69 6f 6e 73 20 2a 2f 0a 0a 69 6e 74 0a 6d |ctions */..int.m| 000003f0 61 69 6e 28 76 6f 69 64 29 20 7b 0a 09 69 6e 74 |ain(void) {..int| 00000400 20 74 61 73 6b 5f 68 61 6e 64 6c 65 3b 0a 09 75 | task_handle;..u| 00000410 6e 73 69 67 6e 65 64 20 63 68 61 72 20 70 6f 6c |nsigned char pol| 00000420 6c 62 6c 6f 63 6b 5b 32 35 37 5d 3b 20 2f 2a 20 |lblock[257]; /* | 00000430 41 20 62 79 74 65 20 61 72 72 61 79 20 6c 61 72 |A byte array lar| 00000440 67 65 20 65 6e 6f 75 67 68 20 66 6f 72 20 6f 75 |ge enough for ou| 00000450 72 20 70 6f 6c 6c 69 6e 67 20 62 6c 6f 63 6b 20 |r polling block | 00000460 2a 2f 0a 09 69 6e 74 20 69 62 61 72 5f 69 63 6f |*/..int ibar_ico| 00000470 6e 5f 68 61 6e 64 6c 65 3b 20 2f 2a 20 41 20 76 |n_handle; /* A v| 00000480 61 72 69 61 62 6c 65 20 74 6f 20 73 74 6f 72 65 |ariable to store| 00000490 20 6f 75 72 20 69 63 6f 6e 62 61 72 20 69 63 6f | our iconbar ico| 000004a0 6e 20 68 61 6e 64 6c 65 20 2a 2f 0a 09 69 6e 74 |n handle */..int| 000004b0 20 70 6f 6c 6c 72 65 73 75 6c 74 3b 0a 09 69 6e | pollresult;..in| 000004c0 74 20 69 3b 0a 09 6c 6f 6e 67 20 69 6e 74 20 6d |t i;..long int m| 000004d0 73 67 6c 69 73 74 5b 31 5d 20 3d 20 7b 30 7d 3b |sglist[1] = {0};| 000004e0 20 2f 2a 20 53 65 74 20 75 70 20 74 68 65 20 61 | /* Set up the a| 000004f0 63 63 65 70 74 61 62 6c 65 20 6d 65 73 73 61 67 |cceptable messag| 00000500 65 20 6c 69 73 74 20 66 6f 72 20 69 6e 69 74 69 |e list for initi| 00000510 61 6c 69 73 61 74 69 6f 6e 20 2a 2f 0a 0a 09 74 |alisation */...t| 00000520 61 73 6b 5f 68 61 6e 64 6c 65 20 3d 20 61 75 5f |ask_handle = au_| 00000530 69 6e 69 74 69 61 6c 69 73 65 28 33 31 30 2c 20 |initialise(310, | 00000540 61 70 70 6e 61 6d 65 2c 20 6d 73 67 6c 69 73 74 |appname, msglist| 00000550 29 3b 0a 09 2f 2a 20 4e 6f 77 2c 20 77 65 27 6c |);../* Now, we'l| 00000560 6c 20 70 75 74 20 61 6e 20 69 63 6f 6e 20 6f 6e |l put an icon on| 00000570 20 74 68 65 20 69 63 6f 6e 20 62 61 72 20 2a 2f | the icon bar */| 00000580 0a 09 69 62 61 72 5f 69 63 6f 6e 5f 68 61 6e 64 |..ibar_icon_hand| 00000590 6c 65 20 3d 20 61 75 5f 63 72 65 61 74 65 5f 69 |le = au_create_i| 000005a0 63 6f 6e 62 61 72 5f 69 63 6f 6e 28 49 42 41 52 |conbar_icon(IBAR| 000005b0 5f 50 52 49 4f 52 5f 41 50 50 2c 0a 09 09 49 42 |_PRIOR_APP,...IB| 000005c0 41 52 5f 4f 4e 52 49 47 48 54 2c 0a 09 09 49 43 |AR_ONRIGHT,...IC| 000005d0 4f 4e 5f 49 53 53 50 52 49 54 45 20 7c 20 49 43 |ON_ISSPRITE | IC| 000005e0 4f 4e 5f 48 43 45 4e 54 52 45 20 7c 20 49 43 4f |ON_HCENTRE | ICO| 000005f0 4e 5f 56 43 45 4e 54 52 45 20 7c 20 49 43 4f 4e |N_VCENTRE | ICON| 00000600 5f 43 4c 49 43 4b 4e 4f 54 49 46 49 45 53 4f 4e |_CLICKNOTIFIESON| 00000610 43 45 2c 0a 09 09 22 21 6e 65 77 77 69 6d 70 63 |CE,..."!newwimpc| 00000620 22 29 3b 0a 0a 2f 2a 20 4e 6f 77 20 6f 70 65 6e |");../* Now open| 00000630 20 61 20 74 65 6d 70 6c 61 74 65 20 66 69 6c 65 | a template file| 00000640 20 72 65 61 64 79 20 66 6f 72 20 6c 6f 61 64 69 | ready for loadi| 00000650 6e 67 20 2a 2f 0a 0a 09 6c 6f 61 64 5f 74 65 6d |ng */...load_tem| 00000660 70 6c 61 74 65 73 28 29 3b 0a 09 61 75 5f 6f 70 |plates();..au_op| 00000670 65 6e 77 69 6e 5f 66 72 6f 6d 5f 74 65 6d 70 6c |enwin_from_templ| 00000680 61 74 65 64 61 74 61 28 26 77 69 6e 5f 61 72 72 |atedata(&win_arr| 00000690 61 79 5b 30 5d 2c 20 2d 31 29 3b 20 2f 2a 20 4f |ay[0], -1); /* O| 000006a0 70 65 6e 20 66 69 72 73 74 20 77 69 6e 64 6f 77 |pen first window| 000006b0 20 61 74 20 66 72 6f 6e 74 20 28 2d 31 29 20 2a | at front (-1) *| 000006c0 2f 0a 0a 20 20 20 20 77 68 69 6c 65 20 28 51 55 |/.. while (QU| 000006d0 49 54 5f 46 4c 41 47 20 3d 3d 20 30 29 20 7b 0a |IT_FLAG == 0) {.| 000006e0 09 70 6f 6c 6c 72 65 73 75 6c 74 20 3d 20 61 75 |.pollresult = au| 000006f0 5f 77 69 6d 70 5f 70 6f 6c 6c 28 50 4f 4c 4c 5f |_wimp_poll(POLL_| 00000700 4d 41 53 4b 2c 20 70 6f 6c 6c 62 6c 6f 63 6b 29 |MASK, pollblock)| 00000710 3b 0a 20 20 20 20 20 20 20 20 73 77 69 74 63 68 |;. switch| 00000720 20 28 70 6f 6c 6c 72 65 73 75 6c 74 29 20 7b 0a | (pollresult) {.| 00000730 20 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 | case| 00000740 20 20 32 3a 20 6f 70 65 6e 77 69 6e 64 6f 77 28 | 2: openwindow(| 00000750 70 6f 6c 6c 62 6c 6f 63 6b 29 3b 0a 20 20 20 20 |pollblock);. | 00000760 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000770 20 62 72 65 61 6b 3b 0a 20 20 20 20 20 20 20 20 | break;. | 00000780 20 20 20 20 63 61 73 65 20 20 33 3a 20 63 6c 6f | case 3: clo| 00000790 73 65 77 69 6e 64 6f 77 28 70 6f 6c 6c 62 6c 6f |sewindow(pollblo| 000007a0 63 6b 29 3b 0a 20 20 20 20 20 20 20 20 20 20 20 |ck);. | 000007b0 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b | break;| 000007c0 0a 20 20 20 20 20 20 20 20 20 20 20 20 63 61 73 |. cas| 000007d0 65 20 20 36 3a 20 6d 6f 75 73 65 63 6c 69 63 6b |e 6: mouseclick| 000007e0 28 70 6f 6c 6c 62 6c 6f 63 6b 29 3b 0a 20 20 20 |(pollblock);. | 000007f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000800 20 20 62 72 65 61 6b 3b 0a 20 20 20 20 20 20 20 | break;. | 00000810 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a | /*| 00000820 20 49 66 20 6f 75 72 20 69 63 6f 6e 20 69 73 20 | If our icon is | 00000830 63 6c 69 63 6b 65 64 20 6f 6e 2c 20 77 65 20 6a |clicked on, we j| 00000840 75 6d 70 20 74 6f 20 6d 6f 75 73 65 63 6c 69 63 |ump to mouseclic| 00000850 6b 28 29 20 2a 2f 0a 20 20 20 20 20 20 20 20 20 |k() */. | 00000860 20 20 20 63 61 73 65 20 20 39 3a 20 6d 65 6e 75 | case 9: menu| 00000870 73 65 6c 65 63 74 69 6f 6e 28 70 6f 6c 6c 62 6c |selection(pollbl| 00000880 6f 63 6b 29 3b 0a 20 20 20 20 20 20 20 20 20 20 |ock);. | 00000890 20 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b | break| 000008a0 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 63 61 |;. ca| 000008b0 73 65 20 31 37 3a 0a 20 20 20 20 20 20 20 20 20 |se 17:. | 000008c0 20 20 20 63 61 73 65 20 31 38 3a 0a 20 20 20 20 | case 18:. | 000008d0 20 20 20 20 20 20 20 20 63 61 73 65 20 31 39 3a | case 19:| 000008e0 20 77 69 6d 70 6d 73 67 28 70 6f 6c 6c 72 65 73 | wimpmsg(pollres| 000008f0 75 6c 74 2c 20 70 6f 6c 6c 62 6c 6f 63 6b 29 3b |ult, pollblock);| 00000900 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |. | 00000910 20 62 72 65 61 6b 3b 0a 20 20 20 20 20 20 20 20 | break;. | 00000920 20 20 20 20 2f 2a 20 54 68 65 20 61 62 6f 76 65 | /* The above| 00000930 20 73 65 63 74 69 6f 6e 20 6c 69 73 74 65 6e 73 | section listens| 00000940 20 66 6f 72 20 65 76 65 6e 74 20 63 6f 64 65 73 | for event codes| 00000950 20 31 37 2c 20 31 38 20 61 6e 64 20 31 39 20 2d | 17, 18 and 19 -| 00000960 20 74 68 65 0a 20 20 20 20 20 20 20 20 20 20 20 | the. | 00000970 20 20 20 20 6f 6e 65 73 20 77 68 69 63 68 20 69 | ones which i| 00000980 6e 64 69 63 61 74 65 20 77 65 27 72 65 20 62 65 |ndicate we're be| 00000990 69 6e 67 20 73 65 6e 74 20 61 20 6d 65 73 73 61 |ing sent a messa| 000009a0 67 65 20 2a 2f 0a 20 20 20 20 20 20 20 20 7d 0a |ge */. }.| 000009b0 20 20 20 20 7d 0a 20 20 20 20 2f 2a 20 49 66 20 | }. /* If | 000009c0 51 55 49 54 5f 46 4c 41 47 20 63 68 61 6e 67 65 |QUIT_FLAG change| 000009d0 73 20 74 6f 20 61 6e 79 74 68 69 6e 67 20 62 75 |s to anything bu| 000009e0 74 20 30 2c 20 77 65 20 73 74 6f 70 20 67 6f 69 |t 0, we stop goi| 000009f0 6e 67 20 72 6f 75 6e 64 20 74 68 65 20 70 6f 6c |ng round the pol| 00000a00 6c 69 6e 67 0a 20 20 20 20 20 2a 20 6c 6f 6f 70 |ling. * loop| 00000a10 20 61 6e 64 20 73 68 75 74 20 64 6f 77 6e 20 2a | and shut down *| 00000a20 2f 0a 0a 20 20 20 20 61 75 5f 63 6c 6f 73 65 64 |/.. au_closed| 00000a30 6f 77 6e 28 74 61 73 6b 5f 68 61 6e 64 6c 65 29 |own(task_handle)| 00000a40 3b 0a 20 20 20 20 2f 2a 20 4e 65 65 64 20 74 6f |;. /* Need to| 00000a50 20 72 65 6c 65 61 73 65 20 6d 61 6c 6c 6f 63 20 | release malloc | 00000a60 6d 65 6d 6f 72 79 20 66 72 6f 6d 20 77 69 6e 64 |memory from wind| 00000a70 6f 77 20 73 74 72 75 63 74 75 72 65 73 20 2a 2f |ow structures */| 00000a80 0a 09 66 6f 72 28 69 20 3d 20 30 3b 20 69 20 3c |..for(i = 0; i <| 00000a90 20 4d 41 58 5f 57 49 4e 44 4f 57 53 3b 20 69 2b | MAX_WINDOWS; i+| 00000aa0 2b 29 20 7b 0a 09 09 66 72 65 65 28 77 69 6e 5f |+) {...free(win_| 00000ab0 61 72 72 61 79 5b 69 5d 2e 77 69 6e 5f 6e 61 6d |array[i].win_nam| 00000ac0 65 29 3b 0a 09 09 66 72 65 65 28 77 69 6e 5f 61 |e);...free(win_a| 00000ad0 72 72 61 79 5b 69 5d 2e 62 75 66 66 65 72 29 3b |rray[i].buffer);| 00000ae0 0a 09 09 66 72 65 65 28 77 69 6e 5f 61 72 72 61 |...free(win_arra| 00000af0 79 5b 69 5d 2e 77 6f 72 6b 73 70 61 63 65 29 3b |y[i].workspace);| 00000b00 0a 09 7d 0a 7d 0a 0a 76 6f 69 64 0a 77 69 6d 70 |..}.}..void.wimp| 00000b10 6d 73 67 28 69 6e 74 20 72 65 73 75 6c 74 2c 20 |msg(int result, | 00000b20 75 6e 73 69 67 6e 65 64 20 63 68 61 72 20 70 6f |unsigned char po| 00000b30 6c 6c 62 6c 6f 63 6b 5b 5d 29 0a 7b 0a 20 20 20 |llblock[]).{. | 00000b40 20 75 6e 73 69 67 6e 65 64 20 6c 6f 6e 67 20 69 | unsigned long i| 00000b50 6e 74 20 20 20 6d 65 73 73 61 67 65 5f 61 63 74 |nt message_act| 00000b60 69 6f 6e 3b 0a 0a 20 20 20 20 2f 2a 20 54 68 65 |ion;.. /* The| 00000b70 20 6e 65 78 74 20 6c 69 6e 65 20 74 61 6b 65 73 | next line takes| 00000b80 20 62 79 74 65 73 20 31 36 20 74 6f 20 31 39 20 | bytes 16 to 19 | 00000b90 6f 66 20 74 68 65 20 70 6f 6c 6c 69 6e 67 20 62 |of the polling b| 00000ba0 6c 6f 63 6b 20 61 6e 64 20 66 6f 72 6d 73 20 74 |lock and forms t| 00000bb0 68 65 6d 0a 20 20 20 20 20 20 20 69 6e 74 6f 20 |hem. into | 00000bc0 61 20 77 6f 72 64 20 68 6f 6c 64 69 6e 67 20 74 |a word holding t| 00000bd0 68 65 20 6d 65 73 73 61 67 65 20 61 63 74 69 6f |he message actio| 00000be0 6e 20 6e 75 6d 62 65 72 20 2a 2f 0a 20 20 20 20 |n number */. | 00000bf0 6d 65 73 73 61 67 65 5f 61 63 74 69 6f 6e 20 3d |message_action =| 00000c00 20 61 75 5f 62 79 74 65 74 6f 77 6f 72 64 28 70 | au_bytetoword(p| 00000c10 6f 6c 6c 62 6c 6f 63 6b 2c 20 31 36 29 3b 0a 20 |ollblock, 16);. | 00000c20 20 20 20 0a 20 20 20 20 73 77 69 74 63 68 20 28 | . switch (| 00000c30 6d 65 73 73 61 67 65 5f 61 63 74 69 6f 6e 29 20 |message_action) | 00000c40 7b 0a 20 20 20 20 20 20 20 20 63 61 73 65 20 30 |{. case 0| 00000c50 3a 20 51 55 49 54 5f 46 4c 41 47 20 3d 20 31 3b |: QUIT_FLAG = 1;| 00000c60 20 2f 2a 20 4d 65 73 73 61 67 65 5f 51 75 69 74 | /* Message_Quit| 00000c70 20 2d 20 74 69 6d 65 20 74 6f 20 67 6f 20 2a 2f | - time to go */| 00000c80 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |. | 00000c90 20 62 72 65 61 6b 3b 0a 20 20 20 20 20 20 20 20 | break;. | 00000ca0 63 61 73 65 20 30 78 34 30 30 63 32 3a 20 61 75 |case 0x400c2: au| 00000cb0 5f 69 63 6f 6e 5f 74 65 78 74 5f 63 68 61 6e 67 |_icon_text_chang| 00000cc0 65 28 28 63 68 61 72 20 2a 29 20 26 70 6f 6c 6c |e((char *) &poll| 00000cd0 62 6c 6f 63 6b 5b 32 38 5d 2c 20 77 69 6e 5f 61 |block[28], win_a| 00000ce0 72 72 61 79 5b 30 5d 2e 77 69 6e 5f 68 61 6e 64 |rray[0].win_hand| 00000cf0 6c 65 2c 20 44 49 53 50 4c 41 59 5f 49 43 4f 4e |le, DISPLAY_ICON| 00000d00 29 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 |);. | 00000d10 20 20 20 62 72 65 61 6b 3b 20 20 20 20 20 20 20 | break; | 00000d20 20 0a 20 20 20 20 20 20 20 20 2f 2a 20 4d 6f 72 | . /* Mor| 00000d30 65 20 6d 65 73 73 61 67 65 20 61 63 74 69 6f 6e |e message action| 00000d40 73 20 63 61 6e 20 62 65 20 61 64 64 65 64 20 68 |s can be added h| 00000d50 65 72 65 20 2a 2f 0a 20 20 20 20 7d 0a 7d 0a 0a |ere */. }.}..| 00000d60 76 6f 69 64 0a 6d 65 6e 75 73 65 6c 65 63 74 69 |void.menuselecti| 00000d70 6f 6e 28 75 6e 73 69 67 6e 65 64 20 63 68 61 72 |on(unsigned char| 00000d80 20 62 6c 6f 63 6b 5b 5d 29 0a 7b 0a 20 20 20 2f | block[]).{. /| 00000d90 2a 20 57 65 20 77 6f 75 6c 64 20 63 68 65 63 6b |* We would check| 00000da0 20 77 68 69 63 68 20 6d 65 6e 75 20 77 61 73 20 | which menu was | 00000db0 61 63 74 69 76 65 20 65 74 63 2e 20 68 65 72 65 |active etc. here| 00000dc0 20 2a 2f 0a 20 20 20 0a 20 20 20 69 66 28 61 75 | */. . if(au| 00000dd0 5f 62 79 74 65 74 6f 77 6f 72 64 28 62 6c 6f 63 |_bytetoword(bloc| 00000de0 6b 2c 20 30 29 20 3d 3d 20 31 29 20 7b 0a 20 20 |k, 0) == 1) {. | 00000df0 20 20 20 20 20 2f 2a 20 54 68 69 73 20 69 73 20 | /* This is | 00000e00 74 68 65 20 27 71 75 69 74 27 20 65 6e 74 72 79 |the 'quit' entry| 00000e10 20 2a 2f 0a 20 20 20 20 20 20 20 51 55 49 54 5f | */. QUIT_| 00000e20 46 4c 41 47 20 3d 20 31 3b 0a 20 20 20 7d 0a 20 |FLAG = 1;. }. | 00000e30 20 20 72 65 74 75 72 6e 3b 0a 7d 0a 0a 76 6f 69 | return;.}..voi| 00000e40 64 0a 6d 6f 75 73 65 63 6c 69 63 6b 28 75 6e 73 |d.mouseclick(uns| 00000e50 69 67 6e 65 64 20 63 68 61 72 20 70 6f 6c 6c 62 |igned char pollb| 00000e60 6c 6f 63 6b 5b 5d 29 0a 7b 0a 20 20 20 63 68 61 |lock[]).{. cha| 00000e70 72 20 6d 65 73 73 61 67 65 5b 32 35 35 5d 3b 0a |r message[255];.| 00000e80 20 20 20 2f 2a 20 41 20 62 75 66 66 65 72 20 74 | /* A buffer t| 00000e90 6f 20 68 6f 6c 64 20 61 6e 20 27 65 72 72 6f 72 |o hold an 'error| 00000ea0 27 20 6d 65 73 73 61 67 65 20 2a 2f 0a 0a 20 20 |' message */.. | 00000eb0 20 69 6e 74 20 63 6c 6b 3b 0a 20 20 20 5f 6b 65 | int clk;. _ke| 00000ec0 72 6e 65 6c 5f 73 77 69 5f 72 65 67 73 20 69 6e |rnel_swi_regs in| 00000ed0 2c 20 6f 75 74 3b 0a 20 20 20 75 6e 73 69 67 6e |, out;. unsign| 00000ee0 65 64 20 63 68 61 72 20 74 65 6d 70 5f 62 75 66 |ed char temp_buf| 00000ef0 66 65 72 5b 32 35 35 5d 3b 0a 0a 20 20 20 2f 2a |fer[255];.. /*| 00000f00 20 44 65 74 65 72 6d 69 6e 65 20 77 68 69 63 68 | Determine which| 00000f10 20 62 75 74 74 6f 6e 20 77 61 73 20 70 72 65 73 | button was pres| 00000f20 73 65 64 20 2a 2f 0a 20 20 20 63 6c 6b 20 3d 20 |sed */. clk = | 00000f30 28 69 6e 74 29 20 61 75 5f 62 79 74 65 74 6f 77 |(int) au_bytetow| 00000f40 6f 72 64 28 70 6f 6c 6c 62 6c 6f 63 6b 2c 20 38 |ord(pollblock, 8| 00000f50 29 3b 0a 0a 20 20 20 2f 2a 20 49 66 20 74 68 65 |);.. /* If the| 00000f60 20 27 53 65 6c 65 63 74 27 20 62 75 74 74 6f 6e | 'Select' button| 00000f70 20 77 61 73 20 63 6c 69 63 6b 65 64 20 6f 6e 20 | was clicked on | 00000f80 74 68 65 20 69 63 6f 6e 20 62 61 72 20 28 70 6f |the icon bar (po| 00000f90 6c 6c 62 6c 6f 63 6b 20 2b 20 31 32 20 3d 20 2d |llblock + 12 = -| 00000fa0 32 29 0a 20 20 20 20 20 20 74 68 65 6e 20 72 65 |2). then re| 00000fb0 2d 6f 70 65 6e 20 6d 61 69 6e 20 77 69 6e 64 6f |-open main windo| 00000fc0 77 20 61 6e 64 20 72 65 74 75 72 6e 20 2a 2f 0a |w and return */.| 00000fd0 0a 20 20 20 69 66 28 28 61 75 5f 62 79 74 65 74 |. if((au_bytet| 00000fe0 6f 77 6f 72 64 28 70 6f 6c 6c 62 6c 6f 63 6b 2c |oword(pollblock,| 00000ff0 20 31 32 29 20 3d 3d 20 2d 32 29 20 26 26 20 28 | 12) == -2) && (| 00001000 63 6c 6b 20 3d 3d 20 34 29 29 20 7b 0a 20 20 20 |clk == 4)) {. | 00001010 20 20 20 61 75 5f 77 6f 72 64 74 6f 62 79 74 65 | au_wordtobyte| 00001020 28 77 69 6e 5f 61 72 72 61 79 5b 30 5d 2e 77 69 |(win_array[0].wi| 00001030 6e 5f 68 61 6e 64 6c 65 2c 20 74 65 6d 70 5f 62 |n_handle, temp_b| 00001040 75 66 66 65 72 2c 20 30 29 3b 0a 20 20 20 20 20 |uffer, 0);. | 00001050 20 69 6e 2e 72 5b 31 5d 20 3d 20 28 69 6e 74 29 | in.r[1] = (int)| 00001060 20 74 65 6d 70 5f 62 75 66 66 65 72 3b 0a 20 20 | temp_buffer;. | 00001070 20 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 28 | _kernel_swi(| 00001080 57 69 6d 70 5f 47 65 74 57 69 6e 64 6f 77 49 6e |Wimp_GetWindowIn| 00001090 66 6f 2c 20 26 69 6e 2c 20 26 6f 75 74 29 3b 0a |fo, &in, &out);.| 000010a0 20 20 20 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 77 | _kernel_sw| 000010b0 69 28 57 69 6d 70 5f 4f 70 65 6e 57 69 6e 64 6f |i(Wimp_OpenWindo| 000010c0 77 2c 20 26 69 6e 2c 20 26 6f 75 74 29 3b 0a 20 |w, &in, &out);. | 000010d0 20 20 20 20 20 72 65 74 75 72 6e 3b 0a 20 20 20 | return;. | 000010e0 7d 0a 0a 20 20 20 69 66 28 28 61 75 5f 62 79 74 |}.. if((au_byt| 000010f0 65 74 6f 77 6f 72 64 28 70 6f 6c 6c 62 6c 6f 63 |etoword(pollbloc| 00001100 6b 2c 20 31 32 29 20 3d 3d 20 2d 32 29 20 26 26 |k, 12) == -2) &&| 00001110 20 28 63 6c 6b 20 3d 3d 20 32 29 29 20 7b 0a 20 | (clk == 2)) {. | 00001120 20 20 20 20 20 2f 2a 20 27 4d 65 6e 75 27 20 68 | /* 'Menu' h| 00001130 61 73 20 62 65 65 6e 20 63 6c 69 63 6b 65 64 20 |as been clicked | 00001140 6f 6e 20 74 68 65 20 69 63 6f 6e 20 62 61 72 20 |on the icon bar | 00001150 69 63 6f 6e 20 2d 20 6e 6f 77 20 77 65 20 70 72 |icon - now we pr| 00001160 6f 64 75 63 65 0a 20 20 20 20 20 20 20 20 20 61 |oduce. a| 00001170 20 6d 65 6e 75 20 2a 2f 0a 09 61 75 5f 62 75 69 | menu */..au_bui| 00001180 6c 64 6d 65 6e 75 28 22 53 75 62 6d 65 6e 75 22 |ldmenu("Submenu"| 00001190 2c 20 26 67 6c 6f 62 6d 65 6e 32 29 3b 0a 09 61 |, &globmen2);..a| 000011a0 75 5f 61 64 64 74 6f 6d 65 6e 75 28 22 45 6e 74 |u_addtomenu("Ent| 000011b0 72 79 22 2c 20 4d 45 4e 55 5f 4c 41 53 54 49 54 |ry", MENU_LASTIT| 000011c0 45 4d 2c 20 2d 31 2c 20 30 2c 20 26 67 6c 6f 62 |EM, -1, 0, &glob| 000011d0 6d 65 6e 32 29 3b 0a 09 61 75 5f 63 72 65 61 74 |men2);..au_creat| 000011e0 65 6d 65 6e 75 28 26 67 6c 6f 62 6d 65 6e 32 29 |emenu(&globmen2)| 000011f0 3b 0a 0a 09 61 75 5f 62 75 69 6c 64 6d 65 6e 75 |;...au_buildmenu| 00001200 28 22 54 65 73 74 20 6d 65 6e 75 22 2c 20 26 67 |("Test menu", &g| 00001210 6c 6f 62 6d 65 6e 29 3b 0a 09 61 75 5f 61 64 64 |lobmen);..au_add| 00001220 74 6f 6d 65 6e 75 28 22 45 6e 74 72 79 20 31 22 |tomenu("Entry 1"| 00001230 2c 20 4d 45 4e 55 5f 54 49 43 4b 20 7c 20 4d 45 |, MENU_TICK | ME| 00001240 4e 55 5f 44 4f 54 54 45 44 2c 20 28 69 6e 74 29 |NU_DOTTED, (int)| 00001250 20 67 6c 6f 62 6d 65 6e 32 2e 64 61 74 61 62 6c | globmen2.databl| 00001260 6f 63 6b 2c 20 30 2c 20 26 67 6c 6f 62 6d 65 6e |ock, 0, &globmen| 00001270 29 3b 0a 09 61 75 5f 61 64 64 74 6f 6d 65 6e 75 |);..au_addtomenu| 00001280 28 22 51 75 69 74 22 2c 20 4d 45 4e 55 5f 4c 41 |("Quit", MENU_LA| 00001290 53 54 49 54 45 4d 2c 20 2d 31 2c 20 30 2c 20 26 |STITEM, -1, 0, &| 000012a0 67 6c 6f 62 6d 65 6e 29 3b 0a 09 61 75 5f 63 72 |globmen);..au_cr| 000012b0 65 61 74 65 6d 65 6e 75 28 26 67 6c 6f 62 6d 65 |eatemenu(&globme| 000012c0 6e 29 3b 0a 09 61 75 5f 6f 70 65 6e 6d 65 6e 75 |n);..au_openmenu| 000012d0 28 26 67 6c 6f 62 6d 65 6e 2c 20 28 69 6e 74 29 |(&globmen, (int)| 000012e0 20 61 75 5f 62 79 74 65 74 6f 77 6f 72 64 28 70 | au_bytetoword(p| 000012f0 6f 6c 6c 62 6c 6f 63 6b 2c 20 30 29 20 2d 20 36 |ollblock, 0) - 6| 00001300 34 2c 20 28 34 34 2a 32 29 2b 39 36 29 3b 0a 09 |4, (44*2)+96);..| 00001310 72 65 74 75 72 6e 3b 0a 20 20 20 7d 0a 0a 20 20 |return;. }.. | 00001320 20 73 74 72 63 70 79 28 6d 65 73 73 61 67 65 2c | strcpy(message,| 00001330 20 22 4d 6f 75 73 65 20 63 6c 69 63 6b 20 64 65 | "Mouse click de| 00001340 74 65 63 74 65 64 20 28 74 79 70 65 22 29 3b 0a |tected (type");.| 00001350 20 20 20 73 70 72 69 6e 74 66 28 6d 65 73 73 61 | sprintf(messa| 00001360 67 65 2c 20 22 25 73 20 25 64 29 20 2d 20 64 6f |ge, "%s %d) - do| 00001370 20 79 6f 75 20 77 69 73 68 20 74 6f 20 73 74 6f | you wish to sto| 00001380 70 20 74 68 65 20 70 72 6f 67 72 61 6d 3f 22 2c |p the program?",| 00001390 20 6d 65 73 73 61 67 65 2c 20 63 6c 6b 29 3b 0a | message, clk);.| 000013a0 20 20 20 69 66 28 61 75 5f 72 65 70 6f 72 74 5f | if(au_report_| 000013b0 65 72 72 6f 72 28 31 2c 20 6d 65 73 73 61 67 65 |error(1, message| 000013c0 2c 20 33 2c 20 61 70 70 6e 61 6d 65 29 20 3d 3d |, 3, appname) ==| 000013d0 20 31 29 20 51 55 49 54 5f 46 4c 41 47 20 3d 20 | 1) QUIT_FLAG = | 000013e0 31 3b 0a 7d 0a 0a 69 6e 74 0a 6c 6f 61 64 5f 74 |1;.}..int.load_t| 000013f0 65 6d 70 6c 61 74 65 73 28 76 6f 69 64 29 0a 7b |emplates(void).{| 00001400 0a 09 61 75 5f 6f 70 65 6e 74 65 6d 70 6c 61 74 |..au_opentemplat| 00001410 65 28 22 3c 57 69 6d 70 43 24 44 69 72 3e 2e 54 |e("<WimpC$Dir>.T| 00001420 65 6d 70 6c 61 74 65 73 22 29 3b 0a 09 69 66 28 |emplates");..if(| 00001430 61 75 5f 6c 6f 61 64 74 65 6d 70 6c 61 74 65 28 |au_loadtemplate(| 00001440 22 4d 61 69 6e 57 69 6e 64 6f 77 22 2c 20 26 77 |"MainWindow", &w| 00001450 69 6e 5f 61 72 72 61 79 5b 30 5d 2c 20 30 29 20 |in_array[0], 0) | 00001460 3d 3d 20 30 29 20 7b 0a 09 09 61 75 5f 72 65 70 |== 0) {...au_rep| 00001470 6f 72 74 5f 65 72 72 6f 72 28 31 2c 20 22 54 65 |ort_error(1, "Te| 00001480 6d 70 6c 61 74 65 20 6e 6f 74 20 66 6f 75 6e 64 |mplate not found| 00001490 21 22 2c 20 31 2c 20 61 70 70 6e 61 6d 65 29 3b |!", 1, appname);| 000014a0 0a 09 09 51 55 49 54 5f 46 4c 41 47 20 3d 20 31 |...QUIT_FLAG = 1| 000014b0 3b 0a 09 7d 0a 09 2f 2a 20 4e 6f 77 20 77 65 27 |;..}../* Now we'| 000014c0 76 65 20 66 69 6e 69 73 68 65 64 20 72 65 61 64 |ve finished read| 000014d0 69 6e 67 20 74 68 65 20 74 65 6d 70 6c 61 74 65 |ing the template| 000014e0 73 2c 20 63 6c 6f 73 65 20 74 68 65 20 66 69 6c |s, close the fil| 000014f0 65 20 2a 2f 0a 09 61 75 5f 63 6c 6f 73 65 74 65 |e */..au_closete| 00001500 6d 70 6c 61 74 65 28 29 3b 0a 09 72 65 74 75 72 |mplate();..retur| 00001510 6e 20 30 3b 0a 7d 0a 0a 76 6f 69 64 20 6f 70 65 |n 0;.}..void ope| 00001520 6e 77 69 6e 64 6f 77 28 75 6e 73 69 67 6e 65 64 |nwindow(unsigned| 00001530 20 63 68 61 72 20 70 6f 6c 6c 62 6c 6f 63 6b 5b | char pollblock[| 00001540 5d 29 0a 7b 0a 20 20 20 5f 6b 65 72 6e 65 6c 5f |]).{. _kernel_| 00001550 73 77 69 5f 72 65 67 73 20 69 6e 2c 20 6f 75 74 |swi_regs in, out| 00001560 3b 0a 0a 20 20 20 69 6e 2e 72 5b 31 5d 20 3d 20 |;.. in.r[1] = | 00001570 28 69 6e 74 29 20 70 6f 6c 6c 62 6c 6f 63 6b 3b |(int) pollblock;| 00001580 0a 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 28 |. _kernel_swi(| 00001590 57 69 6d 70 5f 4f 70 65 6e 57 69 6e 64 6f 77 2c |Wimp_OpenWindow,| 000015a0 20 26 69 6e 2c 20 26 6f 75 74 29 3b 0a 20 20 20 | &in, &out);. | 000015b0 72 65 74 75 72 6e 3b 0a 7d 0a 0a 76 6f 69 64 20 |return;.}..void | 000015c0 63 6c 6f 73 65 77 69 6e 64 6f 77 28 75 6e 73 69 |closewindow(unsi| 000015d0 67 6e 65 64 20 63 68 61 72 20 70 6f 6c 6c 62 6c |gned char pollbl| 000015e0 6f 63 6b 5b 5d 29 0a 7b 0a 20 20 20 5f 6b 65 72 |ock[]).{. _ker| 000015f0 6e 65 6c 5f 73 77 69 5f 72 65 67 73 20 69 6e 2c |nel_swi_regs in,| 00001600 20 6f 75 74 3b 0a 0a 20 20 20 69 6e 2e 72 5b 31 | out;.. in.r[1| 00001610 5d 20 3d 20 28 69 6e 74 29 20 70 6f 6c 6c 62 6c |] = (int) pollbl| 00001620 6f 63 6b 3b 0a 20 20 20 5f 6b 65 72 6e 65 6c 5f |ock;. _kernel_| 00001630 73 77 69 28 57 69 6d 70 5f 43 6c 6f 73 65 57 69 |swi(Wimp_CloseWi| 00001640 6e 64 6f 77 2c 20 26 69 6e 2c 20 26 6f 75 74 29 |ndow, &in, &out)| 00001650 3b 0a 20 20 20 72 65 74 75 72 6e 3b 0a 7d 0a |;. return;.}.| 0000165f
StarInfo/WimpC/!NewWimpC/c/!RunImage
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
.