You are on page 1of 8

program reboo160

* Copyright 2021 Kevin G. Rhoads. All Rights Reserved.


*
* based on xxx2hex
* Copyright 2005, 1999, Kevin G. Rhoads. All Rights Reserved.
*
* Permission for use and distribution in accordance with
* GNU General Public License 2.0 or later is granted.
*
* Permission for use and distribution in accordance with
* CC-BY-SA License any verison is granted.
*
* Version 1.01 Dec 8, 2021 -- adding error checking
* Version 1.00 Dec 7, 2021 -- works, tested on ONE image, no error checking,
limited user notification
*
* Source is F77 with MS/DVF extensions.
*
integer*1 asector(512)
character*2 crlf

character*127 arg,outfile,outfile2,outfile3
character drive*1,path*64,file*8,ext*3
integer*4 nargs,argstat,offset,k,l,sector
integer*2 curarg,i,j,s2b1,s3b1
logical*2 cmdline,endflag,goodimages
external nargs,getarg,fnovr

* IBM DOS 1.0 SS 8 Sector/track boot sector w/ added BPB


integer*1 ibm10(512)
common /ibm10c/ibm10

* IBM DOS 1.1 SS 8 Sector/track boot sector w/ added BPB


integer*1 ibm11(512)
common /ibm11c/ibm11

* IBM JDOS 1.1 SS 8 Sector/track boot sector (includes BPB)


integer*1 jdos(512)
common /jdosc/jdos

*---------

print *,' '


print *,' Version 1.01 December 8, 2021'
print *,' Version 1.00 December 7, 2021'
print *,' '
print *,'Copyright 2021, Kevin G. Rhoads. All Rights Reserved. '
print *,' '
print *,'Permission for use and distribution in accordance with '
print *,'GNU General Public License 2.0 or later is granted. '
print *,' '
print *,'Permission for use and distribution in accordance with'
print *,'CC-BY-SA License any verison is granted. '
print *,' '
print *,' reads one or more 160k disk images '
print *,' outputs to new disk images with updated boot sector'
print *,' boot sectors all have a Single-Side 8 Sector BPB '
print *,' '
print *,' .1MG is with DOS 1.0 SS, 8 sector bootsector w/ BPB '
print *,' .2MG is with DOS 1.1 SS, 8 sector bootsector w/ BPB '
print *,' .JMG is with JDOS 1.1 SS, 8 sector boot (has BPB)'
print *,' '

curarg = 1
cmdline = (nargs().gt.1)

* change crlf to match system definition, what follows is right


* for MS-DOS
crlf = char(13)//char(10)

*-------------------------------MAIN LOOP over file names


9000 continue

if (cmdline) then
call getarg(curarg,arg,argstat)
* print *,' arg is ',arg
arg = arg(1:len_trim(arg))
* print *,' Trimmed arg is ',arg
curarg = curarg + 1
if ( curarg.gt.nargs() ) stop ' Bye - out of arguments'
else
stop ' Bye '
endif

*----

offset = 0
sector = 0
open (unit=10,file=arg,status='old',form='binary',err=9000)
drive = ' '
path = ' '
file = ' '
ext = '1MG'
call fnovr(arg,outfile2,drive,path,file,ext)
open (unit=11,file=outfile2,status='unknown',form='binary',
& err=9003)
*
* .1MG is disk image with DOS 1.0 single-side, 8 sector bootsector w/ BPB (Bios
Parameter Block)
*
drive = ' '
path = ' '
file = ' '
ext = 'JMG'
call fnovr(arg,outfile,drive,path,file,ext)
open (unit=12,file=outfile,status='unknown',form='binary',
& err=9003)
*
* .JMG is disk image with JDOS 1.1 single-side, 8 sector bootsector w/ BPB
(Bios Parameter Block)
*
drive = ' '
path = ' '
file = ' '
ext = '2MG'
call fnovr(arg,outfile3,drive,path,file,ext)
open (unit=13,file=outfile3,status='unknown',form='binary',
& err=9003)
*
* .2MG is disk image with DOS 1.1 single-side, 8 sector bootsector w/ BPB (Bios
Parameter Block)
*

