Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user zschunky ! (Registered 2019-02-20) You are not logged in 
CSDb User Forums


Forums > C64 Coding > 1541 force immediate job code handling
2018-10-31 13:55
Krill

Registered: Apr 2002
Posts: 1108
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: 1079
Neat! How guaranteed the handler location is in 1541 clones / derivatives?
2018-10-31 15:47
Krill

Registered: Apr 2002
Posts: 1108
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: 952
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: 1108
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: 952
Cause it's five precious bytes :)
2018-11-01 15:54
cadaver

Registered: Feb 2002
Posts: 1079
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: 228
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: 1204
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: 228
It works on 1581.
1541 probably - But have to check first.
2018-11-18 14:18
Krill

Registered: Apr 2002
Posts: 1108
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
blendo75
DanPhillips
Didi/Laxity
pcollins/Excess
xIII/ATL/WOW
Guests online: 40
Top Demos
1 Unboxed  (9.7)
2 Uncensored  (9.7)
3 Edge of Disgrace  (9.7)
4 Coma Light 13  (9.6)
5 Comaland 100%  (9.6)
6 The Shores of Reflec..  (9.6)
7 Lunatico  (9.6)
8 Wonderland XII  (9.6)
9 C=Bit 18  (9.6)
10 X Marks the Spot  (9.5)
Top onefile Demos
1 Smile to the Sky  (9.6)
2 Daah, Those Acid Pil..  (9.5)
3 Dawnfall V1.1  (9.4)
4 FMX Music Demo  (9.4)
5 Crystal Gazer  (9.4)
6 Rewind  (9.4)
7 Pandemoniac Part 2 o..  (9.4)
8 Official X2018 Report  (9.4)
9 Arok 20 Invitation  (9.4)
10 Party Horse  (9.3)
Top Groups
1 PriorArt  (9.7)
2 Performers  (9.5)
3 Oxyron  (9.5)
4 Booze Design  (9.4)
5 Censor Design  (9.3)
Top Webmasters
1 Slaygon  (9.6)
2 Perff  (9.6)
3 Morpheus  (9.6)
4 Sabbi  (9.4)
5 CreaMD  (9.3)

Home - Disclaimer
Copyright © No Name 2001-2019
Page generated in: 0.16 sec.