1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria, Dan Boris
3 /*************************************************************************
4 
5     rokola hardware
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_SNK6502_H
9 #define MAME_INCLUDES_SNK6502_H
10 
11 #pragma once
12 
13 #include "machine/bankdev.h"
14 #include "machine/timer.h"
15 #include "emupal.h"
16 #include "tilemap.h"
17 
18 class fantasy_sound_device;
19 
20 class snk6502_state : public driver_device
21 {
22 public:
snk6502_state(const machine_config & mconfig,device_type type,const char * tag)23 	snk6502_state(const machine_config &mconfig, device_type type, const char *tag) :
24 		driver_device(mconfig, type, tag),
25 		m_maincpu(*this, "maincpu"),
26 		m_gfxdecode(*this, "gfxdecode"),
27 		m_palette(*this, "palette"),
28 		m_videoram(*this, "videoram"),
29 		m_videoram2(*this, "videoram2"),
30 		m_colorram(*this, "colorram"),
31 		m_charram(*this, "charram")
32 	{ }
33 
34 	void satansat(machine_config &config);
35 	void sasuke(machine_config &config);
36 
37 	DECLARE_CUSTOM_INPUT_MEMBER(sasuke_count_r);
38 	DECLARE_INPUT_CHANGED_MEMBER(coin_inserted);
39 
40 	DECLARE_VIDEO_START(pballoon);
41 
42 protected:
43 	required_device<cpu_device> m_maincpu;
44 	required_device<gfxdecode_device> m_gfxdecode;
45 	required_device<palette_device> m_palette;
46 
47 	required_shared_ptr<uint8_t> m_videoram;
48 	required_shared_ptr<uint8_t> m_videoram2;
49 	required_shared_ptr<uint8_t> m_colorram;
50 	required_shared_ptr<uint8_t> m_charram;
51 
52 	uint8_t m_sasuke_counter;
53 	int m_charbank;
54 	int m_backcolor;
55 	tilemap_t *m_bg_tilemap;
56 	tilemap_t *m_fg_tilemap;
57 	rgb_t m_palette_val[64];
58 	uint8_t m_irq_mask;
59 
60 	// common
61 	void videoram_w(offs_t offset, uint8_t data);
62 	void videoram2_w(offs_t offset, uint8_t data);
63 	void colorram_w(offs_t offset, uint8_t data);
64 	void charram_w(offs_t offset, uint8_t data);
65 
66 	void scrollx_w(uint8_t data);
67 	void scrolly_w(uint8_t data);
68 	void flipscreen_w(uint8_t data);
69 	void satansat_b002_w(uint8_t data);
70 	void satansat_backcolor_w(uint8_t data);
71 
72 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
73 	TILE_GET_INFO_MEMBER(get_fg_tile_info);
74 	TILE_GET_INFO_MEMBER(satansat_get_bg_tile_info);
75 	TILE_GET_INFO_MEMBER(satansat_get_fg_tile_info);
76 
77 	virtual void machine_start() override;
78 	DECLARE_MACHINE_RESET(sasuke);
79 	DECLARE_VIDEO_START(satansat);
80 	void satansat_palette(palette_device &palette);
81 	DECLARE_VIDEO_START(snk6502);
82 	void snk6502_palette(palette_device &palette);
83 
84 	uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
85 
86 	INTERRUPT_GEN_MEMBER(satansat_interrupt);
87 	INTERRUPT_GEN_MEMBER(snk6502_interrupt);
88 	TIMER_DEVICE_CALLBACK_MEMBER(sasuke_update_counter);
89 
90 	void sasuke_start_counter();
91 	void postload();
92 
93 	void sasuke_map(address_map &map);
94 	void satansat_map(address_map &map);
95 };
96 
97 class vanguard_state : public snk6502_state
98 {
99 public:
vanguard_state(const machine_config & mconfig,device_type type,const char * tag)100 	vanguard_state(const machine_config &mconfig, device_type type, const char *tag) :
101 		snk6502_state(mconfig, type, tag),
102 		m_highmem(*this, "highmem")
103 	{
104 	}
105 
106 	void vanguard(machine_config &config);
107 
108 protected:
109 	uint8_t highmem_r(offs_t offset);
110 	void highmem_w(offs_t offset, uint8_t data);
111 
112 	required_device<address_map_bank_device> m_highmem;
113 
114 private:
115 	void vanguard_map(address_map &map);
116 	void vanguard_upper_map(address_map &map);
117 };
118 
119 class fantasy_state : public vanguard_state
120 {
121 public:
fantasy_state(const machine_config & mconfig,device_type type,const char * tag)122 	fantasy_state(const machine_config &mconfig, device_type type, const char *tag) :
123 		vanguard_state(mconfig, type, tag),
124 		m_sound(*this, "snk6502")
125 	{
126 	}
127 
128 	void fantasy(machine_config &config);
129 	void nibbler(machine_config &config);
130 	void pballoon(machine_config &config);
131 
132 private:
133 	void fantasy_flipscreen_w(offs_t offset, uint8_t data);
134 
135 	void fantasy_map(address_map &map);
136 	void pballoon_map(address_map &map);
137 	void pballoon_upper_map(address_map &map);
138 
139 	required_device<fantasy_sound_device> m_sound;
140 };
141 
142 #endif // MAME_INCLUDES_SNK6502_H
143