system.inc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. (*
  2. $Id: system.inc 25 2007-12-10 21:06:46Z p4p3r0 $
  3. ------------------------------------------------------------------------------
  4. Copyright (C) 2005
  5. Jason Rogers (dovoto)
  6. Dave Murphy (WinterMute)
  7. This software is provided 'as-is', without any express or implied
  8. warranty. In no event will the authors be held liable for any
  9. damages arising from the use of this software.
  10. Permission is granted to anyone to use this software for any
  11. purpose, including commercial applications, and to alter it and
  12. redistribute it freely, subject to the following restrictions:
  13. 1. The origin of this software must not be misrepresented; you
  14. must not claim that you wrote the original software. If you use
  15. this software in a product, an acknowledgment in the product
  16. documentation would be appreciated but is not required.
  17. 2. Altered source versions must be plainly marked as such, and
  18. must not be misrepresented as being the original software.
  19. 3. This notice may not be removed or altered from any source
  20. distribution.
  21. ------------------------------------------------------------------------------
  22. Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
  23. (http://www.freepascal.org)
  24. Copyright (C) 2006 Francesco Lombardi
  25. Check http://sourceforge.net/projects/libndsfpc for updates
  26. ------------------------------------------------------------------------------
  27. $Log$
  28. *)
  29. {$ifdef NDS_INTERFACE}
  30. const
  31. REG_DISPSTAT : pcuint16 = pointer($04000004);
  32. DISP_IN_VBLANK = (1 shl 0);
  33. DISP_IN_HBLANK = (1 shl 1);
  34. DISP_YTRIGGERED = (1 shl 2);
  35. DISP_VBLANK_IRQ = (1 shl 3);
  36. DISP_HBLANK_IRQ = (1 shl 4);
  37. DISP_YTRIGGER_IRQ = (1 shl 5);
  38. {$endif NDS_INTERFACE}
  39. {$ifdef NDS_IMPLEMENTATION}
  40. procedure SetYtrigger(Yvalue: cint); inline;
  41. begin
  42. REG_DISPSTAT^ := (REG_DISPSTAT^ and $007F ) or (Yvalue shl 8) or (( Yvalue and $100 ) shr 2);
  43. end;
  44. {$endif NDS_IMPLEMENTATION}
  45. {$ifdef NDS_INTERFACE}
  46. const
  47. REG_VCOUNT : pcuint16 = pointer($04000006);
  48. HALT_CR : pcuint16 = pointer($04000300);
  49. REG_POWERCNT : pcuint16 = pointer($04000304);
  50. {$endif NDS_INTERFACE}
  51. {$ifdef NDS_IMPLEMENTATION}
  52. procedure powerON(Aon: cint); inline;
  53. begin
  54. REG_POWERCNT^ := REG_POWERCNT^ or Aon;
  55. end;
  56. procedure powerSET(Aon: cint); inline;
  57. begin
  58. REG_POWERCNT^ := Aon;
  59. end;
  60. procedure powerOFF(off: cint); inline;
  61. begin
  62. REG_POWERCNT^ := REG_POWERCNT^ and (not off);
  63. end;
  64. {$endif NDS_IMPLEMENTATION}
  65. {$ifdef ARM9}
  66. {$ifdef NDS_INTERFACE}
  67. {$ifdef DOXYGEN}
  68. type
  69. ARM9_power = cint;
  70. const
  71. POWER_LCD : ARM9_power = 0;
  72. POWER_2D_A : ARM9_power = 1;
  73. POWER_MATRIX : ARM9_power = 2;
  74. POWER_3D_CORE : ARM9_power = 3;
  75. POWER_2D_B : ARM9_power = 4;
  76. POWER_SWAP_LCDS : ARM9_power = 5;
  77. {$else DOXYGEN}
  78. const
  79. POWER_LCD = (1 shl 0);
  80. POWER_2D_A = (1 shl 1);
  81. POWER_MATRIX = (1 shl 2);
  82. POWER_3D_CORE = (1 shl 3);
  83. POWER_2D_B = (1 shl 9);
  84. POWER_SWAP_LCDS = (1 shl 15);
  85. POWER_ALL_2D = (POWER_LCD or POWER_2D_A or POWER_2D_B);
  86. POWER_ALL = (POWER_ALL_2D or POWER_3D_CORE or POWER_MATRIX);
  87. {$endif DOXYGEN}
  88. {$endif NDS_INTERFACE}
  89. {$ifdef NDS_IMPLEMENTATION}
  90. procedure lcdSwap(); inline;
  91. begin
  92. REG_POWERCNT^ := REG_POWERCNT^ xor POWER_SWAP_LCDS;
  93. end;
  94. procedure lcdMainOnTop(); inline;
  95. begin
  96. REG_POWERCNT^ := REG_POWERCNT^ or cint(POWER_SWAP_LCDS);
  97. end;
  98. procedure lcdMainOnBottom(); inline;
  99. begin
  100. REG_POWERCNT^ := REG_POWERCNT^ and (not cint(POWER_SWAP_LCDS));
  101. end;
  102. {$endif NDS_IMPLEMENTATION}
  103. {$endif ARM9}
  104. {$ifdef ARM7}
  105. {$ifdef NDS_INTERFACE}
  106. {$ifdef DOXYGEN}
  107. type
  108. ARM7_power = cint;
  109. const
  110. POWER_SOUND: ARM7_power = 0;
  111. POWER_UNKNOWN: ARM7_power = 1;
  112. {$else DOXYGEN}
  113. const
  114. POWER_SOUND = (1 shl 0);
  115. POWER_UNKNOWN = (1 shl 1);
  116. {$endif DOXYGEN}
  117. procedure readUserSettings(); cdecl; external;
  118. {$endif NDS_INTERFACE}
  119. {$endif ARM7}
  120. {$ifdef NDS_INTERFACE}
  121. type
  122. tPERSONAL_DATA = bitpacked record
  123. RESERVED0: array [0..1] of cuint8;
  124. theme: cuint8;
  125. birthMonth: cuint8;
  126. birthDay: cuint8;
  127. RESERVED1: array [0..0] of cuint8;
  128. name: array [0..9] of cint16;
  129. nameLen: cuint16;
  130. message: array [0..25] of cint16;
  131. messageLen: cuint16;
  132. alarmHour: cuint8;
  133. alarmMinute: cuint8;
  134. RESERVED2: array [0..3] of cuint8;
  135. calX1: cuint16;
  136. calY1: cuint16;
  137. calX1px: cuint8;
  138. calY1px: cuint8;
  139. calX2: cuint16;
  140. calY2: cuint16;
  141. calX2px: cuint8;
  142. calY2px: cuint8;
  143. _user_data: packed record
  144. language: 0..3;
  145. gbaScreen: 0..1;
  146. defaultBrightness: 0..2;
  147. autoMode: 0..1;
  148. RESERVED4: 0..1;
  149. settingsLost: 0..1;
  150. RESERVED2: 0..6;
  151. end;
  152. RESERVED3: cuint16;
  153. rtcOffset: cuint32;
  154. RESERVED4: cuint32;
  155. end;
  156. PERSONAL_DATA = tPERSONAL_DATA;
  157. PPERSONAL_DATA = ^tPERSONAL_DATA;
  158. const
  159. REG_KEYINPUT : pcuint16 = pointer($04000130);
  160. REG_KEYCNT : pcuint16 = pointer($04000132);
  161. PersonalData : PPERSONAL_DATA = pointer($27FFC80);
  162. type
  163. __argv = record
  164. argvMagic: cint; // argv magic number, set to 0x5f617267 ('_arg') if valid
  165. commandLine: pcchar; // base address of command line, set of null terminated strings
  166. length: cint; // total length of command line
  167. end;
  168. Targv = __argv;
  169. Pargv = ^Targv;
  170. const
  171. libnds_argv: Pargv = pointer($027FFF70);
  172. argvMagic = $5f617267;
  173. {$endif NDS_INTERFACE}
  174. {$ifdef NDS_INTERFACE}
  175. procedure SetYtrigger(Yvalue: cint); inline;
  176. procedure powerON(Aon: cint); inline;
  177. procedure powerSET(Aon: cint); inline;
  178. procedure powerOFF(off: cint); inline;
  179. {$ifdef ARM9}
  180. procedure lcdSwap(); inline;
  181. procedure lcdMainOnTop(); inline;
  182. procedure lcdMainOnBottom(); inline;
  183. {$endif ARM9}
  184. {$endif NDS_INTERFACE}