From 37141ac197eaefeae9dada0bcc1c429ff584df44 Mon Sep 17 00:00:00 2001 From: Ian C Date: Fri, 1 Sep 2006 23:48:25 +0000 Subject: GEMMA largely working. Fixed broken expressions with white space. --- callbacks.c | 12 ++- callbacks.h | 4 + expr.c | 33 ++++---- gemma.c | 250 +++++++++++++++++++++++++++++++++++++++++++++++++++-------- gemma.glade | 139 ++++++++++++++++++++++++++++----- gemma.gladep | 1 + gemma.h | 2 +- gtkutil.c | 86 ++++++++------------ gtkutil.h | 3 +- interface.c | 53 ++++++++++--- main.c | 15 +++- z80.c | 6 ++ z80.h | 5 ++ 13 files changed, 472 insertions(+), 137 deletions(-) diff --git a/callbacks.c b/callbacks.c index a0a7a1a..2b8ffa9 100644 --- a/callbacks.c +++ b/callbacks.c @@ -15,6 +15,7 @@ void CloseApplication(GtkObject *object, gpointer user_data) { + GEMMA_Stop(); gtk_main_quit(); } @@ -47,7 +48,7 @@ void OnLoadHEX(GtkButton *button, gpointer user_data) { static char path[PATH_MAX]={0}; - if (DialogFSelect("Select INTEL HEX File to load",path)) + if (DialogFSelect("Open INTEL HEX File","INTEL HEX","*.hex",path)) { GEMMA_LoadHEX(path); } @@ -58,7 +59,7 @@ void OnLoadLabels(GtkButton *button, gpointer user_data) { static char path[PATH_MAX]={0}; - if (DialogFSelect("Select Label File to load",path)) + if (DialogFSelect("Open Label File","Labels","*.lbl",path)) { GEMMA_LoadLabels(path); } @@ -67,12 +68,13 @@ void OnLoadLabels(GtkButton *button, gpointer user_data) void OnRunUntil(GtkButton *button, gpointer user_data) { - DialogOK("Not yet implemented"); + GEMMA_RunUntil(); } void OnQuit(GtkButton *button, gpointer user_data) { + GEMMA_Stop(); gtk_main_quit(); } @@ -82,3 +84,7 @@ void OnMemoryViewChoice(GtkComboBox *combobox, gpointer user_data) GEMMA_UpdateDisplay(UPDATE_MEM_VIEW); } +void OnViewMode(GtkToggleButton *togglebutton, gpointer user_data) +{ + GEMMA_UpdateDisplay(UPDATE_MEM_VIEW); +} diff --git a/callbacks.h b/callbacks.h index f3a05f5..e27c7be 100644 --- a/callbacks.h +++ b/callbacks.h @@ -40,3 +40,7 @@ OnQuit (GtkButton *button, void OnMemoryViewChoice (GtkComboBox *combobox, gpointer user_data); + +void +OnViewMode (GtkToggleButton *togglebutton, + gpointer user_data); diff --git a/expr.c b/expr.c index 9369e1d..6cd8237 100644 --- a/expr.c +++ b/expr.c @@ -436,23 +436,30 @@ static Stack *ToPostfix(const char *expr) } else { - /* Found an operand - parse and store the operand - */ - p=buff; - - while(*expr && !IS_OPERAND_END(*expr)) + if (!isspace(*expr)) { - *p++=*expr++; - } + /* Found an operand - parse and store the operand + */ + p=buff; - *p=0; + while(*expr && !IS_OPERAND_END(*expr)) + { + *p++=*expr++; + } - /* Note that operands are marked as unary just to chose one over - the other branch in EvalPostfix() - no other reason - */ - output=Push(output,TYPE_OPERAND,0,TRUE,buff); + *p=0; - prev_was_op=FALSE; + /* Note that operands are marked as unary just to chose one over + the other branch in EvalPostfix() - no other reason + */ + output=Push(output,TYPE_OPERAND,0,TRUE,buff); + + prev_was_op=FALSE; + } + else + { + expr++; + } } } diff --git a/gemma.c b/gemma.c index 015362b..fbf72fc 100644 --- a/gemma.c +++ b/gemma.c @@ -36,7 +36,7 @@ static const char id[]="$Id$"; #define HI(w) (((w)&0xff00)>>8) #define LO(w) ((w)&0xff) -#define MK(h,l) (((Z80Word)(h))<<8|(l)) +#define MK(h,l) (((Z80Word)(h)<<8)|(l)) /* ---------------------------------------- GLOBALS */ @@ -54,6 +54,8 @@ static GtkWidget *step_over_button; static GtkWidget *stop_button; static GtkWidget *run_until_button; +static GtkWidget *breakpoint_text; + static GtkWidget *top_window; static GtkWidget *regview; static GtkWidget *memview; @@ -61,6 +63,9 @@ static GtkWidget *viewreg; static GtkWidget *logview; static GtkWidget *assemview; +static GtkWidget *memview_combo; +static GtkWidget *memview_check; + #define RUNNING(t) gtk_widget_set_sensitive(run_button,!t); \ gtk_widget_set_sensitive(step_button,!t); \ gtk_widget_set_sensitive(step_over_button,!t); \ @@ -76,6 +81,29 @@ static void *Malloc(size_t len); static void *Realloc(void *p, size_t len); +/* ---------------------------------------- PC BUFFER +*/ +#define PC_BUFFER 100 +static Z80Word pc_buffer[PC_BUFFER]={0}; +static int pc_head=0; + +static Z80Word Get_PC(int back) +{ + return pc_buffer[(pc_head+back+1)%PC_BUFFER]; +} + +static void Step(void) +{ + pc_buffer[pc_head]=Z80GetPC(z80); + + if (pc_head) + pc_head--; + else + pc_head=PC_BUFFER-1; + + Z80SingleStep(z80); +} + /* ---------------------------------------- DYNAMIC STRINGS */ @@ -335,13 +363,10 @@ static const int ToHex(char c) static void FlagString(DString s, Z80Byte flag, Z80Byte last) { - static char buff[32]; static char *c[]={"S","Z","5","H","3","P","N","C"}; int f; - sprintf(buff,"%-10.10s: ","Flags"); - - DSAdd(s,buff); + DSAdd(s,"Flags: "); for(f=0;f<8;f++) { @@ -502,24 +527,43 @@ static int Halt(Z80 *z80, Z80Val v) */ void GEMMA_UpdateDisplay(GEMMA_View view) { + Z80State reg; + + Z80GetState(z80,®); + if (view&UPDATE_ASSEM_VIEW) { - Z80State reg; + Z80Word pc; DString ds; + char buff[10]; int f; ds=DSInit(); - Z80GetState(z80,®); - DSAdd(ds,""); + DSAdd(ds,""); + + for(f=10;f>=0;f--) + { + pc=Get_PC(f); + + sprintf(buff,"%4.4X: ",pc); + DSAdd(ds,buff); + DSAdd(ds,Z80Disassemble(z80,&pc)); + DSAddChar(ds,'\n'); + } + + pc=Z80GetPC(z80); - for(f=0;f<20;f++) + for(f=0;f<12;f++) { if (f==0) { DSAdd(ds,""); } - DSAdd(ds,Z80Disassemble(z80,®.PC)); + sprintf(buff,"%4.4X: ",pc); + DSAdd(ds,buff); + + DSAdd(ds,Z80Disassemble(z80,&pc)); if (f==0) { @@ -529,7 +573,7 @@ void GEMMA_UpdateDisplay(GEMMA_View view) DSAddChar(ds,'\n'); } - DSAdd(ds,""); + DSAdd(ds,""); gtk_label_set_markup(GTK_LABEL(assemview),ds->text); DSFree(ds); @@ -539,52 +583,64 @@ void GEMMA_UpdateDisplay(GEMMA_View view) { static int reg_once=FALSE; static Z80State last_reg; - Z80State reg; DString ds; ds=DSInit(); - Z80GetState(z80,®); if (!reg_once) { last_reg=reg; + reg_once=TRUE; } DSAdd(ds,""); - DisplayState(ds,"A",2,HI(reg.AF),HI(last_reg.AF)); + DisplayState(ds,"A ",2,HI(reg.AF),HI(last_reg.AF)); DSAdd(ds," "); FlagString(ds,LO(reg.AF),LO(last_reg.AF)); DSAdd(ds,"\n"); - DisplayState(ds,"BC",4,reg.BC,last_reg.BC); + DisplayState(ds,"BC ",4,reg.BC,last_reg.BC); DSAdd(ds," "); - DisplayState(ds,"DE",4,reg.DE,last_reg.DE); + DisplayState(ds,"DE ",4,reg.DE,last_reg.DE); DSAdd(ds," "); - DisplayState(ds,"HL",4,reg.HL,last_reg.HL); + DisplayState(ds,"HL ",4,reg.HL,last_reg.HL); DSAdd(ds,"\n"); - DisplayState(ds,"SP",4,reg.SP,last_reg.SP); + DisplayState(ds,"SP ",4,reg.SP,last_reg.SP); DSAdd(ds," "); - DisplayState(ds,"IX",4,reg.IX,last_reg.IX); + DisplayState(ds,"IX ",4,reg.IX,last_reg.IX); DSAdd(ds," "); - DisplayState(ds,"IY",4,reg.IY,last_reg.IY); - DSAdd(ds,"\n"); + DisplayState(ds,"IY ",4,reg.IY,last_reg.IY); + DSAdd(ds,"\n\n"); - DisplayState(ds,"AF'",4,reg.AF_,last_reg.AF_); + DisplayState(ds,"A' ",2,HI(reg.AF_),HI(last_reg.AF_)); DSAdd(ds," "); + FlagString(ds,LO(reg.AF_),LO(last_reg.AF_)); + DSAdd(ds,"\n"); + DisplayState(ds,"BC'",4,reg.BC_,last_reg.BC_); DSAdd(ds," "); DisplayState(ds,"DE'",4,reg.DE_,last_reg.DE_); DSAdd(ds," "); DisplayState(ds,"HL'",4,reg.HL_,last_reg.HL_); + DSAdd(ds,"\n\n"); + + DisplayState(ds,"PC ",4,reg.PC,last_reg.PC); + DSAdd(ds," "); + DisplayState(ds,"CYCLE",8,reg.cycle,last_reg.cycle); + DSAdd(ds,"\n\n"); + + DisplayState(ds,"R ",2,reg.R,last_reg.R); + DSAdd(ds," "); + DisplayState(ds,"IFF1",1,reg.IFF1,last_reg.IFF1); + DSAdd(ds," "); + DisplayState(ds,"IFF2",1,reg.IFF2,last_reg.IFF2); DSAdd(ds,"\n"); - DisplayState(ds,"PC",4,reg.PC,last_reg.PC); - DSAdd(ds,"\n"); - DisplayState(ds,"R",4,reg.R,last_reg.R); - DSAdd(ds,"\n"); - DisplayState(ds,"CYCLES",8,reg.cycle,last_reg.cycle); + DisplayState(ds,"IM ",1,reg.IM,last_reg.IM); + DSAdd(ds," "); + DisplayState(ds,"I",1,reg.I,last_reg.I); DSAdd(ds,"\n"); DSAdd(ds,""); @@ -595,6 +651,114 @@ void GEMMA_UpdateDisplay(GEMMA_View view) last_reg=reg; } + + if (view&UPDATE_MEM_VIEW) + { + Z80Word addr; + Z80Word orig; + DString ds; + int f; + gboolean as_words; + + ds=DSInit(); + + as_words=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(memview_check)); + + switch(gtk_combo_box_get_active(GTK_COMBO_BOX(memview_combo))) + { + case 0: + addr=reg.HL; + break; + case 1: + addr=reg.SP; + as_words=TRUE; + break; + case 2: + addr=reg.IX; + break; + case 3: + addr=reg.IY; + break; + case 4: + addr=reg.BC; + break; + case 5: + addr=reg.DE; + break; + default: + addr=reg.PC; + break; + } + + DSAdd(ds,""); + + orig=addr; + addr-=6*8; + + for(f=0;f<13;f++) + { + DString asc; + char buff[10]; + Z80Word off; + + asc=DSInit(); + + sprintf(buff,"%4.4X: ",addr); + DSAdd(ds,buff); + + for(off=0;off<8;off++) + { + gchar *p; + p=g_markup_printf_escaped + ("%c",isprint(mem[addr+off]) ? mem[addr+off] : '.'); + DSAdd(asc,p); + g_free(p); + } + + for(off=0;off<8;off+=(as_words ? 2:1)) + { + Z80Word a; + + a=addr+off; + + if (a==orig) + { + DSAdd(ds,""); + } + + if (as_words) + { + sprintf(buff,"%4.4X ",MK(mem[a+1],mem[a])); + } + else + { + sprintf(buff,"%2.2X ",mem[a]); + } + + DSAdd(ds,buff); + + if (a==orig) + { + DSAdd(ds,""); + } + } + + DSAdd(ds," "); + DSAdd(ds,asc->text); + DSAdd(ds,"\n"); + + DSFree(asc); + + addr+=8; + } + + DSAdd(ds,""); + + gtk_label_set_markup(GTK_LABEL(memview),ds->text); + + DSFree(ds); + } } @@ -713,7 +877,7 @@ void GEMMA_LoadLabels(const char *path) void GEMMA_Step(void) { - Z80SingleStep(z80); + Step(); GEMMA_UpdateDisplay(UPDATE_ALL_VIEWS); } @@ -733,11 +897,13 @@ void GEMMA_StepOver(void) while(reg.PC!=next && !stop) { - GEMMA_Step(); + Step(); Z80GetState(z80,®); gtk_main_iteration_do(FALSE); } + GEMMA_UpdateDisplay(UPDATE_ALL_VIEWS); + RUNNING(FALSE); } @@ -758,8 +924,12 @@ void GEMMA_Run(void) } -void GEMMA_RunUntil(const char *expr) +void GEMMA_RunUntil(void) { + char *expr; + + expr=StrCopy(gtk_entry_get_text(GTK_ENTRY(breakpoint_text))); + stop=FALSE; RUNNING(TRUE); @@ -770,14 +940,14 @@ void GEMMA_RunUntil(const char *expr) if (!ExprEval(expr,&e,Expand,z80)) { - Log("%s\n",ExprError()); + DialogOK("Error evaluating express:\n%s",ExprError()); stop=TRUE; continue; } if (e) { - Log("%s TRUE\n",expr); + DialogOK("%s TRUE",expr); stop=TRUE; continue; } @@ -786,6 +956,8 @@ void GEMMA_RunUntil(const char *expr) gtk_main_iteration_do(FALSE); } + free(expr); + RUNNING(FALSE); } @@ -803,6 +975,7 @@ void GEMMA_Init(GtkWidget *top) for(f=0;f<256;f++) memctl[f]=1; z80=Z80Init(mem,memctl,WritePort,ReadPort); + Z80SetPC(z80,0x100); if (!z80) { @@ -818,6 +991,19 @@ void GEMMA_Init(GtkWidget *top) viewreg=lookup_widget(top_window,"memory_view_choice"); logview=lookup_widget(top_window,"log_view"); assemview=lookup_widget(top_window,"assem_view"); + + memview_combo=lookup_widget(top_window,"memory_view_choice"); + memview_check=lookup_widget(top_window,"viewmode_check"); + + breakpoint_text=lookup_widget(top_window,"breakpoint_text"); + + run_button=lookup_widget(top_window,"run_button"); + step_button=lookup_widget(top_window,"step_button"); + step_over_button=lookup_widget(top_window,"step_over_button"); + stop_button=lookup_widget(top_window,"stop_button"); + run_until_button=lookup_widget(top_window,"run_until_button"); + + gtk_combo_box_set_active(GTK_COMBO_BOX(memview_combo),0); } diff --git a/gemma.glade b/gemma.glade index a38cc57..073a0e5 100644 --- a/gemma.glade +++ b/gemma.glade @@ -22,6 +22,7 @@ GDK_GRAVITY_NORTH_WEST True False + @@ -32,11 +33,13 @@ True - True + False 0 + 550 + 80 True <b>Assembler View</b> False @@ -44,7 +47,7 @@ GTK_JUSTIFY_LEFT False False - 0 + 0.0299999993294 0 0 0 @@ -55,15 +58,17 @@ 0 - True - True + False + False + 350 + 80 True - <b>Regsiter View</b> + <b>Register View</b> False True GTK_JUSTIFY_LEFT @@ -80,8 +85,8 @@ 0 - True - True + False + False @@ -106,27 +111,62 @@ 0 - + True - SP -HL + False + 0 + + + + True + HL +SP IX IY BC -DE - False - True - +DE +PC + False + True + + + + 0 + True + True + + + + + + True + True + View as Words + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + 0 + False + False + + 0 False - False + True + 200 True <b>Memory View</b> False @@ -134,7 +174,7 @@ DE GTK_JUSTIFY_LEFT False False - 0 + 0.0299999993294 0 0 0 @@ -146,13 +186,13 @@ DE 0 False - True + False 0 - True + False True @@ -188,7 +228,7 @@ DE 0 - True + False True @@ -200,6 +240,63 @@ DE + + + True + False + 0 + + + + True + Run Until Expression: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + True + True + True + 0 + + True + * + False + + + 0 + True + True + + + + + 0 + False + True + + + 4 @@ -269,7 +366,7 @@ DE True GTK_RELIEF_NORMAL True - + @@ -291,7 +388,7 @@ DE True True True - Run Until + Run Until... True GTK_RELIEF_NORMAL True diff --git a/gemma.gladep b/gemma.gladep index 6b08f7f..1e7dfaf 100644 --- a/gemma.gladep +++ b/gemma.gladep @@ -7,4 +7,5 @@ . FALSE FALSE + FALSE diff --git a/gemma.h b/gemma.h index c7ccc1d..be0698f 100644 --- a/gemma.h +++ b/gemma.h @@ -45,7 +45,7 @@ void GEMMA_UpdateDisplay(GEMMA_View view); void GEMMA_Step(void); void GEMMA_StepOver(void); void GEMMA_Run(void); -void GEMMA_RunUntil(const char *expr); +void GEMMA_RunUntil(void); void GEMMA_Stop(void); void GEMMA_Interrupt(int nmi); diff --git a/gtkutil.c b/gtkutil.c index b5ec30c..cbcf2f4 100644 --- a/gtkutil.c +++ b/gtkutil.c @@ -46,8 +46,6 @@ static GtkWidget *dialog; static int dial_done=FALSE; static int selected=FALSE; -static char saved_path[PATH_MAX+1]; - /* ---------------------------------------- PRIVATE FUNCTIONS */ @@ -66,25 +64,6 @@ static gint DestroyCB(GtkWidget *w, GdkEvent *ev, gpointer data) } -static gint NoDestroyCB(GtkWidget *w, GdkEvent *ev, gpointer data) -{ - dial_done=TRUE; - selected=(int)data; - return TRUE; -} - - -static void FselCallback(GtkWidget *w, gpointer data) -{ - dial_done=TRUE; - selected=(int)data; - - if (selected) - strcpy(saved_path, - gtk_file_selection_get_filename(GTK_FILE_SELECTION(dialog))); -} - - /* ---------------------------------------- EXPORTED FUNCTIONS */ void DialogParent(GtkWidget *w) @@ -190,43 +169,40 @@ int DialogYesNo(const char *format, ...) } -int DialogFSelect(const char *title, char path[]) +int DialogFSelect(const char *title, const char *filter_name, + const char *filter, char path[]) { - dialog=gtk_file_selection_new(title); - - if (path[0]) - gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog),path); - - gtk_signal_connect(GTK_OBJECT (GTK_FILE_SELECTION(dialog)->ok_button), - "clicked", - GTK_SIGNAL_FUNC (FselCallback), - (gpointer)1); + GtkWidget *fsel; + int ret=FALSE; - gtk_signal_connect(GTK_OBJECT (GTK_FILE_SELECTION(dialog)->cancel_button), - "clicked", - GTK_SIGNAL_FUNC (FselCallback), - (gpointer)0); - - gtk_signal_connect(GTK_OBJECT(dialog), "delete_event", - GTK_SIGNAL_FUNC(NoDestroyCB), (gpointer)0); - - gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(parent)); - gtk_window_set_modal(GTK_WINDOW(dialog),TRUE); - gtk_window_set_position(GTK_WINDOW(dialog),GTK_WIN_POS_CENTER_ON_PARENT); + fsel=gtk_file_chooser_dialog_new(title, + GTK_WINDOW(parent), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); - gtk_widget_show(dialog); - - dial_done=FALSE; - - while(!dial_done) - gtk_main_iteration(); - - if (selected) - strcpy(path,saved_path); - - gtk_widget_destroy(dialog); - - return selected; + if (path[0]) + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(fsel),path); + + if (filter_name && filter) + { + GtkFileFilter *f=gtk_file_filter_new(); + gtk_file_filter_set_name(GTK_FILE_FILTER(f),filter_name); + gtk_file_filter_add_pattern(GTK_FILE_FILTER(f),filter); + gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(fsel), + GTK_FILE_FILTER(f)); + } + + if (gtk_dialog_run(GTK_DIALOG(fsel))==GTK_RESPONSE_ACCEPT) + { + strcpy(path,gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fsel))); + ret=TRUE; + } + + gtk_widget_destroy(fsel); + + return ret; } diff --git a/gtkutil.h b/gtkutil.h index 46717d2..e1ea3fd 100644 --- a/gtkutil.h +++ b/gtkutil.h @@ -53,7 +53,8 @@ int DialogYesNo(const char *format, ...); MAX_PATH long. If the user selects a file, TRUE is returned and the filename copied to path. */ -int DialogFSelect(const char *title, char path[]); +int DialogFSelect(const char *title, const char *filter_name, + const char *filter, char path[]); /* Append text to a text view */ diff --git a/interface.c b/interface.c index 6ecaa11..ad0defe 100644 --- a/interface.c +++ b/interface.c @@ -36,10 +36,15 @@ create_top_window (void) GtkWidget *register_view; GtkWidget *hbox1; GtkWidget *vbox5; + GtkWidget *hbox3; GtkWidget *memory_view_choice; + GtkWidget *viewmode_check; GtkWidget *memory_view; GtkWidget *scrolledwindow1; GtkWidget *log_view; + GtkWidget *hbox4; + GtkWidget *label1; + GtkWidget *breakpoint_text; GtkWidget *hbuttonbox1; GtkWidget *run_button; GtkWidget *step_button; @@ -61,23 +66,23 @@ create_top_window (void) gtk_widget_show (vbox4); gtk_container_add (GTK_CONTAINER (top_window), vbox4); - hbox2 = gtk_hbox_new (TRUE, 0); + hbox2 = gtk_hbox_new (FALSE, 0); gtk_widget_show (hbox2); gtk_box_pack_start (GTK_BOX (vbox4), hbox2, TRUE, TRUE, 0); assem_view = gtk_label_new (_("Assembler View")); gtk_widget_show (assem_view); gtk_box_pack_start (GTK_BOX (hbox2), assem_view, FALSE, FALSE, 0); - gtk_widget_set_size_request (assem_view, 451, 80); + gtk_widget_set_size_request (assem_view, 550, 80); gtk_label_set_use_markup (GTK_LABEL (assem_view), TRUE); gtk_misc_set_alignment (GTK_MISC (assem_view), 0.03, 0); - register_view = gtk_label_new (_("Regsiter View")); + register_view = gtk_label_new (_("Register View")); gtk_widget_show (register_view); gtk_box_pack_start (GTK_BOX (hbox2), register_view, FALSE, FALSE, 0); - gtk_widget_set_size_request (register_view, 450, 80); + gtk_widget_set_size_request (register_view, 350, 80); gtk_label_set_use_markup (GTK_LABEL (register_view), TRUE); - gtk_misc_set_alignment (GTK_MISC (register_view), 0.03, 0); + gtk_misc_set_alignment (GTK_MISC (register_view), 0, 0); hbox1 = gtk_hbox_new (TRUE, 0); gtk_widget_show (hbox1); @@ -88,19 +93,29 @@ create_top_window (void) gtk_widget_show (vbox5); gtk_box_pack_start (GTK_BOX (hbox1), vbox5, FALSE, TRUE, 0); + hbox3 = gtk_hbox_new (FALSE, 0); + gtk_widget_show (hbox3); + gtk_box_pack_start (GTK_BOX (vbox5), hbox3, FALSE, TRUE, 0); + memory_view_choice = gtk_combo_box_new_text (); gtk_widget_show (memory_view_choice); - gtk_box_pack_start (GTK_BOX (vbox5), memory_view_choice, FALSE, FALSE, 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (memory_view_choice), _("SP")); + gtk_box_pack_start (GTK_BOX (hbox3), memory_view_choice, TRUE, TRUE, 0); gtk_combo_box_append_text (GTK_COMBO_BOX (memory_view_choice), _("HL")); + gtk_combo_box_append_text (GTK_COMBO_BOX (memory_view_choice), _("SP")); gtk_combo_box_append_text (GTK_COMBO_BOX (memory_view_choice), _("IX")); gtk_combo_box_append_text (GTK_COMBO_BOX (memory_view_choice), _("IY")); gtk_combo_box_append_text (GTK_COMBO_BOX (memory_view_choice), _("BC")); gtk_combo_box_append_text (GTK_COMBO_BOX (memory_view_choice), _("DE")); + gtk_combo_box_append_text (GTK_COMBO_BOX (memory_view_choice), _("PC")); + + viewmode_check = gtk_check_button_new_with_mnemonic (_("View as Words")); + gtk_widget_show (viewmode_check); + gtk_box_pack_start (GTK_BOX (hbox3), viewmode_check, FALSE, FALSE, 0); memory_view = gtk_label_new (_("Memory View")); gtk_widget_show (memory_view); - gtk_box_pack_start (GTK_BOX (vbox5), memory_view, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (vbox5), memory_view, FALSE, FALSE, 0); + gtk_widget_set_size_request (memory_view, -1, 200); gtk_label_set_use_markup (GTK_LABEL (memory_view), TRUE); gtk_misc_set_alignment (GTK_MISC (memory_view), 0.03, 0); @@ -116,6 +131,18 @@ create_top_window (void) gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (log_view), GTK_WRAP_CHAR); gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (log_view), FALSE); + hbox4 = gtk_hbox_new (FALSE, 0); + gtk_widget_show (hbox4); + gtk_box_pack_start (GTK_BOX (vbox4), hbox4, FALSE, TRUE, 0); + + label1 = gtk_label_new (_("Run Until Expression: ")); + gtk_widget_show (label1); + gtk_box_pack_start (GTK_BOX (hbox4), label1, FALSE, FALSE, 0); + + breakpoint_text = gtk_entry_new (); + gtk_widget_show (breakpoint_text); + gtk_box_pack_start (GTK_BOX (hbox4), breakpoint_text, TRUE, TRUE, 0); + hbuttonbox1 = gtk_hbutton_box_new (); gtk_widget_show (hbuttonbox1); gtk_box_pack_start (GTK_BOX (vbox4), hbuttonbox1, FALSE, TRUE, 0); @@ -153,7 +180,7 @@ create_top_window (void) gtk_container_add (GTK_CONTAINER (hbuttonbox1), load_labels_button); GTK_WIDGET_SET_FLAGS (load_labels_button, GTK_CAN_DEFAULT); - run_until_button = gtk_button_new_with_mnemonic (_("Run Until")); + run_until_button = gtk_button_new_with_mnemonic (_("Run Until...")); gtk_widget_show (run_until_button); gtk_container_add (GTK_CONTAINER (hbuttonbox1), run_until_button); GTK_WIDGET_SET_FLAGS (run_until_button, GTK_CAN_DEFAULT); @@ -169,6 +196,9 @@ create_top_window (void) g_signal_connect ((gpointer) memory_view_choice, "changed", G_CALLBACK (OnMemoryViewChoice), NULL); + g_signal_connect ((gpointer) viewmode_check, "toggled", + G_CALLBACK (OnViewMode), + NULL); g_signal_connect ((gpointer) run_button, "clicked", G_CALLBACK (OnRun), NULL); @@ -202,10 +232,15 @@ create_top_window (void) GLADE_HOOKUP_OBJECT (top_window, register_view, "register_view"); GLADE_HOOKUP_OBJECT (top_window, hbox1, "hbox1"); GLADE_HOOKUP_OBJECT (top_window, vbox5, "vbox5"); + GLADE_HOOKUP_OBJECT (top_window, hbox3, "hbox3"); GLADE_HOOKUP_OBJECT (top_window, memory_view_choice, "memory_view_choice"); + GLADE_HOOKUP_OBJECT (top_window, viewmode_check, "viewmode_check"); GLADE_HOOKUP_OBJECT (top_window, memory_view, "memory_view"); GLADE_HOOKUP_OBJECT (top_window, scrolledwindow1, "scrolledwindow1"); GLADE_HOOKUP_OBJECT (top_window, log_view, "log_view"); + GLADE_HOOKUP_OBJECT (top_window, hbox4, "hbox4"); + GLADE_HOOKUP_OBJECT (top_window, label1, "label1"); + GLADE_HOOKUP_OBJECT (top_window, breakpoint_text, "breakpoint_text"); GLADE_HOOKUP_OBJECT (top_window, hbuttonbox1, "hbuttonbox1"); GLADE_HOOKUP_OBJECT (top_window, run_button, "run_button"); GLADE_HOOKUP_OBJECT (top_window, step_button, "step_button"); diff --git a/main.c b/main.c index f39e133..038dd49 100644 --- a/main.c +++ b/main.c @@ -38,6 +38,8 @@ static const char ident[]="$Id$"; int main (int argc, char *argv[]) { + int f; + GtkWidget *top_window; gtk_set_locale (); @@ -48,7 +50,6 @@ int main (int argc, char *argv[]) DialogParent(top_window); GEMMA_Init(top_window); - GEMMA_UpdateDisplay(UPDATE_ALL_VIEWS); AppendText(lookup_widget(top_window,"log_view"), "GEMMA, Copyright (C) 2006 Ian Cowburn\n" @@ -57,7 +58,17 @@ int main (int argc, char *argv[]) "to redistribute it under certain conditions;\n" "See the GNU General Public License for details.\n"); - gtk_main (); + for(f=1;fPC; +} + + void Z80ResetCycles(Z80 *cpu, Z80Val cycles) { cpu->cycle=cycles; diff --git a/z80.h b/z80.h index 5ac28b7..9683e3f 100644 --- a/z80.h +++ b/z80.h @@ -179,6 +179,11 @@ void Z80Reset(Z80 *cpu); void Z80SetPC(Z80 *cpu, Z80Word PC); +/* Gets the PC +*/ +Z80Word Z80GetPC(Z80 *cpu); + + /* Sets the cycle count to the specified count */ void Z80ResetCycles(Z80 *cpu, Z80Val cycles); -- cgit v1.2.3