;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_100E0loc_100A0:
move.w word_104A6,d0
lsl.w #2,d0
move.l (a1,d0.w),d0loc_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_1012Aloc_100CA:
cmpi.w #2,d0
bne.s loc_100D6
cmpi.w #2,d1
beq.s loc_100FAloc_100D6:
cmpi.w #8,d1
beq.s loc_1013Cloc_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),d0loc_100F4:
movem.l (a7)+,d1-a6
rtsloc_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_100A0sub_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
rtsloc_10120:
addq.w #4,a7
move.l $1F0(a1),d0
bne.s loc_100AA
bra.s loc_100DCloc_1012A:
bsr.s sub_1010C
move.l $134(a1),d0loc_10130:
mulu.w #$200,d0
movea.l d0,a0
bsr.w sub_101E0
bne.s loc_100E0loc_1013C:
move.l $10(a1),d0
lea $18(a1),a3
move.l $C(a1),d2
subq.w #1,d2
movea.l dword_1049A,a2loc_1014E:
move.b (a3)+,(a2)+
dbf d2,loc_1014E
move.l a2,4(a4)
tst.l d0
bne.s loc_10130
bra.s loc_100E0sub_1015E:
movea.l a0,a2
cmp.w d0,d1
bne.s loc_1017C
subq.w #1,d0loc_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
rtsloc_1017C:
moveq #-1,d0
rtssub_10180:
move.l a0,-(a7)
moveq #0,d0loc_10184:
cmpi.b #$2F,(a0) ; ‘/’
beq.s loc_10192
tst.b (a0)+
beq.s loc_10192
addq.w #1,d0
bra.s loc_10184loc_10192:
movea.l (a7)+,a0
clr.b (a0,d0.w)
movem.l d0/a0,8(a4)
rtssub_101A0:
movem.l dword_1049E,d0/a0
move.l #$7FF,d2loc_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_101ACloc_101BE:
and.l d2,d0
divu.w #$48,d0
swap d0
addq.w #6,d0
move.w d0,$10(a4)
rtssub_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:
rtssub_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_1029Aloc_101FC:
move.b byte_104B4,$1F(a4)
move.b byte_104B6,$21(a4)
bsr.w sub_102CAloc_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_101E6locret_10226:
rtssub_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,d1loc_10252:
moveq #0,d0
bsr.w sub_103FA
dbf d1,loc_10252
rtssub_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)
rtssub_1027E:
lea $BFD100,a5
move.b #$F9,(a5)
nop
nop
move.b #$81,(a5)
nop
nop
move.b #$F9,(a5)
rtssub_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_1029Eloc_102C4:
clr.b $1E(a4)
rtssub_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_102E2loc_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_10336loc_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,d7loc_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,a3loc_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_10458loc_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,a0loc_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,d7loc_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
rtssub_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_103DAloc_103D6:
bclr #1,(a5)loc_103DA:
subq.w #1,d1loc_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:
rtsunk_103F6: dc.b $10 ;
unk_103F7: dc.b $C8 ; +
dc.b $32 ; 2
dc.b $58 ; Xsub_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)
rtsloc_1042A:
move.w #2,$9C(a6)
rtssub_10432:
moveq #$7F,d1loc_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_1020Cloc_10458:
cmpi.b #$A,d7
bne.s loc_1046A
bpl.s loc_1046A
move.b #7,$22(a4)
bra.w loc_1020Cloc_1046A:
move.b #8,$22(a4)
bra.w loc_1020Cloc_10474:
move.b #3,$22(a4)
bra.w loc_1020Cloc_1047E:
move.b #5,$22(a4)
bra.w loc_1020Cloc_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
Bad Brothers – Music Line Editor
Publication author offline 4 days mus@shi9 0 Comments: 1166Publics: 2809Registration: 06-03-2017
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.
thanks mr.spiv for the tip, i’ll try to kill the OS before starting to seek for files.
@WK where did you dig this?
@scenex the loader seems to use timers for wait loops (sub_103FA), which might make your amy go belly up if OS is running.
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.
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 🙂
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 »
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 😛
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?