本文整理汇总了C++中MLOADER::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ MLOADER::Init方法的具体用法?C++ MLOADER::Init怎么用?C++ MLOADER::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MLOADER
的用法示例。
在下文中一共展示了MLOADER::Init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Player_LoadGeneric_internal
/* Loads a module given an reader */
MODULE* Player_LoadGeneric_internal(MREADER *reader,int maxchan,BOOL curious)
{
int t;
MLOADER *l;
BOOL ok;
MODULE *mf;
modreader = reader;
_mm_errno = 0;
_mm_critical = 0;
_mm_iobase_setcur(modreader);
/* Try to find a loader that recognizes the module */
for(l=firstloader;l;l=l->next) {
_mm_rewind(modreader);
if(l->Test()) break;
}
if(!l) {
_mm_errno = MMERR_NOT_A_MODULE;
if(_mm_errorhandler) _mm_errorhandler();
_mm_rewind(modreader);_mm_iobase_revert();
return NULL;
}
/* init unitrk routines */
if(!UniInit()) {
if(_mm_errorhandler) _mm_errorhandler();
_mm_rewind(modreader);_mm_iobase_revert();
return NULL;
}
/* init the module structure with vanilla settings */
memset(&of,0,sizeof(MODULE));
of.bpmlimit = 33;
of.initvolume = 128;
for (t = 0; t < UF_MAXCHAN; t++) of.chanvol[t] = 64;
for (t = 0; t < UF_MAXCHAN; t++)
of.panning[t] = ((t + 1) & 2) ? PAN_RIGHT : PAN_LEFT;
/* init module loader and load the header / patterns */
if (!l->Init || l->Init()) {
_mm_rewind(modreader);
ok = l->Load(curious);
/* propagate inflags=flags for in-module samples */
for (t = 0; t < of.numsmp; t++)
if (of.samples[t].inflags == 0)
of.samples[t].inflags = of.samples[t].flags;
} else
ok = 0;
/* free loader and unitrk allocations */
if (l->Cleanup) l->Cleanup();
UniCleanup();
if(!ok) {
ML_FreeEx(&of);
if(_mm_errorhandler) _mm_errorhandler();
_mm_rewind(modreader);_mm_iobase_revert();
return NULL;
}
if(!ML_LoadSamples()) {
ML_FreeEx(&of);
if(_mm_errorhandler) _mm_errorhandler();
_mm_rewind(modreader);_mm_iobase_revert();
return NULL;
}
if(!(mf=ML_AllocUniMod())) {
ML_FreeEx(&of);
_mm_rewind(modreader);_mm_iobase_revert();
if(_mm_errorhandler) _mm_errorhandler();
return NULL;
}
/* If the module doesn't have any specific panning, create a
MOD-like panning, with the channels half-separated. */
if (!(of.flags & UF_PANNING))
for (t = 0; t < of.numchn; t++)
of.panning[t] = ((t + 1) & 2) ? PAN_HALFRIGHT : PAN_HALFLEFT;
/* Copy the static MODULE contents into the dynamic MODULE struct. */
memcpy(mf,&of,sizeof(MODULE));
if(maxchan>0) {
if(!(mf->flags&UF_NNA)&&(mf->numchn<maxchan))
maxchan = mf->numchn;
else
if((mf->numvoices)&&(mf->numvoices<maxchan))
maxchan = mf->numvoices;
if(maxchan<mf->numchn) mf->flags |= UF_NNA;
if(MikMod_SetNumVoices_internal(maxchan,-1)) {
_mm_iobase_revert();
Player_Free(mf);
return NULL;
}
//.........这里部分代码省略.........
示例2: Player_LoadGeneric_internal
/* Loads a module given an reader */
MODULE* Player_LoadGeneric_internal(MREADER *reader,int maxchan,BOOL curious)
{
int t;
MLOADER *l;
BOOL ok;
MODULE *mf;
modreader = reader;
_mm_errno = 0;
_mm_critical = 0;
_mm_iobase_setcur(modreader);
/* Try to find a loader that recognizes the module */
for(l=firstloader;l;l=l->next) {
_mm_rewind(modreader);
if(l->Test()) break;
}
if(!l) {
_mm_errno = MMERR_NOT_A_MODULE;
if(_mm_errorhandler) _mm_errorhandler();
_mm_rewind(modreader);_mm_iobase_revert();
return NULL;
}
/* init unitrk routines */
if(!UniInit()) {
if(_mm_errorhandler) _mm_errorhandler();
_mm_rewind(modreader);_mm_iobase_revert();
return NULL;
}
/* load the song using the song's loader variable */
memset(&of,0,sizeof(MODULE));
of.initvolume = 128;
/* init panning array */
for(t=0; t<64; t++) of.panning[t] = ((t+1)&2) ? 255 : 0;
for(t=0; t<64; t++) of.chanvol[t] = 64;
/* init module loader and load the header / patterns */
if(l->Init()) {
_mm_rewind(modreader);
ok = l->Load(curious);
} else
ok = 0;
/* free loader and unitrk allocations */
l->Cleanup();
UniCleanup();
if(!ok) {
ML_FreeEx(&of);
if(_mm_errorhandler) _mm_errorhandler();
_mm_rewind(modreader);_mm_iobase_revert();
return NULL;
}
if(!ML_LoadSamples()) {
ML_FreeEx(&of);
if(_mm_errorhandler) _mm_errorhandler();
_mm_rewind(modreader);_mm_iobase_revert();
return NULL;
}
if(!(mf=ML_AllocUniMod())) {
ML_FreeEx(&of);
_mm_rewind(modreader);_mm_iobase_revert();
if(_mm_errorhandler) _mm_errorhandler();
return NULL;
}
/* Copy the static MODULE contents into the dynamic MODULE struct. */
memcpy(mf,&of,sizeof(MODULE));
_mm_iobase_revert();
if(maxchan>0) {
if(!(mf->flags&UF_NNA)&&(mf->numchn<maxchan))
maxchan = mf->numchn;
else
if((mf->numvoices)&&(mf->numvoices<maxchan))
maxchan = mf->numvoices;
if(maxchan<mf->numchn) mf->flags |= UF_NNA;
if(MikMod_SetNumVoices_internal(maxchan,-1)) {
Player_Free(mf);
return NULL;
}
}
if(SL_LoadSamples()) {
Player_Free_internal(mf);
return NULL;
}
if(Player_Init(mf)) {
Player_Free_internal(mf);
mf=NULL;
}
return mf;
//.........这里部分代码省略.........