hi. i need to program a pong/breakout game. its virtually all done for me but i need to add a few things.

at the moment i need to change the balls position and make it collide with the walls and paddle. easy enough but im obviously not understanding the use of data registers properly as it doesnt work. im just going to paste in a little but of the code as youll probaly spot how im using it wrong (the variables and constants are declared elsewhere)

      CMP.W #play_area_left, ball_row_position
      BLE HitLeft
   
      CMP.W #play_area_top, ball_col_position
      BLE HitTop
     
      ADD.W #ball_row_displacement, ball_row_position
      ADD.W #ball_col_displacement, ball_col_position     
     
      BSR RenderBall
      RTS
     
HitLeft
      MOVE.W #ball_displacement, ball_row_displacement
      RTS
HitTop
      Move.W #ball_displacement, ball_col_displacement
      RTS

Posted on 2009-01-07 17:58:22 by cool mr croc
      CMP.W #play_area_left, ball_row_position
      BLE HitLeft
   
      CMP.W #play_area_top, ball_col_position
      BLE HitTop

Not sure, but usually 'column' means horizontal position and 'row' means vertical position.
Posted on 2009-01-09 01:06:13 by ti_mo_n

      CMP.W #play_area_left, ball_row_position
      BLE HitLeft
   
      CMP.W #play_area_top, ball_col_position
      BLE HitTop

Not sure, but usually 'column' means horizontal position and 'row' means vertical position.
yeh but the problem is that the program doesnt display the ball, so its how im using values thats the problem i think.
Posted on 2009-01-09 08:12:52 by cool mr croc
Disagree - Columns are vertical yes - so they describe the Horizontal position (the nth column is the nth horizontal position).

Oh, I'd need to see the code that displays the ball to answer that question... however it seems odd to me that you are adding the ball's x and y (column and row) to the ball_col_displacement and ball_row_displacement variables... how are they used in the renderball function? I assume your renderball function prints a character at (row, column) ... may I see it?
Posted on 2009-01-09 08:29:38 by Homer
RenderBall

      move.b  #1,d1
      move.b  #93,d0
      trap    #15            Set pen width
      move.l  #WHITE,d1
      move.b  #80,d0
      trap    #15            Set pen color for ball     
      move.l  #WHITE,d1
      move.b  #81,d0
      trap    #15            Set fill color for ball
     
      move.w  ball_col_position,d1
      move.w  ball_row_position,d2
      move.w  ball_col_position,d3
      add.w  #ball_dimension,d3
      move.w  ball_row_position,d4
      add.w  #ball_dimension,d4
      move.b  #88,d0        Draw filled circle
      trap    #15
     
      RTS
Posted on 2009-01-09 08:45:55 by cool mr croc
and yes i got row and column mixed up originally, but my problem is using the sub routine to change values. like i use hitleft to invert the ball_col_displacement but its stopping the program from functioning.
Posted on 2009-01-09 08:49:42 by cool mr croc
this may be easier to look at, its what i have at the moment. the ball moves until it hits the right border then dissapears. im still able to move the bat so the program is still functioning. i look at it in c++ terms, all im trying to do is to run a function that changes the value of a global variable, but i think its my use of data registers which is at fault

*****************************************************
*
* BallMove
*
* Adjust ball position and test ball/bat collision
* or lost ball
*
*****************************************************
BallMove

      BSR EraseBall
     
      CMP.W #play_area_right-(ball_displacement/2)-border_width, ball_col_position
      BGE HitLeft
     
      MOVE.W ball_col_displacement, d1
      MOVE.W ball_row_displacement, d2
      ADD.W d2, ball_row_position
      ADD.W d1, ball_col_position
      BSR RenderBall
      RTS
HitLeft   
      MOVE.W #-ball_displacement, d1
      MOVE.W d1, ball_col_displacement
      RTS

           
*****************************************************
Posted on 2009-01-09 09:15:26 by cool mr croc