| |
ChristopherJam
Registered: Aug 2004 Posts: 1403 |
SEI considered harmful.
Once more for the people at the back:
Don't wrap your interrupt initialisation with SEI/CLI.
It's a bad way to avoid interrupts being dispatched while you're changing the IRQ pointer, because it then requires additional code to acknowledge any pending CIA IRQs that might trigger between the SEI being executed and you turning off the CIA timer or interrupt enable.
If you're coming from BASIC, just do this instead:
lda #$7f
sta $dc0d
..then change $01, set your IRQ pointer(s), and init your own raster and/or timer IRQ(s)
If you're coming from a previous part, ask your teammate to turn off any IRQs and acknowedge any requests before they pass the baton (cf 'IRQ recovery' link below) - then all you need to do is set up your own IRQ.
As previously flogged to death at
TIL: The instruction after SEI can be executed before a pending IRQ is handled
C-64 coding cargo cults
Best practice IRQ recovery |
|
... 36 posts hidden. Click here to view all posts.... |
| |
Krill
Registered: Apr 2002 Posts: 2940 |
My point was that the raster interrupt...
lda #0x01
sta 0xD019
; ... may trigger here
sta 0xD01A
; ... and then fire only here
rts
Should usually not be a problem, but... =) |
| |
spider-j
Registered: Oct 2004 Posts: 483 |
Okay. But I guess in my typical setup:
init mem –>
basicfade that ends with screen off (bit 4 of $D011 = 0) –>
setup IRQ chain –>
screen is turned on within the IRQs
that should never be a problem, because you can't turn on the screen in the middle of a frame. So if the IRQ chain is messed up in the first frame, it wouldn't matter, because screen is at the earliest turned on in the second frame anyway.
Or can you somehow trigger one of those "illegal" graphics mode while having bit 4 / $D011 zero in the middle of a frame? *scratchesHead* |
| |
MagerValp
Registered: Dec 2001 Posts: 1065 |
Some of you seem to be conflating initial basic startup, and linking a multipart demo. Basic startup can be reduced to a short piece of boiler plate, that yes, doesn't include sei/cli. Demo linking is however a completely different beast where anything goes and it's hard to make any authoritative statements. Linking without music skipping and hard to debug race conditions is an artform.
And good point about there being an unacknowledged raster irq waiting for you at startup, pretty sure that one has messed with me before. Initial state, state changes, and order of operations are critical when setting up irqs. For raster irqs I usually do a simple wait for $d012 to $ff before setting up. |
| |
spider-j
Registered: Oct 2004 Posts: 483 |
Quoting MagerValpLinking without music skipping and hard to debug race conditions is an artform.
That's correct. But I feel it would be less of a challenge if everyone in your group would properly setup and exit their parts as you instructed them to :-) |
| |
ChristopherJam
Registered: Aug 2004 Posts: 1403 |
Quoting KrillMy point was that the raster interrupt...
lda #0x01
sta 0xD019
; ... may trigger here
sta 0xD01A
; ... and then fire only here
rts
Should usually not be a problem, but... =)
True, but given that Spider Jerusalem already set $d012 to his desired raster line, that will only happen if that line starts just after the sta $d019 - which means it'll be happening at close enough to the desired time anyway. No need to fear for midscreen weirdness from an interrupt triggered on the wrong line altogether, as can happen without the Krill Precaution™ :D
(interestingly, according to some experiments I've just been doing, the RTS is executed before the interrupt service routine!) |
| |
spider-j
Registered: Oct 2004 Posts: 483 |
Just found this looking through our old trackmo framework documentation:
XD |
| |
Krill
Registered: Apr 2002 Posts: 2940 |
Okay then! =)
php
pla
ora #$04
pha
plp
|
| |
Martin Piper
Registered: Nov 2007 Posts: 699 |
Quote: Okay then! =)
php
pla
ora #$04
pha
plp
You beat me to it. :) |
| |
spider-j
Registered: Oct 2004 Posts: 483 |
Quoting KrillOkay then! =)
php
pla
ora #$04
pha
plp
*lol* Thank you Krill. Made my day :-) |
| |
Cruzer
Registered: Dec 2001 Posts: 1048 |
Wait a second... If the Kernal/Basic only uses NMIs, how come you can disable them with sei? I mean, if you do something like this:
!: inc $d020
jmp !-
You will see the code getting interrupted when pressing down keys. But start out with a sei, and there are no interruptions:
sei
!: inc $d020
jmp !-
|
Previous - 1 | 2 | 3 | 4 | 5 - Next |