Mercurial > sdl-ios-xcode
comparison src/haptic/nds/SDL_syshaptic.c @ 2750:e3affc66d963
Fixes to the NDS sprite2 test. Illustrates partially working texture-as-sprite functionality.
author | Darren Alton <dalton@stevens.edu> |
---|---|
date | Sat, 06 Sep 2008 04:31:34 +0000 |
parents | 1c5f440a60fe |
children | 8f4ed5ec2b06 |
comparison
equal
deleted
inserted
replaced
2749:1c5f440a60fe | 2750:e3affc66d963 |
---|---|
42 int pos; | 42 int pos; |
43 } NDS_HapticData; | 43 } NDS_HapticData; |
44 | 44 |
45 | 45 |
46 | 46 |
47 void NDS_EZF_OpenNorWrite() | 47 void |
48 { | 48 NDS_EZF_OpenNorWrite() |
49 GBA_BUS[0x0FF0000] = 0xD200; | 49 { |
50 GBA_BUS[0x0000000] = 0x1500; | 50 |
51 GBA_BUS[0x0010000] = 0xD200; | 51 GBA_BUS[0x0FF0000] = 0xD200; |
52 GBA_BUS[0x0020000] = 0x1500; | 52 |
53 GBA_BUS[0x0E20000] = 0x1500; | 53 GBA_BUS[0x0000000] = 0x1500; |
54 GBA_BUS[0x0FE0000] = 0x1500; | 54 |
55 } | 55 GBA_BUS[0x0010000] = 0xD200; |
56 | 56 |
57 | 57 GBA_BUS[0x0020000] = 0x1500; |
58 void NDS_EZF_CloseNorWrite() | 58 |
59 { | 59 GBA_BUS[0x0E20000] = 0x1500; |
60 GBA_BUS[0x0FF0000] = 0xD200; | 60 |
61 GBA_BUS[0x0000000] = 0x1500; | 61 GBA_BUS[0x0FE0000] = 0x1500; |
62 GBA_BUS[0x0010000] = 0xD200; | 62 |
63 GBA_BUS[0x0020000] = 0x1500; | 63 } |
64 GBA_BUS[0x0E20000] = 0xD200; | 64 |
65 GBA_BUS[0x0FE0000] = 0x1500; | 65 |
66 } | 66 void |
67 | 67 |
68 void NDS_EZF_ChipReset() | 68 NDS_EZF_CloseNorWrite() |
69 { | 69 { |
70 GBA_BUS[0x0000] = 0x00F0 ; | 70 |
71 GBA_BUS[0x1000] = 0x00F0 ; | 71 GBA_BUS[0x0FF0000] = 0xD200; |
72 } | 72 |
73 uint32 NDS_EZF_IsPresent() | 73 GBA_BUS[0x0000000] = 0x1500; |
74 { | 74 |
75 vuint16 id1,id2; | 75 GBA_BUS[0x0010000] = 0xD200; |
76 | |
77 GBA_BUS[0x0020000] = 0x1500; | |
78 | |
79 GBA_BUS[0x0E20000] = 0xD200; | |
80 | |
81 GBA_BUS[0x0FE0000] = 0x1500; | |
82 | |
83 } | |
84 | |
85 void | |
86 NDS_EZF_ChipReset() | |
87 { | |
88 | |
89 GBA_BUS[0x0000] = 0x00F0; | |
90 | |
91 GBA_BUS[0x1000] = 0x00F0; | |
92 } | |
93 uint32 NDS_EZF_IsPresent() | |
94 { | |
95 | |
96 vuint16 id1, id2; | |
76 | 97 |
77 NDS_EZF_OpenNorWrite(); | 98 NDS_EZF_OpenNorWrite(); |
78 | 99 |
79 GBA_BUS[0x0555] = 0x00AA; | 100 GBA_BUS[0x0555] = 0x00AA; |
80 GBA_BUS[0x02AA] = 0x0055; | 101 GBA_BUS[0x02AA] = 0x0055; |
81 GBA_BUS[0x0555] = 0x0090; | 102 GBA_BUS[0x0555] = 0x0090; |
82 GBA_BUS[0x1555] = 0x00AA; | 103 GBA_BUS[0x1555] = 0x00AA; |
83 GBA_BUS[0x12AA] = 0x0055; | 104 GBA_BUS[0x12AA] = 0x0055; |
84 GBA_BUS[0x1555] = 0x0090; | 105 GBA_BUS[0x1555] = 0x0090; |
85 | 106 |
86 id1 = GBA_BUS[0x0001]; | 107 id1 = GBA_BUS[0x0001]; |
87 id2 = GBA_BUS[0x1001]; | 108 |
88 | 109 id2 = GBA_BUS[0x1001]; |
89 if((id1!=0x227E)|| (id2!=0x227E)) { | 110 |
111 if ((id1 != 0x227E) || (id2 != 0x227E)) { | |
90 NDS_EZF_CloseNorWrite(); | 112 NDS_EZF_CloseNorWrite(); |
91 return 0; | 113 |
92 } | 114 return 0; |
93 | 115 } |
94 id1 = GBA_BUS[0x000E]; | 116 |
95 id2 = GBA_BUS[0x100E]; | 117 |
118 id1 = GBA_BUS[0x000E]; | |
119 | |
120 id2 = GBA_BUS[0x100E]; | |
96 | 121 |
97 NDS_EZF_CloseNorWrite(); | 122 NDS_EZF_CloseNorWrite(); |
98 | 123 |
99 if(id1==0x2218 && id2==0x2218) { | 124 if (id1 == 0x2218 && id2 == 0x2218) { |
100 return 1; | 125 |
101 } | 126 return 1; |
102 | 127 } |
103 return 0; | 128 |
104 } | 129 return 0; |
105 | 130 |
106 void NDS_EZF_SetShake(u8 pos) | 131 } |
107 { | 132 |
108 u16 data = ((pos%3)|0x00F0); | 133 void |
109 | 134 NDS_EZF_SetShake(u8 pos) |
110 GBA_BUS[0x0FF0000] = 0xD200; | 135 { |
111 GBA_BUS[0x0000000] = 0x1500; | 136 u16 data = ((pos % 3) | 0x00F0); |
112 GBA_BUS[0x0010000] = 0xD200; | 137 |
113 GBA_BUS[0x0020000] = 0x1500; | 138 GBA_BUS[0x0FF0000] = 0xD200; |
114 GBA_BUS[0x0F10000] = data; | 139 |
115 GBA_BUS[0x0FE0000] = 0x1500; | 140 GBA_BUS[0x0000000] = 0x1500; |
116 | 141 |
117 GBA_BUS[0] = 0x0000; /* write any value for vibration. */ | 142 GBA_BUS[0x0010000] = 0xD200; |
143 | |
144 GBA_BUS[0x0020000] = 0x1500; | |
145 | |
146 GBA_BUS[0x0F10000] = data; | |
147 | |
148 GBA_BUS[0x0FE0000] = 0x1500; | |
149 | |
150 GBA_BUS[0] = 0x0000; /* write any value for vibration. */ | |
118 GBA_BUS[0] = 0x0002; | 151 GBA_BUS[0] = 0x0002; |
152 | |
119 } | 153 } |
120 | 154 |
121 static int | 155 static int |
122 SDL_SYS_LogicError(void) | 156 SDL_SYS_LogicError(void) |
123 { | 157 { |
128 | 162 |
129 int | 163 int |
130 SDL_SYS_HapticInit(void) | 164 SDL_SYS_HapticInit(void) |
131 { | 165 { |
132 int ret = 0; | 166 int ret = 0; |
133 if(isRumbleInserted()) { | 167 if (isRumbleInserted()) { |
134 /* official rumble pak is present. */ | 168 /* official rumble pak is present. */ |
135 ret = 1; | 169 ret = 1; |
136 printf("debug: haptic present: nintendo\n"); | 170 printf("debug: haptic present: nintendo\n"); |
137 } else if(NDS_EZF_IsPresent()) { | 171 } else if (NDS_EZF_IsPresent()) { |
138 /* ezflash 3-in-1 pak is present. */ | 172 /* ezflash 3-in-1 pak is present. */ |
139 ret = 1; | 173 ret = 1; |
140 printf("debug: haptic present: ezf3in1\n"); | 174 printf("debug: haptic present: ezf3in1\n"); |
141 NDS_EZF_ChipReset(); | 175 NDS_EZF_ChipReset(); |
142 } else { | 176 } else { |
148 | 182 |
149 | 183 |
150 const char * | 184 const char * |
151 SDL_SYS_HapticName(int index) | 185 SDL_SYS_HapticName(int index) |
152 { | 186 { |
153 if(nds_haptic) { | 187 if (nds_haptic) { |
154 switch(nds_haptic->hwdata->type) { | 188 switch (nds_haptic->hwdata->type) { |
155 case OFFICIAL: return "Nintendo DS Rumble Pak"; | 189 case OFFICIAL: |
156 case EZF3IN1: return "EZFlash 3-in-1 Rumble"; | 190 return "Nintendo DS Rumble Pak"; |
157 default: return NULL; | 191 case EZF3IN1: |
192 return "EZFlash 3-in-1 Rumble"; | |
193 default: | |
194 return NULL; | |
158 } | 195 } |
159 } | 196 } |
160 return NULL; | 197 return NULL; |
161 } | 198 } |
162 | 199 |
163 | 200 |
164 int | 201 int |
165 SDL_SYS_HapticOpen(SDL_Haptic * haptic) | 202 SDL_SYS_HapticOpen(SDL_Haptic * haptic) |
166 { | 203 { |
167 if(!haptic) { | 204 if (!haptic) { |
168 return -1; | 205 return -1; |
169 } | 206 } |
170 | 207 |
171 haptic->hwdata = SDL_malloc(sizeof(NDS_HapticData)); | 208 haptic->hwdata = SDL_malloc(sizeof(NDS_HapticData)); |
172 if(!haptic->hwdata) { | 209 if (!haptic->hwdata) { |
173 SDL_OutOfMemory(); | 210 SDL_OutOfMemory(); |
174 return -1; | 211 return -1; |
175 } | 212 } |
176 nds_haptic = haptic; | 213 nds_haptic = haptic; |
177 | 214 |
178 haptic->supported = SDL_HAPTIC_CONSTANT; | 215 haptic->supported = SDL_HAPTIC_CONSTANT; |
179 | 216 |
180 /* determine what is here, if anything */ | 217 /* determine what is here, if anything */ |
181 haptic->hwdata->type = NONE; | 218 haptic->hwdata->type = NONE; |
182 if(isRumbleInserted()) { | 219 if (isRumbleInserted()) { |
183 /* official rumble pak is present. */ | 220 /* official rumble pak is present. */ |
184 haptic->hwdata->type = OFFICIAL; | 221 haptic->hwdata->type = OFFICIAL; |
185 } else if(NDS_EZF_IsPresent()) { | 222 } else if (NDS_EZF_IsPresent()) { |
186 /* ezflash 3-in-1 pak is present. */ | 223 /* ezflash 3-in-1 pak is present. */ |
187 haptic->hwdata->type = EZF3IN1; | 224 haptic->hwdata->type = EZF3IN1; |
188 NDS_EZF_ChipReset(); | 225 NDS_EZF_ChipReset(); |
189 } else { | 226 } else { |
190 /* no haptic present */ | 227 /* no haptic present */ |
211 | 248 |
212 | 249 |
213 int | 250 int |
214 SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) | 251 SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) |
215 { | 252 { |
216 /*SDL_SYS_LogicError();*/ | 253 /*SDL_SYS_LogicError(); */ |
217 return -1; | 254 return -1; |
218 } | 255 } |
219 | 256 |
220 | 257 |
221 int | 258 int |