Efficient printf method?
18 posts
• Page 2 of 2 • 1, 2
Re: Efficient printf method?
Mine too! I just see the code don't understand it but learn something every day!
- bonefisher
- Lieutenant General
- Posts: 5413
- Joined: Thu Jan 29, 2015 10:49 am
Re: Efficient printf method?
bonefisher wrote:Mine too! I just see the code don't understand it but learn something every day!
The training wheels are bolted back onto my GPC bike! I know what I want to do, but it's a little frustrating not knowing how to do it :sad panda:
The second part of this quest involves outputting those printf statements to a Raspberry Pi or Arduino screen. That's a much steeper learning curve before I get there...
-
antithesis - Colonel
- Posts: 1912
- Joined: Sat May 28, 2016 10:45 pm
Re: Efficient printf method?
[quote="J2Kbr"]
The correct initialization of an array of strings is:
oh yeah char pointer, duh!,
instead of an array of string , is it possible to do an array of combos? and then do
combo_run(comboArray[comboIndex]);
The correct initialization of an array of strings is:
- Code: Select all
main {
char *SkillModes[] = {
"Skill: None", "Skill: BallRoll", "Skill: BodyFeintCut", "Skill: ReversoStepOverCut", "Skill: HeelFlick2",
"Skill: HeelFlick", "Skill: FakeAndGo", "Skill: Roulette", "Skill: Rainbow", "Skill: StopAndTurn",
"Skill: Spin", "Skill: RonaldoChop", "Skill: BallRollFlick", "Skill: ElasticoChop", "Skill: BolasieFlick",
"Skill: KnockOn", "Skill: StepOverCut", "Skill: FlickUP", "Skill: FakeShotStop", "Skill: FakeShotBallHop",
"Skill: AdvRainbow", "Skill: ScoopTurn", "Skill: HocusPocusElastico"
};
oh yeah char pointer, duh!,
instead of an array of string , is it possible to do an array of combos? and then do
combo_run(comboArray[comboIndex]);
-
FCB77 - Command Sergeant Major
- Posts: 138
- Joined: Sun Feb 01, 2015 9:21 am
Re: Efficient printf method?
is possible make an array of combos, but not possible use combo_run with it. If you look at the combo_run opcode, it has the combo address as argument, which should be determined at compile time.
However, it is possible re-implement combo_run, combo_stop, etc with GPC script and use the combo array like you proposed.
However, it is possible re-implement combo_run, combo_stop, etc with GPC script and use the combo array like you proposed.
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: Efficient printf method?
i tried it.
i thought crun command changed the combo value to 1 like in titan1.
maybe you can add __asm clause to run T2 assembly commands from gpc script
ArrayCmb[0] retuns the correct combo address.
i thought crun command changed the combo value to 1 like in titan1.
maybe you can add __asm clause to run T2 assembly commands from gpc script
ArrayCmb[0] retuns the correct combo address.
- Code: Select all
int ArrayCmb[] = {&Uno, &dos, &tres};
main{
if (event_active(BUTTON_15))
{
printf("%04X", ArrayCmb[0]);
printf("%04X", *ArrayCmb[0]);
*ArrayCmb[0] = 1;
}
}
combo Uno
{
set_val(BUTTON_14, 100);
wait(3000);
}
combo dos
{
set_val(BUTTON_14, 100);
wait(3000);
}
combo tres
{
set_val(BUTTON_14, 100);
wait(3000);
}
-
FCB77 - Command Sergeant Major
- Posts: 138
- Joined: Sun Feb 01, 2015 9:21 am
Re: Efficient printf method?
Cool. Below an example showing how the combo_* commands can be re-implemented and used with an arrays of combos.
- Code: Select all
uint8 *ComboArray[] = {
&ComboA,
&ComboB,
&ComboC,
&ComboD,
&ComboE,
};
init {
comboRun(ComboArray[1]);
}
combo ComboA {}
combo ComboB { set_val(BUTTON_16, 100.0); wait(2000); }
combo ComboC {}
combo ComboD {}
combo ComboE {}
void comboRun(uint8 *c) {
c[0] = 1;
}
void comboPause(uint8 *c) {
c[0] = 0;
}
void comboStop(uint8 *c) {
c[0] = 0;
c[1] = 0;
c[2] = 0;
c[3] = 0;
}
void comboReset(uint8 *c) {
comboStop(c);
comboRun(c);
}
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: Efficient printf method?
cool, will test it when i get back home.
-
FCB77 - Command Sergeant Major
- Posts: 138
- Joined: Sun Feb 01, 2015 9:21 am
Re: Efficient printf method?
alright i already tested my code and your code.
now i see why my code was not working
both arrays had the correct combo pointers despite both being declared differently
i declared the array as
after reading your code i understood why my code didnt work.
i was writting 1 as an int
instead of a byte
your solution is more elegant though
now i see why my code was not working
both arrays had the correct combo pointers despite both being declared differently
i declared the array as
and you asint []
uint8 * []
after reading your code i understood why my code didnt work.
i was writting 1 as an int
*ArrayCmb[0] = 1; // 1 written as an int
instead of a byte
*((int8*)ArrayCmb[0]) = 1; //1 written as a byte;
your solution is more elegant though
-
FCB77 - Command Sergeant Major
- Posts: 138
- Joined: Sun Feb 01, 2015 9:21 am
18 posts
• Page 2 of 2 • 1, 2
Return to GPC2 Script Programming
Who is online
Users browsing this forum: Majestic-12 [Bot] and 75 guests