ipc.inc 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. (*
  2. $Id: ipc.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. type
  31. sTransferSoundData = record
  32. data: pointer;//pcint;
  33. len: cuint32;
  34. rate: cuint32;
  35. vol: cuint8;
  36. pan: cuint8;
  37. format: cuint8;
  38. PADDING: cuint8;
  39. end;
  40. TransferSoundData = sTransferSoundData;
  41. TTransferSoundData = TransferSoundData;
  42. PTransferSoundData = ^sTransferSoundData;
  43. sTransferSound = record
  44. data: array [0..15] of TransferSoundData;
  45. count: cuint8;
  46. PADDING: array [0..2] of cuint8;
  47. end;
  48. TransferSound = sTransferSound;
  49. TTransferSound = TransferSound;
  50. PTransferSound = ^sTransferSound;
  51. sTransferRegion = record
  52. touchX, touchY: cint16; // TSC X, Y
  53. touchXpx, touchYpx: cint16; // TSC X, Y pixel values
  54. touchZ1, touchZ2: cint16; // TSC x-panel measurements
  55. tdiode1, tdiode2: cuint16; // TSC temperature diodes
  56. temperature: cuint32; // TSC computed temperature
  57. buttons: cuint16; // X, Y, /PENIRQ buttons
  58. time: record
  59. case integer of
  60. 0: (curtime: array [0..7] of cuint8); // current time response from RTC
  61. 1: (rtc: record
  62. command: cuint8;
  63. year: cuint8; //add 2000 to get 4 digit year
  64. month: cuint8; //1 to 12
  65. day: cuint8; //1 to (days in month)
  66. incr: cuint8;
  67. hours: cuint8; //0 to 11 for AM, 52 to 63 for PM
  68. minutes: cuint8; //0 to 59
  69. seconds: cuint8; //0 to 59
  70. end;
  71. );
  72. end;
  73. unixTime: cint32;
  74. battery: cuint16; // battery life ?? hopefully. :)
  75. aux: cuint16; // i have no idea...
  76. // Don't rely on these below, will change or be removed in the future
  77. soundData: pTransferSound;
  78. mailAddr: cuint32;
  79. mailData: cuint32;
  80. mailRead: cuint8;
  81. mailBusy: cuint8;
  82. mailSize: cuint32;
  83. end;
  84. TransferRegion = sTransferRegion;
  85. TTransferRegion = TransferRegion;
  86. PTransferRegion = ^sTransferRegion;
  87. const
  88. //IPC : pTransferRegion = pointer($027FF000);
  89. IPC_PEN_DOWN = (1 shl 6);
  90. IPC_X = (1 shl 0);
  91. IPC_Y = (1 shl 1);
  92. IPC_LID_CLOSED = (1 shl 7);
  93. //---------------------------------------------------------------------------------
  94. // Synchronization register
  95. //---------------------------------------------------------------------------------
  96. REG_IPC_SYNC : pcuint16 = pointer($04000180);
  97. type
  98. IPC_SYNC_BITS = longint;
  99. const
  100. IPC_SYNC_IRQ_ENABLE: IPC_SYNC_BITS = (1 shl 14);
  101. IPC_SYNC_IRQ_REQUEST: IPC_SYNC_BITS = (1 shl 13);
  102. {$endif NDS_INTERFACE}
  103. {$ifdef NDS_IMPLEMENTATION}
  104. function getIPC(): pTransferRegion; inline;
  105. begin
  106. getIPC := pTransferRegion(pointer($027FF000));
  107. end;
  108. function IPC(): TransferRegion;
  109. begin
  110. IPC := getIPC()^;
  111. end;
  112. procedure IPC_SendSync(sync: cuint); inline;
  113. begin
  114. REG_IPC_SYNC^ := (REG_IPC_SYNC^ and $f0ff) or (((sync) and $0f) shl 8) or IPC_SYNC_IRQ_REQUEST;
  115. end;
  116. function IPC_GetSync(): cint; inline;
  117. begin
  118. IPC_GetSync := REG_IPC_SYNC^ and $0f;
  119. end;
  120. {$endif NDS_IMPLEMENTATION}
  121. {$ifdef NDS_INTERFACE}
  122. const
  123. REG_IPC_FIFO_TX : pcuint32 = pointer($04000188);
  124. REG_IPC_FIFO_RX : pcuint32 = pointer($04100000);
  125. REG_IPC_FIFO_CR : pcuint16 = pointer($04000184);
  126. type
  127. IPC_CONTROL_BITS = cint;
  128. const
  129. IPC_FIFO_SEND_EMPTY : IPC_CONTROL_BITS = (1 shl 0);
  130. IPC_FIFO_SEND_FULL : IPC_CONTROL_BITS = (1 shl 1);
  131. IPC_FIFO_SEND_IRQ : IPC_CONTROL_BITS = (1 shl 2);
  132. IPC_FIFO_SEND_CLEAR : IPC_CONTROL_BITS = (1 shl 3);
  133. IPC_FIFO_RECV_EMPTY : IPC_CONTROL_BITS = (1 shl 8);
  134. IPC_FIFO_RECV_FULL : IPC_CONTROL_BITS = (1 shl 9);
  135. IPC_FIFO_RECV_IRQ : IPC_CONTROL_BITS = (1 shl 10);
  136. IPC_FIFO_ERROR : IPC_CONTROL_BITS = (1 shl 14);
  137. IPC_FIFO_ENABLE : IPC_CONTROL_BITS = (1 shl 15);
  138. {$endif NDS_INTERFACE}
  139. {$ifdef NDS_INTERFACE}
  140. function getIPC(): pTransferRegion; inline;
  141. function IPC(): TransferRegion;
  142. procedure IPC_SendSync(sync: cuint); inline;
  143. function IPC_GetSync(): cint; inline;
  144. {$endif NDS_INTERFACE}