From 04e679e504e9845a7cecb1597b73ea273a8c3412 Mon Sep 17 00:00:00 2001 From: Barry Harris <44396066+barry65536@users.noreply.github.com> Date: Sun, 20 Apr 2014 20:46:42 +0000 Subject: [PATCH] add debug tracking to sknsspr, v3021 and vdc --- src/burn/burnint.h | 3 ++ src/burn/debug_track.cpp | 6 +++ src/burn/devices/sknsspr.cpp | 22 +++++++++ src/burn/devices/sknsspr.h | 2 + src/burn/devices/v3021.cpp | 26 +++++++++++ src/burn/devices/v3021.h | 3 ++ src/burn/devices/vdc.cpp | 86 ++++++++++++++++++++++++++++++++++-- src/burn/devices/vdc.h | 3 ++ 8 files changed, 147 insertions(+), 4 deletions(-) diff --git a/src/burn/burnint.h b/src/burn/burnint.h index 6e96424ad..a6f8adf6b 100644 --- a/src/burn/burnint.h +++ b/src/burn/burnint.h @@ -167,10 +167,13 @@ extern UINT8 DebugDev_8257DMAInitted; extern UINT8 DebugDev_EEPROMInitted; extern UINT8 DebugDev_PandoraInitted; extern UINT8 DebugDev_SeibuSndInitted; +extern UINT8 DebugDev_SknsSprInitted; extern UINT8 DebugDev_SlapsticInitted; extern UINT8 DebugDev_T5182Initted; extern UINT8 DebugDev_TimeKprInitted; extern UINT8 DebugDev_Tms34061Initted; +extern UINT8 DebugDev_V3021Initted; +extern UINT8 DebugDev_VDCInitted; extern UINT8 DebugSnd_AY8910Initted; extern UINT8 DebugSnd_Y8950Initted; diff --git a/src/burn/debug_track.cpp b/src/burn/debug_track.cpp index 45d58f018..73f523318 100644 --- a/src/burn/debug_track.cpp +++ b/src/burn/debug_track.cpp @@ -13,10 +13,13 @@ UINT8 DebugDev_8257DMAInitted; UINT8 DebugDev_EEPROMInitted; UINT8 DebugDev_PandoraInitted; UINT8 DebugDev_SeibuSndInitted; +UINT8 DebugDev_SknsSprInitted; UINT8 DebugDev_SlapsticInitted; UINT8 DebugDev_T5182Initted; UINT8 DebugDev_TimeKprInitted; UINT8 DebugDev_Tms34061Initted; +UINT8 DebugDev_V3021Initted; +UINT8 DebugDev_VDCInitted; UINT8 DebugSnd_AY8910Initted; UINT8 DebugSnd_Y8950Initted; @@ -85,10 +88,13 @@ void DebugTrackerExit() if (DebugDev_EEPROMInitted) bprintf(PRINT_ERROR, _T("Device EEPROM Not Exited\n")); if (DebugDev_PandoraInitted) bprintf(PRINT_ERROR, _T("Device Pandora Not Exited\n")); if (DebugDev_SeibuSndInitted) bprintf(PRINT_ERROR, _T("Device SeibuSnd Not Exited\n")); + if (DebugDev_SknsSprInitted) bprintf(PRINT_ERROR, _T("Device SknsSpr Not Exited\n")); if (DebugDev_SlapsticInitted) bprintf(PRINT_ERROR, _T("Device Slapstic Not Exited\n")); if (DebugDev_T5182Initted) bprintf(PRINT_ERROR, _T("Device T5182 Not Exited\n")); if (DebugDev_TimeKprInitted) bprintf(PRINT_ERROR, _T("Device TimeKpr Not Exited\n")); if (DebugDev_Tms34061Initted) bprintf(PRINT_ERROR, _T("Device TMS34061 Not Exited\n")); + if (DebugDev_V3021Initted) bprintf(PRINT_ERROR, _T("Device V3021 Not Exited\n")); + if (DebugDev_VDCInitted) bprintf(PRINT_ERROR, _T("Device VDC Not Exited\n")); if (DebugSnd_AY8910Initted) bprintf(PRINT_ERROR, _T("Sound Module AY8910 Not Exited\n")); if (DebugSnd_Y8950Initted) bprintf(PRINT_ERROR, _T("Sound Module Y8950 Not Exited\n")); diff --git a/src/burn/devices/sknsspr.cpp b/src/burn/devices/sknsspr.cpp index 80a040f25..3aac74b87 100644 --- a/src/burn/devices/sknsspr.cpp +++ b/src/burn/devices/sknsspr.cpp @@ -54,6 +54,10 @@ static INT32 skns_rle_decode ( INT32 romoffset, INT32 size, UINT8*gfx_source, IN void skns_sprite_kludge(INT32 x, INT32 y) { +#if defined FBA_DEBUG + if (!DebugDev_SknsSprInitted) bprintf(PRINT_ERROR, _T("skns_sprite_kludge called without init\n")); +#endif + sprite_kludge_x = x; sprite_kludge_y = y; } @@ -223,6 +227,10 @@ static void (*const blit_z[4])(UINT16 *bitmap, const UINT8 *src, INT32 x, INT32 // disable_priority is a hack to make jchan drawing a bit quicker (rather than moving the sprites around different bitmaps and adding colors void skns_draw_sprites(UINT16 *bitmap, UINT32* spriteram_source, INT32 spriteram_size, UINT8* gfx_source, INT32 gfx_length, UINT32* sprite_regs, INT32 disable_priority) { +#if defined FBA_DEBUG + if (!DebugDev_SknsSprInitted) bprintf(PRINT_ERROR, _T("skns_draw_sprites called without init\n")); +#endif + /*- SPR RAM Format -** 16 bytes per sprite @@ -533,3 +541,17 @@ void skns_draw_sprites(UINT16 *bitmap, UINT32* spriteram_source, INT32 spriteram } } } + +void skns_init() +{ + DebugDev_SknsSprInitted = 1; +} + +void skns_exit() +{ +#if defined FBA_DEBUG + if (!DebugDev_SknsSprInitted) bprintf(PRINT_ERROR, _T("skns_exit called without init\n")); +#endif + + DebugDev_SknsSprInitted = 0; +} diff --git a/src/burn/devices/sknsspr.h b/src/burn/devices/sknsspr.h index 2ea55f548..1f90f862a 100644 --- a/src/burn/devices/sknsspr.h +++ b/src/burn/devices/sknsspr.h @@ -1,2 +1,4 @@ void skns_sprite_kludge(INT32 x, INT32 y); void skns_draw_sprites(UINT16 *bitmap, UINT32* spriteram_source, INT32 spriteram_size, UINT8* gfx_source, INT32 gfx_length, UINT32* sprite_regs, INT32 disable_priority); +void skns_init(); +void skns_exit(); diff --git a/src/burn/devices/v3021.cpp b/src/burn/devices/v3021.cpp index bf608d910..8a5c95cf1 100644 --- a/src/burn/devices/v3021.cpp +++ b/src/burn/devices/v3021.cpp @@ -11,6 +11,10 @@ static UINT8 bcd(UINT8 data) UINT8 v3021Read() { +#if defined FBA_DEBUG + if (!DebugDev_V3021Initted) bprintf(PRINT_ERROR, _T("v3021Read called without init\n")); +#endif + UINT8 calr; calr = (CalVal & CalMask) ? 1 : 0; CalMask <<= 1; @@ -19,6 +23,10 @@ UINT8 v3021Read() void v3021Write(UINT16 data) { +#if defined FBA_DEBUG + if (!DebugDev_V3021Initted) bprintf(PRINT_ERROR, _T("v3021Write called without init\n")); +#endif + time_t nLocalTime = time(NULL); tm* tmLocalTime = localtime(&nLocalTime); @@ -76,8 +84,26 @@ void v3021Write(UINT16 data) } } +void v3021Init() +{ + DebugDev_V3021Initted = 1; +} + +void v3021Exit() +{ +#if defined FBA_DEBUG + if (!DebugDev_V3021Initted) bprintf(PRINT_ERROR, _T("v3021Exit called without init\n")); +#endif + + DebugDev_V3021Initted = 0; +} + INT32 v3021Scan() { +#if defined FBA_DEBUG + if (!DebugDev_V3021Initted) bprintf(PRINT_ERROR, _T("v3021Scan called without init\n")); +#endif + SCAN_VAR(CalVal); SCAN_VAR(CalMask); SCAN_VAR(CalCom); diff --git a/src/burn/devices/v3021.h b/src/burn/devices/v3021.h index 746eb65ae..ccdfeff4a 100644 --- a/src/burn/devices/v3021.h +++ b/src/burn/devices/v3021.h @@ -3,4 +3,7 @@ UINT8 v3021Read(); void v3021Write(UINT16 data); +void v3021Init(); +void v3021Exit(); + INT32 v3021Scan(); diff --git a/src/burn/devices/vdc.cpp b/src/burn/devices/vdc.cpp index 3cdba68b0..ae8e6fd08 100644 --- a/src/burn/devices/vdc.cpp +++ b/src/burn/devices/vdc.cpp @@ -52,6 +52,10 @@ static void vpc_update_prio_map() void vpc_write(UINT8 offset, UINT8 data) { +#if defined FBA_DEBUG + if (!DebugDev_VDCInitted) bprintf(PRINT_ERROR, _T("vpc_write called without init\n")); +#endif + switch (offset & 0x07) { case 0x00: /* Priority register #0 */ @@ -102,6 +106,10 @@ void vpc_write(UINT8 offset, UINT8 data) UINT8 vpc_read(UINT8 offset) { +#if defined FBA_DEBUG + if (!DebugDev_VDCInitted) bprintf(PRINT_ERROR, _T("vpc_read called without init\n")); +#endif + switch (offset & 0x07) { case 0x00: /* Priority register #0 */ @@ -128,6 +136,10 @@ UINT8 vpc_read(UINT8 offset) void vpc_reset() { +#if defined FBA_DEBUG + if (!DebugDev_VDCInitted) bprintf(PRINT_ERROR, _T("vpc_reset called without init\n")); +#endif + memset (vpc_prio, 0, 4); memset (vpc_vdc0_enabled, 0, 4); memset (vpc_vdc1_enabled, 0, 4); @@ -145,6 +157,10 @@ void vpc_reset() UINT8 vce_read(UINT8 offset) { +#if defined FBA_DEBUG + if (!DebugDev_VDCInitted) bprintf(PRINT_ERROR, _T("vce_read called without init\n")); +#endif + switch (offset & 7) { case 0x04: @@ -161,6 +177,10 @@ UINT8 vce_read(UINT8 offset) void vce_write(UINT8 offset, UINT8 data) { +#if defined FBA_DEBUG + if (!DebugDev_VDCInitted) bprintf(PRINT_ERROR, _T("vce_write called without init\n")); +#endif + switch (offset & 7) { case 0x00: @@ -188,6 +208,10 @@ void vce_write(UINT8 offset, UINT8 data) void vce_palette_init(UINT32 *Palette) { +#if defined FBA_DEBUG + if (!DebugDev_VDCInitted) bprintf(PRINT_ERROR, _T("vce_palette_init called without init\n")); +#endif + for (INT32 i = 0; i < 512; i++) { INT32 r = ((i >> 3) & 7) << 5; @@ -203,6 +227,10 @@ void vce_palette_init(UINT32 *Palette) void vce_reset() { +#if defined FBA_DEBUG + if (!DebugDev_VDCInitted) bprintf(PRINT_ERROR, _T("vce_reset called without init\n")); +#endif + memset (vce_data, 0, 512 * sizeof(UINT16)); vce_address = 0; @@ -361,7 +389,7 @@ static void pce_refresh_sprites(INT32 which, INT32 line, UINT8 *drawn, UINT16 *l if ( vdc_width[which] != 512 ) { - int dp = 1; + INT32 dp = 1; while ( pixel_x + dp < ( ( ( obj_x + x + 1 ) * 512 ) / vdc_width[which] ) ) { drawn[pixel_x + dp] = i + 2; @@ -411,7 +439,7 @@ static void pce_refresh_sprites(INT32 which, INT32 line, UINT8 *drawn, UINT16 *l line_buffer[pixel_x] = color_base + vce_data[0x100 + (palette << 4) + buf[x]]; if ( vdc_width[which] != 512 ) { - int dp = 1; + INT32 dp = 1; while ( pixel_x + dp < ( ( ( obj_x + x + 1 ) * 512 ) / vdc_width[which] ) ) { drawn[pixel_x + dp] = i + 2; @@ -470,7 +498,7 @@ static void pce_refresh_sprites(INT32 which, INT32 line, UINT8 *drawn, UINT16 *l line_buffer[pixel_x] = color_base + vce_data[0x100 + (palette << 4) + buf[x]]; if ( vdc_width[which] != 512 ) { - int dp = 1; + INT32 dp = 1; while ( pixel_x + dp < ( ( ( obj_x + x + 17 ) * 512 ) / vdc_width[which] ) ) { drawn[pixel_x + dp] = i + 2; @@ -771,6 +799,10 @@ static void pce_refresh_line(INT32 which, INT32 /*line*/, INT32 external_input, void pce_interrupt() { +#if defined FBA_DEBUG + if (!DebugDev_VDCInitted) bprintf(PRINT_ERROR, _T("pce_interrupt called without init\n")); +#endif + INT32 which = 0; // only 1 on pce if (vce_current_bitmap_line >= 14 && vce_current_bitmap_line < 256) @@ -805,6 +837,10 @@ void pce_interrupt() void sgx_interrupt() { +#if defined FBA_DEBUG + if (!DebugDev_VDCInitted) bprintf(PRINT_ERROR, _T("sgx_interrupt called without init\n")); +#endif + if (vce_current_bitmap_line >= 14 && vce_current_bitmap_line < 256) { draw_sgx_overscan_line(vce_current_bitmap_line); @@ -839,7 +875,7 @@ void sgx_interrupt() for( i = 0; i < 512; i++ ) { - int cur_prio = vpc_prio_map[i]; + INT32 cur_prio = vpc_prio_map[i]; if ( vpc_vdc0_enabled[cur_prio] ) { @@ -983,6 +1019,10 @@ static void vdc_do_dma(INT32 which) void vdc_write(INT32 which, UINT8 offset, UINT8 data) { +#if defined FBA_DEBUG + if (!DebugDev_VDCInitted) bprintf(PRINT_ERROR, _T("vdc_write called without init\n")); +#endif + switch (offset & 3) { case 0x00: @@ -1080,6 +1120,10 @@ void vdc_write(INT32 which, UINT8 offset, UINT8 data) UINT8 vdc_read(INT32 which, UINT8 offset) { +#if defined FBA_DEBUG + if (!DebugDev_VDCInitted) bprintf(PRINT_ERROR, _T("vdc_read called without init\n")); +#endif + switch(offset & 3) { case 0x00: { @@ -1106,6 +1150,10 @@ UINT8 vdc_read(INT32 which, UINT8 offset) void sgx_vdc_write(UINT8 offset, UINT8 data) { +#if defined FBA_DEBUG + if (!DebugDev_VDCInitted) bprintf(PRINT_ERROR, _T("sgx_vdc_write called without init\n")); +#endif + if (vpc_vdc_select) { vdc_write( 1, offset, data ); @@ -1118,11 +1166,19 @@ void sgx_vdc_write(UINT8 offset, UINT8 data) UINT8 sgx_vdc_read(UINT8 offset) { +#if defined FBA_DEBUG + if (!DebugDev_VDCInitted) bprintf(PRINT_ERROR, _T("sgx_vdc_read called without init\n")); +#endif + return (vpc_vdc_select) ? vdc_read( 1, offset ) : vdc_read( 0, offset ); } void vdc_reset() { +#if defined FBA_DEBUG + if (!DebugDev_VDCInitted) bprintf(PRINT_ERROR, _T("vdc_reset called without init\n")); +#endif + memset (vdc_register, 0, 2); memset (vdc_data, 0, 2 * 32 * sizeof(UINT16)); memset (vdc_latch, 0, 2); @@ -1146,12 +1202,34 @@ void vdc_reset() void vdc_get_dimensions(INT32 which, INT32 *x, INT32 *y) { +#if defined FBA_DEBUG + if (!DebugDev_VDCInitted) bprintf(PRINT_ERROR, _T("vdc_get_dimensions called without init\n")); +#endif + *x = vdc_width[which] * 2; *y = vdc_height[which]; } +void vdc_init() +{ + DebugDev_VDCInitted = 1; +} + +void vdc_exit() +{ +#if defined FBA_DEBUG + if (!DebugDev_VDCInitted) bprintf(PRINT_ERROR, _T("vdc_exit called without init\n")); +#endif + + DebugDev_VDCInitted = 0; +} + INT32 vdc_scan(INT32 nAction, INT32 *pnMin) { +#if defined FBA_DEBUG + if (!DebugDev_VDCInitted) bprintf(PRINT_ERROR, _T("vdc_scan called without init\n")); +#endif + struct BurnArea ba; if (pnMin) { diff --git a/src/burn/devices/vdc.h b/src/burn/devices/vdc.h index c3ab89827..7a2bc9eea 100644 --- a/src/burn/devices/vdc.h +++ b/src/burn/devices/vdc.h @@ -14,6 +14,9 @@ void vdc_get_dimensions(INT32 which, INT32 *x, INT32 *y); // get resolution void sgx_vdc_write(UINT8 offset, UINT8 data); UINT8 sgx_vdc_read(UINT8 offset); +void vdc_init(); +void vdc_exit(); + // priority void vpc_reset();