clean code

git-svn-id: svn://kolibrios.org@8133 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2020-11-04 21:02:21 +00:00
parent b6a2e048a3
commit 43c1011cb3
5 changed files with 146 additions and 134 deletions

View File

@ -1,5 +1,5 @@
#ifndef __MENUET_H_INCLUDED_
#define __MENUET_H_INCLUDED_
#ifndef __KOLIBRI_H_INCLUDED_
#define __KOLIBRI_H_INCLUDED_
#include <kos_lib.h>
@ -17,7 +17,7 @@ namespace Kolibri // All kolibri functions, types and data are nested in the (
const char *Title;
};
struct TStartData // This structure is used only for MenuetOnStart function.
struct TStartData // This structure is used only for KolibriOnStart function.
{
unsigned short Left, Width, Top, Height; // Initial window rectangle.
TWindowData WinData;
@ -59,7 +59,7 @@ namespace Kolibri // All kolibri functions, types and data are nested in the (
void ExitThread(); // Exit from the current thread
void ExitThread(TThreadData thread_data);
void ReturnMessageLoop(); // Return to the message loop of the thread. Exit from the thread
void ReturnMessageLoop(TThreadData thread_data); //_ if it is called from (MenuetOnStart).
void ReturnMessageLoop(TThreadData thread_data); //_ if it is called from (KolibriOnStart).
void Delay(unsigned int time); // Delay the execution of the program during (time) hundredth seconds.
unsigned int Clock(); // Return the time from starting of the system to this moment in hundredth of seconds.
@ -133,17 +133,18 @@ namespace Kolibri // All kolibri functions, types and data are nested in the (
//_ the same size as the main thread if (stack_size) less that 4096. Set the beginning
//_ of the stack if (stack_end) is zero or (stack_size) is not zero, in this case stack
//_ will be deleted automaticaly from dynamic memory at the finish of the thread.
void DrawText(short x, short y, int color, const char* string);
}
// Function, defined outside.
bool MenuetOnStart(Kolibri::TStartData &me_start, Kolibri::TThreadData thread_data);
bool KolibriOnStart(Kolibri::TStartData &me_start, Kolibri::TThreadData thread_data);
// Window will be created iff return value is true.
bool MenuetOnClose(Kolibri::TThreadData thread_data); // Window will be closed iff return value is true.
int MenuetOnIdle(Kolibri::TThreadData thread_data); // Return the time to wait next message.
void MenuetOnSize(int window_rect[/* 4 */], Kolibri::TThreadData thread_data); // When the window is resized.
void MenuetOnKeyPress(Kolibri::TThreadData thread_data); // When user press a key.
void MenuetOnMouse(Kolibri::TThreadData thread_data); // When user move a mouse.
bool KolibriOnClose(Kolibri::TThreadData thread_data); // Window will be closed iff return value is true.
int KolibriOnIdle(Kolibri::TThreadData thread_data); // Return the time to wait next message.
void KolibriOnSize(int window_rect[/* 4 */], Kolibri::TThreadData thread_data); // When the window is resized.
void KolibriOnKeyPress(Kolibri::TThreadData thread_data); // When user press a key.
void KolibriOnMouse(Kolibri::TThreadData thread_data); // When user move a mouse.
#ifdef __MENUET__
@ -258,18 +259,18 @@ namespace Kolibri
void _GetStartData(TStartData &start_data, TThreadData thread_data)
{
start_data.Left = (unsigned short)((unsigned long)thread_data[MENUET_THREAD_DATA_X] >> 16);
start_data.Width = (unsigned short)((unsigned long)thread_data[MENUET_THREAD_DATA_X]);
start_data.Top = (unsigned short)((unsigned long)thread_data[MENUET_THREAD_DATA_Y] >> 16);
start_data.Height = (unsigned short)((unsigned long)thread_data[MENUET_THREAD_DATA_Y]);
start_data.Left = (unsigned short)((unsigned long)thread_data[KOLIBRI_THREAD_DATA_X] >> 16);
start_data.Width = (unsigned short)((unsigned long)thread_data[KOLIBRI_THREAD_DATA_X]);
start_data.Top = (unsigned short)((unsigned long)thread_data[KOLIBRI_THREAD_DATA_Y] >> 16);
start_data.Height = (unsigned short)((unsigned long)thread_data[KOLIBRI_THREAD_DATA_Y]);
GetWindowData(start_data.WinData, thread_data);
}
void _SetStartData(const TStartData &start_data, TThreadData thread_data)
{
(unsigned long&)thread_data[MENUET_THREAD_DATA_X] =
(unsigned long&)thread_data[KOLIBRI_THREAD_DATA_X] =
((unsigned int)start_data.Left << 16) | start_data.Width;
(unsigned long&)thread_data[MENUET_THREAD_DATA_Y] =
(unsigned long&)thread_data[KOLIBRI_THREAD_DATA_Y] =
((unsigned int)start_data.Top << 16) | start_data.Height;
SetWindowData(start_data.WinData, thread_data);
}
@ -373,9 +374,9 @@ namespace Kolibri
Lock(&_ThreadMutex);
if (_ExitProcessNow) ExitProcess();
thread_table_item = &_ThreadTable[_HashByte(pid)];
thread_data[MENUET_THREAD_DATA_NEXT] = (void*)*thread_table_item;
(unsigned int&)thread_data[MENUET_THREAD_DATA_PID] = pid;
*(_TThreadDataTemplate*)(thread_data + MENUET_THREAD_DATA_FLAG) = _ThreadDataTemplate;
thread_data[KOLIBRI_THREAD_DATA_NEXT] = (void*)*thread_table_item;
(unsigned int&)thread_data[KOLIBRI_THREAD_DATA_PID] = pid;
*(_TThreadDataTemplate*)(thread_data + KOLIBRI_THREAD_DATA_FLAG) = _ThreadDataTemplate;
*thread_table_item = thread_data;
UnLock(&_ThreadMutex);
if (_ExitProcessNow) ExitProcess();
@ -383,10 +384,10 @@ namespace Kolibri
TStartData start_data;
_GetStartData(start_data, thread_data);
_ApplyCommonColors(start_data.WinData);
(unsigned int&)thread_data[MENUET_THREAD_DATA_FLAG] |= 0x40000000;
thread_data[MENUET_THREAD_DATA_TITLE] = (void*)(&start_data);
if (!MenuetOnStart(start_data, thread_data)) return false;
(unsigned int&)thread_data[MENUET_THREAD_DATA_FLAG] &= ~0x40000000;
(unsigned int&)thread_data[KOLIBRI_THREAD_DATA_FLAG] |= 0x40000000;
thread_data[KOLIBRI_THREAD_DATA_TITLE] = (void*)(&start_data);
if (!KolibriOnStart(start_data, thread_data)) return false;
(unsigned int&)thread_data[KOLIBRI_THREAD_DATA_FLAG] &= ~0x40000000;
_SetStartData(start_data, thread_data);
return true;
}
@ -402,10 +403,10 @@ namespace Kolibri
{
if (*thread_table_item == thread_data)
{
*thread_table_item = (TThreadData)thread_data[MENUET_THREAD_DATA_NEXT];
*thread_table_item = (TThreadData)thread_data[KOLIBRI_THREAD_DATA_NEXT];
break;
}
thread_table_item = (TThreadData*)(*thread_table_item + MENUET_THREAD_DATA_NEXT);
thread_table_item = (TThreadData*)(*thread_table_item + KOLIBRI_THREAD_DATA_NEXT);
}
UnLock(&_ThreadMutex);
if (_ExitProcessNow) ExitProcess();
@ -413,59 +414,59 @@ namespace Kolibri
void GetWindowData(TWindowData &win_data, TThreadData thread_data)
{
if ((unsigned int)thread_data[MENUET_THREAD_DATA_FLAG] & 0x40000000)
if ((unsigned int)thread_data[KOLIBRI_THREAD_DATA_FLAG] & 0x40000000)
{
win_data = ((TStartData*)thread_data[MENUET_THREAD_DATA_TITLE])->WinData;
win_data = ((TStartData*)thread_data[KOLIBRI_THREAD_DATA_TITLE])->WinData;
return;
}
win_data.WindowType = (unsigned short)((unsigned int)thread_data[MENUET_THREAD_DATA_C_WINDOW] >> 24);
win_data.HeaderType = (unsigned short)((unsigned int)thread_data[MENUET_THREAD_DATA_C_HEADER] >> 24);
win_data.WindowColor = (unsigned int)thread_data[MENUET_THREAD_DATA_C_WINDOW] & 0xFFFFFF;
win_data.HeaderColor = (unsigned int)thread_data[MENUET_THREAD_DATA_C_HEADER] & 0xFFFFFF;
win_data.BorderColor = (unsigned int)thread_data[MENUET_THREAD_DATA_C_BORDER] & 0xFFFFFF;
win_data.TitleColor = (unsigned int)thread_data[MENUET_THREAD_DATA_C_TITLE] & 0xFFFFFF;
win_data.Title = (char*)thread_data[MENUET_THREAD_DATA_TITLE];
win_data.WindowType = (unsigned short)((unsigned int)thread_data[KOLIBRI_THREAD_DATA_C_WINDOW] >> 24);
win_data.HeaderType = (unsigned short)((unsigned int)thread_data[KOLIBRI_THREAD_DATA_C_HEADER] >> 24);
win_data.WindowColor = (unsigned int)thread_data[KOLIBRI_THREAD_DATA_C_WINDOW] & 0xFFFFFF;
win_data.HeaderColor = (unsigned int)thread_data[KOLIBRI_THREAD_DATA_C_HEADER] & 0xFFFFFF;
win_data.BorderColor = (unsigned int)thread_data[KOLIBRI_THREAD_DATA_C_BORDER] & 0xFFFFFF;
win_data.TitleColor = (unsigned int)thread_data[KOLIBRI_THREAD_DATA_C_TITLE] & 0xFFFFFF;
win_data.Title = (char*)thread_data[KOLIBRI_THREAD_DATA_TITLE];
}
void SetWindowData(const TWindowData &win_data, TThreadData thread_data)
{
if ((unsigned int)thread_data[MENUET_THREAD_DATA_FLAG] & 0x40000000)
if ((unsigned int)thread_data[KOLIBRI_THREAD_DATA_FLAG] & 0x40000000)
{
((TStartData*)thread_data[MENUET_THREAD_DATA_TITLE])->WinData = win_data;
((TStartData*)thread_data[KOLIBRI_THREAD_DATA_TITLE])->WinData = win_data;
return;
}
(unsigned int&)thread_data[MENUET_THREAD_DATA_C_WINDOW] =
(unsigned int&)thread_data[KOLIBRI_THREAD_DATA_C_WINDOW] =
((unsigned int)win_data.WindowType << 24) | (win_data.WindowColor & 0xFFFFFF);
(unsigned int&)thread_data[MENUET_THREAD_DATA_C_HEADER] =
(unsigned int&)thread_data[KOLIBRI_THREAD_DATA_C_HEADER] =
((unsigned int)win_data.HeaderType << 24) | (win_data.HeaderColor & 0xFFFFFF);
(unsigned int&)thread_data[MENUET_THREAD_DATA_C_BORDER] = win_data.BorderColor & 0xFFFFFF;
(unsigned int&)thread_data[MENUET_THREAD_DATA_C_TITLE] = win_data.TitleColor & 0xFFFFFF;
thread_data[MENUET_THREAD_DATA_TITLE] = (void*)win_data.Title;
(unsigned int&)thread_data[KOLIBRI_THREAD_DATA_C_BORDER] = win_data.BorderColor & 0xFFFFFF;
(unsigned int&)thread_data[KOLIBRI_THREAD_DATA_C_TITLE] = win_data.TitleColor & 0xFFFFFF;
thread_data[KOLIBRI_THREAD_DATA_TITLE] = (void*)win_data.Title;
Invalidate(1, thread_data);
}
void CloseWindow(TThreadData thread_data)
{
(unsigned int&)thread_data[MENUET_THREAD_DATA_FLAG] |= 0x80000000;
(unsigned int&)thread_data[KOLIBRI_THREAD_DATA_FLAG] |= 0x80000000;
}
void Invalidate(int frame, TThreadData thread_data)
{
if (frame < 0) return;
(unsigned int&)thread_data[MENUET_THREAD_DATA_FLAG] |= (frame ? 3 : 1);
(unsigned int&)thread_data[KOLIBRI_THREAD_DATA_FLAG] |= (frame ? 3 : 1);
}
void* GetPicture(unsigned short &width, unsigned short &height, TThreadData thread_data)
{
width = (unsigned short)((unsigned int)thread_data[MENUET_THREAD_DATA_SZ_PICT] >> 16);
height = (unsigned short)((unsigned int)thread_data[MENUET_THREAD_DATA_SZ_PICT]);
return (void*)thread_data[MENUET_THREAD_DATA_PICTURE];
width = (unsigned short)((unsigned int)thread_data[KOLIBRI_THREAD_DATA_SZ_PICT] >> 16);
height = (unsigned short)((unsigned int)thread_data[KOLIBRI_THREAD_DATA_SZ_PICT]);
return (void*)thread_data[KOLIBRI_THREAD_DATA_PICTURE];
}
void SetPicture(void *picture, unsigned short width, unsigned short height, TThreadData thread_data)
{
thread_data[MENUET_THREAD_DATA_PICTURE] = (void*)picture;
(unsigned int&)thread_data[MENUET_THREAD_DATA_SZ_PICT] =
thread_data[KOLIBRI_THREAD_DATA_PICTURE] = (void*)picture;
(unsigned int&)thread_data[KOLIBRI_THREAD_DATA_SZ_PICT] =
(width == 0 || height == 0) ? 0 : (((unsigned int)width << 16) | height);
Invalidate(0, thread_data);
}
@ -474,9 +475,9 @@ namespace Kolibri
void GetBorderHeader(unsigned short &border_size, unsigned short &header_size, TThreadData thread_data)
{
int win_type = ((unsigned int)thread_data[MENUET_THREAD_DATA_FLAG] & 0x40000000) ?
((TStartData*)thread_data[MENUET_THREAD_DATA_TITLE])->WinData.WindowType :
((unsigned int)thread_data[MENUET_THREAD_DATA_C_WINDOW] >> 24);
int win_type = ((unsigned int)thread_data[KOLIBRI_THREAD_DATA_FLAG] & 0x40000000) ?
((TStartData*)thread_data[KOLIBRI_THREAD_DATA_TITLE])->WinData.WindowType :
((unsigned int)thread_data[KOLIBRI_THREAD_DATA_C_WINDOW] >> 24);
border_size = MENUET_BORDER_SIZE;
header_size = short(((win_type & 15) == 3) ? _GetSkinHeader() : MENUET_HEADER_SIZE);
}
@ -533,5 +534,5 @@ namespace Kolibri
#endif // else: def __MENUET__
#endif // ndef __MENUET_H_INCLUDED_
#endif // ndef __KOLIBRI_H_INCLUDED_

