void initFontReader(MAHandle file) { sData = new unsigned char[BUFFER_SIZE]; if(!sData) maPanic(0, "Not enough memory for initialization of MAUI::Font"); sFile = file; sFileSize = maGetDataSize(sFile); sBufPos = sFilePos = 0; readMoreData(); }
unsigned char readByte() { unsigned char b; if(sBufPos>=BUFFER_SIZE) readMoreData(); b = sData[sBufPos]; sFilePos++; sBufPos++; return b; }
unsigned int readInt() { unsigned int ret = 0; if(sBufPos+3>=BUFFER_SIZE) readMoreData(); for(int i = 0; i < 4; i++) { unsigned char b; b = sData[sBufPos+i]; ret |= ((unsigned int)b)<<(i<<3); } sFilePos+=4; sBufPos+=4; return ret; }
unsigned short readShort() { unsigned short ret = 0; if(sBufPos+1>=BUFFER_SIZE) readMoreData(); /* if(sBufPos==43) { int a = 2; } */ for(int i = 0; i < 2; i++) { unsigned char b; b = sData[sBufPos+i]; ret |= ((unsigned short)b)<<(i<<3); } sFilePos+=2; sBufPos+=2; return ret; }
unsigned short readShort() { unsigned short ret = 0; if(sBufPos+1>=BUFFER_SIZE) { readMoreData(); } // TODO: Document why commented out or delete. /* if(sBufPos==43) { int a = 2; } */ for(int i = 0; i < 2; i++) { unsigned char b; b = sData[sBufPos+i]; ret |= ((unsigned short)b)<<(i<<3); } sFilePos+=2; sBufPos+=2; return ret; }