I want to make a fast scroll

This is a discussion on I want to make a fast scroll within the C Programming forums, part of the General Programming Boards category; Hi. I-m trying to write a program that can scroll the characters on the screen fast. I know that characters ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Location
    Mexico City
    Posts
    33

    I want to make a fast scroll

    Hi. I-m trying to write a program that can scroll the characters on the screen fast. I know that characters on the screen are actually bytes in some location of RAM memory. The problem is, I dont know what memory locations correspond to the screen.

    And, if i Knew, how can I acces those location. Say..

    #define UPPER_LEFT_CORNER_LOCATION 0xFFAD // this number is fiction

    int main () {
    // what should it be?
    char *p;
    // or?
    void *p;

    // then..


    p= UPPER_LEFT_CORNER_LOCATION;

    // so Im pointing to the first position on the screen

    *p= 'A';

    //... and Im putting and 'A' right there



    }

    The problems: 1) I dont know the locations that represent the screen, and 2) How can I point there if I find it.

    I would aprecciatte if someone tells me. Thanks in advance.
    If you want to be happy one hour: take a nap
    if you want to be happy one day: go fishing
    If you want to be happy a year: inherit a fortune
    if you want to be happy for a life time: HELP SOMEBODY
    chinisse say.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    This will depend on your OS and platform. There is no set number that works across the board. You'll want to look at graphics libraries for your platform to see really what you can get away with. Visit Google.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    There are some extremely fast ways to scroll the screen...but unfortunately if you are in console mode you probably will not be able to use any of them.

    I'm not sure if XP will even let you get a pointer to 0xB800 which is where text memory resides and most, if not all, text modes use.

    You will need to get a far pointer to this (far being it is our of your segment). But XP may not allow far pointers, but theoretically it should if it is running in virtual 8086 mode which it should be. But again there is no such thing as far in 32-bit code. Far used to denote, as I said, that the segment was outside of your segment. But since in protected mode there are no segments (well there are...but I don't want to get into that) the far pointer is pretty much a thing of the past. Memory is pretty much linear now and you can get a pointer to any chunk of it (within certain restrictions of the OS, of course).

    The old code that you would use to do what you want is:

    Code:
    //This is only needed for MK_FP which you could just as easily
    //create yourself if you don't have dos.h
    
    #include <dos.h>   //may not have this
    
    typedef unsigned char BYTE;
    
    BYTE far*Screen=(BYTE far *)MK_FP(0xB800,0);
    
    Screen[location]=value;
    In text modes all even numbered locations specify what character to put there and the odd ones denote which colors -> foreground and background are stored in one byte :

    ((foreground<<4)+background)

    I believe that is the formula. Foreground is stored in the high byte and background in stored in the low byte.



    But again your best bet is to dump the console and go with something like DirectX or OpenGL. DirectX is really easy to get up and running and for creating a DOS-like 32-bit environment in which to code in. You basically create one window...tell windows to leave you alone, start the message loop, and forget about 99% of the API from then on....which is nice.

    There are many books on DirectX and OpenGL and you would do yourself a great service by purchasing one.
    Last edited by VirtualAce; 04-28-2004 at 10:37 PM.

  4. #4
    Registered User
    Join Date
    Nov 2001
    Location
    Mexico City
    Posts
    33
    Quote Originally Posted by Bubba
    There are some extremely fast ways to scroll the screen...but unfortunately if you are in console mode you probably will not be able to use any of them.

    I'm not sure if XP will even let you get a pointer to 0xB800 which is where text memory resides and most, if not all, text modes use.

    You will need to get a far pointer to this (far being it is our of your segment). But XP may not allow far pointers, but theoretically it should if it is running in virtual 8086 mode which it should be. But again there is no such thing as far in 32-bit code. Far used to denote, as I said, that the segment was outside of your segment. But since in protected mode there are no segments (well there are...but I don't want to get into that) the far pointer is pretty much a thing of the past. Memory is pretty much linear now and you can get a pointer to any chunk of it (within certain restrictions of the OS, of course).

    The old code that you would use to do what you want is:

    Code:
    //This is only needed for MK_FP which you could just as easily
    //create yourself if you don't have dos.h
    
    #include <dos.h>   //may not have this
    
    typedef unsigned char BYTE;
    
    BYTE far*Screen=(BYTE far *)MK_FP(0xB800,0);
    
    Screen[location]=value;
    In text modes all even numbered locations specify what character to put there and the odd ones denote which colors -> foreground and background are stored in one byte :

    ((foreground<<4)+background)

    I believe that is the formula. Foreground is stored in the high byte and background in stored in the low byte.



    But again your best bet is to dump the console and go with something like DirectX or OpenGL. DirectX is really easy to get up and running and for creating a DOS-like 32-bit environment in which to code in. You basically create one window...tell windows to leave you alone, start the message loop, and forget about 99% of the API from then on....which is nice.

    There are many books on DirectX and OpenGL and you would do yourself a great service by purchasing one.


    Thank you Bubba.
    Ill try that code you just wrote, I have paste it and put in a file.
    Im using Bloodshed C++ 4 on Windows 98.

    I think Im getting behind, Ill try these DirectX and OpenGL; thank you very much.

    Gustaff.
    If you want to be happy one hour: take a nap
    if you want to be happy one day: go fishing
    If you want to be happy a year: inherit a fortune
    if you want to be happy for a life time: HELP SOMEBODY
    chinisse say.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Win32 Common Controls in C++, how do i make and use them?
    By C+noob in forum Windows Programming
    Replies: 6
    Last Post: 01-09-2006, 10:53 AM
  2. want to make this small program...
    By psycho88 in forum C++ Programming
    Replies: 8
    Last Post: 11-30-2005, 01:05 AM
  3. When am I ready to make games?
    By blankstare77 in forum Game Programming
    Replies: 7
    Last Post: 08-25-2005, 07:23 PM
  4. socket send() exits app unexceptively
    By Kleid-0 in forum C Programming
    Replies: 9
    Last Post: 07-25-2005, 08:29 AM
  5. Horizontal Scroll Bars with CListBox
    By Malek in forum Windows Programming
    Replies: 1
    Last Post: 04-10-2003, 09:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21