Strange problem with C# + SDL

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Strange problem with C# + SDL
by on (#76824)
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:
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?)

by on (#76826)
You could just make it a DLL, and mix C# with non C# code. I was very unimpressed with the SDL port for C#.

by on (#76828)
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 ^^