Thread: Video

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    2

    Video

    Hi,
    I have been trying to make my text blink by changing a byte but with no success. I'd like to know how to have access to my video. So can you help me? thx

    I 7 I 6 I 5 I 4 I 3 I 2 I 1 I 0 I
    ---------------------------

    Foreground : bits 0-2
    Intense : bit 3
    Background : bits 4-6
    Blinking : Bit 7

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Assuming you have access to the attribute byte (you're doing text mode direct memory video access in DOS right)

    To set the flash bit, do this
    byte = byte | 0x80;

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    2
    0x80 does'nt work... I can only change the foreground color.

    #include <stdio.h>
    #include <conio.h>
    #include <stdlib.h>
    #include <dos.h>

    int main () {
    int far *farptr;
    int i;
    unsigned char ch;
    farptr = (int far *) 0xB8000000;

    clrscr ();
    printf ("Press a key and : ");
    while ((ch= getch ()) != '\r')
    for (i = 400; i < 2000; i++)
    *(farptr+i) = ch | 0x700;

    return (0);
    }

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    752
    This is compiler dependent, so I can't be too helpful... but I can give you an example of how I did something like this in DJGPP...
    Code:
    struct charac
    {
     char charac;
     char color;
    };
    My video buffer was an array of these structures, and to display the screen, I used the puttext function...
    Code:
     puttext (x_offset, y_offset, x_offset - 1 + Disp_Width,
              y_offset - 1 + Disp_Depth, map);
    To just print text with certain attributes however, I suspect I'd have ended up using a different function...
    Code:
    textattr(BLINK | WHITE);
    putch('1');
    All this might be helpful if you're using the same compiler as me... but in all likelyhood, you are not. What I suggest is finding a description of your compiler's library functions, and look for ones for console IO. Reading those help files is pretty much the only way to get this done really.
    Callou collei we'll code the way
    Of prime numbers and pings!

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    > 0x80 does'nt work... I can only change the foreground color.
    That's because you're accessing memory all wrong - its an array of bytes, not int's

    Characters are at the even bytes
    Attributes are at the odd bytes

    Eg, to set the attribute of the first character
    unsigned char far *farptr;
    farptr = (unsigned char far *) 0xB8000000;
    farptr[1] |= 0x80;


    > *(farptr+i) = ch | 0x700;
    *(farptr+i) = ch | 0x8000;
    might work

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    752
    ... okay, I feel fairly silly now, didn't realise that you already knew how to map video. I'm unfamiliar with the far syntax, but I'm pretty sure that you don't want to be using int pointers. Assuming that your short is 2 bytes, you prolly want to use that.
    Callou collei we'll code the way
    Of prime numbers and pings!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem With My Box
    By HaVoX in forum Tech Board
    Replies: 9
    Last Post: 10-15-2005, 07:38 AM
  2. Codec Bitrates?
    By gvector1 in forum C# Programming
    Replies: 2
    Last Post: 06-16-2003, 08:39 AM
  3. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 07:57 PM
  4. Drawing a circle in a video captured frame
    By skyhigh in forum C Programming
    Replies: 2
    Last Post: 12-05-2001, 01:00 AM