olikraus / dogm128

Automatically exported from code.google.com/p/dogm128
Other
20 stars 6 forks source link

bugreport setHBitmap is wrong with reverse active #149

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

------------ORIGINAL dogmsm.c ------------

    /* at position (x,y) set a pixel for each logical one bit in the bitmap pattern */
    /* the bitmap must contain (w+7)/8 bytes, each byte is interpreted as bitmap pattern */
    /* most significant bit of the byte in the pattern is on the left */
    void dog_SetHBitmap(uint8_t x, uint8_t y, const unsigned char *bitmap, uint8_t w)
    {
      uint8_t i, tmp, b;
      if ( x < DOG_WIDTH )
        if ( y >= dog_min_y && y <=dog_max_y )
        {
          tmp = y;
          tmp &= (uint8_t)7;
          tmp = dog_bit_to_mask[tmp];

          if ( x+w > DOG_WIDTH )
          {
        w = DOG_WIDTH;
        w -= x;
          }
          b = 0;
          for( i = 0; i < w; i++ )
          {
        if ( (i & 7) == 0 )
          b = *bitmap++;
        if ( b & 128 )
        {
    #if defined(DOG_DOUBLE_MEMORY)
          if ( (y & 8) == 0 )
          {
            dog_page_buffer[x] |= tmp;
          }
          else
          {
            dog_page_buffer[x+DOG_WIDTH] |= tmp;
          }
    #else
          dog_page_buffer[x] |= tmp;
    #endif
        }
        b<<=1;
        x++;
          }
        }  
    }

------------WORKING REVERSED dogmsm.c ------------

    /* at position (x,y) set a pixel for each logical one bit in the bitmap pattern */
    /* the bitmap must contain (w+7)/8 bytes, each byte is interpreted as bitmap pattern */
    /* most significant bit of the byte in the pattern is on the left */
    void dog_SetHBitmap(uint8_t x, uint8_t y, const unsigned char *bitmap, uint8_t w)
    {
        uint8_t i, tmp, b;
        if ( x < DOG_WIDTH )
            if ( y >= dog_min_y && y <=dog_max_y )
                {
                tmp = y;
                tmp &= (uint8_t)7;
                tmp = dog_bit_to_mask[tmp];

                if ( x+w > DOG_WIDTH )
                    {
                    w = DOG_WIDTH;
                    w -= x;
                    }
                b = 0;
                for( i = 0; i < w; i++ )
                    {
                    if ( (i & 7) == 0 )
                        b = *bitmap++;
    #if defined(DOG_REVERSE)               
                    if ( b & 1 )           

    #else
                    if ( b & 128 )
    #endif
                        {
    #if defined(DOG_DOUBLE_MEMORY)
                        if ( (y & 8) == 0 )
                            {
                            dog_page_buffer[x] |= tmp;
                            }
                        else
                            {
                            dog_page_buffer[x+DOG_WIDTH] |= tmp;
                            }
    #else
                        dog_page_buffer[x] |= tmp;
    #endif
                        }
    #if defined(DOG_REVERSE)
                    b>>=1;
    #else
                    b<<=1;
    #endif
                    x++;
                    }
                }  
    }

Original issue reported on code.google.com by olikr...@gmail.com on 21 Feb 2012 at 12:40