From 584c4696c124085aca0fad83a30e690cd6838c01 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Tue, 14 Oct 2008 20:42:05 +0000 Subject: [PATCH] Mac os X port. Compiles and runs slowly git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@256 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- .DS_Store | Bin 0 -> 15364 bytes English.lproj/InfoPlist.strings | Bin 0 -> 558 bytes Info.plist | 28 ++++++++++++++ Makefile.os4 | 66 ++++++++++++++++++++++++++++++++ aide.c | 5 +++ gfxcfg.c | 6 +++ graph.c | 22 ++++++++++- init.c | 14 ++++++- main.c | 1 + pages.c | 18 ++++++++- 10 files changed, 157 insertions(+), 3 deletions(-) create mode 100644 .DS_Store create mode 100644 English.lproj/InfoPlist.strings create mode 100644 Info.plist create mode 100644 Makefile.os4 diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..f17b12ef7dee754ad9a9baa815e4bd1212973d9d GIT binary patch literal 15364 zcmeHNyN(=H5Usn9d8{#70`eiliDf{9NMmaaS_veOGbCis(=*UJz3j{^CO{ejK7f!9 zAmjr`iR}*{Bq1YoY);kfUDvJKJrg0JRb8pOc6;hnojUh1eeW(2g$L{Ldqh1V>fmB~ z{043{jX&orYkSp``>+9cqPsLYEy~fbD2JK1KX3(H0aw5ka0Og}|APYf&gRy+6|LW0 z0aw5kxK@DIhaN7r{mO2lm8AnW*#f{G;ITCPjD3J$dX?>0b`z~Y5i{-{LIn-g79&JB zKJT$RY`?ObXd|3Lgj1+8hiZosBs*|Dai`Fa*6*%>E08O2ACFozpgE0cV)pMmmA=IF z&MRpG*1j{f*N1O-)A)92NF}Xlh5Le*dGzqdPK3!Je11@T4v}LG_63c{%TX~b%Yu2T z$J6iT_o@SlW0d$j{JsCde6+ZfWzBeA&X%+C0;T+z#+Z+umQ{?alMr5ax->%K0bPQ? zgf1Ei)O2%1U4eh90^7(D~sYFh7|D!!?=jSck@?=E7NnAYEb)A!Ol76CR1;)qT$ zZl*vn`#5@5>4;$s_kLBJTIl@+E*|%We_%#UzI9x*?*U>m4-=E~?+2Ct%Fo6_?!>Px z^(-*1xo=EV9!XogO>E)tmEv%O*d=;#43&AEsac{~i~U^~lSf!-OpDGCpY_fv5Kg}* zoX)_Bzb=+wG!`vQe8wEStuP(L=MfWUf0l!5*y?ZMGk@b>Vq85&4NGLo;tQW|6F#ZG zjn90ve+%q6{wR+vT$+4MT;cIT@i>yWyjl;SPVKl9ZFXTy9^s@hZLl9;MQB`05AP^e zske;{Z4&RU#4ZqfB|V&}&un%eOb*uR@F&HnE9)Q6gSaN-IhfUUgvlYSG~(zw2d_^H z)RScqUVkZGbr_q6nQ2V-dM-EB!g_5-m>kTj^^xM$rAKr^pVDX7v)UkdRP8{VrRy{6 zl^|}RjxpA!C1wSGJ58EakJc}WSv{(bokq1$&&QZ63yiR=SA>IxS=lSQ&6>tSy0aw5ka0OfeSHKl;1zZ7Fz!h)> PTme_W6>tS^rUL&0=ff(c literal 0 HcmV?d00001 diff --git a/English.lproj/InfoPlist.strings b/English.lproj/InfoPlist.strings new file mode 100644 index 0000000000000000000000000000000000000000..00b513acaee3a01ab54b8339e7be9f336f4b017b GIT binary patch literal 558 zcmbu5OAoM56|$s1ED_Oh;9@)pK6>nlmScfB2@wrxK$p(kz$lQ@de;tIC%t9k|oyR=;wW zP|`x}4i_?QGqh*ERGC{*jVz^-ZU4Hr0Uz^fNoQ>FDOu)|`%vr2R~HvIR3i;+HzXff OPxB_;-OcO#spSSCo?dDI literal 0 HcmV?d00001 diff --git a/Info.plist b/Info.plist new file mode 100644 index 00000000..e2b73ab1 --- /dev/null +++ b/Info.plist @@ -0,0 +1,28 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + + CFBundleIdentifier + http://grafx2.googlecode.com/ + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + NSMainNibFile + SDLMain + NSPrincipalClass + NSApplication + + diff --git a/Makefile.os4 b/Makefile.os4 new file mode 100644 index 00000000..dddb5596 --- /dev/null +++ b/Makefile.os4 @@ -0,0 +1,66 @@ +# Grafx2 - The Ultimate 256-color bitmap paint program +# +# Copyright 2007 Adrien Destugues +# Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) +# +# Grafx2 is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; version 2 +# of the License. +# +# Grafx2 is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Grafx2; if not, see or +# write to the Free Software Foundation, Inc., +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Aaaameeeegaaaaa +DELCOMMAND = rm -rf +BIN = grafx2 +CFGBIN = gfxcfg +COPT = -Wall -c -gstabs -mcrt=newlib `sdl-config --cflags` +LOPT = `sdl-config --libs` +CC = gcc + +.PHONY : all debug release clean depend zip + +OBJ = main.o init.o graph.o sdlscreen.o divers.o special.o boutons.o palette.o aide.o operatio.o pages.o loadsave.o readline.o moteur.o files.o op_c.o linux.o op_asm.o readini.o saveini.o shade.o clavier.o io.o +CFGOBJ = gfxcfg.o SFont.o clavier.o io.o + +OBJDIR = obj/ + +all : $(BIN) $(CFGBIN) + +debug : $(BIN) + +release : $(BIN) $(CFGBIN) + strip $(BIN) + strip $(CFGBIN) + +# A release zip archive +ziprelease: + tar cvzf src-svn`svnversion`.tgz *.c *.h Makefile Makefile.dep + zip grafx2-beta-svn`svnversion`-win32.zip $(BIN) $(CFGBIN) gfx2.dat gfx2.ico doc/gpl-2.0.txt SDL.dll 8pxfont.png SDL_image.dll + +$(BIN) : $(OBJ) + $(CC) $(OBJ) -o $(BIN) $(LOPT) + +$(CFGBIN) : $(CFGOBJ) + $(CC) $(CFGOBJ) -o $(CFGBIN) $(LOPT) -lSDL_image -lz -lpng -ljpeg + +%.o : + $(CC) $(COPT) -c $*.c -o $*.o + +depend : + $(CC) -MM $(OBJ:.o=.c) $(CFGOBJ:.o=.c) > Makefile.dep + +clean : + $(DELCOMMAND) *.o + $(DELCOMMAND) $(BIN) + $(DELCOMMAND) $(CFGBIN) + +include Makefile.dep diff --git a/aide.c b/aide.c index 124271bd..edb0ce51 100644 --- a/aide.c +++ b/aide.c @@ -33,7 +33,12 @@ #include #ifdef __linux__ + #ifdef __macosx__ + #include + #include + #else #include + #endif #else #ifndef __amigaos4__ #include diff --git a/gfxcfg.c b/gfxcfg.c index e7d7a3a2..af34a737 100644 --- a/gfxcfg.c +++ b/gfxcfg.c @@ -661,6 +661,12 @@ int main(int argc, char * argv[]) /* On initialise SFont */ MyFont = SFont_InitFont(IMG_Load("8pxfont.png")); + if(MyFont==NULL) + { + SDL_Quit(); + exit(0); + } + Dessiner_ecran_principal(); if(!Initialiser_config()) diff --git a/graph.c b/graph.c index 3ec1c7a3..52eb74ad 100644 --- a/graph.c +++ b/graph.c @@ -22,7 +22,11 @@ #include "graph.h" #include "divers.h" #include -#include +#ifdef __macosx__ + #include +#else + #include +#endif #include #include @@ -34,7 +38,11 @@ #include "erreurs.h" #ifdef __linux__ + #ifdef __macosx__ + #include + #else #include + #endif #elif __WATCOMC__ #define _WIN32_WINNT 0x0500 #include @@ -485,9 +493,21 @@ unsigned long Memoire_libre(void) _heapmin(); */ #ifdef __linux__ + #ifdef __macosx__ + int mib[2]; + int maxmem; + size_t len; + + mib[0] = CTL_HW; + mib[1] = HW_USERMEM; + len = sizeof(maxmem); + sysctl(mib,2,&maxmem,&len,NULL,0); + return maxmem; + #else struct sysinfo info; sysinfo(&info); return info.freeram*info.mem_unit; + #endif #elif __WATCOMC__ MEMORYSTATUSEX mstt; mstt.dwLength = sizeof(MEMORYSTATUSEX); diff --git a/init.c b/init.c index 16aa6352..9799dca3 100644 --- a/init.c +++ b/init.c @@ -52,10 +52,22 @@ #endif #endif +#ifdef __macosx__ + #import + #import +#endif + // Chercher le répertoire contenant GFX2.EXE void Chercher_repertoire_du_programme(char * Chaine) { - Extraire_chemin(Repertoire_du_programme, Chaine); + #ifdef __macosx__ + CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle()); + CFURLGetFileSystemRepresentation(url,true,(UInt8*)Repertoire_du_programme,MAXPATHLEN); + CFRelease(url); + strcat(Repertoire_du_programme,"Contents/Resources"); + #else + Extraire_chemin(Repertoire_du_programme, Chaine); + #endif } diff --git a/main.c b/main.c index 5b4950c2..49c4b2b1 100644 --- a/main.c +++ b/main.c @@ -55,6 +55,7 @@ #endif #endif + byte Ancien_nb_lignes; // Ancien nombre de lignes de l'écran diff --git a/pages.c b/pages.c index da2973d2..c2df380b 100644 --- a/pages.c +++ b/pages.c @@ -827,13 +827,25 @@ void Backup(void) // Sauve la page courante comme première page de backup et crée une nouvelle page // pur continuer à dessiner. Utilisé par exemple pour le fill { - S_Page * Nouvelle_page; + #ifdef __macosx__ + S_Page Nouvelle_page; + #else + S_Page * Nouvelle_page; + #endif // On remet à jour l'état des infos de la page courante (pour pouvoir les // retrouver plus tard) Upload_infos_page_principal(Principal_Backups->Pages); // On crée un descripteur pour la nouvelle page courante +#ifdef __macosx__ + Initialiser_S_Page(&Nouvelle_page); + + // Enrichissement de l'historique + Copier_S_page(&Nouvelle_page,Principal_Backups->Pages); + Creer_nouvelle_page(&Nouvelle_page,Principal_Backups,Brouillon_Backups); + Download_infos_page_principal(&Nouvelle_page); +#else Nouvelle_page=(S_Page *)malloc(sizeof(S_Page)); Initialiser_S_Page(Nouvelle_page); @@ -841,13 +853,17 @@ void Backup(void) Copier_S_page(Nouvelle_page,Principal_Backups->Pages); Creer_nouvelle_page(Nouvelle_page,Principal_Backups,Brouillon_Backups); Download_infos_page_principal(Nouvelle_page); +#endif + Download_infos_backup(Principal_Backups); // On copie l'image du backup vers la page courante: memcpy(Principal_Ecran,Ecran_backup,Principal_Largeur_image*Principal_Hauteur_image); // On détruit le descripteur de la page courante +#ifndef __macosx__ free(Nouvelle_page); +#endif // On allume l'indicateur de modification de l'image Principal_Image_modifiee=1;