1 // license:BSD-3-Clause
2 // copyright-holders:Stefan Jokisch
3 /***************************************************************************
4 
5 Atari Sky Raider driver
6 
7 ***************************************************************************/
8 
9 #include "emu.h"
10 #include "includes/skyraid.h"
11 
12 #include "cpu/m6502/m6502.h"
13 #include "machine/watchdog.h"
14 #include "screen.h"
15 #include "speaker.h"
16 
machine_start()17 void skyraid_state::machine_start()
18 {
19 	m_led.resolve();
20 }
21 
skyraid_palette(palette_device & palette) const22 void skyraid_state::skyraid_palette(palette_device &palette) const
23 {
24 	palette.set_pen_color(0, rgb_t(0x00, 0x00, 0x00));   // terrain
25 	palette.set_pen_color(1, rgb_t(0x18, 0x18, 0x18));
26 	palette.set_pen_color(2, rgb_t(0x30, 0x30, 0x30));
27 	palette.set_pen_color(3, rgb_t(0x48, 0x48, 0x48));
28 	palette.set_pen_color(4, rgb_t(0x60, 0x60, 0x60));
29 	palette.set_pen_color(5, rgb_t(0x78, 0x78, 0x78));
30 	palette.set_pen_color(6, rgb_t(0x90, 0x90, 0x90));
31 	palette.set_pen_color(7, rgb_t(0xa8, 0xa8, 0xa8));
32 	palette.set_pen_color(8, rgb_t(0x10, 0x10, 0x10));   // sprites
33 	palette.set_pen_color(9, rgb_t(0xe0, 0xe0, 0xe0));
34 	palette.set_pen_color(10, rgb_t(0xa0, 0xa0, 0xa0));
35 	palette.set_pen_color(11, rgb_t(0x48, 0x48, 0x48));
36 	palette.set_pen_color(12, rgb_t(0x10, 0x10, 0x10));
37 	palette.set_pen_color(13, rgb_t(0x48, 0x48, 0x48));
38 	palette.set_pen_color(14, rgb_t(0xa0, 0xa0, 0xa0));
39 	palette.set_pen_color(15, rgb_t(0xe0, 0xe0, 0xe0));
40 	palette.set_pen_color(16, rgb_t(0x00, 0x00, 0x00));   // missiles
41 	palette.set_pen_color(17, rgb_t(0xff, 0xff, 0xff));
42 	palette.set_pen_color(18, rgb_t(0x00, 0x00, 0x00));   // text
43 	palette.set_pen_color(19, rgb_t(0xe0, 0xe0, 0xe0));
44 }
45 
skyraid_port_0_r()46 uint8_t skyraid_state::skyraid_port_0_r()
47 {
48 	uint8_t val = ioport("LANGUAGE")->read();
49 
50 	if (ioport("STICKY")->read() > m_analog_range)
51 		val |= 0x40;
52 	if (ioport("STICKX")->read() > m_analog_range)
53 		val |= 0x80;
54 
55 	return val;
56 }
57 
58 
skyraid_range_w(uint8_t data)59 void skyraid_state::skyraid_range_w(uint8_t data)
60 {
61 	m_analog_range = data & 0x3f;
62 }
63 
64 
skyraid_offset_w(uint8_t data)65 void skyraid_state::skyraid_offset_w(uint8_t data)
66 {
67 	m_analog_offset = data & 0x3f;
68 }
69 
70 
skyraid_scroll_w(uint8_t data)71 void skyraid_state::skyraid_scroll_w(uint8_t data)
72 {
73 	m_scroll = data;
74 }
75 
76 
skyraid_map(address_map & map)77 void skyraid_state::skyraid_map(address_map &map)
78 {
79 	map(0x0000, 0x00ff).ram().mirror(0x300);
80 	map(0x0400, 0x040f).writeonly().share("pos_ram");
81 	map(0x0800, 0x087f).ram().mirror(0x480).share("alpha_num_ram");
82 	map(0x1000, 0x1000).r(FUNC(skyraid_state::skyraid_port_0_r));
83 	map(0x1001, 0x1001).portr("DSW");
84 	map(0x1400, 0x1400).portr("COIN");
85 	map(0x1401, 0x1401).portr("SYSTEM");
86 	map(0x1c00, 0x1c0f).writeonly().share("obj_ram");
87 	map(0x4000, 0x4000).w(FUNC(skyraid_state::skyraid_scroll_w));
88 	map(0x4400, 0x4400).w(FUNC(skyraid_state::skyraid_sound_w));
89 	map(0x4800, 0x4800).w(FUNC(skyraid_state::skyraid_range_w));
90 	map(0x5000, 0x5000).w("watchdog", FUNC(watchdog_timer_device::reset_w));
91 	map(0x5800, 0x5800).w(FUNC(skyraid_state::skyraid_offset_w));
92 	map(0x7000, 0x7fff).rom();
93 	map(0xf000, 0xffff).rom();
94 }
95 
96 static INPUT_PORTS_START( skyraid )
97 	PORT_START("LANGUAGE")
98 	PORT_DIPNAME( 0x30, 0x00, DEF_STR( Language ) )
99 	PORT_DIPSETTING(    0x00, DEF_STR( English ) )
100 	PORT_DIPSETTING(    0x10, DEF_STR( French ) )
101 	PORT_DIPSETTING(    0x20, DEF_STR( German ) )
102 	PORT_DIPSETTING(    0x30, DEF_STR( Spanish ) )
103 	PORT_BIT (0x40, IP_ACTIVE_HIGH, IPT_UNUSED) /* POT1 */
104 	PORT_BIT (0x80, IP_ACTIVE_HIGH, IPT_UNUSED) /* POT0 */
105 
106 	PORT_START("DSW")
107 	PORT_DIPNAME( 0x30, 0x10, "Play Time" )
108 	PORT_DIPSETTING(    0x00, "60 Seconds" )
109 	PORT_DIPSETTING(    0x10, "80 Seconds" )
110 	PORT_DIPSETTING(    0x20, "100 Seconds" )
111 	PORT_DIPSETTING(    0x30, "120 Seconds" )
112 	PORT_DIPNAME( 0x40, 0x40, "DIP #5" )    /* must be OFF */
113 	PORT_DIPSETTING(    0x40, DEF_STR( Off ))
114 	PORT_DIPSETTING(    0x00, DEF_STR( On ))
115 	PORT_DIPNAME( 0x80, 0x00, "Extended Play" )
116 	PORT_DIPSETTING(    0x80, DEF_STR( No ))
117 	PORT_DIPSETTING(    0x00, DEF_STR( Yes ))
118 
119 	/* coinage settings are insane, refer to the manual */
120 
121 	PORT_START("COIN")
122 	PORT_DIPNAME( 0x0F, 0x01, DEF_STR( Coinage )) /* dial */
123 	PORT_DIPSETTING(    0x00, "Mode 0" )
124 	PORT_DIPSETTING(    0x01, "Mode 1" )
125 	PORT_DIPSETTING(    0x02, "Mode 2" )
126 	PORT_DIPSETTING(    0x03, "Mode 3" )
127 	PORT_DIPSETTING(    0x04, "Mode 4" )
128 	PORT_DIPSETTING(    0x05, "Mode 5" )
129 	PORT_DIPSETTING(    0x06, "Mode 6" )
130 	PORT_DIPSETTING(    0x07, "Mode 7" )
131 	PORT_DIPSETTING(    0x08, "Mode 8" )
132 	PORT_DIPSETTING(    0x09, "Mode 9" )
133 	PORT_DIPSETTING(    0x0A, "Mode A" )
134 	PORT_DIPSETTING(    0x0B, "Mode B" )
135 	PORT_DIPSETTING(    0x0C, "Mode C" )
136 	PORT_DIPSETTING(    0x0D, "Mode D" )
137 	PORT_DIPSETTING(    0x0E, "Mode E" )
138 	PORT_DIPSETTING(    0x0F, "Mode F" )
139 	PORT_DIPNAME( 0x10, 0x10, "Score for Extended Play" )
140 	PORT_DIPSETTING(    0x00, DEF_STR( Low ) )
141 	PORT_DIPSETTING(    0x10, DEF_STR( High ) )
142 	PORT_BIT (0x20, IP_ACTIVE_LOW, IPT_BUTTON1)
143 	PORT_BIT (0x40, IP_ACTIVE_HIGH, IPT_COIN1)
144 	PORT_BIT (0x80, IP_ACTIVE_HIGH, IPT_COIN2)
145 
146 	PORT_START("SYSTEM")
147 	PORT_BIT (0x10, IP_ACTIVE_LOW, IPT_TILT)
148 	PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("Hiscore Reset") PORT_CODE(KEYCODE_H)
149 	PORT_BIT (0x40, IP_ACTIVE_LOW, IPT_START1)
150 	PORT_SERVICE(0x80, IP_ACTIVE_LOW)
151 
152 	PORT_START("STICKY")
153 	PORT_BIT( 0x3f, 0x20, IPT_AD_STICK_Y ) PORT_MINMAX(0,63) PORT_SENSITIVITY(10) PORT_KEYDELTA(10) PORT_REVERSE
154 
155 	PORT_START("STICKX")
156 	PORT_BIT( 0x3f, 0x20, IPT_AD_STICK_X ) PORT_MINMAX(0,63) PORT_SENSITIVITY(10) PORT_KEYDELTA(10)
157 INPUT_PORTS_END
158 
159 
160 static const gfx_layout skyraid_text_layout =
161 {
162 	16, 8,  /* width, height */
163 	64,     /* total         */
164 	1,      /* planes        */
165 	{ 0 },  /* plane offsets */
166 	{
167 		0, 0, 1, 1, 2, 2, 3, 3,
168 		4, 4, 5, 5, 6, 6, 7, 7
169 	},
170 	{
171 		0x38, 0x30, 0x28, 0x20, 0x18, 0x10, 0x08, 0x00
172 	},
173 	0x40
174 };
175 
176 
177 static const gfx_layout skyraid_sprite_layout =
178 {
179 	32, 32, /* width, height */
180 	8,      /* total         */
181 	2,      /* planes        */
182 			/* plane offsets */
183 	{ 0, 1 },
184 	{
185 		0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
186 		0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E,
187 		0x20, 0x22, 0x24, 0x26, 0x28, 0x2A, 0x2C, 0x2E,
188 		0x30, 0x32, 0x34, 0x36, 0x38, 0x3A, 0x3C, 0x3E
189 	},
190 	{
191 		0x000, 0x040, 0x080, 0x0C0, 0x100, 0x140, 0x180, 0x1C0,
192 		0x200, 0x240, 0x280, 0x2C0, 0x300, 0x340, 0x380, 0x3C0,
193 		0x400, 0x440, 0x480, 0x4C0, 0x500, 0x540, 0x580, 0x5C0,
194 		0x600, 0x640, 0x680, 0x6C0, 0x700, 0x740, 0x780, 0x7C0
195 	},
196 	0x800
197 };
198 
199 
200 static const gfx_layout skyraid_missile_layout =
201 {
202 	16, 16, /* width, height */
203 	8,      /* total         */
204 	1,      /* planes        */
205 	{ 0 },  /* plane offsets */
206 	{
207 		0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
208 		0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
209 	},
210 	{
211 		0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
212 		0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0
213 	},
214 	0x100
215 };
216 
217 
218 static GFXDECODE_START( gfx_skyraid )
219 	GFXDECODE_ENTRY( "gfx1", 0, skyraid_text_layout, 18, 1 )
220 	GFXDECODE_ENTRY( "gfx2", 0, skyraid_sprite_layout, 8, 2 )
221 	GFXDECODE_ENTRY( "gfx3", 0, skyraid_missile_layout, 16, 1 )
222 GFXDECODE_END
223 
224 
skyraid(machine_config & config)225 void skyraid_state::skyraid(machine_config &config)
226 {
227 	/* basic machine hardware */
228 	M6502(config, m_maincpu, 12096000 / 12);
229 	m_maincpu->set_addrmap(AS_PROGRAM, &skyraid_state::skyraid_map);
230 	m_maincpu->set_vblank_int("screen", FUNC(skyraid_state::irq0_line_hold));
231 
232 	WATCHDOG_TIMER(config, "watchdog").set_vblank_count("screen", 4);
233 
234 	/* video hardware */
235 	screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
236 	screen.set_refresh_hz(60);
237 	screen.set_vblank_time(ATTOSECONDS_IN_USEC(22 * 1000000 / 15750));
238 	screen.set_size(512, 240);
239 	screen.set_visarea(0, 511, 0, 239);
240 	screen.set_screen_update(FUNC(skyraid_state::screen_update_skyraid));
241 	screen.set_palette(m_palette);
242 
243 	GFXDECODE(config, m_gfxdecode, m_palette, gfx_skyraid);
244 
245 	PALETTE(config, m_palette, FUNC(skyraid_state::skyraid_palette), 20);
246 
247 	/* sound hardware */
248 	SPEAKER(config, "mono").front_center();
249 
250 	DISCRETE(config, m_discrete, skyraid_discrete).add_route(ALL_OUTPUTS, "mono", 1.0);
251 }
252 
253 
254 ROM_START( skyraid )
255 	ROM_REGION( 0x10000, "maincpu", 0 )
256 	ROM_LOAD( "030595.e1", 0x7000, 0x800, CRC(c6cb3a2b) SHA1(e4cb8d259446d0614c0c8f097f97dcf21869782e) )
257 	ROM_RELOAD(            0xF000, 0x800 )
258 	ROM_LOAD( "030594.d1", 0x7800, 0x800, CRC(27979e96) SHA1(55ffe3094c6764e6b99ee148e3dd730ca263fa3a) )
259 	ROM_RELOAD(            0xF800, 0x800 )
260 
261 	ROM_REGION( 0x0200, "gfx1", 0 ) /* alpha numerics */
262 	ROM_LOAD( "030598.h2", 0x0000, 0x200, CRC(2a7c5fa0) SHA1(93a79e5948dfcd9b6c2ff390e85a43f7a8cac327) )
263 
264 	ROM_REGION( 0x0800, "gfx2", 0 ) /* sprites */
265 	ROM_LOAD( "030599.m7", 0x0000, 0x800, CRC(0cd179ea) SHA1(e3c763f76e6103e5909e7b5a979206b262d6e96a) )
266 
267 	ROM_REGION( 0x0100, "gfx3", 0 ) /* missiles */
268 	ROM_LOAD_NIB_LOW ( "030597.n5", 0x0000, 0x100, CRC(319ff49c) SHA1(ff4d8b20436179910bf30c720d98df4678f683a9) )
269 	ROM_LOAD_NIB_HIGH( "030596.m4", 0x0000, 0x100, CRC(30454ed0) SHA1(4216a54c13d9c4803f88f2de35cdee31290bb15e) )
270 
271 	ROM_REGION( 0x0800, "user1", 0 ) /* terrain */
272 	ROM_LOAD_NIB_LOW ( "030584.j5", 0x0000, 0x800, CRC(81f6e8a5) SHA1(ad77b469ed0c9d5dfaa221ecf47d0db4a7f7ac91) )
273 	ROM_LOAD_NIB_HIGH( "030585.k5", 0x0000, 0x800, CRC(b49bec3f) SHA1(b55d25230ec11c52e7b47d2c10194a49adbeb50a) )
274 
275 	ROM_REGION( 0x0100, "user2", 0 ) /* trapezoid */
276 	ROM_LOAD_NIB_LOW ( "030582.a6", 0x0000, 0x100, CRC(0eacd595) SHA1(5469e312a1f522ce0a61054b50895a5b1a3f19ba) )
277 	ROM_LOAD_NIB_HIGH( "030583.b6", 0x0000, 0x100, CRC(3edd6fbc) SHA1(0418ea78cf51e18c51087b43a41cd9e13aac0a16) )
278 
279 	ROM_REGION( 0x0300, "proms", 0 )
280 	ROM_LOAD( "006559.c4", 0x0200, 0x100, CRC(5a8d0e42) SHA1(772220c4c24f18769696ddba26db2bc2e5b0909d) ) /* sync */
281 ROM_END
282 
283 
284 GAME( 1978, skyraid, 0, skyraid, skyraid, skyraid_state, empty_init, ORIENTATION_FLIP_Y, "Atari", "Sky Raider", MACHINE_IMPERFECT_COLORS )
285