GP32 Mr.mirkos Sdk Replacement


May be i am wrong , but...

// Pixels physical range are: for x - 0...239 !!! and for y - 0...319
void gp_SetPixel16 ( int x, int y, u16 c, u16 *framebuffer )
{
// unsigned short *addr;
//addr = framebuffer;
// do not check coordinates check !
// y%240 and x%320 - this is very bad code . Avoid divisions as much as possible !
// You must sub from 240 one to have correct physical x coordinate range
*(framebuffer + (240 - 1- y) + (240 * x) = c;
}


void gp_SetScreen(u32 addr,u16 bitmode) {

{
u16 BPPMODE = 12; // default 16 Bit
u16 CLKVAL = 3;
u16 ENVID = 1;
u16 MMODE = 0;
u16 PNRMODE = 3;
u16 LINECNT = 0;

switch (bitmode) {
//case 16 : BPPMODE=12; break; // do not need this one, you already set it !
case 8 : BPPMODE=11; break;
case 4 : BPPMODE=10; break;
case 2 : BPPMODE= 9; break;
case 1 : BPPMODE= 8; break;
}
 
MaXXik posted on Mar 9 2004 at 04:51 PM said:
May be i am wrong , but...

// Pixels physical range are: for x - 0...239 !!! and for y - 0...319
void gp_SetPixel16 ( int x, int y, u16 c, u16 *framebuffer )
{
// unsigned short *addr;
//addr = framebuffer;
// do not check coordinates check !
// y%240 and x%320 - this is very bad code . Avoid divisions as much as possible !
// You must sub from 240 one to have correct physical x coordinate range
*(framebuffer + (240 - 1- y) + (240 * x) = c;
}


void gp_SetScreen(u32 addr,u16 bitmode) {

{
u16 BPPMODE = 12; // default 16 Bit
u16 CLKVAL = 3;
u16 ENVID = 1;
u16 MMODE = 0;
u16 PNRMODE = 3;
u16 LINECNT = 0;

switch (bitmode) {
//case 16 : BPPMODE=12; break; // do not need this one, you already set it !
case 8 : BPPMODE=11; break;
case 4 : BPPMODE=10; break;
case 2 : BPPMODE= 9; break;
case 1 : BPPMODE= 8; break;
}
*(addr + (240- (y%240) ) + (240* (x%320) )) = c;
Was wrong...
*( framebuffer+(239-y) + (240*x) ) = c;
looks mutch better...

I removed the check range, i think speed is better then
checking for nerds input.
 
Last edited by a moderator:
SDK 0.6.3

Not that big update, but

- gp_SetFont8 you can now use the font in 8 and 16Bit mode
- added gp_SetPixel8
- removed a bug in gp_SetPixel16 thx MaXXik
- added a new 256 color example, with looping palette effect
- added support for ads compiler ( look to gp_timer.c )
ads users: feel free to add more macros...
- added SDK tutorial by syncro

http://mirkoroller.de/gp32

good night ...


get it here until my ISP updates my HP.
http://www.project-io.org/project-io.beta/...ontent/GP32/SDK
 
just a thought, since the gp_SetPixel16 function now only has 1 line in it, wouldn't it be faster to make it a #define instead?
 
Charge posted on Mar 10 2004 at 09:39 AM said:
just a thought, since the gp_SetPixel16 function now only has 1 line in it, wouldn't it be faster to make it a #define instead?
void gp_SetPixel16 ( int x, int y, u16 c, u16 *framebuffer ) {
*(framebuffer +(239-y)+(240*x) ) = c;
}
Wird compiliert zu

gp_SetPixel16:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
rsb r0, r0, r0, asl #4
rsb r1, r1, r0, asl #4
add r3, r3, r1, asl #1
ldr r1, .L3
@ lr needed for prologue
strh r2, [r3, r1] @ movhi
mov pc, lr
.L4:
.align 2
.L3:
.word 478
.size gp_SetPixel16, .-gp_SetPixel16
.align 2
.global test
.type test, %function



#define gp_SetPixel16_define(x,y,c,framebuffer) *((framebuffer) +(239-(y))+(240*(x)) ) = c
wird compiliert zu:

@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
ldr r3, .L6
mov r2, #10 @ movhi
@ lr needed for prologue
strh r2, [r3, #0] @ movhi
mov pc, lr
.L7:
.align 2
.L6:
.word 209452182
.size test, .-test
.align 2
.global gp_SetScreen
.type gp_SetScreen, %function


looks a little shorter :) But it is not working, couse i can not define
x,y,c (as integer) in a define...
 
Last edited by a moderator:
Code:
// Soundplaying for gp32
// coded 2004 Mr.Mirko   mirko@mirkoroller.de
// withe the amazing help of spivvy on efnet

// Modified by omega5 to improve the efficiency


#include "gp32.h"

enum _busmode { iisbus=0, msbbus=0x4 };
enum _fsmode  { fs512=0,  fs384, fs256 };

#define nISR_DMA2       0x13

#define playbuffer_size 4096*4*2  // Twice of Mirko's buffer
static unsigned char playbuffer1[playbuffer_size];
static unsigned char playbuffer2[playbuffer_size];
static unsigned char playbuffer3[playbuffer_size]; // Silence

static unsigned char *playbuffer_zeiger;
static int volatile playbuffer=2;
static int volatile playbuffer1_ready_to_write=1; // PlayerBuffer1 status
static int volatile playbuffer2_ready_to_write=1; // PlayerBuffer2 status

void __irq DMA2_Done(void);
void __irq DMA2_Done(void) {
//        asm volatile ("STMDB    r13!,{r0-r12,lr}\n");

       // We have no data to play back. So, make it silence.
       if((playbuffer1_ready_to_write==1) && (playbuffer2_ready_to_write==1))
       {
            GpPcmPlay((short unsigned int*) &playbuffer3,playbuffer_size,0);
            rSRCPND=BIT_DMA2;   //clear pending bit
            rINTPND=BIT_DMA2;
            return;
       }

        // play one by one in rotation.
        if (playbuffer==1) {
            playbuffer1_ready_to_write=1;
            playbuffer=2;
            playbuffer_zeiger = playbuffer1;
            GpPcmPlay((short unsigned int*) &playbuffer2,playbuffer_size,0);
        }
        else {
            playbuffer2_ready_to_write=1;
            playbuffer=1;
            playbuffer_zeiger = playbuffer2;
            GpPcmPlay((short unsigned int*) &playbuffer1,playbuffer_size,0);
        }

        rSRCPND=BIT_DMA2;   //clear pending bit
        rINTPND=BIT_DMA2;
//        asm volatile ("LDMIA    r13!,{r0-r12,lr}\n"
//                            "SUBS PC,lr,#4\n");
}

void gp_silence(void);
void gp_init_sound(int bus, int freq) {

   rDMASKTRIG2=(1<<2)+(0<<1)+0;
   
   InitIIS (bus,freq);
   Init1330( fs256, iisbus,0);
   
   gp_silence(); // init playbuffer
     
   ARMDisableInterrupt();
   rINTMSK    |=(BIT_DMA2);
   swi_install_irq(nISR_DMA2,(void*)&DMA2_Done);
   ARMEnableInterrupt();

   playbuffer_zeiger=playbuffer2;
   GpPcmPlay(playbuffer_zeiger,4,0); // Kick off the automatic buffer operation
   playbuffer2_ready_to_write=0;   // buffer2 is busy !!
}

void gp_playbuffer( unsigned char *samples,int size) {

   int i;
   unsigned char *buffer; 
   
   if (size > playbuffer_size ) size = playbuffer_size;

//   while((rDSTAT2)!=0){ };  // wait for dma end...

   // if both two buffers are busy, we must wait for ...
   while(playbuffer1_ready_to_write==0 && playbuffer2_ready_to_write==0);

   buffer=playbuffer_zeiger;

   // Update buffer-usage status
   if(playbuffer_zeiger == playbuffer2)
        playbuffer2_ready_to_write=0; 
   else
        playbuffer1_ready_to_write=0;

   memcpy(buffer,samples,size); // this mem-copy is faster about 3~4 times of for-loop.
//   for (i=0;i<size;i++)  buffer[i] = samples[i];
}

void gp_silence(void) {
   int i;
   for (i=0;i<playbuffer_size;i++) { playbuffer1[i]=0; playbuffer2[i]=0; playbuffer3[i]=0; }
}


I've improved the gp_sound.c

The sound lib is NOT polling DMA status.
"gp_playbuffer()" is not a neck point of streaming audio anymore.

I can post the WMA player by end of this week.

Enjoy GP,
- omega5 -
 
omega5 you are my hero...

good work...

:D

And its now working in lower cpu freq, couse we are no longer polling for dma end...

I compiled the example.sample and the sound is shoppy... :blink:
Have you tryed this example ?

( back in 10hours, good night )
 
mr.mirko posted on Mar 12 2004 at 12:30 AM said:
omega5 you are my hero...

good work...

:D

And its now working in lower cpu freq, couse we are no longer polling for dma end...

I compiled the example.sample and the sound is shoppy... :blink:
Have you tryed this example ?

( back in 10hours, good night )

Mirko you are also my hero... :lol:

Due to enlarged size of output buffer, we need to change the example as below.

Code:
    gp_playbuffer((unsigned char*)sample16s+pos,4*4096*2);
    pos+=4*4096*2;
    if ( pos>769848 ) pos=0;

I can hear your test music. I like it :D

Thanks,
- omega5 -
 
Last edited by a moderator:
Good morning :)

Uhh yes, now it works, iwas too tiered yesterday to see
that litte buffer increase :)

yes, now it works 100% :)

Monday i finish the mixer, and you brought me too a very good idear..

cu...
 
Looks like yhat ADS startups are not 100% correct.
_HEAPSTART
DCD |Image$$ZI$$Limit| ; start of Heap area
_HEAPEND
DCD 0x0C700000 ; end of Heap area
_STACKSTART
DCD 0x0C77FF00 ; same as geepee32(emulator)

_START
; Set up stdlib.
LDR r1, _HEAPEND
LDR r0, _HEAPSTART
BL __rt_lib_init

LDR r13, _STACKSTART; sp setup

ldr r3, =gpmain; C/C++ main Entry Function(do not rename to main)
bx r3

END

Stack is only defined for USER Model, but it also must be define for SuperVisor model .
Am I right ? :huh:
 
loki666 posted on Mar 12 2004 at 11:49 PM said:
smil
could this be used for a new smlib?
It is the same Toshiba engine we are currently using,
we need a new start up lib, with smc and fat support.
 
Last edited by a moderator:
loki666 posted on Mar 13 2004 at 12:12 PM said:
i've saw some smc code in gp32 linux project... maybe we could ask them
this would bee a great add, you dont need to ask someone, if it is in the linux kernel, it is free.

Here is a linux project for a hp1900 handheld, using the same arm9 core as gp32.
http://www.handhelds.org/projects/h1900.html

Dont know if its usefull, cant find a source dl of the kernel.
 
Last edited by a moderator:
MaXXik posted on Mar 13 2004 at 06:19 PM said:
Is the mmu page have maximum size of 4 kb ?
With BIOS based routines yes.
 
Last edited by a moderator:
MaXXik posted on Mar 13 2004 at 12:32 AM said:
Stack is only defined for USER Model, but it also must be define for SuperVisor model .
Am I right ? :huh:
GP32 runs by default in supervisor mode.. so the startup code is ok.
 
Last edited by a moderator:
loki666 posted on Mar 14 2004 at 05:12 PM said:
P32 runs by default in supervisor mode.. so the startup code is ok

you mean the bios initialize the SVC stack?
GP32 BIOS initializes all stacks except the user mode stack..
 
Last edited by a moderator:
Back
Top