1 // license:BSD-3-Clause
2 // copyright-holders:Ernesto Corvi
3 /******************************************************************************
4 
5     Data East Side Pocket hardware
6 
7 ******************************************************************************/
8 #ifndef MAME_INCLUDES_SIDEPKT_H
9 #define MAME_INCLUDES_SIDEPKT_H
10 
11 #pragma once
12 
13 #include "cpu/mcs51/mcs51.h"
14 #include "machine/gen_latch.h"
15 #include "emupal.h"
16 #include "tilemap.h"
17 
18 class sidepckt_state : public driver_device
19 {
20 public:
sidepckt_state(const machine_config & mconfig,device_type type,const char * tag)21 	sidepckt_state(const machine_config &mconfig, device_type type, const char *tag) :
22 		driver_device(mconfig, type, tag),
23 		m_maincpu(*this, "maincpu"),
24 		m_mcu(*this, "mcu"),
25 		m_audiocpu(*this, "audiocpu"),
26 		m_gfxdecode(*this, "gfxdecode"),
27 		m_palette(*this, "palette"),
28 		m_soundlatch(*this, "soundlatch"),
29 		m_videoram(*this, "videoram"),
30 		m_colorram(*this, "colorram"),
31 		m_spriteram(*this, "spriteram")
32 	{ }
33 
34 	void sidepcktb(machine_config &config);
35 	void sidepckt(machine_config &config);
36 
37 	void init_sidepckt();
38 
39 protected:
40 	virtual void machine_reset() override;
41 	virtual void video_start() override;
42 
43 private:
44 	required_device<cpu_device> m_maincpu;
45 	optional_device<i8751_device> m_mcu;
46 	required_device<cpu_device> m_audiocpu;
47 	required_device<gfxdecode_device> m_gfxdecode;
48 	required_device<palette_device> m_palette;
49 	required_device<generic_latch_8_device> m_soundlatch;
50 
51 	required_shared_ptr<uint8_t> m_videoram;
52 	required_shared_ptr<uint8_t> m_colorram;
53 	required_shared_ptr<uint8_t> m_spriteram;
54 
55 	tilemap_t *m_bg_tilemap;
56 
57 	uint8_t m_mcu_p1;
58 	uint8_t m_mcu_p2;
59 	uint8_t m_mcu_p3;
60 
61 	uint8_t m_scroll_y;
62 
63 	uint8_t mcu_r();
64 	void mcu_w(uint8_t data);
65 
66 	void mcu_p1_w(uint8_t data);
67 	uint8_t mcu_p2_r();
68 	void mcu_p3_w(uint8_t data);
69 
70 	void videoram_w(offs_t offset, uint8_t data);
71 	void colorram_w(offs_t offset, uint8_t data);
72 	uint8_t scroll_y_r();
73 	void scroll_y_w(uint8_t data);
74 
75 	TILE_GET_INFO_MEMBER(get_tile_info);
76 
77 	void sidepckt_palette(palette_device &palette) const;
78 
79 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
80 	void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
81 
82 	void sidepckt_map(address_map &map);
83 	void sidepcktb_map(address_map &map);
84 	void sound_map(address_map &map);
85 };
86 
87 #endif // MAME_INCLUDES_SIDEPKT_H
88