📄 enigma4j.c
字号:
standout();
else
standend();
#else /* do it System V */
if(!attr) /* revert if necessary */
attrset(A_REVERSE);
else
attrset(A_NORMAL);
#endif
mvaddch(y,x,ch); /* type character */
move(ROWS - 1,COLUMNS - 1 ); /* move away cursor */
refresh(); /* make it visible */
#else
#ifdef VT52 /* vt52 */
/* move cursor */
pos1=translate(x+1);
pos2=translate(y+1);
printf("\033Y%c%c",y+32,x+32);
free(pos1);
free(pos2);
/* revert if necessary */
if(attr){
printf("\033b0");
printf("\033c1");
}else{
printf("\033b1");
printf("\033c0");
}
putchar(ch); /* type char */
/* printf("\033Y%c%c",ROWS+31,COLUMNS+31); */ /* move away cursor */
fflush(stdout);
#else
/*--- put your own b/w routine here ---*/
#endif
#endif
#endif
#endif
}
void cls(color) /* paint screen in colour color */
int color;
{
int attr,n;
attr=color;
#ifdef COLOUR /* colour */
#ifdef ANSI_COL /* with ANSI.SYS */
printf("\033[0;");
switch(attr){ /* not all possible */
/* colours implemented */
/* just those needed by */
/* this program */
case 2:
printf("32;");
printf("40");
break;
case 4:
printf("31;");
printf("40");
break;
case 7:
printf("40;");
printf("37");
break;
case 15:
printf("1;");
printf("40");
break;
case 96:
printf("30;");
printf("41");
break;
case 112:
printf("30;");
printf("47");
break;
}
putchar('m');
printf("\033[2J");
fflush(stdout);
#else
/* ------- put your own colour routine here -------- */
#endif
#else /* black and white */
#ifdef SUN /* cls on SUN */
putchar('\014');
#endif
#ifdef MSDOSBW /* inverted vt100 */
#ifndef VT320 /* ANSI.SYS */
printf("\033[0;"); /* Attributes */
#ifdef MSDOS
if(attr){ /*normal under MSDOS*/
#else
if(!attr){ /*reverse under UNIX*/
#endif
}else{
printf("7");
}
putchar('m');
printf("\033[2J");
fflush(stdout);
#else
/* incompatible */
/* to ANSI.SYS*/
printf("\033[?5"); /* background colour*/
#ifdef MSDOS
if(attr)
#else
if(!attr) /* works reverse */
/* under UNIX */
#endif
printf("h");
else
printf("l");
printf("\033[2J"); /* cls */
fflush(stdout);
#endif
#else
#ifdef VT /* not inverted vt100 */
/* ANSI.SYS */
#ifndef VT320
printf("\033[0;"); /* Attributes */
if(!attr){
}else{
printf("7");
}
putchar('m');
printf("\033[2J"); /* cls */
fflush(stdout);
#else /* incompatible Version*/
printf("\033[?5"); /* background colour*/
if(!attr)
printf("l");
else
printf("h");
printf("\033[2J"); /* cls */
fflush(stdout);
#endif
#else
#ifdef SWEARWORDS /* curses */
erase();
refresh();
#else
#ifdef VT52 /* vt52 */
if(attr){
printf("\033b0\033c1");
}else{
printf("\033b1\033c0");
}
printf("\033E");
fflush(stdout);
#else
/*----------- put your own b/w routine here ------- */
#endif
#endif
#endif
#endif
#endif
}
void putxy(c,mode,x,y) /* just a frame */
int c,mode,x,y;
{
ScreenSetCursor(x,y);
ScreenPutChar(c,mode,x,y);
return;
}
void writexy(s,mode,x,y) /* writes String s at x,y */
/* in colour mode */
char *s;
int mode,x,y;
{
while(s[0]){
putxy(s[0],mode,x,y);
s++;
x++;
}
return;
}
void gr_exit() /* clear up screen */
{
#ifdef ANSI_COL /* ANSI */
cls(KEY_PRES);
#else
#ifdef MSDOSBW /* MSDOSBW */
cls(MENU);
#else
#ifdef VT /* VT */
cls(MENU_CUR);
#else
#ifdef SWEARWORDS /* Curses which are used for output */
cls(MENU_CUR);
#ifndef BSDCURSES /* System V */
curs_set(1); /* make cursor visible */
#endif
#else
/* ----- put your own routine here ----------- */
#endif
#endif
#endif
#endif
/* putxy('\n',1,0,0);*/
/* fflush(stdout);*/
#ifdef CURSES /* Curses (independ.) */
endwin();
refresh();
#endif
#ifdef VT320 /* incompatible to ANSI */
printf("\033[?25h"); /* restore cursor */
fflush(stdout);
#endif
#ifdef VT52
printf("\033e\033q\033b1\033c0\033E");
fflush(stdout);
#endif
return;
}
/* ............................ ENIGMA specific ................... */
int confirm() /* returns 0 if <enter>*/
/* was pressed */
/* 1 on <ESC>*/
{
int c;
while(1){
c=inkey();
switch(c){
case '\r':
case '\n':
return(0);
case ESC:
return(1);
}
}
}
void intro() /* display a title screen */
{
cls(MENU);
writexy("...........................................................",MENU,0,0);
writexy("....... ___/.. /... /.. /.... ___/.... /...... /.... /...",MENU,0,1);
writexy("...... /..... _/... /.. /.. _/...._/.. /..... /.. __/ _ /.",MENU,0,2);
writexy("..... /..... /. /. /.. /.. /......... __/.__ /.. /.... /..",MENU,0,3);
writexy(".... __/... /._/. /.. /.. /...__/... /.. /.. /.. /.... /...",MENU,0,4);
writexy("... /..... /.._/ /.. /.._/..... /.. /.._/.. /.. _____ /....",MENU,0,5);
writexy(".. /..... /.... /.. /..._/...._/.. /...... /.. /.... /.....",MENU,0,6);
writexy(".____/.._/...._/.._/.....____/..._/......_/.._/...._/......",MENU,0,7);
writexy("...........................................................",MENU,0,8);
writexy("ENIGMA, a Simulator for the three rotor Enigma used in WW II",MENU,0,9);
writexy("(c) 1995 by Andreas G. Lessig, Hamburg ",MENU,0,12);
writexy("Special thanks to Vesselin Bontchev, ",MENU,0,15);
writexy("who dug out all the information.",MENU,0,16);
writexy("<Return>",MENU,0,20);
confirm();
cls(MENU);
writexy("Your system might use scancodes different of those on the PC.",
MENU,0,0);
writexy("For this reason you may type:",MENU,0,1);
writexy(" 1 instead of <F1>",MENU,0,3);
writexy(" <ContrlP> ----\"----- <UpArrow>",MENU,0,4);
writexy(" <ContrlN> ----\"----- <DownArrow>",MENU,0,5);
writexy(" <ContrlB> ----\"----- <LeftArrow>",MENU,0,6);
writexy(" <ContrlF> ----\"----- <RightArrow>",MENU,0,7);
writexy("There are the following options to this program:",MENU,0,9);
writexy(" -c simulates a green celloloid cover over the lamps",MENU,0,11);
writexy(" -d shows the assumptions the program makes about your System",
MENU, 0,12);
writexy(" the steps of encryption are shown",MENU,0,13);
writexy(" -t the last 65 encrypted characters are shown in groups of five",
MENU, 0,14);
writexy("<Return>",MENU,0,20);
confirm();
cls(MENU);
writexy("PLEASE NOTE:",MENU_AL,0,0);
writexy("1. You use this program at your own risk.",MENU,0,2);
writexy(" I won't pay for damage caused by its use.",MENU,0,3);
writexy("2. You might use and distribute it for privat purposes.",MENU,0,5);
writexy(" Commercial use has to be licensed by me.",MENU,0,6);
writexy(" (If you make money with it I want a share)",MENU,0,7);
writexy("3. If you change the source, mark it clearly in the",MENU,0,9);
writexy(" source code and make sure that every user knows",MENU,0,10);
writexy(" (s)he is using an altered version. ",MENU,0,11);
writexy(" (e.g. by a addition to the titelpage)",MENU,0,12);
writexy("4. If you ported this program to another system or",MENU,0,14);
writexy(" did some improvements, please let me know.",MENU,0,15);
writexy("Andreas G. Lessig (1lessig@rzdspc1.informatik.uni-hamburg.de)",MENU,0,20);
writexy("<Return>",MENU,0,24);
confirm();
cls(MENU);
return;
}
int keyx(c) /* returns x coordinate of a */
/* given key */
int c;
{
switch(c){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -