1 #pragma once 2 3 enum SREC_TYPE{ 4 SREC_TYPE_S0 = 1,//Header, 16bi "0000" 5 SREC_TYPE_S1,//Data, 16-bit address 6 SREC_TYPE_S2,//Data, 24-bit address 7 SREC_TYPE_S3,//Data, 32-bit address 8 SREC_TYPE_S5,//Count, 16-bit count 9 SREC_TYPE_S6 //Count, 24-bit count 10 }; 11 12 #define SREC_MAX_DATA_SIZE 32 13 14 typedef struct { 15 CString name; 16 CArray<ULONG> size_table; 17 ULONG total_size; 18 USHORT write_res_index; 19 }file_info; 20 21 class binary_resource_gen : public resource_gen 22 { 23 public: 24 binary_resource_gen(studiox_project *proj, BOOL file_format); 25 ~binary_resource_gen(); 26 27 public: 28 BOOL GenerateBinaryFile(int display); 29 BOOL GenerateBinaryData(); 30 void InitResource(); 31 void DestroyResource(); 32 void WritePixelmapBlock(res_info* info, USHORT map_id, USHORT output_map_id, USHORT theme_id, int frame_id = 0); 33 void WriteFontBlock(res_info *info, USHORT font_id, USHORT theme_id); 34 void WriteStandaloneResHeader(); SetDisplay(int display)35 void SetDisplay(int display) { m_display = display; }; 36 void MakeFileDictionary(void); 37 void DestroyFileDictionay(void); 38 file_info* FindFileInfo(CArray<file_info*>* file_dict, CString name); GetResourceHeaderSize()39 static INT GetResourceHeaderSize(){ return GX_RESOURCE_HEADER_SIZE; }; GetThemeHeaderSize()40 static INT GetThemeHeaderSize(){ return GX_THEME_HEADER_SIZE; }; GetColorHeaderSize()41 static INT GetColorHeaderSize(){ return GX_COLOR_HEADER_SIZE; }; GetPaletteHeaderSize()42 static INT GetPaletteHeaderSize(){ return GX_PALETTE_HEADER_SIZE; }; 43 static INT GetFontHeaderSize(); GetPageHeaderSize()44 static INT GetPageHeaderSize(){ return GX_PAGE_HEADER_SIZE; }; 45 static INT GetGlyphHeaderSize(); 46 static INT GetKerningGlyphHeaderSize(); 47 static INT GetPixelmapHeaderSize(); GetStringHeaderSize()48 static INT GetStringHeaderSize(){ return GX_STRING_HEADER_SIZE; }; GetLanguageHeaderSize()49 static INT GetLanguageHeaderSize(){ return GX_LANGUAGE_HEADER_SIZE; }; 50 51 protected: 52 ULONG GetThemeDataSize(SHORT theme_count); 53 ULONG GetThemeDataSize(ULONG written_size, USHORT theme_id); 54 ULONG GetColorBlockSize(USHORT theme_id); 55 ULONG GetPaletteBlockSize(USHORT theme_id); 56 ULONG GetFontBlockSize(ULONG written_size, USHORT theme_id, SHORT font_count); 57 ULONG GetPixelmapBlockSize(ULONG written_size, USHORT theme_id, SHORT map_id, SHORT frame_id); 58 ULONG GetOnePixelmapDataSize(ULONG written_size, res_info *info, USHORT theme_id, INT frame_id, USHORT outmap_id); 59 ULONG GetFontDataSize(ULONG written_size, res_info *info, USHORT theme_id, USHORT font_id); 60 ULONG GetFontDataOffset(USHORT font_id, USHORT theme_id); 61 ULONG GetPixelmapDataOffset(USHORT map_id, USHORT frame_id, USHORT theme_id); 62 ULONG GetGlyphDataSize(ULONG written_size, const GX_FONT *font, INT glyph_index); 63 USHORT GetGlyphKerningTableSize(const GX_FONT *font, INT glyph_index); 64 ULONG GetPageDataSize(ULONG written_size, const GX_FONT *font); 65 ULONG GetStringDataSize(); 66 ULONG GetStringDataSize(USHORT language_id); 67 USHORT GetEnabledThemeCount(); 68 USHORT GetEnabledLanguageCount(); 69 USHORT GetColorCount(USHORT theme_id); 70 USHORT GetFontCount(USHORT theme_id); 71 USHORT GetPageCount(res_info *info, USHORT theme_id, USHORT font_id); 72 USHORT GetPixelmapCount(USHORT theme_id); 73 74 void InitFontSizeStorage(int display); 75 void DeleteFontSizeStorage(int display); 76 77 void WriteResourceHeader(); 78 void WriteThemeHeader(GX_THEME_HEADER *header); 79 void WriteColorHeader(GX_COLOR_HEADER *header); 80 void WritePaletteHeader(GX_PALETTE_HEADER *header); 81 void WriteFontHeader(GX_FONT_HEADER *header); 82 void WritePageHeader(GX_PAGE_HEADER *header); 83 void WriteGlyphHeader(GX_GLYPH_HEADER *header); 84 void WriteKerningGlyphHeader(GX_KERNING_GLYPH_HEADER *header); 85 void WritePixelmapHeader(GX_PIXELMAP_HEADER *header); 86 void WriteStringHeader(GX_STRING_HEADER *header); 87 void WriteLanguageHeader(GX_LANGUAGE_HEADER *header); 88 89 USHORT SwapUshort(USHORT s); 90 UINT SwapUint(UINT l); 91 92 void WriteThemeBlock(USHORT theme_id); 93 void WriteColorBlock(int theme_index); 94 void WritePaletteBlock(int theme_index); 95 void WriteFontData(res_info *info, USHORT theme_id, USHORT font_id); 96 void WritePageBlock(const GX_FONT *font, USHORT page_id); 97 void WriteGlyphBock(const GX_FONT *font, USHORT glyph_id); 98 void WriteStringBlock(); 99 void WriteStringData(USHORT language_id); 100 void WriteOneStringData(GX_STRING *string); 101 102 103 VOID WriteBigEndianUintData(GX_PIXELMAP *map); 104 VOID WriteBigEndianUshortData(GX_PIXELMAP *map); 105 VOID WriteBigEndianCompressedUshortData(GX_PIXELMAP *map); 106 107 VOID WriteOneSRecord(INT type); 108 VOID WriteOneSRecord(); 109 VOID WriteSRecordHeader(); 110 VOID WriteSRecordData(const void *data_ptr, INT data_size); 111 VOID WriteSRecordEnd(); 112 113 VOID WriteDataOut(const void *lpBuf, UINT nCount); 114 115 void InitRotatedPixelmaps(); 116 void DestroyRotatedPixelmaps(); 117 118 private: 119 ULONG m_written_start_address; 120 BOOL m_file_format; 121 INT m_srec_record_count; 122 ULONG m_srec_address; 123 UCHAR m_srec_data[SREC_MAX_DATA_SIZE]; 124 INT m_srec_data_size; 125 INT *m_font_data_size[MAX_THEMES]; 126 127 CArray<GX_PIXELMAP *> m_rotated_pixelmaps[MAX_THEMES]; 128 CArray<file_info*> m_file_dictionary; 129 INT m_output_resource_id; 130 }; 131 132