1 // license:BSD-3-Clause
2 // copyright-holders:Lee Taylor, Couriersud
3 /***************************************************************************
4 
5     IREM M-10,M-11 and M-15 based hardware
6 
7 ****************************************************************************/
8 #ifndef MAME_INCLUDES_M10_H
9 #define MAME_INCLUDES_M10_H
10 
11 #pragma once
12 
13 #include "sound/samples.h"
14 #include "machine/74123.h"
15 #include "emupal.h"
16 #include "screen.h"
17 #include "tilemap.h"
18 
19 #define IREMM10_MASTER_CLOCK        (12500000)
20 
21 #define IREMM10_CPU_CLOCK       (IREMM10_MASTER_CLOCK/16)
22 #define IREMM10_PIXEL_CLOCK     (IREMM10_MASTER_CLOCK/2)
23 #define IREMM10_HTOTAL          (360)   /* (0x100-0xd3)*8 */
24 #define IREMM10_HBSTART         (248)
25 #define IREMM10_HBEND           (8)
26 #define IREMM10_VTOTAL          (281)   /* (0x200-0xe7) */
27 #define IREMM10_VBSTART         (240)
28 #define IREMM10_VBEND           (16)
29 
30 #define IREMM15_MASTER_CLOCK    (11730000)
31 
32 #define IREMM15_CPU_CLOCK       (IREMM15_MASTER_CLOCK/10)
33 #define IREMM15_PIXEL_CLOCK     (IREMM15_MASTER_CLOCK/2)
34 #define IREMM15_HTOTAL          (372)
35 #define IREMM15_HBSTART         (256)
36 #define IREMM15_HBEND           (0)
37 #define IREMM15_VTOTAL          (262)
38 #define IREMM15_VBSTART         (240)
39 #define IREMM15_VBEND           (16)
40 
41 class m10_state : public driver_device
42 {
43 public:
m10_state(const machine_config & mconfig,device_type type,const char * tag)44 	m10_state(const machine_config &mconfig, device_type type, const char *tag) :
45 		driver_device(mconfig, type, tag),
46 		m_memory(*this, "memory"),
47 		m_rom(*this, "rom"),
48 		m_videoram(*this, "videoram"),
49 		m_colorram(*this, "colorram"),
50 		m_chargen(*this, "chargen"),
51 		m_maincpu(*this, "maincpu"),
52 		m_ic8j1(*this, "ic8j1"),
53 		m_ic8j2(*this, "ic8j2"),
54 		m_samples(*this, "samples"),
55 		m_gfxdecode(*this, "gfxdecode"),
56 		m_screen(*this, "screen"),
57 		m_palette(*this, "palette")
58 	{ }
59 
60 	void m15(machine_config &config);
61 	void headoni(machine_config &config);
62 	void m10(machine_config &config);
63 	void m11(machine_config &config);
64 
65 	void init_andromed();
66 	void init_ipminva1();
67 
68 	DECLARE_INPUT_CHANGED_MEMBER(coin_inserted);
69 
70 private:
71 	enum
72 	{
73 		TIMER_INTERRUPT
74 	};
75 
76 	/* memory pointers */
77 	required_shared_ptr<uint8_t> m_memory;
78 	required_shared_ptr<uint8_t> m_rom;
79 	required_shared_ptr<uint8_t> m_videoram;
80 	required_shared_ptr<uint8_t> m_colorram;
81 	required_shared_ptr<uint8_t> m_chargen;
82 
83 	/* video-related */
84 	tilemap_t *         m_tx_tilemap;
85 	gfx_element *       m_back_gfx;
86 
87 	/* this is currently unused, because it is needed by gfx_layout (which has no machine) */
88 	uint32_t              extyoffs[32 * 8];
89 
90 	/* video state */
91 	uint8_t               m_bottomline;
92 	uint8_t               m_flip;
93 
94 	/* misc */
95 	int                 m_last;
96 	emu_timer *m_interrupt_timer;
97 
98 	/* devices */
99 	required_device<cpu_device> m_maincpu;
100 	optional_device<ttl74123_device> m_ic8j1;
101 	optional_device<ttl74123_device> m_ic8j2;
102 	required_device<samples_device> m_samples;
103 	optional_device<gfxdecode_device> m_gfxdecode;
104 	required_device<screen_device> m_screen;
105 	required_device<palette_device> m_palette;
106 
107 	void m10_ctrl_w(uint8_t data);
108 	void m11_ctrl_w(uint8_t data);
109 	void m15_ctrl_w(uint8_t data);
110 	void m10_a500_w(uint8_t data);
111 	void m11_a100_w(uint8_t data);
112 	void m15_a100_w(uint8_t data);
113 	uint8_t m10_a700_r();
114 	uint8_t m11_a700_r();
115 	void m10_colorram_w(offs_t offset, uint8_t data);
116 	void m10_chargen_w(offs_t offset, uint8_t data);
117 	void m15_chargen_w(offs_t offset, uint8_t data);
118 	TILEMAP_MAPPER_MEMBER(tilemap_scan);
119 	TILE_GET_INFO_MEMBER(get_tile_info);
120 	DECLARE_MACHINE_START(m10);
121 	DECLARE_MACHINE_RESET(m10);
122 	DECLARE_VIDEO_START(m10);
123 	void m10_palette(palette_device &palette) const;
124 	DECLARE_VIDEO_START(m15);
125 	uint32_t screen_update_m10(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
126 	uint32_t screen_update_m15(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
127 	INTERRUPT_GEN_MEMBER(m15_interrupt);
128 	TIMER_CALLBACK_MEMBER(interrupt_callback);
129 	DECLARE_WRITE_LINE_MEMBER(ic8j1_output_changed);
130 	DECLARE_WRITE_LINE_MEMBER(ic8j2_output_changed);
131 	inline void plot_pixel_m10( bitmap_ind16 &bm, int x, int y, int col );
132 
133 	void m10_main(address_map &map);
134 	void m11_main(address_map &map);
135 	void m15_main(address_map &map);
136 
137 	virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
138 };
139 
140 #endif // MAME_INCLUDES_M10_H
141