Home » Archimedes archive » Acorn User » AU 1994-04.adf » !WriteDemo_WriteDemo » FNconvert
FNconvert
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 » Acorn User » AU 1994-04.adf » !WriteDemo_WriteDemo |
Filename: | FNconvert |
Read OK: | ✔ |
File size: | 0952 bytes |
Load address: | 0000 |
Exec address: | 0000 |
Duplicates
There are 2 duplicate copies of this file in the archive:
- Archimedes archive » Acorn User » AU 1994-06.adf » !WriteDemo_WriteDemo » FNconvert
- Archimedes archive » Acorn User » AU 1994-04.adf » !WriteDemo_WriteDemo » FNconvert
- Archimedes archive » Acorn User » AU 1994-05.adf » !WriteDemo_WriteDemo » FNconvert
File contents
10REM >FNconvert 20REM by Mark Hobson 30REM v1.00 40 50REM FNconvert(name$,store%) to be used by the 60REM modules to convert their sprite file into 70REM data before compiling their module. 80REM 90REM name$ is the name of the module. 100REM 110REM store% is a pointer to the workspace that 120REM the sprites are to be converted 130REM into. 140REM 150REM The output of the function is as follows : 160REM -1 = sprite file not found 170REM 0 = converted ok 180REM >0 = number of sprites that were not 190REM converted because their width 200REM was not divisible by 4 210 220 230 240DEF FNconvert(n$,store%) 250 LOCAL result%,sa%,exists%,pointer%,sprite%,n% 260 LOCAL name$,a%,w%,h%,mask%,msk%,pic%,offset% 270 LOCAL word%,X%,Y%,max_len%,I% 280 result% = 0 290 SYS "OS_File",13,"<Modules$Dir>."+n$+".Sprites" TO exists%,,,,max_len% 300 310 IF exists% = 1 THEN 320 330 max_len% += 16 340 DIM sa% max_len% 350 sa%!0 = max_len% 360 sa%!4 = 0 370 sa%!8 = 16 380 SYS 46,256+9,sa% 390 400 SYS 46,256+10,sa%,"<Modules$Dir>."+n$+".Sprites" 410 pointer% = store% 420 sprite% = sa% 430 n% = sprite%!4 440 sprite% += sprite%!8 450 460 FOR I% = 1 TO n% 470 name$ = "" 480 a% = 4 490 WHILE (sprite%?a%) >= 32 500 name$ += CHR$(sprite%?a%) 510 a% += 1 520 ENDWHILE 530 SYS 46,256+54,sa%,name$ 540 SYS 46,256+40,sa%,name$ TO ,,,w%,h%,mask% 550 pic% = sprite% + sprite%!32 560 msk% = sprite% + sprite%!36 570 convert% = 1 580 IF sprite%!40 <> 13 THEN convert% = 0 590 IF (w% MOD 4) <> 0 THEN 600 convert% = 0 610 result% += 1 620 ENDIF 630 IF convert% THEN 640 offset% = 0 650 FOR Y% = 0 TO (h% - 1) 660 FOR X% = 0 TO (w% - 1) STEP 4 670 word% = (pic%!offset%) 680 IF mask% THEN word% = (word% AND msk%!offset%) 690 pointer%!offset% = word% 700 offset% += 4 710 NEXT 720 NEXT 730 pointer% += offset% 740 IF mask% THEN 750 offset% = 0 760 FOR Y% = 0 TO (h% - 1) 770 FOR X% = 0 TO (w% - 1) STEP 4 780 pointer%!offset% = (msk%!offset%) EOR -1 790 offset% += 4 800 NEXT 810 NEXT 820 pointer% += offset% 830 ENDIF 840 ENDIF 850 sprite% += sprite%!0 860 NEXT 870 880 ELSE 890 900 result% = -1 910 920 ENDIF 930 940= result%
� >FNconvert � by Mark Hobson � v1.00 ( 20� FNconvert(name$,store%) to be used by the <0� modules to convert their sprite file into F*� data before compiling their module. P� Z(� name$ is the name of the module. d� n0� store% is a pointer to the workspace that x&� the sprites are to be converted �� into. �� �1� The output of the function is as follows : �%� -1 = sprite file not found �� 0 = converted ok �/� >0 = number of sprites that were not �-� converted because their width �&� was not divisible by 4 � � � �� �convert(n$,store%) �/ � result%,sa%,exists%,pointer%,sprite%,n% . � name$,a%,w%,h%,mask%,msk%,pic%,offset% � word%,X%,Y%,max_len%,I% result% = 0 "J ș "OS_File",13,"<Modules$Dir>."+n$+".Sprites" � exists%,,,,max_len% , 6 � exists% = 1 � @ J max_len% += 16 T � sa% max_len% ^ sa%!0 = max_len% h sa%!4 = 0 r sa%!8 = 16 | ș 46,256+9,sa% � �7 ș 46,256+10,sa%,"<Modules$Dir>."+n$+".Sprites" � pointer% = store% � sprite% = sa% � n% = sprite%!4 � sprite% += sprite%!8 � � � I% = 1 � n% � name$ = "" � a% = 4 � ȕ (sprite%?a%) >= 32 �" name$ += �(sprite%?a%) � a% += 1 � ș 46,256+54,sa%,name$ 1 ș 46,256+40,sa%,name$ � ,,,w%,h%,mask% &% pic% = sprite% + sprite%!32 0% msk% = sprite% + sprite%!36 : convert% = 1 D+ � sprite%!40 <> 13 � convert% = 0 N � (w% � 4) <> 0 � X convert% = 0 b result% += 1 l � v � convert% � � offset% = 0 � � Y% = 0 � (h% - 1) �% � X% = 0 � (w% - 1) � 4 �1 word% = (pic%!offset%) �8 � mask% � word% = (word% � msk%!offset%) �( pointer%!offset% = word% �$ offset% += 4 � � � � � pointer% += offset% � � mask% � � offset% = 0 �! � Y% = 0 � (h% - 1) ' � X% = 0 � (w% - 1) � 4 8 pointer%!offset% = (msk%!offset%) � -1 & offset% += 4 � * � 4! pointer% += offset% > � H � R sprite% += sprite%!0 \ � f p � z � result% = -1 � � � � � = result% �
00000000 0d 00 0a 11 f4 20 20 3e 46 4e 63 6f 6e 76 65 72 |..... >FNconver| 00000010 74 0d 00 14 15 f4 20 20 62 79 20 4d 61 72 6b 20 |t..... by Mark | 00000020 48 6f 62 73 6f 6e 0d 00 1e 0c f4 20 20 76 31 2e |Hobson..... v1.| 00000030 30 30 0d 00 28 04 0d 00 32 30 f4 20 20 46 4e 63 |00..(...20. FNc| 00000040 6f 6e 76 65 72 74 28 6e 61 6d 65 24 2c 73 74 6f |onvert(name$,sto| 00000050 72 65 25 29 20 74 6f 20 62 65 20 75 73 65 64 20 |re%) to be used | 00000060 62 79 20 74 68 65 0d 00 3c 30 f4 20 20 6d 6f 64 |by the..<0. mod| 00000070 75 6c 65 73 20 74 6f 20 63 6f 6e 76 65 72 74 20 |ules to convert | 00000080 74 68 65 69 72 20 73 70 72 69 74 65 20 66 69 6c |their sprite fil| 00000090 65 20 69 6e 74 6f 0d 00 46 2a f4 20 20 64 61 74 |e into..F*. dat| 000000a0 61 20 62 65 66 6f 72 65 20 63 6f 6d 70 69 6c 69 |a before compili| 000000b0 6e 67 20 74 68 65 69 72 20 6d 6f 64 75 6c 65 2e |ng their module.| 000000c0 0d 00 50 05 f4 0d 00 5a 28 f4 20 20 6e 61 6d 65 |..P....Z(. name| 000000d0 24 20 20 69 73 20 74 68 65 20 6e 61 6d 65 20 6f |$ is the name o| 000000e0 66 20 74 68 65 20 6d 6f 64 75 6c 65 2e 0d 00 64 |f the module...d| 000000f0 05 f4 0d 00 6e 30 f4 20 20 73 74 6f 72 65 25 20 |....n0. store% | 00000100 69 73 20 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 |is a pointer to | 00000110 74 68 65 20 77 6f 72 6b 73 70 61 63 65 20 74 68 |the workspace th| 00000120 61 74 0d 00 78 26 f4 20 20 74 68 65 20 73 70 72 |at..x&. the spr| 00000130 69 74 65 73 20 61 72 65 20 74 6f 20 62 65 20 63 |ites are to be c| 00000140 6f 6e 76 65 72 74 65 64 0d 00 82 0c f4 20 20 69 |onverted..... i| 00000150 6e 74 6f 2e 0d 00 8c 05 f4 0d 00 96 31 f4 20 20 |nto.........1. | 00000160 54 68 65 20 6f 75 74 70 75 74 20 6f 66 20 74 68 |The output of th| 00000170 65 20 66 75 6e 63 74 69 6f 6e 20 69 73 20 61 73 |e function is as| 00000180 20 66 6f 6c 6c 6f 77 73 20 3a 0d 00 a0 25 f4 20 | follows :...%. | 00000190 20 20 20 20 20 2d 31 20 3d 20 73 70 72 69 74 65 | -1 = sprite| 000001a0 20 66 69 6c 65 20 6e 6f 74 20 66 6f 75 6e 64 0d | file not found.| 000001b0 00 aa 1c f4 20 20 20 20 20 20 20 30 20 3d 20 63 |.... 0 = c| 000001c0 6f 6e 76 65 72 74 65 64 20 6f 6b 0d 00 b4 2f f4 |onverted ok.../.| 000001d0 20 20 20 20 20 20 3e 30 20 3d 20 6e 75 6d 62 65 | >0 = numbe| 000001e0 72 20 6f 66 20 73 70 72 69 74 65 73 20 74 68 61 |r of sprites tha| 000001f0 74 20 77 65 72 65 20 6e 6f 74 0d 00 be 2d f4 20 |t were not...-. | 00000200 20 20 20 20 20 20 20 20 20 20 63 6f 6e 76 65 72 | conver| 00000210 74 65 64 20 62 65 63 61 75 73 65 20 74 68 65 69 |ted because thei| 00000220 72 20 77 69 64 74 68 0d 00 c8 26 f4 20 20 20 20 |r width...&. | 00000230 20 20 20 20 20 20 20 77 61 73 20 6e 6f 74 20 64 | was not d| 00000240 69 76 69 73 69 62 6c 65 20 62 79 20 34 0d 00 d2 |ivisible by 4...| 00000250 04 0d 00 dc 04 0d 00 e6 04 0d 00 f0 19 dd 20 a4 |.............. .| 00000260 63 6f 6e 76 65 72 74 28 6e 24 2c 73 74 6f 72 65 |convert(n$,store| 00000270 25 29 0d 00 fa 2f 20 20 ea 20 72 65 73 75 6c 74 |%).../ . result| 00000280 25 2c 73 61 25 2c 65 78 69 73 74 73 25 2c 70 6f |%,sa%,exists%,po| 00000290 69 6e 74 65 72 25 2c 73 70 72 69 74 65 25 2c 6e |inter%,sprite%,n| 000002a0 25 0d 01 04 2e 20 20 ea 20 6e 61 6d 65 24 2c 61 |%.... . name$,a| 000002b0 25 2c 77 25 2c 68 25 2c 6d 61 73 6b 25 2c 6d 73 |%,w%,h%,mask%,ms| 000002c0 6b 25 2c 70 69 63 25 2c 6f 66 66 73 65 74 25 0d |k%,pic%,offset%.| 000002d0 01 0e 1f 20 20 ea 20 77 6f 72 64 25 2c 58 25 2c |... . word%,X%,| 000002e0 59 25 2c 6d 61 78 5f 6c 65 6e 25 2c 49 25 0d 01 |Y%,max_len%,I%..| 000002f0 18 12 20 20 72 65 73 75 6c 74 25 20 20 3d 20 30 |.. result% = 0| 00000300 0d 01 22 4a 20 20 c8 99 20 22 4f 53 5f 46 69 6c |.."J .. "OS_Fil| 00000310 65 22 2c 31 33 2c 22 3c 4d 6f 64 75 6c 65 73 24 |e",13,"<Modules$| 00000320 44 69 72 3e 2e 22 2b 6e 24 2b 22 2e 53 70 72 69 |Dir>."+n$+".Spri| 00000330 74 65 73 22 20 b8 20 65 78 69 73 74 73 25 2c 2c |tes" . exists%,,| 00000340 2c 2c 6d 61 78 5f 6c 65 6e 25 0d 01 2c 04 0d 01 |,,max_len%..,...| 00000350 36 15 20 20 e7 20 65 78 69 73 74 73 25 20 3d 20 |6. . exists% = | 00000360 31 20 8c 0d 01 40 04 0d 01 4a 16 20 20 20 20 6d |1 ...@...J. m| 00000370 61 78 5f 6c 65 6e 25 20 2b 3d 20 31 36 0d 01 54 |ax_len% += 16..T| 00000380 16 20 20 20 20 de 20 73 61 25 20 6d 61 78 5f 6c |. . sa% max_l| 00000390 65 6e 25 0d 01 5e 18 20 20 20 20 73 61 25 21 30 |en%..^. sa%!0| 000003a0 20 3d 20 6d 61 78 5f 6c 65 6e 25 0d 01 68 11 20 | = max_len%..h. | 000003b0 20 20 20 73 61 25 21 34 20 3d 20 30 0d 01 72 12 | sa%!4 = 0..r.| 000003c0 20 20 20 20 73 61 25 21 38 20 3d 20 31 36 0d 01 | sa%!8 = 16..| 000003d0 7c 17 20 20 20 20 c8 99 20 34 36 2c 32 35 36 2b ||. .. 46,256+| 000003e0 39 2c 73 61 25 0d 01 86 04 0d 01 90 37 20 20 20 |9,sa%.......7 | 000003f0 20 c8 99 20 34 36 2c 32 35 36 2b 31 30 2c 73 61 | .. 46,256+10,sa| 00000400 25 2c 22 3c 4d 6f 64 75 6c 65 73 24 44 69 72 3e |%,"<Modules$Dir>| 00000410 2e 22 2b 6e 24 2b 22 2e 53 70 72 69 74 65 73 22 |."+n$+".Sprites"| 00000420 0d 01 9a 19 20 20 20 20 70 6f 69 6e 74 65 72 25 |.... pointer%| 00000430 20 3d 20 73 74 6f 72 65 25 0d 01 a4 16 20 20 20 | = store%.... | 00000440 20 73 70 72 69 74 65 25 20 20 3d 20 73 61 25 0d | sprite% = sa%.| 00000450 01 ae 1c 20 20 20 20 6e 25 20 20 20 20 20 20 20 |... n% | 00000460 3d 20 73 70 72 69 74 65 25 21 34 0d 01 b8 1c 20 |= sprite%!4.... | 00000470 20 20 20 73 70 72 69 74 65 25 20 2b 3d 20 73 70 | sprite% += sp| 00000480 72 69 74 65 25 21 38 0d 01 c2 04 0d 01 cc 15 20 |rite%!8........ | 00000490 20 20 20 e3 20 49 25 20 3d 20 31 20 b8 20 6e 25 | . I% = 1 . n%| 000004a0 0d 01 d6 14 20 20 20 20 20 20 6e 61 6d 65 24 20 |.... name$ | 000004b0 3d 20 22 22 0d 01 e0 13 20 20 20 20 20 20 61 25 |= "".... a%| 000004c0 20 20 20 20 3d 20 34 0d 01 ea 1f 20 20 20 20 20 | = 4.... | 000004d0 20 c8 95 20 28 73 70 72 69 74 65 25 3f 61 25 29 | .. (sprite%?a%)| 000004e0 20 3e 3d 20 33 32 0d 01 f4 22 20 20 20 20 20 20 | >= 32..." | 000004f0 20 20 6e 61 6d 65 24 20 2b 3d 20 bd 28 73 70 72 | name$ += .(spr| 00000500 69 74 65 25 3f 61 25 29 0d 01 fe 16 20 20 20 20 |ite%?a%).... | 00000510 20 20 20 20 61 25 20 20 20 20 2b 3d 20 31 0d 02 | a% += 1..| 00000520 08 0b 20 20 20 20 20 20 ce 0d 02 12 20 20 20 20 |.. .... | 00000530 20 20 20 c8 99 20 34 36 2c 32 35 36 2b 35 34 2c | .. 46,256+54,| 00000540 73 61 25 2c 6e 61 6d 65 24 0d 02 1c 31 20 20 20 |sa%,name$...1 | 00000550 20 20 20 c8 99 20 34 36 2c 32 35 36 2b 34 30 2c | .. 46,256+40,| 00000560 73 61 25 2c 6e 61 6d 65 24 20 b8 20 2c 2c 2c 77 |sa%,name$ . ,,,w| 00000570 25 2c 68 25 2c 6d 61 73 6b 25 0d 02 26 25 20 20 |%,h%,mask%..&% | 00000580 20 20 20 20 70 69 63 25 20 3d 20 73 70 72 69 74 | pic% = sprit| 00000590 65 25 20 2b 20 73 70 72 69 74 65 25 21 33 32 0d |e% + sprite%!32.| 000005a0 02 30 25 20 20 20 20 20 20 6d 73 6b 25 20 3d 20 |.0% msk% = | 000005b0 73 70 72 69 74 65 25 20 2b 20 73 70 72 69 74 65 |sprite% + sprite| 000005c0 25 21 33 36 0d 02 3a 16 20 20 20 20 20 20 63 6f |%!36..:. co| 000005d0 6e 76 65 72 74 25 20 3d 20 31 0d 02 44 2b 20 20 |nvert% = 1..D+ | 000005e0 20 20 20 20 e7 20 73 70 72 69 74 65 25 21 34 30 | . sprite%!40| 000005f0 20 3c 3e 20 31 33 20 8c 20 63 6f 6e 76 65 72 74 | <> 13 . convert| 00000600 25 20 3d 20 30 0d 02 4e 1c 20 20 20 20 20 20 e7 |% = 0..N. .| 00000610 20 28 77 25 20 83 20 34 29 20 3c 3e 20 30 20 20 | (w% . 4) <> 0 | 00000620 8c 0d 02 58 18 20 20 20 20 20 20 20 20 63 6f 6e |...X. con| 00000630 76 65 72 74 25 20 3d 20 30 0d 02 62 18 20 20 20 |vert% = 0..b. | 00000640 20 20 20 20 20 72 65 73 75 6c 74 25 20 2b 3d 20 | result% += | 00000650 31 0d 02 6c 0b 20 20 20 20 20 20 cd 0d 02 76 16 |1..l. ...v.| 00000660 20 20 20 20 20 20 e7 20 63 6f 6e 76 65 72 74 25 | . convert%| 00000670 20 8c 0d 02 80 17 20 20 20 20 20 20 20 20 6f 66 | ..... of| 00000680 66 73 65 74 25 20 3d 20 30 0d 02 8a 1f 20 20 20 |fset% = 0.... | 00000690 20 20 20 20 20 e3 20 59 25 20 3d 20 30 20 b8 20 | . Y% = 0 . | 000006a0 28 68 25 20 2d 20 31 29 0d 02 94 25 20 20 20 20 |(h% - 1)...% | 000006b0 20 20 20 20 20 20 e3 20 58 25 20 3d 20 30 20 b8 | . X% = 0 .| 000006c0 20 28 77 25 20 2d 20 31 29 20 88 20 34 0d 02 9e | (w% - 1) . 4...| 000006d0 31 20 20 20 20 20 20 20 20 20 20 20 20 77 6f 72 |1 wor| 000006e0 64 25 20 20 20 20 20 20 20 20 20 20 20 20 3d 20 |d% = | 000006f0 28 70 69 63 25 21 6f 66 66 73 65 74 25 29 0d 02 |(pic%!offset%)..| 00000700 a8 38 20 20 20 20 20 20 20 20 20 20 20 20 e7 20 |.8 . | 00000710 6d 61 73 6b 25 20 8c 20 77 6f 72 64 25 20 3d 20 |mask% . word% = | 00000720 28 77 6f 72 64 25 20 80 20 6d 73 6b 25 21 6f 66 |(word% . msk%!of| 00000730 66 73 65 74 25 29 0d 02 b2 28 20 20 20 20 20 20 |fset%)...( | 00000740 20 20 20 20 20 20 70 6f 69 6e 74 65 72 25 21 6f | pointer%!o| 00000750 66 66 73 65 74 25 20 3d 20 77 6f 72 64 25 0d 02 |ffset% = word%..| 00000760 bc 24 20 20 20 20 20 20 20 20 20 20 20 20 6f 66 |.$ of| 00000770 66 73 65 74 25 20 20 20 20 20 20 20 20 20 2b 3d |fset% +=| 00000780 20 34 0d 02 c6 0f 20 20 20 20 20 20 20 20 20 20 | 4.... | 00000790 ed 0d 02 d0 0d 20 20 20 20 20 20 20 20 ed 0d 02 |..... ...| 000007a0 da 1f 20 20 20 20 20 20 20 20 70 6f 69 6e 74 65 |.. pointe| 000007b0 72 25 20 2b 3d 20 6f 66 66 73 65 74 25 0d 02 e4 |r% += offset%...| 000007c0 15 20 20 20 20 20 20 20 20 e7 20 6d 61 73 6b 25 |. . mask%| 000007d0 20 8c 0d 02 ee 19 20 20 20 20 20 20 20 20 20 20 | ..... | 000007e0 6f 66 66 73 65 74 25 20 3d 20 30 0d 02 f8 21 20 |offset% = 0...! | 000007f0 20 20 20 20 20 20 20 20 20 e3 20 59 25 20 3d 20 | . Y% = | 00000800 30 20 b8 20 28 68 25 20 2d 20 31 29 0d 03 02 27 |0 . (h% - 1)...'| 00000810 20 20 20 20 20 20 20 20 20 20 20 20 e3 20 58 25 | . X%| 00000820 20 3d 20 30 20 b8 20 28 77 25 20 2d 20 31 29 20 | = 0 . (w% - 1) | 00000830 88 20 34 0d 03 0c 38 20 20 20 20 20 20 20 20 20 |. 4...8 | 00000840 20 20 20 20 20 70 6f 69 6e 74 65 72 25 21 6f 66 | pointer%!of| 00000850 66 73 65 74 25 20 3d 20 28 6d 73 6b 25 21 6f 66 |fset% = (msk%!of| 00000860 66 73 65 74 25 29 20 82 20 2d 31 0d 03 16 26 20 |fset%) . -1...& | 00000870 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 66 66 | off| 00000880 73 65 74 25 20 20 20 20 20 20 20 20 20 2b 3d 20 |set% += | 00000890 34 0d 03 20 11 20 20 20 20 20 20 20 20 20 20 20 |4.. . | 000008a0 20 ed 0d 03 2a 0f 20 20 20 20 20 20 20 20 20 20 | ...*. | 000008b0 ed 0d 03 34 21 20 20 20 20 20 20 20 20 20 20 70 |...4! p| 000008c0 6f 69 6e 74 65 72 25 20 2b 3d 20 6f 66 66 73 65 |ointer% += offse| 000008d0 74 25 0d 03 3e 0d 20 20 20 20 20 20 20 20 cd 0d |t%..>. ..| 000008e0 03 48 0b 20 20 20 20 20 20 cd 0d 03 52 1e 20 20 |.H. ...R. | 000008f0 20 20 20 20 73 70 72 69 74 65 25 20 2b 3d 20 73 | sprite% += s| 00000900 70 72 69 74 65 25 21 30 0d 03 5c 09 20 20 20 20 |prite%!0..\. | 00000910 ed 0d 03 66 04 0d 03 70 07 20 20 cc 0d 03 7a 04 |...f...p. ...z.| 00000920 0d 03 84 14 20 20 20 20 72 65 73 75 6c 74 25 20 |.... result% | 00000930 3d 20 2d 31 0d 03 8e 04 0d 03 98 07 20 20 cd 0d |= -1........ ..| 00000940 03 a2 04 0d 03 ac 0d 3d 20 72 65 73 75 6c 74 25 |.......= result%| 00000950 0d ff |..| 00000952