Skip to content

Commit

Permalink
Tested on Xubuntu 16.04.3 x64
Browse files Browse the repository at this point in the history
  • Loading branch information
roukaour committed Sep 25, 2017
1 parent a5b4283 commit 3074535
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 28 deletions.
72 changes: 72 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Install Guide

## Windows

TODO: Visual Studio instructions.


## Linux

Run the following commands:

```bash
sudo apt-get install make g++ git unzip
sudo apt-get install zlib1g-dev libpng-dev libxpm-dev libx11-dev libxft-dev libxinerama-dev libfontconfig1-dev x11proto-xext-dev libxrender-dev libxfixes-dev

git clone https://github.com/roukaour/polished-map.git
cd polished-map/lib
unzip fltk-1.3.4.zip
cd fltk-1.3.4

chmod +x configure
./configure --with-abiversion=10304
sudo make
sudo make install
cp lib/*.a ../linux

cd ../..

make install
```

To build **polishedcrystal.gbc**:

```bash
make
```

To build other versions:

```bash
make [faithful] [nortc] [monochrome] [debug]
```


## Mac OS X

In **Terminal**, run:

```bash
xcode-select --install

git clone https://github.com/rednex/rgbds.git
cd rgbds
git checkout v0.3.1
sudo make install
cd ..

git clone https://github.com/roukaour/polishedcrystal.git
cd polishedcrystal
```

To build **polishedcrystal.gbc**:

```bash
make
```

To build other versions:

```bash
make [faithful] [nortc] [monochrome] [debug]
```
23 changes: 5 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ DEBUGOBJDIR = tmp/$(OSDIRNAME)/debug
LIBDIR = lib/$(OSDIRNAME)
BINDIR = bin/$(OSDIRNAME)

