jargon

Sparked x86 loadpack (wip)

Sep 4th, 2020
2,101
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) as string
  5. declare function nconcat(n as long,d as long) as 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. function loadpack(level as long) as string
  54.     dim as string gamename,levelname,rating,datapack
  55.     dim as long levelnum,packexists
  56.  
  57.     dim as string head,buffer,handle,pix
  58.     dim as long o
  59.  
  60.     dim as long filemode
  61.  
  62.     dim as long wid,hei
  63.  
  64.  
  65.     pix=space(0)
  66.     wid=0
  67.     hei=0
  68.  
  69.     buffer=space(0)
  70.     o=0
  71.     filemode=0
  72.     head=space(0)
  73.    
  74.     datapack="./datapack/level-"+nconcat(level,2)
  75.    
  76.     filemode=freefile
  77.     packexists=open(datapack+"/sprites.txt" for input as #filemode)
  78.  
  79.     if packexists then
  80.         gamename="Sparked x86"
  81.         levelnum=0
  82.         levelname="Placeholder"
  83.         rating="Debug Mode"
  84.     else
  85.         do while not(eof(filemode))
  86.             line input #filemode,buffer
  87.             o=instr(1,buffer,"( ")
  88.             if o>0 then
  89.                 head=left(buffer,o-1)
  90.                 if head="DeclareGlobalImage" then
  91.                     buffer=mid(buffer,len(head)+2)
  92.                    
  93.                     o=instr(1,buffer," , ")
  94.                     handle=left(buffer,o-1)
  95.                     buffer=mid(buffer,len(handle)+3)
  96.  
  97.                     o=instr(1,buffer," , ")
  98.                     wid=left(buffer,o-1)
  99.                     pix=pix+nconcat(wid,2)
  100.                     buffer=mid(buffer,len(wid)+3)
  101.                    
  102.                     o=instr(1,buffer," , ")
  103.                     hei=left(buffer,o-1)
  104.                     pix=pix+nconcat(hei,2)
  105.                     buffer=mid(buffer,len(hei)+3)
  106.                    
  107.                     if buffer="_" then exit do
  108.                 else
  109.                     do while len(buffer)>0
  110.                         o=instr(1,buffer,space(2))
  111.                         if o=1 then
  112.                             buffer=mid$(buffer,o+1)
  113.                         else
  114.                             exit do
  115.                         end if
  116.                        
  117.                         o=instr(1,buffer,",")
  118.                         if o>0 then
  119.                             pix=pix+lnconcat(left(buffer,o-1),1)
  120.                             buffer=mid(buffer,len(pix)+1)
  121.                         elseif buffer=" , _"
  122.                             buffer=space(0)
  123.                         elseif buffer="  )"
  124.                             buffer=space(0)
  125.                         end if
  126.                     loop
  127.                 end if
  128.             end if
  129.         loop
  130.    
  131.         loadpack=pix
  132.    
  133.     end if
  134.  
  135.     close #filemode
  136.    
  137. end function
  138.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×