Multiloader. Accelerated version.
ZXNet echo conference «code.zx»
From Aleksey Malov → To All 1 May 2000
Greetings, All!
Now Tigrr and I tormented this monster. On my Scorpio at 3.5.fdd with
frame length 75240 clock cycles when reading the entire disk (640k) the average is achieved
reading speed of 10500 bytes/sec. Those. the subject works at almost the same speed
as in Napalm, only the howls of the Mouzon are completely absent, because loading
comes with interrupts enabled.
The loading algorithm is as follows:
1. read the n'th sector from the track.
2. If the download is completed successfully, then mark this sector in the table as
read (#ff).
3. If the sector turns out to be bad or an interruption occurred while reading it,
then we read the next sector on the track (at a different address), and not the same sector,
like other loaders.
4. Repeat steps 1-3 until we read the entire track or until it ends
the whole file.
5. If the file has not ended, then repeat steps 1-4 for the next tracks.
The source is something like this:
═══════════════════ mult.src.t ══════════════════
sectb equ #ff00;sector table
;should be located
;at round (#xx00) address
inttab equ #be00;int table
intsp equ #bfbf;isr stack
muzon equ #c000
interl equ 2; a number that can be adjusted by selecting it
;reading speed - this number is the number of sectors that
;will be skipped when moving to the next track.
;At number 2, the loader on my drive reads 10500 bytes/second
org #8000
;test procedureENT $
ld hl,muz
ld de,muzon
ld bc,emuz-muz
ldir
call muzon
ld a,8;number of characters
;file name for
;search
ld (23814),a
ld a,(23798);number
;disk drive
ld(drvnum),a
ld c,1;initialize
call #3d13;disk drive
ld hl,findscr
ld de,#5cdd
ld bc,8
ldir
ld c,#0a
call #3d13
ld a,c
cp #ff
ret z
ld c,8
call #3d13
ld de,(#5ceb)
ld (trsec),de
call int_on
ld hl,0
ld (count),hl
ld b,40
suxx00 push bc
ld hl,#4000
ld b,#1b
ldc,1
ld a,0
ld de,#1106
trsec equ $-2
call loader
pop bc
djnz suxx00
call int_off
call #c008; turn off Mouzon
ei
LD HL,#2758;correct
EXX ;return to BASIC
ld bc,(count);int counter
ret
;int procedure
inter ex (sp),hl
ld(intjp+1),hl
ex(sp),hl
inc sp
inc sp
ld(intex+1),sp
ldsp,intsppush af
push bc
push de
push hl
exx
ex af,af'
push af
push bc
push de
push hl
push ix
push iy
;Inta body
call muzon+5; play muzon
ldhl,#2121
count equ $-2;int counter
inc hl
ld (count),hl
;exit from the Internet
ld a,(intjp+2)
cp #40
jr c, zabij
inex pop iy
pop ix
pop hl
pop de
pop bc
pop af
exx
ex af,af'
pop hl
pop de
pop bc
pop af
intex ld sp,#3131
ei
intjp jp #c3c3
zabij ;we are in trdos
ld hl,(intex+1)
dec hl
dec hl
ld(intex+1),hl
ld hl,#3d2f
ld(intjp+1),hl
jr inex
;procedure for including ints
int_on di
ld hl,inttab
ld de,inttab+1
ld b,e
ld c,l
ld a,h
ld i,a
ld (hl),inttab/256+1
ldir
ld a,#c3
ld hl,inter
ld(inttab/256+inttab+257),a
ld (inttab/256+inttab+258),hl
im 2
ei
ret
int_off di
ld a,63
ld i,a
im 1ei
ret
;hl - snowflake
;de - track(0...255) & sector(0...15)
;b - snowflake snowflakes
loader ld a,(drive number)
cp 3
jp z,ram_dsk
ld a,(#5cd6)
push off
push there
push bc
ld (readdress),hl
ld hl, (#5cc2);break protect
ld ( runfile + 1 ), hl
ld hl,#c9f1
ld (#5cc2), hl
call posit ;track d
pop bc
pop there
xor a
ld (second),a
ld (#5cf4),the
load1 is pushed
ld hl,sectb+31
ld a,#ff
ld (hl),a
dec l
jp p,$-2
ld a,d
rra
sbc a,a
and 16
or e
ld l,a
ld (fstsec), a
cpl
add a,3
cp b
jr c,$+3
ld a,b;small scale
;к-е надо с дороги
;считать's
ld c,a
ld (second),a
loadf ld (hl),l
inc l
dec a
jr nz,loadf
load2 push bc
load3 ld hl,sectb;
secunh equ $-2;
ld a,l
seek cp (hl)
jr z,found
xor
ld l,a
cp (hl)
jr z,found
inc aand #1f
ld l,a
jr seek
found ld (secunh),a
and 16
or 3
drvnum equ $-1
or #2c
;set the side number
xor #10
call outff
ld a,l
ld c,l
sub 0
fstsec equ $-1
;determine the sector read address
ldhl,#2121
readadr equ $-2
add a,h
ld h,a
ld a,c
and 15
call readsec; read sector
;from current track
;cf=1 if reading error
jr nc,readok
;error, check the next sector
ld hl,secunh
inc(hl)
res 5,(hl)
jr load3
readok
;increase the current sector and track
ld hl,#5cf4
ld a,(hl)
inc a
and 15
ld(hl),a
inc hl
jr nz,$+3
inc(hl)
;mark the sector in the table as read
ld hl,(secunh)
ld (hl),#ff
;the head is now above the next sector
inc l
res 5.l
ld (secunh),hl
pop bc
;see how many sectors are left
;count
dec b
dec c
jr nz,load2
ld a,l
add a,interl
and 31
LD (secunh),a
;next path
ld hl,readadr+1ld a,(hl)
add a,0
secontrk equ $-1
ld(hl),a
pop af
ld e,0;go to next.
inc a;track
inc a
and #fe
ld d,a
inc b
dec b
jr nz,ostalos
pop af
ld (#5cd6),a
runfile ld hl,#2121
ld (#5cc2),hl
ret
;step to the next path
ostalos call stepfw
jp load1
;reset VG93 (once for crooked cars),
;or the first time you access this
;drive
posit ld a,#3e
or a
jr z,track
xor a;next time
ld(posit+1),a
ld a,(drvnum)
or #3c
call outff
ld a,%00001000
call out1f
call gundos
track ld a,d
srl a
ld (pipisa),a
ld c,#7f
call outc
ld a,%00011000
call out1f
call gundos
ret
;read from disk d via #3d13
ram_dsk ld a,b
push af
push de
push hl
ld a,3
ldc,1
call #3d13
pop hl
pop de
ld (#5cf4),de
pop af
;read 2 sectors from the ram disk per
;interrupt
dermo ei
halt
di
call ramldjr z, eramd
call ramld
jr nz,dermo
erad ei
ret
ramld push af
push hl
ld bc,#0105
ld de,(#5cf4)
call #3d13
pop hl
pop af
inc h
dec a
ret
;read sector with current. roads
readsec ld (adres),hl
inc a
ld c,#5f;physical sector number
call outc;to sector register
ld a,1
ld (#5cd6),a
ld hl,retdos;actions for
push hl ;for control
ld hl,deby ;for
push hl ;correctness
ld bc,#017f ;reading
ldhl,#2121
addresses equ $-2
ld ix,#2091
jp dos
retdos ld a,10
ld (#5cd8),a
ld de,0
pipisa equ $-1
ld ix,#2740
call dos
ld a,(#5ccd)
and %01111111
ret z
ld a,(#5cd6)
dec a
ret z
scf ;error, cf=1
ret
outff ld c,#ff
outc ld ix,#2a53
jr dos
stepfw ld hl,pipisa
inc(hl)
ld a,%01011100
out1f ld ix,#2fc3
jr dos
gundos ld ix,#3ef5
dos push ix
jp #3d2f
deby db 1;needed for polling #1f
findscr db "BWpictrs";filename;for test
muz insert "AlmRave.C"; name of Mouzon
emuz ;for test
════════════════════════ ════════════════════════
I wish you health, happiness and creative Uzbeks.
Aleksey Malov aka VIVID/Brainwave.