Esempio n. 1
1
void K053936Init(INT32 chip, UINT8 *ram, INT32 len, INT32 w, INT32 h, void (*pCallback)(INT32 offset, UINT16 *ram, INT32 *code, INT32 *color, INT32 *sx, INT32 *sy, INT32 *fx, INT32 *fy))
{
	ramptr[chip] = ram;

	nRamLen[chip] = len;

	if (rambuf[chip] == NULL) {
		rambuf[chip] = (UINT8*)BurnMalloc(len);
	}

	nWidth[chip] = w;
	nHeight[chip] = h;

	if (tscreen[chip] == NULL) {
		tscreen[chip] = (UINT16*)BurnMalloc(w * h * 2);
	}

	if (chip == 0) {
		pTileCallback0 = pCallback;
	}
	if (chip == 1) {
		pTileCallback1 = pCallback;
	}

	KonamiAllocateBitmaps();

	KonamiIC_K053936InUse = 1;
}
Esempio n. 2
0
void tms34061_init(UINT8 rowshift, UINT32 ram_size, void (*partial_update)(), void (*callback)(INT32 state))
{
	DebugDev_Tms34061Initted = 1;
	
	m_partial_update = partial_update;
	m_rowshift = rowshift;
	m_vramsize = ram_size;

	/* resolve callbak */
	m_interrupt_cb = callback;

	/* reset the data */
	m_vrammask = m_vramsize - 1;

	/* allocate memory for VRAM */
	m_vram = (UINT8*)BurnMalloc(m_vramsize + 256 * 2);

	/* allocate memory for latch RAM */
	m_latchram = (UINT8*)BurnMalloc(m_vramsize + 256 * 2);

	/* add some buffer space for VRAM and latch RAM */
	m_vram += 256;
	m_latchram += 256;

	/* point the shift register to the base of VRAM for now */
	m_shiftreg = m_vram;
}
Esempio n. 3
0
void K053247Init(UINT8 *gfxrom, INT32 gfxlen, void (*Callback)(INT32 *code, INT32 *color, INT32 *priority), INT32 flags)
{
	K053247Ram = (UINT8*)BurnMalloc(0x1000);

	K053246Gfx = gfxrom;
	K053246Mask = gfxlen;

	K053247Callback = Callback;

	K053247_dx = 0;
	K053247_dy = 0;
	K053247_wraparound = 1;

	if (konami_temp_screen == NULL) {
		INT32 width, height;
		BurnDrvGetVisibleSize(&width, &height);
		konami_temp_screen = (UINT16*)BurnMalloc(width * height * 2);
	}

	K053247Temp = konami_temp_screen;

	K053247Flags = flags; // 0x02 highlight, 0x01 shadow

	KonamiIC_K053247InUse = 1;
}
Esempio n. 4
0
INT32 CavePalInit(INT32 nPalSize)
{
	CavePalette = (UINT32*)BurnMalloc(nPalSize * sizeof(UINT32));
	memset(CavePalette, 0, nPalSize * sizeof(UINT32));

	CavePalCopy = (UINT16*)BurnMalloc(nPalSize * sizeof(UINT16));
	memset(CavePalCopy, 0, nPalSize * sizeof(UINT16));
	
	pBurnDrvPalette = CavePalette;

	return 0;
}
Esempio n. 5
0
static INT32 LoadUpSplit(UINT8** pRom, INT32* pnRomLen, INT32 nNum, INT32 nNumRomsGroup)
{
	UINT8 *Rom;
	struct BurnRomInfo ri;
	UINT32 nRomSize[8], nTotalRomSize = 0;
	INT32 i;

	ri.nLen = 0;
	for (i = 0; i < nNumRomsGroup; i++) {
		BurnDrvGetRomInfo(&ri, nNum + i);
		nRomSize[i] = ri.nLen;
	}
	
	for (i = 0; i < nNumRomsGroup; i++) {
		nTotalRomSize += nRomSize[i];
	}
	if (!nTotalRomSize) return 1;

	Rom = (UINT8*)BurnMalloc(nTotalRomSize);
	if (Rom == NULL) return 1;
	
	INT32 Offset = 0;
	for (i = 0; i < nNumRomsGroup; i++) {
		if (i > 0) Offset += nRomSize[i - 1];
		if (BurnLoadRom(Rom + Offset, nNum + i, 1)) {
			BurnFree(Rom);
			return 1;
		}
	}

	*pRom = Rom;
	*pnRomLen = nTotalRomSize;
	
	return 0;
}
Esempio n. 6
0
// Allocate space and load up a rom
static INT32 LoadUp(UINT8** pRom, INT32* pnRomLen, INT32 nNum)
{
	UINT8 *Rom;
	struct BurnRomInfo ri;

	ri.nLen = 0;
	BurnDrvGetRomInfo(&ri, nNum);	// Find out how big the rom is
	if (ri.nLen <= 0) {
		return 1;
	}

	// Load the rom
	Rom = (UINT8*)BurnMalloc(ri.nLen);
	if (Rom == NULL) {
		return 1;
	}

	if (BurnLoadRom(Rom,nNum,1)) {
		BurnFree(Rom);
		return 1;
	}

	// Success
	*pRom = Rom; *pnRomLen = ri.nLen;
	return 0;
}
Esempio n. 7
0
static INT32 DrvGfxDecode()
{
	INT32 Plane0[4]  = { 0, 4, RGN_FRAC(0x04000, 1,2), RGN_FRAC(0x04000, 1,2)+4 };
	INT32 Plane1[4]  = { 0, 4, RGN_FRAC(0x40000, 1,2), RGN_FRAC(0x40000, 1,2)+4 };
	INT32 Plane2[4]  = { 0, 4, RGN_FRAC(0x40000, 1,2), RGN_FRAC(0x40000, 1,2)+4 };
	INT32 XOffs[16]  = { STEP4(0,1), STEP4(8,1), STEP4(16,1), STEP4(24,1) };
	INT32 YOffs0[8]  = { STEP8(0,16) };
	INT32 YOffs1[16] = { STEP16(0,32) };

	UINT8 *tmp = (UINT8*)BurnMalloc(0x40000);
	if (tmp == NULL) {
		return 1;
	}

	memcpy (tmp, DrvGfxROM0, 0x04000);

	GfxDecode(0x0200, 4,  8,  8, Plane0, XOffs, YOffs0, 0x080, tmp, DrvGfxROM0);

	memcpy (tmp, DrvGfxROM1, 0x40000);

	GfxDecode(0x0800, 4, 16, 16, Plane1, XOffs, YOffs1, 0x200, tmp, DrvGfxROM1);

	memcpy (tmp, DrvGfxROM2, 0x40000);

	GfxDecode(0x0800, 4, 16, 16, Plane2, XOffs, YOffs1, 0x200, tmp, DrvGfxROM2);

	BurnFree (tmp);

	return 0;
}
Esempio n. 8
0
static INT32 crushermInit()
{
	INT32 nLen;

	BurnSetRefreshRate(CAVE_REFRESHRATE);

	// Find out how much memory is needed
	Mem = NULL;
	MemIndex();
	nLen = MemEnd - (UINT8 *)0;
	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) {
		return 1;
	}
	memset(Mem, 0, nLen);										// blank all memory
	MemIndex();													// Index the allocated memory

	// Load the roms into memory
	if (crushermLoadRoms()) {
		return 1;
	}

	EEPROMInit(&eeprom_interface_93C46_8bit);

	{

		SekInit(0, 0x68000);												// Allocate 68000
		SekOpen(0);

		// Map 68000 memory:
		SekMapMemory(Rom01,		0x000000, 0x07FFFF, MAP_ROM);	// CPU 0 ROM
		SekMapMemory(CaveTileRAM[0],	0x100000, 0x107FFF, MAP_RAM);
		SekMapMemory(CaveSpriteRAM,	0x180000, 0x187FFF, MAP_RAM);
		SekMapMemory(CavePalSrc,	0x200000, 0x207FFF, MAP_RAM);
		SekMapMemory(Ram01,		0x340000, 0x34FFFF, MAP_RAM);

		SekSetReadWordHandler(0, 	korokoroReadWord);
		SekSetReadByteHandler(0, 	korokoroReadByte);
		SekSetWriteWordHandler(0, 	korokoroWriteWord);
		SekSetWriteByteHandler(0, 	korokoroWriteByte);

		SekClose();
	}

	nCaveRowModeOffset = 1;

	CavePalInit(0x8000);
	CaveTileInit();
	CaveSpriteInit(1, 0x400000);
	CaveTileInitLayer(0, 0x200000, 4, 0x4400);

	YMZ280BInit(16934400, &TriggerSoundIRQ, 0x200000);
	YMZ280BSetRoute(BURN_SND_YMZ280B_YMZ280B_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT);
	YMZ280BSetRoute(BURN_SND_YMZ280B_YMZ280B_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT);

	bDrawScreen = true;

	DrvDoReset(); // Reset machine

	return 0;
}
Esempio n. 9
0
static INT32 DrvGfxDecode()
{
	INT32 Plane0[4]  = { 0x200000, 0x300000, 0x000000, 0x100000 };
	INT32 XOffs0[8]  = { 0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007 };
	INT32 YOffs0[8]  = { 0x038, 0x030, 0x028, 0x020, 0x018, 0x010, 0x008, 0x000 };

	INT32 Plane1[4]  = { 0x000004, 0x000000, 0x100004, 0x100000 };
	INT32 XOffs1[16] = { 0x10b, 0x10a, 0x109, 0x108, 0x103, 0x102, 0x101, 0x100,
			   0x00b, 0x00a, 0x009, 0x008, 0x003, 0x002, 0x001, 0x000 };
	INT32 YOffs1[16] = { 0x0f0, 0x0e0, 0x0d0, 0x0c0, 0x0b0, 0x0a0, 0x090, 0x080,
			   0x070, 0x060, 0x050, 0x040, 0x030, 0x020, 0x010, 0x000 };

	UINT8 *tmp = (UINT8*)BurnMalloc(0x80000);
	if (tmp == NULL) {
		return 1;
	}

	for (INT32 i = 0; i < 0x80000; i++) tmp[i] = DrvGfxROM0[i] ^ 0xff;

	GfxDecode(0x4000, 4,  8,  8, Plane0, XOffs0, YOffs0, 0x040, tmp, DrvGfxROM0);

	for (INT32 i = 0; i < 0x40000; i++) tmp[i] = DrvGfxROM1[i] ^ 0xff;

	GfxDecode(0x0800, 4, 16, 16, Plane1, XOffs1, YOffs1, 0x200, tmp, DrvGfxROM1);

	BurnFree (tmp);

	return 0;
}
Esempio n. 10
0
INT32 Sf2mdtSoundInit()
{
	Sf2mdtZ80Ram = (UINT8*)BurnMalloc(0x800);
	
	ZetInit(0);
	ZetOpen(0);
	ZetSetReadHandler(Sf2mdtZ80Read);
	ZetSetWriteHandler(Sf2mdtZ80Write);
	ZetMapArea(0x0000, 0x7fff, 0, CpsZRom + 0x00000);
	ZetMapArea(0x0000, 0x7fff, 2, CpsZRom + 0x00000);
	ZetMapArea(0x8000, 0xbfff, 0, CpsZRom + 0x08000);
	ZetMapArea(0x8000, 0xbfff, 2, CpsZRom + 0x08000);
	ZetMapArea(0xd000, 0xd7ff, 0, Sf2mdtZ80Ram     );
	ZetMapArea(0xd000, 0xd7ff, 1, Sf2mdtZ80Ram     );
	ZetMapArea(0xd000, 0xd7ff, 2, Sf2mdtZ80Ram     );
	ZetClose();
	
	BurnYM2151Init(3579540);
	BurnYM2151SetAllRoutes(0.35, BURN_SND_ROUTE_BOTH);
	
	MSM5205Init(0, Sf2mdtSynchroniseStream, 24000000 / 64, Sf2mdtMSM5205Vck0, MSM5205_S96_4B, 1);
	MSM5205Init(1, Sf2mdtSynchroniseStream, 24000000 / 64, Sf2mdtMSM5205Vck1, MSM5205_S96_4B, 1);
	MSM5205SetRoute(0, 0.25, BURN_SND_ROUTE_BOTH);
	MSM5205SetRoute(1, 0.25, BURN_SND_ROUTE_BOTH);
	
	nCpsZ80Cycles = 3579540 * 100 / nBurnFPS;
	
	Sf2mdtNumZ80Banks = (nCpsZRomLen / 0x4000) - 1;
	
	return 0;
}
Esempio n. 11
0
static INT32 DrvInit()
{
	GenericTilesInit();

	AllMem = NULL;
	MemIndex();
	INT32 nLen = MemEnd - (UINT8 *)0;
	if ((AllMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
	memset(AllMem, 0, nLen);
	MemIndex();

	{
		if (BurnLoadRom(Drv68KROM  + 0x000000,  0, 1)) return 1;
		if (BurnLoadRom(Drv68KROM  + 0x080000,  1, 1)) return 1;

		if (BurnLoadRom(DrvGfxROM  + 0x000000,  2, 2)) return 1;
		if (BurnLoadRom(DrvGfxROM  + 0x000001,  3, 2)) return 1;
		if (BurnLoadRom(DrvGfxROM  + 0x100000,  4, 2)) return 1;
		if (BurnLoadRom(DrvGfxROM  + 0x100001,  5, 2)) return 1;

		if (BurnLoadRom(YMZ280BROM + 0x000000,  6, 1)) return 1;
		if (BurnLoadRom(YMZ280BROM + 0x080000,  7, 1)) return 1;
		if (BurnLoadRom(YMZ280BROM + 0x100000,  8, 1)) return 1;
		if (BurnLoadRom(YMZ280BROM + 0x180000,  9, 1)) return 1;

		DrvGfxDecode();
	}

	SekInit(0, 0x68000);
	SekOpen(0);
	SekMapMemory(Drv68KROM,		0x000000, 0x0fffff, MAP_ROM);
	SekMapMemory(Drv68KRAM,		0x400000, 0x407fff, MAP_RAM);
	SekMapMemory(DrvPalRAM,		0xb00000, 0xb03fff, MAP_RAM);
	SekMapMemory(DrvPalRAM,		0xb04000, 0xb047ff, MAP_ROM);
	SekSetWriteWordHandler(0,	bishi_write_word);
	SekSetWriteByteHandler(0,	bishi_write_byte);
	SekSetReadWordHandler(0,	bishi_read_word);
	SekSetReadByteHandler(0,	bishi_read_byte);
	SekClose();

	K055555Init();
	K054338Init();

	K056832Init(DrvGfxROM, DrvGfxROMExp, 0x200000, bishi_tile_callback);
	K056832SetGlobalOffsets(29, 16);
	K056832SetLayerOffsets(0, -2, 0);
	K056832SetLayerOffsets(1,  2, 0);
	K056832SetLayerOffsets(2,  4, 0);
	K056832SetLayerOffsets(3,  6, 0);
	K056832SetLayerAssociation(0);

	YMZ280BInit(16934400, bishi_sound_irq);
	YMZ280BSetRoute(BURN_SND_YMZ280B_YMZ280B_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT);
	YMZ280BSetRoute(BURN_SND_YMZ280B_YMZ280B_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT);

	DrvDoReset();

	return 0;
}
Esempio n. 12
0
static INT32 DrvInit()
{
	INT32 nLen;

#ifdef DRIVER_ROTATION
	bToaRotateScreen = false;
#endif

	nGP9001ROMSize[0] = 0x800000;

	// Find out how much memory is needed
	Mem = NULL;
	MemIndex();
	nLen = MemEnd - (UINT8 *)0;
	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) {
		return 1;
	}
	memset(Mem, 0, nLen);										// blank all memory
	MemIndex();													// Index the allocated memory

	// Load the roms into memory
	if (LoadRoms()) {
		return 1;
	}

	{
		SekInit(0, 0x68000);								// Allocate 68000
		SekOpen(0);
		SekMapMemory(Rom01,		0x000000, 0x07FFFF, SM_ROM);
		SekMapMemory(Ram01,		0x100000, 0x103FFF, SM_RAM);
		SekMapMemory(RamPal,		0x400000, 0x400FFF, SM_RAM);
		SekSetReadWordHandler(0, 	kbash2ReadWord);
		SekSetReadByteHandler(0, 	kbash2ReadByte);
		SekSetWriteWordHandler(0, 	kbash2WriteWord);
		SekSetWriteByteHandler(0, 	kbash2WriteByte);

		SekClose();
	}

	MSM6295Init(0, 1000000 / 132, 100.0, 1);
	MSM6295Init(1, 1000000 / 132, 100.0, 1);

	nSpriteYOffset = 0x0011;

	nLayer0XOffset = -0x01D6;
	nLayer1XOffset = -0x01D8;
	nLayer2XOffset = -0x01DA;

	ToaInitGP9001();

	nToaPalLen = nColCount;
	ToaPalSrc = RamPal;
	ToaPalInit();

	bDrawScreen = true;

	DrvDoReset();			// Reset machine
	return 0;
}
Esempio n. 13
0
static int DrvInit()
{
	int nLen;

	BurnSetRefreshRate(CAVE_REFRESHRATE);

	// Find out how much memory is needed
	Mem = NULL;
	MemIndex();
	nLen = MemEnd - (unsigned char *)0;
	if ((Mem = (unsigned char *)BurnMalloc(nLen)) == NULL) {
		return 1;
	}
	memset(Mem, 0, nLen);										// blank all memory
	MemIndex();													// Index the allocated memory

	EEPROMInit(&eeprom_interface_93C46_8bit);
	
	// Load the roms into memory
	if (LoadRoms()) {
		return 1;
	}

	{

		SekInit(0, 0x68000);												// Allocate 68000
		SekOpen(0);

		// Map 68000 memory:
		SekMapMemory(Rom01,		0x000000, 0x07FFFF, SM_ROM);	// CPU 0 ROM
		SekMapMemory(CaveTileRAM[0],	0x100000, 0x107FFF, SM_RAM);
		SekMapMemory(CaveSpriteRAM,	0x180000, 0x187FFF, SM_RAM);
		SekMapMemory(CavePalSrc,	0x200000, 0x207FFF, SM_RAM);
		SekMapMemory(Ram01,		0x300000, 0x30FFFF, SM_RAM);

		SekSetReadWordHandler(0, 	korokoroReadWord);
		SekSetReadByteHandler(0, 	korokoroReadByte);
		SekSetWriteWordHandler(0, 	korokoroWriteWord);
		SekSetWriteByteHandler(0, 	korokoroWriteByte);

		SekClose();
	}

	nCaveRowModeOffset = 1;

	CavePalInit(0x8000);
	CaveTileInit();
	CaveSpriteInit(1, 0x300000);
	CaveTileInitLayer(0, 0x200000, 4, 0x4400);

	YMZ280BInit(16934400, &TriggerSoundIRQ, 3);

	bDrawScreen = true;

	DrvDoReset(); // Reset machine

	return 0;
}
Esempio n. 14
0
static INT32 DrvInit()
{
	INT32 nLen;

//	bToaRotateScreen = true;

	BurnSetRefreshRate(REFRESHRATE);

	nBCU2ROMSize = 0x080000;
	nFCU2ROMSize = 0x080000;

	// Find out how much memory is needed
	AllMem = NULL;
	MemIndex();
	nLen = MemEnd - (UINT8 *)0;
	if ((AllMem = (UINT8 *)BurnMalloc(nLen)) == NULL) {
		return 1;
	}
	memset(AllMem, 0, nLen);
	MemIndex();

	if (BurnLoadRom(Drv68KROM + 0x000001, 0, 2)) return 1;
	if (BurnLoadRom(Drv68KROM + 0x000000, 1, 2)) return 1;
	if (BurnLoadRom(Drv68KROM + 0x040001, 2, 2)) return 1;
	if (BurnLoadRom(Drv68KROM + 0x040000, 3, 2)) return 1;

	ToaLoadTiles(BCU2ROM, 4, nBCU2ROMSize);
	ToaLoadTiles(FCU2ROM, 8, nFCU2ROMSize);

	{
		SekInit(0, 0x68000);
		SekOpen(0);
		SekMapMemory(Drv68KROM,			0x000000, 0x07FFFF, SM_ROM);
		SekMapMemory(Drv68KRAM,			0x0c0000, 0x0c3FFF, SM_RAM);
		SekMapMemory(DrvPalRAM,			0x104000, 0x1047FF, SM_RAM);
		SekMapMemory(DrvPalRAM2,		0x106000, 0x1067FF, SM_RAM);
		SekSetReadWordHandler(0, 		samesameReadWord);
		SekSetReadByteHandler(0, 		samesameReadByte);
		SekSetWriteWordHandler(0, 		samesameWriteWord);
		SekSetWriteByteHandler(0, 		samesameWriteByte);
		SekClose();
	}

	ToaInitBCU2();

	nToaPalLen = nColCount;
	ToaPalSrc = DrvPalRAM;
	ToaPalSrc2 = DrvPalRAM2;
	ToaPalInit();

//	BurnYM3812Init(28000000 / 8, &toaplan1FMIRQHandler, &toaplan1SynchroniseStream, 0);

	bDrawScreen = true;

	DrvDoReset();
	return 0;
}
Esempio n. 15
0
INT32 CpsInit()
{
	INT32 nMemLen, i;
	
   if (Cps == 2)
      BurnSetRefreshRate(59.629403);

	if (!nCPS68KClockspeed) {
			nCPS68KClockspeed = 11800000;
	}
	nCPS68KClockspeed = nCPS68KClockspeed * 100 / nBurnFPS;

	nMemLen = nCpsGfxLen + nCpsRomLen + nCpsCodeLen + nCpsZRomLen + nCpsQSamLen + nCpsAdLen;

	// Allocate Gfx, Rom and Z80 Roms
	CpsGfx = (UINT8*)BurnMalloc(nMemLen);
	if (CpsGfx == NULL) {
		return 1;
	}
	memset(CpsGfx, 0, nMemLen);

	CpsRom  = CpsGfx + nCpsGfxLen;
	CpsCode = CpsRom + nCpsRomLen;
   CpsZRom = CpsCode + nCpsCodeLen;
	CpsQSam =(INT8*)(CpsZRom + nCpsZRomLen);
	CpsAd   =(UINT8*)(CpsQSam + nCpsQSamLen);

	// Create Gfx addr mask
	for (i = 0; i < 31; i++) {
		if ((1 << i) >= (INT32)nCpsGfxLen) {
			break;
		}
	}
	nCpsGfxMask = (1 << i) - 1;

	// Offset to Scroll tiles
   nCpsGfxScroll[1] = nCpsGfxScroll[2] = nCpsGfxScroll[3] = 0x800000;

#if 0
	if (nCpsZRomLen>=5) {
		// 77->cfff and rst 00 in case driver doesn't load
		CpsZRom[0] = 0x3E; CpsZRom[1] = 0x77;
		CpsZRom[2] = 0x32; CpsZRom[3] = 0xFF; CpsZRom[4] = 0xCF;
		CpsZRom[5] = 0xc7;
	}
#endif

	SepTableCalc();									  // Precalc the separate table

	CpsReset = 0; Cpi01A = Cpi01C = Cpi01E = 0;		  // blank other inputs

	// Use this as default - all CPS-2 games use it
	SetCpsBId(CPS_B_21_DEF, 0);

	return 0;
}
Esempio n. 16
0
void pic16c5xInit(INT32 /*nCPU*/, INT32 type, UINT8 *mem)
{
	DebugCPU_PIC16C5XInitted = 1;
	
	nPic16c5xCpuType = type;

	pic16c5xDoReset(type, &rom_address_mask, &ram_address_mask);

	pic16c5x_rom = mem;
	
	pic16c5x_ram = (UINT8*)BurnMalloc(ram_address_mask + 1);
}
Esempio n. 17
0
static void UpdateStream(INT32 chip, INT32 length)
{
	struct dac_info *ptr;

	if (lBuffer == NULL) {	// delay buffer allocation for cases when fps is not 60
		lBuffer = (INT16*)BurnMalloc(nBurnSoundLen * sizeof(INT16));
		memset (lBuffer, 0, nBurnSoundLen * sizeof(INT16));
	}
	if (rBuffer == NULL) {	// delay buffer allocation for cases when fps is not 60
		rBuffer = (INT16*)BurnMalloc(nBurnSoundLen * sizeof(INT16));
		memset (rBuffer, 0, nBurnSoundLen * sizeof(INT16));
	}

        ptr = &dac_table[chip];
        if (ptr->Initialized == 0) return;

        if (length > nBurnSoundLen) length = nBurnSoundLen;
        length -= ptr->nCurrentPosition;
        if (length <= 0) return;

        INT16 *lbuf = lBuffer + ptr->nCurrentPosition;
	INT16 *rbuf = rBuffer + ptr->nCurrentPosition;

	INT16 lOut = ((ptr->OutputDir & BURN_SND_ROUTE_LEFT ) == BURN_SND_ROUTE_LEFT ) ? ptr->Output : 0;
        INT16 rOut = ((ptr->OutputDir & BURN_SND_ROUTE_RIGHT) == BURN_SND_ROUTE_RIGHT) ? ptr->Output : 0;

        ptr->nCurrentPosition += length;

        if (rOut && lOut) {              
                while (length--) {
                        *lbuf++ = *lbuf + lOut;
			*rbuf++ = *rbuf + rOut;
                }
        } else if (lOut) {              
                while (length--) *lbuf++ = *lbuf + lOut;
        } else if (rOut) {            
                while (length--) *rbuf++ = *rbuf + rOut;
        }
}
Esempio n. 18
0
void PC090OJInit(INT32 nNumTiles, INT32 xOffset, INT32 yOffset, INT32 UseBuffer)
{
	PC090OJRam = (UINT8*)BurnMalloc(0x4000);
	memset(PC090OJRam, 0, 0x4000);
	
	PC090OJNumTiles = nNumTiles;
	
	PC090OJXOffset = xOffset;
	PC090OJYOffset = yOffset;
	PC090OJUseBuffer = UseBuffer;
	PC090OJPaletteOffset = 0;
	
	TaitoIC_PC090OJInUse = 1;
}
Esempio n. 19
0
void K053250Init(INT32 , UINT8 *rom, UINT8 *romexp, INT32 size)
{
	KonamiAllocateBitmaps();

	K053250Ram = (UINT16*)BurnMalloc(0x6000);
	buffer[0] = K053250Ram + 0x2000;
	buffer[1] = K053250Ram + 0x2800;

	k053250Rom = rom;
	k053250RomExp = romexp;

	unpack_nibbles(0, rom, romexp, size);

	KonamiIC_K053250InUse = 1;
}
Esempio n. 20
0
static INT32 Cps2LoadOne(UINT8* Tile, INT32 nNum, INT32 nWord, INT32 nShift)
{
	UINT8 *Rom = NULL; INT32 nRomLen = 0;
	UINT8 *pt, *pr;

	LoadUp(&Rom, &nRomLen, nNum);
	if (Rom == NULL) {
		return 1;
	}

	if (nWord == 0) {
		UINT8*Rom2 = NULL; INT32 nRomLen2 = 0;
		UINT8*Rom3 = Rom;

		LoadUp(&Rom2, &nRomLen2, nNum + 1);
		if (Rom2 == NULL) {
			return 1;
		}

		nRomLen <<= 1;
		Rom = (UINT8*)BurnMalloc(nRomLen);
		if (Rom == NULL) {
			BurnFree(Rom2);
			BurnFree(Rom3);
			return 1;
		}

		for (INT32 i = 0; i < nRomLen2; i++) {
			Rom[(i << 1) + 0] = Rom3[i];
			Rom[(i << 1) + 1] = Rom2[i];
		}

		BurnFree(Rom2);
		BurnFree(Rom3);
	}

	// Go through each section
	pt = Tile; pr = Rom;
	for (INT32 b = 0; b < nRomLen >> 19; b++) {
		Cps2Load100000(pt, pr,     nShift); pt += 0x100000;
		Cps2Load100000(pt, pr + 2, nShift); pt += 0x100000;
		pr += 0x80000;
	}

	BurnFree(Rom);

	return 0;
}
Esempio n. 21
0
void pgm_decode_kovqhsgs_gfx_block(UINT8 *src)
{
	INT32 i, j;
	UINT8 *dec = (UINT8*)BurnMalloc(0x800000);

	for (i = 0; i < 0x800000; i++)
	{
		j = BITSWAP24(i, 23, 10, 9, 22, 19, 18, 20, 21, 17, 16, 15, 14, 13, 12, 11, 8, 7, 6, 5, 4, 3, 2, 1, 0);

		dec[j] = src[i];
	}

	memcpy (src, dec, 0x800000);

	BurnFree (dec);
}
Esempio n. 22
0
static INT32 AllocateMemory()
{
    INT32 nLen;

    CpsMem = NULL;													// Find out how much memory is needed
    CpsMemIndex();
    nLen = CpsMemEnd - (UINT8*)0;

    if ((CpsMem = (UINT8*)BurnMalloc(nLen)) == NULL) {
        return 1;
    }

    memset(CpsMem, 0, nLen);										// blank all memory
    CpsMemIndex();													// Index the allocated memory

    return 0;
}
Esempio n. 23
0
static void pgm_decode_kovassg_program()
{
	INT32 i, j;
	UINT16 *src = (UINT16 *)PGM68KROM;
	UINT16 *dst = (UINT16 *)BurnMalloc(0x400000);

	for (i = 0; i < 0x400000/2; i++)
	{
		j = (i & ~0xffff) | (BITSWAP16(i, 15, 14, 13, 12,  11, 10, 7, 3,  1, 9, 4, 8,  6, 0, 2, 5) ^ 0x019c);

		dst[i] = BITSWAP16(src[j], 13, 9, 10, 11, 2, 0, 12 ,5, 4, 1, 14, 8, 15, 6, 3, 7) ^ 0x9d05;
	}

	memcpy (src, dst, 0x400000);

	BurnFree (dst);
}
Esempio n. 24
0
static void pgm_decode_kovlsqh2_program()
{
	INT32 i, j;
	UINT16 *src = (UINT16*)PGM68KROM;
	UINT16 *dst = (UINT16*)BurnMalloc(0x400000);

	for (i = 0; i < 0x400000 / 2; i++)
	{
		j = BITSWAP24(i, 23, 22, 21, 20, 19, 16, 15, 14, 13, 12, 11, 10, 9, 8, 0, 1, 2, 3, 4, 5, 6, 18, 17, 7);

		dst[j] = BURN_ENDIAN_SWAP_INT16(src[i]);
	}

	memcpy (src, dst, 0x400000);

	BurnFree (dst);
}
Esempio n. 25
0
void pgm_decode_kovqhsgs_tile_data(UINT8 *source)
{
	INT32 i, j;
	UINT16 *src = (UINT16*)source;
	UINT16 *dst = (UINT16*)BurnMalloc(0x800000);

	for (i = 0; i < 0x800000 / 2; i++)
	{
		j = BITSWAP24(i, 23, 22, 9, 8, 21, 18, 0, 1, 2, 3, 16, 15, 14, 13, 12, 11, 10, 19, 20, 17, 7, 6, 5, 4);

		dst[j] = BURN_ENDIAN_SWAP_INT16(BITSWAP16(BURN_ENDIAN_SWAP_INT16(src[i]), 1, 14, 8, 7, 0, 15, 6, 9, 13, 2, 5, 10, 12, 3, 4, 11));
	}

	memcpy (src, dst, 0x800000);

	BurnFree (dst);
}
Esempio n. 26
0
static void DrvSpriteDecode()
{
	UINT8 *tmp = (UINT8*)BurnMalloc(0x40000);
	if (tmp == NULL) {
		return;
	}

	memcpy (tmp, FCU2ROM, 0x40000);
	memset (FCU2ROM, 0, 0x80000);

	for (INT32 i = 0; i < (0x40000 / 4) * 8; i++) {
		for (INT32 j = 0; j < 4; j++) {
			FCU2ROM[i] |= ((tmp[(j * 0x10000) + (i/8)] >> (~i & 7)) & 1) << (3 - j);
		}
	}

	BurnFree (tmp);
}
Esempio n. 27
0
int Adsp2100Init()
{
    pMemMap = new Adsp2100MemoryMap;
    ResetMemoryMap();
    pADSP = (adsp2100_state*) BurnMalloc(sizeof(adsp2100_state));
    adsp2105_init(pADSP, nullptr);
    pADSP->sport_rx_callback = RxCallback;
    pADSP->sport_tx_callback = TxCallback;
    pADSP->timer_fired = TimerCallback;

    pTimerCallback = NULL;
    pTxCallback = NULL;
    pRxCallback = NULL;

#if ENABLE_TRACE
    pTrace = fopen("adsp21xx.txt", "w");
#endif
    return 0;
}
Esempio n. 28
0
static INT32 drvInit()
{
	INT32 nLen;
    
#ifdef DRIVER_ROTATION
	bToaRotateScreen = true;
#endif
    
	nGP9001ROMSize[0] = 0x01000000;
    
	// Find out how much memory is needed
	Mem = NULL;
	MemIndex();
	nLen = MemEnd - (UINT8*)0;
	if ((Mem = (UINT8*)BurnMalloc(nLen)) == NULL) {
		return 1;
	}
	memset(Mem, 0, nLen);										// Zero memory
	MemIndex();													// Index the allocated memory
    
	if (LoadRoms()) {
		return 1;
	}
    
	{
		SekInit(0, 0x68000);									// Allocate 68000
	    SekOpen(0);
        
		// Map 68000 memory:
		SekMapMemory(Rom01, 0x000000, 0x1FFFFF, SM_ROM);		// CPU 0 ROM
		SekMapMemory(Ram02, 0x208000, 0x20FFFF, SM_RAM);
        
		Map68KTextROM(true);
        
		SekSetReadWordHandler(0, batriderReadWord);
		SekSetReadByteHandler(0, batriderReadByte);
		SekSetWriteWordHandler(0, batriderWriteWord);
		SekSetWriteByteHandler(0, batriderWriteByte);
        
		SekMapHandler(1,	0x400000, 0x400400, SM_RAM);		// GP9001 addresses
        
		SekSetReadWordHandler(1, batriderReadWordGP9001);
		SekSetWriteWordHandler(1, batriderWriteWordGP9001);
        
		SekMapHandler(2,	0x300000, 0x37FFFF, SM_ROM);		// Z80 ROM
        
		SekSetReadByteHandler(2, batriderReadByteZ80ROM);
		SekSetReadWordHandler(2, batriderReadWordZ80ROM);
        
		SekClose();
	}
    
	nSpriteYOffset = 0x0001;
    
	nLayer0XOffset = -0x01D6;
	nLayer1XOffset = -0x01D8;
	nLayer2XOffset = -0x01DA;
    
	ToaInitGP9001();
    
	nExtraTXOffset = 0x2C;
	ToaExtraTextInit();
    
	drvZInit();				// Initialize Z80
    
	BurnYM2151Init(32000000 / 8);
	BurnYM2151SetAllRoutes(1.00, BURN_SND_ROUTE_BOTH);
	
	MSM6295Init(0, 32000000 / 10 / 132, 1);
	MSM6295Init(1, 32000000 / 10 / 165, 1);
	MSM6295SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);
	MSM6295SetRoute(1, 1.00, BURN_SND_ROUTE_BOTH);
    
	nToaPalLen = nColCount;
	ToaPalSrc = RamPal;
	ToaPalInit();
    
	nTextROMStatus = -1;
	bDrawScreen = true;
    
	drvDoReset(); // Reset machine
	return 0;
}
Esempio n. 29
0
static INT32 DrvInit()
{
	AllMem = NULL;
	MemIndex();
	INT32 nLen = MemEnd - (UINT8 *)0;
	if ((AllMem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
	memset(AllMem, 0, nLen);
	MemIndex();

	{
		if (BurnLoadRom(DrvZ80ROM0 + 0x000000,  0, 1)) return 1;
		memmove (DrvZ80ROM0 + 0x10000, DrvZ80ROM0 + 0x08000, 0x78000);

		if (BurnLoadRom(DrvZ80ROM1 + 0x000000,  1, 1)) return 1;

		if (BurnLoadRom(DrvGfxROM0 + 0x000000,  2, 1)) return 1;
		memcpy (DrvSndROM + 0x000000, DrvGfxROM0 + 0x000000, 0x020000);
		memcpy (DrvSndROM + 0x040000, DrvGfxROM0 + 0x000000, 0x020000);
		memcpy (DrvSndROM + 0x080000, DrvGfxROM0 + 0x000000, 0x020000);
		memcpy (DrvSndROM + 0x0c0000, DrvGfxROM0 + 0x000000, 0x020000);
		memcpy (DrvSndROM + 0x020000, DrvGfxROM0 + 0x000000, 0x020000);
		memcpy (DrvSndROM + 0x060000, DrvGfxROM0 + 0x020000, 0x020000);
		memcpy (DrvSndROM + 0x0a0000, DrvGfxROM0 + 0x040000, 0x020000);
		memcpy (DrvSndROM + 0x0e0000, DrvGfxROM0 + 0x060000, 0x020000);

		if (BurnLoadRom(DrvGfxROM0 + 0x000000,  3, 1)) return 1;
		if (BurnLoadRom(DrvGfxROM0 + 0x020000,  4, 1)) return 1;
		if (BurnLoadRom(DrvGfxROM0 + 0x040000,  5, 1)) return 1;
		if (BurnLoadRom(DrvGfxROM0 + 0x060000,  6, 1)) return 1;

		if (BurnLoadRom(DrvGfxROM1 + 0x000000,  7, 1)) return 1;
		if (BurnLoadRom(DrvGfxROM1 + 0x020000,  8, 1)) return 1;

		DrvGfxDecode();
	}

	ZetInit(0);
	ZetOpen(0);
	ZetMapArea(0x0000, 0x7fff, 0, DrvZ80ROM0);
	ZetMapArea(0x0000, 0x7fff, 2, DrvZ80ROM0);
	ZetMapArea(0x8000, 0x87ff, 0, DrvPalRAM);
//	ZetMapArea(0x8000, 0x87ff, 1, DrvPalRAM);
	ZetMapArea(0x8000, 0x87ff, 2, DrvPalRAM);
	ZetMapArea(0x8800, 0x8fff, 0, DrvAttrRAM);
	ZetMapArea(0x8800, 0x8fff, 1, DrvAttrRAM);
	ZetMapArea(0x8800, 0x8fff, 2, DrvAttrRAM);
	ZetMapArea(0xa000, 0xbfff, 0, DrvZ80RAM0);
	ZetMapArea(0xa000, 0xbfff, 1, DrvZ80RAM0);
	ZetMapArea(0xa000, 0xbfff, 2, DrvZ80RAM0);
	ZetSetWriteHandler(speedspn_main_write);
	ZetSetOutHandler(speedspn_main_write_port);
	ZetSetInHandler(speedspn_main_read_port);
	ZetClose();

	ZetInit(1);
	ZetOpen(1);
	ZetMapArea(0x0000, 0x7fff, 0, DrvZ80ROM1);
	ZetMapArea(0x0000, 0x7fff, 2, DrvZ80ROM1);
	ZetMapArea(0x8000, 0x87ff, 0, DrvZ80RAM1);
	ZetMapArea(0x8000, 0x87ff, 1, DrvZ80RAM1);
	ZetMapArea(0x8000, 0x87ff, 2, DrvZ80RAM1);
	ZetSetWriteHandler(speedspn_sound_write);
	ZetSetReadHandler(speedspn_sound_read);
	ZetClose();

	MSM6295Init(0, 1122000 / 132, 0);
	MSM6295SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);

	DrvDoReset();

	GenericTilesInit();

	return 0;
}
Esempio n. 30
0
static INT32 DrvInit()
{
	INT32 nLen;

#ifdef DRIVER_ROTATION
	bToaRotateScreen = true;
#endif

	BurnSetRefreshRate(REFRESHRATE);

	nBCU2ROMSize = 0x080000;
	nFCU2ROMSize = 0x080000;

	// Find out how much memory is needed
	Mem = NULL;
	MemIndex();
	nLen = MemEnd - (UINT8 *)0;
	if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) {
		return 1;
	}
	memset(Mem, 0, nLen);											// blank all memory
	MemIndex();														// Index the allocated memory

	// Load the roms into memory
	if (LoadRoms()) {
		return 1;
	}

	{
		SekInit(0, 0x68000);										// Allocate 68000
	    SekOpen(0);

		// Map 68000 memory:
		SekMapMemory(Rom01,			0x000000, 0x03FFFF, SM_ROM);	// 68K ROM
		SekMapMemory(Ram01,			0x080000, 0x083FFF, SM_RAM);	// 68K RAM
		SekMapMemory(RamPal,		0x144000, 0x1447FF, SM_RAM);	// BCU-2 palette RAM
		SekMapMemory(RamPal2,		0x146000, 0x1467FF, SM_RAM);	// FCU-2 palette RAM

		SekSetReadWordHandler(0, truxtonReadWord);
		SekSetReadByteHandler(0, truxtonReadByte);
		SekSetWriteWordHandler(0, truxtonWriteWord);
		SekSetWriteByteHandler(0, truxtonWriteByte);

		SekMapHandler(1,			0x180000, 0x180FFF, SM_RAM);	// Z80 RAM

		SekSetReadByteHandler(1, toaplan1ReadByteZ80RAM);
		SekSetReadWordHandler(1, toaplan1ReadWordZ80RAM);
		SekSetWriteByteHandler(1, toaplan1WriteByteZ80RAM);
		SekSetWriteWordHandler(1, toaplan1WriteWordZ80RAM);

		SekClose();
	}
	
	ToaInitBCU2();
	
	DrvZ80Init();													// Initialize Z80

	nToaPalLen = nColCount;
	ToaPalSrc = RamPal;
	ToaPalSrc2 = RamPal2;
	ToaPalInit();

	BurnYM3812Init(28000000 / 8, &toaplan1FMIRQHandler, &toaplan1SynchroniseStream, 0);
	BurnTimerAttachZetYM3812(28000000 / 8);
	BurnYM3812SetRoute(BURN_SND_YM3812_ROUTE, 1.00, BURN_SND_ROUTE_BOTH);

	bDrawScreen = true;

	DrvDoReset();												// Reset machine
	return 0;
}