life2: change namespace to 'Kolibri'

git-svn-id: svn://kolibrios.org@8129 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2020-11-02 18:44:51 +00:00
parent df14e6f07e
commit 69ced70cd8
15 changed files with 492 additions and 564 deletions

View File

@ -1,4 +1,3 @@
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

View File

@ -1,11 +1,11 @@
#ifndef __MENUET_H_INCLUDED_
#define __MENUET_H_INCLUDED_
#include <me_lib.h>
#include <kos_lib.h>
// Menuet interface.
// Kolibri interface.
namespace Menuet // All menuet functions, types and data are nested in the (Menuet) namespace.
namespace Kolibri // All kolibri functions, types and data are nested in the (Kolibri) namespace.
{
const char *DebugPrefix = "User program: ";
char CommandLine[257];
@ -137,17 +137,17 @@ namespace Menuet // All menuet functions, types and data are nested in the (Me
// Function, defined outside.
bool MenuetOnStart(Menuet::TStartData &me_start, Menuet::TThreadData thread_data);
bool MenuetOnStart(Kolibri::TStartData &me_start, Kolibri::TThreadData thread_data);
// Window will be created iff return value is true.
bool MenuetOnClose(Menuet::TThreadData thread_data); // Window will be closed iff return value is true.
int MenuetOnIdle(Menuet::TThreadData thread_data); // Return the time to wait next message.
void MenuetOnSize(int window_rect[/* 4 */], Menuet::TThreadData thread_data); // When the window is resized.
void MenuetOnKeyPress(Menuet::TThreadData thread_data); // When user press a key.
void MenuetOnMouse(Menuet::TThreadData thread_data); // When user move a mouse.
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.
#ifdef __MENUET__
namespace Menuet
namespace Kolibri
{
// Structures.
@ -248,7 +248,7 @@ namespace Menuet
// Constants from fasm.
#include <me_func.inc>
#include <kos_func.inc>
// Functions.
@ -508,7 +508,7 @@ namespace Menuet
#else // def __MENUET__
namespace Menuet
namespace Kolibri
{
struct TMutex
{

View File

@ -1,12 +1,12 @@
#ifndef __MENUET_FILE_H_INCLUDED_
#define __MENUET_FILE_H_INCLUDED_
#include <menuet.h>
#include <me_heap.h>
#include <kolibri.h>
#include <kos_heap.h>
// Menuet file interface.
// Kolibri file interface.
namespace Menuet // All menuet functions, types and data are nested in the (Menuet) namespace.
namespace Kolibri // All kolibri functions, types and data are nested in the (Kolibri) namespace.
{
struct _FileDataStruct;
typedef _FileDataStruct *TFileData;
@ -24,7 +24,7 @@ namespace Menuet // All menuet functions, types and data are nested in the (Me
#ifdef __MENUET__
namespace Menuet
namespace Kolibri
{
// Define the file data structure.
@ -264,7 +264,7 @@ namespace Menuet
#else // def __MENUET__
namespace Menuet
namespace Kolibri
{
struct _FileDataStruct
{

View File

@ -1,12 +1,12 @@
#ifndef __MENUET_HEAP_H_INCLUDED_
#define __MENUET_HEAP_H_INCLUDED_
#include <menuet.h>
#include <kolibri.h>
#include <memheap.h>
// Menuet memory heap interface.
// Kolibri memory heap interface.
namespace Menuet // All menuet functions, types and data are nested in the (Menuet) namespace.
namespace Kolibri // All kolibri functions, types and data are nested in the (Kolibri) namespace.
{
void *Alloc(unsigned int size);
void *ReAlloc(void *mem, unsigned int size);
@ -15,7 +15,7 @@ namespace Menuet // All menuet functions, types and data are nested in the (Me
#ifdef __MENUET__
namespace Menuet
namespace Kolibri
{
// Global variables

View File

@ -1,16 +1,16 @@
;/***
MenuetHeapInit = @@Menuet@_HeapInit$qpvt1t1
MenuetHeapInit = @@Kolibri@_HeapInit$qpvt1t1
MenuetHeapAlloc = @@Menuet@Alloc$qui
MenuetHeapAlloc = @@Kolibri@Alloc$qui
MenuetHeapReAlloc = @@Menuet@ReAlloc$qpvui
MenuetHeapReAlloc = @@Kolibri@ReAlloc$qpvui
MenuetHeapFree = @@Menuet@Free$qpv
MenuetHeapFree = @@Kolibri@Free$qpv
MenuetHeapFreeAndThreadFinish = @Menuet@_FreeAndThreadFinish$qpvpi
MenuetHeapFreeAndThreadFinish = @Kolibri@_FreeAndThreadFinish$qpvpi
define @Menuet@_SetUseMemory$qui
proc @Kolibri@_SetUseMemory$qui
push ebx
mov eax,64
mov ebx,1
@ -18,23 +18,23 @@ define @Menuet@_SetUseMemory$qui
int 0x40
pop ebx
test eax,eax
jnz Menuet_set_use_memory_nomem
jnz .set_use_memory_nomem
push ecx
push dword [@Menuet@_MenuetMemBlock]
push dword [@Kolibri@_MenuetMemBlock]
call @@MemoryHeap@ResizeBlock$q20MemoryHeap@TMemBlockpv
add esp,8
mov al,1
ret
Menuet_set_use_memory_nomem:
.set_use_memory_nomem:
xor al,al
ret
enddef
endp
define @Menuet@_RecalculateUseMemory$qui
proc @Kolibri@_RecalculateUseMemory$qui
mov eax,dword [esp+4]
mov ecx,(U_END + 3) and not 3
cmp eax,ecx
jna Menuet_recalculate_use_memory_min
jna .recalculate_use_memory_min
push ebx
sub eax,ecx
mov ebx,6
@ -45,35 +45,35 @@ define @Menuet@_RecalculateUseMemory$qui
and eax,not 3
pop ebx
ret
Menuet_recalculate_use_memory_min:
.recalculate_use_memory_min:
mov eax,ecx
ret
enddef
endp
define @Menuet@_FreeAndThreadFinish$qpvpi
proc @Kolibri@_FreeAndThreadFinish$qpvpi
mov ebx,1
mov ecx,[esp+8]
jmp Menuet_heap_free_tf_wait
Menuet_heap_free_tf_wait_loop:
jmp .heap_free_tf_wait
.heap_free_tf_wait_loop:
mov eax,5
int 0x40
shl ebx,1
cmp ebx,MENUET_MUTEX_MAX_TIME_WAIT
jna Menuet_heap_free_tf_wait
jna .heap_free_tf_wait
mov ebx,MENUET_MUTEX_MAX_TIME_WAIT
Menuet_heap_free_tf_wait:
.heap_free_tf_wait:
cmp dword [ecx],0
jnz @Menuet@ExitProcess$qv
lock bts dword [@Menuet@_MemHeapMutex],0
jc Menuet_heap_free_tf_wait_loop
jnz @Kolibri@ExitProcess$qv
lock bts dword [@Kolibri@_MemHeapMutex],0
jc .heap_free_tf_wait_loop
push dword [esp+4]
push @Menuet@_MenuetFreeSpace
push @Kolibri@_MenuetFreeSpace
call @@MemoryHeap@Free$qr21MemoryHeap@TFreeSpacepv
add esp,8
mov byte [@Menuet@_MemHeapMutex],0x40
mov byte [@Kolibri@_MemHeapMutex],0x40
or eax,-1
int 0x40
enddef
endp
macro call func
{

View File

@ -1,9 +1,9 @@
#ifndef __MENUET_LIB_H_INCLUDED_
#define __MENUET_LIB_H_INCLUDED_
// Menuet interface.
// Kolibri interface.
namespace Menuet // All menuet functions, types and data are nested in the (Menuet) namespace.
namespace Kolibri // All kolibri functions, types and data are nested in the (Kolibri) namespace.
{
unsigned int StrLen(const char *str);
char *StrCopy(char *dest, const char *src);

View File

@ -1,5 +1,4 @@
define @Menuet@StrLen$qpxc
push edi
proc @Kolibri@StrLen$qpxc uses edi
cld
mov edi,[esp+8]
mov ecx,-1
@ -7,13 +6,10 @@ define @Menuet@StrLen$qpxc
repnz scas byte [edi]
not ecx
lea eax,[ecx-1]
pop edi
ret
enddef
endp
define @Menuet@StrCopy$qpcpxc
push esi
push edi
proc @Kolibri@StrCopy$qpcpxc uses esi edi
cld
mov edi,[esp+16]
mov ecx,-1
@ -29,14 +25,10 @@ define @Menuet@StrCopy$qpcpxc
mov ecx,edx
and ecx,3
rep movs byte [edi],[esi]
pop edi
pop esi
ret
enddef
endp
define @Menuet@MemCopy$qpvpxvui
push esi
push edi
proc @Kolibri@MemCopy$qpvpxvui uses esi edi
cld
mov edi,[esp+12]
mov eax,edi
@ -48,13 +40,10 @@ define @Menuet@MemCopy$qpvpxvui
mov ecx,edx
and ecx,3
rep movs byte [edi],[esi]
pop edi
pop esi
ret
enddef
endp
define @Menuet@MemSet$qpvcui
push edi
proc @Kolibri@MemSet$qpvcui uses edi
cld
mov edi,[esp+8]
mov al,[esp+12]
@ -69,12 +58,11 @@ define @Menuet@MemSet$qpvcui
mov ecx,edx
and ecx,3
rep stos byte [edi]
pop edi
mov eax,[esp+4]
ret
enddef
endp
define __ftol
proc __ftol
sub esp,12
wait
fstcw word [esp+8]
@ -89,9 +77,9 @@ define __ftol
mov edx,[esp+4]
add esp,12
ret
enddef
endp
define @Menuet@Floor$qd
proc @Kolibri@Floor$qd
fld qword [esp+4]
mov ax,[esp+10]
shl ax,1
@ -114,5 +102,5 @@ define @Menuet@Floor$qd
add esp,2
Menuet_floor_end:
ret
enddef
endp

View File

@ -1,12 +1,12 @@
use32
org 0x0
org 0
db 'MENUET01'
dd 0x1
dd MenuetEntryPoint
dd 1
dd @Kolibri@Main$qv
dd I_END
dd U_END+STACKSIZE+HEAPSIZE
dd U_END+STACKSIZE
dd @Menuet@CommandLine,0x0
dd @Kolibri@CommandLine,0
ptr equ
offset equ
@ -78,13 +78,8 @@ macro newdef x,[link]
usedef link
}
macro nextdef x,[link]
macro nextdef x
{
common
usedef x
end if
if x eq
else if used x
x:
usedef link
}

View File

@ -1,4 +1,3 @@
#include <windows.h>
#include <string.h>
#include <process.h>
#include <stdio.h>
@ -6,11 +5,11 @@
#include <assert.h>
#include <deque.h>
#include <menuet.h>
#include <me_heap.h>
#include <me_file.h>
#include <kolibri.h>
#include <kos_heap.h>
#include <kos_file.h>
using namespace Menuet;
using namespace Kolibri;
using namespace std;
const char file_prefix[] = "";
@ -236,7 +235,7 @@ int ThreadMainProc(void *user)
return 0;
}
namespace Menuet
namespace Kolibri
{
void Main() {ThreadMain();}

View File

@ -1,11 +1,11 @@
#ifndef __MENUET_FILE_OPEN_H_INCLUDED_
#define __MENUET_FILE_OPEN_H_INCLUDED_
#include <menuet.h>
#include <kolibri.h>
// Menuet interface.
// Kolibri interface.
namespace Menuet // All menuet functions, types and data are nested in the (Menuet) namespace.
namespace Kolibri // All kolibri functions, types and data are nested in the (Kolibri) namespace.
{
struct TOpenFileStruct; // Data for a file open dialog.
#define MENUET_OPEN_FILE_INIT {} // Initializer of the file open struct, cat be redefined in a realization of the library
@ -21,7 +21,7 @@ namespace Menuet // All menuet functions, types and data are nested in the (Me
#ifdef __MENUET__
namespace Menuet
namespace Kolibri
{
// Structures.
@ -81,7 +81,7 @@ namespace Menuet
#else // else: def __MENUET__
namespace Menuet
namespace Kolibri
{
struct TOpenFileStruct
{

View File

@ -1,16 +1,12 @@
define @Menuet@OpenFileDialog$qr22Menuet@TOpenFileStruct
push ebx
push esi
push edi
push ebp
call @Menuet@GetThreadData$qv
proc @Kolibri@OpenFileDialog$qr23Kolibri@TOpenFileStruct uses ebx esi edi ebp
call @Kolibri@GetThreadData$qv
mov ebp,eax
mov ebx,[esp+20]
cmp dword [ebx+4],0
jnz Menuet_open_file_dlg_str
jnz .open_file_dlg_str
mov esi,7
jmp Menuet_open_file_dlg_alloc
Menuet_open_file_dlg_str:
jmp .open_file_dlg_alloc
.open_file_dlg_str:
cld
mov edi,[ebx+4]
mov ecx,-1
@ -18,12 +14,12 @@ Menuet_open_file_dlg_str:
repnz scas byte [edi]
not ecx
mov esi,ecx
Menuet_open_file_dlg_alloc:
.open_file_dlg_alloc:
push esi
call @@Menuet@Alloc$qui
call @@Kolibri@Alloc$qui
pop ecx
test eax,eax
jz Menuet_open_file_dlg_ret
jz .open_file_dlg_ret
mov ecx,esi
dec ecx
push esi
@ -31,17 +27,17 @@ Menuet_open_file_dlg_alloc:
push eax
mov dword [ebx],-1
cmp dword [ebx+4],0
jnz Menuet_open_file_dlg_copy
jnz .open_file_dlg_copy
mov dword [eax],0x2F64722F
mov word [eax+4],0x2F31
jmp Menuet_open_file_dlg_redraw
Menuet_open_file_dlg_copy:
jmp .open_file_dlg_redraw
.open_file_dlg_copy:
cld
mov ecx,esi
mov esi,[ebx+4]
mov edi,eax
rep movs byte [edi],[esi]
Menuet_open_file_dlg_redraw:
.open_file_dlg_redraw:
mov eax,12
mov ebx,1
int 0x40
@ -55,8 +51,8 @@ Menuet_open_file_dlg_redraw:
mov eax,4
mov ebx,0x00070007
mov ecx,[ebp+MENUET_THREAD_DATA_C_TITLE*4]
mov edx,Menuet_open_file_dlg_name
mov esi,Menuet_open_file_dlg_name_end - Menuet_open_file_dlg_name
mov edx,Kolibri_open_file_dlg_name
mov esi,Kolibri_open_file_dlg_name_end - Kolibri_open_file_dlg_name
int 0x40
mov eax,4
mov ebx,0x000C001E
@ -67,78 +63,78 @@ Menuet_open_file_dlg_redraw:
mov eax,12
mov ebx,2
int 0x40
Menuet_open_file_dlg_loop:
.open_file_dlg_loop:
mov eax,10
int 0x40
dec eax
jz Menuet_open_file_dlg_redraw
jz .open_file_dlg_redraw
dec eax
jz Menuet_open_file_dlg_key
jz .open_file_dlg_key
dec eax
jz Menuet_open_file_dlg_end
jmp Menuet_open_file_dlg_loop
Menuet_open_file_dlg_key:
jz .open_file_dlg_end
jmp .open_file_dlg_loop
.open_file_dlg_key:
xor edi,edi
Menuet_open_file_dlg_key_loop:
.open_file_dlg_key_loop:
mov eax,2
int 0x40
test al,al
jnz Menuet_open_file_dlg_key_end
jnz .open_file_dlg_key_end
cmp ah,27
jz Menuet_open_file_dlg_end
jz .open_file_dlg_end
cmp ah,13
jz Menuet_open_file_dlg_apply
jz .open_file_dlg_apply
cmp ah,8
jz Menuet_open_file_dlg_key_bsp
jz .open_file_dlg_key_bsp
cmp ah,32
jna Menuet_open_file_dlg_key_loop
jna .open_file_dlg_key_loop
mov ebx,[esp+4]
cmp ebx,[esp+8]
jb Menuet_open_file_dlg_key_any
jb .open_file_dlg_key_any
lea esi,[ebx+2*ebx]
shr esi,1
inc esi
push eax
push esi
push dword [esp+8]
call @@Menuet@ReAlloc$qpvui
call @@Kolibri@ReAlloc$qpvui
add esp,8
mov ecx,eax
pop eax
test ecx,ecx
jz Menuet_open_file_dlg_key
jz .open_file_dlg_key
mov [esp+8],esi
mov [esp],ecx
Menuet_open_file_dlg_key_any:
.open_file_dlg_key_any:
mov esi,ebx
add esi,[esp]
mov byte [esi],ah
inc ebx
mov edi,1
mov [esp+4],ebx
jmp Menuet_open_file_dlg_key_loop
Menuet_open_file_dlg_key_bsp:
jmp .open_file_dlg_key_loop
.open_file_dlg_key_bsp:
mov eax,[esp+4]
test eax,eax
jz Menuet_open_file_dlg_key_loop
jz .open_file_dlg_key_loop
dec eax
mov edi,1
mov [esp+4],eax
jmp Menuet_open_file_dlg_key_loop
Menuet_open_file_dlg_key_end:
jmp .open_file_dlg_key_loop
.open_file_dlg_key_end:
test edi,edi
jnz Menuet_open_file_dlg_redraw
jmp Menuet_open_file_dlg_loop
Menuet_open_file_dlg_apply:
jnz .open_file_dlg_redraw
jmp .open_file_dlg_loop
.open_file_dlg_apply:
mov eax,[esp+4]
inc eax
mov [esp+8],eax
push eax
push dword [esp+4]
call @@Menuet@ReAlloc$qpvui
call @@Kolibri@ReAlloc$qpvui
add esp,8
test eax,eax
jz Menuet_open_file_dlg_end
jz .open_file_dlg_end
mov eax,[esp]
mov esi,eax
add eax,[esp+4]
@ -147,27 +143,25 @@ Menuet_open_file_dlg_apply:
mov ebx,[esp+20]
mov dword [ebx],2
push dword [ebx+4]
call @@Menuet@Free$qpv
call @@Kolibri@Free$qpv
pop ecx
mov [ebx+4],esi
jmp Menuet_open_file_dlg_invalidate
Menuet_open_file_dlg_end:
call @@Menuet@Free$qpv
jmp .open_file_dlg_invalidate
.open_file_dlg_end:
call @@Kolibri@Free$qpv
add esp,12
mov ebx,[esp+20]
mov dword [ebx],1
Menuet_open_file_dlg_invalidate:
.open_file_dlg_invalidate:
push ebp
push dword 1
call @@Menuet@Invalidate$qippv
call @@Kolibri@Invalidate$qippv
add esp,8
Menuet_open_file_dlg_ret:
pop ebp
pop edi
pop esi
pop ebx
.open_file_dlg_ret:
ret
Menuet_open_file_dlg_name:
endp
Kolibri_open_file_dlg_name:
db 'Open file'
Menuet_open_file_dlg_name_end:
enddef
Kolibri_open_file_dlg_name_end:

View File

@ -1,11 +1,10 @@
#include <windows.h>
#include <commdlg.h>
#include <menuet.h>
#include <me_heap.h>
#include "me_cdlg.h"
#include <kolibri.h>
#include <kos_heap.h>
#include "kos_cdlg.h"
using namespace Menuet;
using namespace Kolibri;
extern HINSTANCE hInstance;
@ -31,7 +30,7 @@ struct TOpenFileData
char name[1];
};
namespace Menuet
namespace Kolibri
{
TOpenFileStruct::TOpenFileStruct() : data(0) {}

View File

@ -1,11 +1,11 @@
#include <menuet.h>
#include <me_heap.h>
#include <me_file.h>
#include <kolibri.h>
#include <kos_heap.h>
#include <kos_file.h>
#include "lifegen.h"
#include "life_bmp.h"
#include "me_cdlg.h"
#include "kos_cdlg.h"
using namespace Menuet;
using namespace Kolibri;
/***
#define StrLen LibbStrLen
@ -20,14 +20,13 @@ void *(*MemCopy)(void *dest, const void *src, unsigned int n) = 0;
void *(*MemSet)(void *s, char c, unsigned int n) = 0;
double (*Floor)(double x) = 0;
#include <windows.h>
void LibbInit()
{
HINSTANCE hLib = LoadLibrary("Libb.dll");
if (!hLib)
{
DebugPutString("Can't load the library.\n");
Menuet::Abort();
Kolibri::Abort();
}
StrLen = (unsigned int(*)(const char *str))GetProcAddress(hLib, "StrLen");
StrCopy = (char *(*)(char *dest, const char *src))GetProcAddress(hLib, "StrCopy");
@ -1789,7 +1788,7 @@ int MenuetOnIdle(TThreadData th)
return res;
}
void MenuetOnSize(int window_rect[], Menuet::TThreadData th)
void MenuetOnSize(int window_rect[], Kolibri::TThreadData th)
{
unsigned short w, h;
GetClientSize(w, h, window_rect[2], window_rect[3], th);
@ -1964,13 +1963,13 @@ void DllInit()
if (!hLib)
{
DebugPutString("Can't load the library.\n");
Menuet::Abort();
Kolibri::Abort();
}
DllOneGeneration = (void(__stdcall*)(int, int, void*, const void*, int))GetProcAddress(hLib, "OneGeneration");
if (!DllOneGeneration)
{
DebugPutString("Can't get a library function.\n");
Menuet::Abort();
Kolibri::Abort();
}
}

View File

@ -5,9 +5,10 @@
STACKSIZE equ 102400
HEAPSIZE equ 102400
include "include\me_start.inc"
include "include\me_func.inc"
include "include\me_heap.inc"
include "me_cdlg.inc"
include "..\..\proc32.inc"
include "include\kos_start.inc"
include "include\kos_func.inc"
include "include\kos_heap.inc"
include "kos_cdlg.inc"
include "mmxlife.inc"
;include "sse2life.inc"