trunk/src/mame/includes/chihiro.h
| r250231 | r250232 | |
| 232 | 232 | depthbuffer = NULL; |
| 233 | 233 | displayedtarget = NULL; |
| 234 | 234 | puller_channel = 0; |
| 235 | | puller_subchannel = 0; |
| 236 | 235 | puller_waiting = 0; |
| 237 | 236 | debug_grab_texttype = -1; |
| 238 | 237 | debug_grab_textfile = NULL; |
| 239 | | waitvblank_used = 0; |
| 238 | waitvblank_used = 1; |
| 240 | 239 | memset(vertex_attribute_words, 0, sizeof(vertex_attribute_words)); |
| 241 | 240 | memset(vertex_attribute_offset, 0, sizeof(vertex_attribute_offset)); |
| 242 | 241 | } |
| r250231 | r250232 | |
| 254 | 253 | int geforce_commandkind(UINT32 word); |
| 255 | 254 | UINT32 geforce_object_offset(UINT32 handle); |
| 256 | 255 | void geforce_read_dma_object(UINT32 handle, UINT32 &offset, UINT32 &size); |
| 256 | void geforce_assign_object(address_space &space, UINT32 chanel, UINT32 subchannel, UINT32 address); |
| 257 | 257 | int geforce_exec_method(address_space &space, UINT32 channel, UINT32 subchannel, UINT32 method, UINT32 address, int &countlen); |
| 258 | 258 | UINT32 texture_get_texel(int number, int x, int y); |
| 259 | | UINT8 *read_pixel(int x, int y, UINT32 c[4]); |
| 259 | UINT8 *read_pixel(int x, int y, INT32 c[4]); |
| 260 | 260 | void write_pixel(int x, int y, UINT32 color, UINT32 depth); |
| 261 | 261 | void combiner_initialize_registers(UINT32 argb8[6]); |
| 262 | 262 | void combiner_initialize_stage(int stage_number); |
| r250231 | r250232 | |
| 496 | 496 | int vertex_attribute_offset[16]; |
| 497 | 497 | emu_timer *puller_timer; |
| 498 | 498 | int puller_channel; |
| 499 | | int puller_subchannel; |
| 500 | 499 | int puller_waiting; |
| 501 | 500 | address_space *puller_space; |
| 502 | 501 | UINT32 dilated0[16][2048]; |
| r250231 | r250232 | |
| 660 | 659 | NV2A_RT_DEPTH_FORMAT_Z16 = 0x0001, |
| 661 | 660 | NV2A_RT_DEPTH_FORMAT_Z24S8 = 0x0002 |
| 662 | 661 | }; |
| 663 | | |
| 664 | 662 | enum NV2A_COLOR_FORMAT { |
| 665 | | NV2A_COLOR_FORMAT_X1R5G6B5 = 0x0002, |
| 666 | | NV2A_COLOR_FORMAT_R5G6B5 = 0x0003, |
| 667 | | NV2A_COLOR_FORMAT_UNKNOWN4 = 0x0004, |
| 668 | | NV2A_COLOR_FORMAT_X8R8G8B8 = 0x0005, |
| 669 | | NV2A_COLOR_FORMAT_X1A7R8G8B8 = 0x0007, |
| 670 | | NV2A_COLOR_FORMAT_A8R8G8B8 = 0x0008, |
| 671 | | NV2A_COLOR_FORMAT_B8 = 0x0009, |
| 672 | | NV2A_COLOR_FORMAT_G8B8 = 0x000a |
| 663 | NV2A_COLOR_FORMAT_X1R5G5B5_Z1R5G5B5 = 1, |
| 664 | NV2A_COLOR_FORMAT_X1R5G5B5_X1R5G5B5 = 2, |
| 665 | NV2A_COLOR_FORMAT_R5G6B5 = 3, |
| 666 | NV2A_COLOR_FORMAT_X8R8G8B8_Z8R8G8B8 = 4, |
| 667 | NV2A_COLOR_FORMAT_X8R8G8B8_X8R8G8B8 = 5, |
| 668 | NV2A_COLOR_FORMAT_X1A7R8G8B8_Z1A7R8G8B8 = 6, |
| 669 | NV2A_COLOR_FORMAT_X1A7R8G8B8_X1A7R8G8B8 = 7, |
| 670 | NV2A_COLOR_FORMAT_A8R8G8B8 = 8, |
| 671 | NV2A_COLOR_FORMAT_B8 = 9, |
| 672 | NV2A_COLOR_FORMAT_G8B8 = 10 |
| 673 | 673 | }; |
| 674 | 674 | }; |
trunk/src/mame/video/chihiro.cpp
| r250231 | r250232 | |
| 1240 | 1240 | } |
| 1241 | 1241 | } |
| 1242 | 1242 | |
| 1243 | | inline UINT8 *nv2a_renderer::read_pixel(int x, int y, UINT32 c[4]) |
| 1243 | inline UINT8 *nv2a_renderer::read_pixel(int x, int y, INT32 c[4]) |
| 1244 | 1244 | { |
| 1245 | 1245 | UINT32 offset; |
| 1246 | 1246 | UINT32 color; |
| r250231 | r250232 | |
| 1261 | 1261 | c[1] = pal6bit((color & 0x07e0) >> 5); |
| 1262 | 1262 | c[0] = pal5bit(color & 0x1f); |
| 1263 | 1263 | return (UINT8 *)addr16; |
| 1264 | | case NV2A_COLOR_FORMAT_UNKNOWN4: |
| 1265 | | case NV2A_COLOR_FORMAT_X8R8G8B8: |
| 1264 | case NV2A_COLOR_FORMAT_X8R8G8B8_Z8R8G8B8: |
| 1265 | case NV2A_COLOR_FORMAT_X8R8G8B8_X8R8G8B8: |
| 1266 | 1266 | addr = (UINT32 *)((UINT8 *)rendertarget + offset); |
| 1267 | 1267 | color = *addr; |
| 1268 | 1268 | |
| r250231 | r250232 | |
| 1295 | 1295 | UINT32 *daddr32; |
| 1296 | 1296 | UINT16 *daddr16; |
| 1297 | 1297 | UINT32 deptsten; |
| 1298 | | UINT32 c[4], fb[4], s[4], d[4], cc[4]; |
| 1298 | INT32 c[4], fb[4], s[4], d[4], cc[4]; |
| 1299 | 1299 | UINT32 dep, sten, stenc, stenv; |
| 1300 | 1300 | bool stencil_passed; |
| 1301 | 1301 | bool depth_passed; |
| r250231 | r250232 | |
| 1854 | 1854 | if (color_mask != 0) { |
| 1855 | 1855 | UINT32 ct,ft,w; |
| 1856 | 1856 | |
| 1857 | | ct = (c[3] << 24) | (c[2] << 16) | (c[1] << 8) | c[0]; |
| 1858 | | ft = (fb[3] << 24) | (fb[2] << 16) | (fb[1] << 8) | fb[0]; |
| 1857 | ct = ((UINT32)c[3] << 24) | ((UINT32)c[2] << 16) | ((UINT32)c[1] << 8) | (UINT32)c[0]; |
| 1858 | ft = ((UINT32)fb[3] << 24) | ((UINT32)fb[2] << 16) | ((UINT32)fb[1] << 8) | (UINT32)fb[0]; |
| 1859 | 1859 | w = (ft & ~color_mask) | (ct & color_mask); |
| 1860 | 1860 | switch (colorformat_rendertarget) { |
| 1861 | 1861 | case NV2A_COLOR_FORMAT_R5G6B5: |
| 1862 | 1862 | w = ((w >> 8) & 0xf800) + ((w >> 5) & 0x7e0) + ((w >> 3) & 0x1f); |
| 1863 | 1863 | *((UINT16 *)addr) = (UINT16)w; |
| 1864 | 1864 | break; |
| 1865 | | case NV2A_COLOR_FORMAT_UNKNOWN4: |
| 1866 | | case NV2A_COLOR_FORMAT_X8R8G8B8: |
| 1865 | case NV2A_COLOR_FORMAT_X8R8G8B8_Z8R8G8B8: |
| 1866 | case NV2A_COLOR_FORMAT_X8R8G8B8_X8R8G8B8: |
| 1867 | 1867 | *((UINT32 *)addr) = w; |
| 1868 | 1868 | break; |
| 1869 | 1869 | case NV2A_COLOR_FORMAT_A8R8G8B8: |
| r250231 | r250232 | |
| 2862 | 2862 | m = 1; |
| 2863 | 2863 | // possible buffers: color, depth, stencil |
| 2864 | 2864 | // clear framebuffer |
| 2865 | | if (data & 0xf0) { |
| 2865 | if ((data & 0xf0) == 0xf0) { |
| 2866 | 2866 | if (bytespixel_rendertarget == 4) { |
| 2867 | 2867 | bitmap_rgb32 bm(rendertarget, (limits_rendertarget.right() + 1) * m, (limits_rendertarget.bottom() + 1) * m, pitch_rendertarget / 4); |
| 2868 | 2868 | |
| r250231 | r250232 | |
| 2913 | 2913 | case NV2A_COLOR_FORMAT_R5G6B5: |
| 2914 | 2914 | bytespixel_rendertarget = 2; |
| 2915 | 2915 | break; |
| 2916 | | case NV2A_COLOR_FORMAT_UNKNOWN4: |
| 2917 | | case NV2A_COLOR_FORMAT_X8R8G8B8: |
| 2916 | case NV2A_COLOR_FORMAT_X8R8G8B8_Z8R8G8B8: |
| 2917 | case NV2A_COLOR_FORMAT_X8R8G8B8_X8R8G8B8: |
| 2918 | 2918 | case NV2A_COLOR_FORMAT_A8R8G8B8: |
| 2919 | 2919 | bytespixel_rendertarget = 4; |
| 2920 | 2920 | break; |
| r250231 | r250232 | |
| 4018 | 4018 | return 0; |
| 4019 | 4019 | } |
| 4020 | 4020 | |
| 4021 | void nv2a_renderer::geforce_assign_object(address_space & space, UINT32 chanel, UINT32 subchannel, UINT32 address) |
| 4022 | { |
| 4023 | int handle, objclass; |
| 4024 | |
| 4025 | handle = space.read_dword(address); |
| 4026 | handle = geforce_object_offset(handle); |
| 4027 | #ifdef LOG_NV2A |
| 4028 | machine().logerror(" assign to subchannel %d object at %d", subch, handle); |
| 4029 | #endif |
| 4030 | channel[chanel][subchannel].object.objhandle = handle; |
| 4031 | handle = ramin[handle / 4]; |
| 4032 | objclass = handle & 0xff; |
| 4033 | #ifdef LOG_NV2A |
| 4034 | machine().logerror(" class %03X\n", objclass); |
| 4035 | #endif |
| 4036 | channel[chanel][subchannel].object.objclass = objclass; |
| 4037 | } |
| 4038 | |
| 4021 | 4039 | TIMER_CALLBACK_MEMBER(nv2a_renderer::puller_timer_work) |
| 4022 | 4040 | { |
| 4023 | | int chanel, subchannel; |
| 4024 | | int method, count, handle, objclass; |
| 4041 | int chanel; |
| 4042 | int method, count; |
| 4025 | 4043 | UINT32 *dmaput, *dmaget; |
| 4026 | 4044 | UINT32 cmd, cmdtype; |
| 4027 | 4045 | int countlen; |
| r250231 | r250232 | |
| 4030 | 4048 | UINT32 subch; |
| 4031 | 4049 | |
| 4032 | 4050 | chanel = puller_channel; |
| 4033 | | subchannel = puller_subchannel; |
| 4034 | | dmaput = &channel[chanel][subchannel].regs[0x40 / 4]; |
| 4035 | | dmaget = &channel[chanel][subchannel].regs[0x44 / 4]; |
| 4051 | dmaput = &channel[chanel][0].regs[0x40 / 4]; |
| 4052 | dmaget = &channel[chanel][0].regs[0x44 / 4]; |
| 4036 | 4053 | while (*dmaget != *dmaput) { |
| 4037 | 4054 | cmd = space->read_dword(*dmaget); |
| 4038 | 4055 | *dmaget += 4; |
| r250231 | r250232 | |
| 4041 | 4058 | { |
| 4042 | 4059 | case 6: // jump |
| 4043 | 4060 | #ifdef LOG_NV2A |
| 4044 | | printf("jump dmaget %08X", *dmaget); |
| 4061 | machine().logerror("jump dmaget %08X", *dmaget); |
| 4045 | 4062 | #endif |
| 4046 | 4063 | *dmaget = cmd & 0xfffffffc; |
| 4047 | 4064 | #ifdef LOG_NV2A |
| 4048 | | printf(" -> %08X\n\r", *dmaget); |
| 4065 | machine().logerror(" -> %08X\n\r", *dmaget); |
| 4049 | 4066 | #endif |
| 4050 | 4067 | break; |
| 4051 | 4068 | case 0: // increasing method |
| r250231 | r250232 | |
| 4053 | 4070 | subch = (cmd >> 13) & 7; |
| 4054 | 4071 | count = (cmd >> 18) & 2047; |
| 4055 | 4072 | if ((method == 0) && (count == 1)) { |
| 4056 | | handle = space->read_dword(*dmaget); |
| 4057 | | handle = geforce_object_offset(handle); |
| 4058 | | #ifdef LOG_NV2A |
| 4059 | | machine().logerror(" assign to subchannel %d object at %d", subch, handle); |
| 4060 | | #endif |
| 4061 | | channel[chanel][subch].object.objhandle = handle; |
| 4062 | | handle = ramin[handle / 4]; |
| 4063 | | objclass = handle & 0xff; |
| 4064 | | #ifdef LOG_NV2A |
| 4065 | | machine().logerror(" class %03X\n", objclass); |
| 4066 | | #endif |
| 4067 | | channel[chanel][subch].object.objclass = objclass; |
| 4073 | geforce_assign_object(*space, chanel, subch, *dmaget); |
| 4068 | 4074 | *dmaget += 4; |
| 4069 | 4075 | } |
| 4070 | 4076 | else { |
| r250231 | r250232 | |
| 4093 | 4099 | subch = (cmd >> 13) & 7; |
| 4094 | 4100 | count = (cmd >> 18) & 2047; |
| 4095 | 4101 | if ((method == 0) && (count == 1)) { |
| 4096 | | handle = space->read_dword(*dmaget); |
| 4097 | | handle = geforce_object_offset(handle); |
| 4098 | | #ifdef LOG_NV2A |
| 4099 | | machine().logerror(" assign to subchannel %d object at %d", subch, handle); |
| 4100 | | #endif |
| 4101 | | channel[chanel][subch].object.objhandle = handle; |
| 4102 | | handle = ramin[handle / 4]; |
| 4103 | | objclass = handle & 0xff; |
| 4104 | | #ifdef LOG_NV2A |
| 4105 | | machine().logerror(" class %03X\n", objclass); |
| 4106 | | #endif |
| 4107 | | channel[chanel][subch].object.objclass = objclass; |
| 4102 | geforce_assign_object(*space, chanel, subch, *dmaget); |
| 4108 | 4103 | *dmaget += 4; |
| 4109 | 4104 | } |
| 4110 | 4105 | else { |
| r250231 | r250232 | |
| 4125 | 4120 | count = space->read_dword(*dmaget); |
| 4126 | 4121 | *dmaget += 4; |
| 4127 | 4122 | if ((method == 0) && (count == 1)) { |
| 4128 | | handle = space->read_dword(*dmaget); |
| 4129 | | handle = geforce_object_offset(handle); |
| 4130 | | #ifdef LOG_NV2A |
| 4131 | | machine().logerror(" assign to subchannel %d object at %d", subch, handle); |
| 4132 | | #endif |
| 4133 | | channel[chanel][subch].object.objhandle = handle; |
| 4134 | | handle = ramin[handle / 4]; |
| 4135 | | objclass = handle & 0xff; |
| 4136 | | #ifdef LOG_NV2A |
| 4137 | | machine().logerror(" class %03X\n", objclass); |
| 4138 | | #endif |
| 4139 | | channel[chanel][subch].object.objclass = objclass; |
| 4123 | geforce_assign_object(*space, chanel, subch, *dmaget); |
| 4140 | 4124 | *dmaget += 4; |
| 4141 | 4125 | } |
| 4142 | 4126 | else { |
| r250231 | r250232 | |
| 4294 | 4278 | subchannel = (suboffset >> (13 - 2)) & 7; |
| 4295 | 4279 | suboffset = suboffset & 0x7ff; |
| 4296 | 4280 | //machine().logerror("NV_2A: write channel[%02X,%d,%04X]=%08X\n",chanel,subchannel,suboffset*4,data & mem_mask); |
| 4281 | COMBINE_DATA(&channel[chanel][subchannel].regs[suboffset]); |
| 4297 | 4282 | if (suboffset >= 0x80 / 4) |
| 4298 | 4283 | return; |
| 4299 | | COMBINE_DATA(&channel[chanel][subchannel].regs[suboffset]); |
| 4300 | 4284 | if ((suboffset == 0x40 / 4) || (suboffset == 0x44 / 4)) { // DMA_PUT or DMA_GET |
| 4301 | 4285 | UINT32 *dmaput, *dmaget; |
| 4302 | 4286 | |
| 4303 | | dmaput = &channel[chanel][subchannel].regs[0x40 / 4]; |
| 4304 | | dmaget = &channel[chanel][subchannel].regs[0x44 / 4]; |
| 4287 | dmaput = &channel[chanel][0].regs[0x40 / 4]; |
| 4288 | dmaget = &channel[chanel][0].regs[0x44 / 4]; |
| 4305 | 4289 | //printf("dmaget %08X dmaput %08X\n\r",*dmaget,*dmaput); |
| 4306 | | if ((*dmaput == 0x048cf000) && (*dmaget == 0x07f4d000)) { |
| 4290 | if ((*dmaput == 0x048cf000) && (*dmaget == 0x07f4d000)) { // only for outr2 |
| 4307 | 4291 | *dmaget = *dmaput; |
| 4308 | 4292 | puller_waiting = 0; |
| 4309 | 4293 | puller_timer->enable(false); |
| r250231 | r250232 | |
| 4312 | 4296 | if (*dmaget != *dmaput) { |
| 4313 | 4297 | if (puller_waiting == 0) { |
| 4314 | 4298 | puller_channel = chanel; |
| 4315 | | puller_subchannel = subchannel; |
| 4316 | 4299 | puller_space = &space; |
| 4317 | 4300 | puller_timer->enable(); |
| 4318 | 4301 | puller_timer->adjust(attotime::zero); |