From b62a54b7e5b6fded4f3946a6ee5a0c97090e2bb8 Mon Sep 17 00:00:00 2001 From: yz70s Date: Tue, 14 Apr 2020 13:41:43 +0200 Subject: [PATCH] xbox_nv2a.cpp: add simple blitting to show xbox error screen (nw) --- src/mame/includes/xbox_nv2a.h | 16 +++++++- src/mame/video/xbox_nv2a.cpp | 70 +++++++++++++++++++++++++++++++++-- 2 files changed, 81 insertions(+), 5 deletions(-) diff --git a/src/mame/includes/xbox_nv2a.h b/src/mame/includes/xbox_nv2a.h index 58d303c8c7d..e095a7d1a9d 100644 --- a/src/mame/includes/xbox_nv2a.h +++ b/src/mame/includes/xbox_nv2a.h @@ -484,6 +484,7 @@ public: int execute_method_m2mf(address_space &space, uint32_t chanel, uint32_t subchannel, uint32_t maddress, uint32_t address, uint32_t data, int &countlen); int execute_method_surf2d(address_space &space, uint32_t chanel, uint32_t subchannel, uint32_t maddress, uint32_t address, uint32_t data, int &countlen); int execute_method_blit(address_space &space, uint32_t chanel, uint32_t subchannel, uint32_t maddress, uint32_t address, uint32_t data, int &countlen); + void surface_2d_blit(); uint32_t texture_get_texel(int number, int x, int y); uint8_t *read_pixel(int x, int y, int32_t c[4]); void write_pixel(int x, int y, uint32_t color, int depth); @@ -551,8 +552,8 @@ public: uint32_t pmc[0x1000 / 4]; uint32_t pgraph[0x2000 / 4]; uint32_t ramin[0x100000 / 4]; - uint32_t dma_offset[10]; - uint32_t dma_size[10]; + uint32_t dma_offset[13]; + uint32_t dma_size[13]; uint8_t *basemempointer; uint8_t *topmempointer; std::function irq_callback; @@ -768,6 +769,17 @@ public: int enabled_vertex_attributes; int vertex_attribute_words[16]; int vertex_attribute_offset[16]; + + struct { + int format; + int pitch_source; + int pitch_destination; + uint32_t source_address; + uint32_t destination_address; + int op; + int width; + int heigth; + } bitblit; emu_timer *puller_timer; int puller_waiting; address_space *puller_space; diff --git a/src/mame/video/xbox_nv2a.cpp b/src/mame/video/xbox_nv2a.cpp index 827aef10f98..17c569647b8 100644 --- a/src/mame/video/xbox_nv2a.cpp +++ b/src/mame/video/xbox_nv2a.cpp @@ -3415,7 +3415,10 @@ int nv2a_renderer::execute_method_3d(address_space& space, uint32_t chanel, uint if (maddress == 0x0100) { countlen--; if (data != 0) { - pgraph[0x704 / 4] = 0x100; +#ifdef LOG_NV2A + machine().logerror("Software method %04x\n", data); +#endif + pgraph[0x704 / 4] = 0x100 | (chanel << 20) | (subchannel << 16); pgraph[0x708 / 4] = data; pgraph[0x100 / 4] |= 1; pgraph[0x108 / 4] |= 1; @@ -3922,6 +3925,7 @@ int nv2a_renderer::execute_method_m2mf(address_space &space, uint32_t chanel, ui #ifdef LOG_NV2A machine().logerror("m2mf method 0180 notify\n"); #endif + geforce_read_dma_object(data, dma_offset[10], dma_size[10]); } return 0; } @@ -3932,11 +3936,26 @@ int nv2a_renderer::execute_method_surf2d(address_space &space, uint32_t chanel, #ifdef LOG_NV2A machine().logerror("surf2d method 0184 source\n"); #endif + geforce_read_dma_object(data, dma_offset[11], dma_size[11]); } if (method == 0x0188) { #ifdef LOG_NV2A machine().logerror("surf2d method 0188 destination\n"); #endif + geforce_read_dma_object(data, dma_offset[12], dma_size[12]); + } + if (method == 0x0300) { + bitblit.format = data; // 0xa is a8r8g8b8 + } + if (method == 0x0304) { + bitblit.pitch_source = data & 0xffff; + bitblit.pitch_destination = data >> 16; + } + if (method == 0x0308) { + bitblit.source_address = dma_offset[11] + data; + } + if (method == 0x030c) { + bitblit.destination_address = dma_offset[12] + data; } return 0; } @@ -3945,17 +3964,62 @@ int nv2a_renderer::execute_method_blit(address_space &space, uint32_t chanel, ui { if (method == 0x019c) { #ifdef LOG_NV2A - machine().logerror("blit method 019c surf\n"); + machine().logerror("blit method 019c surface objecct handle %d\n", data); // set to 0x11 #endif } if (method == 0x02fc) { #ifdef LOG_NV2A - machine().logerror("blit method 02fc op\n"); + machine().logerror("blit method 02fc operation %d\n", data); // 3 is copy from source to destination #endif + bitblit.op = data; + } +#if 0 + if (method == 0x0300) { + int x, y; + + x = data & 0xffff; + y = data >> 16; + } + if (method == 0x0304) { + int x, y; + + x = data & 0xffff; + y = data >> 16; + } +#endif + if (method == 0x0308) { + bitblit.width = data & 0xffff; + bitblit.heigth = data >> 16; + surface_2d_blit(); } return 0; } +void nv2a_renderer::surface_2d_blit() +{ + int x, y; + uint32_t *src, *dest; + uint32_t *srcrow, *destrow; + + if (bitblit.format != 0xa) { + machine().logerror("Unsupported format %d in surface_2d_blit\n", bitblit.format); + return; + } + srcrow = (uint32_t *)(basemempointer + bitblit.source_address); + destrow = (uint32_t*)(basemempointer + bitblit.destination_address); + for (y = 0; y < bitblit.heigth; y++) { + src = srcrow; + dest = destrow; + for (x = 0; x < bitblit.width; x++) { + *dest = *src; + dest++; + src++; + } + srcrow += bitblit.pitch_source >> 2; + destrow += bitblit.pitch_destination >> 2; + } +} + bool nv2a_renderer::toggle_register_combiners_usage() { combiner.used = 1 - combiner.used;