Diff for /xmil/z80c/z80c.c between versions 1.2 and 1.9

version 1.2, 2004/08/05 11:30:13 version 1.9, 2005/02/04 06:42:14
Line 11 Line 11
 #include        "parts.h"  #include        "parts.h"
 #include        "z80core.h"  #include        "z80core.h"
 #include        "z80c.h"  #include        "z80c.h"
   #include        "pccore.h"
   #include        "iocore.h"
 #include        "z80c.mcr"  #include        "z80c.mcr"
   
   
         Z80CORE z80core;          Z80CORE z80core;
           UINT8   mainmem[0x10000];
   
         UINT8   ZSPtable[256];          UINT8   z80inc_flag2[256];
         UINT8   z80inc_flag[256];          UINT8   z80dec_flag2[256];
         UINT8   z80dec_flag[256];  
         UINT8   z80szc_flag[512];          UINT8   z80szc_flag[512];
           UINT8   z80szp_flag[256];
   
         const UINT8 cycles_main[256] = {          const UINT8 cycles_main[256] = {
                                          4,10, 7, 6, 4, 4, 7, 4, 4,11, 7, 6, 4, 4, 7, 4,                                           4,10, 7, 6, 4, 4, 7, 4, 4,11, 7, 6, 4, 4, 7, 4,
Line 96  void CPUCALL z80c_initialize(void) { Line 99  void CPUCALL z80c_initialize(void) {
                         }                          }
                 }                  }
   
                 ZSPtable[i] = (UINT8)f;                  z80szp_flag[i] = (UINT8)f;
   
                 z80inc_flag[i] = (UINT8)(f & (~V_FLAG));                  z80inc_flag2[(i - 1) & 0xff] = (UINT8)(f & (~V_FLAG));
                 if (!(i & 0x0f)) {                  if (!(i & 0x0f)) {
                         z80inc_flag[i] |= H_FLAG;                          z80inc_flag2[(i - 1) & 0xff] |= H_FLAG;
                 }                  }
                 z80dec_flag[i] = (UINT8)(f & (~V_FLAG)) | N_FLAG;                  z80dec_flag2[(i + 1) & 0xff] = (UINT8)(f & (~V_FLAG)) | N_FLAG;
                 if ((i & 0x0f) == 0x0f) {                  if ((i & 0x0f) == 0x0f) {
                         z80dec_flag[i] |= H_FLAG;                          z80dec_flag2[(i + 1) & 0xff] |= H_FLAG;
                 }                  }
   
                 z80szc_flag[i] = (UINT8)(f & (~V_FLAG));                  z80szc_flag[i] = (UINT8)(f & (~V_FLAG));
                 z80szc_flag[i+256] = (UINT8)(f & (~V_FLAG)) | C_FLAG;                  z80szc_flag[i+256] = (UINT8)(f & (~V_FLAG)) | C_FLAG;
         }          }
         z80inc_flag[0x80] |= V_FLAG;          z80inc_flag2[0x80 - 1] |= V_FLAG;
         z80dec_flag[0x7f] |= V_FLAG;          z80dec_flag2[0x7f + 1] |= V_FLAG;
 }  }
   
 void CPUCALL z80c_reset(void) {  void CPUCALL z80c_reset(void) {
   
         z80c_initialize();  
   
         ZeroMemory(&z80core.s, sizeof(z80core.s));          ZeroMemory(&z80core.s, sizeof(z80core.s));
         R_Z80R = rand_get();          R_Z80R = rand_get();
 }  }
   
 REG8 CPUCALL z80c_ableinterrupt(void) {  
   
         return((Z80_IFF & ((1 << IFF_IFLAG) | (1 << IFF_IRQ) | (1 << IFF_NMI)))  
                                                                                                                                                 ?0:1);  
 }  
   
 void CPUCALL z80c_interrupt(REG8 vect) {  void CPUCALL z80c_interrupt(REG8 vect) {
   
         REG16   pc;          REG16   pc;
Line 136  void CPUCALL z80c_interrupt(REG8 vect) { Line 131  void CPUCALL z80c_interrupt(REG8 vect) {
                 Z80_IFF ^= (1 << IFF_HALT);                  Z80_IFF ^= (1 << IFF_HALT);
                 R_Z80PC++;                  R_Z80PC++;
         }          }
         Z80_IFF |= (1 << IFF_IRQ) | (1 << IFF_IFLAG);  
         switch(R_Z80IM) {  
                 case 0:  
                         if ((vect != 0xdd) && (vect != 0xed) && (vect != 0xfd)) {  
                                 Z80_COUNT(cycles_main[vect]);  
                                 z80c_mainop[vect]();  
                         }  
                         break;  
   
                 case 1:  
                         Z80_COUNT(11);  
                         R_Z80SP -= 2;  
                         Z80_WRMEM_W(R_Z80SP, R_Z80PC);  
                         R_Z80PC = 0x38;  
                         break;  
   
                 case 2:  
                         pc = Z80_RDMEM_W((R_Z80I << 8) + vect);  
                         R_Z80SP -= 2;  
                         Z80_WRMEM_W(R_Z80SP, R_Z80PC);  
                         R_Z80PC = pc;  
                         break;  
         }  
 }  
   
 void CPUCALL z80c_interrupt2(REG8 vect) {  
   
         REG16   pc;  
   
         if (Z80_IFF & (1 << IFF_HALT)) {  
                 Z80_IFF ^= (1 << IFF_HALT);  
                 R_Z80PC++;  
         }  
         Z80_IFF |= (1 << IFF_IFLAG);          Z80_IFF |= (1 << IFF_IFLAG);
         switch(R_Z80IM) {          switch(R_Z80IM) {
                 case 0:                  case 0:
Line 181  void CPUCALL z80c_interrupt2(REG8 vect)  Line 143  void CPUCALL z80c_interrupt2(REG8 vect) 
                 case 1:                  case 1:
                         Z80_COUNT(11);                          Z80_COUNT(11);
                         R_Z80SP -= 2;                          R_Z80SP -= 2;
                         Z80_WRMEM_W(R_Z80SP, R_Z80PC);                          mem_write16(R_Z80SP, R_Z80PC);
                         R_Z80PC = 0x38;                          R_Z80PC = 0x38;
                         break;                          break;
   
                 case 2:                  case 2:
                         pc = Z80_RDMEM_W((R_Z80I << 8) + vect);                          pc = mem_read16((R_Z80I << 8) + vect);
                         R_Z80SP -= 2;                          R_Z80SP -= 2;
                         Z80_WRMEM_W(R_Z80SP, R_Z80PC);                          mem_write16(R_Z80SP, R_Z80PC);
                         R_Z80PC = pc;                          R_Z80PC = pc;
                         break;                          break;
         }          }
Line 203  void CPUCALL z80c_nonmaskedinterrupt(voi Line 165  void CPUCALL z80c_nonmaskedinterrupt(voi
                         R_Z80PC++;                          R_Z80PC++;
                 }                  }
                 R_Z80SP -= 2;                  R_Z80SP -= 2;
                 Z80_WRMEM_W(R_Z80SP, R_Z80PC);                  mem_write16(R_Z80SP, R_Z80PC);
                 R_Z80PC = 0x66;                  R_Z80PC = 0x66;
         }          }
 }  }
