mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-09 19:10:38 +00:00
(svn r9835) -Codechange: use Pixel typedef instead of byte where ever possible
This commit is contained in:
parent
f739aedf5b
commit
5f0e384ac0
12
src/gfx.cpp
12
src/gfx.cpp
@ -64,12 +64,12 @@ static byte _dirty_blocks[DIRTY_BYTES_PER_LINE * MAX_SCREEN_HEIGHT / 8];
|
|||||||
|
|
||||||
void memcpy_pitch(void *dst, void *src, int w, int h, int srcpitch, int dstpitch)
|
void memcpy_pitch(void *dst, void *src, int w, int h, int srcpitch, int dstpitch)
|
||||||
{
|
{
|
||||||
byte *dstp = (byte*)dst;
|
Pixel *dstp = (Pixel *)dst;
|
||||||
byte *srcp = (byte*)src;
|
Pixel *srcp = (Pixel *)src;
|
||||||
|
|
||||||
assert(h >= 0);
|
assert(h >= 0);
|
||||||
for (; h != 0; --h) {
|
for (; h != 0; --h) {
|
||||||
memcpy(dstp, srcp, w);
|
memcpy(dstp, srcp, w * sizeof(Pixel));
|
||||||
dstp += dstpitch;
|
dstp += dstpitch;
|
||||||
srcp += srcpitch;
|
srcp += srcpitch;
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ void GfxScroll(int left, int top, int width, int height, int xo, int yo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (ht = height; ht > 0; --ht) {
|
for (ht = height; ht > 0; --ht) {
|
||||||
memcpy(dst, src, width);
|
memcpy(dst, src, width * sizeof(Pixel));
|
||||||
src -= p;
|
src -= p;
|
||||||
dst -= p;
|
dst -= p;
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ void GfxScroll(int left, int top, int width, int height, int xo, int yo)
|
|||||||
/* the y-displacement may be 0 therefore we have to use memmove,
|
/* the y-displacement may be 0 therefore we have to use memmove,
|
||||||
* because source and destination may overlap */
|
* because source and destination may overlap */
|
||||||
for (ht = height; ht > 0; --ht) {
|
for (ht = height; ht > 0; --ht) {
|
||||||
memmove(dst, src, width);
|
memmove(dst, src, width * sizeof(Pixel));
|
||||||
src += p;
|
src += p;
|
||||||
dst += p;
|
dst += p;
|
||||||
}
|
}
|
||||||
@ -175,7 +175,7 @@ void GfxFillRect(int left, int top, int right, int bottom, int color)
|
|||||||
if (!HASBIT(color, PALETTE_MODIFIER_GREYOUT)) {
|
if (!HASBIT(color, PALETTE_MODIFIER_GREYOUT)) {
|
||||||
if (!HASBIT(color, USE_COLORTABLE)) {
|
if (!HASBIT(color, USE_COLORTABLE)) {
|
||||||
do {
|
do {
|
||||||
memset(dst, color, right);
|
memset(dst, color, right * sizeof(Pixel));
|
||||||
dst += dpi->pitch;
|
dst += dpi->pitch;
|
||||||
} while (--bottom);
|
} while (--bottom);
|
||||||
} else {
|
} else {
|
||||||
|
@ -449,7 +449,7 @@ void SetScreenshotFormat(int i)
|
|||||||
static void CurrentScreenCallback(void *userdata, Pixel *buf, uint y, uint pitch, uint n)
|
static void CurrentScreenCallback(void *userdata, Pixel *buf, uint y, uint pitch, uint n)
|
||||||
{
|
{
|
||||||
for (; n > 0; --n) {
|
for (; n > 0; --n) {
|
||||||
memcpy(buf, _screen.dst_ptr + y * _screen.pitch, _screen.width);
|
memcpy(buf, _screen.dst_ptr + y * _screen.pitch, _screen.width * sizeof(Pixel));
|
||||||
++y;
|
++y;
|
||||||
buf += pitch;
|
buf += pitch;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ static void CloseWindowsConsoleThread()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void *_dedicated_video_mem;
|
static Pixel *_dedicated_video_mem;
|
||||||
|
|
||||||
extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm);
|
extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm);
|
||||||
extern void SwitchMode(int new_mode);
|
extern void SwitchMode(int new_mode);
|
||||||
@ -122,7 +122,7 @@ static const char *DedicatedVideoStart(const char * const *parm)
|
|||||||
{
|
{
|
||||||
_screen.width = _screen.pitch = _cur_resolution[0];
|
_screen.width = _screen.pitch = _cur_resolution[0];
|
||||||
_screen.height = _cur_resolution[1];
|
_screen.height = _cur_resolution[1];
|
||||||
_dedicated_video_mem = malloc(_cur_resolution[0]*_cur_resolution[1]);
|
_dedicated_video_mem = (Pixel *)malloc(_cur_resolution[0] * _cur_resolution[1] * sizeof(Pixel));
|
||||||
|
|
||||||
SetDebugString("net=6");
|
SetDebugString("net=6");
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ static void DedicatedVideoMainLoop()
|
|||||||
next_tick = cur_ticks + 30;
|
next_tick = cur_ticks + 30;
|
||||||
|
|
||||||
GameLoop();
|
GameLoop();
|
||||||
_screen.dst_ptr = (Pixel*)_dedicated_video_mem;
|
_screen.dst_ptr = _dedicated_video_mem;
|
||||||
UpdateWindows();
|
UpdateWindows();
|
||||||
}
|
}
|
||||||
CSleep(1);
|
CSleep(1);
|
||||||
|
@ -7,13 +7,13 @@
|
|||||||
#include "../window.h"
|
#include "../window.h"
|
||||||
#include "null_v.h"
|
#include "null_v.h"
|
||||||
|
|
||||||
static void* _null_video_mem = NULL;
|
static Pixel *_null_video_mem = NULL;
|
||||||
|
|
||||||
static const char* NullVideoStart(const char* const* parm)
|
static const char* NullVideoStart(const char* const* parm)
|
||||||
{
|
{
|
||||||
_screen.width = _screen.pitch = _cur_resolution[0];
|
_screen.width = _screen.pitch = _cur_resolution[0];
|
||||||
_screen.height = _cur_resolution[1];
|
_screen.height = _cur_resolution[1];
|
||||||
_null_video_mem = malloc(_cur_resolution[0] * _cur_resolution[1]);
|
_null_video_mem = (Pixel *)malloc(_cur_resolution[0] * _cur_resolution[1] * sizeof(Pixel));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ static void NullVideoMainLoop()
|
|||||||
|
|
||||||
for (i = 0; i < 1000; i++) {
|
for (i = 0; i < 1000; i++) {
|
||||||
GameLoop();
|
GameLoop();
|
||||||
_screen.dst_ptr = (Pixel*)_null_video_mem;
|
_screen.dst_ptr = _null_video_mem;
|
||||||
UpdateWindows();
|
UpdateWindows();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ static bool CreateMainSurface(int w, int h)
|
|||||||
|
|
||||||
_screen.width = newscreen->w;
|
_screen.width = newscreen->w;
|
||||||
_screen.height = newscreen->h;
|
_screen.height = newscreen->h;
|
||||||
_screen.pitch = newscreen->pitch;
|
_screen.pitch = newscreen->pitch / sizeof(Pixel);
|
||||||
|
|
||||||
_sdl_screen = newscreen;
|
_sdl_screen = newscreen;
|
||||||
InitPalette();
|
InitPalette();
|
||||||
|
@ -671,7 +671,7 @@ static bool AllocateDibSection(int w, int h)
|
|||||||
|
|
||||||
if (_wnd.double_size) {
|
if (_wnd.double_size) {
|
||||||
w = ALIGN(w, 4);
|
w = ALIGN(w, 4);
|
||||||
_wnd.alloced_bits = _wnd.buffer_bits = (Pixel*)malloc(w * h);
|
_wnd.alloced_bits = _wnd.buffer_bits = (Pixel *)malloc(w * h * sizeof(Pixel));
|
||||||
w *= 2;
|
w *= 2;
|
||||||
h *= 2;
|
h *= 2;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user