Exemplo n.º 1
0
bool Tape::Insert (const char* pcsz_)
{
    Eject();

    CStream *pStream = CStream::Open(pcsz_, true);
    if (!pStream)
        return false;

    pTape = libspectrum_tape_alloc();
    if (!pTape)
    {
        delete pStream;
        return false;
    }

    strFileName = pStream->GetFile();
    size_t uSize = pStream->GetSize();
    pbTape = new libspectrum_byte[uSize];
    if (pbTape) pStream->Read(pbTape, uSize);
    delete pStream;

    if (!pbTape || libspectrum_tape_read(pTape, pbTape, uSize, LIBSPECTRUM_ID_UNKNOWN, pcsz_) != LIBSPECTRUM_ERROR_NONE)
    {
        Eject();
        return false;
    }

    // Store tape path on successful insert
    strFilePath = pcsz_;

    IO::AutoLoad(AUTOLOAD_TAPE);
    return true;
}
Exemplo n.º 2
0
int main()
{
	ElementType X;
	Deque D;
	int done = 0;

	D = CreateDeque();
	while (!done) {
		switch (GetOp()) {
		case push:
			scanf("%d", &X);
			if (!Push(X, D)) printf("Memory is Full!\n");
			break;
		case pop:
			X = Pop(D);
			if ( X == ERROR ) printf("Deque is Empty!\n");
			break;
		case inject:
			scanf("%d", &X);
			if (!Inject(X, D)) printf("Memory is Full!\n");
			break;
		case eject:
			X = Eject(D);
			if ( X == ERROR ) printf("Deque is Empty!\n");
			break;
		case end:
			PrintDeque(D);
			done = 1;
			break;
		}
	}
	system("pause");

	return 0;
}
Exemplo n.º 3
0
// Insert a new disk from the named source (usually a file)
bool CDrive::Insert (const char* pcszSource_, bool fAutoLoad_)
{
    Eject();

    // Open the new disk image
    m_pDisk = CDisk::Open(pcszSource_);
    if (!m_pDisk)
        return false;

    // Check for auto-booting with drive 1
    if (this == pFloppy1 && fAutoLoad_)
        IO::AutoLoad(AUTOLOAD_DISK);

    return true;
}
Exemplo n.º 4
0
/* Eject the CD-ROM */
static int SDL_SYS_CDEject(SDL_CD *cdrom)
{
	Boolean	disk = false;
	QHdr *driveQ = GetDrvQHdr();
	DrvQEl *driveElem;
	HParamBlockRec hpb;
	ParamBlockRec cpb;

	for ( driveElem = (DrvQEl *) driveQ->qHead; driveElem; driveElem = 
			  (driveElem) ? ((DrvQEl *) driveElem->qLink) : 
			  ((DrvQEl *) driveQ->qHead) ) {
		if ( driveQ->qTail ) {
			driveQ->qTail->qLink = 0;
		}
		if ( driveElem->dQRefNum != SDL_cdlist[cdrom->id].dRefNum ) {
			continue;
		}
	
		/* Does drive contain mounted volume? If not, skip */
		SDL_memset(&hpb, 0, sizeof(hpb));
		hpb.volumeParam.ioVRefNum = driveElem->dQDrive;
		if ( PBHGetVInfoSync(&hpb) != noErr ) {
			continue;
		}
		if ( (UnmountVol(0, driveElem->dQDrive) == noErr) && 
		     (Eject(0, driveElem->dQDrive) == noErr) ) {
			driveElem = 0; /* Clear pointer to reset our loop */
			disk = true;
		}
	}

	/* If no disk is present, just eject the tray */
	if (! disk) {
		SDL_memset(&cpb, 0, sizeof(cpb));
		cpb.cntrlParam.ioVRefNum = 0; /* No Drive */
		cpb.cntrlParam.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
		cpb.cntrlParam.csCode = kEjectTheDisc;
		if ( PBControlSync((ParmBlkPtr)&cpb) != noErr ) {
			SDL_SetError("PBControlSync() failed");
			return(-1);
		}
	}
	return(0);
}
Exemplo n.º 5
0
/*****************************************************************
 * Enable/Disable Ctrl+Alt+Del and Ctrl+Shift+Esc key sequences. *
 * TRUE=Enable, FALSE=Disable                                    *
 * (Win 2K).                                                     *
 *****************************************************************/
