AmigaOS 4 port from xeron.

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@253 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Adrien Destugues 2008-10-14 19:45:39 +00:00
parent 70a750e187
commit ff9fc1633b
8 changed files with 2867 additions and 2812 deletions

17
aide.c
View File

@ -35,8 +35,10 @@
#ifdef __linux__
#include <sys/vfs.h>
#else
#ifndef __amigaos4__
#include <windows.h>
#endif
#endif
// -- Menu d'aide -----------------------------------------------------------
@ -304,8 +306,12 @@ void Bouton_Stats(void)
struct statfs Informations_Disque;
uint64_t Taille = 0;
#else
unsigned __int64 Taille;
ULARGE_INTEGER tailleU;
#ifdef __amigaos4__
uint64_t Taille = 0;
#else
unsigned __int64 Taille;
ULARGE_INTEGER tailleU;
#endif
#endif
@ -347,8 +353,11 @@ void Bouton_Stats(void)
statfs(Principal_Repertoire_courant,&Informations_Disque);
Taille=Informations_Disque.f_bfree * Informations_Disque.f_bsize;
#else
GetDiskFreeSpaceEx(Principal_Repertoire_courant,&tailleU,NULL,NULL);
Taille = tailleU.QuadPart;
#ifdef __amigaos4__
#else
GetDiskFreeSpaceEx(Principal_Repertoire_courant,&tailleU,NULL,NULL);
Taille = tailleU.QuadPart;
#endif
#endif
if(Taille > (100ULL*1024*1024*1024))

View File

@ -39,6 +39,9 @@
#ifdef __linux__
#include <dirent.h>
#define isHidden(Enreg) ((Enreg)->d_name[0]=='.')
#elif defined(__amigaos4__)
#include <dirent.h>
#define isHidden(Enreg) (0)
#elif defined(__WATCOMC__)
#include <direct.h>
#define isHidden(Enreg) ((Enreg)->d_attr & _A_HIDDEN)

View File

@ -29,7 +29,7 @@
//SDL
#include <SDL.h>
#include <SDL_image.h>
#include <SDL/SDL_image.h>
#include <SDL_events.h>
//#include <SDL_gfxPrimitives.h>
@ -587,7 +587,13 @@ void Setup()
/* Checks if we can write the config file */
bool Verifier_ecriture_possible()
{
#ifdef __amigaos4__
// TODO: Make it work :)
return 1;
#else
// Doesn't work on OS4.
return access("./",W_OK) == 0;
#endif
}
/* Save the config file */

24
init.c
View File

@ -47,8 +47,10 @@
#include "errno.h"
#ifndef __linux__
#ifndef __amigaos4__
#include "windows.h"
#endif
#endif
// Chercher le répertoire contenant GFX2.EXE
void Chercher_repertoire_du_programme(char * Chaine)
@ -102,7 +104,7 @@ void Ajouter_lecteur(byte Numero, char Lettre, byte Type)
void Rechercher_drives(void)
{
#ifdef __linux__
#if defined(__linux__) || defined(__amigaos4__)
//Sous linux, il n'y a pas de lecteurs, on va juste mettre
// un disque dur qui pointera vers la racine,
// et un autre vers le home directory de l'utilisateur.
@ -159,14 +161,14 @@ int ActiverLecteur(int NumeroLecteur)
char * Home = getenv("HOME");
if (! Home)
return -1;
#ifdef __linux__
#if defined(__linux__)||defined(__amigaos4__)
return chdir(Home);
#else
return ! SetCurrentDirectory(Home);
#endif
}
#ifdef __linux__
#if defined(__linux__)||defined(__amigaos4__)
char NomLecteur[]=" ";
NomLecteur[0]=Drive[NumeroLecteur].Lettre;
return chdir(NomLecteur);
@ -203,7 +205,6 @@ void Decrypte(byte * Donnee,int Taille)
*(Donnee+Indice)=Decrypt(*(Donnee+Indice));
}
void Charger_DAT(void)
{
FILE* Handle;
@ -216,8 +217,12 @@ void Charger_DAT(void)
struct stat Informations_Fichier;
#ifdef __amigaos4__
strcpy(Nom_du_fichier,"PROGDIR:gfx2.dat");
#else
strcpy(Nom_du_fichier,Repertoire_du_programme);
strcat(Nom_du_fichier,"gfx2.dat");
#endif
if(stat(Nom_du_fichier,&Informations_Fichier))
{
@ -230,7 +235,7 @@ void Charger_DAT(void)
case ENOENT: puts("Un composant du chemin path n'existe pas, ou il s'agit d'une chaîne vide."); break;
case ENOMEM: puts("Pas assez de mémoire pour le noyau."); break;
case ENOTDIR: puts("Un composant du chemin d'accès n'est pas un répertoire."); break;
#ifdef __linux__
#if defined(__linux__)||defined(__amigaos4__)
case ELOOP: puts("Trop de liens symboliques rencontrés dans le chemin d'accès."); break;
#endif
}
@ -1618,8 +1623,12 @@ int Charger_CFG(int Tout_charger)
struct stat Informations_Fichier;
int Conversion_touches = 0;
#ifdef __amigaos4__
strcpy(Nom_du_fichier,"PROGDIR:gfx2.cfg");
#else
strcpy(Nom_du_fichier,Repertoire_du_programme);
strcat(Nom_du_fichier,"gfx2.cfg");
#endif
stat(Nom_du_fichier,&Informations_Fichier);
Taille_fichier=Informations_Fichier.st_size;
@ -1889,9 +1898,12 @@ int Sauver_CFG(void)
struct Config_Infos_touche CFG_Infos_touche;
struct Config_Mode_video CFG_Mode_video;
#ifdef __amigaos4__
strcpy(Nom_du_fichier,"PROGDIR:gfx2.cfg");
#else
strcpy(Nom_du_fichier,Repertoire_du_programme);
strcat(Nom_du_fichier,"gfx2.cfg");
#endif
if ((Handle=fopen(Nom_du_fichier,"wb"))==NULL)
return ERREUR_SAUVEGARDE_CFG;

View File

@ -19,7 +19,7 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Diverses fonctions qui existaient sous dos mais pas sous linux...
#ifdef __linux__
#if defined(__linux__)||defined(__amigaos4__)
#include <string.h>
#include <stdio.h>

7
main.c
View File

@ -34,6 +34,7 @@
#include <string.h>
#include <signal.h>
#include <time.h>
#include <SDL/SDL.h>
#include <unistd.h>
#include "pages.h"
#include "files.h"
@ -46,11 +47,13 @@
#include "io.h"
#ifndef __linux__
#ifndef __amigaos4__
#include <windows.h>
#include <shlwapi.h>
#define chdir(dir) SetCurrentDirectory(dir)
#define M_PI 3.14159265358979323846
#endif
#endif
byte Ancien_nb_lignes; // Ancien nombre de lignes de l'écran
@ -212,7 +215,7 @@ void Analyse_de_la_ligne_de_commande(int argc,char * argv[])
// On récupère le chemin complet du paramètre
// Et on découpe ce chemin en répertoire(path) + fichier(.ext)
#ifdef __linux__
#if defined(__linux__) || defined(__amigaos4__)
Buffer=realpath(argv[Indice],NULL);
#else
Buffer = malloc(TAILLE_CHEMIN_FICHIER);
@ -221,8 +224,10 @@ void Analyse_de_la_ligne_de_commande(int argc,char * argv[])
Extraire_chemin(Principal_Repertoire_fichier, Buffer);
Extraire_nom_fichier(Principal_Nom_fichier, Buffer);
#ifndef __linux__
#ifndef __amigaos4__
free(Buffer);
#endif
#endif
chdir(Principal_Repertoire_fichier);
}
else

