;DOS file-loader by Mr.Spiv/CAVE

;example of calling it
; lea mfmbuff(pc),a1 ;point to your MFM buffer here
; movea.l a1,mfmaddr ;set MFM buffer address for loader
; lea filename(pc),a0
; lea $30000,a1
; moveq #0,d0
; bsr.w spivload

;filename: dc.b ‘testfile’,0

; —————————————————————————

spivload:
movem.l d1-a6,-(a7)
bsr sub_1027E
lea $DFF000,a6
lea $BFD100,a5
lea off_10496(pc),a4
movem.l a0-a1,(a4)
move.b d0,$23(a4)
bsr.w sub_10228
movea.l off_10496,a0
bsr.w sub_10180
bsr.w sub_101A0
movea.l #$6E000,a0
lea unk_104BC(pc),a1
bsr.w sub_101E0
bne.s loc_100E0

loc_100A0:
move.w word_104A6,d0
lsl.w #2,d0
move.l (a1,d0.w),d0

loc_100AA:
mulu.w #$200,d0
beq.s loc_100DC
movea.l d0,a0
bsr.w sub_101E0
bne.s loc_100E0
move.l $1FC(a1),d0
move.l (a1),d1
cmpi.w #-3,d0
bne.s loc_100CA
cmpi.w #2,d1
beq.s loc_1012A

loc_100CA:
cmpi.w #2,d0
bne.s loc_100D6
cmpi.w #2,d1
beq.s loc_100FA

loc_100D6:
cmpi.w #8,d1
beq.s loc_1013C

loc_100DC:
st $22(a4)

loc_100E0:
bsr.w sub_1025E
moveq #-1,d0
tst.b $22(a4)
bne.s loc_100F4
move.l dword_1049A,d0
sub.l $20(a7),d0

loc_100F4:
movem.l (a7)+,d1-a6
rts

loc_100FA:
bsr.s sub_1010C
adda.l dword_7049E,a0
addq.w #1,a0
bsr.s sub_10180
bsr.w sub_101A0
bra.s loc_100A0

sub_1010C:
lea $1B0(a1),a3
moveq #0,d1
move.b (a3)+,d1
movem.l dword_1049E,d0/a0
bsr.s sub_1015E
bmi.s loc_10120
rts

loc_10120:
addq.w #4,a7
move.l $1F0(a1),d0
bne.s loc_100AA
bra.s loc_100DC

loc_1012A:
bsr.s sub_1010C
move.l $134(a1),d0

loc_10130:
mulu.w #$200,d0
movea.l d0,a0
bsr.w sub_101E0
bne.s loc_100E0

loc_1013C:
move.l $10(a1),d0
lea $18(a1),a3
move.l $C(a1),d2
subq.w #1,d2
movea.l dword_1049A,a2

loc_1014E:
move.b (a3)+,(a2)+
dbf d2,loc_1014E
move.l a2,4(a4)
tst.l d0
bne.s loc_10130
bra.s loc_100E0

sub_1015E:
movea.l a0,a2
cmp.w d0,d1
bne.s loc_1017C
subq.w #1,d0

loc_10166:
move.b (a3)+,d1
bsr.s sub_101CE
move.b d1,d2
move.b (a2)+,d1
bsr.s sub_101CE
cmp.b d1,d2
bne.s loc_1017C
dbf d0,loc_10166
moveq #0,d0
rts

loc_1017C:
moveq #-1,d0
rts

sub_10180:
move.l a0,-(a7)
moveq #0,d0

loc_10184:
cmpi.b #$2F,(a0) ; ‘/’
beq.s loc_10192
tst.b (a0)+
beq.s loc_10192
addq.w #1,d0
bra.s loc_10184

loc_10192:
movea.l (a7)+,a0
clr.b (a0,d0.w)
movem.l d0/a0,8(a4)
rts

sub_101A0:
movem.l dword_1049E,d0/a0
move.l #$7FF,d2

loc_101AC:
moveq #0,d1
move.b (a0)+,d1
beq.s loc_101BE
bsr.s sub_101CE
mulu.w #$D,d0
add.l d1,d0
and.w d2,d0
bra.s loc_101AC

loc_101BE:
and.l d2,d0
divu.w #$48,d0
swap d0
addq.w #6,d0
move.w d0,$10(a4)
rts

sub_101CE:
cmpi.b #$61,d1 ; ‘a’
bcs.s locret_101DE
cmpi.b #$7A,d1 ; ‘z’
bhi.s locret_101DE
subi.b #$20,d1 ; ‘ ‘

locret_101DE:
rts

sub_101E0:
move.b #3,$24(a4)

loc_101E6:
movem.l a0-a1,-(a7)
move.l a7,$12(a4)
clr.b $22(a4)
tst.b $1E(a4)
bpl.s loc_101FC
bsr.w sub_1029A

loc_101FC:
move.b byte_104B4,$1F(a4)
move.b byte_104B6,$21(a4)
bsr.w sub_102CA

loc_1020C:
movea.l dword_104A8,a7
movem.l (a7)+,a0-a1
tst.b $22(a4)
beq.s locret_10226
subq.b #1,$24(a4)
bmi.s locret_10226
st $1E(a4)
bra.s loc_101E6

locret_10226:
rts

sub_10228:
move.w #$9500,$9E(a6)
move.w #$8210,$96(a6)
move.w #$4489,$7E(a6)
move.l #$A000A,$9A(a6)
bclr #7,(a5)
moveq #0,d0
move.b byte_104B9,d0
addq.b #3,d0
bclr d0,(a5)
moveq #$7F,d1

loc_10252:
moveq #0,d0
bsr.w sub_103FA
dbf d1,loc_10252
rts

sub_1025E:
moveq #0,d0
move.b byte_104B9,d0
addq.b #3,d0
bset d0,(a5)
nop
nop
bset #7,(a5)
nop
nop
bclr d0,(a5)
nop
nop
bset d0,(a5)
rts

sub_1027E:
lea $BFD100,a5
move.b #$F9,(a5)
nop
nop
move.b #$81,(a5)
nop
nop
move.b #$F9,(a5)
rts

sub_1029A:
bset #1,(a5)

loc_1029E:
btst #4,$F01(a5)
beq.s loc_102C4
bclr #0,(a5)
nop
nop
bset #0,(a5)
moveq #0,d0
bsr.w sub_103FA
btst #2,$F01(a5)
beq.w loc_10488
bra.s loc_1029E

loc_102C4:
clr.b $1E(a4)
rts

sub_102CA:
move.l a0,d0
divu.w #$1600,d0
move.l d0,d1
andi.w #1,d1
bne.s loc_102DE
bset #2,(a5)
bra.s loc_102E2

loc_102DE:
bclr #2,(a5)

loc_102E2:
move.b d1,$20(a4)
lsr.w #1,d0
bsr.w sub_103BE
swap d1
move.w d1,d3
move.l #$55555555,d2
lea $7C000,a3 ;MFM buffer
lea $3300(a3),a0
move.b byte_104B4,d7
cmp.b byte_104B5,d7
bne.s loc_10314
move.b byte_104B6,d7
cmp.b byte_104B7,d7
beq.s loc_10336

loc_10314:
move.l a3,$20(a6) ; MFM buffer
move.w #2,$9C(a6)
clr.w $24(a6)
move.w #$9980,$24(a6)
move.w #$9980,$24(a6)
bsr.w sub_10432
clr.w $24(a6)

loc_10336:
moveq #$A,d7

loc_10338:
cmpa.l a0,a3
bcc.w loc_10458
cmpi.w #$4489,(a3)+
bne.s loc_10338
cmpi.w #$4489,(a3)
bne.s loc_1034C
addq.w #2,a3

loc_1034C:
movem.l (a3)+,d0-d1
and.l d2,d0
and.l d2,d1
add.l d0,d0
or.l d1,d0
clr.b d0
move.l d0,$16(a4)
cmpi.b #-1,$16(a4)
bne.w loc_10474
add.w d0,d0
sub.w d3,d0
beq.s loc_1037A
adda.w #$430,a3
dbf d7,loc_10338
bra.w loc_10458

loc_1037A:
adda.w #$28,a3
move.l (a3)+,d0
move.l (a3)+,d4
and.l d2,d0
and.l d2,d4
add.l d0,d0
or.l d0,d4
moveq #0,d6
moveq #$7F,d5
movea.l a3,a0

loc_10390:
move.l $200(a0),d1
move.l (a0)+,d0
eor.l d0,d6
eor.l d1,d6
dbf d5,loc_10390
and.l d2,d6
cmp.l d4,d6
bne.w loc_1047E
moveq #$7F,d7

loc_103A8:
move.l $200(a3),d1
move.l (a3)+,d0
and.l d2,d0
and.l d2,d1
add.l d0,d0
or.l d1,d0
move.l d0,(a1)+
dbf d7,loc_103A8
rts

sub_103BE:
sub.b byte_104B4,d0
beq.s locret_103F4
add.b d0,$1E(a4)
ext.w d0
move.w d0,d1
bge.s loc_103D6
bset #1,(a5)
neg.w d1
bra.s loc_103DA

loc_103D6:
bclr #1,(a5)

loc_103DA:
subq.w #1,d1

loc_103DC:
bclr #0,(a5)
nop
nop
bset #0,(a5)
moveq #0,d0
bsr.s sub_103FA
dbf d1,loc_103DC
bclr #1,(a5)

locret_103F4:
rts

unk_103F6: dc.b $10 ;
unk_103F7: dc.b $C8 ; +
dc.b $32 ; 2
dc.b $58 ; X

sub_103FA:
add.w d0,d0
move.b #$82,$1C01(a5)
move.b unk_103F7(pc,d0.w),$1501(a5)
move.b unk_103F6(pc,d0.w),$1601(a5)
move.b #$19,$1E01(a5)

loc_10414:
btst #1,$1C01(a5)
beq.s loc_10414
move.w #8,$9C(a6)
move.b #2,$1C01(a5)
rts

loc_1042A:
move.w #2,$9C(a6)
rts

sub_10432:
moveq #$7F,d1

loc_10434:
btst #1,$1F(a6)
bne.s loc_1042A
moveq #0,d0
bsr.s sub_103FA
dbf d1,loc_10434
move.b #6,$22(a4)
move.w #2,$9C(a6)
clr.w $24(a6)
bra.w loc_1020C

loc_10458:
cmpi.b #$A,d7
bne.s loc_1046A
bpl.s loc_1046A
move.b #7,$22(a4)
bra.w loc_1020C

loc_1046A:
move.b #8,$22(a4)
bra.w loc_1020C

loc_10474:
move.b #3,$22(a4)
bra.w loc_1020C

loc_1047E:
move.b #5,$22(a4)
bra.w loc_1020C

loc_10488:
move.b #2,$22(a4)
clr.b $24(a4)
bra.w loc_1020C
; —————————————————————————
off_10496: dc.l unk_7005C
dword_1049A: dc.l $30000
dword_1049E: dc.l 6
dc.b 0
dc.b 7
dc.b 0
dc.b $5C
word_104A6: dc.w $1F
dword_104A8: dc.l $2088B8
dc.b 0
dc.b 0
dc.b 0
dc.b 0
dc.b 0
dc.b 0
dc.b 0
dc.b 0
byte_104B4: dc.b $FF
byte_104B5: dc.b 0
byte_104B6: dc.b $FF
byte_104B7: dc.b 0
dc.b 2
byte_104B9: dc.b 1
dc.b $FF
dc.b 0
unk_104BC: blk.b 16,0
mfmaddr: dc.l $0

0

Publication author

offline 2 weeks

mus@shi9

0
Comments: 1160Publics: 2780Registration: 06-03-2017

Subscribe
Notify of
guest

8 Comments
Newest
Oldest
Inline Feedbacks
View all comments
mr.Spiv
mr.Spiv
12 years ago

The loader does paths as well, not just the root directory. And multiple drives (values 0-3 in D0). It seems the path traversing code does something stupid like replacing ‘/’ characters in the path name with ‘\0’, thus for loading the some file again, you need to provide the full path again. I should have the original source for this somewhere.. I can look it up.

0
scenex
scenex
12 years ago

thanks mr.spiv for the tip, i’ll try to kill the OS before starting to seek for files.

0
mr.spiv
mr.spiv
12 years ago

@WK where did you dig this?

the loader seems to use timers for wait loops (sub_103FA), which might make your amy go belly up if OS is running.

0
scenex
scenex
12 years ago

thanks, that very relieving to hear 🙂
it was almost driving me crazy yesterday when i was trying to get it to work.

alright, i’ll have a look on conqueror fileloader in the meanwhile.

0
WayneK
12 years ago

This clearly isn’t the right version, I’ll try and find the correct one tomorrow for you… until then feel free to use the Conqueror file-loader which definitely works 🙂

0
scenex
scenex
12 years ago

thanks for clearing this up WayneK, with the modifications you proposed it assembles now. well, i’m still a bit confused about the recommended usage of this file loader. 1 – lea mfmbuff(pc),a1 ;point to your MFM buffer here 2 – movea.l a1,mfmaddr ;set MFM buffer address for loader 3 – lea filename(pc),a0 4 – lea $30000,a1 5 – moveq #0,d0 6 – bsr.w spivload what parameters in which registers is the loader expecting? i’m asking because i don’t see that the mfmaddr is being referenced anywhere in the code. is register a1 in line 4 the loadaddress where to file… Read more »

WayneK
12 years ago

The code is complete, just change dword_7049e to dword_1049e and make off_10496 dc.l 0 instead…seems I was a bit quick sending this to M9, or he has posted an earlier version 😛

0
scenex
12 years ago

anybody got this piece of code working?
the source doesn’t assemble..

it complains about undefined symbols at:
78 – adda.l dword_7049e,a0
481 – off_10496: dc.l unk_7005c

i just copied it from the website, since the download link is broken.

is the code listing incomplete?

0
Authorization
*
*

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Registration
*
*
*

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Password generation

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

8
0
Would love your thoughts, please comment.x
()
x