1 /***************************************************************************
2 
3 	Bogey Manor               (c) 1985 Technos Japan
4 
5 	This game runs on Data East designed hardware.
6 
7 	Emulation by Bryan McPhail, mish@tendril.co.uk and T.Nogi
8 
9 ***************************************************************************/
10 
11 #include "driver.h"
12 #include "vidhrdw/generic.h"
13 #include "cpu/m6502/m6502.h"
14 
15 extern UINT8 *bogeyman_videoram2, *bogeyman_colorram2;
16 
17 extern WRITE_HANDLER( bogeyman_videoram_w );
18 extern WRITE_HANDLER( bogeyman_colorram_w );
19 extern WRITE_HANDLER( bogeyman_videoram2_w );
20 extern WRITE_HANDLER( bogeyman_colorram2_w );
21 extern WRITE_HANDLER( bogeyman_paletteram_w );
22 
23 extern PALETTE_INIT( bogeyman );
24 extern VIDEO_START( bogeyman );
25 extern VIDEO_UPDATE( bogeyman );
26 
27 /******************************************************************************/
28 
29 /* Sound section is copied from Mysterious Stones driver by Nicola, Mike, Brad */
30 
31 static int psg_latch;
32 
WRITE_HANDLER(bogeyman_8910_latch_w)33 static WRITE_HANDLER( bogeyman_8910_latch_w )
34 {
35 	psg_latch = data;
36 }
37 
WRITE_HANDLER(bogeyman_8910_control_w)38 static WRITE_HANDLER( bogeyman_8910_control_w )
39 {
40 	static int last;
41 
42 	/* bit 0 is flipscreen */
43 	flip_screen_set(~data & 0x01);
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,psg_latch);
51 		else
52 			AY8910_write_port_0_w(0,psg_latch);
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,psg_latch);
60 		else
61 			AY8910_write_port_1_w(0,psg_latch);
62 	}
63 
64 	last = data;
65 }
66 
67 /******************************************************************************/
68 
MEMORY_READ_START(bogeyman_readmem)69 static MEMORY_READ_START( bogeyman_readmem )
70 	{ 0x0000, 0x17ff, MRA_RAM },
71 	{ 0x1800, 0x1fff, MRA_RAM },
72 	{ 0x2000, 0x21ff, MRA_RAM },
73 	{ 0x2800, 0x2bff, MRA_RAM },
74 	{ 0x3800, 0x3800, input_port_0_r },	/* Player 1 */
75 	{ 0x3801, 0x3801, input_port_1_r },	/* Player 2 + VBL */
76 	{ 0x3802, 0x3802, input_port_2_r },	/* Dip 1 */
77 	{ 0x3803, 0x3803, input_port_3_r },	/* Dip 2 + Coins */
78 	{ 0x4000, 0xffff, MRA_ROM },
79 MEMORY_END
80 
81 static MEMORY_WRITE_START( bogeyman_writemem )
82 	{ 0x0000, 0x17ff, MWA_RAM },
83 	{ 0x1800, 0x1bff, bogeyman_videoram2_w, &bogeyman_videoram2 },
84 	{ 0x1c00, 0x1fff, bogeyman_colorram2_w, &bogeyman_colorram2 },
85   	{ 0x2000, 0x20ff, bogeyman_videoram_w, &videoram },
86   	{ 0x2100, 0x21ff, bogeyman_colorram_w, &colorram },
87 	{ 0x2800, 0x2bff, MWA_RAM, &spriteram, &spriteram_size },
88 	{ 0x3000, 0x300f, bogeyman_paletteram_w, &paletteram },
89 	{ 0x3800, 0x3800, bogeyman_8910_control_w },
90 	{ 0x3801, 0x3801, bogeyman_8910_latch_w },
91 	{ 0x3803, 0x3803, MWA_NOP },	/* ?? This has something to do with sound */
92 	{ 0x4000, 0xffff, MWA_ROM },
93 MEMORY_END
94 
95 /******************************************************************************/
96 
97 INPUT_PORTS_START( bogeyman )
98 	PORT_START
99 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 )
100 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 )
101 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY )
102 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY )
103 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY )
104 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
105 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
106 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
107 
108 	PORT_START	/* IN1 */
109 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL )
110 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
111 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL )
112 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP   | IPF_8WAY | IPF_COCKTAIL )
113 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_COCKTAIL )
114 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL )
115 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
116 	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK )
117 
118 	PORT_START	/* DSW1 */
119 	PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coin_A ) )
120 	PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ) )
121 	PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
122 	PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
123 	PORT_DIPSETTING(    0x01, DEF_STR( 1C_3C ) )
124 	PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Coin_B ) )
125 	PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ) )
126 	PORT_DIPSETTING(    0x0c, DEF_STR( 1C_1C ) )
127 	PORT_DIPSETTING(    0x08, DEF_STR( 1C_2C ) )
128 	PORT_DIPSETTING(    0x04, DEF_STR( 1C_3C ) )
129 	PORT_DIPNAME( 0x10, 0x10, DEF_STR( Demo_Sounds ) )
130 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
131 	PORT_DIPSETTING(    0x10, DEF_STR( On ) )
132 	PORT_DIPNAME( 0x20, 0x00, DEF_STR( Cabinet ) )
133 	PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
134 	PORT_DIPSETTING(    0x20, DEF_STR( Cocktail ) )
135 	PORT_SERVICE( 0x40, IP_ACTIVE_LOW )
136 	PORT_DIPNAME( 0x80, 0x80, "Allow Continue" )
137 	PORT_DIPSETTING(    0x00, DEF_STR( No ) )
138 	PORT_DIPSETTING(    0x80, DEF_STR( Yes ) )
139 
140 	PORT_START	/* DSW2 */
141 	PORT_DIPNAME( 0x01, 0x01, DEF_STR( Lives ) )
142 	PORT_DIPSETTING(    0x01, "3" )
143 	PORT_DIPSETTING(    0x00, "5" )
144 	PORT_DIPNAME( 0x02, 0x02, DEF_STR( Bonus_Life ) )
145 	PORT_DIPSETTING(    0x02, "50000" )
146 	PORT_DIPSETTING(    0x00, "none" )
147 	PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Difficulty ) )
148 	PORT_DIPSETTING(    0x0c, "Easy" )			/* Normal*/
149 	PORT_DIPSETTING(    0x08, "Medium" )			/*   |*/
150 	PORT_DIPSETTING(    0x04, "Hard" )			/*   |*/
151 	PORT_DIPSETTING(    0x00, "Hardest" )			/*  HARD*/
152 	PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
153 	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
154 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
155 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 )
156 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 )
157 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 )
158 INPUT_PORTS_END
159 
160 /******************************************************************************/
161 
162 static struct GfxLayout charlayout1 =
163 {
164 	8,8,	/* 8*8 chars */
165 	512,
166 	3,
167 	{ 0x8000*8+4, 0, 4 },
168 	{ 0x2000*8+3, 0x2000*8+2, 0x2000*8+1, 0x2000*8+0, 3, 2, 1, 0, },
169 	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
170 	8*8	/* every char takes 16 consecutive bytes */
171 };
172 
173 static struct GfxLayout charlayout2 =
174 {
175 	8,8,	/* 8*8 chars */
176 	512,
177 	3,
178 	{ 0x8000*8, 0+0x1000*8, 4+0x1000*8, 0 },
179 	{ 0x2000*8+3, 0x2000*8+2, 0x2000*8+1, 0x2000*8+0, 3, 2, 1, 0, },
180 	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
181 	8*8	/* every char takes 16 consecutive bytes */
182 };
183 
184 static struct GfxLayout tiles1a =
185 {
186 	16,16,
187 	0x80,
188 	3,
189 	{ 0x8000*8+4, 0, 4 },
190 	{ 1024*8*8+3, 1024*8*8+2, 1024*8*8+1, 1024*8*8+0, 3,2,1,0,
191 		1024*8*8+3+64, 1024*8*8+2+64, 1024*8*8+1+64, 1024*8*8+0+64, 3+64,2+64,1+64,0+64 },
192 	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
193 		0*8+16*8, 1*8+16*8, 2*8+16*8, 3*8+16*8, 4*8+16*8, 5*8+16*8, 6*8+16*8, 7*8+16*8 },
194 	32*8	/* every tile takes 32 consecutive bytes */
195 };
196 
197 static struct GfxLayout tiles1b =
198 {
199 	16,16,
200 	0x80,
201 	3,
202 	{ 0x8000*8+0, 0+0x1000*8+0, 4+0x1000*8 },
203 	{ 1024*8*8+3, 1024*8*8+2, 1024*8*8+1, 1024*8*8+0, 3,2,1,0,
204 		1024*8*8+3+64, 1024*8*8+2+64, 1024*8*8+1+64, 1024*8*8+0+64, 3+64,2+64,1+64,0+64 },
205 	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
206 		0*8+16*8, 1*8+16*8, 2*8+16*8, 3*8+16*8, 4*8+16*8, 5*8+16*8, 6*8+16*8, 7*8+16*8 },
207 	32*8	/* every tile takes 32 consecutive bytes */
208 };
209 
210 static struct GfxLayout sprites =
211 {
212 	16,16,
213 	0x200,
214 	3,
215  	{ 0x8000*8, 0x4000*8, 0 },
216 	{ 16*8, 1+(16*8), 2+(16*8), 3+(16*8), 4+(16*8), 5+(16*8), 6+(16*8), 7+(16*8),
217 		0,1,2,3,4,5,6,7 },
218 	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 ,8*8,9*8,10*8,11*8,12*8,13*8,14*8,15*8},
219 	16*16
220 };
221 
222 static struct GfxDecodeInfo gfxdecodeinfo[] =
223 {
224 	{ REGION_GFX1, 0x00000, &charlayout1,     16, 32 },
225 	{ REGION_GFX1, 0x00000, &charlayout2,     16, 32 },
226 	{ REGION_GFX2, 0x00000, &sprites,          0,  2 },
227 	{ REGION_GFX3, 0x00000, &tiles1a,     16+128,  8 },
228 	{ REGION_GFX3, 0x00000, &tiles1b,     16+128,  8 },
229 	{ REGION_GFX3, 0x04000, &tiles1a,     16+128,  8 },
230 	{ REGION_GFX3, 0x04000, &tiles1b,     16+128,  8 },
231 	/* colors 16+192 to 16+255 are currently unassigned */
232 	{ -1 } /* end of array */
233 };
234 
235 /******************************************************************************/
236 
237 static struct AY8910interface ay8910_interface =
238 {
239 	2,      /* 2 chips */
240 	1500000,        /* 1.5 MHz ? */
241 	{ 30, 30 },
242 	{ 0 },
243 	{ 0 },
244 	{ 0 },
245 	{ 0 }
246 };
247 
248 /******************************************************************************/
249 
250 static MACHINE_DRIVER_START( bogeyman )
251 
252 	/* basic machine hardware */
253 	MDRV_CPU_ADD(M6502, 2000000) /* 12 MHz clock on board */
254 	MDRV_CPU_MEMORY(bogeyman_readmem,bogeyman_writemem)
255 	MDRV_CPU_VBLANK_INT(irq0_line_hold,16) /* Controls sound */
256 
257 	MDRV_FRAMES_PER_SECOND(60)
258 	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)
259 
260 	/* video hardware */
261 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_UPDATE_BEFORE_VBLANK)
262 	MDRV_SCREEN_SIZE(32*8, 32*8)
263 	MDRV_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
264 
265 	MDRV_GFXDECODE(gfxdecodeinfo)
266 	MDRV_PALETTE_LENGTH(16+256)
267 	MDRV_COLORTABLE_LENGTH(16+256)
268 
269 	MDRV_PALETTE_INIT(bogeyman)
270 	MDRV_VIDEO_START(bogeyman)
271 	MDRV_VIDEO_UPDATE(bogeyman)
272 
273 	/* sound hardware */
274 	MDRV_SOUND_ADD(AY8910, ay8910_interface)
275 MACHINE_DRIVER_END
276 
277 /******************************************************************************/
278 
279 ROM_START( bogeyman )
280 	ROM_REGION( 0x58000, REGION_CPU1, 0 )
281  	ROM_LOAD( "j20.c14",  0x04000, 0x04000, CRC(ea90d637) SHA1(aa89bee806badb05119516d84e7674cd302aaf4e) )
282 	ROM_LOAD( "j10.c15",  0x08000, 0x04000, CRC(0a8f218d) SHA1(5e5958cccfe634e3d274d187a0a7fe4789f3a9c3) )
283 	ROM_LOAD( "j00.c17",  0x0c000, 0x04000, CRC(5d486de9) SHA1(40ea14a4a25f8f38d33a8844f627ba42503e1280) )
284 
285 	ROM_REGION( 0x10000, REGION_GFX1, ROMREGION_DISPOSE )
286 	ROM_LOAD( "j70.h15",  0x00000, 0x04000, CRC(fdc787bf) SHA1(1f185a1927fff6ce793d673ebd882a852ac547e4) )	/* Characters */
287 	ROM_LOAD( "j60.c17",  0x08000, 0x01000, CRC(cc03ceb2) SHA1(0149eacac2c1469be6e19f7a43c13d1fe8790f2c) )
288 	ROM_CONTINUE(         0x0a000, 0x01000 )
289 
290 	ROM_REGION( 0x0c000, REGION_GFX2, ROMREGION_DISPOSE )
291 	ROM_LOAD( "j30.c9",   0x00000, 0x04000, CRC(41af81c0) SHA1(d8465622cdf16bc906818641d7988fc412454a45) )	/* Sprites */
292 	ROM_LOAD( "j40.c7",   0x04000, 0x04000, CRC(8b438421) SHA1(295806c119f4ddc01afc15550e1ff397fbf5d862) )
293 	ROM_LOAD( "j50.c5",   0x08000, 0x04000, CRC(b507157f) SHA1(471f67eb5e7aedef52353581405d9613d2a86898) )
294 
295 	ROM_REGION( 0x10000, REGION_GFX3, ROMREGION_DISPOSE )
296 	ROM_LOAD( "j90.h12",  0x00000, 0x04000, CRC(46b2d4d0) SHA1(35cd320d4db7aa6a89f83ba4d9ff88925357d640) )	/* Tiles */
297 	ROM_LOAD( "j80.h13",  0x04000, 0x04000, CRC(77ebd0a4) SHA1(c6921ee59633eeeda97c73cb7833578fa8a84fa3) )
298 	ROM_LOAD( "ja0.h10",  0x08000, 0x01000, CRC(f2aa05ed) SHA1(e6df96e4128eff6de7e6483254608dd8a7b258b9) )
299 	ROM_CONTINUE(         0x0a000, 0x01000 )
300 	ROM_CONTINUE(         0x0c000, 0x01000 )
301 	ROM_CONTINUE(         0x0e000, 0x01000 )
302 
303 	ROM_REGION( 0x0200, REGION_PROMS, 0 )
304 	ROM_LOAD( "82s129.5k",  0x0000, 0x0100, CRC(4a7c5367) SHA1(a67f5b90c18238cbfb1507230b4614191d37eef4) )	/* Colour prom 1 */
305 	ROM_LOAD( "82s129.6k",  0x0100, 0x0100, CRC(b6127713) SHA1(5bd8627453916ac6605af7d1193f79c748eab981) )	/* Colour prom 2 */
306 ROM_END
307 
308 /******************************************************************************/
309 
310 /* ROT180 confirmed by Kold */
311 GAMEX( 1985, bogeyman, 0, bogeyman, bogeyman, 0, ROT180, "Technos Japan", "Bogey Manor", GAME_IMPERFECT_COLORS )
312