1 // license:BSD-3-Clause
2 // copyright-holders:David Haywood
3 /*************************************************************************
4 
5     Kick Goal - Action Hollywood
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_KICKGOAL_H
9 #define MAME_INCLUDES_KICKGOAL_H
10 
11 #pragma once
12 
13 #include "cpu/pic16c5x/pic16c5x.h"
14 #include "machine/eepromser.h"
15 #include "machine/gen_latch.h"
16 #include "sound/okim6295.h"
17 #include "emupal.h"
18 #include "tilemap.h"
19 
20 class kickgoal_state : public driver_device
21 {
22 public:
kickgoal_state(const machine_config & mconfig,device_type type,const char * tag)23 	kickgoal_state(const machine_config &mconfig, device_type type, const char *tag) :
24 		driver_device(mconfig, type, tag),
25 		m_fgram(*this, "fgram"),
26 		m_bgram(*this, "bgram"),
27 		m_bg2ram(*this, "bg2ram"),
28 		m_scrram(*this, "scrram"),
29 		m_spriteram(*this, "spriteram"),
30 		m_eeprom(*this, "eeprom") ,
31 		m_maincpu(*this, "maincpu"),
32 		m_audiocpu(*this, "audiocpu"),
33 		m_oki(*this, "oki"),
34 		m_okibank(*this, "okibank"),
35 		m_gfxdecode(*this, "gfxdecode"),
36 		m_palette(*this, "palette"),
37 		m_soundlatch(*this, "soundlatch")
38 	{ }
39 
40 	void kickgoal(machine_config &config);
41 	void actionhw(machine_config &config);
42 
43 	void init_kickgoal();
44 	void init_actionhw();
45 
46 protected:
47 	virtual void machine_start() override;
48 	virtual void machine_reset() override;
49 
50 private:
51 	void fgram_w(offs_t offset, u16 data, u16 mem_mask = ~0);
52 	void bgram_w(offs_t offset, u16 data, u16 mem_mask = ~0);
53 	void bg2ram_w(offs_t offset, u16 data, u16 mem_mask = ~0);
54 	void actionhw_snd_w(offs_t offset, u16 data, u16 mem_mask = ~0);
55 
56 	void soundio_port_a_w(u8 data);
57 	u8 soundio_port_b_r();
58 	void soundio_port_b_w(u8 data);
59 	u8 soundio_port_c_r();
60 	void soundio_port_c_w(u8 data);
61 	void to_pic_w(u16 data);
62 
63 	TILE_GET_INFO_MEMBER(get_kickgoal_fg_tile_info);
64 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
65 	TILE_GET_INFO_MEMBER(get_bg2_tile_info);
66 	TILE_GET_INFO_MEMBER(get_actionhw_fg_tile_info);
67 	TILEMAP_MAPPER_MEMBER(tilemap_scan_8x8);
68 	TILEMAP_MAPPER_MEMBER(tilemap_scan_16x16);
69 	TILEMAP_MAPPER_MEMBER(tilemap_scan_32x32);
70 	DECLARE_VIDEO_START(kickgoal);
71 	DECLARE_VIDEO_START(actionhw);
72 
73 	INTERRUPT_GEN_MEMBER(kickgoal_interrupt);
74 
75 	u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
76 
77 	void program_map(address_map &map);
78 	void oki_map(address_map &map);
79 
80 	/* video-related */
81 	tilemap_t     *m_fgtm;
82 	tilemap_t     *m_bgtm;
83 	tilemap_t     *m_bg2tm;
84 
85 	/* misc */
86 	int         m_snd_new;
87 	int         m_snd_sam[4];
88 
89 	u8 m_pic_portc;
90 	u8 m_pic_portb;
91 	int m_sound_command_sent;
92 
93 	int m_fg_base;
94 
95 	int m_bg_base;
96 	int m_bg_mask;
97 
98 	int m_bg2_base;
99 	int m_bg2_mask;
100 	int m_bg2_region;
101 
102 	int m_sprbase;
103 
104 	void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
105 
106 	/* memory pointers */
107 	required_shared_ptr<u16> m_fgram;
108 	required_shared_ptr<u16> m_bgram;
109 	required_shared_ptr<u16> m_bg2ram;
110 	required_shared_ptr<u16> m_scrram;
111 	required_shared_ptr<u16> m_spriteram;
112 
113 	/* devices */
114 	required_device<eeprom_serial_93cxx_device> m_eeprom;
115 	required_device<cpu_device> m_maincpu;
116 	required_device<pic16c57_device> m_audiocpu;
117 	required_device<okim6295_device> m_oki;
118 	required_memory_bank m_okibank;
119 	required_device<gfxdecode_device> m_gfxdecode;
120 	required_device<palette_device> m_palette;
121 	required_device<generic_latch_8_device> m_soundlatch;
122 };
123 
124 #endif // MAME_INCLUDES_KICKGOAL_H
125