Get radar colours from radar text files instead of samples of the terrain tiles.

The radar files use HTML-like hex values for colours (ie FFFFFF is clear white).


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@2295 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2007-07-31 13:02:31 +00:00
parent 179f89cbad
commit af3631c5f9
6 changed files with 306 additions and 111 deletions

View File

@ -0,0 +1,90 @@
6a4936
7b5948
696a53
7d5b43
715c4b
7e5747
754848
6e5043
8a4130
815032
8b5334
7b5e3c
7d5a48
7f583c
8a5a4a
6f5b4c
754f46
855741
894e37
7d503d
6c644a
754736
7a5346
7a4e47
6a524c
864b39
854c36
7e5b45
755c43
64584a
886349
744431
77513e
815c4e
715f47
884832
6c5e43
6e5d41
6e654b
7f5c40
82513f
6e503b
636355
7b4532
785e49
716243
6e5c47
6f5541
886344
5e5638
785e43
8a614b
695042
875c3a
6c5638
79674f
726a49
6e4937
795339
6d5e55
704f42
8e402d
825942
6a5238
726846
715d42
855d46
7f563f
7a6346
815d4a
825b4c
67523a
7c7c4a
858152
807d44
887754
a68952
9d8c51
a18b50
998b4c
9e7b4b
8f7847
81824b
788256
7b7648
8f9953
9d8c59
928a51
918951
8e804e

View File

@ -0,0 +1,91 @@
774a70
81486d
7f536f
895578
784b70
7f5e76
73456a
775677
7b4e6f
7c5770
794e6a
765878
82576c
834f6e
765766
6f5757
73586f
745069
6e4b69
815671
7c5575
8c4c70
825770
7e556a
6a5859
885975
745671
775468
824f6a
6e5572
7c556c
683f65
895773
754c61
6e456d
686074
6f8272
5e746f
788d54
a28a46
6a7370
657d72
638965
958f4b
825e53
6e7966
637c6d
6b826c
999858
767966
6c6e6c
766b62
67765e
95527c
737360
7b7873
70815a
a28540
756e64
7d7469
6c5f63
716f6b
7e4d75
837e74
6a776e
838f51
99904a
80716a
737369
766f65
7f7e6a
9a4a77
6b446f
653b67
75426e
703f6e
a0924f
9a9048
948d43
a79a52
9b8a44
8b4f75
664465
8c5078
8a4f75
968e3f
9d8f41
9d9747
9d9d50
91945e

View File

@ -0,0 +1,91 @@
67507b
685a7f
635981
6a5a82
53647e
49667f
63787c
525b79
74976e
5f5b81
544a72
5d587d
614f7a
4f657a
678163
7d8f58
5e6d7a
7a8a5b
6d5e8b
605e84
5c5780
5b5881
49617a
66866a
74855c
57747a
7c9e6c
615983
66547b
5c5f80
675984
4e6178
4b6777
4c7174
596183
778e5e
798c72
808c5c
919157
94815c
9c875b
9b825f
9c845c
997858
a18158
75805e
8b8959
90714a
a48150
897654
8c8b68
9e8159
978352
8d795b
848b64
8a784e
a38862
a77551
797141
927961
a38858
a2875b
908a54
a27b58
938b67
9f976c
9f8751
9f8959
a18c5a
9c9659
898f54
9a9248
6f8864
70896b
7f9863
728457
8d9152
8a904f
869d67
98964f
989f5d
6a7b62
777e61
6d8d5e
868959
779658
94984f
6b9a68
879e55
6c9556

View File

@ -1158,65 +1158,7 @@ BOOL CoordInRadar(int x,int y)
}
void calcRadarColour(iBitmap *tileBitmap, UDWORD tileNumber)
void radarColour(UDWORD tileNumber, uint8_t r, uint8_t g, uint8_t b)
{
UDWORD i, j;
UBYTE penNumber;
UBYTE fRed,fGreen,fBlue;
UBYTE red,green,blue;
UDWORD tRed,tGreen,tBlue;
iColour* psPalette;
tRed = tGreen = tBlue = 0;
#define SAMPLES 8
#if 0
/* Got through every pixel */
//what all 4096 of them
for(i=0; i<TILE_SIZE; i++)
{
/* Get pixel colour index */
penNumber = (UBYTE) tileBitmap[i];
/* Get the r,g,b components */
red = _iVPALETTE[penNumber].r;
green = _iVPALETTE[penNumber].g;
blue = _iVPALETTE[penNumber].b;
/* Add them to totals */
tRed += red;
tGreen += green;
tBlue += blue;
}
/* Get average of each component */
fRed = (UBYTE) (tRed/TILE_SIZE);
fGreen = (UBYTE) (tGreen/TILE_SIZE);
fBlue = (UBYTE) (tBlue/TILE_SIZE);
#else
//this routine only checks 64 pixels
//offset half a step at the start
tileBitmap += ((TILE_HEIGHT/(2*SAMPLES)) * TILE_WIDTH);
tileBitmap += (TILE_WIDTH/(2*SAMPLES));
psPalette = pie_GetGamePal();
for(i=0; i<SAMPLES; i++)
{
for(j=0; j<SAMPLES; j++)
{
/* Get pixel colour index */
penNumber = (UBYTE) tileBitmap[j*(TILE_WIDTH/SAMPLES)];//stepping across a few steps
/* Get the r,g,b components */
red = psPalette[penNumber].r;
green = psPalette[penNumber].g;
blue = psPalette[penNumber].b;
/* Add them to totals */
tRed += red;
tGreen += green;
tBlue += blue;
}
//step down a few lines
tileBitmap += ((TILE_HEIGHT/(SAMPLES)) * TILE_WIDTH);
}
/* Get average of each component */
fRed = (UBYTE) (tRed/(SAMPLES*SAMPLES));
fGreen = (UBYTE) (tGreen/(SAMPLES*SAMPLES));
fBlue = (UBYTE) (tBlue/(SAMPLES*SAMPLES));
#endif
tileColours[tileNumber] = (UBYTE)iV_PaletteNearestColour(fRed,fGreen,fBlue);
tileColours[tileNumber] = (UBYTE)iV_PaletteNearestColour(r, g, b);
}

