koreth@ssyx.ucsc.edu (Steven Grimm) (03/19/89)
Submitted-by: math.waterloo.edu!orchid!achowe (Anthony C. Howe?) Posting-number: Volume 2, Issue 31 Archive-name: cpboot #!/bin/sh # shar: Shell Archiver (v1.22) # # Run the following text with /bin/sh to create: # README # CPBOOT.C # sed 's/^X//' << 'SHAR_EOF' > README && Xreadme 881015 X X XCPBOOT.TOS X========== X Xobjective X--------- XThis program is designed to copy an executable boot sector from a disk of Xone type of format to that of an other. X Xwhy X--- XThe reason for this is that I wanted to make copies of TOS 1.4 Developer's XRelease and place them on double sided disks. Well TOS 1.4 comes on a single Xsided disk and Atari did not provided a program to modify a boot sector with Xthe TOS loader. The only possible way to make copies was with GEM's disk to Xdisk copy, which ment that I could only make single sided copies. I then tried Xusing MEMFIL14.ACC to read the boot sector from the TOS disk to that of a Xdouble sided disk. ** Smooth move Ex-lax **!! I had forgotten that certain Xbits of info like number of tracks and sides, and the serial number, would be Xdifferent on the two disks. So I ended up trashing a disk and all the info on Xit. X Xwhat X---- XBasically all CPBOOT does is to read both the source and target boot sectors Xfrom respective disks, copies from the source the branch code, filler, and Xthe boot sector code to the target sector. Then a call to Protobt() is made Xin order to adjust the checksum for an executable boot sector, which is then Xwritten back to the target disk. See CPBOOT.C. X Xhow X--- XJust execute the program CPBOOT.TOS and follow the prompts. All work is done Xon A drive so disk swapping will be necessary. X XDisclaimer X---------- XI do not take responsibilty for damage caused by careless use of this program. XMake sure that you follow the prompts, write tabs are up on disks you want to Xprotect and that you have backups of everything. This program was a one day Xquick utility. You can modify the source for more checks like: does the target Xalready have a boot sector, have the disks actually been swapped, prompts Xto select A: or B:, etc. X XEnvironment X----------- XMega ST2 with colour screen. XBDT's GEMCSH & MAKE XOld Acylon C XALN 88/08/12 Linker XMADMAC v1.00 XACHAPP.S and ACHSLIB.S (Anthony's assembler library v1.02) X X XHope this utility comes in handy. X X- Ant SHAR_EOF chmod 0600 README || echo "restore of README fails" sed 's/^X//' << 'SHAR_EOF' > CPBOOT.C && X/* X cpboot.c Copy Boot Sector X X 881014 ACH X X*/ X X#include <osbind.h> X Xextern unsigned strlen(); X X#define SECTOR 512 X#define DELAY_FACTOR 3276 X#define SCREEN_WIDTH 80 X#define SCREEN_LENGTH 25 X#define CURSOR_UP "\033A" X#define CURSOR_DOWN "\033B" X#define CURSOR_RIGHT "\033C" X#define CURSOR_LEFT "\033D" X#define CURSOR_HOME "\033H" X#define CURSOR_POSITION "\033Y" X#define CURSOR_OFFSET 32 X#define REVERSE_INDEX "\033I" X#define CLEAR_SCREEN "\033E" X#define CLEAR_EOP "\033J" X#define CLEAR_EOL "\033K" X#define LINE_INSERT "\033L" X#define LINE_DELETE "\033M" X X Xtypedef int void; X Xint ScreenWidth = SCREEN_WIDTH -1; Xint ScreenLength = SCREEN_LENGTH -1; Xchar source[ SECTOR ]; Xchar target[ SECTOR ]; X X Xvoid RowCol( row, col ) X int row; X int col; X{ X Cconws( CURSOR_POSITION ); X Cconout( row + CURSOR_OFFSET ); X Cconout( col + CURSOR_OFFSET ); X} /* RowCol */ X X Xvoid RowClear( row ) X int row; X{ X RowCol( row, 0 ); X Cconws( CLEAR_EOL ); X} /* RowClear */ X X Xvoid Dclear() X{ X Cconws( CLEAR_SCREEN ); X} /* Dclear */ X X Xvoid Scenter( row, str ) X int row; X char* str; X{ X int x; X X x = strlen( str ); X RowClear( row ); X RowCol( row, ScreenWidth /2 - x /2 ); X Cconws( str ); X} /* Scenter */ X X Xvoid Wait() X{ X Scenter( ScreenLength, "[ press a key ]" ); X while( !Cconis() ); X Cconin(); X RowClear( ScreenLength ); X} /* Wait */ X X Xvoid Delay( x ) X int x; X{ X for( x *= DELAY_FACTOR; x; --x ); X} /* Delay */ X X Xvoid main() X{ X long serial; X short sides; X short tracks; X X Dclear(); X Scenter( 8, "Copy Boot Sector" ); X Scenter( 9, "================" ); X X Scenter( 12, "Insert SOURCE disk into A:." ); X Wait(); X X /* Read source sector. */ X Scenter( 12, "Reading source boot sector." ); X Floprd( source, 0L, 0, 1, 0, 0, 1 ); X X Scenter( 12, "Insert TARGET disk into A:." ); X Wait(); X X /* Read target sector. */ X Scenter( 12, "Reading target boot sector." ); X Floprd( target, 0L, 0, 1, 0, 0, 1 ); X X Scenter( 12, "Merging source sector with target sector." ); X Delay( 10 ); X X /* Copy branch and filler. */ X memmove( target, source, 8L ); X /* Copy boot code. */ X memmove( &target[ 0x1e ], &source[ 0x1e ], 0x200L -0x1eL ); X /* Prototype boot sector to readjust checksum. */ X Protobt( target, -1L, -1, 1 ); X X /* Update target boot sector. */ X Scenter( 12, "Writing updated target boot sector." ); X Flopwr( target, 0L, 0, 1, 0, 0, 1 ); X X Scenter( 12, "Done." ); X Wait(); X} /* main */ X X SHAR_EOF chmod 0600 CPBOOT.C || echo "restore of CPBOOT.C fails" exit 0