org	$30000                  ; JTS present speedtest and trkstep modifyer
load	$30000                  ; 1991 IV. 29.

dos:    dc.b    "DOS",0         ;DOS-disk
        dc.l    0,880           ;chksum, root block
                                ;ne felejtsd el a chksum-ot kiszamolni !!!
s:      btst    #6,$bfe001
        beq     normal
        movem.l a0-a6/d0-d7,-(a7)
        lea     t(pc),a5
        clr.l   4(a5)           ;szamol
        move.l  #$12345678,d0
        move.w  #$4321,d1
        moveq   #-1,d7
        move.l  $6c,(a5)        ;oldit
        move.l  $6c,endit-t+2(a5)
        lea     irq-t,a1
        add.l   a5,a1
        move.l  a1,$6c
ck1:    move.l  d0,d2           ;osztasos speedtest
        divu    d1,d2           ;hogy 7.xxx Mhz-en ne
        dbf     d7,ck1          ;legyen lassabb a drive
        move.l  oldit(pc),$6c
        move.l  szamol(pc),d7
        move.l  #222,d7
        divu    szamol+2(pc),d7
        mulu    #$350,d7
        tst.l   d7
        bne     at1
        move.l  #$a00,d7
at1:    move.l  d7,8(a5)        ;step
        bclr    #1,$bfe001
        cmp.w   #$13e0,d7
        blt     at2
        bset    #1,$bfe001
at2:    move.l  4.w,a6
        lea     tdiv(pc),a1
        lea     350(a6),a0
        jsr     -276(a6)        ;FindTask
        move.l  d0,a0
        beq.s   endd
        move.l  36(a0),a1
        move.l  d7,$2c(a1)      ;uj step-wait beirasa
endd:   movem.l (a7)+,a0-a6/d0-d7

normal: move.l  4.w,a6          ;normal bootblock
        lea     doslib(pc),a1
        jsr     -96(a6)
        tst.l   d0
        beq.s   nemjo
        move.l  d0,a0
        move.l  22(a0),a0
        moveq   #0,d0
vege:   rts
nemjo:  moveq   #-1,d0
        bra.s   vege

doslib: dc.b    "dos.library",0
even
tdiv:   dc.b    "trackdisk.device",0
even

t:
oldit:  dc.l    0
szamol: dc.l    0
step:   dc.l    0

irq:    move.l  a1,-(a7)        ;IT a speedtest-hez
        lea     szamol(pc),a1   ;szamlalo
        add.l   #1,(a1)
        move.l  (a7)+,a1
endit:  jmp     $0