print *,'-------------------------------------------------------'
* print *,'Doing file ',arg(1:len_trim(arg))
print *,'Doing file ',arg
print *,'Writing file DOS10 bootsector ',outfile
print *,'Writing file JDOS bootsector ',outfile2
print *,'Writing file DOS11 bootsector ',outfile3
write (*,*) ' '
goodimages = .true.
last = 0
s2b1 = 0
s3b1 = 0
*
* Use following for DVF command line build initial alignment,
* that there are other problems with builb via FL32 compatibility
* driver
* write (*,'(a1\)') ' '

*-------------------------------MINOR LOOP over sectors in file


9002 continue

* read a sector, detect end of file


j = 0
endflag = .true.
do 11 i = 1,512
asector(i) = 0
11 continue
do 1 i = 1,512
read (10,end=9001,err=9001) asector(i)
j = i
1 continue
endflag = .false.
sector = sector + 1
9001 continue
* if (j.eq.0.and.endflag) goto 9003
if (j.eq.0.and.endflag) then
last = sector
goodimages = goodimages .and. (last.eq.320)
goto 9003
endif

* if read returned bytes, process them


if (j.gt.0) then
if (sector.eq.1) then
* first sector is replaced on both output files
write (11,err=9013) (ibm10(i),i=1,512)
write (12,err=9013) (jdos(i),i=1,512)
write (13,err=9013) (ibm11(i),i=1,512)
else
* all other sectors copied intact
write (11,err=9013) (asector(i),i=1,512)
write (12,err=9013) (asector(i),i=1,512)
write (13,err=9013) (asector(i),i=1,512)
if (sector.eq.2) then
s2b1 = 255 .and. asector(1)
goodimages = goodimages .and. (s2b1.eq.254)
elseif (sector.eq.3) then
s3b1 = 255 .and. asector(1)
goodimages = goodimages .and. (s3b1.eq.254)
endif
endif
endif

offset = offset + j
k = offset/512
l = offset - k*512
* if (l.eq.0) write (11,7002) crlf
if (.not. endflag) goto 9002

*----
9013 continue
close (unit=11,status='delete',err=9014)
* close (unit=11,status='keep',err=9014)
9014 continue
close (unit=12,status='delete',err=9015)
* close (unit=12,status='keep',err=9015)
9015 continue
close (unit=13,status='delete',err=9006)
goto 9005
9003 continue
if (.not.goodimages) then
print *,' output images may not be good '
print *,' first byte of sector 2 should be 254; is ',s2b1
print *,' first byte of sector 3 should be 254; is ',s3b1
print *,' last sector SHOULD be 320; actually is ',last
endif
close (unit=11,status='keep',err=9004)
9004 continue
close (unit=12,status='keep',err=9005)
9005 continue
close (unit=13,status='keep',err=9006)
9006 continue
close (unit=10,status='keep',err=9007)
9007 continue

if ( curarg.lt.nargs() ) goto 9000

stop ' Bye'

end
*----------------------------------------------------------------------
block data jdosbd

integer*1 jdos(512)
common /jdosc/jdos

data (jdos(i),i=1,64)
1/233,044,000,106,100,111,115,049,046,055,055,000,002,001,001,000, |
~,~jdos1 .77~~~~~
2 002,064,000,064,001,254,001,000,008,000,001,000,000,000,040,099, |~@~@~~~~
~~~~~~(c
3 041,049,057,056,050,032,084,097,108,108,032,084,114,101,101,250, |)1982 Ta
ll Tree~
4 184,001,224,142,192,051,192,142,216,142,208,188,000,124,199,006/ |~~~~~3~~
~~~~~|~~
data (jdos(i),i=65,128)
1/120,000,171,125,163,122,000,191,000,016,190,182,125,185,016,000, |x~~}~z~~
~~~~}~~~
2 087,243,164,095,209,231,117,242,255,054,008,000,255,054,010,000, |W~~_~~u~
~6~~~6~~
3 199,006,008,000,255,125,163,010,000,187,105,001,142,192,182,001, |~~~~~}~~
~~i~~~~~
4 177,004,232,002,001,117,011,138,198,210,224,254,198,136,007,067/ |~~~~~u~~
~~~~~~~C
data (jdos(i),i=129,192)
1/235,240,172,139,248,050,228,185,004,000,210,200,211,192,010,198, |~~~~~2~~
~~~~~~~~
2 134,197,005,000,224,142,192,149,038,136,046,000,000,232,215,000, |~~~~~~~~
&~.~~~~~
3 138,198,117,019,058,054,238,125,116,006,210,224,254,198,235,001, |~~u~:6~}
t~~~~~~~
4 151,136,007,067,160,238,125,012,032,142,197,038,162,000,000,129/ |~~~C~~}~
~~&~~~~
data (jdos(i),i=193,256)
1/254,230,125,114,189,143,006,010,000,143,006,008,000,176,032,230, |~~}r~~~~
~~~~~~ ~
2 032,161,237,125,050,228,147,045,104,001,177,006,010,219,117,006, | ~~}2~~-
h~~~~~u~
3 139,030,019,004,211,235,042,195,121,004,002,216,050,192,136,030, |~~~~~~*~
y~~~2~~~
4 237,125,211,227,137,030,019,004,134,196,209,232,163,098,001,116/ |~}~~~~~~
~~~~~b~t
data (jdos(i),i=257,320)
1/020,211,227,142,195,191,000,002,184,248,255,171,176,255,170,064, |~~~~~~~~
~~~~~~~@
2 185,253,001,243,170,051,201,142,193,191,070,001,177,025,243,164, |~~~~~3~~
~~F~~~~~
3 177,096,142,193,051,219,051,210,184,001,002,177,008,182,000,190, |~`~~3~3~
~~~~~~~~
4 000,002,205,019,114,062,003,222,184,008,002,190,000,016,177,001/ |~~~~r>~~
~~~~~~~~
data (jdos(i),i=321,384)
1/050,241,050,054,231,125,034,241,117,002,254,197,129,251,000,034, |2~26~}"~
u~~~~~~"
2 126,224,161,098,001,011,192,116,022,038,163,094,008,179,001,061, |~~~b~~~t
~&~^~~~=
3 084,001,114,006,002,219,209,232,235,245,038,136,030,088,008,234, |T~r~~~~~
~~&~~X~~
4 000,000,096,000,233,137,254,082,083,030,051,192,205,019,114,244/ |~~`~~~~R
S~3~~~r~
data (jdos(i),i=385,448)
1/211,226,142,218,184,026,229,051,219,137,007,057,007,117,016,247, |~~~~~~~3
~~~9~u~~
2 208,137,007,057,007,117,008,067,067,117,238,228,098,036,064,176, |~~~9~u~C
Cu~~b$@~
3 109,230,097,176,077,230,097,031,091,090,195,223,002,037,002,008, |m~a~M~a~
[Z~~~%~~
4 042,255,080,246,000,004,032,033,034,035,036,037,038,039,040,041/ |*~P~~~ !
"#$%&'()
data (jdos(i),i=449,512)
1/042,043,044,045,046,047,200,008,136,088,072,152,216,024,196,004, |*+,-./~~
~XH~~~~~
2 132,084,068,148,212,020,194,002,130,082,066,146,210,018,193,001, |~TD~~~~~
~RB~~~~~
3 129,081,065,145,209,017,000,001,002,000,000,000,000,003,009,003, |~QA~~~~~
~~~~~~~~
4 146,156,086,086,086,086,000,000,000,000,000,000,000,000,023,207/ |~~VVVV~~
~~~~~~~~

end
*----------------------------------------------------------------------
block data ibm10bd

integer*1 ibm10(512)
common /ibm10c/ibm10

data (ibm10(i),i=1,64)
&/235,047,020,000,000,000,096,000,032,055,045,000,002,001,001,000, |~/~~~~`~
7-~~~~~
& 002,064,000,064,001,254,001,000,008,000,001,000,000,000,000,000, |~@~@~~~~
~~~~~~~~
& 000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000, |~~~~~~~~
~~~~~~~~
& 000,250,140,200,142,216,186,000,000,142,210,188,000,124,251,161/ |~~~~~~~~
~~~~~|~~
data (ibm10(i),i=65,128)
&/006,124,142,216,142,192,186,000,000,139,194,205,019,114,065,232, |~|~~~~~~
~~~~~rA~
& 088,000,114,251,046,139,014,002,124,081,187,000,000,051,210,185, |X~r~.~~~
|Q~~~3~~
& 008,000,190,001,000,086,176,001,180,002,205,019,114,034,094,088, |~~~~~V~~
~~~~r"^X
& 232,231,000,043,198,116,020,254,197,177,001,190,008,000,059,198/ |~~~+~t~~
~~~~~~;~
data (ibm10(i),i=129,192)
&/115,004,139,240,235,001,150,086,080,235,221,046,255,046,004,124, |s~~~~~~V
P~~.~.~|
& 190,068,125,184,066,125,080,050,255,172,036,127,116,011,086,180, |~D}~B}P2
~~$t~V~
& 014,187,007,000,205,016,094,235,240,195,187,000,000,185,004,000, |~~~~~~^~
~~~~~~~~
& 184,001,002,205,019,030,114,052,140,200,142,216,191,000,000,185/ |~~~~~~r4
~~~~~~~~
data (ibm10(i),i=193,256)
&/011,000,038,128,013,032,038,128,141,032,000,032,071,226,243,191, |~~&~~ &~
~ ~ G~~~
& 000,000,190,118,125,185,011,000,252,243,166,117,015,191,032,000, |~~~v}~~~
~~~u~~ ~
& 190,130,125,185,011,000,243,166,117,002,031,195,190,249,124,232, |~~}~~~~~
u~~~~~|~
& 165,255,180,000,205,022,031,249,195,013,010,078,111,110,045,083/ |~~~~~~~~
~~~Non-S
data (ibm10(i),i=257,320)
&/121,115,116,101,109,032,100,105,115,107,032,111,114,032,100,105, |ystem di
sk or di
& 115,107,032,101,114,114,111,242,013,010,082,101,112,108,097,099, |sk erro~
~~Replac
& 101,032,097,110,100,032,115,116,114,105,107,101,032,097,110,121, |e and st
rike any
& 032,107,101,121,032,119,104,101,110,032,114,101,097,100,249,013/ | key whe
n read~~
data (ibm10(i),i=321,384)
&/010,000,205,024,013,010,068,105,115,107,032,066,111,111,116,032, |~~~~~~Di
sk Boot
& 102,097,105,108,117,114,229,013,010,000,080,082,139,198,191,000, |failur~~
~~PR~~~~
& 002,247,231,003,216,090,088,195,082,111,098,101,114,116,032,079, |~~~~~ZX~
Robert O
& 039,082,101,097,114,032,105,098,109,098,105,111,032,032,099,111/ |'Rear ib
mbio co
data (ibm10(i),i=385,448)
&/109,176,105,098,109,100,111,115,032,032,099,111,109,176,201,000, |m~ibmdos
com~~~
& 000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000, |~~~~~~~~
~~~~~~~~
& 000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000, |~~~~~~~~
~~~~~~~~
& 000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000/ |~~~~~~~~
~~~~~~~~
data (ibm10(i),i=449,512)
&/000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000, |~~~~~~~~
~~~~~~~~
& 000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000, |~~~~~~~~
~~~~~~~~
& 000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000, |~~~~~~~~
~~~~~~~~
& 000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000/ |~~~~~~~~
~~~~~~~~

end
*----------------------------------------------------------------------
block data ibm11bd

integer*1 ibm11(512)
common /ibm11c/ibm11

data (ibm11(i),i=1,64)
&/235,039,144,008,000,020,000,000,000,000,000,000,002,001,001,000, |~'~~~~~~
~~~~~~~~
& 002,064,000,064,001,254,001,000,008,000,001,000,000,000,000,000, |~@~@~~~~
~~~~~~~~
& 000,000,000,000,000,000,000,205,025,250,140,200,142,216,051,210, |~~~~~~~~
~~~~~~3~
& 142,210,188,000,124,251,184,096,000,142,216,142,192,051,210,139/ |~~~~|~~`
~~~~~3~~
data (ibm11(i),i=65,128)
&/194,205,019,114,105,232,133,000,114,221,046,131,062,003,124,008, |~~~ri~~~
r~.~>~|~
& 116,006,046,198,006,100,125,002,187,000,000,046,139,014,003,124, |t~.~~d}~
~~~.~~~|
& 081,176,009,042,193,180,000,139,240,086,051,210,051,192,138,197, |Q~~*~~~~
~V3~3~~~
& 046,246,054,100,125,138,232,138,244,139,198,180,002,205,019,114/ |.~6d}~~~
~~~~~~~r
data (ibm11(i),i=129,192)
&/045,094,089,046,041,054,005,124,116,031,139,198,046,247,038,101, |-^Y.)6~|
t~~~.~&e
& 125,003,216,254,197,177,001,081,190,008,000,046,059,054,005,124, |}~~~~~~Q
~~~.;6~|
& 124,005,046,139,054,005,124,235,192,234,000,000,096,000,190,103, ||~.~6~|~
~~~~`~~g
& 125,232,002,000,235,254,050,255,046,172,036,127,116,011,086,180/
|}~~~~~2~ .~$t~V~
data (ibm11(i),i=193,256)
&/014,187,007,000,205,016,094,235,239,195,233,051,255,187,000,000, |~~~~~~^~
~~~3~~~~
& 185,004,000,184,001,002,205,019,030,114,051,140,200,142,216,191, |~~~~~~~~
~r3~~~~~
& 000,000,185,011,000,038,128,013,032,038,128,077,032,032,071,226, |~~~~~&~~
&~M G~
& 244,191,000,000,190,139,125,185,011,000,252,243,166,117,015,191/ |~~~~~~}~
~~~~~u~~
data (ibm11(i),i=257,320)
&/032,000,190,151,125,185,011,000,243,166,117,002,031,195,190,027, | ~~~}~~~
~~u~~~~~
& 125,232,162,255,180,000,205,022,031,249,195,013,010,078,111,110, |}~~~~~~~
~~~~~Non
& 045,083,121,115,116,101,109,032,100,105,115,107,032,111,114,032, |-System
disk or
& 100,105,115,107,032,101,114,114,111,114,013,010,082,101,112,108/ |disk err
or~~Repl
data (ibm11(i),i=321,384)
&/097,099,101,032,097,110,100,032,115,116,114,105,107,101,032,097, |ace and
strike a
& 110,121,032,107,101,121,032,119,104,101,110,032,114,101,097,100, |ny key w
hen read
& 121,013,010,000,001,000,002,013,010,068,105,115,107,032,066,111, |y~~~~~~~
~Disk Bo
& 111,116,032,102,097,105,108,117,114,101,013,010,000,077,105,099/ |ot failu
re~~~Mic
data (ibm11(i),i=385,448)
&/114,111,115,111,102,116,044,073,110,099,032,105,098,109,098,105, |rosoft,I
nc ibmbi
& 111,032,032,099,111,109,048,105,098,109,100,111,115,032,032,099, |o com0i
bmdos c
& 111,109,048,005,198,006,119,047,255,131,126,252,000,117,011,128, |om0~~~w/
~~~~~u~~
& 126,247,059,117,005,198,006,118,047,255,137,236,093,202,004,000/ |
~~;u~~~v /~~~]~~~
data (ibm11(i),i=449,512)
&/000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000, |~~~~~~~~
~~~~~~~~
& 000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000, |~~~~~~~~
~~~~~~~~
& 000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000, |~~~~~~~~
~~~~~~~~
& 000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000/ |~~~~~~~~
~~~~~~~~

end

You might also like