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 > Keeping a few bits of information in a hostile environment
2021-04-18 09:24
Krill

Registered: Apr 2002
Posts: 2844
Keeping a few bits of information in a hostile environment

If not reserving space in RAM, where would read-writable data be most likely to survive throughout the run-time of any random demo or game?

$D800-$DC00 is often overwritten entirely, $00/$01 in RAM are too cumbersome to access.

$DD03 (parallel port data direction register) might be good, or maybe the 2x4 CIA TOD registers at $DC08 and $DD08.

Or are they? What else could be usable for that purpose? =)
 
... 72 posts hidden. Click here to view all posts....
 
2021-04-19 17:46
Krill

Registered: Apr 2002
Posts: 2844
Quoting tlr
It's not uncommon to call $fda3 either, which breaks both the $00 and $dd03 approaches but perhaps not the TOD approach.
Yes, but calling $FDA3 causes the loader drive code to reset to ROM, so that should not happen in a finished production. =)
2021-04-19 19:21
aeeben

Registered: May 2002
Posts: 42
Use TOD alarm time:

TOD registers may be easily overwritten if a program inits the CIA state from a lookup table.

But if you write your important number to TOD alarm time instead of TOD time, by setting bit 7 in $dx0f...

"$dx0f Bit 7: 0 = Writing into the TOD register sets the clock time, 1 = Writing into the TOD register sets the alarm time."

...you can then later recover the stored value by writing all possible values to TOC time in a loop and checking which write sets Bit 2 (1 = Time of day and alarm time is equal) in $dx0d
2021-04-19 20:22
Krill

Registered: Apr 2002
Posts: 2844
That's a neat trick. =) TOD alarm is basically never used. And it's pretty much what i meant with "hidden state".

Should work on SX-64 as well, despite no clocked TOD, yeah? :)
2021-04-26 22:46
Zibri
Account closed

Registered: May 2020
Posts: 304
$DD03 has been used historically for example by the electronic arts loader of Archon II.
So even dumping all the memory won't help unless you also save the value contained there before the first run, otherwise the game will start but a lot of sprites will be corrupted because the value of DD03 is later used to XOR the initial data of part of the sprites.
You won't notice this until the first one to one fight.
:D
I would hide also one in some unused SID or CIA or VIC registers.
2021-04-27 13:13
chatGPZ

Registered: Dec 2001
Posts: 11116
Quote:
recover the stored value by writing all possible values to TOC time in a loop

That will take a while .... :=) Also, there is some strange quirk with the alarm time in that the interrupt doesnt trigger in certain constellations (i forgot the details, the programs in the test repo might tell) so this is probably not useful for the general case and for arbitrary data.
2021-04-27 13:21
Copyfault

Registered: Dec 2001
Posts:
The idea of using the alarm time is crazy! Depending on how many different versions of the loader we're dealing with the test loop shouldn't become too long...

Then again, reading Groepaz comment, there are certain quirks to be avoided. Guess there'll still be enough quirk-free alarm times to be used.


@Groepaz: do these kind of quirks qualify to be deep-checked and wrapped up for a certain document about ending secrets??
2021-04-27 13:32
chatGPZ

Registered: Dec 2001
Posts: 11116
haha i'd rather NOT open this can of worms at this point... documenting all the whack CIA behaviour is another lifetime project =D
2021-04-27 13:42
Krill

Registered: Apr 2002
Posts: 2844
It's just exactly one loader version, with the installer shuffling 2 bits of information to the loader.

So querying TOD alarm for these 4 (actually 3) values shouldn't take long indeed, and the values can be chosen to avoid the quirks.

But then again, $dd03 should suffice for most usecases (demos and games) where the loader is used.
2021-04-27 13:42
Copyfault

Registered: Dec 2001
Posts:
Quoting Groepaz
haha i'd rather NOT open this can of worms at this point... documenting all the whack CIA behaviour is another lifetime project =D
I knew it all the time: C64 sceners need more than one life! Now off to find that extra life ;)
2021-04-27 13:45
Krill

Registered: Apr 2002
Posts: 2844
Quoting Zibri
$DD03 has been used historically for example by the electronic arts loader of Archon II.
So even dumping all the memory won't help
This is not about running any arbitrary program. But if it were, then then TOD approach would probably the best bet to actually "hide" information to be retrieved at some later point.
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
aeeben
bugjam
HOL2001/Quantum
Krill/Plush
Aomeba/Artline Desig..
GI-Joe/MYD!
The Human Co../Maste..
Fred/Channel 4
rexbeng
Guests online: 140
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Wafer Demo  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Graphicians
1 Sulevi  (10)
2 Mirage  (9.8)
3 Lobo  (9.7)
4 Mikael  (9.7)
5 Archmage  (9.7)

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