1 #include "../machine/toypop.c"
2 #include "../vidhrdw/toypop.c"
3 
4 /****************************************
5 
6 TOYPOP
7 1986 Namco
8 
9 driver by Edgardo E. Contini Salvan (pag2806@iperbole.bologna.it)
10 
11 TOYPOP uses a 6809 main CPU,
12 another 6809 for the sound and
13 a 68000 to create the background image.
14 
15 Libble Rabble should run on the same board
16 
17 ****************************************/
18 
19 #include "driver.h"
20 #include "sound/namco.h"
21 #include "vidhrdw/generic.h"
22 
23 // machine\toypop.c
24 void toypop_init_machine(void);
25 READ_HANDLER( toypop_cycle_r );
26 int toypop_interrupt(void);
27 WRITE_HANDLER( toypop_interrupt_enable_w );
28 WRITE_HANDLER( toypop_interrupt_disable_w );
29 extern unsigned char *toypop_sharedram_1, *toypop_sharedram_2, *toypop_customio, *toypop_speedup;
30 READ_HANDLER( toypop_sharedram_1_r );
31 WRITE_HANDLER( toypop_sharedram_1_w );
32 READ_HANDLER( toypop_sharedram_2_r );
33 WRITE_HANDLER( toypop_sharedram_2_w );
34 WRITE_HANDLER( toypop_cpu_reset_w );
35 READ_HANDLER( toypop_customio_r );
36 
37 // vidhrdw\toypop.c
38 extern unsigned char *bg_image;
39 int toypop_vh_start(void);
40 void toypop_vh_stop(void);
41 READ_HANDLER( toypop_background_r );
42 WRITE_HANDLER( toypop_background_w );
43 WRITE_HANDLER( toypop_flipscreen_w );
44 void toypop_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
45 void toypop_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
46 
47 static struct MemoryReadAddress toypop_readmem_I_6809[] =
48 {
49 	{ 0x2800, 0x2fff, MRA_RAM },								/* shared RAM with the 68000 CPU */
50 	{ 0x6000, 0x602f, toypop_customio_r },						/* custom I/O chip interface */
51 	{ 0x6840, 0x6bff, MRA_RAM },								/* shared RAM with the sound CPU */
52 	{ 0x8000, 0xffff, MRA_ROM },								/* ROM code */
53 	{ 0x0000, 0x7fff, MRA_RAM },								/* RAM everywhere else */
54 
55 	{ -1 }	/* end of table */
56 };
57 
58 static struct MemoryWriteAddress toypop_writemem_I_6809[] =
59 {
60 	{ 0x0000, 0x03ff, videoram_w, &videoram, &videoram_size },	/* video RAM */
61 	{ 0x0400, 0x07ff, colorram_w, &colorram },					/* color RAM */
62 	{ 0x0800, 0x0f7f, MWA_RAM },								/* general RAM, area 1 */
63 	{ 0x0f80, 0x0fff, MWA_RAM, &spriteram, &spriteram_size },	/* sprite RAM, area 1 */
64 	{ 0x1000, 0x177f, MWA_RAM },								/* general RAM, area 2 */
65 	{ 0x1780, 0x17ff, MWA_RAM, &spriteram_2 },					/* sprite RAM, area 2 */
66 	{ 0x1800, 0x1f7f, MWA_RAM },								/* general RAM, area 3 */
67 	{ 0x1f80, 0x1fff, MWA_RAM, &spriteram_3 },					/* sprite RAM, area 3 */
68 	{ 0x2800, 0x2fff, MWA_RAM, &toypop_sharedram_2 },			/* shared RAM with the 68000 CPU */
69 	{ 0x6000, 0x602f, MWA_RAM, &toypop_customio },				/* custom I/O chip interface */
70 	{ 0x6840, 0x6bff, MWA_RAM, &toypop_sharedram_1 },			/* shared RAM with the sound CPU */
71 	{ 0x7000, 0x7000, MWA_RAM },								/* watchdog timer ??? */
72 	// any of these four addresses could be the sound CPU reset
73 	// (at the start the program writes on all four)
74 //	{ 0x8000, 0x8000, MWA_NOP },								/* ??? */
75 //	{ 0x8800, 0x8800, MWA_NOP },								/* ??? */
76 //	{ 0x9000, 0x9000, MWA_NOP },								/* ??? */
77 	{ 0x9800, 0x9800, toypop_cpu_reset_w },						/* sound CPU reset ??? */
78 	{ 0xa000, 0xa001, MWA_NOP },								/* background image palette ??? */
79 	{ 0x8000, 0xffff, MWA_ROM },								/* ROM code */
80 
81 	{ -1 }	/* end of table */
82 };
83 
84 static struct MemoryReadAddress toypop_readmem_II_6809[] =
85 {
86 	{ 0x0040, 0x03ff, toypop_sharedram_1_r },	/* shared RAM with the main CPU */
87 	{ 0xe000, 0xffff, MRA_ROM },				/* ROM code */
88 
89 	{ -1 }	/* end of table */
90 };
91 
92 static struct MemoryWriteAddress toypop_writemem_II_6809[] =
93 {
94 	{ 0x0000, 0x003f, mappy_sound_w, &namco_soundregs },	/* sound control registers */
95 	{ 0x0040, 0x03ff, toypop_sharedram_1_w },				/* shared RAM with the main CPU */
96 	{ 0x4000, 0x4000, MWA_RAM },							/* interrupt enable ??? */
97 	{ 0x6000, 0x6000, MWA_RAM },							/* watchdog ??? */
98 	{ 0xe000, 0xffff, MWA_ROM },							/* ROM code */
99 
100 	{ -1 }	/* end of table */
101 };
102 
103 static struct MemoryReadAddress toypop_readmem_68k[] =
104 {
105 	{ 0x000000, 0x007fff, MRA_ROM },				/* ROM code */
106 	{ 0x080000, 0x080001, toypop_cycle_r },			/* speed hack */
107 	{ 0x080000, 0x0bffff, MRA_BANK1 },				/* RAM */
108 	{ 0x100000, 0x100fff, toypop_sharedram_2_r },	/* shared RAM with the main CPU */
109 	{ 0x190000, 0x1901ff, MRA_BANK2 },				/* RAM */
110 	{ 0x190200, 0x19fdff, toypop_background_r },	/* RAM containing the background image */
111 	{ 0x19FE00, 0x1dffff, MRA_BANK3 },				/* RAM */
112 
113 	{ -1 }	/* end of table */
114 };
115 
116 static struct MemoryWriteAddress toypop_writemem_68k[] =
117 {
118 	{ 0x000000, 0x007fff, MWA_ROM },						/* ROM code */
119 	{ 0x080000, 0x0bffff, MWA_BANK1, &toypop_speedup },		/* RAM */
120 	{ 0x100000, 0x100fff, toypop_sharedram_2_w },			/* shared RAM with the main CPU */
121 	{ 0x18fffc, 0x18ffff, toypop_flipscreen_w },			/* flip mode */
122 	{ 0x190000, 0x1901ff, MWA_BANK2 },						/* RAM */
123 	{ 0x190200, 0x19fdff, toypop_background_w, &bg_image },	/* RAM containing the background image */
124 	{ 0x19FE00, 0x1dffff, MWA_BANK3 },						/* RAM */
125 	{ 0x300000, 0x300001, toypop_interrupt_enable_w },		/* interrupt enable */
126 	{ 0x380000, 0x380001, toypop_interrupt_disable_w },		/* interrupt disable */
127 
128 	{ -1 }	/* end of table */
129 };
130 
131 //////////////////////////////////////////////////////////////////////////////////
132 
133 INPUT_PORTS_START( toypop )
134 	// FAKE
135 	/* The player inputs and the dipswitches are not memory mapped,
136 		they are handled by an I/O chip (I guess). */
137 	/* These fake input ports are read by toypop_customio_r() */
138 	PORT_START	// IN0
139 	PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_COIN1)
140 	PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_COIN2)
141 	PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_4WAY )
142 	PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_4WAY )
143 	PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_4WAY )
144 	PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_4WAY )
145 	PORT_BIT(0x0c, IP_ACTIVE_HIGH, IPT_UNKNOWN)
146 
147 	PORT_START	// IN1
148 	PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_4WAY | IPF_PLAYER2)
149 	PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_PLAYER2)
150 	PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_PLAYER2)
151 	PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_PLAYER2)
152 	PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_BUTTON1)
153 	PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER2)
154 	PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_START1)
155 	PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_START2)
156 
157 	PORT_START	// DSW0
158 	PORT_DIPNAME(0x03, 0x00, DEF_STR( Coin_A ) )
159 	PORT_DIPSETTING(   0x03, DEF_STR( 3C_1C ) )
160 	PORT_DIPSETTING(   0x02, DEF_STR( 2C_1C ) )
161 	PORT_DIPSETTING(   0x00, DEF_STR( 1C_1C ) )
162 	PORT_DIPSETTING(   0x01, DEF_STR( 1C_2C ) )
163 	PORT_DIPNAME(0x04, 0x00, DEF_STR( Flip_Screen ) )
164 	PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
165 	PORT_DIPSETTING(   0x04, DEF_STR( On ) )
166 	PORT_BITX(0x08, IP_ACTIVE_HIGH, IPT_SERVICE | IPF_TOGGLE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE )
167 	PORT_DIPSETTING(0x00, DEF_STR( Off ) )
168 	PORT_DIPSETTING(0x08, DEF_STR( On ) )
169 	PORT_DIPNAME(0x10, 0x00, "Freeze" )
170 	PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
171 	PORT_DIPSETTING(   0x10, DEF_STR( On ) )
172 	PORT_DIPNAME(0x20, 0x00, "Level Select" )
173 	PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
174 	PORT_DIPSETTING(   0x20, DEF_STR( On ) )
175 	PORT_DIPNAME(0x40, 0x00, "2p play" )
176 	PORT_DIPSETTING(   0x00, "2 Credits" )
177 	PORT_DIPSETTING(   0x40, "1 Credit" )
178 	PORT_DIPNAME(0x80, 0x00, DEF_STR( Demo_Sounds ) )
179 	PORT_DIPSETTING(   0x80, DEF_STR( Off ) )
180 	PORT_DIPSETTING(   0x00, DEF_STR( On ) )
181 
182 	PORT_START	// DSW1
183 	PORT_DIPNAME(0x01, 0x00, "Entering" )	// ???
184 	PORT_DIPSETTING(   0x01, DEF_STR( Off ) )
185 	PORT_DIPSETTING(   0x00, DEF_STR( On ) )
186 	PORT_DIPNAME(0x06, 0x00, DEF_STR( Difficulty ) )
187 	PORT_DIPSETTING(   0x02, "Easy" )
188 	PORT_DIPSETTING(   0x00, "Normal" )
189 	PORT_DIPSETTING(   0x04, "Hard" )
190 	PORT_DIPSETTING(   0x06, "Very hard" )
191 	PORT_DIPNAME(0x08, 0x00, DEF_STR( Bonus_Life ) )
192 	PORT_DIPSETTING(   0x00, "Every 15000 points" )
193 	PORT_DIPSETTING(   0x08, "Every 20000 points" )
194 	PORT_DIPNAME(0x30, 0x00, DEF_STR( Lives ) )
195 	PORT_DIPSETTING(   0x10, "1" )
196 	PORT_DIPSETTING(   0x20, "2" )
197 	PORT_DIPSETTING(   0x00, "3" )
198 	PORT_DIPSETTING(   0x30, "5" )
199 	PORT_DIPNAME(0xc0, 0x00, DEF_STR( Coin_B ) )
200 	PORT_DIPSETTING(   0xc0, DEF_STR( 3C_1C ) )
201 	PORT_DIPSETTING(   0x80, DEF_STR( 2C_1C ) )
202 	PORT_DIPSETTING(   0x00, DEF_STR( 1C_1C ) )
203 	PORT_DIPSETTING(   0x40, DEF_STR( 1C_2C ) )
204 INPUT_PORTS_END
205 
206 ///////////////////////////////////////////////////////////////////////////////////
207 
208 static struct GfxLayout toypop_charlayout =
209 {
210 	8,8,             /* 8*8 characters */
211 	512,             /* 512 characters */
212 	2,             /* 2 bits per pixel */
213 	{ 0, 4 },      /* the two bitplanes for 4 pixels are packed into one byte */
214 	{ 8*8+0, 8*8+1, 8*8+2, 8*8+3, 0, 1, 2, 3 },   /* bits are packed in groups of four */
215 	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },   /* v offset */
216 	16*8           /* every char takes 16 bytes */
217 };
218 
219 static struct GfxLayout toypop_spritelayout =
220 {
221 	16,16,       /* 16*16 sprites */
222 	256,            /* 256 sprites */
223 	2,                 /* 2 bits per pixel */
224 	{ 0, 4 },   /* the two bitplanes for 4 pixels are packed into one byte */
225 	{ 0, 1, 2, 3, 8*8, 8*8+1, 8*8+2, 8*8+3, 16*8+0, 16*8+1, 16*8+2, 16*8+3,
226 	24*8+0, 24*8+1, 24*8+2, 24*8+3 },
227 	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
228 	32 * 8, 33 * 8, 34 * 8, 35 * 8, 36 * 8, 37 * 8, 38 * 8, 39 * 8 },
229 	64*8    /* every sprite takes 64 bytes */
230 };
231 
232 static struct GfxDecodeInfo toypop_gfxdecodeinfo[] =
233 {
234 	{ REGION_GFX1, 0, &toypop_charlayout,      0, 128 },
235 	{ REGION_GFX2, 0, &toypop_spritelayout, 64*4, 256 },
236 	{ -1 } /* end of array */
237 };
238 
239 /////////////////////////////////////////////////////////////////////////////////////
240 
241 static struct namco_interface namco_interface =
242 {
243 	23920,	/* sample rate (approximate value) */
244 	8,		/* number of voices */
245 	100,	/* playback volume */
246 	REGION_SOUND1	/* memory region */
247 };
248 
249 static struct MachineDriver machine_driver_toypop =
250 {
251 	/* basic machine hardware */
252 	{
253 		{
254 			CPU_M6809,
255 			1600000,	/* 1.6 Mhz (?) */
256 			toypop_readmem_I_6809,toypop_writemem_I_6809,0,0,
257 			interrupt,1
258 		},
259 		{
260 			CPU_M6809 | CPU_AUDIO_CPU,
261 			1600000,	/* 1.6 Mhz (?) */
262 			toypop_readmem_II_6809,toypop_writemem_II_6809,0,0,
263 			interrupt,1
264 		},
265 		{
266 			CPU_M68000,
267 			8000000,	/* 8 Mhz (?) */
268 			toypop_readmem_68k,toypop_writemem_68k,0,0,
269 			toypop_interrupt,1
270 		}
271 	},
272 	60, DEFAULT_60HZ_VBLANK_DURATION,	/* frames per second, vblank duration */
273 	100,    /* 100 CPU slices per frame - an high value to ensure proper */
274 			/* synchronization of the CPUs */
275 	toypop_init_machine,
276 
277 	/* video hardware */
278 	18*16, 14*16, { 0*16, 18*16-1, 0*16, 14*16-1 },
279 	toypop_gfxdecodeinfo,
280 	256,256+256,
281 	toypop_vh_convert_color_prom,
282 
283 	VIDEO_TYPE_RASTER,
284 	0,
285 	toypop_vh_start,
286 	toypop_vh_stop,
287 	toypop_vh_screenrefresh,
288 
289 	/* sound hardware */
290 	0,0,0,0,
291 	{
292 		{
293 			SOUND_NAMCO,
294 			&namco_interface
295 		}
296 	}
297 };
298 
299 
300 
301 ROM_START( liblrabl )
302 	ROM_REGION( 0x10000, REGION_CPU1 )	/* 64k for the first CPU */
303 	ROM_LOAD( "5b.rom",   0x8000, 0x4000, 0xda7a93c2 )
304 	ROM_LOAD( "5c.rom",   0xc000, 0x4000, 0x6cae25dc )
305 
306 	ROM_REGION( 0x10000, REGION_CPU2 )	/* 64k for the second CPU */
307 	ROM_LOAD( "2c.rom",   0xe000, 0x2000, 0x7c09e50a )
308 
309 	ROM_REGION( 0x8000, REGION_CPU3 )		/* 32k for the third CPU */
310 	ROM_LOAD_EVEN( "8c.rom",   0x0000, 0x4000, 0xa00cd959 )
311 	ROM_LOAD_ODD( "10c.rom",   0x0000, 0x4000, 0x09ce209b )
312 
313 	/* temporary space for graphics (disposed after conversion) */
314 	ROM_REGION( 0x2000, REGION_GFX1 | REGIONFLAG_DISPOSE )
315 	ROM_LOAD( "5p.rom",   0x0000, 0x2000, 0x3b4937f0 )	/* characters */
316 
317 	ROM_REGION( 0x4000, REGION_GFX2 | REGIONFLAG_DISPOSE )
318 	ROM_LOAD( "9t.rom",   0x0000, 0x4000, 0xa88e24ca )	/* sprites */
319 
320 	ROM_REGION( 0x0600, REGION_PROMS )	/* color proms */
321 	ROM_LOAD( "lr1-3.1r", 0x0000, 0x0100, 0xf3ec0d07 )	// palette: red component
322 	ROM_LOAD( "lr1-2.1s", 0x0100, 0x0100, 0x2ae4f702 )	// palette: green component
323 	ROM_LOAD( "lr1-1.1t", 0x0200, 0x0100, 0x7601f208 )	// palette: blue component
324 	ROM_LOAD( "lr1-5.5l", 0x0300, 0x0100, 0x940f5397 )	/* characters */
325 	ROM_LOAD( "lr1-6.2p", 0x0400, 0x0200, 0xa6b7f850 )	/* sprites */
326 
327 	ROM_REGION( 0x0100, REGION_SOUND1 )	/* sound prom */
328 	ROM_LOAD( "lr1-4.3d", 0x0000, 0x0100, 0x16a9166a )
329 ROM_END
330 
331 ROM_START( toypop )
332 	ROM_REGION( 0x10000, REGION_CPU1 )	/* 64k for the first CPU */
333 	ROM_LOAD( "tp1-2.5b", 0x8000, 0x4000, 0x87469620 )
334 	ROM_LOAD( "tp1-1.5c", 0xc000, 0x4000, 0xdee2fd6e )
335 
336 	ROM_REGION( 0x10000, REGION_CPU2 )	/* 64k for the second CPU */
337 	ROM_LOAD( "tp1-3.2c", 0xe000, 0x2000, 0x5f3bf6e2 )
338 
339 	ROM_REGION( 0x8000, REGION_CPU3 )		/* 32k for the third CPU */
340 	ROM_LOAD_EVEN( "tp1-4.8c", 0x0000, 0x4000, 0x76997db3 )
341 	ROM_LOAD_ODD( "tp1-5.10c", 0x0000, 0x4000, 0x37de8786 )
342 
343 	/* temporary space for graphics (disposed after conversion) */
344 	ROM_REGION( 0x2000, REGION_GFX1 | REGIONFLAG_DISPOSE )
345 	ROM_LOAD( "tp1-7.5p", 0x0000, 0x2000, 0x95076f9e )	/* characters */
346 
347 	ROM_REGION( 0x4000, REGION_GFX2 | REGIONFLAG_DISPOSE )
348 	ROM_LOAD( "tp1-6.9t", 0x0000, 0x4000, 0x481ffeaf )	/* sprites */
349 
350 	ROM_REGION( 0x0600, REGION_PROMS )	/* color proms */
351 	ROM_LOAD( "tp1-3.1r", 0x0000, 0x0100, 0xcfce2fa5 )	// palette: red component
352 	ROM_LOAD( "tp1-2.1s", 0x0100, 0x0100, 0xaeaf039d )	// palette: green component
353 	ROM_LOAD( "tp1-1.1t", 0x0200, 0x0100, 0x08e7cde3 )	// palette: blue component
354 	ROM_LOAD( "tp1-4.5l", 0x0300, 0x0100, 0x74138973 )	/* characters */
355 	ROM_LOAD( "tp1-5.2p", 0x0400, 0x0200, 0x4d77fa5a )	/* sprites */
356 
357 	ROM_REGION( 0x0100, REGION_SOUND1 )	/* sound prom */
358 	ROM_LOAD( "lr1-4.3d", 0x0000, 0x0100, 0x16a9166a )
359 ROM_END
360 
361 
362 GAMEX(1983, liblrabl, 0, toypop, toypop, 0, ROT0, "Namco", "Libble Rabble", GAME_NOT_WORKING )
363 GAME( 1986, toypop,   0, toypop, toypop, 0, ROT0, "Namco", "Toypop" )
364