1 #include "driver.h"
2 #include "vidhrdw/generic.h"
3 
4 extern WRITE_HANDLER( pingpong_videoram_w );
5 extern WRITE_HANDLER( pingpong_colorram_w );
6 
7 extern PALETTE_INIT( pingpong );
8 extern VIDEO_START( pingpong );
9 extern VIDEO_UPDATE( pingpong );
10 
11 static int intenable;
12 
WRITE_HANDLER(coin_w)13 static WRITE_HANDLER( coin_w )
14 {
15 	/* bit 2 = irq enable, bit 3 = nmi enable */
16 	intenable = data & 0x0c;
17 
18 	/* bit 0/1 = coin counters */
19 	coin_counter_w(0,data & 1);
20 	coin_counter_w(1,data & 2);
21 
22 	/* other bits unknown */
23 }
24 
INTERRUPT_GEN(pingpong_interrupt)25 static INTERRUPT_GEN( pingpong_interrupt )
26 {
27 	if (cpu_getiloops() == 0)
28 	{
29 		if (intenable & 0x04) cpu_set_irq_line(0, 0, HOLD_LINE);
30 	}
31 	else if (cpu_getiloops() % 2)
32 	{
33 		if (intenable & 0x08) cpu_set_irq_line(0, IRQ_LINE_NMI, PULSE_LINE);
34 	}
35 }
36 
37 
38 
MEMORY_READ_START(readmem)39 static MEMORY_READ_START( readmem )
40 	{ 0x0000, 0x7fff, MRA_ROM },
41 	{ 0x8000, 0x87ff, MRA_RAM },
42 	{ 0x9000, 0x97ff, MRA_RAM },
43 	{ 0xa800, 0xa800, input_port_0_r },
44 	{ 0xa880, 0xa880, input_port_1_r },
45 	{ 0xa900, 0xa900, input_port_2_r },
46 	{ 0xa980, 0xa980, input_port_3_r },
47 MEMORY_END
48 
49 static MEMORY_WRITE_START( writemem )
50 	{ 0x0000, 0x7fff, MWA_ROM },
51 	{ 0x8000, 0x83ff, pingpong_colorram_w, &colorram },
52 	{ 0x8400, 0x87ff, pingpong_videoram_w, &videoram },
53 	{ 0x9000, 0x9002, MWA_RAM },
54 	{ 0x9003, 0x9052, MWA_RAM, &spriteram, &spriteram_size },
55 	{ 0x9053, 0x97ff, MWA_RAM },
56 	{ 0xa000, 0xa000, coin_w },	/* coin counters + irq enables */
57 	{ 0xa200, 0xa200, MWA_NOP },		/* SN76496 data latch */
58 	{ 0xa400, 0xa400, SN76496_0_w },	/* trigger read */
59 	{ 0xa600, 0xa600, watchdog_reset_w },
60 MEMORY_END
61 
62 
63 
64 INPUT_PORTS_START( pingpong )
65 	PORT_START	/* IN0 */
66 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
67 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED )
68 	PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
69 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 )
70 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 )
71 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 )
72 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 )
73 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
74 
75 	PORT_START	/* IN1 */
76 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
77 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_2WAY | IPF_PLAYER2 )
78 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT| IPF_2WAY | IPF_PLAYER2 )
79 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
80 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 )
81 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_2WAY )
82 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_2WAY )
83 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 )
84 
85 	PORT_START	/* DSW1 */
86 	PORT_DIPNAME( 0x0F, 0x0F, DEF_STR( Coin_B ) )
87 	PORT_DIPSETTING(    0x04, DEF_STR( 4C_1C ) )
88 	PORT_DIPSETTING(    0x0A, DEF_STR( 3C_1C ) )
89 	PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
90 	PORT_DIPSETTING(    0x02, DEF_STR( 3C_2C ) )
91 	PORT_DIPSETTING(    0x08, DEF_STR( 4C_3C ) )
92 	PORT_DIPSETTING(    0x0F, DEF_STR( 1C_1C ) )
93 	PORT_DIPSETTING(    0x0C, DEF_STR( 3C_4C ) )
94 	PORT_DIPSETTING(    0x0E, DEF_STR( 2C_3C ) )
95 	PORT_DIPSETTING(    0x07, DEF_STR( 1C_2C ) )
96 	PORT_DIPSETTING(    0x06, DEF_STR( 2C_5C ) )
97 	PORT_DIPSETTING(    0x0B, DEF_STR( 1C_3C ) )
98 	PORT_DIPSETTING(    0x03, DEF_STR( 1C_4C ) )
99 	PORT_DIPSETTING(    0x0D, DEF_STR( 1C_5C ) )
100 	PORT_DIPSETTING(    0x05, DEF_STR( 1C_6C ) )
101 	PORT_DIPSETTING(    0x09, DEF_STR( 1C_7C ) )
102 	PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
103 	PORT_DIPNAME( 0xF0, 0xF0, DEF_STR( Coin_A ) )
104 	PORT_DIPSETTING(    0x40, DEF_STR( 4C_1C ) )
105 	PORT_DIPSETTING(    0xA0, DEF_STR( 3C_1C ) )
106 	PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
107 	PORT_DIPSETTING(    0x20, DEF_STR( 3C_2C ) )
108 	PORT_DIPSETTING(    0x80, DEF_STR( 4C_3C ) )
109 	PORT_DIPSETTING(    0xF0, DEF_STR( 1C_1C ) )
110 	PORT_DIPSETTING(    0xC0, DEF_STR( 3C_4C ) )
111 	PORT_DIPSETTING(    0xE0, DEF_STR( 2C_3C ) )
112 	PORT_DIPSETTING(    0x70, DEF_STR( 1C_2C ) )
113 	PORT_DIPSETTING(    0x60, DEF_STR( 2C_5C ) )
114 	PORT_DIPSETTING(    0xB0, DEF_STR( 1C_3C ) )
115 	PORT_DIPSETTING(    0x30, DEF_STR( 1C_4C ) )
116 	PORT_DIPSETTING(    0xD0, DEF_STR( 1C_5C ) )
117 	PORT_DIPSETTING(    0x50, DEF_STR( 1C_6C ) )
118 	PORT_DIPSETTING(    0x90, DEF_STR( 1C_7C ) )
119 	PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
120 
121 	PORT_START	/* DSW2 */
122 	PORT_DIPNAME( 0x01, 0x00, DEF_STR( Demo_Sounds ) )
123 	PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
124 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
125 	PORT_DIPNAME( 0x06, 0x06, DEF_STR( Difficulty ) )
126 	PORT_DIPSETTING(    0x06, "Easy" )
127 	PORT_DIPSETTING(    0x02, "Normal" )
128 	PORT_DIPSETTING(    0x04, "Difficult" )
129 	PORT_DIPSETTING(    0x00, "Very Difficult" )
130 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
131 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
132 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED )
133 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
134 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
135 INPUT_PORTS_END
136 
137 
138 
139 static struct GfxLayout charlayout =
140 {
141 	8,8,		/* 8*8 characters */
142 	512,		/* 512 characters */
143 	2,		/* 2 bits per pixel */
144 	{ 4, 0 },	/* the bitplanes are packed in one nibble */
145 	{ 3, 2, 1, 0, 8*8+3, 8*8+2, 8*8+1, 8*8+0 },	/* x bit */
146 	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8   },     /* y bit */
147 	16*8	/* every char takes 16 consecutive bytes */
148 };
149 
150 static struct GfxLayout spritelayout =
151 {
152 	16,16,		/* 16*16 sprites */
153 	128,		/* 128 sprites */
154 	2,		/* 2 bits per pixel */
155 	{ 4, 0 },	/* the bitplanes are packed in one nibble */
156 	{ 12*16+3,12*16+2,12*16+1,12*16+0,
157 	   8*16+3, 8*16+2, 8*16+1, 8*16+0,
158 	   4*16+3, 4*16+2, 4*16+1, 4*16+0,
159 	        3,      2,      1,      0 },			/* x bit */
160 	{  0*8,  1*8,  2*8,  3*8,  4*8,  5*8,  6*8,  7*8,
161 	  32*8, 33*8, 34*8, 35*8, 36*8, 37*8, 38*8, 39*8  },    /* y bit */
162 	64*8	/* every char takes 64 consecutive bytes */
163 };
164 
165 static struct GfxDecodeInfo gfxdecodeinfo[] =
166 {
167 	{ REGION_GFX1, 0, &charlayout,         0, 64 },
168 	{ REGION_GFX2, 0, &spritelayout,    64*4, 64 },
169 	{ -1 } /* end of array */
170 };
171 
172 
173 
174 static struct SN76496interface sn76496_interface =
175 {
176 	1,			/* 1 chip */
177 	{ 18432000/8 },	/* 2.304 MHz */
178 	{ 100 }
179 };
180 
181 
182 static MACHINE_DRIVER_START( pingpong )
183 
184 	/* basic machine hardware */
185 	MDRV_CPU_ADD(Z80,18432000/6)		/* 3.072 MHz (probably) */
186 	MDRV_CPU_MEMORY(readmem,writemem)
187 	MDRV_CPU_VBLANK_INT(pingpong_interrupt,16)	/* 1 IRQ + 8 NMI */
188 
189 	MDRV_FRAMES_PER_SECOND(60)
190 	MDRV_VBLANK_DURATION(DEFAULT_60HZ_VBLANK_DURATION)
191 
192 	/* video hardware */
193 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
194 	MDRV_SCREEN_SIZE(32*8, 32*8)
195 	MDRV_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
196 	MDRV_GFXDECODE(gfxdecodeinfo)
197 	MDRV_PALETTE_LENGTH(32)
198 	MDRV_COLORTABLE_LENGTH(64*4+64*4)
199 
200 	MDRV_PALETTE_INIT(pingpong)
201 	MDRV_VIDEO_START(pingpong)
202 	MDRV_VIDEO_UPDATE(pingpong)
203 
204 	/* sound hardware */
205 	MDRV_SOUND_ADD(SN76496, sn76496_interface)
206 MACHINE_DRIVER_END
207 
208 
209 
210 /***************************************************************************
211 
212   Game driver(s)
213 
214 ***************************************************************************/
215 
216 ROM_START( pingpong )
217 	ROM_REGION( 0x10000, REGION_CPU1, 0 )	/* 64k for code */
218 	ROM_LOAD( "pp_e04.rom",   0x0000, 0x4000, CRC(18552f8f) SHA1(cb03659b5e8a68003e72182a20979384d829280f) )
219 	ROM_LOAD( "pp_e03.rom",   0x4000, 0x4000, CRC(ae5f01e8) SHA1(f0d6a2c64822f2662fed3f601e279db18246f894) )
220 
221 	ROM_REGION( 0x2000, REGION_GFX1, ROMREGION_DISPOSE )
222 	ROM_LOAD( "pp_e01.rom",   0x0000, 0x2000, CRC(d1d6f090) SHA1(7b7d7cb90bed746dda871227463145263e4b0c5a) )
223 
224 	ROM_REGION( 0x2000, REGION_GFX2, ROMREGION_DISPOSE )
225 	ROM_LOAD( "pp_e02.rom",   0x0000, 0x2000, CRC(33c687e0) SHA1(7c90de4d163d2ffad00c8cb6a194fa6125a4f4c1) )
226 
227 	ROM_REGION( 0x0220, REGION_PROMS, 0 )
228 	ROM_LOAD( "pingpong.3j",  0x0000, 0x0020, CRC(3e04f06e) SHA1(a642c350f148e062d56eb2a2fc53c470603000e3) ) /* palette (this might be bad) */
229 	ROM_LOAD( "pingpong.11j", 0x0020, 0x0100, CRC(09d96b08) SHA1(81405e33eacc47f91ea4c7221d122f7e6f5b1e5d) ) /* sprites */
230 	ROM_LOAD( "pingpong.5h",  0x0120, 0x0100, CRC(8456046a) SHA1(8226f1325c14eb8aed5cd3c3d6bad9f9fd88c5fa) ) /* characters */
231 ROM_END
232 
233 
234 
235 GAME( 1985, pingpong, 0, pingpong, pingpong, 0, ROT0, "Konami", "Ping Pong" )
236