Compare commits
23 Commits
rewrite_id
...
reshare-tw
| Author | SHA1 | Date | |
|---|---|---|---|
| eab5059e00 | |||
| 0380ec1157 | |||
| 7ec23b1400 | |||
| 084110a2ba | |||
| f676109eea | |||
| 916df5a769 | |||
| b75f836a4f | |||
| 9093ef3566 | |||
| f7b8d753ca | |||
| 911faf00ab | |||
| 10d9e9f36f | |||
| f4c4a7e29a | |||
|
|
bc5b2f884a | ||
|
|
d0de275ab3 | ||
|
|
a83f6f7e4b | ||
|
|
d54c802297 | ||
|
|
29c42738b8 | ||
| c17d1a57a3 | |||
| 7b0867a6cf | |||
| c65da0d96f | |||
| a0c01e204e | |||
| d50642ce1f | |||
| 8d235ce49b |
@@ -31,8 +31,8 @@ import lib_libini, \
|
||||
LIBINI_enum_keys , 'ini_enum_keys' , \
|
||||
LIBINI_get_str , 'ini_get_str' , \
|
||||
LIBINI_get_int , 'ini_get_int' , \
|
||||
LIBINI_get_color , 'int_get_color' , \
|
||||
LIBINI_get_shortcut , 'int_get_shortcut' , \
|
||||
LIBINI_get_color , 'ini_get_color' , \
|
||||
LIBINI_get_shortcut , 'ini_get_shortcut' , \
|
||||
LIBINI_set_str , 'ini_set_str' , \
|
||||
LIBINI_set_int , 'ini_set_int' , \
|
||||
LIBINI_set_color , 'ini_set_color'
|
||||
|
||||
@@ -864,7 +864,7 @@ void ff_set_mpeg4_time(MpegEncContext * s){
|
||||
}
|
||||
|
||||
static void mpeg4_encode_gop_header(MpegEncContext * s){
|
||||
int hours, minutes, seconds;
|
||||
int64_t hours, minutes, seconds;
|
||||
int64_t time;
|
||||
|
||||
put_bits(&s->pb, 16, 0);
|
||||
|
||||
@@ -2035,8 +2035,13 @@ static int vp3_decode_frame(AVCodecContext *avctx,
|
||||
if (ff_thread_get_buffer(avctx, &s->current_frame, AV_GET_BUFFER_FLAG_REF) < 0)
|
||||
goto error;
|
||||
|
||||
if (!s->edge_emu_buffer)
|
||||
if (!s->edge_emu_buffer) {
|
||||
s->edge_emu_buffer = av_malloc(9*FFABS(s->current_frame.f->linesize[0]));
|
||||
if (!s->edge_emu_buffer) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
if (s->keyframe) {
|
||||
if (!s->theora)
|
||||
|
||||
@@ -2580,8 +2580,10 @@ static int http_receive_data(HTTPContext *c)
|
||||
} else if (c->buffer_ptr - c->buffer >= 2 &&
|
||||
!memcmp(c->buffer_ptr - 1, "\r\n", 2)) {
|
||||
c->chunk_size = strtol(c->buffer, 0, 16);
|
||||
if (c->chunk_size == 0) // end of stream
|
||||
if (c->chunk_size <= 0) { // end of stream or invalid chunk size
|
||||
c->chunk_size = 0;
|
||||
goto fail;
|
||||
}
|
||||
c->buffer_ptr = c->buffer;
|
||||
break;
|
||||
} else if (++loop_run > 10)
|
||||
@@ -2603,6 +2605,7 @@ static int http_receive_data(HTTPContext *c)
|
||||
/* end of connection : close it */
|
||||
goto fail;
|
||||
else {
|
||||
av_assert0(len <= c->chunk_size);
|
||||
c->chunk_size -= len;
|
||||
c->buffer_ptr += len;
|
||||
c->data_count += len;
|
||||
|
||||
@@ -267,8 +267,12 @@ static int cine_read_header(AVFormatContext *avctx)
|
||||
|
||||
/* parse image offsets */
|
||||
avio_seek(pb, offImageOffsets, SEEK_SET);
|
||||
for (i = 0; i < st->duration; i++)
|
||||
for (i = 0; i < st->duration; i++) {
|
||||
if (avio_feof(pb))
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
av_add_index_entry(st, avio_rl64(pb), i, 0, 0, AVINDEX_KEYFRAME);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ diamond'ом. Она используется в проектах xonix и fara
|
||||
Kolibri-программу. Утилита всего лишь изменяет формат exe-шника, так что,
|
||||
чтобы действительно получилась работающая программа, нужно выполнение
|
||||
определённых условий. Понятно, что требуется, чтобы программа общалась
|
||||
с внешним миром средствами Колибри (т.е. int 0x40) и не использовала
|
||||
с внешним миром средствами КолибриОС (т.е. int 0x40) и не использовала
|
||||
никаких Windows-библиотек. Помимо этого, требуется также, чтобы программа
|
||||
размещалась по нулевому адресу (ключ линкера "/base:0"). Как писать такие
|
||||
программы - смотрите в уже упомянутых проектах xonix и fara.
|
||||
|
||||
@@ -38,7 +38,6 @@ img_files = {
|
||||
{"UNIMG", SRC_PROGS .. "/fs/unimg/unimg"},
|
||||
{"3D/HOUSE.3DS", "common/3d/house.3ds"},
|
||||
{"File Managers/ICONS.INI", "common/File Managers/icons.ini"},
|
||||
{"GAMES/FLPYBIRD", SRC_PROGS .. "/games/floppybird/Release/floppybird"},
|
||||
{"FONTS/TAHOMA.KF", "common/fonts/tahoma.kf"},
|
||||
-- {"LIB/ICONV.OBJ", "common/lib/iconv.obj"},
|
||||
{"LIB/KMENU.OBJ", "common/lib/kmenu.obj"},
|
||||
@@ -153,9 +152,6 @@ extra_files = {
|
||||
{"HD_Load/USB_boot_old/", SRC_PROGS .. "/hd_load/usb_boot_old/usb_boot_866.txt"},
|
||||
{"HD_Load/USB_boot_old/", SRC_PROGS .. "/hd_load/usb_boot_old/usb_boot_1251.txt"},
|
||||
{"kolibrios/3D/info3ds/INFO3DS.INI", SRC_PROGS .. "/develop/info3ds/info3ds.ini"},
|
||||
{"kolibrios/3D/info3ds/OBJECTS.PNG", SRC_PROGS .. "/develop/info3ds/objects.png"},
|
||||
{"kolibrios/3D/info3ds/TOOLBAR.PNG", SRC_PROGS .. "/develop/info3ds/toolbar.png"},
|
||||
{"kolibrios/3D/info3ds/FONT8X9.BMP", SRC_PROGS .. "/fs/kfar/trunk/font8x9.bmp"},
|
||||
{"kolibrios/3D/blocks/blocks.kex", "../programs/bcc32/games/blocks/bin/blocks.kex"},
|
||||
{"kolibrios/3D/blocks/models/", "../programs/bcc32/games/blocks/models/*"},
|
||||
{"kolibrios/3D/md2view/", "common/3d/md2view/*"},
|
||||
@@ -205,6 +201,7 @@ extra_files = {
|
||||
{"kolibrios/emul/chip8/roms/", SRC_PROGS .. "/emulator/chip8/roms/*"},
|
||||
{"kolibrios/emul/kwine/kwine", SRC_PROGS .. "/emulator/kwine/bin/kwine"},
|
||||
{"kolibrios/emul/kwine/lib/", SRC_PROGS .. "/emulator/kwine/bin/lib/*"},
|
||||
{"kolibrios/emul/uxn", SRC_PROGS .. "/emulator/uxn/uxn"},
|
||||
{"kolibrios/emul/uarm/", "common/emul/uarm/*"},
|
||||
{"kolibrios/emul/zsnes/", "common/emul/zsnes/*"},
|
||||
{"kolibrios/games/BabyPainter", "common/games/BabyPainter"},
|
||||
@@ -404,8 +401,9 @@ tup.append_table(img_files, {
|
||||
{"@MENU", VAR_PROGS .. "/system/menu/trunk/menu"},
|
||||
{"@NOTIFY", VAR_PROGS .. "/system/notify3/notify"},
|
||||
{"@OPEN", VAR_PROGS .. "/system/open/open"},
|
||||
{"@TASKBAR", VAR_PROGS .. "/system/taskbar/trunk/TASKBAR"},
|
||||
{"@RESHARE", VAR_PROGS .. "/system/reshare/reshare"},
|
||||
{"@SS", VAR_PROGS .. "/system/scrsaver/scrsaver"},
|
||||
{"@TASKBAR", VAR_PROGS .. "/system/taskbar/trunk/TASKBAR"},
|
||||
{"@VOLUME", VAR_PROGS .. "/media/volume/volume"},
|
||||
{"HACONFIG", VAR_PROGS .. "/other/ha/HACONFIG"},
|
||||
{"ACLOCK", VAR_PROGS .. "/demos/aclock/aclock"},
|
||||
@@ -664,7 +662,6 @@ end -- tup.getconfig('NO_JWASM') ~= 'full'
|
||||
-- Programs that require C-- to compile.
|
||||
if tup.getconfig('NO_CMM') ~= 'full' then
|
||||
tup.append_table(img_files, {
|
||||
{"@RESHARE", VAR_PROGS .. "/cmm/misc/reshare.com"},
|
||||
{"APP_PLUS", VAR_PROGS .. "/cmm/app_plus/app_plus.com"},
|
||||
{"EASYSHOT", VAR_PROGS .. "/cmm/misc/easyshot.com"},
|
||||
{"MOUSECFG", VAR_PROGS .. "/cmm/mousecfg/mousecfg.com"},
|
||||
@@ -724,6 +721,7 @@ tup.append_table(img_files, {
|
||||
{"NETWORK/WHOIS", VAR_PROGS .. "/network/whois/whois"},
|
||||
{"SHELL", VAR_PROGS .. "/system/shell/shell"},
|
||||
{"GAMES/DINO", VAR_PROGS .. "/games/dino/dino"},
|
||||
{"GAMES/FLPYBIRD", VAR_PROGS .. "/games/flpybird/flpybird"},
|
||||
})
|
||||
tup.append_table(extra_files, {
|
||||
{"kolibrios/utils/thashview", VAR_PROGS .. "/other/TinyHashView/thashview"},
|
||||
|
||||
@@ -162,6 +162,7 @@ min=23
|
||||
nes=23
|
||||
sna=23
|
||||
snes=23
|
||||
rom=23
|
||||
bat=24
|
||||
sh=24
|
||||
sys=25
|
||||
|
||||
@@ -68,6 +68,7 @@ sna=/kolibrios/emul/e80/e80
|
||||
gb=/kolibrios/emul/gameboy
|
||||
gbc=/kolibrios/emul/gameboy
|
||||
min=/kolibrios/emul/pokemini
|
||||
rom=/kolibrios/emul/uxn
|
||||
nc=/kolibrios/utils/cnc_editor/cnc_editor
|
||||
kf=/sys/KF_VIEW
|
||||
csv=/sys/table
|
||||
|
||||
@@ -22,3 +22,5 @@ ToggleBar=Tab
|
||||
path=/usbhd0/1/kolibri.img
|
||||
autoclose=0
|
||||
|
||||
[WebView]
|
||||
proxy=http://proxy.kolibrios.org:82/?site=
|
||||
@@ -192,6 +192,7 @@ nc=/kolibrios/utils/cnc_editor/cnc_editor
|
||||
ch8=/kolibrios/emul/chip8/chip8
|
||||
md=/kolibrios/emul/dgen/dgen
|
||||
gen=/kolibrios/emul/dgen/dgen
|
||||
rom=/kolibrios/emul/uxn
|
||||
|
||||
zip=$Unz
|
||||
7z=$Unz
|
||||
|
||||
@@ -9,15 +9,15 @@
|
||||
pre {white-space: pre-wrap;}
|
||||
h2 {margin-bottom:0;}
|
||||
blockquote {
|
||||
margin-bottom:0;
|
||||
border-left: 5px solid #EFE8D5;
|
||||
margin-bottom:0;
|
||||
border-left: 5px solid #EFE8D5;
|
||||
padding-left: 10px;}
|
||||
</style>
|
||||
</head>
|
||||
<body bgcolor="#FDF6E3" link="#5551FF"><pre><h1>Решение проблем и часто задаваемые вопросы</h1>
|
||||
<a href="guide.htm" param="d">< Назад</a>
|
||||
|
||||
<b>Какие есть варианты загрузки Колибри?</b>
|
||||
<b>Какие есть варианты загрузки КолибриОС?</b>
|
||||
С флешки, жесткого диска, CD, дискеты. Смотрите папку /HD_Load в скачанном дистрибутиве.
|
||||
При загрузке с флешки иногда может требоваться использование setmbr.exe, иногда нет. Вначале попробуйте загрузится без него, если не получится, то с ним.
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
2. Поменять настройки в BIOS: зайти в раздел с жесткими дисками и выставить режим совместимости с IDE или что-то похожее. (После всех эксперименов не забудьте поменять все обратно!)
|
||||
3. Воспользоваться драйвером ACHI. Для этого зайдите в SYSPANEL > <a href="/kolibrios/drivers/DRVINST.KEX">DriverInstall</a>.
|
||||
|
||||
<b>Как установить Колибри как основную ОС, скажем, на старенький ноутбук?</b>
|
||||
<b>Как установить КолибриОС как основную ОС, скажем, на старенький ноутбук?</b>
|
||||
Есть масса вариантов. Вот один из них.
|
||||
Если на ноутбуке нет ОС, то ставим на него Windows 98. Если на нем уже стоит Windows 95/98/2k/XP, то они тоже подойдут.
|
||||
Заходим в папку /HD_Load поставляемую в дистрибутиве. Там с помощью утилит устанавливаем Kolibri в дуалбут с Windows.
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
MTRRs (Memory type range registers — Диапазонные регистры типа памяти) — используются для назначения типа (политики кеширования) участкам памяти. Регистры MTRR предоставляют механизм, связывающий типы памяти с физическими адресными диапазонами системной памяти. Они позволяют процессору оптимизировать операции для разных типов памяти, таких как ПЗУ, ОЗУ, кадровый буфер и отображаемые в памяти устройства ввода-вывода. Они также упрощают разработку системного оборудования, уменьшая количество контактов управляющих памятью, которые использовались для этой цели в ранних процессорах и внешних логических устройствах.
|
||||
|
||||
<b>На каких ещё языках программирования, кроме ассемблера, можно разрабатывать приложения для Колибри?</b>
|
||||
<b>На каких ещё языках программирования, кроме ассемблера, можно разрабатывать приложения для КолибриОС?</b>
|
||||
|
||||
Портированы:
|
||||
• Компилятор Oberon-07
|
||||
@@ -68,7 +68,7 @@ MTRRs (Memory type range registers — Диапазонные регистры
|
||||
Подробная статья по поддерживаемым компиляторам и их настройке <a href="http://kolibri-n.org/inf/hll/hll">здесь</a>.
|
||||
|
||||
<b>Wi-Fi работает?</b>
|
||||
Нет ни драйверов ни подсистемы.
|
||||
Нет ни драйверов ни подсистемы.
|
||||
Если вы хотите разработать подсистему и драйвер(а) WiFi - напишите нам на форум или в группу ВК, есть возможность оплатить разработку. Для этого нужно весьма неплохо знать ассемблер.
|
||||
|
||||
<b>Не работает мышь, флешка, клавиатура</b>
|
||||
@@ -79,28 +79,28 @@ MTRRs (Memory type range registers — Диапазонные регистры
|
||||
• Использовать PS/2 мышь...
|
||||
• Купить PCI карту на несколько USB 2.0 портов, благо стоит она копейки, часто продается на барахолках
|
||||
|
||||
<b>Можно ли в Колибри запускать EXE (приложения Windows)?</b>
|
||||
<b>Можно ли в КолибриОС запускать EXE (приложения Windows)?</b>
|
||||
Нет, это невозможно.
|
||||
Есть эмулятор DOS и <a href="http://board.kolibrios.org/viewtopic.php?f=9&t=2318&p=48991">PELoad</a> эмулятор некоторых функций WIN32 (в зачаточном состоянии).
|
||||
|
||||
<b>Когда будет нормальный браузер?</b>
|
||||
Браузер штука очень сложная, как в написании, так и в портировании. Есть наработки по портированию Netsurf, но пока все заглохло.
|
||||
Что и когда будет не известно.
|
||||
Что и когда будет не известно.
|
||||
|
||||
<b>У меня есть идея, давайте я вам ее напишу, а вы реализуете!</b>
|
||||
Чаще всего эти идеи мало полезны. Дело в том, что у каждого человека уже вовлеченного в проект, тоже есть множество нереализованных идей, подчас более ценных, чем у новичков, за счет того, что участники лучше разбираются в системе, ее возможностях и ограничениях. Проблема, как всегда, или в мотивации, или в отсутствии времени. Пожалуйста, учитывайте это приходя в проект и не требуйте ничего от незнакомых вам людей. Участвуйте, как наблюдатель и комментатор; и со временем вы сможете генерировать хорошие идеи предметно.
|
||||
К сожалению даже клевая идея не гарантирует ее скорейшей реализации, потому самый надежный шанс воплотить идею в жизнь - реализовать самому.
|
||||
Чаще всего эти идеи мало полезны. Дело в том, что у каждого человека уже вовлеченного в проект, тоже есть множество нереализованных идей, подчас более ценных, чем у новичков, за счет того, что участники лучше разбираются в системе, ее возможностях и ограничениях. Проблема, как всегда, или в мотивации, или в отсутствии времени. Пожалуйста, учитывайте это приходя в проект и не требуйте ничего от незнакомых вам людей. Участвуйте, как наблюдатель и комментатор; и со временем вы сможете генерировать хорошие идеи предметно.
|
||||
К сожалению даже клевая идея не гарантирует ее скорейшей реализации, потому самый надежный шанс воплотить идею в жизнь - реализовать самому.
|
||||
|
||||
<b>Почему в Колибри все еще нет ХХХ? Это же так важно!</b>
|
||||
Потому что это ХХХ еще никто не сделал.
|
||||
<b>Почему в КолибриОС все еще нет ХХХ? Это же так важно!</b>
|
||||
Потому что это ХХХ еще никто не сделал.
|
||||
См. предыдущий ответ.
|
||||
|
||||
<b>Какие у вас дальнейшие планы развития?</b>
|
||||
Большинство путей развития упирается не в планы, а в свободные руки. Особенно в квалифицированные рабочие руки.
|
||||
|
||||
<b>Как насчет версии для ARM вместо Android?</b>
|
||||
Нативно это невозможно. Абсолютно и полностью.
|
||||
Дело в том, что Колибри ОС написана на ассемблере x86, тем самым овермаксимально оптимизирована под процессоры x86. На мобильных девайсах используется другой тип процессора и другая архитектура - arm, что делает портирование невозможным.
|
||||
Нативно это невозможно. Абсолютно и полностью.
|
||||
Дело в том, что КолибриОС написана на ассемблере x86, тем самым овермаксимально оптимизирована под процессоры x86. На мобильных девайсах используется другой тип процессора и другая архитектура - arm, что делает портирование невозможным.
|
||||
Колибри - десктопная ОС для Пека, любите ее такой, какая она есть.
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
Загрузочный сектор для ОС Колибри (FAT12, дискета)
|
||||
Загрузочный сектор для КолибриОС (FAT12, дискета)
|
||||
|
||||
- Описание
|
||||
Позволяет загружать KERNEL.MNT с дискет/образов
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
Загрузочный сектор для ОС Колибри (FAT12, дискета)
|
||||
Загрузочный сектор для КолибриОС (FAT12, дискета)
|
||||
|
||||
- Описание
|
||||
Позволяет загружать KERNEL.MNT с дискет/образов
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
Загрузочный сектор для ОС Колибри (FAT12, дискета)
|
||||
Загрузочный сектор для КолибриОС (FAT12, дискета)
|
||||
|
||||
- Описание
|
||||
Позволяет загружать KERNEL.MNT с дискет/образов
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
Загрузочный сектор для ОС Колибри (FAT12, дискета)
|
||||
Загрузочный сектор для КолибриОС (FAT12, дискета)
|
||||
|
||||
- Описание
|
||||
Позволяет загружать KERNEL.MNT с дискет/образов
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
//Copyright 2007-2025 by Veliant & Leency
|
||||
//Asper, lev, Lrz, Barsuk, Nable, hidnplayr...
|
||||
//Asper, lev, Lrz, Barsuk, Nable, hidnplayr, Burer...
|
||||
|
||||
//BUGS
|
||||
//if maximize a window on image load => crash
|
||||
//issues with a long line
|
||||
//add proxy settings
|
||||
|
||||
//===================================================//
|
||||
// //
|
||||
@@ -13,6 +12,7 @@
|
||||
//===================================================//
|
||||
|
||||
#define MEMSIZE 1024 * 160
|
||||
|
||||
#include "..\lib\gui.h"
|
||||
#include "..\lib\draw_buf.h"
|
||||
#include "..\lib\list_box.h"
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "..\lib\random.h"
|
||||
#include "..\lib\clipboard.h"
|
||||
|
||||
#include "..\lib\obj\libini.h"
|
||||
#include "..\lib\obj\box_lib.h"
|
||||
#include "..\lib\obj\libimg.h"
|
||||
#include "..\lib\obj\http.h"
|
||||
@@ -67,6 +68,10 @@ _http http = 0;
|
||||
progress_bar prbar;
|
||||
proc_info Form;
|
||||
|
||||
char settings_file[256];
|
||||
char proxy_address[768];
|
||||
|
||||
#include "settings.h"
|
||||
#include "tabs.h"
|
||||
|
||||
dword cur_img_url;
|
||||
@@ -90,6 +95,7 @@ edit_box omnibox_edit = {250, 0, 0, 0xffffff,
|
||||
|
||||
void LoadLibraries()
|
||||
{
|
||||
load_dll(libini, #lib_init,1);
|
||||
load_dll(boxlib, #box_lib_init,0);
|
||||
load_dll(libimg, #libimg_init,1);
|
||||
load_dll(libHTTP, #http_lib_init,1);
|
||||
@@ -130,6 +136,7 @@ void main()
|
||||
TOOLBAR_H = PADDING+TSZE+PADDING+2;
|
||||
|
||||
LoadLibraries();
|
||||
LoadIniConfig();
|
||||
HandleParam();
|
||||
|
||||
omnibox_edit.left = PADDING+TSZE*2+PADDING+6;
|
||||
@@ -517,14 +524,17 @@ bool GetLocalFileData(dword _path)
|
||||
bool GetUrl(dword _http_url)
|
||||
{
|
||||
char new_url_full[URL_SIZE+1];
|
||||
if (!strncmp(_http_url,"http:",5)) {
|
||||
if (!strncmp(_http_url,"http://",7)) {
|
||||
http.get(_http_url);
|
||||
return true;
|
||||
} else if (!strncmp(_http_url,"https://",8)) {
|
||||
strcpy(#new_url_full, "http://gate.aspero.pro/?site=");
|
||||
strncat(#new_url_full, _http_url, URL_SIZE);
|
||||
http.get(#new_url_full);
|
||||
return true;
|
||||
if (#proxy_address) {
|
||||
strcpy(#new_url_full, #proxy_address);
|
||||
strncat(#new_url_full, _http_url, URL_SIZE);
|
||||
http.get(#new_url_full);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ Copy link
|
||||
Download link contents";
|
||||
char loading_text[] = "Loading...";
|
||||
char update_param[] = "-e http://builds.kolibrios.org/en_US/data/programs/cmm/browser/WebView.com";
|
||||
char update_download_error[] = "'WebView\nError receiving an up to date information!' -tE";
|
||||
char update_download_error[] = "'WebView\nError receiving update information!' -tE";
|
||||
char update_ok[] = "'WebView\nThe browser has been updated!' -tO";
|
||||
char update_is_current[] = "'WebView\nThe browser is up to date.' -tI";
|
||||
char update_can_not_copy[] = "'WebView\nError copying a new version from Downloads folder!\nProbably too litle space on Ramdisk.' -tE";
|
||||
@@ -112,4 +112,4 @@ char editbox_icons[] = FROM "res/editbox_icons.raw";
|
||||
|
||||
#define DEFAULT_URL URL_SERVICE_HOMEPAGE
|
||||
|
||||
char version[]="WebView 3.91";
|
||||
char version[]="WebView 3.92";
|
||||
@@ -14,7 +14,7 @@
|
||||
| || | | |
|
||||
\_____||__|________|__|<font color=#DDD>lc</font>
|
||||
|
||||
<font bg=#F8F15B> web <font bg=#FF5A7E color=#fff> 1.0 <font bg=#47D018> compatable
|
||||
<font bg=#F8F15B> web <font bg=#FF5A7E color=#fff> 1.0 <font bg=#47D018> compatible
|
||||
<font bg=#3CE7FF> </font></font></font></font>
|
||||
<td>
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
|
||||
By the way,
|
||||
<font color="#555555">• You can check for browser updates from the main menu.
|
||||
• To run a web search, type a text in the adress box and press Ctrl+Enter.
|
||||
• Pressing F6 moves a text cursor to the omnibox.
|
||||
• You can manually change the encoding of a page by clicking on a label in the bottom right corner.
|
||||
• To run a web search, type text in the address box and press Ctrl+Enter.
|
||||
• Pressing F6 moves the text cursor to the omnibox.
|
||||
• You can manually change the encoding of a page by clicking on the label in the bottom right corner.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
<h1> Webpage Not Available</h1>
|
||||
<h2> What could be done:</h2>
|
||||
<ul>
|
||||
<li>Make sure that evetything fine with Internet connection.<br>
|
||||
<li>Make sure that you have a working Internet connection.<br>
|
||||
Open <a href="/sys/network/netcfg">Netcfg</a> network diagnostic tool.<br>
|
||||
<li>Check page address, there may have been made a typo.<br>
|
||||
<li>Check the page address for any typos.<br>
|
||||
<li>Server is temporarily unavailable.<br>
|
||||
Refresh the page.<br>
|
||||
<li>Browser doesn't handled properly server's response.<br>
|
||||
<li>Browser didn't properly handle the server's response.<br>
|
||||
Please, report an error.<br>
|
||||
</ul>
|
||||
|
||||
9
programs/cmm/browser/settings.h
Normal file
9
programs/cmm/browser/settings.h
Normal file
@@ -0,0 +1,9 @@
|
||||
_ini ini;
|
||||
|
||||
void LoadIniConfig()
|
||||
{
|
||||
ini.path = GetIni(#settings_file, "app.ini");
|
||||
ini.section = "WebView";
|
||||
|
||||
ini.GetString("proxy", #proxy_address, sizeof(proxy_address), NULL);
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
//Copyright 2020 - 2025 by Leency
|
||||
//Burer...
|
||||
|
||||
#define MEMSIZE 1024 * 40
|
||||
//Copyright 2020 - 2021 by Leency
|
||||
|
||||
#include "../lib/gui.h"
|
||||
#include "../lib/random.h"
|
||||
|
||||
#include "../lib/obj/libini.h"
|
||||
#include "../lib/obj/box_lib.h"
|
||||
#include "../lib/obj/http.h"
|
||||
|
||||
@@ -21,6 +26,11 @@ char uEdit[URL_SIZE];
|
||||
char filepath[4096];
|
||||
char save_dir[4096];
|
||||
|
||||
char settings_file[256];
|
||||
char proxy_address[768];
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
char* active_status;
|
||||
|
||||
edit_box ed = {WIN_W-GAPX-GAPX,GAPX,20,0xffffff,0x94AECE,0xffffff,0xffffff,
|
||||
@@ -32,9 +42,13 @@ progress_bar pb = {0, GAPX, 52, WIN_W - GAPX - GAPX, 17, 0, NULL, NULL,
|
||||
void main()
|
||||
{
|
||||
dword shared_url;
|
||||
|
||||
load_dll(libini, #lib_init,1);
|
||||
load_dll(boxlib, #box_lib_init,0);
|
||||
load_dll(libHTTP, #http_lib_init,1);
|
||||
|
||||
LoadIniConfig();
|
||||
|
||||
strcpy(#save_dir, DEFAULT_SAVE_DIR);
|
||||
if (!dir_exists(#save_dir)) CreateDir(#save_dir);
|
||||
SetCurDir(#save_dir);
|
||||
@@ -167,10 +181,8 @@ void StartDownloading()
|
||||
if (http.transfer > 0) return;
|
||||
ResetDownloadSpeed();
|
||||
pb.back_color = 0xFFFfff;
|
||||
if (!strncmp(#uEdit,"https:",6)) {
|
||||
//miniprintf(#get_url, "http://gate.aspero.pro/?site=%s", #uEdit);
|
||||
notify("'HTTPS for download temporary is not supported,\ntrying to download the file via HTTP' -W");
|
||||
miniprintf(#uEdit, "http://%s", #uEdit+8);
|
||||
if (!strncmp(#uEdit,"https://",8)) {
|
||||
miniprintf(#get_url, "%s%s", #proxy_address, #uEdit);
|
||||
}
|
||||
strcpy(#get_url, #uEdit);
|
||||
|
||||
|
||||
9
programs/cmm/downloader/settings.h
Normal file
9
programs/cmm/downloader/settings.h
Normal file
@@ -0,0 +1,9 @@
|
||||
_ini ini;
|
||||
|
||||
void LoadIniConfig()
|
||||
{
|
||||
ini.path = GetIni(#settings_file, "app.ini");
|
||||
ini.section = "WebView";
|
||||
|
||||
ini.GetString("proxy", #proxy_address, sizeof(proxy_address), NULL);
|
||||
}
|
||||
@@ -112,7 +112,6 @@ struct _http
|
||||
dword _http::get(dword _url)
|
||||
{
|
||||
cur_url = _url;
|
||||
if (streqrp(cur_url, "http://gate.aspero.pro/?site=")) cur_url += 29;
|
||||
http_get stdcall (_url, 0, 0, #accept_language);
|
||||
transfer = EAX;
|
||||
return EAX;
|
||||
@@ -138,7 +137,7 @@ bool _http::stop()
|
||||
transfer=0;
|
||||
*/
|
||||
hfree();
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
if not exist bin mkdir bin
|
||||
@erase lang.inc
|
||||
@echo lang fix en_US >lang.inc
|
||||
@copy objects.png bin\objects.png
|
||||
if not exist bin\info3ds.ini @copy info3ds.ini bin\info3ds.ini
|
||||
if not exist bin\toolbar.png @copy toolbar.png bin\toolbar.png
|
||||
if not exist bin\font8x9.bmp @copy ..\..\fs\kfar\trunk\font8x9.bmp bin\font8x9.bmp
|
||||
@fasm.exe -m 16384 info3ds.asm bin\info3ds.kex
|
||||
@kpack bin\info3ds.kex
|
||||
@fasm.exe -m 16384 info3ds_u.asm bin\info3ds_u.kex
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
if not exist bin mkdir bin
|
||||
@erase lang.inc
|
||||
@echo lang fix ru_RU >lang.inc
|
||||
@copy objects.png bin\objects.png
|
||||
if not exist bin\info3ds.ini @copy info3ds.ini bin\info3ds.ini
|
||||
if not exist bin\toolbar.png @copy toolbar.png bin\toolbar.png
|
||||
if not exist bin\font8x9.bmp @copy ..\..\fs\kfar\trunk\font8x9.bmp bin\font8x9.bmp
|
||||
@fasm.exe -m 16384 info3ds.asm bin\info3ds.kex
|
||||
@kpack bin\info3ds.kex
|
||||
@fasm.exe -m 16384 info3ds_u.asm bin\info3ds_u.kex
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
; SPDX-License-Identifier: GPL-2.0-only
|
||||
; Info3ds - is a program for viewing the structure of *.3ds files
|
||||
; Copyright (C) 2011-2025 KolibriOS team
|
||||
|
||||
use32
|
||||
org 0
|
||||
db 'MENUET01' ;¨¤¥â¨ä. ¨á¯®«ï¥¬®£® ä ©« ¢á¥£¤ 8 ¡ ©â
|
||||
db 'MENUET01'
|
||||
dd 1, start, i_end, mem, stacktop, file_name, sys_path
|
||||
|
||||
version_edit equ 1
|
||||
@@ -22,36 +26,34 @@ include 'convert_stl_3ds.inc'
|
||||
|
||||
@use_library mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
|
||||
|
||||
ID_ICON_CHUNK_MAIN equ 0 ;¨ª®ª £« ¢®£® ¡«®ª
|
||||
ID_ICON_CHUNK_NOT_FOUND equ 1 ;¨ª®ª ¥ ¨§¢¥á⮣® ¡«®ª
|
||||
ID_ICON_DATA equ 2 ;¨ª®ª ¤«ï ¤ ëå ¡«®ª , ¥ ®¯à¥¤¥«¥®© áâàãªâãàë
|
||||
ID_ICON_CHUNK_MAIN equ 0 ;main block icon
|
||||
ID_ICON_CHUNK_NOT_FOUND equ 1 ;unknown block icon
|
||||
ID_ICON_DATA equ 2 ;icon for block data, undefined structure
|
||||
ID_ICON_POINT equ 8
|
||||
ID_ICON_POINT_SEL equ 9
|
||||
|
||||
FILE_ERROR_CHUNK_SIZE equ -3 ;®è¨¡ª ¢ à §¬¥à¥ ¡«®ª
|
||||
FILE_ERROR_CHUNK_SIZE equ -3 ;block size error
|
||||
|
||||
include 'info_o3d.inc'
|
||||
|
||||
main_wnd_height equ 460 ;¢ëá®â £« ¢®£® ®ª ¯à®£à ¬¬ë
|
||||
main_wnd_height equ 460 ;height of the main program window
|
||||
IMAGE_TOOLBAR_ICON_SIZE equ 21*21*3
|
||||
|
||||
align 4
|
||||
fl255 dd 255.0
|
||||
open_file_data dd 0 ;㪠§ â¥«ì ¯ ¬ïâì ¤«ï ®âªàëâ¨ï ä ©«®¢ 3ds
|
||||
open_file_size dd 0 ;à §¬¥à ®âªàë⮣® ä ©«
|
||||
open_file_data dd 0 ;pointer to memory for opening 3ds files
|
||||
open_file_size dd 0
|
||||
image_data_toolbar dd 0
|
||||
icon_tl_sys dd 0 ;㪠§ ⥥«ì ¯ ¬ïâì ¤«ï åà ¥¨ï á¨á⥬ëå ¨ª®®ª
|
||||
icon_toolbar dd 0 ;㪠§ ⥥«ì ¯ ¬ïâì ¤«ï åà ¥¨ï ¨ª®®ª ®¡ê¥ªâ®¢
|
||||
fn_toolbar db 'toolbar.png',0
|
||||
icon_tl_sys dd 0 ;pointer to memory for storing system icons
|
||||
icon_toolbar dd 0 ;pointer to memory for storing object icons
|
||||
|
||||
align 4
|
||||
level_stack dd 0
|
||||
offs_last_timer dd 0 ;¯®á«¥¤¨© ᤢ¨£ ¯®ª § ë© ¢ äãªæ¨¨ â ©¬¥à
|
||||
offs_last_timer dd 0 ;last shift shown in timer function
|
||||
|
||||
align 4
|
||||
file_3ds: ;¯¥à¥¬¥ë¥ ¨á¯®«ì§ã¥¬ë¥ ¯à¨ ®âªàë⨨ ä ©«
|
||||
.offs: dd 0 ;+0 㪠§ ⥫ì ç «® ¡«®ª
|
||||
.size: dd 0 ;+4 à §¬¥à ¡«®ª (¤«ï 1-£® ¯ à ¬¥âà = à §¬¥à ä ©« 3ds)
|
||||
file_3ds: ;variables used when opening a file
|
||||
.offs: dd 0 ;+0 pointer to the beginning of the block
|
||||
.size: dd 0 ;+4 block size (for 1st parameter = 3ds file size)
|
||||
rb 8*MAX_FILE_LEVEL
|
||||
|
||||
size_one_list equ 42
|
||||
@@ -81,7 +83,7 @@ start:
|
||||
stosd
|
||||
|
||||
load_libraries l_libs_start,l_libs_end
|
||||
;¯à®¢¥àª ᪮«ìª® ã¤ ç® § £ã§¨«¨áì ¡¨¡«¨®â¥ª¨
|
||||
;checking how successfully the libraries were loaded
|
||||
mov ebp,lib_0
|
||||
.test_lib_open:
|
||||
cmp dword [ebp+ll_struc_size-4],0
|
||||
@@ -94,7 +96,7 @@ start:
|
||||
mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors
|
||||
mcall SF_SET_EVENTS_MASK,0xC0000027
|
||||
|
||||
stdcall [OpenDialog_Init],OpenDialog_data ;¯®¤£®â®¢ª ¤¨ «®£
|
||||
stdcall [OpenDialog_Init],OpenDialog_data ;preparation of dialogue
|
||||
|
||||
;kmenu initialisation
|
||||
stdcall [kmenu_init],sc
|
||||
@@ -143,70 +145,68 @@ start:
|
||||
stdcall [tl_data_init], tree1
|
||||
;á¨áâ¥¬ë¥ ¨ª®ª¨ 16*16 ¤«ï tree_list
|
||||
include_image_file 'tl_sys_16.png', icon_tl_sys
|
||||
;¥á«¨ ¨§®¡à ¦¥¨¥ ¥ ®âªàë«®áì, â® ¢ icon_tl_sys ¡ã¤ãâ
|
||||
;¥ ¨¨æ¨ «¨§¨à®¢ ë¥ ¤ ë¥, ® ®è¨¡ª¨ ¥ ¡ã¤¥â, â. ª. ¡ãä¥à 㦮£® à §¬¥à
|
||||
mov eax,dword[icon_tl_sys]
|
||||
mov dword[tree1.data_img_sys],eax
|
||||
mov eax,[icon_tl_sys]
|
||||
mov [tree1.data_img_sys],eax
|
||||
|
||||
load_image_file 'objects.png', icon_toolbar
|
||||
mov eax,dword[icon_toolbar]
|
||||
mov dword[tree1.data_img],eax
|
||||
include_image_file 'objects.png', icon_toolbar
|
||||
mov eax,[icon_toolbar]
|
||||
mov [tree1.data_img],eax
|
||||
|
||||
stdcall [buf2d_create], buf_0 ;á®§¤ ¨¥ ¡ãä¥à
|
||||
|
||||
load_image_file 'font8x9.bmp', image_data_toolbar
|
||||
include_image_file '../../fs/kfar/trunk/font8x9.bmp', image_data_toolbar
|
||||
stdcall [buf2d_create_f_img], buf_1,[image_data_toolbar] ;á®§¤ ¥¬ ¡ãä¥à
|
||||
stdcall mem.Free,[image_data_toolbar] ;®á¢®¡®¦¤ ¥¬ ¯ ¬ïâì
|
||||
stdcall [buf2d_conv_24_to_8], buf_1,1 ;¤¥« ¥¬ ¡ãä¥à ¯à®§à ç®á⨠8 ¡¨â
|
||||
stdcall [buf2d_convert_text_matrix], buf_1
|
||||
|
||||
load_image_file fn_toolbar, image_data_toolbar
|
||||
include_image_file 'toolbar.png', image_data_toolbar
|
||||
|
||||
;à ¡®â á ä ©«®¬ áâ஥ª
|
||||
copy_path ini_name,sys_path,file_name,0
|
||||
mov dword[def_dr_mode],0
|
||||
stdcall dword[ini_get_int],file_name,ini_sec_w3d,key_dv,1
|
||||
stdcall [ini_get_int],file_name,ini_sec_w3d,key_dv,1
|
||||
or eax,eax
|
||||
jz @f
|
||||
or dword[def_dr_mode], 1 shl bit_vertexes
|
||||
@@:
|
||||
stdcall dword[ini_get_int],file_name,ini_sec_w3d,key_df,1
|
||||
stdcall [ini_get_int],file_name,ini_sec_w3d,key_df,1
|
||||
or eax,eax
|
||||
jz @f
|
||||
or dword[def_dr_mode], 1 shl bit_faces
|
||||
@@:
|
||||
stdcall dword[ini_get_int],file_name,ini_sec_w3d,key_dff,1
|
||||
stdcall [ini_get_int],file_name,ini_sec_w3d,key_dff,1
|
||||
or eax,eax
|
||||
jz @f
|
||||
or dword[def_dr_mode], 1 shl bit_faces_fill
|
||||
@@:
|
||||
stdcall dword[ini_get_int],file_name,ini_sec_w3d,key_dl,1
|
||||
stdcall [ini_get_int],file_name,ini_sec_w3d,key_dl,1
|
||||
or eax,eax
|
||||
jz @f
|
||||
or dword[def_dr_mode], 1 shl bit_light
|
||||
@@:
|
||||
stdcall dword[ini_get_int],file_name,ini_sec_w3d,key_ds,1
|
||||
stdcall [ini_get_int],file_name,ini_sec_w3d,key_ds,1
|
||||
or eax,eax
|
||||
jz @f
|
||||
or dword[def_dr_mode], 1 shl bit_smooth
|
||||
@@:
|
||||
stdcall dword[ini_get_color],file_name,ini_sec_w3d,key_ox,0x0000ff
|
||||
stdcall [ini_get_color],file_name,ini_sec_w3d,key_ox,0x0000ff
|
||||
mov [color_ox],eax
|
||||
stdcall dword[ini_get_color],file_name,ini_sec_w3d,key_oy,0xff0000
|
||||
stdcall [ini_get_color],file_name,ini_sec_w3d,key_oy,0xff0000
|
||||
mov [color_oy],eax
|
||||
stdcall dword[ini_get_color],file_name,ini_sec_w3d,key_oz,0x00ff00
|
||||
stdcall [ini_get_color],file_name,ini_sec_w3d,key_oz,0x00ff00
|
||||
mov [color_oz],eax
|
||||
stdcall dword[ini_get_color],file_name,ini_sec_w3d,key_bk,0x000000
|
||||
stdcall [ini_get_color],file_name,ini_sec_w3d,key_bk,0x000000
|
||||
mov [color_bk],eax
|
||||
shr eax,8
|
||||
mov [color_bk+4],eax
|
||||
shr eax,8
|
||||
mov [color_bk+8],eax
|
||||
stdcall dword[ini_get_color],file_name,ini_sec_w3d,key_vert,0xffffff
|
||||
stdcall [ini_get_color],file_name,ini_sec_w3d,key_vert,0xffffff
|
||||
mov [color_vert],eax
|
||||
stdcall dword[ini_get_color],file_name,ini_sec_w3d,key_face,0x808080
|
||||
stdcall [ini_get_color],file_name,ini_sec_w3d,key_face,0x808080
|
||||
mov [color_face],eax
|
||||
stdcall dword[ini_get_color],file_name,ini_sec_w3d,key_select,0xffff00
|
||||
stdcall [ini_get_color],file_name,ini_sec_w3d,key_select,0xffff00
|
||||
mov [color_select],eax
|
||||
finit
|
||||
fild dword[color_bk+8]
|
||||
@@ -262,19 +262,19 @@ still:
|
||||
or eax,eax
|
||||
jz timer_funct
|
||||
|
||||
cmp al,1
|
||||
cmp al,EV_REDRAW
|
||||
jne @f
|
||||
call draw_window
|
||||
jmp still
|
||||
@@:
|
||||
cmp al,2
|
||||
cmp al,EV_KEY
|
||||
jz key
|
||||
cmp al,3
|
||||
cmp al,EV_BUTTON
|
||||
jz button
|
||||
cmp al,6
|
||||
cmp al,EV_MOUSE
|
||||
jne @f
|
||||
mcall SF_THREAD_INFO,procinfo,-1
|
||||
cmp ax,word[procinfo+4]
|
||||
cmp ax,word[procinfo.window_stack_position]
|
||||
jne @f ;®ª® ¥ ªâ¨¢®
|
||||
call mouse
|
||||
@@:
|
||||
@@ -282,7 +282,7 @@ still:
|
||||
|
||||
align 4
|
||||
mouse:
|
||||
stdcall [tl_mouse], dword tree1
|
||||
stdcall [tl_mouse], tree1
|
||||
ret
|
||||
|
||||
align 4
|
||||
@@ -385,7 +385,7 @@ pushad
|
||||
mcall , (20 shl 16)+560, (20 shl 16)+main_wnd_height
|
||||
|
||||
mcall SF_THREAD_INFO,procinfo,-1
|
||||
mov eax,dword[procinfo.box.height]
|
||||
mov eax,[procinfo.box.height]
|
||||
cmp eax,250
|
||||
jge @f
|
||||
mov eax,250
|
||||
@@ -393,13 +393,14 @@ pushad
|
||||
sub eax,65
|
||||
mov dword[tree1.box_height],eax
|
||||
mov word[w_scr_t1.y_size],ax ;®¢ë¥ à §¬¥àë áªà®««¨£
|
||||
cmp eax,dword[buf_0.h] ;㢥«¨ç¨¢ ¥¬ ¢ëá®âã ¡ãä¥à
|
||||
jle @f
|
||||
cmp eax,dword[buf_0.h] ;change buffer height
|
||||
je @f
|
||||
stdcall [buf2d_resize],buf_0,0,eax,1
|
||||
mov dword[offs_last_timer],0 ;¤«ï ®¡®¢«¥¨ï ¡ãä¥à ¢ â ©¬¥à¥
|
||||
stdcall [buf2d_clear], buf_0, [buf_0.color] ;background update
|
||||
mov dword[offs_last_timer],0 ;for update buffer in the timer
|
||||
@@:
|
||||
|
||||
mov eax,dword[procinfo.box.width]
|
||||
mov eax,[procinfo.box.width]
|
||||
cmp eax,400
|
||||
jge @f
|
||||
mov eax,400
|
||||
@@ -457,7 +458,7 @@ popad
|
||||
align 4
|
||||
key:
|
||||
mcall SF_GET_KEY
|
||||
stdcall [tl_key], dword tree1
|
||||
stdcall [tl_key], tree1
|
||||
jmp still
|
||||
|
||||
|
||||
@@ -1087,53 +1088,6 @@ l_libs_start:
|
||||
lib_6 l_libs lib_name_6, file_name, system_dir_6, import_libini
|
||||
l_libs_end:
|
||||
|
||||
align 4
|
||||
import_libimg:
|
||||
dd alib_init1
|
||||
img_is_img dd aimg_is_img
|
||||
img_info dd aimg_info
|
||||
img_from_file dd aimg_from_file
|
||||
img_to_file dd aimg_to_file
|
||||
img_from_rgb dd aimg_from_rgb
|
||||
img_to_rgb dd aimg_to_rgb
|
||||
img_to_rgb2 dd aimg_to_rgb2
|
||||
img_decode dd aimg_decode
|
||||
img_encode dd aimg_encode
|
||||
img_create dd aimg_create
|
||||
img_destroy dd aimg_destroy
|
||||
img_destroy_layer dd aimg_destroy_layer
|
||||
img_count dd aimg_count
|
||||
img_lock_bits dd aimg_lock_bits
|
||||
img_unlock_bits dd aimg_unlock_bits
|
||||
img_flip dd aimg_flip
|
||||
img_flip_layer dd aimg_flip_layer
|
||||
img_rotate dd aimg_rotate
|
||||
img_rotate_layer dd aimg_rotate_layer
|
||||
img_draw dd aimg_draw
|
||||
|
||||
dd 0,0
|
||||
alib_init1 db 'lib_init',0
|
||||
aimg_is_img db 'img_is_img',0 ;®¯à¥¤¥«ï¥â ¯® ¤ ë¬, ¬®¦¥â «¨ ¡¨¡«¨®â¥ª ᤥ« âì ¨§ ¨å ¨§®¡à ¦¥¨¥
|
||||
aimg_info db 'img_info',0
|
||||
aimg_from_file db 'img_from_file',0
|
||||
aimg_to_file db 'img_to_file',0
|
||||
aimg_from_rgb db 'img_from_rgb',0
|
||||
aimg_to_rgb db 'img_to_rgb',0 ;¯à¥®¡à §®¢ ¨¥ ¨§®¡à ¦¥¨ï ¢ ¤ ë¥ RGB
|
||||
aimg_to_rgb2 db 'img_to_rgb2',0
|
||||
aimg_decode db 'img_decode',0 ; ¢â®¬ â¨ç¥áª¨ ®¯à¥¤¥«ï¥â ä®à¬ â £à ä¨ç¥áª¨å ¤ ëå
|
||||
aimg_encode db 'img_encode',0
|
||||
aimg_create db 'img_create',0
|
||||
aimg_destroy db 'img_destroy',0
|
||||
aimg_destroy_layer db 'img_destroy_layer',0
|
||||
aimg_count db 'img_count',0
|
||||
aimg_lock_bits db 'img_lock_bits',0
|
||||
aimg_unlock_bits db 'img_unlock_bits',0
|
||||
aimg_flip db 'img_flip',0
|
||||
aimg_flip_layer db 'img_flip_layer',0
|
||||
aimg_rotate db 'img_rotate',0
|
||||
aimg_rotate_layer db 'img_rotate_layer',0
|
||||
aimg_draw db 'img_draw',0
|
||||
|
||||
align 4
|
||||
import_proclib:
|
||||
OpenDialog_Init dd aOpenDialog_Init
|
||||
@@ -1146,122 +1100,9 @@ dd 0,0
|
||||
aOpenDialog_Set_file_name db 'OpenDialog_set_file_name',0
|
||||
aOpenDialog_Set_file_ext db 'OpenDialog_set_file_ext',0
|
||||
|
||||
align 4
|
||||
import_buf2d:
|
||||
dd sz_init0
|
||||
buf2d_create dd sz_buf2d_create
|
||||
buf2d_create_f_img dd sz_buf2d_create_f_img
|
||||
buf2d_clear dd sz_buf2d_clear
|
||||
buf2d_draw dd sz_buf2d_draw
|
||||
buf2d_delete dd sz_buf2d_delete
|
||||
buf2d_resize dd sz_buf2d_resize
|
||||
buf2d_line dd sz_buf2d_line
|
||||
buf2d_rect_by_size dd sz_buf2d_rect_by_size
|
||||
buf2d_filled_rect_by_size dd sz_buf2d_filled_rect_by_size
|
||||
buf2d_circle dd sz_buf2d_circle
|
||||
buf2d_img_hdiv2 dd sz_buf2d_img_hdiv2
|
||||
buf2d_img_wdiv2 dd sz_buf2d_img_wdiv2
|
||||
buf2d_conv_24_to_8 dd sz_buf2d_conv_24_to_8
|
||||
buf2d_conv_24_to_32 dd sz_buf2d_conv_24_to_32
|
||||
buf2d_bit_blt dd sz_buf2d_bit_blt
|
||||
buf2d_bit_blt_transp dd sz_buf2d_bit_blt_transp
|
||||
buf2d_bit_blt_alpha dd sz_buf2d_bit_blt_alpha
|
||||
buf2d_convert_text_matrix dd sz_buf2d_convert_text_matrix
|
||||
buf2d_draw_text dd sz_buf2d_draw_text
|
||||
buf2d_crop_color dd sz_buf2d_crop_color
|
||||
buf2d_offset_h dd sz_buf2d_offset_h
|
||||
buf2d_set_pixel dd sz_buf2d_set_pixel
|
||||
dd 0,0
|
||||
sz_init0 db 'lib_init',0
|
||||
sz_buf2d_create db 'buf2d_create',0
|
||||
sz_buf2d_create_f_img db 'buf2d_create_f_img',0
|
||||
sz_buf2d_clear db 'buf2d_clear',0
|
||||
sz_buf2d_draw db 'buf2d_draw',0
|
||||
sz_buf2d_delete db 'buf2d_delete',0
|
||||
sz_buf2d_resize db 'buf2d_resize',0
|
||||
sz_buf2d_line db 'buf2d_line',0
|
||||
sz_buf2d_rect_by_size db 'buf2d_rect_by_size',0
|
||||
sz_buf2d_filled_rect_by_size db 'buf2d_filled_rect_by_size',0
|
||||
sz_buf2d_circle db 'buf2d_circle',0
|
||||
sz_buf2d_img_hdiv2 db 'buf2d_img_hdiv2',0
|
||||
sz_buf2d_img_wdiv2 db 'buf2d_img_wdiv2',0
|
||||
sz_buf2d_conv_24_to_8 db 'buf2d_conv_24_to_8',0
|
||||
sz_buf2d_conv_24_to_32 db 'buf2d_conv_24_to_32',0
|
||||
sz_buf2d_bit_blt db 'buf2d_bit_blt',0
|
||||
sz_buf2d_bit_blt_transp db 'buf2d_bit_blt_transp',0
|
||||
sz_buf2d_bit_blt_alpha db 'buf2d_bit_blt_alpha',0
|
||||
sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0
|
||||
sz_buf2d_draw_text db 'buf2d_draw_text',0
|
||||
sz_buf2d_crop_color db 'buf2d_crop_color',0
|
||||
sz_buf2d_offset_h db 'buf2d_offset_h',0
|
||||
sz_buf2d_set_pixel db 'buf2d_set_pixel',0
|
||||
|
||||
align 4
|
||||
import_box_lib:
|
||||
dd sz_init1
|
||||
edit_box_draw dd sz_edit_box_draw
|
||||
edit_box_key dd sz_edit_box_key
|
||||
edit_box_mouse dd sz_edit_box_mouse
|
||||
edit_box_set_text dd sz_edit_box_set_text
|
||||
scrollbar_ver_draw dd sz_scrollbar_ver_draw
|
||||
scrollbar_hor_draw dd sz_scrollbar_hor_draw
|
||||
|
||||
tl_data_init dd sz_tl_data_init
|
||||
tl_data_clear dd sz_tl_data_clear
|
||||
tl_info_clear dd sz_tl_info_clear
|
||||
tl_key dd sz_tl_key
|
||||
tl_mouse dd sz_tl_mouse
|
||||
tl_draw dd sz_tl_draw
|
||||
tl_info_undo dd sz_tl_info_undo
|
||||
tl_info_redo dd sz_tl_info_redo
|
||||
tl_node_add dd sz_tl_node_add
|
||||
tl_node_set_data dd sz_tl_node_set_data
|
||||
tl_node_get_data dd sz_tl_node_get_data
|
||||
tl_node_delete dd sz_tl_node_delete
|
||||
tl_node_move_up dd sz_tl_node_move_up
|
||||
tl_node_move_down dd sz_tl_node_move_down
|
||||
tl_cur_beg dd sz_tl_cur_beg
|
||||
tl_cur_next dd sz_tl_cur_next
|
||||
tl_cur_perv dd sz_tl_cur_perv
|
||||
tl_node_close_open dd sz_tl_node_close_open
|
||||
tl_node_lev_inc dd sz_tl_node_lev_inc
|
||||
tl_node_lev_dec dd sz_tl_node_lev_dec
|
||||
tl_node_poi_get_info dd sz_tl_node_poi_get_info
|
||||
tl_node_poi_get_next_info dd sz_tl_node_poi_get_next_info
|
||||
tl_node_poi_get_data dd sz_tl_node_poi_get_data
|
||||
|
||||
dd 0,0
|
||||
sz_init1 db 'lib_init',0
|
||||
sz_edit_box_draw db 'edit_box_draw',0
|
||||
sz_edit_box_key db 'edit_box_key',0
|
||||
sz_edit_box_mouse db 'edit_box_mouse',0
|
||||
sz_edit_box_set_text db 'edit_box_set_text',0
|
||||
sz_scrollbar_ver_draw db 'scrollbar_v_draw',0
|
||||
sz_scrollbar_hor_draw db 'scrollbar_h_draw',0
|
||||
|
||||
sz_tl_data_init db 'tl_data_init',0
|
||||
sz_tl_data_clear db 'tl_data_clear',0
|
||||
sz_tl_info_clear db 'tl_info_clear',0
|
||||
sz_tl_key db 'tl_key',0
|
||||
sz_tl_mouse db 'tl_mouse',0
|
||||
sz_tl_draw db 'tl_draw',0
|
||||
sz_tl_info_undo db 'tl_info_undo',0
|
||||
sz_tl_info_redo db 'tl_info_redo',0
|
||||
sz_tl_node_add db 'tl_node_add',0
|
||||
sz_tl_node_set_data db 'tl_node_set_data',0
|
||||
sz_tl_node_get_data db 'tl_node_get_data',0
|
||||
sz_tl_node_delete db 'tl_node_delete',0
|
||||
sz_tl_node_move_up db 'tl_node_move_up',0
|
||||
sz_tl_node_move_down db 'tl_node_move_down',0
|
||||
sz_tl_cur_beg db 'tl_cur_beg',0
|
||||
sz_tl_cur_next db 'tl_cur_next',0
|
||||
sz_tl_cur_perv db 'tl_cur_perv',0
|
||||
sz_tl_node_close_open db 'tl_node_close_open',0
|
||||
sz_tl_node_lev_inc db 'tl_node_lev_inc',0
|
||||
sz_tl_node_lev_dec db 'tl_node_lev_dec',0
|
||||
sz_tl_node_poi_get_info db 'tl_node_poi_get_info',0
|
||||
sz_tl_node_poi_get_next_info db 'tl_node_poi_get_next_info',0
|
||||
sz_tl_node_poi_get_data db 'tl_node_poi_get_data',0
|
||||
include '../../develop/libraries/libs-dev/libimg/import.inc'
|
||||
include '../../develop/libraries/box_lib/import.inc'
|
||||
include '../../develop/libraries/buf2d/import.inc'
|
||||
|
||||
align 4
|
||||
import_libkmenu:
|
||||
@@ -1287,23 +1128,7 @@ dd 0,0
|
||||
akmenuitem_delete db 'kmenuitem_delete',0
|
||||
akmenuitem_draw db 'kmenuitem_draw',0
|
||||
|
||||
align 4
|
||||
import_tinygl:
|
||||
macro E_LIB n
|
||||
{
|
||||
if defined sz_#n
|
||||
n dd sz_#n
|
||||
end if
|
||||
}
|
||||
include '../../develop/libraries/TinyGL/asm_fork/export.inc'
|
||||
dd 0,0
|
||||
macro E_LIB n
|
||||
{
|
||||
if used n
|
||||
sz_#n db `n,0
|
||||
end if
|
||||
}
|
||||
include '../../develop/libraries/TinyGL/asm_fork/export.inc'
|
||||
include '../../develop/libraries/TinyGL/asm_fork/import.inc'
|
||||
|
||||
align 4
|
||||
import_libini:
|
||||
@@ -1367,9 +1192,9 @@ white_light dd 0.8, 0.8, 0.8, 1.0 ;
|
||||
lmodel_ambient dd 0.3, 0.3, 0.3, 1.0 ; <20> à ¬¥âàë ä®®¢®£® ®á¢¥é¥¨ï
|
||||
|
||||
if lang eq ru_RU
|
||||
capt db 'info 3ds ¢¥àá¨ï 04.05.25',0 ;¯®¤¯¨áì ®ª
|
||||
capt db 'info 3ds ¢¥àá¨ï 22.10.25',0
|
||||
else ; Default to en_US
|
||||
capt db 'info 3ds version 04.05.25',0 ;window caption
|
||||
capt db 'info 3ds version 22.10.25',0 ;window caption
|
||||
end if
|
||||
|
||||
align 16
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
; SPDX-License-Identifier: GPL-2.0-only
|
||||
; Info3ds_u - is a program for viewing the structure of *.3ds files
|
||||
; Copyright (C) 2015-2025 KolibriOS team
|
||||
|
||||
use32
|
||||
org 0
|
||||
db 'MENUET01' ;¨¤¥â¨ä. ¨á¯®«ï¥¬®£® ä ©« ¢á¥£¤ 8 ¡ ©â
|
||||
@@ -12,6 +16,7 @@ include '../../develop/libraries/libs-dev/libimg/libimg.inc'
|
||||
include '../../load_img.inc'
|
||||
include '../../load_lib.mac'
|
||||
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
|
||||
include '../../develop/libraries/TinyGL/asm_fork/kosgl.inc'
|
||||
include '../../develop/libraries/TinyGL/asm_fork/opengl_const.inc'
|
||||
include 'lang.inc' ; Language support for locales: ru_RU (CP866), en_US.
|
||||
include 'info_fun_float.inc'
|
||||
@@ -21,8 +26,8 @@ include 'convert_stl_3ds.inc'
|
||||
|
||||
3d_wnd_l equ 205 ;®âáâ㯠¤«ï tinygl ¡ãä¥à á«¥¢
|
||||
3d_wnd_t equ 47 ;®âáâ㯠¤«ï tinygl ¡ãä¥à ᢥàåã
|
||||
3d_wnd_w equ 344
|
||||
3d_wnd_h equ 312
|
||||
3d_wnd_w equ 345
|
||||
3d_wnd_h equ 384
|
||||
|
||||
@use_library mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
|
||||
|
||||
@@ -43,13 +48,13 @@ list_offs_text equ 14+sizeof.obj_3d ;ᤢ
|
||||
include 'info_o3d.inc'
|
||||
|
||||
align 4
|
||||
fl180 dd 180.0
|
||||
fl255 dd 255.0
|
||||
open_file_data dd 0 ;㪠§ â¥«ì ¯ ¬ïâì ¤«ï ®âªàëâ¨ï ä ©«®¢ 3ds
|
||||
open_file_size dd 0 ;à §¬¥à ®âªàë⮣® ä ©«
|
||||
|
||||
;
|
||||
main_wnd_height equ 460 ;¢ëá®â £« ¢®£® ®ª ¯à®£à ¬¬ë
|
||||
fn_toolbar db 'toolbar.png',0
|
||||
IMAGE_TOOLBAR_ICON_SIZE equ 21*21*3
|
||||
image_data_toolbar dd 0
|
||||
;
|
||||
@@ -140,17 +145,17 @@ start:
|
||||
mov eax,dword[icon_tl_sys]
|
||||
mov dword[tree1.data_img_sys],eax
|
||||
|
||||
load_image_file 'objects.png', icon_toolbar
|
||||
include_image_file 'objects.png', icon_toolbar
|
||||
mov eax,dword[icon_toolbar]
|
||||
mov dword[tree1.data_img],eax
|
||||
|
||||
load_image_file 'font8x9.bmp', image_data_toolbar
|
||||
include_image_file '../../fs/kfar/trunk/font8x9.bmp', image_data_toolbar
|
||||
stdcall [buf2d_create_f_img], buf_1,[image_data_toolbar] ;á®§¤ ¥¬ ¡ãä¥à
|
||||
stdcall mem.Free,[image_data_toolbar] ;®á¢®¡®¦¤ ¥¬ ¯ ¬ïâì
|
||||
stdcall [buf2d_conv_24_to_8], buf_1,1 ;¤¥« ¥¬ ¡ãä¥à ¯à®§à ç®á⨠8 ¡¨â
|
||||
stdcall [buf2d_convert_text_matrix], buf_1
|
||||
|
||||
load_image_file fn_toolbar, image_data_toolbar
|
||||
include_image_file 'toolbar.png', image_data_toolbar
|
||||
|
||||
;à ¡®â á ä ©«®¬ áâ஥ª
|
||||
copy_path ini_name,sys_path,file_name,0
|
||||
@@ -223,7 +228,7 @@ start:
|
||||
mcall SF_SYSTEM_GET,SSF_TIME_COUNT
|
||||
mov [last_time],eax
|
||||
|
||||
stdcall [kosglMakeCurrent], 3d_wnd_l,3d_wnd_t,3d_wnd_w,3d_wnd_h,ctx1
|
||||
stdcall [kosglMakeCurrent], 3d_wnd_l,3d_wnd_t,[buf_ogl.w],[buf_ogl.h],ctx1
|
||||
stdcall [glEnable], GL_DEPTH_TEST
|
||||
stdcall [glEnable], GL_NORMALIZE ;¤¥« ¬ ®à¬ «¨ ®¤¨ ª®¢®© ¢¥«¨ç¨ë ¢® ¨§¡¥¦ ¨¥ àâ¥ä ªâ®¢
|
||||
stdcall [glClearColor], [color_bk+8],[color_bk+4],[color_bk],0.0
|
||||
@@ -231,7 +236,7 @@ start:
|
||||
call [gluNewQuadric]
|
||||
mov [qObj],eax
|
||||
|
||||
mov eax,dword[ctx1] ;eax -> TinyGLContext.GLContext
|
||||
mov eax,[ctx1.gl_context]
|
||||
mov eax,[eax] ;eax -> ZBuffer
|
||||
mov eax,[eax+ZBuffer.pbuf]
|
||||
mov dword[buf_ogl],eax
|
||||
@@ -257,20 +262,20 @@ still:
|
||||
or eax,eax
|
||||
jz timer_funct
|
||||
|
||||
cmp al,1
|
||||
cmp al,EV_REDRAW
|
||||
jne @f
|
||||
call draw_window
|
||||
jmp still
|
||||
@@:
|
||||
cmp al,2
|
||||
cmp al,EV_KEY
|
||||
jz key
|
||||
cmp al,3
|
||||
cmp al,EV_BUTTON
|
||||
jz button
|
||||
cmp al,6
|
||||
cmp al,EV_MOUSE
|
||||
jne @f
|
||||
mcall SF_THREAD_INFO,procinfo,-1
|
||||
cmp ax,word[procinfo+4]
|
||||
jne @f ;®ª® ¥ ªâ¨¢®
|
||||
cmp ax,word[procinfo.window_stack_position]
|
||||
jne @f ;window is not active
|
||||
call mouse
|
||||
@@:
|
||||
jmp still
|
||||
@@ -301,9 +306,9 @@ mouse:
|
||||
mov ebx,3d_wnd_l
|
||||
@@:
|
||||
sub ebx,3d_wnd_l
|
||||
cmp ebx,3d_wnd_w
|
||||
cmp ebx,[buf_ogl.w]
|
||||
jle @f
|
||||
mov ebx,3d_wnd_w
|
||||
mov ebx,[buf_ogl.w]
|
||||
@@:
|
||||
movsx eax,ax ;mouse.y
|
||||
cmp eax,3d_wnd_t
|
||||
@@ -311,9 +316,9 @@ mouse:
|
||||
mov eax,3d_wnd_t
|
||||
@@:
|
||||
sub eax,3d_wnd_t
|
||||
cmp eax,3d_wnd_h
|
||||
cmp eax,[buf_ogl.h]
|
||||
jle @f
|
||||
mov eax,3d_wnd_h
|
||||
mov eax,[buf_ogl.h]
|
||||
@@:
|
||||
finit
|
||||
fild dword[mouse_y]
|
||||
@@ -351,13 +356,13 @@ mouse:
|
||||
cmp ebx,3d_wnd_l
|
||||
jl .end_d
|
||||
sub ebx,3d_wnd_l
|
||||
cmp ebx,3d_wnd_w
|
||||
cmp ebx,[buf_ogl.w]
|
||||
jg .end_d
|
||||
movsx eax,ax ;mouse.y
|
||||
cmp eax,3d_wnd_t
|
||||
jl .end_d
|
||||
sub eax,3d_wnd_t
|
||||
cmp eax,3d_wnd_h
|
||||
cmp eax,[buf_ogl.h]
|
||||
jg .end_d
|
||||
mov dword[mouse_drag],1
|
||||
mov dword[mouse_x],ebx
|
||||
@@ -440,16 +445,7 @@ pushad
|
||||
or edx,0x33000000
|
||||
mcall SF_CREATE_WINDOW, (20 shl 16)+560, (20 shl 16)+main_wnd_height,,, capt
|
||||
|
||||
mcall SF_THREAD_INFO,procinfo,-1
|
||||
mov eax,dword[procinfo.box.height]
|
||||
cmp eax,250
|
||||
jge @f
|
||||
mov eax,250
|
||||
@@:
|
||||
sub eax,30
|
||||
sub eax,[tree1.box_top]
|
||||
mov [tree1.box_height],eax
|
||||
mov word[w_scr_t1.y_size],ax ;®¢ë¥ à §¬¥àë áªà®««¨£
|
||||
call OnResize
|
||||
|
||||
stdcall [kmainmenu_draw], [main_menu]
|
||||
|
||||
@@ -493,6 +489,64 @@ pushad
|
||||
popad
|
||||
ret
|
||||
|
||||
align 4
|
||||
OnResize:
|
||||
mcall SF_STYLE_SETTINGS,SSF_GET_SKIN_HEIGHT
|
||||
push eax
|
||||
mcall SF_THREAD_INFO,procinfo,-1
|
||||
mov eax,[procinfo.box.height]
|
||||
cmp eax,250
|
||||
jge @f
|
||||
mov eax,250
|
||||
@@:
|
||||
sub eax,[esp]
|
||||
sub eax,5
|
||||
sub eax,[tree1.box_top]
|
||||
mov [tree1.box_height],eax
|
||||
mov word[w_scr_t1.y_size],ax ;new scroll sizes
|
||||
|
||||
cmp [buf_ogl.h],eax
|
||||
je @f
|
||||
mov [buf_ogl.h],eax
|
||||
mov dword[buf_ogl.w],0 ;reset width
|
||||
@@:
|
||||
pop eax
|
||||
movzx eax,word[w_scr_t1.x_size]
|
||||
add eax,[tree1.box_left]
|
||||
add eax,[tree1.box_width]
|
||||
add eax,15 ;5 px * 3 borders
|
||||
sub eax,[procinfo.box.width]
|
||||
neg eax
|
||||
cmp eax,64
|
||||
jge @f
|
||||
mov eax,64
|
||||
@@:
|
||||
cmp [buf_ogl.w],eax
|
||||
je .end
|
||||
mov [buf_ogl.w],eax
|
||||
fild dword[buf_ogl.w]
|
||||
fld st0
|
||||
fdiv dword[fl180]
|
||||
fstp dword[angle_dxm]
|
||||
fidiv dword[buf_ogl.h]
|
||||
fstp dword[ratio]
|
||||
stdcall [glViewport], 0,0, [buf_ogl.w], [buf_ogl.h]
|
||||
|
||||
mov eax,[ctx1.gl_context]
|
||||
mov eax,[eax] ;eax -> ZBuffer
|
||||
mov eax,[eax+ZBuffer.pbuf]
|
||||
mov dword[buf_ogl],eax
|
||||
|
||||
stdcall [tl_node_get_data],tree1
|
||||
or eax,eax
|
||||
jz .end
|
||||
mov dword[offs_last_timer],0 ;for update buffer in the timer
|
||||
add eax,list_offs_obj3d
|
||||
stdcall obj_set_sizes, eax
|
||||
stdcall draw_3d, eax
|
||||
.end:
|
||||
ret
|
||||
|
||||
align 4
|
||||
key:
|
||||
mcall SF_GET_KEY
|
||||
@@ -1152,57 +1206,10 @@ l_libs_start:
|
||||
lib_2 l_libs lib_name_2, file_name, system_dir_2, import_box_lib
|
||||
lib_3 l_libs lib_name_3, file_name, system_dir_3, import_buf2d
|
||||
lib_4 l_libs lib_name_4, file_name, system_dir_4, import_libkmenu
|
||||
lib_5 l_libs lib_name_5, file_name, system_dir_5, import_lib_tinygl
|
||||
lib_5 l_libs lib_name_5, file_name, system_dir_5, import_tinygl
|
||||
lib_6 l_libs lib_name_6, file_name, system_dir_6, import_libini
|
||||
l_libs_end:
|
||||
|
||||
align 4
|
||||
import_libimg:
|
||||
dd alib_init1
|
||||
img_is_img dd aimg_is_img
|
||||
img_info dd aimg_info
|
||||
img_from_file dd aimg_from_file
|
||||
img_to_file dd aimg_to_file
|
||||
img_from_rgb dd aimg_from_rgb
|
||||
img_to_rgb dd aimg_to_rgb
|
||||
img_to_rgb2 dd aimg_to_rgb2
|
||||
img_decode dd aimg_decode
|
||||
img_encode dd aimg_encode
|
||||
img_create dd aimg_create
|
||||
img_destroy dd aimg_destroy
|
||||
img_destroy_layer dd aimg_destroy_layer
|
||||
img_count dd aimg_count
|
||||
img_lock_bits dd aimg_lock_bits
|
||||
img_unlock_bits dd aimg_unlock_bits
|
||||
img_flip dd aimg_flip
|
||||
img_flip_layer dd aimg_flip_layer
|
||||
img_rotate dd aimg_rotate
|
||||
img_rotate_layer dd aimg_rotate_layer
|
||||
img_draw dd aimg_draw
|
||||
|
||||
dd 0,0
|
||||
alib_init1 db 'lib_init',0
|
||||
aimg_is_img db 'img_is_img',0 ;®¯à¥¤¥«ï¥â ¯® ¤ ë¬, ¬®¦¥â «¨ ¡¨¡«¨®â¥ª ᤥ« âì ¨§ ¨å ¨§®¡à ¦¥¨¥
|
||||
aimg_info db 'img_info',0
|
||||
aimg_from_file db 'img_from_file',0
|
||||
aimg_to_file db 'img_to_file',0
|
||||
aimg_from_rgb db 'img_from_rgb',0
|
||||
aimg_to_rgb db 'img_to_rgb',0 ;¯à¥®¡à §®¢ ¨¥ ¨§®¡à ¦¥¨ï ¢ ¤ ë¥ RGB
|
||||
aimg_to_rgb2 db 'img_to_rgb2',0
|
||||
aimg_decode db 'img_decode',0 ; ¢â®¬ â¨ç¥áª¨ ®¯à¥¤¥«ï¥â ä®à¬ â £à ä¨ç¥áª¨å ¤ ëå
|
||||
aimg_encode db 'img_encode',0
|
||||
aimg_create db 'img_create',0
|
||||
aimg_destroy db 'img_destroy',0
|
||||
aimg_destroy_layer db 'img_destroy_layer',0
|
||||
aimg_count db 'img_count',0
|
||||
aimg_lock_bits db 'img_lock_bits',0
|
||||
aimg_unlock_bits db 'img_unlock_bits',0
|
||||
aimg_flip db 'img_flip',0
|
||||
aimg_flip_layer db 'img_flip_layer',0
|
||||
aimg_rotate db 'img_rotate',0
|
||||
aimg_rotate_layer db 'img_rotate_layer',0
|
||||
aimg_draw db 'img_draw',0
|
||||
|
||||
align 4
|
||||
import_proclib:
|
||||
OpenDialog_Init dd aOpenDialog_Init
|
||||
@@ -1215,122 +1222,9 @@ dd 0,0
|
||||
aOpenDialog_Set_file_name db 'OpenDialog_set_file_name',0
|
||||
aOpenDialog_Set_file_ext db 'OpenDialog_set_file_ext',0
|
||||
|
||||
align 4
|
||||
import_buf2d:
|
||||
dd sz_init0
|
||||
buf2d_create dd sz_buf2d_create
|
||||
buf2d_create_f_img dd sz_buf2d_create_f_img
|
||||
buf2d_clear dd sz_buf2d_clear
|
||||
buf2d_draw dd sz_buf2d_draw
|
||||
buf2d_delete dd sz_buf2d_delete
|
||||
buf2d_resize dd sz_buf2d_resize
|
||||
buf2d_line dd sz_buf2d_line
|
||||
buf2d_rect_by_size dd sz_buf2d_rect_by_size
|
||||
buf2d_filled_rect_by_size dd sz_buf2d_filled_rect_by_size
|
||||
buf2d_circle dd sz_buf2d_circle
|
||||
buf2d_img_hdiv2 dd sz_buf2d_img_hdiv2
|
||||
buf2d_img_wdiv2 dd sz_buf2d_img_wdiv2
|
||||
buf2d_conv_24_to_8 dd sz_buf2d_conv_24_to_8
|
||||
buf2d_conv_24_to_32 dd sz_buf2d_conv_24_to_32
|
||||
buf2d_bit_blt dd sz_buf2d_bit_blt
|
||||
buf2d_bit_blt_transp dd sz_buf2d_bit_blt_transp
|
||||
buf2d_bit_blt_alpha dd sz_buf2d_bit_blt_alpha
|
||||
buf2d_convert_text_matrix dd sz_buf2d_convert_text_matrix
|
||||
buf2d_draw_text dd sz_buf2d_draw_text
|
||||
buf2d_crop_color dd sz_buf2d_crop_color
|
||||
buf2d_offset_h dd sz_buf2d_offset_h
|
||||
buf2d_set_pixel dd sz_buf2d_set_pixel
|
||||
dd 0,0
|
||||
sz_init0 db 'lib_init',0
|
||||
sz_buf2d_create db 'buf2d_create',0
|
||||
sz_buf2d_create_f_img db 'buf2d_create_f_img',0
|
||||
sz_buf2d_clear db 'buf2d_clear',0
|
||||
sz_buf2d_draw db 'buf2d_draw',0
|
||||
sz_buf2d_delete db 'buf2d_delete',0
|
||||
sz_buf2d_resize db 'buf2d_resize',0
|
||||
sz_buf2d_line db 'buf2d_line',0
|
||||
sz_buf2d_rect_by_size db 'buf2d_rect_by_size',0
|
||||
sz_buf2d_filled_rect_by_size db 'buf2d_filled_rect_by_size',0
|
||||
sz_buf2d_circle db 'buf2d_circle',0
|
||||
sz_buf2d_img_hdiv2 db 'buf2d_img_hdiv2',0
|
||||
sz_buf2d_img_wdiv2 db 'buf2d_img_wdiv2',0
|
||||
sz_buf2d_conv_24_to_8 db 'buf2d_conv_24_to_8',0
|
||||
sz_buf2d_conv_24_to_32 db 'buf2d_conv_24_to_32',0
|
||||
sz_buf2d_bit_blt db 'buf2d_bit_blt',0
|
||||
sz_buf2d_bit_blt_transp db 'buf2d_bit_blt_transp',0
|
||||
sz_buf2d_bit_blt_alpha db 'buf2d_bit_blt_alpha',0
|
||||
sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0
|
||||
sz_buf2d_draw_text db 'buf2d_draw_text',0
|
||||
sz_buf2d_crop_color db 'buf2d_crop_color',0
|
||||
sz_buf2d_offset_h db 'buf2d_offset_h',0
|
||||
sz_buf2d_set_pixel db 'buf2d_set_pixel',0
|
||||
|
||||
align 4
|
||||
import_box_lib:
|
||||
dd sz_init1
|
||||
edit_box_draw dd sz_edit_box_draw
|
||||
edit_box_key dd sz_edit_box_key
|
||||
edit_box_mouse dd sz_edit_box_mouse
|
||||
edit_box_set_text dd sz_edit_box_set_text
|
||||
scrollbar_ver_draw dd sz_scrollbar_ver_draw
|
||||
scrollbar_hor_draw dd sz_scrollbar_hor_draw
|
||||
|
||||
tl_data_init dd sz_tl_data_init
|
||||
tl_data_clear dd sz_tl_data_clear
|
||||
tl_info_clear dd sz_tl_info_clear
|
||||
tl_key dd sz_tl_key
|
||||
tl_mouse dd sz_tl_mouse
|
||||
tl_draw dd sz_tl_draw
|
||||
tl_info_undo dd sz_tl_info_undo
|
||||
tl_info_redo dd sz_tl_info_redo
|
||||
tl_node_add dd sz_tl_node_add
|
||||
tl_node_set_data dd sz_tl_node_set_data
|
||||
tl_node_get_data dd sz_tl_node_get_data
|
||||
tl_node_delete dd sz_tl_node_delete
|
||||
tl_node_move_up dd sz_tl_node_move_up
|
||||
tl_node_move_down dd sz_tl_node_move_down
|
||||
tl_cur_beg dd sz_tl_cur_beg
|
||||
tl_cur_next dd sz_tl_cur_next
|
||||
tl_cur_perv dd sz_tl_cur_perv
|
||||
tl_node_close_open dd sz_tl_node_close_open
|
||||
tl_node_lev_inc dd sz_tl_node_lev_inc
|
||||
tl_node_lev_dec dd sz_tl_node_lev_dec
|
||||
tl_node_poi_get_info dd sz_tl_node_poi_get_info
|
||||
tl_node_poi_get_next_info dd sz_tl_node_poi_get_next_info
|
||||
tl_node_poi_get_data dd sz_tl_node_poi_get_data
|
||||
|
||||
dd 0,0
|
||||
sz_init1 db 'lib_init',0
|
||||
sz_edit_box_draw db 'edit_box_draw',0
|
||||
sz_edit_box_key db 'edit_box_key',0
|
||||
sz_edit_box_mouse db 'edit_box_mouse',0
|
||||
sz_edit_box_set_text db 'edit_box_set_text',0
|
||||
sz_scrollbar_ver_draw db 'scrollbar_v_draw',0
|
||||
sz_scrollbar_hor_draw db 'scrollbar_h_draw',0
|
||||
|
||||
sz_tl_data_init db 'tl_data_init',0
|
||||
sz_tl_data_clear db 'tl_data_clear',0
|
||||
sz_tl_info_clear db 'tl_info_clear',0
|
||||
sz_tl_key db 'tl_key',0
|
||||
sz_tl_mouse db 'tl_mouse',0
|
||||
sz_tl_draw db 'tl_draw',0
|
||||
sz_tl_info_undo db 'tl_info_undo',0
|
||||
sz_tl_info_redo db 'tl_info_redo',0
|
||||
sz_tl_node_add db 'tl_node_add',0
|
||||
sz_tl_node_set_data db 'tl_node_set_data',0
|
||||
sz_tl_node_get_data db 'tl_node_get_data',0
|
||||
sz_tl_node_delete db 'tl_node_delete',0
|
||||
sz_tl_node_move_up db 'tl_node_move_up',0
|
||||
sz_tl_node_move_down db 'tl_node_move_down',0
|
||||
sz_tl_cur_beg db 'tl_cur_beg',0
|
||||
sz_tl_cur_next db 'tl_cur_next',0
|
||||
sz_tl_cur_perv db 'tl_cur_perv',0
|
||||
sz_tl_node_close_open db 'tl_node_close_open',0
|
||||
sz_tl_node_lev_inc db 'tl_node_lev_inc',0
|
||||
sz_tl_node_lev_dec db 'tl_node_lev_dec',0
|
||||
sz_tl_node_poi_get_info db 'tl_node_poi_get_info',0
|
||||
sz_tl_node_poi_get_next_info db 'tl_node_poi_get_next_info',0
|
||||
sz_tl_node_poi_get_data db 'tl_node_poi_get_data',0
|
||||
include '../../develop/libraries/libs-dev/libimg/import.inc'
|
||||
include '../../develop/libraries/box_lib/import.inc'
|
||||
include '../../develop/libraries/buf2d/import.inc'
|
||||
|
||||
align 4
|
||||
import_libkmenu:
|
||||
@@ -1356,19 +1250,7 @@ dd 0,0
|
||||
akmenuitem_delete db 'kmenuitem_delete',0
|
||||
akmenuitem_draw db 'kmenuitem_draw',0
|
||||
|
||||
align 4
|
||||
import_lib_tinygl:
|
||||
macro E_LIB n
|
||||
{
|
||||
n dd sz_#n
|
||||
}
|
||||
include '../../develop/libraries/TinyGL/asm_fork/export.inc'
|
||||
dd 0,0
|
||||
macro E_LIB n
|
||||
{
|
||||
sz_#n db `n,0
|
||||
}
|
||||
include '../../develop/libraries/TinyGL/asm_fork/export.inc'
|
||||
include '../../develop/libraries/TinyGL/asm_fork/import.inc'
|
||||
|
||||
align 4
|
||||
import_libini:
|
||||
@@ -1387,7 +1269,7 @@ mouse_dd dd 0
|
||||
last_time dd 0
|
||||
angle_dxm dd 1.9111 ;~ 3d_wnd_w/180 - ¯à¨¡ ¢«¥¨¥ 㣫®¢ ¯®¢®à®â áæ¥ë ¯à¨ ¢à 饨¨ ¬ë襩
|
||||
angle_dym dd 1.7333 ;~ 3d_wnd_h/180
|
||||
ratio dd 1.1025 ;~ 3d_wnd_w/3d_wnd_h
|
||||
ratio dd 0.8984375 ;~ 3d_wnd_w/3d_wnd_h
|
||||
|
||||
align 4
|
||||
buf_ogl:
|
||||
@@ -1427,14 +1309,14 @@ white_light dd 0.8, 0.8, 0.8, 1.0 ;
|
||||
lmodel_ambient dd 0.3, 0.3, 0.3, 1.0 ; <20> à ¬¥âàë ä®®¢®£® ®á¢¥é¥¨ï
|
||||
|
||||
if lang eq ru_RU
|
||||
capt db 'info 3ds [user] ¢¥àá¨ï 14.04.25',0 ; ¯®¤¯¨áì ®ª
|
||||
capt db 'info 3ds [user] ¢¥àá¨ï 24.10.25',0 ; ¯®¤¯¨áì ®ª
|
||||
else ; Default to en_US
|
||||
capt db 'info 3ds [user] version 14.04.25',0 ; Window caption
|
||||
capt db 'info 3ds [user] version 24.10.25',0 ; Window caption
|
||||
end if
|
||||
|
||||
align 16
|
||||
i_end:
|
||||
ctx1 rb 28 ;sizeof.TinyGLContext = 28
|
||||
ctx1 TinyGLContext
|
||||
procinfo process_information
|
||||
run_file_70 FileInfoBlock
|
||||
sc system_colors
|
||||
|
||||
@@ -802,7 +802,14 @@ align 4
|
||||
proc draw_3d uses eax ebx ecx edi, o_data:dword
|
||||
mov edi,[o_data]
|
||||
cmp dword[edi+obj_3d.poi_count],2
|
||||
if version_edit eq 0
|
||||
jge @f
|
||||
stdcall [buf2d_clear], buf_ogl, [buf_ogl.color]
|
||||
jmp .end_f
|
||||
@@:
|
||||
else
|
||||
jl .end_f
|
||||
end if
|
||||
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;®ç¨á⨬ ¡ãä¥à 梥⠨ £«ã¡¨ë
|
||||
call [glPushMatrix]
|
||||
bt dword[draw_mode],bit_light
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
;
|
||||
; ¢ í⮬ ä ©«¥ ᮡà ë äãªæ¨¨ ã¦ë¥ ¤«ï á®§¤ ¨ï ¨
|
||||
; à ¡®âë ®ª á ª®®à¤¨ â ¬¨ ¢¥àè¨
|
||||
; This file contains functions needed to create
|
||||
; and operate a window with vertex coordinates
|
||||
;
|
||||
|
||||
prop_wnd_width equ 340 ;è¨à¨ ®ª ᮠ᢮©á⢠¬¨ ®¡ê¥ªâ
|
||||
prop_wnd_height equ 460 ;¢ëá®â ®ª ᮠ᢮©á⢠¬¨ ®¡ê¥ªâ
|
||||
3d_wnd_l equ 5 ;®âáâ㯠¤«ï tinygl ¡ãä¥à á«¥¢
|
||||
3d_wnd_t equ 23 ;®âáâ㯠¤«ï tinygl ¡ãä¥à ᢥàåã
|
||||
3d_wnd_w equ 320
|
||||
3d_wnd_l equ 5 ;tinygl buffer left indent
|
||||
3d_wnd_t equ 23 ;tinygl buffer top indent
|
||||
3d_wnd_w equ 396
|
||||
3d_wnd_h equ 240
|
||||
SIZE_ONE_FLOAT equ 14
|
||||
MAX_OBJECT_SIZE equ (4+SIZE_ONE_FLOAT*3+1)
|
||||
|
||||
prop_wnd_run db 0 ;¯¥à¥¬¥ ï á«¥¤ïé ï § ⥬ çâ®-¡ë ¥ § ¯ã᪠âì ¡®«ìè¥ 1-£® ®ª ᮠ᢮©á⢠¬¨ ®¤®¢à¥¬¥®
|
||||
align 4
|
||||
fl180 dd 180.0
|
||||
|
||||
prop_wnd_run db 0 ;variable that ensures that no more than 1 window with properties is launched at the same time
|
||||
|
||||
txt_q db '?',0
|
||||
txt_space:
|
||||
@@ -173,20 +174,23 @@ prop_still:
|
||||
jmp .end
|
||||
@@:
|
||||
|
||||
cmp al,1 ;¨§¬. ¯®«®¦¥¨¥ ®ª
|
||||
cmp al,EV_REDRAW
|
||||
jne @f
|
||||
call prop_red_win
|
||||
jmp .end
|
||||
@@:
|
||||
cmp al,2
|
||||
cmp al,EV_KEY
|
||||
jne @f
|
||||
call prop_key
|
||||
jmp .end
|
||||
@@:
|
||||
cmp al,3
|
||||
cmp al,EV_BUTTON
|
||||
jz prop_button
|
||||
cmp al,6
|
||||
cmp al,EV_MOUSE
|
||||
jne @f
|
||||
mcall SF_THREAD_INFO,procinfo,-1
|
||||
cmp ax,word[procinfo.window_stack_position]
|
||||
jne @f ;window is not active
|
||||
call prop_mouse
|
||||
@@:
|
||||
.end:
|
||||
@@ -198,20 +202,65 @@ prop_red_win:
|
||||
pushad
|
||||
mcall SF_REDRAW,SSF_BEGIN_DRAW
|
||||
|
||||
xor eax,eax
|
||||
mcall SF_STYLE_SETTINGS,SSF_GET_SKIN_HEIGHT
|
||||
push eax
|
||||
mcall SF_THREAD_INFO,procinfo,-1
|
||||
cmp dword[procinfo.box.height],0
|
||||
je .resize_end
|
||||
mov eax,[procinfo.box.height]
|
||||
sub eax,[esp]
|
||||
sub eax,[tree3.box_top]
|
||||
sub eax,5
|
||||
cmp eax,48
|
||||
jge @f
|
||||
mov eax,48 ;min size
|
||||
@@:
|
||||
mov dword[tree3.box_height],eax
|
||||
mov word[w_scr_t3.y_size],ax
|
||||
mov ebx,[procinfo.box.width]
|
||||
sub ebx,37
|
||||
cmp ebx,240
|
||||
jge @f
|
||||
mov ebx,240
|
||||
@@:
|
||||
mov [tree3.box_width],ebx
|
||||
add ebx,[tree3.box_left]
|
||||
mov word[w_scr_t3.x_pos],bx
|
||||
;todo: resize scroll slider
|
||||
|
||||
mov eax,[tree3.box_width]
|
||||
add eax,16
|
||||
cmp [buf_ogl.w],eax
|
||||
je .resize_end
|
||||
mov [buf_ogl.w],eax
|
||||
fild dword[buf_ogl.w]
|
||||
fld st0
|
||||
fdiv dword[fl180]
|
||||
fstp dword[angle_dxm]
|
||||
fidiv dword[buf_ogl.h]
|
||||
fstp dword[ratio]
|
||||
stdcall [glViewport], 0,0, [buf_ogl.w], 3d_wnd_h
|
||||
stdcall obj_set_sizes, o3d
|
||||
.resize_end:
|
||||
|
||||
mov edi,dword[capt_p] ;children window caption
|
||||
mov bx,word[procinfo.box.left]
|
||||
add bx,word[buf_0.l]
|
||||
add bx,5 ;è¨à¨ ¡®ª®¢®© à ¬ª¨
|
||||
add bx,5 ;side frame width
|
||||
shl ebx,16
|
||||
mov bx,prop_wnd_width
|
||||
mov bx,word[tree3.box_width]
|
||||
add bx,37
|
||||
mov cx,word[procinfo.box.top]
|
||||
add cx,word[buf_0.t]
|
||||
shl ecx,16
|
||||
mov cx,prop_wnd_height
|
||||
pop eax
|
||||
add eax,[tree3.box_height]
|
||||
add eax,[tree3.box_top]
|
||||
add eax,5
|
||||
mov cx,ax
|
||||
mov edx,[sc.work]
|
||||
or edx,0x33000000
|
||||
int 0x40
|
||||
mcall SF_CREATE_WINDOW
|
||||
|
||||
mov esi,[sc.work_button]
|
||||
mcall SF_DEFINE_BUTTON, (5 shl 16)+20, (266 shl 16)+20, 0x40000003
|
||||
@@ -226,7 +275,7 @@ pushad
|
||||
int 0x40
|
||||
|
||||
mov dword[w_scr_t3.all_redraw],1
|
||||
stdcall [scrollbar_ver_draw],dword w_scr_t3
|
||||
stdcall [scrollbar_v_draw], w_scr_t3
|
||||
stdcall [tl_draw], tree3
|
||||
stdcall [edit_box_draw], edit1
|
||||
stdcall [edit_box_draw], edit2
|
||||
@@ -316,9 +365,9 @@ prop_mouse:
|
||||
mov ebx,3d_wnd_l
|
||||
@@:
|
||||
sub ebx,3d_wnd_l
|
||||
cmp ebx,3d_wnd_w
|
||||
cmp ebx,[buf_ogl.w]
|
||||
jle @f
|
||||
mov ebx,3d_wnd_w
|
||||
mov ebx,[buf_ogl.w]
|
||||
@@:
|
||||
and eax,0xffff ;mouse.y
|
||||
cmp eax,3d_wnd_t
|
||||
@@ -334,14 +383,14 @@ prop_mouse:
|
||||
fild dword[mouse_y]
|
||||
mov [mouse_y],eax
|
||||
fisub dword[mouse_y]
|
||||
fdiv dword[angle_dxm] ;¥á«¨ ªãàá®à ¤¢¨¦¥âáï ¯® ®á¨ y (¢¢¥àå ¨«¨ ¢¨§) â® ¯®¢®à®â ¤¥« ¥¬ ¢®ªà㣠®á¨ x
|
||||
fdiv dword[angle_dym] ;if the cursor moves along the y axis
|
||||
fadd dword[angle_x]
|
||||
fstp dword[angle_x]
|
||||
|
||||
fild dword[mouse_x]
|
||||
mov [mouse_x],ebx
|
||||
fisub dword[mouse_x]
|
||||
fdiv dword[angle_dym] ;¥á«¨ ªãàá®à ¤¢¨¦¥âáï ¯® ®á¨ x (¢¢¥àå ¨«¨ ¢¨§) â® ¯®¢®à®â ¤¥« ¥¬ ¢®ªà㣠®á¨ y
|
||||
fdiv dword[angle_dxm] ;if the cursor moves along the x axis
|
||||
fadd dword[angle_y]
|
||||
fstp dword[angle_y]
|
||||
|
||||
@@ -363,7 +412,7 @@ prop_mouse:
|
||||
cmp ebx,3d_wnd_l
|
||||
jl .end_d
|
||||
sub ebx,3d_wnd_l
|
||||
cmp ebx,3d_wnd_w
|
||||
cmp ebx,[buf_ogl.w]
|
||||
jg .end_d
|
||||
and eax,0xffff ;mouse.y
|
||||
cmp eax,3d_wnd_t
|
||||
@@ -811,7 +860,7 @@ capt_p dd 0
|
||||
|
||||
;¤¥à¥¢® á ®¡ê¥ªâ ¬¨ ¢ ¯®«ì§®¢ ⥫ì᪮¬ ä ©«¥
|
||||
tree3 tree_list MAX_OBJECT_SIZE,3, tl_key_no_edit+tl_list_box_mode,\
|
||||
16,16, 0xffffff,0xb0d0ff,0x400040, 5,290,303,140, 16, 4,0, el_focus,\
|
||||
16,16, 0xffffff,0xb0d0ff,0x10400040, 5,290,380,140, 16, 4,0, el_focus,\
|
||||
w_scr_t3,get_point_coords
|
||||
|
||||
edit1 edit_box 80, 76, 269, 0xffd0d0, 0xff, 0x80ff, 0, 0x8000, 32, string1, mouse_dd, 0
|
||||
|
||||
@@ -100,6 +100,10 @@ lib_init: ;//////////////////////////////////////////////////////////////////;;
|
||||
mov [mem.alloc], eax
|
||||
mov [mem.free], ebx
|
||||
mov [mem.realloc], ecx
|
||||
|
||||
cmp [dll.load], edx
|
||||
je .ok
|
||||
|
||||
mov [dll.load], edx
|
||||
|
||||
invoke dll.load, @IMPORT
|
||||
@@ -115,6 +119,7 @@ lib_init: ;//////////////////////////////////////////////////////////////////;;
|
||||
invoke ini.get_str, inifile, sec_proxy, key_password, proxyPassword, 256, proxyPassword
|
||||
popa
|
||||
|
||||
.ok:
|
||||
DEBUGF 1, "HTTP library: init OK\n"
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
@@ -78,6 +78,10 @@ proc lib_init ;///////////////////////////////////////////////////////////////;;
|
||||
mov [mem.alloc], eax
|
||||
mov [mem.free], ebx
|
||||
mov [mem.realloc], ecx
|
||||
|
||||
cmp [dll.load], edx
|
||||
je .ok
|
||||
|
||||
mov [dll.load], edx
|
||||
|
||||
or edx, edx
|
||||
|
||||
@@ -34,21 +34,25 @@ proc libini._.init ;////////////////////////////////////////////////////////////
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 1 (fail) / 0 (ok) (library initialization result) ;;
|
||||
;;================================================================================================;;
|
||||
mov [mem.alloc], eax
|
||||
mov [mem.free], ebx
|
||||
mov [mem.realloc], ecx
|
||||
mov [dll.load], edx
|
||||
mov [mem.alloc], eax
|
||||
mov [mem.free], ebx
|
||||
mov [mem.realloc], ecx
|
||||
|
||||
invoke dll.load, @IMPORT
|
||||
or eax, eax
|
||||
jz .ok
|
||||
cmp [dll.load], edx
|
||||
je .ok
|
||||
|
||||
xor eax, eax
|
||||
inc eax
|
||||
ret
|
||||
mov [dll.load], edx
|
||||
|
||||
.ok: xor eax,eax
|
||||
ret
|
||||
invoke dll.load, @IMPORT
|
||||
or eax, eax
|
||||
jz .ok
|
||||
|
||||
xor eax, eax
|
||||
inc eax
|
||||
ret
|
||||
|
||||
.ok: xor eax,eax
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
@@ -60,16 +64,16 @@ proc libini._.unget_char _f ;///////////////////////////////////////////////////
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< --- TBD --- ;;
|
||||
;;================================================================================================;;
|
||||
push eax ecx
|
||||
mov ecx, [_f]
|
||||
inc [ecx + IniFile.cnt]
|
||||
dec esi
|
||||
mov eax, [ecx + IniFile.bsize]
|
||||
cmp [ecx + IniFile.cnt], eax
|
||||
jle @f
|
||||
stdcall libini._.unload_block, [_f]
|
||||
@@: pop ecx eax
|
||||
ret
|
||||
push eax ecx
|
||||
mov ecx, [_f]
|
||||
inc [ecx + IniFile.cnt]
|
||||
dec esi
|
||||
mov eax, [ecx + IniFile.bsize]
|
||||
cmp [ecx + IniFile.cnt], eax
|
||||
jle @f
|
||||
stdcall libini._.unload_block, [_f]
|
||||
@@: pop ecx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
@@ -81,13 +85,13 @@ proc libini._.get_char _f ;/////////////////////////////////////////////////////
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< --- TBD --- ;;
|
||||
;;================================================================================================;;
|
||||
mov ecx, [_f]
|
||||
dec [ecx + IniFile.cnt]
|
||||
jns @f
|
||||
stdcall libini._.preload_block, [_f]
|
||||
dec [ecx + IniFile.cnt]
|
||||
mov ecx, [_f]
|
||||
dec [ecx + IniFile.cnt]
|
||||
jns @f
|
||||
stdcall libini._.preload_block, [_f]
|
||||
dec [ecx + IniFile.cnt]
|
||||
@@: lodsb
|
||||
ret
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
@@ -99,22 +103,22 @@ proc libini._.skip_nonblanks _f ;///////////////////////////////////////////////
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< --- TBD --- ;;
|
||||
;;================================================================================================;;
|
||||
mov ecx, [_f]
|
||||
mov ecx, [_f]
|
||||
@@: stdcall libini._.get_char, [_f]
|
||||
cmp al, 32
|
||||
je @b
|
||||
cmp al, 13
|
||||
je @b
|
||||
cmp al, 10
|
||||
je @b
|
||||
cmp al, 9
|
||||
je @b
|
||||
cmp al, ini.COMMENT_CHAR
|
||||
jne @f
|
||||
stdcall libini._.skip_line, [_f]
|
||||
jmp @b
|
||||
cmp al, 32
|
||||
je @b
|
||||
cmp al, 13
|
||||
je @b
|
||||
cmp al, 10
|
||||
je @b
|
||||
cmp al, 9
|
||||
je @b
|
||||
cmp al, ini.COMMENT_CHAR
|
||||
jne @f
|
||||
stdcall libini._.skip_line, [_f]
|
||||
jmp @b
|
||||
@@: stdcall libini._.unget_char, [_f]
|
||||
ret
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
@@ -126,14 +130,14 @@ proc libini._.skip_spaces _f ;//////////////////////////////////////////////////
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< --- TBD --- ;;
|
||||
;;================================================================================================;;
|
||||
mov ecx, [_f]
|
||||
mov ecx, [_f]
|
||||
@@: stdcall libini._.get_char, [_f]
|
||||
cmp al, 32
|
||||
je @b
|
||||
cmp al, 9
|
||||
je @b
|
||||
cmp al, 32
|
||||
je @b
|
||||
cmp al, 9
|
||||
je @b
|
||||
@@: stdcall libini._.unget_char, [_f]
|
||||
ret
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
@@ -145,16 +149,16 @@ proc libini._.skip_line _f ;////////////////////////////////////////////////////
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< --- TBD --- ;;
|
||||
;;================================================================================================;;
|
||||
mov ecx, [_f]
|
||||
mov ecx, [_f]
|
||||
@@: stdcall libini._.get_char, [_f]
|
||||
or al, al
|
||||
jz @f
|
||||
cmp al, 13
|
||||
je @f
|
||||
cmp al, 10
|
||||
jne @b
|
||||
or al, al
|
||||
jz @f
|
||||
cmp al, 13
|
||||
je @f
|
||||
cmp al, 10
|
||||
jne @b
|
||||
@@: stdcall libini._.unget_char, [_f]
|
||||
ret
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
@@ -166,16 +170,16 @@ proc libini._.unload_block _f ;/////////////////////////////////////////////////
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< --- TBD --- ;;
|
||||
;;================================================================================================;;
|
||||
push eax ebx ecx
|
||||
mov ebx, [_f]
|
||||
mov eax, [ebx + IniFile.pos]
|
||||
add eax, -ini.BLOCK_SIZE
|
||||
invoke file.seek, [ebx + IniFile.fh], eax, SEEK_SET
|
||||
stdcall libini._.preload_block, ebx
|
||||
add esi, eax
|
||||
mov [ebx + IniFile.cnt], 0
|
||||
pop ecx ebx eax
|
||||
ret
|
||||
push eax ebx ecx
|
||||
mov ebx, [_f]
|
||||
mov eax, [ebx + IniFile.pos]
|
||||
add eax, -ini.BLOCK_SIZE
|
||||
invoke file.seek, [ebx + IniFile.fh], eax, SEEK_SET
|
||||
stdcall libini._.preload_block, ebx
|
||||
add esi, eax
|
||||
mov [ebx + IniFile.cnt], 0
|
||||
pop ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
@@ -187,25 +191,25 @@ proc libini._.preload_block _f ;////////////////////////////////////////////////
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< --- TBD --- ;;
|
||||
;;================================================================================================;;
|
||||
push eax ebx ecx
|
||||
mov ebx, [_f]
|
||||
@@: mov esi, [ebx + IniFile.buf]
|
||||
push edi
|
||||
mov edi, esi
|
||||
mov ecx, ini.BLOCK_SIZE / 4
|
||||
xor eax, eax
|
||||
rep stosd
|
||||
pop edi
|
||||
invoke file.tell, [ebx + IniFile.fh]
|
||||
mov [ebx + IniFile.pos], eax
|
||||
invoke file.read, [ebx + IniFile.fh], esi, ini.BLOCK_SIZE
|
||||
mov esi,[ebx + IniFile.buf]
|
||||
cmp eax,ini.BLOCK_SIZE
|
||||
jl @f
|
||||
@@: mov [ebx + IniFile.cnt], eax
|
||||
mov [ebx + IniFile.bsize], eax
|
||||
pop ecx ebx eax
|
||||
ret
|
||||
push eax ebx ecx
|
||||
mov ebx, [_f]
|
||||
@@: mov esi, [ebx + IniFile.buf]
|
||||
push edi
|
||||
mov edi, esi
|
||||
mov ecx, ini.BLOCK_SIZE / 4
|
||||
xor eax, eax
|
||||
rep stosd
|
||||
pop edi
|
||||
invoke file.tell, [ebx + IniFile.fh]
|
||||
mov [ebx + IniFile.pos], eax
|
||||
invoke file.read, [ebx + IniFile.fh], esi, ini.BLOCK_SIZE
|
||||
mov esi,[ebx + IniFile.buf]
|
||||
cmp eax,ini.BLOCK_SIZE
|
||||
jl @f
|
||||
@@: mov [ebx + IniFile.cnt], eax
|
||||
mov [ebx + IniFile.bsize], eax
|
||||
pop ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
@@ -217,18 +221,18 @@ proc libini._.reload_block _f ;/////////////////////////////////////////////////
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< --- TBD --- ;;
|
||||
;;================================================================================================;;
|
||||
push eax ebx ecx
|
||||
mov ebx, [_f]
|
||||
push [ebx + IniFile.bsize]
|
||||
push esi [ebx + IniFile.cnt]
|
||||
invoke file.seek, [ebx + IniFile.fh], [ebx + IniFile.pos], SEEK_SET
|
||||
stdcall libini._.preload_block, ebx
|
||||
pop [ebx + IniFile.cnt] esi
|
||||
pop eax
|
||||
sub eax,[ebx + IniFile.bsize]
|
||||
sub [ebx + IniFile.cnt], eax
|
||||
pop ecx ebx eax
|
||||
ret
|
||||
push eax ebx ecx
|
||||
mov ebx, [_f]
|
||||
push [ebx + IniFile.bsize]
|
||||
push esi [ebx + IniFile.cnt]
|
||||
invoke file.seek, [ebx + IniFile.fh], [ebx + IniFile.pos], SEEK_SET
|
||||
stdcall libini._.preload_block, ebx
|
||||
pop [ebx + IniFile.cnt] esi
|
||||
pop eax
|
||||
sub eax,[ebx + IniFile.bsize]
|
||||
sub [ebx + IniFile.cnt], eax
|
||||
pop ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; f_info - contains current file block number
|
||||
@@ -249,91 +253,91 @@ locals
|
||||
buf dd ?
|
||||
endl
|
||||
|
||||
xor eax, eax
|
||||
cmp [_delta], 0
|
||||
je .skip
|
||||
xor eax, eax
|
||||
cmp [_delta], 0
|
||||
je .skip
|
||||
|
||||
push ebx ecx
|
||||
invoke mem.alloc, ini.BLOCK_SIZE
|
||||
or eax, eax
|
||||
jz .fail
|
||||
mov [buf], eax
|
||||
push ebx ecx
|
||||
invoke mem.alloc, ini.BLOCK_SIZE
|
||||
or eax, eax
|
||||
jz .fail
|
||||
mov [buf], eax
|
||||
|
||||
cmp [_delta], 0
|
||||
jl .down
|
||||
cmp [_delta], 0
|
||||
jl .down
|
||||
|
||||
mov ebx, [_f]
|
||||
mov ecx, [ebx + IniFile.cnt]
|
||||
mov ebx, [ebx + IniFile.fh]
|
||||
invoke file.tell, ebx
|
||||
sub eax, ecx
|
||||
invoke file.seek, ebx, eax, SEEK_SET
|
||||
@@: invoke file.seek, ebx, [_delta], SEEK_CUR
|
||||
invoke file.eof?, ebx
|
||||
or eax, eax
|
||||
jnz .done
|
||||
invoke file.read, ebx, [buf], ini.BLOCK_SIZE
|
||||
mov ecx, eax
|
||||
mov eax, [_delta]
|
||||
neg eax
|
||||
sub eax, ecx
|
||||
invoke file.seek, ebx, eax, SEEK_CUR
|
||||
push ecx
|
||||
invoke file.write, ebx, [buf], ecx
|
||||
pop ecx
|
||||
cmp eax, ecx
|
||||
jz @b
|
||||
mov ebx, [_f]
|
||||
mov ecx, [ebx + IniFile.cnt]
|
||||
mov ebx, [ebx + IniFile.fh]
|
||||
invoke file.tell, ebx
|
||||
sub eax, ecx
|
||||
invoke file.seek, ebx, eax, SEEK_SET
|
||||
@@: invoke file.seek, ebx, [_delta], SEEK_CUR
|
||||
invoke file.eof?, ebx
|
||||
or eax, eax
|
||||
jnz .done
|
||||
invoke file.read, ebx, [buf], ini.BLOCK_SIZE
|
||||
mov ecx, eax
|
||||
mov eax, [_delta]
|
||||
neg eax
|
||||
sub eax, ecx
|
||||
invoke file.seek, ebx, eax, SEEK_CUR
|
||||
push ecx
|
||||
invoke file.write, ebx, [buf], ecx
|
||||
pop ecx
|
||||
cmp eax, ecx
|
||||
jz @b
|
||||
.fail:
|
||||
or eax, -1
|
||||
pop ecx ebx
|
||||
ret
|
||||
or eax, -1
|
||||
pop ecx ebx
|
||||
ret
|
||||
.done:
|
||||
mov eax, [_delta]
|
||||
neg eax
|
||||
invoke file.seek, ebx, eax, SEEK_CUR
|
||||
invoke file.seteof, ebx
|
||||
stdcall libini._.reload_block, [_f]
|
||||
invoke mem.free, [buf]
|
||||
pop ecx ebx
|
||||
mov eax, [_delta]
|
||||
neg eax
|
||||
invoke file.seek, ebx, eax, SEEK_CUR
|
||||
invoke file.seteof, ebx
|
||||
stdcall libini._.reload_block, [_f]
|
||||
invoke mem.free, [buf]
|
||||
pop ecx ebx
|
||||
.skip:
|
||||
ret
|
||||
ret
|
||||
|
||||
.down:
|
||||
neg [_delta]
|
||||
neg [_delta]
|
||||
|
||||
mov ebx, [_f]
|
||||
mov ecx, [ebx + IniFile.cnt]
|
||||
mov ebx, [ebx + IniFile.fh]
|
||||
invoke file.tell, ebx
|
||||
sub eax, ecx
|
||||
lea edx, [eax - 1]
|
||||
push edx
|
||||
@@: invoke file.seek, ebx, edx, SEEK_SET
|
||||
invoke file.eof?, ebx
|
||||
or eax, eax
|
||||
jnz @f
|
||||
add edx, ini.BLOCK_SIZE
|
||||
jmp @b
|
||||
@@: cmp edx, [esp]
|
||||
je .skip.2
|
||||
add edx, -ini.BLOCK_SIZE
|
||||
cmp edx, [esp]
|
||||
jl @f
|
||||
invoke file.seek, ebx, edx, SEEK_SET
|
||||
invoke file.read, ebx, [buf], ini.BLOCK_SIZE
|
||||
mov ecx, eax
|
||||
mov eax, [_delta]
|
||||
sub eax, ecx
|
||||
invoke file.seek, ebx, eax, SEEK_CUR
|
||||
invoke file.write, ebx, [buf], ecx
|
||||
jmp @b
|
||||
mov ebx, [_f]
|
||||
mov ecx, [ebx + IniFile.cnt]
|
||||
mov ebx, [ebx + IniFile.fh]
|
||||
invoke file.tell, ebx
|
||||
sub eax, ecx
|
||||
lea edx, [eax - 1]
|
||||
push edx
|
||||
@@: invoke file.seek, ebx, edx, SEEK_SET
|
||||
invoke file.eof?, ebx
|
||||
or eax, eax
|
||||
jnz @f
|
||||
add edx, ini.BLOCK_SIZE
|
||||
jmp @b
|
||||
@@: cmp edx, [esp]
|
||||
je .skip.2
|
||||
add edx, -ini.BLOCK_SIZE
|
||||
cmp edx, [esp]
|
||||
jl @f
|
||||
invoke file.seek, ebx, edx, SEEK_SET
|
||||
invoke file.read, ebx, [buf], ini.BLOCK_SIZE
|
||||
mov ecx, eax
|
||||
mov eax, [_delta]
|
||||
sub eax, ecx
|
||||
invoke file.seek, ebx, eax, SEEK_CUR
|
||||
invoke file.write, ebx, [buf], ecx
|
||||
jmp @b
|
||||
@@:
|
||||
.skip.2:
|
||||
add esp, 4
|
||||
stdcall libini._.reload_block, [_f]
|
||||
invoke mem.free, [buf]
|
||||
pop ecx ebx
|
||||
ret
|
||||
add esp, 4
|
||||
stdcall libini._.reload_block, [_f]
|
||||
invoke mem.free, [buf]
|
||||
pop ecx ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
@@ -345,25 +349,25 @@ proc libini._.get_value_length _f ;/////////////////////////////////////////////
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< --- TBD --- ;;
|
||||
;;================================================================================================;;
|
||||
push ebx ecx edx eax
|
||||
mov ebx, [_f]
|
||||
invoke file.tell, [ebx + IniFile.fh]
|
||||
push esi [ebx + IniFile.cnt] [ebx + IniFile.pos]
|
||||
sub eax, [ebx + IniFile.cnt]
|
||||
mov edx, eax
|
||||
push ebx ecx edx eax
|
||||
mov ebx, [_f]
|
||||
invoke file.tell, [ebx + IniFile.fh]
|
||||
push esi [ebx + IniFile.cnt] [ebx + IniFile.pos]
|
||||
sub eax, [ebx + IniFile.cnt]
|
||||
mov edx, eax
|
||||
|
||||
stdcall libini._.skip_line, [_f]
|
||||
invoke file.tell, [ebx + IniFile.fh]
|
||||
sub eax, [ebx + IniFile.cnt]
|
||||
sub eax, edx
|
||||
mov [esp + 4 * 3], eax
|
||||
stdcall libini._.skip_line, [_f]
|
||||
invoke file.tell, [ebx + IniFile.fh]
|
||||
sub eax, [ebx + IniFile.cnt]
|
||||
sub eax, edx
|
||||
mov [esp + 4 * 3], eax
|
||||
|
||||
pop eax
|
||||
invoke file.seek, [ebx + IniFile.fh], eax, SEEK_SET
|
||||
stdcall libini._.preload_block, [_f]
|
||||
pop [ebx + IniFile.cnt] esi
|
||||
pop eax edx ecx ebx
|
||||
ret
|
||||
pop eax
|
||||
invoke file.seek, [ebx + IniFile.fh], eax, SEEK_SET
|
||||
stdcall libini._.preload_block, [_f]
|
||||
pop [ebx + IniFile.cnt] esi
|
||||
pop eax edx ecx ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
@@ -376,10 +380,10 @@ proc libini._.string_copy ;/////////////////////////////////////////////////////
|
||||
;< --- TBD --- ;;
|
||||
;;================================================================================================;;
|
||||
@@: lodsb
|
||||
or al, al
|
||||
jz @f
|
||||
stosb
|
||||
jmp @b
|
||||
or al, al
|
||||
jz @f
|
||||
stosb
|
||||
jmp @b
|
||||
@@: ret
|
||||
endp
|
||||
|
||||
@@ -392,26 +396,26 @@ proc libini._.find_next_section _f ;////////////////////////////////////////////
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< --- TBD --- ;;
|
||||
;;================================================================================================;;
|
||||
push ebx edi
|
||||
push ebx edi
|
||||
|
||||
@@: stdcall libini._.skip_nonblanks, [_f]
|
||||
cmp al, '['
|
||||
je @f
|
||||
or al, al
|
||||
jz .exit_error
|
||||
stdcall libini._.skip_line, [_f]
|
||||
or al, al
|
||||
jz .exit_error
|
||||
jmp @b
|
||||
cmp al, '['
|
||||
je @f
|
||||
or al, al
|
||||
jz .exit_error
|
||||
stdcall libini._.skip_line, [_f]
|
||||
or al, al
|
||||
jz .exit_error
|
||||
jmp @b
|
||||
@@:
|
||||
pop edi ebx
|
||||
xor eax, eax
|
||||
ret
|
||||
pop edi ebx
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
.exit_error:
|
||||
pop edi ebx
|
||||
or eax, -1
|
||||
ret
|
||||
pop edi ebx
|
||||
or eax, -1
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
@@ -425,50 +429,50 @@ proc libini._.find_section _f, _sec_name ;//////////////////////////////////////
|
||||
;< eax = -1 (fail) / 0 (ok) ;;
|
||||
;< [_f.pos] = new cursor position (right after ']' char if eax = 0, at the end of file otherwise) ;;
|
||||
;;================================================================================================;;
|
||||
push ebx edi
|
||||
push ebx edi
|
||||
|
||||
mov ecx, [_f]
|
||||
invoke file.seek, [ecx + IniFile.fh], 0, SEEK_SET
|
||||
stdcall libini._.preload_block, [_f]
|
||||
mov ecx, [_f]
|
||||
invoke file.seek, [ecx + IniFile.fh], 0, SEEK_SET
|
||||
stdcall libini._.preload_block, [_f]
|
||||
|
||||
.next_section:
|
||||
stdcall libini._.find_next_section, [_f]
|
||||
or eax, eax
|
||||
jnz .exit_error
|
||||
stdcall libini._.find_next_section, [_f]
|
||||
or eax, eax
|
||||
jnz .exit_error
|
||||
|
||||
stdcall libini._.get_char, [_f]
|
||||
stdcall libini._.skip_spaces, [_f]
|
||||
mov edi, [_sec_name]
|
||||
stdcall libini._.get_char, [_f]
|
||||
stdcall libini._.skip_spaces, [_f]
|
||||
mov edi, [_sec_name]
|
||||
@@: stdcall libini._.get_char, [_f]
|
||||
cmp al, ']'
|
||||
je @f
|
||||
or al, al
|
||||
jz .exit_error
|
||||
cmp al, 13
|
||||
je .next_section
|
||||
cmp al, 10
|
||||
je .next_section
|
||||
scasb
|
||||
je @b
|
||||
cmp byte[edi - 1], 0
|
||||
jne .next_section
|
||||
dec edi
|
||||
stdcall libini._.unget_char, [_f]
|
||||
stdcall libini._.skip_spaces, [_f]
|
||||
stdcall libini._.get_char, [_f]
|
||||
cmp al, ']'
|
||||
jne .next_section
|
||||
cmp al, ']'
|
||||
je @f
|
||||
or al, al
|
||||
jz .exit_error
|
||||
cmp al, 13
|
||||
je .next_section
|
||||
cmp al, 10
|
||||
je .next_section
|
||||
scasb
|
||||
je @b
|
||||
cmp byte[edi - 1], 0
|
||||
jne .next_section
|
||||
dec edi
|
||||
stdcall libini._.unget_char, [_f]
|
||||
stdcall libini._.skip_spaces, [_f]
|
||||
stdcall libini._.get_char, [_f]
|
||||
cmp al, ']'
|
||||
jne .next_section
|
||||
@@:
|
||||
cmp byte[edi], 0
|
||||
jne .next_section
|
||||
pop edi ebx
|
||||
xor eax, eax
|
||||
ret
|
||||
cmp byte[edi], 0
|
||||
jne .next_section
|
||||
pop edi ebx
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
.exit_error:
|
||||
pop edi ebx
|
||||
or eax, -1
|
||||
ret
|
||||
pop edi ebx
|
||||
or eax, -1
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
@@ -483,44 +487,44 @@ proc libini._.find_key _f, _key_name ;//////////////////////////////////////////
|
||||
;< [_f.pos] = new cursor position (right after '=' char if eax = 0, at the end of file or right ;;
|
||||
;< before '[' char otherwise) ;;
|
||||
;;================================================================================================;;
|
||||
push ebx edi
|
||||
push ebx edi
|
||||
|
||||
.next_value:
|
||||
mov edi, [_key_name]
|
||||
stdcall libini._.skip_line, [_f]
|
||||
stdcall libini._.skip_nonblanks, [_f]
|
||||
or al, al
|
||||
jz .exit_error
|
||||
cmp al, '['
|
||||
je .exit_error
|
||||
mov edi, [_key_name]
|
||||
stdcall libini._.skip_line, [_f]
|
||||
stdcall libini._.skip_nonblanks, [_f]
|
||||
or al, al
|
||||
jz .exit_error
|
||||
cmp al, '['
|
||||
je .exit_error
|
||||
@@: stdcall libini._.get_char, [_f]
|
||||
or al, al
|
||||
jz .exit_error
|
||||
cmp al, '='
|
||||
je @f
|
||||
scasb
|
||||
je @b
|
||||
cmp byte[edi - 1], 0
|
||||
jne .next_value
|
||||
dec edi
|
||||
stdcall libini._.unget_char, [_f]
|
||||
stdcall libini._.skip_spaces, [_f]
|
||||
stdcall libini._.get_char, [_f]
|
||||
cmp al, '='
|
||||
je @f
|
||||
jmp .next_value
|
||||
or al, al
|
||||
jz .exit_error
|
||||
cmp al, '='
|
||||
je @f
|
||||
scasb
|
||||
je @b
|
||||
cmp byte[edi - 1], 0
|
||||
jne .next_value
|
||||
dec edi
|
||||
stdcall libini._.unget_char, [_f]
|
||||
stdcall libini._.skip_spaces, [_f]
|
||||
stdcall libini._.get_char, [_f]
|
||||
cmp al, '='
|
||||
je @f
|
||||
jmp .next_value
|
||||
@@:
|
||||
cmp byte[edi], 0
|
||||
jne .next_value
|
||||
cmp byte[edi], 0
|
||||
jne .next_value
|
||||
|
||||
pop edi ebx
|
||||
xor eax, eax
|
||||
ret
|
||||
pop edi ebx
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
.exit_error:
|
||||
pop edi ebx
|
||||
or eax, -1
|
||||
ret
|
||||
pop edi ebx
|
||||
or eax, -1
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
@@ -532,31 +536,31 @@ proc libini._.low.read_value _f_addr, _buffer, _buf_len ;///////////////////////
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< --- TBD --- ;;
|
||||
;;================================================================================================;;
|
||||
push edi eax
|
||||
mov edi, [_buffer]
|
||||
stdcall libini._.skip_spaces, [_f_addr]
|
||||
@@: dec [_buf_len]
|
||||
jz @f
|
||||
stdcall libini._.get_char, [_f_addr]
|
||||
cmp al, 13
|
||||
je @f
|
||||
cmp al, 10
|
||||
je @f
|
||||
stosb
|
||||
or al, al
|
||||
jnz @b
|
||||
push edi eax
|
||||
mov edi, [_buffer]
|
||||
stdcall libini._.skip_spaces, [_f_addr]
|
||||
@@: dec [_buf_len]
|
||||
jz @f
|
||||
stdcall libini._.get_char, [_f_addr]
|
||||
cmp al, 13
|
||||
je @f
|
||||
cmp al, 10
|
||||
je @f
|
||||
stosb
|
||||
or al, al
|
||||
jnz @b
|
||||
@@: stdcall libini._.unget_char, [_f_addr]
|
||||
mov byte[edi], 0
|
||||
dec edi
|
||||
@@: cmp edi, [_buffer]
|
||||
jb @f
|
||||
cmp byte[edi], 32
|
||||
ja @f
|
||||
mov byte[edi], 0
|
||||
dec edi
|
||||
jmp @b
|
||||
@@: pop eax edi
|
||||
ret
|
||||
mov byte[edi], 0
|
||||
dec edi
|
||||
@@: cmp edi, [_buffer]
|
||||
jb @f
|
||||
cmp byte[edi], 32
|
||||
ja @f
|
||||
mov byte[edi], 0
|
||||
dec edi
|
||||
jmp @b
|
||||
@@: pop eax edi
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
@@ -568,25 +572,25 @@ proc libini._.str_to_int ;//////////////////////////////////////////////////////
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = binary number representation (no overflow checks made) ;;
|
||||
;;================================================================================================;;
|
||||
push edx
|
||||
push edx
|
||||
|
||||
xor eax, eax
|
||||
xor edx, edx
|
||||
xor eax, eax
|
||||
xor edx, edx
|
||||
|
||||
@@: lodsb
|
||||
cmp al, '0'
|
||||
jb @f
|
||||
cmp al, '9'
|
||||
ja @f
|
||||
add eax, -'0'
|
||||
imul edx, 10
|
||||
add edx, eax
|
||||
jmp @b
|
||||
cmp al, '0'
|
||||
jb @f
|
||||
cmp al, '9'
|
||||
ja @f
|
||||
add eax, -'0'
|
||||
imul edx, 10
|
||||
add edx, eax
|
||||
jmp @b
|
||||
|
||||
@@: dec esi
|
||||
mov eax, edx
|
||||
pop edx
|
||||
ret
|
||||
@@: dec esi
|
||||
mov eax, edx
|
||||
pop edx
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
@@ -600,29 +604,29 @@ proc libini._.int_to_str ;//////////////////////////////////////////////////////
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< --- TBD --- ;;
|
||||
;;================================================================================================;;
|
||||
push ecx edx
|
||||
push ecx edx
|
||||
|
||||
or eax, eax
|
||||
jns @f
|
||||
mov byte[edi], '-'
|
||||
inc edi
|
||||
@@: call .recurse
|
||||
pop edx ecx
|
||||
ret
|
||||
or eax, eax
|
||||
jns @f
|
||||
mov byte[edi], '-'
|
||||
inc edi
|
||||
@@: call .recurse
|
||||
pop edx ecx
|
||||
ret
|
||||
|
||||
.recurse:
|
||||
cmp eax,ecx
|
||||
jb @f
|
||||
xor edx,edx
|
||||
div ecx
|
||||
push edx
|
||||
call .recurse
|
||||
pop eax
|
||||
@@: cmp al,10
|
||||
sbb al,0x69
|
||||
das
|
||||
stosb
|
||||
retn
|
||||
cmp eax,ecx
|
||||
jb @f
|
||||
xor edx,edx
|
||||
div ecx
|
||||
push edx
|
||||
call .recurse
|
||||
pop eax
|
||||
@@: cmp al,10
|
||||
sbb al,0x69
|
||||
das
|
||||
stosb
|
||||
retn
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
@@ -635,50 +639,50 @@ proc libini._.ascii_to_scan ;_ascii_code ;//////////////////////////////////////
|
||||
;< eax = 0 (error) / scancode (success) ;;
|
||||
;;================================================================================================;;
|
||||
; /sys/keymap.key
|
||||
sub esp, 256
|
||||
mov eax, esp
|
||||
push ebx
|
||||
push 'key'
|
||||
push 'map.'
|
||||
push '/key'
|
||||
push '/sys'
|
||||
push eax ; buffer in the stack
|
||||
push 0x100 ; read 0x100 bytes
|
||||
push 0
|
||||
push 0 ; from position zero
|
||||
push 0 ; subfunction: read
|
||||
mov ebx, esp
|
||||
push 70
|
||||
pop eax
|
||||
mcall
|
||||
add esp, 36
|
||||
pop ebx
|
||||
test eax, eax
|
||||
jnz .die
|
||||
mov al, [esp+256+4] ; get ASCII code
|
||||
push edi
|
||||
sub esp, 256
|
||||
mov eax, esp
|
||||
push ebx
|
||||
push 'key'
|
||||
push 'map.'
|
||||
push '/key'
|
||||
push '/sys'
|
||||
push eax ; buffer in the stack
|
||||
push 0x100 ; read 0x100 bytes
|
||||
push 0
|
||||
push 0 ; from position zero
|
||||
push 0 ; subfunction: read
|
||||
mov ebx, esp
|
||||
push 70
|
||||
pop eax
|
||||
mcall
|
||||
add esp, 36
|
||||
pop ebx
|
||||
test eax, eax
|
||||
jnz .die
|
||||
mov al, [esp+256+4] ; get ASCII code
|
||||
push edi
|
||||
; first keytable - no modifiers pressed
|
||||
; check scancodes from 1 to 36h (inclusive)
|
||||
lea edi, [esp+4+1]
|
||||
mov edx, edi
|
||||
mov ecx, 36h
|
||||
repnz scasb
|
||||
jz .found
|
||||
lea edi, [esp+4+1]
|
||||
mov edx, edi
|
||||
mov ecx, 36h
|
||||
repnz scasb
|
||||
jz .found
|
||||
; second keytable - Shift pressed
|
||||
lea edi, [esp+4+128+1]
|
||||
mov edx, edi
|
||||
mov ecx, 36h
|
||||
repnz scasb
|
||||
jz .found
|
||||
pop edi
|
||||
lea edi, [esp+4+128+1]
|
||||
mov edx, edi
|
||||
mov ecx, 36h
|
||||
repnz scasb
|
||||
jz .found
|
||||
pop edi
|
||||
.die:
|
||||
xor eax, eax
|
||||
jmp .ret
|
||||
xor eax, eax
|
||||
jmp .ret
|
||||
.found:
|
||||
mov eax, edi
|
||||
sub eax, edx
|
||||
pop edi
|
||||
mov eax, edi
|
||||
sub eax, edx
|
||||
pop edi
|
||||
.ret:
|
||||
add esp, 256
|
||||
ret 4
|
||||
add esp, 256
|
||||
ret 4
|
||||
endp
|
||||
|
||||
@@ -33,38 +33,39 @@ use_ColorDialog
|
||||
;--------------------------------------------------
|
||||
align 16
|
||||
lib_init:
|
||||
ret
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
;--------------------------------------------------
|
||||
align 16
|
||||
EXPORTS:
|
||||
|
||||
|
||||
dd sz_init, lib_init
|
||||
dd sz_version, 0x00000001
|
||||
dd sz_init, lib_init
|
||||
dd sz_version, 0x00000001
|
||||
|
||||
dd sz_OpenDialog_init, OpenDialog.init
|
||||
dd sz_OpenDialog_start, OpenDialog.start
|
||||
dd sz_OpenDialog_set_file_name, OpenDialog.set_file_name
|
||||
dd sz_OpenDialog_set_file_ext, OpenDialog.set_file_ext
|
||||
dd szVersion_OpenDialog, 0x00010001
|
||||
dd sz_OpenDialog_init, OpenDialog.init
|
||||
dd sz_OpenDialog_start, OpenDialog.start
|
||||
dd sz_OpenDialog_set_file_name, OpenDialog.set_file_name
|
||||
dd sz_OpenDialog_set_file_ext, OpenDialog.set_file_ext
|
||||
dd szVersion_OpenDialog, 0x00010001
|
||||
|
||||
dd sz_ColorDialog_init, ColorDialog.init
|
||||
dd sz_ColorDialog_start, ColorDialog.start
|
||||
dd szVersion_ColorDialog, 0x00010001
|
||||
dd sz_ColorDialog_init, ColorDialog.init
|
||||
dd sz_ColorDialog_start, ColorDialog.start
|
||||
dd szVersion_ColorDialog, 0x00010001
|
||||
|
||||
dd 0,0
|
||||
dd 0,0
|
||||
;-----------------------------------------------------------------------------
|
||||
sz_init db 'lib_init',0
|
||||
sz_version db 'version',0
|
||||
sz_init db 'lib_init',0
|
||||
sz_version db 'version',0
|
||||
|
||||
sz_OpenDialog_init db 'OpenDialog_init',0
|
||||
sz_OpenDialog_start db 'OpenDialog_start',0
|
||||
sz_OpenDialog_set_file_name db 'OpenDialog_set_file_name',0
|
||||
sz_OpenDialog_set_file_ext db 'OpenDialog_set_file_ext',0
|
||||
szVersion_OpenDialog db 'Version_OpenDialog',0
|
||||
sz_OpenDialog_init db 'OpenDialog_init',0
|
||||
sz_OpenDialog_start db 'OpenDialog_start',0
|
||||
sz_OpenDialog_set_file_name db 'OpenDialog_set_file_name',0
|
||||
sz_OpenDialog_set_file_ext db 'OpenDialog_set_file_ext',0
|
||||
szVersion_OpenDialog db 'Version_OpenDialog',0
|
||||
|
||||
sz_ColorDialog_init db 'ColorDialog_init',0
|
||||
sz_ColorDialog_start db 'ColorDialog_start',0
|
||||
szVersion_ColorDialog db 'Version_ColorDialog',0
|
||||
sz_ColorDialog_init db 'ColorDialog_init',0
|
||||
sz_ColorDialog_start db 'ColorDialog_start',0
|
||||
szVersion_ColorDialog db 'Version_ColorDialog',0
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
6
programs/emulator/uxn/.gitignore
vendored
Normal file
6
programs/emulator/uxn/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
# SPDX-FileCopyrightText: 2025 iyzsong@envs.net
|
||||
#
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
zig-out
|
||||
.zig-cache
|
||||
17
programs/emulator/uxn/README
Normal file
17
programs/emulator/uxn/README
Normal file
@@ -0,0 +1,17 @@
|
||||
// SPDX-FileCopyrightText: 2025 iyzsong@envs.net
|
||||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
Uxn/Varvara emulator for Kolibri OS
|
||||
|
||||
Based on https://github.com/chmod222/zuxn
|
||||
|
||||
compile: zig build --release=fast
|
||||
result: zig-out/bin/uxn
|
||||
run: uxn SOME.rom
|
||||
control:
|
||||
Up/Down/Left/Right
|
||||
Ctrl/Shift/Alt/Home
|
||||
F1: change scale (1x, 2x, 3x)
|
||||
|
||||
TODO: file/directory stat, audio latency, open dialog?
|
||||
36
programs/emulator/uxn/build.zig
Normal file
36
programs/emulator/uxn/build.zig
Normal file
@@ -0,0 +1,36 @@
|
||||
// SPDX-FileCopyrightText: 2025 iyzsong@envs.net
|
||||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const target_query = std.Target.Query{
|
||||
.cpu_arch = std.Target.Cpu.Arch.x86,
|
||||
.os_tag = std.Target.Os.Tag.freestanding,
|
||||
.abi = std.Target.Abi.none,
|
||||
.cpu_model = std.Target.Query.CpuModel{ .explicit = &std.Target.x86.cpu.i586 },
|
||||
};
|
||||
const target = b.resolveTargetQuery(target_query);
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
const zuxn = b.dependency("zuxn", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
const elf = b.addExecutable(.{
|
||||
.name = "uxn.elf",
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.unwind_tables = .none,
|
||||
});
|
||||
elf.root_module.addImport("uxn-core", zuxn.module("uxn-core"));
|
||||
elf.root_module.addImport("uxn-varvara", zuxn.module("uxn-varvara"));
|
||||
elf.setLinkerScript(b.path("src/linker.ld"));
|
||||
const bin = elf.addObjCopy(.{
|
||||
.format = .bin,
|
||||
});
|
||||
const install_bin = b.addInstallBinFile(bin.getOutput(), "uxn");
|
||||
b.getInstallStep().dependOn(&install_bin.step);
|
||||
b.installArtifact(elf);
|
||||
}
|
||||
21
programs/emulator/uxn/build.zig.zon
Normal file
21
programs/emulator/uxn/build.zig.zon
Normal file
@@ -0,0 +1,21 @@
|
||||
// SPDX-FileCopyrightText: 2025 iyzsong@envs.net
|
||||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
.{
|
||||
.name = .uxn_kolibrios,
|
||||
.version = "0.0.0",
|
||||
.fingerprint = 0x3aef20f25c0a0218,
|
||||
.minimum_zig_version = "0.14.0",
|
||||
.dependencies = .{
|
||||
.zuxn = .{
|
||||
.url = "git+https://github.com/chmod222/zuxn.git#fc3a76724fa87dd08039438b56fc326ac3d51e4d",
|
||||
.hash = "zuxn-0.0.1-XnoOpbqsAgD-fU6rv_AoLffA1utIzXuae2cmnHj6SzE6",
|
||||
},
|
||||
},
|
||||
.paths = .{
|
||||
"build.zig",
|
||||
"build.zig.zon",
|
||||
"src",
|
||||
},
|
||||
}
|
||||
604
programs/emulator/uxn/src/kolibri.zig
Normal file
604
programs/emulator/uxn/src/kolibri.zig
Normal file
@@ -0,0 +1,604 @@
|
||||
// SPDX-FileCopyrightText: 2025 iyzsong@envs.net
|
||||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
pub const SYS = enum(i32) {
|
||||
terminate_process = -1,
|
||||
create_window = 0,
|
||||
put_pixel = 1,
|
||||
get_key = 2,
|
||||
get_sys_time = 3,
|
||||
draw_text = 4,
|
||||
sleep = 5,
|
||||
put_image = 7,
|
||||
define_button = 8,
|
||||
thread_info = 9,
|
||||
wait_event = 10,
|
||||
check_event = 11,
|
||||
redraw = 12,
|
||||
draw_rect = 13,
|
||||
get_screen_size = 14,
|
||||
get_button = 17,
|
||||
system = 18,
|
||||
screen_put_image = 25,
|
||||
system_get = 26,
|
||||
get_sys_date = 29,
|
||||
mouse_get = 37,
|
||||
set_events_mask = 40,
|
||||
style_settings = 48,
|
||||
create_thread = 51,
|
||||
board = 63,
|
||||
keyboard = 66,
|
||||
change_window = 67,
|
||||
sys_misc = 68,
|
||||
file = 70,
|
||||
blitter = 73,
|
||||
};
|
||||
|
||||
pub const Event = enum(u32) {
|
||||
none = 0,
|
||||
redraw = 1,
|
||||
key = 2,
|
||||
button = 3,
|
||||
background = 5,
|
||||
mouse = 6,
|
||||
ipc = 7,
|
||||
};
|
||||
|
||||
pub inline fn syscall0(number: SYS) u32 {
|
||||
return asm volatile ("int $0x40"
|
||||
: [ret] "={eax}" (-> u32),
|
||||
: [number] "{eax}" (@intFromEnum(number)),
|
||||
);
|
||||
}
|
||||
|
||||
pub inline fn syscall1(number: SYS, arg1: u32) u32 {
|
||||
return asm volatile ("int $0x40"
|
||||
: [ret] "={eax}" (-> u32),
|
||||
: [number] "{eax}" (@intFromEnum(number)),
|
||||
[arg1] "{ebx}" (arg1),
|
||||
);
|
||||
}
|
||||
|
||||
pub inline fn syscall2(number: SYS, arg1: u32, arg2: u32) u32 {
|
||||
return asm volatile ("int $0x40"
|
||||
: [ret] "={eax}" (-> u32),
|
||||
: [number] "{eax}" (@intFromEnum(number)),
|
||||
[arg1] "{ebx}" (arg1),
|
||||
[arg2] "{ecx}" (arg2),
|
||||
);
|
||||
}
|
||||
|
||||
pub inline fn syscall3(number: SYS, arg1: u32, arg2: u32, arg3: u32) u32 {
|
||||
return asm volatile ("int $0x40"
|
||||
: [ret] "={eax}" (-> u32),
|
||||
: [number] "{eax}" (@intFromEnum(number)),
|
||||
[arg1] "{ebx}" (arg1),
|
||||
[arg2] "{ecx}" (arg2),
|
||||
[arg3] "{edx}" (arg3),
|
||||
);
|
||||
}
|
||||
|
||||
pub inline fn syscall4(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32) u32 {
|
||||
return asm volatile ("int $0x40"
|
||||
: [ret] "={eax}" (-> u32),
|
||||
: [number] "{eax}" (@intFromEnum(number)),
|
||||
[arg1] "{ebx}" (arg1),
|
||||
[arg2] "{ecx}" (arg2),
|
||||
[arg3] "{edx}" (arg3),
|
||||
[arg4] "{esi}" (arg4),
|
||||
);
|
||||
}
|
||||
|
||||
pub inline fn syscall5(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32, arg5: u32) u32 {
|
||||
return asm volatile ("int $0x40"
|
||||
: [ret] "={eax}" (-> u32),
|
||||
: [number] "{eax}" (@intFromEnum(number)),
|
||||
[arg1] "{ebx}" (arg1),
|
||||
[arg2] "{ecx}" (arg2),
|
||||
[arg3] "{edx}" (arg3),
|
||||
[arg4] "{esi}" (arg4),
|
||||
[arg5] "{edi}" (arg5),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn terminateProcess() noreturn {
|
||||
_ = syscall0(SYS.terminate_process);
|
||||
unreachable;
|
||||
}
|
||||
|
||||
pub const WindowFlags = struct {
|
||||
skinned: bool = true,
|
||||
fixed: bool = true,
|
||||
no_title: bool = false,
|
||||
relative_coordinates: bool = false,
|
||||
no_fill: bool = false,
|
||||
unmovable: bool = false,
|
||||
};
|
||||
|
||||
pub fn createWindow(x: u16, y: u16, width: u16, height: u16, bgcolor: u24, flags: WindowFlags, title: [*:0]const u8) void {
|
||||
var f1: u32 = 0x00000000;
|
||||
if (flags.no_fill)
|
||||
f1 |= 0x40000000;
|
||||
if (flags.relative_coordinates)
|
||||
f1 |= 0x20000000;
|
||||
if (!flags.no_title)
|
||||
f1 |= 0x10000000;
|
||||
if (flags.skinned) {
|
||||
if (flags.fixed) {
|
||||
f1 |= 0x04000000;
|
||||
} else {
|
||||
f1 |= 0x03000000;
|
||||
}
|
||||
} else {
|
||||
f1 |= 0x01000000;
|
||||
}
|
||||
var f2: u32 = 0x00000000;
|
||||
if (flags.unmovable)
|
||||
f2 = 0x01000000;
|
||||
_ = syscall5(SYS.create_window, @as(u32, x) * 0x10000 + width, @as(u32, y) * 0x10000 + height, f1 | @as(u32, bgcolor), f2 | @as(u32, bgcolor), @intFromPtr(title));
|
||||
}
|
||||
|
||||
pub fn putPixel(x: u16, y: u16, color: u24) void {
|
||||
_ = syscall3(SYS.put_pixel, x, y, color);
|
||||
}
|
||||
|
||||
pub fn invertPixel(x: u16, y: u16) void {
|
||||
_ = syscall3(SYS.put_pixel, x, y, 0x01000000);
|
||||
}
|
||||
|
||||
pub const Key = packed struct(u32) {
|
||||
_unused: u8 = 0,
|
||||
key: u8 = 0,
|
||||
scancode: u8 = 0,
|
||||
empty: u8 = 1,
|
||||
|
||||
pub fn pressed(self: *const Key) bool {
|
||||
return self.key & 0x80 > 0;
|
||||
}
|
||||
};
|
||||
|
||||
pub fn getKey() Key {
|
||||
return @bitCast(syscall0(SYS.get_key));
|
||||
}
|
||||
|
||||
pub fn getSysTime() u24 {
|
||||
return @intCast(syscall0(SYS.get_sys_time));
|
||||
}
|
||||
|
||||
pub fn getButton() u32 {
|
||||
return syscall0(SYS.get_button);
|
||||
}
|
||||
|
||||
pub fn terminateThreadId(id: u32) void {
|
||||
_ = syscall2(SYS.system, 18, id);
|
||||
}
|
||||
|
||||
pub fn drawText(x: u16, y: u16, color: u24, text: [*:0]const u8) void {
|
||||
_ = syscall5(SYS.draw_text, @as(u32, x) * 0x10000 + y, 0x80000000 | @as(u32, color), @intFromPtr(text), 0, 0);
|
||||
}
|
||||
|
||||
pub fn sleep(centisecond: u32) void {
|
||||
_ = syscall1(SYS.sleep, centisecond);
|
||||
}
|
||||
|
||||
pub fn beginDraw() void {
|
||||
_ = syscall1(SYS.redraw, 1);
|
||||
}
|
||||
|
||||
pub fn endDraw() void {
|
||||
_ = syscall1(SYS.redraw, 2);
|
||||
}
|
||||
|
||||
pub fn putImage(image: [*]const u8, width: u16, height: u16, x: u16, y: u16) void {
|
||||
_ = syscall3(SYS.put_image, @intFromPtr(image), @as(u32, width) * 0x10000 + height, @as(u32, x) * 0x10000 + y);
|
||||
}
|
||||
|
||||
pub fn drawRect(x: u16, y: u16, width: u16, height: u16, color: u24) void {
|
||||
_ = syscall3(SYS.draw_rect, @as(u32, x) * 0x10000 + width, @as(u32, y) * 0x10000 + height, color);
|
||||
}
|
||||
|
||||
pub fn getScreenSize() packed struct(u32) { height: u16, width: u16 } {
|
||||
return @bitCast(syscall0(SYS.get_screen_size));
|
||||
}
|
||||
|
||||
pub fn waitEvent() Event {
|
||||
return @enumFromInt(syscall0(SYS.wait_event));
|
||||
}
|
||||
|
||||
pub fn checkEvent() Event {
|
||||
return @enumFromInt(syscall0(SYS.check_event));
|
||||
}
|
||||
|
||||
pub fn createThread(entry: *const fn () void, stack: []u8) u32 {
|
||||
return syscall3(SYS.create_thread, 1, @intFromPtr(entry), @intFromPtr(stack.ptr) + stack.len);
|
||||
}
|
||||
|
||||
pub fn debugWrite(byte: u8) void {
|
||||
_ = syscall2(SYS.board, 1, byte);
|
||||
}
|
||||
|
||||
pub fn debugWriteText(bytes: []const u8) void {
|
||||
for (bytes) |byte| {
|
||||
debugWrite(byte);
|
||||
}
|
||||
}
|
||||
|
||||
pub const EventsMask = packed struct(u32) {
|
||||
redraw: bool = true, // 0
|
||||
key: bool = true,
|
||||
button: bool = true,
|
||||
_reserved: bool = false,
|
||||
background: bool = false,
|
||||
mouse: bool = false,
|
||||
ipc: bool = false,
|
||||
network: bool = false,
|
||||
debug: bool = false,
|
||||
_unused: u23 = 0,
|
||||
};
|
||||
|
||||
pub fn setEventsMask(mask: EventsMask) EventsMask {
|
||||
return @bitCast(syscall1(SYS.set_events_mask, @bitCast(mask)));
|
||||
}
|
||||
|
||||
pub fn getSkinHeight() u16 {
|
||||
return @intCast(syscall1(SYS.style_settings, 4));
|
||||
}
|
||||
|
||||
pub fn screenPutImage(image: [*]const u32, width: u16, height: u16, x: u16, y: u16) void {
|
||||
_ = syscall3(SYS.screen_put_image, @intFromPtr(image), @as(u32, width) * 0x10000 + height, @as(u32, x) * 0x10000 + y);
|
||||
}
|
||||
|
||||
pub fn systemGetTimeCount() u32 {
|
||||
return syscall1(SYS.system_get, 9);
|
||||
}
|
||||
|
||||
pub fn getSysDate() u24 {
|
||||
return @intCast(syscall0(SYS.get_sys_date));
|
||||
}
|
||||
|
||||
pub fn mouseGetScreenPosition() packed struct(u32) { y: u16, x: u16 } {
|
||||
return @bitCast(syscall1(SYS.mouse_get, 0));
|
||||
}
|
||||
|
||||
pub fn mouseGetWindowPosition() packed struct(u32) { y: u16, x: u16 } {
|
||||
return @bitCast(syscall1(SYS.mouse_get, 1));
|
||||
}
|
||||
|
||||
pub fn loadCursorIndirect(image: *const [32 * 32]u32, spotx: u5, spoty: u5) u32 {
|
||||
return syscall3(SYS.mouse_get, 4, @intFromPtr(image), 0x0002 | (@as(u32, spotx) << 24) | (@as(u32, spoty) << 16));
|
||||
}
|
||||
|
||||
pub fn setCursor(cursor: u32) u32 {
|
||||
return syscall2(SYS.mouse_get, 5, cursor);
|
||||
}
|
||||
|
||||
pub const MouseEvents = packed struct(u32) {
|
||||
left_hold: bool = false,
|
||||
right_hold: bool = false,
|
||||
middle_hold: bool = false,
|
||||
button4_hold: bool = false,
|
||||
button5_hold: bool = false,
|
||||
_unused0: u3 = 0,
|
||||
left_pressed: bool = false,
|
||||
right_pressed: bool = false,
|
||||
middle_pressed: bool = false,
|
||||
_unused1: u4 = 0,
|
||||
vertical_scroll: bool = false,
|
||||
left_released: bool = false,
|
||||
right_released: bool = false,
|
||||
middle_released: bool = false,
|
||||
_unused2: u4 = 0,
|
||||
horizontal_scroll: bool = false,
|
||||
left_double_clicked: bool = false,
|
||||
_unused3: u7 = 0,
|
||||
};
|
||||
|
||||
pub fn mouseGetEvents() MouseEvents {
|
||||
return @bitCast(syscall1(SYS.mouse_get, 3));
|
||||
}
|
||||
|
||||
pub fn heapInit() u32 {
|
||||
return syscall1(SYS.sys_misc, 11);
|
||||
}
|
||||
|
||||
pub fn memAlloc(size: u32) *anyopaque {
|
||||
return @ptrFromInt(syscall2(SYS.sys_misc, 12, size));
|
||||
}
|
||||
|
||||
pub fn memFree(ptr: *anyopaque) void {
|
||||
_ = syscall2(SYS.sys_misc, 13, @intFromPtr(ptr));
|
||||
}
|
||||
|
||||
pub fn memRealloc(size: u32, ptr: *anyopaque) *anyopaque {
|
||||
return @ptrFromInt(syscall3(SYS.sys_misc, 20, size, @intFromPtr(ptr)));
|
||||
}
|
||||
|
||||
fn alloc(ctx: *anyopaque, len: usize, alignment: std.mem.Alignment, ret_addr: usize) ?[*]u8 {
|
||||
_ = ctx;
|
||||
_ = alignment;
|
||||
_ = ret_addr;
|
||||
return @ptrCast(memAlloc(len));
|
||||
}
|
||||
|
||||
fn free(ctx: *anyopaque, memory: []u8, alignment: std.mem.Alignment, ret_addr: usize) void {
|
||||
_ = ctx;
|
||||
_ = alignment;
|
||||
_ = ret_addr;
|
||||
memFree(@ptrCast(memory.ptr));
|
||||
}
|
||||
|
||||
fn resize(ctx: *anyopaque, memory: []u8, alignment: std.mem.Alignment, new_len: usize, ret_addr: usize) bool {
|
||||
_ = ctx;
|
||||
_ = alignment;
|
||||
_ = ret_addr;
|
||||
_ = memRealloc(new_len, @ptrCast(memory.ptr));
|
||||
return true;
|
||||
}
|
||||
|
||||
fn remap(ctx: *anyopaque, memory: []u8, alignment: std.mem.Alignment, new_len: usize, ret_addr: usize) ?[*]u8 {
|
||||
_ = ctx;
|
||||
_ = memory;
|
||||
_ = alignment;
|
||||
_ = new_len;
|
||||
_ = ret_addr;
|
||||
return null;
|
||||
}
|
||||
|
||||
pub const allocator: std.mem.Allocator = .{
|
||||
.ptr = undefined,
|
||||
.vtable = &.{
|
||||
.alloc = alloc,
|
||||
.free = free,
|
||||
.resize = resize,
|
||||
.remap = remap,
|
||||
},
|
||||
};
|
||||
|
||||
pub fn loadDriver(name: [*:0]const u8) u32 {
|
||||
return syscall2(SYS.sys_misc, 16, @intFromPtr(name));
|
||||
}
|
||||
|
||||
pub fn controlDriver(drv: u32, func: u32, in: ?[]const u32, out: ?[]const *anyopaque) u32 {
|
||||
const ioctl: packed struct(u192) {
|
||||
drv: u32,
|
||||
func: u32,
|
||||
inptr: u32,
|
||||
insize: u32,
|
||||
outptr: u32,
|
||||
outsize: u32,
|
||||
} = .{
|
||||
.drv = drv,
|
||||
.func = func,
|
||||
.inptr = if (in) |v| @intFromPtr(v.ptr) else 0,
|
||||
.insize = if (in) |v| v.len * 4 else 0,
|
||||
.outptr = if (out) |v| @intFromPtr(v.ptr) else 0,
|
||||
.outsize = if (out) |v| v.len * 4 else 0,
|
||||
};
|
||||
return syscall2(SYS.sys_misc, 17, @intFromPtr(&ioctl));
|
||||
}
|
||||
|
||||
pub const Signal = packed struct(u192) {
|
||||
kind: u32,
|
||||
data0: u32,
|
||||
data1: u32,
|
||||
data2: u32,
|
||||
data3: u32,
|
||||
data4: u32,
|
||||
};
|
||||
|
||||
pub fn waitSignal(sig: *Signal) void {
|
||||
_ = syscall2(SYS.sys_misc, 14, @intFromPtr(sig));
|
||||
}
|
||||
|
||||
pub const Sound = struct {
|
||||
drv: u32,
|
||||
|
||||
pub const Buffer = struct {
|
||||
drv: u32,
|
||||
handle: u32,
|
||||
|
||||
pub fn play(self: *const Buffer, flags: u32) void {
|
||||
_ = controlDriver(self.drv, 10, &.{ self.handle, flags }, null);
|
||||
}
|
||||
|
||||
pub fn set(self: *const Buffer, src: []u8, offset: u32) void {
|
||||
_ = controlDriver(self.drv, 8, &.{ self.handle, @intFromPtr(src.ptr), offset, src.len }, null);
|
||||
}
|
||||
};
|
||||
|
||||
pub fn init() Sound {
|
||||
return .{
|
||||
.drv = loadDriver("INFINITY"),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn createBuffer(self: *const Sound, format: u32, size: u32) Buffer {
|
||||
var ret: u32 = 0;
|
||||
_ = controlDriver(self.drv, 1, &.{ format, size }, &.{&ret});
|
||||
return .{
|
||||
.drv = self.drv,
|
||||
.handle = ret,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
pub const InputMode = enum(u32) {
|
||||
normal = 0,
|
||||
scancodes = 1,
|
||||
};
|
||||
|
||||
pub fn setInputMode(mode: InputMode) void {
|
||||
_ = syscall2(SYS.keyboard, 1, @intFromEnum(mode));
|
||||
}
|
||||
|
||||
pub fn changeWindow(x: u32, y: u32, width: u32, height: u32) void {
|
||||
_ = syscall4(SYS.change_window, x, y, width, height);
|
||||
}
|
||||
|
||||
pub const ControlKeys = packed struct(u32) {
|
||||
left_shift: bool,
|
||||
right_shift: bool,
|
||||
left_ctrl: bool,
|
||||
right_ctrl: bool,
|
||||
left_alt: bool,
|
||||
right_alt: bool,
|
||||
caps_lock: bool,
|
||||
num_lock: bool,
|
||||
scroll_lock: bool,
|
||||
left_win: bool,
|
||||
right_win: bool,
|
||||
_unused: u21,
|
||||
};
|
||||
|
||||
pub fn getControlKeys() ControlKeys {
|
||||
return @bitCast(syscall1(SYS.keyboard, 3));
|
||||
}
|
||||
|
||||
const FileInfo = packed struct(u200) {
|
||||
subfn: u32,
|
||||
offset: u64,
|
||||
size: u32,
|
||||
buffer: u32,
|
||||
path0: u8 = 0,
|
||||
pathptr: *const u8,
|
||||
};
|
||||
|
||||
pub fn readFile(pathname: [*:0]const u8, offset: u64, buffer: []u8) !u32 {
|
||||
const info: FileInfo = .{
|
||||
.subfn = 0,
|
||||
.offset = offset,
|
||||
.size = buffer.len,
|
||||
.buffer = @intFromPtr(buffer.ptr),
|
||||
.pathptr = @ptrCast(pathname),
|
||||
};
|
||||
const err = asm volatile ("int $0x40"
|
||||
: [ret] "={eax}" (-> u32),
|
||||
: [number] "{eax}" (SYS.file),
|
||||
[info] "{ebx}" (&info),
|
||||
);
|
||||
const size = asm volatile (""
|
||||
: [ret] "={ebx}" (-> u32),
|
||||
);
|
||||
return switch (err) {
|
||||
0 => size,
|
||||
10 => error.AccessDenied,
|
||||
6 => size,
|
||||
else => error.Unexpected,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn createFile(pathname: [*:0]const u8, buffer: []u8) !u32 {
|
||||
const info: FileInfo = .{
|
||||
.subfn = 2,
|
||||
.offset = 0,
|
||||
.size = buffer.len,
|
||||
.buffer = @intFromPtr(buffer.ptr),
|
||||
.pathptr = @ptrCast(pathname),
|
||||
};
|
||||
const err = asm volatile ("int $0x40"
|
||||
: [ret] "={eax}" (-> u32),
|
||||
: [number] "{eax}" (SYS.file),
|
||||
[info] "{ebx}" (&info),
|
||||
);
|
||||
const size = asm volatile (""
|
||||
: [ret] "={ebx}" (-> u32),
|
||||
);
|
||||
return switch (err) {
|
||||
0 => size,
|
||||
10 => error.AccessDenied,
|
||||
8 => size,
|
||||
else => error.Unexpected,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn writeFile(pathname: [*:0]const u8, offset: u64, buffer: []u8) !u32 {
|
||||
const info: FileInfo = .{
|
||||
.subfn = 3,
|
||||
.offset = offset,
|
||||
.size = buffer.len,
|
||||
.buffer = @intFromPtr(buffer.ptr),
|
||||
.pathptr = @ptrCast(pathname),
|
||||
};
|
||||
const err = asm volatile ("int $0x40"
|
||||
: [ret] "={eax}" (-> u32),
|
||||
: [number] "{eax}" (SYS.file),
|
||||
[info] "{ebx}" (&info),
|
||||
);
|
||||
const size = asm volatile (""
|
||||
: [ret] "={ebx}" (-> u32),
|
||||
);
|
||||
return switch (err) {
|
||||
0 => size,
|
||||
10 => error.AccessDenied,
|
||||
5 => error.FileNotFound,
|
||||
else => error.Unexpected,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn fileGetSize(pathname: [*:0]const u8) !u64 {
|
||||
var ret: [10]u32 = undefined;
|
||||
const info: FileInfo = .{
|
||||
.subfn = 5,
|
||||
.offset = 0,
|
||||
.size = 0,
|
||||
.buffer = @intFromPtr(&ret),
|
||||
.pathptr = @ptrCast(pathname),
|
||||
};
|
||||
if (syscall1(SYS.file, @intFromPtr(&info)) != 0)
|
||||
return error.Unexpected;
|
||||
return ret[8] | (@as(u64, ret[9]) << 32);
|
||||
}
|
||||
|
||||
pub fn deleteFile(pathname: [*:0]const u8) !void {
|
||||
const info: FileInfo = .{
|
||||
.subfn = 8,
|
||||
.offset = 0,
|
||||
.size = 0,
|
||||
.buffer = 0,
|
||||
.pathptr = @ptrCast(pathname),
|
||||
};
|
||||
const err = syscall1(SYS.file, @intFromPtr(&info));
|
||||
if (err != 0)
|
||||
return error.Unexpected;
|
||||
}
|
||||
|
||||
pub const File = struct {
|
||||
pathname: [*:0]const u8,
|
||||
offset: u64 = 0,
|
||||
|
||||
pub fn reader(file: *File) std.io.GenericReader(*File, anyerror, struct {
|
||||
fn read(context: *File, buffer: []u8) !usize {
|
||||
const size = try readFile(context.pathname, context.offset, buffer);
|
||||
context.offset += size;
|
||||
return size;
|
||||
}
|
||||
}.read) {
|
||||
return .{ .context = file };
|
||||
}
|
||||
};
|
||||
|
||||
pub const BlitterFlags = packed struct(u32) {
|
||||
rop: u4 = 0,
|
||||
background: bool = false,
|
||||
transparent: bool = false,
|
||||
reserved1: u23 = 0,
|
||||
client_relative: bool = true,
|
||||
reserved2: u2 = 0,
|
||||
};
|
||||
|
||||
pub fn blitter(dstx: u32, dsty: u32, dstw: u32, dsth: u32, srcx: u32, srcy: u32, srcw: u32, srch: u32, src: *const u8, pitch: u32, flags: BlitterFlags) void {
|
||||
_ = syscall2(SYS.blitter, @bitCast(flags), @intFromPtr(&[_]u32{ dstx, dsty, dstw, dsth, srcx, srcy, srcw, srch, @intFromPtr(src), pitch }));
|
||||
}
|
||||
|
||||
pub const DebugWriter = std.io.GenericWriter(void, anyerror, struct {
|
||||
fn write(context: void, bytes: []const u8) !usize {
|
||||
_ = context;
|
||||
debugWriteText(bytes);
|
||||
return bytes.len;
|
||||
}
|
||||
}.write);
|
||||
|
||||
pub const debug_writer: DebugWriter = .{ .context = {} };
|
||||
42
programs/emulator/uxn/src/linker.ld
Normal file
42
programs/emulator/uxn/src/linker.ld
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 iyzsong@envs.net
|
||||
*
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text 0x00000000 :
|
||||
{
|
||||
/* MENUET01 header */
|
||||
LONG(0x554e454d);
|
||||
LONG(0x31305445);
|
||||
LONG(1);
|
||||
LONG(_start);
|
||||
LONG(_image_end);
|
||||
LONG(_memory_end);
|
||||
LONG(_stack_top);
|
||||
LONG(_cmdline);
|
||||
LONG(0);
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
}
|
||||
.rodata : ALIGN(8)
|
||||
{
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
}
|
||||
.data : ALIGN(8)
|
||||
{
|
||||
*(.data)
|
||||
}
|
||||
_image_end = .;
|
||||
|
||||
.bss : ALIGN(8)
|
||||
{
|
||||
*(.bss)
|
||||
. = . + 4K;
|
||||
_stack_top = .;
|
||||
}
|
||||
_memory_end = .;
|
||||
}
|
||||
418
programs/emulator/uxn/src/main.zig
Normal file
418
programs/emulator/uxn/src/main.zig
Normal file
@@ -0,0 +1,418 @@
|
||||
// SPDX-FileCopyrightText: 2025 iyzsong@envs.net
|
||||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
const std = @import("std");
|
||||
const kos = @import("kolibri.zig");
|
||||
const uxn = @import("uxn-core");
|
||||
const varvara = @import("uxn-varvara");
|
||||
|
||||
const allocator = kos.allocator;
|
||||
export var _cmdline: [1024]u8 = undefined;
|
||||
|
||||
pub const std_options: std.Options = .{
|
||||
.log_level = .info,
|
||||
.logFn = struct {
|
||||
fn log(comptime level: std.log.Level, comptime scope: @Type(.enum_literal), comptime format: []const u8, args: anytype) void {
|
||||
_ = level;
|
||||
_ = scope;
|
||||
kos.debug_writer.print(format, args) catch return;
|
||||
}
|
||||
}.log,
|
||||
};
|
||||
|
||||
const VarvaraDefault = varvara.VarvaraSystem(kos.DebugWriter, kos.DebugWriter);
|
||||
const emu = struct {
|
||||
var cpu: uxn.Cpu = undefined;
|
||||
var sys: VarvaraDefault = undefined;
|
||||
var rom: *[0x10000]u8 = undefined;
|
||||
var pixels: []u8 = undefined;
|
||||
var screen_width: u32 = undefined;
|
||||
var screen_height: u32 = undefined;
|
||||
var null_cursor: u32 = undefined;
|
||||
var hide_cursor: bool = false;
|
||||
var audio_thread: ?u32 = null;
|
||||
var scale: u4 = 1;
|
||||
|
||||
fn init(rompath: [*:0]const u8) !void {
|
||||
const screen = &emu.sys.screen_device;
|
||||
var rom_file = kos.File{ .pathname = rompath };
|
||||
emu.rom = try uxn.loadRom(allocator, rom_file.reader());
|
||||
emu.cpu = uxn.Cpu.init(emu.rom);
|
||||
emu.sys = try VarvaraDefault.init(allocator, kos.debug_writer, kos.debug_writer);
|
||||
emu.cpu.device_intercept = struct {
|
||||
var file_offsets: [2]u64 = .{ 0, 0 };
|
||||
|
||||
fn bcd8(x: u8) u8 {
|
||||
return (x & 0xf) + 10 * ((x & 0xf0) >> 4);
|
||||
}
|
||||
|
||||
fn getFilePortSlice(dev: *varvara.file.File, comptime port: comptime_int) []u8 {
|
||||
const ports = varvara.file.ports;
|
||||
const ptr: usize = dev.loadPort(u16, &cpu, port);
|
||||
|
||||
return if (port == ports.name)
|
||||
std.mem.sliceTo(cpu.mem[ptr..], 0x00)
|
||||
else
|
||||
return cpu.mem[ptr..ptr +| dev.loadPort(u16, &cpu, ports.length)];
|
||||
}
|
||||
|
||||
pub fn intercept(self: *uxn.Cpu, addr: u8, kind: uxn.Cpu.InterceptKind, data: ?*anyopaque) !void {
|
||||
_ = data;
|
||||
const port: u4 = @truncate(addr & 0x0f);
|
||||
if (audio_thread == null and addr >= 0x30 and addr < 0x70) {
|
||||
audio_thread = kos.createThread(&audio, allocator.alloc(u8, 32 * 1024) catch unreachable);
|
||||
}
|
||||
switch (addr >> 4) {
|
||||
0xa, 0xb => {
|
||||
if (kind != .output)
|
||||
return;
|
||||
|
||||
const idx = (addr >> 4) - 0xa;
|
||||
const dev = &sys.file_devices[idx];
|
||||
const ports = varvara.file.ports;
|
||||
switch (port) {
|
||||
ports.stat + 1 => {
|
||||
// TODO: file/directory stat
|
||||
dev.storePort(u16, &cpu, ports.success, 0);
|
||||
},
|
||||
ports.delete => {
|
||||
const name_slice = getFilePortSlice(dev, ports.name);
|
||||
_ = kos.deleteFile(@ptrCast(name_slice)) catch {};
|
||||
dev.storePort(u16, &cpu, ports.success, 0);
|
||||
},
|
||||
ports.name + 1 => {
|
||||
file_offsets[idx] = 0;
|
||||
dev.storePort(u16, &cpu, ports.success, 1);
|
||||
},
|
||||
ports.read + 1 => {
|
||||
const name_slice = getFilePortSlice(dev, ports.name);
|
||||
const data_slice = getFilePortSlice(dev, ports.read);
|
||||
const ret: u32 = kos.readFile(@ptrCast(name_slice), file_offsets[idx], data_slice) catch 0;
|
||||
file_offsets[idx] += ret;
|
||||
dev.storePort(u16, &cpu, ports.success, @intCast(ret));
|
||||
},
|
||||
ports.write + 1 => {
|
||||
const append = dev.loadPort(u8, &cpu, ports.append) == 0x01;
|
||||
const pathname: [*:0]const u8 = @ptrCast(getFilePortSlice(dev, ports.name));
|
||||
const buffer = getFilePortSlice(dev, ports.write);
|
||||
var ret: u32 = 0;
|
||||
if (append) {
|
||||
const offset: u32 = @intCast(kos.fileGetSize(pathname) catch 0);
|
||||
ret = kos.writeFile(pathname, offset, buffer) catch |err| blk: {
|
||||
if (err == error.FileNotFound) {
|
||||
break :blk kos.createFile(pathname, buffer) catch 0;
|
||||
} else {
|
||||
break :blk 0;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
ret = kos.createFile(pathname, buffer) catch 0;
|
||||
}
|
||||
dev.storePort(u16, &cpu, ports.success, @intCast(ret));
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
},
|
||||
0xc => {
|
||||
if (kind != .input)
|
||||
return;
|
||||
|
||||
const dev = &sys.datetime_device;
|
||||
const date = kos.getSysDate();
|
||||
const time = kos.getSysTime();
|
||||
switch (port) {
|
||||
0x0, 0x1 => {
|
||||
const year: u8 = bcd8(@truncate(date & 0xff));
|
||||
dev.storePort(u16, &cpu, 0x0, @as(u16, 2000) + bcd8(year));
|
||||
},
|
||||
0x02 => {
|
||||
const month: u8 = bcd8(@truncate((date & 0xff00) >> 8));
|
||||
dev.storePort(u8, &cpu, port, month);
|
||||
},
|
||||
0x03 => {
|
||||
const day: u8 = bcd8(@truncate((date & 0xff0000) >> 16));
|
||||
dev.storePort(u8, &cpu, port, day);
|
||||
},
|
||||
0x04 => {
|
||||
const hour: u8 = bcd8(@truncate(time & 0xff));
|
||||
dev.storePort(u8, &cpu, port, hour);
|
||||
},
|
||||
0x05 => {
|
||||
const minute: u8 = bcd8(@truncate((time & 0xff00) >> 8));
|
||||
dev.storePort(u8, &cpu, port, minute);
|
||||
},
|
||||
0x06 => {
|
||||
const second: u8 = bcd8(@truncate((time & 0xff0000) >> 16));
|
||||
dev.storePort(u8, &cpu, port, second);
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
},
|
||||
else => try emu.sys.intercept(self, addr, kind),
|
||||
}
|
||||
}
|
||||
}.intercept;
|
||||
emu.cpu.output_intercepts = varvara.full_intercepts.output;
|
||||
emu.cpu.input_intercepts = varvara.full_intercepts.input;
|
||||
|
||||
try emu.cpu.evaluateVector(0x0100);
|
||||
screen_width = screen.width * emu.scale;
|
||||
screen_height = screen.height * emu.scale;
|
||||
emu.pixels = try allocator.alloc(u8, @as(usize, 4) * screen_width * screen_height);
|
||||
}
|
||||
|
||||
fn exit() void {
|
||||
if (audio_thread) |tid| {
|
||||
kos.terminateThreadId(tid);
|
||||
}
|
||||
kos.terminateProcess();
|
||||
}
|
||||
|
||||
fn audio() void {
|
||||
var samples: [8192]i16 = undefined;
|
||||
var sig: kos.Signal = undefined;
|
||||
const buf = kos.Sound.init().createBuffer(3 | 0x10000000, 0);
|
||||
buf.play(0);
|
||||
while (true) {
|
||||
kos.waitSignal(&sig);
|
||||
if (sig.kind != 0xFF000001) continue;
|
||||
@memset(&samples, 0);
|
||||
for (0..samples.len / 512) |i| {
|
||||
const w = samples[i * 512 .. (i + 1) * 512];
|
||||
for (&sys.audio_devices) |*poly| {
|
||||
if (poly.duration <= 0) {
|
||||
poly.evaluateFinishVector(&cpu) catch unreachable;
|
||||
}
|
||||
poly.updateDuration();
|
||||
poly.renderAudio(w);
|
||||
}
|
||||
}
|
||||
for (0..samples.len) |i| {
|
||||
samples[i] <<= 6;
|
||||
}
|
||||
buf.set(@ptrCast(&samples), sig.data2);
|
||||
}
|
||||
}
|
||||
|
||||
fn update() !void {
|
||||
const screen = &sys.screen_device;
|
||||
const colors = &sys.system_device.colors;
|
||||
if (sys.system_device.exit_code) |_| {
|
||||
exit();
|
||||
}
|
||||
if (screen_width != screen.width * scale or screen_height != screen.height * scale) {
|
||||
const skin_height = kos.getSkinHeight();
|
||||
allocator.free(emu.pixels);
|
||||
screen_width = screen.width * scale;
|
||||
screen_height = screen.height * scale;
|
||||
emu.pixels = try allocator.alloc(u8, @as(usize, 4) * screen_width * screen_height);
|
||||
kos.changeWindow(100, 100, screen_width + 9, screen_height + skin_height + 4);
|
||||
}
|
||||
try screen.evaluateFrame(&cpu);
|
||||
if (screen.dirty_region) |region| {
|
||||
for (region.y0..region.y1) |y| {
|
||||
for (region.x0..region.x1) |x| {
|
||||
const idx = y * screen.width + x;
|
||||
const pal = (@as(u4, screen.foreground[idx]) << 2) | screen.background[idx];
|
||||
const color = colors[if ((pal >> 2) > 0) (pal >> 2) else (pal & 0x3)];
|
||||
for (0..scale) |sy| {
|
||||
for (0..scale) |sx| {
|
||||
pixels[4 * ((y * scale + sy) * screen.width * scale + (x * scale + sx)) + 2] = color.r;
|
||||
pixels[4 * ((y * scale + sy) * screen.width * scale + (x * scale + sx)) + 1] = color.g;
|
||||
pixels[4 * ((y * scale + sy) * screen.width * scale + (x * scale + sx)) + 0] = color.b;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const ix = region.x0 * scale;
|
||||
const iy = region.y0 * scale;
|
||||
const iw = (region.x1 - region.x0) * scale;
|
||||
const ih = (region.y1 - region.y0) * scale;
|
||||
kos.blitter(ix, iy, iw, ih, ix, iy, iw, ih, @ptrCast(emu.pixels.ptr), screen.width * scale * 4, .{});
|
||||
screen.dirty_region = null;
|
||||
}
|
||||
}
|
||||
|
||||
fn changeScale() void {
|
||||
const screen = &sys.screen_device;
|
||||
scale = switch (scale) {
|
||||
1 => 2,
|
||||
2 => 3,
|
||||
3 => 1,
|
||||
else => 1,
|
||||
};
|
||||
screen.forceRedraw();
|
||||
}
|
||||
};
|
||||
|
||||
export fn _start() noreturn {
|
||||
const cursor: [32 * 32]u32 = .{0} ** (32 * 32);
|
||||
var counter: u32 = 0;
|
||||
var last_tick = kos.systemGetTimeCount();
|
||||
|
||||
_ = kos.heapInit();
|
||||
_ = kos.setEventsMask(.{ .mouse = true });
|
||||
kos.setInputMode(.scancodes);
|
||||
emu.null_cursor = kos.loadCursorIndirect(&cursor, 0, 0);
|
||||
emu.init(@ptrCast(&_cmdline)) catch unreachable;
|
||||
|
||||
const screen = &emu.sys.screen_device;
|
||||
const controller = &emu.sys.controller_device;
|
||||
|
||||
const callbacks = struct {
|
||||
fn redraw() void {
|
||||
const skin_height = kos.getSkinHeight();
|
||||
kos.beginDraw();
|
||||
kos.createWindow(300, 300, screen.width * emu.scale + 9, screen.height * emu.scale + skin_height + 4, 0x000000, .{ .skinned = true, .no_fill = true, .relative_coordinates = true }, "UXN");
|
||||
kos.endDraw();
|
||||
}
|
||||
|
||||
fn key() void {
|
||||
const symtab: [0x80]u8 = .{
|
||||
// 0x0*
|
||||
0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 8, '\t',
|
||||
// 0x1*
|
||||
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\r', 0, 'a', 's',
|
||||
// 0x2*
|
||||
'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 0, '\\', 'z', 'x', 'c', 'v',
|
||||
// 0x3*
|
||||
'b', 'n', 'm', ',', '.', '/', 0, 0, 0, ' ', 0, 0, 0, 0, 0, 0,
|
||||
// 0x00* + SHIFT
|
||||
0, 27, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', 8, '\t',
|
||||
// 0x10* + SHIFT
|
||||
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\r', 0, 'A', 'S',
|
||||
// 0x20* + SHIFT
|
||||
'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~', 0, '|', 'Z', 'X', 'C', 'V',
|
||||
// 0x30* + SHIFT,
|
||||
'B', 'N', 'M', '<', '>', '?', 0, 0, 0, ' ', 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
const scancode1 = kos.getKey().key;
|
||||
const input: ?union(enum) {
|
||||
button: struct {
|
||||
flags: varvara.controller.ButtonFlags,
|
||||
pressed: bool,
|
||||
},
|
||||
key: u8,
|
||||
} = switch (scancode1) {
|
||||
0xe0 => blk: {
|
||||
const scancode2 = kos.getKey().key;
|
||||
break :blk switch (scancode2) {
|
||||
0x1d => .{ .button = .{ .flags = .{ .ctrl = true }, .pressed = true } },
|
||||
0x9d => .{ .button = .{ .flags = .{ .ctrl = true }, .pressed = false } },
|
||||
0x38 => .{ .button = .{ .flags = .{ .alt = true }, .pressed = true } },
|
||||
0xb8 => .{ .button = .{ .flags = .{ .alt = true }, .pressed = false } },
|
||||
0x47 => .{ .button = .{ .flags = .{ .start = true }, .pressed = true } },
|
||||
0xc7 => .{ .button = .{ .flags = .{ .start = true }, .pressed = false } },
|
||||
0x48 => .{ .button = .{ .flags = .{ .up = true }, .pressed = true } },
|
||||
0xc8 => .{ .button = .{ .flags = .{ .up = true }, .pressed = false } },
|
||||
0x50 => .{ .button = .{ .flags = .{ .down = true }, .pressed = true } },
|
||||
0xd0 => .{ .button = .{ .flags = .{ .down = true }, .pressed = false } },
|
||||
0x4b => .{ .button = .{ .flags = .{ .left = true }, .pressed = true } },
|
||||
0xcb => .{ .button = .{ .flags = .{ .left = true }, .pressed = false } },
|
||||
0x4d => .{ .button = .{ .flags = .{ .right = true }, .pressed = true } },
|
||||
0xcd => .{ .button = .{ .flags = .{ .right = true }, .pressed = false } },
|
||||
else => null,
|
||||
};
|
||||
},
|
||||
0x3b => blk: {
|
||||
emu.changeScale();
|
||||
break :blk null;
|
||||
},
|
||||
0x1d => .{ .button = .{ .flags = .{ .ctrl = true }, .pressed = true } },
|
||||
0x9d => .{ .button = .{ .flags = .{ .ctrl = true }, .pressed = false } },
|
||||
0x38 => .{ .button = .{ .flags = .{ .alt = true }, .pressed = true } },
|
||||
0xb8 => .{ .button = .{ .flags = .{ .alt = true }, .pressed = false } },
|
||||
0x2a, 0x36 => .{ .button = .{ .flags = .{ .shift = true }, .pressed = true } },
|
||||
0xaa, 0xb6 => .{ .button = .{ .flags = .{ .shift = true }, .pressed = false } },
|
||||
else => blk: {
|
||||
if (scancode1 > 0x40) {
|
||||
break :blk null;
|
||||
}
|
||||
const ctrls = kos.getControlKeys();
|
||||
const k = if (ctrls.left_shift or ctrls.right_shift) symtab[scancode1 + 0x40] else symtab[scancode1];
|
||||
break :blk if (k > 0) .{ .key = k } else null;
|
||||
},
|
||||
};
|
||||
|
||||
if (input) |v| {
|
||||
switch (v) {
|
||||
.button => {
|
||||
if (v.button.pressed) {
|
||||
controller.pressButtons(&emu.cpu, v.button.flags, 0) catch unreachable;
|
||||
} else {
|
||||
controller.releaseButtons(&emu.cpu, v.button.flags, 0) catch unreachable;
|
||||
}
|
||||
},
|
||||
.key => {
|
||||
controller.pressKey(&emu.cpu, v.key) catch unreachable;
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn button() void {
|
||||
const btn = kos.getButton();
|
||||
if (btn >> 8 == 1)
|
||||
emu.exit();
|
||||
}
|
||||
|
||||
fn mouse() void {
|
||||
const dev = &emu.sys.mouse_device;
|
||||
const pos = kos.mouseGetWindowPosition();
|
||||
const events = kos.mouseGetEvents();
|
||||
const mouse_pressed: varvara.mouse.ButtonFlags = .{
|
||||
.left = events.left_pressed,
|
||||
.middle = events.middle_pressed,
|
||||
.right = events.right_pressed,
|
||||
._unused = 0,
|
||||
};
|
||||
const mouse_released: varvara.mouse.ButtonFlags = .{
|
||||
.left = events.left_released,
|
||||
.middle = events.middle_released,
|
||||
.right = events.right_released,
|
||||
._unused = 0,
|
||||
};
|
||||
if (emu.hide_cursor and pos.y > emu.screen_height) {
|
||||
_ = kos.setCursor(0);
|
||||
emu.hide_cursor = false;
|
||||
}
|
||||
if (!emu.hide_cursor and pos.y < emu.screen_height) {
|
||||
_ = kos.setCursor(emu.null_cursor);
|
||||
emu.hide_cursor = true;
|
||||
}
|
||||
dev.updatePosition(&emu.cpu, pos.x / emu.scale, pos.y / emu.scale) catch unreachable;
|
||||
if (@as(u8, @bitCast(mouse_pressed)) > 0) {
|
||||
dev.pressButtons(&emu.cpu, mouse_pressed) catch unreachable;
|
||||
}
|
||||
if (@as(u8, @bitCast(mouse_released)) > 0) {
|
||||
dev.releaseButtons(&emu.cpu, mouse_released) catch unreachable;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
callbacks.redraw();
|
||||
while (true) {
|
||||
while (true) {
|
||||
const event = kos.checkEvent();
|
||||
switch (event) {
|
||||
.none => break,
|
||||
.redraw => callbacks.redraw(),
|
||||
.key => callbacks.key(),
|
||||
.button => callbacks.button(),
|
||||
.mouse => callbacks.mouse(),
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
const tick = kos.systemGetTimeCount();
|
||||
counter += (tick - last_tick) * 3;
|
||||
last_tick = tick;
|
||||
|
||||
if (counter > 5) {
|
||||
counter -= 5;
|
||||
emu.update() catch unreachable;
|
||||
} else {
|
||||
kos.sleep(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
programs/emulator/uxn/uxn
Executable file
BIN
programs/emulator/uxn/uxn
Executable file
Binary file not shown.
@@ -1,7 +0,0 @@
|
||||
## Floppy Bird for KolibriOS
|
||||
|
||||
* [Forum topic](http://board.kolibrios.org/viewtopic.php?f=41&t=4471) <br>
|
||||
* [Directory in official KolibriOS GIT repository] kolibrios\programs\games\floppybird
|
||||
|
||||
<img src="https://i.ibb.co/kMsv8pB/menu.jpg" alt="Screenshot" width="400"> <img src="https://i.ibb.co/7NP1yHZ/screen1.jpg" alt="Screenshot" width="400">
|
||||
<img src="https://i.ibb.co/Y2FwxDG/screen2.jpg" alt="Screenshot" width="400"> <img src="https://i.ibb.co/3W8yCYn/gameover.jpg" alt="Screenshot" width="400">
|
||||
Binary file not shown.
@@ -1,73 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{0556BA3E-9447-4000-8613-91AD1CD750D7}</ProjectGuid>
|
||||
<RootNamespace>floppybird</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
<EmbedManifest>false</EmbedManifest>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>smalllibc</AdditionalIncludeDirectories>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
|
||||
<EntryPointSymbol>fakeEntry</EntryPointSymbol>
|
||||
<SubSystem>Native</SubSystem>
|
||||
<AdditionalOptions>/merge:.data=.text /merge:.rdata=.text /merge:.1seg=.text /section:.bss,E %(AdditionalOptions)</AdditionalOptions>
|
||||
<GenerateMapFile>true</GenerateMapFile>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>set EXENAME=$(TargetPath)
|
||||
"C:\kolibri\fasm\FASM.EXE" $(ProjectDir)smalllibc\doexe2.asm $(TargetDir)$(TargetName)</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="floppybird.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="smalllibc\smalllibc.vcxproj">
|
||||
<Project>{0D291390-1953-4E1F-BBE2-57F12AFF3214}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="images.hpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Файлы исходного кода">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Заголовочные файлы">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Файлы ресурсов">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="floppybird.cpp">
|
||||
<Filter>Файлы исходного кода</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="images.hpp">
|
||||
<Filter>Файлы исходного кода</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,436 +0,0 @@
|
||||
#include <kosSyst.h>
|
||||
#include <kosFile.h>
|
||||
#include "images.hpp"
|
||||
|
||||
//Global const strings
|
||||
const char HEADER_STRING[] = "Floppy bird";
|
||||
const char CONTROL_STRING[] = "SPACEBAR TO JUMP";
|
||||
const char GAMEOVER_STRING[] = "GAMEOVER";
|
||||
const char ANY_KEY_STRING[] = "Press any key for restart";
|
||||
const char SELECT_SPEED_STRING[] = "select the speed of the game";
|
||||
const char FAST_STRING[] = "1 FAST";
|
||||
const char SLOW_STRING[] = "2 SLOW";
|
||||
|
||||
//Global const variables
|
||||
const int WINDOW_WIDTH = 400;
|
||||
const int WINDOW_HEIGHT = 400;
|
||||
const int BORDER_TOP = 24;
|
||||
const int BORDER_LEFT = 5;
|
||||
const int BORDER_RIGHT = 5;
|
||||
const int BORDER_DOWN = 5;
|
||||
|
||||
enum GameState
|
||||
{
|
||||
GAMESTATE_MENU,
|
||||
GAMESTATE_STARTED,
|
||||
GAMESTATE_GAMEOVER
|
||||
};
|
||||
|
||||
struct ScreenSize
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
class Bird
|
||||
{
|
||||
public:
|
||||
static const int sizeX = 19;
|
||||
static const int sizeY = 20;
|
||||
static const int x = 100;
|
||||
int prev_y;
|
||||
int y;
|
||||
int acceleration;
|
||||
|
||||
inline void initialize()
|
||||
{
|
||||
y = WINDOW_HEIGHT / 2;
|
||||
acceleration = 0;
|
||||
}
|
||||
|
||||
inline void move()
|
||||
{
|
||||
if (acceleration <= 30)
|
||||
acceleration += 2;
|
||||
prev_y = y;
|
||||
y += acceleration / 10;
|
||||
}
|
||||
|
||||
inline void jump()
|
||||
{
|
||||
acceleration = -50;
|
||||
}
|
||||
|
||||
inline void draw()
|
||||
{
|
||||
kos_PutImage(birdImage, sizeX, sizeY, x, y);
|
||||
}
|
||||
};
|
||||
|
||||
class Tube
|
||||
{
|
||||
public:
|
||||
static const int width = 50;
|
||||
static const int gapHeight = 100;
|
||||
static const int headHeight = 18;
|
||||
int x;
|
||||
int gapY;
|
||||
|
||||
inline void randomize()
|
||||
{
|
||||
x = WINDOW_WIDTH + 1;
|
||||
gapY = rtlRand() % 200 + 50;
|
||||
}
|
||||
|
||||
inline void move()
|
||||
{
|
||||
x -= 2;
|
||||
if (x < -width - 2)
|
||||
randomize();
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
//cleanup
|
||||
int pixels = (WINDOW_WIDTH - (BORDER_LEFT + BORDER_RIGHT - 1)) - (x + width + 2);
|
||||
if (pixels >= -1)
|
||||
{
|
||||
pixels = (pixels == -1) ? 1 : 2;
|
||||
kos_DrawBar(x + width, gapY - headHeight, pixels, headHeight, 0x00FFFF);
|
||||
kos_DrawBar(x + width, gapY + gapHeight, pixels, headHeight, 0x00FFFF);
|
||||
}
|
||||
|
||||
int offset = x >= 0 ? 0 : -x;
|
||||
int trim = x + width >= WINDOW_WIDTH - (BORDER_LEFT + BORDER_RIGHT - 1) ? WINDOW_WIDTH - x - width - (BORDER_LEFT + BORDER_RIGHT - 1) : 0;
|
||||
int trimHead = x + width >= WINDOW_WIDTH - (BORDER_LEFT + BORDER_RIGHT - 1) ? WINDOW_WIDTH - x - width - (BORDER_LEFT + BORDER_RIGHT - 1) : 0;
|
||||
|
||||
//top
|
||||
for (int y = 0; y < gapY - headHeight; ++y)
|
||||
kos_PutImage(tubeBodyImage + offset, width - offset + trim, 1, x + offset, y);
|
||||
//head top
|
||||
for (int y = gapY - headHeight; y < gapY; ++y)
|
||||
kos_PutImage(tubeHeadImage + width * (y - (gapY - headHeight)) + offset, width - offset + trimHead, 1, x + offset, y);
|
||||
//head down
|
||||
for (int y = gapY + gapHeight; y < gapY + gapHeight + headHeight; ++y)
|
||||
kos_PutImage(tubeHeadImage + width * (y - (gapY + gapHeight)) + offset, width - offset + trimHead, 1, x + offset, y);
|
||||
//down
|
||||
for (int y = gapY + gapHeight + headHeight; y < WINDOW_HEIGHT - (BORDER_TOP + BORDER_DOWN - 1); ++y)
|
||||
kos_PutImage(tubeBodyImage + offset, width - offset + trim, 1, x + offset, y);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
//Global variables
|
||||
int loopDelay;
|
||||
GameState gameState;
|
||||
char scoreString[] = "Score: ";
|
||||
bool scoreChanged;
|
||||
int score;
|
||||
Bird bird;
|
||||
int tubeNumber;
|
||||
Tube tubes[3];
|
||||
int windowX;
|
||||
int windowY;
|
||||
|
||||
//Function prototypes
|
||||
void kos_Main();
|
||||
void startGame();
|
||||
ScreenSize getScreenSize();
|
||||
void updateScoreString();
|
||||
void WriteBorderedText(Word x, Word y, Byte fontType, Dword textColor, const char* textPtr, Dword textLen, Dword borderColor, int borderSize);
|
||||
inline bool checkAddScore(Tube tube);
|
||||
inline bool checkCollision(Tube tube);
|
||||
|
||||
void drawMenuWindow();
|
||||
void drawGameWindow();
|
||||
void redrawGameWindow();
|
||||
void drawGameoverWindow();
|
||||
|
||||
//Functions
|
||||
|
||||
void startGame()
|
||||
{
|
||||
kos_SetMaskForEvents(0x7); /// 111 in binary
|
||||
|
||||
bird.initialize();
|
||||
|
||||
score = 0;
|
||||
memset((Byte*)scoreString + 6, ' ', 3);
|
||||
updateScoreString();
|
||||
|
||||
tubeNumber = 1;
|
||||
tubes[0].randomize();
|
||||
|
||||
gameState = GAMESTATE_STARTED;
|
||||
drawGameWindow();
|
||||
}
|
||||
|
||||
ScreenSize getScreenSize()
|
||||
{
|
||||
Dword result;
|
||||
__asm {
|
||||
push 14 //System function 14
|
||||
pop eax
|
||||
int 0x40
|
||||
mov result, eax
|
||||
}
|
||||
ScreenSize screenSize;
|
||||
screenSize.height = (result & 0xFFFF) + 1; //last two bytes
|
||||
screenSize.width = (result >> 16) + 1; //first two bytes
|
||||
return screenSize;
|
||||
}
|
||||
|
||||
void kos_Main()
|
||||
{
|
||||
rtlSrand( kos_GetSystemClock() );
|
||||
|
||||
//Centring window
|
||||
ScreenSize screenSize = getScreenSize();
|
||||
windowX = (screenSize.width - WINDOW_WIDTH) / 2;
|
||||
windowY = (screenSize.height - WINDOW_HEIGHT) / 2;
|
||||
|
||||
gameState = GAMESTATE_MENU;
|
||||
|
||||
kos_SetMaskForEvents(0x27); // 100111 in binary
|
||||
|
||||
while( true )
|
||||
{
|
||||
switch (gameState)
|
||||
{
|
||||
case GAMESTATE_STARTED:
|
||||
kos_Pause(loopDelay);
|
||||
|
||||
bird.move();
|
||||
|
||||
//Adding new tubes
|
||||
if ((tubeNumber == 1 || tubeNumber == 2) && (tubes[tubeNumber - 1].x < (WINDOW_WIDTH - WINDOW_WIDTH / 3)))
|
||||
tubes[tubeNumber++].randomize();
|
||||
|
||||
//Processing all tubes
|
||||
scoreChanged = false;
|
||||
for (int i = 0; i < tubeNumber; ++i)
|
||||
{
|
||||
//Adding score
|
||||
if (checkAddScore(tubes[i]))
|
||||
{
|
||||
++score;
|
||||
scoreChanged = true;
|
||||
}
|
||||
|
||||
//Check collision with bird
|
||||
if (checkCollision(tubes[i]))
|
||||
{
|
||||
gameState = GAMESTATE_GAMEOVER;
|
||||
continue;
|
||||
}
|
||||
|
||||
//Move tube
|
||||
tubes[i].move();
|
||||
}
|
||||
|
||||
if (scoreChanged)
|
||||
updateScoreString();
|
||||
|
||||
//Cheking the bird is too high or low
|
||||
if (bird.y + bird.sizeY > WINDOW_HEIGHT - (BORDER_TOP + BORDER_DOWN - 1) || bird.y < 0)
|
||||
{
|
||||
gameState = GAMESTATE_GAMEOVER;
|
||||
continue;
|
||||
}
|
||||
|
||||
redrawGameWindow();
|
||||
|
||||
switch (kos_CheckForEvent())
|
||||
{
|
||||
case 1:
|
||||
drawGameWindow();
|
||||
break;
|
||||
|
||||
case 2: // key pressed
|
||||
Byte keyCode;
|
||||
kos_GetKey(keyCode);
|
||||
if (keyCode == 32) //if pressed key is spacebar
|
||||
bird.jump();
|
||||
break;
|
||||
|
||||
case 3: // button pressed; we have only one button, close
|
||||
kos_ExitApp();
|
||||
}
|
||||
break;
|
||||
|
||||
case GAMESTATE_GAMEOVER:
|
||||
drawGameoverWindow();
|
||||
|
||||
switch (kos_WaitForEvent())
|
||||
{
|
||||
case 1:
|
||||
drawGameoverWindow();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
startGame();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
kos_ExitApp();
|
||||
}
|
||||
break;
|
||||
|
||||
case GAMESTATE_MENU:
|
||||
switch (kos_WaitForEvent())
|
||||
{
|
||||
case 1:
|
||||
drawMenuWindow();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
Byte keyCode;
|
||||
kos_GetKey(keyCode);
|
||||
if (keyCode == 0x31 || keyCode == 0x61) //1 or NumPad1
|
||||
{
|
||||
loopDelay = 1;
|
||||
startGame();
|
||||
}
|
||||
else if (keyCode == 0x32 || keyCode == 0x62) //2 or NumPad2
|
||||
{
|
||||
loopDelay = 2;
|
||||
startGame();
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
kos_ExitApp();
|
||||
|
||||
case 6:
|
||||
Dword result;
|
||||
__asm {
|
||||
push 37 //Function 37 - work with mouse
|
||||
pop eax
|
||||
mov ebx, 3 //Subfunction 3 - states and events of the mouse buttons
|
||||
int 0x40
|
||||
mov result, eax
|
||||
}
|
||||
result &= 0x100; //bit 8 is set = left button is pressed
|
||||
if ( result )
|
||||
{
|
||||
Dword coordinates;
|
||||
__asm {
|
||||
push 37 //Function 37 - work with mouse
|
||||
pop eax
|
||||
mov ebx, 1 //Subfunction 1 - coordinates of the mouse relative to the window
|
||||
int 0x40
|
||||
mov coordinates, eax
|
||||
}
|
||||
int clickX = coordinates >> 16;
|
||||
int clickY = coordinates & 0xFFFF;
|
||||
if (clickX >= 100 && clickX < 390 && clickY >= 170 && clickY < 230)
|
||||
{
|
||||
loopDelay = 1;
|
||||
startGame();
|
||||
}
|
||||
else if (clickX >= 100 && clickX < 390 && clickY >= 270 && clickY < 330)
|
||||
{
|
||||
loopDelay = 2;
|
||||
startGame();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drawGameWindow()
|
||||
{
|
||||
kos_DefineAndDrawWindow(windowX, windowY, WINDOW_WIDTH, WINDOW_HEIGHT, 0x33, 0x00FFFF, 0, 0, (Dword)HEADER_STRING);
|
||||
bird.draw();
|
||||
for (int i = 0; i < tubeNumber; ++i)
|
||||
tubes[i].draw();
|
||||
kos_WriteTextToWindow(10, 10, 0x81, 0x000000, scoreString, 0);
|
||||
kos_WriteTextToWindow(10, 30, 0x81, 0x000000, CONTROL_STRING, 0);
|
||||
}
|
||||
void redrawGameWindow()
|
||||
{
|
||||
//cleaning the screen
|
||||
if (scoreChanged)
|
||||
kos_DrawBar(80, 10, 50, 15, 0x00FFFF);
|
||||
if (bird.y > bird.prev_y)
|
||||
kos_DrawBar(bird.x, bird.prev_y, bird.sizeX, bird.y - bird.prev_y, 0x00FFFF);
|
||||
else
|
||||
kos_DrawBar(bird.x, bird.y + bird.sizeY, bird.sizeX, bird.prev_y - bird.y, 0x00FFFF);
|
||||
|
||||
bird.draw();
|
||||
for (int i = 0; i < tubeNumber; ++i)
|
||||
tubes[i].draw();
|
||||
|
||||
kos_WriteTextToWindow(10, 10, 0x81, 0x000000, scoreString, 0);
|
||||
kos_WriteTextToWindow(10, 30, 0x81, 0x000000, CONTROL_STRING, 0);
|
||||
}
|
||||
|
||||
void drawGameoverWindow()
|
||||
{
|
||||
kos_DefineAndDrawWindow(windowX, windowY, WINDOW_WIDTH, WINDOW_HEIGHT, 0x33, 0x000000, 0, 0, (Dword)HEADER_STRING);
|
||||
kos_WriteTextToWindow(125, 50, 0x82, 0xFFFFFF, GAMEOVER_STRING, 0);
|
||||
kos_WriteTextToWindow(135, 100, 0x81, 0xFFFFFF, scoreString, 0);
|
||||
kos_WriteTextToWindow(50, 150, 0x81, 0xFFFFFF, ANY_KEY_STRING, 0);
|
||||
}
|
||||
|
||||
void WriteBorderedText(Word x, Word y, Byte fontType, Dword textColor, const char *textPtr, Dword textLen, Dword borderColor, int borderSize)
|
||||
{
|
||||
kos_WriteTextToWindow(x - borderSize, y - borderSize, fontType, borderColor, textPtr, textLen);
|
||||
kos_WriteTextToWindow(x - borderSize, y + borderSize, fontType, borderColor, textPtr, textLen);
|
||||
kos_WriteTextToWindow(x + borderSize, y - borderSize, fontType, borderColor, textPtr, textLen);
|
||||
kos_WriteTextToWindow(x + borderSize, y + borderSize, fontType, borderColor, textPtr, textLen);
|
||||
kos_WriteTextToWindow(x, y, fontType, textColor, textPtr, textLen);
|
||||
}
|
||||
|
||||
void drawMenuWindow()
|
||||
{
|
||||
kos_DefineAndDrawWindow(windowX, windowY, WINDOW_WIDTH, WINDOW_HEIGHT, 0x33, 0x00FFFF, 0, 0, (Dword)HEADER_STRING);
|
||||
|
||||
WriteBorderedText(85, 40, 0x4, 0xFFFFFF, HEADER_STRING, 6, 0x000000, 2);
|
||||
WriteBorderedText(185, 80, 0x84, 0xFFFFFF, HEADER_STRING + 7, 0, 0x000000, 2);
|
||||
|
||||
RGB* pos = &tubeHeadImage[0];
|
||||
for (int x = 100 - 1; x >= 100 - Tube::headHeight; --x)
|
||||
for (int y = 170; y < 170 + Tube::width; ++y)
|
||||
{
|
||||
kos_PutPixel(x, y, (pos->r << 16) + (pos->g << 8) + (pos->b)); //first tube
|
||||
kos_PutPixel(x, y+100, (pos->r << 16) + (pos->g << 8) + (pos->b)); //second tube
|
||||
++pos;
|
||||
}
|
||||
|
||||
//First button
|
||||
for(int x = 100; x < WINDOW_WIDTH - (BORDER_LEFT + BORDER_RIGHT - 1); ++x)
|
||||
kos_PutImage(tubeBodyImage, 1, Tube::width, x, 170);
|
||||
WriteBorderedText(140, 185, 0x82, 0x000000, FAST_STRING, 0, 0xFFFFFF, 1);
|
||||
|
||||
//Second button
|
||||
for (int x = 100; x < WINDOW_WIDTH - (BORDER_LEFT + BORDER_RIGHT - 1); ++x)
|
||||
kos_PutImage(tubeBodyImage, 1, Tube::width, x, 270);
|
||||
WriteBorderedText(140, 285, 0x82, 0x000000, SLOW_STRING, 0, 0xFFFFFF, 1);
|
||||
}
|
||||
|
||||
inline bool checkCollision(Tube tube)
|
||||
{
|
||||
return ((tube.x <= (bird.x + bird.sizeX) && tube.x + tube.width >= bird.x)
|
||||
&& (bird.y <= tube.gapY || bird.y + bird.sizeY >= tube.gapY + tube.gapHeight));
|
||||
}
|
||||
|
||||
inline bool checkAddScore(Tube tube)
|
||||
{
|
||||
//int diff = bird.x - (tube.x + tube.width);
|
||||
//return diff == 0 || diff == 1;
|
||||
return ((bird.x - (tube.x + tube.width)) >> 1) == 0;
|
||||
}
|
||||
|
||||
void updateScoreString()
|
||||
{
|
||||
int temp = score;
|
||||
int index = 9;
|
||||
do {
|
||||
scoreString[index--] = temp % 10 + '0';
|
||||
temp /= 10;
|
||||
} while (temp > 0);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "floppybird", "floppybird.vcxproj", "{0556BA3E-9447-4000-8613-91AD1CD750D7}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{0D291390-1953-4E1F-BBE2-57F12AFF3214} = {0D291390-1953-4E1F-BBE2-57F12AFF3214}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "smalllibc", "smalllibc\smalllibc.vcxproj", "{0D291390-1953-4E1F-BBE2-57F12AFF3214}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{0556BA3E-9447-4000-8613-91AD1CD750D7}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{0556BA3E-9447-4000-8613-91AD1CD750D7}.Release|Win32.Build.0 = Release|Win32
|
||||
{0D291390-1953-4E1F-BBE2-57F12AFF3214}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{0D291390-1953-4E1F-BBE2-57F12AFF3214}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,51 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <kosSyst.h>
|
||||
|
||||
static RGB birdImage[] = {
|
||||
0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0xC08040, 0xC08040, 0xC08040, 0x608080, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
0x00FFFF, 0x40C0C0, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0xC08040, 0xE0C080, 0xC08040, 0xE0C080, 0x806040, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
0xC0DCC0, 0xA06040, 0x80C0C0, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x80C0C0, 0xE0A040, 0xE0E080, 0xE0C080, 0xE0E080, 0x806040, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
0xC08040, 0xE0C080, 0xA06040, 0x20C0C0, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0xC06040, 0xE0C080, 0xC0A080, 0xC0A080, 0xA0A080, 0x806040, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
0xC08040, 0xE0C080, 0xE0E080, 0xA06040, 0x20C0C0, 0x00FFFF, 0x00FFFF, 0xA06040, 0xC08040, 0x800040, 0x800040, 0xE02080, 0xE060C0, 0x40C0C0, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
0xA06040, 0xC08040, 0xE0E080, 0xC0DCC0, 0xA06040, 0x20C0C0, 0x20C0C0, 0xC06040, 0x808080, 0xE02080, 0xE020C0, 0xE02080, 0xE0A0C0, 0x804080, 0x40C0C0, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
0xC08040, 0xE0A040, 0xE0C080, 0xE0E080, 0xFFFBF0, 0x806040, 0xC06040, 0xC0DCC0, 0x800040, 0xE040C0, 0xE040C0, 0x002040, 0xE0E080, 0xA0A080, 0x404040, 0x404040, 0x806080, 0x806080, 0xA08080,
|
||||
0xA06040, 0xE0A040, 0xC08040, 0xE0C080, 0xFFFBF0, 0xC0DCC0, 0xA06040, 0xC0DCC0, 0xE020C0, 0xE0C080, 0xE0C080, 0xE0E080, 0xE0E000, 0xA0A0A4, 0xC0A080, 0x20A080, 0x40A0C0, 0x40A0C0, 0x60C0C0,
|
||||
0x20C0C0, 0xA06040, 0xE0A040, 0xC08040, 0xE0C040, 0xFFFBF0, 0xC0C080, 0x80A040, 0xC00080, 0xFFFF00, 0xFFFF00, 0xE0E080, 0xC0A040, 0xA0A080, 0x60A080, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
0x00FFFF, 0x80A080, 0xC08040, 0xE0A040, 0xE0A040, 0xE0C080, 0xFFFBF0, 0xC0C0C0, 0xE0C040, 0xE0E040, 0xC0E000, 0xC0C080, 0xA0A080, 0xC0C0C0, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
0x00FFFF, 0x40C0C0, 0x80A080, 0xE0A040, 0xE0C080, 0xE0C040, 0xE0E080, 0x80E080, 0xC0E000, 0xE0E080, 0xE0E080, 0xE0E080, 0xC0A080, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
0x00FFFF, 0x00FFFF, 0x40C0C0, 0xA06040, 0xA0C040, 0xA0A040, 0xA0C080, 0xC0E000, 0xC0E000, 0xE0E080, 0xE0E080, 0xE0E080, 0xE0E080, 0x40C080, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
0x60E080, 0xC0DCC0, 0x00FFFF, 0x80C0C0, 0x606080, 0x606080, 0xA0E040, 0xC0E000, 0xE0E000, 0xE0E080, 0xE0E080, 0xE0E080, 0xC0C040, 0x60A040, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
0xC0E080, 0xC0C000, 0xE0E000, 0xC0DCC0, 0x80A040, 0xA0E040, 0xA0C040, 0xC0E000, 0xE0E080, 0xE0E080, 0xE0E080, 0xC0E000, 0xC0C000, 0x60A040, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
0xA0A0A4, 0xA0A080, 0xA0E040, 0xC0E000, 0x80A080, 0xA0C040, 0xC0E000, 0xE0E040, 0xE0E080, 0xE0E080, 0xC0E000, 0xA0E040, 0x808040, 0x20C0C0, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
0xC0E080, 0xE0E000, 0xA0A080, 0x80A080, 0xA0C040, 0xE0E040, 0xE0E040, 0xE0E040, 0xC0E040, 0xC0E000, 0xA0E040, 0x808040, 0xA0C080, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
0x80A080, 0xA0C000, 0xC0E000, 0xA0E040, 0xA0C040, 0xC0E000, 0xC0E000, 0xC0E000, 0xC0E000, 0xA0E040, 0x80A040, 0x80C0C0, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
0xA0C000, 0x6080C0, 0xA0C040, 0xC0E000, 0xC0E000, 0xC0E000, 0xC0E000, 0xA0C040, 0x80A040, 0x808040, 0xA0C0C0, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
0x80A080, 0xA0C080, 0xC0E000, 0xA0E040, 0xC0E040, 0x808040, 0x808040, 0x808040, 0xA0C0C0, 0x20C0C0, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF,
|
||||
0xA0E080, 0x808040, 0xA0A040, 0x808040, 0x808040, 0x80C0C0, 0xA0C0C0, 0x20C0C0, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF
|
||||
};
|
||||
|
||||
static RGB tubeBodyImage[] = {
|
||||
0x00FFFF, 0x00FFFF, 0x000000, 0x608040, 0x80E040, 0xE0E080, 0xA0E040, 0xA0E040, 0x80C040, 0x80C040, 0x80C040, 0x80C040, 0x80E040, 0x60A000, 0x60A000, 0x80E040, 0x80E040, 0x60A000, 0x40A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x40A000, 0x60A000, 0x408000, 0x408000, 0x204000, 0x60A000, 0x408000, 0x408000, 0x204000, 0x206000, 0x204000, 0x200040, 0x00FFFF, 0x00FFFF
|
||||
};
|
||||
|
||||
static RGB tubeHeadImage[] = {
|
||||
0x200040, 0x200040, 0x200040, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040,
|
||||
0x402000, 0x408000, 0x408000, 0x608040, 0x80A040, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xC0C080, 0xA0C040, 0x60A040, 0x60A040, 0xA0C080, 0xA0C080, 0x60A040, 0x60A040, 0x80A040, 0x60A040, 0x60A040, 0x60A040, 0x60A040, 0x60A040, 0x80A040, 0x80A040, 0x80A040, 0x80A040, 0x608000, 0x406000, 0x204000, 0x204000, 0x402000,
|
||||
0x402000, 0x60C000, 0x60C000, 0x80C040, 0xA0E040, 0xE0E080, 0xE0E080, 0xE0E080, 0xE0E080, 0xC0E080, 0xC0E080, 0xC0E080, 0xE0E080, 0xC0E080, 0xC0E080, 0xC0E080, 0xC0E080, 0xC0E080, 0xC0E080, 0xC0E080, 0xC0E080, 0xC0E080, 0xC0E080, 0xC0E080, 0xC0E080, 0xC0E080, 0xC0E080, 0xC0E080, 0xC0E080, 0x80C040, 0x80C040, 0xC0E080, 0xC0E080, 0x80C040, 0x80C040, 0x80E040, 0x80C040, 0x80C040, 0x80E040, 0x80E040, 0x80E040, 0x80C040, 0x80C040, 0x80C040, 0x80E040, 0x60A000, 0x408000, 0x206000, 0x206000, 0x402000,
|
||||
0x402040, 0x80E040, 0x80E040, 0xC0E080, 0xE0E080, 0x80C040, 0x80C040, 0x80C040, 0x80C040, 0x40A000, 0x60A000, 0x60A000, 0x80E040, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x204000, 0x406000, 0x406000, 0x60A000, 0x206000, 0x204000, 0x206000, 0x206000, 0x402000,
|
||||
0x402040, 0x80E040, 0x80E040, 0xC0E080, 0xE0E080, 0x80C040, 0x80C040, 0x80C040, 0x80C040, 0x60A000, 0x60A000, 0x60A000, 0x80E040, 0x60A000, 0x40A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x206000, 0x406000, 0x406000, 0x60A000, 0x206000, 0x206000, 0x206000, 0x206000, 0x402000,
|
||||
0x402040, 0x80E040, 0x80E040, 0xC0E080, 0xE0E080, 0x80C040, 0x80C040, 0x80C040, 0x80C040, 0x60A000, 0x60A000, 0x60A000, 0x80E040, 0x60A000, 0x40A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x206000, 0x406000, 0x406000, 0x60A000, 0x206000, 0x204000, 0x206000, 0x206000, 0x402000,
|
||||
0x402040, 0x80E040, 0x80E040, 0xC0E080, 0xE0E080, 0x80C040, 0x80C040, 0x80C040, 0x80C040, 0x60A000, 0x60A000, 0x60A000, 0x80E040, 0x60A000, 0x40A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x206000, 0x406000, 0x406000, 0x60A000, 0x206000, 0x204000, 0x206000, 0x206000, 0x402000,
|
||||
0x402040, 0x80E040, 0x80E040, 0xC0E080, 0xE0E080, 0x80C040, 0x80C040, 0x80C040, 0x80C040, 0x60A000, 0x60A000, 0x60A000, 0x80E040, 0x60A000, 0x40A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x206000, 0x406000, 0x406000, 0x60A000, 0x206000, 0x204000, 0x206000, 0x206000, 0x402000,
|
||||
0x402040, 0x80E040, 0x80E040, 0xC0E080, 0xE0E080, 0x80C040, 0x80C040, 0x80C040, 0x80C040, 0x60A000, 0x60A000, 0x60A000, 0x80E040, 0x60A000, 0x40A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x206000, 0x406000, 0x406000, 0x60A000, 0x206000, 0x204000, 0x206000, 0x206000, 0x402000,
|
||||
0x402040, 0x80E040, 0x80E040, 0xC0E080, 0xE0E080, 0x80C040, 0x80C040, 0x80C040, 0x80C040, 0x60A000, 0x60A000, 0x60A000, 0x80E040, 0x60A000, 0x40A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x206000, 0x406000, 0x406000, 0x60A000, 0x206000, 0x204000, 0x206000, 0x206000, 0x402000,
|
||||
0x402040, 0x80E040, 0x80E040, 0xC0E080, 0xE0E080, 0x80C040, 0x80C040, 0x80C040, 0x80C040, 0x60A000, 0x60A000, 0x60A000, 0x80E040, 0x60A000, 0x40A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x206000, 0x406000, 0x406000, 0x60A000, 0x206000, 0x204000, 0x206000, 0x206000, 0x402000,
|
||||
0x402040, 0x80E040, 0x80E040, 0xC0E080, 0xE0E080, 0x80C040, 0x80C040, 0x80C040, 0x80C040, 0x60A000, 0x60A000, 0x60A000, 0x80E040, 0x60A000, 0x40A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x206000, 0x406000, 0x406000, 0x60A000, 0x206000, 0x204000, 0x206000, 0x206000, 0x402000,
|
||||
0x402040, 0x80E040, 0x80E040, 0xC0E080, 0xE0E080, 0x80C040, 0x80C040, 0x80C040, 0x80C040, 0x60A000, 0x60A000, 0x60A000, 0x80E040, 0x60A000, 0x40A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x206000, 0x406000, 0x406000, 0x60A000, 0x206000, 0x204000, 0x206000, 0x206000, 0x402000,
|
||||
0x402040, 0x80E040, 0x80E040, 0xC0E080, 0xE0E080, 0x80C040, 0x80C040, 0x80C040, 0x80C040, 0x40A000, 0x60A000, 0x60A000, 0x80E040, 0x60A000, 0x40A000, 0x60A000, 0x60A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x40A000, 0x60A000, 0x206000, 0x406000, 0x406000, 0x60A000, 0x206000, 0x204000, 0x206000, 0x206000, 0x402000,
|
||||
0x402040, 0x80E040, 0x80E040, 0xC0E080, 0xE0E080, 0x80E040, 0x80E040, 0x80E040, 0x80E040, 0x60A000, 0x60C000, 0x60C000, 0xA0E040, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x60A000, 0x206000, 0x406000, 0x406000, 0x60A000, 0x206000, 0x204000, 0x206000, 0x206000, 0x402000,
|
||||
0x402000, 0x408000, 0x408000, 0x608000, 0x608040, 0x408000, 0x408000, 0x408000, 0x408000, 0x406000, 0x408000, 0x408000, 0x408000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x406000, 0x206000, 0x206000, 0x206000, 0x406000, 0x206000, 0x206000, 0x206000, 0x206000, 0x402000,
|
||||
0x402000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x204000, 0x206000, 0x206000, 0x402000,
|
||||
0x200040, 0x200040, 0x200040, 0x200040, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x200040, 0x200040, 0x000000, 0x000000, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040, 0x200040
|
||||
};
|
||||
@@ -1,68 +0,0 @@
|
||||
filename equ '%EXENAME%'
|
||||
|
||||
virtual at 0
|
||||
file filename:3Ch,4
|
||||
load pehea dword from 0
|
||||
file filename:pehea,0F8h+28h*3
|
||||
load NumberOfSections word from 4+6
|
||||
load SizeOfOptionalHeader word from 4+14h
|
||||
if NumberOfSections<>3
|
||||
error Expected three sections, .text, .bss and .reloc
|
||||
end if
|
||||
if SizeOfOptionalHeader<>0E0h
|
||||
error Nonstandard PE header
|
||||
end if
|
||||
load RelocsRVA dword from 4+0A0h
|
||||
load RelocsSize dword from 4+0A4h
|
||||
load ImageBase dword from 4+34h
|
||||
load TextRVA dword from 4+0F8h+0Ch
|
||||
load TextSize dword from 4+0F8h+8
|
||||
load TextOffs dword from 4+0F8h+14h
|
||||
load BSSSize dword from 4+0F8h+28h+10h
|
||||
load RelocRVA dword from 4+0F8h+28h*2+0Ch
|
||||
load RelocOffs dword from 4+0F8h+28h*2+14h
|
||||
if BSSSize
|
||||
error Second section expected to be .bss
|
||||
end if
|
||||
if RelocRVA<>RelocsRVA
|
||||
error Third section expected to be .reloc
|
||||
end if
|
||||
;file 'test.exe':pehea+0F8h,28h
|
||||
;load physofs dword from 4+14h
|
||||
;load mem dword from 4+8
|
||||
;file 'test.exe':physofs+16,4
|
||||
;load sz dword from $-4
|
||||
end virtual
|
||||
|
||||
file filename:TextOffs,TextSize
|
||||
|
||||
while RelocsSize>8
|
||||
virtual at 0
|
||||
file filename:RelocOffs,8
|
||||
load CurRelocPage dword from 0
|
||||
load CurRelocChunkSize dword from 4
|
||||
end virtual
|
||||
RelocsSize=RelocsSize-CurRelocChunkSize
|
||||
CurRelocChunkSize = CurRelocChunkSize-8
|
||||
RelocOffs=RelocOffs+8
|
||||
while CurRelocChunkSize
|
||||
virtual at 0
|
||||
file filename:RelocOffs,2
|
||||
RelocOffs=RelocOffs+2
|
||||
CurRelocChunkSize=CurRelocChunkSize-2
|
||||
load s word from 0
|
||||
end virtual
|
||||
CurRelocType = s shr 12
|
||||
RelocItem = CurRelocPage + (s and 0xFFF)
|
||||
if CurRelocType=0
|
||||
else if CurRelocType=3
|
||||
load z dword from RelocItem-TextRVA
|
||||
store dword z-(TextRVA+ImageBase) at RelocItem-TextRVA
|
||||
else
|
||||
error Unexpected relocation type
|
||||
end if
|
||||
end while
|
||||
end while
|
||||
|
||||
store dword TextSize at 10h
|
||||
store dword RelocRVA-TextRVA at 14h
|
||||
@@ -1,501 +0,0 @@
|
||||
|
||||
|
||||
#include "func.h"
|
||||
|
||||
int convert_error = 0;
|
||||
int SysColor = 0;
|
||||
char debuf[50] = "";
|
||||
|
||||
|
||||
// ïî÷åìó-òî íå áûëî â ñòàíäàðòíîé áèáëèîòåêå
|
||||
void kos_DrawLine( Word x1, Word y1, Word x2, Word y2, Dword colour, Dword invert )
|
||||
{
|
||||
Dword arg1, arg2, arg3;
|
||||
|
||||
//
|
||||
arg1 = ( x1 << 16 ) | x2;
|
||||
arg2 = ( y1 << 16 ) | y2;
|
||||
arg3 = (invert)?0x01000000:colour;
|
||||
//
|
||||
__asm{
|
||||
mov eax, 38
|
||||
mov ebx, arg1
|
||||
mov ecx, arg2
|
||||
mov edx, arg3
|
||||
int 0x40
|
||||
}
|
||||
}
|
||||
|
||||
// ïîõèùåíî èç áèáëèîòåêè ê C--
|
||||
void DrawRegion(Dword x,Dword y,Dword width,Dword height,Dword color1)
|
||||
{
|
||||
kos_DrawBar(x,y,width,1,color1); //ïîëîñà ãîð ñâåðõó
|
||||
kos_DrawBar(x,y+height,width,1,color1); //ïîëîñà ãîð ñíèçó
|
||||
kos_DrawBar(x,y,1,height,color1); //ïîëîñà âåðò ñëåâà
|
||||
kos_DrawBar(x+width,y,1,height+1,color1); //ïîëîñà âåðò ñïðàâà
|
||||
}
|
||||
|
||||
|
||||
// äà, ýòî áàÿí
|
||||
int atoi(const char* string)
|
||||
{
|
||||
int res=0;
|
||||
int sign=0;
|
||||
const char* ptr;
|
||||
for (ptr=string; *ptr && *ptr<=' ';ptr++);
|
||||
if (*ptr=='-') {sign=1;++ptr;}
|
||||
while (*ptr >= '0' && *ptr <= '9')
|
||||
{
|
||||
res = res*10 + *ptr++ - '0';
|
||||
}
|
||||
if (sign) res = -res;
|
||||
return res;
|
||||
}
|
||||
|
||||
/*int abs(int n)
|
||||
{
|
||||
return (n<0)?-n:n;
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
double fabs(double x)
|
||||
{
|
||||
__asm fld x
|
||||
__asm fabs
|
||||
}
|
||||
#define M_PI 3.14159265358979323846
|
||||
double cos(double x)
|
||||
{
|
||||
__asm fld x
|
||||
__asm fcos
|
||||
}
|
||||
double sin(double x)
|
||||
{
|
||||
__asm fld x
|
||||
__asm fsin
|
||||
}
|
||||
|
||||
bool isalpha(char c)
|
||||
{
|
||||
return (c==' ' || c=='\n' || c=='\t' || c=='\r');
|
||||
}
|
||||
|
||||
// ýòà ôóíêöèÿ - âåëîñèïåä. íî ïðîùå áûëî íàïèñàòü ÷åì íàéòè.
|
||||
double convert(char *s, int *len)
|
||||
{
|
||||
|
||||
int i;
|
||||
|
||||
|
||||
double sign,res, tail, div;
|
||||
|
||||
convert_error = 0;
|
||||
|
||||
res = 0.0;
|
||||
|
||||
i=0;
|
||||
while (s[i] && isalpha(s[i])) i++;
|
||||
if (len) *len=i;
|
||||
if (s[i] == '\0')
|
||||
{
|
||||
convert_error = ERROR_END;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
sign=1.0;
|
||||
if (s[i] == '-')
|
||||
{
|
||||
sign=-1.0;
|
||||
i++;
|
||||
}
|
||||
while (s[i] && s[i] >= '0' && s[i] <= '9')
|
||||
{
|
||||
res *= 10.0;
|
||||
res += id(s[i] - '0');
|
||||
i++;
|
||||
}
|
||||
if (len) *len=i;
|
||||
if (!s[i] || isalpha(s[i]))
|
||||
return sign*res;
|
||||
if (s[i] != '.' && s[i] != ',')
|
||||
{
|
||||
convert_error = ERROR;
|
||||
return 0;
|
||||
}
|
||||
i++;
|
||||
if (len) *len=i;
|
||||
if (!s[i])
|
||||
return sign*res;
|
||||
|
||||
div = 1.0;
|
||||
tail = 0.0;
|
||||
while (s[i] && s[i] >= '0' && s[i] <= '9')
|
||||
{
|
||||
tail *= 10.0;
|
||||
tail += id(s[i] - '0');
|
||||
div *= 10.0;
|
||||
i++;
|
||||
}
|
||||
res += tail/div;
|
||||
if (len) *len=i;
|
||||
return sign*res;
|
||||
}
|
||||
|
||||
/*
|
||||
#define PREC 2
|
||||
|
||||
double double_tab[]={1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15};
|
||||
|
||||
// ýòî sprintf, óìåþùèé ôîðìàòèðîâàòü _òîëüêî_ âåùåñòâåííûå ÷èñëà (double) %f
|
||||
void format( char *Str, int len, char* Format, ... )
|
||||
{
|
||||
int i, fmtlinesize, j, k, flag;
|
||||
char c;
|
||||
va_list arglist;
|
||||
//
|
||||
va_start(arglist, Format);
|
||||
|
||||
//
|
||||
fmtlinesize = strlen( Format );
|
||||
//
|
||||
if( fmtlinesize == 0 ) return;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
Str[i] = 0;
|
||||
|
||||
//
|
||||
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;
|
||||
// auaia aauanoaaiiiai ?enea
|
||||
case 'f':
|
||||
// ii?aaaeeou ?enei oeo? ai oi?ee
|
||||
double val, w;
|
||||
int p;
|
||||
val = va_arg(arglist, double);
|
||||
if (val < 0.0)
|
||||
{
|
||||
Str[j++] = '-';
|
||||
val = -val;
|
||||
}
|
||||
for (k = 0; k < 15; k++)
|
||||
if (val < double_tab[k])
|
||||
break;
|
||||
|
||||
if (val < 1.0)
|
||||
{
|
||||
Str[j++] = '0';
|
||||
}
|
||||
|
||||
for (p = 1; p < k + 1; p++)
|
||||
{
|
||||
Str[j++] = '0' + di(val / double_tab[k - p] - 0.499) % 10;
|
||||
}
|
||||
Str[j++] = '.';
|
||||
w = 0.1;
|
||||
for (p = 0; p < 2; p++)
|
||||
{
|
||||
val-=floor(val);
|
||||
Str[j++] = '0' + di(val / w - 0.499) % 10;
|
||||
w /= 10.0;
|
||||
}
|
||||
|
||||
//
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
//
|
||||
Str[j] = 0;
|
||||
}
|
||||
|
||||
void *memcpy(void *dst, const void *src, unsigned size)
|
||||
{
|
||||
while (size--)
|
||||
*((char*)dst+size) = *((char*)src+size);
|
||||
return dst;
|
||||
}
|
||||
*/
|
||||
int strcmp(const char *s1, const char *s2)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (s1 == NULL)
|
||||
if (s2 == NULL)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
else
|
||||
if (s2 == NULL)
|
||||
return 1;
|
||||
|
||||
for (i = 0;;i++)
|
||||
{
|
||||
if (s1[i] == '\0')
|
||||
if (s2[i] == '\0')
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
else
|
||||
if (s2[i] == '\0')
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
if (s1[i] != s2[i])
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
kol_struct_import* kol_cofflib_load(char *name)
|
||||
{
|
||||
//asm ("int $0x40"::"a"(68), "b"(19), "c"(name));
|
||||
__asm
|
||||
{
|
||||
mov eax, 68
|
||||
mov ebx, 19
|
||||
mov ecx, name
|
||||
int 0x40
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void* kol_cofflib_procload (kol_struct_import *imp, char *name)
|
||||
{
|
||||
|
||||
int i;
|
||||
for (i=0;;i++)
|
||||
if ( NULL == ((imp+i) -> name))
|
||||
break;
|
||||
else
|
||||
if ( 0 == strcmp(name, (imp+i)->name) )
|
||||
return (imp+i)->data;
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
unsigned kol_cofflib_procnum (kol_struct_import *imp)
|
||||
{
|
||||
|
||||
unsigned i, n;
|
||||
|
||||
for (i=n=0;;i++)
|
||||
if ( NULL == ((imp+i) -> name))
|
||||
break;
|
||||
else
|
||||
n++;
|
||||
|
||||
return n;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void kol_cofflib_procname (kol_struct_import *imp, char *name, unsigned n)
|
||||
{
|
||||
|
||||
unsigned i;
|
||||
*name = 0;
|
||||
|
||||
for (i=0;;i++)
|
||||
if ( NULL == ((imp+i) -> name))
|
||||
break;
|
||||
else
|
||||
if ( i == n )
|
||||
{
|
||||
strcpy(name, ((imp+i)->name));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
end of system part
|
||||
*/
|
||||
|
||||
|
||||
// ïîñêîëüêó ÿ ïîðòèðîâàë ñ äðåâíåãî äîñà...
|
||||
void line( int x1, int y1, int x2, int y2)
|
||||
{
|
||||
kos_DrawLine(x1,y1,x2,y2,SysColor,0);
|
||||
}
|
||||
|
||||
void outtextxy( int x, int y, char *s, int len)
|
||||
{
|
||||
kos_WriteTextToWindow(x,y,0,SysColor,s,len);
|
||||
}
|
||||
|
||||
double textwidth( char *s, int len)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < len; i++)
|
||||
if (s[i] == 0)
|
||||
break;
|
||||
return id(i * 6);
|
||||
}
|
||||
|
||||
double textheight( char *s, int len)
|
||||
{
|
||||
return 8.0;
|
||||
}
|
||||
|
||||
void setcolor( DWORD color)
|
||||
{
|
||||
SysColor = color;
|
||||
}
|
||||
|
||||
void rectangle( int x1, int y1, int x2, int y2)
|
||||
{
|
||||
kos_DrawBar(x1,y1,x2-x1,y2-y1,SysColor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Dword kos_GetSkinHeight()
|
||||
{
|
||||
__asm{
|
||||
mov eax, 48
|
||||
mov ebx, 4
|
||||
int 0x40
|
||||
}
|
||||
}
|
||||
|
||||
Dword kos_GetSpecialKeyState()
|
||||
{
|
||||
__asm{
|
||||
mov eax, 66
|
||||
mov ebx, 3
|
||||
int 0x40
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Dword kos_GetSlotByPID(Dword PID)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
push ebx
|
||||
push ecx
|
||||
mov eax, 18
|
||||
mov ebx, 21
|
||||
mov ecx, PID
|
||||
int 0x40
|
||||
pop ecx
|
||||
pop ebx
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Dword kos_GetActiveSlot()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
push ebx
|
||||
mov eax, 18
|
||||
mov ebx, 7
|
||||
int 0x40
|
||||
pop ebx
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void kos_GetScrollInfo(int &vert, int &hor)
|
||||
{
|
||||
short v, h;
|
||||
__asm
|
||||
{
|
||||
mov eax, 37
|
||||
mov ebx, 7
|
||||
int 0x40
|
||||
mov ebx, eax
|
||||
and eax, 0xffff
|
||||
mov v, ax
|
||||
shr ebx, 16
|
||||
mov h, bx
|
||||
}
|
||||
vert = v;
|
||||
hor = h;
|
||||
}
|
||||
|
||||
|
||||
// ïîëó÷åíèå èíôîðìàöèè î ñîñòîÿíèè "ìûøè" ôóíêöèÿ 37/1
|
||||
void kos_GetMouseStateWnd( 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.x_start;
|
||||
cursorY = curY - sPI.processInfo.y_start;
|
||||
}
|
||||
|
||||
double atof(char *s)
|
||||
{
|
||||
return convert(s, NULL);
|
||||
}
|
||||
|
||||
|
||||
int di(double x)
|
||||
{
|
||||
int a;
|
||||
__asm fld x
|
||||
__asm fistp a
|
||||
return a;
|
||||
}
|
||||
|
||||
double id(int x)
|
||||
{
|
||||
double a;
|
||||
__asm fild x
|
||||
__asm fstp a
|
||||
return a;
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "kosSyst.h"
|
||||
#include "kosFile.h"
|
||||
#include "MCSMEMM.H"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
#define min(a,b) (((a)<(b))?(a):(b))
|
||||
#define max(a,b) (((a)>(b))?(a):(b))
|
||||
|
||||
|
||||
#define ERROR -1
|
||||
#define ERROR_END -2
|
||||
|
||||
extern int convert_error;
|
||||
|
||||
typedef int HDC;
|
||||
typedef int DWORD;
|
||||
|
||||
extern int SysColor;
|
||||
extern char debuf[50];
|
||||
|
||||
typedef double (*function_t)(double);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double x, y;
|
||||
} TCoord;
|
||||
|
||||
struct kosBDVK
|
||||
{
|
||||
Dword attrib;
|
||||
Dword name_type;
|
||||
Dword create_time;
|
||||
Dword create_date;
|
||||
Dword access_time;
|
||||
Dword access_date;
|
||||
Dword modify_time;
|
||||
Dword modify_date;
|
||||
Dword size_low;
|
||||
Dword size_high;
|
||||
};
|
||||
|
||||
Dword kos_GetSlotByPID(Dword PID);
|
||||
Dword kos_GetActiveSlot();
|
||||
Dword kos_GetSkinHeight();
|
||||
Dword kos_GetSpecialKeyState();
|
||||
void kos_GetMouseStateWnd( Dword & buttons, int & cursorX, int & cursorY );
|
||||
void kos_DrawLine( Word x1, Word y1, Word x2, Word y2, Dword colour, Dword invert);
|
||||
void DrawRegion(Dword x,Dword y,Dword width,Dword height,Dword color1);
|
||||
int atoi(const char* string);
|
||||
void kos_GetScrollInfo(int &vert, int &hor);
|
||||
|
||||
|
||||
Dword kos_GetSlotByPID(Dword PID);
|
||||
Dword kos_GetActiveSlot();
|
||||
Dword kos_GetSkinHeight();
|
||||
Dword kos_GetSpecialKeyState();
|
||||
|
||||
|
||||
double fabs(double x);
|
||||
double cos(double x);
|
||||
double sin(double x);
|
||||
bool isalpha(char c);
|
||||
double convert(char *s, int *len=NULL);
|
||||
void format( char *Str, int len, char* Format, ... );
|
||||
|
||||
void line( int x1, int y1, int x2, int y2);
|
||||
|
||||
void outtextxy( int x, int y, char *s, int len);
|
||||
void settextstyle( int a1, int a2, int a3);
|
||||
|
||||
|
||||
double textwidth( char *s, int len);
|
||||
double textheight( char *s, int len);
|
||||
void setcolor( DWORD color);
|
||||
void unsetcolor(HDC hdc);
|
||||
void rectangle( int x1, int y1, int x2, int y2);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned p00 ;
|
||||
unsigned p04 ;
|
||||
unsigned p08 ;
|
||||
unsigned p12 ;
|
||||
unsigned p16 ;
|
||||
char p20 ;
|
||||
char *p21 ;
|
||||
} kol_struct70 ;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned p00 ;
|
||||
char p04 ;
|
||||
char p05[3] ;
|
||||
unsigned p08 ;
|
||||
unsigned p12 ;
|
||||
unsigned p16 ;
|
||||
unsigned p20 ;
|
||||
unsigned p24 ;
|
||||
unsigned p28 ;
|
||||
unsigned p32[2] ;
|
||||
unsigned p40 ;
|
||||
} kol_struct_BDVK ;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *name ;
|
||||
void *data ;
|
||||
} kol_struct_import ;
|
||||
|
||||
|
||||
|
||||
kol_struct_import* kol_cofflib_load(char *name);
|
||||
void* kol_cofflib_procload (kol_struct_import *imp, char *name);
|
||||
unsigned kol_cofflib_procnum (kol_struct_import *imp);
|
||||
void kol_cofflib_procname (kol_struct_import *imp, char *name, unsigned n);
|
||||
int strcmp(const char* string1, const char* string2);
|
||||
|
||||
char *ftoa(double d);
|
||||
double atof(char *s);
|
||||
|
||||
|
||||
int di(double x);
|
||||
double id(int x);
|
||||
@@ -1,31 +0,0 @@
|
||||
format MS COFF
|
||||
|
||||
StackSize = 16384
|
||||
|
||||
; must be alphabetically first in the image
|
||||
section '.1seg' data readable writable
|
||||
extrn _crtStartUp ; real entry point
|
||||
extrn _kosCmdLine
|
||||
extrn _kosExePath
|
||||
extrn _exeStack
|
||||
public fakeEntry
|
||||
|
||||
kos_header:
|
||||
db 'MENUET01' ; header
|
||||
dd 1 ; headerver
|
||||
dd _crtStartUp ; entry
|
||||
dd 0 ; i_end, filled by doexe2.asm
|
||||
dd 0 ; memsize, filled by doexe2.asm
|
||||
dd _exeStack + StackSize ; stack
|
||||
dd _kosCmdLine ; params
|
||||
dd _kosExePath ; icon
|
||||
fakeEntry: ; only for linker, to force including this obj file
|
||||
; real entry is crtStartUp
|
||||
|
||||
; initializers
|
||||
section '.CRT$XCA' data readable writable
|
||||
public ___xc_a
|
||||
___xc_a:
|
||||
section '.CRT$XCZ' data readable writable
|
||||
public ___xc_z
|
||||
___xc_z:
|
||||
@@ -1,132 +0,0 @@
|
||||
#include "kosSyst.h"
|
||||
#include "kosFile.h"
|
||||
//#include "string.h"
|
||||
|
||||
|
||||
CKosFile::CKosFile(char *fileName)
|
||||
{
|
||||
//
|
||||
this->fileInfo.bufferPtr = new Byte[FILE_BUFFER_SIZE];
|
||||
//
|
||||
this->filePointer = 0;
|
||||
this->bufferPointer = 0;
|
||||
this->validBuffer = false;
|
||||
//
|
||||
strcpy( this->fileInfo.fileURL, fileName );
|
||||
}
|
||||
|
||||
|
||||
CKosFile::~CKosFile(void)
|
||||
{
|
||||
//
|
||||
delete this->fileInfo.bufferPtr;
|
||||
}
|
||||
|
||||
|
||||
void CKosFile::ValidateBuffer()
|
||||
{
|
||||
//
|
||||
if ( this->validBuffer )
|
||||
{
|
||||
//
|
||||
if ( this->filePointer < this->bufferPointer
|
||||
|| this->filePointer >= (this->bufferPointer + FILE_BUFFER_SIZE) )
|
||||
{
|
||||
//
|
||||
this->validBuffer = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CKosFile::UpdateBuffer(void)
|
||||
{
|
||||
//
|
||||
if ( ! this->validBuffer )
|
||||
{
|
||||
//
|
||||
this->fileInfo.OffsetLow = this->filePointer / OS_BLOCK_SIZE;
|
||||
this->fileInfo.OffsetHigh = 0;
|
||||
//
|
||||
this->bufferPointer = this->fileInfo.OffsetLow * OS_BLOCK_SIZE;
|
||||
//
|
||||
this->fileInfo.dataCount = FILE_BUFFER_BLOCKS;
|
||||
//
|
||||
this->fileInfo.rwMode = 0;
|
||||
//
|
||||
Dword rr = kos_FileSystemAccess( &(this->fileInfo) );
|
||||
this->validBuffer = ( rr == 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int CKosFile::Seek(int seekFrom, int seekStep)
|
||||
{
|
||||
//
|
||||
switch ( seekFrom )
|
||||
{
|
||||
//
|
||||
case SEEK_SET:
|
||||
//
|
||||
this->filePointer = seekStep;
|
||||
break;
|
||||
//
|
||||
case SEEK_CUR:
|
||||
//
|
||||
this->filePointer += seekStep;
|
||||
break;
|
||||
}
|
||||
//
|
||||
this->ValidateBuffer();
|
||||
//
|
||||
return this->filePointer;
|
||||
}
|
||||
|
||||
|
||||
int CKosFile::Read(Byte *targetPtr, int readCount)
|
||||
{
|
||||
int bufferLeast, result;
|
||||
|
||||
//
|
||||
result = 0;
|
||||
//
|
||||
do
|
||||
{
|
||||
//
|
||||
this->UpdateBuffer();
|
||||
//
|
||||
if ( ! this->validBuffer ) return result;
|
||||
//
|
||||
bufferLeast = FILE_BUFFER_SIZE - (this->filePointer - this->bufferPointer);
|
||||
//
|
||||
if ( bufferLeast > readCount ) bufferLeast = readCount;
|
||||
//
|
||||
if ( bufferLeast )
|
||||
{
|
||||
//
|
||||
memcpy(
|
||||
targetPtr,
|
||||
this->fileInfo.bufferPtr + (this->filePointer - this->bufferPointer),
|
||||
bufferLeast
|
||||
);
|
||||
//
|
||||
targetPtr += bufferLeast;
|
||||
readCount -= bufferLeast;
|
||||
this->filePointer += bufferLeast;
|
||||
//
|
||||
result += bufferLeast;
|
||||
}
|
||||
//
|
||||
this->ValidateBuffer();
|
||||
}
|
||||
while ( readCount > 0 );
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int CKosFile::Write(Byte *sourcePtr, int writeCount)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#define SEEK_SET 0
|
||||
#define SEEK_CUR 1
|
||||
|
||||
#define FILE_BUFFER_SIZE 512
|
||||
#define OS_BLOCK_SIZE 1
|
||||
#define FILE_BUFFER_BLOCKS (FILE_BUFFER_SIZE / OS_BLOCK_SIZE)
|
||||
|
||||
|
||||
class CKosFile
|
||||
{
|
||||
public:
|
||||
CKosFile(char *fileName);
|
||||
~CKosFile(void);
|
||||
int Read(Byte *targetPtr, int readCount);
|
||||
int Write(Byte *sourcePtr, int writeCount);
|
||||
int Seek(int seekFrom, int seekStep);
|
||||
protected:
|
||||
int filePointer;
|
||||
int bufferPointer;
|
||||
bool validBuffer;
|
||||
kosFileInfo fileInfo;
|
||||
void ValidateBuffer(void);
|
||||
void UpdateBuffer(void);
|
||||
};
|
||||
@@ -1,695 +0,0 @@
|
||||
#include "kosSyst.h"
|
||||
#include "func.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
char kosCmdLine[257];
|
||||
char kosExePath[1024];
|
||||
extern "C" char exeStack[];
|
||||
char exeStack[16384];
|
||||
|
||||
#define atexitBufferSize 32
|
||||
|
||||
#ifndef SMALLLIBC_NO_ATEXIT
|
||||
//
|
||||
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;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
Dword RandomSeed = 0;
|
||||
//
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ïåðåâîä øåñòíàäöàòèðè÷íîãî ÷èñëà â ñèìâîë
|
||||
//
|
||||
|
||||
unsigned int num2hex( unsigned int num )
|
||||
{
|
||||
if( num < 10 )
|
||||
return num + '0';
|
||||
return num - 10 + 'A';
|
||||
}
|
||||
|
||||
|
||||
inline void __declspec(noreturn) kos_sysfuncm1(void)
|
||||
{
|
||||
__asm or eax, -1
|
||||
__asm int 0x40
|
||||
}
|
||||
|
||||
// ôóíêöèÿ -1 çàâåðøåíèÿ ïðîöåññà
|
||||
void kos_ExitApp()
|
||||
{
|
||||
#ifndef SMALLLIBC_NO_ATEXIT
|
||||
int i;
|
||||
|
||||
//
|
||||
for ( i = atExitFnNum - 1; i >= 0; i-- )
|
||||
{
|
||||
//
|
||||
atExitList[i]();
|
||||
}
|
||||
#endif
|
||||
//
|
||||
kos_sysfuncm1();
|
||||
}
|
||||
|
||||
static void __declspec(noinline) __fastcall kos_sysfunc0(Dword _ecx, Dword _edx, Dword _ebx, Dword _esi, Dword _edi)
|
||||
{
|
||||
__asm xor eax, eax
|
||||
__asm mov ebx, _ebx
|
||||
__asm mov esi, _esi
|
||||
__asm mov edi, _edi
|
||||
__asm 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;
|
||||
//
|
||||
kos_sysfunc0(arg2, arg3, arg1, arg4, borderColour);
|
||||
}
|
||||
|
||||
|
||||
// ôóíêöèÿ 1 ïîñòàâèòü òî÷êó
|
||||
void kos_PutPixel( Dword x, Dword y, Dword colour )
|
||||
{
|
||||
//
|
||||
__asm{
|
||||
push 1
|
||||
pop eax
|
||||
mov ebx, x
|
||||
mov ecx, y
|
||||
mov edx, colour
|
||||
int 0x40
|
||||
}
|
||||
}
|
||||
|
||||
inline Dword kos_sysfunc2(void)
|
||||
{
|
||||
__asm push 2
|
||||
__asm pop eax
|
||||
__asm int 0x40
|
||||
}
|
||||
|
||||
// ôóíêöèÿ 2 ïîëó÷èòü êîä íàæàòîé êëàâèøè
|
||||
bool kos_GetKey( Byte &keyCode )
|
||||
{
|
||||
Dword result = kos_sysfunc2();
|
||||
//
|
||||
keyCode = result >> 8;
|
||||
//
|
||||
return ( result & 0xFF ) == 0;
|
||||
}
|
||||
|
||||
|
||||
// ôóíêöèÿ 3 ïîëó÷èòü âðåìÿ
|
||||
Dword kos_GetSystemClock()
|
||||
{
|
||||
// Dword result;
|
||||
|
||||
//
|
||||
__asm{
|
||||
push 3
|
||||
pop eax
|
||||
int 0x40
|
||||
// mov result, eax
|
||||
}
|
||||
//
|
||||
// return result;
|
||||
}
|
||||
|
||||
static void __declspec(noinline) __fastcall kos_sysfunc4(Dword _ecx, const char* _edx, Dword _ebx, Dword _esi)
|
||||
{
|
||||
__asm push 4
|
||||
__asm pop eax
|
||||
__asm mov ebx, [_ebx]
|
||||
__asm mov esi, [_esi]
|
||||
__asm int 0x40
|
||||
}
|
||||
|
||||
// ôóíêöèÿ 4
|
||||
void kos_WriteTextToWindow(
|
||||
Word x,
|
||||
Word y,
|
||||
Byte fontType,
|
||||
Dword textColour,
|
||||
const char *textPtr,
|
||||
Dword textLen
|
||||
)
|
||||
{
|
||||
Dword arg1, arg2;
|
||||
|
||||
//
|
||||
arg1 = ( x << 16 ) | y;
|
||||
arg2 = ( fontType << 24 ) | textColour;
|
||||
//
|
||||
kos_sysfunc4(arg2, textPtr, arg1, textLen);
|
||||
}
|
||||
|
||||
|
||||
// ôóíêöèÿ 5 ïàóçà, â ñîòûõ äîëÿõ ñåêóíäû
|
||||
void kos_Pause( Dword value )
|
||||
{
|
||||
//
|
||||
__asm{
|
||||
push 5
|
||||
pop eax
|
||||
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{
|
||||
push 7
|
||||
pop eax
|
||||
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{
|
||||
push 8
|
||||
pop eax
|
||||
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{
|
||||
push 9
|
||||
pop eax
|
||||
mov ebx, targetPtr
|
||||
mov ecx, processID
|
||||
int 0x40
|
||||
// mov result, eax
|
||||
}
|
||||
//
|
||||
// return result;
|
||||
}
|
||||
|
||||
|
||||
// ôóíêöèÿ 10
|
||||
Dword kos_WaitForEvent()
|
||||
{
|
||||
// Dword result;
|
||||
|
||||
__asm{
|
||||
push 10
|
||||
pop eax
|
||||
int 0x40
|
||||
// mov result, eax
|
||||
}
|
||||
|
||||
// return result;
|
||||
}
|
||||
|
||||
|
||||
// ôóíêöèÿ 11
|
||||
Dword kos_CheckForEvent()
|
||||
{
|
||||
Dword result; //
|
||||
|
||||
__asm{
|
||||
push 11
|
||||
pop eax
|
||||
int 0x40
|
||||
mov result, eax //
|
||||
}
|
||||
|
||||
return result; //
|
||||
}
|
||||
|
||||
|
||||
// ôóíêöèÿ 12
|
||||
void kos_WindowRedrawStatus( Dword status )
|
||||
{
|
||||
__asm{
|
||||
push 12
|
||||
pop eax
|
||||
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{
|
||||
push 13
|
||||
pop eax
|
||||
mov ebx, arg1
|
||||
mov ecx, arg2
|
||||
mov edx, colour
|
||||
int 0x40
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ôóíêöèÿ 17
|
||||
bool kos_GetButtonID( Dword &buttonID )
|
||||
{
|
||||
Dword result;
|
||||
|
||||
//
|
||||
__asm{
|
||||
push 17
|
||||
pop eax
|
||||
int 0x40
|
||||
mov result, eax
|
||||
}
|
||||
//
|
||||
buttonID = result >> 8;
|
||||
//
|
||||
return (result & 0xFF) == 0;
|
||||
}
|
||||
|
||||
|
||||
// ôóíêöèÿ 23
|
||||
Dword kos_WaitForEventTimeout( Dword timeOut )
|
||||
{
|
||||
// Dword result;
|
||||
|
||||
__asm{
|
||||
push 23
|
||||
pop eax
|
||||
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{
|
||||
push 37
|
||||
pop eax
|
||||
xor ebx, ebx
|
||||
int 0x40
|
||||
mov curY, ax
|
||||
shr eax, 16
|
||||
mov curX, ax
|
||||
push 37
|
||||
pop eax
|
||||
push 2
|
||||
pop ebx
|
||||
int 0x40
|
||||
mov mB, eax
|
||||
}
|
||||
//
|
||||
kos_ProcessInfo( &sPI );
|
||||
//
|
||||
buttons = mB;
|
||||
cursorX = curX - sPI.processInfo.x_start;
|
||||
cursorY = curY - sPI.processInfo.y_start;
|
||||
}
|
||||
|
||||
|
||||
// ôóíêöèÿ 40 óñòàíîâèòü ìàñêó ñîáûòèé
|
||||
void kos_SetMaskForEvents( Dword mask )
|
||||
{
|
||||
//
|
||||
__asm{
|
||||
push 40
|
||||
pop eax
|
||||
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{
|
||||
push 47
|
||||
pop eax
|
||||
mov ebx, arg1
|
||||
mov ecx, value
|
||||
mov edx, arg2
|
||||
mov esi, colour
|
||||
int 0x40
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ôóíêöèÿ 70 äîñòóï ê ôàéëîâîé ñèñòåìå
|
||||
Dword kos_FileSystemAccess( kosFileInfo *fileInfo )
|
||||
{
|
||||
// Dword result;
|
||||
|
||||
//
|
||||
__asm{
|
||||
push 70
|
||||
pop eax
|
||||
mov ebx, fileInfo
|
||||
int 0x40
|
||||
// mov result, eax
|
||||
}
|
||||
//
|
||||
// return result;
|
||||
}
|
||||
|
||||
|
||||
// ôóíêöèÿ 63 âûâîä ñèìâîëÿ â îêíî îòëàäêè
|
||||
void kos_DebugOutChar( char ccc )
|
||||
{
|
||||
//
|
||||
__asm{
|
||||
push 63
|
||||
pop eax
|
||||
push 1
|
||||
pop ebx
|
||||
mov cl, ccc
|
||||
int 0x40
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ôóíêöèÿ 66 ðåæèì ïîëó÷åíèÿ äàííûõ îò êëàâèàòóðû
|
||||
void kos_SetKeyboardDataMode( Dword mode )
|
||||
{
|
||||
//
|
||||
__asm{
|
||||
push 66
|
||||
pop eax
|
||||
push 1
|
||||
pop ebx
|
||||
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{
|
||||
push 64
|
||||
pop eax
|
||||
push 1
|
||||
pop ebx
|
||||
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{
|
||||
push 67
|
||||
pop eax
|
||||
mov ebx, x
|
||||
mov ecx, y
|
||||
mov edx, sizeX
|
||||
mov esi, sizeY
|
||||
int 0x40
|
||||
}
|
||||
}
|
||||
|
||||
void kos_InitHeap()
|
||||
{
|
||||
__asm{
|
||||
push 68
|
||||
pop eax
|
||||
push 11
|
||||
pop ebx
|
||||
int 0x40
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// âûçîâ ñòàòè÷åñêèõ èíèöèàëèçàòîðîâ
|
||||
typedef void (__cdecl *_PVFV)(void);
|
||||
extern "C" _PVFV __xc_a[];
|
||||
extern "C" _PVFV __xc_z[];
|
||||
#pragma comment(linker, "/merge:.CRT=.rdata")
|
||||
//
|
||||
void __cdecl crtStartUp()
|
||||
{
|
||||
#ifndef SMALLLIBC_NO_INIT
|
||||
// âûçûâàåì èíèöèàëèçàòîðû ïî ñïèñêó
|
||||
for ( _PVFV *pbegin = __xc_a; pbegin < __xc_z; pbegin++ )
|
||||
{
|
||||
//
|
||||
(**pbegin)();
|
||||
}
|
||||
#endif
|
||||
// èíèöèàëèçèðóåì ãåíåðàòîð ñëó÷àéíûõ ÷èñåë
|
||||
// åñëè íàäî äëÿ ïðèëîæåíèÿ, äåëàòü ýòî â kos_Main()
|
||||
//rtlSrand( kos_GetSystemClock() );
|
||||
// âûçîâ ãëàâíîé ôóíêöèè ïðèëîæåíèÿ
|
||||
kos_Main();
|
||||
// âûõîä
|
||||
kos_ExitApp();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,217 +0,0 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned __int32 Dword;
|
||||
typedef unsigned __int16 Word;
|
||||
typedef unsigned __int8 Byte;
|
||||
//typedef unsigned __int32 size_t;
|
||||
|
||||
extern "C" char kosCmdLine[]; // command line initialized by OS
|
||||
extern "C" char kosExePath[]; // path to binary initialized by OS
|
||||
|
||||
#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 __cdecl acos(double x);
|
||||
extern "C" double __cdecl asin(double x);
|
||||
extern "C" double __cdecl floor(double x);
|
||||
extern "C" double __cdecl 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;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#pragma pack(push, 1)
|
||||
union sProcessInfo
|
||||
{
|
||||
Byte rawData[1024];
|
||||
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 x_start;
|
||||
Dword y_start;
|
||||
Dword x_size;
|
||||
Dword y_size;
|
||||
Word slot_state;
|
||||
} processInfo;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//
|
||||
extern "C" void __cdecl 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 );
|
||||
|
||||
#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
|
||||
|
||||
unsigned int num2hex( unsigned int num );
|
||||
void sprintf( char *Str, char* Format, ... );
|
||||
//
|
||||
Dword rtlInterlockedExchange( Dword *target, Dword value );
|
||||
// ôóíêöèÿ -1 çàâåðøåíèÿ ïðîöåññà
|
||||
void __declspec(noreturn) 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,
|
||||
const char *textPtr,
|
||||
Dword textLen
|
||||
);
|
||||
// ôóíêöèÿ 7 íàðèñîâàòü èçîáðàæåíèå
|
||||
void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y );
|
||||
// ôóíêöèÿ 8 îïðåäåëèòü êíîïêó
|
||||
void __declspec(noinline) 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 __declspec(noinline) kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour );
|
||||
// ôóíêöèÿ 17
|
||||
bool kos_GetButtonID( Dword &buttonID );
|
||||
// ôóíêöèÿ 23
|
||||
Dword kos_WaitForEventTimeout( 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 );
|
||||
|
||||
void kos_InitHeap();
|
||||
|
||||
//
|
||||
void kos_Main();
|
||||
@@ -1,83 +0,0 @@
|
||||
#include <math.h>
|
||||
#include "kosSyst.h"
|
||||
extern "C" int _fltused = 0;
|
||||
double __cdecl acos(double x)
|
||||
{
|
||||
__asm {
|
||||
fld qword ptr [esp+4]
|
||||
fld1
|
||||
fadd st, st(1)
|
||||
fld1
|
||||
fsub st, st(2)
|
||||
fmulp st(1), st
|
||||
fsqrt
|
||||
fxch st(1)
|
||||
fpatan
|
||||
}
|
||||
}
|
||||
double __cdecl asin(double x)
|
||||
{
|
||||
__asm {
|
||||
fld qword ptr [esp+4]
|
||||
fld1
|
||||
fadd st, st(1)
|
||||
fld1
|
||||
fsub st, st(2)
|
||||
fmulp st(1), st
|
||||
fsqrt
|
||||
fpatan
|
||||
ret
|
||||
}
|
||||
}
|
||||
#if _MSC_VER <= 1200
|
||||
extern "C" double _ftol(double x)
|
||||
{
|
||||
__asm {
|
||||
fld qword ptr [esp+4]
|
||||
push 1F3Fh
|
||||
fstcw word ptr [esp+2]
|
||||
fldcw word ptr [esp]
|
||||
frndint
|
||||
fldcw word ptr [esp+2]
|
||||
add esp, 4
|
||||
}
|
||||
}
|
||||
#endif
|
||||
double __cdecl ceil(double x)
|
||||
{
|
||||
__asm {
|
||||
fld qword ptr [esp+4]
|
||||
push 1B3Fh
|
||||
fstcw word ptr [esp+2]
|
||||
fldcw word ptr [esp]
|
||||
frndint
|
||||
fldcw word ptr [esp+2]
|
||||
add esp, 4
|
||||
}
|
||||
}
|
||||
|
||||
double __cdecl floor(double x)
|
||||
{
|
||||
__asm {
|
||||
fld qword ptr [esp+4]
|
||||
push 173Fh
|
||||
fstcw word ptr [esp+2]
|
||||
fldcw word ptr [esp]
|
||||
frndint
|
||||
fldcw word ptr [esp+2]
|
||||
add esp, 4
|
||||
}
|
||||
}
|
||||
|
||||
double __cdecl round(double x)
|
||||
{
|
||||
__asm {
|
||||
fld qword ptr [esp+4]
|
||||
push 133Fh
|
||||
fstcw word ptr [esp+2]
|
||||
fldcw word ptr [esp]
|
||||
frndint
|
||||
fldcw word ptr [esp+2]
|
||||
add esp, 4
|
||||
}
|
||||
}
|
||||
@@ -1,373 +0,0 @@
|
||||
// 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 );
|
||||
}
|
||||
|
||||
void __cdecl initHeap(void)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
push 68
|
||||
pop eax
|
||||
push 11
|
||||
pop ebx
|
||||
int 0x40
|
||||
}
|
||||
}
|
||||
|
||||
#pragma data_seg(".CRT$XCB")
|
||||
__declspec(allocate(".CRT$XCB")) void (__cdecl *initHeapPtr)(void) = &initHeap;
|
||||
|
||||
__declspec(noinline) Byte* __fastcall allocmem( Dword reqsize )
|
||||
{
|
||||
initHeapPtr; // force dependency
|
||||
__asm
|
||||
{
|
||||
push 68
|
||||
pop eax
|
||||
push 12
|
||||
pop ebx
|
||||
int 0x40
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
__declspec(noinline) void __fastcall freemem( void *vaddress )
|
||||
{
|
||||
initHeapPtr; // force dependency
|
||||
__asm
|
||||
{
|
||||
push 68
|
||||
pop eax
|
||||
push 13
|
||||
pop ebx
|
||||
int 0x40
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
|
||||
//
|
||||
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;
|
||||
}
|
||||
|
||||
*/
|
||||
@@ -1,28 +0,0 @@
|
||||
//
|
||||
|
||||
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 * __fastcall allocmem( Dword reqsize );
|
||||
void __fastcall freemem( void *vaddress );
|
||||
|
||||
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
/* Rocket Forces
|
||||
* Filename: mymath.h
|
||||
* Version 0.1
|
||||
* Copyright (c) Serial 2007
|
||||
*/
|
||||
|
||||
|
||||
extern "C" int _fltused = 0;
|
||||
|
||||
#define M_PI 3.14159265358979323846
|
||||
|
||||
inline double sin(double x)
|
||||
{
|
||||
__asm fld x
|
||||
__asm fsin
|
||||
}
|
||||
|
||||
inline double cos(double x)
|
||||
{
|
||||
__asm fld x
|
||||
__asm fcos
|
||||
}
|
||||
|
||||
inline double sqrt(double x)
|
||||
{
|
||||
__asm fld x
|
||||
__asm fsqrt
|
||||
}
|
||||
|
||||
inline double acos(double x)
|
||||
{
|
||||
__asm fld x
|
||||
__asm fld st(0)
|
||||
__asm fmul st,st(1)
|
||||
__asm fld1
|
||||
__asm fsubrp st(1),st(0)
|
||||
__asm fsqrt
|
||||
__asm fxch st(1)
|
||||
__asm fpatan
|
||||
}
|
||||
|
||||
inline double atan(double x)
|
||||
{
|
||||
double res = acos(1 / sqrt(1 + x * x));
|
||||
if (x < 0)
|
||||
{
|
||||
res *= -1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
inline int round_int(double x)
|
||||
{
|
||||
int i;
|
||||
static const float round_to_nearest = 0.5f;
|
||||
__asm
|
||||
{
|
||||
fld x
|
||||
fadd st, st(0)
|
||||
fadd round_to_nearest
|
||||
fistp i
|
||||
sar i, 1
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
inline int floor_int(double x)
|
||||
{
|
||||
int i;
|
||||
static const float round_toward_m_i = -0.5f;
|
||||
__asm
|
||||
{
|
||||
fld x
|
||||
fadd st, st (0)
|
||||
fadd round_toward_m_i
|
||||
fistp i
|
||||
sar i, 1
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
inline int ceil_int(double x)
|
||||
{
|
||||
int i;
|
||||
static const float round_toward_p_i = -0.5f;
|
||||
__asm
|
||||
{
|
||||
fld x
|
||||
fadd st, st (0)
|
||||
fsubr round_toward_p_i
|
||||
fistp i
|
||||
sar i, 1
|
||||
}
|
||||
return (-i);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#include "kosSyst.h"
|
||||
static char pureCallMessage[] = "PURE function call!";
|
||||
|
||||
// âûçîâ àáñòðàêòíîãî ìåòîäà
|
||||
int __cdecl _purecall()
|
||||
{
|
||||
rtlDebugOutString( pureCallMessage );
|
||||
kos_ExitApp();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{0D291390-1953-4E1F-BBE2-57F12AFF3214}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>smalllibc</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="func.h" />
|
||||
<ClInclude Include="kosFile.h" />
|
||||
<ClInclude Include="kosSyst.h" />
|
||||
<ClInclude Include="mcsmemm.h" />
|
||||
<ClInclude Include="mymath.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="func.cpp" />
|
||||
<ClCompile Include="kosFile.cpp" />
|
||||
<ClCompile Include="kosSyst.cpp" />
|
||||
<ClCompile Include="math2.cpp" />
|
||||
<ClCompile Include="mcsmemm.cpp" />
|
||||
<ClCompile Include="purecall.cpp" />
|
||||
<ClCompile Include="sprintf.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Object Include="init.obj" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -1,60 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Файлы исходного кода">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Заголовочные файлы">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Файлы ресурсов">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="func.h">
|
||||
<Filter>Заголовочные файлы</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="kosFile.h">
|
||||
<Filter>Заголовочные файлы</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="kosSyst.h">
|
||||
<Filter>Заголовочные файлы</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="mcsmemm.h">
|
||||
<Filter>Заголовочные файлы</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="mymath.h">
|
||||
<Filter>Заголовочные файлы</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="func.cpp">
|
||||
<Filter>Файлы исходного кода</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="kosFile.cpp">
|
||||
<Filter>Файлы исходного кода</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="kosSyst.cpp">
|
||||
<Filter>Файлы исходного кода</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="math2.cpp">
|
||||
<Filter>Файлы исходного кода</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="mcsmemm.cpp">
|
||||
<Filter>Файлы исходного кода</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sprintf.cpp">
|
||||
<Filter>Файлы исходного кода</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="purecall.cpp">
|
||||
<Filter>Файлы исходного кода</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Object Include="init.obj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,228 +0,0 @@
|
||||
#include "kosSyst.h"
|
||||
#include "func.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// âûâîä ñòðîêè íà ïå÷àòü. barsuk äîáàâèë %f
|
||||
|
||||
//#define PREC 2
|
||||
//#define HALF 0.499
|
||||
#define PREC 6
|
||||
#define HALF 0.4999999
|
||||
|
||||
static double double_tab[]={1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
|
||||
1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 1e23, 1e24, 1e25, 1e26, 1e27, 1e28, 1e29, 1e30};
|
||||
|
||||
|
||||
//
|
||||
|
||||
static 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;
|
||||
// âåùåñòâåííîå ÷èñëî â ôîðìàòå 7.2
|
||||
case 'f':
|
||||
case 'F':
|
||||
case 'g':
|
||||
case 'G':
|
||||
{
|
||||
double val, w;
|
||||
int p;
|
||||
val = va_arg(arglist, double);
|
||||
if (val < 0.0)
|
||||
{
|
||||
Str[j++] = '-';
|
||||
val = -val;
|
||||
}
|
||||
for (k = 0; k < 30; k++)
|
||||
if (val < double_tab[k])
|
||||
break;
|
||||
|
||||
if (val < 1.0)
|
||||
{
|
||||
Str[j++] = '0';
|
||||
}
|
||||
|
||||
for (p = 1; p < k + 1; p++)
|
||||
{
|
||||
int d = (int)di(val / double_tab[k - p] - HALF) % 10;
|
||||
Str[j++] = '0' + d;
|
||||
val -= d * double_tab[k - p];
|
||||
}
|
||||
Str[j++] = '.';
|
||||
w = 0.1;
|
||||
for (p = 0; p < PREC - 1; p++)
|
||||
{
|
||||
val-=floor(val);
|
||||
Str[j++] = '0' + di(val / w - HALF) % 10;
|
||||
w /= 10.0;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
char *ftoa(double d)
|
||||
{
|
||||
char buffer[256], *p;
|
||||
sprintf(buffer, "%f", d);
|
||||
p = (char*)allocmem(strlen(buffer)+1);
|
||||
strcpy(p, buffer);
|
||||
return p;
|
||||
}
|
||||
|
||||
25
programs/games/flpybird/README.md
Normal file
25
programs/games/flpybird/README.md
Normal file
@@ -0,0 +1,25 @@
|
||||
## Floppy Bird for KolibriOS
|
||||
|
||||
Simple clone of world-famous Flappy Bird game for KolibriOS, written in C.
|
||||
|
||||
### Links
|
||||
|
||||
* [Forum topic](http://board.kolibrios.org/viewtopic.php?t=4471)
|
||||
|
||||
### Controls
|
||||
|
||||
* Main menu:
|
||||
* 1 - fast game mode
|
||||
* 2 - slow game mode
|
||||
* Game:
|
||||
* Space - jump
|
||||
* Game over:
|
||||
* Space - restart
|
||||
* Escape - return to main menu
|
||||
|
||||
### Authors
|
||||
|
||||
* zorggish - initial author, all game code
|
||||
* Burer - rewrite to C, some tweaks
|
||||
|
||||
<img src="https://i.ibb.co/JW3MCHmM/showcase.png" alt="Showcase" width="100%">
|
||||
12
programs/games/flpybird/Tupfile.lua
Normal file
12
programs/games/flpybird/Tupfile.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
if tup.getconfig("NO_TCC") ~= "" then return end
|
||||
if tup.getconfig("HELPERDIR") == ""
|
||||
then
|
||||
HELPERDIR = "../../../programs"
|
||||
end
|
||||
tup.include(HELPERDIR .. "/use_tcc.lua")
|
||||
|
||||
SRCS = {
|
||||
"flpybird.c"
|
||||
}
|
||||
|
||||
link_tcc(SRCS, "flpybird");
|
||||
352
programs/games/flpybird/flpybird.c
Normal file
352
programs/games/flpybird/flpybird.c
Normal file
@@ -0,0 +1,352 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
//
|
||||
// Floppy Bird - Infinite flopping game
|
||||
// Copyright (C) 2021-2025 KolibriOS team
|
||||
//
|
||||
// Contributor zorggish - Main code
|
||||
// Contributor Burer - Rewrite to C
|
||||
|
||||
#include <sys/ksys.h>
|
||||
|
||||
#include "images.h"
|
||||
|
||||
/* ===== Global const strings ===== */
|
||||
|
||||
static const char HEADER_STRING[] = "Floppy Bird";
|
||||
static const char CONTROL_STRING[] = "SPACEBAR TO JUMP";
|
||||
static const char GAMEOVER_STRING[] = "GAME OVER";
|
||||
static const char SPA_KEY_STRING[] = "PRESS SPACEBAR FOR RESTART";
|
||||
static const char ESC_KEY_STRING[] = "PRESS ESCAPE FOR MENU";
|
||||
static const char FAST_STRING[] = "1 - FAST";
|
||||
static const char SLOW_STRING[] = "2 - SLOW";
|
||||
|
||||
/* ===== Global window variables ===== */
|
||||
|
||||
#define WIN_W 400
|
||||
#define WIN_H 376
|
||||
#define WIN_B 5
|
||||
#define WIN_S 10
|
||||
|
||||
static int WIN_X;
|
||||
static int WIN_Y;
|
||||
static int WIN_T;
|
||||
|
||||
/* ===== Global game variables ===== */
|
||||
|
||||
#define GAMESTATE_MENU 0
|
||||
#define GAMESTATE_STARTED 1
|
||||
#define GAMESTATE_GAMEOVER 2
|
||||
|
||||
static int game_rng;
|
||||
static int game_speed = 1;
|
||||
static int game_pause = 0;
|
||||
static char game_score[] = "Score: 000";
|
||||
static int game_state;
|
||||
|
||||
/* ===== Bird ===== */
|
||||
|
||||
#define BIRD_W 19
|
||||
#define BIRD_H 20
|
||||
#define BIRD_X 100
|
||||
|
||||
static int bird_pos;
|
||||
static int bird_acc;
|
||||
|
||||
static void Bird_initialize(void) {
|
||||
bird_pos = (WIN_H + WIN_T) / 2;
|
||||
bird_acc = 0;
|
||||
}
|
||||
|
||||
static void Bird_move(void) {
|
||||
bird_acc += (bird_acc <= 30) * 2; // 2 or 0
|
||||
bird_pos += bird_acc / 10;
|
||||
}
|
||||
|
||||
static void Bird_jump(void) {
|
||||
bird_acc = -50;
|
||||
}
|
||||
|
||||
/* ===== Tube ===== */
|
||||
|
||||
#define TUBE_WIDTH 50
|
||||
#define TUBE_GAPHEIGHT 100
|
||||
#define TUBE_HEADHEIGHT 18
|
||||
|
||||
#define tube_num 3
|
||||
|
||||
static int tube_pos[tube_num];
|
||||
static int tube_gap[tube_num];
|
||||
|
||||
static void Tube_randomize(int t) {
|
||||
int x = game_rng; x ^= x << 13; x ^= x >> 17; x ^= x << 5; game_rng = x;
|
||||
int r = x & 255u;
|
||||
if (r >= WIN_H / 2)
|
||||
r -= 256 - WIN_H / 2;
|
||||
tube_pos[t] = WIN_W + 1;
|
||||
tube_gap[t] = r + (WIN_H / 2 - TUBE_GAPHEIGHT - WIN_B) / 2;
|
||||
}
|
||||
|
||||
static void Tube_move(int t) {
|
||||
tube_pos[t] -= 2;
|
||||
if (tube_pos[t] < -TUBE_WIDTH - 2)
|
||||
Tube_randomize(t);
|
||||
}
|
||||
|
||||
static void Tube_draw(int t) {
|
||||
/* cleanup */
|
||||
int pixels = WIN_W - WIN_S - TUBE_WIDTH - tube_pos[t];
|
||||
if (pixels > 0) {
|
||||
if (pixels > 2)
|
||||
pixels = 2;
|
||||
_ksys_draw_bar(tube_pos[t] + TUBE_WIDTH, tube_gap[t] - TUBE_HEADHEIGHT, pixels, TUBE_HEADHEIGHT, GAME_PALETTE[0]);
|
||||
_ksys_draw_bar(tube_pos[t] + TUBE_WIDTH, tube_gap[t] + TUBE_GAPHEIGHT , pixels, TUBE_HEADHEIGHT, GAME_PALETTE[0]);
|
||||
}
|
||||
if (tube_pos[t] < 0) {
|
||||
int w = -tube_pos[t];
|
||||
if (w > 2)
|
||||
w = 2;
|
||||
_ksys_draw_bar(0, tube_gap[t] - TUBE_HEADHEIGHT, w, TUBE_HEADHEIGHT, GAME_PALETTE[0]);
|
||||
_ksys_draw_bar(0, tube_gap[t] + TUBE_GAPHEIGHT , w, TUBE_HEADHEIGHT, GAME_PALETTE[0]);
|
||||
}
|
||||
|
||||
int offset = tube_pos[t] >= 0 ? 0 : -tube_pos[t];
|
||||
int trim = (tube_pos[t] + TUBE_WIDTH >= WIN_W - WIN_S)
|
||||
? WIN_W - tube_pos[t] - TUBE_WIDTH - WIN_S : 0;
|
||||
|
||||
if (offset >= TUBE_WIDTH + trim)
|
||||
return;
|
||||
|
||||
/* top */
|
||||
for (int y = 0; y < tube_gap[t] - TUBE_HEADHEIGHT; ++y)
|
||||
ksys_draw_bitmap_palette(
|
||||
TUBE_BODY_IMAGE + offset,
|
||||
tube_pos[t] + offset, y, TUBE_WIDTH - offset + trim, 1, 8, GAME_PALETTE, 0
|
||||
);
|
||||
|
||||
/* head top */
|
||||
for (int y = tube_gap[t] - TUBE_HEADHEIGHT; y < tube_gap[t]; ++y)
|
||||
ksys_draw_bitmap_palette(
|
||||
TUBE_HEAD_IMAGE + TUBE_WIDTH * (y - tube_gap[t] + TUBE_HEADHEIGHT) + offset,
|
||||
tube_pos[t] + offset, y, TUBE_WIDTH - offset + trim, 1, 8, GAME_PALETTE, 0
|
||||
);
|
||||
/* head down */
|
||||
for (int y = tube_gap[t] + TUBE_GAPHEIGHT; y < tube_gap[t] + TUBE_GAPHEIGHT + TUBE_HEADHEIGHT; ++y)
|
||||
ksys_draw_bitmap_palette(
|
||||
TUBE_HEAD_IMAGE + TUBE_WIDTH * (y - tube_gap[t] - TUBE_GAPHEIGHT) + offset,
|
||||
tube_pos[t] + offset, y, TUBE_WIDTH - offset + trim, 1, 8, GAME_PALETTE, 0
|
||||
);
|
||||
/* down */
|
||||
for (int y = tube_gap[t] + TUBE_GAPHEIGHT + TUBE_HEADHEIGHT; y < WIN_H - WIN_B; ++y)
|
||||
ksys_draw_bitmap_palette(
|
||||
TUBE_BODY_IMAGE + offset,
|
||||
tube_pos[t] + offset, y, TUBE_WIDTH - offset + trim, 1, 8, GAME_PALETTE, 0
|
||||
);
|
||||
}
|
||||
|
||||
/* ===== Functions - Helpers ===== */
|
||||
|
||||
static void WriteBorderedText(int x, int y, const char* textPtr, int textLen, int fontType) {
|
||||
for (int bx = x + 2; bx >= x - 2; --bx) {
|
||||
for (int by = y + 2; by >= y - 2; --by) {
|
||||
_ksys_draw_text(textPtr, bx, by, textLen, fontType);
|
||||
}
|
||||
}
|
||||
_ksys_draw_text(textPtr, x, y, textLen, fontType | 0x00FFFFFF);
|
||||
}
|
||||
|
||||
/* ===== Functions - Game Logic ===== */
|
||||
|
||||
static inline int checkCollision(int t) {
|
||||
return ((tube_pos[t] <= (BIRD_X + BIRD_W) && tube_pos[t] + TUBE_WIDTH >= BIRD_X)
|
||||
&& (bird_pos <= tube_gap[t] || bird_pos + BIRD_H >= tube_gap[t] + TUBE_GAPHEIGHT)) ? 1 : 0;
|
||||
}
|
||||
|
||||
static inline int checkAddScore(int t) {
|
||||
int r = tube_pos[t] + TUBE_WIDTH;
|
||||
return (r + 2 >= BIRD_X) & (r < BIRD_X);
|
||||
}
|
||||
|
||||
static void updateScoreString(void) {
|
||||
for (int i = 9; i >= 6; --i) {
|
||||
if (++game_score[i] <= '9') return;
|
||||
game_score[i] = '0';
|
||||
}
|
||||
}
|
||||
|
||||
/* ===== Functions - Game Drawing ===== */
|
||||
|
||||
static inline void createGameWindow(void) {
|
||||
_ksys_create_window(WIN_X, WIN_Y, WIN_W, WIN_H + WIN_T, HEADER_STRING, GAME_PALETTE[0], 0x34);
|
||||
}
|
||||
|
||||
static void redrawGameWindow(void) {
|
||||
/* cleaning the score area */
|
||||
|
||||
int move = bird_acc / 10;
|
||||
if (move < 0)
|
||||
move = -move;
|
||||
_ksys_draw_bar(BIRD_X, bird_pos - move, BIRD_W, move * 2 + BIRD_H, GAME_PALETTE[0]);
|
||||
|
||||
ksys_draw_bitmap_palette(BIRD_IMAGE, BIRD_X, bird_pos, BIRD_W, BIRD_H, 8, GAME_PALETTE, 0);
|
||||
|
||||
Tube_draw(0); Tube_draw(1); Tube_draw(2);
|
||||
|
||||
WriteBorderedText(10, 10, game_score, 0, 0x81000000);
|
||||
}
|
||||
|
||||
static void drawGameOverWindow(void) {
|
||||
createGameWindow();
|
||||
|
||||
WriteBorderedText(116, 100, GAMEOVER_STRING, 0, 0x82000000);
|
||||
WriteBorderedText(136, 157, game_score, 0, 0x81000000);
|
||||
WriteBorderedText( 40, 207, SPA_KEY_STRING, 0, 0x81000000);
|
||||
WriteBorderedText( 70, 241, ESC_KEY_STRING, 0, 0x81000000);
|
||||
}
|
||||
|
||||
static void drawMenuWindow(void) {
|
||||
createGameWindow();
|
||||
|
||||
WriteBorderedText( 88, 34, HEADER_STRING, 6, 0x04000000);
|
||||
WriteBorderedText(188, 87, HEADER_STRING + 7, 4, 0x04000000);
|
||||
|
||||
char* pos = &TUBE_HEAD_IMAGE[0];
|
||||
for (int x = 50 - 1; x >= 50 - TUBE_HEADHEIGHT; --x) {
|
||||
for (int y = 156; y < 156 + TUBE_WIDTH; ++y) {
|
||||
ksys_draw_bitmap_palette(pos, x, y , 1, 1, 8, GAME_PALETTE, 0);
|
||||
ksys_draw_bitmap_palette(pos, x, y + 82, 1, 1, 8, GAME_PALETTE, 0);
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 50; x < WIN_W - WIN_S; ++x)
|
||||
{
|
||||
ksys_draw_bitmap_palette(TUBE_BODY_IMAGE, x, 156, 1, TUBE_WIDTH, 8, GAME_PALETTE, 0);
|
||||
ksys_draw_bitmap_palette(TUBE_BODY_IMAGE, x, 238, 1, TUBE_WIDTH, 8, GAME_PALETTE, 0);
|
||||
}
|
||||
|
||||
WriteBorderedText(139, 171, FAST_STRING, 0, 0x82000000);
|
||||
WriteBorderedText(139, 253, SLOW_STRING, 0, 0x82000000);
|
||||
|
||||
// Control hint
|
||||
WriteBorderedText(100, 322, CONTROL_STRING, 0, 0x81000000);
|
||||
}
|
||||
|
||||
/* ===== Functions - Game Main ===== */
|
||||
|
||||
static void startGame(void) {
|
||||
createGameWindow();
|
||||
|
||||
game_score[7] = game_score[8] = game_score[9] = '0';
|
||||
|
||||
Bird_initialize();
|
||||
|
||||
const int spacing = (WIN_W + TUBE_WIDTH) / 3;
|
||||
for (int i = tube_num - 1; i >= 0; --i) {
|
||||
Tube_randomize(i);
|
||||
tube_pos[i] = WIN_W + i * spacing;
|
||||
}
|
||||
|
||||
game_state = GAMESTATE_STARTED;
|
||||
}
|
||||
|
||||
static void frameGame(void) {
|
||||
Bird_move();
|
||||
|
||||
/* Processing all tubes */
|
||||
for (int i = tube_num - 1; i >= 0; --i) {
|
||||
/* Adding score */
|
||||
if (checkAddScore(i)) {
|
||||
updateScoreString();
|
||||
_ksys_draw_bar(92, 8, 38, 18, GAME_PALETTE[0]);
|
||||
}
|
||||
|
||||
/* Check collision with bird */
|
||||
if (checkCollision(i))
|
||||
goto game_over;
|
||||
|
||||
/* Move tube */
|
||||
Tube_move(i);
|
||||
}
|
||||
|
||||
/* Checking bird is too high or low */
|
||||
if (bird_pos + BIRD_H > WIN_H - WIN_B || bird_pos < 0)
|
||||
goto game_over;
|
||||
|
||||
redrawGameWindow();
|
||||
return;
|
||||
|
||||
game_over:
|
||||
game_state = GAMESTATE_GAMEOVER;
|
||||
drawGameOverWindow();
|
||||
return;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
/* Setting RNG seed */
|
||||
ksys_time_t t = _ksys_get_time();
|
||||
game_rng = (int)t.val | 1u;
|
||||
|
||||
/* Centering window */
|
||||
ksys_pos_t screen = _ksys_screen_size();
|
||||
WIN_X = (screen.x - WIN_W) / 2;
|
||||
WIN_Y = (screen.y - WIN_H) / 2;
|
||||
WIN_T = _ksys_get_skin_height();
|
||||
|
||||
game_state = GAMESTATE_MENU;
|
||||
|
||||
for (;;) {
|
||||
_ksys_delay(game_speed);
|
||||
|
||||
switch (_ksys_check_event()) {
|
||||
case KSYS_EVENT_NONE:
|
||||
if (game_state == GAMESTATE_STARTED)
|
||||
frameGame();
|
||||
break;
|
||||
|
||||
case KSYS_EVENT_REDRAW: {
|
||||
switch (game_state) {
|
||||
case GAMESTATE_MENU: drawMenuWindow(); break;
|
||||
case GAMESTATE_STARTED: redrawGameWindow(); break;
|
||||
case GAMESTATE_GAMEOVER: drawGameOverWindow(); break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case KSYS_EVENT_KEY: {
|
||||
ksys_oskey_t k = _ksys_get_key();
|
||||
switch (game_state) {
|
||||
case GAMESTATE_MENU: {
|
||||
unsigned kc = k.code - 49; // 1 or 2
|
||||
if (kc <= 1) {
|
||||
game_speed = kc + 1;
|
||||
startGame();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GAMESTATE_STARTED: {
|
||||
if (k.code == 32) // SPACE
|
||||
Bird_jump();
|
||||
break;
|
||||
}
|
||||
case GAMESTATE_GAMEOVER: {
|
||||
if (k.code == 32) // SPACE
|
||||
startGame();
|
||||
if (k.code == 27) // ESCAPE
|
||||
{
|
||||
game_state = GAMESTATE_MENU;
|
||||
drawMenuWindow();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case KSYS_EVENT_BUTTON:
|
||||
_ksys_exit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
74
programs/games/flpybird/images.h
Normal file
74
programs/games/flpybird/images.h
Normal file
@@ -0,0 +1,74 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
//
|
||||
// Floppy Bird - Infinite flopping game
|
||||
// Copyright (C) 2021-2025 KolibriOS team
|
||||
//
|
||||
// Contributor zorggish - Main code
|
||||
// Contributor Burer - Rewrite to C
|
||||
|
||||
#pragma once
|
||||
|
||||
static const int GAME_PALETTE[77] = {
|
||||
// Shared colors
|
||||
0x0000FFFF, 0x00E0E080, 0x00C0C080, 0x0080A040, 0x00A0C040, 0x00A0C080, 0x00A0E040, 0x0060A040,
|
||||
0x00C0E080,
|
||||
// Bird-only colors
|
||||
0x00C08040, 0x00608080, 0x0040C0C0, 0x00E0C080, 0x00806040, 0x00C0DCC0, 0x00A06040, 0x0080C0C0,
|
||||
0x00E0A040, 0x0020C0C0, 0x00C06040, 0x00C0A080, 0x00A0A080, 0x00800040, 0x00E02080, 0x00E060C0,
|
||||
0x00808080, 0x00E020C0, 0x00E0A0C0, 0x00804080, 0x00FFFBF0, 0x00E040C0, 0x00002040, 0x00404040,
|
||||
0x00806080, 0x00A08080, 0x00E0E000, 0x00A0A0A4, 0x0020A080, 0x0040A0C0, 0x0060C0C0, 0x00E0C040,
|
||||
0x00C00080, 0x00FFFF00, 0x00C0A040, 0x0060A080, 0x0080A080, 0x00C0C0C0, 0x00E0E040, 0x00C0E000,
|
||||
0x0080E080, 0x00A0A040, 0x0040C080, 0x0060E080, 0x00606080, 0x00C0C040, 0x00C0C000, 0x00808040,
|
||||
0x00C0E040, 0x00A0C000, 0x006080C0, 0x00A0C0C0, 0x00A0E080,
|
||||
// Tube-only colors
|
||||
0x00000000, 0x00608040,
|
||||
0x0080E040, 0x0080C040, 0x0060A000, 0x0040A000, 0x00408000, 0x00204000, 0x00206000, 0x00200040,
|
||||
0x00402000, 0x00608000, 0x00406000, 0x0060C000, 0x00402040
|
||||
};
|
||||
|
||||
static const char BIRD_IMAGE[380] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 10, 0, 0, 0, 0, 0, 0, 0,
|
||||
11, 0, 0, 0, 0, 0, 0, 9, 12, 9, 12, 13, 0, 0, 0, 0, 0, 0, 14, 15,
|
||||
16, 0, 0, 0, 0, 16, 17, 1, 12, 1, 13, 0, 0, 0, 0, 0, 0, 9, 12, 15,
|
||||
18, 0, 0, 0, 19, 12, 20, 20, 21, 13, 0, 0, 0, 0, 0, 0, 9, 12, 1, 15,
|
||||
18, 0, 0, 15, 9, 22, 22, 23, 24, 11, 0, 0, 0, 0, 0, 15, 9, 1, 14, 15,
|
||||
18, 18, 19, 25, 23, 26, 23, 27, 28, 11, 0, 0, 0, 0, 9, 17, 12, 1, 29, 13,
|
||||
19, 14, 22, 30, 30, 31, 1, 21, 32, 32, 33, 33, 34, 15, 17, 9, 12, 29, 14, 15,
|
||||
14, 26, 12, 12, 1, 35, 36, 20, 37, 38, 38, 39, 18, 15, 17, 9, 40, 29, 2, 3,
|
||||
41, 42, 42, 1, 43, 21, 44, 0, 0, 0, 0, 0, 45, 9, 17, 17, 12, 29, 46, 40,
|
||||
47, 48, 2, 21, 46, 0, 0, 0, 0, 0, 0, 11, 45, 17, 12, 40, 1, 49, 48, 1,
|
||||
1, 1, 20, 0, 0, 0, 0, 0, 0, 0, 0, 11, 15, 4, 50, 5, 48, 48, 1, 1,
|
||||
1, 1, 51, 0, 0, 0, 0, 0, 52, 14, 0, 16, 53, 53, 6, 48, 35, 1, 1, 1,
|
||||
54, 7, 0, 0, 0, 0, 0, 8, 55, 35, 14, 3, 6, 4, 48, 1, 1, 1, 48, 55,
|
||||
7, 0, 0, 0, 0, 0, 36, 21, 6, 48, 45, 4, 48, 47, 1, 1, 48, 6, 56, 18,
|
||||
0, 0, 0, 0, 0, 8, 35, 21, 45, 4, 47, 47, 47, 57, 48, 6, 56, 5, 0, 0,
|
||||
0, 0, 0, 0, 45, 58, 48, 6, 4, 48, 48, 48, 48, 6, 3, 16, 0, 0, 0, 0,
|
||||
0, 0, 0, 58, 59, 4, 48, 48, 48, 48, 4, 3, 56, 60, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 45, 5, 48, 6, 57, 56, 56, 56, 60, 18, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 61, 56, 50, 56, 56, 16, 60, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static const char TUBE_BODY_IMAGE[50] = {
|
||||
0, 0, 62, 63, 64, 1, 6, 6, 65, 65, 65, 65, 64, 66, 66, 64, 64, 66, 67, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 67, 66, 68, 68, 69, 66, 68, 68, 69, 70, 69, 71, 0, 0
|
||||
};
|
||||
|
||||
static const char TUBE_HEAD_IMAGE[900] = {
|
||||
71, 71, 71, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 71, 71, 71, 71, 71,
|
||||
72, 68, 68, 63, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 7, 7, 5, 5, 7, 7, 3, 7, 7, 7, 7, 7, 3, 3, 3, 3, 73, 74, 69, 69, 72,
|
||||
72, 75, 75, 65, 6, 1, 1, 1, 1, 8, 8, 8, 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 65, 65, 8, 8, 65, 65, 64, 65, 65, 64, 64, 64, 65, 65, 65, 64, 66, 68, 70, 70, 72,
|
||||
76, 64, 64, 8, 1, 65, 65, 65, 65, 67, 66, 66, 64, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 69, 74, 74, 66, 70, 69, 70, 70, 72,
|
||||
76, 64, 64, 8, 1, 65, 65, 65, 65, 66, 66, 66, 64, 66, 67, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 70, 74, 74, 66, 70, 70, 70, 70, 72,
|
||||
76, 64, 64, 8, 1, 65, 65, 65, 65, 66, 66, 66, 64, 66, 67, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 70, 74, 74, 66, 70, 69, 70, 70, 72,
|
||||
76, 64, 64, 8, 1, 65, 65, 65, 65, 66, 66, 66, 64, 66, 67, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 70, 74, 74, 66, 70, 69, 70, 70, 72,
|
||||
76, 64, 64, 8, 1, 65, 65, 65, 65, 66, 66, 66, 64, 66, 67, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 70, 74, 74, 66, 70, 69, 70, 70, 72,
|
||||
76, 64, 64, 8, 1, 65, 65, 65, 65, 66, 66, 66, 64, 66, 67, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 70, 74, 74, 66, 70, 69, 70, 70, 72,
|
||||
76, 64, 64, 8, 1, 65, 65, 65, 65, 66, 66, 66, 64, 66, 67, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 70, 74, 74, 66, 70, 69, 70, 70, 72,
|
||||
76, 64, 64, 8, 1, 65, 65, 65, 65, 66, 66, 66, 64, 66, 67, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 70, 74, 74, 66, 70, 69, 70, 70, 72,
|
||||
76, 64, 64, 8, 1, 65, 65, 65, 65, 66, 66, 66, 64, 66, 67, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 70, 74, 74, 66, 70, 69, 70, 70, 72,
|
||||
76, 64, 64, 8, 1, 65, 65, 65, 65, 66, 66, 66, 64, 66, 67, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 70, 74, 74, 66, 70, 69, 70, 70, 72,
|
||||
76, 64, 64, 8, 1, 65, 65, 65, 65, 67, 66, 66, 64, 66, 67, 66, 66, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 66, 70, 74, 74, 66, 70, 69, 70, 70, 72,
|
||||
76, 64, 64, 8, 1, 64, 64, 64, 64, 66, 75, 75, 6, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 70, 74, 74, 66, 70, 69, 70, 70, 72,
|
||||
72, 68, 68, 73, 63, 68, 68, 68, 68, 74, 68, 68, 68, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 70, 70, 70, 74, 70, 70, 70, 70, 72,
|
||||
72, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 70, 70, 72,
|
||||
71, 71, 71, 71, 62, 62, 62, 62, 62, 62, 62, 62, 62, 71, 71, 62, 62, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
// Èñõîäíèê èãðû "Êòî õî÷åò áûòü ìèëëèîíåðîì?" äëÿ Êîëèáðè ÎÑ
|
||||
// Èñõîäíèê èãðû "Êòî õî÷åò áûòü ìèëëèîíåðîì?" äëÿ ÊîëèáðèÎÑ
|
||||
// by Àíäðåé Ìèõàéëîâè÷ (Dron2004)
|
||||
|
||||
#include <kosSyst.h>
|
||||
@@ -83,7 +83,7 @@ void getFilePathName(){
|
||||
for (tmpcnt=0; tmpcnt<strlen(ourfilename); tmpcnt++){
|
||||
filepathname[tmpcnt+lastslashindex+1]=ourfilename[tmpcnt];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void prepareFileData() { //Ïðåäâàðèòåëüíûå ïîäñ÷¸òû
|
||||
@@ -105,22 +105,22 @@ void loadquestion(){
|
||||
int qcodee;
|
||||
|
||||
int skipsleft;
|
||||
|
||||
|
||||
regenerate:
|
||||
qcodee=(rtlRand()%questioncount)+1;
|
||||
|
||||
qcodee=(rtlRand()%questioncount)+1;
|
||||
|
||||
Byte inputbyte[1]={0x00};
|
||||
|
||||
|
||||
//Ïåðâûé ïðîõîä - ïðîâåðÿåì ñëîæíîñòü è ñ÷èòàåì äëèíû ñòðîê
|
||||
tempquestionlength = 0;
|
||||
tempanswerAlength = 0;
|
||||
tempanswerBlength = 0;
|
||||
tempanswerClength = 0;
|
||||
tempanswerDlength = 0;
|
||||
|
||||
|
||||
skipsleft=qcodee;
|
||||
CKosFile basefile(filepathname);
|
||||
|
||||
skipsleft=qcodee;
|
||||
CKosFile basefile(filepathname);
|
||||
//Íàéä¸ì òî ìåñòî, îòêóäà íà÷èíàåòñÿ íàø âîïðîñ
|
||||
while (skipsleft>0){
|
||||
basefile.Read (inputbyte,1);
|
||||
@@ -132,7 +132,7 @@ regenerate:
|
||||
|
||||
//Ïðîâåðèì ñëîæíîñòü
|
||||
basefile.Read (inputbyte,1);
|
||||
|
||||
|
||||
// Íàì íóæíî, ÷òîáû ñëîæíîñòü çàäàâàåìîãî âîïðîñà ñîîòâåòñòâîâàëà íîìåðó çàäàâàåìîãî
|
||||
// â èãðå âîïðîñà (íà êàêóþ ñóììó ìû èãðàåì; âîïðîñ íà 1000000 äîëæåí áûòü ïîñëîæíåå,
|
||||
// ÷åì âîïðîñ íà 100 ðóáëåé :-)))
|
||||
@@ -155,7 +155,7 @@ regenerate:
|
||||
goto regenerate;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (int counter=0; counter <currentquestion; counter++){
|
||||
if (askedquestions[counter]==qcodee){goto regenerate;}
|
||||
@@ -163,7 +163,7 @@ regenerate:
|
||||
|
||||
|
||||
askedquestions[currentquestion-1]=qcodee;
|
||||
|
||||
|
||||
|
||||
inputbyte[0]=0x00;
|
||||
//Ñ÷èòàåì, ñêîëüêî ñèìâîëîâ â âîïðîñå
|
||||
@@ -210,12 +210,12 @@ regenerate:
|
||||
tempanswerD = new char[tempanswerDlength+1];
|
||||
|
||||
|
||||
|
||||
|
||||
// ÂÒÎÐÎÉ ÏÐÎÕÎÄ: ÔÎÐÌÈÐÓÅÌ Â ÏÀÌßÒÈ ÂÎÏÐÎÑ È ÂÀÐÈÀÍÒÛ ÎÒÂÅÒÀ
|
||||
CKosFile basefile2(filepathname);
|
||||
inputbyte[0]=0x00;
|
||||
skipsleft=qcodee;
|
||||
|
||||
skipsleft=qcodee;
|
||||
|
||||
//Íàéä¸ì òî ìåñòî, îòêóäà íà÷èíàåòñÿ íàø âîïðîñ
|
||||
while (skipsleft>0){
|
||||
basefile2.Read (inputbyte,1);
|
||||
@@ -224,11 +224,11 @@ regenerate:
|
||||
}
|
||||
inputbyte[0]=0x00;
|
||||
}
|
||||
|
||||
|
||||
basefile2.Read (inputbyte,1); // Ýòî - ñëîæíîñòü âîïðîñà. Ìû å¸ óæå ïðîâåðèëè.
|
||||
|
||||
//×èòàåì âîïðîñ
|
||||
int currentbyte=0;
|
||||
int currentbyte=0;
|
||||
while (inputbyte[0]!=0x01){
|
||||
basefile2.Read (inputbyte,1);
|
||||
if (inputbyte[0]!=0x01){tempquestion[currentbyte]=inputbyte[0];}
|
||||
@@ -237,7 +237,7 @@ regenerate:
|
||||
tempquestion[currentbyte]='\n';
|
||||
|
||||
//×èòàåì îòâåò A
|
||||
currentbyte=0;
|
||||
currentbyte=0;
|
||||
while (inputbyte[0]!=0x02){
|
||||
basefile2.Read (inputbyte,1);
|
||||
if (inputbyte[0]!=0x02){tempanswerA[currentbyte]=inputbyte[0];}
|
||||
@@ -246,7 +246,7 @@ regenerate:
|
||||
tempanswerA[currentbyte]='\n';
|
||||
|
||||
//×èòàåì îòâåò B
|
||||
currentbyte=0;
|
||||
currentbyte=0;
|
||||
while (inputbyte[0]!=0x03){
|
||||
basefile2.Read (inputbyte,1);
|
||||
if (inputbyte[0]!=0x03){tempanswerB[currentbyte]=inputbyte[0];}
|
||||
@@ -255,7 +255,7 @@ regenerate:
|
||||
tempanswerB[currentbyte]='\n';
|
||||
|
||||
//×èòàåì îòâåò C
|
||||
currentbyte=0;
|
||||
currentbyte=0;
|
||||
while (inputbyte[0]!=0x04){
|
||||
basefile2.Read (inputbyte,1);
|
||||
if (inputbyte[0]!=0x04){tempanswerC[currentbyte]=inputbyte[0];}
|
||||
@@ -264,7 +264,7 @@ regenerate:
|
||||
tempanswerC[currentbyte]='\n';
|
||||
|
||||
//×èòàåì îòâåò D
|
||||
currentbyte=0;
|
||||
currentbyte=0;
|
||||
while (inputbyte[0]!=0x08){
|
||||
basefile2.Read (inputbyte,1);
|
||||
if (inputbyte[0]!=0x08){tempanswerD[currentbyte]=inputbyte[0];}
|
||||
@@ -275,7 +275,7 @@ regenerate:
|
||||
basefile2.Read (inputbyte,1); // Ýòî-ïðàâèëüíûé îòâåò
|
||||
tempcorrectanswer=inputbyte[0];
|
||||
// ÂѨ!!!!!! ÃÎÒÎÂÎ!!!! ÓÐÀ!
|
||||
|
||||
|
||||
//Ñ÷èòàëè. Òåïåðü íàäî ïåðåòàñîâàòü âîïðîñû.
|
||||
questionlength = 0;
|
||||
answerAlength = 0;
|
||||
@@ -297,7 +297,7 @@ regenerate:
|
||||
bool answerDfree = true;
|
||||
|
||||
int tmpvalue=0;
|
||||
|
||||
|
||||
//Ïåðâûé âîïðîñ
|
||||
regenA:
|
||||
tmpvalue = (rtlRand() % 4) +1;
|
||||
@@ -306,7 +306,7 @@ regenA:
|
||||
answerAfree=false;
|
||||
answerAlength=tempanswerAlength;
|
||||
answerA= new char [answerAlength];
|
||||
|
||||
|
||||
for (int c=0; c<answerAlength; c++){
|
||||
answerA[c]=tempanswerA[c];
|
||||
}
|
||||
@@ -322,7 +322,7 @@ regenA:
|
||||
answerBfree=false;
|
||||
answerBlength=tempanswerAlength;
|
||||
answerB= new char [answerBlength];
|
||||
|
||||
|
||||
for (int c=0; c<answerBlength; c++){
|
||||
answerB[c]=tempanswerA[c];
|
||||
}
|
||||
@@ -338,7 +338,7 @@ regenA:
|
||||
answerCfree=false;
|
||||
answerClength=tempanswerAlength;
|
||||
answerC= new char [answerClength];
|
||||
|
||||
|
||||
for (int c=0; c<answerClength; c++){
|
||||
answerC[c]=tempanswerA[c];
|
||||
}
|
||||
@@ -354,7 +354,7 @@ regenA:
|
||||
answerDfree=false;
|
||||
answerDlength=tempanswerAlength;
|
||||
answerD= new char [answerDlength];
|
||||
|
||||
|
||||
for (int c=0; c<answerDlength; c++){
|
||||
answerD[c]=tempanswerA[c];
|
||||
}
|
||||
@@ -374,7 +374,7 @@ regenB:
|
||||
answerAfree=false;
|
||||
answerAlength=tempanswerBlength;
|
||||
answerA= new char [answerAlength];
|
||||
|
||||
|
||||
for (int c=0; c<answerAlength; c++){
|
||||
answerA[c]=tempanswerB[c];
|
||||
}
|
||||
@@ -390,7 +390,7 @@ regenB:
|
||||
answerBfree=false;
|
||||
answerBlength=tempanswerBlength;
|
||||
answerB= new char [answerBlength];
|
||||
|
||||
|
||||
for (int c=0; c<answerBlength; c++){
|
||||
answerB[c]=tempanswerB[c];
|
||||
}
|
||||
@@ -406,7 +406,7 @@ regenB:
|
||||
answerCfree=false;
|
||||
answerClength=tempanswerBlength;
|
||||
answerC= new char [answerClength];
|
||||
|
||||
|
||||
for (int c=0; c<answerClength; c++){
|
||||
answerC[c]=tempanswerB[c];
|
||||
}
|
||||
@@ -422,7 +422,7 @@ regenB:
|
||||
answerDfree=false;
|
||||
answerDlength=tempanswerBlength;
|
||||
answerD= new char [answerDlength];
|
||||
|
||||
|
||||
for (int c=0; c<answerDlength; c++){
|
||||
answerD[c]=tempanswerB[c];
|
||||
}
|
||||
@@ -442,7 +442,7 @@ regenC:
|
||||
answerAfree=false;
|
||||
answerAlength=tempanswerClength;
|
||||
answerA= new char [answerAlength];
|
||||
|
||||
|
||||
for (int c=0; c<answerAlength; c++){
|
||||
answerA[c]=tempanswerC[c];
|
||||
}
|
||||
@@ -458,7 +458,7 @@ regenC:
|
||||
answerBfree=false;
|
||||
answerBlength=tempanswerClength;
|
||||
answerB= new char [answerBlength];
|
||||
|
||||
|
||||
for (int c=0; c<answerBlength; c++){
|
||||
answerB[c]=tempanswerC[c];
|
||||
}
|
||||
@@ -474,7 +474,7 @@ regenC:
|
||||
answerCfree=false;
|
||||
answerClength=tempanswerClength;
|
||||
answerC= new char [answerClength];
|
||||
|
||||
|
||||
for (int c=0; c<answerClength; c++){
|
||||
answerC[c]=tempanswerC[c];
|
||||
}
|
||||
@@ -490,7 +490,7 @@ regenC:
|
||||
answerDfree=false;
|
||||
answerDlength=tempanswerClength;
|
||||
answerD= new char [answerDlength];
|
||||
|
||||
|
||||
for (int c=0; c<answerDlength; c++){
|
||||
answerD[c]=tempanswerC[c];
|
||||
}
|
||||
@@ -510,7 +510,7 @@ regenD:
|
||||
answerAfree=false;
|
||||
answerAlength=tempanswerDlength;
|
||||
answerA= new char [answerAlength];
|
||||
|
||||
|
||||
for (int c=0; c<answerAlength; c++){
|
||||
answerA[c]=tempanswerD[c];
|
||||
}
|
||||
@@ -526,7 +526,7 @@ regenD:
|
||||
answerBfree=false;
|
||||
answerBlength=tempanswerDlength;
|
||||
answerB= new char [answerBlength];
|
||||
|
||||
|
||||
for (int c=0; c<answerBlength; c++){
|
||||
answerB[c]=tempanswerD[c];
|
||||
}
|
||||
@@ -542,7 +542,7 @@ regenD:
|
||||
answerCfree=false;
|
||||
answerClength=tempanswerDlength;
|
||||
answerC= new char [answerClength];
|
||||
|
||||
|
||||
for (int c=0; c<answerClength; c++){
|
||||
answerC[c]=tempanswerD[c];
|
||||
}
|
||||
@@ -558,7 +558,7 @@ regenD:
|
||||
answerDfree=false;
|
||||
answerDlength=tempanswerDlength;
|
||||
answerD= new char [answerDlength];
|
||||
|
||||
|
||||
for (int c=0; c<answerDlength; c++){
|
||||
answerD[c]=tempanswerD[c];
|
||||
}
|
||||
@@ -585,7 +585,7 @@ void draw_window(void){ //
|
||||
kos_WindowRedrawStatus(1);
|
||||
kos_DefineAndDrawWindow(10,10,619,179+kos_GetSkinHeight(),0x74, 0xDDDDFF, 0,0, (Dword)header);
|
||||
kos_WindowRedrawStatus(2);
|
||||
|
||||
|
||||
kos_ProcessInfo( &sPI );
|
||||
if (sPI.rawData[70]&0x04) return; //íè÷åãî íå äåëàòü åñëè îêíî ñõëîïíóòî â çàãîëîâîê
|
||||
|
||||
@@ -593,9 +593,9 @@ void draw_window(void){ //
|
||||
if (status==0){ //Ìåíþ
|
||||
kos_DrawBar(0,0,610,175,0xFFFFBB);
|
||||
kos_WriteTextToWindow (10,10,0x80,0x000000, "Šâ® å®ç¥â ¡ëâì ¬¨««¨®¥à®¬?", 3);
|
||||
|
||||
|
||||
kos_WriteTextToWindow (10,25,0x80,0x000000, sVersion, 3);
|
||||
|
||||
|
||||
kos_WriteTextToWindow (10,70,0x80,0x770000, "<ENTER> - ç âì ¨£àã", 0);
|
||||
kos_WriteTextToWindow (10,85,0x80,0x770000, "<ESC> - ¢ë室", 0);
|
||||
|
||||
@@ -607,7 +607,7 @@ void draw_window(void){ //
|
||||
kos_DrawBar(0,0,610,175,0xEEEEFF);
|
||||
|
||||
kos_WriteTextToWindow (10,10,0x0,0x000000, question, questionlength-1);
|
||||
|
||||
|
||||
if (drawA==true){
|
||||
kos_WriteTextToWindow (10,40,0x80,0x000000, "A. ", 0);
|
||||
kos_WriteTextToWindow (30,40,0x0,0x000000, answerA, answerAlength-1);
|
||||
@@ -637,12 +637,12 @@ void draw_window(void){ //
|
||||
kos_WriteTextToWindow (500,150,0x80,0x000000, summs[currentquestion-1], 0);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
if (status==2){ //Îêíî "Ýòî - ïðàâèëüíûé îòâåò"
|
||||
kos_DrawBar(0,0,610,175,0xDDFFDD);
|
||||
kos_WriteTextToWindow (10,10,0x80,0x000000, "„ , íâ® ¯à ¢¨«ìë© ®â¢¥â!", 0);
|
||||
|
||||
|
||||
kos_WriteTextToWindow (10,150,0x80,0x000000, "<ENTER> - ¯à®¤®«¦¨âì", 0);
|
||||
}
|
||||
if (status==3){ //Âû âûèãðàëè ìèëëèîí, îäíàêî æ!!!
|
||||
@@ -683,7 +683,7 @@ void draw_window(void){ //
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
kos_WriteTextToWindow (10,150,0x80,0x000000, "<ENTER> - ¯à®¤®«¦¨âì", 0);
|
||||
}
|
||||
|
||||
@@ -696,7 +696,7 @@ void draw_window(void){ //
|
||||
if (status==-1){ //Âû îøèáëèñü :-(
|
||||
kos_DrawBar(0,0,610,175,0xFF8888);
|
||||
kos_WriteTextToWindow (10,10,0x80,0x000000, "Š á®¦ «¥¨î, ¢ë ®è¨¡«¨áì... <20>à ¢¨«ìë© ®â¢¥â -", 0);
|
||||
|
||||
|
||||
switch (correctanswer){
|
||||
case 0x01:
|
||||
kos_WriteTextToWindow (10,25,0x80,0x000000, "A. ", 0);
|
||||
@@ -716,7 +716,7 @@ void draw_window(void){ //
|
||||
break;
|
||||
}
|
||||
kos_WriteTextToWindow (10,50,0x80,0x000000, "‚ १ã«ìâ ⥠¢ë ¢ë¨£à «¨:", 0);
|
||||
|
||||
|
||||
if (currentquestion<6) {kos_WriteTextToWindow (220,50,0x80,0x000000,summs[0], 0);}
|
||||
if ((currentquestion>5)&&(currentquestion<11)) {kos_WriteTextToWindow (220,50,0x80,0x000000,summs[5], 0);}
|
||||
if (currentquestion>10) {kos_WriteTextToWindow (220,50,0x80,0x000000,summs[10], 0);}
|
||||
@@ -733,9 +733,9 @@ void draw_window(void){ //
|
||||
|
||||
void call_friend(){
|
||||
int tmpcodee;
|
||||
|
||||
|
||||
recode5:
|
||||
tmpcodee =(rtlRand()%10)+1;
|
||||
tmpcodee =(rtlRand()%10)+1;
|
||||
int tmpbyte;
|
||||
|
||||
if (currentquestion < 6 ){
|
||||
@@ -747,7 +747,7 @@ void call_friend(){
|
||||
}
|
||||
else //Äðóã ãîâîðèò íàóãàä
|
||||
{
|
||||
|
||||
|
||||
int tmpbyte2=0;
|
||||
recode51:
|
||||
int tmpcodee2=(rtlRand()%4)+1;
|
||||
@@ -779,7 +779,7 @@ void call_friend(){
|
||||
}
|
||||
else //Äðóã ãîâîðèò íàóãàä
|
||||
{
|
||||
|
||||
|
||||
int tmpbyte2=0;
|
||||
recode52:
|
||||
int tmpcodee2=(rtlRand()%4)+1;
|
||||
@@ -917,7 +917,7 @@ void call_zal(){ //
|
||||
zalA=100-zalD;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((drawB==true)&&(drawC==true)){
|
||||
if (correctanswer==0x02){
|
||||
zalB=maxpercent;
|
||||
@@ -940,7 +940,7 @@ void call_zal(){ //
|
||||
zalB=100-zalD;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((drawC==true)&&(drawD==true)){
|
||||
if (correctanswer==0x03){
|
||||
zalC=maxpercent;
|
||||
@@ -1005,7 +1005,7 @@ void kos_Main(){
|
||||
drawB = true;
|
||||
drawC = true;
|
||||
drawD = true;
|
||||
|
||||
|
||||
draw_window();
|
||||
}
|
||||
}
|
||||
@@ -1023,8 +1023,8 @@ void kos_Main(){
|
||||
drawB = true;
|
||||
drawC = true;
|
||||
drawD = true;
|
||||
|
||||
draw_window();
|
||||
|
||||
draw_window();
|
||||
}
|
||||
}
|
||||
if (drawC==true){
|
||||
@@ -1040,8 +1040,8 @@ void kos_Main(){
|
||||
drawB = true;
|
||||
drawC = true;
|
||||
drawD = true;
|
||||
|
||||
draw_window();
|
||||
|
||||
draw_window();
|
||||
}
|
||||
}
|
||||
if (drawD==true){
|
||||
@@ -1057,11 +1057,11 @@ void kos_Main(){
|
||||
drawB = true;
|
||||
drawC = true;
|
||||
drawD = true;
|
||||
|
||||
|
||||
draw_window();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (callfriendavailable==true){ //Ðåàëèçàöèÿ ïîäñêàçêè "Çâîíîê äðóãó"
|
||||
if (keyCode==56){
|
||||
callfriendavailable=false;
|
||||
@@ -1082,17 +1082,17 @@ void kos_Main(){
|
||||
|
||||
if (na50available==true){ //Ðåàëèçàöèÿ ïîäñêàçêè "50 íà 50"
|
||||
if (keyCode==55){
|
||||
|
||||
|
||||
if (correctanswer==0x01){
|
||||
drawA=true;
|
||||
|
||||
int tmpcodee;
|
||||
|
||||
|
||||
recode1:
|
||||
tmpcodee =(rtlRand()%3)+1;
|
||||
|
||||
tmpcodee =(rtlRand()%3)+1;
|
||||
|
||||
int tmpbyte;
|
||||
|
||||
|
||||
switch(tmpcodee){
|
||||
case 1:
|
||||
drawB=true;
|
||||
@@ -1107,19 +1107,19 @@ void kos_Main(){
|
||||
drawB=false;
|
||||
drawC=false;
|
||||
drawD=true;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if (correctanswer==0x02){
|
||||
drawB=true;
|
||||
|
||||
int tmpcodee;
|
||||
|
||||
|
||||
recode2:
|
||||
tmpcodee =(rtlRand()%3)+1;
|
||||
|
||||
tmpcodee =(rtlRand()%3)+1;
|
||||
|
||||
int tmpbyte;
|
||||
|
||||
|
||||
|
||||
switch(tmpcodee){
|
||||
case 1:
|
||||
@@ -1135,18 +1135,18 @@ void kos_Main(){
|
||||
drawA=false;
|
||||
drawC=false;
|
||||
drawD=true;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if (correctanswer==0x03){
|
||||
drawC=true;
|
||||
|
||||
int tmpcodee;
|
||||
|
||||
|
||||
recode3:
|
||||
tmpcodee =(rtlRand()%3)+1;
|
||||
tmpcodee =(rtlRand()%3)+1;
|
||||
int tmpbyte;
|
||||
|
||||
|
||||
|
||||
switch(tmpcodee){
|
||||
case 1:
|
||||
@@ -1162,19 +1162,19 @@ void kos_Main(){
|
||||
drawB=false;
|
||||
drawA=false;
|
||||
drawD=true;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if (correctanswer==0x04){
|
||||
drawA=true;
|
||||
|
||||
int tmpcodee;
|
||||
|
||||
|
||||
recode4:
|
||||
tmpcodee =(rtlRand()%3)+1;
|
||||
|
||||
tmpcodee =(rtlRand()%3)+1;
|
||||
|
||||
int tmpbyte;
|
||||
|
||||
|
||||
|
||||
switch(tmpcodee){
|
||||
case 1:
|
||||
@@ -1190,7 +1190,7 @@ void kos_Main(){
|
||||
drawB=false;
|
||||
drawC=false;
|
||||
drawA=true;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
na50available=false;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
Автор: Mario79
|
||||
xx.01.2006 - набор статьи
|
||||
20.03.2006 - публикация статьи
|
||||
Автор: Mario79
|
||||
xx.01.2006 - набор статьи
|
||||
20.03.2006 - публикация статьи
|
||||
23.03.2006 - исправление и дополнение статьи
|
||||
26.02.2007 - переработано и дополнено в связи с изменившимися реалиями
|
||||
|
||||
Загрузка ОС Колибри с USB Flash Drive
|
||||
На сегодняшний день ОС Колибри не имеет поддержки USB устройств на уровне самой системы, по этой причине для запуска с USB Flash накопителей приходится идти на определенные хитрости.
|
||||
Существует 2 известных способа запустить ОС Колибри с «флешки».
|
||||
Загрузка КолибриОС с USB Flash Drive
|
||||
На сегодняшний день КолибриОС не имеет поддержки USB устройств на уровне самой системы, по этой причине для запуска с USB Flash накопителей приходится идти на определенные хитрости.
|
||||
Существует 2 известных способа запустить КолибриОС с «флешки».
|
||||
|
||||
1) Эмуляция флоппи диска в BIOS.
|
||||
Метод прост до тупости на «флешку» записывается IMG образ, с полной эмуляцией, то есть 0 сектор IMG образа становится 0 сектором «флешки», и так далее пока все сектора образа не будут скопированы на накопитель. Из недостатков этого способа сразу можно заметить потерю рабочего пространства выше 1,44 Мб. Особенно обидным это является для накопителей, емкость которых намного превышает этот размер.
|
||||
@@ -23,7 +23,7 @@ xx.01.2006 -
|
||||
Поскольку на данный момент Колибри не является полностью самостоятельной ОС, то повсеместно она применяется параллельно с другими ОС. Эта ситуация привела к тому, что собственного независимого загрузчика (если не считать флоппи диски) у Колибри фактически нет.
|
||||
На сегодняшний день остались актуальными только 2 загрузчика: meosload.com и mtldr.
|
||||
Оба могут запускаться из среды DOS.
|
||||
Установка Колибри на флешку в моем варианте начинается с установки DOS на флешку, как первичной системой, из-под которой будут запущены загрузчики Колибри. Конечно, в этом случае с точки зрения лицензии лучше использовать полные аналоги DOS, которые имеют свободную лицензию на использование, но не в этом суть, так что не будем отвлекаться на мелочи.
|
||||
Установка КолибриОС на флешку в моем варианте начинается с установки DOS на флешку, как первичной системой, из-под которой будут запущены загрузчики КолибриОС. Конечно, в этом случае с точки зрения лицензии лучше использовать полные аналоги DOS, которые имеют свободную лицензию на использование, но не в этом суть, так что не будем отвлекаться на мелочи.
|
||||
|
||||
Установить DOS на «флешку» можно несколькими способами:
|
||||
а) ОС Windows при форматировании флешки выбрать пункт скопировать системные файлы, в общем, то же самое что и для флоппи дискеты. К сожалению, этот метод подходит только для линейки 9х, на 2К не проверял, но в ХР этот пункт недоступен.
|
||||
@@ -54,4 +54,4 @@ xx.01.2006 -
|
||||
|
||||
P.S.
|
||||
1) Хочу выразить большую признательность за помощь в подготовке материала Андрею (NoName), Эдуарду (DoomEdArchangel) и Сергею (Serge).
|
||||
2) В архиве с этим файлом содержаться упомянутые в тексте enable.exe и meosload.com и их исходные коды.
|
||||
2) В архиве с этим файлом содержаться упомянутые в тексте enable.exe и meosload.com и их исходные коды.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
€¢â®à: Mario79
|
||||
xx.01.2006 - ¡®à áâ âì¨
|
||||
20.03.2006 - ¯ã¡«¨ª æ¨ï áâ âì¨
|
||||
€¢â®à: Mario79
|
||||
xx.01.2006 - ¡®à áâ âì¨
|
||||
20.03.2006 - ¯ã¡«¨ª æ¨ï áâ âì¨
|
||||
23.03.2006 - ¨á¯à ¢«¥¨¥ ¨ ¤®¯®«¥¨¥ áâ âì¨
|
||||
26.02.2007 - ¯¥à¥à ¡®â ® ¨ ¤®¯®«¥® ¢ á¢ï§¨ á ¨§¬¥¨¢è¨¬¨áï ॠ«¨ï¬¨
|
||||
|
||||
‡ £à㧪 Ž‘ Š®«¨¡à¨ á USB Flash Drive
|
||||
<EFBFBD> ᥣ®¤ï訩 ¤¥ì Ž‘ Š®«¨¡à¨ ¥ ¨¬¥¥â ¯®¤¤¥à¦ª¨ USB ãáâனá⢠ã஢¥ á ¬®© á¨á⥬ë, ¯® í⮩ ¯à¨ç¨¥ ¤«ï § ¯ã᪠á USB Flash ª®¯¨â¥«¥© ¯à¨å®¤¨âáï ¨¤â¨ ®¯à¥¤¥«¥ë¥ å¨âà®áâ¨.
|
||||
‘ãé¥áâ¢ã¥â 2 ¨§¢¥áâëå ᯮᮡ § ¯ãáâ¨âì Ž‘ Š®«¨¡à¨ á «ä«¥èª¨».
|
||||
‡ £à㧪 Š®«¨¡à¨Ž‘ á USB Flash Drive
|
||||
<EFBFBD> ᥣ®¤ï訩 ¤¥ì Š®«¨¡à¨Ž‘ ¥ ¨¬¥¥â ¯®¤¤¥à¦ª¨ USB ãáâனá⢠ã஢¥ á ¬®© á¨á⥬ë, ¯® í⮩ ¯à¨ç¨¥ ¤«ï § ¯ã᪠á USB Flash ª®¯¨â¥«¥© ¯à¨å®¤¨âáï ¨¤â¨ ®¯à¥¤¥«¥ë¥ å¨âà®áâ¨.
|
||||
‘ãé¥áâ¢ã¥â 2 ¨§¢¥áâëå ᯮᮡ § ¯ãáâ¨âì Š®«¨¡à¨Ž‘ á «ä«¥èª¨».
|
||||
|
||||
1) <20>¬ã«ïæ¨ï ä«®¯¯¨ ¤¨áª ¢ BIOS.
|
||||
Œ¥â®¤ ¯à®áâ ¤® â㯮á⨠«ä«¥èªã» § ¯¨áë¢ ¥âáï IMG ®¡à §, á ¯®«®© í¬ã«ï樥©, â® ¥áâì 0 ᥪâ®à IMG ®¡à § áâ ®¢¨âáï 0 ᥪâ®à®¬ «ä«¥èª¨», ¨ â ª ¤ «¥¥ ¯®ª ¢á¥ ᥪâ®à ®¡à § ¥ ¡ã¤ãâ ᪮¯¨à®¢ ë ª®¯¨â¥«ì. ˆ§ ¥¤®áâ ⪮¢ í⮣® ᯮᮡ áà §ã ¬®¦® § ¬¥â¨âì ¯®â¥àî à ¡®ç¥£® ¯à®áâà á⢠¢ëè¥ 1,44 Œ¡. Žá®¡¥® ®¡¨¤ë¬ í⮠ï¥âáï ¤«ï ª®¯¨â¥«¥©, ¥¬ª®áâì ª®â®àëå ¬®£® ¯à¥¢ëè ¥â íâ®â à §¬¥à.
|
||||
@@ -23,7 +23,7 @@ xx.01.2006 -
|
||||
<EFBFBD>®áª®«ìªã ¤ ë© ¬®¬¥â Š®«¨¡à¨ ¥ ï¥âáï ¯®«®áâìî á ¬®áâ®ï⥫쮩 Ž‘, â® ¯®¢á¥¬¥áâ® ® ¯à¨¬¥ï¥âáï ¯ à ««¥«ì® á ¤à㣨¬¨ Ž‘. <20>â á¨âã æ¨ï ¯à¨¢¥« ª ⮬ã, ç⮠ᮡá⢥®£® ¥§ ¢¨á¨¬®£® § £àã§ç¨ª (¥á«¨ ¥ áç¨â âì ä«®¯¯¨ ¤¨áª¨) ã Š®«¨¡à¨ ä ªâ¨ç¥áª¨ ¥â.
|
||||
<EFBFBD> ᥣ®¤ï訩 ¤¥ì ®áâ «¨áì ªâã «ì묨 ⮫쪮 2 § £àã§ç¨ª : meosload.com ¨ mtldr.
|
||||
Ž¡ ¬®£ãâ § ¯ã᪠âìáï ¨§ á।ë DOS.
|
||||
“áâ ®¢ª Š®«¨¡à¨ ä«¥èªã ¢ ¬®¥¬ ¢ à¨ â¥ ç¨ ¥âáï á ãáâ ®¢ª¨ DOS ä«¥èªã, ª ª ¯¥à¢¨ç®© á¨á⥬®©, ¨§-¯®¤ ª®â®à®© ¡ã¤ãâ § ¯ãé¥ë § £àã§ç¨ª¨ Š®«¨¡à¨. Š®¥ç®, ¢ í⮬ á«ãç ¥ á â®çª¨ §à¥¨ï «¨æ¥§¨¨ «ãçè¥ ¨á¯®«ì§®¢ âì ¯®«ë¥ «®£¨ DOS, ª®â®àë¥ ¨¬¥îâ ᢮¡®¤ãî «¨æ¥§¨î ¨á¯®«ì§®¢ ¨¥, ® ¥ ¢ í⮬ áãâì, â ª çâ® ¥ ¡ã¤¥¬ ®â¢«¥ª âìáï ¬¥«®ç¨.
|
||||
“áâ ®¢ª Š®«¨¡à¨Ž‘ ä«¥èªã ¢ ¬®¥¬ ¢ à¨ â¥ ç¨ ¥âáï á ãáâ ®¢ª¨ DOS ä«¥èªã, ª ª ¯¥à¢¨ç®© á¨á⥬®©, ¨§-¯®¤ ª®â®à®© ¡ã¤ãâ § ¯ãé¥ë § £àã§ç¨ª¨ Š®«¨¡à¨Ž‘. Š®¥ç®, ¢ í⮬ á«ãç ¥ á â®çª¨ §à¥¨ï «¨æ¥§¨¨ «ãçè¥ ¨á¯®«ì§®¢ âì ¯®«ë¥ «®£¨ DOS, ª®â®àë¥ ¨¬¥îâ ᢮¡®¤ãî «¨æ¥§¨î ¨á¯®«ì§®¢ ¨¥, ® ¥ ¢ í⮬ áãâì, â ª çâ® ¥ ¡ã¤¥¬ ®â¢«¥ª âìáï ¬¥«®ç¨.
|
||||
|
||||
“áâ ®¢¨âì DOS «ä«¥èªã» ¬®¦® ¥áª®«ìª¨¬¨ ᯮᮡ ¬¨:
|
||||
) Ž‘ Windows ¯à¨ ä®à¬ â¨à®¢ ¨¨ 䫥誨 ¢ë¡à âì ¯ãªâ ᪮¯¨à®¢ âì á¨áâ¥¬ë¥ ä ©«ë, ¢ ®¡é¥¬, â® ¦¥ á ¬®¥ çâ® ¨ ¤«ï ä«®¯¯¨ ¤¨áª¥âë. Š á®¦ «¥¨î, íâ®â ¬¥â®¤ ¯®¤å®¤¨â ⮫쪮 ¤«ï «¨¥©ª¨ 9å, 2Š ¥ ¯à®¢¥àï«, ® ¢ •<> íâ®â ¯ãªâ ¥¤®áâ㯥.
|
||||
@@ -54,4 +54,4 @@ xx.01.2006 -
|
||||
|
||||
P.S.
|
||||
1) •®çã ¢ëà §¨âì ¡®«ìèãî ¯à¨§ ⥫ì®áâì § ¯®¬®éì ¢ ¯®¤£®â®¢ª¥ ¬ â¥à¨ « €¤à¥î (NoName), <20>¤ã à¤ã (DoomEdArchangel) ¨ ‘¥à£¥î (Serge).
|
||||
2) ‚ à娢¥ á í⨬ ä ©«®¬ ᮤ¥à¦ âìáï 㯮¬ïãâë¥ ¢ ⥪á⥠enable.exe ¨ meosload.com ¨ ¨å ¨áå®¤ë¥ ª®¤ë.
|
||||
2) ‚ à娢¥ á í⨬ ä ©«®¬ ᮤ¥à¦ âìáï 㯮¬ïãâë¥ ¢ ⥪á⥠enable.exe ¨ meosload.com ¨ ¨å ¨áå®¤ë¥ ª®¤ë.
|
||||
|
||||
@@ -238,7 +238,7 @@ end if
|
||||
mov [ebp + thread_data.buffer_ptr], eax
|
||||
mov [ebp + thread_data.passivesocknum], -1
|
||||
|
||||
sendFTP " 220 Welcome to KolibriOS FTP daemon" ; fix output code
|
||||
sendFTP "220 Welcome to KolibriOS FTP daemon" ; fix output code
|
||||
|
||||
diff16 "threadloop", 0, $
|
||||
threadloop:
|
||||
|
||||
@@ -30,7 +30,7 @@ format binary as "" ; Binary file format without extension
|
||||
use32 ; Tell compiler to use 32 bit instructions
|
||||
org 0 ; the base address of code, always 0x0
|
||||
|
||||
; ‡àãîëîâîê èñïîëíÿåìîãî ôàéëà Êîëèáðè ÎÑ
|
||||
; ‡àãîëîâîê èñïîëíÿåìîãî ôàéëà ÊîëèáðèÎÑ
|
||||
db 'MENUET01'
|
||||
dd 1
|
||||
dd START
|
||||
@@ -1662,7 +1662,7 @@ but_open_dlg:
|
||||
.end_open:
|
||||
popad
|
||||
ret
|
||||
|
||||
|
||||
;äàííûå äëß äèàëîãà îòêðûòèß ôàéëîâ
|
||||
align 4
|
||||
OpenDialog_data:
|
||||
@@ -1684,12 +1684,12 @@ OpenDialog_data:
|
||||
.y:
|
||||
.y_size dw 320 ;+52 ; Window y size
|
||||
.y_start dw 10 ;+54 ; Window Y position
|
||||
|
||||
|
||||
default_dir db '/sys',0 ;äèðåêòîðèß ïî óìîë÷àíèþ
|
||||
communication_area_name: db 'FFFFFFFF_open_dialog',0
|
||||
open_dialog_name: db 'opendial',0
|
||||
communication_area_default_path: db '/sys/File managers/',0
|
||||
|
||||
|
||||
Filter:
|
||||
dd Filter.end - Filter.1
|
||||
.1:
|
||||
|
||||
4
programs/system/reshare/Tupfile.lua
Normal file
4
programs/system/reshare/Tupfile.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR")
|
||||
tup.include(HELPERDIR .. "/use_fasm.lua")
|
||||
tup.rule("reshare.asm", FASM .. " -dlang=" .. tup.getconfig("LANG") .. " %f %o" .. tup.getconfig("KPACK_CMD"), "%B")
|
||||
72
programs/system/reshare/checkbox.inc
Normal file
72
programs/system/reshare/checkbox.inc
Normal file
@@ -0,0 +1,72 @@
|
||||
; SPDX-License-Identifier: GPL-2.0-only
|
||||
;
|
||||
; Reshare - Shared Resources Daemon
|
||||
;
|
||||
; Copyright (C) 2024-2026 KolibriOS Team
|
||||
; Copyright (C) 2024-2026 KolibriOS-NG Team
|
||||
|
||||
; ====================================================================
|
||||
|
||||
CBOX_WIDTH = 13
|
||||
CBOX_HEIGHT = 13
|
||||
CBOX_PIXELS = CBOX_WIDTH * CBOX_HEIGHT
|
||||
CBOX_IMG_SIZE = CBOX_PIXELS * 3 ; 24-bpp BGR, tight rows
|
||||
|
||||
; ====================================================================
|
||||
|
||||
; Palette entry: 4 bytes BGR0 (padded for dword-indexed lookup)
|
||||
macro BGRA c
|
||||
{
|
||||
db (c) and 0xFF, (c shr 8) and 0xFF, (c shr 16) and 0xFF, 0
|
||||
}
|
||||
|
||||
P00 = 0x04D4FC ; 0xRRGGBB
|
||||
P01 = 0x04C8FC
|
||||
P02 = 0x04DCFC
|
||||
P03 = 0x04B4FC
|
||||
P04 = 0x04BCFC
|
||||
P05 = 0x04A9FC
|
||||
P06 = 0x0498F9
|
||||
P07 = 0xD2F2FC
|
||||
P08 = 0x04A5FA
|
||||
P09 = 0xFFFFFF
|
||||
P10 = 0xF6FDFD
|
||||
P11 = 0xAFF9FC
|
||||
P12 = 0x95E0F7
|
||||
P13 = 0x0464BC
|
||||
P14 = 0x2CDCFC
|
||||
P15 = 0x049FFA
|
||||
|
||||
cbox_palette:
|
||||
BGRA P00
|
||||
BGRA P01
|
||||
BGRA P02
|
||||
BGRA P03
|
||||
BGRA P04
|
||||
BGRA P05
|
||||
BGRA P06
|
||||
BGRA P07
|
||||
BGRA P08
|
||||
BGRA P09
|
||||
BGRA P10
|
||||
BGRA P11
|
||||
BGRA P12
|
||||
BGRA P13
|
||||
BGRA P14
|
||||
BGRA P15
|
||||
|
||||
; 4-bit palette indices, one byte per pixel (upper nibble unused — values 0..15)
|
||||
cbox_indexed:
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ; row 1
|
||||
db 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 ; row 2
|
||||
db 2, 1, 1, 1, 1, 4, 4, 4, 3, 5, 5, 3, 3 ; row 3
|
||||
db 0, 1, 1, 1, 4, 4, 3, 3, 6, 7, 7, 8, 3 ; row 4
|
||||
db 0, 3, 5, 5, 3, 3, 3, 6, 9,10,11, 6, 3 ; row 5
|
||||
db 0, 5, 7, 7, 6, 3, 6, 9,10,12,13, 6, 5 ; row 6
|
||||
db 0, 6,10, 9,14, 6, 9,10,12,13, 6,15, 5 ; row 7
|
||||
db 0, 6,12,10, 9, 9,10,12,13, 6,15, 5, 5 ; row 8
|
||||
db 0, 6,13,12,10,10,12,13, 6,15, 5, 5, 5 ; row 9
|
||||
db 1, 8, 6,13,12,12,13, 6,15, 5, 5, 5,15 ; row 10
|
||||
db 1, 5,15, 6,13,13, 6,15, 5, 5, 5,15,15 ; row 11
|
||||
db 1, 5, 5,15, 6, 6,15, 5, 5, 5,15,15, 6 ; row 12
|
||||
db 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 ; row 13
|
||||
699
programs/system/reshare/reshare.asm
Normal file
699
programs/system/reshare/reshare.asm
Normal file
@@ -0,0 +1,699 @@
|
||||
; SPDX-License-Identifier: GPL-2.0-only
|
||||
;
|
||||
; Reshare - Shared Resources Daemon
|
||||
;
|
||||
; Copyright (C) 2024-2026 KolibriOS Team
|
||||
; Copyright (C) 2024-2026 KolibriOS-NG Team
|
||||
|
||||
; ====================================================================
|
||||
|
||||
use32
|
||||
org 0
|
||||
|
||||
; ====================================================================
|
||||
|
||||
db "MENUET01"
|
||||
dd 1
|
||||
dd START
|
||||
dd I_END
|
||||
dd MEM
|
||||
dd STACKTOP
|
||||
dd 0
|
||||
dd 0
|
||||
|
||||
; ====================================================================
|
||||
|
||||
include "../../macros.inc"
|
||||
include "../../KOSfuncs.inc"
|
||||
include "../../encoding.inc"
|
||||
include "../../proc32.inc"
|
||||
include "../../dll.inc"
|
||||
include "../../debug-fdo.inc"
|
||||
|
||||
include "../../develop/libraries/libs-dev/libimg/libimg.inc"
|
||||
|
||||
include "checkbox.inc"
|
||||
|
||||
; ====================================================================
|
||||
|
||||
LIBS:
|
||||
library img, "libimg.obj"
|
||||
import img, img.destroy, "img_destroy", \
|
||||
img.from_file, "img_from_file"
|
||||
|
||||
; ====================================================================
|
||||
|
||||
START:
|
||||
|
||||
mcall SF_SYS_MISC, SSF_HEAP_INIT
|
||||
|
||||
mcall SF_KEYBOARD, SSF_SET_INPUT_MODE, 1
|
||||
|
||||
; check if this is second instance of app. if so - run gui, else - run daemon
|
||||
mcall SF_SYS_MISC, SSF_MEM_OPEN, meta_name, 0, SHM_READ
|
||||
test eax, eax
|
||||
jz MODE_DAEMON
|
||||
mcall SF_SYS_MISC, SSF_MEM_CLOSE, meta_name
|
||||
jmp MODE_GUI
|
||||
|
||||
.exit:
|
||||
mcall SF_TERMINATE_PROCESS
|
||||
|
||||
; ====================================================================
|
||||
|
||||
MODE_GUI:
|
||||
|
||||
.event_loop:
|
||||
|
||||
mcall SF_WAIT_EVENT
|
||||
|
||||
cmp eax, EV_REDRAW
|
||||
je .event_redraw
|
||||
|
||||
cmp eax, EV_KEY
|
||||
je .event_key
|
||||
|
||||
cmp eax, EV_BUTTON
|
||||
je .event_button
|
||||
|
||||
jmp .event_loop
|
||||
|
||||
|
||||
.event_redraw:
|
||||
|
||||
mcall SF_REDRAW, SSF_BEGIN_DRAW
|
||||
|
||||
mcall SF_STYLE_SETTINGS, SSF_GET_COLORS, sc, sizeof.system_colors
|
||||
mcall , SSF_GET_SKIN_HEIGHT
|
||||
|
||||
add eax, WIN.H
|
||||
mov esi, eax
|
||||
mcall SF_GET_SCREEN_SIZE
|
||||
movzx ecx, ax
|
||||
shr eax, 16
|
||||
sub eax, WIN.W
|
||||
shr eax, 1
|
||||
shl eax, 16
|
||||
add eax, WIN.W
|
||||
mov ebx, eax
|
||||
sub ecx, esi
|
||||
shr ecx, 1
|
||||
shl ecx, 16
|
||||
add ecx, esi
|
||||
mov edx, [sc.work]
|
||||
add edx, WIN_STYLE
|
||||
|
||||
mcall SF_CREATE_WINDOW, , , , , title
|
||||
|
||||
; visual dividers
|
||||
mcall SF_DRAW_RECT, <PAD, GRID.W>, <BTN.Y + BTN.H + PAD, 1>, [sc.work_graph]
|
||||
mcall , , <GRID.Y + GRID.H, 1>,
|
||||
|
||||
; info row
|
||||
mov ecx, FONT_TYPE shl 24
|
||||
add ecx, [sc.work_text]
|
||||
mcall SF_DRAW_TEXT, <PAD, GRID.Y + GRID.H + PAD - 1>, , lb_info
|
||||
|
||||
; tabs labels
|
||||
mov esi, tab_label_strs
|
||||
xor edi, edi
|
||||
.tab_label_loop:
|
||||
mov ebx, edi
|
||||
imul ebx, TAB_STEP
|
||||
push ebx
|
||||
add ebx, PAD * 2
|
||||
shl ebx, 16
|
||||
add ebx, BTN.Y
|
||||
mov edx, [esi]
|
||||
mcall SF_DRAW_TEXT
|
||||
add ebx, 1 shl 16 ; bold: x+1, same string
|
||||
mcall SF_DRAW_TEXT
|
||||
pop ebx
|
||||
add ebx, PAD * 11
|
||||
shl ebx, 16
|
||||
add ebx, BTN.Y
|
||||
mov edx, [esi + 4]
|
||||
mcall SF_DRAW_TEXT
|
||||
add esi, 8
|
||||
inc edi
|
||||
cmp edi, TAB_COUNT
|
||||
jb .tab_label_loop
|
||||
|
||||
; tabs buttons
|
||||
mov ecx, BTN.Y shl 16 + BTN.H
|
||||
mov esi, ACTIVE_ICONS32
|
||||
xor edi, edi
|
||||
.btn_loop:
|
||||
mov ebx, edi
|
||||
imul ebx, TAB_STEP
|
||||
add ebx, PAD
|
||||
shl ebx, 16
|
||||
add ebx, BTN.W
|
||||
lea edx, [esi + BTN_BASE + BTN_HIDE]
|
||||
mcall SF_DEFINE_BUTTON
|
||||
add esi, esi ; 1→2→4→8 (next ACTIVE bit)
|
||||
inc edi
|
||||
cmp edi, TAB_COUNT
|
||||
jb .btn_loop
|
||||
|
||||
; tabs content
|
||||
call draw_tabs
|
||||
|
||||
mcall SF_REDRAW, SSF_END_DRAW
|
||||
|
||||
jmp .event_loop
|
||||
|
||||
|
||||
.event_key:
|
||||
|
||||
mcall SF_GET_KEY
|
||||
cmp ah, KEY_TAB
|
||||
jne .event_loop
|
||||
|
||||
shl [active_tab], 1 ; * 2
|
||||
cmp [active_tab], ACTIVE_CHECKBOX
|
||||
jbe .tab_draw
|
||||
mov [active_tab], 1
|
||||
|
||||
.tab_draw:
|
||||
call draw_tabs
|
||||
|
||||
jmp .event_loop
|
||||
|
||||
|
||||
.event_button:
|
||||
|
||||
mcall SF_GET_BUTTON
|
||||
|
||||
cmp ah, 1
|
||||
je .event_exit
|
||||
|
||||
movzx eax, ah
|
||||
sub eax, BTN_BASE
|
||||
mov [active_tab], eax
|
||||
call draw_tabs
|
||||
|
||||
jmp .event_loop
|
||||
|
||||
|
||||
.event_exit:
|
||||
mcall SF_TERMINATE_PROCESS
|
||||
|
||||
; ====================================================================
|
||||
|
||||
draw_tabs:
|
||||
|
||||
; draw tab underlines; active tab gets highlight color
|
||||
xor edi, edi
|
||||
mov esi, 1 ; current tab bit (ACTIVE_ICONS32=1, then 2, 4, 8)
|
||||
|
||||
.loop:
|
||||
mov edx, [sc.work_dark]
|
||||
test [active_tab], esi
|
||||
jz .color_ok
|
||||
mov edx, [sc.work_button]
|
||||
|
||||
.color_ok:
|
||||
mov eax, edi
|
||||
imul eax, TAB_STEP
|
||||
add eax, PAD
|
||||
mpack ebx, eax, BTN.W
|
||||
mpack ecx, PAD + BTN.H + 2, 2
|
||||
mcall SF_DRAW_RECT, ebx, ecx, edx
|
||||
|
||||
inc edi
|
||||
add esi, esi ; shift to next tab bit (1→2→4→8)
|
||||
cmp edi, TAB_COUNT
|
||||
jb .loop
|
||||
|
||||
; draw current tab content
|
||||
mcall SF_DRAW_RECT, <GRID.X, GRID.W>, <GRID.Y, GRID.H>, [sc.work]
|
||||
|
||||
mov eax, [active_tab]
|
||||
bsf eax, eax ; 0=i32, 1=i18, 2=i18w, 3=cbox
|
||||
cmp eax, 3
|
||||
je .cbox
|
||||
lea esi, [tab_icon_args + eax * 8]
|
||||
stdcall draw_tab_icons, [esi], [esi + 4]
|
||||
ret
|
||||
|
||||
.cbox:
|
||||
stdcall draw_tab_cbox
|
||||
ret
|
||||
|
||||
|
||||
proc draw_tab_icons stdcall, _shm_name, _meta_off
|
||||
mcall SF_SYS_MISC, SSF_MEM_OPEN, meta_name, 0, SHM_READ
|
||||
test eax, eax
|
||||
jz .done
|
||||
|
||||
add eax, [_meta_off]
|
||||
mov ecx, [eax] ; icon_c
|
||||
mov edx, [eax + 4] ; icon_w (always next field: _meta_off + 4)
|
||||
|
||||
test ecx, ecx
|
||||
jz .close_meta
|
||||
test edx, edx
|
||||
jz .close_meta
|
||||
|
||||
push ecx
|
||||
push edx
|
||||
mcall SF_SYS_MISC, SSF_MEM_OPEN, [_shm_name], 0, SHM_READ
|
||||
pop edx
|
||||
pop ecx
|
||||
|
||||
test eax, eax
|
||||
jz .close_meta
|
||||
|
||||
stdcall draw_tab_icons_grid, eax, ecx, edx
|
||||
|
||||
mcall SF_SYS_MISC, SSF_MEM_CLOSE, [_shm_name]
|
||||
|
||||
.close_meta:
|
||||
mcall SF_SYS_MISC, SSF_MEM_CLOSE, meta_name
|
||||
|
||||
.done:
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc draw_tab_icons_grid stdcall uses ebx esi edi, _icon_img, _icon_c, _icon_w
|
||||
locals
|
||||
x dd 0
|
||||
x_off dd 0
|
||||
y dd 0
|
||||
icon_size dd 0
|
||||
endl
|
||||
; icon_bytes = icon_w * icon_w * 4
|
||||
mov eax, [_icon_w]
|
||||
imul eax, eax
|
||||
shl eax, 2
|
||||
mov [icon_size], eax
|
||||
|
||||
; x_off = (CELL.W - icon_w) / 2
|
||||
mov eax, CELL.W
|
||||
sub eax, [_icon_w]
|
||||
shr eax, 1
|
||||
mov [x_off], eax
|
||||
|
||||
; y_step = CELL.H
|
||||
mov edi, CELL.H
|
||||
|
||||
xor ecx, ecx
|
||||
|
||||
.for_icons:
|
||||
cmp ecx, [_icon_c]
|
||||
jae .end_for_icons
|
||||
push ecx
|
||||
|
||||
; SF_PUT_IMAGE_EXT _icon_img+icon_size*index, <_icon_w, _icon_w>, <x+x_off, y+GRID_Y>, 32, 0, 0
|
||||
mov ebx, [icon_size]
|
||||
imul ebx, ecx
|
||||
add ebx, [_icon_img]
|
||||
|
||||
mov ecx, [_icon_w]
|
||||
shl ecx, 16
|
||||
add ecx, [_icon_w]
|
||||
|
||||
mov edx, [x]
|
||||
add edx, [x_off]
|
||||
shl edx, 16
|
||||
add edx, [y]
|
||||
add edx, GRID.Y
|
||||
|
||||
push edi
|
||||
push ebp
|
||||
mcall SF_PUT_IMAGE_EXT, , , , 32, 0, 0
|
||||
pop ebp
|
||||
pop edi
|
||||
|
||||
; draw number with no leading zeros, centered in CELL.W
|
||||
mov edx, [x]
|
||||
add edx, GAP
|
||||
shl edx, 16
|
||||
add edx, [y]
|
||||
add edx, [_icon_w]
|
||||
add edx, GRID.Y + 2
|
||||
mov esi, DRAWNUM_NOZERO
|
||||
add esi, [sc.work_graph]
|
||||
|
||||
pop ecx
|
||||
mcall SF_DRAW_NUMBER, DRAWNUM_DEC3, , , ,
|
||||
inc ecx
|
||||
|
||||
add [x], CELL.W
|
||||
cmp [x], WIN.W - CELL.W
|
||||
jle .for_icons
|
||||
mov [x], 0
|
||||
add [y], edi
|
||||
|
||||
jmp .for_icons
|
||||
.end_for_icons:
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc draw_tab_cbox stdcall
|
||||
mcall SF_SYS_MISC, SSF_MEM_OPEN, lb_tab_cbox, 0, SHM_READ
|
||||
test eax, eax
|
||||
jz .done
|
||||
mov ebx, eax
|
||||
mcall SF_PUT_IMAGE, , \
|
||||
<CBOX_WIDTH, CBOX_HEIGHT>, \
|
||||
<(WIN.W - CBOX_WIDTH)/2, (WIN.H - CBOX_HEIGHT)/2>
|
||||
mcall SF_SYS_MISC, SSF_MEM_CLOSE, lb_tab_cbox
|
||||
.done:
|
||||
ret
|
||||
endp
|
||||
|
||||
; ====================================================================
|
||||
|
||||
MODE_DAEMON:
|
||||
|
||||
stdcall dll.Load, LIBS
|
||||
|
||||
; load shared resources from files
|
||||
DEBUGF DBG_INFO, "I: @reshare: loading resources...\n"
|
||||
stdcall load_icons, icons32_path, icons32_image, size32
|
||||
stdcall load_icons, icons18_path, icons18_image, size18
|
||||
|
||||
; publish meta
|
||||
mcall SF_SYS_MISC, SSF_MEM_OPEN, meta_name, META_SIZE, SHM_CREATE + SHM_WRITE
|
||||
test eax, eax
|
||||
jz .meta_done
|
||||
mov edi, eax
|
||||
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
mov eax, [icons32_image]
|
||||
test eax, eax
|
||||
jz .i32_set
|
||||
|
||||
mov ebx, [eax + Image.Width]
|
||||
mov eax, [eax + Image.Height]
|
||||
test ebx, ebx
|
||||
jz .i32_set
|
||||
xor edx, edx
|
||||
div ebx
|
||||
mov ecx, eax
|
||||
|
||||
.i32_set:
|
||||
mov [edi + META_I32_W], ebx
|
||||
mov [edi + META_I32_C], ecx
|
||||
xor ebx, ebx
|
||||
xor ecx, ecx
|
||||
mov eax, [icons18_image]
|
||||
test eax, eax
|
||||
jz .i18_set
|
||||
|
||||
mov ebx, [eax + Image.Width]
|
||||
mov eax, [eax + Image.Height]
|
||||
test ebx, ebx
|
||||
jz .i18_set
|
||||
xor edx, edx
|
||||
div ebx
|
||||
mov ecx, eax
|
||||
|
||||
.i18_set:
|
||||
mov [edi + META_I18_W], ebx
|
||||
mov [edi + META_I18_C], ecx
|
||||
mov [edi + META_I18W_W], ebx
|
||||
mov [edi + META_I18W_C], ecx
|
||||
|
||||
mov dword [edi + META_CBOX_W], CBOX_WIDTH
|
||||
mov dword [edi + META_CBOX_H], CBOX_HEIGHT
|
||||
mov dword [edi + META_CBOX_SIZE], CBOX_IMG_SIZE
|
||||
|
||||
.meta_done:
|
||||
DEBUGF DBG_INFO, "I: @reshare: starting in daemon mode\n"
|
||||
|
||||
mcall SF_SYS_MISC, SSF_MEM_OPEN, lb_tab_cbox, CBOX_IMG_SIZE, SHM_CREATE + SHM_WRITE
|
||||
test eax, eax
|
||||
jz .skip_cbox
|
||||
mov edi, eax
|
||||
mov esi, cbox_indexed
|
||||
mov ecx, CBOX_PIXELS
|
||||
cld
|
||||
.cbox_expand:
|
||||
movzx ebx, byte [esi]
|
||||
inc esi
|
||||
mov eax, [cbox_palette + ebx * 4]
|
||||
stosb ; B
|
||||
shr eax, 8
|
||||
stosb ; G
|
||||
shr eax, 8
|
||||
stosb ; R
|
||||
dec ecx
|
||||
jnz .cbox_expand
|
||||
.skip_cbox:
|
||||
|
||||
cmp [icons32_image], 0
|
||||
jz .skip_i32
|
||||
stdcall copy_image_to_shm, lb_tab_i32, size32, icons32_image
|
||||
test eax, eax
|
||||
jz .skip_i32
|
||||
invoke img.destroy, [icons32_image]
|
||||
.skip_i32:
|
||||
|
||||
cmp [icons18_image], 0
|
||||
jz .skip_i18
|
||||
stdcall copy_image_to_shm, lb_tab_i18, size18, icons18_image
|
||||
test eax, eax
|
||||
jz .skip_i18
|
||||
mov [shared_i18], eax
|
||||
|
||||
mcall SF_SYS_MISC, SSF_MEM_OPEN, lb_tab_i18w, [size18], SHM_CREATE + SHM_WRITE
|
||||
test eax, eax
|
||||
jz .skip_i18
|
||||
mov [shared_i18w], eax
|
||||
|
||||
invoke img.destroy, [icons18_image]
|
||||
mov dword [icons18_image], 0
|
||||
.skip_i18:
|
||||
|
||||
mcall SF_SET_EVENTS_MASK, EVM_BACKGROUND
|
||||
|
||||
.event_loop:
|
||||
push [sc.work]
|
||||
mcall SF_STYLE_SETTINGS, SSF_GET_COLORS, sc, sizeof.system_colors
|
||||
pop eax
|
||||
cmp eax, [sc.work]
|
||||
je .wait_event
|
||||
cmp [shared_i18], 0
|
||||
jz .wait_event
|
||||
cmp [shared_i18w], 0
|
||||
jz .wait_event
|
||||
mov esi, [shared_i18]
|
||||
mov edi, [shared_i18w]
|
||||
mov ecx, [size18]
|
||||
shr ecx, 2 ; / 4 to get size in dwords
|
||||
cld
|
||||
rep movsd
|
||||
stdcall replace_2cols, [shared_i18w], [size18], 0xFFFFFFFF, [sc.work], 0xFFCACBD6, [sc.work_dark]
|
||||
|
||||
.wait_event:
|
||||
mcall SF_WAIT_EVENT
|
||||
cmp eax, EV_BACKGROUND
|
||||
je .event_loop
|
||||
jmp .wait_event
|
||||
|
||||
|
||||
proc load_icons stdcall uses ebx ecx, _path, _img_ptr, _size_ptr
|
||||
invoke img.from_file, [_path]
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
mov ebx, [_img_ptr]
|
||||
mov [ebx], eax
|
||||
mov ebx, [eax + Image.Width]
|
||||
mov ecx, [eax + Image.Height]
|
||||
imul ecx, ebx
|
||||
shl ecx, 2
|
||||
mov ebx, [_size_ptr]
|
||||
mov [ebx], ecx
|
||||
ret
|
||||
|
||||
.fail:
|
||||
DEBUGF DBG_ERR, "E: @reshare: error loading icons from %s\n", [_path]
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc copy_image_to_shm stdcall uses ebx ecx edx esi edi, _shm_name, _size_ptr, _image_ptr
|
||||
mov edx, [_size_ptr]
|
||||
mov edx, [edx]
|
||||
mcall SF_SYS_MISC, SSF_MEM_OPEN, [_shm_name], edx, SHM_CREATE + SHM_WRITE
|
||||
test eax, eax
|
||||
jz .done
|
||||
mov ebx, [_image_ptr]
|
||||
mov ebx, [ebx]
|
||||
mov esi, [ebx + Image.Data]
|
||||
mov edi, eax
|
||||
mov ecx, [_size_ptr]
|
||||
mov ecx, [ecx]
|
||||
shr ecx, 2
|
||||
cld
|
||||
rep movsd
|
||||
.done:
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
proc replace_2cols stdcall uses edi, _imgsrc, _imgsize, _col_old1, _col_new1, _col_old2, _col_new2
|
||||
mov edx, [_imgsize]
|
||||
add edx, [_imgsrc]
|
||||
mov edi, [_imgsrc]
|
||||
.loop:
|
||||
cmp edi, edx
|
||||
jae .done
|
||||
mov eax, [edi]
|
||||
cmp eax, [_col_old1]
|
||||
jne .check2
|
||||
mov eax, [_col_new1]
|
||||
mov [edi], eax
|
||||
jmp .next
|
||||
.check2:
|
||||
cmp eax, [_col_old2]
|
||||
jne .next
|
||||
mov eax, [_col_new2]
|
||||
mov [edi], eax
|
||||
.next:
|
||||
add edi, 4
|
||||
jmp .loop
|
||||
.done:
|
||||
ret
|
||||
endp
|
||||
|
||||
; ====================================================================
|
||||
|
||||
BORD = 5
|
||||
PAD = 8
|
||||
GAP = 12
|
||||
|
||||
GRID_COLS = 16
|
||||
GRID_ROWS = 9
|
||||
|
||||
GRID_Y = BTN.Y + BTN.H + PAD * 2 + 1
|
||||
TAB_STEP = BTN.W + PAD * 2
|
||||
|
||||
WIN RECT 0, 0, GRID.W + PAD * 2 + BORD * 2, GRID.H + GRID_Y + 1 + PAD + 10 + GAP
|
||||
BTN RECT 0, PAD + 4, CELL.W * 4 - PAD * 2 , 22
|
||||
CELL RECT 0, 0, 32 + PAD * 2 , 32 + 4 + 10 + PAD
|
||||
|
||||
GRID RECT PAD, GRID_Y, CELL.W * GRID_COLS - PAD * 2, CELL.H * GRID_ROWS
|
||||
|
||||
FONT_TYPE = 0x90
|
||||
WIN_STYLE = 0x34000000 ; skinned window, draws itself
|
||||
|
||||
BTN_HIDE = 0x60000000
|
||||
BTN_BASE = 10 ; first user-defined button ID
|
||||
|
||||
DRAWNUM_DEC3 = 0x00030000 ; SF_DRAW_NUMBER: decimal, 3 digits
|
||||
DRAWNUM_NOZERO = 0x10000000 ; SF_DRAW_NUMBER: no leading zeros
|
||||
|
||||
KEY_TAB = 15 ; Tab key scan code
|
||||
|
||||
; ====================================================================
|
||||
|
||||
if lang eq ru_RU
|
||||
|
||||
title cp866 "@RESHARE - Служба общих ресурсов", 0
|
||||
lb_info cp866 "Имя каждой вкладки соответствует имени области памяти, доступной через сисфункцию 68.22.", 0
|
||||
|
||||
else if lang eq es_ES
|
||||
|
||||
title db "@RESHARE - Servicio de recursos compartidos", 0
|
||||
lb_info db "Cada nombre de pestana corresponde al nombre de memoria accesible mediante sysfunc 68.22.", 0
|
||||
|
||||
else
|
||||
|
||||
title cp850 "@RESHARE - Shared resources service", 0
|
||||
lb_info cp850 "Each tab name corresponds to shared memory page name that can be accessed via sysfunc 68.22.", 0
|
||||
|
||||
endf
|
||||
|
||||
lb_tab_i32 db "ICONS32", 0
|
||||
lb_tab_i18 db "ICONS18", 0
|
||||
lb_tab_i18w db "ICONS18W", 0
|
||||
lb_tab_cbox db "CHECKBOX", 0
|
||||
|
||||
lb_tab_i32_res db "32x32x32bpp", 0
|
||||
lb_tab_i18_res db "18x18x32bpp", 0
|
||||
lb_tab_cbox_res db "13x13x24bpp", 0
|
||||
|
||||
; ====================================================================
|
||||
|
||||
DBG_ALL = 0 ; all messages
|
||||
DBG_INFO = 1 ; info and errors
|
||||
DBG_ERR = 2 ; only errors
|
||||
|
||||
__DEBUG__ = 1
|
||||
__DEBUG_LEVEL__ = DBG_ERR
|
||||
|
||||
SHM_READ = 0x00
|
||||
SHM_WRITE = 0x01
|
||||
SHM_CREATE = 0x08
|
||||
|
||||
ACTIVE_ICONS32 = 1
|
||||
ACTIVE_ICONS18 = 2
|
||||
ACTIVE_ICONS18W = 4
|
||||
ACTIVE_CHECKBOX = 8
|
||||
|
||||
TAB_COUNT = 4
|
||||
|
||||
META_I32_C = 0
|
||||
META_I32_W = 4
|
||||
META_I18_C = 8
|
||||
META_I18_W = 12
|
||||
META_I18W_C = 16
|
||||
META_I18W_W = 20
|
||||
META_CBOX_W = 24
|
||||
META_CBOX_H = 28
|
||||
META_CBOX_SIZE = 32
|
||||
META_SIZE = 36
|
||||
|
||||
; ====================================================================
|
||||
|
||||
meta_name db "RESHARE_META", 0
|
||||
|
||||
icons32_path db "/SYS/ICONS32.PNG", 0
|
||||
icons18_path db "/SYS/ICONS16.PNG", 0
|
||||
|
||||
; pointers to Image structures
|
||||
icons32_image dd 0
|
||||
icons18_image dd 0
|
||||
|
||||
; sizes of icons image data in bytes
|
||||
size32 dd 0
|
||||
size18 dd 0
|
||||
|
||||
; currenly selected i18w section
|
||||
shared_i18 dd 0
|
||||
shared_i18w dd 0
|
||||
|
||||
active_tab dd ACTIVE_ICONS32
|
||||
|
||||
tab_icon_args:
|
||||
dd lb_tab_i32, META_I32_C ; META_I32_W = META_I32_C + 4
|
||||
dd lb_tab_i18, META_I18_C ; META_I18_W = META_I18_C + 4
|
||||
dd lb_tab_i18w, META_I18W_C ; META_I18W_W = META_I18W_C + 4
|
||||
|
||||
tab_label_strs:
|
||||
dd lb_tab_i32, lb_tab_i32_res
|
||||
dd lb_tab_i18, lb_tab_i18_res
|
||||
dd lb_tab_i18w, lb_tab_i18_res
|
||||
dd lb_tab_cbox, lb_tab_cbox_res
|
||||
|
||||
sc system_colors
|
||||
|
||||
include_debug_strings
|
||||
|
||||
; ====================================================================
|
||||
|
||||
I_END:
|
||||
rb 4096
|
||||
align 16
|
||||
STACKTOP:
|
||||
|
||||
MEM:
|
||||
Reference in New Issue
Block a user