From: John Tsiombikas Date: Mon, 17 May 2021 22:50:37 +0000 (+0300) Subject: the sin lut was too small for any kind of reasonable resolution in high X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=commitdiff_plain;h=3ac76817d27b4ffc90f04a97c8714afb165eebc2;p=retrobench the sin lut was too small for any kind of reasonable resolution in high framerates --- diff --git a/src/rbench.c b/src/rbench.c index 7202c1a..8b9e23f 100644 --- a/src/rbench.c +++ b/src/rbench.c @@ -33,7 +33,7 @@ void cleanup(void) #define XORRGB(x, y, zoom, r, g, b) \ do { \ - int xor = (((x) - fb_width/2) * (zoom) >> 10) ^ (((y) - fb_height/2) * (zoom) >> 10); \ + int xor = (((x) - fb_width/2) * (zoom) >> 16) ^ (((y) - fb_height/2) * (zoom) >> 16); \ (r) = xor >> 2; \ (g) = xor >> 1; \ (b) = xor; \ @@ -46,9 +46,9 @@ void redraw(void) uint16_t *fbptr16; uint32_t *fbptr32; - xoffs = COS(time_msec >> 5) * fb_width >> 7; - yoffs = SIN(time_msec >> 4) * fb_height >> 8; - zoom = ((SIN(time_msec >> 4) + 256) << 1) + 512; + xoffs = COS(time_msec >> 3) * fb_width >> 15; + yoffs = SIN(time_msec >> 2) * fb_height >> 16; + zoom = (SIN(time_msec >> 5) >> 1) + 65536; switch(fb_bpp) { case 15: diff --git a/src/util.h b/src/util.h index 9f0eb4d..6880649 100644 --- a/src/util.h +++ b/src/util.h @@ -14,8 +14,8 @@ typedef unsigned int uint32_t; extern int sinlut[]; -#define SIN(x) sinlut[(x) & 0xff] -#define COS(x) sinlut[((x) + 64) & 0xff] +#define SIN(x) sinlut[(x) & 0x3ff] +#define COS(x) sinlut[((x) + 512) & 0x3ff] int mask_to_shift(unsigned int mask); diff --git a/tools/lutgen.c b/tools/lutgen.c index a573de1..a2cc1ed 100644 --- a/tools/lutgen.c +++ b/tools/lutgen.c @@ -10,9 +10,9 @@ int main(void) puts("\t.globl sinlut"); puts("_sinlut:"); puts("sinlut:"); - for(i=0; i<256; i++) { - float x = sin((float)i / 128.0f * M_PI); - printf("\t.long %d\n", (int)(x * 256.0f)); + for(i=0; i<1024; i++) { + float x = sin((float)i / 512.0f * M_PI); + printf("\t.long %d\n", (int)(x * 65536.0f)); } return 0; }