diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/cryo/clhnm.cpp | 162 | ||||
-rw-r--r-- | engines/cryo/clsoundgroup.cpp | 24 | ||||
-rw-r--r-- | engines/cryo/clsoundraw.cpp | 12 | ||||
-rw-r--r-- | engines/cryo/cryolib.cpp | 8 | ||||
-rw-r--r-- | engines/cryo/cryolib.h | 68 |
5 files changed, 131 insertions, 143 deletions
diff --git a/engines/cryo/clhnm.cpp b/engines/cryo/clhnm.cpp index a2915bf4dc..8c88547030 100644 --- a/engines/cryo/clhnm.cpp +++ b/engines/cryo/clhnm.cpp @@ -266,20 +266,20 @@ hnm_t *CLHNM_New(int preload_size) { use_preload = 1; if (!__libError) { - hnm->frame = 0; + hnm->_frameNum = 0; hnm->ff_4 = 0; - hnm->file = 0; - hnm->work_buffer[0] = 0; - hnm->work_buffer[1] = 0; - hnm->final_buffer = 0; - hnm->read_buffer = 0; + hnm->_file = nullptr; + hnm->tmpBuffer[0] = nullptr; + hnm->tmpBuffer[1] = nullptr; + hnm->finalBuffer = nullptr; + hnm->_readBuffer = nullptr; hnm->ff_896 = 0; - hnm->total_read = 0; + hnm->_totalRead = 0; for (i = 0; i < 256; i++) { - hnm->palette[i].a = 0; - hnm->palette[i].r = 0; - hnm->palette[i].g = 0; - hnm->palette[i].b = 0; + hnm->_palette[i].a = 0; + hnm->_palette[i].r = 0; + hnm->_palette[i].g = 0; + hnm->_palette[i].b = 0; } } else CLCheckError(); @@ -302,44 +302,44 @@ void CLHNM_Dispose(hnm_t *hnm) { void CLHNM_SetFile(hnm_t *hnm, file_t *file) { - hnm->file = file; + hnm->_file = file; CLNoError; } void CLHNM_SetFinalBuffer(hnm_t *hnm, byte *buffer) { - hnm->final_buffer = buffer; + hnm->finalBuffer = buffer; CLNoError; } void CLHNM_AllocMemory(hnm_t *hnm) { CLBeginCheck; - hnm->work_buffer[0] = (byte *)CLMemory_Alloc(hnm->_header._bufferSize + 2); + hnm->tmpBuffer[0] = (byte *)CLMemory_Alloc(hnm->_header._bufferSize + 2); CLCheckError(); - if (!hnm->work_buffer[0]) + if (!hnm->tmpBuffer[0]) goto fin; - hnm->work_buffer[1] = (byte *)CLMemory_Alloc(hnm->_header._bufferSize + 2); + hnm->tmpBuffer[1] = (byte *)CLMemory_Alloc(hnm->_header._bufferSize + 2); CLCheckError(); - if (!hnm->work_buffer[1]) { - CLMemory_Free(hnm->work_buffer[0]); + if (!hnm->tmpBuffer[1]) { + CLMemory_Free(hnm->tmpBuffer[0]); CLCheckError(); - hnm->work_buffer[0] = 0; + hnm->tmpBuffer[0] = nullptr; goto fin; } if (!use_preload) { - hnm->read_buffer = (byte *)CLMemory_Alloc(hnm->_header._bufferSize + 2); + hnm->_readBuffer = (byte *)CLMemory_Alloc(hnm->_header._bufferSize + 2); // CLCheckError(); - if (!hnm->read_buffer) { - CLMemory_Free(hnm->work_buffer[0]); + if (!hnm->_readBuffer) { + CLMemory_Free(hnm->tmpBuffer[0]); CLCheckError(); - hnm->work_buffer[0] = 0; - CLMemory_Free(hnm->work_buffer[1]); + hnm->tmpBuffer[0] = nullptr; + CLMemory_Free(hnm->tmpBuffer[1]); CLCheckError(); - hnm->work_buffer[1] = 0; + hnm->tmpBuffer[1] = nullptr; } } fin: @@ -349,22 +349,22 @@ fin: void CLHNM_DeallocMemory(hnm_t *hnm) { CLBeginCheck; - if (hnm->work_buffer[0]) { - CLMemory_Free(hnm->work_buffer[0]); + if (hnm->tmpBuffer[0]) { + CLMemory_Free(hnm->tmpBuffer[0]); CLCheckError(); - hnm->work_buffer[0] = 0; + hnm->tmpBuffer[0] = nullptr; } - if (hnm->work_buffer[1]) { - CLMemory_Free(hnm->work_buffer[1]); + if (hnm->tmpBuffer[1]) { + CLMemory_Free(hnm->tmpBuffer[1]); CLCheckError(); - hnm->work_buffer[1] = 0; + hnm->tmpBuffer[1] = nullptr; } if (!use_preload) { - if (hnm->read_buffer) { - CLMemory_Free(hnm->read_buffer); + if (hnm->_readBuffer) { + CLMemory_Free(hnm->_readBuffer); CLCheckError(); - hnm->read_buffer = 0; + hnm->_readBuffer = nullptr; } } @@ -374,7 +374,7 @@ void CLHNM_DeallocMemory(hnm_t *hnm) { void CLHNM_Read(hnm_t *hnm, int size) { long _size = size; if (!use_preload) { - CLFile_Read(*hnm->file, hnm->read_buffer, &_size); + CLFile_Read(*hnm->_file, hnm->_readBuffer, &_size); } } @@ -384,17 +384,17 @@ void CLHNM_GiveTime(hnm_t *hnm) { } } -void CLHNM_CanLoop(hnm_t *hnm, int16 can_loop) { - hnm->can_loop = can_loop; +void CLHNM_CanLoop(hnm_t *hnm, bool canLoop) { + hnm->_canLoop = canLoop; } void CLHNM_SelectBuffers(hnm_t *hnm) { - if (hnm->frame % 2) { - hnm->new_frame_buffer = hnm->work_buffer[1]; - hnm->old_frame_buffer = hnm->work_buffer[0]; + if (hnm->_frameNum % 2) { + hnm->_newFrameBuffer = hnm->tmpBuffer[1]; + hnm->_oldFrameBuffer = hnm->tmpBuffer[0]; } else { - hnm->new_frame_buffer = hnm->work_buffer[0]; - hnm->old_frame_buffer = hnm->work_buffer[1]; + hnm->_newFrameBuffer = hnm->tmpBuffer[0]; + hnm->_oldFrameBuffer = hnm->tmpBuffer[1]; } } @@ -403,8 +403,8 @@ void CLHNM_ChangePalette(hnm_t *hnm) { uint16 fst, cnt; byte *pal; color_t *color; - CLPalette_GetLastPalette(hnm->palette); - pal = hnm->data_ptr; + CLPalette_GetLastPalette(hnm->_palette); + pal = hnm->_dataPtr; if (*(uint16 *)pal == 0xFFFF) return; mincolor = 255; @@ -420,7 +420,7 @@ void CLHNM_ChangePalette(hnm_t *hnm) { mincolor = fst; if (maxcolor < fst + cnt) maxcolor = fst + cnt; - color = hnm->palette + fst; + color = hnm->_palette + fst; if (safe_palette) { while (cnt--) { byte r = *pal++; @@ -457,13 +457,13 @@ void CLHNM_ChangePalette(hnm_t *hnm) { } #endif // CLBlitter_Send2ScreenNextCopy(hnm->palette, mincolor, maxcolor - mincolor); - CLBlitter_Send2ScreenNextCopy(hnm->palette, 0, 256); + CLBlitter_Send2ScreenNextCopy(hnm->_palette, 0, 256); } void CLHNM_Desentrelace(hnm_t *hnm) { switch (hnm->_header._width) { case 320: - CLHNM_Desentrelace320(hnm->new_frame_buffer, hnm->final_buffer, hnm->_header._height); + CLHNM_Desentrelace320(hnm->_newFrameBuffer, hnm->finalBuffer, hnm->_header._height); CLNoError; break; // case 480: @@ -503,9 +503,9 @@ void CLHNM_ResetInternalTimer() { } void CLHNM_Reset(hnm_t *hnm) { - hnm->frame = 0; + hnm->_frameNum = 0; hnm->ff_4 = 0; - hnm->total_read = 0; + hnm->_totalRead = 0; sound_started = false; pending_sounds = 0; CLHNM_ResetInternalTimer(); @@ -517,7 +517,7 @@ int16 CLHNM_LoadFrame(hnm_t *hnm) { CLBeginCheck; CLHNM_TryRead(hnm, 4); CLEndCheck; - chunk = *(int *)hnm->read_buffer; + chunk = *(int *)hnm->_readBuffer; chunk = LE32(chunk); chunk &= 0xFFFFFF; // upper bit - keyframe mark? if (!chunk) @@ -538,8 +538,8 @@ int16 CLHNM_LoadFrame(hnm_t *hnm) { CLBeginCheck; CLHNM_TryRead(hnm, chunk - 4); CLEndCheck; - hnm->data_ptr = hnm->read_buffer; - hnm->total_read += chunk; + hnm->_dataPtr = hnm->_readBuffer; + hnm->_totalRead += chunk; return 1; } @@ -582,40 +582,40 @@ bool CLHNM_NextElement(hnm_t *hnm) { int16 id; char h6, h7; int16 i; - if (hnm->frame == 0) { + if (hnm->_frameNum == 0) { CLHNM_ResetInternalTimer(); pred_l = pred_r = 0; } - if (hnm->frame == hnm->_header._numbFrame) + if (hnm->_frameNum == hnm->_header._numbFrame) return false; if (!CLHNM_LoadFrame(hnm)) return false; for (;;) { - sz = PLE32(hnm->data_ptr) & 0xFFFFFF; - hnm->data_ptr += 4; - id = *(int16 *)hnm->data_ptr; - hnm->data_ptr += 2; - h6 = *hnm->data_ptr; - hnm->data_ptr += 1; - h7 = *hnm->data_ptr; - hnm->data_ptr += 1; - hnm->chunk_id = id; + sz = PLE32(hnm->_dataPtr) & 0xFFFFFF; + hnm->_dataPtr += 4; + id = *(int16 *)hnm->_dataPtr; + hnm->_dataPtr += 2; + h6 = *hnm->_dataPtr; + hnm->_dataPtr += 1; + h7 = *hnm->_dataPtr; + hnm->_dataPtr += 1; + hnm->_chunkId = id; switch (id) { case BE16('PL'): CLHNM_ChangePalette(hnm); - hnm->data_ptr += sz - 8; + hnm->_dataPtr += sz - 8; break; case BE16('IZ'): - hnm->frame++; + hnm->_frameNum++; CLHNM_SelectBuffers(hnm); - CLHNM_DecompLempelZiv(hnm->data_ptr + 4, hnm->new_frame_buffer); + CLHNM_DecompLempelZiv(hnm->_dataPtr + 4, hnm->_newFrameBuffer); switch (hnm->_header._width) { // case 320: CLBlitter_RawCopy320ASM(hnm->new_frame_buffer, hnm->old_frame_buffer, hnm->header.height); break; // case 480: CLBlitter_RawCopy480ASM(hnm->new_frame_buffer, hnm->old_frame_buffer, hnm->header.height); break; // case 640: CLBlitter_RawCopy640ASM(hnm->new_frame_buffer, hnm->old_frame_buffer, hnm->header.height); break; // default: memcpy(hnm->old_frame_buffer, hnm->new_frame_buffer, hnm->header.width * hnm->header.height); default: - memcpy(hnm->old_frame_buffer, hnm->new_frame_buffer, hnm->_header._bufferSize); //TODO strange buffer size here + memcpy(hnm->_oldFrameBuffer, hnm->_newFrameBuffer, hnm->_header._bufferSize); //TODO strange buffer size here } if (!(h6 & 1)) CLHNM_Desentrelace(hnm); @@ -623,7 +623,7 @@ bool CLHNM_NextElement(hnm_t *hnm) { // if(hnm->header.width == 640) // CLBlitter_RawCopy640(hnm->new_frame_buffer, hnm->final_buffer, hnm->header.height); // else - memcpy(hnm->final_buffer, hnm->new_frame_buffer, hnm->_header._height); //TODO: wrong size? + memcpy(hnm->finalBuffer, hnm->_newFrameBuffer, hnm->_header._height); //TODO: wrong size? } if (use_adpcm) { if (!sound_started) { @@ -638,16 +638,16 @@ bool CLHNM_NextElement(hnm_t *hnm) { } goto end_frame; case BE16('IU'): - hnm->frame++; + hnm->_frameNum++; CLHNM_SelectBuffers(hnm); - CLHNM_DecompUBA(hnm->new_frame_buffer, hnm->new_frame_buffer, hnm->old_frame_buffer, hnm->data_ptr, hnm->_header._width, h6); + CLHNM_DecompUBA(hnm->_newFrameBuffer, hnm->_newFrameBuffer, hnm->_oldFrameBuffer, hnm->_dataPtr, hnm->_header._width, h6); if (!(h6 & 1)) CLHNM_Desentrelace(hnm); else { // if(hnm->header.width == 640) // CLBlitter_RawCopy640(hnm->new_frame_buffer, hnm->final_buffer, hnm->header.height); // else - memcpy(hnm->final_buffer, hnm->new_frame_buffer, hnm->_header._width * hnm->_header._height); + memcpy(hnm->finalBuffer, hnm->_newFrameBuffer, hnm->_header._width * hnm->_header._height); } goto end_frame; case BE16('sd'): @@ -656,7 +656,7 @@ bool CLHNM_NextElement(hnm_t *hnm) { if (!h6) { int sound_size = sz - 8; if (!use_adpcm) { - CLSoundGroup_SetDatas(soundGroup, hnm->data_ptr, sound_size - 2, 0); + CLSoundGroup_SetDatas(soundGroup, hnm->_dataPtr, sound_size - 2, 0); if (sound_started) CLSoundGroup_PlayNextSample(soundGroup, soundChannel); else @@ -665,11 +665,11 @@ bool CLHNM_NextElement(hnm_t *hnm) { int16 *sound_buffer = (int16 *)CLSoundGroup_GetNextBuffer(soundGroup_adpcm); if (!pending_sounds) { const int kDecompTableSize = 256 * sizeof(int16); - CLHNM_LoadDecompTable((int16 *)hnm->data_ptr); - CLHNM_DecompADPCM(hnm->data_ptr + kDecompTableSize, sound_buffer, sound_size - kDecompTableSize); + CLHNM_LoadDecompTable((int16 *)hnm->_dataPtr); + CLHNM_DecompADPCM(hnm->_dataPtr + kDecompTableSize, sound_buffer, sound_size - kDecompTableSize); CLSoundGroup_AssignDatas(soundGroup_adpcm, sound_buffer, (sound_size - kDecompTableSize) * 2, 0); } else { - CLHNM_DecompADPCM(hnm->data_ptr, sound_buffer, sound_size); + CLHNM_DecompADPCM(hnm->_dataPtr, sound_buffer, sound_size); CLSoundGroup_AssignDatas(soundGroup_adpcm, sound_buffer, sound_size * 2, 0); } pending_sounds++; @@ -682,12 +682,12 @@ bool CLHNM_NextElement(hnm_t *hnm) { CLCheckError(); } } - hnm->data_ptr += sz - 8; + hnm->_dataPtr += sz - 8; break; default: if (custom_chunk_handler) - custom_chunk_handler(hnm->data_ptr, sz - 8, id, h6, h7); - hnm->data_ptr += sz - 8; + custom_chunk_handler(hnm->_dataPtr, sz - 8, id, h6, h7); + hnm->_dataPtr += sz - 8; } } end_frame: @@ -701,7 +701,7 @@ void CLHNM_ReadHeader(hnm_t *hnm) { CLBeginCheck; if (!use_preload) { long size = sizeof(hnm->_header); - CLFile_Read(*hnm->file, &hnm->_header, &size); + CLFile_Read(*hnm->_file, &hnm->_header, &size); } else ; CLCheckError(); @@ -726,7 +726,7 @@ int16 CLHNM_GetVersion(hnm_t *hnm) { } int CLHNM_GetFrameNum(hnm_t *hnm) { - return hnm->frame; + return hnm->_frameNum; } void CLHNM_DeactivatePreloadBuffer() { @@ -739,7 +739,7 @@ void CLHNM_Prepare2Read(hnm_t *hnm, int mode) { } void CLHNM_SetPosIntoFile(hnm_t *hnm, long pos) { - CLFile_SetPosition(*hnm->file, 1, pos); + CLFile_SetPosition(*hnm->_file, 1, pos); } void CLHNM_Desentrelace320(byte *frame_buffer, byte *final_buffer, uint16 height) { diff --git a/engines/cryo/clsoundgroup.cpp b/engines/cryo/clsoundgroup.cpp index 0058dee899..16d90bc29d 100644 --- a/engines/cryo/clsoundgroup.cpp +++ b/engines/cryo/clsoundgroup.cpp @@ -59,25 +59,25 @@ void CLSoundGroup_Free(soundgroup_t *sg) { void CLSoundGroup_Reverse16All(soundgroup_t *sg) { int16 i; for (i = 0; i < sg->numSounds; i++) - sg->sound[i]->reversed = 1; + sg->sound[i]->_reversed = true; } void *CLSoundGroup_GetNextBuffer(soundgroup_t *sg) { sound_t *sound = sg->sound[sg->soundIndex]; if (sg->ff_106) - while (sound->locked) ; - return ((char *)(*sound->sndHandle)) + sound->headerLen; + while (sound->_locked) ; + return sound->sndHandle + sound->_headerLen; } int16 CLSoundGroup_AssignDatas(soundgroup_t *sg, void *buffer, int length, int16 isSigned) { sound_t *sound = sg->sound[sg->soundIndex]; if (sg->ff_106) - while (sound->locked) ; - else if (sound->locked) + while (sound->_locked) ; + else if (sound->_locked) return 0; - sound->buffer = (char *)buffer; + sound->_buffer = (char *)buffer; CLSound_SetLength(sound, length); - sound->length = length; + sound->_length = length; // if(sound->reversed && sound->sampleSize == 16) // ReverseBlock16(buffer, length); // if(isSigned) @@ -99,14 +99,14 @@ int16 CLSoundGroup_SetDatas(soundgroup_t *sg, void *data, int length, int16 isSi CLCheckError(); } if (sg->ff_106) - while (sound->locked) ; - else if (sound->locked) + while (sound->_locked) ; + else if (sound->_locked) return 0; - buffer = ((char *)(*sound->sndHandle)) + sound->headerLen; - sound->buffer = (char *)buffer; + buffer = sound->sndHandle + sound->_headerLen; + sound->_buffer = (char *)buffer; memcpy(buffer, data, length); CLSound_SetLength(sound, length); - sound->length = length; + sound->_length = length; // if(sound->reversed && sound->sampleSize == 16) // ReverseBlock16(buffer, length); // if(isSigned) diff --git a/engines/cryo/clsoundraw.cpp b/engines/cryo/clsoundraw.cpp index ec280e49ed..e28dd914a7 100644 --- a/engines/cryo/clsoundraw.cpp +++ b/engines/cryo/clsoundraw.cpp @@ -31,9 +31,9 @@ sound_t *CLSoundRaw_New(int16 arg1, float rate, int16 sampleSize, int16 mode) { sound = (sound_t *)CLMemory_Alloc(sizeof(*sound)); if (sound) { sound->ff_1A = arg1; - sound->rate = rate; - sound->sampleSize = sampleSize; - sound->buffer = 0; + sound->_rate = rate; + sound->_sampleSize = sampleSize; + sound->_buffer = nullptr; // sound->sndHandle = CLMemory_AllocHandle(arg1 + 100); // if(!sound->sndHandle) // { @@ -57,7 +57,7 @@ sound_t *CLSoundRaw_New(int16 arg1, float rate, int16 sampleSize, int16 mode) { } void CLSoundRaw_Free(sound_t *sound) { - while (sound->locked) ; + while (sound->_locked) ; // CLMemory_FreeHandle(sound->sndHandle); CLMemory_Free(sound); } @@ -65,11 +65,11 @@ void CLSoundRaw_Free(sound_t *sound) { void CLSoundRaw_AssignBuffer(sound_t *sound, void *buffer, int bufferOffs, int length) { char *buf; CLSound_SetLength(sound, length); - sound->length = length; + sound->_length = length; buf = bufferOffs + (char *)buffer; // if(CLSound_GetWantsDesigned()) // CLSound_Signed2NonSigned(buf, length); - sound->buffer = buf; + sound->_buffer = buf; // if(sound->reversed && sound->sampleSize == 16) // ReverseBlock16(buf, length); } diff --git a/engines/cryo/cryolib.cpp b/engines/cryo/cryolib.cpp index 1a180b1fbf..5a0ce8b4d2 100644 --- a/engines/cryo/cryolib.cpp +++ b/engines/cryo/cryolib.cpp @@ -409,10 +409,10 @@ void CLFile_Write(file_t &handle, void *buffer, long *size) { ///// CLSound // base sound void CLSound_PrepareSample(sound_t *sound, int16 mode) { - sound->mode = mode; - sound->locked = 0; - sound->loopTimes = 0; - sound->reversed = 0; + sound->_mode = mode; + sound->_locked = 0; + sound->_loopTimes = 0; + sound->_reversed = false; sound->ff_32 = 0; sound->volume = 255; } diff --git a/engines/cryo/cryolib.h b/engines/cryo/cryolib.h index 75146bb478..58e6afb323 100644 --- a/engines/cryo/cryolib.h +++ b/engines/cryo/cryolib.h @@ -48,8 +48,6 @@ namespace Cryo { #define PLE16(p) ( (((byte*)(p))[1] << 8) | ((byte*)(p))[0] ) #define PLE32(p) ( (((byte*)(p))[3] << 24) | (((byte*)(p))[2] << 16) | (((byte*)(p))[1] << 8) | ((byte*)(p))[0] ) -typedef void *SndChannel; -typedef char *Handle; enum { fsFromStart = 1 }; @@ -104,11 +102,6 @@ struct color_t { }; typedef struct color_t color_t; -struct palette_t { - color_t colors[256]; -}; -typedef struct palette_t palette_t; - #pragma pack(push, 1) struct HNMHeader { int _signature; @@ -132,47 +125,42 @@ typedef struct HNMHeader HNMHeader; #pragma pack(pop) struct hnm_t { - int frame; - int ff_4; - file_t *file; + int _frameNum; + int ff_4; + file_t *_file; HNMHeader _header; - byte *work_buffer[2]; - byte *final_buffer; - byte *new_frame_buffer; - byte *old_frame_buffer; - byte *read_buffer; - byte *data_ptr; - color_t palette[256]; - - int16 can_loop; - - int16 ff_896; - int16 chunk_id; - int total_read; + byte *tmpBuffer[2]; + byte *finalBuffer; + byte *_newFrameBuffer; + byte *_oldFrameBuffer; + byte *_readBuffer; + byte *_dataPtr; + color_t _palette[256]; + + bool _canLoop; + int16 ff_896; + int16 _chunkId; + int _totalRead; }; typedef struct hnm_t hnm_t; -//struct filespec_t { -//char puff; -//}; - struct sound_t { - Handle sndHandle; - int16 headerLen; - long headerOffset; + char *sndHandle; + int16 _headerLen; + long _headerOffset; int16 ff_A; - char *buffer; + char *_buffer; int ff_16; int16 ff_1A; - float rate; - int16 sampleSize; - int length; - int16 mode; - volatile int16 locked; - long loopStart; - int16 loopTimes; - int16 reversed; + float _rate; + int16 _sampleSize; + int _length; + int16 _mode; + volatile int16 _locked; + long _loopStart; + int16 _loopTimes; + bool _reversed; int16 ff_32; int16 volume; }; @@ -334,7 +322,7 @@ void CLHNM_AllocMemory(hnm_t *hnm); void CLHNM_DeallocMemory(hnm_t *hnm); void CLHNM_Read(hnm_t *hnm, int size); void CLHNM_GiveTime(hnm_t *hnm); -void CLHNM_CanLoop(hnm_t *hnm, int16 can_loop); +void CLHNM_CanLoop(hnm_t *hnm, bool canLoop); void CLHNM_SelectBuffers(hnm_t *hnm); void CLHNM_ChangePalette(hnm_t *hnm); void CLHNM_Desentrelace(hnm_t *hnm); |