Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: thepenguin77 on July 25, 2011, 10:08:06 pm

Title: Ever corrupt your archive?
Post by: thepenguin77 on July 25, 2011, 10:08:06 pm
New Version down below (http://ourl.ca/12245/234994)

I've seen way to many people getting their archives corrupted and losing all of their hard work lately, so I figured it's time for a solution.

Normally when your archive is corrupted, you can't boot your calculator. The only way to do it is to hold CLEAR and turn it on. The problem though is that all of your programs in the archive will not be listed in the program menu, which means that they can't be sent to your computer. The only way to make them show up is to ram clear, but that will crash since your archive is corrupted.

So, what I did was to make a program that parses the archive and rebuilds the vat. I tried to cover every possible way that would make the calculator crash, so this should work every time. Then once your programs are listed on your calculator, you can send them to your computer and clear mem, fixing all of your problems.

(http://img.removedfromgame.com/imgs/rebuildDemo.gif)

The steps to make this work are pretty easy:
1. Clear Ram while holding clear
2. Send this program
3. Run it with Asm(
4. Send all your variables back to your computer
5. Clear Mem

Here are the errors that I protect against:


I think these are really the only things that can go wrong with an archive entry, if anyone thinks of any others, tell me. One of the big ways I protect against random garbage is by only accepting appVars, programs, protected programs, and groups. It is highly unlikely that a random archive garbage will claim to be one of those variables as well as having a names that is between 1 and 8 characters.

Here's the program with the source, the more people who look at the source, the more holes in it we can find, so look at it. ;D
Title: Re: Every corrupt your archive?
Post by: annoyingcalc on July 25, 2011, 10:11:00 pm
cool I hate when my archiv is corrupted
Title: Re: Ever corrupt your archive?
Post by: ztrumpet on July 25, 2011, 11:19:19 pm
Awesome!  Great job, thepenguin, on what I'm sure will become a community-wide tool.  Thanks. :D
Title: Re: Ever corrupt your archive?
Post by: leafy on July 25, 2011, 11:21:17 pm
OH COME ON, IF YOU HAD TOLD ME THIS EARLIER I WOULDN'T HAVE TO HAD DONE A FULL MEM RESET WITHOUT BACKUPS ><
Title: Re: Ever corrupt your archive?
Post by: thepenguin77 on July 25, 2011, 11:22:23 pm
OH COME ON, IF YOU HAD TOLD ME THIS EARLIER I WOULDN'T HAVE TO HAD DONE A FULL MEM RESET WITHOUT BACKUPS ><

Don't worry, I only made it a few hours ago. It wasn't around then.
Title: Re: Ever corrupt your archive?
Post by: mrmprog on July 26, 2011, 01:28:25 am
On a semi related topic: Nothing happens to me when I turn on while holding clear.
Title: Re: Ever corrupt your archive?
Post by: calcdude84se on July 26, 2011, 08:12:21 am
mrmprog, you have to be rather quick about it. What it does is stop the TI-OS from parsing the Archive, so you should not see anything that is archived except for apps, which are different.
thepenguin, the next logical step would be to allow the Archive to be rebuilt on-calc. A lot of work, perhaps, but last I checked I thought we had good documentation on the archive format.
Title: Re: Ever corrupt your archive?
Post by: p2 on July 26, 2011, 09:01:27 am
great tool!
Spoiler For thepenguin:
I havehad more Programs than you  ;D (before I had to make an archieve clear) :P
Title: Re: Ever corrupt your archive?
Post by: thepenguin77 on July 26, 2011, 10:31:57 am
Calcdude, archive format is simple. [Flag] | [Size low] | [Size high] | [Vat header ...] | [program data ...] But I do agree, I need to figure out how to fix the errors. That would be a bit tougher though :) (Manual garbage collect)

Edit:
On a semi related topic: Nothing happens to me when I turn on while holding clear.

Clear ram while holding CLEAR. Not just OFF/ON.
Title: Re: Ever corrupt your archive?
Post by: chattahippie on July 26, 2011, 11:36:18 am
Corrupted Archive gets really annoying, glad there is now a solution (other than deleting everything)! :D
Title: Re: Ever corrupt your archive?
Post by: thepenguin77 on August 12, 2011, 05:18:57 pm
Today I realized that actually fixing the archive wouldn't really be that difficult, so I did it.

Here is the new version, you can run it whenever you feel like it. It will manually garbage collect, and then clear ram, when your calculator turns back on, it will be good as new.

Uses:


If you run this on your real calculator, (especially after messing with axe 1.0.0 or 1.0.1), you might actually gain 64KB or flash back, which is from those random junk pages that the regular garbage collect routine doesn't delete.

Edit:
   I hate it when I forget to attach it.
Title: Re: Ever corrupt your archive?
Post by: Deep Toaster on August 14, 2011, 11:54:12 am
Wow. It's amazing how you pop in once in a while with an epic new program.
Title: Re: Ever corrupt your archive?
Post by: ztrumpet on August 14, 2011, 12:12:46 pm
What is this wizardry?!
How does it work?
Title: Re: Ever corrupt your archive?
Post by: Deep Toaster on August 14, 2011, 12:22:01 pm
Well, as you said, it is magic...
Title: Re: Ever corrupt your archive?
Post by: DrDnar on August 14, 2011, 04:45:08 pm
Haha. I've been meaning to write something like that for a long time. I wanted to use the extra 96 K of RAM to speed up garbage collection, but after the whole thing with TI trying to save a negligible amount of money by getting rid of most of the extra RAM, I never really felt like it.
Title: Re: Ever corrupt your archive?
Post by: calcdude84se on August 14, 2011, 05:27:49 pm
Cool :D. I've never had issues, but I think I'll keep this topic in mind.
So, the TI-OS will claim another sector from the user sometimes? Interesting.
Title: Re: Ever corrupt your archive?
Post by: thepenguin77 on August 14, 2011, 05:59:01 pm
What is this wizardry?!
How does it work?

I'll explain the process.
1. Find the first page starting at the end of the archive that is not an app, AND it with $FC and store that.
2. Find a suitable swap sector.
    a. First scan the archive for a sector that starts with $FE (swap) or $FF (blank)
    b. If that didn't work, look for a sector that doesn't have any valid programs in it
    c. If that didn't work, screw it and use page 8.
3. Starting on page 8, and ending at the page found in step 1, begin copying everything to the swap sector.
    a. First, search the page for a program that has a valid header (valid meaning not erased, good type, good length, and 0 < (name length) < 9)
    b. Copy that program to the swap sector making sure to set the new address and page to where you are copying it
    c. When the end of a sector is reached, erase it and continue on to the next one
    d. If the swap sector runs out of space, just find a new one. (By this time, page $0C is guarenteed to be open.)
4. Find one last swap sector and copy sector 8 there (program by program because of the valid page thing)
5. Mark sector 8 as the swap sector and clear ram (to rebuild vat)

That's about it. I didn't include any code to try to optimize how the variables are stored in the archive, but, as you make new variables, they'll take up the little spots at the end. This was mostly done to increase speed, and because it would just be annoying to add.

Cool :D. I've never had issues, but I think I'll keep this topic in mind.
So, the TI-OS will claim another sector from the user sometimes? Interesting.

Ti-OS won't claim another sector, but some program might accidentally. If you write 00 to the first address of any sector, the OS will just stop using it. If it sees that the sector is invalid, rather than deleting it, it just ignores it.

Edit:
   Source attached for your enjoyment.
Title: Re: Ever corrupt your archive?
Post by: Darl181 on August 20, 2011, 09:49:25 pm
So I ran this, and now whenever I try to send an app (however many pages, archive completely free) TiLP throws "Msg: Out of Memory"
:|


Nvm, some weird bug with TiLP.
Title: Re: Ever corrupt your archive?
Post by: willrandship on August 20, 2011, 11:59:25 pm
By the way, corrupting 84+ archive on the nspire is very easy to avoid if you know how. Normally, you think crashes are the end of the world, but i can turn invalidated certs into a simple ram clear with my method :)