GPC2 Language Reference

Tutorials, How-tos and FAQs for the Titan Two device.

Re: GPC2 Language Reference

Postby pablosscripts » Sat Dec 03, 2016 1:06 pm

Oh I see. Alright thanks!
Setup: XIM Apex, T2, K780 keyboard, G Pro Wireless mouse, SteelSeries 4HD pad, DXRacer armrest, LucidSound LS30 headset, Netduma router, Ubiquiti UniFi AP LR

My R6 script: https://youtu.be/x-9NtxyySVM
User avatar
pablosscripts
Brigadier General
Brigadier General
 
Posts: 1976
Joined: Tue Nov 24, 2015 6:27 am

Re: GPC2 Language Reference

Postby creedkiller » Mon May 22, 2017 11:47 am

can someone please shed some light on the difference between int32 and fix32, google was not much help.
creedkiller
Lieutenant
Lieutenant
 
Posts: 293
Joined: Fri Mar 17, 2017 4:08 pm

Re: GPC2 Language Reference

Postby The_Rabid_Taco » Mon May 22, 2017 1:07 pm

int32 is just a really large integer value. It can hold values between –2,147,483,648 and 2,147,483,647. That being said it can only hold integers, no decimal places. On the other hand the fix32 values can hold decimal values. Not exactly sure what the max and min are, but these are used for much more precise numbers. Things like setting the stick positions can be set with a precision using a fix32 that can not be achieved with a int32. So the major difference is if you want to have decimal digits or if you just want a solid integer.
User avatar
The_Rabid_Taco
Major
Major
 
Posts: 1066
Joined: Wed Mar 16, 2016 6:04 pm
Location: Pensacola, FL

Re: GPC2 Language Reference

Postby creedkiller » Mon May 22, 2017 8:52 pm

The_Rabid_Taco wrote:int32 is just a really large integer value. It can hold values between –2,147,483,648 and 2,147,483,647. That being said it can only hold integers, no decimal places. On the other hand the fix32 values can hold decimal values. Not exactly sure what the max and min are, but these are used for much more precise numbers. Things like setting the stick positions can be set with a precision using a fix32 that can not be achieved with a int32. So the major difference is if you want to have decimal digits or if you just want a solid integer.

thank you
creedkiller
Lieutenant
Lieutenant
 
Posts: 293
Joined: Fri Mar 17, 2017 4:08 pm

Re: GPC2 Language Reference

Postby J2Kbr » Wed May 24, 2017 5:52 pm

The_Rabid_Taco wrote:int32 is just a really large integer value. It can hold values between –2,147,483,648 and 2,147,483,647. That being said it can only hold integers, no decimal places. On the other hand the fix32 values can hold decimal values. Not exactly sure what the max and min are, but these are used for much more precise numbers. Things like setting the stick positions can be set with a precision using a fix32 that can not be achieved with a int32. So the major difference is if you want to have decimal digits or if you just want a solid integer.

Perfect ... complementing your post, the maximum value for fix32 is 32767.999985, the minimum value is -32768.000000 and the smallest unit (machine precision) is 0.000015
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: GPC2 Language Reference

Postby antithesis » Mon Jul 17, 2017 9:58 pm

UK_Wildcats_Fans wrote:Do you think that you should expand the pmem content by saving 8 bits equal a bit and give examples? For example, if you have a 16 bit variable, it will take Byte 1 & Byte 2; therefore, Byte 3 is the next available variable.

It may be good to have a general variables that defines the ranges, values, etc for the int, unit8, fix32, etc. Also include tips such as fixed variables need to be defined with a decimal (i.e 50.0 vs 50).


This is probably the biggest single hurdle to making the leap to GPC2. I have no idea what any of these variable types mean and there's no reference material in the Wiki to explain the difference, or when to use each type.

Syntax like "define", "int" and "binary" make sense as the meaning is provided in the name with very little learning curve to differentiate between them. But uint8, int32, fix32 etc are meaningless to a newcomer. I understand how "binary" applies to simple on/off operations like toggles, but uintXX, intXX, fixXX and simply 8, 16 and 32 bit numbers are over my head as to what they mean and when to use each type.

What does an 8, 16 and 32 bit number look like and what's the practical difference between them? Saying things like "it's a range of -32XXX.XXXXX to +32XXX.XXXXX" doesn't help me to code a function or combo because I don't know how those numbers translate to actual values like set_val (RX, 50), or set_val (X, 100), or if get_val (RY) > 70, or wait (400) etc.

Are these 8, 16 or 32 bit numbers and why would I use 16 or 32bit when 8 would seemingly suffice?!? I generally only ever care about a value range of -100 to +100, or more commonly 0 or 100, but are they uint8, int16 or fix32? :shocked:

These are things that programming noobs have no comprehension of and need some hand-holding to understand. GPC takes care of it by using just "define" and "int". Defines don't change their value when run through main, ints can change their value...easy-peasy. GPC2 variable types by comparison are utterly confusing!

That's why I think the titanone.gph is so brilliant - GPC has almost no learning curve and the T1 header opens T2 scripting up to many more people. To me, it's like the difference between HTML and JS. It's quick and easy to understand HTML, so anyone can do it, but it's not very powerful. JS is much more complex, so less people can do it, but offers a lot more power. But how much power does the average GPC2 scripter need?

I'm not suggesting to dumb GPC2 down, some aspects just need to be easier to understand for a complete novice. GPC nailed it by making the language accessible. GPC2 isn't as accessible, which creates a barrier to entry. Naming variables to match their purpose, or at a minimum, providing a guide to variable types will help a great deal.

Is there are more general C reference I could use to come to grips with variable types? Am I looking for C, C++, C#, or is the GPC2 sub-set part of all C variants?
Last edited by antithesis on Mon Jul 17, 2017 11:48 pm, edited 2 times in total.
Official Australian retailer for Titan One, Titan Two and XIM APEX at Mod Squad
User avatar
antithesis
Colonel
Colonel
 
Posts: 1912
Joined: Sat May 28, 2016 10:45 pm

Re: GPC2 Language Reference

Postby paname » Mon Jul 17, 2017 11:10 pm

int<n> is signed integer of n bits. so from -2^n-1 to 2^n-1
uint<n> is unsigned integer of n bits so from 0 to 2^n.

fix32 and accum are basically the same and are used for thing related to the input/output (set_val/get_val) or anything requiring precision in a script.

i think the name derive from fixed-point data type.
fixed<32,16> denotes a 32-bit fixed point number, of which 16 right most bits are used for the fractional part so some rounding happen when storing value from dec to bin but the error is acceptable (J2Kbr told us 0.000015 which i guess is 1/2^16)

i think fix32 is something similar and allow for efficient float like calculation without an FPU (floating point unit)
Last edited by paname on Mon Jul 17, 2017 11:34 pm, edited 2 times in total.
User avatar
paname
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 204
Joined: Wed Jan 07, 2015 3:02 pm

Re: GPC2 Language Reference

Postby antithesis » Mon Jul 17, 2017 11:26 pm

Thanks for trying paname, but very little of that made sense :) All I got was "use fix32 for set_val/get_val", but "fix32" itself lacks meaning, particularly when compared to the simplicity of "int" in GPC.

It may be native to you, but you've got to see this from someone's perspective who has never read a scrap of code before and sucks at algebra, which is the majority of the general population. n bits doesn't make sense to me because there's no obvious translation from n bits to a value of 1, 100, or 1000. And what the hell is signed vs unsigned?!? We don't know what we don't know, so using coding or mathematical terminology doesn't solve the problem.

There needs to be a basement-level, coming in with zero knowledge guide to this stuff. Otherwise, most people won't bother and you'll either lose a sale before the checkout, or lose a customer after purchase because they simply don't get it and there's no assistance at the right level to help them get it.

That's the problem in general for Titan Two. While it's obviously a lot more powerful than Titan One, it's also a lot harder to use. If most people don't understand how to use something without having to read a manual, they're not going to buy it. Compare the simplicity of GTuner Pro with the complexity of GTuner IV - the latter is a much more powerful tool, but it's daunting, which will turn a lot of people off.

To counter that we can now build Interactive Configs to dumb it down to the end-user level, which is a huge plus so they don't need to touch any code to customise a script. But we also need to facilitate the learning process to help folks write their own scripts & ICs, and to transition from novice to expert. Right now, it's one or the other, which is understandable given the beta status, but we'll eventually need to fill in the knowledge gap bottom-up from novice, not top-down from expert.

Does that make sense? You don't teach a child to read by handing them a copy of War and Peace. An "Idiot's Guide To GPC2" will help to break down the coding barrier and encourage more users to participate.
Official Australian retailer for Titan One, Titan Two and XIM APEX at Mod Squad
User avatar
antithesis
Colonel
Colonel
 
Posts: 1912
Joined: Sat May 28, 2016 10:45 pm

Re: GPC2 Language Reference

Postby paname » Tue Jul 18, 2017 8:41 am

to be honest i'm not sure everybody will be or need to code to use titan two.
I think there will be some visual scripting in gtunerIV for the basic stuff and the non dev should be able to use this to build complex script. then there is the GamePacks this audience will just have to drag/drop gamepack and eventually make minor adaptations via the configurator..

not everyone is a coder nor want to code at all.

i'm personally not a dev.. but in my field of work you have to know how to code or at least understand code.

and regarding 'int' in general coding this is more complicated than int32 or int16 etc.. because 'int' is platform(32 vs 64 bit) & compiler dependant so it can behave differently if you change one of these. also use just 'int' can be inefficient memory wise.
nothing is as simple as it may look and i think anyone willing to tackle GPC2 more seriously should at least read this :

http://www.learn-c.org

(GPC2 being a simplified version of C)
User avatar
paname
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 204
Joined: Wed Jan 07, 2015 3:02 pm

Re: GPC2 Language Reference

Postby J2Kbr » Tue Jul 18, 2017 10:09 am

@antithesis, to simplify:

use fix32 for everything that is related with controller inputs/outputs (set_val, get_val, etc).
and int32 for anything else.

--

On Titan One the inputs can range from -100 to 100, giving effectively 201 points of resolution. This works but is not enough in some circumstances, specially when translating mouse movement to thumbstick position, on top of that there was an increasing need for real numbers and trigonometric functions. The usual approach for these needs would be floating-point numbers, but in a platform without dedicated FPU (floating-point unit) the processing cost of floating-numbers operations is too high. The alternative is use fixed-point arithmetic, so we have the fix32 type. Historically fixed-point numbers were also referenced as accum, that is why we have accum as alias of fix32.

The fix32 type occupy 32bits of memory space (4 bytes), with 16 bits for the integer part and 16 bits for the decimal part. So, for the same -100 to 100 range, we have 13,333,333 points of resolution with fix32 type. :smile0517:
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

PreviousNext

Return to Tutorials and FAQs

Who is online

Users browsing this forum: No registered users and 34 guests