summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/includes/stfight.h
blob: 9bd052528d733c82205f1fa95c3f94b9b1d790c6 (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
// license:BSD-3-Clause
// copyright-holders:Mark McDougall
#ifndef MAME_INCLUDES_STFIGHT_H
#define MAME_INCLUDES_STFIGHT_H

#pragma once

#include "cpu/m6805/m68705.h"
#include "sound/ymopn.h"
#include "sound/msm5205.h"
#include "video/stfight_dev.h"
#include "video/airraid_dev.h"

class stfight_state : public driver_device
{
public:
	stfight_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag)
		, m_coin_mech(*this, "COIN")
		, m_maincpu(*this, "maincpu")
		, m_audiocpu(*this, "audiocpu")
		, m_mcu(*this, "mcu")
		, m_msm(*this, "msm")
		, m_ym(*this, "ym%u", 0)
		, m_main_bank(*this, "mainbank")
		, m_samples(*this, "adpcm")
		, m_decrypted_opcodes(*this, "decrypted_opcodes")
		, m_coin_state(0)
		, m_fm_data(0)
		, m_cpu_to_mcu_empty(true)
		, m_cpu_to_mcu_data(0x0f)
		, m_port_a_out(0xff)
		, m_port_c_out(0xff)
		, m_vck2(false)
		, m_adpcm_reset(true)
		, m_adpcm_data_offs(0x0000)
	{
	}

	void stfight_base(machine_config &config);
	void stfight(machine_config &config);
	void cshooter(machine_config &config);

	void init_stfight();

protected:
	enum
	{
		TIMER_STFIGHT_INTERRUPT_1
	};

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

	virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;

private:
	DECLARE_WRITE_LINE_MEMBER(stfight_adpcm_int);

	void stfight_io_w(uint8_t data);
	uint8_t stfight_coin_r();
	void stfight_coin_w(uint8_t data);
	void stfight_fm_w(uint8_t data);
	void stfight_mcu_w(uint8_t data);

	void stfight_bank_w(uint8_t data);

	uint8_t stfight_fm_r();

	INTERRUPT_GEN_MEMBER(stfight_vb_interrupt);

	// MCU specifics
	uint8_t stfight_68705_port_b_r();
	void stfight_68705_port_a_w(uint8_t data);
	void stfight_68705_port_b_w(uint8_t data);
	void stfight_68705_port_c_w(uint8_t data);

	void cpu1_map(address_map &map);
	void cpu2_map(address_map &map);
	void cshooter_cpu1_map(address_map &map);
	void decrypted_opcodes_map(address_map &map);
	void stfight_cpu1_map(address_map &map);

	required_ioport                  m_coin_mech;

	required_device<cpu_device>      m_maincpu;
	required_device<cpu_device>      m_audiocpu;
	required_device<m68705p5_device> m_mcu;
	required_device<msm5205_device>  m_msm;
	required_device_array<ym2203_device, 2> m_ym;

	required_memory_bank             m_main_bank;

	required_region_ptr<uint8_t>     m_samples;
	optional_shared_ptr<uint8_t>     m_decrypted_opcodes;

	uint8_t     m_coin_state;

	uint8_t     m_fm_data;

	bool        m_cpu_to_mcu_empty;
	uint8_t     m_cpu_to_mcu_data;
	uint8_t     m_port_a_out;
	uint8_t     m_port_c_out;

	bool        m_vck2;
	bool        m_adpcm_reset;
	uint16_t    m_adpcm_data_offs;

	emu_timer   *m_int1_timer;
};

#endif // MAME_INCLUDES_STFIGHT_H