Home » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199604.adf » Features » Wimp/!WimpC/c/!RunImage » Compare
Compare Wimp/!WimpC/c/!RunImage with C/!WimpC/c/!RunImage
| File: | Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199604.adf » Features » Wimp/!WimpC/c/!RunImage |
| Compared with: | Archimedes archive » Acorn User » AU 1996-05.adf » Features » C/!WimpC/c/!RunImage |
| Similarity: | 95% of bytes duplicated |
95.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/!WimpC/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 41 70 72 69 6c 20 31 39 39 36 |ser - April 1996| 000000b0 20 2a 2f 0a 0a 23 69 6e 63 6c 75 64 65 20 3c 73 | */..#include <s| 000000c0 74 64 69 6f 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 |tdio.h>.#include| 000000d0 20 3c 73 74 72 69 6e 67 2e 68 3e 0a 23 69 6e 63 | <string.h>.#inc| 000000e0 6c 75 64 65 20 22 73 77 69 73 2e 68 22 0a 23 69 |lude "swis.h".#i| 000000f0 6e 63 6c 75 64 65 20 22 6b 65 72 6e 65 6c 2e 68 |nclude "kernel.h| 00000100 22 0a 0a 2f 2a 20 57 65 20 61 6c 73 6f 20 64 65 |"../* We also de| 00000110 66 69 6e 65 20 61 20 70 6f 6c 6c 20 6d 61 73 6b |fine a poll mask| 00000120 20 68 65 72 65 20 74 6f 20 74 65 6c 6c 20 74 68 | here to tell th| 00000130 65 20 57 49 4d 50 20 61 62 6f 75 74 20 61 6e 79 |e WIMP about any| 00000140 20 65 76 65 6e 74 73 20 77 65 27 72 65 20 6e 6f | events we're no| 00000150 74 0a 20 20 20 69 6e 74 65 72 65 72 65 73 74 65 |t. interereste| 00000160 64 20 69 6e 20 2a 2f 0a 0a 23 64 65 66 69 6e 65 |d in */..#define| 00000170 20 50 4f 4c 4c 5f 4d 41 53 4b 20 31 0a 23 64 65 | POLL_MASK 1.#de| 00000180 66 69 6e 65 20 57 4f 52 4b 53 50 41 43 45 5f 53 |fine WORKSPACE_S| 00000190 49 5a 45 20 31 30 32 34 0a 0a 2f 2a 20 49 66 20 |IZE 1024../* If | 000001a0 77 65 20 73 65 74 20 51 55 49 54 5f 46 4c 41 47 |we set QUIT_FLAG| 000001b0 20 75 70 20 61 73 20 61 20 67 6c 6f 62 61 6c 20 | up as a global | 000001c0 76 61 72 69 61 62 6c 65 2c 20 69 74 20 6d 65 61 |variable, it mea| 000001d0 6e 73 20 74 68 61 74 20 77 65 20 63 61 6e 20 63 |ns that we can c| 000001e0 68 61 6e 67 65 20 69 74 0a 20 20 20 61 6e 79 77 |hange it. anyw| 000001f0 68 65 72 65 20 77 69 74 68 69 6e 20 74 68 65 20 |here within the | 00000200 70 72 6f 67 72 61 6d 20 61 6e 64 20 73 68 75 74 |program and shut| 00000210 20 74 68 69 6e 67 73 20 64 6f 77 6e 20 6e 65 78 | things down nex| 00000220 74 20 74 69 6d 65 20 77 65 20 65 6e 64 20 74 68 |t time we end th| 00000230 65 0a 20 20 20 70 6f 6c 6c 69 6e 67 20 6c 6f 6f |e. polling loo| 00000240 70 20 2a 2f 0a 0a 69 6e 74 20 51 55 49 54 5f 46 |p */..int QUIT_F| 00000250 4c 41 47 20 3d 20 30 3b 0a 69 6e 74 20 4d 41 49 |LAG = 0;.int MAI| 00000260 4e 57 49 4e 5f 48 41 4e 44 4c 45 20 3d 20 30 3b |NWIN_HANDLE = 0;| 00000270 0a 69 6e 74 20 44 49 53 50 4c 41 59 5f 49 43 4f |.int DISPLAY_ICO| 00000280 4e 20 3d 20 31 3b 0a 63 68 61 72 20 61 70 70 6e |N = 1;.char appn| 00000290 61 6d 65 5b 5d 20 3d 20 22 57 49 4d 50 43 20 45 |ame[] = "WIMPC E| 000002a0 78 61 6d 70 6c 65 22 3b 0a 75 6e 73 69 67 6e 65 |xample";.unsigne| 000002b0 64 20 63 68 61 72 20 6d 61 69 6e 77 69 6e 5f 62 |d char mainwin_b| 000002c0 75 66 66 65 72 5b 57 4f 52 4b 53 50 41 43 45 5f |uffer[WORKSPACE_| 000002d0 53 49 5a 45 5d 3b 0a 75 6e 73 69 67 6e 65 64 20 |SIZE];.unsigned | 000002e0 63 68 61 72 20 6d 61 69 6e 77 69 6e 5f 77 6f 72 |char mainwin_wor| 000002f0 6b 73 70 61 63 65 5b 57 4f 52 4b 53 50 41 43 45 |kspace[WORKSPACE| 00000300 5f 53 49 5a 45 5d 3b 0a 0a 2f 2a 20 46 75 6e 63 |_SIZE];../* Func| 00000310 74 69 6f 6e 20 70 72 6f 74 6f 74 79 70 69 6e 67 |tion prototyping| 00000320 20 2a 2f 0a 0a 69 6e 74 20 20 20 20 20 20 6d 61 | */..int ma| 00000330 69 6e 28 76 6f 69 64 29 3b 0a 76 6f 69 64 20 20 |in(void);.void | 00000340 20 20 20 77 69 6d 70 6d 73 67 28 69 6e 74 2c 20 | wimpmsg(int, | 00000350 75 6e 73 69 67 6e 65 64 20 63 68 61 72 5b 5d 29 |unsigned char[])| 00000360 3b 0a 75 6e 73 69 67 6e 65 64 20 6c 6f 6e 67 20 |;.unsigned long | 00000370 69 6e 74 20 20 20 62 74 6f 77 28 75 6e 73 69 67 |int btow(unsig| 00000380 6e 65 64 20 63 68 61 72 5b 5d 2c 20 69 6e 74 29 |ned char[], int)| 00000390 3b 0a 76 6f 69 64 20 20 20 20 20 77 74 6f 62 28 |;.void wtob(| 000003a0 75 6e 73 69 67 6e 65 64 20 6c 6f 6e 67 20 69 6e |unsigned long in| 000003b0 74 2c 20 75 6e 73 69 67 6e 65 64 20 63 68 61 72 |t, unsigned char| 000003c0 5b 5d 2c 20 69 6e 74 29 3b 0a 76 6f 69 64 20 20 |[], int);.void | 000003d0 20 20 20 6d 6f 75 73 65 63 6c 69 63 6b 28 75 6e | mouseclick(un| 000003e0 73 69 67 6e 65 64 20 63 68 61 72 5b 5d 29 3b 0a |signed char[]);.| 000003f0 69 6e 74 20 20 20 20 20 20 72 65 70 6f 72 74 5f |int report_| 00000400 65 72 72 6f 72 28 69 6e 74 2c 20 63 68 61 72 5b |error(int, char[| 00000410 5d 2c 20 69 6e 74 29 3b 0a 69 6e 74 20 20 20 20 |], int);.int | 00000420 20 20 6c 6f 61 64 5f 74 65 6d 70 6c 61 74 65 73 | load_templates| 00000430 28 76 6f 69 64 29 3b 0a 76 6f 69 64 20 20 20 20 |(void);.void | 00000440 20 6f 70 65 6e 77 69 6e 64 6f 77 28 75 6e 73 69 | openwindow(unsi| 00000450 67 6e 65 64 20 63 68 61 72 5b 5d 29 3b 0a 76 6f |gned char[]);.vo| 00000460 69 64 20 20 20 20 20 63 6c 6f 73 65 77 69 6e 64 |id closewind| 00000470 6f 77 28 75 6e 73 69 67 6e 65 64 20 63 68 61 72 |ow(unsigned char| 00000480 5b 5d 29 3b 0a 63 68 61 72 20 2a 20 20 20 67 65 |[]);.char * ge| 00000490 74 69 63 6f 6e 74 65 78 74 70 6f 69 6e 74 65 72 |ticontextpointer| 000004a0 28 75 6e 73 69 67 6e 65 64 20 6c 6f 6e 67 20 69 |(unsigned long i| 000004b0 6e 74 2c 20 75 6e 73 69 67 6e 65 64 20 6c 6f 6e |nt, unsigned lon| 000004c0 67 20 69 6e 74 29 3b 0a 76 6f 69 64 20 20 20 20 |g int);.void | 000004d0 20 69 63 6f 6e 63 68 61 6e 67 65 28 63 68 61 72 | iconchange(char| 000004e0 20 2a 2c 20 75 6e 73 69 67 6e 65 64 20 6c 6f 6e | *, unsigned lon| 000004f0 67 20 69 6e 74 2c 20 75 6e 73 69 67 6e 65 64 20 |g int, unsigned | 00000500 6c 6f 6e 67 20 69 6e 74 29 3b 0a 2f 2a 20 50 72 |long int);./* Pr| 00000510 6f 67 72 61 6d 20 66 75 6e 63 74 69 6f 6e 73 20 |ogram functions | 00000520 2a 2f 0a 0a 69 6e 74 0a 6d 61 69 6e 28 76 6f 69 |*/..int.main(voi| 00000530 64 29 20 7b 0a 20 20 20 20 69 6e 74 20 74 61 73 |d) {. int tas| 00000540 6b 5f 68 61 6e 64 6c 65 3b 0a 20 20 20 20 75 6e |k_handle;. un| 00000550 73 69 67 6e 65 64 20 63 68 61 72 20 20 20 70 6f |signed char po| 00000560 6c 6c 62 6c 6f 63 6b 5b 32 35 37 5d 3b 0a 20 20 |llblock[257];. | 00000570 20 20 2f 2a 20 65 73 73 65 6e 74 69 61 6c 6c 79 | /* essentially| 00000580 20 61 20 62 79 74 65 20 61 72 72 61 79 20 6c 61 | a byte array la| 00000590 72 67 65 20 65 6e 6f 75 67 68 20 66 6f 72 20 6f |rge enough for o| 000005a0 75 72 20 70 6f 6c 6c 69 6e 67 20 62 6c 6f 63 6b |ur polling block| 000005b0 20 2a 2f 0a 0a 20 20 20 20 75 6e 73 69 67 6e 65 | */.. unsigne| 000005c0 64 20 63 68 61 72 20 20 69 63 6f 6e 62 6c 6f 63 |d char iconbloc| 000005d0 6b 5b 34 30 5d 3b 0a 20 20 20 20 69 6e 74 20 69 |k[40];. int i| 000005e0 62 61 72 5f 69 63 6f 6e 5f 68 61 6e 64 6c 65 3b |bar_icon_handle;| 000005f0 0a 20 20 20 20 2f 2a 20 41 20 62 6c 6f 63 6b 20 |. /* A block | 00000600 74 6f 20 68 6f 6c 64 20 6f 75 72 20 69 63 6f 6e |to hold our icon| 00000610 20 64 61 74 61 2c 20 61 6e 64 20 61 20 76 61 72 | data, and a var| 00000620 69 61 62 6c 65 20 74 6f 20 73 74 6f 72 65 20 69 |iable to store i| 00000630 74 73 20 68 61 6e 64 6c 65 20 2a 2f 0a 0a 20 20 |ts handle */.. | 00000640 20 20 69 6e 74 20 70 6f 6c 6c 72 65 73 75 6c 74 | int pollresult| 00000650 3b 0a 20 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 77 |;. _kernel_sw| 00000660 69 5f 72 65 67 73 20 20 20 20 72 65 67 73 5f 69 |i_regs regs_i| 00000670 6e 2c 20 72 65 67 73 5f 6f 75 74 3b 0a 20 20 20 |n, regs_out;. | 00000680 20 63 68 61 72 20 69 62 61 72 5f 73 70 72 6e 61 | char ibar_sprna| 00000690 6d 65 5b 5d 20 3d 20 22 21 77 69 6d 70 63 22 3b |me[] = "!wimpc";| 000006a0 0a 0a 20 20 20 20 2f 2a 20 54 68 65 20 61 62 6f |.. /* The abo| 000006b0 76 65 20 6c 69 6e 65 20 73 70 65 63 69 66 69 65 |ve line specifie| 000006c0 73 20 74 68 65 20 6e 61 6d 65 20 6f 66 20 74 68 |s the name of th| 000006d0 65 20 73 70 72 69 74 65 20 69 6e 20 74 68 65 20 |e sprite in the | 000006e0 77 69 6d 70 20 70 6f 6f 6c 20 74 68 61 74 0a 20 |wimp pool that. | 000006f0 20 20 20 20 20 20 77 65 20 61 72 65 20 74 6f 20 | we are to | 00000700 75 73 65 20 6f 6e 20 74 68 65 20 69 63 6f 6e 20 |use on the icon | 00000710 62 61 72 20 2a 2f 0a 0a 20 20 20 20 6c 6f 6e 67 |bar */.. long| 00000720 20 69 6e 74 20 20 20 20 6d 73 67 6c 69 73 74 5b | int msglist[| 00000730 31 5d 20 3d 20 7b 30 7d 3b 0a 0a 20 20 20 20 2f |1] = {0};.. /| 00000740 2a 20 4e 6f 77 20 74 6f 20 69 6e 69 74 69 61 6c |* Now to initial| 00000750 69 73 65 20 6f 75 72 73 65 6c 76 65 73 20 61 73 |ise ourselves as| 00000760 20 61 20 74 61 73 6b 20 2a 2f 0a 20 20 20 20 72 | a task */. r| 00000770 65 67 73 5f 69 6e 2e 72 5b 30 5d 20 3d 20 33 31 |egs_in.r[0] = 31| 00000780 30 3b 0a 20 20 20 20 72 65 67 73 5f 69 6e 2e 72 |0;. regs_in.r| 00000790 5b 31 5d 20 3d 20 2a 28 69 6e 74 20 2a 29 22 54 |[1] = *(int *)"T| 000007a0 41 53 4b 22 3b 0a 20 20 20 20 72 65 67 73 5f 69 |ASK";. regs_i| 000007b0 6e 2e 72 5b 32 5d 20 3d 20 28 69 6e 74 29 20 61 |n.r[2] = (int) a| 000007c0 70 70 6e 61 6d 65 3b 0a 20 20 20 20 72 65 67 73 |ppname;. regs| 000007d0 5f 69 6e 2e 72 5b 33 5d 20 3d 20 28 69 6e 74 29 |_in.r[3] = (int)| 000007e0 20 6d 73 67 6c 69 73 74 3b 0a 20 20 20 20 2f 2a | msglist;. /*| 000007f0 20 57 65 20 6e 65 65 64 20 74 6f 20 73 75 70 70 | We need to supp| 00000800 6c 79 20 6f 75 72 20 63 68 6f 73 65 6e 20 52 49 |ly our chosen RI| 00000810 53 43 20 4f 53 20 76 65 72 73 69 6f 6e 20 6e 75 |SC OS version nu| 00000820 6d 62 65 72 2c 20 74 68 65 20 22 54 41 53 4b 22 |mber, the "TASK"| 00000830 0a 20 20 20 20 20 20 20 69 64 65 6e 74 69 66 69 |. identifi| 00000840 65 72 20 74 6f 20 70 72 6f 76 65 20 77 65 27 72 |er to prove we'r| 00000850 65 20 61 20 6d 75 6c 74 69 74 61 73 6b 69 6e 67 |e a multitasking| 00000860 20 61 70 70 6c 69 63 61 74 69 6f 6e 2c 20 61 20 | application, a | 00000870 70 6f 69 6e 74 65 72 20 74 6f 0a 20 20 20 20 20 |pointer to. | 00000880 20 20 6f 75 72 20 61 70 70 6c 69 63 61 74 69 6f | our applicatio| 00000890 6e 20 6e 61 6d 65 20 61 6e 64 20 61 20 70 6f 69 |n name and a poi| 000008a0 6e 74 65 72 20 74 6f 20 61 20 6d 65 73 73 61 67 |nter to a messag| 000008b0 65 20 6c 69 73 74 20 2d 20 63 6f 6e 76 65 72 74 |e list - convert| 000008c0 65 64 20 74 6f 0a 20 20 20 20 20 20 20 69 6e 74 |ed to. int| 000008d0 65 67 65 72 20 66 6f 72 6d 61 74 20 61 73 20 6e |eger format as n| 000008e0 65 63 65 73 73 61 72 79 20 2a 2f 0a 0a 20 20 20 |ecessary */.. | 000008f0 20 2f 2a 20 6e 6f 77 20 74 6f 20 70 65 72 66 6f | /* now to perfo| 00000900 72 6d 20 74 68 65 20 61 63 74 75 61 6c 20 53 57 |rm the actual SW| 00000910 49 20 63 61 6c 6c 20 2a 2f 0a 20 20 20 20 5f 6b |I call */. _k| 00000920 65 72 6e 65 6c 5f 73 77 69 28 57 69 6d 70 5f 49 |ernel_swi(Wimp_I| 00000930 6e 69 74 69 61 6c 69 73 65 2c 20 26 72 65 67 73 |nitialise, ®s| 00000940 5f 69 6e 2c 20 26 72 65 67 73 5f 6f 75 74 29 3b |_in, ®s_out);| 00000950 0a 20 20 20 20 74 61 73 6b 5f 68 61 6e 64 6c 65 |. task_handle| 00000960 20 3d 20 72 65 67 73 5f 6f 75 74 2e 72 5b 31 5d | = regs_out.r[1]| 00000970 3b 20 2f 2a 20 64 65 74 65 72 6d 69 6e 65 20 6f |; /* determine o| 00000980 75 72 20 74 61 73 6b 20 68 61 6e 64 6c 65 20 66 |ur task handle f| 00000990 6f 72 20 6c 61 74 65 72 20 75 73 65 20 2a 2f 0a |or later use */.| 000009a0 0a 20 20 20 20 2f 2a 20 4e 6f 77 2c 20 77 65 27 |. /* Now, we'| 000009b0 6c 6c 20 70 75 74 20 61 6e 20 69 63 6f 6e 20 6f |ll put an icon o| 000009c0 6e 20 74 68 65 20 69 63 6f 6e 20 62 61 72 20 2d |n the icon bar -| 000009d0 20 77 65 20 6e 65 65 64 20 74 6f 20 68 61 76 65 | we need to have| 000009e0 20 64 65 66 69 6e 65 64 20 61 6e 0a 20 20 20 20 | defined an. | 000009f0 20 20 20 69 63 6f 6e 20 62 6c 6f 63 6b 2c 20 77 | icon block, w| 00000a00 68 6f 73 65 20 61 64 64 72 65 73 73 20 77 65 20 |hose address we | 00000a10 70 61 73 73 20 69 6e 20 52 31 20 2a 2f 0a 0a 20 |pass in R1 */.. | 00000a20 20 20 20 77 74 6f 62 28 2d 31 2c 20 69 63 6f 6e | wtob(-1, icon| 00000a30 62 6c 6f 63 6b 2c 20 30 29 3b 20 2f 2a 20 53 70 |block, 0); /* Sp| 00000a40 65 63 69 66 79 20 70 6f 73 69 74 69 6f 6e 20 6f |ecify position o| 00000a50 6e 20 74 68 65 20 69 63 6f 6e 20 62 61 72 20 28 |n the icon bar (| 00000a60 74 68 65 20 72 69 67 68 74 29 20 2a 2f 0a 20 20 |the right) */. | 00000a70 20 20 77 74 6f 62 28 30 2c 20 69 63 6f 6e 62 6c | wtob(0, iconbl| 00000a80 6f 63 6b 2c 20 34 29 3b 20 2f 2a 20 54 68 65 73 |ock, 4); /* Thes| 00000a90 65 20 66 6f 75 72 20 6c 69 6e 65 73 20 67 69 76 |e four lines giv| 00000aa0 65 20 74 68 65 20 62 6f 75 6e 64 69 6e 67 20 62 |e the bounding b| 00000ab0 6f 78 20 6f 66 20 74 68 65 20 2a 2f 0a 20 20 20 |ox of the */. | 00000ac0 20 77 74 6f 62 28 30 2c 20 69 63 6f 6e 62 6c 6f | wtob(0, iconblo| 00000ad0 63 6b 2c 20 38 29 3b 20 2f 2a 20 69 63 6f 6e 20 |ck, 8); /* icon | 00000ae0 2d 20 6d 69 6e 20 78 2c 20 6d 69 6e 20 79 2c 20 |- min x, min y, | 00000af0 6d 61 78 20 78 2c 20 6d 61 78 20 79 20 2a 2f 0a |max x, max y */.| 00000b00 20 20 20 20 77 74 6f 62 28 37 32 2c 20 69 63 6f | wtob(72, ico| 00000b10 6e 62 6c 6f 63 6b 2c 20 31 32 29 3b 0a 20 20 20 |nblock, 12);. | 00000b20 20 77 74 6f 62 28 37 32 2c 20 69 63 6f 6e 62 6c | wtob(72, iconbl| 00000b30 6f 63 6b 2c 20 31 36 29 3b 0a 20 20 20 20 77 74 |ock, 16);. wt| 00000b40 6f 62 28 31 32 33 31 34 2c 20 69 63 6f 6e 62 6c |ob(12314, iconbl| 00000b50 6f 63 6b 2c 20 32 30 29 3b 0a 20 20 20 20 2f 2a |ock, 20);. /*| 00000b60 20 73 65 74 20 62 69 74 73 20 31 2c 20 33 2c 20 | set bits 1, 3, | 00000b70 34 2c 20 31 32 2c 20 31 33 20 6f 66 20 69 63 6f |4, 12, 13 of ico| 00000b80 6e 20 66 6c 61 67 73 20 2d 20 62 69 74 20 31 20 |n flags - bit 1 | 00000b90 2d 20 74 68 65 20 69 63 6f 6e 20 69 73 20 61 20 |- the icon is a | 00000ba0 73 70 72 69 74 65 3b 0a 20 20 20 20 62 69 74 73 |sprite;. bits| 00000bb0 20 33 2c 20 34 20 63 65 6e 74 72 65 20 74 68 65 | 3, 4 centre the| 00000bc0 20 73 70 72 69 74 65 20 69 6e 20 74 68 65 20 62 | sprite in the b| 00000bd0 6f 75 6e 64 69 6e 67 20 62 6f 78 3b 20 62 69 74 |ounding box; bit| 00000be0 73 20 31 32 20 61 6e 64 20 31 33 20 69 6e 66 6f |s 12 and 13 info| 00000bf0 72 6d 20 74 68 65 0a 20 20 20 20 57 49 4d 50 20 |rm the. WIMP | 00000c00 74 6f 20 6c 65 74 20 75 73 20 6b 6e 6f 77 20 77 |to let us know w| 00000c10 68 65 6e 20 6f 75 72 20 69 63 6f 6e 20 69 73 20 |hen our icon is | 00000c20 63 6c 69 63 6b 65 64 20 6f 6e 2c 20 62 79 20 70 |clicked on, by p| 00000c30 61 73 73 69 6e 67 20 75 73 20 61 0a 20 20 20 20 |assing us a. | 00000c40 4d 6f 75 73 65 5f 43 6c 69 63 6b 20 65 76 65 6e |Mouse_Click even| 00000c50 74 20 2a 2f 0a 0a 20 20 20 20 73 74 72 63 70 79 |t */.. strcpy| 00000c60 28 20 28 63 68 61 72 20 2a 29 20 26 69 63 6f 6e |( (char *) &icon| 00000c70 62 6c 6f 63 6b 5b 32 34 5d 2c 20 69 62 61 72 5f |block[24], ibar_| 00000c80 73 70 72 6e 61 6d 65 29 3b 0a 20 20 20 20 2f 2a |sprname);. /*| 00000c90 20 46 69 6e 61 6c 6c 79 2c 20 63 6f 70 79 20 74 | Finally, copy t| 00000ca0 68 65 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 73 |he name of the s| 00000cb0 70 72 69 74 65 20 77 65 20 61 72 65 20 74 6f 20 |prite we are to | 00000cc0 75 73 65 20 69 6e 74 6f 20 74 68 65 20 64 61 74 |use into the dat| 00000cd0 61 62 6c 6f 63 6b 3b 0a 20 20 20 20 74 68 69 73 |ablock;. this| 00000ce0 20 6d 75 73 74 20 62 65 20 74 65 72 6d 69 6e 61 | must be termina| 00000cf0 74 65 64 20 77 69 74 68 20 61 20 63 6f 6e 74 72 |ted with a contr| 00000d00 6f 6c 20 63 68 61 72 61 63 74 65 72 20 2a 2f 0a |ol character */.| 00000d10 0a 20 20 20 20 72 65 67 73 5f 69 6e 2e 72 5b 30 |. regs_in.r[0| 00000d20 5d 20 3d 20 30 3b 20 2f 2a 20 73 65 74 20 74 68 |] = 0; /* set th| 00000d30 65 20 69 63 6f 6e 27 73 20 70 72 69 6f 72 69 74 |e icon's priorit| 00000d40 79 20 2a 2f 0a 20 20 20 20 72 65 67 73 5f 69 6e |y */. regs_in| 00000d50 2e 72 5b 31 5d 20 3d 20 28 69 6e 74 29 20 69 63 |.r[1] = (int) ic| 00000d60 6f 6e 62 6c 6f 63 6b 3b 0a 20 20 20 20 5f 6b 65 |onblock;. _ke| 00000d70 72 6e 65 6c 5f 73 77 69 28 57 69 6d 70 5f 43 72 |rnel_swi(Wimp_Cr| 00000d80 65 61 74 65 49 63 6f 6e 2c 20 26 72 65 67 73 5f |eateIcon, ®s_| 00000d90 69 6e 2c 20 26 72 65 67 73 5f 6f 75 74 29 3b 0a |in, ®s_out);.| 00000da0 20 20 20 20 69 62 61 72 5f 69 63 6f 6e 5f 68 61 | ibar_icon_ha| 00000db0 6e 64 6c 65 20 3d 20 72 65 67 73 5f 6f 75 74 2e |ndle = regs_out.| 00000dc0 72 5b 30 5d 3b 0a 0a 20 20 20 20 2f 2a 20 4e 6f |r[0];.. /* No| 00000dd0 77 20 6f 70 65 6e 20 61 20 74 65 6d 70 6c 61 74 |w open a templat| 00000de0 65 20 66 69 6c 65 20 72 65 61 64 79 20 66 6f 72 |e file ready for| 00000df0 20 6c 6f 61 64 69 6e 67 20 2a 2f 0a 0a 20 20 20 | loading */.. | 00000e00 20 6c 6f 61 64 5f 74 65 6d 70 6c 61 74 65 73 28 | load_templates(| 00000e10 29 3b 0a 0a 20 20 20 20 64 6f 20 7b 0a 20 20 20 |);.. do {. | 00000e20 20 20 20 20 20 72 65 67 73 5f 69 6e 2e 72 5b 30 | regs_in.r[0| 00000e30 5d 20 3d 20 50 4f 4c 4c 5f 4d 41 53 4b 3b 0a 20 |] = POLL_MASK;. | 00000e40 20 20 20 20 20 20 20 72 65 67 73 5f 69 6e 2e 72 | regs_in.r| 00000e50 5b 31 5d 20 3d 20 28 69 6e 74 29 20 70 6f 6c 6c |[1] = (int) poll| 00000e60 62 6c 6f 63 6b 3b 20 2f 2a 20 61 20 70 6f 69 6e |block; /* a poin| 00000e70 74 65 72 20 74 6f 20 6f 75 72 20 64 61 74 61 20 |ter to our data | 00000e80 62 6c 6f 63 6b 20 2a 2f 0a 0a 20 20 20 20 20 20 |block */.. | 00000e90 20 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 28 57 69 | _kernel_swi(Wi| 00000ea0 6d 70 5f 50 6f 6c 6c 2c 20 26 72 65 67 73 5f 69 |mp_Poll, ®s_i| 00000eb0 6e 2c 20 26 72 65 67 73 5f 6f 75 74 29 3b 0a 20 |n, ®s_out);. | 00000ec0 20 20 20 20 20 20 20 70 6f 6c 6c 72 65 73 75 6c | pollresul| 00000ed0 74 20 3d 20 72 65 67 73 5f 6f 75 74 2e 72 5b 30 |t = regs_out.r[0| 00000ee0 5d 3b 20 2f 2a 20 64 65 74 65 72 6d 69 6e 65 20 |]; /* determine | 00000ef0 74 68 65 20 65 76 65 6e 74 20 63 6f 64 65 20 2a |the event code *| 00000f00 2f 0a 20 20 20 20 20 20 20 20 73 77 69 74 63 68 |/. switch| 00000f10 20 28 70 6f 6c 6c 72 65 73 75 6c 74 29 20 7b 0a | (pollresult) {.| 00000f20 20 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 | case| 00000f30 20 20 32 3a 20 6f 70 65 6e 77 69 6e 64 6f 77 28 | 2: openwindow(| 00000f40 70 6f 6c 6c 62 6c 6f 63 6b 29 3b 0a 20 20 20 20 |pollblock);. | 00000f50 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000f60 20 62 72 65 61 6b 3b 0a 20 20 20 20 20 20 20 20 | break;. | 00000f70 20 20 20 20 63 61 73 65 20 20 33 3a 20 63 6c 6f | case 3: clo| 00000f80 73 65 77 69 6e 64 6f 77 28 70 6f 6c 6c 62 6c 6f |sewindow(pollblo| 00000f90 63 6b 29 3b 0a 20 20 20 20 20 20 20 20 20 20 20 |ck);. | 00000fa0 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b | break;| 00000fb0 0a 20 20 20 20 20 20 20 20 20 20 20 20 63 61 73 |. cas| 00000fc0 65 20 20 36 3a 20 6d 6f 75 73 65 63 6c 69 63 6b |e 6: mouseclick| 00000fd0 28 70 6f 6c 6c 62 6c 6f 63 6b 29 3b 0a 20 20 20 |(pollblock);. | 00000fe0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000ff0 20 20 62 72 65 61 6b 3b 0a 20 20 20 20 20 20 20 | break;. | 00001000 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a | /*| 00001010 20 49 66 20 6f 75 72 20 69 63 6f 6e 20 69 73 20 | If our icon is | 00001020 63 6c 69 63 6b 65 64 20 6f 6e 2c 20 77 65 20 6a |clicked on, we j| 00001030 75 6d 70 20 74 6f 20 6d 6f 75 73 65 63 6c 69 63 |ump to mouseclic| 00001040 6b 28 29 20 2a 2f 0a 20 20 20 20 20 20 20 20 20 |k() */. | 00001050 20 20 20 63 61 73 65 20 31 37 3a 0a 20 20 20 20 | case 17:. | 00001060 20 20 20 20 20 20 20 20 63 61 73 65 20 31 38 3a | case 18:| 00001070 0a 20 20 20 20 20 20 20 20 20 20 20 20 63 61 73 |. cas| 00001080 65 20 31 39 3a 20 77 69 6d 70 6d 73 67 28 70 6f |e 19: wimpmsg(po| 00001090 6c 6c 72 65 73 75 6c 74 2c 20 70 6f 6c 6c 62 6c |llresult, pollbl| 000010a0 6f 63 6b 29 3b 0a 20 20 20 20 20 20 20 20 20 20 |ock);. | 000010b0 20 20 20 20 20 20 62 72 65 61 6b 3b 0a 20 20 20 | break;. | 000010c0 20 20 20 20 20 20 20 20 20 2f 2a 20 54 68 65 20 | /* The | 000010d0 61 62 6f 76 65 20 73 65 63 74 69 6f 6e 20 6c 69 |above section li| 000010e0 73 74 65 6e 73 20 66 6f 72 20 65 76 65 6e 74 20 |stens for event | 000010f0 63 6f 64 65 73 20 31 37 2c 20 31 38 20 61 6e 64 |codes 17, 18 and| 00001100 20 31 39 20 2d 20 74 68 65 0a 20 20 20 20 20 20 | 19 - the. | 00001110 20 20 20 20 20 20 20 20 20 6f 6e 65 73 20 77 68 | ones wh| 00001120 69 63 68 20 69 6e 64 69 63 61 74 65 20 77 65 27 |ich indicate we'| 00001130 72 65 20 62 65 69 6e 67 20 73 65 6e 74 20 61 20 |re being sent a | 00001140 6d 65 73 73 61 67 65 20 2a 2f 0a 20 20 20 20 20 |message */. | 00001150 20 20 20 7d 0a 20 20 20 20 7d 20 77 68 69 6c 65 | }. } while| 00001160 20 28 51 55 49 54 5f 46 4c 41 47 20 3d 3d 20 30 | (QUIT_FLAG == 0| 00001170 29 3b 0a 20 20 20 20 2f 2a 20 49 66 20 51 55 49 |);. /* If QUI| 00001180 54 5f 46 4c 41 47 20 63 68 61 6e 67 65 73 20 74 |T_FLAG changes t| 00001190 6f 20 61 6e 79 74 68 69 6e 67 20 62 75 74 20 30 |o anything but 0| 000011a0 2c 20 77 65 20 73 74 6f 70 20 67 6f 69 6e 67 20 |, we stop going | 000011b0 72 6f 75 6e 64 20 74 68 65 20 70 6f 6c 6c 69 6e |round the pollin| 000011c0 67 0a 20 20 20 20 20 20 20 6c 6f 6f 70 20 61 6e |g. loop an| 000011d0 64 20 73 68 75 74 20 64 6f 77 6e 20 2a 2f 0a 0a |d shut down */..| 000011e0 0a 20 20 20 20 72 65 67 73 5f 69 6e 2e 72 5b 30 |. regs_in.r[0| 000011f0 5d 20 3d 20 74 61 73 6b 5f 68 61 6e 64 6c 65 3b |] = task_handle;| 00001200 0a 20 20 20 20 72 65 67 73 5f 69 6e 2e 72 5b 31 |. regs_in.r[1| 00001210 5d 20 3d 20 2a 28 69 6e 74 20 2a 29 22 54 41 53 |] = *(int *)"TAS| 00001220 4b 22 3b 0a 20 20 20 20 5f 6b 65 72 6e 65 6c 5f |K";. _kernel_| 00001230 73 77 69 28 57 69 6d 70 5f 43 6c 6f 73 65 44 6f |swi(Wimp_CloseDo| 00001240 77 6e 2c 20 26 72 65 67 73 5f 69 6e 2c 20 26 72 |wn, ®s_in, &r| 00001250 65 67 73 5f 6f 75 74 29 3b 0a 20 20 20 20 2f 2a |egs_out);. /*| 00001260 20 41 6e 64 20 74 68 61 74 27 73 20 69 74 20 2d | And that's it -| 00001270 20 77 65 27 76 65 20 74 6f 6c 64 20 74 68 65 20 | we've told the | 00001280 57 49 4d 50 20 74 68 61 74 20 77 65 27 76 65 20 |WIMP that we've | 00001290 66 69 6e 69 73 68 65 64 2c 20 61 6e 64 20 6e 6f |finished, and no| 000012a0 77 20 74 68 65 0a 20 20 20 20 20 20 20 70 72 6f |w the. pro| 000012b0 67 72 61 6d 20 74 65 72 6d 69 6e 61 74 65 73 2e |gram terminates.| 000012c0 20 2a 2f 0a 7d 0a 0a 76 6f 69 64 0a 77 69 6d 70 | */.}..void.wimp| 000012d0 6d 73 67 28 69 6e 74 20 72 65 73 75 6c 74 2c 20 |msg(int result, | 000012e0 75 6e 73 69 67 6e 65 64 20 63 68 61 72 20 70 6f |unsigned char po| 000012f0 6c 6c 62 6c 6f 63 6b 5b 5d 29 0a 7b 0a 20 20 20 |llblock[]).{. | 00001300 20 75 6e 73 69 67 6e 65 64 20 6c 6f 6e 67 20 69 | unsigned long i| 00001310 6e 74 20 20 20 6d 65 73 73 61 67 65 5f 61 63 74 |nt message_act| 00001320 69 6f 6e 3b 0a 0a 20 20 20 20 2f 2a 20 54 68 65 |ion;.. /* The| 00001330 20 6e 65 78 74 20 6c 69 6e 65 20 74 61 6b 65 73 | next line takes| 00001340 20 62 79 74 65 73 20 31 36 20 74 6f 20 31 39 20 | bytes 16 to 19 | 00001350 6f 66 20 74 68 65 20 70 6f 6c 6c 69 6e 67 20 62 |of the polling b| 00001360 6c 6f 63 6b 20 61 6e 64 20 66 6f 72 6d 73 20 74 |lock and forms t| 00001370 68 65 6d 0a 20 20 20 20 20 20 20 69 6e 74 6f 20 |hem. into | 00001380 61 20 77 6f 72 64 20 68 6f 6c 64 69 6e 67 20 74 |a word holding t| 00001390 68 65 20 6d 65 73 73 61 67 65 20 61 63 74 69 6f |he message actio| 000013a0 6e 20 6e 75 6d 62 65 72 20 2a 2f 0a 20 20 20 20 |n number */. | 000013b0 6d 65 73 73 61 67 65 5f 61 63 74 69 6f 6e 20 3d |message_action =| 000013c0 20 62 74 6f 77 28 70 6f 6c 6c 62 6c 6f 63 6b 2c | btow(pollblock,| 000013d0 20 31 36 29 3b 0a 20 20 20 20 0a 20 20 20 20 73 | 16);. . s| 000013e0 77 69 74 63 68 20 28 6d 65 73 73 61 67 65 5f 61 |witch (message_a| 000013f0 63 74 69 6f 6e 29 20 7b 0a 20 20 20 20 20 20 20 |ction) {. | 00001400 20 63 61 73 65 20 30 3a 20 51 55 49 54 5f 46 4c | case 0: QUIT_FL| 00001410 41 47 20 3d 20 31 3b 20 2f 2a 20 4d 65 73 73 61 |AG = 1; /* Messa| 00001420 67 65 5f 51 75 69 74 20 2d 20 74 69 6d 65 20 74 |ge_Quit - time t| 00001430 6f 20 67 6f 20 2a 2f 0a 20 20 20 20 20 20 20 20 |o go */. | 00001440 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b 0a 20 | break;. | 00001450 20 20 20 20 20 20 20 63 61 73 65 20 30 78 34 30 | case 0x40| 00001460 30 63 32 3a 20 69 63 6f 6e 63 68 61 6e 67 65 28 |0c2: iconchange(| 00001470 28 63 68 61 72 20 2a 29 20 26 70 6f 6c 6c 62 6c |(char *) &pollbl| 00001480 6f 63 6b 5b 32 38 5d 2c 20 4d 41 49 4e 57 49 4e |ock[28], MAINWIN| 00001490 5f 48 41 4e 44 4c 45 2c 20 44 49 53 50 4c 41 59 |_HANDLE, DISPLAY| 000014a0 5f 49 43 4f 4e 29 3b 0a 20 20 20 20 20 20 20 20 |_ICON);. | 000014b0 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b 20 20 | break; | 000014c0 20 20 20 20 20 20 0a 20 20 20 20 20 20 20 20 2f | . /| 000014d0 2a 20 4d 6f 72 65 20 6d 65 73 73 61 67 65 20 61 |* More message a| 000014e0 63 74 69 6f 6e 73 20 63 61 6e 20 62 65 20 61 64 |ctions can be ad| 000014f0 64 65 64 20 68 65 72 65 20 2a 2f 0a 20 20 20 20 |ded here */. | 00001500 7d 0a 7d 0a 0a 75 6e 73 69 67 6e 65 64 20 6c 6f |}.}..unsigned lo| 00001510 6e 67 20 69 6e 74 0a 62 74 6f 77 28 75 6e 73 69 |ng int.btow(unsi| 00001520 67 6e 65 64 20 63 68 61 72 20 62 6c 6f 63 6b 5b |gned char block[| 00001530 5d 2c 20 69 6e 74 20 69 6e 64 65 78 29 0a 7b 0a |], int index).{.| 00001540 20 20 20 20 75 6e 73 69 67 6e 65 64 20 6c 6f 6e | unsigned lon| 00001550 67 20 69 6e 74 20 20 20 72 65 73 75 6c 74 20 3d |g int result =| 00001560 20 30 3b 0a 20 20 20 20 69 6e 74 20 6c 6f 6f 70 | 0;. int loop| 00001570 3b 0a 0a 20 20 20 20 2f 2a 20 54 68 69 73 20 72 |;.. /* This r| 00001580 6f 75 74 69 6e 65 20 74 61 6b 65 73 20 61 20 64 |outine takes a d| 00001590 61 74 61 20 62 6c 6f 63 6b 20 61 6e 64 20 61 20 |ata block and a | 000015a0 73 74 61 72 74 69 6e 67 20 62 79 74 65 2c 20 61 |starting byte, a| 000015b0 6e 64 20 63 6f 6e 76 65 72 74 73 20 74 68 65 0a |nd converts the.| 000015c0 20 20 20 20 20 20 20 6e 65 78 74 20 66 6f 75 72 | next four| 000015d0 20 62 79 74 65 73 20 69 6e 74 6f 20 61 20 77 6f | bytes into a wo| 000015e0 72 64 20 2d 20 77 65 20 68 61 76 65 20 74 6f 20 |rd - we have to | 000015f0 73 74 61 72 74 20 61 74 20 74 68 65 20 6d 6f 73 |start at the mos| 00001600 74 20 73 69 67 6e 69 66 69 63 61 6e 74 0a 20 20 |t significant. | 00001610 20 20 20 20 20 62 79 74 65 20 61 6e 64 20 77 6f | byte and wo| 00001620 72 6b 20 62 61 63 6b 77 61 72 64 73 20 2a 2f 0a |rk backwards */.| 00001630 0a 20 20 20 20 69 6e 64 65 78 20 2b 3d 20 33 3b |. index += 3;| 00001640 0a 20 20 20 20 72 65 73 75 6c 74 20 3d 20 62 6c |. result = bl| 00001650 6f 63 6b 5b 69 6e 64 65 78 2d 2d 5d 3b 0a 20 20 |ock[index--];. | 00001660 20 20 66 6f 72 28 6c 6f 6f 70 20 3d 20 30 3b 20 | for(loop = 0; | 00001670 6c 6f 6f 70 20 3c 20 33 3b 20 6c 6f 6f 70 2b 2b |loop < 3; loop++| 00001680 29 20 7b 0a 20 20 20 20 20 20 20 20 72 65 73 75 |) {. resu| 00001690 6c 74 20 3d 20 72 65 73 75 6c 74 20 3c 3c 20 38 |lt = result << 8| 000016a0 3b 0a 20 20 20 20 20 20 20 20 2f 2a 20 74 68 69 |;. /* thi| 000016b0 73 20 73 68 69 66 74 73 20 74 68 65 20 62 69 74 |s shifts the bit| 000016c0 73 20 69 6e 20 72 65 73 75 6c 74 20 6c 65 66 74 |s in result left| 000016d0 20 62 79 20 38 20 73 70 61 63 65 73 20 2a 2f 0a | by 8 spaces */.| 000016e0 20 20 20 20 20 20 20 20 72 65 73 75 6c 74 20 2b | result +| 000016f0 3d 20 62 6c 6f 63 6b 5b 69 6e 64 65 78 2d 2d 5d |= block[index--]| 00001700 3b 0a 20 20 20 20 7d 0a 0a 20 20 20 20 72 65 74 |;. }.. ret| 00001710 75 72 6e 20 28 72 65 73 75 6c 74 29 3b 0a 7d 0a |urn (result);.}.| 00001720 0a 76 6f 69 64 0a 77 74 6f 62 28 75 6e 73 69 67 |.void.wtob(unsig| 00001730 6e 65 64 20 6c 6f 6e 67 20 69 6e 74 20 69 6e 70 |ned long int inp| 00001740 75 74 2c 20 75 6e 73 69 67 6e 65 64 20 63 68 61 |ut, unsigned cha| 00001750 72 20 62 6c 6f 63 6b 5b 5d 2c 20 69 6e 74 20 69 |r block[], int i| 00001760 6e 64 65 78 29 0a 7b 0a 20 20 20 75 6e 73 69 67 |ndex).{. unsig| 00001770 6e 65 64 20 6c 6f 6e 67 20 69 6e 74 20 6d 61 73 |ned long int mas| 00001780 6b 20 3d 20 32 35 35 3b 0a 0a 20 20 20 2f 2a 20 |k = 255;.. /* | 00001790 54 68 65 20 6f 70 70 6f 73 69 74 65 20 6f 66 20 |The opposite of | 000017a0 62 74 6f 77 28 29 20 2d 20 74 68 69 73 20 66 75 |btow() - this fu| 000017b0 6e 63 74 69 6f 6e 20 74 61 6b 65 73 20 61 20 33 |nction takes a 3| 000017c0 32 2d 62 69 74 20 69 6e 74 65 67 65 72 2c 20 73 |2-bit integer, s| 000017d0 70 6c 69 74 73 0a 20 20 20 20 20 20 69 74 20 75 |plits. it u| 000017e0 70 20 69 6e 74 6f 20 34 20 62 79 74 65 73 2c 20 |p into 4 bytes, | 000017f0 61 6e 64 20 73 74 6f 72 65 73 20 74 68 6f 73 65 |and stores those| 00001800 20 69 6e 20 34 20 63 6f 6e 73 65 63 75 74 69 76 | in 4 consecutiv| 00001810 65 20 63 65 6c 6c 73 20 6f 66 20 61 0a 20 20 20 |e cells of a. | 00001820 20 20 20 63 68 61 72 61 63 74 65 72 20 61 72 72 | character arr| 00001830 61 79 20 69 6e 64 65 78 65 64 20 62 79 20 69 6e |ay indexed by in| 00001840 64 65 78 2e 20 54 68 69 73 20 69 73 20 64 6f 6e |dex. This is don| 00001850 65 20 62 79 20 75 73 69 6e 67 20 61 20 6d 61 73 |e by using a mas| 00001860 6b 20 74 6f 0a 20 20 20 20 20 20 65 78 74 72 61 |k to. extra| 00001870 63 74 20 74 68 65 20 64 61 74 61 20 69 6e 20 73 |ct the data in s| 00001880 65 71 75 65 6e 63 65 2c 20 77 69 74 68 20 74 68 |equence, with th| 00001890 65 20 26 20 62 69 74 77 69 73 65 2d 61 6e 64 20 |e & bitwise-and | 000018a0 6f 70 65 72 61 74 6f 72 20 2a 2f 0a 0a 20 20 20 |operator */.. | 000018b0 2f 2a 20 67 65 74 20 66 69 72 73 74 20 62 79 74 |/* get first byt| 000018c0 65 20 2a 2f 0a 20 20 20 62 6c 6f 63 6b 5b 69 6e |e */. block[in| 000018d0 64 65 78 2b 2b 5d 20 3d 20 28 63 68 61 72 29 20 |dex++] = (char) | 000018e0 28 69 6e 70 75 74 20 26 20 6d 61 73 6b 29 3b 0a |(input & mask);.| 000018f0 20 20 20 2f 2a 20 73 68 69 66 74 20 6d 61 73 6b | /* shift mask| 00001900 20 74 6f 20 67 65 74 20 73 65 63 6f 6e 64 20 62 | to get second b| 00001910 79 74 65 2c 20 61 6e 64 20 73 75 70 70 6c 79 20 |yte, and supply | 00001920 72 65 73 75 6c 74 20 61 73 20 62 79 74 65 20 73 |result as byte s| 00001930 69 7a 65 20 2a 2f 0a 20 20 20 6d 61 73 6b 20 3c |ize */. mask <| 00001940 3c 3d 20 38 3b 0a 20 20 20 62 6c 6f 63 6b 5b 69 |<= 8;. block[i| 00001950 6e 64 65 78 2b 2b 5d 20 3d 20 28 63 68 61 72 29 |ndex++] = (char)| 00001960 20 28 28 69 6e 70 75 74 20 26 20 6d 61 73 6b 29 | ((input & mask)| 00001970 20 3e 3e 20 38 29 3b 0a 20 20 20 6d 61 73 6b 20 | >> 8);. mask | 00001980 3c 3c 3d 20 38 3b 0a 20 20 20 62 6c 6f 63 6b 5b |<<= 8;. block[| 00001990 69 6e 64 65 78 2b 2b 5d 20 3d 20 28 63 68 61 72 |index++] = (char| 000019a0 29 20 28 28 69 6e 70 75 74 20 26 20 6d 61 73 6b |) ((input & mask| 000019b0 29 20 3e 3e 20 31 36 29 3b 0a 20 20 20 6d 61 73 |) >> 16);. mas| 000019c0 6b 20 3c 3c 3d 20 38 3b 0a 20 20 20 62 6c 6f 63 |k <<= 8;. bloc| 000019d0 6b 5b 69 6e 64 65 78 2b 2b 5d 20 3d 20 28 63 68 |k[index++] = (ch| 000019e0 61 72 29 20 28 28 69 6e 70 75 74 20 26 20 6d 61 |ar) ((input & ma| 000019f0 73 6b 29 20 3e 3e 20 32 34 29 3b 0a 0a 20 20 20 |sk) >> 24);.. | 00001a00 72 65 74 75 72 6e 3b 0a 7d 0a 0a 76 6f 69 64 0a |return;.}..void.| 00001a10 6d 6f 75 73 65 63 6c 69 63 6b 28 75 6e 73 69 67 |mouseclick(unsig| 00001a20 6e 65 64 20 63 68 61 72 20 70 6f 6c 6c 62 6c 6f |ned char pollblo| 00001a30 63 6b 5b 5d 29 0a 7b 0a 20 20 20 2f 2a 20 57 65 |ck[]).{. /* We| 00001a40 27 76 65 20 72 65 63 65 69 76 65 64 20 61 20 6d |'ve received a m| 00001a50 6f 75 73 65 5f 63 6c 69 63 6b 20 65 76 65 6e 74 |ouse_click event| 00001a60 20 2d 20 69 6e 20 6d 6f 72 65 20 63 6f 6d 70 6c | - in more compl| 00001a70 65 78 20 73 79 73 74 65 6d 73 2c 20 77 65 20 77 |ex systems, we w| 00001a80 6f 75 6c 64 0a 20 20 20 20 20 20 6e 6f 77 20 64 |ould. now d| 00001a90 65 63 69 64 65 20 77 68 61 74 20 68 61 64 20 62 |ecide what had b| 00001aa0 65 65 6e 20 63 6c 69 63 6b 65 64 20 6f 6e 2c 20 |een clicked on, | 00001ab0 62 75 74 20 68 65 72 65 20 61 6c 6c 20 77 65 20 |but here all we | 00001ac0 68 61 76 65 20 74 6f 20 64 6f 20 69 73 0a 20 20 |have to do is. | 00001ad0 20 20 20 20 70 72 6f 76 65 20 74 68 61 74 20 77 | prove that w| 00001ae0 65 27 76 65 20 68 65 61 72 64 20 69 74 2e 20 2a |e've heard it. *| 00001af0 2f 0a 20 20 20 63 68 61 72 20 6d 65 73 73 61 67 |/. char messag| 00001b00 65 5b 32 35 35 5d 3b 0a 20 20 20 2f 2a 20 41 20 |e[255];. /* A | 00001b10 62 75 66 66 65 72 20 74 6f 20 68 6f 6c 64 20 61 |buffer to hold a| 00001b20 6e 20 27 65 72 72 6f 72 27 20 6d 65 73 73 61 67 |n 'error' messag| 00001b30 65 20 2a 2f 0a 0a 20 20 20 69 6e 74 20 72 65 73 |e */.. int res| 00001b40 75 6c 74 2c 20 63 6c 6b 3b 0a 20 20 20 5f 6b 65 |ult, clk;. _ke| 00001b50 72 6e 65 6c 5f 73 77 69 5f 72 65 67 73 20 69 6e |rnel_swi_regs in| 00001b60 2c 20 6f 75 74 3b 0a 20 20 20 75 6e 73 69 67 6e |, out;. unsign| 00001b70 65 64 20 63 68 61 72 20 74 65 6d 70 5f 62 75 66 |ed char temp_buf| 00001b80 66 65 72 5b 32 35 35 5d 3b 0a 0a 20 20 20 2f 2a |fer[255];.. /*| 00001b90 20 44 65 74 65 72 6d 69 6e 65 20 77 68 69 63 68 | Determine which| 00001ba0 20 62 75 74 74 6f 6e 20 77 61 73 20 70 72 65 73 | button was pres| 00001bb0 73 65 64 20 2a 2f 0a 20 20 20 63 6c 6b 20 3d 20 |sed */. clk = | 00001bc0 28 69 6e 74 29 20 62 74 6f 77 28 70 6f 6c 6c 62 |(int) btow(pollb| 00001bd0 6c 6f 63 6b 2c 20 38 29 3b 0a 0a 20 20 20 2f 2a |lock, 8);.. /*| 00001be0 20 49 66 20 74 68 65 20 27 53 65 6c 65 63 74 27 | If the 'Select'| 00001bf0 20 62 75 74 74 6f 6e 20 77 61 73 20 63 6c 69 63 | button was clic| 00001c00 6b 65 64 20 6f 6e 20 74 68 65 20 69 63 6f 6e 20 |ked on the icon | 00001c10 62 61 72 20 28 70 6f 6c 6c 62 6c 6f 63 6b 20 2b |bar (pollblock +| 00001c20 20 31 32 20 3d 20 2d 32 29 0a 20 20 20 20 20 20 | 12 = -2). | 00001c30 74 68 65 6e 20 72 65 2d 6f 70 65 6e 20 6d 61 69 |then re-open mai| 00001c40 6e 20 77 69 6e 64 6f 77 20 61 6e 64 20 72 65 74 |n window and ret| 00001c50 75 72 6e 20 2a 2f 0a 0a 20 20 20 69 66 28 28 62 |urn */.. if((b| 00001c60 74 6f 77 28 70 6f 6c 6c 62 6c 6f 63 6b 2c 20 31 |tow(pollblock, 1| 00001c70 32 29 20 3d 3d 20 2d 32 29 20 26 26 20 28 63 6c |2) == -2) && (cl| 00001c80 6b 20 3d 3d 20 34 29 29 20 7b 0a 20 20 20 20 20 |k == 4)) {. | 00001c90 20 77 74 6f 62 28 4d 41 49 4e 57 49 4e 5f 48 41 | wtob(MAINWIN_HA| 00001ca0 4e 44 4c 45 2c 20 74 65 6d 70 5f 62 75 66 66 65 |NDLE, temp_buffe| 00001cb0 72 2c 20 30 29 3b 0a 20 20 20 20 20 20 69 6e 2e |r, 0);. in.| 00001cc0 72 5b 31 5d 20 3d 20 28 69 6e 74 29 20 74 65 6d |r[1] = (int) tem| 00001cd0 70 5f 62 75 66 66 65 72 3b 0a 20 20 20 20 20 20 |p_buffer;. | 00001ce0 5f 6b 65 72 6e 65 6c 5f 73 77 69 28 57 69 6d 70 |_kernel_swi(Wimp| 00001cf0 5f 47 65 74 57 69 6e 64 6f 77 49 6e 66 6f 2c 20 |_GetWindowInfo, | 00001d00 26 69 6e 2c 20 26 6f 75 74 29 3b 0a 20 20 20 20 |&in, &out);. | 00001d10 20 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 28 57 69 | _kernel_swi(Wi| 00001d20 6d 70 5f 4f 70 65 6e 57 69 6e 64 6f 77 2c 20 26 |mp_OpenWindow, &| 00001d30 69 6e 2c 20 26 6f 75 74 29 3b 0a 20 20 20 20 20 |in, &out);. | 00001d40 20 72 65 74 75 72 6e 3b 0a 20 20 20 7d 0a 0a 20 | return;. }.. | 00001d50 20 20 73 74 72 63 70 79 28 6d 65 73 73 61 67 65 | strcpy(message| 00001d60 2c 20 22 4d 6f 75 73 65 20 63 6c 69 63 6b 20 64 |, "Mouse click d| 00001d70 65 74 65 63 74 65 64 20 28 74 79 70 65 22 29 3b |etected (type");| 00001d80 0a 20 20 20 73 70 72 69 6e 74 66 28 6d 65 73 73 |. sprintf(mess| 00001d90 61 67 65 2c 20 22 25 73 20 25 64 29 20 2d 20 64 |age, "%s %d) - d| 00001da0 6f 20 79 6f 75 20 77 69 73 68 20 74 6f 20 73 74 |o you wish to st| 00001db0 6f 70 20 74 68 65 20 70 72 6f 67 72 61 6d 3f 22 |op the program?"| 00001dc0 2c 20 6d 65 73 73 61 67 65 2c 20 63 6c 6b 29 3b |, message, clk);| 00001dd0 0a 0a 20 20 20 2f 2a 20 54 68 65 20 61 62 6f 76 |.. /* The abov| 00001de0 65 20 6c 69 6e 65 73 20 63 6f 6d 70 69 6c 65 20 |e lines compile | 00001df0 61 6e 20 65 72 72 6f 72 20 6d 65 73 73 61 67 65 |an error message| 00001e00 20 75 73 69 6e 67 20 73 74 61 6e 64 61 72 64 20 | using standard | 00001e10 73 74 72 69 6e 67 0a 20 20 20 20 20 20 66 75 6e |string. fun| 00001e20 63 74 69 6f 6e 73 20 2a 2f 0a 0a 20 20 20 72 65 |ctions */.. re| 00001e30 73 75 6c 74 20 3d 20 72 65 70 6f 72 74 5f 65 72 |sult = report_er| 00001e40 72 6f 72 28 31 2c 20 6d 65 73 73 61 67 65 2c 20 |ror(1, message, | 00001e50 33 29 3b 0a 20 20 20 2f 2a 20 54 68 69 73 20 63 |3);. /* This c| 00001e60 61 6c 6c 73 20 61 20 66 75 6e 63 74 69 6f 6e 20 |alls a function | 00001e70 74 6f 20 64 69 73 70 6c 61 79 20 61 6e 20 65 72 |to display an er| 00001e80 72 6f 72 20 62 6f 78 20 6f 6e 20 74 68 65 20 73 |ror box on the s| 00001e90 63 72 65 65 6e 20 2d 20 69 66 20 74 68 65 0a 20 |creen - if the. | 00001ea0 20 20 20 20 20 75 73 65 72 20 63 6c 69 63 6b 73 | user clicks| 00001eb0 20 6f 6e 20 4f 4b 2c 20 74 68 65 20 70 72 6f 67 | on OK, the prog| 00001ec0 72 61 6d 20 74 65 72 6d 69 6e 61 74 65 73 20 2a |ram terminates *| 00001ed0 2f 0a 0a 20 20 20 69 66 20 28 72 65 73 75 6c 74 |/.. if (result| 00001ee0 20 3d 3d 20 31 29 20 51 55 49 54 5f 46 4c 41 47 | == 1) QUIT_FLAG| 00001ef0 20 3d 20 31 3b 0a 7d 0a 0a 69 6e 74 0a 72 65 70 | = 1;.}..int.rep| 00001f00 6f 72 74 5f 65 72 72 6f 72 28 69 6e 74 20 65 72 |ort_error(int er| 00001f10 72 6e 6f 2c 20 63 68 61 72 20 65 72 72 6d 65 73 |rno, char errmes| 00001f20 73 5b 5d 2c 20 69 6e 74 20 66 6c 61 67 73 29 0a |s[], int flags).| 00001f30 7b 0a 20 20 20 75 6e 73 69 67 6e 65 64 20 63 68 |{. unsigned ch| 00001f40 61 72 20 65 72 72 6f 72 62 6c 6f 63 6b 5b 32 36 |ar errorblock[26| 00001f50 30 5d 3b 0a 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 |0];. _kernel_s| 00001f60 77 69 5f 72 65 67 73 20 69 6e 2c 20 6f 75 74 3b |wi_regs in, out;| 00001f70 0a 0a 20 20 20 2f 2a 20 53 65 74 20 75 70 20 74 |.. /* Set up t| 00001f80 68 65 20 73 74 61 6e 64 61 72 64 20 65 72 72 6f |he standard erro| 00001f90 72 20 62 6c 6f 63 6b 20 77 69 74 68 20 74 68 65 |r block with the| 00001fa0 20 65 72 72 6f 72 20 6e 75 6d 62 65 72 20 61 6e | error number an| 00001fb0 64 20 6d 65 73 73 61 67 65 0a 20 20 20 20 20 20 |d message. | 00001fc0 28 7a 65 72 6f 20 74 65 72 6d 69 6e 61 74 65 64 |(zero terminated| 00001fd0 29 20 2a 2f 0a 20 20 20 77 74 6f 62 28 65 72 72 |) */. wtob(err| 00001fe0 6e 6f 2c 20 65 72 72 6f 72 62 6c 6f 63 6b 2c 20 |no, errorblock, | 00001ff0 30 29 3b 0a 20 20 20 73 74 72 63 70 79 28 20 28 |0);. strcpy( (| 00002000 63 68 61 72 20 2a 29 20 26 65 72 72 6f 72 62 6c |char *) &errorbl| 00002010 6f 63 6b 5b 34 5d 2c 20 65 72 72 6d 65 73 73 29 |ock[4], errmess)| 00002020 3b 0a 0a 20 20 20 2f 2a 20 52 30 20 2d 20 70 6f |;.. /* R0 - po| 00002030 69 6e 74 65 72 20 74 6f 20 73 74 61 6e 64 61 72 |inter to standar| 00002040 64 20 65 72 72 6f 72 20 62 6c 6f 63 6b 0a 20 20 |d error block. | 00002050 20 20 20 20 52 31 20 2d 20 65 72 72 6f 72 20 77 | R1 - error w| 00002060 69 6e 64 6f 77 20 66 6c 61 67 73 0a 20 20 20 20 |indow flags. | 00002070 20 20 52 32 20 2d 20 70 6f 69 6e 74 65 72 20 74 | R2 - pointer t| 00002080 6f 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 6e 61 |o application na| 00002090 6d 65 20 66 6f 72 20 65 72 72 6f 72 20 62 6f 78 |me for error box| 000020a0 20 74 69 74 6c 65 20 2a 2f 0a 0a 20 20 20 69 6e | title */.. in| 000020b0 2e 72 5b 30 5d 20 3d 20 28 69 6e 74 29 20 65 72 |.r[0] = (int) er| 000020c0 72 6f 72 62 6c 6f 63 6b 3b 0a 20 20 20 69 6e 2e |rorblock;. in.| 000020d0 72 5b 31 5d 20 3d 20 66 6c 61 67 73 3b 0a 20 20 |r[1] = flags;. | 000020e0 20 69 6e 2e 72 5b 32 5d 20 3d 20 28 69 6e 74 29 | in.r[2] = (int)| 000020f0 20 61 70 70 6e 61 6d 65 3b 0a 0a 20 20 20 5f 6b | appname;.. _k| 00002100 65 72 6e 65 6c 5f 73 77 69 28 57 69 6d 70 5f 52 |ernel_swi(Wimp_R| 00002110 65 70 6f 72 74 45 72 72 6f 72 2c 20 26 69 6e 2c |eportError, &in,| 00002120 20 26 6f 75 74 29 3b 0a 0a 20 20 20 2f 2a 20 52 | &out);.. /* R| 00002130 65 74 75 72 6e 73 20 31 20 69 66 20 4f 4b 20 73 |eturns 1 if OK s| 00002140 65 6c 65 63 74 65 64 2c 20 32 20 69 66 20 43 61 |elected, 2 if Ca| 00002150 6e 63 65 6c 20 73 65 6c 65 63 74 65 64 20 2a 2f |ncel selected */| 00002160 0a 20 20 20 72 65 74 75 72 6e 20 6f 75 74 2e 72 |. return out.r| 00002170 5b 31 5d 3b 0a 7d 0a 0a 69 6e 74 0a 6c 6f 61 64 |[1];.}..int.load| 00002180 5f 74 65 6d 70 6c 61 74 65 73 28 76 6f 69 64 29 |_templates(void)| 00002190 0a 7b 0a 20 20 20 20 63 68 61 72 20 74 65 6d 70 |.{. char temp| 000021a0 6c 61 74 65 5f 66 69 6c 65 6e 61 6d 65 5b 5d 20 |late_filename[] | 000021b0 3d 20 22 3c 57 69 6d 70 43 24 44 69 72 3e 2e 54 |= "<WimpC$Dir>.T| 000021c0 65 6d 70 6c 61 74 65 73 22 3b 0a 20 20 20 20 63 |emplates";. c| 000021d0 68 61 72 20 74 65 6d 70 6c 61 74 65 5f 6e 61 6d |har template_nam| 000021e0 65 5b 5d 20 3d 20 22 4d 61 69 6e 57 69 6e 64 6f |e[] = "MainWindo| 000021f0 77 5c 30 22 3b 0a 20 20 20 20 75 6e 73 69 67 6e |w\0";. unsign| 00002200 65 64 20 63 68 61 72 20 6f 70 65 6e 77 69 6e 64 |ed char openwind| 00002210 6f 77 5f 62 75 66 66 65 72 5b 33 36 5d 3b 0a 20 |ow_buffer[36];. | 00002220 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 5f 72 | _kernel_swi_r| 00002230 65 67 73 20 69 6e 2c 20 6f 75 74 3b 0a 20 20 20 |egs in, out;. | 00002240 20 69 6e 74 20 6c 6f 6f 70 20 3d 20 30 3b 0a 0a | int loop = 0;..| 00002250 20 20 20 20 2f 2a 20 54 68 69 73 20 53 57 49 20 | /* This SWI | 00002260 63 61 6c 6c 20 70 72 65 70 61 72 65 73 20 61 20 |call prepares a | 00002270 74 65 6d 70 6c 61 74 65 20 66 69 6c 65 20 66 6f |template file fo| 00002280 72 20 72 65 61 64 69 6e 67 20 2a 2f 0a 20 20 20 |r reading */. | 00002290 20 69 6e 2e 72 5b 31 5d 20 3d 20 28 69 6e 74 29 | in.r[1] = (int)| 000022a0 20 74 65 6d 70 6c 61 74 65 5f 66 69 6c 65 6e 61 | template_filena| 000022b0 6d 65 3b 0a 20 20 20 20 5f 6b 65 72 6e 65 6c 5f |me;. _kernel_| 000022c0 73 77 69 28 57 69 6d 70 5f 4f 70 65 6e 54 65 6d |swi(Wimp_OpenTem| 000022d0 70 6c 61 74 65 2c 20 26 69 6e 2c 20 26 6f 75 74 |plate, &in, &out| 000022e0 29 3b 0a 0a 20 20 20 20 2f 2a 20 4e 6f 77 20 77 |);.. /* Now w| 000022f0 65 20 6c 6f 61 64 20 74 68 65 20 74 65 6d 70 6c |e load the templ| 00002300 61 74 65 20 64 61 74 61 20 2a 2f 0a 20 20 20 20 |ate data */. | 00002310 69 6e 2e 72 5b 31 5d 20 3d 20 28 69 6e 74 29 20 |in.r[1] = (int) | 00002320 6d 61 69 6e 77 69 6e 5f 62 75 66 66 65 72 3b 0a |mainwin_buffer;.| 00002330 20 20 20 20 69 6e 2e 72 5b 32 5d 20 3d 20 28 69 | in.r[2] = (i| 00002340 6e 74 29 20 6d 61 69 6e 77 69 6e 5f 77 6f 72 6b |nt) mainwin_work| 00002350 73 70 61 63 65 3b 0a 20 20 20 20 69 6e 2e 72 5b |space;. in.r[| 00002360 33 5d 20 3d 20 28 69 6e 74 29 20 6d 61 69 6e 77 |3] = (int) mainw| 00002370 69 6e 5f 77 6f 72 6b 73 70 61 63 65 20 2b 20 57 |in_workspace + W| 00002380 4f 52 4b 53 50 41 43 45 5f 53 49 5a 45 3b 0a 20 |ORKSPACE_SIZE;. | 00002390 20 20 20 69 6e 2e 72 5b 34 5d 20 3d 20 2d 31 3b | in.r[4] = -1;| 000023a0 20 2f 2a 20 4e 6f 20 66 6f 6e 74 73 20 75 73 65 | /* No fonts use| 000023b0 64 20 2a 2f 0a 20 20 20 20 69 6e 2e 72 5b 35 5d |d */. in.r[5]| 000023c0 20 3d 20 28 69 6e 74 29 20 74 65 6d 70 6c 61 74 | = (int) templat| 000023d0 65 5f 6e 61 6d 65 3b 0a 20 20 20 20 69 6e 2e 72 |e_name;. in.r| 000023e0 5b 36 5d 20 3d 20 30 3b 0a 0a 20 20 20 20 5f 6b |[6] = 0;.. _k| 000023f0 65 72 6e 65 6c 5f 73 77 69 28 57 69 6d 70 5f 4c |ernel_swi(Wimp_L| 00002400 6f 61 64 54 65 6d 70 6c 61 74 65 2c 20 26 69 6e |oadTemplate, &in| 00002410 2c 20 26 6f 75 74 29 3b 0a 20 20 20 20 69 66 28 |, &out);. if(| 00002420 6f 75 74 2e 72 5b 36 5d 20 3d 3d 20 30 29 20 7b |out.r[6] == 0) {| 00002430 0a 20 20 20 20 20 20 20 69 66 28 72 65 70 6f 72 |. if(repor| 00002440 74 5f 65 72 72 6f 72 28 31 2c 20 22 54 65 6d 70 |t_error(1, "Temp| 00002450 6c 61 74 65 20 6e 6f 74 20 66 6f 75 6e 64 21 22 |late not found!"| 00002460 2c 20 33 29 20 3d 3d 20 31 29 20 51 55 49 54 5f |, 3) == 1) QUIT_| 00002470 46 4c 41 47 20 3d 31 3b 20 20 20 20 20 20 20 0a |FLAG =1; .| 00002480 20 20 20 20 7d 0a 0a 20 20 20 20 2f 2a 20 4e 6f | }.. /* No| 00002490 77 20 77 65 27 76 65 20 66 69 6e 69 73 68 65 64 |w we've finished| 000024a0 20 72 65 61 64 69 6e 67 20 74 68 65 20 74 65 6d | reading the tem| 000024b0 70 6c 61 74 65 73 2c 20 63 6c 6f 73 65 20 74 68 |plates, close th| 000024c0 65 20 66 69 6c 65 20 2a 2f 0a 20 20 20 20 5f 6b |e file */. _k| 000024d0 65 72 6e 65 6c 5f 73 77 69 28 57 69 6d 70 5f 43 |ernel_swi(Wimp_C| 000024e0 6c 6f 73 65 54 65 6d 70 6c 61 74 65 2c 20 26 69 |loseTemplate, &i| 000024f0 6e 2c 20 26 6f 75 74 29 3b 0a 0a 20 20 20 20 2f |n, &out);.. /| 00002500 2a 20 43 72 65 61 74 65 20 74 68 65 20 77 69 6e |* Create the win| 00002510 64 6f 77 20 75 73 69 6e 67 20 74 68 65 20 64 61 |dow using the da| 00002520 74 61 20 77 65 27 76 65 20 6a 75 73 74 20 6c 6f |ta we've just lo| 00002530 61 64 65 64 20 61 6e 64 20 73 74 6f 72 65 20 74 |aded and store t| 00002540 68 65 0a 20 20 20 20 20 20 20 72 65 74 75 72 6e |he. return| 00002550 65 64 20 77 69 6e 64 6f 77 20 68 61 6e 64 6c 65 |ed window handle| 00002560 20 69 6e 20 61 20 67 6c 6f 62 61 6c 20 76 61 72 | in a global var| 00002570 69 61 62 6c 65 20 2a 2f 0a 20 20 20 20 69 6e 2e |iable */. in.| 00002580 72 5b 31 5d 20 3d 20 28 69 6e 74 29 20 6d 61 69 |r[1] = (int) mai| 00002590 6e 77 69 6e 5f 62 75 66 66 65 72 3b 0a 20 20 20 |nwin_buffer;. | 000025a0 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 28 57 69 6d | _kernel_swi(Wim| 000025b0 70 5f 43 72 65 61 74 65 57 69 6e 64 6f 77 2c 20 |p_CreateWindow, | 000025c0 26 69 6e 2c 20 26 6f 75 74 29 3b 0a 20 20 20 20 |&in, &out);. | 000025d0 4d 41 49 4e 57 49 4e 5f 48 41 4e 44 4c 45 20 3d |MAINWIN_HANDLE =| 000025e0 20 6f 75 74 2e 72 5b 30 5d 3b 0a 0a 20 20 20 20 | out.r[0];.. | 000025f0 2f 2a 20 43 6f 70 79 20 74 68 65 20 70 6f 73 69 |/* Copy the posi| 00002600 74 69 6f 6e 20 64 61 74 61 20 6f 66 20 74 68 65 |tion data of the| 00002610 20 77 69 6e 64 6f 77 20 69 6e 74 6f 20 61 20 62 | window into a b| 00002620 75 66 66 65 72 20 73 6f 20 74 68 61 74 20 77 65 |uffer so that we| 00002630 20 63 61 6e 0a 20 20 20 20 20 20 20 6f 70 65 6e | can. open| 00002640 20 74 68 65 20 77 69 6e 64 6f 77 20 61 74 20 74 | the window at t| 00002650 68 61 74 20 70 6f 73 69 74 69 6f 6e 20 2a 2f 0a |hat position */.| 00002660 20 20 20 20 77 74 6f 62 28 6f 75 74 2e 72 5b 30 | wtob(out.r[0| 00002670 5d 2c 20 6f 70 65 6e 77 69 6e 64 6f 77 5f 62 75 |], openwindow_bu| 00002680 66 66 65 72 2c 20 30 29 3b 0a 20 20 20 20 66 6f |ffer, 0);. fo| 00002690 72 28 6c 6f 6f 70 20 3d 20 30 3b 20 6c 6f 6f 70 |r(loop = 0; loop| 000026a0 20 3c 20 36 3b 20 6c 6f 6f 70 2b 2b 29 20 7b 0a | < 6; loop++) {.| 000026b0 20 20 20 20 20 20 20 77 74 6f 62 28 62 74 6f 77 | wtob(btow| 000026c0 28 6d 61 69 6e 77 69 6e 5f 62 75 66 66 65 72 2c |(mainwin_buffer,| 000026d0 20 6c 6f 6f 70 2a 34 29 2c 20 6f 70 65 6e 77 69 | loop*4), openwi| 000026e0 6e 64 6f 77 5f 62 75 66 66 65 72 2c 20 28 6c 6f |ndow_buffer, (lo| 000026f0 6f 70 2b 31 29 20 2a 20 34 29 3b 0a 20 20 20 20 |op+1) * 4);. | 00002700 7d 0a 20 20 20 20 2f 2a 20 50 75 74 74 69 6e 67 |}. /* Putting| 00002710 20 2d 31 20 68 65 72 65 20 6d 65 61 6e 73 20 74 | -1 here means t| 00002720 68 65 20 77 69 6e 64 6f 77 20 69 73 20 6f 70 65 |he window is ope| 00002730 6e 65 64 20 69 6e 20 66 72 6f 6e 74 20 6f 66 20 |ned in front of | 00002740 61 6c 6c 20 6f 74 68 65 72 73 20 2a 2f 0a 20 20 |all others */. | 00002750 20 20 77 74 6f 62 28 2d 31 2c 20 6f 70 65 6e 77 | wtob(-1, openw| 00002760 69 6e 64 6f 77 5f 62 75 66 66 65 72 2c 20 32 38 |indow_buffer, 28| 00002770 29 3b 0a 20 20 20 20 69 6e 2e 72 5b 31 5d 20 3d |);. in.r[1] =| 00002780 20 28 69 6e 74 29 20 6f 70 65 6e 77 69 6e 64 6f | (int) openwindo| 00002790 77 5f 62 75 66 66 65 72 3b 0a 20 20 20 20 5f 6b |w_buffer;. _k| 000027a0 65 72 6e 65 6c 5f 73 77 69 28 57 69 6d 70 5f 4f |ernel_swi(Wimp_O| 000027b0 70 65 6e 57 69 6e 64 6f 77 2c 20 26 69 6e 2c 20 |penWindow, &in, | 000027c0 26 6f 75 74 29 3b 0a 20 20 20 20 72 65 74 75 72 |&out);. retur| 000027d0 6e 20 30 3b 0a 7d 0a 0a 76 6f 69 64 20 6f 70 65 |n 0;.}..void ope| 000027e0 6e 77 69 6e 64 6f 77 28 75 6e 73 69 67 6e 65 64 |nwindow(unsigned| 000027f0 20 63 68 61 72 20 70 6f 6c 6c 62 6c 6f 63 6b 5b | char pollblock[| 00002800 5d 29 0a 7b 0a 20 20 20 5f 6b 65 72 6e 65 6c 5f |]).{. _kernel_| 00002810 73 77 69 5f 72 65 67 73 20 69 6e 2c 20 6f 75 74 |swi_regs in, out| 00002820 3b 0a 0a 20 20 20 69 6e 2e 72 5b 31 5d 20 3d 20 |;.. in.r[1] = | 00002830 28 69 6e 74 29 20 70 6f 6c 6c 62 6c 6f 63 6b 3b |(int) pollblock;| 00002840 0a 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 28 |. _kernel_swi(| 00002850 57 69 6d 70 5f 4f 70 65 6e 57 69 6e 64 6f 77 2c |Wimp_OpenWindow,| 00002860 20 26 69 6e 2c 20 26 6f 75 74 29 3b 0a 20 20 20 | &in, &out);. | 00002870 72 65 74 75 72 6e 3b 0a 7d 0a 0a 76 6f 69 64 20 |return;.}..void | 00002880 63 6c 6f 73 65 77 69 6e 64 6f 77 28 75 6e 73 69 |closewindow(unsi| 00002890 67 6e 65 64 20 63 68 61 72 20 70 6f 6c 6c 62 6c |gned char pollbl| 000028a0 6f 63 6b 5b 5d 29 0a 7b 0a 20 20 20 5f 6b 65 72 |ock[]).{. _ker| 000028b0 6e 65 6c 5f 73 77 69 5f 72 65 67 73 20 69 6e 2c |nel_swi_regs in,| 000028c0 20 6f 75 74 3b 0a 0a 20 20 20 69 6e 2e 72 5b 31 | out;.. in.r[1| 000028d0 5d 20 3d 20 28 69 6e 74 29 20 70 6f 6c 6c 62 6c |] = (int) pollbl| 000028e0 6f 63 6b 3b 0a 20 20 20 5f 6b 65 72 6e 65 6c 5f |ock;. _kernel_| 000028f0 73 77 69 28 57 69 6d 70 5f 43 6c 6f 73 65 57 69 |swi(Wimp_CloseWi| 00002900 6e 64 6f 77 2c 20 26 69 6e 2c 20 26 6f 75 74 29 |ndow, &in, &out)| 00002910 3b 0a 20 20 20 72 65 74 75 72 6e 3b 0a 7d 0a 0a |;. return;.}..| 00002920 63 68 61 72 20 2a 0a 67 65 74 69 63 6f 6e 74 65 |char *.geticonte| 00002930 78 74 70 6f 69 6e 74 65 72 28 75 6e 73 69 67 6e |xtpointer(unsign| 00002940 65 64 20 6c 6f 6e 67 20 69 6e 74 20 77 69 6e 68 |ed long int winh| 00002950 64 6c 2c 20 75 6e 73 69 67 6e 65 64 20 6c 6f 6e |dl, unsigned lon| 00002960 67 20 69 6e 74 20 69 63 6f 6e 68 64 6c 29 0a 7b |g int iconhdl).{| 00002970 0a 20 20 20 2f 2a 20 54 68 69 73 20 70 72 6f 63 |. /* This proc| 00002980 65 64 75 72 65 20 69 6e 74 65 72 72 6f 67 61 74 |edure interrogat| 00002990 65 73 20 61 6e 20 69 63 6f 6e 20 74 6f 20 64 65 |es an icon to de| 000029a0 74 65 72 6d 69 6e 65 20 74 68 65 20 61 64 64 72 |termine the addr| 000029b0 65 73 73 20 77 68 65 72 65 20 69 74 73 0a 20 20 |ess where its. | 000029c0 20 20 20 20 69 6e 64 69 72 65 63 74 65 64 20 74 | indirected t| 000029d0 65 78 74 20 64 61 74 61 20 69 73 20 73 74 6f 72 |ext data is stor| 000029e0 65 64 20 69 6e 20 6d 65 6d 6f 72 79 2c 20 61 6e |ed in memory, an| 000029f0 64 20 72 65 74 75 72 6e 73 20 69 74 20 2a 2f 0a |d returns it */.| 00002a00 0a 20 20 20 75 6e 73 69 67 6e 65 64 20 63 68 61 |. unsigned cha| 00002a10 72 20 74 65 6d 70 5f 62 75 66 66 65 72 5b 32 35 |r temp_buffer[25| 00002a20 35 5d 3b 0a 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 |5];. _kernel_s| 00002a30 77 69 5f 72 65 67 73 20 69 6e 2c 20 6f 75 74 3b |wi_regs in, out;| 00002a40 0a 20 20 20 63 68 61 72 20 2a 72 65 73 75 6c 74 |. char *result| 00002a50 3b 0a 0a 20 20 20 77 74 6f 62 28 77 69 6e 68 64 |;.. wtob(winhd| 00002a60 6c 2c 20 74 65 6d 70 5f 62 75 66 66 65 72 2c 20 |l, temp_buffer, | 00002a70 30 29 3b 0a 20 20 20 77 74 6f 62 28 69 63 6f 6e |0);. wtob(icon| 00002a80 68 64 6c 2c 20 74 65 6d 70 5f 62 75 66 66 65 72 |hdl, temp_buffer| 00002a90 2c 20 34 29 3b 0a 0a 20 20 20 69 6e 2e 72 5b 31 |, 4);.. in.r[1| 00002aa0 5d 20 3d 20 28 69 6e 74 29 20 74 65 6d 70 5f 62 |] = (int) temp_b| 00002ab0 75 66 66 65 72 3b 0a 20 20 20 5f 6b 65 72 6e 65 |uffer;. _kerne| 00002ac0 6c 5f 73 77 69 28 57 69 6d 70 5f 47 65 74 49 63 |l_swi(Wimp_GetIc| 00002ad0 6f 6e 53 74 61 74 65 2c 20 26 69 6e 2c 20 26 6f |onState, &in, &o| 00002ae0 75 74 29 3b 0a 0a 20 20 20 72 65 73 75 6c 74 20 |ut);.. result | 00002af0 3d 20 28 63 68 61 72 20 2a 29 20 62 74 6f 77 28 |= (char *) btow(| 00002b00 74 65 6d 70 5f 62 75 66 66 65 72 2c 20 32 38 29 |temp_buffer, 28)| 00002b10 3b 0a 20 20 20 72 65 74 75 72 6e 20 72 65 73 75 |;. return resu| 00002b20 6c 74 3b 0a 7d 0a 0a 76 6f 69 64 20 69 63 6f 6e |lt;.}..void icon| 00002b30 63 68 61 6e 67 65 28 63 68 61 72 20 2a 74 65 78 |change(char *tex| 00002b40 74 2c 20 75 6e 73 69 67 6e 65 64 20 6c 6f 6e 67 |t, unsigned long| 00002b50 20 69 6e 74 20 77 69 6e 5f 68 2c 20 75 6e 73 69 | int win_h, unsi| 00002b60 67 6e 65 64 20 6c 6f 6e 67 20 69 6e 74 20 69 63 |gned long int ic| 00002b70 6f 6e 5f 68 29 0a 7b 0a 20 20 20 5f 6b 65 72 6e |on_h).{. _kern| 00002b80 65 6c 5f 73 77 69 5f 72 65 67 73 20 69 6e 2c 20 |el_swi_regs in, | 00002b90 6f 75 74 3b 0a 20 20 20 63 68 61 72 20 2a 74 70 |out;. char *tp| 00002ba0 6f 69 6e 74 65 72 3b 0a 20 20 20 75 6e 73 69 67 |ointer;. unsig| 00002bb0 6e 65 64 20 63 68 61 72 20 74 65 6d 70 5f 62 75 |ned char temp_bu| 00002bc0 66 66 65 72 5b 32 35 35 5d 3b 0a 0a 20 20 20 2f |ffer[255];.. /| 00002bd0 2a 20 46 69 6e 64 20 6f 75 74 20 77 68 65 72 65 |* Find out where| 00002be0 20 74 68 65 20 69 63 6f 6e 27 73 20 69 6e 64 69 | the icon's indi| 00002bf0 72 65 63 74 65 64 20 74 65 78 74 20 69 73 20 73 |rected text is s| 00002c00 74 6f 72 65 64 20 69 6e 20 6d 65 6d 6f 72 79 20 |tored in memory | 00002c10 61 6e 64 20 63 6f 70 79 0a 20 20 20 20 20 20 61 |and copy. a| 00002c20 20 6e 65 77 20 73 74 72 69 6e 67 20 74 6f 20 69 | new string to i| 00002c30 74 20 2a 2f 0a 20 20 20 74 70 6f 69 6e 74 65 72 |t */. tpointer| 00002c40 20 3d 20 67 65 74 69 63 6f 6e 74 65 78 74 70 6f | = geticontextpo| 00002c50 69 6e 74 65 72 28 77 69 6e 5f 68 2c 20 69 63 6f |inter(win_h, ico| 00002c60 6e 5f 68 29 3b 0a 20 20 20 73 74 72 63 70 79 28 |n_h);. strcpy(| 00002c70 74 70 6f 69 6e 74 65 72 2c 20 74 65 78 74 29 3b |tpointer, text);| 00002c80 0a 0a 20 20 20 2f 2a 20 4e 6f 77 20 77 65 20 6e |.. /* Now we n| 00002c90 65 65 64 20 74 6f 20 69 6e 66 6f 72 6d 20 74 68 |eed to inform th| 00002ca0 65 20 57 49 4d 50 20 74 68 61 74 20 74 68 65 20 |e WIMP that the | 00002cb0 69 63 6f 6e 20 6e 65 65 64 73 20 72 65 64 72 61 |icon needs redra| 00002cc0 77 69 6e 67 20 62 79 20 73 65 74 74 69 6e 67 0a |wing by setting.| 00002cd0 20 20 20 20 20 20 74 68 65 20 69 63 6f 6e 20 66 | the icon f| 00002ce0 6c 61 67 73 20 2d 20 77 65 20 64 6f 6e 27 74 20 |lags - we don't | 00002cf0 61 63 74 75 61 6c 6c 79 20 63 68 61 6e 67 65 20 |actually change | 00002d00 74 68 65 6d 20 77 69 74 68 20 74 68 69 73 20 63 |them with this c| 00002d10 61 6c 6c 2c 20 62 75 74 20 74 68 69 73 0a 20 20 |all, but this. | 00002d20 20 20 20 20 73 70 75 72 73 20 74 68 65 20 57 49 | spurs the WI| 00002d30 4d 50 20 69 6e 74 6f 20 61 63 74 69 6f 6e 20 2a |MP into action *| 00002d40 2f 0a 0a 20 20 20 77 74 6f 62 28 77 69 6e 5f 68 |/.. wtob(win_h| 00002d50 2c 20 74 65 6d 70 5f 62 75 66 66 65 72 2c 20 30 |, temp_buffer, 0| 00002d60 29 3b 0a 20 20 20 77 74 6f 62 28 69 63 6f 6e 5f |);. wtob(icon_| 00002d70 68 2c 20 74 65 6d 70 5f 62 75 66 66 65 72 2c 20 |h, temp_buffer, | 00002d80 34 29 3b 0a 20 20 20 77 74 6f 62 28 30 2c 20 74 |4);. wtob(0, t| 00002d90 65 6d 70 5f 62 75 66 66 65 72 2c 20 38 29 3b 0a |emp_buffer, 8);.| 00002da0 20 20 20 77 74 6f 62 28 30 2c 20 74 65 6d 70 5f | wtob(0, temp_| 00002db0 62 75 66 66 65 72 2c 20 31 32 29 3b 0a 0a 20 20 |buffer, 12);.. | 00002dc0 20 69 6e 2e 72 5b 31 5d 20 3d 20 28 69 6e 74 29 | in.r[1] = (int)| 00002dd0 20 74 65 6d 70 5f 62 75 66 66 65 72 3b 0a 0a 20 | temp_buffer;.. | 00002de0 20 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 28 57 69 | _kernel_swi(Wi| 00002df0 6d 70 5f 53 65 74 49 63 6f 6e 53 74 61 74 65 2c |mp_SetIconState,| 00002e00 20 26 69 6e 2c 20 26 6f 75 74 29 3b 0a 20 20 20 | &in, &out);. | 00002e10 72 65 74 75 72 6e 3b 0a 7d 0a |return;.}.| 00002e1a
C/!WimpC/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 41 70 72 69 6c 20 31 39 39 36 |ser - April 1996| 000000b0 20 2a 2f 0a 0a 23 69 6e 63 6c 75 64 65 20 3c 73 | */..#include <s| 000000c0 74 64 69 6f 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 |tdio.h>.#include| 000000d0 20 3c 73 74 72 69 6e 67 2e 68 3e 0a 23 69 6e 63 | <string.h>.#inc| 000000e0 6c 75 64 65 20 22 73 77 69 73 2e 68 22 0a 23 69 |lude "swis.h".#i| 000000f0 6e 63 6c 75 64 65 20 22 6b 65 72 6e 65 6c 2e 68 |nclude "kernel.h| 00000100 22 0a 0a 2f 2a 20 57 65 20 61 6c 73 6f 20 64 65 |"../* We also de| 00000110 66 69 6e 65 20 61 20 70 6f 6c 6c 20 6d 61 73 6b |fine a poll mask| 00000120 20 68 65 72 65 20 74 6f 20 74 65 6c 6c 20 74 68 | here to tell th| 00000130 65 20 57 49 4d 50 20 61 62 6f 75 74 20 61 6e 79 |e WIMP about any| 00000140 20 65 76 65 6e 74 73 20 77 65 27 72 65 20 6e 6f | events we're no| 00000150 74 0a 20 20 20 69 6e 74 65 72 65 72 65 73 74 65 |t. interereste| 00000160 64 20 69 6e 20 2a 2f 0a 0a 23 64 65 66 69 6e 65 |d in */..#define| 00000170 20 50 4f 4c 4c 5f 4d 41 53 4b 20 31 0a 23 64 65 | POLL_MASK 1.#de| 00000180 66 69 6e 65 20 57 4f 52 4b 53 50 41 43 45 5f 53 |fine WORKSPACE_S| 00000190 49 5a 45 20 31 30 32 34 0a 23 64 65 66 69 6e 65 |IZE 1024.#define| 000001a0 20 4d 45 4e 55 5f 53 49 5a 45 20 31 30 32 34 0a | MENU_SIZE 1024.| 000001b0 0a 2f 2a 20 49 66 20 77 65 20 73 65 74 20 51 55 |./* If we set QU| 000001c0 49 54 5f 46 4c 41 47 20 75 70 20 61 73 20 61 20 |IT_FLAG up as a | 000001d0 67 6c 6f 62 61 6c 20 76 61 72 69 61 62 6c 65 2c |global variable,| 000001e0 20 69 74 20 6d 65 61 6e 73 20 74 68 61 74 20 77 | it means that w| 000001f0 65 20 63 61 6e 20 63 68 61 6e 67 65 20 69 74 0a |e can change it.| 00000200 20 20 20 61 6e 79 77 68 65 72 65 20 77 69 74 68 | anywhere with| 00000210 69 6e 20 74 68 65 20 70 72 6f 67 72 61 6d 20 61 |in the program a| 00000220 6e 64 20 73 68 75 74 20 74 68 69 6e 67 73 20 64 |nd shut things d| 00000230 6f 77 6e 20 6e 65 78 74 20 74 69 6d 65 20 77 65 |own next time we| 00000240 20 65 6e 64 20 74 68 65 0a 20 20 20 70 6f 6c 6c | end the. poll| 00000250 69 6e 67 20 6c 6f 6f 70 20 2a 2f 0a 0a 69 6e 74 |ing loop */..int| 00000260 20 51 55 49 54 5f 46 4c 41 47 20 3d 20 30 3b 0a | QUIT_FLAG = 0;.| 00000270 69 6e 74 20 4d 41 49 4e 57 49 4e 5f 48 41 4e 44 |int MAINWIN_HAND| 00000280 4c 45 20 3d 20 30 3b 0a 69 6e 74 20 44 49 53 50 |LE = 0;.int DISP| 00000290 4c 41 59 5f 49 43 4f 4e 20 3d 20 31 3b 0a 63 68 |LAY_ICON = 1;.ch| 000002a0 61 72 20 61 70 70 6e 61 6d 65 5b 5d 20 3d 20 22 |ar appname[] = "| 000002b0 57 49 4d 50 43 20 45 78 61 6d 70 6c 65 22 3b 0a |WIMPC Example";.| 000002c0 75 6e 73 69 67 6e 65 64 20 63 68 61 72 20 6d 61 |unsigned char ma| 000002d0 69 6e 77 69 6e 5f 62 75 66 66 65 72 5b 57 4f 52 |inwin_buffer[WOR| 000002e0 4b 53 50 41 43 45 5f 53 49 5a 45 5d 3b 0a 75 6e |KSPACE_SIZE];.un| 000002f0 73 69 67 6e 65 64 20 63 68 61 72 20 6d 61 69 6e |signed char main| 00000300 77 69 6e 5f 77 6f 72 6b 73 70 61 63 65 5b 57 4f |win_workspace[WO| 00000310 52 4b 53 50 41 43 45 5f 53 49 5a 45 5d 3b 0a 75 |RKSPACE_SIZE];.u| 00000320 6e 73 69 67 6e 65 64 20 63 68 61 72 20 6d 61 69 |nsigned char mai| 00000330 6e 6d 65 6e 75 5b 4d 45 4e 55 5f 53 49 5a 45 5d |nmenu[MENU_SIZE]| 00000340 3b 0a 0a 2f 2a 20 46 75 6e 63 74 69 6f 6e 20 70 |;../* Function p| 00000350 72 6f 74 6f 74 79 70 69 6e 67 20 2a 2f 0a 0a 69 |rototyping */..i| 00000360 6e 74 20 20 20 20 20 20 6d 61 69 6e 28 76 6f 69 |nt main(voi| 00000370 64 29 3b 0a 76 6f 69 64 20 20 20 20 20 77 69 6d |d);.void wim| 00000380 70 6d 73 67 28 69 6e 74 2c 20 75 6e 73 69 67 6e |pmsg(int, unsign| 00000390 65 64 20 63 68 61 72 5b 5d 29 3b 0a 75 6e 73 69 |ed char[]);.unsi| 000003a0 67 6e 65 64 20 6c 6f 6e 67 20 69 6e 74 20 62 74 |gned long int bt| 000003b0 6f 77 28 75 6e 73 69 67 6e 65 64 20 63 68 61 72 |ow(unsigned char| 000003c0 5b 5d 2c 20 69 6e 74 29 3b 0a 76 6f 69 64 20 20 |[], int);.void | 000003d0 20 20 20 77 74 6f 62 28 75 6e 73 69 67 6e 65 64 | wtob(unsigned| 000003e0 20 6c 6f 6e 67 20 69 6e 74 2c 20 75 6e 73 69 67 | long int, unsig| 000003f0 6e 65 64 20 63 68 61 72 5b 5d 2c 20 69 6e 74 29 |ned char[], int)| 00000400 3b 0a 76 6f 69 64 20 20 20 20 20 6d 6f 75 73 65 |;.void mouse| 00000410 63 6c 69 63 6b 28 75 6e 73 69 67 6e 65 64 20 63 |click(unsigned c| 00000420 68 61 72 5b 5d 29 3b 0a 76 6f 69 64 20 20 20 20 |har[]);.void | 00000430 20 6d 65 6e 75 73 65 6c 65 63 74 69 6f 6e 28 75 | menuselection(u| 00000440 6e 73 69 67 6e 65 64 20 63 68 61 72 5b 5d 29 3b |nsigned char[]);| 00000450 0a 69 6e 74 20 20 20 20 20 20 72 65 70 6f 72 74 |.int report| 00000460 5f 65 72 72 6f 72 28 69 6e 74 2c 20 63 68 61 72 |_error(int, char| 00000470 5b 5d 2c 20 69 6e 74 29 3b 0a 69 6e 74 20 20 20 |[], int);.int | 00000480 20 20 20 6c 6f 61 64 5f 74 65 6d 70 6c 61 74 65 | load_template| 00000490 73 28 76 6f 69 64 29 3b 0a 76 6f 69 64 20 20 20 |s(void);.void | 000004a0 20 20 6f 70 65 6e 77 69 6e 64 6f 77 28 75 6e 73 | openwindow(uns| 000004b0 69 67 6e 65 64 20 63 68 61 72 5b 5d 29 3b 0a 76 |igned char[]);.v| 000004c0 6f 69 64 20 20 20 20 20 63 6c 6f 73 65 77 69 6e |oid closewin| 000004d0 64 6f 77 28 75 6e 73 69 67 6e 65 64 20 63 68 61 |dow(unsigned cha| 000004e0 72 5b 5d 29 3b 0a 63 68 61 72 20 2a 20 20 20 67 |r[]);.char * g| 000004f0 65 74 69 63 6f 6e 74 65 78 74 70 6f 69 6e 74 65 |eticontextpointe| 00000500 72 28 75 6e 73 69 67 6e 65 64 20 6c 6f 6e 67 20 |r(unsigned long | 00000510 69 6e 74 2c 20 75 6e 73 69 67 6e 65 64 20 6c 6f |int, unsigned lo| 00000520 6e 67 20 69 6e 74 29 3b 0a 76 6f 69 64 20 20 20 |ng int);.void | 00000530 20 20 69 63 6f 6e 63 68 61 6e 67 65 28 63 68 61 | iconchange(cha| 00000540 72 20 2a 2c 20 75 6e 73 69 67 6e 65 64 20 6c 6f |r *, unsigned lo| 00000550 6e 67 20 69 6e 74 2c 20 75 6e 73 69 67 6e 65 64 |ng int, unsigned| 00000560 20 6c 6f 6e 67 20 69 6e 74 29 3b 0a 0a 2f 2a 20 | long int);../* | 00000570 50 72 6f 67 72 61 6d 20 66 75 6e 63 74 69 6f 6e |Program function| 00000580 73 20 2a 2f 0a 0a 69 6e 74 0a 6d 61 69 6e 28 76 |s */..int.main(v| 00000590 6f 69 64 29 20 7b 0a 20 20 20 20 69 6e 74 20 74 |oid) {. int t| 000005a0 61 73 6b 5f 68 61 6e 64 6c 65 3b 0a 20 20 20 20 |ask_handle;. | 000005b0 75 6e 73 69 67 6e 65 64 20 63 68 61 72 20 20 20 |unsigned char | 000005c0 70 6f 6c 6c 62 6c 6f 63 6b 5b 32 35 37 5d 3b 0a |pollblock[257];.| 000005d0 20 20 20 20 2f 2a 20 65 73 73 65 6e 74 69 61 6c | /* essential| 000005e0 6c 79 20 61 20 62 79 74 65 20 61 72 72 61 79 20 |ly a byte array | 000005f0 6c 61 72 67 65 20 65 6e 6f 75 67 68 20 66 6f 72 |large enough for| 00000600 20 6f 75 72 20 70 6f 6c 6c 69 6e 67 20 62 6c 6f | our polling blo| 00000610 63 6b 20 2a 2f 0a 0a 20 20 20 20 75 6e 73 69 67 |ck */.. unsig| 00000620 6e 65 64 20 63 68 61 72 20 20 69 63 6f 6e 62 6c |ned char iconbl| 00000630 6f 63 6b 5b 34 30 5d 3b 0a 20 20 20 20 69 6e 74 |ock[40];. int| 00000640 20 69 62 61 72 5f 69 63 6f 6e 5f 68 61 6e 64 6c | ibar_icon_handl| 00000650 65 3b 0a 20 20 20 20 2f 2a 20 41 20 62 6c 6f 63 |e;. /* A bloc| 00000660 6b 20 74 6f 20 68 6f 6c 64 20 6f 75 72 20 69 63 |k to hold our ic| 00000670 6f 6e 20 64 61 74 61 2c 20 61 6e 64 20 61 20 76 |on data, and a v| 00000680 61 72 69 61 62 6c 65 20 74 6f 20 73 74 6f 72 65 |ariable to store| 00000690 20 69 74 73 20 68 61 6e 64 6c 65 20 2a 2f 0a 0a | its handle */..| 000006a0 20 20 20 20 69 6e 74 20 70 6f 6c 6c 72 65 73 75 | int pollresu| 000006b0 6c 74 3b 0a 20 20 20 20 5f 6b 65 72 6e 65 6c 5f |lt;. _kernel_| 000006c0 73 77 69 5f 72 65 67 73 20 20 20 20 72 65 67 73 |swi_regs regs| 000006d0 5f 69 6e 2c 20 72 65 67 73 5f 6f 75 74 3b 0a 20 |_in, regs_out;. | 000006e0 20 20 20 63 68 61 72 20 69 62 61 72 5f 73 70 72 | char ibar_spr| 000006f0 6e 61 6d 65 5b 5d 20 3d 20 22 21 77 69 6d 70 63 |name[] = "!wimpc| 00000700 22 3b 0a 0a 20 20 20 20 2f 2a 20 54 68 65 20 61 |";.. /* The a| 00000710 62 6f 76 65 20 6c 69 6e 65 20 73 70 65 63 69 66 |bove line specif| 00000720 69 65 73 20 74 68 65 20 6e 61 6d 65 20 6f 66 20 |ies the name of | 00000730 74 68 65 20 73 70 72 69 74 65 20 69 6e 20 74 68 |the sprite in th| 00000740 65 20 77 69 6d 70 20 70 6f 6f 6c 20 74 68 61 74 |e wimp pool that| 00000750 0a 20 20 20 20 20 20 20 77 65 20 61 72 65 20 74 |. we are t| 00000760 6f 20 75 73 65 20 6f 6e 20 74 68 65 20 69 63 6f |o use on the ico| 00000770 6e 20 62 61 72 20 2a 2f 0a 0a 20 20 20 20 6c 6f |n bar */.. lo| 00000780 6e 67 20 69 6e 74 20 20 20 20 6d 73 67 6c 69 73 |ng int msglis| 00000790 74 5b 31 5d 20 3d 20 7b 30 7d 3b 0a 0a 20 20 20 |t[1] = {0};.. | 000007a0 20 2f 2a 20 4e 6f 77 20 74 6f 20 69 6e 69 74 69 | /* Now to initi| 000007b0 61 6c 69 73 65 20 6f 75 72 73 65 6c 76 65 73 20 |alise ourselves | 000007c0 61 73 20 61 20 74 61 73 6b 20 2a 2f 0a 20 20 20 |as a task */. | 000007d0 20 72 65 67 73 5f 69 6e 2e 72 5b 30 5d 20 3d 20 | regs_in.r[0] = | 000007e0 33 31 30 3b 0a 20 20 20 20 72 65 67 73 5f 69 6e |310;. regs_in| 000007f0 2e 72 5b 31 5d 20 3d 20 2a 28 69 6e 74 20 2a 29 |.r[1] = *(int *)| 00000800 22 54 41 53 4b 22 3b 0a 20 20 20 20 72 65 67 73 |"TASK";. regs| 00000810 5f 69 6e 2e 72 5b 32 5d 20 3d 20 28 69 6e 74 29 |_in.r[2] = (int)| 00000820 20 61 70 70 6e 61 6d 65 3b 0a 20 20 20 20 72 65 | appname;. re| 00000830 67 73 5f 69 6e 2e 72 5b 33 5d 20 3d 20 28 69 6e |gs_in.r[3] = (in| 00000840 74 29 20 6d 73 67 6c 69 73 74 3b 0a 20 20 20 20 |t) msglist;. | 00000850 2f 2a 20 57 65 20 6e 65 65 64 20 74 6f 20 73 75 |/* We need to su| 00000860 70 70 6c 79 20 6f 75 72 20 63 68 6f 73 65 6e 20 |pply our chosen | 00000870 52 49 53 43 20 4f 53 20 76 65 72 73 69 6f 6e 20 |RISC OS version | 00000880 6e 75 6d 62 65 72 2c 20 74 68 65 20 22 54 41 53 |number, the "TAS| 00000890 4b 22 0a 20 20 20 20 20 20 20 69 64 65 6e 74 69 |K". identi| 000008a0 66 69 65 72 20 74 6f 20 70 72 6f 76 65 20 77 65 |fier to prove we| 000008b0 27 72 65 20 61 20 6d 75 6c 74 69 74 61 73 6b 69 |'re a multitaski| 000008c0 6e 67 20 61 70 70 6c 69 63 61 74 69 6f 6e 2c 20 |ng application, | 000008d0 61 20 70 6f 69 6e 74 65 72 20 74 6f 0a 20 20 20 |a pointer to. | 000008e0 20 20 20 20 6f 75 72 20 61 70 70 6c 69 63 61 74 | our applicat| 000008f0 69 6f 6e 20 6e 61 6d 65 20 61 6e 64 20 61 20 70 |ion name and a p| 00000900 6f 69 6e 74 65 72 20 74 6f 20 61 20 6d 65 73 73 |ointer to a mess| 00000910 61 67 65 20 6c 69 73 74 20 2d 20 63 6f 6e 76 65 |age list - conve| 00000920 72 74 65 64 20 74 6f 0a 20 20 20 20 20 20 20 69 |rted to. i| 00000930 6e 74 65 67 65 72 20 66 6f 72 6d 61 74 20 61 73 |nteger format as| 00000940 20 6e 65 63 65 73 73 61 72 79 20 2a 2f 0a 0a 20 | necessary */.. | 00000950 20 20 20 2f 2a 20 6e 6f 77 20 74 6f 20 70 65 72 | /* now to per| 00000960 66 6f 72 6d 20 74 68 65 20 61 63 74 75 61 6c 20 |form the actual | 00000970 53 57 49 20 63 61 6c 6c 20 2a 2f 0a 20 20 20 20 |SWI call */. | 00000980 5f 6b 65 72 6e 65 6c 5f 73 77 69 28 57 69 6d 70 |_kernel_swi(Wimp| 00000990 5f 49 6e 69 74 69 61 6c 69 73 65 2c 20 26 72 65 |_Initialise, &re| 000009a0 67 73 5f 69 6e 2c 20 26 72 65 67 73 5f 6f 75 74 |gs_in, ®s_out| 000009b0 29 3b 0a 20 20 20 20 74 61 73 6b 5f 68 61 6e 64 |);. task_hand| 000009c0 6c 65 20 3d 20 72 65 67 73 5f 6f 75 74 2e 72 5b |le = regs_out.r[| 000009d0 31 5d 3b 20 2f 2a 20 64 65 74 65 72 6d 69 6e 65 |1]; /* determine| 000009e0 20 6f 75 72 20 74 61 73 6b 20 68 61 6e 64 6c 65 | our task handle| 000009f0 20 66 6f 72 20 6c 61 74 65 72 20 75 73 65 20 2a | for later use *| 00000a00 2f 0a 0a 20 20 20 20 2f 2a 20 4e 6f 77 2c 20 77 |/.. /* Now, w| 00000a10 65 27 6c 6c 20 70 75 74 20 61 6e 20 69 63 6f 6e |e'll put an icon| 00000a20 20 6f 6e 20 74 68 65 20 69 63 6f 6e 20 62 61 72 | on the icon bar| 00000a30 20 2d 20 77 65 20 6e 65 65 64 20 74 6f 20 68 61 | - we need to ha| 00000a40 76 65 20 64 65 66 69 6e 65 64 20 61 6e 0a 20 20 |ve defined an. | 00000a50 20 20 20 20 20 69 63 6f 6e 20 62 6c 6f 63 6b 2c | icon block,| 00000a60 20 77 68 6f 73 65 20 61 64 64 72 65 73 73 20 77 | whose address w| 00000a70 65 20 70 61 73 73 20 69 6e 20 52 31 20 2a 2f 0a |e pass in R1 */.| 00000a80 0a 20 20 20 20 77 74 6f 62 28 2d 31 2c 20 69 63 |. wtob(-1, ic| 00000a90 6f 6e 62 6c 6f 63 6b 2c 20 30 29 3b 20 2f 2a 20 |onblock, 0); /* | 00000aa0 53 70 65 63 69 66 79 20 70 6f 73 69 74 69 6f 6e |Specify position| 00000ab0 20 6f 6e 20 74 68 65 20 69 63 6f 6e 20 62 61 72 | on the icon bar| 00000ac0 20 28 74 68 65 20 72 69 67 68 74 29 20 2a 2f 0a | (the right) */.| 00000ad0 20 20 20 20 77 74 6f 62 28 30 2c 20 69 63 6f 6e | wtob(0, icon| 00000ae0 62 6c 6f 63 6b 2c 20 34 29 3b 20 2f 2a 20 54 68 |block, 4); /* Th| 00000af0 65 73 65 20 66 6f 75 72 20 6c 69 6e 65 73 20 67 |ese four lines g| 00000b00 69 76 65 20 74 68 65 20 62 6f 75 6e 64 69 6e 67 |ive the bounding| 00000b10 20 62 6f 78 20 6f 66 20 74 68 65 20 2a 2f 0a 20 | box of the */. | 00000b20 20 20 20 77 74 6f 62 28 30 2c 20 69 63 6f 6e 62 | wtob(0, iconb| 00000b30 6c 6f 63 6b 2c 20 38 29 3b 20 2f 2a 20 69 63 6f |lock, 8); /* ico| 00000b40 6e 20 2d 20 6d 69 6e 20 78 2c 20 6d 69 6e 20 79 |n - min x, min y| 00000b50 2c 20 6d 61 78 20 78 2c 20 6d 61 78 20 79 20 2a |, max x, max y *| 00000b60 2f 0a 20 20 20 20 77 74 6f 62 28 37 32 2c 20 69 |/. wtob(72, i| 00000b70 63 6f 6e 62 6c 6f 63 6b 2c 20 31 32 29 3b 0a 20 |conblock, 12);. | 00000b80 20 20 20 77 74 6f 62 28 37 32 2c 20 69 63 6f 6e | wtob(72, icon| 00000b90 62 6c 6f 63 6b 2c 20 31 36 29 3b 0a 20 20 20 20 |block, 16);. | 00000ba0 77 74 6f 62 28 31 32 33 31 34 2c 20 69 63 6f 6e |wtob(12314, icon| 00000bb0 62 6c 6f 63 6b 2c 20 32 30 29 3b 0a 20 20 20 20 |block, 20);. | 00000bc0 2f 2a 20 73 65 74 20 62 69 74 73 20 31 2c 20 33 |/* set bits 1, 3| 00000bd0 2c 20 34 2c 20 31 32 2c 20 31 33 20 6f 66 20 69 |, 4, 12, 13 of i| 00000be0 63 6f 6e 20 66 6c 61 67 73 20 2d 20 62 69 74 20 |con flags - bit | 00000bf0 31 20 2d 20 74 68 65 20 69 63 6f 6e 20 69 73 20 |1 - the icon is | 00000c00 61 20 73 70 72 69 74 65 3b 0a 20 20 20 20 62 69 |a sprite;. bi| 00000c10 74 73 20 33 2c 20 34 20 63 65 6e 74 72 65 20 74 |ts 3, 4 centre t| 00000c20 68 65 20 73 70 72 69 74 65 20 69 6e 20 74 68 65 |he sprite in the| 00000c30 20 62 6f 75 6e 64 69 6e 67 20 62 6f 78 3b 20 62 | bounding box; b| 00000c40 69 74 73 20 31 32 20 61 6e 64 20 31 33 20 69 6e |its 12 and 13 in| 00000c50 66 6f 72 6d 20 74 68 65 0a 20 20 20 20 57 49 4d |form the. WIM| 00000c60 50 20 74 6f 20 6c 65 74 20 75 73 20 6b 6e 6f 77 |P to let us know| 00000c70 20 77 68 65 6e 20 6f 75 72 20 69 63 6f 6e 20 69 | when our icon i| 00000c80 73 20 63 6c 69 63 6b 65 64 20 6f 6e 2c 20 62 79 |s clicked on, by| 00000c90 20 70 61 73 73 69 6e 67 20 75 73 20 61 0a 20 20 | passing us a. | 00000ca0 20 20 4d 6f 75 73 65 5f 43 6c 69 63 6b 20 65 76 | Mouse_Click ev| 00000cb0 65 6e 74 20 2a 2f 0a 0a 20 20 20 20 73 74 72 63 |ent */.. strc| 00000cc0 70 79 28 20 28 63 68 61 72 20 2a 29 20 26 69 63 |py( (char *) &ic| 00000cd0 6f 6e 62 6c 6f 63 6b 5b 32 34 5d 2c 20 69 62 61 |onblock[24], iba| 00000ce0 72 5f 73 70 72 6e 61 6d 65 29 3b 0a 20 20 20 20 |r_sprname);. | 00000cf0 2f 2a 20 46 69 6e 61 6c 6c 79 2c 20 63 6f 70 79 |/* Finally, copy| 00000d00 20 74 68 65 20 6e 61 6d 65 20 6f 66 20 74 68 65 | the name of the| 00000d10 20 73 70 72 69 74 65 20 77 65 20 61 72 65 20 74 | sprite we are t| 00000d20 6f 20 75 73 65 20 69 6e 74 6f 20 74 68 65 20 64 |o use into the d| 00000d30 61 74 61 62 6c 6f 63 6b 3b 0a 20 20 20 20 74 68 |atablock;. th| 00000d40 69 73 20 6d 75 73 74 20 62 65 20 74 65 72 6d 69 |is must be termi| 00000d50 6e 61 74 65 64 20 77 69 74 68 20 61 20 63 6f 6e |nated with a con| 00000d60 74 72 6f 6c 20 63 68 61 72 61 63 74 65 72 20 2a |trol character *| 00000d70 2f 0a 0a 20 20 20 20 72 65 67 73 5f 69 6e 2e 72 |/.. regs_in.r| 00000d80 5b 30 5d 20 3d 20 30 3b 20 2f 2a 20 73 65 74 20 |[0] = 0; /* set | 00000d90 74 68 65 20 69 63 6f 6e 27 73 20 70 72 69 6f 72 |the icon's prior| 00000da0 69 74 79 20 2a 2f 0a 20 20 20 20 72 65 67 73 5f |ity */. regs_| 00000db0 69 6e 2e 72 5b 31 5d 20 3d 20 28 69 6e 74 29 20 |in.r[1] = (int) | 00000dc0 69 63 6f 6e 62 6c 6f 63 6b 3b 0a 20 20 20 20 5f |iconblock;. _| 00000dd0 6b 65 72 6e 65 6c 5f 73 77 69 28 57 69 6d 70 5f |kernel_swi(Wimp_| 00000de0 43 72 65 61 74 65 49 63 6f 6e 2c 20 26 72 65 67 |CreateIcon, ®| 00000df0 73 5f 69 6e 2c 20 26 72 65 67 73 5f 6f 75 74 29 |s_in, ®s_out)| 00000e00 3b 0a 20 20 20 20 69 62 61 72 5f 69 63 6f 6e 5f |;. ibar_icon_| 00000e10 68 61 6e 64 6c 65 20 3d 20 72 65 67 73 5f 6f 75 |handle = regs_ou| 00000e20 74 2e 72 5b 30 5d 3b 0a 0a 20 20 20 20 2f 2a 20 |t.r[0];.. /* | 00000e30 4e 6f 77 20 6f 70 65 6e 20 61 20 74 65 6d 70 6c |Now open a templ| 00000e40 61 74 65 20 66 69 6c 65 20 72 65 61 64 79 20 66 |ate file ready f| 00000e50 6f 72 20 6c 6f 61 64 69 6e 67 20 2a 2f 0a 0a 20 |or loading */.. | 00000e60 20 20 20 6c 6f 61 64 5f 74 65 6d 70 6c 61 74 65 | load_template| 00000e70 73 28 29 3b 0a 0a 20 20 20 20 64 6f 20 7b 0a 20 |s();.. do {. | 00000e80 20 20 20 20 20 20 20 72 65 67 73 5f 69 6e 2e 72 | regs_in.r| 00000e90 5b 30 5d 20 3d 20 50 4f 4c 4c 5f 4d 41 53 4b 3b |[0] = POLL_MASK;| 00000ea0 0a 20 20 20 20 20 20 20 20 72 65 67 73 5f 69 6e |. regs_in| 00000eb0 2e 72 5b 31 5d 20 3d 20 28 69 6e 74 29 20 70 6f |.r[1] = (int) po| 00000ec0 6c 6c 62 6c 6f 63 6b 3b 20 2f 2a 20 61 20 70 6f |llblock; /* a po| 00000ed0 69 6e 74 65 72 20 74 6f 20 6f 75 72 20 64 61 74 |inter to our dat| 00000ee0 61 20 62 6c 6f 63 6b 20 2a 2f 0a 0a 20 20 20 20 |a block */.. | 00000ef0 20 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 28 | _kernel_swi(| 00000f00 57 69 6d 70 5f 50 6f 6c 6c 2c 20 26 72 65 67 73 |Wimp_Poll, ®s| 00000f10 5f 69 6e 2c 20 26 72 65 67 73 5f 6f 75 74 29 3b |_in, ®s_out);| 00000f20 0a 20 20 20 20 20 20 20 20 70 6f 6c 6c 72 65 73 |. pollres| 00000f30 75 6c 74 20 3d 20 72 65 67 73 5f 6f 75 74 2e 72 |ult = regs_out.r| 00000f40 5b 30 5d 3b 20 2f 2a 20 64 65 74 65 72 6d 69 6e |[0]; /* determin| 00000f50 65 20 74 68 65 20 65 76 65 6e 74 20 63 6f 64 65 |e the event code| 00000f60 20 2a 2f 0a 20 20 20 20 20 20 20 20 73 77 69 74 | */. swit| 00000f70 63 68 20 28 70 6f 6c 6c 72 65 73 75 6c 74 29 20 |ch (pollresult) | 00000f80 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 63 61 |{. ca| 00000f90 73 65 20 20 32 3a 20 6f 70 65 6e 77 69 6e 64 6f |se 2: openwindo| 00000fa0 77 28 70 6f 6c 6c 62 6c 6f 63 6b 29 3b 0a 20 20 |w(pollblock);. | 00000fb0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000fc0 20 20 20 62 72 65 61 6b 3b 0a 20 20 20 20 20 20 | break;. | 00000fd0 20 20 20 20 20 20 63 61 73 65 20 20 33 3a 20 63 | case 3: c| 00000fe0 6c 6f 73 65 77 69 6e 64 6f 77 28 70 6f 6c 6c 62 |losewindow(pollb| 00000ff0 6c 6f 63 6b 29 3b 0a 20 20 20 20 20 20 20 20 20 |lock);. | 00001000 20 20 20 20 20 20 20 20 20 20 20 20 62 72 65 61 | brea| 00001010 6b 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 63 |k;. c| 00001020 61 73 65 20 20 36 3a 20 6d 6f 75 73 65 63 6c 69 |ase 6: mousecli| 00001030 63 6b 28 70 6f 6c 6c 62 6c 6f 63 6b 29 3b 0a 20 |ck(pollblock);. | 00001040 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001050 20 20 20 20 62 72 65 61 6b 3b 0a 20 20 20 20 20 | break;. | 00001060 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001070 2f 2a 20 49 66 20 6f 75 72 20 69 63 6f 6e 20 69 |/* If our icon i| 00001080 73 20 63 6c 69 63 6b 65 64 20 6f 6e 2c 20 77 65 |s clicked on, we| 00001090 20 6a 75 6d 70 20 74 6f 20 6d 6f 75 73 65 63 6c | jump to mousecl| 000010a0 69 63 6b 28 29 20 2a 2f 0a 20 20 20 20 20 20 20 |ick() */. | 000010b0 20 20 20 20 20 63 61 73 65 20 20 39 3a 20 6d 65 | case 9: me| 000010c0 6e 75 73 65 6c 65 63 74 69 6f 6e 28 70 6f 6c 6c |nuselection(poll| 000010d0 62 6c 6f 63 6b 29 3b 0a 20 20 20 20 20 20 20 20 |block);. | 000010e0 20 20 20 20 20 20 20 20 20 20 20 20 20 62 72 65 | bre| 000010f0 61 6b 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 |ak;. | 00001100 63 61 73 65 20 31 37 3a 0a 20 20 20 20 20 20 20 |case 17:. | 00001110 20 20 20 20 20 63 61 73 65 20 31 38 3a 0a 20 20 | case 18:. | 00001120 20 20 20 20 20 20 20 20 20 20 63 61 73 65 20 31 | case 1| 00001130 39 3a 20 77 69 6d 70 6d 73 67 28 70 6f 6c 6c 72 |9: wimpmsg(pollr| 00001140 65 73 75 6c 74 2c 20 70 6f 6c 6c 62 6c 6f 63 6b |esult, pollblock| 00001150 29 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 |);. | 00001160 20 20 20 62 72 65 61 6b 3b 0a 20 20 20 20 20 20 | break;. | 00001170 20 20 20 20 20 20 2f 2a 20 54 68 65 20 61 62 6f | /* The abo| 00001180 76 65 20 73 65 63 74 69 6f 6e 20 6c 69 73 74 65 |ve section liste| 00001190 6e 73 20 66 6f 72 20 65 76 65 6e 74 20 63 6f 64 |ns for event cod| 000011a0 65 73 20 31 37 2c 20 31 38 20 61 6e 64 20 31 39 |es 17, 18 and 19| 000011b0 20 2d 20 74 68 65 0a 20 20 20 20 20 20 20 20 20 | - the. | 000011c0 20 20 20 20 20 20 6f 6e 65 73 20 77 68 69 63 68 | ones which| 000011d0 20 69 6e 64 69 63 61 74 65 20 77 65 27 72 65 20 | indicate we're | 000011e0 62 65 69 6e 67 20 73 65 6e 74 20 61 20 6d 65 73 |being sent a mes| 000011f0 73 61 67 65 20 2a 2f 0a 20 20 20 20 20 20 20 20 |sage */. | 00001200 7d 0a 20 20 20 20 7d 20 77 68 69 6c 65 20 28 51 |}. } while (Q| 00001210 55 49 54 5f 46 4c 41 47 20 3d 3d 20 30 29 3b 0a |UIT_FLAG == 0);.| 00001220 20 20 20 20 2f 2a 20 49 66 20 51 55 49 54 5f 46 | /* If QUIT_F| 00001230 4c 41 47 20 63 68 61 6e 67 65 73 20 74 6f 20 61 |LAG changes to a| 00001240 6e 79 74 68 69 6e 67 20 62 75 74 20 30 2c 20 77 |nything but 0, w| 00001250 65 20 73 74 6f 70 20 67 6f 69 6e 67 20 72 6f 75 |e stop going rou| 00001260 6e 64 20 74 68 65 20 70 6f 6c 6c 69 6e 67 0a 20 |nd the polling. | 00001270 20 20 20 20 20 20 6c 6f 6f 70 20 61 6e 64 20 73 | loop and s| 00001280 68 75 74 20 64 6f 77 6e 20 2a 2f 0a 0a 0a 20 20 |hut down */... | 00001290 20 20 72 65 67 73 5f 69 6e 2e 72 5b 30 5d 20 3d | regs_in.r[0] =| 000012a0 20 74 61 73 6b 5f 68 61 6e 64 6c 65 3b 0a 20 20 | task_handle;. | 000012b0 20 20 72 65 67 73 5f 69 6e 2e 72 5b 31 5d 20 3d | regs_in.r[1] =| 000012c0 20 2a 28 69 6e 74 20 2a 29 22 54 41 53 4b 22 3b | *(int *)"TASK";| 000012d0 0a 20 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 |. _kernel_swi| 000012e0 28 57 69 6d 70 5f 43 6c 6f 73 65 44 6f 77 6e 2c |(Wimp_CloseDown,| 000012f0 20 26 72 65 67 73 5f 69 6e 2c 20 26 72 65 67 73 | ®s_in, ®s| 00001300 5f 6f 75 74 29 3b 0a 20 20 20 20 2f 2a 20 41 6e |_out);. /* An| 00001310 64 20 74 68 61 74 27 73 20 69 74 20 2d 20 77 65 |d that's it - we| 00001320 27 76 65 20 74 6f 6c 64 20 74 68 65 20 57 49 4d |'ve told the WIM| 00001330 50 20 74 68 61 74 20 77 65 27 76 65 20 66 69 6e |P that we've fin| 00001340 69 73 68 65 64 2c 20 61 6e 64 20 6e 6f 77 20 74 |ished, and now t| 00001350 68 65 0a 20 20 20 20 20 20 20 70 72 6f 67 72 61 |he. progra| 00001360 6d 20 74 65 72 6d 69 6e 61 74 65 73 2e 20 2a 2f |m terminates. */| 00001370 0a 7d 0a 0a 76 6f 69 64 0a 77 69 6d 70 6d 73 67 |.}..void.wimpmsg| 00001380 28 69 6e 74 20 72 65 73 75 6c 74 2c 20 75 6e 73 |(int result, uns| 00001390 69 67 6e 65 64 20 63 68 61 72 20 70 6f 6c 6c 62 |igned char pollb| 000013a0 6c 6f 63 6b 5b 5d 29 0a 7b 0a 20 20 20 20 75 6e |lock[]).{. un| 000013b0 73 69 67 6e 65 64 20 6c 6f 6e 67 20 69 6e 74 20 |signed long int | 000013c0 20 20 6d 65 73 73 61 67 65 5f 61 63 74 69 6f 6e | message_action| 000013d0 3b 0a 0a 20 20 20 20 2f 2a 20 54 68 65 20 6e 65 |;.. /* The ne| 000013e0 78 74 20 6c 69 6e 65 20 74 61 6b 65 73 20 62 79 |xt line takes by| 000013f0 74 65 73 20 31 36 20 74 6f 20 31 39 20 6f 66 20 |tes 16 to 19 of | 00001400 74 68 65 20 70 6f 6c 6c 69 6e 67 20 62 6c 6f 63 |the polling bloc| 00001410 6b 20 61 6e 64 20 66 6f 72 6d 73 20 74 68 65 6d |k and forms them| 00001420 0a 20 20 20 20 20 20 20 69 6e 74 6f 20 61 20 77 |. into a w| 00001430 6f 72 64 20 68 6f 6c 64 69 6e 67 20 74 68 65 20 |ord holding the | 00001440 6d 65 73 73 61 67 65 20 61 63 74 69 6f 6e 20 6e |message action n| 00001450 75 6d 62 65 72 20 2a 2f 0a 20 20 20 20 6d 65 73 |umber */. mes| 00001460 73 61 67 65 5f 61 63 74 69 6f 6e 20 3d 20 62 74 |sage_action = bt| 00001470 6f 77 28 70 6f 6c 6c 62 6c 6f 63 6b 2c 20 31 36 |ow(pollblock, 16| 00001480 29 3b 0a 20 20 20 20 0a 20 20 20 20 73 77 69 74 |);. . swit| 00001490 63 68 20 28 6d 65 73 73 61 67 65 5f 61 63 74 69 |ch (message_acti| 000014a0 6f 6e 29 20 7b 0a 20 20 20 20 20 20 20 20 63 61 |on) {. ca| 000014b0 73 65 20 30 3a 20 51 55 49 54 5f 46 4c 41 47 20 |se 0: QUIT_FLAG | 000014c0 3d 20 31 3b 20 2f 2a 20 4d 65 73 73 61 67 65 5f |= 1; /* Message_| 000014d0 51 75 69 74 20 2d 20 74 69 6d 65 20 74 6f 20 67 |Quit - time to g| 000014e0 6f 20 2a 2f 0a 20 20 20 20 20 20 20 20 20 20 20 |o */. | 000014f0 20 20 20 20 20 62 72 65 61 6b 3b 0a 20 20 20 20 | break;. | 00001500 20 20 20 20 63 61 73 65 20 30 78 34 30 30 63 32 | case 0x400c2| 00001510 3a 20 69 63 6f 6e 63 68 61 6e 67 65 28 28 63 68 |: iconchange((ch| 00001520 61 72 20 2a 29 20 26 70 6f 6c 6c 62 6c 6f 63 6b |ar *) &pollblock| 00001530 5b 32 38 5d 2c 20 4d 41 49 4e 57 49 4e 5f 48 41 |[28], MAINWIN_HA| 00001540 4e 44 4c 45 2c 20 44 49 53 50 4c 41 59 5f 49 43 |NDLE, DISPLAY_IC| 00001550 4f 4e 29 3b 0a 20 20 20 20 20 20 20 20 20 20 20 |ON);. | 00001560 20 20 20 20 20 62 72 65 61 6b 3b 20 20 20 20 20 | break; | 00001570 20 20 20 0a 20 20 20 20 20 20 20 20 2f 2a 20 4d | . /* M| 00001580 6f 72 65 20 6d 65 73 73 61 67 65 20 61 63 74 69 |ore message acti| 00001590 6f 6e 73 20 63 61 6e 20 62 65 20 61 64 64 65 64 |ons can be added| 000015a0 20 68 65 72 65 20 2a 2f 0a 20 20 20 20 7d 0a 7d | here */. }.}| 000015b0 0a 0a 76 6f 69 64 0a 6d 65 6e 75 73 65 6c 65 63 |..void.menuselec| 000015c0 74 69 6f 6e 28 75 6e 73 69 67 6e 65 64 20 63 68 |tion(unsigned ch| 000015d0 61 72 20 62 6c 6f 63 6b 5b 5d 29 0a 7b 0a 20 20 |ar block[]).{. | 000015e0 20 2f 2a 20 57 65 20 77 6f 75 6c 64 20 63 68 65 | /* We would che| 000015f0 63 6b 20 77 68 69 63 68 20 6d 65 6e 75 20 77 61 |ck which menu wa| 00001600 73 20 61 63 74 69 76 65 20 65 74 63 2e 20 68 65 |s active etc. he| 00001610 72 65 20 2a 2f 0a 20 20 20 0a 20 20 20 69 66 28 |re */. . if(| 00001620 62 74 6f 77 28 62 6c 6f 63 6b 2c 20 30 29 20 3d |btow(block, 0) =| 00001630 3d 20 31 29 20 7b 0a 20 20 20 20 20 20 20 2f 2a |= 1) {. /*| 00001640 20 54 68 69 73 20 69 73 20 74 68 65 20 27 71 75 | This is the 'qu| 00001650 69 74 27 20 65 6e 74 72 79 20 2a 2f 0a 20 20 20 |it' entry */. | 00001660 20 20 20 20 51 55 49 54 5f 46 4c 41 47 20 3d 20 | QUIT_FLAG = | 00001670 31 3b 0a 20 20 20 7d 0a 20 20 20 72 65 74 75 72 |1;. }. retur| 00001680 6e 3b 0a 7d 0a 0a 75 6e 73 69 67 6e 65 64 20 6c |n;.}..unsigned l| 00001690 6f 6e 67 20 69 6e 74 0a 62 74 6f 77 28 75 6e 73 |ong int.btow(uns| 000016a0 69 67 6e 65 64 20 63 68 61 72 20 62 6c 6f 63 6b |igned char block| 000016b0 5b 5d 2c 20 69 6e 74 20 69 6e 64 65 78 29 0a 7b |[], int index).{| 000016c0 0a 20 20 20 20 75 6e 73 69 67 6e 65 64 20 6c 6f |. unsigned lo| 000016d0 6e 67 20 69 6e 74 20 20 20 72 65 73 75 6c 74 20 |ng int result | 000016e0 3d 20 30 3b 0a 20 20 20 20 69 6e 74 20 6c 6f 6f |= 0;. int loo| 000016f0 70 3b 0a 0a 20 20 20 20 2f 2a 20 54 68 69 73 20 |p;.. /* This | 00001700 72 6f 75 74 69 6e 65 20 74 61 6b 65 73 20 61 20 |routine takes a | 00001710 64 61 74 61 20 62 6c 6f 63 6b 20 61 6e 64 20 61 |data block and a| 00001720 20 73 74 61 72 74 69 6e 67 20 62 79 74 65 2c 20 | starting byte, | 00001730 61 6e 64 20 63 6f 6e 76 65 72 74 73 20 74 68 65 |and converts the| 00001740 0a 20 20 20 20 20 20 20 6e 65 78 74 20 66 6f 75 |. next fou| 00001750 72 20 62 79 74 65 73 20 69 6e 74 6f 20 61 20 77 |r bytes into a w| 00001760 6f 72 64 20 2d 20 77 65 20 68 61 76 65 20 74 6f |ord - we have to| 00001770 20 73 74 61 72 74 20 61 74 20 74 68 65 20 6d 6f | start at the mo| 00001780 73 74 20 73 69 67 6e 69 66 69 63 61 6e 74 0a 20 |st significant. | 00001790 20 20 20 20 20 20 62 79 74 65 20 61 6e 64 20 77 | byte and w| 000017a0 6f 72 6b 20 62 61 63 6b 77 61 72 64 73 20 2a 2f |ork backwards */| 000017b0 0a 0a 20 20 20 20 69 6e 64 65 78 20 2b 3d 20 33 |.. index += 3| 000017c0 3b 0a 20 20 20 20 72 65 73 75 6c 74 20 3d 20 62 |;. result = b| 000017d0 6c 6f 63 6b 5b 69 6e 64 65 78 2d 2d 5d 3b 0a 20 |lock[index--];. | 000017e0 20 20 20 66 6f 72 28 6c 6f 6f 70 20 3d 20 30 3b | for(loop = 0;| 000017f0 20 6c 6f 6f 70 20 3c 20 33 3b 20 6c 6f 6f 70 2b | loop < 3; loop+| 00001800 2b 29 20 7b 0a 20 20 20 20 20 20 20 20 72 65 73 |+) {. res| 00001810 75 6c 74 20 3d 20 72 65 73 75 6c 74 20 3c 3c 20 |ult = result << | 00001820 38 3b 0a 20 20 20 20 20 20 20 20 2f 2a 20 74 68 |8;. /* th| 00001830 69 73 20 73 68 69 66 74 73 20 74 68 65 20 62 69 |is shifts the bi| 00001840 74 73 20 69 6e 20 72 65 73 75 6c 74 20 6c 65 66 |ts in result lef| 00001850 74 20 62 79 20 38 20 73 70 61 63 65 73 20 2a 2f |t by 8 spaces */| 00001860 0a 20 20 20 20 20 20 20 20 72 65 73 75 6c 74 20 |. result | 00001870 2b 3d 20 62 6c 6f 63 6b 5b 69 6e 64 65 78 2d 2d |+= block[index--| 00001880 5d 3b 0a 20 20 20 20 7d 0a 0a 20 20 20 20 72 65 |];. }.. re| 00001890 74 75 72 6e 20 28 72 65 73 75 6c 74 29 3b 0a 7d |turn (result);.}| 000018a0 0a 0a 76 6f 69 64 0a 77 74 6f 62 28 75 6e 73 69 |..void.wtob(unsi| 000018b0 67 6e 65 64 20 6c 6f 6e 67 20 69 6e 74 20 69 6e |gned long int in| 000018c0 70 75 74 2c 20 75 6e 73 69 67 6e 65 64 20 63 68 |put, unsigned ch| 000018d0 61 72 20 62 6c 6f 63 6b 5b 5d 2c 20 69 6e 74 20 |ar block[], int | 000018e0 69 6e 64 65 78 29 0a 7b 0a 20 20 20 75 6e 73 69 |index).{. unsi| 000018f0 67 6e 65 64 20 6c 6f 6e 67 20 69 6e 74 20 6d 61 |gned long int ma| 00001900 73 6b 20 3d 20 32 35 35 3b 0a 0a 20 20 20 2f 2a |sk = 255;.. /*| 00001910 20 54 68 65 20 6f 70 70 6f 73 69 74 65 20 6f 66 | The opposite of| 00001920 20 62 74 6f 77 28 29 20 2d 20 74 68 69 73 20 66 | btow() - this f| 00001930 75 6e 63 74 69 6f 6e 20 74 61 6b 65 73 20 61 20 |unction takes a | 00001940 33 32 2d 62 69 74 20 69 6e 74 65 67 65 72 2c 20 |32-bit integer, | 00001950 73 70 6c 69 74 73 0a 20 20 20 20 20 20 69 74 20 |splits. it | 00001960 75 70 20 69 6e 74 6f 20 34 20 62 79 74 65 73 2c |up into 4 bytes,| 00001970 20 61 6e 64 20 73 74 6f 72 65 73 20 74 68 6f 73 | and stores thos| 00001980 65 20 69 6e 20 34 20 63 6f 6e 73 65 63 75 74 69 |e in 4 consecuti| 00001990 76 65 20 63 65 6c 6c 73 20 6f 66 20 61 0a 20 20 |ve cells of a. | 000019a0 20 20 20 20 63 68 61 72 61 63 74 65 72 20 61 72 | character ar| 000019b0 72 61 79 20 69 6e 64 65 78 65 64 20 62 79 20 69 |ray indexed by i| 000019c0 6e 64 65 78 2e 20 54 68 69 73 20 69 73 20 64 6f |ndex. This is do| 000019d0 6e 65 20 62 79 20 75 73 69 6e 67 20 61 20 6d 61 |ne by using a ma| 000019e0 73 6b 20 74 6f 0a 20 20 20 20 20 20 65 78 74 72 |sk to. extr| 000019f0 61 63 74 20 74 68 65 20 64 61 74 61 20 69 6e 20 |act the data in | 00001a00 73 65 71 75 65 6e 63 65 2c 20 77 69 74 68 20 74 |sequence, with t| 00001a10 68 65 20 26 20 62 69 74 77 69 73 65 2d 61 6e 64 |he & bitwise-and| 00001a20 20 6f 70 65 72 61 74 6f 72 20 2a 2f 0a 0a 20 20 | operator */.. | 00001a30 20 2f 2a 20 67 65 74 20 66 69 72 73 74 20 62 79 | /* get first by| 00001a40 74 65 20 2a 2f 0a 20 20 20 62 6c 6f 63 6b 5b 69 |te */. block[i| 00001a50 6e 64 65 78 2b 2b 5d 20 3d 20 28 63 68 61 72 29 |ndex++] = (char)| 00001a60 20 28 69 6e 70 75 74 20 26 20 6d 61 73 6b 29 3b | (input & mask);| 00001a70 0a 20 20 20 2f 2a 20 73 68 69 66 74 20 6d 61 73 |. /* shift mas| 00001a80 6b 20 74 6f 20 67 65 74 20 73 65 63 6f 6e 64 20 |k to get second | 00001a90 62 79 74 65 2c 20 61 6e 64 20 73 75 70 70 6c 79 |byte, and supply| 00001aa0 20 72 65 73 75 6c 74 20 61 73 20 62 79 74 65 20 | result as byte | 00001ab0 73 69 7a 65 20 2a 2f 0a 20 20 20 6d 61 73 6b 20 |size */. mask | 00001ac0 3c 3c 3d 20 38 3b 0a 20 20 20 62 6c 6f 63 6b 5b |<<= 8;. block[| 00001ad0 69 6e 64 65 78 2b 2b 5d 20 3d 20 28 63 68 61 72 |index++] = (char| 00001ae0 29 20 28 28 69 6e 70 75 74 20 26 20 6d 61 73 6b |) ((input & mask| 00001af0 29 20 3e 3e 20 38 29 3b 0a 20 20 20 6d 61 73 6b |) >> 8);. mask| 00001b00 20 3c 3c 3d 20 38 3b 0a 20 20 20 62 6c 6f 63 6b | <<= 8;. block| 00001b10 5b 69 6e 64 65 78 2b 2b 5d 20 3d 20 28 63 68 61 |[index++] = (cha| 00001b20 72 29 20 28 28 69 6e 70 75 74 20 26 20 6d 61 73 |r) ((input & mas| 00001b30 6b 29 20 3e 3e 20 31 36 29 3b 0a 20 20 20 6d 61 |k) >> 16);. ma| 00001b40 73 6b 20 3c 3c 3d 20 38 3b 0a 20 20 20 62 6c 6f |sk <<= 8;. blo| 00001b50 63 6b 5b 69 6e 64 65 78 2b 2b 5d 20 3d 20 28 63 |ck[index++] = (c| 00001b60 68 61 72 29 20 28 28 69 6e 70 75 74 20 26 20 6d |har) ((input & m| 00001b70 61 73 6b 29 20 3e 3e 20 32 34 29 3b 0a 0a 20 20 |ask) >> 24);.. | 00001b80 20 72 65 74 75 72 6e 3b 0a 7d 0a 0a 76 6f 69 64 | return;.}..void| 00001b90 0a 6d 6f 75 73 65 63 6c 69 63 6b 28 75 6e 73 69 |.mouseclick(unsi| 00001ba0 67 6e 65 64 20 63 68 61 72 20 70 6f 6c 6c 62 6c |gned char pollbl| 00001bb0 6f 63 6b 5b 5d 29 0a 7b 0a 20 20 20 63 68 61 72 |ock[]).{. char| 00001bc0 20 6d 65 73 73 61 67 65 5b 32 35 35 5d 3b 0a 20 | message[255];. | 00001bd0 20 20 2f 2a 20 41 20 62 75 66 66 65 72 20 74 6f | /* A buffer to| 00001be0 20 68 6f 6c 64 20 61 6e 20 27 65 72 72 6f 72 27 | hold an 'error'| 00001bf0 20 6d 65 73 73 61 67 65 20 2a 2f 0a 0a 20 20 20 | message */.. | 00001c00 69 6e 74 20 72 65 73 75 6c 74 2c 20 63 6c 6b 3b |int result, clk;| 00001c10 0a 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 5f |. _kernel_swi_| 00001c20 72 65 67 73 20 69 6e 2c 20 6f 75 74 3b 0a 20 20 |regs in, out;. | 00001c30 20 75 6e 73 69 67 6e 65 64 20 63 68 61 72 20 74 | unsigned char t| 00001c40 65 6d 70 5f 62 75 66 66 65 72 5b 32 35 35 5d 3b |emp_buffer[255];| 00001c50 0a 0a 20 20 20 2f 2a 20 44 65 74 65 72 6d 69 6e |.. /* Determin| 00001c60 65 20 77 68 69 63 68 20 62 75 74 74 6f 6e 20 77 |e which button w| 00001c70 61 73 20 70 72 65 73 73 65 64 20 2a 2f 0a 20 20 |as pressed */. | 00001c80 20 63 6c 6b 20 3d 20 28 69 6e 74 29 20 62 74 6f | clk = (int) bto| 00001c90 77 28 70 6f 6c 6c 62 6c 6f 63 6b 2c 20 38 29 3b |w(pollblock, 8);| 00001ca0 0a 0a 20 20 20 2f 2a 20 49 66 20 74 68 65 20 27 |.. /* If the '| 00001cb0 53 65 6c 65 63 74 27 20 62 75 74 74 6f 6e 20 77 |Select' button w| 00001cc0 61 73 20 63 6c 69 63 6b 65 64 20 6f 6e 20 74 68 |as clicked on th| 00001cd0 65 20 69 63 6f 6e 20 62 61 72 20 28 70 6f 6c 6c |e icon bar (poll| 00001ce0 62 6c 6f 63 6b 20 2b 20 31 32 20 3d 20 2d 32 29 |block + 12 = -2)| 00001cf0 0a 20 20 20 20 20 20 74 68 65 6e 20 72 65 2d 6f |. then re-o| 00001d00 70 65 6e 20 6d 61 69 6e 20 77 69 6e 64 6f 77 20 |pen main window | 00001d10 61 6e 64 20 72 65 74 75 72 6e 20 2a 2f 0a 0a 20 |and return */.. | 00001d20 20 20 69 66 28 28 62 74 6f 77 28 70 6f 6c 6c 62 | if((btow(pollb| 00001d30 6c 6f 63 6b 2c 20 31 32 29 20 3d 3d 20 2d 32 29 |lock, 12) == -2)| 00001d40 20 26 26 20 28 63 6c 6b 20 3d 3d 20 34 29 29 20 | && (clk == 4)) | 00001d50 7b 0a 20 20 20 20 20 20 77 74 6f 62 28 4d 41 49 |{. wtob(MAI| 00001d60 4e 57 49 4e 5f 48 41 4e 44 4c 45 2c 20 74 65 6d |NWIN_HANDLE, tem| 00001d70 70 5f 62 75 66 66 65 72 2c 20 30 29 3b 0a 20 20 |p_buffer, 0);. | 00001d80 20 20 20 20 69 6e 2e 72 5b 31 5d 20 3d 20 28 69 | in.r[1] = (i| 00001d90 6e 74 29 20 74 65 6d 70 5f 62 75 66 66 65 72 3b |nt) temp_buffer;| 00001da0 0a 20 20 20 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 |. _kernel_s| 00001db0 77 69 28 57 69 6d 70 5f 47 65 74 57 69 6e 64 6f |wi(Wimp_GetWindo| 00001dc0 77 49 6e 66 6f 2c 20 26 69 6e 2c 20 26 6f 75 74 |wInfo, &in, &out| 00001dd0 29 3b 0a 20 20 20 20 20 20 5f 6b 65 72 6e 65 6c |);. _kernel| 00001de0 5f 73 77 69 28 57 69 6d 70 5f 4f 70 65 6e 57 69 |_swi(Wimp_OpenWi| 00001df0 6e 64 6f 77 2c 20 26 69 6e 2c 20 26 6f 75 74 29 |ndow, &in, &out)| 00001e00 3b 0a 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0a |;. return;.| 00001e10 20 20 20 7d 0a 0a 20 20 20 69 66 28 28 62 74 6f | }.. if((bto| 00001e20 77 28 70 6f 6c 6c 62 6c 6f 63 6b 2c 20 31 32 29 |w(pollblock, 12)| 00001e30 20 3d 3d 20 2d 32 29 20 26 26 20 28 63 6c 6b 20 | == -2) && (clk | 00001e40 3d 3d 20 32 29 29 20 7b 0a 20 20 20 20 20 20 2f |== 2)) {. /| 00001e50 2a 20 27 4d 65 6e 75 27 20 68 61 73 20 62 65 65 |* 'Menu' has bee| 00001e60 6e 20 63 6c 69 63 6b 65 64 20 6f 6e 20 74 68 65 |n clicked on the| 00001e70 20 69 63 6f 6e 20 62 61 72 20 69 63 6f 6e 20 2d | icon bar icon -| 00001e80 20 6e 6f 77 20 77 65 20 70 72 6f 64 75 63 65 0a | now we produce.| 00001e90 20 20 20 20 20 20 20 20 20 61 20 6d 65 6e 75 20 | a menu | 00001ea0 2a 2f 0a 20 20 20 20 20 20 73 74 72 63 70 79 28 |*/. strcpy(| 00001eb0 28 63 68 61 72 20 2a 29 20 26 6d 61 69 6e 6d 65 |(char *) &mainme| 00001ec0 6e 75 2c 20 22 54 65 73 74 6d 65 6e 75 22 29 3b |nu, "Testmenu");| 00001ed0 20 2f 2a 20 53 68 6f 75 6c 64 20 61 75 74 6f 6d | /* Should autom| 00001ee0 61 67 69 63 61 6c 6c 79 20 70 75 74 20 74 68 65 |agically put the| 00001ef0 20 5c 30 20 69 6e 20 2a 2f 0a 20 20 20 20 20 20 | \0 in */. | 00001f00 77 74 6f 62 28 34 35 39 32 37 31 2c 20 6d 61 69 |wtob(459271, mai| 00001f10 6e 6d 65 6e 75 2c 20 31 32 29 3b 0a 20 20 20 20 |nmenu, 12);. | 00001f20 20 20 77 74 6f 62 28 31 34 30 2c 20 6d 61 69 6e | wtob(140, main| 00001f30 6d 65 6e 75 2c 20 31 36 29 3b 0a 20 20 20 20 20 |menu, 16);. | 00001f40 20 77 74 6f 62 28 34 38 2c 20 6d 61 69 6e 6d 65 | wtob(48, mainme| 00001f50 6e 75 2c 20 32 30 29 3b 0a 20 20 20 20 20 20 77 |nu, 20);. w| 00001f60 74 6f 62 28 30 2c 20 6d 61 69 6e 6d 65 6e 75 2c |tob(0, mainmenu,| 00001f70 20 32 34 29 3b 0a 20 20 20 20 20 20 77 74 6f 62 | 24);. wtob| 00001f80 28 31 2c 20 6d 61 69 6e 6d 65 6e 75 2c 20 32 38 |(1, mainmenu, 28| 00001f90 29 3b 0a 20 20 20 20 20 20 77 74 6f 62 28 2d 31 |);. wtob(-1| 00001fa0 2c 20 6d 61 69 6e 6d 65 6e 75 2c 20 33 32 29 3b |, mainmenu, 32);| 00001fb0 0a 20 20 20 20 20 20 77 74 6f 62 28 31 32 31 36 |. wtob(1216| 00001fc0 33 34 38 34 39 2c 20 6d 61 69 6e 6d 65 6e 75 2c |34849, mainmenu,| 00001fd0 20 33 36 29 3b 0a 20 20 20 20 20 20 73 74 72 63 | 36);. strc| 00001fe0 70 79 28 28 63 68 61 72 20 2a 29 20 26 6d 61 69 |py((char *) &mai| 00001ff0 6e 6d 65 6e 75 5b 34 30 5d 2c 20 22 41 6e 20 65 |nmenu[40], "An e| 00002000 6e 74 72 79 22 29 3b 0a 20 20 20 20 20 20 77 74 |ntry");. wt| 00002010 6f 62 28 31 32 38 2c 20 6d 61 69 6e 6d 65 6e 75 |ob(128, mainmenu| 00002020 2c 20 35 32 29 3b 0a 20 20 20 20 20 20 77 74 6f |, 52);. wto| 00002030 62 28 2d 31 2c 20 6d 61 69 6e 6d 65 6e 75 2c 20 |b(-1, mainmenu, | 00002040 35 36 29 3b 0a 20 20 20 20 20 20 77 74 6f 62 28 |56);. wtob(| 00002050 31 31 37 34 34 30 35 34 35 2c 20 6d 61 69 6e 6d |117440545, mainm| 00002060 65 6e 75 2c 20 36 30 29 3b 0a 20 20 20 20 20 20 |enu, 60);. | 00002070 73 74 72 63 70 79 28 28 63 68 61 72 20 2a 29 20 |strcpy((char *) | 00002080 26 6d 61 69 6e 6d 65 6e 75 5b 36 34 5d 2c 20 22 |&mainmenu[64], "| 00002090 51 75 69 74 22 29 3b 0a 0a 20 20 20 20 20 20 69 |Quit");.. i| 000020a0 6e 2e 72 5b 31 5d 20 3d 20 28 69 6e 74 29 20 6d |n.r[1] = (int) m| 000020b0 61 69 6e 6d 65 6e 75 3b 0a 20 20 20 20 20 20 69 |ainmenu;. i| 000020c0 6e 2e 72 5b 32 5d 20 3d 20 28 69 6e 74 29 20 62 |n.r[2] = (int) b| 000020d0 74 6f 77 28 70 6f 6c 6c 62 6c 6f 63 6b 2c 20 30 |tow(pollblock, 0| 000020e0 29 20 2d 20 37 30 3b 0a 20 20 20 20 20 20 69 6e |) - 70;. in| 000020f0 2e 72 5b 33 5d 20 3d 20 32 30 30 3b 0a 0a 20 20 |.r[3] = 200;.. | 00002100 20 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 28 | _kernel_swi(| 00002110 57 69 6d 70 5f 43 72 65 61 74 65 4d 65 6e 75 2c |Wimp_CreateMenu,| 00002120 20 26 69 6e 2c 20 26 6f 75 74 29 3b 0a 20 20 20 | &in, &out);. | 00002130 20 20 20 72 65 74 75 72 6e 3b 0a 20 20 20 20 20 | return;. | 00002140 20 0a 20 20 20 7d 0a 0a 20 20 20 73 74 72 63 70 | . }.. strcp| 00002150 79 28 6d 65 73 73 61 67 65 2c 20 22 4d 6f 75 73 |y(message, "Mous| 00002160 65 20 63 6c 69 63 6b 20 64 65 74 65 63 74 65 64 |e click detected| 00002170 20 28 74 79 70 65 22 29 3b 0a 20 20 20 73 70 72 | (type");. spr| 00002180 69 6e 74 66 28 6d 65 73 73 61 67 65 2c 20 22 25 |intf(message, "%| 00002190 73 20 25 64 29 20 2d 20 64 6f 20 79 6f 75 20 77 |s %d) - do you w| 000021a0 69 73 68 20 74 6f 20 73 74 6f 70 20 74 68 65 20 |ish to stop the | 000021b0 70 72 6f 67 72 61 6d 3f 22 2c 20 6d 65 73 73 61 |program?", messa| 000021c0 67 65 2c 20 63 6c 6b 29 3b 0a 0a 20 20 20 2f 2a |ge, clk);.. /*| 000021d0 20 54 68 65 20 61 62 6f 76 65 20 6c 69 6e 65 73 | The above lines| 000021e0 20 63 6f 6d 70 69 6c 65 20 61 6e 20 65 72 72 6f | compile an erro| 000021f0 72 20 6d 65 73 73 61 67 65 20 75 73 69 6e 67 20 |r message using | 00002200 73 74 61 6e 64 61 72 64 20 73 74 72 69 6e 67 0a |standard string.| 00002210 20 20 20 20 20 20 66 75 6e 63 74 69 6f 6e 73 20 | functions | 00002220 2a 2f 0a 0a 20 20 20 72 65 73 75 6c 74 20 3d 20 |*/.. result = | 00002230 72 65 70 6f 72 74 5f 65 72 72 6f 72 28 31 2c 20 |report_error(1, | 00002240 6d 65 73 73 61 67 65 2c 20 33 29 3b 0a 20 20 20 |message, 3);. | 00002250 2f 2a 20 54 68 69 73 20 63 61 6c 6c 73 20 61 20 |/* This calls a | 00002260 66 75 6e 63 74 69 6f 6e 20 74 6f 20 64 69 73 70 |function to disp| 00002270 6c 61 79 20 61 6e 20 65 72 72 6f 72 20 62 6f 78 |lay an error box| 00002280 20 6f 6e 20 74 68 65 20 73 63 72 65 65 6e 20 2d | on the screen -| 00002290 20 69 66 20 74 68 65 0a 20 20 20 20 20 20 75 73 | if the. us| 000022a0 65 72 20 63 6c 69 63 6b 73 20 6f 6e 20 4f 4b 2c |er clicks on OK,| 000022b0 20 74 68 65 20 70 72 6f 67 72 61 6d 20 74 65 72 | the program ter| 000022c0 6d 69 6e 61 74 65 73 20 2a 2f 0a 0a 20 20 20 69 |minates */.. i| 000022d0 66 20 28 72 65 73 75 6c 74 20 3d 3d 20 31 29 20 |f (result == 1) | 000022e0 51 55 49 54 5f 46 4c 41 47 20 3d 20 31 3b 0a 7d |QUIT_FLAG = 1;.}| 000022f0 0a 0a 69 6e 74 0a 72 65 70 6f 72 74 5f 65 72 72 |..int.report_err| 00002300 6f 72 28 69 6e 74 20 65 72 72 6e 6f 2c 20 63 68 |or(int errno, ch| 00002310 61 72 20 65 72 72 6d 65 73 73 5b 5d 2c 20 69 6e |ar errmess[], in| 00002320 74 20 66 6c 61 67 73 29 0a 7b 0a 20 20 20 75 6e |t flags).{. un| 00002330 73 69 67 6e 65 64 20 63 68 61 72 20 65 72 72 6f |signed char erro| 00002340 72 62 6c 6f 63 6b 5b 32 36 30 5d 3b 0a 20 20 20 |rblock[260];. | 00002350 5f 6b 65 72 6e 65 6c 5f 73 77 69 5f 72 65 67 73 |_kernel_swi_regs| 00002360 20 69 6e 2c 20 6f 75 74 3b 0a 0a 20 20 20 2f 2a | in, out;.. /*| 00002370 20 53 65 74 20 75 70 20 74 68 65 20 73 74 61 6e | Set up the stan| 00002380 64 61 72 64 20 65 72 72 6f 72 20 62 6c 6f 63 6b |dard error block| 00002390 20 77 69 74 68 20 74 68 65 20 65 72 72 6f 72 20 | with the error | 000023a0 6e 75 6d 62 65 72 20 61 6e 64 20 6d 65 73 73 61 |number and messa| 000023b0 67 65 0a 20 20 20 20 20 20 28 7a 65 72 6f 20 74 |ge. (zero t| 000023c0 65 72 6d 69 6e 61 74 65 64 29 20 2a 2f 0a 20 20 |erminated) */. | 000023d0 20 77 74 6f 62 28 65 72 72 6e 6f 2c 20 65 72 72 | wtob(errno, err| 000023e0 6f 72 62 6c 6f 63 6b 2c 20 30 29 3b 0a 20 20 20 |orblock, 0);. | 000023f0 73 74 72 63 70 79 28 20 28 63 68 61 72 20 2a 29 |strcpy( (char *)| 00002400 20 26 65 72 72 6f 72 62 6c 6f 63 6b 5b 34 5d 2c | &errorblock[4],| 00002410 20 65 72 72 6d 65 73 73 29 3b 0a 0a 20 20 20 2f | errmess);.. /| 00002420 2a 20 52 30 20 2d 20 70 6f 69 6e 74 65 72 20 74 |* R0 - pointer t| 00002430 6f 20 73 74 61 6e 64 61 72 64 20 65 72 72 6f 72 |o standard error| 00002440 20 62 6c 6f 63 6b 0a 20 20 20 20 20 20 52 31 20 | block. R1 | 00002450 2d 20 65 72 72 6f 72 20 77 69 6e 64 6f 77 20 66 |- error window f| 00002460 6c 61 67 73 0a 20 20 20 20 20 20 52 32 20 2d 20 |lags. R2 - | 00002470 70 6f 69 6e 74 65 72 20 74 6f 20 61 70 70 6c 69 |pointer to appli| 00002480 63 61 74 69 6f 6e 20 6e 61 6d 65 20 66 6f 72 20 |cation name for | 00002490 65 72 72 6f 72 20 62 6f 78 20 74 69 74 6c 65 20 |error box title | 000024a0 2a 2f 0a 0a 20 20 20 69 6e 2e 72 5b 30 5d 20 3d |*/.. in.r[0] =| 000024b0 20 28 69 6e 74 29 20 65 72 72 6f 72 62 6c 6f 63 | (int) errorbloc| 000024c0 6b 3b 0a 20 20 20 69 6e 2e 72 5b 31 5d 20 3d 20 |k;. in.r[1] = | 000024d0 66 6c 61 67 73 3b 0a 20 20 20 69 6e 2e 72 5b 32 |flags;. in.r[2| 000024e0 5d 20 3d 20 28 69 6e 74 29 20 61 70 70 6e 61 6d |] = (int) appnam| 000024f0 65 3b 0a 0a 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 |e;.. _kernel_s| 00002500 77 69 28 57 69 6d 70 5f 52 65 70 6f 72 74 45 72 |wi(Wimp_ReportEr| 00002510 72 6f 72 2c 20 26 69 6e 2c 20 26 6f 75 74 29 3b |ror, &in, &out);| 00002520 0a 0a 20 20 20 2f 2a 20 52 65 74 75 72 6e 73 20 |.. /* Returns | 00002530 31 20 69 66 20 4f 4b 20 73 65 6c 65 63 74 65 64 |1 if OK selected| 00002540 2c 20 32 20 69 66 20 43 61 6e 63 65 6c 20 73 65 |, 2 if Cancel se| 00002550 6c 65 63 74 65 64 20 2a 2f 0a 20 20 20 72 65 74 |lected */. ret| 00002560 75 72 6e 20 6f 75 74 2e 72 5b 31 5d 3b 0a 7d 0a |urn out.r[1];.}.| 00002570 0a 69 6e 74 0a 6c 6f 61 64 5f 74 65 6d 70 6c 61 |.int.load_templa| 00002580 74 65 73 28 76 6f 69 64 29 0a 7b 0a 20 20 20 20 |tes(void).{. | 00002590 63 68 61 72 20 74 65 6d 70 6c 61 74 65 5f 66 69 |char template_fi| 000025a0 6c 65 6e 61 6d 65 5b 5d 20 3d 20 22 3c 57 69 6d |lename[] = "<Wim| 000025b0 70 43 24 44 69 72 3e 2e 54 65 6d 70 6c 61 74 65 |pC$Dir>.Template| 000025c0 73 22 3b 0a 20 20 20 20 63 68 61 72 20 74 65 6d |s";. char tem| 000025d0 70 6c 61 74 65 5f 6e 61 6d 65 5b 5d 20 3d 20 22 |plate_name[] = "| 000025e0 4d 61 69 6e 57 69 6e 64 6f 77 5c 30 22 3b 0a 20 |MainWindow\0";. | 000025f0 20 20 20 75 6e 73 69 67 6e 65 64 20 63 68 61 72 | unsigned char| 00002600 20 6f 70 65 6e 77 69 6e 64 6f 77 5f 62 75 66 66 | openwindow_buff| 00002610 65 72 5b 33 36 5d 3b 0a 20 20 20 20 5f 6b 65 72 |er[36];. _ker| 00002620 6e 65 6c 5f 73 77 69 5f 72 65 67 73 20 69 6e 2c |nel_swi_regs in,| 00002630 20 6f 75 74 3b 0a 20 20 20 20 69 6e 74 20 6c 6f | out;. int lo| 00002640 6f 70 20 3d 20 30 3b 0a 0a 20 20 20 20 2f 2a 20 |op = 0;.. /* | 00002650 54 68 69 73 20 53 57 49 20 63 61 6c 6c 20 70 72 |This SWI call pr| 00002660 65 70 61 72 65 73 20 61 20 74 65 6d 70 6c 61 74 |epares a templat| 00002670 65 20 66 69 6c 65 20 66 6f 72 20 72 65 61 64 69 |e file for readi| 00002680 6e 67 20 2a 2f 0a 20 20 20 20 69 6e 2e 72 5b 31 |ng */. in.r[1| 00002690 5d 20 3d 20 28 69 6e 74 29 20 74 65 6d 70 6c 61 |] = (int) templa| 000026a0 74 65 5f 66 69 6c 65 6e 61 6d 65 3b 0a 20 20 20 |te_filename;. | 000026b0 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 28 57 69 6d | _kernel_swi(Wim| 000026c0 70 5f 4f 70 65 6e 54 65 6d 70 6c 61 74 65 2c 20 |p_OpenTemplate, | 000026d0 26 69 6e 2c 20 26 6f 75 74 29 3b 0a 0a 20 20 20 |&in, &out);.. | 000026e0 20 2f 2a 20 4e 6f 77 20 77 65 20 6c 6f 61 64 20 | /* Now we load | 000026f0 74 68 65 20 74 65 6d 70 6c 61 74 65 20 64 61 74 |the template dat| 00002700 61 20 2a 2f 0a 20 20 20 20 69 6e 2e 72 5b 31 5d |a */. in.r[1]| 00002710 20 3d 20 28 69 6e 74 29 20 6d 61 69 6e 77 69 6e | = (int) mainwin| 00002720 5f 62 75 66 66 65 72 3b 0a 20 20 20 20 69 6e 2e |_buffer;. in.| 00002730 72 5b 32 5d 20 3d 20 28 69 6e 74 29 20 6d 61 69 |r[2] = (int) mai| 00002740 6e 77 69 6e 5f 77 6f 72 6b 73 70 61 63 65 3b 0a |nwin_workspace;.| 00002750 20 20 20 20 69 6e 2e 72 5b 33 5d 20 3d 20 28 69 | in.r[3] = (i| 00002760 6e 74 29 20 6d 61 69 6e 77 69 6e 5f 77 6f 72 6b |nt) mainwin_work| 00002770 73 70 61 63 65 20 2b 20 57 4f 52 4b 53 50 41 43 |space + WORKSPAC| 00002780 45 5f 53 49 5a 45 3b 0a 20 20 20 20 69 6e 2e 72 |E_SIZE;. in.r| 00002790 5b 34 5d 20 3d 20 2d 31 3b 20 2f 2a 20 4e 6f 20 |[4] = -1; /* No | 000027a0 66 6f 6e 74 73 20 75 73 65 64 20 2a 2f 0a 20 20 |fonts used */. | 000027b0 20 20 69 6e 2e 72 5b 35 5d 20 3d 20 28 69 6e 74 | in.r[5] = (int| 000027c0 29 20 74 65 6d 70 6c 61 74 65 5f 6e 61 6d 65 3b |) template_name;| 000027d0 0a 20 20 20 20 69 6e 2e 72 5b 36 5d 20 3d 20 30 |. in.r[6] = 0| 000027e0 3b 0a 0a 20 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 |;.. _kernel_s| 000027f0 77 69 28 57 69 6d 70 5f 4c 6f 61 64 54 65 6d 70 |wi(Wimp_LoadTemp| 00002800 6c 61 74 65 2c 20 26 69 6e 2c 20 26 6f 75 74 29 |late, &in, &out)| 00002810 3b 0a 20 20 20 20 69 66 28 6f 75 74 2e 72 5b 36 |;. if(out.r[6| 00002820 5d 20 3d 3d 20 30 29 20 7b 0a 20 20 20 20 20 20 |] == 0) {. | 00002830 20 69 66 28 72 65 70 6f 72 74 5f 65 72 72 6f 72 | if(report_error| 00002840 28 31 2c 20 22 54 65 6d 70 6c 61 74 65 20 6e 6f |(1, "Template no| 00002850 74 20 66 6f 75 6e 64 21 22 2c 20 33 29 20 3d 3d |t found!", 3) ==| 00002860 20 31 29 20 51 55 49 54 5f 46 4c 41 47 20 3d 31 | 1) QUIT_FLAG =1| 00002870 3b 20 20 20 20 20 20 20 0a 20 20 20 20 7d 0a 0a |; . }..| 00002880 20 20 20 20 2f 2a 20 4e 6f 77 20 77 65 27 76 65 | /* Now we've| 00002890 20 66 69 6e 69 73 68 65 64 20 72 65 61 64 69 6e | finished readin| 000028a0 67 20 74 68 65 20 74 65 6d 70 6c 61 74 65 73 2c |g the templates,| 000028b0 20 63 6c 6f 73 65 20 74 68 65 20 66 69 6c 65 20 | close the file | 000028c0 2a 2f 0a 20 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 |*/. _kernel_s| 000028d0 77 69 28 57 69 6d 70 5f 43 6c 6f 73 65 54 65 6d |wi(Wimp_CloseTem| 000028e0 70 6c 61 74 65 2c 20 26 69 6e 2c 20 26 6f 75 74 |plate, &in, &out| 000028f0 29 3b 0a 0a 20 20 20 20 2f 2a 20 43 72 65 61 74 |);.. /* Creat| 00002900 65 20 74 68 65 20 77 69 6e 64 6f 77 20 75 73 69 |e the window usi| 00002910 6e 67 20 74 68 65 20 64 61 74 61 20 77 65 27 76 |ng the data we'v| 00002920 65 20 6a 75 73 74 20 6c 6f 61 64 65 64 20 61 6e |e just loaded an| 00002930 64 20 73 74 6f 72 65 20 74 68 65 0a 20 20 20 20 |d store the. | 00002940 20 20 20 72 65 74 75 72 6e 65 64 20 77 69 6e 64 | returned wind| 00002950 6f 77 20 68 61 6e 64 6c 65 20 69 6e 20 61 20 67 |ow handle in a g| 00002960 6c 6f 62 61 6c 20 76 61 72 69 61 62 6c 65 20 2a |lobal variable *| 00002970 2f 0a 20 20 20 20 69 6e 2e 72 5b 31 5d 20 3d 20 |/. in.r[1] = | 00002980 28 69 6e 74 29 20 6d 61 69 6e 77 69 6e 5f 62 75 |(int) mainwin_bu| 00002990 66 66 65 72 3b 0a 20 20 20 20 5f 6b 65 72 6e 65 |ffer;. _kerne| 000029a0 6c 5f 73 77 69 28 57 69 6d 70 5f 43 72 65 61 74 |l_swi(Wimp_Creat| 000029b0 65 57 69 6e 64 6f 77 2c 20 26 69 6e 2c 20 26 6f |eWindow, &in, &o| 000029c0 75 74 29 3b 0a 20 20 20 20 4d 41 49 4e 57 49 4e |ut);. MAINWIN| 000029d0 5f 48 41 4e 44 4c 45 20 3d 20 6f 75 74 2e 72 5b |_HANDLE = out.r[| 000029e0 30 5d 3b 0a 0a 20 20 20 20 2f 2a 20 43 6f 70 79 |0];.. /* Copy| 000029f0 20 74 68 65 20 70 6f 73 69 74 69 6f 6e 20 64 61 | the position da| 00002a00 74 61 20 6f 66 20 74 68 65 20 77 69 6e 64 6f 77 |ta of the window| 00002a10 20 69 6e 74 6f 20 61 20 62 75 66 66 65 72 20 73 | into a buffer s| 00002a20 6f 20 74 68 61 74 20 77 65 20 63 61 6e 0a 20 20 |o that we can. | 00002a30 20 20 20 20 20 6f 70 65 6e 20 74 68 65 20 77 69 | open the wi| 00002a40 6e 64 6f 77 20 61 74 20 74 68 61 74 20 70 6f 73 |ndow at that pos| 00002a50 69 74 69 6f 6e 20 2a 2f 0a 20 20 20 20 77 74 6f |ition */. wto| 00002a60 62 28 6f 75 74 2e 72 5b 30 5d 2c 20 6f 70 65 6e |b(out.r[0], open| 00002a70 77 69 6e 64 6f 77 5f 62 75 66 66 65 72 2c 20 30 |window_buffer, 0| 00002a80 29 3b 0a 20 20 20 20 66 6f 72 28 6c 6f 6f 70 20 |);. for(loop | 00002a90 3d 20 30 3b 20 6c 6f 6f 70 20 3c 20 36 3b 20 6c |= 0; loop < 6; l| 00002aa0 6f 6f 70 2b 2b 29 20 7b 0a 20 20 20 20 20 20 20 |oop++) {. | 00002ab0 77 74 6f 62 28 62 74 6f 77 28 6d 61 69 6e 77 69 |wtob(btow(mainwi| 00002ac0 6e 5f 62 75 66 66 65 72 2c 20 6c 6f 6f 70 2a 34 |n_buffer, loop*4| 00002ad0 29 2c 20 6f 70 65 6e 77 69 6e 64 6f 77 5f 62 75 |), openwindow_bu| 00002ae0 66 66 65 72 2c 20 28 6c 6f 6f 70 2b 31 29 20 2a |ffer, (loop+1) *| 00002af0 20 34 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20 2f | 4);. }. /| 00002b00 2a 20 50 75 74 74 69 6e 67 20 2d 31 20 68 65 72 |* Putting -1 her| 00002b10 65 20 6d 65 61 6e 73 20 74 68 65 20 77 69 6e 64 |e means the wind| 00002b20 6f 77 20 69 73 20 6f 70 65 6e 65 64 20 69 6e 20 |ow is opened in | 00002b30 66 72 6f 6e 74 20 6f 66 20 61 6c 6c 20 6f 74 68 |front of all oth| 00002b40 65 72 73 20 2a 2f 0a 20 20 20 20 77 74 6f 62 28 |ers */. wtob(| 00002b50 2d 31 2c 20 6f 70 65 6e 77 69 6e 64 6f 77 5f 62 |-1, openwindow_b| 00002b60 75 66 66 65 72 2c 20 32 38 29 3b 0a 20 20 20 20 |uffer, 28);. | 00002b70 69 6e 2e 72 5b 31 5d 20 3d 20 28 69 6e 74 29 20 |in.r[1] = (int) | 00002b80 6f 70 65 6e 77 69 6e 64 6f 77 5f 62 75 66 66 65 |openwindow_buffe| 00002b90 72 3b 0a 20 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 |r;. _kernel_s| 00002ba0 77 69 28 57 69 6d 70 5f 4f 70 65 6e 57 69 6e 64 |wi(Wimp_OpenWind| 00002bb0 6f 77 2c 20 26 69 6e 2c 20 26 6f 75 74 29 3b 0a |ow, &in, &out);.| 00002bc0 20 20 20 20 72 65 74 75 72 6e 20 30 3b 0a 7d 0a | return 0;.}.| 00002bd0 0a 76 6f 69 64 20 6f 70 65 6e 77 69 6e 64 6f 77 |.void openwindow| 00002be0 28 75 6e 73 69 67 6e 65 64 20 63 68 61 72 20 70 |(unsigned char p| 00002bf0 6f 6c 6c 62 6c 6f 63 6b 5b 5d 29 0a 7b 0a 20 20 |ollblock[]).{. | 00002c00 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 5f 72 65 67 | _kernel_swi_reg| 00002c10 73 20 69 6e 2c 20 6f 75 74 3b 0a 0a 20 20 20 69 |s in, out;.. i| 00002c20 6e 2e 72 5b 31 5d 20 3d 20 28 69 6e 74 29 20 70 |n.r[1] = (int) p| 00002c30 6f 6c 6c 62 6c 6f 63 6b 3b 0a 20 20 20 5f 6b 65 |ollblock;. _ke| 00002c40 72 6e 65 6c 5f 73 77 69 28 57 69 6d 70 5f 4f 70 |rnel_swi(Wimp_Op| 00002c50 65 6e 57 69 6e 64 6f 77 2c 20 26 69 6e 2c 20 26 |enWindow, &in, &| 00002c60 6f 75 74 29 3b 0a 20 20 20 72 65 74 75 72 6e 3b |out);. return;| 00002c70 0a 7d 0a 0a 76 6f 69 64 20 63 6c 6f 73 65 77 69 |.}..void closewi| 00002c80 6e 64 6f 77 28 75 6e 73 69 67 6e 65 64 20 63 68 |ndow(unsigned ch| 00002c90 61 72 20 70 6f 6c 6c 62 6c 6f 63 6b 5b 5d 29 0a |ar pollblock[]).| 00002ca0 7b 0a 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 |{. _kernel_swi| 00002cb0 5f 72 65 67 73 20 69 6e 2c 20 6f 75 74 3b 0a 0a |_regs in, out;..| 00002cc0 20 20 20 69 6e 2e 72 5b 31 5d 20 3d 20 28 69 6e | in.r[1] = (in| 00002cd0 74 29 20 70 6f 6c 6c 62 6c 6f 63 6b 3b 0a 20 20 |t) pollblock;. | 00002ce0 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 28 57 69 6d | _kernel_swi(Wim| 00002cf0 70 5f 43 6c 6f 73 65 57 69 6e 64 6f 77 2c 20 26 |p_CloseWindow, &| 00002d00 69 6e 2c 20 26 6f 75 74 29 3b 0a 20 20 20 72 65 |in, &out);. re| 00002d10 74 75 72 6e 3b 0a 7d 0a 0a 63 68 61 72 20 2a 0a |turn;.}..char *.| 00002d20 67 65 74 69 63 6f 6e 74 65 78 74 70 6f 69 6e 74 |geticontextpoint| 00002d30 65 72 28 75 6e 73 69 67 6e 65 64 20 6c 6f 6e 67 |er(unsigned long| 00002d40 20 69 6e 74 20 77 69 6e 68 64 6c 2c 20 75 6e 73 | int winhdl, uns| 00002d50 69 67 6e 65 64 20 6c 6f 6e 67 20 69 6e 74 20 69 |igned long int i| 00002d60 63 6f 6e 68 64 6c 29 0a 7b 0a 20 20 20 2f 2a 20 |conhdl).{. /* | 00002d70 54 68 69 73 20 70 72 6f 63 65 64 75 72 65 20 69 |This procedure i| 00002d80 6e 74 65 72 72 6f 67 61 74 65 73 20 61 6e 20 69 |nterrogates an i| 00002d90 63 6f 6e 20 74 6f 20 64 65 74 65 72 6d 69 6e 65 |con to determine| 00002da0 20 74 68 65 20 61 64 64 72 65 73 73 20 77 68 65 | the address whe| 00002db0 72 65 20 69 74 73 0a 20 20 20 20 20 20 69 6e 64 |re its. ind| 00002dc0 69 72 65 63 74 65 64 20 74 65 78 74 20 64 61 74 |irected text dat| 00002dd0 61 20 69 73 20 73 74 6f 72 65 64 20 69 6e 20 6d |a is stored in m| 00002de0 65 6d 6f 72 79 2c 20 61 6e 64 20 72 65 74 75 72 |emory, and retur| 00002df0 6e 73 20 69 74 20 2a 2f 0a 0a 20 20 20 75 6e 73 |ns it */.. uns| 00002e00 69 67 6e 65 64 20 63 68 61 72 20 74 65 6d 70 5f |igned char temp_| 00002e10 62 75 66 66 65 72 5b 32 35 35 5d 3b 0a 20 20 20 |buffer[255];. | 00002e20 5f 6b 65 72 6e 65 6c 5f 73 77 69 5f 72 65 67 73 |_kernel_swi_regs| 00002e30 20 69 6e 2c 20 6f 75 74 3b 0a 20 20 20 63 68 61 | in, out;. cha| 00002e40 72 20 2a 72 65 73 75 6c 74 3b 0a 0a 20 20 20 77 |r *result;.. w| 00002e50 74 6f 62 28 77 69 6e 68 64 6c 2c 20 74 65 6d 70 |tob(winhdl, temp| 00002e60 5f 62 75 66 66 65 72 2c 20 30 29 3b 0a 20 20 20 |_buffer, 0);. | 00002e70 77 74 6f 62 28 69 63 6f 6e 68 64 6c 2c 20 74 65 |wtob(iconhdl, te| 00002e80 6d 70 5f 62 75 66 66 65 72 2c 20 34 29 3b 0a 0a |mp_buffer, 4);..| 00002e90 20 20 20 69 6e 2e 72 5b 31 5d 20 3d 20 28 69 6e | in.r[1] = (in| 00002ea0 74 29 20 74 65 6d 70 5f 62 75 66 66 65 72 3b 0a |t) temp_buffer;.| 00002eb0 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 28 57 | _kernel_swi(W| 00002ec0 69 6d 70 5f 47 65 74 49 63 6f 6e 53 74 61 74 65 |imp_GetIconState| 00002ed0 2c 20 26 69 6e 2c 20 26 6f 75 74 29 3b 0a 0a 20 |, &in, &out);.. | 00002ee0 20 20 72 65 73 75 6c 74 20 3d 20 28 63 68 61 72 | result = (char| 00002ef0 20 2a 29 20 62 74 6f 77 28 74 65 6d 70 5f 62 75 | *) btow(temp_bu| 00002f00 66 66 65 72 2c 20 32 38 29 3b 0a 20 20 20 72 65 |ffer, 28);. re| 00002f10 74 75 72 6e 20 72 65 73 75 6c 74 3b 0a 7d 0a 0a |turn result;.}..| 00002f20 76 6f 69 64 20 69 63 6f 6e 63 68 61 6e 67 65 28 |void iconchange(| 00002f30 63 68 61 72 20 2a 74 65 78 74 2c 20 75 6e 73 69 |char *text, unsi| 00002f40 67 6e 65 64 20 6c 6f 6e 67 20 69 6e 74 20 77 69 |gned long int wi| 00002f50 6e 5f 68 2c 20 75 6e 73 69 67 6e 65 64 20 6c 6f |n_h, unsigned lo| 00002f60 6e 67 20 69 6e 74 20 69 63 6f 6e 5f 68 29 0a 7b |ng int icon_h).{| 00002f70 0a 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 5f |. _kernel_swi_| 00002f80 72 65 67 73 20 69 6e 2c 20 6f 75 74 3b 0a 20 20 |regs in, out;. | 00002f90 20 63 68 61 72 20 2a 74 70 6f 69 6e 74 65 72 3b | char *tpointer;| 00002fa0 0a 20 20 20 75 6e 73 69 67 6e 65 64 20 63 68 61 |. unsigned cha| 00002fb0 72 20 74 65 6d 70 5f 62 75 66 66 65 72 5b 32 35 |r temp_buffer[25| 00002fc0 35 5d 3b 0a 0a 20 20 20 2f 2a 20 46 69 6e 64 20 |5];.. /* Find | 00002fd0 6f 75 74 20 77 68 65 72 65 20 74 68 65 20 69 63 |out where the ic| 00002fe0 6f 6e 27 73 20 69 6e 64 69 72 65 63 74 65 64 20 |on's indirected | 00002ff0 74 65 78 74 20 69 73 20 73 74 6f 72 65 64 20 69 |text is stored i| 00003000 6e 20 6d 65 6d 6f 72 79 20 61 6e 64 20 63 6f 70 |n memory and cop| 00003010 79 0a 20 20 20 20 20 20 61 20 6e 65 77 20 73 74 |y. a new st| 00003020 72 69 6e 67 20 74 6f 20 69 74 20 2a 2f 0a 20 20 |ring to it */. | 00003030 20 74 70 6f 69 6e 74 65 72 20 3d 20 67 65 74 69 | tpointer = geti| 00003040 63 6f 6e 74 65 78 74 70 6f 69 6e 74 65 72 28 77 |contextpointer(w| 00003050 69 6e 5f 68 2c 20 69 63 6f 6e 5f 68 29 3b 0a 20 |in_h, icon_h);. | 00003060 20 20 73 74 72 63 70 79 28 74 70 6f 69 6e 74 65 | strcpy(tpointe| 00003070 72 2c 20 74 65 78 74 29 3b 0a 0a 20 20 20 2f 2a |r, text);.. /*| 00003080 20 4e 6f 77 20 77 65 20 6e 65 65 64 20 74 6f 20 | Now we need to | 00003090 69 6e 66 6f 72 6d 20 74 68 65 20 57 49 4d 50 20 |inform the WIMP | 000030a0 74 68 61 74 20 74 68 65 20 69 63 6f 6e 20 6e 65 |that the icon ne| 000030b0 65 64 73 20 72 65 64 72 61 77 69 6e 67 20 62 79 |eds redrawing by| 000030c0 20 73 65 74 74 69 6e 67 0a 20 20 20 20 20 20 74 | setting. t| 000030d0 68 65 20 69 63 6f 6e 20 66 6c 61 67 73 20 2d 20 |he icon flags - | 000030e0 77 65 20 64 6f 6e 27 74 20 61 63 74 75 61 6c 6c |we don't actuall| 000030f0 79 20 63 68 61 6e 67 65 20 74 68 65 6d 20 77 69 |y change them wi| 00003100 74 68 20 74 68 69 73 20 63 61 6c 6c 2c 20 62 75 |th this call, bu| 00003110 74 20 74 68 69 73 0a 20 20 20 20 20 20 73 70 75 |t this. spu| 00003120 72 73 20 74 68 65 20 57 49 4d 50 20 69 6e 74 6f |rs the WIMP into| 00003130 20 61 63 74 69 6f 6e 20 2a 2f 0a 0a 20 20 20 77 | action */.. w| 00003140 74 6f 62 28 77 69 6e 5f 68 2c 20 74 65 6d 70 5f |tob(win_h, temp_| 00003150 62 75 66 66 65 72 2c 20 30 29 3b 0a 20 20 20 77 |buffer, 0);. w| 00003160 74 6f 62 28 69 63 6f 6e 5f 68 2c 20 74 65 6d 70 |tob(icon_h, temp| 00003170 5f 62 75 66 66 65 72 2c 20 34 29 3b 0a 20 20 20 |_buffer, 4);. | 00003180 77 74 6f 62 28 30 2c 20 74 65 6d 70 5f 62 75 66 |wtob(0, temp_buf| 00003190 66 65 72 2c 20 38 29 3b 0a 20 20 20 77 74 6f 62 |fer, 8);. wtob| 000031a0 28 30 2c 20 74 65 6d 70 5f 62 75 66 66 65 72 2c |(0, temp_buffer,| 000031b0 20 31 32 29 3b 0a 0a 20 20 20 69 6e 2e 72 5b 31 | 12);.. in.r[1| 000031c0 5d 20 3d 20 28 69 6e 74 29 20 74 65 6d 70 5f 62 |] = (int) temp_b| 000031d0 75 66 66 65 72 3b 0a 0a 20 20 20 5f 6b 65 72 6e |uffer;.. _kern| 000031e0 65 6c 5f 73 77 69 28 57 69 6d 70 5f 53 65 74 49 |el_swi(Wimp_SetI| 000031f0 63 6f 6e 53 74 61 74 65 2c 20 26 69 6e 2c 20 26 |conState, &in, &| 00003200 6f 75 74 29 3b 0a 20 20 20 72 65 74 75 72 6e 3b |out);. return;| 00003210 0a 7d 0a |.}.| 00003213
.