Bug fix for memory view window when handling large ROM displays.

This commit is contained in:
Matthew Budd 2020-05-31 06:48:37 -04:00
parent 9eab3f9e5d
commit 34e8afe39d
1 changed files with 52 additions and 49 deletions

View File

@ -51,6 +51,7 @@ struct memByte_t
unsigned char data; unsigned char data;
unsigned char color; unsigned char color;
unsigned char actv; unsigned char actv;
unsigned char draw;
}; };
//******************************************************************************************************* //*******************************************************************************************************
// Memory View (Hex Editor) Window // Memory View (Hex Editor) Window
@ -326,6 +327,7 @@ void memViewWin_t::initMem(void)
mbuf[i].data = memAccessFunc(i); mbuf[i].data = memAccessFunc(i);
mbuf[i].color = 0; mbuf[i].color = 0;
mbuf[i].actv = 0; mbuf[i].actv = 0;
mbuf[i].draw = 1;
} }
} }
@ -351,11 +353,13 @@ int memViewWin_t::checkMemActivity(void)
{ {
mbuf[i].actv = 15; mbuf[i].actv = 15;
mbuf[i].data = c; mbuf[i].data = c;
mbuf[i].draw = 1;
} }
else else
{ {
if ( mbuf[i].actv > 0 ) if ( mbuf[i].actv > 0 )
{ {
mbuf[i].draw = 1;
mbuf[i].actv--; mbuf[i].actv--;
} }
} }
@ -413,7 +417,7 @@ void memViewWin_t::showMemViewResults (int reset)
int addr, memSize = 0; int addr, memSize = 0;
int lineAddr = 0, c, un, ln; int lineAddr = 0, c, un, ln;
int i, row, row_start, row_end, totalChars; int i, row, row_start, row_end, totalChars;
gint cpos; gint cpos, textview_lines_allocated;
char addrStr[128], valStr[16][8], ascii[18]; char addrStr[128], valStr[16][8], ascii[18];
char addrChg, valChg[16], activityColoringOn, colorEnable; char addrChg, valChg[16], activityColoringOn, colorEnable;
GtkTextIter iter, next_iter, start_iter, end_iter; GtkTextIter iter, next_iter, start_iter, end_iter;
@ -495,9 +499,10 @@ void memViewWin_t::showMemViewResults (int reset)
if ( reset ) if ( reset )
{ {
gtk_text_buffer_get_bounds( textbuf, &start_iter, &end_iter ); //gtk_text_buffer_get_bounds( textbuf, &start_iter, &end_iter );
gtk_text_buffer_delete( textbuf, &start_iter, &end_iter ); //gtk_text_buffer_delete( textbuf, &start_iter, &end_iter );
gtk_text_buffer_set_text( textbuf, "", -1 );
row_start = 0; row_start = 0;
row_end = numLines; row_end = numLines;
@ -521,9 +526,15 @@ void memViewWin_t::showMemViewResults (int reset)
totalChars = row_start * numCharsPerLine; totalChars = row_start * numCharsPerLine;
textview_lines_allocated = gtk_text_buffer_get_line_count( textbuf ) - 1;
for (row=row_start; row<row_end; row++) for (row=row_start; row<row_end; row++)
{ {
//gtk_text_buffer_get_iter_at_offset( textbuf, &iter, totalChars ); //gtk_text_buffer_get_iter_at_offset( textbuf, &iter, totalChars );
if ( row >= textview_lines_allocated )
{
reset = 1;
}
addrChg = reset; addrChg = reset;
@ -555,21 +566,10 @@ void memViewWin_t::showMemViewResults (int reset)
c = memAccessFunc(addr); c = memAccessFunc(addr);
if ( mbuf[addr].actv ) if ( mbuf[addr].draw )
{ {
valChg[i] = mbuf[addr].actv; mbuf[addr].draw = 0;
} valChg[i] = 1;
if ( useActivityColors )
{
if ( actv_color_reverse_video )
{
mbuf[addr].color = mbuf[addr].actv + HIGHLIGHT_ACTIVITY_NUM_COLORS;
}
else
{
mbuf[addr].color = mbuf[addr].actv;
}
} }
un = ( c & 0x00f0 ) >> 4; un = ( c & 0x00f0 ) >> 4;
@ -601,18 +601,24 @@ void memViewWin_t::showMemViewResults (int reset)
gtk_text_buffer_delete( textbuf, &iter, &next_iter ); gtk_text_buffer_delete( textbuf, &iter, &next_iter );
} }
//gtk_text_buffer_insert( textbuf, &iter, valStr[i], -1 );
if ( colorEnable ) if ( colorEnable )
{ {
if ( activityColoringOn ) if ( activityColoringOn )
{ {
if ( actv_color_reverse_video ) if ( mbuf[addr].actv > 0 )
{ {
gtk_text_buffer_insert_with_tags( textbuf, &iter, valStr[i], -1, colorList[ mbuf[addr].actv + HIGHLIGHT_ACTIVITY_NUM_COLORS ], NULL ); if ( actv_color_reverse_video )
{
gtk_text_buffer_insert_with_tags( textbuf, &iter, valStr[i], -1, colorList[ mbuf[addr].actv + HIGHLIGHT_ACTIVITY_NUM_COLORS ], NULL );
}
else
{
gtk_text_buffer_insert_with_tags( textbuf, &iter, valStr[i], -1, colorList[ mbuf[addr].actv ], NULL );
}
} }
else else
{ {
gtk_text_buffer_insert_with_tags( textbuf, &iter, valStr[i], -1, colorList[ mbuf[addr].actv ], NULL ); gtk_text_buffer_insert( textbuf, &iter, valStr[i], -1 );
} }
} }
else else
@ -627,13 +633,24 @@ void memViewWin_t::showMemViewResults (int reset)
} }
else else
{ {
if ( !reset ) //if ( !reset )
{ //{
gtk_text_iter_forward_chars( &next_iter, 4 ); // next_iter = iter;
gtk_text_buffer_remove_all_tags( textbuf, &iter, &next_iter ); // if ( gtk_text_iter_forward_chars( &next_iter, 4 ) == FALSE )
// {
// return;
// }
// //gtk_text_buffer_remove_all_tags( textbuf, &iter, &next_iter );
// //gtk_text_buffer_delete( textbuf, &iter, &next_iter );
// //gtk_text_buffer_insert( textbuf, &iter, valStr[i], -1 );
//}
if ( gtk_text_iter_forward_chars( &iter, 4 ) == FALSE)
{
return;
} }
gtk_text_iter_forward_chars( &iter, 4 );
} }
} }
ascii[16] = 0; ascii[16] = 0;
@ -645,14 +662,21 @@ void memViewWin_t::showMemViewResults (int reset)
if ( !reset ) if ( !reset )
{ {
next_iter = iter; next_iter = iter;
gtk_text_iter_forward_chars( &next_iter, 1 );
if ( gtk_text_iter_forward_chars( &next_iter, 1 ) == FALSE )
{
return;
}
gtk_text_buffer_delete( textbuf, &iter, &next_iter ); gtk_text_buffer_delete( textbuf, &iter, &next_iter );
} }
gtk_text_buffer_insert( textbuf, &iter, &ascii[i], 1 ); gtk_text_buffer_insert( textbuf, &iter, &ascii[i], 1 );
} }
else else
{ {
gtk_text_iter_forward_chars( &iter, 1 ); if ( gtk_text_iter_forward_chars( &iter, 1 ) == FALSE )
{
return;
}
} }
} }
@ -666,24 +690,6 @@ void memViewWin_t::showMemViewResults (int reset)
{ {
gtk_text_iter_forward_chars( &iter, 1 ); gtk_text_iter_forward_chars( &iter, 1 );
} }
//if ( row_changed )
//{
// if ( reset )
// {
// gtk_text_buffer_get_iter_at_offset( textbuf, &iter, totalChars );
// gtk_text_buffer_insert ( textbuf, &iter, line.c_str(), -1 );
// }
// else
// {
// GtkTextIter next_iter;
// gtk_text_buffer_get_iter_at_offset( textbuf, &next_iter, totalChars + numCharsPerLine - 1 );
// gtk_text_buffer_delete ( textbuf, &iter, &next_iter );
// gtk_text_buffer_get_iter_at_offset( textbuf, &iter, totalChars );
// gtk_text_buffer_insert ( textbuf, &iter, line.c_str(), line.size()-1 );
// }
//}
totalChars += numCharsPerLine; totalChars += numCharsPerLine;
} }
@ -1607,9 +1613,6 @@ void openMemoryViewWindow (void)
gtk_style_context_add_provider( gtk_widget_get_style_context( GTK_WIDGET(mv->textview) ), gtk_style_context_add_provider( gtk_widget_get_style_context( GTK_WIDGET(mv->textview) ),
GTK_STYLE_PROVIDER(mv->cssProvider), GTK_STYLE_PROVIDER(mv->cssProvider),
GTK_STYLE_PROVIDER_PRIORITY_USER); GTK_STYLE_PROVIDER_PRIORITY_USER);
//gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
// GTK_STYLE_PROVIDER(cssProvider),
// GTK_STYLE_PROVIDER_PRIORITY_USER);
gtk_widget_show_all (mv->win); gtk_widget_show_all (mv->win);