X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fregwin.c;h=aaa006b6e56e00ca504861c679b4e861b29d8671;hb=d367f394a97a15018ff1a46d8989586c8456db12;hp=06c643a6f79f25094421f75a61d966e9eaa8bebb;hpb=f3f6f52c0e9b6f42e392835502a5d19ef7abbfc5;p=emu8051.git diff --git a/src/regwin.c b/src/regwin.c index 06c643a..aaa006b 100644 --- a/src/regwin.c +++ b/src/regwin.c @@ -30,7 +30,10 @@ #include "cpu8051.h" #include "regwin.h" #include "memwin.h" +#include "pgmwin.h" #include "instructions_8051.h" +#include "hexfile.h" +#include "emugtk.h" static GtkWidget *reglist; @@ -64,7 +67,8 @@ regwin_read(int addr, int width) /* Address is low address. */ return (cpu8051_ReadD(addr + 1) << 8) + cpu8051_ReadD(addr); - } + } else + return 0xFFFFFFFF; } static void @@ -279,22 +283,20 @@ static GtkListStore * regwin_init_store(void) { GtkTreeIter iter; - int rows; + int row; int col; GtkListStore *store; GType col_types[N_COLUMNS]; - for (col = 0; col < N_COLUMNS; col++) { + /* No need for static array, all our columns are of the same type. */ + for (col = 0; col < N_COLUMNS; col++) col_types[col] = G_TYPE_STRING; - } store = gtk_list_store_newv(N_COLUMNS, col_types); - /* Initialize with rows of dummy data... */ - for (rows = 0; rows < DATA_ROWS; rows++) { - /* Add new row. */ + /* Add rows. */ + for (row = 0; row < DATA_ROWS; row++) gtk_list_store_append(store, &iter); - } return store; } @@ -339,16 +341,14 @@ regwin_cell_edited(GtkCellRendererText *cell, gchar *path_string, /* Read current (old) value. */ gtk_tree_model_get(model, &iter, COL_VAL, &str, -1); - /* Convert old value (asciihex) to integer. */ - sscanf(str, "%x", &old); + old = asciihex2int(str); if (regwin_infos[row].w == 2) log_info(" old value: $%02X", old); else if (regwin_infos[row].w == 4) log_info(" old value: $%04X", old); - /* Convert new value (asciihex) to integer. */ - sscanf(new_str, "%x", &new); + new = asciihex2int(new_str); if (regwin_infos[row].w == 2) { if ((new < 0) || (new > 0xFF)) { @@ -367,10 +367,7 @@ regwin_cell_edited(GtkCellRendererText *cell, gchar *path_string, } /* Convert new value to text. */ - if (regwin_infos[row].w == 2) - sprintf(str, "%02X", new); - else if (regwin_infos[row].w == 4) - sprintf(str, "%04X", new); + int2asciihex(new, str, regwin_infos[row].w); /* Store new value in emulator register. */ if (regwin_infos[row].write_func == NULL) { @@ -391,8 +388,7 @@ regwin_cell_edited(GtkCellRendererText *cell, gchar *path_string, * Make sure to update all windows. * For example, R0-R7 values depends on internal memory values. */ - regwin_Show(); - memwin_DumpD("0"); + emugtk_UpdateDisplay(); }; static void @@ -507,14 +503,12 @@ regwin_Show(void) regwin_infos[row].w); } else { /* Read register value using custom function pointer. */ - val = regwin_infos[row].read_func(regwin_infos[row].param); + val = regwin_infos[row].read_func( + regwin_infos[row].param); } /* Convert to specified number of hex digits. */ - if (regwin_infos[row].w == 2) - sprintf(str , "%.2X", (u_int8_t) val); - else if (regwin_infos[row].w == 4) - sprintf(str , "%.4X", (u_int16_t) val); + int2asciihex(val, str, regwin_infos[row].w); gtk_list_store_set(store, &iter, COL_NAME, regwin_infos[row].name,