GP32 Mr.mirkos Sdk Replacement


Spiv, your answers are great. thanks.
Do you improve your doublebuffer proc ;) ?

And about mmu. If bios based mmu page is only 4 Kb, that is mean if i have 16 kb continious region of memory , i must do bios mmu call 4 times for every 4kb page ?
 
MaXXik posted on Mar 15 2004 at 07:19 PM said:
And about mmu. If bios based mmu page is only 4 Kb, that is mean if i have 16 kb continious region of memory , i must do bios mmu call 4 times for every 4kb page ?
No.. the BIOS call takes in the memory start and stop addresses and changes all pages that are located inside the range. See my pages for examples <_<
 
Last edited by a moderator:
Hi, i rewrote the soundpart, so we can use large samples,
no limit in lenght, and we can use a ringbuffer, where
we need to copy the sound samples to the ring..

It is working good wit the example.sample demo
but gives strange output in the example.modplayer example.

so if someone wants to investigate... :)

Code:
#include "gp32.h"

#define _ring 8            // entrys in the ring
#define _cbuffer 1024*32   // memory for each ringbuffer

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

volatile static struct sound {
   volatile u16 *buffer;
   volatile u16 cbuffer[_cbuffer];
   volatile int  size;
   volatile int  copyflag;
} volatile sound[_ring]; // 0-15

volatile static u16 silence[4096];
volatile static u16 ringpos=0;
volatile static u16 playpos=0;

void DMA2_Done(void) __attribute__ ((interrupt ("IRQ")));
void DMA2_Done(void) {

        volatile u16 *play;
        volatile int size;

        play = sound[playpos].buffer;
        size = sound[playpos].size;
        if (size == NULL)  // Buffer not yet filled -> silence
             GpPcmPlay( silence,4096,0 );
        else {             // Playback
             GpPcmPlay( play,size,0 );
             sound[playpos].size=NULL;
             playpos++;if (playpos==_ring) playpos=0;
        }

        rSRCPND=BIT_DMA2;   //clear pending bit
        rINTPND=BIT_DMA2;
}

void gp_silence(void) {
   int i;
   for (i=0;i<_ring;i++) sound[i].size=NULL;
}

void gp_init_sound(int freq) {
   int i;
   rDMASKTRIG2=(1<<2)+(0<<1)+0;
   InitIIS (gp_GetBusClk(),freq);
   Init1330( fs256, iisbus,0);

   for (i=0;i<4096;i++)  silence[i]=0;
   for (i=0;i<_ring;i++)  sound[i].copyflag=NULL;
   gp_silence();

   ARMDisableInterrupt();
   rINTMSK|=(BIT_DMA2);
   swi_install_irq(0x13,(void*)&DMA2_Done);
   ARMEnableInterrupt();
   //gp_MMUChange(0x0c000000,0x0c7fffff, 0xFF2);

   GpPcmPlay(silence,4096,0); // Start fist playback, the second is irq driven.
}

void gp_playbuffer( u16 *add_buffer,int add_size,int add_copyflag) {

   int i;

   // waiting for free buffer
   while (1) {
     volatile int size;
     size = sound[ringpos].size;
     if (size == NULL ) break;
   }

   // malloc new mem
   if (add_copyflag==1) {
      volatile unsigned short *cbuffer = sound[ringpos].cbuffer;
      //memcpy(cbuffer,add_buffer,add_size);
      sound[ringpos].buffer = cbuffer;
      //for (i=0;i<add_size/2;i++) cbuffer[i]=add_buffer[i];
      //sound[ringpos].buffer = (char*) malloc(add_size);
      //gp_MMUChange(sound[ringpos].cbuffer,(sound[ringpos].cbuffer)+1024*32 , 0xFF2);
      gp_DMA3Memcopy(add_buffer, sound[ringpos].cbuffer,add_size/2);
      //memcpy (sound[ringpos].buffer,add_buffer,add_size);
   }
   else
   sound[ringpos].buffer  =add_buffer;

   sound[ringpos].copyflag=add_copyflag;
   sound[ringpos].size    =add_size;
   ringpos++;if (ringpos==_ring) ringpos=0;

}
 
I am trying to use this SDK with c++ but I am having problems with the FRAMEBUFFER.

Code:
63: error: invalid conversion from `short unsigned int*' to `
   long unsigned int'

It is having problems with the framebuffer pointer. It wants me to dereference framebuffer when I pass it to gp_SetView and gp_SetScreen, but if I do that I get garbled output on the screen.

However this all works in c.
Here is where I set up the framebuffer and use it with setView and SetScreen:

Code:
#define	FLIP_BUFFER	\
      gp_SetView(framebuffer[nflip++]);	\
      nflip &= 0x00;

int nflip = 1;
unsigned short *framebuffer[2];

framebuffer[0] = (unsigned short*) FRAMEBUFFER;
framebuffer[1] = (unsigned short*) (FRAMEBUFFER + (WIDTH*HEIGHT*2));

gp_SetScreen(framebuffer[1], 16);

Any help would be appriciated.
Thanks,
Bobintrees
 
Hi,

I've just completed the WMA player test program(ver 0.17).

WMA.FXE

It supports 48KBPS ~ 160KBPS.
192KBPS music makes small noise.

Copy WMAs into MP3 folder and enjoy music.

Next version will have below features.
- Higher bitrate support
- seek(fast forward / rewind)
- MP3 playback
- More friendly user interface

Special Thanks to Mr.Mirko & Mr.Spiv !! :D

========================================
I made slightly improved IIS/DMA handler.
I'll post the source code tomorrow.
It has very very simple ISR and only one ring buffer.
I'm using DMASTAT register to find the available space on the buffer.

Thanks,
- omega5 -
 
3 Days of coding work, and i really dont know what i have done :)

But i can tell you,

- The sound is working :)
The soundsystem can now handle a ringbuffer,
and playback of samples in unlimited lenght.
( okay there is only 8MB space in your gp :)

- The timer is working on real hardware now :)

And some other things, i cant remember any more...

Mirko

http://mirkoroller.de/gp32
 
ok, im trying to port sdl against this marvelous sdk...
iv got probelms with timer and threads...
here is for timers
Code:
void SDL_gp32_Timer(void)
{
	if (SDL_timer_running)
  SDL_ThreadedTimerCheck();
}

int SDL_SYS_TimerInit(void)
{
	/*if(GPOS_ERR_ALREADY_USED == GpTimerOptSet(GP32_TIMER_IDX,100,0,SDL_gp32_Timer))
  GpTimerKill(GP32_TIMER_IDX); // return -1;
	GpTimerSet(GP32_TIMER_IDX);*/
	ARMDisableInterrupt();
  	swi_install_irq(11,(void*)&SDL_gp32_Timer);
  	ARMEnableInterrupt();
	return(SDL_SetTimerThreaded(1));
}

void SDL_SYS_TimerQuit(void)
{
	//GpTimerKill(GP32_TIMER_IDX);
	rINTMSK&=0xFFFFF7FF;//clear the BIT_TIMER1
}

int SDL_SYS_StartTimer(void)
{
	//GpTimerResume(GP32_TIMER_IDX);
	rINTMSK|=(BIT_TIMER1);
	return 0;
}

void SDL_SYS_StopTimer(void)
{
	//GpTimerPause(GP32_TIMER_IDX);
	rINTMSK&=0xFFFFF7FF;//clear the BIT_TIMER1
	return;
}
as you can see its based on chui's port so i left his code in comments
but in his code there is an arg for GpTimerOptSet that set the sleep time of the timer
so my questions are..
1) is the above code correct/working?
2) how to set the sleep time?

thanx for help
 
well... it wasnt working because the TIMER wasnt inited... so i take a look at the s3c2400 ref doc and here is my code
can anyone check this code??? (mr.spive maybe)
Code:
int SDL_SYS_TimerInit(void)
{
	//for PCLK=66Mhz
	rTCFG0=4;//set 8bit prescalers to 4 for time0&1
	rTCFG1=51;// set 4bit dividers to 1/16 for timer0&1
	//resolution=+-1ms
	//enable auto-reload for TIMER0
	rTCON=8;
	//set rTCMPB0 and rTCNTB0
	rTCMPB0=0;
	rTCNTB0=100;//+-100ms
	//set the manual-update bit
	rTCON|=2;
	ARMDisableInterrupt();
	rINTMSK|=(BIT_TIMER0);//enable isr
  	swi_install_irq(10,(void*)&SDL_gp32_Timer);
  	ARMEnableInterrupt();
	return(SDL_SetTimerThreaded(1));
}

void SDL_SYS_TimerQuit(void)
{
	rINTMSK&=0xFFFFFBFF;//clear the BIT_TIMER0
}

int SDL_SYS_StartTimer(void)
{
	//set the startbit and clear manual-update
	rTCON=9;
	return 0;
}

void SDL_SYS_StopTimer(void)
{
	//clear the startbit for TIMER0
	rTCON=8;
	return;
}
thanx
 
Hi all,

I'm porting the OGG TREMO library to ADS compiler.
I could change the code and play the ogg music now.

But, the decoding speed is too slow. There are too many/much sound skipping.
So, I need to change the math routines to ASM code.

I have a GNU-ASM math inline functions.
I'm converting them to ADS inline assembler.
But, I found something strange.

Please see below code.

Code:
/*
 * This should be used as a memory barrier, forcing all cached values in
 * registers to wr writen back to memory.  Might or might not be beneficial
 * depending on the architecture and compiler.
 */
#define MB() asm volatile ("" : : : "memory")

It seems to be increasing the number of hit on cache.
But, I don't understand what it is exactly.
Please kindly let me know the equavalent for ADS.
How I can implement it on ADS?
ADS can place it automatically ?

Thanks,
- omega5 -
 
FA: Mirko

Code:
int GpRectFill16(GPDRAWTAG * gptag,GPDRAWSURFACE * ptgpds,int dx,int dy,int width,int height,int color)
{
	unsigned short *ptr;
	int x, y;
	
	for (x = 0; x < width; x++)
	{
  ptr = (unsigned short *)ptgpds->ptbuffer + ((dx + x) * ptgpds->buf_h) + (ptgpds->buf_h - 1 - dy);
  for (y = 0; y < height; y++)
  {
  	*ptr = color;
  	ptr--;
  }
	}
	
	return 1;
}

int GpBitBlt16(GPDRAWTAG * gptag,GPDRAWSURFACE * ptgpds,int dx,int dy,int width,int height,unsigned char * src, int sx,int sy,int imgw,int imgh)
{
	u16 *ptr1, *ptr2;
	int x, y;
	
	for (x = 0; x < width; x++)
	{
  ptr1 = (unsigned short *)ptgpds->ptbuffer + ((dx + x) * ptgpds->buf_h) + (ptgpds->buf_h - 1 - dy);
  ptr2 = (unsigned short *)src + ((sx + x) * imgh) + (imgh - 1 - sy);
  for (y = 0; y < height; y++)
  {
  	*ptr1 = *ptr2;
  	ptr1--;
  	ptr2--;
  }
	}
	
	return 1;
}

int GpTransBlt16(GPDRAWTAG * gptag,GPDRAWSURFACE * ptgpds,int dx,int dy,int width,int height,unsigned char *src,int sx,int sy,int imgw,int imgh,int color)
{
	u16 *ptr1, *ptr2;
	int x, y;
	
	for (x = 0; x < width; x++)
	{
  ptr1 = (unsigned short *)ptgpds->ptbuffer + ((dx + x) * ptgpds->buf_h) + (ptgpds->buf_h - 1 - dy);
  ptr2 = (unsigned short *)src + ((sx + x) * imgh) + (imgh - 1 - sy);
  for (y = 0; y < height; y++)
  {
  	if (*ptr2 != color)
    *ptr1 = *ptr2;
  	ptr1--;
  	ptr2--;
  }
	}
	
	return 1;
}
 
I'm having problems, possibly related to the ADS startup code, with global variables not being initialised in the SMC library.

The first call of sm_LPTInitDefaultValue() in smInit() finds (s_lBlock != NULL) and (s_pBlock != NULL) either or both being true, yet both should equal NULL if initialised properly as neither has been changed prior to the static variable declaration in the smf_lpt.c file.

So free() is being called on an undefined value and causing an alignment exception.

Is this a bad linker setting? Or something wrong with the startup code not initialising static vars properly?
 
Now I'm pretty sure a big part of the problem is the startup code for ADS.

From reading all the documentation I can find, it appears we are missing something important.

We don't have functions to copy nonroot (RO and RW) execution regions from load to execution addresses, so basically static data is not being initialised properly, which is bad. :)

Anyone here know how do do this? I'm still looking for the code. :/
 
thats because on gp32 exec regions is the same as load region
if you use the crtO.S i provide you with the templates, c lib is inited properly
i think exec and load regions differ only for bios
 
Hi, just a quick note,

i updated the SDK to Version 0.65 :)

Whats new:

- a new, easy to programm, select box
- new file io stuff from Michael Heinemann
- some minor change in the sound stuff
- and two new examples, to demonstarte this stuff :)

expect a working chatboard driver in the near future ...

Mirko
 
I noticed a small bug in the dam_tripplebuffer example:
Code:
  framebuffer1 = (u16*)  FRAMEBUFFER;                // 0x0C7B4000
  framebuffer2 = (u16*) (FRAMEBUFFER + (320*240*2)); // 0x0C7D9800      
  framebuffer3 = (u16*) malloc (320*240); 
  background   = (u16*) malloc (320*240);

framebuffer 3 should be changed to:
Code:
 framebuffer3 = (u16*) malloc (320*240*2);

The other way it would split the screen in half. It is only noticable if you draw on the right side.
background didn't seem to have a problem.

I also have a c++ header file to use with this SDK. Everything down to the sprite funcs have been tested.
The new smc_fread gives me a syntax error before '*' token when I added it, so it is commented out.
 
bobintrees posted on Apr 5 2004 at 08:01 PM said:
I noticed a small bug in the dam_tripplebuffer example:
Code:
  framebuffer1 = (u16*)  FRAMEBUFFER;                // 0x0C7B4000
  framebuffer2 = (u16*) (FRAMEBUFFER + (320*240*2)); // 0x0C7D9800      
  framebuffer3 = (u16*) malloc (320*240); 
  background   = (u16*) malloc (320*240);

framebuffer 3 should be changed to:
Code:
 framebuffer3 = (u16*) malloc (320*240*2);

The other way it would split the screen in half. It is only noticable if you draw on the right side.
background didn't seem to have a problem.

I also have a c++ header file to use with this SDK. Everything down to the sprite funcs have been tested.
The new smc_fread gives me a syntax error before '*' token when I added it, so it is commented out.
Yes, malloc only allocated bytes, shame on me, i add the *2 to both malloc´s

Please post the complete error message on the smc_fread ...
 
Last edited by a moderator:
Hi Mirko,

Today I just make a little test of your SDK,
lot of example in your sdk very good, but for me more complicate than gamepark SDK.

Code:
// Test code Mirko Roller SDK by JyCet

#include "gp32.h"

#include "bg.h"
#include "titre.h"

u16 *background;
int spritex=0;
long buffer[2];
int nflip;

void main() {

	int x;
	buffer[0] = (u16*)  FRAMEBUFFER;                // 0x0C7B4000
	buffer[1] = (u16*) (FRAMEBUFFER + (320*240*2)); // 0x0C7D9800

	gp_DMA0Memcopy(bg,buffer[0],320*240);
	gp_DMA1Memcopy(bg,buffer[1],320*240);
	nflip = 0;
	gp_SetScreen(buffer[nflip],16);
	gp_ButtonInit();
	gp_SetCpuSpeed(66);
  
 while (1)
{

	gp_DMA0Memcopy(bg,buffer[nflip],320*240);
	gp_DMA0Wait();
	//gp_SpritePut( (short*) odie,     0xFFFE,   1+spritex++, 1,buffer[nflip]);
	gp_SpritePut((short*) titre, 0xFFFE, 50, 50,buffer[nflip]); // nothing why ??

	gp_SetView(buffer[nflip++]);
	nflip&=0x01;

	for (x=0;x<900000;x++) x=x;

	if (spritex>160) spritex=0;
	if ( gp_ButtonResult()&BA) gp_Reset();
}
  
}

I change the double buffer switch to a gamepark style, I prefere it :).
But I've a pb to use the gp_SpritePut function. I've nothing on the screen and I dont undersabd why ?
The header titre.h is same type here:
const unsigned short titre[9416] = {
0x1, 0x3253...};
It's a 24Bits bmp convert by GP32converter

So and finaly, are you add some news GFX function ?

Thks
 
Back
Top