Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to maka characters dim?

Posted on 1997-02-20
6
Medium Priority
?
278 Views
Last Modified: 2012-06-21
How to make characters that are already displayed on the screen
to diminish continuously till they become invisible as is
done in games software (eg: Apogee's Hocus Pocus,Optik's Xixit ?
 Please tell me how i can do it using function or interrups availble in borland C.how do i use rbg contents and reduse the color(I mean which function available does it?)
I am using dos and I have all libraries provided by bc
0
Comment
Question by:Chaitanya021797
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 

Accepted Solution

by:
ansgar earned 600 total points
ID: 1249400
Draw the characters using color cells reserved exclusively for them. After the characters are on the screen, morph the rgb content of these colorcells towards the background color. In the simplest case, just reduce each rgb stepwise to zero. This will give a smooth fading effect. You might want to increase the speed of the morphing towards the end, this will give a better optical effect.
0
 

Author Comment

by:Chaitanya021797
ID: 1249401
Edited text of question
0
 

Expert Comment

by:ansgar
ID: 1249402
Unfortunately, I stopped programming in Borland C two years ago.
Nevertheless, I want to help you !
I dug up some old sources and realized that I had been using the bgi library for 16 color and the SVGA library for 256 colors. A fading as you would want it is probably nicer to do with 256 colors. I also did some direct BIOS programming, which is faster but riskier and you can only set pixels ! I could send you the BIOS functions, and also search the SVGA library on the Borland WWW page.

Are you programming this under DOS ? Which gfx library are you using ? If you want to do this under Win, I cannot help you specifically, since I have never done any Win programming.

I have done this palette fading before, but its no use if I send you the code if you don't have the library to go with it.

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Chaitanya021797
ID: 1249403
Edited text of question
0
 

Expert Comment

by:ansgar
ID: 1249404
svga library:

-------------- svgalib.h --------------------
#include <graphics.h>
#include <process.h>
#include "d:\BORLANDC\BGI\VGAPALET.C"

int init_svga(int mode);
int outit_svga(void);
void getvgapalette16(DacPalette16 *PalBuf);
void getvgapalette256(DacPalette256 *PalBuf);
void setvgapalette16(DacPalette16 *PalBuf);
void setvgapalette256(DacPalette256 *PalBuf);

-----------------------------------------------

---------- svgalib.c --------------------------
#include "svgalib.h"

int init_svga(int gmode)
{
        int gdriver;

        gdriver = installuserdriver("SVGA256",0);
        initgraph(&gdriver,&gmode,"d:\\borlandc\\bgi\\");

        if (graphresult()!=grOk)
                exit(1);

        return 0;
}
int outit_svga()
{
        closegraph();
        return 0;
}

void getvgapalette16(DacPalette16 *PalBuf)
{
  struct REGPACK reg;

  reg.r_ax = 0x1017;
  reg.r_bx = 0;
  reg.r_cx = 16;
  reg.r_es = FP_SEG(PalBuf);
  reg.r_dx = FP_OFF(PalBuf);
  intr(0x10,&reg);
}

void getvgapalette256(DacPalette256 *PalBuf)
{
  struct REGPACK reg;

  reg.r_ax = 0x1017;
  reg.r_bx = 0;
  reg.r_cx = 256;
  reg.r_es = FP_SEG(PalBuf);
  reg.r_dx = FP_OFF(PalBuf);
  intr(0x10,&reg);
}

void setvgapalette16(DacPalette16 *PalBuf)
{
  struct REGPACK reg;

  reg.r_ax = 0x1012;
  reg.r_bx = 0;
  reg.r_cx = 16;
  reg.r_es = FP_SEG(PalBuf);
  reg.r_dx = FP_OFF(PalBuf);
  intr(0x10,&reg);
}

void setvgapalette256(DacPalette256 *PalBuf)
{
  struct REGPACK reg;

  reg.r_ax = 0x1012;
  reg.r_bx = 0;
  reg.r_cx = 256;
  reg.r_es = FP_SEG(PalBuf);
  reg.r_dx = FP_OFF(PalBuf);
  intr(0x10,&reg);
}

-----------------------------------------------


0
 

Expert Comment

by:ansgar
ID: 1249405
code, needs to include 'svgalib.c':

----------------------------------------

#include "svgalib.h"

main()
{
  int num;
  init_svga(SVGA800x600x256);
  set_palette();

  num=15;

  setcolor(num); /* set current drawing color to color cell 15 */
  /* draw something */
  fade(15);
  /* etc */
}

void set_palette()
{
  DacPalette256 palette;

  palette[0][0]=0; /* red component of color cell 0 */
  palette[0][1]=0; /* green component of color cell 0 */
  palette[0][2]=0; /* blue component of color cell 0 */
  /* rgb entries range from 0 to 255 */
  /* 000 eq black, 255 255 255 eq white */

  palette[1][0]=1;
  palette[1][1]=1;
  palette[1][2]=1;
  /* etc */
  palette[255][1]=255;
  palette[255][2]=255;
  palette[255][3]=255;

  /* this has immediate effect */
  setvgapalette256(&palette);
}

/* example for fading any colorcell entry to black */
void fade(int num)
{
  int i,r,g,b;
  int step=10;
  float rf,gf,bf;
  DacPalette256 palette;

  getvgapalette256(&palette);

  r=palette[num][0];
  g=palette[num][1];
  b=palette[num][2];

  rf=(float)r/(float)step;
  gf=(float)g/(float)step;
  bf=(float)b/(float)step;

  for(i=0;i<step;i++){
    palette[num][0]=r-(int)((float)i*rf);
    palette[num][1]=g-(int)((float)i*gf);
    palette[num][1]=b-(int)((float)i*bf);
    setvgapalette256(&palette);
    /* add some delay */
  }
}

-------------------------
You realize of course that this is a very crude example, and I have just typed this from memory, not beeing able to actually test the code. There are lot of things to refine, e.g. checking that palette entries stay in the range 0-255 etc...

But I guess the principal is clear! Hope that gets you going !

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question