#include "../mame/drivers/gyruss.c"

#include "audio/misfmod.h"


WRITE8_HANDLER( gyrussm_music )
{
	switch (data)
	{
	case 0: /* STOP */
		StopFile(0);
		break;

	case 36: /* STOP */
		StopFile(0);
		break;
		
	case 37: /* All 2532954*/
		PlayFile(0, 170, "songs/smgyruss/gyruss36.ogg", 1,521285, 1211386);
		return;

	case 38:
		PlayFile(0, 170, "songs/smgyruss/gyruss40.ogg", 1, 0, 0);
		return;
		
	case 39:
		PlayFile(0, 170, "songs/smgyruss/gyruss39.ogg", 1, 0, 0);
		return;
		
	case 40:
		PlayFile(0, 170, "songs/smgyruss/gyruss40.ogg", 1, 58538, 2072600);
		return;

	case 41:
		PlayFile(0, 170, "songs/smgyruss/gyruss41.ogg", 1, 235934, 2250700);
		return;
	}

	soundlatch_w( machine, 0, data&0xff );
}

static ADDRESS_MAP_START( gyrussm_cpu1_map, ADDRESS_SPACE_PROGRAM, 8 )
	AM_RANGE(0x0000, 0x7fff) AM_ROM
	AM_RANGE(0x8000, 0x83ff) AM_RAM AM_BASE(&gyruss_colorram)
	AM_RANGE(0x8400, 0x87ff) AM_RAM AM_BASE(&gyruss_videoram)
	AM_RANGE(0x9000, 0x9fff) AM_RAM
	AM_RANGE(0xa000, 0xa7ff) AM_RAM AM_SHARE(1)
	AM_RANGE(0xc000, 0xc000) AM_READ_PORT("DSW2") AM_WRITENOP	/* watchdog reset */
	AM_RANGE(0xc080, 0xc080) AM_READ_PORT("SYSTEM") AM_WRITE(gyruss_sh_irqtrigger_w)
	AM_RANGE(0xc0a0, 0xc0a0) AM_READ_PORT("P1")
	AM_RANGE(0xc0c0, 0xc0c0) AM_READ_PORT("P2")
	AM_RANGE(0xc0e0, 0xc0e0) AM_READ_PORT("DSW1")
	AM_RANGE(0xc100, 0xc100) AM_READ_PORT("DSW3") //AM_WRITE(soundlatch_w)
	AM_RANGE(0xc100, 0xc100) AM_WRITE(gyrussm_music)
	AM_RANGE(0xc180, 0xc180) AM_WRITE(interrupt_enable_w)
	AM_RANGE(0xc185, 0xc185) AM_WRITE(SMH_RAM) AM_BASE(&gyruss_flipscreen)
ADDRESS_MAP_END

static MACHINE_DRIVER_START( gyrussm )
	MDRV_IMPORT_FROM(gyruss)
	MDRV_CPU_MODIFY("main")
	MDRV_CPU_PROGRAM_MAP(gyrussm_cpu1_map,0)
MACHINE_DRIVER_END



/***************************************************************************

  Game driver(s)

***************************************************************************/

#define rom_gyrussm rom_gyruss

GAME( 1983, gyrussm,   0,      gyrussm, gyruss,   gyruss, ROT90, "Konami", "Speed Metal Gyruss", GAME_SUPPORTS_SAVE )
