From d9820a5748d91e2db3faefcd7f43a313397c33af Mon Sep 17 00:00:00 2001 From: IgorA Date: Fri, 22 Sep 2023 07:12:51 +0000 Subject: [PATCH] bcc32: add rasterworks example git-svn-id: svn://kolibrios.org@9940 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/bcc32/examples/rasterworks/Makefile | 19 ++++++ .../examples/rasterworks/rasterworks.cpp | 59 +++++++++++++++++++ .../examples/rasterworks/rasterworks_cpp.bat | 15 +++++ programs/bcc32/include/l_libc.h | 51 ++++++++++++++++ programs/bcc32/include/l_rasterworks.h | 17 ++++++ 5 files changed, 161 insertions(+) create mode 100644 programs/bcc32/examples/rasterworks/Makefile create mode 100644 programs/bcc32/examples/rasterworks/rasterworks.cpp create mode 100644 programs/bcc32/examples/rasterworks/rasterworks_cpp.bat create mode 100644 programs/bcc32/include/l_libc.h create mode 100644 programs/bcc32/include/l_rasterworks.h diff --git a/programs/bcc32/examples/rasterworks/Makefile b/programs/bcc32/examples/rasterworks/Makefile new file mode 100644 index 0000000000..8153f973dc --- /dev/null +++ b/programs/bcc32/examples/rasterworks/Makefile @@ -0,0 +1,19 @@ +# Path to /programs +SVN_PROGR:=../../.. + +# Path to /programs/bcc32 +SVN_BCC32:=$(SVN_PROGR)/bcc32 + +# Path to t2fasm +T2FASM:=$(SVN_BCC32)/t2fasm + +# Path to include +INCLUDE:=$(SVN_BCC32)/include + +# Path to Bin folder +KOS32_BCC:=/home/autobuild/borlandcpp/bin + +# Filename without .cpp +FILENAME:=rasterworks + +include $(SVN_BCC32)/Makefile_app diff --git a/programs/bcc32/examples/rasterworks/rasterworks.cpp b/programs/bcc32/examples/rasterworks/rasterworks.cpp new file mode 100644 index 0000000000..de2bbf246c --- /dev/null +++ b/programs/bcc32/examples/rasterworks/rasterworks.cpp @@ -0,0 +1,59 @@ +#include +#include +#include +#include + +using namespace Kolibri; + +const char header[] = "Rasterworks example"; +char library_path[2048]; + +namespace Kolibri{ + char CurrentDirectoryPath[2048]; +} + +void *buffi; + +bool KolibriOnStart(TStartData &kos_start, TThreadData /*th*/) +{ + kos_start.Left = 10; + kos_start.Top = 40; + kos_start.Width = 800; + kos_start.Height = 300; + kos_start.WinData.WindowColor = 0xd0d0d0; + kos_start.WinData.WindowType = 0x33; // 0x34 - fixed, 0x33 - not fixed + kos_start.WinData.Title = header; + if(LoadLibrary("rasterworks.obj", library_path, "/sys/lib/rasterworks.obj", &import_rasterworks)) + { + buffi = new char[768*256*3 +8]; + *((long*)buffi) = 768; + *((long*)buffi+1) = 256; + } else { + buffi = 0; + } + return true; +} + +void KolibriOnPaint(void) +{ + DrawText(10,5, 0x30000000, "Системный шрифт 8x16"); + if(!buffi) return; + + long ln_str = countUTF8Z("Пример работы", -1); + + memset((char*)buffi+8, (char)-1, 768*256*3); + + drawText(buffi, 0, 0, "Пример работы", ln_str, 0xFF000000, 0x30C18); + drawText(buffi, 0, 32, "Пример работы", ln_str, 0xFF000000, 0x1030C18); + drawText(buffi, 0, 64, "Пример работы", ln_str, 0xFF000000, 0x2030C18); + drawText(buffi, 0, 96, "Пример работы", ln_str, 0xFF000000, 0x4030C18); + drawText(buffi, 0,128, "Пример работы", ln_str, 0xFF000000, 0x8030C18); + drawText(buffi, 0,160, "Пример работы", ln_str, 0xFF000000, 0x0F031428); + + PutImage((char*)buffi+8, 5, 25, 768, 256); +} + +bool KolibriOnClose(TThreadData /*th*/) { + if(buffi) {delete buffi; buffi = 0;} + return true; +} \ No newline at end of file diff --git a/programs/bcc32/examples/rasterworks/rasterworks_cpp.bat b/programs/bcc32/examples/rasterworks/rasterworks_cpp.bat new file mode 100644 index 0000000000..2597a93f99 --- /dev/null +++ b/programs/bcc32/examples/rasterworks/rasterworks_cpp.bat @@ -0,0 +1,15 @@ +Set NAME=rasterworks +Set BCC_DIR=..\..\..\bcc32 +kos32-bcc -S -v- -R- -6 -a4 -O2 -Og -Oi -Ov -OS -k- -D__KOLIBRI__ -I..\..\..\bcc32\include %NAME%.cpp + +echo STACKSIZE equ 8192> kos_make.inc +echo include "%BCC_DIR%\include\kos_start.inc">> kos_make.inc +echo include "%BCC_DIR%\include\kos_func.inc">> kos_make.inc +echo include "%BCC_DIR%\include\kos_heap.inc">> kos_make.inc + +echo include "kos_make.inc" > f_%NAME%.asm +t2fasm < %NAME%.asm >> f_%NAME%.asm +fasm f_%NAME%.asm %NAME%.kex +if exist %NAME%.kex kpack %NAME%.kex +if exist %NAME%.kex del kos_make.inc +pause diff --git a/programs/bcc32/include/l_libc.h b/programs/bcc32/include/l_libc.h new file mode 100644 index 0000000000..5fca78fbdf --- /dev/null +++ b/programs/bcc32/include/l_libc.h @@ -0,0 +1,51 @@ +#ifndef __L_LIBC_H_INCLUDED_ +#define __L_LIBC_H_INCLUDED_ +// +// libc.obj +// + +// +// libc - import table +// +#define import_libc sprintf +//int (* scanf)(char* __buffer, const char* __format, ...) = (int (*)(char*, const char*, ...))&"scanf"; //run console aplication ??? +int (* sprintf)(char* __buffer, const char* __format, ...) = (int (*)(char*, const char*, ...))&"sprintf"; +#ifndef __KOS_LIB_H_INCLUDED_ + char* (* strchr)(const char* string, int c) = (char* (*)(const char*, int))&"strchr"; +#endif +char* (* strcat)(char* str1, const char* str2) = (char* (*)(char*, const char*))&"strcat"; +#ifndef __KOS_LIB_H_INCLUDED_ + int (* strcmp)(const char* str1, const char* str2) = (int (*)(const char*, const char*))&"strcmp"; +#endif +int (* strcoll)(const char* str1, const char* str2) = (int (*)(const char*, const char*))&"strcoll"; +#ifndef __KOS_LIB_H_INCLUDED_ + char* (* strcpy)(char* str1, const char* str2) = (char* (*)(char*, const char*))&"strcpy"; +#endif +int (* strcspn)(const char* string, const char* strCharSet) = (int (*)(const char*, const char*))&"strcspn"; +char* (* strdup)(const char* str) = (char* (*)(const char*))&"strdup"; +char* (* strerror)(int err) = (char* (*)(int))&"strerror"; +#ifndef __KOS_LIB_H_INCLUDED_ + int (* strlen)(const char* string) = (int (*)(const char*))&"strlen"; +#endif +char* (* strncat)(char* strDest, const char* strSource, int count) = (char* (*)(char*, const char*, int))&"strncat"; +int (* strncmp)(const char* str1, const char* str2, int count) = (int (*)(const char*, const char*, int))&"strncmp"; +#ifndef __KOS_LIB_H_INCLUDED_ + char* (* strncpy)(char* strDest, const char* strSource, int count) = (char* (*)(char*, const char*, int))&"strncpy"; +#endif +char* (* strrchr)(const char* s, int c) = (char* (*)(const char*, int))&"strrchr"; +char* (* strrev)(char* p) = (char* (*)(char*))&"strrev"; +int (* strspn)(const char* string, const char* strCharSet) = (int (*)(const char*, const char*))&"strspn"; +#ifndef __KOS_LIB_H_INCLUDED_ + char* (* strstr)(const char* s, const char* find) = (char* (*)(const char*, const char*))&"strstr"; +#endif +char* (* strtok)(char* s, const char* delim) = (char* (*)(char*, const char*))&"strtok"; +int (* strxfrm)(char* strDest, const char* strSource, int count) = (int (*)(char*, const char*, int))&"strxfrm"; + +double (* exp)(double x) = (double (*)(double))&"exp"; +double (* fabs)(double x) = (double (*)(double))&"fabs"; + +asm{ + dd 0,0 +} + +#endif \ No newline at end of file diff --git a/programs/bcc32/include/l_rasterworks.h b/programs/bcc32/include/l_rasterworks.h new file mode 100644 index 0000000000..d27667c113 --- /dev/null +++ b/programs/bcc32/include/l_rasterworks.h @@ -0,0 +1,17 @@ +#ifndef __L_RASTERWORKS_INCLUDED_ +#define __L_RASTERWORKS_INCLUDED_ +// +// rasterworks - import table +// +#define import_rasterworks drawText + +void (__stdcall* drawText)(void *canvas, long x, long y, const char *string, long charQuantity, long fontColor, long params) = (void (__stdcall*)(void*, long, long, const char*, long, long, long))&"drawText"; +long (__stdcall* countUTF8Z)(const char *string, long byteQuantity) = (long (__stdcall*)(const char*, long))&"countUTF8Z"; +long (__stdcall* charsFit)(long areaWidth, long charHeight) = (long (__stdcall*)(long, long))&"charsFit"; +long (__stdcall* strWidth)(long charQuantity, long charHeight) = (long (__stdcall*)(long, long))&"strWidth"; + +asm{ + dd 0,0 +} +#endif /* __L_RASTERWORKS_INCLUDED_ */ +