License GNU General Public License, version 2
Lines 29
Keywords
emulators (1) ZX-Spectrum (1)
Permissions
Owner: nitrofurano
Group Owner: sdlBasic
Viewable by Everyone
Editable by All Siafoo Users
Hide
Siafoo is here to make coding less frustrating and to save you time. Join Siafoo Now or Learn More

Converts binary files into .tap files Atom Feed 0

In Brief Converts binary files into .tap files used on ZX-Spectrum emulators
# 's
 1'- bin2tap.sdlbas
2'- converts binary files into .tap files used on ZX-Spectrum emulators
3'- Paulo Silva - 0810210949 - GPL License
4finp$="binaryfile.bin":fout$=finp$+"_.tap"
5dim wrk4[49152],wrk5[49152],sphdr[32]:for i=0 to 31:sphdr[i]=0:next
6sphdr[0]=19:sphdr[3]=3:sphdr[19]=128:sphdr[23]=255
7tapln=0
8specfinp$=left$(finp$+" ",10)
9open finp$ for input as #1:flsize=lof(1):close #1
10if flsize<=65533 and flsize >=1 then:
11 open finp$ for input as #1:adrp=0
12 while eof(1)=0:wrk5[adrp]=readbyte(1):adrp+=1:wend
13 close #1
14 flsize2=flsize+2
15 flsizeh=(int(flsize/256)) mod 256:flsizel=flsize mod 256
16 flsize2h=(int(flsize2/256)) mod 256:flsize2l=flsize2 mod 256
17 for i=0 to 9:u=asc(mid$(specfinp$,i+1,1)):wrk4[tapln+i+4]=u:next
18 wrk4[tapln+14]=flsizel:wrk4[tapln+15]=flsizeh
19 wrk4[tapln+21]=flsize2l:wrk4[tapln+22]=flsize2h
20 checksum=0
21 for i=2 to 19:checksum=bitwisexor(checksum,wrk4[tapln+i]):next
22 wrk4[tapln+20]=checksum:checksum=255
23 for i=0 to flsize-1:wrk4[tapln+i+24]=wrk5[i]:checksum=bitwisexor(checksum,wrk5[i]):next
24 wrk4[tapln+flsize+24]=checksum:tapln=tapln+(flsize+25)
25 wrk4[0]=19:wrk4[3]=3:wrk4[19]=128:wrk4[23]=255
26 open fout$ for output as #2
27 for i=0 to tapln-1:writebyte(2,wrk4[i]):next
28 close #2
29 end if

Converts binary files into .tap files used on ZX-Spectrum emulators