Home » Archimedes archive » Archimedes World » AW-1991-05.adf » May91 » !AWMay91/Goodies/FiveAlive/SPRITELIB

!AWMay91/Goodies/FiveAlive/SPRITELIB

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 » Archimedes World » AW-1991-05.adf » May91
Filename: !AWMay91/Goodies/FiveAlive/SPRITELIB
Read OK:
File size: 1023 bytes
Load address: 0000
Exec address: 0000
File contents
   10REM >SPRITELIB
   20
   30REM Shadow screen and user sprite library routines
   40
   50DEFPROCinit_screen
   60REM Initialises array to whole screen co-ordinates and
   70REM initialises variables for screen banking
   90DIM screen(4):screen(1)=0:screen(2)=0:screen(3)=1279:screen(4)=1023
  100update_bank=1:display_bank=1
  110*FX113,1
  120*FX112,1
  130ENDPROC
  140
  150DEFPROCswitch_display_bank
  160IF display_bank=1 THEN display_bank=2 ELSE display_bank=1
  170WAIT
  180OSCLI "FX 113,"+STR$display_bank
  190ENDPROC
  200
  210DEFPROCswitch_update_bank
  220IF update_bank=1 THEN update_bank=2 ELSE update_bank=1
  230WAIT
  240OSCLI "FX 112,"+STR$update_bank
  250ENDPROC
  260
  270DEFPROCcopy_box(box())
  280REM Copy screen area into shadow screen
  290PROCgrabbox(box(),"temp")
  300PROCswitch_update_bank
  310PROCrestorebox(box(),"temp")
  320PROCswitch_update_bank
  330ENDPROC
  340
  350DEFPROCinit_sprites(spritefile$,size%)
  360REM Initialises sprite area and loads sprite file
  370REM unless passed as "". size% contains required
  380REM size of sprite area in Kbytes
  390spritesize% = size%*1024
  400DIM spritearea spritesize%
  410!spritearea = spritesize%
  420spritearea!4=0
  430spritearea!8=16
  440spritearea!12=16
  450IF spritefile$ >"" THEN
  460PROCloadspritefile(spritefile$)
  470ENDIF
  480ENDPROC
  490
  500DEFPROCloadspritefile(spritefile$)
  510SYS "OS_SpriteOp",256+10,spritearea,spritefile$
  520ENDPROC
  530
  540DEFPROCsavespritefile(spritefile$)
  550SYS "OS_SpriteOp",256+12,spritearea,spritefile$
  560ENDPROC
  570
  580DEFPROCplot_sprite(sprite$,x,y,action)
  590REM Plots sprite
  600REM action = 0 standard plotting
  610REM action = 8 plots with mask
  620MOVE x,y
  630SYS "OS_SpriteOp",256+28,spritearea,sprite$,,,action
  640ENDPROC
  650
  660DEFPROCget_sprite(sprite$,box())
  670REM Grabs sprite, including palette
  680MOVE box(1),box(2):MOVE box(3),box(4)
  690SYS "OS_SpriteOp",256+14,spritearea,sprite$,1
  700ENDPROC
  710
  720DEFPROCfast_get_sprite(sprite$,x1,y1,x2,y2)
  730REM Passes co-ordinates directly, for speed
  740MOVE x1,y1:MOVE x2,y2
  750SYS "OS_SpriteOp",256+14,spritearea,sprite$,1
  760ENDPROC
  770
  780DEFPROCgrabbox(box(),sprite$)
  790REM grabs the screen area defined by box and
  800REM saves it as a sprite called sprite$
  810PROCget_sprite(sprite$,box())
  820ENDPROC
  830
  840DEFPROCrestorebox(box(),sprite$)
  850REM restores screen area defined by box and previously
  860REM saved by PROCgrabbox
  870PROCplot_sprite(sprite$,box(1),box(2),0)
  880ENDPROC
  890
  900DEFPROCgraphicwindow(box())
  910REM creates graphic window of the area specified by box()
  920VDU24,box(1);box(2);box(3);box(4);
  930ENDPROC
  940
  950DEFPROCmask_sprite(sprite$,maskcol)
  960LOCAL width,height,x,y
  970REM Creates mask for sprite and assigns all pixels in colour
  980REM maskcol to be transparent
  990PROCattachmask(sprite$)
 1000PROCgetspritepixels(sprite$,width,height)
 1010FOR x = 0 TO width-1
 1020FOR y = 0 TO height-1
 1030IF FNspritepixelcol(sprite$,x,y) = maskcol THEN
 1040PROCwritepixelmask(sprite$,x,y,0)
 1050ENDIF
 1060NEXT y
 1070NEXT x
 1080ENDPROC
 1090
 1100DEFFNspritepixelcol(sprite$,x,y)
 1110LOCAL col
 1120SYS "OS_SpriteOp",256+41,spritearea,sprite$,x,y TO ,,,,,col
 1130=col
 1140
 1150DEFPROCwritepixelmask(sprite$,x,y,a)
 1160REM a = 0 makes pixel transparent
 1170REM a = 1 makes pixel solid
 1180SYS "OS_SpriteOp",256+44,spritearea,sprite$,x,y,a
 1190ENDPROC
 1200
 1210DEFPROCattachmask(sprite$)
 1220REM Attaches mask to sprite with all pixels initially solid
 1230SYS "OS_SpriteOp",256+29,spritearea,sprite$
 1240ENDPROC
 1250
 1260DEFPROCgetspritepixels(sprite$,RETURN width,RETURN height)
 1270REM Returns width and height of sprite in pixels
 1280SYS "OS_SpriteOp",256+40,spritearea,sprite$ TO ,,,width,height
 1290ENDPROC
 1300
 1310DEFPROCsprite_writecontrolblock
 1320LOCAL size,sprites,bytespr,byteword
 1330SYS "OS_SpriteOp",256+8,spritearea TO ,,size,sprites,bytespr,byteword
 1340PRINT "USER SPRITE AREA"
 1350PRINT "Size : ";size
 1360PRINT "Sprites : ";sprites
 1370PRINT "Byte offset to 1st sprite : ";bytespr
 1380PRINT "Byte offset to 1st free word : ";byteword
 1390ENDPROC
 1400
 1410DEFPROCshiftscreen(shift,dir$)
 1420REM Move screen left or right, wrapping around background
 1430REM Best done on shadow screen, for smoothness
 1440REM Grab area to be covered as a sprite, shift the rest
 1450REM Using RECTANGLE TO, then restore sprite on opposite side
 1460LOCAL temp():DIM temp(4)
 1470CASE dir$ OF
 1480WHEN "L"
 1490PROCfast_get_sprite("temp",0,0,shift,screen(4))
 1500RECTANGLE shift,0,screen(3),screen(4) TO 0,0
 1510PROCplot_sprite("temp",screen(3)-shift,0,0)
 1520WHEN "R"
 1530PROCfast_get_sprite("temp",screen(3)-shift,0,screen(3),screen(4))
 1540RECTANGLE 0,0,screen(3)-shift,screen(4) TO shift,0
 1550PROCplot_sprite("temp",0,0,0)
 1560ENDCASE
 1570ENDPROC
 1580

� >SPRITELIB

4� Shadow screen and user sprite library routines
(
2��init_screen
<8� Initialises array to whole screen co-ordinates and
F.� initialises variables for screen banking
ZE� screen(4):screen(1)=0:screen(2)=0:screen(3)=1279:screen(4)=1023
d update_bank=1:display_bank=1
n*FX113,1
x*FX112,1
��
�
���switch_display_bank
�6� display_bank=1 � display_bank=2 � display_bank=1
�Ȗ
�� "FX 113,"+�display_bank
��
�
���switch_update_bank
�3� update_bank=1 � update_bank=2 � update_bank=1
�Ȗ
�� "FX 112,"+�update_bank
��

��copy_box(box())
)� Copy screen area into shadow screen
"�grabbox(box(),"temp")
,�switch_update_bank
6�restorebox(box(),"temp")
@�switch_update_bank
J�
T
^%��init_sprites(spritefile$,size%)
h3� Initialises sprite area and loads sprite file
r2� unless passed as "". size% contains required
|#� size of sprite area in Kbytes
�spritesize% = size%*1024
�� spritearea spritesize%
�!spritearea = spritesize%
�spritearea!4=0
�spritearea!8=16
�spritearea!12=16
�� spritefile$ >"" �
� �loadspritefile(spritefile$)
��
��
�
�!��loadspritefile(spritefile$)
�2ș "OS_SpriteOp",256+10,spritearea,spritefile$
�

!��savespritefile(spritefile$)
&2ș "OS_SpriteOp",256+12,spritearea,spritefile$
0�
:
D%��plot_sprite(sprite$,x,y,action)
N� Plots sprite
X"� action = 0 standard plotting
b � action = 8 plots with mask
l	� x,y
v7ș "OS_SpriteOp",256+28,spritearea,sprite$,,,action
��
�
���get_sprite(sprite$,box())
�%� Grabs sprite, including palette
�#� box(1),box(2):� box(3),box(4)
�0ș "OS_SpriteOp",256+14,spritearea,sprite$,1
��
�
�*��fast_get_sprite(sprite$,x1,y1,x2,y2)
�-� Passes co-ordinates directly, for speed
�� x1,y1:� x2,y2
�0ș "OS_SpriteOp",256+14,spritearea,sprite$,1
��

��grabbox(box(),sprite$)
.� grabs the screen area defined by box and
 )� saves it as a sprite called sprite$
