Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 4555 → Rev 4556

/programs/games/foxhunt/all.h
0,0 → 1,16
 
#include "system/boolean.h"
#include "system/kolibri.h"
#include "system/stdlib.h"
#include "system/string.h"
#include "system/ctype.h"
 
#include "globals.h"
 
 
void init_board();
void init_grid_sizes();
void wnd_draw();
void grid_to_pos(unsigned gx, unsigned gy, unsigned* x, unsigned* y);
int pos_to_grid(unsigned x, unsigned y, int* gx, int* gy);
int check();
/programs/games/foxhunt/compile.bat
0,0 → 1,12
@echo off
fasm start.asm start.o
gcc -c -fno-builtin foxhunt.c
gcc -c -fno-builtin system/kolibri.c
gcc -c -fno-builtin system/stdlib.c
gcc -c -fno-builtin system/string.c
gcc -c -fno-builtin system/ctype.c
ld -nostdlib -T kolibri.ld -o FOXHUNT start.o kolibri.o stdlib.o string.o ctype.o foxhunt.o
objcopy FOXHUNT -O binary
erase start.o foxhunt.o kolibri.o stdlib.o string.o ctype.o
kpack FOXHUNT
pause
/programs/games/foxhunt/foxhunt.c
0,0 → 1,334
 
#include "all.h"
 
void init_board()
{
int i, x, y, z;
int x1, y1;
 
for (x = 0; x < 8; x++)
for (y = 0; y < 8; y++)
for (z = 0; z < 4; z++)
board[x][y][z] = 0;
 
for (i = 0; i < 4; i++)
board[rand()%8][rand()%8][LAY_HIDDEN] = 1;
 
foxN = 0;
for (x = 0; x < 8; x++)
for (y = 0; y < 8; y++)
if (board[x][y][LAY_HIDDEN] == 1)
foxN++;
 
if (foxN < 4) // if some foxes are in one hole
{
init_board();
return;
}
 
// count of visible foxes
for (x = 0; x < 8; x++)
for (y = 0; y < 8; y++)
{
 
for (x1 = 0; x1 < 8; x1++) // horizontal
if (board[x1][y][LAY_HIDDEN] == 1)
board[x][y][LAY_NUM]++;
 
for (y1 = 0; y1 < 8; y1++) // vertical
if (board[x][y1][LAY_HIDDEN] == 1)
board[x][y][LAY_NUM]++;
 
 
if (x-y>0) // north-west to south-east
x1 = x-y;
else
x1 = 0;
 
if (y-x>0)
y1 = y-x;
else
y1 = 0;
do
{
if (board[x1][y1][LAY_HIDDEN] == 1)
board[x][y][LAY_NUM]++;
x1++;
y1++;
} while ((x1<8)&&(y1<8));
 
if (x+y-7>0) // south-west to north-east
x1 = x+y-7;
else
x1 = 0;
 
if (x+y<8)
y1 = x+y;
else
y1 = 7;
do
{
if (board[x1][y1][LAY_HIDDEN] == 1)
board[x][y][LAY_NUM]++;
x1++;
y1--;
} while ((x1<8)&&(y1>-1));
if (board[x][y][LAY_HIDDEN] == 1)
board[x][y][LAY_NUM] -= 3;
}
 
foxLeft = foxN;
moves = 0;
result = 0;
}
 
void init_grid_sizes()
{
size = 20;
x_start = 5;
y_start = 30;
window_width = 2*x_start + 8*size + 9;
window_height = y_start + x_start + 8*size + kol_skin_height() + 9 + 14;
}
 
