Exemple #1
0
HRESULT CLCDOutput::Draw()
{
    DWORD dwPriorityToUse = LGLCD_ASYNC_UPDATE(m_nPriority);
    
    if ( (NULL == m_pActiveScreen)              ||
         (LGLCD_INVALID_DEVICE == m_hDevice)    ||
         (LGLCD_PRIORITY_IDLE_NO_SHOW == dwPriorityToUse) )
    {
        // don't submit the bitmap
        return S_OK;
    }

    // Render the active screen
    m_pActiveScreen->Draw();
    
    // Get the active bitmap
    lgLcdBitmap160x43x1* pScreen = m_pActiveScreen->GetLCDScreen();

    // Only submit if the bitmap needs to be updated
    // (If the priority or bitmap have changed)
    DWORD res = ERROR_SUCCESS;
    if (DoesBitmapNeedUpdate(pScreen))
    {
        res = lgLcdUpdateBitmap(m_hDevice, &pScreen->hdr, dwPriorityToUse);
        HandleErrorFromAPI(res);
    }

    // read the soft buttons
    ReadButtons();

    return S_OK;
}
HRESULT CLCDOutput::Draw()
{
    DWORD dwPriorityToUse;
    
    if (m_pActiveScreen)
    {
        m_pActiveScreen->Draw();
        dwPriorityToUse = LGLCD_ASYNC_UPDATE(m_nPriority);
    }
    else
    {
        dwPriorityToUse = LGLCD_ASYNC_UPDATE(LGLCD_PRIORITY_IDLE_NO_SHOW);
    }
    
    lgLcdBitmap160x43x1* pScreen = GetLCDScreen();
    if (pScreen && (LGLCD_INVALID_DEVICE != m_hDevice))
    {
        DWORD res = ERROR_SUCCESS;
        res = lgLcdUpdateBitmap(m_hDevice, &pScreen->hdr, dwPriorityToUse);
        
        HandleErrorFromAPI(res);

        // read the soft buttons
        ReadButtons();
    }

    return S_OK;
}
Exemple #3
0
unsigned char GetMouseSensitivity(){
	unsigned char sens=-1;

	if(snesMouseEnabled){
		ReadButtons();

		if(joypad1_status_lo&(1<<15)){
			sens=(joypad1_status_lo>>10)&3;
		}else if(joypad2_status_lo&(1<<15)){
Exemple #4
0
/**
 * Initiates teh buttons reading and detect if joypads are connected.
 * When no device are plugged, the internal AVR pullup will drive the data lines high
 * otherwise the controller's shift register will drive the data lines low after 
 * completing a transfer. (The shift register's serial input pin is tied to ground)
 *
 * This functions is call by the kernel during VSYNC or can be called by the user
 * program when CONTROLLERS_VSYNC_READ==0.
*/
void ReadControllers(){

	//Detect if devices are connected.
	joypadsConnectionStatus=0;
	if((JOYPAD_IN_PORT&(1<<JOYPAD_DATA1_PIN))==0) joypadsConnectionStatus|=1;
	if((JOYPAD_IN_PORT&(1<<JOYPAD_DATA2_PIN))==0) joypadsConnectionStatus|=2;
			
	//read the standard buttons
	ReadButtons();
}
Exemple #5
0
void ReadControllers(){

	//detect if joypads are connected
	//when no connector are plugged, the internal AVR pullup will drive the line high
	//otherwise the controller's shift register will drive the line low.
	joypadsConnectionStatus=0;
	if((JOYPAD_IN_PORT&(1<<JOYPAD_DATA1_PIN))==0) joypadsConnectionStatus|=1;
	if((JOYPAD_IN_PORT&(1<<JOYPAD_DATA2_PIN))==0) joypadsConnectionStatus|=2;
			
	//read the standard buttons
	ReadButtons();
}
void Initialize(void){
	int i;

	if(!isEepromFormatted()) FormatEeprom();

	cli();
	
	//Initialize the mixer buffer
	for(i=0;i<MIX_BANK_SIZE*2;i++){
		mix_buf[i]=0x80;
	}	
	
	mix_pos=mix_buf;
	mix_bank=0;

	for(i=0;i<CHANNELS;i++){
		mixer.channels.all[i].volume=0;
	}

	
	#if MIXER_CHAN4_TYPE == 0
		//initialize LFSR		
		tr4_barrel_lo=1;
		tr4_barrel_hi=1;		
		tr4_params=0b00000001; //15 bits no divider (1)
	#endif

	#if UART_RX_BUFFER == 1
		uart_rx_buf_start=0;
		uart_rx_buf_end=0;
	#endif

	#if MIDI_IN == 1
		UCSR0B=(1<<RXEN0); //set UART for MIDI in
		UCSR0C=(1<<UCSZ01)+(1<<UCSZ00);
		UBRR0L=56; //31250 bauds (.5% error)
	#endif

	
	//stop timers
	TCCR1B=0;
	TCCR0B=0;
	
	//set ports
	DDRC=0xff; //video dac
	DDRB=0xff; //h-sync for ad725
	DDRD=(1<<PD7)+(1<<PD4); //audio-out + led 
	PORTD|=(1<<PD4)+(1<<PD3)+(1<<PD2); //turn on led & activate pull-ups for soft-power switches


	//setup port A for joypads
	DDRA =0b00001100; //set only control lines as outputs
	PORTA=0b11111011; //activate pullups on the data lines
	
	//PORTD=0;
	
	//set sync parameters. starts at odd field, in pre-eq pulses, line 1
	sync_phase=SYNC_PHASE_PRE_EQ;
	sync_pulse=SYNC_PRE_EQ_PULSES;

	//set rendering parameters
	render_lines_count_tmp=FRAME_LINES;
	first_render_line_tmp=FIRST_RENDER_LINE;
	

	//clear timers
	TCNT1H=0;
	TCNT1L=0;

	//set sync generator counter on TIMER1
	OCR1AH=HDRIVE_CL_TWICE>>8;
	OCR1AL=HDRIVE_CL_TWICE&0xff;

	TCCR1B=(1<<WGM12)+(1<<CS10);//CTC mode, use OCR1A for match
	TIMSK1=(1<<OCIE1A);			//generate interrupt on match

	//set clock divider counter for AD725 on TIMER0
	//outputs 14.31818Mhz (4FSC)
	TCCR0A=(1<<COM0A0)+(1<<WGM01); //toggle on compare match + CTC
	OCR0A=0; //divide main clock by 2
	TCCR0B=(1<<CS00); //enable timer, no pre-scaler

	//set sound PWM on TIMER2
	TCCR2A=(1<<COM2A1)+(1<<WGM21)+(1<<WGM20); //Fast PWM	
	OCR2A=0; //duty cycle (amplitude)
	TCCR2B=(1<<CS20);  //enable timer, no pre-scaler

	SYNC_PORT=(1<<SYNC_PIN)|(1<<VIDEOCE_PIN); //set sync & chip enable line to hi

	burstOffset=0;
	curr_frame=0;
	vsync_phase=0;
	joypad1_status_hi=0;
	joypad2_status_hi=0;
	snesMouseEnabled=false;
	sound_enabled=1;

	//enable color correction
	ReadButtons();
	if(ReadJoypad(0)&BTN_B){
		SetColorBurstOffset(4);
	}
	
	InitializeVideoMode();

	sei();
	
	DisplayLogo();
	
}
Exemple #7
0
 //----------------------------------------------------------------------------//
 void Menu(void)
 {
      ReadButtons();
      
      
     if( Button1Pressed && Button2Pressed)   // si se han presionado ambos botones 
     {
      ++MenuIn;
     }
     else
     {
         MenuIn = 0;
     }
     
      if(MenuIn >=250)
      {
          MenuIndex = 1;
          MenuIn = 0;
      }
      else
      {
          MenuIndex = 0;
      }
     
      if(MenuIndex != 0)
      {
       switch(MenuIndex)
       {
         case 0:
         {
             
         }
         break;
         
         case 1:
         {
             LED_1 = 1;
             LED_2 = 1;
             
             ConsolePutROMString((ROM char *)"\r\n      MENU : Temperature Calibration ");
             
             
             while((Button1Pressed)&&(Button2Pressed))
             {
                 if( MiApp_MessageAvailable())
                 {
                     MiApp_DiscardMessage();
                 }
                 
                 ReadButtons();
                 ClrWdt();
             }
             
             ConsolePutROMString((ROM char *)"\r\n SW1: Increase offset value  || SW2 Decrease offset value");
             
             
             
             Button1Released = 1;
             Button2Released = 1;
             
             Exit = 0xff;
             OffsetValue = 100;
             
             while(Exit)
             {
                 ReadButtons();
                 
                 
                 
                 
                 
                 if( Button1Pressed && Button2Pressed)   // si se han presionado ambos botones
                 {
                     Exit = 0;
                     ConsolePutROMString((ROM char *)"\r\nExit");       
                 }
                 else
                 {
                     if( Button1Pressed && Button1Released)   // 
                   {
                     Button1Released = 0;
                     ++OffsetValue;
                     LED_1 ^= 1;
                     LED_2 ^= 1;
                     ConsolePutROMString((ROM char *)"\r\nIncreased offset value");
                   }
                 
                   if( Button2Pressed && Button2Released)   // 
                   {   
                     Button2Released = 0;
                     --OffsetValue;
                     LED_1 ^= 1;
                     LED_2 ^= 1;
                     ConsolePutROMString((ROM char *)"\r\nDecreased offset value");
                   }
                 }
                 
           
                 
                 
                 
                 if( MiApp_MessageAvailable())
                 {
                     MiApp_DiscardMessage();
                 }
                 
                 ClrWdt();
             }
             
             while((Button1Pressed)&&(Button2Pressed))
             {
              if( MiApp_MessageAvailable())
              {
                MiApp_DiscardMessage();
              }
                 
              ReadButtons();
              ClrWdt();
             }
             
             
             
             
         }
         break;
         
         case 2:
         {
             
         }
         break;
         
         case 3:
         {
             
         }
         break;
         
         
         default: break;
         
       }
 }
     
     
     
 }