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 > Best practice IRQ recovery
2021-06-10 20:30
Trap

Registered: Jul 2010
Posts: 223
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
2021-06-10 20:54
TheRyk

Registered: Mar 2009
Posts: 2466
F...ing around with $01 reg just to use KERNAL routines is hardly ever worth the trouble if you don't want KERNAL banked in other parts of your code.
Just look into KERNAL ROM routines to see what they do, for example here: http://unusedino.de/ec64/technical/aay/c64/krnromma.htm and then take the few things you need, normally that would be what you find at $EA81 = restoring accumulator and x/y registers and use them somewhere in RAM.
2021-06-10 21:09
Six

Registered: Apr 2002
Posts: 322
Where does it hang, before or after the depacker starts?
2021-06-10 21:34
chatGPZ

Registered: Dec 2001
Posts: 11510
Quote:
What is the correct/proper way to exit from a part and go to the next?

that raises the question what you are doing there... a trackmo? classic "press space" stuff?
2021-06-10 21:46
Trap

Registered: Jul 2010
Posts: 223
It crashes before it gets to the unpacking
2021-06-10 21:53
MagerValp

Registered: Dec 2001
Posts: 1082
Set a breakpoint at unpacker and then step through the code and see where it crashes? There's no one answer here, it makes some assumption about things and you'll have to figure out what it is.
2021-06-10 21:56
chatGPZ

Registered: Dec 2001
Posts: 11510
the first thing that comes to mind is... don't use SEI. disable the irq sources instead. then set the pointers to their defaults.
2021-06-10 21:58
Krill

Registered: Apr 2002
Posts: 3083
Without further information, my bet is on pending interrupts that wreak havoc as soon as the I flag is cleared. =)

Then wrong vectors/memory configuration usually cause crashes, or with the ROM interrupt handler restored, an infinite IRQ-handling loop (as the ROM interrupt handler only acknowledges CIA1 interrupts, but not VIC interrupts).

Bottom line being that properly disabling any interrupt sources (not just executing SEI) is good practice for cleanly exiting a demo part (in a classical spacemo, that is).

Edit: Oh yeah, what Groepaz said. :D
2021-06-10 22:03
Trap

Registered: Jul 2010
Posts: 223
Well, I'm just learning stuff right now :)

ok, I will re-visit setting the IRQ vectors back. What would be the perfect sequence for this?

Should I just modify the running IRQ code to go to the default IRQ handler and then wait a few frames for it to catch it?
2021-06-10 22:12
Krill

Registered: Apr 2002
Posts: 3083
It's common practice to check for space during an interrupt handler that's executed once a video frame. The I flag is usually still set (because you're in an interrupt) and the interrupt itself was triggered by VIC.

When detecting the keypress, just write 0 to $d01a to disable any VIC interrupts, then write $ff to $d019 to acknowledge any pending VIC interrupts. Resetting any interrupt vectors should not be required. Directly exit to whatever code to unpack and run the next part.
2021-06-10 22:21
Trap

Registered: Jul 2010
Posts: 223
So

set IRQ vector to default handler
$d01a=0
$d019=$ff
wait a frame or two
go to unpacker

Is that what you meant?
 
... 78 posts hidden. Click here to view all posts....
 
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
iAN CooG/HVSC
Scrap/Genesis Project
JEZ
Enforcer/Deers
Didi/Laxity
master_hacker
Guests online: 218
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Codeboys & Endians  (9.7)
4 Mojo  (9.6)
5 Coma Light 13  (9.6)
6 Edge of Disgrace  (9.6)
7 Signal Carnival  (9.6)
8 Uncensored  (9.5)
9 Wonderland XIV  (9.5)
10 No Bounds  (9.5)
Top onefile Demos
1 Nine  (9.7)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.5)
6 Scan and Spin  (9.5)
7 Onscreen 5k  (9.5)
8 Grey  (9.5)
9 Dawnfall V1.1  (9.5)
10 Rainbow Connection  (9.5)
Top Groups
1 Artline Designs  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Performers  (9.3)
5 Censor Design  (9.3)
Top Diskmag Editors
1 Magic  (10)
2 Jazzcat  (9.5)
3 hedning  (9.2)
4 Elwix  (9.1)
5 Peter  (9.0)

Home - Disclaimer
Copyright © No Name 2001-2025
Page generated in: 0.316 sec.