Home » Archimedes archive » Acorn User » AU 1997-08 B.adf » Regulars » WimpC/JulyC/!Window/c/Window
WimpC/JulyC/!Window/c/Window
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
| Tape/disk: | Home » Archimedes archive » Acorn User » AU 1997-08 B.adf » Regulars |
| Filename: | WimpC/JulyC/!Window/c/Window |
| Read OK: | ✔ |
| File size: | 1E6C bytes |
| Load address: | 0000 |
| Exec address: | 0000 |
Duplicates
There is 1 duplicate copy of this file in the archive:
- Archimedes archive » Acorn User » AU 1997-08 B.adf » Regulars » WimpC/AugC/!Window/c/Window
- Archimedes archive » Acorn User » AU 1997-08 B.adf » Regulars » WimpC/JulyC/!Window/c/Window
File contents
/* Demo C program to show plotting of icons within windows
* SJP Mumford, for Acorn User (May 1997) */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "AULib.h"
/* #defines */
#define MAX_WINDOWS 3
#define MAX_MENUS 1
#define RISC_OS_VERSION 310
#define POLL_MASK 1
#define SPRITE_AREA_SIZE 10240
#define TRANS_BUFFER_SIZE 1024
/* iconbar menu */
#define QUIT_OPTION 0
/* Global variables */
window_data win_data[MAX_WINDOWS];
menu_data men_data[MAX_MENUS];
unsigned char sprite_area[SPRITE_AREA_SIZE];
unsigned char translation_buffer[TRANS_BUFFER_SIZE];
unsigned char translation_buffer2[TRANS_BUFFER_SIZE];
int QUIT_FLAG = 0;
int CURRENT_MENU = 0;
char appname[] = "SpriteDemo";
char sprname[] = "!window";
long int msglist[] = {0};
/* Function prototyping */
int main(void);
void load_templates(void);
void wimp_msg(int, unsigned char[]);
void mouse_click(unsigned char[]);
void open_main_window(void);
void menu_selection(unsigned char[]);
void openwindow(unsigned char[]);
void closewindow(unsigned char[]);
void redraw_window(unsigned char[]);
void setup_sprite_area(void);
void plot_sprite(char [], int, int, unsigned char []);
void build_translation_table(char [], unsigned char []);
/* Main program */
int
main()
{
int task_handle, icon_handle;
unsigned char poll_block[256];
int poll_result, i;
/* Load templates and initialise things here */
/* Set up the application with the WIMP */
task_handle = au_initialise(RISC_OS_VERSION, appname, msglist);
icon_handle = au_create_iconbar_icon(IBAR_PRIOR_APP, IBAR_ONRIGHT, ICON_ISSPRITE | ICON_HCENTRE | ICON_VCENTRE | ICON_CLICKNOTIFIESONCE, sprname);
load_templates();
setup_sprite_area();
build_translation_table("screen", translation_buffer);
build_translation_table("testspr", translation_buffer2);
while (QUIT_FLAG == 0) {
/* Main polling loop */
poll_result = au_wimp_poll(POLL_MASK, poll_block);
switch (poll_result) {
case 1 : redraw_window(poll_block);
break;
case 2 : openwindow(poll_block);
break;
case 3 : closewindow(poll_block);
break;
case 6 : mouse_click(poll_block);
break;
case 9 : menu_selection(poll_block);
break;
case 17 :
case 18 :
case 19 : wimp_msg(poll_result, poll_block);
break;
}
/* End of main polling loop */
}
/* If we get this far, it's time to close down */
au_closedown(task_handle);
for(i = 0; i < MAX_WINDOWS; i++) {
free(win_data[i].win_name);
free(win_data[i].buffer);
free(win_data[i].workspace);
}
}
void
load_templates(void)
{
au_opentemplate("<Window$Dir>.Templates");
if(au_loadtemplate("MainWindow", &win_data[0], 0) == 0) {
au_report_error(1, "Template not found!", 1, appname);
QUIT_FLAG = 1;
}
au_closetemplate();
}
void
wimp_msg(int result, unsigned char pollblock[])
{
unsigned long int message_action;
message_action = au_bytetoword(pollblock, 16);
switch (message_action) {
case MESSAGE_QUIT : QUIT_FLAG = 1;
break;
case MESSAGE_MODECHANGE : build_translation_table("screen", translation_buffer);
build_translation_table("testspr", translation_buffer2);
break;
}
}
void mouse_click(unsigned char poll_block[])
{
int clk;
long int icon_num;
/* Determine which button was pressed */
clk = (int) au_bytetoword(poll_block, 8);
if((au_bytetoword(poll_block, 12) == -2) && (clk == 4)) {
open_main_window();
}
if((au_bytetoword(poll_block, 12) == -2) && (clk == 2)) {
/* Time to produce a menu */
au_buildmenu("Window", &men_data[0]);
/*au_addtomenu("Info", 0, win_data[1].win_handle, 0, &men_data[0]);*/
au_addtomenu("Quit", MENU_LASTITEM, -1, 0, &men_data[0]);
au_createmenu(&men_data[0]);
CURRENT_MENU = 1; /* keep track of the last menu we opened */
au_openmenu(&men_data[0], (int) au_bytetoword(poll_block, 0) - 64, (44*1+96));
return;
}
/* Check to see if it was in the main window */
if((au_bytetoword(poll_block, 12) == win_data[0].win_handle) && (clk == 4)) {
icon_num = au_bytetoword(poll_block, 16);
switch (icon_num) {
}
}
return;
}
void open_main_window(void)
{
_kernel_swi_regs in, out;
unsigned char temp_buffer[1024];
au_wordtobyte(win_data[0].win_handle, temp_buffer, 0);
in.r[1] = (int) temp_buffer;
_kernel_swi(Wimp_GetWindowInfo, &in, &out);
_kernel_swi(Wimp_OpenWindow, &in, &out);
return;
}
void menu_selection(unsigned char poll_block[])
{
long int first_hit;
if (CURRENT_MENU == 1) {
first_hit = au_bytetoword(poll_block, 0);
if (first_hit == QUIT_OPTION) {
QUIT_FLAG = 1;
}
}
CURRENT_MENU = 0;
return;
}
void
openwindow(unsigned char pollblock[])
{
_kernel_swi_regs in, out;
in.r[1] = (int) pollblock;
_kernel_swi(Wimp_OpenWindow, &in, &out);
return;
}
void
closewindow(unsigned char pollblock[])
{
_kernel_swi_regs in, out;
in.r[1] = (int) pollblock;
_kernel_swi(Wimp_CloseWindow, &in, &out);
return;
}
void
redraw_window(unsigned char pollblock[])
{
_kernel_swi_regs in, out;
int flag = 0;
long int visx1, visx2, visy1, visy2;
long int winx1, winx2, winy1, winy2;
long int workx1, workx2, worky1, worky2;
long int scrollx, scrolly;
long int testx, testy;
long int testx1, testx2, testy1, testy2;
in.r[1] = (int) pollblock;
_kernel_swi(Wimp_RedrawWindow, &in, &out);
flag = out.r[0];
while (flag) {
/* redraw window here */
winx1 = au_bytetoword(pollblock, 4);
winy1 = au_bytetoword(pollblock, 8);
winx2 = au_bytetoword(pollblock, 12);
winy2 = au_bytetoword(pollblock, 16);
visx1 = au_bytetoword(pollblock, 28);
visy1 = au_bytetoword(pollblock, 32);
visx2 = au_bytetoword(pollblock, 36);
visy2 = au_bytetoword(pollblock, 40);
scrollx = au_bytetoword(pollblock, 20);
scrolly = au_bytetoword(pollblock, 24);
workx1 = visx1 + (scrollx - winx1);
workx2 = visx2 + (scrollx - winx1);
worky1 = visy1 + (scrolly - winy2);
worky2 = visy2 + (scrolly - winy2);
/* These give the work coordinates of the area needing
* to be redrawn */
/* Now convert a work coordinate into a screen pixel */
testx = 25 - scrollx + winx1;
testy = -250 - scrolly + winy2;
testx1 = 300 - scrollx + winx1;
testy1 = -250 - scrolly + winy2;
testx2 = 600 - scrollx + winx1;
testy2 = -250 - scrolly + winy2;
plot_sprite("screen", (int) testx, (int) testy, translation_buffer);
plot_sprite("testspr", (int) testx+150, (int) testy+50, translation_buffer2);
plot_sprite("screen", (int) testx1, (int) testy1, translation_buffer);
plot_sprite("testspr", (int) testx1+150, (int) testy+50, translation_buffer2);
plot_sprite("screen", (int) testx2, (int) testy2, translation_buffer);
/* redraw window finished */
in.r[1] = (int) pollblock;
_kernel_swi(Wimp_GetRectangle, &in, &out);
flag = out.r[0];
}
}
void
setup_sprite_area(void)
{
_kernel_swi_regs in, out;
char filename[] = "<Window$Dir>.Sprites";
au_wordtobyte(SPRITE_AREA_SIZE, sprite_area, 0);
au_wordtobyte(16, sprite_area, 8);
in.r[0] = 256+9;
in.r[1] = (int) sprite_area;
_kernel_swi(OS_SpriteOp, &in, &out);
/* Load the sprites */
in.r[0] = 256+10;
in.r[1] = (int) sprite_area;
in.r[2] = (int) filename;
_kernel_swi(OS_SpriteOp, &in, &out);
}
void
plot_sprite(char sprname[], int x_pix, int y_pix, unsigned char trans_buffer[])
{
_kernel_swi_regs in, out;
in.r[0] = 256+52;
in.r[1] = (int) sprite_area; /* global variable */
in.r[2] = (int) sprname;
in.r[3] = x_pix;
in.r[4] = y_pix;
in.r[5] = 0;
in.r[6] = 0;
in.r[7] = (int) trans_buffer;
_kernel_swi(OS_SpriteOp, &in, &out);
}
void
build_translation_table(char text_buffer[], unsigned char trans_buffer[])
{
_kernel_swi_regs in, out;
in.r[0] = (int) sprite_area;
in.r[1] = (int) text_buffer;
in.r[2] = -1;
in.r[3] = -1;
in.r[4] = (int) trans_buffer;
in.r[5] = 0;
_kernel_swi(ColourTrans_SelectTable, &in, &out);
}
/* End of program */
00000000 2f 2a 20 44 65 6d 6f 20 43 20 70 72 6f 67 72 61 |/* Demo C progra|
00000010 6d 20 74 6f 20 73 68 6f 77 20 70 6c 6f 74 74 69 |m to show plotti|
00000020 6e 67 20 6f 66 20 69 63 6f 6e 73 20 77 69 74 68 |ng of icons with|
00000030 69 6e 20 77 69 6e 64 6f 77 73 0a 20 2a 20 53 4a |in windows. * SJ|
00000040 50 20 4d 75 6d 66 6f 72 64 2c 20 66 6f 72 20 41 |P Mumford, for A|
00000050 63 6f 72 6e 20 55 73 65 72 20 28 4d 61 79 20 31 |corn User (May 1|
00000060 39 39 37 29 20 2a 2f 0a 0a 23 69 6e 63 6c 75 64 |997) */..#includ|
00000070 65 20 3c 73 74 64 69 6f 2e 68 3e 0a 23 69 6e 63 |e <stdio.h>.#inc|
00000080 6c 75 64 65 20 3c 73 74 64 6c 69 62 2e 68 3e 0a |lude <stdlib.h>.|
00000090 23 69 6e 63 6c 75 64 65 20 3c 73 74 72 69 6e 67 |#include <string|
000000a0 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 22 41 55 |.h>.#include "AU|
000000b0 4c 69 62 2e 68 22 0a 0a 2f 2a 20 23 64 65 66 69 |Lib.h"../* #defi|
000000c0 6e 65 73 20 2a 2f 0a 0a 23 64 65 66 69 6e 65 20 |nes */..#define |
000000d0 4d 41 58 5f 57 49 4e 44 4f 57 53 20 33 0a 23 64 |MAX_WINDOWS 3.#d|
000000e0 65 66 69 6e 65 20 4d 41 58 5f 4d 45 4e 55 53 20 |efine MAX_MENUS |
000000f0 31 0a 23 64 65 66 69 6e 65 20 52 49 53 43 5f 4f |1.#define RISC_O|
00000100 53 5f 56 45 52 53 49 4f 4e 20 33 31 30 0a 23 64 |S_VERSION 310.#d|
00000110 65 66 69 6e 65 20 50 4f 4c 4c 5f 4d 41 53 4b 20 |efine POLL_MASK |
00000120 31 0a 23 64 65 66 69 6e 65 20 53 50 52 49 54 45 |1.#define SPRITE|
00000130 5f 41 52 45 41 5f 53 49 5a 45 20 31 30 32 34 30 |_AREA_SIZE 10240|
00000140 0a 23 64 65 66 69 6e 65 20 54 52 41 4e 53 5f 42 |.#define TRANS_B|
00000150 55 46 46 45 52 5f 53 49 5a 45 20 31 30 32 34 0a |UFFER_SIZE 1024.|
00000160 0a 2f 2a 20 69 63 6f 6e 62 61 72 20 6d 65 6e 75 |./* iconbar menu|
00000170 20 2a 2f 0a 0a 23 64 65 66 69 6e 65 20 51 55 49 | */..#define QUI|
00000180 54 5f 4f 50 54 49 4f 4e 20 30 0a 0a 2f 2a 20 47 |T_OPTION 0../* G|
00000190 6c 6f 62 61 6c 20 76 61 72 69 61 62 6c 65 73 20 |lobal variables |
000001a0 2a 2f 0a 0a 77 69 6e 64 6f 77 5f 64 61 74 61 09 |*/..window_data.|
000001b0 77 69 6e 5f 64 61 74 61 5b 4d 41 58 5f 57 49 4e |win_data[MAX_WIN|
000001c0 44 4f 57 53 5d 3b 0a 6d 65 6e 75 5f 64 61 74 61 |DOWS];.menu_data|
000001d0 09 6d 65 6e 5f 64 61 74 61 5b 4d 41 58 5f 4d 45 |.men_data[MAX_ME|
000001e0 4e 55 53 5d 3b 0a 75 6e 73 69 67 6e 65 64 20 63 |NUS];.unsigned c|
000001f0 68 61 72 20 73 70 72 69 74 65 5f 61 72 65 61 5b |har sprite_area[|
00000200 53 50 52 49 54 45 5f 41 52 45 41 5f 53 49 5a 45 |SPRITE_AREA_SIZE|
00000210 5d 3b 0a 75 6e 73 69 67 6e 65 64 20 63 68 61 72 |];.unsigned char|
00000220 20 74 72 61 6e 73 6c 61 74 69 6f 6e 5f 62 75 66 | translation_buf|
00000230 66 65 72 5b 54 52 41 4e 53 5f 42 55 46 46 45 52 |fer[TRANS_BUFFER|
00000240 5f 53 49 5a 45 5d 3b 0a 75 6e 73 69 67 6e 65 64 |_SIZE];.unsigned|
00000250 20 63 68 61 72 20 74 72 61 6e 73 6c 61 74 69 6f | char translatio|
00000260 6e 5f 62 75 66 66 65 72 32 5b 54 52 41 4e 53 5f |n_buffer2[TRANS_|
00000270 42 55 46 46 45 52 5f 53 49 5a 45 5d 3b 0a 0a 69 |BUFFER_SIZE];..i|
00000280 6e 74 20 51 55 49 54 5f 46 4c 41 47 20 3d 20 30 |nt QUIT_FLAG = 0|
00000290 3b 0a 69 6e 74 20 43 55 52 52 45 4e 54 5f 4d 45 |;.int CURRENT_ME|
000002a0 4e 55 20 3d 20 30 3b 0a 63 68 61 72 20 61 70 70 |NU = 0;.char app|
000002b0 6e 61 6d 65 5b 5d 20 3d 20 22 53 70 72 69 74 65 |name[] = "Sprite|
000002c0 44 65 6d 6f 22 3b 0a 63 68 61 72 20 73 70 72 6e |Demo";.char sprn|
000002d0 61 6d 65 5b 5d 20 3d 20 22 21 77 69 6e 64 6f 77 |ame[] = "!window|
000002e0 22 3b 0a 6c 6f 6e 67 20 69 6e 74 20 6d 73 67 6c |";.long int msgl|
000002f0 69 73 74 5b 5d 20 3d 20 7b 30 7d 3b 0a 0a 2f 2a |ist[] = {0};../*|
00000300 20 46 75 6e 63 74 69 6f 6e 20 70 72 6f 74 6f 74 | Function protot|
00000310 79 70 69 6e 67 20 2a 2f 0a 0a 69 6e 74 09 6d 61 |yping */..int.ma|
00000320 69 6e 28 76 6f 69 64 29 3b 0a 76 6f 69 64 09 6c |in(void);.void.l|
00000330 6f 61 64 5f 74 65 6d 70 6c 61 74 65 73 28 76 6f |oad_templates(vo|
00000340 69 64 29 3b 0a 76 6f 69 64 09 77 69 6d 70 5f 6d |id);.void.wimp_m|
00000350 73 67 28 69 6e 74 2c 20 75 6e 73 69 67 6e 65 64 |sg(int, unsigned|
00000360 20 63 68 61 72 5b 5d 29 3b 0a 76 6f 69 64 09 6d | char[]);.void.m|
00000370 6f 75 73 65 5f 63 6c 69 63 6b 28 75 6e 73 69 67 |ouse_click(unsig|
00000380 6e 65 64 20 63 68 61 72 5b 5d 29 3b 0a 76 6f 69 |ned char[]);.voi|
00000390 64 09 6f 70 65 6e 5f 6d 61 69 6e 5f 77 69 6e 64 |d.open_main_wind|
000003a0 6f 77 28 76 6f 69 64 29 3b 0a 76 6f 69 64 09 6d |ow(void);.void.m|
000003b0 65 6e 75 5f 73 65 6c 65 63 74 69 6f 6e 28 75 6e |enu_selection(un|
000003c0 73 69 67 6e 65 64 20 63 68 61 72 5b 5d 29 3b 0a |signed char[]);.|
000003d0 76 6f 69 64 09 6f 70 65 6e 77 69 6e 64 6f 77 28 |void.openwindow(|
000003e0 75 6e 73 69 67 6e 65 64 20 63 68 61 72 5b 5d 29 |unsigned char[])|
000003f0 3b 0a 76 6f 69 64 09 63 6c 6f 73 65 77 69 6e 64 |;.void.closewind|
00000400 6f 77 28 75 6e 73 69 67 6e 65 64 20 63 68 61 72 |ow(unsigned char|
00000410 5b 5d 29 3b 0a 76 6f 69 64 09 72 65 64 72 61 77 |[]);.void.redraw|
00000420 5f 77 69 6e 64 6f 77 28 75 6e 73 69 67 6e 65 64 |_window(unsigned|
00000430 20 63 68 61 72 5b 5d 29 3b 0a 76 6f 69 64 09 73 | char[]);.void.s|
00000440 65 74 75 70 5f 73 70 72 69 74 65 5f 61 72 65 61 |etup_sprite_area|
00000450 28 76 6f 69 64 29 3b 0a 76 6f 69 64 09 70 6c 6f |(void);.void.plo|
00000460 74 5f 73 70 72 69 74 65 28 63 68 61 72 20 5b 5d |t_sprite(char []|
00000470 2c 20 69 6e 74 2c 20 69 6e 74 2c 20 75 6e 73 69 |, int, int, unsi|
00000480 67 6e 65 64 20 63 68 61 72 20 5b 5d 29 3b 0a 76 |gned char []);.v|
00000490 6f 69 64 09 62 75 69 6c 64 5f 74 72 61 6e 73 6c |oid.build_transl|
000004a0 61 74 69 6f 6e 5f 74 61 62 6c 65 28 63 68 61 72 |ation_table(char|
000004b0 20 5b 5d 2c 20 75 6e 73 69 67 6e 65 64 20 63 68 | [], unsigned ch|
000004c0 61 72 20 5b 5d 29 3b 0a 0a 2f 2a 20 4d 61 69 6e |ar []);../* Main|
000004d0 20 70 72 6f 67 72 61 6d 20 2a 2f 0a 0a 69 6e 74 | program */..int|
000004e0 0a 6d 61 69 6e 28 29 0a 7b 0a 09 69 6e 74 20 74 |.main().{..int t|
000004f0 61 73 6b 5f 68 61 6e 64 6c 65 2c 20 69 63 6f 6e |ask_handle, icon|
00000500 5f 68 61 6e 64 6c 65 3b 0a 09 75 6e 73 69 67 6e |_handle;..unsign|
00000510 65 64 20 63 68 61 72 20 70 6f 6c 6c 5f 62 6c 6f |ed char poll_blo|
00000520 63 6b 5b 32 35 36 5d 3b 0a 09 69 6e 74 20 70 6f |ck[256];..int po|
00000530 6c 6c 5f 72 65 73 75 6c 74 2c 20 69 3b 0a 0a 09 |ll_result, i;...|
00000540 2f 2a 20 4c 6f 61 64 20 74 65 6d 70 6c 61 74 65 |/* Load template|
00000550 73 20 61 6e 64 20 69 6e 69 74 69 61 6c 69 73 65 |s and initialise|
00000560 20 74 68 69 6e 67 73 20 68 65 72 65 20 2a 2f 0a | things here */.|
00000570 0a 09 2f 2a 20 53 65 74 20 75 70 20 74 68 65 20 |../* Set up the |
00000580 61 70 70 6c 69 63 61 74 69 6f 6e 20 77 69 74 68 |application with|
00000590 20 74 68 65 20 57 49 4d 50 20 2a 2f 0a 09 74 61 | the WIMP */..ta|
000005a0 73 6b 5f 68 61 6e 64 6c 65 20 3d 20 61 75 5f 69 |sk_handle = au_i|
000005b0 6e 69 74 69 61 6c 69 73 65 28 52 49 53 43 5f 4f |nitialise(RISC_O|
000005c0 53 5f 56 45 52 53 49 4f 4e 2c 20 61 70 70 6e 61 |S_VERSION, appna|
000005d0 6d 65 2c 20 6d 73 67 6c 69 73 74 29 3b 0a 09 69 |me, msglist);..i|
000005e0 63 6f 6e 5f 68 61 6e 64 6c 65 20 3d 20 61 75 5f |con_handle = au_|
000005f0 63 72 65 61 74 65 5f 69 63 6f 6e 62 61 72 5f 69 |create_iconbar_i|
00000600 63 6f 6e 28 49 42 41 52 5f 50 52 49 4f 52 5f 41 |con(IBAR_PRIOR_A|
00000610 50 50 2c 20 49 42 41 52 5f 4f 4e 52 49 47 48 54 |PP, IBAR_ONRIGHT|
00000620 2c 20 49 43 4f 4e 5f 49 53 53 50 52 49 54 45 20 |, ICON_ISSPRITE |
00000630 7c 20 49 43 4f 4e 5f 48 43 45 4e 54 52 45 20 7c || ICON_HCENTRE ||
00000640 20 49 43 4f 4e 5f 56 43 45 4e 54 52 45 20 7c 20 | ICON_VCENTRE | |
00000650 49 43 4f 4e 5f 43 4c 49 43 4b 4e 4f 54 49 46 49 |ICON_CLICKNOTIFI|
00000660 45 53 4f 4e 43 45 2c 20 73 70 72 6e 61 6d 65 29 |ESONCE, sprname)|
00000670 3b 0a 0a 09 6c 6f 61 64 5f 74 65 6d 70 6c 61 74 |;...load_templat|
00000680 65 73 28 29 3b 0a 09 73 65 74 75 70 5f 73 70 72 |es();..setup_spr|
00000690 69 74 65 5f 61 72 65 61 28 29 3b 0a 09 62 75 69 |ite_area();..bui|
000006a0 6c 64 5f 74 72 61 6e 73 6c 61 74 69 6f 6e 5f 74 |ld_translation_t|
000006b0 61 62 6c 65 28 22 73 63 72 65 65 6e 22 2c 20 74 |able("screen", t|
000006c0 72 61 6e 73 6c 61 74 69 6f 6e 5f 62 75 66 66 65 |ranslation_buffe|
000006d0 72 29 3b 0a 09 62 75 69 6c 64 5f 74 72 61 6e 73 |r);..build_trans|
000006e0 6c 61 74 69 6f 6e 5f 74 61 62 6c 65 28 22 74 65 |lation_table("te|
000006f0 73 74 73 70 72 22 2c 20 74 72 61 6e 73 6c 61 74 |stspr", translat|
00000700 69 6f 6e 5f 62 75 66 66 65 72 32 29 3b 0a 0a 09 |ion_buffer2);...|
00000710 77 68 69 6c 65 20 28 51 55 49 54 5f 46 4c 41 47 |while (QUIT_FLAG|
00000720 20 3d 3d 20 30 29 20 7b 0a 09 09 2f 2a 20 4d 61 | == 0) {.../* Ma|
00000730 69 6e 20 70 6f 6c 6c 69 6e 67 20 6c 6f 6f 70 20 |in polling loop |
00000740 2a 2f 0a 09 09 70 6f 6c 6c 5f 72 65 73 75 6c 74 |*/...poll_result|
00000750 20 3d 20 61 75 5f 77 69 6d 70 5f 70 6f 6c 6c 28 | = au_wimp_poll(|
00000760 50 4f 4c 4c 5f 4d 41 53 4b 2c 20 70 6f 6c 6c 5f |POLL_MASK, poll_|
00000770 62 6c 6f 63 6b 29 3b 0a 0a 09 09 73 77 69 74 63 |block);....switc|
00000780 68 20 28 70 6f 6c 6c 5f 72 65 73 75 6c 74 29 20 |h (poll_result) |
00000790 7b 0a 09 09 09 63 61 73 65 20 20 31 20 3a 20 72 |{....case 1 : r|
000007a0 65 64 72 61 77 5f 77 69 6e 64 6f 77 28 70 6f 6c |edraw_window(pol|
000007b0 6c 5f 62 6c 6f 63 6b 29 3b 0a 09 09 09 09 09 62 |l_block);......b|
000007c0 72 65 61 6b 3b 0a 09 09 09 63 61 73 65 20 20 32 |reak;....case 2|
000007d0 20 3a 20 6f 70 65 6e 77 69 6e 64 6f 77 28 70 6f | : openwindow(po|
000007e0 6c 6c 5f 62 6c 6f 63 6b 29 3b 0a 09 09 09 09 09 |ll_block);......|
000007f0 62 72 65 61 6b 3b 0a 09 09 09 63 61 73 65 20 20 |break;....case |
00000800 33 20 3a 20 63 6c 6f 73 65 77 69 6e 64 6f 77 28 |3 : closewindow(|
00000810 70 6f 6c 6c 5f 62 6c 6f 63 6b 29 3b 0a 09 09 09 |poll_block);....|
00000820 09 09 62 72 65 61 6b 3b 0a 09 09 09 63 61 73 65 |..break;....case|
00000830 20 20 36 20 3a 20 6d 6f 75 73 65 5f 63 6c 69 63 | 6 : mouse_clic|
00000840 6b 28 70 6f 6c 6c 5f 62 6c 6f 63 6b 29 3b 0a 09 |k(poll_block);..|
00000850 09 09 09 09 62 72 65 61 6b 3b 0a 09 09 09 63 61 |....break;....ca|
00000860 73 65 20 20 39 20 3a 20 6d 65 6e 75 5f 73 65 6c |se 9 : menu_sel|
00000870 65 63 74 69 6f 6e 28 70 6f 6c 6c 5f 62 6c 6f 63 |ection(poll_bloc|
00000880 6b 29 3b 0a 09 09 09 09 09 62 72 65 61 6b 3b 0a |k);......break;.|
00000890 09 09 09 63 61 73 65 20 31 37 20 3a 0a 09 09 09 |...case 17 :....|
000008a0 63 61 73 65 20 31 38 20 3a 0a 09 09 09 63 61 73 |case 18 :....cas|
000008b0 65 20 31 39 20 3a 20 77 69 6d 70 5f 6d 73 67 28 |e 19 : wimp_msg(|
000008c0 70 6f 6c 6c 5f 72 65 73 75 6c 74 2c 20 70 6f 6c |poll_result, pol|
000008d0 6c 5f 62 6c 6f 63 6b 29 3b 0a 09 09 09 09 09 62 |l_block);......b|
000008e0 72 65 61 6b 3b 0a 09 09 7d 0a 0a 09 2f 2a 20 45 |reak;...}.../* E|
000008f0 6e 64 20 6f 66 20 6d 61 69 6e 20 70 6f 6c 6c 69 |nd of main polli|
00000900 6e 67 20 6c 6f 6f 70 20 2a 2f 0a 09 7d 0a 0a 09 |ng loop */..}...|
00000910 2f 2a 20 49 66 20 77 65 20 67 65 74 20 74 68 69 |/* If we get thi|
00000920 73 20 66 61 72 2c 20 69 74 27 73 20 74 69 6d 65 |s far, it's time|
00000930 20 74 6f 20 63 6c 6f 73 65 20 64 6f 77 6e 20 2a | to close down *|
00000940 2f 0a 09 61 75 5f 63 6c 6f 73 65 64 6f 77 6e 28 |/..au_closedown(|
00000950 74 61 73 6b 5f 68 61 6e 64 6c 65 29 3b 0a 0a 09 |task_handle);...|
00000960 66 6f 72 28 69 20 3d 20 30 3b 20 69 20 3c 20 4d |for(i = 0; i < M|
00000970 41 58 5f 57 49 4e 44 4f 57 53 3b 20 69 2b 2b 29 |AX_WINDOWS; i++)|
00000980 20 7b 0a 09 09 66 72 65 65 28 77 69 6e 5f 64 61 | {...free(win_da|
00000990 74 61 5b 69 5d 2e 77 69 6e 5f 6e 61 6d 65 29 3b |ta[i].win_name);|
000009a0 0a 09 09 66 72 65 65 28 77 69 6e 5f 64 61 74 61 |...free(win_data|
000009b0 5b 69 5d 2e 62 75 66 66 65 72 29 3b 0a 09 09 66 |[i].buffer);...f|
000009c0 72 65 65 28 77 69 6e 5f 64 61 74 61 5b 69 5d 2e |ree(win_data[i].|
000009d0 77 6f 72 6b 73 70 61 63 65 29 3b 0a 09 7d 0a 7d |workspace);..}.}|
000009e0 0a 0a 76 6f 69 64 0a 6c 6f 61 64 5f 74 65 6d 70 |..void.load_temp|
000009f0 6c 61 74 65 73 28 76 6f 69 64 29 0a 7b 0a 09 61 |lates(void).{..a|
00000a00 75 5f 6f 70 65 6e 74 65 6d 70 6c 61 74 65 28 22 |u_opentemplate("|
00000a10 3c 57 69 6e 64 6f 77 24 44 69 72 3e 2e 54 65 6d |<Window$Dir>.Tem|
00000a20 70 6c 61 74 65 73 22 29 3b 0a 0a 09 69 66 28 61 |plates");...if(a|
00000a30 75 5f 6c 6f 61 64 74 65 6d 70 6c 61 74 65 28 22 |u_loadtemplate("|
00000a40 4d 61 69 6e 57 69 6e 64 6f 77 22 2c 20 26 77 69 |MainWindow", &wi|
00000a50 6e 5f 64 61 74 61 5b 30 5d 2c 20 30 29 20 3d 3d |n_data[0], 0) ==|
00000a60 20 30 29 20 7b 0a 09 09 61 75 5f 72 65 70 6f 72 | 0) {...au_repor|
00000a70 74 5f 65 72 72 6f 72 28 31 2c 20 22 54 65 6d 70 |t_error(1, "Temp|
00000a80 6c 61 74 65 20 6e 6f 74 20 66 6f 75 6e 64 21 22 |late not found!"|
00000a90 2c 20 31 2c 20 61 70 70 6e 61 6d 65 29 3b 0a 09 |, 1, appname);..|
00000aa0 09 51 55 49 54 5f 46 4c 41 47 20 3d 20 31 3b 0a |.QUIT_FLAG = 1;.|
00000ab0 09 7d 0a 0a 09 61 75 5f 63 6c 6f 73 65 74 65 6d |.}...au_closetem|
00000ac0 70 6c 61 74 65 28 29 3b 0a 7d 0a 0a 76 6f 69 64 |plate();.}..void|
00000ad0 0a 77 69 6d 70 5f 6d 73 67 28 69 6e 74 20 72 65 |.wimp_msg(int re|
00000ae0 73 75 6c 74 2c 20 75 6e 73 69 67 6e 65 64 20 63 |sult, unsigned c|
00000af0 68 61 72 20 70 6f 6c 6c 62 6c 6f 63 6b 5b 5d 29 |har pollblock[])|
00000b00 0a 7b 0a 09 75 6e 73 69 67 6e 65 64 20 6c 6f 6e |.{..unsigned lon|
00000b10 67 20 69 6e 74 09 6d 65 73 73 61 67 65 5f 61 63 |g int.message_ac|
00000b20 74 69 6f 6e 3b 0a 0a 09 6d 65 73 73 61 67 65 5f |tion;...message_|
00000b30 61 63 74 69 6f 6e 20 3d 20 61 75 5f 62 79 74 65 |action = au_byte|
00000b40 74 6f 77 6f 72 64 28 70 6f 6c 6c 62 6c 6f 63 6b |toword(pollblock|
00000b50 2c 20 31 36 29 3b 0a 0a 09 73 77 69 74 63 68 20 |, 16);...switch |
00000b60 28 6d 65 73 73 61 67 65 5f 61 63 74 69 6f 6e 29 |(message_action)|
00000b70 20 7b 0a 09 09 63 61 73 65 20 4d 45 53 53 41 47 | {...case MESSAG|
00000b80 45 5f 51 55 49 54 20 3a 20 51 55 49 54 5f 46 4c |E_QUIT : QUIT_FL|
00000b90 41 47 20 3d 20 31 3b 0a 09 09 09 62 72 65 61 6b |AG = 1;....break|
00000ba0 3b 0a 09 09 63 61 73 65 20 4d 45 53 53 41 47 45 |;...case MESSAGE|
00000bb0 5f 4d 4f 44 45 43 48 41 4e 47 45 20 3a 20 62 75 |_MODECHANGE : bu|
00000bc0 69 6c 64 5f 74 72 61 6e 73 6c 61 74 69 6f 6e 5f |ild_translation_|
00000bd0 74 61 62 6c 65 28 22 73 63 72 65 65 6e 22 2c 20 |table("screen", |
00000be0 74 72 61 6e 73 6c 61 74 69 6f 6e 5f 62 75 66 66 |translation_buff|
00000bf0 65 72 29 3b 0a 09 09 09 62 75 69 6c 64 5f 74 72 |er);....build_tr|
00000c00 61 6e 73 6c 61 74 69 6f 6e 5f 74 61 62 6c 65 28 |anslation_table(|
00000c10 22 74 65 73 74 73 70 72 22 2c 20 74 72 61 6e 73 |"testspr", trans|
00000c20 6c 61 74 69 6f 6e 5f 62 75 66 66 65 72 32 29 3b |lation_buffer2);|
00000c30 0a 09 09 09 62 72 65 61 6b 3b 0a 09 7d 0a 7d 0a |....break;..}.}.|
00000c40 0a 76 6f 69 64 20 6d 6f 75 73 65 5f 63 6c 69 63 |.void mouse_clic|
00000c50 6b 28 75 6e 73 69 67 6e 65 64 20 63 68 61 72 20 |k(unsigned char |
00000c60 70 6f 6c 6c 5f 62 6c 6f 63 6b 5b 5d 29 0a 7b 0a |poll_block[]).{.|
00000c70 09 69 6e 74 09 63 6c 6b 3b 0a 09 6c 6f 6e 67 20 |.int.clk;..long |
00000c80 69 6e 74 09 69 63 6f 6e 5f 6e 75 6d 3b 0a 0a 09 |int.icon_num;...|
00000c90 2f 2a 20 44 65 74 65 72 6d 69 6e 65 20 77 68 69 |/* Determine whi|
00000ca0 63 68 20 62 75 74 74 6f 6e 20 77 61 73 20 70 72 |ch button was pr|
00000cb0 65 73 73 65 64 20 2a 2f 0a 09 63 6c 6b 20 3d 20 |essed */..clk = |
00000cc0 28 69 6e 74 29 20 61 75 5f 62 79 74 65 74 6f 77 |(int) au_bytetow|
00000cd0 6f 72 64 28 70 6f 6c 6c 5f 62 6c 6f 63 6b 2c 20 |ord(poll_block, |
00000ce0 38 29 3b 20 0a 0a 09 69 66 28 28 61 75 5f 62 79 |8); ...if((au_by|
00000cf0 74 65 74 6f 77 6f 72 64 28 70 6f 6c 6c 5f 62 6c |tetoword(poll_bl|
00000d00 6f 63 6b 2c 20 31 32 29 20 3d 3d 20 2d 32 29 20 |ock, 12) == -2) |
00000d10 26 26 20 28 63 6c 6b 20 3d 3d 20 34 29 29 20 7b |&& (clk == 4)) {|
00000d20 0a 09 6f 70 65 6e 5f 6d 61 69 6e 5f 77 69 6e 64 |..open_main_wind|
00000d30 6f 77 28 29 3b 0a 09 7d 0a 0a 09 69 66 28 28 61 |ow();..}...if((a|
00000d40 75 5f 62 79 74 65 74 6f 77 6f 72 64 28 70 6f 6c |u_bytetoword(pol|
00000d50 6c 5f 62 6c 6f 63 6b 2c 20 31 32 29 20 3d 3d 20 |l_block, 12) == |
00000d60 2d 32 29 20 26 26 20 28 63 6c 6b 20 3d 3d 20 32 |-2) && (clk == 2|
00000d70 29 29 20 7b 0a 09 09 2f 2a 20 54 69 6d 65 20 74 |)) {.../* Time t|
00000d80 6f 20 70 72 6f 64 75 63 65 20 61 20 6d 65 6e 75 |o produce a menu|
00000d90 20 2a 2f 0a 09 09 61 75 5f 62 75 69 6c 64 6d 65 | */...au_buildme|
00000da0 6e 75 28 22 57 69 6e 64 6f 77 22 2c 20 26 6d 65 |nu("Window", &me|
00000db0 6e 5f 64 61 74 61 5b 30 5d 29 3b 0a 09 09 2f 2a |n_data[0]);.../*|
00000dc0 61 75 5f 61 64 64 74 6f 6d 65 6e 75 28 22 49 6e |au_addtomenu("In|
00000dd0 66 6f 22 2c 20 30 2c 20 77 69 6e 5f 64 61 74 61 |fo", 0, win_data|
00000de0 5b 31 5d 2e 77 69 6e 5f 68 61 6e 64 6c 65 2c 20 |[1].win_handle, |
00000df0 30 2c 20 26 6d 65 6e 5f 64 61 74 61 5b 30 5d 29 |0, &men_data[0])|
00000e00 3b 2a 2f 0a 09 09 61 75 5f 61 64 64 74 6f 6d 65 |;*/...au_addtome|
00000e10 6e 75 28 22 51 75 69 74 22 2c 20 4d 45 4e 55 5f |nu("Quit", MENU_|
00000e20 4c 41 53 54 49 54 45 4d 2c 20 2d 31 2c 20 30 2c |LASTITEM, -1, 0,|
00000e30 20 26 6d 65 6e 5f 64 61 74 61 5b 30 5d 29 3b 0a | &men_data[0]);.|
00000e40 09 09 61 75 5f 63 72 65 61 74 65 6d 65 6e 75 28 |..au_createmenu(|
00000e50 26 6d 65 6e 5f 64 61 74 61 5b 30 5d 29 3b 0a 09 |&men_data[0]);..|
00000e60 09 43 55 52 52 45 4e 54 5f 4d 45 4e 55 20 3d 20 |.CURRENT_MENU = |
00000e70 31 3b 20 2f 2a 20 6b 65 65 70 20 74 72 61 63 6b |1; /* keep track|
00000e80 20 6f 66 20 74 68 65 20 6c 61 73 74 20 6d 65 6e | of the last men|
00000e90 75 20 77 65 20 6f 70 65 6e 65 64 20 2a 2f 0a 09 |u we opened */..|
00000ea0 09 61 75 5f 6f 70 65 6e 6d 65 6e 75 28 26 6d 65 |.au_openmenu(&me|
00000eb0 6e 5f 64 61 74 61 5b 30 5d 2c 20 28 69 6e 74 29 |n_data[0], (int)|
00000ec0 20 61 75 5f 62 79 74 65 74 6f 77 6f 72 64 28 70 | au_bytetoword(p|
00000ed0 6f 6c 6c 5f 62 6c 6f 63 6b 2c 20 30 29 20 2d 20 |oll_block, 0) - |
00000ee0 36 34 2c 20 28 34 34 2a 31 2b 39 36 29 29 3b 0a |64, (44*1+96));.|
00000ef0 09 09 72 65 74 75 72 6e 3b 0a 09 7d 0a 0a 09 2f |..return;..}.../|
00000f00 2a 20 43 68 65 63 6b 20 74 6f 20 73 65 65 20 69 |* Check to see i|
00000f10 66 20 69 74 20 77 61 73 20 69 6e 20 74 68 65 20 |f it was in the |
00000f20 6d 61 69 6e 20 77 69 6e 64 6f 77 20 2a 2f 0a 09 |main window */..|
00000f30 69 66 28 28 61 75 5f 62 79 74 65 74 6f 77 6f 72 |if((au_bytetowor|
00000f40 64 28 70 6f 6c 6c 5f 62 6c 6f 63 6b 2c 20 31 32 |d(poll_block, 12|
00000f50 29 20 3d 3d 20 77 69 6e 5f 64 61 74 61 5b 30 5d |) == win_data[0]|
00000f60 2e 77 69 6e 5f 68 61 6e 64 6c 65 29 20 26 26 20 |.win_handle) && |
00000f70 28 63 6c 6b 20 3d 3d 20 34 29 29 20 7b 0a 09 09 |(clk == 4)) {...|
00000f80 69 63 6f 6e 5f 6e 75 6d 20 3d 20 61 75 5f 62 79 |icon_num = au_by|
00000f90 74 65 74 6f 77 6f 72 64 28 70 6f 6c 6c 5f 62 6c |tetoword(poll_bl|
00000fa0 6f 63 6b 2c 20 31 36 29 3b 0a 09 09 73 77 69 74 |ock, 16);...swit|
00000fb0 63 68 20 28 69 63 6f 6e 5f 6e 75 6d 29 20 7b 0a |ch (icon_num) {.|
00000fc0 09 09 7d 0a 09 7d 0a 0a 09 72 65 74 75 72 6e 3b |..}..}...return;|
00000fd0 0a 7d 0a 0a 76 6f 69 64 20 6f 70 65 6e 5f 6d 61 |.}..void open_ma|
00000fe0 69 6e 5f 77 69 6e 64 6f 77 28 76 6f 69 64 29 0a |in_window(void).|
00000ff0 7b 0a 09 5f 6b 65 72 6e 65 6c 5f 73 77 69 5f 72 |{.._kernel_swi_r|
00001000 65 67 73 09 69 6e 2c 20 6f 75 74 3b 0a 09 75 6e |egs.in, out;..un|
00001010 73 69 67 6e 65 64 20 63 68 61 72 09 74 65 6d 70 |signed char.temp|
00001020 5f 62 75 66 66 65 72 5b 31 30 32 34 5d 3b 0a 0a |_buffer[1024];..|
00001030 09 61 75 5f 77 6f 72 64 74 6f 62 79 74 65 28 77 |.au_wordtobyte(w|
00001040 69 6e 5f 64 61 74 61 5b 30 5d 2e 77 69 6e 5f 68 |in_data[0].win_h|
00001050 61 6e 64 6c 65 2c 20 74 65 6d 70 5f 62 75 66 66 |andle, temp_buff|
00001060 65 72 2c 20 30 29 3b 0a 0a 09 69 6e 2e 72 5b 31 |er, 0);...in.r[1|
00001070 5d 20 3d 20 28 69 6e 74 29 20 74 65 6d 70 5f 62 |] = (int) temp_b|
00001080 75 66 66 65 72 3b 0a 09 5f 6b 65 72 6e 65 6c 5f |uffer;.._kernel_|
00001090 73 77 69 28 57 69 6d 70 5f 47 65 74 57 69 6e 64 |swi(Wimp_GetWind|
000010a0 6f 77 49 6e 66 6f 2c 20 26 69 6e 2c 20 26 6f 75 |owInfo, &in, &ou|
000010b0 74 29 3b 0a 09 5f 6b 65 72 6e 65 6c 5f 73 77 69 |t);.._kernel_swi|
000010c0 28 57 69 6d 70 5f 4f 70 65 6e 57 69 6e 64 6f 77 |(Wimp_OpenWindow|
000010d0 2c 20 26 69 6e 2c 20 26 6f 75 74 29 3b 0a 09 72 |, &in, &out);..r|
000010e0 65 74 75 72 6e 3b 0a 7d 0a 0a 76 6f 69 64 20 6d |eturn;.}..void m|
000010f0 65 6e 75 5f 73 65 6c 65 63 74 69 6f 6e 28 75 6e |enu_selection(un|
00001100 73 69 67 6e 65 64 20 63 68 61 72 20 70 6f 6c 6c |signed char poll|
00001110 5f 62 6c 6f 63 6b 5b 5d 29 0a 7b 0a 09 6c 6f 6e |_block[]).{..lon|
00001120 67 20 69 6e 74 09 66 69 72 73 74 5f 68 69 74 3b |g int.first_hit;|
00001130 0a 09 69 66 20 28 43 55 52 52 45 4e 54 5f 4d 45 |..if (CURRENT_ME|
00001140 4e 55 20 3d 3d 20 31 29 20 7b 0a 09 09 66 69 72 |NU == 1) {...fir|
00001150 73 74 5f 68 69 74 20 3d 20 61 75 5f 62 79 74 65 |st_hit = au_byte|
00001160 74 6f 77 6f 72 64 28 70 6f 6c 6c 5f 62 6c 6f 63 |toword(poll_bloc|
00001170 6b 2c 20 30 29 3b 0a 09 09 69 66 20 28 66 69 72 |k, 0);...if (fir|
00001180 73 74 5f 68 69 74 20 3d 3d 20 51 55 49 54 5f 4f |st_hit == QUIT_O|
00001190 50 54 49 4f 4e 29 20 7b 0a 09 09 09 51 55 49 54 |PTION) {....QUIT|
000011a0 5f 46 4c 41 47 20 3d 20 31 3b 0a 09 09 7d 0a 09 |_FLAG = 1;...}..|
000011b0 7d 0a 09 43 55 52 52 45 4e 54 5f 4d 45 4e 55 20 |}..CURRENT_MENU |
000011c0 3d 20 30 3b 0a 09 72 65 74 75 72 6e 3b 0a 7d 0a |= 0;..return;.}.|
000011d0 0a 76 6f 69 64 0a 6f 70 65 6e 77 69 6e 64 6f 77 |.void.openwindow|
000011e0 28 75 6e 73 69 67 6e 65 64 20 63 68 61 72 20 70 |(unsigned char p|
000011f0 6f 6c 6c 62 6c 6f 63 6b 5b 5d 29 0a 7b 0a 20 20 |ollblock[]).{. |
00001200 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 5f 72 65 67 | _kernel_swi_reg|
00001210 73 20 69 6e 2c 20 6f 75 74 3b 0a 0a 20 20 20 69 |s in, out;.. i|
00001220 6e 2e 72 5b 31 5d 20 3d 20 28 69 6e 74 29 20 70 |n.r[1] = (int) p|
00001230 6f 6c 6c 62 6c 6f 63 6b 3b 0a 20 20 20 5f 6b 65 |ollblock;. _ke|
00001240 72 6e 65 6c 5f 73 77 69 28 57 69 6d 70 5f 4f 70 |rnel_swi(Wimp_Op|
00001250 65 6e 57 69 6e 64 6f 77 2c 20 26 69 6e 2c 20 26 |enWindow, &in, &|
00001260 6f 75 74 29 3b 0a 20 20 20 72 65 74 75 72 6e 3b |out);. return;|
00001270 0a 7d 0a 0a 76 6f 69 64 0a 63 6c 6f 73 65 77 69 |.}..void.closewi|
00001280 6e 64 6f 77 28 75 6e 73 69 67 6e 65 64 20 63 68 |ndow(unsigned ch|
00001290 61 72 20 70 6f 6c 6c 62 6c 6f 63 6b 5b 5d 29 0a |ar pollblock[]).|
000012a0 7b 0a 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 |{. _kernel_swi|
000012b0 5f 72 65 67 73 20 69 6e 2c 20 6f 75 74 3b 0a 0a |_regs in, out;..|
000012c0 20 20 20 69 6e 2e 72 5b 31 5d 20 3d 20 28 69 6e | in.r[1] = (in|
000012d0 74 29 20 70 6f 6c 6c 62 6c 6f 63 6b 3b 0a 20 20 |t) pollblock;. |
000012e0 20 5f 6b 65 72 6e 65 6c 5f 73 77 69 28 57 69 6d | _kernel_swi(Wim|
000012f0 70 5f 43 6c 6f 73 65 57 69 6e 64 6f 77 2c 20 26 |p_CloseWindow, &|
00001300 69 6e 2c 20 26 6f 75 74 29 3b 0a 20 20 20 72 65 |in, &out);. re|
00001310 74 75 72 6e 3b 0a 7d 0a 0a 76 6f 69 64 0a 72 65 |turn;.}..void.re|
00001320 64 72 61 77 5f 77 69 6e 64 6f 77 28 75 6e 73 69 |draw_window(unsi|
00001330 67 6e 65 64 20 63 68 61 72 20 70 6f 6c 6c 62 6c |gned char pollbl|
00001340 6f 63 6b 5b 5d 29 0a 7b 0a 09 5f 6b 65 72 6e 65 |ock[]).{.._kerne|
00001350 6c 5f 73 77 69 5f 72 65 67 73 09 69 6e 2c 20 6f |l_swi_regs.in, o|
00001360 75 74 3b 0a 09 69 6e 74 20 66 6c 61 67 20 3d 20 |ut;..int flag = |
00001370 30 3b 0a 09 6c 6f 6e 67 20 69 6e 74 20 76 69 73 |0;..long int vis|
00001380 78 31 2c 20 76 69 73 78 32 2c 20 76 69 73 79 31 |x1, visx2, visy1|
00001390 2c 20 76 69 73 79 32 3b 0a 09 6c 6f 6e 67 20 69 |, visy2;..long i|
000013a0 6e 74 20 77 69 6e 78 31 2c 20 77 69 6e 78 32 2c |nt winx1, winx2,|
000013b0 20 77 69 6e 79 31 2c 20 77 69 6e 79 32 3b 0a 09 | winy1, winy2;..|
000013c0 6c 6f 6e 67 20 69 6e 74 20 77 6f 72 6b 78 31 2c |long int workx1,|
000013d0 20 77 6f 72 6b 78 32 2c 20 77 6f 72 6b 79 31 2c | workx2, worky1,|
000013e0 20 77 6f 72 6b 79 32 3b 0a 09 6c 6f 6e 67 20 69 | worky2;..long i|
000013f0 6e 74 20 73 63 72 6f 6c 6c 78 2c 20 73 63 72 6f |nt scrollx, scro|
00001400 6c 6c 79 3b 0a 09 6c 6f 6e 67 20 69 6e 74 20 74 |lly;..long int t|
00001410 65 73 74 78 2c 20 74 65 73 74 79 3b 0a 09 6c 6f |estx, testy;..lo|
00001420 6e 67 20 69 6e 74 20 74 65 73 74 78 31 2c 20 74 |ng int testx1, t|
00001430 65 73 74 78 32 2c 20 74 65 73 74 79 31 2c 20 74 |estx2, testy1, t|
00001440 65 73 74 79 32 3b 0a 0a 09 69 6e 2e 72 5b 31 5d |esty2;...in.r[1]|
00001450 20 3d 20 28 69 6e 74 29 20 70 6f 6c 6c 62 6c 6f | = (int) pollblo|
00001460 63 6b 3b 0a 0a 09 5f 6b 65 72 6e 65 6c 5f 73 77 |ck;..._kernel_sw|
00001470 69 28 57 69 6d 70 5f 52 65 64 72 61 77 57 69 6e |i(Wimp_RedrawWin|
00001480 64 6f 77 2c 20 26 69 6e 2c 20 26 6f 75 74 29 3b |dow, &in, &out);|
00001490 0a 09 66 6c 61 67 20 3d 20 6f 75 74 2e 72 5b 30 |..flag = out.r[0|
000014a0 5d 3b 0a 0a 09 77 68 69 6c 65 20 28 66 6c 61 67 |];...while (flag|
000014b0 29 20 7b 0a 09 2f 2a 20 72 65 64 72 61 77 20 77 |) {../* redraw w|
000014c0 69 6e 64 6f 77 20 68 65 72 65 20 2a 2f 0a 09 77 |indow here */..w|
000014d0 69 6e 78 31 20 3d 20 61 75 5f 62 79 74 65 74 6f |inx1 = au_byteto|
000014e0 77 6f 72 64 28 70 6f 6c 6c 62 6c 6f 63 6b 2c 20 |word(pollblock, |
000014f0 34 29 3b 0a 09 77 69 6e 79 31 20 3d 20 61 75 5f |4);..winy1 = au_|
00001500 62 79 74 65 74 6f 77 6f 72 64 28 70 6f 6c 6c 62 |bytetoword(pollb|
00001510 6c 6f 63 6b 2c 20 38 29 3b 0a 09 77 69 6e 78 32 |lock, 8);..winx2|
00001520 20 3d 20 61 75 5f 62 79 74 65 74 6f 77 6f 72 64 | = au_bytetoword|
00001530 28 70 6f 6c 6c 62 6c 6f 63 6b 2c 20 31 32 29 3b |(pollblock, 12);|
00001540 0a 09 77 69 6e 79 32 20 3d 20 61 75 5f 62 79 74 |..winy2 = au_byt|
00001550 65 74 6f 77 6f 72 64 28 70 6f 6c 6c 62 6c 6f 63 |etoword(pollbloc|
00001560 6b 2c 20 31 36 29 3b 0a 09 76 69 73 78 31 20 3d |k, 16);..visx1 =|
00001570 20 61 75 5f 62 79 74 65 74 6f 77 6f 72 64 28 70 | au_bytetoword(p|
00001580 6f 6c 6c 62 6c 6f 63 6b 2c 20 32 38 29 3b 0a 09 |ollblock, 28);..|
00001590 76 69 73 79 31 20 3d 20 61 75 5f 62 79 74 65 74 |visy1 = au_bytet|
000015a0 6f 77 6f 72 64 28 70 6f 6c 6c 62 6c 6f 63 6b 2c |oword(pollblock,|
000015b0 20 33 32 29 3b 0a 09 76 69 73 78 32 20 3d 20 61 | 32);..visx2 = a|
000015c0 75 5f 62 79 74 65 74 6f 77 6f 72 64 28 70 6f 6c |u_bytetoword(pol|
000015d0 6c 62 6c 6f 63 6b 2c 20 33 36 29 3b 0a 09 76 69 |lblock, 36);..vi|
000015e0 73 79 32 20 3d 20 61 75 5f 62 79 74 65 74 6f 77 |sy2 = au_bytetow|
000015f0 6f 72 64 28 70 6f 6c 6c 62 6c 6f 63 6b 2c 20 34 |ord(pollblock, 4|
00001600 30 29 3b 0a 09 73 63 72 6f 6c 6c 78 20 3d 20 61 |0);..scrollx = a|
00001610 75 5f 62 79 74 65 74 6f 77 6f 72 64 28 70 6f 6c |u_bytetoword(pol|
00001620 6c 62 6c 6f 63 6b 2c 20 32 30 29 3b 0a 09 73 63 |lblock, 20);..sc|
00001630 72 6f 6c 6c 79 20 3d 20 61 75 5f 62 79 74 65 74 |rolly = au_bytet|
00001640 6f 77 6f 72 64 28 70 6f 6c 6c 62 6c 6f 63 6b 2c |oword(pollblock,|
00001650 20 32 34 29 3b 0a 0a 09 77 6f 72 6b 78 31 20 3d | 24);...workx1 =|
00001660 20 76 69 73 78 31 20 2b 20 28 73 63 72 6f 6c 6c | visx1 + (scroll|
00001670 78 20 2d 20 77 69 6e 78 31 29 3b 0a 09 77 6f 72 |x - winx1);..wor|
00001680 6b 78 32 20 3d 20 76 69 73 78 32 20 2b 20 28 73 |kx2 = visx2 + (s|
00001690 63 72 6f 6c 6c 78 20 2d 20 77 69 6e 78 31 29 3b |crollx - winx1);|
000016a0 0a 09 77 6f 72 6b 79 31 20 3d 20 76 69 73 79 31 |..worky1 = visy1|
000016b0 20 2b 20 28 73 63 72 6f 6c 6c 79 20 2d 20 77 69 | + (scrolly - wi|
000016c0 6e 79 32 29 3b 0a 09 77 6f 72 6b 79 32 20 3d 20 |ny2);..worky2 = |
000016d0 76 69 73 79 32 20 2b 20 28 73 63 72 6f 6c 6c 79 |visy2 + (scrolly|
000016e0 20 2d 20 77 69 6e 79 32 29 3b 0a 0a 09 2f 2a 20 | - winy2);.../* |
000016f0 54 68 65 73 65 20 67 69 76 65 20 74 68 65 20 77 |These give the w|
00001700 6f 72 6b 20 63 6f 6f 72 64 69 6e 61 74 65 73 20 |ork coordinates |
00001710 6f 66 20 74 68 65 20 61 72 65 61 20 6e 65 65 64 |of the area need|
00001720 69 6e 67 0a 09 20 2a 20 74 6f 20 62 65 20 72 65 |ing.. * to be re|
00001730 64 72 61 77 6e 20 2a 2f 0a 0a 09 2f 2a 20 4e 6f |drawn */.../* No|
00001740 77 20 63 6f 6e 76 65 72 74 20 61 20 77 6f 72 6b |w convert a work|
00001750 20 63 6f 6f 72 64 69 6e 61 74 65 20 69 6e 74 6f | coordinate into|
00001760 20 61 20 73 63 72 65 65 6e 20 70 69 78 65 6c 20 | a screen pixel |
00001770 2a 2f 0a 0a 09 74 65 73 74 78 20 3d 20 32 35 20 |*/...testx = 25 |
00001780 2d 20 73 63 72 6f 6c 6c 78 20 2b 20 77 69 6e 78 |- scrollx + winx|
00001790 31 3b 0a 09 74 65 73 74 79 20 3d 20 2d 32 35 30 |1;..testy = -250|
000017a0 20 2d 20 73 63 72 6f 6c 6c 79 20 2b 20 77 69 6e | - scrolly + win|
000017b0 79 32 3b 0a 09 74 65 73 74 78 31 20 3d 20 33 30 |y2;..testx1 = 30|
000017c0 30 20 2d 20 73 63 72 6f 6c 6c 78 20 2b 20 77 69 |0 - scrollx + wi|
000017d0 6e 78 31 3b 0a 09 74 65 73 74 79 31 20 3d 20 2d |nx1;..testy1 = -|
000017e0 32 35 30 20 2d 20 73 63 72 6f 6c 6c 79 20 2b 20 |250 - scrolly + |
000017f0 77 69 6e 79 32 3b 0a 09 74 65 73 74 78 32 20 3d |winy2;..testx2 =|
00001800 20 36 30 30 20 2d 20 73 63 72 6f 6c 6c 78 20 2b | 600 - scrollx +|
00001810 20 77 69 6e 78 31 3b 0a 09 74 65 73 74 79 32 20 | winx1;..testy2 |
00001820 3d 20 2d 32 35 30 20 2d 20 73 63 72 6f 6c 6c 79 |= -250 - scrolly|
00001830 20 2b 20 77 69 6e 79 32 3b 0a 0a 09 70 6c 6f 74 | + winy2;...plot|
00001840 5f 73 70 72 69 74 65 28 22 73 63 72 65 65 6e 22 |_sprite("screen"|
00001850 2c 20 28 69 6e 74 29 20 74 65 73 74 78 2c 20 28 |, (int) testx, (|
00001860 69 6e 74 29 20 74 65 73 74 79 2c 20 74 72 61 6e |int) testy, tran|
00001870 73 6c 61 74 69 6f 6e 5f 62 75 66 66 65 72 29 3b |slation_buffer);|
00001880 0a 09 70 6c 6f 74 5f 73 70 72 69 74 65 28 22 74 |..plot_sprite("t|
00001890 65 73 74 73 70 72 22 2c 20 28 69 6e 74 29 20 74 |estspr", (int) t|
000018a0 65 73 74 78 2b 31 35 30 2c 20 28 69 6e 74 29 20 |estx+150, (int) |
000018b0 74 65 73 74 79 2b 35 30 2c 20 74 72 61 6e 73 6c |testy+50, transl|
000018c0 61 74 69 6f 6e 5f 62 75 66 66 65 72 32 29 3b 0a |ation_buffer2);.|
000018d0 09 70 6c 6f 74 5f 73 70 72 69 74 65 28 22 73 63 |.plot_sprite("sc|
000018e0 72 65 65 6e 22 2c 20 28 69 6e 74 29 20 74 65 73 |reen", (int) tes|
000018f0 74 78 31 2c 20 28 69 6e 74 29 20 74 65 73 74 79 |tx1, (int) testy|
00001900 31 2c 20 74 72 61 6e 73 6c 61 74 69 6f 6e 5f 62 |1, translation_b|
00001910 75 66 66 65 72 29 3b 0a 09 70 6c 6f 74 5f 73 70 |uffer);..plot_sp|
00001920 72 69 74 65 28 22 74 65 73 74 73 70 72 22 2c 20 |rite("testspr", |
00001930 28 69 6e 74 29 20 74 65 73 74 78 31 2b 31 35 30 |(int) testx1+150|
00001940 2c 20 28 69 6e 74 29 20 74 65 73 74 79 2b 35 30 |, (int) testy+50|
00001950 2c 20 74 72 61 6e 73 6c 61 74 69 6f 6e 5f 62 75 |, translation_bu|
00001960 66 66 65 72 32 29 3b 0a 09 70 6c 6f 74 5f 73 70 |ffer2);..plot_sp|
00001970 72 69 74 65 28 22 73 63 72 65 65 6e 22 2c 20 28 |rite("screen", (|
00001980 69 6e 74 29 20 74 65 73 74 78 32 2c 20 28 69 6e |int) testx2, (in|
00001990 74 29 20 74 65 73 74 79 32 2c 20 74 72 61 6e 73 |t) testy2, trans|
000019a0 6c 61 74 69 6f 6e 5f 62 75 66 66 65 72 29 3b 0a |lation_buffer);.|
000019b0 0a 09 2f 2a 20 72 65 64 72 61 77 20 77 69 6e 64 |../* redraw wind|
000019c0 6f 77 20 66 69 6e 69 73 68 65 64 20 2a 2f 0a 09 |ow finished */..|
000019d0 69 6e 2e 72 5b 31 5d 20 3d 20 28 69 6e 74 29 20 |in.r[1] = (int) |
000019e0 70 6f 6c 6c 62 6c 6f 63 6b 3b 0a 09 5f 6b 65 72 |pollblock;.._ker|
000019f0 6e 65 6c 5f 73 77 69 28 57 69 6d 70 5f 47 65 74 |nel_swi(Wimp_Get|
00001a00 52 65 63 74 61 6e 67 6c 65 2c 20 26 69 6e 2c 20 |Rectangle, &in, |
00001a10 26 6f 75 74 29 3b 0a 09 66 6c 61 67 20 3d 20 6f |&out);..flag = o|
00001a20 75 74 2e 72 5b 30 5d 3b 0a 09 7d 0a 7d 0a 0a 76 |ut.r[0];..}.}..v|
00001a30 6f 69 64 0a 73 65 74 75 70 5f 73 70 72 69 74 65 |oid.setup_sprite|
00001a40 5f 61 72 65 61 28 76 6f 69 64 29 0a 7b 0a 09 5f |_area(void).{.._|
00001a50 6b 65 72 6e 65 6c 5f 73 77 69 5f 72 65 67 73 09 |kernel_swi_regs.|
00001a60 69 6e 2c 20 6f 75 74 3b 0a 09 63 68 61 72 09 66 |in, out;..char.f|
00001a70 69 6c 65 6e 61 6d 65 5b 5d 20 3d 20 22 3c 57 69 |ilename[] = "<Wi|
00001a80 6e 64 6f 77 24 44 69 72 3e 2e 53 70 72 69 74 65 |ndow$Dir>.Sprite|
00001a90 73 22 3b 0a 0a 09 61 75 5f 77 6f 72 64 74 6f 62 |s";...au_wordtob|
00001aa0 79 74 65 28 53 50 52 49 54 45 5f 41 52 45 41 5f |yte(SPRITE_AREA_|
00001ab0 53 49 5a 45 2c 20 73 70 72 69 74 65 5f 61 72 65 |SIZE, sprite_are|
00001ac0 61 2c 20 30 29 3b 0a 09 61 75 5f 77 6f 72 64 74 |a, 0);..au_wordt|
00001ad0 6f 62 79 74 65 28 31 36 2c 20 73 70 72 69 74 65 |obyte(16, sprite|
00001ae0 5f 61 72 65 61 2c 20 38 29 3b 0a 0a 09 69 6e 2e |_area, 8);...in.|
00001af0 72 5b 30 5d 20 3d 20 32 35 36 2b 39 3b 0a 09 69 |r[0] = 256+9;..i|
00001b00 6e 2e 72 5b 31 5d 20 3d 20 28 69 6e 74 29 20 73 |n.r[1] = (int) s|
00001b10 70 72 69 74 65 5f 61 72 65 61 3b 0a 09 5f 6b 65 |prite_area;.._ke|
00001b20 72 6e 65 6c 5f 73 77 69 28 4f 53 5f 53 70 72 69 |rnel_swi(OS_Spri|
00001b30 74 65 4f 70 2c 20 26 69 6e 2c 20 26 6f 75 74 29 |teOp, &in, &out)|
00001b40 3b 0a 0a 09 2f 2a 20 4c 6f 61 64 20 74 68 65 20 |;.../* Load the |
00001b50 73 70 72 69 74 65 73 20 2a 2f 0a 0a 09 69 6e 2e |sprites */...in.|
00001b60 72 5b 30 5d 20 3d 20 32 35 36 2b 31 30 3b 0a 09 |r[0] = 256+10;..|
00001b70 69 6e 2e 72 5b 31 5d 20 3d 20 28 69 6e 74 29 20 |in.r[1] = (int) |
00001b80 73 70 72 69 74 65 5f 61 72 65 61 3b 0a 09 69 6e |sprite_area;..in|
00001b90 2e 72 5b 32 5d 20 3d 20 28 69 6e 74 29 20 66 69 |.r[2] = (int) fi|
00001ba0 6c 65 6e 61 6d 65 3b 0a 09 5f 6b 65 72 6e 65 6c |lename;.._kernel|
00001bb0 5f 73 77 69 28 4f 53 5f 53 70 72 69 74 65 4f 70 |_swi(OS_SpriteOp|
00001bc0 2c 20 26 69 6e 2c 20 26 6f 75 74 29 3b 0a 0a 7d |, &in, &out);..}|
00001bd0 0a 0a 76 6f 69 64 0a 70 6c 6f 74 5f 73 70 72 69 |..void.plot_spri|
00001be0 74 65 28 63 68 61 72 20 73 70 72 6e 61 6d 65 5b |te(char sprname[|
00001bf0 5d 2c 20 69 6e 74 20 78 5f 70 69 78 2c 20 69 6e |], int x_pix, in|
00001c00 74 20 79 5f 70 69 78 2c 20 75 6e 73 69 67 6e 65 |t y_pix, unsigne|
00001c10 64 20 63 68 61 72 20 74 72 61 6e 73 5f 62 75 66 |d char trans_buf|
00001c20 66 65 72 5b 5d 29 0a 7b 0a 09 5f 6b 65 72 6e 65 |fer[]).{.._kerne|
00001c30 6c 5f 73 77 69 5f 72 65 67 73 20 69 6e 2c 20 6f |l_swi_regs in, o|
00001c40 75 74 3b 0a 0a 09 69 6e 2e 72 5b 30 5d 20 3d 20 |ut;...in.r[0] = |
00001c50 32 35 36 2b 35 32 3b 0a 09 69 6e 2e 72 5b 31 5d |256+52;..in.r[1]|
00001c60 20 3d 20 28 69 6e 74 29 20 73 70 72 69 74 65 5f | = (int) sprite_|
00001c70 61 72 65 61 3b 20 2f 2a 20 67 6c 6f 62 61 6c 20 |area; /* global |
00001c80 76 61 72 69 61 62 6c 65 20 2a 2f 0a 09 69 6e 2e |variable */..in.|
00001c90 72 5b 32 5d 20 3d 20 28 69 6e 74 29 20 73 70 72 |r[2] = (int) spr|
00001ca0 6e 61 6d 65 3b 0a 09 69 6e 2e 72 5b 33 5d 20 3d |name;..in.r[3] =|
00001cb0 20 78 5f 70 69 78 3b 0a 09 69 6e 2e 72 5b 34 5d | x_pix;..in.r[4]|
00001cc0 20 3d 20 79 5f 70 69 78 3b 0a 09 69 6e 2e 72 5b | = y_pix;..in.r[|
00001cd0 35 5d 20 3d 20 30 3b 0a 09 69 6e 2e 72 5b 36 5d |5] = 0;..in.r[6]|
00001ce0 20 3d 20 30 3b 0a 09 69 6e 2e 72 5b 37 5d 20 3d | = 0;..in.r[7] =|
00001cf0 20 28 69 6e 74 29 20 74 72 61 6e 73 5f 62 75 66 | (int) trans_buf|
00001d00 66 65 72 3b 0a 0a 09 5f 6b 65 72 6e 65 6c 5f 73 |fer;..._kernel_s|
00001d10 77 69 28 4f 53 5f 53 70 72 69 74 65 4f 70 2c 20 |wi(OS_SpriteOp, |
00001d20 26 69 6e 2c 20 26 6f 75 74 29 3b 0a 7d 0a 0a 76 |&in, &out);.}..v|
00001d30 6f 69 64 0a 62 75 69 6c 64 5f 74 72 61 6e 73 6c |oid.build_transl|
00001d40 61 74 69 6f 6e 5f 74 61 62 6c 65 28 63 68 61 72 |ation_table(char|
00001d50 20 74 65 78 74 5f 62 75 66 66 65 72 5b 5d 2c 20 | text_buffer[], |
00001d60 75 6e 73 69 67 6e 65 64 20 63 68 61 72 20 74 72 |unsigned char tr|
00001d70 61 6e 73 5f 62 75 66 66 65 72 5b 5d 29 0a 7b 0a |ans_buffer[]).{.|
00001d80 09 5f 6b 65 72 6e 65 6c 5f 73 77 69 5f 72 65 67 |._kernel_swi_reg|
00001d90 73 20 69 6e 2c 20 6f 75 74 3b 0a 09 69 6e 2e 72 |s in, out;..in.r|
00001da0 5b 30 5d 20 3d 20 28 69 6e 74 29 20 73 70 72 69 |[0] = (int) spri|
00001db0 74 65 5f 61 72 65 61 3b 0a 09 69 6e 2e 72 5b 31 |te_area;..in.r[1|
00001dc0 5d 20 3d 20 28 69 6e 74 29 20 74 65 78 74 5f 62 |] = (int) text_b|
00001dd0 75 66 66 65 72 3b 0a 09 69 6e 2e 72 5b 32 5d 20 |uffer;..in.r[2] |
00001de0 3d 20 2d 31 3b 0a 09 69 6e 2e 72 5b 33 5d 20 3d |= -1;..in.r[3] =|
00001df0 20 2d 31 3b 0a 09 69 6e 2e 72 5b 34 5d 20 3d 20 | -1;..in.r[4] = |
00001e00 28 69 6e 74 29 20 74 72 61 6e 73 5f 62 75 66 66 |(int) trans_buff|
00001e10 65 72 3b 0a 09 69 6e 2e 72 5b 35 5d 20 3d 20 30 |er;..in.r[5] = 0|
00001e20 3b 0a 09 5f 6b 65 72 6e 65 6c 5f 73 77 69 28 43 |;.._kernel_swi(C|
00001e30 6f 6c 6f 75 72 54 72 61 6e 73 5f 53 65 6c 65 63 |olourTrans_Selec|
00001e40 74 54 61 62 6c 65 2c 20 26 69 6e 2c 20 26 6f 75 |tTable, &in, &ou|
00001e50 74 29 3b 0a 7d 0a 0a 2f 2a 20 45 6e 64 20 6f 66 |t);.}../* End of|
00001e60 20 70 72 6f 67 72 61 6d 20 2a 2f 0a | program */.|
00001e6c
.