Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4. #include<menuet/os.h>
  5. #include<menuet/textcon.h>
  6. #include<ctype.h>
  7. #include<stdarg.h>
  8. #include<errno.h>
  9.  
  10. static int did_con_init=0;
  11.  
  12. static char * WindowTitle="xtest";
  13.  
  14. static char con_buffer[0x100000];
  15. static char * conp=con_buffer+0;
  16. static unsigned long sz=0;
  17.  
  18. void check_board(void)
  19. {
  20.  int d0,d1;
  21.  do {
  22.   __asm__ __volatile__("int $0x40":"=a"(d0),"=b"(d1):"0"(63),"1"(2));
  23.   if(d1!=1) break;
  24.   _lcon_putch(d0&0xff);
  25.   *conp++=(d0&0xff);
  26.   sz++;
  27.  } while(1);
  28. }
  29.  
  30. void paint_wnd(void)
  31. {
  32.  __menuet__window_redraw(1);
  33.  __menuet__define_window(100,100,20+(NR_CHARS_X*CHAR_SIZE_X),
  34.     30+(NR_CHARS_Y*CHAR_SIZE_Y),0x03000080,0x800000FF,0x000080);
  35.  __menuet__write_text(5,5,0xFFFFFF,WindowTitle,strlen(WindowTitle));
  36.  if(did_con_init) _lcon_flush_console();
  37.  __menuet__window_redraw(2);
  38. }
  39.  
  40. static char kpf_buf[1024];
  41.  
  42. void _kph_pf(char * p)
  43. {
  44.  for(;p && *p;p++) _lcon_putch(*p);
  45. }
  46.  
  47. void kprintf(const char * fmt,...)
  48. {
  49.  va_list ap;
  50.  va_start(ap,fmt);
  51.  vsprintf(kpf_buf,fmt,ap);
  52.  va_end(ap);
  53.  _kph_pf(kpf_buf);  
  54. }
  55.  
  56. int event_loop(void)
  57. {
  58.  int i;
  59.  i=__menuet__check_for_event();
  60.  switch(i)
  61.  {
  62.   case 1:
  63.    paint_wnd(); return 0;
  64.   case 2:
  65.    return __menuet__getkey();
  66.   case 3:
  67.    if(__menuet__get_button_id()==1)
  68.    {
  69.     exit(0);
  70.    }
  71.    return 0;
  72.  }
  73.  return 1;
  74. }
  75.  
  76. void main(void)
  77. {
  78.  unsigned long xtmp;
  79.  int a,b,c;
  80.  FILE * f=fopen("example","rb");
  81.  did_con_init=0;
  82.  paint_wnd();
  83.  init_consoles();
  84.  did_con_init=1;
  85.  xtmp=__menuet__getsystemclock();
  86.  a=(xtmp>>16)&0xff;
  87.  b=(xtmp>>8)&0xff;
  88.  c=xtmp&0xff;
  89.  kprintf("h/m/s=%x:%x:%x %u:%u:%u\n",a,b,c,a,b,c);
  90. #define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
  91.  BCD_TO_BIN(a);
  92.  BCD_TO_BIN(b);
  93.  BCD_TO_BIN(c);
  94.  kprintf("h/m/s=%x:%x:%x %u:%u:%u\n",a,b,c,a,b,c);
  95.  __asm__ __volatile__("int $0x40":"=a"(xtmp):"0"(29));
  96.  a=(xtmp>>16)&0xff;
  97.  b=(xtmp>>8)&0xff;
  98.  c=xtmp&0xff;
  99.  kprintf("y/d/m=%x:%x:%x %u:%u:%u\n",a,b,c,a,b,c);
  100. #define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
  101.  BCD_TO_BIN(a);
  102.  BCD_TO_BIN(b);
  103.  BCD_TO_BIN(c);
  104.  kprintf("y/d/m=%x:%x:%x %u:%u:%u\n",a,b,c,a,b,c);
  105.  for(;;)
  106.  {
  107.   check_board();
  108.   event_loop();
  109.  }
  110. }
  111.