Advertisement
jargon

Sparked x86 loadpack.bas (wip)

Sep 4th, 2020
2,327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. dim as long level
  2. level=4
  3.  
  4. declare sub loadpack(level as long)
  5. declare function nconcat(n as long,d as long) asec string
  6. declare Sub Intro(level as long)
  7.  
  8. function nconcat(n as long,d as long) as string
  9.     dim as string sn
  10.     sn=str(n)
  11.     while left(sn,1)=chr(32):sn=right(sn,len(sn)-1):wend
  12.     if len(sn)<d then sn=string(d-len(sn),"0")+sn
  13.     nconcat=sn
  14. end function
  15.  
  16. Sub Intro(level as long)
  17.     color 15,1
  18.     dim as string gamename,levelname,rating,datapack
  19.     dim as long levelnum,packexists
  20.  
  21.     dim as long filemode
  22.     datapack="./datapack/level-"+nconcat(level,2)
  23.    
  24.     filemode=freefile
  25.     packexists=open(datapack+"/summary.txt" for input as #filemode)
  26.    
  27.     if packexists then
  28.         gamename="Sparked x86"
  29.         levelnum=0
  30.         levelname="Placeholder"
  31.         rating="Debug Mode"
  32.     else
  33.         input #filemode,gamename
  34.         input #filemode,levelnum,levelname
  35.         input #filemode,rating
  36.     end if
  37.  
  38.     close #filemode
  39.        
  40.     cls : randomize()
  41.    
  42.     locate 1,1 : print datapack
  43.    
  44.     locate  5,34 : print gamename;
  45.     locate  7,28 : print "LEVEL "+nconcat(levelnum,2)+": "+levelname;
  46.     locate  9,28 : print "RATING: "+rating;
  47.     locate 15,24 : print "PUSH THE <ENTER> KEY TO START";
  48.    
  49.     while getkey()<>13 : wend
  50.  
  51. end sub
  52.  
  53. declare sub loadpack(level as long)
  54.     dim as string gamename,levelname,rating,datapack
  55.     dim as long levelnum,packexists
  56.  
  57.     dim as string head,buffer,handle
  58.     dim as long o
  59.  
  60.     dim as long filemode
  61.  
  62.     dim as long wid,hei
  63.    
  64.     wid=0
  65.     hei=0
  66.  
  67.     buffer=space(0)
  68.     o=0
  69.     filemode=0
  70.     head=space(0)
  71.    
  72.     datapack="./datapack/level-"+nconcat(level,2)
  73.    
  74.     filemode=freefile
  75.     packexists=open(datapack+"/sprites.txt" for input as #filemode)
  76.  
  77.     if packexists then
  78.         gamename="Sparked x86"
  79.         levelnum=0
  80.         levelname="Placeholder"
  81.         rating="Debug Mode"
  82.     else
  83.         do while not(eof(filemode))
  84.             line input #filemode,buffer
  85.             o=instr(1,buffer,"( ")
  86.             if o>0 then
  87.                 head=left(buffer,o-1)
  88.                 if head="DeclareGlobalImage" then
  89.                     buffer=mid(buffer,len(head)+2)
  90.                    
  91.                     o=instr(1,buffer," , ")
  92.                     handle=left(buffer,o-1)
  93.                     buffer=mid(buffer,len(handle)+3)
  94.  
  95.                     o=instr(1,buffer," , ")
  96.                     wid=left(buffer,o-1)
  97.                     buffer=mid(buffer,len(wid)+3)
  98.                    
  99.                     o=instr(1,buffer," , ")
  100.                     hei=left(buffer,o-1)
  101.                     buffer=mid(buffer,len(hei)+3)
  102.                    
  103.                     if buffer="_" then exit do
  104.                 else
  105.                     do while len(buffer)>0
  106.                         o=instr(1,buffer,space(2))
  107.                         if o=1 then
  108.                             buffer=mid$(buffer,o+1)
  109.                         else
  110.                             exit do
  111.                         end if
  112.                        
  113.                         o=instr(1,buffer,",")
  114.                         if o>0 then
  115.                             pix=left(buffer,o-1)
  116.                             buffer=mid(buffer,len(pix)+1)
  117.                         elseif buffer=" , _"
  118.                             buffer=space(0)
  119.                         elseif buffer="  )"
  120.                             buffer=space(0)
  121.                         end if
  122.                     loop
  123.                 end if
  124.             end if
  125.         loop
  126.     end if
  127.  
  128.     close #filemode
  129.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement