Example #1
0
int romMapperKonamiSynthCreate(char* filename, UInt8* romData, 
                               int size, int slot, int sslot, int startPage) 
{
    DeviceCallbacks callbacks = { (DeviceCallback)destroy, NULL, NULL, NULL };
    RomMapperKonamiSynth* rm;
    int i;

    if (size != 0x8000) {
        return 0;
    }

    rm = malloc(sizeof(RomMapperKonamiSynth));

    rm->deviceHandle = deviceManagerRegister(ROM_KONAMISYNTH, &callbacks, rm);
    slotRegister(slot, sslot, startPage, 4, NULL, NULL, (SlotWrite)write, (SlotEject)destroy, rm);

    rm->romData = malloc(size);
    memcpy(rm->romData, romData, size);
    rm->dac   = dacCreate(boardGetMixer(), DAC_MONO);
    rm->slot  = slot;
    rm->sslot = sslot;
    rm->startPage  = startPage;

    for (i = 0; i < 4; i++) {   
        slotMapPage(rm->slot, rm->sslot, rm->startPage + i, rm->romData + i * 0x2000, 1, 0);
    }

    return 1;
}
int romMapperKonamiWordProCreate(char* filename, UInt8* romData, 
                          int size, int slot, int sslot, int startPage) 
{
    DeviceCallbacks callbacks = { destroy, reset, saveState, loadState };
    RomMapperKonamiWordPro* rm;
    int pages = 8;
    int i;

    if (size != 0x8000) {
        return 0;
    }

    rm = malloc(sizeof(RomMapperKonamiWordPro));

    if (pages == 8)
        startPage = 0;

    rm->deviceHandle = deviceManagerRegister(ROM_KONWORDPRO, &callbacks, rm);
    slotRegister(slot, sslot, startPage, pages, read, read, write, destroy, rm);

    rm->romData = calloc(1, size);
    memcpy(rm->romData, romData, size);
    rm->slot  = slot;
    rm->sslot = sslot;
    rm->startPage  = startPage;

    for (i = 0; i < pages; i++) {   
        slotMapPage(rm->slot, rm->sslot, rm->startPage + i, rm->romData + i * 0x2000, 0, 0);
    }

    reset(rm);
    return 1;
}
int romMapperGameReaderCreate(int cartSlot, int slot, int sslot) 
{
    DeviceCallbacks callbacks = { destroy, NULL, saveState, loadState };
    RomMapperGameReader* rm;
    int i;

    rm = malloc(sizeof(RomMapperGameReader));

    rm->deviceHandle = deviceManagerRegister(ROM_GAMEREADER, &callbacks, rm);

    rm->slot     = slot;
    rm->sslot    = sslot;
    rm->cartSlot = cartSlot;

//    f = fopen("c:\\grlog.txt", "w+");
    rm->gameReader = gameReaderCreate(cartSlot);

    for (i = 0; i < CACHE_LINES; i++) {
        rm->cacheLineEnabled[i] = 0;
    }

    if (rm->gameReader != NULL) {
        ioPortRegisterUnused(cartSlot, readIo, writeIo, rm);
        slotRegister(slot, sslot, 0, 8, read, read, write, destroy, rm);
        for (i = 0; i < 8; i++) {   
            slotMapPage(rm->slot, rm->sslot, i, NULL, 0, 0);
        }
    }

    return 1;
}
Example #4
0
int romMapperTC8566AFCreate(const char* filename, UInt8* romData, 
                           int size, int slot, int sslot, int startPage,
                           RomType romType) 
{
    DeviceCallbacks callbacks = { destroy, reset, saveState, loadState };
    RomMapperTC8566AF* rm;

    rm = malloc(sizeof(RomMapperTC8566AF));

    rm->deviceHandle = deviceManagerRegister(romType, &callbacks, rm);
    slotRegister(slot, sslot, startPage, 4, read, peek, write, destroy, rm);

    size = (size + 0x3fff) & ~0x3fff;

    rm->romData = malloc(size);
    memcpy(rm->romData, romData, size);
    rm->romMask = size / 0x4000 - 1;
    rm->slot  = slot;
    rm->sslot = sslot;
    rm->startPage  = startPage;
    rm->romType = romType;

    rm->fdc = tc8566afCreate();

    reset(rm);

    return 1;
}
int romMapperMsxDos2Create(const char* filename, UInt8* romData,
                           int size, int slot, int sslot, int startPage) 
{
    DeviceCallbacks callbacks = { destroy, NULL, saveState, loadState };
    RomMapperMsxDos2* rm;
    int i;

    if (size < 0x8000) {
        return 0;
    }

    rm = malloc(sizeof(RomMapperMsxDos2));

    rm->deviceHandle = deviceManagerRegister(ROM_MSXDOS2, &callbacks, rm);
    slotRegister(slot, sslot, startPage, 4, NULL, NULL, write, destroy, rm);

    rm->romData = malloc(size);
    memcpy(rm->romData, romData, size);
    rm->size = size;
    rm->slot  = slot;
    rm->sslot = sslot;
    rm->startPage  = startPage;

    rm->romMapper[0] = 0;
    rm->romMapper[2] = size / 0x2000 - 2;

    for (i = 0; i < 4; i += 2) {   
        slotMapPage(rm->slot, rm->sslot, rm->startPage + i,     rm->romData + rm->romMapper[i] * 0x2000, 1, 0);
        slotMapPage(rm->slot, rm->sslot, rm->startPage + i + 1, rm->romData + rm->romMapper[i] * 0x2000 + 0x2000, 1, 0);
    }

    return 1;
}
int romMapperMajutsushiCreate(const char* filename, UInt8* romData,
                           int size, int slot, int sslot, int startPage) 
{
    DeviceCallbacks callbacks = { destroy, NULL, saveState, loadState };
    RomMapperMajutsushi* rm;
    int i;

    if (size < 0x8000) {
        return 0;
    }

    rm = malloc(sizeof(RomMapperMajutsushi));

    rm->deviceHandle = deviceManagerRegister(ROM_MAJUTSUSHI, &callbacks, rm);
    slotRegister(slot, sslot, startPage, 4, NULL, NULL, write, destroy, rm);

    rm->romData = malloc(size);
    memcpy(rm->romData, romData, size);
    rm->dac = dacCreate(boardGetMixer(), DAC_MONO);
    rm->size = size;
    rm->slot  = slot;
    rm->sslot = sslot;
    rm->startPage  = startPage;

    rm->romMapper[0] = 0;
    rm->romMapper[1] = 1;
    rm->romMapper[2] = 2;
    rm->romMapper[3] = 3;

    for (i = 0; i < 4; i++) {   
        slotMapPage(rm->slot, rm->sslot, rm->startPage + i, rm->romData + rm->romMapper[i] * 0x2000, 1, 0);
    }

    return 1;
}
Example #7
0
int ramMirroredCreate(int size, int slot, int sslot, int startPage, 
                      UInt32 ramBlockSize, UInt8** ramPtr, UInt32* ramSize) 
{
    DeviceCallbacks callbacks = {
        (DeviceCallback)destroy,
        NULL,
        (DeviceCallback)saveState,
        (DeviceCallback)loadState
    };
    DebugCallbacks dbgCallbacks = {
        (void(*)(void*,DbgDevice*))getDebugInfo,
        (int(*)(void*,char*,void*,int,int))dbgWriteMemory,
        NULL,
        NULL
    };
    Ram1kBMirrored* rm;
    int pages = size / 0x2000;
    int i;

    if (size > 0x10000 || (size & 0x1fff)) {
        return 0;
    }

    // Start page must be zero (only full slot allowed)
    if (startPage + pages > 8) {
        return 0;
    }

    rm = malloc(sizeof(Ram1kBMirrored));

    rm->mask      = ramBlockSize - 1;
    rm->slot      = slot;
    rm->sslot     = sslot;
    rm->startPage = startPage;
    rm->pages     = pages;

    memset(rm->ramData, 0, sizeof(rm->ramData));

    rm->debugHandle = debugDeviceRegister(DBGTYPE_RAM, langDbgDevRam(), &dbgCallbacks, rm);

    for (i = 0; i < pages; i++) {
        slotMapPage(slot, sslot, i + startPage, NULL, 0, 0);
    } 

    rm->deviceHandle = deviceManagerRegister(ramBlockSize == 0x400 ? RAM_1KB_MIRRORED : RAM_2KB_MIRRORED, 
                                             &callbacks, rm);
    slotRegister(slot, sslot, startPage, pages, (SlotRead)read, (SlotRead)read, (SlotWrite)write, (SlotEject)destroy, rm);

    if (ramPtr != NULL) {
        *ramPtr = rm->ramData;
    }

    if (ramSize != NULL) {
        *ramSize = rm->pages * 0x2000;
    }

    return 1;
}
int romMapperSCCplusCreate(const char* filename, UInt8* romData,
                           int size, int slot, int sslot, int startPage, SccType sccType) 
{
    DeviceCallbacks callbacks = { destroy, reset, saveState, loadState };
    RomMapperSCCplus* rm;

    rm = malloc(sizeof(RomMapperSCCplus));

    rm->deviceHandle = deviceManagerRegister(ROM_SCCEXTENDED, &callbacks, rm);
    slotRegister(slot, sslot, startPage, 4, read, peek, write, destroy, rm);

    memset(rm->romData, 0xff, 0x22000);

    if (romData) {
        if (size > 0x20000) {
            size = 0x20000;
        }
        memcpy(rm->romData, romData, size);
    }

    rm->slot            = slot;
    rm->sslot           = sslot;
    rm->startPage       = startPage;
    rm->modeRegister    = sccType == SCCP_EXTENDED ? 0x20 : 0;
    rm->isRamSegment[0] = 0;
    rm->isRamSegment[1] = 0;
    rm->isRamSegment[2] = 0;
    rm->isRamSegment[3] = 0;
    rm->isMapped[0]     = sccType != SCC_SDSNATCHER;
    rm->isMapped[1]     = sccType != SCC_SDSNATCHER;
    rm->isMapped[2]     = sccType != SCC_SDSNATCHER;
    rm->isMapped[3]     = sccType != SCC_SDSNATCHER;
    rm->mapperMask      = sccType == SCC_MIRRORED ? 0x07 : 0x0f;
    rm->scc             = sccCreate(boardGetMixer());
    rm->sccType         = sccType;
    rm->sccMode         = SCC_NONE;

    rm->romMapper[0] = 0;
    rm->romMapper[1] = 1;
    rm->romMapper[2] = 2;
    rm->romMapper[3] = 3;

    if (sccType != SCC_SDSNATCHER) {
        slotMapPage(rm->slot, rm->sslot, rm->startPage,     rm->romData + 0x0000, 1, 0);
        slotMapPage(rm->slot, rm->sslot, rm->startPage + 1, rm->romData + 0x2000, 1, 0);
        slotMapPage(rm->slot, rm->sslot, rm->startPage + 2, rm->romData + 0x4000, 1, 0);
        slotMapPage(rm->slot, rm->sslot, rm->startPage + 3, rm->romData + 0x6000, 1, 0);
    }
    else {
        slotMapPage(rm->slot, rm->sslot, rm->startPage,     rm->romData + 0x20000, 1, 0);
        slotMapPage(rm->slot, rm->sslot, rm->startPage + 1, rm->romData + 0x20000, 1, 0);
        slotMapPage(rm->slot, rm->sslot, rm->startPage + 2, rm->romData + 0x20000, 1, 0);
        slotMapPage(rm->slot, rm->sslot, rm->startPage + 3, rm->romData + 0x20000, 1, 0);
    }

    return 1;
}
Example #9
0
int romMapperCasetteCreate(const char* filename, UInt8* romData, 
                        int size, int slot, int sslot, int startPage) 
{
    DeviceCallbacks callbacks = { destroy, NULL, NULL, NULL };
    RomMapperCasette* rm;
    int pages = size / 0x2000;
    int i;

    if (pages == 0 || (startPage + pages) > 8) {
        return 0;
    }

    rm = malloc(sizeof(RomMapperCasette));

    rm->deviceHandle = deviceManagerRegister(ROM_CASPATCH, &callbacks, rm);
    slotRegister(slot, sslot, startPage, pages, NULL, NULL, NULL, destroy, rm);

    rm->romData = malloc(size);
    memcpy(rm->romData, romData, size);
    
    rm->slot  = slot;
    rm->sslot = sslot;
    rm->startPage  = startPage;

    if (boardGetType() == BOARD_SVI) {
        // Patch the SVI-328 BIOS and BASIC for cassette handling
        for (i = 0; patchAddressSVI[i]; i++) {
            UInt8* ptr = rm->romData + patchAddressSVI[i];
            ptr[0] = 0xed;
            ptr[1] = 0xfe;
            ptr[2] = 0xc9;
        }
        rm->romData[0x2073]=0x01;   // Skip delay loop after save
        rm->romData[0x20D0]=0x10;   // Write $55 only $10 times, instead
        rm->romData[0x20D1]=0x00;   //   of $190
        rm->romData[0x20E3]=0x00;   // Cancel instruction
        rm->romData[0x20E4]=0x00;
        rm->romData[0x20E5]=0x00;
        rm->romData[0x20E6]=0xED;
        rm->romData[0x20E7]=0xFE;
    }
    else {
        // Patch the casette rom
        for (i = 0; patchAddress[i]; i++) {
            UInt8* ptr = rm->romData + patchAddress[i];
            ptr[0] = 0xed;
            ptr[1] = 0xfe;
            ptr[2] = 0xc9;
        }
    }

    for (i = 0; i < pages; i++) {
        slotMapPage(slot, sslot, i + startPage, rm->romData + 0x2000 * i, 1, 0);
    }

    return 1;
}
Example #10
0
int ramNormalCreate(int size, int slot, int sslot, int startPage, UInt8** ramPtr, UInt32* ramSize)
{
    DeviceCallbacks callbacks = {
        (DeviceCallback)destroy,
        NULL,
        (DeviceCallback)saveState,
        (DeviceCallback)loadState
    };
    DebugCallbacks dbgCallbacks = {
        (void(*)(void*,DbgDevice*))getDebugInfo,
        (int(*)(void*,char*,void*,int,int))dbgWriteMemory,
        NULL,
        NULL
    };
    RamNormal* rm;
    int pages = size / 0x2000;
    int i;

    if (size > 0x10000 || (size & 0x1fff)) {
        return 0;
    }

    // Start page must be zero (only full slot allowed)
    if (startPage + pages > 8) {
        return 0;
    }

    rm = malloc(sizeof(RamNormal));

    rm->slot      = slot;
    rm->sslot     = sslot;
    rm->startPage = startPage;
    rm->pages     = pages;

    memset(rm->ramData, 0xff, sizeof(rm->ramData));

    rm->debugHandle = debugDeviceRegister(DBGTYPE_RAM, langDbgDevRam(), &dbgCallbacks, rm);

    for (i = 0; i < pages; i++) {
        slotMapPage(slot, sslot, i + startPage, rm->ramData + 0x2000 * i, 1, 1);
    }

    rm->deviceHandle = deviceManagerRegister(RAM_NORMAL, &callbacks, rm);
    slotRegister(slot, sslot, startPage, pages, NULL, NULL, NULL, (SlotEject)destroy, rm);

    if (ramPtr != NULL) {
        *ramPtr = rm->ramData;
    }

    if (ramSize != NULL) {
        *ramSize = pages * 0x2000;
    }

    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;
}
GatewayTask::GatewayTask(ComponentStream *stream)
    : QObject(stream), d(new Private)
{
    d->stream = stream;
    QObject::connect( stream, SIGNAL(stanzaIQ(XMPP::IQ)),
                      SLOT(slotRegister(XMPP::IQ)) );
    QObject::connect( stream, SIGNAL(stanzaMessage(XMPP::Message)),
                      SLOT(slotMessage(XMPP::Message)) );
    QObject::connect( stream, SIGNAL(stanzaPresence(XMPP::Presence)),
                      SLOT(slotGatewaySubscribe(XMPP::Presence)) );
    QObject::connect( stream, SIGNAL(stanzaPresence(XMPP::Presence)),
                      SLOT(slotSubscription(XMPP::Presence)) );
    QObject::connect( stream, SIGNAL(stanzaPresence(XMPP::Presence)),
                      SLOT(slotPresence(XMPP::Presence)) );
}
Example #13
0
/*****************************************
** 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;
}
Example #14
0
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;
}
Example #15
0
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 romMapperGameReaderCreate(int cartSlot, int slot, int sslot) 
{
    DeviceCallbacks callbacks = { destroy, NULL, saveState, loadState };
    RomMapperGameReader* rm;
    int i;

    rm = malloc(sizeof(RomMapperGameReader));

    rm->deviceHandle = deviceManagerRegister(ROM_GAMEREADER, &callbacks, rm);

    rm->slot     = slot;
    rm->sslot    = sslot;
    rm->cartSlot = cartSlot;

    rm->gameReader = gameReaderCreate(cartSlot);

	// read initial buffer
	if (!gameReaderRead(rm->gameReader, 0x4000, rm->romData + 0x4000, 0x4000)) {
        memset(rm->romData, 0xff, 0x10000);
    }
	if (!gameReaderRead(rm->gameReader, 0x8000, rm->romData + 0x8000, 0x4000)) {
        memset(rm->romData, 0xff, 0x10000);
    }

    if (rm->gameReader != NULL) {
        ioPortRegisterUnused(cartSlot, readIo, writeIo, rm);
        slotRegister(slot, sslot, 0, 8, read, read, write, destroy, rm);
        for (i = 0; i < 8; i++) {   
            slotMapPage(rm->slot, rm->sslot, i, NULL, 0, 0);
        }
    }

	for(i = 0; i <= 0xffff; i++) {
		// mark scc as known port
		if (isWellKnownPort(i))	{
			rm->mapperStatus[i]= MAPPER_ADDRESS_PORT;
		} else {
			rm->mapperStatus[i]= MAPPER_ADDRESS_UNKNOWN;
		}
	}

	rm->mapperList = NULL;

    return 1;
}
Example #17
0
int romMapperSg1000CastleCreate(char* filename, UInt8* romData, 
                          int size, int slot, int sslot, int startPage) 
{
    DeviceCallbacks callbacks = { (DeviceCallback)destroy, NULL, NULL, NULL };
    RomMapperSg1000Castle* rm;
    int pages = size / 0x2000 + ((size & 0x1fff) ? 1 : 0);
    int i;

    if (size != 0x8000 || startPage != 0) {
        return 0;
    }

    rm = malloc(sizeof(RomMapperSg1000Castle));

    rm->deviceHandle = deviceManagerRegister(ROM_SG1000CASTLE, &callbacks, rm);
    slotRegister(slot, sslot, startPage, pages, NULL, NULL, NULL, (SlotEject)destroy, rm);

    rm->romData = malloc(pages * 0x2000);
    memcpy(rm->romData, romData, size);
    memset(rm->sram, 0, 0x2000);

    rm->slot  = slot;
    rm->sslot = sslot;
    rm->startPage  = startPage;
    
    strcpy(rm->sramFilename, sramCreateFilename(filename));
    sramLoad(rm->sramFilename, rm->sram, 0x2000, NULL, 0);

    for (i = 0; i < pages; i++) {
        if (i + startPage >= 2) slot = 0;
        slotMapPage(slot, sslot, i + startPage, rm->romData + 0x2000 * i, 1, 0);
    }
    // Always map SRAM in slot 0. This is an unfortunate workaround because
    // Sega roms are mapped in slot 2, but the page size is 16kB and the SRAM
    // is only 8kB which makes it impossible in current implementation to
    // map it in the same slot as the cart.
    // Note though that mapping carts to slot 2 is also sort of a workaround to
    // allow carts to be inserted/removed more easily in a running system. This
    // patch prevent removing the cart to be handled correctly though
    slotMapPage(0, 0, 4 + rm->startPage, rm->sram, 1, 1);
//    slotMapPage(rm->slot, rm->sslot, 4 + rm->startPage, rm->sram, 1, 1);

    return 1;
}
int romMapperNoWindCreate(int driveId, const char* filename, UInt8* romData, 
                         int size, int slot, int sslot, int startPage) 
{
    NoWindProperties* prop = &propGetGlobalProperties()->nowind;
    DeviceCallbacks callbacks = { destroy, reset, saveState, loadState };
    RomMapperNoWind* rm;
    int i;

    rm = (RomMapperNoWind*)malloc(sizeof(RomMapperNoWind));

    rm->deviceHandle = deviceManagerRegister(ROM_NOWIND, &callbacks, rm);
    slotRegister(slot, sslot, startPage, 6, (SlotRead)read, (SlotRead)peek, (SlotWrite)write, destroy, rm);

    if (filename == NULL) {
        filename = "nowind.rom";
    }
    rm->amdFlash = amdFlashCreate(AMD_TYPE_1, 0x80000, 0x10000, 0, romData, size, sramCreateFilenameWithSuffix(filename, "", ".rom"), 0);
    rm->slot  = slot;
    rm->sslot = sslot;
    rm->startPage  = startPage;

#ifdef USE_NOWIND_DLL
    if (++nowindLoaded == 1) {
        nowindLoadDll();
        if (nowindusb_startup)  nowindusb_startup();
    }
    if (nowindusb_attribute) {
        nowindusb_attribute(ATTR_ENABLE_DOS2, prop->enableDos2 != 0);
        nowindusb_attribute(ATTR_ENABLE_OTHER_DISKROMS, prop->enableOtherDiskRoms != 0);
        nowindusb_attribute(ATTR_ENABLE_PHANTOM_DRIVES, prop->enablePhantomDrives != 0);
    }
    if (nowindusb_set_debug_callback) {
        nowindusb_set_debug_callback(debugCb);
    }

    for (i = 0; i < 4; i++) {
        diskInsert(rm, driveId, i);
    }
#endif

    reset(rm);

    return 1;
}
int romMapperKonami5Create(const char* filename, UInt8* romData,
                           int size, int slot, int sslot, int startPage) 
{
    DeviceCallbacks callbacks = { destroy, reset, saveState, loadState };
    RomMapperKonami5* rm;
    int i;

    int origSize = size;
    
    size = 0x8000;
    while (size < origSize) {
        size *= 2;
    }


    rm = malloc(sizeof(RomMapperKonami5));

    rm->deviceHandle = deviceManagerRegister(ROM_KONAMI5, &callbacks, rm);
    slotRegister(slot, sslot, startPage, 4, read, peek, write, destroy, rm);

    rm->romData = calloc(1, size);
    memcpy(rm->romData, romData, origSize);
    rm->romMask = size / 0x2000 - 1;
    rm->slot  = slot;
    rm->sslot = sslot;
    rm->startPage  = startPage;
    rm->scc = sccCreate(boardGetMixer());
    sccSetMode(rm->scc, SCC_REAL);
    rm->sccEnable = 0;

    rm->romMapper[0] = 0;
    rm->romMapper[1] = 1;
    rm->romMapper[2] = 2;
    rm->romMapper[3] = 3;

    for (i = 0; i < 4; i++) {   
        slotMapPage(rm->slot, rm->sslot, rm->startPage + i, rm->romData + rm->romMapper[i] * 0x2000, 1, 0);
    }

    return 1;
}
Example #20
0
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;
}
Example #21
0
int romMapperKorean80Create(char* filename, UInt8* romData, 
                            int size, int slot, int sslot, int startPage) 
{
    DeviceCallbacks callbacks = {
        (DeviceCallback)destroy,
        NULL,
        (DeviceCallback)saveState,
        (DeviceCallback)loadState
    };
    RomMapperKorean80* rm;
    int i;

    if (size < 0x8000) {
        return 0;
    }

    rm = malloc(sizeof(RomMapperKorean80));

    rm->deviceHandle = deviceManagerRegister(ROM_KOREAN80, &callbacks, rm);
    slotRegister(slot, sslot, startPage, 4, NULL, NULL, (SlotWrite)write, (SlotEject)destroy, rm);

    rm->romData = malloc(size);
    memcpy(rm->romData, romData, size);
    rm->size = size;
    rm->slot  = slot;
    rm->sslot = sslot;
    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->romData + rm->romMapper[i] * 0x2000, 1, 0);
    }

    return 1;
}
Example #22
0
int romMapperCvMegaCartCreate(char* filename, UInt8* romData, 
                           int size, int slot, int sslot, int startPage) 
{
    DeviceCallbacks callbacks = {
        (DeviceCallback)destroy,
        NULL,
        (DeviceCallback)saveState,
        (DeviceCallback)loadState
    };
    RomMapperCvMegaCart* rm;
    UInt8* bankData;

    if (size & 0x3fff) {
        return 0;
    }

    rm = malloc(sizeof(RomMapperCvMegaCart));

    rm->deviceHandle = deviceManagerRegister(ROM_CVMEGACART, &callbacks, rm);
    slotRegister(slot, sslot, startPage, 4, (SlotRead)read, (SlotRead)peek, NULL, (SlotEject)destroy, rm);

    rm->romData = calloc(1, size);
    memcpy(rm->romData, romData, size);
    rm->romMask = size / 0x4000 - 1;
    rm->slot  = slot;
    rm->sslot = sslot;
    rm->startPage  = startPage;
    rm->romMapper = 0;

    bankData = rm->romData + (rm->romMask << 14);
    slotMapPage(rm->slot, rm->sslot, rm->startPage + 0, bankData, 1, 0);
    slotMapPage(rm->slot, rm->sslot, rm->startPage + 1, bankData + 0x2000, 1, 0);

    bankData = rm->romData + (rm->romMapper << 14);
    slotMapPage(rm->slot, rm->sslot, rm->startPage + 2, bankData, 1, 0);
    slotMapPage(rm->slot, rm->sslot, rm->startPage + 3, bankData + 0x2000, 0, 0);
 
    return 1;
}
Example #23
0
int romMapperNetCreate(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 };
    RomMapperNet* rm;
    int i;
    int pages = size / 0x2000;

    if (size != 0x4000 && size != 0x8000) {
        return 0;
    }

    rm = malloc(sizeof(RomMapperNet));

    rm->deviceHandle = deviceManagerRegister(ROM_YAMAHANET, &callbacks, rm);
    rm->debugHandle = debugDeviceRegister(DBGTYPE_BIOS, "Yamaha Net", &dbgCallbacks, rm);

    slotRegister(slot, sslot, startPage, pages, read, read, write, destroy, rm);

    rm->romData = malloc(size);
    memcpy(rm->romData, romData, size);
    rm->slot  = slot;
    rm->sslot = sslot;
    rm->startPage  = startPage;
    rm->sizeMask = size - 1;

    for (i = 0; i < pages; i++) {
        slotMapPage(rm->slot, rm->sslot, rm->startPage + i, NULL, 0, 0);
    }

    rm->ym2151 = ym2151Create(boardGetMixer());
    rm->ym2148 = ym2148Create();
    rm->ykIo = ykIoCreate();

    reset(rm);

    return 1;
}
int romMapperDiskCreate(const char* filename, UInt8* romData,
                        int size, int slot, int sslot, int startPage) 
{
    DeviceCallbacks callbacks = { destroy, NULL, NULL, NULL };
    RomMapperDisk* rm;
    int pages = size / 0x2000;
    int i;

    if (pages == 0 || (startPage + pages) > 8) {
        return 0;
    }

    rm = malloc(sizeof(RomMapperDisk));

    rm->deviceHandle = deviceManagerRegister(ROM_DISKPATCH, &callbacks, rm);
    slotRegister(slot, sslot, startPage, pages, NULL, NULL, NULL, destroy, rm);

    rm->romData = malloc(size);
    memcpy(rm->romData, romData, size);
    
    rm->slot  = slot;
    rm->sslot = sslot;
    rm->startPage  = startPage;

    // Patch the disk rom
    for (i = 0; patchAddress[i]; i++) {
        UInt8* ptr = rm->romData + patchAddress[i] - 0x4000;
        ptr[0] = 0xed;
        ptr[1] = 0xfe;
        ptr[2] = 0xc9;
    }

    for (i = 0; i < pages; i++) {
        slotMapPage(slot, sslot, i + startPage, rm->romData + 0x2000 * i, 1, 0);
    }

    return 1;
}
Example #25
0
int romMapperBunsetuCreate(char* filename, UInt8* romData, 
                          int size, int slot, int sslot, int startPage,
                          void* jisyoRom, int jisyoSize) 
{
    DeviceCallbacks callbacks = { destroy, NULL, saveState, loadState };
    RomMapperBunsetu* rm;

    if (size != 0x8000) {
        return 0;
    }

    rm = malloc(sizeof(RomMapperBunsetu));

    rm->deviceHandle = deviceManagerRegister(ROM_BUNSETU, &callbacks, rm);
    slotRegister(slot, sslot, startPage, 4, read, peek, write, destroy, rm);

    rm->romData = malloc(size);
    memcpy(rm->romData, romData, size);
    if (jisyoRom) {
        rm->jisyoData = malloc(jisyoSize);
        memcpy(rm->jisyoData, jisyoRom, jisyoSize);
    }
    else {
        rm->jisyoData = NULL;
    }

    rm->address   = 0;
    rm->slot      = slot;
    rm->sslot     = sslot;
    rm->startPage = startPage;

    slotMapPage(rm->slot, rm->sslot, rm->startPage + 0, rm->romData + 0x0000, 1, 0);
    slotMapPage(rm->slot, rm->sslot, rm->startPage + 1, rm->romData + 0x2000, 1, 0);
    slotMapPage(rm->slot, rm->sslot, rm->startPage + 2, rm->romData + 0x4000, 1, 0);
    slotMapPage(rm->slot, rm->sslot, rm->startPage + 3, rm->romData + 0x6000, 0, 0);

    return 1;
}
Example #26
0
int romMapperCrossBlaimCreate(char* filename, UInt8* romData, 
                              int size, int slot, int sslot, int startPage) 
{
    DeviceCallbacks callbacks = {
        (DeviceCallback)destroy,
        NULL,
        (DeviceCallback)saveState,
        (DeviceCallback)loadState
    };
    RomMapperCrossBlaim* rm;

    if (size < 0x8000) {
        return 0;
    }

    rm = malloc(sizeof(RomMapperCrossBlaim));

    rm->deviceHandle = deviceManagerRegister(ROM_CROSSBLAIM, &callbacks, rm);
    slotRegister(slot, sslot, startPage, 8, NULL, NULL, (SlotWrite)write, (SlotEject)destroy, rm); // $0000-$FFFF

    rm->romData = malloc(size);
    memcpy(rm->romData, romData, size);
    rm->size = size;
    rm->slot  = slot;
    rm->sslot = sslot;
    rm->startPage  = startPage;

    // page 1 fixed to ROM 0 bank 0
    slotMapPage(rm->slot, rm->sslot, 2, rm->romData+0x0000, 1, 0);
    slotMapPage(rm->slot, rm->sslot, 3, rm->romData+0x2000, 1, 0);
    
    rm->romMapper[0] = 0;
    rm->romMapper[2] = -1;
    write(rm,0,0);

    return 1;
}
Example #27
0
int romMapperASCII16Create(char* filename, UInt8* romData, 
                           int size, int slot, int sslot, int startPage) 
{
    DeviceCallbacks callbacks = { destroy, NULL, saveState, loadState };
    RomMapperASCII16* rm;
    int i;
    int origSize = size;
    
    size = 0x8000;
    while (size < origSize) {
        size *= 2;
    }

    rm = malloc(sizeof(RomMapperASCII16));

    rm->deviceHandle = deviceManagerRegister(ROM_ASCII16, &callbacks, rm);
    slotRegister(slot, sslot, startPage, 4, NULL, NULL, write, destroy, rm);

    size = (size + 0x3fff) & ~0x3fff;

    rm->romData = calloc(1, size);
    memcpy(rm->romData, romData, origSize);
    rm->romMask = size / 0x4000 - 1;
    rm->slot  = slot;
    rm->sslot = sslot;
    rm->startPage  = startPage;

    rm->romMapper[0] = 0;
    rm->romMapper[2] = 0;

    for (i = 0; i < 4; i += 2) {   
        slotMapPage(rm->slot, rm->sslot, rm->startPage + i,     rm->romData + rm->romMapper[i] * 0x2000, 1, 0);
        slotMapPage(rm->slot, rm->sslot, rm->startPage + i + 1, rm->romData + rm->romMapper[i] * 0x2000 + 0x2000, 1, 0);
    }

    return 1;
}
int romMapperA1FMModemCreate(const char* filename, UInt8* romData,
                             int size, int slot, int sslot, int startPage) 
{
    DeviceCallbacks callbacks = { destroy, reset, saveState, loadState };
    RomMapperA1FMModem* rm;

    rm = malloc(sizeof(RomMapperA1FMModem));

    rm->deviceHandle = deviceManagerRegister(ROM_FSA1FMMODEM, &callbacks, rm);
    slotRegister(slot, sslot, startPage, 2, read, read, write, destroy, rm);

    rm->romData = malloc(size);
    memcpy(rm->romData, romData, size);
    rm->romSize = size;
    rm->slot  = slot;
    rm->sslot = sslot;
    rm->startPage  = startPage;

    rm->romMapper = 0;

    reset(rm);

    return 1;
}
Example #29
0
int romMapperMatraINKCreate(char* filename, UInt8* romData, 
                             int size, int slot, int sslot, int startPage) 
{
    DeviceCallbacks callbacks = { destroy, NULL, saveState, loadState };
    RomMapperMatraINK* rm;
    int i;

    rm = calloc(1, sizeof(RomMapperMatraINK));

    rm->deviceHandle = deviceManagerRegister(ROM_MEGAFLSHSCC, &callbacks, rm);
    slotRegister(slot, sslot, startPage, 8, read, peek, write, destroy, rm);

    rm->slot  = slot;
    rm->sslot = sslot;
    rm->startPage  = startPage;

    rm->flash = amdFlashCreate(AMD_TYPE_2, 0x10000, 0x10000, 0xff, romData, size, NULL, 0);

    for (i = 0; i < 8; i++) {
        slotMapPage(slot, sslot, startPage + i, NULL, 0, 0);
    }

    return 1;
}
int romMapperPhilipsFdcCreate(char* filename, UInt8* romData, 
                              int size, int slot, int sslot, int startPage) 
{
    DeviceCallbacks callbacks = { destroy, reset, saveState, loadState };
    RomMapperPhilipsFdc* rm;
    int pages = 4;
    int i;

    if ((startPage + pages) > 8) {
        return 0;
    }

    rm = malloc(sizeof(RomMapperPhilipsFdc));

    rm->deviceHandle = deviceManagerRegister(ROM_PHILIPSFDC, &callbacks, rm);
    slotRegister(slot, sslot, startPage, pages, read, peek, write, destroy, rm);

    rm->romData = malloc(size);
    memcpy(rm->romData, romData, size);
    
    rm->slot  = slot;
    rm->sslot = sslot;
    rm->startPage  = startPage;
    rm->sideReg = 0;
    rm->driveReg = 0;

    for (i = 0; i < pages; i++) {
        slotMapPage(slot, sslot, i + startPage, NULL, 0, 0);
    }

    rm->fdc = wd2793Create(FDC_TYPE_WD2793);

    reset(rm);

    return 1;
}