Spoiler:
Code: Select all
#include <stdio.h>
#include <string.h>
#include <kolibrisys.h>
char* dllname="/sys/lib/console.obj";
int i;
char* imports[] = {"START","version","con_init","con_write_asciiz","con_printf","con_exit",NULL};
char* caption = "Console test - colors";
dword (* dll_start)(dword res);
dword* dll_ver;
void stdcall (* con_init)(dword wnd_width, dword wnd_height, dword scr_width, dword scr_height, const char* title);
void stdcall (* con_write_asciiz)(const char* string);
void cdecl (* con_printf)(const char* format,...);
void stdcall (* con_exit)(dword bCloseWindow);
struct import{
char *name;
void *data;
};
void link(struct import *exp, char** imports){
dll_start = (dword (*)(dword))
_ksys_cofflib_getproc(exp, imports[0]);
dll_ver = (dword*)
_ksys_cofflib_getproc(exp, imports[1]);
con_init = (void stdcall (*)(dword , dword, dword, dword, const char*))
_ksys_cofflib_getproc(exp, imports[2]);
con_write_asciiz = (void stdcall (*)(const char*))
_ksys_cofflib_getproc(exp, imports[3]);
con_printf = (void cdecl (*)(const char*,...))
_ksys_cofflib_getproc(exp, imports[4]);
con_exit = (void stdcall (*)(dword))
_ksys_cofflib_getproc(exp, imports[5]);
}
int main(int argc, char **argv){
struct import * hDll;
int a,b,c,d;
if((hDll = (struct import *)_ksys_cofflib_load(dllname)) == 0){
debug_out_str("can't load lib\n");
return 1;
}
link(hDll, imports);
debug_out_str("dll loaded\n");
if(dll_start(1) == 0){
debug_out_str("dll_start failed\n");
return 1;
}
con_init(-1, -1, -1, -1, caption);
char lab[20] [20],key;
int x,y,a,b,c,kolvo=0;
con_printf("\n ⥬ â¨ç¥áª¨© « ¡¨à¨â.");
con_printf("\n\n ¤ ç ¤®©â¨ ¤® æ¥âà « ¡¨à¨â .");
con_printf("\n è¥ ¬¥á⮯®«®¦¥¨¥ ®¡®§ 祮 §¢ñ§¤®çª®©.");
con_printf("\n¯à ¢«¥¨¥ w-¢¢¥àå, s-¢¨§, d-¢¯à ¢®, a-¢«¥¢®, esc - ¢ë室");
con_printf("\n¥ªã饥 ª®«¨ç¥á⢮ è £®¢ 㪠§ ® ¢¨§ã, ¢ áâப¥ ' £®¢:'");
con_printf("\n\n«ï ç « ¦¬¨â¥ «î¡ãî ª« ¢¨èã....\n\n");
key=con_getch();
newlab:
for (x=0;x<20;x++)
for (y=0;y<20;y++)
lab[x] [y]=1+rand()%9;
lab[10] [10]=0;
x=0;y=0;
nextstep:
kolvo++;
for (a=0;a<20;a++)
{for (b=0;b<20;b++)
if (a==y && b==x) con_printf("* ");
else if (lab[b] [a]==0)
con_printf(" ");
else {c=lab[b] [a];
con_printf("%d ",c);
}
con_printf("\n");
}
a=lab [x] [y];
con_printf("\n £®¢: %d \n", a);
if (lab [x] [y]==0)
{
con_printf("çñâ: %d ®çª®¢.",1000/kolvo);
con_printf("\nᥣ® 室®¢: %d \n",kolvo);
con_printf("\n\n«ï § ¯ã᪠¦¬¨â¥ «î¡ãî ª« ¢¨èã....\n");
key = con_getch();
kolvo=0;
goto newlab;
}
getkey:
key=con_getch();
if (key=='a')
if (x-lab[x] [y]>=0)
x=x-lab[x] [y];
else goto getkey;
if (key=='d')
if (x+lab[x] [y]<=19)
x=x+lab[x] [y];
else goto getkey;
if (key=='w')
if (y-lab[x] [y]>=0)
y=y-lab[x] [y];
else goto getkey;
if (key=='s')
if (y+lab[x] [y]<=19)
y=y+lab[x] [y];
else goto getkey;
if (key==27)
return 0;
goto nextstep;
con_exit(0);
debug_out_str("all right's ;)\n");
return 0;
}
1) выдаёт на функцию getch() сообщение "Ошибка: неподдерживаемая инструкция процесора";
2) зависает (скорей всего при обращении к многомерному массиву) с выводом на доску сообщения
Code: Select all
K : Process - forced terminate PID: 00000019 [matlab]
K : Undefined Exception
K : EAX : 00000028 EBX : 0000000B ECX : 7002C845
K : EDX : 7002D767 ESI : 00000902 EDI : 00000000
K : EBP : 00002360 EIP : 00000284 ESP : 0000219C
K : Flags : 00011216 CS : 0000001B (application)
K : Stack dump:
K : [ESP+00]: 00000287 [ESP+04]: 00000000 [ESP+08]: 00000000
K : [ESP+12]: 00000000 [ESP+16]: 00000000 [ESP+20]: 00000000
K : [ESP+24]: 00000000 [ESP+28]: 00000000 [ESP+32]: 00000000