restructure
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,5 +1,2 @@
|
||||
build
|
||||
.cache
|
||||
*.3dsx
|
||||
*.elf
|
||||
*.smdh
|
||||
|
248
Makefile
248
Makefile
@@ -1,229 +1,61 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
TOPDIR ?= $(CURDIR)
|
||||
include $(DEVKITARM)/3ds_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
|
||||
# DATA is a list of directories containing data files
|
||||
# INCLUDES is a list of directories containing header files
|
||||
# GRAPHICS is a list of directories containing graphics files
|
||||
# GFXBUILD is the directory where converted graphics files will be placed
|
||||
# If set to $(BUILD), it will statically link in the converted
|
||||
# files as if they were data files.
|
||||
#
|
||||
# NO_SMDH: if set to anything, no SMDH file is generated.
|
||||
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
|
||||
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
|
||||
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
|
||||
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
|
||||
# ICON is the filename of the icon (.png), relative to the project folder.
|
||||
# If not set, it attempts to use one of the following (in this order):
|
||||
# - <Project name>.png
|
||||
# - icon.png
|
||||
# - <libctru folder>/default_icon.png
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
GRAPHICS := gfx
|
||||
GFXBUILD := $(BUILD)
|
||||
#ROMFS := romfs
|
||||
#GFXBUILD := $(ROMFS)/gfx
|
||||
TARGET := pukeko-3ds
|
||||
BUILD := build
|
||||
SRCDIRS := program/src libpukeko/src
|
||||
INCLUDE := -I$(CURDIR)/include \
|
||||
-I$(CURDIR)/libpukeko/include \
|
||||
-I$(CURDIR)/program/include \
|
||||
-I$(DEVKITPRO)/libctru/include \
|
||||
-I$(BUILD)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
||||
# Updated architecture flags
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -mfpu=vfp
|
||||
|
||||
CFLAGS := -g -Wall -O2 -mword-relocations \
|
||||
-ffunction-sections \
|
||||
$(ARCH)
|
||||
CFLAGS := -g -Wall -O2 -mword-relocations \
|
||||
-ffunction-sections $(ARCH) \
|
||||
$(INCLUDE) -D__3DS__
|
||||
|
||||
CFLAGS += $(INCLUDE) -D__3DS__
|
||||
# These are crucial for 3DS devkitARM - use 3dsx.specs
|
||||
LDFLAGS := -specs=3dsx.specs $(ARCH) -L$(DEVKITPRO)/libctru/lib
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
# Make sure to include standard C library
|
||||
LIBS := -lctru -lm
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lctru -lm
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(CTRULIB)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# 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 TOPDIR := $(CURDIR)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
|
||||
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
|
||||
GFXFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.t3s)))
|
||||
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
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(GFXBUILD),$(BUILD))
|
||||
#---------------------------------------------------------------------------------
|
||||
export T3XFILES := $(GFXFILES:.t3s=.t3x)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export ROMFS_T3XFILES := $(patsubst %.t3s, $(GFXBUILD)/%.t3x, $(GFXFILES))
|
||||
export T3XHFILES := $(patsubst %.t3s, $(BUILD)/%.h, $(GFXFILES))
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \
|
||||
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
|
||||
$(addsuffix .o,$(T3XFILES))
|
||||
|
||||
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
|
||||
|
||||
export HFILES := $(PICAFILES:.v.pica=_shbin.h) $(SHLISTFILES:.shlist=_shbin.h) \
|
||||
$(addsuffix .h,$(subst .,_,$(BINFILES))) \
|
||||
$(GFXFILES:.t3s=.h)
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
export _3DSXDEPS := $(if $(NO_SMDH),,$(OUTPUT).smdh)
|
||||
|
||||
ifeq ($(strip $(ICON)),)
|
||||
icons := $(wildcard *.png)
|
||||
ifneq (,$(findstring $(TARGET).png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/$(TARGET).png
|
||||
else
|
||||
ifneq (,$(findstring icon.png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/icon.png
|
||||
endif
|
||||
endif
|
||||
else
|
||||
export APP_ICON := $(TOPDIR)/$(ICON)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(NO_SMDH)),)
|
||||
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
|
||||
endif
|
||||
|
||||
ifneq ($(ROMFS),)
|
||||
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
|
||||
endif
|
||||
# Use find to recurse
|
||||
CFILES := $(shell find $(SRCDIRS) -name '*.c')
|
||||
OFILES := $(patsubst %.c,$(BUILD)/%.o,$(CFILES))
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(T3XHFILES)
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
all: $(BUILD) $(TARGET).3dsx
|
||||
|
||||
$(TARGET).3dsx: $(BUILD)/$(TARGET).elf
|
||||
@echo "[3DSX] $@"
|
||||
@$(DEVKITPRO)/tools/bin/3dsxtool $< $@ $(if $(filter $(TARGET).smdh,$(wildcard $(TARGET).smdh)),--smdh=$(TARGET).smdh) $(if $(strip $(ROMFS)),--romfs=$(ROMFS))
|
||||
|
||||
$(BUILD)/$(TARGET).elf: $(OFILES)
|
||||
@mkdir -p $(dir $@)
|
||||
@echo "[LD] $@"
|
||||
@$(CC) $(LDFLAGS) -o $@ $(OFILES) $(LIBS)
|
||||
|
||||
# 🧱 C build rule
|
||||
$(BUILD)/%.o: %.c
|
||||
@mkdir -p $(dir $@)
|
||||
@echo "[CC] $<"
|
||||
@$(CC) $(CFLAGS) -MMD -MP -MF $(@:.o=.d) -c $< -o $@
|
||||
|
||||
$(BUILD):
|
||||
@mkdir -p $@
|
||||
|
||||
ifneq ($(GFXBUILD),$(BUILD))
|
||||
$(GFXBUILD):
|
||||
@mkdir -p $@
|
||||
endif
|
||||
|
||||
ifneq ($(DEPSDIR),$(BUILD))
|
||||
$(DEPSDIR):
|
||||
@mkdir -p $@
|
||||
endif
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf $(GFXBUILD)
|
||||
@echo "Cleaning build files..."
|
||||
@rm -rf $(BUILD) $(TARGET).3dsx $(TARGET).elf
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(GFXBUILD)/%.t3x $(BUILD)/%.h : %.t3s
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@tex3ds -i $< -H $(BUILD)/$*.h -d $(DEPSDIR)/$*.d -o $(GFXBUILD)/$*.t3x
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
$(OUTPUT).3dsx : $(OUTPUT).elf $(_3DSXDEPS)
|
||||
|
||||
$(OFILES_SOURCES) : $(HFILES)
|
||||
|
||||
$(OUTPUT).elf : $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# you need a rule like this for each extension you use as binary data
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o %_bin.h : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
.PRECIOUS : %.t3x %.shbin
|
||||
#---------------------------------------------------------------------------------
|
||||
%.t3x.o %_t3x.h : %.t3x
|
||||
#---------------------------------------------------------------------------------
|
||||
$(SILENTMSG) $(notdir $<)
|
||||
$(bin2o)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.shbin.o %_shbin.h : %.shbin
|
||||
#---------------------------------------------------------------------------------
|
||||
$(SILENTMSG) $(notdir $<)
|
||||
$(bin2o)
|
||||
|
||||
-include $(DEPSDIR)/*.d
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
||||
# ⛑ Include generated dependency files
|
||||
-include $(patsubst %.o,%.d,$(OFILES))
|
||||
|
@@ -1,27 +0,0 @@
|
||||
[
|
||||
{
|
||||
"arguments": [
|
||||
"/opt/devkitpro//devkitARM/bin/arm-none-eabi-gcc",
|
||||
"-g",
|
||||
"-Wall",
|
||||
"-O2",
|
||||
"-mword-relocations",
|
||||
"-ffunction-sections",
|
||||
"-march=armv6k",
|
||||
"-mtune=mpcore",
|
||||
"-mfloat-abi=hard",
|
||||
"-mtp=soft",
|
||||
"-I/home/taigo/code/pers/pukeko-3ds/include",
|
||||
"-I/opt/devkitpro//libctru/include",
|
||||
"-I/home/taigo/code/pers/pukeko-3ds/build",
|
||||
"-D__3DS__",
|
||||
"-c",
|
||||
"-o",
|
||||
"input.o",
|
||||
"/home/taigo/code/pers/pukeko-3ds/source/input.c"
|
||||
],
|
||||
"directory": "/home/taigo/code/pers/pukeko-3ds/build",
|
||||
"file": "/home/taigo/code/pers/pukeko-3ds/source/input.c",
|
||||
"output": "/home/taigo/code/pers/pukeko-3ds/build/input.o"
|
||||
}
|
||||
]
|
@@ -1,16 +0,0 @@
|
||||
#ifndef INCLUDE_H
|
||||
#define INCLUDE_H
|
||||
|
||||
#include <3ds.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
extern int user_money;
|
||||
extern int held_pukekos;
|
||||
|
||||
#endif // !INCLUDE_H
|
27
libpukeko/Makefile
Normal file
27
libpukeko/Makefile
Normal file
@@ -0,0 +1,27 @@
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
# Compiler flags
|
||||
CFLAGS := -g -Wall -O2 $(ARCH) -D__3DS__
|
||||
|
||||
# Source files
|
||||
SOURCES := src/navigation/selector.c
|
||||
|
||||
# Object files
|
||||
OFILES := $(SOURCES:.c=.o)
|
||||
|
||||
# Build directory
|
||||
BUILD := ../../build/libpukeko
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: $(BUILD)/libpukeko.a
|
||||
|
||||
$(BUILD)/libpukeko.a: $(OFILES)
|
||||
$(AR) rcs $@ $^
|
||||
|
||||
$(BUILD)/%.o: %.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f $(BUILD)/*.o $(BUILD)/libpukeko.a
|
||||
|
@@ -2,6 +2,6 @@
|
||||
#define INPUT_H
|
||||
|
||||
void waitForKey(char key);
|
||||
int print_select_menu(char menu_items[10][32], int items_length);
|
||||
int selector_render(char menu_items[10][32], int items_length);
|
||||
|
||||
#endif // !INPUT_H
|
@@ -1,18 +1,20 @@
|
||||
#include "include.h"
|
||||
#include <3ds.h>
|
||||
#include <stdio.h>
|
||||
#include "navigation.h"
|
||||
|
||||
void waitForKey(char key) {
|
||||
while (true) {
|
||||
hidScanInput();
|
||||
u32 key_down = hidKeysDown();
|
||||
if (key_down & key) break;
|
||||
}
|
||||
}
|
||||
//void waitForKey(char key) {
|
||||
// while (true) {
|
||||
// hidScanInput();
|
||||
// u32 key_down = hidKeysDown();
|
||||
// if (key_down & key) break;
|
||||
// }
|
||||
//}
|
||||
|
||||
int cursor_select(int items) {
|
||||
int render_cursor(int items) {
|
||||
int cursor_position = 1;
|
||||
|
||||
printf("\x1b[%d;1H>", cursor_position);
|
||||
while (true) {
|
||||
while (true) {
|
||||
hidScanInput();
|
||||
u32 key_down = hidKeysDown();
|
||||
|
||||
@@ -38,16 +40,16 @@ int cursor_select(int items) {
|
||||
return cursor_position;
|
||||
}
|
||||
|
||||
void print_menu(char menu_items[10][32], int items_length) {
|
||||
void selector_draw(char menu_items[10][32], int items_length) {
|
||||
for (int i = 0; i < items_length; i = i + 1) {
|
||||
printf("\x1b[%d;2H%s", i+1, menu_items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int print_select_menu(char menu_items[10][32], int items_length) {
|
||||
int selector_render(char menu_items[10][32], int items_length) {
|
||||
consoleClear();
|
||||
print_menu(menu_items, items_length);
|
||||
int selection = cursor_select(items_length);
|
||||
selector_draw(menu_items, items_length);
|
||||
int selection = render_cursor(items_length);
|
||||
return selection;
|
||||
}
|
||||
|
27
program/Makefile
Normal file
27
program/Makefile
Normal file
@@ -0,0 +1,27 @@
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
# Compiler flags
|
||||
CFLAGS := -g -Wall -O2 $(ARCH) -D__3DS__
|
||||
|
||||
# Source files
|
||||
SOURCES := src/debug/debug.c src/main_menu.c src/main.c src/pukeko.c
|
||||
|
||||
# Object files
|
||||
OFILES := $(SOURCES:.c=.o)
|
||||
|
||||
# Build directory
|
||||
BUILD := ../../build/program
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: $(BUILD)/pukeko.elf
|
||||
|
||||
$(BUILD)/pukeko.elf: $(OFILES) $(BUILD)/libpukeko.a
|
||||
$(LD) -o $@ $^ $(LDFLAGS) $(LIBS)
|
||||
|
||||
$(BUILD)/%.o: %.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f $(BUILD)/*.o $(BUILD)/pukeko.elf
|
||||
|
7
program/include/pukeko_app.h
Normal file
7
program/include/pukeko_app.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef PUKEKO_APP_H
|
||||
#define PUKEKO_APP_H
|
||||
|
||||
extern int user_money;
|
||||
extern int held_pukekos;
|
||||
|
||||
#endif // !PUKEKO_APP_H
|
@@ -1,5 +1,6 @@
|
||||
#include "include.h"
|
||||
#include "pukeko_app.h"
|
||||
#include "debug.h"
|
||||
#include "../../libpukeko/include/navigation.h"
|
||||
|
||||
void print_debug_menu() {
|
||||
int items_length = 2;
|
||||
@@ -9,7 +10,7 @@ void print_debug_menu() {
|
||||
};
|
||||
|
||||
while (true) {
|
||||
int selection = print_select_menu(menu_items, items_length);
|
||||
int selection = selector_render(menu_items, items_length);
|
||||
|
||||
switch (selection) {
|
||||
case 1:
|
@@ -1,5 +1,7 @@
|
||||
#include <3ds.h>
|
||||
#include <stdlib.h>
|
||||
#include "include.h"
|
||||
#include <time.h>
|
||||
#include "pukeko_app.h"
|
||||
#include "main_menu.h"
|
||||
|
||||
int user_money = 0;
|
@@ -1,7 +1,9 @@
|
||||
#include <3ds.h>
|
||||
#include "main_menu.h"
|
||||
#include "include.h"
|
||||
#include "pukeko_app.h"
|
||||
#include "pukeko.h"
|
||||
#include "debug.h"
|
||||
#include "../../libpukeko/include/navigation.h"
|
||||
|
||||
void print_main_menu() {
|
||||
int items_length = 3;
|
||||
@@ -12,7 +14,7 @@ void print_main_menu() {
|
||||
};
|
||||
|
||||
while (true) {
|
||||
int selection = print_select_menu(menu_items, items_length);
|
||||
int selection = selector_render(menu_items, items_length);
|
||||
|
||||
switch (selection) {
|
||||
case 1:
|
@@ -1,4 +1,8 @@
|
||||
#include "include.h"
|
||||
#include <3ds.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "pukeko_app.h"
|
||||
#include "pukeko.h"
|
||||
|
||||
void print_top_info() {
|
BIN
pukeko-3ds.3dsx
Normal file
BIN
pukeko-3ds.3dsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user