Public Domain part of Grey Alien Framework

Miscellaneous Forums/General Discussion/Public Domain part of Grey Alien Framework

Hi all, here's the public domain part of the framework in case you are interested. Each function has a brief explanation saying what it does. Some of it is generally pretty useful and some of it has a very specific purpose.

The code either came from posts in threads on Blitzmax.com or code archives and I asked people's permission to use it (publicly or via email), or the code was emailed to me privately or came via my Framework forums (so is not actually public domain). Also some of the code is slightly modified by me.

This code is about 3% of my framework (based on line count)

'BLITZ MAX *PUBLIC DOMAIN* COMMON CODE (Functions)
'Used in the Grey Alien Blitzmax Game Framework.
'Composition, explanations and some modifications by Jake Birkett (Grey Alien).
'Code credited to authors but is not copyright.
'V1.10 Released 20/01/09

'Note that many of these functions need Windows API calls declared as Extern.
'You'll have to add those yourself if you want to use the functions.

'by Manel Ibáñez for use with ccFastRand()
Extern "C"
	Function crndseed:Int(val:Int) = "srand"
	Function _crand:Int () = "rand"
End Extern

'By Bruce Henderson for use with ccGetSharedUserDataFolder()
?MacOS
Extern
	Function FSFindFolder:Int( vRefNum:Int ,folderType:Int ,createFolder:Int ,foundRef:Byte Ptr )
	Function FSRefMakePath:Int( ref:Byte Ptr,path:Byte Ptr, maxPath:Int )
End Extern
?

' -----------------------------------------------------------------------------
' ccAddLists: Adds one list to another
' By Plash
' -----------------------------------------------------------------------------
Function ccAddLists:Int(dest:TList, from:TList)	
	If dest = Null Or from = Null Or from.Count() = 0 Then Return False
	
	For Local obj:Object = EachIn from		
		dest.AddLast(obj)		
	Next
	
	Return True	
End Function

' -----------------------------------------------------------------------------
' ccCircleHalfWidthAtY: Return half the width of a circle of a specifed radius at a given y coord
' by David Bird (although it's really just a simple formula)
' -----------------------------------------------------------------------------
Function ccCircleHalfWidthAtY:Float( radius:Float, y:Float )
	Return Sqr(radius*radius - y*y )
End Function

' -----------------------------------------------------------------------------
' ccCircleLineIntersect2: Pass in coords for a line and circle and this will tell you if they intersect
' by Oddball (adapted from TomToad's code) modified by Grey Alien 
' -----------------------------------------------------------------------------
Function ccCircleLineIntersect2%(x1:Double, y1:Double, x2:Double, y2:Double, px:Double, py:Double, r:Double)
	'I upgraded all params and local variables from Floats to Doubles (Grey Alien)
	Local sx:Double= x2-x1
	Local sy:Double= y2-y1

	Local q:Double= ((px-x1) * (x2-x1) + (py - y1) * (y2-y1)) / (sx*sx + sy*sy)	
	If q < 0.0 Then q = 0.0
	If q > 1.0 Then q = 1.0
	
	Local cx:Double=(1-q)*x1+q*x2
	Local cy:Double=(1-q)*y1 + q*y2
		
	If ccPointToPointDist(px,py,cx,cy) < r
		Return True
	Else
		Return False
	EndIf
End Function 

' -----------------------------------------------------------------------------
' ccCopyImage: Creates a copy of a TImage
' by BlackSp1der
' -----------------------------------------------------------------------------
Function ccCopyImage:TImage(image:TImage)
	Local newimage:TImage=CreateImage(image.width,image.height,image.frames.Length,image.flags)
	newimage.handle_x=image.handle_x
	newimage.handle_y=image.handle_y
	newimage.mask_r=image.mask_r
	newimage.mask_g=image.mask_g
	newimage.mask_b=image.mask_b

	For Local frame:Int=0 Until image.Frames.Length
		Local pixmap:TPixmap=LockImage(image,frame)
		'pixmap copy
		newimage.SetPixmap(frame,pixmap.Copy())
		'pixmap clone
		'newimage.pixmaps[frame]=image.pixmaps[frame]
		'newimage.frames[frame]=image.frames[frame]
		'newimage.seqs[frame]=image.seqs[frame]
		UnlockImage(image,frame)
	Next

	Return newimage
EndFunction

' -----------------------------------------------------------------------------
' ccCopyImageRect: Copies part of an image onto another image
' by James Chamblin
' -----------------------------------------------------------------------------
Function ccCopyImageRect(Source:TImage,SX:Int,SY:Int,SWidth:Int,SHeight:Int,Dest:TImage,DX:Int,DY:Int)
	'get the pixmap for the images
	Local SourcePix:TPixmap = LockImage(Source)
	Local DestPix:TPixmap = LockImage(Dest)
	
	'find the dimentions
	Local SourceWidth:Int = PixmapWidth(SourcePix)
	Local SourceHeight:Int = PixmapHeight(SourcePix)
	Local DestWidth:Int = PixmapWidth(DestPix)
	Local DestHeight:Int = PixmapHeight(DestPix)
	
	If SX < SourceWidth And SY < SourceHeight And DX < DestWidth And DY < DestHeight 'make sure rects are on image
		If SX+SWidth > SourceWidth Then SWidth = SourceWidth - SX 'bound the coordinates to the image area
		If SY+SHeight > SourceHeight Then SHeight = SourceHeight - SY
		If DX+SWidth > DestWidth Then SWidth = DestWidth - DX 'Make sure coordinates will fit into the destination
		If DY+SHeight > DestHeight Then SHeight = DestHeight - DY
		
		'find the pitch
		Local SourcePitch:Int = PixmapPitch(SourcePix)
		Local DestPitch:Int = PixmapPitch(DestPix)
	
		'pointers To the first pixel of pixmaps
		Local SourcePtr:Byte Ptr = PixmapPixelPtr(SourcePix) + SY * SourcePitch + SX * 4
		Local DestPtr:Byte Ptr = PixmapPixelPtr(DestPix) + DY * DestPitch + DX * 4
		
		'copy pixels over one line at a time
		For Local i:Int = 1 To SHeight
			MemCopy(DestPtr,SourcePtr,SWidth*4)
			SourcePtr :+ SourcePitch
			DestPtr :+ DestPitch
		Next
	End If
	
	'unlock the buffers
	UnlockImage(Source)
	UnlockImage(Dest)
End Function

' -----------------------------------------------------------------------------
' ccCopyImageToImage: Copies one TImage to another with a variety of modes
' by Dave Munsie
' -----------------------------------------------------------------------------
Function ccCopyImageToImage(Source:TImage,SX:Int,SY:Int,SWidth:Int,SHeight:Int,Dest:TImage,DX:Int,DY:Int,flags:Int=0)
  '
  ' flags: 0 = Normal  1 = Mirror  2 = Flip  3 = Mirror and Flip
  '
  Local SourcePix:TPixmap = LockImage(Source)
  Local DestPix:TPixmap = LockImage(Dest)
  Local SourceWidth:Int = PixmapWidth(SourcePix)
  Local SourceHeight:Int = PixmapHeight(SourcePix)
  Local DestWidth:Int = PixmapWidth(DestPix)
  Local DestHeight:Int = PixmapHeight(DestPix)
  If SX < SourceWidth And SY < SourceHeight And DX < DestWidth And DY < DestHeight 
  If SX+SWidth > SourceWidth Then SWidth = SourceWidth - SX 
  If SY+SHeight > SourceHeight Then SHeight = SourceHeight - SY
  If DX+SWidth > DestWidth Then SWidth = DestWidth - DX 
  If DY+SHeight > DestHeight Then SHeight = DestHeight - DY
  Select flags
   Case 0 ' Normal
    For Local py:Int = 0 To SHeight-1 
     For Local px:Int = 0 To SWidth- 1
      WritePixel(DestPix,DX+px,DY+py,ReadPixel(SourcePix,SX+px,SY+py))
     Next 
    Next
   Case 1 ' Mirror
    For Local py:Int = 0 To SHeight-1 
     For Local px:Int = 0 To SWidth- 1
      WritePixel(DestPix,DX+px,DY+py,ReadPixel(SourcePix,(SX+(SWidth-1))-px,SY+py))
     Next
    Next
   Case 2 ' Flip
    For Local py:Int = 0 To SHeight-1 
     For Local px:Int = 0 To SWidth- 1
      WritePixel(DestPix,DX+px,DY+py,ReadPixel(SourcePix,SX+px,(SY+(SHeight-1))-py))
     Next
    Next
   Case 3 ' Mirror and Flip
    For Local py:Int = 0 To SHeight-1 
     For Local px:Int = 0 To SWidth- 1
      WritePixel(DestPix,DX+px,DY+py,ReadPixel(SourcePix,(SX+(SWidth-1))-px,(SY+(SHeight-1))-py))
     Next
    Next
  End Select
 EndIf
 UnlockImage(Source)
 UnlockImage(Dest)
End Function

' -----------------------------------------------------------------------------
' ccCreateFrames: Caches an Image or Anim Image in VRAM
' by Ian Duff
' -----------------------------------------------------------------------------
Function ccCreateFrames(image:TImage) 
	'Use this to cache an image or animimage in VRAM for quicker drawing later.
	For Local c%=0 Until image.frames.length
		image.Frame(c)
	Next
End Function

' -----------------------------------------------------------------------------
' ccDrawImageArea: Draws part of an image. (faster?)
' by Ian Duff fixed by Grey Alien
' -----------------------------------------------------------------------------
Function ccDrawImageArea(image:TImage, x#, y#, rx#, ry#, rw#, rh#, theframe%=0)
 'Note that this code works fine in DirectX or OpenGL on PCs - it autodetects (Grey Alien).
 'Warning: make sure that none of your images have pixels right on the edge otherwise
 'when drawing clipped, they may leave smear in the clipped area! (Grey Alien).
  Local origin_x#, origin_y# ; GetOrigin (origin_x, origin_y)
  Local tw% = ccDrawImageAreaPow2Size(image.width)
  Local th% = ccDrawImageAreaPow2Size(image.height)
  Local rw1#  = rx + rw
  Local rh1#  = ry + rh
  Local x0# = -image.handle_x, x1# = x0 + rw
  Local y0# = -image.handle_y, y1# = y0 + rh
  
  If rw1 > image.width
    x1 = x0 + rw + image.width - rw1
    rw1 = image.width
  EndIf
   
  If rh1 > image.height
    y1 = y0 + rh + image.height - rh1
    rh1 = image.height
  EndIf
?Win32
  If TD3D7ImageFrame(image.frame(theframe))
    Local frame:TD3D7ImageFrame = TD3D7ImageFrame(image.frame(theframe))
    
    frame.setUV(rx / tw, ry / th, rw1 / tw, rh1 / th)
	frame.Draw x0, y0, x1, y1, x + origin_x, y + origin_y
    frame.setUV(0, 0, image.width / Float(tw), image.height / Float(th))
  Else
?
    Local frameA:TGLImageFrame = TGLImageFrame (image.frame(theframe))
    'Protect against frameA being null due to alt+tab. (Grey Alien)
	If frameA<>Null Then
	    frameA.u0 = rx / tw
	    frameA.v0 = ry / th
	    frameA.u1 = rw1 / tw
	    frameA.v1 = rh1 / th
	    
	    frameA.Draw x0, y0, x1, y1, x + origin_x, y + origin_y
	    
	    frameA.u0 = 0
	    frameA.v0 = 0
	    frameA.u1 = image.width / Float(tw)
	    frameA.v1 = image.height / Float(th)
	EndIf
?Win32
  EndIf
?
  
  Function ccDrawImageAreaPow2Size%(n%)
    Local ry% = 1
    
    While ry < n
      ry :* 2
    Wend
    
    Return ry
  End Function
End Function

' -----------------------------------------------------------------------------
' ccDrawImageRect: Draws part of an image. (slow? See also ccDrawImageArea())
' by TonyG
' -----------------------------------------------------------------------------
Function ccDrawImageRect(image:TImage,x:Int,y:Int,xs:Int,ys:Int,width:Int,height:Int)
    DrawImage LoadImage(PixmapWindow(LockImage(image),xs,ys,width,height)),x,y
End Function

' -----------------------------------------------------------------------------
' ccDrawOnPixmap: Allows you to draw an image on a pixmap whilst retaining alpha properties
' By MichaelB
' -----------------------------------------------------------------------------
Function ccDrawOnPixmap(image:TImage, framenr:Int = 0, Pixmap:TPixmap, x:Int, y:Int, alpha:Float = 1.0, light:Float = 1.0) 
      Local TempPix:TPixmap = Null
	  If image = Null Then Throw "image doesnt exist"
	  If framenr = 0 Then TempPix = LockImage(image) 
      If framenr > 0 Then TempPix = LockImage(image, Framenr) 
	  For Local i:Int = 0 To ImageWidth(image) - 1
	    For Local j:Int = 0 To ImageHeight(image) - 1
		  If x + i < pixmap.width And y + j < pixmap.Height
			Local sourcepixel:Int = ReadPixel(TempPix, i,j)
			Local destpixel:Int = ReadPixel(pixmap, x+i,y+j)
			Local destA:Float = ARGB_Alpha(destpixel) 
			Local sourceA:Float = ARGB_Alpha(sourcepixel) * alpha
			If sourceA = 255 Then destA = 0
			'remove comment to remove unneeded calculations 
			'but only when light/alpha not used!
'			If sourceA <> 255 And sourceA <> 0
				Local destR:Float = ARGB_Red(destpixel) 
				Local destG:Float = ARGB_Green(destpixel) 
				Local destB:Float = ARGB_Blue(destpixel) 
				Local SourceR:Float = ARGB_Red(Sourcepixel) 
				Local SourceG:Float = ARGB_Green(Sourcepixel) 
				Local SourceB:Float = ARGB_Blue(Sourcepixel) 
					Local AlphaSum:Int = destA + sourceA

					sourceR = (sourceR * light * sourceA / AlphaSum) + destA / AlphaSum * (destR * destA / AlphaSum) 
					sourceG = (sourceG * light * sourceA / AlphaSum) + destA / AlphaSum * (destG * destA / AlphaSum) 
					sourceB = (sourceB * light * sourceA / AlphaSum) + destA / AlphaSum * (destB * destA / AlphaSum) 
					If AlphaSum > 255 Then AlphaSum = 255
					sourcepixel = ARGB_Color(AlphaSum, SourceR, sourceG, sourceB) 
'			EndIf
			If SourceA <> 0 Then WritePixel(Pixmap, x + i, y + j, sourcepixel) 
		  EndIf
		Next
	  Next
	  If framenr = 0 UnlockImage(image)
	  If framenr > 0 UnlockImage(image, framenr)
End Function

Function ARGB_Alpha:Int(ARGB:Int)
 Return (argb Shr 24) & $ff
End Function

Function ARGB_Red:Int(ARGB:Int)
  Return (argb Shr 16) & $ff
End Function

Function ARGB_Green:Int(ARGB:Int)
  Return (argb Shr 8) & $ff
End Function

Function ARGB_Blue:Int(ARGB:Int)
 Return (argb & $ff) 
End Function

Function ARGB_Color:Int(alpha:Int,red:Int,green:Int,blue:Int)
 Return (Int(alpha * $1000000) + Int(RED * $10000) + Int(green * $100) + Int(blue)) 
End Function

' -----------------------------------------------------------------------------
' ccDrawTextSpaced: DrawText with a specified space between each character
' By Marius Winkelmann
' -----------------------------------------------------------------------------
Function ccDrawTextSpaced(t$,x#,y#, space:Int=0)
	'Same as the built in BMax DrawText except you can specify the space between each char.

	Function ccDrawTextSpacedDraw(font:TImageFont, text$,x#,y#,ix#,iy#,jx#,jy#, space:Int )
		For Local i:Int=0 Until text.length
		
			Local n:Int=font.CharToGlyph( text[i] )
			If n<0 Continue
			
			Local glyph:TImageGlyph=font.LoadGlyph(n)
			Local image:TImage=glyph._image
			
			If image
				Local frame:TImageFrame=image.Frame(0)
				If frame
					Local tx#=glyph._x*ix+glyph._y*iy+(i*space)
					Local ty#=glyph._x*jx+glyph._y*jy			
					frame.Draw 0,0,image.width,image.height,x+tx,y+ty
				EndIf
			EndIf
			
			x:+glyph._advance*ix
			y:+glyph._advance*jx
		Next		
	EndFunction
	
	Local gc:TMax2DGraphics = TMax2DGraphics.Current()	

	ccDrawTextSpacedDraw GetImageFont(), t,..
	x+gc.origin_x+gc.handle_x*gc.tform_ix+gc.handle_y*gc.tform_iy,..
	y+gc.origin_y+gc.handle_x*gc.tform_jx+gc.handle_y*gc.tform_jy,..
	gc.tform_ix,gc.tform_iy,gc.tform_jx,gc.tform_jy, space
End Function

' -----------------------------------------------------------------------------
' ccDrawTextSpacedRounded: DrawText with a specified space between each character.  X coord is rounded before drawing each character.
' (By Marius Winkelmann modified by Grey Alien)
' -----------------------------------------------------------------------------
Function ccDrawTextSpacedRounded(t$,x#,y#, space:Int=0)
	'Same as the built in BMax DrawText except you can specify the space between each char.
	'Rounds the X coord before drawing; good if you are using scaled down fonts.
	Function ccDrawTextSpacedRoundedLocalDraw(font:TImageFont, text$,x#,y#,ix#,iy#,jx#,jy#, space:Int )
		For Local i:Int=0 Until text.length
		
			Local n:Int=font.CharToGlyph( text[i] )
			If n<0 Continue
			
			Local glyph:TImageGlyph=font.LoadGlyph(n)
			Local image:TImage=glyph._image
			
			If image
				Local frame:TImageFrame=image.Frame(0)
				If frame
					Local tx#=glyph._x*ix+glyph._y*iy+(i*space)
					Local ty#=glyph._x*jx+glyph._y*jy			
					frame.Draw 0,0,image.width,image.height,Floor(x+tx),y+ty
				EndIf
			EndIf
			
			x:+glyph._advance*ix
			y:+glyph._advance*jx
		Next		
	EndFunction
	
	Local gc:TMax2DGraphics = TMax2DGraphics.Current()	

	ccDrawTextSpacedRoundedLocalDraw GetImageFont(), t,..
	x+gc.origin_x+gc.handle_x*gc.tform_ix+gc.handle_y*gc.tform_iy,..
	y+gc.origin_y+gc.handle_x*gc.tform_jx+gc.handle_y*gc.tform_jy,..
	gc.tform_ix,gc.tform_iy,gc.tform_jx,gc.tform_jy, space
EndFunction

' -----------------------------------------------------------------------------
' ccEnableMaximize: Uses WindowsAPI call to enable maximize button on window
' Thanks go to Gilzu, Diablo and Zawran
' -----------------------------------------------------------------------------
Function ccEnableMaximize(hWnd:Long)
	'Adds the Maximize Button "[]"
	?Win32
	Local tmp:Int = GetWindowLongA( hWnd, GWL_STYLE )
	tmp = tmp | WS_MAXIMIZEBOX
	SetWindowLongA( hWnd, GWL_STYLE, tmp )
	DrawMenuBar( hWnd )
	?
End Function

' -----------------------------------------------------------------------------
' ccEnableMinimize: Uses WindowsAPI call to enable minimize button on window
' Thanks go to Gilzu, Diablo and Zawran
' -----------------------------------------------------------------------------
Function ccEnableMinimize(hWnd:Long)
	'Adds the Minimize Button "_"
	?Win32
	Local tmp:Long = GetWindowLongA( hWnd, GWL_STYLE )
	tmp = tmp | WS_MINIMIZEBOX
	SetWindowLongA( hWnd, GWL_STYLE, tmp )
	DrawMenuBar( hWnd )
	?
End Function

' -----------------------------------------------------------------------------
' ccFastRand: Faster than BlitzMax Rand()
' by Manel Ibáñez
' -----------------------------------------------------------------------------
Function ccFastRand:Int (start:Int, ende:Int)
	Return _crand() Mod (ende-start+1) + start
End Function

' -----------------------------------------------------------------------------
' ccFastRandSeed: Sets the Seed for ccFastRand()
' by Manel Ibáñez
' -----------------------------------------------------------------------------
Function ccFastRandSeed(seed:Int)
	crndseed(seed)
End Function

' -----------------------------------------------------------------------------
' ccFormatNumber: Pass in a floating point number and it will format it with commas to the specified number of decimal places
' by David Maziarka
' -----------------------------------------------------------------------------
Function ccFormatNumber:String(number:Double, decimal:Int=4, comma:Int=0, padleft:Int=0 )
	Assert decimal > -1 And comma > -1 And padleft > -1, "Negative numbers not allowed in Format()"

	Local str:String = number
	Local dl:Int = str.Find(".")
	If decimal = 0 Then decimal = -1
	str = str[..dl+decimal+1]
	If comma
		While dl>comma
			str = str[..dl-comma] + "," + str[dl-comma..]
			dl :- comma
		Wend
	EndIf
	If padleft
		Local paddedLength:Int = padleft+decimal+1
		If paddedLength < str.Length Then str = "Error"
		str = RSet(str,paddedLength)
	EndIf
	Return str
End Function

' -----------------------------------------------------------------------------
' ccGetDirectXVersion: Returns the DirectX version as a string
' By Qube and MichaelB 
' -----------------------------------------------------------------------------
Function ccGetDirectXVersion$()
	Local strVersion:String = ""

	?win32
	Local hbank:TBank = CreateBank(4)
	RegOpenKey(HKEY_LOCAL_MACHINE,"SOFTWARE\Microsoft\DirectX",BankBuf(hbank))
	Local hKey% = PeekInt(hbank,0)
	
	Local value_bank:TBank = CreateBank(100)
	Local value_bank_size:TBank = CreateBank(4)
	Local type_bank:TBank = CreateBank(4)
	
	PokeInt(type_bank,0,0)
	PokeInt(value_bank_size,0,100)
	   
	RegQueryValueEx(hKey,"Version",0,BankBuf(type_bank),BankBuf(value_bank),BankBuf(value_bank_size))
	
	Local dx_version:String = ""
	For Local char%=0 To PeekInt(value_bank_size,0)-1
		If PeekByte(value_bank,char)=0 Then Exit
		dx_version = dx_version + Chr(PeekByte(value_bank,char))
	Next
	
	RegCloseKey(hKey)
	
	Select dx_version
	    Case "4.02.0095"
	        strVersion = "1.0"
	    Case "4.03.00.1096"
	        strVersion = "2.0"
	    Case "4.04.0068"
	        strVersion = "3.0"
	    Case "4.04.0069"
	        strVersion = "3.0"
	    Case "4.05.00.0155"
	        strVersion = "5.0"
	    Case "4.05.01.1721"
	        strVersion = "5.0"
	    Case "4.05.01.1998"
	        strVersion = "5.0"
	    Case "4.06.02.0436"
	        strVersion = "6.0"
	    Case "4.07.00.0700"
	        strVersion = "7.0"
	    Case "4.07.00.0716"
	        strVersion = "7.0a"
	    Case "4.08.00.0400"
	        strVersion = "8.0"
	    Case "4.08.01.0881"
	        strVersion = "8.1"
	    Case "4.08.01.0810"
	        strVersion = "8.1"
	    Case "4.09.0000.0900"
	        strVersion = "9.0"
	    Case "4.09.00.0900"
	        strVersion = "9.0"
	    Case "4.09.0000.0901"
	        strVersion = "9.0a"
	    Case "4.09.00.0901"
	        strVersion = "9.0a"
	    Case "4.09.0000.0902"
	        strVersion = "9.0b"
	    Case "4.09.00.0902"
	        strVersion = "9.0b"
	    Case "4.09.00.0904"
	        strVersion = "9.0c"
	    Case "4.09.0000.0904"
	        strVersion = "9.0c"
	End Select
	?
	
	Return strVersion
End Function

' -----------------------------------------------------------------------------
' ccGetEnvVar: Uses Windows API call to return an Environment variable
' by Ian Duff modified by Grey Alien
' -----------------------------------------------------------------------------
Function ccGetEnvVar$(envVar$)
	Local result$= ""
	?Win32
		Local buff@[64]
		
		Local rtn% = GetEnvironmentVariable(envVar$, buff@, buff.length)
		If rtn > buff.length
			buff@ = buff@[..rtn]
			rtn = GetEnvironmentVariable(envVar$, buff@, buff.length)
		EndIf
		
		Result =  String.FromBytes(buff@, rtn)
	?
	Return Result 'Mac safe
End Function

' -----------------------------------------------------------------------------
' ccGetSharedUserDataFolder: Returns a special Mac folder for storing shared user data
' By Bruce Henderson
' -----------------------------------------------------------------------------
Function ccGetSharedUserDataFolder:String()
	'Note that it does not have slash on the end!
	?MacOS
		Local buf:Byte[1024],ref:Byte[80]
		
		If FSFindFolder( kUserDomain, kSharedUserDataFolderType, False, ref ) Return Null
		If FSRefMakePath( ref,buf,1024 ) Return Null
		
		Return String.FromCString( buf )
	?
End Function

' -----------------------------------------------------------------------------
' ccGetSpecialFolder: Returns a special Windows folder
' By Dave Kirk
' -----------------------------------------------------------------------------
Function ccGetSpecialFolder:String(folder_id%) 
	?win32
	Local  idl:TBank = CreateBank (8) 
	Local  pathbank:TBank = CreateBank (260) 
	If SHGetSpecialFolderLocation(0,folder_id,BankBuf(idl)) = 0		
		SHGetPathFromIDList PeekInt( idl,0), BankBuf(pathbank)
		Return String.FromCString(pathbank.Buf()) + ""
	EndIf
	?
	Return ""
End Function

' -----------------------------------------------------------------------------
' ccGetVersionString: Returns the Windows version in a string
' By Dave Kirk
' -----------------------------------------------------------------------------
Function ccGetVersionString:String()
	Const VER_PLATFORM_WIN32s% = 0
	Const VER_PLATFORM_WIN32_WINDOWS% = 1
	Const VER_PLATFORM_WIN32_NT% = 2

	Local versionName:String

	?win32
	Local VersionInfo:TOSVersionInfoEx=New TOSVersionInfoEx
	VersionInfo.dwOSVersionInfoSize=SizeOf(VersionInfo)
	
	GetVersionExA(VersionInfo)
	Select versionInfo.dwPlatformID
		Case VER_PLATFORM_WIN32s; VersionName = "Win32s"
		Case VER_PLATFORM_WIN32_NT; VersionName = "Windows NT"
	         
		Select versionInfo.dwVerMajor
			Case 4; VersionName = "Windows NT"
			Case 5;
				Select versionInfo.dwVerMinor
					Case 0; VersionName = "Windows 2000"
					Case 1; VersionName = "Windows XP"
				End Select
			Case 6; VersionName = "Windows Vista"
		End Select
	                  
		Case VER_PLATFORM_WIN32_WINDOWS
			Select versionInfo.dwVerMinor
				Case 0; VersionName = "Windows 95"
				Case 90; VersionName = "Windows ME"
				Case 10; VersionName = "Windows 98"
			End Select
	End Select
	?
	Return VersionName
End Function

' -----------------------------------------------------------------------------
' ccPointToPointDist: Returns the distance between two points
' by Oddball modified by Grey Alien.
' -----------------------------------------------------------------------------
Function ccPointToPointDist:Double(x1:Double, y1:Double, x2:Double, y2:Double)
	'Upgraded Float params and variables to doubles (Grey Alien)
	Local dx:Double= x1-x2
	Local dy:Double= y1-y2
	Return Sqr(dx*dx + dy*dy)
End Function

' -----------------------------------------------------------------------------
' ccPrintGraphicsModes: Outputs all available graphics modes in the Output window
' by xlsior
' -----------------------------------------------------------------------------
Function ccPrintGraphicsModes()
	Local x%,wid%,hei%,dep%,her%
	For x=0 To CountGraphicsModes()-1
		GetGraphicsMode(x,wid,hei,dep,her)
		Print x+" Width: "+wid+" Height: "+hei+" Depth: "+dep+" Hertz: "+her
	Next
End Function

' -----------------------------------------------------------------------------
' ccRound: Gives proper rounding of Float to Integer without bankers rounding
' By Beaker
' -----------------------------------------------------------------------------
Function ccRound%(flot#)
	Return Floor(flot+0.5)
End Function

' -----------------------------------------------------------------------------
' ccRoundFloat: Allows you to round a float to a certain number of decimal places
' By Dreamora
' -----------------------------------------------------------------------------
Function ccRoundFloat:Float(number:Float,decimals:Int)
	Local t:Int = 10^decimals
	Local result:Float = Int(number * t + 0.5)
	Return result / t
End Function

' -----------------------------------------------------------------------------
' ccVWait: Uses DirectX to wait for a vertical blank
' by Skidracer updated by GreyAlien
' -----------------------------------------------------------------------------
Function ccVWait()
	'Only works in DirectX graphics mode.
	'This shouldn't really be needed any more as Flip 1 now always waits for VSync
	'in Full Screen and Windowed mode.
	?Win32
	If TD3D7Max2DDriver(_max2dDriver)
'		PrimaryDevice.ddraw.WaitForVerticalBlank DDWAITVB_BLOCKBEGIN,0 'no longer works since new DX7 module
		D3D7GraphicsDriver().DirectDraw7().WaitForVerticalBlank DDWAITVB_BLOCKBEGIN,0	
	EndIf
	?
End Function


Your a big liar Jake! jk

Thanks alot man :o) Even this will be handy on learning blitzmax. You shouldn't have let them get to you :o)

Hey, ccRoundFloat does not work properly with negative numbers.

Fixed version:
Function ccRoundFloat:Float(number:Float, decimals:Int)
	Local t:Int = 10^decimals
	Local result:Float = Int(number * t + 0.5 * Sgn(number))
	Return result / t
End Function


This is the only function I've used (just copied and pasted the code). If I found anything else, I'll let you know if you want.

Thanks for the fix! I'll be sure to sell it for $1,000,000.

I'll be sure to sell it for $1,000,000.
Why this??
No ofense intended on my previous post... sorry...

Thanks for the fix! I'll be sure to sell it for $1,000,000.
In what way was ziggy's post offensive or sarcastic?

Thanks for the code, in one spot that is.

@Ziggy: Sorry it was just a general joke, not at all aimed at you, sorry if it read that way. It was a joke for the people who keep harping on about me "selling the IP to Public Domain code", and the joke backfired (will teach me!) And yes please post any other things you notice, thx!

Perhaps this code could be the start of a community framework if someone wants to take the reigns and tie it all together?

Ok! Thanks for the clarification!

Is there still people saying this about your framework?!! I wonder how many of them have bought it and know what they're talking about... :D

Yeah it cropped up again recently due to the sale of my framework to BFG. It was people who have not bought it spreading misinformation. Shame but I thought the best way to deal with it was some hard facts and making the PD bits public :-) Hope it works.

I thought your reply in the other thread was enough but this is a nice idea and should be useful to some people.

don't listen to the complainers, [edit] you have perfect right to use that code and deserve compensation for the work you put in which, as you point out, includes much more than just the stuff you got here. anybody can find some of this code too, but most *don't* make a nice package for others... you didn't have to offer what you put together, to the public at all!

That is indeed true. It worked both ways, people benefited and so did I, so that's cool.

oi! i payed for this...whats the damned meaning of all this freebie carry on?! :p
heh.. im sure this will come in handy, the framework contains lots of
helpful code - tho even now ive had little time to actually make use of
it..lol - mostly i grabbed it to see what was in there + to grab the bits
i like... lots of stuff i didnt think about.. not that i ever think that
much ;)

congratz on your success + hope you like working with BFG..

a thread sticky "blitzmax community framework" (moderated of course) would be great
if it aint a code snippet or bug fix the posts should be trimmed like the "full list of blitz games" list is

I got the joke immediately :) Just ignore the haters. There will always be some in every crowd!

I bought the framework in the beginning just because I wanted to support a fellow Blitzer that was working hard. It has been fun to follow your progress over the years.

yep, the lucky detractors blow goats, the unlucky ones well - ho ho.

Thanks all it's good to know there are some friendly people out there.

@Ginger Tea: That's a good idea. The code could be copied out of this thread + adding in ziggy's little fix and then put in a new sticky thread (perhaps in the BlitzMax forum) but it needs a mod who is prepared to trim the posts occasionally or at least make it sticky.

yah...but this code isn't a framework, it would probably be better served just adding it to the code archives as 1 large installment.

Yeah it's not a framework because it's missing 97%. The point is is could be turned into a community framework if more vital pieces of code are pulled from the archives or written/researched and then it's all tied together in a framework for public use.

I see my name has appeared there a few times and...

I asked people's permission to use it
You did? When was this then?

I also don't recall declaring any of it as public domain?


Don't panic, I don't care. :o)

I'm only mentioning it as you appear to be under the impression that code posted on a forum automatically falls into the public domain, even if it isn't explicitly indicated as being so? This just isn't the case. For instance, some of that code, technically, falls under the BSSC as it contains code from BMax's modules. This code is mostly generic GL/DX stuff or are tiny fragments, so I very much doubt BRL are going to care, but you see my point.

I know you wouldn't dream of using any old image from an image search, what makes code so different?

Nobody here is interested in claiming ownership, but someone, somewhere might be. Please be more careful. :o)

