Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: DJ Omnimaga on May 21, 2010, 02:11:51 am

Title: Help: Screenshotting program ends up screensh*tting
Post by: DJ Omnimaga on May 21, 2010, 02:11:51 am
Ok so that french guy was asking how to make a program to store pics into programs, something that is impossible so far, but I decided to make an appvar version for now. However, I have problems. When I recall the pic, it's kinda glitchy. Some stuff shows fine, but other lines are garbage. I also got a crash once

Here's the code of my programs:

Code: [Select]
.SCRNSHOT
StoreGDB
"vPIC"->Str1
GetCalc(Str1)
GetCalc(Str1,768)
conj(L6,Str1,768)
DispGraph

Code: [Select]
.SCRNVIEW
"vPIC"->Str1
GetCalc(Str1)->M
If M
conj(Str1,L6,768)
DispGraph
End

Note: those two progs are launched from a TI-BASIC program so the graph screen is displayed prior launching them.

If anyone tries to debug this, please do not run on calc, or at least back up first, because my TI-Nspire froze once.

For french people, here's the original request: http://ourl.ca/4881/90891;topicseen#new
Title: Re: Help: Screenshotting program ends up screensh*tting
Post by: Builderboy on May 21, 2010, 03:17:36 am
Ok in the first program, remove the first getcalc, add a '->M' to the end of the second getCalc statement and change the Str1 on the line after into an M

should work :) I'm on my itouch so sorry if I messed up
Title: Re: Help: Screenshotting program ends up screensh*tting
Post by: Quigibo on May 21, 2010, 03:35:59 am
Yeah, Str1 is just a pointer to the name of the "vPIC" string it isn't the actual data.  You need to assign the getcalc result to a variable pointer (like M in builderboy's suggestion) becasue the appvars cannot be assigned static pointers like StrXX and PicXX since they move around a lot in ram and aren't in the same place every time you execute.
Title: Re: Help: Screenshotting program ends up screensh*tting
Post by: DJ Omnimaga on May 21, 2010, 07:30:31 am
Ooh wow I didn't knew variables were actually pointers. I thought they could only be like one byte lenght each. I didn't knew you could use -> at the end of the GetCalc(PTR,BYTES) command.

