From: John Tsiombikas Date: Tue, 20 Apr 2021 10:35:14 +0000 (+0300) Subject: 16bit LUT X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=gbajam21;a=commitdiff_plain;h=f6bf5b7710b9a695ddaef0ad929796a4e151268e 16bit LUT --- diff --git a/src/gamescr.c b/src/gamescr.c index 452709c..8d5f344 100644 --- a/src/gamescr.c +++ b/src/gamescr.c @@ -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); diff --git a/src/util.h b/src/util.h index 5181ba1..789e63e 100644 --- a/src/util.h +++ b/src/util.h @@ -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] diff --git a/tools/lutgen.c b/tools/lutgen.c index c3f003a..70d7641 100644 --- a/tools/lutgen.c +++ b/tools/lutgen.c @@ -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; }