1 // license:BSD-3-Clause
2 // copyright-holders:Ernesto Corvi, Jarek Parchanski, Nicola Salmoria, hap
3 /*************************************************************************
4 
5     Talbot - Champion Base Ball - Exciting Soccer
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_CHAMPBAS_H
9 #define MAME_INCLUDES_CHAMPBAS_H
10 
11 #pragma once
12 
13 #include "machine/74259.h"
14 #include "machine/alpha8201.h"
15 #include "machine/timer.h"
16 #include "machine/watchdog.h"
17 #include "emupal.h"
18 #include "tilemap.h"
19 
20 
21 class champbas_state : public driver_device
22 {
23 public:
champbas_state(const machine_config & mconfig,device_type type,const char * tag)24 	champbas_state(const machine_config &mconfig, device_type type, const char *tag) :
25 		driver_device(mconfig, type, tag),
26 		m_maincpu(*this, "maincpu"),
27 		m_mainlatch(*this, "mainlatch"),
28 		m_alpha_8201(*this, "alpha_8201"),
29 		m_watchdog(*this, "watchdog"),
30 		m_gfxdecode(*this, "gfxdecode"),
31 		m_palette(*this, "palette"),
32 		m_mainram(*this, "mainram"),
33 		m_vram(*this, "vram"),
34 		m_spriteram(*this, "spriteram"),
35 		m_spriteram2(*this, "spriteram2")
36 	{
37 	}
38 
39 	DECLARE_READ_LINE_MEMBER(watchdog_bit2);
40 
41 	void init_champbas();
42 
43 	void champbas(machine_config &config);
44 	void champbb2(machine_config &config);
45 	void champbb2j(machine_config &config);
46 	void talbot(machine_config &config);
47 	void tbasebal(machine_config &config);
48 	void champbasjb(machine_config &config);
49 	void champbasj(machine_config &config);
50 	void champbasja(machine_config &config);
51 
52 protected:
53 	// handlers
54 	DECLARE_WRITE_LINE_MEMBER(irq_enable_w);
55 	uint8_t champbja_protection_r(offs_t offset);
56 
57 	DECLARE_WRITE_LINE_MEMBER(vblank_irq);
58 
59 	void tilemap_w(offs_t offset, uint8_t data);
60 	DECLARE_WRITE_LINE_MEMBER(gfxbank_w);
61 	DECLARE_WRITE_LINE_MEMBER(palette_bank_w);
62 	DECLARE_WRITE_LINE_MEMBER(flipscreen_w);
63 
64 	void champbas_palette(palette_device &palette) const;
65 	TILE_GET_INFO_MEMBER(champbas_get_bg_tile_info);
66 
67 	uint32_t screen_update_champbas(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
68 	void champbas_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
69 
70 	virtual void machine_start() override;
71 	virtual void video_start() override;
72 
73 	void champbas_map(address_map &map);
74 	void champbasj_map(address_map &map);
75 	void champbasja_map(address_map &map);
76 	void champbasjb_map(address_map &map);
77 	void champbb2_map(address_map &map);
78 	void champbb2j_map(address_map &map);
79 	void tbasebal_map(address_map &map);
80 	void champbas_sound_map(address_map &map);
81 
82 	// devices, memory pointers
83 	required_device<cpu_device> m_maincpu;
84 	required_device<ls259_device> m_mainlatch;
85 	optional_device<alpha_8201_device> m_alpha_8201;
86 	required_device<watchdog_timer_device> m_watchdog;
87 	required_device<gfxdecode_device> m_gfxdecode;
88 	required_device<palette_device> m_palette;
89 
90 	required_shared_ptr<uint8_t> m_mainram;
91 	required_shared_ptr<uint8_t> m_vram;
92 	required_shared_ptr<uint8_t> m_spriteram;
93 	optional_shared_ptr<uint8_t> m_spriteram2;
94 
95 	// internal state
96 	uint8_t m_irq_mask;
97 	tilemap_t *m_bg_tilemap;
98 	uint8_t m_gfx_bank;
99 	uint8_t m_palette_bank;
100 };
101 
102 class exctsccr_state : public champbas_state
103 {
104 public:
exctsccr_state(const machine_config & mconfig,device_type type,const char * tag)105 	exctsccr_state(const machine_config &mconfig, device_type type, const char *tag) :
106 		champbas_state(mconfig, type, tag),
107 		m_audiocpu(*this, "audiocpu")
108 	{
109 	}
110 
111 	void init_exctsccr();
112 
113 	void exctsccr(machine_config &config);
114 	void exctsccrb(machine_config &config);
115 	void exctscc2(machine_config &config);
116 
117 protected:
118 	TIMER_DEVICE_CALLBACK_MEMBER(exctsccr_sound_irq);
119 
120 	void exctsccr_palette(palette_device &palette) const;
121 	TILE_GET_INFO_MEMBER(exctsccr_get_bg_tile_info);
122 
123 	uint32_t screen_update_exctsccr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
124 
125 	void exctsccr_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
126 
127 	virtual void video_start() override;
128 
129 	void exctsccr_map(address_map &map);
130 	void exctsccrb_map(address_map &map);
131 	void exctsccr_sound_map(address_map &map);
132 	void exctsccr_sound_io_map(address_map &map);
133 	void exctscc2_sound_io_map(address_map &map);
134 
135 private:
136 	required_device<cpu_device> m_audiocpu;
137 };
138 
139 #endif // MAME_INCLUDES_CHAMPBAS_H
140