Ok, here's a quick fix to keep your project moving for now.
function SpritePixelCollision(sprite1 as integer, sprite2 as integer)
local Sprite1Base as dword
local Sprite2Base as dword
local Sprite1Addr as dword
local Sprite2Addr as dword
local V as dword
if sprite collision (sprite1, sprite2) > 0
make memblock from image 255,sprite image(sprite1)
make memblock from image 256,sprite image(sprite2)
Sprite1Base=get memblock ptr(255)
Sprite2Base=get memblock ptr(256)
XPos1=sprite x(sprite1)-sprite offset x(sprite1)
YPos1=sprite y(sprite1)-sprite offset y(sprite2)
Width1=*Sprite1Base
inc Sprite1Base, 4
Height1=*Sprite1Base
` Change 1
inc Sprite1Base, 8
XPos2=sprite x(sprite2)-sprite offset x(sprite2)
YPos2=sprite y(sprite2)-sprite offset y(sprite2)
Width2=*Sprite2Base
inc Sprite2Base, 4
Height2=*Sprite2Base
` Change 2
inc Sprite2Base, 8
if XPos2 > XPos1
XStart1=XPos2-XPos1
XStart2=0
XOverlapSize=(Width1-XStart1)-1
if XOverlapSize >= Width2 then XOverlapSize=Width2-1
else
XStart2=XPos1-XPos2
XStart1=0
XOverlapSize=(Width2-XStart2)-1
if XOverlapSize >= Width1 then XOverlapSize=Width1-1
endif
if YPos2 > YPos1
YStart1=YPos2-YPos1
YStart2=0
YOverlapSize=(Height1-YStart1)-1
if YOverlapSize >= Height2 then YOverlapSize=Height2-1
else
YStart2=YPos1-YPos2
YStart1=0
YOverlapSize=(Height2-YStart2)-1
if YOverlapSize >= Height1 then YOperlapSize=Height1-1
endif
` Change 3
local MMax1 as dword
local MMax2 as dword
MMax1=get memblock ptr(255) + get memblock size(255)
MMax2=get memblock ptr(256) + get memblock size(256)
XStart1=XStart1*4
XStart2=XStart2*4
Width1=Width1*4
Width2=Width2*4
for YOffset=YOverlapSize to 0 step -1
Sprite1Addr=Sprite1Base + ((YOffset+YStart1)*Width1) + XStart1
Sprite2Addr=Sprite2Base + ((YOffset+YStart2)*Width2) + XStart2
for XOffset=XOverlapSize to 0 step -1
` Change 4
if Sprite1Addr >= MMax1 then exit
if Sprite2Addr >= MMax2 then exit
v=*Sprite1Addr
if (v && 0xff000000) <> 0
v=*Sprite2Addr
if (v && 0xff000000) <> 0
delete memblock 255
delete memblock 256
exitfunction 1
endif
endif
inc Sprite1Addr, 4
inc Sprite2Addr, 4
next XOffset
next YOffset
delete memblock 255
delete memblock 256
endif
endFunction 0
The reason that its crashing is that the checking is extending past the end of the memblocks into memory not owned by the process.
I'll rework it tomorrow so that it does the job correctly.
*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++
http://www.matrix1.demon.co.uk