It still doesn't work, though. Now I changed what Builderboy told me to change and I got
Code: [Select]
.SCRNSHOT
StoreGDB
"vPIC"->Str1
GetCalc(Str1)
GetCalc(Str1,768)->M
conj(L6,M,768)
DispGraph
And it's even worse it seems, cuz it no longer actually manages to store even a single byte of the screen data. :/
Title: Re: Help: Screenshotting program ends up screensh*tting
Post by: calcdude84se on May 21, 2010, 07:45:18 am
I don't think you need the first "GetCalc" (did someone already say that?) and the "DispGraph" at the end seems superfluous, but it should work. Let me try...
Also, scrnview should have that last Str1 (the one in the conj( line) be M also.
As an afterthought, though I doubt this is your problem, just be aware that if there isn't enough free ram when you try to create vPIC, nothing will actually be created (since you are then proceeding to try to write to ROM, nothing bad will happen.)
Title: Re: Help: Screenshotting program ends up screensh*tting
Post by: DJ Omnimaga on May 21, 2010, 06:55:36 pm
didn't I need to use GetCalc(Str1) to point to the appvar name? Else IIRC it couldn't find the appvar

I definitively think someone needs to write a tutorial on how to use Getcalc. It is getting way too complicated and confusing
Title: Re: Help: Screenshotting program ends up screensh*tting
Post by: calcdude84se on May 21, 2010, 10:16:54 pm
no, calling GetCalc(Str1,768) creates vPIC it if it doesn't exist, deletes it and recreates it if it does, and then proceeds to return the pointer to the 768 bytes of data.
And yeah, variable management can be difficult. The "correct" way to create an appvar is a bit unwieldy, as this code that loads the value in an appvar demonstrates:
Code: [Select]
"vSCORE"->Str1
GetCalc(Str1)->X
.If it's non-zero, we're good, otherwise it's archived or non existent.
!If
    UnArchive Str1
    .If 0, it failed. Try to create the appvar
    !If
        GetCalc(Str1,2)
        .If it's 0, not enough RAM. Err and give up.
        !If
            "Not enough RAM"->Str2
            Disp Str2,i
            Return
        End
    End
    GetCalc(Str1)->X
    .This next If should never be reached
    !If
        "Serious Error"->Str3
        Disp Str3,i
        Return
    End
End
.X should now contain the pointer to the data. Phew!
Even w/o comments and indents, it still looks like this:
Code: [Select]
"vSCORE"->Str1
GetCalc(Str1)->X
!If
UnArchive Str1
!If
GetCalc(Str1,2)
!If
"Not enough RAM"->Str2
Disp Str2,i
Return
End
End
GetCalc(Str1)->X
!If
"Serious Error"->Str3
Disp Str3,i
Return
End
End
Oh, if an If has on condition following it, it's the condition on the previous line.
Title: Re: Help: Screenshotting program ends up screensh*tting
Post by: DJ Omnimaga on May 21, 2010, 10:24:03 pm
Is !If with nothing after the equivalent of If not(Ans) in BASIC?
Title: Re: Help: Screenshotting program ends up screensh*tting
Post by: calcdude84se on May 21, 2010, 10:25:58 pm
pretty much. and "If" is about the equivalent of "If Ans"
Title: Re: Help: Screenshotting program ends up screensh*tting
Post by: DJ Omnimaga on May 21, 2010, 10:31:55 pm
ooh that's good to know. I did not even know Axe supported some sort of Ans style feature (where the last value is stored after doing something). I guess that's why stuff like 1->A->B->C->D can be done

EDIT: Well I give up, I tried what you all told me to do and to no avail.

I think making a program to store pictures to appvars in Axe is impossible. It just starts reading the appvar content from the wrong location and that stuff is too much for me anyway.

If anyone wants to attempt at writing such program, feel free to do so. Kindermoumoute would appreciate very well.

EDIT: Example of what happens wrong. Both myself and him tried and we got similar results:

The image being stored to the appvar
(http://www.omnimaga.org/index.php?action=dlattach;topic=2284.0;attach=1340;image)

The image being recalled
(http://www.omnimaga.org/index.php?action=dlattach;topic=2284.0;attach=1339;image)

In my case it was more off, though.
Title: Re: Help: Screenshotting program ends up screensh*tting
Post by: Quigibo on May 22, 2010, 01:23:13 am
I'm using minimal error testing, basically if there is a problem, the program will just exit.

Copy the drawing buffer to the appvar
Code: [Select]
"vPIC"->Str1
Return!If GetCalc(Str1,768)->A
conj(L6,A,768)

Or if you want the current LCD instead
Code: [Select]
"vPIC"->Str1
StoreGDB
Return!If GetCalc(Str1,768)->A
conj(L6,A,768)

Copy the appvar to the buffer and then to the screen
Code: [Select]
"vPIC"->Str1
Unarchive Str1
Return!If GetCalc(Str1)->A
conj(A,L6,768)
DispGraph

Or simply display it on the LCD directly
Code: [Select]
"vPIC"->Str1
Unarchive Str1
Return!If GetCalc(Str1)->A
A->DispGraph
Title: Re: Help: Screenshotting program ends up screensh*tting
Post by: DJ Omnimaga on May 22, 2010, 01:31:42 am
Code: [Select]
"vPIC"->Str1
StoreGDB
Return!If GetCalc(Str1,768)->A
conj(L6,A,768)
That gives an ERR:BAD SYMBOL error at 76%
Title: Re: Help: Screenshotting program ends up screensh*tting
Post by: Quigibo on May 22, 2010, 01:38:17 am
You just found a new bug x.x  I'll fix it later, just do this for now, it does the same thing and seems to work:

Replace:
Code: [Select]
Return!If GetCalc(Str1,768)->A
With:
Code: [Select]
GetCalc(Str1,768)->A
Return!If
Title: Re: Help: Screenshotting program ends up screensh*tting
Post by: DJ Omnimaga on May 22, 2010, 01:41:42 am
Ok that works, but now Quigibo I think I found a second bug, and I fear this might be the source of all my problems. Hold on I'll try my original program on another calc model...
Title: Re: Help: Screenshotting program ends up screensh*tting
Post by: kindermoumoute on May 22, 2010, 03:51:22 am
This time there are two results, the first picture that displays whatever and another that displays a portion of the picture :/

The second picture uses "A => dispgraph" and third I do not know :/
Title: Re: Help: Screenshotting program ends up screensh*tting
Post by: kindermoumoute on May 22, 2010, 09:15:05 am
DJ Omnimaga finally found a solution that is:

Code: [Select]
.SCRNSHOT
"vPIC"->Str1
StoreGDB
GetCalc(Str1,768)->A
Return!If
conj(L6,A,768)


Code: [Select]
.SCRNVIEW
"vPIC"->Str1
Unarchive Str1
Return!If GetCalc(Str1)->A
A->DispGraph


Title: Re: Help: Screenshotting program ends up screensh*tting
Post by: ztrumpet on May 22, 2010, 12:30:21 pm
Yea, I'm glad it works. :D It's too bad there are some pretty bad errors, though...
Title: Re: Help: Screenshotting program ends up screensh*tting
Post by: DJ Omnimaga on May 22, 2010, 05:44:07 pm
yeah now my prog seems to work fine. I hope it cannot cause bad errors. I'm not sure why it stopped working in the first place considering my code was practically the same. I guess my RAM really got corrupted or something x.x