From b12423d03be805f96627de4cb342666e9b366300 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sat, 19 Sep 2009 22:41:51 +0000 Subject: [PATCH] Trying to compile on amiga with vbcc. Removed some useless unixisms. Still not working. Hope I did not break too much things. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1035 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- Makefile | 45 ++++++++++++++++++++++----------------------- Makefile.dep | 2 -- buttons.c | 6 +++++- errors.h | 4 ++++ graph.c | 10 +++++++--- hotkeys.h | 6 +++++- init.c | 11 +++++++---- loadsave.c | 41 +++++++++++++++++++++++++++++------------ main.c | 2 +- misc.c | 12 +++++++----- mountlist.h | 9 +++++++-- operatio.c | 3 ++- special.h | 4 +++- struct.h | 16 ++++++++++++---- 14 files changed, 111 insertions(+), 60 deletions(-) diff --git a/Makefile b/Makefile index 21af96b7..8617ae2d 100644 --- a/Makefile +++ b/Makefile @@ -175,6 +175,21 @@ else CC = gcc OBJDIR = obj/skyos ZIP = zip + + else ifeq ($(findstring Kickstart,$(shell version)),Kickstart) + # Classic amiga without gcc. Use vbcc. + PLATFORM = amiga-vbcc + DELCOMMAND = delete + MKDIR = makedir + RMDIR= delete + CP = copy + BIN = grafx2 + COPT = -c99 -Ivbcc:PosixLib/include -D__amigaos__ + CC = vc + OBJDIR = obj/amiga-vbcc + ZIP = lha + ZIPOPT= a + else # Finally, the default rules that work fine for most unix/gcc systems, linux and freebsd are tested. @@ -245,12 +260,14 @@ else JOYCOPT = endif +COPT += -DSVN_revision="$(shell svnversion .)" -DProgram_Revision="$(Label)" + ### And now for the real build rules ### -.PHONY : all debug release clean depend zip version force install uninstall +.PHONY : all debug release clean depend zip force install uninstall # This is the list of the objects we want to build. Dependancies are built by "make depend" automatically. -OBJ = $(OBJDIR)/main.o $(OBJDIR)/init.o $(OBJDIR)/graph.o $(OBJDIR)/sdlscreen.o $(OBJDIR)/misc.o $(OBJDIR)/special.o $(OBJDIR)/buttons.o $(OBJDIR)/palette.o $(OBJDIR)/help.o $(OBJDIR)/operatio.o $(OBJDIR)/pages.o $(OBJDIR)/loadsave.o $(OBJDIR)/readline.o $(OBJDIR)/engine.o $(OBJDIR)/filesel.o $(OBJDIR)/op_c.o $(OBJDIR)/readini.o $(OBJDIR)/saveini.o $(OBJDIR)/shade.o $(OBJDIR)/keyboard.o $(OBJDIR)/io.o $(OBJDIR)/version.o $(OBJDIR)/text.o $(OBJDIR)/SFont.o $(OBJDIR)/setup.o $(OBJDIR)/pxsimple.o $(OBJDIR)/pxtall.o $(OBJDIR)/pxwide.o $(OBJDIR)/pxdouble.o $(OBJDIR)/pxtriple.o $(OBJDIR)/pxtall2.o $(OBJDIR)/pxwide2.o $(OBJDIR)/pxquad.o $(OBJDIR)/windows.o $(OBJDIR)/brush.o $(OBJDIR)/realpath.o $(OBJDIR)/mountlist.o $(OBJDIR)/input.o $(OBJDIR)/hotkeys.o $(OBJDIR)/transform.o $(OBJDIR)/pversion.o $(PLATFORMOBJ) +OBJ = $(OBJDIR)/main.o $(OBJDIR)/init.o $(OBJDIR)/graph.o $(OBJDIR)/sdlscreen.o $(OBJDIR)/misc.o $(OBJDIR)/special.o $(OBJDIR)/buttons.o $(OBJDIR)/palette.o $(OBJDIR)/help.o $(OBJDIR)/operatio.o $(OBJDIR)/pages.o $(OBJDIR)/loadsave.o $(OBJDIR)/readline.o $(OBJDIR)/engine.o $(OBJDIR)/filesel.o $(OBJDIR)/op_c.o $(OBJDIR)/readini.o $(OBJDIR)/saveini.o $(OBJDIR)/shade.o $(OBJDIR)/keyboard.o $(OBJDIR)/io.o $(OBJDIR)/text.o $(OBJDIR)/SFont.o $(OBJDIR)/setup.o $(OBJDIR)/pxsimple.o $(OBJDIR)/pxtall.o $(OBJDIR)/pxwide.o $(OBJDIR)/pxdouble.o $(OBJDIR)/pxtriple.o $(OBJDIR)/pxtall2.o $(OBJDIR)/pxwide2.o $(OBJDIR)/pxquad.o $(OBJDIR)/windows.o $(OBJDIR)/brush.o $(OBJDIR)/realpath.o $(OBJDIR)/mountlist.o $(OBJDIR)/input.o $(OBJDIR)/hotkeys.o $(OBJDIR)/transform.o $(OBJDIR)/pversion.o $(PLATFORMOBJ) SKIN_FILES = skins/skin_classic.png skins/skin_modern.png skins/font_Classic.png skins/font_Fun.png @@ -295,27 +312,6 @@ testsed : $(BIN) : $(OBJ) $(CC) $(OBJ) -o $(BIN) $(LOPT) - -# SVN revision number -version.c : - echo "char SVN_revision[]=\"`svnversion .`\";" > version.c -ifeq ($(LABEL),) -else - echo "char Program_version[]=\"$(LABEL)\";" > pversion.c -endif - -version : delversion delpversion version.c pversion.c $(OBJDIR)/version.o $(OBJDIR)/pversion.o all - - -delversion : - $(DELCOMMAND) version.c - -delpversion : -ifeq ($(LABEL),) -else - $(DELCOMMAND) pversion.c -endif - $(OBJDIR)/%.o : %.c $(if $(wildcard $(OBJDIR)),,$(MKDIR) $(OBJDIR)) $(CC) $(COPT) -c $*.c -o $(OBJDIR)/$*.o @@ -335,6 +331,7 @@ clean : $(DELCOMMAND) $(OBJ) $(DELCOMMAND) $(BIN) +ifneq ($(PLATFORM),amiga-vbcc) # Linux installation of the program install : $(BIN) # Create dirs @@ -376,5 +373,7 @@ uninstall : $(DELCOMMAND) $(DESTDIR)$(datadir)/icons/grafx2.xpm @echo Uninstall complete +endif + -include Makefile.dep diff --git a/Makefile.dep b/Makefile.dep index 3ff0f878..f911692d 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -41,7 +41,6 @@ $(OBJDIR)/pages.o: pages.c global.h struct.h const.h pages.h errors.h misc.h \ $(OBJDIR)/palette.o: palette.c const.h struct.h global.h misc.h engine.h readline.h \ buttons.h pages.h help.h sdlscreen.h errors.h op_c.h windows.h input.h \ palette.h shade.h -$(OBJDIR)/pversion.o: pversion.c $(OBJDIR)/pxdouble.o: pxdouble.c global.h struct.h const.h sdlscreen.h misc.h \ pxdouble.h pxwide.h $(OBJDIR)/pxquad.o: pxquad.c global.h struct.h const.h sdlscreen.h misc.h pxquad.h @@ -74,6 +73,5 @@ $(OBJDIR)/text.o: text.c SFont.h struct.h const.h global.h sdlscreen.h io.h \ $(OBJDIR)/transform.o: transform.c global.h struct.h const.h transform.h engine.h \ sdlscreen.h windows.h input.h help.h misc.h readline.h buttons.h \ pages.h -$(OBJDIR)/version.o: version.c $(OBJDIR)/windows.o: windows.c windows.h struct.h const.h global.h graph.h engine.h \ misc.h sdlscreen.h errors.h diff --git a/buttons.c b/buttons.c index 1e64abd0..59ddacbc 100644 --- a/buttons.c +++ b/buttons.c @@ -53,6 +53,10 @@ #include "input.h" #include "special.h" +#ifdef __VBCC__ + #define __attribute__(x) +#endif + #if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) #include #include @@ -5965,4 +5969,4 @@ void Button_Brush_container(void) //Unselect_button(BUTTON_PAINTBRUSHES); Display_cursor(); -} \ No newline at end of file +} diff --git a/errors.h b/errors.h index 238471b7..cade3071 100644 --- a/errors.h +++ b/errors.h @@ -21,6 +21,10 @@ /// Functions and macros for tracing and error reporting. ////////////////////////////////////////////////////////////////////////////// +#ifndef __func__ + #define __func__ "stupid compiler !" +#endif + /// Prints the source filename, line number, function name, a string and an integer. #define DEBUG(y,z) printf("%s %d %s | %s : %d###\n",__FILE__,__LINE__,__func__,y,(unsigned int)z) diff --git a/graph.c b/graph.c index d6947b8c..baedbde5 100644 --- a/graph.c +++ b/graph.c @@ -47,6 +47,11 @@ #include "windows.h" #include "input.h" +#ifdef __VBCC__ + #define __attribute__(x) + #define M_PI 3.141592653589793238462643 +#endif + // Generic pixel-drawing function. Func_pixel Pixel_figure; @@ -109,8 +114,7 @@ void Update_part_of_screen(short x, short y, short width, short height) effective_h = Menu_Y - effective_Y; /* - SDL_Rect r; - r.x=effective_X; + SDL_Rect r; r.x=effective_X; r.y=effective_Y; r.h=effective_h; r.w=effective_w; @@ -2853,4 +2857,4 @@ void Redraw_grid(short x, short y, unsigned short w, unsigned short h) Vertical_grid_line(col, y, h); col+= Snap_width*Main_magnifier_factor; } -} \ No newline at end of file +} diff --git a/hotkeys.h b/hotkeys.h index d8fc377a..b90e4340 100644 --- a/hotkeys.h +++ b/hotkeys.h @@ -24,7 +24,11 @@ /// The actual data is in hotkeys.c ////////////////////////////////////////////////////////////////////////////// -#include +#ifndef __VBCC__ + #include +#else + #define bool char +#endif #include /*** Types definitions and structs ***/ diff --git a/init.c b/init.c index 2cc6761a..65495059 100644 --- a/init.c +++ b/init.c @@ -25,11 +25,14 @@ #if defined(__WIN32__) || defined(__linux__) #define GRAFX2_CATCHES_SIGNALS #endif -#include #include -#include +//#include #include -#include + +#ifndef __VBCC__ + #include +#endif + #include #include #include @@ -2465,4 +2468,4 @@ void Init_brush_container(void) Brush_container[i].Brush = NULL; } -} \ No newline at end of file +} diff --git a/loadsave.c b/loadsave.c index de983439..81083f5f 100644 --- a/loadsave.c +++ b/loadsave.c @@ -868,6 +868,7 @@ void Save_PAL(void) //////////////////////////////////// IMG //////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// +#pragma pack(1) typedef struct { byte Filler1[6]; @@ -875,7 +876,8 @@ typedef struct word Height; byte Filler2[118]; T_Palette Palette; -} __attribute__((__packed__)) T_IMG_Header; +} T_IMG_Header; +#pragma pack() // -- Tester si un fichier est au format IMG -------------------------------- void Test_IMG(void) @@ -1037,6 +1039,7 @@ void Save_IMG(void) //////////////////////////////////// PKM //////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// +#pragma pack(1) typedef struct { char Ident[3]; // Chaîne "PKM" } @@ -1050,7 +1053,8 @@ typedef struct T_Palette Palette; // Palette RVB 256*3 word Jump; // Taille du saut entre le header et l'image: // On va s'en servir pour rajouter un commentaire -} __attribute__((__packed__)) T_PKM_Header; +} T_PKM_Header; +#pragma pack() // -- Tester si un fichier est au format PKM -------------------------------- void Test_PKM(void) @@ -1495,6 +1499,7 @@ void Save_PKM(void) //////////////////////////////////// LBM //////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// +#pragma pack(1) typedef struct { word Width; @@ -1510,7 +1515,8 @@ typedef struct byte Y_aspect; // Inutile word X_screen; word Y_screen; -} __attribute__((__packed__)) T_LBM_Header; +} T_LBM_Header; +#pragma pack() byte * LBM_buffer; FILE *LBM_file; @@ -2279,7 +2285,7 @@ void Save_LBM(void) //////////////////////////////////// BMP //////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// - +#pragma pack(1) typedef struct { word Signature; // ='BM' = 0x4D42 @@ -2299,7 +2305,8 @@ typedef struct dword YPM; dword Nb_Clr; dword Clr_Imprt; -} __attribute__((__packed__)) T_BMP_Header; +} T_BMP_Header; +#pragma pack() // -- Tester si un fichier est au format BMP -------------------------------- void Test_BMP(void) @@ -2849,6 +2856,7 @@ void Save_BMP(void) //////////////////////////////////// GIF //////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// +#pragma pack(1) typedef struct { word Width; // width de l'écran virtuel @@ -2856,7 +2864,7 @@ typedef struct byte Resol; // Informations sur la résolution (et autres) byte Backcol; // color de fond byte Aspect; // Informations sur l'aspect ratio (et autres) -} __attribute__((__packed__)) T_GIF_LSDB; // Logical Screen Descriptor Block +} T_GIF_LSDB; // Logical Screen Descriptor Block typedef struct { @@ -2866,7 +2874,8 @@ typedef struct word Image_height; // height de l'image byte Indicator; // Informations diverses sur l'image byte Nb_bits_pixel; // Nb de bits par pixel -} __attribute__((__packed__)) T_GIF_IDB; // Image Descriptor Block +} T_GIF_IDB; // Image Descriptor Block +#pragma pack() // -- Tester si un fichier est au format GIF -------------------------------- @@ -3685,6 +3694,7 @@ void Save_GIF(void) //////////////////////////////////// PCX //////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// +#pragma pack(1) typedef struct { byte Manufacturer; // |_ Il font chier ces cons! Ils auraient pu @@ -3705,7 +3715,8 @@ typedef struct word Screen_X; // |_ Dimensions de word Screen_Y; // | l'écran d'origine byte Filler[54]; // Ca... J'adore! - } __attribute__((__packed__)) T_PCX_Header; + } T_PCX_Header; +#pragma pack() T_PCX_Header PCX_header; @@ -4224,11 +4235,12 @@ void Save_PCX(void) //////////////////////////////////// CEL //////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// +#pragma pack(1) typedef struct { word Width; // width de l'image word Height; // height de l'image -} __attribute__((__packed__)) T_CEL_Header1; +} T_CEL_Header1; typedef struct { @@ -4241,7 +4253,8 @@ typedef struct word X_offset; // Offset en X de l'image word Y_offset; // Offset en Y de l'image byte Filler2[16]; // ??? -} __attribute__((__packed__)) T_CEL_Header2; +} T_CEL_Header2; +#pragma pack() // -- Tester si un fichier est au format CEL -------------------------------- @@ -4541,6 +4554,7 @@ void Save_CEL(void) //////////////////////////////////// KCF //////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// +#pragma pack(1) typedef struct { struct @@ -4551,7 +4565,8 @@ typedef struct byte Byte2; } color[16]; } Palette[10]; -} __attribute__((__packed__)) T_KCF_Header; +} T_KCF_Header; +#pragma pack() // -- Tester si un fichier est au format KCF -------------------------------- @@ -4800,6 +4815,7 @@ void Save_KCF(void) //////////////////////////////////// SCx //////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// +#pragma pack(1) typedef struct { byte Filler1[4]; @@ -4807,7 +4823,8 @@ typedef struct word Height; byte Filler2; byte Planes; -} __attribute__((__packed__)) T_SCx_Header; +} T_SCx_Header; +#pragma pack() // -- Tester si un fichier est au format SCx -------------------------------- void Test_SCx(void) diff --git a/main.c b/main.c index 7d7ef312..4b6576aa 100644 --- a/main.c +++ b/main.c @@ -25,7 +25,7 @@ #include #include #include -#include +//#include #include #include diff --git a/misc.c b/misc.c index fc6d00f9..39a7316d 100644 --- a/misc.c +++ b/misc.c @@ -717,15 +717,15 @@ void Zoom_a_line(byte* original_line, byte* zoomed_line, #define _WIN32_WINNT 0x0500 #include #elif defined(__macosx__) || defined(__FreeBSD__) -#include + #include #elif defined(__BEOS__) || defined(__HAIKU__) -// sysinfo not implemented + // sysinfo not implemented #elif defined(__AROS__) || defined(__amigaos4__) || defined(__MORPHOS__) || defined(__amigaos__) -#include + #include #elif defined(__SKYOS__) -#include + #include #else -#include // sysinfo() for free RAM + #include // sysinfo() for free RAM #endif // Indique quelle est la mémoire disponible @@ -846,4 +846,6 @@ int Convert_videomode_arg(const char *argument) return mode_index; return -1; + + } diff --git a/mountlist.h b/mountlist.h index 43a15b21..3a5a3906 100644 --- a/mountlist.h +++ b/mountlist.h @@ -26,8 +26,13 @@ #ifndef MOUNTLIST_H_ # define MOUNTLIST_H_ -# include -# include +#ifndef __VBCC__ + # include +#else + #define bool char +#endif + +#include /* A mount table entry. */ struct mount_entry diff --git a/operatio.c b/operatio.c index c30a1f1b..a477c954 100644 --- a/operatio.c +++ b/operatio.c @@ -35,7 +35,8 @@ #include "brush.h" #include "windows.h" -#if defined(__GP2X__) +// PI is NOT part of math.h according to C standards... +#if defined(__GP2X__) || defined(__VBCC__) #define M_PI 3.14159265358979323846 #endif diff --git a/special.h b/special.h index 7930aedc..d6d64b37 100644 --- a/special.h +++ b/special.h @@ -17,6 +17,8 @@ along with Grafx2; if not, see */ +#include "struct.h" + ////////////////////////////////////////////////////////////////////////////// ///@file special.h /// Editor functions that can be hooked to a keyboard shortcut, but don't have @@ -45,4 +47,4 @@ void Zoom_set(int index); void Display_stored_brush_in_window(word x,word y,int number); void Store_brush(int index); -byte Restore_brush(int index); \ No newline at end of file +byte Restore_brush(int index); diff --git a/struct.h b/struct.h index 7ffed0b4..5b03f0f2 100644 --- a/struct.h +++ b/struct.h @@ -70,12 +70,14 @@ typedef void (* Func_draw_brush) (byte *,word,word,word,word,word,word,byte,word typedef void (* Func_draw_list_item) (word,word,word,byte); /// A set of RGB values. +#pragma pack(1) typedef struct { byte R; ///< Red byte G; ///< Green byte B; ///< Blue -}__attribute__ ((__packed__)) T_Components, T_Palette[256]; ///< A complete 256-entry RGB palette (768 bytes). +} T_Components, T_Palette[256]; ///< A complete 256-entry RGB palette (768 bytes). +#pragma pack() /// A normal rectangular button in windows and menus. typedef struct T_Normal_button @@ -225,13 +227,15 @@ typedef struct byte Mode; ///< Shade mode: Normal, Loop, or No-saturation see ::SHADE_MODES } T_Shade; +#pragma pack(1) // is it useful ? /// Data for one fullscreen video mode in configuration file. Warning, this one is saved/loaded as binary. typedef struct { byte State; ///< How good is the mode supported. 0:Good (white) 1:OK (light) 2:So-so (dark) 4:User-disabled (black); +128 => System doesn't support it at all. word Width; ///< Videomode width in pixels. word Height;///< Videomode height in pixels. -} __attribute__((__packed__)) T_Config_video_mode; +} T_Config_video_mode; + /// Header for gfx2.cfg. Warning, this one is saved/loaded as binary. typedef struct @@ -241,7 +245,9 @@ typedef struct byte Version2; ///< Minor version number (ex: 0) byte Beta1; ///< Major beta version number (ex: 96) byte Beta2; ///< Major beta version number (ex: 5) -} __attribute__((__packed__)) T_Config_header; +} T_Config_header; + +#pragma pack() /// Header for a config chunk in for gfx2.cfg. Warning, this one is saved/loaded as binary. typedef struct @@ -250,13 +256,15 @@ typedef struct word Size; ///< Size of the configuration block that follows, in bytes. } T_Config_chunk; +#pragma pack(1) /// Configuration for one keyboard shortcut in gfx2.cfg. Warning, this one is saved/loaded as binary. typedef struct { word Number; ///< Indicates the shortcut action. This is a number starting from 0, which matches ::T_Key_config.Number word Key; ///< Keyboard shortcut: SDLK_something, or -1 for none word Key2; ///< Alternate keyboard shortcut: SDLK_something, or -1 for none -} __attribute__((__packed__)) T_Config_shortcut_info; +} T_Config_shortcut_info; +#pragma pack() /// This structure holds all the settings saved and loaded as gfx2.ini. typedef struct