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_DIPNAME(0x08, 0x08, DEF_STR( Unused ) )
141 PORT_DIPSETTING( 0x08, DEF_STR( Off ) )
142 PORT_DIPSETTING( 0x00, DEF_STR( On ) )
143 PORT_DIPNAME(0x10, 0x10, DEF_STR( Unused ) )
144 PORT_DIPSETTING( 0x10, DEF_STR( Off ) )
145 PORT_DIPSETTING( 0x00, DEF_STR( On ) )
146 PORT_DIPNAME(0x20, 0x20, DEF_STR( Unused ) )
147 PORT_DIPSETTING( 0x20, DEF_STR( Off ) )
148 PORT_DIPSETTING( 0x00, DEF_STR( On ) )
149 PORT_DIPNAME(0x40, 0x40, DEF_STR( Unused ) )
150 PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
151 PORT_DIPSETTING( 0x00, DEF_STR( On ) )
152 PORT_DIPNAME(0x80, 0x80, DEF_STR( Unused ) )
153 PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
154 PORT_DIPSETTING( 0x00, DEF_STR( On ) )
155
156 PORT_START /* DSW2 */
157 PORT_DIPNAME(0x03, 0x03, DEF_STR( Coin_A ) )
158 PORT_DIPSETTING( 0x00, DEF_STR( 2C_1C ) )
159 PORT_DIPSETTING( 0x03, DEF_STR( 1C_1C ) )
160 PORT_DIPSETTING( 0x02, DEF_STR( 1C_2C ) )
161 PORT_DIPSETTING( 0x01, DEF_STR( 1C_3C ) )
162 PORT_DIPNAME(0x0c, 0x0c, DEF_STR( Coin_B ) )
163 PORT_DIPSETTING( 0x00, DEF_STR( 2C_1C ) )
164 PORT_DIPSETTING( 0x0c, DEF_STR( 1C_1C ) )
165 PORT_DIPSETTING( 0x08, DEF_STR( 1C_2C ) )
166 PORT_DIPSETTING( 0x04, DEF_STR( 1C_3C ) )
167 PORT_DIPNAME(0x10, 0x10, DEF_STR( Unused ) )
168 PORT_DIPSETTING( 0x10, DEF_STR( Off ) )
169 PORT_DIPSETTING( 0x00, DEF_STR( On ) )
170 PORT_DIPNAME(0x20, 0x00, DEF_STR( Flip_Screen ) )
171 PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
172 PORT_DIPSETTING( 0x20, DEF_STR( On ) )
173 PORT_DIPNAME(0x40, 0x00, DEF_STR( Cabinet ) )
174 PORT_DIPSETTING( 0x00, DEF_STR( Upright ) )
175 PORT_DIPSETTING( 0x40, DEF_STR( Cocktail ) )
176 PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) /* VBLANK*/
177 INPUT_PORTS_END
178
179
180 static struct GfxLayout charlayout =
181 {
182 8,8,
183 RGN_FRAC(1,3),
184 3,
185 { RGN_FRAC(2,3), RGN_FRAC(1,3), RGN_FRAC(0,3) },
186 { 0, 1, 2, 3, 4, 5, 6, 7 },
187 { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
188 8*8
189 };
190
191 static struct GfxLayout spritelayout =
192 {
193 16,16,
194 RGN_FRAC(1,3),
195 3,
196 { RGN_FRAC(2,3), RGN_FRAC(1,3), RGN_FRAC(0,3) },
197 { 16*8+0, 16*8+1, 16*8+2, 16*8+3, 16*8+4, 16*8+5, 16*8+6, 16*8+7,
198 0, 1, 2, 3, 4, 5, 6, 7 },
199 { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
200 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
201 32*8
202 };
203
204 static struct GfxDecodeInfo gfxdecodeinfo[] =
205 {
206 { REGION_GFX1, 0, &charlayout, 3*8, 4 },
207 { REGION_GFX2, 0, &spritelayout, 2*8, 1 },
208 { REGION_GFX1, 0, &spritelayout, 0*8, 2 },
209 { -1 } /* end of array */
210 };
211
212
213 static struct AY8910interface ay8910_interface =
214 {
215 2, /* 2 chips*/
216 12000000/8, /* 1.5 MHz*/
217 { 30, 30 },
218 { 0 },
219 { 0 },
220 { 0 },
221 { 0 }
222 };
223
224
INTERRUPT_GEN(mystston_interrupt)225 static INTERRUPT_GEN( mystston_interrupt )
226 {
227 int scanline = 271 - cpu_getiloops();
228 static int coin;
229
230 /* Inserting a coin triggers an NMI */
231 if ((readinputport(0) & 0xc0) != 0xc0)
232 {
233 if (coin == 0)
234 {
235 coin = 1;
236 nmi_line_pulse();
237 return;
238 }
239 }
240 else coin = 0;
241
242 /* VBLK is lowered on scanline 8 */
243 if (scanline == 8)
244 VBLK = 0;
245
246 /* VBLK is raised on scanline 248 */
247 if (scanline == 248)
248 VBLK = 0x80;
249
250 /* IMS is triggered every time VLOC line 3 is raised,
251 as VLOC counter starts at 16, effectively every 16 scanlines */
252 if ((scanline % 16) == 0)
253 cpu_set_irq_line(0, 0, ASSERT_LINE);
254 }
255
256
257 static MACHINE_DRIVER_START( mystston )
258
259 /* basic machine hardware */
260 MDRV_CPU_ADD(M6502, 12000000/8) /* 1.5 MHz*/
261 MDRV_CPU_MEMORY(readmem, writemem)
262 MDRV_CPU_VBLANK_INT(mystston_interrupt, 272)
263
264 MDRV_FRAMES_PER_SECOND(((12000000.0 / 256.0) / 3.0) / 272.0)
265 MDRV_VBLANK_DURATION(0)
266
267 /* video hardware */
268 MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
269 MDRV_SCREEN_SIZE(32*8, 32*8)
270 MDRV_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
271 MDRV_GFXDECODE(gfxdecodeinfo)
272 MDRV_PALETTE_LENGTH(24+32)
273
274 MDRV_PALETTE_INIT(mystston)
275 MDRV_VIDEO_START(mystston)
276 MDRV_VIDEO_UPDATE(mystston)
277
278 /* sound hardware */
279 MDRV_SOUND_ADD(AY8910, ay8910_interface)
280 MACHINE_DRIVER_END
281
282
283 ROM_START( mystston )
284 ROM_REGION( 0x10000, REGION_CPU1, 0 ) /* 64k for code */
285 ROM_LOAD( "rom6.bin", 0x4000, 0x2000, CRC(7bd9c6cd) SHA1(4d14edc783ba1a6c01d2fb9ea29ec85b8fec3c3b) )
286 ROM_LOAD( "rom5.bin", 0x6000, 0x2000, CRC(a83f04a6) SHA1(d8cdf310511c1fef4fbde80ef2161fda00f965d7) )
287 ROM_LOAD( "rom4.bin", 0x8000, 0x2000, CRC(46c73714) SHA1(5b9ac3a35aeeea6a0cd2d838c144925d83b36a7f) )
288 ROM_LOAD( "rom3.bin", 0xa000, 0x2000, CRC(34f8b8a3) SHA1(a270f6665a9f76f97ac02201d51fe2817e6e8f22) )
289 ROM_LOAD( "rom2.bin", 0xc000, 0x2000, CRC(bfd22cfc) SHA1(137cd61c8b1e997e7e50edd57f1671031d8e3ac5) )
290 ROM_LOAD( "rom1.bin", 0xe000, 0x2000, CRC(fb163e38) SHA1(d6f02e90bfd9badd7751bc0a87fdfdd1d0a7e202) )
291
292 ROM_REGION( 0x0c000, REGION_GFX1, ROMREGION_DISPOSE )
293 ROM_LOAD( "ms6", 0x00000, 0x2000, CRC(85c83806) SHA1(cdfed6c224754e8f79b154533b06b7de4a44b4d3) )
294 ROM_LOAD( "ms9", 0x02000, 0x2000, CRC(b146c6ab) SHA1(712c0c17780f222be5c8b09185a22e900ab23944) )
295 ROM_LOAD( "ms7", 0x04000, 0x2000, CRC(d025f84d) SHA1(eaaaa0bde3db850098d04a0af85993026e503fc5) )
296 ROM_LOAD( "ms10", 0x06000, 0x2000, CRC(d85015b5) SHA1(f4afab248dfde354650e59fadd5ab9616b04dac1) )
297 ROM_LOAD( "ms8", 0x08000, 0x2000, CRC(53765d89) SHA1(c8bfc311123b076dccae9f7e3b95460bf9fc843d) )
298 ROM_LOAD( "ms11", 0x0a000, 0x2000, CRC(919ee527) SHA1(609ee854ab3a4fdbf3404a68a4a657b85250f742) )
299
300 ROM_REGION( 0x0c000, REGION_GFX2, ROMREGION_DISPOSE )
301 ROM_LOAD( "ms12", 0x00000, 0x2000, CRC(72d8331d) SHA1(f0a3bc6c9d9966f169f4721c2453f7ee210f0feb) )
302 ROM_LOAD( "ms13", 0x02000, 0x2000, CRC(845a1f9b) SHA1(aa2eabd2a5e89e150b5d2fb3d88f91902e5ebb48) )
303 ROM_LOAD( "ms14", 0x04000, 0x2000, CRC(822874b0) SHA1(9376d48045bf67df91d103effd1d08bd8debad26) )
304 ROM_LOAD( "ms15", 0x06000, 0x2000, CRC(4594e53c) SHA1(a011a5269a9b0ca7a964181efe8413d5637c34f4) )
305 ROM_LOAD( "ms16", 0x08000, 0x2000, CRC(2f470b0f) SHA1(79b50a7d113fed4669361c5f6c60ec96c94344c6) )
306 ROM_LOAD( "ms17", 0x0a000, 0x2000, CRC(38966d1b) SHA1(89e3e54d3298cefeb35922d2292e3e7b8e995871) )
307
308 ROM_REGION( 0x0020, REGION_PROMS, 0 )
309 ROM_LOAD( "ic61", 0x0000, 0x0020, CRC(e802d6cf) SHA1(233ceb9e3a91939e1925766a696bc65ab0dffa50) )
310 ROM_END
311
312 ROM_START( myststno )
313 ROM_REGION( 0x10000, REGION_CPU1, 0 ) /* 64k for code */
314 ROM_LOAD( "ms0", 0x4000, 0x2000, CRC(6dacc05f) SHA1(43054199901639516205c7ea145462d0abea8fb1) )
315 ROM_LOAD( "ms1", 0x6000, 0x2000, CRC(a3546df7) SHA1(89c0349885a9369406a1121cd3db28963b25f2e6) )
316 ROM_LOAD( "ms2", 0x8000, 0x2000, CRC(43bc6182) SHA1(dc36c10eee20009922e89d9bfdf6c2f6ffb881ce) )
317 ROM_LOAD( "ms3", 0xa000, 0x2000, CRC(9322222b) SHA1(25192ac9e8e66cd2bc21c66c690c57c6b9836f2d) )
318 ROM_LOAD( "ms4", 0xc000, 0x2000, CRC(47cefe9b) SHA1(49422b664b1322373a9cd3cb2907f8f5492faf87) )
319 ROM_LOAD( "ms5", 0xe000, 0x2000, CRC(b37ae12b) SHA1(55ee1193088145c85adddd377d9e5ee58aca922f) )
320
321 ROM_REGION( 0x0c000, REGION_GFX1, ROMREGION_DISPOSE )
322 ROM_LOAD( "ms6", 0x00000, 0x2000, CRC(85c83806) SHA1(cdfed6c224754e8f79b154533b06b7de4a44b4d3) )
323 ROM_LOAD( "ms9", 0x02000, 0x2000, CRC(b146c6ab) SHA1(712c0c17780f222be5c8b09185a22e900ab23944) )
324 ROM_LOAD( "ms7", 0x04000, 0x2000, CRC(d025f84d) SHA1(eaaaa0bde3db850098d04a0af85993026e503fc5) )
325 ROM_LOAD( "ms10", 0x06000, 0x2000, CRC(d85015b5) SHA1(f4afab248dfde354650e59fadd5ab9616b04dac1) )
326 ROM_LOAD( "ms8", 0x08000, 0x2000, CRC(53765d89) SHA1(c8bfc311123b076dccae9f7e3b95460bf9fc843d) )
327 ROM_LOAD( "ms11", 0x0a000, 0x2000, CRC(919ee527) SHA1(609ee854ab3a4fdbf3404a68a4a657b85250f742) )
328
329 ROM_REGION( 0x0c000, REGION_GFX2, ROMREGION_DISPOSE )
330 ROM_LOAD( "ms12", 0x00000, 0x2000, CRC(72d8331d) SHA1(f0a3bc6c9d9966f169f4721c2453f7ee210f0feb) )
331 ROM_LOAD( "ms13", 0x02000, 0x2000, CRC(845a1f9b) SHA1(aa2eabd2a5e89e150b5d2fb3d88f91902e5ebb48) )
332 ROM_LOAD( "ms14", 0x04000, 0x2000, CRC(822874b0) SHA1(9376d48045bf67df91d103effd1d08bd8debad26) )
333 ROM_LOAD( "ms15", 0x06000, 0x2000, CRC(4594e53c) SHA1(a011a5269a9b0ca7a964181efe8413d5637c34f4) )
334 ROM_LOAD( "ms16", 0x08000, 0x2000, CRC(2f470b0f) SHA1(79b50a7d113fed4669361c5f6c60ec96c94344c6) )
335 ROM_LOAD( "ms17", 0x0a000, 0x2000, CRC(38966d1b) SHA1(89e3e54d3298cefeb35922d2292e3e7b8e995871) )
336
337 ROM_REGION( 0x0020, REGION_PROMS, 0 )
338 ROM_LOAD( "ic61", 0x0000, 0x0020, CRC(e802d6cf) SHA1(233ceb9e3a91939e1925766a696bc65ab0dffa50) )
339 ROM_END
340
341
342 GAME( 1984, mystston, 0, mystston, mystston, 0, ROT270, "Technos", "Mysterious Stones - Dr. John's Adventure" )
343 GAME( 1984, myststno, mystston, mystston, mystston, 0, ROT270, "Technos", "Mysterious Stones - Dr. Kick in Adventure" )
344