diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/codecs/nsf.c | 489 |
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 */ |
189 | static const int32_t ModulationTable[8] ICONST_ATTR = {0,1,2,4,0,-4,-2,-1}; | 189 | static const int32_t ModulationTable[8] ICONST_ATTR = {0,1,2,4,0,-4,-2,-1}; |
190 | const uint16_t DMC_FREQ_TABLE[2][0x10] ICONST_ATTR_NSF_LARGE_IRAM = { | 190 | static 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 | ||
199 | const uint8_t DUTY_CYCLE_TABLE[4] ICONST_ATTR_NSF_LARGE_IRAM = {2,4,8,12}; | 199 | static const uint8_t DUTY_CYCLE_TABLE[4] ICONST_ATTR_NSF_LARGE_IRAM = { |
200 | 2,4,8,12 | ||
201 | }; | ||
200 | 202 | ||
201 | const uint8_t LENGTH_COUNTER_TABLE[0x20] ICONST_ATTR_NSF_LARGE_IRAM = { | 203 | static 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 | ||
207 | const uint16_t NOISE_FREQ_TABLE[0x10] ICONST_ATTR_NSF_LARGE_IRAM = { | 209 | static 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 | ||
248 | int32_t LoadFile(uint8_t *,size_t); | 250 | static int32_t LoadFile(uint8_t *,size_t); |
249 | 251 | ||
250 | int32_t LoadFile_NESM(uint8_t *,size_t); | 252 | static int32_t LoadFile_NESM(uint8_t *,size_t); |
251 | int32_t LoadFile_NSFE(uint8_t *,size_t); | 253 | static 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 */ |
256 | int32_t bIsExtended=0; /* 0 = NSF, 1 = NSFE */ | 258 | static int32_t bIsExtended=0; /* 0 = NSF, 1 = NSFE */ |
257 | uint8_t nIsPal=0; /* 0 = NTSC, 1 = PAL, | 259 | static 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) */ |
259 | int32_t nfileLoadAddress=0; /* The address to which the NSF code is | 261 | static int32_t nfileLoadAddress=0; /* The address to which the NSF code is |
260 | loaded */ | 262 | loaded */ |
261 | int32_t nfileInitAddress=0; /* The address of the Init routine | 263 | static int32_t nfileInitAddress=0; /* The address of the Init routine |
262 | (called at track change) */ | 264 | (called at track change) */ |
263 | int32_t nfilePlayAddress=0; /* The address of the Play routine | 265 | static int32_t nfilePlayAddress=0; /* The address of the Play routine |
264 | (called several times a second) */ | 266 | (called several times a second) */ |
265 | uint8_t nChipExtensions=0; /* Bitwise representation of the external chips | 267 | static 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) */ |
269 | int32_t nNTSC_PlaySpeed=0; | 271 | static int32_t nNTSC_PlaySpeed=0; |
270 | int32_t nPAL_PlaySpeed=0; | 272 | static 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) */ |
274 | int32_t nTrackCount=0; | 276 | static 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) */ |
276 | int32_t nInitialTrack=0; | 278 | static int32_t nInitialTrack=0; |
277 | 279 | ||
278 | /* nsf data */ | 280 | /* nsf data */ |
279 | uint8_t* pDataBuffer=0; /* the buffer containing NSF code. */ | 281 | static uint8_t* pDataBuffer=0; /* the buffer containing NSF code. */ |
280 | int32_t nDataBufferSize=0; /* the size of the above buffer. */ | 282 | static int32_t nDataBufferSize=0; /* the size of the above buffer. */ |
281 | 283 | ||
282 | /* playlist */ | 284 | /* playlist */ |
283 | uint8_t nPlaylist[256]; /* Each entry is the zero based index of the | 285 | static uint8_t nPlaylist[256]; /* Each entry is the zero based index of |
284 | song to play */ | 286 | the song to play */ |
285 | int32_t nPlaylistSize=0; /* the number of tracks in the playlist */ | 287 | static int32_t nPlaylistSize=0; /* number of tracks in the playlist */ |
286 | 288 | ||
287 | /* track time / fade */ | 289 | /* track time / fade */ |
288 | int32_t nTrackTime[256]; /* track times -1 if no track times specified */ | 290 | static int32_t nTrackTime[256]; /* track times -1 if no track times |
289 | int32_t nTrackFade[256]; /* track fade times -1 if none are specified */ | 291 | specified */ |
292 | static int32_t nTrackFade[256]; /* track fade times -1 if none are | ||
293 | specified */ | ||
290 | 294 | ||
291 | /* string info */ | 295 | /* string info */ |
292 | uint8_t szGameTitle[0x101]; | 296 | static uint8_t szGameTitle[0x101]; |
293 | uint8_t szArtist[0x101]; | 297 | static uint8_t szArtist[0x101]; |
294 | uint8_t szCopyright[0x101]; | 298 | static uint8_t szCopyright[0x101]; |
295 | uint8_t szRipper[0x101]; | 299 | static uint8_t szRipper[0x101]; |
296 | 300 | ||
297 | /* bankswitching info */ | 301 | /* bankswitching info */ |
298 | uint8_t nBankswitch[8]={0}; /* The initial bankswitching registers needed | 302 | static 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 | ||
303 | int32_t LoadFile(uint8_t * inbuffer, size_t size) | 307 | static 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 | ||
331 | int32_t LoadFile_NESM(uint8_t* inbuffer, size_t size) | 335 | static 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 | ||
382 | int32_t LoadFile_NSFE(uint8_t* inbuffer, size_t size) | 386 | static 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 | }; |
607 | int16_t FDS_nOutputTable_L[4][0x21][0x40] IBSS_ATTR_NSF_LARGE_IRAM MEM_ALIGN_ATTR; | 611 | static int16_t FDS_nOutputTable_L[4][0x21][0x40] IBSS_ATTR_NSF_LARGE_IRAM MEM_ALIGN_ATTR; |
608 | 612 | ||
609 | struct FME07Wave | 613 | struct FME07Wave |
610 | { | 614 | { |
@@ -625,7 +629,7 @@ struct FME07Wave | |||
625 | int32_t nMixL; | 629 | int32_t nMixL; |
626 | }; | 630 | }; |
627 | 631 | ||
628 | int16_t FME07_nOutputTable_L[0x10] IDATA_ATTR MEM_ALIGN_ATTR; | 632 | static int16_t FME07_nOutputTable_L[0x10] IDATA_ATTR MEM_ALIGN_ATTR; |
629 | 633 | ||
630 | struct N106Wave | 634 | struct N106Wave |
631 | { | 635 | { |
@@ -665,7 +669,7 @@ struct N106Wave | |||
665 | int32_t nMixL[8]; | 669 | int32_t nMixL[8]; |
666 | }; | 670 | }; |
667 | 671 | ||
668 | int16_t N106_nOutputTable_L[0x10][0x10] IBSS_ATTR_NSF_LARGE_IRAM MEM_ALIGN_ATTR; | 672 | static int16_t N106_nOutputTable_L[0x10][0x10] IBSS_ATTR_NSF_LARGE_IRAM MEM_ALIGN_ATTR; |
669 | 673 | ||
670 | struct VRC6PulseWave | 674 | struct VRC6PulseWave |
671 | { | 675 | { |
@@ -690,7 +694,7 @@ struct VRC6PulseWave | |||
690 | 694 | ||
691 | }; | 695 | }; |
692 | 696 | ||
693 | int16_t VRC6Pulse_nOutputTable_L[0x10] IDATA_ATTR MEM_ALIGN_ATTR; | 697 | static int16_t VRC6Pulse_nOutputTable_L[0x10] IDATA_ATTR MEM_ALIGN_ATTR; |
694 | 698 | ||
695 | struct VRC6SawWave | 699 | struct VRC6SawWave |
696 | { | 700 | { |
@@ -712,7 +716,7 @@ struct VRC6SawWave | |||
712 | 716 | ||
713 | }; | 717 | }; |
714 | 718 | ||
715 | int16_t VRC6Saw_nOutputTable_L[0x20] IDATA_ATTR MEM_ALIGN_ATTR; | 719 | static int16_t VRC6Saw_nOutputTable_L[0x20] IDATA_ATTR MEM_ALIGN_ATTR; |
716 | 720 | ||
717 | struct Wave_Squares | 721 | struct Wave_Squares |
718 | { | 722 | { |
@@ -750,7 +754,7 @@ struct Wave_Squares | |||
750 | int32_t nMixL; | 754 | int32_t nMixL; |
751 | }; | 755 | }; |
752 | 756 | ||
753 | int16_t Squares_nOutputTable_L[0x10][0x10] IDATA_ATTR MEM_ALIGN_ATTR; | 757 | static int16_t Squares_nOutputTable_L[0x10][0x10] IDATA_ATTR MEM_ALIGN_ATTR; |
754 | 758 | ||
755 | struct Wave_TND | 759 | struct Wave_TND |
756 | { | 760 | { |
@@ -841,13 +845,13 @@ struct Wave_TND | |||
841 | }; | 845 | }; |
842 | 846 | ||
843 | /* channels */ | 847 | /* channels */ |
844 | struct Wave_Squares mWave_Squares IDATA_ATTR; /* Square channels 1 and 2 */ | 848 | static struct Wave_Squares mWave_Squares IDATA_ATTR; /* Square channels 1 and 2 */ |
845 | struct Wave_TND mWave_TND IDATA_ATTR; /* Triangle/Noise/DMC channels */ | 849 | static struct Wave_TND mWave_TND IDATA_ATTR; /* Triangle/Noise/DMC channels */ |
846 | struct VRC6PulseWave mWave_VRC6Pulse[2] IDATA_ATTR; | 850 | static struct VRC6PulseWave mWave_VRC6Pulse[2] IDATA_ATTR; |
847 | struct VRC6SawWave mWave_VRC6Saw IDATA_ATTR; | 851 | static struct VRC6SawWave mWave_VRC6Saw IDATA_ATTR; |
848 | struct N106Wave mWave_N106 IDATA_ATTR; | 852 | static struct N106Wave mWave_N106 IDATA_ATTR; |
849 | struct FDSWave mWave_FDS IDATA_ATTR; | 853 | static struct FDSWave mWave_FDS IDATA_ATTR; |
850 | struct FME07Wave mWave_FME07[3] IDATA_ATTR; /* FME-07's 3 pulse channels */ | 854 | static 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 |
860 | void Wave_N106_DoTicks(const int32_t ticks) ICODE_ATTR; | 864 | static void Wave_N106_DoTicks(const int32_t ticks) ICODE_ATTR; |
861 | void Wave_N106_DoTicks(const int32_t ticks) | 865 | static void Wave_N106_DoTicks(const int32_t ticks) |
862 | #else | 866 | #else |
863 | inline void Wave_N106_DoTicks(const int32_t ticks); | 867 | static inline void Wave_N106_DoTicks(const int32_t ticks); |
864 | inline void Wave_N106_DoTicks(const int32_t ticks) | 868 | static 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 |
930 | void Wave_VRC6_DoTicks(const int32_t ticks) ICODE_ATTR; | 934 | static void Wave_VRC6_DoTicks(const int32_t ticks) ICODE_ATTR; |
931 | void Wave_VRC6_DoTicks(const int32_t ticks) | 935 | static void Wave_VRC6_DoTicks(const int32_t ticks) |
932 | #else | 936 | #else |
933 | inline void Wave_VRC6_DoTicks(const int32_t ticks); | 937 | static inline void Wave_VRC6_DoTicks(const int32_t ticks); |
934 | inline void Wave_VRC6_DoTicks(const int32_t ticks) | 938 | static 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 |
992 | void Wave_Squares_ClockMajor(void) ICODE_ATTR; | 996 | static void Wave_Squares_ClockMajor(void) ICODE_ATTR; |
993 | void Wave_Squares_ClockMajor() | 997 | static void Wave_Squares_ClockMajor() |
994 | #else | 998 | #else |
995 | inline void Wave_Squares_ClockMajor(void); | 999 | static inline void Wave_Squares_ClockMajor(void); |
996 | inline void Wave_Squares_ClockMajor() | 1000 | static 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 |
1037 | void Wave_Squares_CheckSweepForcedSilence(const int32_t i) ICODE_ATTR; | 1041 | static void Wave_Squares_CheckSweepForcedSilence(const int32_t i) ICODE_ATTR; |
1038 | void Wave_Squares_CheckSweepForcedSilence(const int32_t i) | 1042 | static void Wave_Squares_CheckSweepForcedSilence(const int32_t i) |
1039 | #else | 1043 | #else |
1040 | inline void Wave_Squares_CheckSweepForcedSilence(const int32_t i); | 1044 | static inline void Wave_Squares_CheckSweepForcedSilence(const int32_t i); |
1041 | inline void Wave_Squares_CheckSweepForcedSilence(const int32_t i) | 1045 | static 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 |
1057 | void Wave_Squares_ClockMinor(void) ICODE_ATTR; | 1061 | static void Wave_Squares_ClockMinor(void) ICODE_ATTR; |
1058 | void Wave_Squares_ClockMinor() | 1062 | static void Wave_Squares_ClockMinor() |
1059 | #else | 1063 | #else |
1060 | inline void Wave_Squares_ClockMinor(void); | 1064 | static inline void Wave_Squares_ClockMinor(void); |
1061 | inline void Wave_Squares_ClockMinor() | 1065 | static 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 |
1117 | void Wave_TND_ClockMajor(void) ICODE_ATTR; | 1121 | static void Wave_TND_ClockMajor(void) ICODE_ATTR; |
1118 | void Wave_TND_ClockMajor() | 1122 | static void Wave_TND_ClockMajor() |
1119 | #else | 1123 | #else |
1120 | inline void Wave_TND_ClockMajor(void); | 1124 | static inline void Wave_TND_ClockMajor(void); |
1121 | inline void Wave_TND_ClockMajor() | 1125 | static 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 |
1155 | void Wave_TND_ClockMinor(void) ICODE_ATTR; | 1159 | static void Wave_TND_ClockMinor(void) ICODE_ATTR; |
1156 | void Wave_TND_ClockMinor() | 1160 | static void Wave_TND_ClockMinor() |
1157 | #else | 1161 | #else |
1158 | inline void Wave_TND_ClockMinor(void); | 1162 | static inline void Wave_TND_ClockMinor(void); |
1159 | inline void Wave_TND_ClockMinor() | 1163 | static 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 */ |
1179 | uint8_t pRAM[0x800] IBSS_ATTR_NSF_LARGE_IRAM MEM_ALIGN_ATTR; | 1183 | static 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) */ |
1181 | uint8_t pSRAM[0x2000] IBSS_ATTR_NSF_LARGE_IRAM MEM_ALIGN_ATTR; | 1185 | static 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) */ |
1184 | uint8_t pExRAM[0x1000] IBSS_ATTR_NSF_LARGE_IRAM MEM_ALIGN_ATTR; | 1188 | static uint8_t pExRAM[0x1000] IBSS_ATTR_NSF_LARGE_IRAM MEM_ALIGN_ATTR; |
1185 | /* Full ROM buffer */ | 1189 | /* Full ROM buffer */ |
1186 | uint8_t* pROM_Full IDATA_ATTR; | 1190 | static uint8_t* pROM_Full IDATA_ATTR; |
1187 | 1191 | ||
1188 | uint16_t main_nOutputTable_L[0x8000] MEM_ALIGN_ATTR; | 1192 | static uint16_t main_nOutputTable_L[0x8000] MEM_ALIGN_ATTR; |
1189 | 1193 | ||
1190 | uint8_t* pROM[10] IDATA_ATTR;/* ROM banks (point to areas in pROM_Full) */ | 1194 | static 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) */ |
1193 | uint8_t* pStack; /* the stack (points to areas in pRAM) */ | 1197 | static uint8_t* pStack; /* the stack (points to areas in pRAM) */ |
1194 | /* 0x0100 - 0x01FF */ | 1198 | /* 0x0100 - 0x01FF */ |
1195 | 1199 | ||
1196 | int32_t nROMSize; /* size of this ROM file in bytes */ | 1200 | static int32_t nROMSize; /* size of this ROM file in bytes */ |
1197 | int32_t nROMBankCount; /* max number of 4k banks */ | 1201 | static int32_t nROMBankCount; /* max number of 4k banks */ |
1198 | int32_t nROMMaxSize; /* size of allocated pROM_Full buffer */ | 1202 | static 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 | ||
1204 | typedef uint8_t ( *ReadProc)(uint16_t); | 1208 | typedef uint8_t ( *ReadProc)(uint16_t); |
1205 | typedef void ( *WriteProc)(uint16_t,uint8_t); | 1209 | typedef void ( *WriteProc)(uint16_t,uint8_t); |
1206 | ReadProc ReadMemory[0x10] IDATA_ATTR MEM_ALIGN_ATTR; | 1210 | static ReadProc ReadMemory[0x10] IDATA_ATTR MEM_ALIGN_ATTR; |
1207 | WriteProc WriteMemory[0x10] IDATA_ATTR MEM_ALIGN_ATTR; | 1211 | static WriteProc WriteMemory[0x10] IDATA_ATTR MEM_ALIGN_ATTR; |
1208 | 1212 | ||
1209 | /* | 1213 | /* |
1210 | * 6502 Registers / Mode | 1214 | * 6502 Registers / Mode |
1211 | */ | 1215 | */ |
1212 | 1216 | ||
1213 | uint8_t regA IDATA_ATTR; /* Accumulator */ | 1217 | static uint8_t regA IDATA_ATTR; /* Accumulator */ |
1214 | uint8_t regX IDATA_ATTR; /* X-Index */ | 1218 | static uint8_t regX IDATA_ATTR; /* X-Index */ |
1215 | uint8_t regY IDATA_ATTR; /* Y-Index */ | 1219 | static uint8_t regY IDATA_ATTR; /* Y-Index */ |
1216 | uint8_t regP IDATA_ATTR; /* Processor Status */ | 1220 | static uint8_t regP IDATA_ATTR; /* Processor Status */ |
1217 | uint8_t regSP IDATA_ATTR; /* Stack Pointer */ | 1221 | static uint8_t regSP IDATA_ATTR; /* Stack Pointer */ |
1218 | uint16_t regPC IDATA_ATTR; /* Program Counter */ | 1222 | static uint16_t regPC IDATA_ATTR; /* Program Counter */ |
1219 | 1223 | ||
1220 | uint8_t bPALMode IDATA_ATTR;/* 1 if in PAL emulation mode, 0 if in NTSC */ | 1224 | static uint8_t bPALMode IDATA_ATTR;/* 1 if in PAL emulation mode, 0 if in NTSC */ |
1221 | uint8_t bCPUJammed IDATA_ATTR; /* 0 = not jammed. 1 = really jammed. | 1225 | static 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) */ |
1227 | uint8_t nMultIn_Low; | 1231 | static uint8_t nMultIn_Low; |
1228 | uint8_t nMultIn_High; | 1232 | static uint8_t nMultIn_High; |
1229 | 1233 | ||
1230 | /* | 1234 | /* |
1231 | * NSF Preparation Information | 1235 | * NSF Preparation Information |
1232 | */ | 1236 | */ |
1233 | 1237 | ||
1234 | uint8_t nBankswitchInitValues[10]; /* banks to swap to on tune init */ | 1238 | static uint8_t nBankswitchInitValues[10]; /* banks to swap to on tune init */ |
1235 | uint16_t nPlayAddress; /* Play routine address */ | 1239 | static uint16_t nPlayAddress; /* Play routine address */ |
1236 | uint16_t nInitAddress; /* Init routine address */ | 1240 | static uint16_t nInitAddress; /* Init routine address */ |
1237 | 1241 | ||
1238 | uint8_t nExternalSound; /* external sound chips */ | 1242 | static uint8_t nExternalSound; /* external sound chips */ |
1239 | uint8_t nCurTrack; | 1243 | static uint8_t nCurTrack; |
1240 | 1244 | ||
1241 | float fNSFPlaybackSpeed; | 1245 | static float fNSFPlaybackSpeed; |
1242 | 1246 | ||
1243 | /* | 1247 | /* |
1244 | * pAPU | 1248 | * pAPU |
1245 | */ | 1249 | */ |
1246 | 1250 | ||
1247 | uint8_t nFrameCounter; /* Frame Sequence Counter */ | 1251 | static uint8_t nFrameCounter; /* Frame Sequence Counter */ |
1248 | uint8_t nFrameCounterMax; /* Frame Sequence Counter Size | 1252 | static uint8_t nFrameCounterMax; /* Frame Sequence Counter Size |
1249 | (3 or 4 depending on $4017.7) */ | 1253 | (3 or 4 depending on $4017.7) */ |
1250 | uint8_t bFrameIRQEnabled; /* TRUE if frame IRQs are enabled */ | 1254 | static uint8_t bFrameIRQEnabled; /* TRUE if frame IRQs are enabled */ |
1251 | uint8_t bFrameIRQPending; /* TRUE if the frame sequencer is holding down | 1255 | static uint8_t bFrameIRQPending; /* TRUE if the frame sequencer is |
1252 | an IRQ */ | 1256 | holding down an IRQ */ |
1253 | 1257 | ||
1254 | uint8_t nFME07_Address; | 1258 | static 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 | ||
1261 | int32_t nTicksUntilNextFrame; | 1265 | static int32_t nTicksUntilNextFrame; |
1262 | int32_t nTicksPerPlay; | 1266 | static int32_t nTicksPerPlay; |
1263 | int32_t nTicksUntilNextPlay; | 1267 | static int32_t nTicksUntilNextPlay; |
1264 | int32_t nTicksPerSample; | 1268 | static int32_t nTicksPerSample; |
1265 | int32_t nTicksUntilNextSample; | 1269 | static int32_t nTicksUntilNextSample; |
1266 | 1270 | ||
1267 | uint32_t nCPUCycle IDATA_ATTR; | 1271 | static uint32_t nCPUCycle IDATA_ATTR; |
1268 | uint32_t nAPUCycle IDATA_ATTR; | 1272 | static uint32_t nAPUCycle IDATA_ATTR; |
1269 | 1273 | ||
1270 | 1274 | ||
1271 | uint32_t nTotalPlays; /* number of times the play subroutine has been called | 1275 | static 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 | */ |
1276 | int32_t nSilentSamples; | 1280 | static int32_t nSilentSamples; |
1277 | int32_t nSilentSampleMax; | 1281 | static int32_t nSilentSampleMax; |
1278 | int32_t nSilenceTrackMS; | 1282 | static int32_t nSilenceTrackMS; |
1279 | uint8_t bNoSilenceIfTime; | 1283 | static uint8_t bNoSilenceIfTime; |
1280 | uint8_t bTimeNotDefault; | 1284 | static uint8_t bTimeNotDefault; |
1281 | 1285 | ||
1282 | /* | 1286 | /* |
1283 | * Sound output options | 1287 | * Sound output options |
1284 | */ | 1288 | */ |
1285 | const int32_t nSampleRate=44100; | 1289 | static const int32_t nSampleRate=44100; |
1286 | 1290 | ||
1287 | /* | 1291 | /* |
1288 | * Volume/fading/filter tracking | 1292 | * Volume/fading/filter tracking |
1289 | */ | 1293 | */ |
1290 | 1294 | ||
1291 | uint32_t nStartFade; /* play call to start fading out */ | 1295 | static uint32_t nStartFade; /* play call to start fading out */ |
1292 | uint32_t nEndFade; /* play call to stop fading out (song is over) */ | 1296 | static uint32_t nEndFade; /* play call to stop fading out (song is over) */ |
1293 | uint8_t bFade; /* are we fading? */ | 1297 | static uint8_t bFade; /* are we fading? */ |
1294 | float fFadeVolume; | 1298 | static float fFadeVolume; |
1295 | float fFadeChange; | 1299 | static float fFadeChange; |
1296 | 1300 | ||
1297 | /* | 1301 | /* |
1298 | * Designated Output Buffer | 1302 | * Designated Output Buffer |
1299 | */ | 1303 | */ |
1300 | uint8_t* pOutput IDATA_ATTR; | 1304 | static uint8_t* pOutput IDATA_ATTR; |
1301 | 1305 | ||
1302 | const uint8_t bDMCPopReducer=1; | 1306 | static const uint8_t bDMCPopReducer=1; |
1303 | uint8_t nDMCPop_Prev IDATA_ATTR = 0; | 1307 | static uint8_t nDMCPop_Prev IDATA_ATTR = 0; |
1304 | uint8_t bDMCPop_Skip IDATA_ATTR = 0; | 1308 | static uint8_t bDMCPop_Skip IDATA_ATTR = 0; |
1305 | uint8_t bDMCPop_SamePlay IDATA_ATTR = 0; | 1309 | static uint8_t bDMCPop_SamePlay IDATA_ATTR = 0; |
1306 | 1310 | ||
1307 | const uint8_t nForce4017Write=0; | 1311 | static const uint8_t nForce4017Write=0; |
1308 | const uint8_t bN106PopReducer=0; | 1312 | static const uint8_t bN106PopReducer=0; |
1309 | const uint8_t bIgnore4011Writes=0; | 1313 | static const uint8_t bIgnore4011Writes=0; |
1310 | 1314 | ||
1311 | const uint8_t bIgnoreBRK=0; | 1315 | static const uint8_t bIgnoreBRK=0; |
1312 | const uint8_t bIgnoreIllegalOps=0; | 1316 | static const uint8_t bIgnoreIllegalOps=0; |
1313 | const uint8_t bNoWaitForReturn=0; | 1317 | static const uint8_t bNoWaitForReturn=0; |
1314 | const uint8_t bPALPreference=0; | 1318 | static const uint8_t bPALPreference=0; |
1315 | const uint8_t bCleanAXY=0; | 1319 | static const uint8_t bCleanAXY=0; |
1316 | const uint8_t bResetDuty=0; | 1320 | static const uint8_t bResetDuty=0; |
1317 | 1321 | ||
1318 | /* | 1322 | /* |
1319 | * Sound Filter | 1323 | * Sound Filter |
1320 | */ | 1324 | */ |
1321 | 1325 | ||
1322 | int64_t nFilterAccL IDATA_ATTR; | 1326 | static int64_t nFilterAccL IDATA_ATTR; |
1323 | int64_t nHighPass IDATA_ATTR; | 1327 | static int64_t nHighPass IDATA_ATTR; |
1324 | 1328 | ||
1325 | int32_t nHighPassBase IDATA_ATTR; | 1329 | static int32_t nHighPassBase IDATA_ATTR; |
1326 | 1330 | ||
1327 | uint8_t bHighPassEnabled IDATA_ATTR; | 1331 | static 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 | ||
1347 | uint32_t Emulate6502(uint32_t runto) ICODE_ATTR; | 1351 | static uint32_t Emulate6502(uint32_t runto) ICODE_ATTR; |
1348 | void EmulateAPU(uint8_t bBurnCPUCycles) ICODE_ATTR; | 1352 | static void EmulateAPU(uint8_t bBurnCPUCycles) ICODE_ATTR; |
1349 | 1353 | ||
1350 | int NSFCore_Initialize(void); /* 1 = initialized ok, | 1354 | static 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 | */ |
1356 | int LoadNSF(int32_t); /* grab data from an existing file | 1360 | static 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 | */ |
1362 | void SetTrack(uint8_t track); /* Change tracks */ | 1366 | static 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 */ |
1368 | int32_t GetSamples(uint8_t* buffer, int32_t buffersize); | 1372 | static 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) */ |
1374 | int SetPlaybackOptions(int32_t samplerate); | 1378 | static int SetPlaybackOptions(int32_t samplerate); |
1375 | /* Speed throttling (0 = uses NSF specified speed) */ | 1379 | /* Speed throttling (0 = uses NSF specified speed) */ |
1376 | void SetPlaybackSpeed(float playspersec); | 1380 | static void SetPlaybackSpeed(float playspersec); |
1377 | 1381 | ||
1378 | float GetPlaybackSpeed(void); | 1382 | static float GetPlaybackSpeed(void); |
1379 | float GetMasterVolume(void); | 1383 | /* rockbox: not used |
1384 | float 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); | |||
1391 | void SetPlayCalls(float plays); | 1398 | void SetPlayCalls(float plays); |
1392 | /* sets the written time (approx. seeking) */ | 1399 | /* sets the written time (approx. seeking) */ |
1393 | void SetWrittenTime(uint32_t ms,float basedplays); | 1400 | void SetWrittenTime(uint32_t ms,float basedplays); |
1401 | #endif | ||
1394 | 1402 | ||
1395 | /* | 1403 | /* |
1396 | * Fading | 1404 | * Fading |
1397 | */ | 1405 | */ |
1398 | 1406 | ||
1399 | void StopFade(void); /* stops all fading (plays indefinitely) */ | 1407 | /* rockbox: not used |
1400 | uint8_t SongCompleted(void); /* song has faded out (samples have stopped | 1408 | void StopFade(void); */ /* stops all fading (plays indefinitely) */ |
1401 | being generated) */ | 1409 | static uint8_t SongCompleted(void); /* song has faded out (samples have |
1410 | stopped being generated) */ | ||
1402 | /* parameters are play calls */ | 1411 | /* parameters are play calls */ |
1403 | void SetFade(int32_t fadestart,int32_t fadestop,uint8_t bNotDefault); | 1412 | static void SetFade(int32_t fadestart,int32_t fadestop,uint8_t bNotDefault); |
1404 | void SetFadeTime(uint32_t fadestart,uint32_t fadestop,float basedplays, | 1413 | static 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 | */ |
1410 | void RebuildOutputTables(void); | 1420 | static void RebuildOutputTables(void); |
1411 | void RecalculateFade(void); /* called when fade status is changed. */ | 1421 | static void RecalculateFade(void); /* called when fade status is changed. */ |
1412 | void RecalcFilter(void); | 1422 | static void RecalcFilter(void); |
1413 | void RecalcSilenceTracker(void); | 1423 | static void RecalcSilenceTracker(void); |
1414 | 1424 | ||
1415 | void WriteMemory_VRC6(uint16_t a,uint8_t v) ICODE_ATTR; | 1425 | static void WriteMemory_VRC6(uint16_t a,uint8_t v) ICODE_ATTR; |
1416 | void WriteMemory_MMC5(uint16_t a,uint8_t v) ICODE_ATTR; | 1426 | static void WriteMemory_MMC5(uint16_t a,uint8_t v) ICODE_ATTR; |
1417 | void WriteMemory_N106(uint16_t a,uint8_t v) ICODE_ATTR; | 1427 | static void WriteMemory_N106(uint16_t a,uint8_t v) ICODE_ATTR; |
1418 | void WriteMemory_FME07(uint16_t a,uint8_t v) ICODE_ATTR; | 1428 | static 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 | ||
1424 | uint8_t ReadMemory_RAM(uint16_t a) ICODE_ATTR; | 1434 | static uint8_t ReadMemory_RAM(uint16_t a) ICODE_ATTR; |
1425 | uint8_t ReadMemory_ExRAM(uint16_t a) ICODE_ATTR; | 1435 | static uint8_t ReadMemory_ExRAM(uint16_t a) ICODE_ATTR; |
1426 | uint8_t ReadMemory_SRAM(uint16_t a) ICODE_ATTR; | 1436 | static uint8_t ReadMemory_SRAM(uint16_t a) ICODE_ATTR; |
1427 | uint8_t ReadMemory_pAPU(uint16_t a) ICODE_ATTR; | 1437 | static uint8_t ReadMemory_pAPU(uint16_t a) ICODE_ATTR; |
1428 | uint8_t ReadMemory_ROM(uint16_t a) ICODE_ATTR; | 1438 | static uint8_t ReadMemory_ROM(uint16_t a) ICODE_ATTR; |
1429 | uint8_t ReadMemory_Default(uint16_t a) ICODE_ATTR; | 1439 | static uint8_t ReadMemory_Default(uint16_t a) ICODE_ATTR; |
1430 | 1440 | ||
1431 | uint8_t ReadMemory_N106(uint16_t a) ICODE_ATTR; | 1441 | static uint8_t ReadMemory_N106(uint16_t a) ICODE_ATTR; |
1432 | 1442 | ||
1433 | void WriteMemory_RAM(uint16_t a,uint8_t v) ICODE_ATTR; | 1443 | static void WriteMemory_RAM(uint16_t a,uint8_t v) ICODE_ATTR; |
1434 | void WriteMemory_ExRAM(uint16_t a,uint8_t v) ICODE_ATTR; | 1444 | static void WriteMemory_ExRAM(uint16_t a,uint8_t v) ICODE_ATTR; |
1435 | void WriteMemory_SRAM(uint16_t a,uint8_t v) ICODE_ATTR; | 1445 | static void WriteMemory_SRAM(uint16_t a,uint8_t v) ICODE_ATTR; |
1436 | void WriteMemory_pAPU(uint16_t a,uint8_t v) ICODE_ATTR; | 1446 | static void WriteMemory_pAPU(uint16_t a,uint8_t v) ICODE_ATTR; |
1437 | void WriteMemory_FDSRAM(uint16_t a,uint8_t v) ICODE_ATTR; | 1447 | static void WriteMemory_FDSRAM(uint16_t a,uint8_t v) ICODE_ATTR; |
1438 | void WriteMemory_Default(uint16_t a,uint8_t v) ICODE_ATTR; | 1448 | static void WriteMemory_Default(uint16_t a,uint8_t v) ICODE_ATTR; |
1439 | 1449 | ||
1440 | uint8_t ReadMemory_RAM(uint16_t a) { return pRAM[a & 0x07FF]; } | 1450 | static uint8_t ReadMemory_RAM(uint16_t a) { return pRAM[a & 0x07FF]; } |
1441 | uint8_t ReadMemory_ExRAM(uint16_t a) { return pExRAM[a & 0x0FFF]; } | 1451 | static uint8_t ReadMemory_ExRAM(uint16_t a) { return pExRAM[a & 0x0FFF]; } |
1442 | uint8_t ReadMemory_SRAM(uint16_t a) { return pSRAM[a & 0x1FFF]; } | 1452 | static uint8_t ReadMemory_SRAM(uint16_t a) { return pSRAM[a & 0x1FFF]; } |
1443 | uint8_t ReadMemory_ROM(uint16_t a) | 1453 | static uint8_t ReadMemory_ROM(uint16_t a) |
1444 | { return pROM[(a >> 12) - 6][a & 0x0FFF]; } | 1454 | { return pROM[(a >> 12) - 6][a & 0x0FFF]; } |
1445 | uint8_t ReadMemory_Default(uint16_t a) { return (a >> 8); } | 1455 | static uint8_t ReadMemory_Default(uint16_t a) { return (a >> 8); } |
1446 | 1456 | ||
1447 | void WriteMemory_RAM(uint16_t a,uint8_t v) | 1457 | static void WriteMemory_RAM(uint16_t a,uint8_t v) |
1448 | { pRAM[a & 0x07FF] = v; } | 1458 | { pRAM[a & 0x07FF] = v; } |
1449 | void WriteMemory_ExRAM(uint16_t a,uint8_t v); | 1459 | static void WriteMemory_ExRAM(uint16_t a,uint8_t v); |
1450 | void WriteMemory_SRAM(uint16_t a,uint8_t v) | 1460 | static void WriteMemory_SRAM(uint16_t a,uint8_t v) |
1451 | { pSRAM[a & 0x1FFF] = v; } | 1461 | { pSRAM[a & 0x1FFF] = v; } |
1452 | void WriteMemory_FDSRAM(uint16_t a,uint8_t v) | 1462 | static 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; } |
1454 | void WriteMemory_Default(uint16_t a,uint8_t v) { (void)a; (void)v; } | 1464 | static 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 | ||
1459 | uint8_t ReadMemory_pAPU(uint16_t a) | 1469 | static 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 | ||
1492 | uint8_t ReadMemory_N106(uint16_t a) | 1502 | static 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 | ||
1508 | void WriteMemory_ExRAM(uint16_t a,uint8_t v) | 1518 | static 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 | ||
1529 | void WriteMemory_pAPU(uint16_t a,uint8_t v) | 1539 | static 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 | ||
1878 | void WriteMemory_VRC6(uint16_t a,uint8_t v) | 1888 | static 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 | ||
1941 | void WriteMemory_MMC5(uint16_t a,uint8_t v) | 1951 | static 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 | ||
1971 | void WriteMemory_N106(uint16_t a,uint8_t v) | 1981 | static 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 | ||
2043 | void WriteMemory_FME07(uint16_t a,uint8_t v) | 2053 | static 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 | ||
2076 | int32_t fulltick; | 2086 | static int32_t fulltick; |
2077 | void EmulateAPU(uint8_t bBurnCPUCycles) | 2087 | static 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 | ||
2595 | int NSFCore_Initialize() | 2605 | static 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 | ||
2754 | int LoadNSF(int32_t datasize) | 2764 | static 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 | ||
2928 | void SetTrack(uint8_t track) | 2938 | static 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 | ||
3057 | int SetPlaybackOptions(int32_t samplerate) | 3067 | static 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 | ||
3076 | void SetPlaybackSpeed(float playspersec) | 3086 | static 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 | ||
3091 | float GetPlaybackSpeed() | 3101 | static 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 | ||
3101 | void RecalcFilter() | 3111 | static 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 | ||
3114 | void RecalcSilenceTracker() | 3124 | static 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 | ||
3127 | void RebuildOutputTables(void) { | 3137 | static 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 | ||
3265 | uint8_t SongCompleted() | 3278 | static 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 | ||
3278 | void SetFade(int32_t fadestart,int32_t fadestop, | 3291 | static 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 | ||
3297 | void SetFadeTime(uint32_t fadestart,uint32_t fadestop,float basedplays, | 3310 | static 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 | ||
3313 | void RecalculateFade() | 3326 | static 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 | ||
3345 | int32_t GetSamples(uint8_t* buffer,int32_t buffersize) | 3358 | static 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 | ||
3808 | union TWIN front; | 3821 | static uint8_t val; |
3809 | union TWIN final; | 3822 | static uint8_t op; |
3810 | uint8_t val; | ||
3811 | uint8_t op; | ||
3812 | 3823 | ||
3813 | uint32_t Emulate6502(uint32_t runto) | 3824 | static 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) |