converted z80 to c++ [smf]

This commit is contained in:
smf- 2014-01-21 05:51:49 +00:00
parent ed175d0a2e
commit a6bd80b07f
10 changed files with 2802 additions and 2756 deletions

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,11 @@
#ifndef __Z80_H__
#define __Z80_H__
#pragma push_macro("BIT")
#undef BIT
#include "z80daisy.h"
enum
{
NSC800_RSTA = INPUT_LINE_IRQ0 + 1,
@ -26,15 +31,253 @@ enum
Z80_GENPCBASE = STATE_GENPCBASE
};
class z80_device : public legacy_cpu_device
class z80_device : public cpu_device
{
public:
z80_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock);
z80_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
DECLARE_WRITE_LINE_MEMBER( irq_line );
void z80_set_cycle_tables(const UINT8 *op, const UINT8 *cb, const UINT8 *ed, const UINT8 *xy, const UINT8 *xycb, const UINT8 *ex);
protected:
z80_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock, cpu_get_info_func info);
z80_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
// device-level overrides
virtual void device_start();
virtual void device_reset();
// device_execute_interface overrides
virtual UINT32 execute_min_cycles() const { return 2; }
virtual UINT32 execute_max_cycles() const { return 16; }
virtual UINT32 execute_input_lines() const { return 4; }
virtual void execute_run();
virtual void execute_set_input(int inputnum, int state);
// device_memory_interface overrides
virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const { return (spacenum == AS_PROGRAM) ? &m_program_config : ( (spacenum == AS_IO) ? &m_io_config : NULL ); }
// device_state_interface overrides
virtual void state_import(const device_state_entry &entry);
virtual void state_export(const device_state_entry &entry);
virtual void state_string_export(const device_state_entry &entry, astring &string);
// device_disasm_interface overrides
virtual UINT32 disasm_min_opcode_bytes() const { return 4; }
virtual UINT32 disasm_max_opcode_bytes() const { return 4; }
virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
#undef PROTOTYPES
#define PROTOTYPES(prefix) \
void prefix##_00(); void prefix##_01(); void prefix##_02(); void prefix##_03(); \
void prefix##_04(); void prefix##_05(); void prefix##_06(); void prefix##_07(); \
void prefix##_08(); void prefix##_09(); void prefix##_0a(); void prefix##_0b(); \
void prefix##_0c(); void prefix##_0d(); void prefix##_0e(); void prefix##_0f(); \
void prefix##_10(); void prefix##_11(); void prefix##_12(); void prefix##_13(); \
void prefix##_14(); void prefix##_15(); void prefix##_16(); void prefix##_17(); \
void prefix##_18(); void prefix##_19(); void prefix##_1a(); void prefix##_1b(); \
void prefix##_1c(); void prefix##_1d(); void prefix##_1e(); void prefix##_1f(); \
void prefix##_20(); void prefix##_21(); void prefix##_22(); void prefix##_23(); \
void prefix##_24(); void prefix##_25(); void prefix##_26(); void prefix##_27(); \
void prefix##_28(); void prefix##_29(); void prefix##_2a(); void prefix##_2b(); \
void prefix##_2c(); void prefix##_2d(); void prefix##_2e(); void prefix##_2f(); \
void prefix##_30(); void prefix##_31(); void prefix##_32(); void prefix##_33(); \
void prefix##_34(); void prefix##_35(); void prefix##_36(); void prefix##_37(); \
void prefix##_38(); void prefix##_39(); void prefix##_3a(); void prefix##_3b(); \
void prefix##_3c(); void prefix##_3d(); void prefix##_3e(); void prefix##_3f(); \
void prefix##_40(); void prefix##_41(); void prefix##_42(); void prefix##_43(); \
void prefix##_44(); void prefix##_45(); void prefix##_46(); void prefix##_47(); \
void prefix##_48(); void prefix##_49(); void prefix##_4a(); void prefix##_4b(); \
void prefix##_4c(); void prefix##_4d(); void prefix##_4e(); void prefix##_4f(); \
void prefix##_50(); void prefix##_51(); void prefix##_52(); void prefix##_53(); \
void prefix##_54(); void prefix##_55(); void prefix##_56(); void prefix##_57(); \
void prefix##_58(); void prefix##_59(); void prefix##_5a(); void prefix##_5b(); \
void prefix##_5c(); void prefix##_5d(); void prefix##_5e(); void prefix##_5f(); \
void prefix##_60(); void prefix##_61(); void prefix##_62(); void prefix##_63(); \
void prefix##_64(); void prefix##_65(); void prefix##_66(); void prefix##_67(); \
void prefix##_68(); void prefix##_69(); void prefix##_6a(); void prefix##_6b(); \
void prefix##_6c(); void prefix##_6d(); void prefix##_6e(); void prefix##_6f(); \
void prefix##_70(); void prefix##_71(); void prefix##_72(); void prefix##_73(); \
void prefix##_74(); void prefix##_75(); void prefix##_76(); void prefix##_77(); \
void prefix##_78(); void prefix##_79(); void prefix##_7a(); void prefix##_7b(); \
void prefix##_7c(); void prefix##_7d(); void prefix##_7e(); void prefix##_7f(); \
void prefix##_80(); void prefix##_81(); void prefix##_82(); void prefix##_83(); \
void prefix##_84(); void prefix##_85(); void prefix##_86(); void prefix##_87(); \
void prefix##_88(); void prefix##_89(); void prefix##_8a(); void prefix##_8b(); \
void prefix##_8c(); void prefix##_8d(); void prefix##_8e(); void prefix##_8f(); \
void prefix##_90(); void prefix##_91(); void prefix##_92(); void prefix##_93(); \
void prefix##_94(); void prefix##_95(); void prefix##_96(); void prefix##_97(); \
void prefix##_98(); void prefix##_99(); void prefix##_9a(); void prefix##_9b(); \
void prefix##_9c(); void prefix##_9d(); void prefix##_9e(); void prefix##_9f(); \
void prefix##_a0(); void prefix##_a1(); void prefix##_a2(); void prefix##_a3(); \
void prefix##_a4(); void prefix##_a5(); void prefix##_a6(); void prefix##_a7(); \
void prefix##_a8(); void prefix##_a9(); void prefix##_aa(); void prefix##_ab(); \
void prefix##_ac(); void prefix##_ad(); void prefix##_ae(); void prefix##_af(); \
void prefix##_b0(); void prefix##_b1(); void prefix##_b2(); void prefix##_b3(); \
void prefix##_b4(); void prefix##_b5(); void prefix##_b6(); void prefix##_b7(); \
void prefix##_b8(); void prefix##_b9(); void prefix##_ba(); void prefix##_bb(); \
void prefix##_bc(); void prefix##_bd(); void prefix##_be(); void prefix##_bf(); \
void prefix##_c0(); void prefix##_c1(); void prefix##_c2(); void prefix##_c3(); \
void prefix##_c4(); void prefix##_c5(); void prefix##_c6(); void prefix##_c7(); \
void prefix##_c8(); void prefix##_c9(); void prefix##_ca(); void prefix##_cb(); \
void prefix##_cc(); void prefix##_cd(); void prefix##_ce(); void prefix##_cf(); \
void prefix##_d0(); void prefix##_d1(); void prefix##_d2(); void prefix##_d3(); \
void prefix##_d4(); void prefix##_d5(); void prefix##_d6(); void prefix##_d7(); \
void prefix##_d8(); void prefix##_d9(); void prefix##_da(); void prefix##_db(); \
void prefix##_dc(); void prefix##_dd(); void prefix##_de(); void prefix##_df(); \
void prefix##_e0(); void prefix##_e1(); void prefix##_e2(); void prefix##_e3(); \
void prefix##_e4(); void prefix##_e5(); void prefix##_e6(); void prefix##_e7(); \
void prefix##_e8(); void prefix##_e9(); void prefix##_ea(); void prefix##_eb(); \
void prefix##_ec(); void prefix##_ed(); void prefix##_ee(); void prefix##_ef(); \
void prefix##_f0(); void prefix##_f1(); void prefix##_f2(); void prefix##_f3(); \
void prefix##_f4(); void prefix##_f5(); void prefix##_f6(); void prefix##_f7(); \
void prefix##_f8(); void prefix##_f9(); void prefix##_fa(); void prefix##_fb(); \
void prefix##_fc(); void prefix##_fd(); void prefix##_fe(); void prefix##_ff();
void illegal_1();
void illegal_2();
PROTOTYPES(op);
PROTOTYPES(cb);
PROTOTYPES(dd);
PROTOTYPES(ed);
PROTOTYPES(fd);
PROTOTYPES(xycb);
void ENTER_HALT();
void LEAVE_HALT();
UINT8 IN(UINT16 port);
void OUT(UINT16 port, UINT8 value);
UINT8 RM(UINT16 addr);
void RM16(UINT16 addr, PAIR &r);
void WM(UINT16 addr, UINT8 value);
void WM16(UINT16 addr, PAIR &r);
UINT8 ROP();
UINT8 ARG();
UINT16 ARG16();
void EAX();
void EAY();
void POP(PAIR &r);
void PUSH(PAIR &r);
void JP(void);
void JP_COND(bool cond);
void JR();
void JR_COND(bool cond, UINT8 opcode);
void CALL();
void CALL_COND(bool cond, UINT8 opcode);
void RET_COND(bool cond, UINT8 opcode);
void RETN();
void RETI();
void LD_R_A();
void LD_A_R();
void LD_I_A();
void LD_A_I();
void RST(UINT16 addr);
UINT8 INC(UINT8 value);
UINT8 DEC(UINT8 value);
void RLCA();
void RRCA();
void RLA();
void RRA();
void RRD();
void RLD();
void ADD(UINT8 value);
void ADC(UINT8 value);
void SUB(UINT8 value);
void SBC(UINT8 value);
void NEG();
void DAA();
void AND(UINT8 value);
void OR(UINT8 value);
void XOR(UINT8 value);
void CP(UINT8 value);
void EX_AF();
void EX_DE_HL();
void EXX();
void EXSP(PAIR &r);
void ADD16(PAIR &dr, PAIR &sr);
void ADC16(PAIR &r);
void SBC16(PAIR &r);
UINT8 RLC(UINT8 value);
UINT8 RRC(UINT8 value);
UINT8 RL(UINT8 value);
UINT8 RR(UINT8 value);
UINT8 SLA(UINT8 value);
UINT8 SRA(UINT8 value);
UINT8 SLL(UINT8 value);
UINT8 SRL(UINT8 value);
void BIT(int bit, UINT8 value);
void BIT_HL(int bit, UINT8 value);
void BIT_XY(int bit, UINT8 value);
UINT8 RES(int bit, UINT8 value);
UINT8 SET(int bit, UINT8 value);
void LDI();
void CPI();
void INI();
void OUTI();
void LDD();
void CPD();
void IND();
void OUTD();
void LDIR();
void CPIR();
void INIR();
void OTIR();
void LDDR();
void CPDR();
void INDR();
void OTDR();
void EI();
void take_interrupt();
// address spaces
const address_space_config m_program_config;
const address_space_config m_io_config;
address_space *m_program;
address_space *m_io;
direct_read_data *m_direct;
PAIR m_prvpc;
PAIR m_pc;
PAIR m_sp;
PAIR m_af;
PAIR m_bc;
PAIR m_de;
PAIR m_hl;
PAIR m_ix;
PAIR m_iy;
PAIR m_wz;
PAIR m_af2;
PAIR m_bc2;
PAIR m_de2;
PAIR m_hl2;
UINT8 m_r;
UINT8 m_r2;
UINT8 m_iff1;
UINT8 m_iff2;
UINT8 m_halt;
UINT8 m_im;
UINT8 m_i;
UINT8 m_nmi_state; /* nmi line state */
UINT8 m_nmi_pending; /* nmi pending */
UINT8 m_irq_state; /* irq line state */
int m_wait_state; // wait line state
int m_busrq_state; // bus request line state
UINT8 m_after_ei; /* are we in the EI shadow? */
UINT8 m_after_ldair; /* same, but for LD A,I or LD A,R */
UINT32 m_ea;
device_irq_acknowledge_callback m_irq_callback;
int m_icount;
z80_daisy_chain m_daisy;
UINT8 m_rtemp;
const UINT8 * m_cc_op;
const UINT8 * m_cc_cb;
const UINT8 * m_cc_ed;
const UINT8 * m_cc_xy;
const UINT8 * m_cc_xycb;
const UINT8 * m_cc_ex;
};
extern const device_type Z80;
@ -42,15 +285,24 @@ extern const device_type Z80;
class nsc800_device : public z80_device
{
public:
nsc800_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock);
nsc800_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
protected:
// device-level overrides
virtual void device_start();
virtual void device_reset();
// device_execute_interface overrides
virtual UINT32 execute_input_lines() const { return 7; }
virtual void execute_run();
virtual void execute_set_input(int inputnum, int state);
void take_interrupt_nsc800();
UINT8 m_nsc800_irq_state[4];/* state of NSC800 restart interrupts A, B, C */
};
extern const device_type NSC800;
CPU_GET_INFO( z80 );
CPU_GET_INFO( nsc800 );
CPU_DISASSEMBLE( z80 );
void z80_set_cycle_tables(device_t *device, const UINT8 *op, const UINT8 *cb, const UINT8 *ed, const UINT8 *xy, const UINT8 *xycb, const UINT8 *ex);
#pragma pop_macro("BIT")
#endif /* __Z80_H__ */

View File

@ -364,7 +364,7 @@ void system1_state::machine_start()
membank("bank1")->configure_entry(0, memregion("maincpu")->base() + 0x8000);
membank("bank1")->set_entry(0);
z80_set_cycle_tables(m_maincpu, cc_op, cc_cb, cc_ed, cc_xy, cc_xycb, cc_ex);
m_maincpu->z80_set_cycle_tables(cc_op, cc_cb, cc_ed, cc_xy, cc_xycb, cc_ex);
m_mute_xor = 0x00;

View File

@ -1,3 +1,4 @@
#include "cpu/z80/z80.h"
#include "machine/i8255.h"
class system1_state : public driver_device
@ -123,7 +124,7 @@ public:
void bank44_custom_w(UINT8 data, UINT8 prevdata);
void bank0c_custom_w(UINT8 data, UINT8 prevdata);
void dakkochn_custom_w(UINT8 data, UINT8 prevdata);
required_device<cpu_device> m_maincpu;
required_device<z80_device> m_maincpu;
required_device<cpu_device> m_soundcpu;
optional_device<cpu_device> m_mcu;
};

View File

@ -7,6 +7,7 @@
#ifndef AMSTRAD_H_
#define AMSTRAD_H_
#include "cpu/z80/z80.h"
#include "sound/ay8910.h"
#include "machine/upd765.h"
#include "video/mc6845.h"
@ -147,7 +148,7 @@ public:
m_io_analog3(*this, "analog3"),
m_io_analog4(*this, "analog4") { }
required_device<cpu_device> m_maincpu;
required_device<z80_device> m_maincpu;
required_device<ay8910_device> m_ay;
optional_device<upd765_family_device> m_fdc; // not on a GX4000
required_device<mc6845_device> m_crtc;

