diff --git a/builds/amiga/EasyRPG-Player.info b/builds/amiga/EasyRPG-Player.info new file mode 100644 index 0000000000..f66b1bcca2 Binary files /dev/null and b/builds/amiga/EasyRPG-Player.info differ diff --git a/builds/amiga/Makefile b/builds/amiga/Makefile new file mode 100644 index 0000000000..9da8d49be1 --- /dev/null +++ b/builds/amiga/Makefile @@ -0,0 +1,70 @@ +TARGET := EasyRPG +BUILD := build +SOURCES := ../../src +OSTYPE := $(shell uname -s) + +CFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.c)) +CPPFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.cpp)) +OBJS := $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) + +ifeq ($(OSTYPE), MorphOS) +PREFIX = ppc-morphos +CC = $(PREFIX)-gcc -noixemul +CXX = $(PREFIX)-g++ -noixemul +TOOLCHAIN_DIR := /gg/usr +SDL_LIBS = -L$(TOOLCHAIN_DIR)/local/lib -lSDL_mixer -lSDL +SDL_CFLAGS = -I$(TOOLCHAIN_DIR)/local/include/SDL -I$(TOOLCHAIN_DIR)/local/include +PIXMAN_LIBS = -lpixman +PNG_LIBS = -lpng_shared +endif +ifeq ($(OSTYPE), AmigaOS) +PREFIX = ppc-amigaos +CC = $(PREFIX)-gcc -D_GLIBCXX_USE_C99_STDINT_TR1 +CXX = $(PREFIX)-g++ -D_GLIBCXX_USE_C99_STDINT_TR1 +TOOLCHAIN_DIR := /usr/local/amiga/ppc-amigaos/SDK/local/newlib +SDL_LIBS = -lSDL_mixer -lmikmod -lFLAC -lmodplug -lsmpeg -lSDL +SDL_CFLAGS = -I$(TOOLCHAIN_DIR)/include/SDL +PIXMAN_LIBS = -lpixman-1 +PNG_LIBS = -lpng -lz +endif + +ICU_LIBS = -licuuc -licui18n -licudata + +LIBS = -llcf -lexpat \ + $(PIXMAN_LIBS) $(PNG_LIBS) \ + -lfreetype -lmpg123 \ + -lvorbisfile -lvorbis -logg -lWildMidi \ + $(ICU_LIBS) \ + $(SDL_LIBS) + +ifeq ($(strip $(LIBLCF_DIR)),) +LIBLCF_DIR := $(TOOLCHAIN_DIR) +endif + +CFLAGS = -g -O2 +CXXFLAGS = $(CFLAGS) -std=gnu++11 -fno-exceptions -fno-rtti +ASFLAGS = $(CFLAGS) +CPPFLAGS = -DUSE_SDL -DHAVE_SDL_MIXER -DHAVE_FREETYPE -DSUPPORT_AUDIO \ + -DHAVE_MPG123 -DHAVE_OGGVORBIS -DHAVE_WILDMIDI -DWANT_FASTWAV \ + -I$(TOOLCHAIN_DIR)/include \ + $(SDL_CFLAGS) \ + -I$(LIBLCF_DIR)/include/liblcf \ + -I$(TOOLCHAIN_DIR)/include/pixman-1 \ + -I$(TOOLCHAIN_DIR)/include/freetype2 \ + -I$(TOOLCHAIN_DIR)/include/libxmp-lite \ + -I$(TOOLCHAIN_DIR)/include/opus + +LDFLAGS = -L$(TOOLCHAIN_DIR)/lib \ + -L$(LIBLCF_DIR)/lib + +all: $(TARGET).elf + +%.o: %.cpp + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@ + +$(TARGET).elf: $(OBJS) + $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) $(LIBS) -o $@ + $(PREFIX)-strip -g -o $(basename $@)-stripped.elf $@ + +clean: + rm -rf $(TARGET).elf $(TARGET)-stripped.elf $(OBJS) diff --git a/src/async_handler.h b/src/async_handler.h index 8a501b9e7c..a2c5f672ee 100644 --- a/src/async_handler.h +++ b/src/async_handler.h @@ -23,6 +23,10 @@ #include #include +#ifdef __MORPHOS__ +#undef bind +#endif + class FileRequestAsync; struct FileRequestResult; diff --git a/src/decoder_wildmidi.cpp b/src/decoder_wildmidi.cpp index c3ae82aa50..0cb0bf26af 100644 --- a/src/decoder_wildmidi.cpp +++ b/src/decoder_wildmidi.cpp @@ -197,6 +197,11 @@ WildMidiDecoder::WildMidiDecoder(const std::string file_name) { } // TODO: We need some installer which creates registry keys for wildmidi +# elif defined(__MORPHOS__) || defined(__amigaos4__) + if (!found) { + config_file = "timidity/timidity.cfg"; + found = FileFinder::Exists(config_file); + } # else if (!found) { config_file = "/etc/timidity.cfg"; @@ -245,6 +250,11 @@ WildMidiDecoder::WildMidiDecoder(const std::string file_name) { return; } +#if defined(__MORPHOS__) || defined(__amigaos4__) + // the default volume is way too quiet with the SDL_mixer patches + WildMidi_MasterVolume(127); +#endif + // setup deinitialization atexit(WildMidiDecoder_deinit); } diff --git a/src/filefinder.cpp b/src/filefinder.cpp index 866f3bcdb4..315a06eabb 100644 --- a/src/filefinder.cpp +++ b/src/filefinder.cpp @@ -68,6 +68,10 @@ # include #endif +#ifdef __MORPHOS__ +#undef bind +#endif + #include "system.h" #include "options.h" #include "utils.h" diff --git a/src/game_character.h b/src/game_character.h index d6ad263800..7163604cdd 100644 --- a/src/game_character.h +++ b/src/game_character.h @@ -23,6 +23,10 @@ #include "color.h" #include "rpg_moveroute.h" +#ifdef __MORPHOS__ +#undef Wait +#endif + /** * Game_Character class. */ diff --git a/src/image_png.cpp b/src/image_png.cpp index 99a4b60b5f..9ef2b6da51 100644 --- a/src/image_png.cpp +++ b/src/image_png.cpp @@ -19,6 +19,9 @@ #ifdef SUPPORT_PNG // Headers +#ifdef __MORPHOS__ +#define __MORPHOS_SHAREDLIBS +#endif #include #include #include diff --git a/src/main_data.cpp b/src/main_data.cpp index 75b40f0d04..7d7a1f4c5b 100644 --- a/src/main_data.cpp +++ b/src/main_data.cpp @@ -34,7 +34,7 @@ #include #endif -#ifdef GEKKO +#if defined(GEKKO) || defined(__MORPHOS__) || defined(__amigaos4__) #include #endif @@ -83,11 +83,11 @@ void Main_Data::Init() { // first set to current directory for all platforms project_path = "."; -#ifdef GEKKO - // Working directory not correctly handled under Wii - char gekko_dir[256]; - getcwd(gekko_dir, 255); - project_path = std::string(gekko_dir); +#if defined(GEKKO) || defined(__MORPHOS__) || defined(__amigaos4__) + // Working directory not correctly handled + char working_dir[256]; + getcwd(working_dir, 255); + project_path = std::string(working_dir); #elif defined(PSP2) // Check if app0 filesystem contains the title id reference file FILE* f = fopen("app0:/titleid.txt","r"); diff --git a/src/output.h b/src/output.h index c5d2957a30..020bbb9ac9 100644 --- a/src/output.h +++ b/src/output.h @@ -22,6 +22,10 @@ #include #include +#ifdef __MORPHOS__ +#undef Debug +#endif + /** * Output Namespace. */ diff --git a/src/sdl_ui.cpp b/src/sdl_ui.cpp index 89ab0f4cf6..6cf214f920 100644 --- a/src/sdl_ui.cpp +++ b/src/sdl_ui.cpp @@ -89,7 +89,7 @@ SdlUi::SdlUi(long width, long height, bool fs_flag) : // Set some SDL environment variables before starting. These are platform // dependent, so every port needs to set them manually -#ifndef GEKKO +#if !defined(GEKKO) && !defined(__MORPHOS__) // Set window position to the middle of the screen putenv(const_cast("SDL_VIDEO_WINDOW_POS=center")); #endif @@ -423,6 +423,90 @@ bool SdlUi::ShowCursor(bool flag) { void SdlUi::Blit2X(Bitmap const& src, SDL_Surface* dst_surf) { if (SDL_MUSTLOCK(dst_surf)) SDL_LockSurface(dst_surf); +#if defined(__MORPHOS__) || defined(__amigaos4__) + // Quick & dirty big endian 2x zoom blitter + int blit_height = src.height() * 2; + int blit_width = src.width(); + int src_pitch = src.pitch(); + int dst_pitch = dst_surf->pitch; + int dst_bpp = sdl_surface->format->BitsPerPixel; + + uint8_t* src_pixels = (uint8_t*)src.pixels(); + uint8_t* dst_pixels = (uint8_t*)dst_surf->pixels; + + switch (dst_bpp) { + case 32: + for (int i = 0; i < blit_height; i++) { + uint32_t* src = (uint32_t*)src_pixels; + uint32_t* dst = (uint32_t*)dst_pixels; + for (int j = 0; j < blit_width; j++) { + uint32_t pixel = *src; + *dst++ = pixel; + *dst++ = pixel; + src++; + } + dst_pixels += dst_pitch; + if (i & 1) { + src_pixels += src_pitch; + } + } + break; + case 24: + for (int i = 0; i < blit_height; i++) { + uint32_t* src = (uint32_t*)src_pixels; + uint8_t* dst = (uint8_t*)dst_pixels; + for (int j = 0; j < blit_width; j++) { + uint8_t* pixels = (uint8_t*)src + 1; + *dst++ = *pixels++; + *dst++ = *pixels++; + *dst++ = *pixels; + pixels = (uint8_t*)src + 1; + *dst++ = *pixels++; + *dst++ = *pixels++; + *dst++ = *pixels; + src++; + } + dst_pixels += dst_pitch; + if (i & 1) { + src_pixels += src_pitch; + } + } + break; + case 16: + for (int i = 0; i < blit_height; i++) { + uint16_t* src = (uint16_t*)src_pixels; + uint16_t* dst = (uint16_t*)dst_pixels; + for (int j = 0; j < blit_width; j++) { + // 5:5:5:1 RGBA to 6:5:5 RGB + uint16_t pixel = (*src & 0x7FE0) << 1 | (*src & 0x001F); + *dst++ = pixel; + *dst++ = pixel; + src++; + } + dst_pixels += dst_pitch; + if (i & 1) { + src_pixels += src_pitch; + } + } + break; + case 15: + for (int i = 0; i < blit_height; i++) { + uint16_t* src = (uint16_t*)src_pixels; + uint16_t* dst = (uint16_t*)dst_pixels; + for (int j = 0; j < blit_width; j++) { + uint16_t pixel = *src; + *dst++ = pixel; + *dst++ = pixel; + src++; + } + dst_pixels += dst_pitch; + if (i & 1) { + src_pixels += src_pitch; + } + } + break; + } +#else BitmapRef dst = Bitmap::Create( dst_surf->pixels, dst_surf->w, @@ -437,6 +521,7 @@ void SdlUi::Blit2X(Bitmap const& src, SDL_Surface* dst_surf) { PF::NoAlpha)); dst->Blit2x(dst->GetRect(), src, src.GetRect()); +#endif if (SDL_MUSTLOCK(dst_surf)) SDL_UnlockSurface(dst_surf); } diff --git a/src/system.h b/src/system.h index a9aaa129e4..63a6ccc8fd 100644 --- a/src/system.h +++ b/src/system.h @@ -52,7 +52,7 @@ # define SUPPORT_JOYSTICK_AXIS #endif -#ifdef GEKKO +#if defined(GEKKO) || defined(__MORPHOS__) || defined(__amigaos4__) # include "stdint.h" # define WORDS_BIGENDIAN diff --git a/src/utils.cpp b/src/utils.cpp index 445607338a..3979b1ea15 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -264,6 +264,7 @@ std::string Utils::EncodeUTF(const std::u32string& str) { return result; } +#ifndef __amigaos4__ template static std::wstring ToWideStringImpl(const std::string&); #if __SIZEOF_WCHAR_T__ == 4 || __WCHAR_MAX__ > 0x10000 @@ -301,6 +302,7 @@ std::string FromWideStringImpl<2>(const std::wstring& str) { std::string Utils::FromWideString(const std::wstring& str) { return FromWideStringImpl(str); } +#endif int Utils::PositiveModulo(int i, int m) { return (i % m + m) % m; diff --git a/src/utils.h b/src/utils.h index 4e7bc2bf3c..74920a51a6 100644 --- a/src/utils.h +++ b/src/utils.h @@ -92,6 +92,7 @@ namespace Utils { */ std::string EncodeUTF(const std::u32string& str); +#ifndef __amigaos4__ /** * Converts UTF-8 string to std::wstring. * @@ -107,6 +108,7 @@ namespace Utils { * @return the converted string. */ std::string FromWideString(const std::wstring& str); +#endif /** * Converts arithmetic types to a string.