harder better faster stronger!!! [can you feel the fuzz!!!]

This is a discussion on harder better faster stronger!!! [can you feel the fuzz!!!] within the A Brief History of Cprogramming.com forums, part of the Community Boards category; do my homework IV me plz... need to make super fast!!! you'll get what i'm trying to do [fuzzing] but ...

  1. #1
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459

    harder better faster stronger!!! [can you feel the fuzz!!!]

    do my homework IV me plz... need to make super fast!!! you'll get what i'm trying to do [fuzzing] but i need another approach to it... which you girls must know!!!!

    Code:
    /***************************** fuzz *******************************************/
      
      void OUTPUT :: fuzz (unsigned int xl, unsigned int yl, unsigned int xh, unsigned it yh)
      {
        unsigned char * old_ptr = h.vb.outdbl.gfx_ptr_;
    
        //  copy the current background to the out double buffer
        h.vb.bg_to_out_dbl (xl, yl, xh, yh);
    
        //  for each pixel in the viewframe
        for (unsigned int u0 = yl; u0 < yh; u0++)
          for (unsigned int u1 = xl; u1 < xh; u1++)
          {
            unsigned int r = 0, g = 0, b = 0;
            unsigned char radius_print [9];
            unsigned int avg_div;
    
            //  grab pixels from out_dbl_
            h.vb.outdbl.gfx_ptr_ = h.vb.outdbl.out_dbl_;
    
            //  get a new grid for each pixel
            avg_div = 0;
            while (avg_div < 5)             //  get at least a 5-pixel average
            {
              avg_div = 0;
              for (unsigned int u0 = 0; u0 < 9; u0++)
              {
                radius_print [u0] = rand () % 2;
                if (radius_print [u0]) avg_div++;
              }
            }
            //  ensure at least the first pixel is on so that it get's counted for
            if (radius_print [4] == 0)
            {
              radius_print [4] = 1;
              avg_div++;
            }
    
            //  add 'em up
            for (unsigned int u2 = 0; u2 < 3; u2++)
              for (unsigned int u3 = 0; u3 < 3; u3++)
                if (radius_print [u2 * 3 + u3])
                {
                  unsigned int x,y;
                  unsigned int pix_add;
                  x = (u1 + h.vb.vars.x_size - 1 + u3) % h.vb.vars.x_size;
                  y = (u0 + h.vb.vars.y_size - 1 + u2) % h.vb.vars.y_size;
    
                  pix_add = h.vb.g_pixel (x, y);
                  
                  //  over line flow, reword...
                  r += (pix_add >> (h.vb.vars.g_bpp + h.vb.vars.b_bpp)) & h.vb.vars.r_max;
                  g += (pix_add >>                    h.vb.vars.b_bpp ) & h.vb.vars.g_max;
                  b += (pix_add >>                    0               ) & h.vb.vars.b_max;
                }
    
            r /= avg_div;
            g /= avg_div;
            b /= avg_div;
    
            //  place pixels to gfx_bg__
            h.vb.outdbl.gfx_ptr_ = h.vb.outdbl.gfx_bg__;
    
            P_PIXEL (u1, u0, r,g,b);
          }
    
        h.vb.update (xl, yl, xh, yh);
      }
    much thanks... i've profiled it many a time... and now that i've got my dirty rectangles updating routine... [doesn't that sound nasty?] i still need it harder better faster stronger!!!

    =-{da, with wings}-=

    [edited]
    hasafraggin shizigishin oppashigger...

  2. #2
    Normal vector Carlos's Avatar
    Join Date
    Sep 2001
    Location
    Budapest
    Posts
    463
    >> i still need it harder better faster stronger!!!

    So don't use C++, it's for girls only, but Assembly instead!

    Btw, is this really a "General Discussions" topic?

    ;)=)

  3. #3
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    hmm... yes i'd say it is because the majority of programers who've gotten past the syntax part of programming, and also visit the boards, view here... also it's more open-ended, although still about code...

    oh, and i don't know asm... is there some structural design flaw i'm missing?
    hasafraggin shizigishin oppashigger...

  4. #4
    Normal vector Carlos's Avatar
    Join Date
    Sep 2001
    Location
    Budapest
    Posts
    463
    >> oh, and i don't know asm... is there some structural design flaw i'm missing?

    Oh, no, you just get what you see.
    There's no "compiler optimization", unneeded linked libs, etc.
    32 bit Asm is a little bit hard, though.

  5. #5
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    i meant the order of the function's statements... perhaps there's a better method of video fuzzing while maintaining acceptable results... note that i'd want to call this function for dimensions of approximately 26k pixels every second... more if possible... any help there? thanks...
    hasafraggin shizigishin oppashigger...

  6. #6
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    Again you could bilinear filter to do the fuzzing.

    Let's say your character 'cell' is 10x10. You need to find how far into the cell you are on x and y. So 5,5 would be .5,.5 or half way into the cell on x and y. Then you call your bilinear filter. Using this method the bilinear would have to be in assembly

    Code:
    WORD BI(WORD v1,WORD v2,WORD v3,WORD v4,double f1,double f2)
    {
    WORD val1=0;
    WORD val2=0;
    WORD fval=0;
    asm
    {
        finit
      GETVAL1:
        fild [v2]
        fisub [v1]
        fmul [f1]
        fiadd [v1]
        fistp [val1]
      GETVAL2:
        fild [v4]
        fisub [v3]
        fmul [f1]
        fiadd [v3]
        fistp [val2]
      GETFVAL:
        fild [val2]
        fisub [val1]
        fmul [f2]
        fiadd [val1]
        fistp [fval]
    } 
    
      return fval;
    }
    This is a very fast bilinear interpolation using the FPU. You can do the same in C but it is not nearly as fast. In my real-mode voxel engine this operation is done at least a 1000 times in the render and I still get a great frame rate in 320x200x16 bit.

    So for blurring text this operation would be very fast. It might be able to be optimized a bit farther (as all assembly programs probably could be) but I've not done it since it gave acceptable results.

    You could also use this to create text that started in one color and smoothly translated to another, although you could also do that with one linear interpolation between the starting color and the ending color. The floating value would be how far into the text string you are (in pixels) divided by the total length of the string (in pixels). This could be pre-computed, set start color to left color value, iterate and increase color RGB's by pre-computed RGB steps.

    The bilinear function would allow you to create radiant blend test strings also.

  7. #7
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    I've looked into the DJGPP Info files concerning assembly and have found the information needed to use the FPU in DJGPP so you can do this in protected mode also. You will be clobbering a lot of registers and also memory but it can be done.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21