Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Builderboy on February 25, 2011, 04:16:49 pm

Title: Mirage safe zones
Post by: Builderboy on February 25, 2011, 04:16:49 pm
So since I am already using L1,L3,L4,L5 and L6 in PortalX, and yet I am looking into adding greyscale to certain parts.  The best way would be to move the variables from L1 into L2 with the Realloc() function, but doesn't use large portions of L2?  What areas are safe?  If I turn off interrupts, will that make L2 safer, or still dangerous?
Title: Re: Mirage safe zones
Post by: ztrumpet on February 25, 2011, 05:41:28 pm
I believe this is what you would have to do:
di
Backup all the contents that you will override in L2 somewhere.
<stuff using L2>
Restore the backup
ei
Title: Re: Mirage safe zones
Post by: DJ Omnimaga on February 25, 2011, 05:43:31 pm
Yeah if you absolutely need these areas, you'll have to store their content elsewhere prior using them, such as an arbitrary buffer inside your program or in a temporary appvar.
Title: Re: Mirage safe zones
Post by: ztrumpet on February 25, 2011, 05:45:12 pm
Oh yeah, if you use a program you can just put a Zeros(768) at the end of your program for another buffer. ;D
Title: Re: Mirage safe zones
Post by: Quigibo on February 26, 2011, 12:18:48 am
You can use LnReg to transfer interrupt control from Mirage to the OS.  That would be the best idea since you can still use OS routines that require interrupts.
Title: Re: Mirage safe zones
Post by: AngelFish on February 26, 2011, 12:22:28 am
Oh yeah, if you use a program you can just put a Zeros(768) at the end of your program for another buffer. ;D

O.O
/me hugs ztrumpet
Title: Re: Mirage safe zones
Post by: ztrumpet on February 26, 2011, 09:59:48 pm
You can use LnReg to transfer interrupt control from Mirage to the OS.  That would be the best idea since you can still use OS routines that require interrupts.

O.O
* ZTrumpet hugs Quigibo

How does that work?
Title: Re: Mirage safe zones
Post by: Deep Toaster on February 26, 2011, 10:18:16 pm
You can use LnReg to transfer interrupt control from Mirage to the OS.  That would be the best idea since you can still use OS routines that require interrupts.

O.O
* ZTrumpet hugs Quigibo

How does that work?

LnReg sets interrupt mode 1 (normal), which doesn't use any extra data. Mirage uses a custom interrupt (mode 2) whose data needs to be stored in RAM. Mirage uses L2 for this data.

So I don't have to start another topic, is L2 completely safe to use if I do FnOff or LnReg? I use L2 for an array in Contra, and for some reason when I mess with it enough, Return returns straight to the homescreen instead of back to the Mirage shell.

And in other cases, Return returns back to Mirage, but the GUI is messed up (none of the program names appear, though I can still run them).
Title: Re: Mirage safe zones
Post by: thepenguin77 on February 26, 2011, 10:29:22 pm
There is one byte in statVars (I assume L2) that mirage uses. That is $8A4A. If it is 1, mirage quits to the homescreen. If it is anything else, it doesn't.
Title: Re: Mirage safe zones
Post by: Deep Toaster on February 26, 2011, 10:40:52 pm
Ah, that must be it. Mirage uses it regardless of whether interrupts are enabled?

EDIT: StatVars is $8A3A... Is that it?

EDIT2: Lol, just realized I can type "statvars" with one hand :D
Title: Re: Mirage safe zones
Post by: thepenguin77 on February 26, 2011, 10:47:12 pm
Yep, $8A4A is the spot. This is the shortest possible (clean) program demonstrating my point.

Code: [Select]
xor a
jr nc, $+2
nop
inc a
ld ($8A4A), a
ret

When you run it, you essentially quit mirage.

Edit:
   Ok, now it's the smallest.
Title: Re: Mirage safe zones
Post by: Builderboy on February 27, 2011, 02:09:54 am
Is that byte the only byte Mirage uses?  I got the impression that it also used a lot more bytes for local variables and stuff, which is why the gui gets messed up
Title: Re: Mirage safe zones
Post by: Deep Toaster on March 20, 2011, 02:15:40 pm
*bump*

Anybody know the answer? The mirdevinfo (http://www.detachedsolutions.com/mirageos/develop/mirdevinfo.zip) package doesn't mention this at all.
Title: Re: Mirage safe zones
Post by: FloppusMaximus on March 20, 2011, 04:21:22 pm
Quote from: mirgui.inc
FolderBytes           = StatVars+5      ;(10)   Holds one data byte for each folder, which
                                        ;       contains the number of progs in the folder,
                                        ;       (99 Max), and then Bit 7 is used to notate
                                        ;       if the folder is either Open or Closed.
That's probably what's causing your problems.  I don't know why that couldn't have been stored somewhere else (e.g., in cmdShadow, and use statVars for the cached appvar settings instead) but there you have it.
Title: Re: Mirage safe zones
Post by: Deep Toaster on March 20, 2011, 06:59:48 pm
Thanks! I didn't see that.

Guess I could save that into the program somewhere and restore it before exiting. What does the (10) mean?
Title: Re: Mirage safe zones
Post by: FloppusMaximus on March 21, 2011, 09:57:33 pm
It means there are 10 bytes there that you might have to back up and restore.  I'm pretty sure Mirage has a limit of 10 folders.
Title: Re: Mirage safe zones
Post by: Xeda112358 on March 21, 2011, 10:09:36 pm
Hmm... I read that as having 99 folders... What does the 99 mean?

EDIT:Never mind, 99 programs per folder :D
Title: Re: Mirage safe zones
Post by: Deep Toaster on March 22, 2011, 10:40:16 am
Hmm... I read that as having 99 folders... What does the 99 mean?

EDIT:Never mind, 99 programs per folder :D

Oh, that's what I thought too. That makes sense then :)

But according to BrandonW (according to _player1537 (on Cemetech (http://www.cemetech.net/forum/viewtopic.php?p=141526#141526))), Mirage might use more of it in future versions.