本帖最后由 happy886rr 于 2016-11-27 20:05 编辑
POWERIMG.EXE
_____________________________________________________________________________
powerimg是一款强大的控制台图显脚本解释器,支持jpg、png、bmp等多种图片格式
该脚本解析器具有类似批处理的标签、跳转、循环、CALL等语法。完全是逐行解释
逐行运行,与批处理的解释机制非常相似,但语法风格略有不同,所有关键字一律
只有3个字符。
_____________________________________________________________________________
下载图片存为a.zip解压即是。

-----------------------------------------------------------------------------
主要关键字:(不区分大小写)
"add", "rot", "zom", "rev", "alp", "arg", "img", "slp", "lib", "jmp", "pos",
"exi", "pau", "cls", "tit", "mod", "cot", "mvw", "cal", "eof", "ech", "cur"
ROT [旋转中心x坐标] [旋转中心y坐标] [初始相位角度值] [角度增量]
ZOM [缩放中心x坐标] [缩放中心y坐标] [横向缩放率] [纵向缩放率] [横向缩放率增量] [纵向缩放率增量]
REV [模式值(-2到2)]
ALP [模式值( 0或1)] [R] [G] [B]
ADD [x坐标增量] [y坐标增量] [宽度大小增量] [高度大小增量] [x剪切坐标增量] [y剪切坐标增量] [显示的长度增量] [显示的高度增量]
ARG [x坐标] [y坐标] [宽度大小] [高度大小] [x剪切坐标] [y剪切坐标] [显示的长度] [显示的高度]
IMG [图片名]
JMP [#标签名]
CAL [#标签名]
COT [1|2|4|8] [1|2|4|8] [1|2|4|8] [16|32|64|128]
POS [x] [y]
MVW [x] [y]
CUR [光标尺寸]
SLP [延时毫秒]
其余ECH、PAU、TIT、CLS、EXI、MOD、CAL、均同批处理的echo, pause, title, cls,
exit, mode, con, call.
-----------------------------------------------------------------------------
注释符格式:
行注释 // 行内容
段注释 /*
段内容
*/
-----------------------------------------------------------------------------
自然宏命令:
||start the img script //每个powerimg脚本必须有的,脚本的开始标记
||using desktop window //使用桌面而非控制台来显示
||hide the cursor //隐藏光标
||end the img script //脚本的结束
||eof
-----------------------------------------------------------------------------
库调用格式:
LIB ||[库文件路径] [参数1] |[参数2]
-----------------------------------------------------------------------------
百叶窗示例:
//////////////////////////////////////////////////////
Shutter effects
//////////////////////////////////////////////////////
||start img script
||hide the cursor
[
[
ADD 0 -50
ARG 0 500, 0 0, 0 0, 500 50
IMG test.jpg
ADD 0 -50
ARG 0 550, 500 50
IMG
SLP 3
]10
ADD 0 0, 0 0, 0 50
]18,-1
||eof
-----------------------------------------------------------------------------
旋转图片示例:
//////////////////////////////////////////////////////
Rote effects
//////////////////////////////////////////////////////
||start img script
||hide the cursor
[
ROT 0 0, 0 10
IMG test.jpg
SLP 3
]18,-1
||eof
-----------------------------------------------------------------------------
标签的使用:
//在批处理中:代表标签的开始,但在powerimg中#才是一个标签的开始,goto用JMP代替
//////////////////////////////////////////////////////
Label effects
//////////////////////////////////////////////////////
||start img script
||hide the cursor
#start
ECH 你好!
EOF
JMP #start
CAL #start
||eof
-----------------------------------------------------------------------------
循环的使用:
//在powerimg中中括号就是循环,括号后的数字就是循环的次数
//////////////////////////////////////////////////////
For effects
//////////////////////////////////////////////////////
||start img script
||hide the cursor
[
ECH 循环内容
//8代表循环8次
]8
||eof
-----------------------------------------------------------------------------
英译:
THE CONSOLE DISPLAYS A PICTURE SCRIPT, VERSION 1.0
COPYRIGHT@2016~2018 BY HAPPY
POWERIMG.EXE
USAGE: powerimg [scriptfile]
-----------------------------------------------------------------------------
11/27/2016
核心源码: | | | | | | | | | | | | | | | #include <stdio.h> | | #include <stdlib.h> | | #include <string.h> | | #include <ctype.h> | | #include <stdbool.h> | | #include <windows.h> | | #include <wincon.h> | | #include <gdiplus\gdiplus.h> | | #include <io.h> | | #include <conio.h> | | #include <math.h> | | #include <time.h> | | | | | | | | #define M_PI 3.14159265358979323846 | | | | | | #define LOOP_LEVELS 16 | | | | #define SENSITIVE_NUM 22 | | | | static const char* KEY_WORDS[]={"add", "rot", "zom", "rev", "alp", "arg", "img", "slp", "lib", "jmp", "pos", "exi", "pau", "cls", "tit", "mod", "cot", "mvw", "cal", "eof", "ech", "cur"}; | | | | | | HWND WINAPI GetConsoleWindow(); | | BOOL WINAPI AlphaBlend(HDC,int,int,int,int,HDC,int,int,int,int,BLENDFUNCTION); | | BOOL WINAPI TransparentBlt(HDC,int,int,int,int,HDC,int,int,int,int,UINT); | | int Drawgif(HWND hCMD, wchar_t* gifFile, int cmd_x, int cmd_y, int size_W, int size_H, int CYCtimes, int playSpeed); | | int FileScript(char* sfile, char* LIB_ARGS[16]); | | WCHAR* AnsiToWCHAR(const char* str); | | | | | | | | int ATOI[16]={0}; | | | | int ROTE[16]={0}; | | | | float ZOOM[16]={0}; | | | | int REVE[16]={0}; | | | | int ALPH[16]={0}; | | | | | | HWND hCMD; | | | | | | typedef struct{ | | HBITMAP hBitmap; | | int Width; | | int Height; | | }IMAGE; | | | | typedef struct{ | | int x; | | int y; | | }RPOINT; | | | | typedef struct{ | | float x; | | float y; | | }RATE; | | | | | | typedef struct{ | | long FTEL; | | int CYCL; | | int CADD; | | int LNUM; | | | | int ADD[16]; | | }fori; | | | | | | | | | | int RotateDC(HDC hdc, int angle, RPOINT rpoint) | | { | | if(angle==0){return 1;} | | XFORM Matrix; | | double rad =-angle/180.0*M_PI; | | Matrix.eM11 = (float)cos(rad); | | Matrix.eM12 = (float)sin(rad); | | Matrix.eM21 =-(float)sin(rad); | | Matrix.eM22 = (float)cos(rad); | | Matrix.eDx = (float)(rpoint.x-cos(rad)*rpoint.x+sin(rad)*rpoint.y); | | Matrix.eDy = (float)(rpoint.y-cos(rad)*rpoint.y-sin(rad)*rpoint.x); | | SetGraphicsMode(hdc, GM_ADVANCED); | | SetWorldTransform(hdc, &Matrix); | | return 0; | | } | | | | int ZoomDC(HDC hdc, RATE rate, RPOINT rpoint) | | { | | XFORM Matrix; | | Matrix.eM11 = (float)rate.x; | | Matrix.eM12 = (float)0; | | Matrix.eM21 = (float)0; | | Matrix.eM22 = (float)rate.y; | | Matrix.eDx = (float)(rpoint.x-rate.x*rpoint.x); | | Matrix.eDy = (float)(rpoint.y-rate.y*rpoint.y); | | SetGraphicsMode(hdc, GM_ADVANCED); | | SetWorldTransform(hdc, &Matrix); | | return 0; | | } | | | | int ReverseDC(HDC hdc, int reverse_mode, IMAGE img) | | { | | XFORM Matrix; | | if (reverse_mode== 1){ | | Matrix.eM11 =-(float)1; | | Matrix.eM12 = (float)0; | | Matrix.eM21 = (float)0; | | Matrix.eM22 = (float)1; | | Matrix.eDx = (float)img.Width; | | Matrix.eDy = (float)0; | | }else if(reverse_mode== 2){ | | Matrix.eM11 = (float)1; | | Matrix.eM12 = (float)0; | | Matrix.eM21 = (float)0; | | Matrix.eM22 =-(float)1; | | Matrix.eDx = (float)0; | | Matrix.eDy = img.Height; | | }else if(reverse_mode== 0){ | | Matrix.eM11 =-(float)1; | | Matrix.eM12 = (float)0; | | Matrix.eM21 = (float)0; | | Matrix.eM22 =-(float)1; | | Matrix.eDx = (float)img.Width; | | Matrix.eDy = (float)img.Height; | | }else if(reverse_mode==-1){ | | Matrix.eM11 = (float)0; | | Matrix.eM12 = (float)1; | | Matrix.eM21 = (float)1; | | Matrix.eM22 = (float)0; | | Matrix.eDx = (float)0; | | Matrix.eDy = (float)0; | | }else if(reverse_mode==-2){ | | Matrix.eM11 = (float)0; | | Matrix.eM12 = (float)1; | | Matrix.eM21 =-(float)1; | | Matrix.eM22 = (float)0; | | Matrix.eDx = (float)img.Height; | | Matrix.eDy = (float)0; | | } | | SetGraphicsMode(hdc, GM_ADVANCED); | | SetWorldTransform(hdc, &Matrix); | | return 0; | | } | | | | IMAGE LoadImg(char* imgFile, int _nWidth, int _nHeight) | | { | | GpImage* thisImage; | | GpGraphics* graphics=NULL; | | ULONG_PTR gdiplusToken; | | IMAGE _img; | | GdiplusStartupInput GSI={1, NULL, false, false}; | | HDC hdc=GetDC(NULL); | | HDC hdcMem=CreateCompatibleDC(hdc); | | | | GdiplusStartup(&gdiplusToken, &GSI, NULL); | | GdipLoadImageFromFile(AnsiToWCHAR(imgFile), &thisImage); | | GdipGetImageWidth(thisImage, &_img.Width); | | GdipGetImageHeight(thisImage, &_img.Height); | | if (_nWidth !=0 && _nHeight==0){ | | _img.Height=(int)( (_img.Height*1.0 / _img.Width) * (_nWidth ) ); | | _img.Width =_nWidth; | | }else if(_nWidth ==0 && _nHeight!=0){ | | _img.Width =(int)( (_img.Width*1.0 / _img.Height) * (_nHeight) ); | | _img.Height=_nHeight; | | }else if(_nWidth !=0 && _nHeight!=0){ | | _img.Width =_nWidth; | | _img.Height=_nHeight; | | } | | _img.hBitmap=CreateCompatibleBitmap(hdc, _img.Width, _img.Height); | | | | SelectObject(hdcMem, _img.hBitmap); | | GdipCreateFromHDC(hdcMem, &graphics); | | GdipDrawImageRectI(graphics, thisImage, 0, 0, _img.Width, _img.Height); | | GdipDisposeImage(thisImage); | | GdipDeleteGraphics(graphics); | | DeleteDC (hdcMem); | | ReleaseDC(NULL, hdc); | | GdiplusShutdown(gdiplusToken); | | return _img; | | } | | | | int DrawImg( | | char* imgfile, | | int cmd_x, int cmd_y, | | int size_W, int size_H, | | int src_x, int src_y, | | int disp_W, int disp_H, | | fori* FORI[LOOP_LEVELS], | | int KLevel | | ){ | | | | IMAGE P=LoadImg(imgfile, size_W, size_H); | | HDC hCUR=GetDC(hCMD); | | HDC hSRC=CreateCompatibleDC(hCUR); | | SelectObject(hSRC, P.hBitmap); | | | | if(ROTE[0]!=0){ | | RPOINT rpoint={ROTE[1], ROTE[2]}; | | RotateDC(hCUR, ROTE[3]+ROTE[0]*ROTE[4], rpoint); | | } | | if(ZOOM[0]!=0){ | | RPOINT rpoint={(int)ZOOM[1], (int)ZOOM[2]}; | | if( | | (ZOOM[3]+ZOOM[0]*ZOOM[5])<0 || | | (ZOOM[4]+ZOOM[0]*ZOOM[6])<0 | | ){ | | return 1; | | } | | RATE rate={ZOOM[3]+ZOOM[0]*ZOOM[5], ZOOM[4]+ZOOM[0]*ZOOM[6]}; | | ZoomDC(hCUR, rate, rpoint); | | } | | if(REVE[0]!=0){ | | ReverseDC(hCUR, REVE[1], P); | | } | | if(FORI[KLevel]->ADD[0]!=0){ | | int i=0; | | for(i=0; i<=KLevel; i++){ | | cmd_x +=FORI[i]->ADD[0] * FORI[i]->ADD[1], cmd_y += FORI[i]->ADD[0] * FORI[i]->ADD[2]; | | size_W+=FORI[i]->ADD[0] * FORI[i]->ADD[3], size_H+= FORI[i]->ADD[0] * FORI[i]->ADD[4]; | | src_x +=FORI[i]->ADD[0] * FORI[i]->ADD[5], src_y += FORI[i]->ADD[0] * FORI[i]->ADD[6]; | | disp_W+=FORI[i]->ADD[0] * FORI[i]->ADD[7], disp_H+= FORI[i]->ADD[0] * FORI[i]->ADD[8]; | | } | | } | | disp_W=(disp_W<=0) ?P.Width :disp_W; | | disp_H=(disp_H<=0) ?P.Height :disp_H; | | | | if (ALPH[0]==1 && ALPH[1]==1){ | | TransparentBlt(hCUR, cmd_x, cmd_y, disp_W, disp_H, hSRC, src_x, src_y, P.Width, P.Height, RGB(ALPH[2],ALPH[3],ALPH[4])); | | }else if(ALPH[0]==1 && ALPH[1]==0){ | | BLENDFUNCTION blendFunction={0, 0, (ALPH[2]==0)?-1:ALPH[2], 1}; | | AlphaBlend(hCUR, cmd_x, cmd_y, disp_W, disp_H, hSRC, src_x, src_y, P.Width, P.Height, blendFunction); | | }else if(ALPH[0]==0){ | | BitBlt(hCUR, cmd_x, cmd_y, disp_W, disp_H, hSRC, src_x, src_y, SRCCOPY); | | } | | | | ROTE[0]=ZOOM[0]=REVE[0]=ALPH[0]=0; | | FORI[KLevel]->ADD[0]=0; | | DeleteObject(P.hBitmap); | | ReleaseDC(hCMD, hCUR); | | DeleteDC(hSRC); | | return 0; | | } | | | | int CleanImg( | | HWND hd, | | LONG cmd_x, LONG cmd_y, | | LONG size_W, LONG size_H, | | BOOL mode, | | fori* FORI[LOOP_LEVELS], | | int KLevel | | ){ | | RECT z={cmd_x+FORI[KLevel]->ADD[0]*FORI[KLevel]->ADD[1], cmd_y+FORI[KLevel]->ADD[0]*FORI[KLevel]->ADD[2], cmd_x+size_W+FORI[KLevel]->ADD[0]*FORI[KLevel]->ADD[3], cmd_y+size_H+FORI[KLevel]->ADD[0]*FORI[KLevel]->ADD[4]}; | | if(mode){ | | InvalidateRect(hd, &z, FALSE); | | }else{ | | InvalidateRect(hd, NULL, FALSE); | | } | | return 0; | | } | | | | | | | | | | char* stristr(const char* str1, const char* str2) | | { | | char* cp=(char *)str1; | | char* s1, *s2; | | if(!*str2){return (char *)str1;} | | while(*cp){ | | s1=cp; | | s2=(char *)str2; | | | | while( | | *s1 && | | *s2 && | | !(_tolower(*s1)-_tolower(*s2)) | | ){s1++, s2++;} | | | | if (!*s2){return cp;} | | cp++; | | } | | return NULL; | | } | | | | WCHAR* AnsiToWCHAR(const char* str) | | { | | if(!str){return NULL;} | | int wLen=MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, str, -1, NULL, 0); | | WCHAR* wstr=(WCHAR*)malloc(sizeof(WCHAR)*wLen + 1); | | MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, str, -1, wstr, wLen); | | wstr[wLen]='\0'; | | return wstr; | | } | | | | void DispyCursor(int size,bool mode) | | { | | CONSOLE_CURSOR_INFO cursor_info ={(DWORD)size, mode}; | | SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info); | | return; | | } | | | | int SetPos(int x,int y) | | { | | COORD pos; | | HANDLE hOutput; | | pos.X=x, pos.Y=y; | | hOutput=GetStdHandle(STD_OUTPUT_HANDLE); | | SetConsoleCursorPosition(hOutput,pos); | | return 0; | | } | | | | inline bool isNULL(const char c){ | | if( | | c=='\t' || | | c==' ' || | | c=='\r' || | | c=='\n' || | | c=='\0' | | | | ){ | | return true; | | } | | return false; | | } | | | | char* passNULL(char* Str){ | | if(Str!=NULL){ | | while(*Str=='\t' ||*Str==' '){Str++;} | | } | | return Str; | | } | | | | int args(char* Str, char* delims, char* ARGS[16], char* LIB_ARGS[16]) | | { | | int i=0; | | char* p; | | ARGS[i]=strtok(Str, delims); | | while(ARGS[i]!=NULL){ | | if( (p=stristr(ARGS[i], "*"))!=NULL){ | | ARGS[i]=LIB_ARGS[atoi(p+1)]; | | } | | ARGS[++i]=strtok(NULL, delims); | | } | | return i; | | } | | | | int ATOIargs(int* taner, int MAX_ARGC, int add, char* ARGS[16]) | | { | | int j; | | for(j=0; j<16; j++){taner[j]=0;} | | for(j=0; j<MAX_ARGC; j++){ | | taner[j+add]=atoi(ARGS[j]); | | } | | return 0; | | } | | | | int Identify_KeyWords(const char* Line) | | { | | int i, SN; | | for(SN=0; SN<SENSITIVE_NUM; SN++){ | | for(i=0; KEY_WORDS[SN][i]!='\0'; i++){ | | if( | | Line[i] !=KEY_WORDS[SN][i] && | | Line[i]+32!=KEY_WORDS[SN][i] | | | | ){ | | break; | | } | | } | | if( | | KEY_WORDS[SN][i]=='\0' && | | isNULL(Line[i]) | | ){ | | return SN; | | } | | } | | return 255; | | } | | | | | | int Shell_IMG(char* imgfile, fori* FORI[LOOP_LEVELS], int KLevel, int LineNUM) | | { | | | | if( | | imgfile==NULL || | | isNULL(imgfile[0]) | | ){ | | if(ATOI[0]==0){ | | CleanImg(hCMD, 0, 0, 0, 0, FALSE, FORI, KLevel); | | }else{ | | CleanImg(hCMD, ATOI[1], ATOI[2], ATOI[3], ATOI[4], TRUE, FORI, KLevel); | | } | | | | | | }else{ | | if(access(imgfile, 0)==-1){ | | fprintf(stdout, "[%d]:图片不存在。\n", LineNUM); | | exit(1); | | } | | DrawImg(imgfile, ATOI[1], ATOI[2], ATOI[3], ATOI[4], ATOI[5], ATOI[6], ATOI[7], ATOI[8], FORI, KLevel); | | } | | return 0; | | } | | | | | | | | | | int Shell_CLS() | | { | | HANDLE hConsole=GetStdHandle(STD_OUTPUT_HANDLE); | | COORD coordScreen={0,0}; | | DWORD cCharsWritten; | | CONSOLE_SCREEN_BUFFER_INFO csbi; | | GetConsoleScreenBufferInfo(hConsole, &csbi); | | FillConsoleOutputCharacter(hConsole, (TCHAR)' ', csbi.dwSize.X*csbi.dwSize.Y, coordScreen, &cCharsWritten); | | GetConsoleScreenBufferInfo(hConsole, &csbi); | | FillConsoleOutputAttribute(hConsole, csbi.wAttributes, csbi.dwSize.X*csbi.dwSize.Y, coordScreen, &cCharsWritten); | | SetConsoleCursorPosition(hConsole,coordScreen); | | return 0; | | } | | | | int Shell_TITLE(char* Str) | | { | | SetConsoleTitle(Str); | | return 0; | | } | | | | int Shell_KEY(clock_t delay) | | { | | int i,KEY_V,start=clock(); | | do{ | | if(kbhit()){ | | KEY_V=(int)(getch()); | | if(KEY_V<97){KEY_V+=32;} | | return KEY_V; | | } | | for(i=0;i<=50;i++); | | }while((clock()-start)<delay); | | return -1; | | } | | | | int Shell_MOUSE(int KEY_V) | | { | | if(KEY_V==0){ | | CONSOLE_CURSOR_INFO cursor_info={1,0}; | | SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info); | | return 0; | | } | | HANDLE StdIn=GetStdHandle(STD_INPUT_HANDLE); | | DWORD OrgMode, Res; | | INPUT_RECORD InR; | | GetConsoleMode(StdIn, &OrgMode); | | SetConsoleMode(StdIn, OrgMode | ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT); | | for(;;){ | | ReadConsoleInput(StdIn, &InR, 1, &Res); | | if( | | InR.Event.MouseEvent.dwEventFlags ==0 && | | InR.Event.MouseEvent.dwButtonState==KEY_V | | ){ | | SetConsoleMode(StdIn, OrgMode); | | return (InR.Event.MouseEvent.dwMousePosition.Y)*1000+(InR.Event.MouseEvent.dwMousePosition.X); | | } | | } | | } | | | | int Shell_MODE_CON(int x, int y) | | { | | | | HANDLE StdOut=GetStdHandle(STD_OUTPUT_HANDLE); | | CONSOLE_SCREEN_BUFFER_INFO scbi; | | COORD size={x, 300}; | | GetConsoleScreenBufferInfo(StdOut, &scbi); | | SetConsoleScreenBufferSize(StdOut, size); | | SMALL_RECT rc={0, 0, x-1, y-1}; | | SetConsoleWindowInfo(StdOut, 1, &rc); | | CloseHandle(StdOut); | | return 0; | | } | | | | int Shell_COLOR(unsigned short A,unsigned short B,unsigned short C,unsigned short D) | | { | | HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE); | | CONSOLE_SCREEN_BUFFER_INFO csbi; | | GetConsoleScreenBufferInfo(handle_out, &csbi); | | SetConsoleTextAttribute(handle_out, A | B | C | D); | | return 0; | | } | | | | int Shell_MW(int x, int y) | | { | | HWND cmd=GetConsoleWindow(); | | SetWindowPos(cmd, HWND_TOP, x, y, 0, 0, SWP_NOSIZE); | | return 0; | | } | | | | | | | | | | int FileScript(char* sfile, char* LIB_ARGS[16]) | | { | | | | int i=0, j=0, KLevel=0, Line_LEN=0, MAX_ARGC=0, SN=255; | | | | | | FILE* fp; | | if( (fp=fopen(sfile, "rb"))==NULL ){ | | fprintf(stdout, "[%d]:读取文件失败。\n", i); | | exit(1); | | } | | | | | | int* SFLAG=(int*)calloc(8, sizeof(int)); | | | | | | fori* FORI[LOOP_LEVELS]; | | for(j=0; j<LOOP_LEVELS; j++){ | | FORI[j]=(fori*)calloc(1, sizeof(FORI)); | | FORI[j]->FTEL=(long)0; | | FORI[j]->CYCL=0; | | FORI[j]->LNUM=0; | | FORI[j]->CADD=0; | | FORI[j]->ADD[16]=(int)calloc(16, sizeof(int)); | | } | | | | | | char* ARGS[16]; | | for(j=0; j<16; j++){ | | ARGS[j]=(char*)calloc(128, sizeof(char*)); | | } | | | | | | char* LCache=(char*)calloc(1025, sizeof(char)); | | | | char* Line; | | | | | | char* JMP_MARK=(char*)malloc(128*sizeof(char)); | | | | long CAL_MARK; | | | | while(!feof(fp)){ | | memset(LCache, 0, 1024*sizeof(char)); | | fgets(LCache, 1024, fp); | | | | | | Line=LCache; | | | | | | i++; | | | | | | while(*Line=='\t'|| *Line==' '){Line++;} | | | | | | if(Line[0]=='/' &&Line[1]=='/'){ | | continue; | | } | | | | if( | | (Line[0]=='/' &&Line[1]=='*' ) | | ){ | | SFLAG[0]=0; | | continue; | | | | }else if( | | (Line[0]=='*' &&Line[1]=='/' ) | | ){ | | SFLAG[0]=1; | | continue; | | | | }else if(Line[0]=='#'){ | | if(SFLAG[1]==0){ | | continue; | | }else{ | | j=0; | | while( | | JMP_MARK[j]==Line[j] || | | JMP_MARK[j]==Line[j]-32 | | ){j++;} | | if( isNULL(JMP_MARK[j]) && isNULL(Line[j]) ){SFLAG[1]=0;} | | continue; | | } | | } | | | | | | if( | | (Line[0]=='|') && | | (Line[1]=='|') | | ){ | | if( | | stristr(Line+2, "start" )!=NULL || | | stristr(Line+2, "begin" )!=NULL || | | stristr(Line+2, "run" )!=NULL | | ){ | | SFLAG[0]=1; | | continue; | | } | | | | if( | | stristr(Line+2, "end" )!=NULL || | | stristr(Line+2, "eof" )!=NULL | | ){ | | return 0; | | } | | | | if( | | stristr(Line+2, "desktop")!=NULL || | | stristr(Line+2, "desk" )!=NULL | | ){ | | hCMD=GetDesktopWindow(); | | continue; | | } | | | | if( | | stristr(Line+2, "hide" )!=NULL | | ){ | | DispyCursor(25, FALSE); | | } | | continue; | | } | | | | | | if( | | SFLAG[0]==0 || | | isNULL(Line[0]) || | | SFLAG[1]==1 | | ){continue;} | | | | | | if( | | (Line[0]=='[' ) && | | (isNULL(Line[1])) | | ){ | | FORI[++KLevel]->FTEL=ftell(fp); | | FORI[KLevel]->CYCL=0; | | FORI[KLevel+1]->CADD=0; | | FORI[KLevel]->LNUM=i+1; | | continue; | | } | | | | | | if(Line[0]==']'){ | | | | (FORI[KLevel]->CYCL)++; | | int TIM=atoi(strtok(Line+1,",")); | | | | | | FORI[KLevel+1]->CADD=atoi(strtok(NULL, ",")); | | | | if ( FORI[KLevel]->CYCL < TIM+(FORI[KLevel]->CADD)*(FORI[KLevel-1]->CYCL) ){ | | fseek(fp, FORI[KLevel]->FTEL, SEEK_SET); | | i=FORI[KLevel]->LNUM-1; | | | | }else if( FORI[KLevel]->CYCL >= TIM+(FORI[KLevel]->CADD)*(FORI[KLevel-1]->CYCL) ){ | | FORI[KLevel--]->CYCL=0; | | } | | continue; | | } | | | | if((Line_LEN=strlen(Line))==2){ | | continue; | | }else{ | | Line[Line_LEN-2]='\0'; | | } | | | | switch(Identify_KeyWords(Line)){ | | case 0: | | | | MAX_ARGC=args(Line+4, " ", ARGS, LIB_ARGS); | | ATOIargs(FORI[KLevel]->ADD, MAX_ARGC, 1, ARGS); | | FORI[KLevel]->ADD[0]=FORI[KLevel]->CYCL+1; | | break; | | case 1: | | | | MAX_ARGC=args(Line+4, " ", ARGS, LIB_ARGS); | | ATOIargs(ROTE, MAX_ARGC, 1, ARGS); | | ROTE[0]=FORI[KLevel]->CYCL+1; | | break; | | case 2: | | | | MAX_ARGC=args(Line+4, " ", ARGS, LIB_ARGS); | | for(j=0; j<MAX_ARGC; j++){ ZOOM[j+1]=atof(ARGS[j]);} | | ZOOM[0]=FORI[KLevel]->CYCL+1; | | break; | | case 3: | | | | MAX_ARGC=args(Line+4, " ", ARGS, LIB_ARGS); | | ATOIargs(REVE, MAX_ARGC, 1, ARGS); | | REVE[0]=FORI[KLevel]->CYCL+1; | | break; | | case 4: | | | | MAX_ARGC=args(Line+4, " ", ARGS, LIB_ARGS); | | ATOIargs(ALPH, MAX_ARGC, 1, ARGS); | | ALPH[0]=1; | | break; | | case 5: | | | | MAX_ARGC=args(Line+4, " ", ARGS, LIB_ARGS); | | ATOIargs(ATOI, MAX_ARGC, 1, ARGS); | | ATOI[0]=1; | | break; | | case 6: | | | | MAX_ARGC=args(Line+4, " ", ARGS, LIB_ARGS); | | Shell_IMG(passNULL(ARGS[0]), FORI, KLevel, i); | | break; | | case 7: | | | | Sleep(atoi(Line+4)); | | break; | | case 8: | | | | Line=passNULL(Line+4); | | if(Line[0]=='|'&&Line[1]=='|'){ | | MAX_ARGC=args(Line+2, "|", ARGS, LIB_ARGS); | | FileScript(ARGS[0], ARGS); | | }else{ | | fprintf(stdout, "[%d]:缺少库名。\n", i); | | exit(1); | | } | | | | break; | | case 9: | | | | strcpy(JMP_MARK, strupr(passNULL(Line+4))); | | i=KLevel=i=SFLAG[0]=0, SFLAG[1]=1; | | fseek(fp, 0, SEEK_SET); | | break; | | case 10: | | | | if(args(Line+4, " ", ARGS, LIB_ARGS) >1){SetPos(atoi(ARGS[0]), atoi(ARGS[1]));} | | break; | | case 11: | | | | exit( atoi(Line+4) ); | | break; | | case 12: | | | | getch(); | | break; | | case 13: | | | | Shell_CLS(); | | break; | | case 14: | | | | SetConsoleTitle(Line+4); | | break; | | case 15: | | | | if( args(Line+4, " ", ARGS, LIB_ARGS) >1){Shell_MODE_CON(atoi(ARGS[0]), atoi(ARGS[1]));} | | break; | | case 16: | | | | if( args(Line+4, " ", ARGS, LIB_ARGS) >3){Shell_COLOR(atoi(ARGS[0]), atoi(ARGS[1]), atoi(ARGS[2]), atoi(ARGS[3]));} | | break; | | case 17: | | | | if( args(Line+4, " ", ARGS, LIB_ARGS) >1){Shell_MW(atoi(ARGS[0]), atoi(ARGS[1]));} | | break; | | case 18: | | | | CAL_MARK=ftell(fp); | | SFLAG[2]=1; | | strcpy(JMP_MARK, strupr(passNULL(Line+4))); | | i=KLevel=i=SFLAG[0]=0, SFLAG[1]=1; | | fseek(fp, 0, SEEK_SET); | | break; | | case 19: | | | | if(SFLAG[2]==1){ | | fseek(fp, CAL_MARK, SEEK_SET); | | SFLAG[2]==0; | | }else{ | | return 0; | | } | | break; | | case 20: | | | | fputs(Line+4,stdout); | | fputs("\r\n",stdout); | | break; | | case 21: | | | | DispyCursor(atoi(Line+4), TRUE); | | break; | | case 255: | | fprintf(stdout, "[%d]:错误指令。\n", i); | | exit(1); | | break; | | } | | } | | free(SFLAG); | | free(FORI); | | free(LCache); | | fclose(fp); | | return 0; | | } | | | | | | | | int main(int argc, char** argv) | | { | | if(argc==2){ | | | | hCMD=GetConsoleWindow(); | | char* LIB_ARGS[16]; | | FileScript(argv[1], LIB_ARGS); | | return 0; | | } | | | | | | fputs( | | "THE CONSOLE DISPLAYS A PICTURE SCRIPT, COPYRIGHT@2016~2018 BY HAPPY\n" | | "VERSION 1.0\n" | | "usage: powerimg [scriptfile]\n" | | ,stdout | | ); | | return 1; | | }COPY |
|