1 // license:BSD-3-Clause
2 // copyright-holders:Brad Oliver
3 
4 /*************************************************************************
5 
6     Jack the Giant Killer
7 
8 *************************************************************************/
9 #ifndef MAME_INCLUDES_JACK_H
10 #define MAME_INCLUDES_JACK_H
11 
12 #pragma once
13 
14 #include "machine/gen_latch.h"
15 #include "emupal.h"
16 #include "tilemap.h"
17 
18 class jack_state : public driver_device
19 {
20 public:
jack_state(const machine_config & mconfig,device_type type,const char * tag)21 	jack_state(const machine_config &mconfig, device_type type, const char *tag) :
22 		driver_device(mconfig, type, tag),
23 		m_maincpu(*this, "maincpu"),
24 		m_audiocpu(*this, "audiocpu"),
25 		m_spriteram(*this, "spriteram"),
26 		m_scrollram(*this, "scrollram"),
27 		m_videoram(*this, "videoram"),
28 		m_colorram(*this, "colorram"),
29 		m_gfxdecode(*this, "gfxdecode"),
30 		m_palette(*this, "palette"),
31 		m_soundlatch(*this, "soundlatch"),
32 		m_decrypted_opcodes(*this, "decrypted_opcodes")
33 	{ }
34 
35 	void joinem(machine_config &config);
36 	void treahunt(machine_config &config);
37 	void unclepoo(machine_config &config);
38 	void striv(machine_config &config);
39 	void jack(machine_config &config);
40 
41 	void init_zzyzzyxx();
42 	void init_striv();
43 	void init_treahunt();
44 	void init_loverboy();
45 	void init_jack();
46 
47 private:
48 	/* device- and memory pointers */
49 	required_device<cpu_device> m_maincpu;
50 	required_device<cpu_device> m_audiocpu;
51 	optional_shared_ptr<uint8_t> m_spriteram;
52 	optional_shared_ptr<uint8_t> m_scrollram;
53 	required_shared_ptr<uint8_t> m_videoram;
54 	required_shared_ptr<uint8_t> m_colorram;
55 	required_device<gfxdecode_device> m_gfxdecode;
56 	required_device<palette_device> m_palette;
57 	required_device<generic_latch_8_device> m_soundlatch;
58 	optional_shared_ptr<uint8_t> m_decrypted_opcodes;
59 
60 	/* video-related */
61 	tilemap_t    *m_bg_tilemap;
62 
63 	/* misc */
64 	int m_timer_rate;
65 	uint8_t m_joinem_nmi_enable;
66 	uint8_t m_joinem_palette_bank;
67 	int m_question_address;
68 	int m_question_rom;
69 	int m_remap_address[16];
70 
71 	IRQ_CALLBACK_MEMBER(jack_sh_irq_ack);
72 	void joinem_control_w(uint8_t data);
73 	void joinem_scroll_w(offs_t offset, uint8_t data);
74 	uint8_t striv_question_r(offs_t offset);
75 	void jack_videoram_w(offs_t offset, uint8_t data);
76 	void jack_colorram_w(offs_t offset, uint8_t data);
77 	uint8_t jack_flipscreen_r(offs_t offset);
78 	void jack_flipscreen_w(offs_t offset, uint8_t data);
79 	uint8_t timer_r();
80 
81 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
82 	TILEMAP_MAPPER_MEMBER(tilemap_scan_cols_flipy);
83 	TILE_GET_INFO_MEMBER(joinem_get_bg_tile_info);
84 	DECLARE_VIDEO_START(joinem);
85 	void joinem_palette(palette_device &palette) const;
86 	DECLARE_MACHINE_START(striv);
87 	DECLARE_MACHINE_RESET(striv);
88 	DECLARE_MACHINE_START(joinem);
89 	DECLARE_MACHINE_RESET(joinem);
90 
91 	uint32_t screen_update_jack(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
92 	uint32_t screen_update_striv(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
93 	uint32_t screen_update_joinem(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
94 
95 	virtual void machine_start() override;
96 	virtual void machine_reset() override;
97 	virtual void video_start() override;
98 
99 	INTERRUPT_GEN_MEMBER(joinem_vblank_irq);
100 	void jack_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
101 	void joinem_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
102 	void treahunt_decode(  );
103 	void decrypted_opcodes_map(address_map &map);
104 	void jack_map(address_map &map);
105 	void joinem_map(address_map &map);
106 	void sound_io_map(address_map &map);
107 	void sound_map(address_map &map);
108 	void striv_map(address_map &map);
109 	void unclepoo_map(address_map &map);
110 };
111 
112 #endif // MAME_INCLUDES_JACK_H
113