SHARE
TWEET

tic2txt.sdlbas

a guest Dec 2nd, 2017 205 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /usr/bin/sdlbrt
  2.  
  3. finp$="config.tic"
  4.  
  5. function writehex(v1,q1)
  6.   if q1=0 then:
  7.     v2=int(v1/16)
  8.   else:
  9.     v2=v1 mod 16
  10.     end if
  11.   v3=48+v2
  12.   if v2>9 then
  13.     v3=v3+7
  14.     end if
  15.   return v3
  16.   end function
  17.  
  18. dim bline[16],bnam$[16]
  19. for i=0 to 15:bline[i]=32:next
  20. bline[0x01]=4:bline[0x02]=4:bline[0x0C]=3:bline[0x0D]=3:bline[0x0A]=16
  21. bnam$[00]="unknown":bnam$[01]="sprites_bg":bnam$[02]="sprites_fg":bnam$[03]="cover"
  22. bnam$[04]="map":bnam$[05]="code":bnam$[06]="unknown":bnam$[07]="unknown"
  23. bnam$[08]="unknown":bnam$[09]="sfx":bnam$[10]="waveform":bnam$[11]="unknown"
  24. bnam$[12]="palette":bnam$[13]="tunes_notes":bnam$[14]="tunes_frames":bnam$[15]="unknown"
  25.  
  26. open finp$ for input as #1
  27. while eof(1)=0:
  28.   qs=readbyte(1)
  29.   s0=readbyte(1)
  30.   s1=readbyte(1)
  31.   s2=readbyte(1)
  32.   st=(s2*65536)+(s1*256)+s0
  33.  
  34.   suf$=".hex":if qs=5 then:suf$=".lua":end if
  35.  
  36.   open finp$+"_"+str$(qs)+"_"+bnam$[qs]+suf$ for output as #2
  37.   for qq=0 to st-1
  38.     rb=readbyte(1)
  39.     if qs=5 then
  40.       writebyte(2,rb)
  41.     else
  42.       writebyte(2,writehex(rb,0))
  43.       writebyte(2,writehex(rb,1))
  44.       if (qq mod bline[qs])=bline[qs]-1 then:writebyte(2,0x0A):end if
  45.       if ((qs=1) or (qs=2)) and ((qq mod 32)=31) then:writebyte(2,0x0A):end if
  46.       end if
  47.     next
  48.  
  49.   close #2
  50.   wend
  51. close #1
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top