imgview 0.08

git-svn-id: svn://kolibrios.org@958 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2008-12-13 23:11:59 +00:00
parent 43ecc0b6a4
commit aef7c5284b
23 changed files with 2996 additions and 0 deletions

View File

@ -0,0 +1,28 @@
//
struct MemBlock
{
Dword Size;
Dword Addr;
MemBlock *Next;
MemBlock *Previous;
};
#define INITIALQUEUESIZE (32 * 4)
#define FALSE 0
#define TRUE -1
#define MB_FREE 0
#define MB_USER 1
#define SIZE_ALIGN 4
Byte *allocmem( Dword reqsize );
Dword freemem( void *vaddress );

View File

@ -0,0 +1,163 @@
/***
*stdarg.h - defines ANSI-style macros for variable argument functions
*
* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
*
*Purpose:
* This file defines ANSI-style macros for accessing arguments
* of functions which take a variable number of arguments.
* [ANSI]
*
* [Public]
*
****/
#if _MSC_VER > 1000
#pragma once
#endif
#ifndef _INC_STDARG
#define _INC_STDARG
#if !defined(_WIN32) && !defined(_MAC)
#error ERROR: Only Mac or Win32 targets supported!
#endif
#ifdef _MSC_VER
/*
* Currently, all MS C compilers for Win32 platforms default to 8 byte
* alignment.
*/
#pragma pack(push,8)
#endif /* _MSC_VER */
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _VA_LIST_DEFINED
#ifdef _M_ALPHA
typedef struct {
char *a0; /* pointer to first homed integer argument */
int offset; /* byte offset of next parameter */
} va_list;
#else
typedef char * va_list;
#endif
#define _VA_LIST_DEFINED
#endif
#ifdef _M_IX86
#define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
#define va_start(ap,v) ( ap = (va_list)&v + _INTSIZEOF(v) )
#define va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
#define va_end(ap) ( ap = (va_list)0 )
#elif defined(_M_MRX000)
/* Use these types and definitions if generating code for MIPS */
#define va_start(ap,v) ap = (va_list)&v + sizeof(v)
#define va_end(list)
#define va_arg(list, mode) ((mode *)(list =\
(char *) ((((int)list + (__builtin_alignof(mode)<=4?3:7)) &\
(__builtin_alignof(mode)<=4?-4:-8))+sizeof(mode))))[-1]
/* +++++++++++++++++++++++++++++++++++++++++++
Because of parameter passing conventions in C:
use mode=int for char, and short types
use mode=double for float types
use a pointer for array types
+++++++++++++++++++++++++++++++++++++++++++ */
#elif defined(_M_ALPHA)
/* Use these types and definitions if generating code for ALPHA */
/*
* The Alpha compiler supports two builtin functions that are used to
* implement stdarg/varargs. The __builtin_va_start function is used
* by va_start to initialize the data structure that locates the next
* argument. The __builtin_isfloat function is used by va_arg to pick
* which part of the home area a given register argument is stored in.
* The home area is where up to six integer and/or six floating point
* register arguments are stored down (so they can also be referenced
* by a pointer like any arguments passed on the stack).
*/
extern void * __builtin_va_start(va_list, ...);
#ifdef _CFRONT
#define __builtin_isfloat(a) __builtin_alignof(a)
#endif
#define va_start(list, v) __builtin_va_start(list, v, 1)
#define va_end(list)
#define va_arg(list, mode) \
( *( ((list).offset += ((int)sizeof(mode) + 7) & -8) , \
(mode *)((list).a0 + (list).offset - \
((__builtin_isfloat(mode) && (list).offset <= (6 * 8)) ? \
(6 * 8) + 8 : ((int)sizeof(mode) + 7) & -8) \
) \
) \
)
#elif defined(_M_PPC)
/* Microsoft C8 front end (used in Motorola Merged compiler) */
/* bytes that a type occupies in the argument list */
#define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
/* return 'ap' adjusted for type 't' in arglist */
#define _ALIGNIT(ap,t) \
((((int)(ap))+(sizeof(t)<8?3:7)) & (sizeof(t)<8?~3:~7))
#define va_start(ap,v) ( ap = (va_list)&v + _INTSIZEOF(v) )
#define va_arg(ap,t) ( *(t *)((ap = (char *) (_ALIGNIT(ap, t) + _INTSIZEOF(t))) - _INTSIZEOF(t)) )
#define va_end(ap) ( ap = (va_list)0 )
#elif defined(_M_M68K)
#define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
#define va_start(ap,v) ( ap = (va_list)&v + (sizeof(v) < sizeof(int) ? sizeof(v) : _INTSIZEOF(v)) )
#define va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
#define va_end(ap) ( ap = (va_list)0 )
#elif defined(_M_MPPC)
#define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
#define va_start(ap,v) ( ap = (va_list)&v + _INTSIZEOF(v) )
#define va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
#define va_end(ap) ( ap = (va_list)0 )
#else
/* A guess at the proper definitions for other platforms */
#define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
#define va_start(ap,v) ( ap = (va_list)&v + _INTSIZEOF(v) )
#define va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
#define va_end(ap) ( ap = (va_list)0 )
#endif
#ifdef __cplusplus
}
#endif
#ifdef _MSC_VER
#pragma pack(pop)
#endif /* _MSC_VER */
#endif /* _INC_STDARG */

View File

@ -0,0 +1,29 @@
Версия 0.08 -
= Устарнена ошибка: программа вылетала при открытии несуществующего файла
= Устарнена ошибка: при открытии файла через параметры, окно не подстраивалось под размеры изображения
Версия 0.07 - 05.08.08:
= Исправлена ошибка с постоянной перерисовкой изображения
= При открытии большого изображения окно не выезжает за пределы экрана (касается эмулятора)
= Оптимизация кода
= Новые иконки для кнопок (25х25 -> 21х21)
= Новый режим отображения: подгонять под размеры окна (с сохранением пропорций изображения)
= Подогнанное изображение центрируется
Версия 0.05 - 14.07.08:
= Устранен баг с исчезновением полос прокрутки, и вообще скроллы стали юзабельней
= Правильно отображаются перевернутые tga
= Добавлены черно-белые и 16-ти цветные bmp
= Исправление мелких, не влияющих на основную работу, ошибок
Версия 0.04 - 09.07.08:
= Уменьшен размер программы, за счет удаления одинакового кода.
= Изображение не выгружается до тех пор, пока не будет открыто новое.
= Добавлен 16-битный bmp.
= Исправлена ошибка с утечкой памяти.
= Теперь с помощью соответствующих кнопок можно просматривать все, поддерживаемые программой,
файлы текущего каталога, не выходя из программы.
= Добавлена строка статуса
Версия 0.01 - 04.07.08:
= Первая версия программы.

View File

@ -0,0 +1,26 @@
ImageView v 0.07
--------------------------------------------------------------
Описание
========
Эта программа предназначена для удобного просмотра графических
файлов. Поддерживаемые форматы: bmp (без сжатия), pcx (только
256-цветные), tga (не все). Поддерживает запуск с параметрами,
поэтому можно сделать в KFAR ассоциации с соответствующими
файлами.
Интерфейс
=========
Программа имеет интуитивно понятный интерфейс. В верхней части
окна расположена панель управляющих кнопок. Вот их назначение
(слева направо): открыть файл, перейти к предыдущиму файлу в
каталоге, перейти к следующему файлу в каталоге, переключить
режим просмотра. Внизу окна имеется строка состояния, отобра-
жающая имя текущего файла, его номер в каталоге и общее число
поддерживаемых файлов в каталоге.
Sh@dy 05.08.08
alex_megasoft@mail.ru
http://artech.org.ru/

View File

@ -0,0 +1,6 @@
@echo off
@cl /c /O2 /nologo main.cpp kosSyst.cpp mcsmemm.cpp formats\pcx.cpp formats\bmp.cpp formats\tga.cpp dlgopen.cpp
@link /nologo /entry:crtStartUp /subsystem:native /base:0 /fixed /align:16 /nodefaultlib main.obj kosSyst.obj mcsmemm.obj pcx.obj bmp.obj tga.obj dlgopen.obj
@tools\pe2kos main.exe imgview.kos PARAM
@erase main.obj,kosSyst.obj,mcsmemm.obj,pcx.obj,bmp.obj,tga.obj,KosFile.obj,main.exe,dlgopen.obj
pause

View File

@ -0,0 +1,107 @@
#include "kosSyst.h"
char* DialogOpenFile(void (*draw)())
{
sProcessInfo proc;
kosFileInfo fi;
char param[6];
int i;
Dword pID,msg_num=0;
char path[1040];
Byte* pPath=(Byte*)&path;
//Ïàðàìåòðû çàïóñêà X-TREE
kos_ProcessInfo(&proc,-1);
pID=proc.processInfo.PID;
for(i=3;i!=-1;i--)
{
param[i]=(char)('0'+(pID % 10));
pID=pID/10;
}
param[4]=(char)0x20;
param[5]='O';
param[6]=(char)0;
//IPC
((Dword*)pPath)[0] = 0;
((Dword*)pPath)[1] = 8;
Dword retval;
__asm
{
mov eax,60
mov ebx,1
mov ecx,pPath
mov edx,1040
int 40h
}
sprintf(fi.fileURL,"/sys/sysxtree");
fi.rwMode = 7;
fi.OffsetLow = 0;
fi.OffsetHigh = (Dword)param;
fi.dataCount = 0;
fi.bufferPtr = 0;
int dlg_pID=kos_FileSystemAccess(&fi);
if (dlg_pID<=0) return 0;
//kos_SetMaskForEvents(0x47);
kos_SetMaskForEvents(0x67);
//draw();
Dword btnID;
Byte keyCode;
for(;;)
{
get_next_event:
//Ñîáûòèÿ
switch (kos_WaitForEvent(50))
{
case 1:
draw();
break;
case 2:
kos_GetKey(keyCode);
break;
case 3:
kos_GetButtonID(btnID);
break;
case 7:
if (msg_num==0)
{
((Dword*)pPath)[0] = 0;
((Dword*)pPath)[1] = 8;
((Dword*)pPath)[2] = 0;
((Dword*)pPath)[3] = 0;
((Dword*)pPath)[4] = 0;
msg_num=1;
draw();
} else {
return (char*)pPath+16;
}
break;
default:
//Æèâ ëè åùå X-TREE?
if (msg_num)
{
int proc_count=kos_ProcessInfo(&proc,-1);
for(i=1;i<=proc_count;i++)
{
kos_ProcessInfo(&proc,i);
if (proc.processInfo.PID==dlg_pID)
{
if (proc.processInfo.slot_state==9)
{
return 0;
} else {
goto get_next_event;
}
}
}
return 0;
}
break;
}
}
return 0;
}

View File

@ -0,0 +1 @@
char* DialogOpenFile(void (*draw)());

View File

@ -0,0 +1,122 @@
#include "..\kosSyst.h"
#include "bmp.h"
int BMPFile::LoadBMPFile(Byte* filebuff, Dword filesize)
{
Dword offset;
memcpy((Byte*)&Bmp_head,(Byte*)filebuff,sizeof(tagBITMAPFILEHEADER));
memcpy((Byte*)&Info_head,(Byte*)filebuff+14,sizeof(tagBITMAPINFOHEADER));
width=Info_head.biWidth;
height=Info_head.biHeight;
offset=(Dword)Bmp_head.bfOffbits;
int state=0;
if (Bmp_head.bfType==0x4d42 && !Info_head.biCompression)
{
Byte* cBuffer;
Byte* pImg;
Byte* pPal;
Dword x,y;
Byte r;
Dword s,p;
Dword cWidth;
int i;
buffer=kos_GetMemory(width*height*3);
pImg=filebuff+offset;
pPal=filebuff+53;
int align_bytes = (4 - ((width * 3) % 4)) % 4;
Dword bpp = Info_head.biBitCount;
switch(Info_head.biBitCount)
{
/* 16,24,32-bit decoding */
case 32:
case 24:
case 16:
for(y=height-1;y!=-1;y--)
{
for(x=0;x<width;x++)
{
cBuffer=buffer+(y*width*3)+x*3;
if (Info_head.biBitCount==16)
{
*(cBuffer+0)=(Byte)((*(Word*)(pImg)) & 31)<<3;
*(cBuffer+1)=(Byte)((*(Word*)(pImg)>>5) & 31)<<3;
*(cBuffer+2)=(Byte)((*(Word*)(pImg)>>10) & 31)<<3;
} else {
*(cBuffer+0)=*(pImg+0);
*(cBuffer+1)=*(pImg+1);
*(cBuffer+2)=*(pImg+2);
}
pImg=pImg+Info_head.biBitCount/8;
}
pImg=pImg+align_bytes;
}
break;
/* 8-bit decoding */
case 8:
for(y=height-1;y!=-1;y--)
{
for(x=0;x<width;x++)
{
r=*(pImg); pImg++;
cBuffer=buffer+(y*width*3)+x*3;
*(cBuffer+0)=(Byte)(pPal[r*4+1]);
*(cBuffer+1)=(Byte)(pPal[r*4+2]);
*(cBuffer+2)=(Byte)(pPal[r*4+3]);
}
}
break;
/* 1,4-bit decode */
case 4:
case 1:
for(y=height-1;y!=-1;y--)
{
x=0;
while(x<width-1)
{
s=*(Dword*)(pImg);
pImg=pImg+4;
__asm
{
mov eax,s
bswap eax
mov s,eax
}
for(i=0;i<32/bpp;i++)
{
if (x>=width) break;
__asm
{
mov eax,s
mov ecx,bpp
rol eax,cl
mov s,eax
mov ebx,1
shl ebx,cl
dec ebx
and eax,ebx
mov p,eax
}
cBuffer=buffer+(y*width*3)+x*3;
*(cBuffer+0)=(Byte)(pPal[p*4+1]);
*(cBuffer+1)=(Byte)(pPal[p*4+2]);
*(cBuffer+2)=(Byte)(pPal[p*4+3]);
x++;
}
}
}
break;
default:
state=1;
break;
}
} else {
state=1;
}
return state;
}

View File

@ -0,0 +1,45 @@
#pragma pack(push, 1)
typedef struct tagBITMAPFILEHEADER
{
Word bfType; //тип файла (для битового образа - BM)
Dword bfSize; //размер файла в dword
Word bfReserved1; //не используется
Word bfReserved2; //не используется
Dword bfOffbits; //смещение данных битового образа от заголовка в байтах
} tagBITMAPFILEHEADER;
typedef struct tagBITMAPINFOHEADER
{
Dword biSize; //число байт, занимаемых структурой BITMAPINFOHEADER
Dword biWidth; //ширина битового образа в пикселах
Dword biHeight; //высота битового образа в пикселах
Word biPlanes; //число битовых плоскостей устройства
Word biBitCount; //число битов на пиксель
Dword biCompression; //тип сжатия
Dword biSizeImage; //размер картинки в байтах
Dword biXPelsPerMeter; //горизонтальное разрешение устройства, пиксел/м
Dword biYPelPerMeter; //вертикальное разрешение устройства, пиксел/м
Dword biClrUsed; //число используемых цветов
Dword biClrImportant; //число "важных" цветов
} tagBITMAPINFOHEADER;
typedef struct tagRGBQUAD
{
Byte rgbBlue;
Byte rgbGreen;
Byte rgbRed;
Byte rgbReserved;
} tagRGBQUAD;
#pragma pack(pop)
class BMPFile
{
protected:
tagBITMAPFILEHEADER Bmp_head;
tagBITMAPINFOHEADER Info_head;
public:
Dword width;
Dword height;
Byte* buffer;
int BMPFile::LoadBMPFile(Byte* filebuff, Dword filesize);
};

View File

@ -0,0 +1,55 @@
#include "..\kosSyst.h"
#include "pcx.h"
int PCXFile::LoadPCXFile(Byte* filebuff, Dword filesize)
{
memcpy((Byte*)&Pcx_head,(Byte*)filebuff,sizeof(PCXHeader));
int state=0;
if (Pcx_head.bManufacturer==0x0a && Pcx_head.bVersion==0x05)
{
width=Pcx_head.dwWidth-Pcx_head.dwX+1;
height=Pcx_head.dwHeight-Pcx_head.dwY+1;
buffer=kos_GetMemory(width*height*3);
Byte* pPal=filebuff+filesize-768;
Byte* pImg=filebuff+128;
Byte* cBuffer=(Byte*)buffer;
if (Pcx_head.bNPlanes==1)
{
/* 8-bit decoding */
Dword y,i;
Byte cur_byte,counter;
Dword cWidth;
for(y=0;y<height;y++)
{
cWidth=width;
while(cWidth!=0)
{
cur_byte=*(pImg); pImg++;
counter=1;
if (cur_byte>=192)
{
counter=(cur_byte & 0x3F);
cur_byte=*(pImg); pImg++;
}
for(i=0;i<counter;i++)
{
*(cBuffer+0)=(pPal[cur_byte*3+0]);
*(cBuffer+1)=(pPal[cur_byte*3+1]);
*(cBuffer+2)=(pPal[cur_byte*3+2]);
cBuffer=cBuffer+3;
cWidth--;
}
}
}
} else if (Pcx_head.bNPlanes==3) {
/* 24-bit decoding */
state=1;
}
} else {
state=1;
}
return state;
}

View File

@ -0,0 +1,31 @@
#pragma pack(push, 1)
typedef struct PCXHeader
{
Byte bManufacturer;
Byte bVersion;
Byte bEncoding;
Byte bBPP;
Word dwX;
Word dwY;
Word dwWidth;
Word dwHeight;
Word dwHRes;
Word dwVRes;
Byte colormap[48];
Byte bReserved;
Byte bNPlanes;
Word iBPL;
Word iPalInfo;
} PCXHeader;
#pragma pack(pop)
class PCXFile
{
protected:
PCXHeader Pcx_head;
public:
Word width;
Word height;
Byte* buffer;
int LoadPCXFile(Byte* filebuff, Dword filesize);
};

View File

@ -0,0 +1,103 @@
#include "..\kosSyst.h"
#include "tga.h"
int TGAFile::LoadTGAFile(Byte* filebuff, Dword filesize)
{
memcpy((Byte*)&Tga_head,(Byte*)filebuff,sizeof(sTGAHeader));
width=Tga_head.Width;
height=Tga_head.Height;
Byte* pImg=filebuff+sizeof(sTGAHeader)+Tga_head.BytesInIdentField+Tga_head.ColorMapOrigin+(Tga_head.ColorMapLength*Tga_head.ColorMapEntrySize/8);
Byte* pPal=filebuff+sizeof(sTGAHeader)+Tga_head.BytesInIdentField+Tga_head.ColorMapOrigin;
Byte* cBuffer;
int x,y;
Byte r;
int sm;
int state=1;
if (Tga_head.ImageDescByte >= 32) sm=height-1; else sm=0;
// Èçîáðàæåíèå ñ ïàëèòðîé (ïàëèòðà 24 èëè 32-áèòíàÿ)
if (Tga_head.ImageTypeCode==1)
{
if (Tga_head.ColorMapEntrySize>=24)
{
buffer=kos_GetMemory(width*height*3);
int bpp=Tga_head.ColorMapEntrySize/8;
for(y=height-1;y!=-1;y--)
{
for(x=0;x<width;x++)
{
r=*(pImg); pImg++;
cBuffer=buffer+(abs(sm-y)*width*3)+x*3;
*(cBuffer+0)=(Byte)(pPal[r*bpp+1]);
*(cBuffer+1)=(Byte)(pPal[r*bpp+2]);
*(cBuffer+2)=(Byte)(pPal[r*bpp+3]);
}
}
state=0;
}
}
// ÖÂåòíîå èçîáðàæåíèå áåç ñæàòèÿ è ïàëèòðû
else if (Tga_head.ImageTypeCode==2)
{
switch (Tga_head.ImagePixelSize)
{
case 32:
case 24:
buffer=kos_GetMemory(width*height*3);
for(y=height-1;y!=-1;y--)
{
for(x=0;x<width;x++)
{
cBuffer=buffer+(abs(sm-y)*width*3)+x*3;
*(cBuffer+0)=*(pImg+0);
*(cBuffer+1)=*(pImg+1);
*(cBuffer+2)=*(pImg+2);
pImg=pImg+Tga_head.ImagePixelSize/8;
}
}
state=0;
break;
case 16:
buffer=kos_GetMemory(width*height*3);
for(y=height-1;y!=-1;y--)
{
for(x=0;x<width;x++)
{
cBuffer=buffer+(abs(sm-y)*width*3)+x*3;
*(cBuffer+0)=(Byte)((*(Word*)(pImg)) & 31)<<3;
*(cBuffer+1)=(Byte)((*(Word*)(pImg)>>5) & 31)<<3;
*(cBuffer+2)=(Byte)((*(Word*)(pImg)>>10) & 31)<<3;
pImg=pImg+2;
}
}
state=0;
break;
}
}
// Ìîíîõðîìíîå èçîáðàæåíèå
else if (Tga_head.ImageTypeCode==3)
{
switch (Tga_head.ImagePixelSize)
{
case 8:
buffer=kos_GetMemory(width*height*3);
for(y=height-1;y!=-1;y--)
{
for(x=0;x<width;x++)
{
cBuffer=buffer+(abs(sm-y)*width*3)+x*3;
*(cBuffer+0)=*(pImg);
*(cBuffer+1)=*(pImg);
*(cBuffer+2)=*(pImg);
pImg++;
}
}
state=0;
break;
}
}
return state;
}

View File

@ -0,0 +1,37 @@
#pragma pack(push, 1)
typedef struct sTGAHeader
{
Byte BytesInIdentField;
Byte ColorMapType; // Color map type - 0 [no map] 1 [256 entry]
Byte ImageTypeCode; /* Image type
[0] No image data included
[1] Uncompressed color map image [4,6]
[2] Uncompressed RGB Image [16,24]
[3] Uncompressed Black & White
[9] RLE Color map image
[10] RLE RGB Image
[11] RLE Black & White
[32 | 33] compressed color map by Huffman, Delta, RLE
*/
Word ColorMapOrigin; // Offset of first color map entry
Word ColorMapLength; // Number of color map entries
Byte ColorMapEntrySize; // Number of bits per color map entries
Word XOrigin;
Word YOrigin;
Word Width;
Word Height;
Byte ImagePixelSize; // BPP
Byte ImageDescByte; // Flags
} sTGAHeader;
#pragma pack(pop)
class TGAFile
{
protected:
sTGAHeader Tga_head;
public:
Word width;
Word height;
Byte* buffer;
int LoadTGAFile(Byte* filebuff, Dword filesize);
};

View File

