gba_bg.pas 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. (*
  2. gba_bg.pas 18/06/2006 4.07.57
  3. ------------------------------------------------------------------------------
  4. This lib is a raw porting of libgba library for gba (you can find it at
  5. http://www.devkitpro.org).
  6. As this is a direct port from c, I'm pretty sure that something could not work
  7. as you expect. I am even more sure that this code could be written better, so
  8. if you think that I have made some mistakes or you have some better
  9. implemented functions, let me know [francky74 (at) gmail (dot) com]
  10. Enjoy!
  11. Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
  12. (http://www.freepascal.org)
  13. Copyright (C) 2006 Francesco Lombardi
  14. This library is free software; you can redistribute it and/or
  15. modify it under the terms of the GNU Lesser General Public
  16. License as published by the Free Software Foundation; either
  17. version 2.1 of the License, or (at your option) any later version.
  18. This library is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  21. Lesser General Public License for more details.
  22. You should have received a copy of the GNU Lesser General Public
  23. License along with this library; if not, write to the Free Software
  24. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  25. ------------------------------------------------------------------------------
  26. *)
  27. unit gba_bg;
  28. {$i def.inc}
  29. interface
  30. uses
  31. gba_types;
  32. const
  33. DISP_HBLANK_PROCESS_ON = (0 shl 5);
  34. DISP_HBLANK_PROCESS_OFF = (1 shl 5);
  35. DISP_SPRITE_TYPE_1D = (1 shl 6);
  36. DISP_SPRITE_TYPE_2D = (0 shl 6);
  37. DISP_FORCE_BLANK = (1 shl 7);
  38. DISP_BG0 = (1 shl 8);
  39. DISP_BG1 = (1 shl 9);
  40. DISP_BG2 = (1 shl 10);
  41. DISP_BG3 = (1 shl 11);
  42. DISP_OBJ = (1 shl 12);
  43. DISP_WND0 = (1 shl 13);
  44. DISP_WND1 = (1 shl 14);
  45. DISP_OBJWND = (1 shl 15);
  46. DSTAT_BIT_VBLANK = (1);
  47. DSTAT_BIT_HBLANK = (1 shl 1);
  48. DSTAT_BIT_VCOUNT = (1 shl 2);
  49. DSTAT_USE_VBLANK = (1 shl 3);
  50. DSTAT_USE_HBLANK = (1 shl 4);
  51. DSTAT_USE_VCOUNT = (1 shl 5);
  52. BG_SIZEA_256_256 = 0;
  53. BG_SIZEA_512_256 = (1 shl 14);
  54. BG_SIZEA_256_512 = (2 shl 14);
  55. BG_SIZEA_512_512 = (3 shl 14);
  56. BG_SIZEB_128_128 = 0;
  57. BG_SIZEB_256_256 = (1 shl 14);
  58. BG_SIZEB_512_512 = (2 shl 14);
  59. BG_SIZEB_1024_1024= (2 shl 14);
  60. BG_OVERLAP = (1 shl 13);
  61. BG_COLOR_16 = 0;
  62. BG_COLOR_256 = (1 shl 7);
  63. BG_MOZAIC_ON = (1 shl 6);
  64. BG_MAP_YFLIP = (1 shl 11);
  65. BG_MAP_XFLIP = (1 shl 10);
  66. MEM_BG_PAL : ^word = pointer($5000000);
  67. function DispBgMode(x: dword): dword;
  68. function DispSelectBuffer(x: dword): dword;
  69. function BgMapTile(x: word): word;
  70. function MemBgChar(x: word): pointer;
  71. function MemBgMap(x: word): pointer;
  72. function BgCharBase(x: dword): dword;
  73. function BgPriority(x: dword): dword;
  74. function BgMapPal(x: dword): dword;
  75. function BgMapBase(x: dword): dword;
  76. function DStatVCountLine(x: dword): dword;
  77. implementation
  78. function DispBgMode(x: dword): dword;
  79. begin
  80. DispBgMode := x;
  81. end;
  82. function DispSelectBuffer(x: dword): dword;
  83. begin
  84. DispSelectBuffer := (x shl 4);
  85. end;
  86. function BgMapTile(x: word): word;
  87. begin
  88. BgMapTile := (x);
  89. end;
  90. function MemBgChar(x: word): pointer;
  91. begin
  92. MemBgChar := pointer($6000000 + (x)*$4000);
  93. end;
  94. function MemBgMap(x: word): pointer;
  95. begin
  96. MemBgMap := pointer($6000000 + (x)* $800);
  97. end;
  98. function BgCharBase(x: dword): dword;
  99. begin
  100. BgCharBase := ((x) shl 2);
  101. end;
  102. function BgPriority(x: dword): dword;
  103. begin
  104. BgPriority := x;
  105. end;
  106. function BgMapPal(x: dword): dword;
  107. begin
  108. BgMapPal := ((x) shl 12);
  109. end;
  110. function BgMapBase(x: dword): dword;
  111. begin
  112. BgMapBase := ((x) shl 8);
  113. end;
  114. function DStatVCountLine(x: dword): dword;
  115. begin
  116. DStatVCountLine := ((x) shl 8);
  117. end;
  118. end.