Jump to content
  • entries
    39
  • comments
    57
  • views
    124,760

Ball Horizontal Counter


Guest

985 views

The final graphic element we need to look at is the ball. Like the score this is a pretty complex, but very clever circuit.

 

The first part of the circuit we will look at is the horizontal counter. This circuit controls the horizontal location, motion and size of the ball. Later we will look at a similar circuit that controls the vertical.

 

blog-184-1126963975_thumb.jpg

 

The main part of the circuit is a 9 bit counter composed of G7 and H7, which are synchronous counters, and G6. When the counter reaches a count of 512, the output of G5 will go low, this will reload the starting count on the next clock pulse. Each chip in the synchronous counter is clocked by the same input clock (in this case the main pixel clock), but the counting is enabled or disabled by the two enable inputs on pin 7 and 10. Pin 7 on G7 is always high and pin 10 is connected to ~HBLANK so this counter will only be enabled when we are not in HBLANK which starts at horizontal position 80 on each line. Pin 10 on H7 is always high and pin 7 is connected to the carry out of G7, so when it reaches a count of 15, H7 gets enabled for one clock to increment the next 4 bits of the counter. The carry output of H7 is used to clock G6 which will toggle on each pulse. We will talk about the source of the CLR input in a later on.

 

As I mentioned above the counter counts up to 512, but it does not start at 0. If you look at the preset inputs (pins 3, 4, 5, 6) to the counters bits 3 and 7 are wired high, and bits 0 and 1 are connected to Aa and Bb. This means that the counter will start at a count of 136, 137, 138, or 139 depending on the state of the Aa and Bb inputs. So if we take 512 (the max count) - 136 (the start count) + 80 (end of HBLANK) we come out with 456. So depending on the state of Aa and Bb we will get 456, 455, 454, or 453 count per line. If you remember back to the horizontal counter section, there are 454 counts per horizontal line. When Bb = 1 and Aa = 0, the ball counter will be in sync with the horizontal counter, so it will reset at the same horizontal position on the screen on every line. If Aa=1 and Bb = 1 then the ball counter will be one clock less then the horizontal counter, so on each line it will reset one pixel sooner then the line before, thus the reset point will drift to the left. If Aa=1 and Bb = 0 the ball counter will be one clock more then the horizontal counter, so on each line it will reset on pixel later then the line before, thus the reset point will drift to the right. Aa = 0 and Bb = 0 is not a state that is used.

 

The signal /HVID is the horizontal portion of the ball video output and is controlled by NAND gate H6. The output will go low when the counter reaches a count of 508, and will stay low for the next 4 counts until the counter resets at 512. This will make the ball four pixels wide.

 

You can begin to see how this would control the horizontal motion of the ball, but remember these moves happen once per line, not once per frame, so it takes careful manipulation of Aa and Bb to control the ball properly. You will see how this happens in the next section.

2 Comments


Recommended Comments

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...