| 1 | |
| 2 | /** |
| 3 | * |
| 4 | * @file plasma.cpp |
| 5 | * |
| 6 | * Part of the OpenJazz project |
| 7 | * |
| 8 | * @par History: |
| 9 | * - 23rd June 2010: Created plasma.cpp |
| 10 | * |
| 11 | * @par Licence: |
| 12 | * Copyright (c) 2010 Alireza Nejati |
| 13 | * |
| 14 | * OpenJazz is distributed under the terms of |
| 15 | * the GNU General Public License, version 2.0 |
| 16 | * |
| 17 | * @par Description: |
| 18 | * Cool plasma effects for the main menu. |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | |
| 23 | #include "plasma.h"cxx . . $ `<file>/src/menu/plasma.h`/ |
| 24 | |
| 25 | #include "level/level.h"cxx . . $ `<file>/src/level/level.h`/ |
| 26 | #include "util.h"cxx . . $ `<file>/src/util.h`/ |
| 27 | #include "io/gfx/video.h"cxx . . $ `<file>/src/io/gfx/video.h`/ |
| 28 | |
| 29 | #ifdef OJ_SDL3 |
| 30 | #include <SDL3/SDL.h> |
| 31 | #else |
| 32 | #include <SDL.h> |
| 33 | #endif |
| 34 | |
| 35 | /** |
| 36 | * Create the plasma. |
| 37 | */ |
| 38 | Plasmacxx . . $ Plasma#::Plasmacxx . . $ Plasma#Plasma(49f6e7a06ebc5aa8).(){ |
| 39 | |
| 40 | p0cxx . . $ Plasma#p0.=0; |
| 41 | p1cxx . . $ Plasma#p1.=0; |
| 42 | p2cxx . . $ Plasma#p2.=0; |
| 43 | p3cxx . . $ Plasma#p3.=0; |
| 44 | |
| 45 | //fSin, fCos: pi = 512 |
| 46 | // -1024 < out < 1024 |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Draw the plasma. |
| 51 | * |
| 52 | * @return Error code |
| 53 | */ |
| 54 | int Plasmacxx . . $ Plasma#::drawcxx . . $ Plasma#draw(b126dc7c1de90089).(){ |
| 55 | int x,y; |
| 56 | |
| 57 | int w,h,pitch; |
| 58 | unsigned char *px; |
| 59 | unsigned char colour; |
| 60 | |
| 61 | // draw plasma |
| 62 | |
| 63 | SDL_LockSurface(canvascxx . . $ canvas.); |
| 64 | |
| 65 | w = canvascxx . . $ canvas.->wcxx . . $ SDL_Surface#w.; |
| 66 | h = canvascxx . . $ canvas.->hcxx . . $ SDL_Surface#h.; |
| 67 | pitch = canvascxx . . $ canvas.->pitchcxx . . $ SDL_Surface#pitch.; |
| 68 | |
| 69 | px = static_cast<unsigned char*>(canvascxx . . $ canvas.->pixelscxx . . $ SDL_Surface#pixels.); |
| 70 | |
| 71 | int t1 = p0cxx . . $ Plasma#p0.; |
| 72 | int t2 = p1cxx . . $ Plasma#p1.; |
| 73 | for(y=0;y<h;y++){ |
| 74 | int t3 = p2cxx . . $ Plasma#p2.; |
| 75 | int t4 = p3cxx . . $ Plasma#p3.; |
| 76 | unsigned int colb = (fCoscxx . . $ fCos(7864480464b09eea).(t1*4)<<3)+(fCoscxx . . $ fCos(7864480464b09eea).(t2*4)<<3)+(32<<10); |
| 77 | for(x=0;x<w;x++){ |
| 78 | |
| 79 | colour = ((colb+(fCoscxx . . $ fCos(7864480464b09eea).(t3*4)<<3)+(fCoscxx . . $ fCos(7864480464b09eea).(t4*4)<<3))>>10) & 0xF; |
| 80 | |
| 81 | t3 += 3; |
| 82 | t4 += 2; |
| 83 | |
| 84 | px[x] = colour; |
| 85 | } |
| 86 | // go to next row |
| 87 | px += pitch; |
| 88 | t1 += 2; |
| 89 | t2 += 1; |
| 90 | } |
| 91 | |
| 92 | p0cxx . . $ Plasma#p0. = p0cxx . . $ Plasma#p0. < 256 ? p0cxx . . $ Plasma#p0.+1 : 1; |
| 93 | p1cxx . . $ Plasma#p1. = p1cxx . . $ Plasma#p1. < 256 ? p1cxx . . $ Plasma#p1.+2 : 2; |
| 94 | p2cxx . . $ Plasma#p2. = p2cxx . . $ Plasma#p2. < 256 ? p2cxx . . $ Plasma#p2.+3 : 3; |
| 95 | p3cxx . . $ Plasma#p3. = p3cxx . . $ Plasma#p3. < 256 ? p3cxx . . $ Plasma#p3.+4 : 4; |
| 96 | |
| 97 | SDL_UnlockSurface(canvascxx . . $ canvas.); |
| 98 | |
| 99 | return E_NONEcxx . . $ `src/OpenJazz.h:69:9`!; |
| 100 | |
| 101 | } |