static int DrvFrame() { int nInterleave = 10; int nSoundBufferPos = 0; if (DrvReset) DrvDoReset(); DrvMakeInputs(); nCyclesTotal[0] = 28638000 / 60; nCyclesDone[0] = 0; for (int i = 0; i < nInterleave; i++) { int nCurrentCPU, nNext; nCurrentCPU = 0; Sh2Open(0); nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave; nCyclesSegment = nNext - nCyclesDone[nCurrentCPU]; nCyclesDone[nCurrentCPU] += Sh2Run(nCyclesSegment); if (i == 5) Sh2SetIRQLine(1, SH2_IRQSTATUS_AUTO); if (i == 9) Sh2SetIRQLine(5, SH2_IRQSTATUS_AUTO); Sh2Close(); } if (pBurnDraw) DrvDraw(); return 0; }
static int DrvDoReset() { Sh2Open(0); Sh2Reset(*(unsigned int *)(DrvBiosRom + 0), *(unsigned int *)(DrvBiosRom + 4)); Sh2Close(); return 0; }
static int s1945iiInit() { int nRet; Mem = NULL; MemIndex(); int nLen = MemEnd - (unsigned char *)0; if ((Mem = (unsigned char *)malloc(nLen)) == NULL) return 1; memset(Mem, 0, nLen); // blank all memory MemIndex(); nRet = BurnLoadRom(RomSH2 + 0x000000, 0, 2); if (nRet != 0) return 1; nRet = BurnLoadRom(RomSH2 + 0x000001, 1, 2); if (nRet != 0) return 1; be_to_le( RomSH2, 0x100000 ); #if 0 FILE * f = fopen("d.bin", "wb+"); fwrite(RomSH2, 1, 0x100000, f); fclose(f); #endif { Sh2Init(1); Sh2Open(0); // Map 68000 memory: Sh2MapMemory(RomSH2, 0x00000000, 0x000fffff, SM_ROM); Sh2MapMemory(RamSpr, 0x03000000, 0x0300ffff, SM_RAM); Sh2MapMemory((unsigned char *) RamPal, 0x03040000, 0x03044fff, SM_RAM); Sh2MapMemory(RamVReg, 0x03050000, 0x0305ffff, SM_WRITE); Sh2MapMemory(RamSH2, 0x06000000, 0x060fffff, SM_RAM); Sh2SetReadByteHandler (0, ps3v1ReadByte); Sh2SetReadWordHandler (0, ps3v1ReadWord); Sh2SetReadLongHandler (0, ps3v1ReadLong); Sh2SetWriteByteHandler(0, ps3v1WriteByte); Sh2SetWriteWordHandler(0, ps3v1WriteWord); Sh2SetWriteLongHandler(0, ps3v1WriteLong); } DrvDoReset(); return 0; }
static void cpu_open(INT32 nCpu) { switch (nCpuType) { case 1: SekOpen(nCpu); break; case 2: VezOpen(nCpu); break; case 3: Sh2Open(nCpu); break; case 4: M6502Open(nCpu); break; case 5: ZetOpen(nCpu); break; case 6: M6809Open(nCpu); break; case 7: HD6309Open(nCpu); break; case 8: break; case 9: s2650Open(nCpu); break; } }
static int DrvInit(int (*LoadCallback)(), int type, int gfx_max, int gfx_min) { AllMem = NULL; MemIndex(gfx_max - gfx_min); int nLen = MemEnd - (unsigned char *)0; if ((AllMem = (unsigned char *)malloc(nLen)) == NULL) return 1; memset(AllMem, 0, nLen); MemIndex(gfx_max - gfx_min); { if (LoadCallback) { if (LoadCallback()) return 1; } BurnSwap32(DrvSh2ROM, 0x100000); BurnSwapEndian(0x200000); DrvGfxDecode(gfx_max - gfx_min); graphics_min_max[0] = gfx_min; graphics_min_max[1] = gfx_max; } if (type == 0) { Sh2Init(1); Sh2Open(0); Sh2MapMemory(DrvSh2ROM, 0x00000000, 0x000fffff, SM_ROM); Sh2MapMemory(DrvSh2ROM + 0x100000, 0x02000000, 0x020fffff, SM_ROM); Sh2MapMemory(DrvSprRAM, 0x03000000, 0x0300ffff, SM_RAM); Sh2MapMemory(DrvPalRAM, 0x03040000, 0x0304ffff, SM_RAM); Sh2MapMemory(DrvZoomRAM, 0x03050000, 0x0305ffff, SM_ROM); Sh2MapMemory(DrvSh2RAM, 0x06000000, 0x060fffff, SM_RAM); Sh2SetReadByteHandler (0, ps3v1_read_byte); Sh2SetWriteByteHandler(0, ps3v1_write_byte); Sh2SetWriteWordHandler(0, ps3v1_write_word); Sh2SetWriteLongHandler(0, psx_write_long); } else { Sh2Init(1); Sh2Open(0); Sh2MapMemory(DrvSh2ROM, 0x00000000, 0x000fffff, SM_ROM); Sh2MapMemory(DrvSprRAM, 0x04000000, 0x0400ffff, SM_RAM); Sh2MapMemory(DrvPalRAM, 0x04040000, 0x0404ffff, SM_RAM); Sh2MapMemory(DrvZoomRAM, 0x04050000, 0x0405ffff, SM_ROM); Sh2MapMemory(DrvSh2ROM + 0x100000, 0x05000000, 0x0507ffff, SM_ROM); Sh2MapMemory(DrvSh2RAM, 0x06000000, 0x060fffff, SM_RAM); Sh2SetReadByteHandler (0, ps5_read_byte); Sh2SetWriteByteHandler(0, ps5_write_byte); Sh2SetWriteWordHandler(0, ps5_write_word); Sh2SetWriteLongHandler(0, psx_write_long); } Sh2MapHandler(1, 0x06000000 | speedhack_address, 0x0600ffff | speedhack_address, SM_ROM); Sh2SetReadByteHandler (1, hack_read_byte); Sh2SetReadWordHandler (1, hack_read_word); Sh2SetReadLongHandler (1, hack_read_long); BurnYMF278BInit(0, DrvSndROM, &DrvIRQCallback, DrvSynchroniseStream); BurnTimerAttachSh2(28636350); EEPROMInit(&eeprom_interface_93C56); PsikyoshVideoInit(gfx_max, gfx_min); DrvDoReset(); return 0; }
static int CyvernInit() { int nRet = 0, nLen; BurnSetRefreshRate(59.5971); // Allocate and Blank all required memory Mem = NULL; MemIndex(); nLen = MemEnd - (unsigned char *)0; if ((Mem = (unsigned char *)malloc(nLen)) == NULL) return 1; memset(Mem, 0, nLen); MemIndex(); DrvTempRom = (unsigned char *)malloc(0x800000); // Load BIOS Rom nRet = BurnLoadRom(DrvBiosRom + 0x000000, 0, 1); if (nRet != 0) return 1; be_to_le(DrvBiosRom, 0x00080000); // Load Program Rom nRet = BurnLoadRom(DrvPrgRom + 0x000000, 1, 2); if (nRet != 0) return 1; nRet = BurnLoadRom(DrvPrgRom + 0x000001, 2, 2); if (nRet != 0) return 1; be_to_le(DrvPrgRom, 0x00200000); free(DrvTempRom); // Setup the 68000 emulation Sh2Init(1); Sh2Open(0); Sh2MapMemory(DrvBiosRom , 0x00000000, 0x0007ffff, SM_ROM); Sh2MapMemory(DrvSpriteRam , 0x02000000, 0x02003fff, SM_RAM); Sh2MapMemory(DrvSpriteRegs , 0x02100000, 0x0210003f, SM_RAM); Sh2MapMemory(DrvTileRegs , 0x02400000, 0x0240007f, SM_RAM); Sh2MapMemory(DrvTileARam , 0x02500000, 0x02503fff, SM_RAM); Sh2MapMemory(DrvTileBRam , 0x02504000, 0x02507fff, SM_RAM); Sh2MapMemory(DrvTileLineRam , 0x02600000, 0x02607fff, SM_RAM); Sh2MapMemory(DrvPaletteRegs , 0x02a00000, 0x02a0001f, SM_RAM); Sh2MapMemory(DrvPaletteRam , 0x02a40000, 0x02a5ffff, SM_RAM); Sh2MapMemory(DrvPrgRom , 0x04000000, 0x041fffff, SM_ROM); Sh2MapMemory(DrvTileBTilesRam , 0x04800000, 0x0483ffff, SM_RAM); Sh2MapMemory(DrvPrgRam , 0x06000000, 0x06ffffff, SM_RAM); // Sh2MapMemory(DrvPrgRam , 0x06000000, 0x06ffffff, SM_WRITE); Sh2MapMemory(DrvCacheRam , 0xc0000000, 0xc0000fff, SM_RAM); // Sh2MapHandler(1 , 0x06000028, 0x0600002b, SM_READ); Sh2SetReadByteHandler (0, CyvernReadByte); Sh2SetReadWordHandler (0, CyvernReadWord); Sh2SetReadLongHandler (0, CyvernReadLong); Sh2SetWriteByteHandler(0, CyvernWriteByte); Sh2SetWriteWordHandler(0, CyvernWriteWord); Sh2SetWriteLongHandler(0, CyvernWriteLong); // Sh2SetReadByteHandler (1, BiosSkipReadByte); // Sh2SetReadWordHandler (1, BiosSkipReadWord); // Sh2SetReadLongHandler (1, BiosSkipReadLong); Sh2Close(); GenericTilesInit(); // Reset the driver DrvDoReset(); return 0; }