Home » Archimedes archive » Micro User » MU 1992-01.adf » PDstuffing » Twilight/+TwPRD/Hints
Twilight/+TwPRD/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-01.adf » PDstuffing |
Filename: | Twilight/+TwPRD/Hints |
Read OK: | ✔ |
File size: | 0543 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 so using them would not always work. 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).
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 0a 53 6f 20 74 68 61 74 20 79 6f 75 20 63 61 6e |.So that you can| 00000080 20 65 61 73 69 6c 79 20 63 68 61 6e 67 65 20 74 | easily change t| 00000090 68 65 20 6f 72 64 65 72 20 6f 72 20 61 64 64 20 |he order or add | 000000a0 6e 65 77 20 70 61 72 61 6d 65 74 65 72 73 2c 20 |new parameters, | 000000b0 69 74 20 69 73 20 61 20 67 6f 6f 64 0a 69 64 65 |it is a good.ide| 000000c0 61 20 74 6f 20 64 65 66 69 6e 65 20 61 20 73 65 |a to define a se| 000000d0 74 20 6f 66 20 63 6f 6e 74 61 6e 74 73 20 69 6e |t of contants in| 000000e0 74 6f 20 74 68 65 20 64 61 74 61 20 69 6e 73 74 |to the data inst| 000000f0 65 61 64 20 6f 66 20 68 61 72 64 20 63 6f 64 69 |ead of hard codi| 00000100 6e 67 20 74 68 65 73 65 0a 69 6e 74 6f 20 74 68 |ng these.into th| 00000110 65 20 69 6e 73 74 72 75 63 74 69 6f 6e 73 2e 0a |e instructions..| 00000120 0a 32 3a 20 44 6f 20 6e 6f 74 20 61 73 73 75 6d |.2: Do not assum| 00000130 65 20 74 68 61 74 20 61 6e 79 20 6d 6f 64 75 6c |e that any modul| 00000140 65 73 20 6f 74 68 65 72 20 74 68 61 6e 20 74 68 |es other than th| 00000150 65 20 6f 6e 65 73 20 69 6e 20 52 4f 4d 20 61 72 |e ones in ROM ar| 00000160 65 20 70 72 65 73 65 6e 74 0a 43 6f 6c 6f 75 72 |e present.Colour| 00000170 54 72 61 6e 73 20 61 6e 64 20 74 68 65 20 46 50 |Trans and the FP| 00000180 45 20 61 72 65 20 70 72 6f 62 61 62 6c 79 20 74 |E are probably t| 00000190 68 65 20 6f 6e 65 73 20 79 6f 75 20 61 72 65 20 |he ones you are | 000001a0 6d 6f 73 74 20 6c 69 6b 65 6c 79 20 74 6f 20 77 |most likely to w| 000001b0 61 6e 74 20 74 6f 0a 75 73 65 2c 20 62 75 74 20 |ant to.use, but | 000001c0 74 68 65 79 20 61 72 65 20 6e 6f 74 20 6c 6f 61 |they are not loa| 000001d0 64 65 64 20 62 79 20 54 77 69 6c 69 67 68 74 20 |ded by Twilight | 000001e0 73 6f 20 75 73 69 6e 67 20 74 68 65 6d 20 77 6f |so using them wo| 000001f0 75 6c 64 20 6e 6f 74 20 61 6c 77 61 79 73 0a 77 |uld not always.w| 00000200 6f 72 6b 2e 0a 0a 33 3a 20 55 73 65 20 66 69 78 |ork...3: Use fix| 00000210 65 64 20 70 6f 69 6e 74 20 6d 61 74 68 73 20 69 |ed point maths i| 00000220 6e 73 74 65 61 64 20 6f 66 20 66 6c 6f 61 74 69 |nstead of floati| 00000230 6e 67 20 70 6f 69 6e 74 0a 46 69 78 65 64 20 70 |ng point.Fixed p| 00000240 6f 69 6e 74 20 6d 61 74 68 73 20 69 73 20 6c 65 |oint maths is le| 00000250 73 73 20 61 63 63 75 72 61 74 65 20 74 68 61 6e |ss accurate than| 00000260 20 66 6c 6f 61 74 69 6e 67 20 70 6f 69 6e 74 20 | floating point | 00000270 6d 61 74 68 73 2c 20 62 75 74 20 61 73 20 69 74 |maths, but as it| 00000280 20 69 73 0a 6a 75 73 74 20 61 6e 20 65 66 66 65 | is.just an effe| 00000290 63 74 2c 20 77 68 6f 20 63 61 72 65 73 3f 20 49 |ct, who cares? I| 000002a0 74 20 61 6c 73 6f 20 69 73 20 66 61 73 74 65 72 |t also is faster| 000002b0 2c 20 61 6e 64 20 74 68 65 20 46 50 45 20 64 6f |, and the FPE do| 000002c0 65 73 20 6e 6f 74 20 68 61 76 65 20 74 6f 0a 62 |es not have to.b| 000002d0 65 20 6c 6f 61 64 65 64 2e 20 41 6c 6c 20 79 6f |e loaded. All yo| 000002e0 75 20 6e 65 65 64 20 74 6f 20 64 6f 20 69 73 20 |u need to do is | 000002f0 74 6f 20 73 68 69 66 74 20 74 68 65 20 6e 75 6d |to shift the num| 00000300 62 65 72 20 62 79 2c 20 73 61 79 2c 20 31 36 20 |ber by, say, 16 | 00000310 62 69 74 73 20 74 6f 20 74 68 65 0a 6c 65 66 74 |bits to the.left| 00000320 2e 20 54 68 65 20 62 6f 74 74 6f 6d 20 31 36 20 |. The bottom 16 | 00000330 62 69 74 73 20 77 6f 75 6c 64 20 74 68 65 6e 20 |bits would then | 00000340 62 65 20 74 68 65 20 64 65 63 69 6d 61 6c 20 70 |be the decimal p| 00000350 6c 61 63 65 73 20 6f 66 20 74 68 65 20 76 61 6c |laces of the val| 00000360 75 65 2e 20 42 65 0a 63 61 72 65 66 75 6c 20 6f |ue. Be.careful o| 00000370 66 20 74 68 69 6e 67 73 20 6c 69 6b 65 20 6d 75 |f things like mu| 00000380 6c 74 69 70 6c 69 63 61 74 69 6f 6e 20 61 6e 64 |ltiplication and| 00000390 20 64 69 76 69 73 69 6f 6e 2e 0a 0a 34 3a 20 55 | division...4: U| 000003a0 73 65 20 63 6f 6e 73 74 61 6e 74 73 20 66 6f 72 |se constants for| 000003b0 20 6f 66 66 73 65 74 73 20 69 6e 20 74 68 65 20 | offsets in the | 000003c0 70 61 72 61 6d 65 74 65 72 20 62 6c 6f 63 6b 2e |parameter block.| 000003d0 0a 46 6f 72 20 65 78 61 6d 70 6c 65 2c 20 74 68 |.For example, th| 000003e0 65 20 66 69 73 68 20 65 66 66 65 63 74 20 73 65 |e fish effect se| 000003f0 74 73 20 74 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 |ts the following| 00000400 20 63 6f 6e 73 74 61 6e 74 73 3a 0a 70 5f 66 69 | constants:.p_fi| 00000410 73 68 20 20 20 20 45 51 55 20 30 0a 70 5f 73 70 |sh EQU 0.p_sp| 00000420 65 65 64 20 20 20 45 51 55 20 34 0a 70 5f 62 75 |eed EQU 4.p_bu| 00000430 62 62 6c 65 73 20 45 51 55 20 38 0a 54 68 65 20 |bbles EQU 8.The | 00000440 70 61 72 61 6d 65 74 65 72 73 20 63 61 6e 20 62 |parameters can b| 00000450 65 20 61 63 63 65 73 73 65 64 20 77 69 74 68 0a |e accessed with.| 00000460 20 20 4c 44 52 20 52 30 2c 5b 52 31 2c 23 70 5f | LDR R0,[R1,#p_| 00000470 66 69 73 68 5d 0a 54 68 69 73 20 65 6e 61 62 6c |fish].This enabl| 00000480 65 73 20 74 68 65 20 6f 72 64 65 72 20 6f 66 20 |es the order of | 00000490 74 68 65 20 70 61 72 61 6d 65 74 65 72 73 20 74 |the parameters t| 000004a0 6f 20 62 65 20 63 68 61 6e 67 65 64 20 65 61 73 |o be changed eas| 000004b0 69 6c 79 2e 20 59 6f 75 20 6d 69 67 68 74 0a 6c |ily. You might.l| 000004c0 69 6b 65 20 74 6f 20 64 6f 20 74 68 65 20 73 61 |ike to do the sa| 000004d0 6d 65 20 73 6f 72 74 20 6f 66 20 74 68 69 6e 67 |me sort of thing| 000004e0 20 77 69 74 68 20 79 6f 75 72 20 77 6f 72 6b 73 | with your works| 000004f0 70 61 63 65 20 28 75 73 69 6e 67 20 74 68 65 20 |pace (using the | 00000500 42 41 53 49 43 0a 61 73 73 65 6d 62 6c 65 72 2c |BASIC.assembler,| 00000510 20 6f 74 68 65 72 20 61 73 73 65 6d 62 6c 65 72 | other assembler| 00000520 73 20 68 61 76 65 20 62 65 74 74 65 72 20 77 61 |s have better wa| 00000530 79 73 20 6f 66 20 64 6f 69 6e 67 20 74 68 69 73 |ys of doing this| 00000540 29 2e 0a |)..| 00000543