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 <_<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 ?
#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;
}
	63: error: invalid conversion from `short unsigned int*' to `
   long unsigned int'
	#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);
	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;
}
	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;
}
	/*
 * 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")
	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;
}
	  framebuffer1 = (u16*)  FRAMEBUFFER;                // 0x0C7B4000
  framebuffer2 = (u16*) (FRAMEBUFFER + (320*240*2)); // 0x0C7D9800      
  framebuffer3 = (u16*) malloc (320*240); 
  background   = (u16*) malloc (320*240);
	 framebuffer3 = (u16*) malloc (320*240*2);
	Yes, malloc only allocated bytes, shame on me, i add the *2 to both malloc´sbobintrees 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.
wonderfull work,bobintrees posted on Apr 5 2004 at 11:27 PM said:ok..the smc_fread thing was me..
sorry
Here is the c++ header file.
I also added ifndefs to the other header files to prevent errors if it gets included twice.
ftp://MrMirko:SDK@bobintrees.mine.nu
// 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();
}
  
}
	
	