console.c
changeset 141 29cc31c87ede
parent 136 78ac8de2b2b8
child 169 4081f1d1f393
equal deleted inserted replaced
140:b00ce8503044 141:29cc31c87ede
    15 static byte* _iconsole_buffer[80];
    15 static byte* _iconsole_buffer[80];
    16 static byte _iconsole_cbuffer[80];
    16 static byte _iconsole_cbuffer[80];
    17 static byte _iconsole_cmdline[255];
    17 static byte _iconsole_cmdline[255];
    18 static byte _iconsole_cmdpos;
    18 static byte _iconsole_cmdpos;
    19 static byte _iconsole_mode = ICONSOLE_CLOSED;
    19 static byte _iconsole_mode = ICONSOLE_CLOSED;
    20 static byte _iconsole_color_default = 1;
       
    21 static byte _iconsole_color_error = 3;
       
    22 static byte _iconsole_color_debug = 5;
       
    23 static byte _iconsole_color_commands = 2;
       
    24 static Window *_iconsole_win = NULL;
    20 static Window *_iconsole_win = NULL;
    25 static byte _iconsole_scroll;
    21 static byte _iconsole_scroll;
       
    22 
       
    23 // ** main console cmd buffer ** // sign_de: especialy for Celestar :D
       
    24 static byte* _iconsole_cmdbuffer[20];
       
    25 static byte _iconsole_cmdbufferpos;
    26 
    26 
    27 // ** console cursor ** //
    27 // ** console cursor ** //
    28 static bool _icursor_state;
    28 static bool _icursor_state;
    29 static byte _icursor_rate;
    29 static byte _icursor_rate;
    30 static byte _icursor_counter;
    30 static byte _icursor_counter;
    31 
    31 
    32 // ** console window ** //
    32 // ** console window ** //
    33 
       
    34 static void IConsoleWndProc(Window *w, WindowEvent *e);
    33 static void IConsoleWndProc(Window *w, WindowEvent *e);
    35 static const Widget _iconsole_window_widgets[] = {{WWT_LAST}};
    34 static const Widget _iconsole_window_widgets[] = {{WWT_LAST}};
    36 static const WindowDesc _iconsole_window_desc = {
    35 static const WindowDesc _iconsole_window_desc = {
    37 	0, 0, 2, 2,
    36 	0, 0, 2, 2,
    38 	WC_CONSOLE,0,
    37 	WC_CONSOLE,0,
    40 	_iconsole_window_widgets,
    39 	_iconsole_window_widgets,
    41 	IConsoleWndProc,
    40 	IConsoleWndProc,
    42 };
    41 };
    43 
    42 
    44 // ** console parser ** //
    43 // ** console parser ** //
    45 
       
    46 static _iconsole_cmd * _iconsole_cmds; // list of registred commands
    44 static _iconsole_cmd * _iconsole_cmds; // list of registred commands
    47 static _iconsole_var * _iconsole_vars; // list of registred vars
    45 static _iconsole_var * _iconsole_vars; // list of registred vars
    48 
    46 
    49 // ** console std lib ** // 
    47 // ** console std lib ** // 
    50 static byte _stdlib_developer=1;
    48 static byte _stdlib_developer=1;
       
    49 static bool _stdlib_con_developer=false;
    51 static void IConsoleStdLibRegister();
    50 static void IConsoleStdLibRegister();
    52 
    51 
    53 /* *************** */
    52 /* *************** */
    54 /*  end of header  */
    53 /*  end of header  */
    55 /* *************** */
    54 /* *************** */
   101 			}
   100 			}
   102 		break;
   101 		break;
   103 
   102 
   104 	case WE_KEYPRESS:
   103 	case WE_KEYPRESS:
   105 		e->keypress.cont=false;
   104 		e->keypress.cont=false;
   106 		if (e->keypress.keycode == WKC_PAGEUP)
   105 		if (e->keypress.keycode == (WKC_UP))
       
   106 			{
       
   107 			IConsoleCmdBufferNavigate(+1);
       
   108 			SetWindowDirty(w);
       
   109 			} else
       
   110 		if (e->keypress.keycode == (WKC_DOWN))
       
   111 			{
       
   112 			IConsoleCmdBufferNavigate(-1);
       
   113 			SetWindowDirty(w);
       
   114 			} else
       
   115 		if (e->keypress.keycode == (WKC_SHIFT | WKC_PAGEUP))
   107 			{
   116 			{
   108 			if ((_iconsole_scroll - ((w->height/12)-1))<0) {
   117 			if ((_iconsole_scroll - ((w->height/12)-1))<0) {
   109 				_iconsole_scroll = 0;
   118 				_iconsole_scroll = 0;
   110 				} else {
   119 				} else {
   111 				_iconsole_scroll -= (w->height/12)-1;
   120 				_iconsole_scroll -= (w->height/12)-1;
   112 				}
   121 				}
   113 			SetWindowDirty(w);
   122 			SetWindowDirty(w);
   114 			} else
   123 			} else
   115 		if (e->keypress.keycode == WKC_PAGEDOWN)
   124 		if (e->keypress.keycode == (WKC_SHIFT | WKC_PAGEDOWN))
   116 			{
   125 			{
   117 			if ((_iconsole_scroll + ((w->height/12)-1))>79) {
   126 			if ((_iconsole_scroll + ((w->height/12)-1))>79) {
   118 				_iconsole_scroll = 79;
   127 				_iconsole_scroll = 79;
   119 				} else {
   128 				} else {
   120 				_iconsole_scroll += (w->height/12)-1;
   129 				_iconsole_scroll += (w->height/12)-1;
   121 				}
   130 				}
   122 			SetWindowDirty(w);
   131 			SetWindowDirty(w);
   123 			} else
   132 			} else
   124 		if (e->keypress.keycode == WKC_UP)
   133 		if (e->keypress.keycode == (WKC_SHIFT | WKC_UP))
   125 			{
   134 			{
   126 			if ((_iconsole_scroll - 1)<0) {
   135 			if ((_iconsole_scroll - 1)<0) {
   127 				_iconsole_scroll = 0;
   136 				_iconsole_scroll = 0;
   128 				} else {
   137 				} else {
   129 				_iconsole_scroll -= 1;
   138 				_iconsole_scroll -= 1;
   130 				}
   139 				}
   131 			SetWindowDirty(w);
   140 			SetWindowDirty(w);
   132 			} else
   141 			} else
   133 		if (e->keypress.keycode == WKC_DOWN)
   142 		if (e->keypress.keycode == (WKC_SHIFT | WKC_DOWN))
   134 			{
   143 			{
   135 			if ((_iconsole_scroll + 1)>79) {
   144 			if ((_iconsole_scroll + 1)>79) {
   136 				_iconsole_scroll = 79;
   145 				_iconsole_scroll = 79;
   137 				} else {
   146 				} else {
   138 				_iconsole_scroll += 1;
   147 				_iconsole_scroll += 1;
   144 			IConsoleSwitch();
   153 			IConsoleSwitch();
   145 			} else
   154 			} else
   146 		if (e->keypress.keycode == WKC_RETURN) 
   155 		if (e->keypress.keycode == WKC_RETURN) 
   147 			{
   156 			{
   148 			IConsolePrintF(_iconsole_color_commands, "] %s", _iconsole_cmdline);
   157 			IConsolePrintF(_iconsole_color_commands, "] %s", _iconsole_cmdline);
       
   158 			IConsoleCmdBufferAdd(_iconsole_cmdline);
   149 			IConsoleCmdExec((byte *) _iconsole_cmdline);
   159 			IConsoleCmdExec((byte *) _iconsole_cmdline);
   150 			IConsoleClearCommand();
   160 			IConsoleClearCommand();
   151 			} else
   161 			} else
   152 		if (e->keypress.keycode == WKC_BACKSPACE) 
   162 		if (e->keypress.keycode == WKC_BACKSPACE) 
   153 			{
   163 			{
   154 			if (_iconsole_cmdpos!=0) _iconsole_cmdpos--;
   164 			if (_iconsole_cmdpos!=0) _iconsole_cmdpos--;
   155 			_iconsole_cmdline[_iconsole_cmdpos]=0;
   165 			_iconsole_cmdline[_iconsole_cmdpos]=0;
   156 			SetWindowDirty(w);
   166 			SetWindowDirty(w);
       
   167 			_iconsole_cmdbufferpos=19;
   157 			} else
   168 			} else
   158 		if (IS_INT_INSIDE((e->keypress.ascii), 32, 256))
   169 		if (IS_INT_INSIDE((e->keypress.ascii), 32, 256))
   159 			{
   170 			{
   160 			_iconsole_scroll=79;
   171 			_iconsole_scroll=79;
   161 			_iconsole_cmdline[_iconsole_cmdpos]=e->keypress.ascii;
   172 			_iconsole_cmdline[_iconsole_cmdpos]=e->keypress.ascii;
   162 			if (_iconsole_cmdpos!=255) _iconsole_cmdpos++;	
   173 			if (_iconsole_cmdpos!=255) _iconsole_cmdpos++;	
   163 			SetWindowDirty(w);
   174 			SetWindowDirty(w);
       
   175 			_iconsole_cmdbufferpos=19;
   164 			} else e->keypress.cont=true;	
   176 			} else e->keypress.cont=true;	
   165 		break;
   177 		break;
   166 
   178 
   167 	}
   179 	}
   168 }
   180 }
   171 {
   183 {
   172 int i;
   184 int i;
   173 #if defined(WITH_REV)
   185 #if defined(WITH_REV)
   174 extern char _openttd_revision[];
   186 extern char _openttd_revision[];
   175 #endif
   187 #endif
       
   188 _iconsole_color_default = 1;
       
   189 _iconsole_color_error = 3;
       
   190 _iconsole_color_debug = 5;
       
   191 _iconsole_color_commands = 2;
   176 _iconsole_scroll=79;
   192 _iconsole_scroll=79;
       
   193 _iconsole_cmdbufferpos=19;
   177 _iconsole_inited=true;
   194 _iconsole_inited=true;
   178 _iconsole_mode=ICONSOLE_CLOSED;
   195 _iconsole_mode=ICONSOLE_CLOSED;
   179 _iconsole_win=NULL;
   196 _iconsole_win=NULL;
   180 _icursor_state=false;
   197 _icursor_state=false;
   181 _icursor_rate=5;
   198 _icursor_rate=5;
   182 _icursor_counter=0;
   199 _icursor_counter=0;
   183 for (i=0;i<80;i++) _iconsole_buffer[i]=NULL;
   200 for (i=0;i<20;i++) {
       
   201 	_iconsole_cmdbuffer[i]=NULL;
       
   202 	}
       
   203 for (i=0;i<80;i++) {
       
   204 	_iconsole_buffer[i]=NULL;
       
   205 	_iconsole_cbuffer[i]=0;
       
   206 	}
   184 IConsoleStdLibRegister();
   207 IConsoleStdLibRegister();
   185 #if defined(WITH_REV)
   208 #if defined(WITH_REV)
   186 IConsolePrintF(13,"OpenTTD Game Console %s",_openttd_revision);	
   209 IConsolePrintF(13,"OpenTTD Game Console Revision 3 - %s",_openttd_revision);	
   187 #else
   210 #else
   188 IConsolePrint(13,"OpenTTD Game Console");	
   211 IConsolePrint(13,"OpenTTD Game Console Revision 3");	
   189 #endif
   212 #endif
   190 IConsolePrint(12,"---------------------------------");
   213 IConsolePrint(12,"---------------------------------");
   191 IConsolePrint(12,"use \"help\" for more info");
   214 IConsolePrint(12,"use \"help\" for more info");
   192 IConsolePrint(12,"");
   215 IConsolePrint(12,"");
   193 IConsoleClearCommand();
   216 IConsoleClearCommand();
       
   217 IConsoleCmdBufferAdd("");
   194 }
   218 }
   195 
   219 
   196 void IConsoleClear()
   220 void IConsoleClear()
   197 {
   221 {
   198 int i;
   222 int i;
   239 
   263 
   240 void IConsoleOpen() {
   264 void IConsoleOpen() {
   241 if (_iconsole_mode==ICONSOLE_CLOSED) IConsoleSwitch();
   265 if (_iconsole_mode==ICONSOLE_CLOSED) IConsoleSwitch();
   242 }
   266 }
   243 
   267 
       
   268 void IConsoleCmdBufferAdd(byte * cmd) {
       
   269 int i;
       
   270 if (_iconsole_cmdbufferpos != 19) return;
       
   271 if (_iconsole_cmdbuffer[18]!=NULL) free(_iconsole_cmdbuffer[18]);
       
   272 for (i=18; i>0; i--) _iconsole_cmdbuffer[i]=_iconsole_cmdbuffer[i-1];
       
   273 i=strlen((char *)cmd);
       
   274 _iconsole_cmdbuffer[0]=malloc(i+1);
       
   275 memset(((void *)_iconsole_cmdbuffer[0]),0,i+1);
       
   276 memcpy(((void *)_iconsole_cmdbuffer[0]),(void *)cmd,i);
       
   277 _iconsole_cmdbuffer[0][i]=0;
       
   278 _iconsole_cmdbufferpos = 19;
       
   279 }
       
   280 
       
   281 void IConsoleCmdBufferNavigate(signed char direction) {
       
   282 int i;
       
   283 i=_iconsole_cmdbufferpos + direction;
       
   284 if (i<0) i=19;
       
   285 if (i>19) i=0;
       
   286 if (direction>0) while (_iconsole_cmdbuffer[i]==NULL) {
       
   287 	i++;
       
   288 	if (i>19) i=0;
       
   289 	}
       
   290 if (direction<0) while (_iconsole_cmdbuffer[i]==NULL) {
       
   291 	i--;
       
   292 	if (i<0) i=19;
       
   293 	}
       
   294 _iconsole_cmdbufferpos = i;
       
   295 IConsoleClearCommand();
       
   296 memcpy((void *)_iconsole_cmdline,(void *)_iconsole_cmdbuffer[i],strlen(_iconsole_cmdbuffer[i]));
       
   297 _iconsole_cmdpos =strlen(_iconsole_cmdbuffer[i]);
       
   298 }
       
   299 
   244 void IConsolePrint(byte color_code, byte* string)
   300 void IConsolePrint(byte color_code, byte* string)
   245 {
   301 {
   246 byte * _ex;
   302 byte * _ex;
   247 byte * _new;
   303 byte * _new;
   248 byte _exc;
   304 byte _exc;
   250 int i,j;
   306 int i,j;
   251 
   307 
   252 if (!_iconsole_inited) return;
   308 if (!_iconsole_inited) return;
   253 
   309 
   254 _newc=color_code;
   310 _newc=color_code;
   255 
       
   256 i=strlen((char *)string);
   311 i=strlen((char *)string);
   257 _new=malloc(i+1);
   312 _new=malloc(i+1);
   258 memset(_new,0,i+1);
   313 memset(_new,0,i+1);
   259 memcpy(_new,string,i);
   314 memcpy(_new,string,i);
   260 
   315 
   468 }
   523 }
   469 
   524 
   470 void IConsoleVarSetString(_iconsole_var * var, byte * string) {
   525 void IConsoleVarSetString(_iconsole_var * var, byte * string) {
   471 int l;
   526 int l;
   472 
   527 
       
   528 if (string == NULL) return;
       
   529 
   473 if (var->_malloc) {
   530 if (var->_malloc) {
   474 	free(var->addr);
   531 	free(var->addr);
   475 	}
   532 	}
   476 
   533 
   477 l=strlen((char *) string);
   534 l=strlen((char *) string);
   573 		case ICONSOLE_VAR_STRING:
   630 		case ICONSOLE_VAR_STRING:
   574 				{
   631 				{
   575 				var_s=(byte *)var->addr;
   632 				var_s=(byte *)var->addr;
   576 				IConsolePrintF(_iconsole_color_default, "%s = %s",dump_desc,var_s);
   633 				IConsolePrintF(_iconsole_color_default, "%s = %s",dump_desc,var_s);
   577 				}
   634 				}
       
   635 				break;
       
   636 		case ICONSOLE_VAR_REFERENCE:
       
   637 				IConsolePrintF(_iconsole_color_default, "%s = @%s",dump_desc,((_iconsole_var *)var->addr)->name);
   578 				break;
   638 				break;
   579 		case ICONSOLE_VAR_UNKNOWN:
   639 		case ICONSOLE_VAR_UNKNOWN:
   580 		case ICONSOLE_VAR_POINTER:
   640 		case ICONSOLE_VAR_POINTER:
   581 				{
   641 				{
   582 				var_i32=(signed int)((byte *)var->addr);
   642 				var_i32=(signed int)((byte *)var->addr);
   672 	}
   732 	}
   673 
   733 
   674 //** interpreting **//
   734 //** interpreting **//
   675 
   735 
   676 for (i=0; i<c; i++) {
   736 for (i=0; i<c; i++) {
   677 	if (i>0) if (strlen((char *) tokens[i])>0) {
   737 	tokentypes[i]=ICONSOLE_VAR_UNKNOWN;
   678 		tokentypes[i]=ICONSOLE_VAR_UNKNOWN;
   738 	if (tokens[i]!=NULL) if (i>0) if (strlen((char *) tokens[i])>0) {
   679 		if (tokens[i][0]=='*') {
   739 		if (tokens[i][0]=='*') {
   680 			var = IConsoleVarGet(tokens[i]);
   740 			if ((i==2) && (tokentypes[1]==ICONSOLE_VAR_UNKNOWN) && (strcmp(tokens[1],"<<")==0)) {
       
   741 				// dont change the variable to an pointer if execution_mode 4 is being prepared
       
   742 				// this is used to assign one variable the value of the other one [token 0 and 2]
       
   743 				} else {
       
   744 				var = IConsoleVarGet(tokens[i]);
       
   745 				if (var!=NULL) {
       
   746 					tokens[i]=(byte *)var->addr;
       
   747 					tokentypes[i]=var->type;
       
   748 					}
       
   749 				}
       
   750 			}
       
   751 		if (tokens[i]!=NULL) if (tokens[i][0]=='@') if (tokens[i][1]=='*') {
       
   752 			var = IConsoleVarGet(tokens[i]+1);
   681 			if (var!=NULL) {
   753 			if (var!=NULL) {
   682 				tokens[i]=(byte *)var->addr;
   754 				tokens[i]=(byte *)var;
   683 				tokentypes[i]=var->type;
   755 				tokentypes[i]=ICONSOLE_VAR_REFERENCE;
   684 				}
   756 				}
   685 			}
   757 			}
   686 		}
   758 		}
   687 	}
   759 	}
   688 
   760 
   698 		if (c>2) if (strcmp(tokens[1],"<<")==0) {
   770 		if (c>2) if (strcmp(tokens[1],"<<")==0) {
   699 			// this is command to variable mode [normal]
   771 			// this is command to variable mode [normal]
   700 			function = IConsoleCmdGetAddr(tokens[2]);
   772 			function = IConsoleCmdGetAddr(tokens[2]);
   701 			if (function != NULL) {
   773 			if (function != NULL) {
   702 				execution_mode=3;
   774 				execution_mode=3;
       
   775 				} else {
       
   776 				result = IConsoleVarGet(tokens[2]);
       
   777 				if (result != NULL) {
       
   778 					execution_mode=4;
       
   779 					}
   703 				}
   780 				}
   704 			}
   781 			}
   705 		}
   782 		}
   706 	}
   783 	}
   707 
   784 
   708 //** executing **//
   785 //** executing **//
   709 
   786 if (_stdlib_con_developer) IConsolePrintF(_iconsole_color_debug,"CONDEBUG: execution_mode: %i",execution_mode);
   710 switch (execution_mode) {
   787 switch (execution_mode) {
   711 case 0: 
   788 case 0: 
   712 	{
   789 	{
   713 	// not found
   790 	// not found
   714 	IConsoleError("command or variable not found");
   791 	IConsoleError("command or variable not found");
   725 	}
   802 	}
   726 	break;
   803 	break;
   727 case 2:
   804 case 2:
   728 	{
   805 	{
   729 	// execution with variable syntax
   806 	// execution with variable syntax
   730 if ((c==2) || (c==3)) {
   807 	if ((c==2) || (c==3)) {
   731 		// ** variable modifications ** //
   808 		// ** variable modifications ** //
   732 		switch (var->type) {
   809 		switch (var->type) {
   733 		case ICONSOLE_VAR_BOOLEAN:
   810 		case ICONSOLE_VAR_BOOLEAN:
   734 				{
   811 				{
   735 				if (strcmp(tokens[1],"=")==0) {
   812 				if (strcmp(tokens[1],"=")==0) {
   909 		IConsoleVarDump(var,NULL);
   986 		IConsoleVarDump(var,NULL);
   910 		}
   987 		}
   911 	}
   988 	}
   912 	break;
   989 	break;
   913 case 3:
   990 case 3:
       
   991 case 4:
   914 	{
   992 	{
   915 	// execute command with result
   993 	// execute command with result or assign a variable
   916 		{
   994 	if (execution_mode==3) {
   917 		int i;
   995 		int i;
   918 		int diff;
   996 		int diff;
   919 		void * temp;
   997 		void * temp;
   920 		byte temp2;
   998 		byte temp2;
   921 
   999 
       
  1000 		// tokenshifting
   922 		for (diff=0; diff<2; diff++) {
  1001 		for (diff=0; diff<2; diff++) {
   923 			temp=tokens[0];
  1002 			temp=tokens[0];
   924 			temp2=tokentypes[0];
  1003 			temp2=tokentypes[0];
   925 			for (i=1; i<20; i++) {
  1004 			for (i=1; i<20; i++) {
   926 				tokens[i-1]=tokens[i];
  1005 				tokens[i-1]=tokens[i];
   927 				tokentypes[i-1]=tokentypes[i];
  1006 				tokentypes[i-1]=tokentypes[i];
   928 				}
  1007 				}
   929 			tokens[19]=temp;
  1008 			tokens[19]=temp;
   930 			tokentypes[19]=temp2;
  1009 			tokentypes[19]=temp2;
   931 			}
  1010 			}
   932 		}
  1011 
   933 
  1012 		result = function(c,tokens,tokentypes);
   934 	result = function(c,tokens,tokentypes);
  1013 		}
       
  1014 
   935 	if (result!=NULL) {
  1015 	if (result!=NULL) {
   936 		if (result ->type != var -> type) {
  1016 		if (result ->type != var -> type) {
   937 			IConsoleError("variable type missmatch");
  1017 			IConsoleError("variable type missmatch");
   938 			} else {
  1018 			} else {
   939 			switch (result->type) {
  1019 			switch (result->type) {
   977 				{
  1057 				{
   978 				var->addr=result->addr;
  1058 				var->addr=result->addr;
   979 				IConsoleVarDump(var,NULL);
  1059 				IConsoleVarDump(var,NULL);
   980 				}
  1060 				}
   981 				break;
  1061 				break;
       
  1062 			case ICONSOLE_VAR_STRING:
       
  1063 				{
       
  1064 				IConsoleVarSetString(var,result->addr);
       
  1065 				IConsoleVarDump(var,NULL);
       
  1066 				}
       
  1067 				break;
   982 			default:
  1068 			default:
   983 				{
  1069 				{
   984 				IConsoleError("variable type missmatch");
  1070 				IConsoleError("variable type missmatch");
   985 				}
  1071 				}
   986 				break;
  1072 				break;
   987 				}
  1073 				}
       
  1074 			}
       
  1075 
       
  1076 		if (execution_mode==3) {
       
  1077 			IConsoleVarFree(result);
       
  1078 			result = NULL;
   988 			}
  1079 			}
   989 		}
  1080 		}
   990 	
  1081 	
   991 	}
  1082 	}
   992 	break;
  1083 	break;
  1038 		_make_screenshot=1;
  1129 		_make_screenshot=1;
  1039 	} else {
  1130 	} else {
  1040 		if (strcmp(argv[1],"big")==0) {
  1131 		if (strcmp(argv[1],"big")==0) {
  1041 			_make_screenshot=2;
  1132 			_make_screenshot=2;
  1042 			}
  1133 			}
  1043 		}
  1134 		if (strcmp(argv[1],"no_con")==0) {
  1044 
  1135 			IConsoleClose();
       
  1136 			_make_screenshot=1;
       
  1137 			}
       
  1138 		}
       
  1139 
       
  1140 return NULL;
       
  1141 }
       
  1142 
       
  1143 static _iconsole_var * IConsoleStdLibVarInfo(byte argc, byte* argv[], byte argt[]) {
       
  1144 if (argc<2) return NULL;
       
  1145 if (argt[1]!=ICONSOLE_VAR_REFERENCE) {
       
  1146 	IConsoleError("variable must be an variable reference");
       
  1147 	} else {
       
  1148     _iconsole_var * item;
       
  1149     item = (_iconsole_var *) argv[1];
       
  1150 	IConsolePrintF(_iconsole_color_default,"variable_name: %s",item->name);
       
  1151 	IConsolePrintF(_iconsole_color_default,"variable_type: %i",item->type);
       
  1152 	IConsolePrintF(_iconsole_color_default,"variable_addr: %i",item->addr);
       
  1153 	if (item->_malloc) IConsolePrintF(_iconsole_color_default,"variable_malloc: internal allocated"); else IConsolePrintF(_iconsole_color_default, "variable_malloc: external allocated");
       
  1154 	}
  1045 return NULL;
  1155 return NULL;
  1046 }
  1156 }
  1047 
  1157 
  1048 static _iconsole_var * IConsoleStdLibDebugLevel(byte argc, byte* argv[], byte argt[]) {
  1158 static _iconsole_var * IConsoleStdLibDebugLevel(byte argc, byte* argv[], byte argt[]) {
  1049 	if (argc<2) return NULL;
  1159 	if (argc<2) return NULL;
  1055 	_exit_game = true;
  1165 	_exit_game = true;
  1056 	return NULL;
  1166 	return NULL;
  1057 }
  1167 }
  1058 
  1168 
  1059 static _iconsole_var * IConsoleStdLibHelp(byte argc, byte* argv[], byte argt[]) {
  1169 static _iconsole_var * IConsoleStdLibHelp(byte argc, byte* argv[], byte argt[]) {
  1060 	IConsolePrint(1		,"");
       
  1061 	IConsolePrint(13	," -- console help -- ");
  1170 	IConsolePrint(13	," -- console help -- ");
  1062 	IConsolePrint(1		," variables: [command to list them: list_vars]");
  1171 	IConsolePrint(1		," variables: [command to list them: list_vars]");
  1063 	IConsolePrint(1		," *temp_string = \"my little \"");
  1172 	IConsolePrint(1		," *temp_string = \"my little \"");
  1064 	IConsolePrint(1		,"");
  1173 	IConsolePrint(1		,"");
  1065 	IConsolePrint(1		," commands: [command to list them: list_cmds]");
  1174 	IConsolePrint(1		," commands: [command to list them: list_cmds]");
  1066 	IConsolePrint(1		," [command] [\"string argument with spaces\"] [argument 2] ...");
  1175 	IConsolePrint(1		," [command] [\"string argument with spaces\"] [argument 2] ...");
  1067 	IConsolePrint(1		," printf \"%s world\" *temp_string");
  1176 	IConsolePrint(1		," printf \"%s world\" *temp_string");
  1068 	IConsolePrint(1		,"");
  1177 	IConsolePrint(1		,"");
  1069 	IConsolePrint(1		," command returning a value into an variable:");
  1178 	IConsolePrint(1		," command/variable returning a value into an variable:");
  1070 	IConsolePrint(1		," *temp_uint16 << random");
  1179 	IConsolePrint(1		," *temp_uint16 << random");
       
  1180 	IConsolePrint(1		," *temp_uint16 << *temp_uint16_2");
  1071 	IConsolePrint(1		,"");
  1181 	IConsolePrint(1		,"");
  1072 return NULL;
  1182 return NULL;
  1073 }
  1183 }
  1074 
  1184 
  1075 static _iconsole_var * IConsoleStdLibRandom(byte argc, byte* argv[], byte argt[]) {
  1185 static _iconsole_var * IConsoleStdLibRandom(byte argc, byte* argv[], byte argt[]) {
  1151 return NULL;
  1261 return NULL;
  1152 }
  1262 }
  1153 
  1263 
  1154 static void IConsoleStdLibRegister() {
  1264 static void IConsoleStdLibRegister() {
  1155 	IConsoleCmdRegister("debug_level",IConsoleStdLibDebugLevel);
  1265 	IConsoleCmdRegister("debug_level",IConsoleStdLibDebugLevel);
       
  1266 	IConsoleCmdRegister("dump_vars",IConsoleStdLibListDumpVariables);
  1156 	IConsoleCmdRegister("echo",IConsoleStdLibEcho);
  1267 	IConsoleCmdRegister("echo",IConsoleStdLibEcho);
  1157 	IConsoleCmdRegister("echoc",IConsoleStdLibEchoC);
  1268 	IConsoleCmdRegister("echoc",IConsoleStdLibEchoC);
  1158 	IConsoleCmdRegister("exit",IConsoleStdLibExit);
  1269 	IConsoleCmdRegister("exit",IConsoleStdLibExit);
  1159 	IConsoleCmdRegister("help",IConsoleStdLibHelp);
  1270 	IConsoleCmdRegister("help",IConsoleStdLibHelp);
  1160 	IConsoleCmdRegister("printf",IConsoleStdLibPrintF);
  1271 	IConsoleCmdRegister("printf",IConsoleStdLibPrintF);
  1161 	IConsoleCmdRegister("printfc",IConsoleStdLibPrintFC);
  1272 	IConsoleCmdRegister("printfc",IConsoleStdLibPrintFC);
  1162 	IConsoleCmdRegister("quit",IConsoleStdLibExit);
  1273 	IConsoleCmdRegister("quit",IConsoleStdLibExit);
  1163 	IConsoleCmdRegister("random",IConsoleStdLibRandom);
  1274 	IConsoleCmdRegister("random",IConsoleStdLibRandom);
  1164 	IConsoleCmdRegister("list_cmds",IConsoleStdLibListCommands);
  1275 	IConsoleCmdRegister("list_cmds",IConsoleStdLibListCommands);
  1165 	IConsoleCmdRegister("list_vars",IConsoleStdLibListVariables);
  1276 	IConsoleCmdRegister("list_vars",IConsoleStdLibListVariables);
  1166 	IConsoleCmdRegister("dump_vars",IConsoleStdLibListDumpVariables);
       
  1167 	IConsoleCmdRegister("screenshot",IConsoleStdLibScreenShot);
  1277 	IConsoleCmdRegister("screenshot",IConsoleStdLibScreenShot);
       
  1278 	IConsoleCmdRegister("varinfo",IConsoleStdLibVarInfo);
  1168 	IConsoleVarRegister("cursor_rate",(void *) &_icursor_rate,ICONSOLE_VAR_BYTE);
  1279 	IConsoleVarRegister("cursor_rate",(void *) &_icursor_rate,ICONSOLE_VAR_BYTE);
       
  1280 	IConsoleVarRegister("con_developer",(void *) &_stdlib_con_developer,ICONSOLE_VAR_BOOLEAN);
  1169 	IConsoleVarRegister("developer",(void *) &_stdlib_developer,ICONSOLE_VAR_BYTE);
  1281 	IConsoleVarRegister("developer",(void *) &_stdlib_developer,ICONSOLE_VAR_BYTE);
  1170 #if defined(_DEBUG)
  1282 #if defined(_DEBUG)
  1171 	{
  1283 	{
  1172 	_iconsole_var * var;
  1284 	_iconsole_var * var;
  1173 	var = IConsoleVarAlloc(ICONSOLE_VAR_BOOLEAN);
  1285 	var = IConsoleVarAlloc(ICONSOLE_VAR_BOOLEAN);
  1181 	var = IConsoleVarAlloc(ICONSOLE_VAR_POINTER);
  1293 	var = IConsoleVarAlloc(ICONSOLE_VAR_POINTER);
  1182 	IConsoleVarInsert(var,"temp_pointer");
  1294 	IConsoleVarInsert(var,"temp_pointer");
  1183 
  1295 
  1184 	var = IConsoleVarAlloc(ICONSOLE_VAR_UINT16);
  1296 	var = IConsoleVarAlloc(ICONSOLE_VAR_UINT16);
  1185 	IConsoleVarInsert(var,"temp_uint16");
  1297 	IConsoleVarInsert(var,"temp_uint16");
       
  1298 	var = IConsoleVarAlloc(ICONSOLE_VAR_UINT16);
       
  1299 	IConsoleVarInsert(var,"temp_uint16_2");
  1186 	var = IConsoleVarAlloc(ICONSOLE_VAR_UINT32);
  1300 	var = IConsoleVarAlloc(ICONSOLE_VAR_UINT32);
  1187 	IConsoleVarInsert(var,"temp_uint32");
  1301 	IConsoleVarInsert(var,"temp_uint32");
  1188 
  1302 
  1189 	var = IConsoleVarAlloc(ICONSOLE_VAR_STRING);
  1303 	var = IConsoleVarAlloc(ICONSOLE_VAR_STRING);
  1190 	IConsoleVarInsert(var,"temp_string");
  1304 	IConsoleVarInsert(var,"temp_string");
       
  1305 	var = IConsoleVarAlloc(ICONSOLE_VAR_STRING);
       
  1306 	IConsoleVarInsert(var,"temp_string2");
  1191 	}
  1307 	}
  1192 #endif
  1308 #endif
  1193 }
  1309 }
  1194 
  1310 
  1195 
  1311