| |
Testa Account closed
Registered: Oct 2004 Posts: 197 |
read $dc0d
when i set up a raster irq i always do lda #$7f sta $dc0d lda $dc0d.. no problem but there is one thing i dont get:
at $ea7e there is also a lda $dc0d.. can i savely skip the lda $dc0d in the irq set up and end the irq with a jmp $ea7e... or is there a diffirence??? |
|
| |
Ninja
Registered: Jan 2002 Posts: 411 |
I guess your IRQs are all VIC-based. So, I would recommend to clear the CIA-irq-latch once right after disabling the CIA-IRQs (that's what you seem to do anyhow). Then, you don't need to clear it in every VIC-based IRQ.
Besides this, there is no difference if you read the latch in your code or the ROM does it for you. As long as it gets read somehow somewhere... |
| |
MagerValp
Registered: Dec 2001 Posts: 1078 |
Just do lda #$7f sta $dc0d *without* using SEI. If the IRQ is triggered while you're setting the control register, the kernal IRQ handler will clear $dc0d for you before continuing. |
| |
HCL
Registered: Feb 2003 Posts: 728 |
I have another related question.. I think i've heard something like when you enter an interrupt, you can tell from a certain register flag if you enterer because of a raster interrupt or a timer interrupt (vic or cia).. Something like
tehIrq:
bvs rasterIrq
bvc timerIrq
The above example doesn't work (i tried), but it should be something similar.. The best alternative i've figured out myself is:
tehIrq
pha
lda $dc0d
bpl rasterIrq
bmi timerIrq
..but that's not like the coder pR0n i want to do :/. Anyone? |
| |
Ninja
Registered: Jan 2002 Posts: 411 |
HCL: This is most probably a misunderstanding. You can distingiush between a BRK and an IRQ using the B-flag. But not VIC or CIA.
What I usually use to distinguish is:
ASL $D019
BCS VIC
...CIA here...
Bonus: you get the acked vic_irq for free (and a carry in a consistent state, woohoo!) ;) |
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
Quote: I have another related question.. I think i've heard something like when you enter an interrupt, you can tell from a certain register flag if you enterer because of a raster interrupt or a timer interrupt (vic or cia).. Something like
tehIrq:
bvs rasterIrq
bvc timerIrq
The above example doesn't work (i tried), but it should be something similar.. The best alternative i've figured out myself is:
tehIrq
pha
lda $dc0d
bpl rasterIrq
bmi timerIrq
..but that's not like the coder pR0n i want to do :/. Anyone?
This is how I normally do it:
lsr $d019 ;ack potential raster irq and move the state to carry.
bcs rasterirq
timerirq:
bit $dc0d ;since it wasn't a raster irq, then it was a timer => ack it.
rti
rasterirq:
rti
|
| |
Ninja
Registered: Jan 2002 Posts: 411 |
JackAsser: You cycle waster; jump to $dc0c after setting it to $40! ;D |
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
Quote: JackAsser: You cycle waster; jump to $dc0c after setting it to $40! ;D
Ofcourse... but this was the school book example. :D |
| |
Ninja
Registered: Jan 2002 Posts: 411 |
school-book example? for HCL? :) |
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
Quote: school-book example? for HCL? :)
Well, the "BEST" alternative he came up with was right out lame. ;D Wouldn't wanna raise the bar too high. |
| |
Ninja
Registered: Jan 2002 Posts: 411 |
*rotfl* :) |
| |
Testa Account closed
Registered: Oct 2004 Posts: 197 |
ok boys thanks for the info... very nice.. |
| |
CreaMD
Registered: Dec 2001 Posts: 3057 |
When I'm stumbling over debates like this I wonder if god gives me the signal that c64 scene is still kicking some major ass. I'm very thankful for that. |
| |
HCL
Registered: Feb 2003 Posts: 728 |
Quote: JackAsser: You cycle waster; jump to $dc0c after setting it to $40! ;D
Hmm, that one beats me.. or did you mean setting it to $4c?! $40 is RTI on my hardware :).
Ok, thanx guys! Yeah, it must have been the BRK/IRQ i had in mind somewhere..
So.. in this case it seems like ASL $d019 and LSR $d019 gives the same result!?
TFM says ($d019):
Bit 7: 1 = IRQ has been generated.
Bit 0: Raster Compare IRQ Flag (see $D012).
|
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
Quote: Hmm, that one beats me.. or did you mean setting it to $4c?! $40 is RTI on my hardware :).
Ok, thanx guys! Yeah, it must have been the BRK/IRQ i had in mind somewhere..
So.. in this case it seems like ASL $d019 and LSR $d019 gives the same result!?
TFM says ($d019):
Bit 7: 1 = IRQ has been generated.
Bit 0: Raster Compare IRQ Flag (see $D012).
Ofcourse ASL and LSR is the same since either bit 7 or bit 0 can be used to check the state of the raster IRQ.
A software IRQ generated by a BRK opcode can indeed be polled by fetching the cpu status word using the PLP opcode.
Placing #$40 (RTI) on $dc0c is useful since the 6502 always fetches two consecutive bytes (and dismiss the last one in case of NOP, RTI etc.). Hence the CPU will actually read $dc0d (ack the timer irq) then you jump to $dc0c.
jmp $dc0c; rti = 3c+rti
bit $dc0c; rti = 4c+rti
One cycle saved!
|
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
rti always reads the byte behind the rti aswell, so it will ack the interrupt. |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
Quote: When I'm stumbling over debates like this I wonder if god gives me the signal that c64 scene is still kicking some major ass. I'm very thankful for that.
no it does not. |
| |
HCL
Registered: Feb 2003 Posts: 728 |
Quote: no it does not.
Maybe you don't, bet we do ;). Weird shit in this thread, possibly i learnt something new, which is also totally unusable :). Thanx guys! |