#include "SettingManager.h" #include static GsDOBJ2 Setting[5][900]; // Contains the geometric primitives static GsCOORDINATE2 coordinates[900]; // Unluckily the coordinates can not be allocated in the heap static short Flags[900]; // Is true if this is a multi-component object (wall, box) static int NumberOfObjects; // Total number of objects static short References[30][30]; // Object references static short ObjectTypes[30][30]; // Type of object positioned here (see level manager) int NoWall(unsigned short xpos,unsigned short ypos) { return (ObjectTypes[xpos][ypos]!=3); } void Unify(unsigned short xpos,unsigned short ypos) { int i; if ((xpos<30)&&(ypos<30)) { if (ObjectTypes[xpos][ypos]==3) { for(i=0;i<5;i++) Setting[i][References[xpos][ypos]].attribute= (Setting[i][References[xpos][ypos]].attribute)&(~(3<<9)); } else if ((ObjectTypes[xpos][ypos]==1)||(ObjectTypes[xpos][ypos]==2)) { Setting[0][References[xpos][ypos]].attribute= (Setting[0][References[xpos][ypos]].attribute)&(~(3<<9)); } } } void Subdivide(unsigned short xpos,unsigned short ypos) { int i; if ((xpos<30)&&(ypos<30)) { if (ObjectTypes[xpos][ypos]==3) { for(i=0;i<5;i++) Setting[i][References[xpos][ypos]].attribute= (Setting[i][References[xpos][ypos]].attribute)|(2<<9); } else if ((ObjectTypes[xpos][ypos]==1)||(ObjectTypes[xpos][ypos]==2)) { Setting[0][References[xpos][ypos]].attribute= (Setting[0][References[xpos][ypos]].attribute)|(2<<9); } } } void RoughSubdivide(unsigned short xpos,unsigned short ypos) { int i; if ((xpos<30)&&(ypos<30)) { if (ObjectTypes[xpos][ypos]==3) { for(i=0;i<5;i++) Setting[i][References[xpos][ypos]].attribute= (Setting[i][References[xpos][ypos]].attribute)|(1<<9); } } } void InitializeSetting(short *LevelDescription,int offset) { int ActualNumber; int xcount; int ycount; short xpos; short ypos; int totalcount; int i; xpos=0; ypos=0; ActualNumber=0; totalcount=offset; for(xcount=0;xcount<30;xcount++) { for(ycount=0;ycount<30;ycount++) { if (LevelDescription[totalcount]!=4) ObjectTypes[xcount][ycount]=LevelDescription[totalcount]; else ObjectTypes[xcount][ycount]=1; References[xcount][ycount]=-1; if (LevelDescription[totalcount]!=0) { References[xcount][ycount]=ActualNumber; GsInitCoordinate2(WORLD,&coordinates[ActualNumber]); coordinates[ActualNumber].coord=GsIDMATRIX; coordinates[ActualNumber].flg=0; coordinates[ActualNumber].coord.t[0]=xpos; coordinates[ActualNumber].coord.t[1]=0; coordinates[ActualNumber].coord.t[2]=ypos; Flags[ActualNumber]=0; switch (LevelDescription[totalcount]) { case 4: // Here is a box; case 1: Setting[0][ActualNumber]=getFloor(&coordinates[ActualNumber]); break; case 2: Setting[0][ActualNumber]=getTarget(&coordinates[ActualNumber]); break; case 3: for(i=0;i<5;i++) Setting[i][ActualNumber]=getWall(i,&coordinates[ActualNumber]); Flags[ActualNumber]=1; break; } if (LevelDescription[totalcount]==4) Setting[0][ActualNumber].attribute=(1<<31); // Switch off as box is positioned here ActualNumber++; } totalcount++; ypos+=512; } xpos+=512; ypos=0; } NumberOfObjects=ActualNumber; } void Activate(unsigned short xpos,unsigned short ypos) { Setting[0][References[xpos][ypos]].attribute= (Setting[0][References[xpos][ypos]].attribute)&(~(1<<31)); } void Deactivate(unsigned short xpos,unsigned short ypos) { Setting[0][References[xpos][ypos]].attribute= Setting[0][References[xpos][ypos]].attribute|(1<<31); } void DrawSetting() { GsOT *table; int count; MATRIX Screen; MATRIX World; int i; table=getMidGround(); for(count=0;count