Tetris

Check-in [2a240b982d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add some comments
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:2a240b982d27d89cf3ef4787a52d529982b8f7cd9b01b4ff7572448d87b79054
User & Date: ajv-899-334-8894@vsta.org 2008-10-25 02:55:29
Context
2008-10-25
02:55
Add -Wall and cleanup rules check-in: 613a9e7d8d user: ajv-899-334-8894@vsta.org tags: trunk
02:55
Add some comments check-in: 2a240b982d user: ajv-899-334-8894@vsta.org tags: trunk
01:16
Initial revision check-in: 6bde378d89 user: ajv-899-334-8894@vsta.org tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to screen.c.

432
433
434
435
436
437
438











439
440
441
442
443
444
445

446


447




448
449
450
451
452
453






454
455
456
457
458
459
460
461



462

463
464
465
466
467
468
469





470
471
472
473

474
475
476
477
478
479
480
481
482
483

484
485
486
487
488
489
490

			moveto(tr, 2*tc);
			putstr("  ");
		}
		putpad(SEstr);
	}
	











	bp = &board[D_FIRST * B_COLS];
	sp = &curscreen[D_FIRST * B_COLS];
	for (j = D_FIRST; j < D_LAST; j++) {
		ccol = -1;
		for (i = 0; i < B_COLS; bp++, sp++, i++) {
			if (*sp == (so = *bp))
				continue;

			*sp = so;


			if (i != ccol) {




				if (cur_so && MSflag) {
					putpad(SEstr);
					cur_so = 0;
				}
				moveto(RTOD(j), CTOD(i));
			}






			if (SOstr) {
				if (so != cur_so) {
					putpad(so ? SOstr : SEstr);
					cur_so = so;
				}
				putstr("  ");
			} else
				putstr(so ? "XX" : "  ");



			ccol = i + 1;

			/*
			 * Look ahead a bit, to avoid extra motion if
			 * we will be redrawing the cell after the next.
			 * Motion probably takes four or more characters,
			 * so we save even if we rewrite two cells
			 * `unnecessarily'.  Skip it all, though, if
			 * the next cell is a different color.





			 */
#define	STOP (B_COLS - 3)
			if (i > STOP || sp[1] != bp[1] || so != bp[1])
				continue;

			if (sp[2] != bp[2])
				sp[1] = -1;
			else if (i < STOP && so == bp[2] && sp[3] != bp[3]) {
				sp[2] = -1;
				sp[1] = -1;
			}
		}
	}
	if (cur_so)
		putpad(SEstr);

	(void) fflush(stdout);
	(void) sigprocmask(SIG_SETMASK, &osigset, (sigset_t *)0);
}

/*
 * Write a message (set!=0), or clear the same message (set==0).
 * (We need its length in case we have to overwrite with blanks.)







>
>
>
>
>
>
>
>
>
>
>





|

>

>
>

>
>
>
>






>
>
>
>
>
>






|

>
>
>

>







>
>
>
>
>


|

>
|

|





|

>







432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525

			moveto(tr, 2*tc);
			putstr("  ");
		}
		putpad(SEstr);
	}
	
	/*
	 * Repaint the actual board
	 *
	 * "bp" Points at the updated board contents
	 * "sp" Points at what was last painted on the screen
	 * "so" Flags whether or not "standout" is active,
	 *  and "cur_so" keeps track of whether or not standout
	 *  is current selected on the terminal.
	 * "ccol" indicates the current column, or -1 if the
	 *  hardware cursor should be moved before next output.
	 */
	bp = &board[D_FIRST * B_COLS];
	sp = &curscreen[D_FIRST * B_COLS];
	for (j = D_FIRST; j < D_LAST; j++) {
		ccol = -1;
		for (i = 0; i < B_COLS; bp++, sp++, i++) {
			if (*sp == (so = *bp)) {
				continue;
			}
			*sp = so;

			/* Need to move cursor for next output */
			if (i != ccol) {
				/*
				 * Can't move with standout enabled,
				 *  so turn it off.
				 */
				if (cur_so && MSflag) {
					putpad(SEstr);
					cur_so = 0;
				}
				moveto(RTOD(j), CTOD(i));
			}

			/*
			 * Paint a position, using either standout applied
			 *  to spaces, or explicit characters if the
			 *  terminal doesn't support standout.
			 */
			if (SOstr) {
				if (so != cur_so) {
					putpad(so ? SOstr : SEstr);
					cur_so = so;
				}
				putstr("  ");
			} else {
				putstr(so ? "XX" : "  ");
			}

			/* Update notion of current column */
			ccol = i + 1;

			/*
			 * Look ahead a bit, to avoid extra motion if
			 * we will be redrawing the cell after the next.
			 * Motion probably takes four or more characters,
			 * so we save even if we rewrite two cells
			 * `unnecessarily'.  Skip it all, though, if
			 * the next cell is a different color.
			 *
			 * We inhibit extra motion by putting -1 into the
			 *  "current screen"'s idea of its contents, which
			 *  forces our loop to write those character
			 *  positions rather than try to skip them.
			 */
#define	STOP (B_COLS - 3)
			if (i > STOP || sp[1] != bp[1] || so != bp[1]) {
				continue;
			}
			if (sp[2] != bp[2]) {
				sp[1] = -1;
			} else if (i < STOP && so == bp[2] && sp[3] != bp[3]) {
				sp[2] = -1;
				sp[1] = -1;
			}
		}
	}
	if (cur_so) {
		putpad(SEstr);
	}
	(void) fflush(stdout);
	(void) sigprocmask(SIG_SETMASK, &osigset, (sigset_t *)0);
}

/*
 * Write a message (set!=0), or clear the same message (set==0).
 * (We need its length in case we have to overwrite with blanks.)