RISC User Volume 2 Issues 1 and 2 featured a Movie Maker package which permits the creation of animated sequences of all kinds. As presented, the program only permits playback from within Movie Maker itself, but as promised, we now give a short program which will allow Movie Maker files to be replayed independently. This means that animated sequences can be included within other pieces of software; and as a bonus, a special feature permits the replayed images to be placed anywhere on a mode 13 screen.
To try it out, type in the program, and en-sure that you have a machine code file called DeltaCode (the one used with Movie Maker), and an animation file (as created by Movie Maker) in your current directory. You must then customise the program to suit your requirements. There are four values to adjust in the first few lines of the program. Set file$ in line 90 to the name of your animation file, and frames% to the required playback speed (50, 25, 12, 6 or 3 frames per second). Lines 110 and 120 contain horizontal and vertical offsets for the image. If these are both zero, the image will appear at the position where it was originally created. The vertical scale runs from 0 to 255, and the horizontal from 0 to 319. Negative numbers may be used (to move left or upwards), but you should not let any part of the image go above the top of the screen, or errors will occur.
The program itself is very simple. It uses just three procedures in sequence: PROCinit, PROCload and PROCreplay. This latter takes as its parameter the number of the last frame to be displayed. In our example we have used the variable frametot to display the full sequence. But you could if you wish be more creative. For example, you could display the sequence from frame 1 to 13 ten times in succession, and then finish off the display by showing the whole sequence. To do this use:
FOR count=1 TO 10
PROCreplay(13)
NEXT
PROCreplay(frametot)
Finally, two more points that might be useful when incorporating a display into another program. Firstly, the quantity of RAM reserved for the animation file is automatically tailored to the size of the file itself in order to save RAM, and should therefore not need to be altered. And secondly, every time that PROCreplay is called, the graphics screen is cleared to the background colour used when the animation sequence was originally generated. If you wish to keep other things on screen during this process, simply set up a graphics window (after line 80) around your animation area so that only this part gets cleared. As an example VDU24,200;300;500;700; will set up a window whose bottom left and top right co-ordinates are 200,300 and 500,700.
10 REM >SoloAnim
20 REM Program Solo Replay
30 REM Version A 0.7
40 REM Author Lee Calcraft
50 REM RISC User December 1988
60 REM Copyright Lee Calcraft
70 :
80 MODE13:OFF
90 file$="Dman2" :REM Customise
100 frames%=25 :REM 25 frames/sec
110 xoffset=0 :REM Horiz offset
120 yoffset=0 :REM Vert offset
130 PROCinit
140 PROCload(file$)
150 PROCreplay(frametot)
160 ON
170 END
180 :
190 DEFPROCinit
200 ON ERROR REPORT:PRINT" at line ";ERL:ON:END
210 handle%=OPENIN(file$)
220 bsize%=EXT# handle%+&400
230 CLOSE# handle%
240 DIM screens bsize%
250 DIM buff &30,code &200
260 OSCLI("LOAD DeltaCode "+STR$~code)
270 speed%=50 DIV frames%
280 A%=screens+bsize%-&10
290 CALL code :REM initialise
300 basaddr=!(code+244)
310 !(code+244)=basaddr+xoffset+yoffset*320
320 ENDPROC
330 :
340 DEFPROCreplay(stopframe)
350 GCOL 128+startcol TINT starttint
360 CLG:B%=screens+12:N%=0
370 REPEAT
380 A%=B%:N%+=1:B%=USR(code+12)
390 IF speed%>0 THEN
400 FOR S%=1 TO speed%
410 WAIT
420 NEXT
430 ENDIF
440 UNTIL N%=stopframe OR B%=0
450 IF B%>0 THEN A%=B%:frameno=N%+1 ELSE frameno=N%
460 ENDPROC
470 :
480 DEFPROCload(file$)
490 OSCLI("LOAD "+file$+" "+STR$~screens)
500 frametot=!screens
510 startcol=screens?4
520 starttint=screens?5
530 ENDPROC