1 // license:BSD-3-Clause
2 // copyright-holders:Jarek Parchanski
3 #ifndef MAME_INCLUDES_TOKI_H
4 #define MAME_INCLUDES_TOKI_H
5 
6 #pragma once
7 
8 #include "audio/seibu.h"
9 #include "machine/gen_latch.h"
10 #include "sound/msm5205.h"
11 #include "video/bufsprite.h"
12 #include "emupal.h"
13 #include "screen.h"
14 #include "tilemap.h"
15 
16 class toki_state : public driver_device
17 {
18 public:
toki_state(const machine_config & mconfig,device_type type,const char * tag)19 	toki_state(const machine_config &mconfig, device_type type, const char *tag) :
20 		driver_device(mconfig, type, tag),
21 		m_maincpu(*this, "maincpu"),
22 		m_audiocpu(*this, "audiocpu"),
23 		m_audiocpu_rom(*this, "audiocpu"),
24 		m_seibu_sound(*this, "seibu_sound"),
25 		m_msm(*this, "msm"),
26 		m_gfxdecode(*this, "gfxdecode"),
27 		m_screen(*this, "screen"),
28 		m_palette(*this, "palette"),
29 		m_soundlatch(*this, "soundlatch"),
30 		m_spriteram(*this, "spriteram"),
31 		m_background1_videoram(*this, "bg1_vram"),
32 		m_background2_videoram(*this, "bg2_vram"),
33 		m_videoram(*this, "videoram"),
34 		m_scrollram(*this, "scrollram")
35 	{ }
36 
37 	void toki(machine_config &config);
38 	void jujuba(machine_config &config);
39 	void tokib(machine_config &config);
40 
41 	void init_tokib();
42 	void init_jujuba();
43 	void init_toki();
44 
45 private:
46 	required_device<cpu_device> m_maincpu;
47 	required_device<cpu_device> m_audiocpu;
48 	required_region_ptr<u8> m_audiocpu_rom;
49 	optional_device<seibu_sound_device> m_seibu_sound;
50 	optional_device<msm5205_device> m_msm;
51 	required_device<gfxdecode_device> m_gfxdecode;
52 	required_device<screen_device> m_screen;
53 	required_device<palette_device> m_palette;
54 	optional_device<generic_latch_8_device> m_soundlatch; // tokib
55 
56 	required_device<buffered_spriteram16_device> m_spriteram;
57 	required_shared_ptr<uint16_t> m_background1_videoram;
58 	required_shared_ptr<uint16_t> m_background2_videoram;
59 	required_shared_ptr<uint16_t> m_videoram;
60 	required_shared_ptr<uint16_t> m_scrollram;
61 
62 	int m_msm5205next;
63 	int m_toggle;
64 
65 	tilemap_t *m_background_layer;
66 	tilemap_t *m_foreground_layer;
67 	tilemap_t *m_text_layer;
68 
69 	void tokib_soundcommand_w(uint16_t data);
70 	uint16_t pip_r();
71 	void toki_control_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
72 	void foreground_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
73 	void background1_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
74 	void background2_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
75 	void tokib_adpcm_control_w(uint8_t data);
76 	void tokib_adpcm_data_w(uint8_t data);
77 	DECLARE_WRITE_LINE_MEMBER(tokib_adpcm_int);
78 
79 	uint8_t jujuba_z80_data_decrypt(offs_t offset);
80 
81 	TILE_GET_INFO_MEMBER(get_text_tile_info);
82 	TILE_GET_INFO_MEMBER(get_back_tile_info);
83 	TILE_GET_INFO_MEMBER(get_fore_tile_info);
84 
85 	virtual void video_start() override;
86 
87 	uint32_t screen_update_toki(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
88 	uint32_t screen_update_tokib(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
89 	void toki_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
90 	void tokib_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
91 
92 	void jujuba_audio_map(address_map &map);
93 	void jujuba_audio_opcodes_map(address_map &map);
94 	void toki_audio_map(address_map &map);
95 	void toki_audio_opcodes_map(address_map &map);
96 	void toki_map(address_map &map);
97 	void tokib_audio_map(address_map &map);
98 	void tokib_map(address_map &map);
99 };
100 
101 #endif // MAME_INCLUDES_TOKI_H
102