home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 3
/
TheARMClub_PDCD3.iso
/
hensa
/
screensav
/
alphasave_2
/
Program
/
ProgHelp
Wrap
Text File
|
1998-07-22
|
16KB
|
430 lines
_ ___ _ _
/\ \ \ \ \ \ \_\ \ /\ ££££ ££ £ £ ££££
/ \ \ \ \ _\ \ _ \ / \ £ £ £ £ £ £ Version
/ __ \ \ \__ \ \ \ \ \ \/ __ \ ££££ ££££ £ £ ££££ 1.25
/_/ \_\ \___\ \_\ \_\ \_\/ \_\ £ £ £ £ £ £
__________________________________ ££££ £ £ £ ££££
-------------- How to Program your Own!! ---------------
________________________________________________________
by Marc Warne of Alpha Programming
------------------------------------------------------------------------------
Introduction
••••••••••••
All screensavers have to, in some way or another, communicate with AlphaSave.
This could range from simply telling AlphaSave when the screensaver has quit, up
to finding out who AlphaSave is registered to and what parameters have been set.
Please note that programming a screensaver should only be done if sufficient
knowledge of programming is available.
Types of screensavers
~~~~~~~~~~~~~~~~~~~~~
Essentially, there are two types of screensavers. The first is a normal, multi-
tasking screensaver. The other is a single-tasking screensaver. Single-tasking
screensavers are now obsolete, so this manual describes how to program a multi-
tasking screensaver.
Examples
~~~~~~~~
There are two simple example screensavers included - !DemoSave and !DemoSave2.
!DemoSave is a multi-tasking screensaver. The !RunImage file within both of
these programs may be used within your own screensavers, even if you intend to
sell them.
------------------------------------------------------------------------------
Program Resources
•••••••••••••••••
In the program directory, !DemoSave can be used as a shell screensaver. Some of
the files, such as !Run will need to be edited, as will the !RunImage file.
Also included are various sprite files for the screensaver. Although you do not
have to stick to these, most other screensavers have the same background for the
icon sprite.
The 'Data' file
~~~~~~~~~~~~~~~
A file called 'Data' should be present inside all screensavers.
This file has information on the screensaver, including:
- What type of screensaver it is
(Multi-tasking or single-tasking)
- What parameters should be passed to it
- How the configuration window should look
- Who wrote it
- A short description of it
- When it was written
This file must be present in all screensavers you create, otherwise they will
not function properly.
!ASMessage
~~~~~~~~~~
This is a simple BASIC program which shows you how to use the AlphaSave message
system. It displays whether AlphaSave is loaded, its version, whether it's
registered, who it's registered to and the key code and date.
------------------------------------------------------------------------------
Icon Maker
••••••••••
If you are making your screensaver configurable by the user (i.e. it can be
configured using the screensaver config window in SaveConf), you must open the
'Icon List' and 'Icon Maker' windows by moving over to 'Saver Creation' from
the icon bar.
Up to 16 icons can be created. Each icon can either be a label (descriptive text
without a border), text (with an indented border - r2 border), writable (where
the user can enter text/ numbers - r7 border), option (tick box) or radio (a
choice of options).
Types of icons
~~~~~~~~~~~~~~
Labels and text are fairly self-explanatory. The text you wish to appear is
entered in the writable box at the bottom of the icon maker window. The
'H. Centered' flag sets whether the text will be centred horizontally. If it is
'Right Aligned', the text will be placed as near to the right of the window as
possible.
Writable is also fairly easy to explain. This time, the white text box at the
bottom is the descriptive text for the writable icon.
Option icons can either be on or off. When they are on, they usually have a
tick in them.
Radio icons are a bit more difficult to explain. These are like a variety of
option icons, but only one of them can be selected at any one time. The 'ESG'
stands for 'Exclusive Selection Group', and for each of these groups, only one
radio icon can be selected.
Colours
~~~~~~~
Colours can also be set for all of the icon types, except for radio. The colours
that can be chosen are the standard 16 used on the desktop. Please do not make
the icons look silly by overusing colours!
Update Information Returned
~~~~~~~~~~~~~~~~~~~~~~~~~~~
There is a button at the bottom of the Icon List window titled 'Update'. If
this is clicked upon, it will display the type of parameter information which
will be sent to the screensaver when it is loaded by AlphaSave. If there are
any suitable icons, then the result will look something like:
{T 3}{S 4}{S 5}{S 6}
In this case, whatever is placed in the writable icon number 3 will be sent as
the first parameter, and '0's or '1's (depending on whether the icon has been
selected or not) sent as parameters 2, 3 and 4.
For example, let's say that the text entered by the user in icon number 3 was
'FishBang', icons 4 and 5 were selected and icon 6 was not, the returned string
would be:
{FishBang}{1}{1}{0}
Hopefully that will make sense. If it doesn't, feel free to contact me.
------------------------------------------------------------------------------
Programming Screensavers
••••••••••••••••••••••••
The following tutorial will tell you how to make the more up-to-date
multitasking screensavers.
Step 1: Creating the screensaver directory
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
First of all, you must create your screensaver directory. It is probably best
to copy !DemoSave as another name. It is best to choose a name which roughly
describes what the screensaver does (eg. !Rain, !Mirror). Try to make it a
different name from those already supplied, and 10 characters or less in length.
Step 2: Screensaver resources
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It would be advisable to change the iconsprite of your screensaver. You may
also wish to edit the !Run and !Boot files. If you wish, you can also add a
!Help file.
Step 3: The 'Data' file (Icon Creator)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
First of all, you must open the 'Detail Files' window. This i done by clicking
menu over the SaveConf icon on the icon bar, moving over to 'Saver Creation'
and then 'Detail Files/Save'. Here, you can set details on your screensaver,
including the name, author's name, date and a brief description. You must also
make sure that 'WIMP Program' is selected so AlphaSave knows you are making a
multitasking program.
If you are making your screensaver configurable by the user (i.e. it can be
configured using the screensaver config window in SaveConf), see the Icon Maker
section file for more information.
Step 4: The actual programming
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following will describe how the !DemoSave screensaver works.
Load the example screensaver. This is a fully working screensaver, which always
changes picture. When you move/ click the mouse or press a button on the
keyboard, the screensaver will exit. This is what all screensavers should do.
Now I will describe how the !RunImage file works:
SYS"OS_GetEnv" TO addr$
This just gets what parameters were sent to the screensaver, and stores them
as addr$
opt1%=VAL(FNgetquotes(addr$,1))
This gets the setting for the first paremeter sent. As this is a selectable
icon (ie. not a writable icon), the value can either be 1 or 0. If opt1%=1
then it was selected, otherwise opt1%=0.
null$=FNgetquotes(addr$,4)
This gets the string sent in the fourth parameter and stores it in null$.
This string must have come from a writable icon.
The parameters sent could look something like this:
{1}{0}{0}{FishBang}
opt1%=1, opt2%=0, opt3%=0, null$="FishBang"
PROCinitscrsave
This procedure initialises the screensaver. If you look in
DEF PROCinitscrsave, you will see that it creates some arrays, sets some
default variables, starts the task, changes the mode, turns the pointer off
and opens a window.
This window that is opened can either be a black window, or a blank window.
If the screensaver changes mode and requires a black background, you must use
PROCloadtemplate("black"). If the screensaver will do something to change the
current desktop appearence (eg. !Mirror), then PROCloadtemplate("blank")
should be used.
PROCscrvars finds out about the current screen mode. When this is called,
xscreen% is the width of the screen, yscreen% is the height of the screen,
and res% is the resolution of the screen. This must be called before the
blank window is opened because the blank window must fill up the entire
screen.
ON ERROR PROCerror
If an error occurs while the screensaver is active, PROCerror will be called.
This should send a message to AlphaSave saying that the screensaver has quit,
tell the user the error and quit the screensaver.
REPEAT
PROCscreensave
...
UNTIL FALSE
This is the main loop the screensaver goes into. PROCscreensave should be
called often so it will allow other multitasking programs to do their tasks.
Usually, there will be a graphical effect happening in this loop to make the
screensaver look appealing.
Other supplied procedures
~~~~~~~~~~~~~~~~~~~~~~~~~
PROCfont
To plot a font, use PROCfont(foreground,background,x,y,font$,text$,fontsize).
'foreground' is the foreground colour and 'background' is the background
colour used for anti- aliasing. An example would be:
PROCfont(9,7,160,RND(800),"Corpus.Bold","DEMO",170)
This would plot a yellow Corpus.Bold font, anti-aliased to black at
co-ordinates x=150 and y=RND(800), with the text "DEMO" and at size 170pt.
PROCwait(time)
This procedure waits for a given amount of time PROCwait(150) will wait for
150cs, or 1.5 seconds.
PROCcheckmove
This procedure must be called as often as possible. It checks whether the
mouse has moved, been clicked upon or a keyboard button has been pressed. If
it has, the program will call PROCend, which will end it.
PROCwimp
This polls the WIMP
PROCloadtemplate(tempname$)
This loads a template and stores the details in block%
PROCopenwindow(block%,win%)
This opens a window
PROCsendmessage
This broadcasts a WIMP message. PROCsendmessage(&4D845,0) is needed in
PROCend to tell AlphaSave that the screensaver has finished. This is
*essential* in order for AlphaSave to work.
The rules of screensaving
~~~~~~~~~~~~~~~~~~~~~~~~~
1. There must never be the same picture on the screen for a long period of time
2. When you move the mouse or press a key, the screensaver must exit immediately
Step 5: The 'Defaults' file.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When your screensaver is installed, or the 'defaults' icon is pressed, all
options will be off and writable icons empty by default. This can be changed
by using a defaults file.
This is a text file in your screensaver directory. The first line of this file
will be the default setting for the first icon, the second line for the second
icon and so on.
If one of the icons is an option or radio icon, a value of '1' means it will
be on by default, and '0' for off. For a writable icon, this will be the
default text in the icon. If the icon cannot be set, eg. a label, it should
have a value of '0' in the defaults file.
------------------------------------------------------------------------------
Technical Details (not necessary for screensavers)
•••••••••••••••••
AlphaSave Message Block
~~~~~~~~~~~~~~~~~~~~~~~
Message block is &4D840 - This is an official Acorn reserved message block.
------------------------------------------------------------------------------
Message_AlphaSaveAlive (&4D840)
Checks whether AlphaSave is alive
In: Nothing
------------------------------------------------------------------------------
Message_AlphaSaveIsAlive (&4D841)
Returned to say that AlphaSave is alive
Out: q%!4 = AlphaSave task
------------------------------------------------------------------------------
Message_AlphaSaveTimes (&4D842)
Sent to set the AlphaSave screensaving times.
In:
q%!20 = Number of hours
q%!24 = Number of minutes
q%!28 = Number of seconds
------------------------------------------------------------------------------
Message_AlphaSaveInfo (&4D843)
Asks about information on AlphaSave.
In:
q%!20=0 : Returns version number (see below)
q%!20=1 : Returns registered status
q%!20=2 : Returns name of person who registered (or 'UNREGISTERED')
q%!20=3 : Returns key code (or 'KS0002')
q%!20=4 : Returns key date (or 'Shareware')
q%!20=5 : Returns On/Off state (screensaving is enabled or disabled)
------------------------------------------------------------------------------
Message_AlphaSaveRecInfo (&4D844)
Returns information sent my Message_AlphaSaveInfo.
Out:
If (In q%!20=0): q%!20=Version number * 100
If (In q%!20=1): Unregistered: q%!20=0
Registered: q%!20=1
If (In q%!20=2): $(q%+20)=Name of person who registered AlphaSave
(32 Characters)
If (In q%!20=3): $(q%+20)=Key code (32 Characters)
If (In q%!20=4): $(q%+20)=Key date (32 Chatacters)
If (In q%!20=5): q%?20=On/Off state (1=On, 0=Off)
------------------------------------------------------------------------------
Message_AlphaSaveScrQuit (&4D845)
Tells AlphaSave that the screensaver is quitting and that it should
continue checking for no movements to load another screensaver.
In: Nothing
------------------------------------------------------------------------------
Message_AlphaSaveSet (&4D846)
Sets the state of AlphaSave.
In:
q%!20=0 : Disables Screensaving
q%!20=1 : Enables Screensaving
q%!20=2 : Sets up time until next Wimp_Poll
q%!24 = Number of centiseconds
q%!20=3 : Sets screensaving to 'Random'
q%!20=4 : Sets screensaving to 'Ordered'
q%!20=5 : Tells AlphaSave to reload the configuration (1.25+ only)
------------------------------------------------------------------------------
Message_AlphaSaveUtils (&4D847)
Allow screensavers to change certain features of AlphaSave
In:
q%!20=0 : Load new screensaver
------------------------------------------------------------------------------
Message_AlphaSaveDied (&4D847)
Broadcasted to say that AlphaSave is dying
------------------------------------------------------------------------------
Message_AlphaSaveCantScreensave (&4D848)
Broadcasted to say that the current screensaver cannot be run (could be
due to a low-res monitor etc.) and AlphaSave should load another
screensaver
In:
$(q%+20) : Reason why screensaver could not operate
------------------------------------------------------------------------------
Message_AlphaSaveForced (&4D849)
Broadcasted to AlphaSave to say that the next screensaver to be loaded
is loaded from SaveConf. This stops Message_AlphaSaveCantScreensave from
loading another screensaver and displays the reason why the screensaver
could not load. It is reset by Message_AlphaSaveScrQuit.
------------------------------------------------------------------------------
Please do not abuse any of these WIMP Messages in any way.
-------------------------------------------------- © 1998 Alpha Programming --