fixed build on watcom
authorJohn Tsiombikas <nuclear@mutantstargoat.com>
Fri, 2 Sep 2016 22:50:49 +0000 (01:50 +0300)
committerJohn Tsiombikas <nuclear@mutantstargoat.com>
Fri, 2 Sep 2016 22:50:49 +0000 (01:50 +0300)
Makefile
src/mike.c

index a78b496..a86ec5b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 baseobj = main.obj
-demoobj = demo.obj screen.obj tunnel.obj fract.obj gfxutil.obj
+demoobj = demo.obj screen.obj tunnel.obj fract.obj gfxutil.obj mike.obj
 sysobj = gfx.obj vbe.obj dpmi.obj timer.obj keyb.obj mouse.obj logger.obj
 obj = $(baseobj) $(demoobj) $(sysobj)
 bin = demo.exe
index 4f92011..93b3f21 100644 (file)
@@ -140,23 +140,25 @@ static void convert32To16(unsigned int *src32, unsigned short *dst16, unsigned i
 /* Scale normal with depth and unpack R component (horizontal component) */
 static void processNormal() {
        int scanline;
-       unsigned int *normalmap = (unsigned int*)background;
-       normalmap += NORMALMAP_SCANLINE * backgroundW;
-       unsigned short *dst = normalmap;
-       displacementMap = (short*)dst;
-       short *dst2 = displacementMap;
        float scale;
        int i;
        int x;
        short maxDisplacement = 0;
        short minDisplacement = 256;
+       unsigned short *dst;
+       short *dst2;
+       unsigned int *normalmap = (unsigned int*)background;
+       normalmap += NORMALMAP_SCANLINE * backgroundW;
+       dst = (unsigned short*)normalmap;
+       displacementMap = (short*)dst;
+       dst2 = displacementMap;
 
        for (scanline = 0; scanline < REFLECTION_HEIGHT; scanline++) {
                scale = 2.0f - (float)scanline / ((float)REFLECTION_HEIGHT - 1);
                scrollModTable[scanline] = (int) (backgroundW / scale + 0.5f);
                for (i = 0; i < backgroundW; i++) {
                        x = (int)(i * scale + 0.5f);
-                       if (x < background) {
+                       if (x < backgroundW) {
                                *dst = (unsigned short)normalmap[x] & 0xFF;
                                if ((short)*dst > maxDisplacement) maxDisplacement = (short)(*dst);
                                if ((short)*dst < minDisplacement) minDisplacement = (short)(*dst);
@@ -202,4 +204,4 @@ static void updateScrollTables(float dt) {
                scrollTable[i] += scrollSpeedTable[i] * dt;
                scrollTableRounded[i] = (int)(scrollTable[i] + 0.5f) % scrollModTable[i];
        }
-}
\ No newline at end of file
+}