home *** CD-ROM | disk | FTP | other *** search
- Documentation for VDU Saver Module V2.04
- ----------------------------------------
-
- ********************** Incredibly boring Copyright Notice *********************
- * *
- * All program code is the exclusive copyright of Richard K. Lloyd. *
- * The program (source and binary) and documentation for VDU Saver are *
- * freely distributable *
- * *
- *******************************************************************************
-
- Version V2.02 onwards
- ---------------------
- Due to the sterling work of people like Philip Colmer of Acorn, I have decided
- to make the source code of the VDU Saver publicly available. It's not a
- fantastic example of ARM code programming by any means, but it provides some
- useful tips (such as how to call lots of OS routines from inside interrupts
- with the minimum of fuss). Please, please, please report any bugs or improve-
- ments to the address at the bottom of this document - I will *not* support
- 'hacked' versions that I don't know about.
-
- Installing VDU Saver (Now requires RISC OS)
- -------------------------------------------
-
- Because VDU Saver is a relocatable module, you can install it by typing
- *VDUSaver, assuming that you have sufficient RMA available and the filetype
- is set to Module. To activate it once it is installed, type *VDUSaver [params].
- This * command is explained in greater detail later in this document.
-
- So what does VDU Saver do ?
- ---------------------------
-
- Acorn standard 14" monitors have a tendency to 'snap' occasionally (actually,
- the blame lies with Philips, but that's another story). Why this happens is
- beyond my limited electronic know-how (I'm of the 'bash-it-and-see' school of
- thinking), but I personally blame bright colours on the screen for prolonged
- periods of time (not a game, honest !).
-
- This is where VDU Saver comes in. It is a relocatable module that sits in
- the background waiting for a specified period of non-activity. When this
- occurs, the current palette is saved and all logical colours in the current
- MODE are set to black, the mouse pointer is saved and the border is set to
- black.
-
- A 'Smiley' face bounces around the screen to indicate that the screen has been
- blacked. This looks more impressive in the 320*256 MODEs (e.g. MODE 1) because
- the face appears circular rather than elliptical !
-
- Instead of a 'Smiley' face, the current time in 24-hour clock format can be
- displayed instead. See the *Configure SaverType command and the Technical
- Details section.
-
- VDU Saver now works in all screen MODEs including the 256-colour and teletext
- MODEs. In 256-colour MODEs, the border colour will 'throb' in varying
- intensities of the RGB colour specified when the *VDUSaver command was issued.
-
- You can, if you wish, control the speed of the Smiley face or time, its colour
- and whether or not the screen is restored on VDU output.
-
- The palette, border and mouse pointer are all restored on any key event (yes,
- that includes SHIFT, Alt etc...), mouse movement, mouse button press or
- (optionally) VDU output.
-
- *Help VDUSaver will give you plenty of on-line help - in fact all of the
- following command descriptions are available via *Help.
-
- The *VDUSaver command
- ---------------------
-
- Syntax: *VDUSaver [<Minutes>] [<Speed>] [<Type>] [<VDUTrap>]
- [<Red>] [<Green>] [<Blue>]
-
- The (optional) parameters have the following meaning:
-
- <Minutes> Minutes (1-63) of inactivity before activation.
- A value of 0 will completely disable VDUSaver.
- If omitted, then the *Configure SaverDelay value is used.
-
- <Speed> Speed of Smiley face (1 = slowest, 3 = fastest).
- A value of 0 will plot the Smiley face randomly.
- If omitted, then the *Configure SaverSpeed value is used.
-
- <Type> What type of mouse shape will be plotted.
- 0 will always plot the (now infamous) Smiley face.
- 1 will plot the current time in 24-hour format.
- If omitted, then the *Configure SaverType value is used.
-
- <VDUTrap> Signifies if VDU output will restore the screen.
- 0 will ignore VDU output, 1 will restore the screen on VDU output.
- If omitted, then the *Configure SaverTrap value is used.
- V1.03 onwards now recognises MODE changes as a screen restoration
- by the OS, even when VDUTrap = 0.
-
- <R> <G> <B> Quantities of RGB in the Smiley face.
- 0 0 0 gives black (invisible) and 3 3 3 gives white.
- If any omitted, then the *Configure SaverRGB values are used.
-
- The *VDUStatus Command *NEW TO V2.03*
- ----------------------
-
- Syntax: *VDUStatus
-
- Because *Status only reveals the VDU Saver CMOS RAM (i.e. permanent) settings,
- I decided to supplement this with a command that shows BOTH the currently
- active settings supplied with *VDUSaver and the *Configure ones. The current
- settings obviously cannot be shown until an activating *VDUSaver command is
- issued, so "Inactive" is displayed in the Current column until such a command
- occurs.
-
- The *Configure SaverDelay Command
- ---------------------------------
-
- Syntax: *Configure SaverDelay <Minutes>
-
- This command alters the permanent SaverDelay value (saved to CMOS RAM byte 35).
- <Minutes> should be an integer value between 1 and 63. A value of 0 is NOT
- permitted and if your CMOS RAM is set to that value, VDUSaver will force it
- to a more sensible value of 15 (minutes).
-
- The *Configure SaverSpeed Command
- ---------------------------------
-
- Syntax: *Configure SaverSpeed <Speed>
-
- This command alters the permanent SaverSpeed value (saved to CMOS RAM byte 36).
- <Speed> should be an integer value between 0 and 3.
-
- The *Configure SaverType Command
- --------------------------------
-
- Syntax: *Configure SaverType <Type>
-
- This command alters the permanent SaverType value (saved to CMOS RAM byte 35).
- <Type> should be either 0 or 1.
-
- The *Configure SaverTrap Command
- --------------------------------
-
- Syntax: *Configure SaverTrap <VDUTrap>
-
- This command alters the permanent SaverTrap value (saved to CMOS RAM byte 35).
- <VDUTrap> should be either 0 or 1.
-
- The *Configure SaverRGB Command
- -------------------------------
-
- Syntax: *Configure SaverRGB <Red> <Green> <Blue>
-
- This command alters the permanent SaverRGB values (saved to CMOS RAM byte 36).
- <Red>, <Green>, <Blue> should be integer values between 0 and 3.
-
- Some Tips whilst using VDU Saver
- --------------------------------
-
- 1. I've just noticed that moving the pointer over various areas of the icon bar
- causes the VDU Saver to stop working. Further investigation has shown that
- that VDU output occurs ! Hence, people may prefer to set VDUTrap to 0 if
- they spend most of their time in the Desktop.
-
- 2. When SaverType is 1, the mouse shape is defined once a minute when the
- screen is blanked - this causes a 'glitch' if SaverSpeed is non-zero due to
- the lengthy time OS_Word 21 (param 0) takes to execute. Hence, I recommend
- a setting of SaverSpeed 0 (randomly plot) when SaverType is set to 1.
-
- 3. For those of you who have dead batteries or faulty clocks (mine falls into
- the latter), DON'T PANIC ! The program has been written so that it only
- reads the current time ONCE each time the screen is blanked. Minute updates
- are achieved by using an internal counter - this may eventually lead to
- slight inaccuracies over a long period of time.
-
- Technical Details of VDU Saver
- ------------------------------
-
- Initially, I tried to use OS_CallAfter and OS_RemoveTickerEvent, but these
- seemed to carry on regardless (maybe they don't work in SVC Mode 3 ?). I
- ended up using a simple decrementing counter inside a Vsync event routine.
-
- I now blank the screen in two possible ways, depending on the MODE :
-
- 1. Non-Teletext/256-colour MODEs
- -----------------------------
-
- The number of logical colours is found using the NColour (3) value supplied
- to OS_ReadVduVariables. It is assumed that it will be a maximum of 15 in
- this case. The palette is read and stored in a (logical colours+2)*4-byte
- area. The extra 8 bytes are for the border colour and mouse logical colour
- 1 in case you're wondering. In the same loop, each colour is set to black
- after its original colour is safely stored. I now use OS_RemoveCursors and
- OS_RestoreCursors to make sure the cursor doesn't remain.
-
- 2. Teletext (currently only MODE 7) and 256-colour MODEs
- -----------------------------------------------------
-
- This is the case when bit 1 of ModeFlags (0) is set to indicate teletext or
- when NColour (3) is set to 63. Less work has to be done here, because the
- ONLY KNOWN WAY to blank/restore the screen in these MODEs is to use the
- following bit of code (of course, I do the ARM equivalent...) :
-
- SYS "OS_UpdateMEMC",&300,&700 TO oldval : blanks the screen
- SYS "OS_UpdateMEMC",oldval,&700 : restores it.
- Thanks to Tolli's Blanker (available on SID) for this information.
-
- Annoyingly, the mouse also gets blanked - hence there is no 'Smiley' face
- or time in these MODEs. The only palette saves/restores that still have to
- be done are the border colour and the background colour (0), the latter of
- which I forgot to do in V1.03 ! For V2.01 onwards, I've added a 'throbbing'
- border colour to at least indicate that something is going on. This cycles
- up and down the palette according to the SaverRGB values specified.
-
- The 'Smiley' face is simply mouse pointer shape 2 (the system usually uses
- shape 1) re-programmed and using colour 1 set to the SaverRGB values * &50.
-
- The following vectors are trapped to avoid mouse shape change during blanking:
- * OS_Byte vector to check for *FX 106,<value>.
- The value is stored (but NOT executed to prevent shape change) and then used,
- when the screen is restored, to restore the new pointer shape number.
- * OS_Word vector to check for OS_Word 12 (write palette) for physical colour
- 25 (mouse). Again, this is saved and restored later on.
-
- Oh, by the way, there's no call to read the current mouse shape (its pixel
- pattern in other words), so shape 2 is overwritten I'm afraid.
-
- *NEW TO V2.03*
- Also missing is a call to find the current mouse rectangle bounds, so I have to
- set them to ( 0 , 0 ) - ( X , Y ) where:
- X = ( XWindLimit << XEigFactor ) and } As read by
- Y = ( ( YWindLimit - 12 ) << YEigFactor ) } OS_ReadVduVariables
-
- When the screen is blanked, the WrchV (restore screen on any VDU output) and
- EventV (restore on Event 10 - Mouse Button pressed - or 11 - Key pressed)
- vectors reactivate the screen. OS_Mouse is also checked to see if the mouse
- position has changed. If it has, the screen is restored.
-
- The Service Call &46 (Mode Change) is now recognised so as to permit a MODE
- change to be a valid screen restoration (by the OS rather than VDU Saver).
- This is independent of the VDUTrap setting or screen MODE.
-
- The new 24-hour clock feature isn't as easy as it sounds because I've specially
- defined the digits 0 to 9 and the string "TIME" as mouse shape data. I call
- OS_Word 14 (param 1) to get the current time in BCD. I do some shifting and
- use the value of the digits to get the offset into the data, which is poked
- into the mouse shape definition.
-
- V2.00 onwards now uses CMOS RAM in the following way:
-
- +---------+-------+-------+-------+-------+-------+-------+-------+-------+
- | Bits: | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
- +---------+-------+-------+-------+-------+-------+-------+-------+-------+
- | Byte 35 |<Trap->|<Type->|<--------------- SaverDelay ---------------->|
- +---------+-------+-------+-------+-------+-------+-------+-------+-------+
- | Byte 36 |<--- Blue ---->|<--- Green --->|<---- Red ---->|<-SaverSpeed-->|
- +---------+-------+-------+-------+-------+-------+-------+-------+-------+
-
- CPU utilisation *UPDATED FOR RISC OS*
- ---------------
-
- Someone enquired about the amount of CPU time used when the VDU Saver was
- active. Here's some (crude, but effective) benchmarks done on my A310 running
- BASIC 1.04 and RISC OS 2.00 :
-
- VDUTrap? Inactive Active Diff Slower
- 10 MODE 0:TIME=0
- 20 FOR A%=1 TO 4000000:NEXT Irrelevant 58.99s 59.06s 00.07s 00.12%
- 30 PRINT TIME/100
-
- 10 MODE 0:TIME=0 Yes 51.32s 61.40s 10.08s 19.64%
- 20 FOR A%=1 TO 300000:PRINT"*";:NEXT No 51.32s 51.38s 00.06s 00.12%
- 30 PRINT TIME/100
-
- As you can see, there is a hefty CPU grab (nearly one-fifth) if continuous
- VDU output occurs when the VDU Saver is active and the VDUTrap is switched on.
- This would seem to indicate that claiming WriteCV (but not doing much) appears
- to be a no-no if you want fast VDU output - blame Acorn, not me !
-
- In normal situations, however, the CPU grab will be well under 1%, so there is
- no need to panic at the alarming 19.64% figure (yes, I was shocked at this
- too)...
-
- The code in V2.00 onwards has been extensively re-organised to use the minimum
- amount of CPU time when the module is loaded and either active or inactive.
- Previous versions would actually use up CPU time as soon as the module was
- loaded ! In particular, V2.00 onwards does not claim any vectors or enable
- events until a *VDUSaver command is issued.
-
- Revision History of VDU Saver
- -----------------------------
-
- Version 2.04
- ------------
-
- * Y-coord fix to bug introduced in 2.03.
-
- * Changed key scanning code to use Event 2.
-
- Version 2.03
- ------------
-
- * A new *VDUStatus command has been added so that users can check what values
- they've just supplied to the latest *VDUSaver command.
-
- * To tie in with the new command, a soft reset now performs the equivalent
- of a *VDUSaver 0 command so that *VDUStatus will report the correct status
- (Inactive) rather than the last active values.
-
- * Used OS_ReadVduVariables to find the MODE-independent mouse rectangle, so
- those people with hi-res B&W monitors should (hopefully...anyone care to
- test this ?) have a proper rectangle.
-
- * Due to above change, support for Arthur 1.20 has now been dropped. RISC OS
- has been generally available for more than 6 months now, so there's no
- excuse (and you can now readily order the new PRM's too - I've got mine).
-
- Version 2.02
- ------------
-
- * Prevented the mouse shape number (2) used by VDU Saver from changing during
- screen blanking (but still changes to requested shape number on screen
- restoration). Ditto for mouse colour 1 (for OS_Word 12 calls only).
-
- * The check for 0 delay value in CMOS RAM was not working correctly. Although
- the value of 15 (minutes) would be used (and shown in *Status), a faulty
- MOVEQS instruction meant that the actual CMOS RAM would not be forced to the
- value of 15. This has been fixed.
-
- * Slightly changed the random number seeding routine.
-
- Version 2.01
- ------------
-
- * Philip Colmer (of Acorn no less) spotted a bug:
- V2.00 would incorrectly restore the palette in 256-colour MODEs. In fact,
- everything started turning green (mouldy old programming perhaps ?)...
- Investigation revealed that I'd moved two statements further down in the
- code, but the first of them, MOV R2,#0, should have remained where it was.
- *BUG FIXED WITH VAPONA FLY SPRAY*
-
- * Philip also put forward the suggestion that the user should see something
- happening in the 256-colour MODEs e.g. the border colour should change.
- I implemented his suggestion - I hope nobody objects too much. He also
- hinted at the possibility of VDU Saver appearing on SID...fingers crossed.
- *VERSION 2.01 IS NOW AVAILABLE ON SID*
-
- Version 2.00
- ------------
-
- * Due to the extra mouse pointer definitions, V2.00 is now 7K long. Some
- people may consider this big for a screen saver, but think of that pretty
- time plotted on the screen and you might forgive me...
-
- * Re-organised the code to use less CPU time generally, especially when
- the module has been loaded but not activated.
-
- * Fixed the bug whereby colour 0 (background) wasn't restored properly in
- 256-colour MODEs.
-
- * Fully (ho hum - I lied here) tested and working in RISC OS (yes, I now have
- it !).
-
- * Modified the MEMC poke to make it 'safer'.
-
- * Now allow either the current time or the Smiley face to be plotted...
- you have a choice at last !
-
- * Added *Configure SaverType to go with the new mouse shape choice.
-
- * Reduced the maximum SaverDelay to 63 minutes because Bit 6 of Byte 35 is
- now used for the SaverType. Also made doubly sure that the version I
- release specifies the delay in minutes (rather than seconds, which I use
- for test purposes and accidentally forgot to change to minutes in V1.03 !).
-
- Version 1.03
- ------------
-
- * Make a special check for Teletext MODEs, so that the screen saving is
- performed in the same way as 256-colour MODEs.
-
- * 256-colour MODEs now toggle the Video/Cursor DMA Enable flag in MEMC's
- control register to blank the screen. In plain English, VDU Saver now
- works in 256-colour MODEs but without the dubious benefit of a Smiley
- face (because the mouse is unfortunately blanked in these MODEs as well).
-
- * MODE changes are now recognised as a screen restoration without the
- intervention of VDU Saver. This takes care of the case when VDUTrap = 0
- and the MODE is changed in a program whilst the screen is blanked. Earlier
- versions would have, after the appropriate delay, restored the OLD palette
- (prior to the MODE change) to the NEW MODE.
-
- * OK, a little bugette here folks. A friend ran VDU Saver on RISC OS and
- claimed erratic behaviour with the screen restoring at random intervals..!?!
- Due to laziness on my part, I had assumed that all events are disabled
- unless enabled by user programs (it's the case in Arthur 1.20). My theory is
- that RISC OS (probably the Desktop) enables events which Arthur 1.20 didn't
- use to. To remedy this problem, I've specifically checked for events 4,10
- and 11 in my event routine, so this behaviour should have been eliminated
- *CONFIRMED - OK IN RISC OS*.
-
- Version 1.02
- ------------
-
- * A soft reset no longer causes the *VDUSaver command to fail to activate.
-
- * Uses 2 bytes of CMOS RAM (35 and 36) to permanently store VDUSaver settings.
-
- * Allows finer control over the Smiley face in terms of colour, speed and
- plotting method.
-
- * The text cursor is now switched off and restored correctly during blanking.
-
- * Screen restoration on VDU output is now optional, because some users may have
- a clock running that uses the VDU drivers (especially Twin and graphicky
- Desktop clocks).
-
- Version 1.01
- ------------
-
- * Shows a bouncing 'Smiley' face when the screen is blacked.
-
- * Restores the screen on mouse movement as well as mouse button presses.
-
- Version 1.00
- ------------
-
- * Written as a relocatable module that traps vectors.
-
- * Properly switches off and restores the mouse pointer and border colour.
-
- Future Improvements to VDU Saver V2.04
- --------------------------------------
-
- * Although OS_Word 12 is trapped to check for mouse colour 1 being changed,
- I later discovered that the *Pointer 1 command actually bypasses this call
- (it uses VDU 19 instead) when changing the mouse colour ! I guess I'll have
- to add yet more code to cope with this...
-
- * At some point, I might make it install itself on the icon bar and act proper
- like wot all programs should do. There again, I might not...nope, I haven't
- bothered yet.
-
- Where to find me to report bugs or improvements to the VDU Saver
- ----------------------------------------------------------------
-
- Snail Mail JANET e-mail
- ---------- ------------
- Richard K. Lloyd, rkl@uk.ac.liv.cs.and
- 1, Banks Road,
- Lower Heswall,
- Wirral,
- Merseyside.
-