Работа С Cmos-памятью

  • Автор темы liza777
  • Дата начала
L

liza777

#1
Задание такое:
Разработать программу, которая бы вела работу с CMOS-памятью. При работе программы используется текстовый режим работы видеоадаптера. Данная программа должна поддерживать следующие режимы работы:

• Считывать и записывать данные из CMOS – памяти

• Подсчитывать контрольную сумму CMOS-памяти и сверять её с хранимой в памяти

• Установка будильника. Данные необходимые для работы будильника задаются с клавиатуры.

• Сброс будильника

• Во время работы программы, в окошке программы, должно отображаться текущее время

Для работы необходимо будет разработать свой собственный пользовательский интерфейс. При разработке элементов интерфейса использовать функции прерывания 10h, для работы в текстовом режиме. В качестве элементов интерфейса должны использоваться следующие элементы:

• Статическое окно (Для вывода информации)

• Окно ввода информации (Ввод – вывод информации)

• Кнопки (Используются для активирования различный действий)

• Курсор (Элемент, местоположение которого можно изменять при помощи кнопок курсора, а также имитировать нажатие кнопки, находящейся под курсором, при помощи кнопки «Enter»)

При необходимости, можно разработать дополнительные элементы управления. Используя различные комбинации элементов управления должен быть, сформирован внешний вид программы. Например: При нажатии кнопки «Подсчет контрольной суммы» в статическом окне «Подсчитанная контрольная сумма» появилось числовое значение.

Задачу решила - в аттаче исходник. Помогите с ошибками)

Добавлено: Текст исходника ,если кому загружать лень. Жирным выделены ошибки

#define RUS

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include <string.h>
#include "liza.h"

#ifdef __cplusplus
#define __CPPARGS ...
#else
#define __CPPARGS
#endif

#define stil1_CMOS 0x1F //оболочка
// строки
#define stil2_CMOS 0x07
#define stil3_CMOS 0x03
#define stil4_CMOS 0x40
#define stil5_CMOS 0x35
#define stil1_al 0x07
#define stil3_al 0x17
#define stil4_al 0x1F
#define stil5_al 0x00
#define stil7_al 0x00 //фон окна
//маяк
#define stil8_al 0x04
#define stil9_al 0x07
//будильник
#define stil10_al 0x70
#define stil11_al 0x20
#define stil12_al 0x70
#define stil13_al 0x0F
#define stil14_al 0x1F
#define chL 63
#define chH 11
#define mL 5
#define mH 5
#define budL 30
#define budH 5
#define vbL 14
#define vbH 3
#define kol_bud 30

#define gxy(x,y) {_AH = 2; _BH = cStr; _DH = y-1; _DL = x-1; geninterrupt(0x10);}
#define wrs(x,y,sym,kol) {gxy(x,y); _AH = 9; _AL = sym; _CX = kol; geninterrupt(0x10);}
#define wrs1(x,y,sym) {gxy(x,y); _AH = 9; _AL = sym; _CX = 1; geninterrupt(0x10);}
#define chst(kol, st) {for (i = 1; i <= kol; i++) {*p = st;p += 2;}}
#define hide_c gxy(1,26)
#define inv {*k ^= 0x7F;}

void setpage(int);
void wrstr(int, int, char [], char);
int csumm(void);
void zapolnenie(int, char);
int mozhno(int);
void setline(int);
void shablon(void);
void int_on(void);
void int_off(void);
void interrupt obrab(__CPPARGS);
void interrupt (*old_0x1C)(__CPPARGS);
void pereshivka(int, char);
void symbols(void);
void tsifra(int, int, int, char);
void mayak(int, int, int);
void zapolnenie_cl(int,int);
void zapolnenie_mayak(int, int, int);
void budil(int);
void vkl_b(void);
void vikl_b(void);
void vr_bud(int);
void set_al_time(void);
int zone(int X, int Y);
void koords(void);
void copy(int,int,int,int,int);

int cStr;
int cLn;
int mozhno_mas[]= {0,1,2,3,4,5,6,7,8,9,50,66};
char chasi[5];
char CMOS[64];
int bud_vkl = 0;
int chX = 9, chY = 2; //л.в. угол часов
int m1X = 2, m1Y = 5; //л.в. угол маяка1
int m2X = 74, m2Y = 5; //л.в. угол маяка1
int budX = 26, budY = 18; //л.в. угол кнопки буд-ка
int vbX = 34, vbY = 14; //л.в. угол часов буд-ка
int kX = 1, kY = 1; //курсор
int sk = 0;
char far *k = (char far *) 0xB8000000;

void main(void)
{
int cCStr = 0;
char ch, ch2;
char far *p;
int i, y, x1, y1, x2, y2, j, m = 0;

_AH = 0;
_AL = 3;
geninterrupt(0x10);

symbols();
shablon();

for (i = 0; i <= 63; i++)
{
outp(0x70,i);
CMOS = inp(0x71);
}

zapolnenie_cl(0,0);

zapolnenie_mayak(m1X, m1Y, 0);
mayak(m1X+1,m1Y+1,0);
zapolnenie_mayak(m2X, m2Y, 0);
mayak(m2X+1,m2Y+1,0);

budil(0);
vikl_b();
vr_bud(0);

k += 4096 * 3 + 1;
inv;

setpage(0);
int_on();

for (;:maybe:
{
ch = getch();

switch (ch)
{
case 27 :
int_off();
nosound();
exit(0);
break;

case 9 :
if (cStr == 3)
setpage(cCStr);
else
setpage(3);
break;

case 32 :
if (cStr == 3)
{
if (sk == 6)
{
inv;
vkl_b();
inv;
}
else
if (sk == 7)
{
inv;
vikl_b();
inv;
}
}
break;

case 13 :
if (cStr != 3)
{
if (mozhno(cLn))
{
int_off();
p = (char far *) 0xB8000000;
p += 4096 * (cLn / 22) + 160 * (cLn % 22 + 1) + 2 * 64;
for (i = 1; i <= 2; i++)
{
*p = 0; p++; *p = 0x0F; p++;
}
p += 2;
for (i = 1; i <= 3; i++)
{
*p = 0; p++; *p = 0x0F; p++;
}
p += 2;
for (i = 1; i <= 8; i++)
{
*p = 0; p++; *p = 0x0F; p++;
}
p -= 30;
y = cLn % 22 + 1;
_AH = 2; _BH = cStr; _DH = y; _DL = 64;
geninterrupt(0x10);

y = 1;
while (y)
{
ch = getch();

switch (ch)
{
case 27:
zapolnenie(cLn,stil5_CMOS);
hide_c;
int_on();
y = 0;
break;

case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
case 'A': case 'B': case 'C': case 'D': case 'E':
case 'F': case 'a': case 'b': case 'c': case 'd':
case 'e': case 'f':
if ((ch >= 'a') && (ch <= 'f'))
ch -= 0x20;
if (y == 1)
{
_AH = 10; _AL = ch; _BH = cStr; _CX = 1;
geninterrupt(0x10);
y++;
_AH = 2; _BH = cStr; _DL = 65;
geninterrupt(0x10);
}
else
{
_AH = 10; _AL = ch; _BH = cStr; _CX = 1;
geninterrupt(0x10);

ch2 = *p;
if (ch2 > '9')
ch2 -= 0x37;
else
ch2 -= 0x30;

ch2 = ch2 << 4;

if (ch > '9')
ch -= 0x37;
else
ch -= 0x30;
ch += ch2;

outp(0x70,cLn);
outp(0x71,ch);

y = 0;
zapolnenie(cLn,stil5_CMOS);
hide_c;
int_on();
}
break;
}
}
}
}
else
{
if ((sk == 8) || (sk == 9) || (sk == 10))
{
_BL = stil13_al;
if (sk == 8)
y = 3;
else
if (sk == 9)
y = 6;
else
y = 9;
wrs(vbX + y,vbY + 1,' ',2);

y = 1;
while (y)
{
ch = getch();

switch (ch)
{
case 27:
set_al_time();
hide_c;
y = 0;
break;

case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
if (y == 1)
{
ch2 = ch;
_AH = 10; _AL = ch; _BH = cStr; _CX = 1;
geninterrupt(0x10);
y++;
_AH = 2; _BH = cStr; _DL++;
geninterrupt(0x10);
}
else
{
_AH = 10; _AL = ch; _BH = cStr; _CX = 1;
geninterrupt(0x10);

ch2 -= 0x30;
ch2 <<= 4;

ch2 += ch - 0x30;

if (sk == 8)
ch = 5;
else
if (sk == 9)
ch = 3;
else
ch = 1;

outp(0x70,ch);
outp(0x71,ch2);

y = 0;
set_al_time();
hide_c;
}
break;
}
}
}
}
break;

case 0 :
switch (ch = getch())
{
case 116: case 115: case -115: case -111:
if ((cStr == 3) && (sk))
{
j = 0;
switch (sk)
{
case 1:
x1 = chX; x2 = chX + chL - 1;
y1 = chY; y2 = chY + chH - 1;
break;
case 2: case 6: case 7:
x1 = budX; x2 = budX + budL - 1;
y1 = budY; y2 = budY + budH - 1;
break;
case 3: case 8: case 9: case 10:
x1 = vbX; x2 = vbX + vbL - 1;
y1 = vbY; y2 = vbY + vbH - 1;
break;
case 4:
x1 = m1X; x2 = m1X + mL - 1;
y1 = m1Y; y2 = m1Y + mH - 1;
break;
case 5:
x1 = m2X; x2 = m2X + mL - 1;
y1 = m2Y; y2 = m2Y + mH - 1;
break;
case 11:
if ((kX - m1X > 0) && (kX - m1X < 4))
{
x1 = m1X; x2 = m1X + mL - 1;
y1 = m1Y; y2 = m1Y + mH - 1;
m = 1;
}
else
{
x1 = m2X; x2 = m2X + mL - 1;
y1 = m2Y; y2 = m2Y + mH - 1;
m = 2;
}
break;
}
y = 0;
switch (ch)
{
case 116:
if (x2 < 80)
{
for (j = y1; j <= y2; j++)
y += zone(x2 + 1, j);

j = 0;

if (!y)
{
inv; kX++; k += 2; j = 1;
copy(x1,y1,x2,y2,1);
}
}
break;

case 115:
if (x1 > 1)
{
for (j = y1; j <= y2; j++)
y += zone(x1 - 1, j);

j = 0;

if (!y)
{
inv; kX--; k -= 2; j = 3;
copy(x1,y1,x2,y2,3);
}
}
break;

case -115:
if (y1 > 1)
{
for (j = x1; j <= x2; j++)
y += zone(j, y1 - 1);

j = 0;

if (!y)
{
inv; kY--; k -= 160; j = 4;
copy(x1,y1,x2,y2,4);
}
}
break;

case -111:
if (y2 < 23)
{
for (j = x1; j <= x2; j++)
y += zone(j, y2 + 1);

j = 0;

if (!y)
{
inv; kY++; k += 160; j = 2;
copy(x1,y1,x2,y2,2);
}
}
break;
}
if (j)
{
switch (sk)
{
case 1:
switch (j)
{
case 1:
chX++;
break;

case 2:
chY++;
break;

case 3:
chX--;
break;

case 4:
chY--;
break;
}
break;
case 2: case 6: case 7:
switch (j)
{
case 1:
budX++;
break;

case 2:
budY++;
break;

case 3:
budX--;
break;

case 4:
budY--;
break;
}
break;
case 3: case 8: case 9: case 10:
switch (j)
{
case 1:
vbX++;
break;

case 2:
vbY++;
break;

case 3:
vbX--;
break;

case 4:
vbY--;
break;
}
break;
case 4:
switch (j)
{
case 1:
m1X++;
break;

case 2:
m1Y++;
break;

case 3:
m1X--;
break;

case 4:
m1Y--;
break;
}
break;
case 5:
switch (j)
{
case 1:
m2X++;
break;

case 2:
m2Y++;
break;

case 3:
m2X--;
break;

case 4:
m2Y--;
break;
}
break;
case 11:
if (m == 1)
{
switch (j)
{
case 1:
m1X++;
break;

case 2:
m1Y++;
break;

case 3:
m1X--;
break;

case 4:
m1Y--;
break;
}
}
else
{
switch (j)
{
case 1:
m2X++;
break;

case 2:
m2Y++;
break;

case 3:
m2X--;
break;

case 4:
m2Y--;
break;
}
}
m = 0;
break;
}
}
}
break;

case 73 :
if (cStr == 1)
{
cCStr = 0;
setpage(0);
setline(0);
}
if (cStr == 2)
{
cCStr = 1;
setpage(1);
setline(22);
}
break;

case 81 :
if (cStr == 1)
{
cCStr = 2;
setpage(2);
setline(44);
}
if (cStr == 0)
{
cCStr = 1;
setpage(1);
setline(22);
}
break;

case 72 :
if (cStr != 3)
{
if (cLn > 0)
{
if (cLn % 22 == 0)
{
setpage((cLn - 1) / 22);
cCStr = cStr;
}
setline(cLn - 1);
}
}
else
{
if (kY > 1)
{
kY--;
inv;
koords();
k -= 160;
inv;
}
}
break;

case 80 :
if (cStr != 3)
{
if (cLn < 63)
{
if ((cLn + 1) % 22 == 0)
{
setpage((cLn + 1) / 22);
cCStr = cStr;
}
setline(cLn + 1);
}
}
else
{
if (kY < 23)
{
kY++;
inv;
koords();
k += 160;
inv;
}
}
break;

case 75 :
if (kX > 1)
{
kX--;
inv;
koords();
k -= 2;
inv;
}
break;

case 77 :
if (kX < 80)
{
kX++;
inv;
koords();
k += 2;
inv;
}
break;
}
break;
}
}
}

void setpage(int pgNum)
{
cStr = pgNum;
_AH = 5;
_AL = pgNum;
geninterrupt(0x10);

if (pgNum == 3)
set_al_time();
}

void wrstr(int x, int y, char str[], char stile)
{
char ch = str[0];
int i = 0;

while (ch)
{
_BL = stile;
wrs1(x,y,ch);
i++; x++;
ch = str;
}
_BL = stile;
}

int csumm(void)
{
unsigned int i, s = 0;

for (i = 0x10; i <= 0x2D; i++)
{
outp(0x70,i);
s += inp(0x71);
}

return s;
}

void zapolnenie(int nom, char stile)
{
char ch, ch16[3], ch10[4], ch2[9];
int y, oldcStr = cStr, i;

outp(0x70,nom);
ch = inp(0x71);

cStr = nom / 22;
y = nom % 22 + 2;

ch16[0] = (ch & 0xF0) >> 4;
ch16[0] += 0x30;
if (ch16[0] > '9')
ch16[0] += 7;

ch16[1] = ch & 0x0F;
ch16[1] += 0x30;
if (ch16[1] > '9')
ch16[1] += 7;

ch16[2] = 0;

_AL = ch; _AH = 0; i = _AX;
ch10[0] = i / 100;
ch10[0] += 0x30;
ch10[1] = (i % 100) / 10;
ch10[1] += 0x30;
ch10[2] = i % 10;
ch10[2] += 0x30;
ch10[3] = 0;

if (ch10[0] == '0')
ch10[0] = ' ';

if ((ch10[0] == ' ') && (ch10[1] == '0'))
ch10[1] = ' ';

ch2[0] = (ch & 0x80) >> 7;
ch2[1] = (ch & 0x40) >> 6;
ch2[2] = (ch & 0x20) >> 5;
ch2[3] = (ch & 0x10) >> 4;
ch2[4] = (ch & 0x08) >> 3;
ch2[5] = (ch & 0x04) >> 2;
ch2[6] = (ch & 0x02) >> 1;
ch2[7] = ch & 0x01;
for (i = 0; i <= 7; i++)
ch2 += 0x30;
ch2[8] = 0;

wrstr(65,y,ch16,stile);
wrstr(68,y,ch10,stile);
wrstr(72,y,ch2,stile);

cStr = oldcStr;
}

int mozhno(int nom)
{
int i = 0;

while ((mozhno_mas < 66) && (mozhno_mas != nom))
i++;

if (mozhno_mas == nom)
return 1;

return 0;
}

void setline(int nom)
{
char far *p;
int i;
char stile;

p = (char far *) 0xB8000000;
p += 4096 * (cLn / 22) + 160 * (cLn % 22 + 1) + 3;
chst(2,stil3_CMOS); p += 2;
chst(59,stil3_CMOS); p += 2;
chst(2,stil3_CMOS); p += 2;
chst(3,stil3_CMOS); p += 2;
chst(8,stil3_CMOS); p += 2;

cLn = nom;

if (mozhno(nom))
stile = stil5_CMOS;
else
stile = stil4_CMOS;

p = (char far *) 0xB8000000;
p += 4096 * (cLn / 22) + 160 * (cLn % 22 + 1) + 3;
chst(2,stile); p += 2;
chst(59,stile); p += 2;
chst(2,stile); p += 2;
chst(3,stile); p += 2;
chst(8,stile); p += 2;
}

void shablon(void)
{
char ch;
int i,j, oldcStr = cStr;;

for (cStr = 0; cStr <= 2; cStr++)
{
_BL = stil1_CMOS;

wrs1(1,1,'Й'); wrs(2,1,'Н',2); wrs1(4,1,'Л'); wrs(5,1,'Н',33);
wrstr(38,1," CMOS ",stil1_CMOS); wrs(44,1,'Н',20); wrs1(64,1,'Л');
wrs(65,1,'Н',2); wrs1(67,1,'Л'); wrs(68,1,'Н',3); wrs1(71,1,'Л');
wrs(72,1,'Н',8); wrs1(80,1,'»');
for (i = 2; i <= 23; i++)
{
wrs1(1,i,'є'); wrs1(4,i,'є'); wrs1(64,i,'є');
wrs1(67,i,'є'); wrs1(71,i,'є'); wrs1(80,i,'є');
}
wrs1(1,24,'И'); wrs(2,24,'Н',2); wrs1(4,24,'К'); wrs(5,24,'Н',22);
wrstr(27,24,SUM,stil1_CMOS);

_AX = csumm();
ch = (_AH & 0xF0) >> 4; ch += 0x30;
if (ch > '9')
ch += 7;
_BL = stil1_CMOS;
wrs1(50,24,ch);

_AX = csumm();
ch = _AH & 0x0F ; ch += 0x30;
if (ch > '9')
ch += 7;
_BL = stil1_CMOS;
wrs1(51,24,ch);

_AX = csumm();
ch = (_AL & 0xF0) >> 4; ch += 0x30;
if (ch > '9')
ch += 7;
_BL = stil1_CMOS;
wrs1(52,24,ch);

_AX = csumm();
ch = _AL & 0x0F ; ch += 0x30;
if (ch > '9')
ch += 7;
_BL = stil1_CMOS;
wrs1(53,24,ch);
_BL = stil1_CMOS;

wrs1(54,24,' '); wrs(55,24,'Н',9); wrs1(64,24,'К'); wrs(65,24,'Н',2);
wrs1(67,24,'К'); wrs(68,24,'Н',3); wrs1(71,24,'К'); wrs(72,24,'Н',8);
wrs1(80,24,'ј');

wrstr(1,25,NIZ,stil2_CMOS);
}

cStr = 0;
for (i = 0; i <= 63; i++)
{
j = i % 22 + 2;
ch = i / 16 + 0x30;
_BL = stil3_CMOS;
wrs1(2,j,ch);

ch = i % 16 + 0x30;
if (ch > '9')
ch += 7;
_BL = stil3_CMOS;
wrs1(3,j,ch);

if ((i + 1) % 22 == 0)
cStr++;
}

cStr = 0;
wrstr(5,2,L00,stil3_CMOS);
wrstr(5,3,L01,stil3_CMOS);
wrstr(5,4,L02,stil3_CMOS);
wrstr(5,5,L03,stil3_CMOS);
wrstr(5,6,L04,stil3_CMOS);
wrstr(5,7,L05,stil3_CMOS);
wrstr(5,8,L06,stil3_CMOS);
wrstr(5,9,L07,stil3_CMOS);
wrstr(5,10,L08,stil3_CMOS);
wrstr(5,11,L09,stil3_CMOS);
wrstr(5,12,L0A,stil3_CMOS);
wrstr(5,13,L0B,stil3_CMOS);
wrstr(5,14,L0C,stil3_CMOS);
wrstr(5,15,L0D,stil3_CMOS);
wrstr(5,16,L0E,stil3_CMOS);
wrstr(5,17,L0F,stil3_CMOS);
wrstr(5,18,L10,stil3_CMOS);
wrstr(5,19,L11,stil3_CMOS);
wrstr(5,20,L12,stil3_CMOS);
wrstr(5,21,L13,stil3_CMOS);
wrstr(5,22,L14,stil3_CMOS);
wrstr(5,23,L15,stil3_CMOS);


cStr = 1;
wrstr(5,2,L16,stil3_CMOS);
wrstr(5,3,L17,stil3_CMOS);
wrstr(5,4,L18,stil3_CMOS);
wrstr(5,5,L19,stil3_CMOS);
wrstr(5,6,L1A,stil3_CMOS);
wrstr(5,7,L1B,stil3_CMOS);
wrstr(5,8,L1C,stil3_CMOS);
wrstr(5,9,L1D,stil3_CMOS);
wrstr(5,10,L1E,stil3_CMOS);
wrstr(5,11,L1F,stil3_CMOS);
wrstr(5,12,L20,stil3_CMOS);
wrstr(5,13,L21,stil3_CMOS);
wrstr(5,14,L22,stil3_CMOS);
wrstr(5,15,L23,stil3_CMOS);
wrstr(5,16,L24,stil3_CMOS);
wrstr(5,17,L25,stil3_CMOS);
wrstr(5,18,L26,stil3_CMOS);
wrstr(5,19,L27,stil3_CMOS);
wrstr(5,20,L28,stil3_CMOS);
wrstr(5,21,L29,stil3_CMOS);
wrstr(5,22,L2A,stil3_CMOS);
wrstr(5,23,L2B,stil3_CMOS);

cStr = 2;
wrstr(5,2,L2C,stil3_CMOS);
wrstr(5,3,L2D,stil3_CMOS);
wrstr(5,4,L2E,stil3_CMOS);
wrstr(5,5,L2F,stil3_CMOS);
wrstr(5,6,L30,stil3_CMOS);
wrstr(5,7,L31,stil3_CMOS);
wrstr(5,8,L32,stil3_CMOS);
wrstr(5,9,L33,stil3_CMOS);
wrstr(5,10,L34,stil3_CMOS);
wrstr(5,11,L35,stil3_CMOS);
wrstr(5,12,L36,stil3_CMOS);
wrstr(5,13,L37,stil3_CMOS);
wrstr(5,14,L38,stil3_CMOS);
wrstr(5,15,L39,stil3_CMOS);
wrstr(5,16,L3A,stil3_CMOS);
wrstr(5,17,L3B,stil3_CMOS);
wrstr(5,18,L3C,stil3_CMOS);
wrstr(5,19,L3D,stil3_CMOS);
wrstr(5,20,L3E,stil3_CMOS);
wrstr(5,21,L3F,stil3_CMOS);


for (i = 0; i < 64; i++)
zapolnenie(i,stil3_CMOS);

setline(0);

for (cStr = 0; cStr <= 2; cStr++)
hide_c;

cStr = oldcStr;
}

void int_on(void)
{
char ch;

old_0x1C = _dos_getvect(0x1C);
_dos_setvect(0x1C,obrab);

outp(0x70,0x0B);
ch = inp(0x71);
outp(0x71,ch | 0x10);
}

void int_off(void)
{
char ch;

_dos_setvect(0x1C,old_0x1C);

outp(0x70,0x0B);
ch = inp(0x71);
outp(0x71,ch & 0x0F);
}

void interrupt obrab(__CPPARGS)
{
char ch, ch2, i;
int j;
char far *p;
unsigned static long int a = kol_bud + 1;

outp(0x70,0x0C);
ch = inp(0x71);
if ((ch & 0x20) && (bud_vkl))
a = 0;

if ((a <= kol_bud) && (bud_vkl))
{
mayak(m1X+1,m1Y+1,0);
mayak(m2X+1,m2Y+1,0);
}

if (ch & 0x10)
{
a++;

if ((a <= kol_bud) && (bud_vkl))
{
mayak(m1X+1,m1Y+1,1);
mayak(m2X+1,m2Y+1,1);

if (a % 2)
sound(370);
else
nosound();
}


outp(0x70,0x00);
ch = inp(0x71);
tsifra(ch & 0x0F,chX + 51,chY + 1,stil1_al);

if (chasi[4] != ((ch & 0xF0) >> 4))
{
chasi[4] = (ch & 0xF0) >> 4;
tsifra(chasi[4],chX + 42,chY + 1,stil1_al);

outp(0x70,0x02);
ch = inp(0x71);
if (chasi[3] != (ch & 0x0F))
{
chasi[3] = ch & 0x0F;
tsifra(chasi[3],chX + 31,chY + 1,stil1_al);

if (chasi[2] != ((ch & 0xF0) >> 4))
{
chasi[2] = (ch & 0xF0) >> 4;
tsifra(chasi[2],chX + 22,chY + 1,stil1_al);

outp(0x70,0x04);
ch = inp(0x71);

if (chasi[1] != (ch & 0x0F))
{
chasi[1] = ch & 0x0F;
tsifra(chasi[1],chX + 11,chY + 1,stil1_al);

if (chasi[0] != ((ch & 0xF0) >> 4))
{
chasi[0] = (ch & 0xF0) >> 4;
tsifra(chasi[0],chX + 2,chY + 1,stil1_al);
}
}
}
}
}

for (i = 0; i <= 63; i++)
{
outp(0x70,i);
ch = inp(0x71);
if (ch != CMOS)
{
CMOS = ch;
p = (char far *) 0xB8000000;
p += 4096 * (i / 22) + 160 * (i % 22 + 1) + 2 * 64;

ch2 = (ch & 0xF0) >> 4;
ch2 += 0x30;
if (ch2 > '9')
ch2 += 7;
*p = ch2;

p += 2;
ch2 = ch & 0x0F;
ch2 += 0x30;
if (ch2 > '9')
ch2 += 7;
*p = ch2;

p += 4;
_AL = ch; _AH = 0; j = _AX;
ch2 = j / 100; ch2 += 0x30;
if (ch2 != '0')
*p = ch2;
else
*p = ' ';
p += 2;

ch2 = (j % 100) / 10; ch2 += 0x30;
if ((ch2 != '0') || (*(p-2) != ' '))
*p = ch2;
else
*p = ' ';
p += 2;

ch2 = j % 10; ch2 += 0x30;
*p = ch2;
p += 4;

ch2 = (ch & 0x80) >> 7; ch2 += 0x30; *p = ch2; p+=2;
ch2 = (ch & 0x40) >> 6; ch2 += 0x30; *p = ch2; p+=2;
ch2 = (ch & 0x20) >> 5; ch2 += 0x30; *p = ch2; p+=2;
ch2 = (ch & 0x10) >> 4; ch2 += 0x30; *p = ch2; p+=2;
ch2 = (ch & 0x08) >> 3; ch2 += 0x30; *p = ch2; p+=2;
ch2 = (ch & 0x04) >> 2; ch2 += 0x30; *p = ch2; p+=2;
ch2 = (ch & 0x02) >> 1; ch2 += 0x30; *p = ch2; p+=2;
ch2 = ch & 0x01; ch2 += 0x30; *p = ch2; p+=2;
}
}
}
}

void pereshivka(int nom, char *tabl)
{
asm {
push ax
push bx
push cx
push dx
push es
push bp
}

_ES = _DS;
_CX = 1;
_DX = nom;
_BL = 0;
_BH = 16;
_BP = (int) tabl;
_AX = 0x1100;

geninterrupt(0x10);

asm {
pop bp
pop es
pop dx
pop cx
pop bx
pop ax
}
}

void symbols(void)
{
char sym243[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0x18,0x3C,0x7E,0xFF};
char sym244[16] = {0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF
};
char sym245[16] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
};
char sym246[16] = {0,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0};
char sym247[16] = {0xFF,0x7E,0x3C,0x18,0,0,0,0,0,0,0,0,0,0,0,0};
char sym248[16] = {0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F
};
char sym249[16] = {0,0,0,0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0,0,0,0,0};
char sym250[16] = {0x7F,0x7F,0x7F,0x7F,0,0,0,0,0,0,0,0,0,0,0,0};
char sym251[16] = {0x7f,0x7F,0x7F,0x7F,0,0,0,0,0,0,0,0x7f,0x7F,0x7F,0x7F,0x7F};
char sym252[16] = {0,0,0,0,0,0,0,0,0,0,0,0x7F,0x7F,0x7F,0x7F,0x7F};

pereshivka(243,sym243);
pereshivka(244,sym244);
pereshivka(245,sym245);
pereshivka(246,sym246);
pereshivka(247,sym247);
pereshivka(248,sym248);
pereshivka(249,sym249);
pereshivka(250,sym250);
pereshivka(251,sym251);
pereshivka(252,sym252);
}

void tsifra(int t, int x, int y, char stile)
{
char far *p;
char ch;
int i;

inv;

p = (char far *) 0xB8000000;
p += 4096 * 3 + 160 * (y - 1) + 2 * (x - 1);

switch (t)
{
case 4: case 5: case 6: case 8: case 9: case 0:
ch = 252;
break;

case 2: case 3: case 7:
ch = 249;
break;

default:
ch = ' ';
break;
}

*p = ch; p++; *p = stile; p++;

switch (t)
{
case 2: case 3: case 5: case 6: case 7: case 8: case 9: case 0:
ch = 249;
break;

default:
ch = ' ';
break;
}

for (i = 1; i <= 6; i++)
{
*p = ch; p++;
*p = stile; p++;
}

switch (t)
{
case 1: case 2: case 3: case 4: case 7: case 8: case 9: case 0:
ch = 252;
break;

case 5: case 6:
ch = 249;
break;

default:
ch = ' ';
break;
}

*p = ch; p++; *p = stile; p += 145;

switch (t)
{
case 1: case 2: case 3: case 7:
for (i = 1; i <= 3; i++)
{
*p = ' '; p++; *p = stile; p += 13;
*p = 248; p++; *p = stile; p += 145;
}
break;

case 5: case 6:
for (i = 1; i <= 3; i++)
{
*p = 248; p++; *p = stile; p += 13;
*p = ' '; p++; *p = stile; p += 145;
}
break;

default:
for (i = 1; i <= 3; i++)
{
*p = 248; p++; *p = stile; p += 13;
*p = 248; p++; *p = stile; p += 145;
}
break;
}

switch (t)
{
case 2:
ch = 252;
break;

case 3:
ch = 249;
break;

case 4: case 5: case 9:
ch = 250;
break;

case 6: case 8: case 0:
ch = 251;
break;

default:
ch = ' ';
break;
}

*p = ch; p++; *p = stile; p++;

switch (t)
{
case 2: case 3: case 4: case 5: case 6: case 8: case 9:
ch = 249;
break;

default:
ch = ' ';
break;
}

for (i = 1; i <= 6; i++)
{
*p = ch; p++;
*p = stile; p++;
}

switch (t)
{
case 1: case 3: case 4: case 7: case 8: case 9: case 0:
ch = 251;
break;

case 2:
ch = 250;
break;

case 5: case 6:
ch = 252;
break;

default:
ch = ' ';
break;
}

*p = ch; p++; *p = stile; p += 145;

switch (t)
{
case 1: case 3: case 4: case 5: case 7: case 9:
for (i = 1; i <= 3; i++)
{
*p = ' '; p++; *p = stile; p += 13;
*p = 248; p++; *p = stile; p += 145;
}
break;

case 2:
for (i = 1; i <= 3; i++)
{
*p = 248; p++; *p = stile; p += 13;
*p = ' '; p++; *p = stile; p += 145;
}
break;

default:
for (i = 1; i <= 3; i++)
{
*p = 248; p++; *p = stile; p += 13;
*p = 248; p++; *p = stile; p += 145;
}
break;
}

switch (t)
{
case 2: case 6: case 8: case 0:
ch = 250;
break;

case 3: case 5: case 9:
ch = 249;
break;

default:
ch = ' ';
break;
}

*p = ch; p++; *p = stile; p++;

switch (t)
{
case 2: case 3: case 5: case 6: case 8: case 9: case 0:
ch = 249;
break;

default:
ch = ' ';
break;
}

for (i = 1; i <= 6; i++)
{
*p = ch; p++;
*p = stile; p++;
}

switch (t)
{
case 1: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 0:
ch = 250;
break;

default:
ch = 249;
break;
}

*p = ch; p++; *p = stile;

inv;
}

void mayak(int x, int y, int vkl)
{
char far *p = (char far *) 0xB8000000;
char st, stile = stil8_al;

inv;

if (!vkl)
stile = stil9_al;

p += 4096 * 3 + 160 * (y - 1) + 2 * (x - 1);

*p = ' '; p++; *p = stile; p++;
*p = 243; p++; *p = stile; p++;
*p = ' '; p++; *p = stile; p += 155;

st = (stile & 0x0F) << 4;
st += (stile & 0xF0) >> 4;

*p = 244; p++; *p = st; p++;

st &= 0xF0; st += (st >> 4);

*p = 245; p++; *p = st; p++;
*p = 246; p++; *p = stile; p += 155;

*p = ' '; p++; *p = stile; p++;
*p = 247; p++; *p = stile; p++;
*p = ' '; p++; *p = stile; p += 155;

inv;
}

void zapolnenie_cl(int akt, int ramka)
{
char far *p = (char far *) 0xB8000000;
int i, x, y, oldcStr = cStr;
char stile = stil4_al, ch;

cStr = 3;

if (!akt)
stile = stil3_al;

if (!ramka)
{
p += 4096 * 3; // clrscr
for (i = 1; i <= 2000; i++)
{
*p = 0; p++; *p = stil7_al; p++;
}
}

_BL = stile;
wrs1(chX, chY,'Й');
x = chX + 1; wrs(x,chY,'Н',18);
x += 18; wrstr(x,chY,CHN,stile);
x += 24; wrs(x,chY,'Н',19);
x += 19; wrs1(x,chY,'»');

x = chX; y = chY + 1;

for (i = 1; i <= 9; i++)
{
_BL = stile; wrs1(x,y,'є'); x++;
if (!ramka)
{
_BL = stil5_al;
wrs(x,y,' ',61);
}
x += 61;
_BL = stile; wrs1(x,y,'є'); x = chX; y++;
}

wrs1(x,y,'И'); x++; wrs(x,y,'Н',61); x += 61; wrs1(x,y,'ј');

if (!ramka)
{
outp(0x70,0x04);
ch = inp(0x71);

chasi[0] = (ch & 0xF0) >> 4;
chasi[1] = ch & 0x0F;

outp(0x70,0x02);
ch = inp(0x71);

chasi[2] = (ch & 0xF0) >> 4;
chasi[3] = ch & 0x0F;

outp(0x70,0x00);
ch = inp(0x71);

chasi[4] = (ch & 0xF0) >> 4;

tsifra(chasi[0],chX + 2,chY + 1,stil1_al);
tsifra(chasi[1],chX + 11,chY + 1,stil1_al);
tsifra(chasi[2],chX + 22,chY + 1,stil1_al);
tsifra(chasi[3],chX + 31,chY + 1,stil1_al);
tsifra(chasi[4],chX + 42,chY + 1,stil1_al);
tsifra(ch & 0x0F,chX + 51,chY + 1,stil1_al);

_BL = stil1_al;

wrs1(chX + 20, chY + 4, 249);
wrs1(chX + 20, chY + 6, 249);

wrs1(chX + 40, chY + 4, 249);
wrs1(chX + 40, chY + 6, 249);
}

wrstr(1,24,NI1,stil14_al);
wrstr(1,25,NI2,stil14_al);

hide_c;
cStr = oldcStr;
}

void zapolnenie_mayak(int X, int Y, int akt)
{
char stile = stil4_al;
int x, i, oldcStr = cStr;

cStr = 3;

if (!akt)
stile = stil3_al;

_BL = stile;
wrs1(X, Y,'Й');
x = X + 1; wrs(x,Y,'Н',3);
x += 3; wrs1(x,Y,'»');

for (i = 1; i <= 3; i++)
{
x = X; wrs1(x,Y + i,'є'); x += 4; wrs1(x,Y + i,'є');
}

wrs1(X, Y + 4,'И');
x = X + 1; wrs(x,Y + 4,'Н',3);
x += 3; wrs1(x,Y + 4,'ј');

hide_c;
cStr = oldcStr;
}

void budil(int akt)
{
char stile = stil4_al;
int x, y, i, oldcStr = cStr;

cStr = 3;
if (!akt)
stile = stil3_al;

_BL = stile;
wrs1(budX, budY,'Й');
x = budX + 1; wrs(x,budY,'Н',9);
x += 9; wrstr(x,budY,BUD,stile);
x += 11; wrs(x,budY,'Н',8);
x += 8; wrs1(x,budY,'»');

y = budY + 1; x = budX;
wrs1(x, y,'є'); x++;
_BL = stil10_al; wrs(x,y,' ',28); x += 28;
_BL = stile; wrs1(x, y,'є');

y++; x = budX;
for (i = 1; i <= 2; i++)
{
wrs1(x, y,'є'); x += 29; wrs1(x, y,'є');
x = budX; y++;
}

wrs1(x,y,'И');
x++; wrs(x,y,'Н',28);
x += 28; wrs1(x,y,'ј');

hide_c;
cStr = oldcStr;
}

void vkl_b(void)
{
int x = budX + 1, y = budY + 2, oldcStr = cStr;
char ch;

cStr = 3;

outp(0x70,0x0B);
ch = inp(0x71);
ch |= 0x20;
outp(0x71,ch);

_BL = stil10_al;
wrs(x,y,' ',2); x += 2;
wrstr(x,y,VKL,stil11_al); x += 10;
_BL = stil10_al;

wrs(x,y,' ',3); x += 3;
wrstr(x,y,VIK,stil11_al); x += 11;
_BL = stil10_al;
wrs1(x,y,220); x++;
wrs1(x,y,' '); x = budX + 1; y++;
wrs(x,y,' ',16); x += 16;
wrs(x,y,223,11); x += 11;
wrs1(x,y,' ');

hide_c;
bud_vkl = 1;
cStr = oldcStr;
}

void vikl_b(void)
{
int x = budX + 1, y = budY + 2, oldcStr = cStr;
char ch;

outp(0x70,0x0B);
ch = inp(0x71);
ch &= 0xDF;
outp(0x71,ch);

cStr = 3;
_BL = stil10_al;
wrs1(x,y,' '); x++;
wrstr(x,y,VKL,stil11_al); x += 10;
_BL = stil10_al;
wrs1(x,y,220); x++;
wrs(x,y,' ',4); x += 4;
wrstr(x,y,VIK,stil11_al); x += 11;
_BL = stil10_al;
wrs1(x,y,' ');

x = budX + 1; y++;
wrs(x,y,' ',2); x += 2;
wrs(x,y,223,10); x += 10;
wrs(x,y,' ',16);

hide_c;
bud_vkl = 0;
cStr = oldcStr;

mayak(m1X+1,m1Y+1,0);
mayak(m2X+1,m2Y+1,0);

nosound();
}

void vr_bud(int akt)
{
int oldcStr = cStr, x = vbX, y = vbY;
char stile = stil4_al;

cStr = 3;
if (!akt)
stile = stil3_al;

_BL = stile;
wrs1(x,y,'Й'); x++;
wrs1(x,y,'Н'); x++;
wrstr(x,y,BUD,stile); x += 11;
wrs1(x,y,'»'); x = vbX; y++;

wrs1(x,y,'є'); x++;
_BL = stil12_al;
wrs(x,y,' ',2); x += 4;
wrs1(x,y,':'); x += 3;
wrs1(x,y,':'); x += 3;
wrs(x,y,' ',2); x += 2;
_BL = stile;
wrs1(x,y,'є'); x = vbX; y++;
wrs1(x,y,'И'); x++;
wrs(x,y,'Н',12); x += 12;
wrs1(x,y,'ј');

hide_c;
cStr = oldcStr;
}

void set_al_time(void)
{
char ch, ch2;

inv;

_BL = stil13_al;

outp(0x70,0x05);
ch = inp(0x71);

ch2 = ((ch & 0xF0) >> 4) + 0x30;
wrs1(vbX + 3, vbY + 1, ch2);
wrs1(vbX + 4, vbY + 1, (ch & 0x0F) + 0x30);

outp(0x70,0x03);
ch = inp(0x71);

ch2 = ((ch & 0xF0) >> 4) + 0x30;
wrs1(vbX + 6, vbY + 1, ch2);
wrs1(vbX + 7, vbY + 1, (ch & 0x0F) + 0x30);

outp(0x70,0x01);
ch = inp(0x71);

ch2 = ((ch & 0xF0) >> 4) + 0x30;
wrs1(vbX + 9, vbY + 1, ch2);
wrs1(vbX + 10, vbY + 1, (ch & 0x0F) + 0x30);

inv;
hide_c;
}

