Skip to content

Commit

Permalink
Updated build procedures.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfjlaros committed Feb 25, 2023
1 parent baf401c commit 61af487
Show file tree
Hide file tree
Showing 14 changed files with 88 additions and 118 deletions.
10 changes: 5 additions & 5 deletions src/args.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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))
Expand Down Expand Up @@ -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]) {
Expand Down Expand Up @@ -159,6 +159,6 @@ int setvars(int argc, char **argv) {
printf("No output filename given.\n");
error(1);
}//if

return 0;
}//setvars
20 changes: 20 additions & 0 deletions src/linux/Makefile
Original file line number Diff line number Diff line change
@@ -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)
23 changes: 0 additions & 23 deletions src/linux/Makefile.linux

This file was deleted.

8 changes: 0 additions & 8 deletions src/linux/build.sh

This file was deleted.

3 changes: 0 additions & 3 deletions src/linux/release/README.md

This file was deleted.

52 changes: 26 additions & 26 deletions src/methods.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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?

Expand All @@ -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)
Expand All @@ -58,28 +58,28 @@ 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
0x22, 0x04, 0x11, // D438: LD (1104h), HL
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.
};
Expand All @@ -90,7 +90,7 @@ void trans(byte *image) {
word cs = 0x0,
fs = getfilesize(image),
i = 0x0;

gap(4000); // Longish gap.
tapemark(40); // Long tapemark.

Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down
20 changes: 10 additions & 10 deletions src/mzf2wav.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdio.h>
Expand Down Expand Up @@ -66,15 +66,15 @@ int main(int argc, char **argv) {
FILE *IN = NULL;
byte *image = NULL;
int i = 0;

setvars(argc, argv);

IN = fopen(filename, "rb");
if (!IN) {
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");
Expand All @@ -93,14 +93,14 @@ int main(int argc, char **argv) {
i++;

setspeed(speed_1);

writewavheader();
method(image);
setheader();

fclose(OUT);
free(image);
fclose(IN);

return 0;
}//main
10 changes: 5 additions & 5 deletions src/physical.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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++)
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/physical.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
23 changes: 0 additions & 23 deletions src/w32/Makefile.windows

This file was deleted.

0 comments on commit 61af487

Please sign in to comment.