1 // license:BSD-3-Clause
2 // copyright-holders:Aaron Giles
3 /***************************************************************************
4
5 atarivad.h
6
7 Atari VAD video controller device.
8
9 ***************************************************************************/
10
11 #ifndef MAME_VIDEO_ATARIVAD_H
12 #define MAME_VIDEO_ATARIVAD_H
13
14 #include "video/atarimo.h"
15 #include "tilemap.h"
16
17
18 //**************************************************************************
19 // TYPE DEFINITIONS
20 //**************************************************************************
21
22 // ======================> atari_vad_device
23
24 // device type definition
DECLARE_DEVICE_TYPE(ATARI_VAD,atari_vad_device)25 DECLARE_DEVICE_TYPE(ATARI_VAD, atari_vad_device)
26
27 class atari_vad_device : public device_t, public device_video_interface
28 {
29 public:
30 // construction/destruction
31 template <typename T>
32 atari_vad_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&screen_tag)
33 : atari_vad_device(mconfig, tag, owner, clock)
34 {
35 set_screen(std::forward<T>(screen_tag));
36 }
37 atari_vad_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
38
39 // configuration helpers
40 auto scanline_int_cb() { return m_scanline_int_cb.bind(); }
41
42 // getters
43 tilemap_device &alpha() const { return *m_alpha_tilemap; }
44 tilemap_device &playfield() const { return *m_playfield_tilemap; }
45 tilemap_device &playfield2() const { return *m_playfield2_tilemap; }
46 atari_motion_objects_device &mob() const { return *m_mob; }
47
48 // read/write handlers
49 uint16_t control_read(offs_t offset);
50 void control_write(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
51
52 // playfield/alpha tilemap helpers
53 void alpha_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
54 void playfield_upper_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
55 void playfield_latched_lsb_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
56 void playfield_latched_msb_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
57 void playfield2_latched_msb_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
58
59 protected:
60 // device-level overrides
61 virtual void device_start() override;
62 virtual void device_reset() override;
63 virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
64
65 private:
66 // timer IDs
67 enum
68 {
69 TID_SCANLINE_INT,
70 TID_TILEROW_UPDATE,
71 TID_EOF
72 };
73
74 // internal helpers
75 void internal_control_write(offs_t offset, uint16_t newword);
76 void update_pf_xscrolls();
77 void update_parameter(uint16_t newword);
78 void update_tilerow(emu_timer &timer, int scanline);
79 void eof_update(emu_timer &timer);
80
81 // configuration state
82 devcb_write_line m_scanline_int_cb;
83
84 // internal state
85 optional_device<tilemap_device> m_alpha_tilemap;
86 required_device<tilemap_device> m_playfield_tilemap;
87 optional_device<tilemap_device> m_playfield2_tilemap;
88 optional_device<atari_motion_objects_device> m_mob;
89 optional_shared_ptr<uint16_t> m_eof_data;
90
91 emu_timer * m_scanline_int_timer;
92 emu_timer * m_tilerow_update_timer;
93 emu_timer * m_eof_timer;
94
95 uint32_t m_palette_bank; // which palette bank is enabled
96 //uint32_t m_pf0_xscroll; // playfield 1 xscroll
97 uint32_t m_pf0_xscroll_raw; // playfield 1 xscroll raw value
98 uint32_t m_pf0_yscroll; // playfield 1 yscroll
99 uint32_t m_pf1_xscroll_raw; // playfield 2 xscroll raw value
100 uint32_t m_pf1_yscroll; // playfield 2 yscroll
101 uint32_t m_mo_xscroll; // sprite xscroll
102 uint32_t m_mo_yscroll; // sprite xscroll
103
104 uint16_t m_control[0x40/2]; // control data
105 };
106
107
108 #endif // MAME_VIDEO_ATARIVAD_H
109