1 /* Copyright 2003-2006 Guillaume Duhamel
2 Copyright 2004-2007 Theo Berkau
3
4 This file is part of Yabause.
5
6 Yabause 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 Yabause 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 Yabause; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /*! \file vidshared.c
22 \brief Functions shared between opengl and software video renderers.
23 */
24
25 #include "ygl.h"
26 #include "vidshared.h"
27 #include "vdp2.h"
28 #include "debug.h"
29
30 //////////////////////////////////////////////////////////////////////////////
31
Vdp2NBG0PlaneAddr(vdp2draw_struct * info,int i,Vdp2 * regs)32 void FASTCALL Vdp2NBG0PlaneAddr(vdp2draw_struct *info, int i, Vdp2* regs)
33 {
34 u32 offset = (regs->MPOFN & 0x7) << 6;
35 u32 tmp=0;
36
37 switch(i)
38 {
39 case 0:
40 tmp = offset | (regs->MPABN0 & 0xFF);
41 break;
42 case 1:
43 tmp = offset | (regs->MPABN0 >> 8);
44 break;
45 case 2:
46 tmp = offset | (regs->MPCDN0 & 0xFF);
47 break;
48 case 3:
49 tmp = offset | (regs->MPCDN0 >> 8);
50 break;
51 }
52
53 CalcPlaneAddr(info, tmp);
54 }
55
56 //////////////////////////////////////////////////////////////////////////////
57
Vdp2NBG1PlaneAddr(vdp2draw_struct * info,int i,Vdp2 * regs)58 void FASTCALL Vdp2NBG1PlaneAddr(vdp2draw_struct *info, int i, Vdp2* regs)
59 {
60 u32 offset = (regs->MPOFN & 0x70) << 2;
61 u32 tmp=0;
62
63 switch(i)
64 {
65 case 0:
66 tmp = offset | (regs->MPABN1 & 0xFF);
67 break;
68 case 1:
69 tmp = offset | (regs->MPABN1 >> 8);
70 break;
71 case 2:
72 tmp = offset | (regs->MPCDN1 & 0xFF);
73 break;
74 case 3:
75 tmp = offset | (regs->MPCDN1 >> 8);
76 break;
77 }
78
79 CalcPlaneAddr(info, tmp);
80 }
81
82 //////////////////////////////////////////////////////////////////////////////
83
Vdp2NBG2PlaneAddr(vdp2draw_struct * info,int i,Vdp2 * regs)84 void FASTCALL Vdp2NBG2PlaneAddr(vdp2draw_struct *info, int i, Vdp2* regs)
85 {
86 u32 offset = (regs->MPOFN & 0x700) >> 2;
87 u32 tmp=0;
88
89 switch(i)
90 {
91 case 0:
92 tmp = offset | (regs->MPABN2 & 0xFF);
93 break;
94 case 1:
95 tmp = offset | (regs->MPABN2 >> 8);
96 break;
97 case 2:
98 tmp = offset | (regs->MPCDN2 & 0xFF);
99 break;
100 case 3:
101 tmp = offset | (regs->MPCDN2 >> 8);
102 break;
103 }
104
105 CalcPlaneAddr(info, tmp);
106 }
107
108 //////////////////////////////////////////////////////////////////////////////
109
Vdp2NBG3PlaneAddr(vdp2draw_struct * info,int i,Vdp2 * regs)110 void FASTCALL Vdp2NBG3PlaneAddr(vdp2draw_struct *info, int i, Vdp2* regs)
111 {
112 u32 offset = (regs->MPOFN & 0x7000) >> 6;
113 u32 tmp=0;
114
115 switch(i)
116 {
117 case 0:
118 tmp = offset | (regs->MPABN3 & 0xFF);
119 break;
120 case 1:
121 tmp = offset | (regs->MPABN3 >> 8);
122 break;
123 case 2:
124 tmp = offset | (regs->MPCDN3 & 0xFF);
125 break;
126 case 3:
127 tmp = offset | (regs->MPCDN3 >> 8);
128 break;
129 }
130
131 CalcPlaneAddr(info, tmp);
132 }
133
134 //////////////////////////////////////////////////////////////////////////////
135
Vdp2ReadRotationTable(int which,vdp2rotationparameter_struct * parameter,Vdp2 * regs,u8 * ram)136 void Vdp2ReadRotationTable(int which, vdp2rotationparameter_struct *parameter, Vdp2* regs, u8* ram)
137 {
138 s32 i;
139 u32 addr;
140
141 addr = regs->RPTA.all << 1;
142
143 if (which == 0)
144 {
145 // Rotation Parameter A
146 addr &= 0x000FFF7C;
147 parameter->coefenab = regs->KTCTL & 0x1;
148 parameter->screenover = (regs->PLSZ >> 10) & 0x3;
149 }
150 else
151 {
152 // Rotation Parameter B
153 addr = (addr & 0x000FFFFC) | 0x00000080;
154 parameter->coefenab = regs->KTCTL & 0x100;
155 parameter->screenover = (regs->PLSZ >> 14) & 0x3;
156 }
157
158 i = T1ReadLong(ram, addr);
159 parameter->Xst = (float) (signed) ((i & 0x1FFFFFC0) | (i & 0x10000000 ? 0xF0000000 : 0x00000000)) / 65536;
160 addr += 4;
161
162 i = T1ReadLong(ram, addr);
163 parameter->Yst = (float) (signed) ((i & 0x1FFFFFC0) | (i & 0x10000000 ? 0xF0000000 : 0x00000000)) / 65536;
164 addr += 4;
165
166 i = T1ReadLong(ram, addr);
167 parameter->Zst = (float) (signed) ((i & 0x1FFFFFC0) | (i & 0x10000000 ? 0xF0000000 : 0x00000000)) / 65536;
168 addr += 4;
169
170 i = T1ReadLong(ram, addr);
171 parameter->deltaXst = (float) (signed) ((i & 0x0007FFC0) | (i & 0x00040000 ? 0xFFFC0000 : 0x00000000)) / 65536;
172 addr += 4;
173
174 i = T1ReadLong(ram, addr);
175 parameter->deltaYst = (float) (signed) ((i & 0x0007FFC0) | (i & 0x00040000 ? 0xFFFC0000 : 0x00000000)) / 65536;
176 addr += 4;
177
178 i = T1ReadLong(ram, addr);
179 parameter->deltaX = (float) (signed) ((i & 0x0007FFC0) | (i & 0x00040000 ? 0xFFFC0000 : 0x00000000)) / 65536;
180 addr += 4;
181
182 i = T1ReadLong(ram, addr);
183 parameter->deltaY = (float) (signed) ((i & 0x0007FFC0) | (i & 0x00040000 ? 0xFFFC0000 : 0x00000000)) / 65536;
184 addr += 4;
185
186 i = T1ReadLong(ram, addr);
187 parameter->A = (float) (signed) ((i & 0x000FFFC0) | (i & 0x00080000 ? 0xFFF80000 : 0x00000000)) / 65536;
188 addr += 4;
189
190 i = T1ReadLong(ram, addr);
191 parameter->B = (float) (signed) ((i & 0x000FFFC0) | ((i & 0x00080000) ? 0xFFF80000 : 0x00000000)) / 65536;
192 addr += 4;
193
194 i = T1ReadLong(ram, addr);
195 parameter->C = (float) (signed) ((i & 0x000FFFC0) | (i & 0x00080000 ? 0xFFF80000 : 0x00000000)) / 65536;
196 addr += 4;
197
198 i = T1ReadLong(ram, addr);
199 parameter->D = (float) (signed) ((i & 0x000FFFC0) | (i & 0x00080000 ? 0xFFF80000 : 0x00000000)) / 65536;
200 addr += 4;
201
202 i = T1ReadLong(ram, addr);
203 parameter->E = (float) (signed) ((i & 0x000FFFC0) | (i & 0x00080000 ? 0xFFF80000 : 0x00000000)) / 65536;
204 addr += 4;
205
206 i = T1ReadLong(ram, addr);
207 parameter->F = (float) (signed) ((i & 0x000FFFC0) | (i & 0x00080000 ? 0xFFF80000 : 0x00000000)) / 65536;
208 addr += 4;
209
210 i = T1ReadWord(ram, addr);
211 parameter->Px = (float) (signed) ((i & 0x3FFF) | (i & 0x2000 ? 0xFFF80000 : 0x00000000));
212 addr += 2;
213
214 i = T1ReadWord(ram, addr);
215 parameter->Py = (float) (signed) ((i & 0x3FFF) | (i & 0x2000 ? 0xFFF80000 : 0x00000000));
216 addr += 2;
217
218 i = T1ReadWord(ram, addr);
219 parameter->Pz = (float) (signed) ((i & 0x3FFF) | (i & 0x2000 ? 0xFFF80000 : 0x00000000));
220 addr += 4;
221
222 i = T1ReadWord(ram, addr);
223 parameter->Cx = (float) (signed) ((i & 0x3FFF) | (i & 0x2000 ? 0xFFF80000 : 0x00000000));
224 addr += 2;
225
226 i = T1ReadWord(ram, addr);
227 parameter->Cy = (float) (signed) ((i & 0x3FFF) | (i & 0x2000 ? 0xFFF80000 : 0x00000000));
228 addr += 2;
229
230 i = T1ReadWord(ram, addr);
231 parameter->Cz = (float) (signed) ((i & 0x3FFF) | (i & 0x2000 ? 0xFFF80000 : 0x00000000));
232 addr += 4;
233
234 i = T1ReadLong(ram, addr);
235 parameter->Mx = (float) (signed) ((i & 0x3FFFFFC0) | (i & 0x20000000 ? 0xE0000000 : 0x00000000)) / 65536;
236 addr += 4;
237
238 i = T1ReadLong(ram, addr);
239 parameter->My = (float) (signed) ((i & 0x3FFFFFC0) | (i & 0x20000000 ? 0xE0000000 : 0x00000000)) / 65536;
240 addr += 4;
241
242 i = T1ReadLong(ram, addr);
243 parameter->kx = (float) (signed) ((i & 0x00FFFFFF) | (i & 0x00800000 ? 0xFF800000 : 0x00000000)) / 65536;
244 addr += 4;
245
246 i = T1ReadLong(ram, addr);
247 parameter->ky = (float) (signed) ((i & 0x00FFFFFF) | (i & 0x00800000 ? 0xFF800000 : 0x00000000)) / 65536;
248 addr += 4;
249
250 if (parameter->coefenab)
251 {
252 // Read in coefficient values
253 i = T1ReadLong(ram, addr);
254 parameter->KAst = (float)(unsigned)(i & 0xFFFFFFC0) / 65536;
255 addr += 4;
256
257 i = T1ReadLong(ram, addr);
258 parameter->deltaKAst = (float) (signed) ((i & 0x03FFFFC0) | (i & 0x02000000 ? 0xFE000000 : 0x00000000)) / 65536;
259 addr += 4;
260
261 i = T1ReadLong(ram, addr);
262 parameter->deltaKAx = (float) (signed) ((i & 0x03FFFFC0) | (i & 0x02000000 ? 0xFE000000 : 0x00000000)) / 65536;
263 addr += 4;
264
265 if (which == 0)
266 {
267 parameter->coefdatasize = (regs->KTCTL & 0x2 ? 2 : 4);
268 parameter->coeftbladdr = ((regs->KTAOF & 0x7) * 0x10000 + (int)(parameter->KAst)) * parameter->coefdatasize;
269 parameter->coefmode = (regs->KTCTL >> 2) & 0x3;
270 }
271 else
272 {
273 parameter->coefdatasize = (regs->KTCTL & 0x200 ? 2 : 4);
274 parameter->coeftbladdr = (((regs->KTAOF >> 8) & 0x7) * 0x10000 + (int)(parameter->KAst)) * parameter->coefdatasize;
275 parameter->coefmode = (regs->KTCTL >> 10) & 0x3;
276 }
277 }
278
279
280 VDP2LOG("Xst: %f, Yst: %f, Zst: %f, deltaXst: %f deltaYst: %f deltaX: %f\n"
281 "deltaY: %f A: %f B: %f C: %f D: %f E: %f F: %f Px: %f Py: %f Pz: %f\n"
282 "Cx: %f Cy: %f Cz: %f Mx: %f My: %f kx: %f ky: %f KAst: %f\n"
283 "deltaKAst: %f deltaKAx: %f kadr %08X\n",
284 parameter->Xst, parameter->Yst, parameter->Zst, parameter->deltaXst,
285 parameter->deltaYst, parameter->deltaX, parameter->deltaY,
286 parameter->A, parameter->B, parameter->C, parameter->D, parameter->E,
287 parameter->F, parameter->Px, parameter->Py, parameter->Pz,
288 parameter->Cx, parameter->Cy, parameter->Cz, parameter->Mx,
289 parameter->My, parameter->kx, parameter->ky, parameter->KAst,
290 parameter->deltaKAst, parameter->deltaKAx,parameter->coeftbladdr);
291 }
292
293 //////////////////////////////////////////////////////////////////////////////
294
Vdp2ReadRotationTableFP(int which,vdp2rotationparameterfp_struct * parameter,Vdp2 * regs,u8 * ram)295 void Vdp2ReadRotationTableFP(int which, vdp2rotationparameterfp_struct *parameter, Vdp2* regs, u8 * ram)
296 {
297 s32 i;
298 u32 addr;
299
300 addr = regs->RPTA.all << 1;
301
302 if (which == 0)
303 {
304 // Rotation Parameter A
305 addr &= 0x000FFF7C;
306 parameter->coefenab = regs->KTCTL & 0x1;
307 parameter->screenover = (regs->PLSZ >> 10) & 0x3;
308 }
309 else
310 {
311 // Rotation Parameter B
312 addr = (addr & 0x000FFFFC) | 0x00000080;
313 parameter->coefenab = regs->KTCTL & 0x100;
314 parameter->screenover = (regs->PLSZ >> 14) & 0x3;
315 }
316
317 i = T1ReadLong(ram, addr);
318 parameter->Xst = (signed) ((i & 0x1FFFFFC0) | (i & 0x10000000 ? 0xF0000000 : 0x00000000));
319 addr += 4;
320
321 i = T1ReadLong(ram, addr);
322 parameter->Yst = (signed) ((i & 0x1FFFFFC0) | (i & 0x10000000 ? 0xF0000000 : 0x00000000));
323 addr += 4;
324
325 i = T1ReadLong(ram, addr);
326 parameter->Zst = (signed) ((i & 0x1FFFFFC0) | (i & 0x10000000 ? 0xF0000000 : 0x00000000));
327 addr += 4;
328
329 i = T1ReadLong(ram, addr);
330 parameter->deltaXst = (signed) ((i & 0x0007FFC0) | (i & 0x00040000 ? 0xFFFC0000 : 0x00000000));
331 addr += 4;
332
333 i = T1ReadLong(ram, addr);
334 parameter->deltaYst = (signed) ((i & 0x0007FFC0) | (i & 0x00040000 ? 0xFFFC0000 : 0x00000000));
335 addr += 4;
336
337 i = T1ReadLong(ram, addr);
338 parameter->deltaX = (signed) ((i & 0x0007FFC0) | (i & 0x00040000 ? 0xFFFC0000 : 0x00000000));
339 addr += 4;
340
341 i = T1ReadLong(ram, addr);
342 parameter->deltaY = (signed) ((i & 0x0007FFC0) | (i & 0x00040000 ? 0xFFFC0000 : 0x00000000));
343 addr += 4;
344
345 i = T1ReadLong(ram, addr);
346 parameter->A = (signed) ((i & 0x000FFFC0) | (i & 0x00080000 ? 0xFFF80000 : 0x00000000));
347 addr += 4;
348
349 i = T1ReadLong(ram, addr);
350 parameter->B = (signed) ((i & 0x000FFFC0) | ((i & 0x00080000) ? 0xFFF80000 : 0x00000000));
351 addr += 4;
352
353 i = T1ReadLong(ram, addr);
354 parameter->C = (signed) ((i & 0x000FFFC0) | (i & 0x00080000 ? 0xFFF80000 : 0x00000000));
355 addr += 4;
356
357 i = T1ReadLong(ram, addr);
358 parameter->D = (signed) ((i & 0x000FFFC0) | (i & 0x00080000 ? 0xFFF80000 : 0x00000000));
359 addr += 4;
360
361 i = T1ReadLong(ram, addr);
362 parameter->E = (signed) ((i & 0x000FFFC0) | (i & 0x00080000 ? 0xFFF80000 : 0x00000000));
363 addr += 4;
364
365 i = T1ReadLong(ram, addr);
366 parameter->F = (signed) ((i & 0x000FFFC0) | (i & 0x00080000 ? 0xFFF80000 : 0x00000000));
367 addr += 4;
368
369 i = T1ReadWord(ram, addr);
370 parameter->Px = tofixed((signed) ((i & 0x3FFF) | (i & 0x2000 ? 0xFFF80000 : 0x00000000)));
371 addr += 2;
372
373 i = T1ReadWord(ram, addr);
374 parameter->Py = tofixed((signed) ((i & 0x3FFF) | (i & 0x2000 ? 0xFFF80000 : 0x00000000)));
375 addr += 2;
376
377 i = T1ReadWord(ram, addr);
378 parameter->Pz = tofixed((signed) ((i & 0x3FFF) | (i & 0x2000 ? 0xFFF80000 : 0x00000000)));
379 addr += 4;
380
381 i = T1ReadWord(ram, addr);
382 parameter->Cx = tofixed((signed) ((i & 0x3FFF) | (i & 0x2000 ? 0xFFF80000 : 0x00000000)));
383 addr += 2;
384
385 i = T1ReadWord(ram, addr);
386 parameter->Cy = tofixed((signed) ((i & 0x3FFF) | (i & 0x2000 ? 0xFFF80000 : 0x00000000)));
387 addr += 2;
388
389 i = T1ReadWord(ram, addr);
390 parameter->Cz = tofixed((signed) ((i & 0x3FFF) | (i & 0x2000 ? 0xFFF80000 : 0x00000000)));
391 addr += 4;
392
393 i = T1ReadLong(ram, addr);
394 parameter->Mx = (signed) ((i & 0x3FFFFFC0) | (i & 0x20000000 ? 0xE0000000 : 0x00000000));
395 addr += 4;
396
397 i = T1ReadLong(ram, addr);
398 parameter->My = (signed) ((i & 0x3FFFFFC0) | (i & 0x20000000 ? 0xE0000000 : 0x00000000));
399 addr += 4;
400
401 i = T1ReadLong(ram, addr);
402 parameter->kx = (signed) ((i & 0x00FFFFFF) | (i & 0x00800000 ? 0xFF800000 : 0x00000000));
403 addr += 4;
404
405 i = T1ReadLong(ram, addr);
406 parameter->ky = (signed) ((i & 0x00FFFFFF) | (i & 0x00800000 ? 0xFF800000 : 0x00000000));
407 addr += 4;
408
409 if (parameter->coefenab)
410 {
411 // Read in coefficient values
412 i = T1ReadLong(ram, addr);
413 parameter->KAst = (unsigned)(i & 0xFFFFFFC0);
414 addr += 4;
415
416 i = T1ReadLong(ram, addr);
417 parameter->deltaKAst = (signed) ((i & 0x03FFFFC0) | (i & 0x02000000 ? 0xFE000000 : 0x00000000));
418 addr += 4;
419
420 i = T1ReadLong(ram, addr);
421 parameter->deltaKAx = (signed) ((i & 0x03FFFFC0) | (i & 0x02000000 ? 0xFE000000 : 0x00000000));
422 addr += 4;
423
424 if (which == 0)
425 {
426 parameter->coefdatasize = (regs->KTCTL & 0x2 ? 2 : 4);
427 parameter->coeftbladdr = ((regs->KTAOF & 0x7) * 0x10000 + touint(parameter->KAst)) * parameter->coefdatasize;
428 parameter->coefmode = (regs->KTCTL >> 2) & 0x3;
429 }
430 else
431 {
432 parameter->coefdatasize = (regs->KTCTL & 0x200 ? 2 : 4);
433 parameter->coeftbladdr = (((regs->KTAOF >> 8) & 0x7) * 0x10000 + touint(parameter->KAst)) * parameter->coefdatasize;
434 parameter->coefmode = (regs->KTCTL >> 10) & 0x3;
435 }
436 }
437
438 VDP2LOG("Xst: %f, Yst: %f, Zst: %f, deltaXst: %f deltaYst: %f deltaX: %f\n"
439 "deltaY: %f A: %f B: %f C: %f D: %f E: %f F: %f Px: %f Py: %f Pz: %f\n"
440 "Cx: %f Cy: %f Cz: %f Mx: %f My: %f kx: %f ky: %f KAst: %f\n"
441 "deltaKAst: %f deltaKAx: %f\n",
442 tofloat(parameter->Xst), tofloat(parameter->Yst),
443 tofloat(parameter->Zst), tofloat(parameter->deltaXst),
444 tofloat(parameter->deltaYst), tofloat(parameter->deltaX),
445 tofloat(parameter->deltaY), tofloat(parameter->A),
446 tofloat(parameter->B), tofloat(parameter->C), tofloat(parameter->D),
447 tofloat(parameter->E), tofloat(parameter->F), tofloat(parameter->Px),
448 tofloat(parameter->Py), tofloat(parameter->Pz), tofloat(parameter->Cx),
449 tofloat(parameter->Cy), tofloat(parameter->Cz), tofloat(parameter->Mx),
450 tofloat(parameter->My), tofloat(parameter->kx),
451 tofloat(parameter->ky), tofloat(parameter->KAst),
452 tofloat(parameter->deltaKAst), tofloat(parameter->deltaKAx));
453 }
454
455 //////////////////////////////////////////////////////////////////////////////
456
Vdp2ParameterAPlaneAddr(vdp2draw_struct * info,int i,Vdp2 * regs)457 void FASTCALL Vdp2ParameterAPlaneAddr(vdp2draw_struct *info, int i, Vdp2* regs)
458 {
459 u32 offset = (regs->MPOFR & 0x7) << 6;
460 u32 tmp=0;
461
462 switch(i)
463 {
464 case 0:
465 tmp = offset | (regs->MPABRA & 0xFF);
466 break;
467 case 1:
468 tmp = offset | (regs->MPABRA >> 8);
469 break;
470 case 2:
471 tmp = offset | (regs->MPCDRA & 0xFF);
472 break;
473 case 3:
474 tmp = offset | (regs->MPCDRA >> 8);
475 break;
476 case 4:
477 tmp = offset | (regs->MPEFRA & 0xFF);
478 break;
479 case 5:
480 tmp = offset | (regs->MPEFRA >> 8);
481 break;
482 case 6:
483 tmp = offset | (regs->MPGHRA & 0xFF);
484 break;
485 case 7:
486 tmp = offset | (regs->MPGHRA >> 8);
487 break;
488 case 8:
489 tmp = offset | (regs->MPIJRA & 0xFF);
490 break;
491 case 9:
492 tmp = offset | (regs->MPIJRA >> 8);
493 break;
494 case 10:
495 tmp = offset | (regs->MPKLRA & 0xFF);
496 break;
497 case 11:
498 tmp = offset | (regs->MPKLRA >> 8);
499 break;
500 case 12:
501 tmp = offset | (regs->MPMNRA & 0xFF);
502 break;
503 case 13:
504 tmp = offset | (regs->MPMNRA >> 8);
505 break;
506 case 14:
507 tmp = offset | (regs->MPOPRA & 0xFF);
508 break;
509 case 15:
510 tmp = offset | (regs->MPOPRA >> 8);
511 break;
512 }
513
514 CalcPlaneAddr(info, tmp);
515 }
516
517 //////////////////////////////////////////////////////////////////////////////
518
Vdp2ParameterBPlaneAddr(vdp2draw_struct * info,int i,Vdp2 * regs)519 void FASTCALL Vdp2ParameterBPlaneAddr(vdp2draw_struct *info, int i, Vdp2* regs)
520 {
521 u32 offset = (regs->MPOFR & 0x70) << 2;
522 u32 tmp=0;
523
524 // Parameter B
525 switch(i)
526 {
527 case 0:
528 tmp = offset | (regs->MPABRB & 0xFF);
529 break;
530 case 1:
531 tmp = offset | (regs->MPABRB >> 8);
532 break;
533 case 2:
534 tmp = offset | (regs->MPCDRB & 0xFF);
535 break;
536 case 3:
537 tmp = offset | (regs->MPCDRB >> 8);
538 break;
539 case 4:
540 tmp = offset | (regs->MPEFRB & 0xFF);
541 break;
542 case 5:
543 tmp = offset | (regs->MPEFRB >> 8);
544 break;
545 case 6:
546 tmp = offset | (regs->MPGHRB & 0xFF);
547 break;
548 case 7:
549 tmp = offset | (regs->MPGHRB >> 8);
550 break;
551 case 8:
552 tmp = offset | (regs->MPIJRB & 0xFF);
553 break;
554 case 9:
555 tmp = offset | (regs->MPIJRB >> 8);
556 break;
557 case 10:
558 tmp = offset | (regs->MPKLRB & 0xFF);
559 break;
560 case 11:
561 tmp = offset | (regs->MPKLRB >> 8);
562 break;
563 case 12:
564 tmp = offset | (regs->MPMNRB & 0xFF);
565 break;
566 case 13:
567 tmp = offset | (regs->MPMNRB >> 8);
568 break;
569 case 14:
570 tmp = offset | (regs->MPOPRB & 0xFF);
571 break;
572 case 15:
573 tmp = offset | (regs->MPOPRB >> 8);
574 break;
575 }
576
577 CalcPlaneAddr(info, tmp);
578 }
579
580 //////////////////////////////////////////////////////////////////////////////
581
Vdp2ReadCoefficientMode0_2(vdp2rotationparameter_struct * parameter,u32 addr,u8 * ram)582 float Vdp2ReadCoefficientMode0_2(vdp2rotationparameter_struct *parameter, u32 addr, u8 * ram)
583 {
584 s32 i;
585
586 if (parameter->coefdatasize == 2)
587 {
588 addr &= 0x7FFFE;
589 i = T1ReadWord(ram, addr);
590 parameter->msb = (i >> 15) & 0x1;
591 return (float) (signed) ((i & 0x7FFF) | (i & 0x4000 ? 0xFFFFC000 : 0x00000000)) / 1024;
592 }
593 else
594 {
595 addr &= 0x7FFFC;
596 i = T1ReadLong(ram, addr);
597 parameter->msb = (i >> 31) & 0x1;
598 return (float) (signed) ((i & 0x00FFFFFF) | (i & 0x00800000 ? 0xFF800000 : 0x00000000)) / 65536;
599 }
600 }
601
602 //////////////////////////////////////////////////////////////////////////////
603
Vdp2ReadCoefficientMode0_2FP(vdp2rotationparameterfp_struct * parameter,u32 addr,u8 * ram)604 fixed32 Vdp2ReadCoefficientMode0_2FP(vdp2rotationparameterfp_struct *parameter, u32 addr, u8* ram)
605 {
606 s32 i;
607
608 if (parameter->coefdatasize == 2)
609 {
610 addr &= 0x7FFFE;
611 i = T1ReadWord(ram, addr);
612 parameter->msb = (i >> 15) & 0x1;
613 return (signed) ((i & 0x7FFF) | (i & 0x4000 ? 0xFFFFC000 : 0x00000000)) * 64;
614 }
615 else
616 {
617 addr &= 0x7FFFC;
618 i = T1ReadLong(ram, addr);
619 parameter->linescreen = (i >> 24) & 0x7F;
620 parameter->msb = (i >> 31) & 0x1;
621 return (signed) ((i & 0x00FFFFFF) | (i & 0x00800000 ? 0xFF800000 : 0x00000000));
622 }
623 }
624
625 //////////////////////////////////////////////////////////////////////////////
626