1 // license:BSD-3-Clause
2 // copyright-holders:Aaron Giles
3 /*************************************************************************
4 
5     Atari G42 hardware
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_ATARIG42_H
9 #define MAME_INCLUDES_ATARIG42_H
10 
11 #pragma once
12 
13 #include "audio/atarijsa.h"
14 #include "machine/atarigen.h"
15 #include "video/atarirle.h"
16 #include "cpu/m68000/m68000.h"
17 #include "machine/adc0808.h"
18 #include "machine/asic65.h"
19 #include "machine/timer.h"
20 #include "tilemap.h"
21 
22 class atarig42_state : public atarigen_state
23 {
24 public:
atarig42_state(const machine_config & mconfig,device_type type,const char * tag)25 	atarig42_state(const machine_config &mconfig, device_type type, const char *tag) :
26 		atarigen_state(mconfig, type, tag),
27 		m_jsa(*this, "jsa"),
28 		m_playfield_tilemap(*this, "playfield"),
29 		m_alpha_tilemap(*this, "alpha"),
30 		m_rle(*this, "rle"),
31 		m_asic65(*this, "asic65"),
32 		m_adc(*this, "adc"),
33 		m_mo_command(*this, "mo_command")
34 	{ }
35 
36 protected:
37 	virtual void machine_start() override;
38 	void video_int_ack_w(uint16_t data = 0);
39 	TIMER_DEVICE_CALLBACK_MEMBER(scanline_update);
40 	void a2d_select_w(offs_t offset, uint8_t data);
41 	uint8_t a2d_data_r(offs_t offset);
42 	void io_latch_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
43 	void mo_command_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
44 	TILE_GET_INFO_MEMBER(get_alpha_tile_info);
45 	TILE_GET_INFO_MEMBER(get_playfield_tile_info);
46 	TILEMAP_MAPPER_MEMBER(atarig42_playfield_scan);
47 	DECLARE_VIDEO_START(atarig42);
48 	uint32_t screen_update_atarig42(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
49 	void atarig42(machine_config &config);
50 	void main_map(address_map &map);
51 
52 	required_device<atari_jsa_iii_device> m_jsa;
53 
54 	required_device<tilemap_device> m_playfield_tilemap;
55 	required_device<tilemap_device> m_alpha_tilemap;
56 	required_device<atari_rle_objects_device> m_rle;
57 	required_device<asic65_device> m_asic65;
58 	optional_device<adc0808_device> m_adc;
59 
60 	uint16_t          m_playfield_base;
61 
62 	uint16_t          m_current_control;
63 	uint8_t           m_playfield_tile_bank;
64 	uint8_t           m_playfield_color_bank;
65 	uint16_t          m_playfield_xscroll;
66 	uint16_t          m_playfield_yscroll;
67 
68 	required_shared_ptr<uint16_t> m_mo_command;
69 
70 	int             m_sloop_bank;
71 	int             m_sloop_next_bank;
72 	int             m_sloop_offset;
73 	int             m_sloop_state;
74 	uint16_t *        m_sloop_base;
75 
76 	uint32_t          m_last_accesses[8];
77 };
78 
79 class atarig42_0x200_state : public atarig42_state
80 {
81 public:
82 	using atarig42_state::atarig42_state;
83 	void init_roadriot();
84 	void atarig42_0x200(machine_config &config);
85 
86 protected:
87 	uint16_t roadriot_sloop_data_r(offs_t offset);
88 	void roadriot_sloop_data_w(offs_t offset, uint16_t data);
89 	void roadriot_sloop_tweak(int offset);
90 };
91 
92 class atarig42_0x400_state : public atarig42_state
93 {
94 public:
95 	using atarig42_state::atarig42_state;
96 	void init_guardian();
97 	void atarig42_0x400(machine_config &config);
98 
99 protected:
100 	uint16_t guardians_sloop_data_r(offs_t offset);
101 	void guardians_sloop_data_w(offs_t offset, uint16_t data);
102 	void guardians_sloop_tweak(int offset);
103 };
104 
105 #endif // MAME_INCLUDES_ATARIG42_H
106