1 // license:BSD-3-Clause
2 // copyright-holders:Manuel Abadia
3 /***************************************************************************
4 
5     Gaelco game hardware from 1991-1996
6 
7 ***************************************************************************/
8 
9 #include "machine/gen_latch.h"
10 #include "machine/74259.h"
11 #include "emupal.h"
12 #include "tilemap.h"
13 
14 class gaelco_state : public driver_device
15 {
16 public:
gaelco_state(const machine_config & mconfig,device_type type,const char * tag)17 	gaelco_state(const machine_config &mconfig, device_type type, const char *tag) :
18 		driver_device(mconfig, type, tag),
19 		m_maincpu(*this, "maincpu"),
20 		m_gfxdecode(*this, "gfxdecode"),
21 		m_palette(*this, "palette"),
22 		m_audiocpu(*this, "audiocpu"),
23 		m_soundlatch(*this, "soundlatch"),
24 		m_outlatch(*this, "outlatch"),
25 		m_okibank(*this, "okibank"),
26 		m_videoram(*this, "videoram"),
27 		m_vregs(*this, "vregs"),
28 		m_spriteram(*this, "spriteram"),
29 		m_screenram(*this, "screenram") { }
30 
31 	void bigkarnk(machine_config &config);
32 	void thoop(machine_config &config);
33 	void maniacsq(machine_config &config);
34 	void squash(machine_config &config);
35 
36 private:
37 	/* devices */
38 	required_device<cpu_device> m_maincpu;
39 	required_device<gfxdecode_device> m_gfxdecode;
40 	required_device<palette_device> m_palette;
41 	optional_device<cpu_device> m_audiocpu;
42 	optional_device<generic_latch_8_device> m_soundlatch;
43 	optional_device<ls259_device> m_outlatch;
44 	optional_memory_bank m_okibank;
45 
46 	/* memory pointers */
47 	required_shared_ptr<uint16_t> m_videoram;
48 	required_shared_ptr<uint16_t> m_vregs;
49 	required_shared_ptr<uint16_t> m_spriteram;
50 	optional_shared_ptr<uint16_t> m_screenram;
51 
52 	/* video-related */
53 	tilemap_t      *m_tilemap[2];
54 
55 	DECLARE_WRITE_LINE_MEMBER(coin1_lockout_w);
56 	DECLARE_WRITE_LINE_MEMBER(coin2_lockout_w);
57 	DECLARE_WRITE_LINE_MEMBER(coin1_counter_w);
58 	DECLARE_WRITE_LINE_MEMBER(coin2_counter_w);
59 	void oki_bankswitch_w(uint8_t data);
60 	void vram_encrypted_w(address_space &space, offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
61 	void encrypted_w(address_space &space, offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
62 	void thoop_vram_encrypted_w(address_space &space, offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
63 	void thoop_encrypted_w(address_space &space, offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
64 	void vram_w(offs_t offset, u16 data, u16 mem_mask);
65 
66 	template<int Layer> TILE_GET_INFO_MEMBER(get_tile_info);
67 
68 	virtual void machine_start() override;
69 	DECLARE_VIDEO_START(bigkarnk);
70 	DECLARE_VIDEO_START(maniacsq);
71 
72 	uint32_t screen_update_bigkarnk(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
73 	uint32_t screen_update_maniacsq(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
74 	void draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect );
75 
76 	void bigkarnk_map(address_map &map);
77 	void bigkarnk_snd_map(address_map &map);
78 	void maniacsq_map(address_map &map);
79 	void oki_map(address_map &map);
80 	void squash_map(address_map &map);
81 	void thoop_map(address_map &map);
82 };
83