Avoiding typematic delays and slow graphics processing

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 1002 Views - Last Post: 27 September 2013 - 07:35 AM Rate Topic: -----

#1 semichaud1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 14-September 13

Avoiding typematic delays and slow graphics processing

Posted 14 September 2013 - 09:05 AM

Hi Guys,

I'm programming an open world rpg engine from scratch with Turbo Pascal. Been working on it for a few months now. There are two bits of the program I have not been able to find a solution for. (Note: I have been programming in general since 1997, started with basic then Turbo Pascal)

First of all, how do you get rid of the typematic delays. That is when for example you press the right arrow key for the player to move right the player will move once then there will be a delay then if you keep pressing right the player keeps moving. How is it that in games when you press right for example, that delay does not exist but the player keeps moving right until the key is not being pressed. I have used a boolean array in order to record whether a key is being pressed or not (see attached file for sample of Turbo Pascal code) but still get the delay.

The other problem I have is with graphics, whereby my logic and coding for displaying graphics is correct but when running the game in dosbox (only way to run Turbo Pascal app) with cycles maxed which means CPU (FX-6100) is running at max, the program does not execute fast enough and there is flicker on the screen which occurs when the program copies image from active page 1 and copies it to active page 0. Active page 1 is not seen by the player and is used to draw the pixels, which are then copied to active page 0 which is what the player sees. I suspect the program is not running fast enough as it depends on cpu to process graphics. I think I should be handling graphics processes to the gpu but how do I do that with Turbo Pascal? There are no tutorials for this (see attached files for sample of Turbo Pascal code).

I would appreciate your help on these. If you know how to solve those two problems in Turbo Pascal or even x86 asm which can be handled by Turbo Pascal, please let me know. If you can point me to perhaps c++ and perhaps some graphics library and keyboard handling libraries that would solve these problems I would be greatful. I have not found any tutorial online that enables me to do what I can do with Turbo Pascal so far. Especially c++ has no tutorial for graphics online. I would prefer solutions in Turbo Pascal and would like to avoid having to switch to another programming language as my rpg engine is quite big by now as I have been working on it for months now. I would consider switching to another programming language only if it solves the two problems mentioned above and only if there are clear tutorials from A to Z with every command clearly explained.

Thanks in advance everyone. Looking forward to your replies.

Is This A Good Question/Topic? 0
  • +

Replies To: Avoiding typematic delays and slow graphics processing

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9393
  • View blog
  • Posts: 35,278
  • Joined: 12-June 08

Re: Avoiding typematic delays and slow graphics processing

Posted 14 September 2013 - 09:38 AM

Turbo pascal? Really? Really?
*sigh*
... And you started this a few months ago?

It is hard to assist you in With a sunsetted tech, or any example of the code.

As it is, c++ is the got to game language... I can't imagine it not having avenues that fix your issues.
Was This Post Helpful? 0
  • +
  • -

#3 semichaud1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 14-September 13

Re: Avoiding typematic delays and slow graphics processing

Posted 14 September 2013 - 09:55 AM

View Postmodi123_1, on 14 September 2013 - 09:38 AM, said:

Turbo pascal? Really? Really?
*sigh*
... And you started this a few months ago?

It is hard to assist you in With a sunsetted tech, or any example of the code.

As it is, c++ is the got to game language... I can't imagine it not having avenues that fix your issues.


How would you implement player movemements while avoiding typematic delay?

If you can code it in c++, there should be equivalent code for Turbo Pascal. As I said I have been searching the net for two weeks and could not find a single c++ tutorial that would help regarding the problems I'm having. That is why I came to this forum. In the hope that the people in the game development section of this forum would know how to program a game. It is the lack of solutions in c++ that is causing me to stick with Turbo Pascal, and in addition I have been programming my engine from scratch for a few months now and am reluctant to start over from zero with c++ as there is no decent tutorial. My rpg engine so far can do everything from party, menus, graphics, maps, books, warp gates, etc. That took a long time to program.

The only thing that I would need really is a list of all the commands in c++ including 2d graphics and keyboard handling and that would be enough. That is how I learned Turbo Pascal by looking at the help doc that came with it and that listed all the commands in the language and their description.
Was This Post Helpful? 0
  • +
  • -

#4 axel1994  Icon User is offline

  • D.I.C Head

Reputation: 83
  • View blog
  • Posts: 167
  • Joined: 27-May 13

Re: Avoiding typematic delays and slow graphics processing

Posted 14 September 2013 - 10:37 AM

I have no idea about your problem.
But you can use OpenGL in C++ (opengl isn't a feature for c++, but you can use it in c++, and it's very low level)

This post has been edited by axel1994: 14 September 2013 - 10:38 AM

Was This Post Helpful? 0
  • +
  • -

#5 semichaud1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 14-September 13

Re: Avoiding typematic delays and slow graphics processing

Posted 14 September 2013 - 10:43 AM

View Postaxel1994, on 14 September 2013 - 10:37 AM, said:

I have no idea about your problem.
But you can use OpenGL in C++ (opengl isn't a feature for c++, but you can use it in c++, and it's very low level)


Thanks, I'm trying to get the opengl library now.
Was This Post Helpful? 0
  • +
  • -

#6 semichaud1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 14-September 13

Re: Avoiding typematic delays and slow graphics processing

Posted 14 September 2013 - 10:49 AM

View Postsemichaud1, on 14 September 2013 - 10:43 AM, said:

View Postaxel1994, on 14 September 2013 - 10:37 AM, said:

I have no idea about your problem.
But you can use OpenGL in C++ (opengl isn't a feature for c++, but you can use it in c++, and it's very low level)


Thanks, I'm trying to get the opengl library now.


Once again no thorough tutorial. They don't tell you everything you need to do to make the opengl commands work. If only I could get my hands on a proper and working tutorial.
Was This Post Helpful? 0
  • +
  • -

#7 semichaud1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 14-September 13

Re: Avoiding typematic delays and slow graphics processing

Posted 14 September 2013 - 10:54 AM

Honestly guys,

Go on google and type: c++ 2d graphics tutorial.

There are no relevant results.
Was This Post Helpful? 0
  • +
  • -

#8 axel1994  Icon User is offline

  • D.I.C Head

Reputation: 83
  • View blog
  • Posts: 167
  • Joined: 27-May 13

Re: Avoiding typematic delays and slow graphics processing

Posted 14 September 2013 - 11:01 AM

View Postsemichaud1, on 14 September 2013 - 05:54 PM, said:

Honestly guys,

Go on google and type: c++ 2d graphics tutorial.

There are no relevant results.

If you would wish to learn openGL then the OpenGL Programming Guide 8th edition or the OpenGL superbible 6th edition is the go to for learning.

This post has been edited by axel1994: 14 September 2013 - 11:02 AM

Was This Post Helpful? 0
  • +
  • -

#9 semichaud1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 14-September 13

Re: Avoiding typematic delays and slow graphics processing

Posted 14 September 2013 - 11:08 AM

Thank you. I'm downloading the pdf version now.

This post has been edited by GunnerInc: 14 September 2013 - 01:35 PM
Reason for edit:: Quote be gone

Was This Post Helpful? 0
  • +
  • -

#10 semichaud1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 14-September 13

Re: Avoiding typematic delays and slow graphics processing

Posted 14 September 2013 - 11:19 AM

The pdf had an error.

I found out that free pascal and SDL are compatible and found a tutorial online. I'm looking that up and if it works great that I can use free pascal for my rpg engine.
Was This Post Helpful? 0
  • +
  • -

#11 BBeck  Icon User is offline

  • Here to help.
  • member icon


Reputation: 581
  • View blog
  • Posts: 1,292
  • Joined: 24-April 12

Re: Avoiding typematic delays and slow graphics processing

Posted 14 September 2013 - 11:46 AM

You're going to have a very difficult time with this one. I'm surprised anyone is even still using Turbo Pascal. I studied with Turbo Pascal in college. I learned Object Oriented Programming with Turbo Pascal. At one time it was my favorite language. But that's been quite awhile back.

I don't think TP was designed to run on any OS after Windows 3.x. That alone is likely to give you some problems. What OS are you running this on?

Back in the day when TP was designed, the world of computers was very different. Essentially, back then everything was in DOS and all the buffers were exposed. Even Windows was in DOS.

With Windows 95, all of that changed. Now DOS (or the Command Console) is built into Windows instead of the other way around. Windows owns everything and that is a huge problem. Now you don't have access to all those buffers. Back in the day, people used to write data straight to the buffers and even read straight from the buffers to get good performance. Now, that's not even possible because Windows owns the buffers and isn't sharing. You have to ask Windows and it will get back to you when it feels like it.

This nearly spelled the end of Windows as a game platform, because games just couldn't run realistically fast enough in Windows. The Graphics Device Interface (GDI) was how Windows did graphics (now it's GDI+). And even that wasn't fast enough to be usable for games.

Microsoft quickly realized this was about to be a major disaster for them. So they came up with a solution: DirectX. DirectX is a COM object packaged basically as an API or library, that allows direct control of the graphics card. Especially in the current versions, you're practically writing your own graphics driver when using it. (OpenGL is roughly the same thing and came out roughly about the same time but is cross platform compatible unlike DX which is specifically for Windows.)

By giving programmers direct access to the graphics card, Microsoft made games in Windows possible. But basically there's no way around either DX or OpenGL, although computers are getting so fast these days, I might not be completely surprised if you could do 2D games with GDI+ now. But even most platforms that are more beginner friendly, such as XNA, run on top of OpenGL or DirectX, otherwise you have to go through Windows and that's likely to make performance unacceptable.

In the original versions of DirectX it did not handle input, such as from the Keyboard (neither does OpenGL to this very day). But Microsoft has included some additional libraries in the SDK for input and such. OR, you could use Windows for keyboard input and DX, or OpenGL for the graphics.

Anyway, if there is a way to do it, I would imagine it would be through Assembly Language calls to a library of some sort.

View Postsemichaud1, on 14 September 2013 - 01:19 PM, said:

The pdf had an error.

I found out that free pascal and SDL are compatible and found a tutorial online. I'm looking that up and if it works great that I can use free pascal for my rpg engine.


Yes. SDL may be a great solution for you. stayscrisp is our resident SDL expert and can probably answer SDL questions, plus he has some SDL tutorials (for C++) here on the forum.
Was This Post Helpful? 4
  • +
  • -

#12 semichaud1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 14-September 13

Re: Avoiding typematic delays and slow graphics processing

Posted 14 September 2013 - 12:06 PM

Thank you so much. You are the first person to explain the state of things to me.

I am going through the SDL tutorial for Free Pascal right now. It states that programming 2d rpgs, side-scrollers and other fast-paced games is possible and games can then be sold as SDL and free pascal are free. In the tutorial I see that SDL not only does graphics but also sound and keyboard input, and the unit has the keydown and keyup functions which will solve the typematic delay problem mentioned at the top of this post. The SDL unit also uses the graphics card for graphics which will solve the slow process of drawing, buffering and updating 2d graphics. If this all works like I expect it to, today will probably be the greatest day of my life so far, as I have been looking for a way to address those issues for many years.

The tutorial should cover all that I need for making an open-world rpg engine. If I get stuck I might contact StaysCrisp for some help if that's okay.

Thanks again.

This post has been edited by GunnerInc: 14 September 2013 - 01:34 PM
Reason for edit:: Quote be gone

Was This Post Helpful? 0
  • +
  • -

#13 semichaud1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 14-September 13

Re: Avoiding typematic delays and slow graphics processing

Posted 14 September 2013 - 02:59 PM

Guess what. The Free Pascal and SDL tutorial did not work. I follow everything to the letter and get an error saying SDL.dll missing from computer despite the fact that SDL.dll is copied to the system32 folder.
Was This Post Helpful? 0
  • +
  • -

#14 semichaud1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 14-September 13

Re: Avoiding typematic delays and slow graphics processing

Posted 14 September 2013 - 04:11 PM

View Postsemichaud1, on 14 September 2013 - 02:59 PM, said:

Guess what. The Free Pascal and SDL tutorial did not work. I follow everything to the letter and get an error saying SDL.dll missing from computer despite the fact that SDL.dll is copied to the system32 folder.


ok it works now with free pascal. had to copy the sdl.dll file to syswow32 since i'm using 64 bit version of win7. got the solution from a c++ sdl tutorial.

View Postsemichaud1, on 14 September 2013 - 04:10 PM, said:

View Postsemichaud1, on 14 September 2013 - 02:59 PM, said:

Guess what. The Free Pascal and SDL tutorial did not work. I follow everything to the letter and get an error saying SDL.dll missing from computer despite the fact that SDL.dll is copied to the system32 folder.


ok it works now with free pascal. had to copy the sdl.dll file to syswow32 since i'm using 64 bit version of win7. got the solution from a c++ sdl tutorial.


syswow64 sorry
Was This Post Helpful? 0
  • +
  • -

#15 semichaud1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 14-September 13

Re: Avoiding typematic delays and slow graphics processing

Posted 21 September 2013 - 09:20 AM

I have so many tutorials about c++ sdl, c++ opengl, c++ directx9, etc but none of them work. when compiling their example code there are errors due to graphics libraries not being compiled properly. I would have liked to learn opengl for c++ but it is very difficult to find a tutorial with examples that do not fail to compile despite having followed every step to set up opengl for c++ and going over the tutorial over and over again.

By the way, I still have not solved my problem of typematic delay which causes the player to move once then pause, then keep moving again when holding down a key on the keyboard. Here is the code for player movement:


x:=a[1]*11; y:=a[2]*11;
 setactivepage(1);
 putimage(x,y,p[1]^,normalput);
 setactivepage(0);
 putimage(x,y,p[1]^,normalput);
 freemem(p[1],size[1]);
 if keypressed then
 begin
  k:=readkey;
  for o[1]:=1 to 4 do
   keys[o[1]]:=false;
  keydelay:=10;
 end;
 if ord(k)=80 then keys[1]:=true;
 if ord(k)=72 then keys[2]:=true;
 if ord(k)=77 then keys[3]:=true;
 if ord(k)=75 then keys[4]:=true;
 if keys[1]=true then
 begin
  a[3]:=1;
  if objm[a[1],a[2]+1]=0 then a[2]:=a[2]+1;
 end;
 if keys[2]=true then
 begin
  a[3]:=2;
  if objm[a[1],a[2]-1]=0 then a[2]:=a[2]-1;
 end;
 if keys[3]=true then
 begin
  a[3]:=3;
  if objm[a[1]+1,a[2]]=0 then a[1]:=a[1]+1;
 end;
 if keys[4]=true then
 begin
  a[3]:=4;
  if objm[a[1]-1,a[2]]=0 then a[1]:=a[1]-1;
 end;
 setactivepage(1);
 x:=a[1]*11; y:=a[2]*11;
 size[1]:=imagesize(x,y,x+10,y+10);
 getmem(p[1],size[1]);
 getimage(x,y,x+10,y+10,p[1]^);
 cplayer;
 player;
 size[2]:=imagesize(x,y,x+10,y+10);
 getmem(p[2],size[2]);
 getimage(x,y,x+10,y+10,p[2]^);
 setactivepage(0);
 putimage(x,y,p[2]^,normalput);
 freemem(p[2],size[2]);
 if keydelay>0 then keydelay:=keydelay-1;
 if keydelay=0 then
 begin
  for o[1]:=1 to 4 do
   keys[o[1]]:=false;
 end;



Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2