Home » Archimedes archive » Micro User » MU 1992-02.adf » PD » Twilight/Hints

Twilight/Hints

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 » Micro User » MU 1992-02.adf » PD
Filename: Twilight/Hints
Read OK:
File size: 07DA bytes
Load address: 0000
Exec address: 0000
File contents
Twilight Programmers Reference Disc
Effect Hints and Tips


1: Use contants for offsets into the parameter block.
So that you can easily change the order or add new parameters, it is a good
idea to define a set of contants into the data instead of hard coding these
into the instructions.

2: Do not assume that any modules other than the ones in ROM are present.
ColourTrans and the FPE are probably the ones you are most likely to want to
use, but they are not loaded by Twilight (ColourTrans is only loaded with
the front end) so using them would not always work. If you really need a
module, for example for sound, then incorperate it into the effect and use
SWI OS_Module 10 to link it in on initialisation, but remember to use an SWI
OS_Module 4 to RMkill it in your finalisation routine.

3: Use fixed point maths instead of floating point.
Fixed point maths is less accurate than floating point maths, but as it is
just an effect, who cares? It also is faster, and the FPE does not have to
be loaded. All you need to do is to shift the number by, say, 16 bits to the
left. The bottom 16 bits would then be the decimal places of the value. Be
careful of things like multiplication and division.

