* 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.
This commit is contained in:
XaviDCR92 2018-03-17 01:43:53 +01:00
parent be36d09ae7
commit 51d4c1ea89
9 changed files with 51 additions and 51 deletions

View File

@ -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

View File

@ -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();
}
}

Binary file not shown.

Binary file not shown.

View File

@ -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

View File

@ -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>

View File

@ -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
}

View File

@ -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);
}
/* ****************************************************************************************

View File

@ -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);