summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2011-06-05 13:05:09 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2011-06-05 13:05:09 +0000
commit9f65f2b6adc24964ac3fe03a75616fab96769bb7 (patch)
tree83ca7c0bf4f66f43b3a374a8d207fd63878ad4d6
parent82f4c60db4f16642c1ee9f461d7eb060c11a49d8 (diff)
downloadrockbox-9f65f2b6adc24964ac3fe03a75616fab96769bb7.tar.gz
rockbox-9f65f2b6adc24964ac3fe03a75616fab96769bb7.zip
Accept FS#12143 (NSF codec clean up): Declare local stuff static, comment unused variables and functions.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29972 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/nsf.c489
1 files changed, 250 insertions, 239 deletions
diff --git a/apps/codecs/nsf.c b/apps/codecs/nsf.c
index 6f780342fd..d626d528bf 100644
--- a/apps/codecs/nsf.c
+++ b/apps/codecs/nsf.c
@@ -69,7 +69,7 @@ static int16_t samples[WAV_CHUNK_SIZE] IBSS_ATTR MEM_ALIGN_ATTR;
69 69
70#ifdef NSF_PROFILE 70#ifdef NSF_PROFILE
71 71
72#define CREATE_TIMER(name) uint32_t nsf_timer_##name##_start,\ 72#define CREATE_TIMER(name) static uint32_t nsf_timer_##name##_start,\
73 nsf_timer_##name##_total 73 nsf_timer_##name##_total
74#define ENTER_TIMER(name) nsf_timer_##name##_start=USEC_TIMER 74#define ENTER_TIMER(name) nsf_timer_##name##_start=USEC_TIMER
75#define EXIT_TIMER(name) nsf_timer_##name##_total+=\ 75#define EXIT_TIMER(name) nsf_timer_##name##_total+=\
@@ -187,7 +187,7 @@ union QUAD
187 187
188/****************** tables */ 188/****************** tables */
189static const int32_t ModulationTable[8] ICONST_ATTR = {0,1,2,4,0,-4,-2,-1}; 189static const int32_t ModulationTable[8] ICONST_ATTR = {0,1,2,4,0,-4,-2,-1};
190const uint16_t DMC_FREQ_TABLE[2][0x10] ICONST_ATTR_NSF_LARGE_IRAM = { 190static const uint16_t DMC_FREQ_TABLE[2][0x10] ICONST_ATTR_NSF_LARGE_IRAM = {
191 /* NTSC */ 191 /* NTSC */
192 {0x1AC,0x17C,0x154,0x140,0x11E,0x0FE,0x0E2,0x0D6,0x0BE,0x0A0,0x08E,0x080, 192 {0x1AC,0x17C,0x154,0x140,0x11E,0x0FE,0x0E2,0x0D6,0x0BE,0x0A0,0x08E,0x080,
193 0x06A,0x054,0x048,0x036}, 193 0x06A,0x054,0x048,0x036},
@@ -196,15 +196,17 @@ const uint16_t DMC_FREQ_TABLE[2][0x10] ICONST_ATTR_NSF_LARGE_IRAM = {
196 0x062,0x04E,0x042,0x032} 196 0x062,0x04E,0x042,0x032}
197}; 197};
198 198
199const uint8_t DUTY_CYCLE_TABLE[4] ICONST_ATTR_NSF_LARGE_IRAM = {2,4,8,12}; 199static const uint8_t DUTY_CYCLE_TABLE[4] ICONST_ATTR_NSF_LARGE_IRAM = {
200 2,4,8,12
201};
200 202
201const uint8_t LENGTH_COUNTER_TABLE[0x20] ICONST_ATTR_NSF_LARGE_IRAM = { 203static const uint8_t LENGTH_COUNTER_TABLE[0x20] ICONST_ATTR_NSF_LARGE_IRAM = {
202 0x0A,0xFE,0x14,0x02,0x28,0x04,0x50,0x06,0xA0,0x08,0x3C,0x0A,0x0E,0x0C,0x1A, 204 0x0A,0xFE,0x14,0x02,0x28,0x04,0x50,0x06,0xA0,0x08,0x3C,0x0A,0x0E,0x0C,0x1A,
203 0x0E,0x0C,0x10,0x18,0x12,0x30,0x14,0x60,0x16,0xC0,0x18,0x48,0x1A,0x10,0x1C, 205 0x0E,0x0C,0x10,0x18,0x12,0x30,0x14,0x60,0x16,0xC0,0x18,0x48,0x1A,0x10,0x1C,
204 0x20,0x1E 206 0x20,0x1E
205}; 207};
206 208
207const uint16_t NOISE_FREQ_TABLE[0x10] ICONST_ATTR_NSF_LARGE_IRAM = { 209static const uint16_t NOISE_FREQ_TABLE[0x10] ICONST_ATTR_NSF_LARGE_IRAM = {
208 0x004,0x008,0x010,0x020,0x040,0x060,0x080,0x0A0,0x0CA,0x0FE,0x17C,0x1FC, 210 0x004,0x008,0x010,0x020,0x040,0x060,0x080,0x0A0,0x0CA,0x0FE,0x17C,0x1FC,
209 0x2FA,0x3F8,0x7F2,0xFE4 211 0x2FA,0x3F8,0x7F2,0xFE4
210}; 212};
@@ -245,62 +247,64 @@ struct NSFE_INFOCHUNK
245 uint8_t nStartingTrack; 247 uint8_t nStartingTrack;
246}; 248};
247 249
248int32_t LoadFile(uint8_t *,size_t); 250static int32_t LoadFile(uint8_t *,size_t);
249 251
250int32_t LoadFile_NESM(uint8_t *,size_t); 252static int32_t LoadFile_NESM(uint8_t *,size_t);
251int32_t LoadFile_NSFE(uint8_t *,size_t); 253static int32_t LoadFile_NSFE(uint8_t *,size_t);
252 254
253/* NSF file info */ 255/* NSF file info */
254 256
255/* basic NSF info */ 257/* basic NSF info */
256int32_t bIsExtended=0; /* 0 = NSF, 1 = NSFE */ 258static int32_t bIsExtended=0; /* 0 = NSF, 1 = NSFE */
257uint8_t nIsPal=0; /* 0 = NTSC, 1 = PAL, 259static uint8_t nIsPal=0; /* 0 = NTSC, 1 = PAL, 2,3 = mixed
258 2,3 = mixed NTSC/PAL (interpretted as NTSC) */ 260 NTSC/PAL (interpretted as NTSC) */
259int32_t nfileLoadAddress=0; /* The address to which the NSF code is 261static int32_t nfileLoadAddress=0; /* The address to which the NSF code is
260 loaded */ 262 loaded */
261int32_t nfileInitAddress=0; /* The address of the Init routine 263static int32_t nfileInitAddress=0; /* The address of the Init routine
262 (called at track change) */ 264 (called at track change) */
263int32_t nfilePlayAddress=0; /* The address of the Play routine 265static int32_t nfilePlayAddress=0; /* The address of the Play routine
264 (called several times a second) */ 266 (called several times a second) */
265uint8_t nChipExtensions=0; /* Bitwise representation of the external chips 267static uint8_t nChipExtensions=0; /* Bitwise representation of the
266 used by this NSF. */ 268 external chips used by this NSF. */
267 269
268/* old NESM speed stuff (blarg) */ 270/* old NESM speed stuff (blarg) */
269int32_t nNTSC_PlaySpeed=0; 271static int32_t nNTSC_PlaySpeed=0;
270int32_t nPAL_PlaySpeed=0; 272static int32_t nPAL_PlaySpeed=0;
271 273
272/* track info */ 274/* track info */
273/* The number of tracks in the NSF (1 = 1 track, 5 = 5 tracks, etc) */ 275/* The number of tracks in the NSF (1 = 1 track, 5 = 5 tracks, etc) */
274int32_t nTrackCount=0; 276static int32_t nTrackCount=0;
275/* The initial track (ZERO BASED: 0 = 1st track, 4 = 5th track, etc) */ 277/* The initial track (ZERO BASED: 0 = 1st track, 4 = 5th track, etc) */
276int32_t nInitialTrack=0; 278static int32_t nInitialTrack=0;
277 279
278/* nsf data */ 280/* nsf data */
279uint8_t* pDataBuffer=0; /* the buffer containing NSF code. */ 281static uint8_t* pDataBuffer=0; /* the buffer containing NSF code. */
280int32_t nDataBufferSize=0; /* the size of the above buffer. */ 282static int32_t nDataBufferSize=0; /* the size of the above buffer. */
281 283
282/* playlist */ 284/* playlist */
283uint8_t nPlaylist[256]; /* Each entry is the zero based index of the 285static uint8_t nPlaylist[256]; /* Each entry is the zero based index of
284 song to play */ 286 the song to play */
285int32_t nPlaylistSize=0; /* the number of tracks in the playlist */ 287static int32_t nPlaylistSize=0; /* number of tracks in the playlist */
286 288
287/* track time / fade */ 289/* track time / fade */
288int32_t nTrackTime[256]; /* track times -1 if no track times specified */ 290static int32_t nTrackTime[256]; /* track times -1 if no track times
289int32_t nTrackFade[256]; /* track fade times -1 if none are specified */ 291 specified */
292static int32_t nTrackFade[256]; /* track fade times -1 if none are
293 specified */
290 294
291/* string info */ 295/* string info */
292uint8_t szGameTitle[0x101]; 296static uint8_t szGameTitle[0x101];
293uint8_t szArtist[0x101]; 297static uint8_t szArtist[0x101];
294uint8_t szCopyright[0x101]; 298static uint8_t szCopyright[0x101];
295uint8_t szRipper[0x101]; 299static uint8_t szRipper[0x101];
296 300
297/* bankswitching info */ 301/* bankswitching info */
298uint8_t nBankswitch[8]={0}; /* The initial bankswitching registers needed 302static uint8_t nBankswitch[8]={0}; /* The initial bankswitching registers
299 * for some NSFs. If the NSF does not use 303 needed for some NSFs. If the NSF does
300 * bankswitching, these values will all be zero 304 not use bankswitching, these values
301 */ 305 will all be zero */
302 306
303int32_t LoadFile(uint8_t * inbuffer, size_t size) 307static int32_t LoadFile(uint8_t * inbuffer, size_t size)
304{ 308{
305 if(!inbuffer) return -1; 309 if(!inbuffer) return -1;
306 310
@@ -328,7 +332,7 @@ int32_t LoadFile(uint8_t * inbuffer, size_t size)
328 return ret; 332 return ret;
329} 333}
330 334
331int32_t LoadFile_NESM(uint8_t* inbuffer, size_t size) 335static int32_t LoadFile_NESM(uint8_t* inbuffer, size_t size)
332{ 336{
333 uint8_t ignoreversion=1; 337 uint8_t ignoreversion=1;
334 uint8_t needdata=1; 338 uint8_t needdata=1;
@@ -379,7 +383,7 @@ int32_t LoadFile_NESM(uint8_t* inbuffer, size_t size)
379 return 0; 383 return 0;
380} 384}
381 385
382int32_t LoadFile_NSFE(uint8_t* inbuffer, size_t size) 386static int32_t LoadFile_NSFE(uint8_t* inbuffer, size_t size)
383{ 387{
384 /* the vars we'll be using */ 388 /* the vars we'll be using */
385 uint32_t nChunkType; 389 uint32_t nChunkType;
@@ -604,7 +608,7 @@ struct FDSWave
604 int32_t nPopCount; 608 int32_t nPopCount;
605 609
606}; 610};
607int16_t FDS_nOutputTable_L[4][0x21][0x40] IBSS_ATTR_NSF_LARGE_IRAM MEM_ALIGN_ATTR; 611static int16_t FDS_nOutputTable_L[4][0x21][0x40] IBSS_ATTR_NSF_LARGE_IRAM MEM_ALIGN_ATTR;
608 612
609struct FME07Wave 613struct FME07Wave
610{ 614{
@@ -625,7 +629,7 @@ struct FME07Wave
625 int32_t nMixL; 629 int32_t nMixL;
626}; 630};
627 631
628int16_t FME07_nOutputTable_L[0x10] IDATA_ATTR MEM_ALIGN_ATTR; 632static int16_t FME07_nOutputTable_L[0x10] IDATA_ATTR MEM_ALIGN_ATTR;
629 633
630struct N106Wave 634struct N106Wave
631{ 635{
@@ -665,7 +669,7 @@ struct N106Wave
665 int32_t nMixL[8]; 669 int32_t nMixL[8];
666}; 670};
667 671
668int16_t N106_nOutputTable_L[0x10][0x10] IBSS_ATTR_NSF_LARGE_IRAM MEM_ALIGN_ATTR; 672static int16_t N106_nOutputTable_L[0x10][0x10] IBSS_ATTR_NSF_LARGE_IRAM MEM_ALIGN_ATTR;
669 673
670struct VRC6PulseWave 674struct VRC6PulseWave
671{ 675{
@@ -690,7 +694,7 @@ struct VRC6PulseWave
690 694
691}; 695};
692 696
693int16_t VRC6Pulse_nOutputTable_L[0x10] IDATA_ATTR MEM_ALIGN_ATTR; 697static int16_t VRC6Pulse_nOutputTable_L[0x10] IDATA_ATTR MEM_ALIGN_ATTR;
694 698
695struct VRC6SawWave 699struct VRC6SawWave
696{ 700{
@@ -712,7 +716,7 @@ struct VRC6SawWave
712 716
713}; 717};
714 718
715int16_t VRC6Saw_nOutputTable_L[0x20] IDATA_ATTR MEM_ALIGN_ATTR; 719static int16_t VRC6Saw_nOutputTable_L[0x20] IDATA_ATTR MEM_ALIGN_ATTR;
716 720
717struct Wave_Squares 721struct Wave_Squares
718{ 722{
@@ -750,7 +754,7 @@ struct Wave_Squares
750 int32_t nMixL; 754 int32_t nMixL;
751}; 755};
752 756
753int16_t Squares_nOutputTable_L[0x10][0x10] IDATA_ATTR MEM_ALIGN_ATTR; 757static int16_t Squares_nOutputTable_L[0x10][0x10] IDATA_ATTR MEM_ALIGN_ATTR;
754 758
755struct Wave_TND 759struct Wave_TND
756{ 760{
@@ -841,13 +845,13 @@ struct Wave_TND
841}; 845};
842 846
843/* channels */ 847/* channels */
844struct Wave_Squares mWave_Squares IDATA_ATTR; /* Square channels 1 and 2 */ 848static struct Wave_Squares mWave_Squares IDATA_ATTR; /* Square channels 1 and 2 */
845struct Wave_TND mWave_TND IDATA_ATTR; /* Triangle/Noise/DMC channels */ 849static struct Wave_TND mWave_TND IDATA_ATTR; /* Triangle/Noise/DMC channels */
846struct VRC6PulseWave mWave_VRC6Pulse[2] IDATA_ATTR; 850static struct VRC6PulseWave mWave_VRC6Pulse[2] IDATA_ATTR;
847struct VRC6SawWave mWave_VRC6Saw IDATA_ATTR; 851static struct VRC6SawWave mWave_VRC6Saw IDATA_ATTR;
848struct N106Wave mWave_N106 IDATA_ATTR; 852static struct N106Wave mWave_N106 IDATA_ATTR;
849struct FDSWave mWave_FDS IDATA_ATTR; 853static struct FDSWave mWave_FDS IDATA_ATTR;
850struct FME07Wave mWave_FME07[3] IDATA_ATTR; /* FME-07's 3 pulse channels */ 854static struct FME07Wave mWave_FME07[3] IDATA_ATTR; /* FME-07's 3 pulse channels */
851 855
852 856
853/****************** MMC5 ******************/ 857/****************** MMC5 ******************/
@@ -857,11 +861,11 @@ struct FME07Wave mWave_FME07[3] IDATA_ATTR; /* FME-07's 3 pulse channels */
857/****************** N106 (Disch loves this chip) ******************/ 861/****************** N106 (Disch loves this chip) ******************/
858 862
859#ifdef ICODE_INSTEAD_OF_INLINE 863#ifdef ICODE_INSTEAD_OF_INLINE
860void Wave_N106_DoTicks(const int32_t ticks) ICODE_ATTR; 864static void Wave_N106_DoTicks(const int32_t ticks) ICODE_ATTR;
861void Wave_N106_DoTicks(const int32_t ticks) 865static void Wave_N106_DoTicks(const int32_t ticks)
862#else 866#else
863inline void Wave_N106_DoTicks(const int32_t ticks); 867static inline void Wave_N106_DoTicks(const int32_t ticks);
864inline void Wave_N106_DoTicks(const int32_t ticks) 868static inline void Wave_N106_DoTicks(const int32_t ticks)
865#endif 869#endif
866{ 870{
867 register int32_t i; 871 register int32_t i;
@@ -927,11 +931,11 @@ inline void Wave_N106_DoTicks(const int32_t ticks)
927/****************** VRC6 ******************/ 931/****************** VRC6 ******************/
928 932
929#ifdef ICODE_INSTEAD_OF_INLINE 933#ifdef ICODE_INSTEAD_OF_INLINE
930void Wave_VRC6_DoTicks(const int32_t ticks) ICODE_ATTR; 934static void Wave_VRC6_DoTicks(const int32_t ticks) ICODE_ATTR;
931void Wave_VRC6_DoTicks(const int32_t ticks) 935static void Wave_VRC6_DoTicks(const int32_t ticks)
932#else 936#else
933inline void Wave_VRC6_DoTicks(const int32_t ticks); 937static inline void Wave_VRC6_DoTicks(const int32_t ticks);
934inline void Wave_VRC6_DoTicks(const int32_t ticks) 938static inline void Wave_VRC6_DoTicks(const int32_t ticks)
935#endif 939#endif
936{ 940{
937 register int32_t i; 941 register int32_t i;
@@ -989,11 +993,11 @@ inline void Wave_VRC6_DoTicks(const int32_t ticks)
989 993
990/* decay */ 994/* decay */
991#ifdef ICODE_INSTEAD_OF_INLINE 995#ifdef ICODE_INSTEAD_OF_INLINE
992void Wave_Squares_ClockMajor(void) ICODE_ATTR; 996static void Wave_Squares_ClockMajor(void) ICODE_ATTR;
993void Wave_Squares_ClockMajor() 997static void Wave_Squares_ClockMajor()
994#else 998#else
995inline void Wave_Squares_ClockMajor(void); 999static inline void Wave_Squares_ClockMajor(void);
996inline void Wave_Squares_ClockMajor() 1000static inline void Wave_Squares_ClockMajor()
997#endif 1001#endif
998{ 1002{
999 if(mWave_Squares.nDecayCount[0]) 1003 if(mWave_Squares.nDecayCount[0])
@@ -1034,11 +1038,11 @@ inline void Wave_Squares_ClockMajor()
1034 1038
1035 1039
1036#ifdef ICODE_INSTEAD_OF_INLINE 1040#ifdef ICODE_INSTEAD_OF_INLINE
1037void Wave_Squares_CheckSweepForcedSilence(const int32_t i) ICODE_ATTR; 1041static void Wave_Squares_CheckSweepForcedSilence(const int32_t i) ICODE_ATTR;
1038void Wave_Squares_CheckSweepForcedSilence(const int32_t i) 1042static void Wave_Squares_CheckSweepForcedSilence(const int32_t i)
1039#else 1043#else
1040inline void Wave_Squares_CheckSweepForcedSilence(const int32_t i); 1044static inline void Wave_Squares_CheckSweepForcedSilence(const int32_t i);
1041inline void Wave_Squares_CheckSweepForcedSilence(const int32_t i) 1045static inline void Wave_Squares_CheckSweepForcedSilence(const int32_t i)
1042#endif 1046#endif
1043{ 1047{
1044 if(mWave_Squares.nFreqTimer[i].W < 8) { 1048 if(mWave_Squares.nFreqTimer[i].W < 8) {
@@ -1054,11 +1058,11 @@ inline void Wave_Squares_CheckSweepForcedSilence(const int32_t i)
1054 1058
1055/* sweep / length */ 1059/* sweep / length */
1056#ifdef ICODE_INSTEAD_OF_INLINE 1060#ifdef ICODE_INSTEAD_OF_INLINE
1057void Wave_Squares_ClockMinor(void) ICODE_ATTR; 1061static void Wave_Squares_ClockMinor(void) ICODE_ATTR;
1058void Wave_Squares_ClockMinor() 1062static void Wave_Squares_ClockMinor()
1059#else 1063#else
1060inline void Wave_Squares_ClockMinor(void); 1064static inline void Wave_Squares_ClockMinor(void);
1061inline void Wave_Squares_ClockMinor() 1065static inline void Wave_Squares_ClockMinor()
1062#endif 1066#endif
1063{ 1067{
1064/* unrolled a little loop 1068/* unrolled a little loop
@@ -1114,11 +1118,11 @@ other_square:
1114/* decay (noise), linear (tri) */ 1118/* decay (noise), linear (tri) */
1115 1119
1116#ifdef ICODE_INSTEAD_OF_INLINE 1120#ifdef ICODE_INSTEAD_OF_INLINE
1117void Wave_TND_ClockMajor(void) ICODE_ATTR; 1121static void Wave_TND_ClockMajor(void) ICODE_ATTR;
1118void Wave_TND_ClockMajor() 1122static void Wave_TND_ClockMajor()
1119#else 1123#else
1120inline void Wave_TND_ClockMajor(void); 1124static inline void Wave_TND_ClockMajor(void);
1121inline void Wave_TND_ClockMajor() 1125static inline void Wave_TND_ClockMajor()
1122#endif 1126#endif
1123{ 1127{
1124 /* noise's decay */ 1128 /* noise's decay */
@@ -1152,11 +1156,11 @@ inline void Wave_TND_ClockMajor()
1152/* length */ 1156/* length */
1153 1157
1154#ifdef ICODE_INSTEAD_OF_INLINE 1158#ifdef ICODE_INSTEAD_OF_INLINE
1155void Wave_TND_ClockMinor(void) ICODE_ATTR; 1159static void Wave_TND_ClockMinor(void) ICODE_ATTR;
1156void Wave_TND_ClockMinor() 1160static void Wave_TND_ClockMinor()
1157#else 1161#else
1158inline void Wave_TND_ClockMinor(void); 1162static inline void Wave_TND_ClockMinor(void);
1159inline void Wave_TND_ClockMinor() 1163static inline void Wave_TND_ClockMinor()
1160#endif 1164#endif
1161{ 1165{
1162 if(mWave_TND.bNoiseLengthEnabled && mWave_TND.nNoiseLengthCount) 1166 if(mWave_TND.bNoiseLengthEnabled && mWave_TND.nNoiseLengthCount)
@@ -1176,26 +1180,26 @@ inline void Wave_TND_ClockMinor()
1176 * Memory 1180 * Memory
1177 */ 1181 */
1178/* RAM: 0x0000 - 0x07FF */ 1182/* RAM: 0x0000 - 0x07FF */
1179uint8_t pRAM[0x800] IBSS_ATTR_NSF_LARGE_IRAM MEM_ALIGN_ATTR; 1183static uint8_t pRAM[0x800] IBSS_ATTR_NSF_LARGE_IRAM MEM_ALIGN_ATTR;
1180/* SRAM: 0x6000 - 0x7FFF (non-FDS only) */ 1184/* SRAM: 0x6000 - 0x7FFF (non-FDS only) */
1181uint8_t pSRAM[0x2000] IBSS_ATTR_NSF_LARGE_IRAM MEM_ALIGN_ATTR; 1185static uint8_t pSRAM[0x2000] IBSS_ATTR_NSF_LARGE_IRAM MEM_ALIGN_ATTR;
1182/* ExRAM: 0x5C00 - 0x5FF5 (MMC5 only) 1186/* ExRAM: 0x5C00 - 0x5FF5 (MMC5 only)
1183 * Also holds NSF player code (at 0x5000 - 0x500F) */ 1187 * Also holds NSF player code (at 0x5000 - 0x500F) */
1184uint8_t pExRAM[0x1000] IBSS_ATTR_NSF_LARGE_IRAM MEM_ALIGN_ATTR; 1188static uint8_t pExRAM[0x1000] IBSS_ATTR_NSF_LARGE_IRAM MEM_ALIGN_ATTR;
1185/* Full ROM buffer */ 1189/* Full ROM buffer */
1186uint8_t* pROM_Full IDATA_ATTR; 1190static uint8_t* pROM_Full IDATA_ATTR;
1187 1191
1188uint16_t main_nOutputTable_L[0x8000] MEM_ALIGN_ATTR; 1192static uint16_t main_nOutputTable_L[0x8000] MEM_ALIGN_ATTR;
1189 1193
1190uint8_t* pROM[10] IDATA_ATTR;/* ROM banks (point to areas in pROM_Full) */ 1194static uint8_t* pROM[10] IDATA_ATTR;/* ROM banks (point to areas in pROM_Full) */
1191 /* 0x8000 - 0xFFFF */ 1195 /* 0x8000 - 0xFFFF */
1192 /* also includes 0x6000 - 0x7FFF (FDS only) */ 1196 /* also includes 0x6000 - 0x7FFF (FDS only) */
1193uint8_t* pStack; /* the stack (points to areas in pRAM) */ 1197static uint8_t* pStack; /* the stack (points to areas in pRAM) */
1194 /* 0x0100 - 0x01FF */ 1198 /* 0x0100 - 0x01FF */
1195 1199
1196int32_t nROMSize; /* size of this ROM file in bytes */ 1200static int32_t nROMSize; /* size of this ROM file in bytes */
1197int32_t nROMBankCount; /* max number of 4k banks */ 1201static int32_t nROMBankCount; /* max number of 4k banks */
1198int32_t nROMMaxSize; /* size of allocated pROM_Full buffer */ 1202static int32_t nROMMaxSize; /* size of allocated pROM_Full buffer */
1199 1203
1200/* 1204/*
1201 * Memory Proc Pointers 1205 * Memory Proc Pointers
@@ -1203,128 +1207,128 @@ int32_t nROMMaxSize; /* size of allocated pROM_Full buffer */
1203 1207
1204typedef uint8_t ( *ReadProc)(uint16_t); 1208typedef uint8_t ( *ReadProc)(uint16_t);
1205typedef void ( *WriteProc)(uint16_t,uint8_t); 1209typedef void ( *WriteProc)(uint16_t,uint8_t);
1206ReadProc ReadMemory[0x10] IDATA_ATTR MEM_ALIGN_ATTR; 1210static ReadProc ReadMemory[0x10] IDATA_ATTR MEM_ALIGN_ATTR;
1207WriteProc WriteMemory[0x10] IDATA_ATTR MEM_ALIGN_ATTR; 1211static WriteProc WriteMemory[0x10] IDATA_ATTR MEM_ALIGN_ATTR;
1208 1212
1209/* 1213/*
1210 * 6502 Registers / Mode 1214 * 6502 Registers / Mode
1211 */ 1215 */
1212 1216
1213uint8_t regA IDATA_ATTR; /* Accumulator */ 1217static uint8_t regA IDATA_ATTR; /* Accumulator */
1214uint8_t regX IDATA_ATTR; /* X-Index */ 1218static uint8_t regX IDATA_ATTR; /* X-Index */
1215uint8_t regY IDATA_ATTR; /* Y-Index */ 1219static uint8_t regY IDATA_ATTR; /* Y-Index */
1216uint8_t regP IDATA_ATTR; /* Processor Status */ 1220static uint8_t regP IDATA_ATTR; /* Processor Status */
1217uint8_t regSP IDATA_ATTR; /* Stack Pointer */ 1221static uint8_t regSP IDATA_ATTR; /* Stack Pointer */
1218uint16_t regPC IDATA_ATTR; /* Program Counter */ 1222static uint16_t regPC IDATA_ATTR; /* Program Counter */
1219 1223
1220uint8_t bPALMode IDATA_ATTR;/* 1 if in PAL emulation mode, 0 if in NTSC */ 1224static uint8_t bPALMode IDATA_ATTR;/* 1 if in PAL emulation mode, 0 if in NTSC */
1221uint8_t bCPUJammed IDATA_ATTR; /* 0 = not jammed. 1 = really jammed. 1225static uint8_t bCPUJammed IDATA_ATTR; /* 0 = not jammed. 1 = really
1222 * 2 = 'fake' jammed */ 1226 jammed. 2 = 'fake' jammed */
1223 /* fake jam caused by the NSF code to signal 1227 /* fake jam caused by the NSF code to signal
1224 * the end of the play/init routine */ 1228 * the end of the play/init routine */
1225 1229
1226/* Multiplication Register, for MMC5 chip only (5205+5206) */ 1230/* Multiplication Register, for MMC5 chip only (5205+5206) */
1227uint8_t nMultIn_Low; 1231static uint8_t nMultIn_Low;
1228uint8_t nMultIn_High; 1232static uint8_t nMultIn_High;
1229 1233
1230/* 1234/*
1231 * NSF Preparation Information 1235 * NSF Preparation Information
1232 */ 1236 */
1233 1237
1234uint8_t nBankswitchInitValues[10]; /* banks to swap to on tune init */ 1238static uint8_t nBankswitchInitValues[10]; /* banks to swap to on tune init */
1235uint16_t nPlayAddress; /* Play routine address */ 1239static uint16_t nPlayAddress; /* Play routine address */
1236uint16_t nInitAddress; /* Init routine address */ 1240static uint16_t nInitAddress; /* Init routine address */
1237 1241
1238uint8_t nExternalSound; /* external sound chips */ 1242static uint8_t nExternalSound; /* external sound chips */
1239uint8_t nCurTrack; 1243static uint8_t nCurTrack;
1240 1244
1241float fNSFPlaybackSpeed; 1245static float fNSFPlaybackSpeed;
1242 1246
1243/* 1247/*
1244 * pAPU 1248 * pAPU
1245 */ 1249 */
1246 1250
1247uint8_t nFrameCounter; /* Frame Sequence Counter */ 1251static uint8_t nFrameCounter; /* Frame Sequence Counter */
1248uint8_t nFrameCounterMax; /* Frame Sequence Counter Size 1252static uint8_t nFrameCounterMax; /* Frame Sequence Counter Size
1249 (3 or 4 depending on $4017.7) */ 1253 (3 or 4 depending on $4017.7) */
1250uint8_t bFrameIRQEnabled; /* TRUE if frame IRQs are enabled */ 1254static uint8_t bFrameIRQEnabled; /* TRUE if frame IRQs are enabled */
1251uint8_t bFrameIRQPending; /* TRUE if the frame sequencer is holding down 1255static uint8_t bFrameIRQPending; /* TRUE if the frame sequencer is
1252 an IRQ */ 1256 holding down an IRQ */
1253 1257
1254uint8_t nFME07_Address; 1258static uint8_t nFME07_Address;
1255 1259
1256/* 1260/*
1257 * Timing and Counters 1261 * Timing and Counters
1258 */ 1262 */
1259/* fixed point -15.16 */ 1263/* fixed point -15.16 */
1260 1264
1261int32_t nTicksUntilNextFrame; 1265static int32_t nTicksUntilNextFrame;
1262int32_t nTicksPerPlay; 1266static int32_t nTicksPerPlay;
1263int32_t nTicksUntilNextPlay; 1267static int32_t nTicksUntilNextPlay;
1264int32_t nTicksPerSample; 1268static int32_t nTicksPerSample;
1265int32_t nTicksUntilNextSample; 1269static int32_t nTicksUntilNextSample;
1266 1270
1267uint32_t nCPUCycle IDATA_ATTR; 1271static uint32_t nCPUCycle IDATA_ATTR;
1268uint32_t nAPUCycle IDATA_ATTR; 1272static uint32_t nAPUCycle IDATA_ATTR;
1269 1273
1270 1274
1271uint32_t nTotalPlays; /* number of times the play subroutine has been called 1275static uint32_t nTotalPlays; /* number of times the play subroutine has been
1272 (for tracking output time) */ 1276 called (for tracking output time) */
1273/* 1277/*
1274 * Silence Tracker 1278 * Silence Tracker
1275 */ 1279 */
1276int32_t nSilentSamples; 1280static int32_t nSilentSamples;
1277int32_t nSilentSampleMax; 1281static int32_t nSilentSampleMax;
1278int32_t nSilenceTrackMS; 1282static int32_t nSilenceTrackMS;
1279uint8_t bNoSilenceIfTime; 1283static uint8_t bNoSilenceIfTime;
1280uint8_t bTimeNotDefault; 1284static uint8_t bTimeNotDefault;
1281 1285
1282/* 1286/*
1283 * Sound output options 1287 * Sound output options
1284 */ 1288 */
1285const int32_t nSampleRate=44100; 1289static const int32_t nSampleRate=44100;
1286 1290
1287/* 1291/*
1288 * Volume/fading/filter tracking 1292 * Volume/fading/filter tracking
1289 */ 1293 */
1290 1294
1291uint32_t nStartFade; /* play call to start fading out */ 1295static uint32_t nStartFade; /* play call to start fading out */
1292uint32_t nEndFade; /* play call to stop fading out (song is over) */ 1296static uint32_t nEndFade; /* play call to stop fading out (song is over) */
1293uint8_t bFade; /* are we fading? */ 1297static uint8_t bFade; /* are we fading? */
1294float fFadeVolume; 1298static float fFadeVolume;
1295float fFadeChange; 1299static float fFadeChange;
1296 1300
1297/* 1301/*
1298 * Designated Output Buffer 1302 * Designated Output Buffer
1299 */ 1303 */
1300uint8_t* pOutput IDATA_ATTR; 1304static uint8_t* pOutput IDATA_ATTR;
1301 1305
1302const uint8_t bDMCPopReducer=1; 1306static const uint8_t bDMCPopReducer=1;
1303uint8_t nDMCPop_Prev IDATA_ATTR = 0; 1307static uint8_t nDMCPop_Prev IDATA_ATTR = 0;
1304uint8_t bDMCPop_Skip IDATA_ATTR = 0; 1308static uint8_t bDMCPop_Skip IDATA_ATTR = 0;
1305uint8_t bDMCPop_SamePlay IDATA_ATTR = 0; 1309static uint8_t bDMCPop_SamePlay IDATA_ATTR = 0;
1306 1310
1307const uint8_t nForce4017Write=0; 1311static const uint8_t nForce4017Write=0;
1308const uint8_t bN106PopReducer=0; 1312static const uint8_t bN106PopReducer=0;
1309const uint8_t bIgnore4011Writes=0; 1313static const uint8_t bIgnore4011Writes=0;
1310 1314
1311const uint8_t bIgnoreBRK=0; 1315static const uint8_t bIgnoreBRK=0;
1312const uint8_t bIgnoreIllegalOps=0; 1316static const uint8_t bIgnoreIllegalOps=0;
1313const uint8_t bNoWaitForReturn=0; 1317static const uint8_t bNoWaitForReturn=0;
1314const uint8_t bPALPreference=0; 1318static const uint8_t bPALPreference=0;
1315const uint8_t bCleanAXY=0; 1319static const uint8_t bCleanAXY=0;
1316const uint8_t bResetDuty=0; 1320static const uint8_t bResetDuty=0;
1317 1321
1318/* 1322/*
1319 * Sound Filter 1323 * Sound Filter
1320 */ 1324 */
1321 1325
1322int64_t nFilterAccL IDATA_ATTR; 1326static int64_t nFilterAccL IDATA_ATTR;
1323int64_t nHighPass IDATA_ATTR; 1327static int64_t nHighPass IDATA_ATTR;
1324 1328
1325int32_t nHighPassBase IDATA_ATTR; 1329static int32_t nHighPassBase IDATA_ATTR;
1326 1330
1327uint8_t bHighPassEnabled IDATA_ATTR; 1331static uint8_t bHighPassEnabled IDATA_ATTR;
1328 1332
1329/* end globals */ 1333/* end globals */
1330 1334
@@ -1344,40 +1348,43 @@ uint8_t bHighPassEnabled IDATA_ATTR;
1344 * prototypes 1348 * prototypes
1345 */ 1349 */
1346 1350
1347uint32_t Emulate6502(uint32_t runto) ICODE_ATTR; 1351static uint32_t Emulate6502(uint32_t runto) ICODE_ATTR;
1348void EmulateAPU(uint8_t bBurnCPUCycles) ICODE_ATTR; 1352static void EmulateAPU(uint8_t bBurnCPUCycles) ICODE_ATTR;
1349 1353
1350int NSFCore_Initialize(void); /* 1 = initialized ok, 1354static int NSFCore_Initialize(void); /* 1 = initialized ok,
1351 0 = couldn't initialize (memory allocation error) */ 1355 0 = couldn't initialize (memory allocation error) */
1352 1356
1353/* 1357/*
1354 * Song Loading 1358 * Song Loading
1355 */ 1359 */
1356int LoadNSF(int32_t); /* grab data from an existing file 1360static int LoadNSF(int32_t); /* grab data from an existing file
1357 1 = loaded ok, 0 = error loading */ 1361 1 = loaded ok, 0 = error loading */
1358 1362
1359/* 1363/*
1360 * Track Control 1364 * Track Control
1361 */ 1365 */
1362void SetTrack(uint8_t track); /* Change tracks */ 1366static void SetTrack(uint8_t track); /* Change tracks */
1363 1367
1364/* 1368/*
1365 * Getting Samples 1369 * Getting Samples
1366 */ 1370 */
1367/* fill a buffer with samples */ 1371/* fill a buffer with samples */
1368int32_t GetSamples(uint8_t* buffer, int32_t buffersize); 1372static int32_t GetSamples(uint8_t* buffer, int32_t buffersize);
1369 1373
1370/* 1374/*
1371 * Playback options 1375 * Playback options
1372 */ 1376 */
1373/* Set desired playback options (0 = bad options couldn't be set) */ 1377/* Set desired playback options (0 = bad options couldn't be set) */
1374int SetPlaybackOptions(int32_t samplerate); 1378static int SetPlaybackOptions(int32_t samplerate);
1375/* Speed throttling (0 = uses NSF specified speed) */ 1379/* Speed throttling (0 = uses NSF specified speed) */
1376void SetPlaybackSpeed(float playspersec); 1380static void SetPlaybackSpeed(float playspersec);
1377 1381
1378float GetPlaybackSpeed(void); 1382static float GetPlaybackSpeed(void);
1379float GetMasterVolume(void); 1383/* rockbox: not used
1384float GetMasterVolume(void); */
1380 1385
1386/* rockbox: not used */
1387#if 0
1381/* 1388/*
1382 * Seeking 1389 * Seeking
1383 */ 1390 */
@@ -1391,72 +1398,75 @@ uint32_t GetWrittenTime(float basedplayspersec);
1391void SetPlayCalls(float plays); 1398void SetPlayCalls(float plays);
1392/* sets the written time (approx. seeking) */ 1399/* sets the written time (approx. seeking) */
1393void SetWrittenTime(uint32_t ms,float basedplays); 1400void SetWrittenTime(uint32_t ms,float basedplays);
1401#endif
1394 1402
1395/* 1403/*
1396 * Fading 1404 * Fading
1397 */ 1405 */
1398 1406
1399void StopFade(void); /* stops all fading (plays indefinitely) */ 1407/* rockbox: not used
1400uint8_t SongCompleted(void); /* song has faded out (samples have stopped 1408void StopFade(void); */ /* stops all fading (plays indefinitely) */
1401 being generated) */ 1409static uint8_t SongCompleted(void); /* song has faded out (samples have
1410 stopped being generated) */
1402/* parameters are play calls */ 1411/* parameters are play calls */
1403void SetFade(int32_t fadestart,int32_t fadestop,uint8_t bNotDefault); 1412static void SetFade(int32_t fadestart,int32_t fadestop,uint8_t bNotDefault);
1404void SetFadeTime(uint32_t fadestart,uint32_t fadestop,float basedplays, 1413static void SetFadeTime(uint32_t fadestart,uint32_t fadestop,
1405 uint8_t bNotDefault); /* parameters are in milliseconds */ 1414 float basedplays, uint8_t bNotDefault);
1415 /* parameters are in milliseconds */
1406 1416
1407/* 1417/*
1408 * Internal Functions 1418 * Internal Functions
1409 */ 1419 */
1410void RebuildOutputTables(void); 1420static void RebuildOutputTables(void);
1411void RecalculateFade(void); /* called when fade status is changed. */ 1421static void RecalculateFade(void); /* called when fade status is changed. */
1412void RecalcFilter(void); 1422static void RecalcFilter(void);
1413void RecalcSilenceTracker(void); 1423static void RecalcSilenceTracker(void);
1414 1424
1415void WriteMemory_VRC6(uint16_t a,uint8_t v) ICODE_ATTR; 1425static void WriteMemory_VRC6(uint16_t a,uint8_t v) ICODE_ATTR;
1416void WriteMemory_MMC5(uint16_t a,uint8_t v) ICODE_ATTR; 1426static void WriteMemory_MMC5(uint16_t a,uint8_t v) ICODE_ATTR;
1417void WriteMemory_N106(uint16_t a,uint8_t v) ICODE_ATTR; 1427static void WriteMemory_N106(uint16_t a,uint8_t v) ICODE_ATTR;
1418void WriteMemory_FME07(uint16_t a,uint8_t v) ICODE_ATTR; 1428static void WriteMemory_FME07(uint16_t a,uint8_t v) ICODE_ATTR;
1419 1429
1420/* 1430/*
1421 * Memory Read/Write routines 1431 * Memory Read/Write routines
1422 */ 1432 */
1423 1433
1424uint8_t ReadMemory_RAM(uint16_t a) ICODE_ATTR; 1434static uint8_t ReadMemory_RAM(uint16_t a) ICODE_ATTR;
1425uint8_t ReadMemory_ExRAM(uint16_t a) ICODE_ATTR; 1435static uint8_t ReadMemory_ExRAM(uint16_t a) ICODE_ATTR;
1426uint8_t ReadMemory_SRAM(uint16_t a) ICODE_ATTR; 1436static uint8_t ReadMemory_SRAM(uint16_t a) ICODE_ATTR;
1427uint8_t ReadMemory_pAPU(uint16_t a) ICODE_ATTR; 1437static uint8_t ReadMemory_pAPU(uint16_t a) ICODE_ATTR;
1428uint8_t ReadMemory_ROM(uint16_t a) ICODE_ATTR; 1438static uint8_t ReadMemory_ROM(uint16_t a) ICODE_ATTR;
1429uint8_t ReadMemory_Default(uint16_t a) ICODE_ATTR; 1439static uint8_t ReadMemory_Default(uint16_t a) ICODE_ATTR;
1430 1440
1431uint8_t ReadMemory_N106(uint16_t a) ICODE_ATTR; 1441static uint8_t ReadMemory_N106(uint16_t a) ICODE_ATTR;
1432 1442
1433void WriteMemory_RAM(uint16_t a,uint8_t v) ICODE_ATTR; 1443static void WriteMemory_RAM(uint16_t a,uint8_t v) ICODE_ATTR;
1434void WriteMemory_ExRAM(uint16_t a,uint8_t v) ICODE_ATTR; 1444static void WriteMemory_ExRAM(uint16_t a,uint8_t v) ICODE_ATTR;
1435void WriteMemory_SRAM(uint16_t a,uint8_t v) ICODE_ATTR; 1445static void WriteMemory_SRAM(uint16_t a,uint8_t v) ICODE_ATTR;
1436void WriteMemory_pAPU(uint16_t a,uint8_t v) ICODE_ATTR; 1446static void WriteMemory_pAPU(uint16_t a,uint8_t v) ICODE_ATTR;
1437void WriteMemory_FDSRAM(uint16_t a,uint8_t v) ICODE_ATTR; 1447static void WriteMemory_FDSRAM(uint16_t a,uint8_t v) ICODE_ATTR;
1438void WriteMemory_Default(uint16_t a,uint8_t v) ICODE_ATTR; 1448static void WriteMemory_Default(uint16_t a,uint8_t v) ICODE_ATTR;
1439 1449
1440uint8_t ReadMemory_RAM(uint16_t a) { return pRAM[a & 0x07FF]; } 1450static uint8_t ReadMemory_RAM(uint16_t a) { return pRAM[a & 0x07FF]; }
1441uint8_t ReadMemory_ExRAM(uint16_t a) { return pExRAM[a & 0x0FFF]; } 1451static uint8_t ReadMemory_ExRAM(uint16_t a) { return pExRAM[a & 0x0FFF]; }
1442uint8_t ReadMemory_SRAM(uint16_t a) { return pSRAM[a & 0x1FFF]; } 1452static uint8_t ReadMemory_SRAM(uint16_t a) { return pSRAM[a & 0x1FFF]; }
1443uint8_t ReadMemory_ROM(uint16_t a) 1453static uint8_t ReadMemory_ROM(uint16_t a)
1444 { return pROM[(a >> 12) - 6][a & 0x0FFF]; } 1454 { return pROM[(a >> 12) - 6][a & 0x0FFF]; }
1445uint8_t ReadMemory_Default(uint16_t a) { return (a >> 8); } 1455static uint8_t ReadMemory_Default(uint16_t a) { return (a >> 8); }
1446 1456
1447void WriteMemory_RAM(uint16_t a,uint8_t v) 1457static void WriteMemory_RAM(uint16_t a,uint8_t v)
1448 { pRAM[a & 0x07FF] = v; } 1458 { pRAM[a & 0x07FF] = v; }
1449void WriteMemory_ExRAM(uint16_t a,uint8_t v); 1459static void WriteMemory_ExRAM(uint16_t a,uint8_t v);
1450void WriteMemory_SRAM(uint16_t a,uint8_t v) 1460static void WriteMemory_SRAM(uint16_t a,uint8_t v)
1451 { pSRAM[a & 0x1FFF] = v; } 1461 { pSRAM[a & 0x1FFF] = v; }
1452void WriteMemory_FDSRAM(uint16_t a,uint8_t v) 1462static void WriteMemory_FDSRAM(uint16_t a,uint8_t v)
1453 { pROM[(a >> 12) - 6][a & 0x0FFF] = v; } 1463 { pROM[(a >> 12) - 6][a & 0x0FFF] = v; }
1454void WriteMemory_Default(uint16_t a,uint8_t v) { (void)a; (void)v; } 1464static void WriteMemory_Default(uint16_t a,uint8_t v) { (void)a; (void)v; }
1455 1465
1456 1466
1457/* Read Memory Procs */ 1467/* Read Memory Procs */
1458 1468
1459uint8_t ReadMemory_pAPU(uint16_t a) 1469static uint8_t ReadMemory_pAPU(uint16_t a)
1460{ 1470{
1461 EmulateAPU(1); 1471 EmulateAPU(1);
1462 1472
@@ -1489,7 +1499,7 @@ uint8_t ReadMemory_pAPU(uint16_t a)
1489 return 0x40; 1499 return 0x40;
1490} 1500}
1491 1501
1492uint8_t ReadMemory_N106(uint16_t a) 1502static uint8_t ReadMemory_N106(uint16_t a)
1493{ 1503{
1494 if(a != 0x4800) 1504 if(a != 0x4800)
1495 return ReadMemory_pAPU(a); 1505 return ReadMemory_pAPU(a);
@@ -1505,7 +1515,7 @@ uint8_t ReadMemory_N106(uint16_t a)
1505 1515
1506/* Write Memory Procs */ 1516/* Write Memory Procs */
1507 1517
1508void WriteMemory_ExRAM(uint16_t a,uint8_t v) 1518static void WriteMemory_ExRAM(uint16_t a,uint8_t v)
1509{ 1519{
1510 if(a < 0x5FF6) /* Invalid */ 1520 if(a < 0x5FF6) /* Invalid */
1511 return; 1521 return;
@@ -1526,7 +1536,7 @@ void WriteMemory_ExRAM(uint16_t a,uint8_t v)
1526 mWave_TND.pDMCDMAPtr[a - 2] = pROM[a]; 1536 mWave_TND.pDMCDMAPtr[a - 2] = pROM[a];
1527} 1537}
1528 1538
1529void WriteMemory_pAPU(uint16_t a,uint8_t v) 1539static void WriteMemory_pAPU(uint16_t a,uint8_t v)
1530{ 1540{
1531 EmulateAPU(1); 1541 EmulateAPU(1);
1532 switch(a) 1542 switch(a)
@@ -1875,7 +1885,7 @@ void WriteMemory_pAPU(uint16_t a,uint8_t v)
1875 } 1885 }
1876} 1886}
1877 1887
1878void WriteMemory_VRC6(uint16_t a,uint8_t v) 1888static void WriteMemory_VRC6(uint16_t a,uint8_t v)
1879{ 1889{
1880 EmulateAPU(1); 1890 EmulateAPU(1);
1881 1891
@@ -1938,7 +1948,7 @@ void WriteMemory_VRC6(uint16_t a,uint8_t v)
1938 } 1948 }
1939} 1949}
1940 1950
1941void WriteMemory_MMC5(uint16_t a,uint8_t v) 1951static void WriteMemory_MMC5(uint16_t a,uint8_t v)
1942{ 1952{
1943 if((a <= 0x5015) && !bPALMode) 1953 if((a <= 0x5015) && !bPALMode)
1944 { 1954 {
@@ -1968,7 +1978,7 @@ multiply:
1968 WriteMemory_ExRAM(a,v); 1978 WriteMemory_ExRAM(a,v);
1969} 1979}
1970 1980
1971void WriteMemory_N106(uint16_t a,uint8_t v) 1981static void WriteMemory_N106(uint16_t a,uint8_t v)
1972{ 1982{
1973 if(a < 0x4800) 1983 if(a < 0x4800)
1974 { 1984 {
@@ -2040,7 +2050,7 @@ void WriteMemory_N106(uint16_t a,uint8_t v)
2040 } 2050 }
2041} 2051}
2042 2052
2043void WriteMemory_FME07(uint16_t a,uint8_t v) 2053static void WriteMemory_FME07(uint16_t a,uint8_t v)
2044{ 2054{
2045 if((a < 0xD000) && (nExternalSound & EXTSOUND_FDS)) 2055 if((a < 0xD000) && (nExternalSound & EXTSOUND_FDS))
2046 WriteMemory_FDSRAM(a,v); 2056 WriteMemory_FDSRAM(a,v);
@@ -2073,8 +2083,8 @@ void WriteMemory_FME07(uint16_t a,uint8_t v)
2073 * Emulate APU 2083 * Emulate APU
2074 */ 2084 */
2075 2085
2076int32_t fulltick; 2086static int32_t fulltick;
2077void EmulateAPU(uint8_t bBurnCPUCycles) 2087static void EmulateAPU(uint8_t bBurnCPUCycles)
2078{ 2088{
2079 int32_t tick; 2089 int32_t tick;
2080 int64_t diff; 2090 int64_t diff;
@@ -2592,7 +2602,7 @@ void EmulateAPU(uint8_t bBurnCPUCycles)
2592 * Initializes Memory 2602 * Initializes Memory
2593 */ 2603 */
2594 2604
2595int NSFCore_Initialize() 2605static int NSFCore_Initialize()
2596{ 2606{
2597 int32_t i; 2607 int32_t i;
2598 /* clear globals */ 2608 /* clear globals */
@@ -2751,7 +2761,7 @@ int NSFCore_Initialize()
2751 * LoadNSF 2761 * LoadNSF
2752 */ 2762 */
2753 2763
2754int LoadNSF(int32_t datasize) 2764static int LoadNSF(int32_t datasize)
2755{ 2765{
2756 if(!pDataBuffer) return 0; 2766 if(!pDataBuffer) return 0;
2757 2767
@@ -2925,7 +2935,7 @@ int LoadNSF(int32_t datasize)
2925 * SetTrack 2935 * SetTrack
2926 */ 2936 */
2927 2937
2928void SetTrack(uint8_t track) 2938static void SetTrack(uint8_t track)
2929{ 2939{
2930 int32_t i; 2940 int32_t i;
2931 2941
@@ -3054,7 +3064,7 @@ void SetTrack(uint8_t track)
3054 * SetPlaybackOptions 3064 * SetPlaybackOptions
3055 */ 3065 */
3056 3066
3057int SetPlaybackOptions(int32_t samplerate) 3067static int SetPlaybackOptions(int32_t samplerate)
3058{ 3068{
3059 if(samplerate < 2000) return 0; 3069 if(samplerate < 2000) return 0;
3060 if(samplerate > 96000) return 0; 3070 if(samplerate > 96000) return 0;
@@ -3073,7 +3083,7 @@ int SetPlaybackOptions(int32_t samplerate)
3073 * SetPlaybackSpeed 3083 * SetPlaybackSpeed
3074 */ 3084 */
3075 3085
3076void SetPlaybackSpeed(float playspersec) 3086static void SetPlaybackSpeed(float playspersec)
3077{ 3087{
3078 if(playspersec < 1) 3088 if(playspersec < 1)
3079 { 3089 {
@@ -3088,7 +3098,7 @@ void SetPlaybackSpeed(float playspersec)
3088* GetPlaybackSpeed 3098* GetPlaybackSpeed
3089*/ 3099*/
3090 3100
3091float GetPlaybackSpeed() 3101static float GetPlaybackSpeed()
3092{ 3102{
3093 if(nTicksPerPlay <= 0) return 0; 3103 if(nTicksPerPlay <= 0) return 0;
3094 return ((bPALMode ? PAL_FREQUENCY : NTSC_FREQUENCY) / (nTicksPerPlay>>16)); 3104 return ((bPALMode ? PAL_FREQUENCY : NTSC_FREQUENCY) / (nTicksPerPlay>>16));
@@ -3098,7 +3108,7 @@ float GetPlaybackSpeed()
3098 * RecalcFilter 3108 * RecalcFilter
3099 */ 3109 */
3100 3110
3101void RecalcFilter() 3111static void RecalcFilter()
3102{ 3112{
3103 if(!nSampleRate) return; 3113 if(!nSampleRate) return;
3104 3114
@@ -3111,7 +3121,7 @@ void RecalcFilter()
3111 * RecalcSilenceTracker 3121 * RecalcSilenceTracker
3112 */ 3122 */
3113 3123
3114void RecalcSilenceTracker() 3124static void RecalcSilenceTracker()
3115{ 3125{
3116 if(nSilenceTrackMS <= 0 || !nSampleRate || 3126 if(nSilenceTrackMS <= 0 || !nSampleRate ||
3117 (bNoSilenceIfTime && bTimeNotDefault)) 3127 (bNoSilenceIfTime && bTimeNotDefault))
@@ -3124,7 +3134,7 @@ void RecalcSilenceTracker()
3124 nSilentSampleMax /= 2; 3134 nSilentSampleMax /= 2;
3125} 3135}
3126 3136
3127void RebuildOutputTables(void) { 3137static void RebuildOutputTables(void) {
3128 int32_t i,j; 3138 int32_t i,j;
3129 float l[3]; 3139 float l[3];
3130 int32_t temp; 3140 int32_t temp;
@@ -3223,6 +3233,8 @@ void RebuildOutputTables(void) {
3223 } 3233 }
3224} 3234}
3225 3235
3236/* rockbox: not used */
3237#if 0
3226/* 3238/*
3227 * GetPlayCalls 3239 * GetPlayCalls
3228 */ 3240 */
@@ -3257,12 +3269,13 @@ void StopFade()
3257 bFade = 0; 3269 bFade = 0;
3258 fFadeVolume = 1; 3270 fFadeVolume = 1;
3259} 3271}
3272#endif
3260 3273
3261/* 3274/*
3262 * SongCompleted 3275 * SongCompleted
3263 */ 3276 */
3264 3277
3265uint8_t SongCompleted() 3278static uint8_t SongCompleted()
3266{ 3279{
3267 if(!bFade) return 0; 3280 if(!bFade) return 0;
3268 if(nTotalPlays >= nEndFade) return 1; 3281 if(nTotalPlays >= nEndFade) return 1;
@@ -3275,7 +3288,7 @@ uint8_t SongCompleted()
3275 * SetFade 3288 * SetFade
3276 */ 3289 */
3277 3290
3278void SetFade(int32_t fadestart,int32_t fadestop, 3291static void SetFade(int32_t fadestart,int32_t fadestop,
3279 uint8_t bNotDefault) /* play routine calls */ 3292 uint8_t bNotDefault) /* play routine calls */
3280{ 3293{
3281 if(fadestart < 0) fadestart = 0; 3294 if(fadestart < 0) fadestart = 0;
@@ -3294,7 +3307,7 @@ void SetFade(int32_t fadestart,int32_t fadestop,
3294 * SetFadeTime 3307 * SetFadeTime
3295 */ 3308 */
3296 3309
3297void SetFadeTime(uint32_t fadestart,uint32_t fadestop,float basedplays, 3310static void SetFadeTime(uint32_t fadestart,uint32_t fadestop,float basedplays,
3298 uint8_t bNotDefault) /* time in MS */ 3311 uint8_t bNotDefault) /* time in MS */
3299{ 3312{
3300 if(basedplays <= 0) 3313 if(basedplays <= 0)
@@ -3310,7 +3323,7 @@ void SetFadeTime(uint32_t fadestart,uint32_t fadestop,float basedplays,
3310 * RecalculateFade 3323 * RecalculateFade
3311 */ 3324 */
3312 3325
3313void RecalculateFade() 3326static void RecalculateFade()
3314{ 3327{
3315 if(!bFade) return; 3328 if(!bFade) return;
3316 3329
@@ -3342,7 +3355,7 @@ void RecalculateFade()
3342 3355
3343} 3356}
3344 3357
3345int32_t GetSamples(uint8_t* buffer,int32_t buffersize) 3358static int32_t GetSamples(uint8_t* buffer,int32_t buffersize)
3346{ 3359{
3347 if(!buffer) return 0; 3360 if(!buffer) return 0;
3348 if(buffersize < 16) return 0; 3361 if(buffersize < 16) return 0;
@@ -3805,12 +3818,10 @@ N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG };
3805 3818
3806/* The 6502 emulation function! */ 3819/* The 6502 emulation function! */
3807 3820
3808union TWIN front; 3821static uint8_t val;
3809union TWIN final; 3822static uint8_t op;
3810uint8_t val;
3811uint8_t op;
3812 3823
3813uint32_t Emulate6502(uint32_t runto) 3824static uint32_t Emulate6502(uint32_t runto)
3814{ 3825{
3815 /* If the CPU is jammed... don't bother */ 3826 /* If the CPU is jammed... don't bother */
3816 if(bCPUJammed == 1) 3827 if(bCPUJammed == 1)