Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

I'm lost again

Name: Anonymous 2011-11-16 4:15

Any idea what does the following code do? (The PalA and PalB tables are used for some scary 16-bit lookup. Never understood such crap.)


void __cdecl initPalsAB()
{
  unsigned __int32 I; // [sp+4Ch] [bp-18h]@4
  unsigned __int32 J; // [sp+4Ch] [bp-18h]@17
  unsigned __int32 K; // [sp+50h] [bp-14h]@2
  unsigned __int32 L; // [sp+50h] [bp-14h]@15
  unsigned __int32 A; // [sp+5Ch] [bp-8h]@7
  unsigned __int32 B; // [sp+5Ch] [bp-8h]@20

  if ( SprFlags == 1 )
  {
    for ( K = 0; K < 0x20; ++K )
    {
      for ( I = 0; I < 0x100; ++I )
      {
        if ( ((0x1F - K) * 8 * (I & 3) >> 4) & 1 )
          A = ((0x1F - K) * 8 * (I & 3) >> 5) + 1;
        else
          A = (0x1F - K) * 8 * (I & 3) >> 5;
        if ( A > 0x1F )
          A = 31;
        *(_DWORD *)&PalB[2 * (I + (K << 8))] = 0x20 * A + ((31 - K) * ((I & 0x7C) >> 2) >> 5 << 10);
        *(_DWORD *)&PalA[2 * (I + (K << 8))] = ((31 - K) * (I & 0x1F) >> 5)
                                             + 0x20 * ((0x1F - K) * ((I & 0xE0) >> 5) >> 5);
      }
    }
    GlbFormat = 0x7BDEu;
  }
  else
  {
    if ( SprFlags )
    {
      GlbFormat = 0xFEFEFEu;
    }
    else
    {
      for ( L = 0; L < 0x20; ++L )
      {
        for ( J = 0; J < 0x100; ++J )
        {
          if ( ((31 - L) * 8 * (J & 7) >> 4) & 1 )
            B = ((31 - L) * 8 * (J & 7) >> 5) + 1;
          else
            B = (31 - L) * 8 * (J & 7) >> 5;
          if ( B > 0x3F )
            B = 63;
          *(_DWORD *)&PalB[2 * (J + (L << 8))] = 0x20 * B + ((0x1F - L) * ((J & 0xF8) >> 3) >> 5 << 11);
          *(_DWORD *)&PalA[2 * (J + (L << 8))] = ((0x1F - L) * (J & 0x1F) >> 5)
                                               + 0x20 * ((0x1F - L) * ((J & 0xE0) >> 5) >> 5);
        }
      }
      GlbFormat = 0xF7DEu;
    }
  }
}

Name: Anonymous 2011-11-16 4:19

Looks similar to alpha hacks, but not the same. Cant decipher


unsigned blend565[33][2][256];

void init() {
    for(unsigned alpha=0; alpha<=32; ++alpha) {
        unsigned f = alpha;

        for(unsigned i=0; i<256; ++i) {
            blend565[alpha][1][i] = (((i & 0xf8)*f) << 19) + (((i & 0x07)*f) <<  3) + (0x04008010 >> 1);
            blend565[alpha][0][i] = (((i & 0xe0)*f) >>  5) + (((i & 0x1f)*f) << 11);
        }
    }
}

void blend565(unsigned dst, unsigned src, unsigned alpha) {
    unsigned ialpha = 32-alpha;
    unsigned sum = blend565tab[alpha][0][src & 0xff] + blend565tab[ialpha][0][dst & 0xff] + blend565tab[alpha][1][src >> 8] + blend565tab[ialpha][1][dst >> 8];

    sum &= 0xf81f07e0;

    return (sum & 0xffff) + (sum >> 16);
}

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-16 4:21

Value at pointer pointed by location of array element= decided by values of loop variables for current elements
Its a pixel filler.

Name: Anonymous 2011-11-16 4:24

SICP wont teach you how to do that.

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-16 4:26

This one is used for my javascript quasicrystal generator(it makes a 8bit pallette based on blue/purple)
function palgen(){
var ic,ir,ig,ib;
    for(ic=0;ic<0xff;ic++){
    ir=ic-31;ir*=ir>2;ig=ic-81;ig*=ig>8;ig=ig<<8;ib=(ic)<<16
    RGB[ic]=ir|ig|ib|0xff000000;}}palgen();

Name: Anonymous 2011-11-16 4:27

>>5
http://www.ioccc.org/
The 20th International Obfuscated C Code Contest is open

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-16 4:29

This is from the C code which generates crystal bitmaps
s4* colors=bitmap+54;
s4* pixels=bitmap+STDOFFSET;
s4 ic,ir,ig,ib,ia;double index,tx,ty,sn,frac;
mkdir(FRAMEDIR);
for(i=0;i<256;i++){
ic=i;
ia=(256-(ic&0xf))<<24;
ir=(ic)-31;ir*=ir>2;
ig=(ic)-81;ig*=ig>8;
ib=(ic)-0; ib*=ib>0;
//------------AR G B
colors[i]=ia<<24|ir<<16|ig<<8|ib  ;
}

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-16 4:32

>>6
I can read their code actually, if it was really obsfucated it would be filled with casts, redefined function pointers and exchanged variables through global arrays decided by functions. Its just "lets minify it to 500 bytes"

Name: Anonymous 2011-11-16 4:33

>>8
Compiler too can read. But does it really understand what it reads?

Name: FrozenVoid !!mJCwdV5J0Xy2A21 2011-11-16 4:38

>>9
Well, the real stuff is not that hard,they just don't use indentation and prefer one-character variables
If you are used to indented, documented "Enterprise" code, you won't get it.

             /*                                     ,*/
            #include                              <time.h>
             #include/*                     _  ,o*/  <stdlib.h>
             #define  c(C)/*     -      . */return      ( C); /*    2004*/
              #include   <stdio.h>/*.   Moekan           "'   `\b-'     */
                typedef/*  */char   p;p* u                     ,w       [9
                  ][128] ,*v;typedef  int _;_   R,i,N,I,A               ,m,o,e
             [9],  a[256],k    [9], n[               256];FILE*f       ;_ x   (_ K,_ r
        ,_ q){;   for(;                                         r<     q    ; K       =((
     0xffffff)   &(K>>8))^                                        n[255     &        ( K
   ^u[0        +                                     r  ++      ]     )]);c          (K
  )}        _ E                           (p*r,    p*q  ){     c(          f         =
          fopen                     (r  ,q))}_   B(_ q){c(    fseek        (f,      0
        ,q))}_ D(){c(  fclose(f ))}_  C(  p    *q){c(  0-    puts(q    )   )}_/*   /
      */main(_ t,p**z){if(t<4)c(   C("<in"       "file>"    "\40<l"   "a"  "yout> "
     /*b9213272*/"<outfile>"   ) )u=0;i=I=(E(z[1],"rb")) ?B(2)?0 :   (((o   =ftell
    (f))>=8)?(u     =(p*)malloc(o))?B(0)?0:!fread(u,o,1,f):0:0)?0:  D():0      ;if(
   !u)c(C("      bad\40input  "));if(E(z[2],"rb" )){for(N=-1;256> i;n[i++] =-1   )a[
   i]=0;       for(i=I=0;   i<o&&(R  =fgetc(   f))>-1;i++)++a[R] ?(R==N)?( ++I>7)?(n[
  N]+1       )?0:(n [N   ]=i-7):0:   (N=R)    |(I=1):0;A =-1;N=o+1;for(i=33;i<127;i++
  )(        n[i   ]+  1&&N>a[i])?    N= a     [A=i]     :0;B(i=I=0);if(A+1)for(N=n[A];
 I<       8&&   (R  =fgetc(f ))>    -1&& i   <o        ;i++)(i<N||i>N+7)?(R==A)?((*w[I
 ]             =u [i])?1:(*w[I]=   46))?(a             [I++]=i):0:0:0;D();}if(I<1)c(C(
              "  bad\40la" "yout  "))for(i            =0;256>(R=  i);n[i++]=R)for(A=8;
             A  >0;A --)   R  = ( (R&1)==0)          ?(unsigned int)R>>(01):((unsigned
            /*kero  Q'        ,KSS  */)R>>         1)^        0xedb88320;m=a[I-1];a[I
            ]=(m           <N)?(m=   N+8):        ++        m;for(i=00;i<I;e[i++]=0){
           v=w         [i]+1;for(R                      =33;127  >R;R++)if(R-47&&R-92
           &&       R-(_)* w[i])*(                   v++)=    (p)R;*v=0;}for(sprintf
                  /*'_  G*/  (*w+1,              "%0"     "8x",x(R=time(i=0),m,o)^~
                0)   ;i<       8;++           i)u      [N+ i]=*(*w+i+1);for(*k=x(~
                  0,i=0     ,*a);i>-        1;      ){for (A=i;A<I;A++){u[+a [ A]
                ]=w[A       ][e[A]]  ;     k     [A+1]=x (k[A],a[A],a[A+1]
              );}if     (R==k[I])      c(      (E(z[3  ],"wb+"))?fwrite(
             /* */   u,o,1,f)?D          ()|C("  \n    OK."):0    :C(
            "  \n  WriteError"            ))  for  (i  =+I-
           1  ;i >-1?!w[i][++                 e[+ i]]:0;
             ) for( A=+i--;                 A<I;e[A++]
             =0); (i <I-4                 )?putchar
             ((_   )  46)                  | fflush
            /*'      ,*/                  ( stdout
            ):       0&                    0;}c(C
           ("       \n                   fail")
           )      /*                    dP' /
                 dP                    pd  '
                '                      zc
                                      */
                                     }

Name: Anonymous 2011-11-16 15:36

>>10
mother of god

Name: Anonymous 2011-11-16 15:48

>>10
Fucking clown

Name: Anonymous 2011-11-16 15:57

>>12
IOCCC submission

Name: Anonymous 2011-11-16 16:16

>>13
Your point?

Name: Anonymous 2011-11-16 19:08

>>14
not his. your point?

Name: Anonymous 2011-11-16 19:19

>>15
You're point first.

Don't change these.
Name: Email:
Entire Thread Thread List