ascii pong half way - how to optimise code ?,
Members - Reputation: 122
Posted 14 July 2001 - 03:21 AM
Posted 14 July 2001 - 03:43 AM
Then you can write directly to those words. I do not know now if high or low byte is the color or the character, but you can try it. In TC it saves you from using
#define screen(x,y) ((unsigned short *) (0xB8000000)) [x+80*y]
After which you may do
screen(17,22) = 0x0707 (grey dot, perhaps a ball).
Unfortunately you cannot fix up x/y in Pascal - they are swapped.
If you use C but a more advanced compiler, try compiling it in Turbo C, which generates small DOS executables.
2) Ralf Brown''s Interrupt List
3) Perhaps you can. Double buffering is easy (just make a screen array somewhere), look at memcpy. You could also do page flipping (see Interrupt List, somewhere in INT 10h). An interesting way of improving textmode graphics is by loading your own textmode font - but you do not have an _ASCII_ pong game after that.
5 a/b) depends on your compiler. A _good_ compiler generates equal code in these cases. But you can give your compiler a hint: do what is better to read. Do not use ifs do distinguish 100 cases; do not use switch to distinguish exactly two.
If you do not have Turbo C: http://community.borland.com/museum . It is a rather old C/C++ compiler (no STL), but since you did it in C it should work. And avoid
Just look at the code generated for a
combination compared to direct graphics memory access.
BTW: If you have Turbo C, you also have a good C online help and graphics library. However, if you want to make bigger projects, get DJGPP (http://www.delorie.com) or Mingw32 (http://www.mingw32.org) and the Allegro graphics library (http://alleg.sourceforge.net), which runs on Windoze, DOS and Linux.
Members - Reputation: 181
Posted 14 July 2001 - 04:10 AM
"Elvis is alive. He is Barney the purple dinosaur. He is the pied piper that leads our children into the wages of sin and eternal damnation."
Members - Reputation: 123
Posted 14 July 2001 - 03:36 PM
Original post by Midnight Coder
An ASCII pong game should run pretty fast in the first place, and because it doesn''t have any real graphics, there''s no optimization you can do their. The only things you can do is optimize some of the math and stuff that the game uses.
*** I moved this response becuase I deleted the double posted topic ***