Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: pimathbrainiac on February 25, 2013, 12:26:17 pm

Title: really big files and how to use them
Post by: pimathbrainiac on February 25, 2013, 12:26:17 pm
So... I got an appvar read from the archive (using files) in my VVVVVV port! The appvar is a 768 byte list and uses the following code:

Code: [Select]
!If (GetCalc("vVVVSAV",Y0)->V)
Output(0,0,"CREATING SAVE")
Pause 1000
GetCalc("vVVVSAV",768)
GetCalc("vVVVSAV",Y0)->V
2->{L+3}->{L+7}
0->{L+0}->{L+1}->{L+2}->{L+8}->{L+9}->{L+18}->{L+19}
8->{L+5}->{L+14}
48->{L+6}->{L+15}
0->{L+10}->{L+12}
0->{L+11}->{L+13}
Copy(L,V,768)
End
Copy(V,L,768)
{L+0}->A
{L+1}->B
{L+2}->C
{L+3}->D
{L+5}->F
{L+6}->G
{L+7}->H
{L+8}->I
{L+9}->J
{L+10}->K
{L+11}->L
{L+12}->M
{L+13}->N
{L+18}->S
{L+19}->T
{L+14}->X
{L+15}->Y

It works completely and totally!

My problem: I have a 9600 byte appvar (made by another program I made) for the maps. It works in the normal way (without files)

Code: [Select]
GetCalc("vPIMAP")->U

But when I use it with files:

Code: [Select]
GetCalc("vPIMAP",Y1)->U

It goofs up the graphics routine and everything that calls that appvar.

Any help?
Title: Re: really big files and how to use them
Post by: leafy on February 25, 2013, 01:28:52 pm
I haven't really looked through the problem, but here's a little trick you can use to optimize your code a whole lot -

Code: [Select]
{L+0}->A
{L+1}->B
{L+2}->C
{L+3}->D
{L+5}->F
{L+6}->G
{L+7}->H
{L+8}->I
{L+9}->J
{L+10}->K
{L+11}->L
{L+12}->M
{L+13}->N
{L+18}->S
{L+19}->T
{L+14}->X
{L+15}->Y

can be replaced with

Code: [Select]
Copy(L,{E}9CFB,16)

where {E} is the EE key where your comma is on the keypad.

In addition,
Code: [Select]
Copy(L,V,768)
can generally be replaced with

Code: [Select]
Copy(L,V)
becuase 768 is the default size argument.
Title: Re: really big files and how to use them
Post by: calc84maniac on February 25, 2013, 01:47:39 pm
I haven't really looked through the problem, but here's a little trick you can use to optimize your code a whole lot -

Code: [Select]
{L+0}->A
{L+1}->B
{L+2}->C
{L+3}->D
{L+5}->F
{L+6}->G
{L+7}->H
{L+8}->I
{L+9}->J
{L+10}->K
{L+11}->L
{L+12}->M
{L+13}->N
{L+18}->S
{L+19}->T
{L+14}->X
{L+15}->Y

can be replaced with

Code: [Select]
Copy(L,{E}9CFB,16)

where {E} is the EE key where your comma is on the keypad.
False. First of all, there are alphabetical gaps in those variable names. Secondly, variables are two bytes large and a Copy() won't skip every other byte. Lastly, it's very bad practice to use raw hex values as variable pointers, the ° operator exists for a reason.
Title: Re: really big files and how to use them
Post by: leafy on February 25, 2013, 01:54:06 pm
Whoops, my bad! Ignore my post, please.
Title: Re: really big files and how to use them
Post by: Hayleia on February 25, 2013, 02:19:09 pm
Code: [Select]
GetCalc("vPIMAP",Y1)->U

It goofs up the graphics routine and everything that calls that appvar.

Any help?
Remove the useless "->U" and replace all your "U" after this line by "Y1". And don't forget to archive your appvar.
Title: Re: really big files and how to use them
Post by: pimathbrainiac on February 25, 2013, 02:23:35 pm
Code: [Select]
GetCalc("vPIMAP",Y1)->U

It goofs up the graphics routine and everything that calls that appvar.

Any help?
Remove the useless "->U" and replace all your "U" after this line by "Y1". And don't forget to archive your appvar.

I've tried that and I get a parenthesis error in my graphics routine (the one Pt-On that uses that) and only there (and ALL I did was replace all the Us with Y1s, I didn't even touch the parenthesis!)
Title: Re: really big files and how to use them
Post by: Hayleia on February 25, 2013, 02:28:24 pm
Ah i guess ypu put a Y1 in your pt-on, which is forbidden.
Then, try this instead (sorry, i am on android so i'll post a weird syntax)

Getcalc appvpimap,Y1
Copy Y1,L3,768

Then replace all the Us (the ones i said shoumd become y1s) by L3
Title: Re: really big files and how to use them
Post by: pimathbrainiac on February 25, 2013, 02:29:18 pm
But the appvar is 9600 bytes, not 768!
Title: Re: really big files and how to use them
Post by: Hayleia on February 25, 2013, 02:33:52 pm
Lol, then you have two solutions: either create a temporary appvar with the right size (pointed by U) and copy the archived one in it, or copy 8 bytes of data to a temporary buffer like L3 before each pt-on. For example, if your Pt-On is like Pt-On(X,Y,f(Y1)), you can replace it by Copy(f(Y1),L3,8):Pt-On(X,Y,L3)
Title: Re: really big files and how to use them
Post by: Streetwalrus on February 25, 2013, 03:09:17 pm
It's crazy slow to make a TMP copy every time you draw. Also, files work form RAM. :P
Title: Re: really big files and how to use them
Post by: pimathbrainiac on February 25, 2013, 03:15:52 pm
Well, I gots this working with Hayleia over IRC! Thanks y'all!
Title: Re: really big files and how to use them
Post by: Streetwalrus on February 25, 2013, 03:19:04 pm
Nice to hear !
Title: Re: really big files and how to use them
Post by: Hayleia on February 26, 2013, 01:15:53 am
It's crazy slow to make a TMP copy every time you draw. Also, files work form RAM. :P
They work from RAM but there is no point using them from RAM :P
And it may be too slow for moving tilemaps but he only draws the map once (I guess) and then only the player moves, so the loss of speed isn't a big problem here.

Well, I gots this working with Hayleia over IRC! Thanks y'all!
Great :D