summaryrefslogtreecommitdiffstats
path: root/src/mame/includes/ojankohs.h
blob: 1d092da76cf75c8d4c62c7b9710cef7efc3dd89c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// license:BSD-3-Clause
// copyright-holders:Takahiro Nogi, Uki
/*************************************************************************

    Ojanko High School & other Video System mahjong series

*************************************************************************/
#ifndef MAME_INCLUDES_OJANKOHS_H
#define MAME_INCLUDES_OJANKOHS_H

#pragma once

#include "sound/msm5205.h"
#include "emupal.h"
#include "screen.h"
#include "tilemap.h"

class ojankohs_state : public driver_device
{
public:
	ojankohs_state(const machine_config &mconfig, device_type type, const char *tag) :
		ojankohs_state(mconfig, type, tag, 0x1000, 0x800)
	{ }

	void ojankohs(machine_config &config);
	void ccasino(machine_config &config);
	void ojankoc(machine_config &config);
	void ojankoy(machine_config &config);

protected:
	ojankohs_state(const machine_config &mconfig, device_type type, const char *tag, uint32_t vramsize, uint32_t pramsize) :
		driver_device(mconfig, type, tag),
		m_videoram(*this, "videoram", vramsize, ENDIANNESS_LITTLE),
		m_colorram(*this, "colorram", 0x1000, ENDIANNESS_LITTLE),
		m_paletteram(*this, "paletteram", pramsize, ENDIANNESS_LITTLE),
		m_maincpu(*this, "maincpu"),
		m_msm(*this, "msm"),
		m_gfxdecode(*this, "gfxdecode"),
		m_screen(*this, "screen"),
		m_palette(*this, "palette"),
		m_coin(*this, "coin"),
		m_inputs_p1(*this, {"p1_0", "p1_1", "p1_2", "p1_3"}),
		m_inputs_p2(*this, {"p2_0", "p2_1", "p2_2", "p2_3"}),
		m_inputs_p1_extra(*this, "p1_4"),
		m_inputs_p2_extra(*this, "p2_4"),
		m_dsw1(*this, "dsw1"), m_dsw2(*this, "dsw2"),
		m_dsw3(*this, "dsw3"), m_dsw4(*this, "dsw4")
	{ }

	virtual void machine_reset() override;

private:
	/* memory pointers */
	memory_share_creator<uint8_t> m_videoram;
	memory_share_creator<uint8_t> m_colorram;
	memory_share_creator<uint8_t> m_paletteram;

	/* video-related */
	tilemap_t  *m_tilemap;
	bitmap_ind16 m_tmpbitmap;
	int       m_gfxreg;
	int       m_flipscreen;
	int       m_flipscreen_old;
	int       m_scrollx;
	int       m_scrolly;
	int       m_screen_refresh;

	/* misc */
	uint8_t   m_port_select;
	int       m_adpcm_reset;
	int       m_adpcm_data;
	int       m_vclk_left;

	/* devices */
	required_device<cpu_device> m_maincpu;
	required_device<msm5205_device> m_msm;
	optional_device<gfxdecode_device> m_gfxdecode;
	required_device<screen_device> m_screen;
	required_device<palette_device> m_palette;
	required_ioport m_coin;
	required_ioport_array<4> m_inputs_p1;
	required_ioport_array<4> m_inputs_p2;
	optional_ioport m_inputs_p1_extra;
	optional_ioport m_inputs_p2_extra;
	required_ioport m_dsw1;
	required_ioport m_dsw2;
	optional_ioport m_dsw3;
	optional_ioport m_dsw4;

	void ojankohs_rombank_w(uint8_t data);
	void ojankoy_rombank_w(uint8_t data);
	void ojankohs_msm5205_w(uint8_t data);
	void ojankoc_ctrl_w(uint8_t data);
	void port_select_w(uint8_t data);
	uint8_t keymatrix_p1_r();
	uint8_t keymatrix_p2_r();
	uint8_t ojankoc_keymatrix_p1_r();
	uint8_t ojankoc_keymatrix_p2_r();
	uint8_t ccasino_dipsw3_r();
	uint8_t ccasino_dipsw4_r();
	void ojankoy_coinctr_w(uint8_t data);
	void ccasino_coinctr_w(uint8_t data);
	void ojankohs_palette_w(offs_t offset, uint8_t data);
	void ccasino_palette_w(offs_t offset, uint8_t data);
	void ojankoc_palette_w(offs_t offset, uint8_t data);
	void ojankohs_videoram_w(offs_t offset, uint8_t data);
	void ojankohs_colorram_w(offs_t offset, uint8_t data);
	void ojankohs_gfxreg_w(uint8_t data);
	void ojankohs_flipscreen_w(uint8_t data);
	void ojankoc_videoram_w(offs_t offset, uint8_t data);
	void ojankohs_adpcm_reset_w(uint8_t data);
	uint8_t ojankohs_dipsw1_r();
	uint8_t ojankohs_dipsw2_r();
	TILE_GET_INFO_MEMBER(ojankohs_get_tile_info);
	TILE_GET_INFO_MEMBER(ojankoy_get_tile_info);
	DECLARE_MACHINE_START(ojankohs);
	DECLARE_VIDEO_START(ojankohs);
	DECLARE_MACHINE_START(ojankoy);
	DECLARE_VIDEO_START(ojankoy);
	void ojankoy_palette(palette_device &palette) const;
	DECLARE_VIDEO_START(ccasino);
	DECLARE_MACHINE_START(ojankoc);
	DECLARE_VIDEO_START(ojankoc);
	DECLARE_MACHINE_START(common);
	uint32_t screen_update_ojankohs(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
	uint32_t screen_update_ojankoc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
	void ojankoc_flipscreen(int data);
	DECLARE_WRITE_LINE_MEMBER(ojankohs_adpcm_int);

	void ccasino_io_map(address_map &map);
	void ojankoc_io_map(address_map &map);
	void ojankoc_map(address_map &map);
	void ojankohs_io_map(address_map &map);
	void ojankohs_map(address_map &map);
	void ojankoy_io_map(address_map &map);
	void ojankoy_map(address_map &map);
};

class ojankoy_state : public ojankohs_state
{
public:
	ojankoy_state(const machine_config &mconfig, device_type type, const char *tag) :
		ojankohs_state(mconfig, type, tag, 0x2000, 0x800)
	{ }
};

class ccasino_state : public ojankohs_state
{
public:
	ccasino_state(const machine_config &mconfig, device_type type, const char *tag) :
		ojankohs_state(mconfig, type, tag, 0x2000, 0x800)
	{ }
};

class ojankoc_state : public ojankohs_state
{
public:
	ojankoc_state(const machine_config &mconfig, device_type type, const char *tag) :
		ojankohs_state(mconfig, type, tag, 0x8000, 0x20)
	{ }
};

#endif // MAME_INCLUDES_OJANKOHS_H