Author Topic: Getting a program to unarchive another and then run it?  (Read 6051 times)

0 Members and 1 Guest are viewing this topic.

Offline robberguy189

  • LV3 Member (Next: 100)
  • ***
  • Posts: 61
  • Rating: +1/-11
    • View Profile
Getting a program to unarchive another and then run it?
« on: October 28, 2012, 04:01:47 pm »
PRGMA:
unarchive pgrmFAKE
pgrmFAKE

It gives me an error, how do I do this correctly?

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: Getting a program to unarchive another and then run it?
« Reply #1 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

Offline robberguy189

  • LV3 Member (Next: 100)
  • ***
  • Posts: 61
  • Rating: +1/-11
    • View Profile
Re: Getting a program to unarchive another and then run it?
« Reply #2 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?

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Getting a program to unarchive another and then run it?
« Reply #3 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.
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: Getting a program to unarchive another and then run it?
« Reply #4 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.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Getting a program to unarchive another and then run it?
« Reply #5 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)

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: Getting a program to unarchive another and then run it?
« Reply #6 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!
« Last Edit: October 29, 2012, 12:28:39 am by dinosteven »

Offline robberguy189

  • LV3 Member (Next: 100)
  • ***
  • Posts: 61
  • Rating: +1/-11
    • View Profile
Re: Getting a program to unarchive another and then run it?
« Reply #7 on: October 28, 2012, 10:05:21 pm »
So what should my complete code be?

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: Getting a program to unarchive another and then run it?
« Reply #8 on: October 28, 2012, 10:53:13 pm »
Code: [Select]
PRGMA:
Asm(prgmARCHIVE
unarchive prgmFAKE
prgmFAKE
archive prgmFAKE
Asm(prgmARCHIVE

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Getting a program to unarchive another and then run it?
« Reply #9 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).




Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Getting a program to unarchive another and then run it?
« Reply #10 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.
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Getting a program to unarchive another and then run it?
« Reply #11 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.

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Getting a program to unarchive another and then run it?
« Reply #12 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.
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: Getting a program to unarchive another and then run it?
« Reply #13 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.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Getting a program to unarchive another and then run it?
« Reply #14 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.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman