mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-30 15:14:18 +01:00
-slightly modified the makefile to hopefully get the default
theme images to work properly again
This commit is contained in:
parent
3d2363bd78
commit
cca5f4559e
469
Makefile.main
469
Makefile.main
@ -1,249 +1,220 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
# Clear the implicit built in rules
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(DEVKITPPC)),)
|
||||
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
|
||||
endif
|
||||
|
||||
include $(DEVKITPPC)/wii_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := boot
|
||||
BUILD := build
|
||||
SOURCES := source \
|
||||
source/banner \
|
||||
source/channel \
|
||||
source/cheats \
|
||||
source/config \
|
||||
source/data \
|
||||
source/devicemounter \
|
||||
source/devicemounter/libwbfs \
|
||||
source/fileOps \
|
||||
source/gc \
|
||||
source/gecko \
|
||||
source/gui \
|
||||
source/homebrew \
|
||||
source/libwbfs \
|
||||
source/list \
|
||||
source/loader \
|
||||
source/memory \
|
||||
source/menu \
|
||||
source/music \
|
||||
source/network \
|
||||
source/plugin \
|
||||
source/unzip \
|
||||
source/xml \
|
||||
source/wstringEx
|
||||
|
||||
DATA := data \
|
||||
data/images \
|
||||
data/sounds \
|
||||
data/help
|
||||
|
||||
INCLUDES := source
|
||||
#---------------------------------------------------------------------------------
|
||||
# Default build shell script options
|
||||
#---------------------------------------------------------------------------------
|
||||
ios := 249
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
CFLAGS = -g -O2 -Wall -Wextra -Wno-multichar $(MACHDEP) $(INCLUDE) -DHAVE_CONFIG_H
|
||||
CXXFLAGS = $(CFLAGS)
|
||||
|
||||
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80620000,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lcustomfat -lcustomntfs -lcustomext2fs -lpng -lm -lz -lwiiuse -lbte -lasnd -logc -lfreetype -lvorbisidec -lmad -ljpeg -lmodplay
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(CURDIR)/portlibs
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# automatically build a list of object files for our project
|
||||
#---------------------------------------------------------------------------------
|
||||
SVNREV := $(shell bash ./scripts/svnrev.sh)
|
||||
|
||||
export CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
export CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
|
||||
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
|
||||
|
||||
TXTFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.txt)))
|
||||
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin)))
|
||||
TTFFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.ttf)))
|
||||
PNGFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.png)))
|
||||
JPGFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.jpg)))
|
||||
|
||||
MP3FILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.mp3)))
|
||||
OGGFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.ogg)))
|
||||
PCMFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.pcm)))
|
||||
WAVFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.wav)))
|
||||
|
||||
DOLFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.dol)))
|
||||
ELFFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.elf)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
export LD := $(CC)
|
||||
else
|
||||
export LD := $(CXX)
|
||||
endif
|
||||
|
||||
export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
||||
$(sFILES:.s=.o) $(SFILES:.S=.o) \
|
||||
$(JPGFILES:.jpg=.jpg.o) $(PNGFILES:.png=.png.o) $(DOLFILES:.dol=.dol.o) \
|
||||
$(OGGFILES:.ogg=.ogg.o) $(WAVFILES:.wav=.wav.o) $(MP3FILES:.mp3=.mp3.o) \
|
||||
$(ELFFILES:.elf=.elf.o) $(BINFILES:.bin=.bin.o) $(TXTFILES:.txt=.txt.o) \
|
||||
$(CURDIR)/data/magic_patcher.o
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of include paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD) \
|
||||
-I$(LIBOGC_INC)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of library paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
||||
-L$(LIBOGC_LIB)
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
.PHONY: $(BUILD) all clean run
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD):
|
||||
@echo Building for IOS $(ios).
|
||||
@bash ./scripts/buildtype.sh $(ios)
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.main
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol $(CURDIR)/data/wiiflow_game_booter.dol \
|
||||
$(CURDIR)/source/loader/alt_ios_gen.c $(CURDIR)/source/svnrev.h
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
run:
|
||||
wiiload $(TARGET).dol
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
gdb:
|
||||
@echo Loading GDB with symbols from boot.elf, type quit to exit.
|
||||
@powerpc-eabi-gdb boot.elf
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
addr:
|
||||
@echo Loading addr2line with symbols from boot.elf..
|
||||
@echo Press ctrl+c to exit.
|
||||
@echo Enter an address from the stack dump:
|
||||
@powerpc-eabi-addr2line -f -e boot.elf
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
$(OUTPUT).dol: $(OUTPUT).elf
|
||||
$(OUTPUT).elf: $(OFILES) alt_ios_gen.o
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD)/alt_ios_gen.o: alt_ios_gen.c
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .txt extension
|
||||
#---------------------------------------------------------------------------------
|
||||
%.txt.o: %.txt
|
||||
@echo $(notdir $<)
|
||||
@bin2s $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .jpg extension
|
||||
#---------------------------------------------------------------------------------
|
||||
%.jpg.o : %.jpg
|
||||
@echo $(notdir $<)
|
||||
@bin2s $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .png extension
|
||||
#---------------------------------------------------------------------------------
|
||||
%.png.o : %.png
|
||||
@echo $(notdir $<)
|
||||
@bin2s $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .ogg extension
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ogg.o : %.ogg
|
||||
@echo $(notdir $<)
|
||||
@bin2s $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .wav extension
|
||||
#---------------------------------------------------------------------------------
|
||||
%.wav.o : %.wav
|
||||
@echo $(notdir $<)
|
||||
@bin2s $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .bin extension
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
@echo $(notdir $<)
|
||||
@bin2s $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .dol extension
|
||||
#---------------------------------------------------------------------------------
|
||||
%.dol.o : %.dol
|
||||
@echo $(notdir $<)
|
||||
@bin2s $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .elf extension
|
||||
#---------------------------------------------------------------------------------
|
||||
%.elf.o : %.elf
|
||||
@echo $(notdir $<)
|
||||
@bin2s $< | $(AS) -o $(@)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
#---------------------------------------------------------------------------------
|
||||
# Clear the implicit built in rules
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(DEVKITPPC)),)
|
||||
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
|
||||
endif
|
||||
|
||||
include $(DEVKITPPC)/wii_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := boot
|
||||
BUILD := build
|
||||
SOURCES := source \
|
||||
source/banner \
|
||||
source/channel \
|
||||
source/cheats \
|
||||
source/config \
|
||||
source/data \
|
||||
source/devicemounter \
|
||||
source/fileOps \
|
||||
source/gc \
|
||||
source/gecko \
|
||||
source/gui \
|
||||
source/homebrew \
|
||||
source/libwbfs \
|
||||
source/list \
|
||||
source/loader \
|
||||
source/memory \
|
||||
source/menu \
|
||||
source/music \
|
||||
source/network \
|
||||
source/plugin \
|
||||
source/unzip \
|
||||
source/xml \
|
||||
source/wstringEx
|
||||
|
||||
DATA := data \
|
||||
data/images \
|
||||
data/sounds \
|
||||
data/help
|
||||
|
||||
INCLUDES := source
|
||||
#---------------------------------------------------------------------------------
|
||||
# Default build shell script options
|
||||
#---------------------------------------------------------------------------------
|
||||
ios := 249
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
CFLAGS := -g -O2 -Wall -Wextra $(MACHDEP) $(INCLUDE) -DHAVE_CONFIG_H
|
||||
CXXFLAGS := $(CFLAGS)
|
||||
|
||||
LDFLAGS := -g $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80620000,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lcustomfat -lcustomntfs -lcustomext2fs -lpng -lm -lz -lwiiuse -lbte -lasnd -logc -lfreetype -lvorbisidec -lmad -ljpeg -lmodplay
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(CURDIR)/portlibs
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# automatically build a list of object files for our project
|
||||
#---------------------------------------------------------------------------------
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
export LD := $(CC)
|
||||
else
|
||||
export LD := $(CXX)
|
||||
endif
|
||||
|
||||
export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
||||
$(sFILES:.s=.o) $(SFILES:.S=.o) \
|
||||
$(addsuffix .o,$(BINFILES)) \
|
||||
$(CURDIR)/data/binary/magic_patcher.o
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of include paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD) \
|
||||
-I$(LIBOGC_INC)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of library paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
||||
-L$(LIBOGC_LIB)
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
.PHONY: $(BUILD) all clean run
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD):
|
||||
@echo Building for IOS $(ios).
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@bash $(CURDIR)/scripts/svnrev.sh
|
||||
@bash $(CURDIR)/scripts/buildtype.sh $(ios)
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.main
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol $(CURDIR)/data/wiiflow_game_booter.dol \
|
||||
$(CURDIR)/source/loader/alt_ios_gen.c $(CURDIR)/source/svnrev.h
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
run:
|
||||
wiiload $(TARGET).dol
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
gdb:
|
||||
@echo Loading GDB with symbols from boot.elf, type quit to exit.
|
||||
@powerpc-eabi-gdb boot.elf
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
addr:
|
||||
@echo Loading addr2line with symbols from boot.elf..
|
||||
@echo Press ctrl+c to exit.
|
||||
@echo Enter an address from the stack dump:
|
||||
@powerpc-eabi-addr2line -f -e boot.elf
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
$(OUTPUT).dol: $(OUTPUT).elf
|
||||
$(OUTPUT).elf: $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .txt extension
|
||||
#---------------------------------------------------------------------------------
|
||||
%.txt.o: %.txt
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .jpg extension
|
||||
#---------------------------------------------------------------------------------
|
||||
%.jpg.o : %.jpg
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .png extension
|
||||
#---------------------------------------------------------------------------------
|
||||
%.png.o : %.png
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .ogg extension
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ogg.o : %.ogg
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .wav extension
|
||||
#---------------------------------------------------------------------------------
|
||||
%.wav.o : %.wav
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .bin extension
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .dol extension
|
||||
#---------------------------------------------------------------------------------
|
||||
%.dol.o : %.dol
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
@ -1616,7 +1616,7 @@ void CMenu::_gameSoundThread(CMenu *m)
|
||||
delete banner;
|
||||
if(soundBin != NULL)
|
||||
{
|
||||
if(((IMD5Header *)soundBin)->fcc == 'IMD5')
|
||||
if(memcmp(&((IMD5Header *)soundBin)->fcc, "IMD5", 4) == 0)
|
||||
{
|
||||
u32 newSize = 0;
|
||||
u8 *newSound = DecompressCopy(soundBin, sndSize, &newSize);
|
||||
|
@ -122,12 +122,12 @@ void AifDecoder::OpenFile()
|
||||
SWaveHdr Header;
|
||||
file_fd->read((u8 *) &Header, sizeof(SWaveHdr));
|
||||
|
||||
if (Header.magicRIFF != 'FORM')
|
||||
if(memcmp(&Header.magicRIFF, "FORM", 4) != 0)
|
||||
{
|
||||
CloseFile();
|
||||
return;
|
||||
}
|
||||
else if(Header.magicWAVE != 'AIFF')
|
||||
else if(memcmp(&Header.magicWAVE, "AIFF", 4) != 0)
|
||||
{
|
||||
CloseFile();
|
||||
return;
|
||||
@ -144,7 +144,7 @@ void AifDecoder::OpenFile()
|
||||
return;
|
||||
}
|
||||
|
||||
if(magic == 'COMM')
|
||||
if(memcmp(&magic, "COMM", 4) == 0)
|
||||
break;
|
||||
else
|
||||
file_fd->seek(-3, SEEK_CUR);
|
||||
@ -156,7 +156,7 @@ void AifDecoder::OpenFile()
|
||||
SAIFFCommChunk CommHdr;
|
||||
file_fd->read((u8 *) &CommHdr, sizeof(SAIFFCommChunk));
|
||||
|
||||
if(CommHdr.fccCOMM != 'COMM')
|
||||
if(memcmp(&CommHdr.fccCOMM, "COMM", 4) != 0)
|
||||
{
|
||||
CloseFile();
|
||||
return;
|
||||
@ -175,7 +175,7 @@ void AifDecoder::OpenFile()
|
||||
file_fd->seek(chunkHdr.size, SEEK_CUR);
|
||||
ret = file_fd->read((u8 *) &chunkHdr, sizeof(SWaveChunk));
|
||||
}
|
||||
while(ret > 0 && chunkHdr.magicDATA != 'SSND');
|
||||
while(ret > 0 && memcmp(&chunkHdr.magicDATA, "SSND", 4) != 0);
|
||||
|
||||
// Seek back to start of SSND chunk
|
||||
file_fd->seek(-sizeof(SWaveChunk), SEEK_CUR);
|
||||
@ -183,7 +183,7 @@ void AifDecoder::OpenFile()
|
||||
SAIFFSSndChunk SSndChunk;
|
||||
file_fd->read((u8 *) &SSndChunk, sizeof(SAIFFSSndChunk));
|
||||
|
||||
if(SSndChunk.fccSSND != 'SSND')
|
||||
if(memcmp(&SSndChunk.fccSSND, "SSND", 4) != 0)
|
||||
{
|
||||
CloseFile();
|
||||
return;
|
||||
|
@ -313,9 +313,9 @@ SoundBlock DecodefromBNS(const u8 *buffer, u32 size)
|
||||
memset(&OutBlock, 0, sizeof(SoundBlock));
|
||||
|
||||
const BNSHeader &hdr = *(BNSHeader *)buffer;
|
||||
if (size < sizeof hdr)
|
||||
if(size < sizeof hdr)
|
||||
return OutBlock;
|
||||
if (hdr.fccBNS != 'BNS ')
|
||||
if(memcmp(&hdr.fccBNS, "BNS ", 4) != 0)
|
||||
return OutBlock;
|
||||
// Find info and data
|
||||
BNSInfo infoChunk;
|
||||
|
@ -203,26 +203,16 @@ SoundDecoder * SoundHandler::GetSoundDecoder(const char * filepath)
|
||||
/* gprintf("SHND: Searching decoder for magic\n");
|
||||
ghexdump((u8 *) &magic, 4); */
|
||||
|
||||
if(magic == 'OggS')
|
||||
{
|
||||
if(memcmp(&magic, "OggS", 4) == 0)
|
||||
return new OggDecoder(filepath);
|
||||
}
|
||||
else if(magic == 'RIFF')
|
||||
{
|
||||
else if(memcmp(&magic, "RIFF", 4) == 0)
|
||||
return new WavDecoder(filepath);
|
||||
}
|
||||
else if(magic == 'BNS ')
|
||||
{
|
||||
else if(memcmp(&magic, "BNS ", 4) == 0)
|
||||
return new BNSDecoder(filepath);
|
||||
}
|
||||
else if(magic == 'FORM')
|
||||
{
|
||||
else if(memcmp(&magic, "FORM", 4) == 0)
|
||||
return new AifDecoder(filepath);
|
||||
}
|
||||
else if(CheckMP3Signature((u8 *) &magic) == true)
|
||||
{
|
||||
return new Mp3Decoder(filepath);
|
||||
}
|
||||
|
||||
return new SoundDecoder(filepath);
|
||||
}
|
||||
@ -241,28 +231,18 @@ SoundDecoder * SoundHandler::GetSoundDecoder(const u8 * sound, int length)
|
||||
if(counter >= length)
|
||||
return NULL;
|
||||
|
||||
u32 * magic = (u32 *) check;
|
||||
u32 * magic = (u32 *)check;
|
||||
|
||||
if(magic[0] == 'OggS')
|
||||
{
|
||||
if(memcmp(&magic[0], "OggS", 4) == 0)
|
||||
return new OggDecoder(sound, length);
|
||||
}
|
||||
else if(magic[0] == 'RIFF')
|
||||
{
|
||||
else if(memcmp(&magic[0], "RIFF", 4) == 0)
|
||||
return new WavDecoder(sound, length);
|
||||
}
|
||||
else if(magic[0] == 'BNS ')
|
||||
{
|
||||
else if(memcmp(&magic[0], "BNS ", 4) == 0)
|
||||
return new BNSDecoder(sound, length);
|
||||
}
|
||||
else if(magic[0] == 'FORM')
|
||||
{
|
||||
else if(memcmp(&magic[0], "FORM", 4) == 0)
|
||||
return new AifDecoder(sound, length);
|
||||
}
|
||||
else if(CheckMP3Signature(check) == true)
|
||||
{
|
||||
return new Mp3Decoder(sound, length);
|
||||
}
|
||||
|
||||
return new SoundDecoder(sound, length);
|
||||
}
|
||||
|
@ -68,23 +68,24 @@ void WavDecoder::OpenFile()
|
||||
file_fd->read((u8 *) &Header, sizeof(SWaveHdr));
|
||||
file_fd->read((u8 *) &FmtChunk, sizeof(SWaveFmtChunk));
|
||||
|
||||
if(Header.magicRIFF != 'RIFF')
|
||||
if(memcmp(&Header.magicRIFF, "RIFF", 4) != 0)
|
||||
{
|
||||
CloseFile();
|
||||
return;
|
||||
}
|
||||
else if(Header.magicWAVE != 'WAVE')
|
||||
else if(memcmp(&Header.magicWAVE, "WAVE", 4) != 0)
|
||||
{
|
||||
CloseFile();
|
||||
return;
|
||||
}
|
||||
if(FmtChunk.magicFMT == 'bext') //Stupid metadata
|
||||
|
||||
if(memcmp(&FmtChunk.magicFMT, "bext", 4) == 0) //Stupid metadata
|
||||
{
|
||||
DataOffset += le32(FmtChunk.size) + 8;
|
||||
file_fd->seek(sizeof(SWaveHdr) + le32(FmtChunk.size) + 8, SEEK_SET);
|
||||
file_fd->read((u8 *)&FmtChunk, sizeof(SWaveFmtChunk));
|
||||
}
|
||||
if(FmtChunk.magicFMT != 'fmt ')
|
||||
if(memcmp(&FmtChunk.magicFMT, "fmt ", 4) != 0)
|
||||
{
|
||||
CloseFile();
|
||||
return;
|
||||
@ -95,7 +96,7 @@ void WavDecoder::OpenFile()
|
||||
SWaveChunk DataChunk;
|
||||
file_fd->read((u8 *) &DataChunk, sizeof(SWaveChunk));
|
||||
|
||||
while(DataChunk.magicDATA != 'data')
|
||||
while(memcmp(&DataChunk.magicDATA, "data", 4) != 0)
|
||||
{
|
||||
DataOffset += 8+le32(DataChunk.size);
|
||||
file_fd->seek(DataOffset, SEEK_SET);
|
||||
@ -128,7 +129,7 @@ void WavDecoder::OpenFile()
|
||||
file_fd->seek(DataOffset + DataSize, SEEK_SET);
|
||||
while(file_fd->read((u8 *)&LoopChunk, sizeof(SWaveChunk)) == sizeof(SWaveChunk))
|
||||
{
|
||||
if(LoopChunk.magicDATA == 'smpl')
|
||||
if(memcmp(&LoopChunk.magicDATA, "smpl", 4) == 0)
|
||||
{
|
||||
file_fd->seek(-8, SEEK_CUR);
|
||||
file_fd->read((u8*)&SmplChunk, sizeof(SWaveSmplChunk));
|
||||
|
@ -202,7 +202,7 @@ bool GuiSound::Load(const u8 * snd, u32 len, bool isallocated)
|
||||
if(!snd)
|
||||
return false;
|
||||
|
||||
if(!isallocated && *((u32 *) snd) == 'RIFF')
|
||||
if(!isallocated && memcmp(snd, "RIFF", 4) == 0)
|
||||
return LoadSoundEffect(snd, len);
|
||||
|
||||
sound = (u8*)snd;
|
||||
|
Loading…
Reference in New Issue
Block a user