Help, I'm melting

Published August 01, 2006
Advertisement
There needs to be some sort of law where if the outside temperature is too high we get to stay home. I say we make it between -40 and 40(Celsius), that seems fair. I'm tired of literally melting at work.

Anyway I've implement sprites into GB.Net, although currently it only supports 8x8 sprites and not 8x16. I've also changed the map and tile code so it doesn't do everything tile-tile, pixel-pixel. Now I just have the data read the data into a large byte[] array and use Stream.Write(). This gives me an FPS of 110 in debug and 240 in release.

There's a problem with reading in the object data though. Well it works, but it's a horrible unsafe and ugly hack.

See I have a struct:
	[InteropServices.StructLayout(InteropServices.LayoutKind.Sequential)]	private struct ObjectData	{		internal int X;		internal int Y;		internal int Tile;		internal int Priority;	  	internal int Flip;	  	internal int Palette;	}


and an array of said struct:
private static ObjectData[] DataArray = new ObjectData[40];

The problem occurs with passing the array to the DLL.
extern "C" DLLEXPORT void GetObjectData( ObjectData *DataArray )

When I tried to pass the array as is like:
GetObjectData( ref DataArray );

It would either do nothing at all or crash. I guess it was trying to pass the Array object itself. Anyway right now I'm just pass the first element:
GetObjectData( ref DataArray[0] );

This works, but it just doesn't seem right to assume .Net arrays operate the same way as C arrays.

So anyone know a better way to do this?

Screenshot time:

The ships on the left are the sprites.
0 likes 4 comments

Comments

Scet
Oh yeah I forgot it is actually using ref. However when passing the whole Array object with or without ref, it crashes.

This is the current one, where I just pass the first element:

[InteropServices.DllImport("SharpBoy.dll", EntryPoint = "GetObjectData")]
private static extern void GetData( ref ObjectData DataArray );
August 01, 2006 06:01 PM
Scet
Thanks AP, it needed to use [In,Out].
August 02, 2006 06:07 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement