+static void eraseArea(struct point *p, int width, int height)
+{
+ int x, y;
+ unsigned short *dst;
+
+ int x0 = p->x;
+ int y0 = p->y;
+ int x1 = p->x + width;
+ int y1 = p->y + height;
+
+ int dx, dy;
+
+ if (x0 < 0) x0 = 0;
+ if (y0 < 0) y0 = 0;
+ if (x1 > fb_width) x1 = fb_width;
+ if (y1 > fb_height) y1 = fb_height;
+
+ dx = x1 - x0;
+ //dy = y1 - y0;
+
+ dst = (unsigned short*)lightmap + y0 * fb_width + x0;
+
+ for (y = y0; y < y1; y++)
+ {
+ for (x = x0; x < x1; x++)
+ {
+ *dst++ = 0;
+ }
+ dst += fb_width - dx;
+ }
+}
+
+
+static void renderLight(struct point *p, int width, int height, 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 < height; y++)
+ {
+ for (x = 0; x < width; x++)
+ {
+ *dst++ |= *light++;
+ }
+ dst += fb_width - width;
+ }
+}
+
+static void eraseLights()
+{
+ eraseArea(&pointR, LIGHT_WIDTH, LIGHT_HEIGHT);
+ eraseArea(&pointG, LIGHT_WIDTH, LIGHT_HEIGHT);
+ eraseArea(&pointB, LIGHT_WIDTH, LIGHT_HEIGHT);
+}
+
+static void renderLights()
+{
+ renderLight(&pointR, LIGHT_WIDTH, LIGHT_HEIGHT, lightR);
+ renderLight(&pointG, LIGHT_WIDTH, LIGHT_HEIGHT, lightG);
+ renderLight(&pointB, LIGHT_WIDTH, LIGHT_HEIGHT, 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);
+
+ // This test condition will crash because I also need to add boundaries to renderLight (tomorrow)
+ //pointR.x = center.x + sin(1.2f * dt) * 144.0f;
+ //pointR.y = center.y + sin(0.8f * dt) * 148.0f;
+
+ pointR.x = center.x + sin(1.2f * dt) * 96.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)