| 1 | |
| 2 | /** |
| 3 | * |
| 4 | * @file paletteeffects.cpp |
| 5 | * |
| 6 | * Part of the OpenJazz project |
| 7 | * |
| 8 | * @par History: |
| 9 | * - 23rd August 2005: Created main.c |
| 10 | * - 22nd July 2008: Created util.c from parts of main.c |
| 11 | * - 3rd February 2009: Renamed main.c to main.cpp and util.c to util.cpp |
| 12 | * - 4th February 2009: Created palette.cpp from parts of main.cpp and util.cpp |
| 13 | * - 1st August 2009: Renamed palette.cpp to paletteeffects.cpp |
| 14 | * |
| 15 | * @par Licence: |
| 16 | * Copyright (c) 2005-2013 AJ Thomson |
| 17 | * |
| 18 | * OpenJazz is distributed under the terms of |
| 19 | * the GNU General Public License, version 2.0 |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | |
| 24 | #include "paletteeffects.h"cxx . . $ `<file>/src/io/gfx/paletteeffects.h`/ |
| 25 | #include "video.h"cxx . . $ `<file>/src/io/gfx/video.h`/ |
| 26 | |
| 27 | #include "jj1/level/jj1level.h"cxx . . $ `<file>/src/jj1/level/jj1level.h`/ |
| 28 | #ifdef ENABLE_JJ2 |
| 29 | #include "jj2/level/jj2level.h" |
| 30 | #endif |
| 31 | #include "level/levelplayer.h"cxx . . $ `<file>/src/level/levelplayer.h`/ |
| 32 | #include "player/player.h"cxx . . $ `<file>/src/player/player.h`/ |
| 33 | |
| 34 | #include <string.h> |
| 35 | |
| 36 | #ifdef OJ_SDL3 |
| 37 | #include <SDL3/SDL.h> |
| 38 | #else |
| 39 | #include <SDL.h> |
| 40 | #endif |
| 41 | |
| 42 | /** |
| 43 | * Create a new palette effect. |
| 44 | * |
| 45 | * @param nextPE The next palette effect |
| 46 | */ |
| 47 | PaletteEffectcxx . . $ PaletteEffect#::PaletteEffectcxx . . $ PaletteEffect#PaletteEffect(1d2f0146fec914e1). (PaletteEffectcxx . . $ PaletteEffect#* nextPE) { |
| 48 | |
| 49 | nextcxx . . $ PaletteEffect#next. = nextPE; |
| 50 | |
| 51 | } |
| 52 | |
| 53 | |
| 54 | /** |
| 55 | * Delete the palette effect. |
| 56 | */ |
| 57 | PaletteEffectcxx . . $ PaletteEffect#::~cxx . . $ PaletteEffect#`~PaletteEffect`(49f6e7a06ebc5aa8).PaletteEffectcxx . . $ PaletteEffect# () { |
| 58 | |
| 59 | if (nextcxx . . $ PaletteEffect#next.) delete nextcxx . . $ PaletteEffect#next.; |
| 60 | |
| 61 | } |
| 62 | |
| 63 | |
| 64 | /** |
| 65 | * Apply the palette effect. |
| 66 | * |
| 67 | * @param shownPalette The palette the effect will be applied to |
| 68 | * @param direct Whether or not to apply the effect directly |
| 69 | * @param mspf Ticks per frame |
| 70 | * @param isStatic Whether the effect should advance after applying |
| 71 | */ |
| 72 | void PaletteEffectcxx . . $ PaletteEffect#::applycxx . . $ PaletteEffect#apply(a0d1f6d228fe1f03). (SDL_Color* shownPalette, bool direct, int mspf, bool isStatic) { |
| 73 | |
| 74 | // Apply the next palette effect |
| 75 | if (nextcxx . . $ PaletteEffect#next.) nextcxx . . $ PaletteEffect#next.->applycxx . . $ PaletteEffect#apply(a0d1f6d228fe1f03).(shownPalette, direct, mspf, isStatic); |
| 76 | |
| 77 | } |
| 78 | |
| 79 | |
| 80 | /** |
| 81 | * Create a new white-in palette effect. |
| 82 | * |
| 83 | * @param newDuration The length of time the effect will last |
| 84 | * @param nextPE The next palette effect |
| 85 | */ |
| 86 | WhiteInPaletteEffectcxx . . $ WhiteInPaletteEffect#::WhiteInPaletteEffectcxx . . $ WhiteInPaletteEffect#WhiteInPaletteEffect(d7b903d8eaeca941). |
| 87 | (int newDuration, PaletteEffectcxx . . $ PaletteEffect#* nextPE) : PaletteEffectcxx . . $ PaletteEffect# (nextPE) { |
| 88 | |
| 89 | durationcxx . . $ WhiteInPaletteEffect#duration. = newDuration; |
| 90 | whitenesscxx . . $ WhiteInPaletteEffect#whiteness. = F1cxx . . $ `src/types.h:31:9`! + FHcxx . . $ `src/types.h:30:9`!; |
| 91 | |
| 92 | } |
| 93 | |
| 94 | |
| 95 | /** |
| 96 | * Apply the palette effect. |
| 97 | * |
| 98 | * @param shownPalette The palette the effect will be applied to |
| 99 | * @param direct Whether or not to apply the effect directly |
| 100 | * @param mspf Ticks per frame |
| 101 | * @param isStatic Whether the effect should advance after applying |
| 102 | */ |
| 103 | void WhiteInPaletteEffectcxx . . $ WhiteInPaletteEffect#::applycxx . . $ WhiteInPaletteEffect#apply(a0d1f6d228fe1f03). (SDL_Color* shownPalette, bool direct, int mspf, bool isStatic) { |
| 104 | |
| 105 | int count; |
| 106 | |
| 107 | // Apply the next palette effect |
| 108 | if (nextcxx . . $ PaletteEffect#next.) nextcxx . . $ PaletteEffect#next.->applycxx . . $ PaletteEffect#apply(a0d1f6d228fe1f03).(shownPalette, direct, mspf, isStatic); |
| 109 | |
| 110 | if (whitenesscxx . . $ WhiteInPaletteEffect#whiteness. > F1cxx . . $ `src/types.h:31:9`!) { |
| 111 | |
| 112 | memset(shownPalette, 255, sizeof(SDL_Color) * MAX_PALETTE_COLORScxx . . $ `src/OpenJazz.h:71:9`!); |
| 113 | |
| 114 | if (!isStatic) whitenesscxx . . $ WhiteInPaletteEffect#whiteness. -= ITOFcxx . . $ `src/types.h:53:9`!(mspf) / durationcxx . . $ WhiteInPaletteEffect#duration.; |
| 115 | |
| 116 | } else if (whitenesscxx . . $ WhiteInPaletteEffect#whiteness. > 0) { |
| 117 | |
| 118 | for (count = 0; count < MAX_PALETTE_COLORScxx . . $ `src/OpenJazz.h:71:9`!; count++) { |
| 119 | |
| 120 | shownPalette[count].rcxx . . $ SDL_Color#r. = 255 - |
| 121 | FTOIcxx . . $ `src/types.h:52:9`!((255 - shownPalette[count].r) * (F1cxx . . $ `src/types.h:31:9`! - whiteness)); |
| 122 | shownPalette[count].gcxx . . $ SDL_Color#g. = 255 - |
| 123 | FTOIcxx . . $ `src/types.h:52:9`!((255 - shownPalette[count].g) * (F1cxx . . $ `src/types.h:31:9`! - whiteness)); |
| 124 | shownPalette[count].bcxx . . $ SDL_Color#b. = 255 - |
| 125 | FTOIcxx . . $ `src/types.h:52:9`!((255 - shownPalette[count].b) * (F1cxx . . $ `src/types.h:31:9`! - whiteness)); |
| 126 | |
| 127 | } |
| 128 | |
| 129 | if (!isStatic) whitenesscxx . . $ WhiteInPaletteEffect#whiteness. -= ITOFcxx . . $ `src/types.h:53:9`!(mspf) / durationcxx . . $ WhiteInPaletteEffect#duration.; |
| 130 | |
| 131 | } |
| 132 | |
| 133 | if (direct) videocxx . . $ video..changePalettecxx . . $ Video#changePalette(dc6239902d762776).(shownPalette, 0, MAX_PALETTE_COLORScxx . . $ `src/OpenJazz.h:71:9`!); |
| 134 | |
| 135 | } |
| 136 | |
| 137 | |
| 138 | /** |
| 139 | * Create a new fade-in palette effect. |
| 140 | * |
| 141 | * @param newDuration The length of time the effect will last |
| 142 | * @param nextPE The next palette effect |
| 143 | */ |
| 144 | FadeInPaletteEffectcxx . . $ FadeInPaletteEffect#::FadeInPaletteEffectcxx . . $ FadeInPaletteEffect#FadeInPaletteEffect(d7b903d8eaeca941). |
| 145 | (int newDuration, PaletteEffectcxx . . $ PaletteEffect#* nextPE) : PaletteEffectcxx . . $ PaletteEffect# (nextPE) { |
| 146 | |
| 147 | durationcxx . . $ FadeInPaletteEffect#duration. = newDuration; |
| 148 | blacknesscxx . . $ FadeInPaletteEffect#blackness. = F1cxx . . $ `src/types.h:31:9`! + FHcxx . . $ `src/types.h:30:9`!; |
| 149 | |
| 150 | } |
| 151 | |
| 152 | |
| 153 | /** |
| 154 | * Apply the palette effect. |
| 155 | * |
| 156 | * @param shownPalette The palette the effect will be applied to |
| 157 | * @param direct Whether or not to apply the effect directly |
| 158 | * @param mspf Ticks per frame |
| 159 | * @param isStatic Whether the effect should advance after applying |
| 160 | */ |
| 161 | void FadeInPaletteEffectcxx . . $ FadeInPaletteEffect#::applycxx . . $ FadeInPaletteEffect#apply(a0d1f6d228fe1f03). (SDL_Color* shownPalette, bool direct, int mspf, bool isStatic) { |
| 162 | |
| 163 | int count; |
| 164 | |
| 165 | // Apply the next palette effect |
| 166 | if (nextcxx . . $ PaletteEffect#next.) nextcxx . . $ PaletteEffect#next.->applycxx . . $ PaletteEffect#apply(a0d1f6d228fe1f03).(shownPalette, direct, mspf, isStatic); |
| 167 | |
| 168 | |
| 169 | if (blacknesscxx . . $ FadeInPaletteEffect#blackness. > F1cxx . . $ `src/types.h:31:9`!) { |
| 170 | |
| 171 | memset(shownPalette, 0, sizeof(SDL_Color) * MAX_PALETTE_COLORScxx . . $ `src/OpenJazz.h:71:9`!); |
| 172 | |
| 173 | if (!isStatic) blacknesscxx . . $ FadeInPaletteEffect#blackness. -= ITOFcxx . . $ `src/types.h:53:9`!(mspf) / durationcxx . . $ FadeInPaletteEffect#duration.; |
| 174 | |
| 175 | } else if (blacknesscxx . . $ FadeInPaletteEffect#blackness. > 0) { |
| 176 | |
| 177 | for (count = 0; count < MAX_PALETTE_COLORScxx . . $ `src/OpenJazz.h:71:9`!; count++) { |
| 178 | |
| 179 | shownPalette[count].rcxx . . $ SDL_Color#r. = |
| 180 | FTOIcxx . . $ `src/types.h:52:9`!(shownPalette[count].r * (F1cxx . . $ `src/types.h:31:9`! - blackness)); |
| 181 | shownPalette[count].gcxx . . $ SDL_Color#g. = |
| 182 | FTOIcxx . . $ `src/types.h:52:9`!(shownPalette[count].g * (F1cxx . . $ `src/types.h:31:9`! - blackness)); |
| 183 | shownPalette[count].bcxx . . $ SDL_Color#b. = |
| 184 | FTOIcxx . . $ `src/types.h:52:9`!(shownPalette[count].b * (F1cxx . . $ `src/types.h:31:9`! - blackness)); |
| 185 | |
| 186 | } |
| 187 | |
| 188 | if (!isStatic) blacknesscxx . . $ FadeInPaletteEffect#blackness. -= ITOFcxx . . $ `src/types.h:53:9`!(mspf) / durationcxx . . $ FadeInPaletteEffect#duration.; |
| 189 | |
| 190 | } |
| 191 | |
| 192 | if (direct) videocxx . . $ video..changePalettecxx . . $ Video#changePalette(dc6239902d762776).(shownPalette, 0, MAX_PALETTE_COLORScxx . . $ `src/OpenJazz.h:71:9`!); |
| 193 | |
| 194 | } |
| 195 | |
| 196 | |
| 197 | /** |
| 198 | * Create a new white-out palette effect. |
| 199 | * |
| 200 | * @param newDuration The length of time the effect will last |
| 201 | * @param nextPE The next palette effect |
| 202 | */ |
| 203 | WhiteOutPaletteEffectcxx . . $ WhiteOutPaletteEffect#::WhiteOutPaletteEffectcxx . . $ WhiteOutPaletteEffect#WhiteOutPaletteEffect(d7b903d8eaeca941). |
| 204 | (int newDuration, PaletteEffectcxx . . $ PaletteEffect#* nextPE) : PaletteEffectcxx . . $ PaletteEffect# (nextPE) { |
| 205 | |
| 206 | durationcxx . . $ WhiteOutPaletteEffect#duration. = newDuration; |
| 207 | whitenesscxx . . $ WhiteOutPaletteEffect#whiteness. = 0; |
| 208 | |
| 209 | } |
| 210 | |
| 211 | |
| 212 | /** |
| 213 | * Apply the palette effect. |
| 214 | * |
| 215 | * @param shownPalette The palette the effect will be applied to |
| 216 | * @param direct Whether or not to apply the effect directly |
| 217 | * @param mspf Ticks per frame |
| 218 | * @param isStatic Whether the effect should advance after applying |
| 219 | */ |
| 220 | void WhiteOutPaletteEffectcxx . . $ WhiteOutPaletteEffect#::applycxx . . $ WhiteOutPaletteEffect#apply(a0d1f6d228fe1f03). (SDL_Color* shownPalette, bool direct, int mspf, bool isStatic) { |
| 221 | |
| 222 | // Apply the next palette effect |
| 223 | if (nextcxx . . $ PaletteEffect#next.) nextcxx . . $ PaletteEffect#next.->applycxx . . $ PaletteEffect#apply(a0d1f6d228fe1f03).(shownPalette, direct, mspf, isStatic); |
| 224 | |
| 225 | |
| 226 | if (whitenesscxx . . $ WhiteOutPaletteEffect#whiteness. > F1cxx . . $ `src/types.h:31:9`!) { |
| 227 | |
| 228 | memset(shownPalette, 255, sizeof(SDL_Color) * MAX_PALETTE_COLORScxx . . $ `src/OpenJazz.h:71:9`!); |
| 229 | |
| 230 | } else { |
| 231 | |
| 232 | if (whitenesscxx . . $ WhiteOutPaletteEffect#whiteness. > 0) { |
| 233 | |
| 234 | for (int i = 0; i < MAX_PALETTE_COLORScxx . . $ `src/OpenJazz.h:71:9`!; i++) { |
| 235 | |
| 236 | shownPalette[i].rcxx . . $ SDL_Color#r. = 255 - |
| 237 | FTOIcxx . . $ `src/types.h:52:9`!((255 - shownPalette[i].r) * (F1cxx . . $ `src/types.h:31:9`! - whiteness)); |
| 238 | shownPalette[i].gcxx . . $ SDL_Color#g. = 255 - |
| 239 | FTOIcxx . . $ `src/types.h:52:9`!((255 - shownPalette[i].g) * (F1cxx . . $ `src/types.h:31:9`! - whiteness)); |
| 240 | shownPalette[i].bcxx . . $ SDL_Color#b. = 255 - |
| 241 | FTOIcxx . . $ `src/types.h:52:9`!((255 - shownPalette[i].b) * (F1cxx . . $ `src/types.h:31:9`! - whiteness)); |
| 242 | |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | if (!isStatic) whitenesscxx . . $ WhiteOutPaletteEffect#whiteness. += ITOFcxx . . $ `src/types.h:53:9`!(mspf) / durationcxx . . $ WhiteOutPaletteEffect#duration.; |
| 247 | |
| 248 | } |
| 249 | |
| 250 | if (direct) videocxx . . $ video..changePalettecxx . . $ Video#changePalette(dc6239902d762776).(shownPalette, 0, MAX_PALETTE_COLORScxx . . $ `src/OpenJazz.h:71:9`!); |
| 251 | |
| 252 | } |
| 253 | |
| 254 | |
| 255 | /** |
| 256 | * Create a new fade-out palette effect. |
| 257 | * |
| 258 | * @param newDuration The length of time the effect will last |
| 259 | * @param nextPE The next palette effect |
| 260 | */ |
| 261 | FadeOutPaletteEffectcxx . . $ FadeOutPaletteEffect#::FadeOutPaletteEffectcxx . . $ FadeOutPaletteEffect#FadeOutPaletteEffect(d7b903d8eaeca941). |
| 262 | (int newDuration, PaletteEffectcxx . . $ PaletteEffect#* nextPE) : PaletteEffectcxx . . $ PaletteEffect# (nextPE) { |
| 263 | |
| 264 | durationcxx . . $ FadeOutPaletteEffect#duration. = newDuration; |
| 265 | blacknesscxx . . $ FadeOutPaletteEffect#blackness. = -(F2cxx . . $ `src/types.h:32:9`! + F1cxx . . $ `src/types.h:31:9`!); |
| 266 | |
| 267 | } |
| 268 | |
| 269 | |
| 270 | /** |
| 271 | * Apply the palette effect. |
| 272 | * |
| 273 | * @param shownPalette The palette the effect will be applied to |
| 274 | * @param direct Whether or not to apply the effect directly |
| 275 | * @param mspf Ticks per frame |
| 276 | * @param isStatic Whether the effect should advance after applying |
| 277 | */ |
| 278 | void FadeOutPaletteEffectcxx . . $ FadeOutPaletteEffect#::applycxx . . $ FadeOutPaletteEffect#apply(a0d1f6d228fe1f03). (SDL_Color* shownPalette, bool direct, int mspf, bool isStatic) { |
| 279 | |
| 280 | // Apply the next palette effect |
| 281 | if (nextcxx . . $ PaletteEffect#next.) nextcxx . . $ PaletteEffect#next.->applycxx . . $ PaletteEffect#apply(a0d1f6d228fe1f03).(shownPalette, direct, mspf, isStatic); |
| 282 | |
| 283 | if (blacknesscxx . . $ FadeOutPaletteEffect#blackness. > F1cxx . . $ `src/types.h:31:9`!) { |
| 284 | |
| 285 | memset(shownPalette, 0, sizeof(SDL_Color) * MAX_PALETTE_COLORScxx . . $ `src/OpenJazz.h:71:9`!); |
| 286 | |
| 287 | } else { |
| 288 | |
| 289 | if (blacknesscxx . . $ FadeOutPaletteEffect#blackness. > 0) { |
| 290 | |
| 291 | for (int i = 0; i < MAX_PALETTE_COLORScxx . . $ `src/OpenJazz.h:71:9`!; i++) { |
| 292 | |
| 293 | shownPalette[i].rcxx . . $ SDL_Color#r. = FTOIcxx . . $ `src/types.h:52:9`!(shownPalette[i].r * (F1cxx . . $ `src/types.h:31:9`! - blackness)); |
| 294 | shownPalette[i].gcxx . . $ SDL_Color#g. = FTOIcxx . . $ `src/types.h:52:9`!(shownPalette[i].g * (F1cxx . . $ `src/types.h:31:9`! - blackness)); |
| 295 | shownPalette[i].bcxx . . $ SDL_Color#b. = FTOIcxx . . $ `src/types.h:52:9`!(shownPalette[i].b * (F1cxx . . $ `src/types.h:31:9`! - blackness)); |
| 296 | |
| 297 | } |
| 298 | |
| 299 | } |
| 300 | |
| 301 | if (!isStatic) blacknesscxx . . $ FadeOutPaletteEffect#blackness. += ITOFcxx . . $ `src/types.h:53:9`!(mspf) / durationcxx . . $ FadeOutPaletteEffect#duration.; |
| 302 | |
| 303 | } |
| 304 | |
| 305 | if (direct) videocxx . . $ video..changePalettecxx . . $ Video#changePalette(dc6239902d762776).(shownPalette, 0, MAX_PALETTE_COLORScxx . . $ `src/OpenJazz.h:71:9`!); |
| 306 | |
| 307 | } |
| 308 | |
| 309 | |
| 310 | /** |
| 311 | * Create a new flash-to-colour palette effect. |
| 312 | * |
| 313 | * @param newRed The red component of the colour |
| 314 | * @param newGreen The green component of the colour |
| 315 | * @param newBlue The blue component of the colour |
| 316 | * @param newDuration The length of time the effect will last |
| 317 | * @param nextPE The next palette effect |
| 318 | */ |
| 319 | FlashPaletteEffectcxx . . $ FlashPaletteEffect#::FlashPaletteEffectcxx . . $ FlashPaletteEffect#FlashPaletteEffect(3a3316a3107c43ea). |
| 320 | (unsigned char newRed, unsigned char newGreen, unsigned char newBlue, |
| 321 | int newDuration, PaletteEffectcxx . . $ PaletteEffect#* nextPE) : |
| 322 | PaletteEffectcxx . . $ PaletteEffect# (nextPE) { |
| 323 | |
| 324 | durationcxx . . $ FlashPaletteEffect#duration. = newDuration; |
| 325 | progresscxx . . $ FlashPaletteEffect#progress. = -F1cxx . . $ `src/types.h:31:9`!; |
| 326 | redcxx . . $ FlashPaletteEffect#red. = newRed; |
| 327 | greencxx . . $ FlashPaletteEffect#green. = newGreen; |
| 328 | bluecxx . . $ FlashPaletteEffect#blue. = newBlue; |
| 329 | |
| 330 | } |
| 331 | |
| 332 | |
| 333 | /** |
| 334 | * Apply the palette effect. |
| 335 | * |
| 336 | * @param shownPalette The palette the effect will be applied to |
| 337 | * @param direct Whether or not to apply the effect directly |
| 338 | * @param mspf Ticks per frame |
| 339 | * @param isStatic Whether the effect should advance after applying |
| 340 | */ |
| 341 | void FlashPaletteEffectcxx . . $ FlashPaletteEffect#::applycxx . . $ FlashPaletteEffect#apply(a0d1f6d228fe1f03). (SDL_Color* shownPalette, bool direct, int mspf, bool isStatic) { |
| 342 | |
| 343 | int count; |
| 344 | |
| 345 | // Apply the next palette effect |
| 346 | if (nextcxx . . $ PaletteEffect#next.) nextcxx . . $ PaletteEffect#next.->applycxx . . $ PaletteEffect#apply(a0d1f6d228fe1f03).(shownPalette, direct, mspf, isStatic); |
| 347 | |
| 348 | if (progresscxx . . $ FlashPaletteEffect#progress. < 0) { |
| 349 | |
| 350 | for (count = 0; count < MAX_PALETTE_COLORScxx . . $ `src/OpenJazz.h:71:9`!; count++) { |
| 351 | |
| 352 | shownPalette[count].rcxx . . $ SDL_Color#r. = FTOIcxx . . $ `src/types.h:52:9`!((shownPalette[count].r * -progress) + |
| 353 | (red * (progress + F1cxx . . $ `src/types.h:31:9`!))); |
| 354 | shownPalette[count].gcxx . . $ SDL_Color#g. = FTOIcxx . . $ `src/types.h:52:9`!((shownPalette[count].g * -progress) + |
| 355 | (green * (progress + F1cxx . . $ `src/types.h:31:9`!))); |
| 356 | shownPalette[count].bcxx . . $ SDL_Color#b. = FTOIcxx . . $ `src/types.h:52:9`!((shownPalette[count].b * -progress) + |
| 357 | (blue * (progress + F1cxx . . $ `src/types.h:31:9`!))); |
| 358 | |
| 359 | } |
| 360 | |
| 361 | if (!isStatic) progresscxx . . $ FlashPaletteEffect#progress. += ITOFcxx . . $ `src/types.h:53:9`!(mspf) / durationcxx . . $ FlashPaletteEffect#duration.; |
| 362 | |
| 363 | } else if (progresscxx . . $ FlashPaletteEffect#progress. < F1cxx . . $ `src/types.h:31:9`!) { |
| 364 | |
| 365 | for (count = 0; count < MAX_PALETTE_COLORScxx . . $ `src/OpenJazz.h:71:9`!; count++) { |
| 366 | |
| 367 | shownPalette[count].rcxx . . $ SDL_Color#r. = FTOIcxx . . $ `src/types.h:52:9`!((shownPalette[count].r * progress) + |
| 368 | (red * (F1cxx . . $ `src/types.h:31:9`! - progress))); |
| 369 | shownPalette[count].gcxx . . $ SDL_Color#g. = FTOIcxx . . $ `src/types.h:52:9`!((shownPalette[count].g * progress) + |
| 370 | (green * (F1cxx . . $ `src/types.h:31:9`! - progress))); |
| 371 | shownPalette[count].bcxx . . $ SDL_Color#b. = FTOIcxx . . $ `src/types.h:52:9`!((shownPalette[count].b * progress) + |
| 372 | (blue * (F1cxx . . $ `src/types.h:31:9`! - progress))); |
| 373 | |
| 374 | } |
| 375 | |
| 376 | if (!isStatic) progresscxx . . $ FlashPaletteEffect#progress. += ITOFcxx . . $ `src/types.h:53:9`!(mspf) / durationcxx . . $ FlashPaletteEffect#duration.; |
| 377 | |
| 378 | } |
| 379 | |
| 380 | if (direct) videocxx . . $ video..changePalettecxx . . $ Video#changePalette(dc6239902d762776).(shownPalette, 0, MAX_PALETTE_COLORScxx . . $ `src/OpenJazz.h:71:9`!); |
| 381 | |
| 382 | } |
| 383 | |
| 384 | |
| 385 | /** |
| 386 | * Create a new colour rotation palette effect. |
| 387 | * |
| 388 | * @param newFirst The first palette index to be affected |
| 389 | * @param newAmount The number of palette indices to be affected |
| 390 | * @param newSpeed The speed of he rotation |
| 391 | * @param nextPE The next palette effect |
| 392 | */ |
| 393 | RotatePaletteEffectcxx . . $ RotatePaletteEffect#::RotatePaletteEffectcxx . . $ RotatePaletteEffect#RotatePaletteEffect(d314fbf4fa48014d). |
| 394 | (unsigned char newFirst, int newAmount, fixedcxx . . $ fixed# newSpeed, PaletteEffectcxx . . $ PaletteEffect# * nextPE) : |
| 395 | PaletteEffectcxx . . $ PaletteEffect# (nextPE) { |
| 396 | |
| 397 | firstcxx . . $ RotatePaletteEffect#first. = newFirst; |
| 398 | amountcxx . . $ RotatePaletteEffect#amount. = newAmount; |
| 399 | speedcxx . . $ RotatePaletteEffect#speed. = newSpeed; |
| 400 | positioncxx . . $ RotatePaletteEffect#position. = 0; |
| 401 | |
| 402 | } |
| 403 | |
| 404 | |
| 405 | /** |
| 406 | * Apply the palette effect. |
| 407 | * |
| 408 | * @param shownPalette The palette the effect will be applied to |
| 409 | * @param direct Whether or not to apply the effect directly |
| 410 | * @param mspf Ticks per frame |
| 411 | * @param isStatic Whether the effect should advance after applying |
| 412 | */ |
| 413 | void RotatePaletteEffectcxx . . $ RotatePaletteEffect#::applycxx . . $ RotatePaletteEffect#apply(a0d1f6d228fe1f03). (SDL_Color* shownPalette, bool direct, int mspf, bool isStatic) { |
| 414 | |
| 415 | SDL_Color* currentPalette; |
| 416 | int count; |
| 417 | |
| 418 | // Apply the next palette effect |
| 419 | if (nextcxx . . $ PaletteEffect#next.) nextcxx . . $ PaletteEffect#next.->applycxx . . $ PaletteEffect#apply(a0d1f6d228fe1f03).(shownPalette, direct, mspf, isStatic); |
| 420 | |
| 421 | currentPalette = videocxx . . $ video..getPalettecxx . . $ Video#getPalette(a696971525c6d1f6).(); |
| 422 | |
| 423 | for (count = 0; count < amountcxx . . $ RotatePaletteEffect#amount.; count++) { |
| 424 | |
| 425 | memcpy(shownPalette + firstcxx . . $ RotatePaletteEffect#first. + count, |
| 426 | currentPalette + firstcxx . . $ RotatePaletteEffect#first. + |
| 427 | ((count + FTOIcxx . . $ `src/types.h:52:9`!(position)) % amountcxx . . $ RotatePaletteEffect#amount.), sizeof(SDL_Color)); |
| 428 | |
| 429 | } |
| 430 | |
| 431 | if (!isStatic) { |
| 432 | |
| 433 | positioncxx . . $ RotatePaletteEffect#position. -= (mspf * speedcxx . . $ RotatePaletteEffect#speed.) >> 10; |
| 434 | while (positioncxx . . $ RotatePaletteEffect#position. < 0) positioncxx . . $ RotatePaletteEffect#position. += ITOFcxx . . $ `src/types.h:53:9`!(amount); |
| 435 | |
| 436 | } |
| 437 | |
| 438 | if (direct) videocxx . . $ video..changePalettecxx . . $ Video#changePalette(dc6239902d762776).(shownPalette + firstcxx . . $ RotatePaletteEffect#first., firstcxx . . $ RotatePaletteEffect#first., amountcxx . . $ RotatePaletteEffect#amount.); |
| 439 | |
| 440 | } |
| 441 | |
| 442 | |
| 443 | /** |
| 444 | * Create a new parallaxing sky background palette effect. |
| 445 | * |
| 446 | * @param newFirst The first palette index to be affected |
| 447 | * @param newAmount The number of palette indices to be affected |
| 448 | * @param newSpeed The relative speed of the background |
| 449 | * @param newSkyPalette Palette containing the sky's colours |
| 450 | * @param nextPE The next palette effect |
| 451 | */ |
| 452 | SkyPaletteEffectcxx . . $ SkyPaletteEffect#::SkyPaletteEffectcxx . . $ SkyPaletteEffect#SkyPaletteEffect(aa213b894402e617). |
| 453 | (unsigned char newFirst, int newAmount, fixedcxx . . $ fixed# newSpeed, |
| 454 | SDL_Color* newSkyPalette, PaletteEffectcxx . . $ PaletteEffect#* nextPE) : |
| 455 | PaletteEffectcxx . . $ PaletteEffect# (nextPE) { |
| 456 | |
| 457 | skyPalettecxx . . $ SkyPaletteEffect#skyPalette. = newSkyPalette; |
| 458 | firstcxx . . $ SkyPaletteEffect#first. = newFirst; |
| 459 | amountcxx . . $ SkyPaletteEffect#amount. = newAmount; |
| 460 | speedcxx . . $ SkyPaletteEffect#speed. = newSpeed; |
| 461 | |
| 462 | } |
| 463 | |
| 464 | |
| 465 | /** |
| 466 | * Apply the palette effect. |
| 467 | * |
| 468 | * @param shownPalette The palette the effect will be applied to |
| 469 | * @param direct Whether or not to apply the effect directly |
| 470 | * @param mspf Ticks per frame |
| 471 | * @param isStatic Whether the effect should advance after applying |
| 472 | */ |
| 473 | void SkyPaletteEffectcxx . . $ SkyPaletteEffect#::applycxx . . $ SkyPaletteEffect#apply(a0d1f6d228fe1f03). (SDL_Color* shownPalette, bool direct, int mspf, bool isStatic) { |
| 474 | |
| 475 | int position, count, y; |
| 476 | |
| 477 | // Apply the next palette effect |
| 478 | if (nextcxx . . $ PaletteEffect#next.) nextcxx . . $ PaletteEffect#next.->applycxx . . $ PaletteEffect#apply(a0d1f6d228fe1f03).(shownPalette, direct, mspf, isStatic); |
| 479 | |
| 480 | position = viewYcxx . . $ viewY. + ((canvasHcxx . . $ canvasH. - 33) << 9) - F4cxx . . $ `src/types.h:33:9`!; |
| 481 | y = ((canvasHcxx . . $ canvasH. - 34) / 100) + 1; |
| 482 | count = (((position * speedcxx . . $ SkyPaletteEffect#speed.) / y) >> 20) % 255; |
| 483 | |
| 484 | if (direct) { |
| 485 | |
| 486 | if (count > 255 - amountcxx . . $ SkyPaletteEffect#amount.) { |
| 487 | |
| 488 | videocxx . . $ video..changePalettecxx . . $ Video#changePalette(dc6239902d762776).(skyPalettecxx . . $ SkyPaletteEffect#skyPalette. + count, firstcxx . . $ SkyPaletteEffect#first., 255 - count); |
| 489 | videocxx . . $ video..changePalettecxx . . $ Video#changePalette(dc6239902d762776).(skyPalettecxx . . $ SkyPaletteEffect#skyPalette., firstcxx . . $ SkyPaletteEffect#first. + (255 - count), count + amountcxx . . $ SkyPaletteEffect#amount. - 255); |
| 490 | |
| 491 | } else { |
| 492 | |
| 493 | videocxx . . $ video..changePalettecxx . . $ Video#changePalette(dc6239902d762776).(skyPalettecxx . . $ SkyPaletteEffect#skyPalette. + count, firstcxx . . $ SkyPaletteEffect#first., amountcxx . . $ SkyPaletteEffect#amount.); |
| 494 | |
| 495 | } |
| 496 | |
| 497 | } else { |
| 498 | |
| 499 | if (count > 255 - amountcxx . . $ SkyPaletteEffect#amount.) { |
| 500 | |
| 501 | memcpy(shownPalette + firstcxx . . $ SkyPaletteEffect#first., skyPalettecxx . . $ SkyPaletteEffect#skyPalette. + count, |
| 502 | sizeof(SDL_Color) * (255 - count)); |
| 503 | memcpy(shownPalette + firstcxx . . $ SkyPaletteEffect#first. + (255 - count), skyPalettecxx . . $ SkyPaletteEffect#skyPalette., |
| 504 | sizeof(SDL_Color) * (count + amountcxx . . $ SkyPaletteEffect#amount. - 255)); |
| 505 | |
| 506 | } else { |
| 507 | |
| 508 | memcpy(shownPalette + firstcxx . . $ SkyPaletteEffect#first., skyPalettecxx . . $ SkyPaletteEffect#skyPalette. + count, |
| 509 | sizeof(SDL_Color) * amountcxx . . $ SkyPaletteEffect#amount.); |
| 510 | |
| 511 | } |
| 512 | |
| 513 | } |
| 514 | |
| 515 | } |
| 516 | |
| 517 | |
| 518 | /** |
| 519 | * Create a new 2D parallaxing background palette effect. |
| 520 | * |
| 521 | * @param newFirst The first palette index to be affected |
| 522 | * @param newAmount The number of palette indices to be affected |
| 523 | * @param newSpeed The relative speed of the background |
| 524 | * @param nextPE The next palette effect |
| 525 | */ |
| 526 | P2DPaletteEffectcxx . . $ P2DPaletteEffect#::P2DPaletteEffectcxx . . $ P2DPaletteEffect#P2DPaletteEffect(d314fbf4fa48014d). |
| 527 | (unsigned char newFirst, int newAmount, fixedcxx . . $ fixed# newSpeed, PaletteEffectcxx . . $ PaletteEffect#* nextPE) : |
| 528 | PaletteEffectcxx . . $ PaletteEffect# (nextPE) { |
| 529 | |
| 530 | firstcxx . . $ P2DPaletteEffect#first. = newFirst; |
| 531 | amountcxx . . $ P2DPaletteEffect#amount. = newAmount; |
| 532 | speedcxx . . $ P2DPaletteEffect#speed. = newSpeed; |
| 533 | |
| 534 | } |
| 535 | |
| 536 | |
| 537 | /** |
| 538 | * Apply the palette effect. |
| 539 | * |
| 540 | * @param shownPalette The palette the effect will be applied to |
| 541 | * @param direct Whether or not to apply the effect directly |
| 542 | * @param mspf Ticks per frame |
| 543 | * @param isStatic Whether the effect should advance after applying |
| 544 | */ |
| 545 | void P2DPaletteEffectcxx . . $ P2DPaletteEffect#::applycxx . . $ P2DPaletteEffect#apply(a0d1f6d228fe1f03). (SDL_Color* shownPalette, bool direct, int mspf, bool isStatic) { |
| 546 | |
| 547 | SDL_Color* currentPalette; |
| 548 | int count, x, y, j; |
| 549 | |
| 550 | // Apply the next palette effect |
| 551 | if (nextcxx . . $ PaletteEffect#next.) nextcxx . . $ PaletteEffect#next.->applycxx . . $ PaletteEffect#apply(a0d1f6d228fe1f03).(shownPalette, direct, mspf, isStatic); |
| 552 | |
| 553 | currentPalette = videocxx . . $ video..getPalettecxx . . $ Video#getPalette(a696971525c6d1f6).(); |
| 554 | x = FTOIcxx . . $ `src/types.h:52:9`!(((256 * 32) - FTOIcxx . . $ `src/types.h:52:9`!(viewX)) * speed); |
| 555 | y = FTOIcxx . . $ `src/types.h:52:9`!(((64 * 32) - FTOIcxx . . $ `src/types.h:52:9`!(viewY)) * speed); |
| 556 | |
| 557 | for (count = 0; count < amountcxx . . $ P2DPaletteEffect#amount. >> 3; count++) { |
| 558 | |
| 559 | for (j = 0; j < 8; j++) { |
| 560 | |
| 561 | memcpy(shownPalette + firstcxx . . $ P2DPaletteEffect#first. + (count << 3) + j, |
| 562 | currentPalette + firstcxx . . $ P2DPaletteEffect#first. + (((count + y) % 8) << 3) + |
| 563 | ((j + x) % 8), sizeof(SDL_Color)); |
| 564 | |
| 565 | } |
| 566 | |
| 567 | } |
| 568 | |
| 569 | if (direct) videocxx . . $ video..changePalettecxx . . $ Video#changePalette(dc6239902d762776).(shownPalette + firstcxx . . $ P2DPaletteEffect#first., firstcxx . . $ P2DPaletteEffect#first., amountcxx . . $ P2DPaletteEffect#amount.); |
| 570 | |
| 571 | } |
| 572 | |
| 573 | |
| 574 | /** |
| 575 | * Create a new 1D parallaxing background palette effect. |
| 576 | * |
| 577 | * @param newFirst The first palette index to be affected |
| 578 | * @param newAmount The number of palette indices to be affected |
| 579 | * @param newSpeed The relative speed of the background |
| 580 | * @param nextPE The next palette effect |
| 581 | */ |
| 582 | P1DPaletteEffectcxx . . $ P1DPaletteEffect#::P1DPaletteEffectcxx . . $ P1DPaletteEffect#P1DPaletteEffect(d314fbf4fa48014d). |
| 583 | (unsigned char newFirst, int newAmount, fixedcxx . . $ fixed# newSpeed, PaletteEffectcxx . . $ PaletteEffect#* nextPE) : |
| 584 | PaletteEffectcxx . . $ PaletteEffect# (nextPE) { |
| 585 | |
| 586 | firstcxx . . $ P1DPaletteEffect#first. = newFirst; |
| 587 | amountcxx . . $ P1DPaletteEffect#amount. = newAmount; |
| 588 | speedcxx . . $ P1DPaletteEffect#speed. = newSpeed; |
| 589 | |
| 590 | } |
| 591 | |
| 592 | |
| 593 | /** |
| 594 | * Apply the palette effect. |
| 595 | * |
| 596 | * @param shownPalette The palette the effect will be applied to |
| 597 | * @param direct Whether or not to apply the effect directly |
| 598 | * @param mspf Ticks per frame |
| 599 | * @param isStatic Whether the effect should advance after applying |
| 600 | */ |
| 601 | void P1DPaletteEffectcxx . . $ P1DPaletteEffect#::applycxx . . $ P1DPaletteEffect#apply(a0d1f6d228fe1f03). (SDL_Color* shownPalette, bool direct, int mspf, bool isStatic) { |
| 602 | |
| 603 | SDL_Color* currentPalette; |
| 604 | fixedcxx . . $ fixed# position; |
| 605 | |
| 606 | // Apply the next palette effect |
| 607 | if (nextcxx . . $ PaletteEffect#next.) nextcxx . . $ PaletteEffect#next.->applycxx . . $ PaletteEffect#apply(a0d1f6d228fe1f03).(shownPalette, direct, mspf, isStatic); |
| 608 | |
| 609 | currentPalette = videocxx . . $ video..getPalettecxx . . $ Video#getPalette(a696971525c6d1f6).(); |
| 610 | position = viewXcxx . . $ viewX. + viewYcxx . . $ viewY.; |
| 611 | |
| 612 | for (int i = 0; i < amountcxx . . $ P1DPaletteEffect#amount.; i++) { |
| 613 | |
| 614 | memcpy(shownPalette + firstcxx . . $ P1DPaletteEffect#first. + i, |
| 615 | currentPalette + firstcxx . . $ P1DPaletteEffect#first. + ((i + |
| 616 | (amountcxx . . $ P1DPaletteEffect#amount. - 1 - (FTOIcxx . . $ `src/types.h:52:9`!(MULcxx . . $ `src/types.h:54:9`!(position, speed)) % amountcxx . . $ P1DPaletteEffect#amount.))) % amountcxx . . $ P1DPaletteEffect#amount.), |
| 617 | sizeof(SDL_Color)); |
| 618 | |
| 619 | } |
| 620 | |
| 621 | if (direct) videocxx . . $ video..changePalettecxx . . $ Video#changePalette(dc6239902d762776).(shownPalette + firstcxx . . $ P1DPaletteEffect#first., firstcxx . . $ P1DPaletteEffect#first., amountcxx . . $ P1DPaletteEffect#amount.); |
| 622 | |
| 623 | } |
| 624 | |
| 625 | |
| 626 | /** |
| 627 | * Create a new water palette effect. |
| 628 | * |
| 629 | * @param newDepth Water depth |
| 630 | * @param nextPE The next palette effect |
| 631 | */ |
| 632 | WaterPaletteEffectcxx . . $ WaterPaletteEffect#::WaterPaletteEffectcxx . . $ WaterPaletteEffect#WaterPaletteEffect(d7b903d8eaeca941). (fixedcxx . . $ fixed# newDepth, PaletteEffectcxx . . $ PaletteEffect#* nextPE) |
| 633 | : PaletteEffectcxx . . $ PaletteEffect# (nextPE) { |
| 634 | |
| 635 | depthcxx . . $ WaterPaletteEffect#depth. = newDepth; |
| 636 | |
| 637 | } |
| 638 | |
| 639 | |
| 640 | /** |
| 641 | * Apply the palette effect. |
| 642 | * |
| 643 | * @param shownPalette The palette the effect will be applied to |
| 644 | * @param direct Whether or not to apply the effect directly |
| 645 | * @param mspf Ticks per frame |
| 646 | * @param isStatic Whether the effect should advance after applying |
| 647 | */ |
| 648 | void WaterPaletteEffectcxx . . $ WaterPaletteEffect#::applycxx . . $ WaterPaletteEffect#apply(a0d1f6d228fe1f03). (SDL_Color* shownPalette, bool direct, int mspf, bool isStatic) { |
| 649 | |
| 650 | SDL_Color* currentPalette; |
| 651 | int position; |
| 652 | |
| 653 | // Apply the next palette effect |
| 654 | if (nextcxx . . $ PaletteEffect#next.) nextcxx . . $ PaletteEffect#next.->applycxx . . $ PaletteEffect#apply(a0d1f6d228fe1f03).(shownPalette, direct, mspf, isStatic); |
| 655 | |
| 656 | currentPalette = videocxx . . $ video..getPalettecxx . . $ Video#getPalette(a696971525c6d1f6).(); |
| 657 | |
| 658 | if (levelcxx . . $ level.) position = localPlayercxx . . $ localPlayer.->getLevelPlayercxx . . $ Player#getLevelPlayer(e55247ee3168a607).()->getYcxx . . $ Movable#getY(b126dc7c1de90089).() - levelcxx . . $ level.->getWaterLevelcxx . . $ JJ1Level#getWaterLevel(b126dc7c1de90089).(); |
| 659 | #ifdef ENABLE_JJ2 |
| 660 | else if (jj2Level) position = localPlayer->getLevelPlayer()->getY() - jj2Level->getWaterLevel(); |
| 661 | #endif |
| 662 | else return; |
| 663 | |
| 664 | if (position <= 0) return; |
| 665 | |
| 666 | if (position < depthcxx . . $ WaterPaletteEffect#depth.) { |
| 667 | |
| 668 | for (int i = 0; i < MAX_PALETTE_COLORScxx . . $ `src/OpenJazz.h:71:9`!; i++) { |
| 669 | |
| 670 | shownPalette[i].rcxx . . $ SDL_Color#r. = FTOIcxx . . $ `src/types.h:52:9`!(currentPalette[i].r * (1023 - DIVcxx . . $ `src/types.h:55:9`!(position, depth))); |
| 671 | shownPalette[i].gcxx . . $ SDL_Color#g. = FTOIcxx . . $ `src/types.h:52:9`!(currentPalette[i].g * (1023 - DIVcxx . . $ `src/types.h:55:9`!(position, depth))); |
| 672 | shownPalette[i].bcxx . . $ SDL_Color#b. = FTOIcxx . . $ `src/types.h:52:9`!(currentPalette[i].b * (1023 - DIVcxx . . $ `src/types.h:55:9`!(position, depth))); |
| 673 | |
| 674 | } |
| 675 | |
| 676 | } else memset(shownPalette, 0, sizeof(SDL_Color) * MAX_PALETTE_COLORScxx . . $ `src/OpenJazz.h:71:9`!); |
| 677 | |
| 678 | if (direct) videocxx . . $ video..changePalettecxx . . $ Video#changePalette(dc6239902d762776).(shownPalette, 0, MAX_PALETTE_COLORScxx . . $ `src/OpenJazz.h:71:9`!); |
| 679 | |
| 680 | } |