Alternatively, join us on Discord.

[Hybrid-Basic][Library] TI-Basic DIY Library

Started by 123outerme, January 16, 2017, 12:29:41 am

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

p2

if you have the appvar OIRAM and the appvar NOMEKOP and both have the command DRAWSTUFF(
how does the game decide which one to use? :)
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

123outerme

January 16, 2017, 02:43:28 pm #16 Last Edit: January 16, 2017, 04:21:01 pm by 123outerme
Quote from: p2 on January 16, 2017, 02:26:48 pm
if you have the appvar OIRAM and the appvar NOMEKOP and both have the command DRAWSTUFF(
how does the game decide which one to use? :)

In your program, you will define which AppVar to use. You can technically use both, but there's no point since you can add as many subroutines as you want.
This is about how it is done:

:"OIRAM->Str0    // If you want the other AppVar, just change it to "NOMEKOP->Str0
:"DRAWSTUFF(20
:prgmDIYILB

What prgmDIYLIB does exactly, is it reads the string of commands in your DIYLIB, then it decides which one you've inputted (no matter the command string length) and executes the code stored under line [command number] +1, where [command number] is the order in which your CALL( appears. Another example, this time of the AppVar:

1 :DIGIT(CALL(EXECUTE(A(
2 :code for DIGIT(
3 :code for CALL(
4 :code for EXECUTE(
etc.

So for CALL(, it looks in the string for CALL(. It's the second command in the list, so it adds 2 (the listing) + 1 (offset since call names are stored in line 1)
Also, if you downloaded the original, please redownload. I made an error, so it could only handle 2 functions. Now it can handle as many as possible.

p2

really nice, might be a great help for on-calc programmers (dont have to type the same super song formula a thousand times again) xD
how big exactly is the slowdown? :)
could you do two counters, one using the external command thingy, one directly counting, and tell us the results (speed comparison)? :)
I'm really interested in how fast it is ^^
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

123outerme

January 16, 2017, 03:04:43 pm #18 Last Edit: January 16, 2017, 03:24:47 pm by 123outerme
Quote from: p2 on January 16, 2017, 03:03:30 pm
really nice, might be a great help for on-calc programmers (dont have to type the same super song formula a thousand times again) xD
how big exactly is the slowdown? :)
could you do two counters, one using the external command thingy, one directly counting, and tell us the results (speed comparison)? :)
I'm really interested in how fast it is ^^

Yeah, I was actually planning on doing that now. I'll edit with the results.
Edit:
Running this set of code to determine speed. Here you can see how many times the loop repeats and the command/equates I used.

"rowSwap(LIBNEW00→Str0
startTmr→T
For(F,1,150
"DIGIT(F
prgmDIYLIB
End
checkTmr(T-I
Ans/150→G
startTmr→T
For(F,1,150
int(1+log(real(F+(0=real(F
End
checkTmr(T)→J
Ans150→H
Disp G,H," ",I,J
Pause

Now here's the results.
[loops] = 150: DIYLIB took an average of .16 seconds to process each request, and the straight command took .013333.... seconds.
DIYLIB, in 150 loops, took ~24 seconds, while the straight command only took ~2.

p2

ouch those numbers hurt...  :ninja:
can you maybe determine where the slowdown comes from?
try a loop INSIDE the external thingy (the userdefined command).
maybe it just takes time to lookup what should be executed, while the execution itself is at regular speed again, which means the slowduwn would be much smaller for real day-to-day usage.
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

123outerme

Quote from: p2 on January 16, 2017, 03:25:21 pm
ouch those numbers hurt...  :ninja:
can you maybe determine where the slowdown comes from?
try a loop INSIDE the external thingy (the userdefined command).
maybe it just takes time to lookup what should be executed, while the execution itself is at regular speed again, which means the slowduwn would be much smaller for real day-to-day usage.

I'm almost positive the issue is finding the command to be used. It basically runs a whole While loop to find the command. That, jumping between programs, and the simple fact that any code that does more than just the equation will inevitably be slower; I'm running all this code to find the equation, then the equation itself.

kotu

shouldn't you store each command's lookup address before you start? idk never programmed a emulator or anything like that b4
SUBSCRIBE TO THE FUTURERAVE.UK MAILING LIST
http://futurerave.uk

123outerme

Quote from: kotu on January 16, 2017, 03:29:00 pm
shouldn't you store each command's lookup address before you start? idk never programmed a emulator or anything like that b4

Because each command can be a variable number of letters, I have to find where each opening parentheses are. There's no way to do this other than a loop. It basically checks the if the command you're attempting to call is anywhere in the system, and what expression/algorithm it goes to.

DJ Omnimaga

I'm kinda curious if some sort of game can be made out of this, such as a turn based text based fighting game

123outerme

Quote from: DJ Omnimaga on February 05, 2017, 04:39:53 pm
I'm kinda curious if some sort of game can be made out of this, such as a turn based text based fighting game

It's possible. I think I want to update this though, so I can improve speed. This is the pseudo-code for what this already does:
Get the input string
Read the DIYLIB appvar to determine which command is being called; repeats through the "master string" holding every command name
Execute the code on one on the corresponding line

and this is the pseudo-code for what I'd want it to do, should I update it:
Get the input string
Read every other line of the appvar until you find the command being called
Execute the code, which appears on the next line

I don't have an exact estimate for the speed increase, it really depends on how many commands it'd have to read before finding the one you want. On the other hand, the current version has a constant speed (12x slower than just writing out the command). The DIY Library is, in my eyes, more suitable for saving bytes than anything. I would recommend it just to use it for setting up variables at the beginning of a program that require a really large algorithm to be executed. I'm guessing the fastest the second method I shared would be at its fastest, probably 4x slower than just writing out the command. At its slowest, it's probably unusable (again, if it has to search through a lot of commands to find what you want).

DJ Omnimaga

Ah ok. I guess it can still be handy if the program size + this lib size is worth it or if it makes development much more simple without making the program unuseable speed-wise. In any case, good luck if you ever update this.

Powered by EzPortal