1
0

CMM: add template app, console library headers

git-svn-id: svn://kolibrios.org@6684 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2016-11-07 14:41:01 +00:00
parent 00d1316dd2
commit 23d86a6122
5 changed files with 126 additions and 12 deletions

View File

@ -58,19 +58,10 @@ inline void debugi(dword d_int)
debugi(number); debugi(number);
} }
:void assert(dword _type, _actual, _expected) :void die(dword _last_msg)
{ {
char r[4096]; debugln(_last_msg);
if (_type=='s') { ExitProcess();
if (streq(_actual, _expected)) return;
sprintf(#r, "==========nok{\nactual: %s\nexpected: %s", _actual, _expected);
debugln(#r);
}
if (_type=='i') {
if (_actual == _expected)) return;
sprintf(#r, "==========nok{\nactual: %i\nexpected: %i", _actual, _expected);
debugln(#r);
}
} }
#endif #endif

View File

@ -0,0 +1,75 @@
#ifndef INCLUDE_CONSOLE_H
#define INCLUDE_CONSOLE_H
#print "[include <obj/console.h]\n"
#ifndef INCLUDE_KOLIBRI_H
#include "../lib/kolibri.h"
#endif
#ifndef INCLUDE_DLL_H
#include "../lib/dll.h"
#endif
dword libConsole = #alibConsole;
char alibConsole[] = "/sys/lib/console.obj";
dword con_start = #a_con_start;
dword con_init = #a_con_init;
dword con_write_asciiz = #a_con_write_asciiz;
dword con_write_string = #a_con_write_string;
dword con_printf = #a_con_printf;
dword con_exit = #a_con_exit;
dword con_get_flags = #a_con_get_flags;
dword con_set_flags = #a_con_set_flags;
dword con_kbhit = #a_con_kbhit;
dword con_getch = #a_con_getch;
dword con_getch2 = #a_con_getch2;
dword con_gets = #a_con_gets;
dword con_gets2 = #a_con_gets2;
dword con_get_font_height = #a_con_get_font_height;
dword con_get_cursor_height = #a_con_get_cursor_height;
dword con_set_cursor_height = #a_con_set_cursor_height;
dword con_cls = #a_con_cls;
dword con_get_cursor_pos = #a_con_get_cursor_pos;
dword con_set_cursor_pos = #a_con_set_cursor_pos;
dword con_set_title = #a_con_set_title;
$DD 2 dup 0
char a_con_start[] = "START";
char a_con_init[] = "con_init";
char a_con_write_asciiz[] = "con_write_asciiz";
char a_con_write_string[] = "con_write_string";
char a_con_printf[] = "con_printf";
char a_con_exit[] = "con_exit";
char a_con_get_flags[] = "con_get_flags";
char a_con_set_flags[] = "con_set_flags";
char a_con_kbhit[] = "con_kbhit";
char a_con_getch[] = "con_getch";
char a_con_getch2[] = "con_getch2";
char a_con_gets[] = "con_gets";
char a_con_gets2[] = "con_gets2";
char a_con_get_font_height[] = "con_get_font_height";
char a_con_get_cursor_height[] = "con_get_cursor_height";
char a_con_set_cursor_height[] = "con_ges_focursoreight";
char a_con_cls[] = "con_cls";
char a_con_get_cursor_pos[] = "con_get_cursor_pos";
char a_con_set_cursor_pos[] = "con_set_cursor_pos";
char a_con_set_title[] = "con_set_title";
// text color
#define CON_COLOR_BLUE 0x01
#define CON_COLOR_GREEN 0x02
#define CON_COLOR_RED 0x04
#define CON_COLOR_BRIGHT 0x08
// background color
#define CON_BGR_BLUE 0x10
#define CON_BGR_GREEN 0x20
#define CON_BGR_RED 0x40
#define CON_BGR_BRIGHT 0x80
// special
#define CON_IGNORE_SPECIALS 0x100
#define CON_WINDOW_CLOSED 0x200
#endif

View File

@ -0,0 +1,6 @@
if tup.getconfig("NO_CMM") ~= "" then return end
if tup.getconfig("LANG") == "ru"
then C_LANG = "LANG_RUS"
else C_LANG = "LANG_ENG" -- this includes default case without config
end
tup.rule("template.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "template.com")

View File

@ -0,0 +1,5 @@
@del *.kex
@c-- template.c
@rename *.com *.kex
@del warning.txt
@pause

View File

@ -0,0 +1,37 @@
/*
* Template C-- program.
*/
#define MEMSIZE 4096*10
#include "../lib/io.h"
#include "../lib/gui.h"
proc_info Form;
void main()
{
word btn;
loop() switch(WaitEvent())
{
case evButton:
btn = GetButtonID();
if (btn == 1) ExitProcess();
break;
case evKey:
GetKeys();
if (key_scancode == SCAN_CODE_ESC) ExitProcess();
break;
case evReDraw:
draw_window();
break;
}
}
void draw_window()
{
DefineAndDrawWindow(215, 100, 350, 300, 0x34, 0xEEEeee, "Window title");
GetProcessInfo(#Form, SelfInfo);
}