forked from KolibriOS/kolibrios
ktcc: Deleted residual files
git-svn-id: svn://kolibrios.org@9550 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
4f6fba63fd
commit
5d71c48018
@ -1,28 +0,0 @@
|
||||
CC=../bin/kos32-tcc
|
||||
CFLAGS= -I ../libc/include
|
||||
|
||||
all:
|
||||
$(CC) $(CFLAGS) asm_ex.c -lck -o asm_ex.kex
|
||||
$(CC) $(CFLAGS) consoleio.c -lck -o consoleio.kex
|
||||
$(CC) $(CFLAGS) files.c -lck -o files.kex
|
||||
$(CC) $(CFLAGS) winbasics.c -lck -o winbasics.kex
|
||||
$(CC) $(CFLAGS) dynamic.c -lck -lhttp -linputbox -o dynamic.kex
|
||||
$(CC) $(CFLAGS) load_coff.c -o load_coff.kex -lck
|
||||
$(CC) $(CFLAGS) graphics.c -lck -lgb -o graphics.kex
|
||||
$(CC) $(CFLAGS) dir_example.c -lck -o dir_example.kex
|
||||
$(CC) $(CFLAGS) getopt_ex.c -lck -o getopt_ex.kex
|
||||
|
||||
$(CC) $(CFLAGS) clayer/msgbox.c -lck -lmsgbox -o clayer/msgbox.kex
|
||||
$(CC) $(CFLAGS) clayer/rasterworks.c -lck -lrasterworks -o clayer/rasterworks.kex
|
||||
$(CC) $(CFLAGS) clayer/boxlib.c -lck -lbox -o clayer/boxlib.kex
|
||||
$(CC) $(CFLAGS) clayer/libimg.c -lck -limg -o clayer/libimg.kex
|
||||
$(CC) $(CFLAGS) clayer/dialog.c -lck -ldialog -o clayer/dialog.kex
|
||||
|
||||
$(CC) $(CFLAGS) net/tcpsrv_demo.c -lck -o net/tcpsrv_demo.kex
|
||||
$(CC) $(CFLAGS) net/nslookup.c -lck -lnetwork -o net/nslookup.kex
|
||||
$(CC) $(CFLAGS) net/http_tcp_demo.c -lck -lnetwork -o net/http_tcp_demo.kex
|
||||
|
||||
$(CC) $(CFLAGS) tinygl/fps.c tinygl/gears.c -o tinygl/gears.kex -ltinygl -lck
|
||||
|
||||
clean:
|
||||
rm *.kex clayer/*.kex net/*.kex tinygl/*.kex
|
@ -1,68 +0,0 @@
|
||||
/* examples for interoperability with assembler
|
||||
|
||||
1. Calling assembler code from .c : see in libc\math any .asm file
|
||||
2. Using inline assembler: see \include\kos32sys1.h and libc\math\fmod.c
|
||||
- https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/Extended-Asm.html
|
||||
- not all constraints from gcc are supported, no "f" or "t" for example
|
||||
- not supported clobberring st registers, must manual add "fstp %%st" at end or similar
|
||||
- need full suffixes for opcodes, fstpl but not fstp
|
||||
|
||||
3. Calling c functions from .asm: see \libc\start\start.asm:99
|
||||
Remember:
|
||||
- small ints always passed as int32, floating point params as 64-bit
|
||||
- returned structs passed on stack with additional hidden 1st param
|
||||
- c functions can use EAX, ECX, EDX without warnings
|
||||
- .c default is cdecl calling convention https://en.wikipedia.org/wiki/X86_calling_conventions
|
||||
- dont use fastcall calling convention, tinycc realized it non-conformant way
|
||||
- tinycc supports only ELF object files
|
||||
|
||||
tcc can be used as a linker
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
main()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 20; i++)
|
||||
{
|
||||
printf("------------------------------------------------------\n");
|
||||
printf ( "remainder of 5.3 / 2 is %f\n", remainder (5.3,2) );
|
||||
printf ( "remainder of 18.5 / 4.2 is %f\n", remainder (18.5,4.2) );
|
||||
//remainder of 5.3 / 2 is -0.700000
|
||||
//remainder of 18.5 / 4.2 is 1.700000
|
||||
|
||||
printf ( "fmod of 5.3 / 2 is %f\n", fmod (5.3,2) );
|
||||
printf ( "fmod of 18.5 / 4.2 is %f\n", fmod (18.5,4.2) );
|
||||
// fmod of 5.3 / 2 is 1.300000
|
||||
// fmod of 18.5 / 4.2 is 1.700000
|
||||
|
||||
double param, fractpart, intpart, result;
|
||||
int n;
|
||||
|
||||
param = 3.14159265;
|
||||
fractpart = modf (param , &intpart);
|
||||
printf ("%f = %f + %f \n", param, intpart, fractpart);
|
||||
//3.141593 = 3.000000 + 0.141593
|
||||
|
||||
param = 0.95;
|
||||
n = 4;
|
||||
result = ldexp (param , n);
|
||||
printf ("%f * 2^%d = %f\n", param, n, result);
|
||||
//0.950000 * 2^4 = 15.200000
|
||||
|
||||
param = 8.0;
|
||||
result = frexp (param , &n);
|
||||
printf ("%f = %f * 2^%d\n", param, result, n);
|
||||
//8.000000 = 0.500000 * 2^4
|
||||
param = 50;
|
||||
result = frexp (param , &n);
|
||||
printf ("%f = %f * 2^%d\n", param, result, n);
|
||||
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
#SHS
|
||||
/sys/@notify 'Build in progress...\nYou will find binaries in /tmp0/1/tccbin' -I
|
||||
mkdir /tmp0/1/tccbin
|
||||
../tcc asm_ex.c -lck -o /tmp0/1/tccbin/asm_ex
|
||||
../tcc consoleio.c -lck -o /tmp0/1/tccbin/consoleio
|
||||
../tcc files.c -lck -o /tmp0/1/tccbin/files
|
||||
../tcc winbasics.c -lck -o /tmp0/1/tccbin/winbasics
|
||||
../tcc dynamic.c -lck -lhttp -linputbox -o /tmp0/1/tccbin/dynamic
|
||||
../tcc load_coff.c -o /tmp0/1/tccbin/load_coff -lck
|
||||
../tcc clayer/msgbox.c -lck -lmsgbox -o /tmp0/1/tccbin/msgbox
|
||||
../tcc graphics.c -lck -lgb -o /tmp0/1/tccbin/graphics
|
||||
../tcc clayer/rasterworks.c -lck -lrasterworks -o /tmp0/1/tccbin/rasterworks
|
||||
../tcc clayer/boxlib.c -lck -lbox -o /tmp0/1/tccbin/boxlib_ex
|
||||
../tcc clayer/libimg.c -lck -limg -o /tmp0/1/tccbin/libimg_ex
|
||||
cp clayer/logo.png /tmp0/1/tccbin/logo.png
|
||||
../tcc clayer/dialog.c -lck -ldialog -o /tmp0/1/tccbin/dialog_ex
|
||||
../tcc dir_example.c -lck -o /tmp0/1/tccbin/dir_example
|
||||
../tcc net/tcpsrv_demo.c -lck -o /tmp0/1/tccbin/tcpsrv_demo
|
||||
../tcc net/nslookup.c -lck -lnetwork -o /tmp0/1/tccbin/nslookup
|
||||
../tcc net/http_tcp_demo.c -lck -lnetwork -o /tmp0/1/tccbin/http_tcp_demo
|
||||
../tcc getopt_ex.c -lck -o /tmp0/1/tccbin/getopt_ex
|
||||
../tcc tinygl/fps.c tinygl/gears.c -o /tmp0/1/tccbin/gears -ltinygl -lck
|
||||
exit
|
@ -1,110 +0,0 @@
|
||||
// BOXLIB EXAMPLE (scrollbar, progressbar, editbox and checkbox)
|
||||
// Writed by maxcodehack and superturbocat2001
|
||||
|
||||
#include <kos32sys1.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <clayer/boxlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define WIN_W 640
|
||||
#define WIN_H 563
|
||||
|
||||
#define ED_BUFF_LEN 50
|
||||
#define TEXT_SIZE 0x10000000
|
||||
#define SCROLL_BUTTON_SIZE 15
|
||||
#define SCROLL_MAX_LEN 215
|
||||
#define BLACK 0x000000
|
||||
#define WHITE 0xFFFFFF
|
||||
#define BLUE 0x0000FF
|
||||
|
||||
uint32_t wheels;
|
||||
char* title = "Boxlib example";
|
||||
char ed_buff[ED_BUFF_LEN];
|
||||
|
||||
|
||||
scrollbar scroll = {15, WIN_W - 26, WIN_H - 29, 0, 0, 2, 215, SCROLL_BUTTON_SIZE, 0,0x707070,0xD2CED0,0x555555};
|
||||
progressbar pg = {0, 10, 10, 270, 35, 1, 0, 200, 0xB4B4B4, 0x2728FF, 0xA9A9A9};
|
||||
edit_box ed={WIN_W-140,10,60,0xFFFFFF,0x6a9480,0,0x6a9480, BLACK | TEXT_SIZE, ED_BUFF_LEN, ed_buff,NULL,ed_focus};
|
||||
check_box output_off={X_W(10, 15), Y_H(120,15), 10, WHITE, BLUE, BLACK | TEXT_SIZE, "Disable duplicate output",0};
|
||||
|
||||
void draw_window(){
|
||||
BeginDraw();
|
||||
DrawWindow(215,100,WIN_W,WIN_H,title, 0x858585, 0x34);
|
||||
edit_box_draw(&ed);
|
||||
check_box_draw2(&output_off);
|
||||
if(!output_off.flags)
|
||||
{
|
||||
draw_text_sys(ed_buff, 10, 90, strlen(ed_buff), BLACK | TEXT_SIZE);
|
||||
}
|
||||
scrollbar_v_draw(&scroll);
|
||||
progressbar_draw(&pg);
|
||||
EndDraw();
|
||||
}
|
||||
|
||||
//// EVENTMASK
|
||||
#define EVM_REDRAW 1
|
||||
#define EVM_KEY 2
|
||||
#define EVM_BUTTON 4
|
||||
#define EVM_EXIT 8
|
||||
#define EVM_BACKGROUND 16
|
||||
#define EVM_MOUSE 32
|
||||
#define EVM_IPC 64
|
||||
#define EVM_STACK 128
|
||||
#define EVM_DEBUG 256
|
||||
#define EVM_STACK2 512
|
||||
#define EVM_MOUSE_FILTER 0x80000000
|
||||
#define EVM_CURSOR_FILTER 0x40000000
|
||||
//// EVENTMASK
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
kolibri_boxlib_init();
|
||||
init_checkbox2(&output_off);
|
||||
set_event_mask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE+EVM_MOUSE_FILTER);
|
||||
while(1)
|
||||
{
|
||||
switch(GetOsEvent())
|
||||
{
|
||||
case KOLIBRI_EVENT_BUTTON:
|
||||
if (get_os_button() == 1) exit(0);
|
||||
break;
|
||||
|
||||
case KOLIBRI_EVENT_KEY:
|
||||
edit_box_key(&ed, get_key().val);
|
||||
draw_window();
|
||||
break;
|
||||
|
||||
case KOLIBRI_EVENT_REDRAW:
|
||||
draw_window();
|
||||
break;
|
||||
case KOLIBRI_EVENT_MOUSE:
|
||||
edit_box_mouse(&ed);
|
||||
scrollbar_v_mouse(&scroll);
|
||||
pg.value = scroll.position;
|
||||
progressbar_draw(&pg);
|
||||
check_box_mouse2(&output_off);
|
||||
unsigned int scroll_strong = 10;
|
||||
wheels = GetMouseWheels();
|
||||
if(wheels & 0xFFFF)
|
||||
{
|
||||
if((short)wheels > 0){
|
||||
scroll.position += scroll_strong;
|
||||
if(scroll.position>scroll.max_area-scroll.cur_area)
|
||||
{
|
||||
scroll.position=scroll.max_area-scroll.cur_area;
|
||||
}
|
||||
}
|
||||
else if((short)wheels < 0 && scroll.position > 0){
|
||||
scroll.position -= scroll_strong;
|
||||
if((int)scroll.position<0){
|
||||
scroll.position=0;
|
||||
}
|
||||
}
|
||||
scrollbar_v_draw(&scroll);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
#include <kos32sys1.h>
|
||||
#include <clayer/dialog.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
kolibri_dialog_init(); // dialog init
|
||||
open_dialog *dlg_open = kolibri_new_open_dialog(OPEN, 10, 10, 420, 320); // create opendialog struct
|
||||
OpenDialog_init(dlg_open); // Initializing an open dialog box.
|
||||
OpenDialog_start(dlg_open); // Show open dialog box
|
||||
|
||||
color_dialog *color_select = kolibri_new_color_dialog(SELECT, 10, 10,420,320); // create colordialog struct
|
||||
ColorDialog_init(color_select); // Initializing an color dialog box.
|
||||
ColorDialog_start(color_select); // Show color dialog
|
||||
|
||||
if(dlg_open->status == SUCCESS){
|
||||
printf("File selected '%s'\n",dlg_open->openfile_path);
|
||||
}else{
|
||||
puts("No file selected!");
|
||||
}
|
||||
|
||||
if(color_select->status == SUCCESS){
|
||||
printf("Color selected: #%06X\n",color_select->color);
|
||||
RGB color_rgb = (RGB)color_select->color;
|
||||
printf("Red:%d Green:%d Blue:%d", color_rgb.red, color_rgb.green, color_rgb.blue);
|
||||
}else{
|
||||
puts("No color selected!");
|
||||
}
|
||||
|
||||
free(dlg_open);
|
||||
free(color_select);
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
/* Written by turbocat2001 (Logaev Maxim) */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <clayer/libimg.h>
|
||||
#include <kos32sys1.h>
|
||||
|
||||
#define NEW_IMG_H 128
|
||||
#define NEW_IMG_W 128
|
||||
|
||||
#define IMG_H 256
|
||||
#define IMG_W 256
|
||||
|
||||
Image *image_blend; // Create image struct
|
||||
|
||||
struct kolibri_system_colors sys_color_table; // Create system colors table
|
||||
|
||||
char* load_img(char* fname, int32_t* read_sz){ // Image file upload function
|
||||
FILE *f = fopen(fname, "rb");
|
||||
if (!f) {
|
||||
printf("Can't open file: %s\n", fname);
|
||||
exit(0);
|
||||
}
|
||||
if (fseek(f, 0, SEEK_END)) {
|
||||
printf("Can't SEEK_END file: %s\n", fname);
|
||||
exit(0);
|
||||
}
|
||||
int filesize = ftell(f);
|
||||
rewind(f);
|
||||
char* fdata = malloc(filesize);
|
||||
if(!fdata) {
|
||||
printf("No memory for file %s\n", fname);
|
||||
exit(0);
|
||||
}
|
||||
*read_sz = fread(fdata, 1, filesize, f);
|
||||
if (ferror(f)) {
|
||||
printf("Error reading file %s\n", fname);
|
||||
exit(0);
|
||||
}
|
||||
fclose(f);
|
||||
return fdata;
|
||||
}
|
||||
|
||||
void DrawGUI(){
|
||||
BeginDraw();
|
||||
DrawWindow(10, 40, (IMG_W+NEW_IMG_W)+50, IMG_H+50, "Libimg", sys_color_table.work_area, 0x34);
|
||||
img_draw(image_blend, 10, 10, IMG_W*2, IMG_H , 0, 0); // Draw blended image to window
|
||||
EndDraw();
|
||||
}
|
||||
|
||||
int main(){
|
||||
if (kolibri_libimg_init() == -1){
|
||||
printf("Error loading lib_img.obj\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
get_system_colors(&sys_color_table); // Get system colors theme
|
||||
set_event_mask(0xC0000027);
|
||||
|
||||
uint32_t img_size;
|
||||
void *file_data = load_img("logo.png", &img_size); // Get RAW data and size
|
||||
|
||||
Image* image = img_decode(file_data, img_size, 0); // Decode RAW data to Image data
|
||||
|
||||
if (image->Type != IMAGE_BPP32) {
|
||||
image = img_convert(image, NULL, IMAGE_BPP32, 0, 0); // Convert image to format BPP32
|
||||
if (!image) {
|
||||
printf("Сonvert error!: \n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
image_blend = img_create(IMG_W+NEW_IMG_W, IMG_H, IMAGE_BPP32); // Create an empty layer
|
||||
img_fill_color(image_blend, IMG_W+NEW_IMG_W, IMG_H, sys_color_table.work_area); // Fill the layer with one color
|
||||
img_blend(image_blend, image, 0, 0, 0, 0, IMG_W, IMG_H); // Blending images to display the alpha channel.
|
||||
/* Reduce image size from 256x256 to 128x128 */
|
||||
image = img_scale(image, 0, 0, IMG_W, IMG_H, NULL, LIBIMG_SCALE_STRETCH , LIBIMG_INTER_BILINEAR, NEW_IMG_W, NEW_IMG_H);
|
||||
img_blend(image_blend, image, 256, 0, 0, 0, NEW_IMG_W, NEW_IMG_H);
|
||||
img_destroy(image); // Destroy image structure
|
||||
free(file_data); // Free allocated file_data buffer
|
||||
|
||||
/* Main event loop */
|
||||
while (1) {
|
||||
switch(get_os_event()){
|
||||
case KOLIBRI_EVENT_REDRAW:
|
||||
DrawGUI();
|
||||
break;
|
||||
case KOLIBRI_EVENT_BUTTON:
|
||||
if (get_os_button() == 1){
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
exit(0);
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 51 KiB |
@ -1,8 +0,0 @@
|
||||
#include <clayer/msgbox.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
msgbox *msg1 = NULL;
|
||||
msg1 = kolibri_new_msgbox("Title", "Text in window", 0, "Ok");
|
||||
kolibri_start_msgbox(msg1, NULL);
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <kos32sys1.h>
|
||||
#include <clayer/rasterworks.h>
|
||||
|
||||
// Sizes
|
||||
int x_size = 768, y_size = 256;
|
||||
|
||||
// Out example string
|
||||
char* string = "Пример/Example";
|
||||
|
||||
int main()
|
||||
{
|
||||
// Count length
|
||||
int ln_str = countUTF8Z(string, -1);
|
||||
|
||||
// Create image buffer
|
||||
void *buffi = malloc(x_size * y_size * 3 * sizeof(char) + 8);
|
||||
|
||||
// Set sizes
|
||||
*((int*)buffi) = x_size;
|
||||
*((int*)buffi+1) = y_size;
|
||||
|
||||
// Fill color
|
||||
memset((char*)buffi + 8, 0xFF, x_size * y_size * 3);
|
||||
|
||||
// Draw text on buffer
|
||||
drawText(buffi, 5, 0, string, ln_str, 0xFF000000, 0x30C18);
|
||||
drawText(buffi, 5, 32, string, ln_str, 0xFF000000, 0x1030C18);
|
||||
drawText(buffi, 5, 64, string, ln_str, 0xFF000000, 0x2030C18);
|
||||
drawText(buffi, 5, 96, string, ln_str, 0xFF000000, 0x4030C18);
|
||||
drawText(buffi, 5, 128, string, ln_str, 0xFF000000, 0x8030C18);
|
||||
drawText(buffi, 5, 160, string, ln_str, 0xFF000000, 0x0F031428);
|
||||
|
||||
while (1)
|
||||
{
|
||||
switch (get_os_event())
|
||||
{
|
||||
case 1:
|
||||
BeginDraw();
|
||||
DrawWindow(50, 50, 800, 300, "Rasterworks Example", 0x999999, 0x34);
|
||||
DrawBitmap(buffi + 8, 10, 10, 768, 256);
|
||||
EndDraw();
|
||||
break;
|
||||
case 2:
|
||||
get_key();
|
||||
break;
|
||||
case 3:
|
||||
if (get_os_button() == 1) exit(0);
|
||||
break;
|
||||
};
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
// demonstration conio use, color text
|
||||
// more info in conio.h
|
||||
|
||||
#include <conio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int i;
|
||||
if (con_init_console_dll()) return 1; // init fail
|
||||
|
||||
// con_write_asciiz("\033[0;31;42m test \n"); // red on green bk
|
||||
|
||||
for(i = 30; i < 48; i++)
|
||||
{
|
||||
con_printf("\033[%dmColor 0x%02X: ", i, i);
|
||||
con_write_asciiz("Text sample.");
|
||||
|
||||
con_printf(" printf %s test %d\n", "small", i);
|
||||
|
||||
}
|
||||
|
||||
con_exit(0);
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
#include <dir.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char *path=getcwd(NULL, PATH_MAX);
|
||||
printf("Current directory: %s\n", path);
|
||||
if(true==mkdir("test")){
|
||||
puts("Test folder created!");
|
||||
}
|
||||
else{
|
||||
puts("Error creating folder!");
|
||||
}
|
||||
short_file_info *info;
|
||||
int num = lsdir(path, &info);
|
||||
if(num==FS_ERROR)
|
||||
{
|
||||
puts("File system error.");
|
||||
return -1;
|
||||
}
|
||||
printf("Objects in the folder: %d\n", num);
|
||||
for(int j=0; j<num; j++)
|
||||
{
|
||||
printf("%s ", info[j].name);
|
||||
if(info[j].type==T_FOLDER)
|
||||
{
|
||||
printf("(Folder)\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("(File)\n");
|
||||
}
|
||||
}
|
||||
free(info);
|
||||
setcwd("/sys");
|
||||
path=getcwd(NULL, PATH_MAX);
|
||||
printf("Move to the directory: %s\n", path);
|
||||
free(path);
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
#include <conio.h>
|
||||
#include <clayer/http.h>
|
||||
#include <clayer/inputbox.h>
|
||||
|
||||
#define OK 200
|
||||
|
||||
int main() {
|
||||
if (con_init_console_dll()) return 1; // init fail
|
||||
con_write_asciiz("Wait, I'll ask you... when I'll done to fetch one site...\n");
|
||||
con_set_title("Dynamicaly linked app");
|
||||
|
||||
http_msg *h = http_get("http://kolibrios.org/en/", 0, HTTP_FLAG_BLOCK, "");
|
||||
http_long_receive(h);
|
||||
|
||||
if (h->status == OK) {
|
||||
con_write_string(h->content_ptr, h->content_length);
|
||||
} else {
|
||||
con_write_asciiz("Oops! Can't access to the page.\n");
|
||||
}
|
||||
char buffer[256];
|
||||
InputBox(buffer, "Hay!", "How do you do?", "Hmm?", 0, 256, 0);
|
||||
con_printf("Your answer is \"%s\"\n", buffer);
|
||||
con_write_string("It's surprising, isn't it?", 26);
|
||||
con_exit(0);
|
||||
return 0;
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
int i;
|
||||
char c;
|
||||
FILE *f;
|
||||
FILE *fin;
|
||||
FILE *fout;
|
||||
|
||||
//write to file
|
||||
f=fopen("testfile.txt","w");
|
||||
|
||||
for(i=0;i<50;i++)
|
||||
{
|
||||
fputc('1',f);
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
//append to file
|
||||
f=fopen("testfile.txt","a");
|
||||
|
||||
for(i=0;i<50;i++)
|
||||
{
|
||||
fputc('2',f);
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
//copy from testfile.txt to copyfile.txt
|
||||
|
||||
fin=fopen("testfile.txt","r");
|
||||
fout=fopen("copyfile.txt","w");
|
||||
|
||||
while((c=fgetc(fin))!=EOF)
|
||||
{
|
||||
fputc(c,fout);
|
||||
}
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void main(int argc, char *argv[]) {
|
||||
int c;
|
||||
if(argc<2)
|
||||
{
|
||||
puts("Usage: getopt_ex [options]\n");
|
||||
puts("-a Show 'Option a'");
|
||||
puts("-B Show 'Option B'");
|
||||
puts("-n [num] Show 'num'");
|
||||
}
|
||||
while ((c = getopt(argc, argv, "aBn:")) != EOF) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
puts("Option 'a'");
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
puts("Option 'B'");
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
printf("Option n: value=%d\n", atoi(optarg));
|
||||
break;
|
||||
|
||||
case '?':
|
||||
printf("ERROR: illegal option %s\n", argv[optind-1]);
|
||||
exit(0);
|
||||
|
||||
default:
|
||||
printf("WARNING: no handler for option %c\n", c);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
exit(0);
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
#include <kos32sys1.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <clayer/gb.h>
|
||||
|
||||
/// ===========================================================
|
||||
|
||||
int main()
|
||||
{
|
||||
GB_BMP b;
|
||||
unsigned event;
|
||||
|
||||
b.w = 300;
|
||||
b.h = 200;
|
||||
b.bmp = malloc (300*200*3);
|
||||
|
||||
gb_bar (&b, 4, 8, 4, 12, 0xff0000); // red
|
||||
gb_bar (&b, 10, 8, 4, 12, 0x00ff00); // green
|
||||
gb_bar (&b, 16, 8, 4, 12, 0x0000ff); // blue
|
||||
|
||||
gb_line(&b, 4, 30, 50, 30, 0xffffff); // white line
|
||||
gb_line(&b, 55, 4, 120, 60, 0xf0f033); // another line
|
||||
|
||||
gb_rect(&b, 65, 24, 100, 60, 0x2065ff); // rectangle
|
||||
|
||||
gb_circle(&b, 55, 95, 40, 0x20ff20); // circle
|
||||
|
||||
for (;;)
|
||||
{
|
||||
event = get_os_event();
|
||||
switch (event)
|
||||
{
|
||||
case 1:
|
||||
begin_draw();
|
||||
sys_create_window(50, 50, 310, 230, "testlibgb" ,0x34f0f0f0, 0x14);
|
||||
draw_bitmap(b.bmp, 5, 25, 300, 200);
|
||||
end_draw();
|
||||
break;
|
||||
case 2:
|
||||
get_key();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (1==get_os_button())
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
/// ===========================================================
|
@ -1,21 +0,0 @@
|
||||
#include <dlfcn.h>
|
||||
|
||||
/*Using the "coff" library in ktcc using "inputbox.obj" as an example*/
|
||||
|
||||
unsigned (*InputBox)(void* Buffer, char* Caption, char* Prompt, char* Default, unsigned long Flags, unsigned long BufferSize, void* RedrawProc);
|
||||
|
||||
void *InputBoxLib;
|
||||
|
||||
void load_coff()
|
||||
{
|
||||
InputBoxLib = dlopen("/sys/lib/inputbox.obj", RTLD_GLOBAL);
|
||||
InputBox = dlsym(InputBoxLib,"InputBox");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
load_coff();
|
||||
char buffer[256];
|
||||
InputBox(buffer, "Hay!", "How do you do?", "Hmm?", 10, 256, 0);
|
||||
dlclose(InputBoxLib);
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
#include <net/network.h>
|
||||
#include <conio.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main() {
|
||||
con_init_console_dll();
|
||||
networklib_init();
|
||||
con_set_title("http request demo using raw sockets");
|
||||
|
||||
char *host = "kolibrios.org";
|
||||
int port = 80;
|
||||
printf("Connecting to %s on port %d\n", host, port);
|
||||
|
||||
struct addrinfo *addr_info;
|
||||
char port_str[16]; sprintf(port_str, "%d", port);
|
||||
struct addrinfo hints;
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = AF_UNSPEC; // IPv4 or IPv6 doesnt matter
|
||||
hints.ai_socktype = SOCK_STREAM; // TCP stream sockets
|
||||
if (getaddrinfo(host, port_str, 0, &addr_info) != 0) {
|
||||
printf("Host %s not found!\n", host);
|
||||
freeaddrinfo(addr_info);
|
||||
exit(-1);
|
||||
}
|
||||
printf("IP address of %s is %s\n", host, inet_ntoa(addr_info->ai_addr->sin_addr));
|
||||
//printf("Host port = %d\n", addr_info->ai_addr->sin_port >> 8);
|
||||
|
||||
char request[256];
|
||||
sprintf(request, "GET /en/ HTTP/1.1\r\nHost: %s\r\n\r\n", host);
|
||||
printf("request = %s\n", request);
|
||||
|
||||
int sock = socket(AF_INET4, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
puts("Connecting...\n");
|
||||
if (connect(sock, addr_info->ai_addr, addr_info->ai_addrlen) != 0) {
|
||||
printf("Connection failed, errno = %d\n", errno);
|
||||
exit(errno);
|
||||
}
|
||||
puts("Connected successfully\n");
|
||||
|
||||
puts("Sending request...\n");
|
||||
if (send(sock, request, strlen(request), MSG_NOFLAG) == -1) {
|
||||
printf("Sending failed, errno = %d\n", errno);
|
||||
exit(errno);
|
||||
}
|
||||
puts("Request sended successfully, waiting for response...\n");
|
||||
|
||||
char buf[512 + 1];
|
||||
if (recv(sock, buf, 512, MSG_NOFLAG) == -1) {
|
||||
printf("Receive failed, errno = %d\n", errno);
|
||||
exit(errno);
|
||||
}
|
||||
|
||||
printf("Response = %s\n", buf);
|
||||
|
||||
freeaddrinfo(addr_info);
|
||||
|
||||
close(sock);
|
||||
puts("\n goodbye)\n");
|
||||
con_exit(0);
|
||||
return 0;
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
#include <net/network.h>
|
||||
#include <conio.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
struct addrinfo *res;
|
||||
char host[256];
|
||||
|
||||
void main()
|
||||
{
|
||||
con_init_console_dll();
|
||||
networklib_init();
|
||||
con_set_title("nslookup demo");
|
||||
printf("Host name to resolve: ");
|
||||
con_gets(host, 256);
|
||||
host[strlen(host)-1] = '\0';
|
||||
if(getaddrinfo(host ,0, 0, &res)!=0)
|
||||
{
|
||||
puts("Host not found!");
|
||||
freeaddrinfo(res);
|
||||
con_exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%s",inet_ntoa(res->ai_addr->sin_addr));
|
||||
freeaddrinfo(res);
|
||||
con_exit(0);
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
#include <net/socket.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
const char msg1[]="Hello!";
|
||||
char msg2='\0';
|
||||
|
||||
int main()
|
||||
{
|
||||
struct sockaddr addr={AF_INET4, PORT(23) , 0, 0};
|
||||
|
||||
int sk1=socket(AF_INET4, SOCK_STREAM, IPPROTO_TCP);
|
||||
printf("Open socket: %d. Status: %s\n",sk1, strerror(errno));
|
||||
|
||||
bind(sk1, &addr,sizeof(addr));
|
||||
printf("Socket binding. Status: %s\n", strerror(errno));
|
||||
|
||||
listen(sk1, 1);
|
||||
printf("Listening to a socket. Status: %s\n", strerror(errno));
|
||||
printf("You can connect to 'tcp server' via 'telnet' on localhost:23 !");
|
||||
|
||||
int sk2 = accept(sk1, &addr, sizeof(addr));
|
||||
printf("Accept done. Status: %s\n", strerror(errno));
|
||||
|
||||
send(sk2, msg1, strlen(msg1),MSG_NOFLAG);
|
||||
printf("Send message: '%s'. Status: %s\n",msg1, strerror(errno));
|
||||
puts("Received data:");
|
||||
while(msg2!='!')
|
||||
{
|
||||
recv(sk2, &msg2, 1, MSG_NOFLAG);
|
||||
printf("%c",msg2);
|
||||
}
|
||||
close(sk1);
|
||||
close(sk2);
|
||||
puts("\nGood bye!");
|
||||
exit(0);
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
#include <kos32sys1.h>
|
||||
int time1=0;
|
||||
int time2=0;
|
||||
int fps1=0;
|
||||
int timerend=0;
|
||||
|
||||
int Fps()
|
||||
{
|
||||
int tr;
|
||||
time1=get_tick_count();
|
||||
if (timerend==0)
|
||||
{
|
||||
time2=time1;
|
||||
timerend=time1;
|
||||
}
|
||||
|
||||
tr = time1 - timerend;
|
||||
|
||||
if ((time1 - time2) < 100)
|
||||
{
|
||||
fps1++;
|
||||
}
|
||||
else
|
||||
{
|
||||
draw_bar(330,8, 50,10,0xFFFFFF);
|
||||
draw_number_sys(fps1,330,8,10,0x0);
|
||||
fps1=0;
|
||||
time2=time1;
|
||||
}
|
||||
timerend=time1;
|
||||
return tr;
|
||||
}
|
||||
|
@ -1,313 +0,0 @@
|
||||
#include <tinygl/kosgl.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <kos32sys1.h>
|
||||
#include <kolibrisys.h>
|
||||
|
||||
int Fps();
|
||||
|
||||
struct {
|
||||
int x,y;
|
||||
int dx,dy;
|
||||
} win;
|
||||
|
||||
#define KEY_ESC 1
|
||||
#define KEY_F 33
|
||||
|
||||
char *title1 = "TinyGL in KolibriOS";
|
||||
char *title2 = "F full screen";
|
||||
char *title3 = "ESC - exit";
|
||||
char *fps = "FPS:";
|
||||
|
||||
unsigned char FullScreen = 0;
|
||||
unsigned char skin = 3;
|
||||
|
||||
struct process_table_entry *pri;
|
||||
KOSGLContext cgl;
|
||||
|
||||
static GLfloat view_rotx=20.0, view_roty=30.0, view_rotz=0.0;
|
||||
static GLint gear1, gear2, gear3;
|
||||
static GLfloat angle = 0.0;
|
||||
|
||||
static GLuint limit;
|
||||
static GLuint count = 1;
|
||||
|
||||
/*
|
||||
* Draw a gear wheel. You'll probably want to call this function when
|
||||
* building a display list since we do a lot of trig here.
|
||||
*
|
||||
* Input: inner_radius - radius of hole at center
|
||||
* outer_radius - radius at center of teeth
|
||||
* width - width of gear
|
||||
* teeth - number of teeth
|
||||
* tooth_depth - depth of tooth
|
||||
*/
|
||||
static void gear( GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
|
||||
GLint teeth, GLfloat tooth_depth )
|
||||
{
|
||||
GLint i;
|
||||
GLfloat r0, r1, r2;
|
||||
GLfloat angle, da;
|
||||
GLfloat u, v, len;
|
||||
|
||||
r0 = inner_radius;
|
||||
r1 = outer_radius - tooth_depth/2.0;
|
||||
r2 = outer_radius + tooth_depth/2.0;
|
||||
|
||||
da = 2.0*M_PI / teeth / 4.0;
|
||||
|
||||
glShadeModel( GL_FLAT );
|
||||
|
||||
glNormal3f( 0.0, 0.0, 1.0 );
|
||||
|
||||
/* draw front face */
|
||||
glBegin( GL_QUAD_STRIP );
|
||||
for (i=0;i<=teeth;i++) {
|
||||
angle = i * 2.0*M_PI / teeth;
|
||||
glVertex3f( r0*cos(angle), r0*sin(angle), width*0.5 );
|
||||
glVertex3f( r1*cos(angle), r1*sin(angle), width*0.5 );
|
||||
glVertex3f( r0*cos(angle), r0*sin(angle), width*0.5 );
|
||||
glVertex3f( r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5 );
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw front sides of teeth */
|
||||
glBegin( GL_QUADS );
|
||||
da = 2.0*M_PI / teeth / 4.0;
|
||||
for (i=0;i<teeth;i++) {
|
||||
angle = i * 2.0*M_PI / teeth;
|
||||
|
||||
glVertex3f( r1*cos(angle), r1*sin(angle), width*0.5 );
|
||||
glVertex3f( r2*cos(angle+da), r2*sin(angle+da), width*0.5 );
|
||||
glVertex3f( r2*cos(angle+2*da), r2*sin(angle+2*da), width*0.5 );
|
||||
glVertex3f( r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5 );
|
||||
}
|
||||
glEnd();
|
||||
|
||||
glNormal3f( 0.0, 0.0, -1.0 );
|
||||
|
||||
/* draw back face */
|
||||
glBegin( GL_QUAD_STRIP );
|
||||
for (i=0;i<=teeth;i++) {
|
||||
angle = i * 2.0*M_PI / teeth;
|
||||
glVertex3f( r1*cos(angle), r1*sin(angle), -width*0.5 );
|
||||
glVertex3f( r0*cos(angle), r0*sin(angle), -width*0.5 );
|
||||
glVertex3f( r1*cos(angle+3*da), r1*sin(angle+3*da), -width*0.5 );
|
||||
glVertex3f( r0*cos(angle), r0*sin(angle), -width*0.5 );
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw back sides of teeth */
|
||||
glBegin( GL_QUADS );
|
||||
da = 2.0*M_PI / teeth / 4.0;
|
||||
for (i=0;i<teeth;i++) {
|
||||
angle = i * 2.0*M_PI / teeth;
|
||||
|
||||
glVertex3f( r1*cos(angle+3*da), r1*sin(angle+3*da), -width*0.5 );
|
||||
glVertex3f( r2*cos(angle+2*da), r2*sin(angle+2*da), -width*0.5 );
|
||||
glVertex3f( r2*cos(angle+da), r2*sin(angle+da), -width*0.5 );
|
||||
glVertex3f( r1*cos(angle), r1*sin(angle), -width*0.5 );
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw outward faces of teeth */
|
||||
glBegin( GL_QUAD_STRIP );
|
||||
for (i=0;i<teeth;i++) {
|
||||
angle = i * 2.0*M_PI / teeth;
|
||||
|
||||
glVertex3f( r1*cos(angle), r1*sin(angle), width*0.5 );
|
||||
glVertex3f( r1*cos(angle), r1*sin(angle), -width*0.5 );
|
||||
u = r2*cos(angle+da) - r1*cos(angle);
|
||||
v = r2*sin(angle+da) - r1*sin(angle);
|
||||
len = sqrt( u*u + v*v );
|
||||
u /= len;
|
||||
v /= len;
|
||||
glNormal3f( v, -u, 0.0 );
|
||||
glVertex3f( r2*cos(angle+da), r2*sin(angle+da), width*0.5 );
|
||||
glVertex3f( r2*cos(angle+da), r2*sin(angle+da), -width*0.5 );
|
||||
glNormal3f( cos(angle), sin(angle), 0.0 );
|
||||
glVertex3f( r2*cos(angle+2*da), r2*sin(angle+2*da), width*0.5 );
|
||||
glVertex3f( r2*cos(angle+2*da), r2*sin(angle+2*da), -width*0.5 );
|
||||
u = r1*cos(angle+3*da) - r2*cos(angle+2*da);
|
||||
v = r1*sin(angle+3*da) - r2*sin(angle+2*da);
|
||||
glNormal3f( v, -u, 0.0 );
|
||||
glVertex3f( r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5 );
|
||||
glVertex3f( r1*cos(angle+3*da), r1*sin(angle+3*da), -width*0.5 );
|
||||
glNormal3f( cos(angle), sin(angle), 0.0 );
|
||||
}
|
||||
|
||||
glVertex3f( r1*cos(0.0), r1*sin(0.0), width*0.5 );
|
||||
glVertex3f( r1*cos(0.0), r1*sin(0.0), -width*0.5 );
|
||||
|
||||
glEnd();
|
||||
|
||||
glShadeModel( GL_SMOOTH );
|
||||
|
||||
/* draw inside radius cylinder */
|
||||
glBegin( GL_QUAD_STRIP );
|
||||
for (i=0;i<=teeth;i++) {
|
||||
angle = i * 2.0*M_PI / teeth;
|
||||
glNormal3f( -cos(angle), -sin(angle), 0.0 );
|
||||
glVertex3f( r0*cos(angle), r0*sin(angle), -width*0.5 );
|
||||
glVertex3f( r0*cos(angle), r0*sin(angle), width*0.5 );
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void init( void )
|
||||
{
|
||||
static GLfloat pos[4] = {5.0, 5.0, 10.0, 1.0 };
|
||||
static GLfloat red[4] = {0.8, 0.1, 0.0, 1.0 };
|
||||
static GLfloat green[4] = {0.0, 0.8, 0.2, 1.0 };
|
||||
static GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0 };
|
||||
|
||||
glLightfv( GL_LIGHT0, GL_POSITION, pos );
|
||||
glEnable( GL_CULL_FACE );
|
||||
glEnable( GL_LIGHTING );
|
||||
glEnable( GL_LIGHT0 );
|
||||
glEnable( GL_DEPTH_TEST );
|
||||
|
||||
/* make the gears */
|
||||
gear1 = glGenLists(1);
|
||||
glNewList(gear1, GL_COMPILE);
|
||||
glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red );
|
||||
gear( 1.0, 4.0, 1.0, 20, 0.7 );
|
||||
glEndList();
|
||||
|
||||
gear2 = glGenLists(1);
|
||||
glNewList(gear2, GL_COMPILE);
|
||||
glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green );
|
||||
gear( 0.5, 2.0, 2.0, 10, 0.7 );
|
||||
glEndList();
|
||||
|
||||
gear3 = glGenLists(1);
|
||||
glNewList(gear3, GL_COMPILE);
|
||||
glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue );
|
||||
gear( 1.3, 2.0, 0.5, 10, 0.7 );
|
||||
glEndList();
|
||||
|
||||
glEnable( GL_NORMALIZE );
|
||||
|
||||
glViewport(0, 0, (GLint)500, (GLint)480);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum( -1.0, 1.0, -1, 1, 5.0, 60.0 );
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef( 0.0, 0.0, -40.0 );
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
}
|
||||
|
||||
void reshape()
|
||||
{
|
||||
_ksys_get_process_table(pri, -1);
|
||||
glViewport(0, 0, pri->winx_size, pri->winy_size-20);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(45.0, (GLfloat)pri->winx_size/pri->winy_size, 1.0, 60.0);
|
||||
glTranslatef( 0.0, 0.0, 20.0 );
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
}
|
||||
|
||||
void disabletgl()
|
||||
{
|
||||
kosglDestroyContext(cgl);
|
||||
free(pri);
|
||||
}
|
||||
|
||||
void Title()
|
||||
{
|
||||
_ksys_write_text(300,8,0x0,fps,strlen(fps));
|
||||
_ksys_write_text(8,8,0x0,title1,strlen(title1));
|
||||
_ksys_write_text(180,8,0x0,title2,strlen(title2));
|
||||
_ksys_write_text(600,8,0x0,title3,strlen(title3));
|
||||
}
|
||||
|
||||
|
||||
void draw_window()
|
||||
{
|
||||
begin_draw();
|
||||
sys_create_window(win.x, win.y, win.dx, win.dy,"Gears", 0xFFFFFF, 0x34);
|
||||
Title();
|
||||
end_draw();
|
||||
}
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
pri=malloc(sizeof(struct process_table_entry));
|
||||
win.x = 100;
|
||||
win.y = 100;
|
||||
win.dx = 400;
|
||||
win.dy = 400;
|
||||
draw_window();
|
||||
_ksys_set_keyboard_mode(1);
|
||||
cgl = kosglCreateContext( 0, 0);
|
||||
kosglMakeCurrent( 0, 20, win.dx, win.dy-20, cgl);
|
||||
init();
|
||||
reshape();
|
||||
do{
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
glPushMatrix();
|
||||
glRotatef( view_rotx, 1.0, 0.0, 0.0 );
|
||||
glRotatef( view_roty, 0.0, 1.0, 0.0 );
|
||||
glRotatef( view_rotz, 0.0, 0.0, 1.0 );
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef( -2.0, -2.0, 0.0 );
|
||||
glRotatef( angle, 0.0, 0.0, 1.0 );
|
||||
glCallList(gear1);
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef( 4.1, -2.0, 0.0 );
|
||||
glRotatef( -2.0*angle-9.0, 0.0, 0.0, 1.0 );
|
||||
glCallList(gear2);
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef( -2.1, 4.2, 0.0 );
|
||||
glRotatef( -2.0*angle-25.0, 0.0, 0.0, 1.0 );
|
||||
glCallList(gear3);
|
||||
glPopMatrix();
|
||||
glPopMatrix();
|
||||
kosglSwapBuffers();
|
||||
|
||||
angle += 0.01 + 0.3* Fps();
|
||||
switch(_ksys_check_for_event()){
|
||||
case KOLIBRI_EVENT_REDRAW: draw_window();
|
||||
reshape();
|
||||
break;
|
||||
|
||||
case KOLIBRI_EVENT_KEY:
|
||||
switch(get_key().ctrl_key){
|
||||
case KEY_F:
|
||||
if(!FullScreen){
|
||||
skin=0;
|
||||
int screen_size_x;
|
||||
int screen_size_y;
|
||||
_ksys_get_screen_size(&screen_size_x, &screen_size_y);
|
||||
sys_change_window(0,0,screen_size_x,screen_size_y);
|
||||
draw_window();
|
||||
reshape();
|
||||
FullScreen = 1;
|
||||
}
|
||||
else{
|
||||
skin=3;
|
||||
draw_window();
|
||||
sys_change_window(win.x,win.y, win.dx, win.dy);
|
||||
reshape();
|
||||
FullScreen = 0;
|
||||
};
|
||||
break;
|
||||
case KEY_ESC: disabletgl();
|
||||
return;}
|
||||
break;
|
||||
|
||||
case 3: disabletgl();
|
||||
return;
|
||||
}
|
||||
} while(1);
|
||||
}
|
@ -1,148 +0,0 @@
|
||||
/*
|
||||
newlib-style window example
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include "kos32sys1.h"
|
||||
|
||||
struct kolibri_system_colors sys_color_table;
|
||||
void __attribute__ ((noinline)) debug_board_printf(const char *format,...);
|
||||
void __attribute__ ((noinline)) debug_board_write_str(const char* str);
|
||||
|
||||
char statusbar[255];
|
||||
char proc_info[1024];
|
||||
char text_line[255];
|
||||
|
||||
enum BUTTONS
|
||||
{
|
||||
BTN_QUIT = 1,
|
||||
BTN_POP = 10,
|
||||
BTN_UNLOCK = 11
|
||||
};
|
||||
|
||||
#define FONT_W 8
|
||||
#define FONT_H 14
|
||||
#define LINES 10
|
||||
|
||||
void draw_window()
|
||||
{
|
||||
int win_hight, win_width, i, pos_y = get_skin_height() + 36; // 60 == 24+36
|
||||
|
||||
// start redraw
|
||||
begin_draw();
|
||||
// define&draw window
|
||||
sys_create_window(10, 40, 600, 400, "My window", /*sys_color_table.work_area*/0xFFFFFF, 0x13);
|
||||
|
||||
get_proc_info(proc_info);
|
||||
win_width = *(int*)(proc_info + 0x3E); // client, 2A windows
|
||||
win_hight = *(int*)(proc_info + 0x42); // client, 2E windows
|
||||
|
||||
define_button((10 << 16) + 80, (30 << 16) + 20, BTN_POP, sys_color_table.work_button);
|
||||
draw_text_sys("BUTTON1", 15, 34, 0, 0x90000000 | sys_color_table.work_button_text); //0x80000000 asciiz
|
||||
|
||||
define_button((100 << 16) + 100, (30 << 16) + 20, BTN_UNLOCK, sys_color_table.work_button);
|
||||
draw_text_sys("BUTTTON2", 110, 34, 0, 0x90000000 | sys_color_table.work_button_text);
|
||||
|
||||
// display statusbar
|
||||
draw_bar(6, win_hight - 17, win_width - 11, 12, 0x80000000 | sys_color_table.work_area); //0x80000000 gradient
|
||||
draw_text_sys(statusbar, 10, win_hight - 15, 0, 0x80000000 | sys_color_table.work_text);
|
||||
|
||||
// display strings
|
||||
for (i = LINES; i > 0; i--)
|
||||
{
|
||||
tiny_snprintf (text_line, sizeof text_line, "Line[%d]<<Just a text>>", i);
|
||||
|
||||
text_line[(win_width - 10 - 5) / FONT_W + 1] = '\0'; // clip text size, seems to big lines crashing OS, and form len by window size
|
||||
// draw_number_sys(nbytes, 5, pos_y, 6, 0x10000000); 8x12 font
|
||||
draw_text_sys(text_line, 5, pos_y, 0, 0x90000000 /*| sys_color_table.work_text*/);
|
||||
pos_y += FONT_H;
|
||||
|
||||
if(pos_y + 29 > win_hight) break; // 12 font + 12 statusbar + 5 border
|
||||
}
|
||||
|
||||
// end redraw
|
||||
end_draw();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int gui_event;
|
||||
uint32_t pressed_button = 0, mouse_button;
|
||||
pos_t mouse_pos;
|
||||
strcpy(statusbar, "Program running...Double click on TEXT for details");
|
||||
|
||||
get_system_colors(&sys_color_table);
|
||||
set_event_mask(0xC0000027); // mouse events only when focused window and mouse inside
|
||||
|
||||
do /* Start of main activity loop */
|
||||
{
|
||||
// gui_event = wait_for_event(10); // 100 = 1 sec, case you have background work
|
||||
gui_event = get_os_event();
|
||||
switch(gui_event)
|
||||
{
|
||||
case KOLIBRI_EVENT_NONE:
|
||||
// background work
|
||||
break;
|
||||
case KOLIBRI_EVENT_REDRAW:
|
||||
draw_window();
|
||||
break;
|
||||
case KOLIBRI_EVENT_KEY:
|
||||
// scroll
|
||||
break;
|
||||
case KOLIBRI_EVENT_BUTTON:
|
||||
pressed_button = get_os_button();
|
||||
switch (pressed_button)
|
||||
{
|
||||
case BTN_POP:
|
||||
strcpy(statusbar, "POP pressed....");
|
||||
draw_window();
|
||||
break;
|
||||
case BTN_UNLOCK:
|
||||
strcpy(statusbar, "UNLOCK pressed....");
|
||||
draw_window();
|
||||
break;
|
||||
case BTN_QUIT:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case KOLIBRI_EVENT_MOUSE:
|
||||
mouse_pos = get_mouse_pos(POS_WINDOW); // window relative
|
||||
mouse_button = get_mouse_eventstate();
|
||||
debug_board_printf("mouse ev (%d,%d)%x\n", mouse_pos.x, mouse_pos.y, mouse_button);
|
||||
if (mouse_button & (1<<24)) // double click
|
||||
{
|
||||
int n = (mouse_pos.y - 60) / FONT_H;
|
||||
if (n < 0 || n >= LINES) break;
|
||||
debug_board_printf("click on str(%d), clip slot(%d)\n", n, LINES - n - 1);
|
||||
tiny_sprintf(statusbar, "click on str(%d), clip slot(%d)\n", n, LINES - n - 1);
|
||||
draw_window();
|
||||
}
|
||||
// ignore
|
||||
break;
|
||||
}
|
||||
} while(1) ; /* End of main activity loop */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void __attribute__ ((noinline)) debug_board_write_str(const char* str){
|
||||
while(*str)
|
||||
debug_board_write_byte(*str++);
|
||||
}
|
||||
|
||||
void __attribute__ ((noinline)) debug_board_printf(const char *format,...)
|
||||
{
|
||||
va_list ap;
|
||||
char log_board[300];
|
||||
|
||||
va_start (ap, format);
|
||||
tiny_vsnprintf(log_board, sizeof log_board, format, ap);
|
||||
va_end(ap);
|
||||
debug_board_write_str(log_board);
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user