Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > AR/RR fastloader, command channel & device number other than 8
2019-03-20 22:25
cadaver

Registered: Feb 2002
Posts: 1153
AR/RR fastloader, command channel & device number other than 8

I'm tinkering with a loader / boot system where it first sends the "UI" command on the command channel to read back the device init-time string & detect the device type. Similar to what the Easyprog fastloader (ELoad) does.

Seems that when the device number is something other than 8, and AR/RR fastloader has been enabled, reading the command channel will get stuck inside Kernal.

Using device number 8 works fine. Not enabling AR/RR fastloader (normal reset) also works.

Anyone else seen this or have an explanation? Probably this is something that I shouldn't bother too much trying to work around, since there are ways the user can fix it :)
2019-03-20 22:50
chatGPZ

Registered: Dec 2001
Posts: 11089
You shouldnt use the drive message for detection anyway, its extremely unreliable :)
2019-03-20 23:20
cadaver

Registered: Feb 2002
Posts: 1153
Assume 1541 if unidentified :)

In seriousness, the ID string method is nice for not needing to push the detection / drivecode patching code to the drive first, which results in faster startup.
2019-03-20 23:25
chatGPZ

Registered: Dec 2001
Posts: 11089
yeah ok, that could work good enough in practise.

the problem you are describing seems kinda odd though. is it really a AR issue? would be really weird :)
2019-03-20 23:28
Krill

Registered: Apr 2002
Posts: 2821
I'm reading the drive ROM at strategic places using M-R to detect the model, seems to work fine (and shouldn't be noticably slower than sending UI = drive reset, then reading and parsing the init string).

Any better methods? :)
2019-03-20 23:37
cadaver

Registered: Feb 2002
Posts: 1153
groepaz: It looks like the combination of AR/RR loader and the device number, and should be possible to reproduce in VICE too.

The code reading the cmd channel shouldn't be anything special, SETNAM with 'UI', SETLFS 15,<devicenum>,15, OPEN, CHKIN, then CHRIN until status bit $40 is set. I'm running it inside stack but it shouldn't be a stack overwrite issue.

Krill: that's probably the most optimal. I used to send the whole drivecode, doing all detection on drive side, and then seeing if it actually starts to run (by checking if the lines change state). But the ID method is needed for SD2IEC in any case.

Btw. it seems that on 1541 the reset is very fast. On 1581 and above it takes noticeable time. :)
2019-03-20 23:39
chatGPZ

Registered: Dec 2001
Posts: 11089
beware: depending on the ROM in the 1541 you need to wait a bit before issueing any commands or it will indeed hang and wait forever
2019-03-20 23:44
Krill

Registered: Apr 2002
Posts: 2821
Quoting cadaver
But the ID method is needed for SD2IEC in any case.
How does SD2IEC respond to M-R or M-E? My method so far has been to M-R $0300 in drive RAM, then upload and execute a small routine to flip (EOR #$FF) the value at $0300 and then M-R it again. If no change, fallback to KERNAL API.
2019-03-21 00:35
cadaver

Registered: Feb 2002
Posts: 1153
M-R on SD2IEC returns bytes from the drive ROM. M-E initiates one of the firmware fastloader implementations if the data checksum / address from M-W matches.

In my case I need to know that it's specifically SD2IEC, to know I can send the "eload1" string to get a somewhat sane timed 2-bit fastload protocol. Your method would be good for getting a negative result (as intended for the fallback)
2019-03-21 07:07
Flavioweb

Registered: Nov 2011
Posts: 442
In my loader i use the "UJ" command to reset drive then, after a delay to wait drive reset, i read the error channel and i can found which drive is by pattern matching the string drive send...
Seems to work also on devices !=8 even if ar/rr fastload is enabled.
2019-03-21 08:48
Krill

Registered: Apr 2002
Posts: 2821
Quoting cadaver
In my case I need to know that it's specifically SD2IEC, to know I can send the "eload1" string to get a somewhat sane timed 2-bit fastload protocol.
Can you read the error channel after sending the "eload1" string to SD2IEC? Because any other drive would return error 31, syntax error.
2019-03-21 08:51
Krill

Registered: Apr 2002
Posts: 2821
Quoting Flavioweb
In my loader i use the "UJ" command to reset drive then, after a delay to wait drive reset, i read the error channel and i can found which drive is by pattern matching the string drive send...
Seems to work also on devices !=8 even if ar/rr fastload is enabled.
That seems to be pretty much exactly what cadaver does. Except it works with AR/RR and devices on #9 and up.
2019-03-21 08:59
cadaver

Registered: Feb 2002
Posts: 1153
Thanks. I have the drive stuck in the idle loop and computer also waiting after CHKIN, so I'll check my sequence of calls, possibly a better idea to close the command channel first, then reopen before reading.
2019-03-21 09:00
cadaver

Registered: Feb 2002
Posts: 1153
Quote: Quoting cadaver
In my case I need to know that it's specifically SD2IEC, to know I can send the "eload1" string to get a somewhat sane timed 2-bit fastload protocol.
Can you read the error channel after sending the "eload1" string to SD2IEC? Because any other drive would return error 31, syntax error.


Sorry, that's bytes sent in a M-W command, so an actual drive would accept it just fine. The bytes need to also be executed (M-E), so a drive would crash..
2019-03-21 09:37
cadaver

Registered: Feb 2002
Posts: 1153
OK.. seems I have a minimal repro case which can be done in BASIC. Load any file with fastloader on drive 9, then

NEW
1 OPEN15,9,15,"UI"
2 GET #15,A$:PRINT A$;:GOTO2

Should get stuck without printing anything.
I'm using Retro Replay 3.8Q. Though I believe I got the same result with AR6. Will do further testing.
2019-03-21 09:39
Krill

Registered: Apr 2002
Posts: 2821
Quoting cadaver
Sorry, that's bytes sent in a M-W command, so an actual drive would accept it just fine. The bytes need to also be executed (M-E), so a drive would crash..
Sigh. That's a pretty poor design committed by the ELoad inventor.
2019-03-21 09:45
Krill

Registered: Apr 2002
Posts: 2821
Quoting cadaver
Your method [of seeing whether the drive can execute uploaded code] would be good for getting a negative result (as intended for the fallback)
The only other "drive" than SD2IEC that can't execute custom code i came across is VICE with disabled true drive emulation. The latter might probably survive uploading the "eload" string and "executing" it just fine (after the initial safe M-E check). If so... :)
2019-03-21 10:14
cadaver

Registered: Feb 2002
Posts: 1153
Yeah, but in case the drive is an actual SD2IEC, then you'd want to continue with the ELoad protocol. And with VICE fast emu or IDE64, you'd want to continue with Kernal calls, so you'd still need to distinguish between.

You kind of can do this, by watching the $a5 serial bus variable, if that is unchanged (or also if you get an error at any point while sending M-W etc.), you know it's not an actual serial device.
2019-03-21 10:48
cadaver

Registered: Feb 2002
Posts: 1153
Hmm.. probably I'll just reverse my detection sequence. I was trying to be (too) clever by having multiple loader implementation files and choosing them with an initial bootpart, which uses the UI command.

But if I just load the full loader first, I can try uploading the drivecode first, and if that fails, proceeding to the ELoad / Kernal load decision.

It appears I get the drive 9 lockup on using the UI command after AR turbo load, even if I load a file byte-by-byte (CHRIN) inbetween. So yeah, best to use it only after verifying the drive isn't arbitrary drivecode capable.
2019-03-21 11:18
cadaver

Registered: Feb 2002
Posts: 1153
Even shorter repro case with the AR/RR wedge command:

Load something on device 9 with fastload
@UI
@

-> device not present, which is cause of the lockup if you just persist on trying to read from it :)
2019-03-21 11:31
Flavioweb

Registered: Nov 2011
Posts: 442
Quoting cadaver
Even shorter repro case with the AR/RR wedge command:

Load something on device 9 with fastload
@UI
@

-> device not present, which is cause of the lockup if you just persist on trying to read from it :)


Yes... but:
@UJ
@
works fine.
And it works also on Sd2IEC, Vice Virtual Drive and Ide64...
2019-03-21 12:23
cadaver

Registered: Feb 2002
Posts: 1153
Cool, thanks!

EDIT: UJ is unfriendlier in the sense that you actually do have to wait until the drive is responsive again, else you'll lockup. So yeah.. probably still have to go the upload drivecode first route :)
2019-03-21 12:56
Flavioweb

Registered: Nov 2011
Posts: 442
I guess rr/ar leave some drivecode running after a load, so maybe you go into troubles uploading some code to drive...
Just guessing eh...
2019-03-21 13:07
cadaver

Registered: Feb 2002
Posts: 1153
Possibly it messes the drive OS state some way, and only for device != 8. After the UI command, the drive appears to be in the idle loop, not responding to anything the computer would send under ATN.

In my tests uploading new drivecode always works fine even after AR fastload.
2019-03-22 11:22
cadaver

Registered: Feb 2002
Posts: 1153
Got info from GRG, the problem stems from the AR fastloader setting $1802 on the fastload-enabled drive, but not resetting it. It's possible to M-W the correct value back in to fix, though that's making an assumption the drive is a 1541 :)
2019-03-22 13:41
Krill

Registered: Apr 2002
Posts: 2821
cadaver: Do you save onto the disk?

If not, you can change the DOS version marker in the BAM (3rd byte on track 18, sector 0) from $41 ('A') to something else.
Trying to save (without prior "UI" command and AR/RR problems) would yield DOS mismatch error 73, which has the init string in the message.

Now, of course, no idea if that behaviour is implemented consistently across all weirdo drives. :)
2019-03-22 14:28
cadaver

Registered: Feb 2002
Posts: 1153
Yes, I save using jobcodes to write on preallocated sectors (or directly via Kernal on fallback loader)

But as all solutions seem a bit nasty, I went ahead and reversed my detection strategy, so drivecode-capable drives no longer receive the UI command / string detection at all, only SD2IEC.
2019-03-22 16:21
Krill

Registered: Apr 2002
Posts: 2821
That seems like a sane thing to do. :)

How do you detect the real-drive model now?
2019-03-22 17:08
cadaver

Registered: Feb 2002
Posts: 1153
I upload a monolithic drivecode from about $0400 to $06ff, it contains a detection based on Dreamload (reading strategic ROM locations), then it patches itself for the drive model, and signals to the C64 with the DATA line. C64 side contains a delay loop to watch for that signal.

Actually just committed the stuff to https://github.com/cadaver/c64gameframework/blob/master/loader.s
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
skull
grasstust/Hoaxers
Holy Moses/Role
kbs/Pht/Lxt
Guests online: 215
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 The Ghost  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.9)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Graphicians
1 Sulevi  (10)
2 Mirage  (9.8)
3 Lobo  (9.7)
4 Mikael  (9.7)
5 Archmage  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.083 sec.