X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Futil.h;fp=src%2Futil.h;h=f719b17b3735d397fcb924df46aaf754639726b6;hb=a4b392b15da0d7da367b1121ec5949f26e10628a;hp=3bbafbd75771e9001be00f240a2a79eabef4dfaa;hpb=dd3064e651cf180e0e02919d644bb0bd86c4e763;p=gbajam22 diff --git a/src/util.h b/src/util.h index 3bbafbd..f719b17 100644 --- a/src/util.h +++ b/src/util.h @@ -29,8 +29,14 @@ void present(int buf); /* defined in src/pc/main.c */ extern int16_t sinlut[]; -#define SIN(x) sinlut[(x) & 0xff] -#define COS(x) sinlut[((x) + 64) & 0xff] +#define SINLUT_BITS 8 +#define SINLUT_SIZE (1 << SINLUT_BITS) + +#define SIN(angle) \ + ((int32_t)sinlut[((angle) >> (16 - SINLUT_BITS)) & (SINLUT_SIZE - 1)] << 1) + +#define COS(angle) \ + ((int32_t)sinlut[(((angle) >> (16 - SINLUT_BITS)) + (SINLUT_SIZE / 4)) & (SINLUT_SIZE - 1)] << 1) int iwram_brk(void *addr); void *iwram_sbrk(intptr_t delta);