trunk/src/mame/video/gticlub.c
| r17906 | r17907 | |
| 23 | 23 | #define POLY_V 4 |
| 24 | 24 | #define POLY_W 5 |
| 25 | 25 | |
| 26 | #define POLY_R 3 |
| 27 | #define POLY_G 4 |
| 28 | #define POLY_B 5 |
| 29 | #define POLY_A 2 |
| 30 | |
| 26 | 31 | #define ZBUFFER_MAX 10000000000.0f |
| 27 | 32 | |
| 28 | 33 | #define LOG_POLY_FIFO 0 |
| r17906 | r17907 | |
| 778 | 783 | } |
| 779 | 784 | } |
| 780 | 785 | |
| 786 | static void draw_scanline_gouraud_blend(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid) |
| 787 | { |
| 788 | bitmap_rgb32 *destmap = (bitmap_rgb32 *)dest; |
| 789 | float z = extent->param[POLY_Z].start; |
| 790 | float dz = extent->param[POLY_Z].dpdx; |
| 791 | float r = extent->param[POLY_R].start; |
| 792 | float dr = extent->param[POLY_R].dpdx; |
| 793 | float g = extent->param[POLY_G].start; |
| 794 | float dg = extent->param[POLY_G].dpdx; |
| 795 | float b = extent->param[POLY_B].start; |
| 796 | float db = extent->param[POLY_B].dpdx; |
| 797 | float a = extent->param[POLY_A].start; |
| 798 | float da = extent->param[POLY_A].dpdx; |
| 799 | UINT32 *fb = &destmap->pix32(scanline); |
| 800 | float *zb = (float*)&K001005_zbuffer->pix32(scanline); |
| 801 | int x; |
| 802 | |
| 803 | for (x = extent->startx; x < extent->stopx; x++) |
| 804 | { |
| 805 | if (z <= zb[x]) |
| 806 | { |
| 807 | int ir = (int)(r); |
| 808 | int ig = (int)(g); |
| 809 | int ib = (int)(b); |
| 810 | int ia = (int)(a); |
| 811 | |
| 812 | if (ia > 0) |
| 813 | { |
| 814 | if (ia != 0xff) |
| 815 | { |
| 816 | int sr = (fb[x] >> 16) & 0xff; |
| 817 | int sg = (fb[x] >> 8) & 0xff; |
| 818 | int sb = fb[x] & 0xff; |
| 819 | |
| 820 | ir = ((ir * ia) >> 8) + ((sr * (0xff-ia)) >> 8); |
| 821 | ig = ((ig * ia) >> 8) + ((sg * (0xff-ia)) >> 8); |
| 822 | ib = ((ib * ia) >> 8) + ((sb * (0xff-ia)) >> 8); |
| 823 | } |
| 824 | |
| 825 | if (ir < 0) ir = 0; if (ir > 255) ir = 255; |
| 826 | if (ig < 0) ig = 0; if (ig > 255) ig = 255; |
| 827 | if (ib < 0) ib = 0; if (ib > 255) ib = 255; |
| 828 | |
| 829 | fb[x] = 0xff000000 | (ir << 16) | (ig << 8) | ib; |
| 830 | zb[x] = z; |
| 831 | } |
| 832 | } |
| 833 | |
| 834 | z += dz; |
| 835 | r += dr; |
| 836 | g += dg; |
| 837 | b += db; |
| 838 | a += da; |
| 839 | } |
| 840 | } |
| 841 | |
| 781 | 842 | static void render_polygons(running_machine &machine) |
| 782 | 843 | { |
| 783 | 844 | const rectangle& visarea = machine.primary_screen->visible_area(); |
| r17906 | r17907 | |
| 807 | 868 | // 0x20: Gouraud shading enable? |
| 808 | 869 | // 0x40: Unused? |
| 809 | 870 | // 0x80: Used by textured polygons. |
| 871 | // 0x100: Alpha blending? Only used by Winding Heat car selection so far. |
| 810 | 872 | |
| 811 | 873 | if (cmd == 0x800000ae || cmd == 0x8000008e || cmd == 0x80000096 || cmd == 0x800000b6 || |
| 812 | 874 | cmd == 0x8000002e || cmd == 0x8000000e || cmd == 0x80000016 || cmd == 0x80000036 || |
| r17906 | r17907 | |
| 1415 | 1477 | poly_render_quad(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline_2d_tex, 5, &v[0], &v[1], &v[2], &v[3]); |
| 1416 | 1478 | } |
| 1417 | 1479 | } |
| 1480 | else if (cmd == 0x80000121) |
| 1481 | { |
| 1482 | // no texture, color gouraud, Z |
| 1483 | |
| 1484 | poly_extra_data *extra = (poly_extra_data *)poly_get_extra_data(poly); |
| 1485 | UINT32 color; |
| 1486 | |
| 1487 | int last_vertex = 0; |
| 1488 | int vert_num = 0; |
| 1489 | do |
| 1490 | { |
| 1491 | int x, y, z; |
| 1492 | |
| 1493 | x = ((fifo[index] >> 0) & 0x3fff); |
| 1494 | y = ((fifo[index] >> 16) & 0x1fff); |
| 1495 | x |= ((x & 0x2000) ? 0xffffc000 : 0); |
| 1496 | y |= ((y & 0x1000) ? 0xffffe000 : 0); |
| 1497 | |
| 1498 | poly_type = fifo[index] & 0x4000; |
| 1499 | last_vertex = fifo[index] & 0x8000; |
| 1500 | index++; |
| 1501 | |
| 1502 | z = fifo[index] & 0xffffff00; |
| 1503 | brightness = fifo[index] & 0xff; |
| 1504 | index++; |
| 1505 | |
| 1506 | color = fifo[index]; |
| 1507 | index++; |
| 1508 | |
| 1509 | v[vert_num].x = ((float)(x) / 16.0f) + 256.0f; |
| 1510 | v[vert_num].y = ((float)(-y) / 16.0f) + 192.0f + 8; |
| 1511 | v[vert_num].p[POLY_Z] = *(float*)(&z); |
| 1512 | v[vert_num].p[POLY_R] = (color >> 16) & 0xff; |
| 1513 | v[vert_num].p[POLY_G] = (color >> 8) & 0xff; |
| 1514 | v[vert_num].p[POLY_B] = color & 0xff; |
| 1515 | v[vert_num].p[POLY_A] = (color >> 24) & 0xff; |
| 1516 | vert_num++; |
| 1517 | } |
| 1518 | while (!last_vertex); |
| 1519 | |
| 1520 | extra->color = color; |
| 1521 | extra->flags = cmd; |
| 1522 | |
| 1523 | if (poly_type == 0) |
| 1524 | { |
| 1525 | poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline_gouraud_blend, 6, &v[0], &v[1], &v[2]); |
| 1526 | } |
| 1527 | else |
| 1528 | { |
| 1529 | poly_render_quad(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline_gouraud_blend, 6, &v[0], &v[1], &v[2], &v[3]); |
| 1530 | } |
| 1531 | |
| 1532 | // TODO: can this poly type form strips? |
| 1533 | } |
| 1418 | 1534 | else if (cmd == 0x80000000) |
| 1419 | 1535 | { |
| 1420 | 1536 | |
| r17906 | r17907 | |
| 1423 | 1539 | { |
| 1424 | 1540 | |
| 1425 | 1541 | } |
| 1426 | | else if ((cmd & 0xffffff00) == 0x80000000) |
| 1542 | else if ((cmd & 0xffff0000) == 0x80000000) |
| 1427 | 1543 | { |
| 1428 | 1544 | /* |
| 1429 | 1545 | mame_printf_debug("Unknown polygon type %08X:\n", fifo[index-1]); |