The Russian square code * / / * under TC uses a circular chain table constructor, before compiling the egavga.bgi to the source program in the directory where the source program is located. * /
/ ************************
/ * Install a new interrupt vector, the interrupt service program is installed to the interrupt vector table * / void interrupt newTimer (); / * Interrupt service program * / struct Diamond * get_diamond (); / * Random get a square * / Struct Diamond * create_i (); / * Function Used to construct a circular chain table of various types * / struct Diamond * create_t (); / * Return to a pointer in a random state in the list * / Struct Diamond * Create_L (); struct diamond * create_J (); struct diamond * create_Z (); struct diamond * create_N (); struct diamond * create_H (); void delinfo (struct diamond * info); / * free space of the current block occupied * / void addtobuffer (int c ); / * Add a DOWN * / / * void clrKey () to the keyboard buffer; call the DOS interrupt empty keyboard buffer without using this method. * / Void showSubwin (Struct Diamond * next); / * in a small window Show next block * / void showScore (int scoreget); / * Display score * / void startset (); / * Initializing game * / / ******************* *********************************************************** ******************** / Main () {int DRIVER = VGA; int mode = VGAHI; INT i; / * counter * / int J; int key; / * Record keyboard scanning code * / initgraph (& driver, & mode, ""); / * Initialization * / color = 8; backcolor = 7; level = 1; score = 298; count = 0; show_interface (9); / * Display Interface * / setFillStyle (Solid_Fill, 1); bar (0,46 5,640,480); Outtextxy (5,469, "press any key to start ..."); getCh (); setfillstyle (Solid_Fill, 9); BAR (0,465,640,480); showscore (0); / * Display score * / randomize (); Nowinfo = get_diamond (); / * Get a current square * / oldtimer = getVect (0x1c); install (newtimer); for (i = 0; i <= 21; i ) / * Initializing GRID [12] [23] * / {For (j = 1; j <= 10; j ) grid [j] = 0;} for (i = 0; i <= 22; i ) {grid [0] [i] = 1; Grid [11] [i] = 1;} for (i = 0; i <= 11; i ) {grid [i] [22] = 1;} x = noinfo-> start_x; / * Initialization square position * / y = noinfo-> start_y; nextinfo = get_diamond (); / * Get the next block * / showSubwin (NextInfo);
For (;;) {key = bioskey (0); / * Get keyboard scanning code * / if (key) {switch (key) {
Case Down: {Show_Down (); Break;} case up: {show_next (); break;} case left: {show_left (); break;} case right: {show_right (); break;} case restart: {install Oldtimer; setFillStyle (Solid_Fill, 1); BAR (0,465,640,480); Outtextxy (5,469, "Are You Sure To Restart (Y / N) ..."); for (;;) {key = bioskey (0); / * Get keyboard scanning code * / if (key == yes) {startset (); setfillstyle (Solid_Fill, 9); BAR (0,465,640,480); BREAK;} if (key == no) {setfillStyle (Solid_Fill, 9); bar (0, 465, 640, 480); INSTALL (NEWTIMER); Break;}} Break;} / * case f1: {print (); break;} * / case esc: {install (oldtimer); setFillStyle (Solid_Fill, 1); bar (0,465,640,480 ); OutTextxy (5,469, "Are you Sure to EXIT (Y / N) ..."); for (;;) {key = bioskey (0); / * Get Keyboard scanning code * / if (key == yes) {closegraph (); exit (0);} if (key == no) {setFillStyle (Solid_Fill, 9); bar (0,465,640,480); install; botak; }}}}}}} / ************************************************* *************************************************************************** / STRUCT DIAMOND * get_diamond () {struct diamond * now; switch (rDOM (7) 1) {case 1: {now = create_i (); return now;} case 2: {now = create_t (); return now;} Case 3 : {Now = create_l (); return now;} case 4: {now = crete_j (); returniful
} Case 5: {now = create_z (); return now;} case 6: {now = create_n (); return now;} case 7: {now = create_h (); return count;}}} / **** *********************************************************** ************************************ / VOID SHOW_ITERFACE (int fix_mode) {INT i; setbkcolor (9) ; setcolor (color); setfillstyle (SOLID_FILL, backcolor); bar (100,60,300,420); bar (360,60,440,140); rectangle (100,60,300,420); rectangle (96,56,304,424); rectangle (360,60,440,140); rectangle ( 356, 56, 444, 144); SetFillStyle (FLOD_MODE, 14); FLOODFILL (97, 57, Color); Floodfill (397, 57, Color); SetColor (1); Rectangle (96, 56, 304, 424); setColor (color); for (i = 80; i <= 400; i = 20) {line (100, i, 300, i);} for (i = 120; i <= 280; i = 20) {Line (i, 60, i, 420 );} For (i = 80; i <= 120; i = 20) {line (360, i, 440, i);} for (i = 380; i <= 420; i = 20) {line (i , 60, i, 140);} show_intro (360, 180); show_copsign (475, 320, 40, 1); SetFillStyle (Solid_Fill, 1); SetColor (14); Rectangle (420, 405, 534, 417); Floodfill (421, 406, 14); OUTTEXTXY (422, 408, "Hi-Tech Wealth");} / *********** *********************************************************** ************************************* / VOID SHOW_COPSIGN (int Topx, Int Tipy, int size, int color) {Int Halfsize, qtrsize; int XADD, XDEL, YADD1, YADD2; HALFSIZE = 0.5 * size; QTRSIZE = 0.25 * size;
XADD = TopX Size; xdel = Topx-size; YADD1 = TOPY SIZE; YADD2 = TOPY 2 * Size;
SetColor (Color); Line (Topx, Topy, XDEL, YADD1); LINE (XDEL, YADD1, TOPX, YADD2); LINE (Topx, YADD2, XADD, YADD1); LINE (XADD, YADD1, TOPX, TOPY); Rectangle (topx-halfsize, topy halfsize, topx halfsize, yadd1 halfsize); setfillstyle (SOLID_FILL, color); floodfill (topx, topy 1, color); floodfill (xdel 1, yadd1, color); floodfill (topx , yadd2-1, color); floodfill (xadd-1, yadd1, color); rectangle (topx-halfsize, yadd1-qtrsize, topx-0.75 * halfsize, yadd1 qtrsize); floodfill (topx-halfsize 1, yadd1- qtrsize 1, color); rectangle (topx-qtrsize, yadd1-halfsize, topx qtrsize, yadd1-0.25 * halfsize); floodfill (topx-qtrsize 1, yadd1-halfsize 1, color); rectangle (topx 0.75 * halfsize, yadd1-qtrsize, topx halfsize, yadd1 qtrsize); floodfill (topx 0.75 * halfsize 1, yadd1-qtrsize 1, color); rectangle (topx-qtrsize, yadd1 0.25 * halfsize, topx qtrsize , Yadd2-HalfSize; floodfill (Topx-QTRSIZE 1, YADD1 0.25 * Halfsize 1, Color); SetColor (14); line (Topx, TOPY-1, XDEL-1, YADD1); line (xDel-1 , YADD1, TOPX, YADD2 1); Li Ne (Topx, YADD2 1, XADD 1, YADD1); LINE (XADD 1, YADD1, TOPX, TOPY-1); SetFillStyle (Solid_Fill, 14); FloodFill (Topx, YADD1, Color);} / ** *********************************************************** *********************************************** / VOID SHOW_INTRO (int XS, int ys) {char STEMP [20]; setColor (15); Rectangle (XS-3, YS-3, XS 239, YS 115); LINE (XS-3, YS 26, XS 239, YS 26); LINE (XS -3, YS 72, XS 239, YS 72); Outtextxy (XS, YS, "Level:"); OutTextxy (XS, YS 15, "Score:"); Sprintf (STEMP, "-Roll - Downwards "); STEMP [0] = 24; Stemp [7] = 25; Outtextxy (XS, YS 30," Help: ");
SetColor (14); OUTTEXTXY (XS 40, YS 30, STEMP); Outtextxy (XS 40, YS 45, "
IF (Random (2) == 0) {Return First;} else {return first-> next;}} / ************************ *********************************************************** *************** / STRUCT DIAMOND * CREATE_T () {struct diamond * info; struct Diamond * first; intelt Diamond * last; int i;
INFO = (Struct Diamond *) Malloc (Struct Diamond)); info-> x [0] = 0; info-> y [0] = 0; info-> x [1] = - 1; info-> Y [1] = 0; info-> x [2] = 0; info-> y [2] = - 1; info-> x [3] = 1; info-> y [3] = 0; info- > start_x = 5; info-> start_y = 3; info-> color = 4; first = info; las = info; info = (struct diamond *) malloc (Struct Diamond); info-> x [0] = 0; info-> y [0] = 0; Info-> x [1] = 0; info-> y [1] = 1; info-> x [2] = 0; info-> y [2] = -1; info-> x [3] = 1; info-> y [3] = 0; info-> start_x = 5; info-> start_y = 2; info-> color = 4; las-> next = INFO; LAST = INFO;
INFO = (Struct Diamond *) Malloc (Struct Diamond)); info-> x [0] = 0; info-> y [0] = 0; info-> x [1] = - 1; info-> Y [1] = 0; info-> x [2] = 1; info-> y [2] = 0; info-> x [3] = 0; info-> y [3] = 1; info-> START_X = 5; info-> start_y = 2; info-> color = 4; las-> next = info; las = info;
INFO = (Struct Diamond *) malloc (Struct Diamond); info-> x [0] = 0; info-> y [0] = 0; info-> x [1] = 0; info-> y [1] = 1; Info-> x [2] = 0; info-> y [2] = - 1; info-> x [3] = - 1; info-> y [3] = 0; info- > start_x = 5; info-> start_y = 2; info-> color = 4; las-> next = info; last = info; las-> next = first;
FOR (i = 0; i <= random (4); i ) {first = first-> next;} Return first;} / ******************** *********************************************************** *************************** / STRUCT DIAMOND * CREATE_L () {struct Diamond * info; struct diamond * first; intelt diamond * last; int i;
INFO = (Struct Diamond *) malloc (Struct Diamond); info-> x [0] = 0; info-> y [0] = 0; info-> x [1] = 0; info-> y [1] = 1; Info-> x [2] = 0; info-> y [2] = - 1; info-> x [3] = 1; info-> y [3] = 1; info-> START_X = 5; info-> start_y = 2; info-> color = 5; first = info; las = info; info = (struct diamond *) malloc (Struct Diamond); info-> x [0] = 0; info-> y [0] = 0; Info-> x [1] = - 1; info-> y [1] = 0; info-> x [2] = 1; info-> y [2] = 0; info-> x [3] = - 1; info-> y [3] = 1; info-> start_x = 5; info-> start_y = 2; info-> color = 5; las-> next = INFO; LAST = INFO;
INFO = (Struct Diamond *) malloc (Struct Diamond); info-> x [0] = 0; info-> y [0] = 0; info-> x [1] = 0; info-> y [1] = 1; Info-> x [2] = 0; info-> y [2] = - 1; info-> x [3] = - 1; info-> y [3] = - 1; info -> START_X = 5; info-> start_y = 2; info-> color = 5; las-> next = info; las = info;
INFO = (Struct Diamond *) Malloc (Struct Diamond)); info-> x [0] = 0; info-> y [0] = 0; info-> x [1] = - 1; info-> Y [1] = 0; info-> x [2] = 1; info-> y [2] = 0; info-> x [3] = 1; info-> y [3] = - 1; info- > start_x = 5; info-> start_y = 2; info-> color = 5; las-> next = info; las = info; las-> next = first;
FOR (i = 0; i <= random (4); i ) {first = first-> next;} Return first;} / ******************** *********************************************************** *************************** / STRUCT DIAMOND * CREATE_J () {struct Diamond * info; struct diamond * first; INT i;
INFO = (Struct Diamond *) malloc (Struct Diamond); info-> x [0] = 0; info-> y [0] = 0; info-> x [1] = 0; info-> y [1] = 1; Info-> x [2] = 0; info-> y [2] = - 1; info-> x [3] = - 1; info-> y [3] = 1; info- > start_x = 5; info-> start_y = 2; info-> color = 6; first = info; las = info; info = (struct diamond *) malloc (Struct Diamond); info-> x [0] = 0; info-> y [0] = 0; info-> x [1] = - 1; info-> y [1] = 0; info-> x [2] = 1; info-> y [2 ] = 0; info-> x [3] = - 1; info-> y [3] = - 1; info-> start_x = 5; info-> start_y = 2; info-> color = 6; las-> NEXT = INFO; LAST = INFO;
INFO = (Struct Diamond *) malloc (Struct Diamond); info-> x [0] = 0; info-> y [0] = 0; info-> x [1] = 0; info-> y [1] = 1; Info-> x [2] = 0; info-> y [2] = - 1; info-> x [3] = 1; info-> y [3] = - 1; info- > start_X = 5; info-> start_y = 2; info-> color = 6; las-> next = info; las = info;
INFO = (Struct Diamond *) Malloc (Struct Diamond)); info-> x [0] = 0; info-> y [0] = 0; info-> x [1] = - 1; info-> Y [1] = 0; info-> x [2] = 1; info-> y [2] = 0; info-> x [3] = 1; info-> y [3] = 1; info-> START_X = 5; info-> start_y = 2; info-> color = 6; las-> next = info; las = info; las-> next = first;
FOR (i = 0; i <= random (4); i ) {first = first-> next;} Return first;} / ******************** *********************************************************** ****************** / STRUCT DIAMOND * CREATE_Z () {struct diamond * info; struct diamond * first; first = (struct diamond *) Malloc (Struct Diamond )); Info = (struct diamond *) malloc (Struct Diamond)); first-> next = info; info-> next = first; first-> x [0] = 0; first-> y [0] = 0; first-> x [1] = - 1; first-> y [1] = 0; first-> x [2] = 0; first-> y [2] = 1; first-> x [3 ] = 1; first-> y [3] = 1; first_x = 5; first_x = 5; first_y = 2; first-> color = 9; info-> x [0] = 0; info-> y 0] = 0; Info-> x [1] = 0; info-> y [1] = 1; info-> x [2] = 1; info-> y [2] = 0; info-> x [ 3] = 1; Info-> Y [3] = - 1; info-> start_x = 5; info-> start_y = 2; info-> color = 9;
IF (Random (2) == 0) {Return First;} else {return first-> next;}} / ************************ *********************************************************** *************** / STRUCT DIAMOND * CREATE_N () {struct Diamond * info; struct diamond * first; first = (struct diamond *) malloc (Struct Diamond); info = (Struct Diamond *) Malloc (Struct Diamond)); first-> next = info; info-> next = first; first-> x [0] = 0; first-> y [0] = 0; first -> x [1] = 0; first-> y [1] = 1; first-> x [2] = - 1; first-> y [2] = 1; first-> x [3] = 1; First-> y [3] = 0; first-> start_x = 5; first-> start_y = 2; first-> color = 14;
INFO-> x [0] = 0; info-> y [0] = 0; info-> x [1] = 0; info-> y [1] = - 1; info-> x [2] = 1 Info-> y [2] = 0; info-> x [3] = 1; info-> y [3] = 1; info-> start_x = 5; info-> start_y = 2; info-> color = 14; IF (Random (2) == 0) {Return First;} else {return first-> next;}} / ************************** *********************************************************** ***************** / STRUCT DIAMOND * CREATE_H () {struct Diamond * first; first = (struct diamond *) malloc (Struct Diamond); first-> Next = first; first-> x [0] = 0; first-> y [0] = 0; first-> x [1] = 0; first-> y [1] = 1; first-> x [2] = 1; first-> y [2] = 0; first-> x [3] = 1; first-> y [3] = 1; first; first_x = 5; first-> start_y = 2; first-> Color = 1; Return First;} / *************************************************** ****************************************************************** / VOID Show_next () {INT NOWX; / * Record the location of each plaid * / int nowy; int i; / * counter * / int J; int since; / * Whether the current grid has been displayed * / Struct Diamond * next; / * The next state after the flip of the current square * / next = noinfo-> next; if (next == null) {gotoxy (1, 1); Printf ("null);} fo R (i = 0; i <= 3; i ) / * Judging whether it can flip, if you can't, you can exit the function * / {if (Grid [x next-> x [i]] [y next- > y [i]] == 1) {return;}}
SetFillStyle (Solid_Fill, BackColor); / * Set background color to eliminate unwanted plaid * / for (i = 0; i <= 3; I ) {haveit = 0; for (j = 0; j <= 3; J ) ) {If (next-> x [j] == nowinfo-> x [i] && next-> y [j] == nowinfo-> y [i]) {have = 1; Break;}} if (Haveit = = 0) / * If the lattice is displayed after the flip is displayed, if not, set the lattice as a background color * / {grid [x nowinfo-> x [i]] [y nowinfo-> y [i]] = 0; if (Y NOWINFO-> Y [I]> = 4) / * Judging whether the lattice can be displayed * / floodfill (80 (NOWINFO-> X [i] x) * 20 1 , -20 (NOWINFO-> Y [I] Y) * 20 1, color);}} nowinfo = next; noWX = x; nowy = y; setFillStyle (Solid_Fill, NowInfo-> color); / * Setting Fill color as a square color * / for (i = 0; i <= 3; i ) {if (grid [x nowinfo-> x [i]] [y nowinfo-> y [i]]! = 2) / * If the lattice has not been displayed * / {NOWX = X NOWINFO-> x [i]; nowy = y nowinfo-> y [i]; if (y nowinfo-> y [i]> = 4) Floodfill (80 NOWX * 20 1, -20 NOWY * 20 1, Color); Grid [NOWX] [NOWY] = 2; / * Setting the plaid current active block * /}} return; } / ******************************************************* *************************************************** / VOID SHOW_LEFT () {INT i; / * Counter * / int J; int since; / * Whether the current grid has been displayed * / int nowx; / * Record the current position of each plaid * / INT nowy; for (i = 0; i <= 3; i ) / * Judgment can move to left * / {IF (Grid [x-1 NOWINFO-> x [i]] [y nowinfo-> y [i]] == 1) {return;}}
SetFillStyle (Solid_Fill, BackColor); / * Set background color to eliminate unwanted plaid * / for (i = 0; i <= 3; I ) {haveit = 0; for (j = 0; j <= 3; J ) ) {Ifinfo-> x [i] == nowinfo-> x [j] -1 && noinfo-> y [i] == nowinfo-> y [j]) {have = 1; Break;}} if (Haveit == 0) / * If the lattice is displayed after the flip is displayed, if not, set the lattice as a background color * / {grid [x nowinfo-> x [i]] [y nowinfo-> y [i] ] = 0; if (Y NOWINFO-> Y [i]> = 4) / * Judging whether the lattice can be displayed * / floodfill (80 (NOWINFO-> X [i] x) * 20 1, -20 (NOWINFO-> Y [I] Y) * 20 1, color);}} setfillstyle (Solid_Fill, NowInfo-> color); / * Set the color of the block * / for ( i = 0; i <= 3; i ) {NOWX = X NOWINFO-> x [i] -1; nowy = y nowinfo-> y [i]; if (grid [noWX] [nowy]! = 2 ) / * If the lattice has not been displayed * / {if (nowy> = 4) Floodfill (80 NOWX * 20 1, -20 NOWY * 20 1, Color); Grid [NOWX] [nowy] = 2;}} x = x-1; return;} / *********************************************** *********************************************************** *** / void show_right () {INT i; / * counter * / int J; int Haveit; / * Current lattice has displayed * / int nowx; / * Record the current position of each plaid * / int nowy; for (i = 0; i <= 3; i ) {IF (Grid [x 1 NOWINFO-> X [i ]] [Y NOWINFO-> Y [I]] == 1) {RETURN; / * Judgment whether it can be moved to the right * /}}
SetFillStyle (Solid_Fill, BackColor); / * Set background color to eliminate unwanted plaid * / for (i = 0; i <= 3; I ) {haveit = 0; for (j = 0; j <= 3; J ) ) {If (nowinfo-> x [i] == nowinfo-> x [j] 1 &&owinfo-> y [i] == nowinfo-> y [j]) {have = 1; Break;}} if (Haveit == 0) / * If the lattice is displayed after the flip is displayed, if not, set the lattice as a background color * / {grid [x nowinfo-> x [i]] [y nowinfo-> y [i] ] = 0; if (Y NOWINFO-> Y [i]> = 4) / * Judging whether the lattice can be displayed * / floodfill (80 (NOWINFO-> X [i] x) * 20 1, -20 (NOWINFO-> Y [I] Y) * 20 1, color);}} setfillstyle (Solid_Fill, NowInfo-> color); / * Set the color of the block * / for ( i = 0; i <= 3; i ) {nowX = x nowinfo-> x [i] 1; nowy = y nowinfo-> y [i]; if (grid [noWX] [nowy]! = 2 ) {If (nowy> = 4) / * Determine whether the lattice can be displayed * / floodfill (80 NOWX * 20 1, -20 NOWY * 20 1, Color); Grid [NOWX] [NOWY ] = 2;}} x = x 1; return;} / *************************************************** *********************************************************** ***** / void show_down () {
INT i; / * counter * / int J; inthait; / * Whether the current grid has been displayed * / int nowx; / * Record the location of each plaid * / int nowy; int key; for (i = 0; i <= 3; i ) {IF (grid [x nowinfo-> x [i]] [Y NOWINFO-> Y [i] 1] == 1) / * Determine whether the block can be dropped * / {for ( J = 0; j <= 3; j ) {grid [x nowinfo-> x [j]] [y nowinfo-> y [j] = 1; if (y nowinfo-> y [j] < = 3) {/ * Judging whether the game has been finished * / install (OldTimer); setFillStyle (Solid_Fill, 1); bar (0,465,640,480); OutTextxy (5,469, "do you want to restart (y / n) ..." ); For (;;) {key = bioskey (0); if (key == yes) {startset (); setfillstyle (Solid_Fill, 9); bar (0,465,640,480); return;} if (key == no) { Closegraph (); exit (0);}}}} Delinfo (NowInfo); scandel (); / * Scan, delete * / delay (2500); while (Bioskey (1)) BIOSKEY (0); / * Clear keyboard Buffer * / / * clrKey (); * / noinfo = nextinfo; / * Get new square * / nextinfo = get_diamond (); / * Get the next block * / showsubwin (nextInfo); x = noinfo-> start_x; / * Reset the block position * / y = noinfo-> start_y; return;}}
SetFillStyle (Solid_Fill, BackColor); / * Set background color to eliminate unwanted plaid * /
For (i = 0; i <= 3; i ) {Haveit = 0; for (j = 0; j <= 3; j ) {if (nowinfo-> x [i] == nowinfo-> x [j] && Noinfo-> Y [i] == NOWINFO-> y [j] 1) {have; = 1; Break;}} f (Haveit == 0) / * Declats whether the lattice is displayed, if not, This lattice is set as a background color * / {grid [x nowinfo-> x [i]]] [y nowinfo-> y [i]] = 0; if (Y NOWINFO-> Y [i]> = 4) / * Determine whether the lattice can be displayed * / floodfill (80 (NOWINFO-> x [i] x) * 20 1, -20 (NOWINFO-> Y [i] Y) * 20 1, color);}}}}}}}}}}}}}}}}}; / * Set the color * / for (i = 0; i <= 3; i ) {nowx = x nowinfo-> x [i]; nowy = y nowinfo-> y [i] 1; if (grid [noWy]! = 2) / * If the lattice has not been displayed * / {if (nowy> = 4 Floodfill (80 NOWX * 20 1, -20 NOWY * 20 1, Color); Grid [NOWX] [NOWY] = 2;}} y = Y 1; Return;} / ***** *********************************************************** ********************************************* / * void print () test function {INT i; int J Gotoxy (1, 1); for (j = 0; j <= 22; j ) {for (i = 0; i <= 11; i ) {printf ("% d", grid [i] [j] );} Printf ("/ n");}} * / / ******************************************************** ***************************** *********************************** / void scandel () {INT i; int K; int J; int Num; int scoreadd; scoreadd = 0; For (k = 21; k> = 4; k -) {num = 0; for (i = 1; i <= 10; i ) {IF (Grid [i] [k] == 1) Num ;} IF (NUM == 10) {scoreadd ; for (i = 1; i <= 10; i ) {setfillstyle; floodfill (80 i * 20 1, -20 k * 20
1, color);} for (j = k; j> = 5; j -) {for (i = 1; i <= 10; i ) {setFillStyle (Solid_Fill, getpixel (80 i * 20 1, -40 j * 20 1)); floodfill (80 i * 20 1, -20 j * 20 1, color); Grid [i] [j] = grid [i] [j-1] ;}} For (i = 1; i <= 10; i ) {setfillstyle; floodfill (80 i * 20 1, 61, color); Grid [i] [4] = 0;} K ;}} if (scoreadd! = 0) showScore (2 * scoreadd-1);} / *************************************** *********************************************************** *********** / VOID Interrupt NewTimer () / * New Timer Interrupt Delivery * / {INT LevelTemp; LevelTemp = 11-Level; Count ; if (count> = leveltemp) {AddTobuffer (Down) Count = 0;} (* Oldtimer) ();} / *************************************************** *********************************************************** **** / void install (Void Interrupt (* paddr) ()) {disable (); setVect (0x1c, paddr); enable ();} / *************** *********************************************************** ************************** / VOID DELINFO (Struct Diamond * INFO) / * Release the open space * / {Struct diamond * next; now = info-> next; next = info-> next; while (next! = Info) {next = now-> next; free (now); now = next;} Free (Info);} / ************************************************** **************************************************************************************************************************************************************** (int C) / * Add a down * / {unsigned i; i = * (unsigned far *) 0x0040001cl; * (unsigned far *) (0x00400000L | i) = C; i = 2; if (iF) = C; I> = * (unsigned far *) 0x00400082L) i = * (unsigned far *) 0x00400080L; * (unsigned far *) 0x0040001cl = i;
} / ******************************************************* *************************************************************** / * VOID CLRKEY () call DOS interrupt empty keyboard buffer, unused this method. {Union Regs in; in.h.ah = 0x0c; in.h.al = 0x00; INTDOS (& IN, & in);} * / / ****** *********************************************************** ********************************************* / VOID Showsubwin (struct diamond * next) {INT i; / * counter * / Int J; setfillstyle; for (i = 0; i <= 3; i ) {for (j = 0; j <= 3; J ) {floodfill (361 20 * i, 61 20 * j, color);}} setfillstyle (Solid_Fill, Next-> Color); for (i = 0; i <= 3; i ) {floodfill (381 next-> x [i] * 20, 81 Next -> y [i] * 20, color);}} / ****************************************************** *********************************************************** ***** / void showscore (int Scoreget) {char sscore [6]; char SLVEL [2]; score = scoreget; if (score <1000) level = score / 100 1; sprintf (sscore, "% d ", SCORE); Sprintf (Slevel,"% D ", Level); setFillStyle (Solid_Fill, 9); BAR (406, 179, 490, 203); setColor 14); Outtextxy (408, 180, Slevel); Outtextxy (408, 195, SSCORE);} / **************************************** *********************************************************** ********** / VOID StartSet () {INT i; INT J; setFillStyle (Solid_Fill, BackColor); for (i = 0; i <= 21; i ) / * Reinitialization * / {for (j = 1; j <= 10; j ) IF (Grid [j]! = 0) {grid [j] [i] = 0; if (i> = 4) floodfill (80 j * 20 1, -20 i * 20 1, color);}} score = 0; showscore (0); nowinfo = get_diamond (); / * Get a current square * / x = noinfo-> start_x; / * initialization Square position * / y = noinfo-> start_y; nextinfo =
Get_Diamond (); / * Get the next block * / showSubwin (nextInfo); install (newtimer);} CCBONLINE All Right Reserved