lab2

 This blog is mainly focus on the lab2 which has provided the original code of a sharp with blue color  move diagonal in the image. And in the class, we use the mob programming to finish the work. Me as the presenter who just watch and give suggestion to the driver who shared their screen and modify the orginal code. We have three tasks for this lab. The first one is selecting a starting position for X and Y with different position. This is quite easily to solve. We have just changed the line of code 

LDA #$00

STA XPOS

STA YPOS  to  

LDA #$05        

STA XPOS        


LDA #$0A      

STA YPOS

This allow us to change the X position to 5 and Y position to 10. And the next question is selecting a X increment that is -1 or +1 and Y increment that is -1 or 1. This question is also not difficult. We can first define the x increment and y increment at top of the code like define X_INCREMENT $22  ; X increment

define Y_INCREMENT $23 ; Y increment  and then initialized the x and y increment like 

LDA #$01         ; For +1 increment

STA X_INCREMENT   ; Store in zero-page variable

STA Y_INCREMENT   ; Store in zero-page variable

This allow us to set the x and y increment. The third question is Successively move the graphic by adding the X and Y increments to the graphic's X and Y position.  This can solved by adding codes in the loop. The code will be 

LDA XPOS

  CLC

  ADC X_INCREMENT   ; Add the X increment

  STA XPOS


  LDA YPOS

  CLC

  ADC Y_INCREMENT   ; Add the Y increment

  STA YPOS

Hence when the loop is working, the position of the graph will keep continuing changing by the x and y increment.

The forth question is kinda a difficult and due to complexity of the question and time limit of the class, we didn't solve the forth quetsion which is Make the graphic bounce when it hits the edge of the bitmapped screen, both vertically (when it hits the top/bottom) and vertically (when it hits the left/right edge). I have tried to solve it after class, and here is my thought and work.

We need to define the screen boundaries and check for the boundaries condition in the main loop. By chekcing the boundaries we can use code

LDA XPOS

  CMP #SCREEN_WIDTH - 1  ; Check if XPOS hits the right edge

  BNE CheckLeftEdge 

and 

LDA XPOS

  CMP #$00           ; Check if XPOS hits the left edge

  BPL CheckVertical  ; Branch if positive (not less than zero)

After the program has get these condition, it will reverse the x or y increment so that the image can bounce back when it hit the edge of the screen. 

In this lab, I have learned that how to change the position of starting point of the graph and how to define the x or y direction increment. Also I have done some research about the condition in main loop for checking the position of graph so that we can change the x or y increment  for some purpose. Also, this is my first time to get familiar with the mob programming. I think this way is also an good way for the team to work together especially for the tricky questions since we can communicate when we are coding.

评论

此博客中的热门博文

Project-stage 2

Project- Stage 1

lab1