Rename macros for maximum memory sizes
[emu8051.git] / src / regwin.c
index 0578781..e549c96 100644 (file)
 #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;
 
-#define DATA_ROWS 24
+#define DATA_ROWS 26
 
 enum
 {
@@ -63,7 +65,7 @@ regwin_read(int addr, int width)
                return cpu8051_ReadD(addr);
        else if (width == 4) {
                /* Address is low address. */
-               return (cpu8051_ReadD(addr + 1) << 8) +
+               return (cpu8051_ReadD(addr + 1) << 8) |
                        cpu8051_ReadD(addr);
        } else
                return 0xFFFFFFFF;
@@ -95,6 +97,20 @@ regwin_write_pc(int param, int val)
        cpu8051.pc = (u_int16_t) val;
 }
 
+static unsigned int
+regwin_read_timer(int timer_low_addr)
+{
+       return (cpu8051_ReadD(timer_low_addr + 2) << 8) |
+               cpu8051_ReadD(timer_low_addr);
+}
+
+static void
+regwin_write_timer(int timer_low_addr, int val)
+{
+       cpu8051_WriteD(timer_low_addr + 2, (u_int8_t) ((val & 0x0000FFFF) >> 8));
+       cpu8051_WriteD(timer_low_addr, (u_int8_t) val);
+}
+
 static unsigned int
 regwin_read_bank(int dummy)
 {
@@ -201,6 +217,18 @@ static struct regwin_infos_t regwin_infos[DATA_ROWS] = {
                NULL, NULL,
                _TMOD_,
        },
+       {
+               "TIMER0",
+               HEX_DIGITS_4,
+               regwin_read_timer, regwin_write_timer,
+               _TL0_,
+       },
+       {
+               "TIMER1",
+               HEX_DIGITS_4,
+               regwin_read_timer, regwin_write_timer,
+               _TL1_,
+       },
        {
                "SCON",
                HEX_DIGITS_2,
@@ -281,22 +309,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;
 }
@@ -388,8 +414,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
@@ -467,7 +492,7 @@ regwin_init(void)
 
 /* Show registers. */
 void
-regwin_Show(void)
+regwin_refresh(void)
 {
        int row;
        GtkListStore *store;