home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
500-599
/
ff537.lzh
/
PaulCopy
/
pc.s
< prev
next >
Wrap
Text File
|
1991-08-26
|
16KB
|
797 lines
*****************************************
* *
* PAULCOPY *
* Single Drive DiskCopy *
* (C) 1990 Paul Hayter *
* V2 910106 *
* *
*****************************************
* TRY ALTERNATE METHOD OF ALLOCATING 5.5K CHUNKS AND ALSO USING A SINGLE PLANE
* Now (0.04) ONLY ALLOCATE 159 5.5K CHUNKS AND ONLY READ ONE SECTOR FROM LAST TRACK
* Now (0.07) WILL COPY IN 3 SWAPS ON 512K MACHINES
* Note: has big bug which stuffs up all destination tracks where only
* one sector is read/written.
* Now (0.08) WILL ALSO COPY ON DF1: ,IF YOU TYPE 1> PAULCOPY DF1:
* Now (1.00) MEGADISC RELEASE VERSION
* Now (1.01) Open little dos window. Removed ability to copy on df1:
* Also can start from Workbench.
* Now (II) Changed title, so that ONE SWAP appears in title bar.
_LVORemakeDisplay equ -384
_LVOAllocRaster equ -492
_LVOFreeRaster equ -498
_LVOBltClear equ -300
_LVOAllocMem equ -198
_LVOFreeMem equ -210
_LVOAvailMem equ -216
_LVOOpenLibrary equ -552
_LVOCloseLibrary equ -414
_LVOFindTask equ -294
_LVOForbid equ -132
_LVOPermit equ -138
_LVOCopyMemQuick equ -630
_LVOReplyMsg equ -378
_LVOPutMsg equ -366
_LVOGetMsg equ -372
_LVOWaitPort equ -384
_LVOOpenDevice equ -444
_LVOCloseDevice equ -450
_LVODoIO equ -456
_LVOWrite equ -48
_LVORead equ -42
_LVOInput equ -54
_LVOOutput equ -60
_LVODeviceProc equ -174
_LVOOpen equ -30
_LVOClose equ -36
pr_CLI equ 172
pr_MsgPort equ 92
bm_Planes_1 equ 8+4
rp_BitMap equ 4
sc_RastPort equ 84
sc_BitMap equ 184
ActiveScreen equ 56
bm_Depth equ 5
sc_Width equ 12
sc_Height equ 14
PortA equ $bfe001
LeftMouse equ 6
MODE_NEWFILE equ 1006
*************
* exec/io.i *
*************
IO_DEVICE EQU $14 ;IO Request Structure
IO_UNIT EQU $18
IO_COMMAND EQU $1C
IO_FLAGS EQU $1E
IO_ERROR EQU $1F
IO_SIZE EQU $20
IO_ACTUAL EQU $20
IO_LENGTH EQU $24
IO_DATA EQU $28
IO_OFFSET EQU $2C
IOSTD_SIZE EQU $30
IOF_QUICK EQU 1<<0 ;IO_FLAGS bit definitions
CMD_INVALID EQU 0 ;Standard Device Commands
CMD_RESET EQU 1
CMD_READ EQU 2
CMD_WRITE EQU 3
CMD_UPDATE EQU 4
CMD_CLEAR EQU 5
CMD_STOP EQU 6
CMD_START EQU 7
CMD_FLUSH EQU 8
CMD_NONSTD EQU 9
* ALLOCATION GUNK
MEMF_PUBLIC EQU 1<<0 ;Memory Options
MEMF_CHIP EQU 1<<1
MEMF_FAST EQU 1<<2
MEMF_CLEAR EQU 1<<16
MEMF_LARGEST EQU 1<<17
***********************
* devices/trackdisk.i *
***********************
NUMCYLS EQU 80 ;Physical drive constants
MAXCYLS EQU NUMCYLS+20
NUMSECS EQU 11
NUMHEADS EQU 2
MAXRETRY EQU 10
NUMTRACKS EQU NUMCYLS*NUMHEADS
NUMUNITS EQU 4
TD_SECTOR EQU 512
TD_SECSHIFT EQU 9
TDF_EXTCOM EQU 1<<15
TD_MOTOR EQU 9
TD_SEEK EQU 10
TD_FORMAT EQU 11
TD_REMOVE EQU 12
TD_CHANGENUM EQU 13
TD_CHANGESTATE EQU 14
TD_PROTSTATUS EQU 15
TD_LASTCOMM EQU TD_PROTSTATUS
ETD_WRITE EQU CMD_WRITE!TDF_EXTCOM
ETD_READ EQU CMD_READ!TDF_EXTCOM
ETD_MOTOR EQU TD_MOTOR!TDF_EXTCOM
ETD_SEEK EQU TD_SEEK!TDF_EXTCOM
ETD_FORMAT EQU TD_FORMAT!TDF_EXTCOM
ETD_UPDATE EQU CMD_UPDATE!TDF_EXTCOM
ETD_CLEAR EQU CMD_CLEAR!TDF_EXTCOM
IOTD_COUNT EQU $30 ;IOEXTTD Structure
IOTD_SECLABEL EQU $34
IOTD_SIZE EQU $38
TD_LABELSIZE EQU 16
TDERR_NotSpecified EQU 20
TDERR_NoSecHdr EQU 21
TDERR_BadSecPreamble EQU 22
TDERR_BadSecID EQU 23
TDERR_BadHdrSum EQU 24
TDERR_BadSecSum EQU 25
TDERR_TooFewSecs EQU 26
TDERR_BadSecHdr EQU 27
TDERR_WriteProt EQU 28
TDERR_DiskChanged EQU 29
TDERR_SeekError EQU 30
TDERR_NoMem EQU 31
TDERR_BadUnitNum EQU 32
TDERR_BadDriveType EQU 33
TDERR_DriveInUse EQU 34
START
move.l a7,entry_stack
move.l (4).w,a6
sub.l a1,a1
jsr _LVOFindTask(a6)
move.l d0,a4
;------ are we running as a son of Workbench?
tst.l pr_CLI(A4)
bne.s start2
fromWB
waitmsg
lea pr_MsgPort(A4),a0 * our process base
jsr _LVOWaitPort(a6)
lea pr_MsgPort(A4),a0 * our process base
jsr _LVOGetMsg(a6)
move.l d0,_WBenchMsg
;------ push the message on the stack for wbmain
move.l d0,-(SP)
clr.l -(SP) indicate: run from Workbench
bsr start2 I KNOW (WEIRD) JUST WANTED THE STACK RIGHT.
start2 move.l #9000000,d0
moveq #0,d1
jsr _LVOAllocMem(a6) kills any resident libraries.
tst.l d0
beq.s 1$
move.l d0,a1
move.l #9000000,d0
jsr _LVOFreeMem(a6)
1$ lea dosname,a1
moveq #0,d0
jsr _LVOOpenLibrary(a6) A6=EXECBASE
move.l d0,dosbase
lea gfxname(pc),a1
moveq #0,d0
jsr _LVOOpenLibrary(a6)
move.l d0,gfxbase
lea intname(pc),a1
moveq #0,d0
jsr _LVOOpenLibrary(a6)
move.l d0,intbase
bsr cut_plane
* bra.s close_int
* bsr pr_tit TITLE
allocate_chunks
bsr allocate_chip_half_track
move.l d0,a5 A5 = CHIP HALF TRACK
move.w #159-2,d7 ALLOCATE 158 5.5K bits
all_ch1 move.l d0,-(a7) ????????????????????????
bsr allocate_half_track
tst.l d0
dbeq d7,all_ch1
addq.w #2,d7
move.w #159,d6
sub.w d7,d6
move.w d6,dealloc_count SHOULD=158 IF ALL OK
tst.l d0
beq.s init_port BRANCH IF ABLE TO FULLY ALLOCATE FOR DISK
* beq.s not_enough_mem
move.l d0,-(a7)
move.b #$20,title_delimiter
init_port
bsr open_window
sub.l a1,a1
jsr _LVOFindTask(a6)
lea DiskPort(pc),a0
move.l d0,16(a0)
open_disk_device
lea DiskName(pc),a0
moveq #0,d0 Unit num
move.b msg2_drive(pc),d0
sub.b #'0',d0
moveq #0,d1
lea DiskIOReq(pc),a4 A4 = DISKIOREQ
move.l a4,a1
jsr _LVOOpenDevice(a6)
tst.l d0
bne not_enough_mem
*DOS INHIBIT NOW!
moveq #-1,d7
bsr dos_inhibit
round1 clr.l last_offset
move.b #'0',last_digit1
move.b #'0',last_digit2
move.b #'0',last_surface1
round2 bsr pr_src ASK FOR SOURCE DISK
bsr wait_for_return
bne check_mouse3
* WAIT FOR DISK INSERTION
wait1 bsr check_changestate
tst.l d1
bne.s wait1
bsr motor_on
bsr pr_rdg SAY "READING..."
bsr restore_last
* MOVEQ #0,D7 D7 = IO_OFFSET (ie sector number)
* MOVEQ #0,D6 D6 = HALF TRACK COUNT
move.l d7,first_offset
move.l a7,a3 A3 = PSEUDO STACK PTR
move.w dealloc_count(pc),d6
loop1 bsr read_half_track
tst.b IO_ERROR(A4)
beq.s no_error
bsr pr_bad PRINT BAD TRACK
no_error bsr check_mouse
subq.w #1,d6 DEC HALF TRACK COUNT
bmi read_finished
cmp.l #889856,d7 MAGIC NUMBER=2*79*11*512
beq.s read_finished
move.l #NUMSECS*TD_SECTOR,d0
move.l a5,a0
move.l (a3)+,a1
jsr _LVOCopyMemQuick(a6) transfer sector to public mem
add.l #NUMSECS*TD_SECTOR,d7
bra.s loop1
read_finished
bsr read_last_sector
tst.b IO_ERROR(A4)
beq.s no_error79
bsr pr_bad ATTENTION !! BAD SECTOR
no_error79
bsr motor_off
bsr save_last
wait3 bsr pr_msg2 TELL USER TO PUT DESTINATION DISK IN
wait600 bsr wait_for_return
bne check_mouse2 RETURN WAS NOT PRESSED
wait2 bsr check_changestate
tst.l d1
bne.s wait2
bsr check_write_protect
tst.l d1
beq.s write_enabled
bsr pr_wpt
bra.s wait600
write_enabled
bsr motor_on
bsr pr_wtg
bsr write_last_sector VERY IMPORTANT
MOVE.W dealloc_count(pc),D5 WRITE LAST 159 TRACKS
wloop1 bsr write_half_track WRITE BACK LAST TRACK READ
move.l -(a3),a0
move.l a5,a1
move.l #NUMSECS*TD_SECTOR,d0
jsr _LVOCopyMemQuick(a6)
cmp.l first_offset(pc),d7
beq.s wexit1
sub.l #NUMSECS*TD_SECTOR,d7
bsr check_mouse
dbf d5,wloop1
wexit1
bsr pr_msg1
bsr motor_off
close_trackdisk
move.l last_offset(pc),d0
cmp.l #901120,d0 MAGIC NUMBER=11*2*80*512
bne round2
once_more bsr pr_opt ASK TO COPY AGAIN
bsr wait_for_return
beq round1
cmp.b #'y',d0
beq round1
not_enough_mem_ui
moveq #0,d7
bsr dos_inhibit UN INHIBIT
move.l a4,a1
jsr _LVOCloseDevice(a6)
not_enough_mem
move.w dealloc_count(pc),d7
nem_1 move.l (a7)+,a1
bsr free_half_track
dbf d7,nem_1
bsr return_plane
close_int move.l intbase(pc),a1
jsr _LVOCloseLibrary(a6)
close_gfx move.l gfxbase(pc),a1
jsr _LVOCloseLibrary(a6)
bsr close_window
close_dos move.l dosbase(pc),a1
jsr _LVOCloseLibrary(a6)
the_end move.l entry_stack,SP ; restore stack pointer
tst.l _WBenchMsg
beq.s exitToDOS
jsr _LVOForbid(a6)
move.l _WBenchMsg,a1
jsr _LVOReplyMsg(a6)
exitToDOS moveq #0,d0
rts
check_mouse
btst #LeftMouse,PortA
bne.s no_button
move.l (a7)+,d0
check_mouse2
bsr motor_off
* move.l a4,a1
* jsr _LVOCloseDevice(a6)
check_mouse3
bsr pr_abort
bra once_more
no_button rts
read_last_sector
move.w #CMD_READ,IO_COMMAND(A4)
bsr pr_msg1
bsr.s inc_half_track_count
rls2 lea last_sector,a0
move.l A0,IO_DATA(A4)
move.l d7,d0
add.l #NUMSECS*TD_SECTOR,d0 V0.08 has fixed bug.
move.l D0,IO_OFFSET(A4)
move.l #TD_SECTOR,IO_LENGTH(A4) READ 0.5K
bra.s rd3
write_last_sector
move.w #CMD_WRITE,IO_COMMAND(A4)
bsr.s dec_half_track_count
bsr pr_msg1
bra.s rls2
write_half_track
move.w #TD_FORMAT,IO_COMMAND(A4)
bsr.s dec_half_track_count
bsr pr_msg1
bra.s rd2
read_half_track
bsr pr_msg1
bsr.s inc_half_track_count
move.w #CMD_READ,IO_COMMAND(A4)
rd2 move.l A5,IO_DATA(A4)
move.l D7,IO_OFFSET(A4)
move.l #NUMSECS*TD_SECTOR,IO_LENGTH(A4) READ/WRITE 5.5K
rd3 move.l a4,a1
jsr _LVODoIO(a6)
rts
inc_half_track_count
lea surface1(pc),a2
addq.b #1,(a2)
cmp.b #$32,(a2)
bne.s us_2
move.b #$30,(a2)
lea digit1+2(pc),a2
us_1 addq.b #1,-(a2)
cmp.b #$3a,(a2)
bne.s us_2
move.b #$30,(a2)
bra.s us_1
us_2 rts
dec_half_track_count
lea surface1(pc),a2
subq.b #1,(a2)
cmp.b #$2f,(a2)
bne.s us_2
move.b #$31,(a2)
lea digit1+2(pc),a2
us_3 subq.b #1,-(a2)
cmp.b #$2f,(a2)
bne.s us_4
move.b #$39,(a2)
bra.s us_3
us_4 rts
wait_for_return
* RETURN EQUAL- return pressed
move.l a6,-(a7)
lea in_buffer(pc),a0
move.l a0,d2
moveq #1,d3
move.l in_handle(pc),d1
move.l dosbase(pc),a6
jsr _LVORead(a6)
move.l (a7)+,a6
move.b in_buffer(pc),d0
cmp.b #13,d0
rts
motor_on
move.l #1,IO_LENGTH(a4)
do_mtr move.w #TD_MOTOR,IO_COMMAND(a4)
move.l a4,a1
jsr _LVODoIO(a6)
rts
motor_off
clr.l IO_LENGTH(a4)
bra.s do_mtr
check_write_protect
* RETURN D1=0 (write enable) D1<>0 (write protect)
move.w #TD_PROTSTATUS,IO_COMMAND(A4)
bra.s check2
check_changestate
* RETURN D1=0 (disk in drive) D1<>0 (no disk present)
move.w #TD_CHANGESTATE,IO_COMMAND(a4)
check2 move.l a4,a1
jsr _LVODoIO(a6)
move.l IO_ACTUAL(a4),d1
rts
pr_src lea msg5(pc),a0
moveq #msg5_end-msg5,d3
bra.s write_text
pr_opt lea opt_text(pc),a0
moveq #opt_text_end-opt_text,d3
bra.s write_text
pr_bad lea bad_text(pc),a0
moveq #bad_text_end-bad_text,d3
bra.s write_text
pr_abort lea abort_text(pc),a0
moveq #abort_text_end-abort_text,d3
bra.s write_text
pr_wpt lea wr_prot_txt(pc),a0
moveq #wr_prot_txt_end-wr_prot_txt,d3
bra.s write_text
pr_rdg lea reading_text(pc),a0
moveq #reading_text_end-reading_text,d3
bra.s write_text
pr_wtg lea writing_text(pc),a0
moveq #writing_text_end-writing_text,d3
bra.s write_text
pr_msg1 lea msg1(pc),a0
moveq #msg1_end-msg1,d3
bra.s write_text
pr_msg2 lea msg2(pc),a0
moveq #msg2_end-msg2,d3
write_text
* ENTRY A0 = text string, D3 = length
move.l a6,-(a7)
move.l a0,d2
move.l out_handle(pc),d1
move.l dosbase(pc),a6
jsr _LVOWrite(a6)
move.l (a7)+,a6
rts
open_window
move.l a6,-(a7)
move.l #MODE_NEWFILE,d2
lea title(pc),a0
move.l a0,d1
move.l dosbase(pc),a6
jsr _LVOOpen(a6)
move.l d0,out_handle
move.l d0,in_handle
move.l (a7)+,a6
rts
close_window
move.l a6,-(a7)
move.l dosbase(pc),a6
move.l out_handle(pc),d1
jsr _LVOClose(a6)
move.l (a7)+,a6
rts
allocate_chip_half_track
* RETURN D0 = BLOCK ADDR
moveq #MEMF_CHIP,d1
bra.s alc_tk_2
allocate_half_track
moveq #0,d1
alc_tk_2 move.l #NUMSECS*TD_SECTOR,d0 allocate 5.5K
jsr _LVOAllocMem(a6)
rts
free_half_track
* ENTRY A1= BLOCK ADDR
move.l #NUMSECS*TD_SECTOR,d0
jsr _LVOFreeMem(a6)
rts
cut_plane
move.l a6,-(a7)
bsr.s get_plane_count
cmp.b #1,d0
ble.s already_cut
move.l bm_Planes_1(a3),a0
move.w sc_Width(a4),d0
move.w sc_Height(a4),d1
move.l gfxbase(pc),a6
jsr _LVOFreeRaster(a6)
subq.b #1,bm_Depth(a3)
move.l a5,a6
jsr _LVORemakeDisplay(a6)
already_cut
move.l (a7)+,a6
rts
return_plane
move.l a6,-(a7)
bsr.s get_plane_count
cmp.b #1,d0
bgt.s not_cut
move.w sc_Width(a4),d0
move.w sc_Height(a4),d1
move.l gfxbase(pc),a6
jsr _LVOAllocRaster(a6)
move.l d0,bm_Planes_1(a3)
move.l d0,a1 MEMORY
moveq #0,d1 FLAGS
moveq #0,d0
move.w sc_Width(a4),d0
lsr.w #3,d0
mulu sc_Height(a4),d0 SIZE
jsr _LVOBltClear(a6)
addq.b #1,bm_Depth(a3)
move.l a5,a6
jsr _LVORemakeDisplay(a6)
not_cut move.l (a7)+,a6
rts
get_plane_count
move.l intbase(pc),a5
move.l ActiveScreen(a5),a4
lea sc_BitMap(a4),a3
move.b bm_Depth(a3),d0
rts
*DOS INHIBITER
dos_inhibit
* ENTRY D7=0 normal, D7=-1 subnormal
lea drivename(pc),a1
move.l a1,d1
move.l a6,-(a7)
move.l dosbase(pc),a6
jsr _LVODeviceProc(a6) DOS.LIBRARY
move.l (a7)+,a6
move.l d0,d6 D6=pid
lea DiskPort(pc),a1
move.l a1,d5 D5=reply port
* lea packet(pc),a4
* move.l a4,packet_addr
move.l d7,arg1
lea sp_Msg(pc),a1
move.l a1,sp_Pkt set sp_Pkt
lea sp_Pkt(pc),a1
move.l a1,ln_Name set ln_Name
move.l d5,dp_Port set dp_port
move.l #31,dp_Type set dp_Type
move.l d6,a0
lea packet(pc),a1
jsr _LVOPutMsg(a6) EXEC
move.l d5,a0
jsr _LVOWaitPort(a6) EXEC
move.l d5,a0
jsr _LVOGetMsg(a6) EXEC
rts
save_last move.l d7,d6
add.l #2*NUMSECS*TD_SECTOR,d6
move.l d6,last_offset
move.b digit1(pc),last_digit1
move.b digit1+1(pc),last_digit2
move.b surface1(pc),last_surface1
rts
restore_last
move.l last_offset(pc),d7
move.b last_digit1(pc),digit1
move.b last_digit2(pc),digit1+1
move.b last_surface1(pc),surface1
rts
CNOP 0,4
**************************************************
DiskName dc.b 'trackdisk.device',0
dosname dc.b 'dos.library',0
gfxname dc.b 'graphics.library',0
intname dc.b 'intuition.library',0
drivename dc.b 'DF0:',0
title dc.b 'RAW:100/80/312/40/PAULCOPY II © P.Hayter'
title_delimiter dc.b 0
dc.b 'ONE.SWAP',0
mega_end
msg5 dc.b 'Insert SOURCE disk in DF'
msg5_drive dc.b '0: (RETURN)'
msg5_end
reading_text dc.b 'Reading....',10
reading_text_end
writing_text dc.b 'Writing....',10
writing_text_end
msg1 dc.b 13,' Track '
digit1 dc.b '0'
dc.b '0'
dc.b ' Surface '
surface1 dc.b '0'
msg1_end
msg2 dc.b 'Insert TARGET disk in DF'
msg2_drive dc.b '0: (RETURN)'
msg2_end
wr_prot_txt dc.b 10,'* TARGET DISK IS WRITE PROTECTED *'
wr_prot_txt_end
abort_text dc.b 10,'USER ABORT!! ',10
abort_text_end
bad_text dc.b ' has a bad sector',10
bad_text_end
opt_text dc.b 13,'COPY AGAIN (y/n) ? '
opt_text_end
in_buffer dc.b ' '
lf dc.b 10
last_digit1 dc.b '0'
last_digit2 dc.b '0'
last_surface1 dc.b '0'
even
entry_stack dc.l 0
in_handle dc.l 0
out_handle dc.l 0
dosbase dc.l 0
intbase dc.l 0
gfxbase dc.l 0
last_offset dc.l 0
first_offset dc.l 0
_WBenchMsg dc.l 0
dealloc_count dc.w 0
cnop 0,4
DiskPort dc.l 0 ;0 ln_Succ
dc.l 0 ;4 ln_Pred
dc.w $0400 ;8 ln_Type
dc.l 0 ;10 ln_Pri
dc.b 0 ;14 mp_Flags
dc.b 31 ;15 mp_SigBit
dc.l 0 ;16 Task addr goes here
LH1 dc.l LH2 ;20 lh_head <MSG list
LH2 dc.l 0 ;24 lh_tail
dc.l LH1 ;28 lh_TailPred
dc.b 0 ;32 lh_Type
dc.b 0 ;33 l_pad
DiskIOReq dc.l 0 ;0
dc.l 0 ;4
dc.b 5 ;8 ln_Type
dc.b 0 ;9
dc.l 0 ;10
dc.l DiskPort ;14 mn_Reply_Port
dc.w 48 ;18 mn_Length
dc.l 0 ;20
dc.l 0 ;24
dc.w 3 ;28 IO_CMD
dc.w 0 ;30
dc.l 0 ;32
dc.l 1024 ;36 IO_LENGTH
dc.l 0 ;40 IO_DATA
dc.l 0 ;44 IO_OFFSET
dc.l 0
dc.l 0
cnop 0,4
packet
sp_Msg dc.l 0 mn_Node ln_Succ
dc.l 0 ln_Pred
dc.b 0 ln_Type
dc.b 0 ln_Pri
ln_Name dc.l sp_Pkt ln_Name
dc.l 0 mn_ReplyPort
dc.w 0 mn_Length
sp_Pkt dc.l sp_Msg dp_Link
dp_Port dc.l DiskPort dp_Port
dp_Type dc.l 31 dp_Type
dc.l 0 dp_Res1
dc.l 0 dp_Res2
arg1 dc.l 0 dp_Arg1
dc.l 0 dp_Arg2
dc.l 0 dp_Arg3
dc.l 0 dp_Arg4
dc.l 0 dp_Arg5
dc.l 0 dp_Arg6
dc.l 0 dp_Arg7
SECTION last_bit,bss_c
last_sector ds.l 128
END