aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXaviDCR92 <xavi.dcr@gmail.com>2018-03-22 20:50:53 +0100
committerXaviDCR92 <xavi.dcr@gmail.com>2018-03-22 20:50:53 +0100
commit4887461e35b64c697cbabaf0268c77ae68576c5e (patch)
tree60b379f5683c1b2065ca03803cf6b3ffab31b81b
parent34c8910b9ff33d50d642fda24c78d88595a59aa6 (diff)
* Increased number of events on SYSTEM.CNF.
Minor changes?
-rw-r--r--Bin/AIRPORT.binbin1707552 -> 1709904 bytes
-rwxr-xr-xSource/Exe/AIRPORT.elfbin449640 -> 450040 bytes
-rw-r--r--Source/Exe/AIRPORT.isobin1486848 -> 1488896 bytes
-rw-r--r--Source/Sfx.c80
-rw-r--r--Source/Sfx.h4
-rw-r--r--Source/System.c9
-rw-r--r--cdimg/SYSTEM.CNF2
7 files changed, 64 insertions, 31 deletions
diff --git a/Bin/AIRPORT.bin b/Bin/AIRPORT.bin
index 96906d4..a284924 100644
--- a/Bin/AIRPORT.bin
+++ b/Bin/AIRPORT.bin
Binary files differ
diff --git a/Source/Exe/AIRPORT.elf b/Source/Exe/AIRPORT.elf
index f3b7219..97b999e 100755
--- a/Source/Exe/AIRPORT.elf
+++ b/Source/Exe/AIRPORT.elf
Binary files differ
diff --git a/Source/Exe/AIRPORT.iso b/Source/Exe/AIRPORT.iso
index 7eac31a..9fb2569 100644
--- a/Source/Exe/AIRPORT.iso
+++ b/Source/Exe/AIRPORT.iso
Binary files differ
diff --git a/Source/Sfx.c b/Source/Sfx.c
index 4e6d324..2f8a565 100644
--- a/Source/Sfx.c
+++ b/Source/Sfx.c
@@ -7,8 +7,6 @@
* Defines
* *************************************/
#define MAX_VOLUME SPU_MAXVOL
-#define SILENT 0
-
#define NUMBER_OF_VOICES 24
/* *************************************
@@ -18,14 +16,14 @@
/* *************************************
* Local Variables
* *************************************/
-static uint8_t voiceIndex;
static uint16_t SfxGlobalVolumeReduction;
+static bool usedVoices[NUMBER_OF_VOICES];
#ifndef NO_CDDA
static uint16_t SfxCddaVolumeReduction;
#endif // NO_CDDA
-void SfxPlaySound(SsVag * sound)
+void SfxPlaySound(SsVag* sound)
{
if (sound->data_size != 0)
{
@@ -33,48 +31,76 @@ void SfxPlaySound(SsVag * sound)
}
}
-bool SfxUploadSound(char* file_path, SsVag * vag)
+bool SfxUploadSound_Ex(char* file_path, SsVag* vag, uint8_t voiceIndex)
{
- static size_t SPUBytesUsed;
+ static size_t SPUBytesUsed;
- if (SystemLoadFile(file_path) == false)
+ if (voiceIndex >= NUMBER_OF_VOICES)
{
+ Serial_printf( "Invalid input voice index %d. Only indexes [%d-%d] are allowed.\n",
+ voiceIndex,
+ 0,
+ NUMBER_OF_VOICES - 1 );
return false;
}
- if (voiceIndex < NUMBER_OF_VOICES)
+ if (usedVoices[voiceIndex] != false)
{
- SsReadVag(vag,SystemGetBufferAddress());
+ Serial_printf("Voice number %d is already being used.\n", voiceIndex);
+ return false;
+ }
- SsUploadVag(vag);
+ if (SystemLoadFile(file_path) == false)
+ {
+ return false;
+ }
- vag->cur_voice = voiceIndex;
+ SsReadVag(vag, SystemGetBufferAddress());
- voiceIndex++;
+ SsUploadVag(vag);
- Serial_printf("SPU voices used = %d\n", voiceIndex);
+ vag->cur_voice = voiceIndex;
- SPUBytesUsed += vag->data_size;
+ usedVoices[voiceIndex] = true;
- if (SPUBytesUsed != 0)
- {
- enum
- {
- SPU_MAX_ALLOWED_BYTES = 512 * 1024 // 512 KBytes
- };
+ SPUBytesUsed += vag->data_size;
- uint16_t percentage = SPUBytesUsed * 100 / SPU_MAX_ALLOWED_BYTES;
+ if (SPUBytesUsed != 0)
+ {
+ enum
+ {
+ SPU_MAX_ALLOWED_BYTES = 512 * 1024 // 512 KBytes
+ };
- dprintf("SPU usage: %d%%\n", percentage);
- }
+ uint16_t percentage = SPUBytesUsed * 100 / SPU_MAX_ALLOWED_BYTES;
+
+ dprintf("SPU usage: %d%%\n", percentage);
}
- else
+
+ return true;
+}
+
+bool SfxUploadSound(char* file_path, SsVag* vag)
+{
+ bool success = false;
+ uint8_t i;
+
+ for (i = 0; i < NUMBER_OF_VOICES; i++)
+ {
+ if (usedVoices[i] == false)
+ {
+ success = true;
+ break;
+ }
+ }
+
+ if (success == false)
{
- Serial_printf("Maximum number of SPU voices exceeded!\n");
- return false; //Maximum voices exceeded
+ Serial_printf("Could not find any free SPU slot.\n");
+ return false;
}
- return true;
+ return SfxUploadSound_Ex(file_path, vag, i);
}
void SfxPlayTrack(MUSIC_TRACKS track)
diff --git a/Source/Sfx.h b/Source/Sfx.h
index 4c248c7..4a7d176 100644
--- a/Source/Sfx.h
+++ b/Source/Sfx.h
@@ -25,8 +25,8 @@ typedef enum t_musicTracks
/* *************************************
* Global prototypes
* *************************************/
-void SfxPlaySound(SsVag * sound);
-bool SfxUploadSound(char* file_path, SsVag * vag);
+void SfxPlaySound(SsVag* sound);
+bool SfxUploadSound(char* file_path, SsVag* vag);
void SfxPlayTrack(MUSIC_TRACKS track);
void SfxStopMusic(void);
diff --git a/Source/System.c b/Source/System.c
index 864e2fc..2a3513a 100644
--- a/Source/System.c
+++ b/Source/System.c
@@ -67,6 +67,11 @@ static unsigned char sine_counter;
* *******************************************************************/
void SystemInit(void)
{
+ enum
+ {
+ RCNT2_100US_TICK_COUNTER = 0xA560
+ };
+
//Reset global timer
global_timer = 0;
//Reset 1 second timer
@@ -118,7 +123,9 @@ void SystemInit(void)
SystemSetStackPattern();
- SetRCntHandler(&ISR_RootCounter2, 2, 0xA560);
+ // Configure root counter 2 so that ISR_RootCounter2
+ // is executed every 100 us.
+ SetRCntHandler(&ISR_RootCounter2, 2, RCNT2_100US_TICK_COUNTER);
SystemEnableRCnt2Interrupt();
}
diff --git a/cdimg/SYSTEM.CNF b/cdimg/SYSTEM.CNF
index c803e3e..331e5a2 100644
--- a/cdimg/SYSTEM.CNF
+++ b/cdimg/SYSTEM.CNF
@@ -1,4 +1,4 @@
BOOT = cdrom:\AIRPORT.EXE;1
TCB = 4
-EVENT = 7
+EVENT = 8
STACK = 801FF800