Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 5122 → Rev 5123

/data/Tupfile.lua
51,7 → 51,6
{"File Managers/EOLITE.INI", "common/File Managers/eolite.ini"},
{"File Managers/ICONS.INI", "common/File Managers/icons.ini"},
{"File Managers/KFM.INI", "common/File Managers/kfm.ini"},
{"GAMES/CHECKERS", build_type .. "/games/checkers"},
{"GAMES/MEGAMAZE", build_type .. "/games/megamaze"},
{"LIB/PIXLIB.OBJ", "common/lib/pixlib.obj"},
{"LIB/ICONV.OBJ", "common/lib/iconv.obj"},
456,6 → 455,7
tup.append_table(img_files, {
{"3D/CUBELINE", PROGS .. "/demos/cubeline/trunk/cubeline"},
{"3D/GEARS", PROGS .. "/demos/gears/trunk/gears"},
{"GAMES/CHECKERS", PROGS .. "/games/checkers/trunk/checkers"},
{"GAMES/REVERSI", PROGS .. "/games/reversi/trunk/reversi"},
{"SHELL", PROGS .. "/system/shell/shell"},
})
/data/eng/games/checkers
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/data/et/games/checkers
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/data/it/games/checkers
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:executable
-*
\ No newline at end of property
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/data/rus/games/checkers
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/data/sp/games/checkers
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/programs/develop/libraries/menuetlibc/include/assert.h
4,7 → 4,11
#undef assert
#undef unimpl
 
#ifdef NDEBUG
#define assert(test) /*nothing*/
#else
#define assert(test) ((void)((test)||(__dj_assert(#test,__FILE__,__LINE__),0)))
#endif
#define unimpl() __dj_unimp("Called unimplemented function in file \"" __FILE__ "\"\n")
 
#ifndef __dj_include_assert_h_
/programs/develop/libraries/menuetlibc/include/time.h
10,10 → 10,7
 
#ifndef __dj_ENFORCE_ANSI_FREESTANDING
 
/* 65536(tics/hour) / 3600(sec/hour) * 5(scale) = 91.02
The 5 is to make it a whole number (18.2*5=91) so that
floating point ops aren't required to use it. */
#define CLOCKS_PER_SEC 91
#define CLOCKS_PER_SEC 100
 
#include <sys/djtypes.h>
/programs/develop/libraries/menuetlibc/src/libc/Tupfile.lua
68,7 → 68,7
"termios",
}
 
