<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Pong Help' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Pong Help' posted on the 'Pascal' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Thu, 20 Jun 2013 02:43:25 -0700</pubDate>
    <lastBuildDate>Thu, 20 Jun 2013 02:43:25 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Pong Help</title>
      <link>http://www.programmersheaven.com/mb/pasprog/346877/346877/pong-help/</link>
      <description>I have gotten a pong program to work but i need help on making it run faster. when the screen refreshes the bottom line blinks because of the slight time it takes to refresh, can that be easily fixed? Problem most likely is ineffiecent loops, but i don't know how to fix.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/346877/346877/pong-help/</guid>
      <pubDate>Sun, 15 Oct 2006 09:33:04 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Pong Help</title>
      <link>http://www.programmersheaven.com/mb/pasprog/346877/346878/re-pong-help/#346878</link>
      <description>: I have gotten a pong program to work but i need help on making it run faster. when the screen refreshes the bottom line blinks because of the slight time it takes to refresh, can that be easily fixed? Problem most likely is ineffiecent loops, but i don't know how to fix.&lt;br /&gt;
: &lt;br /&gt;
Do not refresh the whole screen, but only the paddles and the ball. This is a lot faster than a whole-screen refresh.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/346877/346878/re-pong-help/#346878</guid>
      <pubDate>Sun, 15 Oct 2006 09:46:12 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Pong Help</title>
      <link>http://www.programmersheaven.com/mb/pasprog/346877/346879/re-pong-help/#346879</link>
      <description>&lt;br /&gt;
: Do not refresh the whole screen, but only the paddles and the ball. This is a lot faster than a whole-screen refresh.&lt;br /&gt;
: &lt;br /&gt;
how do i do that?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/346877/346879/re-pong-help/#346879</guid>
      <pubDate>Sun, 15 Oct 2006 10:45:34 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Pong Help</title>
      <link>http://www.programmersheaven.com/mb/pasprog/346877/346880/re-pong-help/#346880</link>
      <description>&lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by zibadian at  2006-10-15 10:56:26&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: &lt;br /&gt;
: : Do not refresh the whole screen, but only the paddles and the ball. This is a lot faster than a whole-screen refresh.&lt;br /&gt;
: : &lt;br /&gt;
: how do i do that?&lt;br /&gt;
: &lt;br /&gt;
That greatly depends on the text/graphics. Nearly always it is done by removing the old position and painting it in the new one. Here is a simple example of a 0 moving along a line:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
  for i := 1 to 60 do
  begin
    if i = 1 then
      GotoXY(60, 2); write(' '); { remove old location }
    else
      GotoXY(i-1, 2); write(' '); { remove old location }
    GotoXY(i, 2); write('0'); { write the new location }
  end;
&lt;/pre&gt;&lt;br /&gt;
More advanced methods store the old location along with the new one, and update that with each step.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/346877/346880/re-pong-help/#346880</guid>
      <pubDate>Sun, 15 Oct 2006 10:56:14 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Pong Help</title>
      <link>http://www.programmersheaven.com/mb/pasprog/346877/346882/re-pong-help/#346882</link>
      <description>i shall try. that just adds a few more vars...one more question, code only works right now so that the entire screen refreshes at once, ei the ball doesn't move unless the paddles move or any other random key is pressed. how can this be fixed? something like adding a timed statement to the major loop? if so, how.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/346877/346882/re-pong-help/#346882</guid>
      <pubDate>Sun, 15 Oct 2006 11:22:10 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Pong Help</title>
      <link>http://www.programmersheaven.com/mb/pasprog/346877/346883/re-pong-help/#346883</link>
      <description>I am myself programming an ASCII game that refreshes the screen about 20 times per second. I use the below code, which writes directly to the screen through assembler code, and is thus REALLY fast.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