View File

@ -20,18 +20,11 @@
#ifndef _radar_h
#define _radar_h
extern void calcRadarColour(iBitmap *tileBitmap, UDWORD tileNumber);
void radarColour(UDWORD tileNumber, uint8_t r, uint8_t g, uint8_t b);
#define RGB_ENTRIES 3
#define MAX_RADARZOOM 2
//#define RADAR_POSITION_AT_ZOOM
/* Radar.h */
extern void resetRadarRedraw(void);
extern BOOL InitRadar(void);
@ -45,8 +38,6 @@ extern UDWORD GetRadarZoom(void);
extern BOOL CoordInRadar(int x,int y);
extern void GetRadarPlayerPos(UDWORD *XPos,UDWORD *YPos);
//#define RADAR_ROT 1
//different mini-map draw modes
typedef enum _radar_draw_mode
{

View File

@ -47,10 +47,11 @@ static void getRectFromPage(UDWORD width, UDWORD height, unsigned char *src, UDW
static void putRectIntoPage(UDWORD width, UDWORD height, unsigned char *dest, UDWORD bufWidth, unsigned char *src);
static void buildTileIndexes(void);
static void makeTileTexturePages(iV_Image * src, UDWORD tileWidth, UDWORD tileHeight);
static BOOL getTileRadarColours(iTexture *tilesPCX);
void texLoad(const char *fileName)
{
char fullPath[MAX_PATH], partialPath[MAX_PATH], *buffer;
unsigned int i, j, k, size;
iTexture tilesPCX;
if(!iV_loadImage_PNG(fileName, &tilesPCX))
@ -59,7 +60,35 @@ void texLoad(const char *fileName)
return;
}
getTileRadarColours(&tilesPCX);
/* Get and set radar colours */
strcpy(partialPath, fileName);
buffer = strrchr(partialPath, '.'); // temporary hack to remove ".png"
*buffer = '\0';
sprintf(fullPath, "%s.radar", partialPath);
if (!loadFile(fullPath, &buffer, &size))
{
debug(LOG_ERROR, "texLoad: Could not find radar colours at %s", fullPath);
abort(); // cannot recover; we could possibly generate a random palette?
}
i = 0; // tile
k = 0; // number of values read
j = 0; // place in buffer
do {
uint8_t r, g, b;
int cnt;
k = sscanf(buffer, "%2hhx%2hhx%2hhx%n", &r, &g, &b, &cnt);
j += cnt;
if (k >= 3)
{
radarColour(i, r, g, b);
}
i++; // next tile
} while (k >= 3 && j < size);
free(buffer);
makeTileTexturePages(&tilesPCX, TILE_WIDTH, TILE_HEIGHT);
free(tilesPCX.bmp);
}
@ -147,45 +176,6 @@ exit:
return;
}
static BOOL getTileRadarColours(iTexture *tilesPCX)
{
UDWORD x, y, i, j, w, h, t;
iBitmap *b, *s;
unsigned char tempBMP[TILE_WIDTH * TILE_HEIGHT];
w = tilesPCX->width / TILE_WIDTH;
h = tilesPCX->height / TILE_HEIGHT;
t = 0;
for (i=0; i<h; i++)
{
for (j=0; j<w; j++)
{
b = tilesPCX->bmp + j * TILE_WIDTH + i * tilesPCX->width * TILE_HEIGHT;
s = &tempBMP[0];
if (s)
{
//copy the bitmap to temp buffer for colour calc
for (y=0; y<TILE_HEIGHT; y++)
{
for (x=0; x<TILE_WIDTH; *s++ = b[x++])
{
; /* NOP */
}
b += tilesPCX->width;
}
calcRadarColour(&tempBMP[0],t);
t++;
}
else
{
return FALSE;
}
}
}
return TRUE;
}
static inline WZ_DECL_CONST unsigned int getTileUIndex(unsigned int tileNumber)
{
return (tileNumber % TILES_IN_PAGE) % TILES_IN_PAGE_COLUMN;