@Yan: Go to any post in the Code Archives and note that it says "This code has been declared by its author to be Public Domain code." right at the top. I still asked some people anyway.

When code cropped up in a thread whilst we were discussing a topic it was freely given by the poster so that anyone could use it - no one ever applied caveats or referenced licenses, but I take your point that what is the default license in such a case? I often still asked the poster if I could put it in the framework anyway. Some of the code above was emailed to me privately to include in the framework. The only "dodgy" bit is BRL's code from DrawText I guess which someone posted on this forum. BRL don't seem to have any guidelines about posting their module code, but they've never clamped down on anyone posting modifications publicly.

Each time i read PublicDomain, i have to think of Fred Fish.

><°>

Go to any post in the Code Archives...
I haven't posted any of that code in the code archives?

I'm only referring to the code bearing my name. Apologies if that wasn't clear. I can't comment on the code of others, neither would I dream of doing so, as I don't know how it's been licensed/declared and I'm not privy to any permissions which may have been granted. :o)

When code cropped up in a thread whilst we were discussing a topic it was freely given by the poster so that anyone could use it
For use in your own projects, yes, but that's a *long* way from handing over the rights or granting a license for it to be sold. Come on Grey, you seem like a reasonably intelligent chap. It's common sense, no?

Speaking for myself, I pretty much consider any code I've posted here to be free for anyone to use in any way they see fit. All I expect in return is a 'thank you'. It's likely, however, that not everyone will see things this way. ;o)

