summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/src/main.c b/src/main.c
index 6a1100f..498bb26 100644
--- a/src/main.c
+++ b/src/main.c
@@ -13,6 +13,7 @@
render_area_to_viewport(a, vp); \
SDL_Flip(vp->screen); \
SDL_Delay(10); \
+ ++i; \
} while (0)
int
@@ -20,41 +21,40 @@ main(void)
{
struct viewport *vp;
struct map *map;
- struct image *img;
+#if 0
struct map_tileset *ts;
struct map_exit *e;
+#endif
struct area *a;
+ SDL_Color colors[256];
+ int i;
+ Uint32 start, end;
int x, y;
init();
- vp = init_viewport(240, 160, 32);
+ vp = init_viewport(240, 160, 8);
map = map_get("data/forest1-8bit.tmx");
a = area_new(map);
- debug("screen: bpp: %u, masks: 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x",
- vp->screen->format->BitsPerPixel,
- vp->screen->format->Rmask, vp->screen->format->Gmask,
- vp->screen->format->Bmask, vp->screen->format->Amask);
- img = img_png_get("../forest-6-layer-test_ground.png");
- debug("image: bpp: %u, masks: 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x",
- img->image->format->BitsPerPixel,
- img->image->format->Rmask, img->image->format->Gmask,
- img->image->format->Bmask, img->image->format->Amask);
- img_png_free(img);
- img = img_png_get("data/tilesets/mountain_landscape_19-16.png");
- debug("image: bpp: %u, masks: 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x",
- img->image->format->BitsPerPixel,
- img->image->format->Rmask, img->image->format->Gmask,
- img->image->format->Bmask, img->image->format->Amask);
- img_png_free(img);
- img = img_png_get("data/tilesets/mountain_landscape_19-16-8bit.png");
- debug("image: bpp: %u, masks: 0x%8.8x 0x%8.8x 0x%8.8x 0x%8.8x",
- img->image->format->BitsPerPixel,
- img->image->format->Rmask, img->image->format->Gmask,
- img->image->format->Bmask, img->image->format->Amask);
- img_png_free(img);
+ for (i = 0; i < 256; ++i) {
+ colors[i].r = (i % 8) * 36;
+ colors[i].g = (i % 64 / 8) * 36;
+ colors[i].b = (i / 64) * 85;
+ }
+ if (!SDL_SetPalette(vp->screen, SDL_LOGPAL, colors, 0, 256)) {
+ warn("Failed to set palette");
+ }
+ for (i = 0; i < 256; ++i) {
+ colors[i].r = i;
+ colors[i].g = i;
+ colors[i].b = i;
+ }
+/* if (!SDL_SetPalette(vp->screen, SDL_PHYSPAL, colors, 0, 256)) {
+ warn("Failed to set palette");
+ }*/
+#if 0
debug("Map dimensions: %dx%d", map->width, map->height);
for (ts = map->tilesets_head; ts != NULL; ts = ts->next) {
debug("Tileset name: %s", ts->tileset->name);
@@ -69,8 +69,11 @@ main(void)
e->target_map->width, e->target_map->height,
e->target_x_coord, e->target_y_coord);
}
+#endif
/* Demo */
+ i = 0;
+ start = SDL_GetTicks();
x = 19 * map->tilewidth ;
y = 38 * map->tileheight;
for (; y > 34 * map->tileheight; y -= 2) DEMO(); /* Up */
@@ -84,6 +87,8 @@ main(void)
for (; y > 5 * map->tileheight; y -= 2) DEMO(); /* Up */
for (; x < 15 * map->tilewidth ; x += 2) DEMO(); /* Right */
for (; y > 1 * map->tileheight; y -= 2) DEMO(); /* Up */
+ end = SDL_GetTicks();
+ debug("Rendered %d frames in %d milliseconds", i, end - start);
quit(0);