*�get_sprite(sprite$,box())
4�
>
H��restorebox(box(),sprite$)
R8� restores screen area defined by box and previously
\� saved by PROCgrabbox
f)�plot_sprite(sprite$,box(1),box(2),0)
p�
z
���graphicwindow(box())
�;� creates graphic window of the area specified by box()
�$�24,box(1);box(2);box(3);box(4);
��
�
�"��mask_sprite(sprite$,maskcol)
�� width,height,x,y
�>� Creates mask for sprite and assigns all pixels in colour
�� maskcol to be transparent
��attachmask(sprite$)
�*�getspritepixels(sprite$,width,height)
�� x = 0 � width-1
�� y = 0 � height-1
.� �spritepixelcol(sprite$,x,y) = maskcol �
"�writepixelmask(sprite$,x,y,0)
�
$� y
.� x
8�
B
L!ݤspritepixelcol(sprite$,x,y)
V	� col
`=ș "OS_SpriteOp",256+41,spritearea,sprite$,x,y � ,,,,,col
j=col
t
~#��writepixelmask(sprite$,x,y,a)
�#� a = 0 makes pixel transparent
�� a = 1 makes pixel solid
�4ș "OS_SpriteOp",256+44,spritearea,sprite$,x,y,a
��
�
���attachmask(sprite$)
�=� Attaches mask to sprite with all pixels initially solid
�.ș "OS_SpriteOp",256+29,spritearea,sprite$
��
�
�/��getspritepixels(sprite$,� width,� height)
�2� Returns width and height of sprite in pixels
@ș "OS_SpriteOp",256+40,spritearea,sprite$ � ,,,width,height

�

��sprite_writecontrolblock
(#� size,sprites,bytespr,byteword
2Gș "OS_SpriteOp",256+8,spritearea � ,,size,sprites,bytespr,byteword
<� "USER SPRITE AREA"
F� "Size : ";size
P� "Sprites : ";sprites
Z,� "Byte offset to 1st sprite : ";bytespr
d0� "Byte offset to 1st free word : ";byteword
n�
x
���shiftscreen(shift,dir$)
�;� Move screen left or right, wrapping around background
�0� Best done on shadow screen, for smoothness
�9� Grab area to be covered as a sprite, shift the rest
�>� Using RECTANGLE TO, then restore sprite on opposite side
�� temp():� temp(4)
�
Ȏ dir$ �
�	� "L"
�0�fast_get_sprite("temp",0,0,shift,screen(4))
�(ȓ shift,0,screen(3),screen(4) � 0,0
�,�plot_sprite("temp",screen(3)-shift,0,0)
�	� "R"
�B�fast_get_sprite("temp",screen(3)-shift,0,screen(3),screen(4))
.ȓ 0,0,screen(3)-shift,screen(4) � shift,0
�plot_sprite("temp",0,0,0)
�
"�
,
�
00000000  0d 00 0a 10 f4 20 3e 53  50 52 49 54 45 4c 49 42  |..... >SPRITELIB|
00000010  0d 00 14 04 0d 00 1e 34  f4 20 53 68 61 64 6f 77  |.......4. Shadow|
00000020  20 73 63 72 65 65 6e 20  61 6e 64 20 75 73 65 72  | screen and user|
00000030  20 73 70 72 69 74 65 20  6c 69 62 72 61 72 79 20  | sprite library |
00000040  72 6f 75 74 69 6e 65 73  0d 00 28 04 0d 00 32 11  |routines..(...2.|
00000050  dd f2 69 6e 69 74 5f 73  63 72 65 65 6e 0d 00 3c  |..init_screen..<|
00000060  38 f4 20 49 6e 69 74 69  61 6c 69 73 65 73 20 61  |8. Initialises a|
00000070  72 72 61 79 20 74 6f 20  77 68 6f 6c 65 20 73 63  |rray to whole sc|
00000080  72 65 65 6e 20 63 6f 2d  6f 72 64 69 6e 61 74 65  |reen co-ordinate|
00000090  73 20 61 6e 64 0d 00 46  2e f4 20 69 6e 69 74 69  |s and..F.. initi|
000000a0  61 6c 69 73 65 73 20 76  61 72 69 61 62 6c 65 73  |alises variables|
000000b0  20 66 6f 72 20 73 63 72  65 65 6e 20 62 61 6e 6b  | for screen bank|
000000c0  69 6e 67 0d 00 5a 45 de  20 73 63 72 65 65 6e 28  |ing..ZE. screen(|
000000d0  34 29 3a 73 63 72 65 65  6e 28 31 29 3d 30 3a 73  |4):screen(1)=0:s|
000000e0  63 72 65 65 6e 28 32 29  3d 30 3a 73 63 72 65 65  |creen(2)=0:scree|
000000f0  6e 28 33 29 3d 31 32 37  39 3a 73 63 72 65 65 6e  |n(3)=1279:screen|
00000100  28 34 29 3d 31 30 32 33  0d 00 64 20 75 70 64 61  |(4)=1023..d upda|
00000110  74 65 5f 62 61 6e 6b 3d  31 3a 64 69 73 70 6c 61  |te_bank=1:displa|
00000120  79 5f 62 61 6e 6b 3d 31  0d 00 6e 0c 2a 46 58 31  |y_bank=1..n.*FX1|
00000130  31 33 2c 31 0d 00 78 0c  2a 46 58 31 31 32 2c 31  |13,1..x.*FX112,1|
00000140  0d 00 82 05 e1 0d 00 8c  04 0d 00 96 19 dd f2 73  |...............s|
00000150  77 69 74 63 68 5f 64 69  73 70 6c 61 79 5f 62 61  |witch_display_ba|
00000160  6e 6b 0d 00 a0 36 e7 20  64 69 73 70 6c 61 79 5f  |nk...6. display_|
00000170  62 61 6e 6b 3d 31 20 8c  20 64 69 73 70 6c 61 79  |bank=1 . display|
00000180  5f 62 61 6e 6b 3d 32 20  8b 20 64 69 73 70 6c 61  |_bank=2 . displa|
00000190  79 5f 62 61 6e 6b 3d 31  0d 00 aa 06 c8 96 0d 00  |y_bank=1........|
000001a0  b4 1d ff 20 22 46 58 20  31 31 33 2c 22 2b c3 64  |... "FX 113,"+.d|
000001b0  69 73 70 6c 61 79 5f 62  61 6e 6b 0d 00 be 05 e1  |isplay_bank.....|
000001c0  0d 00 c8 04 0d 00 d2 18  dd f2 73 77 69 74 63 68  |..........switch|
000001d0  5f 75 70 64 61 74 65 5f  62 61 6e 6b 0d 00 dc 33  |_update_bank...3|
000001e0  e7 20 75 70 64 61 74 65  5f 62 61 6e 6b 3d 31 20  |. update_bank=1 |
000001f0  8c 20 75 70 64 61 74 65  5f 62 61 6e 6b 3d 32 20  |. update_bank=2 |
00000200  8b 20 75 70 64 61 74 65  5f 62 61 6e 6b 3d 31 0d  |. update_bank=1.|
00000210  00 e6 06 c8 96 0d 00 f0  1c ff 20 22 46 58 20 31  |.......... "FX 1|
00000220  31 32 2c 22 2b c3 75 70  64 61 74 65 5f 62 61 6e  |12,"+.update_ban|
00000230  6b 0d 00 fa 05 e1 0d 01  04 04 0d 01 0e 15 dd f2  |k...............|
00000240  63 6f 70 79 5f 62 6f 78  28 62 6f 78 28 29 29 0d  |copy_box(box()).|
00000250  01 18 29 f4 20 43 6f 70  79 20 73 63 72 65 65 6e  |..). Copy screen|
00000260  20 61 72 65 61 20 69 6e  74 6f 20 73 68 61 64 6f  | area into shado|
00000270  77 20 73 63 72 65 65 6e  0d 01 22 1a f2 67 72 61  |w screen.."..gra|
00000280  62 62 6f 78 28 62 6f 78  28 29 2c 22 74 65 6d 70  |bbox(box(),"temp|
00000290  22 29 0d 01 2c 17 f2 73  77 69 74 63 68 5f 75 70  |")..,..switch_up|
000002a0  64 61 74 65 5f 62 61 6e  6b 0d 01 36 1d f2 72 65  |date_bank..6..re|
000002b0  73 74 6f 72 65 62 6f 78  28 62 6f 78 28 29 2c 22  |storebox(box(),"|
000002c0  74 65 6d 70 22 29 0d 01  40 17 f2 73 77 69 74 63  |temp")..@..switc|
000002d0  68 5f 75 70 64 61 74 65  5f 62 61 6e 6b 0d 01 4a  |h_update_bank..J|
000002e0  05 e1 0d 01 54 04 0d 01  5e 25 dd f2 69 6e 69 74  |....T...^%..init|
000002f0  5f 73 70 72 69 74 65 73  28 73 70 72 69 74 65 66  |_sprites(spritef|
00000300  69 6c 65 24 2c 73 69 7a  65 25 29 0d 01 68 33 f4  |ile$,size%)..h3.|
00000310  20 49 6e 69 74 69 61 6c  69 73 65 73 20 73 70 72  | Initialises spr|
00000320  69 74 65 20 61 72 65 61  20 61 6e 64 20 6c 6f 61  |ite area and loa|
00000330  64 73 20 73 70 72 69 74  65 20 66 69 6c 65 0d 01  |ds sprite file..|
00000340  72 32 f4 20 75 6e 6c 65  73 73 20 70 61 73 73 65  |r2. unless passe|
00000350  64 20 61 73 20 22 22 2e  20 73 69 7a 65 25 20 63  |d as "". size% c|
00000360  6f 6e 74 61 69 6e 73 20  72 65 71 75 69 72 65 64  |ontains required|
00000370  0d 01 7c 23 f4 20 73 69  7a 65 20 6f 66 20 73 70  |..|#. size of sp|
00000380  72 69 74 65 20 61 72 65  61 20 69 6e 20 4b 62 79  |rite area in Kby|
00000390  74 65 73 0d 01 86 1c 73  70 72 69 74 65 73 69 7a  |tes....spritesiz|
000003a0  65 25 20 3d 20 73 69 7a  65 25 2a 31 30 32 34 0d  |e% = size%*1024.|
000003b0  01 90 1c de 20 73 70 72  69 74 65 61 72 65 61 20  |.... spritearea |
000003c0  73 70 72 69 74 65 73 69  7a 65 25 0d 01 9a 1d 21  |spritesize%....!|
000003d0  73 70 72 69 74 65 61 72  65 61 20 3d 20 73 70 72  |spritearea = spr|
000003e0  69 74 65 73 69 7a 65 25  0d 01 a4 12 73 70 72 69  |itesize%....spri|
000003f0  74 65 61 72 65 61 21 34  3d 30 0d 01 ae 13 73 70  |tearea!4=0....sp|
00000400  72 69 74 65 61 72 65 61  21 38 3d 31 36 0d 01 b8  |ritearea!8=16...|
00000410  14 73 70 72 69 74 65 61  72 65 61 21 31 32 3d 31  |.spritearea!12=1|
00000420  36 0d 01 c2 17 e7 20 73  70 72 69 74 65 66 69 6c  |6..... spritefil|
00000430  65 24 20 3e 22 22 20 8c  0d 01 cc 20 f2 6c 6f 61  |e$ >"" .... .loa|
00000440  64 73 70 72 69 74 65 66  69 6c 65 28 73 70 72 69  |dspritefile(spri|
00000450  74 65 66 69 6c 65 24 29  0d 01 d6 05 cd 0d 01 e0  |tefile$)........|
00000460  05 e1 0d 01 ea 04 0d 01  f4 21 dd f2 6c 6f 61 64  |.........!..load|
00000470  73 70 72 69 74 65 66 69  6c 65 28 73 70 72 69 74  |spritefile(sprit|
00000480  65 66 69 6c 65 24 29 0d  01 fe 32 c8 99 20 22 4f  |efile$)...2.. "O|
00000490  53 5f 53 70 72 69 74 65  4f 70 22 2c 32 35 36 2b  |S_SpriteOp",256+|
000004a0  31 30 2c 73 70 72 69 74  65 61 72 65 61 2c 73 70  |10,spritearea,sp|
000004b0  72 69 74 65 66 69 6c 65  24 0d 02 08 05 e1 0d 02  |ritefile$.......|
000004c0  12 04 0d 02 1c 21 dd f2  73 61 76 65 73 70 72 69  |.....!..savespri|
000004d0  74 65 66 69 6c 65 28 73  70 72 69 74 65 66 69 6c  |tefile(spritefil|
000004e0  65 24 29 0d 02 26 32 c8  99 20 22 4f 53 5f 53 70  |e$)..&2.. "OS_Sp|
000004f0  72 69 74 65 4f 70 22 2c  32 35 36 2b 31 32 2c 73  |riteOp",256+12,s|
00000500  70 72 69 74 65 61 72 65  61 2c 73 70 72 69 74 65  |pritearea,sprite|
00000510  66 69 6c 65 24 0d 02 30  05 e1 0d 02 3a 04 0d 02  |file$..0....:...|
00000520  44 25 dd f2 70 6c 6f 74  5f 73 70 72 69 74 65 28  |D%..plot_sprite(|
00000530  73 70 72 69 74 65 24 2c  78 2c 79 2c 61 63 74 69  |sprite$,x,y,acti|
00000540  6f 6e 29 0d 02 4e 12 f4  20 50 6c 6f 74 73 20 73  |on)..N.. Plots s|
00000550  70 72 69 74 65 0d 02 58  22 f4 20 61 63 74 69 6f  |prite..X". actio|
00000560  6e 20 3d 20 30 20 73 74  61 6e 64 61 72 64 20 70  |n = 0 standard p|
00000570  6c 6f 74 74 69 6e 67 0d  02 62 20 f4 20 61 63 74  |lotting..b . act|
00000580  69 6f 6e 20 3d 20 38 20  70 6c 6f 74 73 20 77 69  |ion = 8 plots wi|
00000590  74 68 20 6d 61 73 6b 0d  02 6c 09 ec 20 78 2c 79  |th mask..l.. x,y|
000005a0  0d 02 76 37 c8 99 20 22  4f 53 5f 53 70 72 69 74  |..v7.. "OS_Sprit|
000005b0  65 4f 70 22 2c 32 35 36  2b 32 38 2c 73 70 72 69  |eOp",256+28,spri|
000005c0  74 65 61 72 65 61 2c 73  70 72 69 74 65 24 2c 2c  |tearea,sprite$,,|
000005d0  2c 61 63 74 69 6f 6e 0d  02 80 05 e1 0d 02 8a 04  |,action.........|
000005e0  0d 02 94 1f dd f2 67 65  74 5f 73 70 72 69 74 65  |......get_sprite|
000005f0  28 73 70 72 69 74 65 24  2c 62 6f 78 28 29 29 0d  |(sprite$,box()).|
00000600  02 9e 25 f4 20 47 72 61  62 73 20 73 70 72 69 74  |..%. Grabs sprit|
00000610  65 2c 20 69 6e 63 6c 75  64 69 6e 67 20 70 61 6c  |e, including pal|
00000620  65 74 74 65 0d 02 a8 23  ec 20 62 6f 78 28 31 29  |ette...#. box(1)|
00000630  2c 62 6f 78 28 32 29 3a  ec 20 62 6f 78 28 33 29  |,box(2):. box(3)|
00000640  2c 62 6f 78 28 34 29 0d  02 b2 30 c8 99 20 22 4f  |,box(4)...0.. "O|
00000650  53 5f 53 70 72 69 74 65  4f 70 22 2c 32 35 36 2b  |S_SpriteOp",256+|
00000660  31 34 2c 73 70 72 69 74  65 61 72 65 61 2c 73 70  |14,spritearea,sp|
00000670  72 69 74 65 24 2c 31 0d  02 bc 05 e1 0d 02 c6 04  |rite$,1.........|
00000680  0d 02 d0 2a dd f2 66 61  73 74 5f 67 65 74 5f 73  |...*..fast_get_s|
00000690  70 72 69 74 65 28 73 70  72 69 74 65 24 2c 78 31  |prite(sprite$,x1|
000006a0  2c 79 31 2c 78 32 2c 79  32 29 0d 02 da 2d f4 20  |,y1,x2,y2)...-. |
000006b0  50 61 73 73 65 73 20 63  6f 2d 6f 72 64 69 6e 61  |Passes co-ordina|
000006c0  74 65 73 20 64 69 72 65  63 74 6c 79 2c 20 66 6f  |tes directly, fo|
000006d0  72 20 73 70 65 65 64 0d  02 e4 13 ec 20 78 31 2c  |r speed..... x1,|
000006e0  79 31 3a ec 20 78 32 2c  79 32 0d 02 ee 30 c8 99  |y1:. x2,y2...0..|
000006f0  20 22 4f 53 5f 53 70 72  69 74 65 4f 70 22 2c 32  | "OS_SpriteOp",2|
00000700  35 36 2b 31 34 2c 73 70  72 69 74 65 61 72 65 61  |56+14,spritearea|
00000710  2c 73 70 72 69 74 65 24  2c 31 0d 02 f8 05 e1 0d  |,sprite$,1......|
00000720  03 02 04 0d 03 0c 1c dd  f2 67 72 61 62 62 6f 78  |.........grabbox|
00000730  28 62 6f 78 28 29 2c 73  70 72 69 74 65 24 29 0d  |(box(),sprite$).|
00000740  03 16 2e f4 20 67 72 61  62 73 20 74 68 65 20 73  |.... grabs the s|
00000750  63 72 65 65 6e 20 61 72  65 61 20 64 65 66 69 6e  |creen area defin|
00000760  65 64 20 62 79 20 62 6f  78 20 61 6e 64 0d 03 20  |ed by box and.. |
00000770  29 f4 20 73 61 76 65 73  20 69 74 20 61 73 20 61  |). saves it as a|
00000780  20 73 70 72 69 74 65 20  63 61 6c 6c 65 64 20 73  | sprite called s|
00000790  70 72 69 74 65 24 0d 03  2a 1e f2 67 65 74 5f 73  |prite$..*..get_s|
000007a0  70 72 69 74 65 28 73 70  72 69 74 65 24 2c 62 6f  |prite(sprite$,bo|
000007b0  78 28 29 29 0d 03 34 05  e1 0d 03 3e 04 0d 03 48  |x())..4....>...H|
000007c0  1f dd f2 72 65 73 74 6f  72 65 62 6f 78 28 62 6f  |...restorebox(bo|
000007d0  78 28 29 2c 73 70 72 69  74 65 24 29 0d 03 52 38  |x(),sprite$)..R8|
000007e0  f4 20 72 65 73 74 6f 72  65 73 20 73 63 72 65 65  |. restores scree|
000007f0  6e 20 61 72 65 61 20 64  65 66 69 6e 65 64 20 62  |n area defined b|
00000800  79 20 62 6f 78 20 61 6e  64 20 70 72 65 76 69 6f  |y box and previo|
00000810  75 73 6c 79 0d 03 5c 1a  f4 20 73 61 76 65 64 20  |usly..\.. saved |
00000820  62 79 20 50 52 4f 43 67  72 61 62 62 6f 78 0d 03  |by PROCgrabbox..|
00000830  66 29 f2 70 6c 6f 74 5f  73 70 72 69 74 65 28 73  |f).plot_sprite(s|
00000840  70 72 69 74 65 24 2c 62  6f 78 28 31 29 2c 62 6f  |prite$,box(1),bo|
00000850  78 28 32 29 2c 30 29 0d  03 70 05 e1 0d 03 7a 04  |x(2),0)..p....z.|
00000860  0d 03 84 1a dd f2 67 72  61 70 68 69 63 77 69 6e  |......graphicwin|
00000870  64 6f 77 28 62 6f 78 28  29 29 0d 03 8e 3b f4 20  |dow(box())...;. |
00000880  63 72 65 61 74 65 73 20  67 72 61 70 68 69 63 20  |creates graphic |
00000890  77 69 6e 64 6f 77 20 6f  66 20 74 68 65 20 61 72  |window of the ar|
000008a0  65 61 20 73 70 65 63 69  66 69 65 64 20 62 79 20  |ea specified by |
000008b0  62 6f 78 28 29 0d 03 98  24 ef 32 34 2c 62 6f 78  |box()...$.24,box|
000008c0  28 31 29 3b 62 6f 78 28  32 29 3b 62 6f 78 28 33  |(1);box(2);box(3|
000008d0  29 3b 62 6f 78 28 34 29  3b 0d 03 a2 05 e1 0d 03  |);box(4);.......|
000008e0  ac 04 0d 03 b6 22 dd f2  6d 61 73 6b 5f 73 70 72  |....."..mask_spr|
000008f0  69 74 65 28 73 70 72 69  74 65 24 2c 6d 61 73 6b  |ite(sprite$,mask|
00000900  63 6f 6c 29 0d 03 c0 16  ea 20 77 69 64 74 68 2c  |col)..... width,|
00000910  68 65 69 67 68 74 2c 78  2c 79 0d 03 ca 3e f4 20  |height,x,y...>. |
00000920  43 72 65 61 74 65 73 20  6d 61 73 6b 20 66 6f 72  |Creates mask for|
00000930  20 73 70 72 69 74 65 20  61 6e 64 20 61 73 73 69  | sprite and assi|
00000940  67 6e 73 20 61 6c 6c 20  70 69 78 65 6c 73 20 69  |gns all pixels i|
00000950  6e 20 63 6f 6c 6f 75 72  0d 03 d4 1f f4 20 6d 61  |n colour..... ma|
00000960  73 6b 63 6f 6c 20 74 6f  20 62 65 20 74 72 61 6e  |skcol to be tran|
00000970  73 70 61 72 65 6e 74 0d  03 de 18 f2 61 74 74 61  |sparent.....atta|
00000980  63 68 6d 61 73 6b 28 73  70 72 69 74 65 24 29 0d  |chmask(sprite$).|
00000990  03 e8 2a f2 67 65 74 73  70 72 69 74 65 70 69 78  |..*.getspritepix|
000009a0  65 6c 73 28 73 70 72 69  74 65 24 2c 77 69 64 74  |els(sprite$,widt|
000009b0  68 2c 68 65 69 67 68 74  29 0d 03 f2 15 e3 20 78  |h,height)..... x|
000009c0  20 3d 20 30 20 b8 20 77  69 64 74 68 2d 31 0d 03  | = 0 . width-1..|
000009d0  fc 16 e3 20 79 20 3d 20  30 20 b8 20 68 65 69 67  |... y = 0 . heig|
000009e0  68 74 2d 31 0d 04 06 2e  e7 20 a4 73 70 72 69 74  |ht-1..... .sprit|
000009f0  65 70 69 78 65 6c 63 6f  6c 28 73 70 72 69 74 65  |epixelcol(sprite|
00000a00  24 2c 78 2c 79 29 20 3d  20 6d 61 73 6b 63 6f 6c  |$,x,y) = maskcol|
00000a10  20 8c 0d 04 10 22 f2 77  72 69 74 65 70 69 78 65  | ....".writepixe|
00000a20  6c 6d 61 73 6b 28 73 70  72 69 74 65 24 2c 78 2c  |lmask(sprite$,x,|
00000a30  79 2c 30 29 0d 04 1a 05  cd 0d 04 24 07 ed 20 79  |y,0).......$.. y|
00000a40  0d 04 2e 07 ed 20 78 0d  04 38 05 e1 0d 04 42 04  |..... x..8....B.|
00000a50  0d 04 4c 21 dd a4 73 70  72 69 74 65 70 69 78 65  |..L!..spritepixe|
00000a60  6c 63 6f 6c 28 73 70 72  69 74 65 24 2c 78 2c 79  |lcol(sprite$,x,y|
00000a70  29 0d 04 56 09 ea 20 63  6f 6c 0d 04 60 3d c8 99  |)..V.. col..`=..|
00000a80  20 22 4f 53 5f 53 70 72  69 74 65 4f 70 22 2c 32  | "OS_SpriteOp",2|
00000a90  35 36 2b 34 31 2c 73 70  72 69 74 65 61 72 65 61  |56+41,spritearea|
00000aa0  2c 73 70 72 69 74 65 24  2c 78 2c 79 20 b8 20 2c  |,sprite$,x,y . ,|
00000ab0  2c 2c 2c 2c 63 6f 6c 0d  04 6a 08 3d 63 6f 6c 0d  |,,,,col..j.=col.|
00000ac0  04 74 04 0d 04 7e 23 dd  f2 77 72 69 74 65 70 69  |.t...~#..writepi|
00000ad0  78 65 6c 6d 61 73 6b 28  73 70 72 69 74 65 24 2c  |xelmask(sprite$,|
00000ae0  78 2c 79 2c 61 29 0d 04  88 23 f4 20 61 20 3d 20  |x,y,a)...#. a = |
00000af0  30 20 6d 61 6b 65 73 20  70 69 78 65 6c 20 74 72  |0 makes pixel tr|
00000b00  61 6e 73 70 61 72 65 6e  74 0d 04 92 1d f4 20 61  |ansparent..... a|
00000b10  20 3d 20 31 20 6d 61 6b  65 73 20 70 69 78 65 6c  | = 1 makes pixel|
00000b20  20 73 6f 6c 69 64 0d 04  9c 34 c8 99 20 22 4f 53  | solid...4.. "OS|
00000b30  5f 53 70 72 69 74 65 4f  70 22 2c 32 35 36 2b 34  |_SpriteOp",256+4|
00000b40  34 2c 73 70 72 69 74 65  61 72 65 61 2c 73 70 72  |4,spritearea,spr|
00000b50  69 74 65 24 2c 78 2c 79  2c 61 0d 04 a6 05 e1 0d  |ite$,x,y,a......|
00000b60  04 b0 04 0d 04 ba 19 dd  f2 61 74 74 61 63 68 6d  |.........attachm|
00000b70  61 73 6b 28 73 70 72 69  74 65 24 29 0d 04 c4 3d  |ask(sprite$)...=|
00000b80  f4 20 41 74 74 61 63 68  65 73 20 6d 61 73 6b 20  |. Attaches mask |
00000b90  74 6f 20 73 70 72 69 74  65 20 77 69 74 68 20 61  |to sprite with a|
00000ba0  6c 6c 20 70 69 78 65 6c  73 20 69 6e 69 74 69 61  |ll pixels initia|
00000bb0  6c 6c 79 20 73 6f 6c 69  64 0d 04 ce 2e c8 99 20  |lly solid...... |
00000bc0  22 4f 53 5f 53 70 72 69  74 65 4f 70 22 2c 32 35  |"OS_SpriteOp",25|
00000bd0  36 2b 32 39 2c 73 70 72  69 74 65 61 72 65 61 2c  |6+29,spritearea,|
00000be0  73 70 72 69 74 65 24 0d  04 d8 05 e1 0d 04 e2 04  |sprite$.........|
00000bf0  0d 04 ec 2f dd f2 67 65  74 73 70 72 69 74 65 70  |.../..getspritep|
00000c00  69 78 65 6c 73 28 73 70  72 69 74 65 24 2c f8 20  |ixels(sprite$,. |
00000c10  77 69 64 74 68 2c f8 20  68 65 69 67 68 74 29 0d  |width,. height).|
00000c20  04 f6 32 f4 20 52 65 74  75 72 6e 73 20 77 69 64  |..2. Returns wid|
00000c30  74 68 20 61 6e 64 20 68  65 69 67 68 74 20 6f 66  |th and height of|
00000c40  20 73 70 72 69 74 65 20  69 6e 20 70 69 78 65 6c  | sprite in pixel|
00000c50  73 0d 05 00 40 c8 99 20  22 4f 53 5f 53 70 72 69  |s...@.. "OS_Spri|
00000c60  74 65 4f 70 22 2c 32 35  36 2b 34 30 2c 73 70 72  |teOp",256+40,spr|
00000c70  69 74 65 61 72 65 61 2c  73 70 72 69 74 65 24 20  |itearea,sprite$ |
00000c80  b8 20 2c 2c 2c 77 69 64  74 68 2c 68 65 69 67 68  |. ,,,width,heigh|
00000c90  74 0d 05 0a 05 e1 0d 05  14 04 0d 05 1e 1e dd f2  |t...............|
00000ca0  73 70 72 69 74 65 5f 77  72 69 74 65 63 6f 6e 74  |sprite_writecont|
00000cb0  72 6f 6c 62 6c 6f 63 6b  0d 05 28 23 ea 20 73 69  |rolblock..(#. si|
00000cc0  7a 65 2c 73 70 72 69 74  65 73 2c 62 79 74 65 73  |ze,sprites,bytes|
00000cd0  70 72 2c 62 79 74 65 77  6f 72 64 0d 05 32 47 c8  |pr,byteword..2G.|
00000ce0  99 20 22 4f 53 5f 53 70  72 69 74 65 4f 70 22 2c  |. "OS_SpriteOp",|
00000cf0  32 35 36 2b 38 2c 73 70  72 69 74 65 61 72 65 61  |256+8,spritearea|
00000d00  20 b8 20 2c 2c 73 69 7a  65 2c 73 70 72 69 74 65  | . ,,size,sprite|
00000d10  73 2c 62 79 74 65 73 70  72 2c 62 79 74 65 77 6f  |s,bytespr,bytewo|
00000d20  72 64 0d 05 3c 18 f1 20  22 55 53 45 52 20 53 50  |rd..<.. "USER SP|
00000d30  52 49 54 45 20 41 52 45  41 22 0d 05 46 14 f1 20  |RITE AREA"..F.. |
00000d40  22 53 69 7a 65 20 3a 20  22 3b 73 69 7a 65 0d 05  |"Size : ";size..|
00000d50  50 1a f1 20 22 53 70 72  69 74 65 73 20 3a 20 22  |P.. "Sprites : "|
00000d60  3b 73 70 72 69 74 65 73  0d 05 5a 2c f1 20 22 42  |;sprites..Z,. "B|
00000d70  79 74 65 20 6f 66 66 73  65 74 20 74 6f 20 31 73  |yte offset to 1s|
00000d80  74 20 73 70 72 69 74 65  20 3a 20 22 3b 62 79 74  |t sprite : ";byt|
00000d90  65 73 70 72 0d 05 64 30  f1 20 22 42 79 74 65 20  |espr..d0. "Byte |
00000da0  6f 66 66 73 65 74 20 74  6f 20 31 73 74 20 66 72  |offset to 1st fr|
00000db0  65 65 20 77 6f 72 64 20  3a 20 22 3b 62 79 74 65  |ee word : ";byte|
00000dc0  77 6f 72 64 0d 05 6e 05  e1 0d 05 78 04 0d 05 82  |word..n....x....|
00000dd0  1d dd f2 73 68 69 66 74  73 63 72 65 65 6e 28 73  |...shiftscreen(s|
00000de0  68 69 66 74 2c 64 69 72  24 29 0d 05 8c 3b f4 20  |hift,dir$)...;. |
00000df0  4d 6f 76 65 20 73 63 72  65 65 6e 20 6c 65 66 74  |Move screen left|
00000e00  20 6f 72 20 72 69 67 68  74 2c 20 77 72 61 70 70  | or right, wrapp|
00000e10  69 6e 67 20 61 72 6f 75  6e 64 20 62 61 63 6b 67  |ing around backg|
00000e20  72 6f 75 6e 64 0d 05 96  30 f4 20 42 65 73 74 20  |round...0. Best |
00000e30  64 6f 6e 65 20 6f 6e 20  73 68 61 64 6f 77 20 73  |done on shadow s|
00000e40  63 72 65 65 6e 2c 20 66  6f 72 20 73 6d 6f 6f 74  |creen, for smoot|
00000e50  68 6e 65 73 73 0d 05 a0  39 f4 20 47 72 61 62 20  |hness...9. Grab |
00000e60  61 72 65 61 20 74 6f 20  62 65 20 63 6f 76 65 72  |area to be cover|
00000e70  65 64 20 61 73 20 61 20  73 70 72 69 74 65 2c 20  |ed as a sprite, |
00000e80  73 68 69 66 74 20 74 68  65 20 72 65 73 74 0d 05  |shift the rest..|
00000e90  aa 3e f4 20 55 73 69 6e  67 20 52 45 43 54 41 4e  |.>. Using RECTAN|
00000ea0  47 4c 45 20 54 4f 2c 20  74 68 65 6e 20 72 65 73  |GLE TO, then res|
00000eb0  74 6f 72 65 20 73 70 72  69 74 65 20 6f 6e 20 6f  |tore sprite on o|
00000ec0  70 70 6f 73 69 74 65 20  73 69 64 65 0d 05 b4 16  |pposite side....|
00000ed0  ea 20 74 65 6d 70 28 29  3a de 20 74 65 6d 70 28  |. temp():. temp(|
00000ee0  34 29 0d 05 be 0d c8 8e  20 64 69 72 24 20 ca 0d  |4)...... dir$ ..|
00000ef0  05 c8 09 c9 20 22 4c 22  0d 05 d2 30 f2 66 61 73  |.... "L"...0.fas|
00000f00  74 5f 67 65 74 5f 73 70  72 69 74 65 28 22 74 65  |t_get_sprite("te|
00000f10  6d 70 22 2c 30 2c 30 2c  73 68 69 66 74 2c 73 63  |mp",0,0,shift,sc|
00000f20  72 65 65 6e 28 34 29 29  0d 05 dc 28 c8 93 20 73  |reen(4))...(.. s|
00000f30  68 69 66 74 2c 30 2c 73  63 72 65 65 6e 28 33 29  |hift,0,screen(3)|
00000f40  2c 73 63 72 65 65 6e 28  34 29 20 b8 20 30 2c 30  |,screen(4) . 0,0|
00000f50  0d 05 e6 2c f2 70 6c 6f  74 5f 73 70 72 69 74 65  |...,.plot_sprite|
00000f60  28 22 74 65 6d 70 22 2c  73 63 72 65 65 6e 28 33  |("temp",screen(3|
00000f70  29 2d 73 68 69 66 74 2c  30 2c 30 29 0d 05 f0 09  |)-shift,0,0)....|
00000f80  c9 20 22 52 22 0d 05 fa  42 f2 66 61 73 74 5f 67  |. "R"...B.fast_g|
00000f90  65 74 5f 73 70 72 69 74  65 28 22 74 65 6d 70 22  |et_sprite("temp"|
00000fa0  2c 73 63 72 65 65 6e 28  33 29 2d 73 68 69 66 74  |,screen(3)-shift|
00000fb0  2c 30 2c 73 63 72 65 65  6e 28 33 29 2c 73 63 72  |,0,screen(3),scr|
00000fc0  65 65 6e 28 34 29 29 0d  06 04 2e c8 93 20 30 2c  |een(4))...... 0,|
00000fd0  30 2c 73 63 72 65 65 6e  28 33 29 2d 73 68 69 66  |0,screen(3)-shif|
00000fe0  74 2c 73 63 72 65 65 6e  28 34 29 20 b8 20 73 68  |t,screen(4) . sh|
00000ff0  69 66 74 2c 30 0d 06 0e  1e f2 70 6c 6f 74 5f 73  |ift,0.....plot_s|
00001000  70 72 69 74 65 28 22 74  65 6d 70 22 2c 30 2c 30  |prite("temp",0,0|
00001010  2c 30 29 0d 06 18 05 cb  0d 06 22 05 e1 0d 06 2c  |,0)......."....,|
00001020  04 0d ff                                          |...|
00001023