void wnd_draw()
{
 
int i;
int x, y;
int x1, y1;
char tmp[64];
char tmp2[64];
 
kol_paint_start();
 
kol_wnd_define(100, 100, window_width, window_height, 0x34ddddff, 0x34ddddff, "FoxHunt v0.2 by Albom");
 
kol_btn_define(x_start, x_start, 40, 16, 2, 0xccccee);
kol_paint_string(x_start+20-12, x_start+5, "New", 0x902222ff);
 
strcpy(tmp, "F:");
itoa(foxLeft, tmp2);
strcat(tmp, tmp2);
strcat(tmp, "/4");
kol_paint_string(x_start+55, x_start+5, tmp, 0x902222ff);
 
strcpy(tmp, "M:");
itoa(moves, tmp2);
strcat(tmp, tmp2);
kol_paint_string(x_start+110, x_start+5, tmp, 0x902222ff);
 
for (i = 0; i <= 8; i++)
{
kol_paint_line(x_start+i*size, y_start, x_start+i*size, y_start+8*size, 0x33); // vertical
kol_paint_line(x_start, y_start+i*size, x_start+8*size, y_start+i*size, 0x33); // horizontal
}
 
// foxes found by user
for (x1 = 0; x1 < 8; x1++)
for (y1 = 0; y1 < 8; y1++)
{
if (board[x1][y1][LAY_FOUND]==1)
{
grid_to_pos(x1, y1, &x, &y);
kol_paint_string(x+size/2-4, y+size/2-4, "F", 0x90227722);
}
}
 
// opened cells
for (x1 = 0; x1 < 8; x1++)
for (y1 = 0; y1 < 8; y1++)
{
if (board[x1][y1][LAY_OPENED] == 1)
{
itoa(board[x1][y1][LAY_NUM], tmp);
grid_to_pos(x1, y1, &x, &y);
kol_paint_string(x+size/2-4, y+size/2-4, tmp, 0x902222ff);
}
}
if (result > 0)
{
char victory[]={"V I C T O R Y !"};
kol_paint_string(window_width/2-7*8+4, window_height-14-kol_skin_height()-4, victory, 0x90227722);
kol_paint_string(window_width/2-7*8+4-1, window_height-14-kol_skin_height()-4, victory, 0x90227722);
kol_paint_string(window_width/2-7*8+4+1, window_height-14-kol_skin_height()-4, victory, 0x90227722);
}
 
if (result < 0)
{
 
// draw real position of foxes
for (x1 = 0; x1 < 8; x1++)
for (y1 = 0; y1 < 8; y1++)
{
if (board[x1][y1][LAY_HIDDEN]==1)
{
grid_to_pos(x1, y1, &x, &y);
kol_paint_string(x+size/2-2, y+size/2-2, "F", 0x90ff2222);
}
}
char game_over[]={"G A M E O V E R !"};
kol_paint_string(window_width/2-9*8+4, window_height-14-kol_skin_height()-4, game_over, 0x90ff2222);
kol_paint_string(window_width/2-9*8+4-1, window_height-14-kol_skin_height()-4, game_over, 0x90ff2222);
kol_paint_string(window_width/2-9*8+4+1, window_height-14-kol_skin_height()-4, game_over, 0x90ff2222);
}
kol_paint_end();
 
 
 
}
 
 
int check()
{
int x, y;
for (x = 0; x < 8; x++)
for (y = 0; y < 8; y++)
if (board[x][y][LAY_HIDDEN] != board[x][y][LAY_FOUND])
return -1;
return 1;
}
 
 
void grid_to_pos(unsigned gx, unsigned gy, unsigned* x, unsigned* y)
{
*x = gx*size + x_start;
*y = gy*size + y_start;
}
 
 
int pos_to_grid(unsigned x, unsigned y, int* gx, int* gy)
{
 
*gx = (x - x_start)/size;
*gy = (y - y_start)/size;
 
if ((*gx < 0) || (*gx>7) || (*gy < 0) || (*gy>7) )
return -1;
else
return 1;
}
 
 
/// ===========================================================
 
void kol_main()
{
 
unsigned event;
unsigned key;
unsigned btn;
unsigned pos, x, y;
int gx, gy;
 
 
srand(kol_system_time_get());
 
kol_event_mask( 0xC0000027 ); // enable using of mouse
init_grid_sizes();
init_board();
wnd_draw();
 
 
for(;;)
{
event = kol_event_wait();
 
switch (event)
{
case 1:
wnd_draw();
break;
 
case 2:
key = (kol_key_get() & 0xff00)>>8;
break;
case 3:
switch ((kol_btn_get() & 0xff00)>>8)
{
case 1: // close button
kol_exit();
case 2: // 'new' button
init_board();
wnd_draw();
break;
}
break;
case 6:
btn = kol_mouse_btn(); // read mouse button
pos = kol_mouse_posw(); // read mouse position
x = pos / 65536;
y = pos % 65536;
if (x > window_width)
x=0;
if (y > window_height)
y=0;
 
if ( pos_to_grid(x, y, &gx, &gy) > 0 )
{
switch (btn & 3)
{
case 1: // left button
if (result == 0) // are we in game?
{
if (board[gx][gy][LAY_FOUND] == 0)
{
if ( board[gx][gy][LAY_OPENED] == 0 )
board[gx][gy][LAY_OPENED] = 1;
else
board[gx][gy][LAY_OPENED] = 0;
moves++;
wnd_draw();
}
}
break;
case 2: // right button
if (result == 0) // are we in game?
{
if (board[gx][gy][LAY_FOUND] == 0)
{
if ( board[gx][gy][LAY_OPENED] == 0 )
{
board[gx][gy][LAY_FOUND] = 1;
foxLeft--;
moves++;
}
}
else
{
board[gx][gy][LAY_FOUND] = 0;
foxLeft++;
moves++;
}
if (foxLeft == 0) // all 4 foxes are marked
result = check();
wnd_draw();
}
break;
}
}
break;
}
 
}
 
kol_exit();
}
 
