Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: robberguy189 on October 28, 2012, 04:01:47 pm

Title: Getting a program to unarchive another and then run it?
Post by: robberguy189 on October 28, 2012, 04:01:47 pm
PRGMA:
unarchive pgrmFAKE
pgrmFAKE

It gives me an error, how do I do this correctly?
Title: Re: Getting a program to unarchive another and then run it?
Post by: dinosteven on October 28, 2012, 04:38:38 pm
You can't unarchive/archive prgms with TI BASIC, sorry. Here's some ASM you can use, though :)
Code: [Select]
PRGMARCHIVE:
:AsmPrgm
:21F8893E02AE77C9
An ASM program that toggles the ability to archive programs. With this subprogram, do this:
Code: [Select]
PRGMA:
Asm(prgmARCHIVE
unarchive prgmFAKE
prgmFAKE
archive prgmFAKE
Asm(prgmARCHIVE
Title: Re: Getting a program to unarchive another and then run it?
Post by: robberguy189 on October 28, 2012, 04:55:02 pm
Thanks, this works great!

However, fake stays unarchived when I'm done, how do I archive it when I'm done with it?
Title: Re: Getting a program to unarchive another and then run it?
Post by: DJ Omnimaga on October 28, 2012, 05:17:06 pm
Note: For larger programs I recommend that instead of constantly archiving/unarchiving programs, that you use Resource or XCOPY, which temporarily copies the program in RAM instead.

That way if you need to use the program often your Duracell batteries will last longer than two months and your Flash ROM will not wear out as fast.
Title: Re: Getting a program to unarchive another and then run it?
Post by: dinosteven on October 28, 2012, 06:56:38 pm
Yeah, me too. I personally use Xeda's TPROG and everything I have is permanently archived once I finish developing them except for my DoorsCS games (because it unarchive/archives them anyways). I wish there was a shell that had the option to not allow program writeback, (or have it do so only if you do something after exiting,) supported everything, and had a homerun feature... But no, everything that's out there is lacking at least one of those things...

Anyways, the program I posted toggles the ability to unarchive AND archive. You can just do
Code: [Select]
archive prgmFAKE
Asm(prgmARCHIVE
after running it. I think it's best to toggle it off after using it; it might mess up your calc if it's active outside a program.
Title: Re: Getting a program to unarchive another and then run it?
Post by: Xeda112358 on October 28, 2012, 07:04:36 pm
Yeah, if you go with the TPROG idea, you could do something like this:
Code: [Select]
"FAKE:XTEMP000
Asm(prgmTPROG
prgmXTEMP000
Then you wouldn't even need to worry about archiving/unarchiving :D

@dinosteven: I believe DoorsCS7 checks if there are any changes from the original program. If there are no changes, it does nothing. (At least I hope Kerm did it that way)
Title: Re: Getting a program to unarchive another and then run it?
Post by: dinosteven on October 28, 2012, 07:55:05 pm
Test timings:
Garbage Collect 1: 0.98s
Garbage Collect 2: 0.38s
Garbage Collect 3: 0.43s  // so without anything to get rid of, it takes ~0.4s
Garbage Collect 4: 0.92s  // after running and exiting an archived 2068 byte BASIC program
Garbage Collect 5: 0.37s // back to ~0.4s
Garbage Collect 6: 0.81s //after running and exiting archived 3141 byte JUMP by ztrumpet
Garbage Collect 7: 0.44s // back to ~0.4s
Garbage Collect 8: 18.79s // After running and saving a game in 8063 byte Allecto, which does change

So:
I was felling quite suspicious that it didn't do that after the first 6 Garbage Collects, but after testing Allecto, I'm not sure.
Maybe DCS does do that and I was being paranoid with my human timings or maybe DCS doesn't and it just takes 21 times as long to garbage collect 8063 bytes than it does to garbage collect 2000 bytes... idk and I don't want wear out more of my flash ROM. lol I've been so cautious about that; I think I've only Unarchived/Archived something ~30 times since I got my calc.

edit: Someone should ask Kerm
edit2: Thanks, Deep. I can now keep my DCS games archived!
Title: Re: Getting a program to unarchive another and then run it?
Post by: robberguy189 on October 28, 2012, 10:05:21 pm
So what should my complete code be?
Title: Re: Getting a program to unarchive another and then run it?
Post by: dinosteven on October 28, 2012, 10:53:13 pm
Code: [Select]
PRGMA:
Asm(prgmARCHIVE
unarchive prgmFAKE
prgmFAKE
archive prgmFAKE
Asm(prgmARCHIVE
Title: Re: Getting a program to unarchive another and then run it?
Post by: Deep Toaster on October 29, 2012, 12:11:37 am
DoorsCS copies archived programs to RAM and copies back only if the program content changes (basically if it uses SMC).
Title: Re: Getting a program to unarchive another and then run it?
Post by: Hayleia on October 29, 2012, 02:22:01 am
DoorsCS copies archived programs to RAM and copies back only if the program content changes (basically if it uses SMC).
That is what he said but all of my Axe programs get copied back after use, even those not using SMC. Now I use zStart and it does the job perfectly. It is even faster to launch programs too.
Title: Re: Getting a program to unarchive another and then run it?
Post by: chickendude on October 29, 2012, 08:44:40 am
You might want to talk to Kerm about adding that option, MirageOS had it, and i can't imagine it would be difficult to implement (basically just don't call the code to copy the program back into archive). I don't know how Axe programs are handled, but how do you know none of the routines use SMC? Or is there a compile-time option to use only non-SMC routines? Many routines use SMC because it's generally faster and smaller than loading content from locations in SafeRAM, and for some things it's hard to imagine how to go about it without using SMC.
Title: Re: Getting a program to unarchive another and then run it?
Post by: Hayleia on October 29, 2012, 09:21:45 am
You might want to talk to Kerm about adding that option, MirageOS had it, and i can't imagine it would be difficult to implement (basically just don't call the code to copy the program back into archive). I don't know how Axe programs are handled, but how do you know none of the routines use SMC? Or is there a compile-time option to use only non-SMC routines? Many routines use SMC because it's generally faster and smaller than loading content from locations in SafeRAM, and for some things it's hard to imagine how to go about it without using SMC.
This has already been discussed on Cemetech on a topic called "My opinion/request for DoorsCS" or something like that. From what I remember of the discussion, Kerm says that DoorsCS doesn't writeback if it is not necessary, and Quigibo says that not any of Axe routines use SMC.
I think the problem comes from DCS and not Axe because I don't have the problem when I replace DCS with zStart.
Title: Re: Getting a program to unarchive another and then run it?
Post by: willrandship on October 29, 2012, 10:19:31 am
@dinosteve that method only works if you run the asm necessary to forc TIOS to think it's running in the home window, while in a program. Programs are normally not allowed to archive/unarchive things.
Title: Re: Getting a program to unarchive another and then run it?
Post by: calc84maniac on October 29, 2012, 10:26:00 am
You might want to talk to Kerm about adding that option, MirageOS had it, and i can't imagine it would be difficult to implement (basically just don't call the code to copy the program back into archive). I don't know how Axe programs are handled, but how do you know none of the routines use SMC? Or is there a compile-time option to use only non-SMC routines? Many routines use SMC because it's generally faster and smaller than loading content from locations in SafeRAM, and for some things it's hard to imagine how to go about it without using SMC.
This has already been discussed on Cemetech on a topic called "My opinion/request for DoorsCS" or something like that. From what I remember of the discussion, Kerm says that DoorsCS doesn't writeback if it is not necessary, and Quigibo says that not any of Axe routines use SMC.
I think the problem comes from DCS and not Axe because I don't have the problem when I replace DCS with zStart.
Do you modify any of the data buffers you put in the program? That counts as "SMC" as far as the fact that you're modifying things within the program space.
Title: Re: Getting a program to unarchive another and then run it?
Post by: willrandship on October 29, 2012, 10:32:43 am
SMC shouldn't need writeback unless it needs those buffers to be maintained, though, right?
Title: Re: Getting a program to unarchive another and then run it?
Post by: calc84maniac on October 29, 2012, 10:41:20 am
SMC shouldn't need writeback unless it needs those buffers to be maintained, though, right?
True, but there's no way to communicate that back to the shell.
Title: Re: Getting a program to unarchive another and then run it?
Post by: Hayleia on October 29, 2012, 11:31:40 am
Do you modify any of the data buffers you put in the program? That counts as "SMC" as far as the fact that you're modifying things within the program space.
No I don't. And I can prove it with the fact that zStart doesn't perform any writeback on my programs.

SMC shouldn't need writeback unless it needs those buffers to be maintained, though, right?
True, but there's no way to communicate that back to the shell.
You still can restore their initial state. For example, if every byte was at 0 at the beginning, you set them all back to 0 before leaving ;)
Title: Re: Getting a program to unarchive another and then run it?
Post by: Deep Toaster on November 03, 2012, 01:59:34 pm
I moved the topic to TI-BASIC language (Other Calc-Related Projects and Ideas is for projects and ideas :P), but I'm not entirely sure what language this is for, so if you want me to move it again just ask.