Browse code

* Small Makefile changes.

* Removed a couple files that were not being used.
* Cleanups found with clang's -Weverything (and shutting it up about a
lot of things that were ridiculous, as well as ignoring some of the
warnings still coming up).

Naram Qashat authored on 2014/09/25 12:28:21
Showing 1 changed files
... ...
@@ -103,7 +103,6 @@ static uint32_t read32_GCDATAIN(uint8_t PROCNUM)
103 103
 				else
104 104
 					return 0;
105 105
 			}
106
-			break;
107 106
 
108 107
 		// Data read
109 108
 		case 0x00:
... ...
@@ -135,7 +134,6 @@ static uint32_t read32_GCDATAIN(uint8_t PROCNUM)
135 134
 
136 135
 				return T1ReadLong(MMU.CART_ROM, address);
137 136
 			}
138
-			break;
139 137
 		default:
140 138
 			return 0;
141 139
 	} //switch(card.command[0])
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
... ...
@@ -40,7 +40,7 @@ static void write32_GCROMCTRL(uint8_t PROCNUM, uint32_t)
40 40
 
41 41
 	switch (card.command[0])
42 42
 	{
43
-		case 0x00: //Data read
43
+		case 0x00: // Data read
44 44
 		case 0xB7:
45 45
 			card.address = (card.command[1] << 24) | (card.command[2] << 16) | (card.command[3] << 8) | card.command[4];
46 46
 			card.transfer_count = 0x80;
... ...
@@ -90,10 +90,13 @@ static uint32_t read32_GCDATAIN(uint8_t PROCNUM)
90 90
 				// Most games continuously compare the chip ID with
91 91
 				// the value in memory, probably to know if the card
92 92
 				// was removed.
93
-				// As DeSmuME boots directly from the game, the chip
93
+				// As DeSmuME normally boots directly from the game, the chip
94 94
 				// ID in main mem is zero and this value needs to be
95 95
 				// zero too.
96 96
 
97
+				// note that even if desmume was booting from firmware, and reading this chip ID to store in main memory,
98
+				// this still works, since it will have read 00 originally and then read 00 to validate.
99
+
97 100
 				// staff of kings verifies this (it also uses the arm7 IRQ 20)
98 101
 				if (nds.cardEjected) // TODO - handle this with ejected card slot1 device (and verify using this case)
99 102
 					return 0xFFFFFFFF;
... ...
@@ -106,20 +109,20 @@ static uint32_t read32_GCDATAIN(uint8_t PROCNUM)
106 109
 		case 0x00:
107 110
 		case 0xB7:
108 111
 			{
109
-				//it seems that etrian odyssey 3 doesnt work unless we mask this to cart size.
110
-				//but, a thought: does the internal rom address counter register wrap around? we may be making a mistake by keeping the extra precision
111
-				//but there is no test case yet
112
-				uint32_t address = card.address & (gameInfo.mask);
112
+				// it seems that etrian odyssey 3 doesnt work unless we mask this to cart size.
113
+				// but, a thought: does the internal rom address counter register wrap around? we may be making a mistake by keeping the extra precision
114
+				// but there is no test case yet
115
+				uint32_t address = card.address & gameInfo.mask;
113 116
 
114 117
 				// Make sure any reads below 0x8000 redirect to 0x8000+(adr&0x1FF) as on real cart
115
-				if((card.command[0] == 0xB7) && (address < 0x8000))
118
+				if (card.command[0] == 0xB7 && address < 0x8000)
116 119
 				{
117 120
 					// TODO - refactor this to include the PROCNUM, for debugging purposes if nothing else
118 121
 					// (can refactor gbaslot also)
119 122
 
120 123
 					//INFO("Read below 0x8000 (0x%04X) from: ARM%s %08X\n", card.address, (PROCNUM ? "7":"9"), (PROCNUM ? NDS_ARM7:NDS_ARM9).instruct_adr);
121 124
 
122
-					address = (0x8000 + (address&0x1FF));
125
+					address = 0x8000 + (address & 0x1FF);
123 126
 				}
124 127
 
125 128
 				// as a sanity measure for funny-sized roms (homebrew and perhaps truncated retail roms)
... ...
@@ -140,7 +143,7 @@ static uint32_t read32_GCDATAIN(uint8_t PROCNUM)
140 143
 
141 144
 static uint32_t read32(uint8_t PROCNUM, uint32_t adr)
142 145
 {
143
-	switch(adr)
146
+	switch (adr)
144 147
 	{
145 148
 		case REG_GCDATAIN:
146 149
 			return read32_GCDATAIN(PROCNUM);
... ...
@@ -164,115 +167,3 @@ SLOT1INTERFACE slot1Retail =
164 167
 	read32,
165 168
 	info
166 169
 };
167
-
168
-	//		///writetoGCControl:
169
-	//// --- Ninja SD commands -------------------------------------
170
-
171
-	//	// NJSD init/reset
172
-	//	case 0x20:
173
-	//		{
174
-	//			card.address = 0;
175
-	//			card.transfer_count = 0;
176
-	//		}
177
-	//		break;
178
-
179
-	//	// NJSD_sendCLK()
180
-	//	case 0xE0:
181
-	//		{
182
-	//			card.address = 0;
183
-	//			card.transfer_count = 0;
184
-	//			NDS_makeInt(PROCNUM, 20);
185
-	//		}
186
-	//		break;
187
-
188
-	//	// NJSD_sendCMDN() / NJSD_sendCMDR()
189
-	//	case 0xF0:
190
-	//	case 0xF1:
191
-	//		switch (card.command[2])
192
-	//		{
193
-	//		// GO_IDLE_STATE
194
-	//		case 0x40:
195
-	//			card.address = 0;
196
-	//			card.transfer_count = 0;
197
-	//			NDS_makeInt(PROCNUM, 20);
198
-	//			break;
199
-
200
-	//		case 0x42:  // ALL_SEND_CID
201
-	//		case 0x43:  // SEND_RELATIVE_ADDR
202
-	//		case 0x47:  // SELECT_CARD
203
-	//		case 0x49:  // SEND_CSD
204
-	//		case 0x4D:
205
-	//		case 0x77:  // APP_CMD
206
-	//		case 0x69:  // SD_APP_OP_COND
207
-	//			card.address = 0;
208
-	//			card.transfer_count = 6;
209
-	//			NDS_makeInt(PROCNUM, 20);
210
-	//			break;
211
-
212
-	//		// SET_BLOCKLEN
213
-	//		case 0x50:
214
-	//			card.address = 0;
215
-	//			card.transfer_count = 6;
216
-	//			card.blocklen = card.command[6] | (card.command[5] << 8) | (card.command[4] << 16) | (card.command[3] << 24);
217
-	//			NDS_makeInt(PROCNUM, 20);
218
-	//			break;
219
-
220
-	//		// READ_SINGLE_BLOCK
221
-	//		case 0x51:
222
-	//			card.address = card.command[6] | (card.command[5] << 8) | (card.command[4] << 16) | (card.command[3] << 24);
223
-	//			card.transfer_count = (card.blocklen + 3) >> 2;
224
-	//			NDS_makeInt(PROCNUM, 20);
225
-	//			break;
226
-	//		}
227
-	//		break;
228
-
229
-	//	// --- Ninja SD commands end ---------------------------------
230
-
231
-
232
-
233
-	//		//GCDATAIN:
234
-	//	// --- Ninja SD commands -------------------------------------
235
-
236
-	//	// NJSD_sendCMDN() / NJSD_sendCMDR()
237
-	//	case 0xF0:
238
-	//	case 0xF1:
239
-	//		switch (card.command[2])
240
-	//		{
241
-	//		// ALL_SEND_CID
242
-	//		case 0x42:
243
-	//			if (card.transfer_count == 2) val = 0x44534A4E;
244
-	//			else val = 0x00000000;
245
-
246
-	//		// SEND_RELATIVE_ADDR
247
-	//		case 0x43:
248
-	//		case 0x47:
249
-	//		case 0x49:
250
-	//		case 0x50:
251
-	//			val = 0x00000000;
252
-	//			break;
253
-
254
-	//		case 0x4D:
255
-	//			if (card.transfer_count == 2) val = 0x09000000;
256
-	//			else val = 0x00000000;
257
-	//			break;
258
-
259
-	//		// APP_CMD
260
-	//		case 0x77:
261
-	//			if (card.transfer_count == 2) val = 0x00000037;
262
-	//			else val = 0x00000000;
263
-	//			break;
264
-
265
-	//		// SD_APP_OP_COND
266
-	//		case 0x69:
267
-	//			if (card.transfer_count == 2) val = 0x00008000;
268
-	//			else val = 0x00000000;
269
-	//			break;
270
-
271
-	//		// READ_SINGLE_BLOCK
272
-	//		case 0x51:
273
-	//			val = 0x00000000;
274
-	//			break;
275
-	//		}
276
-	//		break;
277
-
278
-	//	// --- Ninja SD commands end ---------------------------------
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,278 @@
1
+/*  Copyright (C) 2010-2011 DeSmuME team
2
+
3
+    This file is part of DeSmuME
4
+
5
+    DeSmuME is free software; you can redistribute it and/or modify
6
+    it under the terms of the GNU General Public License as published by
7
+    the Free Software Foundation; either version 2 of the License, or
8
+    (at your option) any later version.
9
+
10
+    DeSmuME is distributed in the hope that it will be useful,
11
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+    GNU General Public License for more details.
14
+
15
+    You should have received a copy of the GNU General Public License
16
+    along with DeSmuME; if not, write to the Free Software
17
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
18
+*/
19
+
20
+#include "../slot1.h"
21
+#include "../registers.h"
22
+#include "../MMU.h"
23
+#include "../NDSSystem.h"
24
+
25
+static void info(char *info) { strcpy(info, "Slot1 Retail card emulation"); }
26
+static void config() {}
27
+
28
+static bool init() { return true; }
29
+
30
+static void reset() {}
31
+
32
+static void close() {}
33
+
34
+static void write08(uint8_t, uint32_t, uint8_t) {}
35
+static void write16(uint8_t, uint32_t, uint16_t) {}
36
+
37
+static void write32_GCROMCTRL(uint8_t PROCNUM, uint32_t)
38
+{
39
+	nds_dscard &card = MMU.dscard[PROCNUM];
40
+
41
+	switch (card.command[0])
42
+	{
43
+		case 0x00: //Data read
44
+		case 0xB7:
45
+			card.address = (card.command[1] << 24) | (card.command[2] << 16) | (card.command[3] << 8) | card.command[4];
46
+			card.transfer_count = 0x80;
47
+			break;
48
+
49
+		case 0xB8: // Chip ID
50
+			card.address = 0;
51
+			card.transfer_count = 1;
52
+			break;
53
+
54
+		default:
55
+			card.address = 0;
56
+			card.transfer_count = 0;
57
+	}
58
+}
59
+
60
+static void write32(uint8_t PROCNUM, uint32_t adr, uint32_t val)
61
+{
62
+	switch (adr)
63
+	{
64
+		case REG_GCROMCTRL:
65
+			write32_GCROMCTRL(PROCNUM, val);
66
+	}
67
+}
68
+
69
+static uint8_t read08(uint8_t, uint32_t)
70
+{
71
+	return 0xFF;
72
+}
73
+
74
+static uint16_t read16(uint8_t, uint32_t)
75
+{
76
+	return 0xFFFF;
77
+}
78
+
79
+static uint32_t read32_GCDATAIN(uint8_t PROCNUM)
80
+{
81
+	nds_dscard &card = MMU.dscard[PROCNUM];
82
+
83
+	switch (card.command[0])
84
+	{
85
+		// Get ROM chip ID
86
+		case 0x90:
87
+		case 0xB8:
88
+			{
89
+				// Note: the BIOS stores the chip ID in main memory
90
+				// Most games continuously compare the chip ID with
91
+				// the value in memory, probably to know if the card
92
+				// was removed.
93
+				// As DeSmuME boots directly from the game, the chip
94
+				// ID in main mem is zero and this value needs to be
95
+				// zero too.
96
+
97
+				// staff of kings verifies this (it also uses the arm7 IRQ 20)
98
+				if (nds.cardEjected) // TODO - handle this with ejected card slot1 device (and verify using this case)
99
+					return 0xFFFFFFFF;
100
+				else
101
+					return 0;
102
+			}
103
+			break;
104
+
105
+		// Data read
106
+		case 0x00:
107
+		case 0xB7:
108
+			{
109
+				//it seems that etrian odyssey 3 doesnt work unless we mask this to cart size.
110
+				//but, a thought: does the internal rom address counter register wrap around? we may be making a mistake by keeping the extra precision
111
+				//but there is no test case yet
112
+				uint32_t address = card.address & (gameInfo.mask);
113
+
114
+				// Make sure any reads below 0x8000 redirect to 0x8000+(adr&0x1FF) as on real cart
115
+				if((card.command[0] == 0xB7) && (address < 0x8000))
116
+				{
117
+					// TODO - refactor this to include the PROCNUM, for debugging purposes if nothing else
118
+					// (can refactor gbaslot also)
119
+
120
+					//INFO("Read below 0x8000 (0x%04X) from: ARM%s %08X\n", card.address, (PROCNUM ? "7":"9"), (PROCNUM ? NDS_ARM7:NDS_ARM9).instruct_adr);
121
+
122
+					address = (0x8000 + (address&0x1FF));
123
+				}
124
+
125
+				// as a sanity measure for funny-sized roms (homebrew and perhaps truncated retail roms)
126
+				// we need to protect ourselves by returning 0xFF for things still out of range
127
+				if (address >= gameInfo.romsize)
128
+				{
129
+					//DEBUG_Notify.ReadBeyondEndOfCart(address, gameInfo. romsize);
130
+					return 0xFFFFFFFF;
131
+				}
132
+
133
+				return T1ReadLong(MMU.CART_ROM, address);
134
+			}
135
+			break;
136
+		default:
137
+			return 0;
138
+	} //switch(card.command[0])
139
+} //read32_GCDATAIN
140
+
141
+static uint32_t read32(uint8_t PROCNUM, uint32_t adr)
142
+{
143
+	switch(adr)
144
+	{
145
+		case REG_GCDATAIN:
146
+			return read32_GCDATAIN(PROCNUM);
147
+		default:
148
+			return 0;
149
+	}
150
+}
151
+
152
+SLOT1INTERFACE slot1Retail =
153
+{
154
+	"Retail",
155
+	init,
156
+	reset,
157
+	close,
158
+	config,
159
+	write08,
160
+	write16,
161
+	write32,
162
+	read08,
163
+	read16,
164
+	read32,
165
+	info
166
+};
167
+
168
+	//		///writetoGCControl:
169
+	//// --- Ninja SD commands -------------------------------------
170
+
171
+	//	// NJSD init/reset
172
+	//	case 0x20:
173
+	//		{
174
+	//			card.address = 0;
175
+	//			card.transfer_count = 0;
176
+	//		}
177
+	//		break;
178
+
179
+	//	// NJSD_sendCLK()
180
+	//	case 0xE0:
181
+	//		{
182
+	//			card.address = 0;
183
+	//			card.transfer_count = 0;
184
+	//			NDS_makeInt(PROCNUM, 20);
185
+	//		}
186
+	//		break;
187
+
188
+	//	// NJSD_sendCMDN() / NJSD_sendCMDR()
189
+	//	case 0xF0:
190
+	//	case 0xF1:
191
+	//		switch (card.command[2])
192
+	//		{
193
+	//		// GO_IDLE_STATE
194
+	//		case 0x40:
195
+	//			card.address = 0;
196
+	//			card.transfer_count = 0;
197
+	//			NDS_makeInt(PROCNUM, 20);
198
+	//			break;
199
+
200
+	//		case 0x42:  // ALL_SEND_CID
201
+	//		case 0x43:  // SEND_RELATIVE_ADDR
202
+	//		case 0x47:  // SELECT_CARD
203
+	//		case 0x49:  // SEND_CSD
204
+	//		case 0x4D:
205
+	//		case 0x77:  // APP_CMD
206
+	//		case 0x69:  // SD_APP_OP_COND
207
+	//			card.address = 0;
208
+	//			card.transfer_count = 6;
209
+	//			NDS_makeInt(PROCNUM, 20);
210
+	//			break;
211
+
212
+	//		// SET_BLOCKLEN
213
+	//		case 0x50:
214
+	//			card.address = 0;
215
+	//			card.transfer_count = 6;
216
+	//			card.blocklen = card.command[6] | (card.command[5] << 8) | (card.command[4] << 16) | (card.command[3] << 24);
217
+	//			NDS_makeInt(PROCNUM, 20);
218
+	//			break;
219
+
220
+	//		// READ_SINGLE_BLOCK
221
+	//		case 0x51:
222
+	//			card.address = card.command[6] | (card.command[5] << 8) | (card.command[4] << 16) | (card.command[3] << 24);
223
+	//			card.transfer_count = (card.blocklen + 3) >> 2;
224
+	//			NDS_makeInt(PROCNUM, 20);
225
+	//			break;
226
+	//		}
227
+	//		break;
228
+
229
+	//	// --- Ninja SD commands end ---------------------------------
230
+
231
+
232
+
233
+	//		//GCDATAIN:
234
+	//	// --- Ninja SD commands -------------------------------------
235
+
236
+	//	// NJSD_sendCMDN() / NJSD_sendCMDR()
237
+	//	case 0xF0:
238
+	//	case 0xF1:
239
+	//		switch (card.command[2])
240
+	//		{
241
+	//		// ALL_SEND_CID
242
+	//		case 0x42:
243
+	//			if (card.transfer_count == 2) val = 0x44534A4E;
244
+	//			else val = 0x00000000;
245
+
246
+	//		// SEND_RELATIVE_ADDR
247
+	//		case 0x43:
248
+	//		case 0x47:
249
+	//		case 0x49:
250
+	//		case 0x50:
251
+	//			val = 0x00000000;
252
+	//			break;
253
+
254
+	//		case 0x4D:
255
+	//			if (card.transfer_count == 2) val = 0x09000000;
256
+	//			else val = 0x00000000;
257
+	//			break;
258
+
259
+	//		// APP_CMD
260
+	//		case 0x77:
261
+	//			if (card.transfer_count == 2) val = 0x00000037;
262
+	//			else val = 0x00000000;
263
+	//			break;
264
+
265
+	//		// SD_APP_OP_COND
266
+	//		case 0x69:
267
+	//			if (card.transfer_count == 2) val = 0x00008000;
268
+	//			else val = 0x00000000;
269
+	//			break;
270
+
271
+	//		// READ_SINGLE_BLOCK
272
+	//		case 0x51:
273
+	//			val = 0x00000000;
274
+	//			break;
275
+	//		}
276
+	//		break;
277
+
278
+	//	// --- Ninja SD commands end ---------------------------------