Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5234 → Rev 5235

/programs/games/marblematch3/system/boolean.h
0,0 → 1,3
 
#define FALSE 0
#define TRUE 1
/programs/games/marblematch3/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/marblematch3/system/kolibri.c
0,0 → 1,440
 
#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__)) inline kol_paint_start()
{
asm volatile ("int $0x40"::"a"(12), "b"(1));
}
 
 
void __attribute__((__always_inline__)) 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__)) 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/marblematch3/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/marblematch3/system/sound.h
0,0 → 1,133
 
#ifndef _SOUND_H_
#define _SOUND_H_
 
#ifdef __cplusplus
extern "C"
{
#endif
 
#define SOUND_VERSION 0x0100
#define PCM_ALL 0
 
#define PCM_OUT 0x08000000
#define PCM_RING 0x10000000
#define PCM_STATIC 0x20000000
#define PCM_FLOAT 0x40000000
#define PCM_FILTER 0x80000000
 
#define PCM_2_16_48 1
#define PCM_1_16_48 2
#define PCM_2_16_44 3
#define PCM_1_16_44 4
#define PCM_2_16_32 5
#define PCM_1_16_32 6
#define PCM_2_16_24 7
#define PCM_1_16_24 8
#define PCM_2_16_22 9
#define PCM_1_16_22 10
#define PCM_2_16_16 11
#define PCM_1_16_16 12
#define PCM_2_16_12 13
#define PCM_1_16_12 14
#define PCM_2_16_11 15
#define PCM_1_16_11 16
#define PCM_2_16_8 17
#define PCM_1_16_8 18
#define PCM_2_8_48 19
#define PCM_1_8_48 20
#define PCM_2_8_44 21
#define PCM_1_8_44 22
#define PCM_2_8_32 23
#define PCM_1_8_32 24
#define PCM_2_8_24 25
#define PCM_1_8_24 26
#define PCM_2_8_22 27
#define PCM_1_8_22 28
#define PCM_2_8_16 29
#define PCM_1_8_16 30
#define PCM_2_8_12 31
#define PCM_1_8_12 32
#define PCM_2_8_11 33
#define PCM_1_8_11 34
#define PCM_2_8_8 35
#define PCM_1_8_8 36
 
#define SRV_GETVERSION 0
#define SND_CREATE_BUFF 1
#define SND_DESTROY_BUFF 2
#define SND_SETFORMAT 3
#define SND_GETFORMAT 4
#define SND_RESET 5
#define SND_SETPOS 6
#define SND_GETPOS 7
#define SND_SETBUFF 8
#define SND_OUT 9
#define SND_PLAY 10
#define SND_STOP 11
#define SND_SETVOLUME 12
#define SND_GETVOLUME 13
#define SND_SETPAN 14
#define SND_GETPAN 15
#define SND_GETBUFFSIZE 16
 
#define PLAY_SYNC 0x80000000
 
typedef unsigned int SNDBUF;
 
int _stdcall InitSound(int *version);
 
int _stdcall CreateBuffer(unsigned int format,int size,SNDBUF *buf);
int _stdcall DestroyBuffer(SNDBUF hBuff);
 
int _stdcall SetFormat(SNDBUF hBuff, unsigned int format);
int _stdcall GetFormat(SNDBUF hBuff, unsigned int *format);
 
int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags);
int _stdcall SetBufferPos(SNDBUF hBuff, int offset);
int _stdcall GetBufferPos(SNDBUF hBuff, int *offset);
int _stdcall GetBufferSize(SNDBUF hBuff, int *size);
 
int _stdcall SetBuffer(SNDBUF hBuff,void* buff,
int offs, int size);
int _stdcall WaveOut(SNDBUF hBuff,void *buff, int size);
int _stdcall PlayBuffer(SNDBUF hBuff,unsigned int flags);
int _stdcall StopBuffer(SNDBUF hBuff);
 
int _stdcall SetVolume(SNDBUF hBuff, int left, int right);
int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right);
int _stdcall SetPan(SNDBUF hBuff, int pan);
int _stdcall GetPan(SNDBUF hBuff, int *pan);
 
int _stdcall GetMasterVol(int* vol);
int _stdcall SetMasterVol(int vol);
 
 
typedef struct
{
unsigned int riff_id;
unsigned int riff_size;
unsigned int riff_format;
 
unsigned int fmt_id;
unsigned int fmt_size;
 
unsigned short int wFormatTag;
unsigned short int nChannels;
unsigned int nSamplesPerSec;
unsigned int nAvgBytesPerSec;
unsigned short int nBlockAlign;
unsigned short int wBitsPerSample;
unsigned int data_id;
unsigned int data_size;
} WAVEHEADER;
 
 
unsigned int _stdcall test_wav(WAVEHEADER *hdr);
 
#ifdef __cplusplus
extern "C"
}
#endif
 
#endif //_SOUND_H_