From d45967888e9549481f7a09db6bfe69c3801d85ee Mon Sep 17 00:00:00 2001 From: maxcodehack Date: Fri, 6 Nov 2020 13:40:38 +0000 Subject: [PATCH] Add example git-svn-id: svn://kolibrios.org@8144 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/bcc32/examples/window/Makefile | 18 ++++++++++ programs/bcc32/examples/window/hello.cpp | 38 ++++++++++++++++++++ programs/bcc32/examples/window/hello_cpp.bat | 6 ++++ programs/bcc32/examples/window/kos_make.inc | 7 ++++ programs/bcc32/patch/Makefile | 4 +++ programs/bcc32/patch/compile.txt | 8 +++++ programs/bcc32/patch/kos32-bcc.asm | 27 ++++++++++++++ 7 files changed, 108 insertions(+) create mode 100755 programs/bcc32/examples/window/Makefile create mode 100755 programs/bcc32/examples/window/hello.cpp create mode 100755 programs/bcc32/examples/window/hello_cpp.bat create mode 100755 programs/bcc32/examples/window/kos_make.inc create mode 100755 programs/bcc32/patch/Makefile create mode 100755 programs/bcc32/patch/compile.txt create mode 100755 programs/bcc32/patch/kos32-bcc.asm diff --git a/programs/bcc32/examples/window/Makefile b/programs/bcc32/examples/window/Makefile new file mode 100755 index 0000000000..c2e061b186 --- /dev/null +++ b/programs/bcc32/examples/window/Makefile @@ -0,0 +1,18 @@ +SVN_BCC32:=../.. +T2FASM:=$(SVN_BCC32)/t2fasm +INCLUDE:=$(SVN_BCC32)/include + +# Path to Bin folder +KOS32_BCC:=/home/autobuild/borlandcpp/bin + +# Filename +FN:=hello + +hello_world: + wine $(KOS32_BCC)/kos32-bcc -S -v- -R- -6 -a4 -O2 -Og -Oi -Ov -OS -k- -D__KOLIBRI__ -I$(INCLUDE) $(FN).cpp + echo 'include "kos_make.inc"' > f_$(FN).asm + $(T2FASM)/t2fasm < $(FN).asm >> f_$(FN).asm + fasm f_$(FN).asm $(FN).kex + + rm f_$(FN).asm + rm $(FN).asm diff --git a/programs/bcc32/examples/window/hello.cpp b/programs/bcc32/examples/window/hello.cpp new file mode 100755 index 0000000000..9995749129 --- /dev/null +++ b/programs/bcc32/examples/window/hello.cpp @@ -0,0 +1,38 @@ +#include +#include +#include + +using namespace Kolibri; + +const char header[] = "Title"; +const char string[] = "Text"; + +bool KolibriOnStart(TStartData &kos_start, TThreadData th) +{ + kos_start.Left = 10; + kos_start.Top = 40; + kos_start.Width = 150; + kos_start.Height = 80; + kos_start.WinData.WindowColor = 0xFFFFFF; + kos_start.WinData.Title = header; + return true; +} + +void KolibriOnPaint(void) +{ + DrawText(10, 10, 0, string); +} +bool KolibriOnClose(TThreadData th) +{ + return true; +} +int KolibriOnIdle(TThreadData th) +{ + return -1; +} +void KolibriOnSize(int window_rect[], TThreadData th) {} +void KolibriOnKeyPress(TThreadData th) +{ + GetKey(); +} +void KolibriOnMouse(TThreadData th) {} diff --git a/programs/bcc32/examples/window/hello_cpp.bat b/programs/bcc32/examples/window/hello_cpp.bat new file mode 100755 index 0000000000..c3128d40ed --- /dev/null +++ b/programs/bcc32/examples/window/hello_cpp.bat @@ -0,0 +1,6 @@ +kos32-bcc -S -v- -R- -6 -a4 -O2 -Og -Oi -Ov -OS -k- -D__KOLIBRI__ -Iinclude hello.cpp +echo include "kos_make.inc" > f_hello.asm +t2fasm < hello.asm >> f_hello.asm +fasm f_hello.asm hello.kex +kpack hello.kex +pause \ No newline at end of file diff --git a/programs/bcc32/examples/window/kos_make.inc b/programs/bcc32/examples/window/kos_make.inc new file mode 100755 index 0000000000..45f15fb720 --- /dev/null +++ b/programs/bcc32/examples/window/kos_make.inc @@ -0,0 +1,7 @@ +STACKSIZE equ 102400 +HEAPSIZE equ 102400 + +include "..\..\..\proc32.inc" +include "..\..\include\kos_start.inc" +include "..\..\include\kos_func.inc" +include "..\..\include\kos_heap.inc" diff --git a/programs/bcc32/patch/Makefile b/programs/bcc32/patch/Makefile new file mode 100755 index 0000000000..2095bb6592 --- /dev/null +++ b/programs/bcc32/patch/Makefile @@ -0,0 +1,4 @@ +# For success compiling, you should put bcc32.exe here +kos32-bcc: + fasm kos32-bcc.asm kos32-bcc.exe +# Move to BCC 5.5.1 folder diff --git a/programs/bcc32/patch/compile.txt b/programs/bcc32/patch/compile.txt new file mode 100755 index 0000000000..baefd5eba8 --- /dev/null +++ b/programs/bcc32/patch/compile.txt @@ -0,0 +1,8 @@ +В файле kos32-bcc.asm находится патч для компилятора Borland C++ 5.5.1. +После применения данного патча компилятор в режиме компиляции с опцией '-S' +выдает *.asm файлы с синтаксисом более похожим на ассемблер fasm. + +Применение: +fasm kos32-bcc.asm kos32-bcc.exe + +bcc32.exe должен лежать рядом с kos32-bcc.asm diff --git a/programs/bcc32/patch/kos32-bcc.asm b/programs/bcc32/patch/kos32-bcc.asm new file mode 100755 index 0000000000..313bfdf384 --- /dev/null +++ b/programs/bcc32/patch/kos32-bcc.asm @@ -0,0 +1,27 @@ +; patch for new fasm +use32 + +file 'bcc32.exe':0,0x4a8f +dd 0x90909090,0x90909090 ;fix end proc +db 0xb8 +dd 0x4a626b + +file 'bcc32.exe':0x4a9c,0x5753-0x4a9c +dd 0x4b2472 ;fix label byte +file 'bcc32.exe':0x5757,0x575a-0x5757 +dd 0x4b2472 ;fix proc near +file 'bcc32.exe':0x575e,0x5761-0x575e +dd 0x4b2472 ;fix label word +file 'bcc32.exe':0x5765,0x5768-0x5765 +dd 0x4b2472 ;fix label dword +file 'bcc32.exe':0x576c,0x576f-0x576c +dd 0x4b2472 ;fix label qword +file 'bcc32.exe':0x5773,0x5776-0x5773 +dd 0x4b2472 ;fix label tbyte + +file 'bcc32.exe':0x577a,0x56216-0x577a +db '_' ;fix '$' to '_' +file 'bcc32.exe':0x56217,0xd4400-0x56217 + +;0x4b2472 - ':',13,10,0 +;0x4a626b - 13,10,0