diff options
Diffstat (limited to 'jindroush/bas2boot')
| -rw-r--r-- | jindroush/bas2boot/Makefile | 59 | ||||
| -rw-r--r-- | jindroush/bas2boot/bas2boot.asm | 169 | ||||
| -rw-r--r-- | jindroush/bas2boot/bas2boot.boo | bin | 0 -> 256 bytes | |||
| -rw-r--r-- | jindroush/bas2boot/bas2boot.cpp | 286 | ||||
| -rw-r--r-- | jindroush/bas2boot/pub.def | 31 | ||||
| -rw-r--r-- | jindroush/bas2boot/readme.txt | 72 | ||||
| -rw-r--r-- | jindroush/bas2boot/switches.def | 32 | 
7 files changed, 649 insertions, 0 deletions
| diff --git a/jindroush/bas2boot/Makefile b/jindroush/bas2boot/Makefile new file mode 100644 index 0000000..9c3a3de --- /dev/null +++ b/jindroush/bas2boot/Makefile @@ -0,0 +1,59 @@ +#===================================================================== +PRGNAME		= bas2boot + +all: $(PRGNAME) + +release: +	@$(MAKE) $(PRGNAME) CFLAGS="-c -O2 -Wall -D__CDISK_SAVE__ -D__CDISK_NOLOAD__" LDFLAGS="" +	@echo RELEASE: Compiled. + +rel_strip: +	@strip $(PRGNAME).exe + +rel_inst: +	@copy $(PRGNAME).exe $(ATAROOT)\\bin +	@copy bas2boot.boo $(ATAROOT)\\bin +	@echo RELEASE: Installed. + +debug: +	@$(MAKE) $(PRGNAME) CFLAGS="-c -g -Wall -D_DEBUG -D__CDISK_SAVE__ -D__CDISK_NOLOAD__" LDFLAGS="-g" +	@echo DEBUG: Compiled. + +clean: +	rm -f *.o +	rm -f $(PRGNAME) +	rm -f $(PRGNAME).exe +	rm -f switches.cpp +	rm -rf rel +	@echo DEBUG: Cleaned. + +#===================================================================== +INCLUDES =	makefile	\ +		switches.def	\ +		pub.def + + +OBJECTS =	bas2boot.o	\ + +#===================================================================== +CC		= g++ +LD		= g++ +LDLIBS		= -lm -L../lib -ljindroush +CPPFLAGS=-I../include -D__CDISK_SAVE__ $(COPT) +COPT=-O2 + +#===================================================================== + +$(PRGNAME): $(OBJECTS) bas2boot.boo +	$(LD) $(LDFLAGS) $(OBJECTS) $(LDLIBS) -o $(PRGNAME) + +bas2boot.o: bas2boot.cpp switches.cpp + +%.o: %.cpp $(INCLUDES) +	$(CC) $(CPPFLAGS) -c $< -o $@ + +switches.cpp: switches.def ../switches.pl +	perl ../switches.pl $< $@ + +bas2boot.boo: bas2boot.asm +	dasm $< -o$@ -f3 diff --git a/jindroush/bas2boot/bas2boot.asm b/jindroush/bas2boot/bas2boot.asm new file mode 100644 index 0000000..af7752a --- /dev/null +++ b/jindroush/bas2boot/bas2boot.asm @@ -0,0 +1,169 @@ +;Boot stub for loading BASIC programs from short ATR files. +;(c) 1998-1999 Jindrich Kubec <kubecj@asw.cz> + +; 20070524 bkw: modified to assemble with dasm + processor 6502 + +SIOV		= $E459 + +DOSVEC		= $0A +RAMTOP		= $6A +LOMEM		= $80 +BOOT		= $09 +BASICF		= $03F8 +PORTB		= $D301 + +EOPEN		= $EF94 + +BAS_CONT	= $A97A +BAS_EXEC	= $B755 + +LOADER_START	= $0700 +LOADER_END	= $0800 + +BASMEMSTART	= $0700 + +BASPTRSLEN	= $0E +BASPTRSSTART	= LOADER_END - BASPTRSLEN + +		org LOADER_START +		 +BOOTST:	        .byte 0 +		.byte (ENDBOOT-BOOTST+127)/128 +		.WORD *-2 +		.WORD MAIN_BEG + +		CLC +RTS_INSTR:	RTS + +		;used for extractor +ORI_LEN:	.WORD 0 + +MAIN_BEG: +		LDX	#<header +		LDY	#>header +		JSR	$C642 + +		LDX	#<padding +		LDY	#>padding +		JSR	$C642 + +		;copy pointers to correct area, add $700 +		LDX	#BASPTRSLEN - 1 +SETVECT:	CLC +		LDA	BASPTRSSTART,X +		ADC	#>BASMEMSTART +		STA	LOMEM,X +		DEX +		LDA	BASPTRSSTART,X +		STA	LOMEM,X +		DEX +		BPL	SETVECT + +		LDA	#$31	;D +		STA	$300 +		LDA	#$01	;1 +		STA	$301 +		LDA	#$52	;read +		STA	$302 +		LDA	#$80	;$80 bytes +		STA	$308 +		LDA	#$00 +		STA	$309 +		STA	$30B + +		LDA	$82	;buffer address +		STA	$304 +		LDA	$83 +		STA	$305 + +		;starting sector +		LDA	# ( (ENDBOOT-BOOTST+127)/128 ) +1 +		STA	$30A +SIO_CONT: +		LDA	#$40	;read +		STA	$303 + +		JSR	SIOV +		LDA	$303 +		CMP	#$01 +		BEQ	NOERR +		JSR	$C63E +AGAIN:		JMP	AGAIN	;dynamic halt + +		;move buffer pointer +NOERR:		 + +		;LDA	$304 +		;CLC +		;ADC	$308 +		;STA	$304 +		;LDA	$305 +		;ADC	$309 +		;STA	$305 + +		;this does the same as the above, but is shorter +		CLC +		LDX	#$FE +LP0:		LDA	$304 - $FE,X +		ADC	$308 - $FE,X +		STA	$304 - $FE,X +		INX +		BNE	LP0 + +		;increment sector number +		INC	$30A +		BNE	NX1 +		INC	$30B +NX1: +		;decrement number of sectors to load +		LDA	SECTORS +		BNE	NX2 +		DEC	SECTORS+1 +		BMI	BAS_RUN +NX2:		DEC	SECTORS +		JMP	SIO_CONT + +BAS_RUN:	LDX	#$FF +		TXS + +		LDA	#$0A +		STA	$C9 +		LDA	#$00 +		STA	BOOT +		STA	BASICF + +		;turn on basic +		LDA	#$FD +		STA	PORTB + +		;set stack +		LDA	#>BAS_CONT +		PHA +		LDA	#<BAS_CONT - 1 +		PHA + +	    	LDA	#>BAS_EXEC +		PHA +		LDA	#<BAS_EXEC - 1 +		PHA + +		LDA	RAMTOP +		BPL	STORE_MEMT +		LDA	#$A0 +STORE_MEMT:	STA	RAMTOP + +		JMP	EOPEN + +header:		.byte "BAS2BOOT (c)1999 Jindroush" +		.byte $1D +		.byte $9B +padding:	.ds BASPTRSSTART - padding - 2 - 1, " " +		.byte $9B +SECTORS:	.WORD 0 +BASPTRSSTART2:	.ds BASPTRSLEN + +ENDBOOT: + +		.END + diff --git a/jindroush/bas2boot/bas2boot.boo b/jindroush/bas2boot/bas2boot.booBinary files differ new file mode 100644 index 0000000..37a6692 --- /dev/null +++ b/jindroush/bas2boot/bas2boot.boo diff --git a/jindroush/bas2boot/bas2boot.cpp b/jindroush/bas2boot/bas2boot.cpp new file mode 100644 index 0000000..bb8f2f8 --- /dev/null +++ b/jindroush/bas2boot/bas2boot.cpp @@ -0,0 +1,286 @@ +//    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" +#include "autil.h" +#include "adsk.h" + +DISK_TYPE g_dtypeOut = DISK_ATR; +BOOL g_bClassic = FALSE; +#define MAX_STRING 256 +char g_szMessage[ MAX_STRING ] = ""; + +typedef struct +{ +	WORD w1; +	WORD w2; +	WORD w3; +	WORD w4; +	WORD w5; +	WORD w6; +	WORD w7; +} BASHEAD; + +#define BAS_HEAD_SIZE 0x0E + +#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 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_STRING ]; + +	//setting the message +	char szMessage[ MAX_STRING ]; +	strcpy( szMessage, g_szMessage ); + +	//if not present, set to 'Loading prgname' +	if ( ! *szMessage ) +	{ +		strcpy( szMessage, "Loading " ); +		strcat( szMessage, szInFile ); +	} + +	//and pad it with spaces +	memset( szMessage + strlen( szMessage), 0x20, MAX_STRING - strlen( szMessage ) ); +	szMessage[ MAX_STRING - 1 ] = '\0'; + +	//get output filename +	if ( argc >= 3 ) +	{ +		strcpy( szOutFile, argv[ 2 ] ); +	} +	else +	{ +		GuessBestFnameFromPC( szOutFile, szInFile, GetDiskTypeExt( g_dtypeOut ) ); +	} + +	ADisk* pDisk = NULL; +	switch( g_dtypeOut ) +	{ +		case DISK_ATR: +			pDisk = new CAtr(); +			break; + +		case DISK_XFD: +			pDisk = new CXfd(); +			break; + +		case DISK_SCP: +			pDisk = new CScp(); +			break; + +		case DISK_DCM: +			pDisk = new CDcm(); +			break; + +		case DISK_DI: +			pDisk = new CDi(); +			break; + +		default: +			break; +	} + +	if ( !pDisk ) +	{ +		printf( "Can't create such image!\n" ); +		return FALSE; +	} + +	//reads boot stub +	char szBootName[ MAX_STRING ]; +	strcpy( szBootName, argv[ 0 ] ); +	char* szWhere = strrchr( szBootName, '/' ); + +	if ( szWhere ) +		szWhere++; +	else +		szWhere = szBootName; +		 +	strcpy( szWhere, "bas2boot.boo" ); + +	CFile cf; + +	if ( !cf.Open( szBootName ) ) +	{ +		printf( "Can't open boot image: %s\n", szBootName ); +		return 1; +	} + +	long lBootLen = cf.GetLength(); + +	if ( lBootLen % 0x80 ) +	{ +		printf( "Invalid boot image: %s\n", szBootName ); +		cf.Close(); +		return 1; +	} + +	BYTE* pbtBoot = new BYTE [ lBootLen ]; + +	cf.Read( pbtBoot, lBootLen ); + +	cf.Close(); + +	int iBootSectors = lBootLen / 0x80; + +	if ( pbtBoot[ 1 ] != iBootSectors ) +	{ +		printf( "Invalid boot image: %s\nSize mismatch.\n", szBootName ); +		cf.Close(); +		delete [] pbtBoot; +		return 1; +	} + +	//open basic file +	if ( !cf.Open( szInFile ) ) +	{ +		printf( "Can't open source file '%s'!\n", szInFile ); +		return 1; +	} + +	long lBasicLen = cf.GetLength(); + +	//set real length in header +	pbtBoot[ 8 ] = lBasicLen & 0xFF; +	pbtBoot[ 9 ] = lBasicLen >> 8; + +	lBasicLen -= BAS_HEAD_SIZE; + +	int iBasicSectors = ( lBasicLen + 0x7F ) / 0x80; + +	//load and relocate basic header +	BASHEAD head; +	head.w1 = cf.readLEw(); +	head.w2 = cf.readLEw() - head.w1; +	head.w3 = cf.readLEw() - head.w1; +	head.w4 = cf.readLEw() - head.w1; +	head.w5 = cf.readLEw() - head.w1; +	head.w6 = cf.readLEw() - head.w1; +	head.w7 = cf.readLEw() - head.w1; + +	BYTE* pbtHd = pbtBoot + lBootLen - BAS_HEAD_SIZE - 2; + +	*( pbtHd++ ) = ( iBasicSectors - 1 ) & 0xFF; +	*( pbtHd++ ) = ( iBasicSectors - 1 ) >>8; + +	*( pbtHd++ ) = head.w1 & 0xFF; +	*( pbtHd++ ) = head.w1 >> 8; + +	*( pbtHd++ ) = head.w2 & 0xFF; +	*( pbtHd++ ) = head.w2 >> 8; + +	*( pbtHd++ ) = head.w3 & 0xFF; +	*( pbtHd++ ) = head.w3 >> 8; + +	*( pbtHd++ ) = head.w4 & 0xFF; +	*( pbtHd++ ) = head.w4 >> 8; + +	*( pbtHd++ ) = head.w5 & 0xFF; +	*( pbtHd++ ) = head.w5 >> 8; + +	*( pbtHd++ ) = head.w6 & 0xFF; +	*( pbtHd++ ) = head.w6 >> 8; + +	*( pbtHd++ ) = head.w7 & 0xFF; +	*( pbtHd++ ) = head.w7 >> 8; + +	//find empty space at the end of boot +	BYTE* pbtString = pbtBoot + lBootLen - BAS_HEAD_SIZE - 2 - 2; +	BYTE* pbtStringEnd = pbtString; + +	while( *pbtString == 0x20 ) +		pbtString--; + +	pbtString++; + +	int iStringLen = pbtStringEnd - pbtString; + +	//put the message there +	memcpy( pbtString, szMessage, iStringLen + 1 ); + +	//read basic program +	BYTE* pbtBas = new BYTE [ iBasicSectors * 0x80 ]; +	memset( pbtBas, 0, iBasicSectors * 0x80 ); + +	cf.Read( pbtBas, lBasicLen ); + +	cf.Close(); + +	//format disk +	DISK_GEOMETRY dg; +	 +	if ( g_bClassic ) +		ForceClassicSize( iBasicSectors + iBootSectors, 0x80, &dg ); +	else +		GuessClassicSizes( iBasicSectors + iBootSectors, 0x80, &dg ); + +	if ( !pDisk->Format( &dg ) ) +	{ +		delete pDisk; +		delete[] pbtBoot; +		delete [] pbtBas; +		return 1; +	} + +	//write boot & body +	pDisk->WriteSectors( 1, pbtBoot, iBootSectors ); +	pDisk->WriteSectors( 1 + iBootSectors, pbtBas, iBasicSectors ); + +	//save it to disk +	if ( !pDisk->Save( szOutFile, FALSE ) ) +	{ +		printf( "Error! %s\n", pDisk->GetLastError() ); +		delete pDisk; +		delete [] pbtBoot; +		delete [] pbtBas; +		return 1; +	} + +	delete pDisk; + +	delete [] pbtBoot; +	delete [] pbtBas; + +	printf( "Written to %s (%s)\n", szOutFile, GetDiskTypeName( g_dtypeOut ) ); + +	return 0; +} + diff --git a/jindroush/bas2boot/pub.def b/jindroush/bas2boot/pub.def new file mode 100644 index 0000000..0993bbd --- /dev/null +++ b/jindroush/bas2boot/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	"bas2boot" +#define PRG_VERSION	"1.02" +#define PRG_COPYRIGHT	"1998-2001" +#define PRG_UNDERGPL	"1" +#define PRG_AUTHOR	"Jindrich Kubec <kubecj@asw.cz>" + +#define PRG_URL 	"http://www.asw.cz/~kubecj" + +#define PRG_DESC	"Converts Basic files to disk images." +#define PRG_USAGE	"[options] basicfile [diskfile]" + +#define PRG_ARCH	"PC ATARI" +#define PRG_TOOLS	"PERL" + +#define PRG_SRCS "!GENERATED!" +#define PRG_BINS "rel/bas2boot.exe rel/bas2boot.boo" diff --git a/jindroush/bas2boot/readme.txt b/jindroush/bas2boot/readme.txt new file mode 100644 index 0000000..010d3fc --- /dev/null +++ b/jindroush/bas2boot/readme.txt @@ -0,0 +1,72 @@ +Bas2Boot v1.02 (c) 1998-2001 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: +------------ +Converts Basic files to disk images. + + + +Usage: +------ +Bas2Boot [options] basicfile [diskfile] + +basicfile is source basic filename. +  +diskfile is output filename. If not specified it's guessed from input filename. + +-atr -xfd -scp -dcm -di specify output file format. Default is ATR. + +-long forces to use 'classic' disk sizes (SD,DD,ED) + +-message text -sets message displayed while loading program + + +History: +-------- +Date, Author, Version +4/5/1999, kubecj, 0.92 +First version + +6/14/1999, kubecj, 1.00 +First public version + +10/10/1999, kubecj, 1.01 +Only version number increment because of different archive processing. + +2/26/2001, kubecj, 1.02 +Added DI file format. + + +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 + +For Atari assembler sources: XA65 assembler. +URL: http://stockholm.ptloma.edu/cbm/xa/. + + diff --git a/jindroush/bas2boot/switches.def b/jindroush/bas2boot/switches.def new file mode 100644 index 0000000..417e1d4 --- /dev/null +++ b/jindroush/bas2boot/switches.def @@ -0,0 +1,32 @@ +atr, a +output is ATR +=g_dtypeOut = DISK_ATR; += + +xfd, x +output is XFD +=g_dtypeOut = DISK_XFD; += + +scp, s +output is SCP +=g_dtypeOut = DISK_SCP; +=g_bClassic = TRUE; += + +dcm, d +output is DCM +=g_dtypeOut = DISK_DCM; +=g_bClassic = TRUE; += + +long, classic +output has 'classic' size +=g_bClassic = TRUE; += + +message, mess, text +message to display while loading +text=SWFN_GETPATH( g_szMessage ); += + | 
