Exemplo n.º 1
0
void MainWindow::keyReleaseEvent(QKeyEvent *event)
{
	int erases = 0;
	if (event->key() == Qt::Key_P) {
		mode_switch();
		return;
	}
	switch (state) {
	case STATE_RUNNING:
		switch (event->key()) {
		case Qt::Key_Space:
			game->DropToBottom();
			finishJudge();
			drawNext(game->next);
			erases = game->EraseRows();
			for(int i = 0; i<erases; i++)
			{
				score += (i+1) * 100;
			}
			refreshScore();
			goto redraw;
		case Qt::Key_Left:
			game->MoveLeft();
			goto redraw;
		case Qt::Key_Right:
			game->MoveRight();
			goto redraw;
		case Qt::Key_Up:
			game->Rotate();
			goto redraw;
		case Qt::Key_Down:
			timer_timeout ();
			goto redraw;
		case Qt::Key_C:
			if (interval % 10 == 3)
				game->next = block(util::point(0, 0), block_shape::GetRandomBlockShape());
			drawNext(game->next);
			goto redraw;
		default:
			QMainWindow::keyReleaseEvent(event);
			return;
		}
		redraw:
		redraw ();
		return;
	case STATE_INIT:
		if (event->key() == Qt::Key_Space)
			mode_switch();
		else {
			QMainWindow::keyReleaseEvent(event);
			return;
		}
		return;
	case STATE_PAUSE:
		return;
	}
}
Exemplo n.º 2
0
/*
 * 3df RW   display bank, access bank, mode
 * bit 0-2  Identifies the page of main memory being displayed in units of 16K.
 *          0: 0K, 1: 16K...7: 112K. In 32K modes (bits 6-7 = 2) only 0,2,4 and
 *          6 are valid, as the next page will also be used.
 *     3-5  Identifies the page of main memory that can be read/written at B8000h
 *          in units of 16K. 0: 0K, 1: 16K...7: 112K. In 32K modes (bits 6-7 = 2)
 *          only 0,2,4 and 6 are valid, as the next page will also be used.
 *     6-7  Display mode. 0: Text, 1: 16K graphics mode (4,5,6,8)
 *          2: 32K graphics mode (9,Ah)
 */
