Skip to content

Commit

Permalink
Merge pull request #50 from DaniElectra/module
Browse files Browse the repository at this point in the history
  • Loading branch information
ashquarky authored Nov 21, 2024
2 parents cc96712 + 0f3115a commit 2bf5f8b
Show file tree
Hide file tree
Showing 37 changed files with 1,024 additions and 371 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ jobs:
build-inkay:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: build toolchain container
run: docker build . -t builder
- uses: ammaraskar/gcc-problem-matcher@master
- name: build Inkay
run: docker run --rm -v ${PWD}:/app -w /app builder
- uses: actions/upload-artifact@master
- uses: actions/upload-artifact@v4
with:
name: inkay
path: "*.wps"
path: dist/
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
.cache/
.vscode/
.idea/
/build
/plugin/build
/dist
*.elf
*.wms
*.wps
certs/
*.lst
*.lst
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ COPY --from=ghcr.io/wiiu-env/libnotifications:20240426 /artifacts $DEVKITPRO
COPY --from=ghcr.io/wiiu-env/libfunctionpatcher:20230621 /artifacts $DEVKITPRO
COPY --from=ghcr.io/wiiu-env/libkernel:20230621 /artifacts $DEVKITPRO
COPY --from=ghcr.io/wiiu-env/libmocha:20231127 /artifacts $DEVKITPRO
COPY --from=ghcr.io/wiiu-env/wiiumodulesystem:20240424 /artifacts $DEVKITPRO
COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:20240505 /artifacts $DEVKITPRO

WORKDIR /app
CMD make -f Makefile -j$(nproc)
CMD make -f Makefile -j$(nproc)
47 changes: 28 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ endif

TOPDIR ?= $(CURDIR)

include $(DEVKITPRO)/wups/share/wups_rules
include $(DEVKITPRO)/wums/share/wums_rules

WUT_ROOT := $(DEVKITPRO)/wut
WUMS_ROOT := $(DEVKITPRO)/wums
WUT_ROOT := $(DEVKITPRO)/wut
#-------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
Expand All @@ -21,37 +21,35 @@ WUMS_ROOT := $(DEVKITPRO)/wums
#-------------------------------------------------------------------------------
TARGET := Inkay-pretendo
BUILD := build
SOURCES := src src/patches src/utils src/ext/inih
SOURCES := src src/patches src/utils src/ext/inih common
DATA := data
INCLUDES := src src/ext/inih
#DEBUG := 1
INCLUDES := src src/ext/inih src/lang common

#-------------------------------------------------------------------------------
# options for code generation
#-------------------------------------------------------------------------------
CFLAGS := -Wall -O2 -ffunction-sections -fdata-sections \
CFLAGS := -Wall -O2 -ffunction-sections\
$(MACHDEP)

CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ -D__WUPS__

ifeq ($(DEBUG),1)
CFLAGS += -DDEBUG -g
endif
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__

CXXFLAGS := $(CFLAGS) -std=c++20

ASFLAGS := -g $(ARCH)
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -Wl,-gc-sections
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -Wl,-gc-sections -T$(WUMS_ROOT)/share/libkernel.ld $(WUMSSPECS)

LDFLAGS += -T$(WUMS_ROOT)/share/libkernel.ld $(WUPSSPECS)
ifeq ($(DEBUG),1)
CXXFLAGS += -DDEBUG -g
CFLAGS += -DDEBUG -g
endif

LIBS := -lwups -lmocha -lkernel -lwut -lnotifications -lfunctionpatcher
LIBS := -lwums -lmocha -lkernel -lwut -lfunctionpatcher -lnotifications

#-------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level
# containing include and lib
#-------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS) $(WUMS_ROOT) $(WUPS_ROOT) $(WUT_ROOT) $(WUT_ROOT)/usr
LIBDIRS := $(PORTLIBS) $(WUT_ROOT) $(WUMS_ROOT) $(WUT_ROOT)/usr

#-------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
Expand Down Expand Up @@ -103,14 +101,20 @@ export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
#-------------------------------------------------------------------------------
all: $(BUILD)


$(BUILD):
@$(shell [ ! -d $(BUILD) ] && mkdir -p $(BUILD))
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
@$(MAKE) --no-print-directory -C $(CURDIR)/plugin -f $(CURDIR)/plugin/Makefile
mkdir -p dist/
cp *.wms dist/
cp plugin/*.wps dist/

#-------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).wps $(TARGET).elf
@rm -fr dist $(BUILD) $(TARGET).wms $(TARGET).elf
@$(MAKE) --no-print-directory -C $(CURDIR)/plugin -f $(CURDIR)/plugin/Makefile clean

#-------------------------------------------------------------------------------
else
Expand All @@ -121,10 +125,10 @@ DEPENDS := $(OFILES:.o=.d)
#-------------------------------------------------------------------------------
# main targets
#-------------------------------------------------------------------------------
all : $(OUTPUT).wps
all : $(OUTPUT).wms

$(OUTPUT).wps : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)
$(OUTPUT).wms : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)

$(OFILES_SRC) : $(HFILES_BIN)

Expand All @@ -141,6 +145,11 @@ $(OFILES_SRC) : $(HFILES_BIN)
@echo $(notdir $<)
@$(bin2o)

#---------------------------------------------------------------------------------
%.o: %.s
@echo $(notdir $<)
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ $(ERROR_FILTER)

-include $(DEPENDS)

#-------------------------------------------------------------------------------
Expand Down
File renamed without changes.
File renamed without changes.
44 changes: 44 additions & 0 deletions common/lang.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// Created by ash on 21/11/24.
//

#include "lang.h"

config_strings get_config_strings(nn::swkbd::LanguageType language) {
switch (language) {
case nn::swkbd::LanguageType::English:
default: return {
#include "en_US.lang"
};
case nn::swkbd::LanguageType::Spanish: return {
#include "es_ES.lang"
};
case nn::swkbd::LanguageType::French: return {
#include "fr_FR.lang"
};
case nn::swkbd::LanguageType::Italian: return {
#include "it_IT.lang"
};
case nn::swkbd::LanguageType::German: return {
#include "de_DE.lang"
};
case nn::swkbd::LanguageType::SimplifiedChinese: return {
#include "zh_CN.lang"
};
case nn::swkbd::LanguageType::TraditionalChinese: return {
#include "zh_Hant.lang"
};
case nn::swkbd::LanguageType::Portuguese: return {
#include "pt_BR.lang"
};
case nn::swkbd::LanguageType::Japanese: return {
#include "ja_JP.lang"
};
case nn::swkbd::LanguageType::Dutch: return {
#include "nl_NL.lang"
};
case nn::swkbd::LanguageType::Russian: return {
#include "ru_RU.lang"
};
}
}
22 changes: 22 additions & 0 deletions common/lang.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include <string_view>
#include <nn/swkbd.h>

struct config_strings {
const char *plugin_name;
std::string_view network_category;
std::string_view connect_to_network_setting;
std::string_view other_category;
std::string_view reset_wwp_setting;
std::string_view press_a_action;
std::string_view restart_to_apply_action;
std::string_view need_menu_action;
std::string_view using_nintendo_network;
std::string_view using_pretendo_network;
std::string_view multiplayer_port_display;
std::string_view module_not_found;
std::string_view module_init_not_found;
};

config_strings get_config_strings(nn::swkbd::LanguageType language);
22 changes: 19 additions & 3 deletions src/utils/sysconfig.cpp → common/sysconfig.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* Copyright 2024 Pretendo Network contributors <pretendo.network>
Copyright 2024 Ash Logan <[email protected]>
Copyright 2023 Maschell
Copyright 2020-2022 V10lator <[email protected]>
Copyright 2022 Xpl0itU <[email protected]>
Expand Down Expand Up @@ -81,8 +80,8 @@ static void get_mcp_config() {
mcp_os_version = os_version;

DEBUG_FUNCTION_LINE_VERBOSE("Running on %d.%d.%d%c; %s%s",
os_version.major, os_version.minor, os_version.patch, os_version.region
config.code_id, config.serial_id
os_version.major, os_version.minor, os_version.patch, os_version.region
config.code_id, config.serial_id
);
}

Expand All @@ -97,3 +96,20 @@ MCPSystemVersion get_console_os_version() {

return mcp_os_version.value_or((MCPSystemVersion) { .major = 5, .minor = 5, .patch = 5, .region = 'E' });
}

static inline int digit(char a) {
if (a < '0' || a > '9') return 0;
return a - '0';
}

uint16_t get_console_peertopeer_port() {
const char * serial = get_console_serial();

uint16_t port = 50000 +
(digit(serial[4]) * 1000) +
(digit(serial[5]) * 100 ) +
(digit(serial[6]) * 10 ) +
(digit(serial[7]) * 1 );

return port;
}
1 change: 1 addition & 0 deletions src/utils/sysconfig.h → common/sysconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
nn::swkbd::LanguageType get_system_language();
const char * get_console_serial();
MCPSystemVersion get_console_os_version();
unsigned short get_console_peertopeer_port();

#endif //INKAY_SYSCONFIG_H
File renamed without changes.
Loading

0 comments on commit 2bf5f8b

Please sign in to comment.