Omnimaga
Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started 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
-
Wow omg this sounds like XCopy on steroids O.O
-
in 123 bytes, too :D
Small enough for an opcode, big enough to be cool!/me goes to see what XCopy is
-
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
-
amazing! BatLib's gonna be amazing with all this stuff in it! ;)
-
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!
-
do you want this in BatLib subforum btw? unless you're planning on releasing it as a independant program?
-
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?
-
Xeda, that looks pretty awezume!
http://pastebin.com/7JzQngLc (http://pastebin.com/7JzQngLc)
I used Assemblex for this. Do you recognize it?
-
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:
-
SpriteLib was named BatLib a month ago...?
-
Oh, I know that, it's just that this is another example of something that's not "Sprites" :D
-
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.
-
: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.
-
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
-
Wait, how is that adult content.../me wonders if she wants to know...
-
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
-
Do you mean create temp vars? I can check... probably.
-
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
-
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?
-
Sounds good to me :D
-
I almost like the DelVar idea - can it be a one byte token instead of a two byte one? Something like - maybe? :D
-
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:
:"-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:
:"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
-
Is 'E' the prefix for programs, or '['? What are the other prefixes?
Looks great. Nice job! ;D
-
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.
-
Ah, how'd you get 8? Do you modulus it by 16 or something?
-
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
-
Ah, clever. Gotta love bit masking. ;D Nice! :D
-
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.
-
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.
-
This is great :D. Are they all online?
-
Wait, how is that adult content.../me wonders if she wants to know...
http://en.wikipedia.org/wiki/Lolicon :P
O.o
-
All of them are on TICalc, yes.
-
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.
-
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.
-
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
-
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 :)
-
Awesome work Xeda! =)
-
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.
-
Wow, it's been over a year since this thread has seen a new post! O.O Nice to see an update though. ;D
-
Cool updates after some looooooooooooong pause ^^
-
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)
-
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 :)
- GetName now returns a decimal value in theta of precisely .1 if the program is archived.
- GetName now returns custom list names in a syntax BASIC users are more familiar with
- CopyProg (the command) now accepts the little L for custom lists in its name syntax.
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 >.>
-
I found another bug.
On both 2.11 and 2.12, line reading produces a lot of garbage when trying to read archived programs.
-
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.
-
Thanks for fixing the bug! My (WIP) TI-Basic RPG was planning to rely on your wonderful program.
-
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.
-
I've heard only of TPROG.
-
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)
-
Found another bug.
On 2.13, line-reading sometimes still produces garbage for archived programs.
-
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).
-
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.
-
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.
-
Still a bug when V=1 and W=1, or when V=1 and W=0.
Edit: the full upload.
-
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
-
Ah I see, testing Elvyna with Copyprog. ;) Unfortunately I can't get it to work with WabbitEmu.
-
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).
-
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:
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:
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.
-
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...?
-
I'd better try again. I will attempt to do so within the next 24 hours.
-
CopyProg apparently has problems with large line numbers now.
It can't read line 91 of the attached file, for example.
-
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!