| |
AlexC
Registered: Jan 2008 Posts: 299 |
Controling execution flow with timers examples
I'm writing an update to my text on cartridges for codebase64 and I am looking for real life examples of controlling execution flow with timers other than triggering NMI with CIA or triggering IRQ to execute interrupt handler. So if you guys could point me at some code that uses such trick I'd be grateful. BTW: I'm still looking for v4.2 Expert software ;) |
|
| |
Ninja
Registered: Jan 2002 Posts: 411 |
I am not sure if this is what you mean, but you could check my article in Vandalism News #43 describing the 2x2-routine from Real. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
some protections used timers to calculate branches and stuff like that... kinda hard to give a realworld example without digging knee deep into some specific protection though =P |
| |
AlexC
Registered: Jan 2008 Posts: 299 |
Thanks for tips. If you could point me at some protection scheme applied to real program that would be great. Basically I'm looking for a case where you use JMP through timers (or any other similar trick). Maybe someone here remembers such protection scheme and give me tip at which disk I should take a look?
|
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
mmmh i *think* timex did something like that (for example used in the game "logo", and a couple of magic-disk issues). not sure though :) |
| |
Martin Piper
Registered: Nov 2007 Posts: 722 |
Some tape loaders (like my one here TapeLoaderCIA.a http://codebase64.org/doku.php?id=base:autoboot_tape_turbo_load.. or some Cyberloads/Novaloads) use a CIA timer without an IRQ to time tape pulses. This can result in shorter code than using the usual IRQ method to detect and time pusles because there is not extra state handling code needed when reading in tape bits.
|
| |
enthusi
Registered: May 2004 Posts: 677 |
hehe,
tape composer uses CIA timer as well to keep a note active for a constant length...
Tape Composer 1.0
Some weird stable raster routines jump into the TIMER values and prepare a larger table for that... |
| |
Style
Registered: Jun 2004 Posts: 498 |
like enthusi said, doing sideborder stuff with a variable number of sprites on screen is done with a timer which you JMP indirect to, and have a number of delay routines ending in blowing the sideborder...
Apart from that, Ive only ever used NMIs to play samples from memory.... |
| |
AlexC
Registered: Jan 2008 Posts: 299 |
Thank you for all tips and info. One more question - have you ever seen construction similar to this one:
JMP ($DD04) or JMP ($DC04)
|
| |
doynax Account closed
Registered: Oct 2004 Posts: 212 |
Quote: Thank you for all tips and info. One more question - have you ever seen construction similar to this one:
JMP ($DD04) or JMP ($DC04)
To what end? It might well work as a form of copy-protection or other obfuscation, but it would be of little use as jitter compensation given that the timers count downwards.
On the other hand I can see how jumping into a second chained timer might be useful, one which wouldn't be sensitive to jitter. That way you could invoke a different interrupt handler every few scanlines, though without any free stabilization.
Oh, and if you find a use for this the trick on the first IRQ or NMI timer then you could probably get away with poking a JMP opcode directly into the DDR register immediately preceding the timers, and thus save yourself two cycles per interrupt. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
guys, look at the routine ninja mentioned =) |
| |
Radiant
Registered: Sep 2004 Posts: 639 |
Quote: Thank you for all tips and info. One more question - have you ever seen construction similar to this one:
JMP ($DD04) or JMP ($DC04)
jmp ($dc03) is a classic way of making the raster stable within a line, when doing f.e. a DYSP routine. I haven't seen jmp ($dc04). |
| |
Ninja
Registered: Jan 2002 Posts: 411 |
You haven't read the article, have you? I gave an example of a demo using JMP ($DCxx) there... |
| |
AlexC
Registered: Jan 2008 Posts: 299 |
Quote: You haven't read the article, have you? I gave an example of a demo using JMP ($DCxx) there...
Not yet :( But I'll definitively do it. Thank you once again. |
| |
Martin Piper
Registered: Nov 2007 Posts: 722 |
Useful for making a completely steady screen split during a game screen and the score panel with lots of sprites flying around over the split. But not many games bother because they're tight on memory. :) I seem to remember Citadel did do it though. *I think*. My memory is really hazy from back then. |
| |
TNT Account closed
Registered: Oct 2004 Posts: 189 |
Quote: Useful for making a completely steady screen split during a game screen and the score panel with lots of sprites flying around over the split. But not many games bother because they're tight on memory. :) I seem to remember Citadel did do it though. *I think*. My memory is really hazy from back then.
IIRC Citadel does use NMI for screen split but doesn't bother stabilizing it with timers. Paradroid Redux does, but even that isn't perfect. (It does variable delay based on timer value, no jumping through timer). |
| |
AlexC
Registered: Jan 2008 Posts: 299 |
Quote: You haven't read the article, have you? I gave an example of a demo using JMP ($DCxx) there...
Done it. Really cool idea. Apart from the effect itself I really like the idea to store opcode inside hardware registers. Neat trick for copy protection scheme as well. Thanks Ninja. |
| |
Graham Account closed
Registered: Dec 2002 Posts: 990 |
Quote: mmmh i *think* timex did something like that (for example used in the game "logo", and a couple of magic-disk issues). not sure though :)
Yes, Timex did a timer IRQ after every opcode to decrypt the next one and re-crypt the previous one. This way there was only one decrypted opcode at a time in memory.
|
| |
Martin Piper
Registered: Nov 2007 Posts: 722 |
Completely mental. |