TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: David Van Hoose
from: Mario Semo
date: 1998-10-05 08:57:40
subject: Pixels

Hallo David!

Antwort auf eine Message von David Van Hoose an All:

 DVH> How do you write a pixel to the console using BCOS2???
 DVH> The C and C++ echo mods told me to come here.
 DVH> Peace to all of you out there!

1) you have to find the Vio documentation somewhere. its from the OS2 1.x
toolkit. its called prcp.inf (search for prcp.zip on some bbs near to you).

2) which version of bcos2 do you use? at least 1.0 (maybe other versions
too) have a lot of bugs in the function prototypes for the VIO functions.

eq: 
typedef struct _VIOFONTINFO {   /* viofi */
        USHORT  cb;
        USHORT  type;
        USHORT  cxCell;
        USHORT  cyCell;
        PVOID16   pbData;                       /* MS                        */
        USHORT  cbData;
        } VIOFONTINFO;
typedef VIOFONTINFO FAR16PTR PVIOFONTINFO;

APIRET16  APIENTRY16    VioGetState (PVOID16 pState, HVIO hvio); /* MS */
APIRET16  APIENTRY16    VioSetState (PVOID16 pState, HVIO hvio); /* MS */

3)
heres an old mail from Peter:

================================== OS2.L.PROG ==================================
    Von: Peter Fitzsimmons                 1:259/414       02 Apr 1995  19:15:50
     An: David Etheredge                                   15 Apr 1995  11:16:40
  Thema: direct video access                                                    
================================================================================
The following program uses VioGetPhysBuf (and can therefore only be run in a 
full-screen session) to draw a series of circles,  then rotates the palette to 
produce a hypnotic effect (do not use under the influence of recreational drugs 
:-).

It was compiled with IBM cset++ thus:

    icc /G4 /Q /Smes /W3 /Kb+ /O /Gs /Gm circ_fs.c

I was not able to get the program to function properly when compiled with 
Borland/2 or Watcom 32bit (works ok Watcom 16bit).

When I get around to it,  I plan to try to write the same program as a PM 
program,  and as a DIVE program,  unless someone else wants to...

 #define INCL_NOPMAPI
 #define INCL_VIO
 #define INCL_DOS
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 //icc /G4 /Q /Smes /W3 /Kb+ /O /Oi20 /Gs /Gm circ_fs.c
 //p.fitzsimmons 3/95


 #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 *pchScreen)
 {
     int x, y, r;

     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 thread2(void *arg)
 {
     unsigned i=0;
     DosSetPriority(PRTYS_PROCESS, PRTYC_IDLETIME, 1, 0);
     for(;;){
         rotate(0);
         if(!(i++ % 2))   // sleep every other loop
             DosSleep(1);
     }
 }


 int main(void)
 {
     VIOPHYSBUF viopb;
     PCH    pchScreen;
     USHORT fStatus;

     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, NULL, 0x2000, NULL);
     getch();
     return 0;
 }

--- 
* Origin: Sol 3/Toronto (905)858-8488 (1:259/414)
SEEN-BY: 396/1 632/0 371 633/210 260 267 270 371 635/506 728 639/252 670/218
@PATH: 310/14 1 65 24/888 396/1 633/260 635/506 728 633/267

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™.