Line 212  void CPUCALL z80c_execute(void) { Line 174  void CPUCALL z80c_execute(void) {
   
         UINT    op;          UINT    op;
   
         R_Z80R++;  #if !defined(DMAS_STOIC)
         GET_PC_BYTE(op);          if (!dma.working)
         Z80_COUNT(cycles_main[op]);  #else
         z80c_mainop[op]();          if (!(dma.flag & DMAF_WORKING))
   #endif
           {
                   do {
                           R_Z80R++;
                           GET_PC_BYTE(op);
                           Z80_COUNT(cycles_main[op]);
                           z80c_mainop[op]();
                   } while(CPU_REMCLOCK > 0);
           }
           else {
                   do {
                           R_Z80R++;
                           GET_PC_BYTE(op);
                           Z80_COUNT(cycles_main[op]);
                           z80c_mainop[op]();
                           z80dmap();
                   } while(CPU_REMCLOCK > 0);
           }
   }
   
   void CPUCALL z80c_step(void) {
   
           UINT    op;
   
         R_Z80R++;          R_Z80R++;
         GET_PC_BYTE(op);          GET_PC_BYTE(op);
         Z80_COUNT(cycles_main[op]);          Z80_COUNT(cycles_main[op]);
         z80c_mainop[op]();          z80c_mainop[op]();
           z80dmap();
 }  }
   

Removed from v.1.2  
changed lines
  Added in v.1.9


RetroPC.NET-CVS <cvs@retropc.net>