tic2txt.sdlbas 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #! /usr/bin/sdlbrt
  2. finp$="AntarcticAdventureTune_WaldteufelWaltz.tic"
  3. function writehex(v1,q1)
  4. if q1=0 then:
  5. v2=int(v1/16)
  6. else:
  7. v2=v1 mod 16
  8. end if
  9. v3=48+v2
  10. if v2>9 then
  11. v3=v3+7
  12. end if
  13. return v3
  14. end function
  15. dim bline[16],bnam$[16]
  16. for i=0 to 15:bline[i]=32:next
  17. bline[0x01]=4:bline[0x02]=4:bline[0x0C]=3:bline[0x0D]=3:bline[0x0A]=16:bline[0x04]=240
  18. bnam$[00]="unknown":bnam$[01]="sprites_bg":bnam$[02]="sprites_fg":bnam$[03]="cover"
  19. bnam$[04]="map":bnam$[05]="code":bnam$[06]="unknown":bnam$[07]="unknown"
  20. bnam$[08]="unknown":bnam$[09]="sfx":bnam$[10]="waveform":bnam$[11]="unknown"
  21. bnam$[12]="palette":bnam$[13]="tunes_notes":bnam$[14]="tunes_frames":bnam$[15]="unknown"
  22. open finp$ for input as #1
  23. while eof(1)=0:
  24. qs=readbyte(1)
  25. s0=readbyte(1)
  26. s1=readbyte(1)
  27. s2=readbyte(1)
  28. st=(s2*65536)+(s1*256)+s0
  29. suf$=".hex":if qs=5 then:suf$=".lua":end if
  30. open finp$+"_"+str$(qs)+"_"+bnam$[qs]+suf$ for output as #2
  31. for qq=0 to st-1
  32. rb=readbyte(1)
  33. if qs=5 then
  34. writebyte(2,rb)
  35. else
  36. writebyte(2,writehex(rb,0))
  37. writebyte(2,writehex(rb,1))
  38. if (qq mod bline[qs])=bline[qs]-1 then:writebyte(2,0x0A):end if
  39. if ((qs=1) or (qs=2)) and ((qq mod 32)=31) then:writebyte(2,0x0A):end if
  40. end if
  41. next
  42. close #2
  43. wend
  44. close #1