Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

OSX: Engine now builds on Mac OS X.

  • Loading branch information...
commit 49bf457466ebb82bf544c44f4c47068202a98402 1 parent afa7f6b
@jjsat jjsat authored
View
7 Common/Clib32.cpp
@@ -46,6 +46,7 @@
#ifdef MAC_VERSION
#include "macport.h"
+#include <sys/stat.h>
#endif
#include "bigend.h"
@@ -60,7 +61,7 @@ const int RAND_SEED_SALT = 9338638; // must update editor agsnative.cpp if this
#define MAX_FILES 10000
#define MAXMULTIFILES 25
-#ifdef LINUX_VERSION
+#if defined(LINUX_VERSION) || defined(MAC_VERSION)
static off_t filelength(int fd) {
struct stat st;
fstat(fd, &st);
@@ -496,11 +497,7 @@ extern "C"
}
if ((last_opened_size < 0) && (tfil != NULL))
-#ifdef MAC_VERSION
- last_opened_size = flength(tfil);
-#else
last_opened_size = filelength(fileno(tfil));
-#endif
return tfil;
}
View
12 Common/acsound.h
@@ -17,7 +17,7 @@
#include <pspsdk.h>
#include <pspkernel.h>
#include <pspthreadman.h>
-#elif defined(LINUX_VERSION)
+#elif defined(LINUX_VERSION) || defined(MAC_VERSION)
#include <pthread.h>
#elif defined(WINDOWS_VERSION)
#include <windows.h>
@@ -50,7 +50,7 @@ struct SOUNDCLIP
#if defined(PSP_VERSION)
SceUID mutex;
-#elif defined(LINUX_VERSION)
+#elif defined(LINUX_VERSION) || defined(MAC_VERSION)
pthread_mutex_t mutex;
#elif defined(WINDOWS_VERSION)
HANDLE mutex;
@@ -127,7 +127,7 @@ struct SOUNDCLIP
{
#if defined(PSP_VERSION)
mutex = sceKernelCreateSema("SoundMutex", 0, 1, 1, 0);
-#elif defined(LINUX_VERSION)
+#elif defined(LINUX_VERSION) || defined(MAC_VERSION)
pthread_mutex_init(&mutex, NULL);
#elif defined(WINDOWS_VERSION)
mutex = CreateMutex(NULL, FALSE, NULL);
@@ -138,7 +138,7 @@ struct SOUNDCLIP
{
#if defined(PSP_VERSION)
sceKernelWaitSema(mutex, 1, 0);
-#elif defined(LINUX_VERSION)
+#elif defined(LINUX_VERSION) || defined(MAC_VERSION)
pthread_mutex_lock(&mutex);
#elif defined(WINDOWS_VERSION)
WaitForSingleObject(mutex, INFINITE);
@@ -149,7 +149,7 @@ struct SOUNDCLIP
{
#if defined(PSP_VERSION)
sceKernelSignalSema(mutex, 1);
-#elif defined(LINUX_VERSION)
+#elif defined(LINUX_VERSION) || defined(MAC_VERSION)
pthread_mutex_unlock(&mutex);
#elif defined(WINDOWS_VERSION)
ReleaseMutex(mutex);
@@ -160,7 +160,7 @@ struct SOUNDCLIP
{
#if defined(PSP_VERSION)
sceKernelDeleteSema(mutex);
-#elif defined(LINUX_VERSION)
+#elif defined(LINUX_VERSION) || defined(MAC_VERSION)
pthread_mutex_destroy(&mutex);
#elif defined(WINDOWS_VERSION)
CloseHandle(mutex);
View
9 Common/compress.cpp
@@ -27,7 +27,14 @@
#include "bigend.h"
-typedef unsigned char *__block;
+#if !defined(MAC_VERSION)
+typedef unsigned char * __block;
+#else
+#ifdef __block
+#undef __block
+#define __block unsigned char*
+#endif
+#endif
extern long cliboffset(char *);
extern char lib_file_name[13];
View
9 Common/compress.h
@@ -9,7 +9,14 @@
#include <stdlib.h>
// MACPORT FIX 9/6/05: removed far and put space after *
-typedef unsigned char /* far */ * __block;
+#if !defined(MAC_VERSION)
+typedef unsigned char * __block;
+#else
+#ifdef __block
+#undef __block
+#define __block unsigned char*
+#endif
+#endif
extern long csavecompressed(char *finam, __block tobesaved, color pala[256], long exto);
View
2  Common/wgt2allg.h
@@ -41,7 +41,7 @@
#ifdef WINDOWS_VERSION
#include "winalleg.h"
#elif defined(MAC_VERSION)
-#include <Allegro/osxalleg.h>
+#include <osxalleg.h>
#endif
#include "bigend.h"
View
46 Engine/Makefile.osx
@@ -0,0 +1,46 @@
+
+BASE = acaudio.o acchars.o acdebug.o acdialog.o acfonts.o acgfx.o acgui.o acplatfm.o acsound.o bigend.o misc.o routefnd.o scrptrt.o ac.o alogg.o almp3.o ali3dsw.o
+COMMON = ../Common/csrun.o ../Common/Clib32.o ../Common/mousew32.o ../Common/sprcache.o ../Common/cscommon.o ../Common/compress.o ../Common/lzw.o
+
+MAC_SPECIFIC = acplmac.o ../OSX/libc.o
+
+HQ2X3X = libsrc/hq2x/hq2x3x.o
+
+ALFONT = libsrc/alfont-2.0.9/alfont.o
+
+ALMP3 = libsrc/almp3-2.0.5/decoder/common.o libsrc/almp3-2.0.5/decoder/dct64_i386.o libsrc/almp3-2.0.5/decoder/decode_i386.o libsrc/almp3-2.0.5/decoder/interface.o libsrc/almp3-2.0.5/decoder/layer2.o libsrc/almp3-2.0.5/decoder/layer3.o libsrc/almp3-2.0.5/decoder/tabinit.o
+
+APEG = libsrc/apeg-1.2.1/display.o libsrc/apeg-1.2.1/getbits.o libsrc/apeg-1.2.1/getblk.o libsrc/apeg-1.2.1/gethdr.o libsrc/apeg-1.2.1/getpic.o libsrc/apeg-1.2.1/idct.o libsrc/apeg-1.2.1/motion.o libsrc/apeg-1.2.1/mpeg1dec.o libsrc/apeg-1.2.1/ogg.o libsrc/apeg-1.2.1/recon.o libsrc/apeg-1.2.1/audio/apegcommon.o libsrc/apeg-1.2.1/audio/audio.o libsrc/apeg-1.2.1/audio/dct64.o libsrc/apeg-1.2.1/audio/decode_1to1.o libsrc/apeg-1.2.1/audio/decode_2to1.o libsrc/apeg-1.2.1/audio/decode_4to1.o libsrc/apeg-1.2.1/audio/layer1.o libsrc/apeg-1.2.1/audio/layer2.o libsrc/apeg-1.2.1/audio/layer3.o libsrc/apeg-1.2.1/audio/mpg123.o libsrc/apeg-1.2.1/audio/readers.o libsrc/apeg-1.2.1/audio/tabinit.o libsrc/apeg-1.2.1/audio/vbrhead.o
+
+AASTR = libsrc/aastr-0.1.1/AAROT.o libsrc/aastr-0.1.1/aastr.o libsrc/aastr-0.1.1/aautil.o
+
+OBJS = $(ALFONT) $(ALMP3) $(APEG) $(AASTR) $(HQ2X3X) $(BASE) $(COMMON) $(MAC_SPECIFIC)
+
+INCDIR = ../Engine ../Common ../Common/libinclude /sw/include /sw/lib/freetype2/include /sw/lib/freetype2/include/freetype2
+LIBDIR = /sw/lib /sw/lib/freetype2/lib
+CFLAGS = -m32 -O2 -g -Wfatal-errors -DALLEGRO_STATICLINK -DTHIS_IS_THE_ENGINE -DMAC_VERSION -DDISABLE_MPEG_AUDIO -DRTLD_NEXT
+CXXFLAGS = $(CFLAGS) -fno-rtti -Wno-write-strings
+ASFLAGS = $(CFLAGS)
+LIBS = -m32 -framework Cocoa -lalleg-main -lalleg -laldmb -ldumb -ltheora -logg -lvorbis -lvorbisfile -lfreetype -logg -lz -ldl -lpthread -lm -lc -lstdc++
+
+CC = gcc
+CXX = g++
+CFLAGS := $(addprefix -I,$(INCDIR)) $(CFLAGS)
+CXXFLAGS := $(CFLAGS) $(CXXFLAGS)
+ASFLAGS := $(CFLAGS) $(ASFLAGS)
+LDFLAGS := $(addprefix -L,$(LIBDIR))
+
+all: ags
+
+ags: $(OBJS)
+ $(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) $(LIBS)
+
+%.o: %.m
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+%.o: %.mm
+ $(CXX) $(CXXFLAGS) -c -o $@ $<
+
+.PHONY: clean
+clean:
+ rm -f ags $(OBJS)
View
19 Engine/ac.cpp
@@ -12,7 +12,7 @@
*/
-#if defined(WINDOWS_VERSION) || (defined(LINUX_VERSION) && !defined(PSP_VERSION) && !defined(ANDROID_VERSION))
+#if defined(WINDOWS_VERSION) || defined(MAC_VERSION) || (defined(LINUX_VERSION) && !defined(PSP_VERSION) && !defined(ANDROID_VERSION))
int psp_video_framedrop = 1;
int psp_audio_enabled = 1;
int psp_midi_enabled = 1;
@@ -26,7 +26,7 @@ int psp_gfx_smooth_sprites = 1;
char psp_translation[] = "default";
#endif
-#if defined(LINUX_VERSION) && !defined(PSP_VERSION) && !defined(ANDROID_VERSION)
+#if defined(MAC_VERSION) || (defined(LINUX_VERSION) && !defined(PSP_VERSION) && !defined(ANDROID_VERSION))
#include <dlfcn.h>
#endif
@@ -52,12 +52,15 @@ char psp_translation[] = "default";
#define tanh(a) vfpu_tanhf(a)
#endif
-#if defined(ANDROID_VERSION)
+#if defined(MAC_VERSION) || (defined(LINUX_VERSION) && !defined(PSP_VERSION))
#include <pthread.h>
+pthread_t soundthread;
+#endif
+
+#if defined(ANDROID_VERSION)
#include <sys/stat.h>
#include <android/log.h>
-pthread_t soundthread;
extern "C" void android_render();
extern "C" void selectLatestSavegame();
extern bool psp_load_latest_savegame;
@@ -118,7 +121,7 @@ char dataDirectory[512];
char appDirectory[512];
extern "C"
{
- int osx_sys_question(AL_CONST char *msg, AL_CONST char *but1, AL_CONST char *but2);
+ int osx_sys_question(const char *msg, const char *but1, const char *but2);
}
#endif
@@ -529,7 +532,7 @@ int update_mp3_thread(SceSize args, void *argp)
}
return 0;
}
-#elif defined(ANDROID_VERSION)
+#elif (defined(LINUX_VERSION) && !defined(PSP_VERSION)) || defined(MAC_VERSION)
void* update_mp3_thread(void* arg)
{
while (update_mp3_thread_running)
@@ -3039,7 +3042,7 @@ int Game_SetSaveGameDirectory(const char *newFolder) {
platform->ReplaceSpecialPaths(newFolder, newSaveGameDir);
fix_filename_slashes(newSaveGameDir);
-#ifdef LINUX_VERSION
+#if defined(LINUX_VERSION) || defined(MAC_VERSION)
mkdir(newSaveGameDir, 0);
#else
mkdir(newSaveGameDir);
@@ -29144,7 +29147,7 @@ int initialize_engine(int argc,char*argv[])
update_mp3_thread_running = false;
psp_audio_multithreaded = 0;
}
-#elif defined(ANDROID_VERSION)
+#elif (defined(LINUX_VERSION) && !defined(PSP_VERSION)) || defined(MAC_VERSION)
update_mp3_thread_running = true;
if (pthread_create(&soundthread, NULL, update_mp3_thread, NULL) != 0)
{
View
27 Engine/acplatfm.cpp
@@ -16,6 +16,15 @@
#define strnicmp strncasecmp
#endif
+#if defined(MAC_VERSION)
+extern char dataDirectory[512];
+extern char appDirectory[512];
+extern "C"
+{
+ int osx_sys_question(AL_CONST char *msg, AL_CONST char *but1, AL_CONST char *but2);
+}
+#endif
+
#if defined(PSP_VERSION)
#include <pspsdk.h>
#include <pspkernel.h>
@@ -889,20 +898,10 @@ void pl_read_plugins_from_disk (FILE *iii) {
apl->dllHandle = LoadLibrary(caDylib);
if (apl->dllHandle == NULL)
{
- // warn and maybe continue anyway
- char caError[512];
- sprintf(caError, "Unable to load plugin '%s'\n", buffer);
- if (osx_sys_question(caError, "Continue anyway", "Quit") == 0)
- {
- quit(caError);
- }
- else
- {
- // forget this plugin
- numPlugins--;
- a--;
- continue;
- }
+ // forget this plugin
+ numPlugins--;
+ a--;
+ continue;
}
}
#elif defined(ANDROID_VERSION)
View
12 Engine/acplmac.cpp
@@ -25,11 +25,15 @@ struct AGSMac : AGS32BitOSDriver {
virtual void SetGameWindowIcon();
virtual void ShutdownCDPlayer();
virtual void WriteConsole(const char*, ...);
+ virtual void ReplaceSpecialPaths(const char*, char*);
};
+void AGSMac::ReplaceSpecialPaths(const char *sourcePath, char *destPath) {
+ strcpy(destPath, sourcePath);
+}
int AGSMac::CDPlayerCommand(int cmdd, int datt) {
- return cd_player_control(cmdd, datt);
+ return 0;//cd_player_control(cmdd, datt);
}
void AGSMac::DisplayAlert(const char *text, ...) {
@@ -59,16 +63,18 @@ eScriptSystemOSID AGSMac::GetSystemOSID() {
}
int AGSMac::InitializeCDPlayer() {
- return cd_player_init();
+ //return cd_player_init();
}
void AGSMac::PlayVideo(const char *name, int skip, int flags) {
+/*
if (!PlayMovie(name, skip))
{
char useloc[512];
sprintf(useloc, "%s/%s", get_filename(usetup.data_files_dir), name);
PlayMovie(useloc, skip);
}
+*/
}
void AGSMac::PostAllegroExit() {
@@ -93,7 +99,7 @@ void AGSMac::WriteConsole(const char *text, ...) {
}
void AGSMac::ShutdownCDPlayer() {
- cd_exit();
+ //cd_exit();
}
AGSPlatformDriver* AGSPlatformDriver::GetDriver() {
View
2  Engine/ali3dsw.cpp
@@ -24,7 +24,7 @@
#define Sleep(x) sceKernelDelayThread(1000*x)
#endif
-#if defined(LINUX_VERSION) && !defined(PSP_VERSION)
+#if (defined(LINUX_VERSION) && !defined(PSP_VERSION)) || defined(MAC_VERSION)
#define Sleep(x) usleep(1000*x)
#endif
View
2  Engine/misc.cpp
@@ -30,7 +30,7 @@
#include "allegro.h"
#include "misc.h"
-#if defined(WINDOWS_VERSION) || defined(PSP_VERSION) || defined(ANDROID_VERSION)
+#if defined(MAC_VERSION) || defined(WINDOWS_VERSION) || defined(PSP_VERSION) || defined(ANDROID_VERSION)
#include <string.h>
/* File Name Concatenator basically on Windows / DOS */
char *ci_find_file(char *dir_name, char *file_name)
View
12 OSX/libc.c
@@ -0,0 +1,12 @@
+// Functions missing in the OSX Standard C library.
+
+#include <stdlib.h>
+#include <wchar.h>
+#include <string.h>
+#include <ctype.h>
+
+// Only a dummy. It is used in a function of alfont, but never called in AGS.
+size_t malloc_usable_size(void* allocation)
+{
+ return 0;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.