Page 8 of 9 FirstFirst ... 6789 LastLast
Results 71 to 80 of 81

Thread: FPC4GP2X status?

  1. #71

    FPC4GP2X status?

    [quote="savage"]Legolas, any chance you can throw together some instructions on getting FPC and SDL running on DS or GBA. Or are there ]

    Finally got my laptop repaired. Give me some time to reorganize it and I'll try
    Get your fpc4gba copy now!
    Get your fpc4nds copy now!

  2. #72

    FPC4GP2X status?

    ExecuteFile("gp2xmenu",0,0) (as per above) kills USB, and the only chance to connect it again is to restart the gp2x (or maybe remove/insert the cable). dzz said he'd fixed that in version 6 (demo6b.zip).

    I read up on execve() and the second parameter must be an array of strings containing environment variables (for USB to work), but I have no idea what strings to give it.

    Any ideas? This is getting annoying. Argh!
    Henrik Erlandsson, programmer
    <br />bitBrain Studios, bitbrain.se
    <br />(Done 7 sites so far, but who's counting?)

  3. #73

    FPC4GP2X status?

    Quote Originally Posted by HenrikE
    ExecuteFile("gp2xmenu",0,0) (as per above) kills USB, and the only chance to connect it again is to restart the gp2x (or maybe remove/insert the cable). dzz said he'd fixed that in version 6 (demo6b.zip).

    I read up on execve() and the second parameter must be an array of strings containing environment variables (for USB to work), but I have no idea what strings to give it.

    Any ideas? This is getting annoying. Argh!
    I have to admit I haven't used ExecuteFile myself - I use the code below:

    Code:
        chdir         &#40;'/usr/gp2x'&#41;;
        ExecuteProcess&#40;'/usr/gp2x/gp2xmenu',&#91;'/usr/gp2x/gp2xmenu'&#93;&#41;;
    hope this helps,
    cheers,
    Paul

  4. #74

    FPC4GP2X status?

    Paul,

    have you any working sample with playing music/sound und timer? And if, coud you send me this sample?

    Best Regards
    Thomas

  5. #75

    FPC4GP2X status?

    Quote Originally Posted by paul_nicholls
    Quote Originally Posted by HenrikE
    ExecuteFile("gp2xmenu",0,0) (as per above) kills USB, and the only chance to connect it again is to restart the gp2x (or maybe remove/insert the cable). dzz said he'd fixed that in version 6 (demo6b.zip).

    I read up on execve() and the second parameter must be an array of strings containing environment variables (for USB to work), but I have no idea what strings to give it.

    Any ideas? This is getting annoying. Argh!
    I have to admit I haven't used ExecuteFile myself - I use the code below:

    Code:
        chdir         &#40;'/usr/gp2x'&#41;;
        ExecuteProcess&#40;'/usr/gp2x/gp2xmenu',&#91;'/usr/gp2x/gp2xmenu'&#93;&#41;;
    hope this helps,
    cheers,
    Paul
    Well, I'll use anything that results in an Execve kernel call! (swi 0x90000b). So if yours uses RTL or libs, it's out I'm afraid. Also, my c notation skills are not (yet? ever?) at the point where I can create an array of pointers. All those * and ) and &...

    Anyway, made USBnet work, so now USB stays connected and I can compile and test an updated .gpe with 5 button presses. So the problem is not urgent anymore; I have the fastest possible dev setup now.

    Thanks for helping me Paul!
    Henrik Erlandsson, programmer
    <br />bitBrain Studios, bitbrain.se
    <br />(Done 7 sites so far, but who's counting?)

  6. #76

    FPC4GP2X status?

    Quote Originally Posted by KidPaddle
    Paul,

    have you any working sample with playing music/sound und timer? And if, coud you send me this sample?

    Best Regards
    Thomas
    Hi Thomas,
    The only sound stuff I could get working on the GP2X (and Win32) was using .wav files only and the code below (hacked together from C examples off the web). I still can't get SDL_Mixer working under the GP2X

    The following code is not complete, but at least it plays .wav sounds...
    The StopSound and all music methods don''t do anything yet (I was going to see if I could stream a large .wav file in chunks as music).

    You use it like so:

    First, you 'register' any sounds you want to load and play later:

    Code:
    FAudioModule.RegisterSound_WAV&#40;'miss_sound'         ,FDataPath + 'miss.wav'&#41;;
    then later on when you want to play the sound:
    Code:
    FAudioModule.PlaySound_WAV&#40;'miss_sound'&#41;;
    Code:
    Unit EngineAudio_sdl;
    &#123;$IFDEF fpc&#125;
    &#123;$mode delphi&#125;&#123;$H+&#125;
    &#123;$ENDIF&#125;
    Interface
    
    Uses
        SDL,
        Classes;
    
    Type
    &#123;..............................................................................&#125;
        TAudioModule_sdl = Class
        Private
            FSoundNames       &#58; TStringList;
            FAudioInitialized &#58; Boolean;
        Public
            Constructor Create;                                          
            Destructor  Destroy;                                         Override;
            Function  InitAudio&#58; Boolean;                                
            Procedure RegisterSound_WAV&#40;AName,AFileName&#58; AnsiString&#41;;    
            Function  PlaySound_WAV    &#40;AName &#58; AnsiString&#41;&#58; Boolean;    
            Procedure StopSound_WAV    &#40;AChannel&#58; Integer&#41;;              
            Procedure RegisterMusic_WAV&#40;AName,AFileName&#58; AnsiString&#41;;    
            Function  PlayMusic_WAV    &#40;AName &#58; AnsiString&#41;&#58; Boolean;    
            Procedure StopMusic_WAV;                                     
            Procedure CloseAudio;                                        
        End;
    &#123;..............................................................................&#125;
    
    Implementation
    
    Uses
        SDL_Mixer;
        
    Const
    &#123;..............................................................................&#125;
        cMaxSounds = 40;
    &#123;..............................................................................&#125;
    
    Type
    &#123;..............................................................................&#125;
        TSound = Class
        Public
            channel &#58; Integer;
            data    &#58; PUint8;
            dpos    &#58; Uint32;
            dlen    &#58; Uint32;
            Constructor Create;
            Destructor  Destroy;           Override;
            Procedure Update&#40;stream&#58; PUint8; len&#58; Integer&#41;; Virtual;
            Function  Playing &#58; Boolean;
        End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
        TMusic = Class&#40;TSound&#41;
        Public
            Procedure Update&#40;stream&#58; PUint8; len&#58; Integer&#41;; Override;
        End;
    &#123;..............................................................................&#125;
    
    Var
        Sounds &#58; Array&#91;0..cMaxSounds - 1&#93; Of TSound;
        Music  &#58; TMusic;
    
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Constructor TSound.Create;
    Begin
        Inherited Create;
        data &#58;= Nil;
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Destructor  TSound.Destroy;
    Begin
        If data <Nil> len Then
            amount &#58;= len;
        SDL_MixAudio&#40;stream, @PByteArray&#40;data&#41;^&#91;dpos&#93;, amount, SDL_MIX_MAXVOLUME&#41;;
        Inc&#40;dpos,amount&#41;;
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Function  TSound.Playing &#58; Boolean;
    Begin
        Result &#58;= dpos < dlen;
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Procedure TMusic.Update&#40;stream&#58; PUint8; len&#58; Integer&#41;;
    Begin
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Procedure MixAudioProc&#40;unused&#58; Pointer; stream&#58; PUint8; len&#58; Integer&#41;; cdecl;
    Var
        i &#58; Integer;
    Begin
        For  i &#58;= 0 To cMaxSounds - 1 Do
        Begin
            If Sounds&#91;i&#93; <> Nil Then
            Begin
                Sounds&#91;i&#93;.Update&#40;stream,len&#41;;
                If Not Sounds&#91;i&#93;.Playing Then
                Begin
                    Sounds&#91;i&#93;.Free;
                    Sounds&#91;i&#93; &#58;= Nil;
                End;
            End;
        End;
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Constructor TAudioModule_sdl.Create;
    Begin
        Inherited Create;
        FSoundNames       &#58;= TStringList.Create;
        FAudioInitialized &#58;= False;
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Destructor TAudioModule_sdl.Destroy;
    Begin
        FSoundNames.Free;
        Inherited Destroy;
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Function  TAudioModule_sdl.InitAudio&#58; Boolean;
    Var
        fmt &#58; TSDL_AudioSpec;
    Begin
        Result &#58;= False;
        // Set 16-bit stereo audio at 22Khz
        fmt.freq &#58;= 22050;
        fmt.format &#58;= AUDIO_S16;
        fmt.channels &#58;= 2;
        fmt.samples &#58;= 512;        // A good value for games
        fmt.callback &#58;= MixAudioProc;
        fmt.userdata &#58;= Nil;
    
        // Open the audio device
        If SDL_OpenAudio&#40;@fmt, Nil&#41; < 0 Then
        Begin
            //fprintf&#40;stderr, "Unable to open audio&#58; %s\n", SDL_GetError&#40;&#41;&#41;;
            Exit;
        End;
        SDL_PauseAudio&#40;0&#41;;
        Result &#58;= True;
        FAudioInitialized &#58;= True;
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Procedure TAudioModule_sdl.CloseAudio;
    Begin
        If FAudioInitialized Then
            SDL_CloseAudio;
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Procedure TAudioModule_sdl.RegisterSound_WAV&#40;AName,AFileName&#58; AnsiString&#41;;
    Begin
        FSoundNames.Add&#40;AName + '=' + AFileName&#41;;
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Function  TAudioModule_sdl.PlaySound_WAV&#40;AName&#58; AnsiString&#41; &#58; Boolean;
    Var
        index    &#58; Integer;
        wave     &#58; TSDL_AudioSpec;
        data     &#58; PUint8;
        dlen     &#58; Uint32;
        cvt      &#58; TSDL_AudioCVT;
        FileName &#58; AnsiString;
    Begin
        Result &#58;= False;
        If Not FAudioInitialized Then Exit;
        // Look for an empty &#40;or finished&#41; sound slot
        index &#58;= 0;
        While index < cMaxSounds Do
        Begin
            If sounds&#91;index&#93; = Nil Then Break;
            Inc&#40;index&#41;;
        End;
        If index = cMaxSounds Then Exit;
        FileName &#58;= FSoundNames.Values&#91;AName&#93;;
        // Load the sound file and convert it to 16-bit stereo at 22kHz
        If SDL_LoadWAV&#40;PChar&#40;FileName&#41;, @wave, @data, @dlen&#41; = Nil Then
        Begin
    //        fprintf&#40;stderr, "Couldn't load %s&#58; %s\n", file, SDL_GetError&#40;&#41;&#41;;
    //        return;
            Exit;
        End;
        SDL_BuildAudioCVT&#40;@cvt,
                          wave.format,
                          wave.channels,
                          wave.freq,
                          AUDIO_S16,
                          2,
                          22050&#41;;
        GetMem&#40;cvt.buf,dlen * cvt.len_mult&#41;;
        Move&#40;data^,cvt.buf^,dlen&#41;;
        cvt.len &#58;= dlen;
        SDL_ConvertAudio&#40;@cvt&#41;;
        SDL_FreeWAV&#40;data&#41;;
    
        // Put the sound data in the slot &#40;it starts playing immediately&#41;
        SDL_LockAudio;
        sounds&#91;index&#93; &#58;= TSound.Create;
        sounds&#91;index&#93;.channel &#58;= index;
        sounds&#91;index&#93;.data    &#58;= cvt.buf;
        sounds&#91;index&#93;.dlen    &#58;= cvt.len_cvt;
        sounds&#91;index&#93;.dpos    &#58;= 0;
        SDL_UnlockAudio;
        Result &#58;= True;
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Procedure TAudioModule_sdl.StopSound_WAV&#40;AChannel &#58; Integer&#41;;
    Begin
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Procedure TAudioModule_sdl.RegisterMusic_WAV&#40;AName,AFileName&#58; AnsiString&#41;;
    Begin
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Function  TAudioModule_sdl.PlayMusic_WAV&#40;AName &#58; AnsiString&#41;&#58; Boolean;
    Begin
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Procedure TAudioModule_sdl.StopMusic_WAV;
    Begin
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Procedure InitSounds;
    Var
        i &#58; Integer;
    Begin
        For i &#58;= 0 To cMaxSounds - 1 Do
            Sounds&#91;i&#93; &#58;= Nil;
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Initialization
        InitSounds;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    End.
    I hope this helps,
    cheers,
    Paul

  7. #77

    FPC4GP2X status?

    Quote Originally Posted by HenrikE
    Quote Originally Posted by paul_nicholls
    Quote Originally Posted by HenrikE
    ExecuteFile("gp2xmenu",0,0) (as per above) kills USB, and the only chance to connect it again is to restart the gp2x (or maybe remove/insert the cable). dzz said he'd fixed that in version 6 (demo6b.zip).

    I read up on execve() and the second parameter must be an array of strings containing environment variables (for USB to work), but I have no idea what strings to give it.

    Any ideas? This is getting annoying. Argh!
    I have to admit I haven't used ExecuteFile myself - I use the code below:

    Code:
        chdir         &#40;'/usr/gp2x'&#41;;
        ExecuteProcess&#40;'/usr/gp2x/gp2xmenu',&#91;'/usr/gp2x/gp2xmenu'&#93;&#41;;
    hope this helps,
    cheers,
    Paul
    Well, I'll use anything that results in an Execve kernel call! (swi 0x90000b). So if yours uses RTL or libs, it's out I'm afraid. Also, my c notation skills are not (yet? ever?) at the point where I can create an array of pointers. All those * and ) and &...

    Anyway, made USBnet work, so now USB stays connected and I can compile and test an updated .gpe with 5 button presses. So the problem is not urgent anymore; I have the fastest possible dev setup now.

    Thanks for helping me Paul!
    Glad I could help in any way :-)
    Sounds like you are doing nicely so far...would it be possible to see what you have done upto this point?

    cheers,
    Paul

  8. #78

    FPC4GP2X status?

    I optimized senquack's/A_SN's 32bpp to 16bpp asm code yesterday, but it uses R0-R14, so I need to save sp (R13). However, apparently I must first make the asm section writable, since I can't even call an asm routine that stores any register in a declared word in the asm source!

    Storing it in any of the areas mmapped in the c startup code doesn't help me, since if I pass the pointer to where to store to the blitter routine, it gets clobbered, and ofc I can't store it temporarily as per above. Being devious and trying to store it "after the pixels" in the physical framebuffer range doesn't help either, since it's the mmapped range that has write permissions I guess...

    I'm looking at some clues, will probably have something nice this evening.
    Henrik Erlandsson, programmer
    <br />bitBrain Studios, bitbrain.se
    <br />(Done 7 sites so far, but who's counting?)

  9. #79

    FPC4GP2X status?

    @paul_nicholls

    Thanks for source, i will try it at weekend. At the moment, i have problems to connect to my gp2x over USB.

    Cheers,
    Thomas

  10. #80

    FPC4GP2X status?

    Quote Originally Posted by KidPaddle
    @paul_nicholls

    Thanks for source, i will try it at weekend. At the moment, i have problems to connect to my gp2x over USB.

    Cheers,
    Thomas
    The only connection problems I have had with my GP2X is I could never get the &%*$^#^$!!! samba working.

    This means I can't connect via the GP2X samba server (only FTP or telnet), or setup a windows share folder that I am supposed to be able to run gp2x programs from via the gp2x and save on copying my programs to my SD card before I can test them

    Anyone here been able to do that at all?
    If so, perhaps you could help me there

    cheers,
    Paul

Page 8 of 9 FirstFirst ... 6789 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
  •