Beispiel #1
0
int initAudio()
{
	//----------------------------------------------------------------
	// initialize maxmod without any soundbank (unusual setup)
	//----------------------------------------------------------------
	
	sys.mod_count 			= 0;
	sys.samp_count			= 0;
	sys.mem_bank			= 0;
	sys.fifo_channel		= FIFO_MAXMOD;
	mmInit( &sys );
    
    // setup mixer stack
	for (int i=0; i<maxPoly; i++) {
		mixerStack[i].active = -1;
	}
	numPlaying = 0;
	
	stream.sampling_rate =  outputSampleRate;        // outputSampleRate
    stream.buffer_length = streamBufferLen;          // should be adequate
    stream.callback = fill_stream;       			// give fill routine
    stream.format = MM_STREAM_16BIT_MONO; 		// 16-bit mono
    stream.timer = MM_TIMER0;            		// use timer0
    stream.manual = 0;                   		// auto filling
    
    mmStreamOpen( &stream );
	
	return 0;
}
Beispiel #2
0
int sis_ioctl_agp_init( DRM_IOCTL_ARGS )
{
	DRM_DEVICE;
	drm_sis_private_t *dev_priv = dev->dev_private;
	drm_sis_agp_t agp;

	if (dev_priv == NULL) {
		dev->dev_private = DRM(calloc)(1, sizeof(drm_sis_private_t),
		    DRM_MEM_DRIVER);
		dev_priv = dev->dev_private;
		if (dev_priv == NULL)
			return ENOMEM;
	}

	if (dev_priv->AGPHeap != NULL)
		return DRM_ERR(EINVAL);

	DRM_COPY_FROM_USER_IOCTL(agp, (drm_sis_agp_t *)data, sizeof(agp));

	dev_priv->AGPHeap = mmInit(agp.offset, agp.size);

	DRM_DEBUG("offset = %u, size = %u", agp.offset, agp.size);
  
	return 0;
}
Beispiel #3
0
/* Called by the X Server to initialize the FB heap.  Allocations will fail
 * unless this is called.  Offset is the beginning of the heap from the
 * framebuffer offset (MaxXFBMem in XFree86).
 *
 * Memory layout according to Thomas Winischofer:
 * |------------------|DDDDDDDDDDDDDDDDDDDDDDDDDDDDD|HHHH|CCCCCCCCCCC|
 *
 *    X driver/sisfb                                  HW-   Command-
 *  framebuffer memory           DRI heap           Cursor   queue
 */
int sis_fb_init( DRM_IOCTL_ARGS )
{
	DRM_DEVICE;
	drm_sis_private_t *dev_priv = dev->dev_private;
	drm_sis_fb_t fb;

	DRM_COPY_FROM_USER_IOCTL(fb, (drm_sis_fb_t *)data, sizeof(fb));

	if (dev_priv == NULL) {
		dev->dev_private = DRM(calloc)(1, sizeof(drm_sis_private_t),
		    DRM_MEM_DRIVER);
		dev_priv = dev->dev_private;
		if (dev_priv == NULL)
			return ENOMEM;
	}

	if (dev_priv->FBHeap != NULL)
		return DRM_ERR(EINVAL);

	dev_priv->FBHeap = mmInit(fb.offset, fb.size);

	DRM_DEBUG("offset = %u, size = %u", fb.offset, fb.size);

	return 0;
}
void SoundSetup( BlackBox* sndeng, int srate, int bufsize ){
	GenSoundEngine = sndeng;
	mm_ds_system* sys = (mm_ds_system*)malloc( sizeof( mm_ds_system) );
	
	sys->mod_count 			= 0;
	sys->samp_count			= 0;
	sys->mem_bank			= 0;
	sys->fifo_channel		= FIFO_MAXMOD;
	
	mmInit( sys );
	
	//----------------------------------------------------------------
	// open stream
	//----------------------------------------------------------------
	
	mm_stream* mystream = (mm_stream*)malloc( sizeof( mm_stream ) );

	mystream->sampling_rate	= srate;					// sampling rate = 25khz
	mystream->buffer_length	= bufsize;					// buffer length = 1200 samples
	mystream->callback		= on_stream_request;		// set callback function
	mystream->format		= MM_STREAM_16BIT_STEREO;	// format = stereo 16-bit
	mystream->timer			= MM_TIMER0;				// use hardware timer 0
	mystream->manual		= false;					// use automatic filling
	mmStreamOpen( mystream );
}
int sisp_agp_init(struct inode *inode, struct file *filp, unsigned int cmd,
		  unsigned long arg)
{
  drm_sis_agp_t agp;
   
  if (copy_from_user(&agp, (drm_sis_agp_t *)arg, sizeof(agp)))
	  return -EFAULT;

  AgpHeap = mmInit(agp.offset, agp.size);

  DRM_DEBUG("offset = %u, size = %u", agp.offset, agp.size);
  
  return 0;
}
int main(int argc, char **argv){
	struct ModemInterface *mm = mmCreate("/dev/ttyACM0");
	if(!mmInit(mm)){
		printf("Unable to initialize modem.");
		return 0;
	}
	int messageids[256];
	int count = mmGetTextLists(mm, messageids, 256);
	char number[11];
	char message[180];
	printf("deleting %i messages..\n", count);
	for(int i = 0; i < count; i++){
		mmDeleteTextMessage(mm, messageids[i]);
		//printf("Message from %s:\n%s\n", number, message);
	}
	
}
Beispiel #7
0
static int
init_heap(void)
{
#ifdef MESA_SELINUX
    if (is_selinux_enabled()) {
        if (!security_get_boolean_active("allow_execmem") ||
                !security_get_boolean_pending("allow_execmem"))
            return 0;
    }
#endif

    if (!exec_heap)
        exec_heap = mmInit( 0, EXEC_HEAP_SIZE );

    if (!exec_mem)
        exec_mem = mmap(NULL, EXEC_HEAP_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE,
                        MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);

    return (exec_mem != MAP_FAILED);
}
Beispiel #8
0
static int sis_ioctl_agp_init(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
	drm_sis_private_t *dev_priv = dev->dev_private;
	drm_sis_agp_t *agp = data;

	if (dev_priv == NULL) {
		dev->dev_private = drm_calloc(1, sizeof(drm_sis_private_t),
					      DRM_MEM_DRIVER);
		dev_priv = dev->dev_private;
		if (dev_priv == NULL)
			return ENOMEM;
	}

	if (dev_priv->AGPHeap != NULL)
		return -EINVAL;

	dev_priv->AGPHeap = mmInit(agp->offset, agp->size);

	DRM_DEBUG("offset = %u, size = %u", agp->offset, agp->size);

	return 0;
}
Beispiel #9
0
//Main routine. Initialize stdout, the I/O, filesystem and the webserver and we're done.
void user_init(void) {
	mmInit(mmData);
	//Redirect stdout to websocket
	os_install_putc1((void *)stdoutPutcharWs);
	ioInit();
	captdnsInit();
	telnetInit(333);

	// 0x40200000 is the base address for spi flash memory mapping, ESPFS_POS is the position
	// where image is written in flash that is defined in Makefile.
#ifdef ESPFS_POS
	espFsInit((void*)(0x40200000 + ESPFS_POS));
#else
	espFsInit((void*)(webpages_espfs_start));
#endif
	httpdInit(builtInUrls, 80);
	os_timer_disarm(&websockTimer);
	os_timer_setfn(&websockTimer, websockTimerCb, NULL);
	os_timer_arm(&websockTimer, 1000, 1);
	os_printf("\nReady\n");
	wifi_set_sleep_type(LIGHT_SLEEP_T);
}
GLboolean gammaCreateContext( const __GLcontextModes *glVisual,
			     __DRIcontextPrivate *driContextPriv,
                     	     void *sharedContextPrivate)
{
   GLcontext *ctx, *shareCtx;
   __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
   gammaContextPtr gmesa;
   gammaScreenPtr gammascrn;
   GLINTSAREADRIPtr saPriv=(GLINTSAREADRIPtr)(((char*)sPriv->pSAREA)+
						 sizeof(drm_sarea_t));
   struct dd_function_table functions;

   gmesa = (gammaContextPtr) CALLOC( sizeof(*gmesa) );
   if (!gmesa)
      return GL_FALSE;

   /* Init default driver functions then plug in our gamma-specific functions
    * (the texture functions are especially important)
    */
   _mesa_init_driver_functions( &functions );
   gammaDDInitTextureFuncs( &functions );

   /* Allocate the Mesa context */
   if (sharedContextPrivate)
      shareCtx = ((gammaContextPtr) sharedContextPrivate)->glCtx;
   else
      shareCtx = NULL;

   gmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
                                       &functions, (void *) gmesa);
   if (!gmesa->glCtx) {
      FREE(gmesa);
      return GL_FALSE;
   }

   gmesa->driContext = driContextPriv;
   gmesa->driScreen = sPriv;
   gmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */

   gmesa->hHWContext = driContextPriv->hHWContext;
   gmesa->driHwLock = &sPriv->pSAREA->lock;
   gmesa->driFd = sPriv->fd;
   gmesa->sarea = saPriv;

   gammascrn = gmesa->gammaScreen = (gammaScreenPtr)(sPriv->private);

   ctx = gmesa->glCtx;

   ctx->Const.MaxTextureLevels = 13;  /* 4K by 4K?  Is that right? */
   ctx->Const.MaxTextureUnits = 1; /* Permedia 3 */
   ctx->Const.MaxTextureImageUnits = 1;
   ctx->Const.MaxTextureCoordUnits = 1;

   ctx->Const.MinLineWidth = 0.0;
   ctx->Const.MaxLineWidth = 255.0;

   ctx->Const.MinLineWidthAA = 0.0;
   ctx->Const.MaxLineWidthAA = 65536.0;

   ctx->Const.MinPointSize = 0.0;
   ctx->Const.MaxPointSize = 255.0;

   ctx->Const.MinPointSizeAA = 0.5; /* 4x4 quality mode */
   ctx->Const.MaxPointSizeAA = 16.0; 
   ctx->Const.PointSizeGranularity = 0.25;

   gmesa->texHeap = mmInit( 0, gmesa->gammaScreen->textureSize );

   make_empty_list(&gmesa->TexObjList);
   make_empty_list(&gmesa->SwappedOut);

   gmesa->CurrentTexObj[0] = 0;
   gmesa->CurrentTexObj[1] = 0; /* Permedia 3, second texture */

   gmesa->RenderIndex = ~0;


   /* Initialize the software rasterizer and helper modules.
    */
   _swrast_CreateContext( ctx );
   _ac_CreateContext( ctx );
   _tnl_CreateContext( ctx );
   _swsetup_CreateContext( ctx );

   /* Install the customized pipeline:
    */
   _tnl_destroy_pipeline( ctx );
   _tnl_install_pipeline( ctx, gamma_pipeline );

   /* Configure swrast & TNL to match hardware characteristics:
    */
   _swrast_allow_pixel_fog( ctx, GL_FALSE );
   _swrast_allow_vertex_fog( ctx, GL_TRUE );
   _tnl_allow_pixel_fog( ctx, GL_FALSE );
   _tnl_allow_vertex_fog( ctx, GL_TRUE );

   gammaInitVB( ctx );
   gammaDDInitExtensions( ctx );
   /* XXX these should really go right after _mesa_init_driver_functions() */
   gammaDDInitDriverFuncs( ctx );
   gammaDDInitStateFuncs( ctx );
   gammaDDInitSpanFuncs( ctx );
   gammaDDInitTriFuncs( ctx );
   gammaDDInitState( gmesa );

   gammaInitTextureObjects( ctx );

   driContextPriv->driverPrivate = (void *)gmesa;

   GET_FIRST_DMA(gmesa->driFd, gmesa->hHWContext,
		  1, &gmesa->bufIndex, &gmesa->bufSize,
		  &gmesa->buf, &gmesa->bufCount, gammascrn);

#ifdef DO_VALIDATE
    GET_FIRST_DMA(gmesa->driFd, gmesa->hHWContext,
		  1, &gmesa->WCbufIndex, &gmesa->WCbufSize,
		  &gmesa->WCbuf, &gmesa->WCbufCount, gammascrn);
#endif

    switch (glVisual->depthBits) {
    case 16:
	gmesa->DeltaMode = DM_Depth16;
	gmesa->depth_scale = 1.0f / 0xffff;
	break;
    case 24:
	gmesa->DeltaMode = DM_Depth24;
	gmesa->depth_scale = 1.0f / 0xffffff;
	break;
    case 32:
	gmesa->DeltaMode = DM_Depth32;
	gmesa->depth_scale = 1.0f / 0xffffffff;
	break;
    default:
	break;
    }

    gmesa->DepthSize = glVisual->depthBits;
    gmesa->Flags  = GAMMA_FRONT_BUFFER;
    gmesa->Flags |= (glVisual->doubleBufferMode ? GAMMA_BACK_BUFFER : 0);
    gmesa->Flags |= (gmesa->DepthSize > 0 ? GAMMA_DEPTH_BUFFER : 0);

    gmesa->EnabledFlags = GAMMA_FRONT_BUFFER;
    gmesa->EnabledFlags |= (glVisual->doubleBufferMode ? GAMMA_BACK_BUFFER : 0);


    if (gmesa->Flags & GAMMA_BACK_BUFFER) {
        gmesa->readOffset = gmesa->drawOffset = gmesa->driScreen->fbHeight * gmesa->driScreen->fbWidth * gmesa->gammaScreen->cpp;
    } else {
    	gmesa->readOffset = gmesa->drawOffset = 0;
    }

    gammaInitHW( gmesa );

    driContextPriv->driverPrivate = (void *)gmesa;

    return GL_TRUE;
}
Beispiel #11
0
Datei: prng.c Projekt: 0xffea/xnu
/* Set up the PRNG */
prng_error_status
prngInitialize(PrngRef *prng) 
{
	UINT i;
	comp_error_status resp;
	prng_error_status retval = PRNG_ERR_LOW_MEMORY;
	MMPTR	mmp;
	PRNG	*p;
	
	mmInit();
	
	#if	MUTEX_ENABLE
	/* Create the mutex */
	/* NOTE: on return the mutex should bve held, since our caller (prngInitialize)
	 * will release it. 
	 */
	if(mutexCreatorId!=0) {return PRNG_ERR_REINIT;}
	Statmutex = CreateMutex(NULL,TRUE,NULL);
	if(Statmutex == NULL) {mutexCreatorId = 0; return PRNG_ERR_MUTEX;}
	DuplicateHandle(GetCurrentProcess(),Statmutex,GetCurrentProcess(),&mutex,SYNCHRONIZE,FALSE,0);
	mutexCreatorId = GetCurrentProcessId();
	#endif	/* MUTEX_ENABLE */
	
	/* Assign memory */
	mmp = mmMalloc(sizeof(PRNG));
	if(mmp==MM_NULL)
	{
		goto cleanup_init;
	}
	else
	{
		p = (PRNG*)mmGetPtr(mmp);
		memset(p, 0, sizeof(PRNG));
	}

	/* Initialize Variables */
	for(i=0;i<TOTAL_SOURCES;i++) 
	{
		p->poolSize[i] = 0;
		p->poolEstBits[i] = 0;
	}

#ifdef WIN_NT
	/* Setup security on the registry so that remote users cannot predict the slow pool */
	prng_set_NT_security();
#endif

	/* Initialize the secret state. */
	/* FIXME - might want to make this an option here and have the caller
	 * do it after we return....? */
	YSHA1Init(&p->pool);
#if		SLOW_POLL_ENABLE
	prng_slow_init(p);	/* Does a slow poll and then calls prng_make_state(...) */
#else	
	/* NULL init */
	prng_do_SHA1(&p->outstate);
	prng_make_new_state(&p->outstate, p->outstate.out);
#endif	/* SLOW_POLL_ENABLE */

	/* Initialize compression routines */
	for(i=0;i<COMP_SOURCES;i++) 
	{
		resp = comp_init((p->comp_state)+i);
		if(resp!=COMP_SUCCESS) {retval = PRNG_ERR_COMPRESSION; goto cleanup_init;}
	}
	
	p->ready = PRNG_READY;
	*prng = (PrngRef)p;
	
	return PRNG_SUCCESS;

cleanup_init:
	/* Program failed on one of the mmmallocs */
	mmFree(mmp);
	mmp = MM_NULL;
	
	#if		MUTEX_ENABLE
	CloseHandle(Statmutex);
	Statmutex = NULL;
	mutexCreatorId = 0;
	#endif
	
	return retval; /* default PRNG_ERR_LOW_MEMORY */
}
Beispiel #12
0
GLboolean s3vCreateContext(const __GLcontextModes *glVisual,
			   __DRIcontextPrivate *driContextPriv,
                     	   void *sharedContextPrivate)
{
	GLcontext *ctx, *shareCtx;
	__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
	s3vContextPtr vmesa;
	s3vScreenPtr s3vScrn;
	S3VSAREAPtr saPriv=(S3VSAREAPtr)(((char*)sPriv->pSAREA) + 
                            sizeof(drm_sarea_t));
        struct dd_function_table functions;

	DEBUG_WHERE(("*** s3vCreateContext ***\n"));

	vmesa = (s3vContextPtr) CALLOC( sizeof(*vmesa) );
	if ( !vmesa ) return GL_FALSE;

	/* Allocate the Mesa context */
	if (sharedContextPrivate)
		shareCtx = ((s3vContextPtr) sharedContextPrivate)->glCtx;
	else
		shareCtx = NULL;

        _mesa_init_driver_functions(&functions);

	vmesa->glCtx = _mesa_create_context(glVisual, shareCtx, &functions,
                                            (void *)vmesa);
	if (!vmesa->glCtx) {
		FREE(vmesa);
		return GL_FALSE;
	}

	vmesa->driContext = driContextPriv;
	vmesa->driScreen = sPriv;
	vmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */

	vmesa->hHWContext = driContextPriv->hHWContext;
	vmesa->driHwLock = (drmLock *)&sPriv->pSAREA->lock;
	vmesa->driFd = sPriv->fd;
	vmesa->sarea = saPriv;

	s3vScrn = vmesa->s3vScreen = (s3vScreenPtr)(sPriv->private);

	ctx = vmesa->glCtx;

	ctx->Const.MaxTextureLevels = 11;  /* it is (11-1) -> 1024 * 1024 FIXME */

	ctx->Const.MaxTextureUnits = 1; /* FIXME: or 2 ? */

	/* No wide points.
	 */
	ctx->Const.MinPointSize = 1.0;
	ctx->Const.MinPointSizeAA = 1.0;
	ctx->Const.MaxPointSize = 1.0;
	ctx->Const.MaxPointSizeAA = 1.0;

	/* No wide lines.
	 */
	ctx->Const.MinLineWidth = 1.0;
	ctx->Const.MinLineWidthAA = 1.0;
	ctx->Const.MaxLineWidth = 1.0;
	ctx->Const.MaxLineWidthAA = 1.0;
	ctx->Const.LineWidthGranularity = 1.0;

	ctx->Const.MaxDrawBuffers = 1;

	vmesa->texHeap = mmInit( 0, vmesa->s3vScreen->textureSize );
	DEBUG(("vmesa->s3vScreen->textureSize = 0x%x\n",
		vmesa->s3vScreen->textureSize));
	
	/* NOTE */
	/* mmInit(offset, size); */

	/* allocates a structure like this:

	struct mem_block_t {
		struct mem_block_t *next;
		struct mem_block_t *heap;
		int ofs,size;
		int align;
		int free:1;
		int reserved:1;
	};

	*/

	make_empty_list(&vmesa->TexObjList);
	make_empty_list(&vmesa->SwappedOut);

	vmesa->CurrentTexObj[0] = 0;
	vmesa->CurrentTexObj[1] = 0; /* FIXME */

	vmesa->RenderIndex = ~0;

	/* Initialize the software rasterizer and helper modules.
	 */
	_swrast_CreateContext( ctx );
	_vbo_CreateContext( ctx );
	_tnl_CreateContext( ctx );
	_swsetup_CreateContext( ctx );

	/* Install the customized pipeline:
	 */
#if 0
	_tnl_destroy_pipeline( ctx );
	_tnl_install_pipeline( ctx, s3v_pipeline );
#endif
	/* Configure swrast to match hardware characteristics:
	 */
#if 0
	_swrast_allow_pixel_fog( ctx, GL_FALSE );
	_swrast_allow_vertex_fog( ctx, GL_TRUE );
#endif
	vmesa->_3d_mode = 0;

	/* 3D lines / gouraud tris */
	vmesa->CMD = ( AUTO_EXEC_ON | HW_CLIP_ON | DEST_COL_1555
			| FOG_OFF | ALPHA_OFF | Z_OFF | Z_UPDATE_OFF
			| Z_LESS | TEX_WRAP_ON | TEX_MODULATE | LINEAR
			| TEX_COL_ARGB1555 | CMD_3D );

	vmesa->_alpha[0] = vmesa->_alpha[1] = ALPHA_OFF;
	vmesa->alpha_cmd = vmesa->_alpha[0];
	vmesa->_tri[0] = DO_GOURAUD_TRI;
	vmesa->_tri[1] = DO_TEX_LIT_TRI;
	vmesa->prim_cmd = vmesa->_tri[0];

	/* printf("first vmesa->CMD = 0x%x\n", vmesa->CMD); */

	vmesa->TexOffset = vmesa->s3vScreen->texOffset;

	s3vInitVB( ctx );
	s3vInitExtensions( ctx );
	s3vInitDriverFuncs( ctx );
	s3vInitStateFuncs( ctx );
	s3vInitSpanFuncs( ctx );
	s3vInitTextureFuncs( ctx );
	s3vInitTriFuncs( ctx );
	s3vInitState( vmesa );

	driContextPriv->driverPrivate = (void *)vmesa;

	/* HACK */
	vmesa->bufSize = S3V_DMA_BUF_SZ;

	DEBUG(("vmesa->bufSize = %i\n", vmesa->bufSize));
	DEBUG(("vmesa->bufCount = %i\n", vmesa->bufCount));


	/* dma init */
	DEBUG_BUFS(("GET_FIRST_DMA\n"));
	
	vmesa->_bufNum = 0;

	GET_FIRST_DMA(vmesa->driFd, vmesa->hHWContext,
	1, &(vmesa->bufIndex[0]), &(vmesa->bufSize),
	&vmesa->_buf[0], &vmesa->bufCount, s3vScrn);

	GET_FIRST_DMA(vmesa->driFd, vmesa->hHWContext,
    1, &(vmesa->bufIndex[1]), &(vmesa->bufSize),
    &vmesa->_buf[1], &vmesa->bufCount, s3vScrn);

	vmesa->buf = vmesa->_buf[vmesa->_bufNum];
	
/*
	vmesa->CMD = (AUTO_EXEC_ON | HW_CLIP_ON | DEST_COL_1555
	| FOG_OFF | ALPHA_OFF | Z_OFF | Z_UPDATE_OFF
	| DO_GOURAUD_TRI | CMD_3D);

	vmesa->TexOffset = vmesa->s3vScreen->texOffset;
*/

/* ... but we should support only 15 bit in virge (out of 8/15/24)... */

	DEBUG(("glVisual->depthBits = %i\n", glVisual->depthBits));

	switch (glVisual->depthBits) {
	case 8:
		break;
	
	case 15:
	case 16:
		vmesa->depth_scale = 1.0f / 0xffff; 
		break;
	case 24:
		vmesa->depth_scale = 1.0f / 0xffffff;
		break;
	default:
		break;
	}

	vmesa->cull_zero = 0.0f;

	vmesa->DepthSize = glVisual->depthBits;
	vmesa->Flags  = S3V_FRONT_BUFFER;
	vmesa->Flags |= (glVisual->doubleBufferMode ? S3V_BACK_BUFFER : 0);
	vmesa->Flags |= (vmesa->DepthSize > 0 ? S3V_DEPTH_BUFFER : 0);

	vmesa->EnabledFlags = S3V_FRONT_BUFFER;
	vmesa->EnabledFlags |= (glVisual->doubleBufferMode ? S3V_BACK_BUFFER : 0);


	if (vmesa->Flags & S3V_BACK_BUFFER) {
       	vmesa->readOffset = vmesa->drawOffset = vmesa->s3vScreen->backOffset;
	} else {
	   	vmesa->readOffset = vmesa->drawOffset = 0;
	}

	s3vInitHW( vmesa );

	driContextPriv->driverPrivate = (void *)vmesa;

	return GL_TRUE;
}
Beispiel #13
0
/**********************************************************************************
 * main
 *
 * Program Entry Point
 **********************************************************************************/
int main( void ) {
//---------------------------------------------------------------------------------

    //----------------------------------------------------------------
    // print out some stuff
    //----------------------------------------------------------------
    consoleDemoInit();
    iprintf( "\n    Maxmod Streaming Example   \n");

    //----------------------------------------------------------------
    // initialize maxmod without any soundbank (unusual setup)
    //----------------------------------------------------------------
    mm_ds_system sys;
    sys.mod_count 			= 0;
    sys.samp_count			= 0;
    sys.mem_bank			= 0;
    sys.fifo_channel		= FIFO_MAXMOD;
    mmInit( &sys );

    //----------------------------------------------------------------
    // open stream
    //----------------------------------------------------------------
    mm_stream mystream;
    mystream.sampling_rate	= 25000;					// sampling rate = 25khz
    mystream.buffer_length	= 1200;						// buffer length = 1200 samples
    mystream.callback		= on_stream_request;		// set callback function
    mystream.format			= MM_STREAM_16BIT_STEREO;	// format = stereo 16-bit
    mystream.timer			= MM_TIMER0;				// use hardware timer 0
    mystream.manual			= true;						// use manual filling
    mmStreamOpen( &mystream );

    //----------------------------------------------------------------
    // when using 'automatic' filling, your callback will be triggered
    // every time half of the wave buffer is processed.
    //
    // so:
    // 25000 (rate)
    // ----- = ~21 Hz for a full pass, and ~42hz for half pass
    // 1200  (length)
    //----------------------------------------------------------------
    // with 'manual' filling, you must call mmStreamUpdate
    // periodically (and often enough to avoid buffer underruns)
    //----------------------------------------------------------------

    SetYtrigger( 0 );
    irqEnable( IRQ_VCOUNT );

    while( 1 )
    {
        // wait until line 0
        swiIntrWait( 0, IRQ_VCOUNT);

        // update stream
        mmStreamUpdate();

        // restore backdrop (some lines were drawn with another colour to show cpu usage)
        BG_PALETTE_SUB[0] = bg_colour;

        // wait until next frame
        swiWaitForVBlank();

        // set backdrop to show cpu usage
        BG_PALETTE_SUB[0] = cpu_colour;
    }

    return 0;
}