Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 32

Thread: GP2X/FPC Issues

  1. #21

    GP2X/FPC Issues

    Where are you running this code that crashes?

    You need to tell the compiler that this is a console Application otherwise the calls to *writeln* will AV. Which is what I am seeing.

    The following works for me on Windows.

    [pascal]
    program Thread;

    {$APPTYPE CONSOLE}

    uses
    sdl;

    var
    thread : PSDL_Thread;
    returnValue : Integer;

    function thread_func( aData : pointer ) : integer; cdecl;
    begin
    // do threading here
    WriteLn( 'Start Thread' );
    SDL_Delay( 5000 );
    WriteLn( 'End Thread' );

    result := 1; // thread leaves and return this value
    end;

    begin
    returnValue := 0;

    thread := SDL_CreateThread( @thread_func, nil );

    SDL_WaitThread( thread, returnValue );
    WriteLn( 'Thread returns code ', returnValue );
    SDL_Quit;
    WriteLn( 'ByeBye ' );
    end.
    [/pascal]

    On other platforms you may have to specifcy the *cdecl* call and the pointer parameter as well to avoid the AV.

    As for timers, the following example works for me....
    [pascal]
    program SDLTimers;

    {$APPTYPE CONSOLE}

    uses
    SysUtils,
    sdl;

    var
    Timer1 : PSDL_TimerID;
    Timer2 : PSDL_TimerID;
    Param1 : Integer;
    Param2 : Integer;

    function CallTimer1( interval : UInt32; param : Pointer ) : UInt32; cdecl;
    var
    pParam : PInteger;
    begin
    pParam := PInteger( param );
    WriteLn( 'Parameter = ' + IntToStr( pParam^ ) + ' in CallTimer1' );
    Result := interval;
    end;

    function CallTimer2( interval : UInt32; param : Pointer ) : UInt32; cdecl;
    var
    pParam : PInteger;
    begin
    pParam := PInteger( param );
    WriteLn( 'Parameter = ' + IntToStr( pParam^ ) + ' in CallTimer2' );
    Result := interval;
    end;

    begin
    if ( SDL_Init( SDL_INIT_TIMER ) <> 0 ) then
    WriteLn( 'Cannot initalize SDL' );

    // Adding Timers
    WriteLn( 'Adding Timers +' );
    Param1 := 12;
    Param2 := 15;
    Timer1 := SDL_AddTimer( 500, CallTimer1, @Param1 );
    Timer2 := SDL_AddTimer( 1200, CallTimer2, @Param2 );

    WriteLn( 'SDL_Delay 30 secs, so we can see the timers in operation' );
    SDL_Delay( 30000 );

    WriteLn( 'Removing Timers -' );
    SDL_RemoveTimer( Timer2 );
    SDL_RemoveTimer( Timer1 );

    WriteLn( 'Ciao ' );
    ReadLn;
    SDL_Quit;
    end.
    [/pascal]

    Does it work for you?
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  2. #22

    GP2X/FPC Issues

    Btw, I tested both of these apps with Delphi and FreePascal on Windows. Hopefully they should work exactly as advertised on other platforms.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  3. #23

    GP2X/FPC Issues

    Hi Thomas
    I googled for 'MPEGerror.h and found this file:

    http://svn.icculus.org/*checkout*/sm...Gerror.h?rev=2

    So it sounds like something else is causing this class to be used to produce the error.

    I did try adding SDL_INIT_TIMER to my SDL_Init() call, but it still crashes on my GP2X

    I haven't tried running it using gdb again with the SDL_INIT_TIMER to see if it is the same error as before though...

    cheers,
    Paul.

  4. #24

    GP2X/FPC Issues

    Hi,

    @savage
    My sample crashed only on GP2X, on Windows it works perfectly. I will try your sample today.

    @Paul
    You got nearly the same stack trace, only a few higher level calls are missing, but after calling SDL_CreateThread, it crashed in function __pthread_initialize_manager ().

    Thomas

  5. #25

    GP2X/FPC Issues

    Hi savage,

    if have tested both samples from you, under windows it works perfect, on gp2x it crashed always in function __pthread_initialize_manager.

    Cheers,
    Thomas

  6. #26

    GP2X/FPC Issues

    I've posted a message about it on the main SDL mailing list, so will see what they come back with.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  7. #27

    GP2X/FPC Issues

    Thanks for open a post on libsdl mailing list, but i believe it has nothing to do with sdl.

    I have installed the official gph sdk and compiled the thread sample. After executing on gp2x i got following debugger output:

    Code:
    Starting program&#58; /mnt/sd/Test/fpc/fpc4gp2x/fpcthread.gpe
    
    Program received signal SIGSEGV, Segmentation fault.
    0x00000000 in ?? &#40;&#41;
    &#40;gdb&#41; info stack
    #0  0x00000000 in ?? &#40;&#41;
    #1  0x00075ecc in ptmalloc_init &#40;&#41; at malloc.c&#58;1760
    #2  0x00077630 in malloc_hook_ini &#40;sz=792, caller=0x75b6c&#41; at malloc.c&#58;1856
    #3  0x000774ac in __libc_malloc &#40;bytes=989568&#41; at malloc.c&#58;2797
    #4  0x0004da7c in SDL_CreateThread &#40;fn=0x8118 <THREAD_FUNC>, data=0x0&#41; at SDL_thread.c&#58;228
    #5  0x000081e4 in main &#40;&#41; at fpcthread.dpr&#58;26
    As you can see, the gph sdk has more debug symbols insight, so we got a better error location.

    I wrote a smaller sample, like this:
    Code:
    program fpcmalloc;
    &#123;$IFNDEF FPC&#125;
      &#123;$APPTYPE CONSOLE&#125;
    &#123;$ENDIF&#125;
    
    function  malloc&#40;aSize &#58; Integer&#41;&#58; Pointer; cdecl; external;
    procedure free&#40;aPtr &#58; Pointer&#41;; cdecl; external;
    
    var
      MemPtr           &#58; Pointer;
    begin
      WriteLn&#40;'Alloc 792 Bytes'&#41;;
      MemPtr &#58;= Malloc&#40;792&#41;;
    
      WriteLn&#40;'Release 792 Bytes'&#41;;
      Free&#40;MemPtr&#41;;
      
      WriteLn&#40;'ByeBye'&#41;;
    end.
    The output under gp2x is:

    Code:
    Starting program&#58; /mnt/sd/Test/fpc/fpc4gp2x/fpcmalloc.gpe
    Alloc 792 Bytes
    
    Program received signal SIGSEGV, Segmentation fault.
    0x00000000 in ?? &#40;&#41;
    &#40;gdb&#41; info stack
    #0  0x00000000 in ?? &#40;&#41;
    #1  0x00034f70 in ptmalloc_init &#40;&#41; at malloc.c&#58;1756
    #2  0x0003670c in malloc_hook_ini &#40;sz=792, caller=0x0&#41; at malloc.c&#58;1856
    #3  0x00036588 in __libc_malloc &#40;bytes=230028&#41; at malloc.c&#58;2797
    #4  0x00008168 in main &#40;&#41; at fpcmalloc.dpr&#58;13
    I don't know if I'm right, but i look at ptmalloc_init ();

    Cheers,
    Thomas

  8. #28

    GP2X/FPC Issues

    So do you think the problem is in the FreePascal memory allocation?
    That it is incompatible with how GP2X expects it?
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  9. #29

    GP2X/FPC Issues

    I don't know. Using GetMem/FreeMem works, maybe there is something wrong with static linking of libc, but that is guessed.

    Thomas

  10. #30

    GP2X/FPC Issues

    Hi all!
    I used the fpc4gp2x from eonclash.com and got the same problem...crash when trying to use the mixer, when statically linking. All the graphics & joystick stuff works find though...thanks Paul :-)

    I noticed that the Eugene Proshkin's Blocks program is dynamically linked and the sound is working fine.

    However I couldnt work out how to dynamically link from his compiler files. Has anyone been able to dynamically link using fpc4gp2x on Windows? I keep getting all sorts of linking errors.

Page 3 of 4 FirstFirst 1234 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •