1 // license:BSD-3-Clause
2 // copyright-holders:Charles MacDonald, Wilbert Pol, Angelo Salese
3 /*****************************************************************************
4  *
5  * includes/pce.h
6  *
7  * NEC PC Engine/TurboGrafx16
8  *
9  ****************************************************************************/
10 
11 #ifndef MAME_INCLUDES_PCE_H
12 #define MAME_INCLUDES_PCE_H
13 
14 #include "cdrom.h"
15 #include "cpu/h6280/h6280.h"
16 #include "bus/pce/pce_slot.h"
17 #include "machine/pce_cd.h"
18 #include "video/huc6260.h"
19 
20 #define C6280_TAG           "c6280"
21 
22 #define MAIN_CLOCK      21477270
23 
24 #define TG_16_JOY_SIG       0x00
25 #define PCE_JOY_SIG         0x40
26 #define NO_CD_SIG           0x80
27 #define CD_SIG              0x00
28 /* these might be used to indicate something, but they always seem to return 1 */
29 #define CONST_SIG           0x30
30 
31 
32 
33 class pce_state : public driver_device
34 {
35 public:
pce_state(const machine_config & mconfig,device_type type,const char * tag)36 	pce_state(const machine_config &mconfig, device_type type, const char *tag)
37 		: driver_device(mconfig, type, tag),
38 		m_maincpu(*this, "maincpu"),
39 		m_cd_ram(*this, "cd_ram"),
40 		m_user_ram(*this, "user_ram"),
41 		m_huc6260(*this, "huc6260"),
42 		m_cartslot(*this, "cartslot"),
43 		m_cd(*this, "pce_cd"),
44 		m_joy(*this, "JOY_P.%u", 0),
45 		m_joy6b(*this, "JOY6B_P.%u", 0),
46 		m_joy_type(*this, "JOY_TYPE"),
47 		m_a_card(*this, "A_CARD")
48 	{ }
49 
50 	required_device<h6280_device> m_maincpu;
51 	required_shared_ptr<uint8_t> m_cd_ram;
52 	required_shared_ptr<uint8_t> m_user_ram;
53 	optional_device<huc6260_device> m_huc6260;
54 	required_device<pce_cart_slot_device> m_cartslot;
55 	optional_device<pce_cd_device> m_cd;
56 	required_ioport_array<5> m_joy;
57 	required_ioport_array<5> m_joy6b;
58 	required_ioport m_joy_type;
59 	required_ioport m_a_card;
60 
61 	uint8_t m_io_port_options;
62 	uint8_t m_sys3_card;
63 	uint8_t m_acard;
64 	int m_joystick_port_select;
65 	int m_joystick_data_select;
66 	uint8_t m_joy_6b_packet[5];
67 	void mess_pce_joystick_w(uint8_t data);
68 	uint8_t mess_pce_joystick_r();
69 	void pce_cd_intf_w(offs_t offset, uint8_t data);
70 	uint8_t pce_cd_intf_r(offs_t offset);
71 	uint8_t pce_cd_acard_wram_r(offs_t offset);
72 	void pce_cd_acard_wram_w(offs_t offset, uint8_t data);
73 	void init_sgx();
74 	void init_tg16();
75 	void init_mess_pce();
76 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
77 	DECLARE_MACHINE_START(pce);
78 	DECLARE_MACHINE_RESET(mess_pce);
79 	void pce_common(machine_config &config);
80 	void pce(machine_config &config);
81 	void tg16(machine_config &config);
82 	void sgx(machine_config &config);
83 	void pce_io(address_map &map);
84 	void pce_mem(address_map &map);
85 	void sgx_io(address_map &map);
86 	void sgx_mem(address_map &map);
87 };
88 
89 #endif // MAME_INCLUDES_PCE_H
90