| 1 | /* |
| 2 | * OpenTyrian: A modern cross-platform port of Tyrian |
| 3 | * Copyright (C) 2007-2010 The OpenTyrian Development Team |
| 4 | * |
| 5 | * Scale2x, Scale3x |
| 6 | * Copyright (C) 2001, 2002, 2003, 2004 Andrea Mazzoleni |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License |
| 10 | * as published by the Free Software Foundation; either version 2 |
| 11 | * of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 21 | */ |
| 22 | #include "video_scale.h"cxx . . $ `<file>/src/video_scale.h`/ |
| 23 | |
| 24 | #include "palette.h"cxx . . $ `<file>/src/palette.h`/ |
| 25 | #include "video.h"cxx . . $ `<file>/src/video.h`/ |
| 26 | |
| 27 | #include <assert.h> |
| 28 | #include <string.h> |
| 29 | |
| 30 | static void nn_32cxx . . $ nn_32(bacc2b3dc8d7ab53).(SDL_Surfacecxx . . $ SDL_Surface# *src_surface, SDL_Texturecxx . . $ SDL_Texture# *dst_texture); |
| 31 | static void nn_16cxx . . $ nn_16(bacc2b3dc8d7ab53).(SDL_Surfacecxx . . $ SDL_Surface# *src_surface, SDL_Texturecxx . . $ SDL_Texture# *dst_texture); |
| 32 | |
| 33 | static void scale2x_32cxx . . $ scale2x_32(bacc2b3dc8d7ab53).(SDL_Surfacecxx . . $ SDL_Surface# *src_surface, SDL_Texturecxx . . $ SDL_Texture# *dst_texture); |
| 34 | static void scale2x_16cxx . . $ scale2x_16(bacc2b3dc8d7ab53).(SDL_Surfacecxx . . $ SDL_Surface# *src_surface, SDL_Texturecxx . . $ SDL_Texture# *dst_texture); |
| 35 | static void scale3x_32cxx . . $ scale3x_32(bacc2b3dc8d7ab53).(SDL_Surfacecxx . . $ SDL_Surface# *src_surface, SDL_Texturecxx . . $ SDL_Texture# *dst_texture); |
| 36 | static void scale3x_16cxx . . $ scale3x_16(bacc2b3dc8d7ab53).(SDL_Surfacecxx . . $ SDL_Surface# *src_surface, SDL_Texturecxx . . $ SDL_Texture# *dst_texture); |
| 37 | |
| 38 | void hq2x_32cxx . . $ hq2x_32(bacc2b3dc8d7ab53).(SDL_Surfacecxx . . $ SDL_Surface# *src_surface, SDL_Texturecxx . . $ SDL_Texture# *dst_texture); |
| 39 | void hq3x_32cxx . . $ hq3x_32(bacc2b3dc8d7ab53).(SDL_Surfacecxx . . $ SDL_Surface# *src_surface, SDL_Texturecxx . . $ SDL_Texture# *dst_texture); |
| 40 | void hq4x_32cxx . . $ hq4x_32(bacc2b3dc8d7ab53).(SDL_Surfacecxx . . $ SDL_Surface# *src_surface, SDL_Texturecxx . . $ SDL_Texture# *dst_texture); |
| 41 | |
| 42 | uintcxx . . $ uint# scalercxx . . $ scaler.; |
| 43 | |
| 44 | const struct Scalerscxx . . $ Scalers# scalerscxx . . $ scalers.[] = |
| 45 | { |
| 46 | { 1 * vga_widthcxx . . $ `src/video.h:26:9`!, 1 * vga_heightcxx . . $ `src/video.h:27:9`!, nn_16cxx . . $ nn_16(bacc2b3dc8d7ab53)., nn_32cxx . . $ nn_32(bacc2b3dc8d7ab53)., "None" }, |
| 47 | { 2 * vga_widthcxx . . $ `src/video.h:26:9`!, 2 * vga_heightcxx . . $ `src/video.h:27:9`!, nn_16cxx . . $ nn_16(bacc2b3dc8d7ab53)., nn_32cxx . . $ nn_32(bacc2b3dc8d7ab53)., "2x" }, |
| 48 | { 2 * vga_widthcxx . . $ `src/video.h:26:9`!, 2 * vga_heightcxx . . $ `src/video.h:27:9`!, scale2x_16cxx . . $ scale2x_16(bacc2b3dc8d7ab53)., scale2x_32cxx . . $ scale2x_32(bacc2b3dc8d7ab53)., "Scale2x" }, |
| 49 | { 2 * vga_widthcxx . . $ `src/video.h:26:9`!, 2 * vga_heightcxx . . $ `src/video.h:27:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, hq2x_32cxx . . $ hq2x_32(bacc2b3dc8d7ab53)., "hq2x" }, |
| 50 | { 3 * vga_widthcxx . . $ `src/video.h:26:9`!, 3 * vga_heightcxx . . $ `src/video.h:27:9`!, nn_16cxx . . $ nn_16(bacc2b3dc8d7ab53)., nn_32cxx . . $ nn_32(bacc2b3dc8d7ab53)., "3x" }, |
| 51 | { 3 * vga_widthcxx . . $ `src/video.h:26:9`!, 3 * vga_heightcxx . . $ `src/video.h:27:9`!, scale3x_16cxx . . $ scale3x_16(bacc2b3dc8d7ab53)., scale3x_32cxx . . $ scale3x_32(bacc2b3dc8d7ab53)., "Scale3x" }, |
| 52 | { 3 * vga_widthcxx . . $ `src/video.h:26:9`!, 3 * vga_heightcxx . . $ `src/video.h:27:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, hq3x_32cxx . . $ hq3x_32(bacc2b3dc8d7ab53)., "hq3x" }, |
| 53 | { 4 * vga_widthcxx . . $ `src/video.h:26:9`!, 4 * vga_heightcxx . . $ `src/video.h:27:9`!, nn_16cxx . . $ nn_16(bacc2b3dc8d7ab53)., nn_32cxx . . $ nn_32(bacc2b3dc8d7ab53)., "4x" }, |
| 54 | { 4 * vga_widthcxx . . $ `src/video.h:26:9`!, 4 * vga_heightcxx . . $ `src/video.h:27:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, hq4x_32cxx . . $ hq4x_32(bacc2b3dc8d7ab53)., "hq4x" }, |
| 55 | }; |
| 56 | const uintcxx . . $ uint# scalers_countcxx . . $ scalers_count. = COUNTOFcxx . . $ `src/opentyr.h:27:9`!(scalers); |
| 57 | |
| 58 | void set_scaler_by_namecxx . . $ set_scaler_by_name(85c52e162fed56f9).(const char *name) |
| 59 | { |
| 60 | for (uintcxx . . $ uint# i = 0; i < scalers_countcxx . . $ scalers_count.; ++i) |
| 61 | { |
| 62 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(name, scalerscxx . . $ scalers.[i].namecxx . . $ Scalers#name.) == 0) |
| 63 | { |
| 64 | scalercxx . . $ scaler. = i; |
| 65 | break; |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | void nn_32cxx . . $ nn_32(bacc2b3dc8d7ab53).(SDL_Surfacecxx . . $ SDL_Surface# *src_surface, SDL_Texturecxx . . $ SDL_Texture# *dst_texture) |
| 71 | { |
| 72 | Uint8cxx . . $ Uint8# *src = src_surface->pixelscxx . . $ SDL_Surface#pixels., *src_temp; |
| 73 | Uint8cxx . . $ Uint8# *dst, *dst_temp; |
| 74 | |
| 75 | int src_pitch = src_surface->pitchcxx . . $ SDL_Surface#pitch.; |
| 76 | int dst_pitch; |
| 77 | |
| 78 | const int dst_Bpp = 4; // dst_surface->format->BytesPerPixel |
| 79 | int dst_width, dst_height; |
| 80 | SDL_QueryTexturecxx . . $ SDL_QueryTexture(ea18ca1178d0c92c).(dst_texture, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &dst_width, &dst_height); |
| 81 | |
| 82 | const int height = vga_heightcxx . . $ `src/video.h:27:9`!, // src_surface->h |
| 83 | width = vga_widthcxx . . $ `src/video.h:26:9`!, // src_surface->w |
| 84 | scale = dst_width / width; |
| 85 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(scale == dst_height / height); |
| 86 | |
| 87 | void* tmp_ptr; |
| 88 | SDL_LockTexturecxx . . $ SDL_LockTexture(8ee1ca797f83873a).(dst_texture, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &tmp_ptr, &dst_pitch); |
| 89 | dst = tmp_ptr; |
| 90 | |
| 91 | for (int y = height; y > 0; y--) |
| 92 | { |
| 93 | src_temp = src; |
| 94 | dst_temp = dst; |
| 95 | |
| 96 | for (int x = width; x > 0; x--) |
| 97 | { |
| 98 | for (int z = scale; z > 0; z--) |
| 99 | { |
| 100 | *(Uint32cxx . . $ Uint32# *)dst = rgb_palettecxx . . $ rgb_palette.[*src]; |
| 101 | dst += dst_Bpp; |
| 102 | } |
| 103 | src++; |
| 104 | } |
| 105 | |
| 106 | src = src_temp + src_pitch; |
| 107 | dst = dst_temp + dst_pitch; |
| 108 | |
| 109 | for (int z = scale; z > 1; z--) |
| 110 | { |
| 111 | memcpycxx . . $ memcpy(cc817cb175f282d).(dst, dst_temp, dst_width * dst_Bpp); |
| 112 | dst += dst_pitch; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | SDL_UnlockTexturecxx . . $ SDL_UnlockTexture(95a4f98c9f663ab8).(dst_texture); |
| 117 | } |
| 118 | |
| 119 | void nn_16cxx . . $ nn_16(bacc2b3dc8d7ab53).(SDL_Surfacecxx . . $ SDL_Surface# *src_surface, SDL_Texturecxx . . $ SDL_Texture# *dst_texture) |
| 120 | { |
| 121 | Uint8cxx . . $ Uint8# *src = src_surface->pixelscxx . . $ SDL_Surface#pixels., *src_temp; |
| 122 | Uint8cxx . . $ Uint8# *dst, *dst_temp; |
| 123 | |
| 124 | int src_pitch = src_surface->pitchcxx . . $ SDL_Surface#pitch.; |
| 125 | int dst_pitch; |
| 126 | |
| 127 | const int dst_Bpp = 2; // dst_surface->format->BytesPerPixel |
| 128 | int dst_width, dst_height; |
| 129 | SDL_QueryTexturecxx . . $ SDL_QueryTexture(ea18ca1178d0c92c).(dst_texture, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &dst_width, &dst_height); |
| 130 | |
| 131 | const int height = vga_heightcxx . . $ `src/video.h:27:9`!, // src_surface->h |
| 132 | width = vga_widthcxx . . $ `src/video.h:26:9`!, // src_surface->w |
| 133 | scale = dst_width / width; |
| 134 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(scale == dst_height / height); |
| 135 | |
| 136 | void* tmp_ptr; |
| 137 | SDL_LockTexturecxx . . $ SDL_LockTexture(8ee1ca797f83873a).(dst_texture, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &tmp_ptr, &dst_pitch); |
| 138 | dst = tmp_ptr; |
| 139 | |
| 140 | for (int y = height; y > 0; y--) |
| 141 | { |
| 142 | src_temp = src; |
| 143 | dst_temp = dst; |
| 144 | |
| 145 | for (int x = width; x > 0; x--) |
| 146 | { |
| 147 | for (int z = scale; z > 0; z--) |
| 148 | { |
| 149 | *(Uint16cxx . . $ Uint16# *)dst = rgb_palettecxx . . $ rgb_palette.[*src]; |
| 150 | dst += dst_Bpp; |
| 151 | } |
| 152 | src++; |
| 153 | } |
| 154 | |
| 155 | src = src_temp + src_pitch; |
| 156 | dst = dst_temp + dst_pitch; |
| 157 | |
| 158 | for (int z = scale; z > 1; z--) |
| 159 | { |
| 160 | memcpycxx . . $ memcpy(cc817cb175f282d).(dst, dst_temp, dst_width * dst_Bpp); |
| 161 | dst += dst_pitch; |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | SDL_UnlockTexturecxx . . $ SDL_UnlockTexture(95a4f98c9f663ab8).(dst_texture); |
| 166 | } |
| 167 | |
| 168 | void scale2x_32cxx . . $ scale2x_32(bacc2b3dc8d7ab53).(SDL_Surfacecxx . . $ SDL_Surface# *src_surface, SDL_Texturecxx . . $ SDL_Texture# *dst_texture) |
| 169 | { |
| 170 | Uint8cxx . . $ Uint8# *src = src_surface->pixelscxx . . $ SDL_Surface#pixels., *src_temp; |
| 171 | Uint8cxx . . $ Uint8# *dst, *dst_temp; |
| 172 | |
| 173 | int src_pitch = src_surface->pitchcxx . . $ SDL_Surface#pitch.; |
| 174 | int dst_pitch; |
| 175 | |
| 176 | const int dst_Bpp = 4, // dst_surface->format->BytesPerPixel |
| 177 | height = vga_heightcxx . . $ `src/video.h:27:9`!, // src_surface->h |
| 178 | width = vga_widthcxx . . $ `src/video.h:26:9`!; // src_surface->w |
| 179 | |
| 180 | void* tmp_ptr; |
| 181 | SDL_LockTexturecxx . . $ SDL_LockTexture(8ee1ca797f83873a).(dst_texture, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &tmp_ptr, &dst_pitch); |
| 182 | dst = tmp_ptr; |
| 183 | |
| 184 | int prevline, nextline; |
| 185 | |
| 186 | Uint32cxx . . $ Uint32# E0, E1, E2, E3, B, D, E, F, H; |
| 187 | for (int y = 0; y < height; y++) |
| 188 | { |
| 189 | src_temp = src; |
| 190 | dst_temp = dst; |
| 191 | |
| 192 | prevline = (y > 0) ? -src_pitch : 0; |
| 193 | nextline = (y < height - 1) ? src_pitch : 0; |
| 194 | |
| 195 | for (int x = 0; x < width; x++) |
| 196 | { |
| 197 | B = rgb_palettecxx . . $ rgb_palette.[*(src + prevline)]; |
| 198 | D = rgb_palettecxx . . $ rgb_palette.[*(x > 0 ? src - 1 : src)]; |
| 199 | E = rgb_palettecxx . . $ rgb_palette.[*src]; |
| 200 | F = rgb_palettecxx . . $ rgb_palette.[*(x < width - 1 ? src + 1 : src)]; |
| 201 | H = rgb_palettecxx . . $ rgb_palette.[*(src + nextline)]; |
| 202 | |
| 203 | if (B != H && D != F) |
| 204 | { |
| 205 | E0 = D == B ? D : E; |
| 206 | E1 = B == F ? F : E; |
| 207 | E2 = D == H ? D : E; |
| 208 | E3 = H == F ? F : E; |
| 209 | } |
| 210 | else |
| 211 | { |
| 212 | E0 = E1 = E2 = E3 = E; |
| 213 | } |
| 214 | |
| 215 | *(Uint32cxx . . $ Uint32# *)dst = E0; |
| 216 | *(Uint32cxx . . $ Uint32# *)(dst + dst_Bpp) = E1; |
| 217 | *(Uint32cxx . . $ Uint32# *)(dst + dst_pitch) = E2; |
| 218 | *(Uint32cxx . . $ Uint32# *)(dst + dst_pitch + dst_Bpp) = E3; |
| 219 | |
| 220 | src++; |
| 221 | dst += 2 * dst_Bpp; |
| 222 | } |
| 223 | |
| 224 | src = src_temp + src_pitch; |
| 225 | dst = dst_temp + 2 * dst_pitch; |
| 226 | } |
| 227 | |
| 228 | SDL_UnlockTexturecxx . . $ SDL_UnlockTexture(95a4f98c9f663ab8).(dst_texture); |
| 229 | } |
| 230 | |
| 231 | void scale2x_16cxx . . $ scale2x_16(bacc2b3dc8d7ab53).(SDL_Surfacecxx . . $ SDL_Surface# *src_surface, SDL_Texturecxx . . $ SDL_Texture# *dst_texture) |
| 232 | { |
| 233 | Uint8cxx . . $ Uint8# *src = src_surface->pixelscxx . . $ SDL_Surface#pixels., *src_temp; |
| 234 | Uint8cxx . . $ Uint8# *dst, *dst_temp; |
| 235 | |
| 236 | int src_pitch = src_surface->pitchcxx . . $ SDL_Surface#pitch.; |
| 237 | int dst_pitch; |
| 238 | |
| 239 | const int dst_Bpp = 2, // dst_surface->format->BytesPerPixel |
| 240 | height = vga_heightcxx . . $ `src/video.h:27:9`!, // src_surface->h |
| 241 | width = vga_widthcxx . . $ `src/video.h:26:9`!; // src_surface->w |
| 242 | |
| 243 | void* tmp_ptr; |
| 244 | SDL_LockTexturecxx . . $ SDL_LockTexture(8ee1ca797f83873a).(dst_texture, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &tmp_ptr, &dst_pitch); |
| 245 | dst = tmp_ptr; |
| 246 | |
| 247 | int prevline, nextline; |
| 248 | |
| 249 | Uint16cxx . . $ Uint16# E0, E1, E2, E3, B, D, E, F, H; |
| 250 | for (int y = 0; y < height; y++) |
| 251 | { |
| 252 | src_temp = src; |
| 253 | dst_temp = dst; |
| 254 | |
| 255 | prevline = (y > 0) ? -src_pitch : 0; |
| 256 | nextline = (y < height - 1) ? src_pitch : 0; |
| 257 | |
| 258 | for (int x = 0; x < width; x++) |
| 259 | { |
| 260 | B = rgb_palettecxx . . $ rgb_palette.[*(src + prevline)]; |
| 261 | D = rgb_palettecxx . . $ rgb_palette.[*(x > 0 ? src - 1 : src)]; |
| 262 | E = rgb_palettecxx . . $ rgb_palette.[*src]; |
| 263 | F = rgb_palettecxx . . $ rgb_palette.[*(x < width - 1 ? src + 1 : src)]; |
| 264 | H = rgb_palettecxx . . $ rgb_palette.[*(src + nextline)]; |
| 265 | |
| 266 | if (B != H && D != F) |
| 267 | { |
| 268 | E0 = D == B ? D : E; |
| 269 | E1 = B == F ? F : E; |
| 270 | E2 = D == H ? D : E; |
| 271 | E3 = H == F ? F : E; |
| 272 | } |
| 273 | else |
| 274 | { |
| 275 | E0 = E1 = E2 = E3 = E; |
| 276 | } |
| 277 | |
| 278 | *(Uint16cxx . . $ Uint16# *)dst = E0; |
| 279 | *(Uint16cxx . . $ Uint16# *)(dst + dst_Bpp) = E1; |
| 280 | *(Uint16cxx . . $ Uint16# *)(dst + dst_pitch) = E2; |
| 281 | *(Uint16cxx . . $ Uint16# *)(dst + dst_pitch + dst_Bpp) = E3; |
| 282 | |
| 283 | src++; |
| 284 | dst += 2 * dst_Bpp; |
| 285 | } |
| 286 | |
| 287 | src = src_temp + src_pitch; |
| 288 | dst = dst_temp + 2 * dst_pitch; |
| 289 | } |
| 290 | |
| 291 | SDL_UnlockTexturecxx . . $ SDL_UnlockTexture(95a4f98c9f663ab8).(dst_texture); |
| 292 | } |
| 293 | |
| 294 | void scale3x_32cxx . . $ scale3x_32(bacc2b3dc8d7ab53).(SDL_Surfacecxx . . $ SDL_Surface# *src_surface, SDL_Texturecxx . . $ SDL_Texture# *dst_texture) |
| 295 | { |
| 296 | Uint8cxx . . $ Uint8# *src = src_surface->pixelscxx . . $ SDL_Surface#pixels., *src_temp; |
| 297 | Uint8cxx . . $ Uint8# *dst, *dst_temp; |
| 298 | |
| 299 | int src_pitch = src_surface->pitchcxx . . $ SDL_Surface#pitch.; |
| 300 | int dst_pitch; |
| 301 | |
| 302 | const int dst_Bpp = 4, // dst_surface->format->BytesPerPixel |
| 303 | height = vga_heightcxx . . $ `src/video.h:27:9`!, // src_surface->h |
| 304 | width = vga_widthcxx . . $ `src/video.h:26:9`!; // src_surface->w |
| 305 | |
| 306 | void* tmp_ptr; |
| 307 | SDL_LockTexturecxx . . $ SDL_LockTexture(8ee1ca797f83873a).(dst_texture, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &tmp_ptr, &dst_pitch); |
| 308 | dst = tmp_ptr; |
| 309 | |
| 310 | int prevline, nextline; |
| 311 | |
| 312 | Uint32cxx . . $ Uint32# E0, E1, E2, E3, E4, E5, E6, E7, E8, A, B, C, D, E, F, G, H, I; |
| 313 | for (int y = 0; y < height; y++) |
| 314 | { |
| 315 | src_temp = src; |
| 316 | dst_temp = dst; |
| 317 | |
| 318 | prevline = (y > 0) ? -src_pitch : 0; |
| 319 | nextline = (y < height - 1) ? src_pitch : 0; |
| 320 | |
| 321 | for (int x = 0; x < width; x++) |
| 322 | { |
| 323 | A = rgb_palettecxx . . $ rgb_palette.[*(src + prevline - (x > 0 ? 1 : 0))]; |
| 324 | B = rgb_palettecxx . . $ rgb_palette.[*(src + prevline)]; |
| 325 | C = rgb_palettecxx . . $ rgb_palette.[*(src + prevline + (x < width - 1 ? 1 : 0))]; |
| 326 | D = rgb_palettecxx . . $ rgb_palette.[*(src - (x > 0 ? 1 : 0))]; |
| 327 | E = rgb_palettecxx . . $ rgb_palette.[*src]; |
| 328 | F = rgb_palettecxx . . $ rgb_palette.[*(src + (x < width - 1 ? 1 : 0))]; |
| 329 | G = rgb_palettecxx . . $ rgb_palette.[*(src + nextline - (x > 0 ? 1 : 0))]; |
| 330 | H = rgb_palettecxx . . $ rgb_palette.[*(src + nextline)]; |
| 331 | I = rgb_palettecxx . . $ rgb_palette.[*(src + nextline + (x < width - 1 ? 1 : 0))]; |
| 332 | |
| 333 | if (B != H && D != F) |
| 334 | { |
| 335 | E0 = D == B ? D : E; |
| 336 | E1 = (D == B && E != C) || (B == F && E != A) ? B : E; |
| 337 | E2 = B == F ? F : E; |
| 338 | E3 = (D == B && E != G) || (D == H && E != A) ? D : E; |
| 339 | E4 = E; |
| 340 | E5 = (B == F && E != I) || (H == F && E != C) ? F : E; |
| 341 | E6 = D == H ? D : E; |
| 342 | E7 = (D == H && E != I) || (H == F && E != G) ? H : E; |
| 343 | E8 = H == F ? F : E; |
| 344 | } |
| 345 | else |
| 346 | { |
| 347 | E0 = E1 = E2 = E3 = E4 = E5 = E6 = E7 = E8 = E; |
| 348 | } |
| 349 | |
| 350 | *(Uint32cxx . . $ Uint32# *)dst = E0; |
| 351 | *(Uint32cxx . . $ Uint32# *)(dst + dst_Bpp) = E1; |
| 352 | *(Uint32cxx . . $ Uint32# *)(dst + 2 * dst_Bpp) = E2; |
| 353 | *(Uint32cxx . . $ Uint32# *)(dst + dst_pitch) = E3; |
| 354 | *(Uint32cxx . . $ Uint32# *)(dst + dst_pitch + dst_Bpp) = E4; |
| 355 | *(Uint32cxx . . $ Uint32# *)(dst + dst_pitch + 2 * dst_Bpp) = E5; |
| 356 | *(Uint32cxx . . $ Uint32# *)(dst + 2 * dst_pitch) = E6; |
| 357 | *(Uint32cxx . . $ Uint32# *)(dst + 2 * dst_pitch + dst_Bpp) = E7; |
| 358 | *(Uint32cxx . . $ Uint32# *)(dst + 2 * dst_pitch + 2 * dst_Bpp) = E8; |
| 359 | |
| 360 | src++; |
| 361 | dst += 3 * dst_Bpp; |
| 362 | } |
| 363 | |
| 364 | src = src_temp + src_pitch; |
| 365 | dst = dst_temp + 3 * dst_pitch; |
| 366 | } |
| 367 | |
| 368 | SDL_UnlockTexturecxx . . $ SDL_UnlockTexture(95a4f98c9f663ab8).(dst_texture); |
| 369 | } |
| 370 | |
| 371 | void scale3x_16cxx . . $ scale3x_16(bacc2b3dc8d7ab53).(SDL_Surfacecxx . . $ SDL_Surface# *src_surface, SDL_Texturecxx . . $ SDL_Texture# *dst_texture) |
| 372 | { |
| 373 | Uint8cxx . . $ Uint8# *src = src_surface->pixelscxx . . $ SDL_Surface#pixels., *src_temp; |
| 374 | Uint8cxx . . $ Uint8# *dst, *dst_temp; |
| 375 | |
| 376 | int src_pitch = src_surface->pitchcxx . . $ SDL_Surface#pitch.; |
| 377 | int dst_pitch; |
| 378 | |
| 379 | const int dst_Bpp = 2, // dst_surface->format->BytesPerPixel |
| 380 | height = vga_heightcxx . . $ `src/video.h:27:9`!, // src_surface->h |
| 381 | width = vga_widthcxx . . $ `src/video.h:26:9`!; // src_surface->w |
| 382 | |
| 383 | void* tmp_ptr; |
| 384 | SDL_LockTexturecxx . . $ SDL_LockTexture(8ee1ca797f83873a).(dst_texture, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &tmp_ptr, &dst_pitch); |
| 385 | dst = tmp_ptr; |
| 386 | |
| 387 | int prevline, nextline; |
| 388 | |
| 389 | Uint16cxx . . $ Uint16# E0, E1, E2, E3, E4, E5, E6, E7, E8, A, B, C, D, E, F, G, H, I; |
| 390 | for (int y = 0; y < height; y++) |
| 391 | { |
| 392 | src_temp = src; |
| 393 | dst_temp = dst; |
| 394 | |
| 395 | prevline = (y > 0) ? -src_pitch : 0; |
| 396 | nextline = (y < height - 1) ? src_pitch : 0; |
| 397 | |
| 398 | for (int x = 0; x < width; x++) |
| 399 | { |
| 400 | A = rgb_palettecxx . . $ rgb_palette.[*(src + prevline - (x > 0 ? 1 : 0))]; |
| 401 | B = rgb_palettecxx . . $ rgb_palette.[*(src + prevline)]; |
| 402 | C = rgb_palettecxx . . $ rgb_palette.[*(src + prevline + (x < width - 1 ? 1 : 0))]; |
| 403 | D = rgb_palettecxx . . $ rgb_palette.[*(src - (x > 0 ? 1 : 0))]; |
| 404 | E = rgb_palettecxx . . $ rgb_palette.[*src]; |
| 405 | F = rgb_palettecxx . . $ rgb_palette.[*(src + (x < width - 1 ? 1 : 0))]; |
| 406 | G = rgb_palettecxx . . $ rgb_palette.[*(src + nextline - (x > 0 ? 1 : 0))]; |
| 407 | H = rgb_palettecxx . . $ rgb_palette.[*(src + nextline)]; |
| 408 | I = rgb_palettecxx . . $ rgb_palette.[*(src + nextline + (x < width - 1 ? 1 : 0))]; |
| 409 | |
| 410 | if (B != H && D != F) |
| 411 | { |
| 412 | E0 = D == B ? D : E; |
| 413 | E1 = (D == B && E != C) || (B == F && E != A) ? B : E; |
| 414 | E2 = B == F ? F : E; |
| 415 | E3 = (D == B && E != G) || (D == H && E != A) ? D : E; |
| 416 | E4 = E; |
| 417 | E5 = (B == F && E != I) || (H == F && E != C) ? F : E; |
| 418 | E6 = D == H ? D : E; |
| 419 | E7 = (D == H && E != I) || (H == F && E != G) ? H : E; |
| 420 | E8 = H == F ? F : E; |
| 421 | } |
| 422 | else |
| 423 | { |
| 424 | E0 = E1 = E2 = E3 = E4 = E5 = E6 = E7 = E8 = E; |
| 425 | } |
| 426 | |
| 427 | *(Uint16cxx . . $ Uint16# *)dst = E0; |
| 428 | *(Uint16cxx . . $ Uint16# *)(dst + dst_Bpp) = E1; |
| 429 | *(Uint16cxx . . $ Uint16# *)(dst + 2 * dst_Bpp) = E2; |
| 430 | *(Uint16cxx . . $ Uint16# *)(dst + dst_pitch) = E3; |
| 431 | *(Uint16cxx . . $ Uint16# *)(dst + dst_pitch + dst_Bpp) = E4; |
| 432 | *(Uint16cxx . . $ Uint16# *)(dst + dst_pitch + 2 * dst_Bpp) = E5; |
| 433 | *(Uint16cxx . . $ Uint16# *)(dst + 2 * dst_pitch) = E6; |
| 434 | *(Uint16cxx . . $ Uint16# *)(dst + 2 * dst_pitch + dst_Bpp) = E7; |
| 435 | *(Uint16cxx . . $ Uint16# *)(dst + 2 * dst_pitch + 2 * dst_Bpp) = E8; |
| 436 | |
| 437 | src++; |
| 438 | dst += 3 * dst_Bpp; |
| 439 | } |
| 440 | |
| 441 | src = src_temp + src_pitch; |
| 442 | dst = dst_temp + 3 * dst_pitch; |
| 443 | } |
| 444 | |
| 445 | SDL_UnlockTexturecxx . . $ SDL_UnlockTexture(95a4f98c9f663ab8).(dst_texture); |
| 446 | } |