int DLL_EXP_IMP WINAPI CtrlAltDel_Enable_Disable(BOOL bEnableDisable)
{
	static BOOL bInjected = FALSE;

    if (!bEnableDisable)
    {
		if (!bInjected)
		{
			bInjected = Inject();
			return bInjected;
		}
    }
    else
    {
		if (bInjected)
		{
			bInjected = !Eject();
			return !bInjected;
		}
    }

    return 0;
}
Exemplo n.º 6
0
int main(int argc, char* argv[])
{
	RegisterHotKey(0, 100, MOD_ALT, 121);
	RegisterHotKey(0, 200, MOD_CONTROL, 121);

	MSG msg;

	while(GetMessage(&msg, 0, 0, 0))
	{
		if(msg.message == WM_HOTKEY)
		{
			if(msg.wParam == 200)
			{
				Inject();
			}
			else
			{
				Eject();
			}
		}
	}
	return 0;
}
Exemplo n.º 7
0
static UINT Fire(UINT what)
{
	switch (what) {
	case 0:
		return FALL_THROUGH;
	case FIRE_NOTHING:
		break;
	case FIRE_POWER:
		Power();
		break;
	case FIRE_EJECT:
		Eject();
		break;
	case FIRE_FLIP3D:
		Flip3D();
		break;
	case FIRE_BRIGHT_DN:
		Bright(-BRIGHT_STEP);
		break;
	case FIRE_BRIGHT_UP:
		Bright(+BRIGHT_STEP);
		break;
	case FIRE_ALPHA_DN:
		Alpha(-ALPHA_DELTA);
		break;
	case FIRE_ALPHA_UP:
		Alpha(+ALPHA_DELTA);
		break;
	default:
		if (FIRE_CMD_0 <= what && what < FIRE_CMD_0 + ARRAYSIZE(config_szCmds))
			Exec(config_szCmds[what - FIRE_CMD_0]);
		else
			SendKey(what);
	}
	return FIRED;
}
Exemplo n.º 8
0
//-----------------------------------------------------------------------------
// Purpose: Handle "cd" console command
//-----------------------------------------------------------------------------
void CCDAudio::CD_f ( void )
{
	char	*command;
	int		ret;
	int		n;

	if ( Cmd_Argc() < 2 )
		return;

	command = Cmd_Argv (1);

	if (stricmp(command, "on") == 0)
	{
		m_bEnabled = true;
		return;
	}

	if (stricmp(command, "off") == 0)
	{
		if (m_bIsPlaying)
			Stop();
		m_bEnabled = false;
		return;
	}

	if (stricmp(command, "reset") == 0)
	{
		m_bEnabled = true;
		if (m_bIsPlaying)
			Stop();
		for (n = 0; n < 100; n++)
			m_rgRemapCD[n] = n;
		GetAudioDiskInfo();
		return;
	}

	if (stricmp(command, "remap") == 0)
	{
		ret = Cmd_Argc() - 2;
		if ( ret > 0)
		{
			for (n = 1; n <= ret; n++)
			{
				m_rgRemapCD[n] = atoi(Cmd_Argv (n+1));
			}
		}
		return;
	}

	if (stricmp(command, "close") == 0)
	{
		CloseDoor();
		return;
	}

	if (!m_bIsValid)
	{
		GetAudioDiskInfo();
		if (!m_bIsValid)
		{
			return;
		}
	}

	if (stricmp(command, "play") == 0)
	{
		Play( atoi(Cmd_Argv (2)), false );
		return;
	}

	if (stricmp(command, "loop") == 0)
	{
		Play( atoi(Cmd_Argv (2)), true );
		return;
	}

	if (stricmp(command, "stop") == 0)
	{
		Stop();
		return;
	}

	if (stricmp(command, "pause") == 0)
	{
		Pause();
		return;
	}

	if (stricmp(command, "resume") == 0)
	{
		Resume();
		return;
	}

	if (stricmp(command, "eject") == 0)
	{
		if (m_bIsPlaying)
			Stop();
		Eject();
		m_bIsValid = false;
		return;
	}

	if (stricmp(command, "info") == 0)
	{
		Msg("%u tracks\n", m_nMaxTrack);
		if ( m_bIsPlaying )
		{
			Msg("Currently %s track %u\n", m_bIsLooping ? "looping" : "playing", m_nPlayTrack);
		}
		else if ( m_bWasPlaying )
		{
			Msg("Paused %s track %u\n", m_bIsLooping ? "looping" : "playing", m_nPlayTrack);
		}
		Msg("Volume is %f\n", m_flVolume);
		return;
	}
}