commit cdea49064bb2e111987d138e4ab8fcc463e61718 Author: yoruka <> Date: Wed Apr 23 22:32:58 2025 +0200 inital commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..607e0ee --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +build +.cache +*.3dsx +*.elf +*.smdh diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..eff34b4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,11 @@ +DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE +Version 2, December 2004 + +Copyright (C) 2004 Yoruka + +Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed. + +DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..632882b --- /dev/null +++ b/Makefile @@ -0,0 +1,229 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=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): +# - .png +# - icon.png +# - /default_icon.png +#--------------------------------------------------------------------------------- +TARGET := $(notdir $(CURDIR)) +BUILD := build +SOURCES := source +DATA := data +INCLUDES := include +GRAPHICS := gfx +GFXBUILD := $(BUILD) +#ROMFS := romfs +#GFXBUILD := $(ROMFS)/gfx + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft + +CFLAGS := -g -Wall -O2 -mword-relocations \ + -ffunction-sections \ + $(ARCH) + +CFLAGS += $(INCLUDE) -D__3DS__ + +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 + +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 + +.PHONY: all clean + +#--------------------------------------------------------------------------------- +all: $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(T3XHFILES) + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +$(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) + +#--------------------------------------------------------------------------------- +$(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 +#--------------------------------------------------------------------------------------- diff --git a/README.md b/README.md new file mode 100644 index 0000000..c8945f2 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# pukeko-3ds + diff --git a/compile_commands.json b/compile_commands.json new file mode 100644 index 0000000..035ab98 --- /dev/null +++ b/compile_commands.json @@ -0,0 +1,27 @@ +[ + { + "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" + } +] diff --git a/include/debug.h b/include/debug.h new file mode 100644 index 0000000..7bccd21 --- /dev/null +++ b/include/debug.h @@ -0,0 +1,6 @@ +#ifndef DEBUG_H +#define DEBUG_H + +void print_debug_menu(); + +#endif // !DEBUG_H diff --git a/include/include.h b/include/include.h new file mode 100644 index 0000000..f3ab88f --- /dev/null +++ b/include/include.h @@ -0,0 +1,16 @@ +#ifndef INCLUDE_H +#define INCLUDE_H + +#include <3ds.h> +#include +#include +#include +#include +#include + +#include "input.h" + +extern int user_money; +extern int held_pukekos; + +#endif // !INCLUDE_H diff --git a/include/input.h b/include/input.h new file mode 100644 index 0000000..2442902 --- /dev/null +++ b/include/input.h @@ -0,0 +1,7 @@ +#ifndef INPUT_H +#define INPUT_H + +void waitForKey(char key); +int print_select_menu(char menu_items[10][32], int items_length); + +#endif // !INPUT_H diff --git a/include/main_menu.h b/include/main_menu.h new file mode 100644 index 0000000..109e4f3 --- /dev/null +++ b/include/main_menu.h @@ -0,0 +1,6 @@ +#ifndef MAIN_MENU_H +#define MAIN_MENU_H + +void print_main_menu(); + +#endif //MAIN_MENU_H diff --git a/include/pukeko.h b/include/pukeko.h new file mode 100644 index 0000000..16d9b90 --- /dev/null +++ b/include/pukeko.h @@ -0,0 +1,7 @@ +#ifndef PUKEKO_H +#define PUKEKO_H + +void print_game_screen(); + +#endif // !PUKEKO_H + diff --git a/source/debug.c b/source/debug.c new file mode 100644 index 0000000..156b8d7 --- /dev/null +++ b/source/debug.c @@ -0,0 +1,23 @@ +#include "include.h" +#include "debug.h" + +void print_debug_menu() { + int items_length = 2; + char menu_items[10][32] = { + "add money (500)", + "back" + }; + + while (true) { + int selection = print_select_menu(menu_items, items_length); + + switch (selection) { + case 1: + user_money = user_money + 500; + break; + case 0: + case 2: + return; + } + } +} diff --git a/source/input.c b/source/input.c new file mode 100644 index 0000000..af98f47 --- /dev/null +++ b/source/input.c @@ -0,0 +1,53 @@ +#include "include.h" + +void waitForKey(char key) { + while (true) { + hidScanInput(); + u32 key_down = hidKeysDown(); + if (key_down & key) break; + } +} + +int cursor_select(int items) { + int cursor_position = 1; + + printf("\x1b[%d;1H>", cursor_position); + while (true) { + hidScanInput(); + u32 key_down = hidKeysDown(); + + if (key_down & KEY_DDOWN) { + printf("\x1b[%d;1H ", cursor_position); + cursor_position = (cursor_position >= items) ? 1 : cursor_position + 1; + printf("\x1b[%d;1H>", cursor_position); + } + if (key_down & KEY_DUP) { + printf("\x1b[%d;1H ", cursor_position); + cursor_position = (cursor_position <= 1) ? items : cursor_position - 1; + printf("\x1b[%d;1H>", cursor_position); + } + if (key_down & KEY_B) { + return 0; + } + if (key_down & KEY_A) { + break; + } + + printf("\x1b[10;16Hcursorpos: %d", cursor_position); + } + return cursor_position; +} + +void print_menu(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) { + consoleClear(); + print_menu(menu_items, items_length); + int selection = cursor_select(items_length); + return selection; +} + diff --git a/source/main.c b/source/main.c new file mode 100644 index 0000000..c9f8aeb --- /dev/null +++ b/source/main.c @@ -0,0 +1,21 @@ +#include +#include "include.h" +#include "main_menu.h" + +int user_money = 0; + +int held_pukekos = 0; + +int main(int argc, char **argv) { + srand(time(NULL)); + gfxInitDefault(); + consoleInit(GFX_TOP, NULL); + + //printf("\x1b[15;13HPress the start button to start..."); + //waitForKey(KEY_START); + consoleClear(); + + print_main_menu(); + + return 0; +} diff --git a/source/main_menu.c b/source/main_menu.c new file mode 100644 index 0000000..56ac052 --- /dev/null +++ b/source/main_menu.c @@ -0,0 +1,31 @@ +#include "main_menu.h" +#include "include.h" +#include "pukeko.h" +#include "debug.h" + +void print_main_menu() { + int items_length = 3; + char menu_items[10][32] = { + "Catch pukekos", + "Debugging", + "Quit" + }; + + while (true) { + int selection = print_select_menu(menu_items, items_length); + + switch (selection) { + case 1: + consoleClear(); + print_game_screen(); + break; + + case 2: + print_debug_menu(); + break; + + case 3: + return; + } + } +} diff --git a/source/pukeko.c b/source/pukeko.c new file mode 100644 index 0000000..6285395 --- /dev/null +++ b/source/pukeko.c @@ -0,0 +1,44 @@ +#include "include.h" +#include "pukeko.h" + +void print_top_info() { + printf("\x1b[1;1H(A) Catch Pukeko!!!"); + printf("\x1b[2;1H(Y) Sell Pukeko... :("); + printf("\x1b[30;1H(B) Go back"); +} + +void print_bottom_info() { + consoleInit(GFX_BOTTOM, NULL); + printf("\x1b[1;1HMoney: %d", user_money); + + printf("\x1b[3;1HPukekos: %d", held_pukekos); + consoleInit(GFX_TOP, NULL); +} + +void catch_pukeko() { + int random_number = rand() % 5 + 1; + + printf("\x1b[1;1HDAMN!!! "); + held_pukekos = held_pukekos + random_number; + sleep(2); + print_bottom_info(); + print_top_info(); + printf("\x1b[1;1H(A) Catch Pukeko!!!"); +} + +void print_game_screen() { + print_bottom_info(); + print_top_info(); + + while (true) { + hidScanInput(); + u32 key_down = hidKeysDown(); + + if (key_down & KEY_A) { + catch_pukeko(); + } + if (key_down & KEY_B) { + return; + } + } +}