1 // license:BSD-3-Clause
2 // copyright-holders:Mike Balfour, Aaron Giles
3 /*************************************************************************
4 
5     Atari Cloud 9 (prototype) hardware
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_CLOUD9_H
9 #define MAME_INCLUDES_CLOUD9_H
10 
11 #pragma once
12 
13 #include "cpu/m6502/m6502.h"
14 #include "machine/74259.h"
15 #include "machine/x2212.h"
16 #include "emupal.h"
17 #include "screen.h"
18 
19 class cloud9_state : public driver_device
20 {
21 public:
cloud9_state(const machine_config & mconfig,device_type type,const char * tag)22 	cloud9_state(const machine_config &mconfig, device_type type, const char *tag) :
23 		driver_device(mconfig, type, tag),
24 		m_maincpu(*this, "maincpu"),
25 		m_nvram(*this, "nvram") ,
26 		m_spriteram(*this, "spriteram"),
27 		m_paletteram(*this, "paletteram"),
28 		m_gfxdecode(*this, "gfxdecode"),
29 		m_screen(*this, "screen"),
30 		m_palette(*this, "palette"),
31 		m_videolatch(*this, "videolatch")
32 	{ }
33 
34 	DECLARE_READ_LINE_MEMBER(vblank_r);
35 	void cloud9(machine_config &config);
36 
37 protected:
38 	void irq_ack_w(uint8_t data);
39 	uint8_t leta_r(offs_t offset);
40 	void nvram_recall_w(uint8_t data);
41 	void nvram_store_w(uint8_t data);
42 	void cloud9_paletteram_w(offs_t offset, uint8_t data);
43 	void cloud9_videoram_w(offs_t offset, uint8_t data);
44 	uint8_t cloud9_bitmode_r();
45 	void cloud9_bitmode_w(uint8_t data);
46 	void cloud9_bitmode_addr_w(offs_t offset, uint8_t data);
47 	virtual void machine_start() override;
48 	virtual void machine_reset() override;
49 	virtual void video_start() override;
50 	uint32_t screen_update_cloud9(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
51 	TIMER_CALLBACK_MEMBER(clock_irq);
52 	inline void cloud9_write_vram( uint16_t addr, uint8_t data, uint8_t bitmd, uint8_t pixba );
53 	inline void bitmode_autoinc();
54 	inline void schedule_next_irq(int curscanline);
55 	void cloud9_map(address_map &map);
56 
57 private:
58 	/* devices */
59 	required_device<m6502_device> m_maincpu;
60 	required_device<x2212_device> m_nvram;
61 	/* memory pointers */
62 	std::unique_ptr<uint8_t[]>    m_videoram;
63 	required_shared_ptr<uint8_t> m_spriteram;
64 	required_shared_ptr<uint8_t> m_paletteram;
65 
66 	required_device<gfxdecode_device> m_gfxdecode;
67 	required_device<screen_device> m_screen;
68 	required_device<palette_device> m_palette;
69 	required_device<ls259_device> m_videolatch;
70 
71 	/* video-related */
72 	const uint8_t *m_syncprom;
73 	const uint8_t *m_wpprom;
74 	const uint8_t *m_priprom;
75 	bitmap_ind16 m_spritebitmap;
76 	double      m_rweights[3];
77 	double      m_gweights[3];
78 	double      m_bweights[3];
79 	uint8_t       m_bitmode_addr[2];
80 
81 	/* misc */
82 	int         m_vblank_start;
83 	int         m_vblank_end;
84 	emu_timer   *m_irq_timer;
85 	uint8_t       m_irq_state;
86 };
87 
88 #endif // MAME_INCLUDES_CLOUD9_H
89