本文整理汇总了C++中READ_LE_UINT32函数的典型用法代码示例。如果您正苦于以下问题:C++ READ_LE_UINT32函数的具体用法?C++ READ_LE_UINT32怎么用?C++ READ_LE_UINT32使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了READ_LE_UINT32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: READ_LE_UINT32
/**
* Initialize a multi-part object using a list of images to init
* each object piece. One object is created for each image in the list.
* All objects are given the same palette as the first image. A pointer
* to the first (master) object created is returned.
* @param pInitTbl Pointer to multi-object initialisation table
*/
OBJECT *MultiInitObject(const MULTI_INIT *pInitTbl) {
OBJ_INIT obj_init; // object init table
OBJECT *pFirst, *pObj; // object pointers
FRAME *pFrame; // list of images for the multi-part object
if (FROM_LE_32(pInitTbl->hMulFrame)) {
// we have a frame handle
pFrame = (FRAME *)LockMem(FROM_LE_32(pInitTbl->hMulFrame));
obj_init.hObjImg = READ_LE_UINT32(pFrame); // first objects shape
} else { // this must be a animation list for a NULL object
pFrame = NULL;
obj_init.hObjImg = 0; // first objects shape
}
// init the object init table
obj_init.objFlags = (int)FROM_LE_32(pInitTbl->mulFlags); // all objects have same flags
obj_init.objID = (int)FROM_LE_32(pInitTbl->mulID); // all objects have same ID
obj_init.objX = (int)FROM_LE_32(pInitTbl->mulX); // all objects have same X ani pos
obj_init.objY = (int)FROM_LE_32(pInitTbl->mulY); // all objects have same Y ani pos
obj_init.objZ = (int)FROM_LE_32(pInitTbl->mulZ); // all objects have same Z pos
// create and init the first object
pObj = pFirst = InitObject(&obj_init);
if (pFrame) {
// if we have any animation frames
pFrame++;
while (READ_LE_UINT32(pFrame) != 0) {
// set next objects shape
obj_init.hObjImg = READ_LE_UINT32(pFrame);
// create next object and link to previous
pObj = pObj->pSlave = InitObject(&obj_init);
pFrame++;
}
}
// null end of list for final object
pObj->pSlave = NULL;
// return master object
return pFirst;
}
示例2: READ_LE_UINT32
void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, uint sound, int pan, int vol, bool loop) {
byte *buffer, flags;
uint16 compType;
int blockAlign, rate;
int size = READ_LE_UINT32(soundData + 4);
Common::MemoryReadStream stream(soundData, size);
if (!Audio::loadWAVFromStream(stream, size, rate, flags, &compType, &blockAlign)) {
error("playSoundData: Not a valid WAV data");
}
// The Feeble Files originally used DirectSound, which specifies volume
// and panning differently than ScummVM does, using a logarithmic scale
// rather than a linear one.
//
// Volume is a value between -10,000 and 0.
// Panning is a value between -10,000 and 10,000.
//
// In both cases, the -10,000 represents -100 dB. When panning, only
// one speaker's volume is affected - just like in ScummVM - with
// negative values affecting the left speaker, and positive values
// affecting the right speaker. Thus -10,000 means the left speaker is
// silent.
int v, p;
vol = CLIP(vol, -10000, 0);
pan = CLIP(pan, -10000, 10000);
if (vol) {
v = (int)((double)Audio::Mixer::kMaxChannelVolume * pow(10.0, (double)vol / 2000.0) + 0.5);
} else {
v = Audio::Mixer::kMaxChannelVolume;
}
if (pan < 0) {
p = (int)(255.0 * pow(10.0, (double)pan / 2000.0) + 127.5);
} else if (pan > 0) {
p = (int)(255.0 * pow(10.0, (double)pan / -2000.0) - 127.5);
} else {
p = 0;
}
if (loop == true)
flags |= Audio::Mixer::FLAG_LOOP;
if (compType == 2) {
Audio::AudioStream *sndStream = Audio::makeADPCMStream(&stream, size, Audio::kADPCMMS, rate, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign);
buffer = (byte *)malloc(size * 4);
size = sndStream->readBuffer((int16*)buffer, size * 2);
size *= 2; // 16bits.
delete sndStream;
} else {
buffer = (byte *)malloc(size);
memcpy(buffer, soundData + stream.pos(), size);
}
_mixer->playRaw(handle, buffer, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE, -1, v, p);
}
示例3: READ_LE_UINT32
void InputPersistenceBlock::read(uint &value) {
if (checkMarker(UINT_MARKER)) {
value = READ_LE_UINT32(_iter);
_iter += 4;
} else {
value = 0;
}
}
示例4: convertSJIStoUTF32
uint32 convertSJIStoUTF32(uint8 fB, uint8 sB) {
// For some reason iconv will refuse "0x81 0xAD" as valid
// SJIS sequence, even though it is "FULLWIDTH APOSTROPHE",
// thus we will short circuit iconv and convert it ourself
// here.
if (fB == 0x81 && sB == 0xAD)
return 0x0000FF07;
// SJIS uses "YEN SIGN" instead of "REVERSE SOLIDUS"
else if (fB == 0x5C && sB == 0x00)
return 0x000000A5;
// SJIS uses "OVERLINE" instead of "TILDE"
else if (fB == 0x7E && sB == 0x00)
return 0x0000203E;
char inBuf[3];
inBuf[0] = fB;
inBuf[1] = sB;
inBuf[2] = 0;
char outBuf[3 * sizeof(uint32)];
memset(outBuf, 0, sizeof(outBuf));
size_t inBufSize = ((fB >= 0x81 && fB <= 0x9F) || (fB >= 0xE0 && fB <= 0xEF)) ? 3 : 2;
size_t outBufSize = sizeof(outBuf);
#ifdef ICONV_USES_CONST
const char *inBufWrap = inBuf;
#else
char *inBufWrap = inBuf;
#endif
char *outBufWrap = outBuf;
if (iconv(confSetup, &inBufWrap, &inBufSize, &outBufWrap, &outBufSize) == (size_t)-1)
return (uint32)-1;
const uint32 ret = READ_LE_UINT32(outBuf);
// According to http://www.unicode.org/reports/tr19/tr19-9.html it is possible
// that a "zero width no-break space" is added as first character (probably
// to be consistent with the "byte order mark"). In case any iconv implementation
// does that, we just skip over that bit.
if (ret == 0x0000FEFF)
return READ_LE_UINT32(outBuf + 4);
else
return ret;
}
示例5: load
void load(uint32 offset) {
byte *item = getData(offset);
uint32 subItemOffset;
x1 = READ_LE_UINT16(item + 0);
y1 = READ_LE_UINT16(item + 2);
x2 = READ_LE_UINT16(item + 4);
y2 = READ_LE_UINT16(item + 6);
subRectListCount = READ_LE_UINT32(item + 8);
subRectListOffset = READ_LE_UINT32(item + 12);
subItemOffset = subRectListOffset;
for (uint32 j = 0; j < subRectListCount; j++) {
SubRectItem subRectItem;
subRectItem.load(subItemOffset);
subItemOffset += 16;
subRectItems.push_back(subRectItem);
}
}
示例6: READ_LE_UINT32
void GfxPicture::drawSci11Vga() {
byte *inbuffer = _resource->data;
int size = _resource->size;
int priorityBandsCount = inbuffer[3];
int has_cel = inbuffer[4];
int vector_dataPos = READ_LE_UINT32(inbuffer + 16);
int vector_size = size - vector_dataPos;
int palette_data_ptr = READ_LE_UINT32(inbuffer + 28);
int cel_headerPos = READ_LE_UINT32(inbuffer + 32);
int cel_RlePos = READ_LE_UINT32(inbuffer + cel_headerPos + 24);
int cel_LiteralPos = READ_LE_UINT32(inbuffer + cel_headerPos + 28);
Palette palette;
// Header
// [headerSize:WORD] [unknown:BYTE] [priorityBandCount:BYTE] [hasCel:BYTE] [unknown:BYTE]
// [unknown:WORD] [unknown:WORD] [unknown:WORD] [unknown:WORD] [unknown:WORD]
// Offset 16
// [vectorDataOffset:DWORD] [unknown:DWORD] [unknown:DWORD] [paletteDataOffset:DWORD]
// Offset 32
// [celHeaderOffset:DWORD] [unknown:DWORD]
// [priorityBandData:WORD] * priorityBandCount
// [priority:BYTE] [unknown:BYTE]
// priority bands are supposed to be 14 for sci1.1 pictures
assert(priorityBandsCount == 14);
if (_addToFlag) {
_priority = inbuffer[40 + priorityBandsCount * 2] & 0xF;
}
// display Cel-data
if (has_cel) {
// Create palette and set it
_palette->createFromData(inbuffer + palette_data_ptr, size - palette_data_ptr, &palette);
_palette->set(&palette, true);
drawCelData(inbuffer, size, cel_headerPos, cel_RlePos, cel_LiteralPos, 0, 0, 0);
}
// process vector data
drawVectorData(inbuffer + vector_dataPos, vector_size);
// Set priority band information
_ports->priorityBandsInitSci11(inbuffer + 40);
}
示例7: memcpy
void KeyframeAnim::loadBinary(const char *data, int len) {
// First four bytes are the FYEK Keyframe identifier code
// Next 36 bytes are the filename
if (gDebugLevel == DEBUG_NORMAL || gDebugLevel == DEBUG_ALL) {
char filebuf[37];
memcpy(filebuf, data + 4, 36);
filebuf[36] = 0;
printf("Loading Keyframe '%s'.", filebuf);
}
// Next four bytes are the flags
_flags = READ_LE_UINT32(data + 40);
// Next four bytes are a duplicate of _numJoints (?)
// Next four bytes are the type
_type = READ_LE_UINT32(data + 48);
// Next four bytes are the frames per second
_fps = get_float(data + 52);
// Next four bytes are the number of frames
_numFrames = READ_LE_UINT32(data + 56);
// Next four bytes are the number of joints
_numJoints = READ_LE_UINT32(data + 60);
// Next four bytes are unknown (?)
// Next four bytes are the number of markers
_numMarkers = READ_LE_UINT32(data + 68);
_markers = new Marker[_numMarkers];
for (int i = 0; i < _numMarkers; i++) {
_markers[i].frame = get_float(data + 72 + 4 * i);
_markers[i].val = READ_LE_UINT32(data + 104 + 4 * i);
}
_nodes = new KeyframeNode *[_numJoints];
for (int i = 0; i < _numJoints; i++)
_nodes[i] = NULL;
const char *dataEnd = data + len;
// The first 136 bytes are for the header, this was originally
// listed as 180 bytes since the first operation is usually a
// "null" key, however ma_card_hold.key showed that this is
// not always the case so we should not skip this operation
data += 136;
while (data < dataEnd) {
int nodeNum;
// The first 32 bytes (of a keyframe) are the name handle
// The next four bytes are the node number identifier
nodeNum = READ_LE_UINT32(data + 32);
// Because of the issue above ma_card_hold.key used to crash
// at this part without checking to make sure nodeNum is a
// valid number, we'll leave this in just in case something
// else is still wrong but it should now load correctly in
// all cases
if (nodeNum >= _numJoints) {
if (gDebugLevel == DEBUG_WARN || gDebugLevel == DEBUG_ALL) {
warning("A node number was greater than the maximum number of nodes (%d/%d)", nodeNum, _numJoints);
}
return;
}
_nodes[nodeNum] = new KeyframeNode;
_nodes[nodeNum]->loadBinary(data);
}
}
示例8: read
uint32 Script::readUint32() {
byte v[4] = {0, 0, 0, 0};
uint32 n;
n = read(v, 4);
assert(n == 4);
return READ_LE_UINT32(v);
}
示例9: playMidi
void Sound::playMidi(int16_t objKey, int index) {
if (index >= 0 && index < kMusicKeyPathsTableSize) {
int16_t sndKey = _res->getKeyFromPath(_res->_musicKeyPathsTable[index]);
const uint8_t *p_sndinfo = _res->getData(kResType_SND, sndKey, "SNDINFO");
if (p_sndinfo && READ_LE_UINT32(p_sndinfo + 32) == 2) {
// printf("play.midi '%s'\n", (const char *)p_sndinfo);
}
}
}
示例10: error
int32 SaveGame::readLESint32() {
if (_saving)
error("SaveGame::readBlock called when storing a savegame");
if (_currentSection == 0)
error("Tried to read a block without starting a section");
int32 data = (int32)READ_LE_UINT32(&_sectionBuffer[_sectionPtr]);
_sectionPtr += 4;
return data;
}
示例11: READ_LE_UINT32
void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, uint sound, int pan, int vol, bool loop) {
int size = READ_LE_UINT32(soundData + 4) + 8;
Common::SeekableReadStream *stream = new Common::MemoryReadStream(soundData, size);
Audio::RewindableAudioStream *sndStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
convertVolume(vol);
convertPan(pan);
_mixer->playStream(Audio::Mixer::kSFXSoundType, handle, Audio::makeLoopingAudioStream(sndStream, loop ? 0 : 1), -1, vol, pan);
}
示例12: Object
Bitmap::Bitmap(const char *fname, const char *data, int len) :
Object() {
_fname = fname;
if (len < 8 || memcmp(data, "BM F\0\0\0", 8) != 0) {
if (gDebugLevel == DEBUG_BITMAPS || gDebugLevel == DEBUG_ERROR || gDebugLevel == DEBUG_ALL)
error("Invalid magic loading bitmap");
}
strcpy(_filename, fname);
int codec = READ_LE_UINT32(data + 8);
// _paletteIncluded = READ_LE_UINT32(data + 12);
_numImages = READ_LE_UINT32(data + 16);
_x = READ_LE_UINT32(data + 20);
_y = READ_LE_UINT32(data + 24);
// _transparentColor = READ_LE_UINT32(data + 28);
_format = READ_LE_UINT32(data + 32);
// _numBits = READ_LE_UINT32(data + 36);
// _blueBits = READ_LE_UINT32(data + 40);
// _greenBits = READ_LE_UINT32(data + 44);
// _redBits = READ_LE_UINT32(data + 48);
// _blueShift = READ_LE_UINT32(data + 52);
// _greenShift = READ_LE_UINT32(data + 56);
// _redShift = READ_LE_UINT32(data + 60);
_width = READ_LE_UINT32(data + 128);
_height = READ_LE_UINT32(data + 132);
_currImage = 1;
_data = new char *[_numImages];
int pos = 0x88;
for (int i = 0; i < _numImages; i++) {
_data[i] = new char[2 * _width * _height];
if (codec == 0) {
memcpy(_data[i], data + pos, 2 * _width * _height);
pos += 2 * _width * _height + 8;
} else if (codec == 3) {
int compressed_len = READ_LE_UINT32(data + pos);
decompress_codec3(data + pos + 4, _data[i]);
pos += compressed_len + 12;
}
#ifdef SYSTEM_BIG_ENDIAN
if (_format == 1)
for (int j = 0; j < _width * _height; ++j) {
((uint16 *)_data[i])[j] = SWAP_BYTES_16(((uint16 *)_data[i])[j]);
}
#endif
}
g_driver->createBitmap(this);
}
示例13: MoverProcessHelper
static void MoverProcessHelper(int X, int Y, int id, PMOVER pMover) {
const FILM *pfilm;
const MULTI_INIT *pmi;
const FRAME *pFrame;
IMAGE *pim;
assert(BgPal()); // Can't start actor without a background palette
assert(pMover->walkReels[0][FORWARD]); // Starting actor process without walk reels
InitMover(pMover);
InitialPathChecks(pMover, X, Y);
pfilm = (const FILM *)LockMem(pMover->walkReels[0][FORWARD]);
pmi = (const MULTI_INIT *)LockMem(FROM_LE_32(pfilm->reels[0].mobj));
//---
pFrame = (const FRAME *)LockMem(FROM_LE_32(pmi->hMulFrame));
// get pointer to image
pim = (IMAGE *)LockMem(READ_LE_UINT32(pFrame)); // handle to image
pim->hImgPal = TO_LE_32(BgPal());
//---
pMover->actorObj = MultiInitObject(pmi);
/**/ assert(pMover->actorID == id);
pMover->actorID = id;
// add it to display list
MultiInsertObject(GetPlayfieldList(FIELD_WORLD), pMover->actorObj);
storeActorReel(id, NULL, 0, pMover->actorObj, 0, 0, 0);
InitStepAnimScript(&pMover->actorAnim, pMover->actorObj, FROM_LE_32(pfilm->reels[0].script), ONE_SECOND / FROM_LE_32(pfilm->frate));
pMover->stepCount = 0;
MultiSetAniXY(pMover->actorObj, pMover->objX, pMover->objY);
// If no path, just use first path in the scene
if (pMover->hCpath != NOPOLY)
SetMoverZ(pMover, pMover->objY, GetPolyZfactor(pMover->hCpath));
else
SetMoverZ(pMover, pMover->objY, GetPolyZfactor(FirstPathPoly()));
// Make him the right size
SetMoverStanding(pMover);
//**** if added 18/11/94, am
if (X != MAGICX && Y != MAGICY) {
HideMover(pMover, 0); // Allows a play to come in before this appears
pMover->bHidden = false; // ...but don't stay hidden
}
pMover->bActive = true;
}
示例14: get_float
void KeyframeAnim::KeyframeEntry::loadBinary(const char *data) {
_frame = get_float(data);
_flags = READ_LE_UINT32(data + 4);
_pos = Math::Vector3d::get_vector3d(data + 8);
_pitch = get_float(data + 20);
_yaw = get_float(data + 24);
_roll = get_float(data + 28);
_dpos = Math::Vector3d::get_vector3d(data + 32);
_dpitch = get_float(data + 44);
_dyaw = get_float(data + 48);
_droll = get_float(data + 52);
}
示例15: debugC
void CDROM::startTrack(const char *trackname) {
byte *curPtr, *matchPtr;
if (!_LICbuffer)
return;
debugC(1, DEBUG_MUSIC, "startTrack(%s)", trackname);
matchPtr = 0;
curPtr = _LICbuffer;
for (int i = 0; i < _numTracks; i++) {
if (!scumm_stricmp((char *)curPtr, trackname)) {
matchPtr = curPtr;
break;
}
curPtr += 22;
}
if (!matchPtr) {
error("Track %s not found", trackname);
return;
}
strcpy(_curTrack, trackname);
stopPlaying();
while (getTrackPos() != -1);
uint32 start, end;
start = READ_LE_UINT32(matchPtr + 12);
end = READ_LE_UINT32(matchPtr + 16);
play(start, end);
_startTime = _vm->_util->getTimeKey();
_trackStop = _startTime + (end - start + 1 + 150) * 40 / 3;
}