/packages/libgbafpc/src/gba/BoyScout.inc

https://github.com/slibre/freepascal · Pascal · 149 lines · 67 code · 24 blank · 58 comment · 0 complexity · 1cd44c7baae758f8c40c4d99c9d8084a MD5 · raw file

  1. (*
  2. $Id$
  3. ------------------------------------------------------------------------------
  4. Copyright (C) 2005
  5. Christer Andersson (c) 2001
  6. Willem Kokke
  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 GBA_INTERFACE}
  30. // DEFINES ////////
  31. const
  32. PATTERN_PARAMETER_EMPTY = 10000;
  33. SOUND_CHANNEL_COUNT = 4;
  34. SOUND1_PARAMETER_COUNT = 7;
  35. SOUND2_PARAMETER_COUNT = 5;
  36. SOUND3_PARAMETER_COUNT = 4;
  37. SOUND4_PARAMETER_COUNT = 7;
  38. // Play states
  39. PLAYSTATE_STOP = 1;
  40. PLAYSTATE_PLAY = 2;
  41. PLAYSTATE_LOOP = 4;
  42. // STRUCTS ////////
  43. type
  44. // Iterator for traversing compressed data
  45. SRLEIterator = record
  46. pData: pcuchar;
  47. iValue: cuchar;
  48. mask: cuchar;
  49. cValue: cuchar;
  50. nValue: cshort;
  51. iValuePos: cuchar;
  52. end;
  53. TSRLEIterator = SRLEIterator;
  54. PSRLEIterator = ^TSRLEIterator;
  55. // Sound 1 pattern
  56. SSound1Pattern = record
  57. nLength: cushort;
  58. apParams: array [0..SOUND1_PARAMETER_COUNT - 1] of pcuchar;
  59. end;
  60. TSSound1Pattern = SSound1Pattern;
  61. PSSound1Pattern = ^SSound1Pattern;
  62. // Sound 2 pattern
  63. SSound2Pattern = record
  64. nLength: cushort;
  65. apParams: array [0..SOUND2_PARAMETER_COUNT-1] of pcuchar;
  66. end;
  67. TSSound2Pattern = SSound2Pattern;
  68. PSSound2Pattern = ^SSound2Pattern;
  69. // Sound 3 pattern
  70. SSound3Pattern = record
  71. nLength: cushort;
  72. apParams: array [0..SOUND3_PARAMETER_COUNT-1] of pcuchar;
  73. end;
  74. TSSound3Pattern = SSound3Pattern;
  75. PSSound3Pattern = ^SSound3Pattern;
  76. // Sound 4 pattern
  77. SSound4Pattern = record
  78. nLength: cushort;
  79. apParams: array [0..SOUND4_PARAMETER_COUNT-1] of pcuchar;
  80. end;
  81. TSSound4Pattern = SSound4Pattern;
  82. PSSound4Pattern = ^SSound4Pattern;
  83. // PROTOTYPES /////
  84. procedure RLEISet(pData: pcuchar; pRLEIterator: PSRLEIterator); cdecl; external;
  85. procedure RLEINext(pRLEIterator: PSRLEIterator); cdecl; external;
  86. procedure BoyScoutInitialize(); cdecl; external;
  87. procedure BoyScoutOpenSong(const pSongData: pcuchar); cdecl; external;
  88. procedure BoyScoutPlaySong(nLoop: cint); cdecl; external;
  89. procedure BoyScoutStopSong(); cdecl; external;
  90. function BoyScoutGetNeededSongMemory(const pSongData: pcuchar): cushort; cdecl; external;
  91. procedure BoyScoutSetMemoryArea(nMemoryAddress: cuint); cdecl; external;
  92. function BoyScoutGetMemoryArea(): cuint; cdecl; external;
  93. function BoyScoutUpdateSong(): cint; cdecl; external;
  94. procedure DMA3Copy32(Src: cuint; Dst: cuint; Count: cuint); cdecl; external;
  95. // WK Set to 1 to use dma, or to 0 to use software copy
  96. // Software copy is the preffered option, it's faster and more stable
  97. const
  98. USE_DMA = 0;
  99. // WK some functions to manipulate the speed of the original song
  100. // You directly manipulate the time a beat takes
  101. // a beat takes x/60, where x is the value you give
  102. // increasing this value slows the song down, decreasing speeds it up
  103. // TODO? move the timing to a timer to get a better control through increades granularity
  104. function BoyScoutGetNormalSpeed(): cuchar; cdecl; external;
  105. function BoyScoutGetSpeed(): cuchar; cdecl; external;
  106. procedure BoyScoutIncSpeed(speed: cuchar); cdecl; external;
  107. procedure BoyScoutDecSpeed(speed: cuchar); cdecl; external;
  108. procedure BoyScoutSetSpeed(speed: cuchar); cdecl; external;
  109. // WK some functions to mute individual channels
  110. procedure BoyScoutMuteChannel1(mute: cint); cdecl; external;
  111. procedure BoyScoutMuteChannel2(mute: cint); cdecl; external;
  112. procedure BoyScoutMuteChannel3(mute: cint); cdecl; external;
  113. procedure BoyScoutMuteChannel4(mute: cint); cdecl; external;
  114. {$endif GBA_INTERFACE}