SHARE
TWEET

AverageBGR565

Runer112 May 28th, 2015 (edited) 232 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Calculates the average of the BGR565 (or RGB565) colors in DE and HL into HL.
  2. ;    I: DE=color1, HL=color2
  3. ;    O: A=color1&$FF&~((1<<5)+1), BC=color1&color2&(((1<<6)+1<<5)+1),
  4. ;       DE=color1&~(((1<<6)+1<<5)+1), HL=average(color1,color2)
  5. ;   FO: SZP(L), C=0
  6. ;   CC: 125
  7. AverageBGR565:
  8.         ld      a,d
  9.         and     h
  10.         and     1<<(6+5-8)
  11.         ld      b,a
  12.         ld      a,e
  13.         and     l
  14.         and     (1<<5)+1
  15.         ld      c,a
  16.         res     (6+5)&7,d
  17.         ld      a,e
  18.         and     ~((1<<5)+1)
  19.         ld      e,a
  20.         res     (6+5)&7,h
  21.         res     5,l
  22.         add     hl,de
  23.         rr      h
  24.         rr      l
  25.         add     hl,bc
  26.         ret
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top