summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/includes/witch.h
blob: 6167c05f594941bc50a08edb654844337c1a9783 (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
// license:BSD-3-Clause
// copyright-holders:Tomasz Slanina
/*

Witch / Pinball Champ '95 / Keirin Ou

*/

#ifndef MAME_INCLUDES_WITCH_H
#define MAME_INCLUDES_WITCH_H

#pragma once

#include "cpu/z80/z80.h"
#include "machine/i8255.h"
#include "machine/nvram.h"
#include "machine/ticket.h"
#include "sound/ay8910.h"
#include "sound/2203intf.h"
#include "sound/es8712.h"
#include "emupal.h"
#include "screen.h"
#include "speaker.h"
#include "tilemap.h"

#define MAIN_CLOCK        XTAL(12'000'000)
#define CPU_CLOCK         MAIN_CLOCK / 4
#define YM2203_CLOCK      MAIN_CLOCK / 4
#define AY8910_CLOCK      MAIN_CLOCK / 8
#define MSM5202_CLOCK     384_kHz_XTAL

#define HOPPER_PULSE      50          // time between hopper pulses in milliseconds (not right for attendant pay)
#define UNBANKED_SIZE 0x800


class witch_state : public driver_device
{
public:
	witch_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag)
		, m_maincpu(*this, "maincpu")
		, m_subcpu(*this, "sub")
		, m_ppi(*this, "ppi%u", 1U)
		, m_gfxdecode(*this, "gfxdecode")
		, m_gfx0_vram(*this, "gfx0_vram")
		, m_gfx0_cram(*this, "gfx0_cram")
		, m_gfx1_vram(*this, "gfx1_vram")
		, m_gfx1_cram(*this, "gfx1_cram")
		, m_sprite_ram(*this, "sprite_ram")
		, m_palette(*this, "palette")
		, m_hopper(*this, "hopper")
		, m_mainbank(*this, "mainbank")
	{ }

	void witch(machine_config &config);

	void init_witch();

	DECLARE_WRITE8_MEMBER(gfx0_vram_w);
	DECLARE_WRITE8_MEMBER(gfx0_cram_w);
	DECLARE_WRITE8_MEMBER(gfx1_vram_w);
	DECLARE_WRITE8_MEMBER(gfx1_cram_w);
	DECLARE_READ8_MEMBER(gfx1_vram_r);
	DECLARE_READ8_MEMBER(gfx1_cram_r);
	DECLARE_READ8_MEMBER(read_a000);
	DECLARE_WRITE8_MEMBER(write_a002);
	DECLARE_WRITE8_MEMBER(write_a006);
	DECLARE_WRITE8_MEMBER(main_write_a008);
	DECLARE_WRITE8_MEMBER(sub_write_a008);
	DECLARE_READ8_MEMBER(prot_read_700x);
	DECLARE_WRITE8_MEMBER(xscroll_w);
	DECLARE_WRITE8_MEMBER(yscroll_w);

protected:
	void common_map(address_map &map);

	tilemap_t *m_gfx0_tilemap;
	tilemap_t *m_gfx1_tilemap;

	required_device<cpu_device> m_maincpu;
	required_device<cpu_device> m_subcpu;
	required_device_array<i8255_device, 2> m_ppi;
	required_device<gfxdecode_device> m_gfxdecode;

	required_shared_ptr<uint8_t> m_gfx0_vram;
	required_shared_ptr<uint8_t> m_gfx0_cram;
	required_shared_ptr<uint8_t> m_gfx1_vram;
	required_shared_ptr<uint8_t> m_gfx1_cram;
	required_shared_ptr<uint8_t> m_sprite_ram;
	required_device<palette_device> m_palette;

	required_device<ticket_dispenser_device> m_hopper;

	optional_memory_bank m_mainbank;

	int m_scrollx;
	int m_scrolly;
	uint8_t m_reg_a002;
	uint8_t m_motor_active;

	TILE_GET_INFO_MEMBER(get_gfx0_tile_info);
	TILE_GET_INFO_MEMBER(get_gfx1_tile_info);
	virtual void video_start() override;
	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
	virtual void machine_reset() override;

	void witch_common_map(address_map &map);
	void witch_main_map(address_map &map);
	void witch_sub_map(address_map &map);

	void video_common_init();
	bool has_spr_rom_bank;
	uint8_t m_spr_bank;
};

class keirinou_state : public witch_state
{
public:
	keirinou_state(const machine_config &mconfig, device_type type, const char *tag)
		: witch_state(mconfig, type, tag),
		m_paletteram(*this, "paletteram")
	{ }

	void keirinou(machine_config &config);

private:
	void keirinou_common_map(address_map &map);
	void keirinou_main_map(address_map &map);
	void keirinou_sub_map(address_map &map);

	DECLARE_WRITE8_MEMBER(write_keirinou_a002);
	DECLARE_WRITE8_MEMBER(palette_w);
	TILE_GET_INFO_MEMBER(get_keirinou_gfx1_tile_info);

	virtual void video_start() override;

	uint8_t m_bg_bank;
	required_shared_ptr<uint8_t> m_paletteram;
};


#endif