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.
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 );