1 // license:BSD-3-Clause
2 // copyright-holders:Bryan McPhail
3 
4 #include "machine/eepromser.h"
5 #include "machine/deco146.h"
6 #include "machine/timer.h"
7 #include "sound/ymz280b.h"
8 #include "emupal.h"
9 #include "screen.h"
10 
11 
12 class deco_mlc_state : public driver_device
13 {
14 public:
deco_mlc_state(const machine_config & mconfig,device_type type,const char * tag)15 	deco_mlc_state(const machine_config &mconfig, device_type type, const char *tag)
16 		: driver_device(mconfig, type, tag),
17 		m_maincpu(*this, "maincpu"),
18 		m_eeprom(*this, "eeprom"),
19 		m_ymz(*this, "ymz"),
20 		m_gfxdecode(*this, "gfxdecode"),
21 		m_screen(*this, "screen"),
22 		m_palette(*this, "palette"),
23 		m_deco146(*this, "ioprot"),
24 		m_raster_irq_timer(*this, "int_timer"),
25 		m_mainram(*this, "mainram"),
26 		m_irq_ram(*this, "irq_ram"),
27 		m_clip_ram(*this, "clip_ram"),
28 		m_vram(*this, "vram"),
29 		m_gfx2(*this,"gfx2")
30 		{ }
31 
32 	void init_mlc();
33 	void init_acchi();
34 	void init_avengrgs();
35 
36 	void acchi(machine_config &config);
37 	void avengrgs(machine_config &config);
38 	void mlc(machine_config &config);
39 	void mlc_5bpp(machine_config &config);
40 	void mlc_6bpp(machine_config &config);
41 	void stadhr96(machine_config &config);
42 
43 protected:
44 	virtual void machine_reset() override;
45 	virtual void video_start() override;
46 
47 private:
48 	required_device<cpu_device> m_maincpu;
49 	required_device<eeprom_serial_93cxx_device> m_eeprom;
50 	required_device<ymz280b_device> m_ymz;
51 	required_device<gfxdecode_device> m_gfxdecode;
52 	required_device<screen_device> m_screen;
53 	required_device<palette_device> m_palette;
54 	optional_device<deco146_device> m_deco146;
55 	required_device<timer_device> m_raster_irq_timer;
56 
57 	required_shared_ptr<u32> m_mainram;
58 	required_shared_ptr<u32> m_irq_ram;
59 	required_shared_ptr<u32> m_clip_ram;
60 	required_shared_ptr<u32> m_vram;
61 
62 	required_region_ptr<u8> m_gfx2;
63 
64 	int m_irqLevel;
65 	u32 m_vbl_i;
66 	u32 m_colour_mask;
67 	u32 m_shadow_mask;
68 	u32 m_shadow_shift;
69 
70 	std::unique_ptr<u16[]> m_spriteram;
71 	std::unique_ptr<u16[]> m_spriteram_spare;
72 	std::unique_ptr<u16[]> m_buffered_spriteram;
73 
74 	u32 mlc_440008_r();
75 	u32 mlc_44001c_r(offs_t offset);
76 	void mlc_44001c_w(u32 data);
77 
78 	u32 mlc_200000_r();
79 	u32 mlc_200004_r();
80 	u32 mlc_200070_r();
81 	u32 mlc_20007c_r();
82 	u32 mlc_scanline_r();
83 	void irq_ram_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
84 	u32 avengrgs_speedup_r();
85 	void eeprom_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
86 	u32 spriteram_r(offs_t offset, uint32_t mem_mask = ~0);
87 	void spriteram_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
88 
89 	u16 sh96_protection_region_0_146_r(offs_t offset);
90 	void sh96_protection_region_0_146_w(offs_t offset, u16 data, u16 mem_mask = ~0);
91 
92 	u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
93 	DECLARE_WRITE_LINE_MEMBER(screen_vblank_mlc);
94 	TIMER_DEVICE_CALLBACK_MEMBER(interrupt_gen);
95 	void draw_sprites( const rectangle &cliprect, int scanline, u32* dest, u8* pri);
96 	void drawgfxzoomline(u32* dest, u8* pri,const rectangle &clip,gfx_element *gfx,
97 		u32 code1,u32 code2, u32 color,int flipx,int sx,
98 		int transparent_color,int use8bpp,
99 		int scalex, int srcline, int shadowMode);
100 	void descramble_sound();
101 
102 	void avengrgs_map(address_map &map);
103 	void decomlc_146_map(address_map &map);
104 	void decomlc_no146_map(address_map &map);
105 };
106