TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Joey Mukherjee
from: Peter Fitzsimmons
date: 1995-04-08 18:02:48
subject: direct video access

JM> Can you tell me what you used (i.e. command line params and linker args) 
 JM> to get this to compile with Watcom 16 bit?  I tried

Sorry; I had to change the code a bit to compile for 16bit.  There also
appears to be a bug/limit in the wc10 16bit _beginthread(),  that requires
the stack to be part of DGROUP.  I don't remember seeing this problem in
wc9/9.5

[batch file -- note I point it to MSC 6 for the 16 bit headers; you can
                use IBM's toolkit 1.3 instead]
 setlocal
 set include=%WATCOM%\h;d:\usr\msc\v60\inc;
 set lib=d:\os2;%WATCOM%\lib286;%WATCOM%\lib286\os2;d:\usr\msc\v60\lib
 wcl /ml /bm /w3 /zq /od /d2 circ_16.c

[circ_16.c]
 #define INCL_NOPM
 #define INCL_VIO
 #define INCL_DOS
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 

 #define SIZEX 320
 #define SIZEY 200

 #define ORIGINX (SIZEX/2)
 #define ORIGINY (SIZEY/2)


 #define squared(n)  ((n) * (n))
 #define point(x, y)  pchScreen[ (unsigned) ((y) * SIZEX + x)]


 // circle with origin (h,k) and radius r:  r^2 = (x-h)^2 + (y-k)^2

 void circles(UCHAR far *pchScreen)      // NOTE16
 {
     long x, y, r;                       // NOTE16

     for(x=0; x=0; i--){     // rotate old values
         pal[(i+1) * 3 + 0] = pal[i*3 + 0];
         pal[(i+1) * 3 + 1] = pal[i*3 + 1];
         pal[(i+1) * 3 + 2] = pal[i*3 + 2];
     }
     pal[0] = r;     // add new value
     pal[1] = g;
     pal[2] = b;

     switch(ch){
         case 0: b = newcolor(&bdir, b, &ch); break;
         case 2: g = newcolor(&gdir, g, &ch); break;
         case 1: r = newcolor(&rdir, r, &ch); break;
     }

     rc = VioSetState(&vcr, 0);
     if(rc){
         printf( "SYS%04u: Error setting palette registers.\n", rc);
         exit(1);
     }
 }



 static void setmode(void)
 {
     VIOMODEINFO vi;
     USHORT rc;

     vi.cb = sizeof(vi);
     VioGetMode(&vi, 0);
     vi.fbType = 3;
     vi.color  = 8;
     vi.col    = 40;
     vi.row    = 25;
     vi.hres   = SIZEX;
     vi.vres   = SIZEY;
     if( 0 != (rc = VioSetMode(&vi, 0))){
         printf("SYS%04u: Could not set video mode to 320x200x256", rc);
         exit(1);
     }
 }


 void far thread2(void far *arg)                             // NOTE16
 {
     unsigned i=0;
     DosSetPrty(PRTYS_PROCESS, PRTYC_IDLETIME, 1, 0);        // NOTE16
     for(;;){
         rotate(0);
         if(!(i++ % 2))   // sleep every other loop
             DosSleep(1);
     }
 }


 int main(void)
 {
     VIOPHYSBUF viopb;
     PCH    pchScreen;
     USHORT fStatus;
     static char stack[0x2000];      // NOTE16, wc

     srand(time(NULL) % 0x8000);
     setmode();
     viopb.pBuf = (PBYTE) 0xA0000L;
     viopb.cb = 64000L;
     VioScrLock(LOCKIO_WAIT, (PBYTE) &fStatus, 0);
     VioGetPhysBuf(&viopb, 0);
     pchScreen = MAKEP(viopb.asel[0], 0);
     _fmemset(pchScreen, 0, (size_t)viopb.cb);
     circles(pchScreen);
     VioScrUnLock(0);
     rotate(1);
     DosSleep(100L);     // pause for effect
     _beginthread(thread2, stack, sizeof(stack), NULL);  // NOTE16
     getch();
     return 0;
 }




--- Maximus/2 2.02p1
* Origin: Sol 3/Toronto (905)858-8488 (1:259/414)
SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809
@PATH: 259/414 400 99 250/702 3615/50 396/1 270/101 105/103 42 712/515
@PATH: 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.