[cc65] annoying problem with 1541

From: Chris Cureau <cmcureau1gmail.com>
Date: 2011-11-19 20:23:19
I guess this is probably not the place to ask, but I'm sure there's plenty
of Commodore people here!

This is supposed to be an internal function rom image that starts at $8000
on the C128.  I'm trying to use the U1 command from assembly to read Track
18, Sector 1...and even though I can't see anything wrong with the code I
keep getting an error 70 (no channel) from the drive.  Here's the
code...I'd really appreciate knowing what I'm doing wrong!

Thanks,
Chris

---

SETLFS = $ffba
SETNAM = $ffbd
OPEN = $ffc0
CHKIN = $ffc6
CKOUT = $ffc9
CLRCH = $ffcc
BASIN = $ffcf
BSOUT = $ffd2
CLALL = $ffe7
LOADADR = $1c01

.org $8000

; c128 Option ROM trickery

jmp start_code     ;Cold start vector
jmp start_code     ;Warm start vector
.byte $FF           ;> $01 for Autostart
.byte $43,$42,$4d   ;"CBM"
.byte $00,$00,$00   ;padding (easier on the eyes)


start_code:
lda #6  ;Kernal and Internal ROM (LOW), RAM(0), I/O
sta $d501  ;write to preconfiguration register A
sta $ff01  ;write to LCR A
sei  ;disable interrupts
jsr CLALL  ;close all files and channels

; set up command channel
lda #15  ;logical file number 15
ldx #8  ;device 8
ldy #15  ;secondary address 15
jsr SETLFS  ;set LA, FA, SA
lda #0  ;zero length file name
jsr SETNAM
jsr OPEN  ;open command channel

; set up for random access
lda #5 ;logical file number 2
ldx #8 ;device 8
ldy #5 ;secondary address 2
jsr SETLFS ;set LA, FA, SA
lda #1 ;single character file name
ldx #<buffer
ldy #>buffer ;set file name
jsr SETNAM
jsr OPEN ;open command channel

; grab info from Track 1, Sector 0 (block-read)
ldx #15  ;15 is active channel out
jsr CKOUT
ldx #0
ldy #12 ;length of file name (11 characters)
fname:
lda drivecmd,x ;pointer to file name
jsr BSOUT ;output to channel
inx
dey
bne fname ;loop to finish sending filename
jsr CLRCH ;restore default channel
ldx #5 ;set 2 as active channel in
jsr CHKIN
ldx #0
rdloop:
jsr BASIN ;input from channel
rl1:
sta $0400,x ;put to screen
inx
bne rdloop ;read 256 bytes
jsr CLRCH ;restore default channel
jsr CLALL ;close all channels
brk
; data
buffer:
.byte "#"
drivecmd:
.byte "u1:2 0 18 1", $0D
readcnt:
.byte 0

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sat Nov 19 20:23:37 2011

This archive was generated by hypermail 2.1.8 : 2011-11-19 20:23:41 CET