Commodore 128 Alive!

Commodore 128 => 128 programmers => BASIC => Topic started by: Hershey on May 25, 2010, 08:13 AM

Title: DEVICE NUMBER CHECK problem
Post by: Hershey on May 25, 2010, 08:13 AM
This program hangs at line 70 in winvice c128, except if you turn on tron , then it works or if you put in a print d command in side loop (line 70)

Have not tried it on a real c128 yet

10 CLR:FAST
20 PRINT CHR$(147)
30 PRINT "DEVICE NUMBER CHECK": PRINT
40 DN=PEEK(186):PRINT "DEVICE NUMBER";DN;":ACCESSED LAST":PRINT
50 FOR DV=8 TO 15:OPEN 1,DV,15:CLOSE 1
60 PRINT"DEVICE NUMBER";DV;": ";:A$="NOT PRESENT":IF ST<0 THEN 90
70 OPEN1,DV,15,"UJ":FOR D= 1 TO 1000:NEXT:INPUT#1,A,A$:CLOSE1
80 A$=RIGHT$(A$,4):IF LEFT$(A$,1)<>"1" THEN A$="DRIVE UNKNOWN"
90 PRINT A$:NEXT

Try it out see if it works for you
Hershey
Title: Re: DEVICE NUMBER CHECK problem
Post by: Hydrophilic on May 26, 2010, 02:37 PM
Trying it on my latest version of VICE (WinVICE v2.2) gives no problem, no matter what type of device I have setup (I tried 1541, 1541-II, 1571, and 1581)... this is with True Drive Emulation but without either TRON or PRINT D.

Because you are resetting the device, it might work better if you do the command seperate from OPEN.  For example

OPEN 1,DV,15:PRINT#1,"UJ":FOR D=1TO1000:NEXT:INPUT #1,A,A$:CLOSE1

Just a guess, because I have no problem with your original code...

I also tried it in VICE using file-system "device" and there was no crash/hang (although it did report SYNTAX ERROR instead of CBM DOS xxx).
Title: Re: DEVICE NUMBER CHECK problem
Post by: wte on May 27, 2010, 06:22 AM
In my programms I avoid the sec. address to prevent problems with the drive check.

I always use this subroutine:

10000 close15:open15,un:sysdec("e33e"),un:de=st:ifdethenclose15:return
10010 sysdec("e4d2"),un:de=128andst:close15:return

If I remember correctly the first line catches the "drive physically not present" error. The second one everything else. This works on a real C128!

Use the subroutine like this:

rem un = Unit
rem de = Disk Error
for un = 8 to 31
gosub 10000
if de then print "Drive"un": access fails. Error:"de
next
end

Regards WTE

PS: Don't ask me for more details, I programmed this routine more than 20 years ago  ;D
Title: Re: DEVICE NUMBER CHECK problem
Post by: Hershey on May 28, 2010, 01:46 AM
Thanks for the replies.
   
Now I know the code works in other vice systems.
Tried the code on my desktop and got the same responce, also tried wte's code and it stopped too,  at the end of prg no ready prompt. Which leaves me wondering what setting in vice I have to Change?

I just ran the code in vice c64 and it worked correctly. Now I really have to check setting in vice 128


Hershey
Title: Re: DEVICE NUMBER CHECK problem
Post by: wte on May 28, 2010, 09:27 AM
Quote from: Hershey on May 28, 2010, 01:46 AM
... also tried wte's code and it stopped too ...
OK, it also stopps on my Emulator.
But with "for un = 8 to 30" instead of "for un = 8 to 31" it is working in x128 Vice 2.0 (on my PC).
Vice does not love unit# 31.

Regards WTE
Title: Re: DEVICE NUMBER CHECK problem
Post by: gsteemso on May 29, 2010, 05:00 PM
Commodores (and VICE) don't like unit #31 because it's an invalid address. The Commodore serial bus is based on the IEEE-488 bus used in PETs, which uses commands with a 3-bit command field and a 5-bit address field. Should allow addresses from 0-31, right? well, sort of… address 31 is used as a broadcast address to tell all devices to stop doing whatever the command field specifies. The Kernal does little or no internal sanity checking on the numbers you try to use, so you can easily make it very confused by telling everything to stop talking when you actually meant to tell the nonexistent device #31 to do the opposite.
Title: Re: DEVICE NUMBER CHECK problem
Post by: wte on May 31, 2010, 07:54 AM
Quote from: gsteemso on May 29, 2010, 05:00 PM... address 31 is used as a broadcast address to tell all devices to stop doing whatever the command field specifies. ...
Wow! Thank's a lot. I didn't ever heard this before. (Maybe, because I've never asked  ;D ). I'm working since more than 30 years with Commodore Computers but I'm learning new things every year.

Regards WTE
EhPortal 1.34 © 2025, WebDev