1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 #ifndef MAME_INCLUDES_CCLIMBER_H
4 #define MAME_INCLUDES_CCLIMBER_H
5 
6 #pragma once
7 
8 #include "machine/74259.h"
9 #include "machine/gen_latch.h"
10 #include "machine/segacrpt_device.h"
11 #include "emupal.h"
12 #include "tilemap.h"
13 
14 class cclimber_state : public driver_device
15 {
16 public:
cclimber_state(const machine_config & mconfig,device_type type,const char * tag)17 	cclimber_state(const machine_config &mconfig, device_type type, const char *tag) :
18 		driver_device(mconfig, type, tag),
19 		m_maincpu(*this, "maincpu"),
20 		m_audiocpu(*this, "audiocpu"),
21 		m_gfxdecode(*this, "gfxdecode"),
22 		m_palette(*this, "palette"),
23 		m_mainlatch(*this, "mainlatch"),
24 		m_soundlatch(*this, "soundlatch"),
25 		m_bigsprite_videoram(*this, "bigspriteram"),
26 		m_videoram(*this, "videoram"),
27 		m_column_scroll(*this, "column_scroll"),
28 		m_spriteram(*this, "spriteram"),
29 		m_bigsprite_control(*this, "bigspritectrl"),
30 		m_colorram(*this, "colorram"),
31 		m_swimmer_background_color(*this, "bgcolor"),
32 		m_toprollr_bg_videoram(*this, "bg_videoram"),
33 		m_toprollr_bg_coloram(*this, "bg_coloram"),
34 		m_decrypted_opcodes(*this, "decrypted_opcodes")
35 	{ }
36 
37 	void init_cannonb();
38 	void init_cannonb2();
39 	void init_cclimber();
40 	void init_cclimberj();
41 	void init_ckongb();
42 	void init_dking();
43 	void init_rpatrol();
44 	void init_toprollr();
45 	void init_yamato();
46 
47 	void root(machine_config &config);
48 	void bagmanf(machine_config &config);
49 	void cannonb(machine_config &config);
50 	void cclimber(machine_config &config);
51 	void cclimberx(machine_config &config);
52 	void ckongb(machine_config &config);
53 	void guzzler(machine_config &config);
54 	void rpatrol(machine_config &config);
55 	void swimmer(machine_config &config);
56 	void toprollr(machine_config &config);
57 	void yamato(machine_config &config);
58 
59 protected:
60 	virtual void machine_start() override;
61 
62 private:
63 	required_device<cpu_device> m_maincpu;
64 	optional_device<cpu_device> m_audiocpu;
65 	required_device<gfxdecode_device> m_gfxdecode;
66 	required_device<palette_device> m_palette;
67 	required_device<ls259_device> m_mainlatch;
68 	optional_device<generic_latch_8_device> m_soundlatch;
69 
70 	required_shared_ptr<uint8_t> m_bigsprite_videoram;
71 	required_shared_ptr<uint8_t> m_videoram;
72 	optional_shared_ptr<uint8_t> m_column_scroll;
73 	required_shared_ptr<uint8_t> m_spriteram;
74 	required_shared_ptr<uint8_t> m_bigsprite_control;
75 	required_shared_ptr<uint8_t> m_colorram;
76 	optional_shared_ptr<uint8_t> m_swimmer_background_color;
77 	optional_shared_ptr<uint8_t> m_toprollr_bg_videoram;
78 	optional_shared_ptr<uint8_t> m_toprollr_bg_coloram;
79 	optional_shared_ptr<uint8_t> m_decrypted_opcodes;
80 
81 	bool m_flip_x;
82 	bool m_flip_y;
83 	bool m_swimmer_side_background_enabled;
84 	bool m_swimmer_palettebank;
85 
86 	uint8_t m_yamato_p0;
87 	uint8_t m_yamato_p1;
88 	uint8_t m_toprollr_rombank;
89 	bool m_nmi_mask;
90 	tilemap_t *m_pf_tilemap;
91 	tilemap_t *m_bs_tilemap;
92 	tilemap_t *m_toproller_bg_tilemap;
93 	std::unique_ptr<uint8_t[]> m_opcodes;
94 
95 	void swimmer_sh_soundlatch_w(uint8_t data);
96 	void yamato_p0_w(uint8_t data);
97 	void yamato_p1_w(uint8_t data);
98 	uint8_t yamato_p0_r();
99 	uint8_t yamato_p1_r();
100 	void toprollr_rombank_w(int state);
101 	void nmi_mask_w(int state);
102 	uint8_t bagmanf_a000_r();
103 	void cclimber_colorram_w(offs_t offset, uint8_t data);
104 	void flip_screen_x_w(int state);
105 	void flip_screen_y_w(int state);
106 	void sidebg_enable_w(int state);
107 	void palette_bank_w(int state);
108 	void vblank_irq(int state);
109 	void bagmanf_vblank_irq(int state);
110 
111 	DECLARE_VIDEO_START(cclimber);
112 	void cclimber_palette(palette_device &palette) const;
113 	DECLARE_VIDEO_START(swimmer);
114 	void swimmer_palette(palette_device &palette) const;
115 	void yamato_palette(palette_device &palette) const;
116 	DECLARE_VIDEO_START(toprollr);
117 	void toprollr_palette(palette_device &palette) const;
118 
119 	TILE_GET_INFO_MEMBER(cclimber_get_pf_tile_info);
120 	TILE_GET_INFO_MEMBER(swimmer_get_pf_tile_info);
121 	TILE_GET_INFO_MEMBER(toprollr_get_pf_tile_info);
122 	TILE_GET_INFO_MEMBER(cclimber_get_bs_tile_info);
123 	TILE_GET_INFO_MEMBER(toprollr_get_bs_tile_info);
124 	TILE_GET_INFO_MEMBER(toproller_get_bg_tile_info);
125 
126 	uint32_t screen_update_cclimber(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
127 	uint32_t screen_update_swimmer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
128 	uint32_t screen_update_yamato(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
129 	uint32_t screen_update_toprollr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
130 	void swimmer_set_background_pen();
131 	void draw_playfield(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
132 	void cclimber_draw_bigsprite(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
133 	void toprollr_draw_bigsprite(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
134 	void cclimber_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx);
135 	void toprollr_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx);
136 	void swimmer_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfx_element *gfx);
137 	void cclimber_decode(const uint8_t convtable[8][16]);
138 
139 	void bagmanf_map(address_map &map);
140 	void cannonb_map(address_map &map);
141 	void cclimber_map(address_map &map);
142 	void cclimber_portmap(address_map &map);
143 	void decrypted_opcodes_map(address_map &map);
144 	void guzzler_map(address_map &map);
145 	void rpatrol_map(address_map &map);
146 	void rpatrol_portmap(address_map &map);
147 	void swimmer_audio_map(address_map &map);
148 	void swimmer_audio_portmap(address_map &map);
149 	void swimmer_map(address_map &map);
150 	void toprollr_decrypted_opcodes_map(address_map &map);
151 	void toprollr_map(address_map &map);
152 	void yamato_audio_map(address_map &map);
153 	void yamato_audio_portmap(address_map &map);
154 	void yamato_decrypted_opcodes_map(address_map &map);
155 	void yamato_map(address_map &map);
156 	void yamato_portmap(address_map &map);
157 };
158 
159 #endif // MAME_INCLUDES_CCLIMBER_H
160