CFLAGS="-Os -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -fno-ident -fomit-frame-pointer -fno-asynchronous-unwind-tables -mpreferred-stack-boundary=2"
CFLAGS="-Os -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -fno-ident -fomit-frame-pointer -fno-asynchronous-unwind-tables -mpreferred-stack-boundary=2 -march=pentium-mmx"
OBJS={}
for i,v in ipairs(FOLDERS) do
tup.append_table(OBJS,
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/printf.c
1,5 → 1,6
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <stdio.h>
#include <stdarg.h>
#include <libc/file.h>
 
int
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/sprintf.c
1,5 → 1,6
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <stdio.h>
#include <stdarg.h>
#include <limits.h>
#include <libc/file.h>
 
/programs/develop/libraries/menuetlibc/src/libc/crt0/crt1.c
36,7 → 36,6
void __crt1_startup(void)
{
init_brk();
if(__menuet__app_param_area[0]!='\0')
__crt0_setup_arguments();
dosemu_inithandles();
init_dir_stack();
/programs/develop/libraries/menuetlibc/src/libc/pc_hw/timer/clock.c
6,5 → 6,7
 
clock_t clock(void)
{
return 0;
unsigned result;
__asm__ __volatile__("int $0x40" : "=a"(result) : "a"(26), "b"(9));
return result;
}
/programs/develop/libraries/menuetlibc/src/libcpp/Tupfile.lua
1,5 → 1,5
if tup.getconfig('NO_GCC') ~= "" then return end
CFLAGS = "-Os -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -fno-ident -fomit-frame-pointer -fno-asynchronous-unwind-tables -mpreferred-stack-boundary=2"
CFLAGS = "-Os -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -fno-ident -fomit-frame-pointer -fno-asynchronous-unwind-tables -mpreferred-stack-boundary=2 -march=pentium-mmx"
OBJS = tup.foreach_rule({"*.cpp", extra_inputs = {"../../config.h"}},
'kos32-gcc -c -I../../include -D__DEV_CONFIG_H=\\"../../config.h\\" ' .. CFLAGS .. " -o %o %f",
"%B.o")
/programs/develop/libraries/menuetlibc/src/libm/Tupfile.lua
1,5 → 1,5
if tup.getconfig('NO_GCC') ~= "" then return end
CFLAGS="-D_USE_LIBM_MATH_H -Os -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -fno-ident -fomit-frame-pointer -fno-asynchronous-unwind-tables -mpreferred-stack-boundary=2"
CFLAGS="-D_USE_LIBM_MATH_H -Os -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -fno-ident -fomit-frame-pointer -fno-asynchronous-unwind-tables -mpreferred-stack-boundary=2 -march=pentium-mmx"
OBJS = tup.foreach_rule({"*.c", extra_inputs = {"../../config.h"}},
'kos32-gcc -c -I../../include -D__DEV_CONFIG_H=\\"../../config.h\\" ' .. CFLAGS .. ' -o %o %f',
"%B.o")
/programs/develop/libraries/menuetlibc/src/libm/k_standa.c
28,7 → 28,7
#undef fflush
#endif /* !defined(_USE_WRITE) */
 
inline int fputs(const char* str, FILE* f) { return -1; }
#define fputs /*nothing*/
 
#ifdef __STDC__
static const double zero = 0.0; /* used as const */
/programs/games/checkers/trunk/compile_eng.bat
File deleted
\ No newline at end of file
/programs/games/checkers/trunk/cpp2asm.bat
File deleted
\ No newline at end of file
/programs/games/checkers/trunk/me_make.inc
File deleted
/programs/games/checkers/trunk/qsort.c
File deleted
/programs/games/checkers/trunk/t2fasm.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/programs/games/checkers/trunk/compile_ru.bat
File deleted
/programs/games/checkers/trunk/include/stdarg.h
File deleted
/programs/games/checkers/trunk/include/me_lib.h
File deleted
/programs/games/checkers/trunk/include/me_lib.inc
File deleted
/programs/games/checkers/trunk/include/memheap.h
File deleted
/programs/games/checkers/trunk/include/menuet.h
File deleted
/programs/games/checkers/trunk/include/write_macro.inc
File deleted
/programs/games/checkers/trunk/include/me_heap.h
File deleted
/programs/games/checkers/trunk/include/me_func.inc
File deleted
/programs/games/checkers/trunk/include/me_heap.inc
File deleted
/programs/games/checkers/trunk/include/me_start.inc
File deleted
/programs/games/checkers/trunk/include
Property changes:
Deleted: tsvn:logminsize
-5
\ No newline at end of property
/programs/games/checkers/trunk/mt-draw.h
File deleted
/programs/games/checkers/trunk/board.h
1,7 → 1,6
#ifndef _HEADER_BOARD_H
#define _HEADER_BOARD_H
 
#ifndef __MENUET__
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
8,7 → 7,6
#include <time.h>
#include <math.h>
#include <limits.h>
#endif
#include "position.h"
#include "history.h"
#include "gr-draw.h"
527,7 → 525,7
return (y + height - delta_size.y) / 2;
}
 
#ifdef BUILD_RUS
#ifdef LANG_RUS
#define aCheckersGame "ˆ£à  ¢ è èª¨."
#define aRedMoves "Šà á­ë¥ 室ïâ."
#define aBlueMoves "‘¨­¨¥ 室ïâ."
/programs/games/checkers/trunk/buttons.h
1,11 → 1,9
#ifndef _HEADER_BUTTONS_H
#define _HEADER_BUTTONS_H
 
#ifndef __MENUET__
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#endif
#include "gr-draw.h"
 
struct TXButton
/programs/games/checkers/trunk/checkers.cpp
-
-
-
-
-//#define BUILD_RUS
-#ifndef __MENUET__
+//#define LANG_RUS
+#define NDEBUG
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
-#else
-#include <menuet.h>
-#include <me_heap.h>
-using namespace Menuet;
-#define strlen StrLen
-#define strcpy StrCopy
-#define memcpy MemCopy
-#include <stdarg.h>
-const unsigned dectab[] = { 1000000000, 100000000, 10000000, 1000000, 100000,
- 10000, 1000, 100, 10, 0 };
-int sprintf( char *Str, char* Format, ... )
-{
- int i, fmtlinesize, j, k, flag;
- unsigned head, tail;
- char c;
- va_list arglist;
- //
- va_start(arglist, Format);
- //
- fmtlinesize = strlen( Format );
- //
- if( fmtlinesize == 0 ) return 0;
-
- //
- for( i = 0, j = 0; i < fmtlinesize; i++ )
+// sprintf is too heavy
+int itoa(char* dst, int number)
{
- //
- c = Format[i];
- //
- if( c != '%' )
- {
- Str[j++] = c;
- continue;
+ int result = 0;
+ if (number < 0) {
+ result++;
+ *dst++ = '-';
+ number = -number;
}
- //
- i++;
- //
- if( i >= fmtlinesize ) break;
-
- //
- flag = 0;
- //
- c = Format[i];
- if (c == 'l') c = Format[++i];
- //
- switch( c )
- {
- //
- case '%':
- Str[j++] = c;
- break;
- // ˜„ Ÿ‰•
- case 's':
- char* str;
- str = va_arg(arglist, char*);
- for( k = 0; ( c = str[k] ) != 0; k++ )
- {
- Str[j++] = c;
+ char digits[16];
+ int ndigits = 0;
+ do {
+ digits[ndigits++] = number % 10;
+ number /= 10;
+ } while (number);
+ result += ndigits;
+ for (; ndigits--; )
+ *dst++ = digits[ndigits] + '0';
+ return result;
}
- break;
- // ˜„ Ÿ•‹Šž
- case 'c':
- Str[j++] = va_arg(arglist, int) & 0xFF;
- break;
- // ˜„ „ˆŒ– ŸŠž  „…Ÿš•‚Œ‹ •„…
- case 'u':
- case 'd':
- head = va_arg(arglist, unsigned);
- for( k = 0; dectab[k] != 0; k++ )
- {
- tail = head % dectab[k];
- head /= dectab[k];
- c = head + '0';
- if( c == '0' )
- {
- if( flag ) Str[j++] = c;
- }
- else
- {
- flag++;
- Str[j++] = c;
- }
- //
- head = tail;
- }
- //
- c = head + '0';
- Str[j++] = c;
- break;
- default:
- break;
- }
- }
- //
- Str[j] = 0;
- return j;
-}
-int isdigit(int c)
-{
- return (c>='0' && c<='9');
-}
-int atoi(const char* string)
-{
- int res=0;
- int sign=0;
- const char* ptr;
- for (ptr=string; *ptr && *ptr<=' ';ptr++);
- if (*ptr=='-') {sign=1;++ptr;}
- while (*ptr >= '0' && *ptr <= '9')
- {
- res = res*10 + *ptr++ - '0';
- }
- if (sign) res = -res;
- return res;
-}
-int islower(int c)
-{
- return (c>='a' && c<='z');
-}
-int abs(int n)
-{
- return (n<0)?-n:n;
-}
-int memcmp(const void* buf1, const void* buf2, unsigned count)
-{
- const char* ptr1 = (const char*)buf1;
- const char* ptr2 = (const char*)buf2;
- unsigned i=0;
- while (i<count && *ptr1==*ptr2) {++i;++ptr1;++ptr2;}
- if (i==count)
- return 0;
- else if (*ptr1<*ptr2)
- return -1;
- else
- return 1;
-}
-void strncpy(char* dest, const char* source, unsigned len)
-{
- char* ptr1 = dest;
- const char *ptr2 = source;
- for (;len-- && *ptr2; *ptr1++=*ptr2++) ;
-}
-unsigned int rand_data[4];
-void randomize()
-{
- rand_data[0] = (unsigned int)Clock();
- rand_data[1] = (unsigned int)GetPackedTime();
- rand_data[2] = (unsigned int)GetPackedDate();
- rand_data[3] = (unsigned int)0xA3901BD2 ^ GetPid();
-}
-
-unsigned int rand()
-{
- rand_data[0] ^= _HashDword(rand_data[3] + 0x2835C013U);
- rand_data[1] += _HashDword(rand_data[0]);
- rand_data[2] -= _HashDword(rand_data[1]);
- rand_data[3] ^= _HashDword(rand_data[2]);
- return rand_data[3];
-}
-
-#define random(k) (rand() % (k))
-#define floor Floor
-double fabs(double x)
-{
- __asm fld x
- __asm fabs
-}
-#define M_PI 3.14159265358979323846
-double cos(double x)
-{
- __asm fld x
- __asm fcos
-}
-double sin(double x)
-{
- __asm fld x
- __asm fsin
-}
-/*inline void printf(const char* format, ...)
-{}*/
-#define printf /* nothing */
-inline void strcat(char* str1, const char* str2)
-{strcpy(str1+strlen(str1),str2);}
-int strncmp(const char* str1, const char* str2, unsigned len)
-{
- for (;len--;)
- {
- if (*str1 != *str2) break;
- if (*str1 == 0)
- return 0;
- ++str1;++str2;
- }
- if (len==(unsigned)-1)
- return 0;
- if (*str1 < *str2)
- return -1;
- return 1;
-}
-#define clock Clock
-typedef unsigned int clock_t;
-#define CLOCKS_PER_SEC 100
-#define XK_Left 0xB0
-#define XK_Right 0xB3
-#define XK_Up 0xB2
-#define XK_Down 0xB1
-#define XK_Return 0x0D
-#define XK_space 0x20
-#define XK_Escape 0x1B
-#define XK_less '<'
-#define XK_comma ','
-#define XK_period '.'
-#define XK_greater '>'
-#define XK_minus '-'
-#define XK_equal '='
-#define XK_underscore '_'
-#define XK_plus '+'
-#define XK_Delete 0xB6
-#define XK_F8 0x39
-#define XK_l 'l'
-#define XK_L 'L'
-#define XK_F2 0x33
-#define XK_s 's'
-#define XK_S 'S'
-#define XK_slash '/'
-#define XK_question '?'
-#define XK_n 'n'
-#define XK_N 'N'
-#define XK_t 't'
-#define XK_T 'T'
-#define XK_r 'r'
-#define XK_R 'R'
-#define XK_b 'b'
-#define XK_B 'B'
-#define XK_f 'f'
-#define XK_F 'F'
-#define assert(a) /* nothing */
-#include "qsort.c"
-#endif
#include "gr-draw.h"
#include "board.h"
#include "player.h"
@@ -276,7 +50,7 @@
void Add(const PlayWrite &pl);
PlayWrite &operator[](int i) {return play[i];}
int GetNPlay() const {return nplay;}
-#ifndef __MENUET__
+#ifndef NO_FILES
int OpenFile(const char *name, int kind);
int MsgOpenFile(const char *name, int kind);
int SaveFile(const char *name, int num, int kind);
@@ -289,7 +63,7 @@
PlayWrite *play;
int nplay, mplay;
protected:
-#ifndef __MENUET__
+#ifndef NO_FILES
static const char *const search[];
static int AnalizeKind(FILE *f, const int w[], const char *smb = 0);
static int ReadFileTo(FILE *f, char c);
@@ -298,8 +72,7 @@
#endif
};
-#ifndef __MENUET__
-#if LANG_RUS //Pending Russian Translations
+#ifdef LANG_RUS //Pending Russian Translations
#define CHECKERS_CANT_OPEN_STR "\n˜ èª¨: ¥ ¬®£ã ®âªàëâì ä ©« \"%s\".\n"
#define CHECKERS_FILE_EMPTY_STR "\n˜ èª¨: ” ©« \"%s\" ¯ãáâ.\n"
#define CHECKERS_INVALID_FILE_STR "\n˜ èª¨: ” ©« \"%s\" ®è¨¡®ç­ë©.\n"
@@ -329,8 +102,10 @@
#define EXIT_STR "exit"
#define CHECKERS_INVALID_STR "Checkers: Invalid key %s\n"
+#ifndef NO_FILES
const char *const TPlayArray::search[] =
{"checkers-", "play:", "text", "bin_1.0\n", "history_", "1.0", "1.1"};
+#endif
#else /*For all other languages except RUS*/
#define CHECKERS_CANT_OPEN_STR "\nCheckers: Can't open the file \"%s\".\n"
@@ -361,11 +136,13 @@
#define ROTATE_BOARD_STR "rotate board"
#define EXIT_STR "exit"
#define CHECKERS_INVALID_STR "Checkers: Invalid key %s\n"
+
+#ifndef NO_FILES
const char *const TPlayArray::search[] =
{"checkers-", "play:", "text", "bin_1.0\n", "history_", "1.0", "1.1"};
+#endif
#endif
-#endif
void TPlayArray::Clear()
{
if (play) delete[] play;
@@ -396,7 +173,7 @@
nplay++;
}
-#ifndef __MENUET__
+#ifndef NO_FILES
int TPlayArray::AnalizeKind(FILE *f, const int w[], const char *smb)
{
int i, L, was1 = 1;
@@ -884,22 +661,22 @@
void TMainDraw::InitButton()
{
- char newgame_literal[] = NEW_GAME_STR;
- char list_literal[] = LIST_STR;
- char delete_literal[] = DELETE_STR;
- char clear_literal[] = CLEAR_STR;
- char save_literal[] = SAVE_STR;
- char rotateboard_literal[] = ROTATE_BOARD_STR;
- char exit_literal[] = EXIT_STR;
+ static char newgame_literal[] = NEW_GAME_STR;
+ static char list_literal[] = LIST_STR;
+ static char delete_literal[] = DELETE_STR;
+ static char clear_literal[] = CLEAR_STR;
+ static char save_literal[] = SAVE_STR;
+ static char rotateboard_literal[] = ROTATE_BOARD_STR;
+ static char exit_literal[] = EXIT_STR;
- char one_literal[] = "1";
- char dash_literal[] = "-";
- char plus_literal[] = "+";
- char leftshift_literal[] = "<<";
- char rightshift_literal[] = ">>";
- char lessthan_literal[] = "<";
- char greaterthan_literal[] = ">";
- char xor_literal[] = "^";
+ static char one_literal[] = "1";
+ static char dash_literal[] = "-";
+ static char plus_literal[] = "+";
+ static char leftshift_literal[] = "<<";
+ static char rightshift_literal[] = ">>";
+ static char lessthan_literal[] = "<";
+ static char greaterthan_literal[] = ">";
+ static char xor_literal[] = "^";
button.Add(1, 80, 22, newgame_literal);
button.Add(6, 60, 22, list_literal);
@@ -913,7 +690,7 @@
play_list->SetDefW();
button.Add(play_list);
button.Add(24, 50, 22, clear_literal);
-#ifndef __MENUET__
+#ifndef NO_FILES
button.Add(25, 50, 22, save_literal);
#endif
button.Add(2, 120, 22, player_str[0]);
@@ -974,7 +751,7 @@
if (bt1) bt1->drw = is_drw;
bt1 = button.GetButton(7);
if (bt1) bt1->drw = !is_drw;
-#ifndef __MENUET__
+#ifndef NO_FILES
bt1 = button.GetButton(25);
if (bt1) bt1->drw = !is_drw;
#endif
@@ -986,20 +763,18 @@
if (is_drw)
{
play_num[0][0] = 0; play_num[1][0] = 0;
- if (cur_play >= 0) sprintf(play_num[0], "%d", cur_play + 1);
- sprintf(play_num[1], "%d", play.GetNPlay());
+ if (cur_play >= 0) itoa(play_num[0], cur_play + 1);
+ itoa(play_num[1], play.GetNPlay());
thick = (cur_play <= 0) ? 0 : 3;
-#define dynamic_cast static_cast
- txb = dynamic_cast<TextButton*>(play_list->a.GetButton(21));
+ txb = static_cast<TextButton*>(play_list->a.GetButton(21));
if (txb) txb->thick = thick;
- txb = dynamic_cast<TextButton*>(play_list->a.GetButton(26));
+ txb = static_cast<TextButton*>(play_list->a.GetButton(26));
if (txb) txb->thick = thick;
thick = (cur_play >= play.GetNPlay() - 1) ? 0 : 3;
- txb = dynamic_cast<TextButton*>(play_list->a.GetButton(22));
+ txb = static_cast<TextButton*>(play_list->a.GetButton(22));
if (txb) txb->thick = thick;
- txb = dynamic_cast<TextButton*>(play_list->a.GetButton(27));
+ txb = static_cast<TextButton*>(play_list->a.GetButton(27));
if (txb) txb->thick = thick;
-#undef dynamic_cast
}
}
@@ -1077,7 +852,7 @@
}
}
else if (n == 24) {play.Clear(); cur_play = 0; need_redraw = 1;}
-#ifndef __MENUET__
+#ifndef NO_FILES
else if (n == 25)
{
if (play.GetNPlay() > 0) play.MsgSaveFile(def_savefile, -1, def_savekind);
@@ -1317,7 +1092,7 @@
else if (ev.key.k == XK_Delete) data.main_draw.PressLS(7, data.board, ev.button.drw);
else if (ev.key.k == XK_F8) data.main_draw.PressLS(24, data.board, ev.button.drw);
else if (ev.key.k == XK_l || ev.key.k == XK_L) data.main_draw.PressLS(6, data.board, ev.button.drw);
-#ifndef __MENUET__
+#ifndef NO_FILES
else if (ev.key.k == XK_F2) data.main_draw.PressLS(25, data.board, ev.button.drw);
#endif
else if (ev.key.k == XK_s || ev.key.k == XK_S) data.main_draw.PressLS(28, data.board, ev.button.drw);
@@ -1346,11 +1121,12 @@
return ret;
}
-#ifndef __MENUET__
int main(int argc, char **argv)
{
randomize();
+#ifndef NO_FILES
THistory::InitHFile(argv[0]);
+#endif
TMainData data(-1);
if (argv && argc >= 2)
{
@@ -1380,7 +1156,9 @@
}
else if (kx == 0 || kx == 1)
{
+#ifndef NO_FILES
data.main_draw.play.MsgOpenFile(argv[i], -1);
+#endif
}
}
}
@@ -1395,65 +1173,3 @@
450 + 100 * ssf, 528);
return 0;
}
-#else
-
-TMainData* mdata;
-TMainGraphDraw* graph;
-
-bool MenuetOnStart(TStartData &me_start, TThreadData)
-{
- mdata = new TMainData(-1);
- graph = new TMainGraphDraw;
- randomize();
- mdata->InitDef();
- static TTimerDraw timer_draw(&mdata->board, graph);
- mdata->player.draw = TTimerDraw::draw; mdata->player.data = &timer_draw;
- graph->data = mdata;
- me_start.WinData.Title = CHECKERS_STR;
- me_start.Width = 450 + 100*ssf;
- me_start.Height = 528;
- return true;
-}
-bool MenuetOnClose(TThreadData)
-{
- delete mdata;
- delete graph;
- return true;
-}
-int MenuetOnIdle(TThreadData)
-{return -1;}
-void MenuetOnSize(int window_rect[], TThreadData)
-{mdata->board.Resize(window_rect[2]-window_rect[0], window_rect[3]-window_rect[1]);}
-void MenuetOnKeyPress(TThreadData)
-{
- TGraphDraw::event ev;
- ev.type = TGraphDraw::event::key_down;
- ev.any.drw = graph;
- ev.key.k = GetKey();
- mdata->EventFunction(ev);
-}
-void MenuetOnDraw(void)
-{
- TGraphDraw::event ev;
- ev.type = TGraphDraw::event::draw;
- ev.any.drw = graph;
- mdata->EventFunction(ev);
-}
-void MenuetOnMouse(TThreadData)
-{
- short x,y;
- GetMousePosition(x,y);
- int m = GetMouseButton() & 1;
- static int mprev = 0;
- if (m == mprev)
- return;
- mprev = m;
- TGraphDraw::event ev;
- ev.type = m ? TGraphDraw::event::button_down : TGraphDraw::event::button_up;
- ev.any.drw = graph;
- ev.button.n = 1;
- ev.button.x = x;
- ev.button.y = y;
- mdata->EventFunction(ev);
-}
-#endif
/programs/games/checkers/trunk/compile.txt
1,18 → 1,13
1. Êîìïèëÿöèÿ ïîä Êîëèáðè.
Äëÿ êîìïèëÿöèè íåîáõîäèì Borland C++ (èç âñåãî ïàêåòà íóæåí òîëüêî êîìïèëÿòîð
êîìàíäíîé ñòðîêè), à òàêæå FASM âåðñèè íå áîëåå 1.64.
cpp2asm.bat êîìïèëèðóåò Ñ++-èñõîäíèê â TASM-èñõîäíèê,
à ïîòîì ïðåâðàùàåò åãî â FASM-èñõîäíèê.
Ïîñëå ýòîãî, âîçìîæíî, ïîíàäîáèòñÿ ïåðåíåñòè â f_checkers.asm ñòðîêè ñ equ
â íà÷àëî ôàéëà.
Êîìïèëÿöèÿ áèíàðíèêà - êàê îáû÷íî, fasm f_checkers.asm checkers.
Ñòàíäàðòíàÿ äëÿ ïðîãðàìì, èñïîëüçóþùèõ menuetlibc.
 
