1 // license:BSD-3-Clause
2 // copyright-holders:Mirko Buffoni, Couriersud
3 /*************************************************************************
4 
5     IronHorse
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_IRONHORS_H
9 #define MAME_INCLUDES_IRONHORS_H
10 
11 #pragma once
12 
13 #include "machine/gen_latch.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 class ironhors_state : public driver_device
21 {
22 public:
ironhors_state(const machine_config & mconfig,device_type type,const char * tag)23 	ironhors_state(const machine_config &mconfig, device_type type, const char *tag) :
24 		driver_device(mconfig, type, tag),
25 		m_maincpu(*this, "maincpu"),
26 		m_soundcpu(*this, "soundcpu"),
27 		m_gfxdecode(*this, "gfxdecode"),
28 		m_palette(*this, "palette"),
29 		m_screen(*this, "screen"),
30 		m_soundlatch(*this, "soundlatch"),
31 		m_disc_ih(*this, "disc_ih"),
32 		m_interrupt_enable(*this, "int_enable"),
33 		m_scroll(*this, "scroll"),
34 		m_colorram(*this, "colorram"),
35 		m_videoram(*this, "videoram"),
36 		m_spriteram2(*this, "spriteram2"),
37 		m_spriteram(*this, "spriteram")
38 	{ }
39 
40 	void farwest(machine_config &config);
41 	void ironhors(machine_config &config);
42 
43 private:
44 	void sh_irqtrigger_w(uint8_t data);
45 	void videoram_w(offs_t offset, uint8_t data);
46 	void colorram_w(offs_t offset, uint8_t data);
47 	void charbank_w(uint8_t data);
48 	void palettebank_w(uint8_t data);
49 	void flipscreen_w(uint8_t data);
50 	void filter_w(uint8_t data);
51 
52 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
53 	uint32_t screen_update_farwest(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
54 
55 	TIMER_DEVICE_CALLBACK_MEMBER(ironhors_scanline_tick);
56 	TIMER_DEVICE_CALLBACK_MEMBER(farwest_scanline_tick);
57 
58 	void ironhors_palette(palette_device &palette) const;
59 	DECLARE_VIDEO_START(farwest);
60 
61 	void farwest_master_map(address_map &map);
62 	void farwest_slave_map(address_map &map);
63 	void master_map(address_map &map);
64 	void slave_io_map(address_map &map);
65 	void slave_map(address_map &map);
66 
67 	virtual void machine_start() override;
68 	virtual void machine_reset() override;
69 	virtual void video_start() override;
70 
71 	/* devices */
72 	required_device<cpu_device> m_maincpu;
73 	required_device<cpu_device> m_soundcpu;
74 	required_device<gfxdecode_device> m_gfxdecode;
75 	required_device<palette_device> m_palette;
76 	required_device<screen_device> m_screen;
77 	required_device<generic_latch_8_device> m_soundlatch;
78 	required_device<discrete_device> m_disc_ih;
79 
80 	/* memory pointers */
81 	required_shared_ptr<uint8_t> m_interrupt_enable;
82 	required_shared_ptr<uint8_t> m_scroll;
83 	required_shared_ptr<uint8_t> m_colorram;
84 	required_shared_ptr<uint8_t> m_videoram;
85 	required_shared_ptr<uint8_t> m_spriteram2;
86 	required_shared_ptr<uint8_t> m_spriteram;
87 
88 	/* video-related */
89 	tilemap_t    *m_bg_tilemap;
90 	int        m_palettebank;
91 	int        m_charbank;
92 	int        m_spriterambank;
93 
94 	void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
95 	void farwest_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
96 
97 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
98 	TILE_GET_INFO_MEMBER(farwest_get_bg_tile_info);
99 };
100 
101 #endif // MAME_INCLUDES_IRONHORS_H
102