1 // license:BSD-3-Clause
2 // copyright-holders:Tomasz Slanina
3 /*************************************************************************
4 
5     Lady Frog
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_LADYFROG_H
9 #define MAME_INCLUDES_LADYFROG_H
10 
11 #pragma once
12 
13 #include "machine/gen_latch.h"
14 #include "sound/msm5232.h"
15 #include "emupal.h"
16 #include "tilemap.h"
17 
18 class ladyfrog_state : public driver_device
19 {
20 public:
ladyfrog_state(const machine_config & mconfig,device_type type,const char * tag)21 	ladyfrog_state(const machine_config &mconfig, device_type type, const char *tag) :
22 		driver_device(mconfig, type, tag),
23 		m_videoram(*this, "videoram"),
24 		m_scrlram(*this, "scrlram"),
25 		m_maincpu(*this, "maincpu"),
26 		m_audiocpu(*this, "audiocpu"),
27 		m_msm(*this, "msm"),
28 		m_gfxdecode(*this, "gfxdecode"),
29 		m_palette(*this, "palette"),
30 		m_soundlatch(*this, "soundlatch")
31 	{ }
32 
33 	void toucheme(machine_config &config);
34 	void ladyfrog(machine_config &config);
35 
36 protected:
37 	virtual void machine_start() override;
38 	virtual void machine_reset() override;
39 	virtual void video_start() override;
40 
41 private:
42 	/* memory pointers */
43 	required_shared_ptr<uint8_t> m_videoram;
44 	std::unique_ptr<uint8_t[]>    m_spriteram;
45 	required_shared_ptr<uint8_t> m_scrlram;
46 	std::vector<uint8_t> m_paletteram;
47 	std::vector<uint8_t> m_paletteram_ext;
48 
49 	/* video-related */
50 	tilemap_t    *m_bg_tilemap;
51 	int        m_tilebank;
52 	int        m_palette_bank;
53 	int        m_spritetilebase;
54 
55 	/* misc */
56 	int        m_sound_nmi_enable;
57 	int        m_pending_nmi;
58 	int        m_snd_flag;
59 	uint8_t      m_snd_data;
60 
61 	/* devices */
62 	required_device<cpu_device> m_maincpu;
63 	required_device<cpu_device> m_audiocpu;
64 	required_device<msm5232_device> m_msm;
65 	required_device<gfxdecode_device> m_gfxdecode;
66 	required_device<palette_device> m_palette;
67 	required_device<generic_latch_8_device> m_soundlatch;
68 
69 	uint8_t from_snd_r();
70 	void to_main_w(uint8_t data);
71 	void sound_cpu_reset_w(uint8_t data);
72 	void sound_command_w(uint8_t data);
73 	void nmi_disable_w(uint8_t data);
74 	void nmi_enable_w(uint8_t data);
75 	uint8_t snd_flag_r();
76 	void ladyfrog_spriteram_w(offs_t offset, uint8_t data);
77 	uint8_t ladyfrog_spriteram_r(offs_t offset);
78 	void ladyfrog_videoram_w(offs_t offset, uint8_t data);
79 	uint8_t ladyfrog_videoram_r(offs_t offset);
80 	void ladyfrog_palette_w(offs_t offset, uint8_t data);
81 	uint8_t ladyfrog_palette_r(offs_t offset);
82 	void ladyfrog_gfxctrl_w(uint8_t data);
83 	void ladyfrog_gfxctrl2_w(uint8_t data);
84 	uint8_t ladyfrog_scrlram_r(offs_t offset);
85 	void ladyfrog_scrlram_w(offs_t offset, uint8_t data);
86 	void unk_w(uint8_t data);
87 	TILE_GET_INFO_MEMBER(get_tile_info);
88 	DECLARE_VIDEO_START(toucheme);
89 	DECLARE_VIDEO_START(ladyfrog_common);
90 	uint32_t screen_update_ladyfrog(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
91 	TIMER_CALLBACK_MEMBER(nmi_callback);
92 	void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
93 	void ladyfrog_map(address_map &map);
94 	void ladyfrog_sound_map(address_map &map);
95 };
96 
97 #endif // MAME_INCLUDES_LADYFROG_H
98