1 /*
2 
3 Pocket Gal Deluxe
4 Nihon System Inc., 1993
5 
6 This game runs on Data East hardware.
7 
8 PCB Layout
9 ----------
10 
11 DEC-22V0  DE-0378-2
12 |-------------------------------------|
13 |  M6295(2)  KG01.14F     DE102  62256|
14 |  M6295(1)  MAZ-03.13F          62256|
15 |                                     |
16 |   32.220MHz              KG00-2.12A |
17 |                                     |
18 |J           DE56              DE71   |
19 |A                                    |
20 |M     DE153            28MHz         |
21 |M                    6264     DE52   |
22 |A                    6264            |
23 |                                     |
24 |                                     |
25 |                                     |
26 |DSW1                   MAZ-01.3B     |
27 |     DE104  MAZ-02.2H                |
28 |DSW2                   MAZ-00.1B     |
29 |-------------------------------------|
30 
31 Notes:
32       - CPU is DE102. The clock input is 14.000MHz on pin 6
33         It's a custom-made encrypted 68000.
34         The package is a Quad Flat Pack, has 128 pins and is symmetrically square (1 1/4" square from tip to tip).
35       - M6295(1) clock: 2.01375MHz (32.220 / 16)
36         M6295(2) clock: 1.006875MHz (32.220 / 32)
37       - VSync: 58Hz
38 
39 
40     Driver by David Haywood and Bryan McPhail
41 
42 todo:
43     verify sound.
44 
45 */
46 
47 #include "driver.h"
48 #include "decocrpt.h"
49 #include "decoprot.h"
50 #include "deco16ic.h"
51 #include "vidhrdw/generic.h"
52 
53 VIDEO_START(pktgaldx);
54 VIDEO_UPDATE(pktgaldx);
55 
56 
pktgaldx_drawsprites(struct mame_bitmap * bitmap,const struct rectangle * cliprect)57 static void pktgaldx_drawsprites(struct mame_bitmap *bitmap,const struct rectangle *cliprect)
58 {
59 	int offs;
60 	int flipscreen=!flip_screen;
61 
62 	for (offs = 0;offs < 0x400;offs += 4)
63 	{
64 		int x,y,sprite,colour,multi,fx,fy,inc,flash,mult;
65 
66 		sprite = spriteram16[offs+1];
67 		if (!sprite) continue;
68 
69 		y = spriteram16[offs];
70 		flash=y&0x1000;
71 		if (flash && (cpu_getcurrentframe() & 1)) continue;
72 
73 		x = spriteram16[offs+2];
74 		colour = (x >>9) & 0x1f;
75 
76 		fx = y & 0x2000;
77 		fy = y & 0x4000;
78 		multi = (1 << ((y & 0x0600) >> 9)) - 1;	/* 1x, 2x, 4x, 8x height */
79 
80 		x = x & 0x01ff;
81 		y = y & 0x01ff;
82 		if (x >= 320) x -= 512;
83 		if (y >= 256) y -= 512;
84 		y = 240 - y;
85         x = 304 - x;
86 
87 		if (x>320) continue;
88 
89 		sprite &= ~multi;
90 		if (fy)
91 			inc = -1;
92 		else
93 		{
94 			sprite += multi;
95 			inc = 1;
96 		}
97 
98 		if (flipscreen)
99 		{
100 			y=240-y;
101 			x=304-x;
102 			if (fx) fx=0; else fx=1;
103 			if (fy) fy=0; else fy=1;
104 			mult=16;
105 		}
106 		else mult=-16;
107 
108 		while (multi >= 0)
109 		{
110 			drawgfx(bitmap,Machine->gfx[2],
111 					sprite - multi * inc,
112 					colour,
113 					fx,fy,
114 					x,y + mult * multi,
115 					cliprect,TRANSPARENCY_PEN,0);
116 
117 			multi--;
118 		}
119 	}
120 }
121 
pktgaldx_bank_callback(const int bank)122 static int pktgaldx_bank_callback(const int bank)
123 {
124 	return ((bank>>4) & 0x7) * 0x1000;
125 }
126 
127 
VIDEO_START(pktgaldx)128 VIDEO_START(pktgaldx)
129 {
130 	if (deco16_1_video_init())
131 		return 1;
132 
133 	deco16_set_tilemap_bank_callback(1,pktgaldx_bank_callback);
134 
135 	return 0;
136 }
137 
VIDEO_UPDATE(pktgaldx)138 VIDEO_UPDATE(pktgaldx)
139 {
140 	flip_screen_set( deco16_pf12_control[0]&0x80 );
141 	deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
142 
143 	fillbitmap(bitmap,Machine->pens[0x0],cliprect); /* not Confirmed */
144 	fillbitmap(priority_bitmap,0,NULL);
145 
146 	deco16_tilemap_2_draw(bitmap,cliprect,0,0);
147 	pktgaldx_drawsprites(bitmap,cliprect);
148 	deco16_tilemap_1_draw(bitmap,cliprect,0,0);
149 }
150 
151 
WRITE16_HANDLER(pktgaldx_nonbuffered_palette_w)152 WRITE16_HANDLER( pktgaldx_nonbuffered_palette_w )
153 {
154 	int r,g,b;
155 
156 	COMBINE_DATA(&paletteram16[offset]);
157 	if (offset&1) offset--;
158 
159 	b = (paletteram16[offset] >> 0) & 0xff;
160 	g = (paletteram16[offset+1] >> 8) & 0xff;
161 	r = (paletteram16[offset+1] >> 0) & 0xff;
162 
163 	palette_set_color(offset/2,r,g,b);
164 }
165 
166 
167 /**********************************************************************************/
168 
WRITE16_HANDLER(pktgaldx_oki_bank_w)169 static WRITE16_HANDLER(pktgaldx_oki_bank_w)
170 {
171 	OKIM6295_set_bank_base(1, (data & 3) * 0x40000);
172 }
173 
174 /**********************************************************************************/
175 
176 
MEMORY_READ16_START(pktgaldx_readmem)177 static MEMORY_READ16_START( pktgaldx_readmem )
178     { 0x000000, 0x07ffff, MRA16_ROM },
179 	{ 0x100000, 0x100fff, MRA16_RAM },
180 	{ 0x102000, 0x102fff, MRA16_RAM },
181 	{ 0x110000, 0x1107ff, MRA16_RAM },
182 	{ 0x112000, 0x1127ff, MRA16_RAM },
183 	{ 0x120000, 0x1207ff, MRA16_RAM },
184 	{ 0x130000, 0x130fff, MRA16_RAM },
185 	{ 0x140006, 0x140007, OKIM6295_status_0_lsb_r },
186 	{ 0x150006, 0x150007, OKIM6295_status_1_lsb_r },
187 	{ 0x167800, 0x167fff, deco16_104_pktgaldx_prot_r },
188 	{ 0x170000, 0x17ffff, MRA16_RAM },
189 MEMORY_END
190 
191 static MEMORY_WRITE16_START( pktgaldx_writemem )
192     { 0x000000, 0x07ffff, MWA16_ROM },
193 	{ 0x100000, 0x100fff, deco16_pf1_data_w, &deco16_pf1_data },
194 	{ 0x102000, 0x102fff, deco16_pf2_data_w, &deco16_pf2_data },
195 	{ 0x110000, 0x1107ff, MWA16_RAM, &deco16_pf1_rowscroll },
196 	{ 0x112000, 0x1127ff, MWA16_RAM, &deco16_pf2_rowscroll },
197 	{ 0x120000, 0x1207ff, MWA16_RAM, &spriteram16, &spriteram_size },
198 	{ 0x130000, 0x130fff, pktgaldx_nonbuffered_palette_w, &paletteram16 },
199 	{ 0x140000, 0x14000f, OKIM6295_data_0_lsb_w },
200 	{ 0x150000, 0x15000f, OKIM6295_data_1_lsb_w },
201 	{ 0x161800, 0x16180f, MWA16_RAM, &deco16_pf12_control },
202 	{ 0x164800, 0x164801, pktgaldx_oki_bank_w },
203 	{ 0x167800, 0x167fff, deco16_104_pktgaldx_prot_w, &deco16_prot_ram },
204 	{ 0x170000, 0x17ffff, MWA16_RAM },
205 MEMORY_END
206 
207 
208 
209 /**********************************************************************************/
210 
211 INPUT_PORTS_START( pktgaldx )
212 	PORT_START	/* 16bit */
213 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
214 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
215 	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_SERVICE1 )
216 	PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_VBLANK )
217 	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN )
218 	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNKNOWN )
219 	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
220 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
221 	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNKNOWN )
222 
223 	PORT_START	/* 16bit */
224 	PORT_DIPNAME( 0x0007, 0x0007, DEF_STR( Coin_A ) )
225 	PORT_DIPSETTING(      0x0000, DEF_STR( 3C_1C ) )
226 	PORT_DIPSETTING(      0x0001, DEF_STR( 2C_1C ) )
227 	PORT_DIPSETTING(      0x0007, DEF_STR( 1C_1C ) )
228 	PORT_DIPSETTING(      0x0006, DEF_STR( 1C_2C ) )
229 	PORT_DIPSETTING(      0x0005, DEF_STR( 1C_3C ) )
230 	PORT_DIPSETTING(      0x0004, DEF_STR( 1C_4C ) )
231 	PORT_DIPSETTING(      0x0003, DEF_STR( 1C_5C ) )
232 	PORT_DIPSETTING(      0x0002, DEF_STR( 1C_6C ) )
233 	PORT_DIPNAME( 0x0038, 0x0038, DEF_STR( Coin_B ) )
234 	PORT_DIPSETTING(      0x0000, DEF_STR( 3C_1C ) )
235 	PORT_DIPSETTING(      0x0008, DEF_STR( 2C_1C ) )
236 	PORT_DIPSETTING(      0x0038, DEF_STR( 1C_1C ) )
237 	PORT_DIPSETTING(      0x0030, DEF_STR( 1C_2C ) )
238 	PORT_DIPSETTING(      0x0028, DEF_STR( 1C_3C ) )
239 	PORT_DIPSETTING(      0x0020, DEF_STR( 1C_4C ) )
240 	PORT_DIPSETTING(      0x0018, DEF_STR( 1C_5C ) )
241 	PORT_DIPSETTING(      0x0010, DEF_STR( 1C_6C ) )
242 	PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Flip_Screen ) )
243 	PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
244 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
245 	PORT_DIPNAME( 0x0080, 0x0080, "2 Coins to Start, 1 to Continue" )
246 	PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
247 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
248 	PORT_DIPNAME( 0x0300, 0x0300, DEF_STR( Lives ) )
249 	PORT_DIPSETTING(      0x0000, "2" )
250 	PORT_DIPSETTING(      0x0100, "3" )
251 	PORT_DIPSETTING(      0x0300, "4" )
252 	PORT_DIPSETTING(      0x0200, "5" )
253 	PORT_DIPNAME( 0x0c00, 0x0c00, "Time"  ) /* Listed as "Difficulty" */
254 	PORT_DIPSETTING(      0x0000, "60" )
255 	PORT_DIPSETTING(      0x0400, "80" )
256 	PORT_DIPSETTING(      0x0c00, "100" )
257 	PORT_DIPSETTING(      0x0800, "120" )
258 	PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
259 	PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
260 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
261 	PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Free_Play ) )
262 	PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
263 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
264 	PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
265 	PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
266 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
267 	PORT_DIPNAME( 0x8000, 0x0000, DEF_STR( Demo_Sounds ) )
268 	PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
269 	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
270 
271 	PORT_START	/* 16bit */
272 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER1 )
273 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER1 )
274 	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER1 )
275 	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
276 	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
277 	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
278 	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
279 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )
280 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER2 )
281 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER2 )
282 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER2 )
283 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
284 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
285 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
286 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
287 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )
288 INPUT_PORTS_END
289 
290 static struct GfxLayout tile_8x8_layout =
291 {
292 	8,8,
293 	RGN_FRAC(1,2),
294 	4,
295 	{ RGN_FRAC(1,2)+8,RGN_FRAC(1,2)+0,RGN_FRAC(0,2)+8,RGN_FRAC(0,2)+0 },
296 	{ 0, 1, 2, 3, 4, 5, 6, 7 },
297 	{ 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
298 	8*16
299 };
300 
301 static struct GfxLayout tile_16x16_layout =
302 {
303 	16,16,
304 	RGN_FRAC(1,2),
305 	4,
306 	{ RGN_FRAC(1,2)+8,RGN_FRAC(1,2)+0,RGN_FRAC(0,2)+8,RGN_FRAC(0,2)+0 },
307 	{ 256,257,258,259,260,261,262,263,0, 1, 2, 3, 4, 5, 6, 7 },
308 	{ 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,8*16,9*16,10*16,11*16,12*16,13*16,14*16,15*16 },
309 	32*16
310 };
311 
312 static struct GfxLayout spritelayout =
313 {
314 	16,16,
315 	RGN_FRAC(1,1),
316 	4,
317 	{ 24,8,16,0 },
318 	{ 512,513,514,515,516,517,518,519, 0, 1, 2, 3, 4, 5, 6, 7 },
319 	{ 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
320 	  8*32, 9*32,10*32,11*32,12*32,13*32,14*32,15*32},
321 	32*32
322 };
323 
324 static struct GfxDecodeInfo gfxdecodeinfo[] =
325 {
326 	{ REGION_GFX1, 0, &tile_8x8_layout,     0, 32 },	/* Tiles (8x8) */
327 	{ REGION_GFX1, 0, &tile_16x16_layout,   0, 32 },	/* Tiles (16x16) */
328 	{ REGION_GFX2, 0, &spritelayout,      512, 32 },	/* Sprites (16x16) */
329 	{ -1 } /* end of array */
330 };
331 
332 
333 static struct OKIM6295interface okim6295_interface =
334 {
335 	2,              /* 2 chips */
336 	{ 32220000/32/132, 32220000/16/132 },/* Frequency */
337 	{ REGION_SOUND1, REGION_SOUND2 },
338 	{ 95, 40 } /* Note!  Keep chip 1 (voices) louder than chip 2 */
339 };
340 
341 
342 static MACHINE_DRIVER_START( pktgaldx )
343 	/* basic machine hardware */
344 	MDRV_CPU_ADD(M68000, 14000000)
345 	MDRV_CPU_MEMORY(pktgaldx_readmem, pktgaldx_writemem)
346 	MDRV_CPU_VBLANK_INT(irq6_line_hold,1)
347 
348 	MDRV_FRAMES_PER_SECOND(58)
349 	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)
350 
351 	/* video hardware */
352 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_NEEDS_6BITS_PER_GUN)
353 	MDRV_SCREEN_SIZE(40*8, 32*8)
354 	MDRV_VISIBLE_AREA(0*8, 40*8-1, 1*8, 31*8-1)
355 	MDRV_PALETTE_LENGTH(4096)
356 	MDRV_GFXDECODE(gfxdecodeinfo)
357 
358 	MDRV_VIDEO_START(pktgaldx)
359 	MDRV_VIDEO_UPDATE(pktgaldx)
360 
361 	/* sound hardware */
362 	MDRV_SOUND_ADD(OKIM6295, okim6295_interface)
363 MACHINE_DRIVER_END
364 
365 
366 ROM_START( pktgaldx )
367 	ROM_REGION( 0x80000, REGION_CPU1, 0 ) /* DE102 code (encrypted) */
368 	ROM_LOAD16_WORD_SWAP( "ke00-2.12a",    0x00000, 0x80000, CRC(b04baf3a) SHA1(680d1b4ab4b6edef36cd96a60539fb7c2dac9637) )
369 
370 	ROM_REGION( 0x100000, REGION_GFX1, ROMREGION_DISPOSE )
371 	ROM_LOAD( "maz-02.2h",    0x00000, 0x100000, CRC(c9d35a59) SHA1(07b44c7d7d76b668b4d6ca5672bd1c2910228e68) )
372 
373 	ROM_REGION( 0x100000, REGION_GFX2, ROMREGION_DISPOSE )
374 	ROM_LOAD16_BYTE( "maz-00.1b",    0x000000, 0x080000, CRC(fa3071f4) SHA1(72e7d920e9ca94f8cb166007a9e9e5426a201af8) )
375 	ROM_LOAD16_BYTE( "maz-01.3b",    0x000001, 0x080000, CRC(4934fe21) SHA1(b852249f59906d69d32160ebaf9b4781193227e4) )
376 
377 	ROM_REGION( 0x20000, REGION_SOUND1, 0 ) /* Oki samples */
378 	ROM_LOAD( "ke01.14f",    0x00000, 0x20000, CRC(8a106263) SHA1(229ab17403c2b8f4e89a90a8cda2f3c3a4b55d9e) )
379 
380 	ROM_REGION( 0x100000, REGION_SOUND2, 0 ) /* Oki samples (banked?) */
381 	ROM_LOAD( "maz-03.13f",    0x00000, 0x100000, CRC(a313c964) SHA1(4a3664c4e2c44a017a0ab6a6d4361799cbda57b5) )
382 ROM_END
383 
384 ROM_START( pktgaldj )
385 	ROM_REGION( 0x80000, REGION_CPU1, 0 ) /* DE102 code (encrypted) */
386 	ROM_LOAD16_WORD_SWAP( "kg00-2.12a",    0x00000, 0x80000, CRC(62dc4137) SHA1(23887dc3f6e7c4cdcb1bf4f4c87fe3cbe8cdbe69) )
387 
388 	ROM_REGION( 0x100000, REGION_GFX1, ROMREGION_DISPOSE )
389 	ROM_LOAD( "maz-02.2h",    0x00000, 0x100000, CRC(c9d35a59) SHA1(07b44c7d7d76b668b4d6ca5672bd1c2910228e68) )
390 
391 	ROM_REGION( 0x100000, REGION_GFX2, ROMREGION_DISPOSE )
392 	ROM_LOAD16_BYTE( "maz-00.1b",    0x000000, 0x080000, CRC(fa3071f4) SHA1(72e7d920e9ca94f8cb166007a9e9e5426a201af8) )
393 	ROM_LOAD16_BYTE( "maz-01.3b",    0x000001, 0x080000, CRC(4934fe21) SHA1(b852249f59906d69d32160ebaf9b4781193227e4) )
394 
395 	ROM_REGION( 0x20000, REGION_SOUND1, 0 ) /* Oki samples */
396 	ROM_LOAD( "ke01.14f",    0x00000, 0x20000, CRC(8a106263) SHA1(229ab17403c2b8f4e89a90a8cda2f3c3a4b55d9e) )
397 
398 	ROM_REGION( 0x100000, REGION_SOUND2, 0 ) /* Oki samples (banked?) */
399 	ROM_LOAD( "maz-03.13f",    0x00000, 0x100000, CRC(a313c964) SHA1(4a3664c4e2c44a017a0ab6a6d4361799cbda57b5) )
400 ROM_END
401 
402 
403 extern void deco102_decrypt_cpu(int address_xor, int data_select_xor, int opcode_select_xor);
404 
DRIVER_INIT(pktgaldx)405 static DRIVER_INIT( pktgaldx )
406 {
407 	deco56_decrypt(REGION_GFX1);
408 	deco102_decrypt_cpu(0x42ba, 0x00, 0x00);
409 }
410 
411 GAME( 1992, pktgaldx, 0,        pktgaldx, pktgaldx, pktgaldx,  ROT0, "Data East Corporation", "Pocket Gal Deluxe (Euro v3.00)" )
412 GAME( 1993, pktgaldj, pktgaldx, pktgaldx, pktgaldx, pktgaldx,  ROT0, "Nihon System",          "Pocket Gal Deluxe (Japan v3.00)" )
413