/// ===========================================================
/programs/games/foxhunt/globals.h
0,0 → 1,20
 
#define LAY_HIDDEN 0
#define LAY_NUM 1
#define LAY_FOUND 2
#define LAY_OPENED 3
 
extern char PATH[256];
extern char PARAM[256];
 
int window_width, window_height;
int x_start, y_start;
int size;
 
char board[8][8][4];
 
int foxN;
int foxLeft;
int moves;
 
int result;
/programs/games/foxhunt/kolibri.ld
0,0 → 1,20
/*OUTPUT_FORMAT("binary")*/
ENTRY(Start)
SECTIONS
{
.text 0x000000:
{
*(.text)
}
.data : {
*(.data)
hEnd = . ;
}
.bss :
{
*(.bss)
}
Memory = . ;
}
/programs/games/foxhunt/start.asm
0,0 → 1,41
 
format MS COFF
 
public Start
public _PATH
public _PARAM
 
extrn Memory
extrn hEnd
 
extrn _kol_main
 
section ".text" code
db "MENUET01"
dd 1, Start, hEnd, Memory, hStack, _PARAM, _PATH
 
Start:
 
; èíèöèàëèçàöèÿ êó÷è
mov eax, 68
mov ebx, 11
int 0x40
 
; âûçîâ ãëàâíîé ïðîöåäóðû
mov eax, _kol_main
call eax
 
; çàâåðøåíèå ðàáîòû ïðîãðàììû
mov eax, -1
int 0x40
 
section ".bss"
 
_PARAM:
rb 256
 
_PATH:
rb 256
 
rb 8*1024
hStack:
/programs/games/foxhunt/system/boolean.h
0,0 → 1,3
 
#define FALSE 0
#define TRUE 1
/programs/games/foxhunt/system/console.c
0,0 → 1,88
 
///===========================
 
#define CON_COLOR_BLUE 1
#define CON_COLOR_GREEN 2
#define CON_COLOR_RED 4
#define CON_COLOR_BRIGHT 8
/* öâåò ôîíà */
#define CON_BGR_BLUE 0x10
#define CON_BGR_GREEN 0x20
#define CON_BGR_RED 0x40
#define CON_BGR_BRIGHT 0x80
 
///===========================
 
void (* _stdcall con_init)(unsigned w_w, unsigned w_h, unsigned s_w, unsigned s_h, const char* t);
void (* _cdecl printf)(const char* format,...);
void (* _stdcall _exit)(char bCloseWindow);
void (* __stdcall gets)(char* str, int n);
int (* __stdcall getch)(void);
int (* __stdcall con_get_font_height)(void);
int (* __stdcall con_set_cursor_height)(int new_height);
unsigned (*__stdcall con_get_flags)(void);
unsigned (*__stdcall con_set_flags)(unsigned new_flags);
void (*__stdcall con_cls)(void);
 
///===========================
 