@ -0,0 +1,215 @@
RGB tbOpen[] = { /* 21x21 */
0xEFEBEF,0xBDCDE1,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0xBDCDE1,0xEFEBEF,
0xBDCDE1,0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,0xBDCDE1,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF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E8A0,0xFAE8A0,0xFAE8A0,0xFAE8A0,0xFEE080,0xFBD460,0xFBD460,0xFBD460,0xFBD460,0xFBD460,0xFBD460,0x908770,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xA19B96,0xFAE8A0,0xFAE8A0,0xFAE8A0,0xC0B200,0xC0B200,0xB0A890,0xB0A890,0xB0A191,0xB0A191,0xA09880,0xA09880,0xA09080,0xA09080,0x828282,0x908770,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xA09880,0xF5E190,0xFAE8A0,0xEED483,0xB0A890,0xFEE080,0xFEE080,0xFEE080,0xFEE080,0xFEE080,0xFEE080,0xFEE080,0xF9D370,0xF9D370,0xE0985D,0xA09080,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xA09880,0xF5E190,0xF5E190,0xB0A890,0xC0B200,0xF9D370,0xFBD460,0xFBD460,0xFBD460,0xFBD460,0xF2D050,0xF5C34E,0xE8B544,0xEAAA00,0x706850,0xCCCBCB,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xA09080,0xEED483,0xEED483,0xB0A890,0xFEE080,0xF9D370,0xFBD460,0xFBD460,0xFBD460,0xF5C34E,0xE8B544,0xE8B544,0xEAAA00,0x896C22,0x908770,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xA09080,0xEED483,0xB0A890,0xD0C385,0xF9D370,0xFBD460,0xFBD460,0xF5C34E,0xF5C34E,0xE8B544,0xEAAA00,0xEAAA00,0xC68E0F,0x614C00,0xCCCBCB,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0x828282,0xD0C385,0xB0A890,0xFEE080,0xFBD460,0xF5C34E,0xF5C34E,0xE8B544,0xEAAA00,0xEAAA00,0xEAAA00,0xC68E0F,0x896C22,0x595B59,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0x908770,0xB0A191,0xD0C385,0xD09100,0xD09100,0xD09100,0xC68E0F,0xC68E0F,0xB08010,0xB08010,0xA07820,0x896C22,0x614C00,0xA8ABAC,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0x908770,0x908463,0x807870,0x84704C,0x706050,0x645448,0x444646,0x403730,0x2C2726,0x2C2726,0x12100E,0x12100E,0x12100E,0xEFEEE8,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0xBDCDE1,0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,0xBDCDE1,
0xEFEBEF,0xBDCDE1,0x98AFBE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94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F2,0x0087ED,0x007CE1,0x0075DB,0x0049AF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x1E7BD6,0x4EB6FF,0x2DA8FF,0x62BBFE,0x0095FB,0x0090F6,0x0087ED,0x0082E7,0x0082E7,0x007CE1,0x0069CF,0x0066CC,0x2657AF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x1E7BD6,0x14A0FF,0x0200FF,0xFEFFFF,0xA4D4FE,0x0082E7,0x007CE1,0x0075DB,0xFFFFFF,0xBFDBF4,0x0066CC,0x0066CC,0x004DB3,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0x0667CA,0xA9CFF,0x0095FB,0x0090F6,0xFEFFFF,0xFDFEFF,0x8BB5E7,0x006FD5,0x0069CF,0xFFFFFF,0xBFDBF4,0x0066CC,0x0066CC,0x0064CA,0x0056BC,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0x006FD5,0x0095FB,0x008CF2,0x0082E7,0xFFFFFF,0xFEFFFF,0xFDFEFF,0x5DA2E2,0x0066CC,0xFFFFFF,0xBFDBF4,0x0066CC,0x0066CC,0x0066CC,0x0056BC,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0x006FD5,0x0087ED,0x007CE1,0x0075DB,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFD,0x1E7BD6,0xFFFFFF,0xBFDBF4,0x0066CC,0x0066CC,0x0066CC,0x0056BC,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0x006FD5,0x007CE1,0x006FD5,0x0069CF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0x5DA2E2,0x0064CA,0xFFFFFF,0xBFDBF4,0x0066CC,0x0066CC,0x0064CA,0x0056BC,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0x006FD5,0x0069CF,0x0066CC,0x0066CC,0xFFFFFF,0xEBF5FE,0x2D84DA,0x0066CC,0x0066CC,0xFFFFFF,0xBFDBF4,0x0066CC,0x0066CC,0x0053B9,0x0056BC,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x004DB3,0x0066CC,0x0066CC,0xFFFFFD,0x2D84DA,0x0066CC,0x0066CC,0x0066CC,0xFFFFFF,0xBFDBF4,0x0066CC,0x0066CC,0x1049A9,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x004DB3,0x0000C0,0x0066CC,0x0066CC,0x0064CA,0x0066CC,0x0066CC,0x0066CC,0x0066CC,0x0066CC,0x0066CC,0x004DB3,0x0046AC,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x2657AF,0x0056BC,0x0066CC,0x0066CC,0x0066CC,0x0066CC,0x0066CC,0x0066CC,0x0066CC,0x0049AF,0x0046AC,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x004DB3,0x004DB3,0x0053B9,0x0000C0,0x0000C0,0x0000C0,0x004DB3,0x2657AF,0x0046AC,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x0046AC,0x0046AC,0x0046AC,0x0046AC,0x0046AC,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEB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F,0xFFFFFF,0x007CE1,0x006FD5,0x5DA2E2,0xFFFFFF,0xFFFFFF,0x0066CC,0x0066CC,0x0066CC,0x0056BC,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0x0064CA,0x0095FB,0x008CF2,0x0087ED,0xBFDBF4,0xFDFEFF,0x006FD5,0x2D84DA,0xFFFFFF,0xFFFFFF,0xFFFFFF,0x0066CC,0x0066CC,0x0066CC,0x0056BC,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0x0000C0,0x0087ED,0x0082E7,0x007CE1,0xBFDBF4,0xFFFFFF,0x1E7BD6,0xEBF5FE,0xFFFFFF,0xFFFFFF,0xFFFFFF,0x0066CC,0x0066CC,0x0066CC,0x0056BC,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0x0046AC,0x007CE1,0x0075DB,0x0069CF,0xBFDBF4,0xFFFFFF,0x1070CF,0x2D84DA,0xFFFFFD,0xFFFFFF,0xFFFFFF,0x0066CC,0x0066CC,0x0066CC,0x0056BC,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0x0046AC,0x0066CC,0x0066CC,0x0066CC,0xBFDBF4,0xFFFFFF,0x0066CC,0x1070CF,0x2D84DA,0xFFFFFF,0xFFFFFF,0x0066CC,0x0066CC,0x0062C8,0x0056BC,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x004DB3,0x0066CC,0x0066CC,0xBFDBF4,0xFFFFFF,0x0066CC,0x0066CC,0x1070CF,0x2D84DA,0xFFFFFF,0x0066CC,0x0066CC,0x004DB3,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x0046AC,0x0000C0,0x0066CC,0x0066CC,0x0066CC,0x0066CC,0x0066CC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EF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x003399,0x003399,0x003399,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x003399,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x757DAC,0x757DAC,0x757DAC,0x757DAC,0x757DAC,0x757DAC,0x757DAC,0x757DAC,0x757DAC,0x757DAC,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x757DAC,0x78C9FF,0x78C9FF,0x78C9FF,0x78C9FF,0x78C9FF,0x78C9FF,0x78C9FF,0x78C9FF,0x757DAC,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0x003399,0xEFEBEF,0xEFEBEF,0x757DAC,0xB5E3FF,0x9BD1DC,0xAEDBF7,0xB5E3FF,0xB5E3FF,0xB5E3FF,0xB5E3FF,0xB5E3FF,0x757DAC,0xEFEBEF,0xEFEBEF,0x003399,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0x003399,0x003399,0xEFEBEF,0x757DAC,0xDFE7EE,0x23791E,0x3F0031,0xEBF5FE,0xF3F9FF,0xF3F9FF,0xF3F9FF,0xF3F9FF,0x757DAC,0xEFEBEF,0x10409F,0x003399,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0x003399,0x003399,0x2657AF,0x767DAA,0x5EB541,0x3F0031,0x3F0031,0x5EB541,0xF5F8F3,0x5EB541,0x85CE70,0xFAFCF9,0x757DAC,0x2657AF,0x003399,0x003399,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0x003399,0x003399,0xEFEBEF,0x757DAC,0x5EB541,0x5EC33B,0x5EB541,0x5EB541,0x5EB541,0x5EB541,0x5EB541,0x5EB541,0x757DAC,0xEFEBEF,0x10409F,0x003399,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0x003399,0xEFEBEF,0xEFEBEF,0x757DAC,0x7ED351,0x7ED351,0x7ED351,0x7ED351,0x7ED351,0x7ED351,0x7ED351,0x7ED351,0x757DAC,0xEFEBEF,0xEFEBEF,0x003399,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x757DAC,0x757DAC,0x757DAC,0x7600A6,0x757DAC,0x7600A6,0x757DAC,0x757DAC,0x757DAC,0x757DAC,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x10409F,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x003399,0x003399,0x10409F,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x003399,0x003399,0x003399,0x003399,0x003399,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,
0xBDCDE1,0x94AECE,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0xEFEBEF,0x94AECE,0xBDCDE1,
0xEFEBEF,0xBDCDE1,0x98AFBE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0xBDCDE1,0xEFEBEF,
};
RGB arrow_up[] = { /* 15x15 */
0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,
0x94AECE,0xE7E7E7,0xE7E7E7,0xE6E6E6,0xE8E8E8,0xEBEBEB,0xE5E5E5,0xE3E3E3,0xE9E9E9,0xE9E9E9,0xE9E9E9,0xE4E4E4,0xEAEAEA,0xC4C4C4,0x94AECE,
0x94AECE,0xE8E8E8,0xDFDFDF,0xE1E1E1,0xD9D9D9,0xD8D8D8,0xD9D9D9,0xDFDFDF,0xD4D4D4,0xCFCFCF,0xD8D8D8,0xCECECE,0xCECECE,0xB6B6B6,0x94AECE,
0x94AECE,0xEAEAEA,0xE2E2E2,0xDADADA,0xE0E0E0,0xDBDBDB,0xDCDCDC,0xCECECE,0xD6D6D6,0xDADADA,0xD1D1D1,0xCCCCCC,0xCFCFCF,0xB0B0B0,0x94AECE,
0x94AECE,0xE1E1E1,0xE0E0E0,0xDADADA,0xD7D7D7,0xDADADA,0xDBDBDB,0x343434,0xCFCFCF,0xD0D0D0,0xCBCBCB,0xCDCDCD,0xCDCDCD,0xA8A8A8,0x94AECE,
0x94AECE,0xE5E5E5,0xDEDEDE,0xDCDCDC,0xD5D5D5,0xD9D9D9,0x2E2E2E,0x333333,0x333333,0xD0D0D0,0xCFCFCF,0xC9C9C9,0xCACACA,0xB1B1B1,0x94AECE,
0x94AECE,0xE5E5E5,0xDADADA,0xDDDDDD,0xD3D3D3,0x343434,0x343434,0x343434,0x343434,0x343434,0xCBCBCB,0xC8C8C8,0xC8C8C8,0xB5B5B5,0x94AECE,
0x94AECE,0xEAEAEA,0xD7D7D7,0xD1D1D1,0x343434,0x343434,0x343434,0x343434,0x343434,0x343434,0x343434,0xC8C8C8,0xCACACA,0xA8A8A8,0x94AECE,
0x94AECE,0xE3E3E3,0xDCDCDC,0xDCDCDC,0xCDCDCD,0xD0D0D0,0x353535,0x343434,0x303030,0xCDCDCD,0xC0C0C0,0xC7C7C7,0xC6C6C6,0xADADAD,0x94AECE,
0x94AECE,0xEBEBEB,0xCFCFCF,0xCFCFCF,0xD7D7D7,0xD3D3D3,0x2C2C2C,0x383838,0x353535,0xC5C5C5,0xC9C9C9,0xC6C6C6,0xC3C3C3,0xACACAC,0x94AECE,
0x94AECE,0xE6E6E6,0xD2D2D2,0xD4D4D4,0xC9C9C9,0xC8C8C8,0xCECECE,0xC5C5C5,0xC8C8C8,0xC8C8C8,0xC2C2C2,0xC8C8C8,0xBDBDBD,0xAFAFAF,0x94AECE,
0x94AECE,0xE7E7E7,0xCDCDCD,0xCFCFCF,0xD6D6D6,0xCDCDCD,0xCDCDCD,0xCACACA,0xC5C5C5,0xC8C8C8,0xBEBEBE,0xBBBBBB,0xC0C0C0,0xACACAC,0x94AECE,
0x94AECE,0xE9E9E9,0xD0D0D0,0xCDCDCD,0xC5C5C5,0xCACACA,0xC5C5C5,0xC4C4C4,0xC6C6C6,0xC2C2C2,0xC0C0C0,0xC3C3C3,0xC0C0C0,0xAEAEAE,0x94AECE,
0x94AECE,0xC9C9C9,0xB2B2B2,0xACACAC,0xB0B0B0,0xAEAEAE,0xAFAFAF,0xB0B0B0,0xAFAFAF,0xADADAD,0xB0B0B0,0xADADAD,0xABABAB,0xADADAD,0x94AECE,
0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,
};
RGB arrow_right[] = { /* 15x15 */
0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xF1F1F1,0xEAEAEA,0xE8E8E8,0xE1E1E1,0xDEDEDE,0xD9D9D9,0xD9D9D9,0xCFCFCF,0xD1D1D1,0xC9C9C9,0xAFAFAF,0x94AECE,
0x94AECE,0xF3F3F3,0xE2E2E2,0xDFDFDF,0xDFDFDF,0xD9D9D9,0xDBDBDB,0xD8D8D8,0xD6D6D6,0xD3D3D3,0xD5D5D5,0xCFCFCF,0xCFCFCF,0xB3B3B3,0x94AECE,
0x94AECE,0xF3F3F3,0xE0E0E0,0xDBDBDB,0xDEDEDE,0xDADADA,0xD9D9D9,0xD5D5D5,0xD5D5D5,0xD3D3D3,0xCFCFCF,0xD0D0D0,0xCDCDCD,0xB3B3B3,0x94AECE,
0x94AECE,0xF0F0F0,0xDCDCDC,0xE0E0E0,0xD9D9D9,0xD8D8D8,0xD6D6D6,0x333333,0xD3D3D3,0xD0D0D0,0xD1D1D1,0xCBCBCB,0xCACACA,0xB2B2B2,0x94AECE,
0x94AECE,0xF3F3F3,0xDEDEDE,0xD6D6D6,0xD7D7D7,0xD8D8D8,0xD4D4D4,0x353535,0x333333,0xD0D0D0,0xCCCCCC,0xCFCFCF,0xCACACA,0xB3B3B3,0x94AECE,
0x94AECE,0xF2F2F2,0xD7D7D7,0xDBDBDB,0xD8D8D8,0x323232,0x333333,0x313131,0x323232,0x363636,0xC9C9C9,0xC9C9C9,0xC6C6C6,0xB4B4B4,0x94AECE,
0x94AECE,0xF2F2F2,0xD9D9D9,0xD5D5D5,0xD6D6D6,0x343434,0x343434,0x343434,0x343434,0x313131,0x343434,0xC7C7C7,0xC9C9C9,0xB0B0B0,0x94AECE,
0x94AECE,0xF3F3F3,0xD7D7D7,0xD2D2D2,0xD1D1D1,0x343434,0x323232,0x343434,0x343434,0x303030,0xCBCBCB,0xC5C5C5,0xC5C5C5,0xB4B4B4,0x94AECE,
0x94AECE,0xF2F2F2,0xD3D3D3,0xD5D5D5,0xD1D1D1,0xCFCFCF,0xCCCCCC,0x333333,0x323232,0xC9C9C9,0xC5C5C5,0xC5C5C5,0xC3C3C3,0xB0B0B0,0x94AECE,
0x94AECE,0xF2F2F2,0xD3D3D3,0xCECECE,0xCFCFCF,0xCBCBCB,0xCCCCCC,0x343434,0xC7C7C7,0xC8C8C8,0xC3C3C3,0xC1C1C1,0xC2C2C2,0xB3B3B3,0x94AECE,
0x94AECE,0xF2F2F2,0xD0D0D0,0xD0D0D0,0xCCCCCC,0xCBCBCB,0xC9C9C9,0xC7C7C7,0xC6C6C6,0xC4C4C4,0xC4C4C4,0xC1C1C1,0xBEBEBE,0xB1B1B1,0x94AECE,
0x94AECE,0xF2F2F2,0xCFCFCF,0xCACACA,0xCCCCCC,0xC9C9C9,0xC8C8C8,0xC6C6C6,0xC4C4C4,0xC3C3C3,0xC0C0C0,0xC0C0C0,0xBDBDBD,0xB1B1B1,0x94AECE,
0x94AECE,0xF4F4F4,0xAEAEAE,0xB5B5B5,0xB2B2B2,0xB1B1B1,0xB2B2B2,0xB2B2B2,0xB2B2B2,0xB2B2B2,0xB1B1B1,0xB4B4B4,0xB1B1B1,0xB5B5B5,0x94AECE,
0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,
};
RGB arrow_down[] = { /* 15x15 */
0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xF3F3F1,0xF3F3F1,0xF0F0EE,0xF8F8F6,0xF6F6F4,0xEFEFED,0xF5F5F5,0xF1F1F1,0xEEEEEE,0xF4F4F4,0xEEEEEC,0x94AECE,
0x94AECE,0xEBEBEB,0xE6E6E6,0xE0E0E0,0xD9D9D9,0xDADADA,0xD9D9D9,0xD4D4D4,0xD7D7D7,0xD3D3D3,0xD1D1D1,0xD8D8D8,0xCACACA,0xB1B1B1,0x94AECE,
0x94AECE,0xF1F1F1,0xDFDFDF,0xD9D9D9,0xDFDFDF,0xDCDCDC,0xD6D6D6,0xD8D8D8,0xD3D3D3,0xD6D6D8,0xCFCFD1,0xCBCBCB,0xD1D1D1,0xB2B2B2,0x94AECE,
0x94AECE,0xE9E9E9,0xE0E0E0,0xDBDBDB,0xDADADA,0xDCDCDC,0xD4D4D4,0xD7D7D7,0xD2D2D2,0xD1D1D1,0xD0D0D0,0xD0D0D0,0xC9C9C9,0xAEAEAE,0x94AECE,
0x94AECE,0xE3E3E3,0xE0E0E0,0xD3D3D3,0xDBDBDB,0xD3D3D3,0x353535,0x353535,0x2F2F2F,0xD0D0D0,0xC6C6C6,0xCCCCCC,0xCBCBCB,0xB3B3B3,0x94AECE,
0x94AECE,0xDEDEDE,0xDFDFDF,0xD9D9D9,0xD9D9D9,0xCFCFCF,0x343434,0x323232,0x343434,0xD0D0D0,0xCACACA,0xCACACA,0xC5C5C5,0xB1B1B1,0x94AECE,
0x94AECE,0xE1E1E1,0xD6D6D6,0xD4D4D4,0x343434,0x323232,0x333333,0x323232,0x323232,0x333333,0x353535,0xC8C8C8,0xC8C8C8,0xADADAD,0x94AECE,
0x94AECE,0xD7D7D7,0xD4D4D4,0xD3D3D3,0xD3D3D3,0x313131,0x353535,0x333333,0x363636,0x323232,0xCBCBCB,0xBFBFBF,0xC9C9C9,0xB4B4B4,0x94AECE,
0x94AECE,0xD9D9D9,0xD5D5D5,0xD1D1D1,0xD3D3D3,0xD2D2D2,0x333333,0x323232,0x303030,0xC5C5C5,0xCACACA,0xC8C8C8,0xBCBCBC,0xB0B0B0,0x94AECE,
0x94AECE,0xCDCDCD,0xDADADA,0xCFCFCF,0xC9C9C9,0xD3D3D3,0xC9C9C9,0x343434,0xCCCCCC,0xC7C7C7,0xC2C2C2,0xC3C3C3,0xC3C3C3,0xB3B3B3,0x94AECE,
0x94AECE,0xCECECE,0xD1D1D1,0xCFCFCF,0xCFCFCF,0xC8C8C8,0xCBCBCB,0xC6C6C6,0xC6C6C6,0xC7C7C7,0xBEBEBE,0xC3C3C3,0xBDBDBD,0xB1B1B1,0x94AECE,
0x94AECE,0xCCCCCC,0xCCCCCC,0xCCCCCC,0xCCCCCC,0xCACACA,0xC8C8C8,0xC6C6C6,0xC5C5C5,0xC2C2C2,0xC4C4C4,0xBFBFBF,0xB8B8B8,0xB4B4B4,0x94AECE,
0x94AECE,0xB1B1B1,0xB2B2B2,0xB2B2B2,0xB3B3B3,0xB3B3B3,0xB2B2B2,0xB1B1B1,0xB1B1B1,0xB3B3B3,0xAEAEAE,0xAFAFAF,0xBEBEBE,0xA8A8A8,0x94AECE,
0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,
};
RGB arrow_left[] = { /* 15x15 */
0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xE7E7E7,0xE7E7E7,0xE7E7E7,0xE6E6E6,0xE7E7E7,0xE8E8E8,0xE7E7E7,0xE5E5E5,0xE7E7E7,0xE6E6E6,0xCDCDCD,0x94AECE,
0x94AECE,0xE7E7E7,0xE2E2E2,0xE1E1E1,0xDCDCDC,0xDDDDDD,0xD9D9D9,0xDBDBDB,0xD3D3D3,0xD6D6D6,0xD3D3D3,0xD0D0CE,0xD0D0CE,0xABABA9,0x94AECE,
0x94AECE,0xE7E7E7,0xDFDFDF,0xDFDFDF,0xDBDBDB,0xD9D9D9,0xDADADA,0xD2D2D2,0xD8D8D8,0xD2D2D2,0xD0D0D0,0xCFCFCD,0xCCCCCA,0xAEAEAC,0x94AECE,
0x94AECE,0xE9E9E9,0xDEDEDE,0xD8D8D8,0xDEDEDE,0xD7D7D7,0xD6D6D6,0x353535,0xD0D0D0,0xD1D1D1,0xCFCFCF,0xCDCDCD,0xCBCBCB,0xAEAEAE,0x94AECE,
0x94AECE,0xE5E5E5,0xDDDDDD,0xDCDCDC,0xD7D7D7,0xD6D6D6,0x333333,0x333333,0xD0D0D0,0xD0D0D0,0xCCCCCC,0xCBCBCB,0xC8C8CA,0xAEAEB0,0x94AECE,
0x94AECE,0xE7E7E7,0xDADADA,0xD9D9D9,0xD7D7D7,0x353535,0x323232,0x323232,0x343434,0x343434,0xCCCCCC,0xCBCBCB,0xC6C6C6,0xAEAEAE,0x94AECE,
0x94AECE,0xE6E6E6,0xD8D8D8,0xD6D6D6,0x323232,0x333333,0x323232,0x353535,0x323232,0x323232,0xCACACA,0xC7C7C7,0xC7C7C7,0xAEAEAE,0x94AECE,
0x94AECE,0xE8E8E8,0xD6D6D6,0xD4D4D4,0xD2D2D2,0x343434,0x323232,0x353535,0x333333,0x313131,0xC8C8C8,0xC6C6C4,0xC3C3C1,0xAFAFAD,0x94AECE,
0x94AECE,0xE4E4E4,0xD6D6D6,0xD3D3D3,0xD2D2D2,0xCFCFCF,0x343434,0x303030,0xCCCCCC,0xC7C7C7,0xC6C6C6,0xC7C7C5,0xC1C1C1,0xADADAD,0x94AECE,
0x94AECE,0xE9E9E9,0xD1D1D1,0xD0D0D0,0xCECECE,0xCDCDCD,0xCCCCCC,0x343434,0xC5C5C5,0xC7C7C7,0xC4C4C4,0xC0C0C0,0xC3C3C5,0xADADAF,0x94AECE,
0x94AECE,0xE7E7E7,0xD2D2D2,0xD0D0D0,0xCECECE,0xCBCBCB,0xCCCCCC,0xC6C6C6,0xC9C9C9,0xC6C6C6,0xC3C3C3,0xC1C1C1,0xBEBEBE,0xADADAD,0x94AECE,
0x94AECE,0xE7E7E7,0xCFCFCF,0xCCCCCC,0xCDCDCD,0xC9C9C9,0xC9C9C9,0xC7C7C7,0xC4C4C4,0xC0C0C0,0xC2C2C2,0xBDBDBB,0xBCBCBC,0xB1B1B1,0x94AECE,
0x94AECE,0xCDCDCD,0xAEAEAE,0xB0B0B0,0xADADAD,0xAFAFAF,0xACACAC,0xAEAEAE,0xAFAFAF,0xAFAFAF,0xADADAD,0xB0B0AE,0xADADAD,0xADADAD,0x94AECE,
0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,
};
RGB scroll_v[] = { /* 15x35 */
0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,
0x94AECE,0xEFEBEF,0xEFEBEF,0xE5E5E5,0xE8E8E8,0xE7E7E7,0xE7E7E7,0xE7E7E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D0,0xC5C5C7,0xAFAFB1,0x94AECE,
0x94AECE,0xC9C9C9,0xAAAAAA,0xB2B2B2,0xB3B3B3,0xADADAD,0xB0B0B0,0xABABAB,0xB1B1B1,0xABABAD,0xB5B5B7,0xAAAAAC,0xB3B3B3,0xAAAAAA,0x94AECE,
0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,
};
RGB scroll_h[] = { /* 35x15*/
0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,
0x94AECE,0xAAAAAA,0xEFEBEF,0xD6D6D6,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xE7E7E7,0xE8E8E8,0xE8E8E8,0xE8E8E8,0xEDEDED,0xD1D1D1,0xEBEBEB,0x94AECE,
0x94AECE,0xAAAAAA,0xCDCDCF,0xB3B3B3,0xE1E1E1,0xE1E1E1,0xE1E1E1,0xE1E1E1,0xE1E1E1,0xE1E1E1,0xE1E1E1,0xE1E1E1,0xE1E1E1,0xE1E1E1,0xE1E1E1,0xE1E1E1,0xE1E1E1,0xE1E1E1,0xE1E1E1,0xE1E1E1,0xE1E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8B8,0xB8B8B8,0xB8B8B8,0xB8B8B8,0xB8B8B8,0xB8B8B8,0xB8B8B8,0xB8B8B8,0xB8B8B8,0xBABABA,0xB8B8B8,0xB8B8B8,0xB8B8B8,0xE5E5E5,0xC9C9C9,0xEAEAEA,0x94AECE,
0x94AECE,0xAAAAAA,0xAFAFB1,0xABABAB,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xACACAC,0xAEAEAE,0xAEAEAE,0xAEAEAE,0xCBCBCB,0xAFAFAF,0xC1C1C1,0x94AECE,
0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,0x94AECE,
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,921 @@
#include "kosSyst.h"
#include "stdarg.h"
#define atexitBufferSize 32
char pureCallMessage[] = "PURE function call!";
char *kosExePath = NULL;
int abs(int value)
{
if (value<0) value=0-value;
return value;
}
//
void (__cdecl *atExitList[atexitBufferSize])();
int atExitFnNum = 0;
//
int __cdecl atexit( void (__cdecl *func )( void ))
{
//
if ( atExitFnNum < atexitBufferSize )
{
//
atExitList[atExitFnNum++] = func;
return 0;
}
else
{
return 1;
}
}
//
Dword RandomSeed = 1;
//
void rtlSrand( Dword seed )
{
RandomSeed = seed;
}
//
Dword rtlRand( void )
{
//ìàñêà 0x80000776
Dword dwi, i;
for ( i = 0; i < 32; i++ )
{
dwi = RandomSeed & 0x80000776;
__asm{
mov eax, dwi
mov edx, eax
bswap eax
xor eax, edx
xor al, ah
setpo al
movzx eax, al
mov dwi, eax
}
RandomSeed = ( RandomSeed << 1 ) | ( dwi & 1 );
}
return RandomSeed;
}
#if _MSC_VER >= 1400
//
void * __cdecl memcpy( void *dst, const void *src, size_t bytesCount )
{
__asm{
mov edi, dst
mov eax, dst
mov esi, src
mov ecx, bytesCount
rep movsb
}
}
//
void memset( Byte *dst, Byte filler, Dword count )
{
//
__asm{
mov edi, dst
mov al, filler
mov ecx, count
rep stosb
}
}
#endif
//
Dword rtlInterlockedExchange( Dword *target, Dword value )
{
// Dword result;
//
__asm{
mov eax, value
mov ebx, target
xchg eax, [ebx]
// mov result, eax
}
//
// return result;
}
//////////////////////////////////////////////////////////////////////
//
// êîïèðîâàíèå ñòðîêè
//
char * __cdecl strcpy( char *target, const char *source )
{
char *result = target;
while( target[0] = source[0] )
{
target++;
source++;
}
return result;
}
//////////////////////////////////////////////////////////////////////
//
// ðåâåðñèâíûé ïîèñê ñèìâîëà
//
char * __cdecl strrchr( const char * string, int c )
{
char *cPtr;
//
for ( cPtr = (char *)string + strlen( string ); cPtr >= string; cPtr-- )
{
//
if ( *cPtr == c ) return cPtr;
}
//
return NULL;
}
//////////////////////////////////////////////////////////////////////
//
// îïðåäåëåíèå äëèíû ñòðîêè
//
int __cdecl strlen( const char *line )
{
int i;
for( i=0; line[i] != 0; i++ );
return i;
}
//////////////////////////////////////////////////////////////////////
//
// Ñðàâíåíèå ñòðîê
//
int strcmp(char* string1, char* string2)
{
Dword retval;
if (strlen(string1)==strlen(string2))
{
__asm
{
mov dword ptr [retval],0
mov esi,string1
mov edi,string2
next_char:
mov al,byte ptr [esi]
mov bl,byte ptr [edi]
inc esi
inc edi
cmp bl,0
je fin
cmp al,bl
je next_char
jmp not_equal
fin:
mov dword ptr [retval],1
not_equal:
}
return retval;
} else {
return 0;
}
}
//////////////////////////////////////////////////////////////////////
//
// ïåðåâîä øåñòíàäöàòèðè÷íîãî ÷èñëà â ñèìâîë
//
unsigned int num2hex( unsigned int num )
{
if( num < 10 )
return num + '0';
return num - 10 + 'A';
}
//////////////////////////////////////////////////////////////////////
//
// ïåðåâîä ñòðîêè â íèæíèé ðåãèñòð
//
void lcase(char* string)
{
int i;
char chr;
for(i=0;i<strlen(string);i++)
{
chr=((char*)string)[i];
if (chr>=65 && chr<=90) chr=chr+32; //a-z
if (chr>=128 && chr<=143) chr=chr+32; //à-ï
if (chr>=144 && chr<=159) chr=chr+80; //ð-ÿ
if (chr==240) chr=241; //¸
((char*)string)[i]=chr;
}
}
//////////////////////////////////////////////////////////////////////
//
// âûâîä ñòðîêè íà ïå÷àòü
//
Dword dectab[] = { 1000000000, 100000000, 10000000, 1000000, 100000,
10000, 1000, 100, 10, 0 };
//
void sprintf( char *Str, char* Format, ... )
{
int i, fmtlinesize, j, k, flag;
Dword head, tail;
char c;
va_list arglist;
//
va_start(arglist, Format);
//
fmtlinesize = strlen( Format );
//
if( fmtlinesize == 0 ) return;
//
for( i = 0, j = 0; i < fmtlinesize; i++ )
{
//
c = Format[i];
//
if( c != '%' )
{
Str[j++] = c;
continue;
}
//
i++;
//
if( i >= fmtlinesize ) break;
//
flag = 0;
//
c = Format[i];
//
switch( c )
{
//
case '%':
Str[j++] = c;
break;
// âûâîä ñòðîêè
case 'S':
Byte* str;
str = va_arg(arglist, Byte*);
for( k = 0; ( c = str[k] ) != 0; k++ )
{
Str[j++] = c;
}
break;
// âûâîä áàéòà
case 'B':
k = va_arg(arglist, int) & 0xFF;
Str[j++] = num2hex( ( k >> 4 ) & 0xF );
Str[j++] = num2hex( k & 0xF );
break;
// âûâîä ñèìâîëà
case 'C':
Str[j++] = va_arg(arglist, int) & 0xFF;
break;
// âûâîä äâîéíîãî ñëîâà â øåñòíàäöàòèðè÷íîì âèäå
case 'X':
Dword val;
val = va_arg(arglist, Dword);
for( k = 7; k >= 0; k-- )
{
//
c = num2hex ( ( val >> (k * 4) ) & 0xF );
//
if( c == '0' )
{
if( flag ) Str[j++] = c;
}
else
{
flag++;
Str[j++] = c;
}
}
//
if( flag == 0 ) Str[j++] = '0';
break;
// âûâîä äâîéíîãî ñëîâà â äåñÿòè÷íîì âèäå
case 'U':
head = va_arg(arglist, Dword);
tail = 0;
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;
// âûâîä 64-áèòíîãî ñëîâà â øåñòíàäöàòèðè÷íîì âèäå
case 'Q':
unsigned int low_dword, high_dword;
low_dword = va_arg(arglist, unsigned int);
high_dword = va_arg(arglist, unsigned int);
for( k = 7; k >= 0; k-- )
{
//
c = num2hex ( ( ( high_dword + 1) >> (k * 4) ) & 0xF );
//
if( c == '0' )
{
if( flag ) Str[j++] = c;
}
else
{
flag++;
Str[j++] = c;
}
}
//
for( k=7; k >= 0; k-- )
{
//
c = num2hex ( ( low_dword >> (k * 4) ) & 0xF );
//
if( c == '0' )
{
if( flag ) Str[j++] = c;
}
else
{
flag++;
Str[j++] = c;
}
}
//
if( flag == 0 ) Str[j++] = '0';
//
break;
//
default:
break;
}
}
//
Str[j] = 0;
}
// ôóíêöèÿ -1 çàâåðøåíèÿ ïðîöåññà
void kos_ExitApp()
{
int i;
//
for ( i = atExitFnNum - 1; i >= 0; i-- )
{
//
atExitList[i]();
}
//
__asm{
mov eax, -1
int 0x40
}
}
// ôóíêöèÿ 0
void kos_DefineAndDrawWindow(
Word x, Word y,
Word sizeX, Word sizeY,
Byte mainAreaType,
Dword mainAreaColour,
Byte headerType,
Dword headerColour,
Dword borderColour
)
{
Dword arg1, arg2, arg3, arg4;
//
arg1 = ( x << 16 ) + sizeX;
arg2 = ( y << 16 ) + sizeY;
arg3 = ( mainAreaType << 24 ) | mainAreaColour;
arg4 = ( headerType << 24 ) | headerColour;
//
__asm{
mov eax, 0
mov ebx, arg1
mov ecx, arg2
mov edx, arg3
mov esi, arg4
mov edi, borderColour
int 0x40
}
}
// ôóíêöèÿ 1 ïîñòàâèòü òî÷êó
void kos_PutPixel( Dword x, Dword y, Dword colour )
{
//
__asm{
mov eax, 1
mov ebx, x
mov ecx, y
mov edx, colour
int 0x40
}
}
// ôóíêöèÿ 2 ïîëó÷èòü êîä íàæàòîé êëàâèøè
bool kos_GetKey( Byte &keyCode )
{
Dword result;
//
__asm{
mov eax, 2
int 0x40
mov result, eax
}
//
keyCode = result >> 8;
//
return ( result & 0xFF ) == 0;
}
// ôóíêöèÿ 3 ïîëó÷èòü âðåìÿ
Dword kos_GetSystemClock()
{
// Dword result;
//
__asm{
mov eax, 3
int 0x40
// mov result, eax
}
//
// return result;
}
// ôóíêöèÿ 4
void kos_WriteTextToWindow(
Word x,
Word y,
Byte fontType,
Dword textColour,
char *textPtr,
Dword textLen
)
{
Dword arg1, arg2;
//
arg1 = ( x << 16 ) | y;
arg2 = ( fontType << 24 ) | textColour;
//
__asm{
mov eax, 4
mov ebx, arg1
mov ecx, arg2
mov edx, textPtr
mov esi, textLen
int 0x40
}
}
// ôóíêöèÿ 5 ïàóçà, â ñîòûõ äîëÿõ ñåêóíäû
void kos_Pause( Dword value )
{
//
__asm{
mov eax, 5
mov ebx, value
int 0x40
}
}
// ôóíêöèÿ 7 íàðèñîâàòü èçîáðàæåíèå
void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y )
{
Dword arg1, arg2;
//
arg1 = ( sizeX << 16 ) | sizeY;
arg2 = ( x << 16 ) | y;
//
__asm{
mov eax, 7
mov ebx, imagePtr
mov ecx, arg1
mov edx, arg2
int 0x40
}
}
// ôóíêöèÿ 8 îïðåäåëèòü êíîïêó
void kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour )
{
Dword arg1, arg2;
//
arg1 = ( x << 16 ) | sizeX;
arg2 = ( y << 16 ) | sizeY;
//
__asm{
mov eax, 8
mov ebx, arg1
mov ecx, arg2
mov edx, buttonID
mov esi, colour
int 0x40
}
}
// ôóíêöèÿ 9 - èíôîðìàöèÿ î ïðîöåññå
Dword kos_ProcessInfo( sProcessInfo *targetPtr, Dword processID )
{
// Dword result;
//
__asm{
mov eax, 9
mov ebx, targetPtr
mov ecx, processID
int 0x40
// mov result, eax
}
//
// return result;
}
// ôóíêöèÿ 10
Dword kos_WaitForEvent()
{
// Dword result;
__asm{
mov eax, 10
int 0x40
// mov result, eax
}
// return result;
}
// ôóíêöèÿ 11
Dword kos_CheckForEvent()
{
// Dword result;
__asm{
mov eax, 11
int 0x40
// mov result, eax
}
// return result;
}
// ôóíêöèÿ 12
void kos_WindowRedrawStatus( Dword status )
{
__asm{
mov eax, 12
mov ebx, status
int 0x40
}
}
// ôóíêöèÿ 13 íàðèñîâàòü ïîëîñó
void kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour )
{
Dword arg1, arg2;
//
arg1 = ( x << 16 ) | sizeX;
arg2 = ( y << 16 ) | sizeY;
//
__asm{
mov eax, 13
mov ebx, arg1
mov ecx, arg2
mov edx, colour
int 0x40
}
}
// ôóíêöèÿ 17
bool kos_GetButtonID( Dword &buttonID )
{
Dword result;
//
__asm{
mov eax, 17
int 0x40
mov result, eax
}
//
buttonID = result >> 8;
//
return (result & 0xFF) == 0;
}
// ôóíêöèÿ 23
Dword kos_WaitForEvent( Dword timeOut )
{
// Dword result;
__asm{
mov eax, 23
mov ebx, timeOut
int 0x40
// mov result, eax
}
// return result;
}
// ïîëó÷åíèå èíôîðìàöèè î ñîñòîÿíèè "ìûøè" ôóíêöèÿ 37
void kos_GetMouseState( Dword & buttons, int & cursorX, int & cursorY )
{
Dword mB;
Word curX;
Word curY;
sProcessInfo sPI;
//
__asm{
mov eax, 37
mov ebx, 1
int 0x40
mov curY, ax
shr eax, 16
mov curX, ax
mov eax, 37
mov ebx, 2
int 0x40
mov mB, eax
}
//
kos_ProcessInfo( &sPI );
//
buttons = mB;
cursorX = curX - sPI.processInfo.left;
cursorY = curY - sPI.processInfo.top;
}
// ôóíêöèÿ 40 óñòàíîâèòü ìàñêó ñîáûòèé
void kos_SetMaskForEvents( Dword mask )
{
//
__asm{
mov eax, 40
mov ebx, mask
int 0x40
}
}
// ôóíêöèÿ 47 âûâåñòè â îêíî ïðèëîæåíèÿ ÷èñëî
void kos_DisplayNumberToWindow(
Dword value,
Dword digitsNum,
Word x,
Word y,
Dword colour,
eNumberBase nBase,
bool valueIsPointer
)
{
Dword arg1, arg2;
//
arg1 = ( valueIsPointer ? 1 : 0 ) |
( ((Byte)nBase) << 8 ) |
( ( digitsNum & 0x1F ) << 16 );
arg2 = ( x << 16 ) | y;
//
__asm{
mov eax, 47
mov ebx, arg1
mov ecx, value
mov edx, arg2
mov esi, colour
int 0x40
}
}
// ôóíêöèÿ 70 äîñòóï ê ôàéëîâîé ñèñòåìå
Dword kos_FileSystemAccess( kosFileInfo *fileInfo )
{
// Dword result;
//
__asm{
mov eax, 70
mov ebx, fileInfo
int 0x40
// mov result, eax
}
//
// return result;
}
// ôóíêöèÿ 63 âûâîä ñèìâîëÿ â îêíî îòëàäêè
void kos_DebugOutChar( char ccc )
{
//
__asm{
mov eax, 63
mov ebx, 1
mov cl, ccc
int 0x40
}
}
// ôóíêöèÿ 66 ðåæèì ïîëó÷åíèÿ äàííûõ îò êëàâèàòóðû
void kos_SetKeyboardDataMode( Dword mode )
{
//
__asm{
mov eax, 66
mov ebx, 1
mov ecx, mode
int 0x40
}
}
// âûâîä ñòðîêè â îêíî îòëàäêè
void rtlDebugOutString( char *str )
{
//
for ( ; str[0] != 0; str++ )
{
kos_DebugOutChar( str[0] );
}
//
kos_DebugOutChar( 13 );
kos_DebugOutChar( 10 );
}
// ôóíêöèÿ 64 èçìåíåíèå êîëè÷åñòâà ïàìÿòè, âûäåëåííîé äëÿ ïðîãðàììû
bool kos_ApplicationMemoryResize( Dword targetSize )
{
Dword result;
//
__asm{
mov eax, 64
mov ebx, 1
mov ecx, targetSize
int 0x40
mov result, eax
}
//
return result == 0;
}
// ôóíêöèÿ 67 èçìåíèòü ïàðàìåòðû îêíà, ïàðàìåòð == -1 íå ìåíÿåòñÿ
void kos_ChangeWindow( Dword x, Dword y, Dword sizeX, Dword sizeY )
{
//
__asm{
mov eax, 67
mov ebx, x
mov ecx, y
mov edx, sizeX
mov esi, sizeY
int 0x40
}
}
Byte* kos_GetMemory(Dword count)
{
__asm
{
mov eax,68
mov ebx,12
mov ecx,count
int 40h
}
}
Dword kos_FreeMemory(Byte* pMemory)
{
__asm
{
mov eax,68
mov ebx,13
mov ecx,pMemory
int 40h
}
}
// âûçîâ àáñòðàêòíîãî ìåòîäà
int __cdecl _purecall()
{
rtlDebugOutString( pureCallMessage );
kos_ExitApp();
return 0;
}
// âûçîâ ñòàòè÷åñêèõ èíèöèàëèçàòîðîâ
// çàîäíî èíèöèàëèçàöèÿ ãåíåðàòîðà ñëó÷àéíûõ ÷èñåë
//#pragma section(".CRT$XCA",long,read,write)
//#pragma section(".CRT$XCZ",long,read,write)
#pragma data_seg(".CRT$XCA")
#pragma data_seg(".CRT$XCZ")
typedef void (__cdecl *_PVFV)(void);
__declspec(allocate(".CRT$XCA")) _PVFV __xc_a[1] = { NULL };
__declspec(allocate(".CRT$XCZ")) _PVFV __xc_z[1] = { NULL };
//
#pragma comment(linker, "/merge:.CRT=.rdata")
//
void crtStartUp()
{
// âûçûâàåì èíèöèàëèçàòîðû ïî ñïèñêó, NULL'û èãíîðèðóåì
for ( _PVFV *pbegin = __xc_a; pbegin < __xc_z; pbegin++ )
{
//
if ( *pbegin != NULL )
(**pbegin)();
}
// èíèöèàëèçèðóåì ãåíåðàòîð ñëó÷àéíûõ ÷èñåë
rtlSrand( kos_GetSystemClock() );
// ïóòü ê ôàéëó ïðîöåññà
kosExePath = *((char **)0x20);
// âûçîâ ãëàâíîé ôóíêöèè ïðèëîæåíèÿ
kos_Main();
// âûõîä
kos_ExitApp();
}

