From: Wouter V. <m97...@us...> - 2001-12-30 22:38:59
|
Update of /cvsroot/openmsx/openMSX/src In directory usw-pr-cvs1:/tmp/cvs-serv21271/src Modified Files: CPU.hh RP5C01.cc RP5C01.hh Z80.cc Z80.hh Z80.ii Z80Core.hh Z80Tables.hh Log Message: Z80: DDCB FDCB timing Index: CPU.hh =================================================================== RCS file: /cvsroot/openmsx/openMSX/src/CPU.hh,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- CPU.hh 2001/12/30 16:09:30 1.14 +++ CPU.hh 2001/12/30 22:38:55 1.15 @@ -9,6 +9,9 @@ // forward declaration class CPUInterface; +typedef signed char offset; + + class CPU { #ifndef WORDS_BIGENDIAN @@ -32,7 +35,6 @@ byte R, R2; // refresh = R&127 | R2&128 }; - typedef signed char offset; public: /** Index: RP5C01.cc =================================================================== RCS file: /cvsroot/openmsx/openMSX/src/RP5C01.cc,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- RP5C01.cc 2001/12/21 10:31:35 1.11 +++ RP5C01.cc 2001/12/30 22:38:55 1.12 @@ -3,6 +3,7 @@ #include "RP5C01.hh" #include <cassert> #include <time.h> +#include <string> //TODO ALARM is not implemented (not connected on MSX) //TODO 1Hz 16Hz output not implemented (not connected on MSX) @@ -12,23 +13,22 @@ { reference = time; emuTimeBased = emuMode; - - //TODO load saved state - // if no saved state found - for (int b=0; b<4; b++) { - for (int r=0; r<13; r++) { - reg[b][r] = 0; - } - } + memset (reg, 0, sizeof(reg)); reg[ALARM_BLOCK][10] = 1; // set 24hour mode - + initializeTime(); + reset(time); +} +RP5C01::RP5C01(bool emuMode, char* data, const EmuTime &time) +{ + reference = time; + emuTimeBased = emuMode; + memcpy(reg, data, sizeof(reg)); initializeTime(); reset(time); } RP5C01::~RP5C01() { - //TODO save state } void RP5C01::reset(const EmuTime &time) Index: RP5C01.hh =================================================================== RCS file: /cvsroot/openmsx/openMSX/src/RP5C01.hh,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- RP5C01.hh 2001/12/06 13:40:29 1.10 +++ RP5C01.hh 2001/12/30 22:38:55 1.11 @@ -18,6 +18,7 @@ { public: RP5C01(bool emuMode, const EmuTime &time); + RP5C01(bool emuMode, char* data, const EmuTime &time); ~RP5C01(); void reset(const EmuTime &time); Index: Z80.cc =================================================================== RCS file: /cvsroot/openmsx/openMSX/src/Z80.cc,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- Z80.cc 2001/12/29 16:08:06 1.35 +++ Z80.cc 2001/12/30 22:38:55 1.36 @@ -227,8 +227,8 @@ void Z80::and_byte(){ M_AND(Z80_RDMEM_OPCODE()); } void Z80::bit_0_xhl() { M_BIT(0, M_RD_XHL()); currentTime++; } -void Z80::bit_0_xix() { M_BIT(0, M_RD_XIX()); currentTime++; } -void Z80::bit_0_xiy() { M_BIT(0, M_RD_XIY()); currentTime++; } +void Z80::bit_0_xix(offset n) { M_BIT(0, M_RD_XIX(n)); currentTime++; } +void Z80::bit_0_xiy(offset n) { M_BIT(0, M_RD_XIY(n)); currentTime++; } void Z80::bit_0_a() { M_BIT(0, R.AF.B.h); } void Z80::bit_0_b() { M_BIT(0, R.BC.B.h); } void Z80::bit_0_c() { M_BIT(0, R.BC.B.l); } @@ -238,8 +238,8 @@ [...3900 lines suppressed...] - R.PC.w++; + currentTime++; + offset n = Z80_RDMEM_OPCODE(); + byte opcode = Z80_RDOP(R.PC.w++); + currentTime+=2; + (this->*opcode_dd_cb[opcode])(n); } void Z80::fd_cb() { - byte opcode = Z80_RDOP_ARG((R.PC.w+1)&0xFFFF); - currentTime++; // TODO correct timing - (this->*opcode_fd_cb[opcode])(); - R.PC.w++; + currentTime++; + offset n = Z80_RDMEM_OPCODE(); + byte opcode = Z80_RDOP(R.PC.w++); + currentTime+=2; + (this->*opcode_fd_cb[opcode])(n); } void Z80::cb() { M1Cycle(); Index: Z80.hh =================================================================== RCS file: /cvsroot/openmsx/openMSX/src/Z80.hh,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- Z80.hh 2001/12/30 10:40:29 1.27 +++ Z80.hh 2001/12/30 22:38:55 1.28 @@ -28,6 +28,7 @@ class Z80; class CPUInterface; typedef void (Z80::*opcode_fn)(); +typedef void (Z80::*opcode_fn_n)(offset n); class Z80 : public CPU { public: @@ -73,8 +74,8 @@ static const byte breg_tmp2[256]; // opcode function pointers - static const opcode_fn opcode_dd_cb[256]; - static const opcode_fn opcode_fd_cb[256]; + static const opcode_fn_n opcode_dd_cb[256]; + static const opcode_fn_n opcode_fd_cb[256]; static const opcode_fn opcode_cb[256]; static const opcode_fn opcode_dd[256]; static const opcode_fn opcode_ed[256]; Index: Z80.ii =================================================================== RCS file: /cvsroot/openmsx/openMSX/src/Z80.ii,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Z80.ii 2001/12/30 11:16:10 1.7 +++ Z80.ii 2001/12/30 22:38:55 1.8 @@ -129,18 +129,28 @@ } inline word Z80::M_XIX() { - word result = (R.IX.w+(offset)Z80_RDMEM_OPCODE())&0xFFFF; + word result = R.IX.w+(offset)Z80_RDMEM_OPCODE(); currentTime += 5; return result; } inline word Z80::M_XIY() { - word result = (R.IY.w+(offset)Z80_RDMEM_OPCODE())&0xFFFF; + word result = R.IY.w+(offset)Z80_RDMEM_OPCODE(); currentTime += 5; return result; } +inline word Z80::M_XIX(offset n) { + word result = R.IX.w+n; + return result; +} +inline word Z80::M_XIY(offset n) { + word result = R.IY.w+n; + return result; +} inline byte Z80::M_RD_XHL() { return Z80_RDMEM(R.HL.w); } inline byte Z80::M_RD_XIX() { return Z80_RDMEM(M_XIX()); } inline byte Z80::M_RD_XIY() { return Z80_RDMEM(M_XIY()); } +inline byte Z80::M_RD_XIX(offset n) { return Z80_RDMEM(M_XIX(n)); } +inline byte Z80::M_RD_XIY(offset n) { return Z80_RDMEM(M_XIY(n)); } inline void Z80::M_WR_XIX(byte a) { Z80_WRMEM(M_XIX(), a); } inline void Z80::M_WR_XIY(byte a) { Z80_WRMEM(M_XIY(), a); } Index: Z80Core.hh =================================================================== RCS file: /cvsroot/openmsx/openMSX/src/Z80Core.hh,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Z80Core.hh 2001/12/11 10:35:55 1.5 +++ Z80Core.hh 2001/12/30 22:38:55 1.6 @@ -22,9 +22,13 @@ inline word Z80_RDMEM_OPCODE_WORD (); inline word M_XIX(); inline word M_XIY(); +inline word M_XIX(offset n); +inline word M_XIY(offset n); inline byte M_RD_XHL(); inline byte M_RD_XIX(); inline byte M_RD_XIY(); +inline byte M_RD_XIX(offset n); +inline byte M_RD_XIY(offset n); inline void M_WR_XIX(byte a); [...1006 lines suppressed...] -void srl_xiy_l(); +void srl_xix(offset n); +void srl_xix_a(offset n); +void srl_xix_b(offset n); +void srl_xix_c(offset n); +void srl_xix_d(offset n); +void srl_xix_e(offset n); +void srl_xix_h(offset n); +void srl_xix_l(offset n); +void srl_xiy(offset n); +void srl_xiy_a(offset n); +void srl_xiy_b(offset n); +void srl_xiy_c(offset n); +void srl_xiy_d(offset n); +void srl_xiy_e(offset n); +void srl_xiy_h(offset n); +void srl_xiy_l(offset n); void srl_a(); void srl_b(); void srl_c(); Index: Z80Tables.hh =================================================================== RCS file: /cvsroot/openmsx/openMSX/src/Z80Tables.hh,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- Z80Tables.hh 2001/12/11 20:17:31 1.10 +++ Z80Tables.hh 2001/12/30 22:38:55 1.11 @@ -20,7 +20,7 @@ /* */ /********************************************************************/ -const opcode_fn Z80::opcode_dd_cb[256] = { +const opcode_fn_n Z80::opcode_dd_cb[256] = { &Z80::rlc_xix_b ,&Z80::rlc_xix_c ,&Z80::rlc_xix_d ,&Z80::rlc_xix_e , &Z80::rlc_xix_h ,&Z80::rlc_xix_l ,&Z80::rlc_xix ,&Z80::rlc_xix_a , &Z80::rrc_xix_b ,&Z80::rrc_xix_c ,&Z80::rrc_xix_d ,&Z80::rrc_xix_e , @@ -90,7 +90,7 @@ &Z80::set_7_xix_h,&Z80::set_7_xix_l,&Z80::set_7_xix ,&Z80::set_7_xix_a, }; -const opcode_fn Z80::opcode_fd_cb[256] = { +const opcode_fn_n Z80::opcode_fd_cb[256] = { &Z80::rlc_xiy_b ,&Z80::rlc_xiy_c ,&Z80::rlc_xiy_d ,&Z80::rlc_xiy_e , &Z80::rlc_xiy_h ,&Z80::rlc_xiy_l ,&Z80::rlc_xiy ,&Z80::rlc_xiy_a , &Z80::rrc_xiy_b ,&Z80::rrc_xiy_c ,&Z80::rrc_xiy_d ,&Z80::rrc_xiy_e , |