static BOOL DupChannel( SoundManager *sm, Channel* channel, Channel** dupChannelPtr ) { Channel* dupChannel; HRESULT Error; *dupChannelPtr = NULL; // dupChannel = malloc( sizeof(Channel ) ); dupChannel = geRam_Allocate( sizeof(Channel ) ); if( dupChannel == NULL ) { geErrorLog_Add(GE_ERR_OUT_OF_MEMORY, NULL ); return FALSE; } Error = IDirectSound_DuplicateSoundBuffer( lpDirectSound, channel->buffer, &dupChannel->buffer ); if( Error != DS_OK ) { geRam_Free(dupChannel); // free( dupChannel ); dupChannel = ReloadData( channel->Data ); if( dupChannel == NULL ) { geErrorLog_Add(GE_ERR_DS_ERROR, NULL); return FALSE; } } dupChannel->ID = sm->smNextChannelID++; dupChannel->next = NULL; dupChannel->nextDup = channel->nextDup; dupChannel->cfg = channel->cfg; // dupChannel->name = NULL; dupChannel->Data = channel->Data; channel->nextDup = dupChannel; *dupChannelPtr = dupChannel; return( TRUE ); }
//static BOOL CreateChannel( char* Name, DSBUFFERDESC* dsBD, Channel** chanelPtr) static BOOL CreateChannel(DSBUFFERDESC* dsBD, Channel** chanelPtr) { Channel* channel; // channel = malloc( sizeof( Channel ) ); channel = geRam_Allocate( sizeof( Channel ) ); if ( channel == NULL ) { geErrorLog_Add(GE_ERR_OUT_OF_MEMORY, NULL); return( FALSE ); } if(DS_OK != IDirectSound_CreateSoundBuffer(lpDirectSound, dsBD, &channel->buffer, NULL)) { geErrorLog_Add(GE_ERR_CREATE_SOUND_BUFFER_FAILED, NULL); return FALSE; } if(DS_OK != IDirectSoundBuffer_GetFrequency(channel->buffer, &channel->BaseFreq) ) { geErrorLog_Add(GE_ERR_DS_ERROR, NULL); return FALSE; } channel->next = NULL; channel->nextDup = NULL; channel->ID = 0; channel->cfg.Volume = 1.0f; channel->cfg.Pan = 0.0f; channel->cfg.Frequency = 0.0f; // channel->name = Name; *chanelPtr = channel; return( TRUE ); }
//===================================================================================== // geSound_SystemCreate //===================================================================================== GENESISAPI geSound_System *geSound_CreateSoundSystem(HWND hWnd) { geSound_System *SoundSystem; SoundSystem = GE_RAM_ALLOCATE_STRUCT(geSound_System); if (!SoundSystem) { geErrorLog_Add(GE_ERR_OUT_OF_MEMORY, NULL); return NULL; } memset(SoundSystem, 0, sizeof(geSound_System)); // Initialize the sound system SoundSystem->SoundM = CreateSoundManager(hWnd); if (!SoundSystem->SoundM) { geRam_Free(SoundSystem); geErrorLog_Add(GE_ERR_CREATE_SOUND_MANAGER_FAILED, NULL); return NULL; } SoundSystem->GlobalVolume = 1.0f; return SoundSystem; }
static BOOL ModifyChannel( Channel *channel, geSound_Cfg *cfg ) { int Error, Vol, Pan, Freq; assert(channel); if( !cfg ) return( TRUE ); ClearDupBuffers(channel); if( cfg->Volume != channel->cfg.Volume ) { Vol = (DWORD)((1.0 - cfg->Volume ) * DSBVOLUME_MIN); Error = IDirectSoundBuffer_SetVolume(channel->buffer, Vol); if (Error != DS_OK) { geErrorLog_Add(GE_ERR_DS_ERROR, NULL); return FALSE; } channel->cfg.Volume = cfg->Volume; } if( cfg->Pan != channel->cfg.Pan ) { Pan = (int)(cfg->Pan * DSBPAN_RIGHT); Error = IDirectSoundBuffer_SetPan(channel->buffer, Pan); if (Error != DS_OK) { geErrorLog_Add(GE_ERR_DS_ERROR, NULL); return FALSE; } channel->cfg.Pan = cfg->Pan; } if( cfg->Frequency != channel->cfg.Frequency ) { Freq = (DWORD)(channel->BaseFreq * cfg->Frequency); if(Freq < 0) Freq = 0; Error = IDirectSoundBuffer_SetFrequency(channel->buffer, Freq); if (Error != DS_OK) { geErrorLog_Add(GE_ERR_DS_ERROR, NULL); return FALSE; } channel->cfg.Frequency = cfg->Frequency; } return TRUE; }
//===================================================================================== // geCamera_Create //===================================================================================== GENESISAPI geCamera *GENESISCC geCamera_Create(geFloat Fov, const geRect *Rect) { geCamera *Camera; assert( Rect != NULL ); Camera = GE_RAM_ALLOCATE_STRUCT(geCamera); if (Camera == NULL) { geErrorLog_Add(-1, NULL); //FIXME return NULL; } memset(Camera, 0, sizeof(geCamera)); Camera->ZScale = 0.5f; #if 0 Camera->ZFar = 1000.0f; Camera->ZFarEnable = GE_TRUE; #endif geCamera_SetAttributes(Camera,Fov,Rect); return Camera; }
//static BOOL GetSoundData( char* Name, unsigned char** dataPtr) static BOOL GetSoundData( geVFile *File, unsigned char** dataPtr) { // FILE * f; int32 Size; uint8 *data; // int32 CurPos; #if 0 f = fopen(Name, "rb"); if (!f) { geErrorLog_Add(GE_ERR_FILE_OPEN_ERROR, NULL); return FALSE; } #endif #if 0 CurPos = ftell (f); // Save the startinf pos into this function fseek (f, 0, SEEK_END); // Seek to end Size = ftell (f); // Get End (this will be the size) fseek (f, CurPos, SEEK_SET); // Restore file position #endif if (geVFile_Size(File, &Size) == GE_FALSE) return FALSE; data = geRam_Allocate(Size); if (!data) { geErrorLog_Add(GE_ERR_OUT_OF_MEMORY, NULL); return FALSE; } if (geVFile_Read(File, data, Size) == GE_FALSE) { geRam_Free(data); return FALSE; } // fread(data, Size, 1, f); // fclose(f); *dataPtr = data; return( TRUE ); }
static BOOL FreeChannel(SoundManager *sm, Channel* channel) { int Error; Channel*prevChannel = NULL, *curChannel; if ( channel ) { StopDupBuffers( channel ); ClearDupBuffers( channel ); Error = IDirectSoundBuffer_Stop(channel->buffer); if (Error != DS_OK) { geErrorLog_Add(GE_ERR_DS_ERROR, NULL); return FALSE; } Error = IDirectSound_Release(channel->buffer); if (Error != DS_OK) { geErrorLog_Add(GE_ERR_DS_ERROR, NULL); return FALSE; } // if( channel->name ) // geRam_Free(channel->name); // free( channel->name ); if( channel->Data ) geRam_Free(channel->Data); curChannel = sm->smChannels; while( curChannel && curChannel != channel ) { prevChannel = curChannel; curChannel = curChannel->next; } if( curChannel ) { if( prevChannel ) prevChannel->next = curChannel->next; else sm->smChannels = curChannel->next; geRam_Free(curChannel); // free( curChannel ); } } return TRUE; }
static BOOL FreeAllChannels(SoundManager *sm) { int Error; Channel* channel, *nextChannel; channel = sm->smChannels; while( channel ) { nextChannel = channel->next; StopDupBuffers( channel ); ClearDupBuffers( channel ); Error = IDirectSoundBuffer_Stop(channel->buffer); if (Error != DS_OK) { geErrorLog_Add(GE_ERR_DS_ERROR, NULL); return FALSE; } Error = IDirectSound_Release(channel->buffer); if (Error != DS_OK) { geErrorLog_Add(GE_ERR_DS_ERROR, NULL); return FALSE; } // if( channel->name ) // geRam_Free(channel->name); // free( channel->name ); if (channel->Data) geRam_Free(channel->Data); geRam_Free(channel); // free( channel ); channel = nextChannel; } sm->smChannels = NULL; sm->smChannelCount = 0; return TRUE; }
static BOOL StopSoundChannel(Channel* channel) { HRESULT hres; assert(channel); hres = IDirectSoundBuffer_Stop(channel->buffer); if (hres == DS_OK) return TRUE; geErrorLog_Add(GE_ERR_DS_ERROR, NULL); return FALSE; }
static geBoolean LoadMotions(GBSP_BSPData *BSP, geVFile *f) { char KeyS[100], ValueS[100]; char line[200]; int32 NumMotions, ModelNum, i; GFX_Model *Models; if (geVFile_GetS(f, line, sizeof(line)) == GE_FALSE) goto fail; if (sscanf(line, "%s %s\n", KeyS, ValueS) != 2) goto fail; if (strcmp(KeyS, "Genesis_Motion_File")) goto fail; if (geVFile_GetS(f, line, sizeof(line)) == GE_FALSE) goto fail; if (sscanf(line, "%s %i\n", KeyS, &NumMotions) != 2) goto fail; if (strcmp(KeyS, "NumMotions")) goto fail; Models = BSP->GFXModels; for (i=0; i< NumMotions; i++) { if (geVFile_GetS(f, line, sizeof(line)) == GE_FALSE) goto fail; if (sscanf(line, "%s %i\n", KeyS, &ModelNum) != 2) goto fail; if (strcmp(KeyS, "ModelNum")) goto fail; Models[ModelNum].Motion = geMotion_CreateFromFile(f); if (!Models[ModelNum].Motion) goto fail; } return GE_TRUE; fail: geErrorLog_Add(GE_ERR_INVALID_MODEL_MOTION_FILE, NULL); return GE_FALSE; }
static BOOL ParseData( const uint8* data, DSBUFFERDESC* dsBD, BYTE ** pbWaveData ) { //Parse the Data memset(dsBD, 0, sizeof(DSBUFFERDESC)); dsBD->dwSize = sizeof(DSBUFFERDESC); dsBD->dwFlags = DSBCAPS_STATIC | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY; if (!DSParseWaveResource(data, &dsBD->lpwfxFormat, pbWaveData, &dsBD->dwBufferBytes)) { geErrorLog_Add(GE_ERR_INVALID_WAV, NULL); return FALSE; } return( TRUE ); }
//===================================================================================== // User_EngineInit //===================================================================================== geBoolean User_EngineInit(geEngine *Engine) { User_Info *Info; assert(Engine->UserInfo == NULL); Info = GE_RAM_ALLOCATE_STRUCT(User_Info); if (!Info) { geErrorLog_Add(GE_ERR_OUT_OF_MEMORY, NULL); return GE_FALSE;; } memset(Info, 0, sizeof(User_Info)); Engine->UserInfo = Info; return GE_TRUE; }
//======================================================================================== // GBSP_LoadGBSPFile //======================================================================================== BOOL GBSP_LoadGBSPFile(geVFile *File, GBSP_BSPData *BSP) { GBSP_Chunk Chunk; assert(File); assert(BSP); while (1) { if (!ReadChunk(BSP, &Chunk, File)) { geErrorLog_Add(GE_ERR_ERROR_READING_BSP_CHUNK, NULL); return GE_FALSE; } if (Chunk.Type == GBSP_CHUNK_END) break; } return TRUE; }
//===================================================================================== // User_WorldInit //===================================================================================== geBoolean User_WorldInit(geWorld *World) { User_Info *Info; assert(World != NULL); Info = GE_RAM_ALLOCATE_STRUCT(User_Info); assert(Info != NULL); if (!Info) { geErrorLog_Add(GE_ERR_OUT_OF_MEMORY, NULL); return GE_FALSE; } memset(Info, 0, sizeof(User_Info)); World->UserInfo = Info; return GE_TRUE; }
static BOOL StartSoundChannel( SoundManager *sm, unsigned int Handle, geSound_Cfg *cfg, int loop, unsigned int* sfx) { HRESULT hres; Channel* channel, *dupChannel; if( Handle == 0 ) return( FALSE ); channel = GetChannel( sm, Handle ); //Clear all non-playing duplicate buffers. ClearDupBuffers(channel); //If the main buffer is playing and all non-playing dups have been cleared //we need a new duplicate. if( ChannelPlaying( channel ) ) { if(!DupChannel( sm,channel, &dupChannel ) ) return( FALSE ); channel = dupChannel; } if( !ModifyChannel( channel, cfg ) ) return( FALSE ); IDirectSoundBuffer_SetCurrentPosition(channel->buffer, 0); hres = IDirectSoundBuffer_Play( channel->buffer, 0, 0, loop ? DSBPLAY_LOOPING : 0); if (hres == DS_OK) { if( sfx ) *sfx = channel->ID; return TRUE; } geErrorLog_Add(GE_ERR_DS_ERROR, NULL); return FALSE; }
//======================================================================================== // ReadChunk //======================================================================================== static geBoolean ReadChunk(GBSP_BSPData *BSP, GBSP_Chunk *Chunk, geVFile *f) { int i; if (geVFile_Read(f, Chunk, sizeof(GBSP_Chunk)) == GE_FALSE) { return GE_FALSE; } switch(Chunk->Type) { case GBSP_CHUNK_HEADER: { // printf("GBSP_CHUNK_HEADER\n"); if (sizeof(GBSP_Header) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } if (!ReadChunkData(Chunk, (void*)&BSP->GBSPHeader, f)) return GE_FALSE; if (strcmp(BSP->GBSPHeader.TAG, "GBSP")) { geErrorLog_Add(GE_ERR_INVALID_BSP_TAG, NULL); return GE_FALSE; } if (BSP->GBSPHeader.Version != GBSP_VERSION) { geErrorLog_Add(GE_ERR_INVALID_BSP_VERSION, NULL); return GE_FALSE; } break; } case GBSP_CHUNK_MODELS: { // printf("GBSP_CHUNK_MODELS\n"); if (sizeof(GFX_Model) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXModels = Chunk->Elements; BSP->GFXModels = GE_RAM_ALLOCATE_ARRAY(GFX_Model, BSP->NumGFXModels); if (!ReadChunkData(Chunk, (void*)BSP->GFXModels, f)) return GE_FALSE; // Walk the models and zero out the motion pointers for (i = 0; i < BSP->NumGFXModels; i++) BSP->GFXModels[i].Motion = NULL; break; } case GBSP_CHUNK_NODES: { // printf("GBSP_CHUNK_NODES\n"); if (sizeof(GFX_Node) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXNodes = Chunk->Elements; BSP->GFXNodes = (GFX_Node*)geRam_Allocate(sizeof(GFX_Node)*BSP->NumGFXNodes); if (!ReadChunkData(Chunk, (void*)BSP->GFXNodes, f)) return GE_FALSE; break; } case GBSP_CHUNK_BNODES: { // printf("GBSP_CHUNK_BNODES\n"); if (sizeof(GFX_BNode) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXBNodes = Chunk->Elements; if (BSP->NumGFXBNodes) { BSP->GFXBNodes = (GFX_BNode*)geRam_Allocate(sizeof(GFX_BNode)*BSP->NumGFXBNodes); if (!ReadChunkData(Chunk, (void*)BSP->GFXBNodes, f)) return GE_FALSE; } break; } case GBSP_CHUNK_LEAFS: { // printf("GBSP_CHUNK_LEAFS\n"); if (sizeof(GFX_Leaf) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXLeafs = Chunk->Elements; BSP->GFXLeafs = (GFX_Leaf*)geRam_Allocate(sizeof(GFX_Leaf)*BSP->NumGFXLeafs); if (!ReadChunkData(Chunk, (void*)BSP->GFXLeafs, f)) return GE_FALSE; break; } case GBSP_CHUNK_CLUSTERS: { // printf("GBSP_CHUNK_CLUSTERS\n"); if (sizeof(GFX_Cluster) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXClusters = Chunk->Elements; //BSP->GFXClusters = GE_RAM_ALLOCATE_ARRAY(GFX_Cluster, BSP->NumGFXClusters); BSP->GFXClusters = (GFX_Cluster*)geRam_Allocate(sizeof(GFX_Cluster)*BSP->NumGFXClusters); if (!ReadChunkData(Chunk, (void*)BSP->GFXClusters, f)) return GE_FALSE; break; } case GBSP_CHUNK_AREAS: { // printf("GBSP_CHUNK_AREAS\n"); if (sizeof(GFX_Area) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXAreas = Chunk->Elements; BSP->GFXAreas = GE_RAM_ALLOCATE_ARRAY(GFX_Area, BSP->NumGFXAreas); if (!ReadChunkData(Chunk, BSP->GFXAreas, f)) return GE_FALSE; break; } case GBSP_CHUNK_AREA_PORTALS: { // printf("GBSP_CHUNK_AREA_PORTALS\n"); if (sizeof(GFX_AreaPortal) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXAreaPortals = Chunk->Elements; BSP->GFXAreaPortals = GE_RAM_ALLOCATE_ARRAY(GFX_AreaPortal, BSP->NumGFXAreaPortals); if (!ReadChunkData(Chunk, BSP->GFXAreaPortals, f)) return GE_FALSE; break; } case GBSP_CHUNK_PORTALS: { // printf("GBSP_CHUNK_PORTALS\n"); if (sizeof(GFX_Portal) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXPortals = Chunk->Elements; BSP->GFXPortals = (GFX_Portal*)geRam_Allocate(sizeof(GFX_Portal)*BSP->NumGFXPortals); if (!ReadChunkData(Chunk, (void*)BSP->GFXPortals, f)) return GE_FALSE; break; } case GBSP_CHUNK_PLANES: { // printf("GBSP_CHUNK_PLANES\n"); if (sizeof(GFX_Plane) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXPlanes = Chunk->Elements; BSP->GFXPlanes = (GFX_Plane*)geRam_Allocate(sizeof(GFX_Plane)*BSP->NumGFXPlanes); if (!ReadChunkData(Chunk, (void*)BSP->GFXPlanes, f)) return GE_FALSE; break; } case GBSP_CHUNK_FACES: { // printf("GBSP_CHUNK_FACES\n"); if (sizeof(GFX_Face) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXFaces = Chunk->Elements; BSP->GFXFaces = (GFX_Face*)geRam_Allocate(sizeof(GFX_Face)*BSP->NumGFXFaces); if (!ReadChunkData(Chunk, (void*)BSP->GFXFaces, f)) return GE_FALSE; break; } case GBSP_CHUNK_LEAF_FACES: { // printf("GBSP_CHUNK_LEAF_FACES\n"); if (sizeof(int32) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXLeafFaces = Chunk->Elements; BSP->GFXLeafFaces = (int32*)geRam_Allocate(sizeof(int32)*BSP->NumGFXLeafFaces); if (!ReadChunkData(Chunk, (void*)BSP->GFXLeafFaces, f)) return GE_FALSE; break; } case GBSP_CHUNK_LEAF_SIDES: { // printf("GBSP_CHUNK_LEAF_SIDES\n"); if (sizeof(GFX_LeafSide) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXLeafSides = Chunk->Elements; BSP->GFXLeafSides = (GFX_LeafSide*)geRam_Allocate(sizeof(GFX_LeafSide)*BSP->NumGFXLeafSides); if (!ReadChunkData(Chunk, (void*)BSP->GFXLeafSides, f)) return GE_FALSE; break; } case GBSP_CHUNK_VERTS: { // printf("GBSP_CHUNK_VERTS\n"); if (sizeof(geVec3d) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXVerts = Chunk->Elements; BSP->GFXVerts = (geVec3d*)geRam_Allocate(sizeof(geVec3d)*BSP->NumGFXVerts); if (!ReadChunkData(Chunk, (void*)BSP->GFXVerts, f)) return GE_FALSE; break; } case GBSP_CHUNK_VERT_INDEX: { // printf("GBSP_CHUNK_VERT_INDEX\n"); if (sizeof(int32) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXVertIndexList = Chunk->Elements; BSP->GFXVertIndexList = (int32*)geRam_Allocate(sizeof(int32)*BSP->NumGFXVertIndexList); if (!ReadChunkData(Chunk, (void*)BSP->GFXVertIndexList, f)) return GE_FALSE; break; } case GBSP_CHUNK_RGB_VERTS: { // printf("GBSP_CHUNK_RGB_VERTS\n"); if (sizeof(geVec3d) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXRGBVerts = Chunk->Elements; BSP->GFXRGBVerts = (geVec3d*)geRam_Allocate(sizeof(geVec3d)*BSP->NumGFXRGBVerts); if (!ReadChunkData(Chunk, (void*)BSP->GFXRGBVerts, f)) return GE_FALSE; break; } case GBSP_CHUNK_TEXINFO: { // printf("GBSP_CHUNK_TEXINFO\n"); if (sizeof(GFX_TexInfo) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXTexInfo = Chunk->Elements; BSP->GFXTexInfo = (GFX_TexInfo*)geRam_Allocate(sizeof(GFX_TexInfo)*BSP->NumGFXTexInfo); if (!ReadChunkData(Chunk, (void*)BSP->GFXTexInfo, f)) return GE_FALSE; break; } case GBSP_CHUNK_TEXTURES: { // printf("GBSP_CHUNK_TEXTURES\n"); if (sizeof(GFX_Texture) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXTextures = Chunk->Elements; BSP->GFXTextures = (GFX_Texture*)geRam_Allocate(sizeof(GFX_Texture)*BSP->NumGFXTextures); if (!ReadChunkData(Chunk, (void*)BSP->GFXTextures, f)) return GE_FALSE; break; } case GBSP_CHUNK_TEXDATA: { // printf("GBSP_CHUNK_TEXDATA\n"); if (sizeof(uint8) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXTexData = Chunk->Elements; BSP->GFXTexData = (uint8*)geRam_Allocate(sizeof(uint8)*BSP->NumGFXTexData); if (!ReadChunkData(Chunk, (void*)BSP->GFXTexData, f)) return GE_FALSE; break; } case GBSP_CHUNK_ENTDATA: { // printf("GBSP_CHUNK_ENTDATA\n"); if (sizeof(uint8) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXEntData = Chunk->Elements; BSP->GFXEntData = (uint8*)geRam_Allocate(sizeof(uint8)*BSP->NumGFXEntData); if (!ReadChunkData(Chunk, (void*)BSP->GFXEntData, f)) return GE_FALSE; break; } case GBSP_CHUNK_LIGHTDATA: { // printf("GBSP_CHUNK_LIGHTDATA\n"); if (sizeof(uint8) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXLightData = Chunk->Elements; BSP->GFXLightData = (uint8*)geRam_Allocate(sizeof(uint8)*BSP->NumGFXLightData); if (!ReadChunkData(Chunk, (void*)BSP->GFXLightData, f)) return GE_FALSE; break; } case GBSP_CHUNK_VISDATA: { // printf("GBSP_CHUNK_VISDATA\n"); if (sizeof(uint8) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXVisData = Chunk->Elements; BSP->GFXVisData = (uint8*)geRam_Allocate(sizeof(uint8)*BSP->NumGFXVisData); if (!ReadChunkData(Chunk, (void*)BSP->GFXVisData, f)) return GE_FALSE; break; } case GBSP_CHUNK_SKYDATA: { // printf("GBSP_CHUNK_SKYDATA\n"); if (sizeof(GFX_SkyData) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } if (!ReadChunkData(Chunk, (void*)&BSP->GFXSkyData, f)) return GE_FALSE; break; } case GBSP_CHUNK_PALETTES: { // printf("GBSP_CHUNK_PALETTES\n"); if (sizeof(DRV_Palette) != Chunk->Size) { geErrorLog_Add(GE_ERR_BAD_BSP_FILE_CHUNK_SIZE, NULL); return GE_FALSE; } BSP->NumGFXPalettes = Chunk->Elements; BSP->GFXPalettes = (DRV_Palette*)geRam_Allocate(sizeof(DRV_Palette)*BSP->NumGFXPalettes); if (BSP->GFXPalettes == NULL) return GE_FALSE; if (!ReadChunkData(Chunk, (void*)BSP->GFXPalettes, f)) return GE_FALSE; break; } case GBSP_CHUNK_MOTIONS: { // printf("GBSP_CHUNK_MOTIONS\n"); return LoadMotions(BSP, f); } case GBSP_CHUNK_END: { // printf("GBSP_CHUNK_END\n"); break; } default: // printf("Don't know what this chunk is\n"); return GE_FALSE; } return TRUE; }