Browse code

update for C++17 compliance, update to latest 2sf, add WINE cross-compile makefiles

Adam Higerd authored on 2021/02/11 15:36:17
Showing 1 changed files
... ...
@@ -24,7 +24,7 @@
24 24
 #include <cstdio>
25 25
 #include "types.h"
26 26
 #include "emufile.h"
27
-#include "windowsh_wrapper.h"
27
+//#include "windowsh_wrapper.h"
28 28
 
29 29
 #define MAX_SAVE_TYPES 13
30 30
 #define MC_TYPE_AUTODETECT      0x0
Browse code

Use #pragma once instead of include guards.

Naram Qashat authored on 2014/09/08 14:47:36
Showing 1 changed files
... ...
@@ -17,8 +17,7 @@
17 17
 	along with the this software.  If not, see <http://www.gnu.org/licenses/>.
18 18
 */
19 19
 
20
-#ifndef __FW_H__
21
-#define __FW_H__
20
+#pragma once
22 21
 
23 22
 #include <vector>
24 23
 #include <string>
... ...
@@ -162,5 +161,3 @@ struct SAVE_TYPE
162 161
 	int media_type;
163 162
 	int size;
164 163
 };
165
-
166
-#endif /*__FW_H__*/
Browse code

Updating in_2sf to use a newish version of DeSmuME, 0.9.9 from SVN. Somewhat cleaned up as well, but not everything because it's a pain in the ass.

Naram Qashat authored on 2013/04/18 17:22:55
Showing 1 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 /*
2 2
 	Copyright (C) 2006 thoduv
3 3
 	Copyright (C) 2006 Theo Berkau
4
-	Copyright (C) 2008-2012 DeSmuME team
4
+	Copyright (C) 2008-2013 DeSmuME team
5 5
 
6 6
 	This file is free software: you can redistribute it and/or modify
7 7
 	it under the terms of the GNU General Public License as published by
... ...
@@ -23,7 +23,6 @@
23 23
 #include <vector>
24 24
 #include <string>
25 25
 #include <cstdio>
26
-
27 26
 #include "types.h"
28 27
 #include "emufile.h"
29 28
 #include "windowsh_wrapper.h"
... ...
@@ -52,17 +51,16 @@
52 51
 
53 52
 struct memory_chip_t
54 53
 {
55
-	uint8_t com;	//persistent command actually handled
56
-	uint32_t addr;        //current address for reading/writing
57
-	uint8_t addr_shift;   //shift for address (since addresses are transfered by 3 bytes units)
58
-	uint8_t addr_size;    //size of addr when writing/reading
54
+	uint8_t com; // persistent command actually handled
55
+	uint32_t addr; // current address for reading/writing
56
+	uint8_t addr_shift; // shift for address (since addresses are transfered by 3 bytes units)
57
+	uint8_t addr_size; // size of addr when writing/reading
59 58
 
60
-	bool write_enable;	//is write enabled ?
59
+	bool write_enable; //is write enabled ?
61 60
 
62
-	//uint8_t *data;       //memory data
63
-	std::vector<uint8_t> data;
64
-	uint32_t size;       //memory size
65
-	bool writeable_buffer;	//is "data" writeable ?
61
+	std::vector<uint8_t> data; //memory data
62
+	uint32_t size; // memory size
63
+	bool writeable_buffer; // is "data" writeable ?
66 64
 	int type; //type of Memory
67 65
 	char *filename;
68 66
 	FILE *fp;
... ...
@@ -74,114 +72,95 @@ struct memory_chip_t
74 72
 	char userfile[MAX_PATH];
75 73
 };
76 74
 
77
-//the new backup system by zeromus
75
+// the new backup system by zeromus
78 76
 class BackupDevice
79 77
 {
80 78
 public:
81 79
 	BackupDevice();
82 80
 
83
-	//signals the save system that we are in our regular mode, loading up a rom. initializes for that case.
84
-	void load_rom(const char* filename);
85
-	//signals the save system that we are in MOVIE mode. doesnt load up a rom, and never saves it. initializes for that case.
86
-	//void movie_mode();
81
+	// signals the save system that we are in our regular mode, loading up a rom. initializes for that case.
82
+	void load_rom(const std::string &filename);
87 83
 
88 84
 	void reset();
89
-	//void close_rom();
90
-	//void forceManualBackupType();
91 85
 	void reset_hardware();
92 86
 	std::string getFilename() { return filename; }
93 87
 
94
-	//bool save_state(EMUFILE* os);
95
-	bool load_state(EMUFILE* is);
96
-
97
-	//commands from mmu
98
-	//void reset_command();
99
-	//uint8_t data_command(uint8_t,int);
100 88
 	std::vector<uint8_t> data;
101 89
 
102
-	//this info was saved before the last reset (used for savestate compatibility)
90
+	// this info was saved before the last reset (used for savestate compatibility)
103 91
 	struct SavedInfo
104 92
 	{
105 93
 		uint32_t addr_size;
106 94
 	} savedInfo;
107 95
 
108
-	//and these are used by old savestates
109
-	void load_old_state(uint32_t addr_size, uint8_t* data, uint32_t datasize);
96
+	// and these are used by old savestates
97
+	void load_old_state(uint32_t addr_size, uint8_t *data, uint32_t datasize);
110 98
 	static uint32_t addr_size_for_old_save_size(int bupmem_size);
111 99
 	static uint32_t addr_size_for_old_save_type(int bupmem_type);
112 100
 
113
-	//static uint32_t pad_up_size(uint32_t startSize);
114
-	void raw_applyUserSettings(uint32_t& size, bool manual = false);
101
+	void raw_applyUserSettings(uint32_t &size, bool manual = false);
115 102
 
116
-	//bool load_duc(const char* filename);
117 103
 	bool load_no_gba(const char *fname);
118
-	//bool save_no_gba(const char* fname);
119 104
 	bool load_raw(const char* filename, uint32_t force_size = 0);
120
-	//bool save_raw(const char* filename);
121
-	//bool load_movie(EMUFILE* is);
122
-
123
-	//call me once a second or so to lazy flush the save data
124
-	//here's the reason for this system: we want to dump save files when theyre READ
125
-	//so that we have a better idea earlier on how large they are. but it slows things down
126
-	//way too much if we flush whenever we read.
127
-	//void lazy_flush();
128
-	//void flush();
129
-
130
-	struct {
131
-			uint32_t size,padSize,type,addr_size,mem_size;
132
-		} info;
133
-	//bool isMovieMode;
134 105
 
106
+	struct
107
+	{
108
+		uint32_t size, padSize, type, addr_size, mem_size;
109
+	} info;
135 110
 private:
136 111
 	std::string filename;
137 112
 
138
-	bool write_enable;	//is write enabled?
139
-	uint32_t com;	//persistent command actually handled
113
+	bool write_enable; // is write enabled?
114
+	uint32_t com; // persistent command actually handled
140 115
 	uint32_t addr_size, addr_counter;
141 116
 	uint32_t addr;
142 117
 
143 118
 	std::vector<uint8_t> data_autodetect;
144
-	enum STATE {
145
-		DETECTING = 0, RUNNING = 1
119
+	enum STATE
120
+	{
121
+		DETECTING = 0,
122
+		RUNNING = 1
146 123
 	} state;
147 124
 
148 125
 	enum MOTION_INIT_STATE
149 126
 	{
150
-		MOTION_INIT_STATE_IDLE, MOTION_INIT_STATE_RECEIVED_4, MOTION_INIT_STATE_RECEIVED_4_B,
151
-		MOTION_INIT_STATE_FE, MOTION_INIT_STATE_FD, MOTION_INIT_STATE_FB
127
+		MOTION_INIT_STATE_IDLE,
128
+		MOTION_INIT_STATE_RECEIVED_4,
129
+		MOTION_INIT_STATE_RECEIVED_4_B,
130
+		MOTION_INIT_STATE_FE,
131
+		MOTION_INIT_STATE_FD,
132
+		MOTION_INIT_STATE_FB
152 133
 	};
153 134
 	enum MOTION_FLAG
154 135
 	{
155
-		MOTION_FLAG_NONE=0,
156
-		MOTION_FLAG_ENABLED=1,
157
-		MOTION_FLAG_SENSORMODE=2
136
+		MOTION_FLAG_NONE,
137
+		MOTION_FLAG_ENABLED,
138
+		MOTION_FLAG_SENSORMODE
158 139
 	};
159 140
 	uint8_t motionInitState, motionFlag;
160 141
 
161 142
 	void loadfile();
162
-	bool _loadfile(const char *fname);
163 143
 	void ensure(uint32_t addr);
164 144
 
165 145
 	bool flushPending, lazyFlushPending;
166 146
 
167
-private:
168 147
 	void resize(uint32_t size);
169 148
 };
170 149
 
171
-#define NDS_FW_SIZE_V1 (256 * 1024)		/* size of fw memory on nds v1 */
172
-#define NDS_FW_SIZE_V2 (512 * 1024)		/* size of fw memory on nds v2 */
150
+#define NDS_FW_SIZE_V1 (256 * 1024) /* size of fw memory on nds v1 */
151
+#define NDS_FW_SIZE_V2 (512 * 1024) /* size of fw memory on nds v2 */
173 152
 
174
-void mc_init(memory_chip_t *mc, int type);    /* reset and init values for memory struct */
175
-uint8_t *mc_alloc(memory_chip_t *mc, uint32_t size);  /* alloc mc memory */
176
-//void mc_realloc(memory_chip_t *mc, int type, uint32_t size);      /* realloc mc memory */
177
-//void mc_load_file(memory_chip_t *mc, const char* filename); /* load save file and setup fp */
178
-void mc_free(memory_chip_t *mc);    /* delete mc memory */
179
-void fw_reset_com(memory_chip_t *mc);       /* reset communication with mc */
153
+void mc_init(memory_chip_t *mc, int type); /* reset and init values for memory struct */
154
+uint8_t *mc_alloc(memory_chip_t *mc, uint32_t size); /* alloc mc memory */
155
+void mc_free(memory_chip_t *mc); /* delete mc memory */
156
+void fw_reset_com(memory_chip_t *mc); /* reset communication with mc */
180 157
 uint8_t fw_transfer(memory_chip_t *mc, uint8_t data);
181 158
 
182
-//void backup_setManualBackupType(int type);
183
-//void backup_forceManualBackupType();
184
-
185
-//extern const char *save_names[];
159
+struct SAVE_TYPE
160
+{
161
+	const char *descr;
162
+	int media_type;
163
+	int size;
164
+};
186 165
 
187 166
 #endif /*__FW_H__*/
Browse code

Import actual code.