I take your point that what is the default license in such a case?
Well, for what it's worth, I assume any code that doesn't indicate otherwise to be the property of the poster. I'd freely use it in my own projects but I wouldn't attempt to sell it without first making sure I'd gained explicit permission from the poster/owner to do so.

Perhaps I'm just overly cautious?


BRL don't seem to have any guidelines about posting their module code
From the BSSC license that comes with BMax...

This source code is the property of Blitz Research Ltd.

...<Blah>...

You may modify this source code for your own purposes and
can choose to publish such modifications to the BlitzMax
Community page at http://www.blitzbasic.com. You
may not publish this source code or any modified
version of it elsewhere.

By publishing modifications to http://www.blitzbasic.com, you
agree that other members of the Blitz community are free to
use those modifications in their own projects, and that
Blitz Research Ltd are free to include your modifications
in future source code releases.



The only "dodgy" bit is BRL's code from DrawText I guess which someone posted on this forum...<snip>...but they've never clamped down on anyone posting modifications publicly.
I honestly wouldn't worry about it. I was merely making a point about unknown provenance.


Just to reiterate, I'm not talking about code from the archives as that's clearly declared as public domain. I'm referring only to code that's been posted on the forums (or *any* forum for that matter).

I'm no lawyer and it's likely that I'm talking from my posterior. I suppose what I'm really trying to say is, isn't it better to be overly cautious? Especially when it comes to a subject as tricky as copyright law. :o)

For sure it's worth being cautious and I make sure I am very careful about checking the licenses of fonts, art and sound/music of course, and code :-) Did you read my other framework thread where I said that my contract with BFG states that the public domain code remains just that and is not being sold and thus it's a non-issue? That should clear up the issue for you. Also hopefully now as I've posted this info in both threads it won't need to be raised again.

And I'm sure I've said it before personally but certainly I've said it generally - thanks for your help with my framework :-)

Okay, I think you may have misunderstood my point and/or read between the lines and concluded that there's some kind of agenda behind my post that just isn't there. :o)

Forgive me if I've got the wrong end of the stick and at the risk of appearing painfully pedantic, I'd just like to make my standpoint crystal clear...


I not particularly interested in the specifics of your business dealings and I don't have any 'issues' that you need to clear up. Neither am I seeking adoration or praise. AFAIR you've always been polite and courteous when asking for and receiving help on the forums and that's all I expect from anyone. :o)


