Page 1 of 1

Strange problem with C# + SDL

Posted: Fri Apr 15, 2011 9:02 pm
by ehguacho
hi there! now my 6502 emulator matches exactly Nestest.log, i'm moving to the graphics routine. i've moved all my code to MVS C# 2010 + SDL, and when trying to run (e.g.) Balloon Fight it stops rendering after the title screen. on the other hand, using the same code in Code::Blocks + Allegro, the game runs perfectly. therefore, i'm assuming that i'm having some issues with something related directly with SDL.

start counting from 0, after scanline #242 (when VBlank starts) i'm calling the drawing routine (see below).

Code: Select all

static public void DrawFrame()
{
        Surface Pixel = new Surface(PixelSize, PixelSize, 32);

        for (int X = 0; X < 256; X++)
        {
                for (int Y = 0; Y < 240; Y++)
                {
                        // Pantalla = Screen in spanish (:
                        Pixel.Fill(Color.FromArgb((int)ScreenBuffer[X, Y]));
                        Pantalla.Blit(Pixel, new Point(X * PixelSize, Y * PixelSize));
                }
        }

        Pantalla.Update();

        return;
}
i'm not asking for a SDL tutorial, there's a lot of forums out there for that, i'm just asking for someone who had a similar problem that helps me on where to start to looking at to solve this issue.

aslo, i didn't implement a frame regulator, so the FPS are completely crazy: using C# + SDL, the title screen takes about 5 seconds to show up, while using Code::Block + Allegro it appears almost instantly. plus, while using C# + SDL, my computer goes into 100% of usage, and there's no chance to switch to another application without having a big delay, while when using Code::Block + Allegro it works normally, with no delays.

i need to code the emulator in C# to make a more friendly interface for it, so it has to be SDL (otherwise, what do you recommend?)

Posted: Fri Apr 15, 2011 9:11 pm
by Dwedit
You could just make it a DLL, and mix C# with non C# code. I was very unimpressed with the SDL port for C#.

Posted: Fri Apr 15, 2011 9:38 pm
by ehguacho
good point, but what about data types, runtimes and stuff like that?

PD: everything would be easier if knew how to use MVC++ 6.0 ^^