Ejemplo n.º 1
0
/*
 * Keyboard interrupt callback
 */
static int keyboard_handler(struct regs *r) {
	unsigned char scancode;
	keyboard_wait();
	scancode = inportb(KEY_DEVICE);
	irq_ack(KEY_IRQ);

	write_fs(keyboard_pipe, 0, 1, (uint8_t []){scancode});
	return 1;
}
Ejemplo n.º 2
0
char getch()
 {
   unsigned int code,c;
   do
   {
    keyboard_wait();
    c=deq(&_q,&code);
   }
   while (c==-1);
  
   return ((char)code);
 };
Ejemplo n.º 3
0
unsigned int getchw()
 {
  unsigned int code,c;
  do
   {
    keyboard_wait();   
    c=deq(&_q,&code);
   }
   while (c==-1);
   if (current_process->accesslevel==ACCESS_USER)
   return code;
 };
Ejemplo n.º 4
0
/*---------------------------------------------------------
 Function: input_wait

 Description:
 Wait until all enabled input devices have been released.
---------------------------------------------------------*/
void input_wait(void)
{
   if (keyboard) keyboard_wait();
   if (mouse) mouse_wait();
   if (joypad) joypad_wait();
}
Ejemplo n.º 5
0
/**
 * Entry point 
 */
int main(void) {

  /* Misc variables */
  DCPU_registers reg; // CPU registers states (at boot)

  /* Hardware initialisation */
  cli();
  led_setup();
  spi_setup(SPI_PRESCALER, SPI_MODE, SPI_BITS_ORDER);
  uart_setup(UART_BAUDRATE);
  DEBUG_STR("Main init", "UART ready");
  button_setup();
  buzzer_setup(BUZZER_FREQUENCY, BUZZER_DURATION);
  ram_setup();
  rom_setup();
  microvga_setup();
  microvga_enable();
  dcpu_register_init(&reg);
  DEBUG_STR("Main init", "done");
  sei();
  
  /* MicroVGA initialisation */
  _delay_ms(1000);         // MicroVGA boot time
  microvga_clear_screen(); // Clear screen and goto (0, 0)
  microvga_goto_cursor(0, 0);
  uart_puts_PSTR(PSTR("SkyWodd DCPU-16 hardware emulator")); // Screen test
  buzzer_beep();
  DEBUG_STR("Main init", "MicroVGA ready");
  
  /* Hardware self-test */
  DEBUG_STR("Main init", "self-test run");
  led_run_write(1); // Led test
  _delay_ms(250);
  led_run_write(0);
  led_cpu_write(1);
  _delay_ms(250);
  led_cpu_write(0);
  led_rom_write(1);
  _delay_ms(250);
  led_rom_write(0);
  led_ram_write(1);
  _delay_ms(250);
  led_ram_write(0);
  DEBUG_STR("Main init", "self-test done");
  
  /* Keyboard & MicroVGA api test */
  DEBUG_STR("Main init", "waiting for keypress");
  microvga_goto_cursor(0, 1);
  uart_puts_PSTR(PSTR("Press any key to boot ..."));
  keyboard_wait();
  uart_puts_PSTR(PSTR("Loading please wait ..."));
  dcpu_setup(reg);
  buzzer_beep();
  microvga_clear_screen();
  microvga_goto_cursor(0, 0);
  DEBUG_STR("Main init", "ready to run");
  
  /* Infinite loop */
  for(;;) {
  
    /* Handle pause */
    while(!button_get_state()); 
	
#ifdef SERIAL_DEBUG_SUPPORT
	/* Debug */
	dcpu_registers_dump();
#endif
	
	/* Fetch opcode from ROM */
    dcpu_step(); 
  }
  
}