sdk: added `bin2hex` tool

This commit is contained in:
Ivan Tatarinov 2021-04-14 19:05:55 +03:00
parent cb0a8cc8e0
commit 63446da962
14 changed files with 79 additions and 97 deletions

View File

@ -1,33 +0,0 @@
#include <stdio.h>
#include <string.h>
int main (int argc, char *argv[])
{
FILE *f;
unsigned char *scr;
char nombre[256];
int i,leido;
if (argc<2)
return 1;
scr = malloc(65536);
f = fopen (argv[1],"rb");
if (!f)
return 1;
leido = fread (scr, 1, 65536, f);
fclose (f);
strcpy (nombre, argv[1]);
nombre[strlen(nombre)-3]=0;
strcat (nombre, "hex");
f = fopen (nombre, "wt");
for (i=0;i<leido;i++)
fprintf (f, "%.2X\n", scr[i]);
fclose(f);
return 0;
}

Binary file not shown.

View File

@ -1,33 +0,0 @@
#include <stdio.h>
#include <string.h>
int main (int argc, char *argv[])
{
FILE *f;
unsigned char *scr;
char nombre[256];
int i,leido;
if (argc<2)
return 1;
scr = malloc(65536);
f = fopen (argv[1],"rb");
if (!f)
return 1;
leido = fread (scr, 1, 65536, f);
fclose (f);
strcpy (nombre, argv[1]);
nombre[strlen(nombre)-3]=0;
strcat (nombre, "hex");
f = fopen (nombre, "wt");
for (i=0;i<leido;i++)
fprintf (f, "%.2X\n", scr[i]);
fclose(f);
return 0;
}

Binary file not shown.

View File

@ -1,31 +0,0 @@
#include <stdio.h>
#include <string.h>
int main (int argc, char *argv[]){
FILE *f;
unsigned char *scr;
char nombre[256];
int i,leido;
if (argc<2)
return 1;
scr = (unsigned char *) malloc(65536);
f = fopen (argv[1],"rb");
if (!f)
return 1;
leido = fread (scr, 1, 65536, f);
fclose (f);
strcpy (nombre, argv[1]);
nombre[strlen(nombre)-3]=0;
strcat (nombre, "hex");
f = fopen (nombre, "wt");
for (i=0;i<leido;i++)
fprintf (f, "%.2X\n", scr[i]);
fclose(f);
return 0;
}

View File

@ -45,6 +45,7 @@ export FORCECLEAN
SJASMPLUS := sjasmplus$(EXECEXT)
ZX7B := zx7b$(EXECEXT)
BIN2HEX := bin2hex$(EXECEXT)
FCUT := fcut$(EXECEXT)
FPAD := fpad$(EXECEXT)
FPOKE := fpoke$(EXECEXT)
@ -54,6 +55,7 @@ ADDITEM := AddItem$(EXECEXT)
TOOLS:=\
bin/$(SJASMPLUS) \
bin/$(ZX7B) \
bin/$(BIN2HEX) \
bin/$(FCUT) \
bin/$(FPAD) \
bin/$(FPOKE) \

View File

@ -29,6 +29,7 @@ Command | Target
`make` | all tools
`make bin/sjasmplus` | **sjasmplus**
`make bin/zx7b` | **zx7b**
`make bin/bin2hex` | **bin2hex**
`make bin/fcut` | **fcut**
`make bin/fpad` | **fpad**
`make bin/fpoke` | **fpoke**
@ -111,6 +112,7 @@ This has the same behavior as the inclusion of `common.mk` file in a Makefile.
* sjasmplus
* zx7b
* bin2hex
* fcut
* fpad
* fpoke

1
sdk/bin/.gitignore vendored
View File

@ -4,6 +4,7 @@
sjasmplus
zx7b
bin2hex
fcut
fpad
fpoke

BIN
sdk/bin/bin2hex.exe Normal file

Binary file not shown.

View File

@ -0,0 +1,9 @@
SPDX-FileName: bin2hex.exe
SPDX-FileType: BINARY
SPDX-FileChecksum: SHA1: acc480181c0cdc8d5bfce1c633c8eefd8165908c
SPDX-FileCopyrightText: Copyright (C) 2016, 2021 Antonio Villena
SPDX-License-Identifier: GPL-3.0-only

View File

@ -24,6 +24,7 @@ include ../common.mk
SJASMPLUS := sjasmplus$(EXECEXT)
ZX7B := zx7b$(EXECEXT)
BIN2HEX := bin2hex$(EXECEXT)
FCUT := fcut$(EXECEXT)
FPAD := fpad$(EXECEXT)
FPOKE := fpoke$(EXECEXT)
@ -33,6 +34,7 @@ ADDITEM := AddItem$(EXECEXT)
TOOLS:= \
../bin/$(SJASMPLUS) \
../bin/$(ZX7B) \
../bin/$(BIN2HEX) \
../bin/$(FCUT) \
../bin/$(FPAD) \
../bin/$(FPOKE) \
@ -84,6 +86,9 @@ sjasmplus:
zx7b/$(ZX7B): | zx7b
$(MAKE) -w -C $|
../bin/$(BIN2HEX): tools/$(BIN2HEX)
cp $< $@
../bin/$(FCUT): tools/$(FCUT)
cp $< $@
@ -99,6 +104,7 @@ zx7b/$(ZX7B): | zx7b
../bin/$(ADDITEM): tools/$(ADDITEM)
cp $< $@
tools/$(BIN2HEX) \
tools/$(FCUT) \
tools/$(FPAD) \
tools/$(FPOKE) \

View File

@ -2,6 +2,8 @@
#
# SPDX-License-Identifier: CC0-1.0
bin2hex
bin2hex.exe
fcut
fcut.exe
fpad

View File

@ -20,6 +20,7 @@
include ../../common.mk
BIN2HEX := bin2hex$(EXECEXT)
FCUT := fcut$(EXECEXT)
FPAD := fpad$(EXECEXT)
FPOKE := fpoke$(EXECEXT)
@ -27,6 +28,7 @@ GENROM := GenRom$(EXECEXT)
ADDITEM := AddItem$(EXECEXT)
TOOLS:=\
$(BIN2HEX) \
$(FCUT) \
$(FPAD) \
$(FPOKE) \
@ -36,6 +38,9 @@ TOOLS:=\
.PHONY: all
all: $(TOOLS)
$(BIN2HEX): bin2hex.c
$(CC) $(CFLAGS) -o $@ $<
$(FCUT): fcut.c
$(CC) $(CFLAGS) -o $@ $<

52
sdk/src/tools/bin2hex.c Normal file
View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2016, 2021 Antonio Villena
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* SPDX-FileCopyrightText: Copyright (C) 2016, 2021 Antonio Villena
*
* SPDX-License-Identifier: GPL-3.0-only
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main (int argc, char *argv[]){
FILE *f;
unsigned char *scr;
char nombre[256];
int i,leido;
if (argc<2)
return 1;
scr = (unsigned char *) malloc(65536);
f = fopen (argv[1],"rb");
if (!f)
return 1;
leido = fread (scr, 1, 65536, f);
fclose (f);
strcpy (nombre, argv[1]);
nombre[strlen(nombre)-3]=0;
strcat (nombre, "hex");
f = fopen (nombre, "wt");
for (i=0;i<leido;i++)
fprintf (f, "%.2X\n", scr[i]);
fclose(f);
return 0;
}