Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdint.h>
- #include <avr/pgmspace.h>
- typedef struct {
- uint8_t x;
- uint8_t y;
- uint8_t z;
- uint8_t laneHi;
- uint8_t s;
- } ObjectDescStruct;
- extern uint8_t scaleTable[];
- extern uint8_t zTable[];
- extern struct {
- int8_t xStart;
- int8_t yStart;
- int8_t xGrad;
- int8_t yGrad;
- } laneData[];
- void moveXYCommon(ObjectDescStruct *objData){
- uint8_t Z;
- uint8_t lane;
- Z = pgm_read_byte(&zTable[objData->z]); // Perspective transform the objects Z value
- objData->s = pgm_read_byte(&scaleTable[objData->z]); // Get the scale of the object at given Z value
- lane = objData->laneHi;
- int8_t x = laneData[lane].xStart; // Get the X/Y start position of the current lane
- int8_t y = laneData[lane].yStart;
- int8_t xAdd = laneData[lane].xGrad; // Get the gradient of the lane
- int8_t yAdd = laneData[lane].yGrad;
- xAdd = (Z * xAdd)>>8; // Work out how far the object is from the start of the lane
- yAdd = (Z * yAdd)>>8;
- //xAdd = MulSU(Z, xAdd);
- //yAdd = MulSU(Z, yAdd);
- //MulSU2(Z, xAdd, yAdd);
- objData->x = x + xAdd; // Add the delta X/Y to the lane start position
- objData->y = y + yAdd;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement