File blueMSX.dif of Package blueMSX

--- Make/blueMSXlite/linux-sdl/Makefile
+++ Make/blueMSXlite/linux-sdl/Makefile
@@ -8,7 +8,7 @@
 #
 # Comment out if verbose comilation is wanted
 #
-SILENT = @
+#SILENT = @
 
 #
 # Directories
@@ -34,8 +34,8 @@
 #
 #CFLAGS   = -w -O3 -DNO_ASM -DNO_HIRES_TIMERS -DNO_FILE_HISTORY -DNO_EMBEDDED_SAMPLES -DUSE_SDL
 #CPPFLAGS = -O3 -DNO_ASM
-CFLAGS   = -g -w -O2 -DLSB_FIRST -DNO_ASM -DNO_HIRES_TIMERS -DNO_FILE_HISTORY -DNO_EMBEDDED_SAMPLES -DUSE_SDL
-CPPFLAGS = -g -DNO_ASM
+CFLAGS   = -g $(RPM_OPT_FLAGS) -DNO_ASM -DNO_HIRES_TIMERS -DNO_FILE_HISTORY -DNO_EMBEDDED_SAMPLES -DUSE_SDL
+CPPFLAGS = -g -DNO_ASM $(RPM_OPT_FLAGS)
 LDFLAGS  = 
 LIBS     =  -lSDL -lz -lGL
 TARGET   = blueMSXlite
--- Src/Board/Machine.c
+++ Src/Board/Machine.c
@@ -32,6 +32,7 @@
 #include <string.h>
 #include <ctype.h>
 #include <stdlib.h>
+#include <sys/param.h>
 #include "ArchFile.h"
 #include "MediaDb.h"
 #include "TokenExtract.h"
@@ -323,10 +324,10 @@
     int size = 0;
     int i;
 
-    sprintf(dir, "Machines/%s", machine->name);
+    sprintf(dir, "/usr/share/bluemsx/Machines/%s", machine->name);
     archCreateDirectory(dir);
 
-    sprintf(file, "Machines/%s/config.ini", machine->name);
+    sprintf(file, "/usr/share/bluemsx/Machines/%s/config.ini", machine->name);
 
     iniFileOpen(file);
 
@@ -415,7 +416,7 @@
 
     machine = malloc(sizeof(Machine));
 