int zone(int X, int Y)
{
if ((X >= budX + 2 + bud_vkl) && (X < budX + 2 + bud_vkl + 10) && (Y == budY + 2))
return 6;
else
if ((X >= budX + 17 - bud_vkl) && (X < budX + 17 - bud_vkl + 11) && (Y == budY + 2))
return 7;
else
if ((X >= vbX + 3) && (X <= vbX + 4) && (Y == vbY + 1))
return 8;
else
if ((X >= vbX + 6) && (X <= vbX + 7) && (Y == vbY + 1))
return 9;
else
if ((X >= vbX + 9) && (X <= vbX + 10) && (Y == vbY + 1))
return 10;
else
if ((X == m1X + 2) && (Y == m1Y + 1))
return 11;
else
if ((X >= m1X + 1) && (X <= m1X + 3) && (Y == m1Y + 2))
return 11;
else
if ((X == m1X + 2) && (Y == m1Y + 3))
return 11;
else
if ((X == m2X + 2) && (Y == m2Y + 1))
return 11;
else
if ((X >= m2X + 1) && (X <= m2X + 3) && (Y == m2Y + 2))
return 11;
else
if ((X == m2X + 2) && (Y == m2Y + 3))
return 11;
else
if ((X >= chX) && (X < chX + chL) && (Y >= chY) && (Y < chY + chH))
return 1;
else
if ((X >= budX) && (X < budX + budL) && (Y >= budY) && (Y < budY + budH))
return 2;
else
if ((X >= vbX) && (X < vbX + vbL) && (Y >= vbY) && (Y < vbY + vbH))
return 3;
else
if ((X >= m1X) && (X < m1X + mL) && (Y >= m1Y) && (Y < m1Y + mH))
return 4;
else
if ((X >= m2X) && (X < m2X + mL) && (Y >= m2Y) && (Y < m2Y + mH))
return 5;

return 0;
}

void koords(void)
{
int z;

z = zone(kX, kY);

if (z == sk)
return ;
else
{
switch (sk)
{
case 1:
zapolnenie_cl(0,1);
break;

case 2:
if ((z != 6) && (z != 7))
budil(0);
break;

case 3:
if ((z != 8) && (z != 9) && (z != 10))
vr_bud(0);
break;

case 4:
if (z != 11)
zapolnenie_mayak(m1X,m1Y,0);
break;

case 5:
if (z != 11)
zapolnenie_mayak(m2X,m2Y,0);
break;
}

switch (z)
{
case 1:
zapolnenie_cl(1,1);
break;

case 2:
if ((sk != 6) && (sk != 7))
budil(1);
break;

case 3:
if ((sk != 8) && (sk != 9) && (sk != 10))
vr_bud(1);
break;

case 4:
if (sk != 11)
zapolnenie_mayak(m1X,m1Y,1);
break;

case 5:
if (sk != 11)
zapolnenie_mayak(m2X,m2Y,1);
break;
}

sk = z;
}
}

void copy(int lx,int ly,int rx,int ry,int napr)
{
char far *p1 = (char far *) 0xB8000000;
char far *p;
char far *p2;
int i, j;

p1 += 4096 * 3 + 160 * (ly - 1) + 2 * (lx - 1);

switch (napr)
{
case 1:
for (i = 0; i <= ry - ly; i++)
{
p = p1 + i * 160 + 2 * (rx - lx + 1) + 1;

for (j = 0; j <= rx - lx; j++)
{
*p = *(p - 2); p--; *p = *(p - 2); p--;
}
*p = stil7_al; p--; *p = ' ';
}
break;

case 4:
for (i = 0; i <= ry - ly; i++)
{
p = p1 + (i - 1) * 160;
p2 = p1 + i * 160;

for (j = 0; j <= rx - lx; j++)
{
*p = *p2; p++; p2++;
*p = *p2; p++; p2++;
}
}
p = p1 + 160 * (ry - ly);
for (j = 0; j <= rx - lx; j++)
{
*p = ' '; p++; *p = stil7_al; p++;
}
break;

case 3:
for (i = 0; i <= ry - ly; i++)
{
p = p1 + i * 160 - 2;

for (j = 0; j <= rx - lx; j++)
{
*p = *(p + 2); p++; *p = *(p + 2); p++;
}
*p = ' '; p++; *p = stil7_al;
}
break;

case 2:
for (i = ry - ly; i >= 0; i--)
{
p = p1 + (i + 1) * 160;
p2 = p1 + i * 160;

for (j = 0; j <= rx - lx; j++)
{
*p = *p2; p++; p2++;
*p = *p2; p++; p2++;
}
}
p = p1;
for (j = 0; j <= rx - lx; j++)
{
*p = ' '; p++; *p = stil7_al; p++;
}
break;
}
inv;
}
 

Вложения