Advertisement
jargon

fastvds_load from fastscan.bas

Mar 4th, 2021
3,161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. sub fastvds_load ( index as integer = 2)
  2.    
  3.     dim as integer slide=0,col=0,row=0,headw=16,headh=16
  4.     redim as string slides(),lines(),pixies(), dimensions()
  5.     dim as string buffer,filename
  6.     filename=".\datapack\fastvds\map"+string_crop(index,3,"0")+".vds"  
  7.    
  8.     '[?] create maps array
  9.     if ubound(maps,0)=0 then
  10.         redim preserve maps(0 to 0)
  11.     end if
  12.    
  13.     '[?] expand maps array by index
  14.     if ubound(maps,1)<index then
  15.         redim preserve maps(0 to index)
  16.     end if
  17.    
  18.     '[?] pull buffer by filename
  19.     fastload filename, buffer
  20.  
  21.     '[?] capture slides
  22.     fasttok buffer, gt, slides()
  23.    
  24.     '[?] step through slides
  25.     for slide=lbound(slides,1) to ubound(slides,1) step 1
  26.        
  27.         '[?] skip over blank slides
  28.         if not(len(slides(slide))=0) then
  29.            
  30.             '[?] fit slides to current map
  31.             if ubound(maps,1)=0 then
  32.                 redim maps(0 to 0)
  33.             else
  34.                 redim preserve maps(lbound(maps,1) to slide-lbound(slides,1))
  35.             end if
  36.            
  37.             '[?] capture lines from current slide
  38.             fasttok slides(slide),crlf,lines()
  39.            
  40.             '[?] check that first line in current slide is not blank
  41.             if not(len(lines(lbound(lines,1)))=0) then
  42.                
  43.                 '[?] check first line in slide for map dimensions
  44.                 fasttok lines(lbound(lines,1)),comma,dimensions()
  45.                
  46.                 '[?] check dimensions validity
  47.                 if lbound(dimensions,1)=0 and ubound(dimensions,1)>=2 then
  48.                    
  49.                     maps(index).w=val(dimensions(lbound(dimensions,1)+1))
  50.                     maps(index).h=val(dimensions(lbound(dimensions,1)+2))
  51.                    
  52.                     '''[!!!] irrelevant code
  53.                     '''tiles(ubound(tiles,1)).img=imagecreate(headw,headh,0,8)
  54.                
  55.                 end if
  56.             end if
  57.            
  58.             '[?] check that map size is valid
  59.             if maps(index).w>0 and maps(index).h>0 then
  60.            
  61.                 '[?] size map to fit data          
  62.                 redim preserve (maps(index).px)(0 to maps(index).w-1,0 to maps(index).h-1)
  63.  
  64.                 '[?] populate map
  65.                 for row=0 to maps(index).h-1 step 1
  66.                    
  67.                     '[?] capture data from map row
  68.                     fasttok lines(row+1),comma,pixies()
  69.                 for col=0 to maps(index).w-1 step 1
  70.                     '[?] populate data from map col
  71.                     if col>=lbound(pixies,1) and col<=ubound(pixies,1) then
  72.                         maps(index).px(col,row)=val(pixies(col))
  73.                     end if
  74.                 next col
  75.                 next row
  76.             end if
  77.         end if     
  78.     next slide
  79. end sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement