/* %kw # %v %n %d %t # */ /* Version # 2 MW2PAGE.C 27-Oct-92 9:58:00 # */ /**********************************************************/ /* METAGRAPHICS SOFTWARE CORPORATION (c) 1987-1992 */ /* */ /* Description: This program is an example of how to use */ /* and flip between the two EGA pages. */ /* */ /* Functions used: */ /* SetBitmap, SetDisplay */ /**********************************************************/ #include #include #include #include #include #include #include #include "metawndo.h" /* master MetaWINDOW include file */ /* special stack size declaration if using Turbo or Borland C++ */ #ifdef TurboC extern unsigned _stklen = 14336U; /* stack size 14K */ #endif void scrn1(void); rect scrnR; void main() { int i; rect ballR; grafPort *scrnport; i = InitGraphics( EGA640x350 ); if( i != 0 ) { printf( "MetaWINDOW InitGraphics error - %d\n",i ); exit(1); } /* do an initial setdisplay to put into graphics mode */ SetDisplay( GrafPg0 ); ScreenRect(&scrnR); /* Get the screen limits */ EraseRect(&scrnR); /* Clear the screen */ /* set a bounding rectangle for the ball */ SetRect( &ballR, 0,((scrnR.Ymax/2) - 30), 32, scrnR.Ymax/2); OffsetRect( &ballR, scrnR.Xmax/4, 0); /* get pointer to current (default) port */ GetPort( &scrnport ); for (i=0; i<100; i++) { /* draw to bitmap page 0 */ scrn1(); /* draw background screen */ OffsetRect( &ballR, 2, 0); /* move the ball */ PenColor(5); FillOval( &ballR, 1); /* display bitmap page 0 */ SetDisplay( GrafPg0); /* draw to bitmap page 1 */ SetBitmap(GrafPg1,scrnport->portMap); scrn1(); /* draw background screen */ OffsetRect( &ballR, 2, 0); /* move the ball */ PenColor(5); FillOval( &ballR, 1); /* displaying bitmap page 1 */ SetDisplay( GrafPg1); /* draw to bitmap page 0 */ SetBitmap(GrafPg0,scrnport->portMap); } SetDisplay(TextPg0); /* Switch to alpha mode */ StopGraphics(); i = QueryError(); printf("QueryError=%d/%d\n", i >> 7, i & 127); exit(i); } /* set-up "background" screen */ void scrn1() { int wid,len,beg,half; int wallx, wally; wid = 10; len = 30; beg = scrnR.Xmax/4; half = scrnR.Ymax/2; wallx = beg - 70; wally = scrnR.Ymax/4; PenColor(0); EraseRect(&scrnR); PenColor(1); /* draw the bowling lane */ MoveTo( (beg+len), (half - wid)); /* top lane line */ LineTo( scrnR.Xmax, (half - wid)); MoveTo( beg, (half + wid)); /* bottom lane line */ LineTo( (scrnR.Xmax - len), (half + wid)); MoveTo( (beg+len), (half - wid)); /* start line */ LineTo( beg, (half + wid)); MoveTo( scrnR.Xmax, (half - wid)); /* finish line */ LineTo( (scrnR.Xmax - len), (half + wid)); MoveTo( (scrnR.Xmax - 80), (half - 3)); /* top of tri */ LineTo( scrnR.Xmax, (half - wid)); MoveTo( (scrnR.Xmax - 80), (half - 3)); /* bottom of tri */ LineTo( (scrnR.Xmax - len), (half + wid)); /* draw the bowling alley */ MoveTo( wallx, wally); LineTo( wallx, 0); MoveTo( wallx, wally); LineTo( scrnR.Xmax, wally); MoveTo( wallx, wally); LineTo( 0, half - 50); }