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 > $dc0d madness
2010-09-07 12:27
TWW

Registered: Jul 2009
Posts: 545
$dc0d madness

how come a lot of people set up their raster IRQ's like:

lda #$01
sta $d01a
lda #$7f (?)
sta $dc0d

and not just simply:

ldx #$00 // I believe 0 = mask and 1 = don't mask but it isn't specified in the prog.ref.manual...
stx $dc0d // Mask out all CIA#1 IRQ's
inx
stx $d01a // Mask out all VICII IRQ's minus raster compare

Where does this "#$7f" come from?

or have i missed some kind of importaint point here?
2010-09-07 12:40
Mr. SID

Registered: Jan 2003
Posts: 424
AFAIK it works like this:
Bit 7 specifies if you want to clear or set the mask bits. If it's 0 it means clear. A mask bit is only affected by the clear operation, if the corresponding bit in dx0d is set to 1.

So e.g. this would only mask the Timer B IRQ, leaving the other mask bits unaffected:

lda #$02
sta $dc0d

And this would unmask Timer B again:

lda #$82
sta $dc0d

So #$7f masks all CIA IRQs. Makes sense? Or maybe I'm wrong too?
2010-09-07 12:40
Graham
Account closed

Registered: Dec 2002
Posts: 990
Because the register works quite different than you think.

Bit 7 of the register tells if the selected IRQ masking bits get cleared or set. You select an IRQ masking bit by having it's bit set. So if you write $03, the timer A and B IRQ masks will be cleared, but if you write $83 the masks will be set. This way you can modify single IRQ masks without touching the others.
2010-09-07 13:31
TWW

Registered: Jul 2009
Posts: 545
Alrigth then so a setting of a bitmask:

lda #$83
sta $dc0d

would ENABLE Timer A+B IRQ's from CIA#1

and consequently:

lda #$03
sta $dc0d

would DISABLE Timer A+B IRQ's from CIA#1.

Without touching the state of the other available IRQ's.



does it work in the same way for the VICII IRQ mask register aswell (only inverted use of bit #7)?

lda #$01
sta $d01a // Enable raster comp. IRQ

vs.

lda #$81
sta $d01a // Disable raster comp. IRQ?
2010-09-07 14:13
Mr. SID

Registered: Jan 2003
Posts: 424
No, the VIC has just one bit per IRQ source, if you don't want to affect the other ones, you have to mask out the bits yourself.
2010-09-07 16:15
Ninja

Registered: Jan 2002
Posts: 411
In almost any case you want to do a LDA $DC0D after clearing all the other CIA interrupts. Bonus point if you find out why by yourself (stuff like AAY64 might help you)...
2010-09-07 17:01
chatGPZ

Registered: Dec 2001
Posts: 11386
another bonus point for finding the flaw in

lda $dc0d
sta $dc0d

:)
2010-09-07 19:44
Oswald

Registered: Apr 2002
Posts: 5094
madness?!
t h i s i s SPARTAAAAAAAAAAAAAA!!!!!!!!!!!!!!!!!!11111
2010-09-08 00:17
TWW

Registered: Jul 2009
Posts: 545
Quote: In almost any case you want to do a LDA $DC0D after clearing all the other CIA interrupts. Bonus point if you find out why by yourself (stuff like AAY64 might help you)...

No fucking clue there was something like AAY64 around (now I know though) but before consulting documentation of such biblical proporsions I am going out on a limb to achieve my bonus point and guess that a LDA $dc0d would ack any outstanding CIA interrupts to avoid accendental triggering of latent CIA IRQ's.

Fucking hell that's one huge sentence eh?


@ Groepaz:

Uncertain what happens when you read bit #7 of $dc0d (@ work and no time to consult AAY64 or test it) but depending of the state of bit #7 you would then disable/enable any occured IRQ. But I'm sure it doesen't work this way anyway... If I got it half right does I gets its another bonus points?

@ Oswald:

freak!
2010-09-08 07:07
Ninja

Registered: Jan 2002
Posts: 411
Quoting TWW
Fucking hell that's one huge sentence eh?


Still you got the point :D

This can be a reason why some demo-parts crash on start "randomly". Forbid interrupts, clear some memory (during that time, a CIA-IRQ may appear and is waiting for interrupts to be allowed again), set up your VIC-IRQ which just clears $d019, allow interrupts - voila, CIA will trigger IRQs endlessly.
2010-09-08 10:10
TWW

Registered: Jul 2009
Posts: 545
What I find interesting is that SEI itself only inhibit activation of IRQs but don't stop them from setting bits high in $d019/$dc0d even during a sei-cli. An importaint fact to say the least.

On top of this special care regarding NMI which is totally unaffected by the sei-cli statement must be taken.

@ groepas:

After thinking about it I will say the following about your lda/sta $dc0d.

lda $dc0d // loads status of CIA#1 IRQs / Ack's any IRQs

if A & #%10000000 = 80 (some IRQ occured) then whichever IRQ occured will be masked after sta $dc0d.
if A & #%10000000 = 00 (no IRQ occured) then you would write #00 into $dc0d which means unmask no IRQs. which doesen't make any sense?!

So to summarise: If any CIA#1 IRQ(s) occurs, disable it/them. If no IRQ occurs pretend to be 'leet and shout loudly "I kill LAMERS for free!". (aka. nothing happens^^)

I want my bonus point. This gives me totally 2 points (I assume I got ninja's bonuspoint) and then I donate 1/2 a point to Oswald for his SPPPAAAARTTTAAAA comment. A considerable contribution to this discussion afterall :)
 
... 11 posts hidden. Click here to view all posts....
 
Previous - 1 | 2 | 3 - Next
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
Peacemaker/CENSOR/Hi..
Oxbow/Xenon
ΛΛdZ
Chesser/Blazon
B.A./QUANTUM
Sepa/OCD
theK/ATL
tlr
Guests online: 89
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Coders
1 Axis  (9.8)
2 Graham  (9.8)
3 Lft  (9.8)
4 Crossbow  (9.8)
5 HCL  (9.8)

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