Home » Archimedes archive » Micro User » MU 1992-01.adf » PDstuffing » Twilight/+TwPRD/Entry

Twilight/+TwPRD/Entry

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/Entry
Read OK:
File size: 0FDF bytes
Load address: 0000
Exec address: 0000
File contents
Twilight Programmers Reference Disc
Effect entry points


General points
~~~~~~~~~~~~~~
All code should regard itself as OS code - i.e. only X swis etc.

r11 points to private word at all entry points

All registers up to and including r8 may be corrupted

r10 must not be corrupted

Colour 0 is black, and must be kept as so.

Code should be able to run in User and SVC modes. (see below)

All entrys are entered with r0 as zero if the screen is black. This is
useful as if the effect does not want the screen to be faded, then it will
be all black if it is not the first effect in a random sequence or there is
a password set. The effect there for will need to draw something on the
screen. Have a look at the effects 'Puzzle' and 'Spotlight' to see what they
do.

Sleep init
~~~~~~~~~~
Entry r10 = pointer to environment block
      r1  = pointer to parameter block
Exit  if error set V and r0 = pointer to error block

Sleep poll
~~~~~~~~~~
Entry r10 = pointer to environment block
      r1  = pointer to parameter block
Exit  if error set V and r0 = pointer to error block

If module supports suitiable time to stop messages, on exit r0 can be:
  0  not a suitable time
  1  almost a suitiable time
  2  it is a suitiable time to stop now
However, it should be able to cope with being stopped at any time. The
effect will not be changed during a random effect if the effect returns 1.
However, an effect must not continually return a 1 if this stage takes a
long time.

Sleep final
~~~~~~~~~~~
Entry r10 = pointer to environment block


Processor modes
~~~~~~~~~~~~~~~
Effects must be able to be called in both User and SVC modes. Don't worry
about this - just write the code for SVC mode and it will work in user mode.


Errors
~~~~~~
Error should be returned in the normal way (set v flag, r0 points to error
block). If an error occurs in the poll entry, the finalise entry will be
called, but it will not if the error was in the init or finalise entry.


Environment block
~~~~~~~~~~~~~~~~~
each entry is a word long
Note: routines can only be called from effects

Offset Meaning
0      colours in mode
4      max x os unit
8      max y os unit
12     address of random routine
16     address of division routine
20     base address of screen (display hardware) (149)
24     XEigFactor (4)
28     LineLength (6)
32     YWindLimit (12) 
36     ScreenSize (7)

Numbers in brackets refer to the parameter to OS_ReadVduVariables


