One Click - Checkbox Enabled (1)

GPC2 script programming for Titan Two. Code examples, questions, requests.

Re: One Click - Checkbox Enabled (1)

Postby Prototype » Sat Aug 24, 2019 8:35 pm

UK_Wildcats_Fans wrote:Thank you. I was completely missing the binary to hex conversion, which was the whole key. I created the attached Excel worksheet to help people figure out the hex value based upon specific bit values.

I developed and published a Checkbox with bit offset example script.

:smile0517:
Console tuner since my 1st controller.
Scripting, a game in the game.
Believe or dare, It's Titanic! :smile0517:
User avatar
Prototype
Major General
Major General
 
Posts: 3251
Joined: Sun Dec 16, 2012 1:43 pm

Re: One Click - Checkbox Enabled (1)

Postby Scachi » Tue Sep 10, 2019 9:59 am

As it isn't possible (as far as I know) to set a single bit of a byte without also setting the other bits of that byte I have added a feature request at github for that: https://github.com/J2Kbr/GtunerIV/issues/341
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: One Click - Checkbox Enabled (1)

Postby UK_Wildcats » Wed Sep 11, 2019 5:12 am

Yes, you have to set the full byte and cannot set an individual but. If you want to set a bit, you have to know the the state of all other bits of the byte.
User avatar
UK_Wildcats
Brigadier General
Brigadier General
 
Posts: 2243
Joined: Thu Jan 08, 2015 6:53 pm

Re: One Click - Checkbox Enabled (1)

Postby Scachi » Wed Sep 11, 2019 5:21 am

Doing this by code from within a script isn't a problem. I keep the whole byte in a variable and checking/changing the matching bits within it. I can simply write the whole byte back this way.
This isn't working with Prefets / config=control as it isn't possible to read the current state there/set a single bit.
I would like to be able to do that via presets. If I want to be able to toggle different flags/bits via presets I have to put them into seperate bytes to not set the other flags in that byte too I don't want to change..wasting bits.
Thats the reason for the feature request.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: One Click - Checkbox Enabled (1)

Postby Scachi » Wed Sep 11, 2019 7:01 pm

That was fast :smile0517: https://github.com/J2Kbr/GtunerIV/issues/341

Operations OR and AND added on Gtuner IV 1.05 revision 1 (I suggest wait the same update be available on Gtuner Air before publish scripts).

Here is how this works:
GIVICFG:#02:04 Assign the hex value 04 to position hex 02
GIVICFG:#02|04 Bitwise OR the hex value 04 with the current value on position hex 02
GIVICFG:#02&FB Bitwise AND the hex value FB with the current value on position hex 02


Found this page explaining AND + OR a bit with examples: https://www.programiz.com/c-programming ... -operators
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: One Click - Checkbox Enabled (1)

Postby Prototype » Wed Sep 11, 2019 8:17 pm

Awesome :joia:
Console tuner since my 1st controller.
Scripting, a game in the game.
Believe or dare, It's Titanic! :smile0517:
User avatar
Prototype
Major General
Major General
 
Posts: 3251
Joined: Sun Dec 16, 2012 1:43 pm

Re: One Click - Checkbox Enabled (1)

Postby J2Kbr » Wed Sep 11, 2019 11:08 pm

Very nice page about bitwise operations. :)

In summary: OR for set a bit, AND for clear.
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Previous

Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 150 guests

cron