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 > Controling execution flow with timers examples
2009-02-22 11:57
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 ;)
2009-02-22 13:22
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.
2009-02-22 15:30
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
2009-02-22 18:29
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?
2009-02-22 18:43
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 :)
2009-02-23 07:15
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.
2009-02-23 08:00
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...
2009-02-23 10:12
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....
2009-02-24 22:12
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)


2009-02-24 22:46
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.
2009-02-24 23:19
chatGPZ

Registered: Dec 2001
Posts: 11386
guys, look at the routine ninja mentioned =)
2009-02-25 06:29
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).
2009-02-25 08:34
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...
2009-02-25 09:41
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.
2009-02-26 01:51
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.
2009-02-26 09:24
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).
2009-02-27 08:31
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.
2009-02-28 10:22
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.
2009-03-03 12:35
Martin Piper

Registered: Nov 2007
Posts: 722
Completely mental.
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
Da Snake
BYB/Hokuto Force
rexbeng
WVL/Xenon
psych
Peacemaker/CENSOR/Hi..
Guests online: 151
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Musicians
1 Rob Hubbard  (9.7)
2 Mutetus  (9.7)
3 Jeroen Tel  (9.7)
4 Linus  (9.6)
5 Stinsen  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.097 sec.