Naram Qashat authored on 2013/03/26 02:41:19
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,187 @@
1
+/*
2
+	Copyright (C) 2006 thoduv
3
+	Copyright (C) 2006 Theo Berkau
4
+	Copyright (C) 2008-2012 DeSmuME team
5
+
6
+	This file is free software: you can redistribute it and/or modify
7
+	it under the terms of the GNU General Public License as published by
8
+	the Free Software Foundation, either version 2 of the License, or
9
+	(at your option) any later version.
10
+
11
+	This file is distributed in the hope that it will be useful,
12
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+	GNU General Public License for more details.
15
+
16
+	You should have received a copy of the GNU General Public License
17
+	along with the this software.  If not, see <http://www.gnu.org/licenses/>.
18
+*/
19
+
20
+#ifndef __FW_H__
21
+#define __FW_H__
22
+
23
+#include <vector>
24
+#include <string>
25
+#include <cstdio>
26
+
27
+#include "types.h"
28
+#include "emufile.h"
29
+#include "windowsh_wrapper.h"
30
+
31
+#define MAX_SAVE_TYPES 13
32
+#define MC_TYPE_AUTODETECT      0x0
33
+#define MC_TYPE_EEPROM1         0x1
34
+#define MC_TYPE_EEPROM2         0x2
35
+#define MC_TYPE_FLASH           0x3
36
+#define MC_TYPE_FRAM            0x4
37
+
38
+#define MC_SIZE_4KBITS                  0x000200
39
+#define MC_SIZE_64KBITS                 0x002000
40
+#define MC_SIZE_256KBITS                0x008000
41
+#define MC_SIZE_512KBITS                0x010000
42
+#define MC_SIZE_1MBITS                  0x020000
43
+#define MC_SIZE_2MBITS                  0x040000
44
+#define MC_SIZE_4MBITS                  0x080000
45
+#define MC_SIZE_8MBITS                  0x100000
46
+#define MC_SIZE_16MBITS                 0x200000
47
+#define MC_SIZE_32MBITS                 0x400000
48
+#define MC_SIZE_64MBITS                 0x800000
49
+#define MC_SIZE_128MBITS                0x1000000
50
+#define MC_SIZE_256MBITS                0x2000000
51
+#define MC_SIZE_512MBITS                0x4000000
52
+
53
+struct memory_chip_t
54
+{
55
+	uint8_t com;	//persistent command actually handled
56
+	uint32_t addr;        //current address for reading/writing
57
+	uint8_t addr_shift;   //shift for address (since addresses are transfered by 3 bytes units)
58
+	uint8_t addr_size;    //size of addr when writing/reading
59
+
60
+	bool write_enable;	//is write enabled ?
61
+
62
+	//uint8_t *data;       //memory data
63
+	std::vector<uint8_t> data;
64
+	uint32_t size;       //memory size
65
+	bool writeable_buffer;	//is "data" writeable ?
66
+	int type; //type of Memory
67
+	char *filename;
68
+	FILE *fp;
69
+	uint8_t autodetectbuf[32768];
70
+	int autodetectsize;
71
+
72
+	// needs only for firmware
73
+	bool isFirmware;
74
+	char userfile[MAX_PATH];
75
+};
76
+
77
+//the new backup system by zeromus
78
+class BackupDevice
79
+{
80
+public:
81
+	BackupDevice();
82
+
83
+	//signals the save system that we are in our regular mode, loading up a rom. initializes for that case.
84
+	void load_rom(const char* filename);
85
+	//signals the save system that we are in MOVIE mode. doesnt load up a rom, and never saves it. initializes for that case.
86
+	//void movie_mode();
87
+
88
+	void reset();
89
+	//void close_rom();
90
+	//void forceManualBackupType();
91
+	void reset_hardware();
92
+	std::string getFilename() { return filename; }
93
+
94
+	//bool save_state(EMUFILE* os);
95
+	bool load_state(EMUFILE* is);
96
+
97
+	//commands from mmu
98
+	//void reset_command();
99
+	//uint8_t data_command(uint8_t,int);
100
+	std::vector<uint8_t> data;
101
+
102
+	//this info was saved before the last reset (used for savestate compatibility)
103
+	struct SavedInfo
104
+	{
105
+		uint32_t addr_size;
106
+	} savedInfo;
107
+
108
+	//and these are used by old savestates
109
+	void load_old_state(uint32_t addr_size, uint8_t* data, uint32_t datasize);
110
+	static uint32_t addr_size_for_old_save_size(int bupmem_size);
111
+	static uint32_t addr_size_for_old_save_type(int bupmem_type);
112
+
113
+	//static uint32_t pad_up_size(uint32_t startSize);
114
+	void raw_applyUserSettings(uint32_t& size, bool manual = false);
115
+
116
+	//bool load_duc(const char* filename);
117
+	bool load_no_gba(const char *fname);
118
+	//bool save_no_gba(const char* fname);
119
+	bool load_raw(const char* filename, uint32_t force_size = 0);
120
+	//bool save_raw(const char* filename);
121
+	//bool load_movie(EMUFILE* is);
122
+
123
+	//call me once a second or so to lazy flush the save data
124
+	//here's the reason for this system: we want to dump save files when theyre READ
125
+	//so that we have a better idea earlier on how large they are. but it slows things down
126
+	//way too much if we flush whenever we read.
127
+	//void lazy_flush();
128
+	//void flush();
129
+
130
+	struct {
131
+			uint32_t size,padSize,type,addr_size,mem_size;
132
+		} info;
133
+	//bool isMovieMode;
134
+
135
+private:
136
+	std::string filename;
137
+
138
+	bool write_enable;	//is write enabled?
139
+	uint32_t com;	//persistent command actually handled
140
+	uint32_t addr_size, addr_counter;
141
+	uint32_t addr;
142
+
143
+	std::vector<uint8_t> data_autodetect;
144
+	enum STATE {
145
+		DETECTING = 0, RUNNING = 1
146
+	} state;
147
+
148
+	enum MOTION_INIT_STATE
149
+	{
150
+		MOTION_INIT_STATE_IDLE, MOTION_INIT_STATE_RECEIVED_4, MOTION_INIT_STATE_RECEIVED_4_B,
151
+		MOTION_INIT_STATE_FE, MOTION_INIT_STATE_FD, MOTION_INIT_STATE_FB
152
+	};
153
+	enum MOTION_FLAG
154
+	{
155
+		MOTION_FLAG_NONE=0,
156
+		MOTION_FLAG_ENABLED=1,
157
+		MOTION_FLAG_SENSORMODE=2
158
+	};
159
+	uint8_t motionInitState, motionFlag;
160
+
161
+	void loadfile();
162
+	bool _loadfile(const char *fname);
163
+	void ensure(uint32_t addr);
164
+
165
+	bool flushPending, lazyFlushPending;
166
+
167
+private:
168
+	void resize(uint32_t size);
169
+};
170
+
171
+#define NDS_FW_SIZE_V1 (256 * 1024)		/* size of fw memory on nds v1 */
172
+#define NDS_FW_SIZE_V2 (512 * 1024)		/* size of fw memory on nds v2 */
173
+
174
+void mc_init(memory_chip_t *mc, int type);    /* reset and init values for memory struct */
175
+uint8_t *mc_alloc(memory_chip_t *mc, uint32_t size);  /* alloc mc memory */
176
+//void mc_realloc(memory_chip_t *mc, int type, uint32_t size);      /* realloc mc memory */
177
+//void mc_load_file(memory_chip_t *mc, const char* filename); /* load save file and setup fp */
178
+void mc_free(memory_chip_t *mc);    /* delete mc memory */
179
+void fw_reset_com(memory_chip_t *mc);       /* reset communication with mc */
180
+uint8_t fw_transfer(memory_chip_t *mc, uint8_t data);
181
+
182
+//void backup_setManualBackupType(int type);
183
+//void backup_forceManualBackupType();
184
+
185
+//extern const char *save_names[];
186
+
187
+#endif /*__FW_H__*/