Author Topic: Program Copy Routine  (Read 6745 times)

0 Members and 1 Guest are viewing this topic.

Offline Iambian

  • Coder Of Tomorrow
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 739
  • Rating: +216/-3
  • Cherry Flavoured Nommer of Fishies
    • View Profile
Program Copy Routine
« on: March 30, 2009, 11:37:57 pm »
Made at the request of DJ_Omnimaga. It is a program that copies a file and puts it into a temporary program XTEMP000 to XTEMP009. To use it, first read its documentation, which is included in the zip file attached to this post.

Known limitations and bugs:
(1) Don't try to pass a zero-sized string. Although hard (I'd think) to do by accident, don't try it.
(2) The program won't copy things from RAM. The item to be copied must reside in Flash. Doesn't hurt to try, as the program will refuse to do it.
(3) Not really a limitation, but more along the lines of prevention: The copy to the temp file will not be made if the temp file in question already exists.

On-calc, this program weighs in at 179 bytes. *could* make it smaller if I tried. You know, stuff to the tune of excluding crash-preventing checks.
A Cherry-Flavored Iambian draws near... what do you do? ...

Offline kalan_vod

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2715
  • Rating: +10/-0
    • View Profile
    • kalanrock.us
Re: Program Copy Routine
« Reply #1 on: March 31, 2009, 12:41:15 am »
Is this in cletic, or just emulate from xLIB (not emulated, but what xLIB had)? This is definitely optimized well enough, but you can make it smaller if you want haha

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Program Copy Routine
« Reply #2 on: March 31, 2009, 01:30:07 am »
Wow thanks so much iambian, this should be smaller (and less limited) than resource. I hope it doesn't have any bugs x.x I'll do some testing