void CONSOLE_INIT(char title[])
{
kol_struct_import *imp;
 
imp = kol_cofflib_load("/sys/lib/console.obj");
if (imp == NULL)
kol_exit();
 
con_init = ( _stdcall void (*)(unsigned, unsigned, unsigned, unsigned, const char*))
kol_cofflib_procload (imp, "con_init");
if (con_init == NULL)
kol_exit();
 
printf = ( _cdecl void (*)(const char*,...))
kol_cofflib_procload (imp, "con_printf");
if (printf == NULL)
kol_exit();
 
_exit = ( _stdcall void (*)(char))
kol_cofflib_procload (imp, "con_exit");
if (_exit == NULL)
kol_exit();
 
gets = ( _stdcall void (*)(char*, int))
kol_cofflib_procload (imp, "con_gets");
if (gets == NULL)
kol_exit();
 
getch = ( _stdcall int (*)(void))
kol_cofflib_procload (imp, "con_getch2");
if (getch == NULL)
kol_exit();
 
con_get_font_height = ( _stdcall int (*)(void))
kol_cofflib_procload (imp, "con_get_font_height");
if (con_get_font_height == NULL)
kol_exit();
 
con_set_cursor_height = ( _stdcall int (*)(int))
kol_cofflib_procload (imp, "con_set_cursor_height");
if (con_set_cursor_height == NULL)
kol_exit();
 
con_get_flags = ( _stdcall unsigned (*)(void))
kol_cofflib_procload (imp, "con_get_flags");
if (con_get_flags == NULL)
kol_exit();
 
con_set_flags = ( _stdcall unsigned (*)(unsigned))
kol_cofflib_procload (imp, "con_set_flags");
if (con_set_flags == NULL)
kol_exit();
 
con_cls = ( _stdcall void (*)(void))
kol_cofflib_procload (imp, "con_cls");
if (con_cls == NULL)
kol_exit();
 
con_init(-1, -1, -1, -1, title);
}
/programs/games/foxhunt/system/ctype.c
0,0 → 1,39
 
#include "ctype.h"
 
int toupper(int c)
{
 
if ( (c >= 97) && (c <= 122) )
return c-32 ;
 
if ( (c >= 160) && (c <= 175) )
return c-32 ;
 
if ( (c >= 224) && (c <= 239) )
return c-80 ;
 
if ( (c == 241) || (c == 243) || (c == 245) || (c == 247) )
return c-1;
 
return c;
}
 
int tolower(int c)
{
 
if ( (c >= 65) && (c <= 90) )
return c+32 ;
 
if ( (c >= 128) && (c <= 143) )
return c+32 ;
 
if ( (c >= 144) && (c <= 159) )
return c+80 ;
 
if ( (c == 240) || (c == 242) || (c == 244) || (c == 246) )
return c+1;
 
return c;
}
 
/programs/games/foxhunt/system/ctype.h
0,0 → 1,3
 
int toupper(int c);
int tolower(int c);
/programs/games/foxhunt/system/kolibri.c
0,0 → 1,438
 
#include "kolibri.h"
#include "string.h"
 
 
extern char KOL_PATH[256];
extern char KOL_PARAM[256];
extern char KOL_DIR[256];
 
 
void kol_exit()
{
asm volatile ("int $0x40"::"a"(-1));
}
 
 
void kol_sleep(unsigned d)
{
asm volatile ("int $0x40"::"a"(5), "b"(d));
}
 
 
// define a window
// x, y - position; w, h - size; cs - color and style; c - caption; b - boder
void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned cs, unsigned b, char *t)
{
asm volatile ("int $0x40"::"a"(0), "b"(x*65536+w), "c"(y*65536+h), "d"(cs), "D"(t), "S"(b) );
}
 
 
void kol_wnd_move(unsigned x, unsigned y)
{
asm volatile ("int $0x40"::"a"(67), "b"(x), "c"(y), "d"(-1), "S"(-1));
}
 
 
void kol_event_mask(unsigned e)
{
asm volatile ("int $0x40"::"a"(40), "b"(e));
}
 
 
unsigned kol_event_wait()
{
asm volatile ("int $0x40"::"a"(10));
}
 
 
unsigned kol_event_wait_time(unsigned time)
{
asm volatile ("int $0x40"::"a"(23), "b"(time));
}
 
 
unsigned kol_event_check()
{
asm volatile ("int $0x40"::"a"(11));
}
 
 
void __attribute__((__always_inline__)) kol_paint_start()
{
asm volatile ("int $0x40"::"a"(12), "b"(1));
}
 
 
void __attribute__((__always_inline__)) kol_paint_end()
{
asm volatile ("int $0x40"::"a"(12), "b"(2));
}
 
 
void kol_paint_pixel(unsigned x, unsigned y, unsigned c)
{
asm volatile ("int $0x40"::"a"(1), "b"(x), "c"(y), "d"(c));
}
 
 
void kol_paint_bar(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c)
{
asm volatile ("int $0x40"::"a"(13), "b"(x*65536+w), "c"(y*65536+h), "d"(c));
}
 
 
void kol_paint_line(unsigned x1, unsigned y1, unsigned x2, unsigned y2, unsigned c)
{
asm volatile ("int $0x40"::"a"(38), "b"(x1*65536+x2), "c"(y1*65536+y2), "d"(c));
}
 
 
void kol_paint_string(unsigned x, unsigned y, char *s, unsigned c)
{
asm volatile ("int $0x40"::"a"(4), "b"(x*65536+y), "c"(c), "d"(s));
}
 
 
void kol_paint_image(unsigned x, unsigned y, unsigned w, unsigned h, char *d)
{
asm volatile ("int $0x40"::"a"(7), "c"(w*65536+h), "d"(x*65536+y), "b"(d));
}
 
 
void kol_paint_image_pal(unsigned x, unsigned y, unsigned w, unsigned h, char *d, unsigned *palette)
{
asm volatile ("int $0x40"::"a"(65), "b"(d), "c"(w*65536+h), "d"(x*65536+y), "D"(palette), "S"(8));
}
 
 
unsigned kol_key_get()
{
asm volatile ("int $0x40"::"a"(2));
}
 
 
unsigned kol_key_control()
{
asm volatile ("int $0x40"::"a"(66), "b"(3));
}
 
 
void kol_key_lang_set(unsigned lang)
{
asm volatile ("int $0x40"::"a"(21), "b"(2), "c"(9), "d"(lang));
}
 
 
unsigned kol_key_lang_get()
{
asm volatile ("int $0x40"::"a"(26), "b"(2), "c"(9));
}
 
 
void kol_key_mode_set(unsigned mode)
{
asm volatile ("int $0x40"::"a"(66), "b"(1), "c"(mode));
}
 
 
unsigned kol_key_mode_get()
{
asm volatile ("int $0x40"::"a"(66), "b"(2));
}
 
 
unsigned kol_btn_get()
{
asm volatile ("int $0x40"::"a"(17));
}
 
 
void kol_btn_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned d, unsigned c)
{
asm volatile ("int $0x40"::"a"(8), "b"(x*65536+w), "c"(y*65536+h), "d"(d), "S"(c));
}
 
 
void kol_btn_type(unsigned t)
{
asm volatile ("int $0x40"::"a"(48), "b"(1), "c"(t));
}
 
 
void kol_wnd_caption(char *s)
{
asm volatile ("int $0x40"::"a"(71), "b"(1), "c"(s));
}
 
 
unsigned kol_mouse_pos()
{
asm volatile ("int $0x40"::"a"(37), "b"(0));
}
 
 
unsigned kol_mouse_posw()
{
asm volatile ("int $0x40"::"a"(37), "b"(1));
}
 
 
unsigned kol_mouse_btn()
{
asm volatile ("int $0x40"::"a"(37), "b"(2));
}
 
 
void kol_board_putc(char c)
{
asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(c));
}
 
 
void kol_board_puts(char *s)
{
unsigned i;
i = 0;
while (*(s+i))
{
asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(*(s+i)));
i++;
}
}
 
 
void kol_board_puti(int n)
{
char c;
 
if ( n > 1 )
kol_board_puti(n / 10);
 
c = n % 10 + '0';
asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(c));
 
}
 
 
int kol_file_70(kol_struct70 *k)
{
asm volatile ("int $0x40"::"a"(70), "b"(k));
}
 
 
kol_struct_import* kol_cofflib_load(char *name)
{
asm volatile ("int $0x40"::"a"(68), "b"(19), "c"(name));
}
 
 
void* kol_cofflib_procload (kol_struct_import *imp, char *name)
{
int i;
for (i=0;;i++)
if ( NULL == ((imp+i) -> name))
break;
else
if ( 0 == strcmp(name, (imp+i)->name) )
return (imp+i)->data;
return NULL;
}
 
 
unsigned kol_cofflib_procnum (kol_struct_import *imp)
{
unsigned i, n;
 
for (i=n=0;;i++)
if ( NULL == ((imp+i) -> name))
break;
else
n++;
 
return n;
}
 
 
void kol_cofflib_procname (kol_struct_import *imp, char *name, unsigned n)
{
unsigned i;
*name = 0;
 
for (i=0;;i++)
if ( NULL == ((imp+i) -> name))
break;
else
if ( i == n )
{
strcpy(name, ((imp+i)->name));
break;
}
 
}
 
 
unsigned kol_system_cpufreq()
{
asm volatile ("int $0x40"::"a"(18), "b"(5));
}
 
 
unsigned kol_system_mem()
{
asm volatile ("int $0x40"::"a"(18), "b"(17));
}
 
 
unsigned kol_system_memfree()
{
asm volatile ("int $0x40"::"a"(18), "b"(16));
}
 
 
unsigned kol_system_time_get()
{
asm volatile ("int $0x40"::"a"(3));
}
 
 
unsigned kol_system_date_get()
{
asm volatile ("int $0x40"::"a"(29));
}
 
 
unsigned kol_system_end(unsigned param)
{
asm volatile ("int $0x40"::"a"(18), "b"(9), "c"(param));
}
 
 
void kol_path_file2dir(char *dir, char *fname)
{
unsigned i;
strcpy (dir, fname);
for ( i = strlen(dir);; --i)
if ( '/' == dir[i])
{
dir[i] = '\0';
return;
}
}
 
 
void kol_path_full(char *full, char *fname)
{
char temp[256];
 
switch (*fname)
{
 
case '/':
strncpy(temp, fname+1, 2);
temp[2]=0;
if ( (!strcmp("rd", temp)) || (!strcmp("hd", temp)) || (!strcmp("cd", temp)) )
strcpy (full, fname);
break;
 
case '.':
break;
 
default:
break;
 
};
 
}
 
 
 
