Page 3 of 9 FirstFirst 12345 ... LastLast
Results 21 to 30 of 81

Thread: FPC4GP2X status?

  1. #21

    FPC4GP2X status?

    I took your base code and changed it a bit. I made two sprites. The one could be moved horizontal by pressing d-pad and they other moved vertical using timebased movement. However it moves slower than on my pc, so I may have made something wrong.

    Btw. what's going on with the file sizes? The Pc version fills 45 KB while the GP2X fills 0.98 MB :shock:

    I've also taken a quick glimpse at Eugenes code, and he uses the mixer. I haven't actually tried the game yet on my GP2X (Out of batteries and it takes so long to recharge them), but if it works correctly I only have to worry about png support.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

  2. #22

    FPC4GP2X status?

    Sounds good so far guys!
    <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

    FPC4GP2X status?

    I have been away for the weekend on a secluded island which means that I've had some time to fool araound with my GP2X.
    I've been succesful reading input from the touchscreen*. It even worked at first attempt
    If any are interested in it (have a GP2X F200), I've uploaded the code and binaries here.
    It's not 100 % accurate since it isn't calibrated correct. I know some guys have manged to load the settings from the GP2X, so I'll have to look into that next.

    *Thanks to joyrider, hangman etc. @ gp32x.com and their example c code.

    @Paul
    I've also taken a closer look at Eugenes code and worked a bit with SDL_Mixer. Blocks work fine regarding playing ogg-files via mixer. However when I wrote my own testprogram it worked fine on windows, but crashed on the GP2X. But when I compiled the program I got a warning that said something about static linking versus dynamic linking. Your batchfiles use static linking while Eugenes uses dynamic linking. I'm not an expert at this area, but it could maybe solve the problems with mixer if I used dynamic linking instead. However I couldn't compile it using dynamic linking. How do I use dynamic linking?
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

  4. #24

    FPC4GP2X status?

    JEDI-SDL should dynamic link by default as long as it can find the *.so files for the various SDL libs. Not sure if that helps.
    <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 =-

  5. #25

    FPC4GP2X status?

    Ok, but it couldn't find all the *.so files (well at least on so-ile) when I tried dynamic linking. I know the file exists, but I don't know what to do now. The file should be in the search path, but yet it can't be found :?
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

  6. #26

    FPC4GP2X status?

    [quote="pstudio"]I have been away for the weekend on a secluded island which means that I've had some time to fool araound with my GP2X.
    I've been succesful reading input from the touchscreen*. It even worked at first attempt
    If any are interested in it (have a GP2X F200), I've uploaded the code and binaries here.
    It's not 100 % accurate since it isn't calibrated correct. I know some guys have manged to load the settings from the GP2X, so I'll have to look into that next.

    *Thanks to joyrider, hangman etc. @ gp32x.com and their example c code.

    @Paul
    I've also taken a closer look at Eugenes code and worked a bit with SDL_Mixer. Blocks work fine regarding playing ogg-files via mixer. However when I wrote my own testprogram it worked fine on windows, but crashed on the GP2X. But when I compiled the program I got a warning that said something about static ]

    Hi pstudio,
    Great work with the touch screen stuff :-)

    I was 'talking' to Eugene via email and asking him about dynamic linking and he says that he only uses static linking as he can't get a batch file? for dynamic linking...

    I also told him about the SDL_Mixer crashes on the gp2x and he suggested I make a small project with sound and send it to him so he can compile and test it. I am going to do this and I will get back to you guys when I know more.

    PS
    If it helps I had created a pascal unit that links some ARM asm which allows you to use access the gp2x linux system 'files' stuff ('/dev/fb0', etc) in the same way as the C/C++ guys do.

    libgp2x_asm.s
    Code:
    @ gp2x demo article code by Dzz
    @ this code is placed in the public domain.  do anything you want with it.
    
    	.align 4
    	.globl OpenFile
    	.globl CloseFile
    	.globl WriteFile
    	.globl MUnmap
    	.globl ChangeDir
    	.globl ExecuteFile
    	.globl MMap
    	.globl CopyScreen
    	.globl ClearScreen
    	.globl Ioctl3
    
    OpenFile&#58;
    	swi #0x900005
    	mov pc, lr
    
    CloseFile&#58;
    	swi #0x900006
    	mov pc, lr
    
    WriteFile&#58;
    	swi #0x900004
    	mov pc, lr
    
    MUnmap&#58;
    	swi #0x90005B
    	mov pc, lr
    
    ChangeDir&#58;
    	swi #0x90000C
    	mov pc, lr
    
    ExecuteFile&#58;
    	swi #0x90000B
    	mov pc, lr
    
    Ioctl3&#58;
    	swi #0x900036
    	mov pc, lr
    
    MMap&#58;
    	stmdb sp!, &#123;r0, r1, r2, r3&#125;
    	mov r0, sp
    	swi #0x90005A
    	add sp, sp, #16
    	mov pc, lr
    	
    CopyScreen&#58;
      stmfd sp!, &#123;r4-r10&#125;  @ remember registers 4-10
      mov r2, #4800        @ we will run the loop 4800 times to copy the screen
    .CopyScreenLoop&#58;
      ldmia r1!, &#123;r3-r10&#125;  @ pull in 32 bytes from the source
      stmia r0!, &#123;r3-r10&#125;  @ write the 32 bytes to the destination
      subs r2, r2, #1      @ decrement the loop counter
      bne .CopyScreenLoop  @ if we're not done, do it again
      ldmfd sp!, &#123;r4-r10&#125;  @ restore the registers
    	mov pc, lr           @ return
    
    ClearScreen&#58;
      stmfd sp!, &#123;r4-r10&#125;  @ remember registers 4-10
      mov r2, #4800        @ we will run the loop 4800 times to copy the screen
    	mov r3, #0           @ load up the registers with zeros
    	mov r4, #0
    	mov r5, #0
    	mov r6, #0
    	mov r7, #0
    	mov r8, #0
    	mov r9, #0
    	mov r10, #0
    .ClearScreenLoop&#58;
     stmia r0!, &#123;r3-r10&#125;  @ write the 32 bytes of zeros to the destination
     subs r2, r2, #1      @ decrement the loop counter
     bne .ClearScreenLoop @ if we're not done, do it again
     ldmfd sp!, &#123;r4-r10&#125;  @ restore the registers
     mov pc, lr           @ return
    assemble the .s file like so
    Code:
    arm-linux-gcc.exe -c libgp2x_asm.s
    libgp2x.pas
    Code:
    Unit libgp2x;
    &#123;$link libgp2x_asm.o&#125;
    &#123;$linklib c&#125;
    
    Interface
    
    Uses
        CTypes;
    
    Const
        MREMAP_MAYMOVE  = 1;
        MREMAP_FIXED    = 2;
    
        PROT_READ       = $1;		// page can be read
        PROT_WRITE      = $2;		// page can be written
        PROT_EXEC       = $4;		// page can be executed
        PROT_NONE       = $0;		// page can not be accessed
    
        MAP_SHARED      = $01;		// Share changes
        MAP_PRIVATE     = $02;		// Changes are private
    
    &#123;$IFDEF gp2x&#125;
        MAP_FIXED       = $10;		// Interpret addr exactly
        MAP_ANONYMOUS   = $20;		// don't use a file
        MAP_GROWSDOWN   = $0100;		// stack-like segment
        MAP_DENYWRITE   = $0800;		// ETXTBSY
        MAP_EXECUTABLE  = $1000;		// mark it as an executable
        MAP_LOCKED      = $2000;		// pages are locked
        MAP_NORESERVE   = $4000;		// don't check for reservations
        MS_ASYNC        = 1;		// sync memory asynchronously
        MS_INVALIDATE   = 2;		// invalidate the caches
        MS_SYNC         = 4;		// synchronous memory sync
        MCL_CURRENT     = 1;		// lock all current mappings
        MCL_FUTURE      = 2;		// lock all future mappings
        MADV_NORMAL     = $0;		// default page-in behavior
        MADV_RANDOM     = $1;		// page-in minimum required
        MADV_SEQUENTIAL = $2;		// read-ahead aggressively
        MADV_WILLNEED   = $3;		// pre-fault pages
        MADV_DONTNEED   = $4;		// discard these pages
        O_RDWR          = 2;
    &#123;$ENDIF&#125;
    
    // compatibility flags
        MAP_ANON	    = MAP_ANONYMOUS;
        MAP_FILE        = 0;
    
        MAP_FAILED      = Pointer&#40;-1&#41;;
    
    Type
        Tgp2xDevice = Class
        Protected
            FDev     &#58; ctypes.cint32;
            FMemData &#58; Pointer;
            FMemSize &#58; ctypes.cint32;
        Public
            Constructor Create&#40;pszFile&#58; PChar; nMode&#58; ctypes.cint32&#41;;
            Destructor  Destroy; Override;
            Procedure MapMem&#40;pAddr&#58; Pointer; nLen,nProtection,nFlags,nOff&#58; ctypes.cint32&#41;;
            Procedure UnmapMem;
            Property MemData&#58; Pointer Read FMemData;
        End;
    
    Function  OpenFile&#40;pszFile&#58; PChar; nMode&#58; ctypes.cint32&#41;&#58; ctypes.cint32;                    Cdecl; External;
    Procedure CloseFile&#40;nFile&#58; ctypes.cint32&#41;;                                                  Cdecl; External;
    Function  MMap&#40;pAddr&#58; Pointer; nLen,nProtection,nFlags,nFD,nOff&#58; ctypes.cint32&#41;&#58; Pointer;   Cdecl; External;
    Procedure MUnmap&#40;p&#58; Pointer; nSize&#58; ctypes.cint32&#41;;                                         Cdecl; External;
    Procedure ChangeDir&#40;pszDir&#58; PChar&#41;;                                                         Cdecl; External;
    Procedure ExecuteFile&#40;pszFile&#58; PChar; nZero1,nZero2&#58; ctypes.cint32&#41;;                        Cdecl; External;
    Function  Ioctl3&#40;fd&#58; ctypes.cint32; ulFunction,ulParameter&#58; ctypes.cushort&#41;&#58; ctypes.cint32; Cdecl; External;
    Procedure CopyScreen&#40;pDest,pSrc&#58; ctypes.pcushort&#41;;                                          Cdecl; External;
    Procedure ClearScreen&#40;pus&#58; ctypes.pcushort&#41;;                                                Cdecl; External;
    Procedure RestartMenu;
    Implementation
    
    Constructor Tgp2xDevice.Create&#40;pszFile&#58; PChar; nMode&#58; ctypes.cint32&#41;;
    Begin
        Inherited Create;
    
        FDev     &#58;= 0;
        FMemData &#58;= Nil;
        FMemSize &#58;= 0;
        FDev     &#58;= OpenFile&#40;pszFile,nMode&#41;;
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Destructor  Tgp2xDevice.Destroy;
    Begin
        UnmapMem;
        If FDev <> 0 Then
            CloseFile&#40;FDev&#41;;
    
        Inherited Destroy;
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Procedure Tgp2xDevice.UnmapMem;
    Begin
        If FMemData <> Nil Then
        Begin
            MUnmap&#40;FMemData,FMemSize&#41;;
            FMemData &#58;= Nil;
            FMemSize &#58;= 0;
        End;
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Procedure Tgp2xDevice.MapMem&#40;pAddr&#58; Pointer; nLen,nProtection,nFlags,nOff&#58; ctypes.cint32&#41;;
    Begin
        UnmapMem;
    
        FMemSize &#58;= nLen;
        FMemData &#58;= MMap&#40;pAddr, FMemSize, nProtection, nFlags, FDev, nOff&#41;;
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Procedure RestartMenu;
    Begin
        ChangeDir  &#40;PChar&#40;'/usr/gp2x'&#41;&#41;;
        ExecuteFile&#40;PChar&#40;'/usr/gp2x/gp2xmenu'&#41;, 0, 0&#41;;
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    End.
    usage examples
    Code:
    Const
        cRscale  = 5;
        cGscale  = 6;
        cBscale  = 5;
        cRshift  = 11;
        cGshift  = 5;
        cBshift  = 0;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Function RGBTo16Bit&#40;r,g,b&#58; Uint8&#41;&#58; Uint16;
    Begin
        Result &#58;= &#40;&#40;&#40;r Shl cRscale&#41; Shl 8&#41; Shl cRshift&#41; +
                  &#40;&#40;&#40;g Shl cGscale&#41; Shl 8&#41; Shl cGshift&#41; +
                  &#40;&#40;&#40;b Shl cBscale&#41; Shl 8&#41; Shl cBshift&#41;;
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
        Ffb0 &#58;= Tgp2xDevice.Create&#40;'/dev/fb0', O_RDWR&#41;;
        Ffb1 &#58;= Tgp2xDevice.Create&#40;'/dev/fb1', O_RDWR&#41;;
    
        FWidth        &#58;= 320;
        FHeight       &#58;= 240;
        FBitsPerPixel &#58;= 16;
        Ffb0.MapMem&#40;Nil, FWidth * FHeight * &#40;FBitsPerPixel Div 8&#41;, PROT_WRITE, MAP_SHARED, 0&#41;;
        Ffb1.MapMem&#40;Nil, FWidth * FHeight * &#40;FBitsPerPixel Div 8&#41;, PROT_WRITE, MAP_SHARED, 0&#41;;
    
    &#123;...&#125;
    Procedure TRendererModule_gp2x.ClearScreen&#40;r,g,b&#58; Byte&#41;;
    Var
        c    &#58; Uint32;
        i    &#58; LongInt;
        addr &#58; PUint8;
    Begin
        c &#58;= RGBTo16Bit&#40;r,g,b&#41;;
        addr &#58;= Ffb1.MemData;
        i &#58;= FWidth * FHeight;
        While i <= 0 Do
        Begin
            PUint16&#40;addr&#41;^ &#58;= Uint16&#40;c&#41;;
            Inc&#40;addr,2&#41;;
            Dec&#40;i&#41;;
        End;
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    Procedure TRendererModule_gp2x.FlipScreen;
    Begin
        CopyScreen&#40;Ffb0.MemData,Ffb1.MemData&#41;;
    End;
    &#123;..............................................................................&#125;
    
    &#123;..............................................................................&#125;
    
    &#123;...&#125;
        Ffb0.Free;
        Ffb1.Free;
    You could use this for your touchscreen code as well by opening up the device using the Tgp2xDevice class.

    Enjoy

    cheers,
    Paul

  7. #27

    FPC4GP2X status?

    Nice work!

    Have you done some speed test? Which is faster, SDL or your code?

    I have some code for direct access to buttons, now we have some code for display, if we get code for playing sounds / music, we can create small programs without using external libraries.

    cheers,
    Thomas

  8. #28

    FPC4GP2X status?

    Note that most routines in the above libgp2x unit are already present in the baseunix unit and you are doing double work.

  9. #29

    FPC4GP2X status?

    Quote Originally Posted by dmantione
    Note that most routines in the above libgp2x unit are already present in the baseunix unit and you are doing double work.
    Hi dmantione,
    thanks for the info, I didn't realize :-)
    Which routines are present in the baseunix unit?

    cheers,
    Paul.

  10. #30

    FPC4GP2X status?

    That question is best answered by its documentation:

    http://www.freepascal.org/docs-html/...x/index-5.html

Page 3 of 9 FirstFirst 12345 ... 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
  •