summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2013-03-04 20:41:33 (EST)
committer P. J. McDermott <pjm@nac.net>2013-03-04 20:41:33 (EST)
commitb69ee811a0f3b49bef2eb26163f34e8430a24580 (patch)
treec28dcac00c52876c3d5cb1b646bf833f44da2ff0 /src/main.c
parent4b554530020c4bef37feb02a83d640d224bbfd56 (diff)
downloadoverworld-rpg-b69ee811a0f3b49bef2eb26163f34e8430a24580.zip
overworld-rpg-b69ee811a0f3b49bef2eb26163f34e8430a24580.tar.gz
overworld-rpg-b69ee811a0f3b49bef2eb26163f34e8430a24580.tar.bz2
Support palette cycling in area layers.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c22
1 files changed, 3 insertions, 19 deletions
diff --git a/src/main.c b/src/main.c
index 0d75e4a..1dd376a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -11,24 +11,6 @@
do { \
vp->x = x + map->tilewidth / 2 - vp->w / 2; \
vp->y = y + map->tileheight / 2 - vp->h / 2; \
- /* This causes render_area_to_viewport() to use a lot more CPU \
- * time. \
- * Presumably, this is because SDL is mapping the area layers' \
- * color palettes onto the screen's palette. (But they should \
- * be equal, so color mapping shouldn't happen…) \
- * Oddly, the effect of this SDL_SetPalette() call is much \
- * greater than is that of the other one. \
- * Hopefully, cycling the palettes of the area layers should \
- * fix _everything_. */ \
- if (!SDL_SetPalette(vp->screen, SDL_LOGPAL, \
- map->palettes[MAP_PALETTE_DAY] \
- .palette->palette->colors, \
- 0, \
- map->palettes[MAP_PALETTE_DAY] \
- .palette->palette->ncolors)) { \
- warn("Failed to set palette"); \
- } \
- render_area_to_viewport(a, vp); \
if (i % 720 < 180) { \
pal_start = map->palettes[MAP_PALETTE_MORN] \
.palette->palette; \
@@ -53,10 +35,12 @@
if (!cycle_palettes_cosine(i, 180, pal_start, pal_end, pal)) { \
warn("Failed to cycle palettes"); \
} \
+ set_area_palette(a, pal); \
if (!SDL_SetPalette(vp->screen, SDL_LOGPAL, \
pal->colors, 0, pal->ncolors)) { \
warn("Failed to set palette"); \
} \
+ render_area_to_viewport(a, vp); \
SDL_Flip(vp->screen); \
SDL_Delay(10); \
++i; \
@@ -87,7 +71,7 @@ main(void)
0, pal->ncolors)) {
warn("Failed to set palette");
}
- a = area_new(map, vp);
+ a = area_new(map, vp->screen->format->palette);
for (e = map->map_exits_head; e != NULL; e = e->next) {
debug("Map exit (size %dx%d) at (%d,%d) "