Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Xeda112358 on January 29, 2011, 02:53:08 pm

Title: CopyProg
Post by: Xeda112358 on January 29, 2011, 02:53:08 pm
So, again, I have a neat/random program that I want to add to BatLib, now. It was an idea from TIBD for me to make an opcode to copy programs to a string and it was a whole separate idea for me to copy a string to a program. However, this time, the request was to make it copy programs out of archive! So, I got my brain together, planned it out, and now I have this wicked and powerful program... in 123 bytes.

So here are some cool points to keep in mind:
-This is not limited to copying programs
-It can copy from archive or RAM
-It is not limited to copying to programs

The uses of this?  :
-Copy a picture to an appvar or program to make custom pictures
-Copy programs from archive for temp use in games
-Storing things to strings to play with

I hope this proves useful to people! Oh, and as always, opcode included :P

EDIT: Newer version: http://ourl.ca/8987/316378
Title: Re: CopyProg
Post by: Builderboy on January 29, 2011, 02:54:48 pm
Wow omg this sounds like XCopy on steroids O.O
Title: Re: CopyProg
Post by: Xeda112358 on January 29, 2011, 02:58:37 pm
in 123 bytes, too :D
Small enough for an opcode, big enough to be cool!/me goes to see what XCopy is
Title: Re: CopyProg
Post by: Builderboy on January 29, 2011, 03:00:54 pm
Its a utility to copy programs from the archive into Ram as a temp program, and to delete the temp program.  But yours has like 100% more features O.O
Title: Re: CopyProg
Post by: yunhua98 on January 29, 2011, 03:01:25 pm
amazing!  BatLib's gonna be amazing with all this stuff in it!  ;)
Title: Re: CopyProg
Post by: Xeda112358 on January 29, 2011, 03:02:21 pm
Yeah, I just checked it out! Wow, I feel really good about this one! I am almost positive of what my next command for BatLib will be!
Title: Re: CopyProg
Post by: yunhua98 on January 29, 2011, 03:03:47 pm
do you want this in BatLib subforum btw?  unless you're planning on releasing it as a independant program?
Title: Re: CopyProg
Post by: Xeda112358 on January 29, 2011, 03:05:16 pm
Oh, I plan to release it as an independent program. I just didn't expect it to work out so well. Should I make a downloads thing?
Title: Re: CopyProg
Post by: Munchor on January 29, 2011, 05:33:13 pm
Xeda, that looks pretty awezume!

http://pastebin.com/7JzQngLc (http://pastebin.com/7JzQngLc)

I used Assemblex for this. Do you recognize it?
Title: Re: CopyProg
Post by: Hot_Dog on January 29, 2011, 05:34:55 pm
That's awesome!  However, with that in mind, I think that it's a good thing that you changed the name from "SpriteLib" to something else :angel:
Title: Re: CopyProg
Post by: Xeda112358 on January 29, 2011, 06:11:53 pm
SpriteLib was named BatLib a month ago...?
Title: Re: CopyProg
Post by: Hot_Dog on January 29, 2011, 07:06:33 pm
Oh, I know that, it's just that this is another example of something that's not "Sprites" :D
Title: Re: CopyProg
Post by: Munchor on January 29, 2011, 07:17:41 pm
Xeda, that looks pretty awezume!

http://pastebin.com/7JzQngLc (http://pastebin.com/7JzQngLc)

I used Assemblex for this. Do you recognize it?

Hum.


I consider BatLib way way cooler.
Title: Re: CopyProg
Post by: Xeda112358 on January 29, 2011, 07:23:58 pm
:P Yeah... Originally it was called FontEdit, then I got to command 13 which was for tilemaps and I decided to rename it SpriteLib. Then it got to about command 42 before I changed it to BatLib. It is still centered around graphics and math, but the math part is only starting to make its presence known.
Title: Re: CopyProg
Post by: DJ Omnimaga on January 31, 2011, 02:11:06 pm
LoliB or LoliLib would be awesome, too. It contains the words Loli and lib. :P

j/k I think right now it's fine. Plus I doubt with loli in the name it would meet ticalc.org guidelines about adult content. :P
Title: Re: CopyProg
Post by: Xeda112358 on January 31, 2011, 08:01:48 pm
Wait, how is that adult content.../me wonders if she wants to know...
Title: Re: CopyProg
Post by: ztrumpet on January 31, 2011, 08:29:57 pm
This looks excellent, Xeda!  Do you think you could add features to make it able to Delete the Variables it creates?  If you do, I'll use it instead of XCopy in Elmgon. ;D
Title: Re: CopyProg
Post by: Xeda112358 on January 31, 2011, 08:52:35 pm
Do you mean create temp vars? I can check... probably.
Title: Re: CopyProg
Post by: Builderboy on February 01, 2011, 01:33:55 am
I don't think temp vars specifically, I think just the functionality to delete the variables would by nature allow programs to use them as temporary variables
Title: Re: CopyProg
Post by: Xeda112358 on February 01, 2011, 02:07:27 am
Ah, okay. Well, I was thinking I could make it so that using "[" as the prefix would make a twmp program and using "E" as the prefix would make a regular program. Then again, I could make it so that if "Delvar " was the prefix it would delete it... Okay! I think I will go with the "Delvar " prefix thing, does that sound good?
Title: Re: CopyProg
Post by: Builderboy on February 01, 2011, 02:18:01 am
Sounds good to me :D
Title: Re: CopyProg
Post by: ztrumpet on February 01, 2011, 04:34:20 pm
I almost like the DelVar idea - can it be a one byte token instead of a two byte one?  Something like - maybe? :D
Title: Re: CopyProg
Post by: Xeda112358 on February 01, 2011, 05:32:12 pm
ztrumpet is a mind reader. I was just going to look for this topic and I had just typed "copyprog" into the search thing when ztrumpet made a post. Nice. Anywho, I am glad he did because I was about to upload the version that used "Delvar " (well, actually, it could use any 'BB' token), but his way was a lot more practical. Also, I found a problem when Str1 is archived, so I fixed that. The total cost was 20 bytes, but it is definitely worth it (143 bytes). So here is how it works:

