Ximoon (./127) :
Un truc que j'aime bien sur l'éditeur que j'utilise en ce moment (visual slick edit) c'est qu'on peut se déplacer partout d'un caractère, même après la fin des lignes, ça fait comme s'il y avait des espaces... Ça évite d'avoir à rajouter n espaces pour placer un commentaire à tel endroit, ou justement de faire sauter le curseur quand on passe d'une fin de ligne plus longue à une plus courte.
int ia_nme(int tour, int curscard) { int poubelle=-1,i=-1,cj=15,cx=-1,dmax; if (curscard<106) mains[tour][6]=tas[curscard]; if (nbj==4) dmax=1000; else dmax=700; //cherche bottes si adversaire > 800 //oslWarning("bottes %d",cj); if ((scores[0]>=(dmax-200)) || (curscard>92)) { for(i=0; i<7; i++) { if (mains[tour][i]>15) { cj=mains[tour][i]; cx=i; i=8; } } } //cherche feu vert //oslWarning("feuvert %d",cj); for(i=0; i<7; i++) { if ((mains[tour][i]==5) && (cj==15)) { if (etat[1]%10 == 0) { cj=mains[tour][i]; cx=i; i=8; } } } //cherche attaques //oslWarning("attaque %d",cj); for(i=0; i<7; i++) { if ((etat[0]%10 == 1) && (cj == 15)) { if ((mains[tour][i]>9) && (mains[tour][i] != 11) && (mains[tour][i]<15)) { cj=mains[tour][i]; cx=i; i=8; } } } //cherche limites //oslWarning("limites %d",cj); for(i=0; i<7; i++) { if ((mains[tour][i]==11) && (cj==15)) { if (etat[0] < 10) { cj=mains[tour][i]; cx=i; i=8; } } } //cherche parades //oslWarning("contre %d",cj); for(i=0; i<7; i++) { if ((etat[1]%10 != 1) && (cj==15)) { if ((etat[1]>9) && (mains[tour][i]==6)) { cj=mains[tour][i]; cx=i; i=8; } if ((etat[1]%10==0) && (mains[tour][i]==5)) { cj=mains[tour][i]; cx=i; i=8; } if ((etat[1]%10==2) && (mains[tour][i]==7)) { cj=mains[tour][i]; cx=i; i=8; } if ((etat[1]%10==3) && (mains[tour][i]==8)) { cj=mains[tour][i]; cx=i; i=8; } if ((etat[1]%10==4) && (mains[tour][i]==9)) { cj=mains[tour][i]; cx=i; i=8; } } } [...] }
case MAY_POW_T: ; may_t base = may_expand_recur (MAY_AT(x, 0));
may_t may_recursive (may_t expr, may_t (*func) (may_t), unsigned long level) { [...] for (i = 0; i < n; i++) { may_t var = may_op (listvar, i); auto may_t localfunc (may_t x); auto may_t localfunc (may_t x) { return may_recursive (x, func, level-1); } may_t newvar = may_map (var, localfunc); expr = may_replace (expr, var, newvar); } } [...] }
typedef int T[3][3]; int g(const T x); int f(T x) { // Manip sur x // Fucking cast because 'return g(x)' doesn't work return g(*(const T*)&x); }
// V-RALLY par Vark-Dador
// C Source File
// Created 15/04/01; 08:13:28 with TIGCC 0.91 SP1
#define USE_TI92PLUS // Compile for TI-92 Plus
#define USE_V200 // Compile for V200
#define OPTIMIZE_ROM_CALLS // Use ROM Call Optimization
#define MIN_AMS 200 // Compile for AMS 2.00 or higher
#define SAVE_SCREEN // Save/Restore LCD Contents
#include <tigcclib.h> // Include All Header Files
#include "extgraph.h" // Include ExtGraph lib
//**********************Sprites courses*************************
#include "rsprites.h"
//***************definition du type voiture************************
typedef struct
{
long l[32],d[32],m[32],g1l[32],g1d[32],g1m[32],g2l[32],g2d[32],g2m[32],d1l[32],d1d[32],d1m[32],d2l[32],d2d[32],d2m[32];
}CAR;
//****************Initialisation des variables globales******************
short i,pen,diff;
FILE *fp;
unsigned long *br1l,*br1d,*br1m,*br2l,*br2d,*br2m,*br3l,*br3d,*br3m,*ro1l,*ro1d,*ro1m,*ro2l,*ro2d,*ro2m,*ro3l,*ro3d,*ro3m,*bu1l,*bu1d,*bu1m,*bu2l,*bu2d,*bu2m,*bu3l,*bu3d,*bu3m,*tr1l,*tr1d,*tr1m,*tr2l,*tr2d,*tr2m,*tr3al,*tr3ad,*tr3am,*tr3bl,*tr3bd,*tr3bm;
unsigned char *dbuf,*dec,*dec2;
unsigned char squ[]={0xC0,0xC0};
INT_HANDLER save_int_1;
INT_HANDLER save_int_5;
INT_HANDLER autoint_bkp;
char buffer[50];
void *virtuel;
void *virtuel2;
void *virt;
void *virt2;
void *virtf;
void *virt2f;
void *ALL;
typedef struct
{
short place,dist,pts,val;
}CONCURRENTS;
CONCURRENTS adv[5];
//*****************************Fonctions secondaires******************
#include "functions.h"
//******************************Main Function***********************
void _main(void)
{
///////////////Sprites Divers////////////////////////
#include "osprites.h"
///////////////Variables locales/////////////////////
short i,pl,tot,cp,gm,depl,rang,vibr2,vibr,er2,cf,col,obf,xpf,c,xc,carst,r,ch,h,cycle,xd,dd,vst,ob,xp,ty,ot,rst,wsu,cxd,spd,av,cv,mil,sec,min,rc,er;
short vir=0,obb=0,xpb=0,sr=0,rp=0,tp=0,plpl=0,ttt=1,tt=0;
char course[50];
char buff[50];
char srbuf[50];
char rpbuf[50];
char tpbuf[50];
char cpbuf[50];
CAR car;
if(!(ALL=malloc(6*3840+124+2*1920)))exit(0); //une seule allocation c'est plus rapide
virtuel=ALL;
virtuel2=virtuel+3840;
virt=virtuel2+3840;
virt2=virt+3840;
virtf=virt2+3840;
virt2f=virtf+3840;
dbuf=virt2f+3840;
dec=dbuf+124;
dec2=dec+1920;
autoint_bkp=GetIntVec(AUTO_INT_6);
SetIntVec(AUTO_INT_6,DUMMY_HANDLER);
save_int_1=GetIntVec(AUTO_INT_1);
SetIntVec(AUTO_INT_1,DUMMY_HANDLER);
save_int_5=GetIntVec(AUTO_INT_5);
SetIntVec(AUTO_INT_5,DUMMY_HANDLER);
ST_busy(ST_IDLE);
/////////////////////Intro///////////////////////
ClrScr();
GrayOn();
SetPlane(DARK_PLANE);
title();
wait(15);
///////////////////Menus///////////////////////
//--------------->Menu principal<--------------
menu:
ClearGrayScreen();
FontSetSys(F_4x6);
DrawStr(15,122,"By Jonathan PAILLAT (vark.dador@j2t.fr.st) - Version 1.00F",A_NORMAL);
FontSetSys(F_8x10);
DrawStr(90,6,"MAIN MENU",A_NORMAL);
for (i=45;i<90;i+=20)
{
DrawLine(50,i,190,i,A_NORMAL);
DrawLine(50,i+10,190,i+10,A_NORMAL);
DrawLine(50,i,50,i+10,A_NORMAL);
DrawLine(190,i,190,i+10,A_NORMAL);
}
FontSetSys(F_6x8);
DrawStr(90,47,"Start Game",A_NORMAL);
DrawStr(85,67,"Instructions",A_NORMAL);
DrawStr(92,87,"Quit Game",A_NORMAL);
eff(46);
c=1;
while((_rowread(0x3BF)&0x40)||(_rowread(0x2FF)&0x40)){}
while(1)
{
if(_rowread(0x3FE)&0x80)
{
switch(c)
{
case 1:
eff(66);
c=2;
break;
case 2:
eff(86);
c=3;
break;
}
while(_rowread(0x3FE)&0x80){}
}
if(_rowread(0x3FE)&0x20)
{
switch(c)
{
case 2:
eff(46);
c=1;
break;
case 3:
eff(66);
c=2;
break;
}
while(_rowread(0x3FE)&0x20){}
}
if(_rowread(0x3BF)&0x40)
{
switch(c)
{
case 1:
goto ms;
break;
case 2:
ClearGrayScreen();
title();
FontSetSys(F_8x10);
DrawStr(75,5,"Instructions",A_NORMAL);
FontSetSys(F_6x8);
DrawStr(20,30,"How to play ? ... just drive !",A_NORMAL);
DrawStr(10,47,"Left Pad : Turn Left",A_NORMAL);
DrawStr(10,55,"Right Pad : Turn ... Right !!!",A_NORMAL);
DrawStr(10,63,"[APPS] : Pause",A_NORMAL);
DrawStr(10,71,"[ESC] : Exit Game :(",A_NORMAL);
DrawStr(10,79,"[+]/[-] : Adjust Contrast",A_NORMAL);
DrawStr(10,87,"[LOCK] : Speed Up",A_NORMAL);
DrawStr(10,95,"[F1] : Brake",A_NORMAL);
DrawStr(10,103,"[MODE] : Teacher Key :D",A_NORMAL);
FontSetSys(F_4x6);
DrawStr(55,122,"Member of j2t: http://www.j2t.fr.st/",A_NORMAL);
while(_rowread(0x3BF)&0x40){}
while(1)
{
if(_rowread(0x3BF)&0x40)
goto menu;
}
break;
case 3:
while(_rowread(0x3BF)&0x40){}
goto fin;
break;
}
}
if(_rowread(0x2FF)&0x40)
goto fin;
}
//--------------->Sélection mode<--------------
ms:
ClearGrayScreen();
title();
FontSetSys(F_8x10);
DrawStr(75,6,"SELECT MODE",A_NORMAL);
FontSetSys(F_6x8);
DrawStr(10,110,"CHALLENGE",A_NORMAL);//10->64
DrawStr(80,80,"SINGLE RACE",A_NORMAL);//80->146
DrawStr(155,110,"CHAMPIONSHIP",A_NORMAL);//155->227
Sprite8_XOR(72,79,8,dte,GetPlane(1));//> 2 <
Sprite8_XOR(148,79,8,gche,GetPlane(1));
Sprite32_XOR(25,66,32,tric,GetPlane(1));
Sprite32_XOR(100,36,32,vol,GetPlane(1));
Sprite32_XOR(175,66,32,laur,GetPlane(1));
Sprite32_OR(25,66,32,tric,GetPlane(0));
Sprite32_OR(100,36,32,vol,GetPlane(0));
Sprite32_OR(175,66,32,laur,GetPlane(0));
c=2;
while((_rowread(0x3BF)&0x40)||(_rowread(0x2FF)&0x40)){}
while(1)
{
if((_rowread(0x3FE)&0x40)&&c==1)
{
c=2;
Sprite8_XOR(72,79,8,dte,GetPlane(1));//>
Sprite8_XOR(2,109,8,dte,GetPlane(1));
Sprite8_XOR(148,79,8,gche,GetPlane(1));//<
Sprite8_XOR(67,109,8,gche,GetPlane(1));
while(_rowread(0x3FE)&0x40){}
}
else if((_rowread(0x3FE)&0x40)&&c==2)
{
c=3;
Sprite8_XOR(148,109,8,dte,GetPlane(1));//>
Sprite8_XOR(72,79,8,dte,GetPlane(1));
Sprite8_XOR(229,109,8,gche,GetPlane(1));//<
Sprite8_XOR(148,79,8,gche,GetPlane(1));
while(_rowread(0x3FE)&0x40){}
}
else if((_rowread(0x3FE)&0x10)&&c==3)
{
c=2;
Sprite8_XOR(72,79,8,dte,GetPlane(1));//>
Sprite8_XOR(148,109,8,dte,GetPlane(1));
Sprite8_XOR(148,79,8,gche,GetPlane(1));//<
Sprite8_XOR(229,109,8,gche,GetPlane(1));
while(_rowread(0x3FE)&0x10){}
}
else if((_rowread(0x3FE)&0x10)&&c==2)
{
c=1;
Sprite8_XOR(2,109,8,dte,GetPlane(1));//>
Sprite8_XOR(72,79,8,dte,GetPlane(1));
Sprite8_XOR(67,109,8,gche,GetPlane(1));//<
Sprite8_XOR(148,79,8,gche,GetPlane(1));
while(_rowread(0x3FE)&0x10){}
}
else if(_rowread(0x3BF)&0x40)
{
gm=c;
tot=6;
goto ds;
for(i=0;i<5;i++)
{
adv[i].pts=0;
}
rp=0;
tp=0;
}
else if(_rowread(0x2FF)&0x40)
goto menu;
}
//--------------->Sélection difficultée<--------------
ds:
ClearGrayScreen();
title();
FontSetSys(F_8x10);
DrawStr(50,6,"SELECT DIFFICULTY",A_NORMAL);
FontSetSys(F_6x8);
DrawStr(50,90,"ARCADE",A_NORMAL);//35->71
DrawStr(132,90,"SIMULATION",A_NORMAL);//132->192
Sprite8_XOR(42,89,8,dte,GetPlane(DARK_PLANE));//> arcade <
Sprite8_XOR(87,89,8,gche,GetPlane(DARK_PLANE));
Sprite32_XOR(52,46,32,comp,GetPlane(DARK_PLANE));
Sprite32_XOR(146,46,32,cask,GetPlane(DARK_PLANE));
Sprite32_OR(52,46,32,comp,GetPlane(LIGHT_PLANE));
Sprite32_OR(146,46,32,cask,GetPlane(LIGHT_PLANE));
c=1;
while((_rowread(0x3BF)&0x40)||(_rowread(0x2FF)&0x40)){}
while(1)
{
if((_rowread(0x3FE)&0x40)&&c==1)
{
Sprite8_XOR(42,89,8,dte,GetPlane(DARK_PLANE));//> arcade <
Sprite8_XOR(87,89,8,gche,GetPlane(DARK_PLANE));
Sprite8_XOR(124,89,8,dte,GetPlane(DARK_PLANE));//> simulation <
Sprite8_XOR(196,89,8,gche,GetPlane(DARK_PLANE));
c=2;
while(_rowread(0x3FE)&0x40){}
}
else if((_rowread(0x3FE)&0x10)&&c==2)
{
Sprite8_XOR(124,89,8,dte,GetPlane(DARK_PLANE));//> simulation <
Sprite8_XOR(196,89,8,gche,GetPlane(DARK_PLANE));
Sprite8_XOR(42,89,8,dte,GetPlane(DARK_PLANE));//> arcade <
Sprite8_XOR(87,89,8,gche,GetPlane(DARK_PLANE));
c=1;
while(_rowread(0x3FE)&0x10){}
}
else if(_rowread(0x3BF)&0x40)
{
if(c==1) diff=0;
else diff=1;
goto cs;
}
else if(_rowread(0x2FF)&0x40)
goto ms;
}
//--------------->Sélection voiture<--------------
cs:
ClearGrayScreen();
FontSetSys(F_8x10);
DrawStr(80,6,"SELECT CAR",A_NORMAL);
FontSetSys(F_6x8);
DrawStr(20,90,"PEUGEOT 306",A_NORMAL);//20->86
DrawStr(70,110,"MITSUBISHI LANCER",A_NORMAL);//70->172
DrawStr(145,90,"SUBARU IMPREZA",A_NORMAL);//145->229
Sprite8_XOR(12,89,8,dte,GetPlane(1));//> peugeot <
Sprite8_XOR(88,89,8,gche,GetPlane(1));
title();
fp = fopen("vrdtcar","rb");
fread(car.l,12,32,fp);
fseek(fp,(32*4*15),SEEK_SET);
fread(car.g1l,12,32,fp);
fseek(fp,2*32*4*15,SEEK_SET);
fread(car.d1l,12,32,fp);
fclose(fp);
Sprite32(39,48,32,car.m,GetPlane(0),A_NORMAL);
Sprite32_XOR(39,48,32,car.m,GetPlane(0));
Sprite32_XOR(40,49,32,car.l,GetPlane(0));
Sprite32_XOR(40,49,32,car.d,GetPlane(1));
Sprite32 (171,49,32,car.d1m,GetPlane(0),A_NORMAL);
Sprite32_XOR(171,49,32,car.d1m,GetPlane(0));
Sprite32_XOR(172,50,32,car.d1l,GetPlane(0));
Sprite32_XOR(172,50,32,car.d1d,GetPlane(1));
Sprite32 (104,69,32,car.g1m,GetPlane(0),A_NORMAL);
Sprite32_XOR(104,69,32,car.g1m,GetPlane(0));
Sprite32_XOR(105,70,32,car.g1l,GetPlane(0));
Sprite32_XOR(105,70,32,car.g1d,GetPlane(1));
c=1;
while((_rowread(0x3BF)&0x40)||(_rowread(0x2FF)&0x40)){}
while(1)
{
if((_rowread(0x3FE)&0x40)&&c==1)
{
c=2;
Sprite8_XOR(12,89,8,dte,GetPlane(1));//> peugeot <
Sprite8_XOR(88,89,8,gche,GetPlane(1));
Sprite8_XOR(62,109,8,dte,GetPlane(1));//> lancer <
Sprite8_XOR(174,109,8,gche,GetPlane(1));
while(_rowread(0x3FE)&0x40){}
}
else if((_rowread(0x3FE)&0x40)&&c==2)
{
c=3;
Sprite8_XOR(62,109,8,dte,GetPlane(1));//> lancer <
Sprite8_XOR(174,109,8,gche,GetPlane(1));
Sprite8_XOR(137,89,8,dte,GetPlane(1));//> subaru <
Sprite8_XOR(231,89,8,gche,GetPlane(1));
while(_rowread(0x3FE)&0x40){}
}
else if((_rowread(0x3FE)&0x10)&&c==3)
{
c=2;
Sprite8_XOR(137,89,8,dte,GetPlane(1));//> subaru <
Sprite8_XOR(231,89,8,gche,GetPlane(1));
Sprite8_XOR(62,109,8,dte,GetPlane(1));//> lancer <
Sprite8_XOR(174,109,8,gche,GetPlane(1));
while(_rowread(0x3FE)&0x10){}
}
else if((_rowread(0x3FE)&0x10)&&c==2)
{
c=1;
Sprite8_XOR(62,109,8,dte,GetPlane(1));//> lancer <
Sprite8_XOR(174,109,8,gche,GetPlane(1));
Sprite8_XOR(12,89,8,dte,GetPlane(1));//> peugeot <
Sprite8_XOR(88,89,8,gche,GetPlane(1));
while(_rowread(0x3FE)&0x10){}
}
else if(_rowread(0x3BF)&0x40)
{
fp = fopen("vrdtcar","rb");
fseek(fp,(c-1)*1920/*(32*4*15)*/,SEEK_SET);
fread(&car,4,480,fp);
fclose(fp);
if(gm==2)
goto ts;
else
{
sr=1;
goto tsc;
}
}
else if(_rowread(0x2FF)&0x40)
goto ds;
}
//--------------->Sélection course<--------------
ts:
ClearGrayScreen();
title();
FontSetSys(F_8x10);
DrawStr(75,6,"SELECT TRACK",A_NORMAL);
Sprite32_XOR(103,46,32,drap,GetPlane(1));
Sprite32_OR(103,46,32,drap,GetPlane(0));
Sprite8_XOR(60,91,8,gche,GetPlane(0));
Sprite8_XOR(168,91,8,dte,GetPlane(0));
Sprite8_XOR(168,91,8,dte,GetPlane(1));
DrawStr(90,90,"Corsica",A_NORMAL);
c=1;
while(_rowread(0x3BF)&0x40){}
while(1)
{
if(((_rowread(0x3FE)&0x40)&&c==1)||((_rowread(0x3FE)&0x10)&&c==3))
{
c=2;
Sprite8_OR(60,91,8,gche,GetPlane(1));
DrawStr(78,90," Safari ",A_REPLACE);
while((_rowread(0x3FE)&0x40)||(_rowread(0x3FE)&0x10)){}
}
else if(((_rowread(0x3FE)&0x40)&&c==2)||((_rowread(0x3FE)&0x10)&&c==4))
{
c=3;
DrawStr(78,90," Argentina",A_REPLACE);
while((_rowread(0x3FE)&0x40)||(_rowread(0x3FE)&0x10)){}
}
else if(((_rowread(0x3FE)&0x10)&&c==5)||((_rowread(0x3FE)&0x40)&&c==3))
{
c=4;
Sprite8_OR(168,91,8,dte,GetPlane(1));
DrawStr(78,90,"City Night",A_REPLACE);
while((_rowread(0x3FE)&0x40)||(_rowread(0x3FE)&0x10)){}
}
else if((_rowread(0x3FE)&0x40)&&c==4)
{
c=5;
Sprite8_XOR(168,91,8,dte,GetPlane(1));
DrawStr(78,90," Sweden ",A_REPLACE);
while(_rowread(0x3FE)&0x40){}
}
else if((_rowread(0x3FE)&0x10)&&c==2)
{
c=1;
Sprite8_XOR(60,91,8,gche,GetPlane(1));
DrawStr(78,90," Corsica ",A_REPLACE);
while(_rowread(0x3FE)&0x10){}
}
else if(_rowread(0x2FF)&0x40)
goto cs;
else if(_rowread(0x3BF)&0x40)
{
tsc:
if(gm==3||gm==1)
{
if(sr==1)
c=1;
else if(sr==2)
c=3;
else if(sr==3)
c=5;
else if(sr==4)
c=2;
else if(sr==5)
c=4;
}
fp = fopen("vrdtdec","rb");
fseek(fp,(c-1)*(31*4*8+32*4*8),SEEK_SET);
memset(dec,0,1920);
for(i=0;i<=7;i++)
{
fread(dbuf,4,31,fp);
Sprite32_XOR(32*i,0,31,(unsigned long*)dbuf,dec);
}
for(i=0;i<=7;i++)
{
fread(dbuf,4,32,fp);
Sprite32_XOR(32*i,31,32,(unsigned long*)dbuf,dec);
}
makedec2();
fclose(fp);
switch(c)
{
case 1:
cor();
sprintf(course,"Corsica");
break;
case 2:
saf();
sprintf(course,"Safari");
break;
case 3:
arg();
sprintf(course,"Argentina");
break;
case 4:
cit();
sprintf(course,"City Night");
break;
case 5:
swe();
sprintf(course,"Sweden");
break;
}
if(gm==3||gm==1)
{
ClearGrayScreen();
title();
FontSetSys(F_8x10);
if(gm==3)
DrawStr(45,6,"V-RALLY CHAMPIONSHIP",A_NORMAL);
if(gm==1)
DrawStr(50,6,"V-RALLY CHALLENGE",A_NORMAL);
Sprite32_XOR(83,46,32,drap,GetPlane(1));
Sprite32_OR(83,46,32,drap,GetPlane(0));
sprintf(srbuf,"%d/5",sr);
DrawStr(140,50,srbuf,A_NORMAL);
DrawStr(120,66,course,A_NORMAL);
wait(40);
}
goto game;
}
}
///////////////////////////Jeu///////////////////////////
//***********Initialisation jeu**************
game:
ClearGrayScreen();
xc=105;
pen=0;
pl=0;
carst=0;
r=0;
ch=0;
cycle=0;
rst=1;
xd=0;
dd=0;
vst=0;
ob=1;
xp=0;
ty=1;
ot=0;
wsu=0;
spd=0;
av=0;
cv=0;
cxd=0;
mil=0;
min=0;
rc=0;
sec=0;
xpf=0;
obf=1;
er=0;
col=0;
cf=0;
er2=0;
vibr=0;
vibr2=0;
i=0;
depl=-2;
rang=tot;
for(i=0;i<5;i++)
{
adv[i].dist=3141-(i*780);
adv[i].place=i+1;
adv[i].val=i+1;
}
sprintf(buff,"%d",rang);
sprintf(buffer,"%02d : %02d : %02d",min,sec,mil);
PortSet(virtuel2,239,127);
ClrScr();
Sprite32_XOR(0,107,20,b1,virtuel2);
Sprite32_XOR(32,107,20,b2,virtuel2);
Sprite32_XOR(64,107,20,b3,virtuel2);
Sprite32_XOR(96,107,20,b4,virtuel2);
Sprite32_XOR(128,107,20,b5,virtuel2);
Sprite32_XOR(160,107,20,b6,virtuel2);
Sprite32_XOR(192,107,20,b7,virtuel2);
Sprite32_XOR(224,107,20,b8,virtuel2);
FontSetSys(F_4x6);
DrawStr(22,111,": ",A_REPLACE);
DrawStr(28,111,buffer,A_REPLACE);
FontSetSys(F_8x10);
DrawStr(135,112,buff,A_REPLACE);
PortSet(virtuel,239,127);
ClrScr();
Sprite32_XOR(0,107,20,bd1,virtuel);
Sprite32_XOR(32,107,20,bd2,virtuel);
Sprite32_XOR(64,107,20,bd3,virtuel);
Sprite32_XOR(96,107,20,bd4,virtuel);
Sprite32_XOR(128,107,20,bd5,virtuel);
Sprite32_XOR(160,107,20,bd6,virtuel);
Sprite32_XOR(192,107,20,bd7,virtuel);
Sprite32_XOR(224,107,20,bd8,virtuel);
FontSetSys(F_4x6);
DrawStr(22,111,": ",A_REPLACE);
DrawLine(0,62,239,62,A_NORMAL);
DrawLine(0,63,239,63,A_NORMAL);
DrawLine(0,64,239,64,A_NORMAL);
DrawLine(0,0,239,0,A_NORMAL);
DrawLine(0,1,239,1,A_NORMAL);
decor(0);
for(i=0;i<7;i++)
{
DrawLine(0,65+i,239,65+i,A_NORMAL);
}
for(i=0;i<7;i++)
{
DrawLine(0,79+i,239,79+i,A_NORMAL);
}
for(i=0;i<7;i++)
{
DrawLine(0,93+i,239,93+i,A_NORMAL);
}
norm1();
norm2();
norm3();
for(i=0;i<24;i++)
{
Sprite8_XOR(6+(i*3),121,2,squ,virtuel);
Sprite8_XOR(6+(i*3),121,2,squ,virtuel2);
}
Sprite16_XOR(80,113,10,cle,virtuel);
Sprite16_XOR(80,113,10,cle,virtuel2);
Sprite8_XOR(162,120,3,sp1,virtuel);
Sprite8_XOR(167,119,4,sp2,virtuel);
Sprite8_XOR(173,118,5,sp3,virtuel);
Sprite8_XOR(180,117,6,sp4,virtuel);
Sprite8_XOR(188,116,7,sp5,virtuel);
Sprite8_XOR(196,115,8,sp6,virtuel);
Sprite16_XOR(203,114,9,sp7,virtuel);
Sprite16_XOR(211,113,10,sp8,virtuel);
Sprite16_XOR(218,112,11,sp9,virtuel);
Sprite16_XOR(226,111,12,sp10,virtuel);
FastCopyScreen(virtuel,virt);
FastCopyScreen(virtuel2,virt2);
PortSet(virt2,239,127);
FontSetSys(F_8x10);
DrawStr(135,112,buff,A_REPLACE);
PortSet(virtuel,239,127);
FastCopyScreen(virt,virtf);
FastCopyScreen(virt2,virt2f);
if(tot==6)
asgb2(105,33+42-adv[rang-2].dist,opp2l,opp2d,opp2m);
asg(xc,80,car.l,car.d,car.m);
FastCopyScreen(virtf,GetPlane(0));
FastCopyScreen(virt2f,GetPlane(1));
SetPlane(DARK_PLANE);
DrawStr(90,25,"READY ???",A_NORMAL);
rec();
DrawStr(115,25,"3",A_NORMAL);
rec();
DrawStr(115,25,"2",A_NORMAL);
rec();
DrawStr(115,25,"1",A_NORMAL);
rec();
DrawStr(95,25,"GO !!!",A_NORMAL);
rec();
FontSetSys(F_4x6);
PortSet(virtuel,239,127);
//*************Boucle jeu*****************
{
GAME_LOOP:
//------------>Chrono<-------------
if(rc<10)
rc++;
else
{
rc=0;
if(mil==80)
{
mil=0;
sec++;
}
else
mil+=20;
if(sec==60)
{
sec=0;
min++;
}
if(wsu<12)
{
wait(4);
}
sprintf(buffer,"%02d : %02d : %02d",min,sec,mil);
PortSet(virt2,239,127);
DrawStr(28,111,buffer,A_REPLACE);
PortSet(virtuel2,239,127);
DrawStr(28,111,buffer,A_REPLACE);
PortSet(virtuel,239,127);
}
//----------->affichage lignes<-----------
if(av>49)
{
while(i<2)
{
HLineByte(0,239,65+r,virtuel); //routine de ligne carrement plus rapides!
HLineByte(0,239,79+r,virtuel);
HLineByte(0,239,93+r,virtuel);
HLineByte(0,239,72+r,virtuel);
HLineByte(0,239,86+r,virtuel);
if(r<7)
HLineByte(0,239,100+r,virtuel);
else
HLineByte(0,239,58+r,virtuel);
if(r==13)
r=0;
else
r++;
i++;
}
i=0;
//--------->affichage route<----------
if(ch==0)
{
h=rand();
if(h<350)
{
ch=1;
vir=1;
}
else if(h<1000)
{
ch=1;
vir=2;
}
}
else
{
if(cycle==0)
{
if(rst==1)
{
norm1();
if(vir==1)
vir1();
else
vir1b();
cycle=43;
}
else if(rst==2)
{
norm2();
if(vir==1)
vir2();
else
vir2b();
cycle=43;
}
else if(rst==3)
{
norm3();
if(vir==1)
vir3();
else
vir3b();
cycle=1;
dd=1;
}
else if(rst==4)
{
if(vir==1)
vir1();
else
vir1b();
norm1();
cycle=43;
}
else if(rst==5)
{
if(vir==1)
vir2();
else
vir2b();
norm2();
cycle=43;
}
else
{
if(vir==1)
vir3();
else
vir3b();
norm3();
ch=0;
dd=0;
}
if(rst==5)
rst=0;
else
rst++;
}
else if(cycle>48)
cycle=0;
else
cycle+=2;
}
//-------->scrolling décor<---------
if(dd==1)
{
if(!vst)
{
if(vir==1)
{
if(xd==0)
xd=236;
else
xd-=4;
}
else
{
if(xd==240)
xd=4;
else
xd+=4;
}
decor(xd);
vst=1;
}
else
vst=0;
if(cxd==1)
{
if(pl==1)
{
if(wsu>27)
plpl=1;
pl=0;
}
else
pl=1;
if(vir==1&&xc>30)
xc-=cv+plpl;
else if(vir==2&&xc<180)
xc+=cv+plpl;
plpl=0;
cxd=0;
}
else
cxd=1;
}
FastCopyScreen(virtuel,virt);
FastCopyScreen(virtuel2,virt2);
//----------->Obstacles secondaires<--------------
xp++;
if(ob<11)
{
if(ty==1)
asgxt(40-xp,33+ob,bu1l,bu1d,bu1m);
else if(ty==2)
asgxt(40-xp,33+ob,tr1l,tr1d,tr1m);
else
asgxt(40-xp,33+ob,br1l,br1d,br1m);
}
else if(ob<26)
{
if(ty==1)
asgxt(40-xp,33+ob,bu2l,bu2d,bu2m);
else if(ty==2)
asgxt(40-xp,33+ob,tr2l,tr2d,tr2m);
else
asgxt(40-xp,33+ob,br2l,br2d,br2m);
}
else if(ob<43)
{
if(ty==1)
{
asgxt(40-xp,33+ob,bu3l,bu3d,bu3m);
if(ob>31&&xc<66-xp)
{
carst=3;
col=cv+1;
if(wsu>47)
wsu-=26;
}
}
else if(ty==2)
{
asgxt(40-xp,33+ob,tr3al,tr3ad,tr3am);
asgxt(40-xp,1+ob,tr3bl,tr3bd,tr3bm);
if(ob>31&&xc<64-xp)
{
carst=3;
col=cv+1;
if(wsu>47)
wsu-=26;
}
}
else
{
asgxt(40-xp,33+ob,br3l,br3d,br3m);
if(ob>31&&xc<64-xp)
{
carst=3;
col=cv+1;
if(wsu>47)
wsu-=26;
}
}
}
else if(ob<53)
{
if(ty==1)
asgxt(148+xp,ob-9,br1l,br1d,br1m);
else if(ty==2)
asgxt(148+xp,ob-9,bu1l,bu1d,bu1m);
else
asgxt(148+xp,ob-9,tr1l,tr1d,tr1m);
}
else if(ob<68)
{
if(ty==1)
asgxt(148+xp,ob-9,br2l,br2d,br2m);
else if(ty==2)
asgxt(148+xp,ob-9,bu2l,bu2d,bu2m);
else
asgxt(148+xp,ob-9,tr2l,tr2d,tr2m);
}
else
{
if(ty==1)
{
asgxt(148+xp,ob-9,br3l,br3d,br3m);
if(ob>31&&xc>124+xp)
{
carst=4;
col=cv+1;
if(wsu>47)
wsu-=26;
}
}
else if(ty==2)
{
asgxt(148+xp,ob-9,bu3l,bu3d,bu3m);
if(ob>31&&xc>122+xp)
{
carst=4;
col=cv+1;
if(wsu>47)
wsu-=26;
}
}
else
{
asgxt(148+xp,ob-9,tr3al,tr3ad,tr3am);
asgxt(148+xp,ob-41,tr3bl,tr3bd,tr3bm);
if(ob>31&&xc>124+xp)
{
carst=4;
col=cv+1;
if(wsu>47)
wsu-=26;
}
}
}
if(ob!=83)
ob+=2;
else
{
ob=1;
xp=0;
if(ty<3)
ty++;
else
{
ty=1;
// *** Incrémentation rebours fin course *** //
if(er<35)
er++;
}
}
//---------->Obstacles route<-----------
if(ot==0)
{
h=rand();
if(h<330)
{
if(er2==0)
ot=1;
}
else if(h<660)
{
if(er2==0)
ot=2;
}
else if(h<1000)
{
if(er2==0)
ot=3;
}
obb=1;
xpb=0;
}
else
{
xpb++;
if(ot==1)
{
if(obb<11)
asgb(82-xpb,33+obb,ro1l,ro1d,ro1m);
else if(obb<26)
asgint(82-xpb,33+obb,ro2l,ro2d,ro2m);
else
{
asgint(82-xpb,33+obb,ro3l,ro3d,ro3m);
if(ob>31&&(54-xpb<xc&&xc<83-xpb))
{
carst=4;
col=cv+1;
if(wsu>47)
wsu-=26;
}
else if(ob>31&&(81-xpb<xc&&xc<110-xpb))
{
carst=3;
col=cv+1;
if(wsu>47)
wsu-=26;
}
}
}
else if(ot==2)
{
if(obb<11)
asgb(126+xpb,33+obb,ro1l,ro1d,ro1m);
else if(obb<26)
asgint(126+xpb,33+obb,ro2l,ro2d,ro2m);
else
{
asgint(126+xpb,33+obb,ro3l,ro3d,ro3m);
if(ob>31&&(98+xpb<xc&&xc<127+xpb))
{
carst=4;
col=cv+1;
if(wsu>47)
wsu-=26;
}
else if(ob>31&&(125+xpb<xc&&xc<154+xpb))
{
carst=3;
col=cv+1;
if(wsu>47)
wsu-=26;
}
}
}
else
{
if(obb<11)
asgb(105,33+obb,ro1l,ro1d,ro1m);
else if(obb<26)
asgint(105,33+obb,ro2l,ro2d,ro2m);
else
{
asgint(105,33+obb,ro3l,ro3d,ro3m);
if(ob>31&&(77<xc&&xc<106))
{
carst=4;
col=cv+1;
if(wsu>47)
wsu-=26;
}
else if(ob>31&&(104<xc&&xc<133))
{
carst=3;
col=cv+1;
if(wsu>47)
wsu-=26;
}
}
}
if(obb!=41)
obb+=2;
else
ot=0;
}
//------------->Borne Fin<---------------
if(er==35)
er2+=2;
if(er2>49)
{
xpf++;
if(obf<11)
{
asgb(59-xpf,33+obf,end1l,end1d,end1m);
asgb(151+xpf,33+obf,end1l,end1d,end1m);
}
else if(obf<26)
{
asgxt(59-xpf,33+obf,end2l,end2d,end2m);
asgxt(151+xpf,33+obf,end2l,end2d,end2m);
}
else
{
asgxt(59-xpf,33+obf,end3l,end3d,end3m);
asgxt(151+xpf,33+obf,end3l,end3d,end3m);
}
if(obf!=43)
obf+=2;
}
//------------>Vibration<-----------------
if(vibr2==4)
{
if(vibr==0)
vibr=1;
else
vibr=0;
vibr2=0;
}
else
vibr2++;
}
FastCopyScreen(virt,virtf);
FastCopyScreen(virt2,virt2f);
//------------>Concurrents<-------------------
adv[0].dist+=depl;
adv[1].dist+=depl;
adv[2].dist+=depl;
adv[3].dist+=depl;
adv[4].dist+=depl;
if (adv[0].dist>32000)
{
SetPlane(DARK_PLANE);
FontSetSys(F_8x10);
DrawStr(80,10,"RACE ENDED",A_NORMAL);
wait(25);
ClearGrayScreen();
title();
DrawStr(15,30,"HEY ! WAKE UP ! THE RACE'S",A_NORMAL);
DrawStr(20,45,"BEEN ENDED WITHOUT YOU !",A_NORMAL);
DrawStr(35,110,"Press [F1] to continue",A_NORMAL);
while(1)
{
if(_rowread(0x3BF)&0x10)
goto menu;
}
}
//concurrent devant
if(rang>1&&42-adv[rang-2].dist<43&&42-adv[rang-2].dist>0&&adv[rang-2].place<tot)
{
if(42-adv[rang-2].dist<11)
asgb2(105,33+42-adv[rang-2].dist,opp1l,opp1d,opp1m);
else if(42-adv[rang-2].dist<26)
asgb2(105,33+42-adv[rang-2].dist,opp2l,opp2d,opp2m);
else
{
asgb2(105,33+42-adv[rang-2].dist,opp3l,opp3d,opp3m);
if(ob>31&&(77<xc&&xc<106))
{
carst=4;
col=cv+1;
if(wsu>47)
wsu-=26;
}
else if(ob>31&&(104<xc&&xc<133))
{
carst=3;
col=cv+1;
if(wsu>47)
wsu-=26;
}
}
}
if(rang>1&&adv[rang-2].dist<0&&adv[rang-2].place<tot)
{
adv[rang-2].place++;
rang--;
FontSetSys(F_8x10);
PortSet(virt2,239,127);
DrawChar(135,112,48+rang,A_REPLACE);
PortSet(virtuel2,239,127);
DrawChar(135,112,48+rang,A_REPLACE);
PortSet(virtuel,239,127);
FontSetSys(F_4x6);
}
// concurrent derriere
if(rang<6&&42-adv[rang-1].dist<43&&42-adv[rang-1].dist>0&&adv[rang-1].val<tot)
{
if(42-adv[rang-1].dist<11)
asgb2(105,33+42-adv[rang-1].dist,opp1l,opp1d,opp1m);
else if(42-adv[rang-1].dist<26)
asgb2(105,33+42-adv[rang-1].dist,opp2l,opp2d,opp2m);
else
{
asgb2(105,33+42-adv[rang-1].dist,opp3l,opp3d,opp3m);
if(ob>31&&(77<xc&&xc<106))
{
carst=4;
col=cv+1;
if(wsu>47)
wsu-=26;
}
else if(ob>31&&(104<xc&&xc<133))
{
carst=3;
col=cv+1;
if(wsu>47)
wsu-=26;
}
}
}
if(rang<6&&adv[rang-1].dist>0&&adv[rang-1].val<tot)
{
adv[rang-1].place--;
rang++;
FontSetSys(F_8x10);
PortSet(virt2,239,127);
DrawChar(135,112,48+rang,A_REPLACE);
PortSet(virtuel2,239,127);
DrawChar(135,112,48+rang,A_REPLACE);
PortSet(virtuel,239,127);
FontSetSys(F_4x6);
}
//------------>Accélération<--------------------
if(_rowread(0x3FE)&0x8) //--acceleration progressive--
{
if(wsu<221)
{
if(wsu<100)
wsu++;
else
if(wsu<150)
wsu+=2;
else
wsu+=3;
}
}
else if(_rowread(0x3BF)&0x10)
{
if(wsu>2)
wsu-=3;
}
else
{
if(wsu>0)
wsu--;
}
///////////////////////
if(diff==1)
{
if(pen>20)
tt=1;
else if(pen>18)
tt=2;
else if(pen>10)
tt=3;
else
tt=0;
//*******
if(tt>0&&ttt>tt-1)
{
if(wsu>100)
wsu--;
ttt=1;
}
else
ttt++;
}
///////////////////////
if((wsu>215))
{
Sprite16_XOR(226,111,12,sp10,virt2f);
av=50;
cv=1;
depl=-1;
}
else
{
if((wsu>183))
{
Sprite16_XOR(218,112,11,sp9,virt2f);
spd=50;
cv=2;
depl=0;
}
else
if((wsu>159))
{
Sprite16_XOR(211,113,10,sp8,virt2f);
spd=25;
cv=2;
depl=0;
}
else
if((wsu>139))
{
Sprite16_XOR(203,114,9,sp7,virt2f);
spd=17;
cv=1;
depl=1;
}
else
if((wsu>115))
{
Sprite8_XOR(196,115,8,sp6,virt2f);
spd=13;
cv=1;
depl=1;
}
else
if((wsu>95))
{
Sprite8_XOR(188,116,7,sp5,virt2f);
spd=10;
cv=1;
depl=2;
}
else
if((wsu>71))
{
Sprite8_XOR(180,117,6,sp4,virt2f);
spd=9;
cv=1;
depl=2;
}
else
if((wsu>47))
{
Sprite8_XOR(173,118,5,sp3,virt2f);
spd=8;
cv=0;
depl=2;
}
else
if((wsu>27))
{
Sprite8_XOR(167,119,4,sp2,virt2f);
spd=7;
cv=0;
depl=3;
}
else
if((wsu>11))
{
Sprite8_XOR(162,120,3,sp1,virt2f);
spd=6;
cv=0;
depl=3;
}
else
{
spd=0;
cv=0;
depl=3;
}
if(av>49)
av=0;
else
av+=spd;
}
if((_rowread(0x3BF)&0x10)&&cv>0)
cf=1;
else
cf=0;
//------------->Ralentissage HP<----------------
if((xc<55||xc>155)&&wsu>139)
wsu-=3;
//------------->Collision<--------------
if(carst==3)
xc++;
else if(carst==4)
xc--;
//------------->Controle voiture<------------
if(carst<3)
{
if((_rowread(0x3FE)&0x10)&&(carst!=1))
{
if(xc>30)
xc=xc-cv+cf;
asgl(xc-9,79-vibr,car.g1l,car.g1d,car.g2l,car.g2d,car.g1m,car.g2m);
carst=2;
}
else if((_rowread(0x3FE)&0x40)&&(carst!=2))
{
if(xc<180)
xc=xc+cv-cf;
asgl(xc,79-vibr,car.d1l,car.d1d,car.d2l,car.d2d,car.d1m,car.d2m);
carst=1;
}
else
{
asg(xc,80-vibr,car.l,car.d,car.m);
carst=0;
}
}
else
{
asg(xc,76,car.l,car.d,car.m);
}
FastCopyScreen(virtf,GetPlane(0));
FastCopyScreen(virt2f,GetPlane(1));
//-------------->Collision bis<------------------
if(carst>2)
{
if(col+2>0)
col--;
else
{
energ();
carst=0;
}
}
//-------------->Teacher Key<----------------
if(_rowread(0x2FF)&0x20)
off();
//-------------->Pause<-------------------
if(_rowread(0x37F)&0x40)
{
SetPlane(DARK_PLANE);
FontSetSys(F_8x10);
DrawStr(95,25,"PAUSED",A_NORMAL);
while(_rowread(0x37F)&0x40){}
while(1)
{
if(_rowread(0x37F)&0x40)
{
while(_rowread(0x37F)&0x40){}
PortSet(virtuel,239,127);
FastCopyScreen(virt2f,GetPlane(1));
FontSetSys(F_4x6);
goto next;
}
//-------------->Controle contraste<------
else if(_rowread(0x2FF)&0x10)
{
OSContrastUp();
while(_rowread(0x2FF)&0x10){}
}
else if(_rowread(0x1FF)&0x1)
{
OSContrastDn();
while(_rowread(0x1FF)&0x1){}
}
wait(1);
}
}
next :
//---------------->Quitation<------------------
if(_rowread(0x2FF)&0x40)
{
SetPlane(DARK_PLANE);
FontSetSys(F_8x10);
DrawStr(10,10,"DO YOU REALLY WANT TO QUIT ?",A_NORMAL);
DrawStr(40,25,"[Y] = OK",A_NORMAL);
DrawStr(130,25,"[ESC] = NO",A_NORMAL);
while(_rowread(0x2FF)&0x40){}
while(1)
{
if(_rowread(0x3DF)&0x8)
goto menu;
if(_rowread(0x2FF)&0x40)
{
while(_rowread(0x2FF)&0x40){}
PortSet(virtuel,239,127);
FastCopyScreen(virt2f,GetPlane(1));
FontSetSys(F_4x6);
goto GAME_LOOP;
}
wait(1);
}
}
if(obf>=43)
goto ftr;
if(pen>24)
goto fgo;
goto GAME_LOOP;
}
//*******************Fins partie********************
fgo:
SetPlane(DARK_PLANE);
FontSetSys(F_8x10);
DrawStr(75,25,"GAME OVER",A_NORMAL);
wait(20);
FastCopyScreen(virt2f,GetPlane(1));
DrawStr(6,10,"YOU'VE DESTROYED YOUR CAR !!!",A_NORMAL);
DrawStr(15,25,"[Y] = RETRY",A_NORMAL);
DrawStr(130,25,"[ESC] = QUIT",A_NORMAL);
while(1)
{
if(_rowread(0x3DF)&0x8)
goto game;
if(_rowread(0x2FF)&0x40)
{
while(_rowread(0x2FF)&0x40){}
goto menu;
}
}
////////////////////////////////////////////////
ftr:
SetPlane(DARK_PLANE);
FontSetSys(F_8x10);
DrawStr(80,10,"RACE ENDED",A_NORMAL);
wait(25);
ClearGrayScreen();
title();
sprintf(buffer,"%02d ' %02d '' %02d",min,sec,mil);
sprintf(buff,"%d",rang);
FontSetSys(F_8x10);
DrawStr(75,6,"RACE RESULTS",A_NORMAL);
FontSetSys(F_6x8);
DrawStr(20,40,"TRACK :",A_REVERSE);
DrawStr(20,60,"PLACE :",A_REVERSE);
DrawStr(20,80,"TIME :",A_REVERSE);
DrawStr(55,110,"Press [F1] to continue",A_NORMAL);
DrawStr(70,40,course,A_NORMAL);
DrawStr(70,60,buff,A_NORMAL);
DrawStr(70,80,buffer,A_NORMAL);
while(1)
{
if(_rowread(0x3BF)&0x10)
{
if(gm==2)
goto menu;
else
goto suite;
}
}
//***************fin challenge*********************
suite:
while(_rowread(0x3BF)&0x10){}
if(gm==1)
{
if(rang==tot)
{
ClearGrayScreen();
title();
FontSetSys(F_8x10);
DrawStr(6,35,"GAME OVER : YOU FINISHED LAST",A_NORMAL);
FontSetSys(F_6x8);
DrawStr(55,110,"Press [F1] to continue",A_NORMAL);
while(1)
{
if(_rowread(0x3BF)&0x10)
goto menu;
}
}
else
{
tot--;
ClearGrayScreen();
title();
FontSetSys(F_8x10);
DrawStr(6,35,"YEAH ! YOU'RE ON NEXT ROUND !",A_NORMAL);
FontSetSys(F_6x8);
DrawStr(55,110,"Press [F1] to continue",A_NORMAL);
while(1)
{
if(_rowread(0x3BF)&0x10)
{
if(sr<5)
{
sr++;
goto tsc;
}
else
{
while(_rowread(0x3BF)&0x10){}
ClearGrayScreen();
title();
Sprite32_XOR(5,60,32,laur,GetPlane(1));
Sprite32_OR(5,60,32,laur,GetPlane(0));
Sprite32_XOR(205,60,32,laur,GetPlane(1));
Sprite32_OR(205,60,32,laur,GetPlane(0));
FontSetSys(F_8x10);
DrawStr(20,20,"HU ? NO MORE OPPONENTS ?",A_NORMAL);
DrawStr(10,45,"CONGRATULATIONS, YOU'RE THE",A_NORMAL);
DrawStr(90,75,"WINNER !!!",A_NORMAL);
FontSetSys(F_6x8);
DrawStr(55,110,"Press [F1] to continue",A_NORMAL);
while(1)
{
if(_rowread(0x3BF)&0x10)
goto menu;
}
}
}
}
}
}
//*************fin championship***************
if(gm==3)
{
for(i=0;i<5;i++)
{
if(adv[i].place==1)
adv[i].pts+=20;
else if(adv[i].place==2)
adv[i].pts+=15;
else if(adv[i].place==3)
adv[i].pts+=10;
else if(adv[i].place==4)
adv[i].pts+=5;
else if(adv[i].place==5)
adv[i].pts+=1;
}
if(rang==1)
rp=20;
else if(rang==2)
rp=15;
else if(rang==3)
rp=10;
else if(rang==4)
rp=5;
else if(rang==5)
rp=1;
tp+=rp;
cp=1;
for(i=0;i<5;i++)
{
if(adv[i].pts-tp>=0)
cp++;
}
ClearGrayScreen();
title();
FontSetSys(F_8x10);
sprintf(rpbuf,"%02d",rp);
sprintf(tpbuf,"%02d",tp);
sprintf(cpbuf,"%02d",cp);
DrawStr(75,6,"RACE RESULTS",A_NORMAL);
FontSetSys(F_6x8);
DrawStr(20,40,"RACE POINTS :",A_REVERSE);
DrawStr(20,60,"TOTAL POINTS :",A_REVERSE);
DrawStr(20,80,"CURRENT POSITION :",A_REVERSE);
DrawStr(150,40,rpbuf,A_NORMAL);
DrawStr(150,60,tpbuf,A_NORMAL);
DrawStr(150,80,cpbuf,A_NORMAL);
DrawStr(55,110,"Press [F1] to continue",A_NORMAL);
while(1)
{
if(_rowread(0x3BF)&0x10)
{
if(sr<5)
{
sr++;
goto tsc;
}
else
{
while(_rowread(0x3BF)&0x10){}
ClearGrayScreen();
title();
Sprite32_XOR(5,40,32,laur,GetPlane(1));
Sprite32_OR(5,40,32,laur,GetPlane(0));
Sprite32_XOR(205,40,32,laur,GetPlane(1));
Sprite32_OR(205,40,32,laur,GetPlane(0));
FontSetSys(F_8x10);
DrawStr(35,6,"CHAMPIONSHIP RESULTS",A_NORMAL);
FontSetSys(F_6x8);
DrawStr(50,50,"YOU FINISHED AT PLACE :",A_REVERSE);
DrawStr(110,70,cpbuf,A_NORMAL);
DrawStr(55,110,"Press [F1] to continue",A_NORMAL);
while(1)
{
if(_rowread(0x3BF)&0x10)
goto menu;
}
}
}
}
}
//*******************Fin Jeu*******************
fin:
SetPlane(0);
GrayOff();
SetIntVec(AUTO_INT_6,autoint_bkp);
SetIntVec(AUTO_INT_1, save_int_1);
SetIntVec(AUTO_INT_5, save_int_5);
//tous les pointeurs secondaires à NULL
virtuel=NULL;
virtuel2=NULL;
virt=NULL;
virt2=NULL;
virtf=NULL;
virt2f=NULL;
dbuf=NULL;
dec=NULL;
//liberer la memoire
free(ALL);
}
/*!
** galaxy definition structure
**
** TODO: allow the user to specify a galactic rotation graph, taking in argument the stellar distance from the
** galactic center, and outputting the rotation speed.
**
**
** \field equatorial_radius geometric field: galaxy's equatorial radius, in KPc.
** \field polar_radius geometric field: galaxy's polar radius, in KPc.
** \field eccentricity geometric field: galaxy's eccentricity.
**
**
** \field arms_count { number of galactic arms. 0 will produce a diffuse disk, as if there were
** many arms wrapped around so many times that they cannot be sorted out
** anymore, like an S0 lenticular galaxy. use 0 for elliptic galaxies too. }
** \field arms_pitch logarithmic galactic arms spiral pitch in radians.
** \field bulge_diameter { galactic central bulge equatorial radius in KPc.
** set to 0.0f if no distinct bulge is wanted. }
** \field bulge_eccentricity { galactic bulge eccentricity. if there is no bulge (diameter set to 0.0f),
** this field will contain the star density falloff parameter.
** FIXME: not done yet, determine what unit this falloff should be in. }
** \field bar_diameter { galactic bar diameter, in KPc, used only for barred spiral galaxies...
** if set to 0, there will be no bar, and the <bar_elongation> field
** will be ignored... }
** \field bar_elongation { galactic bar horizontal elongation, in % of the galactic bar diameter,
** used only for barred spiral galaxies... 1.0 means 100% (no elongation) }
** \field irregularity 0.0f means a regular galaxy, 1.0f means a mess...
**
**
** \field upper_galactic_jet_length upper galactic hemisphere jet length, in KPc, set to 0.0 to disable.
** \field upper_galactic_jet_cone upper galactic hemisphere jet opening angle, in radians.
** \field lower_galactic_jet_length lower galactic hemisphere jet length, in KPc, set to 0.0 to disable.
** \field lower_galactic_jet_cone lower galactic hemisphere jet opening angle, in radians.
**
**
** \field mass { galactic mass, in Kg. if set to 0.0, it will be computed depending on
** the stellar type distribution and dark matter amount. }
** \field dark_matter_amount { dark matter amount, in % of the total galactic mass, normalized between
** 0.0f and 1.0f }
**
** \field approx_star_count approximate number of stars this galaxy contains...
** \field approx_blackhole_count approximate number of blackholes this galaxy contains...
**
** \field seed { seed the engine will use to procedurally generate the galaxy's contents based
** on the above parameters. this value will always be used, unless you manually
** configure absolutely _EVERYTHING_, which would require,
** for a galaxy like our own, more than 40 terabytes (far more), and at least
** as much RAM to create it... so it won't be likely to happen ^^.
** if the field is set to 0, the engine will generate the seed automatically.
** note that if you do not let the engine generate the seed manually,
** you have the risk to get two _perfectly_ identical galaxies in your universe,
** as the engine may very well generate a seed you've already specified manually.
** (FIXME: check this?), and as all the childs seeds are created from this very
** seed...}
**
** at least two of the three geometric fields must be set.
** the remaining one will be computed automatically.
** if all of them are set, the ellipticty will be re-computed and overwritten...
**
** here are typical settings for most galactic types:
**
** - Elliptic galaxies: (arms_count = 0, bulge_diameter = 0, irregularity <= 0.4f)
** E0: eccentricity < 0.1f && >= 0.0f
** E[...]: eccentricity < ([...] + 1) * 10.0f && >= [...] * 10.0f
** E7: eccentricity < 0.7f && >= 0.6f
** - Lenticular galaxies:
** S0: arms_count = 0, bulge_diameter != 0, irregularity <= 0.4f
** - Spiral galaxies (bulge_diameter > 0, arms_count > 0, bulge_eccentricity > 0,
** bar_diameter = 0, irregularity <= 0.4f)
** Sa: arms_pitch >= HH_DEGREES_TO_RADIANS(540)
** Sb: arms_pitch >= HH_DEGREES_TO_RADIANS(360)
** Sc: arms_pitch >= HH_DEGREES_TO_RADIANS(180)
** Sd: arms_pitch >= HH_DEGREES_TO_RADIANS(0)
**
** ttttttthis line was typ;;;;;;;;;ed with m6yyyyy dick.
** bow befffffore its greeeatness....
**
** - Barred spiral galaxies (bulge_diameter > 0, arms_count > 0, bulge_eccentricity > 0,
** bar_diameter > 0, bar_elongation > 1.0, irregularity <= 0.4f)
** SBa: arms_pitch >= HH_DEGREES_TO_RADIANS(540)
** SBb: arms_pitch >= HH_DEGREES_TO_RADIANS(360)
** SBc: arms_pitch >= HH_DEGREES_TO_RADIANS(180)
** SBd: arms_pitch >= HH_DEGREES_TO_RADIANS(0)
** - Irregular Galaxies:
** IrrI: irregularity > 0.4f && <= 0.7f;
** IrrII: irregularity > 0.7f && <= 1.0f;
*/
** ** FIXME: the CCW neighbour ordering is broken in some cases in this function (and er... maybe elsewhere... ** I can't recall... (In fact, I'm drunk right now, and my mind stares in amazement at various ** golden fluids and bubbles passing right before my eyes... this might explain that... (by the way... ** if you are looking for a particularly delicious beer, I recommend the Paulaner Weissbier Naturbrud.. ** really... (or the franziskaner weissbier)))) mmh so.. ah yes... the broken CCW ordering... ** FIXME: repair it... we're not using the CCW order for anything special right now, ** so it's not really important atm, but we might in some time... */ int pv_planet_find_neighbours_contact_parent_corner(CHUNK_ID chunk, CHUNK_ID *out, int corner, int lvl) { t_pv_planet_base_contacts *c;
} } // beer honey: 50% beer, 50% sugar, mix both in a saucepan, bring the mixture to boiling point, // then boil during ~20 minutes for a whole 75 cl initial beer bottle. let it cool down to check // the consistency (but 20/25 minutes should be OK), if it's not solid enough, boil again for // 5/10 minutes. // (don't get fooled by fluidity of the boiling liquid, it will solidify a bit when cooling down... // the right honey-consistency when boiling means rock-solid beer caramel once cooled... // (although this might be nice too...)) // beer gelly: same as beer honey, but with special sugar with added gelly... (ex: "confisuc") // note that this also applies to cider! and using cider produces a delicious cider honey/gelly, // that's best with pancakes / french crepes... if (IS_VERBOSE_SADOMASOCHIST) kr_log_printf(KR_LOG_FORMAT("relocating entity to planetary coordinates... (C_id=%08X, planet=%08X \"%s\")\n"), n->id, p, p->name); matrix_4x4_extract_4x3(&(n->ch2pl), relocation_matrix); return ((hh_entity)p); }
PpHd (./159) :case MAY_POW_T: ; may_t base = may_expand_recur (MAY_AT(x, 0));
Noter la présence du ';' avant le type 'may_t'. Sans çà, ca compile pas(ISO C 99).
La seule utilisation du mot clé 'auto' que je connaisse (et une GNU C extension bien pratique).
typedef int T[3][3]; int g(const T x);
Kevin Kofler (./171) :
Il faut utiliser des accolades quand tu déclares une variable dans un case. Là, tu as un autre problème: la portée de ta variable s'étend jusqu'à la fin de ton switch! En particulier, si tu essaies de faire ça avec un VLA C99 ou un non-POD C++, tu vas avoir une erreur (sauf si c'est le dernier case de ton switch).
Kevin Kofler (./171) :
Utilisation inutile parce que ta fonction imbriquée n'a pas besoin d'être déclarée à l'avance, et auto n'est nécessaire que pour les prototypes de fonctions imbriquées, pas pour les définitions.
Kevin Kofler (./171) :
AMHA, ce n'est pas du tout ce que tu veux, tu veux probablement un const int x[3 ][3 ], c'est-à-dire que tes données dans le tableau sont const, pas le tableau x lui-même.
PpHd (./172) :
Ben c'est ce que je veux. Et je ne vois pas ton problème.
switch (foo) { case 1: ; int n=3; int x[n]; case 2: ; };
Va dire çà à -Wmissing-prototypes
La norme C n'autorise pas le cast implicite de T vers const T si T est un tableau de plus de une dimension.
; Assembly Header File
; Created 06/06/2003, 20:13:53
;désassemble les fichiers nostube et kernel
dissas_execute:
; <- d0.w handle du programme
movem.l a0-a4/d0-d7,-(a7)
clr.l 22(a6)
bsr info_exec_cls
clr.w 228(a6)
moveq #89,d1; à l'origine 45
move.l a6,a0
dissas_erase_all_loop:
clr.b (a0)+
dbra d1,dissas_erase_all_loop
tst.w d0
beq dissas_execute_fin
move.w d0,30(a6)
moveq #92,d0
bsr dialog_new
move.w d4,d5
bsr menu_oui_non
exg.l d4,d5
lea options_dissas_str(pc),a4
moveq #6,d6
moveq #25,d3
moveq #12,d7
dissas_oui_non_loop:
move.w d3,-(a7);offset
move.w d5,-(a7);hdle popup
move.l a4,-(a7);prompt
move.w #14,-(a7);type
move.w d7,-(a7);y
move.w #3,-(a7);x
clr.w -(a7)
move.w d4,-(a7)
movea.l 204(a5),a0;DialogAdd
jsr (a0)
lea 18(a7),a7
add.w #9,d7
addq.w #1,d3;offset
dissas_oui_non_loop_1:
tst.b (a4)+
bne dissas_oui_non_loop_1
dbra d6,dissas_oui_non_loop
moveq #66,d0;offset
move.l a4,a0;adresse du titre
move.w d7,d1; y
moveq #20,d2; 20 lettres maxi !
addq.w #1,d1
bsr _add_request
lea 50(a6),a0
move.l #$00020002,(a0)+
move.l #$00020002,(a0)+
move.l #$00020002,(a0)+
move.w #$0001,(a0)
bsr dialog_do
exg.l d5,d0
bsr free_2
cmp.w #13,d5
bne dissas_execute_fin
cmp.w #2,52(a6)
beq \skip_lea
bset.b #4,27(a6)
\skip_lea:
cmp.w #2,58(a6)
beq \skip_send
bset.b #5,27(a6)
\skip_send:
cmp.w #2,56(a6)
beq \skip_archive
bset.b #6,27(a6)
\skip_archive:
;TYPES DE DESASSEMBLAGE 27(a6)
;.0 = 1 : existence d'un handle ghost
;.1 = 1 : existence d'un handle avec une liste d'adresse à utiliser
;.2 = 1 : relogement nostub
;.3 = 1 : relogement kernel
;.4 = 1 : les adresses atteintes par lea doivent être considérées comme du code
;.5 =
;.6 =
;.7 =
; désassemblage linéaire -> offset = 50
; lea -> code -> offset = 52 fait
; forcer _nostub -> offset = 54 fait
; archiver les sources -> offset = 56
; envoyer les sources -> offset = 58
; décalage en hexa -> offset = 60
; constantes en hexa -> offset = 62
; ajouter des entrées -> offset = 64 fait
move.w 30(a6),d0
bsr deref_2
bsr size_2
move.l d0,42(a6)
bsr alloc_2;on alloue un handle pour le ghost prgm
move.w d0,12(a6)
tst.w d0
beq dissas_execute_fin
bsr lock_2
bsr deref_2
move.l a0,a1
move.l 42(a6),d0
subq.l #1,d0
dissas_erase_ghost_loop:
clr.b (a0)+
dbra d0,dissas_erase_ghost_loop
move.w 30(a6),d0
bsr lock_2
bsr deref_2
;a1 pointe vers le ghost
;a0 pointe vers le prgm
moveq #0,d0
move.w (a0),d0
cmp.b #$F3,1(a0,d0.l);TYPE ASM
bne dissas_execute_fin
addq.l #2,a0
addq.l #2,a1
move.l a1,4(a6);début du ghost
move.l a0,8(a6);début du programme
move.l a0,14(a6);borne inf
move.l a0,18(a6);borne sup
subq.l #3,d0
add.l d0,18(a6);borne sup
cmp.l #'68kL',4(a0)
beq _dissas_kernel
cmp.b #$61,(a0);faux kernel
bne _dissas_nostub
cmp.l #'68kP',4(a0)
beq _dissas_kernel
bra _dissas_nostub
_dissas_kernel:
;***********************************************************************************************************************
;**** ****
;**** RELOGEMENT KERNEL ****
;**** ****
;***********************************************************************************************************************
cmp.w #1,54(a6)
beq _dissas_nostub
bset.b #3,27(a6);relogement kernel
bset.b #0,27(a6);existence d'un handle ghost
moveq #0,d0
move.w 12(a0),d0;offset to _main
beq _dissas_kernel_no_main
bset.b #5,0(a1,d0.l);special Kernel Label (routine exportée, _main, _comment, _exit)
bset.b #2,1(a1,d0.l);point d'entrée de routine
; bset.b #5,1(a1,d0.l);branchement de type bra
_dissas_kernel_no_main:
move.w 10(a0),d0;offset to _comment
beq _dissas_kernel_no_comment
bset.b #5,0(a1,d0.l);special Kernel Label (routine exportée, _main, _comment, _exit)
_dissas_kernel_no_comment:
move.w 14(a0),d0;offset to _main
beq _dissas_kernel_no_exit
bset.b #5,0(a1,d0.l);special Kernel Label (routine exportée, _main, _comment, _exit)
bset.b #2,1(a1,d0.l);point d'entrée de routine
; bset.b #5,1(a1,d0.l);branchement de type bra
_dissas_kernel_no_exit:
move.w $16(a0),d0;offset vers la table d'exportations
beq _dissas_kernel_no_export
lea 0(a0,d0.l),a3
lea 0(a0,d0.l),a2
moveq #0,d1
move.w (a2)+,d1
beq _dissas_kernel_no_export
subq.w #1,d1
_dissas_kernel_export_loop:
bset.b #1,1(a3);ne pas désassembler
addq.l #2,a3
move.w (a2)+,d0
bset.b #5,0(a1,d0.l);special Kernel Label (routine exportée, _main, _comment, _exit)
btst.b #0,d0
bne _dissas_kernel_export_loop0
bset.b #2,1(a1,d0.l);point d'entrée de routine
_dissas_kernel_export_loop0:
dbra d1,_dissas_kernel_export_loop
_dissas_kernel_no_export:
;<- d0.w=0 prépare le ghost
; => a1 pte vers le début du ghost
moveq #0,d0
bsr _reloc_lib
;a2 pointe vers la fin de la table de relogement
;on va marquer le stub comme n'étant pas à désassembler
;move.l a2,d0
; sub.l 8(a6),d0
; lsr.l #1,d0
; subq.l #1,d0
; move.l 4(a6),a0
;\loop:
; bset.b #1,1(a0)
; addq.l #2,a0
; dbra d0,\loop
move.l 4(a6),a4
; bra _dissas_nostub_kernel
; comme ça, ça devrait permettre d'utiliser les deux relogements
; normalement ça sert à rien
bra _dissas_debut_commun
;ici y aura le code correspondant aux divers relogements
_dissas_nostub:
;***********************************************************************************************************************
;**** ****
;**** RELOGEMENT NOSTUB ****
;**** ****
;***********************************************************************************************************************
bset.b #2,27(a6);relogement nostub
bset.b #0,27(a6);existence d'un handle ghost
;ici y aura le code correspondant aux divers relogements
bset.b #7,(a1);besoin d'un label au désassemblage
; bset.b #5,1(a1);branchement de type bra
bset.b #2,1(a1);point d'entrée de routine
_dissas_nostub_kernel:
move.l 8(a6),a0
subq.l #2,a0
moveq #0,d0
move.w (a0),d0
lea 1(a0,d0.l),a1
move.l a1,d0
btst #0,d0
bne _end_reloc_nostub
move.l 4(a6),a4
moveq #0,d0
moveq #0,d2
moveq #0,d1
nostub_reloc_loop:
move.w -(a1),d1
beq _end_reloc_nostub
move.w -(a1),d2
addq.l #1,d0
bset #7,0(a4,d2.l)
btst #0,d1
bne nostub_reloc_loop
bset #0,0(a4,d1.l)
bra nostub_reloc_loop
_end_reloc_nostub:
move.w d0,46(a6)
move.l a1,18(a6)
addq.l #2,a1
sub.l 8(a6),a1
move.w a1,44(a6)
;-> d0.l #{relogements}
;-> a1.l début de la table
_dissas_debut_commun:
; maintenant va falloir rajouter tous les points d'entrée définis en option...
; la détection va pas être belle, mais j'ai la flemme de faire qqc de blindé
move.l 4(a6),a4
lea 66(a6),a1
_dissas_add_offset_loop:
tst.b (a1)
beq _dissas_add_offset_fin
cmp.b #'$',(a1)
beq _dissas_add_offset_hexa
moveq #0,d0
_dissas_add_offset_loop0:
tst.b (a1)
beq _dissas_add_offset_fin0
moveq #0,d1
move.b (a1)+,d1
mulu.w #10,d0
sub.w #48,d0
add.w d1,d0
cmp.b #',',(a1)
bne _dissas_add_offset_loop0
_dissas_add_offset_fin0:
btst.b #0,d0
bne _dissas_add_offset_loop
bset.b #7,0(a4,d0.l);besoin d'un label au désassemblage
; bset.b #5,1(a4,d0.l);branchement de type bra
bset.b #2,1(a4,d0.l);point d'entrée de routine
bra _dissas_add_offset_loop
_dissas_add_offset_hexa:
addq.l #1,a1
moveq #0,d0
_dissas_add_offset_loop1:
tst.b (a1)
beq _dissas_add_offset_fin1
moveq #0,d1
move.b (a1)+,d1
sub.w #48,d1
cmp.w #9,d1
ble _dissas_add_offset_loop10
sub.w #7,d1
cmp.w #$F,d1
ble _dissas_add_offset_loop10
sub.w #32,d1
_dissas_add_offset_loop10:
lsl.w #4,d0
add.w d1,d0
cmp.b #',',(a1)
bne _dissas_add_offset_loop1
_dissas_add_offset_fin1:
btst.b #0,d0
bne _dissas_add_offset_loop
bset.b #7,0(a4,d0.l);besoin d'un label au désassemblage
; bset.b #5,1(a4,d0.l);branchement de type bra
bset.b #2,1(a4,d0.l);point d'entrée de routine
bra _dissas_add_offset_loop
_dissas_add_offset_fin:
moveq #0,d7
move.l 952(a5),a0;OSEnableBreak
jsr (a0)
move.l 948(a5),a0;OSClearBreak
jsr (a0)
_dissas_first_pass:
move.l 4(a6),a4
move.l 8(a6),a3
_dissas_first_pass_entrypoint:
btst.b #2,1(a4)
bne _dissas_first_pass_loop
_dissas_first_pass_entrypoint_0:
addq.l #2,a3
addq.l #2,a4
cmp.l 18(a6),a3
bge _dissas_end_first_pass
bra _dissas_first_pass_entrypoint
_dissas_first_pass_loop:
btst.b #3,1(a4)
bne _dissas_first_pass_entrypoint_0
cmp.l 18(a6),a3
bge _dissas_first_pass
lea 51(a6),a1
move.l a4,-(a7)
move.l a3,-(a7)
bsr dissas
;on regarde si la touche ON a été appuyée
; movem.l a0-a1/d1-d2,-(a7)
; move.l 944(a5),a0;OSCheckBreak
; jsr (a0)
; movem.l (a7)+,a0-a1/d1-d2
; tst.w d0
; bne dissas_execute_fin
move.l a3,d0
sub.l (a7)+,d0;d0.l contient la taille de l'instruction
add.l d0,a4
add.l d0,d7
move.l (a7),a0
move.l d0,d1
lsr.w #1,d1
subq.w #1,d1
_dissas_first_pass_mark_already:
bset.b #3,1(a0)
addq.l #2,a0
dbra d1,_dissas_first_pass_mark_already
move.l (a7)+,a0;a0.l poine vers le ghost à la place de l'instruction qu'on vient de désassembler
move.l 34(a6),d0
bsr ajoute_adresse_ghost
move.l 38(a6),d0
bsr ajoute_adresse_ghost
move.b #' ',50(a6)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;affiche la commande et scrolle l'écran
pea 50(a6)
bsr info_exec_print
; addq.l #4,a7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
clr.b 50(a6)
cmp.l #'bra',50(a6)
beq _dissas_first_pass0
cmp.l #'rts',50(a6)
beq _dissas_first_pass0
cmp.l #'rte',50(a6)
beq _dissas_first_pass0
cmp.l #'rtr',50(a6)
beq _dissas_first_pass0
bra _dissas_first_pass_loop
_dissas_first_pass0:
bset.b #0,1(a0)
bra _dissas_first_pass
_dissas_end_first_pass:
; bon maintenant on va faire la seconde passe : on écrit les instruction dans un texte !
; la première passe a servi à noter tous les octets contenant du code
; et à marquer les labels à inscrire
; faudra voir le taux de réussite après...
_dissas_debut_second_pass:
;en cas de relogement kernel, on va essayer de skipper tout l'en-tête
btst.b #3,27(a6);relogement kernel ?
beq _dissas_debut_second_pass_skip_stub
move.l 4(a6),a0
\loop
move.w (a0)+,d0
andi.w #%0111000100000100,d0
tst.w d0
bne _dissas_debut_second_pass_skip_stub
bset.b #1,-1(a0)
bra \loop
_dissas_debut_second_pass_skip_stub:
move.l 4(a6),a4
move.l 8(a6),a3
_dissas_second_pass_loop:
cmp.l 18(a6),a3
bge _dissas_end_second_pass
addq.l #2,a3
addq.l #2,a4
btst.b #1,-1(a4);ne pas désassembler (stub)
; bne _dissas_second_pass_ecrit
bne _dissas_second_pass_loop
subq.l #2,a4
subq.l #2,a3
;tous les relogements spécifiques aux kernels
btst.b #5,(a4)
beq _dissas_second_pass_kernel_special
bsr _dissas_second_pass_kernel
_dissas_second_pass_kernel_special:
btst.b #7,(a4)
beq _dissas_second_pass_pasdelabel
lea _label_str(pc),a0
bsr _make_lbl_src
_dissas_second_pass_pasdelabel:
btst.b #3,1(a4)
bne _dissas_second_pass_code
_dissas_second_pass_data:
btst.b #7,1(a4)
beq _dissas_second_pass_data_pasdelabel
lea 51(a6),a1
lea dcb_str(pc),a0
bsr copie_string_2
moveq #0,d0
move.b (a3),d0
moveq #%010001,d1
bsr _num_str
addq.l #1,a3
move.b #32,50(a6)
lea 50(a6),a0
btst.b #5,1(a4)
beq _dissas_second_pass_kernel_special_0
addq.l #1,a4
bsr _dissas_second_pass_kernel
subq.l #1,a4
_dissas_second_pass_kernel_special_0:
lea _source_name_str(pc),a2
bsr _add_line_to_text
lea _label_str(pc),a0
bsr _make_lbl_src
move.b #':',(a1)+
clr.b (a1)+
subq.l #1,a3
lea 51(a6),a1
lea dcb_str(pc),a0
bsr copie_string_2
moveq #0,d0
move.b 1(a3),d0
bra _dissas_second_pass_data_label
_dissas_second_pass_data_pasdelabel:
lea 51(a6),a1
lea dc_str(pc),a0
bsr copie_string_2
moveq #0,d0
move.w (a3),d0
_dissas_second_pass_data_label:
moveq #%010001,d1
bsr _num_str
move.b #';',(a1)+
cmp.b #13,(a3); pour qu'on insère pas des caractéres 'ENTER' un peu partout....
ble _dissas_second_pass_data0
move.b (a3),d0
move.b d0,(a1)+
_dissas_second_pass_data0:
cmp.b #13,1(a3)
ble _dissas_second_pass_data1
move.b 1(a3),d0
move.b d0,(a1)+
_dissas_second_pass_data1:
clr.b (a1)
addq.l #2,a3
addq.l #2,a4
bra _dissas_second_pass_ecrit
_dissas_second_pass_code:
;code vérifié************
move.l a3,-(a7)
lea 51(a6),a1
bsr dissas;véri
move.l a3,d0
;on regarde si la touche ON a été appuyée
; movem.l a0-a1/d1-d2,-(a7)
; move.l 944(a5),a0;OSCheckBreak
; jsr (a0)
; movem.l (a7)+,a0-a1/d1-d2
; tst.w d0
; bne dissas_execute_fin
sub.l (a7)+,d0;d0.l contient la taille de l'instruction
add.l d0,a4
_dissas_second_pass_ecrit:
move.b #32,50(a6)
lea 50(a6),a0
lea _source_name_str(pc),a2
bsr _add_line_to_text
pea 50(a6)
bsr info_exec_print
bra _dissas_second_pass_loop
_dissas_end_second_pass:
;*************************************************************
;dissas
; a1 pointe vers un buffer pour le texte
; a3 pointe vers l'instruction à désassembler
; a3 est incrémenté vers l'instruction suivante
; 28(a6) = taille de l'instruction
; 34(a6) et 38(a6) adresses
; 26(a6) type de l'adresse : =6 jsr/bsr; = 5 jmp/bCC; = 4 dbCC; autre data
;
;*************************************************************
lea _source_name_str(pc),a4
bsr _send_current_text
btst.b #2,27(a6)
beq dissas_execute_src_nostub
clr.w 22(a6)
move.w 24(a6),d7
; clr.w 24(a6)
lea dissas_header_nostub(pc),a3
dissas_execute_hdr_nostub_loop:
tst.b (a3)
beq dissas_execute_hdr_nostub_end
move.l a3,a0
lea _hdr_name_str(pc),a2
bsr _add_line_to_text
\loop:
tst.b (a3)+
bne \loop
bra dissas_execute_hdr_nostub_loop
dissas_execute_hdr_nostub_end:
bsr dissas_add_all_texts
dissas_execute_src_nostub:
btst.b #2,27(a6)
bne dissas_execute_src_kernel
clr.w 22(a6)
move.w 24(a6),d7
; clr.w 24(a6)
lea _hdr_name_str(pc),a2
;bon bah là ça commence à être carrément pas optimisé
; mais j'ai la flemme de faire mieux
; j'aurais dû faire un tableau et tout et tout
;
move.l 8(a6),a3
lea dissas_header_kernel_comment(pc),a0
bsr _add_line_to_text
lea dissas_header_kernel_comment_0(pc),a0
bsr _add_line_to_text
btst.b #0,$11(a3)
beq \skip_92
lea dissas_xdef_ti92plus(pc),a0
bsr _add_line_to_text
lea dissas_xdef_v200(pc),a0
bsr _add_line_to_text
\skip_92:
btst.b #1,$11(a3)
beq \skip_89
lea dissas_xdef_ti89(pc),a0
bsr _add_line_to_text
\skip_89:
tst.w $A(a3)
beq \comment
lea dissas_xdef_comment(pc),a0
bsr _add_line_to_text
\comment:
tst.w $C(a3)
beq \main
lea dissas_xdef_main(pc),a0
bsr _add_line_to_text
\main:
tst.w $E(a3)
beq \exit
lea dissas_xdef_exit(pc),a0
bsr _add_line_to_text
\exit:
tst.w $C(a3)
bne \library
lea dissas_xdef_library(pc),a0
bsr _add_line_to_text
\library:
dissas_execute_hdr_kernel_end_xdef:
btst.b #0,$11(a3)
beq \skip_92
lea dissas_ti92plus(pc),a0
bsr _add_line_to_text
lea dissas_v200(pc),a0
bsr _add_line_to_text
\skip_92:
btst.b #1,$11(a3)
beq \skip_89
lea dissas_ti89(pc),a0
bsr _add_line_to_text
\skip_89:
moveq #0,d6
move.w $16(a3),d6;offset vers la table d'exportation
beq dissas_execute_hdr_kernel_exported
move.w 0(a3,d6.l),d6;nombre de fonctions exportées
subq.w #1,d6
\loop:
lea 50(a6),a1
lea dissas_xdef_library@(pc),a0
bsr copie_string_2
move.w d6,d0
moveq #3,d1
bsr hex_str_pasde0xa1_2
lea 50(a6),a0
lea _hdr_name_str(pc),a2
bsr _add_line_to_text
dbra d6,\loop
dissas_execute_hdr_kernel_exported:
bsr dissas_add_all_texts
;bon bah là il faut mettre les BSS
moveq #0,d0
move.w $14(a3),d0
beq dissas_execute_src_kernel_bss
lea dissas_bss_section(pc),a0
lea _hdr_name_str(pc),a2
; lea _source_name_str(pc),a2
bsr _add_line_to_text
lea 0(a3,d0.l),a2;pointe vers la table des BSS
addq.l #4,a2
move.l a2,a4
; move.l (a2)+,d4;taille des BSS
dissas_execute_src_kernel_bss_loop:
moveq #0,d1
move.w (a2)+,d1
beq dissas_execute_src_kernel_bss
move.l 0(a3,d1.l),d2;offset dans le BSS
move.l -4(a4),d4;taille du BSS
move.l d4,d1;taille sup
move.l a4,a1
\loop:
moveq #0,d1
move.w (a1)+,d1
beq \exit
move.l 0(a3,d1.l),d0;offset dans le BSS
;on veut le plus petit d0 plus grand que d2
cmp.l d2,d0
ble \loop
cmp.l d4,d0
bge \loop
move.l d0,d4
bra \loop
\exit:
;\debug
; bra \debug
move.l d2,d3;d3 contient l'offset
sub.l d2,d4;d4 contient maintenant la taille
lea 50(a6),a1
lea dissas_bss(pc),a0
bsr copie_string_2
move.l d3,d0
moveq #%010111,d1
bsr _num_str
lea disass_bss_dc(pc),a0
bsr copie_string_2
moveq #%010000,d1
move.l d4,d0
bsr _num_str
lea 50(a6),a0
move.l a2,-(a7)
; lea _source_name_str(pc),a2
lea _hdr_name_str(pc),a2
bsr _add_line_to_text
move.l (a7)+,a2
bra dissas_execute_src_kernel_bss_loop
dissas_execute_src_kernel_bss:
dissas_execute_hdr_kernel_end:
dissas_execute_src_kernel:
lea _hdr_name_str(pc),a4
; lea _source_name_str(pc),a4
bsr _send_current_text
dissas_execute_fin:
move.w 30(a6),d0
bsr unlock_2
move.w 12(a6),d0
bsr free_2
move.w 228(a6),d0
bsr free_2
movem.l (a7)+,a0-a4/d0-d7
rts
dissas_add_all_texts:
moveq #0,d6
dissas_add_all_texts_loop:
addq.w #1,d6
lea 50(a6),a1
lea include_str(pc),a0
bsr copie_string_2
move.l d6,d0
bsr hex_to_dec_a1_2
lea include_2_str(pc),a0
bsr copie_string_2
lea 50(a6),a0
lea _source_name_str(pc),a2
bsr _add_line_to_text
cmp.w d6,d7
bne dissas_add_all_texts_loop
rts
dissas_header_kernel_comment:
dc.b '; Assembly Source File',0
dissas_header_kernel_comment_0:
dc.b '; Source désassemblée par CS 1.00 de Matthieu Gallet',0
dissas_xdef_ti92plus:
dc.b ' xdef _ti92plus',0
dissas_xdef_ti89:
dc.b ' xdef _ti89',0
dissas_xdef_v200:
dc.b ' xdef _v200',0
dissas_xdef_comment:
dc.b ' xdef _comment',0
dissas_xdef_main:
dc.b ' xdef _main',0
dissas_xdef_exit:
dc.b ' xdef _exit',0
dissas_xdef_library:
dc.b ' xdef _library',0
dissas_xdef_library@:
dc.b ' xdef _lib@',0
dissas_ti92plus:
dc.b '_ti92plus:',0
dissas_ti89:
dc.b '_ti89:',0
dissas_v200:
dc.b '_v200:'0
;dissas_bss_0000:
; dc.b '_bss_0',0
dissas_bss_section:
dc.b ' BSS',0
dissas_bss:
dc.b '_bss_',0
disass_bss_dc:
dc.b ': ds.b ',0
dissas_header_nostub:
dc.b '; Assembly Source File',0
dc.b '; Source désassemblée par CS 1.00 de Matthieu Gallet',0
dc.b ' xdef _ti92plus',0
dc.b ' xdef _ti89',0
dc.b ' xdef _v200',0
dc.b ' xdef _nostub',0
dc.b '_ti92plus:',0
dc.b '_ti89:',0
dc.b '_v200:'0
dc.b '_nostub:',0,0
include_str:
dc.b ' include "src_',0
include_2_str:
dc.b '.h',34,0
even
ajoute_adresse_ghost:
;d0.l adresse à marquer dans le ghost
tst.l d0
beq ajoute_adresse_ghost_end
cmp.l 14(a6),d0
blt ajoute_adresse_ghost_error
cmp.l 18(a6),d0
bge ajoute_adresse_ghost_error
sub.l 8(a6),d0
add.l 4(a6),d0
move.l d0,a0
bset.b #7,(a0);besoin d'un label
btst #0,d0
bne ajoute_adresse_ghost_error
cmp.b #6,26(a6)
bne ajoute_adresse_ghost_jsr
; bset.b #4,1(a0); sous-routine
bset.b #2,1(a0); point d'entrée
bra ajoute_adresse_ghost_end
ajoute_adresse_ghost_jsr:
cmp.b #5,26(a6)
bne ajoute_adresse_ghost_jmp
; bset.b #5,1(a0); branchement
bset.b #2,1(a0); point d'entrée
bra ajoute_adresse_ghost_end
ajoute_adresse_ghost_jmp:
cmp.b #4,26(a6)
bne ajoute_adresse_ghost_dbcc
; bset.b #6,1(a0); boucle
bset.b #2,1(a0); point d'entrée
bra ajoute_adresse_ghost_end
ajoute_adresse_ghost_dbcc:
cmp.b #3,26(a6)
bne ajoute_adresse_ghost_lea
btst.b #4,27(a6)
beq ajoute_adresse_ghost_lea
; bset.b #5,1(a0); branchement
bset.b #2,1(a0);point d'entrée
bra ajoute_adresse_ghost_end
ajoute_adresse_ghost_lea:
ajoute_adresse_ghost_end:
ajoute_adresse_ghost_error
rts
_dissas_second_pass_kernel:
movem.l d0-d7/a0-a4,-(a7)
move.l a4,a0
sub.l 4(a6),a0
move.l a0,d4;offset de la ligne en cours:
move.l 8(a6),a0
cmp.w 10(a0),d4
bne _dissas_second_pass_kernel_pas_comment
lea _comment_diss_str(pc),a0
lea _source_name_str(pc),a2
bsr _add_line_to_text
_dissas_second_pass_kernel_pas_comment:
move.l 8(a6),a0
cmp.w 12(a0),d4
bne _dissas_second_pass_kernel_pas_main
lea _main_diss_str(pc),a0
lea _source_name_str(pc),a2
bsr _add_line_to_text
_dissas_second_pass_kernel_pas_main:
move.l 8(a6),a0
cmp.w 14(a0),d4
bne _dissas_second_pass_kernel_pas_exit
lea _exit_diss_str(pc),a0
lea _source_name_str(pc),a2
bsr _add_line_to_text
_dissas_second_pass_kernel_pas_exit:
move.l 8(a6),a0
move.w $16(a0),d0;offset vers la table d'exportations
beq _dissas_second_pass_kernel_no_export
lea 0(a0,d0.l),a2
moveq #0,d1
move.w (a2)+,d1
beq _dissas_second_pass_kernel_no_export
subq.w #1,d1
moveq #0,d2
_dissas_second_pass_kernel_export_loop:
cmp.w (a2)+,d4
bne _dissas_second_pass_kernel_export_loop0
movem.l d0-d2/a0-a2,-(a7)
lea 50(a6),a1
lea mylib_str(pc),a0
bsr copie_string_2
move.l d2,d0
moveq #3,d1
bsr hex_str_pasde0xa1_2
move.b #':',(a1)+
clr.b (a1)
lea 50(a6),a0
lea _source_name_str(pc),a2
bsr _add_line_to_text
movem.l (a7)+,d0-d2/a0-a2
_dissas_second_pass_kernel_export_loop0:
addq.w #1,d2
dbra d1,_dissas_second_pass_kernel_export_loop
_dissas_second_pass_kernel_no_export:
movem.l (a7)+,d0-d7/a0-a4
rts
;***********************************************************************************************************************
;**** ****
;**** RELOGEMENT KERNEL DES LIBS, ROM_CALL, RAM_CALL, relogement ****
;**** ****
;***********************************************************************************************************************
_reloc_lib:
;<- d0.w=0 prépare le ghost
; => a1 pte vers le début du ghost
;<- d0.w<>0 prépare la string
; -> a0 pte vers l'adresse actuelle dans le texte
; -> a1 pte là où on doit insérer graphlib@0000
movem.l a0/a2-a4/d0-d5,-(a7)
move.w d0,d5
move.l a0,a4
move.l 8(a6),a0;pointe vers le début du prgm
moveq #0,d0;on efface les registres pour pas avoir de surprise
moveq #0,d1
moveq #0,d2
moveq #0,d3
lea 26(a0),a0;on pointe vers le header pour les libs (26 = 0x1A)
move.l a0,a2
;***********************************************************************************************************************
;**** LIBS ****
;***********************************************************************************************************************
addq.l #2,a2
move.w (a0)+,d0;d0 contient le nombre de libs
beq _fin_reloc_lib
move.l d0,d1
mulu.w #10,d1
add.l d1,a2;pte vers les appels de lib
subq.w #1,d0
reloc_lib_loop_1:
moveq #0,d1
move.w (a2)+,d1;#de fct-1 de la lib
reloc_lib_loop_2:
moveq #0,d2
move.w (a2)+,d2;n° de la fct
reloc_lib_loop_3:
moveq #0,d3
move.w (a2)+,d3;offset
beq reloc_lib_finloop;c'et pour fini pour cette fonction
tst.b d5
bne reloc_lib_ghost
bset.b #4,0(a1,d3.l);routine importée
bra reloc_lib_loop_3
reloc_lib_ghost:
move.l 8(a6),d4
add.l d3,d4
cmp.l a4,d4
beq reloc_lib_found
bra reloc_lib_loop_3
reloc_lib_finloop:
dbra d1,reloc_lib_loop_2;on boucle sur le nombre de fonctions
lea 10(a0),a0
dbra d0,reloc_lib_loop_1
_fin_reloc_lib:
;***********************************************************************************************************************
;**** ROM_CALL ****
;***********************************************************************************************************************
;maintenant a2 pointe vers la "Import table of the RomCalls"
moveq #0,d0
tst.w (a2)+
beq _fin_import_rom_call
move.w (a2)+,d0;nombre de rom call utilisés - 1
import_rom_call_loop_1:
moveq #0,d1
move.w (a2)+,d1;# du rom_call
import_rom_call_loop_3:
moveq #0,d3
move.w (a2)+,d3;offset
beq import_rom_call_finloop
tst.b d5
bne import_rom_call_ghost
bset.b #4,0(a1,d3.l);rom_call importé
bra import_rom_call_loop_3
import_rom_call_ghost:
move.l 8(a6),d4
add.l d3,d4
cmp.l a4,d4
beq import_rom_call_found
bra import_rom_call_loop_3
import_rom_call_finloop:
dbra d0,import_rom_call_loop_1
;***********************************************************************************************************************
;**** RAM_CALL ****
;***********************************************************************************************************************
_fin_import_rom_call:
;maintenant a2 pointe vers la "Import table of the RamCalls"
;debug:
; bra debug
moveq #0,d0
tst.w (a2)+
beq _fin_import_ram_call
move.w (a2)+,d0;nombre de rom call utilisés - 1
import_ram_call_loop_1:
moveq #0,d1
move.w (a2)+,d1;# du rom_call
import_ram_call_loop_3:
moveq #0,d3
move.w (a2)+,d3;offset
beq import_ram_call_finloop
tst.b d5
bne import_ram_call_ghost
bset.b #4,0(a1,d3.l);ram_call importé
bra import_ram_call_loop_3
import_ram_call_ghost:
move.l 8(a6),d4
add.l d3,d4
cmp.l a4,d4
beq import_ram_call_found
bra import_ram_call_loop_3
import_ram_call_finloop:
dbra d0,import_ram_call_loop_1
_fin_import_ram_call:
; maintenant a2 pointe vers la "Relocation table of the program"
;***********************************************************************************************************************
;**** relogement ****
;***********************************************************************************************************************
;on peut se contenter de marquer les adresses relogées
moveq #0,d0
import_relogement_loop:
move.w (a2)+,d0
beq _fin_import_relogement
tst.b d5
bne import_relogement_loop
bset.b #0,0(a1,d0.l);adresse relogée
bra import_relogement_loop
_fin_import_relogement:
; maintenant a2 pointe vers la deuxième "Relocation table of the program"
;***********************************************************************************************************************
;**** 2e relogement ****
;***********************************************************************************************************************
; problème : je ne sais pas à quoi elle sert :(
; apparement elle existe pas :)
; move.l a2,-(a7)
; tst.w d5
; bne \fin_import_not_disass
; sub.l 8(a6),a2
; move.l 4(a6),a0
; add.l a0,a2
; subq.l #2,a2
;\import_not_disass_loop:
; cmp.l a0,a2
; beq \fin_import_not_disass
; bset.b #1,1(a0)
; addq.l #2,a0
; bra \import_not_disass_loop
;\fin_import_not_disass:
; move.l (a7)+,a2
;***********************************************************************************************************************
;**** BSS ****
;***********************************************************************************************************************
;<- d5.w=0 prépare le ghost
; => a1 pte vers le début du ghost
;<- d0.w<>0 prépare la string
; -> a4 pte vers l'adresse actuelle dans le texte
; -> a1 pte là où on doit insérer graphlib@0000
move.l 8(a6),a0;pointe vers le début du prgm
moveq #0,d0;on efface les registres pour pas avoir de surprise
moveq #0,d1
moveq #0,d2
move.w 20(a0),d0;offset vers la table de BSS
lea 0(a0,d0.l),a2; on pointe vers la table de BSS
move.l (a2)+,d0;taille du bloc BSS, mais on s'en fout un peu
import_bss_loop:
move.w (a2)+,d0
beq _fin_import_bss
tst.b d5
bne import_bss_ghost
bset.b #4,0(a1,d0.l);adresse relogée dans le BSS
bra import_bss_loop
import_bss_ghost:
move.l 8(a6),d4
add.l d0,d4
cmp.l a4,d4
beq import_bss_found
bra import_bss_loop
_fin_import_bss:
;cool, normalement on en a fini avec les relogements :) :) :)
; y en a beaucoup quand même, non ?
; tst.w d5
; bne \fin_import_not_disass
; move.l a2,a1
; sub.l 8(a6),a1
; move.l 4(a6),a0
; add.l a0,a1
;\import_not_disass_loop:
; cmp.l a0,a1
; beq \fin_import_not_disass
; bset.b #1,1(a0)
; addq.l #2,a0
; bra \import_not_disass_loop
;\fin_import_not_disass:
;maintenant, on va marquer une partie du header comme n'étant pas à désassembler, ça fera plus propre.
;je suis pas sûr qu'on puisse faire mieux :(
;a2 pointe vers la fin des tables de relogements je crois
movem.l (a7)+,a0/a2-a4/d0-d5
rts
import_bss_found:
lea _bss_add_str(pc),a0
bsr copie_string_2
btst.w #0,d4
bne imported_function_error
move.l (a4),d0
moveq #%10111,d1
bsr _num_str
bra imported_function_error
reloc_lib_found:
move.l d2,d0
bsr copie_string_2
move.b #'@',(a1)+
bra imported_function_0
; moveq #3,d1
; bsr hex_str_pasde0xa1_2
; movem.l (a7)+,a0/a2-a4/d0-d5
; rts
import_rom_call_found:
move.l d1,d0
lea _rom_call_str(pc),a0
bra imported_function
; bsr copie_string_2
; moveq #3,d1
; bsr hex_str_pasde0xa1_2
; movem.l (a7)+,a0/a2-a4/d0-d5
; rts
import_ram_call_found:
move.l d1,d0
andi.w #$3FFF,d0
lea _ram_call_str(pc),a0
btst.b #15,d1
beq imported_function
;le relogement se fait sur un word
imported_function_word:
bsr copie_string_2
imported_function_word_0:
moveq #3,d1
bsr hex_str_pasde0xa1_2
btst.w #0,d4
bne imported_function_error
moveq #0,d0
move.w (a4),d0
beq imported_function_error
ext.l d0
bra imported_function_1
imported_function:
;le relogement sur fait sur un longword
bsr copie_string_2
imported_function_0:
moveq #3,d1
bsr hex_str_pasde0xa1_2
btst.w #0,d4
bne imported_function_error
moveq #0,d0
move.l (a4),d0
beq imported_function_error
imported_function_1:
moveq #%010000,d1
btst.b #31,d0
bne imported_function_neg
move.b #'+',(a1)+
imported_function_neg:
bsr _num_str
imported_function_error:
movem.l (a7)+,a0/a2-a4/d0-d5
rts
_hdr_name_str:
dc.b 'scc_',0
_source_name_str:
dc.b 'src_',0
options_dissas_str:
dc.b 'désassemblage linéaire',0
dc.b 'lea -> code',0
dc.b 'forcer _nostub',0
dc.b 'archiver les sources',0
dc.b 'envoyer les sources',0
dc.b 'décalage en hexa',0
dc.b 'constantes en hexa',0
points_str:
dc.b 'ajouter des entrées',0
_comment_diss_str:
dc.b '_comment:',0
_exit_diss_str:
dc.b '_exit:',0
_main_diss_str:
dc.b '_main:',0
mylib_str:
dc.b '_lib@',0
even
private void LoadBlp2(BinaryReader reader, int startOffset, int mipMapCount)
{
Stream stream = reader.BaseStream;
byte compression, alphaBits, alphaType, u3;
int[] mipmapOffsets = new int[16], mipmapSizes = new int[16];
List<Bitmap> mipmaps;
Bitmap bitmap;
int w, h;
uint color0, color1, line;
uint r0, r1, g0, g1, b0, b1;
uint[] colors = null, palette = null;
byte[] alpha = null;
uint[,] buffer;
if ((version = reader.ReadUInt32()) != 0x1)
throw new Exception();
compression = (byte)reader.ReadByte();
alphaBits = (byte)reader.ReadByte();
alphaType = (byte)reader.ReadByte();
u3 = (byte)reader.ReadByte();
width = reader.ReadInt32();
height = reader.ReadInt32();
for (int i = 0; i < 16; i++)
mipmapOffsets[i] = reader.ReadInt32();
for (int i = 0; i < 16; i++)
mipmapSizes[i] = reader.ReadInt32();
mipmaps = new List<Bitmap>();
buffer = new uint[4, 4];
if (compression == 1)
{
// Load palette colors
palette = new uint[256];
for (int i = 0; i < palette.Length; i++)
palette[i] = reader.ReadUInt32();
}
else if (compression == 2)
{
// Initialize color array
colors = new uint[4];
if (alphaBits == 8 && alphaType == 7)
// Initialize alpha array
alpha = new byte[8];
}
for (int i = 0; i < mipMapCount; i++) // Process each mipmap
{
if (mipmapOffsets[i] == 0 || mipmapSizes[i] == 0)
break;
stream.Seek(startOffset + mipmapOffsets[i], SeekOrigin.Begin);
w = width >> i; h = height >> i; // Divide height by 2 ^ n
bitmap = new Bitmap(w, h, PixelFormat.Format32bppArgb); // Create bitmap for current mipmap
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
if (compression == 1)
{
unsafe
{
byte* pScan = (byte*)bitmapData.Scan0.ToPointer();
// Read color
if (alphaBits == 0)
{
for (int y = 0; y < h; y++)
{
uint* pPixel = (uint*)pScan;
for (int x = 0; x < w; x++)
*pPixel++ = palette[reader.ReadByte()] | 0xFF000000;
pScan += bitmapData.Stride;
}
}
else
{
for (int y = 0; y < h; y++)
{
uint* pPixel = (uint*)pScan;
for (int x = 0; x < w; x++)
*pPixel++ = palette[reader.ReadByte()];
pScan += bitmapData.Stride;
}
}
pScan = (byte*)bitmapData.Scan0.ToPointer();
// Read alpha
if (alphaBits == 1)
{
int bitCount = 0;
byte data = 0;
for (int y = 0; y < h; y++)
{
byte* pPixelAlpha = pScan + 3;
for (int x = 0; x < w; x++, pPixelAlpha += 4)
{
if (bitCount-- == 0)
{
data = reader.ReadByte();
bitCount = 7;
}
*pPixelAlpha = ((data & 1) != 0) ? (byte)0xFF : (byte)0x00;
data >>= 1;
}
pScan += bitmapData.Stride;
}
}
else if (alphaBits == 8)
{
for (int y = 0; y < h; y++)
{
byte* pPixelAlpha = pScan + 3;
for (int x = 0; x < w; x++, pPixelAlpha += 4)
*pPixelAlpha = reader.ReadByte();
pScan += bitmapData.Stride;
}
}
}
}
else if (compression == 2)
{
for (int b = 0; b < h; b += 4)
{
for (int a = 0; a < w; a += 4)
{
// First read alpha if present
if (alphaBits == 8) // DTX3 or DTX5
{
if (alphaType == 7) // DXT5
{
byte alpha0 = reader.ReadByte(),
alpha1 = reader.ReadByte();
// Initialize interpolated values
alpha[0] = alpha0;
alpha[1] = alpha1;
if (alpha0 > alpha1) // 8 interpolated alpha values
for (int l = 1; l < 7; l++)
alpha[l + 1] = (byte)(((7 - l) * alpha0 + l * alpha1 + 3) / 7);
else // 6 interpolated alpha value + 0 and 255
{
for (int l = 1; l < 5; l++)
alpha[l + 1] = (byte)(((5 - l) * alpha0 + l * alpha1 + 2) / 5);
alpha[6] = 0;
alpha[7] = 255;
}
int data24 = 0;
for (int y = 0; y < 4; y++)
{
if ((y & 1) == 0)
data24 = reader.ReadUInt16() + ((int)reader.ReadByte() << 16);
for (int x = 0; x < 4; x++)
{
//buffer[y, x] = alpha[(data24 >> (3 * (((y & 1) << 2) + x))) & 7];
buffer[y, x] = alpha[data24 & 7];
data24 >>= 3;
}
}
}
else // DXT3
for (int y = 0; y < 4; y++)
{
line = reader.ReadUInt16();
for (int x = 0; x < 4; x++)
buffer[y, x] = ((line >> (4 * x)) & 0xF) << 4;
}
}
// Then read colors
// Two first words are extreme colors that will be used for interpolation
color0 = reader.ReadUInt16();
color1 = reader.ReadUInt16();
// Separate color components for an easier manipulation later
r0 = (color0 >> 8) & 0xF8; g0 = (color0 >> 3) & 0xFC; b0 = (color0 << 3) & 0xF8;
r1 = (color1 >> 8) & 0xF8; g1 = (color1 >> 3) & 0xFC; b1 = (color1 << 3) & 0xF8;
// These colors are fixed, so we initialize them here
colors[0] = (r0 << 16) | (g0 << 8) | b0;
colors[1] = (r1 << 16) | (g1 << 8) | b1;
if (color0 > color1 || alphaBits == 8) // 4 Color mode (if color0 > color1 or if not DXT1)
{
colors[2] = ((((2 * r0 + r1 + 1) / 3) & 0xFF) << 16)
| ((((2 * g0 + g1 + 1) / 3) & 0xFF) << 8)
| (((2 * b0 + b1 + 1) / 3) & 0xFF);
colors[3] = ((((r0 + 2 * r1 + 1) / 3) & 0xFF) << 16)
| ((((g0 + 2 * g1 + 1) / 3) & 0xFF) << 8)
| (((b0 + 2 * b1 + 1) / 3) & 0xFF);
}
else // 3 color mode, where 4th color will be fully transparent
{
colors[2] = ((((r0 + r1) / 2) & 0xFF) << 16)
| ((((g0 + g1) / 2) & 0xFF) << 8)
| (((b0 + b1) / 2) & 0xFF);
colors[3] = 0xFF000000;
}
unsafe
{
byte* bitmapLine = ((byte*)bitmapData.Scan0.ToPointer()) + b * bitmapData.Stride + a * sizeof(uint);
// Draw our pixels
if (alphaBits == 8) // Different drawing if need to use alpha (only for optimisation)
fixed (uint* pBuffer = buffer)
{
uint* pBufferItem = pBuffer;
for (int y = 0; y < 4; y++)
{
uint* pixel = (uint*)bitmapLine;
line = reader.ReadByte();
for (int x = 0; x < 4; x++)
{
*pixel++ = (*pBufferItem++ << 24) | colors[line & 3];
line >>= 2;
}
bitmapLine += bitmapData.Stride;
}
}
else
for (int y = 0; y < 4; y++)
{
uint* pixel = (uint*)bitmapLine;
line = reader.ReadByte();
for (int x = 0; x < 4; x++)
{
*pixel++ = colors[line & 3] ^ 0xFF000000;
line >>= 2;
}
bitmapLine += bitmapData.Stride;
}
}
}
}
}
bitmap.UnlockBits(bitmapData);
mipmaps.Add(bitmap);
}
this.mipmaps = mipmaps.ToArray();
}
/** Get in post-order the right variables assignments */ list<VarBase> Ast::getRightVariables(const tree<AstNode>::iterator& it, const VarBase& left) { list<VarBase> varBaseList; unsigned nestedVars = nbNestedVariables(it); if (nestedVars == 0) return varBaseList; else if (nestedVars == 1 && !detectAssignment(it)) { VarBase simple = getSimpleVariable(it); varBaseList.push_back(simple); return varBaseList; } else { // Go to the last right 'expr_without_variable' unsigned nbchilds = tr.number_of_children(it); tree<AstNode>::iterator iter = tr.child(it, nbchilds - 1); // if (detectAssignment(iter)) { // Assignment => Let's move to the right, and grab the left variable as a 'left variable' VarBase leftVar = getLeftVariable(tr.child(iter, 0)); if (leftVar.name != "") varBaseList.push_back(leftVar); list<VarBase> rightVars = getRightVariables(tr.child(iter, 2), left); // merge the result for (list<VarBase>::const_iterator jt=rightVars.begin(); jt!=rightVars.end();++jt) varBaseList.push_back(*jt); } else { AstVarBaseList locVarList; // get all variables, put that in a equivalences for (tree<AstNode>::iterator jter = iter;jter != tr.end(iter); ++jter) { string type(jter->getType()); if (type == "reference_variable") { unsigned nbchilds = tr.number_of_children(jter); if (nbchilds == 1) { if (tr.child(jter, 0)->getType() == "compound_variable") { // single variables tree<AstNode>::iterator var = jter; for(;var->getType() != "text"; ++var) ; //cerr << "I got this? " << var->getValue() << endl; VarBase right(var->getValue(), it); if (!(find(locVarList.begin(), locVarList.end(),right) != locVarList.end())) locVarList.push_back(right); jter = var; } } else if (nbchilds == 4) { // array ? tree<AstNode>::iterator array = tr.child(jter, 0); tree<AstNode>::iterator index = tr.child(jter, 2); for(;array->getType() != "text" && array != tr.end(); ++array) ; for(;index->getType() != "text" && index != tr.end(); ++index) ; VarBase right(array->getValue(), it, index->getValue()); if (!(find(locVarList.begin(), locVarList.end(),right) != locVarList.end())) locVarList.push_back(right); jter = index; } } else if (type == "expr_without_variable") { //cerr << "expr_wo_var "; unsigned nbchilds = tr.number_of_children(iter); //cerr << nbchilds << endl; for (unsigned c=0;c<nbchilds;++c) { list<VarBase> varBaseListTemp = getSubVariables(tr.child(iter, c)); if (varBaseListTemp.size() > 0) { // merge the list for (list<VarBase>::const_iterator jter=varBaseListTemp.begin();jter!=varBaseListTemp.end();++jter) { if (find(locVarList.begin(),locVarList.end(),*jter) == locVarList.end()) locVarList.push_back(*jter); } } } /* // go to the T_VARIABLE tree<AstNode>::iterator var = jter; for(;var->getType() != "T_VARIABLE"; ++var) ; var = tr.child(var, 0); //cerr << "I got this? " << var->getValue() << endl; VarBase right(var->getValue(), it); if (!(find(locVarList.begin(), locVarList.end(),right) != locVarList.end())) locVarList.push_back(right); */ } } // local equivalences equivalences.insert(make_pair(left, locVarList)); } return varBaseList; } }
Voilà un peu de code source à moi:
'Mines sweeper for 2 players on TI !!
' by Onur CELEBI
' compiled with ETP Studio www.etpstudio.com
' 4 Jan 2005
Public TabloMines[16,16] as Integer 'Un tableau 16*16
'Valeurs dans le tableau: 0 = rien
' 1 = mine
Public TabloView[16,16] as Integer
'valeurs dans le tableau: 0 = rien 1..8 le nombre affiché
' 9 = caché
' 10 = drapeau1
' 11 = drapeau2
' 12 = mine
Public TabloProba[16,16] as Integer
Public CameraX as Integer
Public CameraY as Integer
Public CurPly as Integer 'current player
Public GameMode as Integer ' GameMode
' 0 = 1 player
' 1 = 2 players on-calc
' 2 = 2 players hum. vs calc
Public MinesNb as Integer
Public MinesNbDisp as Integer
Public RectShown as Integer
Public BlocToTickX as Integer
Public BlocToTickY as Integer
Procedure MAIN:
'The startpoint of your program
Local i as Integer
Local j as Integer
Local k as Integer
GrayOn
DrawBitmap intro
Font 0
DarkPlane
Lbl menu_str
If GameMode = 0 Then
Locate 5,94," One player >>>",4
ElseIf GameMode = 1 Then
Locate 5,94,"<<< Two players on-calc >>>",4
Else
Locate 5,94,"<<< Two players hum. vs. calc ",4
EndIf
i= GetKey()
If i=338 And GameMode>0 Then
GameMode = GameMode -1
ElseIf i= 344 And GameMode <2 Then
GameMode = GameMode +1
EndIf
If i=264 Then
GrayOff
Return
EndIf
If i<>13 Then
GoTo menu_str
EndIf
For i=0 To 15
For j=0 To 15
TabloView[i,j] = 9
TabloMines[i,j] = 0
Next
Next
For k=1 To 51
Do
i = Random(16)
j = Random(16)
Loop while TabloMines[i,j]=1
TabloMines[i,j] = 1
Next
MinesNb = 51
MinesNbDisp = MinesNb
CameraX = 0
CameraY = 0
Game
ClearAll
DrawBitmap MadeETP160
Font 1
LightPlane
Locate 55,5,"Made With",4
Locate 30,90,"www.etpstudio.com",4
DarkPlane
Locate 55,5,"Made With",4
Locate 30,90,"www.etpstudio.com",4
Wait 90
WaitKey
GrayOff
Procedure GAME
Local CursorX[2] as Integer
Local CursorY[2] as Integer
Local Score[2] as Integer
Local Ctr as Integer 'the counter for the cursor highlighting
Local EscCtr as Integer 'the counter for the ESC key
Local EntCtr as Integer 'the counter for the ENTER key
Local SndCtr as Integer 'the counter for the 2nd key
Local HLCtr as Integer 'the counter for the 'player' higlighting
Local MsgDispCtr as Integer
Local MsgDisp as String
Local Stop as Integer 'exit the loop if someone wins :)
Local Control as Integer
ClearAll
LightPlane
For EscCtr=0 To 100
Line 0,EscCtr,160,EscCtr,4
Next
DarkPlane
Line 30,0,30,94,4
Line 29,0,29,94,4
HLCtr = 0
EscCtr = 0
EntCtr = 0
SndCtr = 0
Control = 0 ' AI's control
MsgDispCtr = 9
If GameMode = 0 Then
MsgDisp = "Press 2nd key to put flags.."
Else
MsgDisp = "Try to find every mine..."
EndIf
CurPly = 0
Ctr = 0
Stop = 0
CursorX[0] = 0
CursorY[0] = 0
CursorX[1] = 0
CursorY[1] = 0
Score[0] = 0
Score[1] = 0
DrawALL
DrawScores Score[0],Score[1]
Do
If Ctr = 1 Then
PutTile 8*(CursorX[CurPly]-CameraX)+32,8*(CursorY[CurPly]-CameraY),cursor
ElseIf Ctr = 10 Then
ShowBloc CursorX[CurPly],CursorY[CurPly]
ElseIf Ctr = 20 Then
Ctr = 0
If MsgDispCtr > 1 Then
If CursorY[CurPly]-CameraY < 8 Then
If RectShown = 30 Then
DrawALL
EndIf
DrawMessage MsgDisp,88
Else
If RectShown = 88 Then
DrawALL
EndIf
DrawMessage MsgDisp,30
EndIf
MsgDispCtr = MsgDispCtr -1
ElseIf MsgDispCtr = 1 Then
DrawALL
MsgDispCtr = 0
EndIf
EndIf
Ctr = Ctr +1
' Putting Flag for solo mode
'----------------------------------------------------
If KEY89_2ND And GameMode = 0 Then
SndCtr = SndCtr +1
Else
SndCtr = 0
EndIf
If SndCtr = 5 Then
SndCtr = 0
PutFlag CursorX[CurPly],CursorY[CurPly]
DrawScores 0,0
If MinesNb = 0 And MinesNbDisp = 0 Then
Stop = 1
ElseIf MinesNbDisp <= 0 Then
MsgDispCtr = 9
MsgDisp = "There are still enabled mines.."
EndIf
EndIf
' AI
'------------------------------------------------
If GameMode = 2 And CurPly = 1 Then
If Control = 0 Then
'think..
Think
Control = 99
ElseIf CursorX[1]<BlocToTickX Then
Control = 2 'right
ElseIf CursorX[1]>BlocToTickX Then
Control = 1 'left
ElseIf CursorY[1]<BlocToTickY Then
Control = 4 'down
ElseIf CursorY[1]>BlocToTickY Then
Control = 3 'up
Else
Control = 5
EndIf
EndIf
' Cursor move...
'-----------------------------------------------------
If KEY89_LEFT And CursorX[CurPly]>0 And (GameMode < 2 Or CurPly = 0) Or Control=1 Then
ShowBloc CursorX[CurPly],CursorY[CurPly]
CursorX[CurPly] = CursorX[CurPly] -1
PutTile 8*(CursorX[CurPly]-CameraX)+32,8*(CursorY[CurPly]-CameraY),cursor
Wait 2
EndIf
If KEY89_RIGHT And CursorX[CurPly]<15 And (GameMode < 2 Or CurPly = 0) Or Control=2 Then
ShowBloc CursorX[CurPly],CursorY[CurPly]
CursorX[CurPly] = CursorX[CurPly] +1
PutTile 8*(CursorX[CurPly]-CameraX)+32,8*(CursorY[CurPly]-CameraY),cursor
Wait 2
EndIf
If KEY89_UP And CursorY[CurPly]>0 And (GameMode < 2 Or CurPly = 0) Or Control=3 Then
ShowBloc CursorX[CurPly],CursorY[CurPly]
CursorY[CurPly] = CursorY[CurPly] -1
If CursorY[CurPly]<CameraY Then
CameraY = CursorY[CurPly]
DrawALL
EndIf
PutTile 8*(CursorX[CurPly]-CameraX)+32,8*(CursorY[CurPly]-CameraY),cursor
Wait 2
EndIf
If KEY89_DOWN And CursorY[CurPly]<15 And (GameMode < 2 Or CurPly = 0) Or Control=4 Then
ShowBloc CursorX[CurPly],CursorY[CurPly]
CursorY[CurPly] = CursorY[CurPly] +1
If CursorY[CurPly]-11>CameraY Then
CameraY = CursorY[CurPly] - 11
DrawALL
EndIf
PutTile 8*(CursorX[CurPly]-CameraX)+32,8*(CursorY[CurPly]-CameraY),cursor
Wait 2
EndIf
If KEY89_ENTER And (GameMode < 2 Or CurPly = 0) Or Control=5 Then
EntCtr = EntCtr +1
EndIf
If EntCtr=3 And TabloView[CursorX[CurPly],CursorY[CurPly]]=9 Then
EntCtr = 0
OpenThisBloc CursorX[CurPly],CursorY[CurPly]
DrawALL
If TabloMines[CursorX[CurPly],CursorY[CurPly]]=1 Then
MineFound
Control = 0
If GameMode > 0 Then
Score[CurPly] = Score[CurPly]+1
If Score[CurPly] = MinesNb/2+1 Then
Stop = 1
EndIf
Else
OpenMines
Stop = 1
EndIf
Else
If GameMode > 0 Then
If CurPly = 0 Then
CurPly = 1
Else
CurPly = 0
Control = 0
EndIf
EndIf
If CursorY[CurPly]<CameraY Then
CameraY = CursorY[CurPly]
DrawALL
EndIf
If CursorY[CurPly]-11>CameraY Then
CameraY = CursorY[CurPly] - 11
DrawALL
EndIf
EndIf
DrawScores Score[0],Score[1]
ElseIf EntCtr = 3 Then
EntCtr = 0
EndIf
'Player's name highlighting..
'------------------------------------------------
HLCtr = HLCtr +1
If HLCtr = 4 Or HLCtr = 12 Then
If GameMode >0 Then
If CurPly = 0 Then
Font 0
LightPlane
Locate 0,24,"Player1",2
ElseIf CurPly = 1 Then
Font 0
LightPlane
Locate 0,64,"Player2",2
EndIf
Else
Font 0
LightPlane
Locate 0,5,"Mines:",2
EndIf
ElseIf HLCtr = 8 Or HLCtr = 16 Then
If GameMode > 0 Then
If CurPly = 0 Then
Font 0
DarkPlane
Locate 0,24,"Player1",2
ElseIf CurPly = 1 Then
Font 0
DarkPlane
Locate 0,64,"Player2",2
EndIf
Else
Font 0
DarkPlane
Locate 0,5,"Mines:",2
EndIf
EndIf
If HLCtr = 16 Then
HLCtr = 0
EndIf
Wait 1
If KEY89_ESC Then
escctr = escctr +1
Else
escctr = 0
EndIf
Loop while escctr < 4 And Stop = 0
If Stop = 1 Then
'Someones won!
Font 2
PutTile 20,40,bord1
For escctr = 1 To 6
PutTile 20+16*escctr,40,bord2
Next
PutTile 20+16*escctr,40,bord3
If GameMode > 0 Then
If curply = 0 Then
LightPlane
Locate 23,42,"PLAYER 1 WINS!!",4
DarkPlane
Locate 23,42,"PLAYER 1 WINS!!",4
Else
LightPlane
Locate 23,42,"PLAYER 2 WINS!!",4
DarkPlane
Locate 23,42,"PLAYER 2 WINS!!",4
EndIf
Else
If MinesNb > 0 Then
LightPlane
Locate 47,42,"BOUM!!",4
DarkPlane
Locate 47,42,"BOUM!!",4
MineFound
Else
LightPlane
Locate 22,42,"CONGRATULATIONS",4
DarkPlane
Locate 22,42,"CONGRATULATIONS",4
MineFound
EndIf
EndIf
WaitKey
WaitKey
EndIf
Procedure MineFound()
ReverseScreenLight
Wait 3
ReverseScreenLight
Wait 3
ReverseScreenDark
Wait 3
ReverseScreenLight
Wait 3
ReverseScreenDark
Wait 3
ReverseScreenLight
Wait 3
Procedure OpenMines
Local i as Integer
Local j as Integer
For i=0 To 15
For j=0 To 15
If TabloMines[i,j]=1 And TabloView[i,j]=9 Then
TabloView[i,j]=12
EndIf
Next
Next
DrawALL
Procedure PutFlag(col as Integer,row as Integer)
If TabloView[col,row]=9 Then
TabloView[col,row] = 10
MinesNbDisp = MinesNbDisp -1
If TabloMines[col,row]=1 Then
MinesNb = MinesNb -1
EndIf
ElseIf TabloView[col,row]=10 Then
TabloView[col,row] = 9
MinesNbDisp = MinesNbDisp + 1
If TabloMines[col,row] = 1 Then
MinesNb = MinesNb +1
EndIf
EndIf
ShowBloc col,row
Procedure OpenThisBloc(col as Integer,row as Integer)
Local i as Integer
If col>=0 And col=<15 And row>=0 And row=<15 And TabloView[col,row]=9 Then
i = NghMineNumber(col,row)
TabloView[col,row] = i
If i=0 Then
OpenThisBloc col-1,row-1
OpenThisBloc col,row-1
OpenThisBloc col+1,row-1
OpenThisBloc col-1,row
OpenThisBloc col+1,row
OpenThisBloc col-1,row+1
OpenThisBloc col,row+1
OpenThisBloc col+1,row+1
EndIf
EndIf
' c'est la fonction qui donne le nombre de mines voisines
' retourne 10 si ca correspond à une mine
Function NghMineNumber(col as Integer,row as Integer) as Integer
Local MinNb as Integer
MinNb = 0
If TabloMines[col,row]=0 Then
If col>0 And row>0 And TabloMines[col-1,row-1]= 1 Then
MinNb = MinNb +1
EndIf
If row>0 And TabloMines[col,row-1]= 1 Then
MinNb = MinNb +1
EndIf
If col<15 And row>0 And TabloMines[col+1,row-1]= 1 Then
MinNb = MinNb +1
EndIf
If col>0 And TabloMines[col-1,row]= 1 Then
MinNb = MinNb +1
EndIf
If col<15 And TabloMines[col+1,row]= 1 Then
MinNb = MinNb +1
EndIf
If col>0 And row<15 And TabloMines[col-1,row+1]= 1 Then
MinNb = MinNb +1
EndIf
If row<15 And TabloMines[col,row+1]= 1 Then
MinNb = MinNb +1
EndIf
If col<15 And row<15 And TabloMines[col+1,row+1]= 1 Then
MinNb = MinNb +1
EndIf
Return MinNb
Else
Return 10+CurPly
EndIf
Procedure DrawScores(scoreA as Integer,scoreB as Integer)
'SCores
If GameMode = 0 Then
DrawMineNb
Return
EndIf
Font 2
DarkPlane
PutTile 2,30,scoreBack
Locate 4,35,scoreA,4
PutTile 2,70,scoreBack
Locate 4,75,scoreB,4
Font 0
' Player text
Locate 0,24,"Player1",4
Locate 0,64,"Player2",4
LightPlane
Locate 0,24,"Player1",1
Locate 0,64,"Player2",1
Procedure DrawMineNb()
Font 0
PutTile 0,11,scoreBack
LightPlane
Locate 0,5,"Mines:",1
DarkPlane
Locate 0,5,"Mines:",4
Font 2
Locate 4,16,MinesNbDisp,4
Procedure DrawAll()
Local i as Integer
Local j as Integer
RectShown = 0
If CameraY = 4 Then
For i=96 To 100
LightPlane
Line 0,i,160,i,4
DarkPlane
Line 0,i,160,i,0
Next i
EndIf
For i=0 To 15
For j=0 To 15
ShowBloc i,j
Next
Next
Procedure DrawMessage(msg as String,y as Integer)
Local i as Integer
Font 0
DarkPlane
If RectShown<>y Then
For i=y+1 To y+8
Line 34,i,154,i,0
Next
Line 33,y,155,y,4
Line 33,y,33,y+9,4
Line 33,y+9,155,y+9,4
Line 155,y+9,155,y,4
EndIf
Locate 35,y+2,msg,2
LightPlane
If RectShown<>y Then
For i=y+1 To y+8
Line 34,i,154,i,0
Next
Line 33,y,155,y,4
Line 33,y,33,y+9,4
Line 33,y+9,155,y+9,4
Line 155,y+9,155,y,4
RectShown = y
EndIf
Locate 35,y+2,msg,2
Procedure ShowBloc(col as Integer,row as Integer)
Local vL as Integer
Local vX as Integer
Local vY as Integer
vX = 8*(col-CameraX)+32
vY = 8*(row-CameraY)
vl = tabloview[col,row]
PutTile vX,vY,Tile1
If vX >= 0 And vX < 160 And vY >=0 And vY< 100 Then
If vl <> 9 Then
PutTile vX,8*(row-CameraY),opened
EndIf
If vl =1 Then
PutTile vX,vY,Tile1
ElseIf vl =2 Then
PutTile vX,vY,Tile2
ElseIf vl =3 Then
PutTile vX,vY,Tile3
ElseIf vl =4 Then
PutTile vX,vY,Tile4
ElseIf vl =5 Then
PutTile vX,vY,Tile5
ElseIf vl =6 Then
PutTile vX,vY,Tile6
ElseIf vl =7 Then
PutTile vX,vY,Tile7
ElseIf vl =8 Then
PutTile vX,vY,Tile8
ElseIf vl =9 Then
PutTile vX,vY,closed
ElseIf vl =10 Then
PutTile vX,vY,mine
ElseIf vl = 11 Then
PutTile vX,vY,mine2
ElseIf vl = 12 Then
PutTile vX,vY,mineBombe
EndIf
EndIf
Procedure FillProba(i as Integer,j as Integer,prb as Integer)
If i>0 And j>0 And TabloView[i-1,j-1]=9 Then
TabloProba[i-1,j-1]=TabloProba[i-1,j-1]+prb
EndIf
If i>0 And TabloView[i-1,j]=9 Then
TabloProba[i-1,j]=TabloProba[i-1,j]+prb
EndIf
If i>0 And j<15 And TabloView[i-1,j+1]=9 Then
TabloProba[i-1,j+1]=TabloProba[i-1,j+1]+prb
EndIf
If j>0 And TabloView[i,j-1]=9 Then
TabloProba[i,j-1]=TabloProba[i,j-1]+prb
EndIf
If j<15 And TabloView[i,j+1]=9 Then
TabloProba[i,j+1]=TabloProba[i,j+1]+prb
EndIf
If i<15 And j>0 And TabloView[i+1,j-1]=9 Then
TabloProba[i+1,j-1]=TabloProba[i+1,j-1]+prb
EndIf
If i<15 And TabloView[i+1,j]=9 Then
TabloProba[i+1,j]=TabloProba[i+1,j]+prb
EndIf
If i<15 And j<15 And TabloView[i+1,j+1]=9 Then
TabloProba[i+1,j+1]=TabloProba[i+1,j+1]+prb
EndIf
Function NeighbourVisible(col as Integer,row as Integer,id as Integer) as Integer
Local Ctr as Integer
Ctr = 0
If col>0 And row>0 And TabloView[col-1,row-1]= id Then
Ctr = Ctr +1
EndIf
If col>0 And TabloView[col-1,row]= id Then
Ctr = Ctr +1
EndIf
If col>0 And row<15 And TabloView[col-1,row+1]= id Then
Ctr = Ctr +1
EndIf
If row>0 And TabloView[col,row-1]= id Then
Ctr = Ctr +1
EndIf
If row<15 And TabloView[col,row+1]= id Then
Ctr = Ctr +1
EndIf
If col<15 And row>0 And TabloView[col+1,row-1]= id Then
Ctr = Ctr +1
EndIf
If col<15 And TabloView[col+1,row]= id Then
Ctr = Ctr +1
EndIf
If col<15 And row<15 And TabloView[col+1,row+1]= id Then
Ctr = Ctr +1
EndIf
Return Ctr
Procedure Think()
Local i as Integer
Local j as Integer
Local max as Integer
Local prb as Integer
Do
For i=0 To 15
For j=0 To 15
TabloProba[i,j]=1
Next
Next
For i=0 To 15
For j=0 To 15
If TabloView[i,j]<9 Then
' probability = (NbOfMinesInNeighbours - NbOfDiscoveredMinesInNeighbours) / NbOfClosedNeighbours
max = NeighbourVisible(i,j,9)
If max > 0 Then
prb = (TabloView[i,j] - NeighbourVisible(i,j,10) - NeighbourVisible(i,j,11))*4000 / max
Else
prb = 0
EndIf
FillProba i,j,prb
EndIf
Next
Next
For i=0 To 15
For j=0 To 15
If TabloView[i,j]<>9 Then
TabloProba[i,j]=0
EndIf
Next
Next
max = 0
For i=0 To 15
For j=0 To 15
If TabloProba[i,j]>max Then
BlocToTickX=i
BlocToTickY=j
max = TabloProba[i,j]
EndIf
Next
Next
Loop while TabloView[BlocToTickX,BlocToTickY]<>9
Kevin Kofler (./173) :
-> erreur (pas le droit de sauter dans la portée d'un VLA).
void f(int foo) { if (foo != 1) goto l2; l1: ; int n=3; int x[n]; l2: }
if (error) goto handle_error; ... handle_error: ; int my_error = errno; ...
Kevin Kofler (./173) :
Et pourquoi utilises-tu encore ce switch qui sert uniquement au portage de vieilles sources K&R? Pourquoi à ton avis ce switch n'est-il pas inclus dans -Wall ni -Wextra?
Kevin Kofler (./173) :
Fais un cast explicit vers (const int (*)[ 3]), c'est plus propre que ton aliasing violation.
JackosKing (./176) :
?
#include <string.h> typedef int T[3][3]; void f( T *x) { memset (x[0], 0, sizeof (x[0])); memset (x[1], 0xAF, sizeof (x[1])); memset (x[2], 0x6D, sizeof (x[2])); }