Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. IBlendRBG:
  2. ; blend color c and a
  3. ; destroy b and e
  4.     ld  b, a
  5.     and c
  6.     and ICOLOR_LOW_BIT
  7.     ld  e, a
  8.     ld  a, b
  9.     and ~ICOLOR_LOW_BIT
  10.     ld  b, a
  11.     ld  a, c
  12.     and ~ICOLOR_LOW_BIT
  13.     add a, b
  14.     rra
  15.     add a, e
  16.     ret
  17. ILitRBG:
  18. ; lit a color (c) by factor (a)
  19. ; destroy bc, hl
  20.     ld  b, a
  21.     ld  a, c
  22.     and IGREEN_BITS
  23.     ld  l, a
  24.     ld  h, b
  25.     mlt hl
  26.     add hl, hl
  27.     add hl, hl
  28.     ld  a, h
  29.     tst a, %11111000
  30.     jr  z, $+4
  31.     ld  h, IGREEN_BITS
  32.     ld  a, c
  33.     and IBLUE_BITS
  34.     ld  l, a
  35.     ld  a, h
  36.     ld  h, b
  37.     mlt hl
  38.     add hl, hl
  39.     add hl, hl
  40.     ld  l, a
  41.     ld  a, h
  42.     tst a, %11100000
  43.     jr  z, $+4
  44.     ld  a, IBLUE_BITS
  45.     and IBLUE_BITS
  46.     or  l
  47.     ld  h, b
  48.     ld  b, a
  49.     ld  a, c
  50.     and IRED_BITS
  51.     ld  l, a
  52.     mlt hl
  53.     ld  a, h
  54.     tst a, %11000000
  55.     jr  z, $+4
  56.     ld  h, IRED_BITS>>2
  57.     add hl, hl
  58.     add hl, hl
  59.     ld  a, h
  60.     and IRED_BITS
  61.     or  b
  62.     ret
  63. ILerpRBG:
  64. ; 452 TStates
  65.     push    hl
  66.     ld  b, (hl)
  67. ; b,c,e
  68.     ld  e, a
  69.     ld  a, b
  70.     and IGREEN_BITS
  71.     ld  h, a
  72.     ld  a, c
  73.     and IGREEN_BITS
  74.     sub h
  75.     jr  nc, $+4
  76.     cpl
  77.     inc a
  78.     ld  h, a
  79.     ld  l, e
  80. ; convert flag
  81.     sbc a, a
  82.     or  a, a
  83. ; c=nz, nc=z
  84.     mlt hl
  85.     add hl, hl
  86.     add hl, hl
  87.     ld  a, h
  88.     jr  z, $+4
  89.     neg
  90.     ld  h, a
  91.     ld  a, b
  92.     and IGREEN_BITS
  93.     add a, h
  94.     ld  d, a
  95. ; 138
  96.     ld  a, b
  97.     and IBLUE_BITS
  98.     ld  h, a
  99.     ld  a, c
  100.     and IBLUE_BITS
  101.     sub h
  102.     jr  nc, $+4
  103.     cpl
  104.     inc a
  105.     ld  h, a
  106.     ld  l, e
  107.     mlt hl
  108.     rl  h   ; push down carry flag 
  109.     add hl, hl
  110.     ld  a, h
  111.     and IBLUE_BITS
  112.     bit 1, h
  113.     jr  z, $+4
  114.     neg
  115.     ld  h, a
  116.     ld  a, b
  117.     and IBLUE_BITS
  118.     add a, h
  119.     or  d
  120.     ld  d, a
  121. ; 280
  122.     ld  a, b
  123.     and IRED_BITS
  124.     ld  h, a
  125.     ld  a, c
  126.     and IRED_BITS
  127.     sub h
  128.     jr  nc, $+4
  129.     cpl
  130.     inc a ; neg, put different flag output
  131.     ld  h, a
  132.     ld  l, e
  133.     mlt hl
  134.     rl  h ; push down carry flag
  135.     ld  a, h
  136.     and IRED_BITS>>1
  137.     bit 0, h
  138.     jr  z, $+4
  139.     neg
  140.     ld  h, a
  141.     ld  a, b
  142.     rra
  143.     and IRED_BITS>>1
  144.     add a, h
  145.     sla a
  146.     or  d
  147.     pop hl
  148.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement