


                    opt a+,o+,w-



* ---------------------------------------------------------------------
* DoBB V2.00
* ---------------------------------------------------------------------
* ® Sunday, 30-04-95, 23:50:53
* ---------------------------------------------------------------------
* © Testaware, Volker Stepprath, Tegeler Str. 7, 40789 Monheim, Germany
* ---------------------------------------------------------------------
* Assembler: GenAm Macro Assembler Copyrigth © HiSoft 1985/8 - V2.11D
* Editor: AZ v1.50 - jm forgeas multitasking editor « Software Winery »
* ---------------------------------------------------------------------


* Library Offsets definieren
* --------------------------
_LVOOpen            equ      -30
_LVOClose           equ      -36
_LVORead            equ      -42
_LVOWrite           equ      -48
_LVOOutput          equ      -60
_LVOIoErr           equ     -132
_LVOAllocMem        equ     -198
_LVOFreeMem         equ     -210
_LVOFindTask        equ     -294
_LVOOpenLibrary     equ     -552
_LVOCloseLibrary    equ     -414
_LVOOpenDevice      equ     -444
_LVOCloseDevice     equ     -450
_LVODoIO            equ     -456


* Macros definieren
* -----------------
CALLEXE             MACRO
                    move.l  $4,a6
                    jsr     _LVO\1(a6)
                    ENDM

CALLDOS             MACRO
                    move.l  DosBase,a6
                    jsr     _LVO\1(a6)
                    ENDM



* Parameter retten & mit NULL Byte abschließen
* --------------------------------------------
                    move.l  a0,d6
                    move.l  d0,d7
                    move.b  #0,-1(a0,d0.l)



* Funktionen der dos.library bereitstellen
* ----------------------------------------
                    lea     Dosname,a1
                    moveq   #0,d0
                    CALLEXE OpenLibrary
                    move.l  d0,DosBase
                    beq     back



* Parametertest A
* ---------------
                    move.l  d6,a0
                    move.l  d7,d0
                    cmp.b   #"?",(a0)
                    beq     l?
                    cmp.l   #7,d0
                    ble     error
                    cmp.b   #58,3(a0)
                    bne     error
                    move.b  2(a0),d4
                    sub.b   #48,d4



* trackdisk.device bereitstellen
* ------------------------------
                    sub.l   a1,a1
                    CALLEXE FindTask
                    move.l  d0,DiskReply+$10
                    lea     DiskIO,a1
                    move.l  #DiskReply,14(a1)
                    clr.l   d1
                    move.l  d4,d0
                    lea     Device,a0
                    CALLEXE OpenDevice
                    tst.l   d0
                    bne     deverr



* Speicher reservieren
* --------------------
                    move.l  #1024,d0
                    move.l  #$10003,d1
                    CALLEXE AllocMem
                    move.l  d0,BootBuff



* Parameter starten
* -----------------
                    bsr     doparam



* Speicher freigeben
* ------------------
                    move.l  #1024,d0
                    move.l  BootBuff,a1
                    CALLEXE FreeMem



* Trackdisk-Device schließen
* --------------------------
                    lea     DiskIO,a1
                    move.w  #9,28(a1)
                    move.l  #0,36(a1)
                    CALLEXE DoIO
                    CALLEXE CloseDevice



* Programm beenden
* ----------------
                    bra     closelib



* Parametertest B
* ---------------
doparam             move.l  d6,a0
                    cmp.b   #"-",5(a0)
                    bne     usage
                    clr.l   d0
                    move.b  6(a0),d0
                    cmp.b   #"*",d0
                    beq     lX
                    cmp.b   #"1",d0
                    beq     l1
                    cmp.b   #"2",d0
                    beq     l2
                    cmp.b   #"3",d0
                    beq     l3
                    bclr    #5,d0
                    cmp.b   #"F",d0
                    beq     lF
                    cmp.b   #"R",d0
                    beq     lR
                    cmp.b   #"W",d0
                    beq     lW
                    cmp.b   #"Q",d0
                    beq     lQ
                    cmp.b   #"D",d0
                    beq     lD
                    cmp.b   #"C",d0
                    beq     lC
                    cmp.b   #"Z",d0
                    beq     lZ
                    cmp.b   #"U",d0
                    beq     lU
                    bra     usage



* BootBlock formatieren & in Datei schreiben ( -F )
* -------------------------------------------------
lF                  bsr     diskintest
                    tst.l   d0
                    bne     back
                    bsr     readboot
                    bsr     getname
                    move.l  #1006,d2
                    CALLDOS Open
                    move.l  d0,File
                    beq     filerr
                    move.l  BootBuff,a1
                    move.l  #1024,d1
                    clr.l   d3
                    clr.l   d4
floop               addq    #1,d4
                    tst.b   (a1)+
                    beq     efloop
                    move.l  d4,d3
efloop              dbra    d1,floop
                    move.l  File,d1
                    move.l  BootBuff,d2
                    CALLDOS Write
                    move.l  File,d1
                    CALLDOS Close
                    rts



* BootBlock in Datei schreiben ( -R )
* -----------------------------------
lR                  bsr     diskintest
                    tst.l   d0
                    bne     back
                    bsr     readboot
                    bsr     getname
                    move.l  #1006,d2
                    CALLDOS Open
                    move.l  d0,File
                    beq     filerr
                    move.l  File,d1
                    move.l  BootBuff,d2
                    move.l  #1024,d3
                    CALLDOS Write
                    move.l  File,d1
                    CALLDOS Close
                    rts



* Datei in BootBlock installieren ( -W )
* --------------------------------------
lW                  bsr     diskintest
                    tst.l   d0
                    bne     back
                    bsr     diskwptest
                    tst.l   d0
                    bne     back
                    bsr     getname
                    move.l  #1005,d2
                    CALLDOS Open
                    move.l  d0,File
                    beq     filerr
                    move.l  File,d1
                    move.l  BootBuff,d2
                    move.l  #1024,d3
                    CALLDOS Read
                    move.l  File,d1
                    CALLDOS Close
                    move.l  BootBuff,a4
                    move.l  #255,d0
                    bra     writeboot



* Standart OS 1.3 BootBlock ( -1 )
* --------------------------------
l1                  bsr     diskintest
                    tst.l   d0
                    bne     back
                    bsr     diskwptest
                    tst.l   d0
                    bne     back
                    lea     OS1Boot,a4
                    moveq   #12,d0
                    bra     writeboot



* Standart OS 2.0 BootBlock ( -2 )
* --------------------------------
l2                  bsr     diskintest
                    tst.l   d0
                    bne     back
                    bsr     diskwptest
                    tst.l   d0
                    bne     back
                    lea     OS2Boot,a4
                    moveq   #23,d0
                    bra     writeboot



* Standart OS 3.0 BootBlock ( -3 )
* --------------------------------
l3                  bsr     diskintest
                    tst.l   d0
                    bne     back
                    bsr     diskwptest
                    tst.l   d0
                    bne     back
                    lea     OS3Boot,a4
                    moveq   #23,d0
                    bra     writeboot



* Quartex Utility Boot V2.0 ( -Q )
* --------------------------------
lQ                  bsr     diskintest
                    tst.l   d0
                    bne     back
                    bsr     diskwptest
                    tst.l   d0
                    bne     back
                    lea     QBoot,a4
                    move.l  #255,d0
                    bra     writeboot



* DOS markierter BootBlock ( -D )
* -------------------------------
lD                  bsr     diskintest
                    tst.l   d0
                    bne     back
                    bsr     diskwptest
                    tst.l   d0
                    bne     back
                    lea     OS1Boot,a4
                    moveq   #0,d0
                    bra     writeboot



* Testen nach unbekannten BootBlock ( -C )
* ----------------------------------------
lC                  bsr     diskintest
                    tst.l   d0
                    bne     back
                    bsr     readboot
                    move.l  BootBuff,a0
                    move.b  #0,3(a0)
                    cmp.l   #$444F5300,(a0)         ;DOS Kennung
                    bne     cbnok
                    move.l  4(a0),d0
                    cmp.l   #$0,d0                  ;Non bootable
                    beq     cbok
                    cmp.l   #$C0200F19,d0           ;DOS Boot OS1.3
                    beq     cbok
                    cmp.l   #$C6D52AD5,d0           ;DOS Boot OS2.0
                    beq     cbok
                    cmp.l   #$E33D0E70,d0           ;DOS Boot OS3.0
                    beq     cbok
                    cmp.l   #$1C2238A9,d0           ;Quartex Boot
                    beq     cbok
cbnok               move.l  #UnknownBoot,d2
                    bra     text
cbok                move.l  #KnownBoot,d2
                    bra     text



* Checksumme von BootBlock löschen
* --------------------------------
lZ                  bsr     diskintest
                    tst.l   d0
                    bne     back
                    bsr     diskwptest
                    tst.l   d0
                    bne     back
                    bsr     readboot
                    move.l  BootBuff,a0
                    clr.l   4(a0)
                    move.l  BootBuff,a4
                    move.l  #255,d0
                    bra     writeboot



* CheckSumme von BootBlock neu berechnen ( -U )
* ---------------------------------------------
lU                  bsr     diskintest
                    tst.l   d0
                    bne     back
                    bsr     diskwptest
                    tst.l   d0
                    bne     back
                    bsr     readboot
                    move.l  BootBuff,a0
                    clr.l   4(a0)
                    move.w  #$ff,d1
                    moveq   #0,d0
uloop               add.l   (a0)+,d0
                    bcc     ujump
                    addq.l  #1,d0
ujump               dbf     d1,uloop
                    not.l   d0
                    move.l  BootBuff,a4
                    move.l  d0,4(a4)
                    move.l  #255,d0
                    bra     writeboot



* BootBlock in/auf Output-Channel ausgeben ( -* )
* -----------------------------------------------
lX                  bsr     diskintest
                    tst.l   d0
                    bne     back
                    bsr     readboot
                    move.l  BootBuff,a1
                    move.l  a1,d5
                    move.l  #1023,d0
xloop               move.b  (a1),d1
                    cmp.b   #32,d1
                    bge     xdo
                    move.b  #".",d1
xdo                 move.b  d1,(a1)+
                    dbra    d0,xloop
                    move.l  #15,d4
xxloop              move.l  d5,d2
                    move.l  #64,d3
                    add.l   d3,d5
                    bsr     textprint
                    move.l  #Lf,d2
                    move.l  #1,d3
                    bsr     textprint
                    dbra    d4,xxloop
                    rts



* Syntaxtext ausgeben ( ? )
* -------------------------
l?                  move.l  #Lf,d2
                    bsr     text
                    move.l  #Syntax,d2
                    bsr     text
                    bra     closelib



* Dateinamen ermitteln
* --------------------
getname             move.l  d6,a0
                    lea     7(a0),a0
                    move.l  a0,d1
                    rts



* Daten von BootBlock auf disk schreiben
* --------------------------------------
writeboot           move.l  BootBuff,a5
wbloop              move.l  (a4)+,(a5)+
                    dbra    d0,wbloop
                    lea     DiskIO,a1
                    move.w  #3,28(a1)
                    move.l  BootBuff,40(a1)
                    move.l  #0,44(a1)
                    move.l  #1024,36(a1)
                    CALLEXE DoIO
                    move.w  #4,28(a1)
                    CALLEXE DoIO
                    rts



* BootBlock einlesen
* ------------------
readboot            lea     DiskIO,a1
                    move.w  #2,28(a1)
                    move.l  BootBuff,40(a1)
                    move.l  #1024,36(a1)
                    move.l  #0,44(a1)
                    CALLEXE DoIO
                    rts



* Test ob Diskette eingelegt D0<>0 = False
* ----------------------------------------
diskintest          lea     DiskIO,a1
                    move.w  #14,28(a1)
                    CALLEXE DoIO
                    move.l  32(a1),d0
                    beq     back
                    move.l  #NoDisk,d2
                    bra     text



* Test ob Diskette schreibgeschützt D0<>0 = False
* -----------------------------------------------
diskwptest          move.w  #15,28(a1)
                    CALLEXE DoIO
                    move.l  32(a1),d0
                    beq     back
                    move.l  #DiskPro,d2
                    bra     text



* Fehler in Parameterübergabe
* ---------------------------
error               bsr     usage
                    bra     closelib



* Keine gültigen Parameter
* ------------------------
usage               move.l  #Usage,d2
                    bra     text



* Device nicht vorhanden
* ----------------------
deverr              move.l  #Deverr,d2
                    bsr     text
                    bra     closelib



* Datei konnte nicht geöffnet werden
* ----------------------------------
filerr              bsr     getdoserr
                    move.l  #Filerr,d2
                    bsr     text
                    bsr     getname
                    move.l  d1,d2
                    bsr     text
                    move.l  #ErrCode,d2
                    bsr     text
                    rts




* Ermittlung der DOS Fehlernummer
* -------------------------------
getdoserr           CALLDOS IoErr
                    move.l  d0,d2
                    move.l  #100,d1
                    move.l  #2,d3
                    lea     ErrCode,a0
                    lea     14(a0),a0
                    bra     out2
loop                divs    #10,d1
out1                swap    d2
out2                and.l   #$FFFF,d2
                    divs    d1,d2
                    add.b   d2,(a0)+
                    dbra    d3,loop
                    rts



* Textausgabe > NULL Byte Test > D2 = TextPtr
* -------------------------------------------
text                move.l  d2,a0
                    clr.l   d3
textloop            tst.b   (a0)+
                    beq     textprint
                    addq.l  #1,d3
                    bra     textloop
textprint           CALLDOS Output
                    move.l  d0,d1
                    CALLDOS Write
                    rts



* dos.library schließen & Programmende
* ------------------------------------
closelib            move.l  DosBase,a1
                    CALLEXE CloseLibrary

back                RTS



* Speicherreservierung
* --------------------
DosBase     dc.l 0
BootBuff    dc.l 0
File        dc.l 0
DiskReply   ds.l 8
DiskIO      ds.l 20
Dosname     dc.b 'dos.library',0
Device      dc.b 'trackdisk.device',0

Lf          dc.b 10
Usage       dc.b 'Usage: ',27,'[33mDoBB',27,'[31m DFn: [-(F|R|W)Filename] [-(1|2|3|Q|D|C|Z|U|*)] [?]',10,0
Syntax      dc.b 10,'Syntax:'
            dc.b 9,'``  DF0: -Ffilename',27,'[3m (format boot to given file)',27,'[0m',10
            dc.b 9,'``  DF1: -Rfilename',27,'[3m (write boot to given file)',27,'[0m',10
            dc.b 9,'``  DF2: -Wfilename',27,'[3m (install given file to boot)',27,'[0m',10
            dc.b 9,'``  DF3: -1',9,27,'[3m    (install OS V1.3 boot)',27,'[0m',10
            dc.b 9,'``  DF0: -2',9,27,'[3m    (install OS V2.0 boot)',27,'[0m',10
            dc.b 9,'``  DF1: -3',9,27,'[3m    (install OS V3.0 boot)',27,'[0m',10
            dc.b 9,'``  DF2: -Q',9,27,'[3m    (install Quartex boot)',27,'[0m',10
            dc.b 9,'``  DF3: -D',9,27,'[3m    (install DOS mark only)',27,'[0m',10
            dc.b 9,'``  DF0: -C',9,27,'[3m    (check for un/known boot)',27,'[0m',10
            dc.b 9,'``  DF1: -Z',9,27,'[3m    (zero checksum of boot)',27,'[0m',10
            dc.b 9,'``  DF2: -U',9,27,'[3m    (update checksum of boot)',27,'[0m',10
            dc.b 9,'``  DF3: -*',9,27,'[3m    (display boot of drive)',27,'[0m',10
            dc.b 9,'``  ?      ',9,27,'[3m    (this global informations)',27,'[0m',10
            dc.b 10
            dc.b 27,'[1mDoBB V2.00',27,'[0;33m © 1995 Testaware'
            dc.b 27,'[31m, Released',27,'[33m 30-04-95 Volker Stepprath',27,'[31m',10,10,0

Deverr      dc.b 'Drive not available !',10,0
NoDisk      dc.b 'No disk in drive !',10,0
DiskPro     dc.b 'Disk is write protected !',10,0

Filerr      dc.b 'Can`t open ',0
ErrCode     dc.b ' - Error code 000 !',10,0

KnownBoot   dc.b 'Appears to be normal bootblock !',10,0
UnknownBoot dc.b 'May not be standard bootblock !',10,0

OS1Boot     dc.l $444F5300,$C0200F19,$00000370,$43FA0018,$4EAEFFA0,$4A80670A
            dc.l $20402068,$00167000,$4E7570FF,$60FA646F,$732E6C69,$62726172
            dc.l $79000000

OS2Boot     dc.l $444F5300,$C6D52AD5,$00000370,$43FA0032,$70254EAE,$FDD84A80
            dc.l $670C2240,$08E90006,$00224EAE,$FE6243FA,$002A4EAE,$FFA04A80
            dc.l $670A2040,$20680016,$70004E75,$70FF4E75,$65787061,$6E73696F
            dc.l $6E2E6C69,$62726172,$7900646F,$732E6C69,$62726172,$79000000

OS3Boot     dc.l $444F5303,$E33D0E70,$00000370,$43FA003E,$70254EAE,$FDD84A80
            dc.l $670C2240,$08E90006,$00224EAE,$FE6243FA,$00184EAE,$FFA04A80
            dc.l $670A2040,$20680016,$70004E75,$70FF4E75,$646F732E,$6C696272
            dc.l $61727900,$65787061,$6E73696F,$6E2E6C69,$62726172,$79000000