The fact is, you stated that the code above is either in the public domain or permission has been sought. I know that neither of those things apply to the code I have posted on the forums and that you've subsequently used. This lead me to conclude that either:-

1) You were under the impression that code posted on the forum automatically falls into the public domain and anyone is free to do with it whatever they wish.

2) There was an oversight on your part and you forgot to seek permission to use portions of code which had.


All I'm trying to say is; whilst the second case is understandable, assuming code is not owned by anyone is the kind of silly mistake that can easily come back and bite you in the arse and to try highlight it as such in order to encourage you to be more diligent in the future. :o)


I wasn't trying to imply any malice on your part, nor am I in a sulk because you didn't ask to use 'my precious codez'...Blimey. ;o)


Now, stop being so thin skinned and go finish your game. ;op

...<EDIT> don't think it is worth it.

Each time i read PublicDomain, i have to think of Fred Fish.
He's dead, him. He was found one morning, floating upside down in his bowl.


(No really, he actually died).

I knew that but that doesn't stop me thinking of some of these guys from time to time and remembering some memories.

Okay, I think you may have misunderstood my point and/or read between the lines and concluded that there's some kind of agenda behind my post that just isn't there. :o)

Forgive me if I've got the wrong end of the stick and at the risk of appearing painfully pedantic, I'd just like to make standpoint crystal clear...
No nothing concluded about agendas or whatever, your posts made sense to me, I just thought that I'd make it clear again that I didn't sell the IP to the code posted above, whether it's public domain or not. I was just trying to be crystal too :-)

Fair enough. :o)

Actually Yan raises an interesting point because many people have used code snippets from forum posts in their games which may be commercial or freeware and they never ask permission. Some even post their code back on the forum (without credits to the original poster) or on other Blitz-related forums, or share the code with friends/colleagues etc.

Perhaps BRL need a license agreement for the forum (not the code archives) that either says a) everything you post is public domain (easy) unless it's BRL Code (as per their BSSC license that Yan posted above), b) it's all owned by BRL (some forums do this but it's dodgy imho) or c) it's all owned by the poster (in which case whenever anyone uses any of it, even a single line, you'd need to seek permission from them - you could differentiate between personal use/freeware and commercial projects like fonts/sound licenses do for example.)

However I find c) to be pretty distasteful because every time I post anything I'm basically saying "here you go, it's in a public space, use it how you like, you don't even have to credit me". I feel that's in the proper spirit of a programming community where everyone helps each other. It would be different it you were posting to a poetry forum for example.

Another related issue is if you modify a code snippet, at what point does it become your own? Is it a simple case of changing variable names and comments, or doing a bit or rearrangement? The thing is with code is that some problems only have one solution and so there's not much variation in the way in which you could solve it...

Well, there's an obvious distinction between using compiled code in a game, and selling code for reuse that was written by somebody else.

Isn't there a difference from using code in a product Vs selling the IC to the product?

Could be...good job I didn't do that with BFG then right? (as I've stated multiple times now so I presume you two are just bringing it up as an academic matter or interest).

And then there's the whole "Fair Use" thing: http://en.wikipedia.org/wiki/Fair_use

... we must be missing something Jake. You said you sold IC to your Framework but not IC to the PD stuff (i.e. Code Archives). Does that mean you sold the IC to code donated for your framework or provided as an answer to a post or lifted from these forums. If that's the case then I am not sure its really your IC to sell.
Again, don't think it matters although you do seem to want to justify yourself. If you're happy what you did is right then that's it, isn't it? If (in the unlikely event) it comes back to bite you then you'd have acted in the best intentions although I don't believe that's defence in law.
Again ... no problem with you doing it just not sure you had the right to.... just my opinion.

@anyone who is interested, not a specific person, so please don't be insulted and think it all applies to you:

