gba_blend.pas 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. (*
  2. gba_blend.pas 18/06/2006 4.17.40
  3. ------------------------------------------------------------------------------
  4. As this is a direct port from c, I'm pretty sure that something could not work
  5. as you expect. I am even more sure that this code could be written better, so
  6. if you think that I have made some mistakes or you have some better
  7. implemented functions, let me know [francky74 (at) gmail (dot) com]
  8. Enjoy!
  9. Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
  10. (http://www.freepascal.org)
  11. Copyright (C) 2006 Francesco Lombardi
  12. This library is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU Lesser General Public
  14. License as published by the Free Software Foundation; either
  15. version 2.1 of the License, or (at your option) any later version.
  16. This library is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. Lesser General Public License for more details.
  20. You should have received a copy of the GNU Lesser General Public
  21. License along with this library; if not, write to the Free Software
  22. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. ------------------------------------------------------------------------------
  24. *)
  25. unit gba_blend;
  26. {$i def.inc}
  27. interface
  28. uses
  29. gba_types;
  30. const
  31. BLEND_TOP_BG0 = (1 shl 0);
  32. BLEND_TOP_BG1 = (1 shl 1);
  33. BLEND_TOP_BG2 = (1 shl 2);
  34. BLEND_TOP_BG3 = (1 shl 3);
  35. BLEND_TOP_OBJ = (1 shl 4);
  36. BLEND_TOP_BD = (1 shl 5);
  37. BLEND_LOW_BG0 = (1 shl 8);
  38. BLEND_LOW_BG1 = (1 shl 9);
  39. BLEND_LOW_BG2 = (1 shl 10);
  40. BLEND_LOW_BG3 = (1 shl 11);
  41. BLEND_LOW_OBJ = (1 shl 12);
  42. BLEND_LOW_BD = (1 shl 13);
  43. BLEND_MODE_OFF = (0 shl 6);
  44. BLEND_MODE_ALPHA = (1 shl 6);
  45. BLEND_MODE_LIGHT = (2 shl 6);
  46. BLEND_MODE_DARK = (3 shl 6);
  47. function BlendLow(n: dword): dword; inline;
  48. function BlendHigh(n: dword): dword; inline;
  49. function BlendLevel(n: dword): dword; inline;
  50. function BlendBalance(n: dword): dword; inline;
  51. function BlendDepth(n: dword): dword; inline;
  52. implementation
  53. function BlendLow(n: dword): dword; inline;
  54. begin
  55. BlendLow := (n shl 0);
  56. end;
  57. function BlendHigh(n: dword): dword; inline;
  58. begin
  59. BlendHigh := (n shl 8);
  60. end;
  61. function BlendLevel(n: dword): dword; inline;
  62. begin
  63. BlendLevel := (BlendLow(n) or BlendHigh(n));
  64. end;
  65. function BlendBalance(n: dword): dword; inline;
  66. begin
  67. BlendBalance := (BlendLow(n) or BlendHigh(16-n));
  68. end;
  69. function BlendDepth(n: dword): dword; inline;
  70. begin
  71. BlendDepth := (n shl 0);
  72. end;
  73. end.