;+------+-----+-----+---+---+---+----------------+---------------+ ;| Addr | CS0 | CS1 |A2 |A1 |A0 | Read (-IOR) | Write (-IOW) | ;+------+-----+-----+---+---+---+----------------+---------------+-----------+ ;| | 0 | 0 | X | X | X | ILLEGAL | ILLEGAL | | ;+------+-----+-----+---+---+---+----------------+---------------+-----------+ ;| 1000 | 0 | 1 | 0 | 0 | 0 | Data Port | Data Port | <--+ | ;| 1001 | 0 | 1 | 0 | 0 | 1 | Error Register | Precomp | | | ;| 1002 | 0 | 1 | 0 | 1 | 0 | Sector Count | Sector Count | Command | ;| 1003 | 0 | 1 | 0 | 1 | 1 | Sector Number | Sector Number | Block | ;| 1004 | 0 | 1 | 1 | 0 | 0 | Cylinder Low | Cylinder Low | Registers | ;| 1005 | 0 | 1 | 1 | 0 | 1 | Cylinder High | Cylinder High | | | ;| 1006 | 0 | 1 | 1 | 1 | 0 | Drive / Head | Drive / Head | | | ;| 1007 | 0 | 1 | 1 | 1 | 1 | Status | Command | <--+ | ;+------+-----+-----+---+---+---+----------------+---------------+-----------+ ;| 1008 | 1 | 0 | 0 | 0 | 0 | High Impedance | Not Used | Control | ;| ... | 1 | 0 | ... | High Impedance | Not Used | Block | ;| 100D | 1 | 0 | 1 | 0 | 1 | High Impedance | Not Used | Registers | ;| 100E | 1 | 0 | 1 | 1 | 0 | Altern Status | Device Control| | | ;| 100F | 1 | 0 | 1 | 1 | 1 | Drive Address | Not Used | <--+ | ;+------+-----+-----+---+---+---+----------------+---------------+-----------+ ;| | 1 | 1 | X | X | X | High Impedance | Not Used | | ;+------+-----+-----+---+---+---+----------------+---------------+-----------+ .eq IDEcs0 = $1000 ; CS0 .eq IDEdata = IDEcs0 + 0 .eq IDEerror = IDEcs0 + 1 .eq IDEnumSec = IDEcs0 + 2 ; number of sectors .eq IDElba0 = IDEcs0 + 3 ; starts counting from ONE !!! .eq IDElba1 = IDEcs0 + 4 .eq IDElba2 = IDEcs0 + 5 .eq IDElba3 = IDEcs0 + 6 .eq IDEstatus = IDEcs0 + 7 ; when reading .eq IDEcommand = IDEcs0 + 7 ; when writing .eq IDEcs1 = IDEcs0 + 8 ; CS1 .eq IDEcontrol = IDEcs0 + 14 .eq PortB2 = $1C00 .ba $0400 jmp L_000 ; floppy -> harddisk jmp L_100 ; harddisk -> floppy ; read data from floppy sector L_000 ldx #$80 ; read command jsr DiskCmd jsr CopyParms ; write the data to the IDE harddisk lda #$30 ; write sector sta IDEcommand ; give the command .... L_030 lda IDEstatus ; ready? bmi L_030 ; if not, -> wait ; .... and copy the data to the harddisk ldx #0 L_020 lda $0300,X sta IDEdata inx bne L_020 jsr IncSector jmp L_000 ; copy sector parameters to harddisk L_100 jsr CopyParms ; read the data from the IDE harddisk lda #$20 ; read sector sta IDEcommand ; give the command .... L_130 lda IDEstatus ; ready? bmi L_130 ; if not, -> wait ; .... and copy the data from harddisk ldx #0 l_120 lda IDEdata sta $0300,X inx bne l_120 ; write data to the floppy ldx #$90 ; write command jsr DiskCmd jsr IncSector jmp L_100 ; next floppy and harddisk sector IncSector inc LBA+1 bne SR1_00 inc LBA+2 bne SR1_00 inc LBA+3 bne SR1_00 inc LBA+4 SR1_00 inc Sector lda Sector ldy Ystore cmp TraSec,Y ; maximum sector for this track? bcc SR1_10 ; no, -> lda #0 sta Sector inc Track lda Track cmp TraCha,Y ; change # of sectors/track? bcc SR1_10 ; no, -> dec Ystore ; all tracks copied? bpl SR1_10 ; no, -> ; end program by removing previous JSR from stack pla pla lda PortB2 and #$F7 ; LED out sta PortB2 SR1_10 rts ; give the settings and command to the 1541 disk controller DiskCmd lda Track sta $06 lda Sector sta $07 stx $00 ; give command DiskCmd02 lda $00 ; command executed? bmi DiskCmd02 ; no, -> rts ; copy sector parameters to harddisk CopyParms ldx #4 CopyParms02 lda LBA,X sta IDEnumsec,X dex bpl CopyParms02 rts Track .by 1 Sector .by 0 TraSec .by $11,$12,$13,$15 ; sectors/track TraCha .by $24,$1F,$19,$12 ; tracks where # sectors/track change Ystore .by 3 LBA .by 1 ; rest will be filled in by DC3.PRG .en