summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/kaneko_toybox.h
blob: ab15e75131c224ec0bcf35b10da504d26e3acb42 (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
// license:BSD-3-Clause
// copyright-holders:David Haywood, Luca Elia, Sebastien Volpe
/* Kaneko Toybox */
#ifndef MAME_MACHINE_KANEKO_TOYBOX_H
#define MAME_MACHINE_KANEKO_TOYBOX_H

#pragma once

class kaneko_toybox_device : public device_t
{
public:
	static constexpr int GAME_NORMAL = 0;
	static constexpr int GAME_BONK = 1;

	static constexpr int TABLE_NORMAL = 0;
	static constexpr int TABLE_ALT = 1;

	kaneko_toybox_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	void set_table(int tabletype) { m_tabletype = tabletype; }
	void set_game_type(int gametype) { m_gametype = gametype; }

	DECLARE_WRITE16_MEMBER(mcu_com0_w);
	DECLARE_WRITE16_MEMBER(mcu_com1_w);
	DECLARE_WRITE16_MEMBER(mcu_com2_w);
	DECLARE_WRITE16_MEMBER(mcu_com3_w);
	DECLARE_READ16_MEMBER(mcu_status_r);

protected:
	virtual void device_start() override;
	virtual void device_reset() override;

private:
	required_shared_ptr<uint16_t> m_mcuram;
	uint16_t m_mcu_com[4];
	int m_gametype;
	int m_tabletype;

	void mcu_com_w(offs_t offset, uint16_t data, uint16_t mem_mask, int _n_);
	void decrypt_rom();
	void handle_04_subcommand(uint8_t mcu_subcmd, uint16_t *mcu_ram);
	void mcu_init();
	void mcu_run();
};


DECLARE_DEVICE_TYPE(KANEKO_TOYBOX, kaneko_toybox_device)

#define MCFG_TOYBOX_TABLE_TYPE(_type) \
	downcast<kaneko_toybox_device &>(*device).set_table(kaneko_toybox_device::TABLE_##_type);

#define MCFG_TOYBOX_GAME_TYPE(_type) \
	downcast<kaneko_toybox_device &>(*device).set_game_type(kaneko_toybox_device::GAME_##_type);

#endif // MAME_MACHINE_KANEKO_TOYBOX_H