| 1 | /* |
| 2 | * |
| 3 | * BaltanTV - like StreakTV, but following for a long time |
| 4 | * Copyright (C) 2001 FUKUCHI Kentarou |
| 5 | * ported to FreeJ by jaromil |
| 6 | * |
| 7 | * 2009/8/26 |
| 8 | * Ported to frei0r from the old FreeJ filter API |
| 9 | * -Jaromil |
| 10 | * |
| 11 | * This source code is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU Public License as published by |
| 13 | * the Free Software Foundation; either version 3 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This source code is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Please refer |
| 19 | * to the GNU Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU Public License along |
| 22 | * with this source code; if not, write to: Free Software Foundation, |
| 23 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 24 | */ |
| 25 | |
| 26 | #include <stdlib.h> |
| 27 | #include <string.h> |
| 28 | |
| 29 | #include <frei0r.hpp> |
| 30 | |
| 31 | #define PLANES 32 |
| 32 | |
| 33 | #define STRIDE 8 |
| 34 | #define STRIDE2 16 /* (STRIDE*2) */ |
| 35 | #define STRIDE3 24 /* (STRIDE*3) */ |
| 36 | |
| 37 | // freej compat facilitator |
| 38 | typedef struct { |
| 39 | int16_t w; |
| 40 | int16_t h; |
| 41 | uint8_t bpp; |
| 42 | uint32_t size; |
| 43 | } ScreenGeometry; |
| 44 | |
| 45 | |
| 46 | class Baltan: public frei0r::filter { |
| 47 | |
| 48 | public: |
| 49 | Baltan(int wdt, int hgt); |
| 50 | ~Baltan(); |
| 51 | |
| 52 | virtual void update(double time, |
| 53 | uint32_t* out, |
| 54 | const uint32_t* in); |
| 55 | |
| 56 | private: |
| 57 | ScreenGeometry geo; |
| 58 | |
| 59 | void _init(int wdt, int hgt); |
| 60 | |
| 61 | uint32_t *planebuf; |
| 62 | uint32_t *planetable[PLANES]; |
| 63 | int plane; |
| 64 | int pixels; |
| 65 | }; |
| 66 | |
| 67 | Baltan::Baltan(int wdt, int hgt) { |
| 68 | int i; |
| 69 | |
| 70 | _init(wdt, hgt); |
| 71 | pixels = geo.w*geo.h; |
| 72 | |
| 73 | planebuf = (uint32_t*)calloc(geo.size, PLANES); |
| 74 | |
| 75 | for(i=0;i<PLANES;i++) |
| 76 | planetable[i] = &planebuf[pixels*i]; |
| 77 | |
| 78 | plane = 0; |
| 79 | } |
| 80 | |
| 81 | Baltan::~Baltan() { |
| 82 | free(planebuf); |
| 83 | } |
| 84 | |
| 85 | void Baltan::update(double time, |
| 86 | uint32_t* out, |
| 87 | const uint32_t* in) { |
| 88 | int i, cf; |
| 89 | |
| 90 | uint32_t *src = (uint32_t*)in; |
| 91 | uint32_t *dst = (uint32_t*)out; |
| 92 | |
| 93 | |
| 94 | for(i=0; i<pixels; i++) |
| 95 | planetable[plane][i] = (src[i] & 0xfcfcfc)>>2; |
| 96 | |
| 97 | |
| 98 | cf = plane & (STRIDE-1); |
| 99 | |
| 100 | for(i=0; i<pixels; i++) { |
| 101 | dst[i] = (src[i]&0xFF000000) |
| 102 | |(planetable[cf][i] |
| 103 | + planetable[cf+STRIDE][i] |
| 104 | + planetable[cf+STRIDE2][i] |
| 105 | + planetable[cf+STRIDE3][i]); |
| 106 | planetable[plane][i] = (dst[i]&0xfcfcfc)>>2; |
| 107 | } |
| 108 | |
| 109 | |
| 110 | plane++; |
| 111 | plane = plane & (PLANES-1); |
| 112 | |
| 113 | } |
| 114 | |
| 115 | void Baltan::_init(int wdt, int hgt) { |
| 116 | geo.w = wdt; |
| 117 | geo.h = hgt; |
| 118 | geo.bpp = 32; |
| 119 | geo.size = geo.w*geo.h*(geo.bpp/8); |
| 120 | } |
| 121 | |
| 122 | frei0r::construct<Baltan> plugin("Baltan", |
| 123 | "delayed alpha smoothed blit of time", |
| 124 | "Kentaro, Jaromil", |
| 125 | 3,1); |