Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
int sg1000Create(Machine* machine, 
                 VdpSyncMode vdpSyncMode,
                 BoardInfo* boardInfo)
{
    int success;
    int i;

    sfRam = NULL;

    r800 = r800Create(0, slotRead, slotWrite, ioPortRead, ioPortWrite, NULL, boardTimerCheckTimeout, NULL, NULL, NULL, NULL);

    boardInfo->cartridgeCount   = 1;
    boardInfo->diskdriveCount   = 0;
    boardInfo->casetteCount     = 0;
    boardInfo->cpuRef           = r800;

    boardInfo->destroy          = destroy;
    boardInfo->softReset        = reset;
    boardInfo->loadState        = loadState;
    boardInfo->saveState        = saveState;
    boardInfo->getRefreshRate   = getRefreshRate;
    boardInfo->getRamPage       = getRamPage;

    boardInfo->run              = r800Execute;
    boardInfo->stop             = r800StopExecution;
    boardInfo->setInt           = r800SetInt;
    boardInfo->clearInt         = r800ClearInt;
    boardInfo->setCpuTimeout    = r800SetTimeoutAt;
    boardInfo->setBreakpoint    = r800SetBreakpoint;
    boardInfo->clearBreakpoint  = r800ClearBreakpoint;
    boardInfo->setDataBus       = r800SetDataBus;

    boardInfo->changeCartridge  = changeCartridge;

    deviceManagerCreate();
    
    boardInit(&r800->systemTime);
    ioPortReset();

    r800Reset(r800, 0);
    mixerReset(boardGetMixer());

    r800DebugCreate(r800);

    sn76489 = sn76489Create(boardGetMixer());

    slotManagerCreate();

    if (vdpSyncMode == VDP_SYNC_AUTO) {
        vdpSyncMode = VDP_SYNC_60HZ;
    }
    vdpCreate(VDP_SG1000, machine->video.vdpVersion, vdpSyncMode, machine->video.vramSize / 0x4000);

    joyIo = sg1000JoyIoCreate();
    if (machine->board.type == BOARD_SC3000) {
        sc3000PPICreate(joyIo);
    }
    if (machine->board.type == BOARD_SF7000) {
        sc3000PPICreate(joyIo);
        sf7000PPICreate();
            
        diskEnable(0, machine->fdc.count > 0);
        diskEnable(1, machine->fdc.count > 1);
    }
    sg1000IoPortCreate();

	ledSetCapslock(0);

    for (i = 0; i < 4; i++) {
        slotSetSubslotted(i, 0);
    }
    for (i = 0; i < 2; i++) {
        cartridgeSetSlotInfo(i, 2 + i, 0);
    }

    success = machineInitialize(machine, &sfRam, &sfRamSize, &sfRamStart);

    for (i = 0; i < 8; i++) {
        slotMapRamPage(0, 0, i);
    }

    if (machine->board.type == BOARD_SF7000) {
        slotSetRamSlot(0, 1);
    }

    if (success) {
        success = boardInsertExternalDevices();
    }

    r800SetFrequency(r800, CPU_Z80,  machine->cpu.freqZ80);
    r800SetFrequency(r800, CPU_R800, machine->cpu.freqR800);

    if (!success) {
        destroy();
    }

    return success;
}