diff options
author | Ian C <ianc@noddybox.co.uk> | 2006-09-19 23:39:18 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2006-09-19 23:39:18 +0000 |
commit | ba407390c6ae965fe217ca7ee2a8cffdd701b623 (patch) | |
tree | 596e8b455c1376ddb223bc951e8568f80132d337 /gemma.c | |
parent | 18dd4ce5aa11515ecd54b01bc33ea5ce848b6990 (diff) |
Changed interface so that Z80 registers are exposed publicly -- using a
Set/Get interface was too ponderous for emulation needs.
Diffstat (limited to 'gemma.c')
-rw-r--r-- | gemma.c | 184 |
1 files changed, 84 insertions, 100 deletions
@@ -93,7 +93,7 @@ static Z80Word Get_PC(int back) static void Step(void) { - pc_buffer[pc_head]=Z80GetPC(z80); + pc_buffer[pc_head]=z80->PC; if (pc_head) pc_head--; @@ -197,75 +197,72 @@ static int StrEq(const char *a, const char *b) static int Expand(void *client, const char *p, long *res) { - Z80State s; int ok=TRUE; - Z80GetState(z80,&s); - if (StrEq(p,"AF")) - *res=s.AF; + *res=z80->AF.w; else if (StrEq(p,"BC")) - *res=s.BC; + *res=z80->BC.w; else if (StrEq(p,"DE")) - *res=s.DE; + *res=z80->DE.w; else if (StrEq(p,"HL")) - *res=s.HL; + *res=z80->HL.w; else if (StrEq(p,"IX")) - *res=s.IX; + *res=z80->IX.w; else if (StrEq(p,"IY")) - *res=s.IY; + *res=z80->IY.w; else if (StrEq(p,"SP")) - *res=s.SP; + *res=z80->SP; else if (StrEq(p,"PC")) - *res=s.PC; + *res=z80->PC; else if (StrEq(p,"A")) - *res=HI(s.AF); + *res=HI(z80->AF.w); else if (StrEq(p,"F")) - *res=LO(s.AF); + *res=LO(z80->AF.w); else if (StrEq(p,"B")) - *res=HI(s.BC); + *res=HI(z80->BC.w); else if (StrEq(p,"C")) - *res=LO(s.BC); + *res=LO(z80->BC.w); else if (StrEq(p,"D")) - *res=HI(s.DE); + *res=HI(z80->DE.w); else if (StrEq(p,"E")) - *res=LO(s.DE); + *res=LO(z80->DE.w); else if (StrEq(p,"H")) - *res=HI(s.HL); + *res=HI(z80->HL.w); else if (StrEq(p,"L")) - *res=LO(s.HL); + *res=LO(z80->HL.w); else if (StrEq(p,"AF_")) - *res=s.AF_; + *res=z80->AF_; else if (StrEq(p,"BC_")) - *res=s.BC_; + *res=z80->BC_; else if (StrEq(p,"DE_")) - *res=s.DE_; + *res=z80->DE_; else if (StrEq(p,"HL_")) - *res=s.HL_; + *res=z80->HL_; else if (StrEq(p,"A_")) - *res=HI(s.AF_); + *res=HI(z80->AF_); else if (StrEq(p,"F_")) - *res=LO(s.AF_); + *res=LO(z80->AF_); else if (StrEq(p,"B_")) - *res=HI(s.BC_); + *res=HI(z80->BC_); else if (StrEq(p,"C_")) - *res=LO(s.BC_); + *res=LO(z80->BC_); else if (StrEq(p,"D_")) - *res=HI(s.DE_); + *res=HI(z80->DE_); else if (StrEq(p,"E_")) - *res=LO(s.DE_); + *res=LO(z80->DE_); else if (StrEq(p,"H_")) - *res=HI(s.HL_); + *res=HI(z80->HL_); else if (StrEq(p,"L_")) - *res=LO(s.HL_); + *res=LO(z80->HL_); else if (StrEq(p,"IM")) - *res=s.IM; + *res=z80->IM; else if (StrEq(p,"R")) - *res=s.R; + *res=z80->R; else if (StrEq(p,"IFF1")) - *res=s.IFF1; + *res=z80->IFF1; else if (StrEq(p,"IFF2")) - *res=s.IFF2; + *res=z80->IFF2; else if (p[0]=='@') { Z80Word n; @@ -428,12 +425,9 @@ static Z80Byte ReadPort(Z80 *z80, Z80Word addr) { Z80Byte b=0xff; Z80Word ptr; - Z80State s; char expr[1024]; char *p; - Z80GetState(z80,&s); - switch(addr&0xff) { case 0x80: @@ -453,7 +447,7 @@ static Z80Byte ReadPort(Z80 *z80, Z80Word addr) break; case 0x81: - ptr=s.DE; + ptr=z80->DE.w; p=expr; @@ -477,50 +471,47 @@ static Z80Byte ReadPort(Z80 *z80, Z80Word addr) static void WritePort(Z80 *z80, Z80Word addr, Z80Byte val) { - Z80State s; - DString ds; + Z80Word de; - ds=DSInit(); - Z80GetState(z80,&s); + de=z80->DE.w; switch(addr&0xff) { case 0x80: - DSAddChar(ds,val); + Log("%c",val); + fflush(stdout); break; case 0x81: - DSAdd(ds,"Stop requested via OUT(0x81)\n"); + Log("Stop requested\n"); stop=TRUE; break; case 0x82: - while(Z80_MEMORY[s.DE]!='$') + while(Z80_MEMORY[de]!='$') { - if (isspace(Z80_MEMORY[s.DE]) || isprint(Z80_MEMORY[s.DE])) - { - DSAddChar(ds,Z80_MEMORY[s.DE]); - } + if (isspace(Z80_MEMORY[de]) || + isprint(Z80_MEMORY[de])) + Log("%c",Z80_MEMORY[de]); - s.DE++; + de++; } + fflush(stdout); break; case 0x83: - while(Z80_MEMORY[s.DE]) + while(Z80_MEMORY[de]) { - DSAddChar(ds,Z80_MEMORY[s.DE]); - s.DE++; + Log("%c",Z80_MEMORY[de]); + de++; } + fflush(stdout); break; default: Log("Wrote 0x%2.2x to port 0x%4.4x\n",(int)val,(int)addr); - return; + break; } - - Log(ds->text); - DSFree(ds); } @@ -538,10 +529,6 @@ static int Halt(Z80 *z80, Z80Val v) */ void GEMMA_UpdateDisplay(GEMMA_View view) { - Z80State reg; - - Z80GetState(z80,®); - if (view&UPDATE_ASSEM_VIEW) { Z80Word pc; @@ -562,7 +549,7 @@ void GEMMA_UpdateDisplay(GEMMA_View view) DSAddChar(ds,'\n'); } - pc=Z80GetPC(z80); + pc=z80->PC; for(f=0;f<12;f++) { @@ -593,65 +580,65 @@ void GEMMA_UpdateDisplay(GEMMA_View view) if (view&UPDATE_REG_VIEW) { static int reg_once=FALSE; - static Z80State last_reg; + static Z80 last_reg; DString ds; ds=DSInit(); if (!reg_once) { - last_reg=reg; + last_reg=*z80; reg_once=TRUE; } DSAdd(ds,"<tt>"); - DisplayState(ds,"A ",2,HI(reg.AF),HI(last_reg.AF)); + DisplayState(ds,"A ",2,HI(z80->AF.w),HI(last_reg.AF.w)); DSAdd(ds," "); - FlagString(ds,LO(reg.AF),LO(last_reg.AF)); + FlagString(ds,LO(z80->AF.w),LO(last_reg.AF.w)); DSAdd(ds,"\n"); - DisplayState(ds,"BC ",4,reg.BC,last_reg.BC); + DisplayState(ds,"BC ",4,z80->BC.w,last_reg.BC.w); DSAdd(ds," "); - DisplayState(ds,"DE ",4,reg.DE,last_reg.DE); + DisplayState(ds,"DE ",4,z80->DE.w,last_reg.DE.w); DSAdd(ds," "); - DisplayState(ds,"HL ",4,reg.HL,last_reg.HL); + DisplayState(ds,"HL ",4,z80->HL.w,last_reg.HL.w); DSAdd(ds,"\n"); - DisplayState(ds,"SP ",4,reg.SP,last_reg.SP); + DisplayState(ds,"SP ",4,z80->SP,last_reg.SP); DSAdd(ds," "); - DisplayState(ds,"IX ",4,reg.IX,last_reg.IX); + DisplayState(ds,"IX ",4,z80->IX.w,last_reg.IX.w); DSAdd(ds," "); - DisplayState(ds,"IY ",4,reg.IY,last_reg.IY); + DisplayState(ds,"IY ",4,z80->IY.w,last_reg.IY.w); DSAdd(ds,"\n\n"); - DisplayState(ds,"A' ",2,HI(reg.AF_),HI(last_reg.AF_)); + DisplayState(ds,"A' ",2,HI(z80->AF_),HI(last_reg.AF_)); DSAdd(ds," "); - FlagString(ds,LO(reg.AF_),LO(last_reg.AF_)); + FlagString(ds,LO(z80->AF_),LO(last_reg.AF_)); DSAdd(ds,"\n"); - DisplayState(ds,"BC'",4,reg.BC_,last_reg.BC_); + DisplayState(ds,"BC'",4,z80->BC_,last_reg.BC_); DSAdd(ds," "); - DisplayState(ds,"DE'",4,reg.DE_,last_reg.DE_); + DisplayState(ds,"DE'",4,z80->DE_,last_reg.DE_); DSAdd(ds," "); - DisplayState(ds,"HL'",4,reg.HL_,last_reg.HL_); + DisplayState(ds,"HL'",4,z80->HL_,last_reg.HL_); DSAdd(ds,"\n\n"); - DisplayState(ds,"PC ",4,reg.PC,last_reg.PC); + DisplayState(ds,"PC ",4,z80->PC,last_reg.PC); DSAdd(ds," "); - DisplayState(ds,"CYCLE",8,reg.cycle,last_reg.cycle); + DisplayState(ds,"CYCLE",8,Z80Cycles(z80),0); DSAdd(ds,"\n\n"); - DisplayState(ds,"R ",2,reg.R,last_reg.R); + DisplayState(ds,"R ",2,z80->R,last_reg.R); DSAdd(ds," "); - DisplayState(ds,"IFF1",1,reg.IFF1,last_reg.IFF1); + DisplayState(ds,"IFF1",1,z80->IFF1,last_reg.IFF1); DSAdd(ds," "); - DisplayState(ds,"IFF2",1,reg.IFF2,last_reg.IFF2); + DisplayState(ds,"IFF2",1,z80->IFF2,last_reg.IFF2); DSAdd(ds,"\n"); - DisplayState(ds,"IM ",1,reg.IM,last_reg.IM); + DisplayState(ds,"IM ",1,z80->IM,last_reg.IM); DSAdd(ds," "); - DisplayState(ds,"I",1,reg.I,last_reg.I); + DisplayState(ds,"I",1,z80->I,last_reg.I); DSAdd(ds,"\n"); DSAdd(ds,"</tt>"); @@ -660,7 +647,7 @@ void GEMMA_UpdateDisplay(GEMMA_View view) DSFree(ds); - last_reg=reg; + last_reg=*z80; } if (view&UPDATE_MEM_VIEW) @@ -678,26 +665,26 @@ void GEMMA_UpdateDisplay(GEMMA_View view) switch(gtk_combo_box_get_active(GTK_COMBO_BOX(memview_combo))) { case 0: - addr=reg.HL; + addr=z80->HL.w; break; case 1: - addr=reg.SP; + addr=z80->SP; as_words=TRUE; break; case 2: - addr=reg.IX; + addr=z80->IX.w; break; case 3: - addr=reg.IY; + addr=z80->IY.w; break; case 4: - addr=reg.BC; + addr=z80->BC.w; break; case 5: - addr=reg.DE; + addr=z80->DE.w; break; default: - addr=reg.PC; + addr=z80->PC; break; } @@ -896,20 +883,17 @@ void GEMMA_Step(void) void GEMMA_StepOver(void) { Z80Word next; - Z80State reg; stop=FALSE; - Z80GetState(z80,®); - next=reg.PC; + next=z80->PC; Z80Disassemble(z80,&next); RUNNING(TRUE); - while(reg.PC!=next && !stop) + while(z80->PC!=next && !stop) { Step(); - Z80GetState(z80,®); gtk_main_iteration_do(FALSE); } @@ -986,7 +970,7 @@ void GEMMA_Init(GtkWidget *top) #else z80=Z80Init(Peek,Poke,ReadPort,WritePort,Peek); #endif - Z80SetPC(z80,0x100); + z80->PC=0x100; if (!z80) { |