| 1 | |
| 2 | /** |
| 3 | * |
| 4 | * @file jj1bonuslevel.cpp |
| 5 | * |
| 6 | * Part of the OpenJazz project |
| 7 | * |
| 8 | * @par History: |
| 9 | * - 23rd August 2005: Created bonus.c |
| 10 | * - 3rd February 2009: Renamed bonus.c to bonus.cpp |
| 11 | * - 1st August 2012: Renamed bonus.cpp to jj1bonuslevel.cpp |
| 12 | * |
| 13 | * @par Licence: |
| 14 | * Copyright (c) 2005-2017 AJ Thomson |
| 15 | * |
| 16 | * OpenJazz is distributed under the terms of |
| 17 | * the GNU General Public License, version 2.0 |
| 18 | * |
| 19 | * @par Description: |
| 20 | * Deals with the loading, running and freeing of bonus levels. |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | |
| 25 | #include "jj1bonuslevelplayer.h"cxx . . $ `<file>/src/jj1/bonuslevel/jj1bonuslevelplayer.h`/ |
| 26 | #include "jj1bonuslevel.h"cxx . . $ `<file>/src/jj1/bonuslevel/jj1bonuslevel.h`/ |
| 27 | |
| 28 | #include "game/game.h"cxx . . $ `<file>/src/game/game.h`/ |
| 29 | #include "game/gamemode.h"cxx . . $ `<file>/src/game/gamemode.h`/ |
| 30 | #include "io/controls.h"cxx . . $ `<file>/src/io/controls.h`/ |
| 31 | #include "io/file.h"cxx . . $ `<file>/src/io/file.h`/ |
| 32 | #include "io/gfx/font.h"cxx . . $ `<file>/src/io/gfx/font.h`/ |
| 33 | #include "io/gfx/paletteeffects.h"cxx . . $ `<file>/src/io/gfx/paletteeffects.h`/ |
| 34 | #include "io/gfx/sprite.h"cxx . . $ `<file>/src/io/gfx/sprite.h`/ |
| 35 | #include "io/gfx/video.h"cxx . . $ `<file>/src/io/gfx/video.h`/ |
| 36 | #include "io/sound.h"cxx . . $ `<file>/src/io/sound.h`/ |
| 37 | #include "io/log.h"cxx . . $ `<file>/src/io/log.h`/ |
| 38 | #include "util.h"cxx . . $ `<file>/src/util.h`/ |
| 39 | |
| 40 | #include <string.h> |
| 41 | |
| 42 | |
| 43 | /** |
| 44 | * Load sprites. |
| 45 | * |
| 46 | * @return Error code |
| 47 | */ |
| 48 | int JJ1BonusLevelcxx . . $ JJ1BonusLevel#::loadSpritescxx . . $ JJ1BonusLevel#loadSprites(b126dc7c1de90089). () { |
| 49 | |
| 50 | FilePtrcxx . . $ FilePtr# filecxx . . $ std/unique_ptr#unique_ptr(49f6e7a06ebc5aa8).; |
| 51 | unsigned char* pixels; |
| 52 | |
| 53 | try { |
| 54 | |
| 55 | file =cxx . . $ std/unique_ptr#`operator=`(1b63e42eaa758a73). stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<Filecxx . . $ File#>("BONUS.000", PATH_TYPE_GAMEcxx . . $ PATH_TYPE_GAME.); |
| 56 | |
| 57 | } catch (int e) { |
| 58 | |
| 59 | return e; |
| 60 | |
| 61 | } |
| 62 | |
| 63 | file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).seekcxx . . $ File#seek(918ebd27a9ddbad3).(2, true); |
| 64 | |
| 65 | spritescxx . . $ Level#sprites. = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadShortcxx . . $ File#loadShort(a18c05e4017afb3d).(256); |
| 66 | spriteSetcxx . . $ JJ1BonusLevel#spriteSet. = new Spritecxx . . $ Sprite#Sprite(49f6e7a06ebc5aa8).[spritescxx . . $ Level#sprites.]; |
| 67 | |
| 68 | for (int i = 0; i < spritescxx . . $ Level#sprites.; i++) { |
| 69 | |
| 70 | // Load dimensions |
| 71 | int width = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadShortcxx . . $ File#loadShort(a18c05e4017afb3d).(SWcxx . . $ `src/io/gfx/video.h:38:9`!); |
| 72 | int height = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadShortcxx . . $ File#loadShort(a18c05e4017afb3d).(SHcxx . . $ `src/io/gfx/video.h:39:9`!); |
| 73 | |
| 74 | int pixelsLength = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadShortcxx . . $ File#loadShort(32a7769d58713265).(); |
| 75 | int maskLength = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadShortcxx . . $ File#loadShort(32a7769d58713265).(); |
| 76 | |
| 77 | // Sprites can be either masked or not masked. |
| 78 | if (pixelsLength != 0xFFFF) { |
| 79 | |
| 80 | // Masked |
| 81 | width <<= 2; |
| 82 | |
| 83 | int pos = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).tellcxx . . $ File#tell(b126dc7c1de90089).() + (pixelsLength << 2) + maskLength; |
| 84 | |
| 85 | // Read scrambled, masked pixel data |
| 86 | pixels = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadPixelscxx . . $ File#loadPixels(1393c316e1be7356).(width * height, 0); |
| 87 | spriteSetcxx . . $ JJ1BonusLevel#spriteSet.[i].setPixelscxx . . $ Sprite#setPixels(3f9b724c895640a0).(pixels, width, height, 0); |
| 88 | |
| 89 | delete[] pixels; |
| 90 | |
| 91 | file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).seekcxx . . $ File#seek(918ebd27a9ddbad3).(pos, true); |
| 92 | |
| 93 | } else if (width) { |
| 94 | |
| 95 | // Not masked |
| 96 | |
| 97 | // Read pixel data |
| 98 | pixels = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadBlockcxx . . $ File#loadBlock(f18dc31a6ecbac56).(width * height); |
| 99 | spriteSetcxx . . $ JJ1BonusLevel#spriteSet.[i].setPixelscxx . . $ Sprite#setPixels(3f9b724c895640a0).(pixels, width, height, 0); |
| 100 | |
| 101 | delete[] pixels; |
| 102 | |
| 103 | } else { |
| 104 | |
| 105 | // Zero-length sprite |
| 106 | |
| 107 | // Create blank sprite |
| 108 | spriteSetcxx . . $ JJ1BonusLevel#spriteSet.[i].clearPixelscxx . . $ Sprite#clearPixels(49f6e7a06ebc5aa8).(); |
| 109 | |
| 110 | } |
| 111 | |
| 112 | } |
| 113 | |
| 114 | return E_NONEcxx . . $ `src/OpenJazz.h:69:9`!; |
| 115 | |
| 116 | } |
| 117 | |
| 118 | |
| 119 | /** |
| 120 | * Load the tileset. |
| 121 | * |
| 122 | * @param fileName Name of the file containing the tileset |
| 123 | * |
| 124 | * @return Error code |
| 125 | */ |
| 126 | int JJ1BonusLevelcxx . . $ JJ1BonusLevel#::loadTilescxx . . $ JJ1BonusLevel#loadTiles(1ef8e6ec083aabb9). (char *fileName) { |
| 127 | |
| 128 | FilePtrcxx . . $ FilePtr# filecxx . . $ std/unique_ptr#unique_ptr(49f6e7a06ebc5aa8).; |
| 129 | unsigned char *pixels; |
| 130 | unsigned char *sorted; |
| 131 | int count, x, y; |
| 132 | |
| 133 | directioncxx . . $ JJ1BonusLevel#direction. = 0; |
| 134 | |
| 135 | try { |
| 136 | |
| 137 | file =cxx . . $ std/unique_ptr#`operator=`(1b63e42eaa758a73). stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<Filecxx . . $ File#>(fileName, PATH_TYPE_GAMEcxx . . $ PATH_TYPE_GAME.); |
| 138 | |
| 139 | } catch (int e) { |
| 140 | |
| 141 | return e; |
| 142 | |
| 143 | } |
| 144 | |
| 145 | // Load background |
| 146 | pixels = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadRLEcxx . . $ File#loadRLE(bf8b529691269f26).(832 * 20); |
| 147 | sorted = new unsigned char[512 * 20]; |
| 148 | |
| 149 | for (count = 0; count < 20; count++) memcpy(sorted + (count * 512), pixels + (count * 832), 512); |
| 150 | |
| 151 | backgroundcxx . . $ JJ1BonusLevel#background. = videocxx . . $ video..createSurfacecxx . . $ Video#createSurface(5ec4649223a2dfef).(sorted, 512, 20); |
| 152 | |
| 153 | delete[] sorted; |
| 154 | delete[] pixels; |
| 155 | |
| 156 | // Load palette |
| 157 | file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadPalettecxx . . $ File#loadPalette(a8e7e0a5cf0a5bef).(palettecxx . . $ Level#palette.); |
| 158 | |
| 159 | // Load tile graphics |
| 160 | pixels = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadRLEcxx . . $ File#loadRLE(bf8b529691269f26).(1024 * 60); |
| 161 | tileSetcxx . . $ JJ1BonusLevel#tileSet. = videocxx . . $ video..createSurfacecxx . . $ Video#createSurface(5ec4649223a2dfef).(pixels, 32, 32 * 60); |
| 162 | |
| 163 | // Create mask |
| 164 | for (count = 0; count < 60; count++) { |
| 165 | |
| 166 | memset(maskcxx . . $ JJ1BonusLevel#mask.[count], 0, 64); |
| 167 | |
| 168 | for (y = 0; y < 32; y++) { |
| 169 | |
| 170 | for (x = 0; x < 32; x++) { |
| 171 | |
| 172 | if ((pixels[(count << 10) + (y << 5) + x] & 240) == 192) |
| 173 | maskcxx . . $ JJ1BonusLevel#mask.[count][((y << 1) & 56) + ((x >> 2) & 7)] = 1; |
| 174 | |
| 175 | } |
| 176 | |
| 177 | } |
| 178 | |
| 179 | } |
| 180 | |
| 181 | delete[] pixels; |
| 182 | |
| 183 | return E_NONEcxx . . $ `src/OpenJazz.h:69:9`!; |
| 184 | |
| 185 | } |
| 186 | |
| 187 | |
| 188 | /** |
| 189 | * Create a JJ1 bonus level. |
| 190 | * |
| 191 | * @param owner The current game |
| 192 | * @param fileName Name of the file containing the level data. |
| 193 | * @param multi Whether or not the level will be multi-player |
| 194 | */ |
| 195 | JJ1BonusLevelcxx . . $ JJ1BonusLevel#::JJ1BonusLevelcxx . . $ JJ1BonusLevel#JJ1BonusLevel(4b4d448ac49d7c5a). (Gamecxx . . $ Game#* owner, char * fileName, bool multi) : Levelcxx . . $ Level#(owner) { |
| 196 | |
| 197 | Animcxx . . $ Anim#* pAnims[BPANIMScxx . . $ `src/jj1/bonuslevel/jj1bonuslevelplayer.h:42:9`!]; |
| 198 | unsigned short int soundRates[BSOUNDScxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:35:9`!]; |
| 199 | FilePtrcxx . . $ FilePtr# filecxx . . $ std/unique_ptr#unique_ptr(49f6e7a06ebc5aa8).; |
| 200 | unsigned char *buffer; |
| 201 | char *string, *fileString; |
| 202 | int count, x, y; |
| 203 | |
| 204 | try { |
| 205 | |
| 206 | fontcxx . . $ JJ1BonusLevel#font. = new Fontcxx . . $ Font#Font(b45ddcbc8423892c).(true); |
| 207 | |
| 208 | } catch (int e) { |
| 209 | |
| 210 | throw; |
| 211 | |
| 212 | } |
| 213 | #if DEBUG_FONTS |
| 214 | font->saveAtlasAsBMP("bonusfont.bmp"); |
| 215 | #endif |
| 216 | |
| 217 | try { |
| 218 | |
| 219 | file =cxx . . $ std/unique_ptr#`operator=`(1b63e42eaa758a73). stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<Filecxx . . $ File#>(fileName, PATH_TYPE_GAMEcxx . . $ PATH_TYPE_GAME.); |
| 220 | |
| 221 | } catch (int e) { |
| 222 | |
| 223 | delete fontcxx . . $ JJ1BonusLevel#font.; |
| 224 | |
| 225 | throw; |
| 226 | |
| 227 | } |
| 228 | |
| 229 | // Load sprites |
| 230 | count = loadSpritescxx . . $ JJ1BonusLevel#loadSprites(b126dc7c1de90089).(); |
| 231 | |
| 232 | if (count < 0) { |
| 233 | |
| 234 | delete fontcxx . . $ JJ1BonusLevel#font.; |
| 235 | |
| 236 | throw count; |
| 237 | |
| 238 | } |
| 239 | |
| 240 | // Skip Editor data files |
| 241 | file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).seekcxx . . $ File#seek(918ebd27a9ddbad3).(10 * 9, true); |
| 242 | |
| 243 | // Load tileset |
| 244 | string = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadTerminatedStringcxx . . $ File#loadTerminatedString(ff224f080444ee45).(8); |
| 245 | fileString = createFileNamecxx . . $ createFileName(2050848944e00d54).(string, 0); |
| 246 | x = loadTilescxx . . $ JJ1BonusLevel#loadTiles(1ef8e6ec083aabb9).(fileString); |
| 247 | delete[] string; |
| 248 | delete[] fileString; |
| 249 | |
| 250 | if (x != E_NONEcxx . . $ `src/OpenJazz.h:69:9`!) throw x; |
| 251 | |
| 252 | // Skip Editor tileset files |
| 253 | file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).seekcxx . . $ File#seek(918ebd27a9ddbad3).(9 + 13); |
| 254 | |
| 255 | // Load music |
| 256 | fileString = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadTerminatedStringcxx . . $ File#loadTerminatedString(ff224f080444ee45).(12); |
| 257 | playMusiccxx . . $ playMusic(90ef5b561fbcb8de).(fileString); |
| 258 | delete[] fileString; |
| 259 | |
| 260 | |
| 261 | // Load animations |
| 262 | buffer = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadBlockcxx . . $ File#loadBlock(f18dc31a6ecbac56).(BANIMScxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:33:9`! << 6); |
| 263 | |
| 264 | // Create animation set based on that data |
| 265 | for (count = 0; count < BANIMScxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:33:9`!; count++) { |
| 266 | |
| 267 | animSetcxx . . $ JJ1BonusLevel#animSet.[count].setDatacxx . . $ Anim#setData(f6a7b8e80ccbdd28).(buffer[(count << 6) + 6], |
| 268 | buffer[count << 6], buffer[(count << 6) + 1], |
| 269 | buffer[(count << 6) + 3], buffer[(count << 6) + 4], |
| 270 | buffer[(count << 6) + 2], buffer[(count << 6) + 5]); |
| 271 | |
| 272 | for (y = 0; y < buffer[(count << 6) + 6]; y++) { |
| 273 | |
| 274 | // Get frame |
| 275 | x = buffer[(count << 6) + 7 + y]; |
| 276 | if (x > spritescxx . . $ Level#sprites.){ |
| 277 | LOG_DEBUGcxx . . $ `src/io/log.h:75:9`!("Clipping Sprite index %d > %d", x, sprites); |
| 278 | x = spritescxx . . $ Level#sprites.; |
| 279 | } |
| 280 | |
| 281 | // Assign sprite and vertical offset |
| 282 | animSetcxx . . $ JJ1BonusLevel#animSet.[count].setFramecxx . . $ Anim#setFrame(918ebd27a9ddbad3).(y, true); |
| 283 | animSetcxx . . $ JJ1BonusLevel#animSet.[count].setFrameDatacxx . . $ Anim#setFrameData(b004b9a6a91098d4).(spriteSetcxx . . $ JJ1BonusLevel#spriteSet. + x, |
| 284 | buffer[(count << 6) + 26 + y], buffer[(count << 6) + 45 + y]); |
| 285 | |
| 286 | } |
| 287 | |
| 288 | } |
| 289 | |
| 290 | delete[] buffer; |
| 291 | |
| 292 | |
| 293 | #if DEBUG_LOAD |
| 294 | // Show animation names |
| 295 | for (count = 0; count < BANIMS; count++) { |
| 296 | char *tmpName = file->loadTerminatedString(15); |
| 297 | if(strlen(tmpName)) { |
| 298 | LOG_MAX("Animation id %d is named \"%s\"", count, tmpName); |
| 299 | } |
| 300 | delete[] tmpName; |
| 301 | } |
| 302 | #else |
| 303 | // Skip animation names |
| 304 | file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).seekcxx . . $ File#seek(918ebd27a9ddbad3).(BANIMScxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:33:9`! * 16); |
| 305 | #endif |
| 306 | |
| 307 | |
| 308 | // Load tiles |
| 309 | buffer = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadRLEcxx . . $ File#loadRLE(bf8b529691269f26).(BLWcxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:31:9`! * BLHcxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:32:9`!); |
| 310 | |
| 311 | for (y = 0; y < BLHcxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:32:9`!; y++) { |
| 312 | for (x = 0; x < BLWcxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:31:9`!; x++) { |
| 313 | |
| 314 | gridcxx . . $ JJ1BonusLevel#grid.[y][x].tilecxx . . $ $anonymous_type_1155ca566b20eb7d_0#tile. = buffer[x + (y * BLWcxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:31:9`!)]; |
| 315 | if (gridcxx . . $ JJ1BonusLevel#grid.[y][x].tilecxx . . $ $anonymous_type_1155ca566b20eb7d_0#tile. > 59) { |
| 316 | LOG_DEBUGcxx . . $ `src/io/log.h:75:9`!("Clipping Tile index %d > %d", grid[y][x].tile, 59); |
| 317 | gridcxx . . $ JJ1BonusLevel#grid.[y][x].tilecxx . . $ $anonymous_type_1155ca566b20eb7d_0#tile. = 59; |
| 318 | } |
| 319 | |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | delete[] buffer; |
| 324 | |
| 325 | |
| 326 | // Load event properties |
| 327 | buffer = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadRLEcxx . . $ File#loadRLE(bf8b529691269f26).(BEVENTScxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:34:9`! * 16); |
| 328 | for (count = 0; count < BEVENTScxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:34:9`!; count++) { |
| 329 | eventSetcxx . . $ JJ1BonusLevel#eventSet.[count].animcxx . . $ $anonymous_type_1155ca566b20eb7d_1#anim. = buffer[(count * BEVENTScxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:34:9`!) + 5]; |
| 330 | eventSetcxx . . $ JJ1BonusLevel#eventSet.[count].typecxx . . $ $anonymous_type_1155ca566b20eb7d_1#type. = buffer[(count * BEVENTScxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:34:9`!) + 7]; |
| 331 | eventSetcxx . . $ JJ1BonusLevel#eventSet.[count].passablecxx . . $ $anonymous_type_1155ca566b20eb7d_1#passable. = buffer[(count * BEVENTScxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:34:9`!) + 8]; |
| 332 | eventSetcxx . . $ JJ1BonusLevel#eventSet.[count].usedcxx . . $ $anonymous_type_1155ca566b20eb7d_1#used. = buffer[(count * BEVENTScxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:34:9`!) + 9]; |
| 333 | |
| 334 | auto se = static_cast<SEcxx . . $ SE/::Typecxx . . $ SE/Type#>(buffer[(count * BEVENTScxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:34:9`!) + 13]); |
| 335 | if (!isValidSoundIndexcxx . . $ isValidSoundIndex(856ce1a3dc69003b).(se)) { |
| 336 | eventSetcxx . . $ JJ1BonusLevel#eventSet.[count].soundcxx . . $ $anonymous_type_1155ca566b20eb7d_1#sound. = SEcxx . . $ SE/::NONEcxx . . $ SE/NONE.; |
| 337 | LOG_WARNcxx . . $ `src/io/log.h:77:9`!("Event %d has invalid sound effect %d.", count, se); |
| 338 | } else { |
| 339 | eventSetcxx . . $ JJ1BonusLevel#eventSet.[count].soundcxx . . $ $anonymous_type_1155ca566b20eb7d_1#sound. = se; |
| 340 | } |
| 341 | |
| 342 | // This is a hack to make "exit signs" work in OJ |
| 343 | if(eventSetcxx . . $ JJ1BonusLevel#eventSet.[count].typecxx . . $ $anonymous_type_1155ca566b20eb7d_1#type. == 7) |
| 344 | eventSetcxx . . $ JJ1BonusLevel#eventSet.[count].passablecxx . . $ $anonymous_type_1155ca566b20eb7d_1#passable. = 1; |
| 345 | |
| 346 | #if DEBUG_LOAD |
| 347 | //hexDump(nullptr, buffer + count * BEVENTS, 16); |
| 348 | LOG_MAX("Event %d: anim=%d, type=%d, passable=%d, sound=%d", |
| 349 | count, eventSet[count].anim, eventSet[count].type, |
| 350 | eventSet[count].passable, eventSet[count].sound); |
| 351 | #endif |
| 352 | } |
| 353 | delete[] buffer; |
| 354 | |
| 355 | |
| 356 | // Load event mapping |
| 357 | buffer = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadRLEcxx . . $ File#loadRLE(bf8b529691269f26).(BLWcxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:31:9`! * BLHcxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:32:9`!); |
| 358 | |
| 359 | for (y = 0; y < BLWcxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:31:9`!; y++) { |
| 360 | for (x = 0; x < BLHcxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:32:9`!; x++) { |
| 361 | |
| 362 | gridcxx . . $ JJ1BonusLevel#grid.[y][x].eventcxx . . $ $anonymous_type_1155ca566b20eb7d_0#event. = buffer[x + (y * BLWcxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:31:9`!)]; |
| 363 | |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | delete[] buffer; |
| 368 | |
| 369 | |
| 370 | // Load sound map |
| 371 | for (count = 0; count < BSOUNDScxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:35:9`!; count++) { |
| 372 | soundRates[count] = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadShortcxx . . $ File#loadShort(32a7769d58713265).(); |
| 373 | } |
| 374 | for (count = 0; count < BSOUNDScxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:35:9`!; count++) { |
| 375 | char *tmpName = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadTerminatedStringcxx . . $ File#loadTerminatedString(ff224f080444ee45).(8); |
| 376 | resampleSoundcxx . . $ resampleSound(d77166e5f335409f).(count, tmpName, soundRates[count]); |
| 377 | delete[] tmpName; |
| 378 | } |
| 379 | |
| 380 | // Unknown marker |
| 381 | if(file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadShortcxx . . $ File#loadShort(32a7769d58713265).() != 0xFFFF) { |
| 382 | LOG_WARNcxx . . $ `src/io/log.h:77:9`!("Invalid bonus level"); |
| 383 | throw E_FILEcxx . . $ `src/OpenJazz.h:60:9`!; |
| 384 | } |
| 385 | |
| 386 | // Set the tick at which the level will end |
| 387 | endTimecxx . . $ Level#endTime. = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadShortcxx . . $ File#loadShort(32a7769d58713265).() * 1000; |
| 388 | |
| 389 | |
| 390 | // Number of gems to collect |
| 391 | itemscxx . . $ Level#items. = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadShortcxx . . $ File#loadShort(32a7769d58713265).(); |
| 392 | |
| 393 | |
| 394 | // The players' coordinates |
| 395 | x = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadShortcxx . . $ File#loadShort(32a7769d58713265).(); |
| 396 | y = file->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).loadShortcxx . . $ File#loadShort(32a7769d58713265).(); |
| 397 | |
| 398 | |
| 399 | // Generate player's animation set references |
| 400 | for (count = 0; count < BPANIMScxx . . $ `src/jj1/bonuslevel/jj1bonuslevelplayer.h:42:9`!; count++) |
| 401 | pAnims[count] = animSetcxx . . $ JJ1BonusLevel#animSet. + count; |
| 402 | |
| 403 | |
| 404 | createLevelPlayerscxx . . $ Level#createLevelPlayers(63f12801702f9d1b).(LT_JJ1BONUScxx . . $ LT_JJ1BONUS., pAnims, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, false, x, y); |
| 405 | |
| 406 | |
| 407 | // Palette animations |
| 408 | |
| 409 | // Spinny whirly thing |
| 410 | paletteEffectscxx . . $ Level#paletteEffects. = new RotatePaletteEffectcxx . . $ RotatePaletteEffect#(112, 16, F32cxx . . $ `src/types.h:40:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 411 | |
| 412 | // Track sides |
| 413 | paletteEffectscxx . . $ Level#paletteEffects. = new RotatePaletteEffectcxx . . $ RotatePaletteEffect#(192, 16, F32cxx . . $ `src/types.h:40:9`!, paletteEffectscxx . . $ Level#paletteEffects.); |
| 414 | |
| 415 | // Bouncy things |
| 416 | paletteEffectscxx . . $ Level#paletteEffects. = new RotatePaletteEffectcxx . . $ RotatePaletteEffect#(240, 16, F32cxx . . $ `src/types.h:40:9`!, paletteEffectscxx . . $ Level#paletteEffects.); |
| 417 | |
| 418 | |
| 419 | // Adjust panelBigFont to use bonus level palette |
| 420 | panelBigFontcxx . . $ panelBigFont.->mapPalettecxx . . $ Font#mapPalette(748afa4755bc9595).(0, 32, 15, -16); |
| 421 | |
| 422 | |
| 423 | multiplayercxx . . $ Level#multiplayer. = multi; |
| 424 | |
| 425 | videocxx . . $ video..setTitlecxx . . $ Video#setTitle(85c52e162fed56f9).("Bonus Level"); |
| 426 | |
| 427 | } |
| 428 | |
| 429 | |
| 430 | /** |
| 431 | * Delete the JJ1 bonus level. |
| 432 | */ |
| 433 | JJ1BonusLevelcxx . . $ JJ1BonusLevel#::~cxx . . $ JJ1BonusLevel#`~JJ1BonusLevel`(49f6e7a06ebc5aa8).JJ1BonusLevelcxx . . $ JJ1BonusLevel# () { |
| 434 | |
| 435 | // Restore panelBigFont palette |
| 436 | panelBigFontcxx . . $ panelBigFont.->restorePalettecxx . . $ Font#restorePalette(49f6e7a06ebc5aa8).(); |
| 437 | |
| 438 | videocxx . . $ video..destroySurfacecxx . . $ Video#destroySurface(60a0b30a00b4fc6d).(tileSetcxx . . $ JJ1BonusLevel#tileSet.); |
| 439 | videocxx . . $ video..destroySurfacecxx . . $ Video#destroySurface(60a0b30a00b4fc6d).(backgroundcxx . . $ JJ1BonusLevel#background.); |
| 440 | |
| 441 | delete[] spriteSetcxx . . $ JJ1BonusLevel#spriteSet.; |
| 442 | |
| 443 | delete fontcxx . . $ JJ1BonusLevel#font.; |
| 444 | |
| 445 | resampleSoundscxx . . $ resampleSounds(49f6e7a06ebc5aa8).(); |
| 446 | |
| 447 | videocxx . . $ video..setTitlecxx . . $ Video#setTitle(85c52e162fed56f9).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 448 | |
| 449 | } |
| 450 | |
| 451 | |
| 452 | /** |
| 453 | * Determine whether or not the given point is in the event area of its tile. |
| 454 | * |
| 455 | * @param x X-coordinate |
| 456 | * @param y Y-coordinate |
| 457 | * |
| 458 | * @return True if in the event area |
| 459 | */ |
| 460 | bool JJ1BonusLevelcxx . . $ JJ1BonusLevel#::isEventcxx . . $ JJ1BonusLevel#isEvent(cf9ef193275fa6d8). (fixedcxx . . $ fixed# x, fixedcxx . . $ fixed# y) { |
| 461 | |
| 462 | return ((x & 32767) > F12cxx . . $ `src/types.h:36:9`!) && ((x & 32767) < F20cxx . . $ `src/types.h:38:9`!) && |
| 463 | ((y & 32767) > F12cxx . . $ `src/types.h:36:9`!) && ((y & 32767) < F20cxx . . $ `src/types.h:38:9`!); |
| 464 | |
| 465 | } |
| 466 | |
| 467 | |
| 468 | /** |
| 469 | * Determine whether or not the given point is solid. |
| 470 | * |
| 471 | * @param x X-coordinate |
| 472 | * @param y Y-coordinate |
| 473 | * |
| 474 | * @return Solidity |
| 475 | */ |
| 476 | bool JJ1BonusLevelcxx . . $ JJ1BonusLevel#::checkMaskcxx . . $ JJ1BonusLevel#checkMask(cf9ef193275fa6d8). (fixedcxx . . $ fixed# x, fixedcxx . . $ fixed# y) { |
| 477 | |
| 478 | JJ1BonusLevelGridElementcxx . . $ JJ1BonusLevelGridElement# *ge = gridcxx . . $ JJ1BonusLevel#grid.[FTOTcxx . . $ `src/level/level.h:37:9`!(y) & 255] + (FTOTcxx . . $ `src/level/level.h:37:9`!(x) & 255); |
| 479 | |
| 480 | // Bounce back |
| 481 | if ((eventSetcxx . . $ JJ1BonusLevel#eventSet.[ge->eventcxx . . $ $anonymous_type_1155ca566b20eb7d_0#event.].usedcxx . . $ $anonymous_type_1155ca566b20eb7d_1#used.) && !(eventSetcxx . . $ JJ1BonusLevel#eventSet.[ge->eventcxx . . $ $anonymous_type_1155ca566b20eb7d_0#event.].passablecxx . . $ $anonymous_type_1155ca566b20eb7d_1#passable.) && isEventcxx . . $ JJ1BonusLevel#isEvent(cf9ef193275fa6d8).(x, y)) |
| 482 | return true; |
| 483 | |
| 484 | // Check the mask in the tile in question |
| 485 | return maskcxx . . $ JJ1BonusLevel#mask.[ge->tilecxx . . $ $anonymous_type_1155ca566b20eb7d_0#tile.][((y >> 9) & 56) + ((x >> 12) & 7)]; |
| 486 | |
| 487 | } |
| 488 | |
| 489 | |
| 490 | /** |
| 491 | * Interpret data received from client/server |
| 492 | * |
| 493 | * @param buffer Received data |
| 494 | */ |
| 495 | void JJ1BonusLevelcxx . . $ JJ1BonusLevel#::receivecxx . . $ JJ1BonusLevel#receive(f25546b61a629de7). (unsigned char* buffer) { |
| 496 | |
| 497 | switch (buffer[1]) { |
| 498 | |
| 499 | case MT_L_PROPcxx . . $ `src/game/game.h:55:9`!: |
| 500 | |
| 501 | if (buffer[2] == 2) { |
| 502 | |
| 503 | if (stagecxx . . $ Level#stage. == LS_NORMALcxx . . $ LS_NORMAL.) |
| 504 | endTimecxx . . $ Level#endTime. += buffer[3] * 1000; |
| 505 | |
| 506 | } |
| 507 | |
| 508 | break; |
| 509 | |
| 510 | case MT_L_GRIDcxx . . $ `src/game/game.h:56:9`!: |
| 511 | |
| 512 | if (buffer[4] == 0) gridcxx . . $ JJ1BonusLevel#grid.[buffer[3]][buffer[2]].tilecxx . . $ $anonymous_type_1155ca566b20eb7d_0#tile. = buffer[5]; |
| 513 | else if (buffer[4] == 2) |
| 514 | gridcxx . . $ JJ1BonusLevel#grid.[buffer[3]][buffer[2]].eventcxx . . $ $anonymous_type_1155ca566b20eb7d_0#event. = buffer[5]; |
| 515 | |
| 516 | break; |
| 517 | |
| 518 | case MT_L_STAGEcxx . . $ `src/game/game.h:57:9`!: |
| 519 | |
| 520 | stagecxx . . $ Level#stage. = LevelStagecxx . . $ LevelStage#(buffer[2]); |
| 521 | |
| 522 | break; |
| 523 | |
| 524 | } |
| 525 | |
| 526 | } |
| 527 | |
| 528 | |
| 529 | /** |
| 530 | * Level iteration. |
| 531 | * |
| 532 | * @return Error code |
| 533 | */ |
| 534 | int JJ1BonusLevelcxx . . $ JJ1BonusLevel#::stepcxx . . $ JJ1BonusLevel#step(b126dc7c1de90089). () { |
| 535 | // Check if time has run out |
| 536 | if (tickscxx . . $ Level#ticks. > endTimecxx . . $ Level#endTime.) { |
| 537 | playSoundcxx . . $ playSound(80b838f98135e5b).(SEcxx . . $ SE/::OWcxx . . $ SE/OW.); |
| 538 | |
| 539 | return LOSTcxx . . $ `src/level/level.h:47:9`!; |
| 540 | } |
| 541 | |
| 542 | // Apply controls to local player |
| 543 | for (int i = 0; i < PCONTROLScxx . . $ `src/player/player.h:45:9`!; i++) |
| 544 | localPlayercxx . . $ localPlayer.->setControlcxx . . $ Player#setControl(918ebd27a9ddbad3).(i, controlscxx . . $ controls..getStatecxx . . $ Controls#getState(83c267b20bac841a).(i)); |
| 545 | |
| 546 | // Process players |
| 547 | for (int i = 0; i < nPlayerscxx . . $ nPlayers.; i++) { |
| 548 | |
| 549 | JJ1BonusLevelPlayercxx . . $ JJ1BonusLevelPlayer#* bonusPlayer = playerscxx . . $ players.[i].getJJ1BonusLevelPlayercxx . . $ Player#getJJ1BonusLevelPlayer(5b714c54c39cd209).(); |
| 550 | |
| 551 | fixedcxx . . $ fixed# playerX = bonusPlayer->getXcxx . . $ Movable#getX(b126dc7c1de90089).(); |
| 552 | fixedcxx . . $ fixed# playerY = bonusPlayer->getYcxx . . $ Movable#getY(b126dc7c1de90089).(); |
| 553 | |
| 554 | bonusPlayer->stepcxx . . $ JJ1BonusLevelPlayer#step(140727f6331ac93d).(tickscxx . . $ Level#ticks., 16, this); |
| 555 | |
| 556 | if ((bonusPlayer->getZcxx . . $ JJ1BonusLevelPlayer#getZ(b126dc7c1de90089).() < FHcxx . . $ `src/types.h:30:9`!) && isEventcxx . . $ JJ1BonusLevel#isEvent(cf9ef193275fa6d8).(playerX, playerY)) { |
| 557 | |
| 558 | int gridX = FTOTcxx . . $ `src/level/level.h:37:9`!(playerX) & 255; |
| 559 | int gridY = FTOTcxx . . $ `src/level/level.h:37:9`!(playerY) & 255; |
| 560 | |
| 561 | // Play sound if available |
| 562 | playSoundcxx . . $ playSound(80b838f98135e5b).(eventSetcxx . . $ JJ1BonusLevel#eventSet.[gridcxx . . $ JJ1BonusLevel#grid.[gridY][gridX].eventcxx . . $ $anonymous_type_1155ca566b20eb7d_0#event.].soundcxx . . $ $anonymous_type_1155ca566b20eb7d_1#sound.); |
| 563 | |
| 564 | switch (eventSetcxx . . $ JJ1BonusLevel#eventSet.[gridcxx . . $ JJ1BonusLevel#grid.[gridY][gridX].eventcxx . . $ $anonymous_type_1155ca566b20eb7d_0#event.].typecxx . . $ $anonymous_type_1155ca566b20eb7d_1#type.) { |
| 565 | |
| 566 | case 1: // Extra time |
| 567 | |
| 568 | addTimercxx . . $ Level#addTimer(d4f767463ce0a6b3).(60); |
| 569 | gridcxx . . $ JJ1BonusLevel#grid.[gridY][gridX].eventcxx . . $ $anonymous_type_1155ca566b20eb7d_0#event. = 0; |
| 570 | |
| 571 | break; |
| 572 | |
| 573 | case 2: // Gem |
| 574 | |
| 575 | bonusPlayer->addGemcxx . . $ JJ1BonusLevelPlayer#addGem(49f6e7a06ebc5aa8).(); |
| 576 | gridcxx . . $ JJ1BonusLevel#grid.[gridY][gridX].eventcxx . . $ $anonymous_type_1155ca566b20eb7d_0#event. = 0; |
| 577 | |
| 578 | if (bonusPlayer->getGemscxx . . $ JJ1BonusLevelPlayer#getGems(b126dc7c1de90089).() >= itemscxx . . $ Level#items.) { |
| 579 | |
| 580 | playerscxx . . $ players.[i].addLifecxx . . $ Player#addLife(49f6e7a06ebc5aa8).(); |
| 581 | |
| 582 | return WONcxx . . $ `src/level/level.h:46:9`!; |
| 583 | |
| 584 | } |
| 585 | |
| 586 | break; |
| 587 | |
| 588 | case 5: // Hand |
| 589 | case 8: |
| 590 | |
| 591 | break; |
| 592 | |
| 593 | case 7: // Exit |
| 594 | |
| 595 | return LOSTcxx . . $ `src/level/level.h:47:9`!; |
| 596 | |
| 597 | default: |
| 598 | |
| 599 | // Do nothing |
| 600 | |
| 601 | break; |
| 602 | |
| 603 | } |
| 604 | |
| 605 | } |
| 606 | |
| 607 | } |
| 608 | |
| 609 | directioncxx . . $ JJ1BonusLevel#direction. = localPlayercxx . . $ localPlayer.->getJJ1BonusLevelPlayercxx . . $ Player#getJJ1BonusLevelPlayer(5b714c54c39cd209).()->getDirectioncxx . . $ JJ1BonusLevelPlayer#getDirection(b126dc7c1de90089).(); |
| 610 | |
| 611 | return E_NONEcxx . . $ `src/OpenJazz.h:69:9`!; |
| 612 | |
| 613 | } |
| 614 | |
| 615 | |
| 616 | /** |
| 617 | * Draw the level. |
| 618 | */ |
| 619 | void JJ1BonusLevelcxx . . $ JJ1BonusLevel#::drawcxx . . $ JJ1BonusLevel#draw(49f6e7a06ebc5aa8). () { |
| 620 | |
| 621 | JJ1BonusLevelPlayercxx . . $ JJ1BonusLevelPlayer# *bonusPlayer; |
| 622 | Animcxx . . $ Anim# *anim; |
| 623 | SDL_Rect dst; |
| 624 | int x, y; |
| 625 | |
| 626 | // Draw the background |
| 627 | |
| 628 | for (x = -(directioncxx . . $ JJ1BonusLevel#direction. & 1023); x < canvasWcxx . . $ canvasW.; x += backgroundcxx . . $ JJ1BonusLevel#background.->wcxx . . $ SDL_Surface#w.) { |
| 629 | |
| 630 | dst.x = x; |
| 631 | dst.y = (canvasHcxx . . $ canvasH. >> 1) - 4; |
| 632 | SDL_BlitSurfacecxx . . $ `<external>/18043084669712134795/SDL_surface.h:873:9`!(backgroundcxx . . $ JJ1BonusLevel#background., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, canvascxx . . $ canvas., &dst); |
| 633 | |
| 634 | } |
| 635 | |
| 636 | x = 171; |
| 637 | |
| 638 | for (y = (canvasHcxx . . $ canvasH. >> 1) - 5; (y >= 0) && (x > 128); y--) |
| 639 | videocxx . . $ video..drawRectcxx . . $ Video#drawRect(a4376a5627a47301).(0, y, canvasWcxx . . $ canvasW., 1, x--); |
| 640 | |
| 641 | if (y > 0) |
| 642 | videocxx . . $ video..drawRectcxx . . $ Video#drawRect(a4376a5627a47301).(0, 0, canvasWcxx . . $ canvasW., y + 1, 128); |
| 643 | |
| 644 | |
| 645 | bonusPlayer = localPlayercxx . . $ localPlayer.->getJJ1BonusLevelPlayercxx . . $ Player#getJJ1BonusLevelPlayer(5b714c54c39cd209).(); |
| 646 | |
| 647 | |
| 648 | // Draw the ground |
| 649 | |
| 650 | fixedcxx . . $ fixed# playerX = bonusPlayer->getXcxx . . $ Movable#getX(b126dc7c1de90089).(); |
| 651 | fixedcxx . . $ fixed# playerY = bonusPlayer->getYcxx . . $ Movable#getY(b126dc7c1de90089).(); |
| 652 | fixedcxx . . $ fixed# playerSin = fSincxx . . $ fSin(7864480464b09eea).(directioncxx . . $ JJ1BonusLevel#direction.); |
| 653 | fixedcxx . . $ fixed# playerCos = fCoscxx . . $ fCos(7864480464b09eea).(directioncxx . . $ JJ1BonusLevel#direction.); |
| 654 | |
| 655 | if (SDL_MUSTLOCKcxx . . $ `<external>/18043084669712134795/SDL_surface.h:62:9`!(canvas)) SDL_LockSurface(canvascxx . . $ canvas.); |
| 656 | |
| 657 | for (y = 1; y <= (canvasHcxx . . $ canvasH. >> 1) - 15; y++) { |
| 658 | |
| 659 | fixedcxx . . $ fixed# distance = DIVcxx . . $ `src/types.h:55:9`!(ITOFcxx . . $ `src/types.h:53:9`!(800), ITOFcxx . . $ `src/types.h:53:9`!(92) - (ITOFcxx . . $ `src/types.h:53:9`!(y * 84) / ((canvasH >> 1) - 16))); |
| 660 | fixedcxx . . $ fixed# sideX = MULcxx . . $ `src/types.h:54:9`!(distance, playerCos); |
| 661 | fixedcxx . . $ fixed# sideY = MULcxx . . $ `src/types.h:54:9`!(distance, playerSin); |
| 662 | fixedcxx . . $ fixed# fwdX = playerX + MULcxx . . $ `src/types.h:54:9`!(distance - F16cxx . . $ `src/types.h:37:9`!, playerSin) - (sideX >> 1); |
| 663 | fixedcxx . . $ fixed# fwdY = playerY - MULcxx . . $ `src/types.h:54:9`!(distance - F16cxx . . $ `src/types.h:37:9`!, playerCos) - (sideY >> 1); |
| 664 | |
| 665 | unsigned char* row = static_cast<unsigned char*>(canvascxx . . $ canvas.->pixelscxx . . $ SDL_Surface#pixels.) + (canvascxx . . $ canvas.->pitchcxx . . $ SDL_Surface#pitch. * (canvasHcxx . . $ canvasH. - y)); |
| 666 | |
| 667 | for (x = 0; x < canvasWcxx . . $ canvasW.; x++) { |
| 668 | |
| 669 | fixedcxx . . $ fixed# nX = ITOFcxx . . $ `src/types.h:53:9`!(x) / canvasWcxx . . $ canvasW.; |
| 670 | int levelX = FTOIcxx . . $ `src/types.h:52:9`!(fwdX + MULcxx . . $ `src/types.h:54:9`!(nX, sideX)); |
| 671 | int levelY = FTOIcxx . . $ `src/types.h:52:9`!(fwdY + MULcxx . . $ `src/types.h:54:9`!(nX, sideY)); |
| 672 | |
| 673 | row[x] = static_cast<unsigned char*>(tileSetcxx . . $ JJ1BonusLevel#tileSet.->pixelscxx . . $ SDL_Surface#pixels.) |
| 674 | [(gridcxx . . $ JJ1BonusLevel#grid.[ITOTcxx . . $ `src/level/level.h:39:9`!(levelY) & 255][ITOTcxx . . $ `src/level/level.h:39:9`!(levelX) & 255].tilecxx . . $ $anonymous_type_1155ca566b20eb7d_0#tile. << 10) + |
| 675 | ((levelY & 31) * tileSetcxx . . $ JJ1BonusLevel#tileSet.->pitchcxx . . $ SDL_Surface#pitch.) + (levelX & 31)]; |
| 676 | |
| 677 | } |
| 678 | |
| 679 | } |
| 680 | |
| 681 | if (SDL_MUSTLOCKcxx . . $ `<external>/18043084669712134795/SDL_surface.h:62:9`!(canvas)) SDL_UnlockSurface(canvascxx . . $ canvas.); |
| 682 | |
| 683 | |
| 684 | // Draw nearby events |
| 685 | |
| 686 | for (y = -6; y < 6; y++) { |
| 687 | int evY = (((directioncxx . . $ JJ1BonusLevel#direction. - FQcxx . . $ `src/types.h:29:9`!) & 512)? y: -y); |
| 688 | fixedcxx . . $ fixed# sY = TTOFcxx . . $ `src/level/level.h:38:9`!(evY) + F16cxx . . $ `src/types.h:37:9`! - (playerY & 32767); |
| 689 | |
| 690 | for (x = -6; x < 6; x++) { |
| 691 | int evX = ((directioncxx . . $ JJ1BonusLevel#direction. & 512)? x: -x); |
| 692 | fixedcxx . . $ fixed# sX = TTOFcxx . . $ `src/level/level.h:38:9`!(evX) + F16cxx . . $ `src/types.h:37:9`! - (playerX & 32767); |
| 693 | |
| 694 | fixedcxx . . $ fixed# divisor = F16cxx . . $ `src/types.h:37:9`! + MULcxx . . $ `src/types.h:54:9`!(sX, playerSin) - MULcxx . . $ `src/types.h:54:9`!(sY, playerCos); |
| 695 | |
| 696 | if (FTOIcxx . . $ `src/types.h:52:9`!(divisor) > 8) { |
| 697 | unsigned char event = gridcxx . . $ JJ1BonusLevel#grid. |
| 698 | [(evY + FTOTcxx . . $ `src/level/level.h:37:9`!(playerY)) & 255][(evX + FTOTcxx . . $ `src/level/level.h:37:9`!(playerX)) & 255].eventcxx . . $ $anonymous_type_1155ca566b20eb7d_0#event.; |
| 699 | |
| 700 | if (eventSetcxx . . $ JJ1BonusLevel#eventSet.[event].typecxx . . $ $anonymous_type_1155ca566b20eb7d_1#type. > 0) { |
| 701 | anim = animSetcxx . . $ JJ1BonusLevel#animSet. + eventSetcxx . . $ JJ1BonusLevel#eventSet.[event].animcxx . . $ $anonymous_type_1155ca566b20eb7d_1#anim.; |
| 702 | |
| 703 | anim->setFramecxx . . $ Anim#setFrame(918ebd27a9ddbad3).(tickscxx . . $ Level#ticks. / 75, true); |
| 704 | fixedcxx . . $ fixed# nX = DIVcxx . . $ `src/types.h:55:9`!(MULcxx . . $ `src/types.h:54:9`!(sX, playerCos) + MULcxx . . $ `src/types.h:54:9`!(sY, playerSin), divisor); |
| 705 | anim->drawScaledcxx . . $ Anim#drawScaled(b1146eedae1e1d0b).(ITOFcxx . . $ `src/types.h:53:9`!(FTOIcxx . . $ `src/types.h:52:9`!(nX * canvasW) + (canvasW >> 1)), |
| 706 | ITOFcxx . . $ `src/types.h:53:9`!(canvasH >> 1), DIVcxx . . $ `src/types.h:55:9`!(F64cxx . . $ `src/types.h:44:9`! * canvasW / SWcxx . . $ `src/io/gfx/video.h:38:9`!, divisor)); |
| 707 | } |
| 708 | } |
| 709 | } |
| 710 | } |
| 711 | |
| 712 | |
| 713 | // Show the player |
| 714 | bonusPlayer->drawcxx . . $ JJ1BonusLevelPlayer#draw(cb2f890c2fdad230).(tickscxx . . $ Level#ticks.); |
| 715 | |
| 716 | |
| 717 | // Show gem count |
| 718 | fontcxx . . $ JJ1BonusLevel#font.->showStringcxx . . $ Font#showString(7e50a619d5a117f1).("*", 0, 0); |
| 719 | fontcxx . . $ JJ1BonusLevel#font.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(bonusPlayer->getGemscxx . . $ JJ1BonusLevelPlayer#getGems(b126dc7c1de90089).() / 10, 50, 0); |
| 720 | fontcxx . . $ JJ1BonusLevel#font.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(bonusPlayer->getGemscxx . . $ JJ1BonusLevelPlayer#getGems(b126dc7c1de90089).() % 10, 68, 0); |
| 721 | fontcxx . . $ JJ1BonusLevel#font.->showStringcxx . . $ Font#showString(7e50a619d5a117f1).("/", 65, 0); |
| 722 | fontcxx . . $ JJ1BonusLevel#font.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(itemscxx . . $ Level#items., 124, 0); |
| 723 | |
| 724 | |
| 725 | // Show time remaining |
| 726 | if (endTimecxx . . $ Level#endTime. > tickscxx . . $ Level#ticks.) x = (endTimecxx . . $ Level#endTime. - tickscxx . . $ Level#ticks.) / 1000; |
| 727 | else x = 0; |
| 728 | fontcxx . . $ JJ1BonusLevel#font.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(x / 60, 250, 0); |
| 729 | fontcxx . . $ JJ1BonusLevel#font.->showStringcxx . . $ Font#showString(7e50a619d5a117f1).(":", 247, 0); |
| 730 | fontcxx . . $ JJ1BonusLevel#font.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).((x / 10) % 6, 274, 0); |
| 731 | fontcxx . . $ JJ1BonusLevel#font.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(x % 10, 291, 0); |
| 732 | |
| 733 | } |
| 734 | |
| 735 | |
| 736 | /** |
| 737 | * Play the level. |
| 738 | * |
| 739 | * @return Error code |
| 740 | */ |
| 741 | int JJ1BonusLevelcxx . . $ JJ1BonusLevel#::playcxx . . $ JJ1BonusLevel#play(b126dc7c1de90089). () { |
| 742 | |
| 743 | bool pmenu, pmessage; |
| 744 | int option; |
| 745 | unsigned int returnTime; |
| 746 | |
| 747 | tickOffsetcxx . . $ Level#tickOffset. = globalTickscxx . . $ globalTicks.; |
| 748 | tickscxx . . $ Level#ticks. = T_STEPcxx . . $ `src/level/level.h:50:9`!; |
| 749 | stepscxx . . $ Level#steps. = 0; |
| 750 | pmessage = pmenu = false; |
| 751 | option = 0; |
| 752 | returnTime = 0; |
| 753 | |
| 754 | videocxx . . $ video..setPalettecxx . . $ Video#setPalette(d5421d17e1a4b2b2).(palettecxx . . $ Level#palette.); |
| 755 | |
| 756 | while (true) { |
| 757 | |
| 758 | int ret = loopcxx . . $ Level#loop(98496cf6cd60cdee).(pmenu, option, pmessage); |
| 759 | if (ret < 0) return ret; |
| 760 | |
| 761 | // Check if level has been won |
| 762 | if (returnTime && (tickscxx . . $ Level#ticks. > returnTime)) { |
| 763 | |
| 764 | if (localPlayercxx . . $ localPlayer.->getJJ1BonusLevelPlayercxx . . $ Player#getJJ1BonusLevelPlayer(5b714c54c39cd209).()->getGemscxx . . $ JJ1BonusLevelPlayer#getGems(b126dc7c1de90089).() >= itemscxx . . $ Level#items.) { |
| 765 | |
| 766 | if (playScenecxx . . $ Level#playScene(5c4306d8553b3696).("BONUS.0SC") == E_QUITcxx . . $ `src/OpenJazz.h:67:9`!) return E_QUITcxx . . $ `src/OpenJazz.h:67:9`!; |
| 767 | |
| 768 | return WONcxx . . $ `src/level/level.h:46:9`!; |
| 769 | |
| 770 | } |
| 771 | |
| 772 | return LOSTcxx . . $ `src/level/level.h:47:9`!; |
| 773 | |
| 774 | } |
| 775 | |
| 776 | |
| 777 | // Process frame-by-frame activity |
| 778 | |
| 779 | while ((getTimeChangecxx . . $ Level#getTimeChange(b126dc7c1de90089).() >= T_STEPcxx . . $ `src/level/level.h:50:9`!) && (stagecxx . . $ Level#stage. == LS_NORMALcxx . . $ LS_NORMAL.)) { |
| 780 | |
| 781 | ret = stepcxx . . $ JJ1BonusLevel#step(b126dc7c1de90089).(); |
| 782 | stepscxx . . $ Level#steps.++; |
| 783 | if (ret < 0) return ret; |
| 784 | else if (ret) { |
| 785 | |
| 786 | stagecxx . . $ Level#stage. = LS_ENDcxx . . $ LS_END.; |
| 787 | paletteEffectscxx . . $ Level#paletteEffects. = new WhiteOutPaletteEffectcxx . . $ WhiteOutPaletteEffect#(T_BONUS_ENDcxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:37:9`!, paletteEffectscxx . . $ Level#paletteEffects.); |
| 788 | returnTime = tickscxx . . $ Level#ticks. + T_BONUS_ENDcxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:37:9`!; |
| 789 | |
| 790 | } |
| 791 | |
| 792 | } |
| 793 | |
| 794 | |
| 795 | // Draw the graphics |
| 796 | |
| 797 | if ((tickscxx . . $ Level#ticks. < returnTime) && !pausedcxx . . $ Level#paused.) directioncxx . . $ JJ1BonusLevel#direction. += (tickscxx . . $ Level#ticks. - prevTickscxx . . $ Level#prevTicks.) * T_BONUS_ENDcxx . . $ `src/jj1/bonuslevel/jj1bonuslevel.h:37:9`! / (returnTime - tickscxx . . $ Level#ticks.); |
| 798 | |
| 799 | drawcxx . . $ JJ1BonusLevel#draw(49f6e7a06ebc5aa8).(); |
| 800 | |
| 801 | // If paused, draw "PAUSE" |
| 802 | if (pmessage && !pmenu) |
| 803 | fontcxx . . $ JJ1BonusLevel#font.->showStringcxx . . $ Font#showString(7e50a619d5a117f1).("pause", (canvasWcxx . . $ canvasW. >> 1) - 44, 32); |
| 804 | |
| 805 | |
| 806 | // Draw statistics, menu etc. |
| 807 | drawOverlaycxx . . $ Level#drawOverlay(ac8280b982de25d7).(0, pmenu, option, 0, 31, 16); |
| 808 | |
| 809 | } |
| 810 | |
| 811 | return E_NONEcxx . . $ `src/OpenJazz.h:69:9`!; |
| 812 | |
| 813 | } |