summaryrefslogtreecommitdiffstats
path: root/src/mame/includes/docastle.h
blob: 5a07f1efc97d128a774ec280ce9db02b86029410 (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
// license:BSD-3-Clause
// copyright-holders:Brad Oliver
/***************************************************************************

  Mr. Do's Castle hardware

***************************************************************************/
#ifndef MAME_INCLUDES_DOCASTLE_H
#define MAME_INCLUDES_DOCASTLE_H

#pragma once

#include "machine/tms1024.h"
#include "video/mc6845.h"
#include "sound/msm5205.h"
#include "emupal.h"
#include "tilemap.h"

class docastle_state : public driver_device
{
public:
	docastle_state(const machine_config &mconfig, device_type type, const char *tag) :
		driver_device(mconfig, type, tag),
		m_maincpu(*this, "maincpu"),
		m_slave(*this, "slave"),
		m_cpu3(*this, "cpu3"),
		m_crtc(*this, "crtc"),
		m_msm(*this, "msm"),
		m_inp(*this, "inp%u", 1),
		m_videoram(*this, "videoram"),
		m_colorram(*this, "colorram"),
		m_spriteram(*this, "spriteram"),
		m_gfxdecode(*this, "gfxdecode"),
		m_palette(*this, "palette")
	{ }

	void dorunrun(machine_config &config);
	void idsoccer(machine_config &config);
	void docastle(machine_config &config);

protected:
	virtual void machine_start() override;
	virtual void machine_reset() override;
	virtual void video_start() override;

private:
	/* devices */
	required_device<cpu_device> m_maincpu;
	required_device<cpu_device> m_slave;
	required_device<cpu_device> m_cpu3;
	required_device<hd6845s_device> m_crtc;
	optional_device<msm5205_device> m_msm;
	required_device_array<tms1025_device, 2> m_inp;

	/* memory pointers */
	required_shared_ptr<uint8_t> m_videoram;
	required_shared_ptr<uint8_t> m_colorram;
	required_shared_ptr<uint8_t> m_spriteram;

	required_device<gfxdecode_device> m_gfxdecode;
	required_device<palette_device> m_palette;

	/* video-related */
	tilemap_t  *m_do_tilemap = nullptr;

	/* misc */
	int      m_prev_ma6 = 0;
	int      m_adpcm_pos = 0;
	int      m_adpcm_idle = 0;
	int      m_adpcm_data = 0;
	int      m_adpcm_status = 0;
	uint8_t    m_buffer0[9]{};
	uint8_t    m_buffer1[9]{};

	uint8_t docastle_shared0_r(offs_t offset);
	uint8_t docastle_shared1_r(offs_t offset);
	void docastle_shared0_w(offs_t offset, uint8_t data);
	void docastle_shared1_w(offs_t offset, uint8_t data);
	void docastle_nmitrigger_w(uint8_t data);
	void docastle_videoram_w(offs_t offset, uint8_t data);
	void docastle_colorram_w(offs_t offset, uint8_t data);
	uint8_t inputs_flipscreen_r(offs_t offset);
	void flipscreen_w(offs_t offset, uint8_t data);
	uint8_t idsoccer_adpcm_status_r();
	void idsoccer_adpcm_w(uint8_t data);
	TILE_GET_INFO_MEMBER(get_tile_info);
	void docastle_palette(palette_device &palette) const;
	DECLARE_VIDEO_START(dorunrun);
	uint32_t screen_update_docastle(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
	void video_start_common( uint32_t tile_transmask );
	void draw_sprites( screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect );
	DECLARE_WRITE_LINE_MEMBER(docastle_tint);
	DECLARE_WRITE_LINE_MEMBER(idsoccer_adpcm_int);
	void docastle_io_map(address_map &map);
	void docastle_map(address_map &map);
	void docastle_map2(address_map &map);
	void docastle_map3(address_map &map);
	void dorunrun_map(address_map &map);
	void dorunrun_map2(address_map &map);
	void idsoccer_map(address_map &map);
};

#endif // MAME_INCLUDES_DOCASTLE_H