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 > 1541 force immediate job code handling
2018-10-31 13:55
Krill

Registered: Apr 2002
Posts: 2839
1541 force immediate job code handling

The canonical way to issue jobs on 1541 is something like
  lda #$80
  sta $00
: lda $00
  bmi :-; wait until job complete
if you don't want to do all the low-level disk access grunt work yourself. (I think 1571 allows for BRK to trigger the handler.)

Now, the problem is that the interrupt handler is triggered by a timer (see http://unusedino.de/ec64/technical/aay/c1541/ro41fe67.htm - the same timer which controls head stepping and movement speed), and that can take a few unnecessary bycles.

While looking for a solution to avoid that, this is what i came up with (realthing tests pending)
  lda #$80
  sei
  sta $00
  jsr $f2b0; force immediate job code processing
  cli
: lda $00
  bmi :-
Any objections to this approach or likely problems? :) (Looking funny at GRG and Magervalp.)
2018-10-31 15:43
cadaver

Registered: Feb 2002
Posts: 1153
Neat! How guaranteed the handler location is in 1541 clones / derivatives?
2018-10-31 15:47
Krill

Registered: Apr 2002
Posts: 2839
Dunno. The only ROM dump i ever came across with significant differences is from CX-500:
; Uncomment to compile the 1541 drivecode for Century Planning Corp. CX-500/Tecmate NPH-501C, which is not
; a clone, as the VIAs are located at $3800 and $5c00 due to simplified address decoding logics, and the ROM
; including the position of the GCR encoding and decoding tables (not used here) is entirely different as well.
;CX500                  = 1
Needless to say, it's a-okay to ignore that weirdo drive. :)
2018-10-31 19:52
MagerValp

Registered: Dec 2001
Posts: 1055
It's been years since I looked at that code, and I never quite got comfortable with the VIAs, but it seems like a reasonable approach. If you're using job codes though and not custom low level code, are you really that concerned about a few bycles being lost? Seems like the impact would be negligible.
2018-10-31 22:34
Krill

Registered: Apr 2002
Posts: 2839
Quoting MagerValp
I never quite got comfortable with the VIAs
Yeah, they're pretty crappy devices. But they're all we've got. :D

Quoting MagerValp
If you're using job codes though and not custom low level code, are you really that concerned about a few bycles being lost? Seems like the impact would be negligible.
Not really concerned, just something i came across again recently. And although the overall impact may not be so big (i wouldn't say negligible, though, it MAY shave off a revolution per track), if the solution is a few simple drop-in lines of code... why, why not? :)
2018-11-01 13:24
MagerValp

Registered: Dec 2001
Posts: 1055
Cause it's five precious bytes :)
2018-11-01 15:54
cadaver

Registered: Feb 2002
Posts: 1153
If the loader is uploaded only once, only increases the startup code size :) But yeah, it's great for cases where you'd just miss a revolution because of the delay. Could get a pretty reliable interleave 8 for Steel Ranger's mainpart (on-the-fly Exomizer), while the release version has 9.
2018-11-18 13:06
6R6

Registered: Feb 2002
Posts: 244
Well, It's been a while.
But you can probably do something like this ?

lda #$80
sta $00
brk ;force job code
nop
2018-11-18 13:27
tlr

Registered: Sep 2003
Posts: 1714
Quote: Well, It's been a while.
But you can probably do something like this ?

lda #$80
sta $00
brk ;force job code
nop


Interesting approach. Is it saaafe?
2018-11-18 13:59
6R6

Registered: Feb 2002
Posts: 244
It works on 1581.
1541 probably - But have to check first.
2018-11-18 14:18
Krill

Registered: Apr 2002
Posts: 2839
Quoting Krill
(I think 1571 allows for BRK to trigger the handler.)
So, no, BRK doesn't work on 1541. The appropriate condition "bit 6 of $1c0d set" isn't met, and the interrupt handler would just return. See http://unusedino.de/ec64/technical/aay/c1541/ro41fe67.htm (1541), which doesn't have this part the 1571 (default) interrupt handler has:
.8:9dce  BD 04 01    LDA $0104,X
.8:9dd1  29 10       AND #$10
.8:9dd3  F0 03       BEQ $9DD8
.8:9dd5  20 B0 F2    JSR $F2B0
As for 1581, while BRK ls the canonical way to do it just like on 1571, there's also an entry in the jump table at $ff54 called STROBE_CONTROLLER, which wraps all that in a neat subroutine.
http://unusedino.de/ec64/technical/aay/c1581/ro819598.htm
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
TheRyk/MYD!
Impetigo/Crescent
Mike
The MeatBall
Alta
rexbeng
ibux/Artline Designs..
The Human Co../Maste..
Guests online: 150
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 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.8)
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 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (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 Crackers
1 Mr. Z  (9.9)
2 S!R  (9.9)
3 Mr Zero Page  (9.8)
4 Antitrack  (9.8)
5 OTD  (9.8)

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