Home » Archimedes archive » Archimedes World » AW-1996-12.adf » !AcornAns_AcornAns » November/!Balls/Tools/DataGen
November/!Balls/Tools/DataGen
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-1996-12.adf » !AcornAns_AcornAns |
Filename: | November/!Balls/Tools/DataGen |
Read OK: | ✔ |
File size: | 091D bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
10REM >DataGen 20REM Purpose: convert a specific sprite into a form suitable 30REM for fast plotting. 40REM 50REM Format of new data is as follows: 60REM Assume image dimensions are 20x16 pixels, 8bpp. 70REM Scanning image across rows, top to bottom, store image as 80REM pixel data block then mask block. 90REM Require that data for pixels which are masked is stored as 0 100REM & that mask bits are set to indicate solidity (ie the 110REM standard sprite mask value), 120REM so that we may write sprite to screen via: 130REM screen_pixel = (screen_pixel BIC sprite_mask) OR sprite_pixel. 140REM This requires 20*16*2 bytes storage. 150REM Follow this by 3 further copies of the same data, each 160REM scrolled right by one additional pixel. 170REM This permits the plotting code to use only word aligned read 180REM & write operations for speed, whilst still being able to write 190REM the image to screen at any pixel alignment. 200: 210areasize% = 1024 220DIM area% areasize% 230!area% = areasize% 240area%!4 = 0 250area%!8 = 16 260area%!12 = 16 270spop% = &2E 280SYS "OS_SpriteOp", &10A, area%, "<Balls$Dir>.Tools.BallSpr" 290spr% = area% + area%!8 300REM We assume sprite is 8bpp, 20*16 pixels, with mask 310REM & is left aligned leaving 3 blank (masked) columns 320REM of pixels on its right. 330: 340width% = 20 350REM datasize%: 20 bytes per row 360datasize% = width%*16*2*4 :REM 16 rows, pixels/masks, 4 instances 370DIM data% datasize% 380spri% = spr%+spr%!32:REM sprite image pointer 390sprm% = spr%+spr%!36:REM sprite mask ptr 400lastimageword%= 0 410lastmaskword% = 0 420dataptr% = data% 430: 440FOR loop% = 1 TO datasize%/32 450 imageword% = !spri%: spri%+=4 460 maskword% = !sprm%: sprm%+=4 470 REM Now ensure masked pixels are zeroed 480 imageword% = imageword% AND maskword% 490 offset% = 0 500 iw% = imageword% 510 mw% = maskword% 520 FOR instance% = 0 TO 3 530 dataptr%!(offset%+0) = iw% 540 dataptr%!(offset%+datasize%/8) = mw% 550 iw% = (iw%<<8) OR (lastimageword%>>>24) 560 lastimageword% = lastimageword%<<8 570 mw% = (mw%<<8) OR (lastmaskword%>>>24) 580 lastmaskword% = lastmaskword%<<8 590 offset%+=datasize%/4 600 NEXT 610 dataptr%+=4 620 lastimageword% = imageword% 630 lastmaskword% = maskword% 640NEXT 650: 660REM Now save our data 670SYS "OS_File", 10, "<Balls$Dir>.Resources.BallData", &FFD,, data%, data%+datasize% 680END
� >DataGen =� Purpose: convert a specific sprite into a form suitable � for fast plotting. (� 2'� Format of new data is as follows: <5� Assume image dimensions are 20x16 pixels, 8bpp. F?� Scanning image across rows, top to bottom, store image as P'� pixel data block then mask block. ZB� Require that data for pixels which are masked is stored as 0 d;� & that mask bits are set to indicate solidity (ie the n"� standard sprite mask value), x0� so that we may write sprite to screen via: �D� screen_pixel = (screen_pixel BIC sprite_mask) OR sprite_pixel. �*� This requires 20*16*2 bytes storage. �<� Follow this by 3 further copies of the same data, each �-� scrolled right by one additional pixel. �B� This permits the plotting code to use only word aligned read �D� & write operations for speed, whilst still being able to write �1� the image to screen at any pixel alignment. �: �areasize% = 1024 �� area% areasize% �!area% = areasize% �area%!4 = 0 �area%!8 = 16 area%!12 = 16 spop% = &2E >ș "OS_SpriteOp", &10A, area%, "<Balls$Dir>.Tools.BallSpr" "spr% = area% + area%!8 ,7� We assume sprite is 8bpp, 20*16 pixels, with mask 68� & is left aligned leaving 3 blank (masked) columns @� of pixels on its right. J: Twidth% = 20 ^!� datasize%: 20 bytes per row hCdatasize% = width%*16*2*4 :� 16 rows, pixels/masks, 4 instances r� data% datasize% |/spri% = spr%+spr%!32:� sprite image pointer �*sprm% = spr%+spr%!36:� sprite mask ptr �lastimageword%= 0 �lastmaskword% = 0 �dataptr% = data% �: �� loop% = 1 � datasize%/32 �" imageword% = !spri%: spri%+=4 �" maskword% = !sprm%: sprm%+=4 �* � Now ensure masked pixels are zeroed �( imageword% = imageword% � maskword% � offset% = 0 � iw% = imageword% � mw% = maskword% � instance% = 0 � 3 dataptr%!(offset%+0) = iw% * dataptr%!(offset%+datasize%/8) = mw% &, iw% = (iw%<<8) � (lastimageword%>>>24) 0( lastimageword% = lastimageword%<<8 :+ mw% = (mw%<<8) � (lastmaskword%>>>24) D' lastmaskword% = lastmaskword%<<8 N offset%+=datasize%/4 X � b dataptr%+=4 l lastimageword% = imageword% v lastmaskword% = maskword% �� �: �� Now save our data �Uș "OS_File", 10, "<Balls$Dir>.Resources.BallData", &FFD,, data%, data%+datasize% �� �
00000000 0d 00 0a 0e f4 20 3e 44 61 74 61 47 65 6e 0d 00 |..... >DataGen..| 00000010 14 3d f4 20 50 75 72 70 6f 73 65 3a 20 63 6f 6e |.=. Purpose: con| 00000020 76 65 72 74 20 61 20 73 70 65 63 69 66 69 63 20 |vert a specific | 00000030 73 70 72 69 74 65 20 69 6e 74 6f 20 61 20 66 6f |sprite into a fo| 00000040 72 6d 20 73 75 69 74 61 62 6c 65 0d 00 1e 18 f4 |rm suitable.....| 00000050 20 66 6f 72 20 66 61 73 74 20 70 6c 6f 74 74 69 | for fast plotti| 00000060 6e 67 2e 0d 00 28 05 f4 0d 00 32 27 f4 20 46 6f |ng...(....2'. Fo| 00000070 72 6d 61 74 20 6f 66 20 6e 65 77 20 64 61 74 61 |rmat of new data| 00000080 20 69 73 20 61 73 20 66 6f 6c 6c 6f 77 73 3a 0d | is as follows:.| 00000090 00 3c 35 f4 20 41 73 73 75 6d 65 20 69 6d 61 67 |.<5. Assume imag| 000000a0 65 20 64 69 6d 65 6e 73 69 6f 6e 73 20 61 72 65 |e dimensions are| 000000b0 20 32 30 78 31 36 20 70 69 78 65 6c 73 2c 20 38 | 20x16 pixels, 8| 000000c0 62 70 70 2e 0d 00 46 3f f4 20 53 63 61 6e 6e 69 |bpp...F?. Scanni| 000000d0 6e 67 20 69 6d 61 67 65 20 61 63 72 6f 73 73 20 |ng image across | 000000e0 72 6f 77 73 2c 20 74 6f 70 20 74 6f 20 62 6f 74 |rows, top to bot| 000000f0 74 6f 6d 2c 20 73 74 6f 72 65 20 69 6d 61 67 65 |tom, store image| 00000100 20 61 73 0d 00 50 27 f4 20 70 69 78 65 6c 20 64 | as..P'. pixel d| 00000110 61 74 61 20 62 6c 6f 63 6b 20 74 68 65 6e 20 6d |ata block then m| 00000120 61 73 6b 20 62 6c 6f 63 6b 2e 0d 00 5a 42 f4 20 |ask block...ZB. | 00000130 52 65 71 75 69 72 65 20 74 68 61 74 20 64 61 74 |Require that dat| 00000140 61 20 66 6f 72 20 70 69 78 65 6c 73 20 77 68 69 |a for pixels whi| 00000150 63 68 20 61 72 65 20 6d 61 73 6b 65 64 20 69 73 |ch are masked is| 00000160 20 73 74 6f 72 65 64 20 61 73 20 30 0d 00 64 3b | stored as 0..d;| 00000170 f4 20 26 20 74 68 61 74 20 6d 61 73 6b 20 62 69 |. & that mask bi| 00000180 74 73 20 61 72 65 20 73 65 74 20 74 6f 20 69 6e |ts are set to in| 00000190 64 69 63 61 74 65 20 73 6f 6c 69 64 69 74 79 20 |dicate solidity | 000001a0 28 69 65 20 74 68 65 0d 00 6e 22 f4 20 73 74 61 |(ie the..n". sta| 000001b0 6e 64 61 72 64 20 73 70 72 69 74 65 20 6d 61 73 |ndard sprite mas| 000001c0 6b 20 76 61 6c 75 65 29 2c 0d 00 78 30 f4 20 73 |k value),..x0. s| 000001d0 6f 20 74 68 61 74 20 77 65 20 6d 61 79 20 77 72 |o that we may wr| 000001e0 69 74 65 20 73 70 72 69 74 65 20 74 6f 20 73 63 |ite sprite to sc| 000001f0 72 65 65 6e 20 76 69 61 3a 0d 00 82 44 f4 20 73 |reen via:...D. s| 00000200 63 72 65 65 6e 5f 70 69 78 65 6c 20 3d 20 28 73 |creen_pixel = (s| 00000210 63 72 65 65 6e 5f 70 69 78 65 6c 20 42 49 43 20 |creen_pixel BIC | 00000220 73 70 72 69 74 65 5f 6d 61 73 6b 29 20 4f 52 20 |sprite_mask) OR | 00000230 73 70 72 69 74 65 5f 70 69 78 65 6c 2e 0d 00 8c |sprite_pixel....| 00000240 2a f4 20 54 68 69 73 20 72 65 71 75 69 72 65 73 |*. This requires| 00000250 20 32 30 2a 31 36 2a 32 20 62 79 74 65 73 20 73 | 20*16*2 bytes s| 00000260 74 6f 72 61 67 65 2e 0d 00 96 3c f4 20 46 6f 6c |torage....<. Fol| 00000270 6c 6f 77 20 74 68 69 73 20 62 79 20 33 20 66 75 |low this by 3 fu| 00000280 72 74 68 65 72 20 63 6f 70 69 65 73 20 6f 66 20 |rther copies of | 00000290 74 68 65 20 73 61 6d 65 20 64 61 74 61 2c 20 65 |the same data, e| 000002a0 61 63 68 0d 00 a0 2d f4 20 73 63 72 6f 6c 6c 65 |ach...-. scrolle| 000002b0 64 20 72 69 67 68 74 20 62 79 20 6f 6e 65 20 61 |d right by one a| 000002c0 64 64 69 74 69 6f 6e 61 6c 20 70 69 78 65 6c 2e |dditional pixel.| 000002d0 0d 00 aa 42 f4 20 54 68 69 73 20 70 65 72 6d 69 |...B. This permi| 000002e0 74 73 20 74 68 65 20 70 6c 6f 74 74 69 6e 67 20 |ts the plotting | 000002f0 63 6f 64 65 20 74 6f 20 75 73 65 20 6f 6e 6c 79 |code to use only| 00000300 20 77 6f 72 64 20 61 6c 69 67 6e 65 64 20 72 65 | word aligned re| 00000310 61 64 0d 00 b4 44 f4 20 26 20 77 72 69 74 65 20 |ad...D. & write | 00000320 6f 70 65 72 61 74 69 6f 6e 73 20 66 6f 72 20 73 |operations for s| 00000330 70 65 65 64 2c 20 77 68 69 6c 73 74 20 73 74 69 |peed, whilst sti| 00000340 6c 6c 20 62 65 69 6e 67 20 61 62 6c 65 20 74 6f |ll being able to| 00000350 20 77 72 69 74 65 0d 00 be 31 f4 20 74 68 65 20 | write...1. the | 00000360 69 6d 61 67 65 20 74 6f 20 73 63 72 65 65 6e 20 |image to screen | 00000370 61 74 20 61 6e 79 20 70 69 78 65 6c 20 61 6c 69 |at any pixel ali| 00000380 67 6e 6d 65 6e 74 2e 0d 00 c8 05 3a 0d 00 d2 14 |gnment.....:....| 00000390 61 72 65 61 73 69 7a 65 25 20 3d 20 31 30 32 34 |areasize% = 1024| 000003a0 0d 00 dc 15 de 20 61 72 65 61 25 20 61 72 65 61 |..... area% area| 000003b0 73 69 7a 65 25 0d 00 e6 19 21 61 72 65 61 25 20 |size%....!area% | 000003c0 20 20 20 3d 20 61 72 65 61 73 69 7a 65 25 0d 00 | = areasize%..| 000003d0 f0 11 61 72 65 61 25 21 34 20 20 20 3d 20 30 0d |..area%!4 = 0.| 000003e0 00 fa 12 61 72 65 61 25 21 38 20 20 20 3d 20 31 |...area%!8 = 1| 000003f0 36 0d 01 04 12 61 72 65 61 25 21 31 32 20 20 3d |6....area%!12 =| 00000400 20 31 36 0d 01 0e 13 73 70 6f 70 25 20 20 20 20 | 16....spop% | 00000410 20 3d 20 26 32 45 0d 01 18 3e c8 99 20 22 4f 53 | = &2E...>.. "OS| 00000420 5f 53 70 72 69 74 65 4f 70 22 2c 20 26 31 30 41 |_SpriteOp", &10A| 00000430 2c 20 61 72 65 61 25 2c 20 22 3c 42 61 6c 6c 73 |, area%, "<Balls| 00000440 24 44 69 72 3e 2e 54 6f 6f 6c 73 2e 42 61 6c 6c |$Dir>.Tools.Ball| 00000450 53 70 72 22 0d 01 22 1f 73 70 72 25 20 20 20 20 |Spr"..".spr% | 00000460 20 20 3d 20 61 72 65 61 25 20 2b 20 61 72 65 61 | = area% + area| 00000470 25 21 38 0d 01 2c 37 f4 20 57 65 20 61 73 73 75 |%!8..,7. We assu| 00000480 6d 65 20 73 70 72 69 74 65 20 69 73 20 38 62 70 |me sprite is 8bp| 00000490 70 2c 20 32 30 2a 31 36 20 70 69 78 65 6c 73 2c |p, 20*16 pixels,| 000004a0 20 77 69 74 68 20 6d 61 73 6b 0d 01 36 38 f4 20 | with mask..68. | 000004b0 26 20 69 73 20 6c 65 66 74 20 61 6c 69 67 6e 65 |& is left aligne| 000004c0 64 20 6c 65 61 76 69 6e 67 20 33 20 62 6c 61 6e |d leaving 3 blan| 000004d0 6b 20 28 6d 61 73 6b 65 64 29 20 63 6f 6c 75 6d |k (masked) colum| 000004e0 6e 73 0d 01 40 1d f4 20 6f 66 20 70 69 78 65 6c |ns..@.. of pixel| 000004f0 73 20 6f 6e 20 69 74 73 20 72 69 67 68 74 2e 0d |s on its right..| 00000500 01 4a 05 3a 0d 01 54 12 77 69 64 74 68 25 20 20 |.J.:..T.width% | 00000510 20 20 3d 20 32 30 0d 01 5e 21 f4 20 64 61 74 61 | = 20..^!. data| 00000520 73 69 7a 65 25 3a 20 32 30 20 62 79 74 65 73 20 |size%: 20 bytes | 00000530 70 65 72 20 72 6f 77 0d 01 68 43 64 61 74 61 73 |per row..hCdatas| 00000540 69 7a 65 25 20 3d 20 77 69 64 74 68 25 2a 31 36 |ize% = width%*16| 00000550 2a 32 2a 34 20 3a f4 20 31 36 20 72 6f 77 73 2c |*2*4 :. 16 rows,| 00000560 20 70 69 78 65 6c 73 2f 6d 61 73 6b 73 2c 20 34 | pixels/masks, 4| 00000570 20 69 6e 73 74 61 6e 63 65 73 0d 01 72 15 de 20 | instances..r.. | 00000580 64 61 74 61 25 20 64 61 74 61 73 69 7a 65 25 0d |data% datasize%.| 00000590 01 7c 2f 73 70 72 69 25 20 3d 20 73 70 72 25 2b |.|/spri% = spr%+| 000005a0 73 70 72 25 21 33 32 3a f4 20 73 70 72 69 74 65 |spr%!32:. sprite| 000005b0 20 69 6d 61 67 65 20 70 6f 69 6e 74 65 72 0d 01 | image pointer..| 000005c0 86 2a 73 70 72 6d 25 20 3d 20 73 70 72 25 2b 73 |.*sprm% = spr%+s| 000005d0 70 72 25 21 33 36 3a f4 20 73 70 72 69 74 65 20 |pr%!36:. sprite | 000005e0 6d 61 73 6b 20 70 74 72 0d 01 90 15 6c 61 73 74 |mask ptr....last| 000005f0 69 6d 61 67 65 77 6f 72 64 25 3d 20 30 0d 01 9a |imageword%= 0...| 00000600 15 6c 61 73 74 6d 61 73 6b 77 6f 72 64 25 20 3d |.lastmaskword% =| 00000610 20 30 0d 01 a4 14 64 61 74 61 70 74 72 25 20 3d | 0....dataptr% =| 00000620 20 64 61 74 61 25 0d 01 ae 05 3a 0d 01 b8 1e e3 | data%....:.....| 00000630 20 6c 6f 6f 70 25 20 3d 20 31 20 b8 20 64 61 74 | loop% = 1 . dat| 00000640 61 73 69 7a 65 25 2f 33 32 0d 01 c2 22 20 69 6d |asize%/32..." im| 00000650 61 67 65 77 6f 72 64 25 20 3d 20 21 73 70 72 69 |ageword% = !spri| 00000660 25 3a 20 73 70 72 69 25 2b 3d 34 0d 01 cc 22 20 |%: spri%+=4..." | 00000670 6d 61 73 6b 77 6f 72 64 25 20 20 3d 20 21 73 70 |maskword% = !sp| 00000680 72 6d 25 3a 20 73 70 72 6d 25 2b 3d 34 0d 01 d6 |rm%: sprm%+=4...| 00000690 2a 20 f4 20 4e 6f 77 20 65 6e 73 75 72 65 20 6d |* . Now ensure m| 000006a0 61 73 6b 65 64 20 70 69 78 65 6c 73 20 61 72 65 |asked pixels are| 000006b0 20 7a 65 72 6f 65 64 0d 01 e0 28 20 69 6d 61 67 | zeroed...( imag| 000006c0 65 77 6f 72 64 25 20 3d 20 69 6d 61 67 65 77 6f |eword% = imagewo| 000006d0 72 64 25 20 80 20 6d 61 73 6b 77 6f 72 64 25 0d |rd% . maskword%.| 000006e0 01 ea 13 20 6f 66 66 73 65 74 25 20 20 20 20 3d |... offset% =| 000006f0 20 30 0d 01 f4 1c 20 69 77 25 20 20 20 20 20 20 | 0.... iw% | 00000700 20 20 3d 20 69 6d 61 67 65 77 6f 72 64 25 0d 01 | = imageword%..| 00000710 fe 1b 20 6d 77 25 20 20 20 20 20 20 20 20 3d 20 |.. mw% = | 00000720 6d 61 73 6b 77 6f 72 64 25 0d 02 08 18 20 e3 20 |maskword%.... . | 00000730 69 6e 73 74 61 6e 63 65 25 20 3d 20 30 20 b8 20 |instance% = 0 . | 00000740 33 0d 02 12 20 20 20 64 61 74 61 70 74 72 25 21 |3... dataptr%!| 00000750 28 6f 66 66 73 65 74 25 2b 30 29 20 3d 20 69 77 |(offset%+0) = iw| 00000760 25 0d 02 1c 2a 20 20 64 61 74 61 70 74 72 25 21 |%...* dataptr%!| 00000770 28 6f 66 66 73 65 74 25 2b 64 61 74 61 73 69 7a |(offset%+datasiz| 00000780 65 25 2f 38 29 20 3d 20 6d 77 25 0d 02 26 2c 20 |e%/8) = mw%..&, | 00000790 20 69 77 25 20 3d 20 28 69 77 25 3c 3c 38 29 20 | iw% = (iw%<<8) | 000007a0 84 20 28 6c 61 73 74 69 6d 61 67 65 77 6f 72 64 |. (lastimageword| 000007b0 25 3e 3e 3e 32 34 29 0d 02 30 28 20 20 6c 61 73 |%>>>24)..0( las| 000007c0 74 69 6d 61 67 65 77 6f 72 64 25 20 3d 20 6c 61 |timageword% = la| 000007d0 73 74 69 6d 61 67 65 77 6f 72 64 25 3c 3c 38 0d |stimageword%<<8.| 000007e0 02 3a 2b 20 20 6d 77 25 20 3d 20 28 6d 77 25 3c |.:+ mw% = (mw%<| 000007f0 3c 38 29 20 84 20 28 6c 61 73 74 6d 61 73 6b 77 |<8) . (lastmaskw| 00000800 6f 72 64 25 3e 3e 3e 32 34 29 0d 02 44 27 20 20 |ord%>>>24)..D' | 00000810 6c 61 73 74 6d 61 73 6b 77 6f 72 64 25 20 20 3d |lastmaskword% =| 00000820 20 6c 61 73 74 6d 61 73 6b 77 6f 72 64 25 3c 3c | lastmaskword%<<| 00000830 38 0d 02 4e 1a 20 20 6f 66 66 73 65 74 25 2b 3d |8..N. offset%+=| 00000840 64 61 74 61 73 69 7a 65 25 2f 34 0d 02 58 06 20 |datasize%/4..X. | 00000850 ed 0d 02 62 10 20 64 61 74 61 70 74 72 25 2b 3d |...b. dataptr%+=| 00000860 34 0d 02 6c 20 20 6c 61 73 74 69 6d 61 67 65 77 |4..l lastimagew| 00000870 6f 72 64 25 20 3d 20 69 6d 61 67 65 77 6f 72 64 |ord% = imageword| 00000880 25 0d 02 76 1f 20 6c 61 73 74 6d 61 73 6b 77 6f |%..v. lastmaskwo| 00000890 72 64 25 20 20 3d 20 6d 61 73 6b 77 6f 72 64 25 |rd% = maskword%| 000008a0 0d 02 80 05 ed 0d 02 8a 05 3a 0d 02 94 17 f4 20 |.........:..... | 000008b0 4e 6f 77 20 73 61 76 65 20 6f 75 72 20 64 61 74 |Now save our dat| 000008c0 61 0d 02 9e 55 c8 99 20 22 4f 53 5f 46 69 6c 65 |a...U.. "OS_File| 000008d0 22 2c 20 31 30 2c 20 22 3c 42 61 6c 6c 73 24 44 |", 10, "<Balls$D| 000008e0 69 72 3e 2e 52 65 73 6f 75 72 63 65 73 2e 42 61 |ir>.Resources.Ba| 000008f0 6c 6c 44 61 74 61 22 2c 20 26 46 46 44 2c 2c 20 |llData", &FFD,, | 00000900 64 61 74 61 25 2c 20 64 61 74 61 25 2b 64 61 74 |data%, data%+dat| 00000910 61 73 69 7a 65 25 0d 02 a8 05 e0 0d ff |asize%.......| 0000091d