?login_element?

Subversion Repositories NedoOS

Rev

Rev 1429 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <oscalls.h>
  6. #include <intrz80.h>
  7. #include <terminal.c>
  8. #define COMMANDLINE 0x0080
  9.  
  10. struct process
  11. {
  12.     unsigned char nomer;
  13.     unsigned char nomer2;
  14.     unsigned char name[32];
  15.     unsigned char used;
  16.     unsigned char window_0;
  17.     unsigned char window_1;
  18.     unsigned char window_2;
  19.     unsigned char window_3;
  20. } table[17];
  21.  
  22. int procnum, prccount;
  23. unsigned char c1, c2, pgbak, freemem, sysmem, usedmem, curpos;
  24. unsigned char procname;
  25. union APP_PAGES main_pg;
  26.  
  27. void redraw(void)
  28. {
  29.     unsigned char c3;
  30.  
  31.     BOX(14, 5, 41, prccount, 43);
  32.     ATRIB(43);
  33.  
  34.     for (c3 = 0; c3 < prccount; c3++)
  35.     {
  36.         AT(12, 5 + c3);
  37.         if (c3 == curpos - 1)
  38.         {
  39.             ATRIB(31);
  40.         }
  41.         else
  42.         {
  43.             ATRIB(30);
  44.         }
  45.         printf("%2X.", table[c3].nomer);
  46.         puts(table[c3].name);
  47.         AT(50, 5 + c3);
  48.         printf("%u  ", table[c3].used);
  49.         AT(55, 5 + c3);
  50.         printf("%2X.", table[c3].window_0);
  51.         printf("%2X.", table[c3].window_1);
  52.         printf("%2X.", table[c3].window_2);
  53.         printf("%2X", table[c3].window_3);
  54.     }
  55.     BOX(12, 5 + prccount, 54, 1, 41);
  56.     AT(12, 5 + prccount);
  57.     ATRIB(33);
  58.     printf("    Free:%u pages     Used:%u pages  Sys:%u pages", freemem, usedmem, sysmem);
  59.     BOX(12, 6 + prccount, 54, 1, 40);
  60. }
  61. void filltable(void)
  62. {
  63.     unsigned char c3, c4;
  64.     main_pg.l = OS_GETMAINPAGES();
  65.     pgbak = main_pg.pgs.window_3;
  66.     prccount = 0;
  67.     for (c3 = 0; c3 < 16; c3++)
  68.     {
  69.         c4 = c3 + 1;
  70.         main_pg.l = OS_GETAPPMAINPAGES(c4);
  71.  
  72.         if (errno == 0)
  73.         {
  74.  
  75.             table[prccount].nomer = c4;
  76.             table[c3].nomer2 = prccount;
  77.             table[prccount].window_0 = main_pg.pgs.window_0;
  78.             table[prccount].window_1 = main_pg.pgs.window_1;
  79.             table[prccount].window_2 = main_pg.pgs.window_2;
  80.             table[prccount].window_3 = main_pg.pgs.window_3;
  81.             SETPG32KHIGH(table[prccount].window_0);
  82.             memcpy(table[prccount].name, (char *)(0xc000 + COMMANDLINE), 31);
  83.             prccount++;
  84.         }
  85.         else
  86.         {
  87.             table[c3].nomer2 = 0;
  88.         }
  89.         table[c3].used = 0;
  90.     }
  91.  
  92.     SETPG32KHIGH(pgbak);
  93.  
  94.     freemem = 0;
  95.     sysmem = 0;
  96.     usedmem = 0;
  97.     for (c2 = 0; c2 < 255; c2++)
  98.     {
  99.         unsigned char owner;
  100.         owner = OS_GETPAGEOWNER(c2);
  101.         if (owner == 0)
  102.         {
  103.             freemem++;
  104.         }
  105.         else
  106.  
  107.             if (owner == 255)
  108.         {
  109.             sysmem++;
  110.         }
  111.         else
  112.         {
  113.             table[table[owner - 1].nomer2].used++;
  114.             usedmem++;
  115.         }
  116.     }
  117. }
  118.  
  119. void killapp(unsigned char id)
  120. {
  121.  
  122.     OS_DROPAPP(id);
  123.     //filltable();
  124. }
  125.  
  126. C_task main(void)
  127. {
  128.     unsigned char loop = 1;
  129.     curpos = 1;
  130.     os_initstdio();
  131.     BOX(1, 1, 80, 25, 40);
  132.     BOX(12, 4, 54, 1, 41);
  133.     AT(33, 4);
  134.     ATRIB(33);
  135.     puts("TASK MANAGER");
  136.     while (loop)
  137.     {
  138.         filltable();
  139.         redraw();
  140.         do
  141.         {
  142.             YIELD();
  143.             procname = _low_level_get();
  144.         } while (procname == 0);
  145.  
  146.         if (procname == 27)
  147.         {
  148.                 break;
  149.         }
  150.  
  151.         if (procname > '0' && procname < 58)
  152.         {
  153.             procname = procname - '0';
  154.             killapp(procname);
  155.         }
  156.  
  157.         if (procname > '@' && procname < 'G')
  158.         {
  159.             killapp(procname - 55);
  160.         }
  161.  
  162.         if (procname > 96 && procname < 'g')
  163.         {
  164.             killapp(procname - 87);
  165.         }
  166.  
  167.         if (procname == 13 || procname == 252)
  168.         {
  169.             killapp(table[curpos - 1].nomer);
  170.         }
  171.  
  172.         if (procname == 250)
  173.         {
  174.             curpos--;
  175.         }
  176.  
  177.         if (procname == 249)
  178.         {
  179.             curpos++;
  180.         }
  181.  
  182.         if (curpos < 1)
  183.         {
  184.             curpos = prccount;
  185.         }
  186.  
  187.         if (curpos > prccount)
  188.         {
  189.             curpos = 1;
  190.         }
  191.     }
  192.     BOX(1, 1, 80, 25, 40);
  193.     AT(1,1);
  194.     ATRIB(47);
  195.     return 0;
  196. }
  197.