View File

@ -402,15 +402,23 @@ int Charger_INI(struct S_Config * Conf)
Nom_du_fichier=(char *)malloc(256);
// On calcule le nom du fichier qu'on manipule:
#ifdef __amigaos4__
strcpy(Nom_du_fichier,"PROGDIR:gfx2.ini");
#else
strcpy(Nom_du_fichier,Repertoire_du_programme);
strcat(Nom_du_fichier,"gfx2.ini");
#endif
Fichier=fopen(Nom_du_fichier,"rb");
if (Fichier==0)
{
// Si le fichier ini est absent on le relit depuis gfx2.dat
#ifdef __amigaos4__
strcpy(Nom_du_fichier,"PROGDIR:gfx2.dat");
#else
strcpy(Nom_du_fichier,Repertoire_du_programme);
strcat(Nom_du_fichier,"gfx2.dat");
#endif
Fichier=fopen(Nom_du_fichier,"rb");
if (Fichier == 0)
{

View File

@ -398,14 +398,22 @@ int Sauver_INI(struct S_Config * Conf)
Buffer=(char *)malloc(1024);
// On calcule les noms des fichiers qu'on manipule:
#ifdef __amigaos4__
strcpy(Nom_du_fichier,"PROGDIR:gfx2.ini");
#else
strcpy(Nom_du_fichier,Repertoire_du_programme);
strcat(Nom_du_fichier,"gfx2.ini");
#endif
// On vérifie si le fichier INI existe
if ((Ini_existe = Fichier_existe(Nom_du_fichier)))
{
#ifdef __amigaos4__
strcpy(Nom_du_fichier_temporaire,"PROGDIR:gfx2.$$$");
#else
strcpy(Nom_du_fichier_temporaire,Repertoire_du_programme);
strcat(Nom_du_fichier_temporaire,"gfx2.$$$");
#endif
// On renome l'ancienne version du fichier INI vers un fichier temporaire:
if (rename(Nom_du_fichier,Nom_du_fichier_temporaire)!=0)
@ -414,8 +422,12 @@ int Sauver_INI(struct S_Config * Conf)
}
}
// On récupère un fichier INI "propre" dans GFX2.DAT
#ifdef __amigaos4__
strcpy(Nom_du_fichier_DAT,"PROGDIR:gfx2.dat");
#else
strcpy(Nom_du_fichier_DAT,Repertoire_du_programme);
strcat(Nom_du_fichier_DAT,"gfx2.dat");
#endif
Ancien_fichier=fopen(Nom_du_fichier_DAT,"rb");
if (Ancien_fichier==0)
{