Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in 
CSDb User Forums


Forums > C64 Coding > Best practice IRQ recovery
2021-06-10 20:30
Trap

Registered: Jul 2010
Posts: 208
Best practice IRQ recovery

Hi,

Here's a little newbie question. Sorry, I'm still learning this shit and it's really complicated :(

I have kernel off ($01=$35) and I am running IRQ's using the normal $fffe/$ffff vectors.
I want to exit from this and call a prepacked piece of code (in this case something packed with TinyCrunch).

I tried restoring the IRQ vectors and jump to the packer. However, it just hangs. I tried some other things but all gave the same result. The only thing that worked was when I did this:

sei
lda #$36
sta $01
jsr $ff81
jmp unpacker

The problem of course is that it resets the VIC which isn't really great for my situation.

So, my question:

What is the correct/proper way to exit from a part and go to the next? preferably not using kernal routines :|

Thank you.

Trap
 
... 78 posts hidden. Click here to view all posts....
 
2021-06-14 10:27
Krill

Registered: Apr 2002
Posts: 1916
So... how about guarding a safe interrupt disable routine against a malicious VM running on 6502 itself, so any of the routine's instructions would be made ineffective if an attempt to disable interrupts (SEI, disable bits in an interrupt mask register, etc.) is detected? =)
2021-06-14 10:32
ChristopherJam

Registered: Aug 2004
Posts: 1164
I'm still with groepaz on this one. For 99% of the parts out there, even if they don't shut themselves down properly all wrapping your cleanup code in SEI/CLI does is to add complexity. If I is clear, you can just turn off the sources and you're done - no acks required.

For the remaining 1%, TWW's solutions will work for some and not others - you really need to study the routine in question to see what you need, and honestly any routine with requirements so weird as to need anything more complex really should be responsible for cleaning up its own shit.


edit - and cf Krill's comment for an example of why there really is no such thing as a bulletproof routine :D
2021-06-14 10:47
Krill

Registered: Apr 2002
Posts: 1916
Yeah, repeating myself: if you need to set interrupt masks from within an ISR, you're most likely doing it wrong and asking for trouble. =)
2021-06-14 14:48
JackAsser

Registered: Jun 2002
Posts: 1824
Quote: Yeah, repeating myself: if you need to set interrupt masks from within an ISR, you're most likely doing it wrong and asking for trouble. =)

I enable/disable NMs from raster IRQs by messing with the mask. F.e. have a stable 4 line timer that I just mask/unmask in top / bottom border to enable the $d011 trickery needed.
2021-06-14 14:52
Krill

Registered: Apr 2002
Posts: 1916
Quoting JackAsser
I enable/disable NMs from raster IRQs by messing with the mask. F.e. have a stable 4 line timer that I just mask/unmask in top / bottom border to enable the $d011 trickery needed.
Could the same effect be achieved by enabling/disabling the NMI handler's ack from a non-NMI context? (And acking previous NMI after re-enabling the handler's ack.)

Alternatively, have the 4-line timer not generate interrupts, but the other timer count just 1 underrun of the 4-line timer and generate interrupts. The latter can then be started and stopped from a non-NMI context without losing sync to VIC.
2021-06-14 15:45
Groepaz

Registered: Dec 2001
Posts: 9918
I also did something like this in Mongobong to play samples in borders using NMI and then have FLI in the display area. Dont remember details, it probably _was_ stupid to do it like i did :)
2021-06-14 15:49
ChristopherJam

Registered: Aug 2004
Posts: 1164
Samples plus FLI? Now that is brave.
2021-06-14 16:16
JackAsser

Registered: Jun 2002
Posts: 1824
Quote: Quoting JackAsser
I enable/disable NMs from raster IRQs by messing with the mask. F.e. have a stable 4 line timer that I just mask/unmask in top / bottom border to enable the $d011 trickery needed.
Could the same effect be achieved by enabling/disabling the NMI handler's ack from a non-NMI context? (And acking previous NMI after re-enabling the handler's ack.)

Alternatively, have the 4-line timer not generate interrupts, but the other timer count just 1 underrun of the 4-line timer and generate interrupts. The latter can then be started and stopped from a non-NMI context without losing sync to VIC.


Ofcourse u can, but less elegant and not really less error prone. A 4th line NMI is 100% predictable when it will trigger anyway.
2021-06-14 16:36
TWW

Registered: Jul 2009
Posts: 499
Quoting Groepaz
you cant just move it, you must sei first to prevent that an irq triggers right after the stx $dd0d and then enables the NMI again.

Enabling NMIs inside an IRQ... Never saw that myself, but not saying it doesn't exist.

Quoting Groepaz
(And then... not considering all of them is ... a bit lame :=P)


Lame yourself :-D
2021-06-14 17:48
Krill

Registered: Apr 2002
Posts: 1916
Quoting JackAsser
Ofcourse u can, but less elegant and not really less error prone. A 4th line NMI is 100% predictable when it will trigger anyway.
Sure, but my point was to avoid setting interrupt masks in ISRs (without drawbacks, except maybe elegance, which is somewhat subjective).
Avoid the main cause for disabling without SEI/ACK/CLI wrapper failing. =)
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 - 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
tlr
TheRyk/MYD
Mike
Higgie/Kraze
Compyx/Focus
Krill/Plush
CreaMD/React
Trash
Madhead
Sh0ckTr00per/Hokuto ..
SLC
rexbeng
.jetan/Samar Product..
Guests online: 302
Top Demos
1 Edge of Disgrace  (9.6)
2 Coma Light 13  (9.6)
3 Uncensored  (9.6)
4 Comaland 100%  (9.6)
5 Lunatico  (9.6)
6 Unboxed  (9.6)
7 Memento Mori  (9.5)
8 Christmas Megademo  (9.5)
9 Wonderland XII  (9.5)
10 The Shores of Reflec..  (9.5)
Top onefile Demos
1 Copper Booze  (9.8)
2 Daah, Those Acid Pil..  (9.5)
3 Lovecats  (9.5)
4 To Norah  (9.5)
5 Dawnfall V1.1  (9.5)
6 Elite Code Mechanics  (9.4)
7 Square Booze  (9.4)
8 Amber Cow - The Real..  (9.4)
9 Quadrants  (9.4)
10 Coma Job 2/3  (9.4)
Top Groups
1 Booze Design  (9.4)
2 Oxyron  (9.4)
3 Censor Design  (9.4)
4 PriorArt  (9.3)
5 Crest  (9.3)
Top Musicians
1 Rob Hubbard  (9.8)
2 Jeroen Tel  (9.6)
3 Linus  (9.5)
4 Drax  (9.5)
5 Reyn Ouwehand  (9.5)

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