int romMapperOpcodeModuleCreate(char* filename, UInt8* romData, int size, int slot, int sslot, int startPage, void* biosRom, int biosSize) { DeviceCallbacks callbacks = { destroy, reset, saveState, loadState }; DebugCallbacks dbgCallbacks = { getDebugInfo, NULL, NULL, NULL }; RomMapperOpcodeModule* rm = malloc(sizeof(RomMapperOpcodeModule)); rm->slot = slot; rm->sslot = sslot; rm->startPage = startPage; memset(rm->ram, 0xff, sizeof(rm->ram)); memset(rm->biosRom, 0xff, sizeof(rm->biosRom)); memset(rm->rom, 0xff, sizeof(rm->rom)); memset(rm->megaRam, 0xff, sizeof(rm->megaRam)); memset(rm->saveRam, 0xff, sizeof(rm->saveRam)); if (biosRom != NULL) { if (biosSize > sizeof(rm->biosRom)) { biosSize = sizeof(rm->biosRom); } memcpy(rm->biosRom, biosRom, biosSize); } if (romData != NULL) { if (size > sizeof(rm->rom)) { size = sizeof(rm->rom); } memcpy(rm->rom, romData, size); } rm->deviceHandle = deviceManagerRegister(ROM_OPCODEPSG, &callbacks, rm); rm->debugHandle = debugDeviceRegister(DBGTYPE_AUDIO, "AY8910", &dbgCallbacks, rm); rm->ay8910 = ay8910Create(boardGetMixer(), AY8910_MSX, PSGTYPE_AY8910, 0, NULL); ioPortRegister(0x40, read, write, rm); ioPortRegister(0x50, NULL, write, rm); ioPortRegister(0x51, NULL, write, rm); ioPortRegister(0x52, read, NULL, rm); reset(rm); return 1; }
int sviCreate(Machine* machine, VdpSyncMode vdpSyncMode, BoardInfo* boardInfo) { int success; int i; r800 = r800Create(CPU_ENABLE_M1, sviMemRead, sviMemWrite, ioPortRead, ioPortWrite, PatchZ80, (R800TimerCb)boardTimerCheckTimeout, NULL, NULL, NULL, NULL); boardInfo->cartridgeCount = 1; boardInfo->diskdriveCount = 2; boardInfo->casetteCount = 1; boardInfo->cpuRef = r800; boardInfo->destroy = destroy; boardInfo->softReset = reset; boardInfo->loadState = loadState; boardInfo->saveState = saveState; boardInfo->getRefreshRate = getRefreshRate; boardInfo->getRamPage = NULL; boardInfo->run = (void(*)(void*))r800Execute; boardInfo->stop = (void(*)(void*))r800StopExecution; boardInfo->setInt = (void(*)(void*))r800SetInt; boardInfo->clearInt = (void(*)(void*))r800ClearInt; boardInfo->setCpuTimeout = (void(*)(void*, UInt32))r800SetTimeoutAt; boardInfo->setBreakpoint = (void(*)(void*, UInt16))r800SetBreakpoint; boardInfo->clearBreakpoint = (void(*)(void*, UInt16))r800ClearBreakpoint; boardInfo->setDataBus = (void(*)(void*, UInt8, UInt8, int))r800SetDataBus; deviceManagerCreate(); boardInit(&r800->systemTime); ioPortReset(); r800Reset(r800, 0); mixerReset(boardGetMixer()); r800DebugCreate(r800); ay8910 = ay8910Create(boardGetMixer(), AY8910_SVI, PSGTYPE_AY8910, 0, machine->audio.psgpan); ay8910SetIoPort(ay8910, sviPsgReadHandler, sviPsgPollHandler, sviPsgWriteHandler, NULL); keyClick = audioKeyClickCreate(boardGetMixer()); joyIO = sviJoyIoCreate(); sviPPICreate(joyIO); slotManagerCreate(); svi80ColEnabled = 0; /* Initialize VDP */ vdpCreate(VDP_SVI, machine->video.vdpVersion, vdpSyncMode, machine->video.vramSize / 0x4000); /* Initialize memory */ for (i = 0; i < 4; i++) { slotSetSubslotted(i, 0); } for (i = 0; i < 2; i++) { cartridgeSetSlotInfo(i, machine->cart[i].slot, 0); } success = machineInitialize(machine, &sviRam, &sviRamSize, &sviRamStart); success &= sviLoad80Col(machine, vdpSyncMode); for (i = 0; i < 8; i++) { slotMapRamPage(0, 0, i); } sviMemSetBank(0xDF); ledSetCapslock(0); if (success) { success = boardInsertExternalDevices(); } memset(KeyboardMap, 0xff, 16); r800SetFrequency(r800, CPU_Z80, machine->cpu.freqZ80); r800SetFrequency(r800, CPU_R800, machine->cpu.freqR800); diskEnable(0, machine->fdc.count > 0); diskEnable(1, machine->fdc.count > 1); if (!success) { destroy(); } return success; }