#include <cstdlib> #include "iostream" #include "string.h" using namespace std; //------------------------------------------- //#define show_debug 1 #define win_x 1 #define win_0 2 #define win_end 3 #define win_gameNext 0 #define CASE_BLOCK_SIZE 9 #define TEXT_BLOCK_SIZE 16 int Text_Block_Size=13; // 13, 13, 13,10 16. asm. char End_Of_String=0; bool useDOSInt=false; // BIOS bool mode_pve=true; // pvp ( ) bool optimizeDataFind=true; // bool casheWinVar=true; // char *winText[4]; // , . unsigned short KEYBOARD_BYTE_OFFSET[] = {0x40,0x80,0x100,0x8,0x10,0x20,0x1,0x2,0x4 }; //{0b001000000,0b010000000,0b100000000,0b000001000,0b000010000,0b000100000,0b000000001,0b000000010,0b000000100 }; //unsigned short BOT_POSITION_PRIORITY[] = //{ 0x10, 0x40, 0x4, 0x100, 0x1, 0x80, 0x2, 0x8, 0x20}; // center bounds other //{0b000010000, 0b001000000,0b000000100,0b100000000,0b000000001,0b010000000,0b000000010,0b000001000,0b000100000 }; unsigned short WIN_MATRIX[] = { 0x1C0, 0x38, 0x7, 0x124, 0x92, 0x49, 0x111, 0x54 }; //{ 0b111000000, 0b000111000, 0b000000111, 0b100100100, 0b010010010, 0b001001001, 0b100010001, 0b001010100 }; unsigned short MATRIX_FULL = 0x1FF; //0b111111111; unsigned short STRING_ENTER_POS = 0x124;//0b100100100; // mode_pve==false && optimizeDataFind==false, max = 294781 #define MAX_DATA_SIZE 550000 int data_addres[MAX_DATA_SIZE][CASE_BLOCK_SIZE]; char text[MAX_DATA_SIZE][TEXT_BLOCK_SIZE]; int data_pos = 0; // FIXME unsigned short data_hashcashe[MAX_DATA_SIZE][2]; // findGameVar optimizeDataFind //---- int testWon(unsigned short MAP_X,unsigned short MAP_0) { for (int i=0; i<8; i++) { if ( (MAP_X & WIN_MATRIX[i]) == WIN_MATRIX[i] ) return win_x; if ( (MAP_0 & WIN_MATRIX[i]) == WIN_MATRIX[i] ) return win_0; } if ( (MAP_X | MAP_0) == MATRIX_FULL ) return win_end; return win_gameNext; } void printField(unsigned short MAP_X,unsigned short MAP_0, char* result) { //char result[TEXT_BLOCK_SIZE]="...\n...\n...\n"; int p=0; for (unsigned int bOfs=1; bOfs<MATRIX_FULL; bOfs=bOfs<<1) { // shl TODO test owerflow! if ( MAP_X & bOfs ) result[p]='X'; else { if ( MAP_0 & bOfs ) result[p]='0'; else result[p]='.'; } if ( bOfs & STRING_ENTER_POS ) { p++; result[p]='\n'; } p++; } result[p]=End_Of_String; return result; } // ---- int setVariant(int varID, int variants[CASE_BLOCK_SIZE], char* txt) { int i; for (i=0;i<CASE_BLOCK_SIZE;i++) data_addres[varID][i]=variants[i]; // TODO memcopy for (i=0; i<Text_Block_Size && ( txt[i]!=End_Of_String && txt[i]!=0 ) ; i++) text[varID][i]=txt[i]; text[varID][Text_Block_Size-1]=End_Of_String; // . #ifdef show_debug cout<<" set №"<<varID<<" as "<<text[varID]<<endl; #endif return varID; } void addToCasheVar(int i,unsigned short MAP_X,unsigned short MAP_0) // if optimizeDataFind { data_hashcashe[i][0]=MAP_X; data_hashcashe[i][1]=MAP_0; } int getFreeVar() { int p=data_pos; if (p>=MAX_DATA_SIZE-1) { cout<<"Owerflow data pos! " << p <<endl; return -1; } data_pos++; #ifdef show_debug cout<<"New variant №"<<p<<endl; #endif return p; } int itrGameHod_traceAll(unsigned short MAP_X,unsigned short MAP_0, bool playOn_X); /** * -. * (0) * - int [0,8], . */ int getBestBotHod(unsigned short MAP_X,unsigned short MAP_0) { // TODO bot . unsigned short lastMAP_X=MAP_X; unsigned short lastMAP_0=MAP_0; unsigned short full_map = MAP_X | MAP_0; int winLevel=-1; // int winPos=-1; //* //if (winLevel<1) for (int i=0; i<9; i++) { // unsigned short p = 1<<i; if ( (full_map & p) == 0 ) { // MAP_0 |= p; // if (playOn_X) MAP_X |= p; else MAP_0 |= p; int tmpWLvl=0; int w=testWon(MAP_X,MAP_0); if ( w!=win_gameNext ) { if (w==win_0) tmpWLvl=40; } else { w=itrGameHod_traceAll(MAP_X,MAP_0, true); if (w & win_0) tmpWLvl+=4; if (w & win_end) tmpWLvl+=2; if (w & win_x) tmpWLvl+=0; } if (tmpWLvl>winLevel) { //|| (tmpWLvl==winLevel && (rand() % 3 == 1))) { winLevel=tmpWLvl; winPos=i; } MAP_X=lastMAP_X; MAP_0=lastMAP_0; } } //*/ return winPos; } int winWariantCashe[4]={0,0,0,0}; // , , . int winWariantVer[4]={0,0,0,0}; // , int setEndGameVariant(unsigned short MAP_X,unsigned short MAP_0, char* txt) { int currentRecordID; if (casheWinVar) { int wonIs = testWon(MAP_X,MAP_0); winWariantVer[wonIs]++; if (winWariantCashe[wonIs]==0) { int addres[CASE_BLOCK_SIZE]={0,0,0,0,0,0,0,0,0}; // ( ) currentRecordID=getFreeVar(); // setVariant(currentRecordID,addres, txt); winWariantCashe[wonIs]=currentRecordID; } else currentRecordID=winWariantCashe[wonIs]; } else { int addres[CASE_BLOCK_SIZE]={0,0,0,0,0,0,0,0,0}; // ( ) //currentText= printField (MAP_X,MAP_0); // , 2 . int currentRecordID=getFreeVar(); setVariant(currentRecordID,addres, txt); } return currentRecordID; } /* * bot 0, mode_pve==true * * playOn_X - 0= , * */ int itrGameHod_traceAll(unsigned short MAP_X,unsigned short MAP_0, bool playOn_X) { unsigned short lastMAP_X=MAP_X; unsigned short lastMAP_0=MAP_0; unsigned short full_map = MAP_X | MAP_0; int winResult=0; int allWinVariant=win_x | win_0 | win_end; if (playOn_X || !mode_pve) { // user, for (int i=0; i<CASE_BLOCK_SIZE; i++) { unsigned short p = 1<<i; if ( (full_map & p) == 0 ) { // //MAP_X |= p; // if (playOn_X) MAP_X |= p; else MAP_0 |= p; int w=testWon(MAP_X,MAP_0); if (w!=win_gameNext) { winResult |= w; if (winResult==allWinVariant) return winResult; // , = } else w=itrGameHod_traceAll(MAP_X,MAP_0, !playOn_X); // iteration MAP_X=lastMAP_X; MAP_0=lastMAP_0; } } } else { // , ( mode_pve ) int i=getBestBotHod(MAP_X,MAP_0); unsigned short p = 1<<i; if ( (full_map & p) == 0 ) { // MAP_0 |= p; int w=testWon(MAP_X,MAP_0); if (w!=win_gameNext) { winResult |= w; if (winResult==allWinVariant) return winResult; } else w=itrGameHod_traceAll(MAP_X,MAP_0, !playOn_X); // iteration MAP_0=lastMAP_0; } } return winResult; } /** * * -1 */ int findGameVar(unsigned short MAP_X,unsigned short MAP_0) { for ( int i=0; i<data_pos ; i++ ) if ( data_hashcashe[i][0]==MAP_X && data_hashcashe[i][1]==MAP_0 ) return i; return -1; } /* * bot 0 * * playOn_X - 0= , * addNewWariant. . */ int itrGameHod_recordAll(unsigned short MAP_X,unsigned short MAP_0, bool playOn_X) { unsigned short lastMAP_X=MAP_X; unsigned short lastMAP_0=MAP_0; unsigned short full_map = MAP_X | MAP_0; int addres[CASE_BLOCK_SIZE]; // ( ) char currentText[Text_Block_Size]; // printField (MAP_X,MAP_0,currentText); if (optimizeDataFind) { int gVar = findGameVar(MAP_X, MAP_0); if ( gVar >=0 ) return gVar; } int currentRecordID=getFreeVar(); if (currentRecordID==-1) { return -1; } if (optimizeDataFind) addToCasheVar(currentRecordID, MAP_X, MAP_0); if (playOn_X || !mode_pve) { // for (int i=0; i<CASE_BLOCK_SIZE; i++) { unsigned short p = KEYBOARD_BYTE_OFFSET[i]; //1<<i; if ( (full_map & p) == 0 ) { // if (playOn_X) MAP_X |= p; else MAP_0 |= p; int w=testWon(MAP_X,MAP_0); if (w!=win_gameNext) { // out who is won addres[i]=setEndGameVariant(MAP_X,MAP_0, winText[w]); // FIXME TEST! winText[win_x] } else { if (mode_pve) { // BOT, PVE int p2Int=getBestBotHod(MAP_X,MAP_0); // 0, !playOn_X if (p2Int == -1) cout<<"Wrong bot variant!"<<endl; unsigned short p2Bit=1<<p2Int; MAP_0 |= p2Bit; int w=testWon(MAP_X,MAP_0); if (w!=win_gameNext) { // out who is won addres[i]=setEndGameVariant(MAP_X,MAP_0, winText[win_0]); } else { // add new wariant int nextDataAddr=itrGameHod_recordAll(MAP_X,MAP_0, playOn_X); // iteration addres[i] = nextDataAddr; } } else { // PVP int nextDataAddr=itrGameHod_recordAll(MAP_X,MAP_0, !playOn_X); // iteration addres[i] = nextDataAddr; // TODO if == -1 } } MAP_X=lastMAP_X; MAP_0=lastMAP_0; } else { addres[i]=currentRecordID; } } currentRecordID=setVariant(currentRecordID, addres,currentText); return currentRecordID; } else { cout<<"Error! ."<<endl; return -1; } } // -------------- void outDataFormatC() { int minimalCaseSize=1; if (data_pos>0xff) minimalCaseSize=2; if (data_pos>0xffff) minimalCaseSize=4; cout<< "// Out data on C array:"<<endl; cout<<"int data_pos = 0; // max="<<data_pos<<endl; cout<<"int CASE_BLOCK_SIZE = "<<CASE_BLOCK_SIZE<<";"<<endl; cout<<"int TEXT_BLOCK_SIZE = "<<Text_Block_Size<<";"<<endl; cout<<"unsigned "; //data_addres if (minimalCaseSize==1) cout<<"char"; if (minimalCaseSize==2) cout<<"short"; if (minimalCaseSize==4) cout<<"int"; cout<<" data_addres["<<data_pos<<"]["<<CASE_BLOCK_SIZE<<"] = {"; for ( int i=0; i<data_pos; i++) { if (i!=0) cout<<", "; cout<<"{"; for ( int j=0; j<CASE_BLOCK_SIZE; j++) { if (j!=0) cout<<", "; cout<<data_addres[i][j]; } cout<<"}"; } cout<<"};"<<endl; //text cout<<"char text["<<data_pos<<"]["<<Text_Block_Size<<"] = {"; for ( int i=0; i<data_pos; i++) { if (i!=0) cout<<", "; // //cout<<"{"; //for ( int j=0; j<TEXT_BLOCK_SIZE; j++) { // if (j!=0) cout<<", "; // cout<< (int)text[i][j]; //} //cout<<"}"; //cout<< "\""<<text[i]<<"\""<<endl; // cout<<"\""; for ( int j=0; j<Text_Block_Size; j++) { if (text[i][j]>=30) cout<< text[i][j]; else { if (text[i][j]=='\n') cout<<"\\n"; else if (text[i][j]==0) cout<<"\\0"; else cout<< "\\("<<(int)text[i][j]<<")"; } } cout<<"\""; } cout<<"};"<<endl; cout<<"// ---- end of data ----"<<endl; } /** * * @param premul , ( ) */ void outDataFormatAsm(int optLevel) { int minimalCaseSize=2; //if (data_pos>0xff) minimalCaseSize=2; //if (data_pos>0xffff) minimalCaseSize=4; cout<<"; Out data on assembler data format"<<endl; if (optLevel==0) { cout<<"data_pos DW 0 ; max="<<data_pos<<"-1"<<endl; cout<<"CASE_BLOCK_SIZE DW "<<CASE_BLOCK_SIZE*minimalCaseSize<<" ;bytes ("<<minimalCaseSize<<" byte per 1 case)"<<endl; cout<<"TEXT_BLOCK_SIZE DW "<<Text_Block_Size<<endl; cout<<"data_addres:"<<endl; for ( int i=0; i<data_pos; i++) { //if (minimalCaseSize==1) cout<<"DB "; //if (minimalCaseSize==2) cout<<"DW "; //if (minimalCaseSize==4) cout<<"QW "; // data_pos 16- DW cout<<"DW "; for ( int j=0; j<CASE_BLOCK_SIZE; j++) { if (j!=0) cout<<", "; cout<<data_addres[i][j]; } cout<<endl; } cout<<endl; //text cout<<"text_data: \n"; bool textMarker=false; for ( int i=0; i<data_pos; i++) { cout<<"DB "; int maxOutBytes=Text_Block_Size; for ( int j=0; j<maxOutBytes; j++) { if (text[i][j]>=30) { if (!textMarker) { if (j!=0) cout<<", "; cout<<"\""; textMarker=true; } cout<< text[i][j]; } else { if (textMarker) { cout<<"\""; textMarker=false; } if (text[i][j]=='\n') { cout<<", 13,10"; maxOutBytes--; } else if (text[i][j]==0 && End_Of_String!=0) cout<<", \""<<End_Of_String<<"\""; // DOS int 21h. else if (text[i][j]==0) cout<<", \" \""; // FIXME ? else cout<< ", "<<(int)text[i][j]; } } if (textMarker) { cout<<"\""; textMarker=false; } cout<<endl; } } if (optLevel==1) { cout<<"data_pos DW 0 ; max="<<data_pos<<"-1"<<endl; //cout<<"CASE_BLOCK_SIZE DW "<<CASE_BLOCK_SIZE*minimalCaseSize<<" ;bytes ("<<minimalCaseSize<<" byte per 1 case)"<<endl; //cout<<"TEXT_BLOCK_SIZE DW "<<Text_Block_Size<<endl; cout<<"data_addres:"<<endl; //data_addres for ( int i=0; i<data_pos; i++) { cout<<"DW "; for ( int j=0; j<CASE_BLOCK_SIZE; j++) { if (j!=0) cout<<", "; cout<< (data_addres[i][j] * (CASE_BLOCK_SIZE*minimalCaseSize+Text_Block_Size)); // . } cout<<endl; //text cout<<"DB "; bool textMarker=false; int maxOutBytes=Text_Block_Size; for ( int j=0; j<maxOutBytes; j++) { if (text[i][j]>=30) { if (!textMarker) { if (j!=0) cout<<", "; cout<<"\""; textMarker=true; } cout<< text[i][j]; } else { if (textMarker) { cout<<"\""; textMarker=false; } if (text[i][j]=='\n') { // "" cout<<", 13,10"; maxOutBytes--; } else if (text[i][j]==0 && End_Of_String!=0) cout<<", \""<<End_Of_String<<"\""; // DOS int 21h. else if (text[i][j]==0) cout<<", \" \""; // , ? else cout<< ", "<<(int)text[i][j]; } } if (textMarker) { cout<<"\""; textMarker=false; } cout<<endl; } } if (optLevel>=2) { cout<<"data_pos DW d_0"<<endl; for ( int i=0; i<data_pos; i++) { cout<<"d_"<< i <<" "; //data_addres cout<<"DW "; for ( int j=0; j<CASE_BLOCK_SIZE; j++) { if (j!=0) cout<<", "; cout<< "d_"<<data_addres[i][j]; // . } cout<<endl; //text cout<<"DB "; bool textMarker=false; int maxOutBytes=Text_Block_Size; for ( int j=0; j<maxOutBytes; j++) { if (text[i][j]>=30) { if (!textMarker) { if (j!=0) cout<<", "; cout<<"\""; textMarker=true; } cout<< text[i][j]; } else { if (textMarker) { cout<<"\""; textMarker=false; } if (text[i][j]=='\n') { // "" cout<<", 13,10"; maxOutBytes--; } else if (text[i][j]==0 && End_Of_String!=0) cout<<", \""<<End_Of_String<<"\""; // DOS int 21h. else if (text[i][j]==0) cout<<", \" \""; // FIXME ? else cout<< ", "<<(int)text[i][j]; } } if (textMarker) { cout<<"\""; textMarker=false; } cout<<endl; } } cout<<"; ---- end of data ----"<<endl; return; } /** * @param showInfo */ void generator_game_data(bool showInfo) { if (showInfo) cout<<"Start generation."<<endl; for ( int i=0; i<MAX_DATA_SIZE; i++) for ( int j=0; j<Text_Block_Size; j++) text[i][j]=End_Of_String; int startP = itrGameHod_recordAll(0,0, true); if (showInfo) { cout<< "Finish generation. Start game position="<<startP<<endl; cout<< "Data length = "<<data_pos<<endl; int minimalCaseSize=1; if (data_pos>0xff) minimalCaseSize=2; if (data_pos>0xffff) minimalCaseSize=4; cout<< " key array size is "<<(data_pos*CASE_BLOCK_SIZE*minimalCaseSize)<<" byte ("<<minimalCaseSize<<" byte per case)"<<endl; cout<< " text array size is "<<(data_pos*Text_Block_Size*sizeof(char))<<" byte"<<endl; cout<< " : "<<winWariantVer[win_end]<<", 0 "<<winWariantVer[win_0]<<", X "<<winWariantVer[win_x] <<endl; cout<< "Use --help for help." <<endl; } } //------------------------------------------- void outListingC() { cout<<"/*"<<endl; cout<<"* example short command tic-tac-toe. By godAlex generator."<<endl; cout<<"*/"<<endl; cout<<"#include <stdio.h>"<<endl; cout<<"#include <stdlib.h>"<<endl; outDataFormatC(); cout<<"int main(int argc, char** argv) {"<<endl; cout<<" while (1) {"<<endl; cout<<" printf(text[data_pos]);"<<endl; cout<<" int i;"<<endl; cout<<" do scanf(\"%i\",&i); while ( i<1 || i>9 );"<<endl; cout<<" data_pos=data_addres[data_pos][i-1];"<<endl; cout<<" }"<<endl; cout<<" return (EXIT_SUCCESS);"<<endl; cout<<"}"<<endl; } void outListingAsm(int optLevel) { cout<<"SECTION .text"<<endl; cout<<"org 0x100 ; .com "<<endl; // cout<<"push cs"<<endl; // cout<<"pop ds ; "<<endl; cout<<"lblShowVariant: "<<endl; cout<<" mov ax,0x0001 ; clear screen, set graphic mode 40x25, color"<<endl; cout<<" int 10h"<<endl; if (!useDOSInt) { // BIOS if (optLevel==0) { cout<<" mov ax, [data_pos]"<<endl; cout<<" mov bx, [TEXT_BLOCK_SIZE]"<<endl; cout<<" mul bx"<<endl; cout<<" mov bp, text_data"<<endl; cout<<" add bp,ax ; offset "<<endl; } if (optLevel==1) { // -3 cout<<" mov bp, data_addres+"<<(CASE_BLOCK_SIZE*2)<<endl; cout<<" add bp, [data_pos]"<<endl; } if (optLevel>=2) { // -1/-3 cout<<" mov bp, "<<(CASE_BLOCK_SIZE*2)<<endl; cout<<" add bp, [data_pos]"<<endl; } cout<<" mov cx, "<<Text_Block_Size<<" ; [TEXT_BLOCK_SIZE]"<<endl; // [TEXT_BLOCK_SIZE] cout<<" mov ax,1300h"<<endl; cout<<" mov bx,0eh ; color"<<endl; cout<<" mov dx,0500h ; 5 0 "<<endl; cout<<" int 10h"<<endl; } else { // DOS if (optLevel==0) { cout<<" mov ax, [data_pos]"<<endl; cout<<" mov bx, [TEXT_BLOCK_SIZE]"<<endl; cout<<" mul bx"<<endl; cout<<" mov dx, text_data"<<endl; cout<<" add dx,ax ; offset "<<endl; } if (optLevel==1) { // -3 cout<<" mov dx, data_addres+"<<(CASE_BLOCK_SIZE*2)<<endl; cout<<" add dx, [data_pos]"<<endl; } if (optLevel>=2) {// -1 -3 cout<<" mov dx, "<<(CASE_BLOCK_SIZE*2)<<endl; cout<<" add dx, [data_pos]"<<endl; } cout<<" mov ah, 0x9 ; print [ds][dx]"<<endl; cout<<" int 21h ; dos, $"<<endl; } if (optLevel<3) cout<<"lReadKey: "<<endl; //cout<<" rep nop ; , "<<endl; cout<<" xor ax,ax"<<endl; cout<<" int 16h ; BIOS read key"<<endl; cout<<" xor ah,ah"<<endl; cout<<" sub al,'1' ; al , "<<endl; if (optLevel<3) cout<<" cmp ax,8"<<endl; // O3 - , , if (optLevel<3) cout<<" ja lReadKey"<<endl; cout<<" shl ax,1 ; ax=ax*2"<<endl; if (optLevel==0) { cout<<" mov bx, data_addres"<<endl; cout<<" add bx,ax ; bx = data_addres[key]"<<endl; cout<<" mov ax, [data_pos]"<<endl; cout<<" mov cx, [CASE_BLOCK_SIZE]"<<endl; cout<<" mul cx ; cx = [data_pos]"<<endl; cout<<" add bx,ax ; bx = data_addres[data_pos][key]"<<endl; } if (optLevel==1) { // -3 cout<<" add ax, data_addres ; bx = data_addres[key]"<<endl; cout<<" add ax, [data_pos]"<<endl; cout<<" mov bx,ax"<<endl; } if (optLevel>=2) { // -1 ; optLevel>2 -1-3 cout<<" add ax, [data_pos]"<<endl; cout<<" mov bx,ax ; TODO , xlat, ?"<<endl; } cout<<" mov ax,[bx]"<<endl; cout<<" mov [data_pos],ax ; ."<<endl; cout<<" jmp lblShowVariant"<<endl; // ;mov ax, 0x4c00; DOS EXIT, )) // ;int 0x21 cout<<"SECTION .data"<<endl; outDataFormatAsm(optLevel); } void outListingHTML() { cout<<"<html>"<<endl; cout<<"<head>"<<endl; cout<<"<!-- 0 JS -->"<<endl; cout<<"<script type=\"text-javascript\">"<<endl; cout<<"</script>"<<endl; cout<<"<style>"<<endl; cout<<" div {"<<endl; cout<<" height: 100%"<<endl; cout<<" }"<<endl; cout<<" td {"<<endl; cout<<" width:1em;"<<endl; cout<<" height:1em;"<<endl; cout<<" }"<<endl; cout<<"</style>"<<endl; cout<<"</head>"<<endl; cout<<"<body>"<<endl; for ( int i=0; i<data_pos; i++) { cout<<"<div id=\"p"<<i<<"\">"<<endl; if (text[i][0]=='X' || text[i][0]=='0' || text[i][0]=='.') { cout<<"<table border=\"border\">"<<endl; cout<<"<tr>"<<endl; cout<<" <td><a href=\"#p"<<data_addres[i][0]<<"\">"<<text[i][6+2]<<"</a></td>"<<endl; cout<<" <td><a href=\"#p"<<data_addres[i][1]<<"\">"<<text[i][7+2]<<"</a></td>"<<endl; cout<<" <td><a href=\"#p"<<data_addres[i][2]<<"\">"<<text[i][8+2]<<"</a></td>"<<endl; cout<<"</tr><tr>"<<endl; cout<<" <td><a href=\"#p"<<data_addres[i][3]<<"\">"<<text[i][3+1]<<"</a></td>"<<endl; cout<<" <td><a href=\"#p"<<data_addres[i][4]<<"\">"<<text[i][4+1]<<"</a></td>"<<endl; cout<<" <td><a href=\"#p"<<data_addres[i][5]<<"\">"<<text[i][5+1]<<"</a></td>"<<endl; cout<<"</tr><tr>"<<endl; cout<<" <td><a href=\"#p"<<data_addres[i][6]<<"\">"<<text[i][0]<<"</a></td>"<<endl; cout<<" <td><a href=\"#p"<<data_addres[i][7]<<"\">"<<text[i][1]<<"</a></td>"<<endl; cout<<" <td><a href=\"#p"<<data_addres[i][8]<<"\">"<<text[i][2]<<"</a></td>"<<endl; cout<<"</tr>"<<endl; cout<<"</table>"<<endl; } else cout<<"<a href=\"#p"<<data_addres[i][0]<<"\">"<<text[i]<<"</a>"<<endl; cout<<"</div>"<<endl; } cout<<"</body>"<<endl; cout<<"</html>"<<endl; } // ---- int main(int argc, char** argv) { int outFormat=-1; // 0 - assembler data, 1 - C array, -1 - . int optLevel=0; // 0 - , 1 - ( ), 2 - (), 3 - ()) for (int i=1; i<argc; i++) { if ( strcmp(argv[i],"--help")==0 || strcmp(argv[i],"-h")==0 ) { cout<<" . --help ."<<endl; cout<<" --help -h ."<<endl; cout<<" -a ( )"<<endl; cout<<" - "<<endl; cout<<" -sa "<<endl; cout<<" -s C"<<endl; cout<<" -sh HTML"<<endl; cout<<" -pvp ( )"<<endl; cout<<" -nodataopt , "<<endl; cout<<" -nowinopt , "<<endl; cout<<" (??) -nowinopt -nodataopt"<<endl; // TODO check text cout<<" :"<<endl; cout<<" -dosint (-3 ) DOS"<<endl; cout<<" -o0 (28 /25 dosint) . ."<<endl; cout<<" -o1 (-6 22 /19 dosint) . ."<<endl; cout<<" -o2 (-1 21/18 ) . , ()."<<endl; cout<<" -o3 (-2 19/16 ) o2 range check - if . !"<<endl; return 0; } else if ( strcmp(argv[i],"-a")==0 ) outFormat=0; else if ( strcmp(argv[i],"-c")==0 ) outFormat=1; else if ( strcmp(argv[i],"-sa")==0 ) outFormat=2; else if ( strcmp(argv[i],"-sc")==0 ) outFormat=3; else if ( strcmp(argv[i],"-sh")==0 ) outFormat=4; else if ( strcmp(argv[i],"-o0")==0 ) optLevel=0; else if ( strcmp(argv[i],"-o1")==0 ) optLevel=1; // -mul else if ( strcmp(argv[i],"-o2")==0 ) optLevel=2; // o1 + -add else if ( strcmp(argv[i],"-o3")==0 ) optLevel=3; // o2 + -range check else if ( strcmp(argv[i],"-dosint")==0 ) useDOSInt=true; else if ( strcmp(argv[i],"-pvp")==0 ) mode_pve=false; else if ( strcmp(argv[i],"-pve")==0 ) mode_pve=true; else if ( strcmp(argv[i],"-nodataopt")==0 ) optimizeDataFind=false; else if ( strcmp(argv[i],"-nowinopt")==0 ) casheWinVar=false; else { cout<<" \""<<argv[i]<<"\". --help ."<<endl; return 1; } } bool usePCSpeaker=false; if ( outFormat==0 || outFormat==2 ) { if (useDOSInt) End_Of_String = '$'; // DOS Text_Block_Size=13+3; usePCSpeaker=true; // } // init win text messages if (mode_pve) { if (usePCSpeaker) { // winText[win_x] = "You are won!\7\n"; winText[win_end]= "Not win. End\n"; winText[win_0] = "Bot won. 0\7\n"; } else { winText[win_x] = "You are won!"; winText[win_end]= "Not win. End"; winText[win_0] = "Bot won."; } } else { // PVP if (usePCSpeaker) { // winText[win_x] = "X are won!\7\n"; winText[win_end]= "Not win. End\n"; winText[win_0] = "0 won.\7\n"; } else { winText[win_x] = "X are won!"; winText[win_end]= "Not win. End"; winText[win_0] = "0 won."; } } generator_game_data( outFormat<2 ); if (outFormat==0) outDataFormatAsm(optLevel); if (outFormat==1) outDataFormatC(); if (outFormat==2) outListingAsm(optLevel); if (outFormat==3) outListingC(); if (outFormat==4) outListingHTML(); return 0; }