Mercurial > hg > sidinfo
comparison sidlib.h @ 319:6d0143e43edf
Add functionality and API changes for doing on-the-fly character set
conversion of STIL data and PSID header string fields while reading them.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 11 Jan 2020 20:12:00 +0200 |
parents | ee56f1f2b528 |
children | 4978ff445572 |
comparison
equal
deleted
inserted
replaced
318:f3ba2ba894b1 | 319:6d0143e43edf |
---|---|
82 | 82 |
83 | 83 |
84 typedef struct | 84 typedef struct |
85 { | 85 { |
86 int ndata; | 86 int ndata; |
87 char **data; | 87 char **data; // Converted through SIDLibChConvCtx if conversion is used |
88 } SIDLibSTILField; | 88 } SIDLibSTILField; |
89 | 89 |
90 | 90 |
91 typedef struct | 91 typedef struct |
92 { | 92 { |
97 | 97 |
98 typedef struct | 98 typedef struct |
99 { | 99 { |
100 th_llist_t node; | 100 th_llist_t node; |
101 | 101 |
102 char *filename; // HVSC path/filename | 102 char *filename; // HVSC path/filename (NOT converted through SIDLibChConvCtx) |
103 size_t nsubtunes; // Number of subtune information structures | 103 size_t nsubtunes; // Number of subtune information structures |
104 SIDLibSTILSubTune *subtunes; | 104 SIDLibSTILSubTune *subtunes; // NOTE! Subtunes are in undefined order here |
105 // (through with correct SIDLibSTILSubTune::tune number, of course) | |
106 // unless sidlib_stildb_build_index() has been run on the SIDLibSTILDB | |
105 | 107 |
106 // Internal use only | 108 // Internal use only |
107 SIDLibSLDBNode *lengths; | 109 SIDLibSLDBNode *lengths; |
108 } SIDLibSTILNode; | 110 } SIDLibSTILNode; |
109 | 111 |
125 initAddress, // Initialization address | 127 initAddress, // Initialization address |
126 playAddress, // Play one frame | 128 playAddress, // Play one frame |
127 nSongs, // Number of subsongs | 129 nSongs, // Number of subsongs |
128 startSong; // Default starting song | 130 startSong; // Default starting song |
129 uint32_t speed; // Speed | 131 uint32_t speed; // Speed |
132 | |
130 char *sidName; // Descriptive text-fields, ASCIIZ | 133 char *sidName; // Descriptive text-fields, ASCIIZ |
131 char *sidAuthor; | 134 char *sidAuthor; // Converted through SIDLibChConvCtx if conversion is used |
132 char *sidCopyright; | 135 char *sidCopyright; |
133 | 136 |
134 // PSIDv2+ data | 137 // PSIDv2+ data |
135 uint16_t flags; // Flags | 138 uint16_t flags; // Flags |
136 uint8_t startPage, pageLength; | 139 uint8_t startPage, pageLength; |
146 SIDLibSLDBNode *lengths; // Songlength information node pointer | 149 SIDLibSLDBNode *lengths; // Songlength information node pointer |
147 SIDLibSTILNode *stil; // STIL database node pointer | 150 SIDLibSTILNode *stil; // STIL database node pointer |
148 } SIDLibPSIDHeader; | 151 } SIDLibPSIDHeader; |
149 | 152 |
150 | 153 |
154 typedef struct SIDLibChConvCtx | |
155 { | |
156 void *data; | |
157 char* (*convert)(struct SIDLibChConvCtx *ctx, const char *str); | |
158 } SIDLibChConvCtx; | |
159 | |
160 | |
151 // | 161 // |
152 // Globals | 162 // Globals |
153 // | 163 // |
154 const char *sidlib_stil_fields[STF_LAST]; | 164 const char * sidlib_stil_fields[STF_LAST]; |
165 | |
155 | 166 |
156 // | 167 // |
157 // Functions | 168 // Functions |
158 // | 169 // |
159 int sidlib_read_sid_file(th_ioctx *ctx, SIDLibPSIDHeader *psid, const BOOL newSLDB); | 170 int sidlib_read_sid_file(th_ioctx *ctx, SIDLibPSIDHeader *psid, const BOOL newSLDB, SIDLibChConvCtx *chconv); |
160 int sidlib_read_sid_file_alloc(th_ioctx *ctx, SIDLibPSIDHeader **ppsid, const BOOL newSLDB); | 171 int sidlib_read_sid_file_alloc(th_ioctx *ctx, SIDLibPSIDHeader **ppsid, const BOOL newSLDB, SIDLibChConvCtx *chconv); |
161 void sidlib_free_sid_file(SIDLibPSIDHeader *psid); | 172 void sidlib_free_sid_file(SIDLibPSIDHeader *psid); |
162 | 173 |
163 const char * sidlib_get_sid_clock_str(const int flags); | 174 const char * sidlib_get_sid_clock_str(const int flags); |
164 const char * sidlib_get_sid_model_str(const int flags); | 175 const char * sidlib_get_sid_model_str(const int flags); |
165 | 176 |
168 int sidlib_sldb_build_index(SIDLibSLDB *dbh); | 179 int sidlib_sldb_build_index(SIDLibSLDB *dbh); |
169 void sidlib_sldb_free(SIDLibSLDB *dbh); | 180 void sidlib_sldb_free(SIDLibSLDB *dbh); |
170 SIDLibSLDBNode * sidlib_sldb_get_by_hash(SIDLibSLDB *dbh, th_md5hash_t hash); | 181 SIDLibSLDBNode * sidlib_sldb_get_by_hash(SIDLibSLDB *dbh, th_md5hash_t hash); |
171 | 182 |
172 int sidlib_stildb_new(SIDLibSTILDB **pdbh); | 183 int sidlib_stildb_new(SIDLibSTILDB **pdbh); |
173 int sidlib_stildb_read(th_ioctx *ctx, SIDLibSTILDB *dbh); | 184 int sidlib_stildb_read(th_ioctx *ctx, SIDLibSTILDB *dbh, SIDLibChConvCtx *chconv); |
174 int sidlib_stildb_build_index(SIDLibSTILDB *dbh); | 185 int sidlib_stildb_build_index(SIDLibSTILDB *dbh); |
175 void sidlib_stildb_free(SIDLibSTILDB *dbh); | 186 void sidlib_stildb_free(SIDLibSTILDB *dbh); |
176 SIDLibSTILNode * sidlib_stildb_get_node(SIDLibSTILDB *dbh, const char *filename); | 187 SIDLibSTILNode * sidlib_stildb_get_node(SIDLibSTILDB *dbh, const char *filename); |
177 SIDLibSTILSubTune *sidlib_stildb_find_subtune(SIDLibSTILNode *node, const int nsubtune); | 188 SIDLibSTILSubTune *sidlib_stildb_find_subtune(SIDLibSTILNode *node, const int nsubtune); |
178 | 189 |