The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Transcendencja on April 04, 2007, 06:44:57 PM

Title: Problem when using SDL...
Post by: Transcendencja on April 04, 2007, 06:44:57 PM
Hello again!
I'm trying to write simple game with SDL and I don't know what's going on.
My code:

        push SDL_INIT_VIDEO
        call [SDL_Init]
        add esp, 0x4

        push SDL_SWSURFACE
        push 0x20
        push 0x1E0
        push 0x280
        call [SDL_SetVideoMode]
        add esp, 0x10

        mov dword [sdl_screen_ptr], eax
       
        push eax
        call [SDL_LockSurface]
        add esp, 0x4

Now, I want to use SDL_Surface.pixels pointer (SDL_SetVideoMode returns pointer to SDL_Surface *screen) and draw something, but it has value 0x0000baad. I tried doing it with locking and without locking, but results was the same. Applications written in C++ work fine. Maybe I'm missing something? :/
Title: Re: Problem when using SDL...
Post by: japheth on April 04, 2007, 08:33:20 PM
search your definition of SDL_Surface. For MASM it should begin like this:

SDL_Surface struct 4

It's important that members are dword aligned
Title: Re: Problem when using SDL...
Post by: Transcendencja on April 04, 2007, 08:45:10 PM
Thanks. ;)