Loading
#openttdcoop - Paste
Archives
Trending
Docs
Login
ABAP
ActionScript
ActionScript 3
Ada
AIMMS3
ALGOL 68
Apache configuration
AppleScript
Apt sources
ARM ASSEMBLER
ASM
ASP
asymptote
Autoconf
Autohotkey
AutoIt
AviSynth
awk
BASCOM AVR
Bash
Basic4GL
BibTeX
BlitzBasic
bnf
Boo
Brainfuck
C
C#
C (LoadRunner)
C (Mac)
C (WinAPI)
C++
C++ (Qt)
C++ (WinAPI)
CAD DCL
CAD Lisp
CFDG
ChaiScript
Chapel
CIL
Clojure
CMake
COBOL
CoffeeScript
ColdFusion
CSS
Cuesheet
D
Dart
DCL
DCPU-16 Assembly
DCS
Delphi
Diff
DIV
DOS
dot
E
ECMAScript
Eiffel
eMail (mbox)
EPC
Erlang
Euphoria
EZT
F#
Falcon
FO (abas-ERP)
Formula One
Fortran
FreeBasic
FreeSWITCH
GADV 4CS
GAMBAS
GDB
genero
Genie
glSlang
GML
GNU/Octave
GNU Gettext
GNU make
Gnuplot
Go
Groovy
GwBasic
Haskell
Haxe
HicEst
HQ9+
HTML
HTML5
Icon
INI
Inno
INTERCAL
Io
ISPF Panel
J
Java
Java(TM) 2 Platform Standard Edition 5.0
Javascript
JCL
jQuery
KiXtart
KLone C
KLone C++
LaTeX
LDIF
Liberty BASIC
Lisp
LLVM Intermediate Representation
Locomotive Basic
Logtalk
LOLcode
Lotus Notes @Formulas
LotusScript
LScript
LSL2
Lua
MagikSF
MapBasic
Matlab M
Microchip Assembler
Microsoft Registry
mIRC Scripting
MMIX
Modula-2
Modula-3
MOS 6502 (6510) ACME Cross Assembler format
MOS 6502 (6510) Kick Assembler format
MOS 6502 (6510) TASM/64TASS 1.46 Assembler format
Motorola 68000 - HiSoft Devpac ST 2 Assembler format
Motorola 68000 Assembler
MXML
MySQL
Nagios
NetRexx
newlisp
nginx
Nimrod
NML NewGRF Meta Language
NSIS
Oberon-2
Objeck Programming Language
Objective-C
OCaml
OCaml (brief)
ooRexx
OpenBSD Packet Filter
OpenOffice.org Basic
Oracle 8 SQL
Oracle 11 SQL
Oxygene
OZ
ParaSail
PARI/GP
Pascal
PCRE
per
Perl
Perl 6
PHP
PHP (brief)
PIC16
Pike
Pixel Bender 1.0
PL/I
PL/SQL
PostgreSQL
PostScript
POVRAY
PowerBuilder
PowerShell
ProFTPd configuration
Progress
Prolog
PROPERTIES
ProvideX
Puppet
PureBasic
Python
Python for S60
q/kdb+
QBasic/QuickBASIC
QML
R / S+
Racket
Rails
RBScript
REBOL
rexx
robots.txt
RPM Specification File
Ruby
Rust
SAS
Scala
Scheme
SciLab
SCL
sdlBasic
Smalltalk
Smarty
SPARK
SPARQL
SQL
Squirrel Script
Squirrel Script with OpenTTD AI/GS
StandardML
StoneScript
SystemVerilog
T-SQL
TCL
Tera Term Macro
Text
thinBasic
TypoScript
Unicon (Unified Extended Dialect of Icon)
Uno Idl
Unreal Script
UPC
Urbi
Vala
vb.net
VBScript
Vedit macro language
Verilog
VHDL
Vim Script
Visual Basic
Visual Fox Pro
Visual Prolog
Whitespace
Whois (RPSL format)
Winbatch
X++
XBasic
XML
Xorg configuration
YAML
ZiLOG Z80 Assembler
ZXBasic
Index: src/blitter/32bpp_anim.cpp =================================================================== --- src/blitter/32bpp_anim.cpp (revision 27795) +++ src/blitter/32bpp_anim.cpp (working copy) @@ -39,6 +39,7 @@ } Colour *dst = (Colour *)bp->dst + bp->top * bp->pitch + bp->left; + assert(_screen.pitch == this->anim_buf_pitch); // precondition for translating 'bp->dst' into an 'anim_buf' offset below. uint16 *anim = this->anim_buf + ((uint32 *)bp->dst - (uint32 *)_screen.dst_ptr) + bp->top * this->anim_buf_width + bp->left; const byte *remap = bp->remap; // store so we don't have to access it via bp everytime @@ -45,7 +46,7 @@ for (int y = 0; y < bp->height; y++) { Colour *dst_ln = dst + bp->pitch; - uint16 *anim_ln = anim + this->anim_buf_width; + uint16 *anim_ln = anim + this->anim_buf_pitch; const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px); src_px++; @@ -279,10 +280,9 @@ } Colour *udst = (Colour *)dst; - uint16 *anim; + assert(_screen.pitch == this->anim_buf_pitch); // precondition for translating 'dst' into an 'anim_buf' offset below. + uint16 *anim = this->anim_buf + ((uint32 *)dst - (uint32 *)_screen.dst_ptr); - anim = this->anim_buf + ((uint32 *)dst - (uint32 *)_screen.dst_ptr); - if (pal == PALETTE_TO_TRANSPARENT) { do { for (int i = 0; i != width; i++) { @@ -292,7 +292,7 @@ anim++; } udst = udst - width + _screen.pitch; - anim = anim - width + this->anim_buf_width; + anim = anim - width + this->anim_buf_pitch; } while (--height); return; } @@ -305,7 +305,7 @@ anim++; } udst = udst - width + _screen.pitch; - anim = anim - width + this->anim_buf_width; + anim = anim - width + this->anim_buf_pitch; } while (--height); return; } @@ -319,7 +319,8 @@ /* Set the colour in the anim-buffer too, if we are rendering to the screen */ if (_screen_disable_anim) return; - this->anim_buf[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * this->anim_buf_width] = colour | (DEFAULT_BRIGHTNESS << 8); + assert(_screen.pitch == this->anim_buf_pitch); // precondition for translating 'video' into an 'anim_buf' offset below. + this->anim_buf[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * this->anim_buf_pitch] = colour | (DEFAULT_BRIGHTNESS << 8); } void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 colour) @@ -331,10 +332,9 @@ } Colour colour32 = LookupColourInPalette(colour); - uint16 *anim_line; + assert(_screen.pitch == this->anim_buf_pitch); // precondition for translating 'video' into an 'anim_buf' offset below. + uint16 *anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf; - anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf; - do { Colour *dst = (Colour *)video; uint16 *anim = anim_line; @@ -347,7 +347,7 @@ anim++; } video = (uint32 *)video + _screen.pitch; - anim_line += this->anim_buf_width; + anim_line += this->anim_buf_pitch; } while (--height); } @@ -357,6 +357,7 @@ assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch); Colour *dst = (Colour *)video; const uint32 *usrc = (const uint32 *)src; + assert(_screen.pitch == this->anim_buf_pitch); // precondition for translating 'video' into an 'anim_buf' offset below. uint16 *anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf; for (; height > 0; height--) { @@ -370,7 +371,7 @@ /* Copy back the anim-buffer */ memcpy(anim_line, usrc, width * sizeof(uint16)); usrc = (const uint32 *)((const uint16 *)usrc + width); - anim_line += this->anim_buf_width; + anim_line += this->anim_buf_pitch; /* Okay, it is *very* likely that the image we stored is using * the wrong palette animated colours. There are two things we @@ -397,11 +398,11 @@ assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch); uint32 *udst = (uint32 *)dst; const uint32 *src = (const uint32 *)video; - const uint16 *anim_line; if (this->anim_buf == NULL) return; - anim_line = ((const uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf; + assert(_screen.pitch == this->anim_buf_pitch); // precondition for translating 'video' into an 'anim_buf' offset below. + const uint16 *anim_line = ((const uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf; for (; height > 0; height--) { memcpy(udst, src, width * sizeof(uint32)); @@ -410,7 +411,7 @@ /* Copy the anim-buffer */ memcpy(udst, anim_line, width * sizeof(uint16)); udst = (uint32 *)((uint16 *)udst + width); - anim_line += this->anim_buf_width; + anim_line += this->anim_buf_pitch; } } @@ -422,8 +423,8 @@ /* We need to scroll the anim-buffer too */ if (scroll_y > 0) { - dst = this->anim_buf + left + (top + height - 1) * this->anim_buf_width; - src = dst - scroll_y * this->anim_buf_width; + dst = this->anim_buf + left + (top + height - 1) * this->anim_buf_pitch; + src = dst - scroll_y * this->anim_buf_pitch; /* Adjust left & width */ if (scroll_x >= 0) { @@ -436,13 +437,13 @@ uint th = height - scroll_y; for (; th > 0; th--) { memcpy(dst, src, tw * sizeof(uint16)); - src -= this->anim_buf_width; - dst -= this->anim_buf_width; + src -= this->anim_buf_pitch; + dst -= this->anim_buf_pitch; } } else { /* Calculate pointers */ - dst = this->anim_buf + left + top * this->anim_buf_width; - src = dst - scroll_y * this->anim_buf_width; + dst = this->anim_buf + left + top * this->anim_buf_pitch; + src = dst - scroll_y * this->anim_buf_pitch; /* Adjust left & width */ if (scroll_x >= 0) { @@ -457,8 +458,8 @@ uint th = height + scroll_y; for (; th > 0; th--) { memmove(dst, src, tw * sizeof(uint16)); - src += this->anim_buf_width; - dst += this->anim_buf_width; + src += this->anim_buf_pitch; + dst += this->anim_buf_pitch; } } @@ -495,6 +496,7 @@ anim++; } dst += _screen.pitch - this->anim_buf_width; + anim += this->anim_buf_pitch - this->anim_buf_width; } /* Make sure the backend redraws the whole screen */ @@ -508,11 +510,13 @@ void Blitter_32bppAnim::PostResize() { - if (_screen.width != this->anim_buf_width || _screen.height != this->anim_buf_height) { + if (_screen.width != this->anim_buf_width || _screen.height != this->anim_buf_height || + _screen.pitch != this->anim_buf_pitch) { /* The size of the screen changed; we can assume we can wipe all data from our buffer */ free(this->anim_buf); - this->anim_buf = CallocT<uint16>(_screen.width * _screen.height); this->anim_buf_width = _screen.width; this->anim_buf_height = _screen.height; + this->anim_buf_pitch = _screen.pitch; + this->anim_buf = CallocT<uint16>(this->anim_buf_height * this->anim_buf_pitch); } } Index: src/blitter/32bpp_anim.hpp =================================================================== --- src/blitter/32bpp_anim.hpp (revision 27795) +++ src/blitter/32bpp_anim.hpp (working copy) @@ -20,6 +20,7 @@ uint16 *anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation int anim_buf_width; ///< The width of the animation buffer. int anim_buf_height; ///< The height of the animation buffer. + int anim_buf_pitch; ///< The pitch of the animation buffer. Palette palette; ///< The current palette. public: @@ -26,7 +27,8 @@ Blitter_32bppAnim() : anim_buf(NULL), anim_buf_width(0), - anim_buf_height(0) + anim_buf_height(0), + anim_buf_pitch(0) { this->palette = _cur_palette; } Index: src/blitter/32bpp_anim_sse4.cpp =================================================================== --- src/blitter/32bpp_anim_sse4.cpp (revision 27795) +++ src/blitter/32bpp_anim_sse4.cpp (working copy) @@ -35,7 +35,8 @@ { const byte * const remap = bp->remap; Colour *dst_line = (Colour *) bp->dst + bp->top * bp->pitch + bp->left; - uint16 *anim_line = this->anim_buf + ((uint32 *)bp->dst - (uint32 *)_screen.dst_ptr) + bp->top * this->anim_buf_width + bp->left; + assert(_screen.pitch == this->anim_buf_pitch); // precondition for translating 'bp->dst' into an 'anim_buf' offset below. + uint16 *anim_line = this->anim_buf + ((uint32 *)bp->dst - (uint32 *)_screen.dst_ptr) + bp->top * this->anim_buf_pitch + bp->left; int effective_width = bp->width; /* Find where to start reading in the source sprite. */ @@ -353,7 +354,7 @@ if (mode != BM_TRANSPARENT) src_mv_line += si->sprite_width; src_rgba_line = (const Colour*) ((const byte*) src_rgba_line + si->sprite_line_size); dst_line += bp->pitch; - anim_line += this->anim_buf_width; + anim_line += this->anim_buf_pitch; } } IGNORE_UNINITIALIZED_WARNING_STOP
Mark as private
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
forever