View File

@ -138,7 +138,7 @@ public:
void msx_ch_reset_core ();
void msx_memory_reset ();
required_device<cpu_device> m_maincpu;
required_device<z80_device> m_maincpu;
optional_device<v9938_device> m_v9938;
optional_device<v9958_device> m_v9958;
required_device<cassette_image_device> m_cassette;

View File

@ -9,6 +9,7 @@
#ifndef SVI318_H_
#define SVI318_H_
#include "cpu/z80/z80.h"
#include "machine/i8255.h"
#include "machine/ins8250.h"
#include "machine/wd17xx.h"
@ -113,7 +114,7 @@ public:
DECLARE_DEVICE_IMAGE_LOAD_MEMBER(svi318_cart);
DECLARE_DEVICE_IMAGE_UNLOAD_MEMBER(svi318_cart);
required_device<cpu_device> m_maincpu;
required_device<z80_device> m_maincpu;
protected:
required_device<cassette_image_device> m_cassette;
required_device<dac_device> m_dac;

View File

@ -2895,7 +2895,7 @@ void amstrad_state::amstrad_common_init()
/* Using the cool code Juergen has provided, I will override
the timing tables with the values for the amstrad */
z80_set_cycle_tables(m_maincpu,
m_maincpu->z80_set_cycle_tables(
(const UINT8*)amstrad_cycle_table_op,
(const UINT8*)amstrad_cycle_table_cb,
(const UINT8*)amstrad_cycle_table_ed,

View File

@ -520,7 +520,7 @@ DRIVER_INIT_MEMBER(msx_state,msx)
msx_memory_init();
z80_set_cycle_tables( m_maincpu, cc_op, cc_cb, cc_ed, cc_xy, cc_xycb, cc_ex );
m_maincpu->z80_set_cycle_tables( cc_op, cc_cb, cc_ed, cc_xy, cc_xycb, cc_ex );
}
TIMER_DEVICE_CALLBACK_MEMBER(msx_state::msx2_interrupt)

View File

@ -510,7 +510,7 @@ static const UINT8 cc_ex[0x100] = {
DRIVER_INIT_MEMBER(svi318_state,svi318)
{
/* z80 stuff */
z80_set_cycle_tables( m_maincpu, cc_op, cc_cb, cc_ed, cc_xy, cc_xycb, cc_ex );
m_maincpu->z80_set_cycle_tables( cc_op, cc_cb, cc_ed, cc_xy, cc_xycb, cc_ex );
memset(&m_svi, 0, sizeof (m_svi) );