Author Topic: really big files and how to use them  (Read 4542 times)

0 Members and 1 Guest are viewing this topic.

Offline pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
really big files and how to use them
« 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?
I am Bach.

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: really big files and how to use them
« Reply #1 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.
In-progress: Graviter (...)

Offline calc84maniac

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

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: really big files and how to use them
« Reply #3 on: February 25, 2013, 01:54:06 pm »
Whoops, my bad! Ignore my post, please.
In-progress: Graviter (...)

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: really big files and how to use them
« Reply #4 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.
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 pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
Re: really big files and how to use them
« Reply #5 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!)
I am Bach.

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: really big files and how to use them
« Reply #6 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
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 pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
Re: really big files and how to use them
« Reply #7 on: February 25, 2013, 02:29:18 pm »
But the appvar is 9600 bytes, not 768!
« Last Edit: February 25, 2013, 02:29:35 pm by pimathbrainiac »
I am Bach.

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: really big files and how to use them
« Reply #8 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)
« Last Edit: February 25, 2013, 02:50:29 pm by Hayleia »
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 Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: really big files and how to use them
« Reply #9 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

Offline pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
Re: really big files and how to use them
« Reply #10 on: February 25, 2013, 03:15:52 pm »
Well, I gots this working with Hayleia over IRC! Thanks y'all!
I am Bach.

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: really big files and how to use them
« Reply #11 on: February 25, 2013, 03:19:04 pm »
Nice to hear !

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: really big files and how to use them
« Reply #12 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
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