To quote battlestar: "for frak sake". I sold the IP to the code which I wrote or heavily enhanced/modified (which accounts for 97% of the framework). The stuff listed at the top of this thread which I've called Public Domain, which may not actually all be PD according to Yan (because it was provided as an answer in a forum thread or "lifted" as TonyG so politely puts it), was NOT sold because it was not mine to sell, it's listed in an appendix to the contract. Is that 100% clear yet? Can we close the case? Is the question answered? (Even if it isn't answered I've wasted so damn much time and mental energy on this that I shan't be posting any more on the topic).

I may have even made errors in preparing the list at the top (the framework has been built over nearly 3 years), but I've done my best to address this issue carefully. Code that was donated to me to plug into my framework is mine to do with as I like (donate=give unless you attach some kind of strings) and thus not all of it is listed above (like a TDateTime type that someone let me plug into my framework. My customers have been very generous in supplying code and fixes and improvements for my framework.)

Yes congrats, enough of my buttons have finally been pushed that I am now officially peeved at all this crap. I am happy with what I'd done and the majority of people support me with the progress I've made with Blitz over the last few years but there seem to always be a few sour grapes and pedants for some reason. This is not unique to me though, it seems that when anyone gets some measure of success and is in "the public eye" (meaning I post on a forum), that they will come under fire from some individuals (normally the same ones who give everyone a hard time because they have a big chip on their shoulder or whatever). I'm pretty good at ignoring this but there are only so many insults you can take in a zen-like manner before exploding ;-) and you've just seen it. Probably I should edit this post away but I'm going to leave it so that my "detractors" can see how they feel about making someone else feel sh*t - did you enjoy it? Do you feel big now? Has it improved your life in some way? Or do you realise that really it's not pleasant and that perhaps being a little nicer to people is a good idea?

So long and thanks for all the code...

Could CreateMutex be added to the list? (then runs)

<edit> P.S. Whatever you may think I have a lot of respect for what you did with the framework, am genuinely happy for your success and have taken a lot of interest in somebody who has 'opened' up Bmax.
<edit> Took a bit out as, although sure I am listed in the "sour grapes and pedants " but also consider myself in "the majority of people support me with the progress I've made with Blitz over the last few years", told not to take it personally.

<edit> in case anybody needs it TDateTime is in the Code Archives.

I wonder if you may have [edit]unknowingly[/edit] committed fraud. I suppose it's possible. Have you considered this, Grey?

Hmm, to be honest nobody cares about all the crappy code lying round these forums so it might as well be public domain. You basically loose your IC when you post code here, the only exception would be if you clearly stated in the code that you are restricting it's use based on copyright.

Didn't we all have a lengthy discussion about this very topic several years ago and the general consensus was that everything posted publically was PD unless stated otherwise?

EDIT : Well, the T&Cs for this site are confusing:

All information and articles contributed to the Blitz Research Ltd by outside parties are under the copyrights of those parties.

You agree not to reprint, redistribute or copy any content on this site without the explicit written consent from Blitz Research Ltd. Although permission is not guaranteed, you may request permission to reprint material by sending an email to marksibly@....

OK, so by default anything contributed is copyrighted by the poster (therefore you require permission from the poster to use their posted code in your program), unless you want to redistribute it (such as has happenned in the OP here) in which case you need permission from BRL.

Either way, this completely and utterly goes against the way I thought it would work, in that I would never have even contemplated getting anyone's permission to use anything.

Either way, this completely and utterly goes against the way I thought it would work, in that I would never have even contemplated getting anyone's permission to use anything.
Not really, if you think about it...

All information and articles contributed to the Blitz Research Ltd by outside parties are under the copyrights of those parties.

...is BRL's way of saying that they don't claim any rights over what you or I or anyone posts, which is right and just and what you'd expect. This is entirely separate to the fact that the code here is, typically, publicly offered in response to requests for assistance and, implicit in that, is the expectation that it be used. You don't give people advice and then forbid them from following it; you don't relay facts and then expect folk to magically un-know them -- no court is going to find that line of thought reasonable.

Frankly I find it absurd, when you look at what BRL's languages allow you to do, and look at what the underlying C compilers allow you to do, and look at what OpenGL and DirectX allow you to do, and look at what the residing OS allows you to do, that anyone could sit atop of all these giants with a thoroughly vanilla code snippet and claim "this is MINE" with a straight face. As if ten other people wouldn't have offered at least an equal solution if they hadn't. As if the high-level code fully describes anything that wouldn't be useless without the underlying systems; As if the same solution hasn't been expressed thousands of times in slightly different dialects, possibly since before they were born. It's embarrassing.

No-one would have believed, in the last years of the nineteenth century, that human affairs were being watched from the timeless worlds of space. No-one could have dreamed that we were being scrutinized, as someone with a microscope studies creatures that swarm and multiply in a drop of water. Few men even considered the possibility of life on other planets. And yet, across the gulf of space, minds immeasurably superior to ours regarded this earth with envious eyes; and slowly, and surely, they drew their plans against us.


You know markcw has had enough when he starts quoting Dickens... :-p

I am now officially peeved at all this crap.

It's really not worth getting so worked up, ya know? :-)
Who really cares what the "detractors" think? There are so many opinions and egos around here that no matter what you do, you will appear to stamp on someone's toes.

We have the code in one thread that Grey Alien has used in his engine which is now BFG's property (correct?)

He isn't SELLING just the PD code, he is selling his code which uses PD code.
Surely you've sold a product that contains code contributed on this site, regardless of the license.

What is the bloody issue?

I've just got back from Aikido and feel much better now :-)

@TonyG: Didn't mean to make you feel bad sorry, although possibly you are a pedant ;-p but then who isn't round here?

@Brucey: You are right of course, but it was good therapy letting it all out for once.

Didn't we all have a lengthy discussion about this very topic several years ago and the general consensus was that everything posted publically was PD unless stated otherwise?
It would certainly be nice if that's the way it was. I bet that's what most people think it is too. Certainly any code I post I think of as 100% public because otherwise I'd just be a jerk frankly.

As if the same solution hasn't been expressed thousands of times in slightly different dialects, possibly since before they were born
Yeah totally agree with this. For example I used near identical Mutex code in 1996 in Delphi for my business software (probably got that off a Borland forum too). Three years ago I found out the syntax (for that's all it was, not anything "creative") to do the same thing in Blitzmax and used that (although my version is modified slightly to suit my own purpose; and how much do you need to modify code before it can be called your own? We never answered that one.). It's only a couple of lines after all, and for many WinAPI functions there is pretty much only one way you can call them anyway!

For a laugh check out ccRound that I've posted above, it's just this: Return Floor(flot+0.5). Imagine someone trying to claim copyright for that? I just put it in the PD collection as I found it useful and was grateful the the original author 4 years ago when I first used it in BlitzPlus. What about if I used x:+1 in my code, could someone else claim it was a part of their copyrighted code, line 354 or whatever? It would be ridiculous. So where are the boundaries? i.e. how big does code have to become before someone can call it an original piece of work that expresses creativity enough to be copyrighted? It's like Microsoft patenting the double click etc, totally stupid.

how much do you need to modify code before it can be called your own? We never answered that one.

I think that sums up my confusion.
If I select a solution from the Framework and convince myself I could have come up with something similar is it OK for me simply to use the framework version, release it or sell it as my own. I don't think so.
Can I simply change it a bit : variable names for example (which seems silly) or do I have to forget I saw the code and begin again. If I do that, do I have to come up with a different solution because, as mentioned, there are somtimes only a few ways of doing something and often a best way.
Once more, this isn't any slur on Jake and what he has done. Any suggestion of annoyance is due to the reaction to a simple question. This isn't just from Jake's reaction but all the people jumping in with size 9s assuming this is, in my case, is an attack on Jake.

Blimey!...Do you feel better now GA? ;op


Certainly any code I post I think of as 100% public.
Yeah I think most people do, including myself. However, what with implicit copyright and all that malarkey, that doesn't necessarily mean it's the way lawyers see it. ;o)

how much do you need to modify code before it can be called your own?
Your getting into the, even more confusing, area of derived works now. I'd be inclined to credit the original author and hope for the best. ;o)


I think the vast majority of us using code from the intarweb need not bother about any of this nonsense. It's only when you come to publish , or otherwise distribute, code that all these pitfalls, could potentially, become a problem.

Personally, I couldn't be arsed with it all, to even bother trying. :o)



Oh...And yes...I can be a pedant, but isn't all programming merely directed pedantry? ;o)

to get a starter:
' ccGetDirectXVersion: Returns the DirectX version as a string
-- I didn't do something else than adding a version string or so - no credits for me needed.


Selling IC (IP not possible - in Germany its bound for life). If GA sold his framework all users stood calmed down but if he sold his work to someone else now being in the position to sell or XYZ it, the crowd is yelling. There is no difference but being another person in the situation of selling/gifting/... the framework.
There is no change from "open source sold to someone now being closed source" or so.
Most work GA spidered from this and other forums were that small or type of "just needs time, no knowledge" that the authors hold IP on their work, but they eg. cannot prohibit others from using it after posting the lines. The needed creative level of work isn't reached in most of the cases, so in Europe (although getting more and more like the US when it comes to patents) nobody would blame GA to have misused/stolen IP from others.
He didn't take a framework, renamed it and then sold it. Even if I decide to collect 1 cup, 1 spoon, a bottle of vasp slime and a triangle folded piece of paper - I will hold the IP on this special sort of arrangement (see art) but I cannot prohibit others from imitating my style, copying it and so on.

Short: every line of code you write is your intellectual property. But as long as the level of your creative (!) work is too low, you cannot prohibit copying, altering, ... You all didn't event the alternative to resource-consumption like oil and wood - you only have shown others how to calculate how many chops of wood are needed to make the fire burn 3 hours. If I had observed you and noted your thoughts about it down, I would have had the right to publish a collection of such notes in a book without being in the situation to get sued by you.


For "PD" - I think programmers may sometimes be called "creatives" or even "artists" - so better use the term "CC" (creative commons) - so you know "xyz" did it, but one can use it for whatever he intends to. But there is no need to step further into discussions about licenses.


Some words about "what level is needed until your derivate work is no longer a copy of something"
... altering names of variables won't do the trick: can be done automatically (refractoring)
... including boundaries checks won't do the trick: can be done by compiler
... changing the effect the code produces: can do the trick as long one doesn't only change the color of the output ;D
... optimizing the code in a way the compiler isn't (atm) able to do (unneccessary calls, logical boundaries (1 / x won't go higher than 1 if x is > 1) ... may do the trick if done more than one time.
... you cannot prohibit others from using your ideas, just the way you do it may be a property you have to decide about (but than again "creative level" is needed) - so you can copy ones game - but you'll have to change the appearance while game logic stays nearly the same (so it's for Germany)


Ok, to come to an end: like said, most code I've seen posted in the forums (not code archive) are way too short to IC them (IP you have anyway) and yes, it's in nearly no case a new idea never used before (comparing to dblclick patents and so on). "i posted usable code others use without my allowance" - it's like staying in a park crying around how to accomplish XYZ - if one notes it down, he may do whatever he wants with it (as long as the person crying around was allowed to do so ;D).


bye MB

