aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMax Horn2002-09-16 10:42:12 +0000
committerMax Horn2002-09-16 10:42:12 +0000
commita6c5762817069974dda24e86a08f91380f15d241 (patch)
treed98b9d29dea7f87ab878b16dcd2597b9a109b2b7 /common
parentae871cd4a6d358cedecd729fb951289c6535fab1 (diff)
downloadscummvm-rg350-a6c5762817069974dda24e86a08f91380f15d241.tar.gz
scummvm-rg350-a6c5762817069974dda24e86a08f91380f15d241.tar.bz2
scummvm-rg350-a6c5762817069974dda24e86a08f91380f15d241.zip
added some comments, cleanup
svn-id: r4950
Diffstat (limited to 'common')
-rw-r--r--common/util.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/common/util.cpp b/common/util.cpp
index 86711866c9..cea9d3a8f0 100644
--- a/common/util.cpp
+++ b/common/util.cpp
@@ -21,9 +21,15 @@
#include "stdafx.h"
#include "util.h"
+//
// 8-bit alpha blending routines
-int BlendCache[256][256];
+//
+static int BlendCache[256][256];
+//
+// Find the entry in the given palette which matches the color defined by
+// the tripel (r,b,g) most closely.
+//
int RGBMatch(byte *palette, int r, int g, int b)
{
int i, bestidx = 0, besterr = 0xFFFFFF;
@@ -45,6 +51,9 @@ int RGBMatch(byte *palette, int r, int g, int b)
return bestidx;
}
+//
+// Blend two 8 bit colors into a third, all colors being defined by palette indices.
+//
int Blend(int src, int dst, byte *palette)
{
int r, g, b;
@@ -70,6 +79,9 @@ int Blend(int src, int dst, byte *palette)
return (BlendCache[dst][src] = RGBMatch(palette, r , g , b ));
}
+//
+// Reset the blending cache
+//
void ClearBlendCache(byte *palette, int weight)
{
for (int i = 0; i < 256; i++)
@@ -80,9 +92,9 @@ void ClearBlendCache(byte *palette, int weight)
}
-/*
- * Print hexdump of the data passed in, 8 bytes a row
- */
+//
+// Print hexdump of the data passed in, 8 bytes a row
+//
void hexdump(const byte * data, int len)
{
int i;
@@ -121,7 +133,12 @@ void hexdump(const byte * data, int len)
printf("|\n");
}
-// Resource string length, supports special chars starting with FF
+//
+// Given a pointer to a Scumm resource, this function returns the length
+// of the (string) data in that resource. To do so it understands certain
+// special chars starting with FF. The reason for this function is that
+// sometimes resource data will contain 0 bytes, thus we can't just use strlen.
+//
int resStrLen(const char *src)
{
int num = 0;