/* ============== S_LoadSound ============== */ sfxcache_t *S_LoadSound (sfx_t *s) { char namebuffer[256]; byte *data; wavinfo_t info; int len; float stepscale; sfxcache_t *sc; byte stackbuf[1*1024]; // avoid dirtying the cache heap // see if still in memory sc = Cache_Check (&s->cache); if (sc) return sc; //Con_Printf ("S_LoadSound: %x\n", (int)stackbuf); // load it in Q_strcpy(namebuffer, "sound/"); Q_strcat(namebuffer, s->name); // Con_Printf ("loading %s\n",namebuffer); data = COM_LoadStackFile(namebuffer, stackbuf, sizeof(stackbuf)); if (!data) { Con_Printf ("Couldn't load %s\n", namebuffer); return NULL; } info = GetWavinfo (s->name, data, com_filesize); if (info.channels != 1) { Con_Printf ("%s is a stereo sample\n",s->name); return NULL; } stepscale = (float)info.rate / shm->speed; len = info.samples / stepscale; len = len * info.width * info.channels; sc = Cache_Alloc ( &s->cache, len + sizeof(sfxcache_t), s->name); if (!sc) return NULL; sc->length = info.samples; sc->loopstart = info.loopstart; sc->speed = info.rate; sc->width = info.width; sc->stereo = info.channels; ResampleSfx (s, sc->speed, sc->width, data + info.dataofs); return sc; }
/* ================== Mod_LoadModel Loads a model into the cache ================== */ model_t *Mod_LoadModel (model_t *mod, qboolean crash) { // void *d; unsigned *buf; byte stackbuf[1024]; // avoid dirtying the cache heap if (!mod->needload) { if (mod->type == mod_alias) { // d = Cache_Check (&mod->cache); // if (d) // return mod; ; } else return mod; // not cached at all } // // load the file // buf = (unsigned *)COM_LoadStackFile (mod->name, stackbuf, sizeof(stackbuf)); if (!buf) { if (crash) SV_Error ("Mod_NumForName: %s not found", mod->name); return NULL; } // // allocate a new model // COM_FileBase (mod->name, loadname); loadmodel = mod; // // fill it in // // call the apropriate loader mod->needload = false; Mod_LoadBrushModel (mod, buf); return mod; }
/* ================== Mod_LoadModel Loads a model into the cache ================== */ model_t *Mod_LoadModel (model_t *mod, qboolean crash) { void *d; unsigned *buf; byte stackbuf[1024]; // avoid dirtying the cache heap if (!mod->needload) { if (mod->type == mod_alias) { d = Cache_Check (&mod->cache); if (d) return mod; } else return mod; // not cached at all } // // because the world is so huge, load it one piece at a time // if (!crash) { } // // load the file // buf = (unsigned *)COM_LoadStackFile (mod->name, stackbuf, sizeof(stackbuf)); if (!buf) { if (crash) Sys_Error ("Mod_NumForName: %s not found", mod->name); return NULL; } // // allocate a new model // COM_FileBase (mod->name, loadname); loadmodel = mod; // // fill it in // // call the apropriate loader mod->needload = false; switch (LittleLong(*(unsigned *)buf)) { case IDPOLYHEADER: Mod_LoadAliasModel (mod, buf); break; case IDSPRITEHEADER: Mod_LoadSpriteModel (mod, buf); break; default: Mod_LoadBrushModel (mod, buf); break; } return mod; }
/* ================== Mod_LoadModel Loads a model into the cache ================== */ model_t *Mod_LoadModel (model_t *mod, qboolean crash) { unsigned *buf; // >>> FIX: For Nintendo Wii using devkitPPC / libogc // Deferring allocation. Stack in this device is pretty small: //byte stackbuf[1024]; // avoid dirtying the cache heap byte* stackbuf; // avoid dirtying the cache heap // <<< FIX if (mod->type == mod_alias) { if (Cache_Check (&mod->cache)) { mod->needload = NL_PRESENT; return mod; } } else { if (mod->needload == NL_PRESENT) return mod; } // // because the world is so huge, load it one piece at a time // // // load the file // // >>> FIX: For Nintendo Wii using devkitPPC / libogc // Allocating for previous fixes (and, this time, expanding the allocated size), in big stack: stackbuf = Sys_BigStackAlloc(4096 * sizeof(byte), "Mod_LoadModel"); // <<< FIX // >>> FIX: For Nintendo Wii using devkitPPC / libogc // Adjusting for previous fix: //buf = (unsigned *)COM_LoadStackFile (mod->name, stackbuf, sizeof(stackbuf)); buf = (unsigned *)COM_LoadStackFile (mod->name, stackbuf, 4096); // <<< FIX if (!buf) { if (crash) Sys_Error ("Mod_NumForName: %s not found", mod->name); // >>> FIX: For Nintendo Wii using devkitPPC / libogc // Deallocating from previous fixes: Sys_BigStackFree(4096 * sizeof(byte), "Mod_LoadModel"); // <<< FIX return NULL; } // // allocate a new model // COM_FileBase (mod->name, loadname); loadmodel = mod; // // fill it in // // call the apropriate loader mod->needload = NL_PRESENT; switch (LittleLong(*(unsigned *)buf)) { case IDPOLYHEADER: Mod_LoadAliasModel (mod, buf); break; case IDSPRITEHEADER: Mod_LoadSpriteModel (mod, buf); break; default: Mod_LoadBrushModel (mod, buf); break; } // >>> FIX: For Nintendo Wii using devkitPPC / libogc // Deallocating from previous fixes: Sys_BigStackFree(4096 * sizeof(byte), "Mod_LoadModel"); // <<< FIX return mod; }
/* ============== S_LoadSound ============== */ sfxcache_t *S_LoadSound(sfx_t *s) { char namebuffer[256]; byte *data; wavinfo_t info; int len; float stepscale; sfxcache_t *sc; byte stackbuf[1*1024]; // avoid dirtying the cache heap loadedfile_t *fileinfo; // 2001-09-12 Returning information about loaded file by Maddes // see if still in memory sc = Cache_Check(&s->cache); if (sc) { return sc; } //Con_Printf ("S_LoadSound: %x\n", (int)stackbuf); // load it in Q_strcpy(namebuffer, "sound/"); Q_strcat(namebuffer, s->name); if (developer.value == 1) { Con_DPrintf("Loading %s\n",namebuffer); // Edited } // Con_Printf ("loading %s\n",namebuffer); // 2001-09-12 Returning information about loaded file by Maddes start /* data = COM_LoadStackFile(namebuffer, stackbuf, sizeof(stackbuf)); if (!data) */ fileinfo = COM_LoadStackFile(namebuffer, stackbuf, sizeof(stackbuf)); if (!fileinfo) // 2001-09-12 Returning information about loaded file by Maddes end { Con_Printf("Couldn't load %s\n", namebuffer); return NULL; } data = fileinfo->data; // 2001-09-12 Returning information about loaded file by Maddes info = GetWavinfo(s->name, data, com_filesize); if (info.channels != 1) { Con_Printf("%s is a stereo sample\n",s->name); return NULL; } stepscale = (float)info.rate / shm->speed; len = info.samples / stepscale; len = len * info.width * info.channels; sc = Cache_Alloc(&s->cache, len + sizeof(sfxcache_t), s->name); if (!sc) { return NULL; } sc->length = info.samples; sc->loopstart = info.loopstart; sc->speed = info.rate; sc->width = info.width; sc->stereo = info.channels; ResampleSfx(s, sc->speed, sc->width, data + info.dataofs); return sc; }