View File

@ -1,5 +1,5 @@
#ifndef __MENUET_FILE_H_INCLUDED_
#define __MENUET_FILE_H_INCLUDED_
#ifndef __KOLIBRI_FILE_H_INCLUDED_
#define __KOLIBRI_FILE_H_INCLUDED_
#include <kolibri.h>
#include <kos_heap.h>
@ -67,7 +67,7 @@ namespace Kolibri
if (!name || !name[0]) return 0;
unsigned int name_len = StrLen(name) + 1;
unsigned int data_len = (_FileDataStruct::PosName + name_len + 3) & ~3;
buffer_length = (buffer_length / MENUET_FILE_BLOCK_SIZE) * MENUET_FILE_BLOCK_SIZE;
buffer_length = (buffer_length / KOLIBRI_FILE_BLOCK_SIZE) * KOLIBRI_FILE_BLOCK_SIZE;
if (buffer_length) data_len += buffer_length + 2*sizeof(unsigned int);
TFileData file = (TFileData)Alloc(_FileDataStruct::PosName + data_len);
if (!file) return 0;
@ -119,7 +119,7 @@ namespace Kolibri
if (file_data->buffer) buffer = file_data->buffer;
else if (temp_mem)
{
buffer = (unsigned int*)((char*)temp_mem + MENUET_FILE_BLOCK_SIZE);
buffer = (unsigned int*)((char*)temp_mem + KOLIBRI_FILE_BLOCK_SIZE);
}
else return 0;
if (!buffer[1]) return 0;
@ -142,18 +142,18 @@ namespace Kolibri
{
int res;
unsigned int len0, len1;
size /= MENUET_FILE_BLOCK_SIZE;
size /= KOLIBRI_FILE_BLOCK_SIZE;
if (!file_data || !mem || size <= 0) return -1;
file_data->access_param[0] = 0;
file_data->access_param[1] = (file_data->position / MENUET_FILE_BLOCK_SIZE) * MENUET_FILE_BLOCK_SIZE;
file_data->access_param[1] = (file_data->position / KOLIBRI_FILE_BLOCK_SIZE) * KOLIBRI_FILE_BLOCK_SIZE;
file_data->access_param[2] = 0;
file_data->access_param[3] = size * MENUET_FILE_BLOCK_SIZE;
file_data->access_param[3] = size * KOLIBRI_FILE_BLOCK_SIZE;
file_data->access_param[4] = (unsigned int)mem;
res = _FileAccess(file_data->access_param);
if (res != 0 && res != 6) return (res & 255) - 1024;
if (file_data->length <= file_data->position) return 0;
len0 = file_data->length - file_data->position;
len1 = size * MENUET_FILE_BLOCK_SIZE - (file_data->position % MENUET_FILE_BLOCK_SIZE);
len1 = size * KOLIBRI_FILE_BLOCK_SIZE - (file_data->position % KOLIBRI_FILE_BLOCK_SIZE);
return (len0 <= len1) ? len0 : len1;
}
@ -167,16 +167,16 @@ namespace Kolibri
{
if (!temp_mem)
{
temp_mem = Alloc(MENUET_FILE_BLOCK_SIZE + 2*sizeof(unsigned int));
temp_mem = Alloc(KOLIBRI_FILE_BLOCK_SIZE + 2*sizeof(unsigned int));
if (!temp_mem) return -10;
}
buffer = (unsigned int*)((char*)temp_mem + MENUET_FILE_BLOCK_SIZE);
buffer[0] = MENUET_FILE_BLOCK_SIZE;
buffer = (unsigned int*)((char*)temp_mem + KOLIBRI_FILE_BLOCK_SIZE);
buffer[0] = KOLIBRI_FILE_BLOCK_SIZE;
}
buffer[1] = buffer[0];
res = _FileReadSystem(file_data, (char*)buffer - buffer[1], buffer[1]);
if (res < 0) buffer[1] = 0;
else buffer[1] -= file_data->position % MENUET_FILE_BLOCK_SIZE;
else buffer[1] -= file_data->position % KOLIBRI_FILE_BLOCK_SIZE;
return res;
}
@ -200,7 +200,7 @@ namespace Kolibri
read_len = res;
mem = (char*)mem + res;
size -= res;
tlen = file_data->position % MENUET_FILE_BLOCK_SIZE;
tlen = file_data->position % KOLIBRI_FILE_BLOCK_SIZE;
if (tlen)
{
res = _FileBufferSystem(file_data, temp_mem);
@ -220,7 +220,7 @@ namespace Kolibri
mem = (char*)mem + res;
size -= res;
}
if (size >= (file_data->buffer ? file_data->buffer[0] : MENUET_FILE_BLOCK_SIZE))
if (size >= (file_data->buffer ? file_data->buffer[0] : KOLIBRI_FILE_BLOCK_SIZE))
{
res = _FileReadSystem(file_data, mem, size);
if (res < 0)
@ -230,7 +230,7 @@ namespace Kolibri
}
file_data->position += res;
read_len += res;
if (res < (size / MENUET_FILE_BLOCK_SIZE) * MENUET_FILE_BLOCK_SIZE)
if (res < (size / KOLIBRI_FILE_BLOCK_SIZE) * KOLIBRI_FILE_BLOCK_SIZE)
{
if (temp_mem) Free(temp_mem);
return read_len;
@ -274,5 +274,5 @@ namespace Kolibri
#endif // else: def __MENUET__
#endif // ndef __MENUET_FILE_H_INCLUDED_
#endif // ndef __KOLIBRI_FILE_H_INCLUDED_

View File

@ -4,48 +4,48 @@ MENUET_BORDER_SIZE = 4;
MENUET_HEADER_SIZE = 20;
;const int
MENUET_THREAD_DATA_USER = 0; // Thread data begin from the user dword
KOLIBRI_THREAD_DATA_USER = 0; // Thread data begin from the user dword
;const int
MENUET_THREAD_DATA_ST_BEGIN = 1; // Stack beginning follows after the user dword
KOLIBRI_THREAD_DATA_ST_BEGIN = 1; // Stack beginning follows after the user dword
;const int
MENUET_THREAD_DATA_NEXT = 2;
KOLIBRI_THREAD_DATA_NEXT = 2;
;const int
MENUET_THREAD_DATA_PID = 3;
KOLIBRI_THREAD_DATA_PID = 3;
;const int
MENUET_THREAD_DATA_FLAG = 4;
KOLIBRI_THREAD_DATA_FLAG = 4;
;const int
MENUET_THREAD_DATA_X = 5;
KOLIBRI_THREAD_DATA_X = 5;
;const int
MENUET_THREAD_DATA_Y = 6;
KOLIBRI_THREAD_DATA_Y = 6;
;const int
MENUET_THREAD_DATA_C_WINDOW = 7;
KOLIBRI_THREAD_DATA_C_WINDOW = 7;
;const int
MENUET_THREAD_DATA_C_HEADER = 8;
KOLIBRI_THREAD_DATA_C_HEADER = 8;
;const int
MENUET_THREAD_DATA_C_BORDER = 9;
KOLIBRI_THREAD_DATA_C_BORDER = 9;
;const int
MENUET_THREAD_DATA_C_TITLE = 10;
KOLIBRI_THREAD_DATA_C_TITLE = 10;
;const int
MENUET_THREAD_DATA_TITLE = 11;
KOLIBRI_THREAD_DATA_TITLE = 11;
;const int
MENUET_THREAD_DATA_PICTURE = 12;
KOLIBRI_THREAD_DATA_PICTURE = 12;
;const int
MENUET_THREAD_DATA_SZ_PICT = 13;
KOLIBRI_THREAD_DATA_SZ_PICT = 13;
;const int
MENUET_THREAD_DATA_LAST_SX = 14;
KOLIBRI_THREAD_DATA_LAST_SX = 14;
;const int
MENUET_THREAD_DATA_LAST_SY = 15;
KOLIBRI_THREAD_DATA_LAST_SY = 15;
;const int
MENUET_THREAD_DATA_LEN = 16;
KOLIBRI_THREAD_DATA_LEN = 16;
;const int
MENUET_MUTEX_MAX_TIME_WAIT = 20;
;const int
MENUET_FILE_BLOCK_SIZE = 512;
KOLIBRI_FILE_BLOCK_SIZE = 512;
;const int
MENUET_FILE_MEMORY_OS_NEED = 4096;
KOLIBRI_FILE_MEMORY_OS_NEED = 4096;
;/***
@ -139,7 +139,7 @@ proc @Kolibri@ThreadMain$qpvt1
xchg ebx,[esp+4]
xchg ebp,[esp+8]
push esi edi
sub esp,MENUET_THREAD_DATA_LEN*4
sub esp,KOLIBRI_THREAD_DATA_LEN*4
mov [esp],ebx
mov [esp+4],ebp
mov eax,40
@ -165,21 +165,21 @@ end if
jnz .main_test_close_first
jmp .main_end
.main_close_first:
btr dword [esp+MENUET_THREAD_DATA_FLAG*4],31
btr dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],31
push esp
call @@MenuetOnClose$qppv
call @@KolibriOnClose$qppv
pop ecx
test al,al
jnz .main_end
.main_test_close_first:
cmp dword [esp+MENUET_THREAD_DATA_FLAG*4],0
cmp dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],0
jl .main_close_first
push esp
push dword 1
call @Kolibri@Redraw$qippv
add esp,8
.main_paint_msg:
or dword [esp+MENUET_THREAD_DATA_FLAG*4],3
or dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],3
sub esp,1024
mov eax,9
mov ebx,esp
@ -190,13 +190,13 @@ end if
mov ecx,[esp+42]
mov edx,[esp+46]
add esp,1024
cmp ecx,[esp+MENUET_THREAD_DATA_LAST_SX*4]
cmp ecx,[esp+KOLIBRI_THREAD_DATA_LAST_SX*4]
jnz .main_size
cmp edx,[esp+MENUET_THREAD_DATA_LAST_SY*4]
cmp edx,[esp+KOLIBRI_THREAD_DATA_LAST_SY*4]
jz .main_paint
.main_size:
mov [esp+MENUET_THREAD_DATA_LAST_SX*4],ecx
mov [esp+MENUET_THREAD_DATA_LAST_SY*4],edx
mov [esp+KOLIBRI_THREAD_DATA_LAST_SX*4],ecx
mov [esp+KOLIBRI_THREAD_DATA_LAST_SY*4],edx
push edx
push ecx
push ebx
@ -205,12 +205,12 @@ end if
mov edx,esp
push ecx
push edx
call @@MenuetOnSize$qpippv
call @@KolibriOnSize$qpippv
add esp,24
test dword [esp+MENUET_THREAD_DATA_FLAG*4],3
test dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],3
jz .main_cycle
.main_paint:
cmp dword [esp+MENUET_THREAD_DATA_FLAG*4],0
cmp dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],0
jl .main_close
push esp
push dword 0
@ -219,15 +219,15 @@ end if
.main_cycle:
mov eax,11
.main_message:
cmp dword [esp+MENUET_THREAD_DATA_FLAG*4],0
cmp dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],0
jl .main_close
int 0x40
test eax,eax
jnz .main_on_message
cmp dword [esp+MENUET_THREAD_DATA_FLAG*4],0
cmp dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],0
jne .main_paint
push esp
call @@MenuetOnIdle$qppv
call @@KolibriOnIdle$qppv
pop ecx
test eax,eax
jz .main_cycle
@ -240,12 +240,12 @@ end if
jmp .main_message
.main_key_press:
push esp
call @@MenuetOnKeyPress$qppv
call @@KolibriOnKeyPress$qppv
pop ecx
jmp .main_cycle
.main_mouse:
push esp
call @@MenuetOnMouse$qppv
call @@KolibriOnMouse$qppv
pop ecx
jmp .main_cycle
.main_on_message:
@ -263,9 +263,9 @@ end if
test al,al
jnz .main_cycle
.main_close:
btr dword [esp+MENUET_THREAD_DATA_FLAG*4],31
btr dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],31
push esp
call @@MenuetOnClose$qppv
call @@KolibriOnClose$qppv
pop ecx
test al,al
jz .main_button
@ -304,7 +304,7 @@ end if
lock dec dword [@Kolibri@_ThreadScanCount+4]
mov ebp,[esp+4]
mov ebx,[esp]
add esp,MENUET_THREAD_DATA_LEN*4
add esp,KOLIBRI_THREAD_DATA_LEN*4
mov eax,ebp
pop edi esi
xchg ebp,[esp+8]
@ -324,7 +324,7 @@ macro call func
proc @Kolibri@Redraw$qippv
push ebp
mov ebp,[esp+12]
mov edx,[ebp+MENUET_THREAD_DATA_FLAG*4]
mov edx,[ebp+KOLIBRI_THREAD_DATA_FLAG*4]
cmp dword [esp+8],0
jl .redraw_only_inv
jz .redraw_no_frame
@ -333,7 +333,7 @@ proc @Kolibri@Redraw$qippv
bt edx,30
jnc .redraw_begin
or dl,1
mov [ebp+MENUET_THREAD_DATA_FLAG*4],edx
mov [ebp+KOLIBRI_THREAD_DATA_FLAG*4],edx
jmp .redraw_end
.redraw_only_inv:
test dl,3
@ -343,20 +343,20 @@ proc @Kolibri@Redraw$qippv
ret
.redraw_begin:
push ebx esi edi
and dword [ebp+MENUET_THREAD_DATA_FLAG*4],0xFFFFFFFC
and dword [ebp+KOLIBRI_THREAD_DATA_FLAG*4],0xFFFFFFFC
test dl,2
jz .redraw_picture
mov eax,12
mov ebx,1
int 0x40
xor eax,eax
mov ebx,[ebp+MENUET_THREAD_DATA_X*4]
mov ecx,[ebp+MENUET_THREAD_DATA_Y*4]
mov edx,[ebp+MENUET_THREAD_DATA_C_WINDOW*4]
mov esi,[ebp+MENUET_THREAD_DATA_C_HEADER*4]
mov edi,[ebp+MENUET_THREAD_DATA_C_BORDER*4]
mov ebx,[ebp+KOLIBRI_THREAD_DATA_X*4]
mov ecx,[ebp+KOLIBRI_THREAD_DATA_Y*4]
mov edx,[ebp+KOLIBRI_THREAD_DATA_C_WINDOW*4]
mov esi,[ebp+KOLIBRI_THREAD_DATA_C_HEADER*4]
mov edi,[ebp+KOLIBRI_THREAD_DATA_C_BORDER*4]
int 0x40
mov edx,[ebp+MENUET_THREAD_DATA_TITLE*4]
mov edx,[ebp+KOLIBRI_THREAD_DATA_TITLE*4]
test edx,edx
jz .window_defined
mov edi,edx
@ -370,7 +370,7 @@ proc @Kolibri@Redraw$qippv
jz .window_defined
mov eax,4
mov ebx,0x00070007
mov ecx,[ebp+MENUET_THREAD_DATA_C_TITLE*4]
mov ecx,[ebp+KOLIBRI_THREAD_DATA_C_TITLE*4]
int 0x40
.window_defined:
mov eax,12
@ -380,12 +380,12 @@ proc @Kolibri@Redraw$qippv
mov eax,12
mov ebx,2
int 0x40
mov esi,[ebp+MENUET_THREAD_DATA_PICTURE*4]
mov esi,[ebp+KOLIBRI_THREAD_DATA_PICTURE*4]
test esi,esi
jz .redraw_end_draw
mov ecx,[ebp+MENUET_THREAD_DATA_SZ_PICT*4]
mov ecx,[ebp+KOLIBRI_THREAD_DATA_SZ_PICT*4]
jecxz .redraw_end_draw
mov al,byte [ebp+MENUET_THREAD_DATA_C_WINDOW*4+3]
mov al,byte [ebp+KOLIBRI_THREAD_DATA_C_WINDOW*4+3]
and al,15
mov edx,MENUET_BORDER_SIZE*65536+MENUET_HEADER_SIZE
cmp al,3
@ -448,11 +448,11 @@ proc @Kolibri@ExitProcess$qv
mov eax,dword [@Kolibri@_ThreadTable+eax*4]
jmp .exit_process_test
.exit_process_next:
mov eax,dword [eax+MENUET_THREAD_DATA_NEXT*4]
mov eax,dword [eax+KOLIBRI_THREAD_DATA_NEXT*4]
.exit_process_test:
test eax,eax
jz .exit_process_continue
cmp ebx,[eax+MENUET_THREAD_DATA_PID*4]
cmp ebx,[eax+KOLIBRI_THREAD_DATA_PID*4]
jnz .exit_process_next
mov eax,18
mov ebx,2
@ -492,7 +492,7 @@ endp
proc @Kolibri@ReturnMessageLoop$qppv,@Kolibri@ThreadMain$qpvt1
mov esp,[esp+4]
bt dword [esp+MENUET_THREAD_DATA_FLAG*4],30
bt dword [esp+KOLIBRI_THREAD_DATA_FLAG*4],30
jc Menuet_main_end
jmp Menuet_main_cycle
endp
@ -584,6 +584,17 @@ proc @Kolibri@ReadCommonColors$qpui uses ebx
ret
endp
proc @Kolibri@DrawText$qssipxc uses ebx
mov eax,4
mov ebx,[esp+8-2]
mov bx,[esp+12]
mov ecx,[esp+16]
or ecx,0x80000000
mov edx,[esp+20]
int 0x40
ret
endp
proc @Kolibri@GetProcessInfo$qpuipct1t1piui uses ebx esi edi
sub esp,1024
mov eax,9
@ -646,7 +657,7 @@ endp
proc @Kolibri@GetPid$qppv
mov ecx,[esp+4]
mov eax,[ecx+MENUET_THREAD_DATA_PID*4]
mov eax,[ecx+KOLIBRI_THREAD_DATA_PID*4]
ret
endp
@ -691,11 +702,11 @@ proc @Kolibri@GetThreadData$qui
mov ecx,[esp+4]
jmp .get_thread_data_test
.get_thread_data_loop:
mov eax,dword [eax+MENUET_THREAD_DATA_NEXT*4]
mov eax,dword [eax+KOLIBRI_THREAD_DATA_NEXT*4]
.get_thread_data_test:
test eax,eax
jz .get_thread_data_end
cmp ecx,[eax+MENUET_THREAD_DATA_PID*4]
cmp ecx,[eax+KOLIBRI_THREAD_DATA_PID*4]
jnz .get_thread_data_loop
.get_thread_data_end:
lock dec dword [@Kolibri@_ThreadScanCount]

View File

@ -46,13 +46,13 @@ macro usedef [link]
if ~link eq
virtual at 0
forward
dd link
dd link
common
end virtual
end if
}
macro define x,[link]
macro define_f x,[link]
{
common
if x eq

View File

@ -1699,7 +1699,7 @@ void Paint(int what, TThreadData th)
SetPicture(picture, (unsigned short)xpar.win, (unsigned short)ypar.win, th);
}
bool MenuetOnStart(TStartData &me_start, TThreadData th)
bool KolibriOnStart(TStartData &me_start, TThreadData th)
{
randomize();
me_start.WinData.Title = "Black and white Life";
@ -1714,14 +1714,14 @@ bool MenuetOnStart(TStartData &me_start, TThreadData th)
return true;
}
bool MenuetOnClose(TThreadData)
bool KolibriOnClose(TThreadData)
{
SetPictureSize(0, 0);
SetPoleSize(0, 0);
return true;
}
int MenuetOnIdle(TThreadData th)
int KolibriOnIdle(TThreadData th)
{
static const unsigned int WAIT_TIME = 2, GEN_TIME = 1;
int res = -1;
@ -1788,7 +1788,7 @@ int MenuetOnIdle(TThreadData th)
return res;
}
void MenuetOnSize(int window_rect[], Kolibri::TThreadData th)
void KolibriOnSize(int window_rect[], Kolibri::TThreadData th)
{
unsigned short w, h;
GetClientSize(w, h, window_rect[2], window_rect[3], th);
@ -1798,7 +1798,7 @@ void MenuetOnSize(int window_rect[], Kolibri::TThreadData th)
Paint(PaintWNull | PaintWNow, th);
}
void MenuetOnKeyPress(TThreadData th)
void KolibriOnKeyPress(TThreadData th)
{
int ch;
while ((ch = GetKey()) >= 0)
@ -1898,7 +1898,7 @@ void MenuetOnKeyPress(TThreadData th)
}
}
void MenuetOnMouse(TThreadData th)
void KolibriOnMouse(TThreadData th)
{
short xp = 0, yp = 0;
int w, h, x, y, xx, yy, m;