1 // license:BSD-3-Clause
2 // copyright-holders:Stefan Jokisch
3 /*************************************************************************
4 
5     Atari Orbit hardware
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_ORBIT_H
9 #define MAME_INCLUDES_ORBIT_H
10 
11 #pragma once
12 
13 #include "machine/74259.h"
14 #include "machine/timer.h"
15 #include "sound/discrete.h"
16 #include "emupal.h"
17 #include "screen.h"
18 #include "tilemap.h"
19 
20 /* Discrete Sound Input Nodes */
21 #define ORBIT_NOTE_FREQ       NODE_01
22 #define ORBIT_ANOTE1_AMP      NODE_02
23 #define ORBIT_ANOTE2_AMP      NODE_03
24 #define ORBIT_NOISE1_AMP      NODE_04
25 #define ORBIT_NOISE2_AMP      NODE_05
26 #define ORBIT_WARNING_EN      NODE_06
27 #define ORBIT_NOISE_EN        NODE_07
28 
29 class orbit_state : public driver_device
30 {
31 public:
orbit_state(const machine_config & mconfig,device_type type,const char * tag)32 	orbit_state(const machine_config &mconfig, device_type type, const char *tag) :
33 		driver_device(mconfig, type, tag),
34 		m_playfield_ram(*this, "playfield_ram"),
35 		m_sprite_ram(*this, "sprite_ram"),
36 		m_discrete(*this, "discrete"),
37 		m_bg_tilemap(nullptr),
38 		m_flip_screen(0),
39 		m_latch(*this, "latch"),
40 		m_maincpu(*this, "maincpu"),
41 		m_gfxdecode(*this, "gfxdecode"),
42 		m_screen(*this, "screen"),
43 		m_palette(*this, "palette")
44 	{ }
45 
46 	void orbit(machine_config &config);
47 
48 protected:
49 	virtual void machine_start() override;
50 	virtual void machine_reset() override;
51 	virtual void video_start() override;
52 
53 private:
54 	DECLARE_WRITE_LINE_MEMBER(coin_lockout_w);
55 	void playfield_w(offs_t offset, uint8_t data);
56 	TILE_GET_INFO_MEMBER(get_tile_info);
57 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
58 	INTERRUPT_GEN_MEMBER(interrupt);
59 	TIMER_CALLBACK_MEMBER(irq_off);
60 	TIMER_DEVICE_CALLBACK_MEMBER(nmi_32v);
61 	void note_w(uint8_t data);
62 	void note_amp_w(uint8_t data);
63 	void noise_amp_w(uint8_t data);
64 	void noise_rst_w(uint8_t data);
65 
66 	void main_map(address_map &map);
67 
68 	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
69 	void update_misc_flags(address_space &space, uint8_t val);
70 
71 	/* memory pointers */
72 	required_shared_ptr<uint8_t> m_playfield_ram;
73 	required_shared_ptr<uint8_t> m_sprite_ram;
74 
75 	required_device<discrete_sound_device> m_discrete;
76 
77 	/* video-related */
78 	tilemap_t  *m_bg_tilemap;
79 	int        m_flip_screen;
80 	emu_timer *m_irq_off_timer;
81 
82 	/* devices */
83 	required_device<f9334_device> m_latch;
84 	required_device<cpu_device> m_maincpu;
85 	required_device<gfxdecode_device> m_gfxdecode;
86 	required_device<screen_device> m_screen;
87 	required_device<palette_device> m_palette;
88 };
89 /*----------- defined in audio/orbit.c -----------*/
90 
91 DISCRETE_SOUND_EXTERN( orbit_discrete );
92 
93 #endif // MAME_INCLUDES_ORBIT_H
94