1 // license:BSD-3-Clause
2 // copyright-holders:Tatsuyuki Satoh
3 #ifndef MAME_INCLUDES_APPOOOH_H
4 #define MAME_INCLUDES_APPOOOH_H
5 
6 #pragma once
7 
8 #include "sound/msm5205.h"
9 #include "emupal.h"
10 #include "tilemap.h"
11 
12 class appoooh_state : public driver_device
13 {
14 public:
appoooh_state(const machine_config & mconfig,device_type type,const char * tag)15 	appoooh_state(const machine_config &mconfig, device_type type, const char *tag) :
16 		driver_device(mconfig, type, tag),
17 		m_spriteram(*this, "spriteram"),
18 		m_fg_videoram(*this, "fg_videoram"),
19 		m_fg_colorram(*this, "fg_colorram"),
20 		m_spriteram_2(*this, "spriteram_2"),
21 		m_bg_videoram(*this, "bg_videoram"),
22 		m_bg_colorram(*this, "bg_colorram"),
23 		m_decrypted_opcodes(*this, "decrypted_opcodes"),
24 		m_maincpu(*this, "maincpu"),
25 		m_gfxdecode(*this, "gfxdecode"),
26 		m_palette(*this, "palette"),
27 		m_msm(*this, "msm")
28 	{ }
29 
30 	void init_robowresb();
31 	void appoooh(machine_config &config);
32 	void robowres(machine_config &config);
33 	void robowrese(machine_config &config);
34 
35 protected:
36 	void adpcm_w(uint8_t data);
37 	void scroll_w(uint8_t data);
38 	void fg_videoram_w(offs_t offset, uint8_t data);
39 	void fg_colorram_w(offs_t offset, uint8_t data);
40 	void bg_videoram_w(offs_t offset, uint8_t data);
41 	void bg_colorram_w(offs_t offset, uint8_t data);
42 	void out_w(uint8_t data);
43 	TILE_GET_INFO_MEMBER(get_fg_tile_info);
44 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
45 	virtual void machine_start() override;
46 	virtual void machine_reset() override;
47 	virtual void video_start() override;
48 	void appoooh_palette(palette_device &palette) const;
49 	void robowres_palette(palette_device &palette) const;
50 	uint32_t screen_update_appoooh(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
51 	uint32_t screen_update_robowres(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
52 	INTERRUPT_GEN_MEMBER(vblank_irq);
53 	void appoooh_draw_sprites( bitmap_ind16 &dest_bmp, const rectangle &cliprect, gfx_element *gfx, uint8_t *sprite );
54 	void robowres_draw_sprites( bitmap_ind16 &dest_bmp, const rectangle &cliprect, gfx_element *gfx, uint8_t *sprite );
55 	DECLARE_WRITE_LINE_MEMBER(adpcm_int);
56 
57 	void appoooh_common(machine_config &config);
58 	void decrypted_opcodes_map(address_map &map);
59 	void main_map(address_map &map);
60 	void main_portmap(address_map &map);
61 
62 private:
63 	/* memory pointers */
64 	required_shared_ptr<uint8_t> m_spriteram;
65 	required_shared_ptr<uint8_t> m_fg_videoram;
66 	required_shared_ptr<uint8_t> m_fg_colorram;
67 	required_shared_ptr<uint8_t> m_spriteram_2;
68 	required_shared_ptr<uint8_t> m_bg_videoram;
69 	required_shared_ptr<uint8_t> m_bg_colorram;
70 	optional_shared_ptr<uint8_t> m_decrypted_opcodes;
71 
72 	/* video-related */
73 	tilemap_t  *m_fg_tilemap;
74 	tilemap_t  *m_bg_tilemap;
75 	int m_scroll_x;
76 	int m_priority;
77 
78 	/* sound-related */
79 	uint32_t   m_adpcm_data;
80 	uint32_t   m_adpcm_address;
81 
82 	/* devices */
83 	required_device<cpu_device> m_maincpu;
84 	required_device<gfxdecode_device> m_gfxdecode;
85 	required_device<palette_device> m_palette;
86 	required_device<msm5205_device> m_msm;
87 
88 	uint8_t m_nmi_mask;
89 };
90 
91 #endif // MAME_INCLUDES_APPOOOH_H
92