trunk/src/mess/video/gbamode1.c
r23309 | r23310 | |
1 | | /*************************************************************************** |
2 | | |
3 | | gbamode1.c |
4 | | |
5 | | Handles GBA mode 1 screen rendering |
6 | | |
7 | | By R. Belmont & Harmony |
8 | | |
9 | | ***************************************************************************/ |
10 | | |
11 | | |
12 | | void gba_state::draw_mode1(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp) |
13 | | { |
14 | | switch (submode) |
15 | | { |
16 | | case 0: |
17 | | draw_mode1_scanline(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp); |
18 | | break; |
19 | | case 1: |
20 | | draw_mode1_scanline_nowindow(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp); |
21 | | break; |
22 | | case 2: |
23 | | draw_mode1_scanline_all(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp); |
24 | | break; |
25 | | } |
26 | | } |
27 | | |
28 | | void gba_state::draw_mode1_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp) |
29 | | { |
30 | | int x = 0; |
31 | | UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000; |
32 | | |
33 | | draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS); |
34 | | draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS); |
35 | | draw_roz_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed); |
36 | | draw_gba_oam(lineOBJ, y); |
37 | | |
38 | | for(x = 0; x < 240; x++) |
39 | | { |
40 | | UINT32 color = backdrop; |
41 | | UINT8 top = 0x20; |
42 | | |
43 | | if(line0[x] < color) |
44 | | { |
45 | | color = line0[x]; |
46 | | top = 0x01; |
47 | | } |
48 | | |
49 | | if((UINT8)(line1[x] >> 24) < (UINT8)(color >> 24)) |
50 | | { |
51 | | color = line1[x]; |
52 | | top = 0x02; |
53 | | } |
54 | | |
55 | | if((UINT8)(line2[x] >> 24) < (UINT8)(color >> 24)) |
56 | | { |
57 | | color = line2[x]; |
58 | | top = 0x04; |
59 | | } |
60 | | |
61 | | if((UINT8)(lineOBJ[x] >> 24) < (UINT8)(color >> 24)) |
62 | | { |
63 | | color = lineOBJ[x]; |
64 | | top = 0x10; |
65 | | } |
66 | | |
67 | | if(top == 0x10 && (color & 0x00010000) != 0) |
68 | | { |
69 | | UINT32 back = backdrop; |
70 | | UINT8 top2 = 0x20; |
71 | | |
72 | | if((UINT8)(line0[x] >> 24) < (UINT8)(back >> 24)) |
73 | | { |
74 | | back = line0[x]; |
75 | | top2 = 0x01; |
76 | | } |
77 | | |
78 | | if((UINT8)(line1[x] >> 24) < (UINT8)(back >> 24)) |
79 | | { |
80 | | back = line1[x]; |
81 | | top2 = 0x02; |
82 | | } |
83 | | |
84 | | if((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24)) |
85 | | { |
86 | | back = line2[x]; |
87 | | top2 = 0x04; |
88 | | } |
89 | | |
90 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
91 | | { |
92 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
93 | | } |
94 | | else |
95 | | { |
96 | | switch(m_BLDCNT & BLDCNT_SFX) |
97 | | { |
98 | | case BLDCNT_SFX_LIGHTEN: |
99 | | if(top & m_BLDCNT) |
100 | | { |
101 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
102 | | } |
103 | | break; |
104 | | case BLDCNT_SFX_DARKEN: |
105 | | if(top & m_BLDCNT) |
106 | | { |
107 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
108 | | } |
109 | | break; |
110 | | } |
111 | | } |
112 | | } |
113 | | |
114 | | lineMix[x] = color; |
115 | | } |
116 | | m_gfxBG2Changed = 0; |
117 | | } |
118 | | |
119 | | void gba_state::draw_mode1_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp) |
120 | | { |
121 | | int x = 0; |
122 | | UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000; |
123 | | int effect = m_BLDCNT & BLDCNT_SFX; |
124 | | |
125 | | draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS); |
126 | | draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS); |
127 | | draw_roz_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed); |
128 | | draw_gba_oam(lineOBJ, y); |
129 | | |
130 | | for(x = 0; x < 240; x++) |
131 | | { |
132 | | UINT32 color = backdrop; |
133 | | UINT8 top = 0x20; |
134 | | |
135 | | if(line0[x] < color) |
136 | | { |
137 | | color = line0[x]; |
138 | | top = 0x01; |
139 | | } |
140 | | |
141 | | if(line1[x] < (color & 0xff000000)) |
142 | | { |
143 | | color = line1[x]; |
144 | | top = 0x02; |
145 | | } |
146 | | |
147 | | if(line2[x] < (color & 0xff000000)) |
148 | | { |
149 | | color = line2[x]; |
150 | | top = 0x04; |
151 | | } |
152 | | |
153 | | if(lineOBJ[x] < (color & 0xff000000)) |
154 | | { |
155 | | color = lineOBJ[x]; |
156 | | top = 0x10; |
157 | | } |
158 | | |
159 | | if((color & 0x00010000) == 0) |
160 | | { |
161 | | switch(effect) |
162 | | { |
163 | | case BLDCNT_SFX_NONE: |
164 | | break; |
165 | | case BLDCNT_SFX_ALPHA: |
166 | | if(m_BLDCNT & top) |
167 | | { |
168 | | UINT32 back = backdrop; |
169 | | UINT8 top2 = 0x20; |
170 | | |
171 | | if((UINT8)(line0[x] >> 24) < (UINT8)(back >> 24)) |
172 | | { |
173 | | if(top != 0x01) |
174 | | { |
175 | | back = line0[x]; |
176 | | top2 = 0x01; |
177 | | } |
178 | | } |
179 | | |
180 | | if((UINT8)(line1[x] >> 24) < (UINT8)(back >> 24)) |
181 | | { |
182 | | if(top != 0x02) |
183 | | { |
184 | | back = line1[x]; |
185 | | top2 = 0x02; |
186 | | } |
187 | | } |
188 | | |
189 | | if((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24)) |
190 | | { |
191 | | if(top != 0x04) |
192 | | { |
193 | | back = line2[x]; |
194 | | top2 = 0x04; |
195 | | } |
196 | | } |
197 | | |
198 | | if((UINT8)(lineOBJ[x] >> 24) < (UINT8)(back >> 24)) |
199 | | { |
200 | | if(top != 0x10) |
201 | | { |
202 | | back = lineOBJ[x]; |
203 | | top2 = 0x10; |
204 | | } |
205 | | } |
206 | | |
207 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
208 | | { |
209 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
210 | | } |
211 | | } |
212 | | break; |
213 | | case BLDCNT_SFX_LIGHTEN: |
214 | | if(top & m_BLDCNT) |
215 | | { |
216 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
217 | | } |
218 | | break; |
219 | | case BLDCNT_SFX_DARKEN: |
220 | | if(top & m_BLDCNT) |
221 | | { |
222 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
223 | | } |
224 | | break; |
225 | | } |
226 | | } |
227 | | else |
228 | | { |
229 | | UINT32 back = backdrop; |
230 | | UINT8 top2 = 0x20; |
231 | | |
232 | | if((UINT8)(line0[x] >> 24) < (UINT8)(back >> 24)) |
233 | | { |
234 | | back = line0[x]; |
235 | | top2 = 0x01; |
236 | | } |
237 | | |
238 | | if((UINT8)(line1[x] >> 24) < (UINT8)(back >> 24)) |
239 | | { |
240 | | back = line1[x]; |
241 | | top2 = 0x02; |
242 | | } |
243 | | |
244 | | if((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24)) |
245 | | { |
246 | | back = line2[x]; |
247 | | top2 = 0x04; |
248 | | } |
249 | | |
250 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
251 | | { |
252 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
253 | | } |
254 | | else |
255 | | { |
256 | | switch(m_BLDCNT & BLDCNT_SFX) |
257 | | { |
258 | | case BLDCNT_SFX_LIGHTEN: |
259 | | if(top & m_BLDCNT) |
260 | | { |
261 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
262 | | } |
263 | | break; |
264 | | case BLDCNT_SFX_DARKEN: |
265 | | if(top & m_BLDCNT) |
266 | | { |
267 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
268 | | } |
269 | | break; |
270 | | } |
271 | | } |
272 | | } |
273 | | lineMix[x] = color; |
274 | | } |
275 | | m_gfxBG2Changed = 0; |
276 | | } |
277 | | |
278 | | void gba_state::draw_mode1_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp) |
279 | | { |
280 | | int x = 0; |
281 | | UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000; |
282 | | int inWindow0 = 0; |
283 | | int inWindow1 = 0; |
284 | | UINT8 inWin0Mask = m_WININ & 0x00ff; |
285 | | UINT8 inWin1Mask = m_WININ >> 8; |
286 | | UINT8 outMask = m_WINOUT & 0x00ff; |
287 | | |
288 | | if(m_DISPCNT & DISPCNT_WIN0_EN) |
289 | | { |
290 | | UINT8 v0 = m_WIN0V >> 8; |
291 | | UINT8 v1 = m_WIN0V & 0x00ff; |
292 | | inWindow0 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; |
293 | | if(v1 >= v0) |
294 | | { |
295 | | inWindow0 |= (y >= v0 && y < v1) ? 1 : 0; |
296 | | } |
297 | | else |
298 | | { |
299 | | inWindow0 |= (y >= v0 || y < v1) ? 1 : 0; |
300 | | } |
301 | | } |
302 | | |
303 | | if(m_DISPCNT & DISPCNT_WIN1_EN) |
304 | | { |
305 | | UINT8 v0 = m_WIN1V >> 8; |
306 | | UINT8 v1 = m_WIN1V & 0x00ff; |
307 | | inWindow1 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; |
308 | | if(v1 >= v0) |
309 | | { |
310 | | inWindow1 |= (y >= v0 && y < v1) ? 1 : 0; |
311 | | } |
312 | | else |
313 | | { |
314 | | inWindow1 |= (y >= v0 || y < v1) ? 1 : 0; |
315 | | } |
316 | | } |
317 | | |
318 | | draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS); |
319 | | draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS); |
320 | | draw_roz_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed); |
321 | | draw_gba_oam(lineOBJ, y); |
322 | | draw_gba_oam_window(lineOBJWin, y); |
323 | | |
324 | | for(x = 0; x < 240; x++) |
325 | | { |
326 | | UINT32 color = backdrop; |
327 | | UINT8 top = 0x20; |
328 | | UINT8 mask = outMask; |
329 | | |
330 | | if((lineOBJWin[x] & 0x80000000) == 0) |
331 | | { |
332 | | mask = m_WINOUT >> 8; |
333 | | } |
334 | | |
335 | | if(inWindow1) |
336 | | { |
337 | | if(is_in_window(x, 1)) |
338 | | { |
339 | | mask = inWin1Mask; |
340 | | } |
341 | | } |
342 | | |
343 | | if(inWindow0) |
344 | | { |
345 | | if(is_in_window(x, 0)) |
346 | | { |
347 | | mask = inWin0Mask; |
348 | | } |
349 | | } |
350 | | |
351 | | if((mask & 0x01) != 0 && (line0[x] < color)) |
352 | | { |
353 | | color = line0[x]; |
354 | | top = 0x01; |
355 | | } |
356 | | |
357 | | if((mask & 0x02) != 0 && ((UINT8)(line1[x] >> 24) < (UINT8)(color >> 24))) |
358 | | { |
359 | | color = line1[x]; |
360 | | top = 0x02; |
361 | | } |
362 | | |
363 | | if((mask & 0x04) != 0 && ((UINT8)(line2[x] >> 24) < (UINT8)(color >> 24))) |
364 | | { |
365 | | color = line2[x]; |
366 | | top = 0x04; |
367 | | } |
368 | | |
369 | | if((mask & 0x10) != 0 && ((UINT8)(lineOBJ[x] >> 24) < (UINT8)(color >> 24))) |
370 | | { |
371 | | color = lineOBJ[x]; |
372 | | top = 0x10; |
373 | | } |
374 | | |
375 | | if((mask & 0x20) != 0) |
376 | | { |
377 | | if((color & 0x00010000) == 0) |
378 | | { |
379 | | switch(m_BLDCNT & BLDCNT_SFX) |
380 | | { |
381 | | case BLDCNT_SFX_NONE: |
382 | | break; |
383 | | case BLDCNT_SFX_ALPHA: |
384 | | { |
385 | | if(top & m_BLDCNT) |
386 | | { |
387 | | UINT32 back = backdrop; |
388 | | UINT8 top2 = 0x20; |
389 | | if((mask & 0x01) != 0 && ((UINT8)(line0[x] >> 24) < (UINT8)(back >> 24))) |
390 | | { |
391 | | if(top != 0x01) |
392 | | { |
393 | | back = line0[x]; |
394 | | top2 = 0x01; |
395 | | } |
396 | | } |
397 | | |
398 | | if((mask & 0x02) != 0 && ((UINT8)(line1[x] >> 24) < (UINT8)(back >> 24))) |
399 | | { |
400 | | if(top != 0x02) |
401 | | { |
402 | | back = line1[x]; |
403 | | top2 = 0x02; |
404 | | } |
405 | | } |
406 | | |
407 | | if((mask & 0x04) != 0 && ((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24))) |
408 | | { |
409 | | if(top != 0x04) |
410 | | { |
411 | | back = line2[x]; |
412 | | top2 = 0x04; |
413 | | } |
414 | | } |
415 | | |
416 | | if((mask & 0x10) != 0 && ((UINT8)(lineOBJ[x] >> 24) < (UINT8)(back >> 24))) |
417 | | { |
418 | | if(top != 0x10) |
419 | | { |
420 | | back = lineOBJ[x]; |
421 | | top2 = 0x10; |
422 | | } |
423 | | } |
424 | | |
425 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
426 | | { |
427 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
428 | | } |
429 | | } |
430 | | break; |
431 | | } |
432 | | case BLDCNT_SFX_LIGHTEN: |
433 | | if(top & m_BLDCNT) |
434 | | { |
435 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
436 | | } |
437 | | break; |
438 | | case BLDCNT_SFX_DARKEN: |
439 | | if(top & m_BLDCNT) |
440 | | { |
441 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
442 | | } |
443 | | break; |
444 | | } |
445 | | } |
446 | | else |
447 | | { |
448 | | UINT32 back = backdrop; |
449 | | UINT8 top2 = 0x20; |
450 | | |
451 | | if((mask & 0x01) != 0 && ((UINT8)(line0[x] >> 24) < (UINT8)(back >> 24))) |
452 | | { |
453 | | back = line0[x]; |
454 | | top2 = 0x01; |
455 | | } |
456 | | |
457 | | if((mask & 0x02) != 0 && ((UINT8)(line1[x] >> 24) < (UINT8)(back >> 24))) |
458 | | { |
459 | | back = line1[x]; |
460 | | top2 = 0x02; |
461 | | } |
462 | | |
463 | | if((mask & 0x04) != 0 && ((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24))) |
464 | | { |
465 | | back = line2[x]; |
466 | | top2 = 0x04; |
467 | | } |
468 | | |
469 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
470 | | { |
471 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
472 | | } |
473 | | else |
474 | | { |
475 | | switch(m_BLDCNT & BLDCNT_SFX) |
476 | | { |
477 | | case BLDCNT_SFX_LIGHTEN: |
478 | | if(top & m_BLDCNT) |
479 | | { |
480 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
481 | | } |
482 | | break; |
483 | | case BLDCNT_SFX_DARKEN: |
484 | | if(top & m_BLDCNT) |
485 | | { |
486 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
487 | | } |
488 | | break; |
489 | | } |
490 | | } |
491 | | } |
492 | | } |
493 | | else if(color & 0x00010000) |
494 | | { |
495 | | UINT32 back = backdrop; |
496 | | UINT8 top2 = 0x20; |
497 | | |
498 | | if((mask & 0x01) != 0 && ((UINT8)(line0[x] >> 24) < (UINT8)(back >> 24))) |
499 | | { |
500 | | back = line0[x]; |
501 | | top2 = 0x01; |
502 | | } |
503 | | |
504 | | if((mask & 0x02) != 0 && ((UINT8)(line1[x] >> 24) < (UINT8)(back >> 24))) |
505 | | { |
506 | | back = line1[x]; |
507 | | top2 = 0x02; |
508 | | } |
509 | | |
510 | | if((mask & 0x04) != 0 && ((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24))) |
511 | | { |
512 | | back = line2[x]; |
513 | | top2 = 0x04; |
514 | | } |
515 | | |
516 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
517 | | { |
518 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
519 | | } |
520 | | else |
521 | | { |
522 | | switch(m_BLDCNT & BLDCNT_SFX) |
523 | | { |
524 | | case BLDCNT_SFX_LIGHTEN: |
525 | | if(top & m_BLDCNT) |
526 | | { |
527 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
528 | | } |
529 | | break; |
530 | | case BLDCNT_SFX_DARKEN: |
531 | | if(top & m_BLDCNT) |
532 | | { |
533 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
534 | | } |
535 | | break; |
536 | | } |
537 | | } |
538 | | } |
539 | | lineMix[x] = color; |
540 | | } |
541 | | m_gfxBG2Changed = 0; |
542 | | } |
trunk/src/mess/video/gbamode2.c
r23309 | r23310 | |
1 | | /*************************************************************************** |
2 | | |
3 | | gbamode2.c |
4 | | |
5 | | Handles GBA mode 2 screen rendering |
6 | | |
7 | | By R. Belmont & Harmony |
8 | | |
9 | | ***************************************************************************/ |
10 | | |
11 | | |
12 | | void gba_state::draw_mode2(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp) |
13 | | { |
14 | | switch (submode) |
15 | | { |
16 | | case 0: |
17 | | draw_mode2_scanline(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp); |
18 | | break; |
19 | | case 1: |
20 | | draw_mode2_scanline_nowindow(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp); |
21 | | break; |
22 | | case 2: |
23 | | draw_mode2_scanline_all(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp); |
24 | | break; |
25 | | } |
26 | | } |
27 | | |
28 | | void gba_state::draw_mode2_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp) |
29 | | { |
30 | | int x = 0; |
31 | | UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000; |
32 | | |
33 | | draw_roz_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed); |
34 | | draw_roz_scanline(line3, y, DISPCNT_BG3_EN, m_BG3CNT, m_BG3X, m_BG3Y, m_BG3PA, m_BG3PB, m_BG3PC, m_BG3PD, &m_gfxBG3X, &m_gfxBG3Y, m_gfxBG3Changed); |
35 | | draw_gba_oam(lineOBJ, y); |
36 | | |
37 | | for(x = 0; x < 240; x++) |
38 | | { |
39 | | UINT32 color = backdrop; |
40 | | UINT8 top = 0x20; |
41 | | |
42 | | if((UINT8)(line2[x] >> 24) < (UINT8)(color >> 24)) |
43 | | { |
44 | | color = line2[x]; |
45 | | top = 0x04; |
46 | | } |
47 | | |
48 | | if((UINT8)(line3[x] >> 24) < (UINT8)(color >> 24)) |
49 | | { |
50 | | color = line3[x]; |
51 | | top = 0x08; |
52 | | } |
53 | | |
54 | | if((UINT8)(lineOBJ[x] >> 24) < (UINT8)(color >> 24)) |
55 | | { |
56 | | color = lineOBJ[x]; |
57 | | top = 0x10; |
58 | | } |
59 | | |
60 | | if(top == 0x10 && (color & 0x00010000) != 0) |
61 | | { |
62 | | UINT32 back = backdrop; |
63 | | UINT8 top2 = 0x20; |
64 | | |
65 | | if((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24)) |
66 | | { |
67 | | back = line2[x]; |
68 | | top2 = 0x04; |
69 | | } |
70 | | |
71 | | if((UINT8)(line3[x] >> 24) < (UINT8)(back >> 24)) |
72 | | { |
73 | | back = line3[x]; |
74 | | top2 = 0x08; |
75 | | } |
76 | | |
77 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
78 | | { |
79 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
80 | | } |
81 | | else |
82 | | { |
83 | | switch(m_BLDCNT & BLDCNT_SFX) |
84 | | { |
85 | | case BLDCNT_SFX_LIGHTEN: |
86 | | if(top & m_BLDCNT) |
87 | | { |
88 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
89 | | } |
90 | | break; |
91 | | case BLDCNT_SFX_DARKEN: |
92 | | if(top & m_BLDCNT) |
93 | | { |
94 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
95 | | } |
96 | | break; |
97 | | } |
98 | | } |
99 | | } |
100 | | |
101 | | lineMix[x] = color; |
102 | | } |
103 | | m_gfxBG2Changed = 0; |
104 | | m_gfxBG3Changed = 0; |
105 | | } |
106 | | |
107 | | void gba_state::draw_mode2_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp) |
108 | | { |
109 | | int x = 0; |
110 | | UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000; |
111 | | int effect = m_BLDCNT & BLDCNT_SFX; |
112 | | |
113 | | draw_roz_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed); |
114 | | draw_roz_scanline(line3, y, DISPCNT_BG3_EN, m_BG3CNT, m_BG3X, m_BG3Y, m_BG3PA, m_BG3PB, m_BG3PC, m_BG3PD, &m_gfxBG3X, &m_gfxBG3Y, m_gfxBG3Changed); |
115 | | draw_gba_oam(lineOBJ, y); |
116 | | |
117 | | for(x = 0; x < 240; x++) |
118 | | { |
119 | | UINT32 color = backdrop; |
120 | | UINT8 top = 0x20; |
121 | | |
122 | | if((UINT8)(line2[x] >> 24) < (UINT8)(color >> 24)) |
123 | | { |
124 | | color = line2[x]; |
125 | | top = 0x04; |
126 | | } |
127 | | |
128 | | if((UINT8)(line3[x] >> 24) < (UINT8)(color >> 24)) |
129 | | { |
130 | | color = line3[x]; |
131 | | top = 0x08; |
132 | | } |
133 | | |
134 | | if((UINT8)(lineOBJ[x] >> 24) < (UINT8)(color >> 24)) |
135 | | { |
136 | | color = lineOBJ[x]; |
137 | | top = 0x10; |
138 | | } |
139 | | |
140 | | if((color & 0x00010000) == 0) |
141 | | { |
142 | | switch(effect) |
143 | | { |
144 | | case BLDCNT_SFX_NONE: |
145 | | break; |
146 | | case BLDCNT_SFX_ALPHA: |
147 | | if(m_BLDCNT & top) |
148 | | { |
149 | | UINT32 back = backdrop; |
150 | | UINT8 top2 = 0x20; |
151 | | |
152 | | if((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24)) |
153 | | { |
154 | | if(top != 0x04) |
155 | | { |
156 | | back = line2[x]; |
157 | | top2 = 0x04; |
158 | | } |
159 | | } |
160 | | |
161 | | if((UINT8)(line3[x] >> 24) < (UINT8)(back >> 24)) |
162 | | { |
163 | | if(top != 0x08) |
164 | | { |
165 | | back = line3[x]; |
166 | | top2 = 0x08; |
167 | | } |
168 | | } |
169 | | |
170 | | if((UINT8)(lineOBJ[x] >> 24) < (UINT8)(back >> 24)) |
171 | | { |
172 | | if(top != 0x10) |
173 | | { |
174 | | back = lineOBJ[x]; |
175 | | top2 = 0x10; |
176 | | } |
177 | | } |
178 | | |
179 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
180 | | { |
181 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
182 | | } |
183 | | } |
184 | | break; |
185 | | case BLDCNT_SFX_LIGHTEN: |
186 | | if(top & m_BLDCNT) |
187 | | { |
188 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
189 | | } |
190 | | break; |
191 | | case BLDCNT_SFX_DARKEN: |
192 | | if(top & m_BLDCNT) |
193 | | { |
194 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
195 | | } |
196 | | break; |
197 | | } |
198 | | } |
199 | | else |
200 | | { |
201 | | UINT32 back = backdrop; |
202 | | UINT8 top2 = 0x20; |
203 | | |
204 | | if((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24)) |
205 | | { |
206 | | back = line2[x]; |
207 | | top2 = 0x04; |
208 | | } |
209 | | |
210 | | if((UINT8)(line3[x] >> 24) < (UINT8)(back >> 24)) |
211 | | { |
212 | | back = line3[x]; |
213 | | top2 = 0x08; |
214 | | } |
215 | | |
216 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
217 | | { |
218 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
219 | | } |
220 | | else |
221 | | { |
222 | | switch(m_BLDCNT & BLDCNT_SFX) |
223 | | { |
224 | | case BLDCNT_SFX_LIGHTEN: |
225 | | if(top & m_BLDCNT) |
226 | | { |
227 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
228 | | } |
229 | | break; |
230 | | case BLDCNT_SFX_DARKEN: |
231 | | if(top & m_BLDCNT) |
232 | | { |
233 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
234 | | } |
235 | | break; |
236 | | } |
237 | | } |
238 | | } |
239 | | lineMix[x] = color; |
240 | | } |
241 | | m_gfxBG2Changed = 0; |
242 | | m_gfxBG3Changed = 0; |
243 | | } |
244 | | |
245 | | void gba_state::draw_mode2_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp) |
246 | | { |
247 | | int x = 0; |
248 | | UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000; |
249 | | int inWindow0 = 0; |
250 | | int inWindow1 = 0; |
251 | | UINT8 inWin0Mask = m_WININ & 0x00ff; |
252 | | UINT8 inWin1Mask = m_WININ >> 8; |
253 | | UINT8 outMask = m_WINOUT & 0x00ff; |
254 | | |
255 | | if(m_DISPCNT & DISPCNT_WIN0_EN) |
256 | | { |
257 | | UINT8 v0 = m_WIN0V >> 8; |
258 | | UINT8 v1 = m_WIN0V & 0x00ff; |
259 | | inWindow0 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; |
260 | | if(v1 >= v0) |
261 | | { |
262 | | inWindow0 |= (y >= v0 && y < v1) ? 1 : 0; |
263 | | } |
264 | | else |
265 | | { |
266 | | inWindow0 |= (y >= v0 || y < v1) ? 1 : 0; |
267 | | } |
268 | | } |
269 | | |
270 | | if(m_DISPCNT & DISPCNT_WIN1_EN) |
271 | | { |
272 | | UINT8 v0 = m_WIN1V >> 8; |
273 | | UINT8 v1 = m_WIN1V & 0x00ff; |
274 | | inWindow1 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; |
275 | | if(v1 >= v0) |
276 | | { |
277 | | inWindow1 |= (y >= v0 && y < v1) ? 1 : 0; |
278 | | } |
279 | | else |
280 | | { |
281 | | inWindow1 |= (y >= v0 || y < v1) ? 1 : 0; |
282 | | } |
283 | | } |
284 | | |
285 | | draw_roz_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed); |
286 | | draw_roz_scanline(line3, y, DISPCNT_BG3_EN, m_BG3CNT, m_BG3X, m_BG3Y, m_BG3PA, m_BG3PB, m_BG3PC, m_BG3PD, &m_gfxBG3X, &m_gfxBG3Y, m_gfxBG3Changed); |
287 | | draw_gba_oam(lineOBJ, y); |
288 | | draw_gba_oam_window(lineOBJWin, y); |
289 | | |
290 | | for(x = 0; x < 240; x++) |
291 | | { |
292 | | UINT32 color = backdrop; |
293 | | UINT8 top = 0x20; |
294 | | UINT8 mask = outMask; |
295 | | |
296 | | if((lineOBJWin[x] & 0x80000000) == 0) |
297 | | { |
298 | | mask = m_WINOUT >> 8; |
299 | | } |
300 | | |
301 | | if(inWindow1) |
302 | | { |
303 | | if(is_in_window(x, 1)) |
304 | | { |
305 | | mask = inWin1Mask; |
306 | | } |
307 | | } |
308 | | |
309 | | if(inWindow0) |
310 | | { |
311 | | if(is_in_window(x, 0)) |
312 | | { |
313 | | mask = inWin0Mask; |
314 | | } |
315 | | } |
316 | | |
317 | | if((mask & 0x04) != 0 && (line2[x] < color)) |
318 | | { |
319 | | color = line2[x]; |
320 | | top = 0x04; |
321 | | } |
322 | | |
323 | | if((mask & 0x08) != 0 && (UINT8)(line3[x] >> 24) < (UINT8)(color >> 24)) |
324 | | { |
325 | | color = line3[x]; |
326 | | top = 0x08; |
327 | | } |
328 | | |
329 | | if((mask & 0x10) != 0 && (UINT8)(lineOBJ[x] >> 24) < (UINT8)(color >> 24)) |
330 | | { |
331 | | color = lineOBJ[x]; |
332 | | top = 0x10; |
333 | | } |
334 | | |
335 | | if((mask & 0x20) != 0) |
336 | | { |
337 | | if((color & 0x00010000) == 0) |
338 | | { |
339 | | switch(m_BLDCNT & BLDCNT_SFX) |
340 | | { |
341 | | case BLDCNT_SFX_NONE: |
342 | | break; |
343 | | case BLDCNT_SFX_ALPHA: |
344 | | { |
345 | | if(top & m_BLDCNT) |
346 | | { |
347 | | UINT32 back = backdrop; |
348 | | UINT8 top2 = 0x20; |
349 | | if((mask & 0x04) != 0 && (line2[x] < back)) |
350 | | { |
351 | | if(top != 0x04) |
352 | | { |
353 | | back = line2[x]; |
354 | | top2 = 0x04; |
355 | | } |
356 | | } |
357 | | |
358 | | if((mask & 0x08) != 0 && ((UINT8)(line3[x] >> 24) < (UINT8)(back >> 24))) |
359 | | { |
360 | | if(top != 0x08) |
361 | | { |
362 | | back = line3[x]; |
363 | | top2 = 0x08; |
364 | | } |
365 | | } |
366 | | |
367 | | if((mask & 0x10) != 0 && ((UINT8)(lineOBJ[x] >> 24) < (UINT8)(back >> 24))) |
368 | | { |
369 | | if(top != 0x10) |
370 | | { |
371 | | back = lineOBJ[x]; |
372 | | top2 = 0x10; |
373 | | } |
374 | | } |
375 | | |
376 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
377 | | { |
378 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
379 | | } |
380 | | } |
381 | | break; |
382 | | } |
383 | | case BLDCNT_SFX_LIGHTEN: |
384 | | if(top & m_BLDCNT) |
385 | | { |
386 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
387 | | } |
388 | | break; |
389 | | case BLDCNT_SFX_DARKEN: |
390 | | if(top & m_BLDCNT) |
391 | | { |
392 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
393 | | } |
394 | | break; |
395 | | } |
396 | | } |
397 | | else |
398 | | { |
399 | | UINT32 back = backdrop; |
400 | | UINT8 top2 = 0x20; |
401 | | |
402 | | if((mask & 0x04) != 0 && (line2[x] < back)) |
403 | | { |
404 | | back = line2[x]; |
405 | | top2 = 0x04; |
406 | | } |
407 | | |
408 | | if((mask & 0x08) != 0 && ((UINT8)(line3[x] >> 24) < (UINT8)(back >> 24))) |
409 | | { |
410 | | back = line3[x]; |
411 | | top2 = 0x08; |
412 | | } |
413 | | |
414 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
415 | | { |
416 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
417 | | } |
418 | | else |
419 | | { |
420 | | switch(m_BLDCNT & BLDCNT_SFX) |
421 | | { |
422 | | case BLDCNT_SFX_LIGHTEN: |
423 | | if(top & m_BLDCNT) |
424 | | { |
425 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
426 | | } |
427 | | break; |
428 | | case BLDCNT_SFX_DARKEN: |
429 | | if(top & m_BLDCNT) |
430 | | { |
431 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
432 | | } |
433 | | break; |
434 | | } |
435 | | } |
436 | | } |
437 | | } |
438 | | else if(color & 0x00010000) |
439 | | { |
440 | | UINT32 back = backdrop; |
441 | | UINT8 top2 = 0x20; |
442 | | |
443 | | if((mask & 0x04) != 0 && (line2[x] < back )) |
444 | | { |
445 | | back = line2[x]; |
446 | | top2 = 0x04; |
447 | | } |
448 | | |
449 | | if((mask & 0x08) != 0 && ((UINT8)(line3[x] >> 24) < (UINT8)(back >> 24))) |
450 | | { |
451 | | back = line3[x]; |
452 | | top2 = 0x08; |
453 | | } |
454 | | |
455 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
456 | | { |
457 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
458 | | } |
459 | | else |
460 | | { |
461 | | switch(m_BLDCNT & BLDCNT_SFX) |
462 | | { |
463 | | case BLDCNT_SFX_LIGHTEN: |
464 | | if(top & m_BLDCNT) |
465 | | { |
466 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
467 | | } |
468 | | break; |
469 | | case BLDCNT_SFX_DARKEN: |
470 | | if(top & m_BLDCNT) |
471 | | { |
472 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
473 | | } |
474 | | break; |
475 | | } |
476 | | } |
477 | | } |
478 | | lineMix[x] = color; |
479 | | } |
480 | | m_gfxBG2Changed = 0; |
481 | | m_gfxBG3Changed = 0; |
482 | | } |
trunk/src/mess/video/gbam345.c
r23309 | r23310 | |
1 | | /*************************************************************************** |
2 | | |
3 | | gbam345.c |
4 | | |
5 | | Handles GBA rendering for modes 3, 4, and 5. |
6 | | |
7 | | By R. Belmont & Harmony |
8 | | |
9 | | ***************************************************************************/ |
10 | | |
11 | | |
12 | | void gba_state::draw_mode345(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp) |
13 | | { |
14 | | switch (submode) |
15 | | { |
16 | | case 0: |
17 | | draw_roz_bitmap_mode_scanline(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp); |
18 | | break; |
19 | | case 1: |
20 | | draw_roz_bitmap_mode_scanline_nowindow(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp); |
21 | | break; |
22 | | case 2: |
23 | | draw_roz_bitmap_mode_scanline_all(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp); |
24 | | break; |
25 | | } |
26 | | } |
27 | | |
28 | | void gba_state::draw_roz_bitmap_mode_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp) |
29 | | { |
30 | | int x = 0; |
31 | | UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000; |
32 | | |
33 | | draw_roz_bitmap_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed, bpp); |
34 | | draw_gba_oam(lineOBJ, y); |
35 | | |
36 | | for(x = 0; x < 240; x++) |
37 | | { |
38 | | UINT32 color = backdrop; |
39 | | UINT8 top = 0x20; |
40 | | |
41 | | if(line2[x] < color) |
42 | | { |
43 | | color = line2[x]; |
44 | | top = 0x04; |
45 | | } |
46 | | |
47 | | if((UINT8)(lineOBJ[x] >> 24) < (UINT8)(color >> 24)) |
48 | | { |
49 | | color = lineOBJ[x]; |
50 | | top = 0x10; |
51 | | } |
52 | | |
53 | | if(top == 0x10 && (color & 0x00010000) != 0) |
54 | | { |
55 | | UINT32 back = backdrop; |
56 | | UINT8 top2 = 0x20; |
57 | | |
58 | | if(line2[x] < back) |
59 | | { |
60 | | back = line2[x]; |
61 | | top2 = 0x04; |
62 | | } |
63 | | |
64 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
65 | | { |
66 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
67 | | } |
68 | | else |
69 | | { |
70 | | switch(m_BLDCNT & BLDCNT_SFX) |
71 | | { |
72 | | case BLDCNT_SFX_LIGHTEN: |
73 | | if(top & m_BLDCNT) |
74 | | { |
75 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
76 | | } |
77 | | break; |
78 | | case BLDCNT_SFX_DARKEN: |
79 | | if(top & m_BLDCNT) |
80 | | { |
81 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
82 | | } |
83 | | break; |
84 | | } |
85 | | } |
86 | | } |
87 | | |
88 | | lineMix[x] = color; |
89 | | } |
90 | | m_gfxBG2Changed = 0; |
91 | | } |
92 | | |
93 | | void gba_state::draw_roz_bitmap_mode_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp) |
94 | | { |
95 | | int x = 0; |
96 | | UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000; |
97 | | int effect = m_BLDCNT & BLDCNT_SFX; |
98 | | |
99 | | draw_roz_bitmap_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed, bpp); |
100 | | draw_gba_oam(lineOBJ, y); |
101 | | |
102 | | for(x = 0; x < 240; x++) |
103 | | { |
104 | | UINT32 color = backdrop; |
105 | | UINT8 top = 0x20; |
106 | | |
107 | | if(line2[x] < color) |
108 | | { |
109 | | color = line2[x]; |
110 | | top = 0x04; |
111 | | } |
112 | | |
113 | | if((UINT8)(lineOBJ[x] >> 24) < (UINT8)(color >> 24)) |
114 | | { |
115 | | color = lineOBJ[x]; |
116 | | top = 0x10; |
117 | | } |
118 | | |
119 | | if((color & 0x00010000) == 0) |
120 | | { |
121 | | switch(effect) |
122 | | { |
123 | | case BLDCNT_SFX_NONE: |
124 | | break; |
125 | | case BLDCNT_SFX_ALPHA: |
126 | | if(m_BLDCNT & top) |
127 | | { |
128 | | UINT32 back = backdrop; |
129 | | UINT8 top2 = 0x20; |
130 | | |
131 | | if(line2[x] < back) |
132 | | { |
133 | | if(top != 0x04) |
134 | | { |
135 | | back = line2[x]; |
136 | | top2 = 0x04; |
137 | | } |
138 | | } |
139 | | |
140 | | if((UINT8)(lineOBJ[x] >> 24) < (UINT8)(back >> 24)) |
141 | | { |
142 | | if(top != 0x10) |
143 | | { |
144 | | back = lineOBJ[x]; |
145 | | top2 = 0x10; |
146 | | } |
147 | | } |
148 | | |
149 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
150 | | { |
151 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
152 | | } |
153 | | } |
154 | | break; |
155 | | case BLDCNT_SFX_LIGHTEN: |
156 | | if(top & m_BLDCNT) |
157 | | { |
158 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
159 | | } |
160 | | break; |
161 | | case BLDCNT_SFX_DARKEN: |
162 | | if(top & m_BLDCNT) |
163 | | { |
164 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
165 | | } |
166 | | break; |
167 | | } |
168 | | } |
169 | | else |
170 | | { |
171 | | UINT32 back = backdrop; |
172 | | UINT8 top2 = 0x20; |
173 | | |
174 | | if(line2[x] < back) |
175 | | { |
176 | | back = line2[x]; |
177 | | top2 = 0x04; |
178 | | } |
179 | | |
180 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
181 | | { |
182 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
183 | | } |
184 | | else |
185 | | { |
186 | | switch(m_BLDCNT & BLDCNT_SFX) |
187 | | { |
188 | | case BLDCNT_SFX_LIGHTEN: |
189 | | if(top & m_BLDCNT) |
190 | | { |
191 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
192 | | } |
193 | | break; |
194 | | case BLDCNT_SFX_DARKEN: |
195 | | if(top & m_BLDCNT) |
196 | | { |
197 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
198 | | } |
199 | | break; |
200 | | } |
201 | | } |
202 | | } |
203 | | lineMix[x] = color; |
204 | | } |
205 | | m_gfxBG2Changed = 0; |
206 | | } |
207 | | |
208 | | void gba_state::draw_roz_bitmap_mode_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp) |
209 | | { |
210 | | int x = 0; |
211 | | UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000; |
212 | | int inWindow0 = 0; |
213 | | int inWindow1 = 0; |
214 | | UINT8 inWin0Mask = m_WININ & 0x00ff; |
215 | | UINT8 inWin1Mask = m_WININ >> 8; |
216 | | UINT8 outMask = m_WINOUT & 0x00ff; |
217 | | |
218 | | if(m_DISPCNT & DISPCNT_WIN0_EN) |
219 | | { |
220 | | UINT8 v0 = m_WIN0V >> 8; |
221 | | UINT8 v1 = m_WIN0V & 0x00ff; |
222 | | inWindow0 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; |
223 | | if(v1 >= v0) |
224 | | { |
225 | | inWindow0 |= (y >= v0 && y < v1) ? 1 : 0; |
226 | | } |
227 | | else |
228 | | { |
229 | | inWindow0 |= (y >= v0 || y < v1) ? 1 : 0; |
230 | | } |
231 | | } |
232 | | |
233 | | if(m_DISPCNT & DISPCNT_WIN1_EN) |
234 | | { |
235 | | UINT8 v0 = m_WIN1V >> 8; |
236 | | UINT8 v1 = m_WIN1V & 0x00ff; |
237 | | inWindow1 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; |
238 | | if(v1 >= v0) |
239 | | { |
240 | | inWindow1 |= (y >= v0 && y < v1) ? 1 : 0; |
241 | | } |
242 | | else |
243 | | { |
244 | | inWindow1 |= (y >= v0 || y < v1) ? 1 : 0; |
245 | | } |
246 | | } |
247 | | |
248 | | draw_roz_bitmap_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed, bpp); |
249 | | draw_gba_oam(lineOBJ, y); |
250 | | draw_gba_oam_window(lineOBJWin, y); |
251 | | |
252 | | for(x = 0; x < 240; x++) |
253 | | { |
254 | | UINT32 color = backdrop; |
255 | | UINT8 top = 0x20; |
256 | | UINT8 mask = outMask; |
257 | | |
258 | | if((lineOBJWin[x] & 0x80000000) == 0) |
259 | | { |
260 | | mask = m_WINOUT >> 8; |
261 | | } |
262 | | |
263 | | if(inWindow1) |
264 | | { |
265 | | if(is_in_window(x, 1)) |
266 | | { |
267 | | mask = inWin1Mask; |
268 | | } |
269 | | } |
270 | | |
271 | | if(inWindow0) |
272 | | { |
273 | | if(is_in_window(x, 0)) |
274 | | { |
275 | | mask = inWin0Mask; |
276 | | } |
277 | | } |
278 | | |
279 | | if((mask & 0x04) != 0 && (line2[x] < color)) |
280 | | { |
281 | | color = line2[x]; |
282 | | top = 0x04; |
283 | | } |
284 | | |
285 | | if((mask & 0x10) != 0 && (UINT8)(lineOBJ[x] >> 24) < (UINT8)(color >> 24)) |
286 | | { |
287 | | color = lineOBJ[x]; |
288 | | top = 0x10; |
289 | | } |
290 | | |
291 | | if((mask & 0x20) != 0) |
292 | | { |
293 | | if((color & 0x00010000) == 0) |
294 | | { |
295 | | switch(m_BLDCNT & BLDCNT_SFX) |
296 | | { |
297 | | case BLDCNT_SFX_NONE: |
298 | | break; |
299 | | case BLDCNT_SFX_ALPHA: |
300 | | { |
301 | | if(top & m_BLDCNT) |
302 | | { |
303 | | UINT32 back = backdrop; |
304 | | UINT8 top2 = 0x20; |
305 | | if((mask & 0x04) != 0 && (line2[x] < back)) |
306 | | { |
307 | | if(top != 0x04) |
308 | | { |
309 | | back = line2[x]; |
310 | | top2 = 0x04; |
311 | | } |
312 | | } |
313 | | |
314 | | if((mask & 0x10) != 0 && ((UINT8)(lineOBJ[x] >> 24) < (UINT8)(back >> 24))) |
315 | | { |
316 | | if(top != 0x10) |
317 | | { |
318 | | back = lineOBJ[x]; |
319 | | top2 = 0x10; |
320 | | } |
321 | | } |
322 | | |
323 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
324 | | { |
325 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
326 | | } |
327 | | } |
328 | | break; |
329 | | } |
330 | | case BLDCNT_SFX_LIGHTEN: |
331 | | if(top & m_BLDCNT) |
332 | | { |
333 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
334 | | } |
335 | | break; |
336 | | case BLDCNT_SFX_DARKEN: |
337 | | if(top & m_BLDCNT) |
338 | | { |
339 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
340 | | } |
341 | | break; |
342 | | } |
343 | | } |
344 | | else |
345 | | { |
346 | | UINT32 back = backdrop; |
347 | | UINT8 top2 = 0x20; |
348 | | |
349 | | if((mask & 0x04) != 0 && (line2[x] < back)) |
350 | | { |
351 | | back = line2[x]; |
352 | | top2 = 0x04; |
353 | | } |
354 | | |
355 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
356 | | { |
357 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
358 | | } |
359 | | else |
360 | | { |
361 | | switch(m_BLDCNT & BLDCNT_SFX) |
362 | | { |
363 | | case BLDCNT_SFX_LIGHTEN: |
364 | | if(top & m_BLDCNT) |
365 | | { |
366 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
367 | | } |
368 | | break; |
369 | | case BLDCNT_SFX_DARKEN: |
370 | | if(top & m_BLDCNT) |
371 | | { |
372 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
373 | | } |
374 | | break; |
375 | | } |
376 | | } |
377 | | } |
378 | | } |
379 | | else if(color & 0x00010000) |
380 | | { |
381 | | UINT32 back = backdrop; |
382 | | UINT8 top2 = 0x20; |
383 | | |
384 | | if((mask & 0x04) != 0 && (line2[x] < back)) |
385 | | { |
386 | | back = line2[x]; |
387 | | top2 = 0x04; |
388 | | } |
389 | | |
390 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
391 | | { |
392 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
393 | | } |
394 | | else |
395 | | { |
396 | | switch(m_BLDCNT & BLDCNT_SFX) |
397 | | { |
398 | | case BLDCNT_SFX_LIGHTEN: |
399 | | if(top & m_BLDCNT) |
400 | | { |
401 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
402 | | } |
403 | | break; |
404 | | case BLDCNT_SFX_DARKEN: |
405 | | if(top & m_BLDCNT) |
406 | | { |
407 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
408 | | } |
409 | | break; |
410 | | } |
411 | | } |
412 | | } |
413 | | lineMix[x] = color; |
414 | | } |
415 | | m_gfxBG2Changed = 0; |
416 | | } |
trunk/src/mess/video/gbamode0.c
r23309 | r23310 | |
1 | | /*************************************************************************** |
2 | | |
3 | | gbamode0.c |
4 | | |
5 | | Handles GBA mode 0 screen rendering |
6 | | |
7 | | By R. Belmont & Harmony |
8 | | |
9 | | ***************************************************************************/ |
10 | | |
11 | | |
12 | | void gba_state::draw_mode0(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp) |
13 | | { |
14 | | switch (submode) |
15 | | { |
16 | | case 0: |
17 | | draw_mode0_scanline(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp); |
18 | | break; |
19 | | case 1: |
20 | | draw_mode0_scanline_nowindow(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp); |
21 | | break; |
22 | | case 2: |
23 | | draw_mode0_scanline_all(y, line0, line1, line2, line3, lineOBJ, lineOBJWin, lineMix, bpp); |
24 | | break; |
25 | | } |
26 | | } |
27 | | |
28 | | void gba_state::draw_mode0_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp) |
29 | | { |
30 | | int x = 0; |
31 | | UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000; |
32 | | |
33 | | draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS); |
34 | | draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS); |
35 | | draw_bg_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2HOFS, m_BG2VOFS); |
36 | | draw_bg_scanline(line3, y, DISPCNT_BG3_EN, m_BG3CNT, m_BG3HOFS, m_BG3VOFS); |
37 | | draw_gba_oam(lineOBJ, y); |
38 | | |
39 | | for(x = 0; x < 240; x++) |
40 | | { |
41 | | UINT32 color = backdrop; |
42 | | UINT8 top = 0x20; |
43 | | |
44 | | if(line0[x] < color) |
45 | | { |
46 | | color = line0[x]; |
47 | | top = 0x01; |
48 | | } |
49 | | |
50 | | if((UINT8)(line1[x] >> 24) < (UINT8)(color >> 24)) |
51 | | { |
52 | | color = line1[x]; |
53 | | top = 0x02; |
54 | | } |
55 | | |
56 | | if((UINT8)(line2[x] >> 24) < (UINT8)(color >> 24)) |
57 | | { |
58 | | color = line2[x]; |
59 | | top = 0x04; |
60 | | } |
61 | | |
62 | | if((UINT8)(line3[x] >> 24) < (UINT8)(color >> 24)) |
63 | | { |
64 | | color = line3[x]; |
65 | | top = 0x08; |
66 | | } |
67 | | |
68 | | if((UINT8)(lineOBJ[x] >> 24) < (UINT8)(color >> 24)) |
69 | | { |
70 | | color = lineOBJ[x]; |
71 | | top = 0x10; |
72 | | } |
73 | | |
74 | | if(top == 0x10 && (color & 0x00010000) != 0) |
75 | | { |
76 | | UINT32 back = backdrop; |
77 | | UINT8 top2 = 0x20; |
78 | | |
79 | | if((UINT8)(line0[x] >> 24) < (UINT8)(back >> 24)) |
80 | | { |
81 | | back = line0[x]; |
82 | | top2 = 0x01; |
83 | | } |
84 | | |
85 | | if((UINT8)(line1[x] >> 24) < (UINT8)(back >> 24)) |
86 | | { |
87 | | back = line1[x]; |
88 | | top2 = 0x02; |
89 | | } |
90 | | |
91 | | if((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24)) |
92 | | { |
93 | | back = line2[x]; |
94 | | top2 = 0x04; |
95 | | } |
96 | | |
97 | | if((UINT8)(line3[x] >> 24) < (UINT8)(back >> 24)) |
98 | | { |
99 | | back = line3[x]; |
100 | | top2 = 0x08; |
101 | | } |
102 | | |
103 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
104 | | { |
105 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
106 | | } |
107 | | else |
108 | | { |
109 | | switch(m_BLDCNT & BLDCNT_SFX) |
110 | | { |
111 | | case BLDCNT_SFX_LIGHTEN: |
112 | | if(top & m_BLDCNT) |
113 | | { |
114 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
115 | | } |
116 | | break; |
117 | | case BLDCNT_SFX_DARKEN: |
118 | | if(top & m_BLDCNT) |
119 | | { |
120 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
121 | | } |
122 | | break; |
123 | | } |
124 | | } |
125 | | } |
126 | | |
127 | | lineMix[x] = color; |
128 | | } |
129 | | } |
130 | | |
131 | | void gba_state::draw_mode0_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp) |
132 | | { |
133 | | int x = 0; |
134 | | UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000; |
135 | | int effect = m_BLDCNT & BLDCNT_SFX; |
136 | | |
137 | | draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS); |
138 | | draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS); |
139 | | draw_bg_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2HOFS, m_BG2VOFS); |
140 | | draw_bg_scanline(line3, y, DISPCNT_BG3_EN, m_BG3CNT, m_BG3HOFS, m_BG3VOFS); |
141 | | draw_gba_oam(lineOBJ, y); |
142 | | |
143 | | for(x = 0; x < 240; x++) |
144 | | { |
145 | | UINT32 color = backdrop; |
146 | | UINT8 top = 0x20; |
147 | | |
148 | | if(line0[x] < color) |
149 | | { |
150 | | color = line0[x]; |
151 | | top = 0x01; |
152 | | } |
153 | | |
154 | | if(line1[x] < (color & 0xff000000)) |
155 | | { |
156 | | color = line1[x]; |
157 | | top = 0x02; |
158 | | } |
159 | | |
160 | | if(line2[x] < (color & 0xff000000)) |
161 | | { |
162 | | color = line2[x]; |
163 | | top = 0x04; |
164 | | } |
165 | | |
166 | | if(line3[x] < (color & 0xff000000)) |
167 | | { |
168 | | color = line3[x]; |
169 | | top = 0x08; |
170 | | } |
171 | | |
172 | | if(lineOBJ[x] < (color & 0xff000000)) |
173 | | { |
174 | | color = lineOBJ[x]; |
175 | | top = 0x10; |
176 | | } |
177 | | |
178 | | if((color & 0x00010000) == 0) |
179 | | { |
180 | | switch(effect) |
181 | | { |
182 | | case BLDCNT_SFX_NONE: |
183 | | break; |
184 | | case BLDCNT_SFX_ALPHA: |
185 | | if(m_BLDCNT & top) |
186 | | { |
187 | | UINT32 back = backdrop; |
188 | | UINT8 top2 = 0x20; |
189 | | |
190 | | if(line0[x] < back) |
191 | | { |
192 | | if(top != 0x01) |
193 | | { |
194 | | back = line0[x]; |
195 | | top2 = 0x01; |
196 | | } |
197 | | } |
198 | | |
199 | | if(line1[x] < (back & 0xff000000)) |
200 | | { |
201 | | if(top != 0x02) |
202 | | { |
203 | | back = line1[x]; |
204 | | top2 = 0x02; |
205 | | } |
206 | | } |
207 | | |
208 | | if(line2[x] < (back & 0xff000000)) |
209 | | { |
210 | | if(top != 0x04) |
211 | | { |
212 | | back = line2[x]; |
213 | | top2 = 0x04; |
214 | | } |
215 | | } |
216 | | |
217 | | if(line3[x] < (back & 0xff000000)) |
218 | | { |
219 | | if(top != 0x08) |
220 | | { |
221 | | back = line3[x]; |
222 | | top2 = 0x08; |
223 | | } |
224 | | } |
225 | | |
226 | | if(lineOBJ[x] < (back & 0xff000000)) |
227 | | { |
228 | | if(top != 0x10) |
229 | | { |
230 | | back = lineOBJ[x]; |
231 | | top2 = 0x10; |
232 | | } |
233 | | } |
234 | | |
235 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
236 | | { |
237 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
238 | | } |
239 | | } |
240 | | break; |
241 | | case BLDCNT_SFX_LIGHTEN: |
242 | | if(top & m_BLDCNT) |
243 | | { |
244 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
245 | | } |
246 | | break; |
247 | | case BLDCNT_SFX_DARKEN: |
248 | | if(top & m_BLDCNT) |
249 | | { |
250 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
251 | | } |
252 | | break; |
253 | | } |
254 | | } |
255 | | else |
256 | | { |
257 | | UINT32 back = backdrop; |
258 | | UINT8 top2 = 0x20; |
259 | | |
260 | | if(line0[x] < back) |
261 | | { |
262 | | back = line0[x]; |
263 | | top2 = 0x01; |
264 | | } |
265 | | |
266 | | if(line1[x] < (back & 0xff000000)) |
267 | | { |
268 | | back = line1[x]; |
269 | | top2 = 0x02; |
270 | | } |
271 | | |
272 | | if(line2[x] < (back & 0xff000000)) |
273 | | { |
274 | | back = line2[x]; |
275 | | top2 = 0x04; |
276 | | } |
277 | | |
278 | | if(line3[x] < (back & 0xff000000)) |
279 | | { |
280 | | back = line3[x]; |
281 | | top2 = 0x08; |
282 | | } |
283 | | |
284 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
285 | | { |
286 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
287 | | } |
288 | | else |
289 | | { |
290 | | switch(m_BLDCNT & BLDCNT_SFX) |
291 | | { |
292 | | case BLDCNT_SFX_LIGHTEN: |
293 | | if(top & m_BLDCNT) |
294 | | { |
295 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
296 | | } |
297 | | break; |
298 | | case BLDCNT_SFX_DARKEN: |
299 | | if(top & m_BLDCNT) |
300 | | { |
301 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
302 | | } |
303 | | break; |
304 | | } |
305 | | } |
306 | | } |
307 | | lineMix[x] = color; |
308 | | } |
309 | | } |
310 | | |
311 | | void gba_state::draw_mode0_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp) |
312 | | { |
313 | | int x = 0; |
314 | | UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000; |
315 | | int inWindow0 = 0; |
316 | | int inWindow1 = 0; |
317 | | UINT8 inWin0Mask = m_WININ & 0x00ff; |
318 | | UINT8 inWin1Mask = m_WININ >> 8; |
319 | | UINT8 outMask = m_WINOUT & 0x00ff; |
320 | | |
321 | | if(m_DISPCNT & DISPCNT_WIN0_EN) |
322 | | { |
323 | | UINT8 v0 = m_WIN0V >> 8; |
324 | | UINT8 v1 = m_WIN0V & 0x00ff; |
325 | | inWindow0 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; |
326 | | if(v1 >= v0) |
327 | | { |
328 | | inWindow0 |= (y >= v0 && y < v1) ? 1 : 0; |
329 | | } |
330 | | else |
331 | | { |
332 | | inWindow0 |= (y >= v0 || y < v1) ? 1 : 0; |
333 | | } |
334 | | } |
335 | | |
336 | | if(m_DISPCNT & DISPCNT_WIN1_EN) |
337 | | { |
338 | | UINT8 v0 = m_WIN1V >> 8; |
339 | | UINT8 v1 = m_WIN1V & 0x00ff; |
340 | | inWindow1 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; |
341 | | if(v1 >= v0) |
342 | | { |
343 | | inWindow1 |= (y >= v0 && y < v1) ? 1 : 0; |
344 | | } |
345 | | else |
346 | | { |
347 | | inWindow1 |= (y >= v0 || y < v1) ? 1 : 0; |
348 | | } |
349 | | } |
350 | | |
351 | | draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS); |
352 | | draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS); |
353 | | draw_bg_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2HOFS, m_BG2VOFS); |
354 | | draw_bg_scanline(line3, y, DISPCNT_BG3_EN, m_BG3CNT, m_BG3HOFS, m_BG3VOFS); |
355 | | draw_gba_oam(lineOBJ, y); |
356 | | draw_gba_oam_window(lineOBJWin, y); |
357 | | |
358 | | for(x = 0; x < 240; x++) |
359 | | { |
360 | | UINT32 color = backdrop; |
361 | | UINT8 top = 0x20; |
362 | | UINT8 mask = outMask; |
363 | | |
364 | | if((lineOBJWin[x] & 0x80000000) == 0) |
365 | | { |
366 | | mask = m_WINOUT >> 8; |
367 | | } |
368 | | |
369 | | if(inWindow1) |
370 | | { |
371 | | if(is_in_window(x, 1)) |
372 | | { |
373 | | mask = inWin1Mask; |
374 | | } |
375 | | } |
376 | | |
377 | | if(inWindow0) |
378 | | { |
379 | | if(is_in_window(x, 0)) |
380 | | { |
381 | | mask = inWin0Mask; |
382 | | } |
383 | | } |
384 | | |
385 | | if((mask & 0x01) != 0 && (line0[x] < color)) |
386 | | { |
387 | | color = line0[x]; |
388 | | top = 0x01; |
389 | | } |
390 | | |
391 | | if((mask & 0x02) != 0 && ((UINT8)(line1[x] >> 24) < (UINT8)(color >> 24))) |
392 | | { |
393 | | color = line1[x]; |
394 | | top = 0x02; |
395 | | } |
396 | | |
397 | | if((mask & 0x04) != 0 && ((UINT8)(line2[x] >> 24) < (UINT8)(color >> 24))) |
398 | | { |
399 | | color = line2[x]; |
400 | | top = 0x04; |
401 | | } |
402 | | |
403 | | if((mask & 0x08) != 0 && ((UINT8)(line3[x] >> 24) < (UINT8)(color >> 24))) |
404 | | { |
405 | | color = line3[x]; |
406 | | top = 0x08; |
407 | | } |
408 | | |
409 | | if((mask & 0x10) != 0 && ((UINT8)(lineOBJ[x] >> 24) < (UINT8)(color >> 24))) |
410 | | { |
411 | | color = lineOBJ[x]; |
412 | | top = 0x10; |
413 | | } |
414 | | |
415 | | if((mask & 0x20) != 0) |
416 | | { |
417 | | if((color & 0x00010000) == 0) |
418 | | { |
419 | | switch(m_BLDCNT & BLDCNT_SFX) |
420 | | { |
421 | | case BLDCNT_SFX_NONE: |
422 | | break; |
423 | | case BLDCNT_SFX_ALPHA: |
424 | | { |
425 | | if(top & m_BLDCNT) |
426 | | { |
427 | | UINT32 back = backdrop; |
428 | | UINT8 top2 = 0x20; |
429 | | if((mask & 0x01) != 0 && ((UINT8)(line0[x] >> 24) < (UINT8)(back >> 24))) |
430 | | { |
431 | | if(top != 0x01) |
432 | | { |
433 | | back = line0[x]; |
434 | | top2 = 0x01; |
435 | | } |
436 | | } |
437 | | |
438 | | if((mask & 0x02) != 0 && ((UINT8)(line1[x] >> 24) < (UINT8)(back >> 24))) |
439 | | { |
440 | | if(top != 0x02) |
441 | | { |
442 | | back = line1[x]; |
443 | | top2 = 0x02; |
444 | | } |
445 | | } |
446 | | |
447 | | if((mask & 0x04) != 0 && ((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24))) |
448 | | { |
449 | | if(top != 0x04) |
450 | | { |
451 | | back = line2[x]; |
452 | | top2 = 0x04; |
453 | | } |
454 | | } |
455 | | |
456 | | if((mask & 0x08) != 0 && ((UINT8)(line3[x] >> 24) < (UINT8)(back >> 24))) |
457 | | { |
458 | | if(top != 0x08) |
459 | | { |
460 | | back = line3[x]; |
461 | | top2 = 0x08; |
462 | | } |
463 | | } |
464 | | |
465 | | if((mask & 0x10) != 0 && ((UINT8)(lineOBJ[x] >> 24) < (UINT8)(back >> 24))) |
466 | | { |
467 | | if(top != 0x10) |
468 | | { |
469 | | back = lineOBJ[x]; |
470 | | top2 = 0x10; |
471 | | } |
472 | | } |
473 | | |
474 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
475 | | { |
476 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
477 | | } |
478 | | } |
479 | | break; |
480 | | } |
481 | | case BLDCNT_SFX_LIGHTEN: |
482 | | if(top & m_BLDCNT) |
483 | | { |
484 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
485 | | } |
486 | | break; |
487 | | case BLDCNT_SFX_DARKEN: |
488 | | if(top & m_BLDCNT) |
489 | | { |
490 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
491 | | } |
492 | | break; |
493 | | } |
494 | | } |
495 | | else |
496 | | { |
497 | | UINT32 back = backdrop; |
498 | | UINT8 top2 = 0x20; |
499 | | |
500 | | if((mask & 0x01) != 0 && ((UINT8)(line0[x] >> 24) < (UINT8)(back >> 24))) |
501 | | { |
502 | | back = line0[x]; |
503 | | top2 = 0x01; |
504 | | } |
505 | | |
506 | | if((mask & 0x02) != 0 && ((UINT8)(line1[x] >> 24) < (UINT8)(back >> 24))) |
507 | | { |
508 | | back = line1[x]; |
509 | | top2 = 0x02; |
510 | | } |
511 | | |
512 | | if((mask & 0x04) != 0 && ((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24))) |
513 | | { |
514 | | back = line2[x]; |
515 | | top2 = 0x04; |
516 | | } |
517 | | |
518 | | if((mask & 0x08) != 0 && ((UINT8)(line3[x] >> 24) < (UINT8)(back >> 24))) |
519 | | { |
520 | | back = line3[x]; |
521 | | top2 = 0x08; |
522 | | } |
523 | | |
524 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
525 | | { |
526 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
527 | | } |
528 | | else |
529 | | { |
530 | | switch(m_BLDCNT & BLDCNT_SFX) |
531 | | { |
532 | | case BLDCNT_SFX_LIGHTEN: |
533 | | if(top & m_BLDCNT) |
534 | | { |
535 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
536 | | } |
537 | | break; |
538 | | case BLDCNT_SFX_DARKEN: |
539 | | if(top & m_BLDCNT) |
540 | | { |
541 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
542 | | } |
543 | | break; |
544 | | } |
545 | | } |
546 | | } |
547 | | } |
548 | | else if(color & 0x00010000) |
549 | | { |
550 | | UINT32 back = backdrop; |
551 | | UINT8 top2 = 0x20; |
552 | | |
553 | | if((mask & 0x01) != 0 && ((UINT8)(line0[x] >> 24) < (UINT8)(back >> 24))) |
554 | | { |
555 | | back = line0[x]; |
556 | | top2 = 0x01; |
557 | | } |
558 | | |
559 | | if((mask & 0x02) != 0 && ((UINT8)(line1[x] >> 24) < (UINT8)(back >> 24))) |
560 | | { |
561 | | back = line1[x]; |
562 | | top2 = 0x02; |
563 | | } |
564 | | |
565 | | if((mask & 0x04) != 0 && ((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24))) |
566 | | { |
567 | | back = line2[x]; |
568 | | top2 = 0x04; |
569 | | } |
570 | | |
571 | | if((mask & 0x08) != 0 && ((UINT8)(line3[x] >> 24) < (UINT8)(back >> 24))) |
572 | | { |
573 | | back = line3[x]; |
574 | | top2 = 0x08; |
575 | | } |
576 | | |
577 | | if(top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
578 | | { |
579 | | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
580 | | } |
581 | | else |
582 | | { |
583 | | switch(m_BLDCNT & BLDCNT_SFX) |
584 | | { |
585 | | case BLDCNT_SFX_LIGHTEN: |
586 | | if(top & m_BLDCNT) |
587 | | { |
588 | | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
589 | | } |
590 | | break; |
591 | | case BLDCNT_SFX_DARKEN: |
592 | | if(top & m_BLDCNT) |
593 | | { |
594 | | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
595 | | } |
596 | | break; |
597 | | } |
598 | | } |
599 | | } |
600 | | lineMix[x] = color; |
601 | | } |
602 | | } |
trunk/src/mess/video/gba.c
r23309 | r23310 | |
36 | 36 | INLINE UINT32 increase_brightness(UINT32 color, int coeff_); |
37 | 37 | INLINE UINT32 decrease_brightness(UINT32 color, int coeff_); |
38 | 38 | |
39 | | #include "gbamode0.c" |
40 | | #include "gbamode1.c" |
41 | | #include "gbamode2.c" |
42 | | #include "gbam345.c" |
| 39 | #define GBA_MODE0 0 |
| 40 | #define GBA_MODE1 1 |
| 41 | #define GBA_MODE2 2 |
| 42 | #define GBA_MODE345 3 |
43 | 43 | |
| 44 | #define GBA_SUBMODE0 0 |
| 45 | #define GBA_SUBMODE1 1 |
| 46 | #define GBA_SUBMODE2 2 |
44 | 47 | |
| 48 | void gba_state::draw_modes(int mode, int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp) |
| 49 | { |
| 50 | UINT32 backdrop = ((UINT16*)m_gba_pram.target())[0] | 0x30000000; |
| 51 | int inWindow0 = 0; |
| 52 | int inWindow1 = 0; |
| 53 | UINT8 inWin0Mask = m_WININ & 0x00ff; |
| 54 | UINT8 inWin1Mask = m_WININ >> 8; |
| 55 | UINT8 outMask = m_WINOUT & 0x00ff; |
| 56 | |
| 57 | if (submode == GBA_SUBMODE2) |
| 58 | { |
| 59 | if (m_DISPCNT & DISPCNT_WIN0_EN) |
| 60 | { |
| 61 | UINT8 v0 = m_WIN0V >> 8; |
| 62 | UINT8 v1 = m_WIN0V & 0x00ff; |
| 63 | inWindow0 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; |
| 64 | if (v1 >= v0) |
| 65 | inWindow0 |= (y >= v0 && y < v1) ? 1 : 0; |
| 66 | else |
| 67 | inWindow0 |= (y >= v0 || y < v1) ? 1 : 0; |
| 68 | } |
| 69 | |
| 70 | if (m_DISPCNT & DISPCNT_WIN1_EN) |
| 71 | { |
| 72 | UINT8 v0 = m_WIN1V >> 8; |
| 73 | UINT8 v1 = m_WIN1V & 0x00ff; |
| 74 | inWindow1 = ((v0 == v1) && (v0 >= 0xe8)) ? 1 : 0; |
| 75 | if (v1 >= v0) |
| 76 | inWindow1 |= (y >= v0 && y < v1) ? 1 : 0; |
| 77 | else |
| 78 | inWindow1 |= (y >= v0 || y < v1) ? 1 : 0; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | // Draw BG |
| 83 | switch (mode) |
| 84 | { |
| 85 | case 0: |
| 86 | draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS); |
| 87 | draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS); |
| 88 | draw_bg_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2HOFS, m_BG2VOFS); |
| 89 | draw_bg_scanline(line3, y, DISPCNT_BG3_EN, m_BG3CNT, m_BG3HOFS, m_BG3VOFS); |
| 90 | break; |
| 91 | case 1: |
| 92 | draw_bg_scanline(line0, y, DISPCNT_BG0_EN, m_BG0CNT, m_BG0HOFS, m_BG0VOFS); |
| 93 | draw_bg_scanline(line1, y, DISPCNT_BG1_EN, m_BG1CNT, m_BG1HOFS, m_BG1VOFS); |
| 94 | draw_roz_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed); |
| 95 | break; |
| 96 | case 2: |
| 97 | draw_roz_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed); |
| 98 | draw_roz_scanline(line3, y, DISPCNT_BG3_EN, m_BG3CNT, m_BG3X, m_BG3Y, m_BG3PA, m_BG3PB, m_BG3PC, m_BG3PD, &m_gfxBG3X, &m_gfxBG3Y, m_gfxBG3Changed); |
| 99 | break; |
| 100 | case 3: |
| 101 | case 4: |
| 102 | case 5: |
| 103 | draw_roz_bitmap_scanline(line2, y, DISPCNT_BG2_EN, m_BG2CNT, m_BG2X, m_BG2Y, m_BG2PA, m_BG2PB, m_BG2PC, m_BG2PD, &m_gfxBG2X, &m_gfxBG2Y, m_gfxBG2Changed, bpp); |
| 104 | break; |
| 105 | } |
| 106 | |
| 107 | // Draw OAM |
| 108 | draw_gba_oam(lineOBJ, y); |
| 109 | if (submode == GBA_SUBMODE2) |
| 110 | draw_gba_oam_window(lineOBJWin, y); |
| 111 | |
| 112 | for (int x = 0; x < 240; x++) |
| 113 | { |
| 114 | UINT32 color = backdrop; |
| 115 | UINT8 top = 0x20; |
| 116 | UINT8 mask = outMask; |
| 117 | |
| 118 | if (submode == GBA_SUBMODE2) |
| 119 | { |
| 120 | if ((lineOBJWin[x] & 0x80000000) == 0) |
| 121 | mask = m_WINOUT >> 8; |
| 122 | |
| 123 | if (inWindow1) |
| 124 | { |
| 125 | if (is_in_window(x, 1)) |
| 126 | mask = inWin1Mask; |
| 127 | } |
| 128 | |
| 129 | if (inWindow0) |
| 130 | { |
| 131 | if (is_in_window(x, 0)) |
| 132 | mask = inWin0Mask; |
| 133 | } |
| 134 | |
| 135 | } |
| 136 | |
| 137 | if (mode == GBA_MODE0 || mode == GBA_MODE1) |
| 138 | if ((UINT8)(line0[x] >> 24) < (UINT8)(color >> 24) && (submode == GBA_SUBMODE0 || submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x01))) |
| 139 | { |
| 140 | color = line0[x]; |
| 141 | top = 0x01; |
| 142 | } |
| 143 | |
| 144 | if (mode == GBA_MODE0 || mode == GBA_MODE1) |
| 145 | if ((UINT8)(line1[x] >> 24) < (UINT8)(color >> 24) && (submode == GBA_SUBMODE0 || submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x02))) |
| 146 | { |
| 147 | color = line1[x]; |
| 148 | top = 0x02; |
| 149 | } |
| 150 | |
| 151 | if (mode == GBA_MODE0 || mode == GBA_MODE1 || mode == GBA_MODE2 || mode == GBA_MODE345) |
| 152 | if ((UINT8)(line2[x] >> 24) < (UINT8)(color >> 24) && (submode == GBA_SUBMODE0 || submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x04))) |
| 153 | { |
| 154 | color = line2[x]; |
| 155 | top = 0x04; |
| 156 | } |
| 157 | |
| 158 | if (mode == GBA_MODE0 || mode == GBA_MODE2) |
| 159 | if ((UINT8)(line3[x] >> 24) < (UINT8)(color >> 24) && (submode == GBA_SUBMODE0 || submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x08))) |
| 160 | { |
| 161 | color = line3[x]; |
| 162 | top = 0x08; |
| 163 | } |
| 164 | |
| 165 | if (mode == GBA_MODE0 || mode == GBA_MODE1 || mode == GBA_MODE2 || mode == GBA_MODE345) |
| 166 | if ((UINT8)(lineOBJ[x] >> 24) < (UINT8)(color >> 24) && (submode == GBA_SUBMODE0 || submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x10))) |
| 167 | { |
| 168 | color = lineOBJ[x]; |
| 169 | top = 0x10; |
| 170 | } |
| 171 | |
| 172 | if (color & 0x00010000) |
| 173 | { |
| 174 | if ((submode == GBA_SUBMODE0 && top == 0x10) || submode == GBA_SUBMODE1 || submode == GBA_SUBMODE2) |
| 175 | { |
| 176 | UINT32 back = backdrop; |
| 177 | UINT8 top2 = 0x20; |
| 178 | |
| 179 | if (mode == GBA_MODE0 || mode == GBA_MODE1) |
| 180 | if ((UINT8)(line0[x] >> 24) < (UINT8)(back >> 24) && (submode == GBA_SUBMODE0 || submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x01))) |
| 181 | { |
| 182 | back = line0[x]; |
| 183 | top2 = 0x01; |
| 184 | } |
| 185 | |
| 186 | if (mode == GBA_MODE0 || mode == GBA_MODE1) |
| 187 | if ((UINT8)(line1[x] >> 24) < (UINT8)(back >> 24) && (submode == GBA_SUBMODE0 || submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x02))) |
| 188 | { |
| 189 | back = line1[x]; |
| 190 | top2 = 0x02; |
| 191 | } |
| 192 | |
| 193 | if (mode == GBA_MODE0 || mode == GBA_MODE1 || mode == GBA_MODE2 || mode == GBA_MODE345) |
| 194 | if ((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24) && (submode == GBA_SUBMODE0 || submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x04))) |
| 195 | { |
| 196 | back = line2[x]; |
| 197 | top2 = 0x04; |
| 198 | } |
| 199 | |
| 200 | if (mode == GBA_MODE0 || mode == GBA_MODE2) |
| 201 | if ((UINT8)(line3[x] >> 24) < (UINT8)(back >> 24) && (submode == GBA_SUBMODE0 || submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x08))) |
| 202 | { |
| 203 | back = line3[x]; |
| 204 | top2 = 0x08; |
| 205 | } |
| 206 | |
| 207 | if (top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
| 208 | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
| 209 | else |
| 210 | { |
| 211 | if (top & m_BLDCNT) |
| 212 | { |
| 213 | switch(m_BLDCNT & BLDCNT_SFX) |
| 214 | { |
| 215 | case BLDCNT_SFX_LIGHTEN: |
| 216 | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
| 217 | break; |
| 218 | case BLDCNT_SFX_DARKEN: |
| 219 | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
| 220 | break; |
| 221 | } |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | else if (submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x20)) |
| 227 | { |
| 228 | if (top & m_BLDCNT) |
| 229 | { |
| 230 | switch(m_BLDCNT & BLDCNT_SFX) |
| 231 | { |
| 232 | case BLDCNT_SFX_NONE: |
| 233 | break; |
| 234 | case BLDCNT_SFX_ALPHA: |
| 235 | { |
| 236 | UINT32 back = backdrop; |
| 237 | UINT8 top2 = 0x20; |
| 238 | |
| 239 | if (mode == GBA_MODE0 || mode == GBA_MODE1) |
| 240 | if ((UINT8)(line0[x] >> 24) < (UINT8)(back >> 24) && (submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x01))) |
| 241 | { |
| 242 | if (top != 0x01) |
| 243 | { |
| 244 | back = line0[x]; |
| 245 | top2 = 0x01; |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | if (mode == GBA_MODE0 || mode == GBA_MODE1) |
| 250 | if ((UINT8)(line1[x] >> 24) < (UINT8)(back >> 24) && (submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x02))) |
| 251 | { |
| 252 | if (top != 0x02) |
| 253 | { |
| 254 | back = line1[x]; |
| 255 | top2 = 0x02; |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | if (mode == GBA_MODE0 || mode == GBA_MODE1 || mode == GBA_MODE2 || mode == GBA_MODE345) |
| 260 | if ((UINT8)(line2[x] >> 24) < (UINT8)(back >> 24) && (submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x04))) |
| 261 | { |
| 262 | if (top != 0x04) |
| 263 | { |
| 264 | back = line2[x]; |
| 265 | top2 = 0x04; |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | if (mode == GBA_MODE0 || mode == GBA_MODE2) |
| 270 | if ((UINT8)(line3[x] >> 24) < (UINT8)(back >> 24) && (submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x08))) |
| 271 | { |
| 272 | if (top != 0x08) |
| 273 | { |
| 274 | back = line3[x]; |
| 275 | top2 = 0x08; |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | if (mode == GBA_MODE0 || mode == GBA_MODE1 || mode == GBA_MODE2 || mode == GBA_MODE345) |
| 280 | if ((UINT8)(lineOBJ[x] >> 24) < (UINT8)(back >> 24) && (submode == GBA_SUBMODE1 || (submode == GBA_SUBMODE2 && mask & 0x10))) |
| 281 | { |
| 282 | if (top != 0x10) |
| 283 | { |
| 284 | back = lineOBJ[x]; |
| 285 | top2 = 0x10; |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | if (top2 & (m_BLDCNT >> BLDCNT_TP2_SHIFT)) |
| 290 | color = alpha_blend_pixel(color, back, coeff[m_BLDALPHA & 0x1f], coeff[(m_BLDALPHA >> 8) & 0x1f]); |
| 291 | } |
| 292 | break; |
| 293 | case BLDCNT_SFX_LIGHTEN: |
| 294 | color = increase_brightness(color, coeff[m_BLDY & 0x1f]); |
| 295 | break; |
| 296 | case BLDCNT_SFX_DARKEN: |
| 297 | color = decrease_brightness(color, coeff[m_BLDY & 0x1f]); |
| 298 | break; |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | lineMix[x] = color; |
| 303 | } |
| 304 | if (mode == GBA_MODE1 || mode == GBA_MODE2 || mode == GBA_MODE345) |
| 305 | m_gfxBG2Changed = 0; |
| 306 | if (mode == GBA_MODE2) |
| 307 | m_gfxBG3Changed = 0; |
| 308 | } |
| 309 | |
45 | 310 | void gba_state::draw_roz_bitmap_scanline(UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, INT32 X, INT32 Y, INT32 PA, INT32 PB, INT32 PC, INT32 PD, INT32 *currentx, INT32 *currenty, int changed, int depth) |
46 | 311 | { |
47 | 312 | UINT8 *src8 = (UINT8 *)m_gba_vram.target(); |
r23309 | r23310 | |
50 | 315 | INT32 sx = (depth == 4) ? 160 : 240; |
51 | 316 | INT32 sy = (depth == 4) ? 128 : 160; |
52 | 317 | UINT32 prio = ((ctrl & BGCNT_PRIORITY) << 25) + 0x1000000; |
53 | | INT32 dx, dmx, dy, dmy, startx, starty; |
54 | | INT32 rx, ry, pixx, pixy, x; |
55 | | |
| 318 | INT32 cx, cy, pixx, pixy, x; |
| 319 | |
56 | 320 | if ((depth == 8) && (m_DISPCNT & DISPCNT_FRAMESEL)) |
57 | 321 | src8 += 0xa000; |
58 | | |
| 322 | |
59 | 323 | if ((depth == 4) && (m_DISPCNT & DISPCNT_FRAMESEL)) |
60 | 324 | src16 += 0xa000/2; |
61 | | |
| 325 | |
62 | 326 | // sign extend roz parameters |
63 | 327 | if (X & 0x08000000) X |= 0xf0000000; |
64 | 328 | if (Y & 0x08000000) Y |= 0xf0000000; |
r23309 | r23310 | |
66 | 330 | if (PB & 0x8000) PB |= 0xffff0000; |
67 | 331 | if (PC & 0x8000) PC |= 0xffff0000; |
68 | 332 | if (PD & 0x8000) PD |= 0xffff0000; |
69 | | |
70 | | // re-assign parameters for convenience's sake |
71 | | dx = PA; |
72 | | dmx = PB; |
73 | | dy = PC; |
74 | | dmy = PD; |
75 | | startx = X; |
76 | | starty = Y; |
77 | | |
| 333 | |
78 | 334 | if(ypos == 0) |
79 | 335 | changed = 3; |
80 | | |
| 336 | |
81 | 337 | if(changed & 1) |
82 | | *currentx = startx; |
| 338 | *currentx = X; |
83 | 339 | else |
84 | | *currentx += dmx; |
85 | | |
| 340 | *currentx += PB; |
| 341 | |
86 | 342 | if(changed & 2) |
87 | | *currenty = starty; |
| 343 | *currenty = Y; |
88 | 344 | else |
89 | | *currenty += dmy; |
90 | | |
91 | | rx = *currentx; |
92 | | ry = *currenty; |
93 | | |
| 345 | *currenty += PD; |
| 346 | |
| 347 | cx = *currentx; |
| 348 | cy = *currenty; |
| 349 | |
94 | 350 | if(ctrl & BGCNT_MOSAIC) |
95 | 351 | { |
96 | | INT32 mosaic_line = ((m_MOSAIC & 0x00f0) >> 4) + 1; |
| 352 | INT32 mosaic_line = ((m_MOSAIC & 0xf0) >> 4) + 1; |
97 | 353 | INT32 tempy = (ypos / mosaic_line) * mosaic_line; |
98 | | rx = startx + tempy*dmx; |
99 | | ry = starty + tempy*dmy; |
| 354 | cx = X + tempy*PB; |
| 355 | cy = Y + tempy*PD; |
100 | 356 | } |
101 | | |
102 | | pixx = rx >> 8; |
103 | | pixy = ry >> 8; |
104 | | |
| 357 | |
| 358 | pixx = cx >> 8; |
| 359 | pixy = cy >> 8; |
| 360 | |
105 | 361 | for(x = 0; x < 240; x++) |
106 | 362 | { |
107 | 363 | if(pixx < 0 || pixy < 0 || pixx >= sx || pixy >= sy) |
r23309 | r23310 | |
120 | 376 | scanline[x] = src16[pixy*sx + pixx] | prio; |
121 | 377 | } |
122 | 378 | } |
123 | | |
124 | | rx += dx; |
125 | | ry += dy; |
126 | | |
127 | | pixx = rx >> 8; |
128 | | pixy = ry >> 8; |
| 379 | |
| 380 | cx += PA; |
| 381 | cy += PC; |
| 382 | |
| 383 | pixx = cx >> 8; |
| 384 | pixy = cy >> 8; |
129 | 385 | } |
130 | | |
| 386 | |
131 | 387 | if(ctrl & BGCNT_MOSAIC) |
132 | 388 | { |
133 | 389 | INT32 mosaicx = (m_MOSAIC & 0x0f) + 1; |
r23309 | r23310 | |
152 | 408 | { |
153 | 409 | UINT32 base, mapbase, size; |
154 | 410 | static const INT32 sizes[4] = { 128, 256, 512, 1024 }; |
155 | | INT32 cx, cy, x, pixx, pixy; |
| 411 | INT32 cx, cy, pixx, pixy; |
156 | 412 | UINT8 *mgba_vram = (UINT8 *)m_gba_vram.target(); |
157 | 413 | UINT32 tile; |
158 | 414 | UINT16 *pgba_pram = (UINT16 *)m_gba_pram.target(); |
159 | 415 | UINT16 pixel; |
160 | 416 | UINT32 prio = ((ctrl & BGCNT_PRIORITY) << 25) + 0x1000000; |
| 417 | int x = 0; |
161 | 418 | |
162 | | for(x = 0; x < 240; x++) |
163 | | { |
| 419 | for (x = 0; x < 240; x++) |
164 | 420 | scanline[x] = 0x80000000; |
165 | | } |
166 | 421 | |
167 | 422 | if (m_DISPCNT & enablemask) |
168 | 423 | { |
r23309 | r23310 | |
179 | 434 | if (PD & 0x8000) PD |= 0xffff0000; |
180 | 435 | |
181 | 436 | if(ypos == 0) |
182 | | { |
183 | 437 | changed = 3; |
184 | | } |
185 | 438 | |
186 | 439 | if(changed & 1) |
187 | | { |
188 | 440 | *currentx = X; |
189 | | } |
190 | 441 | else |
191 | | { |
192 | 442 | *currentx += PB; |
193 | | } |
194 | 443 | |
195 | 444 | if(changed & 2) |
196 | | { |
197 | 445 | *currenty = Y; |
198 | | } |
199 | 446 | else |
200 | | { |
201 | 447 | *currenty += PD; |
202 | | } |
203 | 448 | |
204 | 449 | cx = *currentx; |
205 | 450 | cy = *currenty; |
206 | 451 | |
207 | 452 | if(ctrl & BGCNT_MOSAIC) |
208 | 453 | { |
209 | | int mosaicy = ((m_MOSAIC & 0xf0) >> 4) + 1; |
210 | | int y = ypos % mosaicy; |
| 454 | int mosaic_line = ((m_MOSAIC & 0xf0) >> 4) + 1; |
| 455 | int y = ypos % mosaic_line; |
211 | 456 | cx -= y*PB; |
212 | 457 | cy -= y*PD; |
213 | 458 | } |
r23309 | r23310 | |
229 | 474 | } |
230 | 475 | } |
231 | 476 | |
232 | | if(ctrl & BGCNT_PALETTE256) |
| 477 | for(x = 0; x < 240; x++) |
233 | 478 | { |
234 | | for(x = 0; x < 240; x++) |
| 479 | if(pixx < 0 || pixy < 0 || pixx >= sizes[size] || pixy >= sizes[size]) |
235 | 480 | { |
236 | | if(pixx < 0 || pixy < 0 || pixx >= sizes[size] || pixy >= sizes[size]) |
237 | | { |
238 | | scanline[x] = 0x80000000; |
239 | | } |
240 | | else |
241 | | { |
242 | | int tilex = pixx & 7; |
243 | | int tiley = pixy & 7; |
| 481 | scanline[x] = 0x80000000; |
| 482 | } |
| 483 | else |
| 484 | { |
| 485 | int tilex = pixx & 7; |
| 486 | int tiley = pixy & 7; |
244 | 487 | |
245 | | tile = mgba_vram[mapbase + (pixx >> 3) + (pixy >> 3) * (sizes[size] >> 3)]; |
246 | | pixel = mgba_vram[base + (tile << 6) + (tiley << 3) + tilex]; |
247 | | |
248 | | // plot it |
249 | | scanline[x] = pixel ? (pgba_pram[pixel] | prio) : 0x80000000; |
250 | | } |
251 | | |
252 | | cx += PA; |
253 | | cy += PC; |
254 | | |
255 | | pixx = cx >> 8; |
256 | | pixy = cy >> 8; |
257 | | |
258 | | if(ctrl & BGCNT_PALETTESET_WRAP) |
259 | | { |
260 | | pixx %= sizes[size]; |
261 | | pixy %= sizes[size]; |
262 | | if(pixx < 0) |
263 | | { |
264 | | pixx += sizes[size]; |
265 | | } |
266 | | if(pixy < 0) |
267 | | { |
268 | | pixy += sizes[size]; |
269 | | } |
270 | | } |
| 488 | // shall we shift for (ctrl & BGCNT_PALETTE256)?? or is not effective for ROZ? |
| 489 | tile = mgba_vram[mapbase + (pixx >> 3) + (pixy >> 3) * (sizes[size] >> 3)]; |
| 490 | pixel = mgba_vram[base + (tile << 6) + (tiley << 3) + tilex]; |
| 491 | |
| 492 | // plot it |
| 493 | scanline[x] = pixel ? (pgba_pram[pixel] | prio) : 0x80000000; |
271 | 494 | } |
272 | | } |
273 | | else |
274 | | { |
275 | | for(x = 0; x < 240; x++) |
| 495 | |
| 496 | cx += PA; |
| 497 | cy += PC; |
| 498 | |
| 499 | pixx = cx >> 8; |
| 500 | pixy = cy >> 8; |
| 501 | |
| 502 | if(ctrl & BGCNT_PALETTESET_WRAP) |
276 | 503 | { |
277 | | if(pixx < 0 || pixy < 0 || pixx >= sizes[size] || pixy >= sizes[size]) |
| 504 | pixx %= sizes[size]; |
| 505 | pixy %= sizes[size]; |
| 506 | if(pixx < 0) |
278 | 507 | { |
279 | | scanline[x] = 0x80000000; |
| 508 | pixx += sizes[size]; |
280 | 509 | } |
281 | | else |
| 510 | if(pixy < 0) |
282 | 511 | { |
283 | | int tilex = pixx & 7; |
284 | | int tiley = pixy & 7; |
285 | | |
286 | | tile = mgba_vram[mapbase + (pixx >> 3) + (pixy >> 3) * (sizes[size] >> 3)]; |
287 | | pixel = mgba_vram[base + (tile << 6) + (tiley << 3) + tilex]; |
288 | | |
289 | | // plot it |
290 | | scanline[x] = pixel ? (pgba_pram[pixel] | prio) : 0x80000000; |
| 512 | pixy += sizes[size]; |
291 | 513 | } |
292 | | |
293 | | cx += PA; |
294 | | cy += PC; |
295 | | |
296 | | pixx = cx >> 8; |
297 | | pixy = cy >> 8; |
298 | | |
299 | | if(ctrl & BGCNT_PALETTESET_WRAP) |
300 | | { |
301 | | pixx %= sizes[size]; |
302 | | pixy %= sizes[size]; |
303 | | if(pixx < 0) |
304 | | { |
305 | | pixx += sizes[size]; |
306 | | } |
307 | | if(pixy < 0) |
308 | | { |
309 | | pixy += sizes[size]; |
310 | | } |
311 | | } |
312 | 514 | } |
313 | 515 | } |
314 | 516 | |
r23309 | r23310 | |
347 | 549 | INT32 mosaicx = (m_MOSAIC & 0x000f) + 1; |
348 | 550 | INT32 mosaicy = ((m_MOSAIC & 0x00f0) >> 4) + 1; |
349 | 551 | INT32 stride; |
350 | | INT32 x; |
| 552 | int x = 0; |
351 | 553 | |
352 | | if(!(m_DISPCNT & enablemask)) |
| 554 | for (x = 0; x < 240; x++) |
| 555 | scanline[x] = 0x80000000; |
| 556 | |
| 557 | if(m_DISPCNT & enablemask) |
353 | 558 | { |
354 | | for(x = 0; x < 240; x++) |
| 559 | |
| 560 | switch((ctrl & BGCNT_SCREENSIZE) >> BGCNT_SCREENSIZE_SHIFT) |
355 | 561 | { |
356 | | scanline[x] = 0x80000000; |
| 562 | case 1: |
| 563 | width = 512; |
| 564 | break; |
| 565 | case 2: |
| 566 | height = 512; |
| 567 | break; |
| 568 | case 3: |
| 569 | width = 512; |
| 570 | height = 512; |
| 571 | break; |
357 | 572 | } |
358 | | |
359 | | return; |
360 | | } |
361 | | |
362 | | switch((ctrl & BGCNT_SCREENSIZE) >> BGCNT_SCREENSIZE_SHIFT) |
363 | | { |
364 | | case 1: |
365 | | width = 512; |
366 | | break; |
367 | | case 2: |
368 | | height = 512; |
369 | | break; |
370 | | case 3: |
371 | | width = 512; |
372 | | height = 512; |
373 | | break; |
374 | | } |
375 | | |
376 | | maskx = width - 1; |
377 | | masky = height - 1; |
378 | | |
379 | | pixx = hofs & maskx; |
380 | | pixy = (vofs + ypos) & masky; |
381 | | |
382 | | if(use_mosaic) |
383 | | { |
384 | | if((ypos % mosaicy) != 0) |
| 573 | |
| 574 | maskx = width - 1; |
| 575 | masky = height - 1; |
| 576 | |
| 577 | pixx = hofs & maskx; |
| 578 | pixy = (vofs + ypos) & masky; |
| 579 | |
| 580 | if(use_mosaic) |
385 | 581 | { |
386 | | mosaicy = (ypos / mosaicy) * mosaicy; |
387 | | pixy = (vofs + mosaicy) & masky; |
| 582 | if((ypos % mosaicy) != 0) |
| 583 | { |
| 584 | mosaicy = (ypos / mosaicy) * mosaicy; |
| 585 | pixy = (vofs + mosaicy) & masky; |
| 586 | } |
388 | 587 | } |
389 | | } |
390 | | |
391 | | if(pixy > 255 && height > 256) |
392 | | { |
393 | | pixy &= 0x000000ff; |
394 | | screendata += 0x400; |
395 | | if(width > 256) |
| 588 | |
| 589 | if(pixy > 255 && height > 256) |
396 | 590 | { |
| 591 | pixy &= 0x000000ff; |
397 | 592 | screendata += 0x400; |
398 | | } |
399 | | } |
400 | | |
401 | | stride = (pixy >> 3) << 5; |
402 | | |
403 | | if(ctrl & BGCNT_PALETTE256) |
404 | | { |
405 | | UINT16 *src = screendata + 0x400 * (pixx >> 8) + ((pixx & 255) >> 3) + stride; |
406 | | for(x = 0; x < 240; x++) |
407 | | { |
408 | | UINT16 data = *src; |
409 | | INT32 tile = data & TILEOBJ_TILE; |
410 | | INT32 tilex = pixx & 7; |
411 | | INT32 tiley = pixy & 7; |
412 | | UINT8 color; |
413 | | |
414 | | if(data & TILEOBJ_HFLIP) |
| 593 | if(width > 256) |
415 | 594 | { |
416 | | tilex = 7 - tilex; |
| 595 | screendata += 0x400; |
417 | 596 | } |
418 | | if(data & TILEOBJ_VFLIP) |
419 | | { |
420 | | tiley = 7 - tiley; |
421 | | } |
422 | | |
423 | | color = chardata[(tile << 6) + (tiley << 3) + tilex]; |
424 | | |
425 | | if(color) |
426 | | { |
427 | | scanline[x] = palette[color] | priority; |
428 | | } |
429 | | else |
430 | | { |
431 | | scanline[x] = 0x80000000; |
432 | | } |
433 | | |
434 | | if(data & TILEOBJ_HFLIP) |
435 | | { |
436 | | if(tilex == 0) |
437 | | { |
438 | | src++; |
439 | | } |
440 | | } |
441 | | else if(tilex == 7) |
442 | | { |
443 | | src++; |
444 | | } |
445 | | |
446 | | pixx++; |
447 | | if(pixx == 256) |
448 | | { |
449 | | if(width > 256) |
450 | | { |
451 | | src = screendata + 0x400 + stride; |
452 | | } |
453 | | else |
454 | | { |
455 | | src = screendata + stride; |
456 | | pixx = 0; |
457 | | } |
458 | | } |
459 | | else if(pixx >= width) |
460 | | { |
461 | | pixx = 0; |
462 | | src = screendata + stride; |
463 | | } |
464 | 597 | } |
465 | | } |
466 | | else |
467 | | { |
| 598 | |
| 599 | stride = (pixy >> 3) << 5; |
| 600 | |
468 | 601 | UINT16 *src = screendata + 0x400 * (pixx >> 8) + ((pixx & 255) >> 3) + stride; |
469 | 602 | for(x = 0; x < 240; x++) |
470 | 603 | { |
r23309 | r23310 | |
474 | 607 | INT32 tiley = pixy & 7; |
475 | 608 | UINT8 color; |
476 | 609 | UINT8 palindex; |
477 | | |
| 610 | |
478 | 611 | if(data & TILEOBJ_HFLIP) |
479 | 612 | { |
480 | 613 | tilex = 7 - tilex; |
r23309 | r23310 | |
483 | 616 | { |
484 | 617 | tiley = 7 - tiley; |
485 | 618 | } |
486 | | |
487 | | color = chardata[(tile << 5) + (tiley << 2) + (tilex >> 1)]; |
488 | | |
489 | | if(tilex & 1) |
| 619 | |
| 620 | if (ctrl & BGCNT_PALETTE256) |
490 | 621 | { |
491 | | color >>= 4; |
| 622 | color = chardata[(tile << 6) + (tiley << 3) + tilex]; |
| 623 | palindex = 0; |
492 | 624 | } |
493 | 625 | else |
494 | 626 | { |
495 | | color &= 0x0f; |
496 | | } |
| 627 | color = chardata[(tile << 5) + (tiley << 2) + (tilex >> 1)]; |
| 628 | |
| 629 | if (tilex & 1) |
| 630 | color >>= 4; |
| 631 | else |
| 632 | color &= 0x0f; |
| 633 | palindex = (data >> 8) & 0x00f0; |
| 634 | } |
497 | 635 | |
498 | | palindex = (data >> 8) & 0x00f0; |
499 | | if(color) |
500 | | { |
| 636 | if (color) |
501 | 637 | scanline[x] = palette[palindex + color] | priority; |
502 | | } |
503 | 638 | else |
504 | | { |
505 | 639 | scanline[x] = 0x80000000; |
506 | | } |
507 | | |
508 | | if(data & TILEOBJ_HFLIP) |
| 640 | |
| 641 | if (data & TILEOBJ_HFLIP) |
509 | 642 | { |
510 | | if(tilex == 0) |
| 643 | if (tilex == 0) |
511 | 644 | { |
512 | 645 | src++; |
513 | 646 | } |
514 | 647 | } |
515 | | else if(tilex == 7) |
| 648 | else if (tilex == 7) |
516 | 649 | { |
517 | 650 | src++; |
518 | 651 | } |
519 | | |
| 652 | |
520 | 653 | pixx++; |
521 | 654 | if(pixx == 256) |
522 | 655 | { |
r23309 | r23310 | |
536 | 669 | src = screendata + stride; |
537 | 670 | } |
538 | 671 | } |
539 | | } |
540 | | |
541 | | if(use_mosaic) |
542 | | { |
543 | | if(mosaicx > 1) |
| 672 | |
| 673 | if(use_mosaic) |
544 | 674 | { |
545 | | INT32 m = 1; |
546 | | for(x = 0; x < 239; x++) |
| 675 | if(mosaicx > 1) |
547 | 676 | { |
548 | | scanline[x+1] = scanline[x]; |
549 | | m++; |
550 | | if(m == mosaicx) |
| 677 | INT32 m = 1; |
| 678 | for(x = 0; x < 239; x++) |
551 | 679 | { |
552 | | m = 1; |
553 | | x++; |
| 680 | scanline[x+1] = scanline[x]; |
| 681 | m++; |
| 682 | if(m == mosaicx) |
| 683 | { |
| 684 | m = 1; |
| 685 | x++; |
| 686 | } |
554 | 687 | } |
555 | 688 | } |
556 | 689 | } |
| 690 | |
557 | 691 | } |
558 | 692 | } |
559 | 693 | |
r23309 | r23310 | |
563 | 697 | UINT32 tilebytebase, tileindex, tiledrawindex; |
564 | 698 | UINT32 width, height; |
565 | 699 | UINT16 *pgba_oam = (UINT16 *)m_gba_oam.target(); |
| 700 | UINT8 *src = (UINT8*)m_gba_vram.target(); |
566 | 701 | int x = 0; |
567 | | UINT8 *src = (UINT8*)m_gba_vram.target(); |
568 | 702 | |
569 | | for(x = 0; x < 240; x++) |
570 | | { |
| 703 | for (x = 0; x < 240; x++) |
571 | 704 | scanline[x] = 0x80000000; |
572 | | } |
573 | | |
574 | | if( m_DISPCNT & DISPCNT_OBJWIN_EN ) |
| 705 | |
| 706 | if (m_DISPCNT & DISPCNT_OBJWIN_EN) |
575 | 707 | { |
576 | 708 | for( gba_oamindex = 127; gba_oamindex >= 0; gba_oamindex-- ) |
577 | 709 | { |
r23309 | r23310 | |
1016 | 1148 | UINT16 *palette = (UINT16*)m_gba_pram.target(); |
1017 | 1149 | int x = 0; |
1018 | 1150 | |
1019 | | for(x = 0; x < 240; x++) |
1020 | | { |
| 1151 | for (x = 0; x < 240; x++) |
1021 | 1152 | scanline[x] = 0x80000000; |
1022 | | } |
1023 | | |
| 1153 | |
1024 | 1154 | if( m_DISPCNT & DISPCNT_OBJ_EN ) |
1025 | 1155 | { |
1026 | 1156 | for( gba_oamindex = 0; gba_oamindex < 128; gba_oamindex++ ) |
r23309 | r23310 | |
1686 | 1816 | { |
1687 | 1817 | bitmap_ind16 &bitmap = m_bitmap; |
1688 | 1818 | UINT16 *scanline = &bitmap.pix16(y); |
1689 | | int i, x; |
1690 | 1819 | UINT8 submode = 0; |
| 1820 | int depth = 0; |
1691 | 1821 | |
1692 | 1822 | // forced blank |
1693 | 1823 | if (m_DISPCNT & DISPCNT_BLANK) |
1694 | 1824 | { |
1695 | 1825 | // forced blank is white |
1696 | | for (i = 0; i < 240; i++) |
1697 | | { |
1698 | | scanline[i] = 0x7fff; |
1699 | | } |
| 1826 | for (int x = 0; x < 240; x++) |
| 1827 | scanline[x] = 0x7fff; |
1700 | 1828 | return; |
1701 | 1829 | } |
1702 | 1830 | |
1703 | 1831 | if(!m_fxOn && !m_windowOn && !(m_DISPCNT & DISPCNT_OBJWIN_EN)) |
1704 | | { |
1705 | | submode = 0; |
1706 | | } |
| 1832 | submode = GBA_SUBMODE0; |
1707 | 1833 | else if(m_fxOn && !m_windowOn && !(m_DISPCNT & DISPCNT_OBJWIN_EN)) |
1708 | | { |
1709 | | submode = 1; |
1710 | | } |
| 1834 | submode = GBA_SUBMODE1; |
1711 | 1835 | else |
1712 | | { |
1713 | | submode = 2; |
1714 | | } |
| 1836 | submode = GBA_SUBMODE2; |
1715 | 1837 | |
1716 | | //printf( "mode = %d, %d\n", m_DISPCNT & 7, submode ); |
| 1838 | if (m_DISPCNT & 7 == 3) |
| 1839 | depth = 16; |
| 1840 | else if (m_DISPCNT & 7 == 4) |
| 1841 | depth = 8; |
| 1842 | else if (m_DISPCNT & 7 == 5) |
| 1843 | depth = 4; |
| 1844 | |
| 1845 | //printf("mode = %d, %d\n", m_DISPCNT & 7, submode); |
1717 | 1846 | |
1718 | 1847 | switch(m_DISPCNT & 7) |
1719 | 1848 | { |
1720 | 1849 | case 0: |
1721 | | draw_mode0(submode, y, &m_xferscan[0][1024], &m_xferscan[1][1024], &m_xferscan[2][1024], &m_xferscan[3][1024], &m_xferscan[4][1024], &m_xferscan[5][1024], &m_xferscan[6][1024], 0); |
1722 | | break; |
1723 | 1850 | case 1: |
1724 | | draw_mode1(submode, y, &m_xferscan[0][1024], &m_xferscan[1][1024], &m_xferscan[2][1024], &m_xferscan[3][1024], &m_xferscan[4][1024], &m_xferscan[5][1024], &m_xferscan[6][1024], 0); |
1725 | | break; |
1726 | 1851 | case 2: |
1727 | | draw_mode2(submode, y, &m_xferscan[0][1024], &m_xferscan[1][1024], &m_xferscan[2][1024], &m_xferscan[3][1024], &m_xferscan[4][1024], &m_xferscan[5][1024], &m_xferscan[6][1024], 0); |
1728 | | break; |
1729 | 1852 | case 3: |
1730 | | draw_mode345(submode, y, &m_xferscan[0][1024], &m_xferscan[1][1024], &m_xferscan[2][1024], &m_xferscan[3][1024], &m_xferscan[4][1024], &m_xferscan[5][1024], &m_xferscan[6][1024], 16); |
1731 | | break; |
1732 | 1853 | case 4: |
1733 | | draw_mode345(submode, y, &m_xferscan[0][1024], &m_xferscan[1][1024], &m_xferscan[2][1024], &m_xferscan[3][1024], &m_xferscan[4][1024], &m_xferscan[5][1024], &m_xferscan[6][1024], 8); |
1734 | | break; |
1735 | 1854 | case 5: |
1736 | | draw_mode345(submode, y, &m_xferscan[0][1024], &m_xferscan[1][1024], &m_xferscan[2][1024], &m_xferscan[3][1024], &m_xferscan[4][1024], &m_xferscan[5][1024], &m_xferscan[6][1024], 4); |
| 1855 | draw_modes( m_DISPCNT & 7, submode, y, &m_xferscan[0][1024], &m_xferscan[1][1024], &m_xferscan[2][1024], &m_xferscan[3][1024], &m_xferscan[4][1024], &m_xferscan[5][1024], &m_xferscan[6][1024], depth); |
1737 | 1856 | break; |
1738 | 1857 | default: |
1739 | 1858 | fatalerror( "Invalid screen mode (6 or 7)!\n" ); |
1740 | 1859 | break; |
1741 | 1860 | } |
1742 | 1861 | |
1743 | | for(x = 0; x < 240; x++) |
| 1862 | for (int x = 0; x < 240; x++) |
1744 | 1863 | { |
1745 | 1864 | scanline[x] = m_xferscan[6][1024 + x] & 0x7fff; |
1746 | 1865 | } |
trunk/src/mess/includes/gba.h
r23309 | r23310 | |
262 | 262 | void draw_gba_oam(UINT32 *scanline, int y); |
263 | 263 | |
264 | 264 | inline int is_in_window(int x, int window); |
| 265 | |
| 266 | void draw_modes(int mode, int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp); |
265 | 267 | |
266 | | void draw_mode0(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp); |
267 | | void draw_mode1(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp); |
268 | | void draw_mode2(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp); |
269 | | void draw_mode345(int submode, int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp); |
270 | | |
271 | | void draw_mode0_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp); |
272 | | void draw_mode0_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp); |
273 | | void draw_mode0_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp); |
274 | | void draw_mode1_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp); |
275 | | void draw_mode1_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp); |
276 | | void draw_mode1_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp); |
277 | | void draw_mode2_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp); |
278 | | void draw_mode2_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp); |
279 | | void draw_mode2_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp); |
280 | | void draw_roz_bitmap_mode_scanline(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp); |
281 | | void draw_roz_bitmap_mode_scanline_nowindow(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp); |
282 | | void draw_roz_bitmap_mode_scanline_all(int y, UINT32* line0, UINT32* line1, UINT32* line2, UINT32* line3, UINT32* lineOBJ, UINT32* lineOBJWin, UINT32* lineMix, int bpp); |
283 | | |
284 | 268 | protected: |
285 | 269 | required_memory_region m_region_maincpu; |
286 | 270 | required_ioport m_io_in0; |