Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hacky port for original Xbox #1

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions desktop_version/CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ Contributors
* Emmanuel Vadot (@evadot)
* Rémi Verschelde (@akien-mga)
* viri (viri.me)
* Jannik Vogel (@JayFoxRox)
* Wouter (Xesxen)
103 changes: 103 additions & 0 deletions desktop_version/Makefile.nxdk
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
XBE_TITLE = VVVVVV
GEN_XISO = $(XBE_TITLE).iso

CXXFLAGS=-I$(CURDIR)/src \
-I$(CURDIR)/../third_party/tinyxml \
-I$(CURDIR)/../third_party/physfs \
-I$(CURDIR)/../third_party/lodepng \
-DBLOBCACHE=1 \
-Wall

CFLAGS=-DPHYSFS_NO_CDROM_SUPPORT=1 \
-DPHYSFS_SUPPORTS_ZIP=0 \
-DPHYSFS_SUPPORTS_7Z=0 \
-DPHYSFS_SUPPORTS_GRP=0 \
-DPHYSFS_SUPPORTS_HOG=0 \
-DPHYSFS_SUPPORTS_MVL=0 \
-DPHYSFS_SUPPORTS_WAD=0 \
-DPHYSFS_SUPPORTS_QPAK=0 \
-DPHYSFS_SUPPORTS_SLB=0 \
-DPHYSFS_SUPPORTS_ISO9660=0 \
-DPHYSFS_SUPPORTS_VDF=0 \
-Wall

# Source Lists
VVV_SRC=\
src/BinaryBlob.cpp \
src/BlockV.cpp \
src/editor.cpp \
src/Ent.cpp \
src/Entity.cpp \
src/FileSystemUtils.cpp \
src/Finalclass.cpp \
src/Game.cpp \
src/Graphics.cpp \
src/GraphicsResources.cpp \
src/GraphicsUtil.cpp \
src/Input.cpp \
src/KeyPoll.cpp \
src/Labclass.cpp \
src/Logic.cpp \
src/Map.cpp \
src/Music.cpp \
src/Otherlevel.cpp \
src/preloader.cpp \
src/Screen.cpp \
src/Script.cpp \
src/Scripts.cpp \
src/SoundSystem.cpp \
src/Spacestation2.cpp \
src/TerminalScripts.cpp \
src/Textbox.cpp \
src/titlerender.cpp \
src/Tower.cpp \
src/UtilityClass.cpp \
src/WarpClass.cpp \
src/main.cpp \
src/Network.c \
src/SteamNetwork.c \
src/GOGNetwork.c

XML_SRC=\
../third_party/tinyxml/tinystr.cpp \
../third_party/tinyxml/tinyxml.cpp \
../third_party/tinyxml/tinyxmlerror.cpp \
../third_party/tinyxml/tinyxmlparser.cpp

PFS_SRC=\
../third_party/physfs/physfs.c \
../third_party/physfs/physfs_archiver_dir.c \
../third_party/physfs/physfs_archiver_unpacked.c \
../third_party/physfs/physfs_archiver_zip.c \
../third_party/physfs/physfs_byteorder.c \
../third_party/physfs/physfs_unicode.c \
../third_party/physfs/physfs_platform_posix.c \
../third_party/physfs/physfs_platform_unix.c \
../third_party/physfs/physfs_platform_windows.c

PNG_SRC=../third_party/lodepng/lodepng.c

SRCS += $(VVV_SRC) $(XML_SRC) $(PFS_SRC) $(PNG_SRC)
SRCS := $(addprefix $(CURDIR)/, $(SRCS))

NXDK_SDL = y
NXDK_CXX = y

NXDK_STACKSIZE = 131072

all_local: all

include $(NXDK_DIR)/Makefile

download_data: $(OUTPUT_DIR)/data.zip

# You need data.zip from https://thelettervsixtim.es/makeandplay/
$(OUTPUT_DIR)/data.zip:
@mkdir -p $(OUTPUT_DIR)
wget -N https://thelettervsixtim.es/makeandplay/data.zip -O $(OUTPUT_DIR)/data.zip

install_data: $(OUTPUT_DIR)/data.zip
@mkdir -p $(OUTPUT_DIR)/VVVVVV
unzip -o $(OUTPUT_DIR)/data.zip -d $(OUTPUT_DIR)/VVVVVV; true
rm -f $(OUTPUT_DIR)/VVVVVV/vvvvvvmusic.vvv
rm -f $(OUTPUT_DIR)/data.zip
10 changes: 10 additions & 0 deletions desktop_version/src/FileSystemUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@