CXXFLAGS = -std=c++11 -isystem include -isystem /usr/include -I$(SRCDIR) -I$(RESDIR) -Wall -Wno-unknown-pragmas
LDFLAGS = $(wildcard $(LIBDIR)/*.a) -lm -lpng -lz -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lX11 -lXpm
CXXFLAGS = -std=c++11 -isystem include -isystem /usr/include -I$(SRCDIR) -I$(RESDIR)
LDFLAGS = $(wildcard $(LIBDIR)/*.a) -lm -lpng -lz -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lX11 -lXpm -lXrender

RELEASEFLAGS = -DNDEBUG -O2 -flto -march=native
DEBUGFLAGS = -DDEBUG -D_DEBUG -O0 -g -ggdb3 -Wextra -pedantic -Wsign-conversion
DEBUGFLAGS = -DDEBUG -D_DEBUG -O0 -g -ggdb3 -Wall -Wextra -pedantic -Wsign-conversion

COMMON = $(wildcard $(SRCDIR)/*.h) $(wildcard $(RESDIR)/*.xpm)
SOURCES = $(wildcard $(SRCDIR)/*.cpp)
Expand Down Expand Up @@ -70,18 +70,5 @@ clean:
-@ $(RM) $(TARGET) $(DEBUGTARGET) $(OBJECTS) $(DEBUGOBJECTS)
@ echo Done cleaning

install:
sudo apt-get install make g++ git unzip

git clone https://github.com/roukaour/polished-map.git
cd polished-map/lib
unzip fltk-1.3.4.zip
cd fltk-1.3.4

./configure --with-abiversion=10304
make
sudo make install

cd ../..

make $(BINNAME)
install: release
cp $(TARGET) /usr/local/bin/$(BINNAME)
25 changes: 18 additions & 7 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,36 @@
#include "utils.h"
#include "config.h"

#ifndef _WIN32
#include <libgen.h>
#endif

Fl_Preferences global_config(Fl_Preferences::USER, PROGRAM_AUTHOR, PROGRAM_NAME);

const char *gfx_tileset_dir() {
return "gfx\\tilesets\\";
return "gfx" DIR_SEP "tilesets" DIR_SEP;
}

bool project_path_from_blk_path(const char *blk_path, char *project_path, bool prism) {
#ifdef _WIN32
if (_splitpath_s(blk_path, NULL, 0, project_path, FL_PATH_MAX, NULL, 0, NULL, 0)) { return false; }
strcat(project_path, prism ? "..\\..\\" : "..\\"); // go up from maps/
#else
char *blk = strdup(blk_path);
strcpy(project_path, dirname(blk));
free(blk);
strcat(project_path, DIR_SEP);
#endif
strcat(project_path, prism ? ".." DIR_SEP ".." DIR_SEP : ".." DIR_SEP); // go up from maps/
return true;
}

void blk_path_from_project_path(const char *project_path, char *blk_path, bool prism) {
strcpy(blk_path, project_path);
strcat(blk_path, prism ? "maps\\blk\\" : "maps\\");
strcat(blk_path, prism ? "maps" DIR_SEP "blk" DIR_SEP : "maps" DIR_SEP);
}

void palette_map_path(char *dest, const char *root, const char *tileset) {
sprintf(dest, "%stilesets\\%s_palette_map.asm", root, tileset);
sprintf(dest, "%stilesets" DIR_SEP "%s_palette_map.asm", root, tileset);
}

void tileset_path(char *dest, const char *root, const char *tileset) {
Expand All @@ -41,12 +52,12 @@ void tileset_path(char *dest, const char *root, const char *tileset) {
}

void metatileset_path(char *dest, const char *root, const char *tileset) {
sprintf(dest, "%stilesets\\%s_metatiles.bin", root, tileset);
sprintf(dest, "%stilesets" DIR_SEP "%s_metatiles.bin", root, tileset);
}

void map_constants_path(char *dest, const char *root) {
// prefer map_dimension_constants.asm to map_constants.asm
sprintf(dest, "%sconstants\\map_dimension_constants.asm", root);
sprintf(dest, "%sconstants" DIR_SEP "map_dimension_constants.asm", root);
if (file_exists(dest)) { return; }
sprintf(dest, "%sconstants\\map_constants.asm", root);
sprintf(dest, "%sconstants" DIR_SEP "map_constants.asm", root);
}
3 changes: 2 additions & 1 deletion src/main-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#ifdef _WIN32
#include "resource.h"
#else
#include <X11/xpm.h>
#include "app-icon.xpm"
#endif

Expand Down Expand Up @@ -802,7 +803,7 @@ void Main_Window::new_cb(Fl_Widget *, Main_Window *mw) {
const char *project_dir = mw->_new_dir_chooser->filename();
char directory[FL_PATH_MAX] = {};
strcpy(directory, project_dir);
strcat(directory, "\\");
strcat(directory, DIR_SEP);
mw->open_map(directory, NULL);
}

Expand Down
8 changes: 8 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,20 @@ int main(int argc, char **argv) {
Fl::visual(FL_DOUBLE | FL_RGB);

int theme;
#ifdef _WIN32
global_config.get("theme", theme, (int)OS::Theme::BLUE);
#else
global_config.get("theme", theme, (int)OS::Theme::GREYBIRD);
#endif
use_theme((OS::Theme)theme);

int x, y, w, h;
global_config.get("x", x, 48);
#ifdef _WIN32
global_config.get("y", y, 48 + GetSystemMetrics(SM_CYCAPTION));
#else
global_config.get("y", y, 48);
#endif
global_config.get("w", w, 640);
global_config.get("h", h, 480);
Main_Window window(x, y, w, h);
Expand Down
2 changes: 1 addition & 1 deletion src/themes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,7 @@ void OS::use_native_font() {
use_font("Segoe UI", "Tahoma");

#else
use_font("Droid Sans", "Sans");
use_font("Noto Sans", "Droid Sans");
#endif
}

Expand Down
1 change: 1 addition & 0 deletions src/tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define TILE_H

#include <cstdlib>
#include <cstring>

#pragma warning(push, 0)
#include <FL/fl_types.h>
Expand Down
2 changes: 1 addition & 1 deletion src/tiled-image.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma warning(push, 0)
#include <FL/fl_utf8.H>
#include <FL/fl_utf8.h>
#include <FL/Fl_PNG_Image.H>
#pragma warning(pop)

Expand Down
8 changes: 8 additions & 0 deletions src/utils.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#ifdef _WIN32
#include <io.h>
#else
#include <unistd.h>
#endif

#pragma warning(push, 0)
#include <FL/fl_draw.H>
Expand Down Expand Up @@ -37,5 +41,9 @@ int text_width(const char *l, int pad) {
}

bool file_exists(const char *f) {
#ifdef _WIN32
return !_access_s(f, 4);
#else
return !access(f, 4);
#endif
}
11 changes: 11 additions & 0 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

#include <iostream>
#include <sstream>

#ifdef _WIN32

#include <windows.h>

#define DEBUGPRINT(X) \
Expand All @@ -27,12 +30,20 @@
} while (0) \
__pragma(warning(pop))

#endif

#else

#define DEBUGPRINT(X)

#endif

#ifdef _WIN32
#define DIR_SEP "\\"
#else
#define DIR_SEP "/"
#endif

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))

Expand Down

0 comments on commit 3074535

Please sign in to comment.