X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Fgrise.c;h=1a1cebf5b97649933793d9af8d3e27837ecb7dc0;hp=543b51e653bcf28225350a6a98fb13c6908e17c2;hb=4eabd99a0c9a1de4c1e6bccdeec2d4b9a66e227a;hpb=b326ec9a1deb7086652fae05bb241ecc093b736f diff --git a/src/grise.c b/src/grise.c index 543b51e..1a1cebf 100644 --- a/src/grise.c +++ b/src/grise.c @@ -26,6 +26,8 @@ static RLEBitmap *rleEncode(RLEBitmap *b, unsigned char *pixels, unsigned int w, static void updatePropeller(float t); +extern void drawFps(unsigned short *vram); + #define BG_FILENAME "data/grise.png" #define GROBJ_01_FILENAME "data/grobj_01.png" @@ -97,7 +99,6 @@ struct screen *grise_screen(void) return &scr; } - static int init(void) { unsigned char *tmpBitmap; @@ -167,6 +168,9 @@ static void draw(void) int i = 0; short *dispScanline; int d; + int accum = 0; + int md, sc; + int scrolledIndex; lastFrameDuration = (time_msec - lastFrameTime) / 1000.0f; lastFrameTime = time_msec; @@ -203,8 +207,19 @@ static void draw(void) src = dst + BB_SIZE; /* The pixels to be displaced are 1 scanline below */ dispScanline = displacementMap; for (scanline = 0; scanline < REFLECTION_HEIGHT; scanline++) { + + md = scrollModTable[scanline]; + sc = scrollTableRounded[scanline]; + accum = 0; + for (i = 0; i < fb_width; i++) { - d = dispScanline[(i + scrollTableRounded[scanline]) % scrollModTable[scanline]]; + /* Try to immitate modulo without the division */ + if (i == md) accum += md; + scrolledIndex = i - accum + sc; + if (scrolledIndex >= md) scrolledIndex -= md; + + /* Displace */ + d = dispScanline[scrolledIndex]; *dst++ = src[i + d]; } src += backgroundW; @@ -224,6 +239,8 @@ static void draw(void) dst += fb_width; } + drawFps(vmem_back); + swap_buffers(0); }