Home » Archimedes archive » Acorn User » AU 1995-07.adf » !Life_MacroLife » !MacroLife/Docs/TechNotes
!MacroLife/Docs/TechNotes
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/TechNotes |
Read OK: | ✔ |
File size: | 3608 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
Draw� Draw �� *� X � 8 Homerton.Medium Trinity.Medium Corpus.Medium X �? � � 0 �� T X � �� T X � ���\! 1 \F 0 Trinity.Medium 12 \F 1 Homerton.Medium 12 \F 2 Homerton.Medium 14 \2\AD/\L12 Design and Programming Notes for MacroLife \0\AD/\L12/\P1 The entire MacroLife plane is stored in a four-level tree structure (but not all at once). The plane uses sixteen bits per dimension, allocated as follows: \P24 \P1 Global array covers 65,536 x 65,536 cells, <= 256 regional arrays. (16 x 16) x 4 = 1024 bytes Regional array covers 4,096 x 4,096 cells, <= 256 local arrays. (16 x 16) x 4 + 1 x 4 = 1028 bytes Local array covers 256 x 256 cells, <= 256 cells structures. (16 x 16) x 4 + 1 x 4 = 1028 bytes Cells structure has pointers to 'current' & 'next' cell arrays. 2 x 4 = 8 bytes Cell array covers 16 x 16 cells, <= 256 cells. 16 x 2 + 4 = 36 bytes \P3 Normally, a Cells structure contains a single Cell array, total = 44 bytes During generation, an additional 'next' array is stored, total = 80 bytes. All arrays are de-allocated when they become unoccupied. This means Cells structures & Cell arrays are malloc'ed (calloc, actually) using small allocation units, which speeds up re-use. (malloc:- small: 0-64 bytes, medium 65-512, large 513-16,777,216) malloc was used rather than Flex or Desklib's Mem because of the very heavy use and re-use of small chunks of memory. This does mean that the wimpslot can't shrink, but MacroLife is fairly economical in its memory usage. All but the Global arrays have a 1 word header for the occupied count. An unsigned char would suffice, but memory is allocated in 4-byte blocks, so it might as well be an int. (Incidentally, you might think that an unsigned char wouldn't quite be big enough, since the maximum population is 256 and the largest number you can store in eight bits is 255. However, since the count is only checked after it has been decremented, even if it has overflowed to 0x00 it is decremented back to 0xFF before being tested. Bit dodgy, though.) Since the cell arrays only use a single bit to store the life cells, they can't be used when calculating new generations. The generation code copies the contents of each array in turn into a work area, together with portions of the eight neighbouring arrays. The occupied cells in the overview windows are a direct reflection of the array pointers. If an array pointer is non-null, then the overview code sees this and lights up a blob in the appropriate window. Life planes occupy much less space when saved to disc, since the pointers don't need to be stored. The 1028 byte arrays described above can be stored on the disc as 36 bytes of data. Even so, there is still a good deal of redundancy due to the sparsely populated grid, so Life files usually compress well. \1\AD/\L12 \U -20 10 Other random bits of info... \U. \0\AD/\L12 The main polling loop Wimp_PollIdles 100 times per second to keep down the system overhead. MacroLife's source currently totals around thirteen thousand lines (400 Kbytes), of which about a sixth is directly devoted to the calculation and display of new generations of Life. � � *� �� &c � *� �� &c ���\! 1 \F 0 Trinity.Medium 12 \F 1 Corpus.Medium 12 \F 2 Homerton.Medium 14 \2\AD/\L12 Transformation look-up table \0\AD/\L12/\P6 Some block operations in MacroLife allow the user to apply horizontal reflection, vertical reflection and clockwise or anticlockwise rotation by 90�, in any order and as often as required, before implementing the resulting sequence of transformations. These operations are implemented as combinations of just two transformations, reflection about the y-axis and rotation 90� clockwise. These are converted into one of the eight possible orientations of the block via two eight-element look-up tables, one for reflection and one for rotation. If 't' is the transform index number, the new value of 't' is either reflect[t] or rotate[t]. The look-up tables are reproduced in the diagram to the right. P' � � x � F � I� �" � F l I� �" I� F ���� @ @ �� eE �� eE �� b# �� b# �� eE l � �" � F ���� @ @ �� eE h� eE h� b# �� b# �� eE l ȸ �" ǜ F ���� @ @ h� eE '� eE '� b# h� b# h� eE l �� �" � F ���� @ @ '� eE �~ eE �~ b# '� b# '� eE � U� x � �# l U� x T� �# ���� @ @ �� # �� # �� �� �� # l � x � �# ���� @ @ �� # s� # s� �� �� # l Ӹ x Ҝ �# ���� @ @ s� # 2� # 2� s� s� # l �� x � �# ���� @ @ 2� # �~ # �~ 2� 2� # � ^� _ � b# l ^� _ - b# ���� @ ^� b# - b# - _ ^� _ ^� b# l - _ �e b# ���� @ - b# �e b# �e _ - _ - b# l �e _ n� b# ���� @ �e b# n� b# n� _ �e _ �e b# l n� _ � b# ���� @ n� b# � b# � _ n� _ n� b# � � _ ܹ b# l � _ � b# ���� @ � b# � b# � _ � _ � b# l � _ }H b# ���� @ � b# }H b# }H _ � _ � b# l }H _ -� b# ���� @ }H b# -� b# -� _ }H _ }H b# l -� _ ܹ b# ���� @ -� b# ܹ b# ܹ _ -� _ -� b# � ܹ _ �� b# l ܹ _ �� b# ���� @ ܹ b# �� b# �� _ ܹ _ ܹ b# l �� _ <+ b# ���� @ �� b# <+ b# <+ _ �� _ �� b# l <+ _ �c b# ���� @ <+ b# �c b# �c _ <+ _ <+ b# l �c _ �� b# ���� @ �c b# �� b# �� _ �c _ �c b# � �� _ [ b# l �� _ K� b# ���� @ �� b# K� b# K� _ �� _ �� b# l K� _ � b# ���� @ K� b# � b# � _ K� _ K� b# l � _ �F b# ���� @ � b# �F b# �F _ � _ � b# l �F _ [ b# ���� @ �F b# [ b# [ _ �F _ �F b# � K � i � 8 ] � i � ��� � � J\ � 0 � 8 #� 1 #� 1 ��� � � c� � 11 8 K � � h ��� � � � � 15 8 �� � 8� � ��� � � x� � 3 � 8 �y 1 �� 1 ��� � � �y � 4 � 8 �� 1 B� 1 ��� � � B� � 7 � 8 �� � �� � ��� � � × � 8 � 8 � Z� ^ ��� � � Z� � 12 �A a) N, !A <