2. Êîìïèëÿöèÿ ïîä Linux.
Ïðîñòî ñêàæèòå make. Ïî êðàéíåé ìåðå â îäíîé Linux-ñèñòåìå ýòî ðàáîòàåò.
 äðóãèõ ìîãóò ïîíàäîáèòüñÿ íåêîòîðûå èçìåíåíèÿ.
 èñõîäíèêàõ ðóññêèå áóêâû çàïèñàíû â êîäèðîâêå DOS (cp866). Òàê ÷òî äëÿ
âðàçóìèòåëüíûõ ñîîáùåíèé ëèáî çàêîììåíòèðóéòå ïåðâóþ ñòðîêó â checkers.cpp
("#define BUILD_RUS"), ëèáî ïðîãîíèòå âñå *.cpp è *.h ôàéëû ÷åðåç dos2unix.
âðàçóìèòåëüíûõ ñîîáùåíèé íà ðóññêîì íóæíî, ïîìèìî ðàñêîììåíòèðîâàíèÿ ïåðâîé
ñòðîêè â checkers.cpp ("#define LANG_RUS"),
åù¸ ïðîãíàòü âñå *.cpp è *.h ôàéëû ÷åðåç dos2unix.
 
3. Êîìïèëÿöèÿ ïîä DOS/Windows.
Äëÿ êîìïèëÿöèè íåîáõîäèì ïàêåò Borland C++ for DOS/Windows ñîîòâåòñòâåííî.
/programs/games/checkers/trunk/dos-draw.h
10,8 → 10,9
#include <stdio.h>
#include <limits.h>
 