View File

@ -0,0 +1,203 @@
typedef unsigned __int32 Dword;
typedef unsigned __int16 Word;
typedef unsigned __int8 Byte;
//typedef unsigned __int32 size_t;
#define NULL 0
#define MAX_PATH 256
#define FO_READ 0
#define FO_WRITE 2
#define EM_WINDOW_REDRAW 1
#define EM_KEY_PRESS 2
#define EM_BUTTON_CLICK 4
#define EM_APP_CLOSE 8
#define EM_DRAW_BACKGROUND 16
#define EM_MOUSE_EVENT 32
#define EM_IPC 64
#define EM_NETWORK 256
#define KM_CHARS 0
#define KM_SCANS 1
#define WRS_BEGIN 1
#define WRS_END 2
#define PROCESS_ID_SELF -1
//#define abs(a) (a<0?0-a:a)
extern "C" double acos(double x);
extern "C" double asin(double x);
extern "C" double floor(double x);
extern "C" double round(double x);
#pragma function(acos,asin)
#if _MSC_VER > 1200
#pragma function(floor)
#endif
struct kosFileInfo
{
Dword rwMode;
Dword OffsetLow;
Dword OffsetHigh;
Dword dataCount;
Byte *bufferPtr;
char fileURL[MAX_PATH];
};
struct RGB
{
Byte b;
Byte g;
Byte r;
//
RGB() {};
//
RGB( Dword value )
{
r = (Byte)(value >> 16);
g = (Byte)(value >> 8);
b = (Byte)value;
};
//
bool operator != ( RGB &another )
{
return this->b != another.b || this->g != another.g || this->r != another.r;
};
//
bool operator == ( RGB &another )
{
return this->b == another.b && this->g == another.g && this->r == another.r;
};
};
union sProcessInfo
{
Byte rawData[1024];
#pragma pack(push, 1)
struct
{
Dword cpu_usage;
Word window_stack_position;
Word window_stack_value;
Word reserved1;
char process_name[12];
Dword memory_start;
Dword used_memory;
Dword PID;
Dword left;
Dword top;
Dword width;
Dword height;
Word slot_state;
Word reserved2;
Dword work_left;
Dword work_top;
Dword work_width;
Dword work_height;
Byte window_state;
} processInfo;
#pragma pack(pop)
};
//
extern char *kosExePath;
//
int abs(int value);
//
void crtStartUp();
//
int __cdecl _purecall();
//
int __cdecl atexit( void (__cdecl *func )( void ));
//
void rtlSrand( Dword seed );
Dword rtlRand( void );
//
char * __cdecl strcpy( char *target, const char *source );
int __cdecl strlen( const char *line );
char * __cdecl strrchr( const char * string, int c );
void lcase(char* string);
int strcmp(char* string1, char* string2);
#if _MSC_VER < 1400
extern "C" void * __cdecl memcpy( void *dst, const void *src, size_t bytesCount );
extern "C" void memset( Byte *dst, Byte filler, Dword count );
#pragma intrinsic(memcpy,memset)
#else
void * __cdecl memcpy( void *dst, const void *src, size_t bytesCount );
void memset( Byte *dst, Byte filler, Dword count );
#endif
void sprintf( char *Str, char* Format, ... );
//
Dword rtlInterlockedExchange(Dword *target, Dword value);
// ôóíêöèÿ -1 çàâåðøåíèÿ ïðîöåññà
void kos_ExitApp();
// ôóíêöèÿ 0
void kos_DefineAndDrawWindow(Word x, Word y, Word sizeX, Word sizeY,Byte mainAreaType, Dword mainAreaColour,Byte headerType, Dword headerColour, Dword borderColour);
// ôóíêöèÿ 1 ïîñòàâèòü òî÷êó
void kos_PutPixel( Dword x, Dword y, Dword colour);
// ôóíêöèÿ 2 ïîëó÷èòü êîä íàæàòîé êëàâèøè
bool kos_GetKey(Byte &keyCode);
// ôóíêöèÿ 3 ïîëó÷èòü âðåìÿ
Dword kos_GetSystemClock();
// ôóíêöèÿ 4
void kos_WriteTextToWindow(Word x, Word y,Byte fontType,Dword textColour,char *textPtr,Dword textLen);
// ôóíêöèÿ 7 íàðèñîâàòü èçîáðàæåíèå
void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y);
// ôóíêöèÿ 8 îïðåäåëèòü êíîïêó
void kos_DefineButton(Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour);
// ôóíêöèÿ 5 ïàóçà, â ñîòûõ äîëÿõ ñåêóíäû
void kos_Pause(Dword value);
// ôóíêöèÿ 9 - èíôîðìàöèÿ î ïðîöåññå
Dword kos_ProcessInfo(sProcessInfo *targetPtr, Dword processID = PROCESS_ID_SELF);
// ôóíêöèÿ 10
Dword kos_WaitForEvent();
// ôóíêöèÿ 11
Dword kos_CheckForEvent();
// ôóíêöèÿ 12
void kos_WindowRedrawStatus(Dword status );
// ôóíêöèÿ 13 íàðèñîâàòü ïîëîñó
void kos_DrawBar(Word x, Word y, Word sizeX, Word sizeY, Dword colour);
// ôóíêöèÿ 17
bool kos_GetButtonID(Dword &buttonID);
// ôóíêöèÿ 23
Dword kos_WaitForEvent(Dword timeOut);
//
enum eNumberBase
{
nbDecimal = 0,
nbHex,
nbBin
};
// ïîëó÷åíèå èíôîðìàöèè î ñîñòîÿíèè "ìûøè" ôóíêöèÿ 37
void kos_GetMouseState(Dword & buttons, int & cursorX, int & cursorY);
// ôóíêöèÿ 40 óñòàíîâèòü ìàñêó ñîáûòèé
void kos_SetMaskForEvents(Dword mask);
// ôóíêöèÿ 47 âûâåñòè â îêíî ïðèëîæåíèÿ ÷èñëî
void kos_DisplayNumberToWindow(Dword value, Dword digitsNum, Word x, Word y, Dword colour, eNumberBase nBase = nbDecimal, bool valueIsPointer = false);
// ôóíêöèÿ 58 äîñòóï ê ôàéëîâîé ñèñòåìå
Dword kos_FileSystemAccess(kosFileInfo *fileInfo);
// ôóíêöèÿ 63
void kos_DebugOutChar(char ccc);
//
void rtlDebugOutString(char *str);
// ôóíêöèÿ 64 èçìåíèòü ïàðàìåòðû îêíà, ïàðàìåòð == -1 íå ìåíÿåòñÿ
void kos_ChangeWindow(Dword x, Dword y, Dword sizeX, Dword sizeY);
// ôóíêöèÿ 67 èçìåíåíèå êîëè÷åñòâà ïàìÿòè, âûäåëåííîé äëÿ ïðîãðàììû
bool kos_ApplicationMemoryResize(Dword targetSize);
// ôóíêöèÿ 66 ðåæèì ïîëó÷åíèÿ äàííûõ îò êëàâèàòóðû
void kos_SetKeyboardDataMode(Dword mode);
//
Byte* kos_GetMemory(Dword count);
//
Dword kos_FreeMemory(Byte* pMemory);
//
void kos_Main();

View File

@ -0,0 +1,575 @@
#include "kosSyst.h"
#include "gfx.cpp"
#include "dlgopen.h"
#include "formats\pcx.h"
#include "formats\bmp.h"
#include "formats\tga.h"
#define btn_open 10
#define btn_prev 11
#define btn_next 12
#define btn_fit 13
#define scrl_up 30
#define scrl_down 31
#define scrl_left 32
#define scrl_right 33
char params[2048] = "PARAM";
const char header[] = "ImageView v 0.08";
int image_opened=0;
Byte* image_buffer=NULL; // Ïîëíîå RAW-Èçîáðàæåíèå
Byte* img_cuted=NULL; // Óñå÷åííîå RAW-èçîáðàæåíèå (èñïîëüçóåòñÿ ïðè ïðîêðóòêå èëè ìàñøòàáèðîâàíèè)
Byte* cur_files=NULL; // Áóôåð äëÿ îáùåãî ñïèñêà ôàéëîâ òåêóùåé ïàïêè
Word* img_files=NULL; // Óêàçàòåëü ìàññèâ ñî ñïèñîê ãðàô.ôàéëîâ â òåêóùåé ïàïêå
Dword cnt_imgfiles; // Êîëè÷åñòâî ýëåìåíòîâ ìàññèâà img_files[]
Dword cur_image; // Íîìåð òåêóùåãî èçîáðàæåíèÿ â ìàññèâå
char cur_folder[512]; // Ïóòü ê òåêóùåé ïàïêå ñ / íà êîíöå
Dword image_width;
Dword image_height;
Dword old_status_size=0;
char szStatus[256];
bool scale=0;
sProcessInfo proc;
Dword img_area_left,img_area_top,img_area_width,img_area_height;
int vscrl_max=100,vscrl_value=0,vscrl_coord_x,vscrl_coord_y,vscrl_coord_min,vscrl_coord_max,vscrl_using=0;
int hscrl_max=100,hscrl_value=0,hscrl_coord_x,hscrl_coord_y,hscrl_coord_min,hscrl_coord_max,hscrl_using=0;
Dword width_old,height_old;
/* Âûðåçàåò êâàäðàò èç èçîáðàæåíèÿ ïî êîîðäèíàòàì*/
void GetRectImage(Byte* src, Byte* dst, Dword left,Dword top,Dword width,Dword height)
{
int x,y;
int pImgS,pImgD=0;
for(y=top;y<top+height;y++)
{
for(x=left;x<left+width;x++)
{
pImgS=y*image_width*3+x*3;
*(dst+pImgD+0)=*(src+pImgS+0);
*(dst+pImgD+1)=*(src+pImgS+1);
*(dst+pImgD+2)=*(src+pImgS+2);
pImgD=pImgD+3;
}
}
}
/* Ðàñòÿãèâàåò èçîáðàæåíèå â ìåíüøóþ ñòîðîíó (èíà÷å íóæíî âûäåëÿòü áîëüøå ïàìÿòè ïîä img_cuted) */
void ResizeImage(Byte* src, Byte* dst, Dword new_width,Dword new_height)
{
int x,y,src_y,src_x;
int pImgS,pImgD=0;
for(y=0;y<new_height;y++)
{
for(x=0;x<new_width;x++)
{
__asm
{
finit
fild image_width
fidiv new_width
fild x
fmul st(0),st(1)
fistp src_x
fild image_height
fidiv new_height
fild y
fmul st(0),st(1)
fistp src_y
}
pImgS=src_y*image_width*3+src_x*3;
pImgD=y*new_width*3+x*3;
*(dst+pImgD+0)=*(src+pImgS+0);
*(dst+pImgD+1)=*(src+pImgS+1);
*(dst+pImgD+2)=*(src+pImgS+2);
}
}
}
void set_vscroll_values(Dword max, Dword value)
{
vscrl_max=max;
vscrl_value=value;
kos_DrawBar(vscrl_coord_x,vscrl_coord_y,15,35,0xDADADA);
vscrl_coord_y=vscrl_coord_min+((value*(vscrl_coord_max-vscrl_coord_min-35))/vscrl_max);
kos_PutImage(scroll_v,15,35,vscrl_coord_x,vscrl_coord_y);
}
void set_hscroll_values(Dword max, Dword value)
{
hscrl_max=max;
hscrl_value=value;
kos_DrawBar(hscrl_coord_x,hscrl_coord_y,35,15,0xDADADA);
hscrl_coord_x=hscrl_coord_min+((value*(hscrl_coord_max-hscrl_coord_min-35))/hscrl_max);
kos_PutImage(scroll_h,35,15,hscrl_coord_x,hscrl_coord_y);
}
void draw_image()
{
Dword new_width,new_height,scale_left,scale_top;
if (!image_opened) return;
if (scale==0)
{
/* Çäåñü âûâîä èçîáðàæåíèÿ ñ èñïîëüçîâàíèåì ïîëîñ ïðîêðóòêè */
new_width = image_width <= img_area_width ? image_width : img_area_width;
new_height = image_height <= img_area_height ? image_height : img_area_height;
GetRectImage(image_buffer, img_cuted, hscrl_value, vscrl_value, new_width, new_height);
kos_PutImage((RGB*)img_cuted, new_width, new_height, img_area_left,img_area_top);
} else {
/* Çäåñü âûâîä èçîáðàæåíèÿ ñ èñïîëüçîâàíèåì ìàñøòàáèðîâàíèÿ, ñîõðàíÿÿ ïðîïîðöèè */
__asm
{
finit
fild img_area_width
fidiv image_width
fild image_width
fmul st(0),st(1)
fistp new_width
fild image_height
fmul st(0),st(1)
fistp new_height
}
if (img_area_height<new_height)
{
__asm
{
finit
fild img_area_height
fidiv image_height
fild image_width
fmul st(0),st(1)
fistp new_width
fild image_height
fmul st(0),st(1)
fistp new_height
}
}
/* ýòî â ñëó÷àå íå ïðîïîðöèîíàëüíîãî ìàñøòàáèðîâàíèÿ */
//new_width=img_area_width;
//new_height=img_area_height;
if (new_width>image_width) new_width=image_width;
if (new_height>image_height) new_height=image_height;
ResizeImage(image_buffer,img_cuted,new_width,new_height);
/* Öåíòðèðîâàíèå èçîáðàæåíèÿ */
scale_left=(img_area_width/2)-(new_width/2);
scale_top=(img_area_height/2)-(new_height/2);
kos_PutImage((RGB*)img_cuted,new_width,new_height,img_area_left+scale_left,img_area_top+scale_top);
}
}
void draw_window(void)
{
kos_WindowRedrawStatus(1);
kos_DefineAndDrawWindow(0,0,450,350,0x33,0xEFEBEF,0,0,(Dword)header);
//ToolBar
//open
kos_DefineButton(2,4,20,20,btn_open+0x40000000,0xEFEBEF);
kos_PutImage(tbOpen,21,21,2,4);
//prev
kos_DefineButton(25,4,20,20,btn_prev+0x40000000,0xEFEBEF);
kos_PutImage(tbPrev,21,21,25,4);
//next
kos_DefineButton(48,4,20,20,btn_next+0x40000000,0xEFEBEF);
kos_PutImage(tbNext,21,21,48,4);
//fit image
kos_DefineButton(71,4,20,20,btn_fit+0x40000000,0xEFEBEF);
kos_PutImage(tbFit,21,21,71,4);
//Lines
kos_ProcessInfo(&proc,-1);
kos_DrawBar(2,30,proc.processInfo.work_width-3,1,0x94AECE);
//Scroll controls
//vertical scroll bar
vscrl_coord_x=proc.processInfo.work_width-16;
vscrl_coord_max=proc.processInfo.work_height-46;
kos_DrawBar(proc.processInfo.work_width-16,33,15,proc.processInfo.work_height-79,0xDADADA);
kos_DefineButton(proc.processInfo.work_width-16,33,14,14,scrl_up+0x40000000,0xEFEBEF);
kos_DefineButton(proc.processInfo.work_width-16,proc.processInfo.work_height-46,14,14,scrl_down+0x40000000,0xEFEBEF);
kos_PutImage(arrow_up,15,15,proc.processInfo.work_width-16,33);
kos_PutImage(arrow_down,15,15,proc.processInfo.work_width-16,proc.processInfo.work_height-46);
kos_PutImage(scroll_v,15,35,vscrl_coord_x,vscrl_coord_y);
//horisontal scroll bar
hscrl_coord_y=proc.processInfo.work_height-31;
hscrl_coord_max=proc.processInfo.work_width-31;
kos_DrawBar(2,proc.processInfo.work_height-31,proc.processInfo.work_width-18,15,0xDADADA);
kos_DefineButton(2,proc.processInfo.work_height-31,14,14,scrl_left+0x40000000,0xEFEBEF);
kos_DefineButton(proc.processInfo.work_width-31,proc.processInfo.work_height-31,14,14,scrl_right+0x40000000,0xEFEBEF);
kos_PutImage(arrow_left,15,15,2,proc.processInfo.work_height-31);
kos_PutImage(arrow_right,15,15,proc.processInfo.work_width-31,proc.processInfo.work_height-31);
kos_PutImage(scroll_h,35,15,hscrl_coord_x,hscrl_coord_y);
img_area_left=2;
img_area_top=33;
img_area_width=proc.processInfo.work_width-img_area_left-3-16;
img_area_height=proc.processInfo.work_height-img_area_top-3-16-15;
kos_WriteTextToWindow(2,proc.processInfo.work_height-12, 0x80, 0, szStatus, 0);
if (img_area_width<image_width) set_hscroll_values(image_width-img_area_width,0); else set_hscroll_values(1,0);
if (img_area_height<image_height) set_vscroll_values(image_height-img_area_height,0); else set_vscroll_values(1,0);
draw_image();
kos_WindowRedrawStatus(2);
}
void LoadPCX(Byte* filebuff, Dword filesize)
{
PCXFile pcx;
if (!pcx.LoadPCXFile(filebuff,filesize))
{
image_opened=1;
image_buffer=pcx.buffer;
image_width=pcx.width;
image_height=pcx.height;
} else {
image_opened=0;
}
}
void LoadBMP(Byte* filebuff, Dword filesize)
{
BMPFile bmp;
if (!bmp.LoadBMPFile(filebuff,filesize))
{
image_opened=1;
image_buffer=bmp.buffer;
image_width=bmp.width;
image_height=bmp.height;
} else {
image_opened=0;
}
}
void LoadTGA(Byte* filebuff, Dword filesize)
{
TGAFile tga;
if (!tga.LoadTGAFile(filebuff,filesize))
{
image_opened=1;
image_buffer=tga.buffer;
image_width=tga.width;
image_height=tga.height;
} else {
image_opened=0;
}
}
//Çàãðóçèòü ñïèñîê ôàéëîâ, ïîääåðæèâàåìûõ ïðîãðàììîé èç ïàïêè ñ òåêóùèì ôàéëîì
void load_folder(char* imgfile)
{
kosFileInfo fi;
char* cPtr;
int i;
// Èçâëå÷åì èìÿ ïàïêè
strcpy(fi.fileURL, imgfile);
cPtr=strrchr(fi.fileURL,'/');
cPtr[1]=0;
strcpy(cur_folder,fi.fileURL);
if (cur_files) { kos_FreeMemory(cur_files); cur_files=NULL;}
if (img_files) { kos_FreeMemory((Byte*)img_files); img_files=NULL;}
/* Âûäåëèì ïàìÿòü ïîä ôàéë */
cur_files = kos_GetMemory(65536);
fi.rwMode = 1;
fi.OffsetLow = 0;
fi.OffsetHigh = 0;
fi.dataCount = 65536;
fi.bufferPtr = cur_files;
int state = kos_FileSystemAccess(&fi);
if (state!=0 && state!=6) {kos_FreeMemory(cur_files); cur_files=NULL; return;}
Dword file_count=*(cur_files+8);
img_files = (Word*)kos_GetMemory(4*file_count);
char* image_name;
cnt_imgfiles=0;
cur_image=-1;
lcase(imgfile);
for(i=0;i<file_count;i++)
{
image_name=(char*)cur_files+32+i*304+40;
lcase(image_name);
cPtr=strrchr(image_name,'.');
if (strcmp((char*)cPtr,".bmp") || strcmp((char*)cPtr,".pcx") || strcmp((char*)cPtr,".tga"))
{
cPtr=strrchr(imgfile,'/');
if (strcmp(cPtr+1,image_name)) cur_image=cnt_imgfiles;
((Word*)img_files)[cnt_imgfiles]=i;
cnt_imgfiles++;
}
}
cnt_imgfiles--;
}
void open_imgfile(char* imgfile)
{
Word scr_left,scr_top,scr_right,scr_bot;
Word win_width,win_height;
Dword skin_height;
kosFileInfo fi;
Dword file_size;
Byte* filebuff;
Byte* infoBuf;
/* Âû÷èñëèì ðàçìåð ôàéëà */
infoBuf = kos_GetMemory(40); /* Áóôåð äëÿ èíôî-ñòðóêòóðû */
fi.rwMode = 5;
fi.OffsetLow = 0;
fi.OffsetHigh = 0;
fi.dataCount = 0;
fi.bufferPtr = infoBuf;
strcpy(fi.fileURL, imgfile);
if (kos_FileSystemAccess(&fi)) { kos_FreeMemory(infoBuf); return;}
file_size=*(Dword*)(infoBuf+32);
kos_FreeMemory(infoBuf);
/* Âûäåëèì ïàìÿòü ïîä ôàéë */
filebuff = kos_GetMemory(file_size);
fi.rwMode = 0;
fi.OffsetLow = 0;
fi.OffsetHigh = 0;
fi.dataCount = file_size;
fi.bufferPtr = filebuff;
strcpy(fi.fileURL, imgfile);
if (kos_FileSystemAccess(&fi)) { kos_FreeMemory(filebuff); return;}
/* Îïðåäåëÿåì òèï ôàéëà */
//lcase(imgfile); óæå â íèæíåì ðåãèñòðå: ýòî âûïîëíÿåòñÿ â load_folder
char* cPtr;
cPtr=strrchr(imgfile,'.');
if (strcmp((char*)cPtr,".bmp")) LoadBMP(filebuff,file_size);
if (strcmp((char*)cPtr,".pcx")) LoadPCX(filebuff,file_size);
if (strcmp((char*)cPtr,".tga")) LoadTGA(filebuff,file_size);
cPtr=strrchr(imgfile,'/')+1;
if (image_opened)
{
sprintf(szStatus,"” ©« %S... [%U/%U]",cPtr,cur_image+1,cnt_imgfiles+1);
__asm
{
mov eax,48
mov ebx,5
int 40h
mov scr_right,ax
shr eax,16
mov scr_bot,bx
shr ebx,16
mov scr_left,ax
mov scr_top,bx
mov eax,48
mov ebx,4
int 40h
mov skin_height,eax
}
if (scr_right-scr_left+1>image_width) win_width=image_width+img_area_left+3+16+10; else win_width=scr_right-scr_left+1;
if (scr_bot-scr_top+1>image_height) win_height=image_height+img_area_top+3+16+15+5+skin_height; else win_height=scr_bot-scr_top+1;
if (win_width<150) win_width=150;
if (win_height<160) win_height=160;
img_cuted=kos_GetMemory(image_width*image_height*3);
kos_ChangeWindow(scr_left,scr_top,win_width,win_height);
if (img_area_width<image_width) set_hscroll_values(image_width-img_area_width,0); else set_hscroll_values(1,0);
if (img_area_height<image_height) set_vscroll_values(image_height-img_area_height,0); else set_vscroll_values(1,0);
} else {
sprintf(szStatus,"” ©« %S ­¥ § £à㦥­. ”®à¬ â ­¥ ¯®¤¤¥à¦¨¢ ¥âáï.",cPtr);
}
draw_window();
kos_FreeMemory(filebuff);
}
void show_dlg()
{
char* imgfile;
imgfile=DialogOpenFile(&draw_window);
if (!imgfile) return;
load_folder(imgfile);
//Åñëè ôàéë óæå áûë îòêðûò...
if (image_opened)
{
image_opened=0;
kos_FreeMemory(image_buffer); image_buffer=NULL;
kos_FreeMemory(img_cuted); img_cuted=NULL;
}
open_imgfile(imgfile);
}
void kos_Main()
{
Dword btnID;
Byte keyCode;
Dword mButton;
int mX,mXOld;
int mY,mYOld;
char label1[100];
/* Èíèöèàëèçàöèÿ êó÷è ïðîöåññà */
__asm
{
mov eax,68
mov ebx,11
int 40h
}
vscrl_coord_min=vscrl_coord_y=33+15;
hscrl_coord_min=hscrl_coord_x=2+15;
strcpy(szStatus,"” ©« ­¥ § £à㦥­");
draw_window();
if (params[0]!='P') {load_folder(params); open_imgfile(params);}
kos_SetMaskForEvents(0x27);
for (;;)
{
switch (kos_WaitForEvent(10))
{
case 1:
draw_window();
break;
case 2:
kos_GetKey(keyCode);
break;
case 3:
kos_GetButtonID(btnID);
switch (btnID)
{
case 1:
//Îñâîáîäèì ïàìÿòü
if (image_buffer) kos_FreeMemory(image_buffer);
if (img_cuted) kos_FreeMemory(img_cuted);
if (cur_files) kos_FreeMemory(cur_files);
if (img_files) kos_FreeMemory((Byte*)img_files);
kos_ExitApp();
break;
case btn_open:
show_dlg();
break;
//Èñïîëüçóåì óæå íå íóæíûé íàì params
case btn_prev:
if (!cur_files) break;
if (!cur_image) cur_image=cnt_imgfiles; else cur_image--;
strcpy(params,cur_folder);
strcpy(params+strlen(cur_folder),(char*)cur_files+32+((Word*)img_files)[cur_image]*304+40);
open_imgfile(params);
break;
case btn_next:
if (!cur_files) break;
if (cur_image==cnt_imgfiles) cur_image=0; else cur_image++;
strcpy(params,cur_folder);
strcpy(params+strlen(cur_folder),(char*)cur_files+32+((Word*)img_files)[cur_image]*304+40);
open_imgfile(params);
break;
/*
case scrl_up:
if (vscrl_max==1 || vscrl_coord_y<=vscrl_coord_min) break;
set_vscroll_values(vscrl_max, ((vscrl_coord_y - 2 - vscrl_coord_min) * vscrl_max) / (vscrl_coord_max - vscrl_coord_min - 35));
break;
case scrl_down:
if (vscrl_max == 1 || vscrl_coord_y >= vscrl_coord_max) break;
set_vscroll_values(vscrl_max, ((vscrl_coord_y + 2 - vscrl_coord_min) * vscrl_max) / (vscrl_coord_max - vscrl_coord_min - 35));
break;
*/
case btn_fit:
scale = scale ? 0 : 1;
draw_window();
break;
}
break;
case 6:
default:
kos_GetMouseState(mButton,mX,mY);
//Âåðòèêàëüíàÿ ïðîêðóòêà
if (mButton==1)
{
if (vscrl_using)
{
kos_DrawBar(vscrl_coord_x,vscrl_coord_y,15,35,0xDADADA);
if (vscrl_coord_y+mY-mYOld<vscrl_coord_min)
{
vscrl_value=0;
vscrl_coord_y=vscrl_coord_min;
} else if (vscrl_coord_y+35+mY-mYOld>vscrl_coord_max) {
vscrl_value=vscrl_max;
vscrl_coord_y=vscrl_coord_max-35;
} else {
vscrl_value=(((vscrl_coord_y-vscrl_coord_min)*vscrl_max)/(vscrl_coord_max-vscrl_coord_min-35));
vscrl_coord_y=vscrl_coord_y+mY-mYOld;
mYOld=mY;
}
kos_PutImage(scroll_v,15,35,vscrl_coord_x,vscrl_coord_y);
draw_image();
} else {
if (mY>=vscrl_coord_y && mY<=vscrl_coord_y+35 && mX>=vscrl_coord_x && mX<=vscrl_coord_x+15)
{
vscrl_using=1;
mYOld=mY;
}
}
} else if(mButton==0) {
if (vscrl_using) {vscrl_using=0; draw_image();}
}
//Ãîðèçîíòàëüíàÿ ïðîêðóòêà
if (mButton==1)
{
if (hscrl_using)
{
kos_DrawBar(hscrl_coord_x,hscrl_coord_y,35,15,0xDADADA);
if (hscrl_coord_x+mX-mXOld<hscrl_coord_min)
{
hscrl_value=0;
hscrl_coord_x=hscrl_coord_min;
} else if (hscrl_coord_x+35+mX-mXOld>hscrl_coord_max) {
hscrl_value=hscrl_max;
hscrl_coord_x=hscrl_coord_max-35;
} else {
hscrl_value=(((hscrl_coord_x-hscrl_coord_min)*hscrl_max)/(hscrl_coord_max-hscrl_coord_min-35));
hscrl_coord_x=hscrl_coord_x+mX-mXOld;
mXOld=mX;
}
kos_PutImage(scroll_h,35,15,hscrl_coord_x,hscrl_coord_y);
draw_image();
} else {
if (mX>=hscrl_coord_x && mX<=hscrl_coord_x+35 && mY>=hscrl_coord_y && mY<=hscrl_coord_y+15)
{
hscrl_using=1;
mXOld=mX;
}
}
} else if(mButton==0) {
if (hscrl_using) {hscrl_using=0; draw_image();}
}
break;
}
}
}

