Skip to content

Commit

Permalink
Dummy Xbox port
Browse files Browse the repository at this point in the history
  • Loading branch information
JayFoxRox committed Dec 15, 2019
1 parent 5ee13f2 commit dc1bf59
Show file tree
Hide file tree
Showing 25 changed files with 1,668 additions and 11 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@
/mapc.exe
/contrib/curve.exe
/*.dll

*.obj
/bin
/main.exe
/main.lib
/*.iso
/default.xbe
123 changes: 123 additions & 0 deletions Makefile.nxdk
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
NXDK_DIR = $(CURDIR)/../XboxDev/nxdk

XBE_TITLE = NeverballX
OUTPUT_DIR = bin
GEN_XISO = $(XBE_TITLE).iso

CFLAGS =

CFLAGS += -ferror-limit=0

CFLAGS += -DENABLE_OPENGLES=1
#CFLAGS += -DCONFIG_USER=\"$(USERDIR)\" \
#CFLAGS += -DCONFIG_DATA=\"$(DATADIR)\" \
#CFLAGS += -DCONFIG_LOCALE=\"$(LOCALEDIR)\"
CFLAGS += -I$(CURDIR)/share/ -I$(CURDIR)/xbox/ -D_CRTIMP=

BALL_SRCS := \
$(CURDIR)/share/lang.c \
$(CURDIR)/share/st_common.c \
$(CURDIR)/share/vec3.c \
$(CURDIR)/share/base_image.c \
$(CURDIR)/share/image.c \
$(CURDIR)/share/solid_base.c \
$(CURDIR)/share/solid_vary.c \
$(CURDIR)/share/solid_draw.c \
$(CURDIR)/share/solid_all.c \
$(CURDIR)/share/mtrl.c \
$(CURDIR)/share/part.c \
$(CURDIR)/share/geom.c \
$(CURDIR)/share/ball.c \
$(CURDIR)/share/gui.c \
$(CURDIR)/share/font.c \
$(CURDIR)/share/theme.c \
$(CURDIR)/share/base_config.c \
$(CURDIR)/share/config.c \
$(CURDIR)/share/video.c \
$(CURDIR)/share/glext.c \
$(CURDIR)/share/binary.c \
$(CURDIR)/share/state.c \
$(CURDIR)/share/audio.c \
$(CURDIR)/share/text.c \
$(CURDIR)/share/common.c \
$(CURDIR)/share/list.c \
$(CURDIR)/share/queue.c \
$(CURDIR)/share/cmd.c \
$(CURDIR)/share/array.c \
$(CURDIR)/share/dir.c \
$(CURDIR)/share/fbo.c \
$(CURDIR)/share/glsl.c \
$(CURDIR)/share/fs_common.c \
$(CURDIR)/share/fs_png.c \
$(CURDIR)/share/fs_jpg.c \
$(CURDIR)/share/fs_ov.c \
$(CURDIR)/share/log.c \
$(CURDIR)/share/joy.c \
$(CURDIR)/ball/hud.c \
$(CURDIR)/ball/game_common.c \
$(CURDIR)/ball/game_client.c \
$(CURDIR)/ball/game_server.c \
$(CURDIR)/ball/game_proxy.c \
$(CURDIR)/ball/game_draw.c \
$(CURDIR)/ball/score.c \
$(CURDIR)/ball/level.c \
$(CURDIR)/ball/progress.c \
$(CURDIR)/ball/set.c \
$(CURDIR)/ball/demo.c \
$(CURDIR)/ball/demo_dir.c \
$(CURDIR)/ball/util.c \
$(CURDIR)/ball/st_conf.c \
$(CURDIR)/ball/st_demo.c \
$(CURDIR)/ball/st_save.c \
$(CURDIR)/ball/st_goal.c \
$(CURDIR)/ball/st_fail.c \
$(CURDIR)/ball/st_done.c \
$(CURDIR)/ball/st_level.c \
$(CURDIR)/ball/st_over.c \
$(CURDIR)/ball/st_play.c \
$(CURDIR)/ball/st_set.c \
$(CURDIR)/ball/st_start.c \
$(CURDIR)/ball/st_title.c \
$(CURDIR)/ball/st_help.c \
$(CURDIR)/ball/st_name.c \
$(CURDIR)/ball/st_shared.c \
$(CURDIR)/ball/st_pause.c \
$(CURDIR)/ball/st_ball.c \
$(CURDIR)/ball/main.c

BALL_SRCS += share/solid_sim_sol.c
BALL_SRCS += share/fs_stdio.c
BALL_SRCS += share/tilt_null.c
BALL_SRCS += share/hmd_null.c

SRCS = $(BALL_SRCS) xbox/xbox.c
#SHADER_OBJS = ps.inl vs.inl

# Add SDL
NXDK_SDL = y

# Add vorbis and ogg
include $(CURDIR)/xbox/Makefile-vorbis.xbox
include $(CURDIR)/xbox/Makefile-ogg.xbox

# Add libjpeg
include $(CURDIR)/xbox/Makefile-libjpeg-turbo.xbox

# Add libpng (depends on zlib)
include $(CURDIR)/xbox/Makefile-zlib.xbox
include $(CURDIR)/xbox/Makefile-libpng.xbox

# XGU
CFLAGS += -I$(CURDIR)/xbox/nxdk/lib

all: $(OUTPUT_DIR)/default.xbe data $(GEN_XISO)

# Add data to XISO
#FIXME: Copy files to $(OUTPUT_DIR)
data: force
@echo "Updating data"
@cp -r $(CURDIR)/data $(OUTPUT_DIR)

force:

include $(NXDK_DIR)/Makefile
7 changes: 7 additions & 0 deletions share/base_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
#include "fs.h"

#ifdef _WIN32
#ifndef NXDK
#include <shlobj.h>
#endif
#endif

/*---------------------------------------------------------------------------*/

