1 // license:BSD-3-Clause
2 // copyright-holders:David Haywood
3 #ifndef MAME_INCLUDES_SHADFRCE_H
4 #define MAME_INCLUDES_SHADFRCE_H
5 
6 #pragma once
7 
8 #include "machine/gen_latch.h"
9 #include "machine/timer.h"
10 #include "sound/okim6295.h"
11 #include "emupal.h"
12 #include "screen.h"
13 #include "tilemap.h"
14 
15 class shadfrce_state : public driver_device
16 {
17 public:
shadfrce_state(const machine_config & mconfig,device_type type,const char * tag)18 	shadfrce_state(const machine_config &mconfig, device_type type, const char *tag) :
19 		driver_device(mconfig, type, tag),
20 		m_maincpu(*this, "maincpu"),
21 		m_audiocpu(*this, "audiocpu"),
22 		m_oki(*this, "oki"),
23 		m_gfxdecode(*this, "gfxdecode"),
24 		m_screen(*this, "screen"),
25 		m_palette(*this, "palette"),
26 		m_soundlatch(*this, "soundlatch"),
27 		m_io_p1(*this, "P1"),
28 		m_io_p2(*this, "P2"),
29 		m_io_dsw1(*this, "DSW1"),
30 		m_io_dsw2(*this, "DSW2"),
31 		m_io_other(*this, "OTHER"),
32 		m_io_extra(*this, "EXTRA"),
33 		m_io_misc(*this, "MISC"),
34 		m_io_system(*this, "SYSTEM"),
35 		m_fgvideoram(*this, "fgvideoram"),
36 		m_bg0videoram(*this, "bg0videoram"),
37 		m_bg1videoram(*this, "bg1videoram"),
38 		m_spvideoram(*this, "spvideoram")
39 	{ }
40 
41 	void shadfrce(machine_config &config);
42 
43 protected:
44 	virtual void video_start() override;
45 
46 private:
47 	required_device<cpu_device> m_maincpu;
48 	required_device<cpu_device> m_audiocpu;
49 	required_device<okim6295_device> m_oki;
50 	required_device<gfxdecode_device> m_gfxdecode;
51 	required_device<screen_device> m_screen;
52 	required_device<palette_device> m_palette;
53 	required_device<generic_latch_8_device> m_soundlatch;
54 
55 	required_ioport m_io_p1;
56 	required_ioport m_io_p2;
57 	required_ioport m_io_dsw1;
58 	required_ioport m_io_dsw2;
59 	required_ioport m_io_other;
60 	required_ioport m_io_extra;
61 	required_ioport m_io_misc;
62 	required_ioport m_io_system;
63 
64 	required_shared_ptr<uint16_t> m_fgvideoram;
65 	required_shared_ptr<uint16_t> m_bg0videoram;
66 	required_shared_ptr<uint16_t> m_bg1videoram;
67 	required_shared_ptr<uint16_t> m_spvideoram;
68 
69 	std::unique_ptr<uint16_t[]> m_spvideoram_old;
70 	tilemap_t *m_fgtilemap;
71 	tilemap_t *m_bg0tilemap;
72 	tilemap_t *m_bg1tilemap;
73 	int m_video_enable;
74 	int m_irqs_enable;
75 	int m_raster_scanline;
76 	int m_raster_irq_enable;
77 	int m_vblank;
78 	int m_prev_value;
79 
80 	void flip_screen(uint16_t data);
81 	uint16_t input_ports_r(offs_t offset);
82 	void screen_brt_w(uint8_t data);
83 	void irq_ack_w(offs_t offset, uint16_t data);
84 	void irq_w(uint16_t data);
85 	void scanline_w(uint16_t data);
86 	void fgvideoram_w(offs_t offset, uint16_t data);
87 	void bg0videoram_w(offs_t offset, uint16_t data);
88 	void bg1videoram_w(offs_t offset, uint16_t data);
89 	void bg0scrollx_w(uint16_t data);
90 	void bg0scrolly_w(uint16_t data);
91 	void bg1scrollx_w(uint16_t data);
92 	void bg1scrolly_w(uint16_t data);
93 	void oki_bankswitch_w(uint8_t data);
94 
95 	TILE_GET_INFO_MEMBER(get_fgtile_info);
96 	TILE_GET_INFO_MEMBER(get_bg0tile_info);
97 	TILE_GET_INFO_MEMBER(get_bg1tile_info);
98 
99 	TIMER_DEVICE_CALLBACK_MEMBER(scanline);
100 
101 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
102 	DECLARE_WRITE_LINE_MEMBER(screen_vblank);
103 	void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect );
104 
105 	void shadfrce_map(address_map &map);
106 	void shadfrce_sound_map(address_map &map);
107 };
108 
109 #endif // MAME_INCLUDES_SHADFRCE_H
110