2 Skelton for retropc emulator
4 Author : Takeda.Toshiya
10 #if defined(_USE_QT) || defined(_USE_SDL)
18 #include <sys/types.h>
20 #if !defined(Q_OS_WIN)
37 #include "zlib-1.2.11/zlib.h"
38 #include "zlib-1.2.11/zconf.h"
40 #if defined(ZLIB_VERNUM) && (ZLIB_VERNUM < 0x1290)
41 inline size_t gzfread(void *buffer, size_t size, size_t count, gzFile file)
43 uint8_t *p = (uint8_t *)buffer;
45 for(i = 0; i < count; i++) {
46 for(int j = 0; j < size; j++) {
48 if(s < 0) return 0; // EOF
54 inline size_t gzfwrite(void *buffer, size_t size, size_t count, gzFile file)
56 uint8_t *p = (uint8_t *)buffer;
58 for(i = 0; i < count; i++) {
59 for(int j = 0; j < size; j++) {
61 int s = gzputc(file, n);
62 if(s < 0) return 0; // EOF
84 bool FILEIO::IsFileExisting(const _TCHAR *file_path)
86 #if defined(_USE_QT) || defined(_USE_SDL)
87 FILE *f = fopen(file_path, "r");
94 DWORD attr = GetFileAttributes(file_path);
98 return ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0);
100 return (_taccess(file_path, 0) == 0);
104 bool FILEIO::IsFileProtected(const _TCHAR *file_path)
106 #if defined(_USE_QT) || defined(_USE_SDL)
108 if(stat(file_path, &st) == 0) {
110 if((st.st_mode & S_IWUSR) == 0) {
112 if((st.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH)) == 0) {
118 #elif defined(_WIN32)
119 return ((GetFileAttributes(file_path) & FILE_ATTRIBUTE_READONLY) != 0);
121 return (_taccess(file_path, 2) != 0);
125 bool FILEIO::RemoveFile(const _TCHAR *file_path)
127 #if defined(_USE_QT) || defined(_USE_SDL)
128 return (remove(file_path) == 0);
129 #elif defined(_WIN32)
130 return (DeleteFile(file_path) != 0);
132 return (_tremove(file_path) == 0);
136 bool FILEIO::RenameFile(const _TCHAR *existing_file_path, const _TCHAR *new_file_path)
138 #if defined(_USE_QT) || defined(_USE_SDL)
139 return (rename(existing_file_path, new_file_path) == 0);
140 #elif defined(_WIN32)
141 return (MoveFile(existing_file_path, new_file_path) != 0);
143 return (_trename(existing_file_path, new_file_path) == 0);
147 bool FILEIO::Fopen(const _TCHAR *file_path, int mode)
152 my_tcscpy_s(path, _MAX_PATH, file_path);
156 if(check_file_extension(file_path, _T(".gz"))) {
157 return Gzopen(file_path, mode);
161 case FILEIO_READ_BINARY:
162 return ((fp = _tfopen(file_path, _T("rb"))) != NULL);
163 case FILEIO_WRITE_BINARY:
164 return ((fp = _tfopen(file_path, _T("wb"))) != NULL);
165 case FILEIO_READ_WRITE_BINARY:
166 return ((fp = _tfopen(file_path, _T("r+b"))) != NULL);
167 case FILEIO_READ_WRITE_NEW_BINARY:
168 return ((fp = _tfopen(file_path, _T("w+b"))) != NULL);
169 case FILEIO_READ_ASCII:
170 return ((fp = _tfopen(file_path, _T("r"))) != NULL);
171 case FILEIO_WRITE_ASCII:
172 return ((fp = _tfopen(file_path, _T("w"))) != NULL);
173 case FILEIO_WRITE_APPEND_ASCII:
174 return ((fp = _tfopen(file_path, _T("a"))) != NULL);
175 case FILEIO_READ_WRITE_ASCII:
176 return ((fp = _tfopen(file_path, _T("r+"))) != NULL);
177 case FILEIO_READ_WRITE_NEW_ASCII:
178 return ((fp = _tfopen(file_path, _T("w+"))) != NULL);
179 case FILEIO_READ_WRITE_APPEND_ASCII:
180 return ((fp = _tfopen(file_path, _T("a+"))) != NULL);
186 bool FILEIO::Gzopen(const _TCHAR *file_path, int mode)
191 my_tcscpy_s(path, _MAX_PATH, file_path);
195 case FILEIO_READ_BINARY:
196 // case FILEIO_READ_WRITE_BINARY:
197 case FILEIO_READ_ASCII:
198 // case FILEIO_READ_WRITE_ASCII:
199 // case FILEIO_READ_WRITE_APPEND_ASCII:
200 if((fp = _tfopen(file_path, _T("rb"))) != NULL) {
202 uint8_t data[10], name[_MAX_PATH] = {0};
203 fread(data, 10, 1, fp);
204 if(data[0] == 0x1f && data[1] == 0x8b && data[2] == 0x08) {
207 fseek(fp, 2, SEEK_CUR);
211 fread(data + 4, 2, 1, fp);
212 fseek(fp, data[4] | (data[5] << 8), SEEK_CUR);
215 // read original file name
216 fread(name, sizeof(name), 1, fp);
217 my_stprintf_s(path, _MAX_PATH, _T("%s%s"), get_parent_dir(path), (char *)name);
219 // get uncompressed input size
220 fseek(fp, -4, SEEK_END);
221 fread(data, 4, 1, fp);
222 gz_size = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
233 case FILEIO_READ_BINARY:
234 return ((gz = gzopen(tchar_to_char(file_path), "rb")) != NULL);
235 case FILEIO_WRITE_BINARY:
236 return ((gz = gzopen(tchar_to_char(file_path), "wb")) != NULL);
237 // case FILEIO_READ_WRITE_BINARY:
238 // return ((gz = gzopen(tchar_to_char(file_path), "r+b")) != NULL);
239 // case FILEIO_READ_WRITE_NEW_BINARY:
240 // return ((gz = gzopen(tchar_to_char(file_path), "w+b")) != NULL);
241 case FILEIO_READ_ASCII:
242 return ((gz = gzopen(tchar_to_char(file_path), "r")) != NULL);
243 case FILEIO_WRITE_ASCII:
244 return ((gz = gzopen(tchar_to_char(file_path), "w")) != NULL);
245 // case FILEIO_WRITE_APPEND_ASCII:
246 // return ((gz = gzopen(tchar_to_char(file_path), "a")) != NULL);
247 // case FILEIO_READ_WRITE_ASCII:
248 // return ((gz = gzopen(tchar_to_char(file_path), "r+")) != NULL);
249 // case FILEIO_READ_WRITE_NEW_ASCII:
250 // return ((gz = gzopen(tchar_to_char(file_path), "w+")) != NULL);
251 // case FILEIO_READ_WRITE_APPEND_ASCII:
252 // return ((gz = gzopen(tchar_to_char(file_path), "a+")) != NULL);
258 void FILEIO::Fclose()
273 long FILEIO::FileLength()
276 Fseek(0, FILEIO_SEEK_END);
278 Fseek(pos, FILEIO_SEEK_SET);
282 #define GET_VALUE(type) \
283 uint8_t buffer[sizeof(type)] = {0}; \
284 Fread(buffer, sizeof(buffer), 1); \
285 return *(type *)buffer
287 #define PUT_VALUE(type, v) \
288 Fwrite(&v, sizeof(type), 1)
290 bool FILEIO::FgetBool()
295 void FILEIO::FputBool(bool val)
297 PUT_VALUE(bool, val);
300 uint8_t FILEIO::FgetUint8()
305 void FILEIO::FputUint8(uint8_t val)
307 PUT_VALUE(uint8_t, val);
310 uint16_t FILEIO::FgetUint16()
315 void FILEIO::FputUint16(uint16_t val)
317 PUT_VALUE(uint16_t, val);
320 uint32_t FILEIO::FgetUint32()
325 void FILEIO::FputUint32(uint32_t val)
327 PUT_VALUE(uint32_t, val);
330 uint64_t FILEIO::FgetUint64()
335 void FILEIO::FputUint64(uint64_t val)
337 PUT_VALUE(uint64_t, val);
340 int8_t FILEIO::FgetInt8()
345 void FILEIO::FputInt8(int8_t val)
347 PUT_VALUE(int8_t, val);
350 int16_t FILEIO::FgetInt16()
355 void FILEIO::FputInt16(int16_t val)
357 PUT_VALUE(int16_t, val);
360 int32_t FILEIO::FgetInt32()
365 void FILEIO::FputInt32(int32_t val)
367 PUT_VALUE(int32_t, val);
370 int64_t FILEIO::FgetInt64()
375 void FILEIO::FputInt64(int64_t val)
377 PUT_VALUE(int64_t, val);
380 float FILEIO::FgetFloat()
385 void FILEIO::FputFloat(float val)
387 PUT_VALUE(float, val);
390 double FILEIO::FgetDouble()
395 void FILEIO::FputDouble(double val)
397 PUT_VALUE(double, val);
400 uint16_t FILEIO::FgetUint16_LE()
403 tmp.b.l = FgetUint8();
404 tmp.b.h = FgetUint8();
408 void FILEIO::FputUint16_LE(uint16_t val)
416 uint32_t FILEIO::FgetUint32_LE()
419 tmp.b.l = FgetUint8();
420 tmp.b.h = FgetUint8();
421 tmp.b.h2 = FgetUint8();
422 tmp.b.h3 = FgetUint8();
426 void FILEIO::FputUint32_LE(uint32_t val)
436 uint64_t FILEIO::FgetUint64_LE()
439 tmp.b.l = FgetUint8();
440 tmp.b.h = FgetUint8();
441 tmp.b.h2 = FgetUint8();
442 tmp.b.h3 = FgetUint8();
443 tmp.b.h4 = FgetUint8();
444 tmp.b.h5 = FgetUint8();
445 tmp.b.h6 = FgetUint8();
446 tmp.b.h7 = FgetUint8();
450 void FILEIO::FputUint64_LE(uint64_t val)
464 int16_t FILEIO::FgetInt16_LE()
467 tmp.b.l = FgetUint8();
468 tmp.b.h = FgetUint8();
472 void FILEIO::FputInt16_LE(int16_t val)
480 int32_t FILEIO::FgetInt32_LE()
483 tmp.b.l = FgetUint8();
484 tmp.b.h = FgetUint8();
485 tmp.b.h2 = FgetUint8();
486 tmp.b.h3 = FgetUint8();
490 void FILEIO::FputInt32_LE(int32_t val)
500 int64_t FILEIO::FgetInt64_LE()
503 tmp.b.l = FgetUint8();
504 tmp.b.h = FgetUint8();
505 tmp.b.h2 = FgetUint8();
506 tmp.b.h3 = FgetUint8();
507 tmp.b.h4 = FgetUint8();
508 tmp.b.h5 = FgetUint8();
509 tmp.b.h6 = FgetUint8();
510 tmp.b.h7 = FgetUint8();
514 void FILEIO::FputInt64_LE(int64_t val)
528 float FILEIO::FgetFloat_LE()
531 tmp.b.l = FgetUint8();
532 tmp.b.h = FgetUint8();
533 tmp.b.h2 = FgetUint8();
534 tmp.b.h3 = FgetUint8();
538 void FILEIO::FputFloat_LE(float val)
548 double FILEIO::FgetDouble_LE()
551 tmp.b.l = FgetUint8();
552 tmp.b.h = FgetUint8();
553 tmp.b.h2 = FgetUint8();
554 tmp.b.h3 = FgetUint8();
555 tmp.b.h4 = FgetUint8();
556 tmp.b.h5 = FgetUint8();
557 tmp.b.h6 = FgetUint8();
558 tmp.b.h7 = FgetUint8();
562 void FILEIO::FputDouble_LE(double val)
576 _TCHAR FILEIO::FgetTCHAR_LE()
578 switch(sizeof(_TCHAR)) {
579 case 2: return (_TCHAR)FgetUint16_LE();
580 case 4: return (_TCHAR)FgetUint32_LE();
581 case 8: return (_TCHAR)FgetUint64_LE();
583 return (_TCHAR)FgetUint8();
586 void FILEIO::FputTCHAR_LE(_TCHAR val)
588 switch(sizeof(_TCHAR)) {
589 case 2: FputUint16_LE((uint16_t)val); return;
590 case 4: FputUint32_LE((uint32_t)val); return;
591 case 8: FputUint32_LE((uint64_t)val); return;
593 FputUint8((uint8_t )val);
596 uint16_t FILEIO::FgetUint16_BE()
599 tmp.b.h = FgetUint8();
600 tmp.b.l = FgetUint8();
604 void FILEIO::FputUint16_BE(uint16_t val)
612 uint32_t FILEIO::FgetUint32_BE()
615 tmp.b.h3 = FgetUint8();
616 tmp.b.h2 = FgetUint8();
617 tmp.b.h = FgetUint8();
618 tmp.b.l = FgetUint8();
622 void FILEIO::FputUint32_BE(uint32_t val)
632 uint64_t FILEIO::FgetUint64_BE()
635 tmp.b.h7 = FgetUint8();
636 tmp.b.h6 = FgetUint8();
637 tmp.b.h5 = FgetUint8();
638 tmp.b.h4 = FgetUint8();
639 tmp.b.h3 = FgetUint8();
640 tmp.b.h2 = FgetUint8();
641 tmp.b.h = FgetUint8();
642 tmp.b.l = FgetUint8();
646 void FILEIO::FputUint64_BE(uint64_t val)
660 int16_t FILEIO::FgetInt16_BE()
663 tmp.b.h = FgetUint8();
664 tmp.b.l = FgetUint8();
668 void FILEIO::FputInt16_BE(int16_t val)
676 int32_t FILEIO::FgetInt32_BE()
679 tmp.b.h3 = FgetUint8();
680 tmp.b.h2 = FgetUint8();
681 tmp.b.h = FgetUint8();
682 tmp.b.l = FgetUint8();
686 void FILEIO::FputInt32_BE(int32_t val)
696 int64_t FILEIO::FgetInt64_BE()
699 tmp.b.h7 = FgetUint8();
700 tmp.b.h6 = FgetUint8();
701 tmp.b.h5 = FgetUint8();
702 tmp.b.h4 = FgetUint8();
703 tmp.b.h3 = FgetUint8();
704 tmp.b.h2 = FgetUint8();
705 tmp.b.h = FgetUint8();
706 tmp.b.l = FgetUint8();
710 void FILEIO::FputInt64_BE(int64_t val)
724 float FILEIO::FgetFloat_BE()
727 tmp.b.h3 = FgetUint8();
728 tmp.b.h2 = FgetUint8();
729 tmp.b.h = FgetUint8();
730 tmp.b.l = FgetUint8();
734 void FILEIO::FputFloat_BE(float val)
744 double FILEIO::FgetDouble_BE()
747 tmp.b.h7 = FgetUint8();
748 tmp.b.h6 = FgetUint8();
749 tmp.b.h5 = FgetUint8();
750 tmp.b.h4 = FgetUint8();
751 tmp.b.h3 = FgetUint8();
752 tmp.b.h2 = FgetUint8();
753 tmp.b.h = FgetUint8();
754 tmp.b.l = FgetUint8();
758 void FILEIO::FputDouble_BE(double val)
772 _TCHAR FILEIO::FgetTCHAR_BE()
774 switch(sizeof(_TCHAR)) {
775 case 2: return (_TCHAR)FgetUint16_BE();
776 case 4: return (_TCHAR)FgetUint32_BE();
777 case 8: return (_TCHAR)FgetUint64_BE();
779 return (_TCHAR)FgetUint8();
782 void FILEIO::FputTCHAR_BE(_TCHAR val)
784 switch(sizeof(_TCHAR)) {
785 case 2: FputUint16_BE((uint16_t)val); return;
786 case 4: FputUint32_BE((uint32_t)val); return;
787 case 8: FputUint32_BE((uint64_t)val); return;
789 FputUint8((uint8_t )val);
805 int FILEIO::Fputc(int c)
809 return gzputc(gz, c);
818 char *FILEIO::Fgets(char *str, int n)
822 return gzgets(gz, str, n);
826 return fgets(str, n, fp);
831 _TCHAR *FILEIO::Fgetts(_TCHAR *str, int n)
835 #if defined(_UNICODE) && defined(SUPPORT_TCHAR_TYPE)
836 char *str_mb = (char *)calloc(sizeof(char), n + 1);
837 gzgets(gz, str_mb, n);
838 my_swprintf_s(str, n, L"%s", char_to_wchar(str_mb));
842 return gzgets(gz, str, n);
847 return _fgetts(str, n, fp);
852 int FILEIO::Fprintf(const char* format, ...)
857 va_start(ap, format);
858 my_vsprintf_s(buffer, 1024, format, ap);
863 return gzprintf(gz, "%s", buffer);
867 return my_fprintf_s(fp, "%s", buffer);
872 int FILEIO::Ftprintf(const _TCHAR* format, ...)
877 va_start(ap, format);
878 my_vstprintf_s(buffer, 1024, format, ap);
883 return gzprintf(gz, "%s", tchar_to_char(buffer));
887 return my_ftprintf_s(fp, _T("%s"), buffer);
892 size_t FILEIO::Fread(void* buffer, size_t size, size_t count)
896 return gzfread(buffer, size, count, gz);
900 return fread(buffer, size, count, fp);
905 size_t FILEIO::Fwrite(const void* buffer, size_t size, size_t count)
909 return gzfwrite(buffer, size, count, gz);
913 return fwrite(buffer, size, count, fp);
918 int FILEIO::Fseek(long offset, int origin)
923 case FILEIO_SEEK_CUR:
924 return (gzseek(gz, offset, SEEK_CUR) == -1 ? -1 : 0);
925 case FILEIO_SEEK_END:
926 return (gzseek(gz, offset + gz_size, SEEK_SET) == -1 ? -1 : 0);
927 case FILEIO_SEEK_SET:
928 return (gzseek(gz, offset, SEEK_SET) == -1 ? -1 : 0);
934 case FILEIO_SEEK_CUR:
935 return fseek(fp, offset, SEEK_CUR);
936 case FILEIO_SEEK_END:
937 return fseek(fp, offset, SEEK_END);
938 case FILEIO_SEEK_SET:
939 return fseek(fp, offset, SEEK_SET);
959 bool FILEIO::Fflush()
963 return (gzflush(gz, Z_SYNC_FLUSH) == Z_OK) ? true : false;
967 return (fflush(fp) == 0) ? true : false;
972 bool FILEIO::StateCheckUint32(uint32_t val)
974 if(open_mode == FILEIO_READ_BINARY) {
975 return (val == FgetUint32_LE());
982 bool FILEIO::StateCheckInt32(int32_t val)
984 if(open_mode == FILEIO_READ_BINARY) {
985 return (val == FgetInt32_LE());
992 bool FILEIO::StateCheckBuffer(const _TCHAR *buffer, size_t size, size_t count)
994 for(unsigned int i = 0; i < size / sizeof(buffer[0]) * count; i++) {
995 if(open_mode == FILEIO_READ_BINARY) {
996 if(buffer[i] != FgetTCHAR_LE()) {
1000 FputTCHAR_LE(buffer[i]);
1006 void FILEIO::StateValue(bool &val)
1008 if(open_mode == FILEIO_READ_BINARY) {
1015 void FILEIO::StateValue(uint8_t &val)
1017 if(open_mode == FILEIO_READ_BINARY) {
1024 void FILEIO::StateValue(uint16_t &val)
1026 if(open_mode == FILEIO_READ_BINARY) {
1027 val = FgetUint16_LE();
1033 void FILEIO::StateValue(uint32_t &val)
1035 if(open_mode == FILEIO_READ_BINARY) {
1036 val = FgetUint32_LE();
1042 void FILEIO::StateValue(uint64_t &val)
1044 if(open_mode == FILEIO_READ_BINARY) {
1045 val = FgetUint64_LE();
1051 void FILEIO::StateValue(int8_t &val)
1053 if(open_mode == FILEIO_READ_BINARY) {
1060 void FILEIO::StateValue(int16_t &val)
1062 if(open_mode == FILEIO_READ_BINARY) {
1063 val = FgetInt16_LE();
1069 void FILEIO::StateValue(int32_t &val)
1071 if(open_mode == FILEIO_READ_BINARY) {
1072 val = FgetInt32_LE();
1078 void FILEIO::StateValue(int64_t &val)
1080 if(open_mode == FILEIO_READ_BINARY) {
1081 val = FgetInt64_LE();
1087 void FILEIO::StateValue(pair16_t &val)
1089 if(open_mode == FILEIO_READ_BINARY) {
1090 val.u16 = FgetUint16_LE();
1092 FputUint16_LE(val.u16);
1096 void FILEIO::StateValue(pair32_t &val)
1098 if(open_mode == FILEIO_READ_BINARY) {
1099 val.d = FgetUint32_LE();
1101 FputUint32_LE(val.d);
1105 void FILEIO::StateValue(pair64_t &val)
1107 if(open_mode == FILEIO_READ_BINARY) {
1108 val.q = FgetUint64_LE();
1110 FputUint64_LE(val.q);
1114 void FILEIO::StateValue(float &val)
1116 if(open_mode == FILEIO_READ_BINARY) {
1117 val = FgetFloat_LE();
1123 void FILEIO::StateValue(double &val)
1125 if(open_mode == FILEIO_READ_BINARY) {
1126 val = FgetDouble_LE();
1132 void FILEIO::StateValue(_TCHAR &val)
1134 if(open_mode == FILEIO_READ_BINARY) {
1135 val = FgetTCHAR_LE();
1142 // Note: scrntype_t is variable size type.2 bytes@15/16bpp, 4bytes@24/32bpp.
1143 void FILEIO::StateValueScrnType_t(scrntype_t &val)
1146 if(open_mode == FILEIO_READ_BINARY) {
1150 val = RGB_COLOR(r, g, b);
1152 r = R_OF_COLOR(val);
1153 g = G_OF_COLOR(val);
1154 b = B_OF_COLOR(val);
1162 void FILEIO::StateVector(std::vector<int8_t> datas)
1164 int memb = datas.size();
1165 for(int i = 0; i < memb; i++) {
1166 StateValue(datas[i]);
1170 void FILEIO::StateVector(std::vector<int16_t> datas)
1172 int memb = datas.size();
1173 for(int i = 0; i < memb; i++) {
1174 StateValue(datas[i]);
1178 void FILEIO::StateVector(std::vector<int32_t> datas)
1180 int memb = datas.size();
1181 for(int i = 0; i < memb; i++) {
1182 StateValue(datas[i]);
1186 void FILEIO::StateVector(std::vector<int64_t> datas)
1188 int memb = datas.size();
1189 for(int i = 0; i < memb; i++) {
1190 StateValue(datas[i]);
1194 void FILEIO::StateVector(std::vector<uint8_t> datas)
1196 int memb = datas.size();
1197 for(int i = 0; i < memb; i++) {
1198 StateValue(datas[i]);
1202 void FILEIO::StateVector(std::vector<uint16_t> datas)
1204 int memb = datas.size();
1205 for(int i = 0; i < memb; i++) {
1206 StateValue(datas[i]);
1210 void FILEIO::StateVector(std::vector<uint32_t> datas)
1212 int memb = datas.size();
1213 for(int i = 0; i < memb; i++) {
1214 StateValue(datas[i]);
1218 void FILEIO::StateVector(std::vector<uint64_t> datas)
1220 int memb = datas.size();
1221 for(int i = 0; i < memb; i++) {
1222 StateValue(datas[i]);
1226 void FILEIO::StateVector(std::vector<bool> datas)
1228 int memb = datas.size();
1229 for(int i = 0; i < memb; i++) {
1230 if(open_mode == FILEIO_READ_BINARY) {
1231 datas[i] = FgetBool();
1238 void FILEIO::StateVector(std::vector<float> datas)
1240 int memb = datas.size();
1241 for(int i = 0; i < memb; i++) {
1242 StateValue(datas[i]);
1246 void FILEIO::StateVector(std::vector<double> datas)
1248 int memb = datas.size();
1249 for(int i = 0; i < memb; i++) {
1250 StateValue(datas[i]);
1254 void FILEIO::StateVector(std::vector<_TCHAR> datas)
1256 int memb = datas.size();
1257 for(int i = 0; i < memb; i++) {
1258 StateValue(datas[i]);
1262 void FILEIO::StateVector(std::vector<pair16_t> datas)
1264 int memb = datas.size();
1265 for(int i = 0; i < memb; i++) {
1266 StateValue(datas[i]);
1270 void FILEIO::StateVector(std::vector<pair32_t> datas)
1272 int memb = datas.size();
1273 for(int i = 0; i < memb; i++) {
1274 StateValue(datas[i]);
1278 void FILEIO::StateVector(std::vector<pair64_t> datas)
1280 int memb = datas.size();
1281 for(int i = 0; i < memb; i++) {
1282 StateValue(datas[i]);
1287 void FILEIO::StateArray(bool *buffer, size_t size, size_t count)
1289 for(unsigned int i = 0; i < size / sizeof(buffer[0]) * count; i++) {
1290 StateValue(buffer[i]);
1294 void FILEIO::StateArray(uint8_t *buffer, size_t size, size_t count)
1296 for(unsigned int i = 0; i < size / sizeof(buffer[0]) * count; i++) {
1297 StateValue(buffer[i]);
1301 void FILEIO::StateArray(uint16_t *buffer, size_t size, size_t count)
1303 for(unsigned int i = 0; i < size / sizeof(buffer[0]) * count; i++) {
1304 StateValue(buffer[i]);
1308 void FILEIO::StateArray(uint32_t *buffer, size_t size, size_t count)
1310 for(unsigned int i = 0; i < size / sizeof(buffer[0]) * count; i++) {
1311 StateValue(buffer[i]);
1315 void FILEIO::StateArray(uint64_t *buffer, size_t size, size_t count)
1317 for(unsigned int i = 0; i < size / sizeof(buffer[0]) * count; i++) {
1318 StateValue(buffer[i]);
1322 void FILEIO::StateArray(int8_t *buffer, size_t size, size_t count)
1324 for(unsigned int i = 0; i < size / sizeof(buffer[0]) * count; i++) {
1325 StateValue(buffer[i]);
1329 void FILEIO::StateArray(int16_t *buffer, size_t size, size_t count)
1331 for(unsigned int i = 0; i < size / sizeof(buffer[0]) * count; i++) {
1332 StateValue(buffer[i]);
1336 void FILEIO::StateArray(int32_t *buffer, size_t size, size_t count)
1338 for(unsigned int i = 0; i < size / sizeof(buffer[0]) * count; i++) {
1339 StateValue(buffer[i]);
1343 void FILEIO::StateArray(int64_t *buffer, size_t size, size_t count)
1345 for(unsigned int i = 0; i < size / sizeof(buffer[0]) * count; i++) {
1346 StateValue(buffer[i]);
1350 void FILEIO::StateArray(pair16_t *buffer, size_t size, size_t count)
1352 for(unsigned int i = 0; i < size / sizeof(buffer[0]) * count; i++) {
1353 StateValue(buffer[i]);
1357 void FILEIO::StateArray(pair32_t *buffer, size_t size, size_t count)
1359 for(unsigned int i = 0; i < size / sizeof(buffer[0]) * count; i++) {
1360 StateValue(buffer[i]);
1364 void FILEIO::StateArray(pair64_t *buffer, size_t size, size_t count)
1366 for(unsigned int i = 0; i < size / sizeof(buffer[0]) * count; i++) {
1367 StateValue(buffer[i]);
1371 void FILEIO::StateArray(float *buffer, size_t size, size_t count)
1373 for(unsigned int i = 0; i < size / sizeof(buffer[0]) * count; i++) {
1374 StateValue(buffer[i]);
1378 void FILEIO::StateArray(double *buffer, size_t size, size_t count)
1380 for(unsigned int i = 0; i < size / sizeof(buffer[0]) * count; i++) {
1381 StateValue(buffer[i]);
1385 void FILEIO::StateArray(_TCHAR *buffer, size_t size, size_t count)
1387 for(unsigned int i = 0; i < size / sizeof(buffer[0]) * count; i++) {
1388 StateValue(buffer[i]);
1393 // Note: scrntype_t is variable size type.2 bytes@15/16bpp, 4bytes@24/32bpp.
1394 void FILEIO::StateArrayScrnType_t(scrntype_t *buffer, size_t size, size_t count)
1396 for(unsigned int i = 0; i < size / sizeof(buffer[0]) * count; i++) {
1397 StateValue(buffer[i]);
1402 void FILEIO::StateBuffer(void *buffer, size_t size, size_t count)
1404 if(open_mode == FILEIO_READ_BINARY) {
1405 Fread(buffer, size, count);
1407 Fwrite(buffer, size, count);