summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2011-10-15 21:55:53 (GMT)
committer Chris Young <chris@unsatisfactorysoftware.co.uk>2011-10-15 21:55:53 (GMT)
commit910d8e91ff8244aef316280a015d1b63a09fb001 (patch)
tree9bc868f2e3e727bf2df72979cd911658114ae8f3
parentd3e888a5c6f52c0f5be00bdc8e0781bdb16dcdd1 (diff)
downloadlibrosprite-910d8e91ff8244aef316280a015d1b63a09fb001.tar.gz
librosprite-910d8e91ff8244aef316280a015d1b63a09fb001.tar.bz2
Support 256 colour sprites with a <256 colour palette.
svn path=/trunk/librosprite/; revision=13066
-rw-r--r--librosprite.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/librosprite.c b/librosprite.c
index 21358f0..9ca40c7 100644
--- a/librosprite.c
+++ b/librosprite.c
@@ -686,8 +686,12 @@ static uint32_t rosprite_palette_lookup(struct rosprite* sprite, uint32_t pixel)
uint32_t translated_pixel;
/* because we're dealing with 8bpp or less */
if (sprite->has_palette) {
- assert(pixel <= sprite->palettesize); /* TODO: what to do if your color depth is bigger than palette? */
- translated_pixel = sprite->palette[pixel];
+
+ if(pixel <= (sprite->palettesize/8)) {
+ translated_pixel = sprite->palette[pixel];
+ } else {
+ translated_pixel = sprite_8bpp_palette[pixel];
+ }
} else {
switch (sprite->mode.colorbpp) {
case 8: