1 // license:BSD-3-Clause
2 // copyright-holders:Phil Stroffolino, Nicola Salmoria, Luca Elia
3 /***************************************************************************
4 
5  Lasso and similar hardware
6 
7 ***************************************************************************/
8 #ifndef MAME_INCLUDES_LASSO_H
9 #define MAME_INCLUDES_LASSO_H
10 
11 #pragma once
12 
13 #include "machine/gen_latch.h"
14 #include "sound/sn76496.h"
15 #include "emupal.h"
16 #include "tilemap.h"
17 
18 class lasso_state : public driver_device
19 {
20 public:
lasso_state(const machine_config & mconfig,device_type type,const char * tag)21 	lasso_state(const machine_config &mconfig, device_type type, const char *tag) :
22 		driver_device(mconfig, type, tag),
23 		m_videoram(*this, "videoram"),
24 		m_colorram(*this, "colorram"),
25 		m_spriteram(*this, "spriteram"),
26 		m_back_color(*this, "back_color"),
27 		m_chip_data(*this, "chip_data"),
28 		m_bitmap_ram(*this, "bitmap_ram"),
29 		m_last_colors(*this, "last_colors"),
30 		m_track_scroll(*this, "track_scroll"),
31 		m_maincpu(*this, "maincpu"),
32 		m_audiocpu(*this, "audiocpu"),
33 		m_sn_1(*this, "sn76489.1"),
34 		m_sn_2(*this, "sn76489.2"),
35 		m_gfxdecode(*this, "gfxdecode"),
36 		m_palette(*this, "palette"),
37 		m_soundlatch(*this, "soundlatch")
38 	{ }
39 
40 	void base(machine_config &config);
41 	void wwjgtin(machine_config &config);
42 	void lasso(machine_config &config);
43 	void chameleo(machine_config &config);
44 	void pinbo(machine_config &config);
45 
46 	DECLARE_INPUT_CHANGED_MEMBER(coin_inserted);
47 
48 protected:
49 	virtual void machine_start() override;
50 	virtual void machine_reset() override;
51 	virtual void video_start() override;
52 
53 private:
54 	/* memory pointers */
55 	required_shared_ptr<uint8_t> m_videoram;
56 	required_shared_ptr<uint8_t> m_colorram;
57 	required_shared_ptr<uint8_t> m_spriteram;
58 	required_shared_ptr<uint8_t> m_back_color;
59 	optional_shared_ptr<uint8_t> m_chip_data;
60 	optional_shared_ptr<uint8_t> m_bitmap_ram;    /* 0x2000 bytes for a 256 x 256 x 1 bitmap */
61 	optional_shared_ptr<uint8_t> m_last_colors;
62 	optional_shared_ptr<uint8_t> m_track_scroll;
63 
64 	/* video-related */
65 	tilemap_t  *m_bg_tilemap;
66 	tilemap_t  *m_track_tilemap;
67 	uint8_t    m_gfxbank;     /* used by lasso, chameleo, wwjgtin and pinbo */
68 	uint8_t    m_track_enable;    /* used by wwjgtin */
69 
70 	/* devices */
71 	required_device<cpu_device> m_maincpu;
72 	required_device<cpu_device> m_audiocpu;
73 	optional_device<sn76489_device> m_sn_1;
74 	optional_device<sn76489_device> m_sn_2;
75 	required_device<gfxdecode_device> m_gfxdecode;
76 	required_device<palette_device> m_palette;
77 	required_device<generic_latch_8_device> m_soundlatch;
78 
79 	void sound_command_w(uint8_t data);
80 	uint8_t sound_status_r();
81 	void sound_select_w(uint8_t data);
82 	void lasso_videoram_w(offs_t offset, uint8_t data);
83 	void lasso_colorram_w(offs_t offset, uint8_t data);
84 	void lasso_flip_screen_w(uint8_t data);
85 	void lasso_video_control_w(uint8_t data);
86 	void wwjgtin_video_control_w(uint8_t data);
87 	void pinbo_video_control_w(uint8_t data);
88 	TILE_GET_INFO_MEMBER(lasso_get_bg_tile_info);
89 	TILE_GET_INFO_MEMBER(wwjgtin_get_track_tile_info);
90 	TILE_GET_INFO_MEMBER(pinbo_get_bg_tile_info);
91 	void lasso_palette(palette_device &palette) const;
92 	DECLARE_MACHINE_START(wwjgtin);
93 	DECLARE_MACHINE_RESET(wwjgtin);
94 	DECLARE_VIDEO_START(wwjgtin);
95 	void wwjgtin_palette(palette_device &palette) const;
96 	DECLARE_VIDEO_START(pinbo);
97 	uint32_t screen_update_lasso(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
98 	uint32_t screen_update_chameleo(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
99 	uint32_t screen_update_wwjgtin(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
100 	static rgb_t get_color(int data);
101 	void wwjgtin_set_last_four_colors();
102 	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int reverse);
103 	void draw_lasso(bitmap_ind16 &bitmap, const rectangle &cliprect);
104 	void chameleo_audio_map(address_map &map);
105 	void chameleo_main_map(address_map &map);
106 	void lasso_audio_map(address_map &map);
107 	void lasso_coprocessor_map(address_map &map);
108 	void lasso_main_map(address_map &map);
109 	void pinbo_audio_io_map(address_map &map);
110 	void pinbo_audio_map(address_map &map);
111 	void pinbo_main_map(address_map &map);
112 	void wwjgtin_audio_map(address_map &map);
113 	void wwjgtin_main_map(address_map &map);
114 };
115 
116 #endif // MAME_INCLUDES_LASSO_H
117