diff --git a/misc/n64/Makefile b/misc/n64/Makefile
index d1ebca610..598ca4304 100644
--- a/misc/n64/Makefile
+++ b/misc/n64/Makefile
@@ -5,14 +5,17 @@ SOURCE_DIR = src
N64_ROM_TITLE = "ClassiCube"
N64_ROM_RTC = true
-include $(N64_INST)/include/n64.mk
-
CFILES := $(notdir $(wildcard src/*.c))
OFILES := $(CFILES:.c=.o)
OBJS := $(addprefix $(BUILD_DIR)/,$(OFILES))
-CFLAGS := "-DNINTENDO64 -Wno-error=missing-braces"
+CFLAGS := "-Wno-error=missing-braces -Wno-error=maybe-uninitialized"
+
+include $(N64_INST)/include/n64.mk
ClassiCube-n64.z64: N64_ROM_TITLE = "ClassiCube"
+ClassiCube-n64.z64: $(BUILD_DIR)/filesystem.dfs
+
+$(BUILD_DIR)/filesystem.dfs: misc/n64/default.zip
$(BUILD_DIR)/ClassiCube-n64.elf: $(OBJS)
diff --git a/misc/n64/default.zip b/misc/n64/default.zip
new file mode 100644
index 000000000..ca55af9ba
Binary files /dev/null and b/misc/n64/default.zip differ
diff --git a/readme.md b/readme.md
index 1315bc9a1..b731cb6f4 100644
--- a/readme.md
+++ b/readme.md
@@ -83,6 +83,7 @@ And also runs on:
* PS Vita - unfinished, rendering issues (if you have a GitHub account, can [download from here](https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_vita.yml))
* Xbox - unfinished, major rendering issues (if you have a GitHub account, can [download from here](https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_xbox.yml))
* PS3 - unfinished, rendering issues
+* Nintendo 64 - unfinished, major rendering issues
# Compiling
@@ -293,6 +294,14 @@ Run `make dreamcast`. You'll need [KallistiOS](https://github.com/KallistiOS/Kal
The Dreamcast port needs assistance from someone experienced with Dreamcast homebrew development - if you're interested, please get in contact with me. (`unknownshadow200` on Discord)
+#### Nintendo 64
+
+Run `make n64`. You'll need the opengl branch of [libdragon](https://github.com/DragonMinded/libdragon/tree/opengl)
+
+The Nintendo 64 port needs assistance from someone experienced with Nintendo 64 homebrew development - if you're interested, please get in contact with me. (`unknownshadow200` on Discord)
+
+You'll also need to stub out `WorkerLoop` function in `Http_Worker.c` for now
+
##### Other
You'll have to write the necessary code. You should read portability.md in doc folder.
@@ -347,6 +356,9 @@ Further information (e.g. style) for ClassiCube's source code can be found in th
* [nxdk](https://github.com/XboxDev/nxdk) - Backend for Xbox
* [xemu](https://github.com/xemu-project/xemu) - Emulator used to test Xbox port
* [cxbx-reloaded](https://github.com/Cxbx-Reloaded/Cxbx-Reloaded) - Emulator used to test Xbox port
+* [libdragon](https://github.com/DragonMinded/libdragon) - Backend for Nintendo 64
+* [cen64](https://github.com/n64dev/cen64) - Emulator used to test Nintendo 64 port
+* [ares](https://github.com/ares-emulator/ares) - Emulator used to test Nintendo 64 port
## Sound Credits
diff --git a/src/ClassiCube.vcxproj b/src/ClassiCube.vcxproj
index d306ed5fb..c0ed83da6 100644
--- a/src/ClassiCube.vcxproj
+++ b/src/ClassiCube.vcxproj
@@ -475,6 +475,7 @@
+
diff --git a/src/ClassiCube.vcxproj.filters b/src/ClassiCube.vcxproj.filters
index 7434b907a..48c76b48e 100644
--- a/src/ClassiCube.vcxproj.filters
+++ b/src/ClassiCube.vcxproj.filters
@@ -686,6 +686,9 @@
Source Files\Window
+
+ Source Files\Graphics
+
diff --git a/src/Core.h b/src/Core.h
index 4193ca3f7..8cf07f44b 100644
--- a/src/Core.h
+++ b/src/Core.h
@@ -304,7 +304,7 @@ typedef cc_uint8 cc_bool;
#define CC_BUILD_LOWMEM
#define CC_BUILD_BEARSSL
#undef CC_BUILD_FREETYPE
-#elif defined NINTENDO64
+#elif defined N64
#define CC_BUILD_HTTPCLIENT
#define CC_BUILD_OPENAL
#define CC_BUILD_N64
diff --git a/src/Graphics_N64.c b/src/Graphics_N64.c
index 4506a0cdd..14ab3ce99 100644
--- a/src/Graphics_N64.c
+++ b/src/Graphics_N64.c
@@ -127,6 +127,7 @@ static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, cc_uint8 flags, cc_boo
glGenTextures(1, &tex->textureID);
glBindTexture(GL_TEXTURE_2D, tex->textureID);
+ // NOTE: Enabling these fixes textures, but seems to break on cen64
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -207,8 +208,8 @@ void Gfx_SetColWriteMask(cc_bool r, cc_bool g, cc_bool b, cc_bool a) {
//glColorMask(r, g, b, a); TODO
}
-void Gfx_SetDepthWrite(cc_bool enabled) { }
-void Gfx_SetDepthTest(cc_bool enabled) { }
+void Gfx_SetDepthWrite(cc_bool enabled) { glDepthMask(enabled); }
+void Gfx_SetDepthTest(cc_bool enabled) { gl_Toggle(GL_DEPTH_TEST); }
static void Gfx_FreeState(void) { FreeDefaultResources(); }
static void Gfx_RestoreState(void) {
diff --git a/src/Platform_N64.c b/src/Platform_N64.c
index 9ae45b1ac..f01585cfd 100644
--- a/src/Platform_N64.c
+++ b/src/Platform_N64.c
@@ -42,8 +42,8 @@ cc_uint64 Stopwatch_Measure(void) {
}
void Platform_Log(const char* msg, int len) {
- write(STDOUT_FILENO, msg, len);
- write(STDOUT_FILENO, "\n", 1);
+ write(STDERR_FILENO, msg, len);
+ write(STDERR_FILENO, "\n", 1);
}
#define UnixTime_TotalMS(time) ((cc_uint64)time.tv_sec * 1000 + UNIX_EPOCH + (time.tv_usec / 1000))
@@ -69,12 +69,17 @@ void DateTime_CurrentLocal(struct DateTime* t) {
/*########################################################################################################################*
*-----------------------------------------------------Directory/File------------------------------------------------------*
*#########################################################################################################################*/
-static const cc_string root_path = String_FromConst("");
+static const cc_string root_path = String_FromConst("/");
static void GetNativePath(char* str, const cc_string* path) {
+ // TODO temp hack
+ cc_string path_ = *path;
+ int idx = String_IndexOf(path, '/');
+ if (idx >= 0) path_ = String_UNSAFE_SubstringAt(&path_, idx + 1);
+
Mem_Copy(str, root_path.buffer, root_path.length);
str += root_path.length;
- String_EncodeUtf8(str, path);
+ String_EncodeUtf8(str, &path_);
}
cc_result Directory_Create(const cc_string* path) {
@@ -93,11 +98,12 @@ static cc_result File_Do(cc_file* file, const cc_string* path) {
char str[NATIVE_STR_LEN];
GetNativePath(str, path);
- *file = -1;
- return ReturnCode_FileNotFound;
+ //*file = -1;
+ //return ReturnCode_FileNotFound;
// TODO: Why does trying this code break everything
int ret = dfs_open(str);
+ Platform_Log2("Opened %c = %i", str, &ret);
if (ret < 0) { *file = -1; return ret; }
*file = ret;
diff --git a/src/TexturePack.c b/src/TexturePack.c
index 7925cdd97..f31329812 100644
--- a/src/TexturePack.c
+++ b/src/TexturePack.c
@@ -134,16 +134,16 @@ cc_bool Atlas_TryChange(struct Bitmap* atlas) {
if (!Game_ValidateBitmapPow2(&terrain, atlas)) return false;
tileSize = atlas->width / ATLAS2D_TILES_PER_ROW;
- if (atlas->height < atlas->width) {
- Chat_AddRaw("&cUnable to use terrain.png from the texture pack.");
- Chat_AddRaw("&c Its height is less than its width.");
- return false;
- }
if (tileSize <= 0) {
Chat_AddRaw("&cUnable to use terrain.png from the texture pack.");
Chat_AddRaw("&c It must be 16 or more pixels wide.");
return false;
}
+ if (atlas->height < tileSize) {
+ Chat_AddRaw("&cUnable to use terrain.png from the texture pack.");
+ Chat_AddRaw("&c It must have at least one row in it.");
+ return false;
+ }
if (tileSize > Gfx.MaxTexWidth) {
Chat_AddRaw("&cUnable to use terrain.png from the texture pack.");
@@ -151,6 +151,12 @@ cc_bool Atlas_TryChange(struct Bitmap* atlas) {
&tileSize, &tileSize, &Gfx.MaxTexWidth, &Gfx.MaxTexHeight);
return false;
}
+
+ if (atlas->height < atlas->width) {
+ /* Probably wouldn't want to use these, but you still can technically */
+ Chat_AddRaw("&cHeight of terrain.png is less than its width.");
+ Chat_AddRaw("&c Some tiles will therefore appear completely white.");
+ }
if (atlas->width > Gfx.MaxTexWidth) {
/* Super HD textures probably won't work great on this GPU */
Chat_AddRaw("&cYou may experience significantly reduced performance.");