IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 C Discussion :

Est ce que ce code est du langage C ?


Sujet :

C

  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    769
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Octobre 2007
    Messages : 769
    Points : 726
    Points
    726
    Par défaut Est ce que ce code est du langage C ?
    Bonjour,

    Quelqu'un peut-il me dire si le code suivant est en langage C ou non ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    #include "../hdr/ramp.h"
    #include <stdlib.h>
    #include <hw/inout.h>
    #include "ldev.h"
    #include "lcode.h"
     
     
    unsigned int output;
    int retour;
    int i = 0;
    int tot_remain;
    int tot_flag;
    int win_flag=0;
    int acq_flag =0;
    int go_flag = 0;
    int stp_flag = 0;
    int stp1_flag =0;
    int ok_flag;
    int trig_flag=0;
    int tps_flag=0;
    int rep=5000;
    int fixx;
    int fixy;
    int fxwd=999;
    int fywd=999;
    int foxwd;
    int foywd;
    int win_left_x=-100;
    int win_left_y;
    int win_right_x=100;
    int win_right_y;
    int l;
    int pin;
    int valeur, deuxmille;
    int good=0;
    int bad=0;
    int miss=0;
    int sequence=6;
    int doublerew=0;
     
    /* point de fixation visuelle*/
     
    quelpoint()
    {
    if (sequence ==1)
     {
     int list[] = {2,6,7,1,4,5,0,8,3};
     i=tot_remain%9;
     output = list[i];
     valeur = output;
     }
    if (sequence == 2)
     {
     int list[] = {1,7,8,2,4,0,5,6,3};
    i=tot_remain%9;
    output = list[i];
    valeur = output;
     }
    if (sequence == 3)
     {
     int list[] = {3,8,0,2,4,5,1,6,7};
    i=tot_remain%9;
    output = list[i];
    valeur = output;
     }
    if (sequence == 4)
     {
     int list[] = {8,5,4,3,0,1,7,6,2};
    i=tot_remain%9;
    output = list[i];
    valeur = output;
     }
    if (sequence == 5)
     {
     int list[] = {5,0,7,1,4,2,3,6,8};
    i=tot_remain%9;
    output = list[i];
    valeur = output;
     }
    if (sequence == 6)
     {
     int list[] = {0,0,0,0,0,0,0,0,0};
    i=tot_remain%9;
    output = list[i];
    valeur = output;
     }
     if (sequence == 7)
     {
     int list[] = {5,0,7,5,7,0,7,0,5};
    i=tot_remain%9;
    output = list[i];
    valeur = output;
     }
     
     retour = output + 5000;
    return(0);
    }
     
    fixation(void)
    {
    /* 	envoie sur le port parallele la valeur OUTPUT	*/
    /* 	puis fait basculer le bit BUSY					*/
    /* 	retourne la valeur envoyee					*/
     
    /* calcul valeur */
    		output &= 0xf	;
     
    /* sortie valeur */ 
    		out8(0x378,output);
     
    /* commutation Busy */
    		output |=0x10;
    		out8(0x378,output);
    		return(0);
    }
     
    goodcount()
    {
    	good ++;
    	return(0);
    }
     
    badcount()
    {
    	bad ++;
    	return(0);
    }
     
     
     
    tsttrig()
    {
    		unsigned int value=0xffff,  input=0;
    		input=in8(0x379)&0x0f8;
    		value = (input >>3) & 7;
    		if ((input & 0x80)==0) value |=8;		
    		if (value==0x2) acq_flag =1;
    		return(0);
    }
     
    tsttrg()
    {
    		unsigned int value=0xffff, input=0;
    		input=in8(0x379)&0x0f8;
    		value = (input >>3) & 7;
    		if ((input & 0x80)==0) value |=8;
    		if (value==0) trig_flag=1;
    		return(0);
     
    }
     
    tsttps()
    {
    		unsigned int value=0xffff, input=0;
    		input=in8(0x379)&0x0f8;
    		value = (input >>3) & 7;
    		if ((input & 0x80)==0) value |=8;
    		if (value==0x4) tps_flag=1;
    pin = 5500 + tps_flag;
    		return(0);
    }
     
    clrtbl()
    {
    		tot_flag=0;
    		tot_remain = rep*9;
    		return(0);
    }
     
    /* fonctions controlant la fenetre autour du point de fixation*/
     
    winon()
    {
     
     if (valeur==0 || valeur==1 || valeur==2)
        {    fixx=0;
             fixy=0;}
     
     if (valeur==3 || valeur==4 || valeur==5)
        {
             fixx=win_right_x;
             fixy=win_right_y;}
     
     if  (valeur==6 || valeur==7 || valeur==8)
         {
             fixx=win_left_x;
             fixy=win_left_y;}
     
    		wd_pos(WIND0, fixx, fixy);
    		wd_cntrl(WIND0, WD_ON);
    		wd_siz(WIND0, fxwd, fywd);
    		wd_pos(WIND1, fixx, fixy);
    		wd_cntrl(WIND1, WD_ON);
    		wd_siz(WIND1, foxwd, foywd);
    		win_flag = 1;
    tps_flag=0;
    		return(0);
    }
     
    depart()
    {
    		go_flag = 1;
    		deuxmille = retour - 3000;
    		return(deuxmille);
    }
     
    second()
    {
    		ok_flag = 0;
    		return(0);
    }
     
    blank()
    {
    		wd_cntrl(WIND0, WD_OFF);
    		wd_cntrl(WIND1, WD_OFF);
    wd_siz(WIND0, 0, 0);
    wd_siz(WIND1, 0, 0);
    		output = 9;
    		output &= 0xf;
     
    		out8(0x378, output);
    		output |=0x10;
    		out8(0x378, output);
    		return(0);
    }
     
    dispcd()
    {
    		win_flag = 0;
    		return(retour);
    }
     
    stop1()
    {
    		stp1_flag = 1;
    		win_flag =0;
    		miss ++;
    		return(0);
    }
     
    stop()
    {
    		stp_flag = 1;
    		wd_cntrl(WIND0, WD_OFF);
    		wd_cntrl(WIND1, WD_OFF);
    wd_siz(WIND0, 0, 0);
    wd_siz(WIND1, 0, 0);
    		return(0);
    }
     
    pause3()
    {
    		go_flag = 0;
    		acq_flag = 0;
    		return(0);
    }
     
    alloff()
    {
    		wd_cntrl(WIND0, WD_OFF);
    		wd_cntrl(WIND1, WD_OFF); 
    wd_siz(WIND0, 0, 0);
    wd_siz(WIND1, 0, 0);
    		output = 9;
    		output &= 0xf	;
    		out8(0x378,output);
    		output |=0x10;
    		out8(0x378,output);
    		return(0);
    }
     
    remise()
    {
    		win_flag=0;
    		go_flag=0;
    		acq_flag=0;
    		trig_flag=0;
    		wd_cntrl(WIND0, WD_OFF);
    		wd_cntrl(WIND1, WD_OFF);
    		return(0);
    }
     
    VLIST state_vl[] = {
    "sequence(1-5 | 6 | 7)", &sequence, NP, NP, 0, ME_DEC,
    "double-recompense", &doublerew, NP,NP, 0, ME_DEC,
    "other-win_x", &foxwd,	NP,NP,	0,ME_DEC,
    "other-win_y", &foywd,	NP,NP,	0,ME_DEC,
    "repetitions", &rep, NP, clrtbl, ME_AFT, ME_DEC,
    "remaining",	&tot_remain,	NP,NP,	0, ME_DEC,
    "win_left_x",&win_left_x,NP,NP, 0,ME_DEC,
    "win_left_y",&win_left_y,NP,NP, 0,ME_DEC,
    "win_right_x",&win_right_x,NP,NP, 0,ME_DEC,
    "win_right_y",&win_right_y,NP,NP, 0,ME_DEC,
    NS,
    };
     
    total()
    {
    		ok_flag=1;
    		tot_remain --;
    		if (tot_remain ==0)	tot_flag = 1;
    		return(0);
    }	
     
    ok()
    {
    		ok_flag = 1;
    		stp1_flag = 0;
    		stp_flag = 0;
    		trig_flag = 0;
    		return(0);
    }
     
    /* initialize at first pass or at r s from keyboard */
     
    void rinitf(void)
     
    {
    		ok_flag = 1;
    		stp_flag=0;
    		stp1_flag =0;
    		acq_flag = 0;
    		trig_flag =0;
    		tps_flag=0;
    		tot_remain = rep*9;
    		i= tot_remain % 9;
    		wd_disp(D_W_EYE_X|D_W_EYE_O);
    		wd_src_pos(WIND0, WD_DIRPOS, 0, WD_DIRPOS, 0);
    		wd_src_check(WIND0, WD_SIGNAL, EYEH_SIG, WD_SIGNAL, EYEV_SIG);
    		wd_siz(WIND0, 0, 0);
    		wd_src_pos(WIND1, WD_DIRPOS, 0, WD_DIRPOS, 0);
    		wd_src_check(WIND1, WD_SIGNAL, OEYEH_SIG, WD_SIGNAL, OEYEV_SIG);
    		wd_siz(WIND1, 0, 0);
    		ustatus("paradigme cou");
    }
     
    RTVAR rtvars[] = {
    {"bad trials",	&bad},
    {"good trials",	&good},
    {"miss", &miss},
    {"remaining", &tot_remain},
    {"",0},
    };
     
    /************************************************************************/
     
    char hm_sv_vl[]="";
     
    %%
     
    id 511
    restart rinitf
     
    main_set {
    status ON
    begin	first:
    		time 10
    		to third
     
    	third:
    		time 10
    		to second on +MET & ok_flag 
    		to first
     
    	second:
    		code STARTCD
    		do second()
    		time 1100
    		to pause 
     
    	pause:
    		code PAUSECD
    		to go on -PSTOP & softswitch
     
    	go:
    		code ENABLECD
    		rl 10
    		time 100
    		to donelist on +MET & tot_flag
    		to vrg
     
    	donelist:
    		code LISTDONECD
    		time 500
    		to first on -MET & tot_flag 
     
    	vrg:
    		code VRG
    		time 10
    		do quelpoint()
    		to fwinon
     
    	temps:
    		time 10
    		do tsttps()
    		to alors
     
    	alors:
    		code ALORS
    		to temps on ZERO = tps_flag
    		to fwinon on MET = tps_flag
     
    	fwinon:
    		code FWINON
    		do winon()
    		time 20
    		to fpon
     
    	fpon:
    		code FPONCD
    		do fixation()
    		time 1300
    		to period1 on -EYEALL & eyeflag
    		to stop
     
    	stop:
    		do stop1()
    		to fofo
     
    	fofo:
    		do alloff()
    		to remise
     
    	period1:
    		code PERIOD
    		time 2200
    		do depart()
    		to bad on +EYEALL & eyeflag
    		to troptot
     
    	troptot:
    		time 170
    		to remise
     
    	bad:
    		code RATE
    		time 10
    		do stop()
    		to remise
     
    	remise:
    		code REMISECD
    		do remise()
    		to first
     
    }
     
    timing_set {
    status ON
    begin attente:
    		time 10
    		to boo on +MET & stp1_flag
    		to attente1 on +MET & win_flag
    		to attente
     
    	attente1:
    		time 10
    		to test on +MET & go_flag
    		to attente
     
    	test:
    		time 10 
    		do tsttrig()
    		to wrong1 on +MET & stp_flag 
    		to attente on -MET & win_flag 
    		to branch
     
    	branch:
    		time 10
    		to opnw on +MET & acq_flag
    		to wrong1 on +MET & stp_flag
    		to test 
     
    	opnw:
    		do pre_post(300,100)
    		to opnwd
     
    	opnwd:
    		code WOPENCD
    		do awind(OPEN_W)
    		to wrong2 on +MET & stp_flag
    		to dispcode
     
    	dispcode:
    		do dispcd()
    		to wrong2 on +MET & stp_flag
    		to gords
     
    	gords:
    		code GORDSCD
    		to period
     
    	period:
    		code PERIOCD
    		time 500
    		to wrong2 on +MET & stp_flag
    		to closew
     
    	closew:
    		code WCLOSECD
    		do awind(CLOSE_W)
    		to alloff
     
    	alloff:
    		code ALLOFFCD
    		do alloff()
    		to rewon
     
    	rewon:
    		code REWCD
    		rl 40
    		do dio_on(REW)
    		to rewoff
     
    	rewonattente:
    		time 200
    		to rewon2
     
    	rewon2:
    		do dio_on(REW)
    		to rewoff2
     
    	rewoff:
    		rl 10
    		do dio_off(REW)
    		to rewonattente on +MET & doublerew
    		to score
     
    	rewoff2:
    		do dio_off(REW)
    		to score
     
    	score:
    		code CORRECTCD
    		do goodcount()
    		to total
     
    	total:
    		code TOTALCD
    		do total()
    		to pause3
     
    	pause3:
    		do pause3()
    		to attente
     
    	wrong1:
    		code WRONGCD
    		do blank()
    		to score1
     
    	score1:
    		do badcount()
    		to reset
     
    	wrong2:
    		code WRONGCD
    		do score(NO)
    		to tsttrg
     
    	tsttrg:
    		do tsttrg()
    		to canwin on +MET & trig_flag
    		to tsttrg
     
    	canwin:
    		do awind(CANCEL_W)
    		to reset
     
    	reset:
    		do reset_s(-1)
    		time 10
    		to poo
     
    	poo:
    		do alloff()
    		to beep
     
    	beep:
    		do dio_on(BEEP)
    		time 1000
    		to bpoff
     
    	bpoff:
    		do dio_off(BEEP)
    		to boo
     
    	boo:
    		code BOOCD
    		do ok()
    		to attente
     
    abort list:
    	alloff rewoff bpoff
     
    }
    Je dois le comprendre de A à Z alors si quelqu'un peut me guider d'un point de vue générale, je suis preneur. J'ai remarquer qu'il y a deux blocs ("main_set" et le "timing_set"), est-ce deux fonctions séparées ? Est-ce qu'il y a des liens entre eux ?

    Merci pour votre aide

    Christophe

  2. #2
    Membre averti
    Homme Profil pro
    Développeur de jeux vidéo
    Inscrit en
    Octobre 2008
    Messages
    187
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur de jeux vidéo

    Informations forums :
    Inscription : Octobre 2008
    Messages : 187
    Points : 448
    Points
    448
    Par défaut
    la syntaxe ressemble à celle du C, mais ce n'en n'est pas... Peut-être de l'objective C ?

    Sinon, tu n'a pas plus de renseignement sur ce bout de code ? D'où vient-il ?

  3. #3
    Inactif  
    Avatar de Mac LAK
    Profil pro
    Inscrit en
    Octobre 2004
    Messages
    3 893
    Détails du profil
    Informations personnelles :
    Âge : 50
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations forums :
    Inscription : Octobre 2004
    Messages : 3 893
    Points : 4 846
    Points
    4 846
    Par défaut
    Si c'est du C, alors les entêtes utilisés doivent être gavés de macros particulièrement crades... Parce que dans l'état actuel du code, ça m'étonnerait bien que ça puisse compiler, ou alors c'est un compilateur C fait maison et gavé d'extensions non standards.

  4. #4
    Membre éclairé
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    769
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Octobre 2007
    Messages : 769
    Points : 726
    Points
    726
    Par défaut
    Merci pour vos réponses qui m'annoncent quelques heures de travaillent... lol

    Comme info suppélementaire, ce code fonctionne sous le logiciel REX (Real-time EXperimentation) qui lui même tourne sous une système d'exploitation QNX...

  5. #5
    Membre averti
    Avatar de Chatanga
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    211
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 211
    Points : 346
    Points
    346
    Par défaut
    C'est du (vieux) C plus quelque chose d'exotique qui n'est pas du C++ ni de l'Objective-C. En fait, jusqu'au "%%", ce n'est sans doute que du C. Après, ça ressemble à une sorte d'inclusion de code dans un langage de plus bas niveau. Quoiqu'il en soit, c'est un bon exemple pour illustrer l'utilité des commentaires dans un code susceptible d'être repris 20 ans après...

  6. #6
    Expert éminent sénior

    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    10 610
    Détails du profil
    Informations personnelles :
    Âge : 66
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 10 610
    Points : 17 923
    Points
    17 923
    Billets dans le blog
    2
    Par défaut
    Citation Envoyé par Chatanga Voir le message
    Quoiqu'il en soit, c'est un bon exemple pour illustrer l'utilité des commentaires dans un code susceptible d'être repris 20 ans après...


    et de coder en clair et non pas ni en "obfusqué" ni en hexa..

    Ce code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    		unsigned int value=0xffff, input=0;
    		input=in8(0x379)&0x0f8;
    		value = (input >>3) & 7;
    		if ((input & 0x80)==0) value |=8;
    		if (value==0x4) tps_flag=1;
    serait certainement plus clair écrit "normalement"...

  7. #7
    Inactif  
    Avatar de Mac LAK
    Profil pro
    Inscrit en
    Octobre 2004
    Messages
    3 893
    Détails du profil
    Informations personnelles :
    Âge : 50
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations forums :
    Inscription : Octobre 2004
    Messages : 3 893
    Points : 4 846
    Points
    4 846
    Par défaut
    Citation Envoyé par souviron34 Voir le message
    Ce code <snip> serait certainement plus clair écrit "normalement"...
    Il est (relativement) clair, mais encore faut-il avoir une bonne connaissance du matos et voir que c'est un test de l'état du port parallèle, et avoir la Bible du PC sous le coude pour savoir quels bits du registre d'état sont testés... J'ai beau connaître l'adresse du registre par cœur, je n'en connais quand même pas le mapping bit à bit sans la Bible !

    En dehors de ça, pour l'époque, ce genre de code était plus que courant dans les tests de registres hard, peut-être pour ça qu'il ne me choque pas trop. Cela reste néanmoins du code crade globalement, et surtout non commenté...

Discussions similaires

  1. Est ce que ce code est juste ?
    Par thehurrica dans le forum MS SQL Server
    Réponses: 0
    Dernier message: 11/04/2010, 13h17
  2. Est ce que ce code est optimisé.
    Par Andry dans le forum Langage
    Réponses: 4
    Dernier message: 13/03/2009, 22h06
  3. Est ce que ce code est correct ?
    Par foot.c dans le forum Débuter
    Réponses: 6
    Dernier message: 12/05/2008, 01h49
  4. Réponses: 1
    Dernier message: 08/02/2007, 09h11
  5. [Dates] calcul de date est ce que mon code est bon?
    Par carmen256 dans le forum Langage
    Réponses: 2
    Dernier message: 09/06/2006, 11h30

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo