What is the fastest ay to draw an array onto the screen in c++ 3.1?

Hey ppl me and my friends were uberbored so we decided to write something in c++ using Borland C++ 3.1.
So now im beginning to ask myself whats the fastest an to copy an array onto the screen, like the logical screen thing. cuz we need lots of things onscreen to move and stuff.

Im currently doing it like pokeb(0xA000, y*320 + x, color) for each pixel and I guess there should be a faster way then that.

So if any2 knows how to do that, plz help.

Thanks.

Last edited on
pokeb()? That's not even standard. Drop Borland as soon as possible.
memcpy() is the fastest data copy function.
http://www.cplusplus.com/reference/clibrary/cstring/memcpy.html

And I'm wondering what 0xA000 is.
0xA000 is the address of the video memory.

so pokeb(0xA000, y*320 + x, color) is he sam as putpixlel(x,y,color) but better in some ways.

Also, I figured im a noob in c++ pointers, since i couldnt use memcpy =(

u see i got two arrays:

1
2
3
unsigned char far virtscreen[319][199];

unsigned char far *screen = (unsigned char far *) MK_FP(0xA000,0);


so i need to copy the contents of tha virtscreen array into the screen array =)

omg help i can hardly undrstand myself T_T
Here's my advice: Don't use Borland's library. It's not portable and it's crap.
ok fine. what do u use.
My favorite for portability and ease of use is the SDL.

http://www.libsdl.org/
Here. Ive solved my problem. Posting the result for those ho may have the same question in tha future:

a) screen array should look like
unsigned char far *screen = (unsigned char far*) MK_FP(0xA000, 0);

b) copying should look like
_fmemcpy(screen, virtscreen, 64000);

Works for me =)

BTW hat do you mean under Borland`s library? Graphics.h? Well im not using it, thats why I started using pokeb and virtual screens in the first place =)

Thanks anyway.
Last edited on
I'm pretty sure pokeb() is part of Borland, as well.
peek and poke and variants are BASIC commands. I seem to recall that an old Turbo C had them, but they disappeared rather quickly seeing you could just MK_FP() any address you wanted.

Are you running this under Win32? And it works? Wow...

You should be able to use fmemcpy() without the leading underscore.

The next thing you should do is start googling around "vga mode x" and have some fun!

BTW, helios, why the anti-Borland stuff?
Last edited on
It just pisses me off that teachers don't bother to mention that that damn conio.h ("conio", by the way, sounds awfully close to a Spanish dirty word, which makes making fun of Borland a trivial task) is supported by exactly zero other compilers. To me it's blasphemy that a non-standard header can be statically linked without explicitly telling the compiler to do the linking.
Yes, I know that Boost also does this, but if you're using Boost you know very well that it's non-standard and that you'll need to tell whoever uses your code that they'll need to link to it.
Not everybody knows that conio.h is non-standard, so they get an ugly surprise when trying to compile the code on a different compiler.

I hate Borland (at least Borland C++) ever since I realized this.

And I'm not too crazy about some of the things VC++ does, either.
Last edited on
I agree that conio.h and getch() and the like are ancient zombie cruft... but I can't think of many DOS/Win32 compilers that don't have it.

I used to think that Borland invented it, but I just recently learned that it was invented by Microsoft. Borland just made the library go straight to the hardware (as a default option) instead of through the DOS INT 21h service vectors.

But Borland did (and still does) produce a very good compiler suite. I'm not going to lynch any one just yet. That isn't to say they haven't done some dumb things too...


However, I agree 100% with helios about how non-standard and even dangerous things are still being taught as if they were the Right Thing. Unfortunately, many places in the world are only now becoming "technologically literate", as it were.

India, for example, (not to pick on any one place --there is nothing wrong with India) is now supporting a lot of IT infrastructure. They are only right now experiencing the IT revolution that we in the USA ans UK and Spain and the like saw during the mid to late 80's. As a result, Indian kids go to the University and learn to program using... Borland C++ 4.01 or some other ancient relic --something that doesn't cost a gazillion US dollars to use, has existed for decades, and that a large percentage of professors are actually qualified to teach. The closer you close the gap to the "modern age", the fewer people you will meet in India who have real, industrial experience with modern language standards --either by their own past jobs, or by their own schooling, or by their own independent study.

(AFAIK, India currently has the fastest-growing IT infrastructure around the world. There are a lot of places a decade behind India. Those of us in the West [North America and Western Europe] have a relatively biased view because we take certain knowlege or practice for granted --whereas those who are just now becoming computer-literate really are trying to play catch-up in a giant's stadium.)
1
2
3
4
5
6
7
8
9
10
#include <conio.h>
#include <iostream.h>

void main()
  {
  clrscr();
  cout << "Press a key now";
  getch();
  cout << "Thank you!";
  }

There are so many things wrong with that... but it looks fine to many people simply because they don't know any better. (Yet)


In English the word is pronounced with vowels ah and ai and oh, so it is less potentially crude. console I/O.

:-\
Last edited on
Topic archived. No new replies allowed.