+
+static void renderLight(struct point *p, unsigned short *light)
+{
+ // Check for boundaries is missing atm, will add soon
+ int x, y;
+ unsigned short *dst = (unsigned short*)lightmap + p->y * fb_width + p->x;
+ for (y = 0; y < LIGHT_HEIGHT; y++)
+ {
+ for (x = 0; x < LIGHT_WIDTH; x++)
+ {
+ *dst++ |= *light++;
+ }
+ dst += fb_width - LIGHT_WIDTH;
+ }
+}
+
+
+static void renderLights()
+{
+ memset(lightmap, 0, fb_width * fb_height * sizeof(*lightmap));
+ // I will later delete only the regions of lights to speed up
+
+ renderLight(&pointR, lightR);
+ renderLight(&pointG, lightG);
+ renderLight(&pointB, lightB);
+}
+
+static void animateLights()
+{
+ struct point center;
+ float dt = (float)(time_msec - startingTime) / 1000.0f;
+
+ center.x = (fb_width >> 1) - (LIGHT_WIDTH / 2);
+ center.y = (fb_height >> 1) - (LIGHT_HEIGHT / 2);
+
+ pointR.x = center.x + sin(1.2f * dt) * 64.0f;
+ pointR.y = center.y + sin(0.8f * dt) * 48.0f;
+
+ pointG.x = center.x + sin(1.5f * dt) * 56.0f;
+ pointG.y = center.y + sin(1.1f * dt) * 42.0f;
+
+ pointB.x = center.x + sin(2.0f * dt) * 80.0f;
+ pointB.y = center.y + sin(1.3f * dt) * 46.0f;
+}
+
+static void renderBump(unsigned short *vram)