void __attribute__((__always_inline__)) kol_screen_wait_rr()
{
asm volatile ("int $0x40"::"a"(18), "b"(14));
}
 
 
 
void kol_screen_get_size(unsigned *w, unsigned *h)
{
unsigned size;
asm volatile ("int $0x40":"=a"(size):"a"(14));
*w = size / 65536;
*h = size % 65536;
}
 
 
 
unsigned kol_skin_height()
{
asm volatile ("int $0x40"::"a"(48), "b"(4));
}
 
 
unsigned kol_thread_start(unsigned start, unsigned stack)
{
asm volatile ("int $0x40"::"a"(51), "b"(1), "c"(start), "d"(stack));
}
 
 
unsigned kol_time_tick()
{
asm volatile ("int $0x40"::"a"(26), "b"(9));
}
 
 
unsigned kol_sound_speaker(char data[])
{
asm volatile ("movl %0, %%esi"::"a"(data));
asm volatile ("int $0x40"::"a"(55), "b"(55));
}
 
 
unsigned kol_process_info(unsigned slot, char buf1k[])
{
asm volatile ("int $0x40"::"a"(9), "b"(buf1k), "c"(slot));
}
 
 
int kol_process_kill_pid(unsigned process)
{
asm volatile ("int $0x40"::"a"(18), "b"(18), "c"(process));
}
 
int kol_kill_process(unsigned process)
{
asm volatile ("int $0x40"::"a"(18), "b"(2), "c"(process));
}
 
void kol_get_kernel_ver(char buff16b[])
{
asm volatile ("int $0x40"::"a"(18), "b"(13), "c"(buff16b));
}
 
int kol_buffer_open(char name[], int mode, int size, char **buf)
{
int error;
asm volatile ("int $0x40":"=a"(*buf), "=d"(error):"a"(68), "b"(22), "c"(name), "d"(size), "S"(mode));
return error;
}
 
void kol_buffer_close(char name[])
{
asm volatile ("int $0x40"::"a"(68), "b"(23), "c"(name));
}
 
int kol_clip_num()
{
asm volatile ("int $0x40"::"a"(54), "b"(0));
}
 
char* kol_clip_get(int n)
{
asm volatile ("int $0x40"::"a"(54), "b"(1), "c"(n));
}
 
int kol_clip_set(int n, char buffer[])
{
asm volatile ("int $0x40"::"a"(54), "b"(2), "c"(n), "d"(buffer));
}
/programs/games/foxhunt/system/kolibri.h
0,0 → 1,116
 
#define NULL ((void*)0)
 
#define SHM_OPEN 0
#define SHM_OPEN_ALWAYS 0x04
#define SHM_CREATE 0x08
#define SHM_READ 0x00
#define SHM_WRITE 0x01
 
