Posted: 5th Mar 2003 17:29
i'll be posting up a good few of these over the comming week for DarkBasic Standard/Enhanced/Professional, you can basically think of these as premade shortcuts for caluclations that normally you'd have to figure out yourself.

RavenStd.h.dba
+ Code Snippet
remstart
/*
   Author:    Raven Vegeta [Robert Lettan]
   Version:   0.0.1.0
   Date:      03-03-2003
*/
remend
`** RavenStd.h.dba ****

remstart
 /* Place this within your main game dba //
   TRUE        = 1
   FALSE       = 0
   void        = 0
   _Sprite     = ( bitLeft( asc( "R" ),16 ) ) + ( bitLeft( asc( "P" ),8 ) ) + ( asc( "S" ) )
   _Bitmap     = ( bitLeft( asc( "P" ),16 ) ) + ( bitLeft( asc( "M" ),8 ) ) + ( asc( "B" ) )
   _File       = ( bitLeft( asc( "E" ),16 ) ) + ( bitLeft( asc( "L" ),8 ) ) + ( asc( "F" ) )
   _Memblock   = ( bitLeft( asc( "K" ),16 ) ) + ( bitLeft( asc( "B" ),8 ) ) + ( asc( "M" ) )
   _Image      = ( bitLeft( asc( "G" ),16 ) ) + ( bitLeft( asc( "M" ),8 ) ) + ( asc( "I" ) )
   _Object     = ( bitLeft( asc( "J" ),16 ) ) + ( bitLeft( asc( "B" ),8 ) ) + ( asc( "O" ) )
   iBool       = 2
   iBit        = 8
   iByte       = 256
   iWord       = 65535
   iDword      = 2147483648
 */
remend

`// BitShift >
function BitRight( dwInput, dwStep )
`// private declarations
 dwReturn = dwInput / ( iBool^dwStep )
endfunction dwReturn

`// AutoMatic Resource Allocation
function ALLOCATE( dwType )
`// private declarations
dwIndex = 1 :`// set default search value

`// automatically allocate selected resource at next available space
select dwType
   `// sprite
   case _Sprite
      while sprite exist( dwIndex ) = TRUE
         inc dwIndex
         if dwIndex > iWord then dwIndex = 0 : end
      endwhile
   endcase
   `// bitmap
   case _Bitmap
      while bitmap exist( dwIndex ) = TRUE
         inc dwIndex
         if dwIndex > ( iByte/iBit ) then dwIndex = 0 : end
      endwhile
   endcase
   `// file
   case _File
      while file exist( dwIndex ) = TRUE
         inc dwIndex
         if dwIndex > ( iByte/iBit ) then dwIndex = 0 : end
      endwhile
   endcase
   `// memblock
   case _Memblock
      while memblock exist( dwIndex ) = TRUE
         inc dwIndex
         if dwIndex > iWord then dwIndex = 0 : end
      endwhile
   endcase
   `// image
   case _Image
      while image exist( dwIndex ) = TRUE
         inc dwIndex
         if dwIndex > iWord then dwIndex = 0 : end
      endwhile
   endcase
   `// Object
   case _Object
      while object exist( dwIndex ) = TRUE
         inc dwIndex
         if dwIndex > iWord then dwIndex = 0 : end
      endwhile
   endcase
endselect

 dwReturn = dwIndex :`// allocate number found ... if 0 means no available spaces
endfunction dwReturn

`/* Copyright© 2003 Robert Lettan, FMTau Labs, L,L,C. All Rights Reserved. */


DarkBasic Professional users can drop the .dba at the end, this is only for back compatibility

as i'm plugging these out i won't actually be testing them as i build them - so feel free to post up bugs you get
Posted: 5th Mar 2003 18:23
So how about... you *do* test them.
I hope your contribution to C&C generals was checked properly. :-p
Or I might resent paying money for it.
Posted: 5th Mar 2003 18:29
lmao... my contributions to C&C Generals was mostly art based

these i'm not testing what so ever, if they don't work i wanna know - cause in the past 30mins i've coded around 15functions, and i've got alot more to go ... i have literally 3 days to finish a fully library, after that test them, etc...

i mean they should be oki, but just incase lemme know if they're not
Posted: 5th Mar 2003 19:00
Fair do's.
What are you better at: art or programming?
Or are you multitalented?
Posted: 5th Mar 2003 20:10
far far far better at art... the only programming i ever do with any proficency is artwork based (like Shaders)

i've found an odd bug with the above code, might just be my DarkEdit playing up (oftenly does) - but unless i put the BitShifting within the main file they don't like to be recognised and DarkEdit keeps telling me that the array isn't initilised when trying to use it.

anyone else get this, because i'm sure it used to work - and i have a feeling that because i've taken all of the values and given them designations might be the reason.
Posted: 5th Mar 2003 21:26
Well, your functions will not work in DBpro cause there are no global directives for the variables you assigned outside the functions. Your functions will not work in DBclassic for pretty much the same reasons. Plus if you use DarkEdit's pre-processor, the Global directive will only affect the main source code and not the included libraries.
Posted: 5th Mar 2003 21:39
so in other yes, its because the blasted change from variables - but even so ... that would mean it'd return 0^dwStep, but it doesn't even recognise the function - that is the weird part
Posted: 8th Mar 2003 0:04
To make the variable global in DBv1, turn them into 1 value arrays e.g

dim iBool(1)
iBool(1)=2

Also, your while file exist( dwIndex )= TRUe
is wrong, because file exist() checks for a string$ value of a file, not a file number, and I think DB refuses to compile when there's any error in the library file.