Home » Archimedes archive » Acorn User » AU 1995-07.adf » !Life_MacroLife » !MacroLife/Docs/Structures
!MacroLife/Docs/Structures
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 1995-07.adf » !Life_MacroLife |
Filename: | !MacroLife/Docs/Structures |
Read OK: | ✔ |
File size: | 0A18 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
/************************************************************************** * * * Title: Structures.h * * Purpose: Desktop Life * * Author: Copyright � 1995 Chris Taylor * * Version: 1.0 (22 January 1995) * * Comments: Slightly tweaked version of the source header file; * * neater and better commented than the real thing. * * * **************************************************************************/ /*********************************** STRUCTURES ***************************/ /* This is the bit-level structure: 16 rows of 16 bits. It serves double duty, since it is also used to compress the other arrays onto disc. */ typedef struct cell_array_struct { int count; unsigned short row[16]; }cell_array; /* The cells level structure: The 'next' array is only present during generation. */ typedef struct cells_struct { cell_array *current; cell_array *next; }cells; /* The local structure: 16 x 16 cells structures. */ typedef struct local_array_struct { int count; cells *c[16][16]; }local_array; /* The regional structure: 16 x 16 local structures. */ typedef struct regional_array_struct { int count; local_array *l[16][16]; }regional_array; /* The global structure: 16 x 16 regional structures. */ typedef struct global_array_struct { regional_array *r[16][16]; }global_array; /* The plane structure: two global structures and supporting variables. The real one has more elements; this just shows the important bits. */ struct plane_structure { int x; int y; global_array start; int startpop; global_array base; int gen; int pop; }; /* The co-ordinates structure. */ struct coord_bits { unsigned int c : 4; unsigned int l : 4; unsigned int r : 4; unsigned int g : 4; unsigned int : 16; /* unused */ }; /* The union which ties the co-ordinates to their component parts. Note that this only works on little-endian processors such as the ARM. A big-endian machine would need a reverse ordering. */ typedef union plane_coordinate { int val; struct coord_bits bits; }plane_coord;
00000000 2f 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |/***************| 00000010 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 00000040 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 0a 20 2a 20 20 |***********. * | 00000050 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000090 20 20 20 20 20 20 2a 0a 20 2a 20 20 20 20 20 20 | *. * | 000000a0 20 54 69 74 6c 65 3a 20 20 20 20 53 74 72 75 63 | Title: Struc| 000000b0 74 75 72 65 73 2e 68 20 20 20 20 20 20 20 20 20 |tures.h | 000000c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000000e0 20 20 2a 0a 20 2a 20 20 20 20 20 20 20 50 75 72 | *. * Pur| 000000f0 70 6f 73 65 3a 20 20 44 65 73 6b 74 6f 70 20 4c |pose: Desktop L| 00000100 69 66 65 20 20 20 20 20 20 20 20 20 20 20 20 20 |ife | 00000110 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000120 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2a 0a | *.| 00000130 20 2a 20 20 20 20 20 20 20 41 75 74 68 6f 72 3a | * Author:| 00000140 20 20 20 43 6f 70 79 72 69 67 68 74 20 a9 20 31 | Copyright . 1| 00000150 39 39 35 20 43 68 72 69 73 20 54 61 79 6c 6f 72 |995 Chris Taylor| 00000160 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000170 20 20 20 20 20 20 20 20 20 20 2a 0a 20 2a 20 20 | *. * | 00000180 20 20 20 20 20 56 65 72 73 69 6f 6e 3a 20 20 31 | Version: 1| 00000190 2e 30 20 28 32 32 20 4a 61 6e 75 61 72 79 20 31 |.0 (22 January 1| 000001a0 39 39 35 29 20 20 20 20 20 20 20 20 20 20 20 20 |995) | 000001b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000001c0 20 20 20 20 20 20 2a 0a 20 2a 20 20 20 20 20 20 | *. * | 000001d0 20 43 6f 6d 6d 65 6e 74 73 3a 20 53 6c 69 67 68 | Comments: Sligh| 000001e0 74 6c 79 20 74 77 65 61 6b 65 64 20 76 65 72 73 |tly tweaked vers| 000001f0 69 6f 6e 20 6f 66 20 74 68 65 20 73 6f 75 72 63 |ion of the sourc| 00000200 65 20 68 65 61 64 65 72 20 66 69 6c 65 3b 20 20 |e header file; | 00000210 20 20 2a 0a 20 2a 20 20 20 20 20 20 20 20 20 20 | *. * | 00000220 20 20 20 20 20 20 20 6e 65 61 74 65 72 20 61 6e | neater an| 00000230 64 20 62 65 74 74 65 72 20 63 6f 6d 6d 65 6e 74 |d better comment| 00000240 65 64 20 74 68 61 6e 20 74 68 65 20 72 65 61 6c |ed than the real| 00000250 20 74 68 69 6e 67 2e 20 20 20 20 20 20 20 2a 0a | thing. *.| 00000260 20 2a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | * | 00000270 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000002a0 20 20 20 20 20 20 20 20 20 20 2a 0a 20 2a 2a 2a | *. ***| 000002b0 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 000002f0 2a 2a 2a 2a 2a 2a 2a 2f 0a 0a 2f 2a 2a 2a 2a 2a |*******/../*****| 00000300 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| 00000310 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 20 53 |************** S| 00000320 54 52 55 43 54 55 52 45 53 20 2a 2a 2a 2a 2a 2a |TRUCTURES ******| 00000330 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| 00000340 2a 2a 2a 2a 2a 2f 0a 0a 2f 2a 20 54 68 69 73 20 |*****/../* This | 00000350 69 73 20 74 68 65 20 62 69 74 2d 6c 65 76 65 6c |is the bit-level| 00000360 20 73 74 72 75 63 74 75 72 65 3a 20 31 36 20 72 | structure: 16 r| 00000370 6f 77 73 20 6f 66 20 31 36 20 62 69 74 73 2e 20 |ows of 16 bits. | 00000380 49 74 20 73 65 72 76 65 73 20 64 6f 75 62 6c 65 |It serves double| 00000390 0a 20 20 20 64 75 74 79 2c 20 73 69 6e 63 65 20 |. duty, since | 000003a0 69 74 20 69 73 20 61 6c 73 6f 20 75 73 65 64 20 |it is also used | 000003b0 74 6f 20 63 6f 6d 70 72 65 73 73 20 74 68 65 20 |to compress the | 000003c0 6f 74 68 65 72 20 61 72 72 61 79 73 20 6f 6e 74 |other arrays ont| 000003d0 6f 20 64 69 73 63 2e 20 20 20 20 2a 2f 0a 20 20 |o disc. */. | 000003e0 20 0a 74 79 70 65 64 65 66 20 73 74 72 75 63 74 | .typedef struct| 000003f0 20 63 65 6c 6c 5f 61 72 72 61 79 5f 73 74 72 75 | cell_array_stru| 00000400 63 74 0a 7b 0a 20 20 69 6e 74 20 63 6f 75 6e 74 |ct.{. int count| 00000410 3b 0a 20 20 75 6e 73 69 67 6e 65 64 20 73 68 6f |;. unsigned sho| 00000420 72 74 20 72 6f 77 5b 31 36 5d 3b 0a 7d 63 65 6c |rt row[16];.}cel| 00000430 6c 5f 61 72 72 61 79 3b 0a 0a 0a 2f 2a 20 54 68 |l_array;.../* Th| 00000440 65 20 63 65 6c 6c 73 20 6c 65 76 65 6c 20 73 74 |e cells level st| 00000450 72 75 63 74 75 72 65 3a 0a 20 20 20 54 68 65 20 |ructure:. The | 00000460 27 6e 65 78 74 27 20 61 72 72 61 79 20 69 73 20 |'next' array is | 00000470 6f 6e 6c 79 20 70 72 65 73 65 6e 74 20 64 75 72 |only present dur| 00000480 69 6e 67 20 67 65 6e 65 72 61 74 69 6f 6e 2e 20 |ing generation. | 00000490 2a 2f 0a 0a 74 79 70 65 64 65 66 20 73 74 72 75 |*/..typedef stru| 000004a0 63 74 20 63 65 6c 6c 73 5f 73 74 72 75 63 74 0a |ct cells_struct.| 000004b0 7b 0a 20 20 63 65 6c 6c 5f 61 72 72 61 79 20 2a |{. cell_array *| 000004c0 63 75 72 72 65 6e 74 3b 0a 20 20 63 65 6c 6c 5f |current;. cell_| 000004d0 61 72 72 61 79 20 2a 6e 65 78 74 3b 0a 7d 63 65 |array *next;.}ce| 000004e0 6c 6c 73 3b 0a 0a 0a 2f 2a 20 54 68 65 20 6c 6f |lls;.../* The lo| 000004f0 63 61 6c 20 73 74 72 75 63 74 75 72 65 3a 20 31 |cal structure: 1| 00000500 36 20 78 20 31 36 20 63 65 6c 6c 73 20 73 74 72 |6 x 16 cells str| 00000510 75 63 74 75 72 65 73 2e 20 2a 2f 0a 0a 74 79 70 |uctures. */..typ| 00000520 65 64 65 66 20 73 74 72 75 63 74 20 6c 6f 63 61 |edef struct loca| 00000530 6c 5f 61 72 72 61 79 5f 73 74 72 75 63 74 0a 7b |l_array_struct.{| 00000540 0a 20 20 69 6e 74 20 63 6f 75 6e 74 3b 0a 20 20 |. int count;. | 00000550 63 65 6c 6c 73 20 2a 63 5b 31 36 5d 5b 31 36 5d |cells *c[16][16]| 00000560 3b 0a 7d 6c 6f 63 61 6c 5f 61 72 72 61 79 3b 0a |;.}local_array;.| 00000570 0a 0a 2f 2a 20 54 68 65 20 72 65 67 69 6f 6e 61 |../* The regiona| 00000580 6c 20 73 74 72 75 63 74 75 72 65 3a 20 31 36 20 |l structure: 16 | 00000590 78 20 31 36 20 6c 6f 63 61 6c 20 73 74 72 75 63 |x 16 local struc| 000005a0 74 75 72 65 73 2e 20 2a 2f 0a 0a 74 79 70 65 64 |tures. */..typed| 000005b0 65 66 20 73 74 72 75 63 74 20 72 65 67 69 6f 6e |ef struct region| 000005c0 61 6c 5f 61 72 72 61 79 5f 73 74 72 75 63 74 0a |al_array_struct.| 000005d0 7b 0a 20 20 69 6e 74 20 63 6f 75 6e 74 3b 0a 20 |{. int count;. | 000005e0 20 6c 6f 63 61 6c 5f 61 72 72 61 79 20 2a 6c 5b | local_array *l[| 000005f0 31 36 5d 5b 31 36 5d 3b 0a 7d 72 65 67 69 6f 6e |16][16];.}region| 00000600 61 6c 5f 61 72 72 61 79 3b 0a 0a 0a 2f 2a 20 54 |al_array;.../* T| 00000610 68 65 20 67 6c 6f 62 61 6c 20 73 74 72 75 63 74 |he global struct| 00000620 75 72 65 3a 20 31 36 20 78 20 31 36 20 72 65 67 |ure: 16 x 16 reg| 00000630 69 6f 6e 61 6c 20 73 74 72 75 63 74 75 72 65 73 |ional structures| 00000640 2e 20 2a 2f 0a 0a 74 79 70 65 64 65 66 20 73 74 |. */..typedef st| 00000650 72 75 63 74 20 67 6c 6f 62 61 6c 5f 61 72 72 61 |ruct global_arra| 00000660 79 5f 73 74 72 75 63 74 0a 7b 0a 20 20 72 65 67 |y_struct.{. reg| 00000670 69 6f 6e 61 6c 5f 61 72 72 61 79 20 2a 72 5b 31 |ional_array *r[1| 00000680 36 5d 5b 31 36 5d 3b 0a 7d 67 6c 6f 62 61 6c 5f |6][16];.}global_| 00000690 61 72 72 61 79 3b 0a 0a 0a 2f 2a 20 54 68 65 20 |array;.../* The | 000006a0 70 6c 61 6e 65 20 73 74 72 75 63 74 75 72 65 3a |plane structure:| 000006b0 20 74 77 6f 20 67 6c 6f 62 61 6c 20 73 74 72 75 | two global stru| 000006c0 63 74 75 72 65 73 20 61 6e 64 20 73 75 70 70 6f |ctures and suppo| 000006d0 72 74 69 6e 67 20 76 61 72 69 61 62 6c 65 73 2e |rting variables.| 000006e0 20 20 0a 20 20 20 54 68 65 20 72 65 61 6c 20 6f | . The real o| 000006f0 6e 65 20 68 61 73 20 6d 6f 72 65 20 65 6c 65 6d |ne has more elem| 00000700 65 6e 74 73 3b 20 74 68 69 73 20 6a 75 73 74 20 |ents; this just | 00000710 73 68 6f 77 73 20 74 68 65 20 69 6d 70 6f 72 74 |shows the import| 00000720 61 6e 74 20 62 69 74 73 2e 20 2a 2f 0a 0a 73 74 |ant bits. */..st| 00000730 72 75 63 74 20 70 6c 61 6e 65 5f 73 74 72 75 63 |ruct plane_struc| 00000740 74 75 72 65 0a 7b 0a 20 20 69 6e 74 20 20 20 20 |ture.{. int | 00000750 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 78 | x| 00000760 3b 0a 20 20 69 6e 74 20 20 20 20 20 20 20 20 20 |;. int | 00000770 20 20 20 20 20 20 20 20 20 20 79 3b 0a 20 20 67 | y;. g| 00000780 6c 6f 62 61 6c 5f 61 72 72 61 79 20 20 20 20 20 |lobal_array | 00000790 20 20 20 20 20 73 74 61 72 74 3b 0a 20 20 69 6e | start;. in| 000007a0 74 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |t | 000007b0 20 20 20 20 73 74 61 72 74 70 6f 70 3b 0a 20 20 | startpop;. | 000007c0 67 6c 6f 62 61 6c 5f 61 72 72 61 79 20 20 20 20 |global_array | 000007d0 20 20 20 20 20 20 62 61 73 65 3b 0a 20 20 69 6e | base;. in| 000007e0 74 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |t | 000007f0 20 20 20 20 67 65 6e 3b 0a 20 20 69 6e 74 20 20 | gen;. int | 00000800 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000810 20 70 6f 70 3b 0a 7d 3b 0a 0a 2f 2a 20 54 68 65 | pop;.};../* The| 00000820 20 63 6f 2d 6f 72 64 69 6e 61 74 65 73 20 73 74 | co-ordinates st| 00000830 72 75 63 74 75 72 65 2e 20 2a 2f 0a 0a 73 74 72 |ructure. */..str| 00000840 75 63 74 20 63 6f 6f 72 64 5f 62 69 74 73 0a 7b |uct coord_bits.{| 00000850 0a 20 20 75 6e 73 69 67 6e 65 64 20 69 6e 74 20 |. unsigned int | 00000860 63 20 20 20 20 20 20 20 20 3a 20 20 34 3b 0a 20 |c : 4;. | 00000870 20 75 6e 73 69 67 6e 65 64 20 69 6e 74 20 6c 20 | unsigned int l | 00000880 20 20 20 20 20 20 20 3a 20 20 34 3b 0a 20 20 75 | : 4;. u| 00000890 6e 73 69 67 6e 65 64 20 69 6e 74 20 72 20 20 20 |nsigned int r | 000008a0 20 20 20 20 20 3a 20 20 34 3b 0a 20 20 75 6e 73 | : 4;. uns| 000008b0 69 67 6e 65 64 20 69 6e 74 20 67 20 20 20 20 20 |igned int g | 000008c0 20 20 20 3a 20 20 34 3b 0a 20 20 75 6e 73 69 67 | : 4;. unsig| 000008d0 6e 65 64 20 69 6e 74 20 20 20 20 20 20 20 20 20 |ned int | 000008e0 20 3a 20 31 36 3b 20 20 20 2f 2a 20 75 6e 75 73 | : 16; /* unus| 000008f0 65 64 20 2a 2f 0a 7d 3b 0a 0a 2f 2a 20 54 68 65 |ed */.};../* The| 00000900 20 75 6e 69 6f 6e 20 77 68 69 63 68 20 74 69 65 | union which tie| 00000910 73 20 74 68 65 20 63 6f 2d 6f 72 64 69 6e 61 74 |s the co-ordinat| 00000920 65 73 20 74 6f 20 74 68 65 69 72 20 63 6f 6d 70 |es to their comp| 00000930 6f 6e 65 6e 74 20 70 61 72 74 73 2e 0a 20 20 20 |onent parts.. | 00000940 4e 6f 74 65 20 74 68 61 74 20 74 68 69 73 20 6f |Note that this o| 00000950 6e 6c 79 20 77 6f 72 6b 73 20 6f 6e 20 6c 69 74 |nly works on lit| 00000960 74 6c 65 2d 65 6e 64 69 61 6e 20 70 72 6f 63 65 |tle-endian proce| 00000970 73 73 6f 72 73 20 73 75 63 68 20 61 73 20 74 68 |ssors such as th| 00000980 65 20 41 52 4d 2e 20 0a 20 20 20 41 20 62 69 67 |e ARM. . A big| 00000990 2d 65 6e 64 69 61 6e 20 6d 61 63 68 69 6e 65 20 |-endian machine | 000009a0 77 6f 75 6c 64 20 6e 65 65 64 20 61 20 72 65 76 |would need a rev| 000009b0 65 72 73 65 20 6f 72 64 65 72 69 6e 67 2e 20 2a |erse ordering. *| 000009c0 2f 0a 0a 74 79 70 65 64 65 66 20 75 6e 69 6f 6e |/..typedef union| 000009d0 20 70 6c 61 6e 65 5f 63 6f 6f 72 64 69 6e 61 74 | plane_coordinat| 000009e0 65 0a 7b 0a 20 20 69 6e 74 20 76 61 6c 3b 0a 20 |e.{. int val;. | 000009f0 20 73 74 72 75 63 74 20 63 6f 6f 72 64 5f 62 69 | struct coord_bi| 00000a00 74 73 20 62 69 74 73 3b 0a 7d 70 6c 61 6e 65 5f |ts bits;.}plane_| 00000a10 63 6f 6f 72 64 3b 0a 0a |coord;..| 00000a18