QBoot       dc.l $444F5300,$1C2238A9,$00000370,$48E7FF7E,$70026100,$022E7009
            dc.l $42A90024,$6100023A,$41FA03CC,$22690014,$20A9003C,$22690038
            dc.l $2F0943FA,$02B8303C,$4E20222E,$003E0481,$00080004,$6B043340
            dc.l $001E4AAE,$004E6704,$3340000A,$43FA02B6,$207A0394,$41E80034
            dc.l $4A986604,$33400008,$4A986604,$33400012,$4A986604,$3340001C
            dc.l $4AAE002A,$660C4AAE,$002E6606,$4AAE022A,$671A43FA,$03237020
            dc.l $1340001A,$12C012BC,$004145FA,$02D424FC,$56495249,$43F90007
            dc.l $80002449,$4299B3FC,$0007F000,$66F62C57,$33FC01A0,$00DFF096
            dc.l $43FA01CE,$2D490032,$41F90007,$1000214A,$00087001,$223C0000
            dc.l $0300243C,$00000100,$4EAEFE7A,$43F90007,$11004EAE,$FF3A43F9
            dc.l $00071100,$237C0007,$10000004,$70014EAE,$FEAA4BFA,$01C87800
            dc.l $7632181D,$672E610E,$06830000,$01806106,$4BED001F,$60E843F9
            dc.l $00071100,$20032204,$4EAEFF10,$43F90007,$1100204D,$701F4EAE
            dc.l $FFC44E75,$33FC8380,$00DFF096,$283C000F,$F0002C78,$00045384
            dc.l $670000B8,$43FA025A,$0C110041,$661243FA,$01663011,$02400F00
            dc.l $06400100,$32805284,$4BF900BF,$E0010815,$00066700,$008E102D
            dc.l $0C00422D,$0C004600,$B03C00A0,$670000D4,$B03C00A2,$660A203C
            dc.l $00080000,$600000C8,$B03C00A4,$66164BF9,$00FC00D0,$42AE0026
            dc.l $4EAEFFE2,$41F80002,$4E704ED0,$B03C00A6,$6738B03C,$00A86606
            dc.l $4BFAFFEA,$60DEB03C,$00AA6756,$B03C00AC,$66040855,$0001B03C
            dc.l $00AE6612,$47FA020C,$32130841,$00053681,$33C100DF,$F1DC6000
            dc.l $FF52207A,$01F241E8,$003470FF,$20C020C0,$20806112,$43FA01E6
            dc.l $4EAEFFA0,$20402068,$00167000,$4E75205F,$588F4CDF,$7EFF2F08
            dc.l $4E7561F2,$700541F9,$00050000,$610C7003,$61087004,$61046000
            dc.l $FDCC41F9,$00030000,$23480028,$237C0000,$04000024,$42A9002C
            dc.l $3340001C,$4EAEFE38,$4E75202E,$003E204E,$4BF900FC,$02800C65
            dc.l $21FC66FA,$99CC4DF8,$06762640,$43F900DF,$F096203C,$7FFF7FFF
            dc.l $22C022C0,$4EE8FFE2,$01002200,$01020001,$00920020,$009400D8
            dc.l $008E3000,$009030FF,$00E00007,$00E28870,$00E40007,$00E688A0
            dc.l $01860AAA,$01840EEE,$01820777,$01800002,$FFFFFFFE,$223C3C3C
            dc.l $3C3C3C20,$5554494C,$49545920,$424F4F54,$2056322E,$30203E3E
            dc.l $3E3E3E3E,$35464153,$544D454D,$3A4F4646,$20202020,$20203120
            dc.l $4D454720,$43484950,$3A4F4646,$2C202044,$46313A4F,$46462020
            dc.l $20444632,$3A4F4646,$20202044,$46333A4F,$46462020,$43463120
            dc.l $46415354,$4D454D20,$4F464620,$46322043,$4849502F,$46415354
            dc.l $204F4646,$4C463320,$414C4C20,$4D454D20,$4F4E2020,$4634204B
            dc.l $494C4C20,$44524956,$45532120,$55463520,$48415244,$20524553
            dc.l $45542020,$46362049,$4E535441,$4C4C2042,$4F4F5420,$5E463720
            dc.l $544F4747,$4C45204C,$45442020,$46382054,$4F472050,$414C2F4E
            dc.l $54534320,$6C20204E,$4F205649,$52555320,$48415320,$4245454E
            dc.l $20444554,$45435445,$44212020,$75424F4F,$54204259,$20204E2E
            dc.l $4F2E4D2E,$412E4420,$204F4620,$51554152,$54455821,$00000000
            dc.l $00000000,$646F732E,$6C696272,$61727900

            END