void pcvideo_t1000_device::bank_w(int data)
{
	if (m_bank != data)
	{
		UINT8 *ram = machine().root_device().memregion("maincpu")->base();
		int dram, vram;
		m_bank = data;
	/* it seems the video ram is mapped to the last 128K of main memory */
#if 1
		if ((data&0xc0)==0xc0) /* needed for lemmings */
		{
			dram = 0x80000 + ((data & 0x06) << 14);
			vram = 0x80000 + ((data & 0x30) << (14-3));
		}
		else
		{
			dram = 0x80000 + ((data & 0x07) << 14);
			vram = 0x80000 + ((data & 0x38) << (14-3));
		}
#else
		dram = (data & 0x07) << 14;
		vram = (data & 0x38) << (14-3);
#endif
		m_t1_displayram = &ram[vram];
		m_displayram = &ram[dram];
		mode_switch();
	}
}
Exemplo n.º 3
0
int main() {
    // Initialize keyboard
    keyboard = new Keyboard(&pc);
    // Initialize the clocks to some reasonable time
    cA.reset();
    cA.start();
    int startup = rand() % 70 + 30;
    Thread::wait(startup);
    cV.reset();
    cV.start();
    // Assign interrupts
    as_interrupt.rise(&a_sense);
    vs_interrupt.rise(&v_sense);
    // Initialize the threads
    Thread leds(led_thread);
    led_addr = &leds;
    Thread display(display_thread);
    display_addr = &display;
    Thread alarm(alarm_thread);
    alarm_addr = &alarm;
    Thread keyboard(input_thread);
    Thread mode_switch(mode_switch_thread);
    Thread pace(pace_thread);
    pace_addr = &pace;
    
    while (true) { }
}
Exemplo n.º 4
0
void MainWindow::on_actionSettings_triggered()
{
	if (state == STATE_RUNNING) mode_switch();
	SettingsDialog* dialog = new SettingsDialog(this);
	dialog->dropPreview = dropPreview;
	dialog->interval = interval;
	dialog->init_settings();
	dialog->setModal(true);
	dialog->exec();
	dropPreview = dialog->dropPreview;
	interval = dialog->interval;
	qDebug() << "dropPreview:" << dropPreview;
	qDebug() << "interval:" << interval;
	refreshSettings(true);
}
Exemplo n.º 5
0
// External Interrupt 0 service routine
interrupt [EXT_INT0] void ext_int0_isr(void)
{
    delay_ms(150);
    
    if(CONTROL_PIN == 1)
    {       
        mode--;
        while(CONTROL_PIN == 1)
        {
            strobe_mode(STROBE_DELAY);
        }
    }
    else
    {
        mode_switch();
    }      
}
Exemplo n.º 6
0
void main(void)
{
// Declare your local variables here

// Crystal Oscillator division factor: 1
#pragma optsize-
CLKPR=(1<<CLKPCE);
CLKPR=(0<<CLKPCE) | (0<<CLKPS3) | (0<<CLKPS2) | (0<<CLKPS1) | (0<<CLKPS0);
#ifdef _OPTIMIZE_SIZE_
#pragma optsize+
#endif

DDRD.2 = 0;
PORTB.2 = 0;

DDRB.2 = 1;
DDRB.3 = 1;
DDRB.4 = 1;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: 500,000 kHz
// Mode: Fast PWM top=0xFF
// OC0A output: Non-Inverted PWM
// OC0B output: Disconnected
// Timer Period: 0,512 ms
// Output Pulse(s):
// OC0A Period: 0,512 ms Width: 0 us
TCCR0A=(1<<COM0A1) | (0<<COM0A0) | (0<<COM0B1) | (0<<COM0B0) | (1<<WGM01) | (1<<WGM00);
TCCR0B=(0<<WGM02) | (0<<CS02) | (0<<CS01) | (1<<CS00);
TCNT0=0x00;
OCR0A=0x00;
OCR0B=0x00;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 500,000 kHz
// Mode: Fast PWM top=0x00FF
// OC1A output: Non-Inverted PWM
// OC1B output: Non-Inverted PWM
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer Period: 0,512 ms
// Output Pulse(s):
// OC1A Period: 0,512 ms Width: 0 us
// OC1B Period: 0,512 ms Width: 0 us
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=(1<<COM1A1) | (0<<COM1A0) | (1<<COM1B1) | (0<<COM1B0) | (0<<WGM11) | (1<<WGM10);
TCCR1B=(0<<ICNC1) | (0<<ICES1) | (0<<WGM13) | (1<<WGM12) | (0<<CS12) | (0<<CS11) | (1<<CS10);
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

// External Interrupt(s) initialization
// INT0: On
// INT0 Mode: Rising Edge
// INT1: Off
// Interrupt on any change on pins PCINT0-7: Off
GIMSK=(0<<INT1) | (1<<INT0) | (0<<PCIE);
MCUCR=(0<<ISC11) | (0<<ISC10) | (1<<ISC01) | (1<<ISC00);
EIFR=(0<<INTF1) | (1<<INTF0) | (0<<PCIF);

// Analog Comparator initialization
// Analog Comparator: Off
// The Analog Comparator's positive input is
// connected to the AIN0 pin
// The Analog Comparator's negative input is
// connected to the AIN1 pin
ACSR=(1<<ACD) | (0<<ACBG) | (0<<ACO) | (0<<ACI) | (0<<ACIE) | (0<<ACIC) | (0<<ACIS1) | (0<<ACIS0);
// Digital input buffer on AIN0: On
// Digital input buffer on AIN1: On
DIDR=(0<<AIN0D) | (0<<AIN1D);

// Global enable interrupts
#asm("sei")

    while (1)
    {   
        if(mode%2!=0)
        {
            mode_switch();
        } 
            
        while(mode == pulse)
        {   
            pulse_mode();
        }
        
        while(mode == full)
        {   
            full_mode();
        }
        
        while(mode == cop_light)
        {              
            cop_light_mode();
        }
        
        while(mode == strobe)
        {              
            strobe_mode(STROBE_DELAY);    
        }  
        
        while(mode == off)
        {   
            off_mode();
        }
    }
}
Exemplo n.º 7
0
/*
 * 3d8 rW   T1T mode control register (see #P138)
 */
void pcvideo_t1000_device::mode_control_w(int data)
{
	m_mode_control = data;

	mode_switch();
}
Exemplo n.º 8
0
void MainWindow::on_pushButton_clicked()
{
	mode_switch();
}
Exemplo n.º 9
0
void MainWindow::on_actionStart_Game_triggered()
{
	mode_switch();
}