Added logic to display a label showing the address of the cursor selected memory location in hex editor.
This commit is contained in:
parent
c05c85bcfd
commit
475464cca2
|
@ -89,6 +89,7 @@ struct memViewWin_t
|
||||||
GtkTextView *textview;
|
GtkTextView *textview;
|
||||||
GtkTextBuffer *textbuf;
|
GtkTextBuffer *textbuf;
|
||||||
GtkTreeStore *memview_store;
|
GtkTreeStore *memview_store;
|
||||||
|
int selAddr;
|
||||||
int row_vis_start;
|
int row_vis_start;
|
||||||
int row_vis_end;
|
int row_vis_end;
|
||||||
int row_vis_center;
|
int row_vis_center;
|
||||||
|
@ -119,6 +120,7 @@ struct memViewWin_t
|
||||||
row_vis_start = 0;
|
row_vis_start = 0;
|
||||||
row_vis_end = 64;
|
row_vis_end = 64;
|
||||||
row_vis_center= 32;
|
row_vis_center= 32;
|
||||||
|
selAddr = 0;
|
||||||
mode = MODE_NES_RAM;
|
mode = MODE_NES_RAM;
|
||||||
mbuf = NULL;
|
mbuf = NULL;
|
||||||
numLines = 0;
|
numLines = 0;
|
||||||
|
@ -180,6 +182,7 @@ struct memViewWin_t
|
||||||
|
|
||||||
void showMemViewResults (int reset);
|
void showMemViewResults (int reset);
|
||||||
int calcVisibleRange( int *start_out, int *end_out, int *center_out );
|
int calcVisibleRange( int *start_out, int *end_out, int *center_out );
|
||||||
|
int getAddrFromCursor( int CursorTextOffset = -1 );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -206,13 +209,56 @@ static void initMem( unsigned char *c, int size )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int memViewWin_t::getAddrFromCursor( int CursorTextOffset )
|
||||||
|
{
|
||||||
|
int line, offs, byte0, byte, bcol, addr = -1;
|
||||||
|
|
||||||
|
if ( CursorTextOffset < 0 )
|
||||||
|
{
|
||||||
|
gint cpos;
|
||||||
|
g_object_get( textbuf, "cursor-position", &cpos, NULL );
|
||||||
|
CursorTextOffset = cpos;
|
||||||
|
}
|
||||||
|
line = CursorTextOffset / numCharsPerLine;
|
||||||
|
offs = CursorTextOffset % numCharsPerLine;
|
||||||
|
|
||||||
|
if ( offs < 10 )
|
||||||
|
{
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
else if ( offs < 73 )
|
||||||
|
{
|
||||||
|
byte0 = (offs - 10);
|
||||||
|
|
||||||
|
byte = byte0 / 4;
|
||||||
|
bcol = byte0 % 4;
|
||||||
|
|
||||||
|
if ( byte < 16 )
|
||||||
|
{
|
||||||
|
if (bcol < 2)
|
||||||
|
{
|
||||||
|
addr = (line*16) + byte;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( (offs >= 73) && (offs < 89) )
|
||||||
|
{
|
||||||
|
addr = (line*16) + (offs-73);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
void memViewWin_t::showMemViewResults (int reset)
|
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;
|
||||||
char addrStr[16], valStr[16][8], ascii[18];
|
char addrStr[128], valStr[16][8], ascii[18];
|
||||||
char row_changed;
|
char row_changed;
|
||||||
std::string line;
|
std::string line;
|
||||||
GtkTextIter iter, start_iter, end_iter;
|
GtkTextIter iter, start_iter, end_iter;
|
||||||
|
@ -271,6 +317,8 @@ void memViewWin_t::showMemViewResults (int reset)
|
||||||
|
|
||||||
g_object_get( textbuf, "cursor-position", &cpos, NULL );
|
g_object_get( textbuf, "cursor-position", &cpos, NULL );
|
||||||
|
|
||||||
|
selAddr = getAddrFromCursor( cpos );
|
||||||
|
|
||||||
//printf("CPOS: %i \n", cpos );
|
//printf("CPOS: %i \n", cpos );
|
||||||
|
|
||||||
gtk_text_buffer_get_start_iter( textbuf, &start_iter );
|
gtk_text_buffer_get_start_iter( textbuf, &start_iter );
|
||||||
|
@ -372,6 +420,16 @@ void memViewWin_t::showMemViewResults (int reset)
|
||||||
gtk_text_buffer_get_iter_at_offset( textbuf, &iter, cpos );
|
gtk_text_buffer_get_iter_at_offset( textbuf, &iter, cpos );
|
||||||
gtk_text_buffer_place_cursor( textbuf, &iter );
|
gtk_text_buffer_place_cursor( textbuf, &iter );
|
||||||
|
|
||||||
|
if ( selAddr >= 0 )
|
||||||
|
{
|
||||||
|
sprintf( addrStr, "Selected Addr: 0x%08X", selAddr );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addrStr[0] = 0;
|
||||||
|
}
|
||||||
|
gtk_label_set_text( GTK_LABEL(selCellLabel), addrStr );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int memViewWin_t::calcVisibleRange( int *start_out, int *end_out, int *center_out )
|
int memViewWin_t::calcVisibleRange( int *start_out, int *end_out, int *center_out )
|
||||||
|
@ -710,8 +768,6 @@ void openMemoryViewWindow (void)
|
||||||
g_signal_connect (mv->textview, "button-press-event",
|
g_signal_connect (mv->textview, "button-press-event",
|
||||||
G_CALLBACK (textview_button_press_cb), mv);
|
G_CALLBACK (textview_button_press_cb), mv);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mv->textbuf = gtk_text_view_get_buffer( mv->textview );
|
mv->textbuf = gtk_text_view_get_buffer( mv->textview );
|
||||||
|
|
||||||
g_signal_connect (mv->textbuf, "insert-text",
|
g_signal_connect (mv->textbuf, "insert-text",
|
||||||
|
|
Loading…
Reference in New Issue