class TDosGraphDraw : public TGraphDraw
class TDosGraphDraw : public TBaseGraphDraw<TDosGraphDraw>
{
typedef TBaseGraphDraw<TDosGraphDraw> TGraphDraw;
public:
TDosGraphDraw(const char *s = 0);
~TDosGraphDraw() {}
/programs/games/checkers/trunk/gnu-draw.h
8,8 → 8,9
#ifndef _GNU_GRAPHIC_DRAW_H
#define _GNU_GRAPHIC_DRAW_H
 
class TGnuGraphDraw : public TGraphDraw
class TGnuGraphDraw : public TBaseGraphDraw<TGnuGraphDraw>
{
typedef TBaseGraphDraw<TGnuGraphDraw> TGraphDraw;
public:
TGnuGraphDraw(const char *s = 0);
~TGnuGraphDraw();
/programs/games/checkers/trunk/gr-draw.h
1,7 → 1,6
#ifndef _GRAPHIC_DRAW_H
#define _GRAPHIC_DRAW_H
 
#ifndef __MENUET__
#include <limits.h>
#include <string.h>
 
8,12 → 7,9
#ifdef _Windows
# include <windows.h>
#endif
#else
#define LONG_MIN (-2147483647L-1) /* minimum signed long value */
#define INT_MIN LONG_MIN
#endif
 
class TGraphDraw
template<class TRealGraphDraw>
class TBaseGraphDraw
{
public:
union event
24,7 → 20,7
struct evany
{
evtype type;
TGraphDraw *drw;
TRealGraphDraw *drw;
} any;
 
struct evbutton : public evany
43,41 → 39,41
 
enum {ret_setcapture = 0x10};
public:
TGraphDraw(const char *s = 0) : title(0), about_info(0),
TBaseGraphDraw(const char *s = 0) : title(0), about_info(0),
evfunc(0), id(0), data(0) {CopyTitle(s);}
~TGraphDraw() {FreeTitle();}
~TBaseGraphDraw() {FreeTitle();}
 
virtual unsigned long GetBlackColor() {return 0;}
virtual unsigned long GetWhiteColor() {return 0xFFFFFFL;}
virtual unsigned long CreateColor(unsigned short red,
unsigned long GetBlackColor() {return 0;}
unsigned long GetWhiteColor() {return 0xFFFFFFL;}
unsigned long CreateColor(unsigned short red,
unsigned short green, unsigned short blue);
virtual void FreeColor(unsigned long c) {}
virtual unsigned long GetBgColor() {return GetWhiteColor();}
virtual void SetBgColor(unsigned long c) {}
void FreeColor(unsigned long c) {}
unsigned long GetBgColor() {return GetWhiteColor();}
void SetBgColor(unsigned long c) {}
 
virtual void SetTitle(const char *s) {CopyTitle(s);}
void SetTitle(const char *s) {CopyTitle(s);}
const char *GetTitle() const {return title;}
 
virtual int GetStatus() {return 0;} //1 - can draw, 0 - can't draw, <0 - error
virtual int Init() {return 0;}
virtual void UnInit() {}
virtual int Run(int evmask = 0, int w = INT_MIN, int h = INT_MIN) {return -100;}
int GetStatus() {return 0;} //1 - can draw, 0 - can't draw, <0 - error
int Init() {return 0;}
void UnInit() {}
int Run(int evmask = 0, int w = INT_MIN, int h = INT_MIN) {return -100;}
 
virtual void GetSize(int &w, int &h) {w = 200; h = 200;}
virtual int OpenDraw() {return 0;}
virtual int IsDraw() {return 0;}
virtual void CloseDraw() {}
void GetSize(int &w, int &h) {w = 200; h = 200;}
int OpenDraw() {return 0;}
int IsDraw() {return 0;}
void CloseDraw() {}
 
virtual int SetColor(unsigned long c) {return 0;}
virtual int DrawLine(int x0, int y0, int x1, int y1) {return 0;}
virtual int DrawText(int x0, int y0, char *text) {return 0;}
virtual int DrawClear() {return 0;}
virtual int GetTextH(const char *s) {return 16;}
virtual int GetTextW(const char *s) {return 8 * strlen(s);}
virtual void Quit(int q = 1) {}
virtual void ResReinit(int w = INT_MIN, int h = INT_MIN) {}
virtual int GetAboutInfo() {return about_info;}
virtual void SetAboutInfo(int inf) {about_info = inf;}
int SetColor(unsigned long c) {return 0;}
int DrawLine(int x0, int y0, int x1, int y1) {return 0;}
int DrawText(int x0, int y0, char *text) {return 0;}
int DrawClear() {return 0;}
int GetTextH(const char *s) {return 16;}
int GetTextW(const char *s) {return 8 * strlen(s);}
void Quit(int q = 1) {}
void ResReinit(int w = INT_MIN, int h = INT_MIN) {}
int GetAboutInfo() {return about_info;}
void SetAboutInfo(int inf) {about_info = inf;}
protected:
void FreeTitle() {if (title) {delete[] title; title = 0;}}
void CopyTitle(const char *s);
89,7 → 85,8
void *data;
};
 
unsigned long TGraphDraw::CreateColor(unsigned short red,
template<class TRealGraphDraw>
unsigned long TBaseGraphDraw<TRealGraphDraw>::CreateColor(unsigned short red,
unsigned short green, unsigned short blue)
{
return (unsigned long)(red >> 8) + ((unsigned long)(green >> 8) << 8) +
96,18 → 93,19
((unsigned long)(blue >> 8) << 16);
}
 
void TGraphDraw::CopyTitle(const char *s)
template<class TRealGraphDraw>
void TBaseGraphDraw<TRealGraphDraw>::CopyTitle(const char *s)
{
FreeTitle();
if (s) {title = new char[strlen(s) + 1]; strcpy(title, s);}
}
 
#if defined __GNUC__
#if defined _KOLIBRI
# include "kolibri-draw.h"
typedef TKlbrGraphDraw TMainGraphDraw;
#elif defined __GNUC__
# include "gnu-draw.h"
typedef TGnuGraphDraw TMainGraphDraw;
#elif defined __MENUET__
# include "mt-draw.h"
typedef TKlbrGraphDraw TMainGraphDraw;
#elif defined _Windows
# include "win-draw.h"
typedef TWinGraphDraw TMainGraphDraw;
115,7 → 113,8
# include "dos-draw.h"
typedef TDosGraphDraw TMainGraphDraw;
#else
typedef TGraphDraw TMainGraphDraw;
#error "Unknown platform"
#endif
typedef TMainGraphDraw TGraphDraw;
 
#endif //_GRAPHIC_DRAW_H
/programs/games/checkers/trunk/history.h
1,12 → 1,6
#ifndef _HEADER_HISTORY_H
#define _HEADER_HISTORY_H
 
#ifndef __MENUET__
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#endif
#include "position.h"
#include "hash.h"
#include "sysproc.h"
13,7 → 7,7
 
class THistory
{
#ifndef __MENUET__
#ifndef NO_FILES
public:
static char FileName[1024];
#endif
27,7 → 21,7
int Move(const Position &pos, const unsigned char mv[], int nmove) const;
int Play(const PlayWrite &play) const;
 
#ifndef __MENUET__
#ifndef NO_FILES
static int InitHFile(char *dname = 0);
static int HRead(FILE *f, PlayWrite *&play);
protected:
119,12 → 113,12
};
};
 
#ifndef __MENUET__
#ifndef NO_FILES
char THistory::FileName[1024] = "history.che";
#endif
int THistory::NHid = 0;
 
#ifndef __MENUET__
#ifndef NO_FILES
int THistory::Print(const char *str) const
{
char *line = new char[30 + strlen(str)];
150,9 → 144,9
 
int THistory::Start(const Position &pos) const
{
#ifndef NO_FILES
char str[20 + NUM_CELL] = "Start ";
if (!pos.Write(str + strlen(str), 1)) return 0;
#ifndef __MENUET__
if (!Print(str)) return 0;
#endif
return 1;
160,14 → 154,14
 
int THistory::Move(const Position &pos, const unsigned char mv[], int nmove) const
{
#ifndef NO_FILES
char *str = new char[15 + pos.GetLenMvEx(mv, 11)];
if (!str) return 0;
sprintf(str, "%d.%s ", (nmove + 1) / 2, (nmove % 2 == 0) ? ".." : "");
pos.WriteMvEx(mv, str + strlen(str), 11);
#ifndef __MENUET__
if (!Print(str)) {delete[] str; return 0;}
delete[] str;
#endif
delete[] str;
return 1;
}
 
188,7 → 182,7
return 1;
}
 
#ifndef __MENUET__
#ifndef NO_FILES
int THistory::InitHFile(char *dname)
{
if (dname && dname[0])
262,7 → 256,7
return r;
}
 
#ifndef __MENUET__
#ifndef NO_FILES
int THistory::HRead(FILE *f, PlayWrite *&play)
{
const int MAX_INP_WORD = 100;
/programs/games/checkers/trunk/player.h
3,11 → 3,9
 
#include "position.h"
#include "sysproc.h"
#ifndef __MENUET__
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#endif
 
template <class tvalue>
class TBaseCompPlayer : public TChPlayer
/programs/games/checkers/trunk/position.h
1,12 → 1,10
#ifndef _HEADER_POSITION_H
#define _HEADER_POSITION_H
 
#ifndef __MENUET__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#endif
 
#define NELEM(a) (sizeof(a) / sizeof((a)[0]))
 
226,7 → 224,7
int x, y;
NumToPole(mv[i], x, y);
WP[j++] = char('a' + NW_CELL - 1 - x);
int r = sprintf(WP + j, "%d", 1 + y);
int r = itoa(WP + j, 1 + y);
if (r > 0) j += r;
if (i != nmv) WP[j++] = '-';
}
333,7 → 331,7
if (WP)
{
WP[L++] = char('a' + NW_CELL - 1 - x0);
int r = sprintf(WP + L, "%d", 1 + y0);
int r = itoa(WP + L, 1 + y0);
if (r > 0) L += r;
}
else
/programs/games/checkers/trunk/sysproc.h
1,12 → 1,16
#ifndef _HEADER_SYSTEM_PROCESS_H
#define _HEADER_SYSTEM_PROCESS_H
 
#ifndef __MENUET__
#include <stdlib.h>
#include <time.h>
#endif
 
#if defined __GNUC__
#if defined _KOLIBRI
# define DIR_SEPARATOR ('/')
inline long GetProcessId() {return 0;}
inline long DuplicateProcess() {return -1;}
inline int random(int m) {return ((unsigned long)rand()) % m;}
inline void randomize() {srand(__menuet__getsystemclock());}
#elif defined __GNUC__
# include <unistd.h>
# define DIR_SEPARATOR ('/')
inline long GetProcessId() {return (long)getpid();}
13,7 → 17,7
inline long DuplicateProcess() {return (long)fork();}
inline int random(int m) {return ((unsigned long)rand()) % m;}
inline void randomize() {srand(time(0));}
#elif defined __TURBOC__ && !defined __MENUET__
#elif defined __TURBOC__
# include <process.h>
# define DIR_SEPARATOR ('\\')
inline long GetProcessId() {return (long)getpid();}
/programs/games/checkers/trunk/win-draw.h
19,8 → 19,9
 
#define main OwlMain
 
class TWinGraphDraw : public TGraphDraw
class TWinGraphDraw : public TBaseGraphDraw<TWinGraphDraw>
{
typedef TBaseGraphDraw<TWinGraphDraw> TGraphDraw;
public:
TWinGraphDraw(const char *s = 0);
~TWinGraphDraw();
/programs/use_gcc.lua
1,4 → 1,6
CFLAGS = "-Os -fno-ident -fomit-frame-pointer -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -mpreferred-stack-boundary=2 -fno-exceptions -fno-asynchronous-unwind-tables -ffast-math -mno-ms-bitfields"
CFLAGS = "-Os -fno-ident -fomit-frame-pointer -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -mpreferred-stack-boundary=2 -fno-exceptions -fno-asynchronous-unwind-tables -ffast-math -mno-ms-bitfields -march=pentium-mmx"
CFLAGS_c = "" -- extra flags for *.c
CFLAGS_cpp = " -fno-rtti" -- extra flags for *.cpp
LDFLAGS = "-nostdlib -n --file-alignment=16 --section-alignment=16"
INCLUDES = ""
LIBS = ""
8,7 → 10,7
function compile_gcc(input, output)
if not output then output = '%B.o' end
tup.append_table(OBJS,
tup.foreach_rule(input, "kos32-gcc -c " .. CFLAGS .. " " .. INCLUDES .. " -o %o %f", output)
tup.foreach_rule(input, "kos32-gcc -c " .. CFLAGS .. "$(CFLAGS_%e) " .. INCLUDES .. " -o %o %f", output)
)
end