16bit LUT
authorJohn Tsiombikas <nuclear@member.fsf.org>
Tue, 20 Apr 2021 10:35:14 +0000 (13:35 +0300)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Tue, 20 Apr 2021 10:35:14 +0000 (13:35 +0300)
src/gamescr.c
src/util.h
tools/lutgen.c

index 452709c..8d5f344 100644 (file)
@@ -80,10 +80,10 @@ void gamescr(void)
                present(backbuf);
 
                tunrot = nframes;
-               bgmat[0] = (COS(tunrot) * 280) >> 8;
-               bgmat[1] = (-SIN(tunrot) * 280) >> 8;
-               bgmat[2] = (SIN(tunrot) * 280) >> 8;
-               bgmat[3] = (COS(tunrot) * 280) >> 8;
+               bgmat[0] = (COS(tunrot) * 140) >> 8;
+               bgmat[1] = (-SIN(tunrot) * 140) >> 8;
+               bgmat[2] = (SIN(tunrot) * 140) >> 8;
+               bgmat[3] = (COS(tunrot) * 140) >> 8;
                bgx = (120 << 8) - bgmat[0] * 120 + bgmat[1] * -80;
                bgy = (80 << 8) - bgmat[2] * 120 + bgmat[3] * -80;
 
@@ -101,7 +101,7 @@ static void draw_tunnel(void)
 
        zoffs = nframes;
 
-       uoffs = tunrot;
+       uoffs = tunrot >> 1;
 
        top = vram[backbuf] + 20;
        bot = vram[backbuf] + 159 * 240 / 2 + 20;
@@ -182,10 +182,10 @@ static void vblank(void)
        spr_oam(oam, 0, 512 + 256, x - 64, y - 64, SPR_256COL | SPR_SZ64 | SPR_DBLSZ |
                        SPR_ROTSCL | SPR_ROTSCL_SEL(0));
 
-       mat[0] = COS(rot) << 1;
-       mat[1] = -SIN(rot) << 1;
-       mat[2] = SIN(rot) << 1;
-       mat[3] = COS(rot) << 1;
+       mat[0] = COS(rot);
+       mat[1] = -SIN(rot);
+       mat[2] = SIN(rot);
+       mat[3] = COS(rot);
        spr_transform(oam, 0, mat);
 
 
index 5181ba1..789e63e 100644 (file)
@@ -20,7 +20,7 @@
                ((uint16_t*)CRAM_BG_ADDR)[idx] = (uint16_t)(r) | ((uint16_t)(g) << 5) | ((uint16_t)(b) << 10); \
        } while(0)
 
-extern int8_t sinlut[];
+extern int16_t sinlut[];
 
 #define SIN(x) sinlut[(x) & 0xff]
 #define COS(x) sinlut[((x) + 64) & 0xff]
index c3f003a..70d7641 100644 (file)
@@ -10,7 +10,7 @@ int main(void)
        puts("sinlut:");
        for(i=0; i<256; i++) {
                float x = sin((float)i / 128.0f * M_PI);
-               printf("\t.byte %d\n", (int)(x * 127.5f - 0.5f));
+               printf("\t.short %d\n", (int)(x * 256.0f));
        }
        return 0;
 }