#include <cbm.h> #include <stdio.h> char openFile(void){ char openErr; if ( (openErr = cbm_k_open()) ){ printf("Open failed: Return value = %d\n", openErr); } return openErr; } void main(void){ char drivecmd[] = "u0>\x09"; char openErr; cbm_k_setlfs (15, 8,15); cbm_k_setnam (drivecmd); if ( !(openErr = openFile()) ){ cbm_k_close(15); printf("Successfully changed device\n"); }else{ printf("Could not change device\n"); cbm_k_close(15); } }
OPEN 1,ID,15,"M-W"+CHR$(119)+CHR$(0)+CHR$(2)+CHR$(0)+CHR$(0):CLOSE 1
tightloop = 0; 1 might work better on 1541, 0 might work better on 1571 !to "busoff.prg", cbm * = $0801 !word 2048, 2017; link, line number !byte $9e; SYS !text "2064" !byte 0, 0, 0; end !text "+H!" lda #9 ; device number jsr listen !if tightloop { ldx #0 datalo: lda atnlo,x jsr $ffa8; IECOUT inx cpx #atnloend - atnlo bne datalo jsr $ffae; UNLSTN lda $ae ; FA jsr listen ldx #0 datahi: lda atnhi,x jsr $ffa8; IECOUT inx cpx #atnhiend - atnhi bne datahi jsr $ffae; UNLSTN lda $ae ; FA jsr listen } ldx #0 exec: lda command,x jsr $ffa8; IECOUT inx cpx #endcommand - command bne exec jmp $ffae; UNLSTN listen: ldx #0 stx $90 ; STATUS sta $ae ; FA jsr $ffb1; LISTEN lda #$6f ; open channel 15 (command/error channel) jsr $ff93; LSTNSA lda $90 bmi error rts error: brk command: !text "M-E"; memory-execute !word drivecode !pseudopc $0205 { drivecode: !if tightloop = 0 { ; the simple approach sei lda #$20 sta $1801; 2 MHz on 1571 lda #$00 ; ATNA cleared, CLK OUT low, DATA OUT low ldx #$10 ; ATNA set, CLK OUT low, DATA OUT low -- bit $1800; wait for ATN IN high bpl -- stx $1800; set ATNA - bit $1800; wait for ATN IN low bmi - sta $1800; clear ATNA bpl -- ; loop } else { ; the not-so-simple approach sei lda #$ff sta $1803; set all port bits as outputs lda #>$0300 sta $1801 lda #$7f sta $1802; set only ATN IN as input lda #$00 ; ATNA cleared, CLK OUT low, DATA OUT low ldx #$10 ; ATNA set, CLK OUT low, DATA OUT low sta $1800 jmp ($1800) } } endcommand: !if tightloop { atnlo: !text "M-W"; memory-write !word $0300 !byte $16 jmp ($1800) !byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 sta $1800 jmp ($1800) atnloend: atnhi: !text "M-W"; memory-write !word $0380 !byte $13 stx $1800 jmp ($1800) !byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 jmp ($1800) atnhiend: }