Kalan, this actually does something similar than xlib/celtic XTEMP function (real(10, to be exact), but for people who dont want to carry a huge 16384 bytes app with their game just for one single function (since some pure BASIC people might still want to use minimum ASM to prevent their game from being split into chapters like the old Illusiat series or FFTOM)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Program Copy Routine
« Reply #3 on: March 31, 2009, 02:16:40 am »
First bug report:

It appears the program has trouble copying programs that contains tokens that are only useable by TI-BASIC programmers on later OSes, such as %, $, #, |, _, the black arrows. When trying to copy such program, either part of the beginning code will be truncated or it will be replaced with random stuff such as RegEx. I use these characters a lot in strings, so it could be a serious issue. I am uncertain if this bug is related directly to these characters but I didn't got able to reproduce it on other files yet. Basically the copied program is corrupted. Since it's locked I had to use CODEX to unlock it to view the content, and could see the difference compared to the original file. All readme instructions followed.

EDIT: Confirmed that it only occurs with programs containing such characters early in it. I'M unsure why this happens, but this only happened with two specific files (two programs containing just strings loaded based on ifs E=a number)

EDIT 2(at least the prgm doesn,t seems signifiantly much slower than RESOURCE, even if I need to run it twice (once for deleting the prgm then another time to copy another)

EDIT 3: Attached to this post is a screenshot of the program code in TI-BASIC editor. Since I couldn't get the files with such characters to send on wabbitemu (until I reinstalled TI-Connect) I used my digital cam for now
« Last Edit: March 31, 2009, 05:34:34 am by DJ Omnimaga »

Offline kalan_vod

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2715
  • Rating: +10/-0
    • View Profile
    • kalanrock.us
Re: Program Copy Routine
« Reply #4 on: March 31, 2009, 04:58:53 pm »
Do you delete the temp after it is created the first time? It may be that because the program was already created it was overwriten, which worked instead of making it from scratch?

Offline noahbaby94

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 585
  • Rating: +29/-24
    • View Profile
    • My blog
Re: Program Copy Routine
« Reply #5 on: March 31, 2009, 05:46:12 pm »
Must optimize....
Code: [Select]
:If E=0
Can be changed to...
:If not(E
That's what she said!!!

Offline kalan_vod

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2715
  • Rating: +10/-0
    • View Profile
    • kalanrock.us
Re: Program Copy Routine
« Reply #6 on: March 31, 2009, 05:48:12 pm »
Must optimize....
Code: [Select]
:If E=0
Can be changed to...
:If not(E
He will do what is needed later for that, just be glad he is gracing us with a ti-project again!

Offline Iambian

  • Coder Of Tomorrow
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 739
  • Rating: +216/-3
  • Cherry Flavoured Nommer of Fishies
    • View Profile
Re: Program Copy Routine
« Reply #7 on: March 31, 2009, 08:16:53 pm »
Do you delete the temp after it is created the first time? It may be that because the program was already created it was overwriten, which worked instead of making it from scratch?
Though I may have to check that, the program should refuse to write to a temp file that already exists.

Also, DJ_Omnimaga. Did you try to unarchive, change something "minor" (i.e. add in a closing parenthesis), and rearchive the variable prior to trying it again? If the problem clears up, then it might have something to do with cross-page boundaries that aren't being taken care of (which shouldn't happen because a romcall is used to do the write)
A Cherry-Flavored Iambian draws near... what do you do? ...

Offline Iambian

  • Coder Of Tomorrow
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 739
  • Rating: +216/-3
  • Cherry Flavoured Nommer of Fishies
    • View Profile
Re: Program Copy Routine
« Reply #8 on: March 31, 2009, 09:07:57 pm »
Sorry for the double post, but a potential bug may have been fixed. I also managed to get the program shrunken down by 25 more bytes. Try it out and see what the results might be. If it is what I suspect, then the problem should be solved.

EDIT: Not entirely sure if I could make the program smaller, but if you really wanted me to, I could, say, drop some of the checks to make it come close to the 100 byte mark.

EDIT2: Got it smaller by 7 bytes. Will upload soon.

EDIT3: Fixed a serious bug.

EDIT4: Changed copying method altogether
« Last Edit: April 01, 2009, 02:26:58 am by Iambian »
A Cherry-Flavored Iambian draws near... what do you do? ...

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Program Copy Routine
« Reply #9 on: April 01, 2009, 02:26:44 am »
sorry still no luck, tried your suggestion as well


And noahbaby94 I'll prbly go back through optimizing at one point, but don't jump on me everytime you see something because it has been a long while since I coded a game and I learned BASIC back when Text(-1 was barely even known and that most people didn't knew we didn't have to end quotes
EDIT: Nvm version 5 works (most discussion occured on IRC btw)
« Last Edit: April 01, 2009, 03:27:48 am by DJ Omnimaga »

Offline Iambian

  • Coder Of Tomorrow
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 739
  • Rating: +216/-3
  • Cherry Flavoured Nommer of Fishies
    • View Profile
Re: Program Copy Routine
« Reply #10 on: April 01, 2009, 06:16:05 pm »
The update should've worked. Lemmie know how well it works for large files.

I might produce a smaller file if I find any ways to improve upon the algorithm (however small).
« Last Edit: April 01, 2009, 06:19:15 pm by Iambian »
A Cherry-Flavored Iambian draws near... what do you do? ...

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Program Copy Routine
« Reply #11 on: April 01, 2009, 11:02:40 pm »
Ok confirmed that it works fine. It takes a friggin long while to copy, though (about 6 seconds for a 20.5 KB file).. not that it should be much of a problem for my game, though, but I'll try to keep my files under 10 KB and split map data and events into more sub programs if I have too many in the future, to not slow down loading before an event occurs or when entering a door

Offline Iambian

  • Coder Of Tomorrow
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 739
  • Rating: +216/-3
  • Cherry Flavoured Nommer of Fishies
    • View Profile
Re: Program Copy Routine
« Reply #12 on: April 04, 2009, 01:32:08 am »
This version bloats to about 186 bytes on-calc, but the read/write speed is about as fast as you can get it for this type of program ( ~1sec for 20KB files ). Hope this addresses the issue.
A Cherry-Flavored Iambian draws near... what do you do? ...

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Program Copy Routine
« Reply #13 on: April 04, 2009, 12:13:29 pm »
this one seems faster, map loading in my game returned to ZCOPY speeds so that's good

Offline Galandros

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1140
  • Rating: +42/-10
    • View Profile
Re: Program Copy Routine
« Reply #14 on: April 07, 2009, 10:24:08 am »
Cool. I will see the code to learn something. I am not used to TI-OS routines :P

Also a nice lib to large but pure BASIC games...
Hobbing in calculator projects.