mirror of https://github.com/zxdos/zxuno.git
sdk: added `AddItem` tool to SDK
This commit is contained in:
parent
4fee4cfef7
commit
02ab6a26b8
|
@ -1,68 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
FILE *fi, *fo;
|
||||
int i;
|
||||
unsigned char mem[0x4004], core;
|
||||
unsigned short j, k;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if( argc==1 )
|
||||
printf("\n"
|
||||
"AddItem v0.02, simulates Machine and ROM addition to the ZX-Uno flash image\n\n"
|
||||
" AddItem <type> <input_file> <slot>\n\n"
|
||||
" <type> ROM or COREX, when 2<=X<=45, i.e. CORE5\n"
|
||||
" <input_file> Input .TAP file generate with GenRom\n"
|
||||
" <slot> Number of slot from 0 to 63, only when type is ROM\n\n"
|
||||
"All modifications occur in the file FLASH.ZX1\n\n"),
|
||||
exit(0);
|
||||
fo= fopen("FLASH.ZX1", "rb+");
|
||||
if( strstr(argv[1], "CORE")==argv[1] && strlen(argv[1])<=6 && strlen(argv[1])>=5 && argc==3 ){
|
||||
core= (strlen(argv[1])==5 ? argv[1][4] : (argv[1][4]-'0')*10+argv[1][5])-'2';
|
||||
if( core>43 )
|
||||
printf("\nCore number out of range: %d\n", core+2),
|
||||
exit(-1);
|
||||
fi= fopen(argv[2], "rb");
|
||||
if( !fi )
|
||||
printf("\nInput file not found: %s\n", argv[2]),
|
||||
exit(-1);
|
||||
fread(mem, 1, 0x58, fi);
|
||||
fseek(fo, 0x7100+(core<<5), SEEK_SET);
|
||||
fwrite(mem+0x34, 1, 0x20, fo);
|
||||
j= mem[3];
|
||||
fseek(fo, (core>7?0x160000:0xac000)+core*0x54000, SEEK_SET);
|
||||
for ( i=0; i<j; i++ )
|
||||
fread(mem, 1, 0x4004, fi),
|
||||
fwrite(mem, 1, 0x4000, fo);
|
||||
}
|
||||
else if( !strcmp(argv[1], "ROM") && argc==4 ){
|
||||
fi= fopen(argv[3], "rb");
|
||||
if( !fi )
|
||||
printf("\nInput file not found: %s\n", argv[3]),
|
||||
exit(-1);
|
||||
fseek(fo, 0x7000, SEEK_SET);
|
||||
fread(mem, 1, 0x40, fo);
|
||||
for ( i= 0; i<0x40; i++ )
|
||||
if( mem[i]==0xff )
|
||||
break;
|
||||
mem[i]= i;
|
||||
fseek(fo, 0x7000, SEEK_SET);
|
||||
fwrite(mem, 1, 0x40, fo);
|
||||
fread(mem, 1, 0x58, fi);
|
||||
fseek(fo, 0x6000|i<<6, SEEK_SET);
|
||||
k= mem[2]= atoi(argv[2]);
|
||||
fwrite(mem+2, 1, 0x20, fo);
|
||||
fwrite(mem+0x34, 1, 0x20, fo);
|
||||
j= mem[3];
|
||||
for ( i=0; i<j; i++ )
|
||||
fseek(fo, (k<19?0xc000:0x300000)+k*0x4000, SEEK_SET),
|
||||
k= (k+1)&0x3f,
|
||||
fread(mem, 1, 0x4004, fi),
|
||||
fwrite(mem, 1, 0x4000, fo);
|
||||
}
|
||||
else
|
||||
printf("\nInvalid parameters\n"),
|
||||
exit(-1);
|
||||
printf("\nDone\n");
|
||||
}
|
Binary file not shown.
|
@ -49,6 +49,7 @@ FCUT := fcut$(EXECEXT)
|
|||
FPAD := fpad$(EXECEXT)
|
||||
FPOKE := fpoke$(EXECEXT)
|
||||
GENROM := GenRom$(EXECEXT)
|
||||
ADDITEM := AddItem$(EXECEXT)
|
||||
|
||||
TOOLS:=\
|
||||
bin/$(SJASMPLUS) \
|
||||
|
@ -56,7 +57,8 @@ TOOLS:=\
|
|||
bin/$(FCUT) \
|
||||
bin/$(FPAD) \
|
||||
bin/$(FPOKE) \
|
||||
bin/$(GENROM)
|
||||
bin/$(GENROM) \
|
||||
bin/$(ADDITEM)
|
||||
|
||||
.PHONY: all
|
||||
all: $(TOOLS)
|
||||
|
|
|
@ -33,6 +33,7 @@ Command | Target
|
|||
`make bin/fpad` | **fpad**
|
||||
`make bin/fpoke` | **fpoke**
|
||||
`make bin/GenRom` | **GenRom**
|
||||
`make bin/AddItem` | **AddItem**
|
||||
|
||||
To build using MinGW add this parameter for `make` tool:
|
||||
|
||||
|
@ -114,6 +115,7 @@ This has the same behavior as the inclusion of `common.mk` file in a Makefile.
|
|||
* fpad
|
||||
* fpoke
|
||||
* GenRom
|
||||
* AddItem
|
||||
|
||||
on Windows platform is disabled right now because of presence of precompiled binaries of them in repository.
|
||||
*By default* they are not deleted when cleaning.
|
||||
|
|
|
@ -8,3 +8,4 @@ fcut
|
|||
fpad
|
||||
fpoke
|
||||
GenRom
|
||||
AddItem
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
SPDX-FileName: AddItem.exe
|
||||
|
||||
SPDX-FileType: BINARY
|
||||
|
||||
SPDX-FileChecksum: SHA1: 4c0298aa44631d46b241f90471d36775b536d844
|
||||
|
||||
SPDX-FileCopyrightText: Copyright (C) 2019, 2021 Antonio Villena
|
||||
|
||||
SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
SPDX-FileComment: AddItem version 0.02 - simulates Machine and ROM addition to the ZX-Uno flash image.
|
|
@ -28,6 +28,7 @@ FCUT := fcut$(EXECEXT)
|
|||
FPAD := fpad$(EXECEXT)
|
||||
FPOKE := fpoke$(EXECEXT)
|
||||
GENROM := GenRom$(EXECEXT)
|
||||
ADDITEM := AddItem$(EXECEXT)
|
||||
|
||||
TOOLS:= \
|
||||
../bin/$(SJASMPLUS) \
|
||||
|
@ -35,7 +36,8 @@ TOOLS:= \
|
|||
../bin/$(FCUT) \
|
||||
../bin/$(FPAD) \
|
||||
../bin/$(FPOKE) \
|
||||
../bin/$(GENROM)
|
||||
../bin/$(GENROM) \
|
||||
../bin/$(ADDITEM)
|
||||
|
||||
.PHONY: all
|
||||
all: $(TOOLS)
|
||||
|
@ -94,10 +96,14 @@ zx7b/$(ZX7B): | zx7b
|
|||
../bin/$(GENROM): tools/$(GENROM)
|
||||
cp $< $@
|
||||
|
||||
../bin/$(ADDITEM): tools/$(ADDITEM)
|
||||
cp $< $@
|
||||
|
||||
tools/$(FCUT) \
|
||||
tools/$(FPAD) \
|
||||
tools/$(FPOKE) \
|
||||
tools/$(GENROM): | tools
|
||||
tools/$(GENROM) \
|
||||
tools/$(ADDITEM): | tools
|
||||
$(MAKE) -w -C $|
|
||||
endif
|
||||
|
||||
|
|
|
@ -10,3 +10,5 @@ fpoke
|
|||
fpoke.exe
|
||||
GenRom
|
||||
GenRom.exe
|
||||
AddItem
|
||||
AddItem.exe
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* AddItem - simulates Machine and ROM addition to the ZX-Uno flash image.
|
||||
*
|
||||
* Copyright (C) 2019, 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) 2019, 2021 Antonio Villena
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-only
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define PROGRAM "AddItem"
|
||||
#define DESCRIPTION "simulates Machine and ROM addition to the ZX-Uno flash image."
|
||||
#define VERSION "0.02"
|
||||
#define COPYRIGHT "Copyright (C) 2019, 2021 Antonio Villena"
|
||||
#define LICENSE \
|
||||
"This program is free software: you can redistribute it and/or modify\n" \
|
||||
"it under the terms of the GNU General Public License as published by\n" \
|
||||
"the Free Software Foundation, version 3."
|
||||
#define HOMEPAGE "https://github.com/zxdos/zxuno/"
|
||||
|
||||
#define OUTPUT_FILE "FLASH.ZX1"
|
||||
|
||||
FILE *fi, *fo;
|
||||
int i;
|
||||
unsigned char mem[0x4004], core;
|
||||
unsigned short j, k;
|
||||
|
||||
void show_help() {
|
||||
printf(
|
||||
PROGRAM " version " VERSION " - " DESCRIPTION "\n"
|
||||
COPYRIGHT "\n"
|
||||
LICENSE "\n"
|
||||
"Home page: " HOMEPAGE "\n"
|
||||
"\n"
|
||||
"Usage:\n"
|
||||
" " PROGRAM " <type> <input_file> <slot>\n"
|
||||
"\n"
|
||||
" <type> ROM or COREX, where 2<=X<=45, i.e. CORE5\n"
|
||||
" <input_file> Input .TAP file generated with GenRom\n"
|
||||
" <slot> Slot's number from 0 to 63, only when type is ROM\n"
|
||||
"\n"
|
||||
"All modifications occur in the file `" OUTPUT_FILE "'.\n"
|
||||
);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if( argc==1 )
|
||||
show_help(),
|
||||
exit(0);
|
||||
fo= fopen(OUTPUT_FILE, "rb+");
|
||||
if( strstr(argv[1], "CORE")==argv[1] && strlen(argv[1])<=6 && strlen(argv[1])>=5 && argc==3 ){
|
||||
core= (strlen(argv[1])==5 ? argv[1][4] : (argv[1][4]-'0')*10+argv[1][5])-'2';
|
||||
if( core>43 )
|
||||
printf("\nCore number out of range: %d\n", core+2),
|
||||
exit(-1);
|
||||
fi= fopen(argv[2], "rb");
|
||||
if( !fi )
|
||||
printf("\nInput file not found: %s\n", argv[2]),
|
||||
exit(-1);
|
||||
fread(mem, 1, 0x58, fi);
|
||||
fseek(fo, 0x7100+(core<<5), SEEK_SET);
|
||||
fwrite(mem+0x34, 1, 0x20, fo);
|
||||
j= mem[3];
|
||||
fseek(fo, (core>7?0x160000:0xac000)+core*0x54000, SEEK_SET);
|
||||
for ( i=0; i<j; i++ )
|
||||
fread(mem, 1, 0x4004, fi),
|
||||
fwrite(mem, 1, 0x4000, fo);
|
||||
}
|
||||
else if( !strcmp(argv[1], "ROM") && argc==4 ){
|
||||
fi= fopen(argv[3], "rb");
|
||||
if( !fi )
|
||||
printf("\nInput file not found: %s\n", argv[3]),
|
||||
exit(-1);
|
||||
fseek(fo, 0x7000, SEEK_SET);
|
||||
fread(mem, 1, 0x40, fo);
|
||||
for ( i= 0; i<0x40; i++ )
|
||||
if( mem[i]==0xff )
|
||||
break;
|
||||
mem[i]= i;
|
||||
fseek(fo, 0x7000, SEEK_SET);
|
||||
fwrite(mem, 1, 0x40, fo);
|
||||
fread(mem, 1, 0x58, fi);
|
||||
fseek(fo, 0x6000|i<<6, SEEK_SET);
|
||||
k= mem[2]= atoi(argv[2]);
|
||||
fwrite(mem+2, 1, 0x20, fo);
|
||||
fwrite(mem+0x34, 1, 0x20, fo);
|
||||
j= mem[3];
|
||||
for ( i=0; i<j; i++ )
|
||||
fseek(fo, (k<19?0xc000:0x300000)+k*0x4000, SEEK_SET),
|
||||
k= (k+1)&0x3f,
|
||||
fread(mem, 1, 0x4004, fi),
|
||||
fwrite(mem, 1, 0x4000, fo);
|
||||
}
|
||||
else
|
||||
printf("\nInvalid parameters\n"),
|
||||
exit(-1);
|
||||
printf("File `" OUTPUT_FILE "' is successfully updated.\n");
|
||||
}
|
|
@ -24,12 +24,14 @@ FCUT := fcut$(EXECEXT)
|
|||
FPAD := fpad$(EXECEXT)
|
||||
FPOKE := fpoke$(EXECEXT)
|
||||
GENROM := GenRom$(EXECEXT)
|
||||
ADDITEM := AddItem$(EXECEXT)
|
||||
|
||||
TOOLS:=\
|
||||
$(FCUT) \
|
||||
$(FPAD) \
|
||||
$(FPOKE) \
|
||||
$(GENROM)
|
||||
$(GENROM) \
|
||||
$(ADDITEM)
|
||||
|
||||
.PHONY: all
|
||||
all: $(TOOLS)
|
||||
|
@ -46,6 +48,9 @@ $(FPOKE): fpoke.c
|
|||
$(GENROM): GenRom.c
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(ADDITEM): AddItem.c
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f $(TOOLS)
|
||||
|
|
Loading…
Reference in New Issue