1 // license:BSD-3-Clause
2 // copyright-holders:Ernesto Corvi
3 /*************************************************************************
4 
5     King of Boxer - Ring King
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_KINGOBOX_H
9 #define MAME_INCLUDES_KINGOBOX_H
10 
11 #pragma once
12 
13 #include "machine/gen_latch.h"
14 #include "machine/input_merger.h"
15 #include "emupal.h"
16 #include "tilemap.h"
17 
18 class kingofb_state : public driver_device
19 {
20 public:
kingofb_state(const machine_config & mconfig,device_type type,const char * tag)21 	kingofb_state(const machine_config &mconfig, device_type type, const char *tag) :
22 		driver_device(mconfig, type, tag),
23 		m_scroll_y(*this, "scroll_y"),
24 		m_videoram(*this, "videoram"),
25 		m_colorram(*this, "colorram"),
26 		m_videoram2(*this, "videoram2"),
27 		m_colorram2(*this, "colorram2"),
28 		m_spriteram(*this, "spriteram"),
29 		m_video_cpu(*this, "video"),
30 		m_sprite_cpu(*this, "sprite"),
31 		m_maincpu(*this, "maincpu"),
32 		m_audiocpu(*this, "audiocpu"),
33 		m_nmigate(*this, "nmigate"),
34 		m_gfxdecode(*this, "gfxdecode"),
35 		m_palette(*this, "palette"),
36 		m_soundlatch(*this, "soundlatch")
37 	{ }
38 
39 	void kingofb(machine_config &config);
40 	void ringking(machine_config &config);
41 
42 	void init_ringkingw();
43 	void init_ringking3();
44 
45 private:
46 	/* memory pointers */
47 	required_shared_ptr<uint8_t> m_scroll_y;
48 	required_shared_ptr<uint8_t> m_videoram;
49 	required_shared_ptr<uint8_t> m_colorram;
50 	required_shared_ptr<uint8_t> m_videoram2;
51 	required_shared_ptr<uint8_t> m_colorram2;
52 	required_shared_ptr<uint8_t> m_spriteram;
53 
54 	/* video-related */
55 	tilemap_t    *m_bg_tilemap;
56 	tilemap_t    *m_fg_tilemap;
57 	int        m_palette_bank;
58 
59 	/* devices */
60 	required_device<cpu_device> m_video_cpu;
61 	required_device<cpu_device> m_sprite_cpu;
62 	void video_interrupt_w(uint8_t data);
63 	void sprite_interrupt_w(uint8_t data);
64 	void scroll_interrupt_w(uint8_t data);
65 	void sound_command_w(uint8_t data);
66 	void kingofb_videoram_w(offs_t offset, uint8_t data);
67 	void kingofb_colorram_w(offs_t offset, uint8_t data);
68 	void kingofb_videoram2_w(offs_t offset, uint8_t data);
69 	void kingofb_colorram2_w(offs_t offset, uint8_t data);
70 	void kingofb_f800_w(uint8_t data);
71 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
72 	TILE_GET_INFO_MEMBER(get_fg_tile_info);
73 	TILE_GET_INFO_MEMBER(ringking_get_bg_tile_info);
74 	virtual void machine_start() override;
75 	virtual void machine_reset() override;
76 	DECLARE_VIDEO_START(kingofb);
77 	void kingofb_palette(palette_device &palette);
78 	DECLARE_VIDEO_START(ringking);
79 	void ringking_palette(palette_device &palette);
80 	uint32_t screen_update_kingofb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
81 	uint32_t screen_update_ringking(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
82 	INTERRUPT_GEN_MEMBER(kingofb_interrupt);
83 	void palette_init_common(palette_device &palette, const uint8_t *color_prom, void (kingofb_state::*get_rgb_data)(const uint8_t *, int, int *, int *, int *));
84 	void kingofb_get_rgb_data( const uint8_t *color_prom, int i, int *r_data, int *g_data, int *b_data );
85 	void ringking_get_rgb_data( const uint8_t *color_prom, int i, int *r_data, int *g_data, int *b_data );
86 	void kingofb_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
87 	void ringking_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
88 	required_device<cpu_device> m_maincpu;
89 	required_device<cpu_device> m_audiocpu;
90 	required_device<input_merger_device> m_nmigate;
91 	required_device<gfxdecode_device> m_gfxdecode;
92 	required_device<palette_device> m_palette;
93 	required_device<generic_latch_8_device> m_soundlatch;
94 	void kingobox_map(address_map &map);
95 	void kingobox_sound_io_map(address_map &map);
96 	void kingobox_sound_map(address_map &map);
97 	void kingobox_sprite_map(address_map &map);
98 	void kingobox_video_map(address_map &map);
99 	void ringking_map(address_map &map);
100 	void ringking_sound_io_map(address_map &map);
101 	void ringking_sprite_map(address_map &map);
102 	void ringking_video_map(address_map &map);
103 };
104 
105 #endif // MAME_INCLUDES_KINGOBOX_H
106