View File

@ -0,0 +1,329 @@
// memman.cpp : Defines the entry point for the console application.
//
#include "kosSyst.h"
#include "mcsmemm.h"
void * __cdecl operator new ( size_t count, size_t element_size )
{
return allocmem( (Dword)(count * element_size) );
}
void * __cdecl operator new [] ( size_t amount )
{
return allocmem( (Dword)amount );
}
void * __cdecl operator new ( size_t amount )
{
return allocmem( (Dword)amount );
}
void __cdecl operator delete ( void *pointer )
{
if ( pointer != NULL ) freemem( pointer );
}
void __cdecl operator delete [] ( void *pointer )
{
if ( pointer != NULL ) freemem( pointer );
}
//
Dword mmMutex = FALSE;
MemBlock *rootfree = NULL;
MemBlock *rootuser = NULL;
bool mmInitialized = false;
Byte *mmHeapTop = NULL;
//
Byte * AllocMemFromSystem( Dword reqSize )
{
Byte *result;
sProcessInfo pInfo;
//
if ( mmInitialized )
{
result = mmHeapTop;
}
else
{
//
kos_ProcessInfo( &pInfo );
//
result = (Byte *)(pInfo.processInfo.used_memory + 1);
//
mmInitialized = true;
}
//
if ( ! kos_ApplicationMemoryResize( ((Dword)result) + reqSize ) )
{
result = NULL;
}
//
mmHeapTop = result + reqSize;
//
return result;
}
//
Byte *allocmem( Dword reqsize )
{
MemBlock *BlockForCheck;
MemBlock *LastKnownGood;
Dword tail;
Byte *address;
//ïîäðîâíÿåì ðàçìåð
if( ( tail = reqsize % SIZE_ALIGN ) != 0 )
{
reqsize += SIZE_ALIGN - tail;
}
LastKnownGood = NULL;
// æä¸ì îñâîáîæäåíèÿ ìüþòåêñà
while ( rtlInterlockedExchange( &mmMutex, TRUE ) )
{
//
kos_Pause( 1 );
}
//èùåì ïîäõîäÿùèé ñâîáîäíûé áëîê
if( rootfree != NULL )
{
for ( BlockForCheck = rootfree; ; BlockForCheck = BlockForCheck->Next )
{
if ( BlockForCheck->Size >= reqsize )
{
//íàøëè
if ( LastKnownGood != NULL )
{
if ( LastKnownGood->Size >= BlockForCheck->Size )
LastKnownGood = BlockForCheck;
}
else
LastKnownGood = BlockForCheck;
if ( LastKnownGood->Size == reqsize )
break;
}
if ( BlockForCheck->Next == NULL )
break;
}
}
if ( LastKnownGood != NULL )
{
//ïðîâåðèì íàéäåííûé áëîê íà âîçìîæíîñòü äåëåíèÿ
tail = LastKnownGood->Size - reqsize;
if ( tail >= ( sizeof(MemBlock) + SIZE_ALIGN ) )
{
//áóäåì ðàçáèâàòü
BlockForCheck = (MemBlock *)( ( (Byte *)LastKnownGood ) + tail );
BlockForCheck->Size = reqsize;
//âñòàâèì çàíÿòûé áëîê â íà÷àëî ñïèñêà çàíàòûõ áëîêîâ
if( rootuser != NULL )
{
BlockForCheck->Next = rootuser;
rootuser->Previous = BlockForCheck;
BlockForCheck->Previous = NULL;
rootuser = BlockForCheck;
}
else
{
rootuser = BlockForCheck;
BlockForCheck->Next = NULL;
BlockForCheck->Previous = NULL;
}
//èçìåíèì ðàçìåð îñòàâøåéñÿ ÷àñòè
LastKnownGood->Size = tail - sizeof(MemBlock);
address = ( (Byte *)BlockForCheck ) + sizeof(MemBlock);
// îòïóñòèì ìüþòåêñ
rtlInterlockedExchange( &mmMutex, FALSE );
return address;
}
else
{
//ïåðåìåñòè áëîê èç î÷åðåäè ñâîáîäíûõ â íà÷àëî î÷åðåäè çàíÿòûõ
//ñíà÷àëà âûêèíåì åãî èç î÷åðåäè ñâîáîäíûõ
if ( LastKnownGood->Previous != NULL )
{
LastKnownGood->Previous->Next = LastKnownGood->Next;
}
else
{
//áëîê ñòîèò â íà÷àëå î÷åðåäè
rootfree = LastKnownGood->Next;
}
if( LastKnownGood->Next != NULL )
{
LastKnownGood->Next->Previous = LastKnownGood->Previous;
}
//òåïåðü âñòàâèì åãî â î÷åðåäü çàíÿòûõ
if( rootuser != NULL )
{
LastKnownGood->Next = rootuser;
rootuser->Previous = LastKnownGood;
LastKnownGood->Previous = NULL;
rootuser = LastKnownGood;
}
else
{
rootuser = LastKnownGood;
LastKnownGood->Next = NULL;
LastKnownGood->Previous = NULL;
}
//
address = ( (Byte *)LastKnownGood ) + sizeof(MemBlock);
// îòïóñòèì ìüþòåêñ
rtlInterlockedExchange( &mmMutex, FALSE );
return address;
}
}
else
{
//íàäî ïîëó÷èòü åù¸ êóñî÷åê ïàìÿòè
LastKnownGood = (MemBlock *)AllocMemFromSystem( reqsize + sizeof(MemBlock) );
//
if( LastKnownGood != NULL )
{
LastKnownGood->Size = reqsize;
//òåïåðü âñòàâèì åãî â î÷åðåäü çàíÿòûõ
if( rootuser != NULL )
{
LastKnownGood->Next = rootuser;
rootuser->Previous = LastKnownGood;
LastKnownGood->Previous = NULL;
rootuser = LastKnownGood;
}
else
{
rootuser = LastKnownGood;
LastKnownGood->Next = NULL;
LastKnownGood->Previous = NULL;
}
address = ( (Byte *)LastKnownGood ) + sizeof(MemBlock);
// îòïóñòèì ìüþòåêñ
rtlInterlockedExchange( &mmMutex, FALSE );
return address;
}
}
// îòïóñòèì ìüþòåêñ
rtlInterlockedExchange( &mmMutex, FALSE );
//
rtlDebugOutString( "allocmem failed." );
kos_ExitApp();
//
return NULL;
}
//
Dword freemem( void *vaddress )
{
Dword result;
Byte *checknext, *address = (Byte *)vaddress;
// æä¸ì îñâîáîæäåíèÿ ìüþòåêñà
while ( rtlInterlockedExchange( &mmMutex, TRUE ) )
{
//
kos_Pause( 1 );
}
MemBlock *released = (MemBlock *)( address - sizeof(MemBlock) );
result = released->Size;
//óáèðàåì áëîê èç ñïèñêà çàíÿòûõ
if ( released->Previous != NULL )
{
released->Previous->Next = released->Next;
}
else
{
rootuser = released->Next;
}
if ( released->Next != NULL )
{
released->Next->Previous = released->Previous;
}
//çàêèíåì òåïåðü ýòîò áëîê â ñïèñîê ñâîáîäíûõ
released->Next = rootfree;
released->Previous = NULL;
rootfree = released;
if ( released->Next != NULL )
{
released->Next->Previous = released;
}
//òåïåðü ïîèùåì ñìåæíûå ñâîáîäíûå áëîêè
checknext = (Byte *)(rootfree) + ( rootfree->Size + sizeof(MemBlock) );
//
for ( released = rootfree->Next; released != NULL; released = released->Next )
{
if ( checknext == (Byte *)released )
{
//ñîáèðàåì áëîêè âìåñòå
//ñíà÷àëà âûêèíåì èç î÷åðåäè ñâîáîäíûõ
released->Previous->Next = released->Next;
if( released->Next != NULL )
{
released->Next->Previous = released->Previous;
}
//òåïåðü óâåëè÷èì ðàçìåð êîðíåâîãî áëîêà
rootfree->Size += released->Size + sizeof(MemBlock);
break;
}
}
//åñëè íàäî, ïîèùåì áëîêè ïåðåä òåêùèì.
checknext = (Byte *)(rootfree);
//
if ( released == NULL )
{
for ( released = rootfree->Next; released != NULL; released = released->Next )
{
if ( checknext == (Byte *)released + ( released->Size + sizeof(MemBlock) ) )
{
//ñîáèðàåì áëîêè âìåñòå
//óâåëè÷èì ðàçìåð áëîêà
released->Size += rootfree->Size + sizeof(MemBlock);
//òåïåðü âûêèíåì èç î÷åðåäè ñâîáîäíûõ
released->Previous->Next = released->Next;
if ( released->Next != NULL )
{
released->Next->Previous = released->Previous;
}
//è çàêèíåì åãî â íà÷àëî î÷åðåäè âìåñòî ïðèñîåäèí¸ííîãî áëîêà èç êîðíÿ ñïèñêà
if ( rootfree->Next != NULL )
{
rootfree->Next->Previous = released;
}
released->Next = rootfree->Next;
released->Previous = NULL;
rootfree = released;
break;
}
}
}
// îòïóñòèì ìüþòåêñ
rtlInterlockedExchange( &mmMutex, FALSE );
return result;
}