1 /****************************************************************************
2 
3 Safari Rally by SNK/Taito
4 
5 Driver by Zsolt Vasvari
6 
7 
8 This hardware is a precursor to Phoenix.
9 
10 ----------------------------------
11 
12 CPU board
13 
14 76477        18MHz
15 
16               8080
17 
18 Video board
19 
20 
21  RL07  2114
22        2114
23        2114
24        2114
25        2114           RL01 RL02
26        2114           RL03 RL04
27        2114           RL05 RL06
28  RL08  2114
29 
30 11MHz
31 
32 ----------------------------------
33 
34 TODO:
35 
36 - SN76477 sound
37 
38 ****************************************************************************/
39 
40 #include "driver.h"
41 
42 
43 unsigned char *safarir_ram1, *safarir_ram2;
44 size_t safarir_ram_size;
45 
46 static unsigned char *safarir_ram;
47 static int safarir_scroll;
48 
49 
50 
WRITE_HANDLER(safarir_ram_w)51 WRITE_HANDLER( safarir_ram_w )
52 {
53 	safarir_ram[offset] = data;
54 }
55 
READ_HANDLER(safarir_ram_r)56 READ_HANDLER( safarir_ram_r )
57 {
58 	return safarir_ram[offset];
59 }
60 
61 
WRITE_HANDLER(safarir_scroll_w)62 WRITE_HANDLER( safarir_scroll_w )
63 {
64 	safarir_scroll = data;
65 }
66 
WRITE_HANDLER(safarir_ram_bank_w)67 WRITE_HANDLER( safarir_ram_bank_w )
68 {
69 	safarir_ram = data ? safarir_ram1 : safarir_ram2;
70 }
71 
72 
safarir_vh_screenrefresh(struct osd_bitmap * bitmap,int full_refresh)73 void safarir_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
74 {
75 	int offs;
76 
77 
78 	for (offs = safarir_ram_size/2 - 1;offs >= 0;offs--)
79 	{
80 		int sx,sy;
81 		UINT8 code;
82 
83 
84 		sx = offs % 32;
85 		sy = offs / 32;
86 
87 		code = safarir_ram[offs + safarir_ram_size/2];
88 
89 
90 		drawgfx(bitmap,Machine->gfx[0],
91 				code & 0x7f,
92 				code >> 7,
93 				0,0,
94 				(8*sx - safarir_scroll) & 0xff,8*sy,
95 				&Machine->visible_area,TRANSPARENCY_NONE,0);
96 	}
97 
98 
99 	/* draw the frontmost playfield. They are characters, but draw them as sprites */
100 
101 	for (offs = safarir_ram_size/2 - 1;offs >= 0;offs--)
102 	{
103 		int sx,sy,transparency;
104 		UINT8 code;
105 
106 
107 		sx = offs % 32;
108 		sy = offs / 32;
109 
110 		code = safarir_ram[offs];
111 
112 		transparency = (sx >= 3) ? TRANSPARENCY_PEN : TRANSPARENCY_NONE;
113 
114 
115 		drawgfx(bitmap,Machine->gfx[1],
116 				code & 0x7f,
117 				code >> 7,
118 				0,0,
119 				8*sx,8*sy,
120 				&Machine->visible_area,transparency,0);
121 	}
122 }
123 
124 
125 static unsigned char palette[] =
126 {
127 	0x00,0x00,0x00, /* black */
128 	0x80,0x80,0x80, /* gray */
129 	0xff,0xff,0xff, /* white */
130 };
131 static unsigned short colortable[] =
132 {
133 	0x00, 0x01,
134 	0x00, 0x02,
135 };
136 
init_palette(unsigned char * game_palette,unsigned short * game_colortable,const unsigned char * color_prom)137 static void init_palette(unsigned char *game_palette, unsigned short *game_colortable,const unsigned char *color_prom)
138 {
139 	memcpy(game_palette,palette,sizeof(palette));
140 	memcpy(game_colortable,colortable,sizeof(colortable));
141 }
142 
143 
144 static struct MemoryReadAddress readmem[] =
145 {
146 	{ 0x0000, 0x17ff, MRA_ROM },
147 	{ 0x2000, 0x27ff, safarir_ram_r },
148 	{ 0x3800, 0x38ff, input_port_0_r },
149 	{ 0x3c00, 0x3cff, input_port_1_r },
150 	{ -1 }  /* end of table */
151 };
152 
153 static struct MemoryWriteAddress writemem[] =
154 {
155 	{ 0x0000, 0x17ff, MWA_ROM },
156 	{ 0x2000, 0x27ff, safarir_ram_w, &safarir_ram1, &safarir_ram_size },
157 	{ 0x2800, 0x28ff, safarir_ram_bank_w },
158 	{ 0x2c00, 0x2cff, safarir_scroll_w },
159 	{ 0x3000, 0x30ff, MWA_NOP },	/* goes to SN76477 */
160 
161 	{ 0x8000, 0x87ff, MWA_NOP, &safarir_ram2 },	/* only here to initialize pointer */
162 	{ -1 }  /* end of table */
163 };
164 
165 
166 INPUT_PORTS_START( safarir )
167 	PORT_START	/* IN0 */
168 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
169 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START1 )
170 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START2 )
171 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
172 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
173 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_2WAY )
174 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_2WAY )
175 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
176 
177 	PORT_START	/* DSW0 */
178 	PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )
179 	PORT_DIPSETTING(    0x00, "3" )
180 	PORT_DIPSETTING(    0x01, "4" )
181 	PORT_DIPSETTING(    0x02, "5" )
182 	PORT_DIPSETTING(    0x03, "6" )
183 	PORT_DIPNAME( 0x0c, 0x04, "Acceleration Rate" )
184 	PORT_DIPSETTING(    0x00, "Slowest" )
185 	PORT_DIPSETTING(    0x04, "Slow" )
186 	PORT_DIPSETTING(    0x08, "Fast" )
187 	PORT_DIPSETTING(    0x0c, "Fastest" )
188 	PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) )
189 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
190 	PORT_DIPSETTING(    0x10, DEF_STR( On ) )
191 	PORT_DIPNAME( 0x60, 0x00, DEF_STR( Bonus_Life ) )
192 	PORT_DIPSETTING(    0x00, "3000" )
193 	PORT_DIPSETTING(    0x20, "5000" )
194 	PORT_DIPSETTING(    0x40, "7000" )
195 	PORT_DIPSETTING(    0x60, "9000" )
196 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_VBLANK )
197 INPUT_PORTS_END
198 
199 
200 
201 static struct GfxLayout charlayout =
202 {
203 	8,8,	/* 8*8 chars */
204 	128,	/* 128 characters */
205 	1,		/* 1 bit per pixel */
206 	{ 0 },
207 	{ 7, 6, 5, 4, 3, 2, 1, 0 },
208 	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
209 	8*8	/* every char takes 8 consecutive bytes */
210 };
211 
212 
213 static struct GfxDecodeInfo gfxdecodeinfo[] =
214 {
215 	{ REGION_GFX1, 0, &charlayout, 0, 2 },
216 	{ REGION_GFX2, 0, &charlayout, 0, 2 },
217 	{ -1 } /* end of array */
218 };
219 
220 
221 
222 static struct MachineDriver machine_driver_safarir =
223 {
224 	/* basic machine hardware */
225 	{
226 		{
227 			CPU_8080,
228 			3072000,	/* 3 Mhz ? */								\
229 			readmem,writemem,0,0,
230 			ignore_interrupt,1
231 		}
232 	},
233 	60, DEFAULT_REAL_60HZ_VBLANK_DURATION,
234 	1,      /* single CPU, no need for interleaving */
235 	0,	/* init machine */
236 
237 	/* video hardware */
238 	32*8, 32*8, { 0*8, 30*8-1, 0*8, 28*8-1 },
239 	gfxdecodeinfo,
240 	3,2*2,
241 	init_palette,
242 
243 	VIDEO_TYPE_RASTER,
244 	0,
245 	0,
246 	0,
247 	safarir_vh_screenrefresh,
248 
249 	/* sound hardware */
250 	0,0,0,0
251 };
252 
253 /***************************************************************************
254 
255   Game driver(s)
256 
257 ***************************************************************************/
258 
259 ROM_START( safarir )
260 	ROM_REGION( 0x10000, REGION_CPU1 )     /* 64k for main CPU */
261 	ROM_LOAD( "rl01",		0x0000, 0x0400, 0xcf7703c9 )
262 	ROM_LOAD( "rl02",		0x0400, 0x0400, 0x1013ecd3 )
263 	ROM_LOAD( "rl03",		0x0800, 0x0400, 0x84545894 )
264 	ROM_LOAD( "rl04",		0x0c00, 0x0400, 0x5dd12f96 )
265 	ROM_LOAD( "rl05",		0x1000, 0x0400, 0x935ed469 )
266 	ROM_LOAD( "rl06",		0x1400, 0x0400, 0x24c1cd42 )
267 
268 	ROM_REGION( 0x0400, REGION_GFX1 | REGIONFLAG_DISPOSE )
269 	ROM_LOAD( "rl08",		0x0000, 0x0400, 0xd6a50aac )
270 
271 	ROM_REGION( 0x0400, REGION_GFX2 | REGIONFLAG_DISPOSE )
272 	ROM_LOAD( "rl07",		0x0000, 0x0400, 0xba525203 )
273 ROM_END
274 
275 
276 GAMEX( ????, safarir, 0, safarir, safarir, 0, ROT90, "SNK", "Safari Rally", GAME_NO_SOUND | GAME_IMPERFECT_COLORS )
277