Expand Down Expand Up @@ -51,6 +53,7 @@ static const char *pick_data_path(const char *arg_data_path)
static const char *pick_home_path(void)
{
#ifdef _WIN32
#ifndef NXDK
static char path[MAX_PATH];

if (SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, path) == S_OK)
Expand All @@ -67,6 +70,10 @@ static const char *pick_home_path(void)
}
else
return fs_base_dir();
#else
//FIXME: Xbox
return fs_base_dir();
#endif
#else
const char *path;

Expand Down
4 changes: 4 additions & 0 deletions share/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,14 @@ int rand_between(int low, int high)

#ifdef _WIN32

#ifndef NXDK
/* MinGW hides this from ANSI C. MinGW-w64 doesn't. */
_CRTIMP int _putenv(const char *envstring);
#endif

int set_env_var(const char *name, const char *value)
{
#ifndef NXDK
if (name)
{
char str[MAXSTR];
Expand All @@ -345,6 +348,7 @@ int set_env_var(const char *name, const char *value)

return (_putenv(str) == 0);
}
#endif
return 0;
}

Expand Down
48 changes: 41 additions & 7 deletions share/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
* General Public License for more details.
*/

#ifndef _WIN32
#include <dirent.h>
#else
#include <windows.h>
#endif

#include <string.h>
#include <stdlib.h>
Expand All @@ -21,17 +25,13 @@
#include "dir.h"
#include "common.h"

/*
* HACK: MinGW provides numerous POSIX extensions to MSVCRT, including
* dirent.h, so parasti ever so lazily has not bothered to port the
* code below to FindFirstFile et al.
*/

List dir_list_files(const char *path)
{
DIR *dir;
List files = NULL;

#ifndef _WIN32
DIR *dir;

if ((dir = opendir(path)))
{
struct dirent *ent;
Expand All @@ -46,6 +46,26 @@ List dir_list_files(const char *path)

closedir(dir);
}
#else
printf("Asking for files in '%s'\n", path);

HANDLE hFind;
WIN32_FIND_DATA FindFileData;

hFind = FindFirstFile(path, &FindFileData);
if (hFind != INVALID_HANDLE_VALUE)
{
BOOL status = TRUE;
while(status != FALSE)
{
//FIXME: Handle wide strings?
files = list_cons(strdup(FindFileData.cFileName), files);

FindNextFile(hFind, &FindFileData);
}
FindClose(hFind);
}
#endif

return files;
}
Expand Down Expand Up @@ -122,6 +142,7 @@ void dir_free(Array items)

int dir_exists(const char *path)
{
#ifndef _WIN32
DIR *dir;

if ((dir = opendir(path)))
Expand All @@ -130,4 +151,17 @@ int dir_exists(const char *path)
return 1;
}
return 0;
#else
printf("Looking for '%s'\n", path);
#ifdef NXDK
//FIXME: nxdk issue #161
DWORD dwAttrib = 0;
#define INVALID_FILE_ATTRIBUTES -1
#else
DWORD dwAttrib = GetFileAttributes(path);
#endif

return ((dwAttrib != INVALID_FILE_ATTRIBUTES) &&
(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) ? 1 : 0;
#endif
}
5 changes: 5 additions & 0 deletions share/fs_stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ static List fs_path;

int fs_init(const char *argv0)
{
if (!argv0)
{
argv0 = "";
}

fs_dir_base = strdup(dir_name(argv0));
fs_dir_write = NULL;
fs_path = NULL;
Expand Down
5 changes: 3 additions & 2 deletions share/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,9 @@ static void draw_enable(GLboolean c, GLboolean u, GLboolean p)

static void draw_rect(int id)
{
glDrawElements(GL_TRIANGLE_STRIP, RECT_ELEM, GL_UNSIGNED_SHORT,
(const GLvoid *) (id * WIDGET_ELEM * sizeof (GLushort)));
printf("Tried to draw %d\n", RECT_ELEM);
glDrawElements(GL_TRIANGLE_STRIP, RECT_ELEM, GL_UNSIGNED_SHORT,
(const GLvoid *) (id * WIDGET_ELEM * sizeof (GLushort)));
}

static void draw_text(int id)
Expand Down
6 changes: 4 additions & 2 deletions share/solid_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,10 @@ void sol_draw_mesh(const struct d_mesh *mp, struct s_rend *rend, int p)

if (rend->curr_mtrl.base.fl & M_PARTICLE)
glDrawArrays(GL_POINTS, 0, mp->vbc);
else
glDrawElements(GL_TRIANGLES, mp->ebc, GL_UNSIGNED_SHORT, 0);
else {
printf("Tried to draw %d (solid)\n", mp->ebc);
glDrawElements(GL_TRIANGLES, mp->ebc, GL_UNSIGNED_SHORT, 0);
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions share/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ int video_mode(int f, int w, int h)
w, h, (f ? "fullscreen" : "windowed"));

window = SDL_CreateWindow("", X, Y, w, h,
#ifndef NXDK
SDL_WINDOW_OPENGL |
#endif
(highdpi ? SDL_WINDOW_ALLOW_HIGHDPI : 0) |
(f ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0));

Expand Down
Loading

0 comments on commit dc1bf59

Please sign in to comment.