aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXaviDCR92 <xavi.dcr@gmail.com>2018-03-17 01:43:53 +0100
committerXaviDCR92 <xavi.dcr@gmail.com>2018-03-17 01:43:53 +0100
commit51d4c1ea89c7de9841d37505f9b780de70c696f2 (patch)
tree0b49df5082a68fef97903eb7b7d6b4921277a6cd
parentbe36d09ae70587f2ccb73906e895914421f336ff (diff)
* System.c: Root counters are finally working, YAY!
* Sfx.c: SfxStopMusic() was relying on global timer to be increased under ISR, but this is not true anymore! * Other minor changes on EndAnimation.c.
-rw-r--r--Sounds/SOUND_SOURCES.txt (renamed from Sounds/SOUND_SOURCES)2
-rw-r--r--Source/EndAnimation.c21
-rw-r--r--Source/Exe/AIRPORT.elfbin332120 -> 448856 bytes
-rw-r--r--Source/Exe/AIRPORT.isobin1484800 -> 1486848 bytes
-rw-r--r--Source/Makefile27
-rw-r--r--Source/MapEditor/MapEditor.pro.user2
-rw-r--r--Source/Sfx.c23
-rw-r--r--Source/System.c24
-rw-r--r--Source/System.h3
9 files changed, 51 insertions, 51 deletions
diff --git a/Sounds/SOUND_SOURCES b/Sounds/SOUND_SOURCES.txt
index 0130824..d8cce56 100644
--- a/Sounds/SOUND_SOURCES
+++ b/Sounds/SOUND_SOURCES.txt
@@ -19,7 +19,7 @@ http://freesound.org/people/jobro/sounds/33778/
R C P M 1 A 1
| | | | | | V
| | | | | V Message number
-| | | | V A = Approach, D = Departure
+| | | | V A = Approach, D = Departure, F = Final, T = Taxi
| | | V Voice number
| | V M = Man, W = Woma
| V P = Pilot, T = Tower
diff --git a/Source/EndAnimation.c b/Source/EndAnimation.c
index 75edc85..21d23e3 100644
--- a/Source/EndAnimation.c
+++ b/Source/EndAnimation.c
@@ -48,8 +48,6 @@ static GsSprite EndAnimationDisplay;
void EndAnimation(void)
{
- uint8_t randIndex = 0;
-
GfxSaveDisplayData(&EndAnimationDisplay);
GfxSetGlobalLuminance(NORMAL_LUMINANCE);
@@ -61,7 +59,7 @@ void EndAnimation(void)
}
else
{
- randIndex = rand() % (END_ANIMATION_MAX_RAND_VALUE + 1);
+ uint8_t randIndex = SystemRand(END_ANIMATION_SQUARES, END_ANIMATION_MAX_RAND_VALUE);
switch(randIndex)
{
@@ -81,14 +79,12 @@ void EndAnimation(void)
break;
}
- SfxStopMusic();
+ //~ SfxStopMusic();
}
}
void EndAnimationFadeOut(void)
{
- uint8_t i;
-
while (1)
{
if ( GfxGetGlobalLuminance() > 0)
@@ -100,6 +96,8 @@ void EndAnimationFadeOut(void)
}
else
{
+ uint8_t i;
+
GsSortCls(0,0,0);
for (i = 0 ; i < 2 ; i++)
@@ -149,7 +147,10 @@ void EndAnimationLine(void)
void EndAnimationSquares(void)
{
- uint16_t i, j, k;
+ uint16_t i;
+ uint16_t j;
+ uint16_t k;
+
uint16_t randInd = 0;
bool sqPos[END_ANIMATION_SQUARES_TOTAL];
uint16_t sqCounter = END_ANIMATION_SQUARES_TOTAL;
@@ -171,9 +172,6 @@ void EndAnimationSquares(void)
{
randInd = SystemRand(0,maxIndex);
- /*Serial_printf("randInd = %d\t",randInd);
- Serial_printf("sqPos[randInd] = %d\n", sqPos[randInd]);*/
-
if (sqPos[randInd] == false)
{
sqPos[randInd] = true;
@@ -195,7 +193,6 @@ void EndAnimationSquares(void)
break;
}
}
-
}while (1);
GfxSortSprite(&EndAnimationDisplay);
@@ -223,7 +220,7 @@ void EndAnimationSquares(void)
for (k = 0 ; k < 2 ; k++)
{
// Draw two frames to ensure black display
- GsSortCls(0,0,0);
+ GsSortCls(0, 0, 0);
GfxDrawScene_Slow();
}
}
diff --git a/Source/Exe/AIRPORT.elf b/Source/Exe/AIRPORT.elf
index 57842aa..aa9aa15 100644
--- 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 6dea1b2..7967bab 100644
--- a/Source/Exe/AIRPORT.iso
+++ b/Source/Exe/AIRPORT.iso
Binary files differ
diff --git a/Source/Makefile b/Source/Makefile
index 9eeb9d0..f410b4b 100644
--- a/Source/Makefile
+++ b/Source/Makefile
@@ -12,8 +12,8 @@ GNU_SIZE = mipsel-unknown-elf-size
# Custom define flags for GCC
DEFINE= -DFIXMATH_FAST_SIN -D_PAL_MODE_
DEFINE += -DPSXSDK_DEBUG
-DEFINE += -DNO_CDDA
-DEFINE += -DNO_INTRO
+#DEFINE += -DNO_CDDA
+#DEFINE += -DNO_INTRO
# Compiler flags
LIBS= -lfixmath
@@ -56,9 +56,11 @@ OBJECTS = $(addprefix $(OBJ_DIR)/, main.o System.o Menu.o Gfx.o Pad.o MainMenuBt
DEPS = $(OBJECTS:.o=.d)
# CD-DA objects:
-MUSIC_TRACKS = --track=../Bin/TRACK01.bin --track=../Bin/TRACK02.bin --track=../Bin/TRACK03.bin
+MUSIC_OBJ_DIR = ../Bin
+MUSIC_SRC_DIR = ../Music
+MUSIC_TRACKS = $(addprefix $(MUSIC_OBJ_DIR)/, TRACK01.bin TRACK02.bin TRACK03.bin)
FFMPEG = ffmpeg
-FFMPEG_DIR = ../Music/ffmpeg/bin
+FFMPEG_DIR = $(MUSIC_SRC_DIR)/$(FFMPEG)/bin
FFMPEG_FLAGS = -f s16le -acodec pcm_s16le
# VAG objects:
@@ -110,12 +112,13 @@ SPRITE_OBJECTS = $(addprefix $(OBJ_SPRITES_PATH)/, PSXDISK.TIM \
SPRITE_OBJECTS += $(addprefix $(OBJ_FONTS_PATH)/, INTROFNT.TIM \
FONT_1.TIM \
FONT_2.TIM )
+# ------------------------------------
# Instructions
# ------------------------------------
-$(BIN_TARGET_PATH)/$(PROJECT).bin: $(EXE_PATH)/$(PROJECT).iso
-#~ mkpsxiso $< $@ $(LICENSE_FILE) $(MUSIC_TRACKS)
- mkpsxiso $< $@ $(LICENSE_FILE)
+$(BIN_TARGET_PATH)/$(PROJECT).bin: $(EXE_PATH)/$(PROJECT).iso $(MUSIC_TRACKS)
+ mkpsxiso $< $@ $(LICENSE_FILE) $(addprefix --track=, $(MUSIC_TRACKS))
+#~ mkpsxiso $< $@ $(LICENSE_FILE)
# $(PROJECT).cue is automatically generated by mkpsxiso
rebuild:
@@ -124,8 +127,6 @@ rebuild:
-include $(DEPS)
-music_objects: $(addprefix ../Music/, TRACK01.bin TRACK02.bin TRACK03.bin)
-
clean:
rm -f $(OBJ_DIR)/*.o
rm -f $(OBJ_SOUNDS_DIR)/*.VAG
@@ -173,12 +174,10 @@ $(OBJ_LEVELS_DIR)/%.LVL: $(SRC_LEVELS_DIR)/%.LVL
$(OBJ_LEVELS_DIR)/%.PLT: $(SRC_LEVELS_DIR)/%.PLT
cp $^ $@
-music: clean_music music_objects
+music: music_objects
-%.bin: %.mp3
- rm -f ../Bin/$@1
- $(FFMPEG) -i $< $(FFMPEG_FLAGS) $@
- cp ../Music/$@ ../Bin/
+$(MUSIC_OBJ_DIR)/%.bin: $(MUSIC_SRC_DIR)/%.mp3
+ $(FFMPEG_DIR)/$(FFMPEG) -i $< $(FFMPEG_FLAGS) $@
# ----------------------------------------
# Phony targets
diff --git a/Source/MapEditor/MapEditor.pro.user b/Source/MapEditor/MapEditor.pro.user
index 48e1dbc..7e982c4 100644
--- a/Source/MapEditor/MapEditor.pro.user
+++ b/Source/MapEditor/MapEditor.pro.user
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.0.3, 2018-02-23T20:22:49. -->
+<!-- Written by QtCreator 4.0.3, 2018-03-10T18:45:16. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
diff --git a/Source/Sfx.c b/Source/Sfx.c
index 48d6bed..4e6d324 100644
--- a/Source/Sfx.c
+++ b/Source/Sfx.c
@@ -14,6 +14,7 @@
/* *************************************
* Local Prototypes
* *************************************/
+
/* *************************************
* Local Variables
* *************************************/
@@ -79,7 +80,13 @@ bool SfxUploadSound(char* file_path, SsVag * vag)
void SfxPlayTrack(MUSIC_TRACKS track)
{
#ifndef NO_CDDA
- SsCdVol(0x7FFF - SfxCddaVolumeReduction,0x7FFF - SfxCddaVolumeReduction);
+ enum
+ {
+ CD_MAX_VOLUME = (uint16_t)0x7FFF
+ };
+
+ SsCdVol(CD_MAX_VOLUME - SfxCddaVolumeReduction,
+ CD_MAX_VOLUME - SfxCddaVolumeReduction);
SsEnableCd();
CdPlayTrack(track);
Serial_printf("Track number %d playing...\n",track);
@@ -89,20 +96,14 @@ void SfxPlayTrack(MUSIC_TRACKS track)
void SfxStopMusic(void)
{
#ifndef NO_CDDA
- uint64_t timer = SystemGetGlobalTimer();
uint16_t CDVol = 0x7FFF;
- uint8_t time_step = 5;
- while (CDVol > 0x3F)
+ while (CDVol > 0x003F)
{
- CDVol>>=1;
- SsCdVol(CDVol,CDVol);
-
- while (SystemGetGlobalTimer() < (timer + time_step) );
-
- timer = SystemGetGlobalTimer();
+ CDVol >>= 1;
+ SsCdVol(CDVol, CDVol);
}
CdSendCommand(CdlMute,0);
-#endif
+#endif // NO_CDDA
}
diff --git a/Source/System.c b/Source/System.c
index f47cbca..75a1010 100644
--- a/Source/System.c
+++ b/Source/System.c
@@ -118,16 +118,12 @@ void SystemInit(void)
SystemSetStackPattern();
- //SetRCntHandler(&ISR_RootCounter2, 2, 0xA560);
-
- Serial_printf("Begin SetRCntHandler\n");
- SetRCntHandler(&ISR_RootCounter2, 2, 0xFFFF);
- Serial_printf("End SetRCntHandler\n");
-
+ SetRCntHandler(&ISR_RootCounter2, 2, 0xA560);
SystemEnableRCnt2Interrupt();
}
static volatile uint16_t u16_0_01seconds_cnt;
+static volatile uint16_t u16_0_01seconds_cnt_prev;
/* *******************************************************************
*
@@ -142,6 +138,12 @@ static volatile uint16_t u16_0_01seconds_cnt;
void ISR_RootCounter2(void)
{
u16_0_01seconds_cnt++;
+
+ if ((int16_t)(u16_0_01seconds_cnt - 1000) >= (int16_t)(u16_0_01seconds_cnt_prev))
+ {
+ u16_0_01seconds_cnt_prev = u16_0_01seconds_cnt;
+ DEBUG_PRINT_VAR(u16_0_01seconds_cnt_prev);
+ }
}
/* *******************************************************************
@@ -335,14 +337,14 @@ void SystemIncreaseGlobalTimer(void)
/* *******************************************************************
*
- * @name: uint64_t SystemGetGlobalTimer(void)
+ * @name: volatile uint64_t SystemGetGlobalTimer(void)
*
* @author: Xavier Del Campo
*
* @brief: Returns internal global timer value.
*
* *******************************************************************/
-uint64_t SystemGetGlobalTimer(void)
+volatile uint64_t SystemGetGlobalTimer(void)
{
return global_timer;
}
@@ -525,6 +527,7 @@ bool SystemLoadFileToBuffer(char* fname, uint8_t* buffer, uint32_t szBuffer)
system_busy = true;
+ SystemDisableRCnt2Interrupt();
SystemDisableVBlankInterrupt();
f = fopen(fname, "r");
@@ -554,6 +557,7 @@ bool SystemLoadFileToBuffer(char* fname, uint8_t* buffer, uint32_t szBuffer)
fclose(f);
SystemEnableVBlankInterrupt();
+ SystemEnableRCnt2Interrupt();
system_busy = false;
@@ -640,7 +644,7 @@ uint32_t SystemRand(uint32_t min, uint32_t max)
{
if (rand_seed == false)
{
- Serial_printf("Warning: calling rand() before srand()\n");
+ //~ Serial_printf("Warning: calling rand() before srand()\n");
}
return rand() % (max - min + 1) + min;
@@ -1067,7 +1071,7 @@ void SystemEnableRCnt2Interrupt(void)
* ****************************************************************************************/
void SystemDisableRCnt2Interrupt(void)
{
- I_MASK &= ~(1<<6);
+ I_MASK &= ~(1 << 6);
}
/* ****************************************************************************************
diff --git a/Source/System.h b/Source/System.h
index 9b8dfe8..8519a43 100644
--- a/Source/System.h
+++ b/Source/System.h
@@ -70,8 +70,7 @@ void SystemSetEmergencyMode(bool value);
// Returns emergency mode flag state
bool SystemGetEmergencyMode(void);
-// (Experimental)
-uint64_t SystemGetGlobalTimer(void);
+volatile uint64_t SystemGetGlobalTimer(void);
// Returns whether critical section of code is being entered
volatile bool SystemIsBusy(void);