Beispiel #1
0
void UpdateKeyPort()
{
    byte *keyPortPtr = keyPort;
    word temp;

    for( int i = 0; i < 4; i++ )
    {
        temp = 0xFFFF;

        if( *keyPortPtr++ ) temp &= ~0x0001;
        if( *keyPortPtr++ ) temp &= ~0x0002;
        if( *keyPortPtr++ ) temp &= ~0x0004;
        if( *keyPortPtr++ ) temp &= ~0x0008;
        if( *keyPortPtr++ ) temp &= ~0x0010;

        if( *keyPortPtr++ ) temp &= ~0x0100;
        if( *keyPortPtr++ ) temp &= ~0x0200;
        if( *keyPortPtr++ ) temp &= ~0x0400;
        if( *keyPortPtr++ ) temp &= ~0x0800;
        if( *keyPortPtr++ ) temp &= ~0x1000;

        SystemBus_Write( 0xc00010 + i, temp );
    }

    temp = 0x0000;

    if( *keyPortPtr++ ) temp |= 0x0001;
    if( *keyPortPtr++ ) temp |= 0x0002;
    if( *keyPortPtr++ ) temp |= 0x0004;
    if( *keyPortPtr++ ) temp |= 0x0008;
    if( *keyPortPtr++ ) temp |= 0x0010;

    SystemBus_Write( 0xc00014, temp );
}
void Tape_Send(word pulseLength, bool pulse = true)
{
	pulseLength &= 0x7fff;
	if (pulse)
		pulseLength |= 0x8000;
	SystemBus_Write(0xc00015, pulseLength);
}
Beispiel #3
0
void DecodeKey( word keyCode, word keyFlags )
{
    static bool resetState = false;

    bool flagKeyRelease = ( keyFlags & fKeyRelease ) != 0;

    bool reset1 = ( keyFlags & ( fKeyCtrlLeft | fKeyCtrlRight ) ) == ( fKeyCtrlLeft | fKeyCtrlRight );

    static bool reset2 = false;
    if( keyCode == KEY_POWER && !flagKeyRelease ) reset2 = true;
    if( keyCode == KEY_POWER && flagKeyRelease ) reset2 = false;

    static bool reset3 = false;
    if( keyCode == KEY_PRNTSCR && !flagKeyRelease ) reset3 = true;
    if( keyCode == KEY_PRNTSCR && flagKeyRelease ) reset3 = false;

    if( ( reset1 || reset2 || reset3 ) != resetState )
    {
        resetState = reset1 || reset2 || reset3;
        CPU_Reset( resetState );
        DelayMs( 100 );
    }

    //------------------------------------------------------

    if( !flagKeyRelease )
    {
        if( ( keyFlags & fKeyCtrl ) != 0 )
        {
            switch( keyCode )
            {
                case KEY_1 :
                    specConfig.specVideoMode = 0;
                    Spectrum_UpdateConfig();
                    SaveConfig();
                    break;
                case KEY_2 :
                    specConfig.specVideoMode = 1;
                    Spectrum_UpdateConfig();
                    SaveConfig();
                    break;
                case KEY_3 :
                    specConfig.specVideoMode = 2;
                    Spectrum_UpdateConfig();
                    SaveConfig();
                    break;
                case KEY_4 :
                    specConfig.specVideoMode = 3;
                    Spectrum_UpdateConfig();
                    SaveConfig();
                    break;
                case KEY_5 :
                    specConfig.specVideoMode = 4;
                    Spectrum_UpdateConfig();
                    SaveConfig();
                    break;
                case KEY_F12 :
                    CPU_NMI();
                    break;
            }
        }
        else if ( fKeyAlt & keyFlags )
        {
            int kc;

            switch ( keyCode )
            {
                case KEY_0:
                    kc = 0;
                    break;
                case KEY_1:
                    kc = 1;
                    break;
                case KEY_2:
                    kc = 2;
                    break;
                case KEY_3:
                    kc = 3;
                    break;
                case KEY_4:
                    kc = 4;
                    break;
                case KEY_5:
                    kc = 5;
                    break;
                case KEY_6:
                    kc = 6;
                    break;
                case KEY_7:
                    kc = 7;
                    break;
                case KEY_8:
                    kc = 8;
                    break;
                case KEY_9:
                    kc = 9;
                    break;
                default:
                    kc = -1;
                    break;
            }
            if ( kc >= 0 )
            {
                char snaName[ 0x10 ];
                sniprintf( snaName, sizeof(snaName), "!slot_%.1d.sna", kc );
                SaveSnapshot( snaName );
            }
        }

        else
        {
            switch( keyCode )
            {
                case KEY_ESC :
                    Debugger_Enter();
                    break;

                case KEY_PAUSE :
                    Shell_Pause();
                    break;

                case KEY_F1 :
                    specConfig.specTurbo = 0;
                    Spectrum_UpdateConfig();
                    //SaveConfig();
                    break;
                case KEY_F2 :
                    specConfig.specTurbo = 1;
                    Spectrum_UpdateConfig();
                    //SaveConfig();
                    break;
                case KEY_F3 :
                    specConfig.specTurbo = 2;
                    Spectrum_UpdateConfig();
                    //SaveConfig();
                    break;
                case KEY_F4 :
                    specConfig.specTurbo = 3;
                    Spectrum_UpdateConfig();
                    //SaveConfig();
                    break;

                case KEY_F5 :
                    SystemBus_Write( 0xc00000, 0x00004 );
                    break;
                case KEY_F6 :
                    {
                        CPU_Stop();

                        byte specPort7ffd = SystemBus_Read( 0xc00017 );

                        byte page = ( specPort7ffd & ( 1 << 3 ) ) != 0 ? 7 : 5;
                        dword addr = 0x800000 | ( page << 13 );

                        SystemBus_Write( 0xc00020, 0 );  // use bank 0

                        for( int i = 0x1800; i < 0x1b00; i += 2 )
                        {
                            SystemBus_Write( addr + ( i >> 1 ), 0x3838 );
                        }

                        CPU_Start();
                    }
                    break;

                case KEY_F9 :
                    Shell_SettingsMenu();
                    break;

                case KEY_F10 :
                    Shell_DisksMenu();
                    break;

                case KEY_F11 :
                    if( ( keyFlags & fKeyShift ) != 0 ) Shell_SaveSnapshot();
                    else SaveSnapshot( UpdateSnaName() );
                    break;

                case KEY_F12 :
                    Shell_Browser();
                    break;

                case KEY_EQUALS :
                case KEY_KP_PLUS :
                    if( !Tape_Started() ) Tape_Restart();
                    break;

                case KEY_MINUS :
                case KEY_KP_MINUS :
                    if( !Tape_Started() ) Tape_Start();
                    else Tape_Stop();
                    break;

                case KEY_INSERT :
                    specConfig.specMouseSwap = !specConfig.specMouseSwap;
                    break;
            }
        }
    }
}