DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T d

⟦a018dec83⟧ TextFile

    Length: 9770 (0x262a)
    Types: TextFile
    Names: »draw.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/X/Xtetris/draw.c« 

TextFile

#include "defs.h"

draw_shadow(shape_no, xpos, ypos, rot, col)
        int     shape_no, xpos, ypos, rot, col;
{
        int     y1;
        int     x1, x2, x3, x4;
        int     t0, t1, t2, t3;
        int     xsize;

        t0 = shape[shape_no].table[0][rot];     /* Bit map of 1st Row */
        t1 = shape[shape_no].table[1][rot];     /* Bit map of 2nd Row */
        t2 = shape[shape_no].table[2][rot];     /* Bit map of 3rd Row */
        t3 = shape[shape_no].table[3][rot];     /* Bit map of 4th Row */

        x1 = xpos * UNIT;       /* Position of 1st column of block grid */
        x2 = x1 + UNIT;         /* Position of 2nd column of block grid */
        x3 = x2 + UNIT;         /* Position of 3rd column of block grid */
        x4 = x3 + UNIT;         /* Position of 4th column of block grid */

        y1 = UHEIGHT * UNIT + SHADOW_OFFSET / 2;
        xsize = UWIDTH * UNIT;

	XSetFunction(XtDisplay(toplevel), gc, GXclear);
	XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                       0, y1, xsize, UNIT);
        XFlush(XtDisplay(toplevel));
	if (col == WHITE) XSetFunction(XtDisplay(toplevel), gc, GXclear);
	else XSetFunction(XtDisplay(toplevel), gc, GXcopy);
        if (t0 & 8 || t1 & 8 || t2 & 8 || t3 & 8)
		XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                               x1, y1, UNIT, UNIT);
        if (t0 & 4 || t1 & 4 || t2 & 4 || t3 & 4)
		XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                               x2, y1, UNIT, UNIT);
        if (t0 & 2 || t1 & 2 || t2 & 2 || t3 & 2)
		XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                               x3, y1, UNIT, UNIT);
        if (t0 & 1 || t1 & 1 || t2 & 1 || t3 & 1)
		XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                               x4, y1, UNIT, UNIT);
        XFlush(XtDisplay(toplevel));
}

show_next()
{
        int     y, y1, xsize;

        y = UHEIGHT * UNIT + SHADOW_HEIGHT;
        xsize = UNIT * UWIDTH;

	XSetFunction(XtDisplay(toplevel), gc, GXclear);
        XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                       0, y + UNIT, xsize, NEXT_HEIGHT - UNIT);

	XSetFunction(XtDisplay(toplevel), gc, GXcopy);
        XDrawString(XtDisplay(toplevel), XtWindow(canvas), gc,
                       5, y + UNIT, "Next block", 10);

        y1 = y / UNIT + 1;
        print_shape(next_no, 5, y1, next_rot, shape[next_no].color);
        XFlush(XtDisplay(toplevel));
}

print_shape(shape_no, x, y, rot, col)
        int     shape_no, x, y, rot, col;
{
        int     x1, x2, x3, x4, y1;
        int     t0, t1, t2, t3;

        t0 = shape[shape_no].table[0][rot];     /* Bit map of 1st Row */
        t1 = shape[shape_no].table[1][rot];     /* Bit map of 2nd Row */
        t2 = shape[shape_no].table[2][rot];     /* Bit map of 3rd Row */
        t3 = shape[shape_no].table[3][rot];     /* Bit map of 4th Row */

        x1 = x * UNIT;          /* Position of 1st column of block grid */
        x2 = x1 + UNIT;         /* Position of 2nd column of block grid */
        x3 = x2 + UNIT;         /* Position of 3rd column of block grid */
        x4 = x3 + UNIT;         /* Position of 4th column of block grid */
        y1 = y * UNIT;          /* Position of 1st row of block grid    */

	if (col == WHITE) XSetFunction(XtDisplay(toplevel), gc, GXclear);
	else XSetFunction(XtDisplay(toplevel), gc, GXcopy);
        if (y > -1) {
                if (t0 & 8)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x1, y1, UNIT, UNIT);
                if (t0 & 4)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x2, y1, UNIT, UNIT);
                if (t0 & 2)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x3, y1, UNIT, UNIT);
                if (t0 & 1)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x4, y1, UNIT, UNIT);
        }
        y1 += UNIT;             /* Position of next row */
        if (y > -2) {
                if (t1 & 8)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x1, y1, UNIT, UNIT);
                if (t1 & 4)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x2, y1, UNIT, UNIT);
                if (t1 & 2)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x3, y1, UNIT, UNIT);
                if (t1 & 1)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x4, y1, UNIT, UNIT);
        }
        y1 += UNIT;             /* Position of next row */
        if (y > -3) {
                if (t2 & 8)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x1, y1, UNIT, UNIT);
                if (t2 & 4)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x2, y1, UNIT, UNIT);
                if (t2 & 2)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x3, y1, UNIT, UNIT);
                if (t2 & 1)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x4, y1, UNIT, UNIT);
        }
        y1 += UNIT;             /* Position of next row */
        if (y > -4) {
                if (t3 & 8)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x1, y1, UNIT, UNIT);
                if (t3 & 4)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x2, y1, UNIT, UNIT);
                if (t3 & 2)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x3, y1, UNIT, UNIT);
                if (t3 & 1)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x4, y1, UNIT, UNIT);
        }

	XSetFillStyle(XtDisplay(toplevel), gc, FillTiled);
        y1 = y * UNIT;          /* Position of 1st row of block grid    */
        if (y > -1) {
                if (t0 & 8)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x1 +1, y1 +1, UNIT -2, UNIT -2);
                if (t0 & 4)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x2 +1, y1 +1, UNIT -2, UNIT -2);
                if (t0 & 2)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x3 +1, y1 +1, UNIT -2, UNIT -2);
                if (t0 & 1)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x4 +1, y1 +1, UNIT -2, UNIT -2);
        }
        y1 += UNIT;             /* Position of next row */
        if (y > -2) {
                if (t1 & 8)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x1 +1, y1 +1, UNIT -2, UNIT -2);
                if (t1 & 4)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x2 +1, y1 +1, UNIT -2, UNIT -2);
                if (t1 & 2)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x3 +1, y1 +1, UNIT -2, UNIT -2);
                if (t1 & 1)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x4 +1, y1 +1, UNIT -2, UNIT -2);
        }
        y1 += UNIT;             /* Position of next row */
        if (y > -3) {
                if (t2 & 8)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x1 +1, y1 +1, UNIT -2, UNIT -2);
                if (t2 & 4)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x2 +1, y1 +1, UNIT -2, UNIT -2);
                if (t2 & 2)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x3 +1, y1 +1, UNIT -2, UNIT -2);
                if (t2 & 1)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x4 +1, y1 +1, UNIT -2, UNIT -2);
        }
        y1 += UNIT;             /* Position of next row */
        if (y > -4) {
                if (t3 & 8)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x1 +1, y1 +1, UNIT -2, UNIT -2);
                if (t3 & 4)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x2 +1, y1 +1, UNIT -2, UNIT -2);
                if (t3 & 2)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x3 +1, y1 +1, UNIT -2, UNIT -2);
                if (t3 & 1)
                      XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                                     x4 +1, y1 +1, UNIT -2, UNIT -2);
        }
	XSetFillStyle(XtDisplay(toplevel), gc, FillSolid);
        XFlush(XtDisplay(toplevel));
}