Exemple #1
0
VOID MountFloppy(IN ULONG DiskNumber)
{
// FIXME: This should be present in PSDK commdlg.h
//
// FlagsEx Values
#if (_WIN32_WINNT >= 0x0500)
#define  OFN_EX_NOPLACESBAR         0x00000001
#endif // (_WIN32_WINNT >= 0x0500)

    BOOLEAN Success;
    OPENFILENAMEW ofn;
    WCHAR szFile[MAX_PATH] = L"";

    ASSERT(DiskNumber < ARRAYSIZE(GlobalSettings.FloppyDisks));

    RtlZeroMemory(&ofn, sizeof(ofn));
    ofn.lStructSize  = sizeof(ofn);
    ofn.hwndOwner    = hConsoleWnd;
    ofn.lpstrTitle   = L"Select a virtual floppy image";
    ofn.Flags        = OFN_EXPLORER | OFN_ENABLESIZING | OFN_LONGNAMES | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
//  ofn.FlagsEx      = OFN_EX_NOPLACESBAR;
    ofn.lpstrFilter  = L"Virtual floppy images (*.vfd;*.img;*.ima;*.dsk)\0*.vfd;*.img;*.ima;*.dsk\0All files (*.*)\0*.*\0\0";
    ofn.lpstrDefExt  = L"vfd";
    ofn.nFilterIndex = 0;
    ofn.lpstrFile    = szFile;
    ofn.nMaxFile     = ARRAYSIZE(szFile);

    if (!GetOpenFileNameW(&ofn))
    {
        DPRINT1("CommDlgExtendedError = %d\n", CommDlgExtendedError());
        return;
    }

    /* Free the old string */
    if (GlobalSettings.FloppyDisks[DiskNumber].Buffer)
        RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber]);

    /* Reinitialize the string */
    Success = RtlCreateUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber], szFile);
    ASSERT(Success);

    /* Mount the disk */
    if (!MountDisk(FLOPPY_DISK, DiskNumber, GlobalSettings.FloppyDisks[DiskNumber].Buffer, !!(ofn.Flags & OFN_READONLY)))
    {
        DisplayMessage(L"An error happened when mounting disk %d", DiskNumber);
        RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber]);
        RtlInitEmptyUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber], NULL, 0);
        return;
    }

    /* Refresh the menu state */
    UpdateVdmMenuDisks();
}
Exemple #2
0
VOID EjectFloppy(IN ULONG DiskNumber)
{
    ASSERT(DiskNumber < ARRAYSIZE(GlobalSettings.FloppyDisks));

    /* Unmount the disk */
    if (!UnmountDisk(FLOPPY_DISK, DiskNumber))
        DisplayMessage(L"An error happened when ejecting disk %d", DiskNumber);

    /* Free the old string */
    if (GlobalSettings.FloppyDisks[DiskNumber].Buffer)
    {
        RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber]);
        RtlInitEmptyUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber], NULL, 0);
    }

    /* Refresh the menu state */
    UpdateVdmMenuDisks();
}
Exemple #3
0
static VOID
UpdateVdmMenu(VOID)
{
    UpdateVdmMenuMouse();
    UpdateVdmMenuDisks();
}
Exemple #4
0
BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput)
{
    USHORT i;

    /* Initialize memory */
    if (!MemInitialize())
    {
        wprintf(L"Memory initialization failed.\n");
        return FALSE;
    }

    /* Initialize I/O ports */
    /* Initialize RAM */

    /* Initialize the CPU */

    /* Initialize the internal clock */
    if (!ClockInitialize())
    {
        wprintf(L"FATAL: Failed to initialize the clock\n");
        EmulatorCleanup();
        return FALSE;
    }

    /* Initialize the CPU */
    CpuInitialize();

    /* Initialize DMA */
    DmaInitialize();

    /* Initialize PIC, PIT, CMOS, PC Speaker and PS/2 */
    PicInitialize();

    PitInitialize();
    PitSetOutFunction(0, NULL, PitChan0Out);
    PitSetOutFunction(1, NULL, PitChan1Out);
    PitSetOutFunction(2, NULL, PitChan2Out);

    CmosInitialize();
    SpeakerInitialize();
    PpiInitialize();

    PS2Initialize();

    /* Initialize the keyboard and mouse and connect them to their PS/2 ports */
    KeyboardInit(0);
    MouseInit(1);

    /**************** ATTACH INPUT WITH CONSOLE *****************/
    /* Create the task event */
    VdmTaskEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
    ASSERT(VdmTaskEvent != NULL);

    /* Start the input thread */
    InputThread = CreateThread(NULL, 0, &ConsoleEventThread, ConsoleInput, 0, NULL);
    if (InputThread == NULL)
    {
        wprintf(L"FATAL: Failed to create the console input thread.\n");
        EmulatorCleanup();
        return FALSE;
    }
    ResumeEventThread();
    /************************************************************/

    /* Initialize the VGA */
    if (!VgaInitialize(ConsoleOutput))
    {
        wprintf(L"FATAL: Failed to initialize VGA support.\n");
        EmulatorCleanup();
        return FALSE;
    }

    /* Initialize the disk controller */
    if (!DiskCtrlInitialize())
    {
        wprintf(L"FATAL: Failed to completely initialize the disk controller.\n");
        EmulatorCleanup();
        return FALSE;
    }

    /* Mount the available floppy disks */
    for (i = 0; i < ARRAYSIZE(GlobalSettings.FloppyDisks); ++i)
    {
        if (GlobalSettings.FloppyDisks[i].Length != 0 &&
            GlobalSettings.FloppyDisks[i].Buffer      &&
            GlobalSettings.FloppyDisks[i].Buffer != '\0')
        {
            if (!MountDisk(FLOPPY_DISK, i, GlobalSettings.FloppyDisks[i].Buffer, FALSE))
            {
                DPRINT1("Failed to mount floppy disk file '%wZ'.\n", &GlobalSettings.FloppyDisks[i]);
                RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[i]);
                RtlInitEmptyUnicodeString(&GlobalSettings.FloppyDisks[i], NULL, 0);
            }
        }
    }

    /*
     * Mount the available hard disks. Contrary to floppies, failing
     * mounting a hard disk is considered as an unrecoverable error.
     */
    for (i = 0; i < ARRAYSIZE(GlobalSettings.HardDisks); ++i)
    {
        if (GlobalSettings.HardDisks[i].Length != 0 &&
            GlobalSettings.HardDisks[i].Buffer      &&
            GlobalSettings.HardDisks[i].Buffer != L'\0')
        {
            if (!MountDisk(HARD_DISK, i, GlobalSettings.HardDisks[i].Buffer, FALSE))
            {
                wprintf(L"FATAL: Failed to mount hard disk file '%wZ'.\n", &GlobalSettings.HardDisks[i]);
                EmulatorCleanup();
                return FALSE;
            }
        }
    }

    /* Refresh the menu state */
    UpdateVdmMenuDisks();

    /* Initialize the software callback system and register the emulator BOPs */
    InitializeInt32();
    RegisterBop(BOP_DEBUGGER  , EmulatorDebugBreakBop);
    // RegisterBop(BOP_UNSIMULATE, CpuUnsimulateBop);

    /* Initialize VDD support */
    VDDSupInitialize();

    return TRUE;
}