1 // license:BSD-3-Clause
2 // copyright-holders:Curt Coder
3 
4 #ifndef MAME_INCLUDES_SG1000_H
5 #define MAME_INCLUDES_SG1000_H
6 
7 #include "cpu/z80/z80.h"
8 #include "formats/sf7000_dsk.h"
9 #include "imagedev/floppy.h"
10 #include "imagedev/printer.h"
11 #include "bus/centronics/ctronics.h"
12 #include "machine/i8255.h"
13 #include "machine/i8251.h"
14 #include "machine/ram.h"
15 #include "bus/sega8/sega8_slot.h"
16 #include "bus/sg1000_exp/sg1000exp.h"
17 #include "machine/upd765.h"
18 #include "sound/sn76496.h"
19 #include "video/tms9928a.h"
20 #include "crsshair.h"
21 
22 #define SCREEN_TAG      "screen"
23 #define Z80_TAG         "z80"
24 #define SN76489AN_TAG   "sn76489an"
25 #define UPD765_TAG      "upd765"
26 #define UPD8251_TAG     "upd8251"
27 #define UPD9255_TAG     "upd9255"
28 #define UPD9255_1_TAG   "upd9255_1" // "upd9255_0" is being used by sk1100 device
29 #define CENTRONICS_TAG  "centronics"
30 #define TMS9918A_TAG    "tms9918a"
31 #define RS232_TAG       "rs232"
32 #define CARTSLOT_TAG    "slot"
33 #define EXPSLOT_TAG     "sgexp"
34 
35 
36 
37 class sg1000_state : public driver_device
38 {
39 public:
sg1000_state(const machine_config & mconfig,device_type type,const char * tag)40 	sg1000_state(const machine_config &mconfig, device_type type, const char *tag)
41 		: driver_device(mconfig, type, tag),
42 			m_maincpu(*this, Z80_TAG),
43 			m_ram(*this, RAM_TAG),
44 			m_rom(*this, Z80_TAG),
45 			m_cart(*this, CARTSLOT_TAG),
46 			m_sgexpslot(*this, EXPSLOT_TAG),
47 			m_pa7(*this, "PA7"),
48 			m_pb7(*this, "PB7")
49 	{ }
50 
51 	void sg1000(machine_config &config);
52 	void omv(machine_config &config);
53 
54 	DECLARE_INPUT_CHANGED_MEMBER( trigger_nmi );
55 
56 protected:
57 	enum
58 	{
59 		TIMER_LIGHTGUN_TICK
60 	};
61 
62 	required_device<cpu_device> m_maincpu;
63 	required_device<ram_device> m_ram;
64 	required_memory_region m_rom;
65 	optional_device<sega8_cart_slot_device> m_cart;
66 	optional_device<sg1000_expansion_slot_device> m_sgexpslot;
67 	optional_ioport m_pa7;
68 	optional_ioport m_pb7;
69 
70 	virtual void machine_start() override;
71 
72 	uint8_t peripheral_r(offs_t offset);
73 	void peripheral_w(offs_t offset, uint8_t data);
74 
75 	uint8_t omv_r(offs_t offset);
76 	void omv_w(offs_t offset, uint8_t data);
77 
78 	void omv_io_map(address_map &map);
79 	void omv_map(address_map &map);
80 	void sc3000_io_map(address_map &map);
81 	void sc3000_map(address_map &map);
82 	void sg1000_io_map(address_map &map);
83 	void sg1000_map(address_map &map);
84 };
85 
86 class sc3000_state : public sg1000_state
87 {
88 public:
sc3000_state(const machine_config & mconfig,device_type type,const char * tag)89 	sc3000_state(const machine_config &mconfig, device_type type, const char *tag)
90 		: sg1000_state(mconfig, type, tag)
91 	{ }
92 
93 	void sc3000(machine_config &config);
94 
95 protected:
96 	virtual void machine_start() override;
97 };
98 
99 class sf7000_state : public sc3000_state
100 {
101 public:
sf7000_state(const machine_config & mconfig,device_type type,const char * tag)102 	sf7000_state(const machine_config &mconfig, device_type type, const char *tag)
103 		: sc3000_state(mconfig, type, tag),
104 			m_fdc(*this, UPD765_TAG),
105 			m_centronics(*this, CENTRONICS_TAG),
106 			m_floppy0(*this, UPD765_TAG ":0:3ssdd")
107 	{ }
108 
109 	void sf7000(machine_config &config);
110 
111 private:
112 	required_device<upd765a_device> m_fdc;
113 	required_device<centronics_device> m_centronics;
114 	required_device<floppy_image_device> m_floppy0;
115 
116 	virtual void machine_start() override;
117 	virtual void machine_reset() override;
118 
119 	int m_centronics_busy;
120 	DECLARE_WRITE_LINE_MEMBER( write_centronics_busy );
121 	uint8_t ppi_pa_r();
122 	void ppi_pc_w(uint8_t data);
123 
124 	DECLARE_FLOPPY_FORMATS( floppy_formats );
125 	void sf7000_io_map(address_map &map);
126 	void sf7000_map(address_map &map);
127 };
128 
129 #endif
130