- char TextTmp[255];
- int row, column, TextLength;
-
- gtk_clist_freeze( GTK_CLIST( memclist ) );
- for ( row = 0; row < 16; row++ ) {
- sprintf( TextTmp, "%.4X", Address );
- gtk_clist_set_text( GTK_CLIST( memclist ), row, 0, TextTmp );
-
- for ( column = 0; column < 16; column++ ) {
- sprintf( TextTmp, "%.2X", ( int ) cpu8051_ReadI( Address + column ) );
- gtk_clist_set_text( GTK_CLIST( memclist ), row, column + 1, TextTmp );
- }
-
- TextLength = 0;
- for ( column = 0; column < 16; column++ ) {
- if ( ( ( int ) cpu8051_ReadI( Address + column ) >= 32 ) && ( ( int ) cpu8051_ReadI( Address + column ) <= 126 ) )
- TextLength += sprintf( &TextTmp[ TextLength ], "%c", cpu8051_ReadI( Address + column ) );
- else TextLength += sprintf( &TextTmp[ TextLength ], "." );
- }
- gtk_clist_set_text( GTK_CLIST( memclist ), row, 17, TextTmp );
-
- Address += 16;
- }
- gtk_clist_thaw( GTK_CLIST( memclist ) );
+ int row;
+ unsigned int Address;
+ GtkListStore *store;
+
+#ifdef EMU8051_DEBUG
+ printf("memwin_DumpD, address = %s\n", MemAddress);
+#endif
+
+ if (strlen(MemAddress) != 0) {
+ if (STREQ(MemAddress, "PC"))
+ Address = cpu8051.pc;
+ else
+ Address = Ascii2Hex(MemAddress, strlen(MemAddress));
+ } else {
+ Address = 0;
+ }
+
+ store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(memlist)));
+
+ for (row = 0; row < DATA_ROWS; row++) {
+ int valid;
+ GtkTreeIter iter;
+ char str[4 + 2]; /* Maximum str len is for address column (4 digits) */
+ char ascii_str[DATA_COLS];
+ int col;
+
+ if (row == 0) {
+ /* Get first row in list store */
+ valid = gtk_tree_model_get_iter_first(
+ GTK_TREE_MODEL(store), &iter);
+ } else {
+ /* Get next row in list store */
+ valid = gtk_tree_model_iter_next(
+ GTK_TREE_MODEL(store), &iter);
+ }
+
+ if (!valid) {
+ printf("Invalid iter...\n");
+ return;
+ }
+
+ /* Display base address. */
+ sprintf(str, "%.4X", Address);
+ gtk_list_store_set(store, &iter, COL_ADDRESS, str, -1);
+
+ for (col = 0; col < DATA_COLS; col++) {
+ u_int8_t data;
+
+ data = cpu8051_ReadD(Address + col);
+
+ /* Display hex data */
+ sprintf(str, "%.2X", (u_int8_t) data);
+ gtk_list_store_set(store, &iter, col + 1, str, -1);
+
+ /* Append to ASCII string (if applicable). */
+ if (!isprint(data))
+ data = '.';
+ sprintf(&ascii_str[col], "%c", data);
+ }
+
+ /* Display ASCII characters. */
+ gtk_list_store_set(store, &iter, COL_ASCII, ascii_str, -1);
+
+ Address += DATA_COLS;
+ }