-    sprintf(fileName, "Machines/%s/config.ini", machineName);
+    sprintf(fileName, "/usr/share/bluemsx/Machines/%s/config.ini", machineName);
     success = readMachine(machine, machineName, fileName);
     if (!success) {
         free(machine);
@@ -438,6 +439,7 @@
     Machine* machine = machineCreate(machineName);
     int i;
     int success = 1;
+    char path[PATH_MAX];
 
     if (machine == NULL) {
         return 0;
@@ -451,7 +453,8 @@
         if (strlen(machine->slotInfo[i].name) || 
             strlen(machine->slotInfo[i].inZipName))
         {        
-            FILE* file = fopen(machine->slotInfo[i].name, "r");
+            sprintf(path, "/usr/share/bluemsx/%s", machine->slotInfo[i].name);
+            FILE* file = fopen(path, "r");
             if (file == NULL) {
                 if (success) {
 //                    printf("\n%s: Cant find rom:\n", machineName);
@@ -499,7 +502,7 @@
     else {
         static char* machineNames[256];
         static char  names[256][64];
-        ArchGlob* glob = archGlob("Machines/*", ARCH_GLOB_DIRS);
+        ArchGlob* glob = archGlob("/usr/share/bluemsx/Machines/*", ARCH_GLOB_DIRS);
         int index = 0;
         int i;
 
--- Src/IoDevice/DirAsDisk.c
+++ Src/IoDevice/DirAsDisk.c
@@ -32,6 +32,8 @@
 #pragma warning(disable: 4996)
 #if defined(WIN32) || defined (WINDOWS_HOST)
 #include <io.h> // not on Linux
+#else
+#include <unistd.h>
 #endif
 
 #include <fcntl.h>
--- Src/Memory/MegaromCartridge.c
+++ Src/Memory/MegaromCartridge.c
@@ -278,7 +278,7 @@
 
     case ROM_FMPAC:
         if (cart[strlen(cart) - 4] != '.') {
-            buf = romLoad("Machines/Shared Roms/FMPAC.rom", "", &size);
+            buf = romLoad("/usr/share/bluemsx/Machines/Shared Roms/FMPAC.rom", "", &size);
             if (buf != NULL) {
                 success &= romMapperFMPACCreate("FmPacA.rom", buf, size, slot, sslot, 2);
                 free(buf);
@@ -298,7 +298,7 @@
     default:
         // Load roms for Special Carts
         if (strcmp(cart, "Sunrise IDE") == 0) {
-            buf = romLoad("Machines/Shared Roms/sunriseide.rom", cartZip, &size);
+            buf = romLoad("/usr/share/bluemsx/Machines/Shared Roms/sunriseide.rom", cartZip, &size);
             if (buf == 0) {
                 success &= romMapperSunriseIdeCreate(cartNo, romName, NULL, 0, slot, sslot, 0);
                 break;
@@ -306,7 +306,7 @@
         }
         // Load roms for Special Carts
         else if (strcmp(cart, "Beer IDE") == 0) {
-            buf = romLoad("Machines/Shared Roms/beeride.rom", cartZip, &size);
+            buf = romLoad("/usr/share/bluemsx/Machines/Shared Roms/beeride.rom", cartZip, &size);
             if (buf == 0) {
                 success &= romMapperBeerIdeCreate(cartNo, romName, NULL, 0, slot, sslot, 0);
                 break;
@@ -314,7 +314,7 @@
         }
         // Load roms for Special Carts
         else if (strcmp(cart, "Gouda SCSI") == 0) {
-            buf = romLoad("Machines/Shared Roms/novaxis.rom", cartZip, &size);
+            buf = romLoad("/usr/share/bluemsx/Machines/Shared Roms/novaxis.rom", cartZip, &size);
             if (buf == 0) {
                 success &= romMapperGoudaSCSICreate(cartNo, romName, NULL, 0, slot, sslot, 2);
                 break;
--- Src/Memory/RomLoader.c
+++ Src/Memory/RomLoader.c
@@ -30,6 +30,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+#include <sys/param.h>
 
 // PacketFileSystem.h Need to be included after all other includes
 #include "PacketFileSystem.h"
@@ -39,6 +40,7 @@
 {
     UInt8* buf = NULL;
     FILE *file;
+    char path[PATH_MAX];
 
     if (fileName == NULL || strlen(fileName) == 0) {
         return NULL;
@@ -53,7 +55,13 @@
         return buf;
     }
 
-    file = fopen(fileName, "rb");
+    if(strncmp("Machines",fileName,8) == 0) {
+      sprintf(path, "/usr/share/bluemsx/%s", fileName);
+    }
+    else {
+      strcpy(path, fileName);
+    }
+    file = fopen(path, "rb");
     if (file == NULL) {
         return NULL;
     }
--- Src/Sdl/bluemsxlite.c
+++ Src/Sdl/bluemsxlite.c
@@ -350,7 +350,6 @@
 int  archUpdateEmuDisplay(int syncMode) 
 {
     SDL_Event event;
-
     if (pendingDisplayEvents > 1) {
         return 1;
     }
@@ -421,41 +420,41 @@
 {
 }
 
-void setDefaultPaths(const char* rootDir)
+void setDefaultPaths(const char* shareDir, const char* homeDir)
 {   
     char buffer[512];  
 
-    propertiesSetDirectory(rootDir, rootDir);
+    propertiesSetDirectory(shareDir, homeDir);//, shareDir);
 
-    sprintf(buffer, "%s/Audio Capture", rootDir);
+    sprintf(buffer, "%s/Audio Capture", homeDir);
     archCreateDirectory(buffer);
     actionSetAudioCaptureSetDirectory(buffer, "");
 
-    sprintf(buffer, "%s/Video Capture", rootDir);
+    sprintf(buffer, "%s/Video Capture", homeDir);
     archCreateDirectory(buffer);
     actionSetAudioCaptureSetDirectory(buffer, "");
 
-    sprintf(buffer, "%s/QuickSave", rootDir);
+    sprintf(buffer, "%s/QuickSave", homeDir);
     archCreateDirectory(buffer);
     actionSetQuickSaveSetDirectory(buffer, "");
 
-    sprintf(buffer, "%s/SRAM", rootDir);
+    sprintf(buffer, "%s/SRAM", homeDir);
     archCreateDirectory(buffer);
     boardSetDirectory(buffer);
 
-    sprintf(buffer, "%s/Casinfo", rootDir);
+    sprintf(buffer, "%s/Casinfo", homeDir);
     archCreateDirectory(buffer);
     tapeSetDirectory(buffer, "");
 
-    sprintf(buffer, "%s/Databases", rootDir);
+    sprintf(buffer, "%s/Databases", shareDir);
     archCreateDirectory(buffer);
     mediaDbLoad(buffer);
     
-    sprintf(buffer, "%s/Keyboard Config", rootDir);
+    sprintf(buffer, "%s/Keyboard Config", shareDir);
     archCreateDirectory(buffer);
     keyboardSetDirectory(buffer);
 
-    sprintf(buffer, "%s/Shortcut Profiles", rootDir);
+    sprintf(buffer, "%s/Shortcut Profiles", shareDir);
     archCreateDirectory(buffer);
     shortcutsSetDirectory(buffer);
 }
@@ -525,11 +524,12 @@
         }
         strcat(szLine, " ");
     }
-
-    setDefaultPaths(archGetCurrentDirectory());
+    sprintf(path, "%s/.bluemsx", getenv("HOME"));
+    mkdir(path, 0755);
+    setDefaultPaths("/usr/share/bluemsx", path);
 
     resetProperties = emuCheckResetArgument(szLine);
-    strcat(path, archGetCurrentDirectory());
+    strcpy(path, archGetCurrentDirectory());
     strcat(path, DIR_SEPARATOR "bluemsx.ini");
     properties = propCreate(resetProperties, 0, P_KBD_EUROPEAN, 0, "");
     
openSUSE Build Service is sponsored by