Page 7 of 9 FirstFirst ... 56789 LastLast
Results 61 to 70 of 81

Thread: FPC4GP2X status?

  1. #61

    FPC4GP2X status?

    Regarding the thread topic, the FPC4GP2x page seems to not have been updated for a while. Does that mean the links to downloads are still viable to get stuff working?

    Reason I'm asking is cos I'm having trouble coding inline asm and accessing vars/simply adding labels. ppcrossarm complains.

    I would like to code and debug asm (and perhaps pascal) on pc for GP2x - at least find syntax errors. Possible? I'm still looking for a doc that tells me the exact syntax of the assembler code I can use. Also, I'd like to just use pascal, no delphi and sdl.

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

  2. #62

    FPC4GP2X status?

    Hi Henrik,
    All the downloads are still valid on the fpc4gp2x page, it is just I haven't had any updates to put on the page for a while now (as you noticed).

    I haven't done much in the way of ARM assembly myself yet, but if you want to learn ARM assembly programming, this site may help

    http://www.heyrick.co.uk/assembler/

    If you scroll down a bit you will see a An introduction to assembler link that you can follow, and right below that link is the ARM instruction set information.

    Even though it is for the ARM processor in the BBC computer, quit a bit should still be relevant to GP2X programming :-)

    On this topic of ARM assembly, I did manage to get a small assembler library file off the internet to compile to an .o file using the devkitGP2X arm-linux-gcc.exe program.

    Code:
    arm-linux-gcc.exe -c libgp2x_asm.s
    libgp2x_asm.s file

    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
    I was then able to link it into my FPC gp2x code, and with a header file I whipped up, use the routines in it. Some of the stuff below is duplicated in various FPC files already, but at the time I didn't know that <G> It is still usefull though :-)

    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; color&#58; ctypes.cuint16&#41;;                         Cdecl; External;
    Procedure ClearScreen&#40;pus&#58; ctypes.pcushort&#41;;                                                Cdecl; External;
    Procedure RestartMenu;
    &#123;
    extern int OpenFile&#40;char *pszFile, int nMode&#41;;
    extern void CloseFile&#40;int nFile&#41;;
    extern void *MMap&#40;void *pAddr, int nLen, int nProtection, int nFlags, int nFD, int nOff&#41;;
    extern void MUnmap&#40;void *p, int nSize&#41;;
    extern void ChangeDir&#40;char *pszDir&#41;;
    extern void ExecuteFile&#40;char *pszFile, int nZero1, int nZero2&#41;;
    extern int Ioctl3&#40;int fd, unsigned int ulFunction, unsigned int ulParameter&#41;;
    extern void CopyScreen&#40;unsigned short *pDest, unsigned short *pSrc&#41;;
    extern void ClearScreen&#40;unsigned short *pus&#41;;
    extern void RestartMenu&#40;&#41;;
    &#125;
    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.
    Using the above code I was able to write directly to the GP2X framebuffer pixels like so:

    Code:
    Function RGBTo16Bit&#40;r,g,b&#58; Uint8&#41;&#58; Uint16;
    Begin
        Result &#58;= &#40;&#40;&#40;r Shl cRscale&#41; Shr 8&#41; Shl cRshift&#41; +
                  &#40;&#40;&#40;g Shl cGscale&#41; Shr 8&#41; Shl cGshift&#41; +
                  &#40;&#40;&#40;b Shl cBscale&#41; Shr 8&#41; Shl cBshift&#41;;
    End;
    &#123;..............................................................................&#125;
    
    &#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;
    // open the frame buffers
        Ffb0 &#58;= Tgp2xDevice.Create&#40;'/dev/fb0', O_RDWR&#41;;
        Ffb1 &#58;= Tgp2xDevice.Create&#40;'/dev/fb1', O_RDWR&#41;;
    
    // map the memory so you can read/write to the frame buffers
        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;;
    
    
    Var
        dstAddr &#58; Puint8;
        c           &#58; Uint16;
     
    // how to write to the frame buffer
                c &#58;= RGBTo16Bit&#40;r,g,b&#41;
                dstAddr &#58;= Ffb1.MemData;
                Inc&#40;dstAddr,x + y * FWidth * 2&#41;;
                PUint16&#40;dstAddr&#41;^ &#58;= c;
    It might not be inline assembler, but I hope this helps :-)
    cheers,
    Paul

  3. #63

    FPC4GP2X status?

    That's very helpful! I'm awed

    I should learn to trust my detective skills... Making inline asm was simplest with Delphi 7.2 / Free Pascal 2.3.1, the hard part was fiddling with the toolchain to make my own .bat for a minimum .gpe.

    All done now, minimum size with just the RTL is 28K. I'm looking at sdk2x now, hoping to use their code to make my .gpe with only my asm + minimum "padding".

    I know ARM from Archimedes, so the main goal is to absorb what happened since, including any MMU/multicore shananigans

    Still looking for the last version 6b of the framework in the Demo Dev thread http://www.gp32x.com/board/index.php...c=27433&st=105

    The links in the thread were dead, probably on the Wiki somewhere, will look.

    Thanks a lot for the lengthy reply, some juicy MMAP stuff. I did hw reg. access with mmap today and translated gp2x_joystick_read from rlyeh's minimal lib 0.B. Still not in asm tho, since I don't know the physical address or how to take over the machine temporarily in a friendly way.
    Henrik Erlandsson, programmer
    <br />bitBrain Studios, bitbrain.se
    <br />(Done 7 sites so far, but who's counting?)

  4. #64

    FPC4GP2X status?

    Hi Henrik,
    I'm glad my post helped you :-)

    BTW, I just edited my previous post as I just realized I hadn't included the libgp2x_asm.s file!! ops:

    It is now included in the post...

    And if you look at the very top of the libgp2x_asm.s file you may notice that it was written by Dzz from the gp32x.com posts you gave the link to

    cheers,
    Paul

  5. #65

    FPC4GP2X status?

    Legolas, any chance you can throw together some instructions on getting FPC and SDL running on DS or GBA. Or are there links out there already show this?

    I noticed that none of the examples in the zip file had a SDL example, hence the reason for this post.
    <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 =-

  6. #66

    FPC4GP2X status?

    [quote="paul_nicholls"]Hi Henrik,
    I'm glad my post helped you :-)

    BTW, I just edited my previous post as I just realized I hadn't included the libgp2x_asm.s file!! ops:

    It is now included in the post...

    And if you look at the very top of the libgp2x_asm.s file you may notice that it was written by Dzz from the gp32x.com posts you gave the ]

    Lovely! All this helps jump-start me.

    Haven't been doing much asm this evening, still search for the last version zip from that demo dev thread on gp32x forums... do you have it, since you have other sources by Dzz? (/me heads over to archive.org)
    Henrik Erlandsson, programmer
    <br />bitBrain Studios, bitbrain.se
    <br />(Done 7 sites so far, but who's counting?)

  7. #67

    FPC4GP2X status?

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

    Hi Dom,
    I have never done any programming for the DS or GBA, so I can't help you there, sorry

    I did see some posts about using SDL on the DS floating around on these forums, but I can't recall where without searching...

    EDIT: Perhaps this can help you http://www.pascalgamedevelopment.com...&highlight=sdl

    cheers,
    Paul.

  8. #68

    FPC4GP2X status?

    [quote="HenrikE"]
    Quote Originally Posted by paul_nicholls
    Hi Henrik,
    I'm glad my post helped you :-)

    BTW, I just edited my previous post as I just realized I hadn't included the libgp2x_asm.s file!! ops:

    It is now included in the post...

    And if you look at the very top of the libgp2x_asm.s file you may notice that it was written by Dzz from the gp32x.com posts you gave the ]

    Lovely! All this helps jump-start me.

    Haven't been doing much asm this evening, still search for the last version zip from that demo dev thread on gp32x forums... do you have it, since you have other sources by Dzz? (/me heads over to archive.org)
    Hi Henrik,
    I couldn't get hold of the latest version of Dzz's demo (version 6) either, even through http://www.archive.org

    I do have versions 2, 2a, 3, 4, 5 available though...I could email them to you?

    I just uploaded a zip file containing all the demo zip files that I had previously downloaded: http://fpc4gp2x.eonclash.com/downloa...emos_(2-5).zip

    cheers,
    Paul

  9. #69

    FPC4GP2X status?

    I have those, but thanks! It's elusive since gp2xgamer.com seems to have been replaced by the standard 'find what you want' portal package ops:
    Henrik Erlandsson, programmer
    <br />bitBrain Studios, bitbrain.se
    <br />(Done 7 sites so far, but who's counting?)

  10. #70

    FPC4GP2X status?

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

    Hi Dom,
    I have never done any programming for the DS or GBA, so I can't help you there, sorry

    I did see some posts about using SDL on the DS floating around on these forums, but I can't recall where without searching...

    EDIT: Perhaps this can help you http://www.pascalgamedevelopment.com...&highlight=sdl

    cheers,
    Paul.

    Oops the post was supposed to be directed at Legolas, but I'll check out that other thread, thanks.
    <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 =-

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