STDMETHODIMP_(void) CCMIAdapter::writeMixer(UInt8 index, UInt8 value) { if (value != mixerCache[index]) { mixerCache[index] = value; writeUInt8(REG_SBINDEX, index); writeUInt8(REG_SBDATA, value); } }
STDMETHODIMP_(NTSTATUS) CCMIAdapter::loadSBMixerFromMemory() { PAGED_CODE(); DBGPRINT(("CCMIAdapter[%p]::loadSBMixerFromMemory()", this)); UInt8 sbIndex[] = { 0x04, 0x0A, 0x22, 0x28, 0x2E, 0x30, 0x31, 0x32, 0x33, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3C, 0x3D, 0x3E, 0xF0 }; for (unsigned int i = 0; i<(sizeof(sbIndex)/sizeof(sbIndex[0]));i++) { writeUInt8(REG_SBINDEX, sbIndex[i]); writeUInt8(REG_SBDATA, mixerCache[sbIndex[i]]); } return STATUS_SUCCESS; }
inline void ByteEncoder::writeUInt16(uint16_t x) { if (endian_ == LittleEndian) { writeUInt8(uint8_t(x)); writeUInt8(uint8_t(x >> 8)); }
STDMETHODIMP_(UInt8) CCMIAdapter::readMixer(UInt8 index) { if (mixerCache[index] == 0xFF) { writeUInt8(REG_SBINDEX, index); mixerCache[index] = readUInt8(REG_SBDATA); } return mixerCache[index]; }
void BinaryOutput::endBits() { debugAssertM(m_beginEndBits == 1, "Not in beginBits...endBits"); if (m_bitPos > 0) { writeUInt8(m_bitString); } m_bitString = 0; m_bitPos = 0; m_beginEndBits = 0; }
void QPAGenerator::writeBlock(QFontEngineQPA::BlockTag tag, const QByteArray &data) { writeUInt16(tag); writeUInt16(0); // padding const int padSize = ((data.size() + 3) / 4) * 4 - data.size(); writeUInt32(data.size() + padSize); dev->write(data); for (int i = 0; i < padSize; ++i) writeUInt8(0); }
void BinaryOutput::writeStringEven(const char* s) { // +1 is because strlen doesn't count the null int len = strlen(s) + 1; reserveBytes(len); System::memcpy(m_buffer + m_pos, s, len); m_pos += len; // Pad with another NULL if ((len % 2) == 1) { writeUInt8(0); } }
void BinaryOutputStream::endBits() { debugAssertM(m_beginEndBits == 1, getNameStr() + ": beginBits/endBits mismatch"); if (m_bitPos > 0) { writeUInt8(m_bitString); } m_bitString = 0; m_bitPos = 0; m_beginEndBits = 0; }
void BinaryOutputStream::writeAlignedString(std::string const & s, int alignment) { int length = (int)s.length(); writeInt32(length); writeBytes(length, s.c_str()); int padding = (alignment - (length % alignment)) % alignment; if (padding > 0) { for (int i = 0; i < padding; ++i) writeUInt8(0); // zero not necessary but let's use it to keep things clean instead of calling skip(padding) } }
void BinaryOutput::writeBits(uint32 value, int numBits) { while (numBits > 0) { // Extract the current bit of value and // insert it into the current byte m_bitString |= (value & 1) << m_bitPos; ++m_bitPos; value = value >> 1; --numBits; if (m_bitPos > 7) { // We've reached the end of this byte writeUInt8(m_bitString); m_bitString = 0x00; m_bitPos = 0; } } }
void BinaryOutputStream::writeBits(int num_bits, uint32 value) { debugAssertM(m_beginEndBits == 1, getNameStr() + ": Can't call writeBits outside beginBits/endBits block"); while (num_bits > 0) { // Extract the current bit of value and insert it into the current byte m_bitString |= (value & 1) << m_bitPos; ++m_bitPos; value = value >> 1; --num_bits; if (m_bitPos > 7) { // We've reached the end of this byte writeUInt8(m_bitString); m_bitString = 0x00; m_bitPos = 0; } } }
void DataOutputStream::writeInt8(INT8 x) { writeUInt8((UINT8)x); }
void QPAGenerator::writeTaggedUInt8(QFontEngineQPA::HeaderTag tag, quint8 value) { writeUInt16(tag); writeUInt16(sizeof(value)); writeUInt8(value); }
uint32 NativeTexture::writeD3d(ostream &rw) { HeaderInfo header; header.build = version; uint32 writtenBytesReturn; if (platform != PLATFORM_D3D8 && platform != PLATFORM_D3D9) return 0; // Texture Native SKIP_HEADER(); // Struct { SKIP_HEADER(); bytesWritten += writeUInt32(platform, rw); bytesWritten += writeUInt32(filterFlags, rw); char buffer[32]; strncpy(buffer, name.c_str(), 32); rw.write(buffer, 32); strncpy(buffer, maskName.c_str(), 32); rw.write(buffer, 32); bytesWritten += 2*32; bytesWritten += writeUInt32(rasterFormat, rw); /* if(rasterFormat == RASTER_8888 && !hasAlpha || rasterFormat == RASTER_888 && hasAlpha) cout << "mismatch " << hex << rasterFormat << endl; */ if (platform == PLATFORM_D3D8) { bytesWritten += writeUInt32(hasAlpha, rw); } else { if (dxtCompression) { char fourcc[5] = "DXT0"; fourcc[3] += dxtCompression; rw.write(fourcc, 4); bytesWritten += 4; } else { // 0x15 or 0x16 bytesWritten += writeUInt32(0x16-hasAlpha, rw); } } bytesWritten += writeUInt16(width[0], rw); bytesWritten += writeUInt16(height[0], rw); bytesWritten += writeUInt8(depth, rw); bytesWritten += writeUInt8(mipmapCount, rw); bytesWritten += writeUInt8(0x4, rw); if (platform == PLATFORM_D3D8) bytesWritten += writeUInt8(dxtCompression, rw); else bytesWritten += writeUInt8( (dxtCompression ? 8 : 0) | hasAlpha, rw); /* Palette */ if (rasterFormat & RASTER_PAL8 || rasterFormat & RASTER_PAL4) { uint32 paletteSize = 1 << depth; rw.write(reinterpret_cast <char *> (palette), paletteSize*4*sizeof(uint8)); bytesWritten += paletteSize*4*sizeof(uint8); } /* Texels */ for (uint32 i = 0; i < mipmapCount; i++) { /* uint32 dataSize = width[i]*height[i]; if (!dxtCompression) dataSize *= depth/8; else if (dxtCompression == 1) dataSize /= 2; */ uint32 dataSize = dataSizes[i]; bytesWritten += writeUInt32(dataSize, rw); rw.write(reinterpret_cast <char *> (&texels[i][0]), dataSize*sizeof(uint8)); bytesWritten += dataSize*sizeof(uint8); } WRITE_HEADER(CHUNK_STRUCT); } bytesWritten += writtenBytesReturn; // Extension { SKIP_HEADER(); WRITE_HEADER(CHUNK_EXTENSION); } bytesWritten += writtenBytesReturn; WRITE_HEADER(CHUNK_TEXTURENATIVE); return bytesWritten; }
STDMETHODIMP_(void) CCMIAdapter::clearUInt8Bit(UInt8 reg, UInt8 flag) { writeUInt8(reg, readUInt8(reg) & ~flag); }
STDMETHODIMP_(void) CCMIAdapter::setUInt8Bit(UInt8 reg, UInt8 flag) { writeUInt8(reg, readUInt8(reg) | flag); }