Section Startup,Code Incdir DEVPAC:include/ Include exec/execbase.i Include exec/exec_lib.i Include libraries/dos.i Include libraries/dos_lib.i Start lea SearchName,a1 bsr ReadParString bsr OpenLibraries bsr WaitForPlay tst.l d0 bne .2 bsr ReadName bsr PrintFound tst.l d0 bne .2 bsr WaitForPlay tst.l d0 bne .2 lea Loading_Text,a0 bsr PrintString bsr ReadFile tst.l d0 bne .1 bsr SaveFile tst.l d0 bne .3 rts .1 lea Error_Text,a0 bsr PrintString rts .2 lea Break_Text,a0 bsr PrintString rts .3 lea SaveError_Text,a0 bsr PrintString rts DisableIRQ move.w #$4000,$dff09a rts EnableIRQ move.w #$c000,$dff09a rts ReadParString ;A0=Commandline,D0=NrChars,A1=ParString movem.l d1/d2/a1,-(a7) moveq #$20,d2 .1 subq.l #1,d0 bmi .3 move.b (a0)+,d1 cmp.b #$20,d1 beq .1 cmp.b #$0a,d1 beq .3 cmp.b #$22,d1 bne .2 move.b d1,d2 subq.l #1,d0 bmi .3 move.b (a0)+,d1 .2 move.b d1,(a1)+ subq.l #1,d0 bmi .3 move.b (a0)+,d1 cmp.b #$0a,d1 beq .3 cmp.b d2,d1 bne .2 .3 clr.b (a1) movem.l (a7)+,d1/d2/a1 rts SaveFile lea Name+5,a0 move.l a0,d1 move.l #MODE_NEWFILE,d2 CALLDOS Open move.l d0,d1 beq .1 cmp.l #$ffffffff,d0 beq .1 move.l d1,-(a7) lea Name,a0 move.l a0,d2 moveq #$02,d3 CALLDOS Write move.l (a7),d1 lea File,a0 move.l a0,d2 move.l File_Length,d3 CALLDOS Write move.l (a7)+,d1 CALLDOS Close moveq #$00,d0 rts .1 moveq #$01,d0 rts ReadFile bsr MotorOn lea File,a0 move.l a0,a1 moveq #$00,d0 moveq #$00,d1 move.b Name+1,d0 move.b Name+3,d1 lsl.w #8,d0 lsl.w #8,d1 move.b Name,d0 move.b Name+2,d1 sub.w d0,d1 add.l d1,a1 move.l d1,File_Length bsr FindSyncName moveq #$00,d3 .1 bsr ReadByte move.b d0,(a0)+ eor.b d0,d3 cmp.l a0,a1 bne .1 bsr ReadByte eor.b d3,d0 move.l d0,-(a7) bsr MotorOff move.l (a7)+,d0 and.l #$000000ff,d0 rts ReadName bsr MotorOn bsr FindSyncName cmp.b #$00,d0 beq ReadName lea Name,a0 moveq #$00,d3 .1 bsr ReadByte move.b d0,0(a0,d3.w) addq.w #1,d3 cmp.b #$c0,d3 bne .1 bsr MotorOff rts FindSyncName move.w #$7f80,d7 move.w #$0040,$dff0a8 move.w #$0080,$dff09c move.w #$0080,$dff0a6 .1 btst #6,$bfe001 beq .4 bsr ReadBit roxl.b #1,d2 cmp.b #$02,d2 bne .1 moveq #$09,d3 .2 bsr ReadByte cmp.b #$02,d0 beq .2 .3 cmp.b d3,d0 bne .1 bsr ReadByte subq.b #1,d3 bne .3 .4 rts ReadByte moveq #$07,d1 .2 bsr ReadBit roxl.b #1,d2 dbf d1,.2 move.b d2,d0 rts ReadBit moveq #$00,d0 .1 or.b $bfdd00,d0 btst #4,d0 beq .1 move.b #$19,$bfdf00 move.w #$0080,$dff09c move.w d7,$dff0aa move.w $dff006,$dff180 not.b d0 and.b #$02,d0 subq.b #2,d0 rts WaitForPlay bclr #6,$bfd100 .1 move.b $bfe001,d0 bset #6,$bfd100 btst #5,d0 beq .3 lea PressPlay_Text,a0 bsr PrintString .2 btst #6,$bfe001 beq .4 bclr #6,$bfd100 move.b $bfe001,d0 bset #6,$bfd100 btst #5,d0 bne .2 .3 moveq #$00,d0 rts .4 moveq #$01,d0 rts MotorOn bsr DisableIRQ bclr #7,$bfd100 bclr #6,$bfd100 move.b #$00,$bfd700 move.b #$be,$bfd600 moveq #$00,d0 .1 dbf d0,.1 rts MotorOff bset #7,$bfd100 bset #6,$bfd100 bclr #6,$bfd100 bset #6,$bfd100 bsr EnableIRQ rts OpenLibraries lea DosName(pc),a1 moveq #$00,d0 CALLEXEC OldOpenLibrary move.l d0,_DOSBase CALLDOS Output move.l d0,_output rts PrintFound lea Found_Text,a0 bsr PrintString lea Name+5,a0 lea $10(a0),a1 .1 move.b -(a1),d0 cmp.b #$20,d0 bne .2 cmp.l a0,a1 bne .1 .2 clr.b 1(a1) addq.l #1,a1 .6 move.b -(a1),d0 cmp.b #'/',d0 bne .7 move.b #'-',(a1) .7 cmp.l a0,a1 bne .6 bsr PrintString lea NextLine_Text,a0 bsr PrintString move.l #$0800,d0 .3 btst #6,$bfe001 beq .4 move.b $bfd800,d1 .5 cmp.b $bfd800,d1 beq .5 subq.l #1,d0 bne .3 moveq #$00,d0 rts .4 moveq #$01,d0 rts PrintString ;A0=String nullterminated movem.l d2-d3/a6,-(a7) move.l a0,d2 moveq #$00,d3 .1 tst.b (a0)+ beq .2 addq.l #1,d3 bra .1 .2 tst.l d3 beq .3 move.l _output,d1 CALLDOS Write .3 movem.l (a7)+,d2-d3/a6 rts ************************************************************************* * STRING DEFINITIONS * ************************************************************************* PressPlay_Text dc.b $0a,"PRESS PLAY ON TAPE",$0a,$00 Found_Text dc.b "FOUND ",$00 Loading_Text dc.b "LOADING",$0a,$00 Break_Text dc.b "BREAK ERROR",$0a,$00 Error_Text dc.b "LOAD ERROR",$0a,$00 SaveError_Text dc.b "UNABLE TO CREATE AMIGA FILE ERROR",$0a,$00 NextLine_Text dc.b $0a,$00 DosName DOSNAME Section SomeBuffer,BSS _DOSBase ds.l 1 _output ds.l 1 SearchName ds.l $80/4 Name ds.l $c0/4 File_Length ds.l 1 File ds.l $10000/4