1 // license:BSD-3-Clause
2 // copyright-holders:Takahiro Nogi, Uki
3 /*************************************************************************
4 
5     Ojanko High School & other Video System mahjong series
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_OJANKOHS_H
9 #define MAME_INCLUDES_OJANKOHS_H
10 
11 #pragma once
12 
13 #include "sound/msm5205.h"
14 #include "emupal.h"
15 #include "screen.h"
16 #include "tilemap.h"
17 
18 class ojankohs_state : public driver_device
19 {
20 public:
ojankohs_state(const machine_config & mconfig,device_type type,const char * tag)21 	ojankohs_state(const machine_config &mconfig, device_type type, const char *tag) :
22 		driver_device(mconfig, type, tag),
23 		m_videoram(*this, "videoram"),
24 		m_colorram(*this, "colorram"),
25 		m_paletteram(*this, "paletteram"),
26 		m_maincpu(*this, "maincpu"),
27 		m_msm(*this, "msm"),
28 		m_gfxdecode(*this, "gfxdecode"),
29 		m_screen(*this, "screen"),
30 		m_palette(*this, "palette"),
31 		m_coin(*this, "coin"),
32 		m_inputs_p1(*this, {"p1_0", "p1_1", "p1_2", "p1_3"}),
33 		m_inputs_p2(*this, {"p2_0", "p2_1", "p2_2", "p2_3"}),
34 		m_inputs_p1_extra(*this, "p1_4"),
35 		m_inputs_p2_extra(*this, "p2_4"),
36 		m_dsw1(*this, "dsw1"), m_dsw2(*this, "dsw2"),
37 		m_dsw3(*this, "dsw3"), m_dsw4(*this, "dsw4")
38 	{ }
39 
40 	void ojankohs(machine_config &config);
41 	void ccasino(machine_config &config);
42 	void ojankoc(machine_config &config);
43 	void ojankoy(machine_config &config);
44 
45 protected:
46 	virtual void machine_reset() override;
47 
48 private:
49 	/* memory pointers */
50 	optional_shared_ptr<uint8_t> m_videoram;
51 	optional_shared_ptr<uint8_t> m_colorram;
52 	optional_shared_ptr<uint8_t> m_paletteram;
53 
54 	/* video-related */
55 	tilemap_t  *m_tilemap;
56 	bitmap_ind16 m_tmpbitmap;
57 	int       m_gfxreg;
58 	int       m_flipscreen;
59 	int       m_flipscreen_old;
60 	int       m_scrollx;
61 	int       m_scrolly;
62 	int       m_screen_refresh;
63 
64 	/* misc */
65 	uint8_t   m_port_select;
66 	int       m_adpcm_reset;
67 	int       m_adpcm_data;
68 	int       m_vclk_left;
69 
70 	/* devices */
71 	required_device<cpu_device> m_maincpu;
72 	required_device<msm5205_device> m_msm;
73 	optional_device<gfxdecode_device> m_gfxdecode;
74 	required_device<screen_device> m_screen;
75 	required_device<palette_device> m_palette;
76 	required_ioport m_coin;
77 	required_ioport_array<4> m_inputs_p1;
78 	required_ioport_array<4> m_inputs_p2;
79 	optional_ioport m_inputs_p1_extra;
80 	optional_ioport m_inputs_p2_extra;
81 	required_ioport m_dsw1;
82 	required_ioport m_dsw2;
83 	optional_ioport m_dsw3;
84 	optional_ioport m_dsw4;
85 
86 	void ojankohs_rombank_w(uint8_t data);
87 	void ojankoy_rombank_w(uint8_t data);
88 	void ojankohs_msm5205_w(uint8_t data);
89 	void ojankoc_ctrl_w(uint8_t data);
90 	void port_select_w(uint8_t data);
91 	uint8_t keymatrix_p1_r();
92 	uint8_t keymatrix_p2_r();
93 	uint8_t ojankoc_keymatrix_p1_r();
94 	uint8_t ojankoc_keymatrix_p2_r();
95 	uint8_t ccasino_dipsw3_r();
96 	uint8_t ccasino_dipsw4_r();
97 	void ojankoy_coinctr_w(uint8_t data);
98 	void ccasino_coinctr_w(uint8_t data);
99 	void ojankohs_palette_w(offs_t offset, uint8_t data);
100 	void ccasino_palette_w(offs_t offset, uint8_t data);
101 	void ojankoc_palette_w(offs_t offset, uint8_t data);
102 	void ojankohs_videoram_w(offs_t offset, uint8_t data);
103 	void ojankohs_colorram_w(offs_t offset, uint8_t data);
104 	void ojankohs_gfxreg_w(uint8_t data);
105 	void ojankohs_flipscreen_w(uint8_t data);
106 	void ojankoc_videoram_w(offs_t offset, uint8_t data);
107 	void ojankohs_adpcm_reset_w(uint8_t data);
108 	uint8_t ojankohs_dipsw1_r();
109 	uint8_t ojankohs_dipsw2_r();
110 	TILE_GET_INFO_MEMBER(ojankohs_get_tile_info);
111 	TILE_GET_INFO_MEMBER(ojankoy_get_tile_info);
112 	DECLARE_MACHINE_START(ojankohs);
113 	DECLARE_VIDEO_START(ojankohs);
114 	DECLARE_MACHINE_START(ojankoy);
115 	DECLARE_VIDEO_START(ojankoy);
116 	void ojankoy_palette(palette_device &palette) const;
117 	DECLARE_VIDEO_START(ccasino);
118 	DECLARE_MACHINE_START(ojankoc);
119 	DECLARE_VIDEO_START(ojankoc);
120 	DECLARE_MACHINE_START(common);
121 	uint32_t screen_update_ojankohs(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
122 	uint32_t screen_update_ojankoc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
123 	void ojankoc_flipscreen(int data);
124 	DECLARE_WRITE_LINE_MEMBER(ojankohs_adpcm_int);
125 
126 	void ccasino_io_map(address_map &map);
127 	void ojankoc_io_map(address_map &map);
128 	void ojankoc_map(address_map &map);
129 	void ojankohs_io_map(address_map &map);
130 	void ojankohs_map(address_map &map);
131 	void ojankoy_io_map(address_map &map);
132 	void ojankoy_map(address_map &map);
133 };
134 
135 #endif // MAME_INCLUDES_OJANKOHS_H
136