PageRenderTime 43ms CodeModel.GetById 19ms app.highlight 22ms RepoModel.GetById 0ms app.codeStats 0ms

/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
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
  1(* 
  2  $Id$
  3  ------------------------------------------------------------------------------
  4  	Copyright (C) 2005
  5      Christer Andersson (c) 2001
  6      Willem Kokke         
  7  	
  8  	This software is provided 'as-is', without any express or implied
  9  	warranty.  In no event will the authors be held liable for any
 10  	damages arising from the use of this software.
 11  	
 12  	Permission is granted to anyone to use this software for any
 13  	purpose, including commercial applications, and to alter it and
 14  	redistribute it freely, subject to the following restrictions:
 15  	
 16  	1.	The origin of this software must not be misrepresented; you
 17  		must not claim that you wrote the original software. If you use
 18  		this software in a product, an acknowledgment in the product
 19  		documentation would be appreciated but is not required.
 20  	
 21  	2.	Altered source versions must be plainly marked as such, and
 22  		must not be misrepresented as being the original software.
 23  	
 24  	3.	This notice may not be removed or altered from any source
 25  		distribution.
 26  ------------------------------------------------------------------------------
 27    
 28    
 29  Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
 30  (http://www.freepascal.org)
 31   
 32  Copyright (C) 2006  Francesco Lombardi
 33  Check http://sourceforge.net/projects/libndsfpc for updates
 34   
 35  ------------------------------------------------------------------------------
 36
 37  $Log$
 38
 39*)
 40
 41
 42{$ifdef GBA_INTERFACE}
 43// DEFINES ////////
 44const
 45  PATTERN_PARAMETER_EMPTY	= 10000;
 46
 47  SOUND_CHANNEL_COUNT	    = 4;
 48
 49  SOUND1_PARAMETER_COUNT	= 7;
 50  SOUND2_PARAMETER_COUNT	= 5;
 51  SOUND3_PARAMETER_COUNT	= 4;
 52  SOUND4_PARAMETER_COUNT	= 7;
 53
 54
 55// Play states
 56  PLAYSTATE_STOP	= 1;
 57  PLAYSTATE_PLAY	= 2;
 58  PLAYSTATE_LOOP	= 4;
 59
 60
 61// STRUCTS ////////
 62type
 63// Iterator for traversing compressed data
 64  SRLEIterator = record
 65    pData: pcuchar;
 66    iValue: cuchar;
 67    mask: cuchar;
 68    cValue: cuchar;
 69    nValue: cshort;
 70    iValuePos: cuchar;
 71  end;
 72  TSRLEIterator = SRLEIterator;
 73  PSRLEIterator = ^TSRLEIterator;
 74
 75// Sound 1 pattern
 76  SSound1Pattern = record
 77    nLength: cushort;
 78    apParams: array [0..SOUND1_PARAMETER_COUNT - 1] of pcuchar;
 79  end;
 80  TSSound1Pattern = SSound1Pattern;
 81  PSSound1Pattern = ^SSound1Pattern;
 82
 83// Sound 2 pattern
 84  SSound2Pattern = record
 85    nLength: cushort;
 86    apParams: array [0..SOUND2_PARAMETER_COUNT-1] of pcuchar;
 87  end;
 88  TSSound2Pattern = SSound2Pattern;
 89  PSSound2Pattern = ^SSound2Pattern;
 90
 91// Sound 3 pattern
 92  SSound3Pattern = record
 93    nLength: cushort;
 94    apParams: array [0..SOUND3_PARAMETER_COUNT-1] of pcuchar;
 95  end;
 96  TSSound3Pattern = SSound3Pattern;
 97  PSSound3Pattern = ^SSound3Pattern;
 98
 99// Sound 4 pattern
100  SSound4Pattern = record
101    nLength: cushort;
102    apParams: array [0..SOUND4_PARAMETER_COUNT-1] of pcuchar;
103  end;
104  TSSound4Pattern = SSound4Pattern;
105  PSSound4Pattern = ^SSound4Pattern;
106
107// PROTOTYPES /////
108
109procedure RLEISet(pData: pcuchar; pRLEIterator: PSRLEIterator); cdecl; external;
110procedure RLEINext(pRLEIterator: PSRLEIterator); cdecl; external;
111
112procedure BoyScoutInitialize(); cdecl; external;
113procedure BoyScoutOpenSong(const pSongData: pcuchar); cdecl; external;
114procedure BoyScoutPlaySong(nLoop: cint); cdecl; external;
115procedure BoyScoutStopSong(); cdecl; external;
116function BoyScoutGetNeededSongMemory(const pSongData: pcuchar): cushort; cdecl; external;
117procedure BoyScoutSetMemoryArea(nMemoryAddress: cuint); cdecl; external;
118function BoyScoutGetMemoryArea(): cuint; cdecl; external;
119function BoyScoutUpdateSong(): cint; cdecl; external;
120
121procedure DMA3Copy32(Src: cuint; Dst: cuint; Count: cuint); cdecl; external;
122
123// WK Set to 1 to use dma, or to 0 to use software copy
124// Software copy is the preffered option, it's faster and more stable
125const
126  USE_DMA = 0;
127
128// WK  some functions to manipulate the speed of the original song
129// You directly manipulate the time a beat takes
130// a beat takes x/60, where x is the value you give
131// increasing this value slows the song down, decreasing speeds it up
132
133// TODO?  move the timing to a timer to get a better control through increades granularity
134
135function BoyScoutGetNormalSpeed(): cuchar; cdecl; external;
136function BoyScoutGetSpeed(): cuchar; cdecl; external;
137
138procedure BoyScoutIncSpeed(speed: cuchar); cdecl; external;
139procedure BoyScoutDecSpeed(speed: cuchar); cdecl; external;
140procedure BoyScoutSetSpeed(speed: cuchar); cdecl; external;
141
142
143// WK  some functions to mute individual channels
144procedure BoyScoutMuteChannel1(mute: cint); cdecl; external;
145procedure BoyScoutMuteChannel2(mute: cint); cdecl; external;
146procedure BoyScoutMuteChannel3(mute: cint); cdecl; external;
147procedure BoyScoutMuteChannel4(mute: cint); cdecl; external;
148{$endif GBA_INTERFACE}
149