PROCEDURE FastWrite(Const Col, Row, Attr : Byte; Const Str : String); Assembler;
ASM
    PUSH   DS           {Save DS}
    MOV    DL,CheckSnow {Save CheckSnow Setting}
    MOV    ES,SegB800   {ES = Colour Screen Segment}
    MOV    SI,SegB000   {SI = Mono Screen Segment}
    MOV    DS,Seg0040   {DS = ROM Bios Segment}
    MOV    BX,[49h]     {BL = CRT Mode, BH = ScreenWidth}
    MOV    AL,Row       {AL = Row No}
    MUL    BH           {AX = Row * ScreenWidth}
    XOR    CH,CH        {CH = 0}
    MOV    CL,Col       {CX = Column No}
    ADD    AX,CX        {(Row*ScreenWidth)+Column}
    ADD    AX,AX        {Multiply by 2 (2 Byte per Position)}
    MOV    DI,AX        {DI = Screen Offset}
    CMP    BL,7         {CRT Mode = Mono?}
    JNE    @@DestSet    {No  - Use Colour Screen Segment}
    MOV    ES,SI        {Yes - ES = Mono Screen Segment}
    XOR    DX,DX        {Force jump to FWrite}
  @@DestSet:            {ES:DI = Screen Destination Address}
    LDS    SI,Str       {DS:SI = Source String}
    CLD                 {Move Forward through String}
    LODSB               {Get Length Byte of String}
    MOV    CL,AL        {CX = Input String Length}
    JCXZ   @@Done       {Exit if Null String}
    MOV    AH,Attr      {AH = Attribute}
    OR     DL,DL        {Test Mono/CheckSnow Flag}
    JZ     @@FWrite     {Snow Checking Disabled or Mono - Use FWrite}
{Output during Screen Retrace's}
    MOV    DX,003DAh    {6845 Status Port}
  @@WaitLoop:           {Output during Retrace's}
    MOV    BL,[SI]      {Load Next Character into BL}
    INC    SI           {Update Source Pointer}
    CLI                 {Interrupts off}
  @@Wait1:              {Wait for End of Retrace}
    IN      AL,DX       {Get 6845 status}
    TEST    AL,8        {Vertical Retrace in Progress?}
    JNZ     @@Write     {Yes - Output Next Char}
    SHR     AL,1        {Horizontal Retrace in Progress?}
    JC      @@Wait1     {Yes - Wait until End of Retrace}
  @@Wait2:              {Wait for Start of Next Retrace}
    IN      AL,DX       {Get 6845 status}
    SHR     AL,1        {Horizontal Retrace in Progress?}
    JNC     @@Wait2     {No - Wait until Retrace Starts}
  @@Write:              {Output Char and Attribute}
    MOV     AL,BL       {Put Char to Write into AL}
    STOSW               {Store Character and Attribute}
    STI                 {Interrupts On}
    LOOP   @@WaitLoop   {Repeat for Each Character}
    JMP    @@Done       {Exit}
{Ignore Screen Retrace's}
  @@FWrite:             {Output Ignoring Retrace's}
    TEST   SI,1         {DS:SI an Even Offset?}
    JZ     @@Words      {Yes - Skip (On Even Boundary)}
    LODSB               {Get 1st Char}
    STOSW               {Write 1st Char and Attrib}
    DEC    CX           {Decrement Count}
    JCXZ   @@Done       {Finished if only 1 Char in Str}
  @@Words:              {DS:SI Now on Word Boundary}
    SHR    CX,1         {CX = Char Pairs, Set CF if Odd Byte Left}
    JZ     @@ChkOdd     {Skip if No Pairs to Store}
  @@Loop:               {Loop Outputing 2 Chars per Loop}
    MOV    BH,AH        {BH = Attrib}
    LODSW               {Load 2 Chars}
    XCHG   AH,BH        {AL = 1st Char, AH = Attrib, BH = 2nd Char}
    STOSW               {Store 1st Char and Attrib}
    MOV    AL,BH        {AL = 2nd Char}
    STOSW               {Store 2nd Char and Attrib}
    LOOP   @@Loop       {Repeat for Each Pair of Chars}
  @@ChkOdd:             {Check for Final Char}
    JNC    @@Done       {Skip if No Odd Char to Display}
    LODSB               {Get Last Char}
    STOSW               {Store Last Char and Attribute}
  @@Done:               {Finished}
    POP    DS           {Restore DS}
END;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Note that when you use this procedure, the top left coordinate is (0,0). So if you want to write a red 'X' to coordinate 79,20 (the last coordinate on the 21st line), you just write:&lt;br /&gt;
&lt;br /&gt;
FastWrite(79, 20, 12, 'X'); (where 12 is the color)&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/346877/346883/re-pong-help/#346883</guid>
      <pubDate>Sun, 15 Oct 2006 11:41:46 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Pong Help</title>
      <link>http://www.programmersheaven.com/mb/pasprog/346877/346884/re-pong-help/#346884</link>
      <description>: i shall try. that just adds a few more vars...one more question, code only works right now so that the entire screen refreshes at once, ei the ball doesn't move unless the paddles move or any other random key is pressed. how can this be fixed? something like adding a timed statement to the major loop? if so, how.&lt;br /&gt;
: &lt;br /&gt;
Use the Keypressed() function to detect if there is a keypress. Then you can use ReadKey() to get the key-value.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/346877/346884/re-pong-help/#346884</guid>
      <pubDate>Sun, 15 Oct 2006 11:46:09 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Pong Help</title>
      <link>http://www.programmersheaven.com/mb/pasprog/346877/346887/re-pong-help/#346887</link>
      <description>&lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by acidicburn at  2006-10-15 12:3:38&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: Use the Keypressed() function to detect if there is a keypress. Then you can use ReadKey() to get the key-value.&lt;br /&gt;
:thx this should help a lot. So keypressed() detects if a key was pressed. so how would i use it in a program. if keypressed then? also, i don't know any assembly, i just started using pascal about a month ago. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/346877/346887/re-pong-help/#346887</guid>
      <pubDate>Sun, 15 Oct 2006 12:02:44 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Pong Help</title>
      <link>http://www.programmersheaven.com/mb/pasprog/346877/346888/re-pong-help/#346888</link>
      <description>: &lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by acidicburn at  2006-10-15 12:3:38&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: : Use the Keypressed() function to detect if there is a keypress. Then you can use ReadKey() to get the key-value.&lt;br /&gt;
: :thx this should help a lot. So keypressed() detects if a key was pressed. so how would i use it in a program. if keypressed then? also, i don't know any assembly, i just started using pascal about a month ago. &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
Here's an example, which stops if you press enter:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
var
  i: integer;
begin
  i := 0;
  repeat
    GotoXY(1, 1);
    write(i);
    i := (i+1) mod 999;
    if Keypressed then
    begin
      if Readkey = #13 then
        Break;
    end;
  until i = 1000;
end;
&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/346877/346888/re-pong-help/#346888</guid>
      <pubDate>Sun, 15 Oct 2006 12:10:57 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Pong Help</title>
      <link>http://www.programmersheaven.com/mb/pasprog/346877/346890/re-pong-help/#346890</link>
      <description>i got it all working, thanks alot! it doesnot lag and the ball moves on its own, thanks again!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/346877/346890/re-pong-help/#346890</guid>
      <pubDate>Sun, 15 Oct 2006 12:49:36 -0700</pubDate>
      <category>Pascal</category>
    </item>
  </channel>
</rss>