1 /***************************************************************************
2 
3 Atari Sky Raider driver
4 
5 ***************************************************************************/
6 
7 #include "driver.h"
8 
9 extern UINT8* skyraid_alpha_num_ram;
10 extern UINT8* skyraid_pos_ram;
11 extern UINT8* skyraid_obj_ram;
12 
13 extern int skyraid_scroll;
14 
15 extern VIDEO_START(skyraid);
16 extern VIDEO_UPDATE(skyraid);
17 
18 static int analog_range;
19 static int analog_offset;
20 
21 
PALETTE_INIT(skyraid)22 static PALETTE_INIT( skyraid )
23 {
24 	palette_set_color( 0, 0x00, 0x00, 0x00);	/* terrain */
25 	palette_set_color( 1, 0x18, 0x18, 0x18);
26 	palette_set_color( 2, 0x30, 0x30, 0x30);
27 	palette_set_color( 3, 0x48, 0x48, 0x48);
28 	palette_set_color( 4, 0x60, 0x60, 0x60);
29 	palette_set_color( 5, 0x78, 0x78, 0x78);
30 	palette_set_color( 6, 0x90, 0x90, 0x90);
31 	palette_set_color( 7, 0xA8, 0xA8, 0xA8);
32 	palette_set_color( 8, 0x10, 0x10, 0x10);	/* sprites */
33 	palette_set_color( 9, 0xE0, 0xE0, 0xE0);
34 	palette_set_color(10, 0xA0, 0xA0, 0xA0);
35 	palette_set_color(11, 0x48, 0x48, 0x48);
36 	palette_set_color(12, 0x10, 0x10, 0x10);
37 	palette_set_color(13, 0x48, 0x48, 0x48);
38 	palette_set_color(14, 0xA0, 0xA0, 0xA0);
39 	palette_set_color(15, 0xE0, 0xE0, 0xE0);
40 	palette_set_color(16, 0x00, 0x00, 0x00);	/* missiles */
41 	palette_set_color(17, 0xFF, 0xFF, 0xFF);
42 	palette_set_color(18, 0x00, 0x00, 0x00);	/* text */
43 	palette_set_color(19, 0xE0, 0xE0, 0xE0);
44 }
45 
46 
READ_HANDLER(skyraid_zeropage_r)47 static READ_HANDLER( skyraid_zeropage_r )
48 {
49 	return memory_region(REGION_CPU1)[offset & 0xff];
50 }
51 
52 
READ_HANDLER(skyraid_alpha_num_r)53 static READ_HANDLER( skyraid_alpha_num_r)
54 {
55 	return skyraid_alpha_num_ram[offset & 0x7f];
56 }
57 
58 
READ_HANDLER(skyraid_port_0_r)59 static READ_HANDLER( skyraid_port_0_r )
60 {
61 	UINT8 val = readinputport(0);
62 
63 	if (readinputport(4) > analog_range)
64 		val |= 0x40;
65 	if (readinputport(5) > analog_range)
66 		val |= 0x80;
67 
68 	return val;
69 }
70 
71 
WRITE_HANDLER(skyraid_zeropage_w)72 static WRITE_HANDLER( skyraid_zeropage_w )
73 {
74 	memory_region(REGION_CPU1)[offset & 0xff] = data;
75 }
76 
77 
WRITE_HANDLER(skyraid_alpha_num_w)78 static WRITE_HANDLER( skyraid_alpha_num_w )
79 {
80 	skyraid_alpha_num_ram[offset & 0x7f] = data;
81 }
82 
83 
WRITE_HANDLER(skyraid_sound_w)84 static WRITE_HANDLER( skyraid_sound_w )
85 {
86 	/* BIT0 => PLANE SWEEP */
87 	/* BIT1 => MISSILE     */
88 	/* BIT2 => EXPLOSION   */
89 	/* BIT3 => START LAMP  */
90 	/* BIT4 => PLANE ON    */
91 	/* BIT5 => ATTRACT     */
92 
93 	set_led_status(0, !(data & 0x08));
94 }
95 
96 
WRITE_HANDLER(skyraid_range_w)97 static WRITE_HANDLER( skyraid_range_w )
98 {
99 	analog_range = data & 0x3f;
100 }
101 
102 
WRITE_HANDLER(skyraid_offset_w)103 static WRITE_HANDLER( skyraid_offset_w )
104 {
105 	analog_offset = data & 0x3f;
106 }
107 
108 
WRITE_HANDLER(skyraid_scroll_w)109 static WRITE_HANDLER( skyraid_scroll_w )
110 {
111 	skyraid_scroll = data;
112 }
113 
114 
MEMORY_READ_START(skyraid_readmem)115 static MEMORY_READ_START( skyraid_readmem )
116 	{ 0x0000, 0x00ff, MRA_RAM },
117 	{ 0x0100, 0x03ff, skyraid_zeropage_r },
118 	{ 0x0800, 0x087f, MRA_RAM },
119 	{ 0x0880, 0x0bff, skyraid_alpha_num_r },
120 	{ 0x1000, 0x1000, skyraid_port_0_r },
121 	{ 0x1000, 0x1001, input_port_1_r },
122 	{ 0x1400, 0x1400, input_port_2_r },
123 	{ 0x1400, 0x1401, input_port_3_r },
124 	{ 0x7000, 0x7fff, MRA_ROM },
125 	{ 0xf000, 0xffff, MRA_ROM },
126 MEMORY_END
127 
128 
129 static MEMORY_WRITE_START( skyraid_writemem )
130 	{ 0x0000, 0x00ff, MWA_RAM },
131 	{ 0x0100, 0x03ff, skyraid_zeropage_w },
132 	{ 0x0400, 0x040f, MWA_RAM, &skyraid_pos_ram },
133 	{ 0x0800, 0x087f, MWA_RAM, &skyraid_alpha_num_ram },
134 	{ 0x0880, 0x0bff, skyraid_alpha_num_w },
135 	{ 0x1c00, 0x1c0f, MWA_RAM, &skyraid_obj_ram },
136 	{ 0x4000, 0x4000, skyraid_scroll_w },
137 	{ 0x4400, 0x4400, skyraid_sound_w },
138 	{ 0x4800, 0x4800, skyraid_range_w },
139 	{ 0x5000, 0x5000, watchdog_reset_w },
140 	{ 0x5800, 0x5800, skyraid_offset_w },
141 	{ 0x7000, 0x7fff, MWA_ROM },
142 	{ 0xf000, 0xffff, MWA_ROM },
143 MEMORY_END
144 
145 
146 INPUT_PORTS_START( skyraid )
147 	PORT_START
148 	PORT_DIPNAME( 0x30, 0x00, "Language" )
149 	PORT_DIPSETTING(    0x00, "English" )
150 	PORT_DIPSETTING(    0x10, "French" )
151 	PORT_DIPSETTING(    0x20, "German" )
152 	PORT_DIPSETTING(    0x30, "Spanish" )
153 	PORT_BIT (0x40, IP_ACTIVE_HIGH, IPT_UNUSED) /* POT1 */
154 	PORT_BIT (0x80, IP_ACTIVE_HIGH, IPT_UNUSED) /* POT0 */
155 
156 	PORT_START
157 	PORT_DIPNAME( 0x30, 0x10, "Play Time" )
158 	PORT_DIPSETTING(    0x00, "60 Seconds" )
159 	PORT_DIPSETTING(    0x10, "80 Seconds" )
160 	PORT_DIPSETTING(    0x20, "100 Seconds" )
161 	PORT_DIPSETTING(    0x30, "120 Seconds" )
162 	PORT_DIPNAME( 0x40, 0x40, "DIP #5" )	/* must be OFF */
163 	PORT_DIPSETTING(    0x40, DEF_STR( Off ))
164 	PORT_DIPSETTING(    0x00, DEF_STR( On ))
165 	PORT_DIPNAME( 0x80, 0x00, "Extended Play" )
166 	PORT_DIPSETTING(    0x80, DEF_STR( No ))
167 	PORT_DIPSETTING(    0x00, DEF_STR( Yes ))
168 
169 	/* coinage settings are insane, refer to the manual */
170 
171 	PORT_START
172 	PORT_DIPNAME( 0x0F, 0x01, DEF_STR( Coinage )) /* dial */
173 	PORT_DIPSETTING(    0x00, "Mode 0" )
174 	PORT_DIPSETTING(    0x01, "Mode 1" )
175 	PORT_DIPSETTING(    0x02, "Mode 2" )
176 	PORT_DIPSETTING(    0x03, "Mode 3" )
177 	PORT_DIPSETTING(    0x04, "Mode 4" )
178 	PORT_DIPSETTING(    0x05, "Mode 5" )
179 	PORT_DIPSETTING(    0x06, "Mode 6" )
180 	PORT_DIPSETTING(    0x07, "Mode 7" )
181 	PORT_DIPSETTING(    0x08, "Mode 8" )
182 	PORT_DIPSETTING(    0x09, "Mode 9" )
183 	PORT_DIPSETTING(    0x0A, "Mode A" )
184 	PORT_DIPSETTING(    0x0B, "Mode B" )
185 	PORT_DIPSETTING(    0x0C, "Mode C" )
186 	PORT_DIPSETTING(    0x0D, "Mode D" )
187 	PORT_DIPSETTING(    0x0E, "Mode E" )
188 	PORT_DIPSETTING(    0x0F, "Mode F" )
189 	PORT_DIPNAME( 0x10, 0x10, "Score for Extended Play" )
190 	PORT_DIPSETTING(    0x00, "Low" )
191 	PORT_DIPSETTING(    0x10, "High" )
192 	PORT_BIT (0x20, IP_ACTIVE_LOW, IPT_BUTTON1)
193 	PORT_BIT (0x40, IP_ACTIVE_HIGH, IPT_COIN1)
194 	PORT_BIT (0x80, IP_ACTIVE_HIGH, IPT_COIN2)
195 
196 	PORT_START
197 	PORT_BIT (0x10, IP_ACTIVE_LOW, IPT_TILT)
198 	PORT_BITX(0x20, IP_ACTIVE_LOW, IPT_BUTTON7, "Hiscore Reset", KEYCODE_H, IP_JOY_DEFAULT)
199 	PORT_BIT (0x40, IP_ACTIVE_LOW, IPT_START1)
200 	PORT_SERVICE(0x80, IP_ACTIVE_LOW)
201 
202 	PORT_START
203 	PORT_ANALOG( 0x3f, 0x20, IPT_AD_STICK_Y | IPF_REVERSE, 10, 10, 0, 63 )
204 
205 	PORT_START
206 	PORT_ANALOG( 0x3f, 0x20, IPT_AD_STICK_X, 10, 10, 0, 63 )
207 INPUT_PORTS_END
208 
209 
210 static struct GfxLayout skyraid_text_layout =
211 {
212 	16, 8,  /* width, height */
213 	64,     /* total         */
214 	1,      /* planes        */
215 	{ 0 },  /* plane offsets */
216 	{
217 		0, 0, 1, 1, 2, 2, 3, 3,
218 		4, 4, 5, 5, 6, 6, 7, 7
219 	},
220 	{
221 		0x38, 0x30, 0x28, 0x20, 0x18, 0x10, 0x08, 0x00
222 	},
223 	0x40
224 };
225 
226 
227 static struct GfxLayout skyraid_sprite_layout =
228 {
229 	32, 32, /* width, height */
230 	8,      /* total         */
231 	2,      /* planes        */
232 	        /* plane offsets */
233 	{ 0, 1 },
234 	{
235 		0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
236 		0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E,
237 		0x20, 0x22, 0x24, 0x26, 0x28, 0x2A, 0x2C, 0x2E,
238 		0x30, 0x32, 0x34, 0x36, 0x38, 0x3A, 0x3C, 0x3E
239 	},
240 	{
241 		0x000, 0x040, 0x080, 0x0C0, 0x100, 0x140, 0x180, 0x1C0,
242 		0x200, 0x240, 0x280, 0x2C0, 0x300, 0x340, 0x380, 0x3C0,
243 		0x400, 0x440, 0x480, 0x4C0, 0x500, 0x540, 0x580, 0x5C0,
244 		0x600, 0x640, 0x680, 0x6C0, 0x700, 0x740, 0x780, 0x7C0
245 	},
246 	0x800
247 };
248 
249 
250 static struct GfxLayout skyraid_missile_layout =
251 {
252 	16, 16, /* width, height */
253 	8,      /* total         */
254 	1,      /* planes        */
255 	{ 0 },  /* plane offsets */
256 	{
257 		0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
258 		0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
259 	},
260 	{
261 		0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
262 		0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0
263 	},
264 	0x100
265 };
266 
267 
268 static struct GfxDecodeInfo skyraid_gfxdecodeinfo[] =
269 {
270 	{ REGION_GFX1, 0, &skyraid_text_layout, 18, 1 },
271 	{ REGION_GFX2, 0, &skyraid_sprite_layout, 8, 2 },
272 	{ REGION_GFX3, 0, &skyraid_missile_layout, 16, 1 },
273 	{ -1 }
274 };
275 
276 
277 static MACHINE_DRIVER_START( skyraid )
278 
279 	/* basic machine hardware */
280 	MDRV_CPU_ADD(M6502, 12096000 / 12)
281 	MDRV_CPU_MEMORY(skyraid_readmem, skyraid_writemem)
282 	MDRV_CPU_VBLANK_INT(irq0_line_hold, 1)
283 
284 	MDRV_FRAMES_PER_SECOND(60)
285 	MDRV_VBLANK_DURATION(22 * 1000000 / 15750)
286 
287 	/* video hardware */
288 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
289 	MDRV_SCREEN_SIZE(512, 240)
290 	MDRV_VISIBLE_AREA(0, 511, 0, 239)
291 	MDRV_GFXDECODE(skyraid_gfxdecodeinfo)
292 
293 	MDRV_PALETTE_INIT(skyraid)
294 	MDRV_PALETTE_LENGTH(20)
295 
296 	MDRV_VIDEO_START(skyraid)
297 	MDRV_VIDEO_UPDATE(skyraid)
298 
299 	/* sound hardware */
300 MACHINE_DRIVER_END
301 
302 
303 ROM_START( skyraid )
304 	ROM_REGION( 0x10000, REGION_CPU1, 0 )
305 	ROM_LOAD( "030595.e1", 0x7000, 0x800, CRC(c6cb3a2b) SHA1(e4cb8d259446d0614c0c8f097f97dcf21869782e) )
306 	ROM_RELOAD(            0xF000, 0x800 )
307 	ROM_LOAD( "030594.d1", 0x7800, 0x800, CRC(27979e96) SHA1(55ffe3094c6764e6b99ee148e3dd730ca263fa3a) )
308 	ROM_RELOAD(            0xF800, 0x800 )
309 
310 	ROM_REGION( 0x0200, REGION_GFX1, ROMREGION_DISPOSE ) /* alpha numerics */
311 	ROM_LOAD( "030598.h2", 0x0000, 0x200, CRC(2a7c5fa0) SHA1(93a79e5948dfcd9b6c2ff390e85a43f7a8cac327) )
312 
313 	ROM_REGION( 0x0800, REGION_GFX2, ROMREGION_DISPOSE ) /* sprites */
314 	ROM_LOAD( "030599.m7", 0x0000, 0x800, CRC(0cd179ea) SHA1(e3c763f76e6103e5909e7b5a979206b262d6e96a) )
315 
316 	ROM_REGION( 0x0100, REGION_GFX3, ROMREGION_DISPOSE ) /* missiles */
317 	ROM_LOAD_NIB_LOW ( "030597.n5", 0x0000, 0x100, CRC(319ff49c) SHA1(ff4d8b20436179910bf30c720d98df4678f683a9) )
318 	ROM_LOAD_NIB_HIGH( "030596.m4", 0x0000, 0x100, CRC(30454ed0) SHA1(4216a54c13d9c4803f88f2de35cdee31290bb15e) )
319 
320 	ROM_REGION( 0x0800, REGION_USER1, 0 ) /* terrain */
321 	ROM_LOAD_NIB_LOW ( "030584.j5", 0x0000, 0x800, CRC(81f6e8a5) SHA1(ad77b469ed0c9d5dfaa221ecf47d0db4a7f7ac91) )
322 	ROM_LOAD_NIB_HIGH( "030585.k5", 0x0000, 0x800, CRC(b49bec3f) SHA1(b55d25230ec11c52e7b47d2c10194a49adbeb50a) )
323 
324 	ROM_REGION( 0x0100, REGION_USER2, 0 ) /* trapezoid */
325 	ROM_LOAD_NIB_LOW ( "030582.a6", 0x0000, 0x100, CRC(0eacd595) SHA1(5469e312a1f522ce0a61054b50895a5b1a3f19ba) )
326 	ROM_LOAD_NIB_HIGH( "030583.b6", 0x0000, 0x100, CRC(3edd6fbc) SHA1(0418ea78cf51e18c51087b43a41cd9e13aac0a16) )
327 
328 	ROM_REGION( 0x0300, REGION_PROMS, 0 )
329 	ROM_LOAD( "006559.c4", 0x0200, 0x100, CRC(5a8d0e42) SHA1(772220c4c24f18769696ddba26db2bc2e5b0909d) ) /* sync */
330 ROM_END
331 
332 
333 GAMEX( 1978, skyraid, 0, skyraid, skyraid, 0, ORIENTATION_FLIP_Y, "Atari", "Sky Raider", GAME_NO_SOUND | GAME_IMPERFECT_COLORS )
334