How to call a environment block routine
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
r12 must be preserved for these calls to work.
 ...
 MOV   R14,PC                ; as PC points 2 instructions ahead
 LDR   PC,[R10,#e_random]    ; using standard effect header
 ...

Random routine
~~~~~~~~~~~~~~
A random routine - fairly random. Provides a function similar to the BASIC
rnd() command - but integers only. The value returned is from 0 to the max
number specified. 0 and the max number may be returned.

Entry: r0 = max random number
Exit:  r0 = random number

Division routine
~~~~~~~~~~~~~~~~
This is a fast division routine. It will always take the same time to
execute.

divides r0 by r1 
returns r2 = remainder
        r3 = result


Calling effects from effects
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It is possible to call another effect from an effect, and in some cases it
is useful (for example the RndLoader effects supplied with Twilight). Some
Twilight SWIs are documented here which may help. You should obey the entry
conditions exactly providing parameter blocks and workspace. Be careful..

Twilight_NEffects
Entry -
Exit  r1 = number of effects currently loaded

Counts how many effects are currently loaded.


Twilight_GetEffectHeader
Entry r0 = effect name
Exit  r1 = pointer to effect header

Gets a pointer to the header of an effect. 0 is returned if it cannot be
found. Special values for the effect name are:
  -1 currently selected effect.


Twilight_EnvironmentBlock
Entry -
Exit  r1 = pointer to environment block

Gets the pointer to the current environment block.
Note: routines can only be called from effects.

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 65 6e 74 72 79  |isc.Effect entry|
00000030  20 70 6f 69 6e 74 73 0a  0a 0a 47 65 6e 65 72 61  | points...Genera|
00000040  6c 20 70 6f 69 6e 74 73  0a 7e 7e 7e 7e 7e 7e 7e  |l points.~~~~~~~|
00000050  7e 7e 7e 7e 7e 7e 7e 0a  41 6c 6c 20 63 6f 64 65  |~~~~~~~.All code|
00000060  20 73 68 6f 75 6c 64 20  72 65 67 61 72 64 20 69  | should regard i|
00000070  74 73 65 6c 66 20 61 73  20 4f 53 20 63 6f 64 65  |tself as OS code|
00000080  20 2d 20 69 2e 65 2e 20  6f 6e 6c 79 20 58 20 73  | - i.e. only X s|
00000090  77 69 73 20 65 74 63 2e  0a 0a 72 31 31 20 70 6f  |wis etc...r11 po|
000000a0  69 6e 74 73 20 74 6f 20  70 72 69 76 61 74 65 20  |ints to private |
000000b0  77 6f 72 64 20 61 74 20  61 6c 6c 20 65 6e 74 72  |word at all entr|
000000c0  79 20 70 6f 69 6e 74 73  0a 0a 41 6c 6c 20 72 65  |y points..All re|
000000d0  67 69 73 74 65 72 73 20  75 70 20 74 6f 20 61 6e  |gisters up to an|
000000e0  64 20 69 6e 63 6c 75 64  69 6e 67 20 72 38 20 6d  |d including r8 m|
000000f0  61 79 20 62 65 20 63 6f  72 72 75 70 74 65 64 0a  |ay be corrupted.|
00000100  0a 72 31 30 20 6d 75 73  74 20 6e 6f 74 20 62 65  |.r10 must not be|
00000110  20 63 6f 72 72 75 70 74  65 64 0a 0a 43 6f 6c 6f  | corrupted..Colo|
00000120  75 72 20 30 20 69 73 20  62 6c 61 63 6b 2c 20 61  |ur 0 is black, a|
00000130  6e 64 20 6d 75 73 74 20  62 65 20 6b 65 70 74 20  |nd must be kept |
00000140  61 73 20 73 6f 2e 0a 0a  43 6f 64 65 20 73 68 6f  |as so...Code sho|
00000150  75 6c 64 20 62 65 20 61  62 6c 65 20 74 6f 20 72  |uld be able to r|
00000160  75 6e 20 69 6e 20 55 73  65 72 20 61 6e 64 20 53  |un in User and S|
00000170  56 43 20 6d 6f 64 65 73  2e 20 28 73 65 65 20 62  |VC modes. (see b|
00000180  65 6c 6f 77 29 0a 0a 41  6c 6c 20 65 6e 74 72 79  |elow)..All entry|
00000190  73 20 61 72 65 20 65 6e  74 65 72 65 64 20 77 69  |s are entered wi|
000001a0  74 68 20 72 30 20 61 73  20 7a 65 72 6f 20 69 66  |th r0 as zero if|
000001b0  20 74 68 65 20 73 63 72  65 65 6e 20 69 73 20 62  | the screen is b|
000001c0  6c 61 63 6b 2e 20 54 68  69 73 20 69 73 0a 75 73  |lack. This is.us|
000001d0  65 66 75 6c 20 61 73 20  69 66 20 74 68 65 20 65  |eful as if the e|
000001e0  66 66 65 63 74 20 64 6f  65 73 20 6e 6f 74 20 77  |ffect does not w|
000001f0  61 6e 74 20 74 68 65 20  73 63 72 65 65 6e 20 74  |ant the screen t|
00000200  6f 20 62 65 20 66 61 64  65 64 2c 20 74 68 65 6e  |o be faded, then|
00000210  20 69 74 20 77 69 6c 6c  0a 62 65 20 61 6c 6c 20  | it will.be all |
00000220  62 6c 61 63 6b 20 69 66  20 69 74 20 69 73 20 6e  |black if it is n|
00000230  6f 74 20 74 68 65 20 66  69 72 73 74 20 65 66 66  |ot the first eff|
00000240  65 63 74 20 69 6e 20 61  20 72 61 6e 64 6f 6d 20  |ect in a random |
00000250  73 65 71 75 65 6e 63 65  20 6f 72 20 74 68 65 72  |sequence or ther|
00000260  65 20 69 73 0a 61 20 70  61 73 73 77 6f 72 64 20  |e is.a password |
00000270  73 65 74 2e 20 54 68 65  20 65 66 66 65 63 74 20  |set. The effect |
00000280  74 68 65 72 65 20 66 6f  72 20 77 69 6c 6c 20 6e  |there for will n|
00000290  65 65 64 20 74 6f 20 64  72 61 77 20 73 6f 6d 65  |eed to draw some|
000002a0  74 68 69 6e 67 20 6f 6e  20 74 68 65 0a 73 63 72  |thing on the.scr|
000002b0  65 65 6e 2e 20 48 61 76  65 20 61 20 6c 6f 6f 6b  |een. Have a look|
000002c0  20 61 74 20 74 68 65 20  65 66 66 65 63 74 73 20  | at the effects |
000002d0  27 50 75 7a 7a 6c 65 27  20 61 6e 64 20 27 53 70  |'Puzzle' and 'Sp|
000002e0  6f 74 6c 69 67 68 74 27  20 74 6f 20 73 65 65 20  |otlight' to see |
000002f0  77 68 61 74 20 74 68 65  79 0a 64 6f 2e 0a 0a 53  |what they.do...S|
00000300  6c 65 65 70 20 69 6e 69  74 0a 7e 7e 7e 7e 7e 7e  |leep init.~~~~~~|
00000310  7e 7e 7e 7e 0a 45 6e 74  72 79 20 72 31 30 20 3d  |~~~~.Entry r10 =|
00000320  20 70 6f 69 6e 74 65 72  20 74 6f 20 65 6e 76 69  | pointer to envi|
00000330  72 6f 6e 6d 65 6e 74 20  62 6c 6f 63 6b 0a 20 20  |ronment block.  |
00000340  20 20 20 20 72 31 20 20  3d 20 70 6f 69 6e 74 65  |    r1  = pointe|
00000350  72 20 74 6f 20 70 61 72  61 6d 65 74 65 72 20 62  |r to parameter b|
00000360  6c 6f 63 6b 0a 45 78 69  74 20 20 69 66 20 65 72  |lock.Exit  if er|
00000370  72 6f 72 20 73 65 74 20  56 20 61 6e 64 20 72 30  |ror set V and r0|
00000380  20 3d 20 70 6f 69 6e 74  65 72 20 74 6f 20 65 72  | = pointer to er|
00000390  72 6f 72 20 62 6c 6f 63  6b 0a 0a 53 6c 65 65 70  |ror block..Sleep|
000003a0  20 70 6f 6c 6c 0a 7e 7e  7e 7e 7e 7e 7e 7e 7e 7e  | poll.~~~~~~~~~~|
000003b0  0a 45 6e 74 72 79 20 72  31 30 20 3d 20 70 6f 69  |.Entry r10 = poi|
000003c0  6e 74 65 72 20 74 6f 20  65 6e 76 69 72 6f 6e 6d  |nter to environm|
000003d0  65 6e 74 20 62 6c 6f 63  6b 0a 20 20 20 20 20 20  |ent block.      |
000003e0  72 31 20 20 3d 20 70 6f  69 6e 74 65 72 20 74 6f  |r1  = pointer to|
000003f0  20 70 61 72 61 6d 65 74  65 72 20 62 6c 6f 63 6b  | parameter block|
00000400  0a 45 78 69 74 20 20 69  66 20 65 72 72 6f 72 20  |.Exit  if error |
00000410  73 65 74 20 56 20 61 6e  64 20 72 30 20 3d 20 70  |set V and r0 = p|
00000420  6f 69 6e 74 65 72 20 74  6f 20 65 72 72 6f 72 20  |ointer to error |
00000430  62 6c 6f 63 6b 0a 0a 49  66 20 6d 6f 64 75 6c 65  |block..If module|
00000440  20 73 75 70 70 6f 72 74  73 20 73 75 69 74 69 61  | supports suitia|
00000450  62 6c 65 20 74 69 6d 65  20 74 6f 20 73 74 6f 70  |ble time to stop|
00000460  20 6d 65 73 73 61 67 65  73 2c 20 6f 6e 20 65 78  | messages, on ex|
00000470  69 74 20 72 30 20 63 61  6e 20 62 65 3a 0a 20 20  |it r0 can be:.  |
00000480  30 20 20 6e 6f 74 20 61  20 73 75 69 74 61 62 6c  |0  not a suitabl|
00000490  65 20 74 69 6d 65 0a 20  20 31 20 20 61 6c 6d 6f  |e time.  1  almo|
000004a0  73 74 20 61 20 73 75 69  74 69 61 62 6c 65 20 74  |st a suitiable t|
000004b0  69 6d 65 0a 20 20 32 20  20 69 74 20 69 73 20 61  |ime.  2  it is a|
000004c0  20 73 75 69 74 69 61 62  6c 65 20 74 69 6d 65 20  | suitiable time |
000004d0  74 6f 20 73 74 6f 70 20  6e 6f 77 0a 48 6f 77 65  |to stop now.Howe|
000004e0  76 65 72 2c 20 69 74 20  73 68 6f 75 6c 64 20 62  |ver, it should b|
000004f0  65 20 61 62 6c 65 20 74  6f 20 63 6f 70 65 20 77  |e able to cope w|
00000500  69 74 68 20 62 65 69 6e  67 20 73 74 6f 70 70 65  |ith being stoppe|
00000510  64 20 61 74 20 61 6e 79  20 74 69 6d 65 2e 20 54  |d at any time. T|
00000520  68 65 0a 65 66 66 65 63  74 20 77 69 6c 6c 20 6e  |he.effect will n|
00000530  6f 74 20 62 65 20 63 68  61 6e 67 65 64 20 64 75  |ot be changed du|
00000540  72 69 6e 67 20 61 20 72  61 6e 64 6f 6d 20 65 66  |ring a random ef|
00000550  66 65 63 74 20 69 66 20  74 68 65 20 65 66 66 65  |fect if the effe|
00000560  63 74 20 72 65 74 75 72  6e 73 20 31 2e 0a 48 6f  |ct returns 1..Ho|
00000570  77 65 76 65 72 2c 20 61  6e 20 65 66 66 65 63 74  |wever, an effect|
00000580  20 6d 75 73 74 20 6e 6f  74 20 63 6f 6e 74 69 6e  | must not contin|
00000590  75 61 6c 6c 79 20 72 65  74 75 72 6e 20 61 20 31  |ually return a 1|
000005a0  20 69 66 20 74 68 69 73  20 73 74 61 67 65 20 74  | if this stage t|
000005b0  61 6b 65 73 20 61 0a 6c  6f 6e 67 20 74 69 6d 65  |akes a.long time|
000005c0  2e 0a 0a 53 6c 65 65 70  20 66 69 6e 61 6c 0a 7e  |...Sleep final.~|
000005d0  7e 7e 7e 7e 7e 7e 7e 7e  7e 7e 0a 45 6e 74 72 79  |~~~~~~~~~~.Entry|
000005e0  20 72 31 30 20 3d 20 70  6f 69 6e 74 65 72 20 74  | r10 = pointer t|
000005f0  6f 20 65 6e 76 69 72 6f  6e 6d 65 6e 74 20 62 6c  |o environment bl|
00000600  6f 63 6b 0a 0a 0a 50 72  6f 63 65 73 73 6f 72 20  |ock...Processor |
00000610  6d 6f 64 65 73 0a 7e 7e  7e 7e 7e 7e 7e 7e 7e 7e  |modes.~~~~~~~~~~|
00000620  7e 7e 7e 7e 7e 0a 45 66  66 65 63 74 73 20 6d 75  |~~~~~.Effects mu|
00000630  73 74 20 62 65 20 61 62  6c 65 20 74 6f 20 62 65  |st be able to be|
00000640  20 63 61 6c 6c 65 64 20  69 6e 20 62 6f 74 68 20  | called in both |
00000650  55 73 65 72 20 61 6e 64  20 53 56 43 20 6d 6f 64  |User and SVC mod|
00000660  65 73 2e 20 44 6f 6e 27  74 20 77 6f 72 72 79 0a  |es. Don't worry.|
00000670  61 62 6f 75 74 20 74 68  69 73 20 2d 20 6a 75 73  |about this - jus|
00000680  74 20 77 72 69 74 65 20  74 68 65 20 63 6f 64 65  |t write the code|
00000690  20 66 6f 72 20 53 56 43  20 6d 6f 64 65 20 61 6e  | for SVC mode an|
000006a0  64 20 69 74 20 77 69 6c  6c 20 77 6f 72 6b 20 69  |d it will work i|
000006b0  6e 20 75 73 65 72 20 6d  6f 64 65 2e 0a 0a 0a 45  |n user mode....E|
000006c0  72 72 6f 72 73 0a 7e 7e  7e 7e 7e 7e 0a 45 72 72  |rrors.~~~~~~.Err|
000006d0  6f 72 20 73 68 6f 75 6c  64 20 62 65 20 72 65 74  |or should be ret|
000006e0  75 72 6e 65 64 20 69 6e  20 74 68 65 20 6e 6f 72  |urned in the nor|
000006f0  6d 61 6c 20 77 61 79 20  28 73 65 74 20 76 20 66  |mal way (set v f|
00000700  6c 61 67 2c 20 72 30 20  70 6f 69 6e 74 73 20 74  |lag, r0 points t|
00000710  6f 20 65 72 72 6f 72 0a  62 6c 6f 63 6b 29 2e 20  |o error.block). |
00000720  49 66 20 61 6e 20 65 72  72 6f 72 20 6f 63 63 75  |If an error occu|
00000730  72 73 20 69 6e 20 74 68  65 20 70 6f 6c 6c 20 65  |rs in the poll e|
00000740  6e 74 72 79 2c 20 74 68  65 20 66 69 6e 61 6c 69  |ntry, the finali|
00000750  73 65 20 65 6e 74 72 79  20 77 69 6c 6c 20 62 65  |se entry will be|
00000760  0a 63 61 6c 6c 65 64 2c  20 62 75 74 20 69 74 20  |.called, but it |
00000770  77 69 6c 6c 20 6e 6f 74  20 69 66 20 74 68 65 20  |will not if the |
00000780  65 72 72 6f 72 20 77 61  73 20 69 6e 20 74 68 65  |error was in the|
00000790  20 69 6e 69 74 20 6f 72  20 66 69 6e 61 6c 69 73  | init or finalis|
000007a0  65 20 65 6e 74 72 79 2e  0a 0a 0a 45 6e 76 69 72  |e entry....Envir|
000007b0  6f 6e 6d 65 6e 74 20 62  6c 6f 63 6b 0a 7e 7e 7e  |onment block.~~~|
000007c0  7e 7e 7e 7e 7e 7e 7e 7e  7e 7e 7e 7e 7e 7e 0a 65  |~~~~~~~~~~~~~~.e|
000007d0  61 63 68 20 65 6e 74 72  79 20 69 73 20 61 20 77  |ach entry is a w|
000007e0  6f 72 64 20 6c 6f 6e 67  0a 4e 6f 74 65 3a 20 72  |ord long.Note: r|
000007f0  6f 75 74 69 6e 65 73 20  63 61 6e 20 6f 6e 6c 79  |outines can only|
00000800  20 62 65 20 63 61 6c 6c  65 64 20 66 72 6f 6d 20  | be called from |
00000810  65 66 66 65 63 74 73 0a  0a 4f 66 66 73 65 74 20  |effects..Offset |
00000820  4d 65 61 6e 69 6e 67 0a  30 20 20 20 20 20 20 63  |Meaning.0      c|
00000830  6f 6c 6f 75 72 73 20 69  6e 20 6d 6f 64 65 0a 34  |olours in mode.4|
00000840  20 20 20 20 20 20 6d 61  78 20 78 20 6f 73 20 75  |      max x os u|
00000850  6e 69 74 0a 38 20 20 20  20 20 20 6d 61 78 20 79  |nit.8      max y|
00000860  20 6f 73 20 75 6e 69 74  0a 31 32 20 20 20 20 20  | os unit.12     |
00000870  61 64 64 72 65 73 73 20  6f 66 20 72 61 6e 64 6f  |address of rando|
00000880  6d 20 72 6f 75 74 69 6e  65 0a 31 36 20 20 20 20  |m routine.16    |
00000890  20 61 64 64 72 65 73 73  20 6f 66 20 64 69 76 69  | address of divi|
000008a0  73 69 6f 6e 20 72 6f 75  74 69 6e 65 0a 32 30 20  |sion routine.20 |
000008b0  20 20 20 20 62 61 73 65  20 61 64 64 72 65 73 73  |    base address|
000008c0  20 6f 66 20 73 63 72 65  65 6e 20 28 64 69 73 70  | of screen (disp|
000008d0  6c 61 79 20 68 61 72 64  77 61 72 65 29 20 28 31  |lay hardware) (1|
000008e0  34 39 29 0a 32 34 20 20  20 20 20 58 45 69 67 46  |49).24     XEigF|
000008f0  61 63 74 6f 72 20 28 34  29 0a 32 38 20 20 20 20  |actor (4).28    |
00000900  20 4c 69 6e 65 4c 65 6e  67 74 68 20 28 36 29 0a  | LineLength (6).|
00000910  33 32 20 20 20 20 20 59  57 69 6e 64 4c 69 6d 69  |32     YWindLimi|
00000920  74 20 28 31 32 29 20 0a  33 36 20 20 20 20 20 53  |t (12) .36     S|
00000930  63 72 65 65 6e 53 69 7a  65 20 28 37 29 0a 0a 4e  |creenSize (7)..N|
00000940  75 6d 62 65 72 73 20 69  6e 20 62 72 61 63 6b 65  |umbers in bracke|
00000950  74 73 20 72 65 66 65 72  20 74 6f 20 74 68 65 20  |ts refer to the |
00000960  70 61 72 61 6d 65 74 65  72 20 74 6f 20 4f 53 5f  |parameter to OS_|
00000970  52 65 61 64 56 64 75 56  61 72 69 61 62 6c 65 73  |ReadVduVariables|
00000980  0a 0a 0a 48 6f 77 20 74  6f 20 63 61 6c 6c 20 61  |...How to call a|
00000990  20 65 6e 76 69 72 6f 6e  6d 65 6e 74 20 62 6c 6f  | environment blo|
000009a0  63 6b 20 72 6f 75 74 69  6e 65 0a 7e 7e 7e 7e 7e  |ck routine.~~~~~|
000009b0  7e 7e 7e 7e 7e 7e 7e 7e  7e 7e 7e 7e 7e 7e 7e 7e  |~~~~~~~~~~~~~~~~|
*
000009d0  7e 7e 0a 72 31 32 20 6d  75 73 74 20 62 65 20 70  |~~.r12 must be p|
000009e0  72 65 73 65 72 76 65 64  20 66 6f 72 20 74 68 65  |reserved for the|
000009f0  73 65 20 63 61 6c 6c 73  20 74 6f 20 77 6f 72 6b  |se calls to work|
00000a00  2e 0a 20 2e 2e 2e 0a 20  4d 4f 56 20 20 20 52 31  |.. .... MOV   R1|
00000a10  34 2c 50 43 20 20 20 20  20 20 20 20 20 20 20 20  |4,PC            |
00000a20  20 20 20 20 3b 20 61 73  20 50 43 20 70 6f 69 6e  |    ; as PC poin|
00000a30  74 73 20 32 20 69 6e 73  74 72 75 63 74 69 6f 6e  |ts 2 instruction|
00000a40  73 20 61 68 65 61 64 0a  20 4c 44 52 20 20 20 50  |s ahead. LDR   P|
00000a50  43 2c 5b 52 31 30 2c 23  65 5f 72 61 6e 64 6f 6d  |C,[R10,#e_random|
00000a60  5d 20 20 20 20 3b 20 75  73 69 6e 67 20 73 74 61  |]    ; using sta|
00000a70  6e 64 61 72 64 20 65 66  66 65 63 74 20 68 65 61  |ndard effect hea|
00000a80  64 65 72 0a 20 2e 2e 2e  0a 0a 52 61 6e 64 6f 6d  |der. .....Random|
00000a90  20 72 6f 75 74 69 6e 65  0a 7e 7e 7e 7e 7e 7e 7e  | routine.~~~~~~~|
00000aa0  7e 7e 7e 7e 7e 7e 7e 0a  41 20 72 61 6e 64 6f 6d  |~~~~~~~.A random|
00000ab0  20 72 6f 75 74 69 6e 65  20 2d 20 66 61 69 72 6c  | routine - fairl|
00000ac0  79 20 72 61 6e 64 6f 6d  2e 20 50 72 6f 76 69 64  |y random. Provid|
00000ad0  65 73 20 61 20 66 75 6e  63 74 69 6f 6e 20 73 69  |es a function si|
00000ae0  6d 69 6c 61 72 20 74 6f  20 74 68 65 20 42 41 53  |milar to the BAS|
00000af0  49 43 0a 72 6e 64 28 29  20 63 6f 6d 6d 61 6e 64  |IC.rnd() command|
00000b00  20 2d 20 62 75 74 20 69  6e 74 65 67 65 72 73 20  | - but integers |
00000b10  6f 6e 6c 79 2e 20 54 68  65 20 76 61 6c 75 65 20  |only. The value |
00000b20  72 65 74 75 72 6e 65 64  20 69 73 20 66 72 6f 6d  |returned is from|
00000b30  20 30 20 74 6f 20 74 68  65 20 6d 61 78 0a 6e 75  | 0 to the max.nu|
00000b40  6d 62 65 72 20 73 70 65  63 69 66 69 65 64 2e 20  |mber specified. |
00000b50  30 20 61 6e 64 20 74 68  65 20 6d 61 78 20 6e 75  |0 and the max nu|
00000b60  6d 62 65 72 20 6d 61 79  20 62 65 20 72 65 74 75  |mber may be retu|
00000b70  72 6e 65 64 2e 0a 0a 45  6e 74 72 79 3a 20 72 30  |rned...Entry: r0|
00000b80  20 3d 20 6d 61 78 20 72  61 6e 64 6f 6d 20 6e 75  | = max random nu|
00000b90  6d 62 65 72 0a 45 78 69  74 3a 20 20 72 30 20 3d  |mber.Exit:  r0 =|
00000ba0  20 72 61 6e 64 6f 6d 20  6e 75 6d 62 65 72 0a 0a  | random number..|
00000bb0  44 69 76 69 73 69 6f 6e  20 72 6f 75 74 69 6e 65  |Division routine|
00000bc0  0a 7e 7e 7e 7e 7e 7e 7e  7e 7e 7e 7e 7e 7e 7e 7e  |.~~~~~~~~~~~~~~~|
00000bd0  7e 0a 54 68 69 73 20 69  73 20 61 20 66 61 73 74  |~.This is a fast|
00000be0  20 64 69 76 69 73 69 6f  6e 20 72 6f 75 74 69 6e  | division routin|
00000bf0  65 2e 20 49 74 20 77 69  6c 6c 20 61 6c 77 61 79  |e. It will alway|
00000c00  73 20 74 61 6b 65 20 74  68 65 20 73 61 6d 65 20  |s take the same |
00000c10  74 69 6d 65 20 74 6f 0a  65 78 65 63 75 74 65 2e  |time to.execute.|
00000c20  0a 0a 64 69 76 69 64 65  73 20 72 30 20 62 79 20  |..divides r0 by |
00000c30  72 31 20 0a 72 65 74 75  72 6e 73 20 72 32 20 3d  |r1 .returns r2 =|
00000c40  20 72 65 6d 61 69 6e 64  65 72 0a 20 20 20 20 20  | remainder.     |
00000c50  20 20 20 72 33 20 3d 20  72 65 73 75 6c 74 0a 0a  |   r3 = result..|
00000c60  0a 43 61 6c 6c 69 6e 67  20 65 66 66 65 63 74 73  |.Calling effects|
00000c70  20 66 72 6f 6d 20 65 66  66 65 63 74 73 0a 7e 7e  | from effects.~~|
00000c80  7e 7e 7e 7e 7e 7e 7e 7e  7e 7e 7e 7e 7e 7e 7e 7e  |~~~~~~~~~~~~~~~~|
00000c90  7e 7e 7e 7e 7e 7e 7e 7e  7e 7e 0a 49 74 20 69 73  |~~~~~~~~~~.It is|
00000ca0  20 70 6f 73 73 69 62 6c  65 20 74 6f 20 63 61 6c  | possible to cal|
00000cb0  6c 20 61 6e 6f 74 68 65  72 20 65 66 66 65 63 74  |l another effect|
00000cc0  20 66 72 6f 6d 20 61 6e  20 65 66 66 65 63 74 2c  | from an effect,|
00000cd0  20 61 6e 64 20 69 6e 20  73 6f 6d 65 20 63 61 73  | and in some cas|
00000ce0  65 73 20 69 74 0a 69 73  20 75 73 65 66 75 6c 20  |es it.is useful |
00000cf0  28 66 6f 72 20 65 78 61  6d 70 6c 65 20 74 68 65  |(for example the|
00000d00  20 52 6e 64 4c 6f 61 64  65 72 20 65 66 66 65 63  | RndLoader effec|
00000d10  74 73 20 73 75 70 70 6c  69 65 64 20 77 69 74 68  |ts supplied with|
00000d20  20 54 77 69 6c 69 67 68  74 29 2e 20 53 6f 6d 65  | Twilight). Some|
00000d30  0a 54 77 69 6c 69 67 68  74 20 53 57 49 73 20 61  |.Twilight SWIs a|
00000d40  72 65 20 64 6f 63 75 6d  65 6e 74 65 64 20 68 65  |re documented he|
00000d50  72 65 20 77 68 69 63 68  20 6d 61 79 20 68 65 6c  |re which may hel|
00000d60  70 2e 20 59 6f 75 20 73  68 6f 75 6c 64 20 6f 62  |p. You should ob|
00000d70  65 79 20 74 68 65 20 65  6e 74 72 79 0a 63 6f 6e  |ey the entry.con|
00000d80  64 69 74 69 6f 6e 73 20  65 78 61 63 74 6c 79 20  |ditions exactly |
00000d90  70 72 6f 76 69 64 69 6e  67 20 70 61 72 61 6d 65  |providing parame|
00000da0  74 65 72 20 62 6c 6f 63  6b 73 20 61 6e 64 20 77  |ter blocks and w|
00000db0  6f 72 6b 73 70 61 63 65  2e 20 42 65 20 63 61 72  |orkspace. Be car|
00000dc0  65 66 75 6c 2e 2e 0a 0a  54 77 69 6c 69 67 68 74  |eful....Twilight|
00000dd0  5f 4e 45 66 66 65 63 74  73 0a 45 6e 74 72 79 20  |_NEffects.Entry |
00000de0  2d 0a 45 78 69 74 20 20  72 31 20 3d 20 6e 75 6d  |-.Exit  r1 = num|
00000df0  62 65 72 20 6f 66 20 65  66 66 65 63 74 73 20 63  |ber of effects c|
00000e00  75 72 72 65 6e 74 6c 79  20 6c 6f 61 64 65 64 0a  |urrently loaded.|
00000e10  0a 43 6f 75 6e 74 73 20  68 6f 77 20 6d 61 6e 79  |.Counts how many|
00000e20  20 65 66 66 65 63 74 73  20 61 72 65 20 63 75 72  | effects are cur|
00000e30  72 65 6e 74 6c 79 20 6c  6f 61 64 65 64 2e 0a 0a  |rently loaded...|
00000e40  0a 54 77 69 6c 69 67 68  74 5f 47 65 74 45 66 66  |.Twilight_GetEff|
00000e50  65 63 74 48 65 61 64 65  72 0a 45 6e 74 72 79 20  |ectHeader.Entry |
00000e60  72 30 20 3d 20 65 66 66  65 63 74 20 6e 61 6d 65  |r0 = effect name|
00000e70  0a 45 78 69 74 20 20 72  31 20 3d 20 70 6f 69 6e  |.Exit  r1 = poin|
00000e80  74 65 72 20 74 6f 20 65  66 66 65 63 74 20 68 65  |ter to effect he|
00000e90  61 64 65 72 0a 0a 47 65  74 73 20 61 20 70 6f 69  |ader..Gets a poi|
00000ea0  6e 74 65 72 20 74 6f 20  74 68 65 20 68 65 61 64  |nter to the head|
00000eb0  65 72 20 6f 66 20 61 6e  20 65 66 66 65 63 74 2e  |er of an effect.|
00000ec0  20 30 20 69 73 20 72 65  74 75 72 6e 65 64 20 69  | 0 is returned i|
00000ed0  66 20 69 74 20 63 61 6e  6e 6f 74 20 62 65 0a 66  |f it cannot be.f|
00000ee0  6f 75 6e 64 2e 20 53 70  65 63 69 61 6c 20 76 61  |ound. Special va|
00000ef0  6c 75 65 73 20 66 6f 72  20 74 68 65 20 65 66 66  |lues for the eff|
00000f00  65 63 74 20 6e 61 6d 65  20 61 72 65 3a 0a 20 20  |ect name are:.  |
00000f10  2d 31 20 63 75 72 72 65  6e 74 6c 79 20 73 65 6c  |-1 currently sel|
00000f20  65 63 74 65 64 20 65 66  66 65 63 74 2e 0a 0a 0a  |ected effect....|
00000f30  54 77 69 6c 69 67 68 74  5f 45 6e 76 69 72 6f 6e  |Twilight_Environ|
00000f40  6d 65 6e 74 42 6c 6f 63  6b 0a 45 6e 74 72 79 20  |mentBlock.Entry |
00000f50  2d 0a 45 78 69 74 20 20  72 31 20 3d 20 70 6f 69  |-.Exit  r1 = poi|
00000f60  6e 74 65 72 20 74 6f 20  65 6e 76 69 72 6f 6e 6d  |nter to environm|
00000f70  65 6e 74 20 62 6c 6f 63  6b 0a 0a 47 65 74 73 20  |ent block..Gets |
00000f80  74 68 65 20 70 6f 69 6e  74 65 72 20 74 6f 20 74  |the pointer to t|
00000f90  68 65 20 63 75 72 72 65  6e 74 20 65 6e 76 69 72  |he current envir|
00000fa0  6f 6e 6d 65 6e 74 20 62  6c 6f 63 6b 2e 0a 4e 6f  |onment block..No|
00000fb0  74 65 3a 20 72 6f 75 74  69 6e 65 73 20 63 61 6e  |te: routines can|
00000fc0  20 6f 6e 6c 79 20 62 65  20 63 61 6c 6c 65 64 20  | only be called |
00000fd0  66 72 6f 6d 20 65 66 66  65 63 74 73 2e 0a 0a     |from effects...|
00000fdf