1 /***************************************************************************
2
3 Mysterious Stones
4
5 driver by Nicola Salmoria
6
7 Notes:
8 - The subtitle of the two sets is slightly different:
9 "dr john s adventure" vs. "dr kick in adventure".
10 The Dr John's is a bug fix. See the routine at 4376/4384 for example. The
11 old set thrashes the Y register, the new one saves in on the stack. The
12 newer set also resets the sound chips more often.
13
14 ***************************************************************************/
15
16 #include "driver.h"
17 #include "vidhrdw/generic.h"
18
19
20 extern UINT8 *mystston_videoram2;
21
22 extern WRITE_HANDLER( mystston_videoram_w );
23 extern WRITE_HANDLER( mystston_videoram2_w );
24 extern WRITE_HANDLER( mystston_scroll_w );
25 extern WRITE_HANDLER( mystston_control_w );
26
27 extern PALETTE_INIT( mystston );
28 extern VIDEO_START( mystston );
29 extern VIDEO_UPDATE( mystston );
30
31
32 static int VBLK = 0x80;
33 static int soundlatch;
34
35
WRITE_HANDLER(mystston_soundlatch_w)36 static WRITE_HANDLER( mystston_soundlatch_w )
37 {
38 soundlatch = data;
39 }
40
WRITE_HANDLER(mystston_soundcontrol_w)41 static WRITE_HANDLER( mystston_soundcontrol_w )
42 {
43 static int last;
44
45 /* bit 5 goes to 8910 #0 BDIR pin */
46 if ((last & 0x20) == 0x20 && (data & 0x20) == 0x00)
47 {
48 /* bit 4 goes to the 8910 #0 BC1 pin */
49 if (last & 0x10)
50 AY8910_control_port_0_w(0,soundlatch);
51 else
52 AY8910_write_port_0_w(0,soundlatch);
53 }
54 /* bit 7 goes to 8910 #1 BDIR pin */
55 if ((last & 0x80) == 0x80 && (data & 0x80) == 0x00)
56 {
57 /* bit 6 goes to the 8910 #1 BC1 pin */
58 if (last & 0x40)
59 AY8910_control_port_1_w(0,soundlatch);
60 else
61 AY8910_write_port_1_w(0,soundlatch);
62 }
63
64 last = data;
65 }
66
READ_HANDLER(port3_r)67 static READ_HANDLER( port3_r )
68 {
69 int port = readinputport(3);
70
71 return port | VBLK;
72 }
73
WRITE_HANDLER(mystston_irq_reset_w)74 static WRITE_HANDLER( mystston_irq_reset_w )
75 {
76 cpu_set_irq_line(0, 0, CLEAR_LINE);
77 }
78
79
MEMORY_READ_START(readmem)80 static MEMORY_READ_START( readmem )
81 { 0x0000, 0x077f, MRA_RAM },
82 { 0x0800, 0x0fff, MRA_RAM }, /* work RAM? */
83 { 0x1000, 0x1fff, MRA_RAM },
84 { 0x2000, 0x2000, input_port_0_r },
85 { 0x2010, 0x2010, input_port_1_r },
86 { 0x2020, 0x2020, input_port_2_r },
87 { 0x2030, 0x2030, port3_r },
88 { 0x4000, 0xffff, MRA_ROM },
89 MEMORY_END
90
91 static MEMORY_WRITE_START( writemem )
92 { 0x0000, 0x077f, MWA_RAM },
93 { 0x0780, 0x07df, MWA_RAM, &spriteram, &spriteram_size },
94 { 0x07e0, 0x07ff, MWA_RAM },
95 { 0x0800, 0x0fff, MWA_RAM }, /* work RAM? */
96 { 0x1000, 0x17ff, &mystston_videoram_w, &videoram },
97 { 0x1800, 0x1bff, &mystston_videoram2_w, &mystston_videoram2 },
98 { 0x1c00, 0x1fff, MWA_RAM }, /* work RAM? This gets copied to videoram */
99 { 0x2000, 0x2000, mystston_control_w }, /* text color, flip screen & coin counters */
100 { 0x2010, 0x2010, mystston_irq_reset_w },
101 { 0x2020, 0x2020, mystston_scroll_w },
102 { 0x2030, 0x2030, mystston_soundlatch_w },
103 { 0x2040, 0x2040, mystston_soundcontrol_w },
104 { 0x2060, 0x2077, paletteram_BBGGGRRR_w, &paletteram },
105 { 0x4000, 0xffff, MWA_ROM },
106 MEMORY_END
107
108
109 INPUT_PORTS_START( mystston )
110 PORT_START /* IN0 */
111 PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY )
112 PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY )
113 PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY )
114 PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY )
115 PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
116 PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
117 PORT_BIT_IMPULSE( 0x40, IP_ACTIVE_LOW, IPT_COIN1, 1 )
118 PORT_BIT_IMPULSE( 0x80, IP_ACTIVE_LOW, IPT_COIN2, 1 )
119
120 PORT_START /* IN1 */
121 PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL )
122 PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_COCKTAIL )
123 PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_COCKTAIL )
124 PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_COCKTAIL )
125 PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL )
126 PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
127 PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
128 PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
129
130 PORT_START /* DSW1 */
131 PORT_DIPNAME(0x01, 0x01, DEF_STR( Lives ) )
132 PORT_DIPSETTING( 0x01, "3" )
133 PORT_DIPSETTING( 0x00, "5" )
134 PORT_DIPNAME(0x02, 0x02, DEF_STR( Difficulty ) )
135 PORT_DIPSETTING( 0x02, "Easy" )
136 PORT_DIPSETTING( 0x00, "Hard" )
137 PORT_DIPNAME(0x04, 0x00, DEF_STR( Demo_Sounds ) )
138 PORT_DIPSETTING( 0x04, DEF_STR( Off ) )
139 PORT_DIPSETTING( 0x00, DEF_STR( On ) )
140 PORT_BIT( 0xf8, IP_ACTIVE_LOW, IPT_UNUSED )
141
142 PORT_START /* DSW2 */
143 PORT_DIPNAME(0x03, 0x03, DEF_STR( Coin_A ) )
144 PORT_DIPSETTING( 0x00, DEF_STR( 2C_1C ) )
145 PORT_DIPSETTING( 0x03, DEF_STR( 1C_1C ) )
146 PORT_DIPSETTING( 0x02, DEF_STR( 1C_2C ) )
147 PORT_DIPSETTING( 0x01, DEF_STR( 1C_3C ) )
148 PORT_DIPNAME(0x0c, 0x0c, DEF_STR( Coin_B ) )
149 PORT_DIPSETTING( 0x00, DEF_STR( 2C_1C ) )
150 PORT_DIPSETTING( 0x0c, DEF_STR( 1C_1C ) )
151 PORT_DIPSETTING( 0x08, DEF_STR( 1C_2C ) )
152 PORT_DIPSETTING( 0x04, DEF_STR( 1C_3C ) )
153 PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
154 PORT_DIPNAME(0x20, 0x00, DEF_STR( Flip_Screen ) )
155 PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
156 PORT_DIPSETTING( 0x20, DEF_STR( On ) )
157 PORT_DIPNAME(0x40, 0x00, DEF_STR( Cabinet ) )
158 PORT_DIPSETTING( 0x00, DEF_STR( Upright ) )
159 PORT_DIPSETTING( 0x40, DEF_STR( Cocktail ) )
160 PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) // VBLANK
161 INPUT_PORTS_END
162
163
164 static struct GfxLayout charlayout =
165 {
166 8,8,
167 RGN_FRAC(1,3),
168 3,
169 { RGN_FRAC(2,3), RGN_FRAC(1,3), RGN_FRAC(0,3) },
170 { 0, 1, 2, 3, 4, 5, 6, 7 },
171 { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
172 8*8
173 };
174
175 static struct GfxLayout spritelayout =
176 {
177 16,16,
178 RGN_FRAC(1,3),
179 3,
180 { RGN_FRAC(2,3), RGN_FRAC(1,3), RGN_FRAC(0,3) },
181 { 16*8+0, 16*8+1, 16*8+2, 16*8+3, 16*8+4, 16*8+5, 16*8+6, 16*8+7,
182 0, 1, 2, 3, 4, 5, 6, 7 },
183 { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
184 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
185 32*8
186 };
187
188 static struct GfxDecodeInfo gfxdecodeinfo[] =
189 {
190 { REGION_GFX1, 0, &charlayout, 3*8, 4 },
191 { REGION_GFX2, 0, &spritelayout, 2*8, 1 },
192 { REGION_GFX1, 0, &spritelayout, 0*8, 2 },
193 { -1 } /* end of array */
194 };
195
196
197 static struct AY8910interface ay8910_interface =
198 {
199 2, // 2 chips
200 12000000/8, // 1.5 MHz
201 { 30, 30 },
202 { 0 },
203 { 0 },
204 { 0 },
205 { 0 }
206 };
207
208
INTERRUPT_GEN(mystston_interrupt)209 static INTERRUPT_GEN( mystston_interrupt )
210 {
211 int scanline = 271 - cpu_getiloops();
212 static int coin;
213
214 /* Inserting a coin triggers an NMI */
215 if ((readinputport(0) & 0xc0) != 0xc0)
216 {
217 if (coin == 0)
218 {
219 coin = 1;
220 nmi_line_pulse();
221 return;
222 }
223 }
224 else coin = 0;
225
226 /* VBLK is lowered on scanline 8 */
227 if (scanline == 8)
228 VBLK = 0;
229
230 /* VBLK is raised on scanline 248 */
231 if (scanline == 248)
232 VBLK = 0x80;
233
234 /* IMS is triggered every time VLOC line 3 is raised,
235 as VLOC counter starts at 16, effectively every 16 scanlines */
236 if ((scanline % 16) == 0)
237 cpu_set_irq_line(0, 0, HOLD_LINE);
238 }
239
240
241 static MACHINE_DRIVER_START( mystston )
242
243 /* basic machine hardware */
244 MDRV_CPU_ADD(M6502, 12000000/8) // 1.5 MHz
245 MDRV_CPU_MEMORY(readmem, writemem)
246 MDRV_CPU_VBLANK_INT(mystston_interrupt, 272)
247
248 MDRV_FRAMES_PER_SECOND(((12000000.0 / 256.0) / 3.0) / 272.0)
249 MDRV_VBLANK_DURATION(0)
250
251 /* video hardware */
252 MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
253 MDRV_SCREEN_SIZE(32*8, 32*8)
254 MDRV_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
255 MDRV_GFXDECODE(gfxdecodeinfo)
256 MDRV_PALETTE_LENGTH(24+32)
257
258 MDRV_PALETTE_INIT(mystston)
259 MDRV_VIDEO_START(mystston)
260 MDRV_VIDEO_UPDATE(mystston)
261
262 /* sound hardware */
263 MDRV_SOUND_ADD(AY8910, ay8910_interface)
264 MACHINE_DRIVER_END
265
266
267 ROM_START( mystston )
268 ROM_REGION( 0x10000, REGION_CPU1, 0 ) /* 64k for code */
269 ROM_LOAD( "rom6.bin", 0x4000, 0x2000, CRC(7bd9c6cd) SHA1(4d14edc783ba1a6c01d2fb9ea29ec85b8fec3c3b) )
270 ROM_LOAD( "rom5.bin", 0x6000, 0x2000, CRC(a83f04a6) SHA1(d8cdf310511c1fef4fbde80ef2161fda00f965d7) )
271 ROM_LOAD( "rom4.bin", 0x8000, 0x2000, CRC(46c73714) SHA1(5b9ac3a35aeeea6a0cd2d838c144925d83b36a7f) )
272 ROM_LOAD( "rom3.bin", 0xa000, 0x2000, CRC(34f8b8a3) SHA1(a270f6665a9f76f97ac02201d51fe2817e6e8f22) )
273 ROM_LOAD( "rom2.bin", 0xc000, 0x2000, CRC(bfd22cfc) SHA1(137cd61c8b1e997e7e50edd57f1671031d8e3ac5) )
274 ROM_LOAD( "rom1.bin", 0xe000, 0x2000, CRC(fb163e38) SHA1(d6f02e90bfd9badd7751bc0a87fdfdd1d0a7e202) )
275
276 ROM_REGION( 0x0c000, REGION_GFX1, ROMREGION_DISPOSE )
277 ROM_LOAD( "ms6", 0x00000, 0x2000, CRC(85c83806) SHA1(cdfed6c224754e8f79b154533b06b7de4a44b4d3) )
278 ROM_LOAD( "ms9", 0x02000, 0x2000, CRC(b146c6ab) SHA1(712c0c17780f222be5c8b09185a22e900ab23944) )
279 ROM_LOAD( "ms7", 0x04000, 0x2000, CRC(d025f84d) SHA1(eaaaa0bde3db850098d04a0af85993026e503fc5) )
280 ROM_LOAD( "ms10", 0x06000, 0x2000, CRC(d85015b5) SHA1(f4afab248dfde354650e59fadd5ab9616b04dac1) )
281 ROM_LOAD( "ms8", 0x08000, 0x2000, CRC(53765d89) SHA1(c8bfc311123b076dccae9f7e3b95460bf9fc843d) )
282 ROM_LOAD( "ms11", 0x0a000, 0x2000, CRC(919ee527) SHA1(609ee854ab3a4fdbf3404a68a4a657b85250f742) )
283
284 ROM_REGION( 0x0c000, REGION_GFX2, ROMREGION_DISPOSE )
285 ROM_LOAD( "ms12", 0x00000, 0x2000, CRC(72d8331d) SHA1(f0a3bc6c9d9966f169f4721c2453f7ee210f0feb) )
286 ROM_LOAD( "ms13", 0x02000, 0x2000, CRC(845a1f9b) SHA1(aa2eabd2a5e89e150b5d2fb3d88f91902e5ebb48) )
287 ROM_LOAD( "ms14", 0x04000, 0x2000, CRC(822874b0) SHA1(9376d48045bf67df91d103effd1d08bd8debad26) )
288 ROM_LOAD( "ms15", 0x06000, 0x2000, CRC(4594e53c) SHA1(a011a5269a9b0ca7a964181efe8413d5637c34f4) )
289 ROM_LOAD( "ms16", 0x08000, 0x2000, CRC(2f470b0f) SHA1(79b50a7d113fed4669361c5f6c60ec96c94344c6) )
290 ROM_LOAD( "ms17", 0x0a000, 0x2000, CRC(38966d1b) SHA1(89e3e54d3298cefeb35922d2292e3e7b8e995871) )
291
292 ROM_REGION( 0x0020, REGION_PROMS, 0 )
293 ROM_LOAD( "ic61", 0x0000, 0x0020, CRC(e802d6cf) SHA1(233ceb9e3a91939e1925766a696bc65ab0dffa50) )
294 ROM_END
295
296 ROM_START( myststno )
297 ROM_REGION( 0x10000, REGION_CPU1, 0 ) /* 64k for code */
298 ROM_LOAD( "ms0", 0x4000, 0x2000, CRC(6dacc05f) SHA1(43054199901639516205c7ea145462d0abea8fb1) )
299 ROM_LOAD( "ms1", 0x6000, 0x2000, CRC(a3546df7) SHA1(89c0349885a9369406a1121cd3db28963b25f2e6) )
300 ROM_LOAD( "ms2", 0x8000, 0x2000, CRC(43bc6182) SHA1(dc36c10eee20009922e89d9bfdf6c2f6ffb881ce) )
301 ROM_LOAD( "ms3", 0xa000, 0x2000, CRC(9322222b) SHA1(25192ac9e8e66cd2bc21c66c690c57c6b9836f2d) )
302 ROM_LOAD( "ms4", 0xc000, 0x2000, CRC(47cefe9b) SHA1(49422b664b1322373a9cd3cb2907f8f5492faf87) )
303 ROM_LOAD( "ms5", 0xe000, 0x2000, CRC(b37ae12b) SHA1(55ee1193088145c85adddd377d9e5ee58aca922f) )
304
305 ROM_REGION( 0x0c000, REGION_GFX1, ROMREGION_DISPOSE )
306 ROM_LOAD( "ms6", 0x00000, 0x2000, CRC(85c83806) SHA1(cdfed6c224754e8f79b154533b06b7de4a44b4d3) )
307 ROM_LOAD( "ms9", 0x02000, 0x2000, CRC(b146c6ab) SHA1(712c0c17780f222be5c8b09185a22e900ab23944) )
308 ROM_LOAD( "ms7", 0x04000, 0x2000, CRC(d025f84d) SHA1(eaaaa0bde3db850098d04a0af85993026e503fc5) )
309 ROM_LOAD( "ms10", 0x06000, 0x2000, CRC(d85015b5) SHA1(f4afab248dfde354650e59fadd5ab9616b04dac1) )
310 ROM_LOAD( "ms8", 0x08000, 0x2000, CRC(53765d89) SHA1(c8bfc311123b076dccae9f7e3b95460bf9fc843d) )
311 ROM_LOAD( "ms11", 0x0a000, 0x2000, CRC(919ee527) SHA1(609ee854ab3a4fdbf3404a68a4a657b85250f742) )
312
313 ROM_REGION( 0x0c000, REGION_GFX2, ROMREGION_DISPOSE )
314 ROM_LOAD( "ms12", 0x00000, 0x2000, CRC(72d8331d) SHA1(f0a3bc6c9d9966f169f4721c2453f7ee210f0feb) )
315 ROM_LOAD( "ms13", 0x02000, 0x2000, CRC(845a1f9b) SHA1(aa2eabd2a5e89e150b5d2fb3d88f91902e5ebb48) )
316 ROM_LOAD( "ms14", 0x04000, 0x2000, CRC(822874b0) SHA1(9376d48045bf67df91d103effd1d08bd8debad26) )
317 ROM_LOAD( "ms15", 0x06000, 0x2000, CRC(4594e53c) SHA1(a011a5269a9b0ca7a964181efe8413d5637c34f4) )
318 ROM_LOAD( "ms16", 0x08000, 0x2000, CRC(2f470b0f) SHA1(79b50a7d113fed4669361c5f6c60ec96c94344c6) )
319 ROM_LOAD( "ms17", 0x0a000, 0x2000, CRC(38966d1b) SHA1(89e3e54d3298cefeb35922d2292e3e7b8e995871) )
320
321 ROM_REGION( 0x0020, REGION_PROMS, 0 )
322 ROM_LOAD( "ic61", 0x0000, 0x0020, CRC(e802d6cf) SHA1(233ceb9e3a91939e1925766a696bc65ab0dffa50) )
323 ROM_END
324
325
326 GAME( 1984, mystston, 0, mystston, mystston, 0, ROT270, "Technos", "Mysterious Stones - Dr. John's Adventure" )
327 GAME( 1984, myststno, mystston, mystston, mystston, 0, ROT270, "Technos", "Mysterious Stones - Dr. Kick in Adventure" )
328