Управление видеопамятью Турбо Си - C (СИ)
Формулировка задачи:
Что за ошибки такие?
// ****** Control videoadapter ................ * / #include <dos.h> #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <time.h> //***************Constanty */ #define VSEG 0xb800 /* video memory segment address*/ #define byte unsigned char#define word unsigned int #define Esc 27 #define Spase 32 #define Enter 13 #define Up 0x48 #define Down 0x50 #define Left 0x4b #define Right 0x4d #define Home 0x47 int xk,yk; //*****Reading a character from the video memory*/ byte GetSym(x1,y1) int x1,y1; { return(peekb(VSEG,y1*160+x1*2)); } //****read from the video memory*/ byte GetAtr(x1,y1) int x1,y1; { return(peekb(VSEG,y1*160+x1*2+1)); } //****Write a character in the video memory*/ void PutSym(x1,y1,sym) int x1,y1; byte sym; { pokeb(VSEG,y1*160+x1*2,sym); } //****Record attribute to video memory*/ void PutAtr(x1,y1,atr) int x1,y1; byte atr; { pokeb(VSEG,y1*160+x1*2+1,atr); } //***The inversion of a square on the screen*/ void Invert(x1,y1) int x1,y1; { byte b; int i,j; for (j=0;j<5;j++)for (i=0;i<10;i++) { b=GetAtr(x1*10+i,y1*5+j); PutAtr(x1*10+i,y1*5+j,(b^0x7f)); } } //***Replacing the current square in the upper left*/ void Change(x,y) byte x,y; { int i,j; byte ba,bs; if ((x!=0)||(y!=0)) for (j=0;j<5;j++) for (i=0;i<10;i++) { bs=GetSym(x*10+i,y*5+j); ba=GetAtr(x*10+i,y*5+j); PutSym(x*10+i,y*5+j,GetSym(i,j)); PutAtr(x*10+i,y*5+j,GetAtr(i,j)); PutSym(i,j,bs); PutAtr(i,j,ba); } } //***Stirring squares until you press*/ void RandText(void) { Invert(xk,yk); xk=5; yk=1; while(!kbhit()) { Change(xk,yk); xk++; if (xk>7) xk=0; yk++; if (yk>4) yk=0; } Invert(xk,yk); } //******Start the main program*/ main(int argn,char *argc[]) {int i; xk=0; yk=0; if (argn>1){} else / /* If the parameter is not present, the output instructions*/ { textattr(10); clrscr(); cprintf("""""""""""""""""); cprintf(" Laboratorna rabota N5 "); cprintf("""""""""""""""""); cprintf("""""""""""""""""); cprintf(" Control videoadapter. "); cprintf("""""""""""""""""); textattr(15); gotoxy(23,4);cprintf("Demonstration of video memory."); textattr(12); gotoxy(30,6);cprintf("<< MOZAIKA >>"); textattr(14); gotoxy(30,8);cprintf("control keys:"); gotoxy(7,10);cprintf("< Left, Right, Up, Down> — "); cprintf("square dedicated management."); gotoxy(7,11);cprintf("<Spase Bar> — Sharing content "); cprintf("between the selected square"); gotoxy(7,12);cprintf(" and the upper left"); cprintf(" квадратом."); gotoxy(7,13);cprintf("<Enter> — squares mixing"); cprintf(" until you press any key."); gotoxy(7,14);cprintf("<Esc> — Entrance."); textattr(11); gotoxy(28,16);cprintf("ZADACHA GAME :"); gotoxy(14,17);cprintf("Absorb with keys"); cprintf("management initial screen."); textattr(12); gotoxy(27,19);cprintf("Zelaem uspeha!"); textattr(7); gotoxy(1,21);cprintf("Note: When you start with "); cprintf("parameter<<>"); gotoxy(13,22);cprintf("the initial screen for the game"); cprintf("is the current."); } Invert(xk,yk);for(i=0;i==0;) switch(getch()) { //* Processing of keypresses */ case Esc: i++; break; case Enter:RandText();break; case Spase:Invert(xk,yk); Change(xk,yk); Invert(xk,yk); break; case 0: switch (getch()) { case Left:Invert(xk,yk); xkkk; if(xk<0) xk=7; Invert(xk,yk); break; case Right:Invert(xk,yk); xk++; if(xk>7) xk=0; Invert(xk,yk); break; case Up:Invert(xk,yk); ykkk; if(yk<0) yk=4; Invert(xk,yk); break; case Down:Invert(xk,yk); yk++; if(yk>4) yk=0; Invert(xk,yk); break; } } Invert(xk,yk); }
Решение задачи: «Управление видеопамятью Турбо Си»
textual
Листинг программы
byte GetSym( int x1, int y1 ) { ... }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д