#define E_NOTFOUND 5
#define E_ACCESS 10
#define E_NOMEM 30
#define E_PARAM 33
 
 
#pragma pack(push,1)
typedef struct
{
unsigned p00;
unsigned p04;
unsigned p08;
unsigned p12;
unsigned p16;
char p20;
char *p21;
} kol_struct70;
#pragma pack(pop)
 
 
#pragma pack(push,1)
typedef struct
{
unsigned p00;
char p04;
char p05[3];
unsigned p08;
unsigned p12;
unsigned p16;
unsigned p20;
unsigned p24;
unsigned p28;
unsigned p32[2];
unsigned p40;
} kol_struct_BDVK;
#pragma pack(pop)
 
 
#pragma pack(push,1)
typedef struct
{
char *name;
void *data;
} kol_struct_import;
#pragma pack(pop)
 
 
void kol_exit();
void kol_sleep(unsigned d);
void kol_wnd_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned cs, unsigned b, char *t);
void kol_wnd_move(unsigned x, unsigned y);
void kol_wnd_caption(char *s);
void kol_event_mask(unsigned e);
unsigned kol_event_wait();
unsigned kol_event_wait_time(unsigned time);
unsigned kol_event_check();
void kol_paint_start();
void kol_paint_end();
void kol_paint_pixel(unsigned x, unsigned y, unsigned c);
void kol_paint_bar(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c);
void kol_paint_line(unsigned x1, unsigned y1, unsigned x2, unsigned y2, unsigned c);
void kol_paint_string(unsigned x, unsigned y, char *s, unsigned c);
void kol_paint_image(unsigned x, unsigned y, unsigned w, unsigned h, char *d);
void kol_paint_image_pal(unsigned x, unsigned y, unsigned w, unsigned h, char *d, unsigned *palette);
unsigned kol_key_get();
unsigned kol_key_control();
void kol_key_lang_set(unsigned lang);
unsigned kol_key_lang_get();
void kol_key_mode_set(unsigned mode);
unsigned kol_key_mode_get();
void kol_btn_define(unsigned x, unsigned y, unsigned w, unsigned h, unsigned d, unsigned c);
unsigned kol_btn_get();
void kol_btn_type(unsigned t);
unsigned kol_mouse_pos();
unsigned kol_mouse_posw();
unsigned kol_mouse_btn();
void kol_board_putc(char c);
void kol_board_puts(char *s);
void kol_board_puti(int n);
int kol_file_70(kol_struct70 *k);
kol_struct_import* kol_cofflib_load(char *name);
void* kol_cofflib_procload (kol_struct_import *imp, char *name);
unsigned kol_cofflib_procnum (kol_struct_import *imp);
void kol_cofflib_procname (kol_struct_import *imp, char *name, unsigned n);
unsigned kol_system_end(unsigned param);
unsigned kol_system_cpufreq();
unsigned kol_system_mem();
unsigned kol_system_memfree();
unsigned kol_system_time_get();
unsigned kol_system_date_get();
void kol_path_file2dir(char *dir, char *fname);
void kol_path_full(char *full, char *fname);
void kol_screen_wait_rr();
void kol_screen_get_size(unsigned *w, unsigned *h);
unsigned kol_skin_height();
unsigned kol_thread_start(unsigned start, unsigned stack);
unsigned kol_time_tick();
unsigned kol_sound_speaker(char data[]);
unsigned kol_process_info(unsigned slot, char buf1k[]);
int kol_process_kill_pid(unsigned process);
void kol_get_kernel_ver(char buff16b[]);
int kol_kill_process(unsigned process);
int kol_buffer_open(char name[], int mode, int size, char **buf);
void kol_buffer_close(char name[]);
int kol_clip_num();
char* kol_clip_get(int n);
int kol_clip_set(int n, char buffer[]);
/programs/games/foxhunt/system/stdlib.c
0,0 → 1,33
 
unsigned int seed_o = 0x45168297;
 
 
void srand (unsigned seed)
{
seed_o = seed;
}
 
 
int rand (void)
{
seed_o = seed_o * 0x15a4e35 + 1;
return(seed_o >> 16);
}
 
 
void* malloc(unsigned s)
{
asm ("int $0x40"::"a"(68), "b"(12), "c"(s) );
}
 
 
void free(void *p)
{
asm ("int $0x40"::"a"(68), "b"(13), "c"(p) );
}
 
 
void* realloc(void *p, unsigned s)
{
asm ("int $0x40"::"a"(68), "b"(12), "c"(p), "d"(s) );
}
/programs/games/foxhunt/system/stdlib.h
0,0 → 1,14
 
#define RAND_MAX 0x7FFFU
 
#define isspace(c) ((c)==' ')
#define abs(i) (((i)<0)?(-(i)):(i))
 
#define random(num) ((rand()*(num))/((RAND_MAX+1)))
 
void* malloc(unsigned size);
void free(void* pointer);
void* realloc(void* pointer, unsigned size);
 
void srand (unsigned seed);
int rand (void);
/programs/games/foxhunt/system/string.c
0,0 → 1,202
 
#include "string.h"
 
void* memset(void *mem, int c, unsigned size)
{
unsigned i;
 
for ( i = 0; i < size; i++ )
*((char *)mem+i) = (char) c;
 
return NULL;
}
 
 
void* memcpy(void *dst, const void *src, unsigned size)
{
 
unsigned i;
 
for ( i = 0; i < size; i++)
*(char *)(dst+i) = *(char *)(src+i);
 
return NULL;
}
 
 
int memcmp(const void* buf1, const void* buf2, int count)
{
int i;
for (i=0;i<count;i++)
{
if (*(unsigned char*)buf1<*(unsigned char*)buf2)
return -1;
if (*(unsigned char*)buf1>*(unsigned char*)buf2)
return 1;
}
return 0;
}
 
void strcat(char strDest[], char strSource[])
{
 
int i, j;
i = j = 0;
while (strDest[i] != '\0')
i++;
 
while ((strDest[i++] = strSource[j++]) != '\0')
;
}
 
 
int strcmp(const char* string1, const char* string2)
{
 
while (1)
{
if (*string1<*string2)
return -1;
if (*string1>*string2)
return 1;
 
if (*string1=='\0')
return 0;
 
string1++;
string2++;
}
 
}
 
 
void strcpy(char strDest[], const char strSource[])
{
unsigned i;
 
i = 0;
while ((strDest[i] = strSource[i]) != '\0')
i++;
 
}
 
 
char* strncpy(char *strDest, const char *strSource, unsigned n)
{
unsigned i;
 
if (! n )
return strDest;
 
i = 0;
while ((strDest[i] = strSource[i]) != '\0')
if ( (n-1) == i )
break;
else
i++;
 
return strDest;
}
 
 
int strlen(const char* string)
{
int i;
 
i=0;
while (*string++) i++;
return i;
}
 
 
 
char* strchr(const char* string, int c)
{
while (*string)
{
if (*string==c)
return (char*)string;
string++;
}
return (char*)0;
}
 
 
char* strrchr(const char* string, int c)
{
char* last_found;
while (*string)
{
if (*string==c)
{
last_found = (char*)string;
}
string++;
}
return last_found;
}
 
 
 
void _itoa(int i, char *s)
{
int a, b, c, d;
a = (i - i%1000)/1000;
b = (i - i%100)/100 - a*10;
c = (i - i%10)/10 - a*100 - b*10;
d = i%10;
s[0] = a + '0';
s[1] = b + '0';
s[2] = c + '0';
s[3] = d + '0';
s[4] = 0;
}
 
 
/* reverse: ïåðåâîðà÷èâàåì ñòðîêó s íà ìåñòå */
void reverse(char s[])
{
int i, j;
char c;
for (i = 0, j = strlen(s)-1; i<j; i++, j--) {
c = s[i];
s[i] = s[j];
s[j] = c;
}
}
 
 
/* itoa: êîíâåðòèðóåì n â ñèìâîëû â s */
void itoa(int n, char s[])
{
int i, sign;
if ((sign = n) < 0)
n = -n;
i = 0;
do {
s[i++] = n % 10 + '0';
} while ((n /= 10) > 0);
if (sign < 0)
s[i++] = '-';
s[i] = '\0';
reverse(s);
}
 
 
 
int _atoi ( char *s )
{
int i, n;
 
n = 0;
for ( i = 0; s[i]!= '\0'; ++i)
if ((s[i]<'0') || (s[i]>'9'))
return 0;
else
n = 10 * n + s[i] - '0';
 
return n;
}
/programs/games/foxhunt/system/string.h
0,0 → 1,20
 
#ifndef NULL
#define NULL ((void*)0)
#endif
 
void* memset(void *mem, int c, unsigned size);
void* memcpy(void *dst, const void *src, unsigned size);
int memcmp(const void* buf1, const void* buf2, int count);
 
void strcat(char strDest[], char strSource[]);
int strcmp(const char* string1, const char* string2);
void strcpy(char strDest[], const char strSource[]);
char* strncpy(char *strDest, const char *strSource, unsigned n);
int strlen(const char* string);
char* strchr(const char* string, int c);
char* strrchr(const char* string, int c);
void _itoa(int i, char *s);
void reverse(char *s);
void itoa(int i, char *s);
int _atoi( char *s );
/programs/games/foxhunt/system
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property
/programs/games/foxhunt
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property