summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-07-15 14:16:14 +0000
committertron <tron@openttd.org>2005-07-15 14:16:14 +0000
commit8f71864bef912a9cd8b8f649c5acbe638d48fc24 (patch)
tree37a7c3272357635a96d29652c78fbc738b0c782d
parentb21ee889fec9b8d197692969855cb54675edfa6d (diff)
downloadopenttd-8f71864bef912a9cd8b8f649c5acbe638d48fc24.tar.xz
(svn r2571) Add explicit type Pixel for ... Pixels
-rw-r--r--gfx.c22
-rw-r--r--gfx.h3
-rw-r--r--screenshot.c14
-rw-r--r--smallmap_gui.c12
-rw-r--r--texteff.c2
-rw-r--r--win32.c12
6 files changed, 32 insertions, 33 deletions
diff --git a/gfx.c b/gfx.c
index bbd9d1efe..17d850a72 100644
--- a/gfx.c
+++ b/gfx.c
@@ -11,7 +11,7 @@ Colour _cur_palette[256];
static void GfxMainBlitter(const Sprite *sprite, int x, int y, int mode);
static int _stringwidth_out;
-static byte _cursor_backup[64*64];
+static Pixel _cursor_backup[64 * 64];
static Rect _invalid_rect;
static const byte *_color_remap_ptr;
static byte _string_colorremap[3];
@@ -37,8 +37,8 @@ void memcpy_pitch(void *d, void *s, int w, int h, int spitch, int dpitch)
void GfxScroll(int left, int top, int width, int height, int xo, int yo)
{
- byte *src;
- byte *dst;
+ const Pixel *src;
+ Pixel *dst;
int p;
int ht;
@@ -109,7 +109,7 @@ void GfxScroll(int left, int top, int width, int height, int xo, int yo)
void GfxFillRect(int left, int top, int right, int bottom, int color)
{
DrawPixelInfo *dpi = _cur_dpi;
- byte *dst;
+ Pixel *dst;
const int otop = top;
const int oleft = left;
@@ -574,7 +574,7 @@ typedef struct BlitterParams {
int start_x, start_y;
const byte* sprite;
const byte* sprite_org;
- byte *dst;
+ Pixel *dst;
int mode;
int width, height;
int width_org;
@@ -589,7 +589,7 @@ static void GfxBlitTileZoomIn(BlitterParams *bp)
const byte* src;
int num, skip;
byte done;
- byte *dst;
+ Pixel *dst;
const byte* ctab;
if (bp->mode & 1) {
@@ -718,7 +718,7 @@ static void GfxBlitTileZoomIn(BlitterParams *bp)
static void GfxBlitZoomInUncomp(BlitterParams *bp)
{
const byte *src = bp->sprite;
- byte *dst = bp->dst;
+ Pixel *dst = bp->dst;
int height = bp->height;
int width = bp->width;
int i;
@@ -791,7 +791,7 @@ static void GfxBlitTileZoomMedium(BlitterParams *bp)
const byte* src;
int num, skip;
byte done;
- byte *dst;
+ Pixel *dst;
const byte* ctab;
if (bp->mode & 1) {
@@ -945,7 +945,7 @@ static void GfxBlitTileZoomMedium(BlitterParams *bp)
static void GfxBlitZoomMediumUncomp(BlitterParams *bp)
{
const byte *src = bp->sprite;
- byte *dst = bp->dst;
+ Pixel *dst = bp->dst;
int height = bp->height;
int width = bp->width;
int i;
@@ -996,7 +996,7 @@ static void GfxBlitTileZoomOut(BlitterParams *bp)
const byte* src;
int num, skip;
byte done;
- byte *dst;
+ Pixel *dst;
const byte* ctab;
if (bp->mode & 1) {
@@ -1209,7 +1209,7 @@ static void GfxBlitTileZoomOut(BlitterParams *bp)
static void GfxBlitZoomOutUncomp(BlitterParams *bp)
{
const byte* src = bp->sprite;
- byte *dst = bp->dst;
+ Pixel *dst = bp->dst;
int height = bp->height;
int width = bp->width;
int i;
diff --git a/gfx.h b/gfx.h
index 9b8bd8814..8c44123c9 100644
--- a/gfx.h
+++ b/gfx.h
@@ -1,6 +1,7 @@
#ifndef GFX_H
#define GFX_H
+typedef byte Pixel;
typedef struct ColorList {
byte unk0, unk1, unk2;
@@ -10,7 +11,7 @@ typedef struct ColorList {
} ColorList;
struct DrawPixelInfo {
- byte *dst_ptr;
+ Pixel *dst_ptr;
int left, top, width, height;
int pitch;
uint16 zoom;
diff --git a/screenshot.c b/screenshot.c
index 3c23e327b..8350cb35f 100644
--- a/screenshot.c
+++ b/screenshot.c
@@ -57,7 +57,7 @@ static bool MakeBmpImage(const char *name, ScreenshotCallback *callb, void *user
BitmapFileHeader bfh;
BitmapInfoHeader bih;
RgbQuad rq[256];
- byte *buff;
+ Pixel *buff;
FILE *f;
uint i, padw;
uint n, maxlines;
@@ -159,7 +159,7 @@ static void PNGAPI png_my_warning(png_structp png_ptr, png_const_charp message)
static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
{
png_color rq[256];
- byte *buff;
+ Pixel *buff;
FILE *f;
uint i, y, n;
uint maxlines;
@@ -272,7 +272,7 @@ assert_compile(sizeof(PcxHeader) == 128);
static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
{
- byte *buff;
+ Pixel *buff;
FILE *f;
uint maxlines;
uint y;
@@ -330,14 +330,14 @@ static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *user
// write them to pcx
for (i = 0; i != n; i++) {
- const byte* bufp = buff + i * w;
+ const Pixel* bufp = buff + i * w;
byte runchar = bufp[0];
uint runcount = 1;
uint j;
// for each pixel...
for (j = 1; j < w; j++) {
- byte ch = bufp[j];
+ Pixel ch = bufp[j];
if (ch != runchar || runcount >= 0x3f) {
if (runcount > 1 || (runchar & 0xC0) == 0xC0)
@@ -426,7 +426,7 @@ void SetScreenshotFormat(int i)
}
// screenshot generator that dumps the current video buffer
-static void CurrentScreenCallback(void *userdata, byte *buf, uint y, uint pitch, uint n)
+static void CurrentScreenCallback(void *userdata, Pixel *buf, uint y, uint pitch, uint n)
{
for (; n > 0; --n) {
memcpy(buf, _screen.dst_ptr + y * _screen.pitch, _screen.width);
@@ -436,7 +436,7 @@ static void CurrentScreenCallback(void *userdata, byte *buf, uint y, uint pitch,
}
// generate a large piece of the world
-static void LargeWorldCallback(void *userdata, byte *buf, uint y, uint pitch, uint n)
+static void LargeWorldCallback(void *userdata, Pixel *buf, uint y, uint pitch, uint n)
{
ViewPort *vp = (ViewPort *)userdata;
DrawPixelInfo dpi, *old_dpi;
diff --git a/smallmap_gui.c b/smallmap_gui.c
index 540917179..2a69cfc96 100644
--- a/smallmap_gui.c
+++ b/smallmap_gui.c
@@ -190,9 +190,8 @@ static const uint16 * const _legend_table[] = {
};
#if defined(TTD_ALIGNMENT_4)
- static inline void WRITE_PIXELS(void *dst, uint32 val)
+ static inline void WRITE_PIXELS(Pixel* d, uint32 val)
{
- byte *d = (byte*)dst;
# if defined(TTD_BIG_ENDIAN)
d[0] = (byte)(val >> 24);
d[1] = (byte)(val >> 16);
@@ -207,9 +206,8 @@ static const uint16 * const _legend_table[] = {
}
/* need to use OR, otherwise we will overwrite the wrong pixels at the edges :( */
- static inline void WRITE_PIXELS_OR(void *dst, uint32 val)
+ static inline void WRITE_PIXELS_OR(Pixel* d, uint32 val)
{
- byte *d = (byte*)dst;
# if defined(TTD_BIG_ENDIAN)
d[0] |= (byte)(val >> 24);
d[1] |= (byte)(val >> 16);
@@ -324,9 +322,9 @@ typedef uint32 GetSmallMapPixels(TileIndex tile); // typedef callthrough functio
* @param proc Pointer to the colour function
* @see GetSmallMapPixels(TileIndex)
*/
-static void DrawSmallMapStuff(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask, GetSmallMapPixels *proc)
+static void DrawSmallMapStuff(Pixel *dst, uint xc, uint yc, int pitch, int reps, uint32 mask, GetSmallMapPixels *proc)
{
- byte *dst_ptr_end = _screen.dst_ptr + _screen.width * _screen.height - _screen.width;
+ Pixel *dst_ptr_end = _screen.dst_ptr + _screen.width * _screen.height - _screen.width;
do {
// check if the tile (xc,yc) is within the map range
@@ -589,7 +587,7 @@ static void DrawSmallMap(DrawPixelInfo *dpi, Window *w, int type, bool show_town
{
DrawPixelInfo *old_dpi;
int dx,dy, x, y, x2, y2;
- byte *ptr;
+ Pixel *ptr;
int tile_x;
int tile_y;
ViewPort *vp;
diff --git a/texteff.c b/texteff.c
index b13a27bec..1ef28762f 100644
--- a/texteff.c
+++ b/texteff.c
@@ -43,7 +43,7 @@ const int _textmessage_box_y = 150; // Height of box
const int _textmessage_box_bottom = 30; // Pixels from bottom
const int _textmessage_box_max_width = 400; // Max width of box
-static byte _textmessage_backup[150*400]; // (y * max_width)
+static Pixel _textmessage_backup[150 * 400]; // (y * max_width)
extern void memcpy_pitch(void *d, void *s, int w, int h, int spitch, int dpitch);
diff --git a/win32.c b/win32.c
index d5bcdf7c6..00107cc55 100644
--- a/win32.c
+++ b/win32.c
@@ -21,9 +21,9 @@
static struct {
HWND main_wnd;
HBITMAP dib_sect;
- void *bitmap_bits;
- void *buffer_bits;
- void *alloced_bits;
+ Pixel *bitmap_bits;
+ Pixel *buffer_bits;
+ Pixel *alloced_bits;
HPALETTE gdi_palette;
int width,height;
int width_org, height_org;
@@ -568,7 +568,7 @@ static bool AllocateDibSection(int w, int h)
DeleteObject(_wnd.dib_sect);
dc = GetDC(0);
- _wnd.dib_sect = CreateDIBSection(dc, bi, DIB_RGB_COLORS, &_wnd.bitmap_bits, NULL, 0);
+ _wnd.dib_sect = CreateDIBSection(dc, bi, DIB_RGB_COLORS, (void**)&_wnd.bitmap_bits, NULL, 0);
if (_wnd.dib_sect == NULL)
error("CreateDIBSection failed");
ReleaseDC(0, dc);
@@ -665,8 +665,8 @@ static void Win32GdiStop(void)
static void filter(int left, int top, int width, int height)
{
uint p = _screen.pitch;
- byte *s = (byte*)_wnd.buffer_bits + top * p + left;
- byte *d = (byte*)_wnd.bitmap_bits + top * p * 4 + left * 2;
+ const Pixel *s = _wnd.buffer_bits + top * p + left;
+ Pixel *d = _wnd.bitmap_bits + top * p * 4 + left * 2;
for (; height > 0; height--) {
int i;