1 // license:BSD-3-Clause
2 // copyright-holders:Chris Hardy
3 /***************************************************************************
4 
5     Track'n'Field
6 
7 ***************************************************************************/
8 #ifndef MAME_INCLUDES_TRACKFLD_H
9 #define MAME_INCLUDES_TRACKFLD_H
10 
11 #pragma once
12 
13 #include "audio/trackfld.h"
14 #include "machine/74259.h"
15 #include "sound/dac.h"
16 #include "sound/sn76496.h"
17 #include "sound/vlm5030.h"
18 
19 #include "emupal.h"
20 #include "screen.h"
21 #include "tilemap.h"
22 
23 class trackfld_state : public driver_device
24 {
25 public:
trackfld_state(const machine_config & mconfig,device_type type,const char * tag)26 	trackfld_state(const machine_config &mconfig, device_type type, const char *tag) :
27 		driver_device(mconfig, type, tag),
28 		m_spriteram2(*this, "spriteram2"),
29 		m_scroll(*this, "scroll"),
30 		m_spriteram(*this, "spriteram"),
31 		m_scroll2(*this, "scroll2"),
32 		m_videoram(*this, "videoram"),
33 		m_colorram(*this, "colorram"),
34 		m_maincpu(*this, "maincpu"),
35 		m_mainlatch(*this, "mainlatch"),
36 		m_audiocpu(*this, "audiocpu"),
37 		m_soundbrd(*this, "trackfld_audio"),
38 		m_sn(*this, "snsnd"),
39 		m_vlm(*this, "vlm"),
40 		m_dac(*this, "dac"),
41 		m_screen(*this, "screen"),
42 		m_gfxdecode(*this, "gfxdecode"),
43 		m_palette(*this, "palette")
44 	{ }
45 
46 	void reaktor(machine_config &config);
47 	void atlantol(machine_config &config);
48 	void yieartf(machine_config &config);
49 	void wizzquiz(machine_config &config);
50 	void trackfld(machine_config &config);
51 	void trackfldu(machine_config &config);
52 	void hyprolyb(machine_config &config);
53 	void mastkin(machine_config &config);
54 
55 	void init_trackfld();
56 	void init_atlantol();
57 	void init_wizzquiz();
58 	void init_mastkin();
59 	void init_trackfldnz();
60 
61 private:
62 	void questions_bank_w(uint8_t data);
63 	void trackfld_videoram_w(offs_t offset, uint8_t data);
64 	void trackfld_colorram_w(offs_t offset, uint8_t data);
65 	void atlantol_gfxbank_w(uint8_t data);
66 	uint8_t trackfld_SN76496_r();
67 	uint8_t trackfld_speech_r();
68 	void trackfld_VLM5030_control_w(uint8_t data);
konami_SN76496_latch_w(uint8_t data)69 	void konami_SN76496_latch_w(uint8_t data) { m_SN76496_latch = data; };
konami_SN76496_w(uint8_t data)70 	void konami_SN76496_w(uint8_t data) { m_sn->write(m_SN76496_latch); };
71 
72 	void hyprolyb_sound_map(address_map &map);
73 	void main_map(address_map &map);
74 	void mastkin_map(address_map &map);
75 	void reaktor_io_map(address_map &map);
76 	void reaktor_map(address_map &map);
77 	void sound_map(address_map &map);
78 	void vlm_map(address_map &map);
79 	void wizzquiz_map(address_map &map);
80 	void yieartf_map(address_map &map);
81 	void hyprolyb_adpcm_map(address_map &map);
82 
83 	/* memory pointers */
84 	required_shared_ptr<uint8_t> m_spriteram2;
85 	required_shared_ptr<uint8_t> m_scroll;
86 	required_shared_ptr<uint8_t> m_spriteram;
87 	required_shared_ptr<uint8_t> m_scroll2;
88 	required_shared_ptr<uint8_t> m_videoram;
89 	required_shared_ptr<uint8_t> m_colorram;
90 
91 	/* devices */
92 	required_device<cpu_device> m_maincpu;
93 	optional_device<ls259_device> m_mainlatch;
94 	optional_device<cpu_device> m_audiocpu;
95 	optional_device<trackfld_audio_device> m_soundbrd;
96 	optional_device<sn76496_device> m_sn;
97 	optional_device<vlm5030_device> m_vlm;
98 	required_device<dac_8bit_r2r_device> m_dac;
99 	required_device<screen_device> m_screen;
100 	required_device<gfxdecode_device> m_gfxdecode;
101 	required_device<palette_device> m_palette;
102 
103 	/* video-related */
104 	tilemap_t  *m_bg_tilemap;
105 	int      m_bg_bank;
106 	int      m_sprite_bank1;
107 	int      m_sprite_bank2;
108 	int      m_old_gfx_bank;                    // needed by atlantol
109 	int      m_sprites_gfx_banked;
110 
111 	bool     m_irq_mask;
112 	bool     m_nmi_mask;
113 
114 	uint8_t m_SN76496_latch;
115 
116 	DECLARE_WRITE_LINE_MEMBER(coin_counter_1_w);
117 	DECLARE_WRITE_LINE_MEMBER(coin_counter_2_w);
118 	DECLARE_WRITE_LINE_MEMBER(irq_mask_w);
119 	DECLARE_WRITE_LINE_MEMBER(nmi_mask_w);
120 	DECLARE_WRITE_LINE_MEMBER(flipscreen_w);
121 
122 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
123 	DECLARE_MACHINE_START(trackfld);
124 	DECLARE_MACHINE_RESET(trackfld);
125 	DECLARE_VIDEO_START(trackfld);
126 	void trackfld_palette(palette_device &palette) const;
127 	DECLARE_VIDEO_START(atlantol);
128 	uint32_t screen_update_trackfld(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
129 	DECLARE_WRITE_LINE_MEMBER(vblank_irq);
130 	DECLARE_WRITE_LINE_MEMBER(vblank_nmi);
131 	INTERRUPT_GEN_MEMBER(yieartf_timer_irq);
132 	void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
133 };
134 
135 #endif // MAME_INCLUDES_TRACKFLD_H
136