diff options
Diffstat (limited to 'jindroush/aext')
| -rw-r--r-- | jindroush/aext/Makefile | 49 | ||||
| -rw-r--r-- | jindroush/aext/aext.cpp | 280 | ||||
| -rw-r--r-- | jindroush/aext/pub.def | 31 | ||||
| -rw-r--r-- | jindroush/aext/readme.txt | 76 | ||||
| -rw-r--r-- | jindroush/aext/switches.def | 25 | 
5 files changed, 461 insertions, 0 deletions
| diff --git a/jindroush/aext/Makefile b/jindroush/aext/Makefile new file mode 100644 index 0000000..4d016e6 --- /dev/null +++ b/jindroush/aext/Makefile @@ -0,0 +1,49 @@ +#===================================================================== +PRGNAME		= aext + +DESTDIR= +PREFIX=/usr + +LDLIBS=-L../lib -ljindroush +INCPATH=-I../include + +all: $(PRGNAME) + +release: +	@$(MAKE) $(PRGNAME) CFLAGS="-c -O2 -Wall -D__CDISK_SAVE__" LDFLAGS="" +	@echo RELEASE: Compiled. + +rel_strip: release +	@strip $(PRGNAME) + +install: rel_strip +	cp $(PRGNAME) $(DESTDIR)/$(PREFIX)/bin/ +	@echo RELEASE: Installed. + +debug: +	@$(MAKE) $(PRGNAME) CFLAGS="-c -g -Wall -D_DEBUG -D__CDISK_SAVE__" LDFLAGS="-g" +	@echo DEBUG: Compiled. + +clean: +	rm -rf *.o $(PRGNAME) $(PRGNAME).exe switches.cpp +	@echo DEBUG: Cleaned. + + +OBJECTS = aext.o + +#===================================================================== +CXX		= g++ +LD		= g++ +CPPFLAGS=$(COPT) +COPT=-O2 + +#===================================================================== + +$(PRGNAME) : $(OBJECTS) +	$(LD) $(LDFLAGS) $(OBJECTS) $(LDLIBS) -o $(PRGNAME) + +%.o : %.cpp switches.cpp +	$(CXX) $(INCPATH) $(CPPFLAGS) -c $< -o $@ + +switches.cpp : switches.def ../switches.pl +	perl ../switches.pl $< $@ diff --git a/jindroush/aext/aext.cpp b/jindroush/aext/aext.cpp new file mode 100644 index 0000000..75c94c3 --- /dev/null +++ b/jindroush/aext/aext.cpp @@ -0,0 +1,280 @@ +//    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; either version 2 of the License, or +//    any later version. +// +//    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, write to the Free Software +//    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// + +#include "pub.def" +#include "jintypes.h" + +int g_iBlkEnd = 0; +int g_iBlkStart = 0; +int g_iBlkLength = 0; +int g_iBlkBase = 0; + +char szStart[ MAX_PATH ]; +char szEnd[ MAX_PATH ]; +char szLength[ MAX_PATH ]; + +BOOL g_bStartUsed = FALSE; +BOOL g_bEndUsed = FALSE; +BOOL g_bLenUsed = FALSE; + +int g_bOutputIsAtari = FALSE; +int g_bUseBase = FALSE; + +#define SHEADER PRG_NAME " v" PRG_VERSION " (c) " PRG_COPYRIGHT " " PRG_AUTHOR "\n" + +#define HEADER SHEADER \ +   PRG_DESC "\n" \ +	"  Latest version can be found at " PRG_URL "\n" \ +	"  Published under GPL. See GPL.TXT.\n\n" + +#define USAGE HEADER "Usage:  " PRG_NAME " " PRG_USAGE + +#include "switches.cpp" + +int ToNum( char*, int ); + +int main( int argc, char *argv[] ) +{ +	setbuf( stdout, NULL ); +	setbuf( stderr, NULL ); + +	if ( !SWITCHES_Init( &argc, argv ) ) +		return 1; + +	if ( argc < 2 ) +	{ +		SWFN_HELP( USAGE ); +		return 1; +	} + +	fprintf( stderr, SHEADER ); + +	char* szInfile = argv[ 1 ]; + +	char szOutfile[ MAX_PATH ]; + +	if ( argc >= 3 ) +	{ +		strcpy( szOutfile, argv[ 2 ] ); +	} +	else +	{ +		strcpy( szOutfile, "prg.axe" ); +	} + +	int hIn = open( szInfile, O_RDONLY | O_BINARY ); + +	if ( hIn == -1 ) +	{ +		fprintf( stderr, "Can't open infile '%s'!\n", szInfile ); +		return -1; +	} + +	if( g_bStartUsed ) +	{ +		g_iBlkStart = ToNum( szStart, 1 ); +	} + +	if( g_bEndUsed ) +	{ +		g_iBlkEnd = ToNum( szEnd, 1 ); +	} + +	if( g_bLenUsed ) +	{ +		g_iBlkLength = ToNum( szLength, 0 ); +	} + +	LONG lLen = lseek( hIn, 0, SEEK_END ); +	lseek( hIn, 0, SEEK_SET ); + +	if( g_bEndUsed && g_iBlkEnd < 1 ) +	{ +		g_iBlkEnd = lLen - 1 + g_iBlkEnd; +	} + +	if( g_bStartUsed ) +	{ +		if ( g_bEndUsed ) +		{ +			g_iBlkLength = g_iBlkEnd - g_iBlkStart + 1; +		} +		else +		{ +			//START & ? +			if ( g_bLenUsed ) +			{ +				//start & length +				g_iBlkEnd = g_iBlkStart + g_iBlkLength - 1;		 +			} +			else +			{ +				//start & nothing +				g_iBlkEnd = lLen - 1; +				g_iBlkLength = g_iBlkEnd - g_iBlkStart + 1; +			} +		} + +	} +	else if( g_bEndUsed ) +	{ +		if( g_bLenUsed ) +		{ +			//end & length +			g_iBlkStart = g_iBlkEnd - g_iBlkLength + 1; +		} +		else +		{ +			//end only +			g_iBlkStart = 0; +			g_iBlkLength = g_iBlkEnd - g_iBlkStart + 1; +		} +	} +	else +	{ +		if( g_bLenUsed ) +		{ +			//length only +			g_iBlkStart = 0; +			g_iBlkEnd = g_iBlkStart + g_iBlkLength - 1;		 +		} +		else +		{ +			//nothing +			g_iBlkStart = 0; +			g_iBlkLength = lLen; +			g_iBlkEnd = g_iBlkStart + g_iBlkLength - 1;		 +		} +	} + +	if( ( g_iBlkStart < 0 ) || ( g_iBlkStart >= lLen ) ) +	{ +		fprintf( stderr, "Invalid start ptr!\n" ); +		close( hIn ); +		return -1; +	} + +	if( ( g_iBlkEnd < 0 ) || ( g_iBlkEnd >= lLen ) || ( g_iBlkEnd < g_iBlkStart ) ) +	{ +		fprintf( stderr, "Invalid end ptr!\n" ); +		close( hIn ); +		return -1; +	} + +	int iBlkStartM = g_iBlkStart; +	int iBlkEndM = g_iBlkEnd; + +	if( g_bUseBase ) +	{ +		iBlkStartM = g_iBlkBase; +		iBlkEndM = g_iBlkBase + g_iBlkLength - 1; +	} + +	if ( ( ( iBlkEndM >= 0x10000 ) || ( iBlkStartM >= 0x10000 ) ) && g_bOutputIsAtari ) +	{ +		fprintf( stderr, "End goes past end of RAM in real Atari!\n" ); +		close( hIn ); +		return -1; +	} + +	int hOut = open( szOutfile, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, 0666 ); + +	if ( hOut == -1 ) +	{ +		fprintf( stderr, "Can't open outfile '%s'!\n", szOutfile ); +		close( hIn ); +		return -1; +	} + +	#define BUFLEN 0x10000 + +	BYTE* pbtPtr = new BYTE [ BUFLEN ]; +	lseek( hIn, g_iBlkStart, SEEK_SET ); + +	if ( g_bOutputIsAtari ) +	{ +		WORD wStart = iBlkStartM; +		WORD wEnd = iBlkEndM; + +		BYTE btPom = 0xFF; +		write( hOut, &btPom, 1 ); +		write( hOut, &btPom, 1 ); + +		btPom = wStart & 0xFF; +		write( hOut, &btPom, 1 ); + +		btPom = wStart >> 8; +		write( hOut, &btPom, 1 ); + +		btPom = wEnd & 0xFF; +		write( hOut, &btPom, 1 ); + +		btPom = wEnd >> 8; +		write( hOut, &btPom, 1 ); +	} + +	int iLeft = g_iBlkLength; + +	while( iLeft ) +	{ +		int iReadNow = iLeft > BUFLEN ? BUFLEN : iLeft; +		read( hIn, pbtPtr, iReadNow ); +		write( hOut, pbtPtr, iReadNow ); +		iLeft -= iReadNow; +	} + +	close( hOut ); +	close( hIn ); + +	printf( "Done!\n" ); + +	return 0; +} + +int ToNum( char* szString, int iOffs ) +{ +	BOOL bSec = FALSE; + +	if( *szString == 's' ) +	{ +		bSec = TRUE; +		szString++; +	} + +	int iNum; +	sscanf( szString, "%X", &iNum ); + +	if( bSec ) +	{ +		if( iNum < iOffs ) +		{ +			printf( "Incorrect sector number %s\n", szString ); +			return -1; +		} + +		iNum -= iOffs; +		iNum *= 0x80; + +		if( iOffs ) +		{ +			//begin & end +			iNum += 0x10; +		} + +		//whole code assumes SD ATR file!!! +	} + +	return iNum; +} diff --git a/jindroush/aext/pub.def b/jindroush/aext/pub.def new file mode 100644 index 0000000..19e525e --- /dev/null +++ b/jindroush/aext/pub.def @@ -0,0 +1,31 @@ +//    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; either version 2 of the License, or +//    any later version. +// +//    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, write to the Free Software +//    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// + +#define PRG_NAME	"aext"	 +#define PRG_VERSION	"1.02" +#define PRG_COPYRIGHT	"1998-2002" +#define PRG_UNDERGPL	"1" +#define PRG_AUTHOR	"Jindrich Kubec <kubecj@asw.cz>" + +#define PRG_URL 	"http://www.asw.cz/~kubecj" + +#define PRG_DESC	"Atari file extractor." +#define PRG_USAGE	"[options] infile [outfile]" + +#define PRG_ARCH	"PC" +#define PRG_TOOLS	"PERL" + +#define PRG_SRCS	"!GENERATED!" +#define PRG_BINS	"rel/aext.exe" diff --git a/jindroush/aext/readme.txt b/jindroush/aext/readme.txt new file mode 100644 index 0000000..f73b129 --- /dev/null +++ b/jindroush/aext/readme.txt @@ -0,0 +1,76 @@ +AExt v1.02 (c) 1998-2002 Jindrich Kubec <kubecj@asw.cz> +Latest version can be found at http://www.asw.cz/~kubecj + +This program is provided 'as is', no warranty will be taken +for any damage caused by it or by any use of it. + +The whole package is placed under the GNU Public License, for further +information on redistribution see the included file "GPL.TXT". + + +Description: +------------ +Atari file extractor. +This is just simple utility for extracting binary block in binary/atari binary +block formats. + + +Usage: +------ +AExt [options] infile [outfile] + +If outfile is not specified, prg.axe is assumed. + +-s, -e, -n specify start, end or length parameters of block in hexadecimal +	numbers. + +-oa creates atari binary block (start, end, data). + +-base is used with -oa to create based binary block. (The number specifies  +	start address of block). + + +History: +-------- +Date, Author, Version +8/19/1999, kubecj, 0.10 +First version. + +10/10/1999, kubecj, 0.11 +New archive processing, version incremented to avoid version problems. + +10/10/1999, kubecj, 1.00 +First release. + +12/10/2001, kubecj, 1.01 +Large block processing. +-e 0 means end ptr now. + +1/23/2002, kubecj, 1.02 +Added useful single density extracting parameters. Now include 's' as first +character in a number, e.g. -s s06 means start from sixth sector. By definition +works only on ATR files with 0x80 long sectors. + + +To Do: +------ +Nothing. + + +Known Bugs: +----------- +None. + + +Compiling Tools: +---------------- +For scripts: Perl. +URL: http://www.perl.com + +For PC executables: DJGPP. +Sources were written/tested on GCC/Intel only. There should be only +minor problems to port it to different architectures/environments. +Makefile should need only minor changes. +URL: http://www.delorie.com + + diff --git a/jindroush/aext/switches.def b/jindroush/aext/switches.def new file mode 100644 index 0000000..1bcb33b --- /dev/null +++ b/jindroush/aext/switches.def @@ -0,0 +1,25 @@ +e, end +end +hexnum= bRet = SWFN_GETPATH( szEnd );g_bEndUsed = TRUE; += + +s, start +start +hexnum=bRet = SWFN_GETPATH( szStart );g_bStartUsed = TRUE; += + +n, length +length +hexnum=bRet = SWFN_GETPATH( szLength );g_bLenUsed = TRUE; += + +oa, atari +output is Atari block +=g_bOutputIsAtari = TRUE; += + +base +base +hexnum=bRet = SWFN_NUMH( &g_iBlkBase ); +=g_bUseBase = TRUE; += | 
