Skip to content

Commit

Permalink
Calculator_NX Rewrite (and version 2.0.0) (#10)
Browse files Browse the repository at this point in the history
* Removed all code and updated README

* borealis subrepo stuff

* Added simple calculator tab view layout

* Calculator tab is now functional!

* Fixed bug where the screen wouldn't update when a button is pressed

* In-progress of adding the update feature

* More borealis subrepo stuff

* Added exponent operator

* Update feature is now fully working!

* Added message to exit app after finished update

* Added wrapper for curl

* Updated borealis submodule

* Added tesla overlay

* Preparing for release 2.0.0

* Last commit before rewrite merge
  • Loading branch information
EmmmaTech authored Aug 18, 2021
1 parent 4a32904 commit 04754ce
Show file tree
Hide file tree
Showing 1,257 changed files with 2,003 additions and 367,797 deletions.
29 changes: 0 additions & 29 deletions .github/workflows/main.yml

This file was deleted.

7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
build/*
cnx_forwarder/build/*
overlay/build/*
*.elf
*.nacp
*.nro
*.dksh
*.dksh
*.ovl
.vscode/*
./resources/shaders/**
resources/shaders/fill_vsh.dksh
7 changes: 7 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[submodule "lib/borealis"]
path = lib/borealis
url = https://github.com/EmreTech/borealis.git
branch = working-yoga
[submodule "overlay/lib/libtesla"]
path = overlay/lib/libtesla
url = https://github.com/WerWolv/libtesla.git
39 changes: 23 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,25 @@ include $(DEVKITPRO)/libnx/switch_rules
# of a homebrew executable (.nro). This is intended to be used for sysmodules.
# NACP building is skipped as well.
#---------------------------------------------------------------------------------
VERSION := 1.3.2
STABLE := Beta 2
VERSION := 2.0.0
STABLE := Stable

APP_TITLE := Calculator_NX
APP_AUTHOR := EmreTech
APP_TITLE := Calculator_NX Rewrite
APP_AUTHOR := EmreTech
APP_VERSION := ${VERSION} ${STABLE}
ICON := resources/icon/Calculator_NX_Icon.jpg
ICON := resources/icon/Calculator_NX_Icon.jpg

TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := core/source gui/source
SOURCES := source source/common lib/nxdumptool
DATA := data
INCLUDES := core/include gui/include $(BOREALIS_PATH)/library/include/borealis/extern/nlohmann/
ROMFS := resources
BOREALIS_PATH := lib/borealis
INCLUDES := include include/common lib/nxdumptool

OUT_SHADERS := shaders
ROMFS := resources
BOREALIS_PATH := lib/borealis

# Output folders for autogenerated files in romfs
OUT_SHADERS := shaders

#---------------------------------------------------------------------------------
# options for code generation
Expand All @@ -63,9 +65,9 @@ ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
CFLAGS := -g -Wall -O2 -ffunction-sections \
$(ARCH) $(DEFINES) `curl-config --cflags`

CFLAGS += $(INCLUDE) -D__SWITCH__
CFLAGS += $(INCLUDE) -D__SWITCH__ -DVERSION_NUM=\"$(VERSION)\" -DSTABLE=\"$(STABLE)\"

CXXFLAGS := $(CFLAGS) -std=c++17 -fexceptions -O2 -Wno-volatile
CXXFLAGS := $(CFLAGS) -std=c++17 -O2 -Wno-volatile

ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
Expand Down Expand Up @@ -180,13 +182,17 @@ ifneq ($(ROMFS),)
export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
endif

.PHONY: all clean
.PHONY: all clean $(ROMFS)

#---------------------------------------------------------------------------------
all: $(ROMFS_TARGETS) | $(BUILD)
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
@MSYS2_ARG_CONV_EXCL="-D;$(MSYS2_ARG_CONV_EXCL)" $(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

$(ROMFS):
@echo Merging ROMFS...
@cp $(CURDIR)/cnx_forwarder/cnx_forwarder.nro $(CURDIR)/$(ROMFS)/cnx_forwarder.nro

$(BUILD):
$(BUILD): $(ROMFS)
@mkdir -p $@

ifneq ($(strip $(ROMFS_TARGETS)),)
Expand Down Expand Up @@ -227,6 +233,7 @@ clean:
@echo clean ...
ifeq ($(strip $(APP_JSON)),)
@rm -fr $(BUILD) $(ROMFS_FOLDERS) $(TARGET).nro $(TARGET).nacp $(TARGET).elf
@rm -fr $(CURDIR)/cnx_forwarder/build $(CURDIR)/cnx_forwarder/*.nro $(CURDIR)/cnx_forwarder/*.nacp $(CURDIR)/cnx_forwarder/*.elf
else
@rm -fr $(BUILD) $(ROMFS_FOLDERS) $(TARGET).nsp $(TARGET).nso $(TARGET).npdm $(TARGET).elf
endif
Expand Down Expand Up @@ -277,4 +284,4 @@ $(OFILES_SRC) : $(HFILES_BIN)

#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------
51 changes: 12 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,26 @@
![Icon photo for Calculator_NX](./resources/Calculator_NX.jpg)

# Calculator_NX
This is my C++ Calculator program, ported to the Nintendo Switch.

This app can now be used in a GUI way, or the normal Command-Line looking way. The app by default uses the GUI version. The command-line version (or CMD for short) has been deprecated. You should instead use the GUI version.
### Currently under a rewrite. All features may not be implemented or work correctly.

[Join the Discord Server!](https://discord.gg/WXKMvK2NRe)
## Features

## COMPLATION INSTRUCTIONS
Calculator_NX can calculate any expression with the addition, subtraction, multiplication, division and exopoint operators.
Calculator_NX includes a homebrew app which has full support for all the features, and a Tesla menu overlay, which can only calculate expressions (no updating or about tab).

Compiling this program requires the libnx library and any other libraries required by libnx. These can be installed via [devkitpro.](https://devkitpro.org/wiki/Getting_Started)
## Compile

You also need some additional libraries for Borealis from devkitpro. Use `(sudo) (dkp-)pacman -S switch-glfw switch-mesa switch-glm` to download those libraries.
In order to compile, you need to setup a development environment.
[Refer to the Getting Started guide](https://devkitpro.org/wiki/Getting_Started) to start.

You also need switch-curl, which is also from devkitpro. Use `(sudo) (dkp-)pacman -S switch-curl` to download it.

You can then `git clone` this repo to any folder on your computer. To compile on Unix-based distros (these instructions are mostly for macOS & Linux), run `make` while in the root of the repo. To compile on Windows is unknown to me, so feel free to change this for instructions on Windows.

### Complation troubleshooting

When you ran the command `make` and it gives an error like: `Please set DEVKITPRO in your environment`, this means you have to edit the .bash_profile file (this file differs from versions of macOS/Linux) to add the following:
After it's fully installed, please install the dependencies below.
```bash
export DEVKITPRO=/opt/devkitpro
export DEVKITA64=/opt/devkitpro/devkitA64
export DEVKITARM=/opt/devkitpro/devkitARM
export DEVKITPPC=/opt/devkitpro/devkitPPC
export PATH=$DEVKITPPC/bin:$DEVKITPRO/tools/bin:$PATH
(sudo) (dkp-)pacman -S switch-glfw switch-mesa switch-glm switch-curl
```

Any errors relating to borealis should be reported.

## PLANNED FEATURES

Some planned features include translating the app. If you know English and another language (it doesn't have to be well), then join my Discord Server and we can discuss the translating part!

## CREDITS

Switchbrew for making libnx

The people on the ReSwitched Discord server for helping me

The people on the Switchroot Discord server for helping me on my original Calculator program (this is based on that)

natinusala and any contributors for creating the borealis library

The people on the RetroNX Discord server for helping me on using borealis

## LICENSE
Finally, run the `build.sh` file which will build the cnx_forwarder, the Calculator_NX app, and the Calculator_NX overlay.

Calculator_NX uses the MIT License. Read the license for more details.
## License

borealis uses the Apache v2.0 License. Read the license in borealis/LICENSE for more details.
Calculator_NX uses the MIT License. Read the license for more details.
18 changes: 18 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

# Set dir to project root
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $DIR

# Make the cnx_forwarder
pushd cnx_forwarder
make
popd

# Make the main application
make

# Make the overlay
pushd overlay
make
popd
96 changes: 21 additions & 75 deletions lib/borealis/Makefile → cnx_forwarder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,15 @@ include $(DEVKITPRO)/libnx/switch_rules
# of a homebrew executable (.nro). This is intended to be used for sysmodules.
# NACP building is skipped as well.
#---------------------------------------------------------------------------------
TARGET := borealis_demo
BUILD := build.nx
SOURCES := demo
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
ICON := resources/icon/borealis.jpg
INCLUDES := demo

APP_TITLE := borealis demo
APP_AUTHOR := natinusala
APP_VERSION := 1.0

ROMFS := resources
BOREALIS_PATH := .

# Output folders for autogenerated files in romfs
OUT_SHADERS := shaders
INCLUDES := include
APP_TITLE := Calculator_NX Forwarder
APP_AUTHOR := EmreTech
APP_VERSION := 1.0
#ROMFS := romfs

#---------------------------------------------------------------------------------
# options for code generation
Expand All @@ -64,7 +57,7 @@ CFLAGS := -g -Wall -O2 -ffunction-sections \

CFLAGS += $(INCLUDE) -D__SWITCH__

CXXFLAGS := $(CFLAGS) -std=c++1z -O2 -Wno-volatile
CXXFLAGS := $(CFLAGS) -std=gnu++17 -fno-rtti -fno-exceptions

ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
Expand All @@ -77,7 +70,6 @@ LIBS := -lnx
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS) $(LIBNX)

include $(TOPDIR)/library/borealis.mk

#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
Expand All @@ -97,7 +89,6 @@ 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)))
GLSLFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.glsl)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))

#---------------------------------------------------------------------------------
Expand All @@ -119,18 +110,6 @@ export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))

ifneq ($(strip $(ROMFS)),)
ROMFS_TARGETS :=
ROMFS_FOLDERS :=
ifneq ($(strip $(OUT_SHADERS)),)
ROMFS_SHADERS := $(ROMFS)/$(OUT_SHADERS)
ROMFS_TARGETS += $(patsubst %.glsl, $(ROMFS_SHADERS)/%.dksh, $(GLSLFILES))
ROMFS_FOLDERS += $(ROMFS_SHADERS)
endif

export ROMFS_DEPS := $(foreach file,$(ROMFS_TARGETS),$(CURDIR)/$(file))
endif

export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
Expand Down Expand Up @@ -175,59 +154,26 @@ ifneq ($(APP_TITLEID),)
export NACPFLAGS += --titleid=$(APP_TITLEID)
endif

ifneq ($(ROMFS),)
export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
endif
#ifneq ($(ROMFS),)
# export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
#endif

.PHONY: all clean
.PHONY: $(BUILD) clean all

#---------------------------------------------------------------------------------
all: $(ROMFS_TARGETS) | $(BUILD)
@MSYS2_ARG_CONV_EXCL="-D;$(MSYS2_ARG_CONV_EXCL)" $(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
all: $(BUILD)

$(BUILD):
@mkdir -p $@

ifneq ($(strip $(ROMFS_TARGETS)),)

$(ROMFS_TARGETS): | $(ROMFS_FOLDERS)

$(ROMFS_FOLDERS):
@mkdir -p $@

$(ROMFS_SHADERS)/%_vsh.dksh: %_vsh.glsl
@echo {vert} $(notdir $<)
@uam -s vert -o $@ $<

$(ROMFS_SHADERS)/%_tcsh.dksh: %_tcsh.glsl
@echo {tess_ctrl} $(notdir $<)
@uam -s tess_ctrl -o $@ $<

$(ROMFS_SHADERS)/%_tesh.dksh: %_tesh.glsl
@echo {tess_eval} $(notdir $<)
@uam -s tess_eval -o $@ $<

$(ROMFS_SHADERS)/%_gsh.dksh: %_gsh.glsl
@echo {geom} $(notdir $<)
@uam -s geom -o $@ $<

$(ROMFS_SHADERS)/%_fsh.dksh: %_fsh.glsl
@echo {frag} $(notdir $<)
@uam -s frag -o $@ $<

$(ROMFS_SHADERS)/%.dksh: %.glsl
@echo {comp} $(notdir $<)
@uam -s comp -o $@ $<

endif
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

#---------------------------------------------------------------------------------
clean:
@echo clean ...
ifeq ($(strip $(APP_JSON)),)
@rm -fr $(BUILD) $(ROMFS_FOLDERS) $(TARGET).nro $(TARGET).nacp $(TARGET).elf
@rm -fr $(BUILD) $(TARGET).nro $(TARGET).nacp $(TARGET).elf
else
@rm -fr $(BUILD) $(ROMFS_FOLDERS) $(TARGET).nsp $(TARGET).nso $(TARGET).npdm $(TARGET).elf
@rm -fr $(BUILD) $(TARGET).nsp $(TARGET).nso $(TARGET).npdm $(TARGET).elf
endif


Expand All @@ -245,9 +191,9 @@ ifeq ($(strip $(APP_JSON)),)
all : $(OUTPUT).nro

ifeq ($(strip $(NO_NACP)),)
$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp $(ROMFS_DEPS)
$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp
else
$(OUTPUT).nro : $(OUTPUT).elf $(ROMFS_DEPS)
$(OUTPUT).nro : $(OUTPUT).elf
endif

else
Expand Down Expand Up @@ -276,4 +222,4 @@ $(OFILES_SRC) : $(HFILES_BIN)

#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------
Loading

0 comments on commit 04754ce

Please sign in to comment.