A simple OutRun on Casio Graph 90+E
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
OutRun/src/src/segment.cc

69 lines
1.2 KiB

#include "../include/segment.h"
#include "../parameters.h"
Segment::Segment()
{
//ctor
}
Segment::Segment( uint16_t n_seg )
{
wX = 0;
wY = 0;
wZ = (double) (400.0 + (double) (n_seg * SEGMENT_LENGTH));
}
Segment::Segment( int16_t x, int16_t y, double z, int8_t c )
{
wX = x;
wY = y;
wZ = z;
Curve = c;
LDeco = -1;
RDeco = -1;
}
Segment::Segment( int16_t x, int16_t y, double z, int8_t c, int8_t left, int8_t right )
{
wX = x;
wY = y;
wZ = z;
Curve = c;
LDeco = left;
RDeco = right;
}
Segment::~Segment()
{
//dtor
}
void Segment::Project3DFP( camera* c )
{
fixed_t DX = (fix(wX) - c->cX);
fixed_t DY = (fix(wY) - c->cY);
fixed_t divDZ = fdiv( fix(1), (fixdouble(wZ) - c->cZ));
fixed_t RW = fix(ROAD_WIDTH);
fixed_t divAR = fdiv(fix(1), fixdouble(ASPECT_RATIO));
fixed_t Scale = fmul(fixdouble(DISTANCE_SCREEN), divDZ);
fixed_t tempx = fmul(fmul(DX,Scale), divAR);
fixed_t tempy = fmul(DY, Scale);
fixed_t tempw = fmul(fmul(RW,Scale), divAR);
fixed_t sX=fmul(fix(SCREEN_CX), (fix(1)+tempx));
fixed_t sY=fmul(fix(SCREEN_CY), (fix(1)-tempy));
fixed_t sW=fmul(fix(SCREEN_CX), tempw);
X=fround(sX);
Y=fround(sY);
W=fround(sW);
}