Skip to content

Commit

Permalink
version 1.1, C64 version
Browse files Browse the repository at this point in the history
  • Loading branch information
wiebow committed May 25, 2017
1 parent d431dcc commit 3314d32
Show file tree
Hide file tree
Showing 9 changed files with 1,218 additions and 2 deletions.
48 changes: 46 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,46 @@
# d81writer
1541 ultimate 2 write tool
# d71/d81writer
A 1541 Ultimate 2 write tool
============================

Written by Ernoman and WdW.

Introduction
============

This C64 tool will enable you to use your 1541 Ultimate 2 cartridge (U2) to
write .D71 and .D81 images to a physical drive.

The C64 version uses the standard kernal calls, so operation is slow. A C128
version using burst write commands is in the works.

Preparations
============

Set your physical drive to another id than the emulated U2 drive, because having
two drives with the same device id on the serial bus is asking for trouble.

The diskette must be formatted before you can use it. It does not need
to be empty. In order to get a 1:1 copy it's best to format the diskette with
the index option, as the copy tool will not write empty sectors.

Enther the U2 cartridge and enable the command interface and the REU with at
least 1MB of memory.

Disable any cartridge in the U2 interface. Some cartridges, like the Retro
Replay, do not play nice and will cause the command interface to fail.

Put your image files somewhere on a USB or Micro SD card and insert it into the
U2.

When the tools starts, double check if you see the ultimate dos version appear
under the header. If this does not happen, re-check your U2 settings.


Usage
=====

1) Enter the type of image you want to write.
2) Enter the path to the folder containing the images files.
3) Type in the name of the image file.
4) Enter the destination drive device ID and watch the counter until it reaches
track 80 (for a D81 image) or 70 (for a D71 image)
Binary file added bin/d7181writer.prg
Binary file not shown.
204 changes: 204 additions & 0 deletions diskwrite64.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@

.import source "kernal.asm"

.label buffer = $fb // sector buffer zero page pointer

// --------------------------------------------------------------------------
// writes memory buffer to disk.
// write_track and write_sector strings need to be up to date.
// assumes channels 2 (buffer) and 15 (command) are open.

WRITE_SECTOR:
jsr RESET_BLOCK_POINTER

// send 256 bytes to the drive buffer.

ldx #2
jsr CHKOUT // use file 2 (buffer) as output.

ldy #0
!loop:
lda (buffer),y
jsr CHROUT
iny
bne !loop-

// send drive buffer to disk.

ldx #15
jsr CHKOUT // use file 15 (command) as output.

ldy #0
!loop:
lda u2_command,y // read byte from command string.
jsr CHROUT // send to command channel.
iny
cpy #u2_command_end - u2_command
bne !loop-

jsr CLRCHN // execute sent command
rts

u2_command: .text "U2 2 0 "
write_track: .text "00 "
write_sector: .text "00"
u2_command_end:

// --------------------------------------------------------------------------
// resets block pointer to position 0
// assumes channel 15 is open, and channel 2 is used for block operations

RESET_BLOCK_POINTER:
ldx #15
jsr CHKOUT // use file 15 (command) as output.

ldy #0
!loop:
lda bp_command,y // read byte from command string
jsr CHROUT // send to command channel
iny
cpy #bp_command_end - bp_command
bne !loop-
jsr CLRCHN // execute sent command
rts

bp_command:
.text "B-P 2 0"
bp_command_end:

// --------------------------------------------------------------------------
// Sets 1571 drive in double sided mode

SET_1571_MODE:
ldx #15
jsr CHKOUT // use file 15 (command) as output.

ldy #0
!loop:
lda ds_command,y // read byte from command string
jsr CHROUT // send to command channel
iny
cpy #ds_command_end - ds_command
bne !loop-
jsr CLRCHN // execute sent command
rts

ds_command:
.text "U0>M1"
ds_command_end:


// --------------------------------------------------------------------------
// opens drive buffer (#) as logical file 2.

OPEN_BUFFER_CHANNEL:
lda #2 // logical file number
ldx device // device number
ldy #2 // command number
jsr SETLFS

lda #1
ldy #>buffer_name
ldx #<buffer_name
jsr SETNAM
jsr OPEN
!exit:
rts

buffer_name:
.text "#"

// --------------------------------------------------------------------------
// closes the buffer channel (2)

CLOSE_BUFFER_CHANNEL:
lda #2
jmp CLOSE

// --------------------------------------------------------------------------
// opens a command channel (15)

OPEN_COMMAND_CHANNEL:
lda #15 // logical file number
ldx device // device number
ldy #15 // command number
jsr SETLFS

lda #0 // no file name
jsr SETNAM

jsr OPEN // open channel, using parameters
!exit:
rts

// --------------------------------------------------------------------------
// closes command channel (15) and files and resets all i/o

CLOSE_COMMAND_CHANNEL:
lda #15
jmp CLOSE

// --------------------------------------------------------------------------

// Zero track administration. put 01 in string.
ZERO_TRACK:
lda #$30
sta write_track+0
lda #$31
sta write_track+1
rts

// Zero sector administration. put 00 in string.
ZERO_SECTOR:
lda #$30
sta write_sector+0
sta write_sector+1
rts

// text Advance one track
NEXT_TRACK:
inc write_track+1
lda write_track+1
cmp #$3a
beq !skip+
rts
!skip:
inc write_track+0
lda #$30
sta write_track+1
rts

// text Advance one sector
NEXT_SECTOR:
inc write_sector+1
lda write_sector+1
cmp #$3a
beq !skip+
rts
!skip:
inc write_sector+0
lda #$30
sta write_sector+1
rts

// --------------------------------------------------------------------------
// 1571 sectors per track
// sectors start at 0, tracks start at 1

sectors_1571:
.byte 0
// side 1, track 1
.byte 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21 // 17
.byte 19,19,19,19,19,19,19 // 7
.byte 18,18,18,18,18,18 // 6
.byte 17,17,17,17,17 // 5
// side 2, track 36
.byte 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21
.byte 19,19,19,19,19,19,19
.byte 18,18,18,18,18,18
.byte 17,17,17,17,17

// --------------------------------------------------------------------------

sector_buffer:
.fill 256,$f0
25 changes: 25 additions & 0 deletions kernal.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

#importonce

// kernal jump table
// exits with carry bit set indicate an error

.const ACPTR = $FFA5
.const CHKIN = $FFC6
.const CHKOUT = $FFC9
.const CHRIN = $FFCF
.const CHROUT = $FFD2
.const CIOUT = $FFA8
.const CINT = $FF81
.const CLALL = $FFE7
.const CLOSE = $FFC3
.const CLRCHN = $FFCC
.const GETIN = $FFE4
.const LISTEN = $FFB1
.const LOAD = $FFD5
.const OPEN = $FFC0
.const PLOT = $FFF0
.const SAVE = $FFD8
.const SETLFS = $FFBA
.const SETNAM = $FFBD
.const UNLSN = $FFAE
Loading

0 comments on commit 3314d32

Please sign in to comment.