From 61af487edb0c97fc0faf489519d85c0edf0e91b2 Mon Sep 17 00:00:00 2001 From: "Jeroen F.J. Laros" Date: Sat, 25 Feb 2023 16:00:48 +0100 Subject: [PATCH] Updated build procedures. --- src/args.c | 10 +++---- src/linux/Makefile | 20 ++++++++++++++ src/linux/Makefile.linux | 23 ---------------- src/linux/build.sh | 8 ------ src/linux/release/README.md | 3 --- src/methods.c | 52 ++++++++++++++++++------------------- src/mzf2wav.c | 20 +++++++------- src/physical.c | 10 +++---- src/physical.h | 2 +- src/w32/Makefile.windows | 23 ---------------- src/w32/build.bat | 10 ------- src/w32/release/README.md | 3 --- src/wav.c | 2 +- src/windows/Makefile | 20 ++++++++++++++ 14 files changed, 88 insertions(+), 118 deletions(-) create mode 100644 src/linux/Makefile delete mode 100644 src/linux/Makefile.linux delete mode 100644 src/linux/build.sh delete mode 100644 src/linux/release/README.md delete mode 100644 src/w32/Makefile.windows delete mode 100644 src/w32/build.bat delete mode 100644 src/w32/release/README.md create mode 100644 src/windows/Makefile diff --git a/src/args.c b/src/args.c index 94af3e9..7fd7858 100644 --- a/src/args.c +++ b/src/args.c @@ -21,7 +21,7 @@ int chtoi(char *), // Convert the first char of a string to an integer. // Convert the first char of a string to an integer and check the boundries. int chtoi(char *string) { int temp = 0; - + if (!string) return -1; temp = (int)string[0] - 48; @@ -36,14 +36,14 @@ int stoi(char *string) { m = 1, temp = 0, ret = 0; - + if (!string) return -100; if (string[0] == '-') { m = -1; i++; }//if - + while (string[i]) { temp = (int)string[i] - 48; if ((temp < 0) || (temp > 9)) @@ -78,7 +78,7 @@ int setvars(int argc, char **argv) { char *endptr; int temp = 0, i = 1; - + while (i < argc) { if (argv[i][0] == '-') switch (argv[i][1]) { @@ -159,6 +159,6 @@ int setvars(int argc, char **argv) { printf("No output filename given.\n"); error(1); }//if - + return 0; }//setvars diff --git a/src/linux/Makefile b/src/linux/Makefile new file mode 100644 index 0000000..46c66f2 --- /dev/null +++ b/src/linux/Makefile @@ -0,0 +1,20 @@ +CC = gcc +CFLAGS = -Wall -O2 -static + +EXEC = mzf2wav +MAIN = ../mzf2wav.c +OBJS = ../physical.o ../methods.o ../args.o ../wav.o + +all: $(EXEC) + +.cc.o: + $(CC) $(CFLAGS) -c $< + +$(EXEC): $(MAIN) $(OBJS) + $(CC) $(CFLAGS) -o $@ $^ + +clean: + rm -f $(OBJS) core + +distclean: clean + rm -f $(EXEC) diff --git a/src/linux/Makefile.linux b/src/linux/Makefile.linux deleted file mode 100644 index e744eb1..0000000 --- a/src/linux/Makefile.linux +++ /dev/null @@ -1,23 +0,0 @@ -CC = gcc -CFLAGS = -Wall -O3 - -EXEC = mzf2wav -MAIN = mzf2wav.c -OBJS = physical.o methods.o args.o wav.o - -all: $(EXEC) - -release: all - cp $(EXEC) linux/release - -.cc.o: - $(CC) $(CFLAGS) -c $< - -$(EXEC): $(MAIN) $(OBJS) - $(CC) $(CFLAGS) -o $@ $^ - -clean: - rm -f *.o core - -realclean: clean - rm -f $(EXEC) diff --git a/src/linux/build.sh b/src/linux/build.sh deleted file mode 100644 index ff3bcf0..0000000 --- a/src/linux/build.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -cp Makefile.linux ../Makefile -cd .. -make release -make realclean -rm Makefile -echo If all is well, the executable is in: linux/release diff --git a/src/linux/release/README.md b/src/linux/release/README.md deleted file mode 100644 index 262f5a7..0000000 --- a/src/linux/release/README.md +++ /dev/null @@ -1,3 +0,0 @@ -Please read the -[documentation](https://github.com/jfjlaros/mzf2wav/blob/master/README.md) before -using this software. diff --git a/src/methods.c b/src/methods.c index 74ffdec..cdea32a 100644 --- a/src/methods.c +++ b/src/methods.c @@ -5,18 +5,18 @@ int speed_2 = 2; // Defenitions. // This is the turbo loader in MZF format. -byte program[300] = { +byte program[300] = { 0x01, // Program type. - + 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, // Room for the 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, // image name. 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, - + 0x5a, 0x00, // File size. 0x00, 0xd4, // Load adress. 0x00, 0xd4, // Execution adress. '[', 't', 'u', 'r', 'b', 'o', ']', // The first 7 bytes. - + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Room for comment. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // minus 7 bytes. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -28,15 +28,15 @@ byte program[300] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - + 0xcd, 0x00, // End Header. - + // Begin Program. 0x3e, 0x08, // D400: LD A, 08h 0xd3, 0xce, // D402: OUT (0ceh), A ; Set video mode? - + 0xe5, // D404: PUSH HL - + 0x21, 0x00, 0x00, // D405: LD HL, 0000h 0xd3, 0xe4, // D408: OUT (0e4h), A ; Bank switch to ROM? @@ -45,11 +45,11 @@ byte program[300] = { 0x77, // D40D: LD (HL), A 0x23, // D40E: INC HL - + 0x7c, // D40F: LD A, H 0xfe, 0x10, // D410: CP 10h 0x20, 0xf4, // D412: JR NZ, f4h ; Jump 0xf4 forward if A != 0x10 - + 0x3a, 0x4b, 0xd4, // D414: LD A, (d44bh) 0x32, 0x4b, 0x0a, // D417: LD (0a4bh), A ; (0x0a4b) = (0xd44b) 0x3a, 0x4c, 0xd4, // D41A: LD A, (d44ch) @@ -58,13 +58,13 @@ byte program[300] = { 0x11, 0x02, 0x11, // D423: LD DE, 1102h 0x01, 0x0d, 0x00, // D426: LD BC, 000dh 0xed, 0xb0, // D429: LDIR ; Copy 0x0d bytes from (HL) to (DE) - + 0xe1, // D42B: POP HL - + 0x7c, // D42C: LD A, H 0xfe, 0xd4, // D42D: CP d4h 0x28, 0x12, // D42F: JR Z, 12h ; Jump to label #1 if A == 0xd4 - + 0x2a, 0x04, 0x11, // D431: LD HL, (1104h) 0xd9, // D434: EXX ; BC/DE/HL <-> BC'/DE'/HL' 0x21, 0x00, 0x12, // D435: LD HL, 1200h @@ -72,14 +72,14 @@ byte program[300] = { 0xcd, 0x2a, 0x00, // D43B: CALL 002ah ; Read data subroutine. 0xd3, 0xe4, // D43E: OUT (0e4h), A ; Bank switch to ROM? 0xc3, 0x9a, 0xe9, // D440: JP e99ah ; Jump to 0xe99a - + 0xcd, 0x2a, 0x00, // D443: CALL (002ah) ; Label #1 (read data sub). 0xd3, 0xe4, // D446: OUT (0e4h), A ; Bank switch to ROM? 0xc3, 0x24, 0x01, // D448: JP (0124h) // End program. - 0x15, 0x01, // D44B: - + 0x15, 0x01, // D44B: + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Room for the address information 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // + the first 7 bytes of comment. }; @@ -90,7 +90,7 @@ void trans(byte *image) { word cs = 0x0, fs = getfilesize(image), i = 0x0; - + gap(4000); // Longish gap. tapemark(40); // Long tapemark. @@ -100,7 +100,7 @@ void trans(byte *image) { gap(5000); // Shortish gap. tapemark(20); // Short tapemark. - + cs = 0x0; fs += 0x80; for (i = 0x80; i < fs; i++) // The mzf body. @@ -113,31 +113,31 @@ void conv(byte *image) { word cs = 0x0, fs = getfilesize(image), i = 0x0; - + gap(22000); // Long gap. tapemark(40); // Long tapemark. for (i = 0x0; i < 0x80; i++) // The mzf header. cs += writebyte(image[i]); writecs(cs); // The checksum of the mzf header. - + gap(256); // 256 short pulses. - + for (i = 0x0; i < 0x80; i++) // The copy of the mzf header. writebyte(image[i]); writecs(cs); // The copy of the checksum of the mzf header. - + gap(11000); // Short gap. tapemark(20); // Short tapemark. - + cs = 0x0; fs += 0x80; for (i = 0x80; i < fs; i++) // The mzf body. cs += writebyte(image[i]); writecs(cs); // The checksum of the body. - + gap(256); // 256 short pulses. - + for (i = 0x80; i < fs; i++) // The copy of the mzf body. writebyte(image[i]); writecs(cs); // The copy of checksum of the body. @@ -146,7 +146,7 @@ void conv(byte *image) { // First write a turbo loader, then write the image at high speed. void turbo(byte *image) { int j = 0; - + for (j = 0x1; j < 0x12; j++) // Copy the name. program[j] = image[j]; for (j = 0x1f; j < 0x80; j++) // Copy the comment. diff --git a/src/mzf2wav.c b/src/mzf2wav.c index 1863ee3..1f5dc05 100644 --- a/src/mzf2wav.c +++ b/src/mzf2wav.c @@ -2,13 +2,13 @@ * mzf2wav by: Jeroen F. J. Laros. * * Last change on: Sep 11 2003. - * - * This program is freeware and may be used without paying any registration - * fees. It may be distributed freely provided it is done so using the - * original, unmodified version. Usage of parts of the source code is granted, - * provided the author is referenced. For private use only. Re-selling or any + * + * This program is freeware and may be used without paying any registration + * fees. It may be distributed freely provided it is done so using the + * original, unmodified version. Usage of parts of the source code is granted, + * provided the author is referenced. For private use only. Re-selling or any * commercial use of this program or parts of it is strictly forbidden. The - * author is not responsible for any damage or data loss as a result of using + * author is not responsible for any damage or data loss as a result of using * this program. */ #include @@ -66,7 +66,7 @@ int main(int argc, char **argv) { FILE *IN = NULL; byte *image = NULL; int i = 0; - + setvars(argc, argv); IN = fopen(filename, "rb"); @@ -74,7 +74,7 @@ int main(int argc, char **argv) { printf("Unable to open file: %s for reading.\n\n", argv[1]); error(2); }//if - + image = readfile(IN); if (!image) { printf("Out of memory or assertion error.\n\n"); @@ -93,7 +93,7 @@ int main(int argc, char **argv) { i++; setspeed(speed_1); - + writewavheader(); method(image); setheader(); @@ -101,6 +101,6 @@ int main(int argc, char **argv) { fclose(OUT); free(image); fclose(IN); - + return 0; }//main diff --git a/src/physical.c b/src/physical.c index 2dc98f1..5031508 100644 --- a/src/physical.c +++ b/src/physical.c @@ -18,7 +18,7 @@ int LONG_UP = 0, // These variables define the long wave. // Private function prototypes. void lp(void), // Long pulse. sp(void); // Short pulse. - + // Private functions. // Write a long pulse. void lp(void) { @@ -52,7 +52,7 @@ void reversepol(void) { // Write a gap of i short pulses. void gap(int i) { int j = 0; - + for (j = 0; j < i; j++) sp(); }//gap @@ -73,7 +73,7 @@ void tapemark(int i) { void writecs(word cs) { byte i = 0x0; int j = 0; - + cs &= 0xffff; for (j = 0x3; j; j >>= 1) { // for (j = 0; j < 2; j++) for (i = 0xff; i; i >>= 1) { // for (i = 0; i < 8; i++) @@ -82,7 +82,7 @@ void writecs(word cs) { else sp(); // Else write a zero. cs <<= 1; // Go to the next bit. - }//for + }//for lp(); }//for lp(); @@ -131,7 +131,7 @@ void setspeed(int i) { word writebyte(byte b) { word cs = 0x0; byte i = 0x0; - + for (i = 0xff; i; i >>= 1) { if (b & 0x80) { lp(); diff --git a/src/physical.h b/src/physical.h index c9b6ac9..550797e 100644 --- a/src/physical.h +++ b/src/physical.h @@ -11,6 +11,6 @@ void reversepol(void), // Reverse polarity. tapemark(int), // i long, i short and two long pulses. writecs(word), // Write the checksum. setspeed(int); // Define the waveform. -word writebyte(byte), // Write a byte and count the ones. +word writebyte(byte), // Write a byte and count the ones. getfilesize(byte *); // Get the file size. int assert(byte *, word); // See if the MZF file is valid. diff --git a/src/w32/Makefile.windows b/src/w32/Makefile.windows deleted file mode 100644 index c0c29c8..0000000 --- a/src/w32/Makefile.windows +++ /dev/null @@ -1,23 +0,0 @@ -CC = cl -CFLAGS = /GX /O2 - -EXEC = mzf2wav.exe -MAIN = mzf2wav.c -OBJS = physical.obj methods.obj args.obj wav.obj - -all: $(EXEC) - -release: all - copy $(EXEC) w32\release - -.cc.o: - $(CC) $(CFLAGS) /c $< - -$(EXEC): $(MAIN) $(OBJS) - $(CC) $(CFLAGS) /o $@ $(MAIN) $(OBJS) - -clean: - del *.obj - -realclean: clean - del $(EXEC) diff --git a/src/w32/build.bat b/src/w32/build.bat deleted file mode 100644 index 7fb4f37..0000000 --- a/src/w32/build.bat +++ /dev/null @@ -1,10 +0,0 @@ -@echo off - -copy Makefile.Windows ..\Makefile -cd .. -nmake release -nmake realclean -del Makefile -cd w32 -echo If all is well, the executable and belongings are in: -echo w32\release diff --git a/src/w32/release/README.md b/src/w32/release/README.md deleted file mode 100644 index 262f5a7..0000000 --- a/src/w32/release/README.md +++ /dev/null @@ -1,3 +0,0 @@ -Please read the -[documentation](https://github.com/jfjlaros/mzf2wav/blob/master/README.md) before -using this software. diff --git a/src/wav.c b/src/wav.c index f97345f..37719e1 100644 --- a/src/wav.c +++ b/src/wav.c @@ -49,7 +49,7 @@ void writewavheader(void) { fprintf(OUT, "%c", header[i]); }//writewavheader -// Set the filesizes in the WAV header. +// Set the filesizes in the WAV header. void setheader(void) { dword temp = fs; int i = 0; diff --git a/src/windows/Makefile b/src/windows/Makefile new file mode 100644 index 0000000..ebee652 --- /dev/null +++ b/src/windows/Makefile @@ -0,0 +1,20 @@ +CC = x86_64-w64-mingw32-c++ +CFLAGS = -Wall -O2 -static + +EXEC = mzf2wav.exe +MAIN = ../mzf2wav.c +OBJS = ../physical.obj ../methods.obj ../args.obj ../wav.obj + +all: $(EXEC) + +%.obj: %.c %.h + $(CC) $(CFLAGS) -o $@ -c $< + +$(EXEC): $(MAIN) $(OBJS) + $(CC) $(CFLAGS) -o $@ $(MAIN) $(OBJS) + +clean: + rm -f $(OBJS) + +distclean: clean + rm -f $(EXEC)