コード例 #1
0
static void
make_window8(unsigned char* buf, int width, int height, char* title)
{
    static char s_close_btn[14][16] = {
        "OOOOOOOOOOOOOOO@",
        "OQQQQQQQQQQQQQ$@",
        "OQQQQQQQQQQQQQ$@",
        "OQQQ@@QQQQ@@QQ$@",
        "OQQQQ@@QQ@@QQQ$@",
        "OQQQQQ@@@@QQQQ$@",
        "OQQQQQQ@@QQQQQ$@",
        "OQQQQQ@@@@QQQQ$@",
        "OQQQQ@@QQ@@QQQ$@",
        "OQQQ@@QQQQ@@QQ$@",
        "OQQQQQQQQQQQQQ$@",
        "OQQQQQQQQQQQQQ$@",
        "O$$$$$$$$$$$$$$@",
        "@@@@@@@@@@@@@@@@",
    };
    int x, y;
    char c;

    fill_box8(buf, width, COLOR8_C6C6C6, 0, 0, width - 1, 0);
    fill_box8(buf, width, COLOR8_FFFFFF, 1, 1, width - 2, 1);
    fill_box8(buf, width, COLOR8_C6C6C6, 0, 0, 0, height - 1);
    fill_box8(buf, width, COLOR8_FFFFFF, 1, 1, 1, height - 2);
    fill_box8(buf, width, COLOR8_848484, width - 2, 1, width - 2, height - 2);
    fill_box8(buf, width, COLOR8_000000, width - 1, 0, width - 1, height - 1);
    fill_box8(buf, width, COLOR8_C6C6C6, 2, 2, width - 3, height - 3);
    fill_box8(buf, width, COLOR8_000084, 3, 3, width - 4, 20);
    fill_box8(buf, width, COLOR8_848484,
              1, height - 2, width - 2, height - 2);
    fill_box8(buf, width, COLOR8_000000,
              0, height - 1, width - 1, height - 1);
    draw_font8_asc(buf, width, 24, 4, COLOR8_FFFFFF, title);

    for (y = 0; y < 14; ++y) {
        for (x = 0; x < 16; ++x) {
            c = s_close_btn[y][x];
            switch (c) {
            case '@':
                c = COLOR8_000000;
                break;
            case '$':
                c = COLOR8_848484;
                break;
            case 'Q':
                c = COLOR8_C6C6C6;
                break;
            default:
                c = COLOR8_FFFFFF;
            }
            buf[(5 + y) * width + (width - 21 + x)] = c;
        }
    }
}
コード例 #2
0
ファイル: pic.c プロジェクト: hbfhaapy/study
void 
interrupt_handler2c(int* esp)
{
  boot_info_t* binfo = (boot_info_t*)ADR_BOOTINFO;
  fill_box8(binfo->vram, binfo->screen_x, 
      COLOR8_000000, 0, 0, 32 * 8 - 1, 15);
  draw_font8_asc(binfo->vram, binfo->screen_x, 0, 0, 
      COLOR8_FFFFFF, "INT 21 (IRQ - 12): PS/2 mouse");

  for ( ; ; )
    io_hlt();
}
コード例 #3
0
ファイル: window.c プロジェクト: songtzu/study
void 
make_title8(unsigned char* buf, int width, char* title, char act)
{
  static char s_close_btn[14][16] = {
    "OOOOOOOOOOOOOOO@", 
    "OQQQQQQQQQQQQQ$@", 
    "OQQQQQQQQQQQQQ$@", 
    "OQQQ@@QQQQ@@QQ$@", 
    "OQQQQ@@QQ@@QQQ$@", 
    "OQQQQQ@@@@QQQQ$@", 
    "OQQQQQQ@@QQQQQ$@", 
    "OQQQQQ@@@@QQQQ$@", 
    "OQQQQ@@QQ@@QQQ$@", 
    "OQQQ@@QQQQ@@QQ$@", 
    "OQQQQQQQQQQQQQ$@", 
    "OQQQQQQQQQQQQQ$@", 
    "O$$$$$$$$$$$$$$@", 
    "@@@@@@@@@@@@@@@@", 
  };
  int x, y;
  char c, tc, tbc;

  if (0 != act) {
    tc  = COLOR8_FFFFFF;
    tbc = COLOR8_000084;
  }
  else {
    tc  = COLOR8_C6C6C6;
    tbc = COLOR8_848484;
  }

  fill_box8(buf, width, tbc, 3, 3, width - 4, 20);
  draw_font8_asc(buf, width, 24, 4, tc, title);

  for (y = 0; y < 14; ++y) {
    for (x = 0; x < 16; ++x) {
      c = s_close_btn[y][x];
      switch (c) {
      case '@':
        c = COLOR8_000000; break;
      case '$':
        c = COLOR8_848484; break;
      case 'Q':
        c = COLOR8_C6C6C6; break;
      default:
        c = COLOR8_FFFFFF; break;
      }
      buf[(5 + y) * width + (width - 21 + x)] = c;
    }
  }
}
コード例 #4
0
ファイル: bootpack.c プロジェクト: hbfhaapy/study
void 
HariMain(void)
{
  boot_info_t* binfo = (boot_info_t*)ADR_BOOTINFO;
  char debug_info[64], mouse_cursor[256], keybuf[32];
  int mouse_x, mouse_y;

  init_gdt_idt();
  init_pic();
  io_sti();

  fifo_init(&g_keybuf, keybuf, 32);
  io_out8(PIC0_IMR, 0xf9);
  io_out8(PIC1_IMR, 0xef);

  init_keyboard();    /* initialize keyboard */

  init_palette();
  init_screen(binfo->vram, binfo->screen_x, binfo->screen_y);
  mouse_x = (binfo->screen_x - 16) / 2;
  mouse_y = (binfo->screen_y - 28 - 16) / 2;
  init_mouse_cursor8(mouse_cursor, COLOR8_848484);
  draw_block8_8(binfo->vram, binfo->screen_x, 16, 16, 
      mouse_x, mouse_y, mouse_cursor, 16);

  draw_font8_asc(binfo->vram, binfo->screen_x, 8, 8, 
      COLOR8_FFFFFF, "HELLO BOYS:");
  draw_font8_asc(binfo->vram, binfo->screen_x, 9, 9, 
      COLOR8_000000, "HELLO BOYS:");
  draw_font8_asc(binfo->vram, binfo->screen_x, 31, 31, 
      COLOR8_000000, "WELCOME TO THE LOVELY TOY-OS.");
  draw_font8_asc(binfo->vram, binfo->screen_x, 30, 30, 
      COLOR8_FFFFFF, "WELCOME TO THE LOVELY TOY-OS.");

  sprintf(debug_info, "screen=>{%d, %d}", binfo->screen_x, binfo->screen_y);
  draw_font8_asc(binfo->vram, binfo->screen_x, 16, 64, 
      COLOR8_FF0000, debug_info);

  enable_mouse();   /* enabled mouse */

  for ( ; ; ) {
    int data;

    io_cli();

    if (0 == fifo_size(&g_keybuf)) 
      io_stihlt();
    else {
      data = fifo_get(&g_keybuf);

      io_sti();
      sprintf(debug_info, "%02X", data);
      fill_box8(binfo->vram, binfo->screen_x, COLOR8_008484, 0, 16, 15, 31);
      draw_font8_asc(binfo->vram, binfo->screen_x, 
          0, 16, COLOR8_FFFFFF, debug_info);
    }
  }
}
コード例 #5
0
ファイル: bootpack.c プロジェクト: hbfhaapy/study
void 
HariMain(void)
{
  boot_info_t* binfo = (boot_info_t*)ADR_BOOTINFO;
  char debug_info[64], mouse_cursor[256];
  int mouse_x, mouse_y;

  init_gdt_idt();
  init_pic();
  io_sti();

  io_out8(PIC0_IMR, 0xf9);
  io_out8(PIC1_IMR, 0xef);

  init_palette();
  init_screen(binfo->vram, binfo->screen_x, binfo->screen_y);
  mouse_x = (binfo->screen_x - 16) / 2;
  mouse_y = (binfo->screen_y - 28 - 16) / 2;
  init_mouse_cursor8(mouse_cursor, COLOR8_848484);
  draw_block8_8(binfo->vram, binfo->screen_x, 16, 16, 
      mouse_x, mouse_y, mouse_cursor, 16);

  draw_font8_asc(binfo->vram, binfo->screen_x, 8, 8, 
      COLOR8_FFFFFF, "HELLO BOYS:");
  draw_font8_asc(binfo->vram, binfo->screen_x, 9, 9, 
      COLOR8_000000, "HELLO BOYS:");
  draw_font8_asc(binfo->vram, binfo->screen_x, 31, 31, 
      COLOR8_000000, "WELCOME TO THE LOVELY TOY-OS.");
  draw_font8_asc(binfo->vram, binfo->screen_x, 30, 30, 
      COLOR8_FFFFFF, "WELCOME TO THE LOVELY TOY-OS.");

  sprintf(debug_info, "screen=>{%d, %d}", binfo->screen_x, binfo->screen_y);
  draw_font8_asc(binfo->vram, binfo->screen_x, 16, 64, 
      COLOR8_FF0000, debug_info);


  for ( ; ; ) {
    int data, i;

    io_cli();

    if (0 == g_keybuf.next) 
      io_stihlt();
    else {
      data = g_keybuf.data[0];
      --g_keybuf.next;
      for (i = 0; i < g_keybuf.next; ++i) 
        g_keybuf.data[i] = g_keybuf.data[i + 1];

      io_sti();
      sprintf(debug_info, "%02X", data);
      fill_box8(binfo->vram, binfo->screen_x, COLOR8_008484, 0, 16, 15, 31);
      draw_font8_asc(binfo->vram, binfo->screen_x, 
          0, 16, COLOR8_FFFFFF, debug_info);
    }
  }
}
コード例 #6
0
ファイル: window.c プロジェクト: songtzu/study
void 
drawstring_and_refresh(layer_t* layer, int x, int y, 
    int color, int bg_color, char* string, int len)
{
  /*
   * x, y => position of string 
   * color => color of string
   * bg_color => background color of string 
   * string => string to display
   * len => length of string
   */

  fill_box8(layer->buf, layer->w_size, bg_color, 
      x, y, x + len * 8 - 1, y + 15);
  draw_font8_asc(layer->buf, layer->w_size, x, y, color, string);
  layers_refresh(layer, x, y, x + len * 8, y + 16);
}
コード例 #7
0
ファイル: bootpack.c プロジェクト: hbfhaapy/study
void 
HariMain(void)
{
  boot_info_t* binfo = (boot_info_t*)ADR_BOOTINFO;
  char debug_info[64], keybuf[32], mousebuf[128];
  int mouse_x, mouse_y;
  int data;
  mouse_dec_t mdec;
  unsigned int memory_total;
  mem_mgr_t* mem_mgr = (mem_mgr_t*)MEMMGR_ADDR;
  layer_mgr_t* layer_mgr;
  layer_t* back_layer;
  layer_t* mouse_layer;
  unsigned char* back_buf;
  unsigned char  mouse_buf[256];

  init_gdt_idt();
  init_pic();
  io_sti();

  fifo_init(&g_keybuf, keybuf, 32);
  fifo_init(&g_mousebuf, mousebuf, 128);
  io_out8(PIC0_IMR, 0xf9);
  io_out8(PIC1_IMR, 0xef);

  init_keyboard();      /* initialize keyboard */
  enable_mouse(&mdec);  /* enabled mouse */

  memory_total = memory_test(0x00400000, 0xbfffffff);
  mem_mgr_init(mem_mgr);
  mem_mgr_free(mem_mgr, 0x00001000, 0x0009e000);  /*0x00001000~0x0009e000*/
  mem_mgr_free(mem_mgr, 0x00400000, memory_total - 0x00400000);

  init_palette();
  layer_mgr = layer_mgr_init(mem_mgr, binfo->vram, 
      binfo->screen_x, binfo->screen_y);
  back_layer = layer_alloc(layer_mgr);
  mouse_layer = layer_alloc(layer_mgr);
  back_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 
      binfo->screen_x * binfo->screen_y);
  layer_setbuf(back_layer, back_buf, 
      binfo->screen_x, binfo->screen_y, -1);
  layer_setbuf(mouse_layer, mouse_buf, 16, 16, 99);
  init_screen(back_buf, binfo->screen_x, binfo->screen_y);
  init_mouse_cursor8(mouse_buf, 99);
  layer_slide(layer_mgr, back_layer, 0, 0);
  mouse_x = (binfo->screen_x - 16) / 2;
  mouse_y = (binfo->screen_y - 28 - 16) / 2;
  layer_slide(layer_mgr, mouse_layer, mouse_x, mouse_y);
  layer_updown(layer_mgr, back_layer, 0);
  layer_updown(layer_mgr, mouse_layer, 1);
  sprintf(debug_info, "(%3d, %3d)", mouse_x, mouse_y);
  draw_font8_asc(back_buf, binfo->screen_x, 0, 0, 
      COLOR8_FFFFFF, debug_info);

  sprintf(debug_info, "memory total: %dMB, free space: %dKB", 
      memory_total / (1024 * 1024), mem_mgr_total(mem_mgr) / 1024);
  draw_font8_asc(back_buf, binfo->screen_x, 
      0, 32, COLOR8_FFFFFF, debug_info);

  layers_refresh(layer_mgr, back_layer, 0, 0, binfo->screen_x, 48);

  for ( ; ; ) {
    io_cli();

    if (0 == fifo_size(&g_keybuf) && 0 == fifo_size(&g_mousebuf)) 
      io_stihlt();
    else {
      if (0 != fifo_size(&g_keybuf)) {
          data = fifo_get(&g_keybuf);

          io_sti();
          sprintf(debug_info, "%02X", data);
          fill_box8(back_buf, binfo->screen_x, 
            COLOR8_848484, 0, 16, 15, 31);
          draw_font8_asc(back_buf, binfo->screen_x, 
            0, 16, COLOR8_FFFFFF, debug_info);

          layers_refresh(layer_mgr, back_layer, 0, 16, 16, 32);
      }
      else if (0 != fifo_size(&g_mousebuf)) {
        data = fifo_get(&g_mousebuf);
        io_sti();

        if (0 != mouse_decode(&mdec, data)) {
          /* show all mouse bytes code */
          sprintf(debug_info, "[lcr %4d %4d]", mdec.x, mdec.y);
          if (0 != (mdec.state & 0x01)) 
            debug_info[1] = 'L';
          if (0 != (mdec.state & 0x02))
            debug_info[3] = 'R';
          if (0 != (mdec.state & 0x04))
            debug_info[2] = 'C';
          fill_box8(back_buf, binfo->screen_x, 
              COLOR8_848484, 32, 16, 32 + 15 * 8 - 1, 31);
          draw_font8_asc(back_buf, binfo->screen_x, 
              32, 16, COLOR8_FFFFFF, debug_info);
          layers_refresh(layer_mgr, back_layer, 32, 16, 32 + 15 * 8, 32);

          mouse_x += mdec.x;
          mouse_y += mdec.y;

          if (mouse_x < 0)
            mouse_x = 0;
          if (mouse_y < 0)
            mouse_y = 0;
          if (mouse_x > binfo->screen_x - 1)
            mouse_x = binfo->screen_x - 1;
          if (mouse_y > binfo->screen_y - 1)
            mouse_y = binfo->screen_y - 1;

          sprintf(debug_info, "(%3d, %3d)", mouse_x, mouse_y);
          fill_box8(back_buf, binfo->screen_x, 
              COLOR8_848484, 0, 0, 79, 15);     /* hide mouse position */
          draw_font8_asc(back_buf, binfo->screen_x, 
              0, 0, COLOR8_FFFFFF, debug_info); /* show mouse position */

          layers_refresh(layer_mgr, back_layer, 0, 0, 80, 16);
          layer_slide(layer_mgr, mouse_layer, mouse_x, mouse_y);
        }
      }
    }
  }
}
コード例 #8
0
ファイル: console.c プロジェクト: songtzu/study
int* 
toy_api(int edi, int esi, int ebp, 
    int esp, int ebx, int edx, int ecx, int eax)
{
  int ds_base = *((int*)0x0fe8);
  task_t* task = task_now();
  console_t* console = (console_t*)(*((int*)0x0fec));
  layer_mgr_t* layermgr = (layer_mgr_t*)(*((int*)0x0fe4));
  layer_t* layer;
  int* reg = &eax + 1;  /* address after eax */
  /*
   * force to modify value of pushad
   * reg[0] : edi, reg[1] : esi, reg[2] : ebp, reg[3] : esp 
   * reg[4] : ebx, reg[5] : edx, reg[6] : ecx, reg[7] : eax
   */

  switch (edx) {
  case 1:
    console_putchar(console, eax & 0xff, 1);
    break;
  case 2:
    console_putstr0(console, (char*)ebx + ds_base);
    break;
  case 3:
    console_putstr1(console, (char*)ebx + ds_base, ecx);
    break;
  case 4:
    return &(task->tss.esp0);
  case 5: 
    {
      layer = layer_alloc(layermgr);
      layer_setbuf(layer, (char*)ebx + ds_base, esi, edi, eax);
      make_window8((char*)ebx + ds_base, esi, edi, (char*)ecx + ds_base, 0);
      layer_slide(layer, 100, 50);
      layer_updown(layer, 3);
      reg[7] = (int)layer;
    } break;
  case 6:
    {
      layer = (layer_t*)ebx;
      draw_font8_asc(layer->buf, layer->w_size, 
          esi, edi, eax, (char*)ebp + ds_base);
      layers_refresh(layer, esi, edi, esi + ecx * 8, edi + 16);
    } break;
  case 7:
    {
      layer = (layer_t*)ebx;
      fill_box8(layer->buf, layer->w_size, ebp, eax, ecx, esi, edi);
      layers_refresh(layer, eax, ecx, esi + 1, edi + 1);
    } break;
  case 8:
    {
      mem_mgr_init((mem_mgr_t*)(ebx + ds_base));
      ecx &= 0xfffffff0;  /* unit: 16bytes */
      mem_mgr_free((mem_mgr_t*)(ebx + ds_base), eax, ecx);
    } break;
  case 9: 
    {
      ecx = (ecx + 0x0f) & 0xfffffff0;
      reg[7] = mem_mgr_alloc((mem_mgr_t*)(ebx + ds_base), ecx);
    } break;
  case 10:
    {
      ecx = (ecx + 0x0f) & 0xfffffff0;
      mem_mgr_free((mem_mgr_t*)(ebx + ds_base), eax, ecx);
    } break;
  }

  return 0;
}
コード例 #9
0
ファイル: bootpack.c プロジェクト: hbfhaapy/study
void 
HariMain(void)
{
  boot_info_t* binfo = (boot_info_t*)ADR_BOOTINFO;
  fifo8_t timerfifo;
  char debug_info[64], keybuf[32], mousebuf[128], timerbuf[8];
  int mouse_x, mouse_y;
  int data;
  mouse_dec_t mdec;
  unsigned int memory_total;
  mem_mgr_t* mem_mgr = (mem_mgr_t*)MEMMGR_ADDR;
  layer_mgr_t* layer_mgr;
  layer_t* back_layer;
  layer_t* mouse_layer;
  layer_t* win_layer;
  unsigned char* back_buf;
  unsigned char  mouse_buf[256];
  unsigned char* win_buf;

  init_gdt_idt();
  init_pic();
  io_sti();   /* after initialize IDT/PIC, allow all CPU's interruptors */

  fifo_init(&g_keybuf, keybuf, 32);
  fifo_init(&g_mousebuf, mousebuf, 128);
  init_pit(); /* initialize programmable interval timer */
  io_out8(PIC0_IMR, 0xf8);  /* set PIT/PIC1/keyboard permission 11111000 */
  io_out8(PIC1_IMR, 0xef);  /* set mouse permission 11101111 */

  fifo_init(&timerfifo, timerbuf, 8);
  set_timer(1000, &timerfifo, 1);

  init_keyboard();      /* initialize keyboard */
  enable_mouse(&mdec);  /* enabled mouse */

  memory_total = memory_test(0x00400000, 0xbfffffff);
  mem_mgr_init(mem_mgr);
  mem_mgr_free(mem_mgr, 0x00001000, 0x0009e000);  /*0x00001000~0x0009e000*/
  mem_mgr_free(mem_mgr, 0x00400000, memory_total - 0x00400000);

  init_palette();
  layer_mgr = layer_mgr_init(mem_mgr, binfo->vram, 
      binfo->screen_x, binfo->screen_y);
  back_layer = layer_alloc(layer_mgr);
  mouse_layer = layer_alloc(layer_mgr);
  win_layer = layer_alloc(layer_mgr);
  back_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 
      binfo->screen_x * binfo->screen_y);
  win_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 160 * 52);
  layer_setbuf(back_layer, back_buf, 
      binfo->screen_x, binfo->screen_y, -1);
  layer_setbuf(mouse_layer, mouse_buf, 16, 16, 99);
  layer_setbuf(win_layer, win_buf, 160, 52, -1);
  init_screen(back_buf, binfo->screen_x, binfo->screen_y);
  init_mouse_cursor8(mouse_buf, 99);
  make_window8(win_buf, 160, 52, "Counter");
  layer_slide(back_layer, 0, 0);
  mouse_x = (binfo->screen_x - 16) / 2;
  mouse_y = (binfo->screen_y - 28 - 16) / 2;
  layer_slide(mouse_layer, mouse_x, mouse_y);
  layer_slide(win_layer, 80, 72);
  layer_updown(back_layer, 0);
  layer_updown(win_layer, 1);
  layer_updown(mouse_layer, 2);
  sprintf(debug_info, "(%3d, %3d)", mouse_x, mouse_y);
  draw_font8_asc(back_buf, binfo->screen_x, 0, 0, 
      COLOR8_FFFFFF, debug_info);

  sprintf(debug_info, "memory total: %dMB, free space: %dKB", 
      memory_total / (1024 * 1024), mem_mgr_total(mem_mgr) / 1024);
  draw_font8_asc(back_buf, binfo->screen_x, 
      0, 32, COLOR8_FFFFFF, debug_info);

  layers_refresh(back_layer, 0, 0, binfo->screen_x, 48);

  for ( ; ; ) {
    sprintf(debug_info, "%010d", g_timerctl.count);
    fill_box8(win_buf, 160, COLOR8_C6C6C6, 40, 28, 119, 43);
    draw_font8_asc(win_buf, 160, 40, 28, COLOR8_000000, debug_info);
    layers_refresh(win_layer, 40, 28, 120, 44);

    io_cli();
    if (0 == fifo_size(&g_keybuf) 
        && 0 == fifo_size(&g_mousebuf)
        && 0 == fifo_size(&timerfifo)) 
      io_stihlt();
    else {
      if (0 != fifo_size(&g_keybuf)) {
          data = fifo_get(&g_keybuf);

          io_sti();
          sprintf(debug_info, "%02X", data);
          fill_box8(back_buf, binfo->screen_x, 
            COLOR8_848484, 0, 16, 15, 31);
          draw_font8_asc(back_buf, binfo->screen_x, 
            0, 16, COLOR8_FFFFFF, debug_info);

          layers_refresh(back_layer, 0, 16, 16, 32);
      }
      else if (0 != fifo_size(&g_mousebuf)) {
        data = fifo_get(&g_mousebuf);
        io_sti();

        if (0 != mouse_decode(&mdec, data)) {
          /* show all mouse bytes code */
          sprintf(debug_info, "[lcr %4d %4d]", mdec.x, mdec.y);
          if (0 != (mdec.state & 0x01)) 
            debug_info[1] = 'L';
          if (0 != (mdec.state & 0x02))
            debug_info[3] = 'R';
          if (0 != (mdec.state & 0x04))
            debug_info[2] = 'C';
          fill_box8(back_buf, binfo->screen_x, 
              COLOR8_848484, 32, 16, 32 + 15 * 8 - 1, 31);
          draw_font8_asc(back_buf, binfo->screen_x, 
              32, 16, COLOR8_FFFFFF, debug_info);
          layers_refresh(back_layer, 32, 16, 32 + 15 * 8, 32);

          mouse_x += mdec.x;
          mouse_y += mdec.y;

          if (mouse_x < 0)
            mouse_x = 0;
          if (mouse_y < 0)
            mouse_y = 0;
          if (mouse_x > binfo->screen_x - 1)
            mouse_x = binfo->screen_x - 1;
          if (mouse_y > binfo->screen_y - 1)
            mouse_y = binfo->screen_y - 1;

          sprintf(debug_info, "(%3d, %3d)", mouse_x, mouse_y);
          fill_box8(back_buf, binfo->screen_x, 
              COLOR8_848484, 0, 0, 79, 15);     /* hide mouse position */
          draw_font8_asc(back_buf, binfo->screen_x, 
              0, 0, COLOR8_FFFFFF, debug_info); /* show mouse position */

          layers_refresh(back_layer, 0, 0, 80, 16);
          layer_slide(mouse_layer, mouse_x, mouse_y);
        }
      }
      else if (0 != fifo_size(&timerfifo)) {
        data = fifo_get(&timerfifo);
        io_sti();

        draw_font8_asc(back_buf, binfo->screen_x, 
            0, 64, COLOR8_FFFFFF, "10[sec]");
        layers_refresh(back_layer, 0, 64, 56, 80);
      }
    }
  }
}
コード例 #10
0
ファイル: bootpack.c プロジェクト: hbfhaapy/study
void 
HariMain(void)
{
  boot_info_t* binfo = (boot_info_t*)ADR_BOOTINFO;
  char debug_info[64], mouse_cursor[256], keybuf[32], mousebuf[128];
  int mouse_x, mouse_y;
  int data;
  mouse_dec_t mdec;

  init_gdt_idt();
  init_pic();
  io_sti();

  fifo_init(&g_keybuf, keybuf, 32);
  fifo_init(&g_mousebuf, mousebuf, 128);
  io_out8(PIC0_IMR, 0xf9);
  io_out8(PIC1_IMR, 0xef);

  init_keyboard();    /* initialize keyboard */

  init_palette();
  init_screen(binfo->vram, binfo->screen_x, binfo->screen_y);
  mouse_x = (binfo->screen_x - 16) / 2;
  mouse_y = (binfo->screen_y - 28 - 16) / 2;
  init_mouse_cursor8(mouse_cursor, COLOR8_848484);
  draw_block8_8(binfo->vram, binfo->screen_x, 16, 16, 
      mouse_x, mouse_y, mouse_cursor, 16);
  sprintf(debug_info, "(%3d, %3d)", mouse_x, mouse_y);
  draw_font8_asc(binfo->vram, binfo->screen_x, 0, 0, 
      COLOR8_FFFFFF, debug_info);


  enable_mouse(&mdec);   /* enabled mouse */

  for ( ; ; ) {
    io_cli();

    if (0 == fifo_size(&g_keybuf) && 0 == fifo_size(&g_mousebuf)) 
      io_stihlt();
    else {
      if (0 != fifo_size(&g_keybuf)) {
          data = fifo_get(&g_keybuf);

          io_sti();
          sprintf(debug_info, "%02X", data);
          fill_box8(binfo->vram, binfo->screen_x, 
            COLOR8_848484, 0, 16, 15, 31);
          draw_font8_asc(binfo->vram, binfo->screen_x, 
            0, 16, COLOR8_FFFFFF, debug_info);
      }
      else if (0 != fifo_size(&g_mousebuf)) {
        data = fifo_get(&g_mousebuf);
        io_sti();

        if (0 != mouse_decode(&mdec, data)) {
          /* show all mouse bytes code */
          sprintf(debug_info, "[lcr %4d %4d]", mdec.x, mdec.y);
          if (0 != (mdec.state & 0x01)) 
            debug_info[1] = 'L';
          if (0 != (mdec.state & 0x02))
            debug_info[3] = 'R';
          if (0 != (mdec.state & 0x04))
            debug_info[2] = 'C';
          fill_box8(binfo->vram, binfo->screen_x, 
              COLOR8_848484, 32, 16, 32 + 15 * 8 - 1, 31);
          draw_font8_asc(binfo->vram, binfo->screen_x, 
              32, 16, COLOR8_FFFFFF, debug_info);

          /* move mouse pointer */
          fill_box8(binfo->vram, binfo->screen_x, COLOR8_848484, 
              mouse_x, mouse_y, mouse_x + 15, mouse_y + 15);/* hide mouse */
          mouse_x += mdec.x;
          mouse_y += mdec.y;

          if (mouse_x < 0)
            mouse_x = 0;
          if (mouse_y < 0)
            mouse_y = 0;
          if (mouse_x > binfo->screen_x - 16)
            mouse_x = binfo->screen_x - 16;
          if (mouse_y > binfo->screen_y - 16)
            mouse_y = binfo->screen_y - 16;

          sprintf(debug_info, "(%3d, %3d)", mouse_x, mouse_y);
          fill_box8(binfo->vram, binfo->screen_x, 
              COLOR8_848484, 0, 0, 79, 15);     /* hide mouse position */
          draw_font8_asc(binfo->vram, binfo->screen_x, 
              0, 0, COLOR8_FFFFFF, debug_info); /* show mouse position */
          draw_block8_8(binfo->vram, binfo->screen_x, 
              16, 16, mouse_x, mouse_y, mouse_cursor,  16); /* draw mouse */
        }
      }
    }
  }
}