void sviPPICreate(SviJoyIo* joyIO) { DeviceCallbacks callbacks = { destroy, reset, saveState, loadState }; DebugCallbacks dbgCallbacks = { getDebugInfo, NULL, NULL, NULL }; SviPPI* ppi = malloc(sizeof(SviPPI)); ppi->deviceHandle = deviceManagerRegister(RAM_MAPPER, &callbacks, ppi); ppi->debugHandle = debugDeviceRegister(DBGTYPE_BIOS, langDbgDevPpi(), &dbgCallbacks, ppi); ppi->joyIO = joyIO; ppi->i8255 = i8255Create(peekA, readA, NULL, peekB, readB, NULL, NULL, NULL, writeCLo, NULL, NULL, writeCHi, ppi); ppi->keyClick = audioKeyClickCreate(boardGetMixer()); ppi->dac = dacCreate(boardGetMixer(), DAC_MONO); ioPortRegister(0x98, i8255Read, i8255Write, ppi->i8255); // PPI Port A ioPortRegister(0x99, i8255Read, i8255Write, ppi->i8255); // PPI Port B ioPortRegister(0x96, i8255Read, i8255Write, ppi->i8255); // PPI Port C ioPortRegister(0x97, i8255Read, i8255Write, ppi->i8255); // PPI Mode ioPortRegister(0x9A, readRow, NULL, ppi); // PPI Return Port C (Low) reset(ppi); }
int romMapperSvi328RsIdeCreate(int hdId) { DeviceCallbacks callbacks = { destroy, reset, saveState, loadState }; DebugCallbacks dbgCallbacks = { getDebugInfo, NULL, NULL, NULL }; RomMapperRsIde* rm; rm = malloc(sizeof(RomMapperRsIde)); rm->deviceHandle = deviceManagerRegister(ROM_SVI328RSIDE, &callbacks, rm); rm->debugHandle = debugDeviceRegister(DBGTYPE_PORT, langDbgDevIdeSviRs(), &dbgCallbacks, rm); rm->i8255 = i8255Create( NULL, NULL, writeA, NULL, readB, writeB, NULL, readCLo, writeCLo, NULL, readCHi, writeCHi, rm); ioPortRegister(0x14, i8255Read, i8255Write, rm->i8255); // PPI Port A ioPortRegister(0x15, i8255Read, i8255Write, rm->i8255); // PPI Port B ioPortRegister(0x16, i8255Read, i8255Write, rm->i8255); // PPI Port C ioPortRegister(0x17, i8255Read, i8255Write, rm->i8255); // PPI Mode rm->hdide = harddiskIdeCreate(diskGetHdDriveId(hdId, 0)); reset(rm); return 1; }
int romMapperSvi328Col80Create(int frameRate, UInt8* romData, int size) { DeviceCallbacks callbacks = {destroy, reset, saveState, loadState}; DebugCallbacks dbgCallbacks = {getDebugInfo, NULL, NULL, NULL}; RomMapperSvi328Col80* svi328col80; if (size != 0x1000) return 0; svi328col80 = malloc(sizeof(RomMapperSvi328Col80)); svi328col80Instance = svi328col80; svi328col80->deviceHandle = deviceManagerRegister(ROM_SVI328COL80, &callbacks, svi328col80); svi328col80->crtc6845 = NULL; svi328col80->crtc6845 = crtc6845Create(frameRate, romData, size, 0x800, 7, 0, 82, 4); svi328col80->debugHandle = debugDeviceRegister(DBGTYPE_VIDEO, langDbgDevSvi80Col(), &dbgCallbacks, svi328col80); ioPortRegister(0x50, NULL, writeIo, svi328col80); ioPortRegister(0x51, readIo, writeIo, svi328col80); ioPortRegister(0x58, readIo, writeIo, svi328col80); reset(svi328col80); return 1; }
int romMapperSonyHBI55Create() { DeviceCallbacks callbacks = { destroy, reset, saveState, loadState }; DebugCallbacks dbgCallbacks = { getDebugInfo, NULL, NULL, NULL }; SonyHBI55* rm = malloc(sizeof(SonyHBI55)); rm->deviceHandle = deviceManagerRegister(ROM_SONYHBI55, &callbacks, rm); rm->debugHandle = debugDeviceRegister(DBGTYPE_CART, langDbgDevHbi55(), &dbgCallbacks, rm); memset(rm->sram, 0xff, sizeof(rm->sram)); sramLoad(sramCreateFilename("HBI-55.SRAM"), rm->sram, 0x1000, NULL, 0); rm->sram[0] = 0x53; rm->i8255 = i8255Create(NULL, NULL, writeA, NULL, NULL, writeB, readCLo, readCLo, writeCLo, readCHi, readCHi, writeCHi, rm); ioPortRegister(0xb0, i8255Read, i8255Write, rm->i8255); ioPortRegister(0xb1, i8255Read, i8255Write, rm->i8255); ioPortRegister(0xb2, i8255Read, i8255Write, rm->i8255); ioPortRegister(0xb3, i8255Read, i8255Write, rm->i8255); reset(rm); return 1; }
int ramMapperIoCreate() { RamMapperIo* rm; DeviceCallbacks callbacks = { (DeviceCallback)destroy, NULL, (DeviceCallback)saveState, (DeviceCallback)loadState }; DebugCallbacks dbgCallbacks = { (void(*)(void*,DbgDevice*))getDebugInfo, NULL, NULL, NULL }; rm = malloc(sizeof(RamMapperIo)); rm->count = 0; rm->mask = 0; rm->handleCount = 0; rm->port[0] = 3; rm->port[1] = 2; rm->port[2] = 1; rm->port[3] = 0; rm->deviceHandle = deviceManagerRegister(RAM_MAPPER, &callbacks, rm); rm->debugHandle = debugDeviceRegister(DBGTYPE_BIOS, langDbgDevRamMapper(), &dbgCallbacks, rm); ioPortRegister(0xfc, (IoPortRead)read, (IoPortWrite)write, rm); ioPortRegister(0xfd, (IoPortRead)read, (IoPortWrite)write, rm); ioPortRegister(0xfe, (IoPortRead)read, (IoPortWrite)write, rm); ioPortRegister(0xff, (IoPortRead)read, (IoPortWrite)write, rm); mapperIo = rm; return 1; }
int romMapperOpcodeMegaRamCreate(int slot, int sslot, int startPage) { DeviceCallbacks callbacks = { (DeviceCallback)destroy, (DeviceCallback)reset, (DeviceCallback)saveState, (DeviceCallback)loadState }; DebugCallbacks dbgCallbacks = { (void(*)(void*,DbgDevice*))getDebugInfo, NULL, NULL, NULL }; RomMapperOpcodeMegaRam* rm = malloc(sizeof(RomMapperOpcodeMegaRam)); rm->slot = slot; rm->sslot = sslot; rm->startPage = startPage; memset(rm->megaRam, 0xff, sizeof(rm->megaRam)); rm->deviceHandle = deviceManagerRegister(ROM_OPCODEMEGA, &callbacks, rm); rm->debugHandle = debugDeviceRegister(DBGTYPE_RAM, "MEGARAM", &dbgCallbacks, rm); ioPortRegister(0x48, (SlotRead)read, (SlotWrite)write, rm); ioPortRegister(0x49, (SlotRead)read, (SlotWrite)write, rm); ioPortRegister(0x4a, (SlotRead)read, (SlotWrite)write, rm); ioPortRegister(0x4b, (SlotRead)read, (SlotWrite)write, rm); reset(rm); return 1; }
static void write(RomMapperMsxAudio* rm, UInt16 address, UInt8 value) { address &= 0x7fff; #if 0 // FS-CA1 port select, bit 0:c0/c1, bit 1:c2/c3 if (rm->is_fs_ca1&&address==0x7fff&&rm->y8950) { if (value&1) { ioPortRegister(0xc0, y8950Read, y8950Write, rm->y8950); ioPortRegister(0xc1, y8950Read, y8950Write, rm->y8950); } else if (ioPortGetRef(0xc0)==rm->y8950&&ioPortGetRef(0xc1)==rm->y8950) { ioPortUnregister(0xc0); ioPortUnregister(0xc1); } if (value&2) { ioPortRegister(0xc2, y8950Read, y8950Write, rm->y8950); ioPortRegister(0xc3, y8950Read, y8950Write, rm->y8950); } else if (ioPortGetRef(0xc2)==rm->y8950&&ioPortGetRef(0xc3)==rm->y8950) { ioPortUnregister(0xc2); ioPortUnregister(0xc3); } } #endif // bankswitch if (address==0x7ffe) rm->bankSelect = value & 3; address &= 0x3fff; if (rm->bankSelect == 0 && address >= 0x3000) { rm->ram[address - 0x3000] = value; } }
static void sg1000IoPortCreate() { DeviceCallbacks callbacks = { sg1000IoPortDestroy, NULL, NULL, NULL }; int i; for (i=0x40; i<0x80; i++) ioPortRegister(i, NULL, sg1000Sn76489Write, NULL); for (i=0xC0; i<0x100; i+=2) ioPortRegister(i, joyIoRead, NULL, NULL); ioPortRegister(0xc1, joyIoRead, NULL, NULL); ioPortRegister(0xdd, joyIoRead, NULL, NULL); }
/***************************************** ** MSX MIDI Create Method ****************************************** */ int MSXMidiCreate() { DeviceCallbacks callbacks = {destroy, reset, saveState, loadState}; DebugCallbacks dbgCallbacks = { getDebugInfo, NULL, NULL, NULL }; MSXMidi* msxMidi; msxMidi = malloc(sizeof(MSXMidi)); msxMidi->deviceHandle = deviceManagerRegister(ROM_MSXMIDI, &callbacks, msxMidi); msxMidi->debugHandle = debugDeviceRegister(DBGTYPE_AUDIO, langDbgDevMsxMidi(), &dbgCallbacks, msxMidi); msxMidi->i8254 = i8254Create(4000000, pitOut0, pitOut1, pitOut2, msxMidi); msxMidi->i8251 = i8251Create(transmit, signal8251, setDataBits, setStopBits, setParity, setRxReady, setDtr, setRts, getDtr, getRts, msxMidi); ioPortRegister(0xe8, readIo, writeIo, msxMidi); ioPortRegister(0xe9, readIo, writeIo, msxMidi); ioPortRegister(0xea, readIo, writeIo, msxMidi); ioPortRegister(0xeb, readIo, writeIo, msxMidi); ioPortRegister(0xec, readIo, writeIo, msxMidi); ioPortRegister(0xed, readIo, writeIo, msxMidi); ioPortRegister(0xee, readIo, writeIo, msxMidi); ioPortRegister(0xef, readIo, writeIo, msxMidi); msxMidi->midiIo = midiIoCreate(midiInCallback, msxMidi); reset(msxMidi); return 1; }
int romMapperKonamiKeyboardMasterCreate(const char* filename, UInt8* romData, int size, int slot, int sslot, int startPage, void* voiceRom, int voiceSize) { DeviceCallbacks callbacks = { destroy, NULL, saveState, loadState }; DebugCallbacks dbgCallbacks = { getDebugInfo, NULL, NULL, NULL }; RomMapperKonamiKeyboardMaster* rm; int i; if (size != 0x4000) { return 0; } rm = malloc(sizeof(RomMapperKonamiKeyboardMaster)); rm->deviceHandle = deviceManagerRegister(ROM_KONAMKBDMAS, &callbacks, rm); rm->debugHandle = debugDeviceRegister(DBGTYPE_CART, langDbgDevKonamiKbd(), &dbgCallbacks, rm); slotRegister(slot, sslot, startPage, 4, NULL, NULL, NULL, destroy, rm); rm->romData = malloc(size); memcpy(rm->romData, romData, size); rm->voiceData = calloc(1, 0x4000); if (voiceRom != NULL) { if (voiceSize > 0x4000) { voiceSize = 0x4000; } memcpy(rm->voiceData, voiceRom, voiceSize); } else { memcpy(rm->voiceData, voiceData, 0x4000); } rm->vlm5030 = vlm5030Create(boardGetMixer(), rm->voiceData, 0x4000); rm->slot = slot; rm->sslot = sslot; rm->startPage = startPage; for (i = 0; i < 2; i++) { slotMapPage(rm->slot, rm->sslot, rm->startPage + i, rm->romData + i * 0x2000, 1, 0); } ioPortRegister(0x00, read, write, rm); ioPortRegister(0x20, read, write, rm); return 1; }
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; }
static void adamMemMapCreate(void) { int i; for (i = 0x60; i <= 0x7f; i++) { ioPortRegister(i, adamMemMapRead, adamMemMapWrite, NULL); } }
static void adamNetCreate(void) { int i; for (i = 0x20; i <= 0x3f; i++) { ioPortRegister(i, adamNetRead, adamNetWrite, NULL); } }
int romMapperSvi727Create(char* filename, UInt8* charRom, int charSize, int slot, int sslot, int startPage) { DeviceCallbacks callbacks = { (DeviceCallback)destroy, (DeviceCallback)reset, (DeviceCallback)saveState, (DeviceCallback)loadState }; RomMapperSvi727* rm; int pages = 8; int i; startPage = 0; rm = malloc(sizeof(RomMapperSvi727)); rm->deviceHandle = deviceManagerRegister(ROM_SVI727, &callbacks, rm); slotRegister(slot, sslot, startPage, pages, (SlotRead)read, (SlotRead)read, (SlotWrite)write, (SlotEject)destroy, rm); rm->charData = calloc(1, 0x2000); if (charRom != NULL) { charSize += 0x200; if (charSize > 0x2000) { charSize = 0x2000; } memcpy(rm->charData + 0x200, charRom, charSize - 0x200); } rm->crtc6845 = NULL; rm->crtc6845 = crtc6845Create(50, rm->charData, charSize, 0x0800, 7, 0, 80, 4); rm->slot = slot; rm->sslot = sslot; rm->startPage = startPage; for (i = 0; i < pages; i++) { slotMapPage(slot, sslot, i + startPage, NULL, 0, 0); } ioPortRegister(0x78, NULL, (IoPortWrite)writeIo, rm); ioPortRegister(0x79, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); reset(rm); return 1; }
RTC* rtcCreate(int enable, char* cmosName) { DebugCallbacks dbgCallbacks = { getDebugInfo, NULL, NULL, NULL }; RTC* rtc = (RTC*)calloc(1, sizeof(RTC)); rtc->modeReg = MODE_TIMERENABLE; if (cmosName != NULL) { struct tm* tm; time_t t; FILE* file; strcpy(rtc->cmosName, cmosName); file = archFileOpen(cmosName, "r"); if (file != NULL) { fread(rtc->registers, 1, sizeof(rtc->registers), file); fclose(file); } t = time(NULL); tm = localtime(&t); rtc->fraction = 0; rtc->seconds = tm->tm_sec; rtc->minutes = tm->tm_min; rtc->hours = tm->tm_hour; rtc->dayWeek = tm->tm_wday; rtc->days = tm->tm_mday - 1; rtc->months = tm->tm_mon; rtc->years = tm->tm_year - 80; rtc->leapYear = tm->tm_year % 4; } if (enable) { rtc->debugHandle = debugDeviceRegister(DBGTYPE_BIOS, langDbgDevRtc(), &dbgCallbacks, rtc); ioPortRegister(0xb4, NULL, rtcWriteLatch, rtc); ioPortRegister(0xb5, rtcReadData, rtcWriteData, rtc); } rtcUpdateRegs(rtc); return rtc; }
int romMapperS1990Create() { DeviceCallbacks callbacks = { destroy, reset, saveState, loadState }; DebugCallbacks dbgCallbacks = { getDebugInfo, NULL, NULL, NULL }; RomMapperS1990* rm; rm = malloc(sizeof(RomMapperS1990)); rm->deviceHandle = deviceManagerRegister(ROM_S1990, &callbacks, rm); rm->debugHandle = debugDeviceRegister(DBGTYPE_BIOS, langDbgDevS1990(), &dbgCallbacks, rm); ioPortRegister(0xe4, read, write, rm); ioPortRegister(0xe5, read, write, rm); reset(rm); return 1; }
int romMapperTurboRPcmCreate() { DeviceCallbacks callbacks = { destroy, reset, saveState, loadState }; DebugCallbacks dbgCallbacks = { getDebugInfo, NULL, NULL, NULL }; RomMapperTurboRPcm* rm = malloc(sizeof(RomMapperTurboRPcm)); rm->deviceHandle = deviceManagerRegister(ROM_TURBORPCM, &callbacks, rm); rm->debugHandle = debugDeviceRegister(DBGTYPE_AUDIO, langDbgDevPcm(), &dbgCallbacks, rm); rm->mixer = boardGetMixer(); rm->dac = dacCreate(rm->mixer, DAC_MONO); rm->status = 0; rm->time = 0; ioPortRegister(0xa4, read, write, rm); ioPortRegister(0xa5, read, write, rm); return 1; }
int romMapperMicrosolCreate(char* filename, UInt8* romData, int size, int slot, int sslot, int startPage) { DeviceCallbacks callbacks = { destroy, reset, saveState, loadState }; DebugCallbacks dbgCallbacks = { getDebugInfo, NULL, NULL, NULL }; Microsol* rm; int pages = size / 0x2000; int i; rm = malloc(sizeof(Microsol)); rm->deviceHandle = deviceManagerRegister(ROM_MICROSOL, &callbacks, rm); rm->debugHandle = debugDeviceRegister(DBGTYPE_BIOS, langDbgDevFdcMicrosol(), &dbgCallbacks, rm); slotRegister(slot, sslot, startPage, 4, NULL, NULL, NULL, destroy, rm); size = (size + 0x3fff) & ~0x3fff; rm->romData = malloc(size); memcpy(rm->romData, romData, size); rm->slot = slot; rm->sslot = sslot; rm->startPage = startPage; for (i = 0; i < pages; i++) { slotMapPage(slot, sslot, i + startPage, rm->romData + 0x2000 * i, 1, 0); } ioPortRegister(0xd0, readIo, writeIo, rm); ioPortRegister(0xd1, readIo, writeIo, rm); ioPortRegister(0xd2, readIo, writeIo, rm); ioPortRegister(0xd3, readIo, writeIo, rm); ioPortRegister(0xd4, readIo, writeIo, rm); rm->fdc = wd2793Create(FDC_TYPE_WD2793); reset(rm); return 1; }
int romMapperMoonsoundCreate(char* filename, UInt8* romData, int size, int sramSize) { DeviceCallbacks callbacks = { destroy, reset, saveState, loadState }; DebugCallbacks dbgCallbacks = { getDebugInfo, NULL, NULL, NULL }; RomMapperMoonsound* rm = malloc(sizeof(RomMapperMoonsound)); rm->deviceHandle = deviceManagerRegister(ROM_MOONSOUND, &callbacks, rm); rm->debugHandle = debugDeviceRegister(DBGTYPE_AUDIO, langDbgDevMoonsound(), &dbgCallbacks, rm); rm->moonsound = NULL; if (boardGetMoonsoundEnable()) { rm->moonsound = moonsoundCreate(boardGetMixer(), romData, size, sramSize); ioPortRegister(0x7e, read, write, rm); ioPortRegister(0x7f, read, write, rm); ioPortRegister(0xc4, read, write, rm); ioPortRegister(0xc5, read, write, rm); ioPortRegister(0xc6, read, write, rm); ioPortRegister(0xc7, read, write, rm); } else { // moonsound emulation has ownership of rom data. Need to // free it if its not being used. free(romData); } reset(rm); return 1; }
int svi328FdcCreate(void) { DeviceCallbacks callbacks = { (DeviceCallback)destroy, (DeviceCallback)reset, (DeviceCallback)saveState, (DeviceCallback)loadState }; DebugCallbacks dbgCallbacks = { (void(*)(void*,DbgDevice*))getDebugInfo, NULL, NULL, NULL }; Svi328Fdc* rm; rm = malloc(sizeof(Svi328Fdc)); rm->deviceHandle = deviceManagerRegister(ROM_SVI328FDC, &callbacks, rm); rm->debugHandle = debugDeviceRegister(DBGTYPE_PORT, langDbgDevSviFdc(), &dbgCallbacks, rm); ioPortRegister(0x30, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); ioPortRegister(0x31, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); ioPortRegister(0x32, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); ioPortRegister(0x33, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); ioPortRegister(0x34, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); ioPortRegister(0x38, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); rm->fdc = wd2793Create(FDC_TYPE_WD2793); reset(rm); return 1; }
int romMapperF4deviceCreate(int inverted) { DeviceCallbacks callbacks = { destroy, reset, saveState, loadState }; DebugCallbacks dbgCallbacks = { getDebugInfo, NULL, NULL, NULL }; RomMapperF4device* rm = malloc(sizeof(RomMapperF4device)); rm->inverted = inverted; rm->deviceHandle = deviceManagerRegister(inverted ? ROM_F4INVERTED : ROM_F4DEVICE, &callbacks, rm); rm->debugHandle = debugDeviceRegister(DBGTYPE_BIOS, langDbgDevF4Device(), &dbgCallbacks, rm); ioPortRegister(0xf4, read, write, rm); reset(rm); return 1; }
int romMapperOpcodeSlotManagerCreate() { DeviceCallbacks callbacks = { destroy, reset, saveState, loadState }; DebugCallbacks dbgCallbacks = { getDebugInfo, NULL, NULL, NULL }; RomMapperOpcodeSlotManager* rm = malloc(sizeof(RomMapperOpcodeSlotManager)); rm->deviceHandle = deviceManagerRegister(ROM_OPCODESLOT, &callbacks, rm); rm->debugHandle = debugDeviceRegister(DBGTYPE_BIOS, "SLOTSELECT", &dbgCallbacks, rm); ioPortRegister(0x41, read, write, rm); reset(rm); return 1; }
/***************************************** ** MSX RS-232 Create Method ****************************************** */ int romMapperMsxRs232Create(char* filename, UInt8* romData, int size, int slot, int sslot, int startPage) { DeviceCallbacks callbacks = {destroy, reset, saveState, loadState}; DebugCallbacks dbgCallbacks = { getDebugInfo, NULL, NULL, NULL }; int pages = 4; int i; if ((startPage + pages) > 8) { return 0; } msxRs232 = malloc(sizeof(MSXRs232)); msxRs232->deviceHandle = deviceManagerRegister(ROM_MSXRS232, &callbacks, msxRs232); msxRs232->debugHandle = debugDeviceRegister(DBGTYPE_BIOS, langDbgDevRs232(), &dbgCallbacks, msxRs232); slotRegister(slot, sslot, startPage, pages, read, peek, write, destroy, msxRs232); msxRs232->romData = malloc(size); memcpy(msxRs232->romData, romData, size); msxRs232->slot = slot; msxRs232->sslot = sslot; msxRs232->startPage = startPage; for (i = 0; i < pages; i++) { slotMapPage(slot, sslot, i + startPage, NULL, 0, 0); } msxRs232->i8251 = i8251Create(rs232transmit, rs232signal, setDataBits, setStopBits, setParity, setRxReady, setDtr, setRts, getDtr, getRts, msxRs232); msxRs232->i8254 = i8254Create(1843200, pitOut0, pitOut1, pitOut2, msxRs232); msxRs232->serialLink = archUartCreate(romMapperMsxRs232ReceiveCallback); ioPortRegister(0x80, readIo, writeIo, msxRs232); ioPortRegister(0x81, readIo, writeIo, msxRs232); ioPortRegister(0x82, readIo, writeIo, msxRs232); ioPortRegister(0x84, readIo, writeIo, msxRs232); ioPortRegister(0x85, readIo, writeIo, msxRs232); ioPortRegister(0x86, readIo, writeIo, msxRs232); ioPortRegister(0x87, NULL, writeIo, msxRs232); reset(msxRs232); return 1; }
int romMapperMegaRAMCreate(int size, int slot, int sslot, int startPage) { DeviceCallbacks callbacks = { (DeviceCallback)destroy, NULL, (DeviceCallback)saveState, (DeviceCallback)loadState }; DebugCallbacks dbgCallbacks = { (void(*)(void*,DbgDevice*))getDebugInfo, NULL, NULL, NULL }; RomMapperMegaRAM* rm; int i; if (startPage != 0) { return 0; } rm = malloc(sizeof(RomMapperMegaRAM)); rm->deviceHandle = deviceManagerRegister(ROM_MEGARAM, &callbacks, rm); rm->debugHandle = debugDeviceRegister(DBGTYPE_CART, langDbgDevMegaRam(), &dbgCallbacks, rm); slotRegister(slot, sslot, startPage, 8, NULL, NULL, (SlotWrite)write, (SlotEject)destroy, rm); rm->ramData = malloc(size); memset(rm->ramData, 0xff, size); rm->size = size; rm->slot = slot; rm->sslot = sslot; rm->writeEnabled = 0; rm->startPage = startPage; rm->romMapper[0] = 0; rm->romMapper[1] = 0; rm->romMapper[2] = 0; rm->romMapper[3] = 0; for (i = 0; i < 4; i++) { slotMapPage(rm->slot, rm->sslot, rm->startPage + i, rm->ramData + rm->romMapper[i] * 0x2000, 1, 0); slotMapPage(rm->slot, rm->sslot, rm->startPage + i + 4, rm->ramData + rm->romMapper[i] * 0x2000, 1, 0); } ioPortRegister(0x8e, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); return 1; }
int romMapperGoudaSCSICreate(int hdId, char* filename, UInt8* romData, int size, int slot, int sslot, int startPage) { DeviceCallbacks callbacks = { (void*)destroy, (void*)reset, (void*)saveState, (void*)loadState }; DebugCallbacks dbgCallbacks = { (void*)getDebugInfo, NULL, NULL, NULL }; RomMapperGoudaSCSI* rm; int i; UInt8* pBuf; UInt8 id15964[16] = { 0x4b, 0x4d, 0x63, 0x73, 0x02, 0x01, 0x59, 0xb0, 0x34, 0x64, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00 }; UInt8 bugcode[5] = { 0xc1, 0x16, 0x02, 0xc1, 0xc9 }; if (romData == NULL) { size = 0x4000; } else { if (size != 0x4000) { return 0; } } rm = malloc(sizeof(RomMapperGoudaSCSI)); rm->deviceHandle = deviceManagerRegister(ROM_GOUDASCSI, &callbacks, rm); slotRegister(slot, sslot, startPage, 2, NULL, NULL, NULL, (SlotEject)destroy, rm); rm->debugHandle = debugDeviceRegister(DBGTYPE_PORT, langDbgDevScsiGouda(), &dbgCallbacks, rm); rm->romData = malloc(0x4000); if (romData != NULL) { memcpy(rm->romData, romData, 0x4000); pBuf = rm->romData; if (memcmp(pBuf + 0x3ff0, id15964, 16) == 0) { // Bug patch for NOVAXIS SCSI bios 1.59.64 // fixed stack pointer if (memcmp(pBuf + 0x91c, bugcode, 5) == 0) { pBuf[0x091f] = 0; } } // Bug patch for NOVAXIS (a setting menu comes to function) i = 0x3ffd; do { if (*pBuf == 0xcd && *(pBuf+1) == 0x65 && *(pBuf+2) == 0xf3) { *pBuf++ = 0xdb; // in a,(0a8h) *pBuf++ = 0xa8; *pBuf = 0x00; i -= 2; } i--; pBuf++; } while (i > 0); } else { memset(rm->romData, 0xff, 0x4000); } rm->slot = slot; rm->sslot = sslot; rm->startPage = startPage; rm->wd33c93 = wd33c93Create(hdId); slotMapPage(slot, sslot, startPage , rm->romData , 1, 0); slotMapPage(slot, sslot, startPage + 1, rm->romData + 0x2000, 1, 0); ioPortRegister(PORT_BASE + 0, (IoPortRead)wd33c93ReadAuxStatus, (IoPortWrite)wd33c93WriteAdr, rm->wd33c93); ioPortRegister(PORT_BASE + 1, (IoPortRead)wd33c93ReadCtrl, (IoPortWrite)wd33c93WriteCtrl, rm->wd33c93); ioPortRegister(PORT_BASE + 2, (IoPortRead)dummy, (IoPortWrite)sbicReset, rm); return 1; }
int romMapperSvi328Rs232Create(Svi328UartConnector connector) { DeviceCallbacks callbacks = {destroy, NULL, saveState, loadState}; DebugCallbacks dbgCallbacks = {getDebugInfo, NULL, NULL, NULL}; rs232 = malloc(sizeof(RomMapperSvi328Rs232)); rs232->connector = connector; rs232->deviceHandle = deviceManagerRegister(ROM_SVI328RS232, &callbacks, rs232); rs232->debugHandle = debugDeviceRegister(DBGTYPE_BIOS, langDbgDevRs232(), &dbgCallbacks, rs232); rs232->i8250 = NULL; rs232->i8250 = i8250Create(3072000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, rs232); rs232->serialLink = archUartCreate(romMapperSvi328Rs232ReceiveCallback); switch (rs232->connector) { case SVI328_MODEM: rs232->baseAddress = 0x20; ioPortRegister(0x20, readIo, writeIo, rs232); ioPortRegister(0x21, readIo, writeIo, rs232); ioPortRegister(0x22, readIo, NULL, rs232); ioPortRegister(0x23, readIo, writeIo, rs232); ioPortRegister(0x24, readIo, writeIo, rs232); ioPortRegister(0x25, readIo, NULL, rs232); ioPortRegister(0x26, readIo, NULL, rs232); ioPortRegister(0x27, readIo, writeIo, rs232); break; case SVI328_RS232: rs232->baseAddress = 0x28; ioPortRegister(0x28, readIo, writeIo, rs232); ioPortRegister(0x29, readIo, writeIo, rs232); ioPortRegister(0x2A, readIo, NULL, rs232); ioPortRegister(0x2B, readIo, writeIo, rs232); ioPortRegister(0x2C, readIo, writeIo, rs232); ioPortRegister(0x2D, readIo, NULL, rs232); ioPortRegister(0x2E, readIo, NULL, rs232); ioPortRegister(0x2F, readIo, writeIo, rs232); break; default: return 0; } return 1; }
int romMapperGIdeCreate(int hdId) { DeviceCallbacks callbacks = { (DeviceCallback)destroy, (DeviceCallback)reset, (DeviceCallback)saveState, (DeviceCallback)loadState }; DebugCallbacks dbgCallbacks = { (void(*)(void*,DbgDevice*))getDebugInfo, NULL, NULL, NULL }; RomMapperGIde* rm; int portBase; rm = malloc(sizeof(RomMapperGIde)); rm->deviceHandle = deviceManagerRegister(ROM_GIDE, &callbacks, rm); rm->debugHandle = debugDeviceRegister(DBGTYPE_PORT, langDbgDevIdeGide(), &dbgCallbacks, rm); portBase = (boardGetType() == BOARD_SVI) ? 0x40:0x60; ioPortRegister(portBase | 0x04, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); ioPortRegister(portBase | 0x05, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); ioPortRegister(portBase | 0x06, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); ioPortRegister(portBase | 0x07, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); ioPortRegister(portBase | 0x08, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); ioPortRegister(portBase | 0x09, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); ioPortRegister(portBase | 0x0a, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); ioPortRegister(portBase | 0x0b, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); ioPortRegister(portBase | 0x0c, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); ioPortRegister(portBase | 0x0d, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); ioPortRegister(portBase | 0x0e, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); ioPortRegister(portBase | 0x0f, (IoPortRead)readIo, (IoPortWrite)writeIo, rm); rm->hdide = harddiskIdeCreate(diskGetHdDriveId(hdId, 0)); reset(rm); return 1; }
int romMapperFMPAKCreate(const char* filename, UInt8* romData, int size, int slot, int sslot, int startPage) { DeviceCallbacks callbacks = { destroy, reset, saveState, loadState }; DebugCallbacks dbgCallbacks = { getDebugInfo, NULL, NULL, NULL }; RomMapperFMPAK* rm; int romMapper[8]; int i; if (size > 0x10000) { return 0; } rm = malloc(sizeof(RomMapperFMPAK)); rm->romData = malloc(0x10000); memset(rm->romData, 0xff, 0x10000); memcpy(rm->romData, romData, size); // Align ROM size up to next valid rom size if (size <= 0x2000) size = 0x2000; else if (size <= 0x4000) size = 0x4000; else if (size <= 0x8000) size = 0x8000; else if (size <= 0xc000) size = 0xc000; else if (size <= 0x10000) size = 0x10000; rm->size = size; rm->slot = slot; rm->sslot = sslot; rm->startPage = startPage; switch (size) { case 0x2000: for (i = 0; i < 8; i++) { romMapper[i] = 0; } break; case 0x4000: for (i = 0; i < 8; i++) { romMapper[i] = i & 1; } break; case 0x8000: if (getRomStart(romData, size) == 0x4000) { for (i = 0; i < 4; i++) { romMapper[i] = i & 1; romMapper[i + 4] = 2 + (i & 1); } } else { for (i = 0; i < 8; i++) { romMapper[i] = i & 3; } } break; case 0xc000: if (getRomStart(romData, size) == 0x4000) { romMapper[0] = 0; romMapper[1] = 1; for (i = 0; i < 6; i++) { romMapper[i + 2] = i; } } else { for (i = 0; i < 6; i++) { romMapper[i] = i; } romMapper[6] = 0; romMapper[7] = 1; } break; case 0x10000: for (i = 0; i < 8; i++) { romMapper[i] = i; } break; default: free(rm); return 0; } rm->ym2413 = NULL; if (boardGetYm2413Enable()) { rm->ym2413 = ym2413Create(boardGetMixer()); rm->debugHandle = debugDeviceRegister(DBGTYPE_AUDIO, langDbgDevFmpak(), &dbgCallbacks, rm); ioPortRegister(0x7c, NULL, writeIo, rm); ioPortRegister(0x7d, NULL, writeIo, rm); } rm->deviceHandle = deviceManagerRegister(ROM_FMPAK, &callbacks, rm); slotRegister(slot, sslot, startPage, 8, NULL, NULL, NULL, destroy, rm); for (i = 0; i < 8; i++) { slotMapPage(slot, sslot, startPage + i, rm->romData + 0x2000 * romMapper[i], 1, 0); } return 1; }
int romMapperMsxAudioCreate(const char* filename, UInt8* romData, int size, int slot, int sslot, int startPage) { DeviceCallbacks callbacks = { destroy, reset, saveState, loadState }; DebugCallbacks dbgCallbacks = { getDebugInfo, NULL, NULL, NULL }; RomMapperMsxAudio* rm; int i; rm = malloc(sizeof(RomMapperMsxAudio)); rm->deviceHandle = deviceManagerRegister(ROM_MSXAUDIO, &callbacks, rm); rm->debugHandle = debugDeviceRegister(DBGTYPE_AUDIO, langDbgDevMsxAudio(), &dbgCallbacks, rm); rm->ioBase = 0xc0 + deviceCount++ * 2; rm->romData = NULL; if (size > 0) { int pages=8; rm->is_fs_ca1 = (size == 0x20000); // meh // pages=rm->is_fs_ca1?4:8; // For FS-CA1, $8000-$FFFF is unmapped // firmware locks up, needs more testing slotRegister(slot, sslot, startPage, pages, read, read, write, destroy, rm); rm->romData = malloc(size); memcpy(rm->romData, romData, size); memset(rm->ram, 0, 0x1000); rm->bankSelect = 0; rm->sizeMask = size - 1; rm->slot = slot; rm->sslot = sslot; rm->startPage = startPage; rm->midi = NULL; if (!switchGetAudio()) { // FS-CA1 BIOS hack, ret z -> nop // not needed if port select register is emulated rm->romData[0x408e] = 0; } for (i = 0; i < pages; i++) { slotMapPage(rm->slot, rm->sslot, rm->startPage + i, NULL, 0, 0); } } rm->y8950 = NULL; if (boardGetY8950Enable()) { rm->y8950 = y8950Create(boardGetMixer()); ioPortRegister(rm->ioBase + 0, y8950Read, y8950Write, rm->y8950); ioPortRegister(rm->ioBase + 1, y8950Read, y8950Write, rm->y8950); ioPortRegister(0x00, NULL, midiWrite, rm); ioPortRegister(0x01, NULL, midiWrite, rm); ioPortRegister(0x04, midiRead, NULL, rm); ioPortRegister(0x05, midiRead, NULL, rm); } if (deviceCount == 1) { rm->midi = philipsMidiCreate(); } reset(rm); return 1; }