diff options
Diffstat (limited to 'src/emu/rendfont.cpp')
-rw-r--r-- | src/emu/rendfont.cpp | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/emu/rendfont.cpp b/src/emu/rendfont.cpp index aa43342958c..9adbbe2dc33 100644 --- a/src/emu/rendfont.cpp +++ b/src/emu/rendfont.cpp @@ -22,7 +22,7 @@ #include <cstring> -const uint64_t render_font::CACHED_BDF_HASH_SIZE; +const u64 render_font::CACHED_BDF_HASH_SIZE; //************************************************************************** // INLINE FUNCTIONS @@ -234,11 +234,11 @@ void render_font::char_expand(char32_t chnum, glyph &gl) // extract the data const char *ptr = gl.rawdata; - uint8_t accum = 0, accumbit = 7; + u8 accum = 0, accumbit = 7; for (int y = 0; y < gl.bmheight; y++) { int desty = y + m_height_cmd + m_yoffs_cmd - gl.yoffs - gl.bmheight; - uint32_t *dest = (desty >= 0 && desty < m_height_cmd) ? &gl.bitmap.pix32(desty, 0) : nullptr; + u32 *dest = (desty >= 0 && desty < m_height_cmd) ? &gl.bitmap.pix32(desty, 0) : nullptr; { for (int x = 0; x < gl.bmwidth; x++) { @@ -283,11 +283,11 @@ void render_font::char_expand(char32_t chnum, glyph &gl) // extract the data const char *ptr = gl.rawdata; - uint8_t accum = 0, accumbit = 7; + u8 accum = 0, accumbit = 7; for (int y = 0; y < gl.bmheight; y++) { int desty = y + m_height + m_yoffs - gl.yoffs - gl.bmheight; - uint32_t *dest = (desty >= 0 && desty < m_height) ? &gl.bitmap.pix32(desty) : nullptr; + u32 *dest = (desty >= 0 && desty < m_height) ? &gl.bitmap.pix32(desty) : nullptr; // text format if (m_format == FF_TEXT) @@ -454,7 +454,7 @@ float render_font::utf8string_width(float height, float aspect, const char *utf8 // loop over the string and accumulate widths int count; - int32_t totwidth = 0; + s32 totwidth = 0; for (std::size_t offset = 0U; offset < length; offset += unsigned(count)) { char32_t uchar; @@ -490,12 +490,12 @@ bool render_font::load_cached_bdf(const char *filename) m_rawdata.resize(m_rawsize + 1); // read the first chunk - uint32_t bytes = file.read(&m_rawdata[0], std::min(CACHED_BDF_HASH_SIZE, m_rawsize)); + u32 bytes = file.read(&m_rawdata[0], std::min(CACHED_BDF_HASH_SIZE, m_rawsize)); if (bytes != std::min(CACHED_BDF_HASH_SIZE, m_rawsize)) return false; // has the chunk - uint32_t hash = core_crc32(0, (const uint8_t *)&m_rawdata[0], bytes) ^ (uint32_t)m_rawsize; + u32 hash = core_crc32(0, (const u8 *)&m_rawdata[0], bytes) ^ u32(m_rawsize); // create the cached filename, changing the 'F' to a 'C' on the extension std::string cachedname(filename); @@ -523,7 +523,7 @@ bool render_font::load_cached_bdf(const char *filename) // read in the rest of the font if (bytes < m_rawsize) { - uint32_t read = file.read(&m_rawdata[bytes], m_rawsize - bytes); + u32 read = file.read(&m_rawdata[bytes], m_rawsize - bytes); if (read != m_rawsize - bytes) { m_rawdata.clear(); @@ -664,26 +664,26 @@ bool render_font::load_bdf() // load_cached - load a font in cached format //------------------------------------------------- -bool render_font::load_cached(emu_file &file, uint32_t hash) +bool render_font::load_cached(emu_file &file, u32 hash) { // get the file size - uint64_t filesize = file.size(); + u64 filesize = file.size(); // first read the header - uint8_t header[CACHED_HEADER_SIZE]; - uint32_t bytes_read = file.read(header, CACHED_HEADER_SIZE); + u8 header[CACHED_HEADER_SIZE]; + u32 bytes_read = file.read(header, CACHED_HEADER_SIZE); if (bytes_read != CACHED_HEADER_SIZE) return false; // validate the header if (header[0] != 'f' || header[1] != 'o' || header[2] != 'n' || header[3] != 't') return false; - if (hash && (header[4] != (uint8_t)(hash >> 24) || header[5] != (uint8_t)(hash >> 16) || header[6] != (uint8_t)(hash >> 8) || header[7] != (uint8_t)hash)) + if (hash && (header[4] != u8(hash >> 24) || header[5] != u8(hash >> 16) || header[6] != u8(hash >> 8) || header[7] != u8(hash))) return false; m_height = (header[8] << 8) | header[9]; m_scale = 1.0f / (float)m_height; - m_yoffs = (int16_t)((header[10] << 8) | header[11]); - uint32_t numchars = (header[12] << 24) | (header[13] << 16) | (header[14] << 8) | header[15]; + m_yoffs = s16((header[10] << 8) | header[11]); + u32 numchars = (header[12] << 24) | (header[13] << 16) | (header[14] << 8) | header[15]; if (filesize - CACHED_HEADER_SIZE < numchars * CACHED_CHAR_SIZE) return false; @@ -697,10 +697,10 @@ bool render_font::load_cached(emu_file &file, uint32_t hash) } // extract the data from the data - uint64_t offset = numchars * CACHED_CHAR_SIZE; + u64 offset = numchars * CACHED_CHAR_SIZE; for (int chindex = 0; chindex < numchars; chindex++) { - const uint8_t *info = reinterpret_cast<uint8_t *>(&m_rawdata[chindex * CACHED_CHAR_SIZE]); + const u8 *info = reinterpret_cast<u8 *>(&m_rawdata[chindex * CACHED_CHAR_SIZE]); int chnum = (info[0] << 8) | info[1]; // if we don't have a subtable yet, make one @@ -710,8 +710,8 @@ bool render_font::load_cached(emu_file &file, uint32_t hash) // fill in the entry glyph &gl = m_glyphs[chnum / 256][chnum % 256]; gl.width = (info[2] << 8) | info[3]; - gl.xoffs = (int16_t)((info[4] << 8) | info[5]); - gl.yoffs = (int16_t)((info[6] << 8) | info[7]); + gl.xoffs = s16((info[4] << 8) | info[5]); + gl.yoffs = s16((info[6] << 8) | info[7]); gl.bmwidth = (info[8] << 8) | info[9]; gl.bmheight = (info[10] << 8) | info[11]; gl.rawdata = &m_rawdata[offset]; @@ -735,7 +735,7 @@ bool render_font::load_cached(emu_file &file, uint32_t hash) // save_cached - save a font in cached format //------------------------------------------------- -bool render_font::save_cached(const char *filename, uint32_t hash) +bool render_font::save_cached(const char *filename, u32 hash) { osd_printf_warning("Generating cached BDF font...\n"); @@ -760,13 +760,13 @@ bool render_font::save_cached(const char *filename, uint32_t hash) try { // allocate an array to hold the character data - std::vector<uint8_t> chartable(numchars * CACHED_CHAR_SIZE, 0); + std::vector<u8> chartable(numchars * CACHED_CHAR_SIZE, 0); // allocate a temp buffer to compress into - std::vector<uint8_t> tempbuffer(65536); + std::vector<u8> tempbuffer(65536); // write the header - uint8_t *dest = &tempbuffer[0]; + u8 *dest = &tempbuffer[0]; *dest++ = 'f'; *dest++ = 'o'; *dest++ = 'n'; @@ -784,7 +784,7 @@ bool render_font::save_cached(const char *filename, uint32_t hash) *dest++ = numchars >> 8; *dest++ = numchars & 0xff; assert(dest == &tempbuffer[CACHED_HEADER_SIZE]); - uint32_t bytes_written = file.write(&tempbuffer[0], CACHED_HEADER_SIZE); + u32 bytes_written = file.write(&tempbuffer[0], CACHED_HEADER_SIZE); if (bytes_written != dest - &tempbuffer[0]) throw emu_fatalerror("Error writing cached file"); @@ -805,14 +805,14 @@ bool render_font::save_cached(const char *filename, uint32_t hash) { // write the data to the tempbuffer dest = &tempbuffer[0]; - uint8_t accum = 0; - uint8_t accbit = 7; + u8 accum = 0; + u8 accbit = 7; // bit-encode the character data for (int y = 0; y < gl.bmheight; y++) { int desty = y + m_height + m_yoffs - gl.yoffs - gl.bmheight; - const uint32_t *src = (desty >= 0 && desty < m_height) ? &gl.bitmap.pix32(desty) : nullptr; + const u32 *src = (desty >= 0 && desty < m_height) ? &gl.bitmap.pix32(desty) : nullptr; for (int x = 0; x < gl.bmwidth; x++) { if (src != nullptr && rgb_t(src[x]).a() != 0) |