/*! * Writes a signed byte in a file stream. */ void lib3ds_io_write_intb(Lib3dsIo *io, int8_t b) { assert(io); if (lib3ds_io_write(io, &b, 1) != 1) { lib3ds_io_write_error(io); } }
/*! * Writes a zero-terminated string into a file stream. */ void lib3ds_io_write_string(Lib3dsIo *io, const char *s) { size_t len; assert(io && s); len = strlen(s); if (lib3ds_io_write(io, s, len + 1) != len +1) { lib3ds_io_write_error(io); } }
/*! * Writes a signed word into a little endian file stream. */ void lib3ds_io_write_intw(Lib3dsIo *io, int16_t w) { uint8_t b[2]; assert(io); b[1] = ((uint16_t)w & 0xFF00) >> 8; b[0] = ((uint16_t)w & 0x00FF); if (lib3ds_io_write(io, b, 2) != 2) { lib3ds_io_write_error(io); } }
/*! * Writes a word into a little endian file stream. */ void lib3ds_io_write_word(Lib3dsIo *io, uint16_t w) { uint8_t b[2]; assert(io); b[1] = (uint8_t)((w & 0xFF00) >> 8); b[0] = (uint8_t)(w & 0x00FF); if (lib3ds_io_write(io, b, 2) != 2) { lib3ds_io_write_error(io); } }
/*! * Writes a signed dword into a little endian file stream. */ void lib3ds_io_write_intd(Lib3dsIo *io, int32_t d) { uint8_t b[4]; assert(io); b[3] = (uint8_t)(((uint32_t)d & 0xFF000000) >> 24); b[2] = (uint8_t)(((uint32_t)d & 0x00FF0000) >> 16); b[1] = (uint8_t)(((uint32_t)d & 0x0000FF00) >> 8); b[0] = (uint8_t)(((uint32_t)d & 0x000000FF)); if (lib3ds_io_write(io, b, 4) != 4) { lib3ds_io_write_error(io); } }
/*! * Writes a float into a little endian file stream. */ void lib3ds_io_write_float(Lib3dsIo *io, float l) { uint8_t b[4]; Lib3dsDwordFloat d; assert(io); d.float_value = l; b[3] = (uint8_t)(((uint32_t)d.dword_value & 0xFF000000) >> 24); b[2] = (uint8_t)(((uint32_t)d.dword_value & 0x00FF0000) >> 16); b[1] = (uint8_t)(((uint32_t)d.dword_value & 0x0000FF00) >> 8); b[0] = (uint8_t)(((uint32_t)d.dword_value & 0x000000FF)); if (lib3ds_io_write(io, b, 4) != 4) { lib3ds_io_write_error(io); } }