summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gfx.c22
-rw-r--r--gfx.h10
-rw-r--r--landscape.c2
-rw-r--r--main_gui.c2
-rw-r--r--smallmap_gui.c2
-rw-r--r--spritecache.c9
-rw-r--r--spritecache.h13
7 files changed, 33 insertions, 27 deletions
diff --git a/gfx.c b/gfx.c
index a4c2d21f6..48614f97f 100644
--- a/gfx.c
+++ b/gfx.c
@@ -144,7 +144,7 @@ void GfxFillRect(int left, int top, int right, int bottom, int color) {
} while (--bottom);
} else {
/* use colortable mode */
- ctab = GetSpritePtr(color & 0x3FFF) + 1;
+ ctab = GetNonSprite(color & 0x3FFF) + 1;
do {
int i;
for(i=0; i!=right;i++)
@@ -528,7 +528,7 @@ skip_cont:;
if (c >= ASCII_LETTERSTART) {
if (x >= dpi->left + dpi->width) goto skip_char;
if (x + 26 >= dpi->left) {
- GfxMainBlitter(GetSpritePtr(base + 2 + c - ASCII_LETTERSTART), x, y, 1);
+ GfxMainBlitter(GetSprite(base + 2 + c - ASCII_LETTERSTART), x, y, 1);
}
x += _stringwidth_table[base + c - ' '];
} else if (c == ASCII_NL) { // newline = {}
@@ -560,13 +560,13 @@ skip_cont:;
void DrawSprite(uint32 img, int x, int y) {
if (img & 0x8000) {
- _color_remap_ptr = GetSpritePtr(img >> 16) + 1;
- GfxMainBlitter(GetSpritePtr(img & 0x3FFF), x, y, 1);
+ _color_remap_ptr = GetNonSprite(img >> 16) + 1;
+ GfxMainBlitter(GetSprite(img & 0x3FFF), x, y, 1);
} else if (img & 0x4000) {
- _color_remap_ptr = GetSpritePtr(img >> 16) + 1;
- GfxMainBlitter(GetSpritePtr(img & 0x3FFF), x, y, 2);
+ _color_remap_ptr = GetNonSprite(img >> 16) + 1;
+ GfxMainBlitter(GetSprite(img & 0x3FFF), x, y, 2);
} else {
- GfxMainBlitter(GetSpritePtr(img & 0x3FFF), x, y, 0);
+ GfxMainBlitter(GetSprite(img & 0x3FFF), x, y, 0);
}
}
@@ -1628,15 +1628,15 @@ void LoadStringWidthTable(void)
// 2 equals space.
for(i=2; i != 0xE2; i++) {
- *b++ = (byte)((i < 93 || i >= 129 || i == 98) ? GetSpritePtr(i)[2] : 0);
+ *b++ = (byte)((i < 93 || i >= 129 || i == 98) ? TO_LE16(GetSprite(i)->width) : 0);
}
for(i=0xE2; i != 0x1C2; i++) {
- *b++ = (byte)((i < 317 || i >= 353) ? GetSpritePtr(i)[2]+1 : 0);
+ *b++ = (byte)((i < 317 || i >= 353) ? TO_LE16(GetSprite(i)->width) + 1 : 0);
}
for(i=0x1C2; i != 0x2A2; i++) {
- *b++ = (byte)((i < 541 || i >= 577) ? GetSpritePtr(i)[2]+1 : 0);
+ *b++ = (byte)((i < 541 || i >= 577) ? TO_LE16(GetSprite(i)->width) + 1 : 0);
}
}
@@ -1911,7 +1911,7 @@ static void SetCursorSprite(uint cursor)
if (cv->sprite == cursor)
return;
- p = GetSpritePtr(cursor & 0x3FFF);
+ p = GetSprite(cursor & 0x3FFF);
cv->sprite = cursor;
cv->size.y = p->height;
cv->size.x = TO_LE16(p->width);
diff --git a/gfx.h b/gfx.h
index de202d298..9dcf01296 100644
--- a/gfx.h
+++ b/gfx.h
@@ -17,16 +17,6 @@ struct DrawPixelInfo {
};
-typedef struct Sprite {
- byte info;
- byte height;
- uint16 width; // LE!
- int16 x_offs; // LE!
- int16 y_offs; // LE!
- byte data[VARARRAY_SIZE];
-} Sprite;
-assert_compile(sizeof(Sprite) == 8);
-
typedef struct CursorVars {
Point pos, size, offs, delta;
Point draw_pos, draw_size;
diff --git a/landscape.c b/landscape.c
index 4bd2d78cf..dfcdbe8c2 100644
--- a/landscape.c
+++ b/landscape.c
@@ -476,7 +476,7 @@ static void GenerateTerrain(int type, int flag)
byte direction;
r = Random();
- p = GetSpritePtr((((r >> 24) * _genterrain_tbl_1[type]) >> 8) + _genterrain_tbl_2[type] + 4845);
+ p = GetNonSprite((((r >> 24) * _genterrain_tbl_1[type]) >> 8) + _genterrain_tbl_2[type] + 4845);
x = r & MapMaxX();
y = (r >> MapLogX()) & MapMaxY();
diff --git a/main_gui.c b/main_gui.c
index 65f29b981..4e0d8c326 100644
--- a/main_gui.c
+++ b/main_gui.c
@@ -2378,7 +2378,7 @@ void SetupColorsAndInitialWindow(void)
int width,height;
for(i=0; i!=16; i++) {
- b = GetSpritePtr(0x307 + i);
+ b = GetNonSprite(0x307 + i);
assert(b);
_color_list[i] = *(ColorList*)(b + 0xC6);
}
diff --git a/smallmap_gui.c b/smallmap_gui.c
index 476867083..174447d0f 100644
--- a/smallmap_gui.c
+++ b/smallmap_gui.c
@@ -618,7 +618,7 @@ static void DrawSmallMap(DrawPixelInfo *dpi, Window *w, int type, bool show_town
FOR_ALL_PLAYERS(p) {
if (p->is_active)
_owner_colors[p->index] =
- dup_byte32(GetSpritePtr(0x307 + p->player_color)[0xCB]);
+ dup_byte32(GetNonSprite(0x307 + p->player_color)[0xCB]);
}
}
diff --git a/spritecache.c b/spritecache.c
index 30cd4ad46..9c6f4702d 100644
--- a/spritecache.c
+++ b/spritecache.c
@@ -698,7 +698,12 @@ static uint RotateSprite(uint s)
}
#endif
-byte *GetSpritePtr(SpriteID sprite)
+Sprite *GetSprite(SpriteID sprite)
+{
+ return GetNonSprite(sprite);
+}
+
+byte *GetNonSprite(SpriteID sprite)
{
byte *p;
@@ -987,7 +992,7 @@ const SpriteDimension *GetSpriteDimension(SpriteID sprite)
p = _sprite_ptr[sprite];
if (p == NULL)
- p = GetSpritePtr(sprite);
+ p = GetSprite(sprite);
/* decode sprite header */
sd = &sd_static;
diff --git a/spritecache.h b/spritecache.h
index d6a4373aa..b4becda45 100644
--- a/spritecache.h
+++ b/spritecache.h
@@ -1,13 +1,24 @@
#ifndef SPRITECACHE_H
#define SPRITECACHE_H
+typedef struct Sprite {
+ byte info;
+ byte height;
+ uint16 width; // LE!
+ int16 x_offs; // LE!
+ int16 y_offs; // LE!
+ byte data[VARARRAY_SIZE];
+} Sprite;
+assert_compile(sizeof(Sprite) == 8);
+
typedef struct {
int xoffs, yoffs;
int xsize, ysize;
} SpriteDimension;
const SpriteDimension *GetSpriteDimension(SpriteID sprite);
-byte *GetSpritePtr(SpriteID sprite);
+Sprite *GetSprite(SpriteID sprite);
+byte *GetNonSprite(SpriteID sprite);
void GfxInitSpriteMem(byte *ptr, uint32 size);
void GfxLoadSprites(void);