home *** CD-ROM | disk | FTP | other *** search
/ Dream 44 / Amiga_Dream_44.iso / RiscPc / Utils / blackhol.arc / !BlakHole2 / !FatHelp / Help / WriteSS < prev   
Text File  |  1996-01-08  |  7KB  |  105 lines

  1. {title}Information for people who
  2. {title}want to write their own
  3. {title}screensavers.
  4. [1]
  5. You don't expect to understand this, do you?
  6. [234]
  7. Hopefully this won't get too technical, but bear with me 'cos it's late and I've run out of coffee.
  8. The intention with Blackout was to write a screensaver which could be easily extended by the addition of new bits. The other intention was that the new bits should be easy to write so that people with little in-depth knowledge of the WIMP and graphics (such as me) could write their own savers. 
  9. To write a screen saver for Blackout you will need the following:
  10. a) A BASIC editor (preferably !Zap, because it's great).
  11. b) Part of a brain. Preferably yours, but you can borrow one if necessary.
  12. c) An idea.
  13. Generally, I find that part c is the hardest. The evidence for this comes from the quality of the savers I supply as standard.
  14. The best way to see how to do it is to look at some of the predefined savers, but a few notes might help.
  15. {subhead}Format
  16. A screen saver for Blackout is a framgent of a BASIC program. The main Blackout program uses BASIC's OVERLAY command to merge the two sections. A screen saver must contain the following two DEFPROCs:
  17. {tab}
  18. {subsub}DEFPROCinitsaver
  19. to initialise the variables used in the screen saver and, if necessary, clear the screen. You could also assemble a machine code routine, but you will need to DIM your own memory for this (or use PROCmemory - see below). 'Stars' uses a machine code routine, and simply sets this up by using a DIM statement in PROCinitsaver to allocate some memory for the code.
  20. If you want the screen background colour to be black, you should include the statement black%=TRUE somewhere in PROCinitsaver. This informs the program that it should use the black window instead of the transparent one.
  21. {subsub}DEFPROCupdatesaver
  22. to provide one 'step' in the animation of the saver. This must be written so that it ENDPROCs after not too long so that the WIMP can carry on polling other applications. For example, in the 'Stars' saver this procedure erases the stars, updates their coordinates, replots them, then returns.
  23. {notab}
  24. You can add as many other procedures as you like, provided they don't have the same names as ones in the main program (see below). The same applies to your own variables.
  25. You don't have to worry about checking for key presses or mouse movements or anything because the main program does that for you.
  26. The saver must also contain some REM statements at the start of the file:
  27. {tab}
  28. REM <Saver Name>
  29. REM Parameters:<description1>,<default1>
  30. REM Parameters:<description2>,<default2>
  31. REM Parameters:EndOpts
  32. REM Author:<author's name>
  33. REM Description:<short description>
  34. {notab}
  35. The first line is obvious.
  36. The Parameters: lines are the parameters. You can have up to 11 (or is it 10 - I can never remember) parameters. The <description> should be short enough to fit in the window. The <default> should be a sensible default. The REM Parameters:EndOpts must ALWAYS be there and is CASE SENSITIVE. If you have no parameters, just include this line.
  37. The last two lines are what will be displayed in the "Saver Information" box.
  38. To include a Faster variable (see above) you MUST have a parameter 'Faster', which when given the value 1 causes the variable bogie_eater% to be set to TRUE in PROCinitsaver. Blackout takes care of the rest.
  39. Your screen saver must be mode-independent. To help you in this, some variables are supplied by the main program.
  40. {subhead}Checking Parameters
  41. You may wish to check that the parameters are valid. To do this, put at the start of PROCinitsaver
  42. IF <parameter not valid> PROClemon("some descriptive text")
  43. That's all there is to it.
  44. {subhead}Supplied Variables
  45. The main blackout program sets up a number of variables which the saver can use. These are:
  46. {tab}
  47. {subsub}options$(0)-options$(10)
  48. contain each of the parameters as passed to blackout by the configuration program. In the above example options$(0) would be "30" and options$(1) would be "40". Note that all these are string variables.
  49. {subsub}numcols%
  50. is the number of colours that the current screen mode supports.
  51. {subsub}scrx%,scry%
  52. are the screen mode x and y size in OS units.
  53. {subsub}xeigen%,yeigen%
  54. are the x and y eigen factors - i.e. the log (base 2) of the number of OS units per pixel.
  55. {subsub}handle%
  56. If you want to use an outline font you will need a variable to store the font handle from Font_FindFont. I recommend you use handle% for this because then Blackout will do a Font_LoseFont when it closes down. If you use your own variable the font will remain open (unless you edit Blackout, which I would rather you didn't).
  57. {notab}
  58. {subhead}Useful Procedures
  59. Some procedures are also supplied by the program which may be of general use:
  60. {tab}
  61. {subsub}PROCblack
  62. clears the screen to black. It's not very fast but it works. If you want to use a screen saver with a black background, you MUST call this procedure once. If you don't, odd things may happen. On Risc OS 3.50 and above, this starts off the screen fade-to-black.
  63. {subsub}FNreadvar
  64. will read a system variable and return the result as a string.
  65. {subsub}PROCmemory
  66. is used to gain a large block of memory if, for instance, you want to set up a large user sprite area. The procedure takes one parameter, which is the amount of memory (in bytes) that you want. The variable rmablock% points to the start of this memory. The program uses SYS"Wimp_SlotSize" to get the memory, but the variable is called rmablock% because I originally used the RMA. So there. This procedure will abort the program if the required memory cannot be grabbed.
  67. {subsub}PROCcycle
  68. On RiscOS 3.50 and above this performs palette cycling using the CompoSupport Gamma Correction module written by Rob Davison. Call it from PROCupdatesaver once per iteration and it will cycle your palette for you. The Psych savers use this.
  69. {notab}
  70. {subhead}Changing Screen Mode
  71. {subsub}(RiscOS 3.50 and above ONLY)
  72. Some of the screen savers change mode before they start. To do this, use the following procedure:
  73. In PROCinitsaver call PROCrecovermode, which gets Blackout ready to restore the current mode once the screen saver has finished, then set up anything else you want, then call PROCblack.
  74. In PROCupdatesaver start with the following:
  75. DEFPROCupdatesaver
  76. IF NOT modechanged% THEN
  77.   PROCsixteenmillion
  78.   <anything else you want to do now that the mode has changed>
  79. ENDIF
  80. <etc. etc.>
  81. PROCsixteenmillion will change to 800x600 and 16 million colours by default, but if you want the user to be able to specify a mode string then just include a parameter for it and use it to set the variable changemode$.
  82. Note that calling PROCsixteenmillion does not guarantee that you will get that mode - someone may have less than 2MB of VRAM.
  83. {subhead}Reserved Names
  84. Procedures in your fragment of program must not have the same names as ones in the main program. The following PROC and FN names are reserved:
  85. {tab}
  86.   PROCaskforpassword
  87.   PROCblack
  88.   PROCcheckpassword
  89.   PROCinitwimp
  90.   PROCloadwindows
  91.   PROCmemory(bytes%)
  92.   PROCmessage(woof%)
  93.   PROCopenwindow
  94.   PROCps(window,icon,s$)
  95.   PROCquit
  96.   PROCscrnxy
  97.   PROCselic(bl%!0,bl%!4,bl%!8,bl%!12)
  98.   PROCstupidity
  99.   FNgaga(add%)
  100.   FNlust(bl%!0,bl%!4)
  101.   FNreadvar(var$)
  102.   FN colour(palentry%)
  103. {notab}
  104.  
  105.