#if defined(_WIN32)
#include <windows.h>
#if !defined(XBOX)
#include <shlobj.h>
int mkdir(char* path, int mode)
{
WCHAR utf16_path[MAX_PATH];
MultiByteToWideChar(CP_UTF8, 0, path, -1, utf16_path, MAX_PATH);
return CreateDirectoryW(utf16_path, NULL);
}
#else
#define mkdir(a, b) CreateDirectory(a, NULL)
#endif
#define VNEEDS_MIGRATION (mkdirResult != 0)
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__)
#include <sys/stat.h>
Expand Down Expand Up @@ -194,11 +198,17 @@ std::vector<std::string> FILESYSTEM_getLevelDirFileNames()
void PLATFORM_getOSDirectory(char* output)
{
#ifdef _WIN32
#if !defined(XBOX)
/* This block is here for compatibility, do not touch it! */
WCHAR utf16_path[MAX_PATH];
SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, utf16_path);
WideCharToMultiByte(CP_UTF8, 0, utf16_path, -1, output, MAX_PATH, NULL, NULL);
strcat(output, "\\VVVVVV\\");
#else
//FIXME: strcpy(output, "T:\\UDATA"); ?
strcpy(output, "D:");
strcat(output, "\\VVVVVV\\");
#endif
#else
strcpy(output, PHYSFS_getPrefDir("distractionware", "VVVVVV"));
#endif
Expand Down
18 changes: 17 additions & 1 deletion desktop_version/src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@

// lol, Win32 -flibit
#ifdef _WIN32
#ifndef XBOX
#define strcasecmp stricmp
#else
#define strcasecmp strcmp //FIXME: !!!
#endif
#endif

//TODO: Non Urgent code cleanup
Expand Down Expand Up @@ -190,7 +194,7 @@ Game::Game(void):
slowdown = 30;
gameframerate=34;

fullscreen = false;// true; //Assumed true at first unless overwritten at some point!
fullscreen = false; //true; //Assumed true at first unless overwritten at some point!
stretchMode = 0;
useLinearFilter = false;
advanced_mode = false;
Expand Down Expand Up @@ -7042,6 +7046,18 @@ void Game::createmenu( std::string t )
menuxoff = 20;
menuyoff = 64;
}
#ifdef XBOX
else if (t == "credits2X")
{
menuoptions[0] = "next page";
menuoptionsactive[0] = true;
menuoptions[1] = "return";
menuoptionsactive[1] = true;
nummenuoptions = 2;
menuxoff = 20;
menuyoff = 64;
}
#endif
else if (t == "credits25")
{
menuoptions[0] = "next page";
Expand Down
23 changes: 23 additions & 0 deletions desktop_version/src/Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,28 @@ SDL_assert(0 && "Remove open level dir");
{
//next page
music.playef(11, 10);
#ifndef XBOX
game.createmenu("credits2");
#else
game.createmenu("credits2X");
#endif
map.nexttowercolour();
}
else
{
//back
music.playef(11, 10);
game.createmenu("mainmenu");
map.nexttowercolour();
}
}
#ifdef XBOX
else if (game.currentmenuname == "credits2X")
{
if (game.currentmenuoption == 0)
{
//next page
music.playef(11, 10);
game.createmenu("credits25");
map.nexttowercolour();
}
Expand All @@ -1060,6 +1082,7 @@ SDL_assert(0 && "Remove open level dir");
map.nexttowercolour();
}
}
#endif
else if (game.currentmenuname == "credits25")
{
if (game.currentmenuoption == 0)
Expand Down
35 changes: 34 additions & 1 deletion desktop_version/src/SoundSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "SoundSystem.h"
#include "FileSystemUtils.h"

#include <hal/debug.h>

MusicTrack::MusicTrack(const char* fileName)
{
m_music = Mix_LoadMUS(fileName);
Expand Down Expand Up @@ -32,7 +34,9 @@ SoundTrack::SoundTrack(const char* fileName)
size_t length = 0;
FILESYSTEM_loadFileToMemory(fileName, &mem, &length);
SDL_RWops *fileIn = SDL_RWFromMem(mem, length);
debugPrint("Loading sound %p %p\n", fileIn, mem);
sound = Mix_LoadWAV_RW(fileIn, 1);
debugPrint("Loaded sound %p\n", sound);
if (length)
{
FILESYSTEM_freeMemory(&mem);
Expand All @@ -44,18 +48,47 @@ SoundTrack::SoundTrack(const char* fileName)
}
}

#include <xboxkrnl/xboxkrnl.h>


extern "C" {
extern int nextCol;
extern int nextRow;
}

SoundSystem::SoundSystem()
{
int audio_rate = 44100;
Uint16 audio_format = AUDIO_S16SYS;
int audio_channels = 2;
int audio_buffers = 1024;

#if 0
if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0)
{
fprintf(stderr, "Unable to initialize audio: %s\n", Mix_GetError());
SDL_assert(0 && "Unable to initialize audio!");
}
debugPrint("Okay!\n");

nextCol = 25;
nextRow = 300;

debugPrint(" Memory statistics:\n");
MM_STATISTICS ms;
ms.Length = sizeof(MM_STATISTICS);
MmQueryStatistics(&ms);
#define PRINT(stat) debugPrint(" - " #stat ": %d\n", ms.stat);
PRINT(TotalPhysicalPages)
PRINT(AvailablePages)
PRINT(VirtualMemoryBytesCommitted)
PRINT(VirtualMemoryBytesReserved)
PRINT(CachePagesCommitted)
PRINT(PoolPagesCommitted)
PRINT(StackPagesCommitted)
PRINT(ImagePagesCommitted)
#undef PRINT

#endif
}

void SoundSystem::playMusic(MusicTrack* music)
Expand Down
Loading