| ... | ... |
@@ -15,8 +15,7 @@ |
| 15 | 15 |
along with the this software. If not, see <http://www.gnu.org/licenses/>. |
| 16 | 16 |
*/ |
| 17 | 17 |
|
| 18 |
-#ifndef _READWRITE_H_ |
|
| 19 |
-#define _READWRITE_H_ |
|
| 18 |
+#pragma once |
|
| 20 | 19 |
|
| 21 | 20 |
#include <iostream> |
| 22 | 21 |
#include <vector> |
| ... | ... |
@@ -42,5 +41,3 @@ int read16le(uint16_t *Bufo, std::istream *is); |
| 42 | 41 |
int readbool(bool *b, EMUFILE *is); |
| 43 | 42 |
|
| 44 | 43 |
int readbuffer(std::vector<uint8_t> &vec, EMUFILE *is); |
| 45 |
- |
|
| 46 |
-#endif |
| ... | ... |
@@ -21,46 +21,26 @@ |
| 21 | 21 |
#include <iostream> |
| 22 | 22 |
#include <vector> |
| 23 | 23 |
#include <cstdio> |
| 24 |
- |
|
| 25 | 24 |
#include "types.h" |
| 26 | 25 |
#include "emufile.h" |
| 27 | 26 |
|
| 28 |
-//well. just for the sake of consistency |
|
| 29 |
-//int write8le(uint8_t b, EMUFILE *fp); |
|
| 30 |
-//inline int write8le(uint8_t* b, EMUFILE *fp) { return write8le(*b,fp); }
|
|
| 31 |
-//int write16le(uint16_t b, EMUFILE* os); |
|
| 32 |
-//int write32le(uint32_t b, EMUFILE* os); |
|
| 33 |
-//int write64le(uint64_t b, EMUFILE* os); |
|
| 34 |
-//inline int write_double_le(double b, EMUFILE*is) { uint64_t temp = double_to_u64(b); int ret = write64le(temp,is); return ret; }
|
|
| 35 |
- |
|
| 36 |
-int read8le(uint8_t *Bufo, EMUFILE*is); |
|
| 37 |
-int read16le(uint16_t *Bufo, EMUFILE*is); |
|
| 38 |
-inline int read16le(int16_t *Bufo, EMUFILE*is) { return read16le((uint16_t*)Bufo,is); }
|
|
| 39 |
-int read32le(uint32_t *Bufo, EMUFILE*is); |
|
| 40 |
-inline int read32le(int32_t *Bufo, EMUFILE*is) { return read32le((uint32_t*)Bufo,is); }
|
|
| 41 |
-int read64le(uint64_t *Bufo, EMUFILE*is); |
|
| 42 |
-inline int read_double_le(double *Bufo, EMUFILE*is) { uint64_t temp; int ret = read64le(&temp,is); *Bufo = u64_to_double(temp); return ret; }
|
|
| 43 |
-int read16le(uint16_t *Bufo, std::istream *is); |
|
| 44 |
- |
|
| 45 |
- |
|
| 46 |
-/*template<typename T> |
|
| 47 |
-int readle(T *Bufo, EMUFILE*is) |
|
| 27 |
+int read8le(uint8_t *Bufo, EMUFILE *is); |
|
| 28 |
+int read16le(uint16_t *Bufo, EMUFILE *is); |
|
| 29 |
+inline int read16le(int16_t *Bufo, EMUFILE *is) { return read16le(reinterpret_cast<uint16_t *>(Bufo), is); }
|
|
| 30 |
+int read32le(uint32_t *Bufo, EMUFILE *is); |
|
| 31 |
+inline int read32le(int32_t *Bufo, EMUFILE *is) { return read32le(reinterpret_cast<uint32_t *>(Bufo), is); }
|
|
| 32 |
+int read64le(uint64_t *Bufo, EMUFILE *is); |
|
| 33 |
+inline int read_double_le(double *Bufo, EMUFILE *is) |
|
| 48 | 34 |
{
|
| 49 |
- CTASSERT(sizeof(T)==1||sizeof(T)==2||sizeof(T)==4||sizeof(T)==8); |
|
| 50 |
- switch(sizeof(T)) {
|
|
| 51 |
- case 1: return read8le((uint8_t*)Bufo,is); |
|
| 52 |
- case 2: return read16le((uint16_t*)Bufo,is); |
|
| 53 |
- case 4: return read32le((uint32_t*)Bufo,is); |
|
| 54 |
- case 8: return read64le((uint64_t*)Bufo,is); |
|
| 55 |
- default: |
|
| 56 |
- return 0; |
|
| 57 |
- } |
|
| 58 |
-}*/ |
|
| 35 |
+ uint64_t temp; |
|
| 36 |
+ int ret = read64le(&temp,is); |
|
| 37 |
+ *Bufo = u64_to_double(temp); |
|
| 38 |
+ return ret; |
|
| 39 |
+} |
|
| 40 |
+int read16le(uint16_t *Bufo, std::istream *is); |
|
| 59 | 41 |
|
| 60 |
-int readbool(bool *b, EMUFILE* is); |
|
| 61 |
-//void writebool(bool b, EMUFILE* os); |
|
| 42 |
+int readbool(bool *b, EMUFILE *is); |
|
| 62 | 43 |
|
| 63 |
-int readbuffer(std::vector<uint8_t> &vec, EMUFILE* is); |
|
| 64 |
-//int writebuffer(std::vector<uint8_t>& vec, EMUFILE* os); |
|
| 44 |
+int readbuffer(std::vector<uint8_t> &vec, EMUFILE *is); |
|
| 65 | 45 |
|
| 66 | 46 |
#endif |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,66 @@ |
| 1 |
+/* |
|
| 2 |
+ Copyright (C) 2008-2009 DeSmuME team |
|
| 3 |
+ |
|
| 4 |
+ This file is free software: you can redistribute it and/or modify |
|
| 5 |
+ it under the terms of the GNU General Public License as published by |
|
| 6 |
+ the Free Software Foundation, either version 2 of the License, or |
|
| 7 |
+ (at your option) any later version. |
|
| 8 |
+ |
|
| 9 |
+ This file is distributed in the hope that it will be useful, |
|
| 10 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 11 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 12 |
+ GNU General Public License for more details. |
|
| 13 |
+ |
|
| 14 |
+ You should have received a copy of the GNU General Public License |
|
| 15 |
+ along with the this software. If not, see <http://www.gnu.org/licenses/>. |
|
| 16 |
+*/ |
|
| 17 |
+ |
|
| 18 |
+#ifndef _READWRITE_H_ |
|
| 19 |
+#define _READWRITE_H_ |
|
| 20 |
+ |
|
| 21 |
+#include <iostream> |
|
| 22 |
+#include <vector> |
|
| 23 |
+#include <cstdio> |
|
| 24 |
+ |
|
| 25 |
+#include "types.h" |
|
| 26 |
+#include "emufile.h" |
|
| 27 |
+ |
|
| 28 |
+//well. just for the sake of consistency |
|
| 29 |
+//int write8le(uint8_t b, EMUFILE *fp); |
|
| 30 |
+//inline int write8le(uint8_t* b, EMUFILE *fp) { return write8le(*b,fp); }
|
|
| 31 |
+//int write16le(uint16_t b, EMUFILE* os); |
|
| 32 |
+//int write32le(uint32_t b, EMUFILE* os); |
|
| 33 |
+//int write64le(uint64_t b, EMUFILE* os); |
|
| 34 |
+//inline int write_double_le(double b, EMUFILE*is) { uint64_t temp = double_to_u64(b); int ret = write64le(temp,is); return ret; }
|
|
| 35 |
+ |
|
| 36 |
+int read8le(uint8_t *Bufo, EMUFILE*is); |
|
| 37 |
+int read16le(uint16_t *Bufo, EMUFILE*is); |
|
| 38 |
+inline int read16le(int16_t *Bufo, EMUFILE*is) { return read16le((uint16_t*)Bufo,is); }
|
|
| 39 |
+int read32le(uint32_t *Bufo, EMUFILE*is); |
|
| 40 |
+inline int read32le(int32_t *Bufo, EMUFILE*is) { return read32le((uint32_t*)Bufo,is); }
|
|
| 41 |
+int read64le(uint64_t *Bufo, EMUFILE*is); |
|
| 42 |
+inline int read_double_le(double *Bufo, EMUFILE*is) { uint64_t temp; int ret = read64le(&temp,is); *Bufo = u64_to_double(temp); return ret; }
|
|
| 43 |
+int read16le(uint16_t *Bufo, std::istream *is); |
|
| 44 |
+ |
|
| 45 |
+ |
|
| 46 |
+/*template<typename T> |
|
| 47 |
+int readle(T *Bufo, EMUFILE*is) |
|
| 48 |
+{
|
|
| 49 |
+ CTASSERT(sizeof(T)==1||sizeof(T)==2||sizeof(T)==4||sizeof(T)==8); |
|
| 50 |
+ switch(sizeof(T)) {
|
|
| 51 |
+ case 1: return read8le((uint8_t*)Bufo,is); |
|
| 52 |
+ case 2: return read16le((uint16_t*)Bufo,is); |
|
| 53 |
+ case 4: return read32le((uint32_t*)Bufo,is); |
|
| 54 |
+ case 8: return read64le((uint64_t*)Bufo,is); |
|
| 55 |
+ default: |
|
| 56 |
+ return 0; |
|
| 57 |
+ } |
|
| 58 |
+}*/ |
|
| 59 |
+ |
|
| 60 |
+int readbool(bool *b, EMUFILE* is); |
|
| 61 |
+//void writebool(bool b, EMUFILE* os); |
|
| 62 |
+ |
|
| 63 |
+int readbuffer(std::vector<uint8_t> &vec, EMUFILE* is); |
|
| 64 |
+//int writebuffer(std::vector<uint8_t>& vec, EMUFILE* os); |
|
| 65 |
+ |
|
| 66 |
+#endif |