Cronus GPC Documentation
Cronus CommunityGPC LibraryGPC Guide
  • Welcome
  • Introduction
    • GPC Explained
    • What's New with Zen?
  • Basic Syntax
  • A Simple Tutorial
  • Style Guide
  • GPC Structure
  • Basic GPC Structure
  • Definitions
  • Data Section
  • Remapping
  • Variables
  • Init Section
  • Main Section
  • Combo Section
  • User Created Functions
  • GPC Programming Basics
  • Constants
    • Zen
      • OLED
      • ASCII Constants
      • PIO
    • Keyboard
      • Keyboard
    • Controller
      • Polar
      • LED
      • Rumble
      • PS3
      • PS4
      • XBox 360
      • Xbox One
      • Nintendo WII
      • Nintendo Switch
    • Racing Wheel
      • G29
      • G27
      • G25
      • DF
      • DF GT
      • DF Pro
    • Trace
    • Memory
    • Misc
  • Flow Control
  • Persistent Memory
  • Operator Types
  • Identifiers
  • Functions & Commands
    • Internal Functions
      • Bit Functions
      • Combo Functions
      • Math Functions
      • Device Functions
      • OLED Display Functions
    • Console Functions
      • Core Console Functions
    • Controller Functions
      • Core Controller Functions
      • Rumble Functions
      • LED Functions
    • Keyboard Functions
      • Core Keyboard Functions
  • GPC Examples
    • #1
Powered by GitBook
On this page
  • set_bit
  • clear_bit
  • test_bit
  • set_bits
  • get_bits

Was this helpful?

  1. Functions & Commands
  2. Internal Functions

Bit Functions

PreviousInternal FunctionsNextCombo Functions

Last updated 5 years ago

Was this helpful?

GPC allows you to manipulate the bits of a given variable. Bit operations are quite complicated, however, there is not really much call for them in the GPC environment and most users will never need them. Therefore, this section will assume you have an understanding of bits, bit masks, how they correlate with bytes and the binary system.

Function

Description

Zen

Plus

Sets one Bit

✔️

✔️

Clears one Bit

✔️

✔️

Tests a Bit

✔️

✔️

Stores a value into a Bit Index

✔️

✔️

Gets a value from the Bit Index

✔️

✔️

set_bit

set_bit sets one bit of a variable based on its bit index

set_bit(a,5);

Syntax

set_bit ( <variable> , <bit_index> );

Parameters

<variable> : any defined variable. <bit_index> : index point of the bit to be set with a range of 0 to 15.

Returns

Nothing

clear_bit

clear_bit clears one bit of a variable based on its bit index

clear_bit(a,5);

clear_bit( <variable> , <bit_index> );

<variable> : any defined variable. <bit_index> : index point of the bit to be set with a range of 0 to 15.

Nothing

test_bit

test_bit tests a bit index point in a variable to check if it is TRUE or FALSE.

test_bit(b,2);

test_bit( <variable> , <bit_index> );

<variable> : any defined variable. <bit_index> : index point of the bit to be set with a range of 0 to 15.

TRUE if the bit is set, FALSE if it is not.

set_bits

set_bits stores a value into a variable based on its bit index and bit mask.

set_bits(c, 3, 4, 15);

set_bits( <variable> , <value>, <bit_index>, <bit_mask> );

<variable> : any defined variable. <value> : anything that has a value (constants, variables, functions, expressions, etc.) <bit_index> : index point of the bit to be set with a range of 0 to 15. <bit_mask> : bit mask corresponding to the size, in bits, of the value to store (without shifting)

Nothing

get_bits

get_bits extracts a value from a variable based on a bit index and bit mask

get_bits(c, 4, 15);

get_bits( <variable> , <bit_index>, <bit_mask> );

<variable> : any defined variable. <bit_index> : index point of the bit to be set with a range of 0 to 15. <bit_mask> : bit mask corresponding to the size, in bits, of the value to store (without shifting)

Returns an int value

Syntax

Parameters

Returns

Syntax

Parameters

Returns

Syntax

Parameters

Returns

Syntax

Parameters

Returns

🔴
⚪
🔵
🔴
⚪
🔵
🔴
⚪
🔵
🔴
⚪
🔵
🔴
⚪
🔵
set_bit
clear_bit
test_bit
set_bits
get_bits