1 // license:BSD-3-Clause
2 // copyright-holders:Bryan McPhail, Manuel Abadia
3 /*************************************************************************
4 
5     Super Contra / Thunder Cross
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_THUNDERX_H
9 #define MAME_INCLUDES_THUNDERX_H
10 
11 #pragma once
12 
13 #include "cpu/m6809/konami.h" // for the callback and the firq irq definition
14 #include "machine/bankdev.h"
15 #include "sound/k007232.h"
16 #include "video/k051960.h"
17 #include "video/k052109.h"
18 #include "video/konami_helper.h"
19 #include "emupal.h"
20 
21 class thunderx_state : public driver_device
22 {
23 public:
thunderx_state(const machine_config & mconfig,device_type type,const char * tag)24 	thunderx_state(const machine_config &mconfig, device_type type, const char *tag) :
25 		driver_device(mconfig, type, tag),
26 		m_maincpu(*this, "maincpu"),
27 		m_audiocpu(*this, "audiocpu"),
28 		m_bank5800(*this, "bank5800"),
29 		m_k007232(*this, "k007232"),
30 		m_k052109(*this, "k052109"),
31 		m_k051960(*this, "k051960"),
32 		m_palette(*this, "palette"),
33 		m_rombank(*this, "rombank"),
34 		m_pmcram(*this, "pmcram")
35 	{ }
36 
37 	void scontra(machine_config &config);
38 	void gbusters(machine_config &config);
39 	void thunderx(machine_config &config);
40 
41 	void init_thunderx();
42 
43 protected:
44 	virtual void machine_start() override;
45 	virtual void machine_reset() override;
46 	virtual void video_start() override;
47 
48 private:
49 	/* devices */
50 	required_device<konami_cpu_device> m_maincpu;
51 	required_device<cpu_device> m_audiocpu;
52 	required_device<address_map_bank_device> m_bank5800;
53 	optional_device<k007232_device> m_k007232;
54 	required_device<k052109_device> m_k052109;
55 	required_device<k051960_device> m_k051960;
56 	required_device<palette_device> m_palette;
57 
58 	/* memory */
59 	required_memory_bank m_rombank;
60 	optional_shared_ptr<uint8_t> m_pmcram;
61 
62 	/* misc */
63 	int        m_priority;
64 	uint8_t      m_1f98_latch;
65 	emu_timer *m_thunderx_firq_timer;
66 
67 	void scontra_bankswitch_w(uint8_t data);
68 	void thunderx_videobank_w(uint8_t data);
69 	void gbusters_videobank_w(uint8_t data);
70 	uint8_t pmc_r(offs_t offset);
71 	void pmc_w(offs_t offset, uint8_t data);
72 	uint8_t _1f98_r();
73 	void scontra_1f98_w(uint8_t data);
74 	void thunderx_1f98_w(uint8_t data);
75 	void sh_irqtrigger_w(uint8_t data);
76 	uint8_t k052109_051960_r(offs_t offset);
77 	void k052109_051960_w(offs_t offset, uint8_t data);
78 	void k007232_bankswitch_w(uint8_t data);
79 	TIMER_CALLBACK_MEMBER(thunderx_firq_cb);
80 
81 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
82 	void run_collisions( int s0, int e0, int s1, int e1, int cm, int hm );
83 	void calculate_collisions(  );
84 	void volume_callback(uint8_t data);
85 	K052109_CB_MEMBER(tile_callback);
86 	K052109_CB_MEMBER(gbusters_tile_callback);
87 	K051960_CB_MEMBER(sprite_callback);
88 	void banking_callback(uint8_t data);
89 
90 	void gbusters_map(address_map &map);
91 	void scontra_bank5800_map(address_map &map);
92 	void scontra_map(address_map &map);
93 	void scontra_sound_map(address_map &map);
94 	void thunderx_bank5800_map(address_map &map);
95 	void thunderx_map(address_map &map);
96 	void thunderx_sound_map(address_map &map);
97 };
98 
99 #endif // MAME_INCLUDES_THUNDERX_H
100