#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <oscalls.h>
#include <intrz80.h>
#include <terminal.c>
#define COMMANDLINE 0x0080
struct process
{
unsigned char nomer;
unsigned char nomer2;
unsigned char name[32];
unsigned char used;
unsigned char window_0;
unsigned char window_1;
unsigned char window_2;
unsigned char window_3;
} table[17];
int procnum, prccount;
unsigned char c1, c2, pgbak, freemem, sysmem, usedmem, curpos;
unsigned char procname;
union APP_PAGES main_pg;
void redraw(void)
{
unsigned char c3;
BOX(14, 5, 41, prccount, 43);
ATRIB(43);
for (c3 = 0; c3 < prccount; c3++)
{
AT(12, 5 + c3);
if (c3 == curpos - 1)
{
ATRIB(31);
}
else
{
ATRIB(30);
}
printf("%2X.", table
[c3
].
nomer);
AT(50, 5 + c3);
printf("%u ", table
[c3
].
used);
AT(55, 5 + c3);
printf("%2X.", table
[c3
].
window_0);
printf("%2X.", table
[c3
].
window_1);
printf("%2X.", table
[c3
].
window_2);
printf("%2X", table
[c3
].
window_3);
}
BOX(12, 5 + prccount, 54, 1, 41);
AT(12, 5 + prccount);
ATRIB(33);
printf(" Free:%u pages Used:%u pages Sys:%u pages", freemem
, usedmem
, sysmem
);
BOX(12, 6 + prccount, 54, 1, 40);
}
void filltable(void)
{
unsigned char c3, c4;
main_pg.l = OS_GETMAINPAGES();
pgbak = main_pg.pgs.window_3;
prccount = 0;
for (c3 = 0; c3 < 16; c3++)
{
c4 = c3 + 1;
main_pg.l = OS_GETAPPMAINPAGES(c4);
if (errno == 0)
{
table[prccount].nomer = c4;
table[c3].nomer2 = prccount;
table[prccount].window_0 = main_pg.pgs.window_0;
table[prccount].window_1 = main_pg.pgs.window_1;
table[prccount].window_2 = main_pg.pgs.window_2;
table[prccount].window_3 = main_pg.pgs.window_3;
SETPG32KHIGH(table[prccount].window_0);
memcpy(table
[prccount
].
name, (char *)(0xc000 + COMMANDLINE
), 31);
prccount++;
}
else
{
table[c3].nomer2 = 0;
}
table[c3].used = 0;
}
SETPG32KHIGH(pgbak);
freemem = 0;
sysmem = 0;
usedmem = 0;
for (c2 = 0; c2 < 255; c2++)
{
unsigned char owner;
owner = OS_GETPAGEOWNER(c2);
if (owner == 0)
{
freemem++;
}
else
if (owner == 255)
{
sysmem++;
}
else
{
table[table[owner - 1].nomer2].used++;
usedmem++;
}
}
}
void killapp(unsigned char id)
{
OS_DROPAPP(id);
//filltable();
}
C_task main(void)
{
unsigned char loop = 1;
curpos = 1;
os_initstdio();
BOX(1, 1, 80, 25, 40);
BOX(12, 4, 54, 1, 41);
AT(33, 4);
ATRIB(33);
while (loop)
{
filltable();
redraw();
do
{
YIELD();
procname = _low_level_get();
} while (procname == 0);
if (procname == 27)
{
break;
}
if (procname > '0' && procname < 58)
{
procname = procname - '0';
killapp(procname);
}
if (procname > '@' && procname < 'G')
{
killapp(procname - 55);
}
if (procname > 96 && procname < 'g')
{
killapp(procname - 87);
}
if (procname == 13 || procname == 252)
{
killapp(table[curpos - 1].nomer);
}
if (procname == 250)
{
curpos--;
}
if (procname == 249)
{
curpos++;
}
if (curpos < 1)
{
curpos = prccount;
}
if (curpos > prccount)
{
curpos = 1;
}
}
BOX(1, 1, 80, 25, 40);
AT(1,1);
ATRIB(47);
return 0;
}