From 0c438fe2a3cb99b45443948fdc2c6e459dbc1590 Mon Sep 17 00:00:00 2001 From: angelosa Date: Tue, 27 Feb 2018 19:52:42 +0100 Subject: model2.cpp: added trilist custom debugger command [Angelo Salese] --- src/mame/includes/model2.h | 3 ++ src/mame/machine/model2.cpp | 35 +++++++++++++++++++++ src/mame/video/model2.cpp | 74 +++++++++++++++++++++------------------------ 3 files changed, 72 insertions(+), 40 deletions(-) diff --git a/src/mame/includes/model2.h b/src/mame/includes/model2.h index 379394bdd06..2069cfff82c 100644 --- a/src/mame/includes/model2.h +++ b/src/mame/includes/model2.h @@ -264,12 +264,15 @@ public: void debug_init(); void debug_commands( int ref, const std::vector ¶ms ); void debug_geo_dasm_command(int ref, const std::vector ¶ms); + void debug_tri_dump_command(int ref, const std::vector ¶ms); void debug_help_command(int ref, const std::vector ¶ms); protected: virtual void video_start() override; private: + void tri_list_dump(FILE *dst); + bool m_render_unk; bool m_render_mode; }; diff --git a/src/mame/machine/model2.cpp b/src/mame/machine/model2.cpp index aac3f1f2e81..a3f4505a2ad 100644 --- a/src/mame/machine/model2.cpp +++ b/src/mame/machine/model2.cpp @@ -13,6 +13,7 @@ #include "debug/debugcmd.h" #include "debugger.h" +struct raster_state; void model2_state::debug_init() { @@ -30,6 +31,8 @@ void model2_state::debug_commands(int ref, const std::vector ¶m if (params[0] == "geodasm") debug_geo_dasm_command(ref, params); + else if(params[0] == "trilist") + debug_tri_dump_command(ref, params); else debug_help_command(ref, params); } @@ -40,6 +43,7 @@ void model2_state::debug_help_command(int ref, const std::vector &p con.printf("Available Sega Model 2 commands:\n"); con.printf(" m2 geodasm, -- dump current geometrizer DASM in \n"); + con.printf(" m2 trilist, -- dump current parsed triangles in \n"); con.printf(" m2 help -- this list\n"); } @@ -255,4 +259,35 @@ void model2_state::debug_geo_dasm_command(int ref, const std::vector ¶ms) +{ + debugger_console &con = machine().debugger().console(); + FILE *f; + + if (params.size() < 2) + { + con.printf("Error: not enough parameters for m2 trilist command\n"); + return; + } + + if (params[1].empty() || params[1].length() > 127) + { + con.printf("Error: invalid filename parameter for m2 trilist command\n"); + return; + } + + if((f = fopen( params[1].c_str(), "w" )) == nullptr) + { + con.printf("Error: while opening %s for writing\n",params[1].c_str()); + return; + } + + tri_list_dump(f); + con.printf("Data dumped successfully\n"); +} diff --git a/src/mame/video/model2.cpp b/src/mame/video/model2.cpp index a88ffbdafbc..decc7d18923 100644 --- a/src/mame/video/model2.cpp +++ b/src/mame/video/model2.cpp @@ -91,8 +91,6 @@ #include "video/segaic24.h" #include "includes/model2.h" -#define MODEL2_VIDEO_DEBUG 0 - #define pz p[0] #define pu p[1] @@ -918,44 +916,6 @@ void model2_state::model2_3d_frame_end( bitmap_rgb32 &bitmap, const rectangle &c if ( raster->tri_list_index == 0 ) return; -#if MODEL2_VIDEO_DEBUG - if (machine().input().code_pressed(KEYCODE_Q)) - { - uint32_t i; - - FILE *f = fopen( "triangles.txt", "w" ); - - if ( f ) - { - for( i = 0; i < raster->tri_list_index; i++ ) - { - fprintf( f, "index: %d\n", i ); - fprintf( f, "v0.x = %f, v0.y = %f, v0.z = %f\n", raster->tri_list[i].v[0].x, raster->tri_list[i].v[0].y, raster->tri_list[i].v[0].pz ); - fprintf( f, "v1.x = %f, v1.y = %f, v1.z = %f\n", raster->tri_list[i].v[1].x, raster->tri_list[i].v[1].y, raster->tri_list[i].v[1].pz ); - fprintf( f, "v2.x = %f, v2.y = %f, v2.z = %f\n", raster->tri_list[i].v[2].x, raster->tri_list[i].v[2].y, raster->tri_list[i].v[2].pz ); - - fprintf( f, "tri z: %04x\n", raster->tri_list[i].z ); - fprintf( f, "texheader - 0: %04x\n", raster->tri_list[i].texheader[0] ); - fprintf( f, "texheader - 1: %04x\n", raster->tri_list[i].texheader[1] ); - fprintf( f, "texheader - 2: %04x\n", raster->tri_list[i].texheader[2] ); - fprintf( f, "texheader - 3: %04x\n", raster->tri_list[i].texheader[3] ); - fprintf( f, "luma: %02x\n", raster->tri_list[i].luma ); - fprintf( f, "vp.sx: %04x\n", raster->tri_list[i].viewport[0] ); - fprintf( f, "vp.sy: %04x\n", raster->tri_list[i].viewport[1] ); - fprintf( f, "vp.ex: %04x\n", raster->tri_list[i].viewport[2] ); - fprintf( f, "vp.ey: %04x\n", raster->tri_list[i].viewport[3] ); - fprintf( f, "vp.swx: %04x\n", raster->tri_list[i].center[0] ); - fprintf( f, "vp.swy: %04x\n", raster->tri_list[i].center[1] ); - fprintf( f, "\n---\n\n" ); - } - - fprintf( f, "min_z = %04x, max_z = %04x\n", raster->min_z, raster->max_z ); - - fclose( f ); - } - } -#endif - m_poly->destmap().fill(0x00000000, cliprect); /* go through the Z levels, and render each bucket */ @@ -2660,3 +2620,37 @@ uint32_t model2_state::screen_update_model2(screen_device &screen, bitmap_rgb32 return 0; } + +// called from machine/model2.cpp trilist command +// TODO: fix forward declaration mess and move this function there instead +void model2_state::tri_list_dump(FILE *dst) +{ + uint32_t i; + + for( i = 0; i < m_raster->tri_list_index; i++ ) + { + fprintf( dst, "index: %d\n", i ); + fprintf( dst, "v0.x = %f, v0.y = %f, v0.z = %f\n", m_raster->tri_list[i].v[0].x, m_raster->tri_list[i].v[0].y, m_raster->tri_list[i].v[0].pz ); + fprintf( dst, "v1.x = %f, v1.y = %f, v1.z = %f\n", m_raster->tri_list[i].v[1].x, m_raster->tri_list[i].v[1].y, m_raster->tri_list[i].v[1].pz ); + fprintf( dst, "v2.x = %f, v2.y = %f, v2.z = %f\n", m_raster->tri_list[i].v[2].x, m_raster->tri_list[i].v[2].y, m_raster->tri_list[i].v[2].pz ); + + fprintf( dst, "tri z: %04x\n", m_raster->tri_list[i].z ); + fprintf( dst, "texheader - 0: %04x\n", m_raster->tri_list[i].texheader[0] ); + fprintf( dst, "texheader - 1: %04x\n", m_raster->tri_list[i].texheader[1] ); + fprintf( dst, "texheader - 2: %04x\n", m_raster->tri_list[i].texheader[2] ); + fprintf( dst, "texheader - 3: %04x\n", m_raster->tri_list[i].texheader[3] ); + fprintf( dst, "luma: %02x\n", m_raster->tri_list[i].luma ); + fprintf( dst, "vp.sx: %04x\n", m_raster->tri_list[i].viewport[0] ); + fprintf( dst, "vp.sy: %04x\n", m_raster->tri_list[i].viewport[1] ); + fprintf( dst, "vp.ex: %04x\n", m_raster->tri_list[i].viewport[2] ); + fprintf( dst, "vp.ey: %04x\n", m_raster->tri_list[i].viewport[3] ); + fprintf( dst, "vp.swx: %04x\n", m_raster->tri_list[i].center[0] ); + fprintf( dst, "vp.swy: %04x\n", m_raster->tri_list[i].center[1] ); + fprintf( dst, "\n---\n\n" ); + } + + fprintf( dst, "min_z = %04x, max_z = %04x\n", m_raster->min_z, m_raster->max_z ); + + fclose( dst ); + +} -- cgit v1.2.3