diff --git a/.github/actions/action.yml b/.github/actions/action.yml
new file mode 100644
index 000000000..df55028e7
--- /dev/null
+++ b/.github/actions/action.yml
@@ -0,0 +1,8 @@
+name: 'Make Nintendont'
+description: 'Compiles Nintendont'
+
+runs:
+ using: 'docker'
+ # Oldest tag I can find with both devkitARM and devkitPPC.
+ image: 'devkitpro/devkitppc:20210619'
+ entrypoint: make
\ No newline at end of file
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 000000000..195d14393
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,29 @@
+name: CI
+
+on: [push, pull_request]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Compile Nintendont
+ uses: ./.github/actions
+ # The build process updates NintendontVersion.h with minor version set to be
+ # the GitHub CI workflow number. More importantly, we get the main binary,
+ # loader.dol. Both of them needs to be committed back to the repo because
+ # the online update feature fetches directly from the repo. Assume major
+ # version is 7, update common/include/NintendontVersion.h too for a major
+ # version change.
+ - name: Commit loader.dol
+ run: |
+ git config user.name '${{ github.actor }}'
+ git config user.email '${{ github.actor }}@users.noreply.github.com'
+ git add -f loader/loader.dol common/include/NintendontVersion.h
+ ( git commit -m "loader.dol v7.${{ github.run_number }}" && git push ) || true
+ - uses: actions/upload-artifact@v1
+ with:
+ name: Nintendont
+ path: build/
diff --git a/.gitignore b/.gitignore
index c1cf9e5c9..652c34111 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,11 +2,11 @@
*.o
*.bin
*.elf
+build/
codehandler/*.h
kernel/asm/*.h
kernel/kernel.map
loader/build/
loader/data/kernel.zip
-nintendont/boot.dol
fatfs/*.a
-codehandler/*.h
\ No newline at end of file
+codehandler/*.h
diff --git a/Makefile b/Makefile
index 3096e4665..621c25a80 100644
--- a/Makefile
+++ b/Makefile
@@ -15,11 +15,23 @@ SUBPROJECTS := multidol kernel/asm resetstub \
fatfs/libfat-arm.a fatfs/libfat-ppc.a \
codehandler kernel kernelboot \
loader/source/ppc/PADReadGC loader/source/ppc/IOSInterface loader
+# This is where titles.txt and icon.png will be copied to
+ARTIFACTS := build/app/Nintendont
+NINTENTDONTVERSION_H := common/include/NintendontVersion.h
.PHONY: all forced clean $(SUBPROJECTS)
-all: loader
+all: nintendontversion loader copy_files
forced: clean all
+# change version number
+nintendontversion:
+ @echo " "
+ @echo "Update version number (if available)"
+ @echo " "
+ if [ -n "$(GITHUB_RUN_NUMBER)" ]; then \
+ sed -i 's/#define NIN_MINOR_VERSION.*$$/#define NIN_MINOR_VERSION\t\t\t$(GITHUB_RUN_NUMBER)/' $(NINTENTDONTVERSION_H); \
+ fi
+
multidol:
@echo " "
@echo "Building Multi-DOL loader"
@@ -86,6 +98,16 @@ loader: multidol resetstub fatfs/libfat-ppc.a kernel kernelboot loader/source/pp
@echo " "
$(MAKE) -C loader
+# After building, assemble a build directory. GitHub will zip it and it can be
+# downloaded and extracted to a SD card or HDD.
+copy_files:
+ @echo " "
+ @echo "Copying files"
+ @echo " "
+ mkdir -p $(ARTIFACTS)
+ cp -p nintendont/icon.png nintendont/titles.txt $(ARTIFACTS)
+ unzip -d build/controllers -q -n controllerconfigs/controllers.zip
+
clean:
@echo " "
@echo "Cleaning all subprojects..."
diff --git a/common/include/Metadata.h b/common/include/Metadata.h
index c18535251..4ad4a46fb 100644
--- a/common/include/Metadata.h
+++ b/common/include/Metadata.h
@@ -4,9 +4,11 @@
#define META_NAME "Nintendont"
#define META_AUTHOR "FIX94, crediar"
-
-#define META_LONG1 "Commiters: GerbilSoft, JoostinOnline, GreyRogue, Howard, Cyan \r\n\r\n Project website: https://github.com/FIX94/Nintendont "
-#define META_LONG2 "Nintendont allows you to run GameCube games on a Wii or Wii U from an SD or HDD device."
+#if !defined(META_DATETIME)
+# define META_DATETIME "20160710000000"
+#endif
+#define META_LONG1 "Nintendont allows you to run GameCube games on a Wii or Wii U from an SD or HDD device."
+#define META_LONG2 " Project website: https://github.com/FIX94/Nintendont\r\n\r\nCommitters: GerbilSoft, JoostinOnline, GreyRogue, Howard, Cyan, nastys, carnage702, AnthonyRyuki, DankRank, Chickoodel, akemin-dayo, SuperrSonic, KoldMonster12, cheatfreak47, capnfunky77, cesarmades, crazycaveman, Wolfy76700, AndyCasaceli, ShadowOne333, Aurelio92, darkalemanbr, jmapjp, sailormoon, Dr-Crow, cyberstudio10, corey-underdown"
#define META_SHORT "Gamecube Loader"
#define META_XML ""
diff --git a/common/include/NintendontVersion.h b/common/include/NintendontVersion.h
index ae361e838..ea91accd8 100644
--- a/common/include/NintendontVersion.h
+++ b/common/include/NintendontVersion.h
@@ -1,8 +1,11 @@
#ifndef __NINTENDONT_VERSION_H__
#define __NINTENDONT_VERSION_H__
-#define NIN_MAJOR_VERSION 6
-#define NIN_MINOR_VERSION 498
+/* Minor version to be automatically filled in by GitHub CI. Any major version
+ * change will have to update main.yml. Online updates fetch this file directly
+ * from the repo and scanf these version numbers. */
+#define NIN_MAJOR_VERSION 7
+#define NIN_MINOR_VERSION 12
#define NIN_VERSION ((NIN_MAJOR_VERSION << 16) | NIN_MINOR_VERSION)
diff --git a/loader/Makefile b/loader/Makefile
index 2748d5c20..18575f1d8 100644
--- a/loader/Makefile
+++ b/loader/Makefile
@@ -15,6 +15,7 @@ include $(DEVKITPPC)/wii_rules
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
+# ARTIFACTS is to package a zip for the user to unpack to their SD card/HDD
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
@@ -22,6 +23,16 @@ SOURCES := source
SOURCES += source/unzip
DATA := data
INCLUDES := include ../fatfs
+ARTIFACTS := ../build/apps/Nintendont
+NINTENTDONTVERSION_H := ../common/include/NintendontVersion.h
+
+#---------------------------------------------------------------------------------
+# metadata
+#---------------------------------------------------------------------------------
+# If dol does not come from FIX94 we identify source on the screen
+NIN_SPECIAL_VERSION := $(if $(and $(GITHUB_REPOSITORY_OWNER),$(findstring FIX94,$(GITHUB_REPOSITORY_OWNER))),,\"-$(GITHUB_REPOSITORY_OWNER)\")
+# As preprocessor defines, DATETIME is unquoted, META_DATETIME is quoted
+DATETIME := $(shell git show -s --format=%cI | grep -o -E "[[:digit:]]*" - | head -n 6 | paste -sd '')
#---------------------------------------------------------------------------------
# options for code generation
@@ -29,7 +40,9 @@ INCLUDES := include ../fatfs
ASFLAGS := $(MACHDEP) -mregnames -D_LANGUAGE_ASSEMBLY
CFLAGS := -O3 -g -std=gnu89 -Wno-format-truncation \
- -Wall $(MACHDEP) $(INCLUDE) -DDEBUG -DDEBUG_MODULE_PATCH -DARCH_IS_BIG_ENDIAN
+ -Wall $(MACHDEP) $(INCLUDE) -DDEBUG -DDEBUG_MODULE_PATCH -DARCH_IS_BIG_ENDIAN \
+ -DNIN_SPECIAL_VERSION=$(NIN_SPECIAL_VERSION) \
+ -DMETA_DATETIME=\"$(DATETIME)\"
CXXFLAGS := $(CFLAGS)
# NOTE: Do NOT change to := - needed for proper expansion of $(CURDIR) later.
@@ -103,10 +116,19 @@ export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
+# 1, build loader.dol
+# 2, output meta.xml using C preprocessor on a template
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
- @cp $(OUTPUT).dol ../nintendont/boot.dol
+ @[ -d $(ARTIFACTS) ] || mkdir -p $(ARTIFACTS)
+ @cp -p $(OUTPUT).dol $(ARTIFACTS)/boot.dol
+ $(CC) -E -traditional -P \
+ -include $(NINTENTDONTVERSION_H) \
+ -DDATETIME=$(DATETIME) \
+ ../metaxml.sx \
+ | sed -n '/^ $(ARTIFACTS)/meta.xml
#---------------------------------------------------------------------------------
clean:
diff --git a/loader/loader.dol b/loader/loader.dol
index 89412a9da..ad5ea7751 100644
Binary files a/loader/loader.dol and b/loader/loader.dol differ
diff --git a/loader/source/main.c b/loader/source/main.c
index 37b452865..e70574278 100644
--- a/loader/source/main.c
+++ b/loader/source/main.c
@@ -151,7 +151,7 @@ static void updateMetaXml(void)
"\t" META_NAME "\r\n"
"\t" META_AUTHOR "\r\n"
"\t%d.%d%s\r\n"
- "\t20160710000000\r\n"
+ "\t" META_DATETIME "\r\n"
"\t" META_SHORT "\r\n"
"\t" META_LONG1 "\r\n\r\n" META_LONG2 "\r\n"
"\t\r\n"
diff --git a/loader/source/usbstorage.c b/loader/source/usbstorage.c
index e38920a90..e76b1ba96 100644
--- a/loader/source/usbstorage.c
+++ b/loader/source/usbstorage.c
@@ -946,27 +946,31 @@ static bool __usbstorage_IsInserted(void)
// If not, it might be a Wii U drive.
retval = USBStorageOGC_Read(&__usbfd, __lun, 0, 1, sector_buf);
if (retval == 0) {
- if (sector_buf[510] == 0x55 &&
- (sector_buf[511] == 0xAA || sector_buf[511] == 0xAB))
- {
- // Valid MBR and/or UStealth signature.
- __mounted = true;
- __vid = vid;
- __pid = pid;
- usb_last_used = gettime()-secs_to_ticks(100);
- usleep(10000);
- } else {
- // Invalid signature.
+ // discard first read. I've seen a controller so buggy which returns the boot sector of LUN 1 when that of LUN 0 is asked for.
+ usb_last_used = gettime()-secs_to_ticks(100);
+ usleep(10000);
+ retval = USBStorageOGC_Read(&__usbfd, __lun, 0, 1, sector_buf);
+ if (retval == 0) {
+ if (sector_buf[510] == 0x55 &&
+ (sector_buf[511] == 0xAA || sector_buf[511] == 0xAB))
+ {
+ // Valid MBR and/or UStealth signature.
+ __mounted = true;
+ __vid = vid;
+ __pid = pid;
+ usb_last_used = gettime()-secs_to_ticks(100);
+ usleep(10000);
+ break; // found valid signature. Done!
+ }
+ // Else invalid signature.
// This may be a Wii U-formatted HDD.
- __mounted = false;
- __lun = 0;
}
- } else {
- // Read error.
- __mounted = false;
- __lun = 0;
+ // Else read error.
}
- break;
+ // Else read error.
+ __mounted = false;
+ __lun = 0;
+ // continue scanning for next LUN instead of giving up
}
if (__mounted)
diff --git a/metaxml.sx b/metaxml.sx
new file mode 100644
index 000000000..de86eb898
--- /dev/null
+++ b/metaxml.sx
@@ -0,0 +1,15 @@
+
+
+ Nintendont
+ FIX94, crediar
+ NIN_MAJOR_VERSION.NIN_MINOR_VERSION
+ DATETIME
+ Gamecube Loader
+ Nintendont allows you to run GameCube games on a Wii or Wii U from an SD or HDD device.
+
+ Project website: https://github.com/FIX94/Nintendont
+
+Committers: GerbilSoft, JoostinOnline, GreyRogue, Howard, Cyan, nastys, carnage702, AnthonyRyuki, DankRank, Chickoodel, akemin-dayo, SuperrSonic, KoldMonster12, cheatfreak47, capnfunky77, cesarmades, crazycaveman, Wolfy76700, AndyCasaceli, ShadowOne333, Aurelio92, darkalemanbr, jmapjp, sailormoon, Dr-Crow, cyberstudio10, corey-underdown
+
+
+
diff --git a/nintendont/meta.xml b/nintendont/meta.xml
deleted file mode 100644
index 906d76d92..000000000
--- a/nintendont/meta.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
- Nintendont
- FIX94, crediar
- 4.431
- 20161218000000
- Gamecube Loader
- Commiters: GerbilSoft, JoostinOnline, GreyRogue, Howard, Cyan, nastys
-
- Project website: https://github.com/FIX94/Nintendont
-
-Nintendont allows you to run GameCube games on a Wii or Wii U from an SD or HDD device.
-
-
-