Lab 3a: Assembly Math Lab (Theory)

A. Introduction:

In this lab, we will be using Assembly Math operations to create sereval interactive projects on the bitmap

B. Project – Pong Game:

I. Summary:

The Pong game is a classical game where 2 players use their paddle to bounce a ball between them. A score is counted when the ball passes a player’s paddle and hit the edge behind their paddle. For the simplicity of the project, we will only create 1 paddle and the ball will bounce off the other 3 edges. The game is over when the ball hit the edge behind our paddle

II. Requirements:

There are 3 required conditions for the project:

  • There must be a paddle to bounce the ball and it can move to the left and right
  • The ball must bounce off the 3 edges and the paddle except the one behind the paddle
  • The ball must have velocity to control the speed of the game since the speed of the ball might be too fast

III. Concept:

1/ Coordinate:
  • To allocate the position of the ball and to check whether it has collided with the edges. We need to have 2 values the represent the vertical and horizontal values
  • The ROW represents the row that the ball is at, this can be used to compare with the last row in the bitmap for bouncing operation
  • Similarly, the COL (column) represents the column that the ball is at and can be used to determine the bouncing operation
2/ Paddle:
  • First, we need to draw the paddle at the last line of the bitmap. This can be done by using a loop to color each bit from the start until we reach the last pixel of the paddle.
  • The value of the paddle will be used for comparison to check if the ball hits the paddle or not
  • Before decide to bounce off the paddle, we needs to check if the ball is at one line before the paddle and compare it (using ROW for both comparisons) with the value of paddle stored in memory
  • To make sure that the velocity of the ball doesn’t go too high, we randomize it and perform an additional operation to ensure this
3/ Edges:
  • We need to use ROW and COL to see whether the ball has reached the edges
  • In the case of left and right edges, we will use the COL value because these edges are vertical. If the COL value is equal to the leftmost (#$00) and rightmost (#$1F) pixel then the ball has collided
  • Similar for the top and bottom edges, the difference is that we ues the ROW value instead because these are horizontal. The top and bottom pixel are also #$00 and #$1F respectively
  • However, if the ball reached the last line (bottom edge) instead of second to last line (paddle) and did not hit the paddle (comparison above in the paddle section), we clear the screen and the game is over
4/ Other components:
  • There are other components such as how do we determine the location of the ball across the bitmap with different page, keystroke capture for paddle’s movement. These will be explained in the next article for lab 3

One thought on “Lab 3a: Assembly Math Lab (Theory)

Leave a comment