From 958ada407564e35e4eef81a05eed3c68e0e758c7 Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 20:31:57 +0200 Subject: [PATCH 01/21] Refactor / minimize deps: move version to a separated file. --- nibtools.h | 6 +----- nibtools_version.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 nibtools_version.h diff --git a/nibtools.h b/nibtools.h index a859549..c69c72f 100644 --- a/nibtools.h +++ b/nibtools.h @@ -4,12 +4,8 @@ * based on MNIB by Markus Brenner */ -#define VERSION "Built "__DATE__" "__TIME__ -#define AUTHOR "(C) Peter Rittwage and the rest of the C64 Preservation Project team\nhttp://c64preservation.com\n" -#ifndef SVN -#define SVN 2014 -#endif +#include "nibtools_version.h" #define FL_STEPTO 0x00 #define FL_MOTOR 0x01 diff --git a/nibtools_version.h b/nibtools_version.h new file mode 100644 index 0000000..459f29e --- /dev/null +++ b/nibtools_version.h @@ -0,0 +1,12 @@ + +#ifndef NIBTOOLS_VERSION_H +#define NIBTOOLS_VERSION_H + +#define VERSION "Built "__DATE__" "__TIME__ +#define AUTHOR "(C) Peter Rittwage and the rest of the C64 Preservation Project team\nhttp://c64preservation.com\n" + +#ifndef SVN +#define SVN 2014 +#endif + +#endif From 0314a9fddf00f5e71e30cece0cd3f5a170fd046c Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 20:33:15 +0200 Subject: [PATCH 02/21] Refactor / minimize deps: move fileio declarations to its own header. --- fileio.h | 25 +++++++++++++++++++++++++ nibtools.h | 20 +------------------- 2 files changed, 26 insertions(+), 19 deletions(-) create mode 100644 fileio.h diff --git a/fileio.h b/fileio.h new file mode 100644 index 0000000..d499699 --- /dev/null +++ b/fileio.h @@ -0,0 +1,25 @@ + +#ifndef FILEIO_H +#define FILEIO_H + +void parseargs(char *argv[]); +void switchusage(void); +int load_file(char *filename, BYTE *file_buffer); +int save_file(char *filename, BYTE *file_buffer, int length); +int read_nib(BYTE *file_buffer, int file_buffer_size, BYTE *track_buffer, BYTE *track_density, size_t *track_length); +int read_nb2(char *filename, BYTE *track_buffer, BYTE *track_density, size_t *track_length); +int read_g64(char *filename, BYTE *track_buffer, BYTE *track_density, size_t *track_length); +int read_d64(char *filename, BYTE *track_buffer, BYTE *track_density, size_t *track_length); +int write_nib(BYTE*file_buffer, BYTE *track_buffer, BYTE *track_density, size_t *track_length); +int write_g64(char *filename, BYTE *track_buffer, BYTE *track_density, size_t *track_length); +int write_d64(char *filename, BYTE *track_buffer, BYTE *track_density, size_t *track_length); +size_t compress_halftrack(int halftrack, BYTE *track_buffer, BYTE track_density, size_t track_length); +int align_tracks(BYTE *track_buffer, BYTE *track_density, size_t *track_length, BYTE *track_alignment); +int sync_tracks(BYTE *track_buffer, BYTE *track_density, size_t *track_length, BYTE *track_alignment); +int write_dword(FILE * fd, DWORD * buf, int num); +unsigned int crc_dir_track(BYTE *track_buffer, size_t *track_length); +unsigned int crc_all_tracks(BYTE *track_buffer, size_t *track_length); +unsigned int md5_dir_track(BYTE *track_buffer, size_t *track_length, unsigned char *result); +unsigned int md5_all_tracks(BYTE *track_buffer, size_t *track_length, unsigned char *result); + +#endif diff --git a/nibtools.h b/nibtools.h index c69c72f..7622821 100644 --- a/nibtools.h +++ b/nibtools.h @@ -121,25 +121,7 @@ int loadimage(char * filename); int writeimage(CBM_FILE fd); /* fileio.c */ -void parseargs(char *argv[]); -void switchusage(void); -int load_file(char *filename, BYTE *file_buffer); -int save_file(char *filename, BYTE *file_buffer, int length); -int read_nib(BYTE *file_buffer, int file_buffer_size, BYTE *track_buffer, BYTE *track_density, size_t *track_length); -int read_nb2(char *filename, BYTE *track_buffer, BYTE *track_density, size_t *track_length); -int read_g64(char *filename, BYTE *track_buffer, BYTE *track_density, size_t *track_length); -int read_d64(char *filename, BYTE *track_buffer, BYTE *track_density, size_t *track_length); -int write_nib(BYTE*file_buffer, BYTE *track_buffer, BYTE *track_density, size_t *track_length); -int write_g64(char *filename, BYTE *track_buffer, BYTE *track_density, size_t *track_length); -int write_d64(char *filename, BYTE *track_buffer, BYTE *track_density, size_t *track_length); -size_t compress_halftrack(int halftrack, BYTE *track_buffer, BYTE track_density, size_t track_length); -int align_tracks(BYTE *track_buffer, BYTE *track_density, size_t *track_length, BYTE *track_alignment); -int sync_tracks(BYTE *track_buffer, BYTE *track_density, size_t *track_length, BYTE *track_alignment); -int write_dword(FILE * fd, DWORD * buf, int num); -unsigned int crc_dir_track(BYTE *track_buffer, size_t *track_length); -unsigned int crc_all_tracks(BYTE *track_buffer, size_t *track_length); -unsigned int md5_dir_track(BYTE *track_buffer, size_t *track_length, unsigned char *result); -unsigned int md5_all_tracks(BYTE *track_buffer, size_t *track_length, unsigned char *result); +#include "fileio.h" /* read.c */ BYTE read_halftrack(CBM_FILE fd, int halftrack, BYTE * buffer); From 6d4940f56cdf8afedfeb5da4a7851fcc8916dc7f Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 20:39:39 +0200 Subject: [PATCH 03/21] Refactor / minimize deps: move drive module declarations to its own header. --- drive.h | 34 ++++++++++++++++++++++++++++++++++ nibtools.h | 29 +---------------------------- 2 files changed, 35 insertions(+), 28 deletions(-) create mode 100644 drive.h diff --git a/drive.h b/drive.h new file mode 100644 index 0000000..b74e17a --- /dev/null +++ b/drive.h @@ -0,0 +1,34 @@ + +#ifndef DRIVE_H +#define DRIVE_H + +int compare_extension(unsigned char * filename, unsigned char * extension); +unsigned char burst_read(CBM_FILE f); +void burst_write(CBM_FILE f, unsigned char c); +int burst_read_n(CBM_FILE f, unsigned char *Buffer, unsigned int Length); +int burst_write_n(CBM_FILE f, unsigned char *Buffer, unsigned int Length); +int burst_read_track(CBM_FILE f, unsigned char *Buffer, unsigned int Length); +int burst_write_track(CBM_FILE f, unsigned char *Buffer, unsigned int Length); +void ARCH_SIGNALDECL handle_signals(int sig); +void ARCH_SIGNALDECL handle_exit(void); +int upload_code(CBM_FILE fd, BYTE drive); +int reset_floppy(CBM_FILE fd, BYTE drive); +int init_floppy(CBM_FILE fd, BYTE drive, int bump); +int set_density(CBM_FILE fd, BYTE density); +BYTE set_bitrate(CBM_FILE fd, BYTE density); +BYTE set_default_bitrate(CBM_FILE fd, int track); +BYTE scan_track(CBM_FILE fd, int track); +void perform_bump(CBM_FILE fd, BYTE drive); +int test_par_port(CBM_FILE fd); +void send_mnib_cmd(CBM_FILE fd, BYTE cmd, BYTE *args, int num_args); +void set_full_track(CBM_FILE fd); +void motor_on(CBM_FILE fd); +void motor_off(CBM_FILE fd); +void step_to_halftrack(CBM_FILE fd, int halftrack); +int verify_floppy(CBM_FILE fd); +#ifdef DJGPP +#include +int find_par_port(CBM_FILE fd); +#endif + +#endif diff --git a/nibtools.h b/nibtools.h index 7622821..7cd1e0c 100644 --- a/nibtools.h +++ b/nibtools.h @@ -146,31 +146,4 @@ void speed_adjust(CBM_FILE fd); void kill_track(CBM_FILE fd, int track); /* drive.c */ -int compare_extension(unsigned char * filename, unsigned char * extension); -unsigned char burst_read(CBM_FILE f); -void burst_write(CBM_FILE f, unsigned char c); -int burst_read_n(CBM_FILE f, unsigned char *Buffer, unsigned int Length); -int burst_write_n(CBM_FILE f, unsigned char *Buffer, unsigned int Length); -int burst_read_track(CBM_FILE f, unsigned char *Buffer, unsigned int Length); -int burst_write_track(CBM_FILE f, unsigned char *Buffer, unsigned int Length); -void ARCH_SIGNALDECL handle_signals(int sig); -void ARCH_SIGNALDECL handle_exit(void); -int upload_code(CBM_FILE fd, BYTE drive); -int reset_floppy(CBM_FILE fd, BYTE drive); -int init_floppy(CBM_FILE fd, BYTE drive, int bump); -int set_density(CBM_FILE fd, BYTE density); -BYTE set_bitrate(CBM_FILE fd, BYTE density); -BYTE set_default_bitrate(CBM_FILE fd, int track); -BYTE scan_track(CBM_FILE fd, int track); -void perform_bump(CBM_FILE fd, BYTE drive); -int test_par_port(CBM_FILE fd); -void send_mnib_cmd(CBM_FILE fd, BYTE cmd, BYTE *args, int num_args); -void set_full_track(CBM_FILE fd); -void motor_on(CBM_FILE fd); -void motor_off(CBM_FILE fd); -void step_to_halftrack(CBM_FILE fd, int halftrack); -int verify_floppy(CBM_FILE fd); -#ifdef DJGPP -#include -int find_par_port(CBM_FILE fd); -#endif +#include "drive.h" From b77e1e3e342b0140228c72985962695107551524 Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 21:00:08 +0200 Subject: [PATCH 04/21] Refactor / minimize deps: move global variables' declarations to a separated header. --- nibtools.h | 41 ++--------------------------------------- nibtools_global.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 39 deletions(-) create mode 100644 nibtools_global.h diff --git a/nibtools.h b/nibtools.h index 7cd1e0c..90f7415 100644 --- a/nibtools.h +++ b/nibtools.h @@ -67,45 +67,8 @@ #endif /* global variables */ -extern char bitrate_range[4]; -extern char bitrate_value[4]; -extern char density_branch[4]; -extern char *cbm_adapter; -extern BYTE density_map; -extern BYTE skew_map[]; -extern BYTE fillbyte; -extern BYTE copyprot; -extern BYTE drive; -extern FILE * fplog; -extern float motor_speed; -extern size_t error_retries; -extern int skew; -extern int mode; -extern int read_killer; -extern int align_disk; -extern int force_density; -extern int track_match; -extern int interactive_mode; -extern int gap_match_length; -extern int cap_min_ignore; -extern int verbose; -extern int ihs; -extern int start_track, end_track, track_inc; -extern int fix_gcr, reduce_sync, increase_sync; -extern int imagetype, auto_capacity_adjust; -extern int extended_parallel_test; -extern int force_nosync; -extern int rawmode; -extern int rpm_real; -extern int unformat_passes; -extern int align_delay; -extern int presync; -extern int use_floppycode_srq; -extern int override_srq; -extern int extra_capacity_margin; -extern int sync_align_buffer; -extern int fattrack; -extern int old_g64; +#include "nibtools_global.h" + #include "ihs.h" diff --git a/nibtools_global.h b/nibtools_global.h new file mode 100644 index 0000000..51b935a --- /dev/null +++ b/nibtools_global.h @@ -0,0 +1,45 @@ + +#ifndef NIBTOOLS_GLOBAL_H +#define NIBTOOLS_GLOBAL_H + +extern char bitrate_range[4]; +extern char bitrate_value[4]; +extern char density_branch[4]; +extern char *cbm_adapter; +extern BYTE density_map; +extern BYTE skew_map[]; +extern BYTE fillbyte; +extern BYTE copyprot; +extern BYTE drive; +extern FILE * fplog; +extern float motor_speed; +extern size_t error_retries; +extern int skew; +extern int mode; +extern int read_killer; +extern int align_disk; +extern int force_density; +extern int track_match; +extern int interactive_mode; +extern int gap_match_length; +extern int cap_min_ignore; +extern int verbose; +extern int ihs; +extern int start_track, end_track, track_inc; +extern int fix_gcr, reduce_sync, increase_sync; +extern int imagetype, auto_capacity_adjust; +extern int extended_parallel_test; +extern int force_nosync; +extern int rawmode; +extern int rpm_real; +extern int unformat_passes; +extern int align_delay; +extern int presync; +extern int use_floppycode_srq; +extern int override_srq; +extern int extra_capacity_margin; +extern int sync_align_buffer; +extern int fattrack; +extern int old_g64; + +#endif From bd2ff5de6cd2cf3ab13f13073d7d92272f540132 Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 21:08:12 +0200 Subject: [PATCH 05/21] Refactor / minimize deps: move global defines to a separated header. --- nibtools.h | 56 +--------------------------------------------- nibtools_defs.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 55 deletions(-) create mode 100644 nibtools_defs.h diff --git a/nibtools.h b/nibtools.h index 90f7415..d99e560 100644 --- a/nibtools.h +++ b/nibtools.h @@ -6,61 +6,7 @@ #include "nibtools_version.h" - -#define FL_STEPTO 0x00 -#define FL_MOTOR 0x01 -#define FL_RESET 0x02 -#define FL_READWOSYNC 0x03 -#define FL_READNORMAL 0x04 -#define FL_READIHS 0x05 -#define FL_DENSITY 0x06 -#define FL_SCANKILLER 0x07 -#define FL_SCANDENSITY 0x08 -#define FL_READMOTOR 0x09 -#define FL_TEST 0x0a -#define FL_WRITE 0x0b -#define FL_CAPACITY 0x0c -#define FL_ALIGNDISK 0x0d -#define FL_VERIFY_CODE 0x0e -#define FL_FILLTRACK 0x0f -#define FL_READMARKER 0x10 - -#define DISK_NORMAL 0 - -#define IMAGE_NIB 0 /* destination image format */ -#define IMAGE_D64 1 -#define IMAGE_G64 2 -#define IMAGE_NB2 3 - -#define BM_MATCH 0x10 /* not used but exists in very old images */ -#define BM_NO_CYCLE 0x20 -#define BM_NO_SYNC 0x40 -#define BM_FF_TRACK 0x80 - -#define DENSITY_SAMPLES 2 - -/* custom density maps for reading */ -#define DENSITY_STANDARD 0 -#define DENSITY_RAPIDLOK 1 - -#define MODE_READ_DISK 0 -#define MODE_WRITE_DISK 1 -#define MODE_UNFORMAT_DISK 2 -#define MODE_WRITE_RAW 3 -#define MODE_TEST_ALIGNMENT 4 -#define MODE_SPEED_ADJUST 5 - -#define BYTETOBINARYPATTERN "%d%d%d%d%d%d%d%d" -#define BYTETOBINARY(byte) \ - (byte & 0x80 ? 1 : 0), \ - (byte & 0x40 ? 1 : 0), \ - (byte & 0x20 ? 1 : 0), \ - (byte & 0x10 ? 1 : 0), \ - (byte & 0x08 ? 1 : 0), \ - (byte & 0x04 ? 1 : 0), \ - (byte & 0x02 ? 1 : 0), \ - (byte & 0x01 ? 1 : 0) - +#include "nibtools_defs.h" #ifndef DJGPP #include diff --git a/nibtools_defs.h b/nibtools_defs.h new file mode 100644 index 0000000..860acf9 --- /dev/null +++ b/nibtools_defs.h @@ -0,0 +1,59 @@ + +#ifndef NIBTOOLS_DEFS_H +#define NIBTOOLS_DEFS_H + +#define FL_STEPTO 0x00 +#define FL_MOTOR 0x01 +#define FL_RESET 0x02 +#define FL_READWOSYNC 0x03 +#define FL_READNORMAL 0x04 +#define FL_READIHS 0x05 +#define FL_DENSITY 0x06 +#define FL_SCANKILLER 0x07 +#define FL_SCANDENSITY 0x08 +#define FL_READMOTOR 0x09 +#define FL_TEST 0x0a +#define FL_WRITE 0x0b +#define FL_CAPACITY 0x0c +#define FL_ALIGNDISK 0x0d +#define FL_VERIFY_CODE 0x0e +#define FL_FILLTRACK 0x0f +#define FL_READMARKER 0x10 + +#define DISK_NORMAL 0 + +#define IMAGE_NIB 0 /* destination image format */ +#define IMAGE_D64 1 +#define IMAGE_G64 2 +#define IMAGE_NB2 3 + +#define BM_MATCH 0x10 /* not used but exists in very old images */ +#define BM_NO_CYCLE 0x20 +#define BM_NO_SYNC 0x40 +#define BM_FF_TRACK 0x80 + +#define DENSITY_SAMPLES 2 + +/* custom density maps for reading */ +#define DENSITY_STANDARD 0 +#define DENSITY_RAPIDLOK 1 + +#define MODE_READ_DISK 0 +#define MODE_WRITE_DISK 1 +#define MODE_UNFORMAT_DISK 2 +#define MODE_WRITE_RAW 3 +#define MODE_TEST_ALIGNMENT 4 +#define MODE_SPEED_ADJUST 5 + +#define BYTETOBINARYPATTERN "%d%d%d%d%d%d%d%d" +#define BYTETOBINARY(byte) \ + (byte & 0x80 ? 1 : 0), \ + (byte & 0x40 ? 1 : 0), \ + (byte & 0x20 ? 1 : 0), \ + (byte & 0x10 ? 1 : 0), \ + (byte & 0x08 ? 1 : 0), \ + (byte & 0x04 ? 1 : 0), \ + (byte & 0x02 ? 1 : 0), \ + (byte & 0x01 ? 1 : 0) + +#endif From 5e83f3a7869bfdd91617072364569d2baa99f122 Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 21:15:26 +0200 Subject: [PATCH 06/21] fileio: minimize dependencies. --- fileio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fileio.c b/fileio.c index cb28ced..5250c38 100644 --- a/fileio.c +++ b/fileio.c @@ -14,7 +14,9 @@ #include "mnibarch.h" #include "gcr.h" -#include "nibtools.h" +#include "nibtools_defs.h" +#include "nibtools_global.h" +#include "fileio.h" #include "prot.h" #include "crc.h" #include "md5.h" From 7a3dd5af8a548d1765da37816ccea4efcabb4902 Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 21:15:50 +0200 Subject: [PATCH 07/21] nibconv: minimize dependencies. --- nibconv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nibconv.c b/nibconv.c index d5f5538..d4b3cae 100644 --- a/nibconv.c +++ b/nibconv.c @@ -12,10 +12,14 @@ #include "mnibarch.h" #include "gcr.h" -#include "nibtools.h" +#include "drive.h" +#include "fileio.h" #include "lz.h" +#include "nibtools_version.h" #include "prot.h" +void usage(void); + int _dowildcard = 1; BYTE compressed_buffer[(MAX_HALFTRACKS_1541 + 2) * NIB_TRACK_LENGTH]; From 6c1d2d5d40f7aa8ab1f6f618c2e4571bf50eed4a Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 21:20:57 +0200 Subject: [PATCH 08/21] makefile (GNU): do not link opencbm to programs that not require it. --- GNU/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GNU/Makefile b/GNU/Makefile index 8086b91..a621d5f 100644 --- a/GNU/Makefile +++ b/GNU/Makefile @@ -103,13 +103,13 @@ nibsrqtest.c: ${NIBTOOLS_BIN} nibwrite.c: ${NIBTOOLS_BIN} nibconv: ${OBJ} nibconv.o - ${CC} -o nibconv$(EXE) nibconv.o ${OBJ} $(LDFLAGS) + ${CC} -o nibconv$(EXE) nibconv.o ${OBJ} nibrepair: ${OBJ} nibrepair.o - ${CC} -o nibrepair$(EXE) nibrepair.o ${OBJ} $(LDFLAGS) + ${CC} -o nibrepair$(EXE) nibrepair.o ${OBJ} nibscan: ${OBJ} nibscan.o - ${CC} -o nibscan$(EXE) nibscan.o ${OBJ} $(LDFLAGS) + ${CC} -o nibscan$(EXE) nibscan.o ${OBJ} clean: ${RM} *.o ${MNIB_BIN} *.bin *.inc nib*.exe From 1860ef59c5d86b89cd60ddc3b819e61d585e01f5 Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 21:24:49 +0200 Subject: [PATCH 09/21] makefile (GNU): compile first programs that do not require opencbm. Otherwise, if opencbm is not available - it is not possible to build the program that do not need openpbm. Note that this modification is a quick shortcut, not resolving the problem fully (ie. install rules will not work with not all programs built...). In general, improving configuration options and build dependencies should allow to build things depending what is needed. In particular, the tools that do not require the openpbm driver, should not require it for building. --- GNU/Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/GNU/Makefile b/GNU/Makefile index a621d5f..da3779b 100644 --- a/GNU/Makefile +++ b/GNU/Makefile @@ -47,27 +47,27 @@ dos: CFLAGS="-I include/DOS/ $(CFLAGS)" \ EXE=".exe" \ -f GNU/Makefile \ - nibread nibwrite nibconv nibscan nibrepair + nibconv nibscan nibrepair nibread nibwrite linux: ${MAKE} CFLAGS="-I include/LINUX/ -I ${CBM_LNX_PATH}/include ${CFLAGS} -std=c99" \ LDFLAGS="-L${CBM_LNX_PATH}/lib -lopencbm" \ -f GNU/Makefile \ - nibread nibwrite nibconv nibscan nibrepair nibsrqtest + nibconv nibscan nibrepair nibread nibwrite nibsrqtest win32: ${MAKE} CFLAGS="-I include/WINDOWS/ -I ${CBM_WIN_PATH}/include -D WIN32 ${CFLAGS} -std=c99" \ LDFLAGS="-L${CBM_WIN_PATH}/bin/i386/ -lopencbm" \ EXE=".exe" \ -f GNU/Makefile \ - nibread nibwrite nibconv nibscan nibrepair nibsrqtest + nibconv nibscan nibrepair nibread nibwrite nibsrqtest win64: ${MAKE} CFLAGS="-I include/WINDOWS/ -I ${CBM_WIN_PATH}/include -D WIN32 ${CFLAGS} -std=c99" \ LDFLAGS="-L${CBM_WIN_PATH}/bin/amd64/ -lopencbm" \ EXE=".exe" \ -f GNU/Makefile \ - nibread nibwrite nibconv nibscan nibrepair nibsrqtest + nibconv nibscan nibrepair nibread nibwrite nibsrqtest # Warning level. Don't reduce, fix your new code instead. WARNS= -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wpointer-arith @@ -89,7 +89,7 @@ buildall: ${PROG} nibread: ${OBJ} ${NIBREAD_OBJ} ${NIBTOOLS_BIN} ${ARCH_OBJ} ${CC} -o nibread$(EXE) ${OBJ} ${NIBREAD_OBJ} ${ARCH_OBJ} ${LDFLAGS} - + nibsrqtest: ${NIBSRQTEST_OBJ} ${NIBTOOLS_BIN} ${ARCH_OBJ} ${CC} -o nibsrqtest$(EXE) ${NIBSRQTEST_OBJ} ${ARCH_OBJ} ${LDFLAGS} @@ -116,7 +116,7 @@ clean: distclean: clean ${RM} ${PROG} *.exe - + drive.o: nibtools_1541.inc nibtools_1541_ihs.inc nibtools_1571.inc nibtools_1571_ihs.inc nibtools_1571_srq.inc nibtools_1571_srq_test.inc *.o: gcr.h nibtools.h @@ -136,7 +136,7 @@ nibtools_1541_ihs.bin: nibtools_15x1_ihs.asm nibtools_1571_ihs.bin: nibtools_15x1_ihs.asm $(CA65) $(CA65_FLAGS) -D DRIVE=1571 -o $*.tmp $< $(LD65) -o $@ --target none $*.tmp && rm -f $*.tmp - + nibtools_1571_srq.bin: nibtools_1571_srq.asm $(CA65) $(CA65_FLAGS) -D DRIVE=1571 -o $*.tmp $< $(LD65) -o $@ --target none $*.tmp && rm -f $*.tmp @@ -144,7 +144,7 @@ nibtools_1571_srq.bin: nibtools_1571_srq.asm nibtools_1571_srq_test.bin: nibtools_1571_srq_test.asm $(CA65) $(CA65_FLAGS) -D DRIVE=1571 -o $*.tmp $< $(LD65) -o $@ --target none $*.tmp && rm -f $*.tmp - + .bin.inc: test -s $< && od -txC -v -An $< | \ sed 's/\([0-9a-f]\{2\}\) */0x\1,/g; $$s/,$$//' > $@ From c3582a6f400c6e94d17711634e6fc0419e79e055 Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 21:59:02 +0200 Subject: [PATCH 10/21] Add main makefile (where the OS / environment should be selected). --- Makefile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1e367fb --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ + +#TARGET_ENV=GNU +TARGET_ENV=LINUX +#TARGET_ENV=WSDK + +all: + make -f $(TARGET_ENV)/Makefile + +clean: + make -f $(TARGET_ENV)/Makefile clean + +install: + make -f $(TARGET_ENV)/Makefile install + +uninstall: + make -f $(TARGET_ENV)/Makefile uninstall + +.PHONY: all clean install uninstall From 8978bc8cace4632a427680da022e864da63cc0fa Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 21:59:47 +0200 Subject: [PATCH 11/21] Fix linux makefile. The RELATIVEPATH suggests that the build was supposed to be executed in LINUX/ directory (maybe producing binaries there), but this is inconsistent with GNU/Makefile (it, basically, does not work that way). Removing it and building things in the main project directory. --- LINUX/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LINUX/Makefile b/LINUX/Makefile index 2fa1b0a..e7767b8 100644 --- a/LINUX/Makefile +++ b/LINUX/Makefile @@ -1,7 +1,7 @@ # $Id: Makefile,v 1.1.1.1 2007/01/21 17:15:35 peter Exp $ -RELATIVEPATH=../ -include ${RELATIVEPATH}LINUX/config.make +#RELATIVEPATH=../ +#include ${RELATIVEPATH}LINUX/config.make .PHONY: all mrproper clean install uninstall install-files From 75870f5932eb703a04c56b354f1d2d7e91f04eb2 Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 22:34:58 +0200 Subject: [PATCH 12/21] Refact / minimize deps: include opencbm only where required (nibread and nibwrite). opencbm is used only by the utilities for data transfer using serial cable. Other utilities do not need it. --- include/LINUX/mnibarch.h | 7 ++++++- nibread.c | 4 ++++ nibtools.h | 4 ---- nibwrite.c | 4 ++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/LINUX/mnibarch.h b/include/LINUX/mnibarch.h index 1d6f65d..b1e4dda 100644 --- a/include/LINUX/mnibarch.h +++ b/include/LINUX/mnibarch.h @@ -1,4 +1,5 @@ -#include + +#include #include #define delay(x) usleep((x) * 1000) @@ -12,6 +13,10 @@ typedef unsigned char BYTE; // __int32 and min() are needed for bitshifter.c (included by fileio.c) typedef int32_t __int32; +#ifndef CBM_FILE +typedef int CBM_FILE; +#endif + #ifndef min #define min(x, y) ((x) > (y) ? (y) : (x)) #endif diff --git a/nibread.c b/nibread.c index 17d574a..af2b749 100644 --- a/nibread.c +++ b/nibread.c @@ -11,6 +11,10 @@ #include #include +#ifndef DJGPP +#include +#endif + #include "mnibarch.h" #include "gcr.h" #include "nibtools.h" diff --git a/nibtools.h b/nibtools.h index d99e560..16b0d33 100644 --- a/nibtools.h +++ b/nibtools.h @@ -8,10 +8,6 @@ #include "nibtools_version.h" #include "nibtools_defs.h" -#ifndef DJGPP -#include -#endif - /* global variables */ #include "nibtools_global.h" diff --git a/nibwrite.c b/nibwrite.c index da76abd..a1d2e78 100644 --- a/nibwrite.c +++ b/nibwrite.c @@ -11,6 +11,10 @@ #include #include +#ifndef DJGPP +#include +#endif + #include "mnibarch.h" #include "gcr.h" #include "nibtools.h" From c032b74ade616d63edeae31f699d58ec361e4766 Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 22:37:52 +0200 Subject: [PATCH 13/21] Update gitignore (add *.o and *~). --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index e489d5d..7b3f338 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,5 @@ WINBUILD-nibread/objfre* /obj* /objchk* /objfre* +*.o +*~ From 4e7c39602a4272ef15f0d228fa33bbe53ede1b0c Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 22:46:52 +0200 Subject: [PATCH 14/21] Revert "fileio: minimize dependencies." This reverts commit 5e83f3a7869bfdd91617072364569d2baa99f122. fileio needs prototype of usage (an external defined in the main module of each utility). --- fileio.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fileio.c b/fileio.c index 5250c38..cb28ced 100644 --- a/fileio.c +++ b/fileio.c @@ -14,9 +14,7 @@ #include "mnibarch.h" #include "gcr.h" -#include "nibtools_defs.h" -#include "nibtools_global.h" -#include "fileio.h" +#include "nibtools.h" #include "prot.h" #include "crc.h" #include "md5.h" From 41e3e9d146c3ca4be5e8e5d70c8c12ff83e2afc5 Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 23:12:15 +0200 Subject: [PATCH 15/21] Refact / minimize deps: include opencbm only where required (cont.). --- drive.c | 4 ++++ nibsrqtest.c | 4 ++++ read.c | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/drive.c b/drive.c index 71e1462..e468551 100644 --- a/drive.c +++ b/drive.c @@ -8,6 +8,10 @@ #include #include +#ifndef DJGPP +#include +#endif + #include "mnibarch.h" #include "gcr.h" #include "nibtools.h" diff --git a/nibsrqtest.c b/nibsrqtest.c index 5d326b9..3462533 100755 --- a/nibsrqtest.c +++ b/nibsrqtest.c @@ -9,6 +9,10 @@ #include #include +#ifndef DJGPP +#include +#endif + #include "mnibarch.h" #include "gcr.h" #include "nibtools.h" diff --git a/read.c b/read.c index 7a6fd26..2470cbd 100644 --- a/read.c +++ b/read.c @@ -9,6 +9,10 @@ #include #include +#ifndef DJGPP +#include +#endif + #include "mnibarch.h" #include "gcr.h" #include "nibtools.h" From c2ea4146d47e4d6fe2d1766ba000d5326414a50c Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 23:12:43 +0200 Subject: [PATCH 16/21] Fix double object defs. Make extern things already defined in read.c --- nibwrite.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nibwrite.c b/nibwrite.c index a1d2e78..68cd98a 100644 --- a/nibwrite.c +++ b/nibwrite.c @@ -38,10 +38,10 @@ int start_track, end_track, track_inc; int reduce_sync; int fix_gcr, aggressive_gcr; int align; -unsigned int lpt[4]; -int lpt_num; +extern unsigned int lpt[4]; +extern int lpt_num; int drivetype; -unsigned int floppybytes; +extern unsigned int floppybytes; int imagetype; int mode; int verify; From cfa8e70569499977649b670c368c1eeb3538c9c7 Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 23:20:14 +0200 Subject: [PATCH 17/21] Set correct build source type. usleep() is a POSIX function, not provided by c99. Proper source type must be set to build. --- GNU/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNU/Makefile b/GNU/Makefile index da3779b..cbc9fb9 100644 --- a/GNU/Makefile +++ b/GNU/Makefile @@ -50,7 +50,7 @@ dos: nibconv nibscan nibrepair nibread nibwrite linux: - ${MAKE} CFLAGS="-I include/LINUX/ -I ${CBM_LNX_PATH}/include ${CFLAGS} -std=c99" \ + ${MAKE} CFLAGS="-I include/LINUX/ -I ${CBM_LNX_PATH}/include ${CFLAGS} -std=c99 -D_BSD_SOURCE" \ LDFLAGS="-L${CBM_LNX_PATH}/lib -lopencbm" \ -f GNU/Makefile \ nibconv nibscan nibrepair nibread nibwrite nibsrqtest From bbdfce2d714daf3c81f92c459f701636c7befb34 Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 23:22:23 +0200 Subject: [PATCH 18/21] gnu makefile: more warnings / compiler checks. --- GNU/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/GNU/Makefile b/GNU/Makefile index cbc9fb9..d6cc2b0 100644 --- a/GNU/Makefile +++ b/GNU/Makefile @@ -70,7 +70,12 @@ win64: nibconv nibscan nibrepair nibread nibwrite nibsrqtest # Warning level. Don't reduce, fix your new code instead. -WARNS= -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wpointer-arith +WARNS= -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wpointer-arith \ + -Wextra -Wconversion -pedantic \ + -Werror-implicit-function-declaration \ + -Wsign-conversion +# -Werror=format-security + # Common objects OBJ=gcr.o prot.o fileio.o crc.o md5.o lz.o From 35d159b83c94769bf750f849a059dcb143aa409d Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 23:35:04 +0200 Subject: [PATCH 19/21] makefile linux: set example path to opencbm. To update/set by user. --- LINUX/Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/LINUX/Makefile b/LINUX/Makefile index e7767b8..cc54e70 100644 --- a/LINUX/Makefile +++ b/LINUX/Makefile @@ -8,13 +8,15 @@ OBJS = nibread.o nibwrite.o nibscan.o nibconv.o nibrepair.o nibsrqtest.o read.o write.o gcr.o prot.o crc.o drive.o fileio.o ihs.o lz.o md5.o PROG = nibread nibwrite nibscan nibconv nibrepair nibsrqtest +CBM_LNX_PATH=../../../opencbm/OpenCBM/opencbm + all: - make -f GNU/Makefile CBM_LNX_PATH="../" linux + make -f GNU/Makefile CBM_LNX_PATH=$(CBM_LNX_PATH) linux mrproper: clean clean: - make -f GNU/Makefile CBM_LNX_PATH="../" distclean + make -f GNU/Makefile distclean install-files: $(PROG) install -m 755 -s $(PROG) $(BINDIR) From 80e1981aa4a14a9fee93217684426590487b330f Mon Sep 17 00:00:00 2001 From: t-m Date: Mon, 6 May 2024 23:38:52 +0200 Subject: [PATCH 20/21] Fix source files' permissions. --- .cvsignore | 0 ihs.c | 0 ihs.h | 0 lz.c | 0 lz.h | 0 nibsrqtest.c | 0 nibtools_1571_srq.asm | 0 nibtools_1571_srq_test.asm | 0 nibtools_15x1_ihs.asm | 0 readme.txt | 0 10 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 .cvsignore mode change 100755 => 100644 ihs.c mode change 100755 => 100644 ihs.h mode change 100755 => 100644 lz.c mode change 100755 => 100644 lz.h mode change 100755 => 100644 nibsrqtest.c mode change 100755 => 100644 nibtools_1571_srq.asm mode change 100755 => 100644 nibtools_1571_srq_test.asm mode change 100755 => 100644 nibtools_15x1_ihs.asm mode change 100755 => 100644 readme.txt diff --git a/.cvsignore b/.cvsignore old mode 100755 new mode 100644 diff --git a/ihs.c b/ihs.c old mode 100755 new mode 100644 diff --git a/ihs.h b/ihs.h old mode 100755 new mode 100644 diff --git a/lz.c b/lz.c old mode 100755 new mode 100644 diff --git a/lz.h b/lz.h old mode 100755 new mode 100644 diff --git a/nibsrqtest.c b/nibsrqtest.c old mode 100755 new mode 100644 diff --git a/nibtools_1571_srq.asm b/nibtools_1571_srq.asm old mode 100755 new mode 100644 diff --git a/nibtools_1571_srq_test.asm b/nibtools_1571_srq_test.asm old mode 100755 new mode 100644 diff --git a/nibtools_15x1_ihs.asm b/nibtools_15x1_ihs.asm old mode 100755 new mode 100644 diff --git a/readme.txt b/readme.txt old mode 100755 new mode 100644 From a6d31f72022e09e8b474a88f532b25ff9da21dd2 Mon Sep 17 00:00:00 2001 From: t-m Date: Tue, 7 May 2024 00:04:25 +0200 Subject: [PATCH 21/21] mnibarch: add include guard. --- include/LINUX/mnibarch.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/LINUX/mnibarch.h b/include/LINUX/mnibarch.h index b1e4dda..d45b584 100644 --- a/include/LINUX/mnibarch.h +++ b/include/LINUX/mnibarch.h @@ -1,4 +1,7 @@ +#ifndef MNIBARCH_H +#define MNIBARCH_H + #include #include @@ -20,3 +23,5 @@ typedef int CBM_FILE; #ifndef min #define min(x, y) ((x) > (y) ? (y) : (x)) #endif + +#endif