mirror of
https://github.com/switchbrew/switch-examples.git
synced 2025-06-21 13:22:40 +02:00
Fix up indentation
This commit is contained in:
parent
f045830070
commit
06e11f9482
@ -29,36 +29,36 @@ include $(DEVKITPRO)/libnx/switch_rules
|
|||||||
# - icon.jpg
|
# - icon.jpg
|
||||||
# - <libnx folder>/default_icon.jpg
|
# - <libnx folder>/default_icon.jpg
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
TARGET := $(notdir $(CURDIR))
|
TARGET := $(notdir $(CURDIR))
|
||||||
BUILD := build
|
BUILD := build
|
||||||
SOURCES := source
|
SOURCES := source
|
||||||
DATA := data
|
DATA := data
|
||||||
INCLUDES := include
|
INCLUDES := include
|
||||||
EXEFS_SRC := exefs_src
|
EXEFS_SRC := exefs_src
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# options for code generation
|
# options for code generation
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
ARCH := -march=armv8-a -mtp=soft -fPIE
|
ARCH := -march=armv8-a -mtp=soft -fPIE
|
||||||
|
|
||||||
CFLAGS := -g -Wall -O2 \
|
CFLAGS := -g -Wall -O2 \
|
||||||
-ffast-math \
|
-ffast-math \
|
||||||
$(ARCH) $(DEFINES)
|
$(ARCH) $(DEFINES)
|
||||||
|
|
||||||
CFLAGS += $(INCLUDE) -DSWITCH
|
CFLAGS += $(INCLUDE) -DSWITCH
|
||||||
|
|
||||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||||
|
|
||||||
ASFLAGS := -g $(ARCH)
|
ASFLAGS := -g $(ARCH)
|
||||||
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||||
|
|
||||||
LIBS := -lnx -lm
|
LIBS := -lnx -lm
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# list of directories containing libraries, this must be the top level containing
|
# list of directories containing libraries, this must be the top level containing
|
||||||
# include and lib
|
# include and lib
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
LIBDIRS := $(PORTLIBS) $(LIBNX)
|
LIBDIRS := $(PORTLIBS) $(LIBNX)
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
@ -68,67 +68,67 @@ LIBDIRS := $(PORTLIBS) $(LIBNX)
|
|||||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||||
export TOPDIR := $(CURDIR)
|
export TOPDIR := $(CURDIR)
|
||||||
|
|
||||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||||
|
|
||||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||||
|
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
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)/*.*)))
|
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# use CXX for linking C++ projects, CC for standard C
|
# use CXX for linking C++ projects, CC for standard C
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
ifeq ($(strip $(CPPFILES)),)
|
ifeq ($(strip $(CPPFILES)),)
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
export LD := $(CC)
|
export LD := $(CC)
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
else
|
else
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
export LD := $(CXX)
|
export LD := $(CXX)
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
endif
|
endif
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||||
|
|
||||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||||
-I$(CURDIR)/$(BUILD)
|
-I$(CURDIR)/$(BUILD)
|
||||||
|
|
||||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||||
|
|
||||||
export BUILD_EXEFS_SRC := $(TOPDIR)/$(EXEFS_SRC)
|
export BUILD_EXEFS_SRC := $(TOPDIR)/$(EXEFS_SRC)
|
||||||
|
|
||||||
ifeq ($(strip $(ICON)),)
|
ifeq ($(strip $(ICON)),)
|
||||||
icons := $(wildcard *.jpg)
|
icons := $(wildcard *.jpg)
|
||||||
ifneq (,$(findstring $(TARGET).jpg,$(icons)))
|
ifneq (,$(findstring $(TARGET).jpg,$(icons)))
|
||||||
export APP_ICON := $(TOPDIR)/$(TARGET).jpg
|
export APP_ICON := $(TOPDIR)/$(TARGET).jpg
|
||||||
else
|
else
|
||||||
ifneq (,$(findstring icon.jpg,$(icons)))
|
ifneq (,$(findstring icon.jpg,$(icons)))
|
||||||
export APP_ICON := $(TOPDIR)/icon.jpg
|
export APP_ICON := $(TOPDIR)/icon.jpg
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
export APP_ICON := $(TOPDIR)/$(ICON)
|
export APP_ICON := $(TOPDIR)/$(ICON)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(strip $(NO_ICON)),)
|
ifeq ($(strip $(NO_ICON)),)
|
||||||
export NROFLAGS += --icon=$(APP_ICON)
|
export NROFLAGS += --icon=$(APP_ICON)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(strip $(NO_NACP)),)
|
ifeq ($(strip $(NO_NACP)),)
|
||||||
export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp
|
export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(APP_TITLEID),)
|
ifneq ($(APP_TITLEID),)
|
||||||
export NACPFLAGS += --titleid=$(APP_TITLEID)
|
export NACPFLAGS += --titleid=$(APP_TITLEID)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: $(BUILD) clean all
|
.PHONY: $(BUILD) clean all
|
||||||
@ -137,45 +137,45 @@ endif
|
|||||||
all: $(BUILD)
|
all: $(BUILD)
|
||||||
|
|
||||||
$(BUILD):
|
$(BUILD):
|
||||||
@[ -d $@ ] || mkdir -p $@
|
@[ -d $@ ] || mkdir -p $@
|
||||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
clean:
|
clean:
|
||||||
@echo clean ...
|
@echo clean ...
|
||||||
@rm -fr $(BUILD) $(TARGET).pfs0 $(TARGET).nso $(TARGET).nro $(TARGET).nacp $(TARGET).elf
|
@rm -fr $(BUILD) $(TARGET).pfs0 $(TARGET).nso $(TARGET).nro $(TARGET).nacp $(TARGET).elf
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
else
|
else
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
|
|
||||||
DEPENDS := $(OFILES:.o=.d)
|
DEPENDS := $(OFILES:.o=.d)
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# main targets
|
# main targets
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
all : $(OUTPUT).pfs0 $(OUTPUT).nro
|
all : $(OUTPUT).pfs0 $(OUTPUT).nro
|
||||||
|
|
||||||
$(OUTPUT).pfs0 : $(OUTPUT).nso
|
$(OUTPUT).pfs0 : $(OUTPUT).nso
|
||||||
|
|
||||||
$(OUTPUT).nso : $(OUTPUT).elf
|
$(OUTPUT).nso : $(OUTPUT).elf
|
||||||
|
|
||||||
ifeq ($(strip $(NO_NACP)),)
|
ifeq ($(strip $(NO_NACP)),)
|
||||||
$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp
|
$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp
|
||||||
else
|
else
|
||||||
$(OUTPUT).nro : $(OUTPUT).elf
|
$(OUTPUT).nro : $(OUTPUT).elf
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(OUTPUT).elf : $(OFILES)
|
$(OUTPUT).elf : $(OFILES)
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# you need a rule like this for each extension you use as binary data
|
# you need a rule like this for each extension you use as binary data
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
%.bin.o : %.bin
|
%.bin.o : %.bin
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
@echo $(notdir $<)
|
@echo $(notdir $<)
|
||||||
@$(bin2o)
|
@$(bin2o)
|
||||||
|
|
||||||
-include $(DEPENDS)
|
-include $(DEPENDS)
|
||||||
|
|
||||||
|
@ -8,50 +8,50 @@
|
|||||||
#define SAMPLESPERBUF (SAMPLERATE / 10)
|
#define SAMPLESPERBUF (SAMPLERATE / 10)
|
||||||
|
|
||||||
void fill_audio_buffer(void* audio_buffer, size_t offset, size_t size, int frequency) {
|
void fill_audio_buffer(void* audio_buffer, size_t offset, size_t size, int frequency) {
|
||||||
u32* dest = (u32*) audio_buffer;
|
u32* dest = (u32*) audio_buffer;
|
||||||
|
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
// This is a simple sine wave, with a frequency of `frequency` Hz, and an amplitude 30% of maximum.
|
// This is a simple sine wave, with a frequency of `frequency` Hz, and an amplitude 30% of maximum.
|
||||||
s16 sample = 0.3 * 0x7FFF * sin(frequency * (2 * M_PI) * (offset + i) / SAMPLERATE);
|
s16 sample = 0.3 * 0x7FFF * sin(frequency * (2 * M_PI) * (offset + i) / SAMPLERATE);
|
||||||
|
|
||||||
// Stereo samples are interleaved: left and right channels.
|
// Stereo samples are interleaved: left and right channels.
|
||||||
dest[i] = (sample << 16) | (sample & 0xffff);
|
dest[i] = (sample << 16) | (sample & 0xffff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
Result rc = 0;
|
Result rc = 0;
|
||||||
Handle event = 0;
|
Handle event = 0;
|
||||||
AudioOutBuffer source_buffer;
|
AudioOutBuffer source_buffer;
|
||||||
AudioOutBuffer released_buffer;
|
AudioOutBuffer released_buffer;
|
||||||
|
|
||||||
int notefreq[] = {
|
int notefreq[] = {
|
||||||
220,
|
220,
|
||||||
440, 880, 1760, 3520, 7040,
|
440, 880, 1760, 3520, 7040,
|
||||||
14080,
|
14080,
|
||||||
7040, 3520, 1760, 880, 440
|
7040, 3520, 1760, 880, 440
|
||||||
};
|
};
|
||||||
|
|
||||||
u32 raw_data[SAMPLESPERBUF * 2];
|
u32 raw_data[SAMPLESPERBUF * 2];
|
||||||
fill_audio_buffer(raw_data, 0, SAMPLESPERBUF * 2, notefreq[4]);
|
fill_audio_buffer(raw_data, 0, SAMPLESPERBUF * 2, notefreq[4]);
|
||||||
|
|
||||||
gfxInitDefault();
|
gfxInitDefault();
|
||||||
|
|
||||||
// Initialize console. Using NULL as the second argument tells the console library to use the internal console structure as current one.
|
// Initialize console. Using NULL as the second argument tells the console library to use the internal console structure as current one.
|
||||||
consoleInit(NULL);
|
consoleInit(NULL);
|
||||||
|
|
||||||
rc = audoutInitialize();
|
rc = audoutInitialize();
|
||||||
printf("audoutInitialize() returned 0x%x\n", rc);
|
printf("audoutInitialize() returned 0x%x\n", rc);
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc))
|
||||||
{
|
{
|
||||||
rc = audoutRegisterBufferEvent(&event);
|
rc = audoutRegisterBufferEvent(&event);
|
||||||
printf("audoutRegisterBufferEvent() returned 0x%x\n", rc);
|
printf("audoutRegisterBufferEvent() returned 0x%x\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc))
|
||||||
{
|
{
|
||||||
source_buffer.next = 0;
|
source_buffer.next = 0;
|
||||||
source_buffer.buffer = raw_data;
|
source_buffer.buffer = raw_data;
|
||||||
source_buffer.buffer_size = sizeof(raw_data);
|
source_buffer.buffer_size = sizeof(raw_data);
|
||||||
@ -60,23 +60,23 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
rc = audoutAppendAudioOutBuffer(&source_buffer);
|
rc = audoutAppendAudioOutBuffer(&source_buffer);
|
||||||
printf("audoutAppendAudioOutBuffer() returned 0x%x\n", rc);
|
printf("audoutAppendAudioOutBuffer() returned 0x%x\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc))
|
||||||
{
|
{
|
||||||
rc = audoutStartAudioOut();
|
rc = audoutStartAudioOut();
|
||||||
printf("audoutStartAudioOut() returned 0x%x\n", rc);
|
printf("audoutStartAudioOut() returned 0x%x\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool play_tone = false;
|
bool play_tone = false;
|
||||||
printf("Press A, B, Y, X, Left, Up, Right, Down, L, R, ZL or ZR to play a different tone.\n");
|
printf("Press A, B, Y, X, Left, Up, Right, Down, L, R, ZL or ZR to play a different tone.\n");
|
||||||
|
|
||||||
while (appletMainLoop())
|
while (appletMainLoop())
|
||||||
{
|
{
|
||||||
//Scan all the inputs. This should be done once for each frame
|
//Scan all the inputs. This should be done once for each frame
|
||||||
hidScanInput();
|
hidScanInput();
|
||||||
|
|
||||||
if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_PLUS) break;
|
if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_PLUS) break;
|
||||||
|
|
||||||
if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_A)
|
if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_A)
|
||||||
{
|
{
|
||||||
@ -177,16 +177,16 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gfxFlushBuffers();
|
gfxFlushBuffers();
|
||||||
gfxSwapBuffers();
|
gfxSwapBuffers();
|
||||||
gfxWaitForVsync();
|
gfxWaitForVsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = audoutStopAudioOut();
|
rc = audoutStopAudioOut();
|
||||||
printf("audoutStopAudioOut() returned 0x%x\n", rc);
|
printf("audoutStopAudioOut() returned 0x%x\n", rc);
|
||||||
|
|
||||||
audoutExit();
|
audoutExit();
|
||||||
|
|
||||||
gfxExit();
|
gfxExit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user