summaryrefslogtreecommitdiffstats
path: root/src/mame/includes/gberet.h
blob: 2f79b4110069f62c451106f86c9da6241182b6af (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
// license:BSD-3-Clause
// copyright-holders:Nicola Salmoria
/***************************************************************************

    Green Beret

***************************************************************************/
#ifndef MAME_INCLUDES_GBERET_H
#define MAME_INCLUDES_GBERET_H

#pragma once

#include "machine/timer.h"
#include "sound/sn76496.h"
#include "emupal.h"
#include "tilemap.h"

class gberet_base_state : public driver_device
{
public:
	gberet_base_state(const machine_config &mconfig, device_type type, const char *tag) :
		driver_device(mconfig, type, tag),
		m_colorram(*this, "colorram"),
		m_videoram(*this, "videoram"),
		m_spriteram(*this, "spriteram"),
		m_maincpu(*this, "maincpu"),
		m_gfxdecode(*this, "gfxdecode"),
		m_palette(*this, "palette"),
		m_sn(*this, "snsnd")
	{ }

protected:
	virtual void video_start() override;

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

	// devices
	required_device<cpu_device> m_maincpu;
	required_device<gfxdecode_device> m_gfxdecode;
	required_device<palette_device> m_palette;
	required_device<sn76489a_device> m_sn;

	// video-related
	tilemap_t * m_bg_tilemap = nullptr;

	// misc
	void videoram_w(offs_t offset, uint8_t data);
	void colorram_w(offs_t offset, uint8_t data);
	TILE_GET_INFO_MEMBER(get_bg_tile_info);
	void palette(palette_device &palette) const; // TODO: move down in gberet_state once the bootleg PROMs decoding is done
};

class gberet_state : public gberet_base_state
{
public:
	gberet_state(const machine_config &mconfig, device_type type, const char *tag) :
		gberet_base_state(mconfig, type, tag),
		m_spriteram2(*this, "spriteram2"),
		m_scrollram(*this, "scrollram"),
		m_soundlatch(*this, "soundlatch")
	{ }

	void gberet(machine_config &config);

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

	void prg_map(address_map &map);

private:
	// memory pointers
	required_shared_ptr<uint8_t> m_spriteram2;
	required_shared_ptr<uint8_t> m_scrollram;
	required_shared_ptr<uint8_t> m_soundlatch;

	// video-related
	uint8_t m_spritebank = 0U;

	// misc
	uint8_t m_interrupt_mask = 0U;
	uint8_t m_interrupt_ticks = 0U;
	void coin_counter_w(uint8_t data);
	void flipscreen_w(uint8_t data);
	void sound_w(uint8_t data);
	void scroll_w(offs_t offset, uint8_t data);
	void sprite_bank_w(uint8_t data);
	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
	TIMER_DEVICE_CALLBACK_MEMBER(interrupt_tick);
	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
};

class mrgoemon_state : public gberet_state
{
public:
	mrgoemon_state(const machine_config &mconfig, device_type type, const char *tag) :
		gberet_state(mconfig, type, tag),
		m_mainbank(*this, "mainbank")
	{ }

	void mrgoemon(machine_config &config);

protected:
	virtual void machine_start() override;

private:
	// memory pointers
	required_memory_bank m_mainbank;

	void coin_counter_w(uint8_t data);
	void prg_map(address_map &map);
};

class gberetb_state : public gberet_base_state
{
public:
	gberetb_state(const machine_config &mconfig, device_type type, const char *tag) :
		gberet_base_state(mconfig, type, tag)
	{ }

	void gberetb(machine_config &config);

private:
	void flipscreen_w(uint8_t data);
	uint8_t irq_ack_r();
	void nmi_ack_w(uint8_t data);
	void scroll_w(offs_t offset, uint8_t data);
	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
	void prg_map(address_map &map);
};

#endif // MAME_INCLUDES_GBERET_H