Omnimaga
Omnimaga => Completed => Our Projects => BatLib => Topic started by: Xeda112358 on March 13, 2011, 02:33:32 pm
-
Now that I have put some serious work into BASIC ReCode, I figured a topic should be started to explain routines, help people out, and to share ideas. First off, here is what I have managed to make using the current version of ReCode:
(http://www.omnimaga.org/index.php?action=dlattach;topic=6412.0;attach=6557;image)
That took 809 bytes of memory, but you can see it has speed and ability. You can download a PDF of the commands and syntax below, but as a warning, the While command will fail miserably if there is an End statement inside of it. So for example:
While getKey≠15
getKey→A
If A=9
Then
Fill(2
DispGraph
End
End
This will fail because it will try to pick up at the second End when it exits the loop and that End will send the parser to another random spot in memory. This isn't a problem if the parser can reach a Stop, but it isn't likely. For now, using a trick that results from the way the parser is designed, you can avoid If Then...End statements by putting a space after non-text commands (text is read until it reaches a newline token). For example:
While getKey≠15
getKey→A
If A=9
Fill(2 DispGraph
End
It uses less memory, anyway and is faster, but I added the If Then...End form for readability.
Here is the readme to ReCode:
-
Woah! It looks awesome, seems like Axe too, really fast for an Axe program!
AWESOME.
-
Oh, that's not Axe... This is an interpreted language, like BASIC!
-
Oh, that's not Axe... This is an interpreted language, like BASIC!
I know, but it is a language with BASIC's syntax but better speed and capabilities.
Not the compiled part.
-
Yep ^_^ The only problem is that when I started it, I hadn't heard of Axe, so I modeled the math differently :( Apparently Axe does math in the exact opposite order as ReCode, so it could be confusing for Axe users !_!
-
Wow that looks really fast, nice job!
-
Wait, Xeda, in the screenshot you do:
prgmBROCKEAT
No Asm( or is it DoorsCS Homerun hook? No Asm( and that speed looks great ;)
-
Hehe, BASIC ReCode works inline with BASIC. in prgmBLOCKEAT, the last few lines that display score are BASIC. So for example:
ClrHome
Disp "THIS IS BASIC
dim(40
Disp 1,0,THIS IS SPARTA!
Disp 2,0,ER...I MEAN, RECODE!
Pause While getkey≠15
AsmPrgmEF4045C9
Stop
Pause "AND MORE BASIC!
-
Hehe, BASIC ReCode works inline with BASIC. in prgmBLOCKEAT, the last few lines that display score are BASIC. So for example:
ClrHome
Disp "THIS IS BASIC
dim(40
Disp 1,0,THIS IS SPARTA!
Disp 2,0,ER...I MEAN, RECODE!
Pause While getkey≠15
AsmPrgmEF4045C9
Stop
Pause "AND MORE BASIC!
WOW! That's pure epic!
-
Aw, thanks! Okay, I plan to add some sprite stuff, when I got time (Mondays are my busy days). But before I do that, I want to add support for working with the BASIC strings and a second set of number vars. So for example, not only will you have A,B,C.... you will have A',B',C'..., too.
Also, I did double check and ReCode is allowed in the competition (it is in the category of Hybrid BASIC) if anybody was wondering. The same goes with BatLib :D
-
Okee dokey then, I have now added several functions:
' is used to use the second set of vars (for example, A'-1→B)
" is used to use a BASIC string (for example, Text(0,0,"Str1)
RecallPic is used to copy pictures to the graph screen (for example, RecallPic 23)
StorePic is used to store the graph image to a picture (for example, StorePic 17)
Full is used to set the clock speed to 15MHz (or 6MHz if you add a 0 to the end)
Pt-On( draws a sprite using a hex string.
All string arguments must be the last on a line, so with the Pt-On( thing, you need to do something like this:
:0
:Pt-On("Str1
:8,0,0,2
I'm a bit sleepy at the moment, so I'm not going to go into too many details. If anybody has questions or ideas for changes/additions, feel free to mention them!
-
Hey with the DS<( command, can it exit a ReCode block and repeat a section of Basic? Or can it even exit one Block and enter another?
:dim(40
:Stuff here
:stop
:output(x,y,"...
:dim(40
:1
:DS<(3 (or 5)
:stop
-
It wouldn't exit ReCode, but it would try to execute the BASIC data as ReCode data. However, it would be pretty cool to make it recognise if it has gone to a point before the block! That is a cool idea! I would have to make it so that you could choose to make it exit the ReCode parser or not...
If I can add that in, I will try, but I cannot promise anything :D
-
Ok, because there appears no way to display numbers in variables like "X" or "A". Perhaps One could try jumping to an empty ReCode Block and have it exit there via the Stop command.
/me starts coding to test that out.
It works :D You just have to drop out in a ReCode block then exit.
-
You mean like displaying the values of the variables? Yeah, I haven't added that, yet :D
EDIT: Added :D
-
wow! That looks awesome, how did I not notice this before?/me wonders if another "Axe" is here...
Quigibo needs to watch his back now. :P
-
Well it isn't quite as fast as Axe because it has to convert all of the numbers on the fly. The main difference between Axe and this is that ReCode is interpreted so most codes should be smaller than an Axe program. Plus, you can use assembly, BASIC, and ReCode in the same program :D
With that in mind, I think my goal over the summer will be to create an app that takes total control of the RAM and is solely an environment to create and execute programs. It will not use the OS whatsoever. The problem with that, though, is that I will need to have a way to eventually give control back to the OS (for linking and to use the calc as a calc :D)
-
wow! That looks awesome, how did I not notice this before?/me wonders if another "Axe" is here...
Quigibo needs to watch his back now. :P
Well it isn't quite as fast as Axe because it has to convert all of the numbers on the fly. The main difference between Axe and this is that ReCode is interpreted so most codes should be smaller than an Axe program. Plus, you can use assembly, BASIC, and ReCode in the same program :D
With that in mind, I think my goal over the summer will be to create an app that takes total control of the RAM and is solely an environment to create and execute programs. It will not use the OS whatsoever. The problem with that, though, is that I will need to have a way to eventually give control back to the OS (for linking and to use the calc as a calc :D)
Xeda, don't be modest, yunhua98 is right, this is looking pretty awesome.
Can you make an example with smoothscrolling?
-
I want to give some respect points, but Xeda's respect is the perfect square of 12... :P
/me gives it anyway.
-
I want to give some respect points, but Xeda's respect is the perfect square of 12... :P
/me gives it anyway.
I'll take away her respect to to be 12^2 again >D
-
Xeda this IS awesome. The fact that BASIC or ASM can be integrated with no effort make it unique. I'm very interested to see where you take this. :D
-
I also like the fact that we have a fast interpreted langauge.
-
Wow, I just saw the thing about A' (and the other vars). That's awesome! ^-^
Great job on this, Zeda. :)
-
Can you make an example with smoothscrolling?
My next command goal is to make use of pointers to data and the ability to read and write data. From there, I can make use of the sprite commands and possibly make a smoothscrolling thing :)
I want to give some respect points, but Xeda's respect is the perfect square of 12... :P
/me gives it anyway.
Aww, now I need 18 more :( !_!
-
Can you make an example with smoothscrolling?
My next command goal is to make use of pointers to data and the ability to read and write data. From there, I can make use of the sprite commands and possibly make a smoothscrolling thing :)
I want to give some respect points, but Xeda's respect is the perfect square of 12... :P
/me gives it anyway.
Aww, now I need 18 more :( !_!
Give us a smoothscrolling example (sprites and all that stuff, pointers, etc) and you'll have a few more :)
-
Aw, I added pointers and some new things and I tried making a tilemap routine in ReCode... :(
It took 25/64 of a second to produce and display a tilemap. That means it can only produce 5 tilemaps in 2 seconds which doesn't look smooth at all :( Anywho, the new commands and syntax are:
Pt-Off( copies some bytes from a var to a fixed RAM area and returns a pointer to it in Ans
using {#,Size instead of a string will use the bytes at address # as data.
-
Well it isn't quite as fast as Axe because it has to convert all of the numbers on the fly. The main difference between Axe and this is that ReCode is interpreted so most codes should be smaller than an Axe program. Plus, you can use assembly, BASIC, and ReCode in the same program :D
With that in mind, I think my goal over the summer will be to create an app that takes total control of the RAM and is solely an environment to create and execute programs. It will not use the OS whatsoever. The problem with that, though, is that I will need to have a way to eventually give control back to the OS (for linking and to use the calc as a calc :D)
That would be nice. It would be great if we could create/read from appvars like Axe does if it's not possible already, and use them as memory areas to store data. I guess safeRAM areas would be out of the question, though. X.x
-
For now I will need to, but if I do make that programming environment, I am going to be writing my own variable structures and VAT, so there will be more RAM to be used and there will be vars that ReCode can use. My plans are to add these vars:
Pictures (variable size?)
Programs
Strings
Lists
Matrices
Numbers
Data
-
Ah nice, but I wonder how it would work in BASIC, since the other RAM is used by the OS sometimes in BASIC?
-
Oh, that version would not use BASIC at all :( It would use its own tokens, its own variables, et cetera and it would only work with the OS through entering or exiting the environment.
-
Oh ok, you mean it would kinda be a totally new language where BASIC cannot be used, like MLC and BBC Basic, but using the PRGM editor, unlike BBC Basic?
-
Is there a stand-alone thing for recode, or does it only run with Batlib?
-
What do you mean by stand alone? For now, ReCode is available only with BatLib because it uses BatLib routines and because apps always use multiples of 16384 bytes (even if it only has 1 byte of actual code). So, since both still fit on one app page (and there is still over 5000 bytes of code space left before it fills up), I have the two combined. I could make a ReCode app, but to ensure compatibility, it would still require dim(40 to begin ReCode. So if you want, you can think of BatLib as ReCode with BatLib included XD
-
So Xeda, have you added comments to BatLib yet?
Wondering, since I'm starting to program in BatLib today :D
-
I have not added it, but it won't be difficult. Is there a token in particular that should start a comment? I was thinking a newline followed by a space...
-
I have not added it, but it won't be difficult. Is there a token in particular that should start a comment? I was thinking a newline followed by a space...
I'd like it to be // like in most languages, or at least something that's not a space, the space is hard to spot and some people might want to use identation.
-
I can probably do that as well as make a space a null character. Still, I think space are easy to spot since the screen is so small :P
-
I can probably do that as well as make a space a null character. Still, I think space are easy to spot since the screen is so small :P
What about indentaters?
-
Yeah, I will leave spaces as null commands.
-
I think // is best for comments (c++ programmer here XD ) Also, if you haven't added it already, will you add a command to display a variable?
Edit: 200th post! XD
-
Do you mean like display A or A'? For that you can use log(Text( and it will display the value in some base. If you omit the base, it automatically outputs in base 10 :)
-
Oh ok I see, thx. (I gotta update batlib on my calc soon x.X ) :P
-
Yeah, I plan to make a new update soon, anyway. I have to fix >, I have added // comments as well as 2 other commands. I am working on command 93 which will let you insert a list somewhere inside another list. I also need to add 3 more commands to do that for strings (deleteing bytes, inserting, and inserting other strings).
-
Hmm, // comments? Thats actually very nice, I was tired of only having a string stored to Ans as a possiblility in BASIC. Nice work :D
-
Hehe, thanks :) I was actually a little iffy about using //, but it really does look nice :) Also, it only works after a newline and it pretty much just skips the whole line and moves to the next one when it reaches a //
Does anybody else have any coding conventions that I should add?
-
Hehe, thanks :) I was actually a little iffy about using //, but it really does look nice :) Also, it only works after a newline and it pretty much just skips the whole line and moves to the next one when it reaches a //
Does anybody else have any coding conventions that I should add?
/*
*/ Maybe for multiline comments.
-
How would it work? Can you give an example?
-
How would it work? Can you give an example?
As in most PC languages:
/*
All these lines are comments
The goal of this program
is to clear the
screen/LCD
*/
dim(40
Fill(0
//The last line clears the screen
Stop
-
Okay, then in that case maybe I can make it so that if you do /Then, the comment will end with an End statement (to save a byte?) Would that work?
-
Okay, then in that case maybe I can make it so that if you do /Then, the comment will end with an End statement (to save a byte?) Would that work?
Yes, it would :D
-
I just realised that I will need to change the Pause While command because it will cause problems if it is inside of another block (the parser reads the "While" and expects another End). So I am thinking of changing it back to Pause If like I once had it. Does anybody have any better suggestions?
-
I highly recommend adding Goto and Labels if you can :)
-
Yes, I plan to add them, but I don't know how soon and I don't know if I want to add support for long labels or just one or two byte labels like the OS.
-
Yes, I plan to add them, but I don't know how soon and I don't know if I want to add support for long labels or just one or two byte labels like the OS.
You mean, you'll only be using jr's?
-
Yes, I plan to add them, but I don't know how soon and I don't know if I want to add support for long labels or just one or two byte labels like the OS.
You mean, you'll only be using jr's?
Sorry, I don't know what you mean :/ In TI-BASIC, labels can be letters or numbers and can either be 1 or 2 of them in any combination. I know in a lot of other programming languages, you can make longer labels than that. I am not sure if I want to add label support for that or not. If I keep it at a one or two byte limit, it will be faster :)
-
Yes, I plan to add them, but I don't know how soon and I don't know if I want to add support for long labels or just one or two byte labels like the OS.
You mean, you'll only be using jr's?
Sorry, I don't know what you mean :/ In TI-BASIC, labels can be letters or numbers and can either be 1 or 2 of them in any combination. I know in a lot of other programming languages, you can make longer labels than that. I am not sure if I want to add label support for that or not. If I keep it at a one or two byte limit, it will be faster :)
I meant, you said Labels will have a limited range, so I guessed you would only use 18** for labels (in the hex code).
-
I don't remember saying that... :/ Also, BatLib doesn't work that way, so it wouldn't use a jr :P There is a pointer stored in RAM that tells where the next byte to parse is. Actually, I use the same pointer as the BASIC parser, which is why when it reaches "Stop" the BASIC program pics up where it left off. That is also why ReCode can execute after C000h
-
I don't remember saying that... :/ Also, BatLib doesn't work that way, so it wouldn't use a jr :P There is a pointer stored in RAM that tells where the next byte to parse is. Actually, I use the same pointer as the BASIC parser, which is why when it reaches "Stop" the BASIC program pics up where it left off. That is also why ReCode can execute after C000h
I misunderstood this:
nd I don't know if I want to add support for long labels or just one
Sorry.
-
Sorry about that :/
-
Sorry about that :/
No problem, but numbered labels are good too :D
-
Is there a kill switch, like ON in basic?
-
No, not yet :/ I have to figure out interrupts and then I can do that :)
-
I would like ON to break if the coder allows it. So for debugging I'll turn it on but for releases I won't.
-
That would be handy if you got stuck ;)
-
Hmm, then I guess I will have to make another effort at learning how to make interrupts :/
Also, I am getting ready for the next BatLib update :)
-
Hmm, then I guess I will have to make another effort at learning how to make interrupts :/
Also, I am getting ready for the next BatLib update :)
Awaiting it anxiously :)
-
If you make a kill swich, there should be a command to turn it off/on like what scout was saying.
-
That would be an excellent idea! Like a command to do that... Also, I was thinking that maybe the user could specify a kill switch or a combination?
-
That would good. You could then make a password program just by starting a loop, and waiting for the key combo to break the program. I was also wondering how much faster Recode is than Basic.
-
Well,, if you check the screenshots, with graphics, ReCode is much faster. So if you are making a game, ReCode is great for graphics rendering, especially when you have 15MHz mode. If you checkout the Block Eater example made first in BASIC, then ReCode, I would say that it is several times faster in ReCode.
-
I figured out why recode was looping! Key codes are different!
Do you have a chart?
Edit: New record! I cleared my ram 9 times since I started playing with recode!
-
hehe! As long as you are having fun, RAM clears aren't bad :D Um, it uses the same key codes as xLIB and Celtic 3 (the real(8 command) I will look for a chart and include it in the readme at some point, too.
Really quickly, though, 9=Enter, 15=Clear, 55=Mode, down=1, up=4, left=2, right=3
If you run this code, it will return the keycodes:
Lbl 0
dim(43
If Ans and Ans≠A
Then
Ans→A
ClrHome
Output(1,1,Ans
End
Goto 0
You It will return individual values for two key presses, too, so the highest value (mode+del) will return 3247
-
Zeda: Thanks for the code on how to dim(56 inside ReCode blocks =D
-
dim(56 has some drawing functions... Is that the command you are talking about?
-
dim(56 has some drawing functions... Is that the command you are talking about?
I mean dim(52 for displaying hex data sprites.
-
Ah, okay :D I will explain this one to others who haven't used the trick before... In ReCode, you can pass string arguments, but they are ended by a newline, not an end quote. So, if you want to use dim(52 in ReCode to display a sprite, instead of doing dim(52,"3C4281818181423C",8,0,0,0:
:dim(40 ;to start the ReCode block
:dim(52,3C4281818181423C
:8,0,0,0
:DispGraph
:Stop
-
I would call it half a trick and half a bug :P I'd rather have Recode Stings working properly :P
-
Well I included it that way because I wanted people to be able to use tokens like " and → for data :P If you were to use dim(53 or Disp, you might want to use tokens :P I did purposefully make it so that you need a newline to end it :)
-
Well I included it that way because I wanted people to be able to use tokens like " and → for data :P If you were to use dim(53 or Disp, you might want to use tokens :P I did purposefully make it so that you need a newline to end it :)
Then it'll be left like this? Cool enough :) Maybe include that in the next readme.
-
There is another method I included that is buggy, though :/
-
Seeing as I let you use the Correlation idea for creating a backup of data when library compatability is needed, perhaps I can borrow this idea? :D :D
Basic ReCode gave me the idea to create "Correlation IF"--taking over program reading to speed up the process of moving Correlific Mode sprites from one X/Y coordinate to another one
-
Sure, that is fine with me :) I am sure there will be plenty of happy programmers if you do that :)
-
Sure, that is fine with me :) I am sure there will be plenty of happy programmers if you do that :)
True dat ;D
-
Is this anything about mixing Libraries?
-
No, Hot_Dog seems to want to have fun making his own programming language :) It isn't about mixing libraries :P
-
No, Hot_Dog seems to want to have fun making his own programming language :) It isn't about mixing libraries :P
Thanks, I really didn't understand what he meant.
-
Am I correct to assume that Grammer will replace recode in batlib?
-
Am I correct to assume that Grammer will replace recode in batlib?
I'd vote in favour, indeed, Grammer as the new language.
-
I agree, I would definitely like to see grammer with Batlib
-
I was wondering what others would think about that idea... So once I get BatLib all converted I can just insert Grammer in there :) Grammer is simply a whole lot safer (as safe as BASIC) and has more advanced features. I'll see what I can do in the next few months :D
-
I would like Grammer with Batlib, as long as there's still the option to still use ReCode. (ReCode in Grammer or vice versa?)
-
I could keep both, but let ReCode piggyback on the more stable ReCode code. That should hopefully make ReCode safer...
-
I would like Grammer with Batlib, as long as there's still the option to still use ReCode. (ReCode in Grammer or vice versa?)
I thought of having both, but that would make BatLib huge, right?
-
It seems a little redundant. What are the differences between Grammer and Recode?
-
The main differences are a few more advanced features and Grammer is much more safe. For example, with Grammer you can press [ON] in case you make an infinite loop or do something similar whereas ReCode does not allow this. Also, Grammer gives you the option of things like sub routines, labels, and more advanced math. If I kept ReCode, it would only use calls to Grammer code so it would use only a little memory.