From 35f15eb06c1c82a7d68572e028373adcd4a0805a Mon Sep 17 00:00:00 2001 From: Morten Delenk Date: Sat, 24 Jan 2015 09:46:35 +0100 Subject: [PATCH 1/3] Added Linux support. +Makefile was changed, to produce dispel under linux + mac os and dispel.exe under Windows. +Added make install and make uninstall --- Makefile | 18 +++++++++++++++--- main.c | 10 +++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index c644800..99548c6 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,16 @@ CFLAGS=-Wall -O2 LDFLAGS= SOURCES=main.c 65816.c OBJECTS=$(SOURCES:.c=.o) -EXECUTABLE=dispel.exe - +CAN_INSTALL = no +ifeq ($(OS),Windows_NT) + EXECUTABLE = dispel.exe +else + EXECUTABLE = dispel + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S),Linux) + CAN_INSTALL = yes + endif +endif all: $(SOURCES) $(EXECUTABLE) $(EXECUTABLE): $(OBJECTS) @@ -12,6 +20,10 @@ $(EXECUTABLE): $(OBJECTS) .c.o: $(CC) -c $(CFLAGS) $< -o $@ - +install: + cp -v $(EXECUTABLE) /usr/bin + #FIXME It ALWAYS copies dispel to /usr/bin, regardless of OS +uninstall: + rm -rf /usr/bin/$(EXECUTABLE) clean: rm *.o ${EXECUTABLE} diff --git a/main.c b/main.c index 44b1dca..ea5d4e2 100644 --- a/main.c +++ b/main.c @@ -11,8 +11,12 @@ #ifdef __APPLE__ #include #else +#ifdef __linux__ +#include +#else #include #endif +#endif #include "dispel.h" @@ -275,12 +279,12 @@ int main(int argc, char *argv[]) } // Read the file into memory -#ifdef __APPLE__ - fseek(fin, 0L, SEEK_END); +#if defined(__APPLE__) || defined(__linux__) + fseek(fin, 0L, SEEK_END); //Apple and linux code len = ftell(fin); fseek(fin, 0L, SEEK_SET); #else - len = filelength(fileno(fin)); + len = filelength(fileno(fin)); //Windows code #endif // Make sure the image is big enough From 89c01b98f0952be180b47c236b6e6aa3f39c3330 Mon Sep 17 00:00:00 2001 From: Morten Delenk Date: Tue, 23 Jun 2015 15:27:24 +0000 Subject: [PATCH 2/3] Made linux-dependent-code unix-dependent !Checks for _LINUX_ being defined are not checks for _WIN32 being not defined !Makefile does not touch /usr/bin anymore --- Makefile | 4 ++-- main.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 99548c6..c0d5f8a 100644 --- a/Makefile +++ b/Makefile @@ -21,9 +21,9 @@ $(EXECUTABLE): $(OBJECTS) .c.o: $(CC) -c $(CFLAGS) $< -o $@ install: - cp -v $(EXECUTABLE) /usr/bin + cp -v $(EXECUTABLE) /usr/local/bin #FIXME It ALWAYS copies dispel to /usr/bin, regardless of OS uninstall: - rm -rf /usr/bin/$(EXECUTABLE) + rm -rf /usr/local/bin/$(EXECUTABLE) clean: rm *.o ${EXECUTABLE} diff --git a/main.c b/main.c index ea5d4e2..3f9ff50 100644 --- a/main.c +++ b/main.c @@ -11,7 +11,7 @@ #ifdef __APPLE__ #include #else -#ifdef __linux__ +#ifndef _WIN32 #include #else #include @@ -279,7 +279,7 @@ int main(int argc, char *argv[]) } // Read the file into memory -#if defined(__APPLE__) || defined(__linux__) +#if !defined(_WIN32) fseek(fin, 0L, SEEK_END); //Apple and linux code len = ftell(fin); fseek(fin, 0L, SEEK_SET); @@ -328,6 +328,7 @@ int main(int argc, char *argv[]) } } + // Unmangle the address options pos = start; From 31dbba39782306e71d2ac85650e297c0c12f647f Mon Sep 17 00:00:00 2001 From: Morten Delenk Date: Tue, 21 Jul 2015 18:39:12 +0000 Subject: [PATCH 3/3] Changed a small error in the original coding - LoROMs have to be 0x8000 in size, unlike HiROMs. This is fixed now --- main.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index 3f9ff50..8a053fb 100644 --- a/main.c +++ b/main.c @@ -289,11 +289,6 @@ int main(int argc, char *argv[]) // Make sure the image is big enough - if (len < 0x10000 || (skip == 1 && len < 0x10200)) - { - printf("This file looks too small to be a rom image.\n"); - exit(1); - } // Allocate mem for file. Extra 3 bytes to prevent segfault during memcpy if ((data = malloc(len+3)) == NULL) @@ -327,7 +322,11 @@ int main(int argc, char *argv[]) hirom = 0; } } - + if ((!hirom&&(len < 0x8000 || (skip == 1 && len < 0x8200)))||(hirom&&(len < 0x10000 || (skip == 1 && len < 0x10200)))) //Check if ROM is big enough for current mapping + { + printf("This file looks too small to be a rom image.\n"); + exit(1); + } // Unmangle the address options