X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=src%2Fgtk%2Fpgmwin.c;h=d1ad01055c310668d7d3910695fa2ed6c81782f4;hb=f7e3f1d8d0438f52e4f988a12318075cc1b43568;hp=0e8961bd0d51d92a65174cd08e80908d898416de;hpb=1eb382f72510d50b3636fb88c4bfaf17183672b6;p=emu8051.git diff --git a/src/gtk/pgmwin.c b/src/gtk/pgmwin.c index 0e8961b..d1ad010 100644 --- a/src/gtk/pgmwin.c +++ b/src/gtk/pgmwin.c @@ -4,19 +4,7 @@ * Copyright (C) 1999 Jonathan St-André * Copyright (C) 1999 Hugo Villeneuve * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + * This file is released under the GPLv2 */ #if HAVE_CONFIG_H @@ -28,6 +16,7 @@ #include "common.h" #include "memory.h" #include "cpu8051.h" +#include "opcodes.h" #include "pgmwin.h" #include "hexfile.h" @@ -36,8 +25,7 @@ static GtkWidget *pgmlist; #define LIST_VIEW_NAME "Program" #define DATA_ROWS 100 -enum -{ +enum { COL_BREAKPT = 0, COL_ADDR, COL_B0, @@ -84,7 +72,8 @@ pgmwin_init_store(void) if (row == 0) gtk_list_store_set(store, &iter, COL_COLOR, "red", -1); else - gtk_list_store_set(store, &iter, COL_COLOR, "black", -1); + gtk_list_store_set(store, &iter, COL_COLOR, "black", + -1); } return store; @@ -128,6 +117,11 @@ pgmwin_sel_changed_event(GtkWidget *widget, GdkEvent *event, gpointer data) GtkTreeModel *model; GtkTreeIter iter; + /* Remove compiler warning about unused variables. */ + (void) widget; + (void) event; + (void) data; + log_debug("pgmwin_sel_changed_event()"); /* This will only work in single or browse selection mode! */ @@ -140,11 +134,12 @@ pgmwin_sel_changed_event(GtkWidget *widget, GdkEvent *event, gpointer data) gtk_tree_model_get(model, &iter, COL_ADDR, &str_addr, -1); /* Convert hex address in ASCII to integer. */ + /* No need to check error, has already been validated. */ val = asciihex2int(str_addr); log_debug(" row address is: $%04X", val); - ToggleBreakpoint(val); + breakpoint_toggle(val); pgmwin_refresh(); g_free(str_addr); @@ -190,7 +185,7 @@ pgmwin_init(void) gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE); g_signal_connect(selection, "changed", - G_CALLBACK(pgmwin_sel_changed_event), NULL); + G_CALLBACK(pgmwin_sel_changed_event), NULL); pgmwin_init_columns(); @@ -210,9 +205,9 @@ pgmwin_refresh(void) { int row; GtkListStore *store; - unsigned int Address; + unsigned int address; - Address = cpu8051.pc; + address = cpu8051.pc; store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(pgmlist))); @@ -222,8 +217,8 @@ pgmwin_refresh(void) char str[128]; int k; int col_id; - int InstSize; - unsigned char OpCode; + int inst_size; + unsigned char opcode; if (row == 0) { /* Get first row in list store */ @@ -236,11 +231,11 @@ pgmwin_refresh(void) } if (!valid) { - printf("Invalid iter...\n"); + log_err("Tree model: invalid iter"); return; } - if (Address > 0xFFFF) { + if (address > 0xFFFF) { /* * Not the most elegant solution, but it works to not * display instructions past last address, 0xFFFF. @@ -257,7 +252,7 @@ pgmwin_refresh(void) -1); } else { /* Display breakpoints. */ - if (IsBreakpoint(Address)) + if (breakpoint_is_defined(address)) sprintf(str, "*"); else str[0] = '\0'; @@ -265,35 +260,34 @@ pgmwin_refresh(void) gtk_list_store_set(store, &iter, COL_BREAKPT, str, -1); /* Display base address. */ - int2asciihex(Address, str, 4); - + int2asciihex(address, str, 4); gtk_list_store_set(store, &iter, COL_ADDR, str, -1); - OpCode = memory_read8(PGM_MEM_ID, Address); - InstSize = cpu8051_get_instruction_size(OpCode); + opcode = mem_read8(PGM_MEM_ID, address); + inst_size = opcodes_get_instr_size(opcode); /* Display instruction hex bytes. */ for (k = 0, col_id = COL_B0; k < 3; k++, col_id++) { - if (k < InstSize) - int2asciihex(memory_read8(PGM_MEM_ID, - Address + k), + if (k < inst_size) + int2asciihex(mem_read8(PGM_MEM_ID, + address + k), str, 2); else str[0] = '\0'; - gtk_list_store_set(store, &iter, col_id, str, -1); + gtk_list_store_set(store, &iter, col_id, str, + -1); } /* Display instruction menmonic. */ - cpu8051_disasm_mnemonic(OpCode, str); + (void) cpu8051_disasm_mnemonic(opcode, str); gtk_list_store_set(store, &iter, COL_INST, str, -1); /* Display instruction arguments (if applicable). */ - str[0] = '\0'; - cpu8051_disasm_args(Address, str); + cpu8051_disasm_args(address, str); gtk_list_store_set(store, &iter, COL_ARGS, str, -1); - Address += InstSize; + address += inst_size; } } }