I've posted code in the archives with this sentence:
Local X:int
So if you've used my sentence, you'll have to pay royalties... Come on... let's use common sense...

Ziggy, who's point are you responding to? I am sure everybody would agree with you in that case.

So if you've used my sentence, you'll have to pay royalties
Except, as you've posted it in the archives, you've declared it as being Public Domain.

Come on, you really haven't been paying attention, have you. ;op


Also, since when has the law had anything to do with common sense, it is, after all, an ass? ;o)

Didn't we all have a lengthy discussion about this very topic several years ago and the general consensus was that everything posted publically was PD unless stated otherwise?
Here's a link to a similar discussion that took place last year. All code in the archives is public domain, but you certainly can't assume code posted in the forums is also public domain. If it's in the forums you need to be absolutely sure you've got permission to use it first.

I'd say, stuff it. You explaining yourself Grey, is just an opportunity for other people to pick holes in what you've done.

Ziggy, who's point are you responding to? I am sure everybody would agree with you in that case.
I was just kidding. I think this whole discussion is becoming a bit non-sence (IMHO). If you want your code to be private and copyrighted, don't post it here. I can't take seriously anyone posting code in this community and pretending the code not to be used by others.

Ziggy, yeah I think that is most people's view. It's just there is no statement and, as such, using that code without permission is dodgy (legal term). Going on to sell the IC of that source code seems one step further to me.


I think this whole discussion is becoming a bit non-sence (IMHO). If you want your code to be private and copyrighted, don't post it here.



and thats the bottom line, i was really trying to stay out of these particular topics but i couldn't agree more with ziggy.

i say let this die, jake posted the pd code so let people use/enjoy it for what its worth and leave it at that.

I agree, code posted must be expected to be used by others.

Most of the code is posted because somebody says "How do you do this?".

So, if you respond and post "Like this:" and give code, you have basically given that code to the person who asked for it, and you laid it out on the table for all to see. So, expect them to use it to.

I think the only way that posted code couldn't be thought of as being given away, is if someone were to post "Look how I did this, it is great and it is mine, you can't use it". And in that case, why would you show it to anybody to begin with.

If someone says "How do I do this" and you show them how, you better say, but before you do it that way, you have to buy the rights from me. Because by showing them how, you are basically giving them permission to do it that way.

edited because it's over...no use to keep on keeping on. ;)

And lets not forget: 9 out of 10 times if I solve a problem by myself, it's by the same solution someone else has used before me. So even if code is alike, that itself is no proof that it's 'nicked'. If you post code here, it's re-used. Fact. Don't post if you don't want you code used.

The whole discussion is moot for a different reason anyway:

Grey didn't sell the 'PD' code. He bundled it up into one file and posted it in the same forum as where he collected the code from in the first place. The framework that he DID sell, simply happens to include this 'PD' file.

Omg let the man have his glory yeah we all wish we had Greys string of luck but thats mostly down to his own efforts.

God if we all look back i bet a good 10% of all our coding is similar to code snippits posted on the forums if someone made some dosh from it fair play.

anyways im declaring this code as mine you may never use it again

Print X+Y
£1,000,000

anyways im declaring this code as mine you may never use it again

Print X+Y
£1,000,000
Bit of an own-goal since nobody uses Print anyway.

Heh, good thing I use Print A+B.

I'm surprised anyone could make a deal out of minimal functions like this. If you leave the damn doritos out, hippies are going to take them.

Making a deal out of this is like leaving your crappy old washer and dryer on the side of the road for the taking, then sueing the scrapper for making a penny off it.

Can someone link me to the next soap opera in the general section please?

Can someone link me to the next soap opera in the general section please?

http://www.blitzbasic.com/Community/posts.php?topic=82834

However the network cancelled it during its first season... erm, page. A shame really, it had potential. :o)

I'm surprised that so many people seem to struggle with the comprehension of simple English.


I was merely highlighting a misapprehension in the hope of saving a fellow blitzer from potential difficulties in the future.

What a complete and utter b*****d I must be! Perhaps I should be strung from the nearest lamppost or be burned at the stake?


I wont bother in future...Blimey! 8o[

Yan, I had another quick look at the topic in case I missed something but... I'm still completely lost about your last comment. It isn't about my joke, right? in that case no harm intended.

I just feel that everything which could be said on the subject, and probably more, has already been said.

Doiron, That wasn't aimed at you.

I'd be quite the hypocrite if I were to chastise the authors of inane or jokey posts. ;o)


Perhaps it is *I* who's being thin skinned now? :o)

Yan, i hope it wasn't my post that offended you. i wasn't pointing fingers at anyone,just trying to state a fact.

but to quote myself:

i say let this die, jake posted the pd code so let people use/enjoy it for what its worth and leave it at that.



in fact i wish a moderator would delete all but the first post and lock it, or do a copy and paste from the first post put it in the archive and delete this thread all together. but thats just me.

i think we all get thin skinned now and then, but sometimes its hard to take in the tone and full context of written words over an actual voice conversation.

edit:
on a side note, i do understand what you've been trying to say all along.

:) Thanks Jake - It had been boiling under the skin for a while and wanted to get it out. Thanks for posting - good luck to you and family in Canada.

@Indiepath: Thanks, it's pretty neat over here. Hope all is well with you too.

But I probably did it in a non-non-offense (double negative) way so sorry :(

@Indiepath: Believe it or not it was you who started this whole thing off in that other thread, but it seemed a few other people had the same thoughts so it was worth thrashing it out (well maybe) ;-)

[edit] Oh and I'm not "blaming" you just to be clear, it is what it is. You said sorry and I appreciate that - it means a lot when people can say sorry and perhaps some other people round here could learn from that...including me - I don't think I said sorry for my outburst above yet, so "Sorry Everyone".

I am Pro Grey Alien. I think there are various books Grey could read to further enhance his thinking state. I don't mean that in an offensive way it's just something I read sometime ago about the way people think.

E.g There is a way that succesful people think to make them succesfull. It's all about how you apply your thoughts and work with them. In the book I read the guy was discussing thought blueprints. He was talking about succesful thinking and the "Model" as in the structure of the thought behind it. He also talked about Behavioural Engineering in that the thoughts alone are not enough but must be applied and a succesful new behaviour created with those thoughts. This goes back to the whole Blueprint thing.

I think Jake has managed himself well in this whole issue regarding the Framework. It's unfortunate that people would try to sting him.

Thanks Amon. I do actually read books and sites like that and I learn about it through my style of Aikido which is about positive thinking (and much more). But there's always more I can learn for sure. Here's a great book I read a couple of years back that made a big difference: http://www.amazon.ca/Secrets-Millionaire-Mind-T-Eker/dp/0002008033 It's where I got the idea of why choose either/or when you can have BOTH :-) It talks about Money Blueprints and is very interesting. I totally revamped my finances after reading that and cleared off loads of debt. What was the book you read? Do you have the name?

I'm in the same position as Yan with a bit of curiosity thrown in. I'm certainly not going to bother next time.

Well I think that big debates like these teach us all something don't they?

See? And that's the great thing about Jake.

While I certainly don't agree with the way he decided the fate of his frame work, he has RESPECTFULLY and PROFESSIONALLY agreed to disagree. And I guess he's contributed quite a lot to the larger community in the form of sharing his experiences and offering advice via his blogs...

Which is a great trait in any developer in a collaborative environment.

In fact.. should he ever get sick of the game dev arena, and want to relocate to Arizona to get a REAL job, he should let me know. ;)

I'm surprised anyone could make a deal out of minimal functions like this

Somebody has some threads to actually read.