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

Twilight/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-02.adf » PD
Filename: Twilight/Entry
Read OK:
File size: 10D2 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


Stack
~~~~~
In all entrys, R13 is a full descending stack. There will be at least 256
bytes of stack available. If you call another effect, it might be a good
idea to use your own stack.

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 parameters 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. Do not use any other
Twilight SWIs as their entry and exit parameters may not be the same in
future versions. 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.

Do not disemble the RndLoader effect to find out how it works as it makes
use of an undefined interface with Twilight.

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 53 74  61 63 6b 0a 7e 7e 7e 7e  |ock...Stack.~~~~|
00000610  7e 0a 49 6e 20 61 6c 6c  20 65 6e 74 72 79 73 2c  |~.In all entrys,|
00000620  20 52 31 33 20 69 73 20  61 20 66 75 6c 6c 20 64  | R13 is a full d|
00000630  65 73 63 65 6e 64 69 6e  67 20 73 74 61 63 6b 2e  |escending stack.|
00000640  20 54 68 65 72 65 20 77  69 6c 6c 20 62 65 20 61  | There will be a|
00000650  74 20 6c 65 61 73 74 20  32 35 36 0a 62 79 74 65  |t least 256.byte|
00000660  73 20 6f 66 20 73 74 61  63 6b 20 61 76 61 69 6c  |s of stack avail|
00000670  61 62 6c 65 2e 20 49 66  20 79 6f 75 20 63 61 6c  |able. If you cal|
00000680  6c 20 61 6e 6f 74 68 65  72 20 65 66 66 65 63 74  |l another effect|
00000690  2c 20 69 74 20 6d 69 67  68 74 20 62 65 20 61 20  |, it might be a |
000006a0  67 6f 6f 64 0a 69 64 65  61 20 74 6f 20 75 73 65  |good.idea to use|
000006b0  20 79 6f 75 72 20 6f 77  6e 20 73 74 61 63 6b 2e  | your own stack.|
000006c0  0a 0a 50 72 6f 63 65 73  73 6f 72 20 6d 6f 64 65  |..Processor mode|
000006d0  73 0a 7e 7e 7e 7e 7e 7e  7e 7e 7e 7e 7e 7e 7e 7e  |s.~~~~~~~~~~~~~~|
000006e0  7e 0a 45 66 66 65 63 74  73 20 6d 75 73 74 20 62  |~.Effects must b|
000006f0  65 20 61 62 6c 65 20 74  6f 20 62 65 20 63 61 6c  |e able to be cal|
00000700  6c 65 64 20 69 6e 20 62  6f 74 68 20 55 73 65 72  |led in both User|
00000710  20 61 6e 64 20 53 56 43  20 6d 6f 64 65 73 2e 20  | and SVC modes. |
00000720  44 6f 6e 27 74 20 77 6f  72 72 79 0a 61 62 6f 75  |Don't worry.abou|
00000730  74 20 74 68 69 73 20 2d  20 6a 75 73 74 20 77 72  |t this - just wr|
00000740  69 74 65 20 74 68 65 20  63 6f 64 65 20 66 6f 72  |ite the code for|
00000750  20 53 56 43 20 6d 6f 64  65 20 61 6e 64 20 69 74  | SVC mode and it|
00000760  20 77 69 6c 6c 20 77 6f  72 6b 20 69 6e 20 75 73  | will work in us|
00000770  65 72 20 6d 6f 64 65 2e  0a 0a 0a 45 72 72 6f 72  |er mode....Error|
00000780  73 0a 7e 7e 7e 7e 7e 7e  0a 45 72 72 6f 72 20 73  |s.~~~~~~.Error s|
00000790  68 6f 75 6c 64 20 62 65  20 72 65 74 75 72 6e 65  |hould be returne|
000007a0  64 20 69 6e 20 74 68 65  20 6e 6f 72 6d 61 6c 20  |d in the normal |
000007b0  77 61 79 20 28 73 65 74  20 76 20 66 6c 61 67 2c  |way (set v flag,|
000007c0  20 72 30 20 70 6f 69 6e  74 73 20 74 6f 20 65 72  | r0 points to er|
000007d0  72 6f 72 0a 62 6c 6f 63  6b 29 2e 20 49 66 20 61  |ror.block). If a|
000007e0  6e 20 65 72 72 6f 72 20  6f 63 63 75 72 73 20 69  |n error occurs i|
000007f0  6e 20 74 68 65 20 70 6f  6c 6c 20 65 6e 74 72 79  |n the poll entry|
00000800  2c 20 74 68 65 20 66 69  6e 61 6c 69 73 65 20 65  |, the finalise e|
00000810  6e 74 72 79 20 77 69 6c  6c 20 62 65 0a 63 61 6c  |ntry will be.cal|
00000820  6c 65 64 2c 20 62 75 74  20 69 74 20 77 69 6c 6c  |led, but it will|
00000830  20 6e 6f 74 20 69 66 20  74 68 65 20 65 72 72 6f  | not if the erro|
00000840  72 20 77 61 73 20 69 6e  20 74 68 65 20 69 6e 69  |r was in the ini|
00000850  74 20 6f 72 20 66 69 6e  61 6c 69 73 65 20 65 6e  |t or finalise en|
00000860  74 72 79 2e 0a 0a 0a 45  6e 76 69 72 6f 6e 6d 65  |try....Environme|
00000870  6e 74 20 62 6c 6f 63 6b  0a 7e 7e 7e 7e 7e 7e 7e  |nt block.~~~~~~~|
00000880  7e 7e 7e 7e 7e 7e 7e 7e  7e 7e 0a 65 61 63 68 20  |~~~~~~~~~~.each |
00000890  65 6e 74 72 79 20 69 73  20 61 20 77 6f 72 64 20  |entry is a word |
000008a0  6c 6f 6e 67 0a 4e 6f 74  65 3a 20 72 6f 75 74 69  |long.Note: routi|
000008b0  6e 65 73 20 63 61 6e 20  6f 6e 6c 79 20 62 65 20  |nes can only be |
000008c0  63 61 6c 6c 65 64 20 66  72 6f 6d 20 65 66 66 65  |called from effe|
000008d0  63 74 73 0a 0a 4f 66 66  73 65 74 20 4d 65 61 6e  |cts..Offset Mean|
000008e0  69 6e 67 0a 30 20 20 20  20 20 20 63 6f 6c 6f 75  |ing.0      colou|
000008f0  72 73 20 69 6e 20 6d 6f  64 65 0a 34 20 20 20 20  |rs in mode.4    |
00000900  20 20 6d 61 78 20 78 20  6f 73 20 75 6e 69 74 0a  |  max x os unit.|
00000910  38 20 20 20 20 20 20 6d  61 78 20 79 20 6f 73 20  |8      max y os |
00000920  75 6e 69 74 0a 31 32 20  20 20 20 20 61 64 64 72  |unit.12     addr|
00000930  65 73 73 20 6f 66 20 72  61 6e 64 6f 6d 20 72 6f  |ess of random ro|
00000940  75 74 69 6e 65 0a 31 36  20 20 20 20 20 61 64 64  |utine.16     add|
00000950  72 65 73 73 20 6f 66 20  64 69 76 69 73 69 6f 6e  |ress of division|
00000960  20 72 6f 75 74 69 6e 65  0a 32 30 20 20 20 20 20  | routine.20     |
00000970  62 61 73 65 20 61 64 64  72 65 73 73 20 6f 66 20  |base address of |
00000980  73 63 72 65 65 6e 20 28  64 69 73 70 6c 61 79 20  |screen (display |
00000990  68 61 72 64 77 61 72 65  29 20 28 31 34 39 29 0a  |hardware) (149).|
000009a0  32 34 20 20 20 20 20 58  45 69 67 46 61 63 74 6f  |24     XEigFacto|
000009b0  72 20 28 34 29 0a 32 38  20 20 20 20 20 4c 69 6e  |r (4).28     Lin|
000009c0  65 4c 65 6e 67 74 68 20  28 36 29 0a 33 32 20 20  |eLength (6).32  |
000009d0  20 20 20 59 57 69 6e 64  4c 69 6d 69 74 20 28 31  |   YWindLimit (1|
000009e0  32 29 20 0a 33 36 20 20  20 20 20 53 63 72 65 65  |2) .36     Scree|
000009f0  6e 53 69 7a 65 20 28 37  29 0a 0a 4e 75 6d 62 65  |nSize (7)..Numbe|
00000a00  72 73 20 69 6e 20 62 72  61 63 6b 65 74 73 20 72  |rs in brackets r|
00000a10  65 66 65 72 20 74 6f 20  74 68 65 20 70 61 72 61  |efer to the para|
00000a20  6d 65 74 65 72 73 20 74  6f 20 4f 53 5f 52 65 61  |meters to OS_Rea|
00000a30  64 56 64 75 56 61 72 69  61 62 6c 65 73 0a 0a 0a  |dVduVariables...|
00000a40  48 6f 77 20 74 6f 20 63  61 6c 6c 20 61 20 65 6e  |How to call a en|
00000a50  76 69 72 6f 6e 6d 65 6e  74 20 62 6c 6f 63 6b 20  |vironment block |
00000a60  72 6f 75 74 69 6e 65 0a  7e 7e 7e 7e 7e 7e 7e 7e  |routine.~~~~~~~~|
00000a70  7e 7e 7e 7e 7e 7e 7e 7e  7e 7e 7e 7e 7e 7e 7e 7e  |~~~~~~~~~~~~~~~~|
00000a80  7e 7e 7e 7e 7e 7e 7e 7e  7e 7e 7e 7e 7e 7e 7e 0a  |~~~~~~~~~~~~~~~.|
00000a90  72 31 32 20 6d 75 73 74  20 62 65 20 70 72 65 73  |r12 must be pres|
00000aa0  65 72 76 65 64 20 66 6f  72 20 74 68 65 73 65 20  |erved for these |
00000ab0  63 61 6c 6c 73 20 74 6f  20 77 6f 72 6b 2e 0a 20  |calls to work.. |
00000ac0  2e 2e 2e 0a 20 4d 4f 56  20 20 20 52 31 34 2c 50  |.... MOV   R14,P|
00000ad0  43 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |C               |
00000ae0  20 3b 20 61 73 20 50 43  20 70 6f 69 6e 74 73 20  | ; as PC points |
00000af0  32 20 69 6e 73 74 72 75  63 74 69 6f 6e 73 20 61  |2 instructions a|
00000b00  68 65 61 64 0a 20 4c 44  52 20 20 20 50 43 2c 5b  |head. LDR   PC,[|
00000b10  52 31 30 2c 23 65 5f 72  61 6e 64 6f 6d 5d 20 20  |R10,#e_random]  |
00000b20  20 20 3b 20 75 73 69 6e  67 20 73 74 61 6e 64 61  |  ; using standa|
00000b30  72 64 20 65 66 66 65 63  74 20 68 65 61 64 65 72  |rd effect header|
00000b40  0a 20 2e 2e 2e 0a 0a 52  61 6e 64 6f 6d 20 72 6f  |. .....Random ro|
00000b50  75 74 69 6e 65 0a 7e 7e  7e 7e 7e 7e 7e 7e 7e 7e  |utine.~~~~~~~~~~|
00000b60  7e 7e 7e 7e 0a 41 20 72  61 6e 64 6f 6d 20 72 6f  |~~~~.A random ro|
00000b70  75 74 69 6e 65 20 2d 20  66 61 69 72 6c 79 20 72  |utine - fairly r|
00000b80  61 6e 64 6f 6d 2e 20 50  72 6f 76 69 64 65 73 20  |andom. Provides |
00000b90  61 20 66 75 6e 63 74 69  6f 6e 20 73 69 6d 69 6c  |a function simil|
00000ba0  61 72 20 74 6f 20 74 68  65 20 42 41 53 49 43 0a  |ar to the BASIC.|
00000bb0  72 6e 64 28 29 20 63 6f  6d 6d 61 6e 64 20 2d 20  |rnd() command - |
00000bc0  62 75 74 20 69 6e 74 65  67 65 72 73 20 6f 6e 6c  |but integers onl|
00000bd0  79 2e 20 54 68 65 20 76  61 6c 75 65 20 72 65 74  |y. The value ret|
00000be0  75 72 6e 65 64 20 69 73  20 66 72 6f 6d 20 30 20  |urned is from 0 |
00000bf0  74 6f 20 74 68 65 20 6d  61 78 0a 6e 75 6d 62 65  |to the max.numbe|
00000c00  72 20 73 70 65 63 69 66  69 65 64 2e 20 30 20 61  |r specified. 0 a|
00000c10  6e 64 20 74 68 65 20 6d  61 78 20 6e 75 6d 62 65  |nd the max numbe|
00000c20  72 20 6d 61 79 20 62 65  20 72 65 74 75 72 6e 65  |r may be returne|
00000c30  64 2e 0a 0a 45 6e 74 72  79 3a 20 72 30 20 3d 20  |d...Entry: r0 = |
00000c40  6d 61 78 20 72 61 6e 64  6f 6d 20 6e 75 6d 62 65  |max random numbe|
00000c50  72 0a 45 78 69 74 3a 20  20 72 30 20 3d 20 72 61  |r.Exit:  r0 = ra|
00000c60  6e 64 6f 6d 20 6e 75 6d  62 65 72 0a 0a 44 69 76  |ndom number..Div|
00000c70  69 73 69 6f 6e 20 72 6f  75 74 69 6e 65 0a 7e 7e  |ision routine.~~|
00000c80  7e 7e 7e 7e 7e 7e 7e 7e  7e 7e 7e 7e 7e 7e 0a 54  |~~~~~~~~~~~~~~.T|
00000c90  68 69 73 20 69 73 20 61  20 66 61 73 74 20 64 69  |his is a fast di|
00000ca0  76 69 73 69 6f 6e 20 72  6f 75 74 69 6e 65 2e 20  |vision routine. |
00000cb0  49 74 20 77 69 6c 6c 20  61 6c 77 61 79 73 20 74  |It will always t|
00000cc0  61 6b 65 20 74 68 65 20  73 61 6d 65 20 74 69 6d  |ake the same tim|
00000cd0  65 20 74 6f 0a 65 78 65  63 75 74 65 2e 0a 0a 64  |e to.execute...d|
00000ce0  69 76 69 64 65 73 20 72  30 20 62 79 20 72 31 20  |ivides r0 by r1 |
00000cf0  0a 72 65 74 75 72 6e 73  20 72 32 20 3d 20 72 65  |.returns r2 = re|
00000d00  6d 61 69 6e 64 65 72 0a  20 20 20 20 20 20 20 20  |mainder.        |
00000d10  72 33 20 3d 20 72 65 73  75 6c 74 0a 0a 0a 43 61  |r3 = result...Ca|
00000d20  6c 6c 69 6e 67 20 65 66  66 65 63 74 73 20 66 72  |lling effects fr|
00000d30  6f 6d 20 65 66 66 65 63  74 73 0a 7e 7e 7e 7e 7e  |om effects.~~~~~|
00000d40  7e 7e 7e 7e 7e 7e 7e 7e  7e 7e 7e 7e 7e 7e 7e 7e  |~~~~~~~~~~~~~~~~|
00000d50  7e 7e 7e 7e 7e 7e 7e 0a  49 74 20 69 73 20 70 6f  |~~~~~~~.It is po|
00000d60  73 73 69 62 6c 65 20 74  6f 20 63 61 6c 6c 20 61  |ssible to call a|
00000d70  6e 6f 74 68 65 72 20 65  66 66 65 63 74 20 66 72  |nother effect fr|
00000d80  6f 6d 20 61 6e 20 65 66  66 65 63 74 2c 20 61 6e  |om an effect, an|
00000d90  64 20 69 6e 20 73 6f 6d  65 20 63 61 73 65 73 20  |d in some cases |
00000da0  69 74 0a 69 73 20 75 73  65 66 75 6c 20 28 66 6f  |it.is useful (fo|
00000db0  72 20 65 78 61 6d 70 6c  65 20 74 68 65 20 52 6e  |r example the Rn|
00000dc0  64 4c 6f 61 64 65 72 20  65 66 66 65 63 74 73 20  |dLoader effects |
00000dd0  73 75 70 70 6c 69 65 64  20 77 69 74 68 20 54 77  |supplied with Tw|
00000de0  69 6c 69 67 68 74 29 2e  20 53 6f 6d 65 0a 54 77  |ilight). Some.Tw|
00000df0  69 6c 69 67 68 74 20 53  57 49 73 20 61 72 65 20  |ilight SWIs are |
00000e00  64 6f 63 75 6d 65 6e 74  65 64 20 68 65 72 65 20  |documented here |
00000e10  77 68 69 63 68 20 6d 61  79 20 68 65 6c 70 2e 20  |which may help. |
00000e20  44 6f 20 6e 6f 74 20 75  73 65 20 61 6e 79 20 6f  |Do not use any o|
00000e30  74 68 65 72 0a 54 77 69  6c 69 67 68 74 20 53 57  |ther.Twilight SW|
00000e40  49 73 20 61 73 20 74 68  65 69 72 20 65 6e 74 72  |Is as their entr|
00000e50  79 20 61 6e 64 20 65 78  69 74 20 70 61 72 61 6d  |y and exit param|
00000e60  65 74 65 72 73 20 6d 61  79 20 6e 6f 74 20 62 65  |eters may not be|
00000e70  20 74 68 65 20 73 61 6d  65 20 69 6e 0a 66 75 74  | the same in.fut|
00000e80  75 72 65 20 76 65 72 73  69 6f 6e 73 2e 20 59 6f  |ure versions. Yo|
00000e90  75 20 73 68 6f 75 6c 64  20 6f 62 65 79 20 74 68  |u should obey th|
00000ea0  65 20 65 6e 74 72 79 20  63 6f 6e 64 69 74 69 6f  |e entry conditio|
00000eb0  6e 73 20 65 78 61 63 74  6c 79 20 70 72 6f 76 69  |ns exactly provi|
00000ec0  64 69 6e 67 0a 70 61 72  61 6d 65 74 65 72 20 62  |ding.parameter b|
00000ed0  6c 6f 63 6b 73 20 61 6e  64 20 77 6f 72 6b 73 70  |locks and worksp|
00000ee0  61 63 65 2e 20 42 65 20  63 61 72 65 66 75 6c 2e  |ace. Be careful.|
00000ef0  2e 0a 0a 54 77 69 6c 69  67 68 74 5f 4e 45 66 66  |...Twilight_NEff|
00000f00  65 63 74 73 0a 45 6e 74  72 79 20 2d 0a 45 78 69  |ects.Entry -.Exi|
00000f10  74 20 20 72 31 20 3d 20  6e 75 6d 62 65 72 20 6f  |t  r1 = number o|
00000f20  66 20 65 66 66 65 63 74  73 20 63 75 72 72 65 6e  |f effects curren|
00000f30  74 6c 79 20 6c 6f 61 64  65 64 0a 0a 43 6f 75 6e  |tly loaded..Coun|
00000f40  74 73 20 68 6f 77 20 6d  61 6e 79 20 65 66 66 65  |ts how many effe|
00000f50  63 74 73 20 61 72 65 20  63 75 72 72 65 6e 74 6c  |cts are currentl|
00000f60  79 20 6c 6f 61 64 65 64  2e 0a 0a 0a 54 77 69 6c  |y loaded....Twil|
00000f70  69 67 68 74 5f 47 65 74  45 66 66 65 63 74 48 65  |ight_GetEffectHe|
00000f80  61 64 65 72 0a 45 6e 74  72 79 20 72 30 20 3d 20  |ader.Entry r0 = |
00000f90  65 66 66 65 63 74 20 6e  61 6d 65 0a 45 78 69 74  |effect name.Exit|
00000fa0  20 20 72 31 20 3d 20 70  6f 69 6e 74 65 72 20 74  |  r1 = pointer t|
00000fb0  6f 20 65 66 66 65 63 74  20 68 65 61 64 65 72 0a  |o effect header.|
00000fc0  0a 47 65 74 73 20 61 20  70 6f 69 6e 74 65 72 20  |.Gets a pointer |
00000fd0  74 6f 20 74 68 65 20 68  65 61 64 65 72 20 6f 66  |to the header of|
00000fe0  20 61 6e 20 65 66 66 65  63 74 2e 20 30 20 69 73  | an effect. 0 is|
00000ff0  20 72 65 74 75 72 6e 65  64 20 69 66 20 69 74 20  | returned if it |
00001000  63 61 6e 6e 6f 74 20 62  65 0a 66 6f 75 6e 64 2e  |cannot be.found.|
00001010  20 53 70 65 63 69 61 6c  20 76 61 6c 75 65 73 20  | Special values |
00001020  66 6f 72 20 74 68 65 20  65 66 66 65 63 74 20 6e  |for the effect n|
00001030  61 6d 65 20 61 72 65 3a  0a 20 20 2d 31 20 63 75  |ame are:.  -1 cu|
00001040  72 72 65 6e 74 6c 79 20  73 65 6c 65 63 74 65 64  |rrently selected|
00001050  20 65 66 66 65 63 74 2e  0a 0a 44 6f 20 6e 6f 74  | effect...Do not|
00001060  20 64 69 73 65 6d 62 6c  65 20 74 68 65 20 52 6e  | disemble the Rn|
00001070  64 4c 6f 61 64 65 72 20  65 66 66 65 63 74 20 74  |dLoader effect t|
00001080  6f 20 66 69 6e 64 20 6f  75 74 20 68 6f 77 20 69  |o find out how i|
00001090  74 20 77 6f 72 6b 73 20  61 73 20 69 74 20 6d 61  |t works as it ma|
000010a0  6b 65 73 0a 75 73 65 20  6f 66 20 61 6e 20 75 6e  |kes.use of an un|
000010b0  64 65 66 69 6e 65 64 20  69 6e 74 65 72 66 61 63  |defined interfac|
000010c0  65 20 77 69 74 68 20 54  77 69 6c 69 67 68 74 2e  |e with Twilight.|
000010d0  0a 0a                                             |..|
000010d2