OPEN - return values on IDE64

29 views
Skip to first unread message

Tomas Vondracek

unread,
Jun 12, 2017, 2:50:12 AM6/12/17
to id...@googlegroups.com
What is the correct way how to treat "device not present error" after OPEN routine calling on IDE64?

I have a tool which requires IDE64 device. There is string "IDE" at $DE60. User types a device number and the tool sends command "UI" to this number. If the device is present, I will parse the string from error channel. How can I check, if there isn't any device?

I found Graham's DOS tutorial on Codebase, he uses "BCS error" after OPEN, but it works for numbers 8 or 9. E.g. number 18 isn't any device, but the OPEN returns C=0. I detected those values after OPEN:

dev.num 8 (1541): A=$08, V=1, C=0
dev.num 9 (no device): A=$05, V=0, C=1
dev.num 12 (IDE64 disk): A=$0C, V=1, C=0
dev.num 18 (no device): A=$12, V=0, C=0

It looks like if the V=0 in status register is the right flag. Is it right?


LHS



lda #$2
ldx #<command
ldy #>command
jsr SETNAM

lda #$f
ldx $ba
ldy #$f
jsr SETLFS
jsr OPEN

php
sta $400
pla
sta $401

command
.text "ui"

Kajtár Zsolt

unread,
Jun 12, 2017, 3:56:00 AM6/12/17
to id...@googlegroups.com
> What is the correct way how to treat "device not present error" after OPEN
> routine calling on IDE64?

0 OPEN 15,12,15:CLOSE 15
5 IF ST THEN PRINT"DEVICE NOT PRESENT":END

Or the equivalent in assembly. This is what the "@#xx" command does:

jsr bas_open_common
jsr bas_close
lda #KERNAL.DEVICE_NOT_PRESENT
bit Status
bmi bas_ioerror

> I have a tool which requires IDE64 device. There is string "IDE" at $DE60.
> User types a device number and the tool sends command "UI" to this number.
> If the device is present, I will parse the string from error channel. How
> can I check, if there isn't any device?

Please note that some serial drives may crash if you don't leave enough time
between UI and reading the result. Also UI reverts to the "root" partition on
1581.

> I found Graham's DOS tutorial on Codebase, he uses "BCS error" after OPEN,
> but it works for numbers 8 or 9. E.g. number 18 isn't any device, but the
> OPEN returns C=0. I detected those values after OPEN:

He's not detecting device not present with that check.

> dev.num 8 (1541): A=$08, V=1, C=0 dev.num 9 (no device): A=$05, V=0, C=1
> dev.num 12 (IDE64 disk): A=$0C, V=1, C=0 dev.num 18 (no device): A=$12,
> V=0, C=0
>
> It looks like if the V=0 in status register is the right flag. Is it
> right?

No, don't do that, V is undefined. Open, close secondary address 15 without
file name. If ST=0 then open again for real.

--
-soci-

signature.asc

Greg King

unread,
Jun 12, 2017, 12:55:22 PM6/12/17
to IDE64
On Monday, June 12, 2017 at 3:56:00 AM UTC-4, soci/singular wrote:
> What is the correct way how to treat "device not present error" after OPEN
> routine calling on IDE64?

0 OPEN15,12,15:CLOSE15
5 IFSTTHENPRINT"DEVICE NOT PRESENT.":END

Or the equivalent in Assembly. This is what IDEDOS's "@#xx" command does:

   jsr bas_open_common
   jsr bas_close
   lda #KERNAL.DEVICE_NOT_PRESENT
   bit Status
   bmi bas_ioerror

This is how you should write it:

 lda #0
 jsr SETNAM
 lda
#15
 ldx $ba
 ldy
#15
 jsr SETLFS
 jsr OPEN
 jsr CLOSE
 jsr READST
 asl a
 
bcs Not_There

Kajtár Zsolt

unread,
Jun 13, 2017, 2:21:47 AM6/13/17
to id...@googlegroups.com
> This is how you should write it:
>
> lda #0
> jsr SETNAM
> lda #15
> ldx $ba
> ldy #15
> jsr SETLFS
> jsr OPEN

lda #15 ; channel needed!

> jsr CLOSE
> jsr READST
> asl a
> bcs Not_There

Otherwise fine, this is how it should be done.

Those functions used in the DOS wedge included channel numbers and more
therefore out of context they were incomplete.

--
-soci-

signature.asc

Comos

unread,
Jun 14, 2017, 2:12:07 PM6/14/17
to IDE64
Is there another occurrence, that when calling OPEN,CLOSE,that the negative flag can get set? For a drive detection, I allways just did (simplified syntax) OPEN15,DR,15:CLOSE15 and BMI when the requested drive is not present.

Dne úterý 13. června 2017 8:21:47 UTC+2 soci/singular napsal(a):

Greg King

unread,
Jun 14, 2017, 4:11:06 PM6/14/17
to IDE64
On Wednesday, June 14, 2017 at 2:12:07 PM UTC-4, Comos wrote:
Is there another occurrence, that when calling "OPEN,CLOSE", that the negative flag can get set? For a drive detection, I always just did (simplified syntax) "OPEN15,DR,15:CLOSE15" and "BMI" when the requested drive is not present.


Dne úterý 13. června 2017 8:21:47 UTC+2 soci/singular napsal(a):
> This is how you should write it:
>
>  lda #0
>  jsr SETNAM
>  lda #15
>  ldx $ba
>  ldy #15
>  jsr SETLFS
>  jsr OPEN

   lda #15  ; channel needed!

>  jsr CLOSE
>  jsr READST
>  asl a
>  bcs Not_There

Otherwise fine, this is how it should be done.

Yes.  The call to READST is the official, portable way of getting the status.  But instead, you can do what READST does:

 ...
 jsr CLOSE
 bit STATUS
   ; $90 on C64
 bmi
Not_There

Pawel Krol

unread,
Jun 15, 2017, 10:25:20 AM6/15/17
to id...@googlegroups.com
I have just tested it with different device numbers and different
devices attached to and removed from a computer.

Works like a charm! Thanks everyone!

PK
Reply all
Reply to author
Forward
0 new messages