4: Use constants for offsets in the parameter block.
For example, the fish effect sets the following constants:
p_fish    EQU 0
p_speed   EQU 4
p_bubbles EQU 8
The parameters can be accessed with
  LDR R0,[R1,#p_fish]
This enables the order of the parameters to be changed easily. You might
like to do the same sort of thing with your workspace (using the BASIC
assembler, other assemblers have better ways of doing this).

5: Don't worry too much about not being able to run in 2 colour modes.
Most people only use 2 colour modes for printing, and users with large
monochrome screens are far and few between. Just return an error saying you
can't if you really can't. However, if there is just a slight possibity of
it working, have a go. The fish need 5 colours, but will work in 2,4 and 16
colour modes.
00000000  54 77 69 6c 69 67 68 74  20 50 72 6f 67 72 61 6d  |Twilight Program|
00000010  6d 65 72 73 20 52 65 66  65 72 65 6e 63 65 20 44  |mers Reference D|
00000020  69 73 63 0a 45 66 66 65  63 74 20 48 69 6e 74 73  |isc.Effect Hints|
00000030  20 61 6e 64 20 54 69 70  73 0a 0a 0a 31 3a 20 55  | and Tips...1: U|
00000040  73 65 20 63 6f 6e 74 61  6e 74 73 20 66 6f 72 20  |se contants for |
00000050  6f 66 66 73 65 74 73 20  69 6e 74 6f 20 74 68 65  |offsets into the|
00000060  20 70 61 72 61 6d 65 74  65 72 20 62 6c 6f 63 6b  | parameter block|
00000070  2e 0a 53 6f 20 74 68 61  74 20 79 6f 75 20 63 61  |..So that you ca|
00000080  6e 20 65 61 73 69 6c 79  20 63 68 61 6e 67 65 20  |n easily change |
00000090  74 68 65 20 6f 72 64 65  72 20 6f 72 20 61 64 64  |the order or add|
000000a0  20 6e 65 77 20 70 61 72  61 6d 65 74 65 72 73 2c  | new parameters,|
000000b0  20 69 74 20 69 73 20 61  20 67 6f 6f 64 0a 69 64  | it is a good.id|
000000c0  65 61 20 74 6f 20 64 65  66 69 6e 65 20 61 20 73  |ea to define a s|
000000d0  65 74 20 6f 66 20 63 6f  6e 74 61 6e 74 73 20 69  |et of contants i|
000000e0  6e 74 6f 20 74 68 65 20  64 61 74 61 20 69 6e 73  |nto the data ins|
000000f0  74 65 61 64 20 6f 66 20  68 61 72 64 20 63 6f 64  |tead of hard cod|
00000100  69 6e 67 20 74 68 65 73  65 0a 69 6e 74 6f 20 74  |ing these.into t|
00000110  68 65 20 69 6e 73 74 72  75 63 74 69 6f 6e 73 2e  |he instructions.|
00000120  0a 0a 32 3a 20 44 6f 20  6e 6f 74 20 61 73 73 75  |..2: Do not assu|
00000130  6d 65 20 74 68 61 74 20  61 6e 79 20 6d 6f 64 75  |me that any modu|
00000140  6c 65 73 20 6f 74 68 65  72 20 74 68 61 6e 20 74  |les other than t|
00000150  68 65 20 6f 6e 65 73 20  69 6e 20 52 4f 4d 20 61  |he ones in ROM a|
00000160  72 65 20 70 72 65 73 65  6e 74 2e 0a 43 6f 6c 6f  |re present..Colo|
00000170  75 72 54 72 61 6e 73 20  61 6e 64 20 74 68 65 20  |urTrans and the |
00000180  46 50 45 20 61 72 65 20  70 72 6f 62 61 62 6c 79  |FPE are probably|
00000190  20 74 68 65 20 6f 6e 65  73 20 79 6f 75 20 61 72  | the ones you ar|
000001a0  65 20 6d 6f 73 74 20 6c  69 6b 65 6c 79 20 74 6f  |e most likely to|
000001b0  20 77 61 6e 74 20 74 6f  0a 75 73 65 2c 20 62 75  | want to.use, bu|
000001c0  74 20 74 68 65 79 20 61  72 65 20 6e 6f 74 20 6c  |t they are not l|
000001d0  6f 61 64 65 64 20 62 79  20 54 77 69 6c 69 67 68  |oaded by Twiligh|
000001e0  74 20 28 43 6f 6c 6f 75  72 54 72 61 6e 73 20 69  |t (ColourTrans i|
000001f0  73 20 6f 6e 6c 79 20 6c  6f 61 64 65 64 20 77 69  |s only loaded wi|
00000200  74 68 0a 74 68 65 20 66  72 6f 6e 74 20 65 6e 64  |th.the front end|
00000210  29 20 73 6f 20 75 73 69  6e 67 20 74 68 65 6d 20  |) so using them |
00000220  77 6f 75 6c 64 20 6e 6f  74 20 61 6c 77 61 79 73  |would not always|
00000230  20 77 6f 72 6b 2e 20 49  66 20 79 6f 75 20 72 65  | work. If you re|
00000240  61 6c 6c 79 20 6e 65 65  64 20 61 0a 6d 6f 64 75  |ally need a.modu|
00000250  6c 65 2c 20 66 6f 72 20  65 78 61 6d 70 6c 65 20  |le, for example |
00000260  66 6f 72 20 73 6f 75 6e  64 2c 20 74 68 65 6e 20  |for sound, then |
00000270  69 6e 63 6f 72 70 65 72  61 74 65 20 69 74 20 69  |incorperate it i|
00000280  6e 74 6f 20 74 68 65 20  65 66 66 65 63 74 20 61  |nto the effect a|
00000290  6e 64 20 75 73 65 0a 53  57 49 20 4f 53 5f 4d 6f  |nd use.SWI OS_Mo|
000002a0  64 75 6c 65 20 31 30 20  74 6f 20 6c 69 6e 6b 20  |dule 10 to link |
000002b0  69 74 20 69 6e 20 6f 6e  20 69 6e 69 74 69 61 6c  |it in on initial|
000002c0  69 73 61 74 69 6f 6e 2c  20 62 75 74 20 72 65 6d  |isation, but rem|
000002d0  65 6d 62 65 72 20 74 6f  20 75 73 65 20 61 6e 20  |ember to use an |
000002e0  53 57 49 0a 4f 53 5f 4d  6f 64 75 6c 65 20 34 20  |SWI.OS_Module 4 |
000002f0  74 6f 20 52 4d 6b 69 6c  6c 20 69 74 20 69 6e 20  |to RMkill it in |
00000300  79 6f 75 72 20 66 69 6e  61 6c 69 73 61 74 69 6f  |your finalisatio|
00000310  6e 20 72 6f 75 74 69 6e  65 2e 0a 0a 33 3a 20 55  |n routine...3: U|
00000320  73 65 20 66 69 78 65 64  20 70 6f 69 6e 74 20 6d  |se fixed point m|
00000330  61 74 68 73 20 69 6e 73  74 65 61 64 20 6f 66 20  |aths instead of |
00000340  66 6c 6f 61 74 69 6e 67  20 70 6f 69 6e 74 2e 0a  |floating point..|
00000350  46 69 78 65 64 20 70 6f  69 6e 74 20 6d 61 74 68  |Fixed point math|
00000360  73 20 69 73 20 6c 65 73  73 20 61 63 63 75 72 61  |s is less accura|
00000370  74 65 20 74 68 61 6e 20  66 6c 6f 61 74 69 6e 67  |te than floating|
00000380  20 70 6f 69 6e 74 20 6d  61 74 68 73 2c 20 62 75  | point maths, bu|
00000390  74 20 61 73 20 69 74 20  69 73 0a 6a 75 73 74 20  |t as it is.just |
000003a0  61 6e 20 65 66 66 65 63  74 2c 20 77 68 6f 20 63  |an effect, who c|
000003b0  61 72 65 73 3f 20 49 74  20 61 6c 73 6f 20 69 73  |ares? It also is|
000003c0  20 66 61 73 74 65 72 2c  20 61 6e 64 20 74 68 65  | faster, and the|
000003d0  20 46 50 45 20 64 6f 65  73 20 6e 6f 74 20 68 61  | FPE does not ha|
000003e0  76 65 20 74 6f 0a 62 65  20 6c 6f 61 64 65 64 2e  |ve to.be loaded.|
000003f0  20 41 6c 6c 20 79 6f 75  20 6e 65 65 64 20 74 6f  | All you need to|
00000400  20 64 6f 20 69 73 20 74  6f 20 73 68 69 66 74 20  | do is to shift |
00000410  74 68 65 20 6e 75 6d 62  65 72 20 62 79 2c 20 73  |the number by, s|
00000420  61 79 2c 20 31 36 20 62  69 74 73 20 74 6f 20 74  |ay, 16 bits to t|
00000430  68 65 0a 6c 65 66 74 2e  20 54 68 65 20 62 6f 74  |he.left. The bot|
00000440  74 6f 6d 20 31 36 20 62  69 74 73 20 77 6f 75 6c  |tom 16 bits woul|
00000450  64 20 74 68 65 6e 20 62  65 20 74 68 65 20 64 65  |d then be the de|
00000460  63 69 6d 61 6c 20 70 6c  61 63 65 73 20 6f 66 20  |cimal places of |
00000470  74 68 65 20 76 61 6c 75  65 2e 20 42 65 0a 63 61  |the value. Be.ca|
00000480  72 65 66 75 6c 20 6f 66  20 74 68 69 6e 67 73 20  |reful of things |
00000490  6c 69 6b 65 20 6d 75 6c  74 69 70 6c 69 63 61 74  |like multiplicat|
000004a0  69 6f 6e 20 61 6e 64 20  64 69 76 69 73 69 6f 6e  |ion and division|
000004b0  2e 0a 0a 34 3a 20 55 73  65 20 63 6f 6e 73 74 61  |...4: Use consta|
000004c0  6e 74 73 20 66 6f 72 20  6f 66 66 73 65 74 73 20  |nts for offsets |
000004d0  69 6e 20 74 68 65 20 70  61 72 61 6d 65 74 65 72  |in the parameter|
000004e0  20 62 6c 6f 63 6b 2e 0a  46 6f 72 20 65 78 61 6d  | block..For exam|
000004f0  70 6c 65 2c 20 74 68 65  20 66 69 73 68 20 65 66  |ple, the fish ef|
00000500  66 65 63 74 20 73 65 74  73 20 74 68 65 20 66 6f  |fect sets the fo|
00000510  6c 6c 6f 77 69 6e 67 20  63 6f 6e 73 74 61 6e 74  |llowing constant|
00000520  73 3a 0a 70 5f 66 69 73  68 20 20 20 20 45 51 55  |s:.p_fish    EQU|
00000530  20 30 0a 70 5f 73 70 65  65 64 20 20 20 45 51 55  | 0.p_speed   EQU|
00000540  20 34 0a 70 5f 62 75 62  62 6c 65 73 20 45 51 55  | 4.p_bubbles EQU|
00000550  20 38 0a 54 68 65 20 70  61 72 61 6d 65 74 65 72  | 8.The parameter|
00000560  73 20 63 61 6e 20 62 65  20 61 63 63 65 73 73 65  |s can be accesse|
00000570  64 20 77 69 74 68 0a 20  20 4c 44 52 20 52 30 2c  |d with.  LDR R0,|
00000580  5b 52 31 2c 23 70 5f 66  69 73 68 5d 0a 54 68 69  |[R1,#p_fish].Thi|
00000590  73 20 65 6e 61 62 6c 65  73 20 74 68 65 20 6f 72  |s enables the or|
000005a0  64 65 72 20 6f 66 20 74  68 65 20 70 61 72 61 6d  |der of the param|
000005b0  65 74 65 72 73 20 74 6f  20 62 65 20 63 68 61 6e  |eters to be chan|
000005c0  67 65 64 20 65 61 73 69  6c 79 2e 20 59 6f 75 20  |ged easily. You |
000005d0  6d 69 67 68 74 0a 6c 69  6b 65 20 74 6f 20 64 6f  |might.like to do|
000005e0  20 74 68 65 20 73 61 6d  65 20 73 6f 72 74 20 6f  | the same sort o|
000005f0  66 20 74 68 69 6e 67 20  77 69 74 68 20 79 6f 75  |f thing with you|
00000600  72 20 77 6f 72 6b 73 70  61 63 65 20 28 75 73 69  |r workspace (usi|
00000610  6e 67 20 74 68 65 20 42  41 53 49 43 0a 61 73 73  |ng the BASIC.ass|
00000620  65 6d 62 6c 65 72 2c 20  6f 74 68 65 72 20 61 73  |embler, other as|
00000630  73 65 6d 62 6c 65 72 73  20 68 61 76 65 20 62 65  |semblers have be|
00000640  74 74 65 72 20 77 61 79  73 20 6f 66 20 64 6f 69  |tter ways of doi|
00000650  6e 67 20 74 68 69 73 29  2e 0a 0a 35 3a 20 44 6f  |ng this)...5: Do|
00000660  6e 27 74 20 77 6f 72 72  79 20 74 6f 6f 20 6d 75  |n't worry too mu|
00000670  63 68 20 61 62 6f 75 74  20 6e 6f 74 20 62 65 69  |ch about not bei|
00000680  6e 67 20 61 62 6c 65 20  74 6f 20 72 75 6e 20 69  |ng able to run i|
00000690  6e 20 32 20 63 6f 6c 6f  75 72 20 6d 6f 64 65 73  |n 2 colour modes|
000006a0  2e 0a 4d 6f 73 74 20 70  65 6f 70 6c 65 20 6f 6e  |..Most people on|
000006b0  6c 79 20 75 73 65 20 32  20 63 6f 6c 6f 75 72 20  |ly use 2 colour |
000006c0  6d 6f 64 65 73 20 66 6f  72 20 70 72 69 6e 74 69  |modes for printi|
000006d0  6e 67 2c 20 61 6e 64 20  75 73 65 72 73 20 77 69  |ng, and users wi|
000006e0  74 68 20 6c 61 72 67 65  0a 6d 6f 6e 6f 63 68 72  |th large.monochr|
000006f0  6f 6d 65 20 73 63 72 65  65 6e 73 20 61 72 65 20  |ome screens are |
00000700  66 61 72 20 61 6e 64 20  66 65 77 20 62 65 74 77  |far and few betw|
00000710  65 65 6e 2e 20 4a 75 73  74 20 72 65 74 75 72 6e  |een. Just return|
00000720  20 61 6e 20 65 72 72 6f  72 20 73 61 79 69 6e 67  | an error saying|
00000730  20 79 6f 75 0a 63 61 6e  27 74 20 69 66 20 79 6f  | you.can't if yo|
00000740  75 20 72 65 61 6c 6c 79  20 63 61 6e 27 74 2e 20  |u really can't. |
00000750  48 6f 77 65 76 65 72 2c  20 69 66 20 74 68 65 72  |However, if ther|
00000760  65 20 69 73 20 6a 75 73  74 20 61 20 73 6c 69 67  |e is just a slig|
00000770  68 74 20 70 6f 73 73 69  62 69 74 79 20 6f 66 0a  |ht possibity of.|
00000780  69 74 20 77 6f 72 6b 69  6e 67 2c 20 68 61 76 65  |it working, have|
00000790  20 61 20 67 6f 2e 20 54  68 65 20 66 69 73 68 20  | a go. The fish |
000007a0  6e 65 65 64 20 35 20 63  6f 6c 6f 75 72 73 2c 20  |need 5 colours, |
000007b0  62 75 74 20 77 69 6c 6c  20 77 6f 72 6b 20 69 6e  |but will work in|
000007c0  20 32 2c 34 20 61 6e 64  20 31 36 0a 63 6f 6c 6f  | 2,4 and 16.colo|
000007d0  75 72 20 6d 6f 64 65 73  2e 0a                    |ur modes..|
000007da