CopyProg is still compatible with the previous syntax. However, if you add a "-" (the minus sign, not the negative sign) to the beginning, you delete the var. In this case, Str1 is not needed. The name of the var to be deleted is in Ans. So for example, to delete prgmTEMP, "E" is a prefix for a program:
Code: [Select]
:"-ETEMP
:Asm(prgmCOPYPROG

Also note that there is no need to delete the variable if you want to reuse it for temporary storage. For example:
Code: [Select]
:"5PROG1→Str1
:"[T
:Asm(prgmCOPYPROG        ;appvar PROG1 is copied to prgmT
:prgmT
:"5PROG2→Str1
:"[T
:Asm(prgmCOPYPROG        ;appvar PROG2 is copied to prgmT
:prgmT
:"-[T
:Asm(prgmCOPYPROG        ;deletes prgmT

EDIT: I noticed I accidentally typed that "E" is a suffix instead of prefix :D
Title: Re: CopyProg
Post by: ztrumpet on February 01, 2011, 08:33:57 pm
Is 'E' the prefix for programs, or '['?  What are the other prefixes?

Looks great.  Nice job! ;D
Title: Re: CopyProg
Post by: Xeda112358 on February 01, 2011, 08:36:48 pm
The other prefixes are in the readme. And "E" and "[" are both program prefixes. It was just that for strings, I had → as the prefix, but that isn't normally doable in BASIC, so I use "D" for strings. There are actually 8 prefixes for each type, but the letters are easier to use.
Title: Re: CopyProg
Post by: ztrumpet on February 01, 2011, 08:43:12 pm
Ah, how'd you get 8?  Do you modulus it by 16 or something?
Title: Re: CopyProg
Post by: Xeda112358 on February 01, 2011, 08:44:50 pm
Oh, "F" happens to be 46h and "[" is 06h... I do and 1Fh, so that leaves the upper 3 bits to be anything. 2^3=8
Title: Re: CopyProg
Post by: ztrumpet on February 01, 2011, 08:58:10 pm
Ah, clever.  Gotta love bit masking. ;D  Nice! :D
Title: Re: CopyProg
Post by: DJ Omnimaga on February 02, 2011, 05:12:45 pm
Wait, how is that adult content.../me wonders if she wants to know...
http://en.wikipedia.org/wiki/Lolicon :P

Also I like the features in this :D, I'm glad to see more ASM libs for BASIC programmers.
Title: Re: CopyProg
Post by: Xeda112358 on February 02, 2011, 05:24:02 pm
Oh, that's what that is...
Anywho, pretty much all of the programs I make are intended for BASIC programmers. I have:
ASMHex-Lets you execute a string of hex code (instead of using sub programs)
BASIC Sprite- A small program to display a sprite. Uses a hex string and some vars for coordinates
DataString-Converts a list to a string or the other way around
DataType-Changes the type of variables (helpful if you have lots of sub programs or you want to hide vars)
HexToken-Converts a string of hex to its tokens
ListToReal-Copies list elements to real vars
MultiGraphs-Gives the user 16 additional graph screens to manipulate (using no user RAM)
MultiPics-Manipulate any of 256 pic vars using 6 functions
TokenHex-Converts tokens to their hex
Xtra-Makes hacked vars

I have a few other ones, but they aren't as easy to use.
Title: Re: CopyProg
Post by: DJ Omnimaga on February 02, 2011, 05:42:47 pm
This is great :D. Are they all online?
Title: Re: CopyProg
Post by: Ashbad on February 02, 2011, 05:44:56 pm
Wait, how is that adult content.../me wonders if she wants to know...
http://en.wikipedia.org/wiki/Lolicon :P

O.o
Title: Re: CopyProg
Post by: Xeda112358 on February 02, 2011, 05:44:59 pm
All of them are on TICalc, yes.
Title: Re: CopyProg
Post by: DJ Omnimaga on February 03, 2011, 12:42:49 am
Ah ok good :D . If you ever upload them here I would recommend packaging the ones that only does like one simple thing in one zip file, though, or at least the non-major ones, so it won't clutter the downloads section too much either. Also only tools that are related to game development would be allowed.
Title: Re: CopyProg
Post by: Xeda112358 on February 03, 2011, 12:50:02 am
Ah, okay. I'll see what I can do, then. That was what I was worried about-- the clutter. So, yeah, I'll put together a package then.
Title: Re: CopyProg
Post by: DJ Omnimaga on February 04, 2011, 12:36:42 am
Cool :D. More files in the archives are cool because they include what Omni people worked on (the reason why there's a 100 posts requirement), while still being available on the main download site, ticalc.org, but I try to make sure they won't get cluttered too much either. Back then about 8 people were working on sprite editors and that scared me. O.O
Title: Re: CopyProg
Post by: Xeda112358 on August 10, 2011, 06:06:51 pm
It has been a long while since I updated here on this, so I think I should now that I have time. After a few weeks of summer vacation, I added some new functionality to CopyProg. It now makes use of theta, too, but otherwise it is reverse compatible. What it now does is:
--It does the job of GetName. You specify the variable type to search for and the nth item (alphabetically) and this returns the name as a string. For example, you can use this to find the name of the third program in the programs menu.
   -This returns "." if the var does not exist. Otherwise the var name
   -The size of the variable data is returned in Theta
   -If there is a decimal part, this means the var is archived
--It can copy any var from RAM or Archive to any other var
   -If this is successfully done, Ans is 1, else it is 0
   -This automatically overwrites a preexisting var
--It can delete vars from RAM or Archive
-It can now read lines from a program and can be used to read the number of lines in the program.
   -This reads lines of program code
   -The line number read is returned in theta
   -Theta is returned as 0 if the file does not exist
-It can delete lines of code from a program in RAM


Once again, thanks mrmprog!

EDIT: Also, this program is now running at about 600 bytes, so still pretty small :)
Title: Re: CopyProg
Post by: TIfanx1999 on August 12, 2011, 09:42:21 am
Awesome work Xeda! =)
Title: Re: CopyProg
Post by: Xeda112358 on September 09, 2012, 05:42:41 pm
Woo, a small (ish) update is here. Copyprog is now 707 bytes, but I added in the ability to Archive and Unarchive variables (thanks pocketpc for messaging me to do this!) and I also fixed the little GetName bug that made Str1, GDB1, pic1 and other "<<OSvartype>>1" variables from not appearing correctly.
Title: Re: CopyProg
Post by: TIfanx1999 on September 10, 2012, 06:07:14 pm
Wow, it's been over a year since this thread has seen a new post! O.O Nice to see an update though. ;D
Title: Re: CopyProg
Post by: Sorunome on September 10, 2012, 06:53:49 pm
Cool updates after some looooooooooooong pause ^^
Title: Re: CopyProg
Post by: Xeda112358 on September 11, 2012, 12:12:05 pm
Thanks, that has been a long time. I feel old o.o I think it was a useful update though, and I finally remembered to upload the new version to TICalc (which had only the original version XD)
Title: Re: CopyProg
Post by: Xeda112358 on November 26, 2012, 06:40:16 pm
Well, I found a few bugs and I've no clue how they got there since I specifically addressed them in the last update. Anyways, GetName was almost completely broken. It wasn't returning names properly in many cases and it was returning the wrong sizes for archived vars (I know how that bug snuck in... I optimised something and forgot to update something else). Anyways, I decided to fix the command and then update it a bit to make things worthwhile :)



Unfortunately, the cost of this was 52 bytes of code in all, bringing the total to 759 bytes :[ On the other hand, it makes things much easier/better when using the program for a shell >.>
Title: Re: CopyProg
Post by: blue_bear_94 on July 01, 2013, 04:14:50 pm
I found another bug.
On both 2.11 and 2.12, line reading produces a lot of garbage when trying to read archived programs.
Title: Re: CopyProg
Post by: Xeda112358 on July 01, 2013, 09:31:28 pm
Sorry for the long wait, I share the internet :P Anyways, thanks for notifying me of the bug! As said on IRC, there was a snippet of code deleted that saved the flash page of the data. I fixed that and tested a few more functions to make sure they worked (though there could still be bugs).

Hopefully I didn't leave in any bad code.
Title: Re: CopyProg
Post by: blue_bear_94 on July 01, 2013, 09:34:30 pm
Thanks for fixing the bug! My (WIP) TI-Basic RPG was planning to rely on your wonderful program.
Title: Re: CopyProg
Post by: Xeda112358 on July 01, 2013, 09:40:37 pm
Awesome, have you seen my GrpRead, TPROG, and LblRW programs, too ? Those are also pretty powerful for BASIC games like RPGs. The first is like CopyProg for groups (it allows you to access data from the groups and extract variables, read lines from variables, and recall pictures from groups). The other is like a simplified CopyProg that is designed specifically for loading archived subprograms to RAM and cleaning them up (it is also tiny). LblRW is rather epic since it allows you to edit data inside your program by overwriting lines or reading lines starting at a label. This lets you keep user data directly in the program (for example, you can make a label called Lbl SV and store the user name and any string data to the lines following). I used that to store monster data, item data such as prices and descriptions, and all sorts of similar code that way.
Title: Re: CopyProg
Post by: blue_bear_94 on July 01, 2013, 09:41:19 pm
I've heard only of TPROG.
Title: Re: CopyProg
Post by: Xeda112358 on July 01, 2013, 10:10:38 pm
Sorry, my computer died (bad battery, off the charger for about a minute). Anyways, GroupRead can be found on TICalc here (http://www.ticalc.org/archives/files/fileinfo/451/45164.html) and LblRW can be found here. (http://ourl.ca/17635/325962)
Title: Re: CopyProg
Post by: blue_bear_94 on July 02, 2013, 04:04:10 pm
Found another bug.
On 2.13, line-reading sometimes still produces garbage for archived programs.
Title: Re: CopyProg
Post by: Xeda112358 on July 03, 2013, 12:21:00 pm
In particular, do you mean empty lines, or is it on lines that actually have data? I only encountered a problem with that on newlines, but if you could give an example of it failing on lines with data, that could be helpful (before I release another update).
Title: Re: CopyProg
Post by: blue_bear_94 on July 03, 2013, 12:54:55 pm
It's broken for data too.
I'll attach the necessary programs for you to reproduce the problem. (thetaD1 needs to be archived.)
Set U to 1, V to 0, W to 0, X to 6, and Y to 13. Run RD.
If Str4 isn't filled with garbage, then change the values of V and W to something 0 to 5, inclusive, then rerun RD.
Title: Re: CopyProg
Post by: Xeda112358 on July 03, 2013, 03:18:38 pm
This should fix it. There was a line of code checking for the parity of a result instead of whether it was positive or negative. Essentially, I used jp pe, instead of jp p,.

Oops.
Title: Re: CopyProg
Post by: blue_bear_94 on July 03, 2013, 03:29:48 pm
Still a bug when V=1 and W=1, or when V=1 and W=0.

Edit: the full upload.
Title: Re: CopyProg
Post by: Xeda112358 on July 04, 2013, 11:54:45 am
Okay, now let's try this. I figured out the problem and even a rookie wouldn't have made this mistake! I forgot to modify HL after crossing a page boundary.
Xeda112358 has shame.
:P
Title: Re: CopyProg
Post by: Jonius7 on July 09, 2013, 03:29:51 am
Ah I see, testing Elvyna with Copyprog. ;) Unfortunately I can't get it to work with WabbitEmu.
Title: Re: CopyProg
Post by: Xeda112358 on July 09, 2013, 05:57:43 am
Hmm, you cannot get CopyProg to work? What isn't working? I tried the line reading and that works, and copying from one var to another worked for me, as well as the GetName instruction works for programs and whatnot (I just tested it and there is an issue with strings and whatnot, but it still returns strings in an appropriate format).
Title: Re: CopyProg
Post by: blue_bear_94 on July 15, 2013, 03:51:32 pm
Hmm, this chunk of code gives me a memory error, despite having 20 KB free in my RAM, and it happens only when thetaC is in RAM:
Code: [Select]
1+200fPart(sub(R->theta
"+Etheta"+sub("CELPAS",1+int(sub(R)),1
prgmZ
Ans->Str2
theta+1->theta
"+Etheta"+sub("CELPAS",1+int(sub(R)),1
prgmZ
expr(Ans->I
(try this with R between 0 and 6 inclusive)
As usual, the contents in prgmZ is Asm(prgmCOPYPROG.
The data in thetaC:
Code: [Select]
RYVMORS
{500,0,0,0,0,0,0,0,0,1,80
RYVVAN
{0,50,0,0,0,0,0,0,0,1,80
RYVMORS2
{2E3,0,0,0,0,0,0,0,0,2,500
RYVVAN2
{0,500,0,0,0,0,0,0,0,2,500
RYVMORS3
{E4,0,0,0,0,0,0,0,0,3,4E3
RYVVAN3
{0,5E3,0,0,0,0,0,0,0,3,4E3
XPNYLL
{0,0,0,0,E3,0,0,0,0,2,250

So now reading lines from programs in RAM is bugged.
Title: Re: CopyProg
Post by: Xeda112358 on July 29, 2013, 06:55:00 am
I did not have any issues when I tried it and I tried values of R from 0 to 7 (at this point, it just kept returning the last line as it should). I tried it with the program archived and unarchived and it didn't make a difference, so maybe I forgot to upload something...?
Title: Re: CopyProg
Post by: Jonius7 on August 14, 2013, 07:10:10 pm
I'd better try again. I will attempt to do so within the next 24 hours.
Title: Re: CopyProg
Post by: blue_bear_94 on January 02, 2014, 07:22:39 pm
CopyProg apparently has problems with large line numbers now.
It can't read line 91 of the attached file, for example.
Title: Re: CopyProg
Post by: Xeda112358 on January 03, 2014, 09:29:00 am
Hmm, I feel like I corrected this bug before (I had a typo in the program reading "jp p," instead of "jp pe,". It should work now (see attached)

Thanks for letting me know!