SHARE
TWEET

Untitled

a guest Apr 16th, 2015 197 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdint.h>
  2. #include <avr/pgmspace.h>
  3.  
  4. typedef struct {
  5.         uint8_t x;
  6.         uint8_t y;
  7.         uint8_t z;
  8.         uint8_t laneHi;
  9.         uint8_t s;
  10. } ObjectDescStruct;
  11.  
  12. extern uint8_t scaleTable[];
  13. extern uint8_t zTable[];
  14.  
  15. extern struct {
  16.         int8_t xStart;
  17.         int8_t yStart;
  18.         int8_t xGrad;
  19.         int8_t yGrad;
  20. } laneData[];
  21.  
  22. void moveXYCommon(ObjectDescStruct *objData){
  23.         uint8_t Z;
  24.         uint8_t lane;
  25.  
  26.         Z = pgm_read_byte(&zTable[objData->z]);              // Perspective transform the objects Z value
  27.  
  28.         objData->s = pgm_read_byte(&scaleTable[objData->z]); // Get the scale of the object at given Z value
  29.  
  30.         lane = objData->laneHi;
  31.  
  32.         int8_t x = laneData[lane].xStart;                    // Get the X/Y start position of the current lane
  33.         int8_t y = laneData[lane].yStart;
  34.  
  35.         int8_t xAdd = laneData[lane].xGrad;                  // Get the gradient of the lane
  36.         int8_t yAdd = laneData[lane].yGrad;
  37.  
  38.         xAdd = (Z * xAdd)>>8;                                // Work out how far the object is from the start of the lane
  39.         yAdd = (Z * yAdd)>>8;
  40.  
  41.         //xAdd = MulSU(Z, xAdd);
  42.         //yAdd = MulSU(Z, yAdd);
  43.  
  44.         //MulSU2(Z, xAdd, yAdd);
  45.  
  46.         objData->x = x + xAdd;                               // Add the delta X/Y to the lane start position
  47.         objData->y = y + yAdd;
  48. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top